aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS3
-rw-r--r--Documentation/00-INDEX2
-rw-r--r--Documentation/Changes2
-rw-r--r--Documentation/DMA-API.txt2
-rw-r--r--Documentation/DMA-ISA-LPC.txt2
-rw-r--r--Documentation/DocBook/writing_usb_driver.tmpl3
-rw-r--r--Documentation/MSI-HOWTO.txt2
-rw-r--r--Documentation/accounting/taskstats.txt10
-rw-r--r--Documentation/block/biodoc.txt10
-rw-r--r--Documentation/cpu-freq/cpufreq-nforce2.txt4
-rw-r--r--Documentation/cpu-hotplug.txt4
-rw-r--r--Documentation/devices.txt8
-rw-r--r--Documentation/driver-model/platform.txt204
-rw-r--r--Documentation/driver-model/porting.txt2
-rw-r--r--Documentation/dvb/ci.txt4
-rw-r--r--Documentation/eisa.txt2
-rw-r--r--Documentation/feature-removal-schedule.txt38
-rw-r--r--Documentation/filesystems/adfs.txt2
-rw-r--r--Documentation/filesystems/configfs/configfs.txt4
-rw-r--r--Documentation/filesystems/fuse.txt4
-rw-r--r--Documentation/filesystems/hpfs.txt2
-rw-r--r--Documentation/filesystems/ntfs.txt4
-rw-r--r--Documentation/filesystems/ocfs2.txt2
-rw-r--r--Documentation/filesystems/proc.txt10
-rw-r--r--Documentation/filesystems/spufs.txt2
-rw-r--r--Documentation/ftape.txt307
-rw-r--r--Documentation/fujitsu/frv/gdbstub.txt2
-rw-r--r--Documentation/fujitsu/frv/kernel-ABI.txt2
-rw-r--r--Documentation/ide.txt2
-rw-r--r--Documentation/input/amijoy.txt4
-rw-r--r--Documentation/input/atarikbd.txt12
-rw-r--r--Documentation/input/yealink.txt2
-rw-r--r--Documentation/ioctl/cdrom.txt2
-rw-r--r--Documentation/kbuild/makefiles.txt10
-rw-r--r--Documentation/kernel-parameters.txt3
-rw-r--r--Documentation/keys.txt2
-rw-r--r--Documentation/laptop-mode.txt8
-rw-r--r--Documentation/memory-barriers.txt2
-rw-r--r--Documentation/networking/NAPI_HOWTO.txt26
-rw-r--r--Documentation/networking/cs89x0.txt6
-rw-r--r--Documentation/networking/dccp.txt84
-rw-r--r--Documentation/networking/e1000.txt451
-rw-r--r--Documentation/networking/ip-sysctl.txt347
-rw-r--r--Documentation/networking/iphase.txt2
-rw-r--r--Documentation/networking/packet_mmap.txt2
-rw-r--r--Documentation/networking/phy.txt13
-rw-r--r--Documentation/networking/pktgen.txt6
-rw-r--r--Documentation/networking/proc_net_tcp.txt2
-rw-r--r--Documentation/networking/sk98lin.txt2
-rw-r--r--Documentation/networking/slicecom.txt2
-rw-r--r--Documentation/networking/udplite.txt281
-rw-r--r--Documentation/networking/wan-router.txt8
-rw-r--r--Documentation/networking/xfrm_sync.txt5
-rw-r--r--Documentation/pnp.txt2
-rw-r--r--Documentation/power/pci.txt4
-rw-r--r--Documentation/power/states.txt2
-rw-r--r--Documentation/power/swsusp.txt2
-rw-r--r--Documentation/powerpc/booting-without-of.txt8
-rw-r--r--Documentation/robust-futex-ABI.txt2
-rw-r--r--Documentation/robust-futexes.txt2
-rw-r--r--Documentation/rtc.txt463
-rw-r--r--Documentation/s390/crypto/crypto-API.txt4
-rw-r--r--Documentation/scsi/aic79xx.txt4
-rw-r--r--Documentation/scsi/aic7xxx_old.txt4
-rw-r--r--Documentation/scsi/ibmmca.txt14
-rw-r--r--Documentation/scsi/in2000.txt2
-rw-r--r--Documentation/scsi/libsas.txt2
-rw-r--r--Documentation/scsi/ncr53c8xx.txt2
-rw-r--r--Documentation/scsi/scsi-changer.txt4
-rw-r--r--Documentation/scsi/scsi_eh.txt2
-rw-r--r--Documentation/scsi/st.txt2
-rw-r--r--Documentation/scsi/sym53c8xx_2.txt2
-rw-r--r--Documentation/sharedsubtree.txt4
-rw-r--r--Documentation/sound/alsa/ALSA-Configuration.txt2
-rw-r--r--Documentation/sound/alsa/Audigy-mixer.txt2
-rw-r--r--Documentation/sound/alsa/SB-Live-mixer.txt2
-rw-r--r--Documentation/stable_kernel_rules.txt2
-rw-r--r--Documentation/sysctl/fs.txt2
-rw-r--r--Documentation/sysctl/vm.txt2
-rw-r--r--Documentation/uml/UserModeLinux-HOWTO.txt2
-rw-r--r--Documentation/usb/hiddev.txt2
-rw-r--r--Documentation/usb/rio.txt4
-rw-r--r--Documentation/usb/usb-serial.txt8
-rw-r--r--Documentation/watchdog/watchdog-api.txt2
-rw-r--r--MAINTAINERS169
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/lib/checksum.c37
-rw-r--r--arch/alpha/lib/csum_partial_copy.c31
-rw-r--r--arch/arm/Kconfig2
-rw-r--r--arch/arm/configs/assabet_defconfig1
-rw-r--r--arch/arm/configs/cerfcube_defconfig1
-rw-r--r--arch/arm/configs/corgi_defconfig1
-rw-r--r--arch/arm/configs/h3600_defconfig1
-rw-r--r--arch/arm/configs/integrator_defconfig1
-rw-r--r--arch/arm/configs/jornada720_defconfig1
-rw-r--r--arch/arm/configs/lart_defconfig1
-rw-r--r--arch/arm/configs/neponset_defconfig1
-rw-r--r--arch/arm/configs/simpad_defconfig1
-rw-r--r--arch/arm/configs/spitz_defconfig1
-rw-r--r--arch/arm/kernel/smp.c1
-rw-r--r--arch/arm/mach-ebsa110/io.c8
-rw-r--r--arch/arm/mach-ixp4xx/Kconfig2
-rw-r--r--arch/arm/mach-lh7a40x/Kconfig2
-rw-r--r--arch/arm/mach-s3c2410/Kconfig2
-rw-r--r--arch/arm/mm/Kconfig2
-rw-r--r--arch/arm/mm/consistent.c3
-rw-r--r--arch/cris/arch-v10/Kconfig2
-rw-r--r--arch/cris/arch-v10/drivers/Kconfig2
-rw-r--r--arch/cris/arch-v10/drivers/eeprom.c6
-rw-r--r--arch/cris/arch-v10/drivers/i2c.c2
-rw-r--r--arch/cris/arch-v10/kernel/kgdb.c2
-rw-r--r--arch/cris/arch-v10/lib/old_checksum.c62
-rw-r--r--arch/cris/arch-v32/drivers/Kconfig8
-rw-r--r--arch/frv/lib/checksum.c25
-rw-r--r--arch/h8300/kernel/h8300_ksyms.c2
-rw-r--r--arch/h8300/lib/checksum.c29
-rw-r--r--arch/i386/kernel/acpi/boot.c10
-rw-r--r--arch/i386/kernel/cpuid.c20
-rw-r--r--arch/i386/kernel/msr.c20
-rw-r--r--arch/i386/kernel/pci-dma.c4
-rw-r--r--arch/i386/pci/common.c2
-rw-r--r--arch/i386/pci/fixup.c46
-rw-r--r--arch/i386/pci/i386.c64
-rw-r--r--arch/i386/pci/irq.c6
-rw-r--r--arch/ia64/hp/common/sba_iommu.c8
-rw-r--r--arch/ia64/lib/checksum.c38
-rw-r--r--arch/ia64/lib/csum_partial_copy.c31
-rw-r--r--arch/ia64/pci/pci.c75
-rw-r--r--arch/ia64/sn/kernel/Makefile5
-rw-r--r--arch/ia64/sn/kernel/io_acpi_init.c231
-rw-r--r--arch/ia64/sn/kernel/io_common.c613
-rw-r--r--arch/ia64/sn/kernel/io_init.c633
-rw-r--r--arch/ia64/sn/kernel/iomv.c11
-rw-r--r--arch/ia64/sn/kernel/setup.c18
-rw-r--r--arch/ia64/sn/kernel/tiocx.c2
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_provider.c17
-rw-r--r--arch/ia64/sn/pci/tioce_provider.c18
-rw-r--r--arch/m32r/lib/csum_partial_copy.c12
-rw-r--r--arch/m68k/lib/checksum.c13
-rw-r--r--arch/m68knommu/Kconfig4
-rw-r--r--arch/m68knommu/kernel/m68k_ksyms.c2
-rw-r--r--arch/m68knommu/lib/checksum.c28
-rw-r--r--arch/mips/Kconfig32
-rw-r--r--arch/mips/Makefile4
-rw-r--r--arch/mips/au1000/common/irq.c63
-rw-r--r--arch/mips/au1000/pb1200/board_setup.c8
-rw-r--r--arch/mips/cobalt/irq.c31
-rw-r--r--arch/mips/cobalt/setup.c16
-rw-r--r--arch/mips/ddb5xxx/ddb5477/irq_5477.c23
-rw-r--r--arch/mips/dec/ecc-berr.c6
-rw-r--r--arch/mips/dec/int-handler.S2
-rw-r--r--arch/mips/dec/ioasic-irq.c74
-rw-r--r--arch/mips/dec/kn02-irq.c53
-rw-r--r--arch/mips/dec/setup.c6
-rw-r--r--arch/mips/dec/time.c4
-rw-r--r--arch/mips/emma2rh/common/irq_emma2rh.c35
-rw-r--r--arch/mips/emma2rh/markeins/irq_markeins.c56
-rw-r--r--arch/mips/gt64120/ev64120/irq.c40
-rw-r--r--arch/mips/jazz/irq.c27
-rw-r--r--arch/mips/jmr3927/rbhma3100/irq.c32
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c4
-rw-r--r--arch/mips/kernel/Makefile5
-rw-r--r--arch/mips/kernel/cpu-probe.c19
-rw-r--r--arch/mips/kernel/dma-no-isa.c28
-rw-r--r--arch/mips/kernel/genex.S63
-rw-r--r--arch/mips/kernel/head.S3
-rw-r--r--arch/mips/kernel/i8259.c21
-rw-r--r--arch/mips/kernel/irq-msc01.c47
-rw-r--r--arch/mips/kernel/irq-mv6434x.c54
-rw-r--r--arch/mips/kernel/irq-rm7000.c54
-rw-r--r--arch/mips/kernel/irq-rm9000.c47
-rw-r--r--arch/mips/kernel/irq.c32
-rw-r--r--arch/mips/kernel/irq_cpu.c80
-rw-r--r--arch/mips/kernel/machine_kexec.c85
-rw-r--r--arch/mips/kernel/module.c15
-rw-r--r--arch/mips/kernel/relocate_kernel.S80
-rw-r--r--arch/mips/kernel/scall32-o32.S2
-rw-r--r--arch/mips/kernel/scall64-64.S2
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S2
-rw-r--r--arch/mips/kernel/setup.c87
-rw-r--r--arch/mips/kernel/signal_n32.c1
-rw-r--r--arch/mips/kernel/smp-mt.c2
-rw-r--r--arch/mips/kernel/smp.c23
-rw-r--r--arch/mips/kernel/smtc.c1
-rw-r--r--arch/mips/kernel/time.c64
-rw-r--r--arch/mips/kernel/topology.c29
-rw-r--r--arch/mips/kernel/traps.c72
-rw-r--r--arch/mips/lasat/interrupt.c36
-rw-r--r--arch/mips/lib/csum_partial_copy.c8
-rw-r--r--arch/mips/mips-boards/atlas/atlas_int.c29
-rw-r--r--arch/mips/mips-boards/generic/time.c1
-rw-r--r--arch/mips/mips-boards/malta/malta_setup.c2
-rw-r--r--arch/mips/mips-boards/sim/sim_time.c18
-rw-r--r--arch/mips/mm/c-r4k.c22
-rw-r--r--arch/mips/mm/c-sb1.c22
-rw-r--r--arch/mips/mm/fault.c4
-rw-r--r--arch/mips/mm/init.c42
-rw-r--r--arch/mips/mm/pgtable-64.c3
-rw-r--r--arch/mips/mm/tlbex.c55
-rw-r--r--arch/mips/momentum/ocelot_c/cpci-irq.c53
-rw-r--r--arch/mips/momentum/ocelot_c/uart-irq.c56
-rw-r--r--arch/mips/oprofile/Makefile1
-rw-r--r--arch/mips/oprofile/common.c3
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c32
-rw-r--r--arch/mips/pci/fixup-cobalt.c11
-rw-r--r--arch/mips/pci/ops-gt64111.c16
-rw-r--r--arch/mips/philips/pnx8550/common/int.c68
-rw-r--r--arch/mips/pmc-sierra/yosemite/smp.c2
-rw-r--r--arch/mips/sgi-ip22/ip22-eisa.c33
-rw-r--r--arch/mips/sgi-ip22/ip22-int.c109
-rw-r--r--arch/mips/sgi-ip27/ip27-irq.c17
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c32
-rw-r--r--arch/mips/sgi-ip32/ip32-irq.c133
-rw-r--r--arch/mips/sibyte/bcm1480/irq.c30
-rw-r--r--arch/mips/sibyte/bcm1480/time.c6
-rw-r--r--arch/mips/sibyte/sb1250/irq.c30
-rw-r--r--arch/mips/sibyte/sb1250/time.c8
-rw-r--r--arch/mips/sni/irq.c40
-rw-r--r--arch/mips/tx4927/common/tx4927_irq.c164
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c184
-rw-r--r--arch/mips/tx4938/common/irq.c115
-rw-r--r--arch/mips/tx4938/common/setup.c1
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/irq.c54
-rw-r--r--arch/mips/vr41xx/common/icu.c48
-rw-r--r--arch/mips/vr41xx/nec-cmbvr4133/irq.c20
-rw-r--r--arch/parisc/lib/checksum.c17
-rw-r--r--arch/powerpc/Kconfig2
-rw-r--r--arch/powerpc/platforms/83xx/Kconfig4
-rw-r--r--arch/powerpc/platforms/powermac/pci.c1
-rw-r--r--arch/ppc/Kconfig2
-rw-r--r--arch/sh/Kconfig2
-rw-r--r--arch/sh/kernel/sh_ksyms.c1
-rw-r--r--arch/sh64/kernel/sh_ksyms.c2
-rw-r--r--arch/sh64/lib/c-checksum.c49
-rw-r--r--arch/sh64/lib/dbg.c2
-rw-r--r--arch/sparc/Kconfig4
-rw-r--r--arch/sparc64/kernel/pci.c9
-rw-r--r--arch/um/drivers/chan_user.c2
-rw-r--r--arch/um/include/os.h2
-rw-r--r--arch/um/include/sysdep-i386/checksum.h74
-rw-r--r--arch/um/include/sysdep-x86_64/checksum.h47
-rw-r--r--arch/um/os-Linux/Makefile10
-rw-r--r--arch/um/os-Linux/execvp.c149
-rw-r--r--arch/um/os-Linux/helper.c14
-rw-r--r--arch/v850/kernel/v850_ksyms.c2
-rw-r--r--arch/v850/lib/checksum.c26
-rw-r--r--arch/x86_64/kernel/early_printk.c2
-rw-r--r--arch/x86_64/kernel/io_apic.c2
-rw-r--r--arch/x86_64/kernel/traps.c10
-rw-r--r--arch/x86_64/lib/csum-partial.c7
-rw-r--r--arch/x86_64/lib/csum-wrappers.c37
-rw-r--r--block/as-iosched.c2
-rw-r--r--block/blktrace.c57
-rw-r--r--block/cfq-iosched.c9
-rw-r--r--block/deadline-iosched.c2
-rw-r--r--block/elevator.c4
-rw-r--r--block/ll_rw_blk.c166
-rw-r--r--block/noop-iosched.c2
-rw-r--r--block/scsi_ioctl.c53
-rw-r--r--drivers/acpi/glue.c20
-rw-r--r--drivers/acpi/processor_perflib.c4
-rw-r--r--drivers/ata/ahci.c38
-rw-r--r--drivers/ata/ata_generic.c1
-rw-r--r--drivers/ata/libata-scsi.c21
-rw-r--r--drivers/ata/pata_ali.c1
-rw-r--r--drivers/ata/pata_amd.c1
-rw-r--r--drivers/ata/pata_artop.c1
-rw-r--r--drivers/ata/pata_atiixp.c1
-rw-r--r--drivers/ata/pata_cmd64x.c1
-rw-r--r--drivers/ata/pata_cs5520.c1
-rw-r--r--drivers/ata/pata_cs5530.c1
-rw-r--r--drivers/ata/pata_cs5535.c1
-rw-r--r--drivers/ata/pata_cypress.c1
-rw-r--r--drivers/ata/pata_efar.c1
-rw-r--r--drivers/ata/pata_hpt366.c1
-rw-r--r--drivers/ata/pata_hpt37x.c1
-rw-r--r--drivers/ata/pata_hpt3x2n.c1
-rw-r--r--drivers/ata/pata_hpt3x3.c1
-rw-r--r--drivers/ata/pata_isapnp.c1
-rw-r--r--drivers/ata/pata_it821x.c1
-rw-r--r--drivers/ata/pata_jmicron.c1
-rw-r--r--drivers/ata/pata_legacy.c1
-rw-r--r--drivers/ata/pata_mpiix.c1
-rw-r--r--drivers/ata/pata_netcell.c1
-rw-r--r--drivers/ata/pata_ns87410.c1
-rw-r--r--drivers/ata/pata_oldpiix.c1
-rw-r--r--drivers/ata/pata_opti.c1
-rw-r--r--drivers/ata/pata_optidma.c1
-rw-r--r--drivers/ata/pata_pcmcia.c1
-rw-r--r--drivers/ata/pata_pdc2027x.c1
-rw-r--r--drivers/ata/pata_pdc202xx_old.c1
-rw-r--r--drivers/ata/pata_qdi.c1
-rw-r--r--drivers/ata/pata_radisys.c1
-rw-r--r--drivers/ata/pata_rz1000.c1
-rw-r--r--drivers/ata/pata_sc1200.c1
-rw-r--r--drivers/ata/pata_serverworks.c1
-rw-r--r--drivers/ata/pata_sil680.c1
-rw-r--r--drivers/ata/pata_sis.c1
-rw-r--r--drivers/ata/pata_sl82c105.c1
-rw-r--r--drivers/ata/pata_triflex.c1
-rw-r--r--drivers/ata/pata_via.c1
-rw-r--r--drivers/atm/ambassador.c2
-rw-r--r--drivers/atm/firestream.c2
-rw-r--r--drivers/atm/iphase.c2
-rw-r--r--drivers/base/bus.c34
-rw-r--r--drivers/base/class.c166
-rw-r--r--drivers/base/core.c241
-rw-r--r--drivers/base/dd.c92
-rw-r--r--drivers/base/firmware_class.c119
-rw-r--r--drivers/base/platform.c48
-rw-r--r--drivers/base/topology.c55
-rw-r--r--drivers/cdrom/cdrom.c6
-rw-r--r--drivers/char/Kconfig35
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/agp/generic.c2
-rw-r--r--drivers/char/agp/intel-agp.c33
-rw-r--r--drivers/char/ftape/Kconfig330
-rw-r--r--drivers/char/ftape/Makefile28
-rw-r--r--drivers/char/ftape/README.PCI81
-rw-r--r--drivers/char/ftape/RELEASE-NOTES966
-rw-r--r--drivers/char/ftape/compressor/Makefile31
-rw-r--r--drivers/char/ftape/compressor/lzrw3.c743
-rw-r--r--drivers/char/ftape/compressor/lzrw3.h253
-rw-r--r--drivers/char/ftape/compressor/zftape-compress.c1203
-rw-r--r--drivers/char/ftape/compressor/zftape-compress.h83
-rw-r--r--drivers/char/ftape/lowlevel/Makefile43
-rw-r--r--drivers/char/ftape/lowlevel/fc-10.c175
-rw-r--r--drivers/char/ftape/lowlevel/fc-10.h39
-rw-r--r--drivers/char/ftape/lowlevel/fdc-io.c1349
-rw-r--r--drivers/char/ftape/lowlevel/fdc-io.h252
-rw-r--r--drivers/char/ftape/lowlevel/fdc-isr.c1170
-rw-r--r--drivers/char/ftape/lowlevel/fdc-isr.h55
-rw-r--r--drivers/char/ftape/lowlevel/ftape-bsm.c491
-rw-r--r--drivers/char/ftape/lowlevel/ftape-bsm.h66
-rw-r--r--drivers/char/ftape/lowlevel/ftape-buffer.c130
-rw-r--r--drivers/char/ftape/lowlevel/ftape-buffer.h32
-rw-r--r--drivers/char/ftape/lowlevel/ftape-calibr.c275
-rw-r--r--drivers/char/ftape/lowlevel/ftape-calibr.h37
-rw-r--r--drivers/char/ftape/lowlevel/ftape-ctl.c896
-rw-r--r--drivers/char/ftape/lowlevel/ftape-ctl.h162
-rw-r--r--drivers/char/ftape/lowlevel/ftape-ecc.c853
-rw-r--r--drivers/char/ftape/lowlevel/ftape-ecc.h84
-rw-r--r--drivers/char/ftape/lowlevel/ftape-format.c344
-rw-r--r--drivers/char/ftape/lowlevel/ftape-format.h37
-rw-r--r--drivers/char/ftape/lowlevel/ftape-init.c160
-rw-r--r--drivers/char/ftape/lowlevel/ftape-init.h43
-rw-r--r--drivers/char/ftape/lowlevel/ftape-io.c992
-rw-r--r--drivers/char/ftape/lowlevel/ftape-io.h90
-rw-r--r--drivers/char/ftape/lowlevel/ftape-proc.c214
-rw-r--r--drivers/char/ftape/lowlevel/ftape-proc.h35
-rw-r--r--drivers/char/ftape/lowlevel/ftape-read.c621
-rw-r--r--drivers/char/ftape/lowlevel/ftape-read.h51
-rw-r--r--drivers/char/ftape/lowlevel/ftape-rw.c1092
-rw-r--r--drivers/char/ftape/lowlevel/ftape-rw.h111
-rw-r--r--drivers/char/ftape/lowlevel/ftape-setup.c104
-rw-r--r--drivers/char/ftape/lowlevel/ftape-tracing.c118
-rw-r--r--drivers/char/ftape/lowlevel/ftape-tracing.h179
-rw-r--r--drivers/char/ftape/lowlevel/ftape-write.c336
-rw-r--r--drivers/char/ftape/lowlevel/ftape-write.h53
-rw-r--r--drivers/char/ftape/lowlevel/ftape_syms.c87
-rw-r--r--drivers/char/ftape/zftape/Makefile36
-rw-r--r--drivers/char/ftape/zftape/zftape-buffers.c149
-rw-r--r--drivers/char/ftape/zftape/zftape-buffers.h55
-rw-r--r--drivers/char/ftape/zftape/zftape-ctl.c1417
-rw-r--r--drivers/char/ftape/zftape/zftape-ctl.h58
-rw-r--r--drivers/char/ftape/zftape/zftape-eof.c199
-rw-r--r--drivers/char/ftape/zftape/zftape-eof.h52
-rw-r--r--drivers/char/ftape/zftape/zftape-init.c377
-rw-r--r--drivers/char/ftape/zftape/zftape-init.h77
-rw-r--r--drivers/char/ftape/zftape/zftape-read.c377
-rw-r--r--drivers/char/ftape/zftape/zftape-read.h53
-rw-r--r--drivers/char/ftape/zftape/zftape-rw.c375
-rw-r--r--drivers/char/ftape/zftape/zftape-rw.h101
-rw-r--r--drivers/char/ftape/zftape/zftape-vtbl.c757
-rw-r--r--drivers/char/ftape/zftape/zftape-vtbl.h227
-rw-r--r--drivers/char/ftape/zftape/zftape-write.c483
-rw-r--r--drivers/char/ftape/zftape/zftape-write.h38
-rw-r--r--drivers/char/ftape/zftape/zftape_syms.c43
-rw-r--r--drivers/char/hw_random/core.c38
-rw-r--r--drivers/char/mem.c8
-rw-r--r--drivers/char/misc.c13
-rw-r--r--drivers/char/ppdev.c6
-rw-r--r--drivers/char/random.c48
-rw-r--r--drivers/char/raw.c12
-rw-r--r--drivers/char/rio/riocmd.c2
-rw-r--r--drivers/char/rio/rioinit.c2
-rw-r--r--drivers/char/rio/rioparam.c6
-rw-r--r--drivers/char/tlclk.c5
-rw-r--r--drivers/char/tpm/tpm.c2
-rw-r--r--drivers/char/tty_io.c19
-rw-r--r--drivers/char/vc_screen.c16
-rw-r--r--drivers/char/vt.c81
-rw-r--r--drivers/char/watchdog/Kconfig32
-rw-r--r--drivers/char/watchdog/Makefile4
-rw-r--r--drivers/char/watchdog/iTCO_vendor_support.c307
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c29
-rw-r--r--drivers/char/watchdog/pc87413_wdt.c635
-rw-r--r--drivers/char/watchdog/pcwd_usb.c3
-rw-r--r--drivers/char/watchdog/rm9k_wdt.c420
-rw-r--r--drivers/i2c/busses/Kconfig1
-rw-r--r--drivers/i2c/busses/i2c-i801.c2
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c2
-rw-r--r--drivers/i2c/i2c-dev.c26
-rw-r--r--drivers/ide/ide-floppy.c2
-rw-r--r--drivers/ide/pci/sgiioc4.c7
-rw-r--r--drivers/infiniband/core/addr.c19
-rw-r--r--drivers/infiniband/core/cm.c121
-rw-r--r--drivers/infiniband/core/cma.c49
-rw-r--r--drivers/infiniband/core/iwcm.c44
-rw-r--r--drivers/infiniband/core/mad.c2
-rw-r--r--drivers/infiniband/core/ucm.c20
-rw-r--r--drivers/infiniband/hw/amso1100/c2.h2
-rw-r--r--drivers/infiniband/hw/amso1100/c2_qp.c36
-rw-r--r--drivers/infiniband/hw/amso1100/c2_rnic.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c22
-rw-r--r--drivers/infiniband/hw/ehca/ipz_pt_fn.c13
-rw-r--r--drivers/infiniband/hw/ehca/ipz_pt_fn.h15
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_av.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c21
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mad.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c29
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mr.c5
-rw-r--r--drivers/infiniband/hw/mthca/mthca_pd.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c19
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c2
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.h2
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c11
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c6
-rw-r--r--drivers/input/serio/serio_raw.c2
-rw-r--r--drivers/isdn/gigaset/common.c2
-rw-r--r--drivers/isdn/gigaset/gigaset.h2
-rw-r--r--drivers/isdn/gigaset/interface.c10
-rw-r--r--drivers/isdn/gigaset/proc.c19
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c15
-rw-r--r--drivers/isdn/hardware/eicon/os_4bri.c2
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.h2
-rw-r--r--drivers/isdn/hisax/isdnl2.c20
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c6
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c2
-rw-r--r--drivers/media/dvb/frontends/tda10086.c4
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c8
-rw-r--r--drivers/media/dvb/ttpci/budget.c9
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c3
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c10
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c2
-rw-r--r--drivers/media/video/pwc/pwc-if.c9
-rw-r--r--drivers/media/video/saa6588.c4
-rw-r--r--drivers/media/video/saa7115.c9
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c5
-rw-r--r--drivers/media/video/usbvideo/quickcam_messenger.c3
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c2
-rw-r--r--drivers/message/fusion/mptbase.c2
-rw-r--r--drivers/message/i2o/pci.c15
-rw-r--r--drivers/mmc/Kconfig2
-rw-r--r--drivers/mmc/at91_mci.c2
-rw-r--r--drivers/mmc/au1xmmc.c2
-rw-r--r--drivers/mmc/imxmmc.c2
-rw-r--r--drivers/mmc/mmc.c294
-rw-r--r--drivers/mmc/mmc_block.c15
-rw-r--r--drivers/mmc/mmc_queue.c67
-rw-r--r--drivers/mmc/mmc_queue.h3
-rw-r--r--drivers/mmc/mmc_sysfs.c20
-rw-r--r--drivers/mmc/mmci.c2
-rw-r--r--drivers/mmc/omap.c275
-rw-r--r--drivers/mmc/omap.h55
-rw-r--r--drivers/mmc/pxamci.c2
-rw-r--r--drivers/mmc/sdhci.c17
-rw-r--r--drivers/mmc/sdhci.h2
-rw-r--r--drivers/mmc/wbsd.c8
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c2
-rw-r--r--drivers/mtd/maps/Kconfig2
-rw-r--r--drivers/mtd/maps/cfi_flagadm.c2
-rw-r--r--drivers/net/8390.c1080
-rw-r--r--drivers/net/8390.h37
-rw-r--r--drivers/net/Kconfig47
-rw-r--r--drivers/net/Makefile13
-rw-r--r--drivers/net/Space.c1
-rw-r--r--drivers/net/amd8111e.c27
-rw-r--r--drivers/net/amd8111e.h4
-rw-r--r--drivers/net/arm/etherh.c39
-rw-r--r--drivers/net/au1000_eth.c3
-rw-r--r--drivers/net/bnx2.c689
-rw-r--r--drivers/net/bnx2.h2940
-rw-r--r--drivers/net/bnx2_fw.h1234
-rw-r--r--drivers/net/bnx2_fw2.h4086
-rw-r--r--drivers/net/bonding/bond_main.c63
-rw-r--r--drivers/net/cassini.c2
-rw-r--r--drivers/net/chelsio/Makefile8
-rw-r--r--drivers/net/chelsio/common.h105
-rw-r--r--drivers/net/chelsio/cphy.h24
-rw-r--r--drivers/net/chelsio/cpl5_cmd.h510
-rw-r--r--drivers/net/chelsio/cxgb2.c591
-rw-r--r--drivers/net/chelsio/elmer0.h7
-rw-r--r--drivers/net/chelsio/espi.c205
-rw-r--r--drivers/net/chelsio/espi.h1
-rw-r--r--drivers/net/chelsio/fpga_defs.h232
-rw-r--r--drivers/net/chelsio/gmac.h5
-rw-r--r--drivers/net/chelsio/ixf1010.c485
-rw-r--r--drivers/net/chelsio/mac.c368
-rw-r--r--drivers/net/chelsio/mv88e1xxx.c397
-rw-r--r--drivers/net/chelsio/mv88e1xxx.h127
-rw-r--r--drivers/net/chelsio/mv88x201x.c36
-rw-r--r--drivers/net/chelsio/my3126.c204
-rw-r--r--drivers/net/chelsio/pm3393.c125
-rw-r--r--drivers/net/chelsio/regs.h1718
-rw-r--r--drivers/net/chelsio/sge.c867
-rw-r--r--drivers/net/chelsio/sge.h33
-rw-r--r--drivers/net/chelsio/subr.c494
-rw-r--r--drivers/net/chelsio/suni1x10gexp_regs.h1430
-rw-r--r--drivers/net/chelsio/tp.c178
-rw-r--r--drivers/net/chelsio/tp.h73
-rw-r--r--drivers/net/chelsio/vsc7326.c725
-rw-r--r--drivers/net/chelsio/vsc7326_reg.h286
-rw-r--r--drivers/net/chelsio/vsc8244.c368
-rw-r--r--drivers/net/chelsio/vsc8244_reg.h172
-rw-r--r--drivers/net/cs89x0.c4
-rw-r--r--drivers/net/defxx.c39
-rw-r--r--drivers/net/defxx.h15
-rw-r--r--drivers/net/depca.c28
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/e1000/e1000.h17
-rw-r--r--drivers/net/e1000/e1000_ethtool.c36
-rw-r--r--drivers/net/e1000/e1000_hw.c139
-rw-r--r--drivers/net/e1000/e1000_hw.h90
-rw-r--r--drivers/net/e1000/e1000_main.c490
-rw-r--r--drivers/net/e1000/e1000_osdep.h9
-rw-r--r--drivers/net/e1000/e1000_param.c98
-rw-r--r--drivers/net/forcedeth.c290
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c3
-rw-r--r--drivers/net/gianfar.c72
-rw-r--r--drivers/net/gianfar.h3
-rw-r--r--drivers/net/hamradio/6pack.c2
-rw-r--r--drivers/net/hydra.c23
-rw-r--r--drivers/net/ioc3-eth.c1
-rw-r--r--drivers/net/irda/irda-usb.c6
-rw-r--r--drivers/net/ixgb/ixgb_main.c2
-rw-r--r--drivers/net/lib8390.c1097
-rw-r--r--drivers/net/mac8390.c26
-rw-r--r--drivers/net/macb.c1210
-rw-r--r--drivers/net/macb.h387
-rw-r--r--drivers/net/meth.c1
-rw-r--r--drivers/net/myri10ge/myri10ge.c2
-rw-r--r--drivers/net/myri_sbus.c1
-rw-r--r--drivers/net/ne-h8300.c23
-rw-r--r--drivers/net/netconsole.c8
-rw-r--r--drivers/net/netxen/Makefile35
-rw-r--r--drivers/net/netxen/netxen_nic.h1028
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c741
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h678
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c1010
-rw-r--r--drivers/net/netxen/netxen_nic_hw.h482
-rw-r--r--drivers/net/netxen/netxen_nic_init.c1304
-rw-r--r--drivers/net/netxen/netxen_nic_ioctl.h77
-rw-r--r--drivers/net/netxen/netxen_nic_isr.c215
-rw-r--r--drivers/net/netxen/netxen_nic_main.c1161
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c894
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h215
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c1
-rw-r--r--drivers/net/phy/Kconfig10
-rw-r--r--drivers/net/phy/Makefile1
-rw-r--r--drivers/net/phy/broadcom.c175
-rw-r--r--drivers/net/phy/phy.c113
-rw-r--r--drivers/net/phy/phy_device.c30
-rw-r--r--drivers/net/ppp_generic.c4
-rw-r--r--drivers/net/pppoe.c2
-rw-r--r--drivers/net/r8169.c26
-rw-r--r--drivers/net/sk98lin/h/skdrv2nd.h2
-rw-r--r--drivers/net/sk98lin/skdim.c4
-rw-r--r--drivers/net/sk98lin/skethtool.c26
-rw-r--r--drivers/net/sk98lin/skge.c58
-rw-r--r--drivers/net/skge.c8
-rw-r--r--drivers/net/sky2.c41
-rw-r--r--drivers/net/sky2.h11
-rw-r--r--drivers/net/spider_net.c20
-rw-r--r--drivers/net/spider_net.h8
-rw-r--r--drivers/net/sundance.c58
-rw-r--r--drivers/net/sungem.c2
-rw-r--r--drivers/net/sunhme.c2
-rw-r--r--drivers/net/tokenring/olympic.c2
-rw-r--r--drivers/net/tsi108_eth.c1708
-rw-r--r--drivers/net/tsi108_eth.h365
-rw-r--r--drivers/net/tulip/de2104x.c4
-rw-r--r--drivers/net/tulip/dmfe.c9
-rw-r--r--drivers/net/typhoon.c1
-rw-r--r--drivers/net/ucc_geth.c6
-rw-r--r--drivers/net/wan/Kconfig76
-rw-r--r--drivers/net/wireless/atmel.c36
-rw-r--r--drivers/net/wireless/atmel_cs.c74
-rw-r--r--drivers/net/wireless/atmel_pci.c10
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h32
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c207
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_power.c28
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c4
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_xmit.c18
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c8
-rw-r--r--drivers/net/wireless/ipw2100.c25
-rw-r--r--drivers/net/wireless/ipw2200.c12
-rw-r--r--drivers/net/wireless/orinoco_pci.h7
-rw-r--r--drivers/net/wireless/prism54/isl_38xx.c17
-rw-r--r--drivers/net/wireless/prism54/isl_38xx.h7
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c61
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.h1
-rw-r--r--drivers/net/wireless/prism54/isl_oid.h48
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c13
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.h11
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c28
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.h1
-rw-r--r--drivers/net/wireless/prism54/islpci_hotplug.c43
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.c3
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.h5
-rw-r--r--drivers/net/wireless/prism54/oid_mgt.c6
-rw-r--r--drivers/net/wireless/prism54/prismcompat.h4
-rw-r--r--drivers/net/wireless/zd1201.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c38
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h104
-rw-r--r--drivers/net/wireless/zd1211rw/zd_def.h1
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.c10
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.h3
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c404
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h38
-rw-r--r--drivers/net/wireless/zd1211rw/zd_netdev.c13
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c45
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.h14
-rw-r--r--drivers/net/zorro8390.c24
-rw-r--r--drivers/parisc/ccio-dma.c2
-rw-r--r--drivers/parisc/iosapic.c6
-rw-r--r--drivers/pci/Kconfig6
-rw-r--r--drivers/pci/access.c75
-rw-r--r--drivers/pci/hotplug/acpiphp.h4
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c39
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c8
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c2
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c4
-rw-r--r--drivers/pci/hotplug/pciehp_core.c7
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c2
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c2
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c2
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c35
-rw-r--r--drivers/pci/msi.h8
-rw-r--r--drivers/pci/pci-acpi.c10
-rw-r--r--drivers/pci/pci-driver.c11
-rw-r--r--drivers/pci/pci-sysfs.c33
-rw-r--r--drivers/pci/pci.c123
-rw-r--r--drivers/pci/pci.h1
-rw-r--r--drivers/pci/probe.c27
-rw-r--r--drivers/pci/quirks.c59
-rw-r--r--drivers/pci/rom.c9
-rw-r--r--drivers/pcmcia/ds.c2
-rw-r--r--drivers/rtc/interface.c16
-rw-r--r--drivers/rtc/rtc-at91.c3
-rw-r--r--drivers/rtc/rtc-dev.c25
-rw-r--r--drivers/rtc/rtc-ds1553.c3
-rw-r--r--drivers/rtc/rtc-rs5c372.c6
-rw-r--r--drivers/rtc/rtc-test.c2
-rw-r--r--drivers/s390/net/claw.h2
-rw-r--r--drivers/s390/net/lcs.c2
-rw-r--r--drivers/s390/net/lcs.h4
-rw-r--r--drivers/s390/net/qeth_eddp.c40
-rw-r--r--drivers/s390/net/qeth_eddp.h2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_reg_def.h2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_sds.c4
-rw-r--r--drivers/scsi/ncr53c8xx.c14
-rw-r--r--drivers/scsi/ncr53c8xx.h6
-rw-r--r--drivers/spi/Kconfig2
-rw-r--r--drivers/usb/atm/speedtch.c4
-rw-r--r--drivers/usb/atm/ueagle-atm.c10
-rw-r--r--drivers/usb/class/cdc-acm.c2
-rw-r--r--drivers/usb/core/Kconfig15
-rw-r--r--drivers/usb/core/devices.c9
-rw-r--r--drivers/usb/core/devio.c4
-rw-r--r--drivers/usb/core/driver.c304
-rw-r--r--drivers/usb/core/endpoint.c98
-rw-r--r--drivers/usb/core/hcd.c4
-rw-r--r--drivers/usb/core/hub.c234
-rw-r--r--drivers/usb/core/hub.h41
-rw-r--r--drivers/usb/core/message.c8
-rw-r--r--drivers/usb/core/usb.c160
-rw-r--r--drivers/usb/core/usb.h9
-rw-r--r--drivers/usb/gadget/ether.c4
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c1
-rw-r--r--drivers/usb/gadget/net2280.c8
-rw-r--r--drivers/usb/gadget/net2280.h3
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c2
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/ehci-hcd.c16
-rw-r--r--drivers/usb/host/ehci-hub.c104
-rw-r--r--drivers/usb/host/ehci-pci.c40
-rw-r--r--drivers/usb/host/ehci.h1
-rw-r--r--drivers/usb/host/ohci-hcd.c10
-rw-r--r--drivers/usb/host/ohci-hub.c172
-rw-r--r--drivers/usb/host/u132-hcd.c14
-rw-r--r--drivers/usb/image/microtek.c8
-rw-r--r--drivers/usb/input/Kconfig6
-rw-r--r--drivers/usb/input/ati_remote.c17
-rw-r--r--drivers/usb/input/ati_remote2.c3
-rw-r--r--drivers/usb/input/hid-core.c91
-rw-r--r--drivers/usb/input/hid.h1
-rw-r--r--drivers/usb/input/usbkbd.c10
-rw-r--r--drivers/usb/input/usbmouse.c4
-rw-r--r--drivers/usb/input/usbtouchscreen.c96
-rw-r--r--drivers/usb/input/wacom.h1
-rw-r--r--drivers/usb/input/wacom_sys.c2
-rw-r--r--drivers/usb/input/yealink.c6
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/appledisplay.c5
-rw-r--r--drivers/usb/misc/auerswald.c7
-rw-r--r--drivers/usb/misc/emi26.c3
-rw-r--r--drivers/usb/misc/emi62.c3
-rw-r--r--drivers/usb/misc/ftdi-elan.c20
-rw-r--r--drivers/usb/misc/idmouse.c22
-rw-r--r--drivers/usb/misc/legousbtower.c31
-rw-r--r--drivers/usb/misc/phidgetkit.c5
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c5
-rw-r--r--drivers/usb/misc/usb_u132.h6
-rw-r--r--drivers/usb/misc/usbtest.c4
-rw-r--r--drivers/usb/net/asix.c6
-rw-r--r--drivers/usb/net/catc.c12
-rw-r--r--drivers/usb/net/cdc_ether.c3
-rw-r--r--drivers/usb/net/net1080.c4
-rw-r--r--drivers/usb/net/pegasus.c1
-rw-r--r--drivers/usb/net/usbnet.c4
-rw-r--r--drivers/usb/serial/Kconfig11
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/aircable.c9
-rw-r--r--drivers/usb/serial/airprime.c1
-rw-r--r--drivers/usb/serial/ark3116.c3
-rw-r--r--drivers/usb/serial/console.c6
-rw-r--r--drivers/usb/serial/cypress_m8.c9
-rw-r--r--drivers/usb/serial/digi_acceleport.c2
-rw-r--r--drivers/usb/serial/ezusb.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/garmin_gps.c3
-rw-r--r--drivers/usb/serial/io_edgeport.c4
-rw-r--r--drivers/usb/serial/ipw.c3
-rw-r--r--drivers/usb/serial/keyspan.c18
-rw-r--r--drivers/usb/serial/kobil_sct.c9
-rw-r--r--drivers/usb/serial/mct_u232.c6
-rw-r--r--drivers/usb/serial/mos7840.c3
-rw-r--r--drivers/usb/serial/navman.c3
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c5
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h1
-rw-r--r--drivers/usb/serial/usb-serial.c12
-rw-r--r--drivers/usb/serial/usb_debug.c65
-rw-r--r--drivers/usb/serial/visor.c3
-rw-r--r--drivers/usb/storage/onetouch.c5
-rw-r--r--drivers/usb/storage/unusual_devs.h10
-rw-r--r--drivers/usb/storage/usb.c8
-rw-r--r--drivers/video/fbmem.c16
-rw-r--r--drivers/video/fbsysfs.c163
-rw-r--r--fs/Kconfig4
-rw-r--r--fs/aio.c6
-rw-r--r--fs/bio.c23
-rw-r--r--fs/cifs/inode.c6
-rw-r--r--fs/cifs/link.c33
-rw-r--r--fs/debugfs/inode.c1
-rw-r--r--fs/ecryptfs/crypto.c3
-rw-r--r--fs/fuse/dir.c52
-rw-r--r--fs/jfs/jfs_filsys.h2
-rw-r--r--fs/nfs/nfsroot.c13
-rw-r--r--fs/proc/base.c3
-rw-r--r--fs/reiserfs/file.c3
-rw-r--r--fs/reiserfs/journal.c6
-rw-r--r--fs/reiserfs/xattr.c2
-rw-r--r--fs/sysfs/dir.c45
-rw-r--r--fs/sysfs/file.c3
-rw-r--r--include/acpi/acpi_bus.h2
-rw-r--r--include/asm-alpha/checksum.h34
-rw-r--r--include/asm-alpha/device.h7
-rw-r--r--include/asm-arm/arch-ebsa110/io.h16
-rw-r--r--include/asm-arm/arch-pxa/udc.h17
-rw-r--r--include/asm-arm/checksum.h83
-rw-r--r--include/asm-arm/device.h7
-rw-r--r--include/asm-arm/dma-mapping.h4
-rw-r--r--include/asm-arm/mach/udc_pxa2xx.h26
-rw-r--r--include/asm-arm26/checksum.h63
-rw-r--r--include/asm-arm26/device.h7
-rw-r--r--include/asm-avr32/checksum.h40
-rw-r--r--include/asm-avr32/device.h7
-rw-r--r--include/asm-cris/arch-v10/checksum.h10
-rw-r--r--include/asm-cris/arch-v32/checksum.h10
-rw-r--r--include/asm-cris/checksum.h34
-rw-r--r--include/asm-cris/device.h7
-rw-r--r--include/asm-frv/checksum.h41
-rw-r--r--include/asm-frv/device.h7
-rw-r--r--include/asm-generic/device.h12
-rw-r--r--include/asm-h8300/checksum.h31
-rw-r--r--include/asm-h8300/device.h7
-rw-r--r--include/asm-i386/checksum.h65
-rw-r--r--include/asm-i386/device.h15
-rw-r--r--include/asm-i386/mach-summit/mach_apic.h4
-rw-r--r--include/asm-ia64/checksum.h31
-rw-r--r--include/asm-ia64/device.h15
-rw-r--r--include/asm-ia64/io.h2
-rw-r--r--include/asm-ia64/machvec.h12
-rw-r--r--include/asm-ia64/machvec_sn2.h2
-rw-r--r--include/asm-ia64/pci.h21
-rw-r--r--include/asm-ia64/sn/acpi.h16
-rw-r--r--include/asm-ia64/sn/pcidev.h22
-rw-r--r--include/asm-ia64/sn/sn_feature_sets.h6
-rw-r--r--include/asm-ia64/sn/sn_sal.h1
-rw-r--r--include/asm-m32r/checksum.h52
-rw-r--r--include/asm-m32r/device.h7
-rw-r--r--include/asm-m68k/checksum.h46
-rw-r--r--include/asm-m68k/device.h7
-rw-r--r--include/asm-m68knommu/checksum.h46
-rw-r--r--include/asm-m68knommu/device.h7
-rw-r--r--include/asm-m68knommu/mcfmbus.h2
-rw-r--r--include/asm-mips/addrspace.h40
-rw-r--r--include/asm-mips/atomic.h10
-rw-r--r--include/asm-mips/bitops.h65
-rw-r--r--include/asm-mips/bug.h12
-rw-r--r--include/asm-mips/checksum.h55
-rw-r--r--include/asm-mips/cpu-info.h10
-rw-r--r--include/asm-mips/dec/kn02.h2
-rw-r--r--include/asm-mips/device.h7
-rw-r--r--include/asm-mips/dma.h2
-rw-r--r--include/asm-mips/gt64120.h14
-rw-r--r--include/asm-mips/io.h2
-rw-r--r--include/asm-mips/irq.h8
-rw-r--r--include/asm-mips/kexec.h32
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx_ide.h6
-rw-r--r--include/asm-mips/mach-cobalt/cobalt.h29
-rw-r--r--include/asm-mips/mach-cobalt/mach-gt64120.h28
-rw-r--r--include/asm-mips/mipsregs.h56
-rw-r--r--include/asm-mips/page.h16
-rw-r--r--include/asm-mips/pgtable-64.h13
-rw-r--r--include/asm-mips/pgtable.h2
-rw-r--r--include/asm-mips/ptrace.h2
-rw-r--r--include/asm-mips/time.h9
-rw-r--r--include/asm-parisc/checksum.h55
-rw-r--r--include/asm-parisc/device.h7
-rw-r--r--include/asm-parisc/dma.h6
-rw-r--r--include/asm-parisc/pci.h2
-rw-r--r--include/asm-parisc/ropes.h2
-rw-r--r--include/asm-parisc/semaphore.h6
-rw-r--r--include/asm-powerpc/checksum.h59
-rw-r--r--include/asm-powerpc/device.h7
-rw-r--r--include/asm-powerpc/pci.h20
-rw-r--r--include/asm-ppc/device.h7
-rw-r--r--include/asm-s390/checksum.h45
-rw-r--r--include/asm-s390/device.h7
-rw-r--r--include/asm-sh/checksum.h59
-rw-r--r--include/asm-sh/device.h7
-rw-r--r--include/asm-sh64/checksum.h41
-rw-r--r--include/asm-sh64/device.h7
-rw-r--r--include/asm-sparc/checksum.h103
-rw-r--r--include/asm-sparc/device.h7
-rw-r--r--include/asm-sparc64/checksum.h77
-rw-r--r--include/asm-sparc64/device.h7
-rw-r--r--include/asm-sparc64/pci.h6
-rw-r--r--include/asm-um/device.h7
-rw-r--r--include/asm-v850/checksum.h38
-rw-r--r--include/asm-v850/device.h7
-rw-r--r--include/asm-x86_64/checksum.h54
-rw-r--r--include/asm-x86_64/device.h15
-rw-r--r--include/asm-xtensa/checksum.h64
-rw-r--r--include/asm-xtensa/device.h7
-rw-r--r--include/linux/Kbuild5
-rw-r--r--include/linux/atmarp.h2
-rw-r--r--include/linux/atmbr2684.h4
-rw-r--r--include/linux/atmmpc.h16
-rw-r--r--include/linux/blkdev.h7
-rw-r--r--include/linux/blktrace_api.h12
-rw-r--r--include/linux/dccp.h63
-rw-r--r--include/linux/device.h35
-rw-r--r--include/linux/divert.h132
-rw-r--r--include/linux/elevator.h4
-rw-r--r--include/linux/fb.h8
-rw-r--r--include/linux/fib_rules.h3
-rw-r--r--include/linux/ftape-header-segment.h122
-rw-r--r--include/linux/ftape-vendors.h137
-rw-r--r--include/linux/ftape.h201
-rw-r--r--include/linux/icmp.h2
-rw-r--r--include/linux/icmpv6.h12
-rw-r--r--include/linux/if_packet.h6
-rw-r--r--include/linux/if_tunnel.h8
-rw-r--r--include/linux/igmp.h2
-rw-r--r--include/linux/in.h1
-rw-r--r--include/linux/in6.h4
-rw-r--r--include/linux/inet.h4
-rw-r--r--include/linux/inetdevice.h14
-rw-r--r--include/linux/ioport.h1
-rw-r--r--include/linux/ip.h2
-rw-r--r--include/linux/ip6_tunnel.h2
-rw-r--r--include/linux/ipv6.h2
-rw-r--r--include/linux/ixjuser.h2
-rw-r--r--include/linux/jiffies.h2
-rw-r--r--include/linux/kernel.h6
-rw-r--r--include/linux/kexec.h2
-rw-r--r--include/linux/kobject.h8
-rw-r--r--include/linux/miscdevice.h5
-rw-r--r--include/linux/mmc/card.h13
-rw-r--r--include/linux/mmc/host.h8
-rw-r--r--include/linux/mmc/protocol.h74
-rw-r--r--include/linux/module.h1
-rw-r--r--include/linux/mqueue.h2
-rw-r--r--include/linux/mv643xx.h4
-rw-r--r--include/linux/net.h2
-rw-r--r--include/linux/netdevice.h18
-rw-r--r--include/linux/netfilter.h44
-rw-r--r--include/linux/netfilter/Kbuild2
-rw-r--r--include/linux/netfilter/nf_conntrack_amanda.h10
-rw-r--r--include/linux/netfilter/nf_conntrack_ftp.h20
-rw-r--r--include/linux/netfilter/nf_conntrack_h323.h92
-rw-r--r--include/linux/netfilter/nf_conntrack_h323_asn1.h (renamed from include/linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h)10
-rw-r--r--include/linux/netfilter/nf_conntrack_h323_types.h (renamed from include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h)12
-rw-r--r--include/linux/netfilter/nf_conntrack_irc.h15
-rw-r--r--include/linux/netfilter/nf_conntrack_pptp.h321
-rw-r--r--include/linux/netfilter/nf_conntrack_proto_gre.h112
-rw-r--r--include/linux/netfilter/nf_conntrack_sctp.h2
-rw-r--r--include/linux/netfilter/nf_conntrack_sip.h41
-rw-r--r--include/linux/netfilter/nf_conntrack_tftp.h20
-rw-r--r--include/linux/netfilter/nfnetlink.h2
-rw-r--r--include/linux/netfilter/nfnetlink_log.h12
-rw-r--r--include/linux/netfilter/nfnetlink_queue.h19
-rw-r--r--include/linux/netfilter/xt_NFLOG.h18
-rw-r--r--include/linux/netfilter/xt_conntrack.h4
-rw-r--r--include/linux/netfilter/xt_hashlimit.h40
-rw-r--r--include/linux/netfilter/xt_policy.h2
-rw-r--r--include/linux/netfilter_bridge.h2
-rw-r--r--include/linux/netfilter_bridge/ebt_802_3.h10
-rw-r--r--include/linux/netfilter_bridge/ebt_among.h2
-rw-r--r--include/linux/netfilter_bridge/ebt_arp.h14
-rw-r--r--include/linux/netfilter_bridge/ebt_ip.h8
-rw-r--r--include/linux/netfilter_bridge/ebt_nat.h1
-rw-r--r--include/linux/netfilter_bridge/ebt_vlan.h2
-rw-r--r--include/linux/netfilter_bridge/ebtables.h25
-rw-r--r--include/linux/netfilter_ipv4.h2
-rw-r--r--include/linux/netfilter_ipv4/Kbuild2
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack.h2
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_ftp.h40
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_h323.h2
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h4
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_sip.h34
-rw-r--r--include/linux/netfilter_ipv4/ip_conntrack_tftp.h2
-rw-r--r--include/linux/netfilter_ipv4/ipt_LOG.h2
-rw-r--r--include/linux/netfilter_ipv4/ipt_hashlimit.h42
-rw-r--r--include/linux/netfilter_ipv6.h2
-rw-r--r--include/linux/netfilter_ipv6/ip6t_LOG.h2
-rw-r--r--include/linux/netlink.h2
-rw-r--r--include/linux/netpoll.h15
-rw-r--r--include/linux/nfs_fs.h2
-rw-r--r--include/linux/nsproxy.h4
-rw-r--r--include/linux/pci.h3
-rw-r--r--include/linux/pci_ids.h12
-rw-r--r--include/linux/pci_regs.h6
-rw-r--r--include/linux/pfkeyv2.h4
-rw-r--r--include/linux/phy.h30
-rw-r--r--include/linux/platform_device.h6
-rw-r--r--include/linux/random.h20
-rw-r--r--include/linux/reiserfs_fs_sb.h2
-rw-r--r--include/linux/rtnetlink.h5
-rw-r--r--include/linux/sctp.h72
-rw-r--r--include/linux/security.h56
-rw-r--r--include/linux/skbuff.h26
-rw-r--r--include/linux/socket.h3
-rw-r--r--include/linux/sockios.h4
-rw-r--r--include/linux/spinlock.h14
-rw-r--r--include/linux/spinlock_api_smp.h2
-rw-r--r--include/linux/sunrpc/xdr.h2
-rw-r--r--include/linux/sysctl.h12
-rw-r--r--include/linux/sysfs.h8
-rw-r--r--include/linux/tcp.h190
-rw-r--r--include/linux/textsearch.h4
-rw-r--r--include/linux/tfrc.h20
-rw-r--r--include/linux/tipc_config.h32
-rw-r--r--include/linux/tty.h5
-rw-r--r--include/linux/types.h4
-rw-r--r--include/linux/udp.h14
-rw-r--r--include/linux/usb.h181
-rw-r--r--include/linux/wireless.h2
-rw-r--r--include/linux/xfrm.h6
-rw-r--r--include/linux/zftape.h87
-rw-r--r--include/net/addrconf.h8
-rw-r--r--include/net/arp.h2
-rw-r--r--include/net/atmclip.h2
-rw-r--r--include/net/bluetooth/rfcomm.h4
-rw-r--r--include/net/checksum.h43
-rw-r--r--include/net/cipso_ipv4.h4
-rw-r--r--include/net/dsfield.h10
-rw-r--r--include/net/fib_rules.h10
-rw-r--r--include/net/flow.h9
-rw-r--r--include/net/genetlink.h54
-rw-r--r--include/net/ieee80211.h6
-rw-r--r--include/net/if_inet6.h1
-rw-r--r--include/net/inet6_connection_sock.h4
-rw-r--r--include/net/inet6_hashtables.h16
-rw-r--r--include/net/inet_connection_sock.h7
-rw-r--r--include/net/inet_ecn.h10
-rw-r--r--include/net/ip.h21
-rw-r--r--include/net/ip6_checksum.h76
-rw-r--r--include/net/ip6_fib.h5
-rw-r--r--include/net/ip6_route.h2
-rw-r--r--include/net/ip_fib.h2
-rw-r--r--include/net/ip_mp_alg.h4
-rw-r--r--include/net/ip_vs.h16
-rw-r--r--include/net/ipconfig.h8
-rw-r--r--include/net/ipip.h6
-rw-r--r--include/net/ipv6.h62
-rw-r--r--include/net/irda/irlap_frame.h16
-rw-r--r--include/net/llc_pdu.h10
-rw-r--r--include/net/ndisc.h4
-rw-r--r--include/net/netfilter/ipv4/nf_conntrack_ipv4.h29
-rw-r--r--include/net/netfilter/ipv6/nf_conntrack_ipv6.h25
-rw-r--r--include/net/netfilter/nf_conntrack.h171
-rw-r--r--include/net/netfilter/nf_conntrack_core.h16
-rw-r--r--include/net/netfilter/nf_conntrack_ecache.h95
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h80
-rw-r--r--include/net/netfilter/nf_conntrack_helper.h22
-rw-r--r--include/net/netfilter/nf_conntrack_l3proto.h15
-rw-r--r--include/net/netfilter/nf_conntrack_l4proto.h (renamed from include/net/netfilter/nf_conntrack_protocol.h)49
-rw-r--r--include/net/netfilter/nf_conntrack_tuple.h34
-rw-r--r--include/net/netfilter/nf_nat.h77
-rw-r--r--include/net/netfilter/nf_nat_core.h27
-rw-r--r--include/net/netfilter/nf_nat_helper.h32
-rw-r--r--include/net/netfilter/nf_nat_protocol.h70
-rw-r--r--include/net/netfilter/nf_nat_rule.h35
-rw-r--r--include/net/netlabel.h123
-rw-r--r--include/net/netlink.h21
-rw-r--r--include/net/protocol.h4
-rw-r--r--include/net/rawv6.h2
-rw-r--r--include/net/request_sock.h12
-rw-r--r--include/net/sch_generic.h6
-rw-r--r--include/net/sctp/command.h4
-rw-r--r--include/net/sctp/constants.h2
-rw-r--r--include/net/sctp/sctp.h2
-rw-r--r--include/net/sctp/sm.h6
-rw-r--r--include/net/sctp/structs.h21
-rw-r--r--include/net/sctp/tsnmap.h4
-rw-r--r--include/net/sock.h28
-rw-r--r--include/net/tcp.h159
-rw-r--r--include/net/timewait_sock.h3
-rw-r--r--include/net/tipc/tipc_bearer.h2
-rw-r--r--include/net/tipc/tipc_msg.h2
-rw-r--r--include/net/transp_v6.h2
-rw-r--r--include/net/udp.h96
-rw-r--r--include/net/udplite.h151
-rw-r--r--include/net/xfrm.h66
-rw-r--r--include/rdma/ib_cm.h16
-rw-r--r--include/rdma/ib_user_cm.h7
-rw-r--r--include/scsi/libsas.h1
-rw-r--r--include/sound/core.h8
-rw-r--r--include/sound/version.h2
-rw-r--r--init/Kconfig20
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/irq/handle.c4
-rw-r--r--kernel/irq/spurious.c6
-rw-r--r--kernel/kmod.c8
-rw-r--r--kernel/module.c31
-rw-r--r--kernel/spinlock.c21
-rw-r--r--kernel/taskstats.c11
-rw-r--r--kernel/unwind.c9
-rw-r--r--lib/kobject.c50
-rw-r--r--lib/kobject_uevent.c28
-rw-r--r--lib/textsearch.c2
-rw-r--r--mm/page_alloc.c6
-rw-r--r--net/802/hippi.c1
-rw-r--r--net/Kconfig29
-rw-r--r--net/atm/Makefile3
-rw-r--r--net/atm/br2684.c30
-rw-r--r--net/atm/clip.c39
-rw-r--r--net/atm/ipcommon.c63
-rw-r--r--net/atm/ipcommon.h22
-rw-r--r--net/atm/lec.c16
-rw-r--r--net/atm/lec.h6
-rw-r--r--net/atm/mpc.c29
-rw-r--r--net/atm/mpc.h6
-rw-r--r--net/atm/mpoa_caches.c20
-rw-r--r--net/atm/mpoa_caches.h16
-rw-r--r--net/atm/mpoa_proc.c6
-rw-r--r--net/ax25/af_ax25.c6
-rw-r--r--net/ax25/ax25_out.c4
-rw-r--r--net/ax25/ax25_route.c5
-rw-r--r--net/ax25/sysctl_net_ax25.c5
-rw-r--r--net/bluetooth/bnep/bnep.h4
-rw-r--r--net/bluetooth/bnep/core.c28
-rw-r--r--net/bluetooth/bnep/netdev.c11
-rw-r--r--net/bluetooth/l2cap.c4
-rw-r--r--net/bluetooth/rfcomm/core.c18
-rw-r--r--net/bridge/br_ioctl.c9
-rw-r--r--net/bridge/br_netfilter.c3
-rw-r--r--net/bridge/br_netlink.c113
-rw-r--r--net/bridge/netfilter/ebt_802_3.c2
-rw-r--r--net/bridge/netfilter/ebt_among.c22
-rw-r--r--net/bridge/netfilter/ebt_arp.c6
-rw-r--r--net/bridge/netfilter/ebt_ip.c4
-rw-r--r--net/bridge/netfilter/ebt_log.c6
-rw-r--r--net/bridge/netfilter/ebt_mark.c14
-rw-r--r--net/bridge/netfilter/ebt_mark_m.c4
-rw-r--r--net/bridge/netfilter/ebt_snat.c27
-rw-r--r--net/bridge/netfilter/ebt_ulog.c2
-rw-r--r--net/bridge/netfilter/ebt_vlan.c2
-rw-r--r--net/bridge/netfilter/ebtable_broute.c2
-rw-r--r--net/bridge/netfilter/ebtable_filter.c2
-rw-r--r--net/bridge/netfilter/ebtable_nat.c2
-rw-r--r--net/bridge/netfilter/ebtables.c222
-rw-r--r--net/core/Makefile1
-rw-r--r--net/core/datagram.c16
-rw-r--r--net/core/dev.c39
-rw-r--r--net/core/dv.c546
-rw-r--r--net/core/fib_rules.c71
-rw-r--r--net/core/filter.c6
-rw-r--r--net/core/iovec.c4
-rw-r--r--net/core/neighbour.c24
-rw-r--r--net/core/netpoll.c327
-rw-r--r--net/core/pktgen.c68
-rw-r--r--net/core/request_sock.c35
-rw-r--r--net/core/rtnetlink.c60
-rw-r--r--net/core/skbuff.c26
-rw-r--r--net/core/sock.c13
-rw-r--r--net/core/sysctl_net_core.c14
-rw-r--r--net/core/utils.c10
-rw-r--r--net/dccp/Kconfig5
-rw-r--r--net/dccp/Makefile8
-rw-r--r--net/dccp/ackvec.c116
-rw-r--r--net/dccp/ackvec.h20
-rw-r--r--net/dccp/ccid.h12
-rw-r--r--net/dccp/ccids/Kconfig25
-rw-r--r--net/dccp/ccids/ccid2.c45
-rw-r--r--net/dccp/ccids/ccid2.h3
-rw-r--r--net/dccp/ccids/ccid3.c549
-rw-r--r--net/dccp/ccids/ccid3.h119
-rw-r--r--net/dccp/ccids/lib/loss_interval.c6
-rw-r--r--net/dccp/ccids/lib/tfrc_equation.c7
-rw-r--r--net/dccp/dccp.h110
-rw-r--r--net/dccp/feat.c131
-rw-r--r--net/dccp/feat.h48
-rw-r--r--net/dccp/input.c63
-rw-r--r--net/dccp/ipv4.c537
-rw-r--r--net/dccp/ipv6.c613
-rw-r--r--net/dccp/minisocks.c48
-rw-r--r--net/dccp/options.c61
-rw-r--r--net/dccp/output.c84
-rw-r--r--net/dccp/probe.c8
-rw-r--r--net/dccp/proto.c64
-rw-r--r--net/dccp/sysctl.c60
-rw-r--r--net/dccp/timer.c134
-rw-r--r--net/decnet/Kconfig8
-rw-r--r--net/decnet/dn_dev.c173
-rw-r--r--net/decnet/dn_neigh.c1
-rw-r--r--net/decnet/dn_nsp_in.c2
-rw-r--r--net/decnet/dn_route.c46
-rw-r--r--net/decnet/dn_rules.c43
-rw-r--r--net/decnet/dn_table.c42
-rw-r--r--net/ethernet/eth.c1
-rw-r--r--net/ieee80211/ieee80211_module.c25
-rw-r--r--net/ieee80211/ieee80211_rx.c68
-rw-r--r--net/ieee80211/ieee80211_tx.c4
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_auth.c24
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_scan.c7
-rw-r--r--net/ipv4/Kconfig19
-rw-r--r--net/ipv4/Makefile3
-rw-r--r--net/ipv4/af_inet.c16
-rw-r--r--net/ipv4/ah4.c4
-rw-r--r--net/ipv4/arp.c2
-rw-r--r--net/ipv4/cipso_ipv4.c813
-rw-r--r--net/ipv4/devinet.c32
-rw-r--r--net/ipv4/esp4.c4
-rw-r--r--net/ipv4/fib_frontend.c5
-rw-r--r--net/ipv4/fib_rules.c53
-rw-r--r--net/ipv4/fib_semantics.c36
-rw-r--r--net/ipv4/icmp.c6
-rw-r--r--net/ipv4/igmp.c2
-rw-r--r--net/ipv4/inet_connection_sock.c2
-rw-r--r--net/ipv4/ip_gre.c56
-rw-r--r--net/ipv4/ip_output.c19
-rw-r--r--net/ipv4/ip_sockglue.c2
-rw-r--r--net/ipv4/ipconfig.c105
-rw-r--r--net/ipv4/ipip.c16
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_app.c3
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c4
-rw-r--r--net/ipv4/ipvs/ip_vs_proto.c8
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_tcp.c16
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_udp.c22
-rw-r--r--net/ipv4/netfilter.c10
-rw-r--r--net/ipv4/netfilter/Kconfig138
-rw-r--r--net/ipv4/netfilter/Makefile30
-rw-r--r--net/ipv4/netfilter/ip_conntrack_amanda.c11
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c14
-rw-r--r--net/ipv4/netfilter/ip_conntrack_ftp.c8
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323.c172
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_pptp.c33
-rw-r--r--net/ipv4/netfilter/ip_conntrack_irc.c12
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c66
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_gre.c2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_sip.c118
-rw-r--r--net/ipv4/netfilter/ip_conntrack_standalone.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_tftp.c6
-rw-r--r--net/ipv4/netfilter/ip_nat_amanda.c9
-rw-r--r--net/ipv4/netfilter/ip_nat_core.c6
-rw-r--r--net/ipv4/netfilter/ip_nat_ftp.c9
-rw-r--r--net/ipv4/netfilter/ip_nat_helper.c32
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_h323.c58
-rw-r--r--net/ipv4/netfilter/ip_nat_helper_pptp.c29
-rw-r--r--net/ipv4/netfilter/ip_nat_irc.c9
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_gre.c8
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_icmp.c10
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_tcp.c5
-rw-r--r--net/ipv4/netfilter/ip_nat_proto_udp.c9
-rw-r--r--net/ipv4/netfilter/ip_nat_sip.c199
-rw-r--r--net/ipv4/netfilter/ip_nat_snmp_basic.c85
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c6
-rw-r--r--net/ipv4/netfilter/ip_nat_tftp.c9
-rw-r--r--net/ipv4/netfilter/ip_queue.c2
-rw-r--r--net/ipv4/netfilter/ipt_CLUSTERIP.c25
-rw-r--r--net/ipv4/netfilter/ipt_ECN.c11
-rw-r--r--net/ipv4/netfilter/ipt_LOG.c20
-rw-r--r--net/ipv4/netfilter/ipt_MASQUERADE.c29
-rw-r--r--net/ipv4/netfilter/ipt_NETMAP.c4
-rw-r--r--net/ipv4/netfilter/ipt_REDIRECT.c6
-rw-r--r--net/ipv4/netfilter/ipt_REJECT.c18
-rw-r--r--net/ipv4/netfilter/ipt_SAME.c12
-rw-r--r--net/ipv4/netfilter/ipt_TCPMSS.c24
-rw-r--r--net/ipv4/netfilter/ipt_TOS.c5
-rw-r--r--net/ipv4/netfilter/ipt_TTL.c5
-rw-r--r--net/ipv4/netfilter/ipt_ULOG.c2
-rw-r--r--net/ipv4/netfilter/iptable_mangle.c8
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c137
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c412
-rw-r--r--net/ipv4/netfilter/nf_conntrack_proto_icmp.c57
-rw-r--r--net/ipv4/netfilter/nf_nat_amanda.c78
-rw-r--r--net/ipv4/netfilter/nf_nat_core.c647
-rw-r--r--net/ipv4/netfilter/nf_nat_ftp.c179
-rw-r--r--net/ipv4/netfilter/nf_nat_h323.c596
-rw-r--r--net/ipv4/netfilter/nf_nat_helper.c433
-rw-r--r--net/ipv4/netfilter/nf_nat_irc.c101
-rw-r--r--net/ipv4/netfilter/nf_nat_pptp.c315
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_gre.c179
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_icmp.c86
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_tcp.c148
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_udp.c138
-rw-r--r--net/ipv4/netfilter/nf_nat_proto_unknown.c54
-rw-r--r--net/ipv4/netfilter/nf_nat_rule.c343
-rw-r--r--net/ipv4/netfilter/nf_nat_sip.c283
-rw-r--r--net/ipv4/netfilter/nf_nat_snmp_basic.c1332
-rw-r--r--net/ipv4/netfilter/nf_nat_standalone.c406
-rw-r--r--net/ipv4/netfilter/nf_nat_tftp.c52
-rw-r--r--net/ipv4/proc.c13
-rw-r--r--net/ipv4/raw.c4
-rw-r--r--net/ipv4/route.c66
-rw-r--r--net/ipv4/syncookies.c18
-rw-r--r--net/ipv4/sysctl_net_ipv4.c76
-rw-r--r--net/ipv4/tcp.c156
-rw-r--r--net/ipv4/tcp_cong.c91
-rw-r--r--net/ipv4/tcp_htcp.c4
-rw-r--r--net/ipv4/tcp_input.c14
-rw-r--r--net/ipv4/tcp_ipv4.c713
-rw-r--r--net/ipv4/tcp_minisocks.c69
-rw-r--r--net/ipv4/tcp_output.c122
-rw-r--r--net/ipv4/tcp_probe.c2
-rw-r--r--net/ipv4/tcp_timer.c2
-rw-r--r--net/ipv4/tcp_vegas.c4
-rw-r--r--net/ipv4/udp.c558
-rw-r--r--net/ipv4/udp_impl.h38
-rw-r--r--net/ipv4/udplite.c119
-rw-r--r--net/ipv4/xfrm4_policy.c7
-rw-r--r--net/ipv6/Kconfig7
-rw-r--r--net/ipv6/Makefile4
-rw-r--r--net/ipv6/addrconf.c190
-rw-r--r--net/ipv6/af_inet6.c27
-rw-r--r--net/ipv6/ah6.c5
-rw-r--r--net/ipv6/datagram.c16
-rw-r--r--net/ipv6/esp6.c2
-rw-r--r--net/ipv6/exthdrs.c59
-rw-r--r--net/ipv6/exthdrs_core.c2
-rw-r--r--net/ipv6/fib6_rules.c60
-rw-r--r--net/ipv6/icmp.c23
-rw-r--r--net/ipv6/inet6_connection_sock.c17
-rw-r--r--net/ipv6/inet6_hashtables.c6
-rw-r--r--net/ipv6/ip6_fib.c8
-rw-r--r--net/ipv6/ip6_flowlabel.c8
-rw-r--r--net/ipv6/ip6_input.c42
-rw-r--r--net/ipv6/ip6_output.c84
-rw-r--r--net/ipv6/ip6_tunnel.c296
-rw-r--r--net/ipv6/ipcomp6.c2
-rw-r--r--net/ipv6/ipv6_sockglue.c11
-rw-r--r--net/ipv6/mcast.c36
-rw-r--r--net/ipv6/mip6.c4
-rw-r--r--net/ipv6/ndisc.c29
-rw-r--r--net/ipv6/netfilter.c11
-rw-r--r--net/ipv6/netfilter/Kconfig2
-rw-r--r--net/ipv6/netfilter/ip6_queue.c4
-rw-r--r--net/ipv6/netfilter/ip6_tables.c3
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c23
-rw-r--r--net/ipv6/netfilter/ip6table_mangle.c9
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c93
-rw-r--r--net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c40
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c26
-rw-r--r--net/ipv6/proc.c18
-rw-r--r--net/ipv6/raw.c25
-rw-r--r--net/ipv6/reassembly.c87
-rw-r--r--net/ipv6/route.c97
-rw-r--r--net/ipv6/sit.c22
-rw-r--r--net/ipv6/tcp_ipv6.c607
-rw-r--r--net/ipv6/tunnel6.c2
-rw-r--r--net/ipv6/udp.c426
-rw-r--r--net/ipv6/udp_impl.h34
-rw-r--r--net/ipv6/udplite.c105
-rw-r--r--net/ipv6/xfrm6_policy.c3
-rw-r--r--net/ipv6/xfrm6_tunnel.c8
-rw-r--r--net/irda/iriap.c11
-rw-r--r--net/irda/irias_object.c4
-rw-r--r--net/irda/irlan/irlan_common.c2
-rw-r--r--net/irda/irlmp.c4
-rw-r--r--net/irda/irqueue.c3
-rw-r--r--net/irda/irttp.c4
-rw-r--r--net/key/af_key.c42
-rw-r--r--net/llc/af_llc.c2
-rw-r--r--net/llc/llc_input.c4
-rw-r--r--net/netfilter/Kconfig193
-rw-r--r--net/netfilter/Makefile17
-rw-r--r--net/netfilter/core.c31
-rw-r--r--net/netfilter/nf_conntrack_amanda.c238
-rw-r--r--net/netfilter/nf_conntrack_core.c699
-rw-r--r--net/netfilter/nf_conntrack_ecache.c93
-rw-r--r--net/netfilter/nf_conntrack_expect.c442
-rw-r--r--net/netfilter/nf_conntrack_ftp.c42
-rw-r--r--net/netfilter/nf_conntrack_h323_asn1.c (renamed from net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c)4
-rw-r--r--net/netfilter/nf_conntrack_h323_main.c1856
-rw-r--r--net/netfilter/nf_conntrack_h323_types.c (renamed from net/ipv4/netfilter/ip_conntrack_helper_h323_types.c)7
-rw-r--r--net/netfilter/nf_conntrack_helper.c155
-rw-r--r--net/netfilter/nf_conntrack_irc.c281
-rw-r--r--net/netfilter/nf_conntrack_l3proto_generic.c7
-rw-r--r--net/netfilter/nf_conntrack_netbios_ns.c126
-rw-r--r--net/netfilter/nf_conntrack_netlink.c214
-rw-r--r--net/netfilter/nf_conntrack_pptp.c607
-rw-r--r--net/netfilter/nf_conntrack_proto.c410
-rw-r--r--net/netfilter/nf_conntrack_proto_generic.c47
-rw-r--r--net/netfilter/nf_conntrack_proto_gre.c305
-rw-r--r--net/netfilter/nf_conntrack_proto_sctp.c182
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c275
-rw-r--r--net/netfilter/nf_conntrack_proto_udp.c83
-rw-r--r--net/netfilter/nf_conntrack_sip.c531
-rw-r--r--net/netfilter/nf_conntrack_standalone.c444
-rw-r--r--net/netfilter/nf_conntrack_tftp.c160
-rw-r--r--net/netfilter/nf_sysctl.c134
-rw-r--r--net/netfilter/nfnetlink_log.c45
-rw-r--r--net/netfilter/nfnetlink_queue.c23
-rw-r--r--net/netfilter/xt_CONNMARK.c13
-rw-r--r--net/netfilter/xt_MARK.c12
-rw-r--r--net/netfilter/xt_NFLOG.c86
-rw-r--r--net/netfilter/xt_hashlimit.c (renamed from net/ipv4/netfilter/ipt_hashlimit.c)511
-rw-r--r--net/netfilter/xt_mark.c2
-rw-r--r--net/netfilter/xt_multiport.c9
-rw-r--r--net/netfilter/xt_sctp.c2
-rw-r--r--net/netfilter/xt_tcpudp.c20
-rw-r--r--net/netlabel/netlabel_cipso_v4.c47
-rw-r--r--net/netlabel/netlabel_domainhash.c48
-rw-r--r--net/netlabel/netlabel_kapi.c212
-rw-r--r--net/netlabel/netlabel_mgmt.c42
-rw-r--r--net/netlabel/netlabel_unlabeled.c48
-rw-r--r--net/netlabel/netlabel_user.c7
-rw-r--r--net/netlabel/netlabel_user.h31
-rw-r--r--net/netlink/af_netlink.c14
-rw-r--r--net/netlink/genetlink.c70
-rw-r--r--net/netrom/nr_route.c12
-rw-r--r--net/packet/af_packet.c18
-rw-r--r--net/rose/rose_route.c4
-rw-r--r--net/rxrpc/transport.c1
-rw-r--r--net/sched/Kconfig6
-rw-r--r--net/sched/Makefile3
-rw-r--r--net/sched/act_gact.c4
-rw-r--r--net/sched/act_ipt.c6
-rw-r--r--net/sched/act_police.c26
-rw-r--r--net/sched/act_simple.c3
-rw-r--r--net/sched/cls_api.c3
-rw-r--r--net/sched/cls_fw.c6
-rw-r--r--net/sched/cls_rsvp.h16
-rw-r--r--net/sched/cls_u32.c2
-rw-r--r--net/sched/em_meta.c13
-rw-r--r--net/sched/em_nbyte.c4
-rw-r--r--net/sched/ematch.c3
-rw-r--r--net/sched/sch_api.c41
-rw-r--r--net/sched/sch_atm.c5
-rw-r--r--net/sched/sch_cbq.c10
-rw-r--r--net/sched/sch_dsmark.c9
-rw-r--r--net/sched/sch_generic.c10
-rw-r--r--net/sched/sch_hfsc.c27
-rw-r--r--net/sched/sch_htb.c36
-rw-r--r--net/sched/sch_netem.c10
-rw-r--r--net/sched/sch_prio.c14
-rw-r--r--net/sched/sch_red.c14
-rw-r--r--net/sched/sch_sfq.c3
-rw-r--r--net/sched/sch_tbf.c16
-rw-r--r--net/sctp/associola.c22
-rw-r--r--net/sctp/bind_addr.c4
-rw-r--r--net/sctp/endpointola.c11
-rw-r--r--net/sctp/input.c6
-rw-r--r--net/sctp/ipv6.c24
-rw-r--r--net/sctp/outqueue.c4
-rw-r--r--net/sctp/proc.c6
-rw-r--r--net/sctp/protocol.c24
-rw-r--r--net/sctp/sm_make_chunk.c65
-rw-r--r--net/sctp/sm_sideeffect.c8
-rw-r--r--net/sctp/sm_statefuns.c55
-rw-r--r--net/sctp/sm_statetable.c696
-rw-r--r--net/sctp/socket.c77
-rw-r--r--net/sctp/tsnmap.c9
-rw-r--r--net/sctp/ulpevent.c2
-rw-r--r--net/socket.c6
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c3
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_mech.c3
-rw-r--r--net/sunrpc/auth_gss/gss_spkm3_mech.c3
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c7
-rw-r--r--net/sunrpc/clnt.c3
-rw-r--r--net/sunrpc/socklib.c7
-rw-r--r--net/sunrpc/svcauth_unix.c8
-rw-r--r--net/tipc/bcast.c6
-rw-r--r--net/tipc/config.c32
-rw-r--r--net/tipc/dbg.c3
-rw-r--r--net/tipc/name_distr.c10
-rw-r--r--net/tipc/node.c12
-rw-r--r--net/tipc/subscr.c3
-rw-r--r--net/unix/af_unix.c3
-rw-r--r--net/wanrouter/af_wanpipe.c4
-rw-r--r--net/wanrouter/wanmain.c2
-rw-r--r--net/xfrm/xfrm_policy.c38
-rw-r--r--net/xfrm/xfrm_state.c2
-rw-r--r--net/xfrm/xfrm_user.c58
-rw-r--r--scripts/gen_initramfs_list.sh3
-rw-r--r--scripts/kconfig/lxdialog/util.c16
-rw-r--r--scripts/kconfig/qconf.cc1
-rw-r--r--security/dummy.c17
-rw-r--r--security/selinux/avc.c23
-rw-r--r--security/selinux/hooks.c155
-rw-r--r--security/selinux/include/av_inherit.h1
-rw-r--r--security/selinux/include/av_perm_to_string.h8
-rw-r--r--security/selinux/include/av_permissions.h32
-rw-r--r--security/selinux/include/avc_ss.h24
-rw-r--r--security/selinux/include/class_to_string.h2
-rw-r--r--security/selinux/include/flask.h2
-rw-r--r--security/selinux/include/objsec.h2
-rw-r--r--security/selinux/include/security.h4
-rw-r--r--security/selinux/include/selinux_netlabel.h43
-rw-r--r--security/selinux/include/xfrm.h28
-rw-r--r--security/selinux/nlmsgtab.c1
-rw-r--r--security/selinux/ss/ebitmap.c198
-rw-r--r--security/selinux/ss/ebitmap.h26
-rw-r--r--security/selinux/ss/hashtab.c6
-rw-r--r--security/selinux/ss/hashtab.h10
-rw-r--r--security/selinux/ss/mls.c156
-rw-r--r--security/selinux/ss/mls.h46
-rw-r--r--security/selinux/ss/policydb.c6
-rw-r--r--security/selinux/ss/services.c437
-rw-r--r--security/selinux/ss/symtab.c8
-rw-r--r--security/selinux/xfrm.c207
-rw-r--r--sound/Kconfig4
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-tas.c13
-rw-r--r--sound/core/init.c8
-rw-r--r--sound/core/oss/pcm_oss.c3
-rw-r--r--sound/core/pcm.c7
-rw-r--r--sound/core/pcm_native.c6
-rw-r--r--sound/core/rtctimer.c20
-rw-r--r--sound/core/sound.c22
-rw-r--r--sound/oss/cs46xx.c6
-rw-r--r--sound/oss/soundcard.c16
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c1
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/pci/hda/patch_sigmatel.c14
-rw-r--r--sound/sound_core.c6
-rw-r--r--sound/usb/usbaudio.c3
-rw-r--r--sound/usb/usbmidi.c2
-rw-r--r--sound/usb/usbmixer.c9
-rw-r--r--usr/Makefile2
1476 files changed, 67631 insertions, 41020 deletions
diff --git a/CREDITS b/CREDITS
index ccd4f9f4dd71..d0880082c19b 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2598,6 +2598,9 @@ S: Ucitelska 1576
2598S: Prague 8 2598S: Prague 8
2599S: 182 00 Czech Republic 2599S: 182 00 Czech Republic
2600 2600
2601N: Rick Payne
2602D: RFC2385 Support for TCP
2603
2601N: Barak A. Pearlmutter 2604N: Barak A. Pearlmutter
2602E: bap@cs.unm.edu 2605E: bap@cs.unm.edu
2603W: http://www.cs.unm.edu/~bap/ 2606W: http://www.cs.unm.edu/~bap/
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index 02457ec9c94f..f08ca9535733 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -104,8 +104,6 @@ firmware_class/
104 - request_firmware() hotplug interface info. 104 - request_firmware() hotplug interface info.
105floppy.txt 105floppy.txt
106 - notes and driver options for the floppy disk driver. 106 - notes and driver options for the floppy disk driver.
107ftape.txt
108 - notes about the floppy tape device driver.
109hayes-esp.txt 107hayes-esp.txt
110 - info on using the Hayes ESP serial driver. 108 - info on using the Hayes ESP serial driver.
111highuid.txt 109highuid.txt
diff --git a/Documentation/Changes b/Documentation/Changes
index abee7f58c1ed..73a8617f1861 100644
--- a/Documentation/Changes
+++ b/Documentation/Changes
@@ -201,7 +201,7 @@ udev
201---- 201----
202udev is a userspace application for populating /dev dynamically with 202udev is a userspace application for populating /dev dynamically with
203only entries for devices actually present. udev replaces the basic 203only entries for devices actually present. udev replaces the basic
204functionality of devfs, while allowing persistant device naming for 204functionality of devfs, while allowing persistent device naming for
205devices. 205devices.
206 206
207FUSE 207FUSE
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 2ffb0d62f0fe..05431621c861 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -489,7 +489,7 @@ size is the size of the area (must be multiples of PAGE_SIZE).
489flags can be or'd together and are 489flags can be or'd together and are
490 490
491DMA_MEMORY_MAP - request that the memory returned from 491DMA_MEMORY_MAP - request that the memory returned from
492dma_alloc_coherent() be directly writeable. 492dma_alloc_coherent() be directly writable.
493 493
494DMA_MEMORY_IO - request that the memory returned from 494DMA_MEMORY_IO - request that the memory returned from
495dma_alloc_coherent() be addressable using read/write/memcpy_toio etc. 495dma_alloc_coherent() be addressable using read/write/memcpy_toio etc.
diff --git a/Documentation/DMA-ISA-LPC.txt b/Documentation/DMA-ISA-LPC.txt
index 705f6be92bdb..e767805b4182 100644
--- a/Documentation/DMA-ISA-LPC.txt
+++ b/Documentation/DMA-ISA-LPC.txt
@@ -110,7 +110,7 @@ lock.
110 110
111Once the DMA transfer is finished (or timed out) you should disable 111Once the DMA transfer is finished (or timed out) you should disable
112the channel again. You should also check get_dma_residue() to make 112the channel again. You should also check get_dma_residue() to make
113sure that all data has been transfered. 113sure that all data has been transferred.
114 114
115Example: 115Example:
116 116
diff --git a/Documentation/DocBook/writing_usb_driver.tmpl b/Documentation/DocBook/writing_usb_driver.tmpl
index 07cd34c1940b..d4188d4ff535 100644
--- a/Documentation/DocBook/writing_usb_driver.tmpl
+++ b/Documentation/DocBook/writing_usb_driver.tmpl
@@ -345,8 +345,7 @@ static inline void skel_delete (struct usb_skel *dev)
345 usb_buffer_free (dev->udev, dev->bulk_out_size, 345 usb_buffer_free (dev->udev, dev->bulk_out_size,
346 dev->bulk_out_buffer, 346 dev->bulk_out_buffer,
347 dev->write_urb->transfer_dma); 347 dev->write_urb->transfer_dma);
348 if (dev->write_urb != NULL) 348 usb_free_urb (dev->write_urb);
349 usb_free_urb (dev->write_urb);
350 kfree (dev); 349 kfree (dev);
351} 350}
352 </programlisting> 351 </programlisting>
diff --git a/Documentation/MSI-HOWTO.txt b/Documentation/MSI-HOWTO.txt
index 5c34910665d1..d389388c733e 100644
--- a/Documentation/MSI-HOWTO.txt
+++ b/Documentation/MSI-HOWTO.txt
@@ -219,7 +219,7 @@ into the field vector of each element contained in a second argument.
219Note that the pre-assigned IOAPIC dev->irq is valid only if the device 219Note that the pre-assigned IOAPIC dev->irq is valid only if the device
220operates in PIN-IRQ assertion mode. In MSI-X mode, any attempt at 220operates in PIN-IRQ assertion mode. In MSI-X mode, any attempt at
221using dev->irq by the device driver to request for interrupt service 221using dev->irq by the device driver to request for interrupt service
222may result unpredictabe behavior. 222may result in unpredictable behavior.
223 223
224For each MSI-X vector granted, a device driver is responsible for calling 224For each MSI-X vector granted, a device driver is responsible for calling
225other functions like request_irq(), enable_irq(), etc. to enable 225other functions like request_irq(), enable_irq(), etc. to enable
diff --git a/Documentation/accounting/taskstats.txt b/Documentation/accounting/taskstats.txt
index 92ebf29e9041..ff06b738bb88 100644
--- a/Documentation/accounting/taskstats.txt
+++ b/Documentation/accounting/taskstats.txt
@@ -96,9 +96,9 @@ a) TASKSTATS_TYPE_AGGR_PID/TGID : attribute containing no payload but indicates
96a pid/tgid will be followed by some stats. 96a pid/tgid will be followed by some stats.
97 97
98b) TASKSTATS_TYPE_PID/TGID: attribute whose payload is the pid/tgid whose stats 98b) TASKSTATS_TYPE_PID/TGID: attribute whose payload is the pid/tgid whose stats
99is being returned. 99are being returned.
100 100
101c) TASKSTATS_TYPE_STATS: attribute with a struct taskstsats as payload. The 101c) TASKSTATS_TYPE_STATS: attribute with a struct taskstats as payload. The
102same structure is used for both per-pid and per-tgid stats. 102same structure is used for both per-pid and per-tgid stats.
103 103
1043. New message sent by kernel whenever a task exits. The payload consists of a 1043. New message sent by kernel whenever a task exits. The payload consists of a
@@ -122,12 +122,12 @@ of atomicity).
122 122
123However, maintaining per-process, in addition to per-task stats, within the 123However, maintaining per-process, in addition to per-task stats, within the
124kernel has space and time overheads. To address this, the taskstats code 124kernel has space and time overheads. To address this, the taskstats code
125accumalates each exiting task's statistics into a process-wide data structure. 125accumulates each exiting task's statistics into a process-wide data structure.
126When the last task of a process exits, the process level data accumalated also 126When the last task of a process exits, the process level data accumulated also
127gets sent to userspace (along with the per-task data). 127gets sent to userspace (along with the per-task data).
128 128
129When a user queries to get per-tgid data, the sum of all other live threads in 129When a user queries to get per-tgid data, the sum of all other live threads in
130the group is added up and added to the accumalated total for previously exited 130the group is added up and added to the accumulated total for previously exited
131threads of the same thread group. 131threads of the same thread group.
132 132
133Extending taskstats 133Extending taskstats
diff --git a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt
index 34bf8f60d8f8..c6c9a9c10d7f 100644
--- a/Documentation/block/biodoc.txt
+++ b/Documentation/block/biodoc.txt
@@ -183,7 +183,7 @@ it, the pci dma mapping routines and associated data structures have now been
183modified to accomplish a direct page -> bus translation, without requiring 183modified to accomplish a direct page -> bus translation, without requiring
184a virtual address mapping (unlike the earlier scheme of virtual address 184a virtual address mapping (unlike the earlier scheme of virtual address
185-> bus translation). So this works uniformly for high-memory pages (which 185-> bus translation). So this works uniformly for high-memory pages (which
186do not have a correponding kernel virtual address space mapping) and 186do not have a corresponding kernel virtual address space mapping) and
187low-memory pages. 187low-memory pages.
188 188
189Note: Please refer to DMA-mapping.txt for a discussion on PCI high mem DMA 189Note: Please refer to DMA-mapping.txt for a discussion on PCI high mem DMA
@@ -391,7 +391,7 @@ forced such requests to be broken up into small chunks before being passed
391on to the generic block layer, only to be merged by the i/o scheduler 391on to the generic block layer, only to be merged by the i/o scheduler
392when the underlying device was capable of handling the i/o in one shot. 392when the underlying device was capable of handling the i/o in one shot.
393Also, using the buffer head as an i/o structure for i/os that didn't originate 393Also, using the buffer head as an i/o structure for i/os that didn't originate
394from the buffer cache unecessarily added to the weight of the descriptors 394from the buffer cache unnecessarily added to the weight of the descriptors
395which were generated for each such chunk. 395which were generated for each such chunk.
396 396
397The following were some of the goals and expectations considered in the 397The following were some of the goals and expectations considered in the
@@ -403,14 +403,14 @@ i. Should be appropriate as a descriptor for both raw and buffered i/o -
403 for raw i/o. 403 for raw i/o.
404ii. Ability to represent high-memory buffers (which do not have a virtual 404ii. Ability to represent high-memory buffers (which do not have a virtual
405 address mapping in kernel address space). 405 address mapping in kernel address space).
406iii.Ability to represent large i/os w/o unecessarily breaking them up (i.e 406iii.Ability to represent large i/os w/o unnecessarily breaking them up (i.e
407 greater than PAGE_SIZE chunks in one shot) 407 greater than PAGE_SIZE chunks in one shot)
408iv. At the same time, ability to retain independent identity of i/os from 408iv. At the same time, ability to retain independent identity of i/os from
409 different sources or i/o units requiring individual completion (e.g. for 409 different sources or i/o units requiring individual completion (e.g. for
410 latency reasons) 410 latency reasons)
411v. Ability to represent an i/o involving multiple physical memory segments 411v. Ability to represent an i/o involving multiple physical memory segments
412 (including non-page aligned page fragments, as specified via readv/writev) 412 (including non-page aligned page fragments, as specified via readv/writev)
413 without unecessarily breaking it up, if the underlying device is capable of 413 without unnecessarily breaking it up, if the underlying device is capable of
414 handling it. 414 handling it.
415vi. Preferably should be based on a memory descriptor structure that can be 415vi. Preferably should be based on a memory descriptor structure that can be
416 passed around different types of subsystems or layers, maybe even 416 passed around different types of subsystems or layers, maybe even
@@ -1013,7 +1013,7 @@ Characteristics:
1013i. Binary tree 1013i. Binary tree
1014AS and deadline i/o schedulers use red black binary trees for disk position 1014AS and deadline i/o schedulers use red black binary trees for disk position
1015sorting and searching, and a fifo linked list for time-based searching. This 1015sorting and searching, and a fifo linked list for time-based searching. This
1016gives good scalability and good availablility of information. Requests are 1016gives good scalability and good availability of information. Requests are
1017almost always dispatched in disk sort order, so a cache is kept of the next 1017almost always dispatched in disk sort order, so a cache is kept of the next
1018request in sort order to prevent binary tree lookups. 1018request in sort order to prevent binary tree lookups.
1019 1019
diff --git a/Documentation/cpu-freq/cpufreq-nforce2.txt b/Documentation/cpu-freq/cpufreq-nforce2.txt
index 9188337d8f6b..babce1315026 100644
--- a/Documentation/cpu-freq/cpufreq-nforce2.txt
+++ b/Documentation/cpu-freq/cpufreq-nforce2.txt
@@ -1,7 +1,7 @@
1 1
2The cpufreq-nforce2 driver changes the FSB on nVidia nForce2 plattforms. 2The cpufreq-nforce2 driver changes the FSB on nVidia nForce2 platforms.
3 3
4This works better than on other plattforms, because the FSB of the CPU 4This works better than on other platforms, because the FSB of the CPU
5can be controlled independently from the PCI/AGP clock. 5can be controlled independently from the PCI/AGP clock.
6 6
7The module has two options: 7The module has two options:
diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt
index 4868c34f7509..cc60d29b954c 100644
--- a/Documentation/cpu-hotplug.txt
+++ b/Documentation/cpu-hotplug.txt
@@ -54,8 +54,8 @@ additional_cpus=n (*) Use this to limit hotpluggable cpus. This option sets
54 54
55ia64 and x86_64 use the number of disabled local apics in ACPI tables MADT 55ia64 and x86_64 use the number of disabled local apics in ACPI tables MADT
56to determine the number of potentially hot-pluggable cpus. The implementation 56to determine the number of potentially hot-pluggable cpus. The implementation
57should only rely on this to count the #of cpus, but *MUST* not rely on the 57should only rely on this to count the # of cpus, but *MUST* not rely on the
58apicid values in those tables for disabled apics. In the event BIOS doesnt 58apicid values in those tables for disabled apics. In the event BIOS doesn't
59mark such hot-pluggable cpus as disabled entries, one could use this 59mark such hot-pluggable cpus as disabled entries, one could use this
60parameter "additional_cpus=x" to represent those cpus in the cpu_possible_map. 60parameter "additional_cpus=x" to represent those cpus in the cpu_possible_map.
61 61
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 28c4f79662c2..70690f1a14af 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -92,7 +92,7 @@ Your cooperation is appreciated.
92 7 = /dev/full Returns ENOSPC on write 92 7 = /dev/full Returns ENOSPC on write
93 8 = /dev/random Nondeterministic random number gen. 93 8 = /dev/random Nondeterministic random number gen.
94 9 = /dev/urandom Faster, less secure random number gen. 94 9 = /dev/urandom Faster, less secure random number gen.
95 10 = /dev/aio Asyncronous I/O notification interface 95 10 = /dev/aio Asynchronous I/O notification interface
96 11 = /dev/kmsg Writes to this come out as printk's 96 11 = /dev/kmsg Writes to this come out as printk's
97 1 block RAM disk 97 1 block RAM disk
98 0 = /dev/ram0 First RAM disk 98 0 = /dev/ram0 First RAM disk
@@ -1093,7 +1093,7 @@ Your cooperation is appreciated.
1093 1093
1094 55 char DSP56001 digital signal processor 1094 55 char DSP56001 digital signal processor
1095 0 = /dev/dsp56k First DSP56001 1095 0 = /dev/dsp56k First DSP56001
1096 55 block Mylex DAC960 PCI RAID controller; eigth controller 1096 55 block Mylex DAC960 PCI RAID controller; eighth controller
1097 0 = /dev/rd/c7d0 First disk, whole disk 1097 0 = /dev/rd/c7d0 First disk, whole disk
1098 8 = /dev/rd/c7d1 Second disk, whole disk 1098 8 = /dev/rd/c7d1 Second disk, whole disk
1099 ... 1099 ...
@@ -1456,7 +1456,7 @@ Your cooperation is appreciated.
1456 1 = /dev/cum1 Callout device for ttyM1 1456 1 = /dev/cum1 Callout device for ttyM1
1457 ... 1457 ...
1458 1458
1459 79 block Compaq Intelligent Drive Array, eigth controller 1459 79 block Compaq Intelligent Drive Array, eighth controller
1460 0 = /dev/ida/c7d0 First logical drive whole disk 1460 0 = /dev/ida/c7d0 First logical drive whole disk
1461 16 = /dev/ida/c7d1 Second logical drive whole disk 1461 16 = /dev/ida/c7d1 Second logical drive whole disk
1462 ... 1462 ...
@@ -1900,7 +1900,7 @@ Your cooperation is appreciated.
1900 1 = /dev/av1 Second A/V card 1900 1 = /dev/av1 Second A/V card
1901 ... 1901 ...
1902 1902
1903111 block Compaq Next Generation Drive Array, eigth controller 1903111 block Compaq Next Generation Drive Array, eighth controller
1904 0 = /dev/cciss/c7d0 First logical drive, whole disk 1904 0 = /dev/cciss/c7d0 First logical drive, whole disk
1905 16 = /dev/cciss/c7d1 Second logical drive, whole disk 1905 16 = /dev/cciss/c7d1 Second logical drive, whole disk
1906 ... 1906 ...
diff --git a/Documentation/driver-model/platform.txt b/Documentation/driver-model/platform.txt
index 5eee3e0bfc4c..9f0bc3bfd776 100644
--- a/Documentation/driver-model/platform.txt
+++ b/Documentation/driver-model/platform.txt
@@ -1,99 +1,131 @@
1Platform Devices and Drivers 1Platform Devices and Drivers
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3See <linux/platform_device.h> for the driver model interface to the
4platform bus: platform_device, and platform_driver. This pseudo-bus
5is used to connect devices on busses with minimal infrastructure,
6like those used to integrate peripherals on many system-on-chip
7processors, or some "legacy" PC interconnects; as opposed to large
8formally specified ones like PCI or USB.
9
3 10
4Platform devices 11Platform devices
5~~~~~~~~~~~~~~~~ 12~~~~~~~~~~~~~~~~
6Platform devices are devices that typically appear as autonomous 13Platform devices are devices that typically appear as autonomous
7entities in the system. This includes legacy port-based devices and 14entities in the system. This includes legacy port-based devices and
8host bridges to peripheral buses. 15host bridges to peripheral buses, and most controllers integrated
9 16into system-on-chip platforms. What they usually have in common
10 17is direct addressing from a CPU bus. Rarely, a platform_device will
11Platform drivers 18be connected through a segment of some other kind of bus; but its
12~~~~~~~~~~~~~~~~ 19registers will still be directly addressible.
13Drivers for platform devices are typically very simple and
14unstructured. Either the device was present at a particular I/O port
15and the driver was loaded, or it was not. There was no possibility
16of hotplugging or alternative discovery besides probing at a specific
17I/O address and expecting a specific response.
18 20
21Platform devices are given a name, used in driver binding, and a
22list of resources such as addresses and IRQs.
19 23
20Other Architectures, Modern Firmware, and new Platforms 24struct platform_device {
21~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 const char *name;
22These devices are not always at the legacy I/O ports. This is true on 26 u32 id;
23other architectures and on some modern architectures. In most cases, 27 struct device dev;
24the drivers are modified to discover the devices at other well-known 28 u32 num_resources;
25ports for the given platform. However, the firmware in these systems 29 struct resource *resource;
26does usually know where exactly these devices reside, and in some 30};
27cases, it's the only way of discovering them.
28 31
29 32
30The Platform Bus 33Platform drivers
31~~~~~~~~~~~~~~~~
32A platform bus has been created to deal with these issues. First and
33foremost, it groups all the legacy devices under a common bus, and
34gives them a common parent if they don't already have one.
35
36But, besides the organizational benefits, the platform bus can also
37accommodate firmware-based enumeration.
38
39
40Device Discovery
41~~~~~~~~~~~~~~~~ 34~~~~~~~~~~~~~~~~
42The platform bus has no concept of probing for devices. Devices 35Platform drivers follow the standard driver model convention, where
43discovery is left up to either the legacy drivers or the 36discovery/enumeration is handled outside the drivers, and drivers
44firmware. These entities are expected to notify the platform of 37provide probe() and remove() methods. They support power management
45devices that it discovers via the bus's add() callback: 38and shutdown notifications using the standard conventions.
46 39
47 platform_bus.add(parent,bus_id). 40struct platform_driver {
48 41 int (*probe)(struct platform_device *);
49 42 int (*remove)(struct platform_device *);
50Bus IDs 43 void (*shutdown)(struct platform_device *);
51~~~~~~~ 44 int (*suspend)(struct platform_device *, pm_message_t state);
52Bus IDs are the canonical names for the devices. There is no globally 45 int (*suspend_late)(struct platform_device *, pm_message_t state);
53standard addressing mechanism for legacy devices. In the IA-32 world, 46 int (*resume_early)(struct platform_device *);
54we have Pnp IDs to use, as well as the legacy I/O ports. However, 47 int (*resume)(struct platform_device *);
55neither tell what the device really is or have any meaning on other 48 struct device_driver driver;
56platforms. 49};
57 50
58Since both PnP IDs and the legacy I/O ports (and other standard I/O 51Note that probe() should general verify that the specified device hardware
59ports for specific devices) have a 1:1 mapping, we map the 52actually exists; sometimes platform setup code can't be sure. The probing
60platform-specific name or identifier to a generic name (at least 53can use device resources, including clocks, and device platform_data.
61within the scope of the kernel). 54
62 55Platform drivers register themselves the normal way:
63For example, a serial driver might find a device at I/O 0x3f8. The 56
64ACPI firmware might also discover a device with PnP ID (_HID) 57 int platform_driver_register(struct platform_driver *drv);
65PNP0501. Both correspond to the same device and should be mapped to the 58
66canonical name 'serial'. 59Or, in common situations where the device is known not to be hot-pluggable,
67 60the probe() routine can live in an init section to reduce the driver's
68The bus_id field should be a concatenation of the canonical name and 61runtime memory footprint:
69the instance of that type of device. For example, the device at I/O 62
70port 0x3f8 should have a bus_id of "serial0". This places the 63 int platform_driver_probe(struct platform_driver *drv,
71responsibility of enumerating devices of a particular type up to the 64 int (*probe)(struct platform_device *))
72discovery mechanism. But, they are the entity that should know best 65
73(as opposed to the platform bus driver). 66
74 67Device Enumeration
75 68~~~~~~~~~~~~~~~~~~
76Drivers 69As a rule, platform specific (and often board-specific) setup code wil
77~~~~~~~ 70register platform devices:
78Drivers for platform devices should have a name that is the same as 71
79the canonical name of the devices they support. This allows the 72 int platform_device_register(struct platform_device *pdev);
80platform bus driver to do simple matching with the basic data 73
81structures to determine if a driver supports a certain device. 74 int platform_add_devices(struct platform_device **pdevs, int ndev);
82 75
83For example, a legacy serial driver should have a name of 'serial' and 76The general rule is to register only those devices that actually exist,
84register itself with the platform bus. 77but in some cases extra devices might be registered. For example, a kernel
85 78might be configured to work with an external network adapter that might not
86 79be populated on all boards, or likewise to work with an integrated controller
87Driver Binding 80that some boards might not hook up to any peripherals.
88~~~~~~~~~~~~~~ 81
89Legacy drivers assume they are bound to the device once they start up 82In some cases, boot firmware will export tables describing the devices
90and probe an I/O port. Divorcing them from this will be a difficult 83that are populated on a given board. Without such tables, often the
91process. However, that shouldn't prevent us from implementing 84only way for system setup code to set up the correct devices is to build
92firmware-based enumeration. 85a kernel for a specific target board. Such board-specific kernels are
93 86common with embedded and custom systems development.
94The firmware should notify the platform bus about devices before the 87
95legacy drivers have had a chance to load. Once the drivers are loaded, 88In many cases, the memory and IRQ resources associated with the platform
96they driver model core will attempt to bind the driver to any 89device are not enough to let the device's driver work. Board setup code
97previously-discovered devices. Once that has happened, it will be free 90will often provide additional information using the device's platform_data
98to discover any other devices it pleases. 91field to hold additional information.
92
93Embedded systems frequently need one or more clocks for platform devices,
94which are normally kept off until they're actively needed (to save power).
95System setup also associates those clocks with the device, so that that
96calls to clk_get(&pdev->dev, clock_name) return them as needed.
97
98
99Device Naming and Driver Binding
100~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101The platform_device.dev.bus_id is the canonical name for the devices.
102It's built from two components:
103
104 * platform_device.name ... which is also used to for driver matching.
105
106 * platform_device.id ... the device instance number, or else "-1"
107 to indicate there's only one.
108
109These are catenated, so name/id "serial"/0 indicates bus_id "serial.0", and
110"serial/3" indicates bus_id "serial.3"; both would use the platform_driver
111named "serial". While "my_rtc"/-1 would be bus_id "my_rtc" (no instance id)
112and use the platform_driver called "my_rtc".
113
114Driver binding is performed automatically by the driver core, invoking
115driver probe() after finding a match between device and driver. If the
116probe() succeeds, the driver and device are bound as usual. There are
117three different ways to find such a match:
118
119 - Whenever a device is registered, the drivers for that bus are
120 checked for matches. Platform devices should be registered very
121 early during system boot.
122
123 - When a driver is registered using platform_driver_register(), all
124 unbound devices on that bus are checked for matches. Drivers
125 usually register later during booting, or by module loading.
126
127 - Registering a driver using platform_driver_probe() works just like
128 using platform_driver_register(), except that the the driver won't
129 be probed later if another device registers. (Which is OK, since
130 this interface is only for use with non-hotpluggable devices.)
99 131
diff --git a/Documentation/driver-model/porting.txt b/Documentation/driver-model/porting.txt
index 98b233cb8b36..92d86f7271b4 100644
--- a/Documentation/driver-model/porting.txt
+++ b/Documentation/driver-model/porting.txt
@@ -92,7 +92,7 @@ struct device represents a single device. It mainly contains metadata
92describing the relationship the device has to other entities. 92describing the relationship the device has to other entities.
93 93
94 94
95- Embedd a struct device in the bus-specific device type. 95- Embed a struct device in the bus-specific device type.
96 96
97 97
98struct pci_dev { 98struct pci_dev {
diff --git a/Documentation/dvb/ci.txt b/Documentation/dvb/ci.txt
index 531239b29082..2ecd834585e6 100644
--- a/Documentation/dvb/ci.txt
+++ b/Documentation/dvb/ci.txt
@@ -71,7 +71,7 @@ eliminating the need for any additional ioctls.
71The disadvantage is that the driver/hardware has to manage the rest. For 71The disadvantage is that the driver/hardware has to manage the rest. For
72the application programmer it would be as simple as sending/receiving an 72the application programmer it would be as simple as sending/receiving an
73array to/from the CI ioctls as defined in the Linux DVB API. No changes 73array to/from the CI ioctls as defined in the Linux DVB API. No changes
74have been made in the API to accomodate this feature. 74have been made in the API to accommodate this feature.
75 75
76 76
77* Why the need for another CI interface ? 77* Why the need for another CI interface ?
@@ -102,7 +102,7 @@ This CI interface follows the CI high level interface, which is not
102implemented by most applications. Hence this area is revisited. 102implemented by most applications. Hence this area is revisited.
103 103
104This CI interface is quite different in the case that it tries to 104This CI interface is quite different in the case that it tries to
105accomodate all other CI based devices, that fall into the other categories 105accommodate all other CI based devices, that fall into the other categories.
106 106
107This means that this CI interface handles the EN50221 style tags in the 107This means that this CI interface handles the EN50221 style tags in the
108Application layer only and no session management is taken care of by the 108Application layer only and no session management is taken care of by the
diff --git a/Documentation/eisa.txt b/Documentation/eisa.txt
index 6a099edadd62..60e361ba08c0 100644
--- a/Documentation/eisa.txt
+++ b/Documentation/eisa.txt
@@ -62,7 +62,7 @@ res : root device I/O resource
62bus_base_addr : slot 0 address on this bus 62bus_base_addr : slot 0 address on this bus
63slots : max slot number to probe 63slots : max slot number to probe
64force_probe : Probe even when slot 0 is empty (no EISA mainboard) 64force_probe : Probe even when slot 0 is empty (no EISA mainboard)
65dma_mask : Default DMA mask. Usualy the bridge device dma_mask. 65dma_mask : Default DMA mask. Usually the bridge device dma_mask.
66bus_nr : unique bus id, set by eisa_root_register 66bus_nr : unique bus id, set by eisa_root_register
67 67
68** Driver : 68** Driver :
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index d52c4aaaf17f..226ecf2ffd56 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -70,18 +70,6 @@ Who: Dominik Brodowski <linux@brodo.de>
70 70
71--------------------------- 71---------------------------
72 72
73What: ip_queue and ip6_queue (old ipv4-only and ipv6-only netfilter queue)
74When: December 2005
75Why: This interface has been obsoleted by the new layer3-independent
76 "nfnetlink_queue". The Kernel interface is compatible, so the old
77 ip[6]tables "QUEUE" targets still work and will transparently handle
78 all packets into nfnetlink queue number 0. Userspace users will have
79 to link against API-compatible library on top of libnfnetlink_queue
80 instead of the current 'libipq'.
81Who: Harald Welte <laforge@netfilter.org>
82
83---------------------------
84
85What: remove EXPORT_SYMBOL(kernel_thread) 73What: remove EXPORT_SYMBOL(kernel_thread)
86When: August 2006 74When: August 2006
87Files: arch/*/kernel/*_ksyms.c 75Files: arch/*/kernel/*_ksyms.c
@@ -227,21 +215,6 @@ Who: Patrick McHardy <kaber@trash.net>
227 215
228--------------------------- 216---------------------------
229 217
230What: frame diverter
231When: November 2006
232Why: The frame diverter is included in most distribution kernels, but is
233 broken. It does not correctly handle many things:
234 - IPV6
235 - non-linear skb's
236 - network device RCU on removal
237 - input frames not correctly checked for protocol errors
238 It also adds allocation overhead even if not enabled.
239 It is not clear if anyone is still using it.
240Who: Stephen Hemminger <shemminger@osdl.org>
241
242---------------------------
243
244
245What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment 218What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment
246When: October 2008 219When: October 2008
247Why: The stacking of class devices makes these values misleading and 220Why: The stacking of class devices makes these values misleading and
@@ -261,10 +234,11 @@ Who: Jean Delvare <khali@linux-fr.org>
261 234
262--------------------------- 235---------------------------
263 236
264What: ftape 237What: IPv4 only connection tracking/NAT/helpers
265When: 2.6.20 238When: 2.6.22
266Why: Orphaned for ages. SMP bugs long unfixed. Few users left 239Why: The new layer 3 independant connection tracking replaces the old
267 in the world. 240 IPv4 only version. After some stabilization of the new code the
268Who: Jeff Garzik <jeff@garzik.org> 241 old one will be removed.
242Who: Patrick McHardy <kaber@trash.net>
269 243
270--------------------------- 244---------------------------
diff --git a/Documentation/filesystems/adfs.txt b/Documentation/filesystems/adfs.txt
index 060abb0c7004..9e8811f92b84 100644
--- a/Documentation/filesystems/adfs.txt
+++ b/Documentation/filesystems/adfs.txt
@@ -3,7 +3,7 @@ Mount options for ADFS
3 3
4 uid=nnn All files in the partition will be owned by 4 uid=nnn All files in the partition will be owned by
5 user id nnn. Default 0 (root). 5 user id nnn. Default 0 (root).
6 gid=nnn All files in the partition willbe in group 6 gid=nnn All files in the partition will be in group
7 nnn. Default 0 (root). 7 nnn. Default 0 (root).
8 ownmask=nnn The permission mask for ADFS 'owner' permissions 8 ownmask=nnn The permission mask for ADFS 'owner' permissions
9 will be nnn. Default 0700. 9 will be nnn. Default 0700.
diff --git a/Documentation/filesystems/configfs/configfs.txt b/Documentation/filesystems/configfs/configfs.txt
index c3a7afb5eabf..b34cdb50eab4 100644
--- a/Documentation/filesystems/configfs/configfs.txt
+++ b/Documentation/filesystems/configfs/configfs.txt
@@ -209,7 +209,7 @@ will happen for write(2).
209 209
210[struct config_group] 210[struct config_group]
211 211
212A config_item cannot live in a vaccum. The only way one can be created 212A config_item cannot live in a vacuum. The only way one can be created
213is via mkdir(2) on a config_group. This will trigger creation of a 213is via mkdir(2) on a config_group. This will trigger creation of a
214child item. 214child item.
215 215
@@ -275,7 +275,7 @@ directory is not empty.
275 275
276[struct configfs_subsystem] 276[struct configfs_subsystem]
277 277
278A subsystem must register itself, ususally at module_init time. This 278A subsystem must register itself, usually at module_init time. This
279tells configfs to make the subsystem appear in the file tree. 279tells configfs to make the subsystem appear in the file tree.
280 280
281 struct configfs_subsystem { 281 struct configfs_subsystem {
diff --git a/Documentation/filesystems/fuse.txt b/Documentation/filesystems/fuse.txt
index a584f05403a4..3d7447738958 100644
--- a/Documentation/filesystems/fuse.txt
+++ b/Documentation/filesystems/fuse.txt
@@ -111,7 +111,7 @@ For each connection the following files exist within this directory:
111 111
112 'waiting' 112 'waiting'
113 113
114 The number of requests which are waiting to be transfered to 114 The number of requests which are waiting to be transferred to
115 userspace or being processed by the filesystem daemon. If there is 115 userspace or being processed by the filesystem daemon. If there is
116 no filesystem activity and 'waiting' is non-zero, then the 116 no filesystem activity and 'waiting' is non-zero, then the
117 filesystem is hung or deadlocked. 117 filesystem is hung or deadlocked.
@@ -136,7 +136,7 @@ following will happen:
136 136
137 2) If the request is not yet sent to userspace AND the signal is not 137 2) If the request is not yet sent to userspace AND the signal is not
138 fatal, then an 'interrupted' flag is set for the request. When 138 fatal, then an 'interrupted' flag is set for the request. When
139 the request has been successfully transfered to userspace and 139 the request has been successfully transferred to userspace and
140 this flag is set, an INTERRUPT request is queued. 140 this flag is set, an INTERRUPT request is queued.
141 141
142 3) If the request is already sent to userspace, then an INTERRUPT 142 3) If the request is already sent to userspace, then an INTERRUPT
diff --git a/Documentation/filesystems/hpfs.txt b/Documentation/filesystems/hpfs.txt
index 33dc360c8e89..38aba03efc5e 100644
--- a/Documentation/filesystems/hpfs.txt
+++ b/Documentation/filesystems/hpfs.txt
@@ -274,7 +274,7 @@ History
274 Fixed race-condition in buffer code - it is in all filesystems in Linux; 274 Fixed race-condition in buffer code - it is in all filesystems in Linux;
275 when reading device (cat /dev/hda) while creating files on it, files 275 when reading device (cat /dev/hda) while creating files on it, files
276 could be damaged 276 could be damaged
2772.02 Woraround for bug in breada in Linux. breada could cause accesses beyond 2772.02 Workaround for bug in breada in Linux. breada could cause accesses beyond
278 end of partition 278 end of partition
2792.03 Char, block devices and pipes are correctly created 2792.03 Char, block devices and pipes are correctly created
280 Fixed non-crashing race in unlink (Alexander Viro) 280 Fixed non-crashing race in unlink (Alexander Viro)
diff --git a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt
index 35f105b29e3e..13ba649bda75 100644
--- a/Documentation/filesystems/ntfs.txt
+++ b/Documentation/filesystems/ntfs.txt
@@ -337,7 +337,7 @@ Finally, for a mirrored volume, i.e. raid level 1, the table would look like
337this (note all values are in 512-byte sectors): 337this (note all values are in 512-byte sectors):
338 338
339--- cut here --- 339--- cut here ---
340# Ofs Size Raid Log Number Region Should Number Source Start Taget Start 340# Ofs Size Raid Log Number Region Should Number Source Start Target Start
341# in of the type type of log size sync? of Device in Device in 341# in of the type type of log size sync? of Device in Device in
342# vol volume params mirrors Device Device 342# vol volume params mirrors Device Device
3430 2056320 mirror core 2 16 nosync 2 /dev/hda1 0 /dev/hdb1 0 3430 2056320 mirror core 2 16 nosync 2 /dev/hda1 0 /dev/hdb1 0
@@ -599,7 +599,7 @@ Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
599 - Major bug fixes for reading files and volumes in corner cases which 599 - Major bug fixes for reading files and volumes in corner cases which
600 were being hit by Windows 2k/XP users. 600 were being hit by Windows 2k/XP users.
6012.1.2: 6012.1.2:
602 - Major bug fixes aleviating the hangs in statfs experienced by some 602 - Major bug fixes alleviating the hangs in statfs experienced by some
603 users. 603 users.
6042.1.1: 6042.1.1:
605 - Update handling of compressed files so people no longer get the 605 - Update handling of compressed files so people no longer get the
diff --git a/Documentation/filesystems/ocfs2.txt b/Documentation/filesystems/ocfs2.txt
index 4389c684a80a..af6defd10cb6 100644
--- a/Documentation/filesystems/ocfs2.txt
+++ b/Documentation/filesystems/ocfs2.txt
@@ -30,7 +30,7 @@ Caveats
30Features which OCFS2 does not support yet: 30Features which OCFS2 does not support yet:
31 - sparse files 31 - sparse files
32 - extended attributes 32 - extended attributes
33 - shared writeable mmap 33 - shared writable mmap
34 - loopback is supported, but data written will not 34 - loopback is supported, but data written will not
35 be cluster coherent. 35 be cluster coherent.
36 - quotas 36 - quotas
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 3355e6920105..72af5de1effb 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -1220,9 +1220,9 @@ applications are using mlock(), or if you are running with no swap then
1220you probably should increase the lower_zone_protection setting. 1220you probably should increase the lower_zone_protection setting.
1221 1221
1222The units of this tunable are fairly vague. It is approximately equal 1222The units of this tunable are fairly vague. It is approximately equal
1223to "megabytes". So setting lower_zone_protection=100 will protect around 100 1223to "megabytes," so setting lower_zone_protection=100 will protect around 100
1224megabytes of the lowmem zone from user allocations. It will also make 1224megabytes of the lowmem zone from user allocations. It will also make
1225those 100 megabytes unavaliable for use by applications and by 1225those 100 megabytes unavailable for use by applications and by
1226pagecache, so there is a cost. 1226pagecache, so there is a cost.
1227 1227
1228The effects of this tunable may be observed by monitoring 1228The effects of this tunable may be observed by monitoring
@@ -1538,10 +1538,10 @@ TCP settings
1538tcp_ecn 1538tcp_ecn
1539------- 1539-------
1540 1540
1541This file controls the use of the ECN bit in the IPv4 headers, this is a new 1541This file controls the use of the ECN bit in the IPv4 headers. This is a new
1542feature about Explicit Congestion Notification, but some routers and firewalls 1542feature about Explicit Congestion Notification, but some routers and firewalls
1543block trafic that has this bit set, so it could be necessary to echo 0 to 1543block traffic that has this bit set, so it could be necessary to echo 0 to
1544/proc/sys/net/ipv4/tcp_ecn, if you want to talk to this sites. For more info 1544/proc/sys/net/ipv4/tcp_ecn if you want to talk to these sites. For more info
1545you could read RFC2481. 1545you could read RFC2481.
1546 1546
1547tcp_retrans_collapse 1547tcp_retrans_collapse
diff --git a/Documentation/filesystems/spufs.txt b/Documentation/filesystems/spufs.txt
index 982645a1981d..1343d118a9b2 100644
--- a/Documentation/filesystems/spufs.txt
+++ b/Documentation/filesystems/spufs.txt
@@ -210,7 +210,7 @@ FILES
210 /signal2 210 /signal2
211 The two signal notification channels of an SPU. These are read-write 211 The two signal notification channels of an SPU. These are read-write
212 files that operate on a 32 bit word. Writing to one of these files 212 files that operate on a 32 bit word. Writing to one of these files
213 triggers an interrupt on the SPU. The value writting to the signal 213 triggers an interrupt on the SPU. The value written to the signal
214 files can be read from the SPU through a channel read or from host user 214 files can be read from the SPU through a channel read or from host user
215 space through the file. After the value has been read by the SPU, it 215 space through the file. After the value has been read by the SPU, it
216 is reset to zero. The possible operations on an open signal1 or sig- 216 is reset to zero. The possible operations on an open signal1 or sig-
diff --git a/Documentation/ftape.txt b/Documentation/ftape.txt
deleted file mode 100644
index 7d8bb3384031..000000000000
--- a/Documentation/ftape.txt
+++ /dev/null
@@ -1,307 +0,0 @@
1Intro
2=====
3
4This file describes some issues involved when using the "ftape"
5floppy tape device driver that comes with the Linux kernel.
6
7ftape has a home page at
8
9http://ftape.dot-heine.de/
10
11which contains further information about ftape. Please cross check
12this WWW address against the address given (if any) in the MAINTAINERS
13file located in the top level directory of the Linux kernel source
14tree.
15
16NOTE: This is an unmaintained set of drivers, and it is not guaranteed to work.
17If you are interested in taking over maintenance, contact Claus-Justus Heine
18<ch@dot-heine.de>, the former maintainer.
19
20Contents
21========
22
23A minus 1: Ftape documentation
24
25A. Changes
26 1. Goal
27 2. I/O Block Size
28 3. Write Access when not at EOD (End Of Data) or BOT (Begin Of Tape)
29 4. Formatting
30 5. Interchanging cartridges with other operating systems
31
32B. Debugging Output
33 1. Introduction
34 2. Tuning the debugging output
35
36C. Boot and load time configuration
37 1. Setting boot time parameters
38 2. Module load time parameters
39 3. Ftape boot- and load time options
40 4. Example kernel parameter setting
41 5. Example module parameter setting
42
43D. Support and contacts
44
45*******************************************************************************
46
47A minus 1. Ftape documentation
48==============================
49
50Unluckily, the ftape-HOWTO is out of date. This really needs to be
51changed. Up to date documentation as well as recent development
52versions of ftape and useful links to related topics can be found at
53the ftape home page at
54
55http://ftape.dot-heine.de/
56
57*******************************************************************************
58
59A. Changes
60==========
61
621. Goal
63 ~~~~
64 The goal of all that incompatibilities was to give ftape an interface
65 that resembles the interface provided by SCSI tape drives as close
66 as possible. Thus any Unix backup program that is known to work
67 with SCSI tape drives should also work.
68
69 The concept of a fixed block size for read/write transfers is
70 rather unrelated to this SCSI tape compatibility at the file system
71 interface level. It developed out of a feature of zftape, a
72 block wise user transparent on-the-fly compression. That compression
73 support will not be dropped in future releases for compatibility
74 reasons with previous releases of zftape.
75
762. I/O Block Size
77 ~~~~~~~~~~~~~~
78 The block size defaults to 10k which is the default block size of
79 GNU tar.
80
81 The block size can be tuned either during kernel configuration or
82 at runtime with the MTIOCTOP ioctl using the MTSETBLK operation
83 (i.e. do "mt -f /dev/qft0" setblk #BLKSZ). A block size of 0
84 switches to variable block size mode i.e. "mt setblk 0" switches
85 off the block size restriction. However, this disables zftape's
86 built in on-the-fly compression which doesn't work with variable
87 block size mode.
88
89 The BLKSZ parameter must be given as a byte count and must be a
90 multiple of 32k or 0, i.e. use "mt setblk 32768" to switch to a
91 block size of 32k.
92
93 The typical symptom of a block size mismatch is an "invalid
94 argument" error message.
95
963. Write Access when not at EOD (End Of Data) or BOT (Begin Of Tape)
97 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98 zftape (the file system interface of ftape-3.x) denies write access
99 to the tape cartridge when it isn't positioned either at BOT or
100 EOD.
101
1024. Formatting
103 ~~~~~~~~~~
104 ftape DOES support formatting of floppy tape cartridges. You need the
105 `ftformat' program that is shipped with the modules version of ftape.
106 Please get the latest version of ftape from
107
108 ftp://sunsite.unc.edu/pub/Linux/kernel/tapes
109
110 or from the ftape home page at
111
112 http://ftape.dot-heine.de/
113
114 `ftformat' is contained in the `./contrib/' subdirectory of that
115 separate ftape package.
116
1175. Interchanging cartridges with other operating systems
118 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119
120 The internal emulation of Unix tape device file marks has changed
121 completely. ftape now uses the volume table segment as specified
122 by the QIC-40/80/3010/3020/113 standards to emulate file marks. As
123 a consequence there is limited support to interchange cartridges
124 with other operating systems.
125
126 To be more precise: ftape will detect volumes written by other OS's
127 programs and other OS's programs will detect volumes written by
128 ftape.
129
130 However, it isn't possible to extract the data dumped to the tape
131 by some MSDOS program with ftape. This exceeds the scope of a
132 kernel device driver. If you need such functionality, then go ahead
133 and write a user space utility that is able to do that. ftape already
134 provides all kernel level support necessary to do that.
135
136*******************************************************************************
137
138B. Debugging Output
139 ================
140
1411. Introduction
142 ~~~~~~~~~~~~
143 The ftape driver can be very noisy in that is can print lots of
144 debugging messages to the kernel log files and the system console.
145 While this is useful for debugging it might be annoying during
146 normal use and enlarges the size of the driver by several kilobytes.
147
148 To reduce the size of the driver you can trim the maximal amount of
149 debugging information available during kernel configuration. Please
150 refer to the kernel configuration script and its on-line help
151 functionality.
152
153 The amount of debugging output maps to the "tracing" boot time
154 option and the "ft_tracing" modules option as follows:
155
156 0 bugs
157 1 + errors (with call-stack dump)
158 2 + warnings
159 3 + information
160 4 + more information
161 5 + program flow
162 6 + fdc/dma info
163 7 + data flow
164 8 + everything else
165
1662. Tuning the debugging output
167 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
168 To reduce the amount of debugging output printed to the system
169 console you can
170
171 i) trim the debugging output at run-time with
172
173 mt -f /dev/nqft0 setdensity #DBGLVL
174
175 where "#DBGLVL" is a number between 0 and 9
176
177 ii) trim the debugging output at module load time with
178
179 modprobe ftape ft_tracing=#DBGLVL
180
181 Of course, this applies only if you have configured ftape to be
182 compiled as a module.
183
184 iii) trim the debugging output during system boot time. Add the
185 following to the kernel command line:
186
187 ftape=#DBGLVL,tracing
188
189 Please refer also to the next section if you don't know how to
190 set boot time parameters.
191
192*******************************************************************************
193
194C. Boot and load time configuration
195 ================================
196
1971. Setting boot time parameters
198 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199 Assuming that you use lilo, the LI)nux LO)ader, boot time kernel
200 parameters can be set by adding a line
201
202 append some_kernel_boot_time_parameter
203
204 to `/etc/lilo.conf' or at real boot time by typing in the options
205 at the prompt provided by LILO. I can't give you advice on how to
206 specify those parameters with other loaders as I don't use them.
207
208 For ftape, each "some_kernel_boot_time_parameter" looks like
209 "ftape=value,option". As an example, the debugging output can be
210 increased with
211
212 ftape=4,tracing
213
214 NOTE: the value precedes the option name.
215
2162. Module load time parameters
217 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
218 Module parameters can be specified either directly when invoking
219 the program 'modprobe' at the shell prompt:
220
221 modprobe ftape ft_tracing=4
222
223 or by editing the file `/etc/modprobe.conf' in which case they take
224 effect each time when the module is loaded with `modprobe' (please
225 refer to the respective manual pages). Thus, you should add a line
226
227 options ftape ft_tracing=4
228
229 to `/etc/modprobe.conf` if you intend to increase the debugging
230 output of the driver.
231
232
2333. Ftape boot- and load time options
234 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
236 i. Controlling the amount of debugging output
237 DBGLVL has to be replaced by a number between 0 and 8.
238
239 module | kernel command line
240 -----------------------|----------------------
241 ft_tracing=DBGLVL | ftape=DBGLVL,tracing
242
243 ii. Hardware setup
244 BASE is the base address of your floppy disk controller,
245 IRQ and DMA give its interrupt and DMA channel, respectively.
246 BOOL is an integer, "0" means "no"; any other value means
247 "yes". You don't need to specify anything if connecting your tape
248 drive to the standard floppy disk controller. All of these
249 values have reasonable defaults. The defaults can be modified
250 during kernel configuration, i.e. while running "make config",
251 "make menuconfig" or "make xconfig" in the top level directory
252 of the Linux kernel source tree. Please refer also to the on
253 line documentation provided during that kernel configuration
254 process.
255
256 ft_probe_fc10 is set to a non-zero value if you wish for ftape to
257 probe for a Colorado FC-10 or FC-20 controller.
258
259 ft_mach2 is set to a non-zero value if you wish for ftape to probe
260 for a Mountain MACH-2 controller.
261
262 module | kernel command line
263 -----------------------|----------------------
264 ft_fdc_base=BASE | ftape=BASE,ioport
265 ft_fdc_irq=IRQ | ftape=IRQ,irq
266 ft_fdc_dma=DMA | ftape=DMA,dma
267 ft_probe_fc10=BOOL | ftape=BOOL,fc10
268 ft_mach2=BOOL | ftape=BOOL,mach2
269 ft_fdc_threshold=THR | ftape=THR,threshold
270 ft_fdc_rate_limit=RATE | ftape=RATE,datarate
271
2724. Example kernel parameter setting
273 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274 To configure ftape to probe for a Colorado FC-10/FC-20 controller
275 and to increase the amount of debugging output a little bit, add
276 the following line to `/etc/lilo.conf':
277
278 append ftape=1,fc10 ftape=4,tracing
279
2805. Example module parameter setting
281 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
282 To do the same, but with ftape compiled as a loadable kernel
283 module, add the following line to `/etc/modprobe.conf':
284
285 options ftape ft_probe_fc10=1 ft_tracing=4
286
287*******************************************************************************
288
289D. Support and contacts
290 ====================
291
292 Ftape is distributed under the GNU General Public License. There is
293 absolutely no warranty for this software. However, you can reach
294 the current maintainer of the ftape package under the email address
295 given in the MAINTAINERS file which is located in the top level
296 directory of the Linux kernel source tree. There you'll find also
297 the relevant mailing list to use as a discussion forum and the web
298 page to query for the most recent documentation, related work and
299 development versions of ftape.
300
301 Changelog:
302 ==========
303
304~1996: Original Document
305
30610-24-2004: General cleanup and updating, noting additional module options.
307 James Nelson <james4765@gmail.com>
diff --git a/Documentation/fujitsu/frv/gdbstub.txt b/Documentation/fujitsu/frv/gdbstub.txt
index 6ce5aa9abbc5..9304fb36ae8a 100644
--- a/Documentation/fujitsu/frv/gdbstub.txt
+++ b/Documentation/fujitsu/frv/gdbstub.txt
@@ -59,7 +59,7 @@ the following things on the "Kernel Hacking" tab:
59Then build as usual, download to the board and execute. Note that if 59Then build as usual, download to the board and execute. Note that if
60"Immediate activation" was selected, then the kernel will wait for GDB to 60"Immediate activation" was selected, then the kernel will wait for GDB to
61attach. If not, then the kernel will boot immediately and GDB will have to 61attach. If not, then the kernel will boot immediately and GDB will have to
62interupt it or wait for an exception to occur if before doing anything with 62interrupt it or wait for an exception to occur before doing anything with
63the kernel. 63the kernel.
64 64
65 65
diff --git a/Documentation/fujitsu/frv/kernel-ABI.txt b/Documentation/fujitsu/frv/kernel-ABI.txt
index 8b0a5fc8bfd9..aaa1cec86f0b 100644
--- a/Documentation/fujitsu/frv/kernel-ABI.txt
+++ b/Documentation/fujitsu/frv/kernel-ABI.txt
@@ -156,7 +156,7 @@ with the main kernel in this regard. Hence the debug mode code (gdbstub) is
156almost completely self-contained. The only external code used is the 156almost completely self-contained. The only external code used is the
157sprintf family of functions. 157sprintf family of functions.
158 158
159Futhermore, break.S is so complicated because single-step mode does not 159Furthermore, break.S is so complicated because single-step mode does not
160switch off on entry to an exception. That means unless manually disabled, 160switch off on entry to an exception. That means unless manually disabled,
161single-stepping will blithely go on stepping into things like interrupts. 161single-stepping will blithely go on stepping into things like interrupts.
162See gdbstub.txt for more information. 162See gdbstub.txt for more information.
diff --git a/Documentation/ide.txt b/Documentation/ide.txt
index 0bf38baa2db9..786c3a766995 100644
--- a/Documentation/ide.txt
+++ b/Documentation/ide.txt
@@ -390,5 +390,5 @@ mlord@pobox.com
390Wed Apr 17 22:52:44 CEST 2002 edited by Marcin Dalecki, the current 390Wed Apr 17 22:52:44 CEST 2002 edited by Marcin Dalecki, the current
391maintainer. 391maintainer.
392 392
393Wed Aug 20 22:31:29 CEST 2003 updated ide boot uptions to current ide.c 393Wed Aug 20 22:31:29 CEST 2003 updated ide boot options to current ide.c
394comments at 2.6.0-test4 time. Maciej Soltysiak <solt@dns.toxicfilms.tv> 394comments at 2.6.0-test4 time. Maciej Soltysiak <solt@dns.toxicfilms.tv>
diff --git a/Documentation/input/amijoy.txt b/Documentation/input/amijoy.txt
index 4f0e89df5c51..7dc4f175943c 100644
--- a/Documentation/input/amijoy.txt
+++ b/Documentation/input/amijoy.txt
@@ -91,8 +91,8 @@ JOY1DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0
91 | 1 | M0HQ | JOY0DAT Horizontal Clock (quadrature) | 91 | 1 | M0HQ | JOY0DAT Horizontal Clock (quadrature) |
92 | 2 | M0V | JOY0DAT Vertical Clock | 92 | 2 | M0V | JOY0DAT Vertical Clock |
93 | 3 | M0VQ | JOY0DAT Vertical Clock (quadrature) | 93 | 3 | M0VQ | JOY0DAT Vertical Clock (quadrature) |
94 | 4 | M1V | JOY1DAT Horizontall Clock | 94 | 4 | M1V | JOY1DAT Horizontal Clock |
95 | 5 | M1VQ | JOY1DAT Horizontall Clock (quadrature) | 95 | 5 | M1VQ | JOY1DAT Horizontal Clock (quadrature) |
96 | 6 | M1V | JOY1DAT Vertical Clock | 96 | 6 | M1V | JOY1DAT Vertical Clock |
97 | 7 | M1VQ | JOY1DAT Vertical Clock (quadrature) | 97 | 7 | M1VQ | JOY1DAT Vertical Clock (quadrature) |
98 +--------+----------+-----------------------------------------+ 98 +--------+----------+-----------------------------------------+
diff --git a/Documentation/input/atarikbd.txt b/Documentation/input/atarikbd.txt
index 1e7e5853ba4c..668f4d0d97d6 100644
--- a/Documentation/input/atarikbd.txt
+++ b/Documentation/input/atarikbd.txt
@@ -103,7 +103,7 @@ LEFT=0x74 & RIGHT=0x75).
103 103
1045.1 Joystick Event Reporting 1045.1 Joystick Event Reporting
105 105
106In this mode, the ikbd generates a record whever the joystick position is 106In this mode, the ikbd generates a record whenever the joystick position is
107changed (i.e. for each opening or closing of a joystick switch or trigger). 107changed (i.e. for each opening or closing of a joystick switch or trigger).
108 108
109The joystick event record is two bytes of the form: 109The joystick event record is two bytes of the form:
@@ -277,8 +277,8 @@ default to 1 at RESET (or power-up).
2779.7 SET MOUSE SCALE 2779.7 SET MOUSE SCALE
278 278
279 0x0C 279 0x0C
280 X ; horizontal mouse ticks per internel X 280 X ; horizontal mouse ticks per internal X
281 Y ; vertical mouse ticks per internel Y 281 Y ; vertical mouse ticks per internal Y
282 282
283This command sets the scale factor for the ABSOLUTE MOUSE POSITIONING mode. 283This command sets the scale factor for the ABSOLUTE MOUSE POSITIONING mode.
284In this mode, the specified number of mouse phase changes ('clicks') must 284In this mode, the specified number of mouse phase changes ('clicks') must
@@ -323,7 +323,7 @@ mouse position.
323 0x0F 323 0x0F
324 324
325This command makes the origin of the Y axis to be at the bottom of the 325This command makes the origin of the Y axis to be at the bottom of the
326logical coordinate system internel to the ikbd for all relative or absolute 326logical coordinate system internal to the ikbd for all relative or absolute
327mouse motion. This causes mouse motion toward the user to be negative in sign 327mouse motion. This causes mouse motion toward the user to be negative in sign
328and away from the user to be positive. 328and away from the user to be positive.
329 329
@@ -597,8 +597,8 @@ mode or FIRE BUTTON MONITORING mode.
597 597
59810. SCAN CODES 59810. SCAN CODES
599 599
600The key scan codes return by the ikbd are chosen to simplify the 600The key scan codes returned by the ikbd are chosen to simplify the
601implementaion of GSX. 601implementation of GSX.
602 602
603GSX Standard Keyboard Mapping. 603GSX Standard Keyboard Mapping.
604 604
diff --git a/Documentation/input/yealink.txt b/Documentation/input/yealink.txt
index 0a8c97e87d47..5360e434486c 100644
--- a/Documentation/input/yealink.txt
+++ b/Documentation/input/yealink.txt
@@ -134,7 +134,7 @@ Reading /sys/../lineX will return the format string with its current value:
134 888888888888 134 888888888888
135 Linux Rocks! 135 Linux Rocks!
136 136
137Writing to /sys/../lineX will set the coresponding LCD line. 137Writing to /sys/../lineX will set the corresponding LCD line.
138 - Excess characters are ignored. 138 - Excess characters are ignored.
139 - If less characters are written than allowed, the remaining digits are 139 - If less characters are written than allowed, the remaining digits are
140 unchanged. 140 unchanged.
diff --git a/Documentation/ioctl/cdrom.txt b/Documentation/ioctl/cdrom.txt
index 8ec32cc49eb1..62d4af44ec4a 100644
--- a/Documentation/ioctl/cdrom.txt
+++ b/Documentation/ioctl/cdrom.txt
@@ -735,7 +735,7 @@ CDROM_DISC_STATUS Get disc type, etc.
735 Ok, this is where problems start. The current interface for 735 Ok, this is where problems start. The current interface for
736 the CDROM_DISC_STATUS ioctl is flawed. It makes the false 736 the CDROM_DISC_STATUS ioctl is flawed. It makes the false
737 assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. 737 assumption that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc.
738 Unfortunatly, while this is often the case, it is also 738 Unfortunately, while this is often the case, it is also
739 very common for CDs to have some tracks with data, and some 739 very common for CDs to have some tracks with data, and some
740 tracks with audio. Just because I feel like it, I declare 740 tracks with audio. Just because I feel like it, I declare
741 the following to be the best way to cope. If the CD has 741 the following to be the best way to cope. If the CD has
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 50f4eddf899c..4b3d6710c504 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -227,9 +227,9 @@ more details, with real examples.
227 be included in a library, lib.a. 227 be included in a library, lib.a.
228 All objects listed with lib-y are combined in a single 228 All objects listed with lib-y are combined in a single
229 library for that directory. 229 library for that directory.
230 Objects that are listed in obj-y and additionaly listed in 230 Objects that are listed in obj-y and additionally listed in
231 lib-y will not be included in the library, since they will anyway 231 lib-y will not be included in the library, since they will
232 be accessible. 232 be accessible anyway.
233 For consistency, objects listed in lib-m will be included in lib.a. 233 For consistency, objects listed in lib-m will be included in lib.a.
234 234
235 Note that the same kbuild makefile may list files to be built-in 235 Note that the same kbuild makefile may list files to be built-in
@@ -535,7 +535,7 @@ Both possibilities are described in the following.
535 Host programs can be made up based on composite objects. 535 Host programs can be made up based on composite objects.
536 The syntax used to define composite objects for host programs is 536 The syntax used to define composite objects for host programs is
537 similar to the syntax used for kernel objects. 537 similar to the syntax used for kernel objects.
538 $(<executeable>-objs) lists all objects used to link the final 538 $(<executable>-objs) lists all objects used to link the final
539 executable. 539 executable.
540 540
541 Example: 541 Example:
@@ -1022,7 +1022,7 @@ When kbuild executes, the following steps are followed (roughly):
1022 In this example, there are two possible targets, requiring different 1022 In this example, there are two possible targets, requiring different
1023 options to the linker. The linker options are specified using the 1023 options to the linker. The linker options are specified using the
1024 LDFLAGS_$@ syntax - one for each potential target. 1024 LDFLAGS_$@ syntax - one for each potential target.
1025 $(targets) are assinged all potential targets, by which kbuild knows 1025 $(targets) are assigned all potential targets, by which kbuild knows
1026 the targets and will: 1026 the targets and will:
1027 1) check for commandline changes 1027 1) check for commandline changes
1028 2) delete target during make clean 1028 2) delete target during make clean
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 67473849f20e..15e4fed127f6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -557,9 +557,6 @@ and is between 256 and 4096 characters. It is defined in the file
557 floppy= [HW] 557 floppy= [HW]
558 See Documentation/floppy.txt. 558 See Documentation/floppy.txt.
559 559
560 ftape= [HW] Floppy Tape subsystem debugging options.
561 See Documentation/ftape.txt.
562
563 gamecon.map[2|3]= 560 gamecon.map[2|3]=
564 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad 561 [HW,JOY] Multisystem joystick and NES/SNES/PSX pad
565 support via parallel port (up to 5 devices per port) 562 support via parallel port (up to 5 devices per port)
diff --git a/Documentation/keys.txt b/Documentation/keys.txt
index 3da586bc7859..60c665d9cfaa 100644
--- a/Documentation/keys.txt
+++ b/Documentation/keys.txt
@@ -304,7 +304,7 @@ about the status of the key service:
304 R Revoked 304 R Revoked
305 D Dead 305 D Dead
306 Q Contributes to user's quota 306 Q Contributes to user's quota
307 U Under contruction by callback to userspace 307 U Under construction by callback to userspace
308 N Negative key 308 N Negative key
309 309
310 This file must be enabled at kernel configuration time as it allows anyone 310 This file must be enabled at kernel configuration time as it allows anyone
diff --git a/Documentation/laptop-mode.txt b/Documentation/laptop-mode.txt
index c487186eb2b9..6f639e3473af 100644
--- a/Documentation/laptop-mode.txt
+++ b/Documentation/laptop-mode.txt
@@ -121,7 +121,7 @@ contains the following options:
121MAX_AGE: 121MAX_AGE:
122 122
123Maximum time, in seconds, of hard drive spindown time that you are 123Maximum time, in seconds, of hard drive spindown time that you are
124confortable with. Worst case, it's possible that you could lose this 124comfortable with. Worst case, it's possible that you could lose this
125amount of work if your battery fails while you're in laptop mode. 125amount of work if your battery fails while you're in laptop mode.
126 126
127MINIMUM_BATTERY_MINUTES: 127MINIMUM_BATTERY_MINUTES:
@@ -235,7 +235,7 @@ It should be installed as /etc/default/laptop-mode on Debian, and as
235 235
236--------------------CONFIG FILE BEGIN------------------------------------------- 236--------------------CONFIG FILE BEGIN-------------------------------------------
237# Maximum time, in seconds, of hard drive spindown time that you are 237# Maximum time, in seconds, of hard drive spindown time that you are
238# confortable with. Worst case, it's possible that you could lose this 238# comfortable with. Worst case, it's possible that you could lose this
239# amount of work if your battery fails you while in laptop mode. 239# amount of work if your battery fails you while in laptop mode.
240#MAX_AGE=600 240#MAX_AGE=600
241 241
@@ -350,7 +350,7 @@ fi
350# set defaults instead: 350# set defaults instead:
351 351
352# Maximum time, in seconds, of hard drive spindown time that you are 352# Maximum time, in seconds, of hard drive spindown time that you are
353# confortable with. Worst case, it's possible that you could lose this 353# comfortable with. Worst case, it's possible that you could lose this
354# amount of work if your battery fails you while in laptop mode. 354# amount of work if your battery fails you while in laptop mode.
355MAX_AGE=${MAX_AGE:-'600'} 355MAX_AGE=${MAX_AGE:-'600'}
356 356
@@ -699,7 +699,7 @@ ACPI integration
699Dax Kelson submitted this so that the ACPI acpid daemon will 699Dax Kelson submitted this so that the ACPI acpid daemon will
700kick off the laptop_mode script and run hdparm. The part that 700kick off the laptop_mode script and run hdparm. The part that
701automatically disables laptop mode when the battery is low was 701automatically disables laptop mode when the battery is low was
702writen by Jan Topinski. 702written by Jan Topinski.
703 703
704-----------------/etc/acpi/events/ac_adapter BEGIN------------------------------ 704-----------------/etc/acpi/events/ac_adapter BEGIN------------------------------
705event=ac_adapter 705event=ac_adapter
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index 7751704b6db1..58408dd023c7 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -212,7 +212,7 @@ There are some minimal guarantees that may be expected of a CPU:
212 212
213 STORE *X = c, d = LOAD *X 213 STORE *X = c, d = LOAD *X
214 214
215 (Loads and stores overlap if they are targetted at overlapping pieces of 215 (Loads and stores overlap if they are targeted at overlapping pieces of
216 memory). 216 memory).
217 217
218And there are a number of things that _must_ or _must_not_ be assumed: 218And there are a number of things that _must_ or _must_not_ be assumed:
diff --git a/Documentation/networking/NAPI_HOWTO.txt b/Documentation/networking/NAPI_HOWTO.txt
index 93af3e87c65b..fb8dc6422a52 100644
--- a/Documentation/networking/NAPI_HOWTO.txt
+++ b/Documentation/networking/NAPI_HOWTO.txt
@@ -95,8 +95,8 @@ There are two types of event register ACK mechanisms.
95 Move all to dev->poll() 95 Move all to dev->poll()
96 96
97C) Ability to detect new work correctly. 97C) Ability to detect new work correctly.
98NAPI works by shutting down event interrupts when theres work and 98NAPI works by shutting down event interrupts when there's work and
99turning them on when theres none. 99turning them on when there's none.
100New packets might show up in the small window while interrupts were being 100New packets might show up in the small window while interrupts were being
101re-enabled (refer to appendix 2). A packet might sneak in during the period 101re-enabled (refer to appendix 2). A packet might sneak in during the period
102we are enabling interrupts. We only get to know about such a packet when the 102we are enabling interrupts. We only get to know about such a packet when the
@@ -114,7 +114,7 @@ Locking rules and environmental guarantees
114only one CPU can pick the initial interrupt and hence the initial 114only one CPU can pick the initial interrupt and hence the initial
115netif_rx_schedule(dev); 115netif_rx_schedule(dev);
116- The core layer invokes devices to send packets in a round robin format. 116- The core layer invokes devices to send packets in a round robin format.
117This implies receive is totaly lockless because of the guarantee only that 117This implies receive is totally lockless because of the guarantee that only
118one CPU is executing it. 118one CPU is executing it.
119- contention can only be the result of some other CPU accessing the rx 119- contention can only be the result of some other CPU accessing the rx
120ring. This happens only in close() and suspend() (when these methods 120ring. This happens only in close() and suspend() (when these methods
@@ -510,7 +510,7 @@ static int my_poll (struct net_device *dev, int *budget)
510 an interrupt will be generated */ 510 an interrupt will be generated */
511 goto done; 511 goto done;
512 } 512 }
513 /* done! at least thats what it looks like ;-> 513 /* done! at least that's what it looks like ;->
514 if new packets came in after our last check on status bits 514 if new packets came in after our last check on status bits
515 they'll be caught by the while check and we go back and clear them 515 they'll be caught by the while check and we go back and clear them
516 since we havent exceeded our quota */ 516 since we havent exceeded our quota */
@@ -535,11 +535,11 @@ done:
535 * 1. it can race with disabling irqs in irq handler (which are done to 535 * 1. it can race with disabling irqs in irq handler (which are done to
536 * schedule polls) 536 * schedule polls)
537 * 2. it can race with dis/enabling irqs in other poll threads 537 * 2. it can race with dis/enabling irqs in other poll threads
538 * 3. if an irq raised after the begining of the outer beginning 538 * 3. if an irq raised after the beginning of the outer beginning
539 * loop(marked in the code above), it will be immediately 539 * loop (marked in the code above), it will be immediately
540 * triggered here. 540 * triggered here.
541 * 541 *
542 * Summarizing: the logic may results in some redundant irqs both 542 * Summarizing: the logic may result in some redundant irqs both
543 * due to races in masking and due to too late acking of already 543 * due to races in masking and due to too late acking of already
544 * processed irqs. The good news: no events are ever lost. 544 * processed irqs. The good news: no events are ever lost.
545 */ 545 */
@@ -601,7 +601,7 @@ a)
601 601
6025) dev->close() and dev->suspend() issues 6025) dev->close() and dev->suspend() issues
603========================================== 603==========================================
604The driver writter neednt worry about this. The top net layer takes 604The driver writer needn't worry about this; the top net layer takes
605care of it. 605care of it.
606 606
6076) Adding new Stats to /proc 6076) Adding new Stats to /proc
@@ -622,9 +622,9 @@ FC should be programmed to apply in the case when the system cant pull out
622packets fast enough i.e send a pause only when you run out of rx buffers. 622packets fast enough i.e send a pause only when you run out of rx buffers.
623Note FC in itself is a good solution but we have found it to not be 623Note FC in itself is a good solution but we have found it to not be
624much of a commodity feature (both in NICs and switches) and hence falls 624much of a commodity feature (both in NICs and switches) and hence falls
625under the same category as using NIC based mitigation. Also experiments 625under the same category as using NIC based mitigation. Also, experiments
626indicate that its much harder to resolve the resource allocation 626indicate that it's much harder to resolve the resource allocation
627issue (aka lazy receiving that NAPI offers) and hence quantify its usefullness 627issue (aka lazy receiving that NAPI offers) and hence quantify its usefulness
628proved harder. In any case, FC works even better with NAPI but is not 628proved harder. In any case, FC works even better with NAPI but is not
629necessary. 629necessary.
630 630
@@ -678,10 +678,10 @@ routine:
678CSR5 bit of interest is only the rx status. 678CSR5 bit of interest is only the rx status.
679If you look at the last if statement: 679If you look at the last if statement:
680you just finished grabbing all the packets from the rx ring .. you check if 680you just finished grabbing all the packets from the rx ring .. you check if
681status bit says theres more packets just in ... it says none; you then 681status bit says there are more packets just in ... it says none; you then
682enable rx interrupts again; if a new packet just came in during this check, 682enable rx interrupts again; if a new packet just came in during this check,
683we are counting that CSR5 will be set in that small window of opportunity 683we are counting that CSR5 will be set in that small window of opportunity
684and that by re-enabling interrupts, we would actually triger an interrupt 684and that by re-enabling interrupts, we would actually trigger an interrupt
685to register the new packet for processing. 685to register the new packet for processing.
686 686
687[The above description nay be very verbose, if you have better wording 687[The above description nay be very verbose, if you have better wording
diff --git a/Documentation/networking/cs89x0.txt b/Documentation/networking/cs89x0.txt
index 64896470e279..6387d3decf85 100644
--- a/Documentation/networking/cs89x0.txt
+++ b/Documentation/networking/cs89x0.txt
@@ -248,7 +248,7 @@ c) The driver's hardware probe routine is designed to avoid
248 with device probing. To avoid this behaviour, add one 248 with device probing. To avoid this behaviour, add one
249 to the `io=' module parameter. This doesn't actually change 249 to the `io=' module parameter. This doesn't actually change
250 the I/O address, but it is a flag to tell the driver 250 the I/O address, but it is a flag to tell the driver
251 topartially initialise the hardware before trying to 251 to partially initialise the hardware before trying to
252 identify the card. This could be dangerous if you are 252 identify the card. This could be dangerous if you are
253 not sure that there is a cs89x0 card at the provided address. 253 not sure that there is a cs89x0 card at the provided address.
254 254
@@ -620,8 +620,8 @@ I/O Address Device IRQ Device
620 12 Mouse (PS/2) 620 12 Mouse (PS/2)
621Memory Address Device 13 Math Coprocessor 621Memory Address Device 13 Math Coprocessor
622-------------- --------------------- 14 Hard Disk controller 622-------------- --------------------- 14 Hard Disk controller
623A000-BFFF EGA Graphics Adpater 623A000-BFFF EGA Graphics Adapter
624A000-C7FF VGA Graphics Adpater 624A000-C7FF VGA Graphics Adapter
625B000-BFFF Mono Graphics Adapter 625B000-BFFF Mono Graphics Adapter
626B800-BFFF Color Graphics Adapter 626B800-BFFF Color Graphics Adapter
627E000-FFFF AT BIOS 627E000-FFFF AT BIOS
diff --git a/Documentation/networking/dccp.txt b/Documentation/networking/dccp.txt
index 74563b38ffd9..dda15886bcb5 100644
--- a/Documentation/networking/dccp.txt
+++ b/Documentation/networking/dccp.txt
@@ -19,21 +19,17 @@ for real time and multimedia traffic.
19 19
20It has a base protocol and pluggable congestion control IDs (CCIDs). 20It has a base protocol and pluggable congestion control IDs (CCIDs).
21 21
22It is at draft RFC status and the homepage for DCCP as a protocol is at: 22It is at experimental RFC status and the homepage for DCCP as a protocol is at:
23 http://www.icir.org/kohler/dcp/ 23 http://www.read.cs.ucla.edu/dccp/
24 24
25Missing features 25Missing features
26================ 26================
27 27
28The DCCP implementation does not currently have all the features that are in 28The DCCP implementation does not currently have all the features that are in
29the draft RFC. 29the RFC.
30 30
31In particular the following are missing: 31The known bugs are at:
32- CCID2 support 32 http://linux-net.osdl.org/index.php/TODO#DCCP
33- feature negotiation
34
35When testing against other implementations it appears that elapsed time
36options are not coded compliant to the specification.
37 33
38Socket options 34Socket options
39============== 35==============
@@ -47,12 +43,70 @@ the socket will fall back to 0 (which means that no meaningful service code
47is present). Connecting sockets set at most one service option; for 43is present). Connecting sockets set at most one service option; for
48listening sockets, multiple service codes can be specified. 44listening sockets, multiple service codes can be specified.
49 45
46DCCP_SOCKOPT_SEND_CSCOV and DCCP_SOCKOPT_RECV_CSCOV are used for setting the
47partial checksum coverage (RFC 4340, sec. 9.2). The default is that checksums
48always cover the entire packet and that only fully covered application data is
49accepted by the receiver. Hence, when using this feature on the sender, it must
50be enabled at the receiver, too with suitable choice of CsCov.
51
52DCCP_SOCKOPT_SEND_CSCOV sets the sender checksum coverage. Values in the
53 range 0..15 are acceptable. The default setting is 0 (full coverage),
54 values between 1..15 indicate partial coverage.
55DCCP_SOCKOPT_SEND_CSCOV is for the receiver and has a different meaning: it
56 sets a threshold, where again values 0..15 are acceptable. The default
57 of 0 means that all packets with a partial coverage will be discarded.
58 Values in the range 1..15 indicate that packets with minimally such a
59 coverage value are also acceptable. The higher the number, the more
60 restrictive this setting (see [RFC 4340, sec. 9.2.1]).
61
62Sysctl variables
63================
64Several DCCP default parameters can be managed by the following sysctls
65(sysctl net.dccp.default or /proc/sys/net/dccp/default):
66
67request_retries
68 The number of active connection initiation retries (the number of
69 Requests minus one) before timing out. In addition, it also governs
70 the behaviour of the other, passive side: this variable also sets
71 the number of times DCCP repeats sending a Response when the initial
72 handshake does not progress from RESPOND to OPEN (i.e. when no Ack
73 is received after the initial Request). This value should be greater
74 than 0, suggested is less than 10. Analogue of tcp_syn_retries.
75
76retries1
77 How often a DCCP Response is retransmitted until the listening DCCP
78 side considers its connecting peer dead. Analogue of tcp_retries1.
79
80retries2
81 The number of times a general DCCP packet is retransmitted. This has
82 importance for retransmitted acknowledgments and feature negotiation,
83 data packets are never retransmitted. Analogue of tcp_retries2.
84
85send_ndp = 1
86 Whether or not to send NDP count options (sec. 7.7.2).
87
88send_ackvec = 1
89 Whether or not to send Ack Vector options (sec. 11.5).
90
91ack_ratio = 2
92 The default Ack Ratio (sec. 11.3) to use.
93
94tx_ccid = 2
95 Default CCID for the sender-receiver half-connection.
96
97rx_ccid = 2
98 Default CCID for the receiver-sender half-connection.
99
100seq_window = 100
101 The initial sequence window (sec. 7.5.2).
102
103tx_qlen = 5
104 The size of the transmit buffer in packets. A value of 0 corresponds
105 to an unbounded transmit buffer.
106
50Notes 107Notes
51===== 108=====
52 109
53SELinux does not yet have support for DCCP. You will need to turn it off or 110DCCP does not travel through NAT successfully at present on many boxes. This is
54else you will get EACCES. 111because the checksum covers the psuedo-header as per TCP and UDP. Linux NAT
55 112support for DCCP has been added.
56DCCP does not travel through NAT successfully at present. This is because
57the checksum covers the psuedo-header as per TCP and UDP. It should be
58relatively trivial to add Linux NAT support for DCCP.
diff --git a/Documentation/networking/e1000.txt b/Documentation/networking/e1000.txt
index 5c0a5cc03998..61b171cf5313 100644
--- a/Documentation/networking/e1000.txt
+++ b/Documentation/networking/e1000.txt
@@ -1,7 +1,7 @@
1Linux* Base Driver for the Intel(R) PRO/1000 Family of Adapters 1Linux* Base Driver for the Intel(R) PRO/1000 Family of Adapters
2=============================================================== 2===============================================================
3 3
4November 15, 2005 4September 26, 2006
5 5
6 6
7Contents 7Contents
@@ -9,6 +9,7 @@ Contents
9 9
10- In This Release 10- In This Release
11- Identifying Your Adapter 11- Identifying Your Adapter
12- Building and Installation
12- Command Line Parameters 13- Command Line Parameters
13- Speed and Duplex Configuration 14- Speed and Duplex Configuration
14- Additional Configurations 15- Additional Configurations
@@ -41,6 +42,9 @@ or later), lspci, and ifconfig to obtain the same information.
41Instructions on updating ethtool can be found in the section "Additional 42Instructions on updating ethtool can be found in the section "Additional
42Configurations" later in this document. 43Configurations" later in this document.
43 44
45NOTE: The Intel(R) 82562v 10/100 Network Connection only provides 10/100
46support.
47
44 48
45Identifying Your Adapter 49Identifying Your Adapter
46======================== 50========================
@@ -51,28 +55,27 @@ Driver ID Guide at:
51 http://support.intel.com/support/network/adapter/pro100/21397.htm 55 http://support.intel.com/support/network/adapter/pro100/21397.htm
52 56
53For the latest Intel network drivers for Linux, refer to the following 57For the latest Intel network drivers for Linux, refer to the following
54website. In the search field, enter your adapter name or type, or use the 58website. In the search field, enter your adapter name or type, or use the
55networking link on the left to search for your adapter: 59networking link on the left to search for your adapter:
56 60
57 http://downloadfinder.intel.com/scripts-df/support_intel.asp 61 http://downloadfinder.intel.com/scripts-df/support_intel.asp
58 62
59 63
60Command Line Parameters ======================= 64Command Line Parameters
65=======================
61 66
62If the driver is built as a module, the following optional parameters 67If the driver is built as a module, the following optional parameters
63are used by entering them on the command line with the modprobe or insmod 68are used by entering them on the command line with the modprobe command
64command using this syntax: 69using this syntax:
65 70
66 modprobe e1000 [<option>=<VAL1>,<VAL2>,...] 71 modprobe e1000 [<option>=<VAL1>,<VAL2>,...]
67 72
68 insmod e1000 [<option>=<VAL1>,<VAL2>,...]
69
70For example, with two PRO/1000 PCI adapters, entering: 73For example, with two PRO/1000 PCI adapters, entering:
71 74
72 insmod e1000 TxDescriptors=80,128 75 modprobe e1000 TxDescriptors=80,128
73 76
74loads the e1000 driver with 80 TX descriptors for the first adapter and 128 77loads the e1000 driver with 80 TX descriptors for the first adapter and
75TX descriptors for the second adapter. 78128 TX descriptors for the second adapter.
76 79
77The default value for each parameter is generally the recommended setting, 80The default value for each parameter is generally the recommended setting,
78unless otherwise noted. 81unless otherwise noted.
@@ -87,7 +90,7 @@ NOTES: For more information about the AutoNeg, Duplex, and Speed
87 http://www.intel.com/design/network/applnots/ap450.htm 90 http://www.intel.com/design/network/applnots/ap450.htm
88 91
89 A descriptor describes a data buffer and attributes related to 92 A descriptor describes a data buffer and attributes related to
90 the data buffer. This information is accessed by the hardware. 93 the data buffer. This information is accessed by the hardware.
91 94
92 95
93AutoNeg 96AutoNeg
@@ -96,9 +99,9 @@ AutoNeg
96Valid Range: 0x01-0x0F, 0x20-0x2F 99Valid Range: 0x01-0x0F, 0x20-0x2F
97Default Value: 0x2F 100Default Value: 0x2F
98 101
99This parameter is a bit mask that specifies which speed and duplex 102This parameter is a bit-mask that specifies the speed and duplex settings
100settings the board advertises. When this parameter is used, the Speed 103advertised by the adapter. When this parameter is used, the Speed and
101and Duplex parameters must not be specified. 104Duplex parameters must not be specified.
102 105
103NOTE: Refer to the Speed and Duplex section of this readme for more 106NOTE: Refer to the Speed and Duplex section of this readme for more
104 information on the AutoNeg parameter. 107 information on the AutoNeg parameter.
@@ -110,14 +113,15 @@ Duplex
110Valid Range: 0-2 (0=auto-negotiate, 1=half, 2=full) 113Valid Range: 0-2 (0=auto-negotiate, 1=half, 2=full)
111Default Value: 0 114Default Value: 0
112 115
113Defines the direction in which data is allowed to flow. Can be either 116This defines the direction in which data is allowed to flow. Can be
114one or two-directional. If both Duplex and the link partner are set to 117either one or two-directional. If both Duplex and the link partner are
115auto-negotiate, the board auto-detects the correct duplex. If the link 118set to auto-negotiate, the board auto-detects the correct duplex. If the
116partner is forced (either full or half), Duplex defaults to half-duplex. 119link partner is forced (either full or half), Duplex defaults to half-
120duplex.
117 121
118 122
119FlowControl 123FlowControl
120---------- 124-----------
121Valid Range: 0-3 (0=none, 1=Rx only, 2=Tx only, 3=Rx&Tx) 125Valid Range: 0-3 (0=none, 1=Rx only, 2=Tx only, 3=Rx&Tx)
122Default Value: Reads flow control settings from the EEPROM 126Default Value: Reads flow control settings from the EEPROM
123 127
@@ -127,57 +131,107 @@ to Ethernet PAUSE frames.
127 131
128InterruptThrottleRate 132InterruptThrottleRate
129--------------------- 133---------------------
130(not supported on Intel 82542, 82543 or 82544-based adapters) 134(not supported on Intel(R) 82542, 82543 or 82544-based adapters)
131Valid Range: 100-100000 (0=off, 1=dynamic) 135Valid Range: 0,1,3,100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
132Default Value: 8000 136Default Value: 3
133 137
134This value represents the maximum number of interrupts per second the 138The driver can limit the amount of interrupts per second that the adapter
135controller generates. InterruptThrottleRate is another setting used in 139will generate for incoming packets. It does this by writing a value to the
136interrupt moderation. Dynamic mode uses a heuristic algorithm to adjust 140adapter that is based on the maximum amount of interrupts that the adapter
137InterruptThrottleRate based on the current traffic load. 141will generate per second.
142
143Setting InterruptThrottleRate to a value greater or equal to 100
144will program the adapter to send out a maximum of that many interrupts
145per second, even if more packets have come in. This reduces interrupt
146load on the system and can lower CPU utilization under heavy load,
147but will increase latency as packets are not processed as quickly.
148
149The default behaviour of the driver previously assumed a static
150InterruptThrottleRate value of 8000, providing a good fallback value for
151all traffic types,but lacking in small packet performance and latency.
152The hardware can handle many more small packets per second however, and
153for this reason an adaptive interrupt moderation algorithm was implemented.
154
155Since 7.3.x, the driver has two adaptive modes (setting 1 or 3) in which
156it dynamically adjusts the InterruptThrottleRate value based on the traffic
157that it receives. After determining the type of incoming traffic in the last
158timeframe, it will adjust the InterruptThrottleRate to an appropriate value
159for that traffic.
160
161The algorithm classifies the incoming traffic every interval into
162classes. Once the class is determined, the InterruptThrottleRate value is
163adjusted to suit that traffic type the best. There are three classes defined:
164"Bulk traffic", for large amounts of packets of normal size; "Low latency",
165for small amounts of traffic and/or a significant percentage of small
166packets; and "Lowest latency", for almost completely small packets or
167minimal traffic.
168
169In dynamic conservative mode, the InterruptThrottleRate value is set to 4000
170for traffic that falls in class "Bulk traffic". If traffic falls in the "Low
171latency" or "Lowest latency" class, the InterruptThrottleRate is increased
172stepwise to 20000. This default mode is suitable for most applications.
173
174For situations where low latency is vital such as cluster or
175grid computing, the algorithm can reduce latency even more when
176InterruptThrottleRate is set to mode 1. In this mode, which operates
177the same as mode 3, the InterruptThrottleRate will be increased stepwise to
17870000 for traffic in class "Lowest latency".
179
180Setting InterruptThrottleRate to 0 turns off any interrupt moderation
181and may improve small packet latency, but is generally not suitable
182for bulk throughput traffic.
138 183
139NOTE: InterruptThrottleRate takes precedence over the TxAbsIntDelay and 184NOTE: InterruptThrottleRate takes precedence over the TxAbsIntDelay and
140 RxAbsIntDelay parameters. In other words, minimizing the receive 185 RxAbsIntDelay parameters. In other words, minimizing the receive
141 and/or transmit absolute delays does not force the controller to 186 and/or transmit absolute delays does not force the controller to
142 generate more interrupts than what the Interrupt Throttle Rate 187 generate more interrupts than what the Interrupt Throttle Rate
143 allows. 188 allows.
144 189
145CAUTION: If you are using the Intel PRO/1000 CT Network Connection 190CAUTION: If you are using the Intel(R) PRO/1000 CT Network Connection
146 (controller 82547), setting InterruptThrottleRate to a value 191 (controller 82547), setting InterruptThrottleRate to a value
147 greater than 75,000, may hang (stop transmitting) adapters 192 greater than 75,000, may hang (stop transmitting) adapters
148 under certain network conditions. If this occurs a NETDEV 193 under certain network conditions. If this occurs a NETDEV
149 WATCHDOG message is logged in the system event log. In 194 WATCHDOG message is logged in the system event log. In
150 addition, the controller is automatically reset, restoring 195 addition, the controller is automatically reset, restoring
151 the network connection. To eliminate the potential for the 196 the network connection. To eliminate the potential for the
152 hang, ensure that InterruptThrottleRate is set no greater 197 hang, ensure that InterruptThrottleRate is set no greater
153 than 75,000 and is not set to 0. 198 than 75,000 and is not set to 0.
154 199
155NOTE: When e1000 is loaded with default settings and multiple adapters 200NOTE: When e1000 is loaded with default settings and multiple adapters
156 are in use simultaneously, the CPU utilization may increase non- 201 are in use simultaneously, the CPU utilization may increase non-
157 linearly. In order to limit the CPU utilization without impacting 202 linearly. In order to limit the CPU utilization without impacting
158 the overall throughput, we recommend that you load the driver as 203 the overall throughput, we recommend that you load the driver as
159 follows: 204 follows:
160 205
161 insmod e1000.o InterruptThrottleRate=3000,3000,3000 206 modprobe e1000 InterruptThrottleRate=3000,3000,3000
162 207
163 This sets the InterruptThrottleRate to 3000 interrupts/sec for 208 This sets the InterruptThrottleRate to 3000 interrupts/sec for
164 the first, second, and third instances of the driver. The range 209 the first, second, and third instances of the driver. The range
165 of 2000 to 3000 interrupts per second works on a majority of 210 of 2000 to 3000 interrupts per second works on a majority of
166 systems and is a good starting point, but the optimal value will 211 systems and is a good starting point, but the optimal value will
167 be platform-specific. If CPU utilization is not a concern, use 212 be platform-specific. If CPU utilization is not a concern, use
168 RX_POLLING (NAPI) and default driver settings. 213 RX_POLLING (NAPI) and default driver settings.
169 214
170 215
216
171RxDescriptors 217RxDescriptors
172------------- 218-------------
173Valid Range: 80-256 for 82542 and 82543-based adapters 219Valid Range: 80-256 for 82542 and 82543-based adapters
174 80-4096 for all other supported adapters 220 80-4096 for all other supported adapters
175Default Value: 256 221Default Value: 256
176 222
177This value specifies the number of receive descriptors allocated by the 223This value specifies the number of receive buffer descriptors allocated
178driver. Increasing this value allows the driver to buffer more incoming 224by the driver. Increasing this value allows the driver to buffer more
179packets. Each descriptor is 16 bytes. A receive buffer is also 225incoming packets, at the expense of increased system memory utilization.
180allocated for each descriptor and is 2048. 226
227Each descriptor is 16 bytes. A receive buffer is also allocated for each
228descriptor and can be either 2048, 4096, 8192, or 16384 bytes, depending
229on the MTU setting. The maximum MTU size is 16110.
230
231NOTE: MTU designates the frame size. It only needs to be set for Jumbo
232 Frames. Depending on the available system resources, the request
233 for a higher number of receive descriptors may be denied. In this
234 case, use a lower number.
181 235
182 236
183RxIntDelay 237RxIntDelay
@@ -187,17 +241,17 @@ Default Value: 0
187 241
188This value delays the generation of receive interrupts in units of 1.024 242This value delays the generation of receive interrupts in units of 1.024
189microseconds. Receive interrupt reduction can improve CPU efficiency if 243microseconds. Receive interrupt reduction can improve CPU efficiency if
190properly tuned for specific network traffic. Increasing this value adds 244properly tuned for specific network traffic. Increasing this value adds
191extra latency to frame reception and can end up decreasing the throughput 245extra latency to frame reception and can end up decreasing the throughput
192of TCP traffic. If the system is reporting dropped receives, this value 246of TCP traffic. If the system is reporting dropped receives, this value
193may be set too high, causing the driver to run out of available receive 247may be set too high, causing the driver to run out of available receive
194descriptors. 248descriptors.
195 249
196CAUTION: When setting RxIntDelay to a value other than 0, adapters may 250CAUTION: When setting RxIntDelay to a value other than 0, adapters may
197 hang (stop transmitting) under certain network conditions. If 251 hang (stop transmitting) under certain network conditions. If
198 this occurs a NETDEV WATCHDOG message is logged in the system 252 this occurs a NETDEV WATCHDOG message is logged in the system
199 event log. In addition, the controller is automatically reset, 253 event log. In addition, the controller is automatically reset,
200 restoring the network connection. To eliminate the potential 254 restoring the network connection. To eliminate the potential
201 for the hang ensure that RxIntDelay is set to 0. 255 for the hang ensure that RxIntDelay is set to 0.
202 256
203 257
@@ -208,7 +262,7 @@ Valid Range: 0-65535 (0=off)
208Default Value: 128 262Default Value: 128
209 263
210This value, in units of 1.024 microseconds, limits the delay in which a 264This value, in units of 1.024 microseconds, limits the delay in which a
211receive interrupt is generated. Useful only if RxIntDelay is non-zero, 265receive interrupt is generated. Useful only if RxIntDelay is non-zero,
212this value ensures that an interrupt is generated after the initial 266this value ensures that an interrupt is generated after the initial
213packet is received within the set amount of time. Proper tuning, 267packet is received within the set amount of time. Proper tuning,
214along with RxIntDelay, may improve traffic throughput in specific network 268along with RxIntDelay, may improve traffic throughput in specific network
@@ -222,9 +276,9 @@ Valid Settings: 0, 10, 100, 1000
222Default Value: 0 (auto-negotiate at all supported speeds) 276Default Value: 0 (auto-negotiate at all supported speeds)
223 277
224Speed forces the line speed to the specified value in megabits per second 278Speed forces the line speed to the specified value in megabits per second
225(Mbps). If this parameter is not specified or is set to 0 and the link 279(Mbps). If this parameter is not specified or is set to 0 and the link
226partner is set to auto-negotiate, the board will auto-detect the correct 280partner is set to auto-negotiate, the board will auto-detect the correct
227speed. Duplex should also be set when Speed is set to either 10 or 100. 281speed. Duplex should also be set when Speed is set to either 10 or 100.
228 282
229 283
230TxDescriptors 284TxDescriptors
@@ -234,7 +288,7 @@ Valid Range: 80-256 for 82542 and 82543-based adapters
234Default Value: 256 288Default Value: 256
235 289
236This value is the number of transmit descriptors allocated by the driver. 290This value is the number of transmit descriptors allocated by the driver.
237Increasing this value allows the driver to queue more transmits. Each 291Increasing this value allows the driver to queue more transmits. Each
238descriptor is 16 bytes. 292descriptor is 16 bytes.
239 293
240NOTE: Depending on the available system resources, the request for a 294NOTE: Depending on the available system resources, the request for a
@@ -248,8 +302,8 @@ Valid Range: 0-65535 (0=off)
248Default Value: 64 302Default Value: 64
249 303
250This value delays the generation of transmit interrupts in units of 304This value delays the generation of transmit interrupts in units of
2511.024 microseconds. Transmit interrupt reduction can improve CPU 3051.024 microseconds. Transmit interrupt reduction can improve CPU
252efficiency if properly tuned for specific network traffic. If the 306efficiency if properly tuned for specific network traffic. If the
253system is reporting dropped transmits, this value may be set too high 307system is reporting dropped transmits, this value may be set too high
254causing the driver to run out of available transmit descriptors. 308causing the driver to run out of available transmit descriptors.
255 309
@@ -261,7 +315,7 @@ Valid Range: 0-65535 (0=off)
261Default Value: 64 315Default Value: 64
262 316
263This value, in units of 1.024 microseconds, limits the delay in which a 317This value, in units of 1.024 microseconds, limits the delay in which a
264transmit interrupt is generated. Useful only if TxIntDelay is non-zero, 318transmit interrupt is generated. Useful only if TxIntDelay is non-zero,
265this value ensures that an interrupt is generated after the initial 319this value ensures that an interrupt is generated after the initial
266packet is sent on the wire within the set amount of time. Proper tuning, 320packet is sent on the wire within the set amount of time. Proper tuning,
267along with TxIntDelay, may improve traffic throughput in specific 321along with TxIntDelay, may improve traffic throughput in specific
@@ -288,15 +342,15 @@ fiber interface board only links at 1000 Mbps full-duplex.
288 342
289For copper-based boards, the keywords interact as follows: 343For copper-based boards, the keywords interact as follows:
290 344
291 The default operation is auto-negotiate. The board advertises all 345 The default operation is auto-negotiate. The board advertises all
292 supported speed and duplex combinations, and it links at the highest 346 supported speed and duplex combinations, and it links at the highest
293 common speed and duplex mode IF the link partner is set to auto-negotiate. 347 common speed and duplex mode IF the link partner is set to auto-negotiate.
294 348
295 If Speed = 1000, limited auto-negotiation is enabled and only 1000 Mbps 349 If Speed = 1000, limited auto-negotiation is enabled and only 1000 Mbps
296 is advertised (The 1000BaseT spec requires auto-negotiation.) 350 is advertised (The 1000BaseT spec requires auto-negotiation.)
297 351
298 If Speed = 10 or 100, then both Speed and Duplex should be set. Auto- 352 If Speed = 10 or 100, then both Speed and Duplex should be set. Auto-
299 negotiation is disabled, and the AutoNeg parameter is ignored. Partner 353 negotiation is disabled, and the AutoNeg parameter is ignored. Partner
300 SHOULD also be forced. 354 SHOULD also be forced.
301 355
302The AutoNeg parameter is used when more control is required over the 356The AutoNeg parameter is used when more control is required over the
@@ -304,7 +358,7 @@ auto-negotiation process. It should be used when you wish to control which
304speed and duplex combinations are advertised during the auto-negotiation 358speed and duplex combinations are advertised during the auto-negotiation
305process. 359process.
306 360
307The parameter may be specified as either a decimal or hexidecimal value as 361The parameter may be specified as either a decimal or hexadecimal value as
308determined by the bitmap below. 362determined by the bitmap below.
309 363
310Bit position 7 6 5 4 3 2 1 0 364Bit position 7 6 5 4 3 2 1 0
@@ -337,20 +391,19 @@ Additional Configurations
337 391
338 Configuring the Driver on Different Distributions 392 Configuring the Driver on Different Distributions
339 ------------------------------------------------- 393 -------------------------------------------------
340
341 Configuring a network driver to load properly when the system is started 394 Configuring a network driver to load properly when the system is started
342 is distribution dependent. Typically, the configuration process involves 395 is distribution dependent. Typically, the configuration process involves
343 adding an alias line to /etc/modules.conf or /etc/modprobe.conf as well 396 adding an alias line to /etc/modules.conf or /etc/modprobe.conf as well
344 as editing other system startup scripts and/or configuration files. Many 397 as editing other system startup scripts and/or configuration files. Many
345 popular Linux distributions ship with tools to make these changes for you. 398 popular Linux distributions ship with tools to make these changes for you.
346 To learn the proper way to configure a network device for your system, 399 To learn the proper way to configure a network device for your system,
347 refer to your distribution documentation. If during this process you are 400 refer to your distribution documentation. If during this process you are
348 asked for the driver or module name, the name for the Linux Base Driver 401 asked for the driver or module name, the name for the Linux Base Driver
349 for the Intel PRO/1000 Family of Adapters is e1000. 402 for the Intel(R) PRO/1000 Family of Adapters is e1000.
350 403
351 As an example, if you install the e1000 driver for two PRO/1000 adapters 404 As an example, if you install the e1000 driver for two PRO/1000 adapters
352 (eth0 and eth1) and set the speed and duplex to 10full and 100half, add 405 (eth0 and eth1) and set the speed and duplex to 10full and 100half, add
353 the following to modules.conf or modprobe.conf: 406 the following to modules.conf or or modprobe.conf:
354 407
355 alias eth0 e1000 408 alias eth0 e1000
356 alias eth1 e1000 409 alias eth1 e1000
@@ -358,9 +411,8 @@ Additional Configurations
358 411
359 Viewing Link Messages 412 Viewing Link Messages
360 --------------------- 413 ---------------------
361
362 Link messages will not be displayed to the console if the distribution is 414 Link messages will not be displayed to the console if the distribution is
363 restricting system messages. In order to see network driver link messages 415 restricting system messages. In order to see network driver link messages
364 on your console, set dmesg to eight by entering the following: 416 on your console, set dmesg to eight by entering the following:
365 417
366 dmesg -n 8 418 dmesg -n 8
@@ -369,11 +421,9 @@ Additional Configurations
369 421
370 Jumbo Frames 422 Jumbo Frames
371 ------------ 423 ------------
372 424 Jumbo Frames support is enabled by changing the MTU to a value larger than
373 The driver supports Jumbo Frames for all adapters except 82542 and 425 the default of 1500. Use the ifconfig command to increase the MTU size.
374 82573-based adapters. Jumbo Frames support is enabled by changing the 426 For example:
375 MTU to a value larger than the default of 1500. Use the ifconfig command
376 to increase the MTU size. For example:
377 427
378 ifconfig eth<x> mtu 9000 up 428 ifconfig eth<x> mtu 9000 up
379 429
@@ -390,26 +440,49 @@ Additional Configurations
390 440
391 - To enable Jumbo Frames, increase the MTU size on the interface beyond 441 - To enable Jumbo Frames, increase the MTU size on the interface beyond
392 1500. 442 1500.
393 - The maximum MTU setting for Jumbo Frames is 16110. This value coincides 443
444 - The maximum MTU setting for Jumbo Frames is 16110. This value coincides
394 with the maximum Jumbo Frames size of 16128. 445 with the maximum Jumbo Frames size of 16128.
446
395 - Using Jumbo Frames at 10 or 100 Mbps may result in poor performance or 447 - Using Jumbo Frames at 10 or 100 Mbps may result in poor performance or
396 loss of link. 448 loss of link.
449
397 - Some Intel gigabit adapters that support Jumbo Frames have a frame size 450 - Some Intel gigabit adapters that support Jumbo Frames have a frame size
398 limit of 9238 bytes, with a corresponding MTU size limit of 9216 bytes. 451 limit of 9238 bytes, with a corresponding MTU size limit of 9216 bytes.
399 The adapters with this limitation are based on the Intel 82571EB and 452 The adapters with this limitation are based on the Intel(R) 82571EB,
400 82572EI controllers, which correspond to these product names: 453 82572EI, 82573L and 80003ES2LAN controller. These correspond to the
401 Intel® PRO/1000 PT Dual Port Server Adapter 454 following product names:
402 Intel® PRO/1000 PF Dual Port Server Adapter 455 Intel(R) PRO/1000 PT Server Adapter
403 Intel® PRO/1000 PT Server Adapter 456 Intel(R) PRO/1000 PT Desktop Adapter
404 Intel® PRO/1000 PT Desktop Adapter 457 Intel(R) PRO/1000 PT Network Connection
405 Intel® PRO/1000 PF Server Adapter 458 Intel(R) PRO/1000 PT Dual Port Server Adapter
406 459 Intel(R) PRO/1000 PT Dual Port Network Connection
407 - The Intel PRO/1000 PM Network Connection does not support jumbo frames. 460 Intel(R) PRO/1000 PF Server Adapter
461 Intel(R) PRO/1000 PF Network Connection
462 Intel(R) PRO/1000 PF Dual Port Server Adapter
463 Intel(R) PRO/1000 PB Server Connection
464 Intel(R) PRO/1000 PL Network Connection
465 Intel(R) PRO/1000 EB Network Connection with I/O Acceleration
466 Intel(R) PRO/1000 EB Backplane Connection with I/O Acceleration
467 Intel(R) PRO/1000 PT Quad Port Server Adapter
468
469 - Adapters based on the Intel(R) 82542 and 82573V/E controller do not
470 support Jumbo Frames. These correspond to the following product names:
471 Intel(R) PRO/1000 Gigabit Server Adapter
472 Intel(R) PRO/1000 PM Network Connection
473
474 - The following adapters do not support Jumbo Frames:
475 Intel(R) 82562V 10/100 Network Connection
476 Intel(R) 82566DM Gigabit Network Connection
477 Intel(R) 82566DC Gigabit Network Connection
478 Intel(R) 82566MM Gigabit Network Connection
479 Intel(R) 82566MC Gigabit Network Connection
480 Intel(R) 82562GT 10/100 Network Connection
481 Intel(R) 82562G 10/100 Network Connection
408 482
409 483
410 Ethtool 484 Ethtool
411 ------- 485 -------
412
413 The driver utilizes the ethtool interface for driver configuration and 486 The driver utilizes the ethtool interface for driver configuration and
414 diagnostics, as well as displaying statistical information. Ethtool 487 diagnostics, as well as displaying statistical information. Ethtool
415 version 1.6 or later is required for this functionality. 488 version 1.6 or later is required for this functionality.
@@ -417,15 +490,14 @@ Additional Configurations
417 The latest release of ethtool can be found from 490 The latest release of ethtool can be found from
418 http://sourceforge.net/projects/gkernel. 491 http://sourceforge.net/projects/gkernel.
419 492
420 NOTE: Ethtool 1.6 only supports a limited set of ethtool options. Support 493 NOTE: Ethtool 1.6 only supports a limited set of ethtool options. Support
421 for a more complete ethtool feature set can be enabled by upgrading 494 for a more complete ethtool feature set can be enabled by upgrading
422 ethtool to ethtool-1.8.1. 495 ethtool to ethtool-1.8.1.
423 496
424 Enabling Wake on LAN* (WoL) 497 Enabling Wake on LAN* (WoL)
425 --------------------------- 498 ---------------------------
426 499 WoL is configured through the Ethtool* utility. Ethtool is included with
427 WoL is configured through the Ethtool* utility. Ethtool is included with 500 all versions of Red Hat after Red Hat 7.2. For other Linux distributions,
428 all versions of Red Hat after Red Hat 7.2. For other Linux distributions,
429 download and install Ethtool from the following website: 501 download and install Ethtool from the following website:
430 http://sourceforge.net/projects/gkernel. 502 http://sourceforge.net/projects/gkernel.
431 503
@@ -436,11 +508,17 @@ Additional Configurations
436 For this driver version, in order to enable WoL, the e1000 driver must be 508 For this driver version, in order to enable WoL, the e1000 driver must be
437 loaded when shutting down or rebooting the system. 509 loaded when shutting down or rebooting the system.
438 510
511 Wake On LAN is only supported on port A for the following devices:
512 Intel(R) PRO/1000 PT Dual Port Network Connection
513 Intel(R) PRO/1000 PT Dual Port Server Connection
514 Intel(R) PRO/1000 PT Dual Port Server Adapter
515 Intel(R) PRO/1000 PF Dual Port Server Adapter
516 Intel(R) PRO/1000 PT Quad Port Server Adapter
517
439 NAPI 518 NAPI
440 ---- 519 ----
441 520 NAPI (Rx polling mode) is supported in the e1000 driver. NAPI is enabled
442 NAPI (Rx polling mode) is supported in the e1000 driver. NAPI is enabled 521 or disabled based on the configuration of the kernel. To override
443 or disabled based on the configuration of the kernel. To override
444 the default, use the following compile-time flags. 522 the default, use the following compile-time flags.
445 523
446 To enable NAPI, compile the driver module, passing in a configuration option: 524 To enable NAPI, compile the driver module, passing in a configuration option:
@@ -457,88 +535,105 @@ Additional Configurations
457Known Issues 535Known Issues
458============ 536============
459 537
460 Jumbo Frames System Requirement 538Dropped Receive Packets on Half-duplex 10/100 Networks
461 ------------------------------- 539------------------------------------------------------
462 540If you have an Intel PCI Express adapter running at 10mbps or 100mbps, half-
463 Memory allocation failures have been observed on Linux systems with 64 MB 541duplex, you may observe occasional dropped receive packets. There are no
464 of RAM or less that are running Jumbo Frames. If you are using Jumbo 542workarounds for this problem in this network configuration. The network must
465 Frames, your system may require more than the advertised minimum 543be updated to operate in full-duplex, and/or 1000mbps only.
466 requirement of 64 MB of system memory. 544
467 545Jumbo Frames System Requirement
468 Performance Degradation with Jumbo Frames 546-------------------------------
469 ----------------------------------------- 547Memory allocation failures have been observed on Linux systems with 64 MB
470 548of RAM or less that are running Jumbo Frames. If you are using Jumbo
471 Degradation in throughput performance may be observed in some Jumbo frames 549Frames, your system may require more than the advertised minimum
472 environments. If this is observed, increasing the application's socket 550requirement of 64 MB of system memory.
473 buffer size and/or increasing the /proc/sys/net/ipv4/tcp_*mem entry values 551
474 may help. See the specific application manual and 552Performance Degradation with Jumbo Frames
475 /usr/src/linux*/Documentation/ 553-----------------------------------------
476 networking/ip-sysctl.txt for more details. 554Degradation in throughput performance may be observed in some Jumbo frames
477 555environments. If this is observed, increasing the application's socket
478 Jumbo frames on Foundry BigIron 8000 switch 556buffer size and/or increasing the /proc/sys/net/ipv4/tcp_*mem entry values
479 ------------------------------------------- 557may help. See the specific application manual and
480 There is a known issue using Jumbo frames when connected to a Foundry 558/usr/src/linux*/Documentation/
481 BigIron 8000 switch. This is a 3rd party limitation. If you experience 559networking/ip-sysctl.txt for more details.
482 loss of packets, lower the MTU size. 560
483 561Jumbo Frames on Foundry BigIron 8000 switch
484 Multiple Interfaces on Same Ethernet Broadcast Network 562-------------------------------------------
485 ------------------------------------------------------ 563There is a known issue using Jumbo frames when connected to a Foundry
486 564BigIron 8000 switch. This is a 3rd party limitation. If you experience
487 Due to the default ARP behavior on Linux, it is not possible to have 565loss of packets, lower the MTU size.
488 one system on two IP networks in the same Ethernet broadcast domain 566
489 (non-partitioned switch) behave as expected. All Ethernet interfaces 567Allocating Rx Buffers when Using Jumbo Frames
490 will respond to IP traffic for any IP address assigned to the system. 568---------------------------------------------
491 This results in unbalanced receive traffic. 569Allocating Rx buffers when using Jumbo Frames on 2.6.x kernels may fail if
492 570the available memory is heavily fragmented. This issue may be seen with PCI-X
493 If you have multiple interfaces in a server, either turn on ARP 571adapters or with packet split disabled. This can be reduced or eliminated
494 filtering by entering: 572by changing the amount of available memory for receive buffer allocation, by
495 573increasing /proc/sys/vm/min_free_kbytes.
496 echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter 574
497 (this only works if your kernel's version is higher than 2.4.5), 575Multiple Interfaces on Same Ethernet Broadcast Network
498 576------------------------------------------------------
499 NOTE: This setting is not saved across reboots. The configuration 577Due to the default ARP behavior on Linux, it is not possible to have
500 change can be made permanent by adding the line: 578one system on two IP networks in the same Ethernet broadcast domain
501 net.ipv4.conf.all.arp_filter = 1 579(non-partitioned switch) behave as expected. All Ethernet interfaces
502 to the file /etc/sysctl.conf 580will respond to IP traffic for any IP address assigned to the system.
503 581This results in unbalanced receive traffic.
504 or, 582
505 583If you have multiple interfaces in a server, either turn on ARP
506 install the interfaces in separate broadcast domains (either in 584filtering by entering:
507 different switches or in a switch partitioned to VLANs). 585
508 586 echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
509 82541/82547 can't link or are slow to link with some link partners 587(this only works if your kernel's version is higher than 2.4.5),
510 ----------------------------------------------------------------- 588
511 589NOTE: This setting is not saved across reboots. The configuration
512 There is a known compatibility issue with 82541/82547 and some 590change can be made permanent by adding the line:
513 low-end switches where the link will not be established, or will 591 net.ipv4.conf.all.arp_filter = 1
514 be slow to establish. In particular, these switches are known to 592to the file /etc/sysctl.conf
515 be incompatible with 82541/82547: 593
516 594 or,
517 Planex FXG-08TE 595
518 I-O Data ETG-SH8 596install the interfaces in separate broadcast domains (either in
519 597different switches or in a switch partitioned to VLANs).
520 To workaround this issue, the driver can be compiled with an override 598
521 of the PHY's master/slave setting. Forcing master or forcing slave 59982541/82547 can't link or are slow to link with some link partners
522 mode will improve time-to-link. 600-----------------------------------------------------------------
523 601There is a known compatibility issue with 82541/82547 and some
524 # make EXTRA_CFLAGS=-DE1000_MASTER_SLAVE=<n> 602low-end switches where the link will not be established, or will
525 603be slow to establish. In particular, these switches are known to
526 Where <n> is: 604be incompatible with 82541/82547:
527 605
528 0 = Hardware default 606 Planex FXG-08TE
529 1 = Master mode 607 I-O Data ETG-SH8
530 2 = Slave mode 608
531 3 = Auto master/slave 609To workaround this issue, the driver can be compiled with an override
532 610of the PHY's master/slave setting. Forcing master or forcing slave
533 Disable rx flow control with ethtool 611mode will improve time-to-link.
534 ------------------------------------ 612
535 613 # make CFLAGS_EXTRA=-DE1000_MASTER_SLAVE=<n>
536 In order to disable receive flow control using ethtool, you must turn 614
537 off auto-negotiation on the same command line. 615Where <n> is:
538 616
539 For example: 617 0 = Hardware default
540 618 1 = Master mode
541 ethtool -A eth? autoneg off rx off 619 2 = Slave mode
620 3 = Auto master/slave
621
622Disable rx flow control with ethtool
623------------------------------------
624In order to disable receive flow control using ethtool, you must turn
625off auto-negotiation on the same command line.
626
627For example:
628
629 ethtool -A eth? autoneg off rx off
630
631Unplugging network cable while ethtool -p is running
632----------------------------------------------------
633In kernel versions 2.5.50 and later (including 2.6 kernel), unplugging
634the network cable while ethtool -p is running will cause the system to
635become unresponsive to keyboard commands, except for control-alt-delete.
636Restarting the system appears to be the only remedy.
542 637
543 638
544Support 639Support
@@ -548,24 +643,10 @@ For general information, go to the Intel support website at:
548 643
549 http://support.intel.com 644 http://support.intel.com
550 645
551 or the Intel Wired Networking project hosted by Sourceforge at: 646or the Intel Wired Networking project hosted by Sourceforge at:
552 647
553 http://sourceforge.net/projects/e1000 648 http://sourceforge.net/projects/e1000
554 649
555If an issue is identified with the released source code on the supported 650If an issue is identified with the released source code on the supported
556kernel with a supported adapter, email the specific information related 651kernel with a supported adapter, email the specific information related
557to the issue to e1000-devel@lists.sourceforge.net 652to the issue to e1000-devel@lists.sf.net
558
559
560License
561=======
562
563This software program is released under the terms of a license agreement
564between you ('Licensee') and Intel. Do not use or load this software or any
565associated materials (collectively, the 'Software') until you have carefully
566read the full terms and conditions of the file COPYING located in this software
567package. By loading or using the Software, you agree to the terms of this
568Agreement. If you do not agree with the terms of this Agreement, do not
569install or use the Software.
570
571* Other names and brands may be claimed as the property of others.
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index fd3c0c012351..a0f6842368c3 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -101,6 +101,11 @@ inet_peer_gc_maxtime - INTEGER
101 101
102TCP variables: 102TCP variables:
103 103
104somaxconn - INTEGER
105 Limit of socket listen() backlog, known in userspace as SOMAXCONN.
106 Defaults to 128. See also tcp_max_syn_backlog for additional tuning
107 for TCP sockets.
108
104tcp_abc - INTEGER 109tcp_abc - INTEGER
105 Controls Appropriate Byte Count (ABC) defined in RFC3465. 110 Controls Appropriate Byte Count (ABC) defined in RFC3465.
106 ABC is a way of increasing congestion window (cwnd) more slowly 111 ABC is a way of increasing congestion window (cwnd) more slowly
@@ -112,48 +117,51 @@ tcp_abc - INTEGER
112 of two segments to compensate for delayed acknowledgments. 117 of two segments to compensate for delayed acknowledgments.
113 Default: 0 (off) 118 Default: 0 (off)
114 119
115tcp_syn_retries - INTEGER 120tcp_abort_on_overflow - BOOLEAN
116 Number of times initial SYNs for an active TCP connection attempt 121 If listening service is too slow to accept new connections,
117 will be retransmitted. Should not be higher than 255. Default value 122 reset them. Default state is FALSE. It means that if overflow
118 is 5, which corresponds to ~180seconds. 123 occurred due to a burst, connection will recover. Enable this
124 option _only_ if you are really sure that listening daemon
125 cannot be tuned to accept connections faster. Enabling this
126 option can harm clients of your server.
119 127
120tcp_synack_retries - INTEGER 128tcp_adv_win_scale - INTEGER
121 Number of times SYNACKs for a passive TCP connection attempt will 129 Count buffering overhead as bytes/2^tcp_adv_win_scale
122 be retransmitted. Should not be higher than 255. Default value 130 (if tcp_adv_win_scale > 0) or bytes-bytes/2^(-tcp_adv_win_scale),
123 is 5, which corresponds to ~180seconds. 131 if it is <= 0.
132 Default: 2
124 133
125tcp_keepalive_time - INTEGER 134tcp_allowed_congestion_control - STRING
126 How often TCP sends out keepalive messages when keepalive is enabled. 135 Show/set the congestion control choices available to non-privileged
127 Default: 2hours. 136 processes. The list is a subset of those listed in
137 tcp_available_congestion_control.
138 Default is "reno" and the default setting (tcp_congestion_control).
128 139
129tcp_keepalive_probes - INTEGER 140tcp_app_win - INTEGER
130 How many keepalive probes TCP sends out, until it decides that the 141 Reserve max(window/2^tcp_app_win, mss) of window for application
131 connection is broken. Default value: 9. 142 buffer. Value 0 is special, it means that nothing is reserved.
143 Default: 31
132 144
133tcp_keepalive_intvl - INTEGER 145tcp_available_congestion_control - STRING
134 How frequently the probes are send out. Multiplied by 146 Shows the available congestion control choices that are registered.
135 tcp_keepalive_probes it is time to kill not responding connection, 147 More congestion control algorithms may be available as modules,
136 after probes started. Default value: 75sec i.e. connection 148 but not loaded.
137 will be aborted after ~11 minutes of retries.
138 149
139tcp_retries1 - INTEGER 150tcp_congestion_control - STRING
140 How many times to retry before deciding that something is wrong 151 Set the congestion control algorithm to be used for new
141 and it is necessary to report this suspicion to network layer. 152 connections. The algorithm "reno" is always available, but
142 Minimal RFC value is 3, it is default, which corresponds 153 additional choices may be available based on kernel configuration.
143 to ~3sec-8min depending on RTO. 154 Default is set as part of kernel configuration.
144 155
145tcp_retries2 - INTEGER 156tcp_dsack - BOOLEAN
146 How may times to retry before killing alive TCP connection. 157 Allows TCP to send "duplicate" SACKs.
147 RFC1122 says that the limit should be longer than 100 sec.
148 It is too small number. Default value 15 corresponds to ~13-30min
149 depending on RTO.
150 158
151tcp_orphan_retries - INTEGER 159tcp_ecn - BOOLEAN
152 How may times to retry before killing TCP connection, closed 160 Enable Explicit Congestion Notification in TCP.
153 by our side. Default value 7 corresponds to ~50sec-16min 161
154 depending on RTO. If you machine is loaded WEB server, 162tcp_fack - BOOLEAN
155 you should think about lowering this value, such sockets 163 Enable FACK congestion avoidance and fast retransmission.
156 may consume significant resources. Cf. tcp_max_orphans. 164 The value is not used, if tcp_sack is not enabled.
157 165
158tcp_fin_timeout - INTEGER 166tcp_fin_timeout - INTEGER
159 Time to hold socket in state FIN-WAIT-2, if it was closed 167 Time to hold socket in state FIN-WAIT-2, if it was closed
@@ -166,24 +174,33 @@ tcp_fin_timeout - INTEGER
166 because they eat maximum 1.5K of memory, but they tend 174 because they eat maximum 1.5K of memory, but they tend
167 to live longer. Cf. tcp_max_orphans. 175 to live longer. Cf. tcp_max_orphans.
168 176
169tcp_max_tw_buckets - INTEGER 177tcp_frto - BOOLEAN
170 Maximal number of timewait sockets held by system simultaneously. 178 Enables F-RTO, an enhanced recovery algorithm for TCP retransmission
171 If this number is exceeded time-wait socket is immediately destroyed 179 timeouts. It is particularly beneficial in wireless environments
172 and warning is printed. This limit exists only to prevent 180 where packet loss is typically due to random radio interference
173 simple DoS attacks, you _must_ not lower the limit artificially, 181 rather than intermediate router congestion.
174 but rather increase it (probably, after increasing installed memory),
175 if network conditions require more than default value.
176 182
177tcp_tw_recycle - BOOLEAN 183tcp_keepalive_time - INTEGER
178 Enable fast recycling TIME-WAIT sockets. Default value is 0. 184 How often TCP sends out keepalive messages when keepalive is enabled.
179 It should not be changed without advice/request of technical 185 Default: 2hours.
180 experts.
181 186
182tcp_tw_reuse - BOOLEAN 187tcp_keepalive_probes - INTEGER
183 Allow to reuse TIME-WAIT sockets for new connections when it is 188 How many keepalive probes TCP sends out, until it decides that the
184 safe from protocol viewpoint. Default value is 0. 189 connection is broken. Default value: 9.
185 It should not be changed without advice/request of technical 190
186 experts. 191tcp_keepalive_intvl - INTEGER
192 How frequently the probes are send out. Multiplied by
193 tcp_keepalive_probes it is time to kill not responding connection,
194 after probes started. Default value: 75sec i.e. connection
195 will be aborted after ~11 minutes of retries.
196
197tcp_low_latency - BOOLEAN
198 If set, the TCP stack makes decisions that prefer lower
199 latency as opposed to higher throughput. By default, this
200 option is not set meaning that higher throughput is preferred.
201 An example of an application where this default should be
202 changed would be a Beowulf compute cluster.
203 Default: 0
187 204
188tcp_max_orphans - INTEGER 205tcp_max_orphans - INTEGER
189 Maximal number of TCP sockets not attached to any user file handle, 206 Maximal number of TCP sockets not attached to any user file handle,
@@ -197,41 +214,6 @@ tcp_max_orphans - INTEGER
197 more aggressively. Let me to remind again: each orphan eats 214 more aggressively. Let me to remind again: each orphan eats
198 up to ~64K of unswappable memory. 215 up to ~64K of unswappable memory.
199 216
200tcp_abort_on_overflow - BOOLEAN
201 If listening service is too slow to accept new connections,
202 reset them. Default state is FALSE. It means that if overflow
203 occurred due to a burst, connection will recover. Enable this
204 option _only_ if you are really sure that listening daemon
205 cannot be tuned to accept connections faster. Enabling this
206 option can harm clients of your server.
207
208tcp_syncookies - BOOLEAN
209 Only valid when the kernel was compiled with CONFIG_SYNCOOKIES
210 Send out syncookies when the syn backlog queue of a socket
211 overflows. This is to prevent against the common 'syn flood attack'
212 Default: FALSE
213
214 Note, that syncookies is fallback facility.
215 It MUST NOT be used to help highly loaded servers to stand
216 against legal connection rate. If you see synflood warnings
217 in your logs, but investigation shows that they occur
218 because of overload with legal connections, you should tune
219 another parameters until this warning disappear.
220 See: tcp_max_syn_backlog, tcp_synack_retries, tcp_abort_on_overflow.
221
222 syncookies seriously violate TCP protocol, do not allow
223 to use TCP extensions, can result in serious degradation
224 of some services (f.e. SMTP relaying), visible not by you,
225 but your clients and relays, contacting you. While you see
226 synflood warnings in logs not being really flooded, your server
227 is seriously misconfigured.
228
229tcp_stdurg - BOOLEAN
230 Use the Host requirements interpretation of the TCP urg pointer field.
231 Most hosts use the older BSD interpretation, so if you turn this on
232 Linux might not communicate correctly with them.
233 Default: FALSE
234
235tcp_max_syn_backlog - INTEGER 217tcp_max_syn_backlog - INTEGER
236 Maximal number of remembered connection requests, which are 218 Maximal number of remembered connection requests, which are
237 still did not receive an acknowledgment from connecting client. 219 still did not receive an acknowledgment from connecting client.
@@ -239,24 +221,34 @@ tcp_max_syn_backlog - INTEGER
239 and 128 for low memory machines. If server suffers of overload, 221 and 128 for low memory machines. If server suffers of overload,
240 try to increase this number. 222 try to increase this number.
241 223
242tcp_window_scaling - BOOLEAN 224tcp_max_tw_buckets - INTEGER
243 Enable window scaling as defined in RFC1323. 225 Maximal number of timewait sockets held by system simultaneously.
226 If this number is exceeded time-wait socket is immediately destroyed
227 and warning is printed. This limit exists only to prevent
228 simple DoS attacks, you _must_ not lower the limit artificially,
229 but rather increase it (probably, after increasing installed memory),
230 if network conditions require more than default value.
244 231
245tcp_timestamps - BOOLEAN 232tcp_mem - vector of 3 INTEGERs: min, pressure, max
246 Enable timestamps as defined in RFC1323. 233 min: below this number of pages TCP is not bothered about its
234 memory appetite.
247 235
248tcp_sack - BOOLEAN 236 pressure: when amount of memory allocated by TCP exceeds this number
249 Enable select acknowledgments (SACKS). 237 of pages, TCP moderates its memory consumption and enters memory
238 pressure mode, which is exited when memory consumption falls
239 under "min".
250 240
251tcp_fack - BOOLEAN 241 max: number of pages allowed for queueing by all TCP sockets.
252 Enable FACK congestion avoidance and fast retransmission.
253 The value is not used, if tcp_sack is not enabled.
254 242
255tcp_dsack - BOOLEAN 243 Defaults are calculated at boot time from amount of available
256 Allows TCP to send "duplicate" SACKs. 244 memory.
257 245
258tcp_ecn - BOOLEAN 246tcp_orphan_retries - INTEGER
259 Enable Explicit Congestion Notification in TCP. 247 How may times to retry before killing TCP connection, closed
248 by our side. Default value 7 corresponds to ~50sec-16min
249 depending on RTO. If you machine is loaded WEB server,
250 you should think about lowering this value, such sockets
251 may consume significant resources. Cf. tcp_max_orphans.
260 252
261tcp_reordering - INTEGER 253tcp_reordering - INTEGER
262 Maximal reordering of packets in a TCP stream. 254 Maximal reordering of packets in a TCP stream.
@@ -267,20 +259,23 @@ tcp_retrans_collapse - BOOLEAN
267 On retransmit try to send bigger packets to work around bugs in 259 On retransmit try to send bigger packets to work around bugs in
268 certain TCP stacks. 260 certain TCP stacks.
269 261
270tcp_wmem - vector of 3 INTEGERs: min, default, max 262tcp_retries1 - INTEGER
271 min: Amount of memory reserved for send buffers for TCP socket. 263 How many times to retry before deciding that something is wrong
272 Each TCP socket has rights to use it due to fact of its birth. 264 and it is necessary to report this suspicion to network layer.
273 Default: 4K 265 Minimal RFC value is 3, it is default, which corresponds
266 to ~3sec-8min depending on RTO.
274 267
275 default: Amount of memory allowed for send buffers for TCP socket 268tcp_retries2 - INTEGER
276 by default. This value overrides net.core.wmem_default used 269 How may times to retry before killing alive TCP connection.
277 by other protocols, it is usually lower than net.core.wmem_default. 270 RFC1122 says that the limit should be longer than 100 sec.
278 Default: 16K 271 It is too small number. Default value 15 corresponds to ~13-30min
272 depending on RTO.
279 273
280 max: Maximal amount of memory allowed for automatically selected 274tcp_rfc1337 - BOOLEAN
281 send buffers for TCP socket. This value does not override 275 If set, the TCP stack behaves conforming to RFC1337. If unset,
282 net.core.wmem_max, "static" selection via SO_SNDBUF does not use this. 276 we are not conforming to RFC, but prevent TCP TIME_WAIT
283 Default: 128K 277 assassination.
278 Default: 0
284 279
285tcp_rmem - vector of 3 INTEGERs: min, default, max 280tcp_rmem - vector of 3 INTEGERs: min, default, max
286 min: Minimal size of receive buffer used by TCP sockets. 281 min: Minimal size of receive buffer used by TCP sockets.
@@ -299,67 +294,91 @@ tcp_rmem - vector of 3 INTEGERs: min, default, max
299 net.core.rmem_max, "static" selection via SO_RCVBUF does not use this. 294 net.core.rmem_max, "static" selection via SO_RCVBUF does not use this.
300 Default: 87380*2 bytes. 295 Default: 87380*2 bytes.
301 296
302tcp_mem - vector of 3 INTEGERs: min, pressure, max 297tcp_sack - BOOLEAN
303 min: below this number of pages TCP is not bothered about its 298 Enable select acknowledgments (SACKS).
304 memory appetite.
305 299
306 pressure: when amount of memory allocated by TCP exceeds this number 300tcp_slow_start_after_idle - BOOLEAN
307 of pages, TCP moderates its memory consumption and enters memory 301 If set, provide RFC2861 behavior and time out the congestion
308 pressure mode, which is exited when memory consumption falls 302 window after an idle period. An idle period is defined at
309 under "min". 303 the current RTO. If unset, the congestion window will not
304 be timed out after an idle period.
305 Default: 1
310 306
311 max: number of pages allowed for queueing by all TCP sockets. 307tcp_stdurg - BOOLEAN
308 Use the Host requirements interpretation of the TCP urg pointer field.
309 Most hosts use the older BSD interpretation, so if you turn this on
310 Linux might not communicate correctly with them.
311 Default: FALSE
312 312
313 Defaults are calculated at boot time from amount of available 313tcp_synack_retries - INTEGER
314 memory. 314 Number of times SYNACKs for a passive TCP connection attempt will
315 be retransmitted. Should not be higher than 255. Default value
316 is 5, which corresponds to ~180seconds.
315 317
316tcp_app_win - INTEGER 318tcp_syncookies - BOOLEAN
317 Reserve max(window/2^tcp_app_win, mss) of window for application 319 Only valid when the kernel was compiled with CONFIG_SYNCOOKIES
318 buffer. Value 0 is special, it means that nothing is reserved. 320 Send out syncookies when the syn backlog queue of a socket
319 Default: 31 321 overflows. This is to prevent against the common 'syn flood attack'
322 Default: FALSE
320 323
321tcp_adv_win_scale - INTEGER 324 Note, that syncookies is fallback facility.
322 Count buffering overhead as bytes/2^tcp_adv_win_scale 325 It MUST NOT be used to help highly loaded servers to stand
323 (if tcp_adv_win_scale > 0) or bytes-bytes/2^(-tcp_adv_win_scale), 326 against legal connection rate. If you see synflood warnings
324 if it is <= 0. 327 in your logs, but investigation shows that they occur
325 Default: 2 328 because of overload with legal connections, you should tune
329 another parameters until this warning disappear.
330 See: tcp_max_syn_backlog, tcp_synack_retries, tcp_abort_on_overflow.
326 331
327tcp_rfc1337 - BOOLEAN 332 syncookies seriously violate TCP protocol, do not allow
328 If set, the TCP stack behaves conforming to RFC1337. If unset, 333 to use TCP extensions, can result in serious degradation
329 we are not conforming to RFC, but prevent TCP TIME_WAIT 334 of some services (f.e. SMTP relaying), visible not by you,
330 assassination. 335 but your clients and relays, contacting you. While you see
331 Default: 0 336 synflood warnings in logs not being really flooded, your server
337 is seriously misconfigured.
332 338
333tcp_low_latency - BOOLEAN 339tcp_syn_retries - INTEGER
334 If set, the TCP stack makes decisions that prefer lower 340 Number of times initial SYNs for an active TCP connection attempt
335 latency as opposed to higher throughput. By default, this 341 will be retransmitted. Should not be higher than 255. Default value
336 option is not set meaning that higher throughput is preferred. 342 is 5, which corresponds to ~180seconds.
337 An example of an application where this default should be 343
338 changed would be a Beowulf compute cluster. 344tcp_timestamps - BOOLEAN
339 Default: 0 345 Enable timestamps as defined in RFC1323.
340 346
341tcp_tso_win_divisor - INTEGER 347tcp_tso_win_divisor - INTEGER
342 This allows control over what percentage of the congestion window 348 This allows control over what percentage of the congestion window
343 can be consumed by a single TSO frame. 349 can be consumed by a single TSO frame.
344 The setting of this parameter is a choice between burstiness and 350 The setting of this parameter is a choice between burstiness and
345 building larger TSO frames. 351 building larger TSO frames.
346 Default: 3 352 Default: 3
347 353
348tcp_frto - BOOLEAN 354tcp_tw_recycle - BOOLEAN
349 Enables F-RTO, an enhanced recovery algorithm for TCP retransmission 355 Enable fast recycling TIME-WAIT sockets. Default value is 0.
350 timeouts. It is particularly beneficial in wireless environments 356 It should not be changed without advice/request of technical
351 where packet loss is typically due to random radio interference 357 experts.
352 rather than intermediate router congestion.
353 358
354tcp_congestion_control - STRING 359tcp_tw_reuse - BOOLEAN
355 Set the congestion control algorithm to be used for new 360 Allow to reuse TIME-WAIT sockets for new connections when it is
356 connections. The algorithm "reno" is always available, but 361 safe from protocol viewpoint. Default value is 0.
357 additional choices may be available based on kernel configuration. 362 It should not be changed without advice/request of technical
363 experts.
358 364
359somaxconn - INTEGER 365tcp_window_scaling - BOOLEAN
360 Limit of socket listen() backlog, known in userspace as SOMAXCONN. 366 Enable window scaling as defined in RFC1323.
361 Defaults to 128. See also tcp_max_syn_backlog for additional tuning 367
362 for TCP sockets. 368tcp_wmem - vector of 3 INTEGERs: min, default, max
369 min: Amount of memory reserved for send buffers for TCP socket.
370 Each TCP socket has rights to use it due to fact of its birth.
371 Default: 4K
372
373 default: Amount of memory allowed for send buffers for TCP socket
374 by default. This value overrides net.core.wmem_default used
375 by other protocols, it is usually lower than net.core.wmem_default.
376 Default: 16K
377
378 max: Maximal amount of memory allowed for automatically selected
379 send buffers for TCP socket. This value does not override
380 net.core.wmem_max, "static" selection via SO_SNDBUF does not use this.
381 Default: 128K
363 382
364tcp_workaround_signed_windows - BOOLEAN 383tcp_workaround_signed_windows - BOOLEAN
365 If set, assume no receipt of a window scaling option means the 384 If set, assume no receipt of a window scaling option means the
@@ -368,13 +387,6 @@ tcp_workaround_signed_windows - BOOLEAN
368 not receive a window scaling option from them. 387 not receive a window scaling option from them.
369 Default: 0 388 Default: 0
370 389
371tcp_slow_start_after_idle - BOOLEAN
372 If set, provide RFC2861 behavior and time out the congestion
373 window after an idle period. An idle period is defined at
374 the current RTO. If unset, the congestion window will not
375 be timed out after an idle period.
376 Default: 1
377
378CIPSOv4 Variables: 390CIPSOv4 Variables:
379 391
380cipso_cache_enable - BOOLEAN 392cipso_cache_enable - BOOLEAN
@@ -974,4 +986,3 @@ no_cong_thresh FIXME
974slot_timeout FIXME 986slot_timeout FIXME
975warn_noreply_time FIXME 987warn_noreply_time FIXME
976 988
977$Id: ip-sysctl.txt,v 1.20 2001/12/13 09:00:18 davem Exp $
diff --git a/Documentation/networking/iphase.txt b/Documentation/networking/iphase.txt
index 493203a080a8..55eac4a784e2 100644
--- a/Documentation/networking/iphase.txt
+++ b/Documentation/networking/iphase.txt
@@ -81,7 +81,7 @@ Installation
81 1M. The RAM size decides the number of buffers and buffer size. The default 81 1M. The RAM size decides the number of buffers and buffer size. The default
82 size and number of buffers are set as following: 82 size and number of buffers are set as following:
83 83
84 Totol Rx RAM Tx RAM Rx Buf Tx Buf Rx buf Tx buf 84 Total Rx RAM Tx RAM Rx Buf Tx Buf Rx buf Tx buf
85 RAM size size size size size cnt cnt 85 RAM size size size size size cnt cnt
86 -------- ------ ------ ------ ------ ------ ------ 86 -------- ------ ------ ------ ------ ------ ------
87 128K 64K 64K 10K 10K 6 6 87 128K 64K 64K 10K 10K 6 6
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt
index 12a008a5c221..5a232d946be3 100644
--- a/Documentation/networking/packet_mmap.txt
+++ b/Documentation/networking/packet_mmap.txt
@@ -284,7 +284,7 @@ the necessary memory, so normally limits can be reached.
284------------------- 284-------------------
285 285
286If you check the source code you will see that what I draw here as a frame 286If you check the source code you will see that what I draw here as a frame
287is not only the link level frame. At the begining of each frame there is a 287is not only the link level frame. At the beginning of each frame there is a
288header called struct tpacket_hdr used in PACKET_MMAP to hold link level's frame 288header called struct tpacket_hdr used in PACKET_MMAP to hold link level's frame
289meta information like timestamp. So what we draw here a frame it's really 289meta information like timestamp. So what we draw here a frame it's really
290the following (from include/linux/if_packet.h): 290the following (from include/linux/if_packet.h):
diff --git a/Documentation/networking/phy.txt b/Documentation/networking/phy.txt
index 29ccae409031..0bc95eab1512 100644
--- a/Documentation/networking/phy.txt
+++ b/Documentation/networking/phy.txt
@@ -1,7 +1,7 @@
1 1
2------- 2-------
3PHY Abstraction Layer 3PHY Abstraction Layer
4(Updated 2005-07-21) 4(Updated 2006-11-30)
5 5
6Purpose 6Purpose
7 7
@@ -97,11 +97,12 @@ Letting the PHY Abstraction Layer do Everything
97 97
98 Next, you need to know the device name of the PHY connected to this device. 98 Next, you need to know the device name of the PHY connected to this device.
99 The name will look something like, "phy0:0", where the first number is the 99 The name will look something like, "phy0:0", where the first number is the
100 bus id, and the second is the PHY's address on that bus. 100 bus id, and the second is the PHY's address on that bus. Typically,
101 the bus is responsible for making its ID unique.
101 102
102 Now, to connect, just call this function: 103 Now, to connect, just call this function:
103 104
104 phydev = phy_connect(dev, phy_name, &adjust_link, flags); 105 phydev = phy_connect(dev, phy_name, &adjust_link, flags, interface);
105 106
106 phydev is a pointer to the phy_device structure which represents the PHY. If 107 phydev is a pointer to the phy_device structure which represents the PHY. If
107 phy_connect is successful, it will return the pointer. dev, here, is the 108 phy_connect is successful, it will return the pointer. dev, here, is the
@@ -115,6 +116,10 @@ Letting the PHY Abstraction Layer do Everything
115 This is useful if the system has put hardware restrictions on 116 This is useful if the system has put hardware restrictions on
116 the PHY/controller, of which the PHY needs to be aware. 117 the PHY/controller, of which the PHY needs to be aware.
117 118
119 interface is a u32 which specifies the connection type used
120 between the controller and the PHY. Examples are GMII, MII,
121 RGMII, and SGMII. For a full list, see include/linux/phy.h
122
118 Now just make sure that phydev->supported and phydev->advertising have any 123 Now just make sure that phydev->supported and phydev->advertising have any
119 values pruned from them which don't make sense for your controller (a 10/100 124 values pruned from them which don't make sense for your controller (a 10/100
120 controller may be connected to a gigabit capable PHY, so you would need to 125 controller may be connected to a gigabit capable PHY, so you would need to
@@ -191,7 +196,7 @@ Doing it all yourself
191 start, or disables then frees them for stop. 196 start, or disables then frees them for stop.
192 197
193 struct phy_device * phy_attach(struct net_device *dev, const char *phy_id, 198 struct phy_device * phy_attach(struct net_device *dev, const char *phy_id,
194 u32 flags); 199 u32 flags, phy_interface_t interface);
195 200
196 Attaches a network device to a particular PHY, binding the PHY to a generic 201 Attaches a network device to a particular PHY, binding the PHY to a generic
197 driver if none was found during bus initialization. Passes in 202 driver if none was found during bus initialization. Passes in
diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt
index c8eee23be8c0..c6cf4a3c16e0 100644
--- a/Documentation/networking/pktgen.txt
+++ b/Documentation/networking/pktgen.txt
@@ -63,8 +63,8 @@ Current:
63Result: OK: 13101142(c12220741+d880401) usec, 10000000 (60byte,0frags) 63Result: OK: 13101142(c12220741+d880401) usec, 10000000 (60byte,0frags)
64 763292pps 390Mb/sec (390805504bps) errors: 39664 64 763292pps 390Mb/sec (390805504bps) errors: 39664
65 65
66Confguring threads and devices 66Configuring threads and devices
67============================== 67================================
68This is done via the /proc interface easiest done via pgset in the scripts 68This is done via the /proc interface easiest done via pgset in the scripts
69 69
70Examples: 70Examples:
@@ -116,7 +116,7 @@ Examples:
116 there must be no spaces between the 116 there must be no spaces between the
117 arguments. Leading zeros are required. 117 arguments. Leading zeros are required.
118 Do not set the bottom of stack bit, 118 Do not set the bottom of stack bit,
119 thats done automatically. If you do 119 that's done automatically. If you do
120 set the bottom of stack bit, that 120 set the bottom of stack bit, that
121 indicates that you want to randomly 121 indicates that you want to randomly
122 generate that address and the flag 122 generate that address and the flag
diff --git a/Documentation/networking/proc_net_tcp.txt b/Documentation/networking/proc_net_tcp.txt
index 59cb915c3713..5e21f7cb6383 100644
--- a/Documentation/networking/proc_net_tcp.txt
+++ b/Documentation/networking/proc_net_tcp.txt
@@ -25,7 +25,7 @@ up into 3 parts because of the length of the line):
25 25
26 1000 0 54165785 4 cd1e6040 25 4 27 3 -1 26 1000 0 54165785 4 cd1e6040 25 4 27 3 -1
27 | | | | | | | | | |--> slow start size threshold, 27 | | | | | | | | | |--> slow start size threshold,
28 | | | | | | | | | or -1 if the treshold 28 | | | | | | | | | or -1 if the threshold
29 | | | | | | | | | is >= 0xFFFF 29 | | | | | | | | | is >= 0xFFFF
30 | | | | | | | | |----> sending congestion window 30 | | | | | | | | |----> sending congestion window
31 | | | | | | | |-------> (ack.quick<<1)|ack.pingpong 31 | | | | | | | |-------> (ack.quick<<1)|ack.pingpong
diff --git a/Documentation/networking/sk98lin.txt b/Documentation/networking/sk98lin.txt
index 4e1cc745ec63..8590a954df1d 100644
--- a/Documentation/networking/sk98lin.txt
+++ b/Documentation/networking/sk98lin.txt
@@ -346,7 +346,7 @@ Possible modes:
346 depending on the load of the system. If the driver detects that the 346 depending on the load of the system. If the driver detects that the
347 system load is too high, the driver tries to shield the system against 347 system load is too high, the driver tries to shield the system against
348 too much network load by enabling interrupt moderation. If - at a later 348 too much network load by enabling interrupt moderation. If - at a later
349 time - the CPU utilizaton decreases again (or if the network load is 349 time - the CPU utilization decreases again (or if the network load is
350 negligible) the interrupt moderation will automatically be disabled. 350 negligible) the interrupt moderation will automatically be disabled.
351 351
352Interrupt moderation should be used when the driver has to handle one or more 352Interrupt moderation should be used when the driver has to handle one or more
diff --git a/Documentation/networking/slicecom.txt b/Documentation/networking/slicecom.txt
index 2f04c9267f89..32d3b916afad 100644
--- a/Documentation/networking/slicecom.txt
+++ b/Documentation/networking/slicecom.txt
@@ -126,7 +126,7 @@ comx0/boardnum - board number of the SliceCom in the PC (using the 'natural'
126 126
127Though the options below are to be set on a single interface, they apply to the 127Though the options below are to be set on a single interface, they apply to the
128whole board. The restriction, to use them on 'UP' interfaces, is because the 128whole board. The restriction, to use them on 'UP' interfaces, is because the
129command sequence below could lead to unpredicable results. 129command sequence below could lead to unpredictable results.
130 130
131 # echo 0 >boardnum 131 # echo 0 >boardnum
132 # echo internal >clock_source 132 # echo internal >clock_source
diff --git a/Documentation/networking/udplite.txt b/Documentation/networking/udplite.txt
new file mode 100644
index 000000000000..dd6f46b83dab
--- /dev/null
+++ b/Documentation/networking/udplite.txt
@@ -0,0 +1,281 @@
1 ===========================================================================
2 The UDP-Lite protocol (RFC 3828)
3 ===========================================================================
4
5
6 UDP-Lite is a Standards-Track IETF transport protocol whose characteristic
7 is a variable-length checksum. This has advantages for transport of multimedia
8 (video, VoIP) over wireless networks, as partly damaged packets can still be
9 fed into the codec instead of being discarded due to a failed checksum test.
10
11 This file briefly describes the existing kernel support and the socket API.
12 For in-depth information, you can consult:
13
14 o The UDP-Lite Homepage: http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/
15 Fom here you can also download some example application source code.
16
17 o The UDP-Lite HOWTO on
18 http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/files/UDP-Lite-HOWTO.txt
19
20 o The Wireshark UDP-Lite WiKi (with capture files):
21 http://wiki.wireshark.org/Lightweight_User_Datagram_Protocol
22
23 o The Protocol Spec, RFC 3828, http://www.ietf.org/rfc/rfc3828.txt
24
25
26 I) APPLICATIONS
27
28 Several applications have been ported successfully to UDP-Lite. Ethereal
29 (now called wireshark) has UDP-Litev4/v6 support by default. The tarball on
30
31 http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/files/udplite_linux.tar.gz
32
33 has source code for several v4/v6 client-server and network testing examples.
34
35 Porting applications to UDP-Lite is straightforward: only socket level and
36 IPPROTO need to be changed; senders additionally set the checksum coverage
37 length (default = header length = 8). Details are in the next section.
38
39
40 II) PROGRAMMING API
41
42 UDP-Lite provides a connectionless, unreliable datagram service and hence
43 uses the same socket type as UDP. In fact, porting from UDP to UDP-Lite is
44 very easy: simply add `IPPROTO_UDPLITE' as the last argument of the socket(2)
45 call so that the statement looks like:
46
47 s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDPLITE);
48
49 or, respectively,
50
51 s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDPLITE);
52
53 With just the above change you are able to run UDP-Lite services or connect
54 to UDP-Lite servers. The kernel will assume that you are not interested in
55 using partial checksum coverage and so emulate UDP mode (full coverage).
56
57 To make use of the partial checksum coverage facilities requires setting a
58 single socket option, which takes an integer specifying the coverage length:
59
60 * Sender checksum coverage: UDPLITE_SEND_CSCOV
61
62 For example,
63
64 int val = 20;
65 setsockopt(s, SOL_UDPLITE, UDPLITE_SEND_CSCOV, &val, sizeof(int));
66
67 sets the checksum coverage length to 20 bytes (12b data + 8b header).
68 Of each packet only the first 20 bytes (plus the pseudo-header) will be
69 checksummed. This is useful for RTP applications which have a 12-byte
70 base header.
71
72
73 * Receiver checksum coverage: UDPLITE_RECV_CSCOV
74
75 This option is the receiver-side analogue. It is truly optional, i.e. not
76 required to enable traffic with partial checksum coverage. Its function is
77 that of a traffic filter: when enabled, it instructs the kernel to drop
78 all packets which have a coverage _less_ than this value. For example, if
79 RTP and UDP headers are to be protected, a receiver can enforce that only
80 packets with a minimum coverage of 20 are admitted:
81
82 int min = 20;
83 setsockopt(s, SOL_UDPLITE, UDPLITE_RECV_CSCOV, &min, sizeof(int));
84
85 The calls to getsockopt(2) are analogous. Being an extension and not a stand-
86 alone protocol, all socket options known from UDP can be used in exactly the
87 same manner as before, e.g. UDP_CORK or UDP_ENCAP.
88
89 A detailed discussion of UDP-Lite checksum coverage options is in section IV.
90
91
92 III) HEADER FILES
93
94 The socket API requires support through header files in /usr/include:
95
96 * /usr/include/netinet/in.h
97 to define IPPROTO_UDPLITE
98
99 * /usr/include/netinet/udplite.h
100 for UDP-Lite header fields and protocol constants
101
102 For testing purposes, the following can serve as a `mini' header file:
103
104 #define IPPROTO_UDPLITE 136
105 #define SOL_UDPLITE 136
106 #define UDPLITE_SEND_CSCOV 10
107 #define UDPLITE_RECV_CSCOV 11
108
109 Ready-made header files for various distros are in the UDP-Lite tarball.
110
111
112 IV) KERNEL BEHAVIOUR WITH REGARD TO THE VARIOUS SOCKET OPTIONS
113
114 To enable debugging messages, the log level need to be set to 8, as most
115 messages use the KERN_DEBUG level (7).
116
117 1) Sender Socket Options
118
119 If the sender specifies a value of 0 as coverage length, the module
120 assumes full coverage, transmits a packet with coverage length of 0
121 and according checksum. If the sender specifies a coverage < 8 and
122 different from 0, the kernel assumes 8 as default value. Finally,
123 if the specified coverage length exceeds the packet length, the packet
124 length is used instead as coverage length.
125
126 2) Receiver Socket Options
127
128 The receiver specifies the minimum value of the coverage length it
129 is willing to accept. A value of 0 here indicates that the receiver
130 always wants the whole of the packet covered. In this case, all
131 partially covered packets are dropped and an error is logged.
132
133 It is not possible to specify illegal values (<0 and <8); in these
134 cases the default of 8 is assumed.
135
136 All packets arriving with a coverage value less than the specified
137 threshold are discarded, these events are also logged.
138
139 3) Disabling the Checksum Computation
140
141 On both sender and receiver, checksumming will always be performed
142 and can not be disabled using SO_NO_CHECK. Thus
143
144 setsockopt(sockfd, SOL_SOCKET, SO_NO_CHECK, ... );
145
146 will always will be ignored, while the value of
147
148 getsockopt(sockfd, SOL_SOCKET, SO_NO_CHECK, &value, ...);
149
150 is meaningless (as in TCP). Packets with a zero checksum field are
151 illegal (cf. RFC 3828, sec. 3.1) will be silently discarded.
152
153 4) Fragmentation
154
155 The checksum computation respects both buffersize and MTU. The size
156 of UDP-Lite packets is determined by the size of the send buffer. The
157 minimum size of the send buffer is 2048 (defined as SOCK_MIN_SNDBUF
158 in include/net/sock.h), the default value is configurable as
159 net.core.wmem_default or via setting the SO_SNDBUF socket(7)
160 option. The maximum upper bound for the send buffer is determined
161 by net.core.wmem_max.
162
163 Given a payload size larger than the send buffer size, UDP-Lite will
164 split the payload into several individual packets, filling up the
165 send buffer size in each case.
166
167 The precise value also depends on the interface MTU. The interface MTU,
168 in turn, may trigger IP fragmentation. In this case, the generated
169 UDP-Lite packet is split into several IP packets, of which only the
170 first one contains the L4 header.
171
172 The send buffer size has implications on the checksum coverage length.
173 Consider the following example:
174
175 Payload: 1536 bytes Send Buffer: 1024 bytes
176 MTU: 1500 bytes Coverage Length: 856 bytes
177
178 UDP-Lite will ship the 1536 bytes in two separate packets:
179
180 Packet 1: 1024 payload + 8 byte header + 20 byte IP header = 1052 bytes
181 Packet 2: 512 payload + 8 byte header + 20 byte IP header = 540 bytes
182
183 The coverage packet covers the UDP-Lite header and 848 bytes of the
184 payload in the first packet, the second packet is fully covered. Note
185 that for the second packet, the coverage length exceeds the packet
186 length. The kernel always re-adjusts the coverage length to the packet
187 length in such cases.
188
189 As an example of what happens when one UDP-Lite packet is split into
190 several tiny fragments, consider the following example.
191
192 Payload: 1024 bytes Send buffer size: 1024 bytes
193 MTU: 300 bytes Coverage length: 575 bytes
194
195 +-+-----------+--------------+--------------+--------------+
196 |8| 272 | 280 | 280 | 280 |
197 +-+-----------+--------------+--------------+--------------+
198 280 560 840 1032
199 ^
200 *****checksum coverage*************
201
202 The UDP-Lite module generates one 1032 byte packet (1024 + 8 byte
203 header). According to the interface MTU, these are split into 4 IP
204 packets (280 byte IP payload + 20 byte IP header). The kernel module
205 sums the contents of the entire first two packets, plus 15 bytes of
206 the last packet before releasing the fragments to the IP module.
207
208 To see the analogous case for IPv6 fragmentation, consider a link
209 MTU of 1280 bytes and a write buffer of 3356 bytes. If the checksum
210 coverage is less than 1232 bytes (MTU minus IPv6/fragment header
211 lengths), only the first fragment needs to be considered. When using
212 larger checksum coverage lengths, each eligible fragment needs to be
213 checksummed. Suppose we have a checksum coverage of 3062. The buffer
214 of 3356 bytes will be split into the following fragments:
215
216 Fragment 1: 1280 bytes carrying 1232 bytes of UDP-Lite data
217 Fragment 2: 1280 bytes carrying 1232 bytes of UDP-Lite data
218 Fragment 3: 948 bytes carrying 900 bytes of UDP-Lite data
219
220 The first two fragments have to be checksummed in full, of the last
221 fragment only 598 (= 3062 - 2*1232) bytes are checksummed.
222
223 While it is important that such cases are dealt with correctly, they
224 are (annoyingly) rare: UDP-Lite is designed for optimising multimedia
225 performance over wireless (or generally noisy) links and thus smaller
226 coverage lenghts are likely to be expected.
227
228
229 V) UDP-LITE RUNTIME STATISTICS AND THEIR MEANING
230
231 Exceptional and error conditions are logged to syslog at the KERN_DEBUG
232 level. Live statistics about UDP-Lite are available in /proc/net/snmp
233 and can (with newer versions of netstat) be viewed using
234
235 netstat -svu
236
237 This displays UDP-Lite statistics variables, whose meaning is as follows.
238
239 InDatagrams: Total number of received datagrams.
240
241 NoPorts: Number of packets received to an unknown port.
242 These cases are counted separately (not as InErrors).
243
244 InErrors: Number of erroneous UDP-Lite packets. Errors include:
245 * internal socket queue receive errors
246 * packet too short (less than 8 bytes or stated
247 coverage length exceeds received length)
248 * xfrm4_policy_check() returned with error
249 * application has specified larger min. coverage
250 length than that of incoming packet
251 * checksum coverage violated
252 * bad checksum
253
254 OutDatagrams: Total number of sent datagrams.
255
256 These statistics derive from the UDP MIB (RFC 2013).
257
258
259 VI) IPTABLES
260
261 There is packet match support for UDP-Lite as well as support for the LOG target.
262 If you copy and paste the following line into /etc/protcols,
263
264 udplite 136 UDP-Lite # UDP-Lite [RFC 3828]
265
266 then
267 iptables -A INPUT -p udplite -j LOG
268
269 will produce logging output to syslog. Dropping and rejecting packets also works.
270
271
272 VII) MAINTAINER ADDRESS
273
274 The UDP-Lite patch was developed at
275 University of Aberdeen
276 Electronics Research Group
277 Department of Engineering
278 Fraser Noble Building
279 Aberdeen AB24 3UE; UK
280 The current maintainer is Gerrit Renker, <gerrit@erg.abdn.ac.uk>. Initial
281 code was developed by William Stanislaus, <william@erg.abdn.ac.uk>.
diff --git a/Documentation/networking/wan-router.txt b/Documentation/networking/wan-router.txt
index 0cf654147634..653978dcea7f 100644
--- a/Documentation/networking/wan-router.txt
+++ b/Documentation/networking/wan-router.txt
@@ -412,7 +412,7 @@ beta-2.1.4 Jul 2000 o Dynamic interface configuration:
412 412
413beta3-2.1.4 Jul 2000 o X25 M_BIT Problem fix. 413beta3-2.1.4 Jul 2000 o X25 M_BIT Problem fix.
414 o Added the Multi-Port PPP 414 o Added the Multi-Port PPP
415 Updated utilites for the Multi-Port PPP. 415 Updated utilities for the Multi-Port PPP.
416 416
4172.1.4 Aut 2000 4172.1.4 Aut 2000
418 o In X25API: 418 o In X25API:
@@ -444,13 +444,13 @@ beta1-2.1.5 Nov 15 2000
444 444
445 o Cpipemon 445 o Cpipemon
446 - Added set FT1 commands to the cpipemon. Thus CSU/DSU 446 - Added set FT1 commands to the cpipemon. Thus CSU/DSU
447 configuraiton can be performed using cpipemon. 447 configuration can be performed using cpipemon.
448 All systems that cannot run cfgft1 GUI utility should 448 All systems that cannot run cfgft1 GUI utility should
449 use cpipemon to configure the on board CSU/DSU. 449 use cpipemon to configure the on board CSU/DSU.
450 450
451 451
452 o Keyboard Led Monitor/Debugger 452 o Keyboard Led Monitor/Debugger
453 - A new utilty /usr/sbin/wpkbdmon uses keyboard leds 453 - A new utility /usr/sbin/wpkbdmon uses keyboard leds
454 to convey operational statistic information of the 454 to convey operational statistic information of the
455 Sangoma WANPIPE cards. 455 Sangoma WANPIPE cards.
456 NUM_LOCK = Line State (On=connected, Off=disconnected) 456 NUM_LOCK = Line State (On=connected, Off=disconnected)
@@ -464,7 +464,7 @@ beta1-2.1.5 Nov 15 2000
464 - Appropriate number of devices are dynamically loaded 464 - Appropriate number of devices are dynamically loaded
465 based on the number of Sangoma cards found. 465 based on the number of Sangoma cards found.
466 466
467 Note: The kernel configuraiton option 467 Note: The kernel configuration option
468 CONFIG_WANPIPE_CARDS has been taken out. 468 CONFIG_WANPIPE_CARDS has been taken out.
469 469
470 o Fixed the Frame Relay and Chdlc network interfaces so they are 470 o Fixed the Frame Relay and Chdlc network interfaces so they are
diff --git a/Documentation/networking/xfrm_sync.txt b/Documentation/networking/xfrm_sync.txt
index 8be626f7c0b8..d7aac9dedeb4 100644
--- a/Documentation/networking/xfrm_sync.txt
+++ b/Documentation/networking/xfrm_sync.txt
@@ -47,10 +47,13 @@ aevent_id structure looks like:
47 47
48 struct xfrm_aevent_id { 48 struct xfrm_aevent_id {
49 struct xfrm_usersa_id sa_id; 49 struct xfrm_usersa_id sa_id;
50 xfrm_address_t saddr;
50 __u32 flags; 51 __u32 flags;
52 __u32 reqid;
51 }; 53 };
52 54
53xfrm_usersa_id in this message layout identifies the SA. 55The unique SA is identified by the combination of xfrm_usersa_id,
56reqid and saddr.
54 57
55flags are used to indicate different things. The possible 58flags are used to indicate different things. The possible
56flags are: 59flags are:
diff --git a/Documentation/pnp.txt b/Documentation/pnp.txt
index 9ff966bf76e6..28037aa1846c 100644
--- a/Documentation/pnp.txt
+++ b/Documentation/pnp.txt
@@ -184,7 +184,7 @@ static const struct pnp_id pnp_dev_table[] = {
184Please note that the character 'X' can be used as a wild card in the function 184Please note that the character 'X' can be used as a wild card in the function
185portion (last four characters). 185portion (last four characters).
186ex: 186ex:
187 /* Unkown PnP modems */ 187 /* Unknown PnP modems */
188 { "PNPCXXX", UNKNOWN_DEV }, 188 { "PNPCXXX", UNKNOWN_DEV },
189 189
190Supported PnP card IDs can optionally be defined. 190Supported PnP card IDs can optionally be defined.
diff --git a/Documentation/power/pci.txt b/Documentation/power/pci.txt
index 24edf25b3bb7..c750f9f2e76e 100644
--- a/Documentation/power/pci.txt
+++ b/Documentation/power/pci.txt
@@ -153,7 +153,7 @@ Description:
153 events, which is implicit if it doesn't even support it in the first 153 events, which is implicit if it doesn't even support it in the first
154 place). 154 place).
155 155
156 Note that the PMC Register in the device's PM Capabilties has a bitmask 156 Note that the PMC Register in the device's PM Capabilities has a bitmask
157 of the states it supports generating PME# from. D3hot is bit 3 and 157 of the states it supports generating PME# from. D3hot is bit 3 and
158 D3cold is bit 4. So, while a value of 4 as the state may not seem 158 D3cold is bit 4. So, while a value of 4 as the state may not seem
159 semantically correct, it is. 159 semantically correct, it is.
@@ -268,7 +268,7 @@ to wake the system up. (However, it is possible that a device may support
268some non-standard way of generating a wake event on sleep.) 268some non-standard way of generating a wake event on sleep.)
269 269
270Bits 15:11 of the PMC (Power Mgmt Capabilities) Register in a device's 270Bits 15:11 of the PMC (Power Mgmt Capabilities) Register in a device's
271PM Capabilties describe what power states the device supports generating a 271PM Capabilities describe what power states the device supports generating a
272wake event from: 272wake event from:
273 273
274+------------------+ 274+------------------+
diff --git a/Documentation/power/states.txt b/Documentation/power/states.txt
index 3e5e5d3ff419..0931a330d362 100644
--- a/Documentation/power/states.txt
+++ b/Documentation/power/states.txt
@@ -62,7 +62,7 @@ setup via another operating system for it to use. Despite the
62inconvenience, this method requires minimal work by the kernel, since 62inconvenience, this method requires minimal work by the kernel, since
63the firmware will also handle restoring memory contents on resume. 63the firmware will also handle restoring memory contents on resume.
64 64
65If the kernel is responsible for persistantly saving state, a mechanism 65If the kernel is responsible for persistently saving state, a mechanism
66called 'swsusp' (Swap Suspend) is used to write memory contents to 66called 'swsusp' (Swap Suspend) is used to write memory contents to
67free swap space. swsusp has some restrictive requirements, but should 67free swap space. swsusp has some restrictive requirements, but should
68work in most cases. Some, albeit outdated, documentation can be found 68work in most cases. Some, albeit outdated, documentation can be found
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
index 9ea2208b43b5..e635e6f1e316 100644
--- a/Documentation/power/swsusp.txt
+++ b/Documentation/power/swsusp.txt
@@ -153,7 +153,7 @@ add:
153 153
154If the thread is needed for writing the image to storage, you should 154If the thread is needed for writing the image to storage, you should
155instead set the PF_NOFREEZE process flag when creating the thread (and 155instead set the PF_NOFREEZE process flag when creating the thread (and
156be very carefull). 156be very careful).
157 157
158 158
159Q: What is the difference between "platform", "shutdown" and 159Q: What is the difference between "platform", "shutdown" and
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index 27b457c09729..4ac2d641fcb6 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -33,13 +33,13 @@
33 - Change version 16 format to always align 33 - Change version 16 format to always align
34 property data to 4 bytes. Since tokens are 34 property data to 4 bytes. Since tokens are
35 already aligned, that means no specific 35 already aligned, that means no specific
36 required alignement between property size 36 required alignment between property size
37 and property data. The old style variable 37 and property data. The old style variable
38 alignment would make it impossible to do 38 alignment would make it impossible to do
39 "simple" insertion of properties using 39 "simple" insertion of properties using
40 memove (thanks Milton for 40 memove (thanks Milton for
41 noticing). Updated kernel patch as well 41 noticing). Updated kernel patch as well
42 - Correct a few more alignement constraints 42 - Correct a few more alignment constraints
43 - Add a chapter about the device-tree 43 - Add a chapter about the device-tree
44 compiler and the textural representation of 44 compiler and the textural representation of
45 the tree that can be "compiled" by dtc. 45 the tree that can be "compiled" by dtc.
@@ -854,7 +854,7 @@ address which can extend beyond that limit.
854 console device if any. Typically, if you have serial devices on 854 console device if any. Typically, if you have serial devices on
855 your board, you may want to put the full path to the one set as 855 your board, you may want to put the full path to the one set as
856 the default console in the firmware here, for the kernel to pick 856 the default console in the firmware here, for the kernel to pick
857 it up as it's own default console. If you look at the funciton 857 it up as its own default console. If you look at the function
858 set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see 858 set_preferred_console() in arch/ppc64/kernel/setup.c, you'll see
859 that the kernel tries to find out the default console and has 859 that the kernel tries to find out the default console and has
860 knowledge of various types like 8250 serial ports. You may want 860 knowledge of various types like 8250 serial ports. You may want
@@ -1124,7 +1124,7 @@ should have the following properties:
1124 - interrupt-parent : contains the phandle of the interrupt 1124 - interrupt-parent : contains the phandle of the interrupt
1125 controller which handles interrupts for this device 1125 controller which handles interrupts for this device
1126 - interrupts : a list of tuples representing the interrupt 1126 - interrupts : a list of tuples representing the interrupt
1127 number and the interrupt sense and level for each interupt 1127 number and the interrupt sense and level for each interrupt
1128 for this device. 1128 for this device.
1129 1129
1130This information is used by the kernel to build the interrupt table 1130This information is used by the kernel to build the interrupt table
diff --git a/Documentation/robust-futex-ABI.txt b/Documentation/robust-futex-ABI.txt
index 8529a17ffaa1..535f69fab45f 100644
--- a/Documentation/robust-futex-ABI.txt
+++ b/Documentation/robust-futex-ABI.txt
@@ -170,7 +170,7 @@ any point:
170 1) the 'head' pointer or an subsequent linked list pointer 170 1) the 'head' pointer or an subsequent linked list pointer
171 is not a valid address of a user space word 171 is not a valid address of a user space word
172 2) the calculated location of the 'lock word' (address plus 172 2) the calculated location of the 'lock word' (address plus
173 'offset') is not the valud address of a 32 bit user space 173 'offset') is not the valid address of a 32 bit user space
174 word 174 word
175 3) if the list contains more than 1 million (subject to 175 3) if the list contains more than 1 million (subject to
176 future kernel configuration changes) elements. 176 future kernel configuration changes) elements.
diff --git a/Documentation/robust-futexes.txt b/Documentation/robust-futexes.txt
index 76e8064b8c3a..0a9446a53bd1 100644
--- a/Documentation/robust-futexes.txt
+++ b/Documentation/robust-futexes.txt
@@ -181,7 +181,7 @@ for new threads, without the need of another syscall.]
181So there is virtually zero overhead for tasks not using robust futexes, 181So there is virtually zero overhead for tasks not using robust futexes,
182and even for robust futex users, there is only one extra syscall per 182and even for robust futex users, there is only one extra syscall per
183thread lifetime, and the cleanup operation, if it happens, is fast and 183thread lifetime, and the cleanup operation, if it happens, is fast and
184straightforward. The kernel doesnt have any internal distinction between 184straightforward. The kernel doesn't have any internal distinction between
185robust and normal futexes. 185robust and normal futexes.
186 186
187If a futex is found to be held at exit time, the kernel sets the 187If a futex is found to be held at exit time, the kernel sets the
diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt
index 2a58f985795a..7cf1ec5bcdd3 100644
--- a/Documentation/rtc.txt
+++ b/Documentation/rtc.txt
@@ -1,12 +1,49 @@
1 1
2 Real Time Clock Driver for Linux 2 Real Time Clock (RTC) Drivers for Linux
3 ================================ 3 =======================================
4
5When Linux developers talk about a "Real Time Clock", they usually mean
6something that tracks wall clock time and is battery backed so that it
7works even with system power off. Such clocks will normally not track
8the local time zone or daylight savings time -- unless they dual boot
9with MS-Windows -- but will instead be set to Coordinated Universal Time
10(UTC, formerly "Greenwich Mean Time").
11
12The newest non-PC hardware tends to just count seconds, like the time(2)
13system call reports, but RTCs also very commonly represent time using
14the Gregorian calendar and 24 hour time, as reported by gmtime(3).
15
16Linux has two largely-compatible userspace RTC API families you may
17need to know about:
18
19 * /dev/rtc ... is the RTC provided by PC compatible systems,
20 so it's not very portable to non-x86 systems.
21
22 * /dev/rtc0, /dev/rtc1 ... are part of a framework that's
23 supported by a wide variety of RTC chips on all systems.
24
25Programmers need to understand that the PC/AT functionality is not
26always available, and some systems can do much more. That is, the
27RTCs use the same API to make requests in both RTC frameworks (using
28different filenames of course), but the hardware may not offer the
29same functionality. For example, not every RTC is hooked up to an
30IRQ, so they can't all issue alarms; and where standard PC RTCs can
31only issue an alarm up to 24 hours in the future, other hardware may
32be able to schedule one any time in the upcoming century.
33
34
35 Old PC/AT-Compatible driver: /dev/rtc
36 --------------------------------------
4 37
5All PCs (even Alpha machines) have a Real Time Clock built into them. 38All PCs (even Alpha machines) have a Real Time Clock built into them.
6Usually they are built into the chipset of the computer, but some may 39Usually they are built into the chipset of the computer, but some may
7actually have a Motorola MC146818 (or clone) on the board. This is the 40actually have a Motorola MC146818 (or clone) on the board. This is the
8clock that keeps the date and time while your computer is turned off. 41clock that keeps the date and time while your computer is turned off.
9 42
43ACPI has standardized that MC146818 functionality, and extended it in
44a few ways (enabling longer alarm periods, and wake-from-hibernate).
45That functionality is NOT exposed in the old driver.
46
10However it can also be used to generate signals from a slow 2Hz to a 47However it can also be used to generate signals from a slow 2Hz to a
11relatively fast 8192Hz, in increments of powers of two. These signals 48relatively fast 8192Hz, in increments of powers of two. These signals
12are reported by interrupt number 8. (Oh! So *that* is what IRQ 8 is 49are reported by interrupt number 8. (Oh! So *that* is what IRQ 8 is
@@ -63,223 +100,331 @@ Rather than write 50 pages describing the ioctl() and so on, it is
63perhaps more useful to include a small test program that demonstrates 100perhaps more useful to include a small test program that demonstrates
64how to use them, and demonstrates the features of the driver. This is 101how to use them, and demonstrates the features of the driver. This is
65probably a lot more useful to people interested in writing applications 102probably a lot more useful to people interested in writing applications
66that will be using this driver. 103that will be using this driver. See the code at the end of this document.
104
105(The original /dev/rtc driver was written by Paul Gortmaker.)
106
107
108 New portable "RTC Class" drivers: /dev/rtcN
109 --------------------------------------------
110
111Because Linux supports many non-ACPI and non-PC platforms, some of which
112have more than one RTC style clock, it needed a more portable solution
113than expecting a single battery-backed MC146818 clone on every system.
114Accordingly, a new "RTC Class" framework has been defined. It offers
115three different userspace interfaces:
116
117 * /dev/rtcN ... much the same as the older /dev/rtc interface
118
119 * /sys/class/rtc/rtcN ... sysfs attributes support readonly
120 access to some RTC attributes.
121
122 * /proc/driver/rtc ... the first RTC (rtc0) may expose itself
123 using a procfs interface. More information is (currently) shown
124 here than through sysfs.
125
126The RTC Class framework supports a wide variety of RTCs, ranging from those
127integrated into embeddable system-on-chip (SOC) processors to discrete chips
128using I2C, SPI, or some other bus to communicate with the host CPU. There's
129even support for PC-style RTCs ... including the features exposed on newer PCs
130through ACPI.
131
132The new framework also removes the "one RTC per system" restriction. For
133example, maybe the low-power battery-backed RTC is a discrete I2C chip, but
134a high functionality RTC is integrated into the SOC. That system might read
135the system clock from the discrete RTC, but use the integrated one for all
136other tasks, because of its greater functionality.
137
138The ioctl() calls supported by /dev/rtc are also supported by the RTC class
139framework. However, because the chips and systems are not standardized,
140some PC/AT functionality might not be provided. And in the same way, some
141newer features -- including those enabled by ACPI -- are exposed by the
142RTC class framework, but can't be supported by the older driver.
143
144 * RTC_RD_TIME, RTC_SET_TIME ... every RTC supports at least reading
145 time, returning the result as a Gregorian calendar date and 24 hour
146 wall clock time. To be most useful, this time may also be updated.
147
148 * RTC_AIE_ON, RTC_AIE_OFF, RTC_ALM_SET, RTC_ALM_READ ... when the RTC
149 is connected to an IRQ line, it can often issue an alarm IRQ up to
150 24 hours in the future.
151
152 * RTC_WKALM_SET, RTC_WKALM_READ ... RTCs that can issue alarms beyond
153 the next 24 hours use a slightly more powerful API, which supports
154 setting the longer alarm time and enabling its IRQ using a single
155 request (using the same model as EFI firmware).
156
157 * RTC_UIE_ON, RTC_UIE_OFF ... if the RTC offers IRQs, it probably
158 also offers update IRQs whenever the "seconds" counter changes.
159 If needed, the RTC framework can emulate this mechanism.
160
161 * RTC_PIE_ON, RTC_PIE_OFF, RTC_IRQP_SET, RTC_IRQP_READ ... another
162 feature often accessible with an IRQ line is a periodic IRQ, issued
163 at settable frequencies (usually 2^N Hz).
164
165In many cases, the RTC alarm can be a system wake event, used to force
166Linux out of a low power sleep state (or hibernation) back to a fully
167operational state. For example, a system could enter a deep power saving
168state until it's time to execute some scheduled tasks.
67 169
68 Paul Gortmaker
69 170
70-------------------- 8< ---------------- 8< ----------------------------- 171-------------------- 8< ---------------- 8< -----------------------------
71 172
72/* 173/*
73 * Real Time Clock Driver Test/Example Program 174 * Real Time Clock Driver Test/Example Program
74 * 175 *
75 * Compile with: 176 * Compile with:
76 * gcc -s -Wall -Wstrict-prototypes rtctest.c -o rtctest 177 * gcc -s -Wall -Wstrict-prototypes rtctest.c -o rtctest
77 * 178 *
78 * Copyright (C) 1996, Paul Gortmaker. 179 * Copyright (C) 1996, Paul Gortmaker.
79 * 180 *
80 * Released under the GNU General Public License, version 2, 181 * Released under the GNU General Public License, version 2,
81 * included herein by reference. 182 * included herein by reference.
82 * 183 *
83 */ 184 */
84 185
85#include <stdio.h> 186#include <stdio.h>
86#include <stdlib.h>
87#include <linux/rtc.h> 187#include <linux/rtc.h>
88#include <sys/ioctl.h> 188#include <sys/ioctl.h>
89#include <sys/time.h> 189#include <sys/time.h>
90#include <sys/types.h> 190#include <sys/types.h>
91#include <fcntl.h> 191#include <fcntl.h>
92#include <unistd.h> 192#include <unistd.h>
193#include <stdlib.h>
93#include <errno.h> 194#include <errno.h>
94 195
95int main(void) {
96
97int i, fd, retval, irqcount = 0;
98unsigned long tmp, data;
99struct rtc_time rtc_tm;
100 196
101fd = open ("/dev/rtc", O_RDONLY); 197/*
198 * This expects the new RTC class driver framework, working with
199 * clocks that will often not be clones of what the PC-AT had.
200 * Use the command line to specify another RTC if you need one.
201 */
202static const char default_rtc[] = "/dev/rtc0";
203
204
205int main(int argc, char **argv)
206{
207 int i, fd, retval, irqcount = 0;
208 unsigned long tmp, data;
209 struct rtc_time rtc_tm;
210 const char *rtc = default_rtc;
211
212 switch (argc) {
213 case 2:
214 rtc = argv[1];
215 /* FALLTHROUGH */
216 case 1:
217 break;
218 default:
219 fprintf(stderr, "usage: rtctest [rtcdev]\n");
220 return 1;
221 }
102 222
103if (fd == -1) { 223 fd = open(rtc, O_RDONLY);
104 perror("/dev/rtc");
105 exit(errno);
106}
107 224
108fprintf(stderr, "\n\t\t\tRTC Driver Test Example.\n\n"); 225 if (fd == -1) {
226 perror(rtc);
227 exit(errno);
228 }
109 229
110/* Turn on update interrupts (one per second) */ 230 fprintf(stderr, "\n\t\t\tRTC Driver Test Example.\n\n");
111retval = ioctl(fd, RTC_UIE_ON, 0);
112if (retval == -1) {
113 perror("ioctl");
114 exit(errno);
115}
116 231
117fprintf(stderr, "Counting 5 update (1/sec) interrupts from reading /dev/rtc:"); 232 /* Turn on update interrupts (one per second) */
118fflush(stderr); 233 retval = ioctl(fd, RTC_UIE_ON, 0);
119for (i=1; i<6; i++) {
120 /* This read will block */
121 retval = read(fd, &data, sizeof(unsigned long));
122 if (retval == -1) { 234 if (retval == -1) {
123 perror("read"); 235 if (errno == ENOTTY) {
236 fprintf(stderr,
237 "\n...Update IRQs not supported.\n");
238 goto test_READ;
239 }
240 perror("ioctl");
124 exit(errno); 241 exit(errno);
125 } 242 }
126 fprintf(stderr, " %d",i); 243
244 fprintf(stderr, "Counting 5 update (1/sec) interrupts from reading %s:",
245 rtc);
127 fflush(stderr); 246 fflush(stderr);
128 irqcount++; 247 for (i=1; i<6; i++) {
129} 248 /* This read will block */
249 retval = read(fd, &data, sizeof(unsigned long));
250 if (retval == -1) {
251 perror("read");
252 exit(errno);
253 }
254 fprintf(stderr, " %d",i);
255 fflush(stderr);
256 irqcount++;
257 }
130 258
131fprintf(stderr, "\nAgain, from using select(2) on /dev/rtc:"); 259 fprintf(stderr, "\nAgain, from using select(2) on /dev/rtc:");
132fflush(stderr); 260 fflush(stderr);
133for (i=1; i<6; i++) { 261 for (i=1; i<6; i++) {
134 struct timeval tv = {5, 0}; /* 5 second timeout on select */ 262 struct timeval tv = {5, 0}; /* 5 second timeout on select */
135 fd_set readfds; 263 fd_set readfds;
264
265 FD_ZERO(&readfds);
266 FD_SET(fd, &readfds);
267 /* The select will wait until an RTC interrupt happens. */
268 retval = select(fd+1, &readfds, NULL, NULL, &tv);
269 if (retval == -1) {
270 perror("select");
271 exit(errno);
272 }
273 /* This read won't block unlike the select-less case above. */
274 retval = read(fd, &data, sizeof(unsigned long));
275 if (retval == -1) {
276 perror("read");
277 exit(errno);
278 }
279 fprintf(stderr, " %d",i);
280 fflush(stderr);
281 irqcount++;
282 }
136 283
137 FD_ZERO(&readfds); 284 /* Turn off update interrupts */
138 FD_SET(fd, &readfds); 285 retval = ioctl(fd, RTC_UIE_OFF, 0);
139 /* The select will wait until an RTC interrupt happens. */
140 retval = select(fd+1, &readfds, NULL, NULL, &tv);
141 if (retval == -1) { 286 if (retval == -1) {
142 perror("select"); 287 perror("ioctl");
143 exit(errno); 288 exit(errno);
144 } 289 }
145 /* This read won't block unlike the select-less case above. */ 290
146 retval = read(fd, &data, sizeof(unsigned long)); 291test_READ:
292 /* Read the RTC time/date */
293 retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
147 if (retval == -1) { 294 if (retval == -1) {
148 perror("read"); 295 perror("ioctl");
149 exit(errno); 296 exit(errno);
150 } 297 }
151 fprintf(stderr, " %d",i);
152 fflush(stderr);
153 irqcount++;
154}
155
156/* Turn off update interrupts */
157retval = ioctl(fd, RTC_UIE_OFF, 0);
158if (retval == -1) {
159 perror("ioctl");
160 exit(errno);
161}
162
163/* Read the RTC time/date */
164retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
165if (retval == -1) {
166 perror("ioctl");
167 exit(errno);
168}
169
170fprintf(stderr, "\n\nCurrent RTC date/time is %d-%d-%d, %02d:%02d:%02d.\n",
171 rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900,
172 rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
173
174/* Set the alarm to 5 sec in the future, and check for rollover */
175rtc_tm.tm_sec += 5;
176if (rtc_tm.tm_sec >= 60) {
177 rtc_tm.tm_sec %= 60;
178 rtc_tm.tm_min++;
179}
180if (rtc_tm.tm_min == 60) {
181 rtc_tm.tm_min = 0;
182 rtc_tm.tm_hour++;
183}
184if (rtc_tm.tm_hour == 24)
185 rtc_tm.tm_hour = 0;
186
187retval = ioctl(fd, RTC_ALM_SET, &rtc_tm);
188if (retval == -1) {
189 perror("ioctl");
190 exit(errno);
191}
192
193/* Read the current alarm settings */
194retval = ioctl(fd, RTC_ALM_READ, &rtc_tm);
195if (retval == -1) {
196 perror("ioctl");
197 exit(errno);
198}
199
200fprintf(stderr, "Alarm time now set to %02d:%02d:%02d.\n",
201 rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
202 298
203/* Enable alarm interrupts */ 299 fprintf(stderr, "\n\nCurrent RTC date/time is %d-%d-%d, %02d:%02d:%02d.\n",
204retval = ioctl(fd, RTC_AIE_ON, 0); 300 rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900,
205if (retval == -1) { 301 rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
206 perror("ioctl");
207 exit(errno);
208}
209 302
210fprintf(stderr, "Waiting 5 seconds for alarm..."); 303 /* Set the alarm to 5 sec in the future, and check for rollover */
211fflush(stderr); 304 rtc_tm.tm_sec += 5;
212/* This blocks until the alarm ring causes an interrupt */ 305 if (rtc_tm.tm_sec >= 60) {
213retval = read(fd, &data, sizeof(unsigned long)); 306 rtc_tm.tm_sec %= 60;
214if (retval == -1) { 307 rtc_tm.tm_min++;
215 perror("read"); 308 }
216 exit(errno); 309 if (rtc_tm.tm_min == 60) {
217} 310 rtc_tm.tm_min = 0;
218irqcount++; 311 rtc_tm.tm_hour++;
219fprintf(stderr, " okay. Alarm rang.\n"); 312 }
220 313 if (rtc_tm.tm_hour == 24)
221/* Disable alarm interrupts */ 314 rtc_tm.tm_hour = 0;
222retval = ioctl(fd, RTC_AIE_OFF, 0);
223if (retval == -1) {
224 perror("ioctl");
225 exit(errno);
226}
227 315
228/* Read periodic IRQ rate */ 316 retval = ioctl(fd, RTC_ALM_SET, &rtc_tm);
229retval = ioctl(fd, RTC_IRQP_READ, &tmp); 317 if (retval == -1) {
230if (retval == -1) { 318 if (errno == ENOTTY) {
231 perror("ioctl"); 319 fprintf(stderr,
232 exit(errno); 320 "\n...Alarm IRQs not supported.\n");
233} 321 goto test_PIE;
234fprintf(stderr, "\nPeriodic IRQ rate was %ldHz.\n", tmp); 322 }
323 perror("ioctl");
324 exit(errno);
325 }
235 326
236fprintf(stderr, "Counting 20 interrupts at:"); 327 /* Read the current alarm settings */
237fflush(stderr); 328 retval = ioctl(fd, RTC_ALM_READ, &rtc_tm);
329 if (retval == -1) {
330 perror("ioctl");
331 exit(errno);
332 }
238 333
239/* The frequencies 128Hz, 256Hz, ... 8192Hz are only allowed for root. */ 334 fprintf(stderr, "Alarm time now set to %02d:%02d:%02d.\n",
240for (tmp=2; tmp<=64; tmp*=2) { 335 rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
241 336
242 retval = ioctl(fd, RTC_IRQP_SET, tmp); 337 /* Enable alarm interrupts */
338 retval = ioctl(fd, RTC_AIE_ON, 0);
243 if (retval == -1) { 339 if (retval == -1) {
244 perror("ioctl"); 340 perror("ioctl");
245 exit(errno); 341 exit(errno);
246 } 342 }
247 343
248 fprintf(stderr, "\n%ldHz:\t", tmp); 344 fprintf(stderr, "Waiting 5 seconds for alarm...");
249 fflush(stderr); 345 fflush(stderr);
346 /* This blocks until the alarm ring causes an interrupt */
347 retval = read(fd, &data, sizeof(unsigned long));
348 if (retval == -1) {
349 perror("read");
350 exit(errno);
351 }
352 irqcount++;
353 fprintf(stderr, " okay. Alarm rang.\n");
250 354
251 /* Enable periodic interrupts */ 355 /* Disable alarm interrupts */
252 retval = ioctl(fd, RTC_PIE_ON, 0); 356 retval = ioctl(fd, RTC_AIE_OFF, 0);
253 if (retval == -1) { 357 if (retval == -1) {
254 perror("ioctl"); 358 perror("ioctl");
255 exit(errno); 359 exit(errno);
256 } 360 }
257 361
258 for (i=1; i<21; i++) { 362test_PIE:
259 /* This blocks */ 363 /* Read periodic IRQ rate */
260 retval = read(fd, &data, sizeof(unsigned long)); 364 retval = ioctl(fd, RTC_IRQP_READ, &tmp);
365 if (retval == -1) {
366 /* not all RTCs support periodic IRQs */
367 if (errno == ENOTTY) {
368 fprintf(stderr, "\nNo periodic IRQ support\n");
369 return 0;
370 }
371 perror("ioctl");
372 exit(errno);
373 }
374 fprintf(stderr, "\nPeriodic IRQ rate is %ldHz.\n", tmp);
375
376 fprintf(stderr, "Counting 20 interrupts at:");
377 fflush(stderr);
378
379 /* The frequencies 128Hz, 256Hz, ... 8192Hz are only allowed for root. */
380 for (tmp=2; tmp<=64; tmp*=2) {
381
382 retval = ioctl(fd, RTC_IRQP_SET, tmp);
261 if (retval == -1) { 383 if (retval == -1) {
262 perror("read"); 384 /* not all RTCs can change their periodic IRQ rate */
263 exit(errno); 385 if (errno == ENOTTY) {
386 fprintf(stderr,
387 "\n...Periodic IRQ rate is fixed\n");
388 goto done;
389 }
390 perror("ioctl");
391 exit(errno);
264 } 392 }
265 fprintf(stderr, " %d",i); 393
394 fprintf(stderr, "\n%ldHz:\t", tmp);
266 fflush(stderr); 395 fflush(stderr);
267 irqcount++;
268 }
269 396
270 /* Disable periodic interrupts */ 397 /* Enable periodic interrupts */
271 retval = ioctl(fd, RTC_PIE_OFF, 0); 398 retval = ioctl(fd, RTC_PIE_ON, 0);
272 if (retval == -1) { 399 if (retval == -1) {
273 perror("ioctl"); 400 perror("ioctl");
274 exit(errno); 401 exit(errno);
402 }
403
404 for (i=1; i<21; i++) {
405 /* This blocks */
406 retval = read(fd, &data, sizeof(unsigned long));
407 if (retval == -1) {
408 perror("read");
409 exit(errno);
410 }
411 fprintf(stderr, " %d",i);
412 fflush(stderr);
413 irqcount++;
414 }
415
416 /* Disable periodic interrupts */
417 retval = ioctl(fd, RTC_PIE_OFF, 0);
418 if (retval == -1) {
419 perror("ioctl");
420 exit(errno);
421 }
275 } 422 }
276}
277 423
278fprintf(stderr, "\n\n\t\t\t *** Test complete ***\n"); 424done:
279fprintf(stderr, "\nTyping \"cat /proc/interrupts\" will show %d more events on IRQ 8.\n\n", 425 fprintf(stderr, "\n\n\t\t\t *** Test complete ***\n");
280 irqcount);
281 426
282close(fd); 427 close(fd);
283return 0;
284 428
285} /* end main */ 429 return 0;
430}
diff --git a/Documentation/s390/crypto/crypto-API.txt b/Documentation/s390/crypto/crypto-API.txt
index 29dee792c887..41a8b07da05a 100644
--- a/Documentation/s390/crypto/crypto-API.txt
+++ b/Documentation/s390/crypto/crypto-API.txt
@@ -75,8 +75,8 @@ name of the respective module is given in square brackets.
75 75
76- SHA1 Digest Algorithm [sha1 -> sha1_z990] 76- SHA1 Digest Algorithm [sha1 -> sha1_z990]
77- DES Encrypt/Decrypt Algorithm (64bit key) [des -> des_z990] 77- DES Encrypt/Decrypt Algorithm (64bit key) [des -> des_z990]
78- Tripple DES Encrypt/Decrypt Algorithm (128bit key) [des3_ede128 -> des_z990] 78- Triple DES Encrypt/Decrypt Algorithm (128bit key) [des3_ede128 -> des_z990]
79- Tripple DES Encrypt/Decrypt Algorithm (192bit key) [des3_ede -> des_z990] 79- Triple DES Encrypt/Decrypt Algorithm (192bit key) [des3_ede -> des_z990]
80 80
81In order to load, for example, the sha1_z990 module when the sha1 algorithm is 81In order to load, for example, the sha1_z990 module when the sha1 algorithm is
82requested (see 3.2.) add 'alias sha1 sha1_z990' to /etc/modprobe.conf. 82requested (see 3.2.) add 'alias sha1 sha1_z990' to /etc/modprobe.conf.
diff --git a/Documentation/scsi/aic79xx.txt b/Documentation/scsi/aic79xx.txt
index 904d49e90ef2..6aa9a891f3d0 100644
--- a/Documentation/scsi/aic79xx.txt
+++ b/Documentation/scsi/aic79xx.txt
@@ -127,7 +127,7 @@ The following information is available in this file:
127 - Correct a reference to free'ed memory during controller 127 - Correct a reference to free'ed memory during controller
128 shutdown. 128 shutdown.
129 - Reset the bus on an SE->LVD change. This is required 129 - Reset the bus on an SE->LVD change. This is required
130 to reset our transcievers. 130 to reset our transceivers.
131 131
132 1.3.5 (March 24th, 2003) 132 1.3.5 (March 24th, 2003)
133 - Fix a few register window mode bugs. 133 - Fix a few register window mode bugs.
@@ -169,7 +169,7 @@ The following information is available in this file:
169 1.3.0 (January 21st, 2003) 169 1.3.0 (January 21st, 2003)
170 - Full regression testing for all U320 products completed. 170 - Full regression testing for all U320 products completed.
171 - Added abort and target/lun reset error recovery handler and 171 - Added abort and target/lun reset error recovery handler and
172 interrupt coalessing. 172 interrupt coalescing.
173 173
174 1.2.0 (November 14th, 2002) 174 1.2.0 (November 14th, 2002)
175 - Added support for Domain Validation 175 - Added support for Domain Validation
diff --git a/Documentation/scsi/aic7xxx_old.txt b/Documentation/scsi/aic7xxx_old.txt
index c92f4473193b..05667e7308d4 100644
--- a/Documentation/scsi/aic7xxx_old.txt
+++ b/Documentation/scsi/aic7xxx_old.txt
@@ -256,7 +256,7 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD
256 En/Disable High Byte LVD Termination 256 En/Disable High Byte LVD Termination
257 257
258 The upper 2 bits that deal with LVD termination only apply to Ultra2 258 The upper 2 bits that deal with LVD termination only apply to Ultra2
259 controllers. Futhermore, due to the current Ultra2 controller 259 controllers. Furthermore, due to the current Ultra2 controller
260 designs, these bits are tied together such that setting either bit 260 designs, these bits are tied together such that setting either bit
261 enables both low and high byte LVD termination. It is not possible 261 enables both low and high byte LVD termination. It is not possible
262 to only set high or low byte LVD termination in this manner. This is 262 to only set high or low byte LVD termination in this manner. This is
@@ -436,7 +436,7 @@ linux-1.1.x and fairly stable since linux-1.2.x, and are also in FreeBSD
436 the commas to periods, insmod won't interpret this as more than one 436 the commas to periods, insmod won't interpret this as more than one
437 string and write junk into our binary image. I consider it a bug in 437 string and write junk into our binary image. I consider it a bug in
438 the insmod program that even if you wrap your string in quotes (quotes 438 the insmod program that even if you wrap your string in quotes (quotes
439 that pass the shell mind you and that insmod sees) it still treates 439 that pass the shell mind you and that insmod sees) it still treats
440 a comma inside of those quotes as starting a new variable, resulting 440 a comma inside of those quotes as starting a new variable, resulting
441 in memory scribbles if you don't switch the commas to periods. 441 in memory scribbles if you don't switch the commas to periods.
442 442
diff --git a/Documentation/scsi/ibmmca.txt b/Documentation/scsi/ibmmca.txt
index 35f6b8ed2295..9707941704e3 100644
--- a/Documentation/scsi/ibmmca.txt
+++ b/Documentation/scsi/ibmmca.txt
@@ -461,7 +461,7 @@
461 This needs the RD-Bit to be disabled on IM_OTHER_SCSI_CMD_CMD which 461 This needs the RD-Bit to be disabled on IM_OTHER_SCSI_CMD_CMD which
462 allows data to be written from the system to the device. It is a 462 allows data to be written from the system to the device. It is a
463 necessary step to be allowed to set blocksize of SCSI-tape-drives and 463 necessary step to be allowed to set blocksize of SCSI-tape-drives and
464 the tape-speed, whithout confusing the SCSI-Subsystem. 464 the tape-speed, without confusing the SCSI-Subsystem.
465 2) The recognition of a tape is included in the check_devices routine. 465 2) The recognition of a tape is included in the check_devices routine.
466 This is done by checking for TYPE_TAPE, that is already defined in 466 This is done by checking for TYPE_TAPE, that is already defined in
467 the kernel-scsi-environment. The markup of a tape is done in the 467 the kernel-scsi-environment. The markup of a tape is done in the
@@ -710,8 +710,8 @@
710 of troubles with some controllers and after I wanted to apply some 710 of troubles with some controllers and after I wanted to apply some
711 extensions, it jumped out in the same situation, on my w/cache, as like 711 extensions, it jumped out in the same situation, on my w/cache, as like
712 on D. Weinehalls' Model 56, having integrated SCSI. This gave me the 712 on D. Weinehalls' Model 56, having integrated SCSI. This gave me the
713 descissive hint to move the code-part out and declare it global. Now, 713 decisive hint to move the code-part out and declare it global. Now
714 it seems to work by far much better an more stable. Let us see, what 714 it seems to work far better and more stable. Let us see what
715 the world thinks of it... 715 the world thinks of it...
716 3) By the way, only Sony DAT-drives seem to show density code 0x13. A 716 3) By the way, only Sony DAT-drives seem to show density code 0x13. A
717 test with a HP drive gave right results, so the problem is vendor- 717 test with a HP drive gave right results, so the problem is vendor-
@@ -822,10 +822,10 @@
822 A long period of collecting bugreports from all corners of the world 822 A long period of collecting bugreports from all corners of the world
823 now lead to the following corrections to the code: 823 now lead to the following corrections to the code:
824 1) SCSI-2 F/W support crashed with a COMMAND ERROR. The reason for this 824 1) SCSI-2 F/W support crashed with a COMMAND ERROR. The reason for this
825 was, that it is possible to disbale Fast-SCSI for the external bus. 825 was that it is possible to disable Fast-SCSI for the external bus.
826 The feature-control command, where this crash appeared regularly tried 826 The feature-control command, where this crash appeared regularly, tried
827 to set the maximum speed of 10MHz synchronous transfer speed and that 827 to set the maximum speed of 10MHz synchronous transfer speed and that
828 reports a COMMAND ERROR, if external bus Fast-SCSI is disabled. Now, 828 reports a COMMAND ERROR if external bus Fast-SCSI is disabled. Now,
829 the feature-command probes down from maximum speed until the adapter 829 the feature-command probes down from maximum speed until the adapter
830 stops to complain, which is at the same time the maximum possible 830 stops to complain, which is at the same time the maximum possible
831 speed selected in the reference program. So, F/W external can run at 831 speed selected in the reference program. So, F/W external can run at
@@ -920,7 +920,7 @@
920 completed in such a way, that they are now completely conform to the 920 completed in such a way, that they are now completely conform to the
921 demands in the technical description of IBM. Main candidates were the 921 demands in the technical description of IBM. Main candidates were the
922 DEVICE_INQUIRY, REQUEST_SENSE and DEVICE_CAPACITY commands. They must 922 DEVICE_INQUIRY, REQUEST_SENSE and DEVICE_CAPACITY commands. They must
923 be tranferred by bypassing the internal command buffer of the adapter 923 be transferred by bypassing the internal command buffer of the adapter
924 or else the response can be a random result. GET_POS_INFO would be more 924 or else the response can be a random result. GET_POS_INFO would be more
925 safe in usage, if one could use the SUPRESS_EXCEPTION_SHORT, but this 925 safe in usage, if one could use the SUPRESS_EXCEPTION_SHORT, but this
926 is not allowed by the technical references of IBM. (Sorry, folks, the 926 is not allowed by the technical references of IBM. (Sorry, folks, the
diff --git a/Documentation/scsi/in2000.txt b/Documentation/scsi/in2000.txt
index 80f104042645..c3e2a90475d2 100644
--- a/Documentation/scsi/in2000.txt
+++ b/Documentation/scsi/in2000.txt
@@ -24,7 +24,7 @@ UPDATE NEWS: version 1.32 - 28 Mar 98
24UPDATE NEWS: version 1.31 - 6 Jul 97 24UPDATE NEWS: version 1.31 - 6 Jul 97
25 25
26 Fixed a bug that caused incorrect SCSI status bytes to be 26 Fixed a bug that caused incorrect SCSI status bytes to be
27 returned from commands sent to LUN's greater than 0. This 27 returned from commands sent to LUNs greater than 0. This
28 means that CDROM changers work now! Fixed a bug in the 28 means that CDROM changers work now! Fixed a bug in the
29 handling of command-line arguments when loaded as a module. 29 handling of command-line arguments when loaded as a module.
30 Also put all the header data in in2000.h where it belongs. 30 Also put all the header data in in2000.h where it belongs.
diff --git a/Documentation/scsi/libsas.txt b/Documentation/scsi/libsas.txt
index 9e2078b2a615..aa54f54c4a50 100644
--- a/Documentation/scsi/libsas.txt
+++ b/Documentation/scsi/libsas.txt
@@ -393,7 +393,7 @@ struct sas_task {
393 task_proto -- _one_ of enum sas_proto 393 task_proto -- _one_ of enum sas_proto
394 scatter -- pointer to scatter gather list array 394 scatter -- pointer to scatter gather list array
395 num_scatter -- number of elements in scatter 395 num_scatter -- number of elements in scatter
396 total_xfer_len -- total number of bytes expected to be transfered 396 total_xfer_len -- total number of bytes expected to be transferred
397 data_dir -- PCI_DMA_... 397 data_dir -- PCI_DMA_...
398 task_done -- callback when the task has finished execution 398 task_done -- callback when the task has finished execution
399}; 399};
diff --git a/Documentation/scsi/ncr53c8xx.txt b/Documentation/scsi/ncr53c8xx.txt
index 58ad8db333d9..caf10b155185 100644
--- a/Documentation/scsi/ncr53c8xx.txt
+++ b/Documentation/scsi/ncr53c8xx.txt
@@ -115,7 +115,7 @@ SCSI standard documentations are available at SYMBIOS ftp server:
115 115
116 ftp://ftp.symbios.com/ 116 ftp://ftp.symbios.com/
117 117
118Usefull SCSI tools written by Eric Youngdale are available at tsx-11: 118Useful SCSI tools written by Eric Youngdale are available at tsx-11:
119 119
120 ftp://tsx-11.mit.edu/pub/linux/ALPHA/scsi/scsiinfo-X.Y.tar.gz 120 ftp://tsx-11.mit.edu/pub/linux/ALPHA/scsi/scsiinfo-X.Y.tar.gz
121 ftp://tsx-11.mit.edu/pub/linux/ALPHA/scsi/scsidev-X.Y.tar.gz 121 ftp://tsx-11.mit.edu/pub/linux/ALPHA/scsi/scsidev-X.Y.tar.gz
diff --git a/Documentation/scsi/scsi-changer.txt b/Documentation/scsi/scsi-changer.txt
index d74bbd29eb3a..032399b16a53 100644
--- a/Documentation/scsi/scsi-changer.txt
+++ b/Documentation/scsi/scsi-changer.txt
@@ -88,7 +88,7 @@ If the module finds the changer, it prints some messages about the
88device [ try "dmesg" if you don't see anything ] and should show up in 88device [ try "dmesg" if you don't see anything ] and should show up in
89/proc/devices. If not.... some changers use ID ? / LUN 0 for the 89/proc/devices. If not.... some changers use ID ? / LUN 0 for the
90device and ID ? / LUN 1 for the robot mechanism. But Linux does *not* 90device and ID ? / LUN 1 for the robot mechanism. But Linux does *not*
91look for LUN's other than 0 as default, becauce there are to many 91look for LUNs other than 0 as default, because there are too many
92broken devices. So you can try: 92broken devices. So you can try:
93 93
94 1) echo "scsi add-single-device 0 0 ID 1" > /proc/scsi/scsi 94 1) echo "scsi add-single-device 0 0 ID 1" > /proc/scsi/scsi
@@ -107,7 +107,7 @@ because the kernel will translate the error codes into human-readable
107strings then. 107strings then.
108 108
109You can display these messages with the dmesg command (or check the 109You can display these messages with the dmesg command (or check the
110logfiles). If you email me some question becauce of a problem with the 110logfiles). If you email me some question because of a problem with the
111driver, please include these messages. 111driver, please include these messages.
112 112
113 113
diff --git a/Documentation/scsi/scsi_eh.txt b/Documentation/scsi/scsi_eh.txt
index b964eef2f62f..7acbebb17fa6 100644
--- a/Documentation/scsi/scsi_eh.txt
+++ b/Documentation/scsi/scsi_eh.txt
@@ -75,7 +75,7 @@ with the command.
75 75
76 - otherwise 76 - otherwise
77 scsi_eh_scmd_add(scmd, 0) is invoked for the command. See 77 scsi_eh_scmd_add(scmd, 0) is invoked for the command. See
78 [1-3] for details of this funciton. 78 [1-3] for details of this function.
79 79
80 80
81[1-2-2] Completing a scmd w/ timeout 81[1-2-2] Completing a scmd w/ timeout
diff --git a/Documentation/scsi/st.txt b/Documentation/scsi/st.txt
index 5ff65b184265..3c12422f7f41 100644
--- a/Documentation/scsi/st.txt
+++ b/Documentation/scsi/st.txt
@@ -261,7 +261,7 @@ pairs are separated with a comma (no spaces allowed). A colon can be
261used instead of the equal mark. The definition is prepended by the 261used instead of the equal mark. The definition is prepended by the
262string st=. Here is an example: 262string st=. Here is an example:
263 263
264 st=buffer_kbs:64,write_threhold_kbs:60 264 st=buffer_kbs:64,write_threshold_kbs:60
265 265
266The following syntax used by the old kernel versions is also supported: 266The following syntax used by the old kernel versions is also supported:
267 267
diff --git a/Documentation/scsi/sym53c8xx_2.txt b/Documentation/scsi/sym53c8xx_2.txt
index 26c8a08ca3ea..2c1745a9df00 100644
--- a/Documentation/scsi/sym53c8xx_2.txt
+++ b/Documentation/scsi/sym53c8xx_2.txt
@@ -609,7 +609,7 @@ appropriate mailing lists or news-groups. Send me a copy in order to
609be sure I will receive it. Obviously, a bug in the driver code is 609be sure I will receive it. Obviously, a bug in the driver code is
610possible. 610possible.
611 611
612 My cyrrent email address: Gerard Roudier <groudier@free.fr> 612 My current email address: Gerard Roudier <groudier@free.fr>
613 613
614Allowing disconnections is important if you use several devices on 614Allowing disconnections is important if you use several devices on
615your SCSI bus but often causes problems with buggy devices. 615your SCSI bus but often causes problems with buggy devices.
diff --git a/Documentation/sharedsubtree.txt b/Documentation/sharedsubtree.txt
index 2d8f403eb6eb..ccf1cebe744f 100644
--- a/Documentation/sharedsubtree.txt
+++ b/Documentation/sharedsubtree.txt
@@ -942,13 +942,13 @@ replicas continue to be exactly same.
942 ->mnt_slave 942 ->mnt_slave
943 ->mnt_master 943 ->mnt_master
944 944
945 ->mnt_share links togather all the mount to/from which this vfsmount 945 ->mnt_share links together all the mount to/from which this vfsmount
946 send/receives propagation events. 946 send/receives propagation events.
947 947
948 ->mnt_slave_list links all the mounts to which this vfsmount propagates 948 ->mnt_slave_list links all the mounts to which this vfsmount propagates
949 to. 949 to.
950 950
951 ->mnt_slave links togather all the slaves that its master vfsmount 951 ->mnt_slave links together all the slaves that its master vfsmount
952 propagates to. 952 propagates to.
953 953
954 ->mnt_master points to the master vfsmount from which this vfsmount 954 ->mnt_master points to the master vfsmount from which this vfsmount
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt
index 3472d9c4ef1b..9fef210ab50a 100644
--- a/Documentation/sound/alsa/ALSA-Configuration.txt
+++ b/Documentation/sound/alsa/ALSA-Configuration.txt
@@ -955,7 +955,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
955 dmx6fire, dsp24, dsp24_value, dsp24_71, ez8, 955 dmx6fire, dsp24, dsp24_value, dsp24_71, ez8,
956 phase88, mediastation 956 phase88, mediastation
957 omni - Omni I/O support for MidiMan M-Audio Delta44/66 957 omni - Omni I/O support for MidiMan M-Audio Delta44/66
958 cs8427_timeout - reset timeout for the CS8427 chip (S/PDIF transciever) 958 cs8427_timeout - reset timeout for the CS8427 chip (S/PDIF transceiver)
959 in msec resolution, default value is 500 (0.5 sec) 959 in msec resolution, default value is 500 (0.5 sec)
960 960
961 This module supports multiple cards and autoprobe. Note: The consumer part 961 This module supports multiple cards and autoprobe. Note: The consumer part
diff --git a/Documentation/sound/alsa/Audigy-mixer.txt b/Documentation/sound/alsa/Audigy-mixer.txt
index 5132fd95e074..7f10dc6ff28c 100644
--- a/Documentation/sound/alsa/Audigy-mixer.txt
+++ b/Documentation/sound/alsa/Audigy-mixer.txt
@@ -6,7 +6,7 @@ This is based on SB-Live-mixer.txt.
6 6
7The EMU10K2 chips have a DSP part which can be programmed to support 7The EMU10K2 chips have a DSP part which can be programmed to support
8various ways of sample processing, which is described here. 8various ways of sample processing, which is described here.
9(This acticle does not deal with the overall functionality of the 9(This article does not deal with the overall functionality of the
10EMU10K2 chips. See the manuals section for further details.) 10EMU10K2 chips. See the manuals section for further details.)
11 11
12The ALSA driver programs this portion of chip by default code 12The ALSA driver programs this portion of chip by default code
diff --git a/Documentation/sound/alsa/SB-Live-mixer.txt b/Documentation/sound/alsa/SB-Live-mixer.txt
index 651adaf60473..f5639d40521d 100644
--- a/Documentation/sound/alsa/SB-Live-mixer.txt
+++ b/Documentation/sound/alsa/SB-Live-mixer.txt
@@ -5,7 +5,7 @@
5 5
6The EMU10K1 chips have a DSP part which can be programmed to support 6The EMU10K1 chips have a DSP part which can be programmed to support
7various ways of sample processing, which is described here. 7various ways of sample processing, which is described here.
8(This acticle does not deal with the overall functionality of the 8(This article does not deal with the overall functionality of the
9EMU10K1 chips. See the manuals section for further details.) 9EMU10K1 chips. See the manuals section for further details.)
10 10
11The ALSA driver programs this portion of chip by default code 11The ALSA driver programs this portion of chip by default code
diff --git a/Documentation/stable_kernel_rules.txt b/Documentation/stable_kernel_rules.txt
index 02a481225b0d..c815c5206e84 100644
--- a/Documentation/stable_kernel_rules.txt
+++ b/Documentation/stable_kernel_rules.txt
@@ -50,7 +50,7 @@ Review cycle:
50 Contact the kernel security team for more details on this procedure. 50 Contact the kernel security team for more details on this procedure.
51 51
52 52
53Review committe: 53Review committee:
54 54
55 - This is made up of a number of kernel developers who have volunteered for 55 - This is made up of a number of kernel developers who have volunteered for
56 this task, and a few that haven't. 56 this task, and a few that haven't.
diff --git a/Documentation/sysctl/fs.txt b/Documentation/sysctl/fs.txt
index 5c3a51905969..aa986a35e994 100644
--- a/Documentation/sysctl/fs.txt
+++ b/Documentation/sysctl/fs.txt
@@ -146,7 +146,7 @@ or otherwise protected/tainted binaries. The modes are
146 readable by root only. This allows the end user to remove 146 readable by root only. This allows the end user to remove
147 such a dump but not access it directly. For security reasons 147 such a dump but not access it directly. For security reasons
148 core dumps in this mode will not overwrite one another or 148 core dumps in this mode will not overwrite one another or
149 other files. This mode is appropriate when adminstrators are 149 other files. This mode is appropriate when administrators are
150 attempting to debug problems in a normal environment. 150 attempting to debug problems in a normal environment.
151 151
152============================================================== 152==============================================================
diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt
index 20d0d797f539..e96a341eb7e4 100644
--- a/Documentation/sysctl/vm.txt
+++ b/Documentation/sysctl/vm.txt
@@ -129,7 +129,7 @@ the high water marks for each per cpu page list.
129 129
130zone_reclaim_mode: 130zone_reclaim_mode:
131 131
132Zone_reclaim_mode allows to set more or less agressive approaches to 132Zone_reclaim_mode allows someone to set more or less aggressive approaches to
133reclaim memory when a zone runs out of memory. If it is set to zero then no 133reclaim memory when a zone runs out of memory. If it is set to zero then no
134zone reclaim occurs. Allocations will be satisfied from other zones / nodes 134zone reclaim occurs. Allocations will be satisfied from other zones / nodes
135in the system. 135in the system.
diff --git a/Documentation/uml/UserModeLinux-HOWTO.txt b/Documentation/uml/UserModeLinux-HOWTO.txt
index b60590eca18f..628013f944c4 100644
--- a/Documentation/uml/UserModeLinux-HOWTO.txt
+++ b/Documentation/uml/UserModeLinux-HOWTO.txt
@@ -1477,7 +1477,7 @@
1477 1477
1478 1478
1479 1479
1480 Making it world-writeable looks bad, but it seems not to be 1480 Making it world-writable looks bad, but it seems not to be
1481 exploitable as a security hole. However, it does allow anyone to cre- 1481 exploitable as a security hole. However, it does allow anyone to cre-
1482 ate useless tap devices (useless because they can't configure them), 1482 ate useless tap devices (useless because they can't configure them),
1483 which is a DOS attack. A somewhat more secure alternative would to be 1483 which is a DOS attack. A somewhat more secure alternative would to be
diff --git a/Documentation/usb/hiddev.txt b/Documentation/usb/hiddev.txt
index 6a790754e963..6e8c9f1d2f22 100644
--- a/Documentation/usb/hiddev.txt
+++ b/Documentation/usb/hiddev.txt
@@ -8,7 +8,7 @@ interfaces, but have similar sorts of communication needs. The two big
8examples for this are power devices (especially uninterruptable power 8examples for this are power devices (especially uninterruptable power
9supplies) and monitor control on higher end monitors. 9supplies) and monitor control on higher end monitors.
10 10
11To support these disparite requirements, the Linux USB system provides 11To support these disparate requirements, the Linux USB system provides
12HID events to two separate interfaces: 12HID events to two separate interfaces:
13* the input subsystem, which converts HID events into normal input 13* the input subsystem, which converts HID events into normal input
14device interfaces (such as keyboard, mouse and joystick) and a 14device interfaces (such as keyboard, mouse and joystick) and a
diff --git a/Documentation/usb/rio.txt b/Documentation/usb/rio.txt
index ab21db454694..aee715af7db7 100644
--- a/Documentation/usb/rio.txt
+++ b/Documentation/usb/rio.txt
@@ -24,10 +24,10 @@ are in no way responsible for any damage that may occur, no matter how
24inconsequential. 24inconsequential.
25 25
26It seems that the Rio has a problem when sending .mp3 with low batteries. 26It seems that the Rio has a problem when sending .mp3 with low batteries.
27I suggest when the batteries are low and want to transfer stuff that you 27I suggest when the batteries are low and you want to transfer stuff that you
28replace it with a fresh one. In my case, what happened is I lost two 16kb 28replace it with a fresh one. In my case, what happened is I lost two 16kb
29blocks (they are no longer usable to store information to it). But I don't 29blocks (they are no longer usable to store information to it). But I don't
30know if thats normal or not. It could simply be a problem with the flash 30know if that's normal or not; it could simply be a problem with the flash
31memory. 31memory.
32 32
33In an extreme case, I left my Rio playing overnight and the batteries wore 33In an extreme case, I left my Rio playing overnight and the batteries wore
diff --git a/Documentation/usb/usb-serial.txt b/Documentation/usb/usb-serial.txt
index 50436e1663ea..d61f6e7865de 100644
--- a/Documentation/usb/usb-serial.txt
+++ b/Documentation/usb/usb-serial.txt
@@ -175,7 +175,7 @@ Keyspan USA-series Serial Adapters
175 175
176 Current status: 176 Current status:
177 The USA-18X, USA-28X, USA-19, USA-19W and USA-49W are supported and 177 The USA-18X, USA-28X, USA-19, USA-19W and USA-49W are supported and
178 have been pretty throughly tested at various baud rates with 8-N-1 178 have been pretty thoroughly tested at various baud rates with 8-N-1
179 character settings. Other character lengths and parity setups are 179 character settings. Other character lengths and parity setups are
180 presently untested. 180 presently untested.
181 181
@@ -253,7 +253,7 @@ Cypress M8 CY4601 Family Serial Driver
253 together without hacking the adapter to set the line high. 253 together without hacking the adapter to set the line high.
254 254
255 The driver is smp safe. Performance with the driver is rather low when using 255 The driver is smp safe. Performance with the driver is rather low when using
256 it for transfering files. This is being worked on, but I would be willing to 256 it for transferring files. This is being worked on, but I would be willing to
257 accept patches. An urb queue or packet buffer would likely fit the bill here. 257 accept patches. An urb queue or packet buffer would likely fit the bill here.
258 258
259 If you have any questions, problems, patches, feature requests, etc. you can 259 If you have any questions, problems, patches, feature requests, etc. you can
@@ -297,7 +297,7 @@ Belkin USB Serial Adapter F5U103
297 Parity N,E,O,M,S 297 Parity N,E,O,M,S
298 Handshake None, Software (XON/XOFF), Hardware (CTSRTS,CTSDTR)* 298 Handshake None, Software (XON/XOFF), Hardware (CTSRTS,CTSDTR)*
299 Break Set and clear 299 Break Set and clear
300 Line contrl Input/Output query and control ** 300 Line control Input/Output query and control **
301 301
302 * Hardware input flow control is only enabled for firmware 302 * Hardware input flow control is only enabled for firmware
303 levels above 2.06. Read source code comments describing Belkin 303 levels above 2.06. Read source code comments describing Belkin
@@ -309,7 +309,7 @@ Belkin USB Serial Adapter F5U103
309 automatic hardware flow control. 309 automatic hardware flow control.
310 310
311 TO DO List: 311 TO DO List:
312 -- Add true modem contol line query capability. Currently tracks the 312 -- Add true modem control line query capability. Currently tracks the
313 states reported by the interrupt and the states requested. 313 states reported by the interrupt and the states requested.
314 -- Add error reporting back to application for UART error conditions. 314 -- Add error reporting back to application for UART error conditions.
315 -- Add support for flush ioctls. 315 -- Add support for flush ioctls.
diff --git a/Documentation/watchdog/watchdog-api.txt b/Documentation/watchdog/watchdog-api.txt
index 7e8ae83e9847..8d16f6f3c4ec 100644
--- a/Documentation/watchdog/watchdog-api.txt
+++ b/Documentation/watchdog/watchdog-api.txt
@@ -214,7 +214,7 @@ returned value is the temperature in degrees fahrenheit.
214 214
215Finally the SETOPTIONS ioctl can be used to control some aspects of 215Finally the SETOPTIONS ioctl can be used to control some aspects of
216the cards operation; right now the pcwd driver is the only one 216the cards operation; right now the pcwd driver is the only one
217supporting thiss ioctl. 217supporting this ioctl.
218 218
219 int options = 0; 219 int options = 0;
220 ioctl(fd, WDIOC_SETOPTIONS, options); 220 ioctl(fd, WDIOC_SETOPTIONS, options);
diff --git a/MAINTAINERS b/MAINTAINERS
index a5508f930ed9..8385a69138a8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -155,16 +155,16 @@ L: netdev@vger.kernel.org
155S: Maintained 155S: Maintained
156 156
1579P FILE SYSTEM 1579P FILE SYSTEM
158P: Eric Van Hensbergen 158P: Eric Van Hensbergen
159M: ericvh@gmail.com 159M: ericvh@gmail.com
160P: Ron Minnich 160P: Ron Minnich
161M: rminnich@lanl.gov 161M: rminnich@lanl.gov
162P: Latchesar Ionkov 162P: Latchesar Ionkov
163M: lucho@ionkov.net 163M: lucho@ionkov.net
164L: v9fs-developer@lists.sourceforge.net 164L: v9fs-developer@lists.sourceforge.net
165W: http://v9fs.sf.net 165W: http://v9fs.sf.net
166T: git kernel.org:/pub/scm/linux/kernel/ericvh/v9fs.git 166T: git kernel.org:/pub/scm/linux/kernel/ericvh/v9fs.git
167S: Maintained 167S: Maintained
168 168
169A2232 SERIAL BOARD DRIVER 169A2232 SERIAL BOARD DRIVER
170P: Enver Haase 170P: Enver Haase
@@ -290,8 +290,8 @@ M: ink@jurassic.park.msu.ru
290S: Maintained for 2.4; PCI support for 2.6. 290S: Maintained for 2.4; PCI support for 2.6.
291 291
292AMD GEODE PROCESSOR/CHIPSET SUPPORT 292AMD GEODE PROCESSOR/CHIPSET SUPPORT
293P: Jordan Crouse 293P: Jordan Crouse
294M: info-linux@geode.amd.com 294M: info-linux@geode.amd.com
295L: info-linux@geode.amd.com 295L: info-linux@geode.amd.com
296W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html 296W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html
297S: Supported 297S: Supported
@@ -353,6 +353,12 @@ P: Richard Purdie
353M: rpurdie@rpsys.net 353M: rpurdie@rpsys.net
354S: Maintained 354S: Maintained
355 355
356ARM/HP JORNADA 7XX MACHINE SUPPORT
357P: Kristoffer Ericson
358M: kristoffer_e1@hotmail.com
359W: www.jlime.com
360S: Maintained
361
356ARM/TOSA MACHINE SUPPORT 362ARM/TOSA MACHINE SUPPORT
357P: Dirk Opfer 363P: Dirk Opfer
358M: dirk@opfer-online.de 364M: dirk@opfer-online.de
@@ -426,6 +432,13 @@ L: linux-atm-general@lists.sourceforge.net (subscribers-only)
426W: http://linux-atm.sourceforge.net 432W: http://linux-atm.sourceforge.net
427S: Maintained 433S: Maintained
428 434
435ATMEL MACB ETHERNET DRIVER
436P: Atmel AVR32 Support Team
437M: avr32@atmel.com
438P: Haavard Skinnemoen
439M: hskinnemoen@atmel.com
440S: Supported
441
429ATMEL WIRELESS DRIVER 442ATMEL WIRELESS DRIVER
430P: Simon Kelley 443P: Simon Kelley
431M: simon@thekelleys.org.uk 444M: simon@thekelleys.org.uk
@@ -595,13 +608,13 @@ M: maxk@qualcomm.com
595S: Maintained 608S: Maintained
596 609
597BONDING DRIVER 610BONDING DRIVER
598P: Chad Tindel 611P: Chad Tindel
599M: ctindel@users.sourceforge.net 612M: ctindel@users.sourceforge.net
600P: Jay Vosburgh 613P: Jay Vosburgh
601M: fubar@us.ibm.com 614M: fubar@us.ibm.com
602L: bonding-devel@lists.sourceforge.net 615L: bonding-devel@lists.sourceforge.net
603W: http://sourceforge.net/projects/bonding/ 616W: http://sourceforge.net/projects/bonding/
604S: Supported 617S: Supported
605 618
606BROADBAND PROCESSOR ARCHITECTURE 619BROADBAND PROCESSOR ARCHITECTURE
607P: Arnd Bergmann 620P: Arnd Bergmann
@@ -738,8 +751,8 @@ W: http://www.bullopensource.org/cpuset/
738S: Supported 751S: Supported
739 752
740CRAMFS FILESYSTEM 753CRAMFS FILESYSTEM
741W: http://sourceforge.net/projects/cramfs/ 754W: http://sourceforge.net/projects/cramfs/
742S: Orphan 755S: Orphan
743 756
744CRIS PORT 757CRIS PORT
745P: Mikael Starvik 758P: Mikael Starvik
@@ -1048,11 +1061,11 @@ W: http://sourceforge.net/projects/emu10k1/
1048S: Maintained 1061S: Maintained
1049 1062
1050EMULEX LPFC FC SCSI DRIVER 1063EMULEX LPFC FC SCSI DRIVER
1051P: James Smart 1064P: James Smart
1052M: james.smart@emulex.com 1065M: james.smart@emulex.com
1053L: linux-scsi@vger.kernel.org 1066L: linux-scsi@vger.kernel.org
1054W: http://sourceforge.net/projects/lpfcxxxx 1067W: http://sourceforge.net/projects/lpfcxxxx
1055S: Supported 1068S: Supported
1056 1069
1057EPSON 1355 FRAMEBUFFER DRIVER 1070EPSON 1355 FRAMEBUFFER DRIVER
1058P: Christopher Hoover 1071P: Christopher Hoover
@@ -1153,11 +1166,6 @@ P: David Howells
1153M: dhowells@redhat.com 1166M: dhowells@redhat.com
1154S: Maintained 1167S: Maintained
1155 1168
1156FTAPE/QIC-117
1157L: linux-tape@vger.kernel.org
1158W: http://sourceforge.net/projects/ftape
1159S: Orphan
1160
1161FUSE: FILESYSTEM IN USERSPACE 1169FUSE: FILESYSTEM IN USERSPACE
1162P: Miklos Szeredi 1170P: Miklos Szeredi
1163M: miklos@szeredi.hu 1171M: miklos@szeredi.hu
@@ -1489,16 +1497,16 @@ L: linux-kernel@vger.kernel.org
1489S: Maintained 1497S: Maintained
1490 1498
1491INTEL FRAMEBUFFER DRIVER (excluding 810 and 815) 1499INTEL FRAMEBUFFER DRIVER (excluding 810 and 815)
1492P: Sylvain Meyer 1500P: Sylvain Meyer
1493M: sylvain.meyer@worldonline.fr 1501M: sylvain.meyer@worldonline.fr
1494L: linux-fbdev-devel@lists.sourceforge.net 1502L: linux-fbdev-devel@lists.sourceforge.net
1495S: Maintained 1503S: Maintained
1496 1504
1497INTEL 810/815 FRAMEBUFFER DRIVER 1505INTEL 810/815 FRAMEBUFFER DRIVER
1498P: Antonino Daplas 1506P: Antonino Daplas
1499M: adaplas@pol.net 1507M: adaplas@pol.net
1500L: linux-fbdev-devel@lists.sourceforge.net 1508L: linux-fbdev-devel@lists.sourceforge.net
1501S: Maintained 1509S: Maintained
1502 1510
1503INTEL APIC/IOAPIC, LOWLEVEL X86 SMP SUPPORT 1511INTEL APIC/IOAPIC, LOWLEVEL X86 SMP SUPPORT
1504P: Ingo Molnar 1512P: Ingo Molnar
@@ -1824,11 +1832,11 @@ L: linuxppc-embedded@ozlabs.org
1824S: Maintained 1832S: Maintained
1825 1833
1826LINUX FOR POWERPC EMBEDDED PPC83XX AND PPC85XX 1834LINUX FOR POWERPC EMBEDDED PPC83XX AND PPC85XX
1827P: Kumar Gala 1835P: Kumar Gala
1828M: galak@kernel.crashing.org 1836M: galak@kernel.crashing.org
1829W: http://www.penguinppc.org/ 1837W: http://www.penguinppc.org/
1830L: linuxppc-embedded@ozlabs.org 1838L: linuxppc-embedded@ozlabs.org
1831S: Maintained 1839S: Maintained
1832 1840
1833LINUX FOR POWERPC PA SEMI PWRFICIENT 1841LINUX FOR POWERPC PA SEMI PWRFICIENT
1834P: Olof Johansson 1842P: Olof Johansson
@@ -1927,10 +1935,10 @@ W: http://www.syskonnect.com
1927S: Supported 1935S: Supported
1928 1936
1929MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7 1937MAN-PAGES: MANUAL PAGES FOR LINUX -- Sections 2, 3, 4, 5, and 7
1930P: Michael Kerrisk 1938P: Michael Kerrisk
1931M: mtk-manpages@gmx.net 1939M: mtk-manpages@gmx.net
1932W: ftp://ftp.kernel.org/pub/linux/docs/manpages 1940W: ftp://ftp.kernel.org/pub/linux/docs/manpages
1933S: Maintained 1941S: Maintained
1934 1942
1935MARVELL MV643XX ETHERNET DRIVER 1943MARVELL MV643XX ETHERNET DRIVER
1936P: Dale Farnsworth 1944P: Dale Farnsworth
@@ -1947,11 +1955,11 @@ L: linux-fbdev-devel@lists.sourceforge.net
1947S: Maintained 1955S: Maintained
1948 1956
1949MEGARAID SCSI DRIVERS 1957MEGARAID SCSI DRIVERS
1950P: Neela Syam Kolli 1958P: Neela Syam Kolli
1951M: Neela.Kolli@engenio.com 1959M: Neela.Kolli@engenio.com
1952S: linux-scsi@vger.kernel.org 1960S: linux-scsi@vger.kernel.org
1953W: http://megaraid.lsilogic.com 1961W: http://megaraid.lsilogic.com
1954S: Maintained 1962S: Maintained
1955 1963
1956MEMORY MANAGEMENT 1964MEMORY MANAGEMENT
1957L: linux-mm@kvack.org 1965L: linux-mm@kvack.org
@@ -2126,6 +2134,13 @@ L: netdev@vger.kernel.org
2126T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git 2134T: git kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6.git
2127S: Maintained 2135S: Maintained
2128 2136
2137NETXEN (1/10) GbE SUPPORT
2138P: Amit S. Kale
2139M: amitkale@netxen.com
2140L: netdev@vger.kernel.org
2141W: http://www.netxen.com
2142S: Supported
2143
2129IPVS 2144IPVS
2130P: Wensong Zhang 2145P: Wensong Zhang
2131M: wensong@linux-vs.org 2146M: wensong@linux-vs.org
@@ -2180,10 +2195,10 @@ T: git kernel.org:/pub/scm/linux/kernel/git/aia21/ntfs-2.6.git
2180S: Maintained 2195S: Maintained
2181 2196
2182NVIDIA (rivafb and nvidiafb) FRAMEBUFFER DRIVER 2197NVIDIA (rivafb and nvidiafb) FRAMEBUFFER DRIVER
2183P: Antonino Daplas 2198P: Antonino Daplas
2184M: adaplas@pol.net 2199M: adaplas@pol.net
2185L: linux-fbdev-devel@lists.sourceforge.net 2200L: linux-fbdev-devel@lists.sourceforge.net
2186S: Maintained 2201S: Maintained
2187 2202
2188OPENCORES I2C BUS DRIVER 2203OPENCORES I2C BUS DRIVER
2189P: Peter Korsgaard 2204P: Peter Korsgaard
@@ -2533,10 +2548,10 @@ RISCOM8 DRIVER
2533S: Orphan 2548S: Orphan
2534 2549
2535S3 SAVAGE FRAMEBUFFER DRIVER 2550S3 SAVAGE FRAMEBUFFER DRIVER
2536P: Antonino Daplas 2551P: Antonino Daplas
2537M: adaplas@pol.net 2552M: adaplas@pol.net
2538L: linux-fbdev-devel@lists.sourceforge.net 2553L: linux-fbdev-devel@lists.sourceforge.net
2539S: Maintained 2554S: Maintained
2540 2555
2541S390 2556S390
2542P: Martin Schwidefsky 2557P: Martin Schwidefsky
@@ -2617,10 +2632,10 @@ L: linux-scsi@vger.kernel.org
2617S: Maintained 2632S: Maintained
2618 2633
2619SCTP PROTOCOL 2634SCTP PROTOCOL
2620P: Sridhar Samudrala 2635P: Sridhar Samudrala
2621M: sri@us.ibm.com 2636M: sri@us.ibm.com
2622L: lksctp-developers@lists.sourceforge.net 2637L: lksctp-developers@lists.sourceforge.net
2623S: Supported 2638S: Supported
2624 2639
2625SCx200 CPU SUPPORT 2640SCx200 CPU SUPPORT
2626P: Jim Cromie 2641P: Jim Cromie
@@ -2788,9 +2803,9 @@ L: tpmdd-devel@lists.sourceforge.net
2788S: Maintained 2803S: Maintained
2789 2804
2790Telecom Clock Driver for MCPL0010 2805Telecom Clock Driver for MCPL0010
2791P: Mark Gross 2806P: Mark Gross
2792M: mark.gross@intel.com 2807M: mark.gross@intel.com
2793S: Supported 2808S: Supported
2794 2809
2795TENSILICA XTENSA PORT (xtensa): 2810TENSILICA XTENSA PORT (xtensa):
2796P: Chris Zankel 2811P: Chris Zankel
@@ -2937,9 +2952,9 @@ L: linux-kernel@vger.kernel.org
2937S: Maintained 2952S: Maintained
2938 2953
2939TI PARALLEL LINK CABLE DRIVER 2954TI PARALLEL LINK CABLE DRIVER
2940P: Romain Lievin 2955P: Romain Lievin
2941M: roms@lpg.ticalc.org 2956M: roms@lpg.ticalc.org
2942S: Maintained 2957S: Maintained
2943 2958
2944TIPC NETWORK LAYER 2959TIPC NETWORK LAYER
2945P: Per Liden 2960P: Per Liden
@@ -2989,12 +3004,12 @@ L: linux-kernel@vger.kernel.org
2989S: Maintained 3004S: Maintained
2990 3005
2991TRIVIAL PATCHES 3006TRIVIAL PATCHES
2992P: Adrian Bunk 3007P: Adrian Bunk
2993M: trivial@kernel.org 3008M: trivial@kernel.org
2994L: linux-kernel@vger.kernel.org 3009L: linux-kernel@vger.kernel.org
2995W: http://www.kernel.org/pub/linux/kernel/people/bunk/trivial/ 3010W: http://www.kernel.org/pub/linux/kernel/people/bunk/trivial/
2996T: git kernel.org:/pub/scm/linux/kernel/git/bunk/trivial.git 3011T: git kernel.org:/pub/scm/linux/kernel/git/bunk/trivial.git
2997S: Maintained 3012S: Maintained
2998 3013
2999TMS380 TOKEN-RING NETWORK DRIVER 3014TMS380 TOKEN-RING NETWORK DRIVER
3000P: Adam Fritzler 3015P: Adam Fritzler
diff --git a/Makefile b/Makefile
index 958fad6739b3..aef96259051f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 19 3SUBLEVEL = 19
4EXTRAVERSION =-rc6 4EXTRAVERSION =
5NAME=Avast! A bilge rat! 5NAME=Avast! A bilge rat!
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/lib/checksum.c b/arch/alpha/lib/checksum.c
index 89044e6385fe..ab3761c437a8 100644
--- a/arch/alpha/lib/checksum.c
+++ b/arch/alpha/lib/checksum.c
@@ -41,28 +41,25 @@ static inline unsigned short from64to16(unsigned long x)
41 * computes the checksum of the TCP/UDP pseudo-header 41 * computes the checksum of the TCP/UDP pseudo-header
42 * returns a 16-bit checksum, already complemented. 42 * returns a 16-bit checksum, already complemented.
43 */ 43 */
44unsigned short int csum_tcpudp_magic(unsigned long saddr, 44__sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
45 unsigned long daddr,
46 unsigned short len, 45 unsigned short len,
47 unsigned short proto, 46 unsigned short proto,
48 unsigned int sum) 47 __wsum sum)
49{ 48{
50 return ~from64to16(saddr + daddr + sum + 49 return (__force __sum16)~from64to16(
51 ((unsigned long) ntohs(len) << 16) + 50 (__force u64)saddr + (__force u64)daddr +
52 ((unsigned long) proto << 8)); 51 (__force u64)sum + ((len + proto) << 8));
53} 52}
54 53
55unsigned int csum_tcpudp_nofold(unsigned long saddr, 54__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
56 unsigned long daddr,
57 unsigned short len, 55 unsigned short len,
58 unsigned short proto, 56 unsigned short proto,
59 unsigned int sum) 57 __wsum sum)
60{ 58{
61 unsigned long result; 59 unsigned long result;
62 60
63 result = (saddr + daddr + sum + 61 result = (__force u64)saddr + (__force u64)daddr +
64 ((unsigned long) ntohs(len) << 16) + 62 (__force u64)sum + ((len + proto) << 8);
65 ((unsigned long) proto << 8));
66 63
67 /* Fold down to 32-bits so we don't lose in the typedef-less 64 /* Fold down to 32-bits so we don't lose in the typedef-less
68 network stack. */ 65 network stack. */
@@ -70,7 +67,7 @@ unsigned int csum_tcpudp_nofold(unsigned long saddr,
70 result = (result & 0xffffffff) + (result >> 32); 67 result = (result & 0xffffffff) + (result >> 32);
71 /* 33 to 32 */ 68 /* 33 to 32 */
72 result = (result & 0xffffffff) + (result >> 32); 69 result = (result & 0xffffffff) + (result >> 32);
73 return result; 70 return (__force __wsum)result;
74} 71}
75 72
76/* 73/*
@@ -146,9 +143,9 @@ out:
146 * This is a version of ip_compute_csum() optimized for IP headers, 143 * This is a version of ip_compute_csum() optimized for IP headers,
147 * which always checksum on 4 octet boundaries. 144 * which always checksum on 4 octet boundaries.
148 */ 145 */
149unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) 146__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
150{ 147{
151 return ~do_csum(iph,ihl*4); 148 return (__force __sum16)~do_csum(iph,ihl*4);
152} 149}
153 150
154/* 151/*
@@ -163,15 +160,15 @@ unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl)
163 * 160 *
164 * it's best to have buff aligned on a 32-bit boundary 161 * it's best to have buff aligned on a 32-bit boundary
165 */ 162 */
166unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) 163__wsum csum_partial(const void *buff, int len, __wsum sum)
167{ 164{
168 unsigned long result = do_csum(buff, len); 165 unsigned long result = do_csum(buff, len);
169 166
170 /* add in old sum, and carry.. */ 167 /* add in old sum, and carry.. */
171 result += sum; 168 result += (__force u32)sum;
172 /* 32+c bits -> 32 bits */ 169 /* 32+c bits -> 32 bits */
173 result = (result & 0xffffffff) + (result >> 32); 170 result = (result & 0xffffffff) + (result >> 32);
174 return result; 171 return (__force __wsum)result;
175} 172}
176 173
177EXPORT_SYMBOL(csum_partial); 174EXPORT_SYMBOL(csum_partial);
@@ -180,7 +177,7 @@ EXPORT_SYMBOL(csum_partial);
180 * this routine is used for miscellaneous IP-like checksums, mainly 177 * this routine is used for miscellaneous IP-like checksums, mainly
181 * in icmp.c 178 * in icmp.c
182 */ 179 */
183unsigned short ip_compute_csum(unsigned char * buff, int len) 180__sum16 ip_compute_csum(const void *buff, int len)
184{ 181{
185 return ~from64to16(do_csum(buff,len)); 182 return (__force __sum16)~from64to16(do_csum(buff,len));
186} 183}
diff --git a/arch/alpha/lib/csum_partial_copy.c b/arch/alpha/lib/csum_partial_copy.c
index a37948f3037a..4ca75c74ce90 100644
--- a/arch/alpha/lib/csum_partial_copy.c
+++ b/arch/alpha/lib/csum_partial_copy.c
@@ -329,11 +329,11 @@ csum_partial_cfu_unaligned(const unsigned long __user * src,
329 return checksum; 329 return checksum;
330} 330}
331 331
332static unsigned int 332__wsum
333do_csum_partial_copy_from_user(const char __user *src, char *dst, int len, 333csum_partial_copy_from_user(const void __user *src, void *dst, int len,
334 unsigned int sum, int *errp) 334 __wsum sum, int *errp)
335{ 335{
336 unsigned long checksum = (unsigned) sum; 336 unsigned long checksum = (__force u32) sum;
337 unsigned long soff = 7 & (unsigned long) src; 337 unsigned long soff = 7 & (unsigned long) src;
338 unsigned long doff = 7 & (unsigned long) dst; 338 unsigned long doff = 7 & (unsigned long) dst;
339 339
@@ -367,25 +367,12 @@ do_csum_partial_copy_from_user(const char __user *src, char *dst, int len,
367 } 367 }
368 checksum = from64to16 (checksum); 368 checksum = from64to16 (checksum);
369 } 369 }
370 return checksum; 370 return (__force __wsum)checksum;
371}
372
373unsigned int
374csum_partial_copy_from_user(const char __user *src, char *dst, int len,
375 unsigned int sum, int *errp)
376{
377 if (!access_ok(VERIFY_READ, src, len)) {
378 *errp = -EFAULT;
379 memset(dst, 0, len);
380 return sum;
381 }
382
383 return do_csum_partial_copy_from_user(src, dst, len, sum, errp);
384} 371}
385 372
386unsigned int 373__wsum
387csum_partial_copy_nocheck(const char __user *src, char *dst, int len, 374csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
388 unsigned int sum)
389{ 375{
390 return do_csum_partial_copy_from_user(src, dst, len, sum, NULL); 376 return csum_partial_copy_from_user((__force const void __user *)src,
377 dst, len, sum, NULL);
391} 378}
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index adb05de40e24..ce00c570459d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -879,6 +879,8 @@ endif
879 879
880source "drivers/scsi/Kconfig" 880source "drivers/scsi/Kconfig"
881 881
882source "drivers/ata/Kconfig"
883
882source "drivers/md/Kconfig" 884source "drivers/md/Kconfig"
883 885
884source "drivers/message/fusion/Kconfig" 886source "drivers/message/fusion/Kconfig"
diff --git a/arch/arm/configs/assabet_defconfig b/arch/arm/configs/assabet_defconfig
index 089c9d598409..b1cd331aaecf 100644
--- a/arch/arm/configs/assabet_defconfig
+++ b/arch/arm/configs/assabet_defconfig
@@ -184,6 +184,7 @@ CONFIG_BINFMT_ELF=y
184# Power management options 184# Power management options
185# 185#
186CONFIG_PM=y 186CONFIG_PM=y
187# CONFIG_PM_LEGACY is not set
187# CONFIG_APM is not set 188# CONFIG_APM is not set
188 189
189# 190#
diff --git a/arch/arm/configs/cerfcube_defconfig b/arch/arm/configs/cerfcube_defconfig
index f81a60005cd3..09b7acd7f647 100644
--- a/arch/arm/configs/cerfcube_defconfig
+++ b/arch/arm/configs/cerfcube_defconfig
@@ -194,6 +194,7 @@ CONFIG_BINFMT_ELF=y
194# Power management options 194# Power management options
195# 195#
196CONFIG_PM=y 196CONFIG_PM=y
197# CONFIG_PM_LEGACY is not set
197# CONFIG_APM is not set 198# CONFIG_APM is not set
198 199
199# 200#
diff --git a/arch/arm/configs/corgi_defconfig b/arch/arm/configs/corgi_defconfig
index 3c3461e83398..c41c04fa5020 100644
--- a/arch/arm/configs/corgi_defconfig
+++ b/arch/arm/configs/corgi_defconfig
@@ -208,6 +208,7 @@ CONFIG_BINFMT_MISC=m
208# Power management options 208# Power management options
209# 209#
210CONFIG_PM=y 210CONFIG_PM=y
211# CONFIG_PM_LEGACY is not set
211CONFIG_APM=y 212CONFIG_APM=y
212 213
213# 214#
diff --git a/arch/arm/configs/h3600_defconfig b/arch/arm/configs/h3600_defconfig
index 7a0da0b7facb..8f986e9f1c62 100644
--- a/arch/arm/configs/h3600_defconfig
+++ b/arch/arm/configs/h3600_defconfig
@@ -194,6 +194,7 @@ CONFIG_BINFMT_ELF=y
194# Power management options 194# Power management options
195# 195#
196CONFIG_PM=y 196CONFIG_PM=y
197# CONFIG_PM_LEGACY is not set
197# CONFIG_APM is not set 198# CONFIG_APM is not set
198 199
199# 200#
diff --git a/arch/arm/configs/integrator_defconfig b/arch/arm/configs/integrator_defconfig
index d1ba7fdde818..692ab57ba1ca 100644
--- a/arch/arm/configs/integrator_defconfig
+++ b/arch/arm/configs/integrator_defconfig
@@ -190,6 +190,7 @@ CONFIG_BINFMT_ELF=y
190# Power management options 190# Power management options
191# 191#
192CONFIG_PM=y 192CONFIG_PM=y
193# CONFIG_PM_LEGACY is not set
193# CONFIG_APM is not set 194# CONFIG_APM is not set
194 195
195# 196#
diff --git a/arch/arm/configs/jornada720_defconfig b/arch/arm/configs/jornada720_defconfig
index ad1048db96fb..80a6fd97eb32 100644
--- a/arch/arm/configs/jornada720_defconfig
+++ b/arch/arm/configs/jornada720_defconfig
@@ -182,6 +182,7 @@ CONFIG_BINFMT_AOUT=m
182# Power management options 182# Power management options
183# 183#
184CONFIG_PM=y 184CONFIG_PM=y
185# CONFIG_PM_LEGACY is not set
185# CONFIG_APM is not set 186# CONFIG_APM is not set
186 187
187# 188#
diff --git a/arch/arm/configs/lart_defconfig b/arch/arm/configs/lart_defconfig
index c3a932844160..a1cc34f25602 100644
--- a/arch/arm/configs/lart_defconfig
+++ b/arch/arm/configs/lart_defconfig
@@ -180,6 +180,7 @@ CONFIG_BINFMT_AOUT=y
180# Power management options 180# Power management options
181# 181#
182CONFIG_PM=y 182CONFIG_PM=y
183# CONFIG_PM_LEGACY is not set
183CONFIG_APM=m 184CONFIG_APM=m
184 185
185# 186#
diff --git a/arch/arm/configs/neponset_defconfig b/arch/arm/configs/neponset_defconfig
index 3d35255c64ed..df8168e57b7c 100644
--- a/arch/arm/configs/neponset_defconfig
+++ b/arch/arm/configs/neponset_defconfig
@@ -190,6 +190,7 @@ CONFIG_BINFMT_AOUT=y
190# Power management options 190# Power management options
191# 191#
192CONFIG_PM=y 192CONFIG_PM=y
193# CONFIG_PM_LEGACY is not set
193CONFIG_APM=y 194CONFIG_APM=y
194 195
195# 196#
diff --git a/arch/arm/configs/simpad_defconfig b/arch/arm/configs/simpad_defconfig
index 2e5a616cc98d..140056a3507f 100644
--- a/arch/arm/configs/simpad_defconfig
+++ b/arch/arm/configs/simpad_defconfig
@@ -180,6 +180,7 @@ CONFIG_BINFMT_MISC=m
180# Power management options 180# Power management options
181# 181#
182CONFIG_PM=y 182CONFIG_PM=y
183# CONFIG_PM_LEGACY is not set
183CONFIG_APM=y 184CONFIG_APM=y
184 185
185# 186#
diff --git a/arch/arm/configs/spitz_defconfig b/arch/arm/configs/spitz_defconfig
index d1ace3abfd8a..bd03238968c1 100644
--- a/arch/arm/configs/spitz_defconfig
+++ b/arch/arm/configs/spitz_defconfig
@@ -207,6 +207,7 @@ CONFIG_BINFMT_MISC=m
207# Power management options 207# Power management options
208# 208#
209CONFIG_PM=y 209CONFIG_PM=y
210# CONFIG_PM_LEGACY is not set
210CONFIG_APM=y 211CONFIG_APM=y
211 212
212# 213#
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index a07d202143c3..070bcb7a6306 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -451,6 +451,7 @@ int smp_call_function(void (*func)(void *info), void *info, int retry,
451 return smp_call_function_on_cpu(func, info, retry, wait, 451 return smp_call_function_on_cpu(func, info, retry, wait,
452 cpu_online_map); 452 cpu_online_map);
453} 453}
454EXPORT_SYMBOL_GPL(smp_call_function);
454 455
455void show_ipi_list(struct seq_file *p) 456void show_ipi_list(struct seq_file *p)
456{ 457{
diff --git a/arch/arm/mach-ebsa110/io.c b/arch/arm/mach-ebsa110/io.c
index c648bfb676a1..db38afb2aa88 100644
--- a/arch/arm/mach-ebsa110/io.c
+++ b/arch/arm/mach-ebsa110/io.c
@@ -28,7 +28,7 @@
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/page.h> 29#include <asm/page.h>
30 30
31static void __iomem *__isamem_convert_addr(void __iomem *addr) 31static void __iomem *__isamem_convert_addr(const volatile void __iomem *addr)
32{ 32{
33 u32 ret, a = (u32 __force) addr; 33 u32 ret, a = (u32 __force) addr;
34 34
@@ -63,7 +63,7 @@ static void __iomem *__isamem_convert_addr(void __iomem *addr)
63/* 63/*
64 * read[bwl] and write[bwl] 64 * read[bwl] and write[bwl]
65 */ 65 */
66u8 __readb(void __iomem *addr) 66u8 __readb(const volatile void __iomem *addr)
67{ 67{
68 void __iomem *a = __isamem_convert_addr(addr); 68 void __iomem *a = __isamem_convert_addr(addr);
69 u32 ret; 69 u32 ret;
@@ -75,7 +75,7 @@ u8 __readb(void __iomem *addr)
75 return ret; 75 return ret;
76} 76}
77 77
78u16 __readw(void __iomem *addr) 78u16 __readw(const volatile void __iomem *addr)
79{ 79{
80 void __iomem *a = __isamem_convert_addr(addr); 80 void __iomem *a = __isamem_convert_addr(addr);
81 81
@@ -85,7 +85,7 @@ u16 __readw(void __iomem *addr)
85 return __raw_readw(a); 85 return __raw_readw(a);
86} 86}
87 87
88u32 __readl(void __iomem *addr) 88u32 __readl(const volatile void __iomem *addr)
89{ 89{
90 void __iomem *a = __isamem_convert_addr(addr); 90 void __iomem *a = __isamem_convert_addr(addr);
91 u32 ret; 91 u32 ret;
diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig
index 57f23b465392..e316bd93313f 100644
--- a/arch/arm/mach-ixp4xx/Kconfig
+++ b/arch/arm/mach-ixp4xx/Kconfig
@@ -133,7 +133,7 @@ config IXP4XX_INDIRECT_PCI
133 into the kernel and we can use the standard read[bwl]/write[bwl] 133 into the kernel and we can use the standard read[bwl]/write[bwl]
134 macros. This is the preferred method due to speed but it 134 macros. This is the preferred method due to speed but it
135 limits the system to just 64MB of PCI memory. This can be 135 limits the system to just 64MB of PCI memory. This can be
136 problamatic if using video cards and other memory-heavy devices. 136 problematic if using video cards and other memory-heavy devices.
137 137
138 2) If > 64MB of memory space is required, the IXP4xx can be 138 2) If > 64MB of memory space is required, the IXP4xx can be
139 configured to use indirect registers to access PCI This allows 139 configured to use indirect registers to access PCI This allows
diff --git a/arch/arm/mach-lh7a40x/Kconfig b/arch/arm/mach-lh7a40x/Kconfig
index 147b01928a9b..6f4c6a1798c1 100644
--- a/arch/arm/mach-lh7a40x/Kconfig
+++ b/arch/arm/mach-lh7a40x/Kconfig
@@ -8,7 +8,7 @@ config MACH_KEV7A400
8 help 8 help
9 Say Y here if you are using the Sharp KEV7A400 development 9 Say Y here if you are using the Sharp KEV7A400 development
10 board. This hardware is discontinued, so I'd be very 10 board. This hardware is discontinued, so I'd be very
11 suprised if you wanted this option. 11 surprised if you wanted this option.
12 12
13config MACH_LPD7A400 13config MACH_LPD7A400
14 bool "LPD7A400 Card Engine" 14 bool "LPD7A400 Card Engine"
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
index 63965c78de8c..9aa26b99045d 100644
--- a/arch/arm/mach-s3c2410/Kconfig
+++ b/arch/arm/mach-s3c2410/Kconfig
@@ -91,7 +91,7 @@ config SMDK2440_CPU2442
91config MACH_S3C2413 91config MACH_S3C2413
92 bool 92 bool
93 help 93 help
94 Internal node for S3C2413 verison of SMDK2413, so that 94 Internal node for S3C2413 version of SMDK2413, so that
95 machine_is_s3c2413() will work when MACH_SMDK2413 is 95 machine_is_s3c2413() will work when MACH_SMDK2413 is
96 selected 96 selected
97 97
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index c0bfb8212b77..b09a19f87d68 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -197,7 +197,7 @@ config CPU_ARM940T
197 select CPU_CP15_MPU 197 select CPU_CP15_MPU
198 help 198 help
199 ARM940T is a member of the ARM9TDMI family of general- 199 ARM940T is a member of the ARM9TDMI family of general-
200 purpose microprocessors with MPU and seperate 4KB 200 purpose microprocessors with MPU and separate 4KB
201 instruction and 4KB data cases, each with a 4-word line 201 instruction and 4KB data cases, each with a 4-word line
202 length. 202 length.
203 203
diff --git a/arch/arm/mm/consistent.c b/arch/arm/mm/consistent.c
index 50e6b6bfb2e2..b797217e82be 100644
--- a/arch/arm/mm/consistent.c
+++ b/arch/arm/mm/consistent.c
@@ -476,6 +476,9 @@ core_initcall(consistent_init);
476 476
477/* 477/*
478 * Make an area consistent for devices. 478 * Make an area consistent for devices.
479 * Note: Drivers should NOT use this function directly, as it will break
480 * platforms with CONFIG_DMABOUNCE.
481 * Use the driver DMA support - see dma-mapping.h (dma_sync_*)
479 */ 482 */
480void consistent_sync(void *vaddr, size_t size, int direction) 483void consistent_sync(void *vaddr, size_t size, int direction)
481{ 484{
diff --git a/arch/cris/arch-v10/Kconfig b/arch/cris/arch-v10/Kconfig
index 44eb1b9accb3..c7ea9efd0104 100644
--- a/arch/cris/arch-v10/Kconfig
+++ b/arch/cris/arch-v10/Kconfig
@@ -323,7 +323,7 @@ config ETRAX_DEF_R_WAITSTATES
323 depends on ETRAX_ARCH_V10 323 depends on ETRAX_ARCH_V10
324 default "95a6" 324 default "95a6"
325 help 325 help
326 Waitstates for SRAM, Flash and peripherials (not DRAM). 95f8 is a 326 Waitstates for SRAM, Flash and peripherals (not DRAM). 95f8 is a
327 good choice for most Axis products... 327 good choice for most Axis products...
328 328
329config ETRAX_DEF_R_BUS_CONFIG 329config ETRAX_DEF_R_BUS_CONFIG
diff --git a/arch/cris/arch-v10/drivers/Kconfig b/arch/cris/arch-v10/drivers/Kconfig
index 734d5f3a5304..e7e724bc0ba6 100644
--- a/arch/cris/arch-v10/drivers/Kconfig
+++ b/arch/cris/arch-v10/drivers/Kconfig
@@ -839,7 +839,7 @@ config ETRAX_DS1302_TRICKLE_CHARGE
839 default "0" 839 default "0"
840 help 840 help
841 This controls the initial value of the trickle charge register. 841 This controls the initial value of the trickle charge register.
842 0 = disabled (use this if you are unsure or have a non rechargable battery) 842 0 = disabled (use this if you are unsure or have a non rechargeable battery)
843 Otherwise the following values can be OR:ed together to control the 843 Otherwise the following values can be OR:ed together to control the
844 charge current: 844 charge current:
845 1 = 2kohm, 2 = 4kohm, 3 = 4kohm 845 1 = 2kohm, 2 = 4kohm, 3 = 4kohm
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c
index 6e1f191a71e3..284ebfda03f0 100644
--- a/arch/cris/arch-v10/drivers/eeprom.c
+++ b/arch/cris/arch-v10/drivers/eeprom.c
@@ -1,7 +1,7 @@
1/*!***************************************************************************** 1/*!*****************************************************************************
2*! 2*!
3*! Implements an interface for i2c compatible eeproms to run under linux. 3*! Implements an interface for i2c compatible eeproms to run under Linux.
4*! Supports 2k, 8k(?) and 16k. Uses adaptive timing adjustents by 4*! Supports 2k, 8k(?) and 16k. Uses adaptive timing adjustments by
5*! Johan.Adolfsson@axis.com 5*! Johan.Adolfsson@axis.com
6*! 6*!
7*! Probing results: 7*! Probing results:
@@ -51,7 +51,7 @@
51*! Revision 1.8 2001/06/15 13:24:29 jonashg 51*! Revision 1.8 2001/06/15 13:24:29 jonashg
52*! * Added verification of pointers from userspace in read and write. 52*! * Added verification of pointers from userspace in read and write.
53*! * Made busy counter volatile. 53*! * Made busy counter volatile.
54*! * Added define for inital write delay. 54*! * Added define for initial write delay.
55*! * Removed warnings by using loff_t instead of unsigned long. 55*! * Removed warnings by using loff_t instead of unsigned long.
56*! 56*!
57*! Revision 1.7 2001/06/14 15:26:54 jonashg 57*! Revision 1.7 2001/06/14 15:26:54 jonashg
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c
index 6114596c3b33..092c724a645f 100644
--- a/arch/cris/arch-v10/drivers/i2c.c
+++ b/arch/cris/arch-v10/drivers/i2c.c
@@ -47,7 +47,7 @@
47*! Update Port B register and shadow even when running with hardware support 47*! Update Port B register and shadow even when running with hardware support
48*! to avoid glitches when reading bits 48*! to avoid glitches when reading bits
49*! Never set direction to out in i2c_inbyte 49*! Never set direction to out in i2c_inbyte
50*! Removed incorrect clock togling at end of i2c_inbyte 50*! Removed incorrect clock toggling at end of i2c_inbyte
51*! 51*!
52*! Revision 1.8 2002/08/13 06:31:53 starvik 52*! Revision 1.8 2002/08/13 06:31:53 starvik
53*! Made SDA and SCL line configurable 53*! Made SDA and SCL line configurable
diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c
index 34528da98817..07628a13c6c4 100644
--- a/arch/cris/arch-v10/kernel/kgdb.c
+++ b/arch/cris/arch-v10/kernel/kgdb.c
@@ -33,7 +33,7 @@
33*! 33*!
34*! Revision 1.2 2002/11/19 14:35:24 starvik 34*! Revision 1.2 2002/11/19 14:35:24 starvik
35*! Changes from linux 2.4 35*! Changes from linux 2.4
36*! Changed struct initializer syntax to the currently prefered notation 36*! Changed struct initializer syntax to the currently preferred notation
37*! 37*!
38*! Revision 1.1 2001/12/17 13:59:27 bjornw 38*! Revision 1.1 2001/12/17 13:59:27 bjornw
39*! Initial revision 39*! Initial revision
diff --git a/arch/cris/arch-v10/lib/old_checksum.c b/arch/cris/arch-v10/lib/old_checksum.c
index 22a6f0aa9cef..497634a64829 100644
--- a/arch/cris/arch-v10/lib/old_checksum.c
+++ b/arch/cris/arch-v10/lib/old_checksum.c
@@ -47,39 +47,41 @@
47 47
48#include <asm/delay.h> 48#include <asm/delay.h>
49 49
50unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) 50__wsum csum_partial(const void *p, int len, __wsum __sum)
51{ 51{
52 /* 52 u32 sum = (__force u32)__sum;
53 * Experiments with ethernet and slip connections show that buff 53 const u16 *buff = p;
54 * is aligned on either a 2-byte or 4-byte boundary. 54 /*
55 */ 55 * Experiments with ethernet and slip connections show that buff
56 const unsigned char *endMarker = buff + len; 56 * is aligned on either a 2-byte or 4-byte boundary.
57 const unsigned char *marker = endMarker - (len % 16); 57 */
58 const void *endMarker = p + len;
59 const void *marker = endMarker - (len % 16);
58#if 0 60#if 0
59 if((int)buff & 0x3) 61 if((int)buff & 0x3)
60 printk("unaligned buff %p\n", buff); 62 printk("unaligned buff %p\n", buff);
61 __delay(900); /* extra delay of 90 us to test performance hit */ 63 __delay(900); /* extra delay of 90 us to test performance hit */
62#endif 64#endif
63 BITON; 65 BITON;
64 while (buff < marker) { 66 while (buff < marker) {
65 sum += *((unsigned short *)buff)++; 67 sum += *buff++;
66 sum += *((unsigned short *)buff)++; 68 sum += *buff++;
67 sum += *((unsigned short *)buff)++; 69 sum += *buff++;
68 sum += *((unsigned short *)buff)++; 70 sum += *buff++;
69 sum += *((unsigned short *)buff)++; 71 sum += *buff++;
70 sum += *((unsigned short *)buff)++; 72 sum += *buff++;
71 sum += *((unsigned short *)buff)++; 73 sum += *buff++;
72 sum += *((unsigned short *)buff)++; 74 sum += *buff++;
73 } 75 }
74 marker = endMarker - (len % 2); 76 marker = endMarker - (len % 2);
75 while(buff < marker) { 77 while (buff < marker)
76 sum += *((unsigned short *)buff)++; 78 sum += *buff++;
77 } 79
78 if(endMarker - buff > 0) { 80 if (endMarker > buff)
79 sum += *buff; /* add extra byte seperately */ 81 sum += *(const u8 *)buff; /* add extra byte seperately */
80 } 82
81 BITOFF; 83 BITOFF;
82 return(sum); 84 return (__force __wsum)sum;
83} 85}
84 86
85EXPORT_SYMBOL(csum_partial); 87EXPORT_SYMBOL(csum_partial);
diff --git a/arch/cris/arch-v32/drivers/Kconfig b/arch/cris/arch-v32/drivers/Kconfig
index a33097f95362..f64624fc4504 100644
--- a/arch/cris/arch-v32/drivers/Kconfig
+++ b/arch/cris/arch-v32/drivers/Kconfig
@@ -88,7 +88,7 @@ config ETRAX_SERIAL_PORT0_DMA7_IN
88 help 88 help
89 Enables the DMA7 input channel for ser0 (ttyS0). 89 Enables the DMA7 input channel for ser0 (ttyS0).
90 If you do not enable DMA, an interrupt for each character will be 90 If you do not enable DMA, an interrupt for each character will be
91 used when receiveing data. 91 used when receiving data.
92 Normally you want to use DMA, unless you use the DMA channel for 92 Normally you want to use DMA, unless you use the DMA channel for
93 something else. 93 something else.
94 94
@@ -157,7 +157,7 @@ config ETRAX_SERIAL_PORT1_DMA5_IN
157 help 157 help
158 Enables the DMA5 input channel for ser1 (ttyS1). 158 Enables the DMA5 input channel for ser1 (ttyS1).
159 If you do not enable DMA, an interrupt for each character will be 159 If you do not enable DMA, an interrupt for each character will be
160 used when receiveing data. 160 used when receiving data.
161 Normally you want this on, unless you use the DMA channel for 161 Normally you want this on, unless you use the DMA channel for
162 something else. 162 something else.
163 163
@@ -228,7 +228,7 @@ config ETRAX_SERIAL_PORT2_DMA3_IN
228 help 228 help
229 Enables the DMA3 input channel for ser2 (ttyS2). 229 Enables the DMA3 input channel for ser2 (ttyS2).
230 If you do not enable DMA, an interrupt for each character will be 230 If you do not enable DMA, an interrupt for each character will be
231 used when receiveing data. 231 used when receiving data.
232 Normally you want to use DMA, unless you use the DMA channel for 232 Normally you want to use DMA, unless you use the DMA channel for
233 something else. 233 something else.
234 234
@@ -297,7 +297,7 @@ config ETRAX_SERIAL_PORT3_DMA9_IN
297 help 297 help
298 Enables the DMA9 input channel for ser3 (ttyS3). 298 Enables the DMA9 input channel for ser3 (ttyS3).
299 If you do not enable DMA, an interrupt for each character will be 299 If you do not enable DMA, an interrupt for each character will be
300 used when receiveing data. 300 used when receiving data.
301 Normally you want to use DMA, unless you use the DMA channel for 301 Normally you want to use DMA, unless you use the DMA channel for
302 something else. 302 something else.
303 303
diff --git a/arch/frv/lib/checksum.c b/arch/frv/lib/checksum.c
index 20e7dfc474ef..44e16d59bc10 100644
--- a/arch/frv/lib/checksum.c
+++ b/arch/frv/lib/checksum.c
@@ -32,7 +32,6 @@
32 of the assembly has to go. */ 32 of the assembly has to go. */
33 33
34#include <net/checksum.h> 34#include <net/checksum.h>
35#include <asm/checksum.h>
36#include <linux/module.h> 35#include <linux/module.h>
37 36
38static inline unsigned short from32to16(unsigned long x) 37static inline unsigned short from32to16(unsigned long x)
@@ -105,15 +104,15 @@ out:
105 * 104 *
106 * it's best to have buff aligned on a 32-bit boundary 105 * it's best to have buff aligned on a 32-bit boundary
107 */ 106 */
108unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) 107__wsum csum_partial(const void *buff, int len, __wsum sum)
109{ 108{
110 unsigned int result = do_csum(buff, len); 109 unsigned int result = do_csum(buff, len);
111 110
112 /* add in old sum, and carry.. */ 111 /* add in old sum, and carry.. */
113 result += sum; 112 result += (__force u32)sum;
114 if (sum > result) 113 if ((__force u32)sum > result)
115 result += 1; 114 result += 1;
116 return result; 115 return (__force __wsum)result;
117} 116}
118 117
119EXPORT_SYMBOL(csum_partial); 118EXPORT_SYMBOL(csum_partial);
@@ -122,9 +121,9 @@ EXPORT_SYMBOL(csum_partial);
122 * this routine is used for miscellaneous IP-like checksums, mainly 121 * this routine is used for miscellaneous IP-like checksums, mainly
123 * in icmp.c 122 * in icmp.c
124 */ 123 */
125unsigned short ip_compute_csum(const unsigned char * buff, int len) 124__sum16 ip_compute_csum(const void *buff, int len)
126{ 125{
127 return ~do_csum(buff, len); 126 return (__force __sum16)~do_csum(buff, len);
128} 127}
129 128
130EXPORT_SYMBOL(ip_compute_csum); 129EXPORT_SYMBOL(ip_compute_csum);
@@ -132,9 +131,9 @@ EXPORT_SYMBOL(ip_compute_csum);
132/* 131/*
133 * copy from fs while checksumming, otherwise like csum_partial 132 * copy from fs while checksumming, otherwise like csum_partial
134 */ 133 */
135unsigned int 134__wsum
136csum_partial_copy_from_user(const char __user *src, char *dst, 135csum_partial_copy_from_user(const void __user *src, void *dst,
137 int len, int sum, int *csum_err) 136 int len, __wsum sum, int *csum_err)
138{ 137{
139 int rem; 138 int rem;
140 139
@@ -157,11 +156,11 @@ EXPORT_SYMBOL(csum_partial_copy_from_user);
157/* 156/*
158 * copy from ds while checksumming, otherwise like csum_partial 157 * copy from ds while checksumming, otherwise like csum_partial
159 */ 158 */
160unsigned int 159__wsum
161csum_partial_copy(const char *src, char *dst, int len, int sum) 160csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
162{ 161{
163 memcpy(dst, src, len); 162 memcpy(dst, src, len);
164 return csum_partial(dst, len, sum); 163 return csum_partial(dst, len, sum);
165} 164}
166 165
167EXPORT_SYMBOL(csum_partial_copy); 166EXPORT_SYMBOL(csum_partial_copy_nocheck);
diff --git a/arch/h8300/kernel/h8300_ksyms.c b/arch/h8300/kernel/h8300_ksyms.c
index 9b4be053de3c..d1b15267ac81 100644
--- a/arch/h8300/kernel/h8300_ksyms.c
+++ b/arch/h8300/kernel/h8300_ksyms.c
@@ -39,7 +39,7 @@ EXPORT_SYMBOL(enable_irq);
39EXPORT_SYMBOL(disable_irq); 39EXPORT_SYMBOL(disable_irq);
40 40
41/* Networking helper routines. */ 41/* Networking helper routines. */
42EXPORT_SYMBOL(csum_partial_copy); 42EXPORT_SYMBOL(csum_partial_copy_nocheck);
43 43
44/* The following are special because they're not called 44/* The following are special because they're not called
45 explicitly (the C compiler generates them). Fortunately, 45 explicitly (the C compiler generates them). Fortunately,
diff --git a/arch/h8300/lib/checksum.c b/arch/h8300/lib/checksum.c
index 5aa688d9242d..bdc5b032acd6 100644
--- a/arch/h8300/lib/checksum.c
+++ b/arch/h8300/lib/checksum.c
@@ -96,9 +96,9 @@ out:
96 * This is a version of ip_compute_csum() optimized for IP headers, 96 * This is a version of ip_compute_csum() optimized for IP headers,
97 * which always checksum on 4 octet boundaries. 97 * which always checksum on 4 octet boundaries.
98 */ 98 */
99unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) 99__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
100{ 100{
101 return ~do_csum(iph,ihl*4); 101 return (__force __sum16)~do_csum(iph,ihl*4);
102} 102}
103 103
104/* 104/*
@@ -113,15 +113,19 @@ unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl)
113 * 113 *
114 * it's best to have buff aligned on a 32-bit boundary 114 * it's best to have buff aligned on a 32-bit boundary
115 */ 115 */
116unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) 116/*
117 * Egads... That thing apparently assumes that *all* checksums it ever sees will
118 * be folded. Very likely a bug.
119 */
120__wsum csum_partial(const void *buff, int len, __wsum sum)
117{ 121{
118 unsigned int result = do_csum(buff, len); 122 unsigned int result = do_csum(buff, len);
119 123
120 /* add in old sum, and carry.. */ 124 /* add in old sum, and carry.. */
121 result += sum; 125 result += (__force u32)sum;
122 /* 16+c bits -> 16 bits */ 126 /* 16+c bits -> 16 bits */
123 result = (result & 0xffff) + (result >> 16); 127 result = (result & 0xffff) + (result >> 16);
124 return result; 128 return (__force __wsum)result;
125} 129}
126 130
127EXPORT_SYMBOL(csum_partial); 131EXPORT_SYMBOL(csum_partial);
@@ -130,20 +134,21 @@ EXPORT_SYMBOL(csum_partial);
130 * this routine is used for miscellaneous IP-like checksums, mainly 134 * this routine is used for miscellaneous IP-like checksums, mainly
131 * in icmp.c 135 * in icmp.c
132 */ 136 */
133unsigned short ip_compute_csum(const unsigned char * buff, int len) 137__sum16 ip_compute_csum(const void *buff, int len)
134{ 138{
135 return ~do_csum(buff,len); 139 return (__force __sum16)~do_csum(buff,len);
136} 140}
137 141
138/* 142/*
139 * copy from fs while checksumming, otherwise like csum_partial 143 * copy from fs while checksumming, otherwise like csum_partial
140 */ 144 */
141 145
142unsigned int 146__wsum
143csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *csum_err) 147csum_partial_copy_from_user(const void __user *src, void *dst, int len,
148 __wsum sum, int *csum_err)
144{ 149{
145 if (csum_err) *csum_err = 0; 150 if (csum_err) *csum_err = 0;
146 memcpy(dst, src, len); 151 memcpy(dst, (__force const void *)src, len);
147 return csum_partial(dst, len, sum); 152 return csum_partial(dst, len, sum);
148} 153}
149 154
@@ -151,8 +156,8 @@ csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *c
151 * copy from ds while checksumming, otherwise like csum_partial 156 * copy from ds while checksumming, otherwise like csum_partial
152 */ 157 */
153 158
154unsigned int 159__wsum
155csum_partial_copy(const char *src, char *dst, int len, int sum) 160csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
156{ 161{
157 memcpy(dst, src, len); 162 memcpy(dst, src, len);
158 return csum_partial(dst, len, sum); 163 return csum_partial(dst, len, sum);
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index d12fb97a5337..c8f96cff07c6 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -333,7 +333,7 @@ acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end)
333/* 333/*
334 * Parse Interrupt Source Override for the ACPI SCI 334 * Parse Interrupt Source Override for the ACPI SCI
335 */ 335 */
336static void acpi_sci_ioapic_setup(u32 bus_irq, u32 gsi, u16 polarity, u16 trigger) 336static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger)
337{ 337{
338 if (trigger == 0) /* compatible SCI trigger is level */ 338 if (trigger == 0) /* compatible SCI trigger is level */
339 trigger = 3; 339 trigger = 3;
@@ -353,13 +353,13 @@ static void acpi_sci_ioapic_setup(u32 bus_irq, u32 gsi, u16 polarity, u16 trigge
353 * If GSI is < 16, this will update its flags, 353 * If GSI is < 16, this will update its flags,
354 * else it will create a new mp_irqs[] entry. 354 * else it will create a new mp_irqs[] entry.
355 */ 355 */
356 mp_override_legacy_irq(bus_irq, polarity, trigger, gsi); 356 mp_override_legacy_irq(gsi, polarity, trigger, gsi);
357 357
358 /* 358 /*
359 * stash over-ride to indicate we've been here 359 * stash over-ride to indicate we've been here
360 * and for later update of acpi_fadt 360 * and for later update of acpi_fadt
361 */ 361 */
362 acpi_sci_override_gsi = bus_irq; 362 acpi_sci_override_gsi = gsi;
363 return; 363 return;
364} 364}
365 365
@@ -377,7 +377,7 @@ acpi_parse_int_src_ovr(acpi_table_entry_header * header,
377 acpi_table_print_madt_entry(header); 377 acpi_table_print_madt_entry(header);
378 378
379 if (intsrc->bus_irq == acpi_fadt.sci_int) { 379 if (intsrc->bus_irq == acpi_fadt.sci_int) {
380 acpi_sci_ioapic_setup(intsrc->bus_irq, intsrc->global_irq, 380 acpi_sci_ioapic_setup(intsrc->global_irq,
381 intsrc->flags.polarity, 381 intsrc->flags.polarity,
382 intsrc->flags.trigger); 382 intsrc->flags.trigger);
383 return 0; 383 return 0;
@@ -880,7 +880,7 @@ static int __init acpi_parse_madt_ioapic_entries(void)
880 * pretend we got one so we can set the SCI flags. 880 * pretend we got one so we can set the SCI flags.
881 */ 881 */
882 if (!acpi_sci_override_gsi) 882 if (!acpi_sci_override_gsi)
883 acpi_sci_ioapic_setup(acpi_fadt.sci_int, acpi_fadt.sci_int, 0, 0); 883 acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0);
884 884
885 /* Fill in identity legacy mapings where no override */ 885 /* Fill in identity legacy mapings where no override */
886 mp_config_acpi_legacy_irqs(); 886 mp_config_acpi_legacy_irqs();
diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
index fde8bea85cee..ab0c327e79dc 100644
--- a/arch/i386/kernel/cpuid.c
+++ b/arch/i386/kernel/cpuid.c
@@ -156,14 +156,14 @@ static struct file_operations cpuid_fops = {
156 .open = cpuid_open, 156 .open = cpuid_open,
157}; 157};
158 158
159static int cpuid_class_device_create(int i) 159static int cpuid_device_create(int i)
160{ 160{
161 int err = 0; 161 int err = 0;
162 struct class_device *class_err; 162 struct device *dev;
163 163
164 class_err = class_device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), NULL, "cpu%d",i); 164 dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, i), "cpu%d",i);
165 if (IS_ERR(class_err)) 165 if (IS_ERR(dev))
166 err = PTR_ERR(class_err); 166 err = PTR_ERR(dev);
167 return err; 167 return err;
168} 168}
169 169
@@ -174,10 +174,10 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long ac
174 174
175 switch (action) { 175 switch (action) {
176 case CPU_ONLINE: 176 case CPU_ONLINE:
177 cpuid_class_device_create(cpu); 177 cpuid_device_create(cpu);
178 break; 178 break;
179 case CPU_DEAD: 179 case CPU_DEAD:
180 class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); 180 device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
181 break; 181 break;
182 } 182 }
183 return NOTIFY_OK; 183 return NOTIFY_OK;
@@ -206,7 +206,7 @@ static int __init cpuid_init(void)
206 goto out_chrdev; 206 goto out_chrdev;
207 } 207 }
208 for_each_online_cpu(i) { 208 for_each_online_cpu(i) {
209 err = cpuid_class_device_create(i); 209 err = cpuid_device_create(i);
210 if (err != 0) 210 if (err != 0)
211 goto out_class; 211 goto out_class;
212 } 212 }
@@ -218,7 +218,7 @@ static int __init cpuid_init(void)
218out_class: 218out_class:
219 i = 0; 219 i = 0;
220 for_each_online_cpu(i) { 220 for_each_online_cpu(i) {
221 class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i)); 221 device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, i));
222 } 222 }
223 class_destroy(cpuid_class); 223 class_destroy(cpuid_class);
224out_chrdev: 224out_chrdev:
@@ -232,7 +232,7 @@ static void __exit cpuid_exit(void)
232 int cpu = 0; 232 int cpu = 0;
233 233
234 for_each_online_cpu(cpu) 234 for_each_online_cpu(cpu)
235 class_device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); 235 device_destroy(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
236 class_destroy(cpuid_class); 236 class_destroy(cpuid_class);
237 unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); 237 unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
238 unregister_hotcpu_notifier(&cpuid_class_cpu_notifier); 238 unregister_hotcpu_notifier(&cpuid_class_cpu_notifier);
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index d535cdbbfd25..a773f776c9ea 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -239,14 +239,14 @@ static struct file_operations msr_fops = {
239 .open = msr_open, 239 .open = msr_open,
240}; 240};
241 241
242static int msr_class_device_create(int i) 242static int msr_device_create(int i)
243{ 243{
244 int err = 0; 244 int err = 0;
245 struct class_device *class_err; 245 struct device *dev;
246 246
247 class_err = class_device_create(msr_class, NULL, MKDEV(MSR_MAJOR, i), NULL, "msr%d",i); 247 dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, i), "msr%d",i);
248 if (IS_ERR(class_err)) 248 if (IS_ERR(dev))
249 err = PTR_ERR(class_err); 249 err = PTR_ERR(dev);
250 return err; 250 return err;
251} 251}
252 252
@@ -258,10 +258,10 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
258 258
259 switch (action) { 259 switch (action) {
260 case CPU_ONLINE: 260 case CPU_ONLINE:
261 msr_class_device_create(cpu); 261 msr_device_create(cpu);
262 break; 262 break;
263 case CPU_DEAD: 263 case CPU_DEAD:
264 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu)); 264 device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
265 break; 265 break;
266 } 266 }
267 return NOTIFY_OK; 267 return NOTIFY_OK;
@@ -290,7 +290,7 @@ static int __init msr_init(void)
290 goto out_chrdev; 290 goto out_chrdev;
291 } 291 }
292 for_each_online_cpu(i) { 292 for_each_online_cpu(i) {
293 err = msr_class_device_create(i); 293 err = msr_device_create(i);
294 if (err != 0) 294 if (err != 0)
295 goto out_class; 295 goto out_class;
296 } 296 }
@@ -302,7 +302,7 @@ static int __init msr_init(void)
302out_class: 302out_class:
303 i = 0; 303 i = 0;
304 for_each_online_cpu(i) 304 for_each_online_cpu(i)
305 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, i)); 305 device_destroy(msr_class, MKDEV(MSR_MAJOR, i));
306 class_destroy(msr_class); 306 class_destroy(msr_class);
307out_chrdev: 307out_chrdev:
308 unregister_chrdev(MSR_MAJOR, "cpu/msr"); 308 unregister_chrdev(MSR_MAJOR, "cpu/msr");
@@ -314,7 +314,7 @@ static void __exit msr_exit(void)
314{ 314{
315 int cpu = 0; 315 int cpu = 0;
316 for_each_online_cpu(cpu) 316 for_each_online_cpu(cpu)
317 class_device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu)); 317 device_destroy(msr_class, MKDEV(MSR_MAJOR, cpu));
318 class_destroy(msr_class); 318 class_destroy(msr_class);
319 unregister_chrdev(MSR_MAJOR, "cpu/msr"); 319 unregister_chrdev(MSR_MAJOR, "cpu/msr");
320 unregister_hotcpu_notifier(&msr_class_cpu_notifier); 320 unregister_hotcpu_notifier(&msr_class_cpu_notifier);
diff --git a/arch/i386/kernel/pci-dma.c b/arch/i386/kernel/pci-dma.c
index 25fe66853934..5c8c6ef1fc5e 100644
--- a/arch/i386/kernel/pci-dma.c
+++ b/arch/i386/kernel/pci-dma.c
@@ -75,7 +75,7 @@ EXPORT_SYMBOL(dma_free_coherent);
75int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr, 75int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
76 dma_addr_t device_addr, size_t size, int flags) 76 dma_addr_t device_addr, size_t size, int flags)
77{ 77{
78 void __iomem *mem_base; 78 void __iomem *mem_base = NULL;
79 int pages = size >> PAGE_SHIFT; 79 int pages = size >> PAGE_SHIFT;
80 int bitmap_size = (pages + 31)/32; 80 int bitmap_size = (pages + 31)/32;
81 81
@@ -114,6 +114,8 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
114 free1_out: 114 free1_out:
115 kfree(dev->dma_mem->bitmap); 115 kfree(dev->dma_mem->bitmap);
116 out: 116 out:
117 if (mem_base)
118 iounmap(mem_base);
117 return 0; 119 return 0;
118} 120}
119EXPORT_SYMBOL(dma_declare_coherent_memory); 121EXPORT_SYMBOL(dma_declare_coherent_memory);
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
index cdfcf971098b..53ca6e897984 100644
--- a/arch/i386/pci/common.c
+++ b/arch/i386/pci/common.c
@@ -20,7 +20,7 @@
20unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 | 20unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
21 PCI_PROBE_MMCONF; 21 PCI_PROBE_MMCONF;
22 22
23int pci_bf_sort; 23static int pci_bf_sort;
24int pci_routeirq; 24int pci_routeirq;
25int pcibios_last_bus = -1; 25int pcibios_last_bus = -1;
26unsigned long pirq_table_addr; 26unsigned long pirq_table_addr;
diff --git a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
index c1949ff38d61..cde1170b01a1 100644
--- a/arch/i386/pci/fixup.c
+++ b/arch/i386/pci/fixup.c
@@ -74,52 +74,6 @@ static void __devinit pci_fixup_ncr53c810(struct pci_dev *d)
74} 74}
75DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, pci_fixup_ncr53c810); 75DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, pci_fixup_ncr53c810);
76 76
77static void __devinit pci_fixup_ide_bases(struct pci_dev *d)
78{
79 int i;
80
81 /*
82 * PCI IDE controllers use non-standard I/O port decoding, respect it.
83 */
84 if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
85 return;
86 DBG("PCI: IDE base address fixup for %s\n", pci_name(d));
87 for(i=0; i<4; i++) {
88 struct resource *r = &d->resource[i];
89 if ((r->start & ~0x80) == 0x374) {
90 r->start |= 2;
91 r->end = r->start;
92 }
93 }
94}
95DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_ide_bases);
96
97static void __devinit pci_fixup_ide_trash(struct pci_dev *d)
98{
99 int i;
100
101 /*
102 * Runs the fixup only for the first IDE controller
103 * (Shai Fultheim - shai@ftcon.com)
104 */
105 static int called = 0;
106 if (called)
107 return;
108 called = 1;
109
110 /*
111 * There exist PCI IDE controllers which have utter garbage
112 * in first four base registers. Ignore that.
113 */
114 DBG("PCI: IDE base address trash cleared for %s\n", pci_name(d));
115 for(i=0; i<4; i++)
116 d->resource[i].start = d->resource[i].end = d->resource[i].flags = 0;
117}
118DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5513, pci_fixup_ide_trash);
119DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, pci_fixup_ide_trash);
120DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_11, pci_fixup_ide_trash);
121DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_9, pci_fixup_ide_trash);
122
123static void __devinit pci_fixup_latency(struct pci_dev *d) 77static void __devinit pci_fixup_latency(struct pci_dev *d)
124{ 78{
125 /* 79 /*
diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c
index 98580292f0d4..43005f044424 100644
--- a/arch/i386/pci/i386.c
+++ b/arch/i386/pci/i386.c
@@ -104,16 +104,24 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
104 /* Depth-First Search on bus tree */ 104 /* Depth-First Search on bus tree */
105 list_for_each_entry(bus, bus_list, node) { 105 list_for_each_entry(bus, bus_list, node) {
106 if ((dev = bus->self)) { 106 if ((dev = bus->self)) {
107 for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { 107 for (idx = PCI_BRIDGE_RESOURCES;
108 idx < PCI_NUM_RESOURCES; idx++) {
108 r = &dev->resource[idx]; 109 r = &dev->resource[idx];
109 if (!r->flags) 110 if (!r->flags)
110 continue; 111 continue;
111 pr = pci_find_parent_resource(dev, r); 112 pr = pci_find_parent_resource(dev, r);
112 if (!r->start || !pr || request_resource(pr, r) < 0) { 113 if (!r->start || !pr ||
113 printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev)); 114 request_resource(pr, r) < 0) {
114 /* Something is wrong with the region. 115 printk(KERN_ERR "PCI: Cannot allocate "
115 Invalidate the resource to prevent child 116 "resource region %d "
116 resource allocations in this range. */ 117 "of bridge %s\n",
118 idx, pci_name(dev));
119 /*
120 * Something is wrong with the region.
121 * Invalidate the resource to prevent
122 * child resource allocations in this
123 * range.
124 */
117 r->flags = 0; 125 r->flags = 0;
118 } 126 }
119 } 127 }
@@ -131,7 +139,7 @@ static void __init pcibios_allocate_resources(int pass)
131 139
132 for_each_pci_dev(dev) { 140 for_each_pci_dev(dev) {
133 pci_read_config_word(dev, PCI_COMMAND, &command); 141 pci_read_config_word(dev, PCI_COMMAND, &command);
134 for(idx = 0; idx < 6; idx++) { 142 for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) {
135 r = &dev->resource[idx]; 143 r = &dev->resource[idx];
136 if (r->parent) /* Already allocated */ 144 if (r->parent) /* Already allocated */
137 continue; 145 continue;
@@ -142,11 +150,15 @@ static void __init pcibios_allocate_resources(int pass)
142 else 150 else
143 disabled = !(command & PCI_COMMAND_MEMORY); 151 disabled = !(command & PCI_COMMAND_MEMORY);
144 if (pass == disabled) { 152 if (pass == disabled) {
145 DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n", 153 DBG("PCI: Resource %08lx-%08lx "
154 "(f=%lx, d=%d, p=%d)\n",
146 r->start, r->end, r->flags, disabled, pass); 155 r->start, r->end, r->flags, disabled, pass);
147 pr = pci_find_parent_resource(dev, r); 156 pr = pci_find_parent_resource(dev, r);
148 if (!pr || request_resource(pr, r) < 0) { 157 if (!pr || request_resource(pr, r) < 0) {
149 printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev)); 158 printk(KERN_ERR "PCI: Cannot allocate "
159 "resource region %d "
160 "of device %s\n",
161 idx, pci_name(dev));
150 /* We'll assign a new address later */ 162 /* We'll assign a new address later */
151 r->end -= r->start; 163 r->end -= r->start;
152 r->start = 0; 164 r->start = 0;
@@ -156,12 +168,16 @@ static void __init pcibios_allocate_resources(int pass)
156 if (!pass) { 168 if (!pass) {
157 r = &dev->resource[PCI_ROM_RESOURCE]; 169 r = &dev->resource[PCI_ROM_RESOURCE];
158 if (r->flags & IORESOURCE_ROM_ENABLE) { 170 if (r->flags & IORESOURCE_ROM_ENABLE) {
159 /* Turn the ROM off, leave the resource region, but keep it unregistered. */ 171 /* Turn the ROM off, leave the resource region,
172 * but keep it unregistered. */
160 u32 reg; 173 u32 reg;
161 DBG("PCI: Switching off ROM of %s\n", pci_name(dev)); 174 DBG("PCI: Switching off ROM of %s\n",
175 pci_name(dev));
162 r->flags &= ~IORESOURCE_ROM_ENABLE; 176 r->flags &= ~IORESOURCE_ROM_ENABLE;
163 pci_read_config_dword(dev, dev->rom_base_reg, &reg); 177 pci_read_config_dword(dev,
164 pci_write_config_dword(dev, dev->rom_base_reg, reg & ~PCI_ROM_ADDRESS_ENABLE); 178 dev->rom_base_reg, &reg);
179 pci_write_config_dword(dev, dev->rom_base_reg,
180 reg & ~PCI_ROM_ADDRESS_ENABLE);
165 } 181 }
166 } 182 }
167 } 183 }
@@ -173,9 +189,11 @@ static int __init pcibios_assign_resources(void)
173 struct resource *r, *pr; 189 struct resource *r, *pr;
174 190
175 if (!(pci_probe & PCI_ASSIGN_ROMS)) { 191 if (!(pci_probe & PCI_ASSIGN_ROMS)) {
176 /* Try to use BIOS settings for ROMs, otherwise let 192 /*
177 pci_assign_unassigned_resources() allocate the new 193 * Try to use BIOS settings for ROMs, otherwise let
178 addresses. */ 194 * pci_assign_unassigned_resources() allocate the new
195 * addresses.
196 */
179 for_each_pci_dev(dev) { 197 for_each_pci_dev(dev) {
180 r = &dev->resource[PCI_ROM_RESOURCE]; 198 r = &dev->resource[PCI_ROM_RESOURCE];
181 if (!r->flags || !r->start) 199 if (!r->flags || !r->start)
@@ -215,9 +233,9 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask)
215 233
216 pci_read_config_word(dev, PCI_COMMAND, &cmd); 234 pci_read_config_word(dev, PCI_COMMAND, &cmd);
217 old_cmd = cmd; 235 old_cmd = cmd;
218 for(idx = 0; idx < PCI_NUM_RESOURCES; idx++) { 236 for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
219 /* Only set up the requested stuff */ 237 /* Only set up the requested stuff */
220 if (!(mask & (1<<idx))) 238 if (!(mask & (1 << idx)))
221 continue; 239 continue;
222 240
223 r = &dev->resource[idx]; 241 r = &dev->resource[idx];
@@ -227,7 +245,9 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask)
227 (!(r->flags & IORESOURCE_ROM_ENABLE))) 245 (!(r->flags & IORESOURCE_ROM_ENABLE)))
228 continue; 246 continue;
229 if (!r->start && r->end) { 247 if (!r->start && r->end) {
230 printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev)); 248 printk(KERN_ERR "PCI: Device %s not available "
249 "because of resource collisions\n",
250 pci_name(dev));
231 return -EINVAL; 251 return -EINVAL;
232 } 252 }
233 if (r->flags & IORESOURCE_IO) 253 if (r->flags & IORESOURCE_IO)
@@ -236,7 +256,8 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask)
236 cmd |= PCI_COMMAND_MEMORY; 256 cmd |= PCI_COMMAND_MEMORY;
237 } 257 }
238 if (cmd != old_cmd) { 258 if (cmd != old_cmd) {
239 printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd); 259 printk("PCI: Enabling device %s (%04x -> %04x)\n",
260 pci_name(dev), old_cmd, cmd);
240 pci_write_config_word(dev, PCI_COMMAND, cmd); 261 pci_write_config_word(dev, PCI_COMMAND, cmd);
241 } 262 }
242 return 0; 263 return 0;
@@ -258,7 +279,8 @@ void pcibios_set_master(struct pci_dev *dev)
258 lat = pcibios_max_latency; 279 lat = pcibios_max_latency;
259 else 280 else
260 return; 281 return;
261 printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat); 282 printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n",
283 pci_name(dev), lat);
262 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); 284 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
263} 285}
264 286
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index 69163998adeb..e65551cd8216 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -543,6 +543,12 @@ static __init int intel_router_probe(struct irq_router *r, struct pci_dev *route
543 case PCI_DEVICE_ID_INTEL_ICH8_2: 543 case PCI_DEVICE_ID_INTEL_ICH8_2:
544 case PCI_DEVICE_ID_INTEL_ICH8_3: 544 case PCI_DEVICE_ID_INTEL_ICH8_3:
545 case PCI_DEVICE_ID_INTEL_ICH8_4: 545 case PCI_DEVICE_ID_INTEL_ICH8_4:
546 case PCI_DEVICE_ID_INTEL_ICH9_0:
547 case PCI_DEVICE_ID_INTEL_ICH9_1:
548 case PCI_DEVICE_ID_INTEL_ICH9_2:
549 case PCI_DEVICE_ID_INTEL_ICH9_3:
550 case PCI_DEVICE_ID_INTEL_ICH9_4:
551 case PCI_DEVICE_ID_INTEL_ICH9_5:
546 r->name = "PIIX/ICH"; 552 r->name = "PIIX/ICH";
547 r->get = pirq_piix_get; 553 r->get = pirq_piix_get;
548 r->set = pirq_piix_set; 554 r->set = pirq_piix_set;
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index db8e1fcfa047..14691cda05c3 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -75,7 +75,7 @@
75** If a device prefetches beyond the end of a valid pdir entry, it will cause 75** If a device prefetches beyond the end of a valid pdir entry, it will cause
76** a hard failure, ie. MCA. Version 3.0 and later of the zx1 LBA should 76** a hard failure, ie. MCA. Version 3.0 and later of the zx1 LBA should
77** disconnect on 4k boundaries and prevent such issues. If the device is 77** disconnect on 4k boundaries and prevent such issues. If the device is
78** particularly agressive, this option will keep the entire pdir valid such 78** particularly aggressive, this option will keep the entire pdir valid such
79** that prefetching will hit a valid address. This could severely impact 79** that prefetching will hit a valid address. This could severely impact
80** error containment, and is therefore off by default. The page that is 80** error containment, and is therefore off by default. The page that is
81** used for spill-over is poisoned, so that should help debugging somewhat. 81** used for spill-over is poisoned, so that should help debugging somewhat.
@@ -258,10 +258,10 @@ static u64 prefetch_spill_page;
258 258
259/* 259/*
260** DMA_CHUNK_SIZE is used by the SCSI mid-layer to break up 260** DMA_CHUNK_SIZE is used by the SCSI mid-layer to break up
261** (or rather not merge) DMA's into managable chunks. 261** (or rather not merge) DMAs into manageable chunks.
262** On parisc, this is more of the software/tuning constraint 262** On parisc, this is more of the software/tuning constraint
263** rather than the HW. I/O MMU allocation alogorithms can be 263** rather than the HW. I/O MMU allocation algorithms can be
264** faster with smaller size is (to some degree). 264** faster with smaller sizes (to some degree).
265*/ 265*/
266#define DMA_CHUNK_SIZE (BITS_PER_LONG*iovp_size) 266#define DMA_CHUNK_SIZE (BITS_PER_LONG*iovp_size)
267 267
diff --git a/arch/ia64/lib/checksum.c b/arch/ia64/lib/checksum.c
index beb11721d9f5..4411d9baeb21 100644
--- a/arch/ia64/lib/checksum.c
+++ b/arch/ia64/lib/checksum.c
@@ -33,32 +33,32 @@ from64to16 (unsigned long x)
33 * computes the checksum of the TCP/UDP pseudo-header 33 * computes the checksum of the TCP/UDP pseudo-header
34 * returns a 16-bit checksum, already complemented. 34 * returns a 16-bit checksum, already complemented.
35 */ 35 */
36unsigned short int 36__sum16
37csum_tcpudp_magic (unsigned long saddr, unsigned long daddr, unsigned short len, 37csum_tcpudp_magic (__be32 saddr, __be32 daddr, unsigned short len,
38 unsigned short proto, unsigned int sum) 38 unsigned short proto, __wsum sum)
39{ 39{
40 return ~from64to16(saddr + daddr + sum + ((unsigned long) ntohs(len) << 16) + 40 return (__force __sum16)~from64to16(
41 ((unsigned long) proto << 8)); 41 (__force u64)saddr + (__force u64)daddr +
42 (__force u64)sum + ((len + proto) << 8));
42} 43}
43 44
44EXPORT_SYMBOL(csum_tcpudp_magic); 45EXPORT_SYMBOL(csum_tcpudp_magic);
45 46
46unsigned int 47__wsum
47csum_tcpudp_nofold (unsigned long saddr, unsigned long daddr, unsigned short len, 48csum_tcpudp_nofold (__be32 saddr, __be32 daddr, unsigned short len,
48 unsigned short proto, unsigned int sum) 49 unsigned short proto, __wsum sum)
49{ 50{
50 unsigned long result; 51 unsigned long result;
51 52
52 result = (saddr + daddr + sum + 53 result = (__force u64)saddr + (__force u64)daddr +
53 ((unsigned long) ntohs(len) << 16) + 54 (__force u64)sum + ((len + proto) << 8);
54 ((unsigned long) proto << 8));
55 55
56 /* Fold down to 32-bits so we don't lose in the typedef-less network stack. */ 56 /* Fold down to 32-bits so we don't lose in the typedef-less network stack. */
57 /* 64 to 33 */ 57 /* 64 to 33 */
58 result = (result & 0xffffffff) + (result >> 32); 58 result = (result & 0xffffffff) + (result >> 32);
59 /* 33 to 32 */ 59 /* 33 to 32 */
60 result = (result & 0xffffffff) + (result >> 32); 60 result = (result & 0xffffffff) + (result >> 32);
61 return result; 61 return (__force __wsum)result;
62} 62}
63 63
64extern unsigned long do_csum (const unsigned char *, long); 64extern unsigned long do_csum (const unsigned char *, long);
@@ -75,16 +75,15 @@ extern unsigned long do_csum (const unsigned char *, long);
75 * 75 *
76 * it's best to have buff aligned on a 32-bit boundary 76 * it's best to have buff aligned on a 32-bit boundary
77 */ 77 */
78unsigned int 78__wsum csum_partial(const void *buff, int len, __wsum sum)
79csum_partial (const unsigned char * buff, int len, unsigned int sum)
80{ 79{
81 unsigned long result = do_csum(buff, len); 80 u64 result = do_csum(buff, len);
82 81
83 /* add in old sum, and carry.. */ 82 /* add in old sum, and carry.. */
84 result += sum; 83 result += (__force u32)sum;
85 /* 32+c bits -> 32 bits */ 84 /* 32+c bits -> 32 bits */
86 result = (result & 0xffffffff) + (result >> 32); 85 result = (result & 0xffffffff) + (result >> 32);
87 return result; 86 return (__force __wsum)result;
88} 87}
89 88
90EXPORT_SYMBOL(csum_partial); 89EXPORT_SYMBOL(csum_partial);
@@ -93,10 +92,9 @@ EXPORT_SYMBOL(csum_partial);
93 * this routine is used for miscellaneous IP-like checksums, mainly 92 * this routine is used for miscellaneous IP-like checksums, mainly
94 * in icmp.c 93 * in icmp.c
95 */ 94 */
96unsigned short 95__sum16 ip_compute_csum (const void *buff, int len)
97ip_compute_csum (unsigned char * buff, int len)
98{ 96{
99 return ~do_csum(buff,len); 97 return (__force __sum16)~do_csum(buff,len);
100} 98}
101 99
102EXPORT_SYMBOL(ip_compute_csum); 100EXPORT_SYMBOL(ip_compute_csum);
diff --git a/arch/ia64/lib/csum_partial_copy.c b/arch/ia64/lib/csum_partial_copy.c
index 36866e8a5d2b..503dfe6d1450 100644
--- a/arch/ia64/lib/csum_partial_copy.c
+++ b/arch/ia64/lib/csum_partial_copy.c
@@ -104,9 +104,9 @@ out:
104 */ 104 */
105extern unsigned long do_csum(const unsigned char *, long); 105extern unsigned long do_csum(const unsigned char *, long);
106 106
107static unsigned int 107__wsum
108do_csum_partial_copy_from_user (const unsigned char __user *src, unsigned char *dst, 108csum_partial_copy_from_user(const void __user *src, void *dst,
109 int len, unsigned int psum, int *errp) 109 int len, __wsum psum, int *errp)
110{ 110{
111 unsigned long result; 111 unsigned long result;
112 112
@@ -122,30 +122,17 @@ do_csum_partial_copy_from_user (const unsigned char __user *src, unsigned char *
122 result = do_csum(dst, len); 122 result = do_csum(dst, len);
123 123
124 /* add in old sum, and carry.. */ 124 /* add in old sum, and carry.. */
125 result += psum; 125 result += (__force u32)psum;
126 /* 32+c bits -> 32 bits */ 126 /* 32+c bits -> 32 bits */
127 result = (result & 0xffffffff) + (result >> 32); 127 result = (result & 0xffffffff) + (result >> 32);
128 return result; 128 return (__force __wsum)result;
129}
130
131unsigned int
132csum_partial_copy_from_user (const unsigned char __user *src, unsigned char *dst,
133 int len, unsigned int sum, int *errp)
134{
135 if (!access_ok(VERIFY_READ, src, len)) {
136 *errp = -EFAULT;
137 memset(dst, 0, len);
138 return sum;
139 }
140
141 return do_csum_partial_copy_from_user(src, dst, len, sum, errp);
142} 129}
143 130
144unsigned int 131__wsum
145csum_partial_copy_nocheck(const unsigned char __user *src, unsigned char *dst, 132csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
146 int len, unsigned int sum)
147{ 133{
148 return do_csum_partial_copy_from_user(src, dst, len, sum, NULL); 134 return csum_partial_copy_from_user((__force const void __user *)src,
135 dst, len, sum, NULL);
149} 136}
150 137
151EXPORT_SYMBOL(csum_partial_copy_nocheck); 138EXPORT_SYMBOL(csum_partial_copy_nocheck);
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index b30be7c48ba8..f4edfbf27134 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -469,10 +469,11 @@ pcibios_fixup_resources(struct pci_dev *dev, int start, int limit)
469 } 469 }
470} 470}
471 471
472static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) 472void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
473{ 473{
474 pcibios_fixup_resources(dev, 0, PCI_BRIDGE_RESOURCES); 474 pcibios_fixup_resources(dev, 0, PCI_BRIDGE_RESOURCES);
475} 475}
476EXPORT_SYMBOL_GPL(pcibios_fixup_device_resources);
476 477
477static void __devinit pcibios_fixup_bridge_resources(struct pci_dev *dev) 478static void __devinit pcibios_fixup_bridge_resources(struct pci_dev *dev)
478{ 479{
@@ -493,6 +494,7 @@ pcibios_fixup_bus (struct pci_bus *b)
493 } 494 }
494 list_for_each_entry(dev, &b->devices, bus_list) 495 list_for_each_entry(dev, &b->devices, bus_list)
495 pcibios_fixup_device_resources(dev); 496 pcibios_fixup_device_resources(dev);
497 platform_pci_fixup_bus(b);
496 498
497 return; 499 return;
498} 500}
@@ -738,75 +740,44 @@ int ia64_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size)
738 return ret; 740 return ret;
739} 741}
740 742
743/* It's defined in drivers/pci/pci.c */
744extern u8 pci_cache_line_size;
745
741/** 746/**
742 * pci_cacheline_size - determine cacheline size for PCI devices 747 * set_pci_cacheline_size - determine cacheline size for PCI devices
743 * @dev: void
744 * 748 *
745 * We want to use the line-size of the outer-most cache. We assume 749 * We want to use the line-size of the outer-most cache. We assume
746 * that this line-size is the same for all CPUs. 750 * that this line-size is the same for all CPUs.
747 * 751 *
748 * Code mostly taken from arch/ia64/kernel/palinfo.c:cache_info(). 752 * Code mostly taken from arch/ia64/kernel/palinfo.c:cache_info().
749 *
750 * RETURNS: An appropriate -ERRNO error value on eror, or zero for success.
751 */ 753 */
752static unsigned long 754static void __init set_pci_cacheline_size(void)
753pci_cacheline_size (void)
754{ 755{
755 u64 levels, unique_caches; 756 u64 levels, unique_caches;
756 s64 status; 757 s64 status;
757 pal_cache_config_info_t cci; 758 pal_cache_config_info_t cci;
758 static u8 cacheline_size;
759
760 if (cacheline_size)
761 return cacheline_size;
762 759
763 status = ia64_pal_cache_summary(&levels, &unique_caches); 760 status = ia64_pal_cache_summary(&levels, &unique_caches);
764 if (status != 0) { 761 if (status != 0) {
765 printk(KERN_ERR "%s: ia64_pal_cache_summary() failed (status=%ld)\n", 762 printk(KERN_ERR "%s: ia64_pal_cache_summary() failed "
766 __FUNCTION__, status); 763 "(status=%ld)\n", __FUNCTION__, status);
767 return SMP_CACHE_BYTES; 764 return;
768 } 765 }
769 766
770 status = ia64_pal_cache_config_info(levels - 1, /* cache_type (data_or_unified)= */ 2, 767 status = ia64_pal_cache_config_info(levels - 1,
771 &cci); 768 /* cache_type (data_or_unified)= */ 2, &cci);
772 if (status != 0) { 769 if (status != 0) {
773 printk(KERN_ERR "%s: ia64_pal_cache_config_info() failed (status=%ld)\n", 770 printk(KERN_ERR "%s: ia64_pal_cache_config_info() failed "
774 __FUNCTION__, status); 771 "(status=%ld)\n", __FUNCTION__, status);
775 return SMP_CACHE_BYTES; 772 return;
776 } 773 }
777 cacheline_size = 1 << cci.pcci_line_size; 774 pci_cache_line_size = (1 << cci.pcci_line_size) / 4;
778 return cacheline_size;
779} 775}
780 776
781/** 777static int __init pcibios_init(void)
782 * pcibios_prep_mwi - helper function for drivers/pci/pci.c:pci_set_mwi() 778{
783 * @dev: the PCI device for which MWI is enabled 779 set_pci_cacheline_size();
784 * 780 return 0;
785 * For ia64, we can get the cacheline sizes from PAL.
786 *
787 * RETURNS: An appropriate -ERRNO error value on eror, or zero for success.
788 */
789int
790pcibios_prep_mwi (struct pci_dev *dev)
791{
792 unsigned long desired_linesize, current_linesize;
793 int rc = 0;
794 u8 pci_linesize;
795
796 desired_linesize = pci_cacheline_size();
797
798 pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &pci_linesize);
799 current_linesize = 4 * pci_linesize;
800 if (desired_linesize != current_linesize) {
801 printk(KERN_WARNING "PCI: slot %s has incorrect PCI cache line size of %lu bytes,",
802 pci_name(dev), current_linesize);
803 if (current_linesize > desired_linesize) {
804 printk(" expected %lu bytes instead\n", desired_linesize);
805 rc = -EINVAL;
806 } else {
807 printk(" correcting to %lu\n", desired_linesize);
808 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, desired_linesize / 4);
809 }
810 }
811 return rc;
812} 781}
782
783subsys_initcall(pcibios_init);
diff --git a/arch/ia64/sn/kernel/Makefile b/arch/ia64/sn/kernel/Makefile
index 2d78f34dd763..0a59371d3475 100644
--- a/arch/ia64/sn/kernel/Makefile
+++ b/arch/ia64/sn/kernel/Makefile
@@ -4,13 +4,14 @@
4# License. See the file "COPYING" in the main directory of this archive 4# License. See the file "COPYING" in the main directory of this archive
5# for more details. 5# for more details.
6# 6#
7# Copyright (C) 1999,2001-2005 Silicon Graphics, Inc. All Rights Reserved. 7# Copyright (C) 1999,2001-2006 Silicon Graphics, Inc. All Rights Reserved.
8# 8#
9 9
10CPPFLAGS += -I$(srctree)/arch/ia64/sn/include 10CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
11 11
12obj-y += setup.o bte.o bte_error.o irq.o mca.o idle.o \ 12obj-y += setup.o bte.o bte_error.o irq.o mca.o idle.o \
13 huberror.o io_init.o iomv.o klconflib.o pio_phys.o \ 13 huberror.o io_acpi_init.o io_common.o \
14 io_init.o iomv.o klconflib.o pio_phys.o \
14 sn2/ 15 sn2/
15obj-$(CONFIG_IA64_GENERIC) += machvec.o 16obj-$(CONFIG_IA64_GENERIC) += machvec.o
16obj-$(CONFIG_SGI_TIOCX) += tiocx.o 17obj-$(CONFIG_SGI_TIOCX) += tiocx.o
diff --git a/arch/ia64/sn/kernel/io_acpi_init.c b/arch/ia64/sn/kernel/io_acpi_init.c
new file mode 100644
index 000000000000..99d7f278612a
--- /dev/null
+++ b/arch/ia64/sn/kernel/io_acpi_init.c
@@ -0,0 +1,231 @@
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) 2006 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#include <asm/sn/types.h>
10#include <asm/sn/addrs.h>
11#include <asm/sn/pcidev.h>
12#include <asm/sn/pcibus_provider_defs.h>
13#include <asm/sn/sn_sal.h>
14#include "xtalk/hubdev.h"
15#include <linux/acpi.h>
16
17
18/*
19 * The code in this file will only be executed when running with
20 * a PROM that has ACPI IO support. (i.e., SN_ACPI_BASE_SUPPORT() == 1)
21 */
22
23
24/*
25 * This value must match the UUID the PROM uses
26 * (io/acpi/defblk.c) when building a vendor descriptor.
27 */
28struct acpi_vendor_uuid sn_uuid = {
29 .subtype = 0,
30 .data = { 0x2c, 0xc6, 0xa6, 0xfe, 0x9c, 0x44, 0xda, 0x11,
31 0xa2, 0x7c, 0x08, 0x00, 0x69, 0x13, 0xea, 0x51 },
32};
33
34/*
35 * Perform the early IO init in PROM.
36 */
37static s64
38sal_ioif_init(u64 *result)
39{
40 struct ia64_sal_retval isrv = {0,0,0,0};
41
42 SAL_CALL_NOLOCK(isrv,
43 SN_SAL_IOIF_INIT, 0, 0, 0, 0, 0, 0, 0);
44 *result = isrv.v0;
45 return isrv.status;
46}
47
48/*
49 * sn_hubdev_add - The 'add' function of the acpi_sn_hubdev_driver.
50 * Called for every "SGIHUB" or "SGITIO" device defined
51 * in the ACPI namespace.
52 */
53static int __init
54sn_hubdev_add(struct acpi_device *device)
55{
56 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
57 u64 addr;
58 struct hubdev_info *hubdev;
59 struct hubdev_info *hubdev_ptr;
60 int i;
61 u64 nasid;
62 struct acpi_resource *resource;
63 int ret = 0;
64 acpi_status status;
65 struct acpi_resource_vendor_typed *vendor;
66 extern void sn_common_hubdev_init(struct hubdev_info *);
67
68 status = acpi_get_vendor_resource(device->handle, METHOD_NAME__CRS,
69 &sn_uuid, &buffer);
70 if (ACPI_FAILURE(status)) {
71 printk(KERN_ERR
72 "sn_hubdev_add: acpi_get_vendor_resource() failed: %d\n",
73 status);
74 return 1;
75 }
76
77 resource = buffer.pointer;
78 vendor = &resource->data.vendor_typed;
79 if ((vendor->byte_length - sizeof(struct acpi_vendor_uuid)) !=
80 sizeof(struct hubdev_info *)) {
81 printk(KERN_ERR
82 "sn_hubdev_add: Invalid vendor data length: %d\n",
83 vendor->byte_length);
84 ret = 1;
85 goto exit;
86 }
87
88 memcpy(&addr, vendor->byte_data, sizeof(struct hubdev_info *));
89 hubdev_ptr = __va((struct hubdev_info *) addr);
90
91 nasid = hubdev_ptr->hdi_nasid;
92 i = nasid_to_cnodeid(nasid);
93 hubdev = (struct hubdev_info *)(NODEPDA(i)->pdinfo);
94 *hubdev = *hubdev_ptr;
95 sn_common_hubdev_init(hubdev);
96
97exit:
98 kfree(buffer.pointer);
99 return ret;
100}
101
102/*
103 * sn_get_bussoft_ptr() - The pcibus_bussoft pointer is found in
104 * the ACPI Vendor resource for this bus.
105 */
106static struct pcibus_bussoft *
107sn_get_bussoft_ptr(struct pci_bus *bus)
108{
109 u64 addr;
110 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
111 acpi_handle handle;
112 struct pcibus_bussoft *prom_bussoft_ptr;
113 struct acpi_resource *resource;
114 acpi_status status;
115 struct acpi_resource_vendor_typed *vendor;
116
117
118 handle = PCI_CONTROLLER(bus)->acpi_handle;
119 status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS,
120 &sn_uuid, &buffer);
121 if (ACPI_FAILURE(status)) {
122 printk(KERN_ERR "get_acpi_pcibus_ptr: "
123 "get_acpi_bussoft_info() failed: %d\n",
124 status);
125 return NULL;
126 }
127 resource = buffer.pointer;
128 vendor = &resource->data.vendor_typed;
129
130 if ((vendor->byte_length - sizeof(struct acpi_vendor_uuid)) !=
131 sizeof(struct pcibus_bussoft *)) {
132 printk(KERN_ERR
133 "get_acpi_bussoft_ptr: Invalid vendor data "
134 "length %d\n", vendor->byte_length);
135 kfree(buffer.pointer);
136 return NULL;
137 }
138 memcpy(&addr, vendor->byte_data, sizeof(struct pcibus_bussoft *));
139 prom_bussoft_ptr = __va((struct pcibus_bussoft *) addr);
140 kfree(buffer.pointer);
141
142 return prom_bussoft_ptr;
143}
144
145/*
146 * sn_acpi_bus_fixup
147 */
148void
149sn_acpi_bus_fixup(struct pci_bus *bus)
150{
151 struct pci_dev *pci_dev = NULL;
152 struct pcibus_bussoft *prom_bussoft_ptr;
153 extern void sn_common_bus_fixup(struct pci_bus *,
154 struct pcibus_bussoft *);
155
156 if (!bus->parent) { /* If root bus */
157 prom_bussoft_ptr = sn_get_bussoft_ptr(bus);
158 if (prom_bussoft_ptr == NULL) {
159 printk(KERN_ERR
160 "sn_pci_fixup_bus: 0x%04x:0x%02x Unable to "
161 "obtain prom_bussoft_ptr\n",
162 pci_domain_nr(bus), bus->number);
163 return;
164 }
165 sn_common_bus_fixup(bus, prom_bussoft_ptr);
166 }
167 list_for_each_entry(pci_dev, &bus->devices, bus_list) {
168 sn_pci_fixup_slot(pci_dev);
169 }
170}
171
172/*
173 * sn_acpi_slot_fixup - Perform any SN specific slot fixup.
174 * At present there does not appear to be
175 * any generic way to handle a ROM image
176 * that has been shadowed by the PROM, so
177 * we pass a pointer to it within the
178 * pcidev_info structure.
179 */
180
181void
182sn_acpi_slot_fixup(struct pci_dev *dev, struct pcidev_info *pcidev_info)
183{
184 void __iomem *addr;
185 size_t size;
186
187 if (pcidev_info->pdi_pio_mapped_addr[PCI_ROM_RESOURCE]) {
188 /*
189 * A valid ROM image exists and has been shadowed by the
190 * PROM. Setup the pci_dev ROM resource to point to
191 * the shadowed copy.
192 */
193 size = dev->resource[PCI_ROM_RESOURCE].end -
194 dev->resource[PCI_ROM_RESOURCE].start;
195 addr =
196 ioremap(pcidev_info->pdi_pio_mapped_addr[PCI_ROM_RESOURCE],
197 size);
198 dev->resource[PCI_ROM_RESOURCE].start = (unsigned long) addr;
199 dev->resource[PCI_ROM_RESOURCE].end =
200 (unsigned long) addr + size;
201 dev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_BIOS_COPY;
202 }
203}
204
205static struct acpi_driver acpi_sn_hubdev_driver = {
206 .name = "SGI HUBDEV Driver",
207 .ids = "SGIHUB,SGITIO",
208 .ops = {
209 .add = sn_hubdev_add,
210 },
211};
212
213
214/*
215 * sn_io_acpi_init - PROM has ACPI support for IO, defining at a minimum the
216 * nodes and root buses in the DSDT. As a result, bus scanning
217 * will be initiated by the Linux ACPI code.
218 */
219
220void __init
221sn_io_acpi_init(void)
222{
223 u64 result;
224 s64 status;
225
226 acpi_bus_register_driver(&acpi_sn_hubdev_driver);
227 status = sal_ioif_init(&result);
228 if (status || result)
229 panic("sal_ioif_init failed: [%lx] %s\n",
230 status, ia64_sal_strerror(status));
231}
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
new file mode 100644
index 000000000000..d4dd8f4b6b8d
--- /dev/null
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -0,0 +1,613 @@
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) 2006 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#include <linux/bootmem.h>
10#include <asm/sn/types.h>
11#include <asm/sn/addrs.h>
12#include <asm/sn/sn_feature_sets.h>
13#include <asm/sn/geo.h>
14#include <asm/sn/io.h>
15#include <asm/sn/l1.h>
16#include <asm/sn/module.h>
17#include <asm/sn/pcibr_provider.h>
18#include <asm/sn/pcibus_provider_defs.h>
19#include <asm/sn/pcidev.h>
20#include <asm/sn/simulator.h>
21#include <asm/sn/sn_sal.h>
22#include <asm/sn/tioca_provider.h>
23#include <asm/sn/tioce_provider.h>
24#include "xtalk/hubdev.h"
25#include "xtalk/xwidgetdev.h"
26#include <linux/acpi.h>
27#include <asm/sn/sn2/sn_hwperf.h>
28#include <asm/sn/acpi.h>
29
30extern void sn_init_cpei_timer(void);
31extern void register_sn_procfs(void);
32extern void sn_acpi_bus_fixup(struct pci_bus *);
33extern void sn_bus_fixup(struct pci_bus *);
34extern void sn_acpi_slot_fixup(struct pci_dev *, struct pcidev_info *);
35extern void sn_more_slot_fixup(struct pci_dev *, struct pcidev_info *);
36extern void sn_legacy_pci_window_fixup(struct pci_controller *, u64, u64);
37extern void sn_io_acpi_init(void);
38extern void sn_io_init(void);
39
40
41static struct list_head sn_sysdata_list;
42
43/* sysdata list struct */
44struct sysdata_el {
45 struct list_head entry;
46 void *sysdata;
47};
48
49int sn_ioif_inited; /* SN I/O infrastructure initialized? */
50
51struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */
52
53/*
54 * Hooks and struct for unsupported pci providers
55 */
56
57static dma_addr_t
58sn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size, int type)
59{
60 return 0;
61}
62
63static void
64sn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction)
65{
66 return;
67}
68
69static void *
70sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller)
71{
72 return NULL;
73}
74
75static struct sn_pcibus_provider sn_pci_default_provider = {
76 .dma_map = sn_default_pci_map,
77 .dma_map_consistent = sn_default_pci_map,
78 .dma_unmap = sn_default_pci_unmap,
79 .bus_fixup = sn_default_pci_bus_fixup,
80};
81
82/*
83 * Retrieve the DMA Flush List given nasid, widget, and device.
84 * This list is needed to implement the WAR - Flush DMA data on PIO Reads.
85 */
86static inline u64
87sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
88 u64 address)
89{
90 struct ia64_sal_retval ret_stuff;
91 ret_stuff.status = 0;
92 ret_stuff.v0 = 0;
93
94 SAL_CALL_NOLOCK(ret_stuff,
95 (u64) SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST,
96 (u64) nasid, (u64) widget_num,
97 (u64) device_num, (u64) address, 0, 0, 0);
98 return ret_stuff.status;
99}
100
101/*
102 * Retrieve the pci device information given the bus and device|function number.
103 */
104static inline u64
105sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev,
106 u64 sn_irq_info)
107{
108 struct ia64_sal_retval ret_stuff;
109 ret_stuff.status = 0;
110 ret_stuff.v0 = 0;
111
112 SAL_CALL_NOLOCK(ret_stuff,
113 (u64) SN_SAL_IOIF_GET_PCIDEV_INFO,
114 (u64) segment, (u64) bus_number, (u64) devfn,
115 (u64) pci_dev,
116 sn_irq_info, 0, 0);
117 return ret_stuff.v0;
118}
119
120/*
121 * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified
122 * device.
123 */
124inline struct pcidev_info *
125sn_pcidev_info_get(struct pci_dev *dev)
126{
127 struct pcidev_info *pcidev;
128
129 list_for_each_entry(pcidev,
130 &(SN_PLATFORM_DATA(dev)->pcidev_info), pdi_list) {
131 if (pcidev->pdi_linux_pcidev == dev)
132 return pcidev;
133 }
134 return NULL;
135}
136
137/* Older PROM flush WAR
138 *
139 * 01/16/06 -- This war will be in place until a new official PROM is released.
140 * Additionally note that the struct sn_flush_device_war also has to be
141 * removed from arch/ia64/sn/include/xtalk/hubdev.h
142 */
143static u8 war_implemented = 0;
144
145static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
146 struct sn_flush_device_common *common)
147{
148 struct sn_flush_device_war *war_list;
149 struct sn_flush_device_war *dev_entry;
150 struct ia64_sal_retval isrv = {0,0,0,0};
151
152 if (!war_implemented) {
153 printk(KERN_WARNING "PROM version < 4.50 -- implementing old "
154 "PROM flush WAR\n");
155 war_implemented = 1;
156 }
157
158 war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
159 if (!war_list)
160 BUG();
161
162 SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
163 nasid, widget, __pa(war_list), 0, 0, 0 ,0);
164 if (isrv.status)
165 panic("sn_device_fixup_war failed: %s\n",
166 ia64_sal_strerror(isrv.status));
167
168 dev_entry = war_list + device;
169 memcpy(common,dev_entry, sizeof(*common));
170 kfree(war_list);
171
172 return isrv.status;
173}
174
175/*
176 * sn_common_hubdev_init() - This routine is called to initialize the HUB data
177 * structure for each node in the system.
178 */
179void __init
180sn_common_hubdev_init(struct hubdev_info *hubdev)
181{
182
183 struct sn_flush_device_kernel *sn_flush_device_kernel;
184 struct sn_flush_device_kernel *dev_entry;
185 s64 status;
186 int widget, device, size;
187
188 /* Attach the error interrupt handlers */
189 if (hubdev->hdi_nasid & 1) /* If TIO */
190 ice_error_init(hubdev);
191 else
192 hub_error_init(hubdev);
193
194 for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++)
195 hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev;
196
197 if (!hubdev->hdi_flush_nasid_list.widget_p)
198 return;
199
200 size = (HUB_WIDGET_ID_MAX + 1) *
201 sizeof(struct sn_flush_device_kernel *);
202 hubdev->hdi_flush_nasid_list.widget_p =
203 kzalloc(size, GFP_KERNEL);
204 if (!hubdev->hdi_flush_nasid_list.widget_p)
205 BUG();
206
207 for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) {
208 size = DEV_PER_WIDGET *
209 sizeof(struct sn_flush_device_kernel);
210 sn_flush_device_kernel = kzalloc(size, GFP_KERNEL);
211 if (!sn_flush_device_kernel)
212 BUG();
213
214 dev_entry = sn_flush_device_kernel;
215 for (device = 0; device < DEV_PER_WIDGET;
216 device++, dev_entry++) {
217 size = sizeof(struct sn_flush_device_common);
218 dev_entry->common = kzalloc(size, GFP_KERNEL);
219 if (!dev_entry->common)
220 BUG();
221 if (sn_prom_feature_available(PRF_DEVICE_FLUSH_LIST))
222 status = sal_get_device_dmaflush_list(
223 hubdev->hdi_nasid, widget, device,
224 (u64)(dev_entry->common));
225 else
226 status = sn_device_fixup_war(hubdev->hdi_nasid,
227 widget, device,
228 dev_entry->common);
229 if (status != SALRET_OK)
230 panic("SAL call failed: %s\n",
231 ia64_sal_strerror(status));
232
233 spin_lock_init(&dev_entry->sfdl_flush_lock);
234 }
235
236 if (sn_flush_device_kernel)
237 hubdev->hdi_flush_nasid_list.widget_p[widget] =
238 sn_flush_device_kernel;
239 }
240}
241
242void sn_pci_unfixup_slot(struct pci_dev *dev)
243{
244 struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev;
245
246 sn_irq_unfixup(dev);
247 pci_dev_put(host_pci_dev);
248 pci_dev_put(dev);
249}
250
251/*
252 * sn_pci_fixup_slot() - This routine sets up a slot's resources consistent
253 * with the Linux PCI abstraction layer. Resources
254 * acquired from our PCI provider include PIO maps
255 * to BAR space and interrupt objects.
256 */
257void sn_pci_fixup_slot(struct pci_dev *dev)
258{
259 int segment = pci_domain_nr(dev->bus);
260 int status = 0;
261 struct pcibus_bussoft *bs;
262 struct pci_bus *host_pci_bus;
263 struct pci_dev *host_pci_dev;
264 struct pcidev_info *pcidev_info;
265 struct sn_irq_info *sn_irq_info;
266 unsigned int bus_no, devfn;
267
268 pci_dev_get(dev); /* for the sysdata pointer */
269 pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
270 if (!pcidev_info)
271 BUG(); /* Cannot afford to run out of memory */
272
273 sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
274 if (!sn_irq_info)
275 BUG(); /* Cannot afford to run out of memory */
276
277 /* Call to retrieve pci device information needed by kernel. */
278 status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number,
279 dev->devfn,
280 (u64) __pa(pcidev_info),
281 (u64) __pa(sn_irq_info));
282 if (status)
283 BUG(); /* Cannot get platform pci device information */
284
285 /* Add pcidev_info to list in pci_controller.platform_data */
286 list_add_tail(&pcidev_info->pdi_list,
287 &(SN_PLATFORM_DATA(dev->bus)->pcidev_info));
288
289 if (SN_ACPI_BASE_SUPPORT())
290 sn_acpi_slot_fixup(dev, pcidev_info);
291 else
292 sn_more_slot_fixup(dev, pcidev_info);
293 /*
294 * Using the PROMs values for the PCI host bus, get the Linux
295 * PCI host_pci_dev struct and set up host bus linkages
296 */
297
298 bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff;
299 devfn = pcidev_info->pdi_slot_host_handle & 0xffffffff;
300 host_pci_bus = pci_find_bus(segment, bus_no);
301 host_pci_dev = pci_get_slot(host_pci_bus, devfn);
302
303 pcidev_info->host_pci_dev = host_pci_dev;
304 pcidev_info->pdi_linux_pcidev = dev;
305 pcidev_info->pdi_host_pcidev_info = SN_PCIDEV_INFO(host_pci_dev);
306 bs = SN_PCIBUS_BUSSOFT(dev->bus);
307 pcidev_info->pdi_pcibus_info = bs;
308
309 if (bs && bs->bs_asic_type < PCIIO_ASIC_MAX_TYPES) {
310 SN_PCIDEV_BUSPROVIDER(dev) = sn_pci_provider[bs->bs_asic_type];
311 } else {
312 SN_PCIDEV_BUSPROVIDER(dev) = &sn_pci_default_provider;
313 }
314
315 /* Only set up IRQ stuff if this device has a host bus context */
316 if (bs && sn_irq_info->irq_irq) {
317 pcidev_info->pdi_sn_irq_info = sn_irq_info;
318 dev->irq = pcidev_info->pdi_sn_irq_info->irq_irq;
319 sn_irq_fixup(dev, sn_irq_info);
320 } else {
321 pcidev_info->pdi_sn_irq_info = NULL;
322 kfree(sn_irq_info);
323 }
324}
325
326/*
327 * sn_common_bus_fixup - Perform platform specific bus fixup.
328 * Execute the ASIC specific fixup routine
329 * for this bus.
330 */
331void
332sn_common_bus_fixup(struct pci_bus *bus,
333 struct pcibus_bussoft *prom_bussoft_ptr)
334{
335 int cnode;
336 struct pci_controller *controller;
337 struct hubdev_info *hubdev_info;
338 int nasid;
339 void *provider_soft;
340 struct sn_pcibus_provider *provider;
341 struct sn_platform_data *sn_platform_data;
342
343 controller = PCI_CONTROLLER(bus);
344 /*
345 * Per-provider fixup. Copies the bus soft structure from prom
346 * to local area and links SN_PCIBUS_BUSSOFT().
347 */
348
349 if (prom_bussoft_ptr->bs_asic_type >= PCIIO_ASIC_MAX_TYPES) {
350 printk(KERN_WARNING "sn_common_bus_fixup: Unsupported asic type, %d",
351 prom_bussoft_ptr->bs_asic_type);
352 return;
353 }
354
355 if (prom_bussoft_ptr->bs_asic_type == PCIIO_ASIC_TYPE_PPB)
356 return; /* no further fixup necessary */
357
358 provider = sn_pci_provider[prom_bussoft_ptr->bs_asic_type];
359 if (provider == NULL)
360 panic("sn_common_bus_fixup: No provider registered for this asic type, %d",
361 prom_bussoft_ptr->bs_asic_type);
362
363 if (provider->bus_fixup)
364 provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr,
365 controller);
366 else
367 provider_soft = NULL;
368
369 /*
370 * Generic bus fixup goes here. Don't reference prom_bussoft_ptr
371 * after this point.
372 */
373 controller->platform_data = kzalloc(sizeof(struct sn_platform_data),
374 GFP_KERNEL);
375 if (controller->platform_data == NULL)
376 BUG();
377 sn_platform_data =
378 (struct sn_platform_data *) controller->platform_data;
379 sn_platform_data->provider_soft = provider_soft;
380 INIT_LIST_HEAD(&((struct sn_platform_data *)
381 controller->platform_data)->pcidev_info);
382 nasid = NASID_GET(SN_PCIBUS_BUSSOFT(bus)->bs_base);
383 cnode = nasid_to_cnodeid(nasid);
384 hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
385 SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info =
386 &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]);
387
388 /*
389 * If the node information we obtained during the fixup phase is
390 * invalid then set controller->node to -1 (undetermined)
391 */
392 if (controller->node >= num_online_nodes()) {
393 struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus);
394
395 printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u"
396 "L_IO=%lx L_MEM=%lx BASE=%lx\n",
397 b->bs_asic_type, b->bs_xid, b->bs_persist_busnum,
398 b->bs_legacy_io, b->bs_legacy_mem, b->bs_base);
399 printk(KERN_WARNING "on node %d but only %d nodes online."
400 "Association set to undetermined.\n",
401 controller->node, num_online_nodes());
402 controller->node = -1;
403 }
404}
405
406void sn_bus_store_sysdata(struct pci_dev *dev)
407{
408 struct sysdata_el *element;
409
410 element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL);
411 if (!element) {
412 dev_dbg(dev, "%s: out of memory!\n", __FUNCTION__);
413 return;
414 }
415 element->sysdata = SN_PCIDEV_INFO(dev);
416 list_add(&element->entry, &sn_sysdata_list);
417}
418
419void sn_bus_free_sysdata(void)
420{
421 struct sysdata_el *element;
422 struct list_head *list, *safe;
423
424 list_for_each_safe(list, safe, &sn_sysdata_list) {
425 element = list_entry(list, struct sysdata_el, entry);
426 list_del(&element->entry);
427 list_del(&(((struct pcidev_info *)
428 (element->sysdata))->pdi_list));
429 kfree(element->sysdata);
430 kfree(element);
431 }
432 return;
433}
434
435/*
436 * hubdev_init_node() - Creates the HUB data structure and link them to it's
437 * own NODE specific data area.
438 */
439void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
440{
441 struct hubdev_info *hubdev_info;
442 int size;
443 pg_data_t *pg;
444
445 size = sizeof(struct hubdev_info);
446
447 if (node >= num_online_nodes()) /* Headless/memless IO nodes */
448 pg = NODE_DATA(0);
449 else
450 pg = NODE_DATA(node);
451
452 hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size);
453
454 npda->pdinfo = (void *)hubdev_info;
455}
456
457geoid_t
458cnodeid_get_geoid(cnodeid_t cnode)
459{
460 struct hubdev_info *hubdev;
461
462 hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
463 return hubdev->hdi_geoid;
464}
465
466void sn_generate_path(struct pci_bus *pci_bus, char *address)
467{
468 nasid_t nasid;
469 cnodeid_t cnode;
470 geoid_t geoid;
471 moduleid_t moduleid;
472 u16 bricktype;
473
474 nasid = NASID_GET(SN_PCIBUS_BUSSOFT(pci_bus)->bs_base);
475 cnode = nasid_to_cnodeid(nasid);
476 geoid = cnodeid_get_geoid(cnode);
477 moduleid = geo_module(geoid);
478
479 sprintf(address, "module_%c%c%c%c%.2d",
480 '0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)),
481 '0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)),
482 '0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)),
483 MODULE_GET_BTCHAR(moduleid), MODULE_GET_BPOS(moduleid));
484
485 /* Tollhouse requires slot id to be displayed */
486 bricktype = MODULE_GET_BTYPE(moduleid);
487 if ((bricktype == L1_BRICKTYPE_191010) ||
488 (bricktype == L1_BRICKTYPE_1932))
489 sprintf(address, "%s^%d", address, geo_slot(geoid));
490}
491
492/*
493 * sn_pci_fixup_bus() - Perform SN specific setup of software structs
494 * (pcibus_bussoft, pcidev_info) and hardware
495 * registers, for the specified bus and devices under it.
496 */
497void __devinit
498sn_pci_fixup_bus(struct pci_bus *bus)
499{
500
501 if (SN_ACPI_BASE_SUPPORT())
502 sn_acpi_bus_fixup(bus);
503 else
504 sn_bus_fixup(bus);
505}
506
507/*
508 * sn_io_early_init - Perform early IO (and some non-IO) initialization.
509 * In particular, setup the sn_pci_provider[] array.
510 * This needs to be done prior to any bus scanning
511 * (acpi_scan_init()) in the ACPI case, as the SN
512 * bus fixup code will reference the array.
513 */
514static int __init
515sn_io_early_init(void)
516{
517 int i;
518
519 if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
520 return 0;
521
522 /*
523 * prime sn_pci_provider[]. Individial provider init routines will
524 * override their respective default entries.
525 */
526
527 for (i = 0; i < PCIIO_ASIC_MAX_TYPES; i++)
528 sn_pci_provider[i] = &sn_pci_default_provider;
529
530 pcibr_init_provider();
531 tioca_init_provider();
532 tioce_init_provider();
533
534 /*
535 * This is needed to avoid bounce limit checks in the blk layer
536 */
537 ia64_max_iommu_merge_mask = ~PAGE_MASK;
538
539 sn_irq_lh_init();
540 INIT_LIST_HEAD(&sn_sysdata_list);
541 sn_init_cpei_timer();
542
543#ifdef CONFIG_PROC_FS
544 register_sn_procfs();
545#endif
546
547 printk(KERN_INFO "ACPI DSDT OEM Rev 0x%x\n",
548 acpi_gbl_DSDT->oem_revision);
549 if (SN_ACPI_BASE_SUPPORT())
550 sn_io_acpi_init();
551 else
552 sn_io_init();
553 return 0;
554}
555
556arch_initcall(sn_io_early_init);
557
558/*
559 * sn_io_late_init() - Perform any final platform specific IO initialization.
560 */
561
562int __init
563sn_io_late_init(void)
564{
565 struct pci_bus *bus;
566 struct pcibus_bussoft *bussoft;
567 cnodeid_t cnode;
568 nasid_t nasid;
569 cnodeid_t near_cnode;
570
571 if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
572 return 0;
573
574 /*
575 * Setup closest node in pci_controller->node for
576 * PIC, TIOCP, TIOCE (TIOCA does it during bus fixup using
577 * info from the PROM).
578 */
579 bus = NULL;
580 while ((bus = pci_find_next_bus(bus)) != NULL) {
581 bussoft = SN_PCIBUS_BUSSOFT(bus);
582 nasid = NASID_GET(bussoft->bs_base);
583 cnode = nasid_to_cnodeid(nasid);
584 if ((bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP) ||
585 (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCE)) {
586 /* TIO PCI Bridge: find nearest node with CPUs */
587 int e = sn_hwperf_get_nearest_node(cnode, NULL,
588 &near_cnode);
589 if (e < 0) {
590 near_cnode = (cnodeid_t)-1; /* use any node */
591 printk(KERN_WARNING "pcibr_bus_fixup: failed "
592 "to find near node with CPUs to TIO "
593 "node %d, err=%d\n", cnode, e);
594 }
595 PCI_CONTROLLER(bus)->node = near_cnode;
596 } else if (bussoft->bs_asic_type == PCIIO_ASIC_TYPE_PIC) {
597 PCI_CONTROLLER(bus)->node = cnode;
598 }
599 }
600
601 sn_ioif_inited = 1; /* SN I/O infrastructure now initialized */
602
603 return 0;
604}
605
606fs_initcall(sn_io_late_init);
607
608EXPORT_SYMBOL(sn_pci_fixup_slot);
609EXPORT_SYMBOL(sn_pci_unfixup_slot);
610EXPORT_SYMBOL(sn_bus_store_sysdata);
611EXPORT_SYMBOL(sn_bus_free_sysdata);
612EXPORT_SYMBOL(sn_generate_path);
613
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index dc09a6a28a37..9ad843e0383b 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -3,103 +3,28 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1992 - 1997, 2000-2006 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9#include <linux/bootmem.h>
10#include <linux/nodemask.h>
11#include <asm/sn/types.h> 9#include <asm/sn/types.h>
12#include <asm/sn/addrs.h> 10#include <asm/sn/addrs.h>
13#include <asm/sn/sn_feature_sets.h>
14#include <asm/sn/geo.h>
15#include <asm/sn/io.h> 11#include <asm/sn/io.h>
16#include <asm/sn/l1.h>
17#include <asm/sn/module.h> 12#include <asm/sn/module.h>
18#include <asm/sn/pcibr_provider.h> 13#include <asm/sn/intr.h>
19#include <asm/sn/pcibus_provider_defs.h> 14#include <asm/sn/pcibus_provider_defs.h>
20#include <asm/sn/pcidev.h> 15#include <asm/sn/pcidev.h>
21#include <asm/sn/simulator.h>
22#include <asm/sn/sn_sal.h> 16#include <asm/sn/sn_sal.h>
23#include <asm/sn/tioca_provider.h>
24#include <asm/sn/tioce_provider.h>
25#include "xtalk/hubdev.h" 17#include "xtalk/hubdev.h"
26#include "xtalk/xwidgetdev.h"
27
28
29extern void sn_init_cpei_timer(void);
30extern void register_sn_procfs(void);
31
32static struct list_head sn_sysdata_list;
33
34/* sysdata list struct */
35struct sysdata_el {
36 struct list_head entry;
37 void *sysdata;
38};
39
40struct slab_info {
41 struct hubdev_info hubdev;
42};
43
44struct brick {
45 moduleid_t id; /* Module ID of this module */
46 struct slab_info slab_info[MAX_SLABS + 1];
47};
48
49int sn_ioif_inited; /* SN I/O infrastructure initialized? */
50
51struct sn_pcibus_provider *sn_pci_provider[PCIIO_ASIC_MAX_TYPES]; /* indexed by asic type */
52
53static int max_segment_number; /* Default highest segment number */
54static int max_pcibus_number = 255; /* Default highest pci bus number */
55 18
56/* 19/*
57 * Hooks and struct for unsupported pci providers 20 * The code in this file will only be executed when running with
21 * a PROM that does _not_ have base ACPI IO support.
22 * (i.e., SN_ACPI_BASE_SUPPORT() == 0)
58 */ 23 */
59 24
60static dma_addr_t 25static int max_segment_number; /* Default highest segment number */
61sn_default_pci_map(struct pci_dev *pdev, unsigned long paddr, size_t size, int type) 26static int max_pcibus_number = 255; /* Default highest pci bus number */
62{
63 return 0;
64}
65
66static void
67sn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction)
68{
69 return;
70}
71
72static void *
73sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller)
74{
75 return NULL;
76}
77
78static struct sn_pcibus_provider sn_pci_default_provider = {
79 .dma_map = sn_default_pci_map,
80 .dma_map_consistent = sn_default_pci_map,
81 .dma_unmap = sn_default_pci_unmap,
82 .bus_fixup = sn_default_pci_bus_fixup,
83};
84
85/*
86 * Retrieve the DMA Flush List given nasid, widget, and device.
87 * This list is needed to implement the WAR - Flush DMA data on PIO Reads.
88 */
89static inline u64
90sal_get_device_dmaflush_list(u64 nasid, u64 widget_num, u64 device_num,
91 u64 address)
92{
93 struct ia64_sal_retval ret_stuff;
94 ret_stuff.status = 0;
95 ret_stuff.v0 = 0;
96 27
97 SAL_CALL_NOLOCK(ret_stuff,
98 (u64) SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST,
99 (u64) nasid, (u64) widget_num,
100 (u64) device_num, (u64) address, 0, 0, 0);
101 return ret_stuff.status;
102}
103 28
104/* 29/*
105 * Retrieve the hub device info structure for the given nasid. 30 * Retrieve the hub device info structure for the given nasid.
@@ -131,93 +56,20 @@ static inline u64 sal_get_pcibus_info(u64 segment, u64 busnum, u64 address)
131 return ret_stuff.v0; 56 return ret_stuff.v0;
132} 57}
133 58
134/*
135 * Retrieve the pci device information given the bus and device|function number.
136 */
137static inline u64
138sal_get_pcidev_info(u64 segment, u64 bus_number, u64 devfn, u64 pci_dev,
139 u64 sn_irq_info)
140{
141 struct ia64_sal_retval ret_stuff;
142 ret_stuff.status = 0;
143 ret_stuff.v0 = 0;
144
145 SAL_CALL_NOLOCK(ret_stuff,
146 (u64) SN_SAL_IOIF_GET_PCIDEV_INFO,
147 (u64) segment, (u64) bus_number, (u64) devfn,
148 (u64) pci_dev,
149 sn_irq_info, 0, 0);
150 return ret_stuff.v0;
151}
152
153/*
154 * sn_pcidev_info_get() - Retrieve the pcidev_info struct for the specified
155 * device.
156 */
157inline struct pcidev_info *
158sn_pcidev_info_get(struct pci_dev *dev)
159{
160 struct pcidev_info *pcidev;
161
162 list_for_each_entry(pcidev,
163 &(SN_PCI_CONTROLLER(dev)->pcidev_info), pdi_list) {
164 if (pcidev->pdi_linux_pcidev == dev) {
165 return pcidev;
166 }
167 }
168 return NULL;
169}
170
171/* Older PROM flush WAR
172 *
173 * 01/16/06 -- This war will be in place until a new official PROM is released.
174 * Additionally note that the struct sn_flush_device_war also has to be
175 * removed from arch/ia64/sn/include/xtalk/hubdev.h
176 */
177static u8 war_implemented = 0;
178
179static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
180 struct sn_flush_device_common *common)
181{
182 struct sn_flush_device_war *war_list;
183 struct sn_flush_device_war *dev_entry;
184 struct ia64_sal_retval isrv = {0,0,0,0};
185
186 if (!war_implemented) {
187 printk(KERN_WARNING "PROM version < 4.50 -- implementing old "
188 "PROM flush WAR\n");
189 war_implemented = 1;
190 }
191
192 war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
193 if (!war_list)
194 BUG();
195
196 SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
197 nasid, widget, __pa(war_list), 0, 0, 0 ,0);
198 if (isrv.status)
199 panic("sn_device_fixup_war failed: %s\n",
200 ia64_sal_strerror(isrv.status));
201
202 dev_entry = war_list + device;
203 memcpy(common,dev_entry, sizeof(*common));
204 kfree(war_list);
205
206 return isrv.status;
207}
208 59
209/* 60/*
210 * sn_fixup_ionodes() - This routine initializes the HUB data strcuture for 61 * sn_fixup_ionodes() - This routine initializes the HUB data structure for
211 * each node in the system. 62 * each node in the system. This function is only
63 * executed when running with a non-ACPI capable PROM.
212 */ 64 */
213static void __init sn_fixup_ionodes(void) 65static void __init sn_fixup_ionodes(void)
214{ 66{
215 struct sn_flush_device_kernel *sn_flush_device_kernel; 67
216 struct sn_flush_device_kernel *dev_entry;
217 struct hubdev_info *hubdev; 68 struct hubdev_info *hubdev;
218 u64 status; 69 u64 status;
219 u64 nasid; 70 u64 nasid;
220 int i, widget, device, size; 71 int i;
72 extern void sn_common_hubdev_init(struct hubdev_info *);
221 73
222 /* 74 /*
223 * Get SGI Specific HUB chipset information. 75 * Get SGI Specific HUB chipset information.
@@ -240,70 +92,47 @@ static void __init sn_fixup_ionodes(void)
240 max_segment_number = hubdev->max_segment_number; 92 max_segment_number = hubdev->max_segment_number;
241 max_pcibus_number = hubdev->max_pcibus_number; 93 max_pcibus_number = hubdev->max_pcibus_number;
242 } 94 }
95 sn_common_hubdev_init(hubdev);
96 }
97}
243 98
244 /* Attach the error interrupt handlers */ 99/*
245 if (nasid & 1) 100 * sn_pci_legacy_window_fixup - Create PCI controller windows for
246 ice_error_init(hubdev); 101 * legacy IO and MEM space. This needs to
247 else 102 * be done here, as the PROM does not have
248 hub_error_init(hubdev); 103 * ACPI support defining the root buses
249 104 * and their resources (_CRS),
250 for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) 105 */
251 hubdev->hdi_xwidget_info[widget].xwi_hubinfo = hubdev; 106static void
252 107sn_legacy_pci_window_fixup(struct pci_controller *controller,
253 if (!hubdev->hdi_flush_nasid_list.widget_p) 108 u64 legacy_io, u64 legacy_mem)
254 continue; 109{
255 110 controller->window = kcalloc(2, sizeof(struct pci_window),
256 size = (HUB_WIDGET_ID_MAX + 1) * 111 GFP_KERNEL);
257 sizeof(struct sn_flush_device_kernel *); 112 if (controller->window == NULL)
258 hubdev->hdi_flush_nasid_list.widget_p =
259 kzalloc(size, GFP_KERNEL);
260 if (!hubdev->hdi_flush_nasid_list.widget_p)
261 BUG(); 113 BUG();
262 114 controller->window[0].offset = legacy_io;
263 for (widget = 0; widget <= HUB_WIDGET_ID_MAX; widget++) { 115 controller->window[0].resource.name = "legacy_io";
264 size = DEV_PER_WIDGET * 116 controller->window[0].resource.flags = IORESOURCE_IO;
265 sizeof(struct sn_flush_device_kernel); 117 controller->window[0].resource.start = legacy_io;
266 sn_flush_device_kernel = kzalloc(size, GFP_KERNEL); 118 controller->window[0].resource.end =
267 if (!sn_flush_device_kernel) 119 controller->window[0].resource.start + 0xffff;
268 BUG(); 120 controller->window[0].resource.parent = &ioport_resource;
269 121 controller->window[1].offset = legacy_mem;
270 dev_entry = sn_flush_device_kernel; 122 controller->window[1].resource.name = "legacy_mem";
271 for (device = 0; device < DEV_PER_WIDGET; 123 controller->window[1].resource.flags = IORESOURCE_MEM;
272 device++,dev_entry++) { 124 controller->window[1].resource.start = legacy_mem;
273 size = sizeof(struct sn_flush_device_common); 125 controller->window[1].resource.end =
274 dev_entry->common = kzalloc(size, GFP_KERNEL); 126 controller->window[1].resource.start + (1024 * 1024) - 1;
275 if (!dev_entry->common) 127 controller->window[1].resource.parent = &iomem_resource;
276 BUG(); 128 controller->windows = 2;
277
278 if (sn_prom_feature_available(
279 PRF_DEVICE_FLUSH_LIST))
280 status = sal_get_device_dmaflush_list(
281 nasid, widget, device,
282 (u64)(dev_entry->common));
283 else
284 status = sn_device_fixup_war(nasid,
285 widget, device,
286 dev_entry->common);
287 if (status != SALRET_OK)
288 panic("SAL call failed: %s\n",
289 ia64_sal_strerror(status));
290
291 spin_lock_init(&dev_entry->sfdl_flush_lock);
292 }
293
294 if (sn_flush_device_kernel)
295 hubdev->hdi_flush_nasid_list.widget_p[widget] =
296 sn_flush_device_kernel;
297 }
298 }
299} 129}
300 130
301/* 131/*
302 * sn_pci_window_fixup() - Create a pci_window for each device resource. 132 * sn_pci_window_fixup() - Create a pci_window for each device resource.
303 * Until ACPI support is added, we need this code 133 * It will setup pci_windows for use by
304 * to setup pci_windows for use by 134 * pcibios_bus_to_resource(), pcibios_resource_to_bus(),
305 * pcibios_bus_to_resource(), 135 * etc.
306 * pcibios_resource_to_bus(), etc.
307 */ 136 */
308static void 137static void
309sn_pci_window_fixup(struct pci_dev *dev, unsigned int count, 138sn_pci_window_fixup(struct pci_dev *dev, unsigned int count,
@@ -342,60 +171,22 @@ sn_pci_window_fixup(struct pci_dev *dev, unsigned int count,
342 controller->window = new_window; 171 controller->window = new_window;
343} 172}
344 173
345void sn_pci_unfixup_slot(struct pci_dev *dev)
346{
347 struct pci_dev *host_pci_dev = SN_PCIDEV_INFO(dev)->host_pci_dev;
348
349 sn_irq_unfixup(dev);
350 pci_dev_put(host_pci_dev);
351 pci_dev_put(dev);
352}
353
354/* 174/*
355 * sn_pci_fixup_slot() - This routine sets up a slot's resources 175 * sn_more_slot_fixup() - We are not running with an ACPI capable PROM,
356 * consistent with the Linux PCI abstraction layer. Resources acquired 176 * and need to convert the pci_dev->resource
357 * from our PCI provider include PIO maps to BAR space and interrupt 177 * 'start' and 'end' addresses to mapped addresses,
358 * objects. 178 * and setup the pci_controller->window array entries.
359 */ 179 */
360void sn_pci_fixup_slot(struct pci_dev *dev) 180void
181sn_more_slot_fixup(struct pci_dev *dev, struct pcidev_info *pcidev_info)
361{ 182{
362 unsigned int count = 0; 183 unsigned int count = 0;
363 int idx; 184 int idx;
364 int segment = pci_domain_nr(dev->bus);
365 int status = 0;
366 struct pcibus_bussoft *bs;
367 struct pci_bus *host_pci_bus;
368 struct pci_dev *host_pci_dev;
369 struct pcidev_info *pcidev_info;
370 s64 pci_addrs[PCI_ROM_RESOURCE + 1]; 185 s64 pci_addrs[PCI_ROM_RESOURCE + 1];
371 struct sn_irq_info *sn_irq_info; 186 unsigned long addr, end, size, start;
372 unsigned long size;
373 unsigned int bus_no, devfn;
374
375 pci_dev_get(dev); /* for the sysdata pointer */
376 pcidev_info = kzalloc(sizeof(struct pcidev_info), GFP_KERNEL);
377 if (!pcidev_info)
378 BUG(); /* Cannot afford to run out of memory */
379
380 sn_irq_info = kzalloc(sizeof(struct sn_irq_info), GFP_KERNEL);
381 if (!sn_irq_info)
382 BUG(); /* Cannot afford to run out of memory */
383
384 /* Call to retrieve pci device information needed by kernel. */
385 status = sal_get_pcidev_info((u64) segment, (u64) dev->bus->number,
386 dev->devfn,
387 (u64) __pa(pcidev_info),
388 (u64) __pa(sn_irq_info));
389 if (status)
390 BUG(); /* Cannot get platform pci device information */
391
392 /* Add pcidev_info to list in sn_pci_controller struct */
393 list_add_tail(&pcidev_info->pdi_list,
394 &(SN_PCI_CONTROLLER(dev->bus)->pcidev_info));
395 187
396 /* Copy over PIO Mapped Addresses */ 188 /* Copy over PIO Mapped Addresses */
397 for (idx = 0; idx <= PCI_ROM_RESOURCE; idx++) { 189 for (idx = 0; idx <= PCI_ROM_RESOURCE; idx++) {
398 unsigned long start, end, addr;
399 190
400 if (!pcidev_info->pdi_pio_mapped_addr[idx]) { 191 if (!pcidev_info->pdi_pio_mapped_addr[idx]) {
401 pci_addrs[idx] = -1; 192 pci_addrs[idx] = -1;
@@ -419,60 +210,28 @@ void sn_pci_fixup_slot(struct pci_dev *dev)
419 dev->resource[idx].parent = &ioport_resource; 210 dev->resource[idx].parent = &ioport_resource;
420 else 211 else
421 dev->resource[idx].parent = &iomem_resource; 212 dev->resource[idx].parent = &iomem_resource;
213 /* If ROM, mark as shadowed in PROM */
214 if (idx == PCI_ROM_RESOURCE)
215 dev->resource[idx].flags |= IORESOURCE_ROM_BIOS_COPY;
422 } 216 }
423 /* Create a pci_window in the pci_controller struct for 217 /* Create a pci_window in the pci_controller struct for
424 * each device resource. 218 * each device resource.
425 */ 219 */
426 if (count > 0) 220 if (count > 0)
427 sn_pci_window_fixup(dev, count, pci_addrs); 221 sn_pci_window_fixup(dev, count, pci_addrs);
428
429 /*
430 * Using the PROMs values for the PCI host bus, get the Linux
431 * PCI host_pci_dev struct and set up host bus linkages
432 */
433
434 bus_no = (pcidev_info->pdi_slot_host_handle >> 32) & 0xff;
435 devfn = pcidev_info->pdi_slot_host_handle & 0xffffffff;
436 host_pci_bus = pci_find_bus(segment, bus_no);
437 host_pci_dev = pci_get_slot(host_pci_bus, devfn);
438
439 pcidev_info->host_pci_dev = host_pci_dev;
440 pcidev_info->pdi_linux_pcidev = dev;
441 pcidev_info->pdi_host_pcidev_info = SN_PCIDEV_INFO(host_pci_dev);
442 bs = SN_PCIBUS_BUSSOFT(dev->bus);
443 pcidev_info->pdi_pcibus_info = bs;
444
445 if (bs && bs->bs_asic_type < PCIIO_ASIC_MAX_TYPES) {
446 SN_PCIDEV_BUSPROVIDER(dev) = sn_pci_provider[bs->bs_asic_type];
447 } else {
448 SN_PCIDEV_BUSPROVIDER(dev) = &sn_pci_default_provider;
449 }
450
451 /* Only set up IRQ stuff if this device has a host bus context */
452 if (bs && sn_irq_info->irq_irq) {
453 pcidev_info->pdi_sn_irq_info = sn_irq_info;
454 dev->irq = pcidev_info->pdi_sn_irq_info->irq_irq;
455 sn_irq_fixup(dev, sn_irq_info);
456 } else {
457 pcidev_info->pdi_sn_irq_info = NULL;
458 kfree(sn_irq_info);
459 }
460} 222}
461 223
462/* 224/*
463 * sn_pci_controller_fixup() - This routine sets up a bus's resources 225 * sn_pci_controller_fixup() - This routine sets up a bus's resources
464 * consistent with the Linux PCI abstraction layer. 226 * consistent with the Linux PCI abstraction layer.
465 */ 227 */
466void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) 228static void
229sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
467{ 230{
468 int status; 231 s64 status = 0;
469 int nasid, cnode;
470 struct pci_controller *controller; 232 struct pci_controller *controller;
471 struct sn_pci_controller *sn_controller;
472 struct pcibus_bussoft *prom_bussoft_ptr; 233 struct pcibus_bussoft *prom_bussoft_ptr;
473 struct hubdev_info *hubdev_info; 234
474 void *provider_soft;
475 struct sn_pcibus_provider *provider;
476 235
477 status = sal_get_pcibus_info((u64) segment, (u64) busnum, 236 status = sal_get_pcibus_info((u64) segment, (u64) busnum,
478 (u64) ia64_tpa(&prom_bussoft_ptr)); 237 (u64) ia64_tpa(&prom_bussoft_ptr));
@@ -480,261 +239,77 @@ void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
480 return; /*bus # does not exist */ 239 return; /*bus # does not exist */
481 prom_bussoft_ptr = __va(prom_bussoft_ptr); 240 prom_bussoft_ptr = __va(prom_bussoft_ptr);
482 241
483 /* Allocate a sn_pci_controller, which has a pci_controller struct 242 controller = kzalloc(sizeof(*controller), GFP_KERNEL);
484 * as the first member. 243 if (!controller)
485 */
486 sn_controller = kzalloc(sizeof(struct sn_pci_controller), GFP_KERNEL);
487 if (!sn_controller)
488 BUG(); 244 BUG();
489 INIT_LIST_HEAD(&sn_controller->pcidev_info);
490 controller = &sn_controller->pci_controller;
491 controller->segment = segment; 245 controller->segment = segment;
492 246
493 if (bus == NULL) {
494 bus = pci_scan_bus(busnum, &pci_root_ops, controller);
495 if (bus == NULL)
496 goto error_return; /* error, or bus already scanned */
497 bus->sysdata = NULL;
498 }
499
500 if (bus->sysdata)
501 goto error_return; /* sysdata already alloc'd */
502
503 /* 247 /*
504 * Per-provider fixup. Copies the contents from prom to local 248 * Temporarily save the prom_bussoft_ptr for use by sn_bus_fixup().
505 * area and links SN_PCIBUS_BUSSOFT(). 249 * (platform_data will be overwritten later in sn_common_bus_fixup())
506 */ 250 */
251 controller->platform_data = prom_bussoft_ptr;
507 252
508 if (prom_bussoft_ptr->bs_asic_type >= PCIIO_ASIC_MAX_TYPES) 253 bus = pci_scan_bus(busnum, &pci_root_ops, controller);
509 goto error_return; /* unsupported asic type */ 254 if (bus == NULL)
510 255 goto error_return; /* error, or bus already scanned */
511 if (prom_bussoft_ptr->bs_asic_type == PCIIO_ASIC_TYPE_PPB)
512 goto error_return; /* no further fixup necessary */
513
514 provider = sn_pci_provider[prom_bussoft_ptr->bs_asic_type];
515 if (provider == NULL)
516 goto error_return; /* no provider registerd for this asic */
517 256
518 bus->sysdata = controller; 257 bus->sysdata = controller;
519 if (provider->bus_fixup)
520 provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller);
521 else
522 provider_soft = NULL;
523
524 if (provider_soft == NULL) {
525 /* fixup failed or not applicable */
526 bus->sysdata = NULL;
527 goto error_return;
528 }
529
530 /*
531 * Setup pci_windows for legacy IO and MEM space.
532 * (Temporary until ACPI support is in place.)
533 */
534 controller->window = kcalloc(2, sizeof(struct pci_window), GFP_KERNEL);
535 if (controller->window == NULL)
536 BUG();
537 controller->window[0].offset = prom_bussoft_ptr->bs_legacy_io;
538 controller->window[0].resource.name = "legacy_io";
539 controller->window[0].resource.flags = IORESOURCE_IO;
540 controller->window[0].resource.start = prom_bussoft_ptr->bs_legacy_io;
541 controller->window[0].resource.end =
542 controller->window[0].resource.start + 0xffff;
543 controller->window[0].resource.parent = &ioport_resource;
544 controller->window[1].offset = prom_bussoft_ptr->bs_legacy_mem;
545 controller->window[1].resource.name = "legacy_mem";
546 controller->window[1].resource.flags = IORESOURCE_MEM;
547 controller->window[1].resource.start = prom_bussoft_ptr->bs_legacy_mem;
548 controller->window[1].resource.end =
549 controller->window[1].resource.start + (1024 * 1024) - 1;
550 controller->window[1].resource.parent = &iomem_resource;
551 controller->windows = 2;
552
553 /*
554 * Generic bus fixup goes here. Don't reference prom_bussoft_ptr
555 * after this point.
556 */
557
558 PCI_CONTROLLER(bus)->platform_data = provider_soft;
559 nasid = NASID_GET(SN_PCIBUS_BUSSOFT(bus)->bs_base);
560 cnode = nasid_to_cnodeid(nasid);
561 hubdev_info = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
562 SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info =
563 &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]);
564 258
565 /*
566 * If the node information we obtained during the fixup phase is invalid
567 * then set controller->node to -1 (undetermined)
568 */
569 if (controller->node >= num_online_nodes()) {
570 struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus);
571
572 printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%u"
573 "L_IO=%lx L_MEM=%lx BASE=%lx\n",
574 b->bs_asic_type, b->bs_xid, b->bs_persist_busnum,
575 b->bs_legacy_io, b->bs_legacy_mem, b->bs_base);
576 printk(KERN_WARNING "on node %d but only %d nodes online."
577 "Association set to undetermined.\n",
578 controller->node, num_online_nodes());
579 controller->node = -1;
580 }
581 return; 259 return;
582 260
583error_return: 261error_return:
584 262
585 kfree(sn_controller); 263 kfree(controller);
586 return; 264 return;
587} 265}
588 266
589void sn_bus_store_sysdata(struct pci_dev *dev) 267/*
268 * sn_bus_fixup
269 */
270void
271sn_bus_fixup(struct pci_bus *bus)
590{ 272{
591 struct sysdata_el *element; 273 struct pci_dev *pci_dev = NULL;
592 274 struct pcibus_bussoft *prom_bussoft_ptr;
593 element = kzalloc(sizeof(struct sysdata_el), GFP_KERNEL); 275 extern void sn_common_bus_fixup(struct pci_bus *,
594 if (!element) { 276 struct pcibus_bussoft *);
595 dev_dbg(dev, "%s: out of memory!\n", __FUNCTION__); 277
596 return; 278
597 } 279 if (!bus->parent) { /* If root bus */
598 element->sysdata = SN_PCIDEV_INFO(dev); 280 prom_bussoft_ptr = PCI_CONTROLLER(bus)->platform_data;
599 list_add(&element->entry, &sn_sysdata_list); 281 if (prom_bussoft_ptr == NULL) {
600} 282 printk(KERN_ERR
283 "sn_bus_fixup: 0x%04x:0x%02x Unable to "
284 "obtain prom_bussoft_ptr\n",
285 pci_domain_nr(bus), bus->number);
286 return;
287 }
288 sn_common_bus_fixup(bus, prom_bussoft_ptr);
289 sn_legacy_pci_window_fixup(PCI_CONTROLLER(bus),
290 prom_bussoft_ptr->bs_legacy_io,
291 prom_bussoft_ptr->bs_legacy_mem);
292 }
293 list_for_each_entry(pci_dev, &bus->devices, bus_list) {
294 sn_pci_fixup_slot(pci_dev);
295 }
601 296
602void sn_bus_free_sysdata(void)
603{
604 struct sysdata_el *element;
605 struct list_head *list, *safe;
606
607 list_for_each_safe(list, safe, &sn_sysdata_list) {
608 element = list_entry(list, struct sysdata_el, entry);
609 list_del(&element->entry);
610 list_del(&(((struct pcidev_info *)
611 (element->sysdata))->pdi_list));
612 kfree(element->sysdata);
613 kfree(element);
614 }
615 return;
616} 297}
617 298
618/* 299/*
619 * Ugly hack to get PCI setup until we have a proper ACPI namespace. 300 * sn_io_init - PROM does not have ACPI support to define nodes or root buses,
301 * so we need to do things the hard way, including initiating the
302 * bus scanning ourselves.
620 */ 303 */
621 304
622#define PCI_BUSES_TO_SCAN 256 305void __init sn_io_init(void)
623
624static int __init sn_pci_init(void)
625{ 306{
626 int i, j; 307 int i, j;
627 struct pci_dev *pci_dev = NULL;
628
629 if (!ia64_platform_is("sn2") || IS_RUNNING_ON_FAKE_PROM())
630 return 0;
631
632 /*
633 * prime sn_pci_provider[]. Individial provider init routines will
634 * override their respective default entries.
635 */
636
637 for (i = 0; i < PCIIO_ASIC_MAX_TYPES; i++)
638 sn_pci_provider[i] = &sn_pci_default_provider;
639 308
640 pcibr_init_provider();
641 tioca_init_provider();
642 tioce_init_provider();
643
644 /*
645 * This is needed to avoid bounce limit checks in the blk layer
646 */
647 ia64_max_iommu_merge_mask = ~PAGE_MASK;
648 sn_fixup_ionodes(); 309 sn_fixup_ionodes();
649 sn_irq_lh_init();
650 INIT_LIST_HEAD(&sn_sysdata_list);
651 sn_init_cpei_timer();
652
653#ifdef CONFIG_PROC_FS
654 register_sn_procfs();
655#endif
656 310
657 /* busses are not known yet ... */ 311 /* busses are not known yet ... */
658 for (i = 0; i <= max_segment_number; i++) 312 for (i = 0; i <= max_segment_number; i++)
659 for (j = 0; j <= max_pcibus_number; j++) 313 for (j = 0; j <= max_pcibus_number; j++)
660 sn_pci_controller_fixup(i, j, NULL); 314 sn_pci_controller_fixup(i, j, NULL);
661
662 /*
663 * Generic Linux PCI Layer has created the pci_bus and pci_dev
664 * structures - time for us to add our SN PLatform specific
665 * information.
666 */
667
668 while ((pci_dev =
669 pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL)
670 sn_pci_fixup_slot(pci_dev);
671
672 sn_ioif_inited = 1; /* sn I/O infrastructure now initialized */
673
674 return 0;
675}
676
677/*
678 * hubdev_init_node() - Creates the HUB data structure and link them to it's
679 * own NODE specific data area.
680 */
681void hubdev_init_node(nodepda_t * npda, cnodeid_t node)
682{
683 struct hubdev_info *hubdev_info;
684 int size;
685 pg_data_t *pg;
686
687 size = sizeof(struct hubdev_info);
688
689 if (node >= num_online_nodes()) /* Headless/memless IO nodes */
690 pg = NODE_DATA(0);
691 else
692 pg = NODE_DATA(node);
693
694 hubdev_info = (struct hubdev_info *)alloc_bootmem_node(pg, size);
695
696 npda->pdinfo = (void *)hubdev_info;
697} 315}
698
699geoid_t
700cnodeid_get_geoid(cnodeid_t cnode)
701{
702 struct hubdev_info *hubdev;
703
704 hubdev = (struct hubdev_info *)(NODEPDA(cnode)->pdinfo);
705 return hubdev->hdi_geoid;
706}
707
708void sn_generate_path(struct pci_bus *pci_bus, char *address)
709{
710 nasid_t nasid;
711 cnodeid_t cnode;
712 geoid_t geoid;
713 moduleid_t moduleid;
714 u16 bricktype;
715
716 nasid = NASID_GET(SN_PCIBUS_BUSSOFT(pci_bus)->bs_base);
717 cnode = nasid_to_cnodeid(nasid);
718 geoid = cnodeid_get_geoid(cnode);
719 moduleid = geo_module(geoid);
720
721 sprintf(address, "module_%c%c%c%c%.2d",
722 '0'+RACK_GET_CLASS(MODULE_GET_RACK(moduleid)),
723 '0'+RACK_GET_GROUP(MODULE_GET_RACK(moduleid)),
724 '0'+RACK_GET_NUM(MODULE_GET_RACK(moduleid)),
725 MODULE_GET_BTCHAR(moduleid), MODULE_GET_BPOS(moduleid));
726
727 /* Tollhouse requires slot id to be displayed */
728 bricktype = MODULE_GET_BTYPE(moduleid);
729 if ((bricktype == L1_BRICKTYPE_191010) ||
730 (bricktype == L1_BRICKTYPE_1932))
731 sprintf(address, "%s^%d", address, geo_slot(geoid));
732}
733
734subsys_initcall(sn_pci_init);
735EXPORT_SYMBOL(sn_pci_fixup_slot);
736EXPORT_SYMBOL(sn_pci_unfixup_slot);
737EXPORT_SYMBOL(sn_pci_controller_fixup);
738EXPORT_SYMBOL(sn_bus_store_sysdata);
739EXPORT_SYMBOL(sn_bus_free_sysdata);
740EXPORT_SYMBOL(sn_generate_path);
diff --git a/arch/ia64/sn/kernel/iomv.c b/arch/ia64/sn/kernel/iomv.c
index 7ce3cdad627b..4aa4f301d56d 100644
--- a/arch/ia64/sn/kernel/iomv.c
+++ b/arch/ia64/sn/kernel/iomv.c
@@ -3,10 +3,11 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 2000-2003, 2006 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/acpi.h>
10#include <asm/io.h> 11#include <asm/io.h>
11#include <asm/delay.h> 12#include <asm/delay.h>
12#include <asm/vga.h> 13#include <asm/vga.h>
@@ -15,6 +16,7 @@
15#include <asm/sn/pda.h> 16#include <asm/sn/pda.h>
16#include <asm/sn/sn_cpuid.h> 17#include <asm/sn/sn_cpuid.h>
17#include <asm/sn/shub_mmr.h> 18#include <asm/sn/shub_mmr.h>
19#include <asm/sn/acpi.h>
18 20
19#define IS_LEGACY_VGA_IOPORT(p) \ 21#define IS_LEGACY_VGA_IOPORT(p) \
20 (((p) >= 0x3b0 && (p) <= 0x3bb) || ((p) >= 0x3c0 && (p) <= 0x3df)) 22 (((p) >= 0x3b0 && (p) <= 0x3bb) || ((p) >= 0x3c0 && (p) <= 0x3df))
@@ -31,11 +33,14 @@ void *sn_io_addr(unsigned long port)
31{ 33{
32 if (!IS_RUNNING_ON_SIMULATOR()) { 34 if (!IS_RUNNING_ON_SIMULATOR()) {
33 if (IS_LEGACY_VGA_IOPORT(port)) 35 if (IS_LEGACY_VGA_IOPORT(port))
34 port += vga_console_iobase; 36 return (__ia64_mk_io_addr(port));
35 /* On sn2, legacy I/O ports don't point at anything */ 37 /* On sn2, legacy I/O ports don't point at anything */
36 if (port < (64 * 1024)) 38 if (port < (64 * 1024))
37 return NULL; 39 return NULL;
38 return ((void *)(port | __IA64_UNCACHED_OFFSET)); 40 if (SN_ACPI_BASE_SUPPORT())
41 return (__ia64_mk_io_addr(port));
42 else
43 return ((void *)(port | __IA64_UNCACHED_OFFSET));
39 } else { 44 } else {
40 /* but the simulator uses them... */ 45 /* but the simulator uses them... */
41 unsigned long addr; 46 unsigned long addr;
diff --git a/arch/ia64/sn/kernel/setup.c b/arch/ia64/sn/kernel/setup.c
index 7a2d824c5ce3..1d009f93244d 100644
--- a/arch/ia64/sn/kernel/setup.c
+++ b/arch/ia64/sn/kernel/setup.c
@@ -388,6 +388,14 @@ void __init sn_setup(char **cmdline_p)
388 ia64_sn_plat_set_error_handling_features(); // obsolete 388 ia64_sn_plat_set_error_handling_features(); // obsolete
389 ia64_sn_set_os_feature(OSF_MCA_SLV_TO_OS_INIT_SLV); 389 ia64_sn_set_os_feature(OSF_MCA_SLV_TO_OS_INIT_SLV);
390 ia64_sn_set_os_feature(OSF_FEAT_LOG_SBES); 390 ia64_sn_set_os_feature(OSF_FEAT_LOG_SBES);
391 /*
392 * Note: The calls to notify the PROM of ACPI and PCI Segment
393 * support must be done prior to acpi_load_tables(), as
394 * an ACPI capable PROM will rebuild the DSDT as result
395 * of the call.
396 */
397 ia64_sn_set_os_feature(OSF_PCISEGMENT_ENABLE);
398 ia64_sn_set_os_feature(OSF_ACPI_ENABLE);
391 399
392 400
393#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) 401#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
@@ -413,6 +421,16 @@ void __init sn_setup(char **cmdline_p)
413 if (! vga_console_membase) 421 if (! vga_console_membase)
414 sn_scan_pcdp(); 422 sn_scan_pcdp();
415 423
424 /*
425 * Setup legacy IO space.
426 * vga_console_iobase maps to PCI IO Space address 0 on the
427 * bus containing the VGA console.
428 */
429 if (vga_console_iobase) {
430 io_space[0].mmio_base = vga_console_iobase;
431 io_space[0].sparse = 0;
432 }
433
416 if (vga_console_membase) { 434 if (vga_console_membase) {
417 /* usable vga ... make tty0 the preferred default console */ 435 /* usable vga ... make tty0 the preferred default console */
418 if (!strstr(*cmdline_p, "console=")) 436 if (!strstr(*cmdline_p, "console="))
diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c
index feaf1a6e8101..493380b2c05f 100644
--- a/arch/ia64/sn/kernel/tiocx.c
+++ b/arch/ia64/sn/kernel/tiocx.c
@@ -552,7 +552,7 @@ static void __exit tiocx_exit(void)
552 bus_unregister(&tiocx_bus_type); 552 bus_unregister(&tiocx_bus_type);
553} 553}
554 554
555subsys_initcall(tiocx_init); 555fs_initcall(tiocx_init);
556module_exit(tiocx_exit); 556module_exit(tiocx_exit);
557 557
558/************************************************************************ 558/************************************************************************
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_provider.c b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
index 27dd7df0f446..6846dc9b432d 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_provider.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2001-2004 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 2001-2004, 2006 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8 8
9#include <linux/interrupt.h> 9#include <linux/interrupt.h>
@@ -109,7 +109,6 @@ void *
109pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *controller) 109pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *controller)
110{ 110{
111 int nasid, cnode, j; 111 int nasid, cnode, j;
112 cnodeid_t near_cnode;
113 struct hubdev_info *hubdev_info; 112 struct hubdev_info *hubdev_info;
114 struct pcibus_info *soft; 113 struct pcibus_info *soft;
115 struct sn_flush_device_kernel *sn_flush_device_kernel; 114 struct sn_flush_device_kernel *sn_flush_device_kernel;
@@ -186,20 +185,6 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
186 return NULL; 185 return NULL;
187 } 186 }
188 187
189 if (prom_bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP) {
190 /* TIO PCI Bridge: find nearest node with CPUs */
191 int e = sn_hwperf_get_nearest_node(cnode, NULL, &near_cnode);
192
193 if (e < 0) {
194 near_cnode = (cnodeid_t)-1; /* use any node */
195 printk(KERN_WARNING "pcibr_bus_fixup: failed to find "
196 "near node with CPUs to TIO node %d, err=%d\n",
197 cnode, e);
198 }
199 controller->node = near_cnode;
200 }
201 else
202 controller->node = cnode;
203 return soft; 188 return soft;
204} 189}
205 190
diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c
index 46e16dcf5971..35f854fb6120 100644
--- a/arch/ia64/sn/pci/tioce_provider.c
+++ b/arch/ia64/sn/pci/tioce_provider.c
@@ -15,7 +15,6 @@
15#include <asm/sn/pcidev.h> 15#include <asm/sn/pcidev.h>
16#include <asm/sn/pcibus_provider_defs.h> 16#include <asm/sn/pcibus_provider_defs.h>
17#include <asm/sn/tioce_provider.h> 17#include <asm/sn/tioce_provider.h>
18#include <asm/sn/sn2/sn_hwperf.h>
19 18
20/* 19/*
21 * 1/26/2006 20 * 1/26/2006
@@ -990,8 +989,6 @@ tioce_target_interrupt(struct sn_irq_info *sn_irq_info)
990static void * 989static void *
991tioce_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *controller) 990tioce_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *controller)
992{ 991{
993 int my_nasid;
994 cnodeid_t my_cnode, mem_cnode;
995 struct tioce_common *tioce_common; 992 struct tioce_common *tioce_common;
996 struct tioce_kernel *tioce_kern; 993 struct tioce_kernel *tioce_kern;
997 struct tioce __iomem *tioce_mmr; 994 struct tioce __iomem *tioce_mmr;
@@ -1035,21 +1032,6 @@ tioce_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
1035 tioce_common->ce_pcibus.bs_persist_segment, 1032 tioce_common->ce_pcibus.bs_persist_segment,
1036 tioce_common->ce_pcibus.bs_persist_busnum); 1033 tioce_common->ce_pcibus.bs_persist_busnum);
1037 1034
1038 /*
1039 * identify closest nasid for memory allocations
1040 */
1041
1042 my_nasid = NASID_GET(tioce_common->ce_pcibus.bs_base);
1043 my_cnode = nasid_to_cnodeid(my_nasid);
1044
1045 if (sn_hwperf_get_nearest_node(my_cnode, &mem_cnode, NULL) < 0) {
1046 printk(KERN_WARNING "tioce_bus_fixup: failed to find "
1047 "closest node with MEM to TIO node %d\n", my_cnode);
1048 mem_cnode = (cnodeid_t)-1; /* use any node */
1049 }
1050
1051 controller->node = mem_cnode;
1052
1053 return tioce_common; 1035 return tioce_common;
1054} 1036}
1055 1037
diff --git a/arch/m32r/lib/csum_partial_copy.c b/arch/m32r/lib/csum_partial_copy.c
index 3d5f06145854..5596f3df833f 100644
--- a/arch/m32r/lib/csum_partial_copy.c
+++ b/arch/m32r/lib/csum_partial_copy.c
@@ -27,9 +27,8 @@
27/* 27/*
28 * Copy while checksumming, otherwise like csum_partial 28 * Copy while checksumming, otherwise like csum_partial
29 */ 29 */
30unsigned int 30__wsum
31csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, 31csum_partial_copy_nocheck (const void *src, void *dst, int len, __wsum sum)
32 int len, unsigned int sum)
33{ 32{
34 sum = csum_partial(src, len, sum); 33 sum = csum_partial(src, len, sum);
35 memcpy(dst, src, len); 34 memcpy(dst, src, len);
@@ -42,10 +41,9 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck);
42 * Copy from userspace and compute checksum. If we catch an exception 41 * Copy from userspace and compute checksum. If we catch an exception
43 * then zero the rest of the buffer. 42 * then zero the rest of the buffer.
44 */ 43 */
45unsigned int 44__wsum
46csum_partial_copy_from_user (const unsigned char __user *src, 45csum_partial_copy_from_user (const void __user *src, void *dst,
47 unsigned char *dst, 46 int len, __wsum sum, int *err_ptr)
48 int len, unsigned int sum, int *err_ptr)
49{ 47{
50 int missing; 48 int missing;
51 49
diff --git a/arch/m68k/lib/checksum.c b/arch/m68k/lib/checksum.c
index cb13c6e3ccae..aed3be29e06b 100644
--- a/arch/m68k/lib/checksum.c
+++ b/arch/m68k/lib/checksum.c
@@ -39,8 +39,7 @@
39 * computes a partial checksum, e.g. for TCP/UDP fragments 39 * computes a partial checksum, e.g. for TCP/UDP fragments
40 */ 40 */
41 41
42unsigned int 42__wsum csum_partial(const void *buff, int len, __wsum sum)
43csum_partial (const unsigned char *buff, int len, unsigned int sum)
44{ 43{
45 unsigned long tmp1, tmp2; 44 unsigned long tmp1, tmp2;
46 /* 45 /*
@@ -133,9 +132,9 @@ EXPORT_SYMBOL(csum_partial);
133 * copy from user space while checksumming, with exception handling. 132 * copy from user space while checksumming, with exception handling.
134 */ 133 */
135 134
136unsigned int 135__wsum
137csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst, 136csum_partial_copy_from_user(const void __user *src, void *dst,
138 int len, int sum, int *csum_err) 137 int len, __wsum sum, int *csum_err)
139{ 138{
140 /* 139 /*
141 * GCC doesn't like more than 10 operands for the asm 140 * GCC doesn't like more than 10 operands for the asm
@@ -325,8 +324,8 @@ csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst,
325 * copy from kernel space while checksumming, otherwise like csum_partial 324 * copy from kernel space while checksumming, otherwise like csum_partial
326 */ 325 */
327 326
328unsigned int 327__wsum
329csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, int len, int sum) 328csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
330{ 329{
331 unsigned long tmp1, tmp2; 330 unsigned long tmp1, tmp2;
332 __asm__("movel %2,%4\n\t" 331 __asm__("movel %2,%4\n\t"
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index 6d920d4bdc3d..c1bc22c6d0d8 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -565,7 +565,7 @@ config ROMVEC
565 depends on ROM 565 depends on ROM
566 help 566 help
567 This is almost always the same as the base of the ROM. Since on all 567 This is almost always the same as the base of the ROM. Since on all
568 68000 type varients the vectors are at the base of the boot device 568 68000 type variants the vectors are at the base of the boot device
569 on system startup. 569 on system startup.
570 570
571config ROMVECSIZE 571config ROMVECSIZE
@@ -574,7 +574,7 @@ config ROMVECSIZE
574 depends on ROM 574 depends on ROM
575 help 575 help
576 Define the size of the vector region in ROM. For most 68000 576 Define the size of the vector region in ROM. For most 68000
577 varients this would be 0x400 bytes in size. Set to 0 if you do 577 variants this would be 0x400 bytes in size. Set to 0 if you do
578 not want a vector region at the start of the ROM. 578 not want a vector region at the start of the ROM.
579 579
580config ROMSTART 580config ROMSTART
diff --git a/arch/m68knommu/kernel/m68k_ksyms.c b/arch/m68knommu/kernel/m68k_ksyms.c
index 1e62150f3588..25327c9eadd7 100644
--- a/arch/m68knommu/kernel/m68k_ksyms.c
+++ b/arch/m68knommu/kernel/m68k_ksyms.c
@@ -38,7 +38,7 @@ EXPORT_SYMBOL(ip_fast_csum);
38EXPORT_SYMBOL(kernel_thread); 38EXPORT_SYMBOL(kernel_thread);
39 39
40/* Networking helper routines. */ 40/* Networking helper routines. */
41EXPORT_SYMBOL(csum_partial_copy); 41EXPORT_SYMBOL(csum_partial_copy_nocheck);
42 42
43/* The following are special because they're not called 43/* The following are special because they're not called
44 explicitly (the C compiler generates them). Fortunately, 44 explicitly (the C compiler generates them). Fortunately,
diff --git a/arch/m68knommu/lib/checksum.c b/arch/m68knommu/lib/checksum.c
index 7bec6fdee34b..269d83bfbbe1 100644
--- a/arch/m68knommu/lib/checksum.c
+++ b/arch/m68knommu/lib/checksum.c
@@ -96,9 +96,9 @@ out:
96 * This is a version of ip_compute_csum() optimized for IP headers, 96 * This is a version of ip_compute_csum() optimized for IP headers,
97 * which always checksum on 4 octet boundaries. 97 * which always checksum on 4 octet boundaries.
98 */ 98 */
99unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) 99__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
100{ 100{
101 return ~do_csum(iph,ihl*4); 101 return (__force __sum16)~do_csum(iph,ihl*4);
102} 102}
103 103
104/* 104/*
@@ -113,15 +113,15 @@ unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl)
113 * 113 *
114 * it's best to have buff aligned on a 32-bit boundary 114 * it's best to have buff aligned on a 32-bit boundary
115 */ 115 */
116unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) 116__wsum csum_partial(const void *buff, int len, __wsum sum)
117{ 117{
118 unsigned int result = do_csum(buff, len); 118 unsigned int result = do_csum(buff, len);
119 119
120 /* add in old sum, and carry.. */ 120 /* add in old sum, and carry.. */
121 result += sum; 121 result += (__force u32)sum;
122 if (sum > result) 122 if ((__force u32)sum > result)
123 result += 1; 123 result += 1;
124 return result; 124 return (__force __wsum)result;
125} 125}
126 126
127EXPORT_SYMBOL(csum_partial); 127EXPORT_SYMBOL(csum_partial);
@@ -130,21 +130,21 @@ EXPORT_SYMBOL(csum_partial);
130 * this routine is used for miscellaneous IP-like checksums, mainly 130 * this routine is used for miscellaneous IP-like checksums, mainly
131 * in icmp.c 131 * in icmp.c
132 */ 132 */
133unsigned short ip_compute_csum(const unsigned char * buff, int len) 133__sum16 ip_compute_csum(const void *buff, int len)
134{ 134{
135 return ~do_csum(buff,len); 135 return (__force __sum16)~do_csum(buff,len);
136} 136}
137 137
138/* 138/*
139 * copy from fs while checksumming, otherwise like csum_partial 139 * copy from fs while checksumming, otherwise like csum_partial
140 */ 140 */
141 141
142unsigned int 142__wsum
143csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, 143csum_partial_copy_from_user(const void __user *src, void *dst,
144 int len, int sum, int *csum_err) 144 int len, __wsum sum, int *csum_err)
145{ 145{
146 if (csum_err) *csum_err = 0; 146 if (csum_err) *csum_err = 0;
147 memcpy(dst, src, len); 147 memcpy(dst, (__force const void *)src, len);
148 return csum_partial(dst, len, sum); 148 return csum_partial(dst, len, sum);
149} 149}
150 150
@@ -152,8 +152,8 @@ csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst,
152 * copy from ds while checksumming, otherwise like csum_partial 152 * copy from ds while checksumming, otherwise like csum_partial
153 */ 153 */
154 154
155unsigned int 155__wsum
156csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, int sum) 156csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
157{ 157{
158 memcpy(dst, src, len); 158 memcpy(dst, src, len);
159 return csum_partial(dst, len, sum); 159 return csum_partial(dst, len, sum);
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 1443024b1c7c..27f83e642968 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -266,8 +266,8 @@ config MIPS_MALTA
266 select BOOT_ELF32 266 select BOOT_ELF32
267 select HAVE_STD_PC_SERIAL_PORT 267 select HAVE_STD_PC_SERIAL_PORT
268 select DMA_NONCOHERENT 268 select DMA_NONCOHERENT
269 select IRQ_CPU
270 select GENERIC_ISA_DMA 269 select GENERIC_ISA_DMA
270 select IRQ_CPU
271 select HW_HAS_PCI 271 select HW_HAS_PCI
272 select I8259 272 select I8259
273 select MIPS_BOARDS_GEN 273 select MIPS_BOARDS_GEN
@@ -534,7 +534,7 @@ config SGI_IP22
534 select HW_HAS_EISA 534 select HW_HAS_EISA
535 select IP22_CPU_SCACHE 535 select IP22_CPU_SCACHE
536 select IRQ_CPU 536 select IRQ_CPU
537 select NO_ISA if ISA 537 select GENERIC_ISA_DMA_SUPPORT_BROKEN
538 select SWAP_IO_SPACE 538 select SWAP_IO_SPACE
539 select SYS_HAS_CPU_R4X00 539 select SYS_HAS_CPU_R4X00
540 select SYS_HAS_CPU_R5000 540 select SYS_HAS_CPU_R5000
@@ -766,6 +766,23 @@ config TOSHIBA_RBTX4938
766 766
767endchoice 767endchoice
768 768
769config KEXEC
770 bool "Kexec system call (EXPERIMENTAL)"
771 depends on EXPERIMENTAL
772 help
773 kexec is a system call that implements the ability to shutdown your
774 current kernel, and to start another kernel. It is like a reboot
775 but it is indepedent of the system firmware. And like a reboot
776 you can start any kernel with it, not just Linux.
777
778 The name comes from the similiarity to the exec system call.
779
780 It is an ongoing process to be certain the hardware in a machine
781 is properly shutdown, so do not be surprised if this code does not
782 initially work for you. It may help to enable device hotplugging
783 support. As of this writing the exact hardware interface is
784 strongly in flux, so no good recommendation can be made.
785
769source "arch/mips/ddb5xxx/Kconfig" 786source "arch/mips/ddb5xxx/Kconfig"
770source "arch/mips/gt64120/ev64120/Kconfig" 787source "arch/mips/gt64120/ev64120/Kconfig"
771source "arch/mips/jazz/Kconfig" 788source "arch/mips/jazz/Kconfig"
@@ -864,8 +881,11 @@ config MIPS_NILE4
864config MIPS_DISABLE_OBSOLETE_IDE 881config MIPS_DISABLE_OBSOLETE_IDE
865 bool 882 bool
866 883
884config GENERIC_ISA_DMA_SUPPORT_BROKEN
885 bool
886
867# 887#
868# Endianess selection. Suffiently obscure so many users don't know what to 888# Endianess selection. Sufficiently obscure so many users don't know what to
869# answer,so we try hard to limit the available choices. Also the use of a 889# answer,so we try hard to limit the available choices. Also the use of a
870# choice statement should be more obvious to the user. 890# choice statement should be more obvious to the user.
871# 891#
@@ -874,7 +894,7 @@ choice
874 help 894 help
875 Some MIPS machines can be configured for either little or big endian 895 Some MIPS machines can be configured for either little or big endian
876 byte order. These modes require different kernels and a different 896 byte order. These modes require different kernels and a different
877 Linux distribution. In general there is one prefered byteorder for a 897 Linux distribution. In general there is one preferred byteorder for a
878 particular system but some systems are just as commonly used in the 898 particular system but some systems are just as commonly used in the
879 one or the other endianess. 899 one or the other endianess.
880 900
@@ -1835,13 +1855,11 @@ source "drivers/pci/Kconfig"
1835config ISA 1855config ISA
1836 bool 1856 bool
1837 1857
1838config NO_ISA
1839 bool
1840
1841config EISA 1858config EISA
1842 bool "EISA support" 1859 bool "EISA support"
1843 depends on HW_HAS_EISA 1860 depends on HW_HAS_EISA
1844 select ISA 1861 select ISA
1862 select GENERIC_ISA_DMA
1845 ---help--- 1863 ---help---
1846 The Extended Industry Standard Architecture (EISA) bus was 1864 The Extended Industry Standard Architecture (EISA) bus was
1847 developed as an open alternative to the IBM MicroChannel bus. 1865 developed as an open alternative to the IBM MicroChannel bus.
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index d580d46f967b..641aa30b3638 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -63,9 +63,7 @@ cflags-y += -mabi=64
63ifdef CONFIG_BUILD_ELF64 63ifdef CONFIG_BUILD_ELF64
64cflags-y += $(call cc-option,-mno-explicit-relocs) 64cflags-y += $(call cc-option,-mno-explicit-relocs)
65else 65else
66# -msym32 can not be used for modules since they are loaded into XKSEG 66cflags-y += $(call cc-option,-msym32)
67CFLAGS_MODULE += $(call cc-option,-mno-explicit-relocs)
68CFLAGS_KERNEL += $(call cc-option,-msym32)
69endif 67endif
70endif 68endif
71 69
diff --git a/arch/mips/au1000/common/irq.c b/arch/mips/au1000/common/irq.c
index 2abe132bb07d..9cf7b6715836 100644
--- a/arch/mips/au1000/common/irq.c
+++ b/arch/mips/au1000/common/irq.c
@@ -70,7 +70,6 @@ extern irq_cpustat_t irq_stat [NR_CPUS];
70extern void mips_timer_interrupt(void); 70extern void mips_timer_interrupt(void);
71 71
72static void setup_local_irq(unsigned int irq, int type, int int_req); 72static void setup_local_irq(unsigned int irq, int type, int int_req);
73static unsigned int startup_irq(unsigned int irq);
74static void end_irq(unsigned int irq_nr); 73static void end_irq(unsigned int irq_nr);
75static inline void mask_and_ack_level_irq(unsigned int irq_nr); 74static inline void mask_and_ack_level_irq(unsigned int irq_nr);
76static inline void mask_and_ack_rise_edge_irq(unsigned int irq_nr); 75static inline void mask_and_ack_rise_edge_irq(unsigned int irq_nr);
@@ -84,20 +83,6 @@ void (*board_init_irq)(void);
84static DEFINE_SPINLOCK(irq_lock); 83static DEFINE_SPINLOCK(irq_lock);
85 84
86 85
87static unsigned int startup_irq(unsigned int irq_nr)
88{
89 local_enable_irq(irq_nr);
90 return 0;
91}
92
93
94static void shutdown_irq(unsigned int irq_nr)
95{
96 local_disable_irq(irq_nr);
97 return;
98}
99
100
101inline void local_enable_irq(unsigned int irq_nr) 86inline void local_enable_irq(unsigned int irq_nr)
102{ 87{
103 if (irq_nr > AU1000_LAST_INTC0_INT) { 88 if (irq_nr > AU1000_LAST_INTC0_INT) {
@@ -249,41 +234,37 @@ void restore_local_and_enable(int controller, unsigned long mask)
249 234
250static struct irq_chip rise_edge_irq_type = { 235static struct irq_chip rise_edge_irq_type = {
251 .typename = "Au1000 Rise Edge", 236 .typename = "Au1000 Rise Edge",
252 .startup = startup_irq,
253 .shutdown = shutdown_irq,
254 .enable = local_enable_irq,
255 .disable = local_disable_irq,
256 .ack = mask_and_ack_rise_edge_irq, 237 .ack = mask_and_ack_rise_edge_irq,
238 .mask = local_disable_irq,
239 .mask_ack = mask_and_ack_rise_edge_irq,
240 .unmask = local_enable_irq,
257 .end = end_irq, 241 .end = end_irq,
258}; 242};
259 243
260static struct irq_chip fall_edge_irq_type = { 244static struct irq_chip fall_edge_irq_type = {
261 .typename = "Au1000 Fall Edge", 245 .typename = "Au1000 Fall Edge",
262 .startup = startup_irq,
263 .shutdown = shutdown_irq,
264 .enable = local_enable_irq,
265 .disable = local_disable_irq,
266 .ack = mask_and_ack_fall_edge_irq, 246 .ack = mask_and_ack_fall_edge_irq,
247 .mask = local_disable_irq,
248 .mask_ack = mask_and_ack_fall_edge_irq,
249 .unmask = local_enable_irq,
267 .end = end_irq, 250 .end = end_irq,
268}; 251};
269 252
270static struct irq_chip either_edge_irq_type = { 253static struct irq_chip either_edge_irq_type = {
271 .typename = "Au1000 Rise or Fall Edge", 254 .typename = "Au1000 Rise or Fall Edge",
272 .startup = startup_irq,
273 .shutdown = shutdown_irq,
274 .enable = local_enable_irq,
275 .disable = local_disable_irq,
276 .ack = mask_and_ack_either_edge_irq, 255 .ack = mask_and_ack_either_edge_irq,
256 .mask = local_disable_irq,
257 .mask_ack = mask_and_ack_either_edge_irq,
258 .unmask = local_enable_irq,
277 .end = end_irq, 259 .end = end_irq,
278}; 260};
279 261
280static struct irq_chip level_irq_type = { 262static struct irq_chip level_irq_type = {
281 .typename = "Au1000 Level", 263 .typename = "Au1000 Level",
282 .startup = startup_irq,
283 .shutdown = shutdown_irq,
284 .enable = local_enable_irq,
285 .disable = local_disable_irq,
286 .ack = mask_and_ack_level_irq, 264 .ack = mask_and_ack_level_irq,
265 .mask = local_disable_irq,
266 .mask_ack = mask_and_ack_level_irq,
267 .unmask = local_enable_irq,
287 .end = end_irq, 268 .end = end_irq,
288}; 269};
289 270
@@ -328,31 +309,31 @@ static void setup_local_irq(unsigned int irq_nr, int type, int int_req)
328 au_writel(1<<(irq_nr-32), IC1_CFG2CLR); 309 au_writel(1<<(irq_nr-32), IC1_CFG2CLR);
329 au_writel(1<<(irq_nr-32), IC1_CFG1CLR); 310 au_writel(1<<(irq_nr-32), IC1_CFG1CLR);
330 au_writel(1<<(irq_nr-32), IC1_CFG0SET); 311 au_writel(1<<(irq_nr-32), IC1_CFG0SET);
331 irq_desc[irq_nr].chip = &rise_edge_irq_type; 312 set_irq_chip(irq_nr, &rise_edge_irq_type);
332 break; 313 break;
333 case INTC_INT_FALL_EDGE: /* 0:1:0 */ 314 case INTC_INT_FALL_EDGE: /* 0:1:0 */
334 au_writel(1<<(irq_nr-32), IC1_CFG2CLR); 315 au_writel(1<<(irq_nr-32), IC1_CFG2CLR);
335 au_writel(1<<(irq_nr-32), IC1_CFG1SET); 316 au_writel(1<<(irq_nr-32), IC1_CFG1SET);
336 au_writel(1<<(irq_nr-32), IC1_CFG0CLR); 317 au_writel(1<<(irq_nr-32), IC1_CFG0CLR);
337 irq_desc[irq_nr].chip = &fall_edge_irq_type; 318 set_irq_chip(irq_nr, &fall_edge_irq_type);
338 break; 319 break;
339 case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */ 320 case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */
340 au_writel(1<<(irq_nr-32), IC1_CFG2CLR); 321 au_writel(1<<(irq_nr-32), IC1_CFG2CLR);
341 au_writel(1<<(irq_nr-32), IC1_CFG1SET); 322 au_writel(1<<(irq_nr-32), IC1_CFG1SET);
342 au_writel(1<<(irq_nr-32), IC1_CFG0SET); 323 au_writel(1<<(irq_nr-32), IC1_CFG0SET);
343 irq_desc[irq_nr].chip = &either_edge_irq_type; 324 set_irq_chip(irq_nr, &either_edge_irq_type);
344 break; 325 break;
345 case INTC_INT_HIGH_LEVEL: /* 1:0:1 */ 326 case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
346 au_writel(1<<(irq_nr-32), IC1_CFG2SET); 327 au_writel(1<<(irq_nr-32), IC1_CFG2SET);
347 au_writel(1<<(irq_nr-32), IC1_CFG1CLR); 328 au_writel(1<<(irq_nr-32), IC1_CFG1CLR);
348 au_writel(1<<(irq_nr-32), IC1_CFG0SET); 329 au_writel(1<<(irq_nr-32), IC1_CFG0SET);
349 irq_desc[irq_nr].chip = &level_irq_type; 330 set_irq_chip(irq_nr, &level_irq_type);
350 break; 331 break;
351 case INTC_INT_LOW_LEVEL: /* 1:1:0 */ 332 case INTC_INT_LOW_LEVEL: /* 1:1:0 */
352 au_writel(1<<(irq_nr-32), IC1_CFG2SET); 333 au_writel(1<<(irq_nr-32), IC1_CFG2SET);
353 au_writel(1<<(irq_nr-32), IC1_CFG1SET); 334 au_writel(1<<(irq_nr-32), IC1_CFG1SET);
354 au_writel(1<<(irq_nr-32), IC1_CFG0CLR); 335 au_writel(1<<(irq_nr-32), IC1_CFG0CLR);
355 irq_desc[irq_nr].chip = &level_irq_type; 336 set_irq_chip(irq_nr, &level_irq_type);
356 break; 337 break;
357 case INTC_INT_DISABLED: /* 0:0:0 */ 338 case INTC_INT_DISABLED: /* 0:0:0 */
358 au_writel(1<<(irq_nr-32), IC1_CFG0CLR); 339 au_writel(1<<(irq_nr-32), IC1_CFG0CLR);
@@ -380,31 +361,31 @@ static void setup_local_irq(unsigned int irq_nr, int type, int int_req)
380 au_writel(1<<irq_nr, IC0_CFG2CLR); 361 au_writel(1<<irq_nr, IC0_CFG2CLR);
381 au_writel(1<<irq_nr, IC0_CFG1CLR); 362 au_writel(1<<irq_nr, IC0_CFG1CLR);
382 au_writel(1<<irq_nr, IC0_CFG0SET); 363 au_writel(1<<irq_nr, IC0_CFG0SET);
383 irq_desc[irq_nr].chip = &rise_edge_irq_type; 364 set_irq_chip(irq_nr, &rise_edge_irq_type);
384 break; 365 break;
385 case INTC_INT_FALL_EDGE: /* 0:1:0 */ 366 case INTC_INT_FALL_EDGE: /* 0:1:0 */
386 au_writel(1<<irq_nr, IC0_CFG2CLR); 367 au_writel(1<<irq_nr, IC0_CFG2CLR);
387 au_writel(1<<irq_nr, IC0_CFG1SET); 368 au_writel(1<<irq_nr, IC0_CFG1SET);
388 au_writel(1<<irq_nr, IC0_CFG0CLR); 369 au_writel(1<<irq_nr, IC0_CFG0CLR);
389 irq_desc[irq_nr].chip = &fall_edge_irq_type; 370 set_irq_chip(irq_nr, &fall_edge_irq_type);
390 break; 371 break;
391 case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */ 372 case INTC_INT_RISE_AND_FALL_EDGE: /* 0:1:1 */
392 au_writel(1<<irq_nr, IC0_CFG2CLR); 373 au_writel(1<<irq_nr, IC0_CFG2CLR);
393 au_writel(1<<irq_nr, IC0_CFG1SET); 374 au_writel(1<<irq_nr, IC0_CFG1SET);
394 au_writel(1<<irq_nr, IC0_CFG0SET); 375 au_writel(1<<irq_nr, IC0_CFG0SET);
395 irq_desc[irq_nr].chip = &either_edge_irq_type; 376 set_irq_chip(irq_nr, &either_edge_irq_type);
396 break; 377 break;
397 case INTC_INT_HIGH_LEVEL: /* 1:0:1 */ 378 case INTC_INT_HIGH_LEVEL: /* 1:0:1 */
398 au_writel(1<<irq_nr, IC0_CFG2SET); 379 au_writel(1<<irq_nr, IC0_CFG2SET);
399 au_writel(1<<irq_nr, IC0_CFG1CLR); 380 au_writel(1<<irq_nr, IC0_CFG1CLR);
400 au_writel(1<<irq_nr, IC0_CFG0SET); 381 au_writel(1<<irq_nr, IC0_CFG0SET);
401 irq_desc[irq_nr].chip = &level_irq_type; 382 set_irq_chip(irq_nr, &level_irq_type);
402 break; 383 break;
403 case INTC_INT_LOW_LEVEL: /* 1:1:0 */ 384 case INTC_INT_LOW_LEVEL: /* 1:1:0 */
404 au_writel(1<<irq_nr, IC0_CFG2SET); 385 au_writel(1<<irq_nr, IC0_CFG2SET);
405 au_writel(1<<irq_nr, IC0_CFG1SET); 386 au_writel(1<<irq_nr, IC0_CFG1SET);
406 au_writel(1<<irq_nr, IC0_CFG0CLR); 387 au_writel(1<<irq_nr, IC0_CFG0CLR);
407 irq_desc[irq_nr].chip = &level_irq_type; 388 set_irq_chip(irq_nr, &level_irq_type);
408 break; 389 break;
409 case INTC_INT_DISABLED: /* 0:0:0 */ 390 case INTC_INT_DISABLED: /* 0:0:0 */
410 au_writel(1<<irq_nr, IC0_CFG0CLR); 391 au_writel(1<<irq_nr, IC0_CFG0CLR);
diff --git a/arch/mips/au1000/pb1200/board_setup.c b/arch/mips/au1000/pb1200/board_setup.c
index 8b953b9fc25c..043302b7fe58 100644
--- a/arch/mips/au1000/pb1200/board_setup.c
+++ b/arch/mips/au1000/pb1200/board_setup.c
@@ -55,7 +55,7 @@
55#endif 55#endif
56 56
57extern void _board_init_irq(void); 57extern void _board_init_irq(void);
58extern void (*board_init_irq)(void); 58extern void (*board_init_irq)(void);
59 59
60void board_reset (void) 60void board_reset (void)
61{ 61{
@@ -151,11 +151,7 @@ void __init board_setup(void)
151#endif 151#endif
152 152
153 /* Setup Pb1200 External Interrupt Controller */ 153 /* Setup Pb1200 External Interrupt Controller */
154 { 154 board_init_irq = _board_init_irq;
155 extern void (*board_init_irq)(void);
156 extern void _board_init_irq(void);
157 board_init_irq = _board_init_irq;
158 }
159} 155}
160 156
161int 157int
diff --git a/arch/mips/cobalt/irq.c b/arch/mips/cobalt/irq.c
index 82e569d5b02c..4c46f0e73783 100644
--- a/arch/mips/cobalt/irq.c
+++ b/arch/mips/cobalt/irq.c
@@ -45,25 +45,22 @@ static inline void galileo_irq(void)
45{ 45{
46 unsigned int mask, pending, devfn; 46 unsigned int mask, pending, devfn;
47 47
48 mask = GALILEO_INL(GT_INTRMASK_OFS); 48 mask = GT_READ(GT_INTRMASK_OFS);
49 pending = GALILEO_INL(GT_INTRCAUSE_OFS) & mask; 49 pending = GT_READ(GT_INTRCAUSE_OFS) & mask;
50 50
51 if (pending & GALILEO_INTR_T0EXP) { 51 if (pending & GT_INTR_T0EXP_MSK) {
52 52 GT_WRITE(GT_INTRCAUSE_OFS, ~GT_INTR_T0EXP_MSK);
53 GALILEO_OUTL(~GALILEO_INTR_T0EXP, GT_INTRCAUSE_OFS);
54 do_IRQ(COBALT_GALILEO_IRQ); 53 do_IRQ(COBALT_GALILEO_IRQ);
55 54 } else if (pending & GT_INTR_RETRYCTR0_MSK) {
56 } else if (pending & GALILEO_INTR_RETRY_CTR) { 55 devfn = GT_READ(GT_PCI0_CFGADDR_OFS) >> 8;
57 56 GT_WRITE(GT_INTRCAUSE_OFS, ~GT_INTR_RETRYCTR0_MSK);
58 devfn = GALILEO_INL(GT_PCI0_CFGADDR_OFS) >> 8; 57 printk(KERN_WARNING
59 GALILEO_OUTL(~GALILEO_INTR_RETRY_CTR, GT_INTRCAUSE_OFS); 58 "Galileo: PCI retry count exceeded (%02x.%u)\n",
60 printk(KERN_WARNING "Galileo: PCI retry count exceeded (%02x.%u)\n", 59 PCI_SLOT(devfn), PCI_FUNC(devfn));
61 PCI_SLOT(devfn), PCI_FUNC(devfn));
62
63 } else { 60 } else {
64 61 GT_WRITE(GT_INTRMASK_OFS, mask & ~pending);
65 GALILEO_OUTL(mask & ~pending, GT_INTRMASK_OFS); 62 printk(KERN_WARNING
66 printk(KERN_WARNING "Galileo: masking unexpected interrupt %08x\n", pending); 63 "Galileo: masking unexpected interrupt %08x\n", pending);
67 } 64 }
68} 65}
69 66
@@ -104,7 +101,7 @@ void __init arch_init_irq(void)
104 * Mask all Galileo interrupts. The Galileo 101 * Mask all Galileo interrupts. The Galileo
105 * handler is set in cobalt_timer_setup() 102 * handler is set in cobalt_timer_setup()
106 */ 103 */
107 GALILEO_OUTL(0, GT_INTRMASK_OFS); 104 GT_WRITE(GT_INTRMASK_OFS, 0);
108 105
109 init_i8259_irqs(); /* 0 ... 15 */ 106 init_i8259_irqs(); /* 0 ... 15 */
110 mips_cpu_irq_init(COBALT_CPU_IRQ); /* 16 ... 23 */ 107 mips_cpu_irq_init(COBALT_CPU_IRQ); /* 16 ... 23 */
diff --git a/arch/mips/cobalt/setup.c b/arch/mips/cobalt/setup.c
index bf9dc72b9720..e8f0f20b852d 100644
--- a/arch/mips/cobalt/setup.c
+++ b/arch/mips/cobalt/setup.c
@@ -51,23 +51,23 @@ const char *get_system_type(void)
51void __init plat_timer_setup(struct irqaction *irq) 51void __init plat_timer_setup(struct irqaction *irq)
52{ 52{
53 /* Load timer value for HZ (TCLK is 50MHz) */ 53 /* Load timer value for HZ (TCLK is 50MHz) */
54 GALILEO_OUTL(50*1000*1000 / HZ, GT_TC0_OFS); 54 GT_WRITE(GT_TC0_OFS, 50*1000*1000 / HZ);
55 55
56 /* Enable timer */ 56 /* Enable timer */
57 GALILEO_OUTL(GALILEO_ENTC0 | GALILEO_SELTC0, GT_TC_CONTROL_OFS); 57 GT_WRITE(GT_TC_CONTROL_OFS, GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK);
58 58
59 /* Register interrupt */ 59 /* Register interrupt */
60 setup_irq(COBALT_GALILEO_IRQ, irq); 60 setup_irq(COBALT_GALILEO_IRQ, irq);
61 61
62 /* Enable interrupt */ 62 /* Enable interrupt */
63 GALILEO_OUTL(GALILEO_INTR_T0EXP | GALILEO_INL(GT_INTRMASK_OFS), GT_INTRMASK_OFS); 63 GT_WRITE(GT_INTRMASK_OFS, GT_INTR_T0EXP_MSK | GT_READ(GT_INTRMASK_OFS));
64} 64}
65 65
66extern struct pci_ops gt64111_pci_ops; 66extern struct pci_ops gt64111_pci_ops;
67 67
68static struct resource cobalt_mem_resource = { 68static struct resource cobalt_mem_resource = {
69 .start = GT64111_MEM_BASE, 69 .start = GT_DEF_PCI0_MEM0_BASE,
70 .end = GT64111_MEM_END, 70 .end = GT_DEF_PCI0_MEM0_BASE + GT_DEF_PCI0_MEM0_SIZE - 1,
71 .name = "PCI memory", 71 .name = "PCI memory",
72 .flags = IORESOURCE_MEM 72 .flags = IORESOURCE_MEM
73}; 73};
@@ -115,7 +115,7 @@ static struct pci_controller cobalt_pci_controller = {
115 .mem_resource = &cobalt_mem_resource, 115 .mem_resource = &cobalt_mem_resource,
116 .mem_offset = 0, 116 .mem_offset = 0,
117 .io_resource = &cobalt_io_resource, 117 .io_resource = &cobalt_io_resource,
118 .io_offset = 0 - GT64111_IO_BASE 118 .io_offset = 0 - GT_DEF_PCI0_IO_BASE,
119}; 119};
120 120
121void __init plat_mem_setup(void) 121void __init plat_mem_setup(void)
@@ -128,7 +128,7 @@ void __init plat_mem_setup(void)
128 _machine_halt = cobalt_machine_halt; 128 _machine_halt = cobalt_machine_halt;
129 pm_power_off = cobalt_machine_power_off; 129 pm_power_off = cobalt_machine_power_off;
130 130
131 set_io_port_base(CKSEG1ADDR(GT64111_IO_BASE)); 131 set_io_port_base(CKSEG1ADDR(GT_DEF_PCI0_IO_BASE));
132 132
133 /* I/O port resource must include UART and LCD/buttons */ 133 /* I/O port resource must include UART and LCD/buttons */
134 ioport_resource.end = 0x0fffffff; 134 ioport_resource.end = 0x0fffffff;
@@ -139,7 +139,7 @@ void __init plat_mem_setup(void)
139 139
140 /* Read the cobalt id register out of the PCI config space */ 140 /* Read the cobalt id register out of the PCI config space */
141 PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3)); 141 PCI_CFG_SET(devfn, (VIA_COBALT_BRD_ID_REG & ~0x3));
142 cobalt_board_id = GALILEO_INL(GT_PCI0_CFGDATA_OFS); 142 cobalt_board_id = GT_READ(GT_PCI0_CFGDATA_OFS);
143 cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8); 143 cobalt_board_id >>= ((VIA_COBALT_BRD_ID_REG & 3) * 8);
144 cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id); 144 cobalt_board_id = VIA_COBALT_BRD_REG_to_ID(cobalt_board_id);
145 145
diff --git a/arch/mips/ddb5xxx/ddb5477/irq_5477.c b/arch/mips/ddb5xxx/ddb5477/irq_5477.c
index ba52705a2738..96249aa5df5d 100644
--- a/arch/mips/ddb5xxx/ddb5477/irq_5477.c
+++ b/arch/mips/ddb5xxx/ddb5477/irq_5477.c
@@ -53,14 +53,6 @@ vrc5477_irq_disable(unsigned int irq)
53 ll_vrc5477_irq_disable(irq - vrc5477_irq_base); 53 ll_vrc5477_irq_disable(irq - vrc5477_irq_base);
54} 54}
55 55
56static unsigned int vrc5477_irq_startup(unsigned int irq)
57{
58 vrc5477_irq_enable(irq);
59 return 0;
60}
61
62#define vrc5477_irq_shutdown vrc5477_irq_disable
63
64static void 56static void
65vrc5477_irq_ack(unsigned int irq) 57vrc5477_irq_ack(unsigned int irq)
66{ 58{
@@ -91,11 +83,10 @@ vrc5477_irq_end(unsigned int irq)
91 83
92struct irq_chip vrc5477_irq_controller = { 84struct irq_chip vrc5477_irq_controller = {
93 .typename = "vrc5477_irq", 85 .typename = "vrc5477_irq",
94 .startup = vrc5477_irq_startup,
95 .shutdown = vrc5477_irq_shutdown,
96 .enable = vrc5477_irq_enable,
97 .disable = vrc5477_irq_disable,
98 .ack = vrc5477_irq_ack, 86 .ack = vrc5477_irq_ack,
87 .mask = vrc5477_irq_disable,
88 .mask_ack = vrc5477_irq_ack,
89 .unmask = vrc5477_irq_enable,
99 .end = vrc5477_irq_end 90 .end = vrc5477_irq_end
100}; 91};
101 92
@@ -103,12 +94,8 @@ void __init vrc5477_irq_init(u32 irq_base)
103{ 94{
104 u32 i; 95 u32 i;
105 96
106 for (i= irq_base; i< irq_base+ NUM_5477_IRQ; i++) { 97 for (i= irq_base; i< irq_base+ NUM_5477_IRQ; i++)
107 irq_desc[i].status = IRQ_DISABLED; 98 set_irq_chip(i, &vrc5477_irq_controller);
108 irq_desc[i].action = NULL;
109 irq_desc[i].depth = 1;
110 irq_desc[i].chip = &vrc5477_irq_controller;
111 }
112 99
113 vrc5477_irq_base = irq_base; 100 vrc5477_irq_base = irq_base;
114} 101}
diff --git a/arch/mips/dec/ecc-berr.c b/arch/mips/dec/ecc-berr.c
index 3e374d05978f..c8430c07355e 100644
--- a/arch/mips/dec/ecc-berr.c
+++ b/arch/mips/dec/ecc-berr.c
@@ -18,7 +18,6 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/spinlock.h>
22#include <linux/types.h> 21#include <linux/types.h>
23 22
24#include <asm/addrspace.h> 23#include <asm/addrspace.h>
@@ -231,13 +230,10 @@ irqreturn_t dec_ecc_be_interrupt(int irq, void *dev_id)
231static inline void dec_kn02_be_init(void) 230static inline void dec_kn02_be_init(void)
232{ 231{
233 volatile u32 *csr = (void *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_CSR); 232 volatile u32 *csr = (void *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_CSR);
234 unsigned long flags;
235 233
236 kn0x_erraddr = (void *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_ERRADDR); 234 kn0x_erraddr = (void *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_ERRADDR);
237 kn0x_chksyn = (void *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_CHKSYN); 235 kn0x_chksyn = (void *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_CHKSYN);
238 236
239 spin_lock_irqsave(&kn02_lock, flags);
240
241 /* Preset write-only bits of the Control Register cache. */ 237 /* Preset write-only bits of the Control Register cache. */
242 cached_kn02_csr = *csr | KN02_CSR_LEDS; 238 cached_kn02_csr = *csr | KN02_CSR_LEDS;
243 239
@@ -247,8 +243,6 @@ static inline void dec_kn02_be_init(void)
247 cached_kn02_csr |= KN02_CSR_CORRECT; 243 cached_kn02_csr |= KN02_CSR_CORRECT;
248 *csr = cached_kn02_csr; 244 *csr = cached_kn02_csr;
249 iob(); 245 iob();
250
251 spin_unlock_irqrestore(&kn02_lock, flags);
252} 246}
253 247
254static inline void dec_kn03_be_init(void) 248static inline void dec_kn03_be_init(void)
diff --git a/arch/mips/dec/int-handler.S b/arch/mips/dec/int-handler.S
index 31dd47d1002d..b251ef864c33 100644
--- a/arch/mips/dec/int-handler.S
+++ b/arch/mips/dec/int-handler.S
@@ -267,7 +267,7 @@ handle_it:
267 LONG_L s0, TI_REGS($28) 267 LONG_L s0, TI_REGS($28)
268 LONG_S sp, TI_REGS($28) 268 LONG_S sp, TI_REGS($28)
269 PTR_LA ra, ret_from_irq 269 PTR_LA ra, ret_from_irq
270 j do_IRQ 270 j dec_irq_dispatch
271 nop 271 nop
272 272
273#ifdef CONFIG_32BIT 273#ifdef CONFIG_32BIT
diff --git a/arch/mips/dec/ioasic-irq.c b/arch/mips/dec/ioasic-irq.c
index 41cd2a96148b..269b22b34313 100644
--- a/arch/mips/dec/ioasic-irq.c
+++ b/arch/mips/dec/ioasic-irq.c
@@ -13,7 +13,6 @@
13 13
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/spinlock.h>
17#include <linux/types.h> 16#include <linux/types.h>
18 17
19#include <asm/dec/ioasic.h> 18#include <asm/dec/ioasic.h>
@@ -21,8 +20,6 @@
21#include <asm/dec/ioasic_ints.h> 20#include <asm/dec/ioasic_ints.h>
22 21
23 22
24static DEFINE_SPINLOCK(ioasic_lock);
25
26static int ioasic_irq_base; 23static int ioasic_irq_base;
27 24
28 25
@@ -52,65 +49,31 @@ static inline void clear_ioasic_irq(unsigned int irq)
52 ioasic_write(IO_REG_SIR, sir); 49 ioasic_write(IO_REG_SIR, sir);
53} 50}
54 51
55static inline void enable_ioasic_irq(unsigned int irq)
56{
57 unsigned long flags;
58
59 spin_lock_irqsave(&ioasic_lock, flags);
60 unmask_ioasic_irq(irq);
61 spin_unlock_irqrestore(&ioasic_lock, flags);
62}
63
64static inline void disable_ioasic_irq(unsigned int irq)
65{
66 unsigned long flags;
67
68 spin_lock_irqsave(&ioasic_lock, flags);
69 mask_ioasic_irq(irq);
70 spin_unlock_irqrestore(&ioasic_lock, flags);
71}
72
73
74static inline unsigned int startup_ioasic_irq(unsigned int irq)
75{
76 enable_ioasic_irq(irq);
77 return 0;
78}
79
80#define shutdown_ioasic_irq disable_ioasic_irq
81
82static inline void ack_ioasic_irq(unsigned int irq) 52static inline void ack_ioasic_irq(unsigned int irq)
83{ 53{
84 spin_lock(&ioasic_lock);
85 mask_ioasic_irq(irq); 54 mask_ioasic_irq(irq);
86 spin_unlock(&ioasic_lock);
87 fast_iob(); 55 fast_iob();
88} 56}
89 57
90static inline void end_ioasic_irq(unsigned int irq) 58static inline void end_ioasic_irq(unsigned int irq)
91{ 59{
92 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 60 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
93 enable_ioasic_irq(irq); 61 unmask_ioasic_irq(irq);
94} 62}
95 63
96static struct irq_chip ioasic_irq_type = { 64static struct irq_chip ioasic_irq_type = {
97 .typename = "IO-ASIC", 65 .typename = "IO-ASIC",
98 .startup = startup_ioasic_irq,
99 .shutdown = shutdown_ioasic_irq,
100 .enable = enable_ioasic_irq,
101 .disable = disable_ioasic_irq,
102 .ack = ack_ioasic_irq, 66 .ack = ack_ioasic_irq,
67 .mask = mask_ioasic_irq,
68 .mask_ack = ack_ioasic_irq,
69 .unmask = unmask_ioasic_irq,
103 .end = end_ioasic_irq, 70 .end = end_ioasic_irq,
104}; 71};
105 72
106 73
107#define startup_ioasic_dma_irq startup_ioasic_irq 74#define unmask_ioasic_dma_irq unmask_ioasic_irq
108
109#define shutdown_ioasic_dma_irq shutdown_ioasic_irq
110
111#define enable_ioasic_dma_irq enable_ioasic_irq
112 75
113#define disable_ioasic_dma_irq disable_ioasic_irq 76#define mask_ioasic_dma_irq mask_ioasic_irq
114 77
115#define ack_ioasic_dma_irq ack_ioasic_irq 78#define ack_ioasic_dma_irq ack_ioasic_irq
116 79
@@ -123,11 +86,10 @@ static inline void end_ioasic_dma_irq(unsigned int irq)
123 86
124static struct irq_chip ioasic_dma_irq_type = { 87static struct irq_chip ioasic_dma_irq_type = {
125 .typename = "IO-ASIC-DMA", 88 .typename = "IO-ASIC-DMA",
126 .startup = startup_ioasic_dma_irq,
127 .shutdown = shutdown_ioasic_dma_irq,
128 .enable = enable_ioasic_dma_irq,
129 .disable = disable_ioasic_dma_irq,
130 .ack = ack_ioasic_dma_irq, 89 .ack = ack_ioasic_dma_irq,
90 .mask = mask_ioasic_dma_irq,
91 .mask_ack = ack_ioasic_dma_irq,
92 .unmask = unmask_ioasic_dma_irq,
131 .end = end_ioasic_dma_irq, 93 .end = end_ioasic_dma_irq,
132}; 94};
133 95
@@ -140,18 +102,12 @@ void __init init_ioasic_irqs(int base)
140 ioasic_write(IO_REG_SIMR, 0); 102 ioasic_write(IO_REG_SIMR, 0);
141 fast_iob(); 103 fast_iob();
142 104
143 for (i = base; i < base + IO_INR_DMA; i++) { 105 for (i = base; i < base + IO_INR_DMA; i++)
144 irq_desc[i].status = IRQ_DISABLED; 106 set_irq_chip_and_handler(i, &ioasic_irq_type,
145 irq_desc[i].action = 0; 107 handle_level_irq);
146 irq_desc[i].depth = 1; 108 for (; i < base + IO_IRQ_LINES; i++)
147 irq_desc[i].chip = &ioasic_irq_type; 109 set_irq_chip_and_handler(i, &ioasic_dma_irq_type,
148 } 110 handle_level_irq);
149 for (; i < base + IO_IRQ_LINES; i++) {
150 irq_desc[i].status = IRQ_DISABLED;
151 irq_desc[i].action = 0;
152 irq_desc[i].depth = 1;
153 irq_desc[i].chip = &ioasic_dma_irq_type;
154 }
155 111
156 ioasic_irq_base = base; 112 ioasic_irq_base = base;
157} 113}
diff --git a/arch/mips/dec/kn02-irq.c b/arch/mips/dec/kn02-irq.c
index 04a367a60a57..5a9be4c93584 100644
--- a/arch/mips/dec/kn02-irq.c
+++ b/arch/mips/dec/kn02-irq.c
@@ -14,7 +14,6 @@
14 14
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/irq.h> 16#include <linux/irq.h>
17#include <linux/spinlock.h>
18#include <linux/types.h> 17#include <linux/types.h>
19 18
20#include <asm/dec/kn02.h> 19#include <asm/dec/kn02.h>
@@ -29,7 +28,6 @@
29 * There is no default value -- it has to be initialized. 28 * There is no default value -- it has to be initialized.
30 */ 29 */
31u32 cached_kn02_csr; 30u32 cached_kn02_csr;
32DEFINE_SPINLOCK(kn02_lock);
33 31
34 32
35static int kn02_irq_base; 33static int kn02_irq_base;
@@ -53,54 +51,24 @@ static inline void mask_kn02_irq(unsigned int irq)
53 *csr = cached_kn02_csr; 51 *csr = cached_kn02_csr;
54} 52}
55 53
56static inline void enable_kn02_irq(unsigned int irq)
57{
58 unsigned long flags;
59
60 spin_lock_irqsave(&kn02_lock, flags);
61 unmask_kn02_irq(irq);
62 spin_unlock_irqrestore(&kn02_lock, flags);
63}
64
65static inline void disable_kn02_irq(unsigned int irq)
66{
67 unsigned long flags;
68
69 spin_lock_irqsave(&kn02_lock, flags);
70 mask_kn02_irq(irq);
71 spin_unlock_irqrestore(&kn02_lock, flags);
72}
73
74
75static unsigned int startup_kn02_irq(unsigned int irq)
76{
77 enable_kn02_irq(irq);
78 return 0;
79}
80
81#define shutdown_kn02_irq disable_kn02_irq
82
83static void ack_kn02_irq(unsigned int irq) 54static void ack_kn02_irq(unsigned int irq)
84{ 55{
85 spin_lock(&kn02_lock);
86 mask_kn02_irq(irq); 56 mask_kn02_irq(irq);
87 spin_unlock(&kn02_lock);
88 iob(); 57 iob();
89} 58}
90 59
91static void end_kn02_irq(unsigned int irq) 60static void end_kn02_irq(unsigned int irq)
92{ 61{
93 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 62 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
94 enable_kn02_irq(irq); 63 unmask_kn02_irq(irq);
95} 64}
96 65
97static struct irq_chip kn02_irq_type = { 66static struct irq_chip kn02_irq_type = {
98 .typename = "KN02-CSR", 67 .typename = "KN02-CSR",
99 .startup = startup_kn02_irq,
100 .shutdown = shutdown_kn02_irq,
101 .enable = enable_kn02_irq,
102 .disable = disable_kn02_irq,
103 .ack = ack_kn02_irq, 68 .ack = ack_kn02_irq,
69 .mask = mask_kn02_irq,
70 .mask_ack = ack_kn02_irq,
71 .unmask = unmask_kn02_irq,
104 .end = end_kn02_irq, 72 .end = end_kn02_irq,
105}; 73};
106 74
@@ -109,22 +77,15 @@ void __init init_kn02_irqs(int base)
109{ 77{
110 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE + 78 volatile u32 *csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE +
111 KN02_CSR); 79 KN02_CSR);
112 unsigned long flags;
113 int i; 80 int i;
114 81
115 /* Mask interrupts. */ 82 /* Mask interrupts. */
116 spin_lock_irqsave(&kn02_lock, flags);
117 cached_kn02_csr &= ~KN02_CSR_IOINTEN; 83 cached_kn02_csr &= ~KN02_CSR_IOINTEN;
118 *csr = cached_kn02_csr; 84 *csr = cached_kn02_csr;
119 iob(); 85 iob();
120 spin_unlock_irqrestore(&kn02_lock, flags); 86
121 87 for (i = base; i < base + KN02_IRQ_LINES; i++)
122 for (i = base; i < base + KN02_IRQ_LINES; i++) { 88 set_irq_chip_and_handler(i, &kn02_irq_type, handle_level_irq);
123 irq_desc[i].status = IRQ_DISABLED;
124 irq_desc[i].action = 0;
125 irq_desc[i].depth = 1;
126 irq_desc[i].chip = &kn02_irq_type;
127 }
128 89
129 kn02_irq_base = base; 90 kn02_irq_base = base;
130} 91}
diff --git a/arch/mips/dec/setup.c b/arch/mips/dec/setup.c
index 6b7481e97bec..d34032ac492a 100644
--- a/arch/mips/dec/setup.c
+++ b/arch/mips/dec/setup.c
@@ -761,3 +761,9 @@ void __init arch_init_irq(void)
761 if (dec_interrupt[DEC_IRQ_HALT] >= 0) 761 if (dec_interrupt[DEC_IRQ_HALT] >= 0)
762 setup_irq(dec_interrupt[DEC_IRQ_HALT], &haltirq); 762 setup_irq(dec_interrupt[DEC_IRQ_HALT], &haltirq);
763} 763}
764
765asmlinkage unsigned int dec_irq_dispatch(unsigned int irq)
766{
767 do_IRQ(irq);
768 return 0;
769}
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c
index 69e424e9ab6f..8b7e0c17ac35 100644
--- a/arch/mips/dec/time.c
+++ b/arch/mips/dec/time.c
@@ -151,7 +151,7 @@ static void dec_timer_ack(void)
151 CMOS_READ(RTC_REG_C); /* Ack the RTC interrupt. */ 151 CMOS_READ(RTC_REG_C); /* Ack the RTC interrupt. */
152} 152}
153 153
154static unsigned int dec_ioasic_hpt_read(void) 154static cycle_t dec_ioasic_hpt_read(void)
155{ 155{
156 /* 156 /*
157 * The free-running counter is 32-bit which is good for about 157 * The free-running counter is 32-bit which is good for about
@@ -171,7 +171,7 @@ void __init dec_time_init(void)
171 171
172 if (!cpu_has_counter && IOASIC) 172 if (!cpu_has_counter && IOASIC)
173 /* For pre-R4k systems we use the I/O ASIC's counter. */ 173 /* For pre-R4k systems we use the I/O ASIC's counter. */
174 mips_hpt_read = dec_ioasic_hpt_read; 174 clocksource_mips.read = dec_ioasic_hpt_read;
175 175
176 /* Set up the rate of periodic DS1287 interrupts. */ 176 /* Set up the rate of periodic DS1287 interrupts. */
177 CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A); 177 CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A);
diff --git a/arch/mips/emma2rh/common/irq_emma2rh.c b/arch/mips/emma2rh/common/irq_emma2rh.c
index 197ed4c2ba04..59b98299c896 100644
--- a/arch/mips/emma2rh/common/irq_emma2rh.c
+++ b/arch/mips/emma2rh/common/irq_emma2rh.c
@@ -56,22 +56,6 @@ static void emma2rh_irq_disable(unsigned int irq)
56 ll_emma2rh_irq_disable(irq - emma2rh_irq_base); 56 ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
57} 57}
58 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) 59static void emma2rh_irq_end(unsigned int irq)
76{ 60{
77 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 61 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
@@ -80,25 +64,20 @@ static void emma2rh_irq_end(unsigned int irq)
80 64
81struct irq_chip emma2rh_irq_controller = { 65struct irq_chip emma2rh_irq_controller = {
82 .typename = "emma2rh_irq", 66 .typename = "emma2rh_irq",
83 .startup = emma2rh_irq_startup, 67 .ack = emma2rh_irq_disable,
84 .shutdown = emma2rh_irq_shutdown, 68 .mask = emma2rh_irq_disable,
85 .enable = emma2rh_irq_enable, 69 .mask_ack = emma2rh_irq_disable,
86 .disable = emma2rh_irq_disable, 70 .unmask = emma2rh_irq_enable,
87 .ack = emma2rh_irq_ack,
88 .end = emma2rh_irq_end, 71 .end = emma2rh_irq_end,
89 .set_affinity = NULL /* no affinity stuff for UP */
90}; 72};
91 73
92void emma2rh_irq_init(u32 irq_base) 74void emma2rh_irq_init(u32 irq_base)
93{ 75{
94 u32 i; 76 u32 i;
95 77
96 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ; i++) { 78 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ; i++)
97 irq_desc[i].status = IRQ_DISABLED; 79 set_irq_chip_and_handler(i, &emma2rh_irq_controller,
98 irq_desc[i].action = NULL; 80 handle_level_irq);
99 irq_desc[i].depth = 1;
100 irq_desc[i].chip = &emma2rh_irq_controller;
101 }
102 81
103 emma2rh_irq_base = irq_base; 82 emma2rh_irq_base = irq_base;
104} 83}
diff --git a/arch/mips/emma2rh/markeins/irq_markeins.c b/arch/mips/emma2rh/markeins/irq_markeins.c
index 0b36eb001e62..3ac4e405ecdc 100644
--- a/arch/mips/emma2rh/markeins/irq_markeins.c
+++ b/arch/mips/emma2rh/markeins/irq_markeins.c
@@ -48,19 +48,6 @@ static void emma2rh_sw_irq_disable(unsigned int irq)
48 ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base); 48 ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base);
49} 49}
50 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) 51static void emma2rh_sw_irq_end(unsigned int irq)
65{ 52{
66 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 53 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
@@ -69,25 +56,20 @@ static void emma2rh_sw_irq_end(unsigned int irq)
69 56
70struct irq_chip emma2rh_sw_irq_controller = { 57struct irq_chip emma2rh_sw_irq_controller = {
71 .typename = "emma2rh_sw_irq", 58 .typename = "emma2rh_sw_irq",
72 .startup = emma2rh_sw_irq_startup, 59 .ack = emma2rh_sw_irq_disable,
73 .shutdown = emma2rh_sw_irq_shutdown, 60 .mask = emma2rh_sw_irq_disable,
74 .enable = emma2rh_sw_irq_enable, 61 .mask_ack = emma2rh_sw_irq_disable,
75 .disable = emma2rh_sw_irq_disable, 62 .unmask = emma2rh_sw_irq_enable,
76 .ack = emma2rh_sw_irq_ack,
77 .end = emma2rh_sw_irq_end, 63 .end = emma2rh_sw_irq_end,
78 .set_affinity = NULL,
79}; 64};
80 65
81void emma2rh_sw_irq_init(u32 irq_base) 66void emma2rh_sw_irq_init(u32 irq_base)
82{ 67{
83 u32 i; 68 u32 i;
84 69
85 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_SW; i++) { 70 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_SW; i++)
86 irq_desc[i].status = IRQ_DISABLED; 71 set_irq_chip_and_handler(i, &emma2rh_sw_irq_controller,
87 irq_desc[i].action = NULL; 72 handle_level_irq);
88 irq_desc[i].depth = 2;
89 irq_desc[i].chip = &emma2rh_sw_irq_controller;
90 }
91 73
92 emma2rh_sw_irq_base = irq_base; 74 emma2rh_sw_irq_base = irq_base;
93} 75}
@@ -126,14 +108,6 @@ static void emma2rh_gpio_irq_disable(unsigned int irq)
126 ll_emma2rh_gpio_irq_disable(irq - emma2rh_gpio_irq_base); 108 ll_emma2rh_gpio_irq_disable(irq - emma2rh_gpio_irq_base);
127} 109}
128 110
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) 111static void emma2rh_gpio_irq_ack(unsigned int irq)
138{ 112{
139 irq -= emma2rh_gpio_irq_base; 113 irq -= emma2rh_gpio_irq_base;
@@ -149,25 +123,19 @@ static void emma2rh_gpio_irq_end(unsigned int irq)
149 123
150struct irq_chip emma2rh_gpio_irq_controller = { 124struct irq_chip emma2rh_gpio_irq_controller = {
151 .typename = "emma2rh_gpio_irq", 125 .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, 126 .ack = emma2rh_gpio_irq_ack,
127 .mask = emma2rh_gpio_irq_disable,
128 .mask_ack = emma2rh_gpio_irq_ack,
129 .unmask = emma2rh_gpio_irq_enable,
157 .end = emma2rh_gpio_irq_end, 130 .end = emma2rh_gpio_irq_end,
158 .set_affinity = NULL,
159}; 131};
160 132
161void emma2rh_gpio_irq_init(u32 irq_base) 133void emma2rh_gpio_irq_init(u32 irq_base)
162{ 134{
163 u32 i; 135 u32 i;
164 136
165 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_GPIO; i++) { 137 for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_GPIO; i++)
166 irq_desc[i].status = IRQ_DISABLED; 138 set_irq_chip(i, &emma2rh_gpio_irq_controller);
167 irq_desc[i].action = NULL;
168 irq_desc[i].depth = 2;
169 irq_desc[i].chip = &emma2rh_gpio_irq_controller;
170 }
171 139
172 emma2rh_gpio_irq_base = irq_base; 140 emma2rh_gpio_irq_base = irq_base;
173} 141}
diff --git a/arch/mips/gt64120/ev64120/irq.c b/arch/mips/gt64120/ev64120/irq.c
index ed4d82b9a24a..b3e5796c81d7 100644
--- a/arch/mips/gt64120/ev64120/irq.c
+++ b/arch/mips/gt64120/ev64120/irq.c
@@ -66,38 +66,21 @@ asmlinkage void plat_irq_dispatch(void)
66 66
67static void disable_ev64120_irq(unsigned int irq_nr) 67static void disable_ev64120_irq(unsigned int irq_nr)
68{ 68{
69 unsigned long flags;
70
71 local_irq_save(flags);
72 if (irq_nr >= 8) { // All PCI interrupts are on line 5 or 2 69 if (irq_nr >= 8) { // All PCI interrupts are on line 5 or 2
73 clear_c0_status(9 << 10); 70 clear_c0_status(9 << 10);
74 } else { 71 } else {
75 clear_c0_status(1 << (irq_nr + 8)); 72 clear_c0_status(1 << (irq_nr + 8));
76 } 73 }
77 local_irq_restore(flags);
78} 74}
79 75
80static void enable_ev64120_irq(unsigned int irq_nr) 76static void enable_ev64120_irq(unsigned int irq_nr)
81{ 77{
82 unsigned long flags;
83
84 local_irq_save(flags);
85 if (irq_nr >= 8) // All PCI interrupts are on line 5 or 2 78 if (irq_nr >= 8) // All PCI interrupts are on line 5 or 2
86 set_c0_status(9 << 10); 79 set_c0_status(9 << 10);
87 else 80 else
88 set_c0_status(1 << (irq_nr + 8)); 81 set_c0_status(1 << (irq_nr + 8));
89 local_irq_restore(flags);
90}
91
92static unsigned int startup_ev64120_irq(unsigned int irq)
93{
94 enable_ev64120_irq(irq);
95 return 0; /* Never anything pending */
96} 82}
97 83
98#define shutdown_ev64120_irq disable_ev64120_irq
99#define mask_and_ack_ev64120_irq disable_ev64120_irq
100
101static void end_ev64120_irq(unsigned int irq) 84static void end_ev64120_irq(unsigned int irq)
102{ 85{
103 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 86 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -106,13 +89,11 @@ static void end_ev64120_irq(unsigned int irq)
106 89
107static struct irq_chip ev64120_irq_type = { 90static struct irq_chip ev64120_irq_type = {
108 .typename = "EV64120", 91 .typename = "EV64120",
109 .startup = startup_ev64120_irq, 92 .ack = disable_ev64120_irq,
110 .shutdown = shutdown_ev64120_irq, 93 .mask = disable_ev64120_irq,
111 .enable = enable_ev64120_irq, 94 .mask_ack = disable_ev64120_irq,
112 .disable = disable_ev64120_irq, 95 .unmask = enable_ev64120_irq,
113 .ack = mask_and_ack_ev64120_irq,
114 .end = end_ev64120_irq, 96 .end = end_ev64120_irq,
115 .set_affinity = NULL
116}; 97};
117 98
118void gt64120_irq_setup(void) 99void gt64120_irq_setup(void)
@@ -122,8 +103,6 @@ void gt64120_irq_setup(void)
122 */ 103 */
123 clear_c0_status(ST0_IM); 104 clear_c0_status(ST0_IM);
124 105
125 local_irq_disable();
126
127 /* 106 /*
128 * Enable timer. Other interrupts will be enabled as they are 107 * Enable timer. Other interrupts will be enabled as they are
129 * registered. 108 * registered.
@@ -133,16 +112,5 @@ void gt64120_irq_setup(void)
133 112
134void __init arch_init_irq(void) 113void __init arch_init_irq(void)
135{ 114{
136 int i;
137
138 /* Let's initialize our IRQ descriptors */
139 for (i = 0; i < NR_IRQS; i++) {
140 irq_desc[i].status = 0;
141 irq_desc[i].chip = &no_irq_chip;
142 irq_desc[i].action = NULL;
143 irq_desc[i].depth = 0;
144 spin_lock_init(&irq_desc[i].lock);
145 }
146
147 gt64120_irq_setup(); 115 gt64120_irq_setup();
148} 116}
diff --git a/arch/mips/jazz/irq.c b/arch/mips/jazz/irq.c
index d5bd6b3a0933..5c4f50cdf157 100644
--- a/arch/mips/jazz/irq.c
+++ b/arch/mips/jazz/irq.c
@@ -28,14 +28,6 @@ static void enable_r4030_irq(unsigned int irq)
28 spin_unlock_irqrestore(&r4030_lock, flags); 28 spin_unlock_irqrestore(&r4030_lock, flags);
29} 29}
30 30
31static unsigned int startup_r4030_irq(unsigned int irq)
32{
33 enable_r4030_irq(irq);
34 return 0; /* never anything pending */
35}
36
37#define shutdown_r4030_irq disable_r4030_irq
38
39void disable_r4030_irq(unsigned int irq) 31void disable_r4030_irq(unsigned int irq)
40{ 32{
41 unsigned int mask = ~(1 << (irq - JAZZ_PARALLEL_IRQ)); 33 unsigned int mask = ~(1 << (irq - JAZZ_PARALLEL_IRQ));
@@ -47,8 +39,6 @@ void disable_r4030_irq(unsigned int irq)
47 spin_unlock_irqrestore(&r4030_lock, flags); 39 spin_unlock_irqrestore(&r4030_lock, flags);
48} 40}
49 41
50#define mask_and_ack_r4030_irq disable_r4030_irq
51
52static void end_r4030_irq(unsigned int irq) 42static void end_r4030_irq(unsigned int irq)
53{ 43{
54 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 44 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -57,11 +47,10 @@ static void end_r4030_irq(unsigned int irq)
57 47
58static struct irq_chip r4030_irq_type = { 48static struct irq_chip r4030_irq_type = {
59 .typename = "R4030", 49 .typename = "R4030",
60 .startup = startup_r4030_irq, 50 .ack = disable_r4030_irq,
61 .shutdown = shutdown_r4030_irq, 51 .mask = disable_r4030_irq,
62 .enable = enable_r4030_irq, 52 .mask_ack = disable_r4030_irq,
63 .disable = disable_r4030_irq, 53 .unmask = enable_r4030_irq,
64 .ack = mask_and_ack_r4030_irq,
65 .end = end_r4030_irq, 54 .end = end_r4030_irq,
66}; 55};
67 56
@@ -69,12 +58,8 @@ void __init init_r4030_ints(void)
69{ 58{
70 int i; 59 int i;
71 60
72 for (i = JAZZ_PARALLEL_IRQ; i <= JAZZ_TIMER_IRQ; i++) { 61 for (i = JAZZ_PARALLEL_IRQ; i <= JAZZ_TIMER_IRQ; i++)
73 irq_desc[i].status = IRQ_DISABLED; 62 set_irq_chip_and_handler(i, &r4030_irq_type, handle_level_irq);
74 irq_desc[i].action = 0;
75 irq_desc[i].depth = 1;
76 irq_desc[i].chip = &r4030_irq_type;
77 }
78 63
79 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0); 64 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0);
80 r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */ 65 r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */
diff --git a/arch/mips/jmr3927/rbhma3100/irq.c b/arch/mips/jmr3927/rbhma3100/irq.c
index de4a238c28be..3da49c5aaf49 100644
--- a/arch/mips/jmr3927/rbhma3100/irq.c
+++ b/arch/mips/jmr3927/rbhma3100/irq.c
@@ -90,17 +90,6 @@ static unsigned char irc_level[TX3927_NUM_IR] = {
90static void jmr3927_irq_disable(unsigned int irq_nr); 90static void jmr3927_irq_disable(unsigned int irq_nr);
91static void jmr3927_irq_enable(unsigned int irq_nr); 91static void jmr3927_irq_enable(unsigned int irq_nr);
92 92
93static DEFINE_SPINLOCK(jmr3927_irq_lock);
94
95static unsigned int jmr3927_irq_startup(unsigned int irq)
96{
97 jmr3927_irq_enable(irq);
98
99 return 0;
100}
101
102#define jmr3927_irq_shutdown jmr3927_irq_disable
103
104static void jmr3927_irq_ack(unsigned int irq) 93static void jmr3927_irq_ack(unsigned int irq)
105{ 94{
106 if (irq == JMR3927_IRQ_IRC_TMR0) 95 if (irq == JMR3927_IRQ_IRC_TMR0)
@@ -118,9 +107,7 @@ static void jmr3927_irq_end(unsigned int irq)
118static void jmr3927_irq_disable(unsigned int irq_nr) 107static void jmr3927_irq_disable(unsigned int irq_nr)
119{ 108{
120 struct tb_irq_space* sp; 109 struct tb_irq_space* sp;
121 unsigned long flags;
122 110
123 spin_lock_irqsave(&jmr3927_irq_lock, flags);
124 for (sp = tb_irq_spaces; sp; sp = sp->next) { 111 for (sp = tb_irq_spaces; sp; sp = sp->next) {
125 if (sp->start_irqno <= irq_nr && 112 if (sp->start_irqno <= irq_nr &&
126 irq_nr < sp->start_irqno + sp->nr_irqs) { 113 irq_nr < sp->start_irqno + sp->nr_irqs) {
@@ -130,15 +117,12 @@ static void jmr3927_irq_disable(unsigned int irq_nr)
130 break; 117 break;
131 } 118 }
132 } 119 }
133 spin_unlock_irqrestore(&jmr3927_irq_lock, flags);
134} 120}
135 121
136static void jmr3927_irq_enable(unsigned int irq_nr) 122static void jmr3927_irq_enable(unsigned int irq_nr)
137{ 123{
138 struct tb_irq_space* sp; 124 struct tb_irq_space* sp;
139 unsigned long flags;
140 125
141 spin_lock_irqsave(&jmr3927_irq_lock, flags);
142 for (sp = tb_irq_spaces; sp; sp = sp->next) { 126 for (sp = tb_irq_spaces; sp; sp = sp->next) {
143 if (sp->start_irqno <= irq_nr && 127 if (sp->start_irqno <= irq_nr &&
144 irq_nr < sp->start_irqno + sp->nr_irqs) { 128 irq_nr < sp->start_irqno + sp->nr_irqs) {
@@ -148,7 +132,6 @@ static void jmr3927_irq_enable(unsigned int irq_nr)
148 break; 132 break;
149 } 133 }
150 } 134 }
151 spin_unlock_irqrestore(&jmr3927_irq_lock, flags);
152} 135}
153 136
154/* 137/*
@@ -457,11 +440,10 @@ void __init arch_init_irq(void)
457 440
458static struct irq_chip jmr3927_irq_controller = { 441static struct irq_chip jmr3927_irq_controller = {
459 .typename = "jmr3927_irq", 442 .typename = "jmr3927_irq",
460 .startup = jmr3927_irq_startup,
461 .shutdown = jmr3927_irq_shutdown,
462 .enable = jmr3927_irq_enable,
463 .disable = jmr3927_irq_disable,
464 .ack = jmr3927_irq_ack, 443 .ack = jmr3927_irq_ack,
444 .mask = jmr3927_irq_disable,
445 .mask_ack = jmr3927_irq_ack,
446 .unmask = jmr3927_irq_enable,
465 .end = jmr3927_irq_end, 447 .end = jmr3927_irq_end,
466}; 448};
467 449
@@ -469,12 +451,8 @@ void jmr3927_irq_init(u32 irq_base)
469{ 451{
470 u32 i; 452 u32 i;
471 453
472 for (i= irq_base; i< irq_base + JMR3927_NR_IRQ_IRC + JMR3927_NR_IRQ_IOC; i++) { 454 for (i= irq_base; i< irq_base + JMR3927_NR_IRQ_IRC + JMR3927_NR_IRQ_IOC; i++)
473 irq_desc[i].status = IRQ_DISABLED; 455 set_irq_chip(i, &jmr3927_irq_controller);
474 irq_desc[i].action = NULL;
475 irq_desc[i].depth = 1;
476 irq_desc[i].chip = &jmr3927_irq_controller;
477 }
478 456
479 jmr3927_irq_base = irq_base; 457 jmr3927_irq_base = irq_base;
480} 458}
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
index 16e5dfe7aa8a..138f25efe38a 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -170,7 +170,7 @@ static void jmr3927_machine_power_off(void)
170 while (1); 170 while (1);
171} 171}
172 172
173static unsigned int jmr3927_hpt_read(void) 173static cycle_t jmr3927_hpt_read(void)
174{ 174{
175 /* We assume this function is called xtime_lock held. */ 175 /* We assume this function is called xtime_lock held. */
176 return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr; 176 return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr;
@@ -182,7 +182,7 @@ extern void rtc_ds1742_init(unsigned long base);
182#endif 182#endif
183static void __init jmr3927_time_init(void) 183static void __init jmr3927_time_init(void)
184{ 184{
185 mips_hpt_read = jmr3927_hpt_read; 185 clocksource_mips.read = jmr3927_hpt_read;
186 mips_hpt_frequency = JMR3927_TIMER_CLK; 186 mips_hpt_frequency = JMR3927_TIMER_CLK;
187#ifdef USE_RTC_DS1742 187#ifdef USE_RTC_DS1742
188 if (jmr3927_have_nvram()) { 188 if (jmr3927_have_nvram()) {
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index cd9cec9e39e9..bbbb8d7cb89b 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -6,7 +6,7 @@ extra-y := head.o init_task.o vmlinux.lds
6 6
7obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \ 7obj-y += cpu-probe.o branch.o entry.o genex.o irq.o process.o \
8 ptrace.o reset.o semaphore.o setup.o signal.o syscall.o \ 8 ptrace.o reset.o semaphore.o setup.o signal.o syscall.o \
9 time.o traps.o unaligned.o 9 time.o topology.o traps.o unaligned.o
10 10
11binfmt_irix-objs := irixelf.o irixinv.o irixioctl.o irixsig.o \ 11binfmt_irix-objs := irixelf.o irixinv.o irixioctl.o irixsig.o \
12 irix5sys.o sysirix.o 12 irix5sys.o sysirix.o
@@ -45,7 +45,6 @@ obj-$(CONFIG_MIPS_APSP_KSPD) += kspd.o
45obj-$(CONFIG_MIPS_VPE_LOADER) += vpe.o 45obj-$(CONFIG_MIPS_VPE_LOADER) += vpe.o
46obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o 46obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
47 47
48obj-$(CONFIG_NO_ISA) += dma-no-isa.o
49obj-$(CONFIG_I8259) += i8259.o 48obj-$(CONFIG_I8259) += i8259.o
50obj-$(CONFIG_IRQ_CPU) += irq_cpu.o 49obj-$(CONFIG_IRQ_CPU) += irq_cpu.o
51obj-$(CONFIG_IRQ_CPU_RM7K) += irq-rm7000.o 50obj-$(CONFIG_IRQ_CPU_RM7K) += irq-rm7000.o
@@ -67,6 +66,8 @@ obj-$(CONFIG_64BIT) += cpu-bugs64.o
67 66
68obj-$(CONFIG_I8253) += i8253.o 67obj-$(CONFIG_I8253) += i8253.o
69 68
69obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
70
70CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) 71CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
71 72
72EXTRA_AFLAGS := $(CFLAGS) 73EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 8485af340ee1..442839e9578c 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -110,9 +110,8 @@ static inline void check_wait(void)
110{ 110{
111 struct cpuinfo_mips *c = &current_cpu_data; 111 struct cpuinfo_mips *c = &current_cpu_data;
112 112
113 printk("Checking for 'wait' instruction... ");
114 if (nowait) { 113 if (nowait) {
115 printk (" disabled.\n"); 114 printk("Wait instruction disabled.\n");
116 return; 115 return;
117 } 116 }
118 117
@@ -120,11 +119,9 @@ static inline void check_wait(void)
120 case CPU_R3081: 119 case CPU_R3081:
121 case CPU_R3081E: 120 case CPU_R3081E:
122 cpu_wait = r3081_wait; 121 cpu_wait = r3081_wait;
123 printk(" available.\n");
124 break; 122 break;
125 case CPU_TX3927: 123 case CPU_TX3927:
126 cpu_wait = r39xx_wait; 124 cpu_wait = r39xx_wait;
127 printk(" available.\n");
128 break; 125 break;
129 case CPU_R4200: 126 case CPU_R4200:
130/* case CPU_R4300: */ 127/* case CPU_R4300: */
@@ -146,33 +143,23 @@ static inline void check_wait(void)
146 case CPU_74K: 143 case CPU_74K:
147 case CPU_PR4450: 144 case CPU_PR4450:
148 cpu_wait = r4k_wait; 145 cpu_wait = r4k_wait;
149 printk(" available.\n");
150 break; 146 break;
151 case CPU_TX49XX: 147 case CPU_TX49XX:
152 cpu_wait = r4k_wait_irqoff; 148 cpu_wait = r4k_wait_irqoff;
153 printk(" available.\n");
154 break; 149 break;
155 case CPU_AU1000: 150 case CPU_AU1000:
156 case CPU_AU1100: 151 case CPU_AU1100:
157 case CPU_AU1500: 152 case CPU_AU1500:
158 case CPU_AU1550: 153 case CPU_AU1550:
159 case CPU_AU1200: 154 case CPU_AU1200:
160 if (allow_au1k_wait) { 155 if (allow_au1k_wait)
161 cpu_wait = au1k_wait; 156 cpu_wait = au1k_wait;
162 printk(" available.\n");
163 } else
164 printk(" unavailable.\n");
165 break; 157 break;
166 case CPU_RM9000: 158 case CPU_RM9000:
167 if ((c->processor_id & 0x00ff) >= 0x40) { 159 if ((c->processor_id & 0x00ff) >= 0x40)
168 cpu_wait = r4k_wait; 160 cpu_wait = r4k_wait;
169 printk(" available.\n");
170 } else {
171 printk(" unavailable.\n");
172 }
173 break; 161 break;
174 default: 162 default:
175 printk(" unavailable.\n");
176 break; 163 break;
177 } 164 }
178} 165}
diff --git a/arch/mips/kernel/dma-no-isa.c b/arch/mips/kernel/dma-no-isa.c
deleted file mode 100644
index 6df8b07741e3..000000000000
--- a/arch/mips/kernel/dma-no-isa.c
+++ /dev/null
@@ -1,28 +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) 2004 by Ralf Baechle
7 *
8 * Dummy ISA DMA functions for systems that don't have ISA but share drivers
9 * with ISA such as legacy free PCI.
10 */
11#include <linux/errno.h>
12#include <linux/module.h>
13#include <linux/spinlock.h>
14
15DEFINE_SPINLOCK(dma_spin_lock);
16
17int request_dma(unsigned int dmanr, const char * device_id)
18{
19 return -EINVAL;
20}
21
22void free_dma(unsigned int dmanr)
23{
24}
25
26EXPORT_SYMBOL(dma_spin_lock);
27EXPORT_SYMBOL(request_dma);
28EXPORT_SYMBOL(free_dma);
diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
index 5baca16993d0..aacd4a005c5f 100644
--- a/arch/mips/kernel/genex.S
+++ b/arch/mips/kernel/genex.S
@@ -19,6 +19,7 @@
19#include <asm/mipsregs.h> 19#include <asm/mipsregs.h>
20#include <asm/stackframe.h> 20#include <asm/stackframe.h>
21#include <asm/war.h> 21#include <asm/war.h>
22#include <asm/page.h>
22 23
23#define PANIC_PIC(msg) \ 24#define PANIC_PIC(msg) \
24 .set push; \ 25 .set push; \
@@ -378,6 +379,68 @@ NESTED(nmi_handler, PT_SIZE, sp)
378 BUILD_HANDLER dsp dsp sti silent /* #26 */ 379 BUILD_HANDLER dsp dsp sti silent /* #26 */
379 BUILD_HANDLER reserved reserved sti verbose /* others */ 380 BUILD_HANDLER reserved reserved sti verbose /* others */
380 381
382 .align 5
383 LEAF(handle_ri_rdhwr_vivt)
384#ifdef CONFIG_MIPS_MT_SMTC
385 PANIC_PIC("handle_ri_rdhwr_vivt called")
386#else
387 .set push
388 .set noat
389 .set noreorder
390 /* check if TLB contains a entry for EPC */
391 MFC0 k1, CP0_ENTRYHI
392 andi k1, 0xff /* ASID_MASK */
393 MFC0 k0, CP0_EPC
394 PTR_SRL k0, PAGE_SHIFT + 1
395 PTR_SLL k0, PAGE_SHIFT + 1
396 or k1, k0
397 MTC0 k1, CP0_ENTRYHI
398 mtc0_tlbw_hazard
399 tlbp
400 tlb_probe_hazard
401 mfc0 k1, CP0_INDEX
402 .set pop
403 bltz k1, handle_ri /* slow path */
404 /* fall thru */
405#endif
406 END(handle_ri_rdhwr_vivt)
407
408 LEAF(handle_ri_rdhwr)
409 .set push
410 .set noat
411 .set noreorder
412 /* 0x7c03e83b: rdhwr v1,$29 */
413 MFC0 k1, CP0_EPC
414 lui k0, 0x7c03
415 lw k1, (k1)
416 ori k0, 0xe83b
417 .set reorder
418 bne k0, k1, handle_ri /* if not ours */
419 /* The insn is rdhwr. No need to check CAUSE.BD here. */
420 get_saved_sp /* k1 := current_thread_info */
421 .set noreorder
422 MFC0 k0, CP0_EPC
423#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
424 ori k1, _THREAD_MASK
425 xori k1, _THREAD_MASK
426 LONG_L v1, TI_TP_VALUE(k1)
427 LONG_ADDIU k0, 4
428 jr k0
429 rfe
430#else
431 LONG_ADDIU k0, 4 /* stall on $k0 */
432 MTC0 k0, CP0_EPC
433 /* I hope three instructions between MTC0 and ERET are enough... */
434 ori k1, _THREAD_MASK
435 xori k1, _THREAD_MASK
436 LONG_L v1, TI_TP_VALUE(k1)
437 .set mips3
438 eret
439 .set mips0
440#endif
441 .set pop
442 END(handle_ri_rdhwr)
443
381#ifdef CONFIG_64BIT 444#ifdef CONFIG_64BIT
382/* A temporary overflow handler used by check_daddi(). */ 445/* A temporary overflow handler used by check_daddi(). */
383 446
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index ddc1b71c9378..a2e095adaa3f 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -250,6 +250,9 @@ NESTED(smp_bootstrap, 16, sp)
250 */ 250 */
251 page swapper_pg_dir, _PGD_ORDER 251 page swapper_pg_dir, _PGD_ORDER
252#ifdef CONFIG_64BIT 252#ifdef CONFIG_64BIT
253#if defined(CONFIG_MODULES) && !defined(CONFIG_BUILD_ELF64)
254 page module_pg_dir, _PGD_ORDER
255#endif
253 page invalid_pmd_table, _PMD_ORDER 256 page invalid_pmd_table, _PMD_ORDER
254#endif 257#endif
255 page invalid_pte_table, _PTE_ORDER 258 page invalid_pte_table, _PTE_ORDER
diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
index 48e3418c217b..2526c0ca4d81 100644
--- a/arch/mips/kernel/i8259.c
+++ b/arch/mips/kernel/i8259.c
@@ -40,21 +40,10 @@ static void end_8259A_irq (unsigned int irq)
40 enable_8259A_irq(irq); 40 enable_8259A_irq(irq);
41} 41}
42 42
43#define shutdown_8259A_irq disable_8259A_irq
44
45void mask_and_ack_8259A(unsigned int); 43void mask_and_ack_8259A(unsigned int);
46 44
47static unsigned int startup_8259A_irq(unsigned int irq)
48{
49 enable_8259A_irq(irq);
50
51 return 0; /* never anything pending */
52}
53
54static struct irq_chip i8259A_irq_type = { 45static struct irq_chip i8259A_irq_type = {
55 .typename = "XT-PIC", 46 .typename = "XT-PIC",
56 .startup = startup_8259A_irq,
57 .shutdown = shutdown_8259A_irq,
58 .enable = enable_8259A_irq, 47 .enable = enable_8259A_irq,
59 .disable = disable_8259A_irq, 48 .disable = disable_8259A_irq,
60 .ack = mask_and_ack_8259A, 49 .ack = mask_and_ack_8259A,
@@ -120,7 +109,7 @@ int i8259A_irq_pending(unsigned int irq)
120void make_8259A_irq(unsigned int irq) 109void make_8259A_irq(unsigned int irq)
121{ 110{
122 disable_irq_nosync(irq); 111 disable_irq_nosync(irq);
123 irq_desc[irq].chip = &i8259A_irq_type; 112 set_irq_chip(irq, &i8259A_irq_type);
124 enable_irq(irq); 113 enable_irq(irq);
125} 114}
126 115
@@ -323,12 +312,8 @@ void __init init_i8259_irqs (void)
323 312
324 init_8259A(0); 313 init_8259A(0);
325 314
326 for (i = 0; i < 16; i++) { 315 for (i = 0; i < 16; i++)
327 irq_desc[i].status = IRQ_DISABLED; 316 set_irq_chip(i, &i8259A_irq_type);
328 irq_desc[i].action = NULL;
329 irq_desc[i].depth = 1;
330 irq_desc[i].chip = &i8259A_irq_type;
331 }
332 317
333 setup_irq(2, &irq2); 318 setup_irq(2, &irq2);
334} 319}
diff --git a/arch/mips/kernel/irq-msc01.c b/arch/mips/kernel/irq-msc01.c
index 650a80ca3741..bcaad6696082 100644
--- a/arch/mips/kernel/irq-msc01.c
+++ b/arch/mips/kernel/irq-msc01.c
@@ -45,31 +45,6 @@ static inline void unmask_msc_irq(unsigned int irq)
45} 45}
46 46
47/* 47/*
48 * Enables the IRQ on SOC-it
49 */
50static void enable_msc_irq(unsigned int irq)
51{
52 unmask_msc_irq(irq);
53}
54
55/*
56 * Initialize the IRQ on SOC-it
57 */
58static unsigned int startup_msc_irq(unsigned int irq)
59{
60 unmask_msc_irq(irq);
61 return 0;
62}
63
64/*
65 * Disables the IRQ on SOC-it
66 */
67static void disable_msc_irq(unsigned int irq)
68{
69 mask_msc_irq(irq);
70}
71
72/*
73 * Masks and ACKs an IRQ 48 * Masks and ACKs an IRQ
74 */ 49 */
75static void level_mask_and_ack_msc_irq(unsigned int irq) 50static void level_mask_and_ack_msc_irq(unsigned int irq)
@@ -136,25 +111,23 @@ msc_bind_eic_interrupt (unsigned int irq, unsigned int set)
136 (irq<<MSC01_IC_RAMW_ADDR_SHF) | (set<<MSC01_IC_RAMW_DATA_SHF)); 111 (irq<<MSC01_IC_RAMW_ADDR_SHF) | (set<<MSC01_IC_RAMW_DATA_SHF));
137} 112}
138 113
139#define shutdown_msc_irq disable_msc_irq
140
141struct irq_chip msc_levelirq_type = { 114struct irq_chip msc_levelirq_type = {
142 .typename = "SOC-it-Level", 115 .typename = "SOC-it-Level",
143 .startup = startup_msc_irq,
144 .shutdown = shutdown_msc_irq,
145 .enable = enable_msc_irq,
146 .disable = disable_msc_irq,
147 .ack = level_mask_and_ack_msc_irq, 116 .ack = level_mask_and_ack_msc_irq,
117 .mask = mask_msc_irq,
118 .mask_ack = level_mask_and_ack_msc_irq,
119 .unmask = unmask_msc_irq,
120 .eoi = unmask_msc_irq,
148 .end = end_msc_irq, 121 .end = end_msc_irq,
149}; 122};
150 123
151struct irq_chip msc_edgeirq_type = { 124struct irq_chip msc_edgeirq_type = {
152 .typename = "SOC-it-Edge", 125 .typename = "SOC-it-Edge",
153 .startup =startup_msc_irq,
154 .shutdown = shutdown_msc_irq,
155 .enable = enable_msc_irq,
156 .disable = disable_msc_irq,
157 .ack = edge_mask_and_ack_msc_irq, 126 .ack = edge_mask_and_ack_msc_irq,
127 .mask = mask_msc_irq,
128 .mask_ack = edge_mask_and_ack_msc_irq,
129 .unmask = unmask_msc_irq,
130 .eoi = unmask_msc_irq,
158 .end = end_msc_irq, 131 .end = end_msc_irq,
159}; 132};
160 133
@@ -175,14 +148,14 @@ void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq)
175 148
176 switch (imp->im_type) { 149 switch (imp->im_type) {
177 case MSC01_IRQ_EDGE: 150 case MSC01_IRQ_EDGE:
178 irq_desc[base+n].chip = &msc_edgeirq_type; 151 set_irq_chip(base+n, &msc_edgeirq_type);
179 if (cpu_has_veic) 152 if (cpu_has_veic)
180 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT); 153 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT);
181 else 154 else
182 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl); 155 MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl);
183 break; 156 break;
184 case MSC01_IRQ_LEVEL: 157 case MSC01_IRQ_LEVEL:
185 irq_desc[base+n].chip = &msc_levelirq_type; 158 set_irq_chip(base+n, &msc_levelirq_type);
186 if (cpu_has_veic) 159 if (cpu_has_veic)
187 MSCIC_WRITE(MSC01_IC_SUP+n*8, 0); 160 MSCIC_WRITE(MSC01_IC_SUP+n*8, 0);
188 else 161 else
diff --git a/arch/mips/kernel/irq-mv6434x.c b/arch/mips/kernel/irq-mv6434x.c
index 37d106202b83..6cfb31cafde2 100644
--- a/arch/mips/kernel/irq-mv6434x.c
+++ b/arch/mips/kernel/irq-mv6434x.c
@@ -67,39 +67,6 @@ static inline void unmask_mv64340_irq(unsigned int irq)
67} 67}
68 68
69/* 69/*
70 * Enables the IRQ on Marvell Chip
71 */
72static void enable_mv64340_irq(unsigned int irq)
73{
74 unmask_mv64340_irq(irq);
75}
76
77/*
78 * Initialize the IRQ on Marvell Chip
79 */
80static unsigned int startup_mv64340_irq(unsigned int irq)
81{
82 unmask_mv64340_irq(irq);
83 return 0;
84}
85
86/*
87 * Disables the IRQ on Marvell Chip
88 */
89static void disable_mv64340_irq(unsigned int irq)
90{
91 mask_mv64340_irq(irq);
92}
93
94/*
95 * Masks and ACKs an IRQ
96 */
97static void mask_and_ack_mv64340_irq(unsigned int irq)
98{
99 mask_mv64340_irq(irq);
100}
101
102/*
103 * End IRQ processing 70 * End IRQ processing
104 */ 71 */
105static void end_mv64340_irq(unsigned int irq) 72static void end_mv64340_irq(unsigned int irq)
@@ -133,15 +100,12 @@ void ll_mv64340_irq(void)
133 do_IRQ(ls1bit32(irq_src_high) + irq_base + 32); 100 do_IRQ(ls1bit32(irq_src_high) + irq_base + 32);
134} 101}
135 102
136#define shutdown_mv64340_irq disable_mv64340_irq
137
138struct irq_chip mv64340_irq_type = { 103struct irq_chip mv64340_irq_type = {
139 .typename = "MV-64340", 104 .typename = "MV-64340",
140 .startup = startup_mv64340_irq, 105 .ack = mask_mv64340_irq,
141 .shutdown = shutdown_mv64340_irq, 106 .mask = mask_mv64340_irq,
142 .enable = enable_mv64340_irq, 107 .mask_ack = mask_mv64340_irq,
143 .disable = disable_mv64340_irq, 108 .unmask = unmask_mv64340_irq,
144 .ack = mask_and_ack_mv64340_irq,
145 .end = end_mv64340_irq, 109 .end = end_mv64340_irq,
146}; 110};
147 111
@@ -149,13 +113,9 @@ void __init mv64340_irq_init(unsigned int base)
149{ 113{
150 int i; 114 int i;
151 115
152 /* Reset irq handlers pointers to NULL */ 116 for (i = base; i < base + 64; i++)
153 for (i = base; i < base + 64; i++) { 117 set_irq_chip_and_handler(i, &mv64340_irq_type,
154 irq_desc[i].status = IRQ_DISABLED; 118 handle_level_irq);
155 irq_desc[i].action = 0;
156 irq_desc[i].depth = 2;
157 irq_desc[i].chip = &mv64340_irq_type;
158 }
159 119
160 irq_base = base; 120 irq_base = base;
161} 121}
diff --git a/arch/mips/kernel/irq-rm7000.c b/arch/mips/kernel/irq-rm7000.c
index 6b54c7109e2e..ddcc2a5f8a06 100644
--- a/arch/mips/kernel/irq-rm7000.c
+++ b/arch/mips/kernel/irq-rm7000.c
@@ -29,42 +29,6 @@ static inline void mask_rm7k_irq(unsigned int irq)
29 clear_c0_intcontrol(0x100 << (irq - irq_base)); 29 clear_c0_intcontrol(0x100 << (irq - irq_base));
30} 30}
31 31
32static inline void rm7k_cpu_irq_enable(unsigned int irq)
33{
34 unsigned long flags;
35
36 local_irq_save(flags);
37 unmask_rm7k_irq(irq);
38 local_irq_restore(flags);
39}
40
41static void rm7k_cpu_irq_disable(unsigned int irq)
42{
43 unsigned long flags;
44
45 local_irq_save(flags);
46 mask_rm7k_irq(irq);
47 local_irq_restore(flags);
48}
49
50static unsigned int rm7k_cpu_irq_startup(unsigned int irq)
51{
52 rm7k_cpu_irq_enable(irq);
53
54 return 0;
55}
56
57#define rm7k_cpu_irq_shutdown rm7k_cpu_irq_disable
58
59/*
60 * While we ack the interrupt interrupts are disabled and thus we don't need
61 * to deal with concurrency issues. Same for rm7k_cpu_irq_end.
62 */
63static void rm7k_cpu_irq_ack(unsigned int irq)
64{
65 mask_rm7k_irq(irq);
66}
67
68static void rm7k_cpu_irq_end(unsigned int irq) 32static void rm7k_cpu_irq_end(unsigned int irq)
69{ 33{
70 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 34 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
@@ -73,11 +37,10 @@ static void rm7k_cpu_irq_end(unsigned int irq)
73 37
74static struct irq_chip rm7k_irq_controller = { 38static struct irq_chip rm7k_irq_controller = {
75 .typename = "RM7000", 39 .typename = "RM7000",
76 .startup = rm7k_cpu_irq_startup, 40 .ack = mask_rm7k_irq,
77 .shutdown = rm7k_cpu_irq_shutdown, 41 .mask = mask_rm7k_irq,
78 .enable = rm7k_cpu_irq_enable, 42 .mask_ack = mask_rm7k_irq,
79 .disable = rm7k_cpu_irq_disable, 43 .unmask = unmask_rm7k_irq,
80 .ack = rm7k_cpu_irq_ack,
81 .end = rm7k_cpu_irq_end, 44 .end = rm7k_cpu_irq_end,
82}; 45};
83 46
@@ -87,12 +50,9 @@ void __init rm7k_cpu_irq_init(int base)
87 50
88 clear_c0_intcontrol(0x00000f00); /* Mask all */ 51 clear_c0_intcontrol(0x00000f00); /* Mask all */
89 52
90 for (i = base; i < base + 4; i++) { 53 for (i = base; i < base + 4; i++)
91 irq_desc[i].status = IRQ_DISABLED; 54 set_irq_chip_and_handler(i, &rm7k_irq_controller,
92 irq_desc[i].action = NULL; 55 handle_level_irq);
93 irq_desc[i].depth = 1;
94 irq_desc[i].chip = &rm7k_irq_controller;
95 }
96 56
97 irq_base = base; 57 irq_base = base;
98} 58}
diff --git a/arch/mips/kernel/irq-rm9000.c b/arch/mips/kernel/irq-rm9000.c
index 62f011ba97a2..ba6440c88abd 100644
--- a/arch/mips/kernel/irq-rm9000.c
+++ b/arch/mips/kernel/irq-rm9000.c
@@ -48,15 +48,6 @@ static void rm9k_cpu_irq_disable(unsigned int irq)
48 local_irq_restore(flags); 48 local_irq_restore(flags);
49} 49}
50 50
51static unsigned int rm9k_cpu_irq_startup(unsigned int irq)
52{
53 rm9k_cpu_irq_enable(irq);
54
55 return 0;
56}
57
58#define rm9k_cpu_irq_shutdown rm9k_cpu_irq_disable
59
60/* 51/*
61 * Performance counter interrupts are global on all processors. 52 * Performance counter interrupts are global on all processors.
62 */ 53 */
@@ -89,16 +80,6 @@ static void rm9k_perfcounter_irq_shutdown(unsigned int irq)
89 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1); 80 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1);
90} 81}
91 82
92
93/*
94 * While we ack the interrupt interrupts are disabled and thus we don't need
95 * to deal with concurrency issues. Same for rm9k_cpu_irq_end.
96 */
97static void rm9k_cpu_irq_ack(unsigned int irq)
98{
99 mask_rm9k_irq(irq);
100}
101
102static void rm9k_cpu_irq_end(unsigned int irq) 83static void rm9k_cpu_irq_end(unsigned int irq)
103{ 84{
104 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 85 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
@@ -107,11 +88,10 @@ static void rm9k_cpu_irq_end(unsigned int irq)
107 88
108static struct irq_chip rm9k_irq_controller = { 89static struct irq_chip rm9k_irq_controller = {
109 .typename = "RM9000", 90 .typename = "RM9000",
110 .startup = rm9k_cpu_irq_startup, 91 .ack = mask_rm9k_irq,
111 .shutdown = rm9k_cpu_irq_shutdown, 92 .mask = mask_rm9k_irq,
112 .enable = rm9k_cpu_irq_enable, 93 .mask_ack = mask_rm9k_irq,
113 .disable = rm9k_cpu_irq_disable, 94 .unmask = unmask_rm9k_irq,
114 .ack = rm9k_cpu_irq_ack,
115 .end = rm9k_cpu_irq_end, 95 .end = rm9k_cpu_irq_end,
116}; 96};
117 97
@@ -119,9 +99,10 @@ static struct irq_chip rm9k_perfcounter_irq = {
119 .typename = "RM9000", 99 .typename = "RM9000",
120 .startup = rm9k_perfcounter_irq_startup, 100 .startup = rm9k_perfcounter_irq_startup,
121 .shutdown = rm9k_perfcounter_irq_shutdown, 101 .shutdown = rm9k_perfcounter_irq_shutdown,
122 .enable = rm9k_cpu_irq_enable, 102 .ack = mask_rm9k_irq,
123 .disable = rm9k_cpu_irq_disable, 103 .mask = mask_rm9k_irq,
124 .ack = rm9k_cpu_irq_ack, 104 .mask_ack = mask_rm9k_irq,
105 .unmask = unmask_rm9k_irq,
125 .end = rm9k_cpu_irq_end, 106 .end = rm9k_cpu_irq_end,
126}; 107};
127 108
@@ -135,15 +116,13 @@ void __init rm9k_cpu_irq_init(int base)
135 116
136 clear_c0_intcontrol(0x0000f000); /* Mask all */ 117 clear_c0_intcontrol(0x0000f000); /* Mask all */
137 118
138 for (i = base; i < base + 4; i++) { 119 for (i = base; i < base + 4; i++)
139 irq_desc[i].status = IRQ_DISABLED; 120 set_irq_chip_and_handler(i, &rm9k_irq_controller,
140 irq_desc[i].action = NULL; 121 handle_level_irq);
141 irq_desc[i].depth = 1;
142 irq_desc[i].chip = &rm9k_irq_controller;
143 }
144 122
145 rm9000_perfcount_irq = base + 1; 123 rm9000_perfcount_irq = base + 1;
146 irq_desc[rm9000_perfcount_irq].chip = &rm9k_perfcounter_irq; 124 set_irq_chip_and_handler(rm9000_perfcount_irq, &rm9k_perfcounter_irq,
125 handle_level_irq);
147 126
148 irq_base = base; 127 irq_base = base;
149} 128}
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index 9b0e49d63d7b..b339798b3172 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -88,25 +88,6 @@ atomic_t irq_err_count;
88unsigned long irq_hwmask[NR_IRQS]; 88unsigned long irq_hwmask[NR_IRQS];
89#endif /* CONFIG_MIPS_MT_SMTC */ 89#endif /* CONFIG_MIPS_MT_SMTC */
90 90
91#undef do_IRQ
92
93/*
94 * do_IRQ handles all normal device IRQ's (the special
95 * SMP cross-CPU interrupts have their own specific
96 * handlers).
97 */
98asmlinkage unsigned int do_IRQ(unsigned int irq)
99{
100 irq_enter();
101
102 __DO_IRQ_SMTC_HOOK();
103 __do_IRQ(irq);
104
105 irq_exit();
106
107 return 1;
108}
109
110/* 91/*
111 * Generic, controller-independent functions: 92 * Generic, controller-independent functions:
112 */ 93 */
@@ -172,19 +153,6 @@ __setup("nokgdb", nokgdb);
172 153
173void __init init_IRQ(void) 154void __init init_IRQ(void)
174{ 155{
175 int i;
176
177 for (i = 0; i < NR_IRQS; i++) {
178 irq_desc[i].status = IRQ_DISABLED;
179 irq_desc[i].action = NULL;
180 irq_desc[i].depth = 1;
181 irq_desc[i].chip = &no_irq_chip;
182 spin_lock_init(&irq_desc[i].lock);
183#ifdef CONFIG_MIPS_MT_SMTC
184 irq_hwmask[i] = 0;
185#endif /* CONFIG_MIPS_MT_SMTC */
186 }
187
188 arch_init_irq(); 156 arch_init_irq();
189 157
190#ifdef CONFIG_KGDB 158#ifdef CONFIG_KGDB
diff --git a/arch/mips/kernel/irq_cpu.c b/arch/mips/kernel/irq_cpu.c
index 9bb21c7f2149..be5ac23d3812 100644
--- a/arch/mips/kernel/irq_cpu.c
+++ b/arch/mips/kernel/irq_cpu.c
@@ -50,44 +50,6 @@ static inline void mask_mips_irq(unsigned int irq)
50 irq_disable_hazard(); 50 irq_disable_hazard();
51} 51}
52 52
53static inline void mips_cpu_irq_enable(unsigned int irq)
54{
55 unsigned long flags;
56
57 local_irq_save(flags);
58 unmask_mips_irq(irq);
59 back_to_back_c0_hazard();
60 local_irq_restore(flags);
61}
62
63static void mips_cpu_irq_disable(unsigned int irq)
64{
65 unsigned long flags;
66
67 local_irq_save(flags);
68 mask_mips_irq(irq);
69 back_to_back_c0_hazard();
70 local_irq_restore(flags);
71}
72
73static unsigned int mips_cpu_irq_startup(unsigned int irq)
74{
75 mips_cpu_irq_enable(irq);
76
77 return 0;
78}
79
80#define mips_cpu_irq_shutdown mips_cpu_irq_disable
81
82/*
83 * While we ack the interrupt interrupts are disabled and thus we don't need
84 * to deal with concurrency issues. Same for mips_cpu_irq_end.
85 */
86static void mips_cpu_irq_ack(unsigned int irq)
87{
88 mask_mips_irq(irq);
89}
90
91static void mips_cpu_irq_end(unsigned int irq) 53static void mips_cpu_irq_end(unsigned int irq)
92{ 54{
93 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 55 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
@@ -96,11 +58,11 @@ static void mips_cpu_irq_end(unsigned int irq)
96 58
97static struct irq_chip mips_cpu_irq_controller = { 59static struct irq_chip mips_cpu_irq_controller = {
98 .typename = "MIPS", 60 .typename = "MIPS",
99 .startup = mips_cpu_irq_startup, 61 .ack = mask_mips_irq,
100 .shutdown = mips_cpu_irq_shutdown, 62 .mask = mask_mips_irq,
101 .enable = mips_cpu_irq_enable, 63 .mask_ack = mask_mips_irq,
102 .disable = mips_cpu_irq_disable, 64 .unmask = unmask_mips_irq,
103 .ack = mips_cpu_irq_ack, 65 .eoi = unmask_mips_irq,
104 .end = mips_cpu_irq_end, 66 .end = mips_cpu_irq_end,
105}; 67};
106 68
@@ -110,8 +72,6 @@ static struct irq_chip mips_cpu_irq_controller = {
110 72
111#define unmask_mips_mt_irq unmask_mips_irq 73#define unmask_mips_mt_irq unmask_mips_irq
112#define mask_mips_mt_irq mask_mips_irq 74#define mask_mips_mt_irq mask_mips_irq
113#define mips_mt_cpu_irq_enable mips_cpu_irq_enable
114#define mips_mt_cpu_irq_disable mips_cpu_irq_disable
115 75
116static unsigned int mips_mt_cpu_irq_startup(unsigned int irq) 76static unsigned int mips_mt_cpu_irq_startup(unsigned int irq)
117{ 77{
@@ -119,13 +79,11 @@ static unsigned int mips_mt_cpu_irq_startup(unsigned int irq)
119 79
120 clear_c0_cause(0x100 << (irq - mips_cpu_irq_base)); 80 clear_c0_cause(0x100 << (irq - mips_cpu_irq_base));
121 evpe(vpflags); 81 evpe(vpflags);
122 mips_mt_cpu_irq_enable(irq); 82 unmask_mips_mt_irq(irq);
123 83
124 return 0; 84 return 0;
125} 85}
126 86
127#define mips_mt_cpu_irq_shutdown mips_mt_cpu_irq_disable
128
129/* 87/*
130 * While we ack the interrupt interrupts are disabled and thus we don't need 88 * While we ack the interrupt interrupts are disabled and thus we don't need
131 * to deal with concurrency issues. Same for mips_cpu_irq_end. 89 * to deal with concurrency issues. Same for mips_cpu_irq_end.
@@ -143,10 +101,11 @@ static void mips_mt_cpu_irq_ack(unsigned int irq)
143static struct irq_chip mips_mt_cpu_irq_controller = { 101static struct irq_chip mips_mt_cpu_irq_controller = {
144 .typename = "MIPS", 102 .typename = "MIPS",
145 .startup = mips_mt_cpu_irq_startup, 103 .startup = mips_mt_cpu_irq_startup,
146 .shutdown = mips_mt_cpu_irq_shutdown,
147 .enable = mips_mt_cpu_irq_enable,
148 .disable = mips_mt_cpu_irq_disable,
149 .ack = mips_mt_cpu_irq_ack, 104 .ack = mips_mt_cpu_irq_ack,
105 .mask = mask_mips_mt_irq,
106 .mask_ack = mips_mt_cpu_irq_ack,
107 .unmask = unmask_mips_mt_irq,
108 .eoi = unmask_mips_mt_irq,
150 .end = mips_mt_cpu_irq_end, 109 .end = mips_mt_cpu_irq_end,
151}; 110};
152 111
@@ -163,19 +122,12 @@ void __init mips_cpu_irq_init(int irq_base)
163 * leave them uninitialized for other processors. 122 * leave them uninitialized for other processors.
164 */ 123 */
165 if (cpu_has_mipsmt) 124 if (cpu_has_mipsmt)
166 for (i = irq_base; i < irq_base + 2; i++) { 125 for (i = irq_base; i < irq_base + 2; i++)
167 irq_desc[i].status = IRQ_DISABLED; 126 set_irq_chip(i, &mips_mt_cpu_irq_controller);
168 irq_desc[i].action = NULL; 127
169 irq_desc[i].depth = 1; 128 for (i = irq_base + 2; i < irq_base + 8; i++)
170 irq_desc[i].chip = &mips_mt_cpu_irq_controller; 129 set_irq_chip_and_handler(i, &mips_cpu_irq_controller,
171 } 130 handle_level_irq);
172
173 for (i = irq_base + 2; i < irq_base + 8; i++) {
174 irq_desc[i].status = IRQ_DISABLED;
175 irq_desc[i].action = NULL;
176 irq_desc[i].depth = 1;
177 irq_desc[i].chip = &mips_cpu_irq_controller;
178 }
179 131
180 mips_cpu_irq_base = irq_base; 132 mips_cpu_irq_base = irq_base;
181} 133}
diff --git a/arch/mips/kernel/machine_kexec.c b/arch/mips/kernel/machine_kexec.c
new file mode 100644
index 000000000000..e0ad754c7edd
--- /dev/null
+++ b/arch/mips/kernel/machine_kexec.c
@@ -0,0 +1,85 @@
1/*
2 * machine_kexec.c for kexec
3 * Created by <nschichan@corp.free.fr> on Thu Oct 12 15:15:06 2006
4 *
5 * This source code is licensed under the GNU General Public License,
6 * Version 2. See the file COPYING for more details.
7 */
8
9#include <linux/kexec.h>
10#include <linux/mm.h>
11#include <linux/delay.h>
12
13#include <asm/cacheflush.h>
14#include <asm/page.h>
15
16const extern unsigned char relocate_new_kernel[];
17const extern unsigned int relocate_new_kernel_size;
18
19extern unsigned long kexec_start_address;
20extern unsigned long kexec_indirection_page;
21
22int
23machine_kexec_prepare(struct kimage *kimage)
24{
25 return 0;
26}
27
28void
29machine_kexec_cleanup(struct kimage *kimage)
30{
31}
32
33void
34machine_shutdown(void)
35{
36}
37
38void
39machine_crash_shutdown(struct pt_regs *regs)
40{
41}
42
43void
44machine_kexec(struct kimage *image)
45{
46 unsigned long reboot_code_buffer;
47 unsigned long entry;
48 unsigned long *ptr;
49
50 reboot_code_buffer =
51 (unsigned long)page_address(image->control_code_page);
52
53 kexec_start_address = image->start;
54 kexec_indirection_page = phys_to_virt(image->head & PAGE_MASK);
55
56 memcpy((void*)reboot_code_buffer, relocate_new_kernel,
57 relocate_new_kernel_size);
58
59 /*
60 * The generic kexec code builds a page list with physical
61 * addresses. they are directly accessible through KSEG0 (or
62 * CKSEG0 or XPHYS if on 64bit system), hence the
63 * pys_to_virt() call.
64 */
65 for (ptr = &image->head; (entry = *ptr) && !(entry &IND_DONE);
66 ptr = (entry & IND_INDIRECTION) ?
67 phys_to_virt(entry & PAGE_MASK) : ptr + 1) {
68 if (*ptr & IND_SOURCE || *ptr & IND_INDIRECTION ||
69 *ptr & IND_DESTINATION)
70 *ptr = phys_to_virt(*ptr);
71 }
72
73 /*
74 * we do not want to be bothered.
75 */
76 local_irq_disable();
77
78 flush_icache_range(reboot_code_buffer,
79 reboot_code_buffer + KEXEC_CONTROL_CODE_SIZE);
80
81 printk("Will call new kernel at %08x\n", image->start);
82 printk("Bye ...\n");
83 flush_cache_all();
84 ((void (*)(void))reboot_code_buffer)();
85}
diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c
index d7bf0215bc1d..cb0801437b66 100644
--- a/arch/mips/kernel/module.c
+++ b/arch/mips/kernel/module.c
@@ -29,6 +29,7 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <asm/pgtable.h> /* MODULE_START */
32 33
33struct mips_hi16 { 34struct mips_hi16 {
34 struct mips_hi16 *next; 35 struct mips_hi16 *next;
@@ -43,9 +44,23 @@ static DEFINE_SPINLOCK(dbe_lock);
43 44
44void *module_alloc(unsigned long size) 45void *module_alloc(unsigned long size)
45{ 46{
47#ifdef MODULE_START
48 struct vm_struct *area;
49
50 size = PAGE_ALIGN(size);
51 if (!size)
52 return NULL;
53
54 area = __get_vm_area(size, VM_ALLOC, MODULE_START, MODULE_END);
55 if (!area)
56 return NULL;
57
58 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL);
59#else
46 if (size == 0) 60 if (size == 0)
47 return NULL; 61 return NULL;
48 return vmalloc(size); 62 return vmalloc(size);
63#endif
49} 64}
50 65
51/* Free memory returned from module_alloc */ 66/* Free memory returned from module_alloc */
diff --git a/arch/mips/kernel/relocate_kernel.S b/arch/mips/kernel/relocate_kernel.S
new file mode 100644
index 000000000000..a3f0d00c1334
--- /dev/null
+++ b/arch/mips/kernel/relocate_kernel.S
@@ -0,0 +1,80 @@
1/*
2 * relocate_kernel.S for kexec
3 * Created by <nschichan@corp.free.fr> on Thu Oct 12 17:49:57 2006
4 *
5 * This source code is licensed under the GNU General Public License,
6 * Version 2. See the file COPYING for more details.
7 */
8
9#include <asm/asm.h>
10#include <asm/asmmacro.h>
11#include <asm/regdef.h>
12#include <asm/page.h>
13#include <asm/mipsregs.h>
14#include <asm/stackframe.h>
15#include <asm/addrspace.h>
16
17 .globl relocate_new_kernel
18relocate_new_kernel:
19
20 PTR_L s0, kexec_indirection_page
21 PTR_L s1, kexec_start_address
22
23process_entry:
24 PTR_L s2, (s0)
25 PTR_ADD s0, s0, SZREG
26
27 /* destination page */
28 and s3, s2, 0x1
29 beq s3, zero, 1f
30 and s4, s2, ~0x1 /* store destination addr in s4 */
31 move a0, s4
32 b process_entry
33
341:
35 /* indirection page, update s0 */
36 and s3, s2, 0x2
37 beq s3, zero, 1f
38 and s0, s2, ~0x2
39 b process_entry
40
411:
42 /* done page */
43 and s3, s2, 0x4
44 beq s3, zero, 1f
45 b done
461:
47 /* source page */
48 and s3, s2, 0x8
49 beq s3, zero, process_entry
50 and s2, s2, ~0x8
51 li s6, (1 << PAGE_SHIFT) / SZREG
52
53copy_word:
54 /* copy page word by word */
55 REG_L s5, (s2)
56 REG_S s5, (s4)
57 INT_ADD s4, s4, SZREG
58 INT_ADD s2, s2, SZREG
59 INT_SUB s6, s6, 1
60 beq s6, zero, process_entry
61 b copy_word
62 b process_entry
63
64done:
65 /* jump to kexec_start_address */
66 j s1
67
68 .globl kexec_start_address
69kexec_start_address:
70 .long 0x0
71
72 .globl kexec_indirection_page
73kexec_indirection_page:
74 .long 0x0
75
76relocate_new_kernel_end:
77
78 .globl relocate_new_kernel_size
79relocate_new_kernel_size:
80 .long relocate_new_kernel_end - relocate_new_kernel
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index a95f37de080e..7c0b3936ba44 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -653,7 +653,7 @@ einval: li v0, -EINVAL
653 sys sys_move_pages 6 653 sys sys_move_pages 6
654 sys sys_set_robust_list 2 654 sys sys_set_robust_list 2
655 sys sys_get_robust_list 3 /* 4310 */ 655 sys sys_get_robust_list 3 /* 4310 */
656 sys sys_ni_syscall 0 656 sys sys_kexec_load 4
657 sys sys_getcpu 3 657 sys sys_getcpu 3
658 sys sys_epoll_pwait 6 658 sys sys_epoll_pwait 6
659 .endm 659 .endm
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 8fb0f60f657b..e569b846e9a3 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -468,6 +468,6 @@ sys_call_table:
468 PTR sys_move_pages 468 PTR sys_move_pages
469 PTR sys_set_robust_list 469 PTR sys_set_robust_list
470 PTR sys_get_robust_list 470 PTR sys_get_robust_list
471 PTR sys_ni_syscall /* 5270 */ 471 PTR sys_kexec_load /* 5270 */
472 PTR sys_getcpu 472 PTR sys_getcpu
473 PTR sys_epoll_pwait 473 PTR sys_epoll_pwait
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 0da5ca2040ff..5b18f265d75b 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -394,6 +394,6 @@ EXPORT(sysn32_call_table)
394 PTR sys_move_pages 394 PTR sys_move_pages
395 PTR compat_sys_set_robust_list 395 PTR compat_sys_set_robust_list
396 PTR compat_sys_get_robust_list 396 PTR compat_sys_get_robust_list
397 PTR sys_ni_syscall 397 PTR compat_sys_kexec_load
398 PTR sys_getcpu 398 PTR sys_getcpu
399 PTR sys_epoll_pwait 399 PTR sys_epoll_pwait
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index b9d00cae8b5f..e91379c1be1d 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -516,7 +516,7 @@ sys_call_table:
516 PTR compat_sys_move_pages 516 PTR compat_sys_move_pages
517 PTR compat_sys_set_robust_list 517 PTR compat_sys_set_robust_list
518 PTR compat_sys_get_robust_list /* 4310 */ 518 PTR compat_sys_get_robust_list /* 4310 */
519 PTR sys_ni_syscall 519 PTR compat_sys_kexec_load
520 PTR sys_getcpu 520 PTR sys_getcpu
521 PTR sys_epoll_pwait 521 PTR sys_epoll_pwait
522 .size sys_call_table,.-sys_call_table 522 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8f6e89697ccf..89440a0d8528 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -145,13 +145,12 @@ static int __init rd_start_early(char *p)
145 unsigned long start = memparse(p, &p); 145 unsigned long start = memparse(p, &p);
146 146
147#ifdef CONFIG_64BIT 147#ifdef CONFIG_64BIT
148 /* HACK: Guess if the sign extension was forgotten */ 148 /* Guess if the sign extension was forgotten by bootloader */
149 if (start > 0x0000000080000000 && start < 0x00000000ffffffff) 149 if (start < XKPHYS)
150 start |= 0xffffffff00000000UL; 150 start = (int)start;
151#endif 151#endif
152 initrd_start = start; 152 initrd_start = start;
153 initrd_end += start; 153 initrd_end += start;
154
155 return 0; 154 return 0;
156} 155}
157early_param("rd_start", rd_start_early); 156early_param("rd_start", rd_start_early);
@@ -159,41 +158,64 @@ early_param("rd_start", rd_start_early);
159static int __init rd_size_early(char *p) 158static int __init rd_size_early(char *p)
160{ 159{
161 initrd_end += memparse(p, &p); 160 initrd_end += memparse(p, &p);
162
163 return 0; 161 return 0;
164} 162}
165early_param("rd_size", rd_size_early); 163early_param("rd_size", rd_size_early);
166 164
165/* it returns the next free pfn after initrd */
167static unsigned long __init init_initrd(void) 166static unsigned long __init init_initrd(void)
168{ 167{
169 unsigned long tmp, end, size; 168 unsigned long end;
170 u32 *initrd_header; 169 u32 *initrd_header;
171 170
172 ROOT_DEV = Root_RAM0;
173
174 /* 171 /*
175 * Board specific code or command line parser should have 172 * Board specific code or command line parser should have
176 * already set up initrd_start and initrd_end. In these cases 173 * already set up initrd_start and initrd_end. In these cases
177 * perfom sanity checks and use them if all looks good. 174 * perfom sanity checks and use them if all looks good.
178 */ 175 */
179 size = initrd_end - initrd_start; 176 if (initrd_start && initrd_end > initrd_start)
180 if (initrd_end == 0 || size == 0) { 177 goto sanitize;
181 initrd_start = 0; 178
182 initrd_end = 0; 179 /*
183 } else 180 * See if initrd has been added to the kernel image by
184 return initrd_end; 181 * arch/mips/boot/addinitrd.c. In that case a header is
185 182 * prepended to initrd and is made up by 8 bytes. The fisrt
186 end = (unsigned long)&_end; 183 * word is a magic number and the second one is the size of
187 tmp = PAGE_ALIGN(end) - sizeof(u32) * 2; 184 * initrd. Initrd start must be page aligned in any cases.
188 if (tmp < end) 185 */
189 tmp += PAGE_SIZE; 186 initrd_header = __va(PAGE_ALIGN(__pa_symbol(&_end) + 8)) - 8;
190 187 if (initrd_header[0] != 0x494E5244)
191 initrd_header = (u32 *)tmp; 188 goto disable;
192 if (initrd_header[0] == 0x494E5244) { 189 initrd_start = (unsigned long)(initrd_header + 2);
193 initrd_start = (unsigned long)&initrd_header[2]; 190 initrd_end = initrd_start + initrd_header[1];
194 initrd_end = initrd_start + initrd_header[1]; 191
192sanitize:
193 if (initrd_start & ~PAGE_MASK) {
194 printk(KERN_ERR "initrd start must be page aligned\n");
195 goto disable;
195 } 196 }
196 return initrd_end; 197 if (initrd_start < PAGE_OFFSET) {
198 printk(KERN_ERR "initrd start < PAGE_OFFSET\n");
199 goto disable;
200 }
201
202 /*
203 * Sanitize initrd addresses. For example firmware
204 * can't guess if they need to pass them through
205 * 64-bits values if the kernel has been built in pure
206 * 32-bit. We need also to switch from KSEG0 to XKPHYS
207 * addresses now, so the code can now safely use __pa().
208 */
209 end = __pa(initrd_end);
210 initrd_end = (unsigned long)__va(end);
211 initrd_start = (unsigned long)__va(__pa(initrd_start));
212
213 ROOT_DEV = Root_RAM0;
214 return PFN_UP(end);
215disable:
216 initrd_start = 0;
217 initrd_end = 0;
218 return 0;
197} 219}
198 220
199static void __init finalize_initrd(void) 221static void __init finalize_initrd(void)
@@ -204,12 +226,12 @@ static void __init finalize_initrd(void)
204 printk(KERN_INFO "Initrd not found or empty"); 226 printk(KERN_INFO "Initrd not found or empty");
205 goto disable; 227 goto disable;
206 } 228 }
207 if (CPHYSADDR(initrd_end) > PFN_PHYS(max_low_pfn)) { 229 if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) {
208 printk("Initrd extends beyond end of memory"); 230 printk("Initrd extends beyond end of memory");
209 goto disable; 231 goto disable;
210 } 232 }
211 233
212 reserve_bootmem(CPHYSADDR(initrd_start), size); 234 reserve_bootmem(__pa(initrd_start), size);
213 initrd_below_start_ok = 1; 235 initrd_below_start_ok = 1;
214 236
215 printk(KERN_INFO "Initial ramdisk at: 0x%lx (%lu bytes)\n", 237 printk(KERN_INFO "Initial ramdisk at: 0x%lx (%lu bytes)\n",
@@ -259,8 +281,7 @@ static void __init bootmem_init(void)
259 * not selected. Once that done we can determine the low bound 281 * not selected. Once that done we can determine the low bound
260 * of usable memory. 282 * of usable memory.
261 */ 283 */
262 reserved_end = init_initrd(); 284 reserved_end = max(init_initrd(), PFN_UP(__pa_symbol(&_end)));
263 reserved_end = PFN_UP(CPHYSADDR(max(reserved_end, (unsigned long)&_end)));
264 285
265 /* 286 /*
266 * Find the highest page frame number we have available. 287 * Find the highest page frame number we have available.
@@ -432,10 +453,10 @@ static void __init resource_init(void)
432 if (UNCAC_BASE != IO_BASE) 453 if (UNCAC_BASE != IO_BASE)
433 return; 454 return;
434 455
435 code_resource.start = virt_to_phys(&_text); 456 code_resource.start = __pa_symbol(&_text);
436 code_resource.end = virt_to_phys(&_etext) - 1; 457 code_resource.end = __pa_symbol(&_etext) - 1;
437 data_resource.start = virt_to_phys(&_etext); 458 data_resource.start = __pa_symbol(&_etext);
438 data_resource.end = virt_to_phys(&_edata) - 1; 459 data_resource.end = __pa_symbol(&_edata) - 1;
439 460
440 /* 461 /*
441 * Request address space for all standard RAM. 462 * Request address space for all standard RAM.
diff --git a/arch/mips/kernel/signal_n32.c b/arch/mips/kernel/signal_n32.c
index 477c5334ec1b..a67c18555ed3 100644
--- a/arch/mips/kernel/signal_n32.c
+++ b/arch/mips/kernel/signal_n32.c
@@ -17,7 +17,6 @@
17 */ 17 */
18#include <linux/cache.h> 18#include <linux/cache.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/sched.h>
21#include <linux/mm.h> 20#include <linux/mm.h>
22#include <linux/smp.h> 21#include <linux/smp.h>
23#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c
index 2ac19a6cbf68..1ee689c0e0c9 100644
--- a/arch/mips/kernel/smp-mt.c
+++ b/arch/mips/kernel/smp-mt.c
@@ -278,7 +278,9 @@ void __init plat_prepare_cpus(unsigned int max_cpus)
278 278
279 /* need to mark IPI's as IRQ_PER_CPU */ 279 /* need to mark IPI's as IRQ_PER_CPU */
280 irq_desc[cpu_ipi_resched_irq].status |= IRQ_PER_CPU; 280 irq_desc[cpu_ipi_resched_irq].status |= IRQ_PER_CPU;
281 set_irq_handler(cpu_ipi_resched_irq, handle_percpu_irq);
281 irq_desc[cpu_ipi_call_irq].status |= IRQ_PER_CPU; 282 irq_desc[cpu_ipi_call_irq].status |= IRQ_PER_CPU;
283 set_irq_handler(cpu_ipi_call_irq, handle_percpu_irq);
282} 284}
283 285
284/* 286/*
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index db80957ada89..49db516789e0 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -463,28 +463,5 @@ void flush_tlb_one(unsigned long vaddr)
463 smp_on_each_tlb(flush_tlb_one_ipi, (void *) vaddr); 463 smp_on_each_tlb(flush_tlb_one_ipi, (void *) vaddr);
464} 464}
465 465
466static DEFINE_PER_CPU(struct cpu, cpu_devices);
467
468static int __init topology_init(void)
469{
470 int i, ret;
471
472#ifdef CONFIG_NUMA
473 for_each_online_node(i)
474 register_one_node(i);
475#endif /* CONFIG_NUMA */
476
477 for_each_present_cpu(i) {
478 ret = register_cpu(&per_cpu(cpu_devices, i), i);
479 if (ret)
480 printk(KERN_WARNING "topology_init: register_cpu %d "
481 "failed (%d)\n", i, ret);
482 }
483
484 return 0;
485}
486
487subsys_initcall(topology_init);
488
489EXPORT_SYMBOL(flush_tlb_page); 466EXPORT_SYMBOL(flush_tlb_page);
490EXPORT_SYMBOL(flush_tlb_one); 467EXPORT_SYMBOL(flush_tlb_one);
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 3b78caf112f5..802febed7df5 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -1009,6 +1009,7 @@ void setup_cross_vpe_interrupts(void)
1009 setup_irq_smtc(cpu_ipi_irq, &irq_ipi, (0x100 << MIPS_CPU_IPI_IRQ)); 1009 setup_irq_smtc(cpu_ipi_irq, &irq_ipi, (0x100 << MIPS_CPU_IPI_IRQ));
1010 1010
1011 irq_desc[cpu_ipi_irq].status |= IRQ_PER_CPU; 1011 irq_desc[cpu_ipi_irq].status |= IRQ_PER_CPU;
1012 set_irq_handler(cpu_ipi_irq, handle_percpu_irq);
1012} 1013}
1013 1014
1014/* 1015/*
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index e535f86efa2f..11aab6d6bfe5 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -11,7 +11,6 @@
11 * Free Software Foundation; either version 2 of the License, or (at your 11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version. 12 * option) any later version.
13 */ 13 */
14#include <linux/clocksource.h>
15#include <linux/types.h> 14#include <linux/types.h>
16#include <linux/kernel.h> 15#include <linux/kernel.h>
17#include <linux/init.h> 16#include <linux/init.h>
@@ -83,17 +82,11 @@ static void null_timer_ack(void) { /* nothing */ }
83/* 82/*
84 * Null high precision timer functions for systems lacking one. 83 * Null high precision timer functions for systems lacking one.
85 */ 84 */
86static unsigned int null_hpt_read(void) 85static cycle_t null_hpt_read(void)
87{ 86{
88 return 0; 87 return 0;
89} 88}
90 89
91static void __init null_hpt_init(void)
92{
93 /* nothing */
94}
95
96
97/* 90/*
98 * Timer ack for an R4k-compatible timer of a known frequency. 91 * Timer ack for an R4k-compatible timer of a known frequency.
99 */ 92 */
@@ -118,7 +111,7 @@ static void c0_timer_ack(void)
118/* 111/*
119 * High precision timer functions for a R4k-compatible timer. 112 * High precision timer functions for a R4k-compatible timer.
120 */ 113 */
121static unsigned int c0_hpt_read(void) 114static cycle_t c0_hpt_read(void)
122{ 115{
123 return read_c0_count(); 116 return read_c0_count();
124} 117}
@@ -132,9 +125,6 @@ static void __init c0_hpt_timer_init(void)
132 125
133int (*mips_timer_state)(void); 126int (*mips_timer_state)(void);
134void (*mips_timer_ack)(void); 127void (*mips_timer_ack)(void);
135unsigned int (*mips_hpt_read)(void);
136void (*mips_hpt_init)(void) __initdata = null_hpt_init;
137unsigned int mips_hpt_mask = 0xffffffff;
138 128
139/* last time when xtime and rtc are sync'ed up */ 129/* last time when xtime and rtc are sync'ed up */
140static long last_rtc_update; 130static long last_rtc_update;
@@ -276,8 +266,7 @@ static struct irqaction timer_irqaction = {
276 266
277static unsigned int __init calibrate_hpt(void) 267static unsigned int __init calibrate_hpt(void)
278{ 268{
279 u64 frequency; 269 cycle_t frequency, hpt_start, hpt_end, hpt_count, hz;
280 u32 hpt_start, hpt_end, hpt_count, hz;
281 270
282 const int loops = HZ / 10; 271 const int loops = HZ / 10;
283 int log_2_loops = 0; 272 int log_2_loops = 0;
@@ -303,28 +292,23 @@ static unsigned int __init calibrate_hpt(void)
303 * during the calculated number of periods between timer 292 * during the calculated number of periods between timer
304 * interrupts. 293 * interrupts.
305 */ 294 */
306 hpt_start = mips_hpt_read(); 295 hpt_start = clocksource_mips.read();
307 do { 296 do {
308 while (mips_timer_state()); 297 while (mips_timer_state());
309 while (!mips_timer_state()); 298 while (!mips_timer_state());
310 } while (--i); 299 } while (--i);
311 hpt_end = mips_hpt_read(); 300 hpt_end = clocksource_mips.read();
312 301
313 hpt_count = (hpt_end - hpt_start) & mips_hpt_mask; 302 hpt_count = (hpt_end - hpt_start) & clocksource_mips.mask;
314 hz = HZ; 303 hz = HZ;
315 frequency = (u64)hpt_count * (u64)hz; 304 frequency = hpt_count * hz;
316 305
317 return frequency >> log_2_loops; 306 return frequency >> log_2_loops;
318} 307}
319 308
320static cycle_t read_mips_hpt(void) 309struct clocksource clocksource_mips = {
321{
322 return (cycle_t)mips_hpt_read();
323}
324
325static struct clocksource clocksource_mips = {
326 .name = "MIPS", 310 .name = "MIPS",
327 .read = read_mips_hpt, 311 .mask = 0xffffffff,
328 .is_continuous = 1, 312 .is_continuous = 1,
329}; 313};
330 314
@@ -333,7 +317,7 @@ static void __init init_mips_clocksource(void)
333 u64 temp; 317 u64 temp;
334 u32 shift; 318 u32 shift;
335 319
336 if (!mips_hpt_frequency || mips_hpt_read == null_hpt_read) 320 if (!mips_hpt_frequency || clocksource_mips.read == null_hpt_read)
337 return; 321 return;
338 322
339 /* Calclate a somewhat reasonable rating value */ 323 /* Calclate a somewhat reasonable rating value */
@@ -347,7 +331,6 @@ static void __init init_mips_clocksource(void)
347 } 331 }
348 clocksource_mips.shift = shift; 332 clocksource_mips.shift = shift;
349 clocksource_mips.mult = (u32)temp; 333 clocksource_mips.mult = (u32)temp;
350 clocksource_mips.mask = mips_hpt_mask;
351 334
352 clocksource_register(&clocksource_mips); 335 clocksource_register(&clocksource_mips);
353} 336}
@@ -367,32 +350,36 @@ void __init time_init(void)
367 -xtime.tv_sec, -xtime.tv_nsec); 350 -xtime.tv_sec, -xtime.tv_nsec);
368 351
369 /* Choose appropriate high precision timer routines. */ 352 /* Choose appropriate high precision timer routines. */
370 if (!cpu_has_counter && !mips_hpt_read) 353 if (!cpu_has_counter && !clocksource_mips.read)
371 /* No high precision timer -- sorry. */ 354 /* No high precision timer -- sorry. */
372 mips_hpt_read = null_hpt_read; 355 clocksource_mips.read = null_hpt_read;
373 else if (!mips_hpt_frequency && !mips_timer_state) { 356 else if (!mips_hpt_frequency && !mips_timer_state) {
374 /* A high precision timer of unknown frequency. */ 357 /* A high precision timer of unknown frequency. */
375 if (!mips_hpt_read) 358 if (!clocksource_mips.read)
376 /* No external high precision timer -- use R4k. */ 359 /* No external high precision timer -- use R4k. */
377 mips_hpt_read = c0_hpt_read; 360 clocksource_mips.read = c0_hpt_read;
378 } else { 361 } else {
379 /* We know counter frequency. Or we can get it. */ 362 /* We know counter frequency. Or we can get it. */
380 if (!mips_hpt_read) { 363 if (!clocksource_mips.read) {
381 /* No external high precision timer -- use R4k. */ 364 /* No external high precision timer -- use R4k. */
382 mips_hpt_read = c0_hpt_read; 365 clocksource_mips.read = c0_hpt_read;
383 366
384 if (!mips_timer_state) { 367 if (!mips_timer_state) {
385 /* No external timer interrupt -- use R4k. */ 368 /* No external timer interrupt -- use R4k. */
386 mips_hpt_init = c0_hpt_timer_init;
387 mips_timer_ack = c0_timer_ack; 369 mips_timer_ack = c0_timer_ack;
370 /* Calculate cache parameters. */
371 cycles_per_jiffy =
372 (mips_hpt_frequency + HZ / 2) / HZ;
373 /*
374 * This sets up the high precision
375 * timer for the first interrupt.
376 */
377 c0_hpt_timer_init();
388 } 378 }
389 } 379 }
390 if (!mips_hpt_frequency) 380 if (!mips_hpt_frequency)
391 mips_hpt_frequency = calibrate_hpt(); 381 mips_hpt_frequency = calibrate_hpt();
392 382
393 /* Calculate cache parameters. */
394 cycles_per_jiffy = (mips_hpt_frequency + HZ / 2) / HZ;
395
396 /* Report the high precision timer rate for a reference. */ 383 /* Report the high precision timer rate for a reference. */
397 printk("Using %u.%03u MHz high precision timer.\n", 384 printk("Using %u.%03u MHz high precision timer.\n",
398 ((mips_hpt_frequency + 500) / 1000) / 1000, 385 ((mips_hpt_frequency + 500) / 1000) / 1000,
@@ -403,9 +390,6 @@ void __init time_init(void)
403 /* No timer interrupt ack (e.g. i8254). */ 390 /* No timer interrupt ack (e.g. i8254). */
404 mips_timer_ack = null_timer_ack; 391 mips_timer_ack = null_timer_ack;
405 392
406 /* This sets up the high precision timer for the first interrupt. */
407 mips_hpt_init();
408
409 /* 393 /*
410 * Call board specific timer interrupt setup. 394 * Call board specific timer interrupt setup.
411 * 395 *
diff --git a/arch/mips/kernel/topology.c b/arch/mips/kernel/topology.c
new file mode 100644
index 000000000000..660e44ed44d7
--- /dev/null
+++ b/arch/mips/kernel/topology.c
@@ -0,0 +1,29 @@
1#include <linux/cpu.h>
2#include <linux/cpumask.h>
3#include <linux/init.h>
4#include <linux/node.h>
5#include <linux/nodemask.h>
6#include <linux/percpu.h>
7
8static DEFINE_PER_CPU(struct cpu, cpu_devices);
9
10static int __init topology_init(void)
11{
12 int i, ret;
13
14#ifdef CONFIG_NUMA
15 for_each_online_node(i)
16 register_one_node(i);
17#endif /* CONFIG_NUMA */
18
19 for_each_present_cpu(i) {
20 ret = register_cpu(&per_cpu(cpu_devices, i), i);
21 if (ret)
22 printk(KERN_WARNING "topology_init: register_cpu %d "
23 "failed (%d)\n", i, ret);
24 }
25
26 return 0;
27}
28
29subsys_initcall(topology_init);
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 9fda1b8be3a7..2a932cada244 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -54,6 +54,8 @@ extern asmlinkage void handle_dbe(void);
54extern asmlinkage void handle_sys(void); 54extern asmlinkage void handle_sys(void);
55extern asmlinkage void handle_bp(void); 55extern asmlinkage void handle_bp(void);
56extern asmlinkage void handle_ri(void); 56extern asmlinkage void handle_ri(void);
57extern asmlinkage void handle_ri_rdhwr_vivt(void);
58extern asmlinkage void handle_ri_rdhwr(void);
57extern asmlinkage void handle_cpu(void); 59extern asmlinkage void handle_cpu(void);
58extern asmlinkage void handle_ov(void); 60extern asmlinkage void handle_ov(void);
59extern asmlinkage void handle_tr(void); 61extern asmlinkage void handle_tr(void);
@@ -397,19 +399,6 @@ asmlinkage void do_be(struct pt_regs *regs)
397 force_sig(SIGBUS, current); 399 force_sig(SIGBUS, current);
398} 400}
399 401
400static inline int get_insn_opcode(struct pt_regs *regs, unsigned int *opcode)
401{
402 unsigned int __user *epc;
403
404 epc = (unsigned int __user *) regs->cp0_epc +
405 ((regs->cp0_cause & CAUSEF_BD) != 0);
406 if (!get_user(*opcode, epc))
407 return 0;
408
409 force_sig(SIGSEGV, current);
410 return 1;
411}
412
413/* 402/*
414 * ll/sc emulation 403 * ll/sc emulation
415 */ 404 */
@@ -544,8 +533,8 @@ static inline int simulate_llsc(struct pt_regs *regs)
544{ 533{
545 unsigned int opcode; 534 unsigned int opcode;
546 535
547 if (unlikely(get_insn_opcode(regs, &opcode))) 536 if (get_user(opcode, (unsigned int __user *) exception_epc(regs)))
548 return -EFAULT; 537 goto out_sigsegv;
549 538
550 if ((opcode & OPCODE) == LL) { 539 if ((opcode & OPCODE) == LL) {
551 simulate_ll(regs, opcode); 540 simulate_ll(regs, opcode);
@@ -557,6 +546,10 @@ static inline int simulate_llsc(struct pt_regs *regs)
557 } 546 }
558 547
559 return -EFAULT; /* Strange things going on ... */ 548 return -EFAULT; /* Strange things going on ... */
549
550out_sigsegv:
551 force_sig(SIGSEGV, current);
552 return -EFAULT;
560} 553}
561 554
562/* 555/*
@@ -569,8 +562,8 @@ static inline int simulate_rdhwr(struct pt_regs *regs)
569 struct thread_info *ti = task_thread_info(current); 562 struct thread_info *ti = task_thread_info(current);
570 unsigned int opcode; 563 unsigned int opcode;
571 564
572 if (unlikely(get_insn_opcode(regs, &opcode))) 565 if (get_user(opcode, (unsigned int __user *) exception_epc(regs)))
573 return -EFAULT; 566 goto out_sigsegv;
574 567
575 if (unlikely(compute_return_epc(regs))) 568 if (unlikely(compute_return_epc(regs)))
576 return -EFAULT; 569 return -EFAULT;
@@ -589,6 +582,10 @@ static inline int simulate_rdhwr(struct pt_regs *regs)
589 582
590 /* Not ours. */ 583 /* Not ours. */
591 return -EFAULT; 584 return -EFAULT;
585
586out_sigsegv:
587 force_sig(SIGSEGV, current);
588 return -EFAULT;
592} 589}
593 590
594asmlinkage void do_ov(struct pt_regs *regs) 591asmlinkage void do_ov(struct pt_regs *regs)
@@ -672,10 +669,8 @@ asmlinkage void do_bp(struct pt_regs *regs)
672 unsigned int opcode, bcode; 669 unsigned int opcode, bcode;
673 siginfo_t info; 670 siginfo_t info;
674 671
675 die_if_kernel("Break instruction in kernel code", regs); 672 if (get_user(opcode, (unsigned int __user *) exception_epc(regs)))
676 673 goto out_sigsegv;
677 if (get_insn_opcode(regs, &opcode))
678 return;
679 674
680 /* 675 /*
681 * There is the ancient bug in the MIPS assemblers that the break 676 * There is the ancient bug in the MIPS assemblers that the break
@@ -696,6 +691,7 @@ asmlinkage void do_bp(struct pt_regs *regs)
696 switch (bcode) { 691 switch (bcode) {
697 case BRK_OVERFLOW << 10: 692 case BRK_OVERFLOW << 10:
698 case BRK_DIVZERO << 10: 693 case BRK_DIVZERO << 10:
694 die_if_kernel("Break instruction in kernel code", regs);
699 if (bcode == (BRK_DIVZERO << 10)) 695 if (bcode == (BRK_DIVZERO << 10))
700 info.si_code = FPE_INTDIV; 696 info.si_code = FPE_INTDIV;
701 else 697 else
@@ -705,9 +701,16 @@ asmlinkage void do_bp(struct pt_regs *regs)
705 info.si_addr = (void __user *) regs->cp0_epc; 701 info.si_addr = (void __user *) regs->cp0_epc;
706 force_sig_info(SIGFPE, &info, current); 702 force_sig_info(SIGFPE, &info, current);
707 break; 703 break;
704 case BRK_BUG:
705 die("Kernel bug detected", regs);
706 break;
708 default: 707 default:
708 die_if_kernel("Break instruction in kernel code", regs);
709 force_sig(SIGTRAP, current); 709 force_sig(SIGTRAP, current);
710 } 710 }
711
712out_sigsegv:
713 force_sig(SIGSEGV, current);
711} 714}
712 715
713asmlinkage void do_tr(struct pt_regs *regs) 716asmlinkage void do_tr(struct pt_regs *regs)
@@ -715,10 +718,8 @@ asmlinkage void do_tr(struct pt_regs *regs)
715 unsigned int opcode, tcode = 0; 718 unsigned int opcode, tcode = 0;
716 siginfo_t info; 719 siginfo_t info;
717 720
718 die_if_kernel("Trap instruction in kernel code", regs); 721 if (get_user(opcode, (unsigned int __user *) exception_epc(regs)))
719 722 goto out_sigsegv;
720 if (get_insn_opcode(regs, &opcode))
721 return;
722 723
723 /* Immediate versions don't provide a code. */ 724 /* Immediate versions don't provide a code. */
724 if (!(opcode & OPCODE)) 725 if (!(opcode & OPCODE))
@@ -733,6 +734,7 @@ asmlinkage void do_tr(struct pt_regs *regs)
733 switch (tcode) { 734 switch (tcode) {
734 case BRK_OVERFLOW: 735 case BRK_OVERFLOW:
735 case BRK_DIVZERO: 736 case BRK_DIVZERO:
737 die_if_kernel("Trap instruction in kernel code", regs);
736 if (tcode == BRK_DIVZERO) 738 if (tcode == BRK_DIVZERO)
737 info.si_code = FPE_INTDIV; 739 info.si_code = FPE_INTDIV;
738 else 740 else
@@ -742,9 +744,16 @@ asmlinkage void do_tr(struct pt_regs *regs)
742 info.si_addr = (void __user *) regs->cp0_epc; 744 info.si_addr = (void __user *) regs->cp0_epc;
743 force_sig_info(SIGFPE, &info, current); 745 force_sig_info(SIGFPE, &info, current);
744 break; 746 break;
747 case BRK_BUG:
748 die("Kernel bug detected", regs);
749 break;
745 default: 750 default:
751 die_if_kernel("Trap instruction in kernel code", regs);
746 force_sig(SIGTRAP, current); 752 force_sig(SIGTRAP, current);
747 } 753 }
754
755out_sigsegv:
756 force_sig(SIGSEGV, current);
748} 757}
749 758
750asmlinkage void do_ri(struct pt_regs *regs) 759asmlinkage void do_ri(struct pt_regs *regs)
@@ -1423,6 +1432,15 @@ void __init set_uncached_handler (unsigned long offset, void *addr, unsigned lon
1423 memcpy((void *)(uncached_ebase + offset), addr, size); 1432 memcpy((void *)(uncached_ebase + offset), addr, size);
1424} 1433}
1425 1434
1435static int __initdata rdhwr_noopt;
1436static int __init set_rdhwr_noopt(char *str)
1437{
1438 rdhwr_noopt = 1;
1439 return 1;
1440}
1441
1442__setup("rdhwr_noopt", set_rdhwr_noopt);
1443
1426void __init trap_init(void) 1444void __init trap_init(void)
1427{ 1445{
1428 extern char except_vec3_generic, except_vec3_r4000; 1446 extern char except_vec3_generic, except_vec3_r4000;
@@ -1502,7 +1520,9 @@ void __init trap_init(void)
1502 1520
1503 set_except_vector(8, handle_sys); 1521 set_except_vector(8, handle_sys);
1504 set_except_vector(9, handle_bp); 1522 set_except_vector(9, handle_bp);
1505 set_except_vector(10, handle_ri); 1523 set_except_vector(10, rdhwr_noopt ? handle_ri :
1524 (cpu_has_vtag_icache ?
1525 handle_ri_rdhwr_vivt : handle_ri_rdhwr));
1506 set_except_vector(11, handle_cpu); 1526 set_except_vector(11, handle_cpu);
1507 set_except_vector(12, handle_ov); 1527 set_except_vector(12, handle_ov);
1508 set_except_vector(13, handle_tr); 1528 set_except_vector(13, handle_tr);
diff --git a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c
index a144a002dcc4..4a84a7beac53 100644
--- a/arch/mips/lasat/interrupt.c
+++ b/arch/mips/lasat/interrupt.c
@@ -36,33 +36,14 @@ static volatile int lasat_int_mask_shift;
36 36
37void disable_lasat_irq(unsigned int irq_nr) 37void disable_lasat_irq(unsigned int irq_nr)
38{ 38{
39 unsigned long flags;
40
41 local_irq_save(flags);
42 *lasat_int_mask &= ~(1 << irq_nr) << lasat_int_mask_shift; 39 *lasat_int_mask &= ~(1 << irq_nr) << lasat_int_mask_shift;
43 local_irq_restore(flags);
44} 40}
45 41
46void enable_lasat_irq(unsigned int irq_nr) 42void enable_lasat_irq(unsigned int irq_nr)
47{ 43{
48 unsigned long flags;
49
50 local_irq_save(flags);
51 *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift; 44 *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift;
52 local_irq_restore(flags);
53} 45}
54 46
55static unsigned int startup_lasat_irq(unsigned int irq)
56{
57 enable_lasat_irq(irq);
58
59 return 0; /* never anything pending */
60}
61
62#define shutdown_lasat_irq disable_lasat_irq
63
64#define mask_and_ack_lasat_irq disable_lasat_irq
65
66static void end_lasat_irq(unsigned int irq) 47static void end_lasat_irq(unsigned int irq)
67{ 48{
68 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 49 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -71,11 +52,10 @@ static void end_lasat_irq(unsigned int irq)
71 52
72static struct irq_chip lasat_irq_type = { 53static struct irq_chip lasat_irq_type = {
73 .typename = "Lasat", 54 .typename = "Lasat",
74 .startup = startup_lasat_irq, 55 .ack = disable_lasat_irq,
75 .shutdown = shutdown_lasat_irq, 56 .mask = disable_lasat_irq,
76 .enable = enable_lasat_irq, 57 .mask_ack = disable_lasat_irq,
77 .disable = disable_lasat_irq, 58 .unmask = enable_lasat_irq,
78 .ack = mask_and_ack_lasat_irq,
79 .end = end_lasat_irq, 59 .end = end_lasat_irq,
80}; 60};
81 61
@@ -152,10 +132,6 @@ void __init arch_init_irq(void)
152 panic("arch_init_irq: mips_machtype incorrect"); 132 panic("arch_init_irq: mips_machtype incorrect");
153 } 133 }
154 134
155 for (i = 0; i <= LASATINT_END; i++) { 135 for (i = 0; i <= LASATINT_END; i++)
156 irq_desc[i].status = IRQ_DISABLED; 136 set_irq_chip_and_handler(i, &lasat_irq_type, handle_level_irq);
157 irq_desc[i].action = 0;
158 irq_desc[i].depth = 1;
159 irq_desc[i].chip = &lasat_irq_type;
160 }
161} 137}
diff --git a/arch/mips/lib/csum_partial_copy.c b/arch/mips/lib/csum_partial_copy.c
index 6e9f366f961d..1720f2ceeeae 100644
--- a/arch/mips/lib/csum_partial_copy.c
+++ b/arch/mips/lib/csum_partial_copy.c
@@ -16,8 +16,8 @@
16/* 16/*
17 * copy while checksumming, otherwise like csum_partial 17 * copy while checksumming, otherwise like csum_partial
18 */ 18 */
19unsigned int csum_partial_copy_nocheck(const unsigned char *src, 19__wsum csum_partial_copy_nocheck(const void *src,
20 unsigned char *dst, int len, unsigned int sum) 20 void *dst, int len, __wsum sum)
21{ 21{
22 /* 22 /*
23 * It's 2:30 am and I don't feel like doing it real ... 23 * It's 2:30 am and I don't feel like doing it real ...
@@ -33,8 +33,8 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src,
33 * Copy from userspace and compute checksum. If we catch an exception 33 * Copy from userspace and compute checksum. If we catch an exception
34 * then zero the rest of the buffer. 34 * then zero the rest of the buffer.
35 */ 35 */
36unsigned int csum_partial_copy_from_user (const unsigned char __user *src, 36__wsum csum_partial_copy_from_user (const void __user *src,
37 unsigned char *dst, int len, unsigned int sum, int *err_ptr) 37 void *dst, int len, __wsum sum, int *err_ptr)
38{ 38{
39 int missing; 39 int missing;
40 40
diff --git a/arch/mips/mips-boards/atlas/atlas_int.c b/arch/mips/mips-boards/atlas/atlas_int.c
index be624b8c3b0e..43dba6ce6603 100644
--- a/arch/mips/mips-boards/atlas/atlas_int.c
+++ b/arch/mips/mips-boards/atlas/atlas_int.c
@@ -62,16 +62,6 @@ void enable_atlas_irq(unsigned int irq_nr)
62 iob(); 62 iob();
63} 63}
64 64
65static unsigned int startup_atlas_irq(unsigned int irq)
66{
67 enable_atlas_irq(irq);
68 return 0; /* never anything pending */
69}
70
71#define shutdown_atlas_irq disable_atlas_irq
72
73#define mask_and_ack_atlas_irq disable_atlas_irq
74
75static void end_atlas_irq(unsigned int irq) 65static void end_atlas_irq(unsigned int irq)
76{ 66{
77 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 67 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -80,11 +70,11 @@ static void end_atlas_irq(unsigned int irq)
80 70
81static struct irq_chip atlas_irq_type = { 71static struct irq_chip atlas_irq_type = {
82 .typename = "Atlas", 72 .typename = "Atlas",
83 .startup = startup_atlas_irq, 73 .ack = disable_atlas_irq,
84 .shutdown = shutdown_atlas_irq, 74 .mask = disable_atlas_irq,
85 .enable = enable_atlas_irq, 75 .mask_ack = disable_atlas_irq,
86 .disable = disable_atlas_irq, 76 .unmask = enable_atlas_irq,
87 .ack = mask_and_ack_atlas_irq, 77 .eoi = enable_atlas_irq,
88 .end = end_atlas_irq, 78 .end = end_atlas_irq,
89}; 79};
90 80
@@ -217,13 +207,8 @@ static inline void init_atlas_irqs (int base)
217 */ 207 */
218 atlas_hw0_icregs->intrsten = 0xffffffff; 208 atlas_hw0_icregs->intrsten = 0xffffffff;
219 209
220 for (i = ATLAS_INT_BASE; i <= ATLAS_INT_END; i++) { 210 for (i = ATLAS_INT_BASE; i <= ATLAS_INT_END; i++)
221 irq_desc[i].status = IRQ_DISABLED; 211 set_irq_chip_and_handler(i, &atlas_irq_type, handle_level_irq);
222 irq_desc[i].action = 0;
223 irq_desc[i].depth = 1;
224 irq_desc[i].chip = &atlas_irq_type;
225 spin_lock_init(&irq_desc[i].lock);
226 }
227} 212}
228 213
229static struct irqaction atlasirq = { 214static struct irqaction atlasirq = {
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index d817c60c5ca5..e4604c73f02e 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -288,6 +288,7 @@ void __init plat_timer_setup(struct irqaction *irq)
288 The effect is that the int remains disabled on the second cpu. 288 The effect is that the int remains disabled on the second cpu.
289 Mark the interrupt with IRQ_PER_CPU to avoid any confusion */ 289 Mark the interrupt with IRQ_PER_CPU to avoid any confusion */
290 irq_desc[mips_cpu_timer_irq].status |= IRQ_PER_CPU; 290 irq_desc[mips_cpu_timer_irq].status |= IRQ_PER_CPU;
291 set_irq_handler(mips_cpu_timer_irq, handle_percpu_irq);
291#endif 292#endif
292 293
293 /* to generate the first timer interrupt */ 294 /* to generate the first timer interrupt */
diff --git a/arch/mips/mips-boards/malta/malta_setup.c b/arch/mips/mips-boards/malta/malta_setup.c
index ab460f805bef..282f3e52eea3 100644
--- a/arch/mips/mips-boards/malta/malta_setup.c
+++ b/arch/mips/mips-boards/malta/malta_setup.c
@@ -159,7 +159,7 @@ void __init plat_mem_setup(void)
159 BONITO_PCIMEMBASECFG |= 159 BONITO_PCIMEMBASECFG |=
160 (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED | 160 (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |
161 BONITO_PCIMEMBASECFG_MEMBASE1_CACHED); 161 BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);
162 printk("Disabled Bonito IOBC coherency\n"); 162 printk("Enabled Bonito IOBC coherency\n");
163 } 163 }
164 } 164 }
165 else 165 else
diff --git a/arch/mips/mips-boards/sim/sim_time.c b/arch/mips/mips-boards/sim/sim_time.c
index 24a4ed00cc0a..30711d016fed 100644
--- a/arch/mips/mips-boards/sim/sim_time.c
+++ b/arch/mips/mips-boards/sim/sim_time.c
@@ -3,31 +3,24 @@
3#include <linux/kernel_stat.h> 3#include <linux/kernel_stat.h>
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/spinlock.h> 5#include <linux/spinlock.h>
6
7#include <asm/mipsregs.h>
8#include <asm/ptrace.h>
9#include <asm/hardirq.h>
10#include <asm/div64.h>
11#include <asm/cpu.h>
12#include <asm/time.h>
13
14#include <linux/interrupt.h> 6#include <linux/interrupt.h>
15#include <linux/mc146818rtc.h> 7#include <linux/mc146818rtc.h>
16#include <linux/timex.h> 8#include <linux/timex.h>
9
17#include <asm/mipsregs.h> 10#include <asm/mipsregs.h>
11#include <asm/ptrace.h>
18#include <asm/hardirq.h> 12#include <asm/hardirq.h>
19#include <asm/irq.h>
20#include <asm/div64.h> 13#include <asm/div64.h>
21#include <asm/cpu.h> 14#include <asm/cpu.h>
22#include <asm/time.h> 15#include <asm/time.h>
16#include <asm/irq.h>
23#include <asm/mc146818-time.h> 17#include <asm/mc146818-time.h>
24#include <asm/msc01_ic.h> 18#include <asm/msc01_ic.h>
19#include <asm/smp.h>
25 20
26#include <asm/mips-boards/generic.h> 21#include <asm/mips-boards/generic.h>
27#include <asm/mips-boards/prom.h> 22#include <asm/mips-boards/prom.h>
28#include <asm/mips-boards/simint.h> 23#include <asm/mips-boards/simint.h>
29#include <asm/mc146818-time.h>
30#include <asm/smp.h>
31 24
32 25
33unsigned long cpu_khz; 26unsigned long cpu_khz;
@@ -203,7 +196,8 @@ void __init plat_timer_setup(struct irqaction *irq)
203 on seperate cpu's the first one tries to handle the second interrupt. 196 on seperate cpu's the first one tries to handle the second interrupt.
204 The effect is that the int remains disabled on the second cpu. 197 The effect is that the int remains disabled on the second cpu.
205 Mark the interrupt with IRQ_PER_CPU to avoid any confusion */ 198 Mark the interrupt with IRQ_PER_CPU to avoid any confusion */
206 irq_desc[mips_cpu_timer_irq].status |= IRQ_PER_CPU; 199 irq_desc[mips_cpu_timer_irq].flags |= IRQ_PER_CPU;
200 set_irq_handler(mips_cpu_timer_irq, handle_percpu_irq);
207#endif 201#endif
208 202
209 /* to generate the first timer interrupt */ 203 /* to generate the first timer interrupt */
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index cc895dad71d2..df04a315d830 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -323,7 +323,6 @@ static void __init r4k_blast_scache_setup(void)
323static inline void local_r4k_flush_cache_all(void * args) 323static inline void local_r4k_flush_cache_all(void * args)
324{ 324{
325 r4k_blast_dcache(); 325 r4k_blast_dcache();
326 r4k_blast_icache();
327} 326}
328 327
329static void r4k_flush_cache_all(void) 328static void r4k_flush_cache_all(void)
@@ -359,21 +358,19 @@ static void r4k___flush_cache_all(void)
359static inline void local_r4k_flush_cache_range(void * args) 358static inline void local_r4k_flush_cache_range(void * args)
360{ 359{
361 struct vm_area_struct *vma = args; 360 struct vm_area_struct *vma = args;
362 int exec;
363 361
364 if (!(cpu_context(smp_processor_id(), vma->vm_mm))) 362 if (!(cpu_context(smp_processor_id(), vma->vm_mm)))
365 return; 363 return;
366 364
367 exec = vma->vm_flags & VM_EXEC; 365 r4k_blast_dcache();
368 if (cpu_has_dc_aliases || exec)
369 r4k_blast_dcache();
370 if (exec)
371 r4k_blast_icache();
372} 366}
373 367
374static void r4k_flush_cache_range(struct vm_area_struct *vma, 368static void r4k_flush_cache_range(struct vm_area_struct *vma,
375 unsigned long start, unsigned long end) 369 unsigned long start, unsigned long end)
376{ 370{
371 if (!cpu_has_dc_aliases)
372 return;
373
377 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1); 374 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
378} 375}
379 376
@@ -384,18 +381,21 @@ static inline void local_r4k_flush_cache_mm(void * args)
384 if (!cpu_context(smp_processor_id(), mm)) 381 if (!cpu_context(smp_processor_id(), mm))
385 return; 382 return;
386 383
387 r4k_blast_dcache();
388 r4k_blast_icache();
389
390 /* 384 /*
391 * Kludge alert. For obscure reasons R4000SC and R4400SC go nuts if we 385 * Kludge alert. For obscure reasons R4000SC and R4400SC go nuts if we
392 * only flush the primary caches but R10000 and R12000 behave sane ... 386 * only flush the primary caches but R10000 and R12000 behave sane ...
387 * R4000SC and R4400SC indexed S-cache ops also invalidate primary
388 * caches, so we can bail out early.
393 */ 389 */
394 if (current_cpu_data.cputype == CPU_R4000SC || 390 if (current_cpu_data.cputype == CPU_R4000SC ||
395 current_cpu_data.cputype == CPU_R4000MC || 391 current_cpu_data.cputype == CPU_R4000MC ||
396 current_cpu_data.cputype == CPU_R4400SC || 392 current_cpu_data.cputype == CPU_R4400SC ||
397 current_cpu_data.cputype == CPU_R4400MC) 393 current_cpu_data.cputype == CPU_R4400MC) {
398 r4k_blast_scache(); 394 r4k_blast_scache();
395 return;
396 }
397
398 r4k_blast_dcache();
399} 399}
400 400
401static void r4k_flush_cache_mm(struct mm_struct *mm) 401static void r4k_flush_cache_mm(struct mm_struct *mm)
diff --git a/arch/mips/mm/c-sb1.c b/arch/mips/mm/c-sb1.c
index d0ddb4a768a5..3a8afd47feaa 100644
--- a/arch/mips/mm/c-sb1.c
+++ b/arch/mips/mm/c-sb1.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */ 20 */
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/hardirq.h>
22 23
23#include <asm/asm.h> 24#include <asm/asm.h>
24#include <asm/bootinfo.h> 25#include <asm/bootinfo.h>
@@ -242,6 +243,25 @@ void sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsign
242 __attribute__((alias("local_sb1_flush_cache_page"))); 243 __attribute__((alias("local_sb1_flush_cache_page")));
243#endif 244#endif
244 245
246#ifdef CONFIG_SMP
247static void sb1_flush_cache_data_page_ipi(void *info)
248{
249 unsigned long start = (unsigned long)info;
250
251 __sb1_writeback_inv_dcache_range(start, start + PAGE_SIZE);
252}
253
254static void sb1_flush_cache_data_page(unsigned long addr)
255{
256 if (in_atomic())
257 __sb1_writeback_inv_dcache_range(addr, addr + PAGE_SIZE);
258 else
259 on_each_cpu(sb1_flush_cache_data_page_ipi, (void *) addr, 1, 1);
260}
261#else
262void sb1_flush_cache_data_page(unsigned long)
263 __attribute__((alias("local_sb1_flush_cache_data_page")));
264#endif
245 265
246/* 266/*
247 * Invalidate all caches on this CPU 267 * Invalidate all caches on this CPU
@@ -481,7 +501,7 @@ void sb1_cache_init(void)
481 501
482 flush_cache_sigtramp = sb1_flush_cache_sigtramp; 502 flush_cache_sigtramp = sb1_flush_cache_sigtramp;
483 local_flush_data_cache_page = (void *) sb1_nop; 503 local_flush_data_cache_page = (void *) sb1_nop;
484 flush_data_cache_page = (void *) sb1_nop; 504 flush_data_cache_page = sb1_flush_cache_data_page;
485 505
486 /* Full flush */ 506 /* Full flush */
487 __flush_cache_all = sb1___flush_cache_all; 507 __flush_cache_all = sb1___flush_cache_all;
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 8423d8590779..6f90e7ef66ac 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -60,6 +60,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
60 */ 60 */
61 if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END)) 61 if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END))
62 goto vmalloc_fault; 62 goto vmalloc_fault;
63#ifdef MODULE_START
64 if (unlikely(address >= MODULE_START && address < MODULE_END))
65 goto vmalloc_fault;
66#endif
63 67
64 /* 68 /*
65 * If we're in an interrupt or have no user 69 * If we're in an interrupt or have no user
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 2de4d3c367a2..9e29ba9205f0 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -90,9 +90,9 @@ unsigned long setup_zero_pages(void)
90 if (!empty_zero_page) 90 if (!empty_zero_page)
91 panic("Oh boy, that early out of memory?"); 91 panic("Oh boy, that early out of memory?");
92 92
93 page = virt_to_page(empty_zero_page); 93 page = virt_to_page((void *)empty_zero_page);
94 split_page(page, order); 94 split_page(page, order);
95 while (page < virt_to_page(empty_zero_page + (PAGE_SIZE << order))) { 95 while (page < virt_to_page((void *)(empty_zero_page + (PAGE_SIZE << order)))) {
96 SetPageReserved(page); 96 SetPageReserved(page);
97 page++; 97 page++;
98 } 98 }
@@ -443,15 +443,18 @@ void __init mem_init(void)
443} 443}
444#endif /* !CONFIG_NEED_MULTIPLE_NODES */ 444#endif /* !CONFIG_NEED_MULTIPLE_NODES */
445 445
446void free_init_pages(char *what, unsigned long begin, unsigned long end) 446static void free_init_pages(char *what, unsigned long begin, unsigned long end)
447{ 447{
448 unsigned long addr; 448 unsigned long pfn;
449 449
450 for (addr = begin; addr < end; addr += PAGE_SIZE) { 450 for (pfn = PFN_UP(begin); pfn < PFN_DOWN(end); pfn++) {
451 ClearPageReserved(virt_to_page(addr)); 451 struct page *page = pfn_to_page(pfn);
452 init_page_count(virt_to_page(addr)); 452 void *addr = phys_to_virt(PFN_PHYS(pfn));
453 memset((void *)addr, 0xcc, PAGE_SIZE); 453
454 free_page(addr); 454 ClearPageReserved(page);
455 init_page_count(page);
456 memset(addr, POISON_FREE_INITMEM, PAGE_SIZE);
457 __free_page(page);
455 totalram_pages++; 458 totalram_pages++;
456 } 459 }
457 printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10); 460 printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
@@ -460,12 +463,9 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
460#ifdef CONFIG_BLK_DEV_INITRD 463#ifdef CONFIG_BLK_DEV_INITRD
461void free_initrd_mem(unsigned long start, unsigned long end) 464void free_initrd_mem(unsigned long start, unsigned long end)
462{ 465{
463#ifdef CONFIG_64BIT 466 free_init_pages("initrd memory",
464 /* Switch from KSEG0 to XKPHYS addresses */ 467 virt_to_phys((void *)start),
465 start = (unsigned long)phys_to_virt(CPHYSADDR(start)); 468 virt_to_phys((void *)end));
466 end = (unsigned long)phys_to_virt(CPHYSADDR(end));
467#endif
468 free_init_pages("initrd memory", start, end);
469} 469}
470#endif 470#endif
471 471
@@ -473,17 +473,13 @@ extern unsigned long prom_free_prom_memory(void);
473 473
474void free_initmem(void) 474void free_initmem(void)
475{ 475{
476 unsigned long start, end, freed; 476 unsigned long freed;
477 477
478 freed = prom_free_prom_memory(); 478 freed = prom_free_prom_memory();
479 if (freed) 479 if (freed)
480 printk(KERN_INFO "Freeing firmware memory: %ldk freed\n",freed); 480 printk(KERN_INFO "Freeing firmware memory: %ldk freed\n",freed);
481 481
482 start = (unsigned long)(&__init_begin); 482 free_init_pages("unused kernel memory",
483 end = (unsigned long)(&__init_end); 483 __pa_symbol(&__init_begin),
484#ifdef CONFIG_64BIT 484 __pa_symbol(&__init_end));
485 start = PAGE_OFFSET | CPHYSADDR(start);
486 end = PAGE_OFFSET | CPHYSADDR(end);
487#endif
488 free_init_pages("unused kernel memory", start, end);
489} 485}
diff --git a/arch/mips/mm/pgtable-64.c b/arch/mips/mm/pgtable-64.c
index 8d600d307d5d..c46eb651bf09 100644
--- a/arch/mips/mm/pgtable-64.c
+++ b/arch/mips/mm/pgtable-64.c
@@ -58,6 +58,9 @@ void __init pagetable_init(void)
58 58
59 /* Initialize the entire pgd. */ 59 /* Initialize the entire pgd. */
60 pgd_init((unsigned long)swapper_pg_dir); 60 pgd_init((unsigned long)swapper_pg_dir);
61#ifdef MODULE_START
62 pgd_init((unsigned long)module_pg_dir);
63#endif
61 pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table); 64 pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
62 65
63 pgd_base = swapper_pg_dir; 66 pgd_base = swapper_pg_dir;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index fec318a1c8c5..492c518e7ba5 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -423,6 +423,9 @@ enum label_id {
423 label_invalid, 423 label_invalid,
424 label_second_part, 424 label_second_part,
425 label_leave, 425 label_leave,
426#ifdef MODULE_START
427 label_module_alloc,
428#endif
426 label_vmalloc, 429 label_vmalloc,
427 label_vmalloc_done, 430 label_vmalloc_done,
428 label_tlbw_hazard, 431 label_tlbw_hazard,
@@ -455,6 +458,9 @@ static __init void build_label(struct label **lab, u32 *addr,
455 458
456L_LA(_second_part) 459L_LA(_second_part)
457L_LA(_leave) 460L_LA(_leave)
461#ifdef MODULE_START
462L_LA(_module_alloc)
463#endif
458L_LA(_vmalloc) 464L_LA(_vmalloc)
459L_LA(_vmalloc_done) 465L_LA(_vmalloc_done)
460L_LA(_tlbw_hazard) 466L_LA(_tlbw_hazard)
@@ -686,6 +692,13 @@ static void __init il_bgezl(u32 **p, struct reloc **r, unsigned int reg,
686 i_bgezl(p, reg, 0); 692 i_bgezl(p, reg, 0);
687} 693}
688 694
695static void __init __attribute__((unused))
696il_bgez(u32 **p, struct reloc **r, unsigned int reg, enum label_id l)
697{
698 r_mips_pc16(r, *p, l);
699 i_bgez(p, reg, 0);
700}
701
689/* The only general purpose registers allowed in TLB handlers. */ 702/* The only general purpose registers allowed in TLB handlers. */
690#define K0 26 703#define K0 26
691#define K1 27 704#define K1 27
@@ -970,7 +983,11 @@ build_get_pmde64(u32 **p, struct label **l, struct reloc **r,
970 * The vmalloc handling is not in the hotpath. 983 * The vmalloc handling is not in the hotpath.
971 */ 984 */
972 i_dmfc0(p, tmp, C0_BADVADDR); 985 i_dmfc0(p, tmp, C0_BADVADDR);
986#ifdef MODULE_START
987 il_bltz(p, r, tmp, label_module_alloc);
988#else
973 il_bltz(p, r, tmp, label_vmalloc); 989 il_bltz(p, r, tmp, label_vmalloc);
990#endif
974 /* No i_nop needed here, since the next insn doesn't touch TMP. */ 991 /* No i_nop needed here, since the next insn doesn't touch TMP. */
975 992
976#ifdef CONFIG_SMP 993#ifdef CONFIG_SMP
@@ -1023,8 +1040,46 @@ build_get_pgd_vmalloc64(u32 **p, struct label **l, struct reloc **r,
1023{ 1040{
1024 long swpd = (long)swapper_pg_dir; 1041 long swpd = (long)swapper_pg_dir;
1025 1042
1043#ifdef MODULE_START
1044 long modd = (long)module_pg_dir;
1045
1046 l_module_alloc(l, *p);
1047 /*
1048 * Assumption:
1049 * VMALLOC_START >= 0xc000000000000000UL
1050 * MODULE_START >= 0xe000000000000000UL
1051 */
1052 i_SLL(p, ptr, bvaddr, 2);
1053 il_bgez(p, r, ptr, label_vmalloc);
1054
1055 if (in_compat_space_p(MODULE_START) && !rel_lo(MODULE_START)) {
1056 i_lui(p, ptr, rel_hi(MODULE_START)); /* delay slot */
1057 } else {
1058 /* unlikely configuration */
1059 i_nop(p); /* delay slot */
1060 i_LA(p, ptr, MODULE_START);
1061 }
1062 i_dsubu(p, bvaddr, bvaddr, ptr);
1063
1064 if (in_compat_space_p(modd) && !rel_lo(modd)) {
1065 il_b(p, r, label_vmalloc_done);
1066 i_lui(p, ptr, rel_hi(modd));
1067 } else {
1068 i_LA_mostly(p, ptr, modd);
1069 il_b(p, r, label_vmalloc_done);
1070 i_daddiu(p, ptr, ptr, rel_lo(modd));
1071 }
1072
1073 l_vmalloc(l, *p);
1074 if (in_compat_space_p(MODULE_START) && !rel_lo(MODULE_START) &&
1075 MODULE_START << 32 == VMALLOC_START)
1076 i_dsll32(p, ptr, ptr, 0); /* typical case */
1077 else
1078 i_LA(p, ptr, VMALLOC_START);
1079#else
1026 l_vmalloc(l, *p); 1080 l_vmalloc(l, *p);
1027 i_LA(p, ptr, VMALLOC_START); 1081 i_LA(p, ptr, VMALLOC_START);
1082#endif
1028 i_dsubu(p, bvaddr, bvaddr, ptr); 1083 i_dsubu(p, bvaddr, bvaddr, ptr);
1029 1084
1030 if (in_compat_space_p(swpd) && !rel_lo(swpd)) { 1085 if (in_compat_space_p(swpd) && !rel_lo(swpd)) {
diff --git a/arch/mips/momentum/ocelot_c/cpci-irq.c b/arch/mips/momentum/ocelot_c/cpci-irq.c
index 47e3fa32b075..e5a4a0a8a7f0 100644
--- a/arch/mips/momentum/ocelot_c/cpci-irq.c
+++ b/arch/mips/momentum/ocelot_c/cpci-irq.c
@@ -66,39 +66,6 @@ static inline void unmask_cpci_irq(unsigned int irq)
66} 66}
67 67
68/* 68/*
69 * Enables the IRQ in the FPGA
70 */
71static void enable_cpci_irq(unsigned int irq)
72{
73 unmask_cpci_irq(irq);
74}
75
76/*
77 * Initialize the IRQ in the FPGA
78 */
79static unsigned int startup_cpci_irq(unsigned int irq)
80{
81 unmask_cpci_irq(irq);
82 return 0;
83}
84
85/*
86 * Disables the IRQ in the FPGA
87 */
88static void disable_cpci_irq(unsigned int irq)
89{
90 mask_cpci_irq(irq);
91}
92
93/*
94 * Masks and ACKs an IRQ
95 */
96static void mask_and_ack_cpci_irq(unsigned int irq)
97{
98 mask_cpci_irq(irq);
99}
100
101/*
102 * End IRQ processing 69 * End IRQ processing
103 */ 70 */
104static void end_cpci_irq(unsigned int irq) 71static void end_cpci_irq(unsigned int irq)
@@ -125,15 +92,12 @@ void ll_cpci_irq(void)
125 do_IRQ(ls1bit8(irq_src) + CPCI_IRQ_BASE); 92 do_IRQ(ls1bit8(irq_src) + CPCI_IRQ_BASE);
126} 93}
127 94
128#define shutdown_cpci_irq disable_cpci_irq
129
130struct irq_chip cpci_irq_type = { 95struct irq_chip cpci_irq_type = {
131 .typename = "CPCI/FPGA", 96 .typename = "CPCI/FPGA",
132 .startup = startup_cpci_irq, 97 .ack = mask_cpci_irq,
133 .shutdown = shutdown_cpci_irq, 98 .mask = mask_cpci_irq,
134 .enable = enable_cpci_irq, 99 .mask_ack = mask_cpci_irq,
135 .disable = disable_cpci_irq, 100 .unmask = unmask_cpci_irq,
136 .ack = mask_and_ack_cpci_irq,
137 .end = end_cpci_irq, 101 .end = end_cpci_irq,
138}; 102};
139 103
@@ -141,11 +105,6 @@ void cpci_irq_init(void)
141{ 105{
142 int i; 106 int i;
143 107
144 /* Reset irq handlers pointers to NULL */ 108 for (i = CPCI_IRQ_BASE; i < (CPCI_IRQ_BASE + 8); i++)
145 for (i = CPCI_IRQ_BASE; i < (CPCI_IRQ_BASE + 8); i++) { 109 set_irq_chip_and_handler(i, &cpci_irq_type, handle_level_irq);
146 irq_desc[i].status = IRQ_DISABLED;
147 irq_desc[i].action = 0;
148 irq_desc[i].depth = 2;
149 irq_desc[i].chip = &cpci_irq_type;
150 }
151} 110}
diff --git a/arch/mips/momentum/ocelot_c/uart-irq.c b/arch/mips/momentum/ocelot_c/uart-irq.c
index 510257dc205a..0029f0008dea 100644
--- a/arch/mips/momentum/ocelot_c/uart-irq.c
+++ b/arch/mips/momentum/ocelot_c/uart-irq.c
@@ -60,39 +60,6 @@ static inline void unmask_uart_irq(unsigned int irq)
60} 60}
61 61
62/* 62/*
63 * Enables the IRQ in the FPGA
64 */
65static void enable_uart_irq(unsigned int irq)
66{
67 unmask_uart_irq(irq);
68}
69
70/*
71 * Initialize the IRQ in the FPGA
72 */
73static unsigned int startup_uart_irq(unsigned int irq)
74{
75 unmask_uart_irq(irq);
76 return 0;
77}
78
79/*
80 * Disables the IRQ in the FPGA
81 */
82static void disable_uart_irq(unsigned int irq)
83{
84 mask_uart_irq(irq);
85}
86
87/*
88 * Masks and ACKs an IRQ
89 */
90static void mask_and_ack_uart_irq(unsigned int irq)
91{
92 mask_uart_irq(irq);
93}
94
95/*
96 * End IRQ processing 63 * End IRQ processing
97 */ 64 */
98static void end_uart_irq(unsigned int irq) 65static void end_uart_irq(unsigned int irq)
@@ -118,28 +85,17 @@ void ll_uart_irq(void)
118 do_IRQ(ls1bit8(irq_src) + 74); 85 do_IRQ(ls1bit8(irq_src) + 74);
119} 86}
120 87
121#define shutdown_uart_irq disable_uart_irq
122
123struct irq_chip uart_irq_type = { 88struct irq_chip uart_irq_type = {
124 .typename = "UART/FPGA", 89 .typename = "UART/FPGA",
125 .startup = startup_uart_irq, 90 .ack = mask_uart_irq,
126 .shutdown = shutdown_uart_irq, 91 .mask = mask_uart_irq,
127 .enable = enable_uart_irq, 92 .mask_ack = mask_uart_irq,
128 .disable = disable_uart_irq, 93 .unmask = unmask_uart_irq,
129 .ack = mask_and_ack_uart_irq,
130 .end = end_uart_irq, 94 .end = end_uart_irq,
131}; 95};
132 96
133void uart_irq_init(void) 97void uart_irq_init(void)
134{ 98{
135 /* Reset irq handlers pointers to NULL */ 99 set_irq_chip_and_handler(80, &uart_irq_type, handle_level_irq);
136 irq_desc[80].status = IRQ_DISABLED; 100 set_irq_chip_and_handler(81, &uart_irq_type, handle_level_irq);
137 irq_desc[80].action = 0;
138 irq_desc[80].depth = 2;
139 irq_desc[80].chip = &uart_irq_type;
140
141 irq_desc[81].status = IRQ_DISABLED;
142 irq_desc[81].action = 0;
143 irq_desc[81].depth = 2;
144 irq_desc[81].chip = &uart_irq_type;
145} 101}
diff --git a/arch/mips/oprofile/Makefile b/arch/mips/oprofile/Makefile
index 0a50aad5bbe4..bf3be6fcf7ff 100644
--- a/arch/mips/oprofile/Makefile
+++ b/arch/mips/oprofile/Makefile
@@ -12,5 +12,6 @@ oprofile-y := $(DRIVER_OBJS) common.o
12 12
13oprofile-$(CONFIG_CPU_MIPS32) += op_model_mipsxx.o 13oprofile-$(CONFIG_CPU_MIPS32) += op_model_mipsxx.o
14oprofile-$(CONFIG_CPU_MIPS64) += op_model_mipsxx.o 14oprofile-$(CONFIG_CPU_MIPS64) += op_model_mipsxx.o
15oprofile-$(CONFIG_CPU_R10000) += op_model_mipsxx.o
15oprofile-$(CONFIG_CPU_SB1) += op_model_mipsxx.o 16oprofile-$(CONFIG_CPU_SB1) += op_model_mipsxx.o
16oprofile-$(CONFIG_CPU_RM9000) += op_model_rm9000.o 17oprofile-$(CONFIG_CPU_RM9000) += op_model_rm9000.o
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index 65eb55400d77..4e0a90b3916b 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -83,6 +83,9 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
83 case CPU_74K: 83 case CPU_74K:
84 case CPU_SB1: 84 case CPU_SB1:
85 case CPU_SB1A: 85 case CPU_SB1A:
86 case CPU_R10000:
87 case CPU_R12000:
88 case CPU_R14000:
86 lmodel = &op_model_mipsxx_ops; 89 lmodel = &op_model_mipsxx_ops;
87 break; 90 break;
88 91
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index 1fb240c57bac..455d76ad06d8 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -18,7 +18,7 @@
18#define M_PERFCTL_SUPERVISOR (1UL << 2) 18#define M_PERFCTL_SUPERVISOR (1UL << 2)
19#define M_PERFCTL_USER (1UL << 3) 19#define M_PERFCTL_USER (1UL << 3)
20#define M_PERFCTL_INTERRUPT_ENABLE (1UL << 4) 20#define M_PERFCTL_INTERRUPT_ENABLE (1UL << 4)
21#define M_PERFCTL_EVENT(event) ((event) << 5) 21#define M_PERFCTL_EVENT(event) (((event) & 0x3f) << 5)
22#define M_PERFCTL_VPEID(vpe) ((vpe) << 16) 22#define M_PERFCTL_VPEID(vpe) ((vpe) << 16)
23#define M_PERFCTL_MT_EN(filter) ((filter) << 20) 23#define M_PERFCTL_MT_EN(filter) ((filter) << 20)
24#define M_TC_EN_ALL M_PERFCTL_MT_EN(0) 24#define M_TC_EN_ALL M_PERFCTL_MT_EN(0)
@@ -218,13 +218,23 @@ static inline int __n_counters(void)
218 218
219static inline int n_counters(void) 219static inline int n_counters(void)
220{ 220{
221 int counters = __n_counters(); 221 int counters;
222
223 switch (current_cpu_data.cputype) {
224 case CPU_R10000:
225 counters = 2;
226
227 case CPU_R12000:
228 case CPU_R14000:
229 counters = 4;
230
231 default:
232 counters = __n_counters();
233 }
222 234
223#ifdef CONFIG_MIPS_MT_SMP 235#ifdef CONFIG_MIPS_MT_SMP
224 if (current_cpu_data.cputype == CPU_34K) 236 counters >> 1;
225 return counters >> 1;
226#endif 237#endif
227
228 return counters; 238 return counters;
229} 239}
230 240
@@ -284,6 +294,18 @@ static int __init mipsxx_init(void)
284 op_model_mipsxx_ops.cpu_type = "mips/5K"; 294 op_model_mipsxx_ops.cpu_type = "mips/5K";
285 break; 295 break;
286 296
297 case CPU_R10000:
298 if ((current_cpu_data.processor_id & 0xff) == 0x20)
299 op_model_mipsxx_ops.cpu_type = "mips/r10000-v2.x";
300 else
301 op_model_mipsxx_ops.cpu_type = "mips/r10000";
302 break;
303
304 case CPU_R12000:
305 case CPU_R14000:
306 op_model_mipsxx_ops.cpu_type = "mips/r12000";
307 break;
308
287 case CPU_SB1: 309 case CPU_SB1:
288 case CPU_SB1A: 310 case CPU_SB1A:
289 op_model_mipsxx_ops.cpu_type = "mips/sb1"; 311 op_model_mipsxx_ops.cpu_type = "mips/sb1";
diff --git a/arch/mips/pci/fixup-cobalt.c b/arch/mips/pci/fixup-cobalt.c
index 75a01e764898..7d5f6bbf7a9d 100644
--- a/arch/mips/pci/fixup-cobalt.c
+++ b/arch/mips/pci/fixup-cobalt.c
@@ -94,22 +94,21 @@ static void qube_raq_galileo_fixup(struct pci_dev *dev)
94#if 0 94#if 0
95 if (galileo_id >= 0x10) { 95 if (galileo_id >= 0x10) {
96 /* New Galileo, assumes PCI stop line to VIA is connected. */ 96 /* New Galileo, assumes PCI stop line to VIA is connected. */
97 GALILEO_OUTL(0x4020, GT_PCI0_TOR_OFS); 97 GT_WRITE(GT_PCI0_TOR_OFS, 0x4020);
98 } else if (galileo_id == 0x1 || galileo_id == 0x2) 98 } else if (galileo_id == 0x1 || galileo_id == 0x2)
99#endif 99#endif
100 { 100 {
101 signed int timeo; 101 signed int timeo;
102 /* XXX WE MUST DO THIS ELSE GALILEO LOCKS UP! -DaveM */ 102 /* XXX WE MUST DO THIS ELSE GALILEO LOCKS UP! -DaveM */
103 timeo = GALILEO_INL(GT_PCI0_TOR_OFS); 103 timeo = GT_READ(GT_PCI0_TOR_OFS);
104 /* Old Galileo, assumes PCI STOP line to VIA is disconnected. */ 104 /* Old Galileo, assumes PCI STOP line to VIA is disconnected. */
105 GALILEO_OUTL( 105 GT_WRITE(GT_PCI0_TOR_OFS,
106 (0xff << 16) | /* retry count */ 106 (0xff << 16) | /* retry count */
107 (0xff << 8) | /* timeout 1 */ 107 (0xff << 8) | /* timeout 1 */
108 0xff, /* timeout 0 */ 108 0xff); /* timeout 0 */
109 GT_PCI0_TOR_OFS);
110 109
111 /* enable PCI retry exceeded interrupt */ 110 /* enable PCI retry exceeded interrupt */
112 GALILEO_OUTL(GALILEO_INTR_RETRY_CTR | GALILEO_INL(GT_INTRMASK_OFS), GT_INTRMASK_OFS); 111 GT_WRITE(GT_INTRMASK_OFS, GT_INTR_RETRYCTR0_MSK | GT_READ(GT_INTRMASK_OFS));
113 } 112 }
114} 113}
115 114
diff --git a/arch/mips/pci/ops-gt64111.c b/arch/mips/pci/ops-gt64111.c
index 13de45940b19..ecd3991bd0e4 100644
--- a/arch/mips/pci/ops-gt64111.c
+++ b/arch/mips/pci/ops-gt64111.c
@@ -38,18 +38,18 @@ static int gt64111_pci_read_config(struct pci_bus *bus, unsigned int devfn,
38 switch (size) { 38 switch (size) {
39 case 4: 39 case 4:
40 PCI_CFG_SET(devfn, where); 40 PCI_CFG_SET(devfn, where);
41 *val = GALILEO_INL(GT_PCI0_CFGDATA_OFS); 41 *val = GT_READ(GT_PCI0_CFGDATA_OFS);
42 return PCIBIOS_SUCCESSFUL; 42 return PCIBIOS_SUCCESSFUL;
43 43
44 case 2: 44 case 2:
45 PCI_CFG_SET(devfn, (where & ~0x3)); 45 PCI_CFG_SET(devfn, (where & ~0x3));
46 *val = GALILEO_INL(GT_PCI0_CFGDATA_OFS) 46 *val = GT_READ(GT_PCI0_CFGDATA_OFS)
47 >> ((where & 3) * 8); 47 >> ((where & 3) * 8);
48 return PCIBIOS_SUCCESSFUL; 48 return PCIBIOS_SUCCESSFUL;
49 49
50 case 1: 50 case 1:
51 PCI_CFG_SET(devfn, (where & ~0x3)); 51 PCI_CFG_SET(devfn, (where & ~0x3));
52 *val = GALILEO_INL(GT_PCI0_CFGDATA_OFS) 52 *val = GT_READ(GT_PCI0_CFGDATA_OFS)
53 >> ((where & 3) * 8); 53 >> ((where & 3) * 8);
54 return PCIBIOS_SUCCESSFUL; 54 return PCIBIOS_SUCCESSFUL;
55 } 55 }
@@ -68,25 +68,25 @@ static int gt64111_pci_write_config(struct pci_bus *bus, unsigned int devfn,
68 switch (size) { 68 switch (size) {
69 case 4: 69 case 4:
70 PCI_CFG_SET(devfn, where); 70 PCI_CFG_SET(devfn, where);
71 GALILEO_OUTL(val, GT_PCI0_CFGDATA_OFS); 71 GT_WRITE(GT_PCI0_CFGDATA_OFS, val);
72 72
73 return PCIBIOS_SUCCESSFUL; 73 return PCIBIOS_SUCCESSFUL;
74 74
75 case 2: 75 case 2:
76 PCI_CFG_SET(devfn, (where & ~0x3)); 76 PCI_CFG_SET(devfn, (where & ~0x3));
77 tmp = GALILEO_INL(GT_PCI0_CFGDATA_OFS); 77 tmp = GT_READ(GT_PCI0_CFGDATA_OFS);
78 tmp &= ~(0xffff << ((where & 0x3) * 8)); 78 tmp &= ~(0xffff << ((where & 0x3) * 8));
79 tmp |= (val << ((where & 0x3) * 8)); 79 tmp |= (val << ((where & 0x3) * 8));
80 GALILEO_OUTL(tmp, GT_PCI0_CFGDATA_OFS); 80 GT_WRITE(GT_PCI0_CFGDATA_OFS, tmp);
81 81
82 return PCIBIOS_SUCCESSFUL; 82 return PCIBIOS_SUCCESSFUL;
83 83
84 case 1: 84 case 1:
85 PCI_CFG_SET(devfn, (where & ~0x3)); 85 PCI_CFG_SET(devfn, (where & ~0x3));
86 tmp = GALILEO_INL(GT_PCI0_CFGDATA_OFS); 86 tmp = GT_READ(GT_PCI0_CFGDATA_OFS);
87 tmp &= ~(0xff << ((where & 0x3) * 8)); 87 tmp &= ~(0xff << ((where & 0x3) * 8));
88 tmp |= (val << ((where & 0x3) * 8)); 88 tmp |= (val << ((where & 0x3) * 8));
89 GALILEO_OUTL(tmp, GT_PCI0_CFGDATA_OFS); 89 GT_WRITE(GT_PCI0_CFGDATA_OFS, tmp);
90 90
91 return PCIBIOS_SUCCESSFUL; 91 return PCIBIOS_SUCCESSFUL;
92 } 92 }
diff --git a/arch/mips/philips/pnx8550/common/int.c b/arch/mips/philips/pnx8550/common/int.c
index 710611615ca2..0dc23930edbd 100644
--- a/arch/mips/philips/pnx8550/common/int.c
+++ b/arch/mips/philips/pnx8550/common/int.c
@@ -38,8 +38,6 @@
38#include <int.h> 38#include <int.h>
39#include <uart.h> 39#include <uart.h>
40 40
41static DEFINE_SPINLOCK(irq_lock);
42
43/* default prio for interrupts */ 41/* default prio for interrupts */
44/* first one is a no-no so therefore always prio 0 (disabled) */ 42/* first one is a no-no so therefore always prio 0 (disabled) */
45static char gic_prio[PNX8550_INT_GIC_TOTINT] = { 43static char gic_prio[PNX8550_INT_GIC_TOTINT] = {
@@ -149,38 +147,6 @@ static inline void unmask_irq(unsigned int irq_nr)
149 } 147 }
150} 148}
151 149
152#define pnx8550_disable pnx8550_ack
153static void pnx8550_ack(unsigned int irq)
154{
155 unsigned long flags;
156
157 spin_lock_irqsave(&irq_lock, flags);
158 mask_irq(irq);
159 spin_unlock_irqrestore(&irq_lock, flags);
160}
161
162#define pnx8550_enable pnx8550_unmask
163static void pnx8550_unmask(unsigned int irq)
164{
165 unsigned long flags;
166
167 spin_lock_irqsave(&irq_lock, flags);
168 unmask_irq(irq);
169 spin_unlock_irqrestore(&irq_lock, flags);
170}
171
172static unsigned int startup_irq(unsigned int irq_nr)
173{
174 pnx8550_unmask(irq_nr);
175 return 0;
176}
177
178static void shutdown_irq(unsigned int irq_nr)
179{
180 pnx8550_ack(irq_nr);
181 return;
182}
183
184int pnx8550_set_gic_priority(int irq, int priority) 150int pnx8550_set_gic_priority(int irq, int priority)
185{ 151{
186 int gic_irq = irq-PNX8550_INT_GIC_MIN; 152 int gic_irq = irq-PNX8550_INT_GIC_MIN;
@@ -192,26 +158,19 @@ int pnx8550_set_gic_priority(int irq, int priority)
192 return prev_priority; 158 return prev_priority;
193} 159}
194 160
195static inline void mask_and_ack_level_irq(unsigned int irq)
196{
197 pnx8550_disable(irq);
198 return;
199}
200
201static void end_irq(unsigned int irq) 161static void end_irq(unsigned int irq)
202{ 162{
203 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) { 163 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
204 pnx8550_enable(irq); 164 unmask_irq(irq);
205 } 165 }
206} 166}
207 167
208static struct irq_chip level_irq_type = { 168static struct irq_chip level_irq_type = {
209 .typename = "PNX Level IRQ", 169 .typename = "PNX Level IRQ",
210 .startup = startup_irq, 170 .ack = mask_irq,
211 .shutdown = shutdown_irq, 171 .mask = mask_irq,
212 .enable = pnx8550_enable, 172 .mask_ack = mask_irq,
213 .disable = pnx8550_disable, 173 .unmask = unmask_irq,
214 .ack = mask_and_ack_level_irq,
215 .end = end_irq, 174 .end = end_irq,
216}; 175};
217 176
@@ -233,8 +192,8 @@ void __init arch_init_irq(void)
233 int configPR; 192 int configPR;
234 193
235 for (i = 0; i < PNX8550_INT_CP0_TOTINT; i++) { 194 for (i = 0; i < PNX8550_INT_CP0_TOTINT; i++) {
236 irq_desc[i].chip = &level_irq_type; 195 set_irq_chip_and_handler(i, &level_irq_type, handle_level_irq);
237 pnx8550_ack(i); /* mask the irq just in case */ 196 mask_irq(i); /* mask the irq just in case */
238 } 197 }
239 198
240 /* init of GIC/IPC interrupts */ 199 /* init of GIC/IPC interrupts */
@@ -270,7 +229,7 @@ void __init arch_init_irq(void)
270 /* mask/priority is still 0 so we will not get any 229 /* mask/priority is still 0 so we will not get any
271 * interrupts until it is unmasked */ 230 * interrupts until it is unmasked */
272 231
273 irq_desc[i].chip = &level_irq_type; 232 set_irq_chip_and_handler(i, &level_irq_type, handle_level_irq);
274 } 233 }
275 234
276 /* Priority level 0 */ 235 /* Priority level 0 */
@@ -279,20 +238,21 @@ void __init arch_init_irq(void)
279 /* Set int vector table address */ 238 /* Set int vector table address */
280 PNX8550_GIC_VECTOR_0 = PNX8550_GIC_VECTOR_1 = 0; 239 PNX8550_GIC_VECTOR_0 = PNX8550_GIC_VECTOR_1 = 0;
281 240
282 irq_desc[MIPS_CPU_GIC_IRQ].chip = &level_irq_type; 241 set_irq_chip_and_handler(MIPS_CPU_GIC_IRQ, &level_irq_type,
242 handle_level_irq);
283 setup_irq(MIPS_CPU_GIC_IRQ, &gic_action); 243 setup_irq(MIPS_CPU_GIC_IRQ, &gic_action);
284 244
285 /* init of Timer interrupts */ 245 /* init of Timer interrupts */
286 for (i = PNX8550_INT_TIMER_MIN; i <= PNX8550_INT_TIMER_MAX; i++) { 246 for (i = PNX8550_INT_TIMER_MIN; i <= PNX8550_INT_TIMER_MAX; i++)
287 irq_desc[i].chip = &level_irq_type; 247 set_irq_chip_and_handler(i, &level_irq_type, handle_level_irq);
288 }
289 248
290 /* Stop Timer 1-3 */ 249 /* Stop Timer 1-3 */
291 configPR = read_c0_config7(); 250 configPR = read_c0_config7();
292 configPR |= 0x00000038; 251 configPR |= 0x00000038;
293 write_c0_config7(configPR); 252 write_c0_config7(configPR);
294 253
295 irq_desc[MIPS_CPU_TIMER_IRQ].chip = &level_irq_type; 254 set_irq_chip_and_handler(MIPS_CPU_TIMER_IRQ, &level_irq_type,
255 handle_level_irq);
296 setup_irq(MIPS_CPU_TIMER_IRQ, &timer_action); 256 setup_irq(MIPS_CPU_TIMER_IRQ, &timer_action);
297} 257}
298 258
diff --git a/arch/mips/pmc-sierra/yosemite/smp.c b/arch/mips/pmc-sierra/yosemite/smp.c
index 3cc0436db6cf..305491e74dbe 100644
--- a/arch/mips/pmc-sierra/yosemite/smp.c
+++ b/arch/mips/pmc-sierra/yosemite/smp.c
@@ -99,8 +99,6 @@ void prom_cpus_done(void)
99 */ 99 */
100void prom_init_secondary(void) 100void prom_init_secondary(void)
101{ 101{
102 mips_hpt_init();
103
104 set_c0_status(ST0_CO | ST0_IE | ST0_IM); 102 set_c0_status(ST0_CO | ST0_IE | ST0_IM);
105} 103}
106 104
diff --git a/arch/mips/sgi-ip22/ip22-eisa.c b/arch/mips/sgi-ip22/ip22-eisa.c
index 0d18ed47c47a..a1a9af6da7bf 100644
--- a/arch/mips/sgi-ip22/ip22-eisa.c
+++ b/arch/mips/sgi-ip22/ip22-eisa.c
@@ -95,16 +95,11 @@ static irqreturn_t ip22_eisa_intr(int irq, void *dev_id)
95 95
96static void enable_eisa1_irq(unsigned int irq) 96static void enable_eisa1_irq(unsigned int irq)
97{ 97{
98 unsigned long flags;
99 u8 mask; 98 u8 mask;
100 99
101 local_irq_save(flags);
102
103 mask = inb(EISA_INT1_MASK); 100 mask = inb(EISA_INT1_MASK);
104 mask &= ~((u8) (1 << irq)); 101 mask &= ~((u8) (1 << irq));
105 outb(mask, EISA_INT1_MASK); 102 outb(mask, EISA_INT1_MASK);
106
107 local_irq_restore(flags);
108} 103}
109 104
110static unsigned int startup_eisa1_irq(unsigned int irq) 105static unsigned int startup_eisa1_irq(unsigned int irq)
@@ -130,8 +125,6 @@ static void disable_eisa1_irq(unsigned int irq)
130 outb(mask, EISA_INT1_MASK); 125 outb(mask, EISA_INT1_MASK);
131} 126}
132 127
133#define shutdown_eisa1_irq disable_eisa1_irq
134
135static void mask_and_ack_eisa1_irq(unsigned int irq) 128static void mask_and_ack_eisa1_irq(unsigned int irq)
136{ 129{
137 disable_eisa1_irq(irq); 130 disable_eisa1_irq(irq);
@@ -148,25 +141,20 @@ static void end_eisa1_irq(unsigned int irq)
148static struct irq_chip ip22_eisa1_irq_type = { 141static struct irq_chip ip22_eisa1_irq_type = {
149 .typename = "IP22 EISA", 142 .typename = "IP22 EISA",
150 .startup = startup_eisa1_irq, 143 .startup = startup_eisa1_irq,
151 .shutdown = shutdown_eisa1_irq,
152 .enable = enable_eisa1_irq,
153 .disable = disable_eisa1_irq,
154 .ack = mask_and_ack_eisa1_irq, 144 .ack = mask_and_ack_eisa1_irq,
145 .mask = disable_eisa1_irq,
146 .mask_ack = mask_and_ack_eisa1_irq,
147 .unmask = enable_eisa1_irq,
155 .end = end_eisa1_irq, 148 .end = end_eisa1_irq,
156}; 149};
157 150
158static void enable_eisa2_irq(unsigned int irq) 151static void enable_eisa2_irq(unsigned int irq)
159{ 152{
160 unsigned long flags;
161 u8 mask; 153 u8 mask;
162 154
163 local_irq_save(flags);
164
165 mask = inb(EISA_INT2_MASK); 155 mask = inb(EISA_INT2_MASK);
166 mask &= ~((u8) (1 << (irq - 8))); 156 mask &= ~((u8) (1 << (irq - 8)));
167 outb(mask, EISA_INT2_MASK); 157 outb(mask, EISA_INT2_MASK);
168
169 local_irq_restore(flags);
170} 158}
171 159
172static unsigned int startup_eisa2_irq(unsigned int irq) 160static unsigned int startup_eisa2_irq(unsigned int irq)
@@ -192,8 +180,6 @@ static void disable_eisa2_irq(unsigned int irq)
192 outb(mask, EISA_INT2_MASK); 180 outb(mask, EISA_INT2_MASK);
193} 181}
194 182
195#define shutdown_eisa2_irq disable_eisa2_irq
196
197static void mask_and_ack_eisa2_irq(unsigned int irq) 183static void mask_and_ack_eisa2_irq(unsigned int irq)
198{ 184{
199 disable_eisa2_irq(irq); 185 disable_eisa2_irq(irq);
@@ -210,10 +196,10 @@ static void end_eisa2_irq(unsigned int irq)
210static struct irq_chip ip22_eisa2_irq_type = { 196static struct irq_chip ip22_eisa2_irq_type = {
211 .typename = "IP22 EISA", 197 .typename = "IP22 EISA",
212 .startup = startup_eisa2_irq, 198 .startup = startup_eisa2_irq,
213 .shutdown = shutdown_eisa2_irq,
214 .enable = enable_eisa2_irq,
215 .disable = disable_eisa2_irq,
216 .ack = mask_and_ack_eisa2_irq, 199 .ack = mask_and_ack_eisa2_irq,
200 .mask = disable_eisa2_irq,
201 .mask_ack = mask_and_ack_eisa2_irq,
202 .unmask = enable_eisa2_irq,
217 .end = end_eisa2_irq, 203 .end = end_eisa2_irq,
218}; 204};
219 205
@@ -275,13 +261,10 @@ int __init ip22_eisa_init(void)
275 outb(0, EISA_DMA2_WRITE_SINGLE); 261 outb(0, EISA_DMA2_WRITE_SINGLE);
276 262
277 for (i = SGINT_EISA; i < (SGINT_EISA + EISA_MAX_IRQ); i++) { 263 for (i = SGINT_EISA; i < (SGINT_EISA + EISA_MAX_IRQ); i++) {
278 irq_desc[i].status = IRQ_DISABLED;
279 irq_desc[i].action = 0;
280 irq_desc[i].depth = 1;
281 if (i < (SGINT_EISA + 8)) 264 if (i < (SGINT_EISA + 8))
282 irq_desc[i].chip = &ip22_eisa1_irq_type; 265 set_irq_chip(i, &ip22_eisa1_irq_type);
283 else 266 else
284 irq_desc[i].chip = &ip22_eisa2_irq_type; 267 set_irq_chip(i, &ip22_eisa2_irq_type);
285 } 268 }
286 269
287 /* Cannot use request_irq because of kmalloc not being ready at such 270 /* Cannot use request_irq because of kmalloc not being ready at such
diff --git a/arch/mips/sgi-ip22/ip22-int.c b/arch/mips/sgi-ip22/ip22-int.c
index af518898eaa1..c7b138053159 100644
--- a/arch/mips/sgi-ip22/ip22-int.c
+++ b/arch/mips/sgi-ip22/ip22-int.c
@@ -40,34 +40,17 @@ extern int ip22_eisa_init(void);
40 40
41static void enable_local0_irq(unsigned int irq) 41static void enable_local0_irq(unsigned int irq)
42{ 42{
43 unsigned long flags;
44
45 local_irq_save(flags);
46 /* don't allow mappable interrupt to be enabled from setup_irq, 43 /* don't allow mappable interrupt to be enabled from setup_irq,
47 * we have our own way to do so */ 44 * we have our own way to do so */
48 if (irq != SGI_MAP_0_IRQ) 45 if (irq != SGI_MAP_0_IRQ)
49 sgint->imask0 |= (1 << (irq - SGINT_LOCAL0)); 46 sgint->imask0 |= (1 << (irq - SGINT_LOCAL0));
50 local_irq_restore(flags);
51}
52
53static unsigned int startup_local0_irq(unsigned int irq)
54{
55 enable_local0_irq(irq);
56 return 0; /* Never anything pending */
57} 47}
58 48
59static void disable_local0_irq(unsigned int irq) 49static void disable_local0_irq(unsigned int irq)
60{ 50{
61 unsigned long flags;
62
63 local_irq_save(flags);
64 sgint->imask0 &= ~(1 << (irq - SGINT_LOCAL0)); 51 sgint->imask0 &= ~(1 << (irq - SGINT_LOCAL0));
65 local_irq_restore(flags);
66} 52}
67 53
68#define shutdown_local0_irq disable_local0_irq
69#define mask_and_ack_local0_irq disable_local0_irq
70
71static void end_local0_irq (unsigned int irq) 54static void end_local0_irq (unsigned int irq)
72{ 55{
73 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 56 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -76,44 +59,26 @@ static void end_local0_irq (unsigned int irq)
76 59
77static struct irq_chip ip22_local0_irq_type = { 60static struct irq_chip ip22_local0_irq_type = {
78 .typename = "IP22 local 0", 61 .typename = "IP22 local 0",
79 .startup = startup_local0_irq, 62 .ack = disable_local0_irq,
80 .shutdown = shutdown_local0_irq, 63 .mask = disable_local0_irq,
81 .enable = enable_local0_irq, 64 .mask_ack = disable_local0_irq,
82 .disable = disable_local0_irq, 65 .unmask = enable_local0_irq,
83 .ack = mask_and_ack_local0_irq,
84 .end = end_local0_irq, 66 .end = end_local0_irq,
85}; 67};
86 68
87static void enable_local1_irq(unsigned int irq) 69static void enable_local1_irq(unsigned int irq)
88{ 70{
89 unsigned long flags;
90
91 local_irq_save(flags);
92 /* don't allow mappable interrupt to be enabled from setup_irq, 71 /* don't allow mappable interrupt to be enabled from setup_irq,
93 * we have our own way to do so */ 72 * we have our own way to do so */
94 if (irq != SGI_MAP_1_IRQ) 73 if (irq != SGI_MAP_1_IRQ)
95 sgint->imask1 |= (1 << (irq - SGINT_LOCAL1)); 74 sgint->imask1 |= (1 << (irq - SGINT_LOCAL1));
96 local_irq_restore(flags);
97}
98
99static unsigned int startup_local1_irq(unsigned int irq)
100{
101 enable_local1_irq(irq);
102 return 0; /* Never anything pending */
103} 75}
104 76
105void disable_local1_irq(unsigned int irq) 77void disable_local1_irq(unsigned int irq)
106{ 78{
107 unsigned long flags;
108
109 local_irq_save(flags);
110 sgint->imask1 &= ~(1 << (irq - SGINT_LOCAL1)); 79 sgint->imask1 &= ~(1 << (irq - SGINT_LOCAL1));
111 local_irq_restore(flags);
112} 80}
113 81
114#define shutdown_local1_irq disable_local1_irq
115#define mask_and_ack_local1_irq disable_local1_irq
116
117static void end_local1_irq (unsigned int irq) 82static void end_local1_irq (unsigned int irq)
118{ 83{
119 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 84 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -122,44 +87,26 @@ static void end_local1_irq (unsigned int irq)
122 87
123static struct irq_chip ip22_local1_irq_type = { 88static struct irq_chip ip22_local1_irq_type = {
124 .typename = "IP22 local 1", 89 .typename = "IP22 local 1",
125 .startup = startup_local1_irq, 90 .ack = disable_local1_irq,
126 .shutdown = shutdown_local1_irq, 91 .mask = disable_local1_irq,
127 .enable = enable_local1_irq, 92 .mask_ack = disable_local1_irq,
128 .disable = disable_local1_irq, 93 .unmask = enable_local1_irq,
129 .ack = mask_and_ack_local1_irq,
130 .end = end_local1_irq, 94 .end = end_local1_irq,
131}; 95};
132 96
133static void enable_local2_irq(unsigned int irq) 97static void enable_local2_irq(unsigned int irq)
134{ 98{
135 unsigned long flags;
136
137 local_irq_save(flags);
138 sgint->imask0 |= (1 << (SGI_MAP_0_IRQ - SGINT_LOCAL0)); 99 sgint->imask0 |= (1 << (SGI_MAP_0_IRQ - SGINT_LOCAL0));
139 sgint->cmeimask0 |= (1 << (irq - SGINT_LOCAL2)); 100 sgint->cmeimask0 |= (1 << (irq - SGINT_LOCAL2));
140 local_irq_restore(flags);
141}
142
143static unsigned int startup_local2_irq(unsigned int irq)
144{
145 enable_local2_irq(irq);
146 return 0; /* Never anything pending */
147} 101}
148 102
149void disable_local2_irq(unsigned int irq) 103void disable_local2_irq(unsigned int irq)
150{ 104{
151 unsigned long flags;
152
153 local_irq_save(flags);
154 sgint->cmeimask0 &= ~(1 << (irq - SGINT_LOCAL2)); 105 sgint->cmeimask0 &= ~(1 << (irq - SGINT_LOCAL2));
155 if (!sgint->cmeimask0) 106 if (!sgint->cmeimask0)
156 sgint->imask0 &= ~(1 << (SGI_MAP_0_IRQ - SGINT_LOCAL0)); 107 sgint->imask0 &= ~(1 << (SGI_MAP_0_IRQ - SGINT_LOCAL0));
157 local_irq_restore(flags);
158} 108}
159 109
160#define shutdown_local2_irq disable_local2_irq
161#define mask_and_ack_local2_irq disable_local2_irq
162
163static void end_local2_irq (unsigned int irq) 110static void end_local2_irq (unsigned int irq)
164{ 111{
165 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 112 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -168,44 +115,26 @@ static void end_local2_irq (unsigned int irq)
168 115
169static struct irq_chip ip22_local2_irq_type = { 116static struct irq_chip ip22_local2_irq_type = {
170 .typename = "IP22 local 2", 117 .typename = "IP22 local 2",
171 .startup = startup_local2_irq, 118 .ack = disable_local2_irq,
172 .shutdown = shutdown_local2_irq, 119 .mask = disable_local2_irq,
173 .enable = enable_local2_irq, 120 .mask_ack = disable_local2_irq,
174 .disable = disable_local2_irq, 121 .unmask = enable_local2_irq,
175 .ack = mask_and_ack_local2_irq,
176 .end = end_local2_irq, 122 .end = end_local2_irq,
177}; 123};
178 124
179static void enable_local3_irq(unsigned int irq) 125static void enable_local3_irq(unsigned int irq)
180{ 126{
181 unsigned long flags;
182
183 local_irq_save(flags);
184 sgint->imask1 |= (1 << (SGI_MAP_1_IRQ - SGINT_LOCAL1)); 127 sgint->imask1 |= (1 << (SGI_MAP_1_IRQ - SGINT_LOCAL1));
185 sgint->cmeimask1 |= (1 << (irq - SGINT_LOCAL3)); 128 sgint->cmeimask1 |= (1 << (irq - SGINT_LOCAL3));
186 local_irq_restore(flags);
187}
188
189static unsigned int startup_local3_irq(unsigned int irq)
190{
191 enable_local3_irq(irq);
192 return 0; /* Never anything pending */
193} 129}
194 130
195void disable_local3_irq(unsigned int irq) 131void disable_local3_irq(unsigned int irq)
196{ 132{
197 unsigned long flags;
198
199 local_irq_save(flags);
200 sgint->cmeimask1 &= ~(1 << (irq - SGINT_LOCAL3)); 133 sgint->cmeimask1 &= ~(1 << (irq - SGINT_LOCAL3));
201 if (!sgint->cmeimask1) 134 if (!sgint->cmeimask1)
202 sgint->imask1 &= ~(1 << (SGI_MAP_1_IRQ - SGINT_LOCAL1)); 135 sgint->imask1 &= ~(1 << (SGI_MAP_1_IRQ - SGINT_LOCAL1));
203 local_irq_restore(flags);
204} 136}
205 137
206#define shutdown_local3_irq disable_local3_irq
207#define mask_and_ack_local3_irq disable_local3_irq
208
209static void end_local3_irq (unsigned int irq) 138static void end_local3_irq (unsigned int irq)
210{ 139{
211 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 140 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -214,11 +143,10 @@ static void end_local3_irq (unsigned int irq)
214 143
215static struct irq_chip ip22_local3_irq_type = { 144static struct irq_chip ip22_local3_irq_type = {
216 .typename = "IP22 local 3", 145 .typename = "IP22 local 3",
217 .startup = startup_local3_irq, 146 .ack = disable_local3_irq,
218 .shutdown = shutdown_local3_irq, 147 .mask = disable_local3_irq,
219 .enable = enable_local3_irq, 148 .mask_ack = disable_local3_irq,
220 .disable = disable_local3_irq, 149 .unmask = enable_local3_irq,
221 .ack = mask_and_ack_local3_irq,
222 .end = end_local3_irq, 150 .end = end_local3_irq,
223}; 151};
224 152
@@ -430,10 +358,7 @@ void __init arch_init_irq(void)
430 else 358 else
431 handler = &ip22_local3_irq_type; 359 handler = &ip22_local3_irq_type;
432 360
433 irq_desc[i].status = IRQ_DISABLED; 361 set_irq_chip_and_handler(i, handler, handle_level_irq);
434 irq_desc[i].action = 0;
435 irq_desc[i].depth = 1;
436 irq_desc[i].chip = handler;
437 } 362 }
438 363
439 /* vector handler. this register the IRQ as non-sharable */ 364 /* vector handler. this register the IRQ as non-sharable */
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index 270ecd3e6b4a..5f8835b4e84a 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -332,11 +332,6 @@ static inline void disable_bridge_irq(unsigned int irq)
332 intr_disconnect_level(cpu, swlevel); 332 intr_disconnect_level(cpu, swlevel);
333} 333}
334 334
335static void mask_and_ack_bridge_irq(unsigned int irq)
336{
337 disable_bridge_irq(irq);
338}
339
340static void end_bridge_irq(unsigned int irq) 335static void end_bridge_irq(unsigned int irq)
341{ 336{
342 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)) && 337 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)) &&
@@ -348,18 +343,16 @@ static struct irq_chip bridge_irq_type = {
348 .typename = "bridge", 343 .typename = "bridge",
349 .startup = startup_bridge_irq, 344 .startup = startup_bridge_irq,
350 .shutdown = shutdown_bridge_irq, 345 .shutdown = shutdown_bridge_irq,
351 .enable = enable_bridge_irq, 346 .ack = disable_bridge_irq,
352 .disable = disable_bridge_irq, 347 .mask = disable_bridge_irq,
353 .ack = mask_and_ack_bridge_irq, 348 .mask_ack = disable_bridge_irq,
349 .unmask = enable_bridge_irq,
354 .end = end_bridge_irq, 350 .end = end_bridge_irq,
355}; 351};
356 352
357void __devinit register_bridge_irq(unsigned int irq) 353void __devinit register_bridge_irq(unsigned int irq)
358{ 354{
359 irq_desc[irq].status = IRQ_DISABLED; 355 set_irq_chip_and_handler(irq, &bridge_irq_type, handle_level_irq);
360 irq_desc[irq].action = 0;
361 irq_desc[irq].depth = 1;
362 irq_desc[irq].chip = &bridge_irq_type;
363} 356}
364 357
365int __devinit request_bridge_irq(struct bridge_controller *bc) 358int __devinit request_bridge_irq(struct bridge_controller *bc)
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 5e82a268e3c9..7d361726bbfb 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -172,15 +172,6 @@ static __init unsigned long get_m48t35_time(void)
172 return mktime(year, month, date, hour, min, sec); 172 return mktime(year, month, date, hour, min, sec);
173} 173}
174 174
175static unsigned int startup_rt_irq(unsigned int irq)
176{
177 return 0;
178}
179
180static void shutdown_rt_irq(unsigned int irq)
181{
182}
183
184static void enable_rt_irq(unsigned int irq) 175static void enable_rt_irq(unsigned int irq)
185{ 176{
186} 177}
@@ -189,21 +180,17 @@ static void disable_rt_irq(unsigned int irq)
189{ 180{
190} 181}
191 182
192static void mask_and_ack_rt(unsigned int irq)
193{
194}
195
196static void end_rt_irq(unsigned int irq) 183static void end_rt_irq(unsigned int irq)
197{ 184{
198} 185}
199 186
200static struct irq_chip rt_irq_type = { 187static struct irq_chip rt_irq_type = {
201 .typename = "SN HUB RT timer", 188 .typename = "SN HUB RT timer",
202 .startup = startup_rt_irq, 189 .ack = disable_rt_irq,
203 .shutdown = shutdown_rt_irq, 190 .mask = disable_rt_irq,
204 .enable = enable_rt_irq, 191 .mask_ack = disable_rt_irq,
205 .disable = disable_rt_irq, 192 .unmask = enable_rt_irq,
206 .ack = mask_and_ack_rt, 193 .eoi = enable_rt_irq,
207 .end = end_rt_irq, 194 .end = end_rt_irq,
208}; 195};
209 196
@@ -221,10 +208,7 @@ void __init plat_timer_setup(struct irqaction *irq)
221 if (irqno < 0) 208 if (irqno < 0)
222 panic("Can't allocate interrupt number for timer interrupt"); 209 panic("Can't allocate interrupt number for timer interrupt");
223 210
224 irq_desc[irqno].status = IRQ_DISABLED; 211 set_irq_chip_and_handler(irqno, &rt_irq_type, handle_percpu_irq);
225 irq_desc[irqno].action = NULL;
226 irq_desc[irqno].depth = 1;
227 irq_desc[irqno].chip = &rt_irq_type;
228 212
229 /* over-write the handler, we use our own way */ 213 /* over-write the handler, we use our own way */
230 irq->handler = no_action; 214 irq->handler = no_action;
@@ -239,14 +223,14 @@ void __init plat_timer_setup(struct irqaction *irq)
239 setup_irq(irqno, &rt_irqaction); 223 setup_irq(irqno, &rt_irqaction);
240} 224}
241 225
242static unsigned int ip27_hpt_read(void) 226static cycle_t ip27_hpt_read(void)
243{ 227{
244 return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT); 228 return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT);
245} 229}
246 230
247void __init ip27_time_init(void) 231void __init ip27_time_init(void)
248{ 232{
249 mips_hpt_read = ip27_hpt_read; 233 clocksource_mips.read = ip27_hpt_read;
250 mips_hpt_frequency = CYCLES_PER_SEC; 234 mips_hpt_frequency = CYCLES_PER_SEC;
251 xtime.tv_sec = get_m48t35_time(); 235 xtime.tv_sec = get_m48t35_time();
252 xtime.tv_nsec = 0; 236 xtime.tv_nsec = 0;
diff --git a/arch/mips/sgi-ip32/ip32-irq.c b/arch/mips/sgi-ip32/ip32-irq.c
index c9acadd0846b..ae063864c026 100644
--- a/arch/mips/sgi-ip32/ip32-irq.c
+++ b/arch/mips/sgi-ip32/ip32-irq.c
@@ -113,12 +113,6 @@ static void inline flush_mace_bus(void)
113 * is quite different anyway. 113 * is quite different anyway.
114 */ 114 */
115 115
116/*
117 * IRQ spinlock - Ralf says not to disable CPU interrupts,
118 * and I think he knows better.
119 */
120static DEFINE_SPINLOCK(ip32_irq_lock);
121
122/* Some initial interrupts to set up */ 116/* Some initial interrupts to set up */
123extern irqreturn_t crime_memerr_intr(int irq, void *dev_id); 117extern irqreturn_t crime_memerr_intr(int irq, void *dev_id);
124extern irqreturn_t crime_cpuerr_intr(int irq, void *dev_id); 118extern irqreturn_t crime_cpuerr_intr(int irq, void *dev_id);
@@ -138,12 +132,6 @@ static void enable_cpu_irq(unsigned int irq)
138 set_c0_status(STATUSF_IP7); 132 set_c0_status(STATUSF_IP7);
139} 133}
140 134
141static unsigned int startup_cpu_irq(unsigned int irq)
142{
143 enable_cpu_irq(irq);
144 return 0;
145}
146
147static void disable_cpu_irq(unsigned int irq) 135static void disable_cpu_irq(unsigned int irq)
148{ 136{
149 clear_c0_status(STATUSF_IP7); 137 clear_c0_status(STATUSF_IP7);
@@ -155,16 +143,12 @@ static void end_cpu_irq(unsigned int irq)
155 enable_cpu_irq (irq); 143 enable_cpu_irq (irq);
156} 144}
157 145
158#define shutdown_cpu_irq disable_cpu_irq
159#define mask_and_ack_cpu_irq disable_cpu_irq
160
161static struct irq_chip ip32_cpu_interrupt = { 146static struct irq_chip ip32_cpu_interrupt = {
162 .typename = "IP32 CPU", 147 .typename = "IP32 CPU",
163 .startup = startup_cpu_irq, 148 .ack = disable_cpu_irq,
164 .shutdown = shutdown_cpu_irq, 149 .mask = disable_cpu_irq,
165 .enable = enable_cpu_irq, 150 .mask_ack = disable_cpu_irq,
166 .disable = disable_cpu_irq, 151 .unmask = enable_cpu_irq,
167 .ack = mask_and_ack_cpu_irq,
168 .end = end_cpu_irq, 152 .end = end_cpu_irq,
169}; 153};
170 154
@@ -177,45 +161,27 @@ static uint64_t crime_mask;
177 161
178static void enable_crime_irq(unsigned int irq) 162static void enable_crime_irq(unsigned int irq)
179{ 163{
180 unsigned long flags;
181
182 spin_lock_irqsave(&ip32_irq_lock, flags);
183 crime_mask |= 1 << (irq - 1); 164 crime_mask |= 1 << (irq - 1);
184 crime->imask = crime_mask; 165 crime->imask = crime_mask;
185 spin_unlock_irqrestore(&ip32_irq_lock, flags);
186}
187
188static unsigned int startup_crime_irq(unsigned int irq)
189{
190 enable_crime_irq(irq);
191 return 0; /* This is probably not right; we could have pending irqs */
192} 166}
193 167
194static void disable_crime_irq(unsigned int irq) 168static void disable_crime_irq(unsigned int irq)
195{ 169{
196 unsigned long flags;
197
198 spin_lock_irqsave(&ip32_irq_lock, flags);
199 crime_mask &= ~(1 << (irq - 1)); 170 crime_mask &= ~(1 << (irq - 1));
200 crime->imask = crime_mask; 171 crime->imask = crime_mask;
201 flush_crime_bus(); 172 flush_crime_bus();
202 spin_unlock_irqrestore(&ip32_irq_lock, flags);
203} 173}
204 174
205static void mask_and_ack_crime_irq(unsigned int irq) 175static void mask_and_ack_crime_irq(unsigned int irq)
206{ 176{
207 unsigned long flags;
208
209 /* Edge triggered interrupts must be cleared. */ 177 /* Edge triggered interrupts must be cleared. */
210 if ((irq >= CRIME_GBE0_IRQ && irq <= CRIME_GBE3_IRQ) 178 if ((irq >= CRIME_GBE0_IRQ && irq <= CRIME_GBE3_IRQ)
211 || (irq >= CRIME_RE_EMPTY_E_IRQ && irq <= CRIME_RE_IDLE_E_IRQ) 179 || (irq >= CRIME_RE_EMPTY_E_IRQ && irq <= CRIME_RE_IDLE_E_IRQ)
212 || (irq >= CRIME_SOFT0_IRQ && irq <= CRIME_SOFT2_IRQ)) { 180 || (irq >= CRIME_SOFT0_IRQ && irq <= CRIME_SOFT2_IRQ)) {
213 uint64_t crime_int; 181 uint64_t crime_int;
214 spin_lock_irqsave(&ip32_irq_lock, flags);
215 crime_int = crime->hard_int; 182 crime_int = crime->hard_int;
216 crime_int &= ~(1 << (irq - 1)); 183 crime_int &= ~(1 << (irq - 1));
217 crime->hard_int = crime_int; 184 crime->hard_int = crime_int;
218 spin_unlock_irqrestore(&ip32_irq_lock, flags);
219 } 185 }
220 disable_crime_irq(irq); 186 disable_crime_irq(irq);
221} 187}
@@ -226,15 +192,12 @@ static void end_crime_irq(unsigned int irq)
226 enable_crime_irq(irq); 192 enable_crime_irq(irq);
227} 193}
228 194
229#define shutdown_crime_irq disable_crime_irq
230
231static struct irq_chip ip32_crime_interrupt = { 195static struct irq_chip ip32_crime_interrupt = {
232 .typename = "IP32 CRIME", 196 .typename = "IP32 CRIME",
233 .startup = startup_crime_irq,
234 .shutdown = shutdown_crime_irq,
235 .enable = enable_crime_irq,
236 .disable = disable_crime_irq,
237 .ack = mask_and_ack_crime_irq, 197 .ack = mask_and_ack_crime_irq,
198 .mask = disable_crime_irq,
199 .mask_ack = mask_and_ack_crime_irq,
200 .unmask = enable_crime_irq,
238 .end = end_crime_irq, 201 .end = end_crime_irq,
239}; 202};
240 203
@@ -248,34 +211,20 @@ static unsigned long macepci_mask;
248 211
249static void enable_macepci_irq(unsigned int irq) 212static void enable_macepci_irq(unsigned int irq)
250{ 213{
251 unsigned long flags;
252
253 spin_lock_irqsave(&ip32_irq_lock, flags);
254 macepci_mask |= MACEPCI_CONTROL_INT(irq - 9); 214 macepci_mask |= MACEPCI_CONTROL_INT(irq - 9);
255 mace->pci.control = macepci_mask; 215 mace->pci.control = macepci_mask;
256 crime_mask |= 1 << (irq - 1); 216 crime_mask |= 1 << (irq - 1);
257 crime->imask = crime_mask; 217 crime->imask = crime_mask;
258 spin_unlock_irqrestore(&ip32_irq_lock, flags);
259}
260
261static unsigned int startup_macepci_irq(unsigned int irq)
262{
263 enable_macepci_irq (irq);
264 return 0;
265} 218}
266 219
267static void disable_macepci_irq(unsigned int irq) 220static void disable_macepci_irq(unsigned int irq)
268{ 221{
269 unsigned long flags;
270
271 spin_lock_irqsave(&ip32_irq_lock, flags);
272 crime_mask &= ~(1 << (irq - 1)); 222 crime_mask &= ~(1 << (irq - 1));
273 crime->imask = crime_mask; 223 crime->imask = crime_mask;
274 flush_crime_bus(); 224 flush_crime_bus();
275 macepci_mask &= ~MACEPCI_CONTROL_INT(irq - 9); 225 macepci_mask &= ~MACEPCI_CONTROL_INT(irq - 9);
276 mace->pci.control = macepci_mask; 226 mace->pci.control = macepci_mask;
277 flush_mace_bus(); 227 flush_mace_bus();
278 spin_unlock_irqrestore(&ip32_irq_lock, flags);
279} 228}
280 229
281static void end_macepci_irq(unsigned int irq) 230static void end_macepci_irq(unsigned int irq)
@@ -284,16 +233,12 @@ static void end_macepci_irq(unsigned int irq)
284 enable_macepci_irq(irq); 233 enable_macepci_irq(irq);
285} 234}
286 235
287#define shutdown_macepci_irq disable_macepci_irq
288#define mask_and_ack_macepci_irq disable_macepci_irq
289
290static struct irq_chip ip32_macepci_interrupt = { 236static struct irq_chip ip32_macepci_interrupt = {
291 .typename = "IP32 MACE PCI", 237 .typename = "IP32 MACE PCI",
292 .startup = startup_macepci_irq, 238 .ack = disable_macepci_irq,
293 .shutdown = shutdown_macepci_irq, 239 .mask = disable_macepci_irq,
294 .enable = enable_macepci_irq, 240 .mask_ack = disable_macepci_irq,
295 .disable = disable_macepci_irq, 241 .unmask = enable_macepci_irq,
296 .ack = mask_and_ack_macepci_irq,
297 .end = end_macepci_irq, 242 .end = end_macepci_irq,
298}; 243};
299 244
@@ -339,7 +284,6 @@ static unsigned long maceisa_mask;
339static void enable_maceisa_irq (unsigned int irq) 284static void enable_maceisa_irq (unsigned int irq)
340{ 285{
341 unsigned int crime_int = 0; 286 unsigned int crime_int = 0;
342 unsigned long flags;
343 287
344 DBG ("maceisa enable: %u\n", irq); 288 DBG ("maceisa enable: %u\n", irq);
345 289
@@ -355,26 +299,16 @@ static void enable_maceisa_irq (unsigned int irq)
355 break; 299 break;
356 } 300 }
357 DBG ("crime_int %08x enabled\n", crime_int); 301 DBG ("crime_int %08x enabled\n", crime_int);
358 spin_lock_irqsave(&ip32_irq_lock, flags);
359 crime_mask |= crime_int; 302 crime_mask |= crime_int;
360 crime->imask = crime_mask; 303 crime->imask = crime_mask;
361 maceisa_mask |= 1 << (irq - 33); 304 maceisa_mask |= 1 << (irq - 33);
362 mace->perif.ctrl.imask = maceisa_mask; 305 mace->perif.ctrl.imask = maceisa_mask;
363 spin_unlock_irqrestore(&ip32_irq_lock, flags);
364}
365
366static unsigned int startup_maceisa_irq(unsigned int irq)
367{
368 enable_maceisa_irq(irq);
369 return 0;
370} 306}
371 307
372static void disable_maceisa_irq(unsigned int irq) 308static void disable_maceisa_irq(unsigned int irq)
373{ 309{
374 unsigned int crime_int = 0; 310 unsigned int crime_int = 0;
375 unsigned long flags;
376 311
377 spin_lock_irqsave(&ip32_irq_lock, flags);
378 maceisa_mask &= ~(1 << (irq - 33)); 312 maceisa_mask &= ~(1 << (irq - 33));
379 if(!(maceisa_mask & MACEISA_AUDIO_INT)) 313 if(!(maceisa_mask & MACEISA_AUDIO_INT))
380 crime_int |= MACE_AUDIO_INT; 314 crime_int |= MACE_AUDIO_INT;
@@ -387,23 +321,20 @@ static void disable_maceisa_irq(unsigned int irq)
387 flush_crime_bus(); 321 flush_crime_bus();
388 mace->perif.ctrl.imask = maceisa_mask; 322 mace->perif.ctrl.imask = maceisa_mask;
389 flush_mace_bus(); 323 flush_mace_bus();
390 spin_unlock_irqrestore(&ip32_irq_lock, flags);
391} 324}
392 325
393static void mask_and_ack_maceisa_irq(unsigned int irq) 326static void mask_and_ack_maceisa_irq(unsigned int irq)
394{ 327{
395 unsigned long mace_int, flags; 328 unsigned long mace_int;
396 329
397 switch (irq) { 330 switch (irq) {
398 case MACEISA_PARALLEL_IRQ: 331 case MACEISA_PARALLEL_IRQ:
399 case MACEISA_SERIAL1_TDMAPR_IRQ: 332 case MACEISA_SERIAL1_TDMAPR_IRQ:
400 case MACEISA_SERIAL2_TDMAPR_IRQ: 333 case MACEISA_SERIAL2_TDMAPR_IRQ:
401 /* edge triggered */ 334 /* edge triggered */
402 spin_lock_irqsave(&ip32_irq_lock, flags);
403 mace_int = mace->perif.ctrl.istat; 335 mace_int = mace->perif.ctrl.istat;
404 mace_int &= ~(1 << (irq - 33)); 336 mace_int &= ~(1 << (irq - 33));
405 mace->perif.ctrl.istat = mace_int; 337 mace->perif.ctrl.istat = mace_int;
406 spin_unlock_irqrestore(&ip32_irq_lock, flags);
407 break; 338 break;
408 } 339 }
409 disable_maceisa_irq(irq); 340 disable_maceisa_irq(irq);
@@ -415,15 +346,12 @@ static void end_maceisa_irq(unsigned irq)
415 enable_maceisa_irq(irq); 346 enable_maceisa_irq(irq);
416} 347}
417 348
418#define shutdown_maceisa_irq disable_maceisa_irq
419
420static struct irq_chip ip32_maceisa_interrupt = { 349static struct irq_chip ip32_maceisa_interrupt = {
421 .typename = "IP32 MACE ISA", 350 .typename = "IP32 MACE ISA",
422 .startup = startup_maceisa_irq,
423 .shutdown = shutdown_maceisa_irq,
424 .enable = enable_maceisa_irq,
425 .disable = disable_maceisa_irq,
426 .ack = mask_and_ack_maceisa_irq, 351 .ack = mask_and_ack_maceisa_irq,
352 .mask = disable_maceisa_irq,
353 .mask_ack = mask_and_ack_maceisa_irq,
354 .unmask = enable_maceisa_irq,
427 .end = end_maceisa_irq, 355 .end = end_maceisa_irq,
428}; 356};
429 357
@@ -433,29 +361,15 @@ static struct irq_chip ip32_maceisa_interrupt = {
433 361
434static void enable_mace_irq(unsigned int irq) 362static void enable_mace_irq(unsigned int irq)
435{ 363{
436 unsigned long flags;
437
438 spin_lock_irqsave(&ip32_irq_lock, flags);
439 crime_mask |= 1 << (irq - 1); 364 crime_mask |= 1 << (irq - 1);
440 crime->imask = crime_mask; 365 crime->imask = crime_mask;
441 spin_unlock_irqrestore(&ip32_irq_lock, flags);
442}
443
444static unsigned int startup_mace_irq(unsigned int irq)
445{
446 enable_mace_irq(irq);
447 return 0;
448} 366}
449 367
450static void disable_mace_irq(unsigned int irq) 368static void disable_mace_irq(unsigned int irq)
451{ 369{
452 unsigned long flags;
453
454 spin_lock_irqsave(&ip32_irq_lock, flags);
455 crime_mask &= ~(1 << (irq - 1)); 370 crime_mask &= ~(1 << (irq - 1));
456 crime->imask = crime_mask; 371 crime->imask = crime_mask;
457 flush_crime_bus(); 372 flush_crime_bus();
458 spin_unlock_irqrestore(&ip32_irq_lock, flags);
459} 373}
460 374
461static void end_mace_irq(unsigned int irq) 375static void end_mace_irq(unsigned int irq)
@@ -464,16 +378,12 @@ static void end_mace_irq(unsigned int irq)
464 enable_mace_irq(irq); 378 enable_mace_irq(irq);
465} 379}
466 380
467#define shutdown_mace_irq disable_mace_irq
468#define mask_and_ack_mace_irq disable_mace_irq
469
470static struct irq_chip ip32_mace_interrupt = { 381static struct irq_chip ip32_mace_interrupt = {
471 .typename = "IP32 MACE", 382 .typename = "IP32 MACE",
472 .startup = startup_mace_irq, 383 .ack = disable_mace_irq,
473 .shutdown = shutdown_mace_irq, 384 .mask = disable_mace_irq,
474 .enable = enable_mace_irq, 385 .mask_ack = disable_mace_irq,
475 .disable = disable_mace_irq, 386 .unmask = enable_mace_irq,
476 .ack = mask_and_ack_mace_irq,
477 .end = end_mace_irq, 387 .end = end_mace_irq,
478}; 388};
479 389
@@ -586,10 +496,7 @@ void __init arch_init_irq(void)
586 else 496 else
587 controller = &ip32_maceisa_interrupt; 497 controller = &ip32_maceisa_interrupt;
588 498
589 irq_desc[irq].status = IRQ_DISABLED; 499 set_irq_chip(irq, controller);
590 irq_desc[irq].action = 0;
591 irq_desc[irq].depth = 0;
592 irq_desc[irq].chip = controller;
593 } 500 }
594 setup_irq(CRIME_MEMERR_IRQ, &memerr_irq); 501 setup_irq(CRIME_MEMERR_IRQ, &memerr_irq);
595 setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq); 502 setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq);
diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c
index 8b1f41484923..2e8f6b2e2420 100644
--- a/arch/mips/sibyte/bcm1480/irq.c
+++ b/arch/mips/sibyte/bcm1480/irq.c
@@ -45,11 +45,9 @@
45 */ 45 */
46 46
47 47
48#define shutdown_bcm1480_irq disable_bcm1480_irq
49static void end_bcm1480_irq(unsigned int irq); 48static void end_bcm1480_irq(unsigned int irq);
50static void enable_bcm1480_irq(unsigned int irq); 49static void enable_bcm1480_irq(unsigned int irq);
51static void disable_bcm1480_irq(unsigned int irq); 50static void disable_bcm1480_irq(unsigned int irq);
52static unsigned int startup_bcm1480_irq(unsigned int irq);
53static void ack_bcm1480_irq(unsigned int irq); 51static void ack_bcm1480_irq(unsigned int irq);
54#ifdef CONFIG_SMP 52#ifdef CONFIG_SMP
55static void bcm1480_set_affinity(unsigned int irq, cpumask_t mask); 53static void bcm1480_set_affinity(unsigned int irq, cpumask_t mask);
@@ -85,11 +83,10 @@ extern char sb1250_duart_present[];
85 83
86static struct irq_chip bcm1480_irq_type = { 84static struct irq_chip bcm1480_irq_type = {
87 .typename = "BCM1480-IMR", 85 .typename = "BCM1480-IMR",
88 .startup = startup_bcm1480_irq,
89 .shutdown = shutdown_bcm1480_irq,
90 .enable = enable_bcm1480_irq,
91 .disable = disable_bcm1480_irq,
92 .ack = ack_bcm1480_irq, 86 .ack = ack_bcm1480_irq,
87 .mask = disable_bcm1480_irq,
88 .mask_ack = ack_bcm1480_irq,
89 .unmask = enable_bcm1480_irq,
93 .end = end_bcm1480_irq, 90 .end = end_bcm1480_irq,
94#ifdef CONFIG_SMP 91#ifdef CONFIG_SMP
95 .set_affinity = bcm1480_set_affinity 92 .set_affinity = bcm1480_set_affinity
@@ -188,14 +185,6 @@ static void bcm1480_set_affinity(unsigned int irq, cpumask_t mask)
188 185
189/*****************************************************************************/ 186/*****************************************************************************/
190 187
191static unsigned int startup_bcm1480_irq(unsigned int irq)
192{
193 bcm1480_unmask_irq(bcm1480_irq_owner[irq], irq);
194
195 return 0; /* never anything pending */
196}
197
198
199static void disable_bcm1480_irq(unsigned int irq) 188static void disable_bcm1480_irq(unsigned int irq)
200{ 189{
201 bcm1480_mask_irq(bcm1480_irq_owner[irq], irq); 190 bcm1480_mask_irq(bcm1480_irq_owner[irq], irq);
@@ -270,16 +259,9 @@ void __init init_bcm1480_irqs(void)
270{ 259{
271 int i; 260 int i;
272 261
273 for (i = 0; i < NR_IRQS; i++) { 262 for (i = 0; i < BCM1480_NR_IRQS; i++) {
274 irq_desc[i].status = IRQ_DISABLED; 263 set_irq_chip(i, &bcm1480_irq_type);
275 irq_desc[i].action = 0; 264 bcm1480_irq_owner[i] = 0;
276 irq_desc[i].depth = 1;
277 if (i < BCM1480_NR_IRQS) {
278 irq_desc[i].chip = &bcm1480_irq_type;
279 bcm1480_irq_owner[i] = 0;
280 } else {
281 irq_desc[i].chip = &no_irq_chip;
282 }
283 } 265 }
284} 266}
285 267
diff --git a/arch/mips/sibyte/bcm1480/time.c b/arch/mips/sibyte/bcm1480/time.c
index e136bde5248e..6f3f71bf4244 100644
--- a/arch/mips/sibyte/bcm1480/time.c
+++ b/arch/mips/sibyte/bcm1480/time.c
@@ -94,8 +94,6 @@ void bcm1480_time_init(void)
94 */ 94 */
95} 95}
96 96
97#include <asm/sibyte/sb1250.h>
98
99void bcm1480_timer_interrupt(void) 97void bcm1480_timer_interrupt(void)
100{ 98{
101 int cpu = smp_processor_id(); 99 int cpu = smp_processor_id();
@@ -119,7 +117,7 @@ void bcm1480_timer_interrupt(void)
119 } 117 }
120} 118}
121 119
122static unsigned int bcm1480_hpt_read(void) 120static cycle_t bcm1480_hpt_read(void)
123{ 121{
124 /* We assume this function is called xtime_lock held. */ 122 /* We assume this function is called xtime_lock held. */
125 unsigned long count = 123 unsigned long count =
@@ -129,6 +127,6 @@ static unsigned int bcm1480_hpt_read(void)
129 127
130void __init bcm1480_hpt_setup(void) 128void __init bcm1480_hpt_setup(void)
131{ 129{
132 mips_hpt_read = bcm1480_hpt_read; 130 clocksource_mips.read = bcm1480_hpt_read;
133 mips_hpt_frequency = BCM1480_HPT_VALUE; 131 mips_hpt_frequency = BCM1480_HPT_VALUE;
134} 132}
diff --git a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c
index d5d26770daf6..82ce7533053f 100644
--- a/arch/mips/sibyte/sb1250/irq.c
+++ b/arch/mips/sibyte/sb1250/irq.c
@@ -44,11 +44,9 @@
44 */ 44 */
45 45
46 46
47#define shutdown_sb1250_irq disable_sb1250_irq
48static void end_sb1250_irq(unsigned int irq); 47static void end_sb1250_irq(unsigned int irq);
49static void enable_sb1250_irq(unsigned int irq); 48static void enable_sb1250_irq(unsigned int irq);
50static void disable_sb1250_irq(unsigned int irq); 49static void disable_sb1250_irq(unsigned int irq);
51static unsigned int startup_sb1250_irq(unsigned int irq);
52static void ack_sb1250_irq(unsigned int irq); 50static void ack_sb1250_irq(unsigned int irq);
53#ifdef CONFIG_SMP 51#ifdef CONFIG_SMP
54static void sb1250_set_affinity(unsigned int irq, cpumask_t mask); 52static void sb1250_set_affinity(unsigned int irq, cpumask_t mask);
@@ -70,11 +68,10 @@ extern char sb1250_duart_present[];
70 68
71static struct irq_chip sb1250_irq_type = { 69static struct irq_chip sb1250_irq_type = {
72 .typename = "SB1250-IMR", 70 .typename = "SB1250-IMR",
73 .startup = startup_sb1250_irq,
74 .shutdown = shutdown_sb1250_irq,
75 .enable = enable_sb1250_irq,
76 .disable = disable_sb1250_irq,
77 .ack = ack_sb1250_irq, 71 .ack = ack_sb1250_irq,
72 .mask = disable_sb1250_irq,
73 .mask_ack = ack_sb1250_irq,
74 .unmask = enable_sb1250_irq,
78 .end = end_sb1250_irq, 75 .end = end_sb1250_irq,
79#ifdef CONFIG_SMP 76#ifdef CONFIG_SMP
80 .set_affinity = sb1250_set_affinity 77 .set_affinity = sb1250_set_affinity
@@ -163,14 +160,6 @@ static void sb1250_set_affinity(unsigned int irq, cpumask_t mask)
163 160
164/*****************************************************************************/ 161/*****************************************************************************/
165 162
166static unsigned int startup_sb1250_irq(unsigned int irq)
167{
168 sb1250_unmask_irq(sb1250_irq_owner[irq], irq);
169
170 return 0; /* never anything pending */
171}
172
173
174static void disable_sb1250_irq(unsigned int irq) 163static void disable_sb1250_irq(unsigned int irq)
175{ 164{
176 sb1250_mask_irq(sb1250_irq_owner[irq], irq); 165 sb1250_mask_irq(sb1250_irq_owner[irq], irq);
@@ -239,16 +228,9 @@ void __init init_sb1250_irqs(void)
239{ 228{
240 int i; 229 int i;
241 230
242 for (i = 0; i < NR_IRQS; i++) { 231 for (i = 0; i < SB1250_NR_IRQS; i++) {
243 irq_desc[i].status = IRQ_DISABLED; 232 set_irq_chip(i, &sb1250_irq_type);
244 irq_desc[i].action = 0; 233 sb1250_irq_owner[i] = 0;
245 irq_desc[i].depth = 1;
246 if (i < SB1250_NR_IRQS) {
247 irq_desc[i].chip = &sb1250_irq_type;
248 sb1250_irq_owner[i] = 0;
249 } else {
250 irq_desc[i].chip = &no_irq_chip;
251 }
252 } 234 }
253} 235}
254 236
diff --git a/arch/mips/sibyte/sb1250/time.c b/arch/mips/sibyte/sb1250/time.c
index bcb74f2c1948..2efffe15ff23 100644
--- a/arch/mips/sibyte/sb1250/time.c
+++ b/arch/mips/sibyte/sb1250/time.c
@@ -51,7 +51,7 @@
51 51
52extern int sb1250_steal_irq(int irq); 52extern int sb1250_steal_irq(int irq);
53 53
54static unsigned int sb1250_hpt_read(void); 54static cycle_t sb1250_hpt_read(void);
55 55
56void __init sb1250_hpt_setup(void) 56void __init sb1250_hpt_setup(void)
57{ 57{
@@ -66,8 +66,8 @@ void __init sb1250_hpt_setup(void)
66 IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CFG))); 66 IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CFG)));
67 67
68 mips_hpt_frequency = V_SCD_TIMER_FREQ; 68 mips_hpt_frequency = V_SCD_TIMER_FREQ;
69 mips_hpt_read = sb1250_hpt_read; 69 clocksource_mips.read = sb1250_hpt_read;
70 mips_hpt_mask = M_SCD_TIMER_INIT; 70 clocksource_mips.mask = M_SCD_TIMER_INIT;
71 } 71 }
72} 72}
73 73
@@ -143,7 +143,7 @@ void sb1250_timer_interrupt(void)
143 * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over 143 * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over
144 * again. 144 * again.
145 */ 145 */
146static unsigned int sb1250_hpt_read(void) 146static cycle_t sb1250_hpt_read(void)
147{ 147{
148 unsigned int count; 148 unsigned int count;
149 149
diff --git a/arch/mips/sni/irq.c b/arch/mips/sni/irq.c
index 48fb74a7aaec..8511bcc6d99d 100644
--- a/arch/mips/sni/irq.c
+++ b/arch/mips/sni/irq.c
@@ -11,44 +11,25 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/spinlock.h>
15 14
16#include <asm/i8259.h> 15#include <asm/i8259.h>
17#include <asm/io.h> 16#include <asm/io.h>
18#include <asm/sni.h> 17#include <asm/sni.h>
19 18
20DEFINE_SPINLOCK(pciasic_lock);
21
22static void enable_pciasic_irq(unsigned int irq) 19static void enable_pciasic_irq(unsigned int irq)
23{ 20{
24 unsigned int mask = 1 << (irq - PCIMT_IRQ_INT2); 21 unsigned int mask = 1 << (irq - PCIMT_IRQ_INT2);
25 unsigned long flags;
26 22
27 spin_lock_irqsave(&pciasic_lock, flags);
28 *(volatile u8 *) PCIMT_IRQSEL |= mask; 23 *(volatile u8 *) PCIMT_IRQSEL |= mask;
29 spin_unlock_irqrestore(&pciasic_lock, flags);
30}
31
32static unsigned int startup_pciasic_irq(unsigned int irq)
33{
34 enable_pciasic_irq(irq);
35 return 0; /* never anything pending */
36} 24}
37 25
38#define shutdown_pciasic_irq disable_pciasic_irq
39
40void disable_pciasic_irq(unsigned int irq) 26void disable_pciasic_irq(unsigned int irq)
41{ 27{
42 unsigned int mask = ~(1 << (irq - PCIMT_IRQ_INT2)); 28 unsigned int mask = ~(1 << (irq - PCIMT_IRQ_INT2));
43 unsigned long flags;
44 29
45 spin_lock_irqsave(&pciasic_lock, flags);
46 *(volatile u8 *) PCIMT_IRQSEL &= mask; 30 *(volatile u8 *) PCIMT_IRQSEL &= mask;
47 spin_unlock_irqrestore(&pciasic_lock, flags);
48} 31}
49 32
50#define mask_and_ack_pciasic_irq disable_pciasic_irq
51
52static void end_pciasic_irq(unsigned int irq) 33static void end_pciasic_irq(unsigned int irq)
53{ 34{
54 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 35 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
@@ -57,11 +38,10 @@ static void end_pciasic_irq(unsigned int irq)
57 38
58static struct irq_chip pciasic_irq_type = { 39static struct irq_chip pciasic_irq_type = {
59 .typename = "ASIC-PCI", 40 .typename = "ASIC-PCI",
60 .startup = startup_pciasic_irq, 41 .ack = disable_pciasic_irq,
61 .shutdown = shutdown_pciasic_irq, 42 .mask = disable_pciasic_irq,
62 .enable = enable_pciasic_irq, 43 .mask_ack = disable_pciasic_irq,
63 .disable = disable_pciasic_irq, 44 .unmask = enable_pciasic_irq,
64 .ack = mask_and_ack_pciasic_irq,
65 .end = end_pciasic_irq, 45 .end = end_pciasic_irq,
66}; 46};
67 47
@@ -178,12 +158,8 @@ asmlinkage void plat_irq_dispatch(void)
178 158
179void __init init_pciasic(void) 159void __init init_pciasic(void)
180{ 160{
181 unsigned long flags;
182
183 spin_lock_irqsave(&pciasic_lock, flags);
184 * (volatile u8 *) PCIMT_IRQSEL = 161 * (volatile u8 *) PCIMT_IRQSEL =
185 IT_EISA | IT_INTA | IT_INTB | IT_INTC | IT_INTD; 162 IT_EISA | IT_INTA | IT_INTB | IT_INTC | IT_INTD;
186 spin_unlock_irqrestore(&pciasic_lock, flags);
187} 163}
188 164
189/* 165/*
@@ -199,12 +175,8 @@ void __init arch_init_irq(void)
199 init_pciasic(); 175 init_pciasic();
200 176
201 /* Actually we've got more interrupts to handle ... */ 177 /* Actually we've got more interrupts to handle ... */
202 for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_ETHERNET; i++) { 178 for (i = PCIMT_IRQ_INT2; i <= PCIMT_IRQ_ETHERNET; i++)
203 irq_desc[i].status = IRQ_DISABLED; 179 set_irq_chip(i, &pciasic_irq_type);
204 irq_desc[i].action = 0;
205 irq_desc[i].depth = 1;
206 irq_desc[i].chip = &pciasic_irq_type;
207 }
208 180
209 change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ2|IE_IRQ3|IE_IRQ4); 181 change_c0_status(ST0_IM, IE_IRQ1|IE_IRQ2|IE_IRQ3|IE_IRQ4);
210} 182}
diff --git a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
index 8266a88a3f88..21873de49aa8 100644
--- a/arch/mips/tx4927/common/tx4927_irq.c
+++ b/arch/mips/tx4927/common/tx4927_irq.c
@@ -64,19 +64,13 @@
64#define TX4927_IRQ_NEST4 ( 1 << 9 ) 64#define TX4927_IRQ_NEST4 ( 1 << 9 )
65 65
66#define TX4927_IRQ_CP0_INIT ( 1 << 10 ) 66#define TX4927_IRQ_CP0_INIT ( 1 << 10 )
67#define TX4927_IRQ_CP0_STARTUP ( 1 << 11 )
68#define TX4927_IRQ_CP0_SHUTDOWN ( 1 << 12 )
69#define TX4927_IRQ_CP0_ENABLE ( 1 << 13 ) 67#define TX4927_IRQ_CP0_ENABLE ( 1 << 13 )
70#define TX4927_IRQ_CP0_DISABLE ( 1 << 14 ) 68#define TX4927_IRQ_CP0_DISABLE ( 1 << 14 )
71#define TX4927_IRQ_CP0_MASK ( 1 << 15 )
72#define TX4927_IRQ_CP0_ENDIRQ ( 1 << 16 ) 69#define TX4927_IRQ_CP0_ENDIRQ ( 1 << 16 )
73 70
74#define TX4927_IRQ_PIC_INIT ( 1 << 20 ) 71#define TX4927_IRQ_PIC_INIT ( 1 << 20 )
75#define TX4927_IRQ_PIC_STARTUP ( 1 << 21 )
76#define TX4927_IRQ_PIC_SHUTDOWN ( 1 << 22 )
77#define TX4927_IRQ_PIC_ENABLE ( 1 << 23 ) 72#define TX4927_IRQ_PIC_ENABLE ( 1 << 23 )
78#define TX4927_IRQ_PIC_DISABLE ( 1 << 24 ) 73#define TX4927_IRQ_PIC_DISABLE ( 1 << 24 )
79#define TX4927_IRQ_PIC_MASK ( 1 << 25 )
80#define TX4927_IRQ_PIC_ENDIRQ ( 1 << 26 ) 74#define TX4927_IRQ_PIC_ENDIRQ ( 1 << 26 )
81 75
82#define TX4927_IRQ_ALL 0xffffffff 76#define TX4927_IRQ_ALL 0xffffffff
@@ -87,18 +81,12 @@ static const u32 tx4927_irq_debug_flag = (TX4927_IRQ_NONE
87 | TX4927_IRQ_INFO 81 | TX4927_IRQ_INFO
88 | TX4927_IRQ_WARN | TX4927_IRQ_EROR 82 | TX4927_IRQ_WARN | TX4927_IRQ_EROR
89// | TX4927_IRQ_CP0_INIT 83// | TX4927_IRQ_CP0_INIT
90// | TX4927_IRQ_CP0_STARTUP
91// | TX4927_IRQ_CP0_SHUTDOWN
92// | TX4927_IRQ_CP0_ENABLE 84// | TX4927_IRQ_CP0_ENABLE
93// | TX4927_IRQ_CP0_DISABLE 85// | TX4927_IRQ_CP0_DISABLE
94// | TX4927_IRQ_CP0_MASK
95// | TX4927_IRQ_CP0_ENDIRQ 86// | TX4927_IRQ_CP0_ENDIRQ
96// | TX4927_IRQ_PIC_INIT 87// | TX4927_IRQ_PIC_INIT
97// | TX4927_IRQ_PIC_STARTUP
98// | TX4927_IRQ_PIC_SHUTDOWN
99// | TX4927_IRQ_PIC_ENABLE 88// | TX4927_IRQ_PIC_ENABLE
100// | TX4927_IRQ_PIC_DISABLE 89// | TX4927_IRQ_PIC_DISABLE
101// | TX4927_IRQ_PIC_MASK
102// | TX4927_IRQ_PIC_ENDIRQ 90// | TX4927_IRQ_PIC_ENDIRQ
103// | TX4927_IRQ_INIT 91// | TX4927_IRQ_INIT
104// | TX4927_IRQ_NEST1 92// | TX4927_IRQ_NEST1
@@ -124,49 +112,36 @@ static const u32 tx4927_irq_debug_flag = (TX4927_IRQ_NONE
124 * Forwad definitions for all pic's 112 * Forwad definitions for all pic's
125 */ 113 */
126 114
127static unsigned int tx4927_irq_cp0_startup(unsigned int irq);
128static void tx4927_irq_cp0_shutdown(unsigned int irq);
129static void tx4927_irq_cp0_enable(unsigned int irq); 115static void tx4927_irq_cp0_enable(unsigned int irq);
130static void tx4927_irq_cp0_disable(unsigned int irq); 116static void tx4927_irq_cp0_disable(unsigned int irq);
131static void tx4927_irq_cp0_mask_and_ack(unsigned int irq);
132static void tx4927_irq_cp0_end(unsigned int irq); 117static void tx4927_irq_cp0_end(unsigned int irq);
133 118
134static unsigned int tx4927_irq_pic_startup(unsigned int irq);
135static void tx4927_irq_pic_shutdown(unsigned int irq);
136static void tx4927_irq_pic_enable(unsigned int irq); 119static void tx4927_irq_pic_enable(unsigned int irq);
137static void tx4927_irq_pic_disable(unsigned int irq); 120static void tx4927_irq_pic_disable(unsigned int irq);
138static void tx4927_irq_pic_mask_and_ack(unsigned int irq);
139static void tx4927_irq_pic_end(unsigned int irq); 121static void tx4927_irq_pic_end(unsigned int irq);
140 122
141/* 123/*
142 * Kernel structs for all pic's 124 * Kernel structs for all pic's
143 */ 125 */
144 126
145static DEFINE_SPINLOCK(tx4927_cp0_lock);
146static DEFINE_SPINLOCK(tx4927_pic_lock);
147
148#define TX4927_CP0_NAME "TX4927-CP0" 127#define TX4927_CP0_NAME "TX4927-CP0"
149static struct irq_chip tx4927_irq_cp0_type = { 128static struct irq_chip tx4927_irq_cp0_type = {
150 .typename = TX4927_CP0_NAME, 129 .typename = TX4927_CP0_NAME,
151 .startup = tx4927_irq_cp0_startup, 130 .ack = tx4927_irq_cp0_disable,
152 .shutdown = tx4927_irq_cp0_shutdown, 131 .mask = tx4927_irq_cp0_disable,
153 .enable = tx4927_irq_cp0_enable, 132 .mask_ack = tx4927_irq_cp0_disable,
154 .disable = tx4927_irq_cp0_disable, 133 .unmask = tx4927_irq_cp0_enable,
155 .ack = tx4927_irq_cp0_mask_and_ack,
156 .end = tx4927_irq_cp0_end, 134 .end = tx4927_irq_cp0_end,
157 .set_affinity = NULL
158}; 135};
159 136
160#define TX4927_PIC_NAME "TX4927-PIC" 137#define TX4927_PIC_NAME "TX4927-PIC"
161static struct irq_chip tx4927_irq_pic_type = { 138static struct irq_chip tx4927_irq_pic_type = {
162 .typename = TX4927_PIC_NAME, 139 .typename = TX4927_PIC_NAME,
163 .startup = tx4927_irq_pic_startup, 140 .ack = tx4927_irq_pic_disable,
164 .shutdown = tx4927_irq_pic_shutdown, 141 .mask = tx4927_irq_pic_disable,
165 .enable = tx4927_irq_pic_enable, 142 .mask_ack = tx4927_irq_pic_disable,
166 .disable = tx4927_irq_pic_disable, 143 .unmask = tx4927_irq_pic_enable,
167 .ack = tx4927_irq_pic_mask_and_ack,
168 .end = tx4927_irq_pic_end, 144 .end = tx4927_irq_pic_end,
169 .set_affinity = NULL
170}; 145};
171 146
172#define TX4927_PIC_ACTION(s) { no_action, 0, CPU_MASK_NONE, s, NULL, NULL } 147#define TX4927_PIC_ACTION(s) { no_action, 0, CPU_MASK_NONE, s, NULL, NULL }
@@ -211,8 +186,6 @@ tx4927_irq_cp0_modify(unsigned cp0_reg, unsigned clr_bits, unsigned set_bits)
211 break; 186 break;
212 } 187 }
213 } 188 }
214
215 return;
216} 189}
217 190
218static void __init tx4927_irq_cp0_init(void) 191static void __init tx4927_irq_cp0_init(void)
@@ -222,71 +195,23 @@ static void __init tx4927_irq_cp0_init(void)
222 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_INIT, "beg=%d end=%d\n", 195 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_INIT, "beg=%d end=%d\n",
223 TX4927_IRQ_CP0_BEG, TX4927_IRQ_CP0_END); 196 TX4927_IRQ_CP0_BEG, TX4927_IRQ_CP0_END);
224 197
225 for (i = TX4927_IRQ_CP0_BEG; i <= TX4927_IRQ_CP0_END; i++) { 198 for (i = TX4927_IRQ_CP0_BEG; i <= TX4927_IRQ_CP0_END; i++)
226 irq_desc[i].status = IRQ_DISABLED; 199 set_irq_chip_and_handler(i, &tx4927_irq_cp0_type,
227 irq_desc[i].action = 0; 200 handle_level_irq);
228 irq_desc[i].depth = 1;
229 irq_desc[i].chip = &tx4927_irq_cp0_type;
230 }
231
232 return;
233}
234
235static unsigned int tx4927_irq_cp0_startup(unsigned int irq)
236{
237 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_STARTUP, "irq=%d \n", irq);
238
239 tx4927_irq_cp0_enable(irq);
240
241 return (0);
242}
243
244static void tx4927_irq_cp0_shutdown(unsigned int irq)
245{
246 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_SHUTDOWN, "irq=%d \n", irq);
247
248 tx4927_irq_cp0_disable(irq);
249
250 return;
251} 201}
252 202
253static void tx4927_irq_cp0_enable(unsigned int irq) 203static void tx4927_irq_cp0_enable(unsigned int irq)
254{ 204{
255 unsigned long flags;
256
257 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_ENABLE, "irq=%d \n", irq); 205 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_ENABLE, "irq=%d \n", irq);
258 206
259 spin_lock_irqsave(&tx4927_cp0_lock, flags);
260
261 tx4927_irq_cp0_modify(CCP0_STATUS, 0, tx4927_irq_cp0_mask(irq)); 207 tx4927_irq_cp0_modify(CCP0_STATUS, 0, tx4927_irq_cp0_mask(irq));
262
263 spin_unlock_irqrestore(&tx4927_cp0_lock, flags);
264
265 return;
266} 208}
267 209
268static void tx4927_irq_cp0_disable(unsigned int irq) 210static void tx4927_irq_cp0_disable(unsigned int irq)
269{ 211{
270 unsigned long flags;
271
272 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_DISABLE, "irq=%d \n", irq); 212 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_DISABLE, "irq=%d \n", irq);
273 213
274 spin_lock_irqsave(&tx4927_cp0_lock, flags);
275
276 tx4927_irq_cp0_modify(CCP0_STATUS, tx4927_irq_cp0_mask(irq), 0); 214 tx4927_irq_cp0_modify(CCP0_STATUS, tx4927_irq_cp0_mask(irq), 0);
277
278 spin_unlock_irqrestore(&tx4927_cp0_lock, flags);
279
280 return;
281}
282
283static void tx4927_irq_cp0_mask_and_ack(unsigned int irq)
284{
285 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_MASK, "irq=%d \n", irq);
286
287 tx4927_irq_cp0_disable(irq);
288
289 return;
290} 215}
291 216
292static void tx4927_irq_cp0_end(unsigned int irq) 217static void tx4927_irq_cp0_end(unsigned int irq)
@@ -296,8 +221,6 @@ static void tx4927_irq_cp0_end(unsigned int irq)
296 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) { 221 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
297 tx4927_irq_cp0_enable(irq); 222 tx4927_irq_cp0_enable(irq);
298 } 223 }
299
300 return;
301} 224}
302 225
303/* 226/*
@@ -418,94 +341,39 @@ static void tx4927_irq_pic_modify(unsigned pic_reg, unsigned clr_bits,
418 val &= (~clr_bits); 341 val &= (~clr_bits);
419 val |= (set_bits); 342 val |= (set_bits);
420 TX4927_WR(pic_reg, val); 343 TX4927_WR(pic_reg, val);
421
422 return;
423} 344}
424 345
425static void __init tx4927_irq_pic_init(void) 346static void __init tx4927_irq_pic_init(void)
426{ 347{
427 unsigned long flags;
428 int i; 348 int i;
429 349
430 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_INIT, "beg=%d end=%d\n", 350 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_INIT, "beg=%d end=%d\n",
431 TX4927_IRQ_PIC_BEG, TX4927_IRQ_PIC_END); 351 TX4927_IRQ_PIC_BEG, TX4927_IRQ_PIC_END);
432 352
433 for (i = TX4927_IRQ_PIC_BEG; i <= TX4927_IRQ_PIC_END; i++) { 353 for (i = TX4927_IRQ_PIC_BEG; i <= TX4927_IRQ_PIC_END; i++)
434 irq_desc[i].status = IRQ_DISABLED; 354 set_irq_chip_and_handler(i, &tx4927_irq_pic_type,
435 irq_desc[i].action = 0; 355 handle_level_irq);
436 irq_desc[i].depth = 2;
437 irq_desc[i].chip = &tx4927_irq_pic_type;
438 }
439 356
440 setup_irq(TX4927_IRQ_NEST_PIC_ON_CP0, &tx4927_irq_pic_action); 357 setup_irq(TX4927_IRQ_NEST_PIC_ON_CP0, &tx4927_irq_pic_action);
441 358
442 spin_lock_irqsave(&tx4927_pic_lock, flags);
443
444 TX4927_WR(0xff1ff640, 0x6); /* irq level mask -- only accept hightest */ 359 TX4927_WR(0xff1ff640, 0x6); /* irq level mask -- only accept hightest */
445 TX4927_WR(0xff1ff600, TX4927_RD(0xff1ff600) | 0x1); /* irq enable */ 360 TX4927_WR(0xff1ff600, TX4927_RD(0xff1ff600) | 0x1); /* irq enable */
446
447 spin_unlock_irqrestore(&tx4927_pic_lock, flags);
448
449 return;
450}
451
452static unsigned int tx4927_irq_pic_startup(unsigned int irq)
453{
454 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_STARTUP, "irq=%d\n", irq);
455
456 tx4927_irq_pic_enable(irq);
457
458 return (0);
459}
460
461static void tx4927_irq_pic_shutdown(unsigned int irq)
462{
463 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_SHUTDOWN, "irq=%d\n", irq);
464
465 tx4927_irq_pic_disable(irq);
466
467 return;
468} 361}
469 362
470static void tx4927_irq_pic_enable(unsigned int irq) 363static void tx4927_irq_pic_enable(unsigned int irq)
471{ 364{
472 unsigned long flags;
473
474 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_ENABLE, "irq=%d\n", irq); 365 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_ENABLE, "irq=%d\n", irq);
475 366
476 spin_lock_irqsave(&tx4927_pic_lock, flags);
477
478 tx4927_irq_pic_modify(tx4927_irq_pic_addr(irq), 0, 367 tx4927_irq_pic_modify(tx4927_irq_pic_addr(irq), 0,
479 tx4927_irq_pic_mask(irq)); 368 tx4927_irq_pic_mask(irq));
480
481 spin_unlock_irqrestore(&tx4927_pic_lock, flags);
482
483 return;
484} 369}
485 370
486static void tx4927_irq_pic_disable(unsigned int irq) 371static void tx4927_irq_pic_disable(unsigned int irq)
487{ 372{
488 unsigned long flags;
489
490 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_DISABLE, "irq=%d\n", irq); 373 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_DISABLE, "irq=%d\n", irq);
491 374
492 spin_lock_irqsave(&tx4927_pic_lock, flags);
493
494 tx4927_irq_pic_modify(tx4927_irq_pic_addr(irq), 375 tx4927_irq_pic_modify(tx4927_irq_pic_addr(irq),
495 tx4927_irq_pic_mask(irq), 0); 376 tx4927_irq_pic_mask(irq), 0);
496
497 spin_unlock_irqrestore(&tx4927_pic_lock, flags);
498
499 return;
500}
501
502static void tx4927_irq_pic_mask_and_ack(unsigned int irq)
503{
504 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_MASK, "irq=%d\n", irq);
505
506 tx4927_irq_pic_disable(irq);
507
508 return;
509} 377}
510 378
511static void tx4927_irq_pic_end(unsigned int irq) 379static void tx4927_irq_pic_end(unsigned int irq)
@@ -515,8 +383,6 @@ static void tx4927_irq_pic_end(unsigned int irq)
515 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) { 383 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
516 tx4927_irq_pic_enable(irq); 384 tx4927_irq_pic_enable(irq);
517 } 385 }
518
519 return;
520} 386}
521 387
522/* 388/*
@@ -533,8 +399,6 @@ void __init tx4927_irq_init(void)
533 tx4927_irq_pic_init(); 399 tx4927_irq_pic_init();
534 400
535 TX4927_IRQ_DPRINTK(TX4927_IRQ_INIT, "+\n"); 401 TX4927_IRQ_DPRINTK(TX4927_IRQ_INIT, "+\n");
536
537 return;
538} 402}
539 403
540static int tx4927_irq_nested(void) 404static int tx4927_irq_nested(void)
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
index 0c3c3f668230..34cdb2a240e9 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
@@ -151,16 +151,11 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
151#define TOSHIBA_RBTX4927_IRQ_EROR ( 1 << 2 ) 151#define TOSHIBA_RBTX4927_IRQ_EROR ( 1 << 2 )
152 152
153#define TOSHIBA_RBTX4927_IRQ_IOC_INIT ( 1 << 10 ) 153#define TOSHIBA_RBTX4927_IRQ_IOC_INIT ( 1 << 10 )
154#define TOSHIBA_RBTX4927_IRQ_IOC_STARTUP ( 1 << 11 )
155#define TOSHIBA_RBTX4927_IRQ_IOC_SHUTDOWN ( 1 << 12 )
156#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 ) 154#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 )
157#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 ) 155#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 )
158#define TOSHIBA_RBTX4927_IRQ_IOC_MASK ( 1 << 15 )
159#define TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ ( 1 << 16 ) 156#define TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ ( 1 << 16 )
160 157
161#define TOSHIBA_RBTX4927_IRQ_ISA_INIT ( 1 << 20 ) 158#define TOSHIBA_RBTX4927_IRQ_ISA_INIT ( 1 << 20 )
162#define TOSHIBA_RBTX4927_IRQ_ISA_STARTUP ( 1 << 21 )
163#define TOSHIBA_RBTX4927_IRQ_ISA_SHUTDOWN ( 1 << 22 )
164#define TOSHIBA_RBTX4927_IRQ_ISA_ENABLE ( 1 << 23 ) 159#define TOSHIBA_RBTX4927_IRQ_ISA_ENABLE ( 1 << 23 )
165#define TOSHIBA_RBTX4927_IRQ_ISA_DISABLE ( 1 << 24 ) 160#define TOSHIBA_RBTX4927_IRQ_ISA_DISABLE ( 1 << 24 )
166#define TOSHIBA_RBTX4927_IRQ_ISA_MASK ( 1 << 25 ) 161#define TOSHIBA_RBTX4927_IRQ_ISA_MASK ( 1 << 25 )
@@ -175,15 +170,10 @@ static const u32 toshiba_rbtx4927_irq_debug_flag =
175 (TOSHIBA_RBTX4927_IRQ_NONE | TOSHIBA_RBTX4927_IRQ_INFO | 170 (TOSHIBA_RBTX4927_IRQ_NONE | TOSHIBA_RBTX4927_IRQ_INFO |
176 TOSHIBA_RBTX4927_IRQ_WARN | TOSHIBA_RBTX4927_IRQ_EROR 171 TOSHIBA_RBTX4927_IRQ_WARN | TOSHIBA_RBTX4927_IRQ_EROR
177// | TOSHIBA_RBTX4927_IRQ_IOC_INIT 172// | TOSHIBA_RBTX4927_IRQ_IOC_INIT
178// | TOSHIBA_RBTX4927_IRQ_IOC_STARTUP
179// | TOSHIBA_RBTX4927_IRQ_IOC_SHUTDOWN
180// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE 173// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE
181// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE 174// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE
182// | TOSHIBA_RBTX4927_IRQ_IOC_MASK
183// | TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ 175// | TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ
184// | TOSHIBA_RBTX4927_IRQ_ISA_INIT 176// | TOSHIBA_RBTX4927_IRQ_ISA_INIT
185// | TOSHIBA_RBTX4927_IRQ_ISA_STARTUP
186// | TOSHIBA_RBTX4927_IRQ_ISA_SHUTDOWN
187// | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE 177// | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE
188// | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE 178// | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE
189// | TOSHIBA_RBTX4927_IRQ_ISA_MASK 179// | TOSHIBA_RBTX4927_IRQ_ISA_MASK
@@ -231,35 +221,25 @@ extern void disable_8259A_irq(unsigned int irq);
231extern void mask_and_ack_8259A(unsigned int irq); 221extern void mask_and_ack_8259A(unsigned int irq);
232#endif 222#endif
233 223
234static unsigned int toshiba_rbtx4927_irq_ioc_startup(unsigned int irq);
235static void toshiba_rbtx4927_irq_ioc_shutdown(unsigned int irq);
236static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq); 224static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq);
237static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq); 225static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq);
238static void toshiba_rbtx4927_irq_ioc_mask_and_ack(unsigned int irq);
239static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq); 226static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq);
240 227
241#ifdef CONFIG_TOSHIBA_FPCIB0 228#ifdef CONFIG_TOSHIBA_FPCIB0
242static unsigned int toshiba_rbtx4927_irq_isa_startup(unsigned int irq);
243static void toshiba_rbtx4927_irq_isa_shutdown(unsigned int irq);
244static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq); 229static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq);
245static void toshiba_rbtx4927_irq_isa_disable(unsigned int irq); 230static void toshiba_rbtx4927_irq_isa_disable(unsigned int irq);
246static void toshiba_rbtx4927_irq_isa_mask_and_ack(unsigned int irq); 231static void toshiba_rbtx4927_irq_isa_mask_and_ack(unsigned int irq);
247static void toshiba_rbtx4927_irq_isa_end(unsigned int irq); 232static void toshiba_rbtx4927_irq_isa_end(unsigned int irq);
248#endif 233#endif
249 234
250static DEFINE_SPINLOCK(toshiba_rbtx4927_ioc_lock);
251
252
253#define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC" 235#define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC"
254static struct irq_chip toshiba_rbtx4927_irq_ioc_type = { 236static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
255 .typename = TOSHIBA_RBTX4927_IOC_NAME, 237 .typename = TOSHIBA_RBTX4927_IOC_NAME,
256 .startup = toshiba_rbtx4927_irq_ioc_startup, 238 .ack = toshiba_rbtx4927_irq_ioc_disable,
257 .shutdown = toshiba_rbtx4927_irq_ioc_shutdown, 239 .mask = toshiba_rbtx4927_irq_ioc_disable,
258 .enable = toshiba_rbtx4927_irq_ioc_enable, 240 .mask_ack = toshiba_rbtx4927_irq_ioc_disable,
259 .disable = toshiba_rbtx4927_irq_ioc_disable, 241 .unmask = toshiba_rbtx4927_irq_ioc_enable,
260 .ack = toshiba_rbtx4927_irq_ioc_mask_and_ack,
261 .end = toshiba_rbtx4927_irq_ioc_end, 242 .end = toshiba_rbtx4927_irq_ioc_end,
262 .set_affinity = NULL
263}; 243};
264#define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000 244#define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000
265#define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006 245#define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006
@@ -269,13 +249,11 @@ static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
269#define TOSHIBA_RBTX4927_ISA_NAME "RBTX4927-ISA" 249#define TOSHIBA_RBTX4927_ISA_NAME "RBTX4927-ISA"
270static struct irq_chip toshiba_rbtx4927_irq_isa_type = { 250static struct irq_chip toshiba_rbtx4927_irq_isa_type = {
271 .typename = TOSHIBA_RBTX4927_ISA_NAME, 251 .typename = TOSHIBA_RBTX4927_ISA_NAME,
272 .startup = toshiba_rbtx4927_irq_isa_startup,
273 .shutdown = toshiba_rbtx4927_irq_isa_shutdown,
274 .enable = toshiba_rbtx4927_irq_isa_enable,
275 .disable = toshiba_rbtx4927_irq_isa_disable,
276 .ack = toshiba_rbtx4927_irq_isa_mask_and_ack, 252 .ack = toshiba_rbtx4927_irq_isa_mask_and_ack,
253 .mask = toshiba_rbtx4927_irq_isa_disable,
254 .mask_ack = toshiba_rbtx4927_irq_isa_mask_and_ack,
255 .unmask = toshiba_rbtx4927_irq_isa_enable,
277 .end = toshiba_rbtx4927_irq_isa_end, 256 .end = toshiba_rbtx4927_irq_isa_end,
278 .set_affinity = NULL
279}; 257};
280#endif 258#endif
281 259
@@ -363,58 +341,16 @@ static void __init toshiba_rbtx4927_irq_ioc_init(void)
363 TOSHIBA_RBTX4927_IRQ_IOC_END); 341 TOSHIBA_RBTX4927_IRQ_IOC_END);
364 342
365 for (i = TOSHIBA_RBTX4927_IRQ_IOC_BEG; 343 for (i = TOSHIBA_RBTX4927_IRQ_IOC_BEG;
366 i <= TOSHIBA_RBTX4927_IRQ_IOC_END; i++) { 344 i <= TOSHIBA_RBTX4927_IRQ_IOC_END; i++)
367 irq_desc[i].status = IRQ_DISABLED; 345 set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_ioc_type,
368 irq_desc[i].action = 0; 346 handle_level_irq);
369 irq_desc[i].depth = 3;
370 irq_desc[i].chip = &toshiba_rbtx4927_irq_ioc_type;
371 }
372 347
373 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC, 348 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC,
374 &toshiba_rbtx4927_irq_ioc_action); 349 &toshiba_rbtx4927_irq_ioc_action);
375
376 return;
377} 350}
378 351
379static unsigned int toshiba_rbtx4927_irq_ioc_startup(unsigned int irq)
380{
381 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_STARTUP,
382 "irq=%d\n", irq);
383
384 if (irq < TOSHIBA_RBTX4927_IRQ_IOC_BEG
385 || irq > TOSHIBA_RBTX4927_IRQ_IOC_END) {
386 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
387 "bad irq=%d\n", irq);
388 panic("\n");
389 }
390
391 toshiba_rbtx4927_irq_ioc_enable(irq);
392
393 return (0);
394}
395
396
397static void toshiba_rbtx4927_irq_ioc_shutdown(unsigned int irq)
398{
399 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_SHUTDOWN,
400 "irq=%d\n", irq);
401
402 if (irq < TOSHIBA_RBTX4927_IRQ_IOC_BEG
403 || irq > TOSHIBA_RBTX4927_IRQ_IOC_END) {
404 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
405 "bad irq=%d\n", irq);
406 panic("\n");
407 }
408
409 toshiba_rbtx4927_irq_ioc_disable(irq);
410
411 return;
412}
413
414
415static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq) 352static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq)
416{ 353{
417 unsigned long flags;
418 volatile unsigned char v; 354 volatile unsigned char v;
419 355
420 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_ENABLE, 356 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_ENABLE,
@@ -427,21 +363,14 @@ static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq)
427 panic("\n"); 363 panic("\n");
428 } 364 }
429 365
430 spin_lock_irqsave(&toshiba_rbtx4927_ioc_lock, flags);
431
432 v = TX4927_RD08(TOSHIBA_RBTX4927_IOC_INTR_ENAB); 366 v = TX4927_RD08(TOSHIBA_RBTX4927_IOC_INTR_ENAB);
433 v |= (1 << (irq - TOSHIBA_RBTX4927_IRQ_IOC_BEG)); 367 v |= (1 << (irq - TOSHIBA_RBTX4927_IRQ_IOC_BEG));
434 TOSHIBA_RBTX4927_WR08(TOSHIBA_RBTX4927_IOC_INTR_ENAB, v); 368 TOSHIBA_RBTX4927_WR08(TOSHIBA_RBTX4927_IOC_INTR_ENAB, v);
435
436 spin_unlock_irqrestore(&toshiba_rbtx4927_ioc_lock, flags);
437
438 return;
439} 369}
440 370
441 371
442static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq) 372static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
443{ 373{
444 unsigned long flags;
445 volatile unsigned char v; 374 volatile unsigned char v;
446 375
447 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_DISABLE, 376 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_DISABLE,
@@ -454,36 +383,11 @@ static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
454 panic("\n"); 383 panic("\n");
455 } 384 }
456 385
457 spin_lock_irqsave(&toshiba_rbtx4927_ioc_lock, flags);
458
459 v = TX4927_RD08(TOSHIBA_RBTX4927_IOC_INTR_ENAB); 386 v = TX4927_RD08(TOSHIBA_RBTX4927_IOC_INTR_ENAB);
460 v &= ~(1 << (irq - TOSHIBA_RBTX4927_IRQ_IOC_BEG)); 387 v &= ~(1 << (irq - TOSHIBA_RBTX4927_IRQ_IOC_BEG));
461 TOSHIBA_RBTX4927_WR08(TOSHIBA_RBTX4927_IOC_INTR_ENAB, v); 388 TOSHIBA_RBTX4927_WR08(TOSHIBA_RBTX4927_IOC_INTR_ENAB, v);
462
463 spin_unlock_irqrestore(&toshiba_rbtx4927_ioc_lock, flags);
464
465 return;
466} 389}
467 390
468
469static void toshiba_rbtx4927_irq_ioc_mask_and_ack(unsigned int irq)
470{
471 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_MASK,
472 "irq=%d\n", irq);
473
474 if (irq < TOSHIBA_RBTX4927_IRQ_IOC_BEG
475 || irq > TOSHIBA_RBTX4927_IRQ_IOC_END) {
476 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
477 "bad irq=%d\n", irq);
478 panic("\n");
479 }
480
481 toshiba_rbtx4927_irq_ioc_disable(irq);
482
483 return;
484}
485
486
487static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq) 391static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq)
488{ 392{
489 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ, 393 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ,
@@ -499,8 +403,6 @@ static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq)
499 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) { 403 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
500 toshiba_rbtx4927_irq_ioc_enable(irq); 404 toshiba_rbtx4927_irq_ioc_enable(irq);
501 } 405 }
502
503 return;
504} 406}
505 407
506 408
@@ -520,13 +422,8 @@ static void __init toshiba_rbtx4927_irq_isa_init(void)
520 TOSHIBA_RBTX4927_IRQ_ISA_END); 422 TOSHIBA_RBTX4927_IRQ_ISA_END);
521 423
522 for (i = TOSHIBA_RBTX4927_IRQ_ISA_BEG; 424 for (i = TOSHIBA_RBTX4927_IRQ_ISA_BEG;
523 i <= TOSHIBA_RBTX4927_IRQ_ISA_END; i++) { 425 i <= TOSHIBA_RBTX4927_IRQ_ISA_END; i++)
524 irq_desc[i].status = IRQ_DISABLED; 426 set_irq_chip(i, &toshiba_rbtx4927_irq_isa_type);
525 irq_desc[i].action = 0;
526 irq_desc[i].depth =
527 ((i < TOSHIBA_RBTX4927_IRQ_ISA_MID) ? (4) : (5));
528 irq_desc[i].chip = &toshiba_rbtx4927_irq_isa_type;
529 }
530 427
531 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC, 428 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC,
532 &toshiba_rbtx4927_irq_isa_master); 429 &toshiba_rbtx4927_irq_isa_master);
@@ -536,48 +433,6 @@ static void __init toshiba_rbtx4927_irq_isa_init(void)
536 /* make sure we are looking at IRR (not ISR) */ 433 /* make sure we are looking at IRR (not ISR) */
537 outb(0x0A, 0x20); 434 outb(0x0A, 0x20);
538 outb(0x0A, 0xA0); 435 outb(0x0A, 0xA0);
539
540 return;
541}
542#endif
543
544
545#ifdef CONFIG_TOSHIBA_FPCIB0
546static unsigned int toshiba_rbtx4927_irq_isa_startup(unsigned int irq)
547{
548 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_ISA_STARTUP,
549 "irq=%d\n", irq);
550
551 if (irq < TOSHIBA_RBTX4927_IRQ_ISA_BEG
552 || irq > TOSHIBA_RBTX4927_IRQ_ISA_END) {
553 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
554 "bad irq=%d\n", irq);
555 panic("\n");
556 }
557
558 toshiba_rbtx4927_irq_isa_enable(irq);
559
560 return (0);
561}
562#endif
563
564
565#ifdef CONFIG_TOSHIBA_FPCIB0
566static void toshiba_rbtx4927_irq_isa_shutdown(unsigned int irq)
567{
568 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_ISA_SHUTDOWN,
569 "irq=%d\n", irq);
570
571 if (irq < TOSHIBA_RBTX4927_IRQ_ISA_BEG
572 || irq > TOSHIBA_RBTX4927_IRQ_ISA_END) {
573 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
574 "bad irq=%d\n", irq);
575 panic("\n");
576 }
577
578 toshiba_rbtx4927_irq_isa_disable(irq);
579
580 return;
581} 436}
582#endif 437#endif
583 438
@@ -596,8 +451,6 @@ static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq)
596 } 451 }
597 452
598 enable_8259A_irq(irq); 453 enable_8259A_irq(irq);
599
600 return;
601} 454}
602#endif 455#endif
603 456
@@ -616,8 +469,6 @@ static void toshiba_rbtx4927_irq_isa_disable(unsigned int irq)
616 } 469 }
617 470
618 disable_8259A_irq(irq); 471 disable_8259A_irq(irq);
619
620 return;
621} 472}
622#endif 473#endif
623 474
@@ -636,8 +487,6 @@ static void toshiba_rbtx4927_irq_isa_mask_and_ack(unsigned int irq)
636 } 487 }
637 488
638 mask_and_ack_8259A(irq); 489 mask_and_ack_8259A(irq);
639
640 return;
641} 490}
642#endif 491#endif
643 492
@@ -658,8 +507,6 @@ static void toshiba_rbtx4927_irq_isa_end(unsigned int irq)
658 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) { 507 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
659 toshiba_rbtx4927_irq_isa_enable(irq); 508 toshiba_rbtx4927_irq_isa_enable(irq);
660 } 509 }
661
662 return;
663} 510}
664#endif 511#endif
665 512
@@ -668,8 +515,6 @@ void __init arch_init_irq(void)
668{ 515{
669 extern void tx4927_irq_init(void); 516 extern void tx4927_irq_init(void);
670 517
671 local_irq_disable();
672
673 tx4927_irq_init(); 518 tx4927_irq_init();
674 toshiba_rbtx4927_irq_ioc_init(); 519 toshiba_rbtx4927_irq_ioc_init();
675#ifdef CONFIG_TOSHIBA_FPCIB0 520#ifdef CONFIG_TOSHIBA_FPCIB0
@@ -681,8 +526,6 @@ void __init arch_init_irq(void)
681#endif 526#endif
682 527
683 wbflush(); 528 wbflush();
684
685 return;
686} 529}
687 530
688void toshiba_rbtx4927_irq_dump(char *key) 531void toshiba_rbtx4927_irq_dump(char *key)
@@ -715,7 +558,6 @@ void toshiba_rbtx4927_irq_dump(char *key)
715 } 558 }
716 } 559 }
717#endif 560#endif
718 return;
719} 561}
720 562
721void toshiba_rbtx4927_irq_dump_pics(char *s) 563void toshiba_rbtx4927_irq_dump_pics(char *s)
@@ -780,6 +622,4 @@ void toshiba_rbtx4927_irq_dump_pics(char *s)
780 level5_s); 622 level5_s);
781 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO, "[%s]\n", 623 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO, "[%s]\n",
782 s); 624 s);
783
784 return;
785} 625}
diff --git a/arch/mips/tx4938/common/irq.c b/arch/mips/tx4938/common/irq.c
index 77fe2454f5b9..42e127683ae9 100644
--- a/arch/mips/tx4938/common/irq.c
+++ b/arch/mips/tx4938/common/irq.c
@@ -37,48 +37,36 @@
37/* Forwad definitions for all pic's */ 37/* Forwad definitions for all pic's */
38/**********************************************************************************/ 38/**********************************************************************************/
39 39
40static unsigned int tx4938_irq_cp0_startup(unsigned int irq);
41static void tx4938_irq_cp0_shutdown(unsigned int irq);
42static void tx4938_irq_cp0_enable(unsigned int irq); 40static void tx4938_irq_cp0_enable(unsigned int irq);
43static void tx4938_irq_cp0_disable(unsigned int irq); 41static void tx4938_irq_cp0_disable(unsigned int irq);
44static void tx4938_irq_cp0_mask_and_ack(unsigned int irq);
45static void tx4938_irq_cp0_end(unsigned int irq); 42static void tx4938_irq_cp0_end(unsigned int irq);
46 43
47static unsigned int tx4938_irq_pic_startup(unsigned int irq);
48static void tx4938_irq_pic_shutdown(unsigned int irq);
49static void tx4938_irq_pic_enable(unsigned int irq); 44static void tx4938_irq_pic_enable(unsigned int irq);
50static void tx4938_irq_pic_disable(unsigned int irq); 45static void tx4938_irq_pic_disable(unsigned int irq);
51static void tx4938_irq_pic_mask_and_ack(unsigned int irq);
52static void tx4938_irq_pic_end(unsigned int irq); 46static void tx4938_irq_pic_end(unsigned int irq);
53 47
54/**********************************************************************************/ 48/**********************************************************************************/
55/* Kernel structs for all pic's */ 49/* Kernel structs for all pic's */
56/**********************************************************************************/ 50/**********************************************************************************/
57DEFINE_SPINLOCK(tx4938_cp0_lock);
58DEFINE_SPINLOCK(tx4938_pic_lock);
59 51
60#define TX4938_CP0_NAME "TX4938-CP0" 52#define TX4938_CP0_NAME "TX4938-CP0"
61static struct irq_chip tx4938_irq_cp0_type = { 53static struct irq_chip tx4938_irq_cp0_type = {
62 .typename = TX4938_CP0_NAME, 54 .typename = TX4938_CP0_NAME,
63 .startup = tx4938_irq_cp0_startup, 55 .ack = tx4938_irq_cp0_disable,
64 .shutdown = tx4938_irq_cp0_shutdown, 56 .mask = tx4938_irq_cp0_disable,
65 .enable = tx4938_irq_cp0_enable, 57 .mask_ack = tx4938_irq_cp0_disable,
66 .disable = tx4938_irq_cp0_disable, 58 .unmask = tx4938_irq_cp0_enable,
67 .ack = tx4938_irq_cp0_mask_and_ack,
68 .end = tx4938_irq_cp0_end, 59 .end = tx4938_irq_cp0_end,
69 .set_affinity = NULL
70}; 60};
71 61
72#define TX4938_PIC_NAME "TX4938-PIC" 62#define TX4938_PIC_NAME "TX4938-PIC"
73static struct irq_chip tx4938_irq_pic_type = { 63static struct irq_chip tx4938_irq_pic_type = {
74 .typename = TX4938_PIC_NAME, 64 .typename = TX4938_PIC_NAME,
75 .startup = tx4938_irq_pic_startup, 65 .ack = tx4938_irq_pic_disable,
76 .shutdown = tx4938_irq_pic_shutdown, 66 .mask = tx4938_irq_pic_disable,
77 .enable = tx4938_irq_pic_enable, 67 .mask_ack = tx4938_irq_pic_disable,
78 .disable = tx4938_irq_pic_disable, 68 .unmask = tx4938_irq_pic_enable,
79 .ack = tx4938_irq_pic_mask_and_ack,
80 .end = tx4938_irq_pic_end, 69 .end = tx4938_irq_pic_end,
81 .set_affinity = NULL
82}; 70};
83 71
84static struct irqaction tx4938_irq_pic_action = { 72static struct irqaction tx4938_irq_pic_action = {
@@ -99,56 +87,21 @@ tx4938_irq_cp0_init(void)
99{ 87{
100 int i; 88 int i;
101 89
102 for (i = TX4938_IRQ_CP0_BEG; i <= TX4938_IRQ_CP0_END; i++) { 90 for (i = TX4938_IRQ_CP0_BEG; i <= TX4938_IRQ_CP0_END; i++)
103 irq_desc[i].status = IRQ_DISABLED; 91 set_irq_chip_and_handler(i, &tx4938_irq_cp0_type,
104 irq_desc[i].action = 0; 92 handle_level_irq);
105 irq_desc[i].depth = 1;
106 irq_desc[i].chip = &tx4938_irq_cp0_type;
107 }
108}
109
110static unsigned int
111tx4938_irq_cp0_startup(unsigned int irq)
112{
113 tx4938_irq_cp0_enable(irq);
114
115 return 0;
116}
117
118static void
119tx4938_irq_cp0_shutdown(unsigned int irq)
120{
121 tx4938_irq_cp0_disable(irq);
122} 93}
123 94
124static void 95static void
125tx4938_irq_cp0_enable(unsigned int irq) 96tx4938_irq_cp0_enable(unsigned int irq)
126{ 97{
127 unsigned long flags;
128
129 spin_lock_irqsave(&tx4938_cp0_lock, flags);
130
131 set_c0_status(tx4938_irq_cp0_mask(irq)); 98 set_c0_status(tx4938_irq_cp0_mask(irq));
132
133 spin_unlock_irqrestore(&tx4938_cp0_lock, flags);
134} 99}
135 100
136static void 101static void
137tx4938_irq_cp0_disable(unsigned int irq) 102tx4938_irq_cp0_disable(unsigned int irq)
138{ 103{
139 unsigned long flags;
140
141 spin_lock_irqsave(&tx4938_cp0_lock, flags);
142
143 clear_c0_status(tx4938_irq_cp0_mask(irq)); 104 clear_c0_status(tx4938_irq_cp0_mask(irq));
144
145 spin_unlock_irqrestore(&tx4938_cp0_lock, flags);
146}
147
148static void
149tx4938_irq_cp0_mask_and_ack(unsigned int irq)
150{
151 tx4938_irq_cp0_disable(irq);
152} 105}
153 106
154static void 107static void
@@ -290,70 +243,30 @@ tx4938_irq_pic_modify(unsigned pic_reg, unsigned clr_bits, unsigned set_bits)
290static void __init 243static void __init
291tx4938_irq_pic_init(void) 244tx4938_irq_pic_init(void)
292{ 245{
293 unsigned long flags;
294 int i; 246 int i;
295 247
296 for (i = TX4938_IRQ_PIC_BEG; i <= TX4938_IRQ_PIC_END; i++) { 248 for (i = TX4938_IRQ_PIC_BEG; i <= TX4938_IRQ_PIC_END; i++)
297 irq_desc[i].status = IRQ_DISABLED; 249 set_irq_chip_and_handler(i, &tx4938_irq_pic_type,
298 irq_desc[i].action = 0; 250 handle_level_irq);
299 irq_desc[i].depth = 2;
300 irq_desc[i].chip = &tx4938_irq_pic_type;
301 }
302 251
303 setup_irq(TX4938_IRQ_NEST_PIC_ON_CP0, &tx4938_irq_pic_action); 252 setup_irq(TX4938_IRQ_NEST_PIC_ON_CP0, &tx4938_irq_pic_action);
304 253
305 spin_lock_irqsave(&tx4938_pic_lock, flags);
306
307 TX4938_WR(0xff1ff640, 0x6); /* irq level mask -- only accept hightest */ 254 TX4938_WR(0xff1ff640, 0x6); /* irq level mask -- only accept hightest */
308 TX4938_WR(0xff1ff600, TX4938_RD(0xff1ff600) | 0x1); /* irq enable */ 255 TX4938_WR(0xff1ff600, TX4938_RD(0xff1ff600) | 0x1); /* irq enable */
309
310 spin_unlock_irqrestore(&tx4938_pic_lock, flags);
311}
312
313static unsigned int
314tx4938_irq_pic_startup(unsigned int irq)
315{
316 tx4938_irq_pic_enable(irq);
317
318 return 0;
319}
320
321static void
322tx4938_irq_pic_shutdown(unsigned int irq)
323{
324 tx4938_irq_pic_disable(irq);
325} 256}
326 257
327static void 258static void
328tx4938_irq_pic_enable(unsigned int irq) 259tx4938_irq_pic_enable(unsigned int irq)
329{ 260{
330 unsigned long flags;
331
332 spin_lock_irqsave(&tx4938_pic_lock, flags);
333
334 tx4938_irq_pic_modify(tx4938_irq_pic_addr(irq), 0, 261 tx4938_irq_pic_modify(tx4938_irq_pic_addr(irq), 0,
335 tx4938_irq_pic_mask(irq)); 262 tx4938_irq_pic_mask(irq));
336
337 spin_unlock_irqrestore(&tx4938_pic_lock, flags);
338} 263}
339 264
340static void 265static void
341tx4938_irq_pic_disable(unsigned int irq) 266tx4938_irq_pic_disable(unsigned int irq)
342{ 267{
343 unsigned long flags;
344
345 spin_lock_irqsave(&tx4938_pic_lock, flags);
346
347 tx4938_irq_pic_modify(tx4938_irq_pic_addr(irq), 268 tx4938_irq_pic_modify(tx4938_irq_pic_addr(irq),
348 tx4938_irq_pic_mask(irq), 0); 269 tx4938_irq_pic_mask(irq), 0);
349
350 spin_unlock_irqrestore(&tx4938_pic_lock, flags);
351}
352
353static void
354tx4938_irq_pic_mask_and_ack(unsigned int irq)
355{
356 tx4938_irq_pic_disable(irq);
357} 270}
358 271
359static void 272static void
diff --git a/arch/mips/tx4938/common/setup.c b/arch/mips/tx4938/common/setup.c
index f415a1f18fba..dc87d92bb08d 100644
--- a/arch/mips/tx4938/common/setup.c
+++ b/arch/mips/tx4938/common/setup.c
@@ -31,7 +31,6 @@
31#include <asm/mipsregs.h> 31#include <asm/mipsregs.h>
32#include <asm/system.h> 32#include <asm/system.h>
33#include <asm/time.h> 33#include <asm/time.h>
34#include <asm/time.h>
35#include <asm/tx4938/rbtx4938.h> 34#include <asm/tx4938/rbtx4938.h>
36 35
37extern void toshiba_rbtx4938_setup(void); 36extern void toshiba_rbtx4938_setup(void);
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/irq.c b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
index 102e473c10a2..8c87a35f3068 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/irq.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
@@ -87,25 +87,18 @@ IRQ Device
87#include <linux/bootmem.h> 87#include <linux/bootmem.h>
88#include <asm/tx4938/rbtx4938.h> 88#include <asm/tx4938/rbtx4938.h>
89 89
90static unsigned int toshiba_rbtx4938_irq_ioc_startup(unsigned int irq);
91static void toshiba_rbtx4938_irq_ioc_shutdown(unsigned int irq);
92static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq); 90static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
93static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq); 91static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);
94static void toshiba_rbtx4938_irq_ioc_mask_and_ack(unsigned int irq);
95static void toshiba_rbtx4938_irq_ioc_end(unsigned int irq); 92static void toshiba_rbtx4938_irq_ioc_end(unsigned int irq);
96 93
97DEFINE_SPINLOCK(toshiba_rbtx4938_ioc_lock);
98
99#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC" 94#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"
100static struct irq_chip toshiba_rbtx4938_irq_ioc_type = { 95static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
101 .typename = TOSHIBA_RBTX4938_IOC_NAME, 96 .typename = TOSHIBA_RBTX4938_IOC_NAME,
102 .startup = toshiba_rbtx4938_irq_ioc_startup, 97 .ack = toshiba_rbtx4938_irq_ioc_disable,
103 .shutdown = toshiba_rbtx4938_irq_ioc_shutdown, 98 .mask = toshiba_rbtx4938_irq_ioc_disable,
104 .enable = toshiba_rbtx4938_irq_ioc_enable, 99 .mask_ack = toshiba_rbtx4938_irq_ioc_disable,
105 .disable = toshiba_rbtx4938_irq_ioc_disable, 100 .unmask = toshiba_rbtx4938_irq_ioc_enable,
106 .ack = toshiba_rbtx4938_irq_ioc_mask_and_ack,
107 .end = toshiba_rbtx4938_irq_ioc_end, 101 .end = toshiba_rbtx4938_irq_ioc_end,
108 .set_affinity = NULL
109}; 102};
110 103
111#define TOSHIBA_RBTX4938_IOC_INTR_ENAB 0xb7f02000 104#define TOSHIBA_RBTX4938_IOC_INTR_ENAB 0xb7f02000
@@ -142,69 +135,36 @@ toshiba_rbtx4938_irq_ioc_init(void)
142 int i; 135 int i;
143 136
144 for (i = TOSHIBA_RBTX4938_IRQ_IOC_BEG; 137 for (i = TOSHIBA_RBTX4938_IRQ_IOC_BEG;
145 i <= TOSHIBA_RBTX4938_IRQ_IOC_END; i++) { 138 i <= TOSHIBA_RBTX4938_IRQ_IOC_END; i++)
146 irq_desc[i].status = IRQ_DISABLED; 139 set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type,
147 irq_desc[i].action = 0; 140 handle_level_irq);
148 irq_desc[i].depth = 3;
149 irq_desc[i].chip = &toshiba_rbtx4938_irq_ioc_type;
150 }
151 141
152 setup_irq(RBTX4938_IRQ_IOCINT, 142 setup_irq(RBTX4938_IRQ_IOCINT,
153 &toshiba_rbtx4938_irq_ioc_action); 143 &toshiba_rbtx4938_irq_ioc_action);
154} 144}
155 145
156static unsigned int
157toshiba_rbtx4938_irq_ioc_startup(unsigned int irq)
158{
159 toshiba_rbtx4938_irq_ioc_enable(irq);
160
161 return 0;
162}
163
164static void
165toshiba_rbtx4938_irq_ioc_shutdown(unsigned int irq)
166{
167 toshiba_rbtx4938_irq_ioc_disable(irq);
168}
169
170static void 146static void
171toshiba_rbtx4938_irq_ioc_enable(unsigned int irq) 147toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)
172{ 148{
173 unsigned long flags;
174 volatile unsigned char v; 149 volatile unsigned char v;
175 150
176 spin_lock_irqsave(&toshiba_rbtx4938_ioc_lock, flags);
177
178 v = TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB); 151 v = TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
179 v |= (1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG)); 152 v |= (1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));
180 TX4938_WR08(TOSHIBA_RBTX4938_IOC_INTR_ENAB, v); 153 TX4938_WR08(TOSHIBA_RBTX4938_IOC_INTR_ENAB, v);
181 mmiowb(); 154 mmiowb();
182 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB); 155 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
183
184 spin_unlock_irqrestore(&toshiba_rbtx4938_ioc_lock, flags);
185} 156}
186 157
187static void 158static void
188toshiba_rbtx4938_irq_ioc_disable(unsigned int irq) 159toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
189{ 160{
190 unsigned long flags;
191 volatile unsigned char v; 161 volatile unsigned char v;
192 162
193 spin_lock_irqsave(&toshiba_rbtx4938_ioc_lock, flags);
194
195 v = TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB); 163 v = TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
196 v &= ~(1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG)); 164 v &= ~(1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG));
197 TX4938_WR08(TOSHIBA_RBTX4938_IOC_INTR_ENAB, v); 165 TX4938_WR08(TOSHIBA_RBTX4938_IOC_INTR_ENAB, v);
198 mmiowb(); 166 mmiowb();
199 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB); 167 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
200
201 spin_unlock_irqrestore(&toshiba_rbtx4938_ioc_lock, flags);
202}
203
204static void
205toshiba_rbtx4938_irq_ioc_mask_and_ack(unsigned int irq)
206{
207 toshiba_rbtx4938_irq_ioc_disable(irq);
208} 168}
209 169
210static void 170static void
diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
index c215c0d39fae..54b92a74c7ac 100644
--- a/arch/mips/vr41xx/common/icu.c
+++ b/arch/mips/vr41xx/common/icu.c
@@ -417,14 +417,7 @@ void vr41xx_disable_bcuint(void)
417 417
418EXPORT_SYMBOL(vr41xx_disable_bcuint); 418EXPORT_SYMBOL(vr41xx_disable_bcuint);
419 419
420static unsigned int startup_sysint1_irq(unsigned int irq) 420static void disable_sysint1_irq(unsigned int irq)
421{
422 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
423
424 return 0; /* never anything pending */
425}
426
427static void shutdown_sysint1_irq(unsigned int irq)
428{ 421{
429 icu1_clear(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq)); 422 icu1_clear(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
430} 423}
@@ -434,9 +427,6 @@ static void enable_sysint1_irq(unsigned int irq)
434 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq)); 427 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
435} 428}
436 429
437#define disable_sysint1_irq shutdown_sysint1_irq
438#define ack_sysint1_irq shutdown_sysint1_irq
439
440static void end_sysint1_irq(unsigned int irq) 430static void end_sysint1_irq(unsigned int irq)
441{ 431{
442 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 432 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
@@ -445,22 +435,14 @@ static void end_sysint1_irq(unsigned int irq)
445 435
446static struct irq_chip sysint1_irq_type = { 436static struct irq_chip sysint1_irq_type = {
447 .typename = "SYSINT1", 437 .typename = "SYSINT1",
448 .startup = startup_sysint1_irq, 438 .ack = disable_sysint1_irq,
449 .shutdown = shutdown_sysint1_irq, 439 .mask = disable_sysint1_irq,
450 .enable = enable_sysint1_irq, 440 .mask_ack = disable_sysint1_irq,
451 .disable = disable_sysint1_irq, 441 .unmask = enable_sysint1_irq,
452 .ack = ack_sysint1_irq,
453 .end = end_sysint1_irq, 442 .end = end_sysint1_irq,
454}; 443};
455 444
456static unsigned int startup_sysint2_irq(unsigned int irq) 445static void disable_sysint2_irq(unsigned int irq)
457{
458 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
459
460 return 0; /* never anything pending */
461}
462
463static void shutdown_sysint2_irq(unsigned int irq)
464{ 446{
465 icu2_clear(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq)); 447 icu2_clear(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
466} 448}
@@ -470,9 +452,6 @@ static void enable_sysint2_irq(unsigned int irq)
470 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq)); 452 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
471} 453}
472 454
473#define disable_sysint2_irq shutdown_sysint2_irq
474#define ack_sysint2_irq shutdown_sysint2_irq
475
476static void end_sysint2_irq(unsigned int irq) 455static void end_sysint2_irq(unsigned int irq)
477{ 456{
478 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 457 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
@@ -481,11 +460,10 @@ static void end_sysint2_irq(unsigned int irq)
481 460
482static struct irq_chip sysint2_irq_type = { 461static struct irq_chip sysint2_irq_type = {
483 .typename = "SYSINT2", 462 .typename = "SYSINT2",
484 .startup = startup_sysint2_irq, 463 .ack = disable_sysint2_irq,
485 .shutdown = shutdown_sysint2_irq, 464 .mask = disable_sysint2_irq,
486 .enable = enable_sysint2_irq, 465 .mask_ack = disable_sysint2_irq,
487 .disable = disable_sysint2_irq, 466 .unmask = enable_sysint2_irq,
488 .ack = ack_sysint2_irq,
489 .end = end_sysint2_irq, 467 .end = end_sysint2_irq,
490}; 468};
491 469
@@ -723,10 +701,12 @@ static int __init vr41xx_icu_init(void)
723 icu2_write(MGIUINTHREG, 0xffff); 701 icu2_write(MGIUINTHREG, 0xffff);
724 702
725 for (i = SYSINT1_IRQ_BASE; i <= SYSINT1_IRQ_LAST; i++) 703 for (i = SYSINT1_IRQ_BASE; i <= SYSINT1_IRQ_LAST; i++)
726 irq_desc[i].chip = &sysint1_irq_type; 704 set_irq_chip_and_handler(i, &sysint1_irq_type,
705 handle_level_irq);
727 706
728 for (i = SYSINT2_IRQ_BASE; i <= SYSINT2_IRQ_LAST; i++) 707 for (i = SYSINT2_IRQ_BASE; i <= SYSINT2_IRQ_LAST; i++)
729 irq_desc[i].chip = &sysint2_irq_type; 708 set_irq_chip_and_handler(i, &sysint2_irq_type,
709 handle_level_irq);
730 710
731 cascade_irq(INT0_IRQ, icu_get_irq); 711 cascade_irq(INT0_IRQ, icu_get_irq);
732 cascade_irq(INT1_IRQ, icu_get_irq); 712 cascade_irq(INT1_IRQ, icu_get_irq);
diff --git a/arch/mips/vr41xx/nec-cmbvr4133/irq.c b/arch/mips/vr41xx/nec-cmbvr4133/irq.c
index 2483487344c2..a039bb7251ff 100644
--- a/arch/mips/vr41xx/nec-cmbvr4133/irq.c
+++ b/arch/mips/vr41xx/nec-cmbvr4133/irq.c
@@ -30,17 +30,6 @@ extern void init_8259A(int hoge);
30 30
31extern int vr4133_rockhopper; 31extern int vr4133_rockhopper;
32 32
33static unsigned int startup_i8259_irq(unsigned int irq)
34{
35 enable_8259A_irq(irq - I8259_IRQ_BASE);
36 return 0;
37}
38
39static void shutdown_i8259_irq(unsigned int irq)
40{
41 disable_8259A_irq(irq - I8259_IRQ_BASE);
42}
43
44static void enable_i8259_irq(unsigned int irq) 33static void enable_i8259_irq(unsigned int irq)
45{ 34{
46 enable_8259A_irq(irq - I8259_IRQ_BASE); 35 enable_8259A_irq(irq - I8259_IRQ_BASE);
@@ -64,11 +53,10 @@ static void end_i8259_irq(unsigned int irq)
64 53
65static struct irq_chip i8259_irq_type = { 54static struct irq_chip i8259_irq_type = {
66 .typename = "XT-PIC", 55 .typename = "XT-PIC",
67 .startup = startup_i8259_irq,
68 .shutdown = shutdown_i8259_irq,
69 .enable = enable_i8259_irq,
70 .disable = disable_i8259_irq,
71 .ack = ack_i8259_irq, 56 .ack = ack_i8259_irq,
57 .mask = disable_i8259_irq,
58 .mask_ack = ack_i8259_irq,
59 .unmask = enable_i8259_irq,
72 .end = end_i8259_irq, 60 .end = end_i8259_irq,
73}; 61};
74 62
@@ -104,7 +92,7 @@ void __init rockhopper_init_irq(void)
104 } 92 }
105 93
106 for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++) 94 for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++)
107 irq_desc[i].chip = &i8259_irq_type; 95 set_irq_chip(i, &i8259_irq_type);
108 96
109 setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade); 97 setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade);
110 98
diff --git a/arch/parisc/lib/checksum.c b/arch/parisc/lib/checksum.c
index 8a1e08068e7d..462696d30d3b 100644
--- a/arch/parisc/lib/checksum.c
+++ b/arch/parisc/lib/checksum.c
@@ -101,11 +101,14 @@ out:
101/* 101/*
102 * computes a partial checksum, e.g. for TCP/UDP fragments 102 * computes a partial checksum, e.g. for TCP/UDP fragments
103 */ 103 */
104unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) 104/*
105 * why bother folding?
106 */
107__wsum csum_partial(const void *buff, int len, __wsum sum)
105{ 108{
106 unsigned int result = do_csum(buff, len); 109 unsigned int result = do_csum(buff, len);
107 addc(result, sum); 110 addc(result, sum);
108 return from32to16(result); 111 return (__force __wsum)from32to16(result);
109} 112}
110 113
111EXPORT_SYMBOL(csum_partial); 114EXPORT_SYMBOL(csum_partial);
@@ -113,8 +116,8 @@ EXPORT_SYMBOL(csum_partial);
113/* 116/*
114 * copy while checksumming, otherwise like csum_partial 117 * copy while checksumming, otherwise like csum_partial
115 */ 118 */
116unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, 119__wsum csum_partial_copy_nocheck(const void *src, void *dst,
117 int len, unsigned int sum) 120 int len, __wsum sum)
118{ 121{
119 /* 122 /*
120 * It's 2:30 am and I don't feel like doing it real ... 123 * It's 2:30 am and I don't feel like doing it real ...
@@ -131,9 +134,9 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck);
131 * Copy from userspace and compute checksum. If we catch an exception 134 * Copy from userspace and compute checksum. If we catch an exception
132 * then zero the rest of the buffer. 135 * then zero the rest of the buffer.
133 */ 136 */
134unsigned int csum_partial_copy_from_user(const unsigned char __user *src, 137__wsum csum_partial_copy_from_user(const void __user *src,
135 unsigned char *dst, int len, 138 void *dst, int len,
136 unsigned int sum, int *err_ptr) 139 __wsum sum, int *err_ptr)
137{ 140{
138 int missing; 141 int missing;
139 142
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 0673dbedb241..116d7d3683ed 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -425,7 +425,7 @@ config PPC_MAPLE
425 default n 425 default n
426 help 426 help
427 This option enables support for the Maple 970FX Evaluation Board. 427 This option enables support for the Maple 970FX Evaluation Board.
428 For more informations, refer to <http://www.970eval.com> 428 For more information, refer to <http://www.970eval.com>
429 429
430config PPC_PASEMI 430config PPC_PASEMI
431 depends on PPC_MULTIPLATFORM && PPC64 431 depends on PPC_MULTIPLATFORM && PPC64
diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
index 7edb6b461382..edcd5b875b66 100644
--- a/arch/powerpc/platforms/83xx/Kconfig
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -21,7 +21,7 @@ config MPC834x_SYS
21 Be aware that PCI buses can only function when SYS board is plugged 21 Be aware that PCI buses can only function when SYS board is plugged
22 into the PIB (Platform IO Board) board from Freescale which provide 22 into the PIB (Platform IO Board) board from Freescale which provide
23 3 PCI slots. The PIBs PCI initialization is the bootloader's 23 3 PCI slots. The PIBs PCI initialization is the bootloader's
24 responsiblilty. 24 responsibility.
25 25
26config MPC834x_ITX 26config MPC834x_ITX
27 bool "Freescale MPC834x ITX" 27 bool "Freescale MPC834x ITX"
@@ -30,7 +30,7 @@ config MPC834x_ITX
30 This option enables support for the MPC 834x ITX evaluation board. 30 This option enables support for the MPC 834x ITX evaluation board.
31 31
32 Be aware that PCI initialization is the bootloader's 32 Be aware that PCI initialization is the bootloader's
33 responsiblilty. 33 responsibility.
34 34
35config MPC8360E_PB 35config MPC8360E_PB
36 bool "Freescale MPC8360E PB" 36 bool "Freescale MPC8360E PB"
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 9923adc5248e..257dc9068468 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -48,7 +48,6 @@ static struct pci_controller *u3_ht;
48static int has_second_ohare; 48static int has_second_ohare;
49#endif /* CONFIG_PPC64 */ 49#endif /* CONFIG_PPC64 */
50 50
51extern u8 pci_cache_line_size;
52extern int pcibios_assign_bus_offset; 51extern int pcibios_assign_bus_offset;
53 52
54struct device_node *k2_skiplist[2]; 53struct device_node *k2_skiplist[2];
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 077711e63104..ef018e25fb07 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -724,7 +724,7 @@ config MPC834x_SYS
724 Be aware that PCI buses can only function when SYS board is plugged 724 Be aware that PCI buses can only function when SYS board is plugged
725 into the PIB (Platform IO Board) board from Freescale which provide 725 into the PIB (Platform IO Board) board from Freescale which provide
726 3 PCI slots. The PIBs PCI initialization is the bootloader's 726 3 PCI slots. The PIBs PCI initialization is the bootloader's
727 responsiblilty. 727 responsibility.
728 728
729config EV64360 729config EV64360
730 bool "Marvell-EV64360BP" 730 bool "Marvell-EV64360BP"
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 6a461d4caeff..bffc7e176970 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -217,7 +217,7 @@ config SH_SHMIN
217 bool "SHMIN" 217 bool "SHMIN"
218 select CPU_SUBTYPE_SH7706 218 select CPU_SUBTYPE_SH7706
219 help 219 help
220 Select SHMIN if configureing for the SHMIN board 220 Select SHMIN if configuring for the SHMIN board.
221 221
222config SH_UNKNOWN 222config SH_UNKNOWN
223 bool "BareCPU" 223 bool "BareCPU"
diff --git a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
index 9daad70bc305..8a2fd19dc9eb 100644
--- a/arch/sh/kernel/sh_ksyms.c
+++ b/arch/sh/kernel/sh_ksyms.c
@@ -18,7 +18,6 @@
18#include <asm/delay.h> 18#include <asm/delay.h>
19#include <asm/tlbflush.h> 19#include <asm/tlbflush.h>
20#include <asm/cacheflush.h> 20#include <asm/cacheflush.h>
21#include <asm/checksum.h>
22 21
23extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); 22extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
24extern struct hw_interrupt_type no_irq_type; 23extern struct hw_interrupt_type no_irq_type;
diff --git a/arch/sh64/kernel/sh_ksyms.c b/arch/sh64/kernel/sh_ksyms.c
index 4b2df7247b59..7aa4b4f7bc5e 100644
--- a/arch/sh64/kernel/sh_ksyms.c
+++ b/arch/sh64/kernel/sh_ksyms.c
@@ -38,7 +38,7 @@ EXPORT_SYMBOL(disable_irq);
38EXPORT_SYMBOL(kernel_thread); 38EXPORT_SYMBOL(kernel_thread);
39 39
40/* Networking helper routines. */ 40/* Networking helper routines. */
41EXPORT_SYMBOL(csum_partial_copy); 41EXPORT_SYMBOL(csum_partial_copy_nocheck);
42 42
43EXPORT_SYMBOL(strstr); 43EXPORT_SYMBOL(strstr);
44 44
diff --git a/arch/sh64/lib/c-checksum.c b/arch/sh64/lib/c-checksum.c
index 0e8a742abf8c..4b2676380deb 100644
--- a/arch/sh64/lib/c-checksum.c
+++ b/arch/sh64/lib/c-checksum.c
@@ -118,24 +118,24 @@ static unsigned long do_csum(const unsigned char *buff, int len)
118 118
119/* computes the checksum of a memory block at buff, length len, 119/* computes the checksum of a memory block at buff, length len,
120 and adds in "sum" (32-bit) */ 120 and adds in "sum" (32-bit) */
121unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) 121__wsum csum_partial(const void *buff, int len, __wsum sum)
122{ 122{
123 unsigned long long result = do_csum(buff, len); 123 unsigned long long result = do_csum(buff, len);
124 124
125 /* add in old sum, and carry.. */ 125 /* add in old sum, and carry.. */
126 result += sum; 126 result += (__force u32)sum;
127 /* 32+c bits -> 32 bits */ 127 /* 32+c bits -> 32 bits */
128 result = (result & 0xffffffff) + (result >> 32); 128 result = (result & 0xffffffff) + (result >> 32);
129 129
130 pr_debug("csum_partial, buff %p len %d sum 0x%x result=0x%016Lx\n", 130 pr_debug("csum_partial, buff %p len %d sum 0x%x result=0x%016Lx\n",
131 buff, len, sum, result); 131 buff, len, sum, result);
132 132
133 return result; 133 return (__force __wsum)result;
134} 134}
135 135
136/* Copy while checksumming, otherwise like csum_partial. */ 136/* Copy while checksumming, otherwise like csum_partial. */
137unsigned int 137__wsum
138csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, unsigned int sum) 138csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
139{ 139{
140 sum = csum_partial(src, len, sum); 140 sum = csum_partial(src, len, sum);
141 memcpy(dst, src, len); 141 memcpy(dst, src, len);
@@ -145,9 +145,9 @@ csum_partial_copy(const unsigned char *src, unsigned char *dst, int len, unsigne
145 145
146/* Copy from userspace and compute checksum. If we catch an exception 146/* Copy from userspace and compute checksum. If we catch an exception
147 then zero the rest of the buffer. */ 147 then zero the rest of the buffer. */
148unsigned int 148__wsum
149csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, int len, 149csum_partial_copy_from_user(const void __user *src, void *dst, int len,
150 unsigned int sum, int *err_ptr) 150 __wsum sum, int *err_ptr)
151{ 151{
152 int missing; 152 int missing;
153 153
@@ -166,9 +166,9 @@ csum_partial_copy_from_user(const unsigned char *src, unsigned char *dst, int le
166} 166}
167 167
168/* Copy to userspace and compute checksum. */ 168/* Copy to userspace and compute checksum. */
169unsigned int 169__wsum
170csum_partial_copy_to_user(const unsigned char *src, unsigned char *dst, int len, 170csum_partial_copy_to_user(const unsigned char *src, unsigned char *dst, int len,
171 unsigned int sum, int *err_ptr) 171 __wsum sum, int *err_ptr)
172{ 172{
173 sum = csum_partial(src, len, sum); 173 sum = csum_partial(src, len, sum);
174 174
@@ -182,28 +182,24 @@ csum_partial_copy_to_user(const unsigned char *src, unsigned char *dst, int len,
182 * This is a version of ip_compute_csum() optimized for IP headers, 182 * This is a version of ip_compute_csum() optimized for IP headers,
183 * which always checksum on 4 octet boundaries. 183 * which always checksum on 4 octet boundaries.
184 */ 184 */
185unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) 185__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
186{ 186{
187 pr_debug("ip_fast_csum %p,%d\n", iph, ihl); 187 pr_debug("ip_fast_csum %p,%d\n", iph, ihl);
188 188
189 return ~do_csum(iph, ihl * 4); 189 return (__force __sum16)~do_csum(iph, ihl * 4);
190} 190}
191 191
192unsigned int csum_tcpudp_nofold(unsigned long saddr, 192__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
193 unsigned long daddr,
194 unsigned short len, 193 unsigned short len,
195 unsigned short proto, unsigned int sum) 194 unsigned short proto, __wsum sum)
196{ 195{
197 unsigned long long result; 196 unsigned long long result;
198 197
199 pr_debug("ntohs(0x%x)=0x%x\n", 0xdead, ntohs(0xdead)); 198 pr_debug("ntohs(0x%x)=0x%x\n", 0xdead, ntohs(0xdead));
200 pr_debug("htons(0x%x)=0x%x\n", 0xdead, htons(0xdead)); 199 pr_debug("htons(0x%x)=0x%x\n", 0xdead, htons(0xdead));
201 200
202 result = ((unsigned long long) saddr + 201 result = (__force u64) saddr + (__force u64) daddr +
203 (unsigned long long) daddr + 202 (__force u64) sum + ((len + proto) << 8);
204 (unsigned long long) sum +
205 ((unsigned long long) ntohs(len) << 16) +
206 ((unsigned long long) proto << 8));
207 203
208 /* Fold down to 32-bits so we don't loose in the typedef-less 204 /* Fold down to 32-bits so we don't loose in the typedef-less
209 network stack. */ 205 network stack. */
@@ -215,16 +211,5 @@ unsigned int csum_tcpudp_nofold(unsigned long saddr,
215 pr_debug("%s saddr %x daddr %x len %x proto %x sum %x result %08Lx\n", 211 pr_debug("%s saddr %x daddr %x len %x proto %x sum %x result %08Lx\n",
216 __FUNCTION__, saddr, daddr, len, proto, sum, result); 212 __FUNCTION__, saddr, daddr, len, proto, sum, result);
217 213
218 return result; 214 return (__wsum)result;
219}
220
221// Post SIM:
222unsigned int
223csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, int len, unsigned int sum)
224{
225 // unsigned dummy;
226 pr_debug("csum_partial_copy_nocheck src %p dst %p len %d\n", src, dst,
227 len);
228
229 return csum_partial_copy(src, dst, len, sum);
230} 215}
diff --git a/arch/sh64/lib/dbg.c b/arch/sh64/lib/dbg.c
index 1326f45f31eb..4310fc87444e 100644
--- a/arch/sh64/lib/dbg.c
+++ b/arch/sh64/lib/dbg.c
@@ -383,7 +383,7 @@ void show_excp_regs(char *from, int trapnr, int signr, struct pt_regs *regs)
383/* ======================================================================= */ 383/* ======================================================================= */
384 384
385/* 385/*
386** Depending on <base> scan the MMU, Data or Instrction side 386** Depending on <base> scan the MMU, Data or Instruction side
387** looking for a valid mapping matching Eaddr & asid. 387** looking for a valid mapping matching Eaddr & asid.
388** Return -1 if not found or the TLB id entry otherwise. 388** Return -1 if not found or the TLB id entry otherwise.
389** Note: it works only for 4k pages! 389** Note: it works only for 4k pages!
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 2f96610a83e9..92a7c8a636d3 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -212,8 +212,8 @@ config SPARC_LED
212 tristate "Sun4m LED driver" 212 tristate "Sun4m LED driver"
213 help 213 help
214 This driver toggles the front-panel LED on sun4m systems 214 This driver toggles the front-panel LED on sun4m systems
215 in a user-specifyable manner. It's state can be probed 215 in a user-specifiable manner. Its state can be probed
216 by reading /proc/led and it's blinking mode can be changed 216 by reading /proc/led and its blinking mode can be changed
217 via writes to /proc/led 217 via writes to /proc/led
218 218
219source "fs/Kconfig.binfmt" 219source "fs/Kconfig.binfmt"
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index e02f01b644af..dfc41cd4bb5d 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -646,13 +646,4 @@ int pci_domain_nr(struct pci_bus *pbus)
646} 646}
647EXPORT_SYMBOL(pci_domain_nr); 647EXPORT_SYMBOL(pci_domain_nr);
648 648
649int pcibios_prep_mwi(struct pci_dev *dev)
650{
651 /* We set correct PCI_CACHE_LINE_SIZE register values for every
652 * device probed on this platform. So there is nothing to check
653 * and this always succeeds.
654 */
655 return 0;
656}
657
658#endif /* !(CONFIG_PCI) */ 649#endif /* !(CONFIG_PCI) */
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
index 2f880cb167a5..0cad3546cb89 100644
--- a/arch/um/drivers/chan_user.c
+++ b/arch/um/drivers/chan_user.c
@@ -120,7 +120,7 @@ static int winch_thread(void *arg)
120 /* These are synchronization calls between various UML threads on the 120 /* These are synchronization calls between various UML threads on the
121 * host - since they are not different kernel threads, we cannot use 121 * host - since they are not different kernel threads, we cannot use
122 * kernel semaphores. We don't use SysV semaphores because they are 122 * kernel semaphores. We don't use SysV semaphores because they are
123 * persistant. */ 123 * persistent. */
124 count = os_read_file(pipe_fd, &c, sizeof(c)); 124 count = os_read_file(pipe_fd, &c, sizeof(c));
125 if(count != sizeof(c)) 125 if(count != sizeof(c))
126 printk("winch_thread : failed to read synchronization byte, " 126 printk("winch_thread : failed to read synchronization byte, "
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 6516f6dca96d..13a86bd383d3 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -233,6 +233,8 @@ extern unsigned long __do_user_copy(void *to, const void *from, int n,
233 void (*op)(void *to, const void *from, 233 void (*op)(void *to, const void *from,
234 int n), int *faulted_out); 234 int n), int *faulted_out);
235 235
236/* execvp.c */
237extern int execvp_noalloc(char *buf, const char *file, char *const argv[]);
236/* helper.c */ 238/* helper.c */
237extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, 239extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
238 unsigned long *stack_out); 240 unsigned long *stack_out);
diff --git a/arch/um/include/sysdep-i386/checksum.h b/arch/um/include/sysdep-i386/checksum.h
index 052bb061a978..0cb4645cbeb8 100644
--- a/arch/um/include/sysdep-i386/checksum.h
+++ b/arch/um/include/sysdep-i386/checksum.h
@@ -20,8 +20,7 @@
20 * 20 *
21 * it's best to have buff aligned on a 32-bit boundary 21 * it's best to have buff aligned on a 32-bit boundary
22 */ 22 */
23unsigned int csum_partial(const unsigned char * buff, int len, 23__wsum csum_partial(const void *buff, int len, __wsum sum);
24 unsigned int sum);
25 24
26/* 25/*
27 * Note: when you get a NULL pointer exception here this means someone 26 * Note: when you get a NULL pointer exception here this means someone
@@ -32,8 +31,8 @@ unsigned int csum_partial(const unsigned char * buff, int len,
32 */ 31 */
33 32
34static __inline__ 33static __inline__
35unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, 34__wsum csum_partial_copy_nocheck(const void *src, void *dst,
36 int len, int sum) 35 int len, __wsum sum)
37{ 36{
38 memcpy(dst, src, len); 37 memcpy(dst, src, len);
39 return csum_partial(dst, len, sum); 38 return csum_partial(dst, len, sum);
@@ -48,36 +47,25 @@ unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *
48 */ 47 */
49 48
50static __inline__ 49static __inline__
51unsigned int csum_partial_copy_from_user(const unsigned char __user *src, 50__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
52 unsigned char *dst, 51 int len, __wsum sum, int *err_ptr)
53 int len, int sum, int *err_ptr)
54{ 52{
55 if(copy_from_user(dst, src, len)){ 53 if (copy_from_user(dst, src, len)) {
56 *err_ptr = -EFAULT; 54 *err_ptr = -EFAULT;
57 return(-1); 55 return (__force __wsum)-1;
58 } 56 }
59 57
60 return csum_partial(dst, len, sum); 58 return csum_partial(dst, len, sum);
61} 59}
62 60
63/* 61/*
64 * These are the old (and unsafe) way of doing checksums, a warning message
65 * will be printed if they are used and an exception occurs.
66 *
67 * these functions should go away after some time.
68 */
69
70#define csum_partial_copy_fromuser csum_partial_copy_from_user
71
72/*
73 * This is a version of ip_compute_csum() optimized for IP headers, 62 * This is a version of ip_compute_csum() optimized for IP headers,
74 * which always checksum on 4 octet boundaries. 63 * which always checksum on 4 octet boundaries.
75 * 64 *
76 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by 65 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
77 * Arnt Gulbrandsen. 66 * Arnt Gulbrandsen.
78 */ 67 */
79static inline unsigned short ip_fast_csum(unsigned char * iph, 68static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
80 unsigned int ihl)
81{ 69{
82 unsigned int sum; 70 unsigned int sum;
83 71
@@ -105,29 +93,29 @@ static inline unsigned short ip_fast_csum(unsigned char * iph,
105 : "=r" (sum), "=r" (iph), "=r" (ihl) 93 : "=r" (sum), "=r" (iph), "=r" (ihl)
106 : "1" (iph), "2" (ihl) 94 : "1" (iph), "2" (ihl)
107 : "memory"); 95 : "memory");
108 return sum; 96 return (__force __sum16)sum;
109} 97}
110 98
111/* 99/*
112 * Fold a partial checksum 100 * Fold a partial checksum
113 */ 101 */
114 102
115static inline unsigned int csum_fold(unsigned int sum) 103static inline __sum16 csum_fold(__wsum sum)
116{ 104{
117 __asm__( 105 __asm__(
118 "addl %1, %0 ;\n" 106 "addl %1, %0 ;\n"
119 "adcl $0xffff, %0 ;\n" 107 "adcl $0xffff, %0 ;\n"
120 : "=r" (sum) 108 : "=r" (sum)
121 : "r" (sum << 16), "0" (sum & 0xffff0000) 109 : "r" ((__force u32)sum << 16),
110 "0" ((__force u32)sum & 0xffff0000)
122 ); 111 );
123 return (~sum) >> 16; 112 return (__force __sum16)(~(__force u32)sum >> 16);
124} 113}
125 114
126static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, 115static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
127 unsigned long daddr,
128 unsigned short len, 116 unsigned short len,
129 unsigned short proto, 117 unsigned short proto,
130 unsigned int sum) 118 __wsum sum)
131{ 119{
132 __asm__( 120 __asm__(
133 "addl %1, %0 ;\n" 121 "addl %1, %0 ;\n"
@@ -135,7 +123,7 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
135 "adcl %3, %0 ;\n" 123 "adcl %3, %0 ;\n"
136 "adcl $0, %0 ;\n" 124 "adcl $0, %0 ;\n"
137 : "=r" (sum) 125 : "=r" (sum)
138 : "g" (daddr), "g"(saddr), "g"((ntohs(len)<<16)+proto*256), "0"(sum)); 126 : "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum));
139 return sum; 127 return sum;
140} 128}
141 129
@@ -143,11 +131,10 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
143 * computes the checksum of the TCP/UDP pseudo-header 131 * computes the checksum of the TCP/UDP pseudo-header
144 * returns a 16-bit checksum, already complemented 132 * returns a 16-bit checksum, already complemented
145 */ 133 */
146static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 134static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
147 unsigned long daddr,
148 unsigned short len, 135 unsigned short len,
149 unsigned short proto, 136 unsigned short proto,
150 unsigned int sum) 137 __wsum sum)
151{ 138{
152 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 139 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
153} 140}
@@ -157,17 +144,16 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
157 * in icmp.c 144 * in icmp.c
158 */ 145 */
159 146
160static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 147static inline __sum16 ip_compute_csum(const void *buff, int len)
161{ 148{
162 return csum_fold (csum_partial(buff, len, 0)); 149 return csum_fold (csum_partial(buff, len, 0));
163} 150}
164 151
165#define _HAVE_ARCH_IPV6_CSUM 152#define _HAVE_ARCH_IPV6_CSUM
166static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 153static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
167 struct in6_addr *daddr, 154 const struct in6_addr *daddr,
168 __u32 len, 155 __u32 len, unsigned short proto,
169 unsigned short proto, 156 __wsum sum)
170 unsigned int sum)
171{ 157{
172 __asm__( 158 __asm__(
173 "addl 0(%1), %0 ;\n" 159 "addl 0(%1), %0 ;\n"
@@ -192,14 +178,14 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
192 * Copy and checksum to user 178 * Copy and checksum to user
193 */ 179 */
194#define HAVE_CSUM_COPY_USER 180#define HAVE_CSUM_COPY_USER
195static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src, 181static __inline__ __wsum csum_and_copy_to_user(const void *src,
196 unsigned char __user *dst, 182 void __user *dst,
197 int len, int sum, int *err_ptr) 183 int len, __wsum sum, int *err_ptr)
198{ 184{
199 if (access_ok(VERIFY_WRITE, dst, len)){ 185 if (access_ok(VERIFY_WRITE, dst, len)) {
200 if(copy_to_user(dst, src, len)){ 186 if (copy_to_user(dst, src, len)) {
201 *err_ptr = -EFAULT; 187 *err_ptr = -EFAULT;
202 return(-1); 188 return (__force __wsum)-1;
203 } 189 }
204 190
205 return csum_partial(src, len, sum); 191 return csum_partial(src, len, sum);
@@ -208,7 +194,7 @@ static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src,
208 if (len) 194 if (len)
209 *err_ptr = -EFAULT; 195 *err_ptr = -EFAULT;
210 196
211 return -1; /* invalid checksum */ 197 return (__force __wsum)-1; /* invalid checksum */
212} 198}
213 199
214#endif 200#endif
diff --git a/arch/um/include/sysdep-x86_64/checksum.h b/arch/um/include/sysdep-x86_64/checksum.h
index ea97005af694..a5be9031ea85 100644
--- a/arch/um/include/sysdep-x86_64/checksum.h
+++ b/arch/um/include/sysdep-x86_64/checksum.h
@@ -9,8 +9,7 @@
9#include "linux/in6.h" 9#include "linux/in6.h"
10#include "asm/uaccess.h" 10#include "asm/uaccess.h"
11 11
12extern unsigned csum_partial(const unsigned char *buff, unsigned len, 12extern __wsum csum_partial(const void *buff, int len, __wsum sum);
13 unsigned sum);
14 13
15/* 14/*
16 * Note: when you get a NULL pointer exception here this means someone 15 * Note: when you get a NULL pointer exception here this means someone
@@ -21,21 +20,21 @@ extern unsigned csum_partial(const unsigned char *buff, unsigned len,
21 */ 20 */
22 21
23static __inline__ 22static __inline__
24unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, 23__wsum csum_partial_copy_nocheck(const void *src, void *dst,
25 int len, int sum) 24 int len, __wsum sum)
26{ 25{
27 memcpy(dst, src, len); 26 memcpy(dst, src, len);
28 return(csum_partial(dst, len, sum)); 27 return(csum_partial(dst, len, sum));
29} 28}
30 29
31static __inline__ 30static __inline__
32unsigned int csum_partial_copy_from_user(const unsigned char *src, 31__wsum csum_partial_copy_from_user(const void __user *src,
33 unsigned char *dst, int len, int sum, 32 void *dst, int len, __wsum sum,
34 int *err_ptr) 33 int *err_ptr)
35{ 34{
36 if(copy_from_user(dst, src, len)){ 35 if (copy_from_user(dst, src, len)) {
37 *err_ptr = -EFAULT; 36 *err_ptr = -EFAULT;
38 return(-1); 37 return (__force __wsum)-1;
39 } 38 }
40 return csum_partial(dst, len, sum); 39 return csum_partial(dst, len, sum);
41} 40}
@@ -48,15 +47,16 @@ unsigned int csum_partial_copy_from_user(const unsigned char *src,
48 * the last step before putting a checksum into a packet. 47 * the last step before putting a checksum into a packet.
49 * Make sure not to mix with 64bit checksums. 48 * Make sure not to mix with 64bit checksums.
50 */ 49 */
51static inline unsigned int csum_fold(unsigned int sum) 50static inline __sum16 csum_fold(__wsum sum)
52{ 51{
53 __asm__( 52 __asm__(
54 " addl %1,%0\n" 53 " addl %1,%0\n"
55 " adcl $0xffff,%0" 54 " adcl $0xffff,%0"
56 : "=r" (sum) 55 : "=r" (sum)
57 : "r" (sum << 16), "0" (sum & 0xffff0000) 56 : "r" ((__force u32)sum << 16),
57 "0" ((__force u32)sum & 0xffff0000)
58 ); 58 );
59 return (~sum) >> 16; 59 return (__force __sum16)(~(__force u32)sum >> 16);
60} 60}
61 61
62/** 62/**
@@ -70,28 +70,27 @@ static inline unsigned int csum_fold(unsigned int sum)
70 * Returns the pseudo header checksum the input data. Result is 70 * Returns the pseudo header checksum the input data. Result is
71 * 32bit unfolded. 71 * 32bit unfolded.
72 */ 72 */
73static inline unsigned long 73static inline __wsum
74csum_tcpudp_nofold(unsigned saddr, unsigned daddr, unsigned short len, 74csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
75 unsigned short proto, unsigned int sum) 75 unsigned short proto, __wsum sum)
76{ 76{
77 asm(" addl %1, %0\n" 77 asm(" addl %1, %0\n"
78 " adcl %2, %0\n" 78 " adcl %2, %0\n"
79 " adcl %3, %0\n" 79 " adcl %3, %0\n"
80 " adcl $0, %0\n" 80 " adcl $0, %0\n"
81 : "=r" (sum) 81 : "=r" (sum)
82 : "g" (daddr), "g" (saddr), "g" ((ntohs(len)<<16)+proto*256), "0" (sum)); 82 : "g" (daddr), "g" (saddr), "g" ((len + proto) << 8), "0" (sum));
83 return sum; 83 return sum;
84} 84}
85 85
86/* 86/*
87 * computes the checksum of the TCP/UDP pseudo-header 87 * computes the checksum of the TCP/UDP pseudo-header
88 * returns a 16-bit checksum, already complemented 88 * returns a 16-bit checksum, already complemented
89 */ 89 */
90static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 90static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
91 unsigned long daddr, 91 unsigned short len,
92 unsigned short len, 92 unsigned short proto,
93 unsigned short proto, 93 __wsum sum)
94 unsigned int sum)
95{ 94{
96 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 95 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
97} 96}
@@ -101,7 +100,7 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
101 * iph: ipv4 header 100 * iph: ipv4 header
102 * ihl: length of header / 4 101 * ihl: length of header / 4
103 */ 102 */
104static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) 103static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
105{ 104{
106 unsigned int sum; 105 unsigned int sum;
107 106
@@ -128,7 +127,7 @@ static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
128 : "=r" (sum), "=r" (iph), "=r" (ihl) 127 : "=r" (sum), "=r" (iph), "=r" (ihl)
129 : "1" (iph), "2" (ihl) 128 : "1" (iph), "2" (ihl)
130 : "memory"); 129 : "memory");
131 return(sum); 130 return (__force __sum16)sum;
132} 131}
133 132
134static inline unsigned add32_with_carry(unsigned a, unsigned b) 133static inline unsigned add32_with_carry(unsigned a, unsigned b)
@@ -140,6 +139,6 @@ static inline unsigned add32_with_carry(unsigned a, unsigned b)
140 return a; 139 return a;
141} 140}
142 141
143extern unsigned short ip_compute_csum(unsigned char * buff, int len); 142extern __sum16 ip_compute_csum(const void *buff, int len);
144 143
145#endif 144#endif
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index b4183929b32c..2f8c79464015 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -3,8 +3,8 @@
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6obj-y = aio.o elf_aux.o file.o helper.o irq.o main.o mem.o process.o sigio.o \ 6obj-y = aio.o elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
7 signal.o start_up.o time.o trap.o tty.o uaccess.o umid.o tls.o \ 7 sigio.o signal.o start_up.o time.o trap.o tty.o uaccess.o umid.o tls.o \
8 user_syms.o util.o drivers/ sys-$(SUBARCH)/ 8 user_syms.o util.o drivers/ sys-$(SUBARCH)/
9 9
10obj-$(CONFIG_MODE_SKAS) += skas/ 10obj-$(CONFIG_MODE_SKAS) += skas/
@@ -15,9 +15,9 @@ user-objs-$(CONFIG_MODE_TT) += tt.o
15obj-$(CONFIG_TTY_LOG) += tty_log.o 15obj-$(CONFIG_TTY_LOG) += tty_log.o
16user-objs-$(CONFIG_TTY_LOG) += tty_log.o 16user-objs-$(CONFIG_TTY_LOG) += tty_log.o
17 17
18USER_OBJS := $(user-objs-y) aio.o elf_aux.o file.o helper.o irq.o main.o mem.o \ 18USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \
19 process.o sigio.o signal.o start_up.o time.o trap.o tty.o tls.o \ 19 main.o mem.o process.o sigio.o signal.o start_up.o time.o trap.o tty.o \
20 uaccess.o umid.o util.o 20 tls.o uaccess.o umid.o util.o
21 21
22CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH) 22CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH)
23 23
diff --git a/arch/um/os-Linux/execvp.c b/arch/um/os-Linux/execvp.c
new file mode 100644
index 000000000000..66e583a4031b
--- /dev/null
+++ b/arch/um/os-Linux/execvp.c
@@ -0,0 +1,149 @@
1/* Copyright (C) 2006 by Paolo Giarrusso - modified from glibc' execvp.c.
2 Original copyright notice follows:
3
4 Copyright (C) 1991,92,1995-99,2002,2004 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 The GNU C Library 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 GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA. */
21#include <unistd.h>
22
23#include <stdbool.h>
24#include <stdlib.h>
25#include <string.h>
26#include <errno.h>
27#include <limits.h>
28
29#ifndef TEST
30#include "um_malloc.h"
31#else
32#include <stdio.h>
33#define um_kmalloc malloc
34#endif
35#include "os.h"
36
37/* Execute FILE, searching in the `PATH' environment variable if it contains
38 no slashes, with arguments ARGV and environment from `environ'. */
39int execvp_noalloc(char *buf, const char *file, char *const argv[])
40{
41 if (*file == '\0') {
42 return -ENOENT;
43 }
44
45 if (strchr (file, '/') != NULL) {
46 /* Don't search when it contains a slash. */
47 execv(file, argv);
48 } else {
49 int got_eacces;
50 size_t len, pathlen;
51 char *name, *p;
52 char *path = getenv("PATH");
53 if (path == NULL)
54 path = ":/bin:/usr/bin";
55
56 len = strlen(file) + 1;
57 pathlen = strlen(path);
58 /* Copy the file name at the top. */
59 name = memcpy(buf + pathlen + 1, file, len);
60 /* And add the slash. */
61 *--name = '/';
62
63 got_eacces = 0;
64 p = path;
65 do {
66 char *startp;
67
68 path = p;
69 //Let's avoid this GNU extension.
70 //p = strchrnul (path, ':');
71 p = strchr(path, ':');
72 if (!p)
73 p = strchr(path, '\0');
74
75 if (p == path)
76 /* Two adjacent colons, or a colon at the beginning or the end
77 of `PATH' means to search the current directory. */
78 startp = name + 1;
79 else
80 startp = memcpy(name - (p - path), path, p - path);
81
82 /* Try to execute this name. If it works, execv will not return. */
83 execv(startp, argv);
84
85 /*
86 if (errno == ENOEXEC) {
87 }
88 */
89
90 switch (errno) {
91 case EACCES:
92 /* Record the we got a `Permission denied' error. If we end
93 up finding no executable we can use, we want to diagnose
94 that we did find one but were denied access. */
95 got_eacces = 1;
96 case ENOENT:
97 case ESTALE:
98 case ENOTDIR:
99 /* Those errors indicate the file is missing or not executable
100 by us, in which case we want to just try the next path
101 directory. */
102 case ENODEV:
103 case ETIMEDOUT:
104 /* Some strange filesystems like AFS return even
105 stranger error numbers. They cannot reasonably mean
106 anything else so ignore those, too. */
107 case ENOEXEC:
108 /* We won't go searching for the shell
109 * if it is not executable - the Linux
110 * kernel already handles this enough,
111 * for us. */
112 break;
113
114 default:
115 /* Some other error means we found an executable file, but
116 something went wrong executing it; return the error to our
117 caller. */
118 return -errno;
119 }
120 } while (*p++ != '\0');
121
122 /* We tried every element and none of them worked. */
123 if (got_eacces)
124 /* At least one failure was due to permissions, so report that
125 error. */
126 return -EACCES;
127 }
128
129 /* Return the error from the last attempt (probably ENOENT). */
130 return -errno;
131}
132#ifdef TEST
133int main(int argc, char**argv)
134{
135 char buf[PATH_MAX];
136 int ret;
137 argc--;
138 if (!argc) {
139 fprintf(stderr, "Not enough arguments\n");
140 return 1;
141 }
142 argv++;
143 if (ret = execvp_noalloc(buf, argv[0], argv)) {
144 errno = -ret;
145 perror("execvp_noalloc");
146 }
147 return 0;
148}
149#endif
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index d13299cfa318..c7ad6306e22f 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -8,18 +8,21 @@
8#include <unistd.h> 8#include <unistd.h>
9#include <errno.h> 9#include <errno.h>
10#include <sched.h> 10#include <sched.h>
11#include <limits.h>
11#include <sys/signal.h> 12#include <sys/signal.h>
12#include <sys/wait.h> 13#include <sys/wait.h>
13#include "user.h" 14#include "user.h"
14#include "kern_util.h" 15#include "kern_util.h"
15#include "user_util.h" 16#include "user_util.h"
16#include "os.h" 17#include "os.h"
18#include "um_malloc.h"
17 19
18struct helper_data { 20struct helper_data {
19 void (*pre_exec)(void*); 21 void (*pre_exec)(void*);
20 void *pre_data; 22 void *pre_data;
21 char **argv; 23 char **argv;
22 int fd; 24 int fd;
25 char *buf;
23}; 26};
24 27
25/* Debugging aid, changed only from gdb */ 28/* Debugging aid, changed only from gdb */
@@ -41,9 +44,8 @@ static int helper_child(void *arg)
41 } 44 }
42 if (data->pre_exec != NULL) 45 if (data->pre_exec != NULL)
43 (*data->pre_exec)(data->pre_data); 46 (*data->pre_exec)(data->pre_data);
44 execvp(argv[0], argv); 47 errval = execvp_noalloc(data->buf, argv[0], argv);
45 errval = -errno; 48 printk("helper_child - execvp of '%s' failed - errno = %d\n", argv[0], -errval);
46 printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno);
47 os_write_file(data->fd, &errval, sizeof(errval)); 49 os_write_file(data->fd, &errval, sizeof(errval));
48 kill(os_getpid(), SIGKILL); 50 kill(os_getpid(), SIGKILL);
49 return 0; 51 return 0;
@@ -84,11 +86,13 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
84 data.pre_data = pre_data; 86 data.pre_data = pre_data;
85 data.argv = argv; 87 data.argv = argv;
86 data.fd = fds[1]; 88 data.fd = fds[1];
89 data.buf = __cant_sleep() ? um_kmalloc_atomic(PATH_MAX) :
90 um_kmalloc(PATH_MAX);
87 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); 91 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
88 if (pid < 0) { 92 if (pid < 0) {
89 ret = -errno; 93 ret = -errno;
90 printk("run_helper : clone failed, errno = %d\n", errno); 94 printk("run_helper : clone failed, errno = %d\n", errno);
91 goto out_close; 95 goto out_free2;
92 } 96 }
93 97
94 close(fds[1]); 98 close(fds[1]);
@@ -109,6 +113,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
109 CATCH_EINTR(waitpid(pid, NULL, 0)); 113 CATCH_EINTR(waitpid(pid, NULL, 0));
110 } 114 }
111 115
116out_free2:
117 kfree(data.buf);
112out_close: 118out_close:
113 if (fds[1] != -1) 119 if (fds[1] != -1)
114 close(fds[1]); 120 close(fds[1]);
diff --git a/arch/v850/kernel/v850_ksyms.c b/arch/v850/kernel/v850_ksyms.c
index 67bc48e57c60..93575fdc874d 100644
--- a/arch/v850/kernel/v850_ksyms.c
+++ b/arch/v850/kernel/v850_ksyms.c
@@ -24,7 +24,7 @@ EXPORT_SYMBOL (kernel_thread);
24EXPORT_SYMBOL (__bug); 24EXPORT_SYMBOL (__bug);
25 25
26/* Networking helper routines. */ 26/* Networking helper routines. */
27EXPORT_SYMBOL (csum_partial_copy); 27EXPORT_SYMBOL (csum_partial_copy_nocheck);
28EXPORT_SYMBOL (csum_partial_copy_from_user); 28EXPORT_SYMBOL (csum_partial_copy_from_user);
29EXPORT_SYMBOL (ip_compute_csum); 29EXPORT_SYMBOL (ip_compute_csum);
30EXPORT_SYMBOL (ip_fast_csum); 30EXPORT_SYMBOL (ip_fast_csum);
diff --git a/arch/v850/lib/checksum.c b/arch/v850/lib/checksum.c
index fa5872633075..042158dfe17a 100644
--- a/arch/v850/lib/checksum.c
+++ b/arch/v850/lib/checksum.c
@@ -88,32 +88,32 @@ out:
88 * This is a version of ip_compute_csum() optimized for IP headers, 88 * This is a version of ip_compute_csum() optimized for IP headers,
89 * which always checksum on 4 octet boundaries. 89 * which always checksum on 4 octet boundaries.
90 */ 90 */
91unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) 91__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
92{ 92{
93 return ~do_csum(iph,ihl*4); 93 return (__force __sum16)~do_csum(iph,ihl*4);
94} 94}
95 95
96/* 96/*
97 * this routine is used for miscellaneous IP-like checksums, mainly 97 * this routine is used for miscellaneous IP-like checksums, mainly
98 * in icmp.c 98 * in icmp.c
99 */ 99 */
100unsigned short ip_compute_csum(const unsigned char * buff, int len) 100__sum16 ip_compute_csum(const void *buff, int len)
101{ 101{
102 return ~do_csum(buff,len); 102 return (__force __sum16)~do_csum(buff,len);
103} 103}
104 104
105/* 105/*
106 * computes a partial checksum, e.g. for TCP/UDP fragments 106 * computes a partial checksum, e.g. for TCP/UDP fragments
107 */ 107 */
108unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) 108__wsum csum_partial(const void *buff, int len, __wsum sum)
109{ 109{
110 unsigned int result = do_csum(buff, len); 110 unsigned int result = do_csum(buff, len);
111 111
112 /* add in old sum, and carry.. */ 112 /* add in old sum, and carry.. */
113 result += sum; 113 result += (__force u32)sum;
114 if(sum > result) 114 if ((__force u32)sum > result)
115 result += 1; 115 result += 1;
116 return result; 116 return (__force __wsum)result;
117} 117}
118 118
119EXPORT_SYMBOL(csum_partial); 119EXPORT_SYMBOL(csum_partial);
@@ -121,8 +121,8 @@ EXPORT_SYMBOL(csum_partial);
121/* 121/*
122 * copy while checksumming, otherwise like csum_partial 122 * copy while checksumming, otherwise like csum_partial
123 */ 123 */
124unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, 124__wsum csum_partial_copy_nocheck(const void *src, void *dst,
125 int len, unsigned int sum) 125 int len, __wsum sum)
126{ 126{
127 /* 127 /*
128 * It's 2:30 am and I don't feel like doing it real ... 128 * It's 2:30 am and I don't feel like doing it real ...
@@ -138,9 +138,9 @@ unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst,
138 * Copy from userspace and compute checksum. If we catch an exception 138 * Copy from userspace and compute checksum. If we catch an exception
139 * then zero the rest of the buffer. 139 * then zero the rest of the buffer.
140 */ 140 */
141unsigned int csum_partial_copy_from_user (const unsigned char *src, 141__wsum csum_partial_copy_from_user (const void *src,
142 unsigned char *dst, 142 void *dst,
143 int len, unsigned int sum, 143 int len, __wsum sum,
144 int *err_ptr) 144 int *err_ptr)
145{ 145{
146 int missing; 146 int missing;
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index e22ecd54870d..47b6d90349da 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -224,7 +224,7 @@ static int __init setup_early_printk(char *buf)
224 return 0; 224 return 0;
225 early_console_initialized = 1; 225 early_console_initialized = 1;
226 226
227 if (!strcmp(buf,"keep")) 227 if (strstr(buf, "keep"))
228 keep_early = 1; 228 keep_early = 1;
229 229
230 if (!strncmp(buf, "serial", 6)) { 230 if (!strncmp(buf, "serial", 6)) {
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 14654e682411..c80081a6ba41 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -754,10 +754,8 @@ void __setup_vector_irq(int cpu)
754{ 754{
755 /* Initialize vector_irq on a new cpu */ 755 /* Initialize vector_irq on a new cpu */
756 /* This function must be called with vector_lock held */ 756 /* This function must be called with vector_lock held */
757 unsigned long flags;
758 int irq, vector; 757 int irq, vector;
759 758
760
761 /* Mark the inuse vectors */ 759 /* Mark the inuse vectors */
762 for (irq = 0; irq < NR_IRQ_VECTORS; ++irq) { 760 for (irq = 0; irq < NR_IRQ_VECTORS; ++irq) {
763 if (!cpu_isset(cpu, irq_domain[irq])) 761 if (!cpu_isset(cpu, irq_domain[irq]))
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index a153d0a01b72..0d65b22f229c 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -242,12 +242,19 @@ static int dump_trace_unwind(struct unwind_frame_info *info, void *context)
242 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack 242 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
243 */ 243 */
244 244
245static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
246{
247 void *t = (void *)tinfo;
248 return p > t && p < t + THREAD_SIZE - 3;
249}
250
245void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack, 251void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack,
246 struct stacktrace_ops *ops, void *data) 252 struct stacktrace_ops *ops, void *data)
247{ 253{
248 const unsigned cpu = smp_processor_id(); 254 const unsigned cpu = smp_processor_id();
249 unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr; 255 unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
250 unsigned used = 0; 256 unsigned used = 0;
257 struct thread_info *tinfo;
251 258
252 if (!tsk) 259 if (!tsk)
253 tsk = current; 260 tsk = current;
@@ -370,7 +377,8 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
370 /* 377 /*
371 * This handles the process stack: 378 * This handles the process stack:
372 */ 379 */
373 HANDLE_STACK (((long) stack & (THREAD_SIZE-1)) != 0); 380 tinfo = current_thread_info();
381 HANDLE_STACK (valid_stack_ptr(tinfo, stack));
374#undef HANDLE_STACK 382#undef HANDLE_STACK
375} 383}
376EXPORT_SYMBOL(dump_trace); 384EXPORT_SYMBOL(dump_trace);
diff --git a/arch/x86_64/lib/csum-partial.c b/arch/x86_64/lib/csum-partial.c
index c493735218da..06ae630de82b 100644
--- a/arch/x86_64/lib/csum-partial.c
+++ b/arch/x86_64/lib/csum-partial.c
@@ -132,9 +132,10 @@ static __force_inline unsigned do_csum(const unsigned char *buff, unsigned len)
132 * 132 *
133 * it's best to have buff aligned on a 64-bit boundary 133 * it's best to have buff aligned on a 64-bit boundary
134 */ 134 */
135unsigned csum_partial(const unsigned char *buff, unsigned len, unsigned sum) 135__wsum csum_partial(const void *buff, int len, __wsum sum)
136{ 136{
137 return add32_with_carry(do_csum(buff, len), sum); 137 return (__force __wsum)add32_with_carry(do_csum(buff, len),
138 (__force u32)sum);
138} 139}
139 140
140EXPORT_SYMBOL(csum_partial); 141EXPORT_SYMBOL(csum_partial);
@@ -143,7 +144,7 @@ EXPORT_SYMBOL(csum_partial);
143 * this routine is used for miscellaneous IP-like checksums, mainly 144 * this routine is used for miscellaneous IP-like checksums, mainly
144 * in icmp.c 145 * in icmp.c
145 */ 146 */
146unsigned short ip_compute_csum(unsigned char * buff, int len) 147__sum16 ip_compute_csum(const void *buff, int len)
147{ 148{
148 return csum_fold(csum_partial(buff,len,0)); 149 return csum_fold(csum_partial(buff,len,0));
149} 150}
diff --git a/arch/x86_64/lib/csum-wrappers.c b/arch/x86_64/lib/csum-wrappers.c
index b1320ec58428..fd42a4a095fc 100644
--- a/arch/x86_64/lib/csum-wrappers.c
+++ b/arch/x86_64/lib/csum-wrappers.c
@@ -18,9 +18,9 @@
18 * Returns an 32bit unfolded checksum of the buffer. 18 * Returns an 32bit unfolded checksum of the buffer.
19 * src and dst are best aligned to 64bits. 19 * src and dst are best aligned to 64bits.
20 */ 20 */
21unsigned int 21__wsum
22csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst, 22csum_partial_copy_from_user(const void __user *src, void *dst,
23 int len, unsigned int isum, int *errp) 23 int len, __wsum isum, int *errp)
24{ 24{
25 might_sleep(); 25 might_sleep();
26 *errp = 0; 26 *errp = 0;
@@ -34,17 +34,19 @@ csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst,
34 if (unlikely((unsigned long)src & 6)) { 34 if (unlikely((unsigned long)src & 6)) {
35 while (((unsigned long)src & 6) && len >= 2) { 35 while (((unsigned long)src & 6) && len >= 2) {
36 __u16 val16; 36 __u16 val16;
37 *errp = __get_user(val16, (__u16 __user *)src); 37 *errp = __get_user(val16, (const __u16 __user *)src);
38 if (*errp) 38 if (*errp)
39 return isum; 39 return isum;
40 *(__u16 *)dst = val16; 40 *(__u16 *)dst = val16;
41 isum = add32_with_carry(isum, val16); 41 isum = (__force __wsum)add32_with_carry(
42 (__force unsigned)isum, val16);
42 src += 2; 43 src += 2;
43 dst += 2; 44 dst += 2;
44 len -= 2; 45 len -= 2;
45 } 46 }
46 } 47 }
47 isum = csum_partial_copy_generic((__force void *)src,dst,len,isum,errp,NULL); 48 isum = csum_partial_copy_generic((__force const void *)src,
49 dst, len, isum, errp, NULL);
48 if (likely(*errp == 0)) 50 if (likely(*errp == 0))
49 return isum; 51 return isum;
50 } 52 }
@@ -66,9 +68,9 @@ EXPORT_SYMBOL(csum_partial_copy_from_user);
66 * Returns an 32bit unfolded checksum of the buffer. 68 * Returns an 32bit unfolded checksum of the buffer.
67 * src and dst are best aligned to 64bits. 69 * src and dst are best aligned to 64bits.
68 */ 70 */
69unsigned int 71__wsum
70csum_partial_copy_to_user(unsigned const char *src, unsigned char __user *dst, 72csum_partial_copy_to_user(const void *src, void __user *dst,
71 int len, unsigned int isum, int *errp) 73 int len, __wsum isum, int *errp)
72{ 74{
73 might_sleep(); 75 might_sleep();
74 if (unlikely(!access_ok(VERIFY_WRITE, dst, len))) { 76 if (unlikely(!access_ok(VERIFY_WRITE, dst, len))) {
@@ -79,7 +81,8 @@ csum_partial_copy_to_user(unsigned const char *src, unsigned char __user *dst,
79 if (unlikely((unsigned long)dst & 6)) { 81 if (unlikely((unsigned long)dst & 6)) {
80 while (((unsigned long)dst & 6) && len >= 2) { 82 while (((unsigned long)dst & 6) && len >= 2) {
81 __u16 val16 = *(__u16 *)src; 83 __u16 val16 = *(__u16 *)src;
82 isum = add32_with_carry(isum, val16); 84 isum = (__force __wsum)add32_with_carry(
85 (__force unsigned)isum, val16);
83 *errp = __put_user(val16, (__u16 __user *)dst); 86 *errp = __put_user(val16, (__u16 __user *)dst);
84 if (*errp) 87 if (*errp)
85 return isum; 88 return isum;
@@ -104,19 +107,21 @@ EXPORT_SYMBOL(csum_partial_copy_to_user);
104 * 107 *
105 * Returns an 32bit unfolded checksum of the buffer. 108 * Returns an 32bit unfolded checksum of the buffer.
106 */ 109 */
107unsigned int 110__wsum
108csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, int len, unsigned int sum) 111csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
109{ 112{
110 return csum_partial_copy_generic(src,dst,len,sum,NULL,NULL); 113 return csum_partial_copy_generic(src,dst,len,sum,NULL,NULL);
111} 114}
112EXPORT_SYMBOL(csum_partial_copy_nocheck); 115EXPORT_SYMBOL(csum_partial_copy_nocheck);
113 116
114unsigned short csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, 117__sum16 csum_ipv6_magic(const struct in6_addr *saddr,
115 __u32 len, unsigned short proto, unsigned int sum) 118 const struct in6_addr *daddr,
119 __u32 len, unsigned short proto, __wsum sum)
116{ 120{
117 __u64 rest, sum64; 121 __u64 rest, sum64;
118 122
119 rest = (__u64)htonl(len) + (__u64)htons(proto) + (__u64)sum; 123 rest = (__force __u64)htonl(len) + (__force __u64)htons(proto) +
124 (__force __u64)sum;
120 asm(" addq (%[saddr]),%[sum]\n" 125 asm(" addq (%[saddr]),%[sum]\n"
121 " adcq 8(%[saddr]),%[sum]\n" 126 " adcq 8(%[saddr]),%[sum]\n"
122 " adcq (%[daddr]),%[sum]\n" 127 " adcq (%[daddr]),%[sum]\n"
@@ -124,7 +129,7 @@ unsigned short csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr,
124 " adcq $0,%[sum]\n" 129 " adcq $0,%[sum]\n"
125 : [sum] "=r" (sum64) 130 : [sum] "=r" (sum64)
126 : "[sum]" (rest),[saddr] "r" (saddr), [daddr] "r" (daddr)); 131 : "[sum]" (rest),[saddr] "r" (saddr), [daddr] "r" (daddr));
127 return csum_fold(add32_with_carry(sum64 & 0xffffffff, sum64>>32)); 132 return csum_fold((__force __wsum)add32_with_carry(sum64 & 0xffffffff, sum64>>32));
128} 133}
129 134
130EXPORT_SYMBOL(csum_ipv6_magic); 135EXPORT_SYMBOL(csum_ipv6_magic);
diff --git a/block/as-iosched.c b/block/as-iosched.c
index f371c9359999..5934c4bfd52a 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -1318,7 +1318,7 @@ static void as_exit_queue(elevator_t *e)
1318/* 1318/*
1319 * initialize elevator private data (as_data). 1319 * initialize elevator private data (as_data).
1320 */ 1320 */
1321static void *as_init_queue(request_queue_t *q, elevator_t *e) 1321static void *as_init_queue(request_queue_t *q)
1322{ 1322{
1323 struct as_data *ad; 1323 struct as_data *ad;
1324 1324
diff --git a/block/blktrace.c b/block/blktrace.c
index 135593c8e45b..562ca7cbf858 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -22,30 +22,61 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/debugfs.h> 24#include <linux/debugfs.h>
25#include <linux/time.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26 27
27static DEFINE_PER_CPU(unsigned long long, blk_trace_cpu_offset) = { 0, }; 28static DEFINE_PER_CPU(unsigned long long, blk_trace_cpu_offset) = { 0, };
28static unsigned int blktrace_seq __read_mostly = 1; 29static unsigned int blktrace_seq __read_mostly = 1;
29 30
30/* 31/*
32 * Send out a notify message.
33 */
34static inline unsigned int trace_note(struct blk_trace *bt,
35 pid_t pid, int action,
36 const void *data, size_t len)
37{
38 struct blk_io_trace *t;
39 int cpu = smp_processor_id();
40
41 t = relay_reserve(bt->rchan, sizeof(*t) + len);
42 if (t == NULL)
43 return 0;
44
45 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
46 t->time = sched_clock() - per_cpu(blk_trace_cpu_offset, cpu);
47 t->device = bt->dev;
48 t->action = action;
49 t->pid = pid;
50 t->cpu = cpu;
51 t->pdu_len = len;
52 memcpy((void *) t + sizeof(*t), data, len);
53 return blktrace_seq;
54}
55
56/*
31 * Send out a notify for this process, if we haven't done so since a trace 57 * Send out a notify for this process, if we haven't done so since a trace
32 * started 58 * started
33 */ 59 */
34static void trace_note_tsk(struct blk_trace *bt, struct task_struct *tsk) 60static void trace_note_tsk(struct blk_trace *bt, struct task_struct *tsk)
35{ 61{
36 struct blk_io_trace *t; 62 tsk->btrace_seq = trace_note(bt, tsk->pid,
63 BLK_TN_PROCESS,
64 tsk->comm, sizeof(tsk->comm));
65}
37 66
38 t = relay_reserve(bt->rchan, sizeof(*t) + sizeof(tsk->comm)); 67static void trace_note_time(struct blk_trace *bt)
39 if (t) { 68{
40 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; 69 struct timespec now;
41 t->device = bt->dev; 70 unsigned long flags;
42 t->action = BLK_TC_ACT(BLK_TC_NOTIFY); 71 u32 words[2];
43 t->pid = tsk->pid; 72
44 t->cpu = smp_processor_id(); 73 getnstimeofday(&now);
45 t->pdu_len = sizeof(tsk->comm); 74 words[0] = now.tv_sec;
46 memcpy((void *) t + sizeof(*t), tsk->comm, t->pdu_len); 75 words[1] = now.tv_nsec;
47 tsk->btrace_seq = blktrace_seq; 76
48 } 77 local_irq_save(flags);
78 trace_note(bt, 0, BLK_TN_TIMESTAMP, words, sizeof(words));
79 local_irq_restore(flags);
49} 80}
50 81
51static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector, 82static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector,
@@ -394,6 +425,8 @@ static int blk_trace_startstop(request_queue_t *q, int start)
394 blktrace_seq++; 425 blktrace_seq++;
395 smp_mb(); 426 smp_mb();
396 bt->trace_state = Blktrace_running; 427 bt->trace_state = Blktrace_running;
428
429 trace_note_time(bt);
397 ret = 0; 430 ret = 0;
398 } 431 }
399 } else { 432 } else {
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 6cec3a1dccb8..84e9be073180 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1464,8 +1464,7 @@ cfq_update_io_thinktime(struct cfq_data *cfqd, struct cfq_io_context *cic)
1464} 1464}
1465 1465
1466static void 1466static void
1467cfq_update_io_seektime(struct cfq_data *cfqd, struct cfq_io_context *cic, 1467cfq_update_io_seektime(struct cfq_io_context *cic, struct request *rq)
1468 struct request *rq)
1469{ 1468{
1470 sector_t sdist; 1469 sector_t sdist;
1471 u64 total; 1470 u64 total;
@@ -1617,7 +1616,7 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1617 } 1616 }
1618 1617
1619 cfq_update_io_thinktime(cfqd, cic); 1618 cfq_update_io_thinktime(cfqd, cic);
1620 cfq_update_io_seektime(cfqd, cic, rq); 1619 cfq_update_io_seektime(cic, rq);
1621 cfq_update_idle_window(cfqd, cfqq, cic); 1620 cfq_update_idle_window(cfqd, cfqq, cic);
1622 1621
1623 cic->last_queue = jiffies; 1622 cic->last_queue = jiffies;
@@ -1770,7 +1769,7 @@ static int cfq_may_queue(request_queue_t *q, int rw)
1770/* 1769/*
1771 * queue lock held here 1770 * queue lock held here
1772 */ 1771 */
1773static void cfq_put_request(request_queue_t *q, struct request *rq) 1772static void cfq_put_request(struct request *rq)
1774{ 1773{
1775 struct cfq_queue *cfqq = RQ_CFQQ(rq); 1774 struct cfq_queue *cfqq = RQ_CFQQ(rq);
1776 1775
@@ -1953,7 +1952,7 @@ static void cfq_exit_queue(elevator_t *e)
1953 kfree(cfqd); 1952 kfree(cfqd);
1954} 1953}
1955 1954
1956static void *cfq_init_queue(request_queue_t *q, elevator_t *e) 1955static void *cfq_init_queue(request_queue_t *q)
1957{ 1956{
1958 struct cfq_data *cfqd; 1957 struct cfq_data *cfqd;
1959 int i; 1958 int i;
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index b7c5b34cb7b4..6d673e938d3e 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -356,7 +356,7 @@ static void deadline_exit_queue(elevator_t *e)
356/* 356/*
357 * initialize elevator private data (deadline_data). 357 * initialize elevator private data (deadline_data).
358 */ 358 */
359static void *deadline_init_queue(request_queue_t *q, elevator_t *e) 359static void *deadline_init_queue(request_queue_t *q)
360{ 360{
361 struct deadline_data *dd; 361 struct deadline_data *dd;
362 362
diff --git a/block/elevator.c b/block/elevator.c
index 8ccd163254b8..c0063f345c5d 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -129,7 +129,7 @@ static struct elevator_type *elevator_get(const char *name)
129 129
130static void *elevator_init_queue(request_queue_t *q, struct elevator_queue *eq) 130static void *elevator_init_queue(request_queue_t *q, struct elevator_queue *eq)
131{ 131{
132 return eq->ops->elevator_init_fn(q, eq); 132 return eq->ops->elevator_init_fn(q);
133} 133}
134 134
135static void elevator_attach(request_queue_t *q, struct elevator_queue *eq, 135static void elevator_attach(request_queue_t *q, struct elevator_queue *eq,
@@ -810,7 +810,7 @@ void elv_put_request(request_queue_t *q, struct request *rq)
810 elevator_t *e = q->elevator; 810 elevator_t *e = q->elevator;
811 811
812 if (e->ops->elevator_put_req_fn) 812 if (e->ops->elevator_put_req_fn)
813 e->ops->elevator_put_req_fn(q, rq); 813 e->ops->elevator_put_req_fn(rq);
814} 814}
815 815
816int elv_may_queue(request_queue_t *q, int rw) 816int elv_may_queue(request_queue_t *q, int rw)
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index eb4cf6df7374..cc6e95f8e5d9 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -2322,6 +2322,84 @@ void blk_insert_request(request_queue_t *q, struct request *rq,
2322 2322
2323EXPORT_SYMBOL(blk_insert_request); 2323EXPORT_SYMBOL(blk_insert_request);
2324 2324
2325static int __blk_rq_unmap_user(struct bio *bio)
2326{
2327 int ret = 0;
2328
2329 if (bio) {
2330 if (bio_flagged(bio, BIO_USER_MAPPED))
2331 bio_unmap_user(bio);
2332 else
2333 ret = bio_uncopy_user(bio);
2334 }
2335
2336 return ret;
2337}
2338
2339static int __blk_rq_map_user(request_queue_t *q, struct request *rq,
2340 void __user *ubuf, unsigned int len)
2341{
2342 unsigned long uaddr;
2343 struct bio *bio, *orig_bio;
2344 int reading, ret;
2345
2346 reading = rq_data_dir(rq) == READ;
2347
2348 /*
2349 * if alignment requirement is satisfied, map in user pages for
2350 * direct dma. else, set up kernel bounce buffers
2351 */
2352 uaddr = (unsigned long) ubuf;
2353 if (!(uaddr & queue_dma_alignment(q)) && !(len & queue_dma_alignment(q)))
2354 bio = bio_map_user(q, NULL, uaddr, len, reading);
2355 else
2356 bio = bio_copy_user(q, uaddr, len, reading);
2357
2358 if (IS_ERR(bio)) {
2359 return PTR_ERR(bio);
2360 }
2361
2362 orig_bio = bio;
2363 blk_queue_bounce(q, &bio);
2364 /*
2365 * We link the bounce buffer in and could have to traverse it
2366 * later so we have to get a ref to prevent it from being freed
2367 */
2368 bio_get(bio);
2369
2370 /*
2371 * for most (all? don't know of any) queues we could
2372 * skip grabbing the queue lock here. only drivers with
2373 * funky private ->back_merge_fn() function could be
2374 * problematic.
2375 */
2376 spin_lock_irq(q->queue_lock);
2377 if (!rq->bio)
2378 blk_rq_bio_prep(q, rq, bio);
2379 else if (!q->back_merge_fn(q, rq, bio)) {
2380 ret = -EINVAL;
2381 spin_unlock_irq(q->queue_lock);
2382 goto unmap_bio;
2383 } else {
2384 rq->biotail->bi_next = bio;
2385 rq->biotail = bio;
2386
2387 rq->nr_sectors += bio_sectors(bio);
2388 rq->hard_nr_sectors = rq->nr_sectors;
2389 rq->data_len += bio->bi_size;
2390 }
2391 spin_unlock_irq(q->queue_lock);
2392
2393 return bio->bi_size;
2394
2395unmap_bio:
2396 /* if it was boucned we must call the end io function */
2397 bio_endio(bio, bio->bi_size, 0);
2398 __blk_rq_unmap_user(orig_bio);
2399 bio_put(bio);
2400 return ret;
2401}
2402
2325/** 2403/**
2326 * blk_rq_map_user - map user data to a request, for REQ_BLOCK_PC usage 2404 * blk_rq_map_user - map user data to a request, for REQ_BLOCK_PC usage
2327 * @q: request queue where request should be inserted 2405 * @q: request queue where request should be inserted
@@ -2343,42 +2421,44 @@ EXPORT_SYMBOL(blk_insert_request);
2343 * unmapping. 2421 * unmapping.
2344 */ 2422 */
2345int blk_rq_map_user(request_queue_t *q, struct request *rq, void __user *ubuf, 2423int blk_rq_map_user(request_queue_t *q, struct request *rq, void __user *ubuf,
2346 unsigned int len) 2424 unsigned long len)
2347{ 2425{
2348 unsigned long uaddr; 2426 unsigned long bytes_read = 0;
2349 struct bio *bio; 2427 int ret;
2350 int reading;
2351 2428
2352 if (len > (q->max_hw_sectors << 9)) 2429 if (len > (q->max_hw_sectors << 9))
2353 return -EINVAL; 2430 return -EINVAL;
2354 if (!len || !ubuf) 2431 if (!len || !ubuf)
2355 return -EINVAL; 2432 return -EINVAL;
2356 2433
2357 reading = rq_data_dir(rq) == READ; 2434 while (bytes_read != len) {
2435 unsigned long map_len, end, start;
2358 2436
2359 /* 2437 map_len = min_t(unsigned long, len - bytes_read, BIO_MAX_SIZE);
2360 * if alignment requirement is satisfied, map in user pages for 2438 end = ((unsigned long)ubuf + map_len + PAGE_SIZE - 1)
2361 * direct dma. else, set up kernel bounce buffers 2439 >> PAGE_SHIFT;
2362 */ 2440 start = (unsigned long)ubuf >> PAGE_SHIFT;
2363 uaddr = (unsigned long) ubuf;
2364 if (!(uaddr & queue_dma_alignment(q)) && !(len & queue_dma_alignment(q)))
2365 bio = bio_map_user(q, NULL, uaddr, len, reading);
2366 else
2367 bio = bio_copy_user(q, uaddr, len, reading);
2368 2441
2369 if (!IS_ERR(bio)) { 2442 /*
2370 rq->bio = rq->biotail = bio; 2443 * A bad offset could cause us to require BIO_MAX_PAGES + 1
2371 blk_rq_bio_prep(q, rq, bio); 2444 * pages. If this happens we just lower the requested
2445 * mapping len by a page so that we can fit
2446 */
2447 if (end - start > BIO_MAX_PAGES)
2448 map_len -= PAGE_SIZE;
2372 2449
2373 rq->buffer = rq->data = NULL; 2450 ret = __blk_rq_map_user(q, rq, ubuf, map_len);
2374 rq->data_len = len; 2451 if (ret < 0)
2375 return 0; 2452 goto unmap_rq;
2453 bytes_read += ret;
2454 ubuf += ret;
2376 } 2455 }
2377 2456
2378 /* 2457 rq->buffer = rq->data = NULL;
2379 * bio is the err-ptr 2458 return 0;
2380 */ 2459unmap_rq:
2381 return PTR_ERR(bio); 2460 blk_rq_unmap_user(rq);
2461 return ret;
2382} 2462}
2383 2463
2384EXPORT_SYMBOL(blk_rq_map_user); 2464EXPORT_SYMBOL(blk_rq_map_user);
@@ -2404,7 +2484,7 @@ EXPORT_SYMBOL(blk_rq_map_user);
2404 * unmapping. 2484 * unmapping.
2405 */ 2485 */
2406int blk_rq_map_user_iov(request_queue_t *q, struct request *rq, 2486int blk_rq_map_user_iov(request_queue_t *q, struct request *rq,
2407 struct sg_iovec *iov, int iov_count) 2487 struct sg_iovec *iov, int iov_count, unsigned int len)
2408{ 2488{
2409 struct bio *bio; 2489 struct bio *bio;
2410 2490
@@ -2418,10 +2498,15 @@ int blk_rq_map_user_iov(request_queue_t *q, struct request *rq,
2418 if (IS_ERR(bio)) 2498 if (IS_ERR(bio))
2419 return PTR_ERR(bio); 2499 return PTR_ERR(bio);
2420 2500
2421 rq->bio = rq->biotail = bio; 2501 if (bio->bi_size != len) {
2502 bio_endio(bio, bio->bi_size, 0);
2503 bio_unmap_user(bio);
2504 return -EINVAL;
2505 }
2506
2507 bio_get(bio);
2422 blk_rq_bio_prep(q, rq, bio); 2508 blk_rq_bio_prep(q, rq, bio);
2423 rq->buffer = rq->data = NULL; 2509 rq->buffer = rq->data = NULL;
2424 rq->data_len = bio->bi_size;
2425 return 0; 2510 return 0;
2426} 2511}
2427 2512
@@ -2429,23 +2514,26 @@ EXPORT_SYMBOL(blk_rq_map_user_iov);
2429 2514
2430/** 2515/**
2431 * blk_rq_unmap_user - unmap a request with user data 2516 * blk_rq_unmap_user - unmap a request with user data
2432 * @bio: bio to be unmapped 2517 * @rq: rq to be unmapped
2433 * @ulen: length of user buffer
2434 * 2518 *
2435 * Description: 2519 * Description:
2436 * Unmap a bio previously mapped by blk_rq_map_user(). 2520 * Unmap a rq previously mapped by blk_rq_map_user().
2521 * rq->bio must be set to the original head of the request.
2437 */ 2522 */
2438int blk_rq_unmap_user(struct bio *bio, unsigned int ulen) 2523int blk_rq_unmap_user(struct request *rq)
2439{ 2524{
2440 int ret = 0; 2525 struct bio *bio, *mapped_bio;
2441 2526
2442 if (bio) { 2527 while ((bio = rq->bio)) {
2443 if (bio_flagged(bio, BIO_USER_MAPPED)) 2528 if (bio_flagged(bio, BIO_BOUNCED))
2444 bio_unmap_user(bio); 2529 mapped_bio = bio->bi_private;
2445 else 2530 else
2446 ret = bio_uncopy_user(bio); 2531 mapped_bio = bio;
2447 }
2448 2532
2533 __blk_rq_unmap_user(mapped_bio);
2534 rq->bio = bio->bi_next;
2535 bio_put(bio);
2536 }
2449 return 0; 2537 return 0;
2450} 2538}
2451 2539
@@ -2476,11 +2564,8 @@ int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf,
2476 if (rq_data_dir(rq) == WRITE) 2564 if (rq_data_dir(rq) == WRITE)
2477 bio->bi_rw |= (1 << BIO_RW); 2565 bio->bi_rw |= (1 << BIO_RW);
2478 2566
2479 rq->bio = rq->biotail = bio;
2480 blk_rq_bio_prep(q, rq, bio); 2567 blk_rq_bio_prep(q, rq, bio);
2481
2482 rq->buffer = rq->data = NULL; 2568 rq->buffer = rq->data = NULL;
2483 rq->data_len = len;
2484 return 0; 2569 return 0;
2485} 2570}
2486 2571
@@ -3495,6 +3580,7 @@ void blk_rq_bio_prep(request_queue_t *q, struct request *rq, struct bio *bio)
3495 rq->hard_cur_sectors = rq->current_nr_sectors; 3580 rq->hard_cur_sectors = rq->current_nr_sectors;
3496 rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio); 3581 rq->hard_nr_sectors = rq->nr_sectors = bio_sectors(bio);
3497 rq->buffer = bio_data(bio); 3582 rq->buffer = bio_data(bio);
3583 rq->data_len = bio->bi_size;
3498 3584
3499 rq->bio = rq->biotail = bio; 3585 rq->bio = rq->biotail = bio;
3500} 3586}
diff --git a/block/noop-iosched.c b/block/noop-iosched.c
index 79af43179421..1c3de2b9a6b5 100644
--- a/block/noop-iosched.c
+++ b/block/noop-iosched.c
@@ -65,7 +65,7 @@ noop_latter_request(request_queue_t *q, struct request *rq)
65 return list_entry(rq->queuelist.next, struct request, queuelist); 65 return list_entry(rq->queuelist.next, struct request, queuelist);
66} 66}
67 67
68static void *noop_init_queue(request_queue_t *q, elevator_t *e) 68static void *noop_init_queue(request_queue_t *q)
69{ 69{
70 struct noop_data *nd; 70 struct noop_data *nd;
71 71
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index e55a75621437..5493c2fbbab1 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -226,7 +226,6 @@ static int sg_io(struct file *file, request_queue_t *q,
226 unsigned long start_time; 226 unsigned long start_time;
227 int writing = 0, ret = 0; 227 int writing = 0, ret = 0;
228 struct request *rq; 228 struct request *rq;
229 struct bio *bio;
230 char sense[SCSI_SENSE_BUFFERSIZE]; 229 char sense[SCSI_SENSE_BUFFERSIZE];
231 unsigned char cmd[BLK_MAX_CDB]; 230 unsigned char cmd[BLK_MAX_CDB];
232 231
@@ -258,30 +257,6 @@ static int sg_io(struct file *file, request_queue_t *q,
258 if (!rq) 257 if (!rq)
259 return -ENOMEM; 258 return -ENOMEM;
260 259
261 if (hdr->iovec_count) {
262 const int size = sizeof(struct sg_iovec) * hdr->iovec_count;
263 struct sg_iovec *iov;
264
265 iov = kmalloc(size, GFP_KERNEL);
266 if (!iov) {
267 ret = -ENOMEM;
268 goto out;
269 }
270
271 if (copy_from_user(iov, hdr->dxferp, size)) {
272 kfree(iov);
273 ret = -EFAULT;
274 goto out;
275 }
276
277 ret = blk_rq_map_user_iov(q, rq, iov, hdr->iovec_count);
278 kfree(iov);
279 } else if (hdr->dxfer_len)
280 ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len);
281
282 if (ret)
283 goto out;
284
285 /* 260 /*
286 * fill in request structure 261 * fill in request structure
287 */ 262 */
@@ -294,7 +269,6 @@ static int sg_io(struct file *file, request_queue_t *q,
294 rq->sense_len = 0; 269 rq->sense_len = 0;
295 270
296 rq->cmd_type = REQ_TYPE_BLOCK_PC; 271 rq->cmd_type = REQ_TYPE_BLOCK_PC;
297 bio = rq->bio;
298 272
299 /* 273 /*
300 * bounce this after holding a reference to the original bio, it's 274 * bounce this after holding a reference to the original bio, it's
@@ -309,6 +283,31 @@ static int sg_io(struct file *file, request_queue_t *q,
309 if (!rq->timeout) 283 if (!rq->timeout)
310 rq->timeout = BLK_DEFAULT_TIMEOUT; 284 rq->timeout = BLK_DEFAULT_TIMEOUT;
311 285
286 if (hdr->iovec_count) {
287 const int size = sizeof(struct sg_iovec) * hdr->iovec_count;
288 struct sg_iovec *iov;
289
290 iov = kmalloc(size, GFP_KERNEL);
291 if (!iov) {
292 ret = -ENOMEM;
293 goto out;
294 }
295
296 if (copy_from_user(iov, hdr->dxferp, size)) {
297 kfree(iov);
298 ret = -EFAULT;
299 goto out;
300 }
301
302 ret = blk_rq_map_user_iov(q, rq, iov, hdr->iovec_count,
303 hdr->dxfer_len);
304 kfree(iov);
305 } else if (hdr->dxfer_len)
306 ret = blk_rq_map_user(q, rq, hdr->dxferp, hdr->dxfer_len);
307
308 if (ret)
309 goto out;
310
312 rq->retries = 0; 311 rq->retries = 0;
313 312
314 start_time = jiffies; 313 start_time = jiffies;
@@ -339,7 +338,7 @@ static int sg_io(struct file *file, request_queue_t *q,
339 hdr->sb_len_wr = len; 338 hdr->sb_len_wr = len;
340 } 339 }
341 340
342 if (blk_rq_unmap_user(bio, hdr->dxfer_len)) 341 if (blk_rq_unmap_user(rq))
343 ret = -EFAULT; 342 ret = -EFAULT;
344 343
345 /* may not have succeeded, but output values written to control 344 /* may not have succeeded, but output values written to control
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 10f160dc75b1..a2f46d587d55 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -267,9 +267,9 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
267{ 267{
268 acpi_status status; 268 acpi_status status;
269 269
270 if (dev->firmware_data) { 270 if (dev->archdata.acpi_handle) {
271 printk(KERN_WARNING PREFIX 271 printk(KERN_WARNING PREFIX
272 "Drivers changed 'firmware_data' for %s\n", dev->bus_id); 272 "Drivers changed 'acpi_handle' for %s\n", dev->bus_id);
273 return -EINVAL; 273 return -EINVAL;
274 } 274 }
275 get_device(dev); 275 get_device(dev);
@@ -278,25 +278,26 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
278 put_device(dev); 278 put_device(dev);
279 return -EINVAL; 279 return -EINVAL;
280 } 280 }
281 dev->firmware_data = handle; 281 dev->archdata.acpi_handle = handle;
282 282
283 return 0; 283 return 0;
284} 284}
285 285
286static int acpi_unbind_one(struct device *dev) 286static int acpi_unbind_one(struct device *dev)
287{ 287{
288 if (!dev->firmware_data) 288 if (!dev->archdata.acpi_handle)
289 return 0; 289 return 0;
290 if (dev == acpi_get_physical_device(dev->firmware_data)) { 290 if (dev == acpi_get_physical_device(dev->archdata.acpi_handle)) {
291 /* acpi_get_physical_device increase refcnt by one */ 291 /* acpi_get_physical_device increase refcnt by one */
292 put_device(dev); 292 put_device(dev);
293 acpi_detach_data(dev->firmware_data, acpi_glue_data_handler); 293 acpi_detach_data(dev->archdata.acpi_handle,
294 dev->firmware_data = NULL; 294 acpi_glue_data_handler);
295 dev->archdata.acpi_handle = NULL;
295 /* acpi_bind_one increase refcnt by one */ 296 /* acpi_bind_one increase refcnt by one */
296 put_device(dev); 297 put_device(dev);
297 } else { 298 } else {
298 printk(KERN_ERR PREFIX 299 printk(KERN_ERR PREFIX
299 "Oops, 'firmware_data' corrupt for %s\n", dev->bus_id); 300 "Oops, 'acpi_handle' corrupt for %s\n", dev->bus_id);
300 } 301 }
301 return 0; 302 return 0;
302} 303}
@@ -328,7 +329,8 @@ static int acpi_platform_notify(struct device *dev)
328 if (!ret) { 329 if (!ret) {
329 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 330 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
330 331
331 acpi_get_name(dev->firmware_data, ACPI_FULL_PATHNAME, &buffer); 332 acpi_get_name(dev->archdata.acpi_handle,
333 ACPI_FULL_PATHNAME, &buffer);
332 DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer); 334 DBG("Device %s -> %s\n", dev->bus_id, (char *)buffer.pointer);
333 kfree(buffer.pointer); 335 kfree(buffer.pointer);
334 } else 336 } else
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 7ba5e49ab302..6fd174a37149 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -83,10 +83,8 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
83 goto out; 83 goto out;
84 84
85 ppc = (unsigned int)pr->performance_platform_limit; 85 ppc = (unsigned int)pr->performance_platform_limit;
86 if (!ppc)
87 goto out;
88 86
89 if (ppc > pr->performance->state_count) 87 if (ppc >= pr->performance->state_count)
90 goto out; 88 goto out;
91 89
92 cpufreq_verify_within_limits(policy, 0, 90 cpufreq_verify_within_limits(policy, 0,
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 234197e57e9e..bddb14e91d3c 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -78,6 +78,7 @@ enum {
78 78
79 board_ahci = 0, 79 board_ahci = 0,
80 board_ahci_vt8251 = 1, 80 board_ahci_vt8251 = 1,
81 board_ahci_ign_iferr = 2,
81 82
82 /* global controller registers */ 83 /* global controller registers */
83 HOST_CAP = 0x00, /* host capabilities */ 84 HOST_CAP = 0x00, /* host capabilities */
@@ -168,6 +169,7 @@ enum {
168 /* ap->flags bits */ 169 /* ap->flags bits */
169 AHCI_FLAG_RESET_NEEDS_CLO = (1 << 24), 170 AHCI_FLAG_RESET_NEEDS_CLO = (1 << 24),
170 AHCI_FLAG_NO_NCQ = (1 << 25), 171 AHCI_FLAG_NO_NCQ = (1 << 25),
172 AHCI_FLAG_IGN_IRQ_IF_ERR = (1 << 26), /* ignore IRQ_IF_ERR */
171}; 173};
172 174
173struct ahci_cmd_hdr { 175struct ahci_cmd_hdr {
@@ -295,6 +297,17 @@ static const struct ata_port_info ahci_port_info[] = {
295 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 297 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
296 .port_ops = &ahci_ops, 298 .port_ops = &ahci_ops,
297 }, 299 },
300 /* board_ahci_ign_iferr */
301 {
302 .sht = &ahci_sht,
303 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
304 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
305 ATA_FLAG_SKIP_D2H_BSY |
306 AHCI_FLAG_IGN_IRQ_IF_ERR,
307 .pio_mask = 0x1f, /* pio0-4 */
308 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
309 .port_ops = &ahci_ops,
310 },
298}; 311};
299 312
300static const struct pci_device_id ahci_pci_tbl[] = { 313static const struct pci_device_id ahci_pci_tbl[] = {
@@ -314,13 +327,24 @@ static const struct pci_device_id ahci_pci_tbl[] = {
314 { PCI_VDEVICE(INTEL, 0x2824), board_ahci }, /* ICH8 */ 327 { PCI_VDEVICE(INTEL, 0x2824), board_ahci }, /* ICH8 */
315 { PCI_VDEVICE(INTEL, 0x2829), board_ahci }, /* ICH8M */ 328 { PCI_VDEVICE(INTEL, 0x2829), board_ahci }, /* ICH8M */
316 { PCI_VDEVICE(INTEL, 0x282a), board_ahci }, /* ICH8M */ 329 { PCI_VDEVICE(INTEL, 0x282a), board_ahci }, /* ICH8M */
330 { PCI_VDEVICE(INTEL, 0x2922), board_ahci }, /* ICH9 */
331 { PCI_VDEVICE(INTEL, 0x2923), board_ahci }, /* ICH9 */
332 { PCI_VDEVICE(INTEL, 0x2924), board_ahci }, /* ICH9 */
333 { PCI_VDEVICE(INTEL, 0x2925), board_ahci }, /* ICH9 */
334 { PCI_VDEVICE(INTEL, 0x2927), board_ahci }, /* ICH9 */
335 { PCI_VDEVICE(INTEL, 0x2929), board_ahci }, /* ICH9M */
336 { PCI_VDEVICE(INTEL, 0x292a), board_ahci }, /* ICH9M */
337 { PCI_VDEVICE(INTEL, 0x292b), board_ahci }, /* ICH9M */
338 { PCI_VDEVICE(INTEL, 0x292f), board_ahci }, /* ICH9M */
339 { PCI_VDEVICE(INTEL, 0x294d), board_ahci }, /* ICH9 */
340 { PCI_VDEVICE(INTEL, 0x294e), board_ahci }, /* ICH9M */
317 341
318 /* JMicron */ 342 /* JMicron */
319 { PCI_VDEVICE(JMICRON, 0x2360), board_ahci }, /* JMicron JMB360 */ 343 { PCI_VDEVICE(JMICRON, 0x2360), board_ahci_ign_iferr }, /* JMB360 */
320 { PCI_VDEVICE(JMICRON, 0x2361), board_ahci }, /* JMicron JMB361 */ 344 { PCI_VDEVICE(JMICRON, 0x2361), board_ahci_ign_iferr }, /* JMB361 */
321 { PCI_VDEVICE(JMICRON, 0x2363), board_ahci }, /* JMicron JMB363 */ 345 { PCI_VDEVICE(JMICRON, 0x2363), board_ahci_ign_iferr }, /* JMB363 */
322 { PCI_VDEVICE(JMICRON, 0x2365), board_ahci }, /* JMicron JMB365 */ 346 { PCI_VDEVICE(JMICRON, 0x2365), board_ahci_ign_iferr }, /* JMB365 */
323 { PCI_VDEVICE(JMICRON, 0x2366), board_ahci }, /* JMicron JMB366 */ 347 { PCI_VDEVICE(JMICRON, 0x2366), board_ahci_ign_iferr }, /* JMB366 */
324 348
325 /* ATI */ 349 /* ATI */
326 { PCI_VDEVICE(ATI, 0x4380), board_ahci }, /* ATI SB600 non-raid */ 350 { PCI_VDEVICE(ATI, 0x4380), board_ahci }, /* ATI SB600 non-raid */
@@ -969,6 +993,10 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
969 /* analyze @irq_stat */ 993 /* analyze @irq_stat */
970 ata_ehi_push_desc(ehi, "irq_stat 0x%08x", irq_stat); 994 ata_ehi_push_desc(ehi, "irq_stat 0x%08x", irq_stat);
971 995
996 /* some controllers set IRQ_IF_ERR on device errors, ignore it */
997 if (ap->flags & AHCI_FLAG_IGN_IRQ_IF_ERR)
998 irq_stat &= ~PORT_IRQ_IF_ERR;
999
972 if (irq_stat & PORT_IRQ_TF_ERR) 1000 if (irq_stat & PORT_IRQ_TF_ERR)
973 err_mask |= AC_ERR_DEV; 1001 err_mask |= AC_ERR_DEV;
974 1002
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 377425e71391..4a80ff9312b8 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -116,6 +116,7 @@ static struct scsi_host_template generic_sht = {
116 .proc_name = DRV_NAME, 116 .proc_name = DRV_NAME,
117 .dma_boundary = ATA_DMA_BOUNDARY, 117 .dma_boundary = ATA_DMA_BOUNDARY,
118 .slave_configure = ata_scsi_slave_config, 118 .slave_configure = ata_scsi_slave_config,
119 .slave_destroy = ata_scsi_slave_destroy,
119 .bios_param = ata_std_bios_param, 120 .bios_param = ata_std_bios_param,
120}; 121};
121 122
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index c872b324dbd3..4c32d93d44b1 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1451,6 +1451,7 @@ nothing_to_do:
1451 1451
1452static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) 1452static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1453{ 1453{
1454 struct ata_port *ap = qc->ap;
1454 struct scsi_cmnd *cmd = qc->scsicmd; 1455 struct scsi_cmnd *cmd = qc->scsicmd;
1455 u8 *cdb = cmd->cmnd; 1456 u8 *cdb = cmd->cmnd;
1456 int need_sense = (qc->err_mask != 0); 1457 int need_sense = (qc->err_mask != 0);
@@ -1459,11 +1460,12 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1459 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE 1460 * schedule EH_REVALIDATE operation to update the IDENTIFY DEVICE
1460 * cache 1461 * cache
1461 */ 1462 */
1462 if (!need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) && 1463 if (ap->ops->error_handler &&
1464 !need_sense && (qc->tf.command == ATA_CMD_SET_FEATURES) &&
1463 ((qc->tf.feature == SETFEATURES_WC_ON) || 1465 ((qc->tf.feature == SETFEATURES_WC_ON) ||
1464 (qc->tf.feature == SETFEATURES_WC_OFF))) { 1466 (qc->tf.feature == SETFEATURES_WC_OFF))) {
1465 qc->ap->eh_info.action |= ATA_EH_REVALIDATE; 1467 ap->eh_info.action |= ATA_EH_REVALIDATE;
1466 ata_port_schedule_eh(qc->ap); 1468 ata_port_schedule_eh(ap);
1467 } 1469 }
1468 1470
1469 /* For ATA pass thru (SAT) commands, generate a sense block if 1471 /* For ATA pass thru (SAT) commands, generate a sense block if
@@ -1490,8 +1492,8 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1490 } 1492 }
1491 } 1493 }
1492 1494
1493 if (need_sense && !qc->ap->ops->error_handler) 1495 if (need_sense && !ap->ops->error_handler)
1494 ata_dump_status(qc->ap->id, &qc->result_tf); 1496 ata_dump_status(ap->id, &qc->result_tf);
1495 1497
1496 qc->scsidone(cmd); 1498 qc->scsidone(cmd);
1497 1499
@@ -3347,20 +3349,23 @@ EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
3347 * @ap: ATA port to which the command is being sent 3349 * @ap: ATA port to which the command is being sent
3348 * 3350 *
3349 * RETURNS: 3351 * RETURNS:
3350 * Zero. 3352 * Return value from __ata_scsi_queuecmd() if @cmd can be queued,
3353 * 0 otherwise.
3351 */ 3354 */
3352 3355
3353int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), 3356int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
3354 struct ata_port *ap) 3357 struct ata_port *ap)
3355{ 3358{
3359 int rc = 0;
3360
3356 ata_scsi_dump_cdb(ap, cmd); 3361 ata_scsi_dump_cdb(ap, cmd);
3357 3362
3358 if (likely(ata_scsi_dev_enabled(ap->device))) 3363 if (likely(ata_scsi_dev_enabled(ap->device)))
3359 __ata_scsi_queuecmd(cmd, done, ap->device); 3364 rc = __ata_scsi_queuecmd(cmd, done, ap->device);
3360 else { 3365 else {
3361 cmd->result = (DID_BAD_TARGET << 16); 3366 cmd->result = (DID_BAD_TARGET << 16);
3362 done(cmd); 3367 done(cmd);
3363 } 3368 }
3364 return 0; 3369 return rc;
3365} 3370}
3366EXPORT_SYMBOL_GPL(ata_sas_queuecmd); 3371EXPORT_SYMBOL_GPL(ata_sas_queuecmd);
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 1d695df5860a..64eed99f6814 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -346,6 +346,7 @@ static struct scsi_host_template ali_sht = {
346 .proc_name = DRV_NAME, 346 .proc_name = DRV_NAME,
347 .dma_boundary = ATA_DMA_BOUNDARY, 347 .dma_boundary = ATA_DMA_BOUNDARY,
348 .slave_configure = ata_scsi_slave_config, 348 .slave_configure = ata_scsi_slave_config,
349 .slave_destroy = ata_scsi_slave_destroy,
349 .bios_param = ata_std_bios_param, 350 .bios_param = ata_std_bios_param,
350}; 351};
351 352
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 5c47a9e0e0ca..8be46a63af74 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -333,6 +333,7 @@ static struct scsi_host_template amd_sht = {
333 .proc_name = DRV_NAME, 333 .proc_name = DRV_NAME,
334 .dma_boundary = ATA_DMA_BOUNDARY, 334 .dma_boundary = ATA_DMA_BOUNDARY,
335 .slave_configure = ata_scsi_slave_config, 335 .slave_configure = ata_scsi_slave_config,
336 .slave_destroy = ata_scsi_slave_destroy,
336 .bios_param = ata_std_bios_param, 337 .bios_param = ata_std_bios_param,
337}; 338};
338 339
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 96a098020a8f..2cd30761ca1f 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -314,6 +314,7 @@ static struct scsi_host_template artop_sht = {
314 .proc_name = DRV_NAME, 314 .proc_name = DRV_NAME,
315 .dma_boundary = ATA_DMA_BOUNDARY, 315 .dma_boundary = ATA_DMA_BOUNDARY,
316 .slave_configure = ata_scsi_slave_config, 316 .slave_configure = ata_scsi_slave_config,
317 .slave_destroy = ata_scsi_slave_destroy,
317 .bios_param = ata_std_bios_param, 318 .bios_param = ata_std_bios_param,
318}; 319};
319 320
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 1ce28d2125f4..4e1d3b59adbb 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -216,6 +216,7 @@ static struct scsi_host_template atiixp_sht = {
216 .proc_name = DRV_NAME, 216 .proc_name = DRV_NAME,
217 .dma_boundary = ATA_DMA_BOUNDARY, 217 .dma_boundary = ATA_DMA_BOUNDARY,
218 .slave_configure = ata_scsi_slave_config, 218 .slave_configure = ata_scsi_slave_config,
219 .slave_destroy = ata_scsi_slave_destroy,
219 .bios_param = ata_std_bios_param, 220 .bios_param = ata_std_bios_param,
220}; 221};
221 222
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index b9bbd1d454bf..29a60df465da 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -275,6 +275,7 @@ static struct scsi_host_template cmd64x_sht = {
275 .proc_name = DRV_NAME, 275 .proc_name = DRV_NAME,
276 .dma_boundary = ATA_DMA_BOUNDARY, 276 .dma_boundary = ATA_DMA_BOUNDARY,
277 .slave_configure = ata_scsi_slave_config, 277 .slave_configure = ata_scsi_slave_config,
278 .slave_destroy = ata_scsi_slave_destroy,
278 .bios_param = ata_std_bios_param, 279 .bios_param = ata_std_bios_param,
279}; 280};
280 281
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index 2cd3c0ff76df..33d2b88f9c79 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -166,6 +166,7 @@ static struct scsi_host_template cs5520_sht = {
166 .proc_name = DRV_NAME, 166 .proc_name = DRV_NAME,
167 .dma_boundary = ATA_DMA_BOUNDARY, 167 .dma_boundary = ATA_DMA_BOUNDARY,
168 .slave_configure = ata_scsi_slave_config, 168 .slave_configure = ata_scsi_slave_config,
169 .slave_destroy = ata_scsi_slave_destroy,
169 .bios_param = ata_std_bios_param, 170 .bios_param = ata_std_bios_param,
170}; 171};
171 172
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index a07cc81ef791..981f49223469 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -180,6 +180,7 @@ static struct scsi_host_template cs5530_sht = {
180 .proc_name = DRV_NAME, 180 .proc_name = DRV_NAME,
181 .dma_boundary = ATA_DMA_BOUNDARY, 181 .dma_boundary = ATA_DMA_BOUNDARY,
182 .slave_configure = ata_scsi_slave_config, 182 .slave_configure = ata_scsi_slave_config,
183 .slave_destroy = ata_scsi_slave_destroy,
183 .bios_param = ata_std_bios_param, 184 .bios_param = ata_std_bios_param,
184}; 185};
185 186
diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
index f8def3f9c618..8dafa4a49fdc 100644
--- a/drivers/ata/pata_cs5535.c
+++ b/drivers/ata/pata_cs5535.c
@@ -184,6 +184,7 @@ static struct scsi_host_template cs5535_sht = {
184 .proc_name = DRV_NAME, 184 .proc_name = DRV_NAME,
185 .dma_boundary = ATA_DMA_BOUNDARY, 185 .dma_boundary = ATA_DMA_BOUNDARY,
186 .slave_configure = ata_scsi_slave_config, 186 .slave_configure = ata_scsi_slave_config,
187 .slave_destroy = ata_scsi_slave_destroy,
187 .bios_param = ata_std_bios_param, 188 .bios_param = ata_std_bios_param,
188}; 189};
189 190
diff --git a/drivers/ata/pata_cypress.c b/drivers/ata/pata_cypress.c
index 247b43608b14..5a0b811907ee 100644
--- a/drivers/ata/pata_cypress.c
+++ b/drivers/ata/pata_cypress.c
@@ -135,6 +135,7 @@ static struct scsi_host_template cy82c693_sht = {
135 .proc_name = DRV_NAME, 135 .proc_name = DRV_NAME,
136 .dma_boundary = ATA_DMA_BOUNDARY, 136 .dma_boundary = ATA_DMA_BOUNDARY,
137 .slave_configure = ata_scsi_slave_config, 137 .slave_configure = ata_scsi_slave_config,
138 .slave_destroy = ata_scsi_slave_destroy,
138 .bios_param = ata_std_bios_param, 139 .bios_param = ata_std_bios_param,
139}; 140};
140 141
diff --git a/drivers/ata/pata_efar.c b/drivers/ata/pata_efar.c
index ef18c60fe140..755f79279de3 100644
--- a/drivers/ata/pata_efar.c
+++ b/drivers/ata/pata_efar.c
@@ -233,6 +233,7 @@ static struct scsi_host_template efar_sht = {
233 .proc_name = DRV_NAME, 233 .proc_name = DRV_NAME,
234 .dma_boundary = ATA_DMA_BOUNDARY, 234 .dma_boundary = ATA_DMA_BOUNDARY,
235 .slave_configure = ata_scsi_slave_config, 235 .slave_configure = ata_scsi_slave_config,
236 .slave_destroy = ata_scsi_slave_destroy,
236 .bios_param = ata_std_bios_param, 237 .bios_param = ata_std_bios_param,
237}; 238};
238 239
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 6d3e4c0f15fe..c0e150a9586b 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -329,6 +329,7 @@ static struct scsi_host_template hpt36x_sht = {
329 .proc_name = DRV_NAME, 329 .proc_name = DRV_NAME,
330 .dma_boundary = ATA_DMA_BOUNDARY, 330 .dma_boundary = ATA_DMA_BOUNDARY,
331 .slave_configure = ata_scsi_slave_config, 331 .slave_configure = ata_scsi_slave_config,
332 .slave_destroy = ata_scsi_slave_destroy,
332 .bios_param = ata_std_bios_param, 333 .bios_param = ata_std_bios_param,
333}; 334};
334 335
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index fce3fcdc7e79..1eeb16f0fb02 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -775,6 +775,7 @@ static struct scsi_host_template hpt37x_sht = {
775 .proc_name = DRV_NAME, 775 .proc_name = DRV_NAME,
776 .dma_boundary = ATA_DMA_BOUNDARY, 776 .dma_boundary = ATA_DMA_BOUNDARY,
777 .slave_configure = ata_scsi_slave_config, 777 .slave_configure = ata_scsi_slave_config,
778 .slave_destroy = ata_scsi_slave_destroy,
778 .bios_param = ata_std_bios_param, 779 .bios_param = ata_std_bios_param,
779}; 780};
780 781
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index 58cfb2bc8098..47d7664e9eee 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -341,6 +341,7 @@ static struct scsi_host_template hpt3x2n_sht = {
341 .proc_name = DRV_NAME, 341 .proc_name = DRV_NAME,
342 .dma_boundary = ATA_DMA_BOUNDARY, 342 .dma_boundary = ATA_DMA_BOUNDARY,
343 .slave_configure = ata_scsi_slave_config, 343 .slave_configure = ata_scsi_slave_config,
344 .slave_destroy = ata_scsi_slave_destroy,
344 .bios_param = ata_std_bios_param, 345 .bios_param = ata_std_bios_param,
345}; 346};
346 347
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index 3334d72e251b..d216cc564b56 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -118,6 +118,7 @@ static struct scsi_host_template hpt3x3_sht = {
118 .proc_name = DRV_NAME, 118 .proc_name = DRV_NAME,
119 .dma_boundary = ATA_DMA_BOUNDARY, 119 .dma_boundary = ATA_DMA_BOUNDARY,
120 .slave_configure = ata_scsi_slave_config, 120 .slave_configure = ata_scsi_slave_config,
121 .slave_destroy = ata_scsi_slave_destroy,
121 .bios_param = ata_std_bios_param, 122 .bios_param = ata_std_bios_param,
122}; 123};
123 124
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index 640b8b0954f5..40ca2b82b7fc 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -34,6 +34,7 @@ static struct scsi_host_template isapnp_sht = {
34 .proc_name = DRV_NAME, 34 .proc_name = DRV_NAME,
35 .dma_boundary = ATA_DMA_BOUNDARY, 35 .dma_boundary = ATA_DMA_BOUNDARY,
36 .slave_configure = ata_scsi_slave_config, 36 .slave_configure = ata_scsi_slave_config,
37 .slave_destroy = ata_scsi_slave_destroy,
37 .bios_param = ata_std_bios_param, 38 .bios_param = ata_std_bios_param,
38}; 39};
39 40
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 18ff3e59a89b..7f68f14be6fd 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -675,6 +675,7 @@ static struct scsi_host_template it821x_sht = {
675 .proc_name = DRV_NAME, 675 .proc_name = DRV_NAME,
676 .dma_boundary = ATA_DMA_BOUNDARY, 676 .dma_boundary = ATA_DMA_BOUNDARY,
677 .slave_configure = ata_scsi_slave_config, 677 .slave_configure = ata_scsi_slave_config,
678 .slave_destroy = ata_scsi_slave_destroy,
678 .bios_param = ata_std_bios_param, 679 .bios_param = ata_std_bios_param,
679}; 680};
680 681
diff --git a/drivers/ata/pata_jmicron.c b/drivers/ata/pata_jmicron.c
index 52a2bdf3c38d..0210b10d49cd 100644
--- a/drivers/ata/pata_jmicron.c
+++ b/drivers/ata/pata_jmicron.c
@@ -136,6 +136,7 @@ static struct scsi_host_template jmicron_sht = {
136 .proc_name = DRV_NAME, 136 .proc_name = DRV_NAME,
137 .dma_boundary = ATA_DMA_BOUNDARY, 137 .dma_boundary = ATA_DMA_BOUNDARY,
138 .slave_configure = ata_scsi_slave_config, 138 .slave_configure = ata_scsi_slave_config,
139 .slave_destroy = ata_scsi_slave_destroy,
139 /* Use standard CHS mapping rules */ 140 /* Use standard CHS mapping rules */
140 .bios_param = ata_std_bios_param, 141 .bios_param = ata_std_bios_param,
141}; 142};
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index 10231ef731d1..b39078b2a47b 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -135,6 +135,7 @@ static struct scsi_host_template legacy_sht = {
135 .proc_name = DRV_NAME, 135 .proc_name = DRV_NAME,
136 .dma_boundary = ATA_DMA_BOUNDARY, 136 .dma_boundary = ATA_DMA_BOUNDARY,
137 .slave_configure = ata_scsi_slave_config, 137 .slave_configure = ata_scsi_slave_config,
138 .slave_destroy = ata_scsi_slave_destroy,
138 .bios_param = ata_std_bios_param, 139 .bios_param = ata_std_bios_param,
139}; 140};
140 141
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index 9dfe3e9abea3..e00d406bfdf5 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -166,6 +166,7 @@ static struct scsi_host_template mpiix_sht = {
166 .proc_name = DRV_NAME, 166 .proc_name = DRV_NAME,
167 .dma_boundary = ATA_DMA_BOUNDARY, 167 .dma_boundary = ATA_DMA_BOUNDARY,
168 .slave_configure = ata_scsi_slave_config, 168 .slave_configure = ata_scsi_slave_config,
169 .slave_destroy = ata_scsi_slave_destroy,
169 .bios_param = ata_std_bios_param, 170 .bios_param = ata_std_bios_param,
170}; 171};
171 172
diff --git a/drivers/ata/pata_netcell.c b/drivers/ata/pata_netcell.c
index f5672de99c22..1963a4d35873 100644
--- a/drivers/ata/pata_netcell.c
+++ b/drivers/ata/pata_netcell.c
@@ -62,6 +62,7 @@ static struct scsi_host_template netcell_sht = {
62 .proc_name = DRV_NAME, 62 .proc_name = DRV_NAME,
63 .dma_boundary = ATA_DMA_BOUNDARY, 63 .dma_boundary = ATA_DMA_BOUNDARY,
64 .slave_configure = ata_scsi_slave_config, 64 .slave_configure = ata_scsi_slave_config,
65 .slave_destroy = ata_scsi_slave_destroy,
65 /* Use standard CHS mapping rules */ 66 /* Use standard CHS mapping rules */
66 .bios_param = ata_std_bios_param, 67 .bios_param = ata_std_bios_param,
67}; 68};
diff --git a/drivers/ata/pata_ns87410.c b/drivers/ata/pata_ns87410.c
index 2a3dbeed89b4..7ec800f00ec8 100644
--- a/drivers/ata/pata_ns87410.c
+++ b/drivers/ata/pata_ns87410.c
@@ -156,6 +156,7 @@ static struct scsi_host_template ns87410_sht = {
156 .proc_name = DRV_NAME, 156 .proc_name = DRV_NAME,
157 .dma_boundary = ATA_DMA_BOUNDARY, 157 .dma_boundary = ATA_DMA_BOUNDARY,
158 .slave_configure = ata_scsi_slave_config, 158 .slave_configure = ata_scsi_slave_config,
159 .slave_destroy = ata_scsi_slave_destroy,
159 .bios_param = ata_std_bios_param, 160 .bios_param = ata_std_bios_param,
160}; 161};
161 162
diff --git a/drivers/ata/pata_oldpiix.c b/drivers/ata/pata_oldpiix.c
index fc947dfecd73..8837256632e9 100644
--- a/drivers/ata/pata_oldpiix.c
+++ b/drivers/ata/pata_oldpiix.c
@@ -231,6 +231,7 @@ static struct scsi_host_template oldpiix_sht = {
231 .proc_name = DRV_NAME, 231 .proc_name = DRV_NAME,
232 .dma_boundary = ATA_DMA_BOUNDARY, 232 .dma_boundary = ATA_DMA_BOUNDARY,
233 .slave_configure = ata_scsi_slave_config, 233 .slave_configure = ata_scsi_slave_config,
234 .slave_destroy = ata_scsi_slave_destroy,
234 .bios_param = ata_std_bios_param, 235 .bios_param = ata_std_bios_param,
235}; 236};
236 237
diff --git a/drivers/ata/pata_opti.c b/drivers/ata/pata_opti.c
index a7320ba15575..c6319cf50de4 100644
--- a/drivers/ata/pata_opti.c
+++ b/drivers/ata/pata_opti.c
@@ -202,6 +202,7 @@ static struct scsi_host_template opti_sht = {
202 .proc_name = DRV_NAME, 202 .proc_name = DRV_NAME,
203 .dma_boundary = ATA_DMA_BOUNDARY, 203 .dma_boundary = ATA_DMA_BOUNDARY,
204 .slave_configure = ata_scsi_slave_config, 204 .slave_configure = ata_scsi_slave_config,
205 .slave_destroy = ata_scsi_slave_destroy,
205 .bios_param = ata_std_bios_param, 206 .bios_param = ata_std_bios_param,
206}; 207};
207 208
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index c6906b4215de..2f4770cce04e 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -359,6 +359,7 @@ static struct scsi_host_template optidma_sht = {
359 .proc_name = DRV_NAME, 359 .proc_name = DRV_NAME,
360 .dma_boundary = ATA_DMA_BOUNDARY, 360 .dma_boundary = ATA_DMA_BOUNDARY,
361 .slave_configure = ata_scsi_slave_config, 361 .slave_configure = ata_scsi_slave_config,
362 .slave_destroy = ata_scsi_slave_destroy,
362 .bios_param = ata_std_bios_param, 363 .bios_param = ata_std_bios_param,
363}; 364};
364 365
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index e93ea2702c73..999922de476e 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -69,6 +69,7 @@ static struct scsi_host_template pcmcia_sht = {
69 .proc_name = DRV_NAME, 69 .proc_name = DRV_NAME,
70 .dma_boundary = ATA_DMA_BOUNDARY, 70 .dma_boundary = ATA_DMA_BOUNDARY,
71 .slave_configure = ata_scsi_slave_config, 71 .slave_configure = ata_scsi_slave_config,
72 .slave_destroy = ata_scsi_slave_destroy,
72 .bios_param = ata_std_bios_param, 73 .bios_param = ata_std_bios_param,
73}; 74};
74 75
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index d894d9918b1d..beb6d10a234b 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -141,6 +141,7 @@ static struct scsi_host_template pdc2027x_sht = {
141 .proc_name = DRV_NAME, 141 .proc_name = DRV_NAME,
142 .dma_boundary = ATA_DMA_BOUNDARY, 142 .dma_boundary = ATA_DMA_BOUNDARY,
143 .slave_configure = ata_scsi_slave_config, 143 .slave_configure = ata_scsi_slave_config,
144 .slave_destroy = ata_scsi_slave_destroy,
144 .bios_param = ata_std_bios_param, 145 .bios_param = ata_std_bios_param,
145}; 146};
146 147
diff --git a/drivers/ata/pata_pdc202xx_old.c b/drivers/ata/pata_pdc202xx_old.c
index 5ba9eb20a6c2..6baf51b2fda1 100644
--- a/drivers/ata/pata_pdc202xx_old.c
+++ b/drivers/ata/pata_pdc202xx_old.c
@@ -269,6 +269,7 @@ static struct scsi_host_template pdc_sht = {
269 .proc_name = DRV_NAME, 269 .proc_name = DRV_NAME,
270 .dma_boundary = ATA_DMA_BOUNDARY, 270 .dma_boundary = ATA_DMA_BOUNDARY,
271 .slave_configure = ata_scsi_slave_config, 271 .slave_configure = ata_scsi_slave_config,
272 .slave_destroy = ata_scsi_slave_destroy,
272 .bios_param = ata_std_bios_param, 273 .bios_param = ata_std_bios_param,
273}; 274};
274 275
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 2c3cc0ccc606..314938dea1fc 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -164,6 +164,7 @@ static struct scsi_host_template qdi_sht = {
164 .proc_name = DRV_NAME, 164 .proc_name = DRV_NAME,
165 .dma_boundary = ATA_DMA_BOUNDARY, 165 .dma_boundary = ATA_DMA_BOUNDARY,
166 .slave_configure = ata_scsi_slave_config, 166 .slave_configure = ata_scsi_slave_config,
167 .slave_destroy = ata_scsi_slave_destroy,
167 .bios_param = ata_std_bios_param, 168 .bios_param = ata_std_bios_param,
168}; 169};
169 170
diff --git a/drivers/ata/pata_radisys.c b/drivers/ata/pata_radisys.c
index 1af83d7694d5..048c2bb21ef1 100644
--- a/drivers/ata/pata_radisys.c
+++ b/drivers/ata/pata_radisys.c
@@ -227,6 +227,7 @@ static struct scsi_host_template radisys_sht = {
227 .proc_name = DRV_NAME, 227 .proc_name = DRV_NAME,
228 .dma_boundary = ATA_DMA_BOUNDARY, 228 .dma_boundary = ATA_DMA_BOUNDARY,
229 .slave_configure = ata_scsi_slave_config, 229 .slave_configure = ata_scsi_slave_config,
230 .slave_destroy = ata_scsi_slave_destroy,
230 .bios_param = ata_std_bios_param, 231 .bios_param = ata_std_bios_param,
231}; 232};
232 233
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 4533b6357d99..e4e5ea423fef 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -90,6 +90,7 @@ static struct scsi_host_template rz1000_sht = {
90 .proc_name = DRV_NAME, 90 .proc_name = DRV_NAME,
91 .dma_boundary = ATA_DMA_BOUNDARY, 91 .dma_boundary = ATA_DMA_BOUNDARY,
92 .slave_configure = ata_scsi_slave_config, 92 .slave_configure = ata_scsi_slave_config,
93 .slave_destroy = ata_scsi_slave_destroy,
93 .bios_param = ata_std_bios_param, 94 .bios_param = ata_std_bios_param,
94}; 95};
95 96
diff --git a/drivers/ata/pata_sc1200.c b/drivers/ata/pata_sc1200.c
index 067d9d223e35..0c75dae74764 100644
--- a/drivers/ata/pata_sc1200.c
+++ b/drivers/ata/pata_sc1200.c
@@ -193,6 +193,7 @@ static struct scsi_host_template sc1200_sht = {
193 .proc_name = DRV_NAME, 193 .proc_name = DRV_NAME,
194 .dma_boundary = ATA_DMA_BOUNDARY, 194 .dma_boundary = ATA_DMA_BOUNDARY,
195 .slave_configure = ata_scsi_slave_config, 195 .slave_configure = ata_scsi_slave_config,
196 .slave_destroy = ata_scsi_slave_destroy,
196 .bios_param = ata_std_bios_param, 197 .bios_param = ata_std_bios_param,
197}; 198};
198 199
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index 5bbf76ec14a4..be7f60efcb61 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -325,6 +325,7 @@ static struct scsi_host_template serverworks_sht = {
325 .proc_name = DRV_NAME, 325 .proc_name = DRV_NAME,
326 .dma_boundary = ATA_DMA_BOUNDARY, 326 .dma_boundary = ATA_DMA_BOUNDARY,
327 .slave_configure = ata_scsi_slave_config, 327 .slave_configure = ata_scsi_slave_config,
328 .slave_destroy = ata_scsi_slave_destroy,
328 .bios_param = ata_std_bios_param, 329 .bios_param = ata_std_bios_param,
329}; 330};
330 331
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 4a2b72b4be8a..11942fd03b55 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -225,6 +225,7 @@ static struct scsi_host_template sil680_sht = {
225 .proc_name = DRV_NAME, 225 .proc_name = DRV_NAME,
226 .dma_boundary = ATA_DMA_BOUNDARY, 226 .dma_boundary = ATA_DMA_BOUNDARY,
227 .slave_configure = ata_scsi_slave_config, 227 .slave_configure = ata_scsi_slave_config,
228 .slave_destroy = ata_scsi_slave_destroy,
228 .bios_param = ata_std_bios_param, 229 .bios_param = ata_std_bios_param,
229}; 230};
230 231
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index b9ffafb4198c..91e85f90941d 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -545,6 +545,7 @@ static struct scsi_host_template sis_sht = {
545 .proc_name = DRV_NAME, 545 .proc_name = DRV_NAME,
546 .dma_boundary = ATA_DMA_BOUNDARY, 546 .dma_boundary = ATA_DMA_BOUNDARY,
547 .slave_configure = ata_scsi_slave_config, 547 .slave_configure = ata_scsi_slave_config,
548 .slave_destroy = ata_scsi_slave_destroy,
548 .bios_param = ata_std_bios_param, 549 .bios_param = ata_std_bios_param,
549}; 550};
550 551
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 08a6dc88676f..dc1cfc6d805b 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -237,6 +237,7 @@ static struct scsi_host_template sl82c105_sht = {
237 .proc_name = DRV_NAME, 237 .proc_name = DRV_NAME,
238 .dma_boundary = ATA_DMA_BOUNDARY, 238 .dma_boundary = ATA_DMA_BOUNDARY,
239 .slave_configure = ata_scsi_slave_config, 239 .slave_configure = ata_scsi_slave_config,
240 .slave_destroy = ata_scsi_slave_destroy,
240 .bios_param = ata_std_bios_param, 241 .bios_param = ata_std_bios_param,
241}; 242};
242 243
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index 9640f80e8b0d..bfda1f7e760a 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -192,6 +192,7 @@ static struct scsi_host_template triflex_sht = {
192 .proc_name = DRV_NAME, 192 .proc_name = DRV_NAME,
193 .dma_boundary = ATA_DMA_BOUNDARY, 193 .dma_boundary = ATA_DMA_BOUNDARY,
194 .slave_configure = ata_scsi_slave_config, 194 .slave_configure = ata_scsi_slave_config,
195 .slave_destroy = ata_scsi_slave_destroy,
195 .bios_param = ata_std_bios_param, 196 .bios_param = ata_std_bios_param,
196}; 197};
197 198
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 1e7be9eee9c3..c5f1616d224d 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -295,6 +295,7 @@ static struct scsi_host_template via_sht = {
295 .proc_name = DRV_NAME, 295 .proc_name = DRV_NAME,
296 .dma_boundary = ATA_DMA_BOUNDARY, 296 .dma_boundary = ATA_DMA_BOUNDARY,
297 .slave_configure = ata_scsi_slave_config, 297 .slave_configure = ata_scsi_slave_config,
298 .slave_destroy = ata_scsi_slave_destroy,
298 .bios_param = ata_std_bios_param, 299 .bios_param = ata_std_bios_param,
299}; 300};
300 301
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 9fffa7af6db1..afa7d750a593 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -972,7 +972,7 @@ static int make_rate (unsigned int rate, rounding r,
972 } 972 }
973 case round_up: { 973 case round_up: {
974 // check all bits that we are discarding 974 // check all bits that we are discarding
975 if (man & (-1>>9)) { 975 if (man & (~0U>>9)) {
976 man = (man>>(32-9)) + 1; 976 man = (man>>(32-9)) + 1;
977 if (man == (1<<9)) { 977 if (man == (1<<9)) {
978 // no need to check for round up outside of range 978 // no need to check for round up outside of range
diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
index 697ad82f6634..9c67df5ccfa4 100644
--- a/drivers/atm/firestream.c
+++ b/drivers/atm/firestream.c
@@ -512,7 +512,7 @@ static unsigned int make_rate (unsigned int rate, int r,
512 } 512 }
513 case ROUND_UP: { 513 case ROUND_UP: {
514 /* check all bits that we are discarding */ 514 /* check all bits that we are discarding */
515 if (man & (-1>>9)) { 515 if (man & (~0U>>9)) {
516 man = (man>>(32-9)) + 1; 516 man = (man>>(32-9)) + 1;
517 if (man == (1<<9)) { 517 if (man == (1<<9)) {
518 /* no need to check for round up outside of range */ 518 /* no need to check for round up outside of range */
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 9ed1c60048f0..bb7ef570514c 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -305,7 +305,7 @@ static void clear_lockup (struct atm_vcc *vcc, IADEV *dev) {
305** | R | NZ | 5-bit exponent | 9-bit mantissa | 305** | R | NZ | 5-bit exponent | 9-bit mantissa |
306** +----+----+------------------+-------------------------------+ 306** +----+----+------------------+-------------------------------+
307** 307**
308** R = reserverd (written as 0) 308** R = reserved (written as 0)
309** NZ = 0 if 0 cells/sec; 1 otherwise 309** NZ = 0 if 0 cells/sec; 1 otherwise
310** 310**
311** if NZ = 1, rate = 1.mmmmmmmmm x 2^(eeeee) cells/sec 311** if NZ = 1, rate = 1.mmmmmmmmm x 2^(eeeee) cells/sec
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 7d8a7ce73fb3..472810f8e6e7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -355,6 +355,21 @@ static void device_remove_attrs(struct bus_type * bus, struct device * dev)
355 } 355 }
356} 356}
357 357
358#ifdef CONFIG_SYSFS_DEPRECATED
359static int make_deprecated_bus_links(struct device *dev)
360{
361 return sysfs_create_link(&dev->kobj,
362 &dev->bus->subsys.kset.kobj, "bus");
363}
364
365static void remove_deprecated_bus_links(struct device *dev)
366{
367 sysfs_remove_link(&dev->kobj, "bus");
368}
369#else
370static inline int make_deprecated_bus_links(struct device *dev) { return 0; }
371static inline void remove_deprecated_bus_links(struct device *dev) { }
372#endif
358 373
359/** 374/**
360 * bus_add_device - add device to bus 375 * bus_add_device - add device to bus
@@ -381,8 +396,7 @@ int bus_add_device(struct device * dev)
381 &dev->bus->subsys.kset.kobj, "subsystem"); 396 &dev->bus->subsys.kset.kobj, "subsystem");
382 if (error) 397 if (error)
383 goto out_subsys; 398 goto out_subsys;
384 error = sysfs_create_link(&dev->kobj, 399 error = make_deprecated_bus_links(dev);
385 &dev->bus->subsys.kset.kobj, "bus");
386 if (error) 400 if (error)
387 goto out_deprecated; 401 goto out_deprecated;
388 } 402 }
@@ -436,7 +450,7 @@ void bus_remove_device(struct device * dev)
436{ 450{
437 if (dev->bus) { 451 if (dev->bus) {
438 sysfs_remove_link(&dev->kobj, "subsystem"); 452 sysfs_remove_link(&dev->kobj, "subsystem");
439 sysfs_remove_link(&dev->kobj, "bus"); 453 remove_deprecated_bus_links(dev);
440 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); 454 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
441 device_remove_attrs(dev->bus, dev); 455 device_remove_attrs(dev->bus, dev);
442 if (dev->is_registered) { 456 if (dev->is_registered) {
@@ -724,6 +738,8 @@ int bus_register(struct bus_type * bus)
724{ 738{
725 int retval; 739 int retval;
726 740
741 BLOCKING_INIT_NOTIFIER_HEAD(&bus->bus_notifier);
742
727 retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name); 743 retval = kobject_set_name(&bus->subsys.kset.kobj, "%s", bus->name);
728 if (retval) 744 if (retval)
729 goto out; 745 goto out;
@@ -782,6 +798,18 @@ void bus_unregister(struct bus_type * bus)
782 subsystem_unregister(&bus->subsys); 798 subsystem_unregister(&bus->subsys);
783} 799}
784 800
801int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb)
802{
803 return blocking_notifier_chain_register(&bus->bus_notifier, nb);
804}
805EXPORT_SYMBOL_GPL(bus_register_notifier);
806
807int bus_unregister_notifier(struct bus_type *bus, struct notifier_block *nb)
808{
809 return blocking_notifier_chain_unregister(&bus->bus_notifier, nb);
810}
811EXPORT_SYMBOL_GPL(bus_unregister_notifier);
812
785int __init buses_init(void) 813int __init buses_init(void)
786{ 814{
787 return subsystem_register(&bus_subsys); 815 return subsystem_register(&bus_subsys);
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 0ff267a248db..f098881f45b2 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -352,6 +352,92 @@ static const char *class_uevent_name(struct kset *kset, struct kobject *kobj)
352 return class_dev->class->name; 352 return class_dev->class->name;
353} 353}
354 354
355#ifdef CONFIG_SYSFS_DEPRECATED
356char *make_class_name(const char *name, struct kobject *kobj)
357{
358 char *class_name;
359 int size;
360
361 size = strlen(name) + strlen(kobject_name(kobj)) + 2;
362
363 class_name = kmalloc(size, GFP_KERNEL);
364 if (!class_name)
365 return ERR_PTR(-ENOMEM);
366
367 strcpy(class_name, name);
368 strcat(class_name, ":");
369 strcat(class_name, kobject_name(kobj));
370 return class_name;
371}
372
373static int deprecated_class_uevent(char **envp, int num_envp, int *cur_index,
374 char *buffer, int buffer_size,
375 int *cur_len,
376 struct class_device *class_dev)
377{
378 struct device *dev = class_dev->dev;
379 char *path;
380
381 if (!dev)
382 return 0;
383
384 /* add device, backing this class device (deprecated) */
385 path = kobject_get_path(&dev->kobj, GFP_KERNEL);
386
387 add_uevent_var(envp, num_envp, cur_index, buffer, buffer_size,
388 cur_len, "PHYSDEVPATH=%s", path);
389 kfree(path);
390
391 if (dev->bus)
392 add_uevent_var(envp, num_envp, cur_index,
393 buffer, buffer_size, cur_len,
394 "PHYSDEVBUS=%s", dev->bus->name);
395
396 if (dev->driver)
397 add_uevent_var(envp, num_envp, cur_index,
398 buffer, buffer_size, cur_len,
399 "PHYSDEVDRIVER=%s", dev->driver->name);
400 return 0;
401}
402
403static int make_deprecated_class_device_links(struct class_device *class_dev)
404{
405 char *class_name;
406 int error;
407
408 if (!class_dev->dev)
409 return 0;
410
411 class_name = make_class_name(class_dev->class->name, &class_dev->kobj);
412 error = sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj,
413 class_name);
414 kfree(class_name);
415 return error;
416}
417
418static void remove_deprecated_class_device_links(struct class_device *class_dev)
419{
420 char *class_name;
421
422 if (!class_dev->dev)
423 return;
424
425 class_name = make_class_name(class_dev->class->name, &class_dev->kobj);
426 sysfs_remove_link(&class_dev->dev->kobj, class_name);
427 kfree(class_name);
428}
429#else
430static inline int deprecated_class_uevent(char **envp, int num_envp,
431 int *cur_index, char *buffer,
432 int buffer_size, int *cur_len,
433 struct class_device *class_dev)
434{ return 0; }
435static inline int make_deprecated_class_device_links(struct class_device *cd)
436{ return 0; }
437static void remove_deprecated_class_device_links(struct class_device *cd)
438{ }
439#endif
440
355static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp, 441static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
356 int num_envp, char *buffer, int buffer_size) 442 int num_envp, char *buffer, int buffer_size)
357{ 443{
@@ -362,25 +448,8 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
362 448
363 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); 449 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
364 450
365 if (class_dev->dev) { 451 deprecated_class_uevent(envp, num_envp, &i, buffer, buffer_size,
366 /* add device, backing this class device (deprecated) */ 452 &length, class_dev);
367 struct device *dev = class_dev->dev;
368 char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
369
370 add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
371 &length, "PHYSDEVPATH=%s", path);
372 kfree(path);
373
374 if (dev->bus)
375 add_uevent_var(envp, num_envp, &i,
376 buffer, buffer_size, &length,
377 "PHYSDEVBUS=%s", dev->bus->name);
378
379 if (dev->driver)
380 add_uevent_var(envp, num_envp, &i,
381 buffer, buffer_size, &length,
382 "PHYSDEVDRIVER=%s", dev->driver->name);
383 }
384 453
385 if (MAJOR(class_dev->devt)) { 454 if (MAJOR(class_dev->devt)) {
386 add_uevent_var(envp, num_envp, &i, 455 add_uevent_var(envp, num_envp, &i,
@@ -506,29 +575,11 @@ void class_device_initialize(struct class_device *class_dev)
506 INIT_LIST_HEAD(&class_dev->node); 575 INIT_LIST_HEAD(&class_dev->node);
507} 576}
508 577
509char *make_class_name(const char *name, struct kobject *kobj)
510{
511 char *class_name;
512 int size;
513
514 size = strlen(name) + strlen(kobject_name(kobj)) + 2;
515
516 class_name = kmalloc(size, GFP_KERNEL);
517 if (!class_name)
518 return ERR_PTR(-ENOMEM);
519
520 strcpy(class_name, name);
521 strcat(class_name, ":");
522 strcat(class_name, kobject_name(kobj));
523 return class_name;
524}
525
526int class_device_add(struct class_device *class_dev) 578int class_device_add(struct class_device *class_dev)
527{ 579{
528 struct class *parent_class = NULL; 580 struct class *parent_class = NULL;
529 struct class_device *parent_class_dev = NULL; 581 struct class_device *parent_class_dev = NULL;
530 struct class_interface *class_intf; 582 struct class_interface *class_intf;
531 char *class_name = NULL;
532 int error = -EINVAL; 583 int error = -EINVAL;
533 584
534 class_dev = class_device_get(class_dev); 585 class_dev = class_device_get(class_dev);
@@ -599,20 +650,18 @@ int class_device_add(struct class_device *class_dev)
599 goto out5; 650 goto out5;
600 651
601 if (class_dev->dev) { 652 if (class_dev->dev) {
602 class_name = make_class_name(class_dev->class->name,
603 &class_dev->kobj);
604 error = sysfs_create_link(&class_dev->kobj, 653 error = sysfs_create_link(&class_dev->kobj,
605 &class_dev->dev->kobj, "device"); 654 &class_dev->dev->kobj, "device");
606 if (error) 655 if (error)
607 goto out6; 656 goto out6;
608 error = sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj,
609 class_name);
610 if (error)
611 goto out7;
612 } 657 }
613 658
614 error = class_device_add_groups(class_dev); 659 error = class_device_add_groups(class_dev);
615 if (error) 660 if (error)
661 goto out7;
662
663 error = make_deprecated_class_device_links(class_dev);
664 if (error)
616 goto out8; 665 goto out8;
617 666
618 kobject_uevent(&class_dev->kobj, KOBJ_ADD); 667 kobject_uevent(&class_dev->kobj, KOBJ_ADD);
@@ -629,8 +678,7 @@ int class_device_add(struct class_device *class_dev)
629 goto out1; 678 goto out1;
630 679
631 out8: 680 out8:
632 if (class_dev->dev) 681 class_device_remove_groups(class_dev);
633 sysfs_remove_link(&class_dev->kobj, class_name);
634 out7: 682 out7:
635 if (class_dev->dev) 683 if (class_dev->dev)
636 sysfs_remove_link(&class_dev->kobj, "device"); 684 sysfs_remove_link(&class_dev->kobj, "device");
@@ -649,7 +697,6 @@ int class_device_add(struct class_device *class_dev)
649 class_put(parent_class); 697 class_put(parent_class);
650 out1: 698 out1:
651 class_device_put(class_dev); 699 class_device_put(class_dev);
652 kfree(class_name);
653 return error; 700 return error;
654} 701}
655 702
@@ -726,7 +773,6 @@ void class_device_del(struct class_device *class_dev)
726 struct class *parent_class = class_dev->class; 773 struct class *parent_class = class_dev->class;
727 struct class_device *parent_device = class_dev->parent; 774 struct class_device *parent_device = class_dev->parent;
728 struct class_interface *class_intf; 775 struct class_interface *class_intf;
729 char *class_name = NULL;
730 776
731 if (parent_class) { 777 if (parent_class) {
732 down(&parent_class->sem); 778 down(&parent_class->sem);
@@ -738,10 +784,8 @@ void class_device_del(struct class_device *class_dev)
738 } 784 }
739 785
740 if (class_dev->dev) { 786 if (class_dev->dev) {
741 class_name = make_class_name(class_dev->class->name, 787 remove_deprecated_class_device_links(class_dev);
742 &class_dev->kobj);
743 sysfs_remove_link(&class_dev->kobj, "device"); 788 sysfs_remove_link(&class_dev->kobj, "device");
744 sysfs_remove_link(&class_dev->dev->kobj, class_name);
745 } 789 }
746 sysfs_remove_link(&class_dev->kobj, "subsystem"); 790 sysfs_remove_link(&class_dev->kobj, "subsystem");
747 class_device_remove_file(class_dev, &class_dev->uevent_attr); 791 class_device_remove_file(class_dev, &class_dev->uevent_attr);
@@ -755,7 +799,6 @@ void class_device_del(struct class_device *class_dev)
755 799
756 class_device_put(parent_device); 800 class_device_put(parent_device);
757 class_put(parent_class); 801 class_put(parent_class);
758 kfree(class_name);
759} 802}
760 803
761void class_device_unregister(struct class_device *class_dev) 804void class_device_unregister(struct class_device *class_dev)
@@ -804,14 +847,17 @@ int class_device_rename(struct class_device *class_dev, char *new_name)
804 pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id, 847 pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id,
805 new_name); 848 new_name);
806 849
850#ifdef CONFIG_SYSFS_DEPRECATED
807 if (class_dev->dev) 851 if (class_dev->dev)
808 old_class_name = make_class_name(class_dev->class->name, 852 old_class_name = make_class_name(class_dev->class->name,
809 &class_dev->kobj); 853 &class_dev->kobj);
854#endif
810 855
811 strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN); 856 strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN);
812 857
813 error = kobject_rename(&class_dev->kobj, new_name); 858 error = kobject_rename(&class_dev->kobj, new_name);
814 859
860#ifdef CONFIG_SYSFS_DEPRECATED
815 if (class_dev->dev) { 861 if (class_dev->dev) {
816 new_class_name = make_class_name(class_dev->class->name, 862 new_class_name = make_class_name(class_dev->class->name,
817 &class_dev->kobj); 863 &class_dev->kobj);
@@ -819,6 +865,7 @@ int class_device_rename(struct class_device *class_dev, char *new_name)
819 new_class_name); 865 new_class_name);
820 sysfs_remove_link(&class_dev->dev->kobj, old_class_name); 866 sysfs_remove_link(&class_dev->dev->kobj, old_class_name);
821 } 867 }
868#endif
822 class_device_put(class_dev); 869 class_device_put(class_dev);
823 870
824 kfree(old_class_name); 871 kfree(old_class_name);
@@ -893,23 +940,6 @@ void class_interface_unregister(struct class_interface *class_intf)
893 class_put(parent); 940 class_put(parent);
894} 941}
895 942
896int virtual_device_parent(struct device *dev)
897{
898 if (!dev->class)
899 return -ENODEV;
900
901 if (!dev->class->virtual_dir) {
902 static struct kobject *virtual_dir = NULL;
903
904 if (!virtual_dir)
905 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual");
906 dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name);
907 }
908
909 dev->kobj.parent = dev->class->virtual_dir;
910 return 0;
911}
912
913int __init classes_init(void) 943int __init classes_init(void)
914{ 944{
915 int retval; 945 int retval;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 68ad11af22b4..e4b530ef757d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -17,6 +17,7 @@
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/kdev_t.h> 19#include <linux/kdev_t.h>
20#include <linux/notifier.h>
20 21
21#include <asm/semaphore.h> 22#include <asm/semaphore.h>
22 23
@@ -153,20 +154,24 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
153 "MINOR=%u", MINOR(dev->devt)); 154 "MINOR=%u", MINOR(dev->devt));
154 } 155 }
155 156
157#ifdef CONFIG_SYSFS_DEPRECATED
156 /* add bus name (same as SUBSYSTEM, deprecated) */ 158 /* add bus name (same as SUBSYSTEM, deprecated) */
157 if (dev->bus) 159 if (dev->bus)
158 add_uevent_var(envp, num_envp, &i, 160 add_uevent_var(envp, num_envp, &i,
159 buffer, buffer_size, &length, 161 buffer, buffer_size, &length,
160 "PHYSDEVBUS=%s", dev->bus->name); 162 "PHYSDEVBUS=%s", dev->bus->name);
163#endif
161 164
162 /* add driver name (PHYSDEV* values are deprecated)*/ 165 /* add driver name (PHYSDEV* values are deprecated)*/
163 if (dev->driver) { 166 if (dev->driver) {
164 add_uevent_var(envp, num_envp, &i, 167 add_uevent_var(envp, num_envp, &i,
165 buffer, buffer_size, &length, 168 buffer, buffer_size, &length,
166 "DRIVER=%s", dev->driver->name); 169 "DRIVER=%s", dev->driver->name);
170#ifdef CONFIG_SYSFS_DEPRECATED
167 add_uevent_var(envp, num_envp, &i, 171 add_uevent_var(envp, num_envp, &i,
168 buffer, buffer_size, &length, 172 buffer, buffer_size, &length,
169 "PHYSDEVDRIVER=%s", dev->driver->name); 173 "PHYSDEVDRIVER=%s", dev->driver->name);
174#endif
170 } 175 }
171 176
172 /* terminate, set to next free slot, shrink available space */ 177 /* terminate, set to next free slot, shrink available space */
@@ -383,6 +388,52 @@ void device_initialize(struct device *dev)
383 device_init_wakeup(dev, 0); 388 device_init_wakeup(dev, 0);
384} 389}
385 390
391#ifdef CONFIG_SYSFS_DEPRECATED
392static int setup_parent(struct device *dev, struct device *parent)
393{
394 /* Set the parent to the class, not the parent device */
395 /* this keeps sysfs from having a symlink to make old udevs happy */
396 if (dev->class)
397 dev->kobj.parent = &dev->class->subsys.kset.kobj;
398 else if (parent)
399 dev->kobj.parent = &parent->kobj;
400
401 return 0;
402}
403#else
404static int virtual_device_parent(struct device *dev)
405{
406 if (!dev->class)
407 return -ENODEV;
408
409 if (!dev->class->virtual_dir) {
410 static struct kobject *virtual_dir = NULL;
411
412 if (!virtual_dir)
413 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual");
414 dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name);
415 }
416
417 dev->kobj.parent = dev->class->virtual_dir;
418 return 0;
419}
420
421static int setup_parent(struct device *dev, struct device *parent)
422{
423 int error;
424
425 /* if this is a class device, and has no parent, create one */
426 if ((dev->class) && (parent == NULL)) {
427 error = virtual_device_parent(dev);
428 if (error)
429 return error;
430 } else if (parent)
431 dev->kobj.parent = &parent->kobj;
432
433 return 0;
434}
435#endif
436
386/** 437/**
387 * device_add - add device to device hierarchy. 438 * device_add - add device to device hierarchy.
388 * @dev: device. 439 * @dev: device.
@@ -405,29 +456,29 @@ int device_add(struct device *dev)
405 if (!dev || !strlen(dev->bus_id)) 456 if (!dev || !strlen(dev->bus_id))
406 goto Error; 457 goto Error;
407 458
408 /* if this is a class device, and has no parent, create one */ 459 pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id);
409 if ((dev->class) && (dev->parent == NULL)) {
410 error = virtual_device_parent(dev);
411 if (error)
412 goto Error;
413 }
414 460
415 parent = get_device(dev->parent); 461 parent = get_device(dev->parent);
416 462
417 pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id); 463 error = setup_parent(dev, parent);
464 if (error)
465 goto Error;
418 466
419 /* first, register with generic layer. */ 467 /* first, register with generic layer. */
420 kobject_set_name(&dev->kobj, "%s", dev->bus_id); 468 kobject_set_name(&dev->kobj, "%s", dev->bus_id);
421 if (parent) 469 error = kobject_add(&dev->kobj);
422 dev->kobj.parent = &parent->kobj; 470 if (error)
423
424 if ((error = kobject_add(&dev->kobj)))
425 goto Error; 471 goto Error;
426 472
427 /* notify platform of device entry */ 473 /* notify platform of device entry */
428 if (platform_notify) 474 if (platform_notify)
429 platform_notify(dev); 475 platform_notify(dev);
430 476
477 /* notify clients of device entry (new way) */
478 if (dev->bus)
479 blocking_notifier_call_chain(&dev->bus->bus_notifier,
480 BUS_NOTIFY_ADD_DEVICE, dev);
481
431 dev->uevent_attr.attr.name = "uevent"; 482 dev->uevent_attr.attr.name = "uevent";
432 dev->uevent_attr.attr.mode = S_IWUSR; 483 dev->uevent_attr.attr.mode = S_IWUSR;
433 if (dev->driver) 484 if (dev->driver)
@@ -461,13 +512,18 @@ int device_add(struct device *dev)
461 if (dev->class) { 512 if (dev->class) {
462 sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj, 513 sysfs_create_link(&dev->kobj, &dev->class->subsys.kset.kobj,
463 "subsystem"); 514 "subsystem");
464 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, 515 /* If this is not a "fake" compatible device, then create the
465 dev->bus_id); 516 * symlink from the class to the device. */
517 if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
518 sysfs_create_link(&dev->class->subsys.kset.kobj,
519 &dev->kobj, dev->bus_id);
520#ifdef CONFIG_SYSFS_DEPRECATED
466 if (parent) { 521 if (parent) {
467 sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); 522 sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device");
468 class_name = make_class_name(dev->class->name, &dev->kobj); 523 class_name = make_class_name(dev->class->name, &dev->kobj);
469 sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); 524 sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name);
470 } 525 }
526#endif
471 } 527 }
472 528
473 if ((error = device_add_attrs(dev))) 529 if ((error = device_add_attrs(dev)))
@@ -504,6 +560,9 @@ int device_add(struct device *dev)
504 BusError: 560 BusError:
505 device_pm_remove(dev); 561 device_pm_remove(dev);
506 PMError: 562 PMError:
563 if (dev->bus)
564 blocking_notifier_call_chain(&dev->bus->bus_notifier,
565 BUS_NOTIFY_DEL_DEVICE, dev);
507 device_remove_groups(dev); 566 device_remove_groups(dev);
508 GroupError: 567 GroupError:
509 device_remove_attrs(dev); 568 device_remove_attrs(dev);
@@ -586,22 +645,31 @@ void put_device(struct device * dev)
586void device_del(struct device * dev) 645void device_del(struct device * dev)
587{ 646{
588 struct device * parent = dev->parent; 647 struct device * parent = dev->parent;
589 char *class_name = NULL;
590 struct class_interface *class_intf; 648 struct class_interface *class_intf;
591 649
592 if (parent) 650 if (parent)
593 klist_del(&dev->knode_parent); 651 klist_del(&dev->knode_parent);
594 if (dev->devt_attr) 652 if (dev->devt_attr) {
595 device_remove_file(dev, dev->devt_attr); 653 device_remove_file(dev, dev->devt_attr);
654 kfree(dev->devt_attr);
655 }
596 if (dev->class) { 656 if (dev->class) {
597 sysfs_remove_link(&dev->kobj, "subsystem"); 657 sysfs_remove_link(&dev->kobj, "subsystem");
598 sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); 658 /* If this is not a "fake" compatible device, remove the
599 class_name = make_class_name(dev->class->name, &dev->kobj); 659 * symlink from the class to the device. */
660 if (dev->kobj.parent != &dev->class->subsys.kset.kobj)
661 sysfs_remove_link(&dev->class->subsys.kset.kobj,
662 dev->bus_id);
663#ifdef CONFIG_SYSFS_DEPRECATED
600 if (parent) { 664 if (parent) {
601 sysfs_remove_link(&dev->kobj, "device"); 665 char *class_name = make_class_name(dev->class->name,
666 &dev->kobj);
602 sysfs_remove_link(&dev->parent->kobj, class_name); 667 sysfs_remove_link(&dev->parent->kobj, class_name);
668 kfree(class_name);
669 sysfs_remove_link(&dev->kobj, "device");
603 } 670 }
604 kfree(class_name); 671#endif
672
605 down(&dev->class->sem); 673 down(&dev->class->sem);
606 /* notify any interfaces that the device is now gone */ 674 /* notify any interfaces that the device is now gone */
607 list_for_each_entry(class_intf, &dev->class->interfaces, node) 675 list_for_each_entry(class_intf, &dev->class->interfaces, node)
@@ -614,13 +682,16 @@ void device_del(struct device * dev)
614 device_remove_file(dev, &dev->uevent_attr); 682 device_remove_file(dev, &dev->uevent_attr);
615 device_remove_groups(dev); 683 device_remove_groups(dev);
616 device_remove_attrs(dev); 684 device_remove_attrs(dev);
685 bus_remove_device(dev);
617 686
618 /* Notify the platform of the removal, in case they 687 /* Notify the platform of the removal, in case they
619 * need to do anything... 688 * need to do anything...
620 */ 689 */
621 if (platform_notify_remove) 690 if (platform_notify_remove)
622 platform_notify_remove(dev); 691 platform_notify_remove(dev);
623 bus_remove_device(dev); 692 if (dev->bus)
693 blocking_notifier_call_chain(&dev->bus->bus_notifier,
694 BUS_NOTIFY_DEL_DEVICE, dev);
624 device_pm_remove(dev); 695 device_pm_remove(dev);
625 kobject_uevent(&dev->kobj, KOBJ_REMOVE); 696 kobject_uevent(&dev->kobj, KOBJ_REMOVE);
626 kobject_del(&dev->kobj); 697 kobject_del(&dev->kobj);
@@ -679,12 +750,45 @@ int device_for_each_child(struct device * parent, void * data,
679 return error; 750 return error;
680} 751}
681 752
753/**
754 * device_find_child - device iterator for locating a particular device.
755 * @parent: parent struct device
756 * @data: Data to pass to match function
757 * @match: Callback function to check device
758 *
759 * This is similar to the device_for_each_child() function above, but it
760 * returns a reference to a device that is 'found' for later use, as
761 * determined by the @match callback.
762 *
763 * The callback should return 0 if the device doesn't match and non-zero
764 * if it does. If the callback returns non-zero and a reference to the
765 * current device can be obtained, this function will return to the caller
766 * and not iterate over any more devices.
767 */
768struct device * device_find_child(struct device *parent, void *data,
769 int (*match)(struct device *, void *))
770{
771 struct klist_iter i;
772 struct device *child;
773
774 if (!parent)
775 return NULL;
776
777 klist_iter_init(&parent->klist_children, &i);
778 while ((child = next_device(&i)))
779 if (match(child, data) && get_device(child))
780 break;
781 klist_iter_exit(&i);
782 return child;
783}
784
682int __init devices_init(void) 785int __init devices_init(void)
683{ 786{
684 return subsystem_register(&devices_subsys); 787 return subsystem_register(&devices_subsys);
685} 788}
686 789
687EXPORT_SYMBOL_GPL(device_for_each_child); 790EXPORT_SYMBOL_GPL(device_for_each_child);
791EXPORT_SYMBOL_GPL(device_find_child);
688 792
689EXPORT_SYMBOL_GPL(device_initialize); 793EXPORT_SYMBOL_GPL(device_initialize);
690EXPORT_SYMBOL_GPL(device_add); 794EXPORT_SYMBOL_GPL(device_add);
@@ -807,8 +911,10 @@ int device_rename(struct device *dev, char *new_name)
807 911
808 pr_debug("DEVICE: renaming '%s' to '%s'\n", dev->bus_id, new_name); 912 pr_debug("DEVICE: renaming '%s' to '%s'\n", dev->bus_id, new_name);
809 913
914#ifdef CONFIG_SYSFS_DEPRECATED
810 if ((dev->class) && (dev->parent)) 915 if ((dev->class) && (dev->parent))
811 old_class_name = make_class_name(dev->class->name, &dev->kobj); 916 old_class_name = make_class_name(dev->class->name, &dev->kobj);
917#endif
812 918
813 if (dev->class) { 919 if (dev->class) {
814 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); 920 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
@@ -823,6 +929,7 @@ int device_rename(struct device *dev, char *new_name)
823 929
824 error = kobject_rename(&dev->kobj, new_name); 930 error = kobject_rename(&dev->kobj, new_name);
825 931
932#ifdef CONFIG_SYSFS_DEPRECATED
826 if (old_class_name) { 933 if (old_class_name) {
827 new_class_name = make_class_name(dev->class->name, &dev->kobj); 934 new_class_name = make_class_name(dev->class->name, &dev->kobj);
828 if (new_class_name) { 935 if (new_class_name) {
@@ -831,6 +938,8 @@ int device_rename(struct device *dev, char *new_name)
831 sysfs_remove_link(&dev->parent->kobj, old_class_name); 938 sysfs_remove_link(&dev->parent->kobj, old_class_name);
832 } 939 }
833 } 940 }
941#endif
942
834 if (dev->class) { 943 if (dev->class) {
835 sysfs_remove_link(&dev->class->subsys.kset.kobj, 944 sysfs_remove_link(&dev->class->subsys.kset.kobj,
836 old_symlink_name); 945 old_symlink_name);
@@ -846,3 +955,95 @@ int device_rename(struct device *dev, char *new_name)
846 955
847 return error; 956 return error;
848} 957}
958
959
960static int device_move_class_links(struct device *dev,
961 struct device *old_parent,
962 struct device *new_parent)
963{
964#ifdef CONFIG_SYSFS_DEPRECATED
965 int error;
966 char *class_name;
967
968 class_name = make_class_name(dev->class->name, &dev->kobj);
969 if (!class_name) {
970 error = PTR_ERR(class_name);
971 class_name = NULL;
972 goto out;
973 }
974 if (old_parent) {
975 sysfs_remove_link(&dev->kobj, "device");
976 sysfs_remove_link(&old_parent->kobj, class_name);
977 }
978 error = sysfs_create_link(&dev->kobj, &new_parent->kobj, "device");
979 if (error)
980 goto out;
981 error = sysfs_create_link(&new_parent->kobj, &dev->kobj, class_name);
982 if (error)
983 sysfs_remove_link(&dev->kobj, "device");
984out:
985 kfree(class_name);
986 return error;
987#else
988 return 0;
989#endif
990}
991
992/**
993 * device_move - moves a device to a new parent
994 * @dev: the pointer to the struct device to be moved
995 * @new_parent: the new parent of the device
996 */
997int device_move(struct device *dev, struct device *new_parent)
998{
999 int error;
1000 struct device *old_parent;
1001
1002 dev = get_device(dev);
1003 if (!dev)
1004 return -EINVAL;
1005
1006 if (!device_is_registered(dev)) {
1007 error = -EINVAL;
1008 goto out;
1009 }
1010 new_parent = get_device(new_parent);
1011 if (!new_parent) {
1012 error = -EINVAL;
1013 goto out;
1014 }
1015 pr_debug("DEVICE: moving '%s' to '%s'\n", dev->bus_id,
1016 new_parent->bus_id);
1017 error = kobject_move(&dev->kobj, &new_parent->kobj);
1018 if (error) {
1019 put_device(new_parent);
1020 goto out;
1021 }
1022 old_parent = dev->parent;
1023 dev->parent = new_parent;
1024 if (old_parent)
1025 klist_remove(&dev->knode_parent);
1026 klist_add_tail(&dev->knode_parent, &new_parent->klist_children);
1027 if (!dev->class)
1028 goto out_put;
1029 error = device_move_class_links(dev, old_parent, new_parent);
1030 if (error) {
1031 /* We ignore errors on cleanup since we're hosed anyway... */
1032 device_move_class_links(dev, new_parent, old_parent);
1033 if (!kobject_move(&dev->kobj, &old_parent->kobj)) {
1034 klist_remove(&dev->knode_parent);
1035 if (old_parent)
1036 klist_add_tail(&dev->knode_parent,
1037 &old_parent->klist_children);
1038 }
1039 put_device(new_parent);
1040 goto out;
1041 }
1042out_put:
1043 put_device(old_parent);
1044out:
1045 put_device(dev);
1046 return error;
1047}
1048
1049EXPORT_SYMBOL_GPL(device_move);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index c5d6bb4290ad..510e7884975f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -26,33 +26,28 @@
26#define to_drv(node) container_of(node, struct device_driver, kobj.entry) 26#define to_drv(node) container_of(node, struct device_driver, kobj.entry)
27 27
28 28
29/** 29static void driver_bound(struct device *dev)
30 * device_bind_driver - bind a driver to one device.
31 * @dev: device.
32 *
33 * Allow manual attachment of a driver to a device.
34 * Caller must have already set @dev->driver.
35 *
36 * Note that this does not modify the bus reference count
37 * nor take the bus's rwsem. Please verify those are accounted
38 * for before calling this. (It is ok to call with no other effort
39 * from a driver's probe() method.)
40 *
41 * This function must be called with @dev->sem held.
42 */
43int device_bind_driver(struct device *dev)
44{ 30{
45 int ret;
46
47 if (klist_node_attached(&dev->knode_driver)) { 31 if (klist_node_attached(&dev->knode_driver)) {
48 printk(KERN_WARNING "%s: device %s already bound\n", 32 printk(KERN_WARNING "%s: device %s already bound\n",
49 __FUNCTION__, kobject_name(&dev->kobj)); 33 __FUNCTION__, kobject_name(&dev->kobj));
50 return 0; 34 return;
51 } 35 }
52 36
53 pr_debug("bound device '%s' to driver '%s'\n", 37 pr_debug("bound device '%s' to driver '%s'\n",
54 dev->bus_id, dev->driver->name); 38 dev->bus_id, dev->driver->name);
39
40 if (dev->bus)
41 blocking_notifier_call_chain(&dev->bus->bus_notifier,
42 BUS_NOTIFY_BOUND_DRIVER, dev);
43
55 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); 44 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
45}
46
47static int driver_sysfs_add(struct device *dev)
48{
49 int ret;
50
56 ret = sysfs_create_link(&dev->driver->kobj, &dev->kobj, 51 ret = sysfs_create_link(&dev->driver->kobj, &dev->kobj,
57 kobject_name(&dev->kobj)); 52 kobject_name(&dev->kobj));
58 if (ret == 0) { 53 if (ret == 0) {
@@ -65,6 +60,36 @@ int device_bind_driver(struct device *dev)
65 return ret; 60 return ret;
66} 61}
67 62
63static void driver_sysfs_remove(struct device *dev)
64{
65 struct device_driver *drv = dev->driver;
66
67 if (drv) {
68 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj));
69 sysfs_remove_link(&dev->kobj, "driver");
70 }
71}
72
73/**
74 * device_bind_driver - bind a driver to one device.
75 * @dev: device.
76 *
77 * Allow manual attachment of a driver to a device.
78 * Caller must have already set @dev->driver.
79 *
80 * Note that this does not modify the bus reference count
81 * nor take the bus's rwsem. Please verify those are accounted
82 * for before calling this. (It is ok to call with no other effort
83 * from a driver's probe() method.)
84 *
85 * This function must be called with @dev->sem held.
86 */
87int device_bind_driver(struct device *dev)
88{
89 driver_bound(dev);
90 return driver_sysfs_add(dev);
91}
92
68struct stupid_thread_structure { 93struct stupid_thread_structure {
69 struct device_driver *drv; 94 struct device_driver *drv;
70 struct device *dev; 95 struct device *dev;
@@ -85,30 +110,32 @@ static int really_probe(void *void_data)
85 drv->bus->name, drv->name, dev->bus_id); 110 drv->bus->name, drv->name, dev->bus_id);
86 111
87 dev->driver = drv; 112 dev->driver = drv;
113 if (driver_sysfs_add(dev)) {
114 printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
115 __FUNCTION__, dev->bus_id);
116 goto probe_failed;
117 }
118
88 if (dev->bus->probe) { 119 if (dev->bus->probe) {
89 ret = dev->bus->probe(dev); 120 ret = dev->bus->probe(dev);
90 if (ret) { 121 if (ret)
91 dev->driver = NULL;
92 goto probe_failed; 122 goto probe_failed;
93 }
94 } else if (drv->probe) { 123 } else if (drv->probe) {
95 ret = drv->probe(dev); 124 ret = drv->probe(dev);
96 if (ret) { 125 if (ret)
97 dev->driver = NULL;
98 goto probe_failed; 126 goto probe_failed;
99 }
100 }
101 if (device_bind_driver(dev)) {
102 printk(KERN_ERR "%s: device_bind_driver(%s) failed\n",
103 __FUNCTION__, dev->bus_id);
104 /* How does undo a ->probe? We're screwed. */
105 } 127 }
128
129 driver_bound(dev);
106 ret = 1; 130 ret = 1;
107 pr_debug("%s: Bound Device %s to Driver %s\n", 131 pr_debug("%s: Bound Device %s to Driver %s\n",
108 drv->bus->name, dev->bus_id, drv->name); 132 drv->bus->name, dev->bus_id, drv->name);
109 goto done; 133 goto done;
110 134
111probe_failed: 135probe_failed:
136 driver_sysfs_remove(dev);
137 dev->driver = NULL;
138
112 if (ret == -ENODEV || ret == -ENXIO) { 139 if (ret == -ENODEV || ret == -ENXIO) {
113 /* Driver matched, but didn't support device 140 /* Driver matched, but didn't support device
114 * or device not found. 141 * or device not found.
@@ -284,10 +311,15 @@ static void __device_release_driver(struct device * dev)
284 drv = dev->driver; 311 drv = dev->driver;
285 if (drv) { 312 if (drv) {
286 get_driver(drv); 313 get_driver(drv);
287 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); 314 driver_sysfs_remove(dev);
288 sysfs_remove_link(&dev->kobj, "driver"); 315 sysfs_remove_link(&dev->kobj, "driver");
289 klist_remove(&dev->knode_driver); 316 klist_remove(&dev->knode_driver);
290 317
318 if (dev->bus)
319 blocking_notifier_call_chain(&dev->bus->bus_notifier,
320 BUS_NOTIFY_UNBIND_DRIVER,
321 dev);
322
291 if (dev->bus && dev->bus->remove) 323 if (dev->bus && dev->bus->remove)
292 dev->bus->remove(dev); 324 dev->bus->remove(dev);
293 else if (drv->remove) 325 else if (drv->remove)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 14615694ae9a..4bad2870c485 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -21,6 +21,8 @@
21#include <linux/firmware.h> 21#include <linux/firmware.h>
22#include "base.h" 22#include "base.h"
23 23
24#define to_dev(obj) container_of(obj, struct device, kobj)
25
24MODULE_AUTHOR("Manuel Estrada Sainz <ranty@debian.org>"); 26MODULE_AUTHOR("Manuel Estrada Sainz <ranty@debian.org>");
25MODULE_DESCRIPTION("Multi purpose firmware loading support"); 27MODULE_DESCRIPTION("Multi purpose firmware loading support");
26MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
@@ -86,12 +88,12 @@ firmware_timeout_store(struct class *class, const char *buf, size_t count)
86 88
87static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); 89static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store);
88 90
89static void fw_class_dev_release(struct class_device *class_dev); 91static void fw_dev_release(struct device *dev);
90 92
91static int firmware_class_uevent(struct class_device *class_dev, char **envp, 93static int firmware_uevent(struct device *dev, char **envp, int num_envp,
92 int num_envp, char *buffer, int buffer_size) 94 char *buffer, int buffer_size)
93{ 95{
94 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 96 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
95 int i = 0, len = 0; 97 int i = 0, len = 0;
96 98
97 if (!test_bit(FW_STATUS_READY, &fw_priv->status)) 99 if (!test_bit(FW_STATUS_READY, &fw_priv->status))
@@ -110,21 +112,21 @@ static int firmware_class_uevent(struct class_device *class_dev, char **envp,
110 112
111static struct class firmware_class = { 113static struct class firmware_class = {
112 .name = "firmware", 114 .name = "firmware",
113 .uevent = firmware_class_uevent, 115 .dev_uevent = firmware_uevent,
114 .release = fw_class_dev_release, 116 .dev_release = fw_dev_release,
115}; 117};
116 118
117static ssize_t 119static ssize_t firmware_loading_show(struct device *dev,
118firmware_loading_show(struct class_device *class_dev, char *buf) 120 struct device_attribute *attr, char *buf)
119{ 121{
120 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 122 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
121 int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status); 123 int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status);
122 return sprintf(buf, "%d\n", loading); 124 return sprintf(buf, "%d\n", loading);
123} 125}
124 126
125/** 127/**
126 * firmware_loading_store - set value in the 'loading' control file 128 * firmware_loading_store - set value in the 'loading' control file
127 * @class_dev: class_device pointer 129 * @dev: device pointer
128 * @buf: buffer to scan for loading control value 130 * @buf: buffer to scan for loading control value
129 * @count: number of bytes in @buf 131 * @count: number of bytes in @buf
130 * 132 *
@@ -134,11 +136,11 @@ firmware_loading_show(struct class_device *class_dev, char *buf)
134 * 0: Conclude the load and hand the data to the driver code. 136 * 0: Conclude the load and hand the data to the driver code.
135 * -1: Conclude the load with an error and discard any written data. 137 * -1: Conclude the load with an error and discard any written data.
136 **/ 138 **/
137static ssize_t 139static ssize_t firmware_loading_store(struct device *dev,
138firmware_loading_store(struct class_device *class_dev, 140 struct device_attribute *attr,
139 const char *buf, size_t count) 141 const char *buf, size_t count)
140{ 142{
141 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 143 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
142 int loading = simple_strtol(buf, NULL, 10); 144 int loading = simple_strtol(buf, NULL, 10);
143 145
144 switch (loading) { 146 switch (loading) {
@@ -174,15 +176,14 @@ firmware_loading_store(struct class_device *class_dev,
174 return count; 176 return count;
175} 177}
176 178
177static CLASS_DEVICE_ATTR(loading, 0644, 179static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store);
178 firmware_loading_show, firmware_loading_store);
179 180
180static ssize_t 181static ssize_t
181firmware_data_read(struct kobject *kobj, 182firmware_data_read(struct kobject *kobj,
182 char *buffer, loff_t offset, size_t count) 183 char *buffer, loff_t offset, size_t count)
183{ 184{
184 struct class_device *class_dev = to_class_dev(kobj); 185 struct device *dev = to_dev(kobj);
185 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 186 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
186 struct firmware *fw; 187 struct firmware *fw;
187 ssize_t ret_count = count; 188 ssize_t ret_count = count;
188 189
@@ -234,7 +235,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
234 235
235/** 236/**
236 * firmware_data_write - write method for firmware 237 * firmware_data_write - write method for firmware
237 * @kobj: kobject for the class_device 238 * @kobj: kobject for the device
238 * @buffer: buffer being written 239 * @buffer: buffer being written
239 * @offset: buffer offset for write in total data store area 240 * @offset: buffer offset for write in total data store area
240 * @count: buffer size 241 * @count: buffer size
@@ -246,8 +247,8 @@ static ssize_t
246firmware_data_write(struct kobject *kobj, 247firmware_data_write(struct kobject *kobj,
247 char *buffer, loff_t offset, size_t count) 248 char *buffer, loff_t offset, size_t count)
248{ 249{
249 struct class_device *class_dev = to_class_dev(kobj); 250 struct device *dev = to_dev(kobj);
250 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 251 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
251 struct firmware *fw; 252 struct firmware *fw;
252 ssize_t retval; 253 ssize_t retval;
253 254
@@ -280,13 +281,12 @@ static struct bin_attribute firmware_attr_data_tmpl = {
280 .write = firmware_data_write, 281 .write = firmware_data_write,
281}; 282};
282 283
283static void 284static void fw_dev_release(struct device *dev)
284fw_class_dev_release(struct class_device *class_dev)
285{ 285{
286 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 286 struct firmware_priv *fw_priv = dev_get_drvdata(dev);
287 287
288 kfree(fw_priv); 288 kfree(fw_priv);
289 kfree(class_dev); 289 kfree(dev);
290 290
291 module_put(THIS_MODULE); 291 module_put(THIS_MODULE);
292} 292}
@@ -298,26 +298,23 @@ firmware_class_timeout(u_long data)
298 fw_load_abort(fw_priv); 298 fw_load_abort(fw_priv);
299} 299}
300 300
301static inline void 301static inline void fw_setup_device_id(struct device *f_dev, struct device *dev)
302fw_setup_class_device_id(struct class_device *class_dev, struct device *dev)
303{ 302{
304 /* XXX warning we should watch out for name collisions */ 303 /* XXX warning we should watch out for name collisions */
305 strlcpy(class_dev->class_id, dev->bus_id, BUS_ID_SIZE); 304 strlcpy(f_dev->bus_id, dev->bus_id, BUS_ID_SIZE);
306} 305}
307 306
308static int 307static int fw_register_device(struct device **dev_p, const char *fw_name,
309fw_register_class_device(struct class_device **class_dev_p, 308 struct device *device)
310 const char *fw_name, struct device *device)
311{ 309{
312 int retval; 310 int retval;
313 struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), 311 struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv),
314 GFP_KERNEL); 312 GFP_KERNEL);
315 struct class_device *class_dev = kzalloc(sizeof(*class_dev), 313 struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL);
316 GFP_KERNEL);
317 314
318 *class_dev_p = NULL; 315 *dev_p = NULL;
319 316
320 if (!fw_priv || !class_dev) { 317 if (!fw_priv || !f_dev) {
321 printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__); 318 printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__);
322 retval = -ENOMEM; 319 retval = -ENOMEM;
323 goto error_kfree; 320 goto error_kfree;
@@ -331,55 +328,54 @@ fw_register_class_device(struct class_device **class_dev_p,
331 fw_priv->timeout.data = (u_long) fw_priv; 328 fw_priv->timeout.data = (u_long) fw_priv;
332 init_timer(&fw_priv->timeout); 329 init_timer(&fw_priv->timeout);
333 330
334 fw_setup_class_device_id(class_dev, device); 331 fw_setup_device_id(f_dev, device);
335 class_dev->dev = device; 332 f_dev->parent = device;
336 class_dev->class = &firmware_class; 333 f_dev->class = &firmware_class;
337 class_set_devdata(class_dev, fw_priv); 334 dev_set_drvdata(f_dev, fw_priv);
338 retval = class_device_register(class_dev); 335 retval = device_register(f_dev);
339 if (retval) { 336 if (retval) {
340 printk(KERN_ERR "%s: class_device_register failed\n", 337 printk(KERN_ERR "%s: device_register failed\n",
341 __FUNCTION__); 338 __FUNCTION__);
342 goto error_kfree; 339 goto error_kfree;
343 } 340 }
344 *class_dev_p = class_dev; 341 *dev_p = f_dev;
345 return 0; 342 return 0;
346 343
347error_kfree: 344error_kfree:
348 kfree(fw_priv); 345 kfree(fw_priv);
349 kfree(class_dev); 346 kfree(f_dev);
350 return retval; 347 return retval;
351} 348}
352 349
353static int 350static int fw_setup_device(struct firmware *fw, struct device **dev_p,
354fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, 351 const char *fw_name, struct device *device,
355 const char *fw_name, struct device *device, int uevent) 352 int uevent)
356{ 353{
357 struct class_device *class_dev; 354 struct device *f_dev;
358 struct firmware_priv *fw_priv; 355 struct firmware_priv *fw_priv;
359 int retval; 356 int retval;
360 357
361 *class_dev_p = NULL; 358 *dev_p = NULL;
362 retval = fw_register_class_device(&class_dev, fw_name, device); 359 retval = fw_register_device(&f_dev, fw_name, device);
363 if (retval) 360 if (retval)
364 goto out; 361 goto out;
365 362
366 /* Need to pin this module until class device is destroyed */ 363 /* Need to pin this module until class device is destroyed */
367 __module_get(THIS_MODULE); 364 __module_get(THIS_MODULE);
368 365
369 fw_priv = class_get_devdata(class_dev); 366 fw_priv = dev_get_drvdata(f_dev);
370 367
371 fw_priv->fw = fw; 368 fw_priv->fw = fw;
372 retval = sysfs_create_bin_file(&class_dev->kobj, &fw_priv->attr_data); 369 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data);
373 if (retval) { 370 if (retval) {
374 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", 371 printk(KERN_ERR "%s: sysfs_create_bin_file failed\n",
375 __FUNCTION__); 372 __FUNCTION__);
376 goto error_unreg; 373 goto error_unreg;
377 } 374 }
378 375
379 retval = class_device_create_file(class_dev, 376 retval = device_create_file(f_dev, &dev_attr_loading);
380 &class_device_attr_loading);
381 if (retval) { 377 if (retval) {
382 printk(KERN_ERR "%s: class_device_create_file failed\n", 378 printk(KERN_ERR "%s: device_create_file failed\n",
383 __FUNCTION__); 379 __FUNCTION__);
384 goto error_unreg; 380 goto error_unreg;
385 } 381 }
@@ -388,11 +384,11 @@ fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p,
388 set_bit(FW_STATUS_READY, &fw_priv->status); 384 set_bit(FW_STATUS_READY, &fw_priv->status);
389 else 385 else
390 set_bit(FW_STATUS_READY_NOHOTPLUG, &fw_priv->status); 386 set_bit(FW_STATUS_READY_NOHOTPLUG, &fw_priv->status);
391 *class_dev_p = class_dev; 387 *dev_p = f_dev;
392 goto out; 388 goto out;
393 389
394error_unreg: 390error_unreg:
395 class_device_unregister(class_dev); 391 device_unregister(f_dev);
396out: 392out:
397 return retval; 393 return retval;
398} 394}
@@ -401,7 +397,7 @@ static int
401_request_firmware(const struct firmware **firmware_p, const char *name, 397_request_firmware(const struct firmware **firmware_p, const char *name,
402 struct device *device, int uevent) 398 struct device *device, int uevent)
403{ 399{
404 struct class_device *class_dev; 400 struct device *f_dev;
405 struct firmware_priv *fw_priv; 401 struct firmware_priv *fw_priv;
406 struct firmware *firmware; 402 struct firmware *firmware;
407 int retval; 403 int retval;
@@ -417,12 +413,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
417 goto out; 413 goto out;
418 } 414 }
419 415
420 retval = fw_setup_class_device(firmware, &class_dev, name, device, 416 retval = fw_setup_device(firmware, &f_dev, name, device, uevent);
421 uevent);
422 if (retval) 417 if (retval)
423 goto error_kfree_fw; 418 goto error_kfree_fw;
424 419
425 fw_priv = class_get_devdata(class_dev); 420 fw_priv = dev_get_drvdata(f_dev);
426 421
427 if (uevent) { 422 if (uevent) {
428 if (loading_timeout > 0) { 423 if (loading_timeout > 0) {
@@ -430,7 +425,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
430 add_timer(&fw_priv->timeout); 425 add_timer(&fw_priv->timeout);
431 } 426 }
432 427
433 kobject_uevent(&class_dev->kobj, KOBJ_ADD); 428 kobject_uevent(&f_dev->kobj, KOBJ_ADD);
434 wait_for_completion(&fw_priv->completion); 429 wait_for_completion(&fw_priv->completion);
435 set_bit(FW_STATUS_DONE, &fw_priv->status); 430 set_bit(FW_STATUS_DONE, &fw_priv->status);
436 del_timer_sync(&fw_priv->timeout); 431 del_timer_sync(&fw_priv->timeout);
@@ -445,7 +440,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
445 } 440 }
446 fw_priv->fw = NULL; 441 fw_priv->fw = NULL;
447 mutex_unlock(&fw_lock); 442 mutex_unlock(&fw_lock);
448 class_device_unregister(class_dev); 443 device_unregister(f_dev);
449 goto out; 444 goto out;
450 445
451error_kfree_fw: 446error_kfree_fw:
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 940ce41f1887..d1df4a087924 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -388,6 +388,11 @@ static int platform_drv_probe(struct device *_dev)
388 return drv->probe(dev); 388 return drv->probe(dev);
389} 389}
390 390
391static int platform_drv_probe_fail(struct device *_dev)
392{
393 return -ENXIO;
394}
395
391static int platform_drv_remove(struct device *_dev) 396static int platform_drv_remove(struct device *_dev)
392{ 397{
393 struct platform_driver *drv = to_platform_driver(_dev->driver); 398 struct platform_driver *drv = to_platform_driver(_dev->driver);
@@ -451,6 +456,49 @@ void platform_driver_unregister(struct platform_driver *drv)
451} 456}
452EXPORT_SYMBOL_GPL(platform_driver_unregister); 457EXPORT_SYMBOL_GPL(platform_driver_unregister);
453 458
459/**
460 * platform_driver_probe - register driver for non-hotpluggable device
461 * @drv: platform driver structure
462 * @probe: the driver probe routine, probably from an __init section
463 *
464 * Use this instead of platform_driver_register() when you know the device
465 * is not hotpluggable and has already been registered, and you want to
466 * remove its run-once probe() infrastructure from memory after the driver
467 * has bound to the device.
468 *
469 * One typical use for this would be with drivers for controllers integrated
470 * into system-on-chip processors, where the controller devices have been
471 * configured as part of board setup.
472 *
473 * Returns zero if the driver registered and bound to a device, else returns
474 * a negative error code and with the driver not registered.
475 */
476int platform_driver_probe(struct platform_driver *drv,
477 int (*probe)(struct platform_device *))
478{
479 int retval, code;
480
481 /* temporary section violation during probe() */
482 drv->probe = probe;
483 retval = code = platform_driver_register(drv);
484
485 /* Fixup that section violation, being paranoid about code scanning
486 * the list of drivers in order to probe new devices. Check to see
487 * if the probe was successful, and make sure any forced probes of
488 * new devices fail.
489 */
490 spin_lock(&platform_bus_type.klist_drivers.k_lock);
491 drv->probe = NULL;
492 if (code == 0 && list_empty(&drv->driver.klist_devices.k_list))
493 retval = -ENODEV;
494 drv->driver.probe = platform_drv_probe_fail;
495 spin_unlock(&platform_bus_type.klist_drivers.k_lock);
496
497 if (code != retval)
498 platform_driver_unregister(drv);
499 return retval;
500}
501EXPORT_SYMBOL_GPL(platform_driver_probe);
454 502
455/* modalias support enables more hands-off userspace setup: 503/* modalias support enables more hands-off userspace setup:
456 * (a) environment variable lets new-style hotplug events work once system is 504 * (a) environment variable lets new-style hotplug events work once system is
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 28dccb730af9..3d12b85b0962 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -94,54 +94,63 @@ static struct attribute_group topology_attr_group = {
94 .name = "topology" 94 .name = "topology"
95}; 95};
96 96
97static cpumask_t topology_dev_map = CPU_MASK_NONE;
98
97/* Add/Remove cpu_topology interface for CPU device */ 99/* Add/Remove cpu_topology interface for CPU device */
98static int __cpuinit topology_add_dev(struct sys_device * sys_dev) 100static int __cpuinit topology_add_dev(unsigned int cpu)
99{ 101{
100 return sysfs_create_group(&sys_dev->kobj, &topology_attr_group); 102 int rc;
103 struct sys_device *sys_dev = get_cpu_sysdev(cpu);
104
105 rc = sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
106 if (!rc)
107 cpu_set(cpu, topology_dev_map);
108 return rc;
101} 109}
102 110
103static int __cpuinit topology_remove_dev(struct sys_device * sys_dev) 111#ifdef CONFIG_HOTPLUG_CPU
112static void __cpuinit topology_remove_dev(unsigned int cpu)
104{ 113{
114 struct sys_device *sys_dev = get_cpu_sysdev(cpu);
115
116 if (!cpu_isset(cpu, topology_dev_map))
117 return;
118 cpu_clear(cpu, topology_dev_map);
105 sysfs_remove_group(&sys_dev->kobj, &topology_attr_group); 119 sysfs_remove_group(&sys_dev->kobj, &topology_attr_group);
106 return 0;
107} 120}
108 121
109static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, 122static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
110 unsigned long action, void *hcpu) 123 unsigned long action, void *hcpu)
111{ 124{
112 unsigned int cpu = (unsigned long)hcpu; 125 unsigned int cpu = (unsigned long)hcpu;
113 struct sys_device *sys_dev; 126 int rc = 0;
114 127
115 sys_dev = get_cpu_sysdev(cpu);
116 switch (action) { 128 switch (action) {
117 case CPU_ONLINE: 129 case CPU_UP_PREPARE:
118 topology_add_dev(sys_dev); 130 rc = topology_add_dev(cpu);
119 break; 131 break;
132 case CPU_UP_CANCELED:
120 case CPU_DEAD: 133 case CPU_DEAD:
121 topology_remove_dev(sys_dev); 134 topology_remove_dev(cpu);
122 break; 135 break;
123 } 136 }
124 return NOTIFY_OK; 137 return rc ? NOTIFY_BAD : NOTIFY_OK;
125} 138}
126 139#endif
127static struct notifier_block __cpuinitdata topology_cpu_notifier =
128{
129 .notifier_call = topology_cpu_callback,
130};
131 140
132static int __cpuinit topology_sysfs_init(void) 141static int __cpuinit topology_sysfs_init(void)
133{ 142{
134 int i; 143 int cpu;
144 int rc;
135 145
136 for_each_online_cpu(i) { 146 for_each_online_cpu(cpu) {
137 topology_cpu_callback(&topology_cpu_notifier, CPU_ONLINE, 147 rc = topology_add_dev(cpu);
138 (void *)(long)i); 148 if (rc)
149 return rc;
139 } 150 }
140 151 hotcpu_notifier(topology_cpu_callback, 0);
141 register_hotcpu_notifier(&topology_cpu_notifier);
142 152
143 return 0; 153 return 0;
144} 154}
145 155
146device_initcall(topology_sysfs_init); 156device_initcall(topology_sysfs_init);
147
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 7ea0f48f8fa6..2df5cf4ec743 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2133,16 +2133,14 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
2133 rq->timeout = 60 * HZ; 2133 rq->timeout = 60 * HZ;
2134 bio = rq->bio; 2134 bio = rq->bio;
2135 2135
2136 if (rq->bio)
2137 blk_queue_bounce(q, &rq->bio);
2138
2139 if (blk_execute_rq(q, cdi->disk, rq, 0)) { 2136 if (blk_execute_rq(q, cdi->disk, rq, 0)) {
2140 struct request_sense *s = rq->sense; 2137 struct request_sense *s = rq->sense;
2141 ret = -EIO; 2138 ret = -EIO;
2142 cdi->last_sense = s->sense_key; 2139 cdi->last_sense = s->sense_key;
2143 } 2140 }
2144 2141
2145 if (blk_rq_unmap_user(bio, len)) 2142 rq->bio = bio;
2143 if (blk_rq_unmap_user(rq))
2146 ret = -EFAULT; 2144 ret = -EFAULT;
2147 2145
2148 if (ret) 2146 if (ret)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 2af12fc45115..24f922f12783 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -855,39 +855,6 @@ config TANBAC_TB0219
855 depends TANBAC_TB022X 855 depends TANBAC_TB022X
856 select GPIO_VR41XX 856 select GPIO_VR41XX
857 857
858menu "Ftape, the floppy tape device driver"
859
860config FTAPE
861 tristate "Ftape (QIC-80/Travan) support"
862 depends on BROKEN_ON_SMP && (ALPHA || X86)
863 ---help---
864 If you have a tape drive that is connected to your floppy
865 controller, say Y here.
866
867 Some tape drives (like the Seagate "Tape Store 3200" or the Iomega
868 "Ditto 3200" or the Exabyte "Eagle TR-3") come with a "high speed"
869 controller of their own. These drives (and their companion
870 controllers) are also supported if you say Y here.
871
872 If you have a special controller (such as the CMS FC-10, FC-20,
873 Mountain Mach-II, or any controller that is based on the Intel 82078
874 FDC like the high speed controllers by Seagate and Exabyte and
875 Iomega's "Ditto Dash") you must configure it by selecting the
876 appropriate entries from the "Floppy tape controllers" sub-menu
877 below and possibly modify the default values for the IRQ and DMA
878 channel and the IO base in ftape's configuration menu.
879
880 If you want to use your floppy tape drive on a PCI-bus based system,
881 please read the file <file:drivers/char/ftape/README.PCI>.
882
883 The ftape kernel driver is also available as a runtime loadable
884 module. To compile this driver as a module, choose M here: the
885 module will be called ftape.
886
887source "drivers/char/ftape/Kconfig"
888
889endmenu
890
891source "drivers/char/agp/Kconfig" 858source "drivers/char/agp/Kconfig"
892 859
893source "drivers/char/drm/Kconfig" 860source "drivers/char/drm/Kconfig"
@@ -994,7 +961,7 @@ config HPET
994 help 961 help
995 If you say Y here, you will have a miscdevice named "/dev/hpet/". Each 962 If you say Y here, you will have a miscdevice named "/dev/hpet/". Each
996 open selects one of the timers supported by the HPET. The timers are 963 open selects one of the timers supported by the HPET. The timers are
997 non-periodioc and/or periodic. 964 non-periodic and/or periodic.
998 965
999config HPET_RTC_IRQ 966config HPET_RTC_IRQ
1000 bool "HPET Control RTC IRQ" if !HPET_EMULATE_RTC 967 bool "HPET Control RTC IRQ" if !HPET_EMULATE_RTC
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 777cad045094..b1fcdab90947 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -78,7 +78,6 @@ obj-$(CONFIG_TOSHIBA) += toshiba.o
78obj-$(CONFIG_I8K) += i8k.o 78obj-$(CONFIG_I8K) += i8k.o
79obj-$(CONFIG_DS1620) += ds1620.o 79obj-$(CONFIG_DS1620) += ds1620.o
80obj-$(CONFIG_HW_RANDOM) += hw_random/ 80obj-$(CONFIG_HW_RANDOM) += hw_random/
81obj-$(CONFIG_FTAPE) += ftape/
82obj-$(CONFIG_COBALT_LCD) += lcd.o 81obj-$(CONFIG_COBALT_LCD) += lcd.o
83obj-$(CONFIG_PPDEV) += ppdev.o 82obj-$(CONFIG_PPDEV) += ppdev.o
84obj-$(CONFIG_NWBUTTON) += nwbutton.o 83obj-$(CONFIG_NWBUTTON) += nwbutton.o
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index c39200161688..5ff457b41efb 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1054,7 +1054,7 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
1054{ 1054{
1055 struct page * page; 1055 struct page * page;
1056 1056
1057 page = alloc_page(GFP_KERNEL); 1057 page = alloc_page(GFP_KERNEL | GFP_DMA32);
1058 if (page == NULL) 1058 if (page == NULL)
1059 return NULL; 1059 return NULL;
1060 1060
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index d1ede7db5a12..555b3a8ab49c 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -169,7 +169,7 @@ static void *i8xx_alloc_pages(void)
169{ 169{
170 struct page * page; 170 struct page * page;
171 171
172 page = alloc_pages(GFP_KERNEL, 2); 172 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
173 if (page == NULL) 173 if (page == NULL)
174 return NULL; 174 return NULL;
175 175
@@ -387,11 +387,7 @@ static void intel_i830_init_gtt_entries(void)
387 /* We obtain the size of the GTT, which is also stored (for some 387 /* We obtain the size of the GTT, which is also stored (for some
388 * reason) at the top of stolen memory. Then we add 4KB to that 388 * reason) at the top of stolen memory. Then we add 4KB to that
389 * for the video BIOS popup, which is also stored in there. */ 389 * for the video BIOS popup, which is also stored in there. */
390 390 size = agp_bridge->driver->fetch_size() + 4;
391 if (IS_I965)
392 size = 512 + 4;
393 else
394 size = agp_bridge->driver->fetch_size() + 4;
395 391
396 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB || 392 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
397 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { 393 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
@@ -805,6 +801,26 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
805 801
806 return 0; 802 return 0;
807} 803}
804
805/*
806 * The i965 supports 36-bit physical addresses, but to keep
807 * the format of the GTT the same, the bits that don't fit
808 * in a 32-bit word are shifted down to bits 4..7.
809 *
810 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
811 * is always zero on 32-bit architectures, so no need to make
812 * this conditional.
813 */
814static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
815 unsigned long addr, int type)
816{
817 /* Shift high bits down */
818 addr |= (addr >> 28) & 0xf0;
819
820 /* Type checking must be done elsewhere */
821 return addr | bridge->driver->masks[type].mask;
822}
823
808static int intel_i965_fetch_size(void) 824static int intel_i965_fetch_size(void)
809{ 825{
810 struct aper_size_info_fixed *values; 826 struct aper_size_info_fixed *values;
@@ -832,7 +848,8 @@ static int intel_i965_fetch_size(void)
832 848
833 agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset); 849 agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset);
834 850
835 return values[offset].size; 851 /* The i965 GTT is always sized as if it had a 512kB aperture size */
852 return 512;
836} 853}
837 854
838/* The intel i965 automatically initializes the agp aperture during POST. 855/* The intel i965 automatically initializes the agp aperture during POST.
@@ -1584,7 +1601,7 @@ static struct agp_bridge_driver intel_i965_driver = {
1584 .fetch_size = intel_i965_fetch_size, 1601 .fetch_size = intel_i965_fetch_size,
1585 .cleanup = intel_i915_cleanup, 1602 .cleanup = intel_i915_cleanup,
1586 .tlb_flush = intel_i810_tlbflush, 1603 .tlb_flush = intel_i810_tlbflush,
1587 .mask_memory = intel_i810_mask_memory, 1604 .mask_memory = intel_i965_mask_memory,
1588 .masks = intel_i810_masks, 1605 .masks = intel_i810_masks,
1589 .agp_enable = intel_i810_agp_enable, 1606 .agp_enable = intel_i810_agp_enable,
1590 .cache_flush = global_cache_flush, 1607 .cache_flush = global_cache_flush,
diff --git a/drivers/char/ftape/Kconfig b/drivers/char/ftape/Kconfig
deleted file mode 100644
index 0d65189a7ae8..000000000000
--- a/drivers/char/ftape/Kconfig
+++ /dev/null
@@ -1,330 +0,0 @@
1#
2# Ftape configuration
3#
4config ZFTAPE
5 tristate "Zftape, the VFS interface"
6 depends on FTAPE
7 ---help---
8 Normally, you want to say Y or M. DON'T say N here or you
9 WON'T BE ABLE TO USE YOUR FLOPPY TAPE DRIVE.
10
11 The ftape module itself no longer contains the routines necessary
12 to interface with the kernel VFS layer (i.e. to actually write data
13 to and read data from the tape drive). Instead the file system
14 interface (i.e. the hardware independent part of the driver) has
15 been moved to a separate module.
16
17 To compile this driver as a module, choose M here: the
18 module will be called zftape.
19
20 Regardless of whether you say Y or M here, an additional runtime
21 loadable module called `zft-compressor' which contains code to
22 support user transparent on-the-fly compression based on Ross
23 William's lzrw3 algorithm will be produced. If you have enabled the
24 kernel module loader (i.e. have said Y to "Kernel module loader
25 support", above) then `zft-compressor' will be loaded
26 automatically by zftape when needed.
27
28 Despite its name, zftape does NOT use compression by default.
29
30config ZFT_DFLT_BLK_SZ
31 int "Default block size"
32 depends on ZFTAPE
33 default "10240"
34 ---help---
35 If unsure leave this at its default value, i.e. 10240. Note that
36 you specify only the default block size here. The block size can be
37 changed at run time using the MTSETBLK tape operation with the
38 MTIOCTOP ioctl (i.e. with "mt -f /dev/qft0 setblk #BLKSZ" from the
39 shell command line).
40
41 The probably most striking difference between zftape and previous
42 versions of ftape is the fact that all data must be written or read
43 in multiples of a fixed block size. The block size defaults to
44 10240 which is what GNU tar uses. The values for the block size
45 should be either 1 or multiples of 1024 up to a maximum value of
46 63488 (i.e. 62 K). If you specify `1' then zftape's builtin
47 compression will be disabled.
48
49 Reasonable values are `10240' (GNU tar's default block size),
50 `5120' (afio's default block size), `32768' (default block size some
51 backup programs assume for SCSI tape drives) or `1' (no restriction
52 on block size, but disables builtin compression).
53
54comment "The compressor will be built as a module only!"
55 depends on FTAPE && ZFTAPE
56
57config ZFT_COMPRESSOR
58 tristate
59 depends on FTAPE!=n && ZFTAPE!=n
60 default m
61
62config FT_NR_BUFFERS
63 int "Number of ftape buffers (EXPERIMENTAL)"
64 depends on FTAPE && EXPERIMENTAL
65 default "3"
66 help
67 Please leave this at `3' unless you REALLY know what you are doing.
68 It is not necessary to change this value. Values below 3 make the
69 proper use of ftape impossible, values greater than 3 are a waste of
70 memory. You can change the amount of DMA memory used by ftape at
71 runtime with "mt -f /dev/qft0 setdrvbuffer #NUMBUFFERS". Each buffer
72 wastes 32 KB of memory. Please note that this memory cannot be
73 swapped out.
74
75config FT_PROC_FS
76 bool "Enable procfs status report (+2kb)"
77 depends on FTAPE && PROC_FS
78 ---help---
79 Optional. Saying Y will result in creation of a directory
80 `/proc/ftape' under the /proc file system. The files can be viewed
81 with your favorite pager (i.e. use "more /proc/ftape/history" or
82 "less /proc/ftape/history" or simply "cat /proc/ftape/history"). The
83 file will contain some status information about the inserted
84 cartridge, the kernel driver, your tape drive, the floppy disk
85 controller and the error history for the most recent use of the
86 kernel driver. Saying Y will enlarge the size of the ftape driver
87 by approximately 2 KB.
88
89 WARNING: When compiling ftape as a module (i.e. saying M to "Floppy
90 tape drive") it is dangerous to use ftape's /proc file system
91 interface. Accessing `/proc/ftape' while the module is unloaded will
92 result in a kernel Oops. This cannot be fixed from inside ftape.
93
94choice
95 prompt "Debugging output"
96 depends on FTAPE
97 default FT_NORMAL_DEBUG
98
99config FT_NORMAL_DEBUG
100 bool "Normal"
101 ---help---
102 This option controls the amount of debugging output the ftape driver
103 is ABLE to produce; it does not increase or diminish the debugging
104 level itself. If unsure, leave this at its default setting,
105 i.e. choose "Normal".
106
107 Ftape can print lots of debugging messages to the system console
108 resp. kernel log files. Reducing the amount of possible debugging
109 output reduces the size of the kernel module by some KB, so it might
110 be a good idea to use "None" for emergency boot floppies.
111
112 If you want to save memory then the following strategy is
113 recommended: leave this option at its default setting "Normal" until
114 you know that the driver works as expected, afterwards reconfigure
115 the kernel, this time specifying "Reduced" or "None" and recompile
116 and install the kernel as usual. Note that choosing "Excessive"
117 debugging output does not increase the amount of debugging output
118 printed to the console but only makes it possible to produce
119 "Excessive" debugging output.
120
121 Please read <file:Documentation/ftape.txt> for a short description
122 how to control the amount of debugging output.
123
124config FT_FULL_DEBUG
125 bool "Excessive"
126 help
127 Extremely verbose output for driver debugging purposes.
128
129config FT_NO_TRACE
130 bool "Reduced"
131 help
132 Reduced tape driver debugging output.
133
134config FT_NO_TRACE_AT_ALL
135 bool "None"
136 help
137 Suppress all debugging output from the tape drive.
138
139endchoice
140
141comment "Hardware configuration"
142 depends on FTAPE
143
144choice
145 prompt "Floppy tape controllers"
146 depends on FTAPE
147 default FT_STD_FDC
148
149config FT_STD_FDC
150 bool "Standard"
151 ---help---
152 Only change this setting if you have a special controller. If you
153 didn't plug any add-on card into your computer system but just
154 plugged the floppy tape cable into the already existing floppy drive
155 controller then you don't want to change the default setting,
156 i.e. choose "Standard".
157
158 Choose "MACH-2" if you have a Mountain Mach-2 controller.
159 Choose "FC-10/FC-20" if you have a Colorado FC-10 or FC-20
160 controller.
161 Choose "Alt/82078" if you have another controller that is located at
162 an IO base address different from the standard floppy drive
163 controller's base address of `0x3f0', or uses an IRQ (interrupt)
164 channel different from `6', or a DMA channel different from
165 `2'. This is necessary for any controller card that is based on
166 Intel's 82078 FDC such as Seagate's, Exabyte's and Iomega's "high
167 speed" controllers.
168
169 If you choose something other than "Standard" then please make
170 sure that the settings for the IO base address and the IRQ and DMA
171 channel in the configuration menus below are correct. Use the manual
172 of your tape drive to determine the correct settings!
173
174 If you are already successfully using your tape drive with another
175 operating system then you definitely should use the same settings
176 for the IO base, the IRQ and DMA channel that have proven to work
177 with that other OS.
178
179 Note that this menu lets you specify only the default setting for
180 the hardware setup. The hardware configuration can be changed at
181 boot time (when ftape is compiled into the kernel, i.e. if you
182 have said Y to "Floppy tape drive") or module load time (i.e. if you
183 have said M to "Floppy tape drive").
184
185 Please read also the file <file:Documentation/ftape.txt> which
186 contains a short description of the parameters that can be set at
187 boot or load time. If you want to use your floppy tape drive on a
188 PCI-bus based system, please read the file
189 <file:drivers/char/ftape/README.PCI>.
190
191config FT_MACH2
192 bool "MACH-2"
193
194config FT_PROBE_FC10
195 bool "FC-10/FC-20"
196
197config FT_ALT_FDC
198 bool "Alt/82078"
199
200endchoice
201
202comment "Consult the manuals of your tape drive for the correct settings!"
203 depends on FTAPE && !FT_STD_FDC
204
205config FT_FDC_BASE
206 hex "IO base of the floppy disk controller"
207 depends on FTAPE && !FT_STD_FDC
208 default "0"
209 ---help---
210 You don't need to specify a value if the following default
211 settings for the base IO address are correct:
212 <<< MACH-2 : 0x1E0 >>>
213 <<< FC-10/FC-20: 0x180 >>>
214 <<< Secondary : 0x370 >>>
215 Secondary refers to a secondary FDC controller like the "high speed"
216 controllers delivered by Seagate or Exabyte or Iomega's Ditto Dash.
217 Please make sure that the setting for the IO base address
218 specified here is correct. USE THE MANUAL OF YOUR TAPE DRIVE OR
219 CONTROLLER CARD TO DETERMINE THE CORRECT SETTING. If you are already
220 successfully using the tape drive with another operating system then
221 you definitely should use the same settings for the IO base that has
222 proven to work with that other OS.
223
224 Note that this menu lets you specify only the default setting for
225 the IO base. The hardware configuration can be changed at boot time
226 (when ftape is compiled into the kernel, i.e. if you specified Y to
227 "Floppy tape drive") or module load time (i.e. if you have said M to
228 "Floppy tape drive").
229
230 Please read also the file <file:Documentation/ftape.txt> which
231 contains a short description of the parameters that can be set at
232 boot or load time.
233
234config FT_FDC_IRQ
235 int "IRQ channel of the floppy disk controller"
236 depends on FTAPE && !FT_STD_FDC
237 default "0"
238 ---help---
239 You don't need to specify a value if the following default
240 settings for the interrupt channel are correct:
241 <<< MACH-2 : 6 >>>
242 <<< FC-10/FC-20: 9 >>>
243 <<< Secondary : 6 >>>
244 Secondary refers to secondary a FDC controller like the "high speed"
245 controllers delivered by Seagate or Exabyte or Iomega's Ditto Dash.
246 Please make sure that the setting for the IO base address
247 specified here is correct. USE THE MANUAL OF YOUR TAPE DRIVE OR
248 CONTROLLER CARD TO DETERMINE THE CORRECT SETTING. If you are already
249 successfully using the tape drive with another operating system then
250 you definitely should use the same settings for the IO base that has
251 proven to work with that other OS.
252
253 Note that this menu lets you specify only the default setting for
254 the IRQ channel. The hardware configuration can be changed at boot
255 time (when ftape is compiled into the kernel, i.e. if you said Y to
256 "Floppy tape drive") or module load time (i.e. if you said M to
257 "Floppy tape drive").
258
259 Please read also the file <file:Documentation/ftape.txt> which
260 contains a short description of the parameters that can be set at
261 boot or load time.
262
263config FT_FDC_DMA
264 int "DMA channel of the floppy disk controller"
265 depends on FTAPE && !FT_STD_FDC
266 default "0"
267 ---help---
268 You don't need to specify a value if the following default
269 settings for the DMA channel are correct:
270 <<< MACH-2 : 2 >>>
271 <<< FC-10/FC-20: 3 >>>
272 <<< Secondary : 2 >>>
273 Secondary refers to a secondary FDC controller like the "high speed"
274 controllers delivered by Seagate or Exabyte or Iomega's Ditto Dash.
275 Please make sure that the setting for the IO base address
276 specified here is correct. USE THE MANUAL OF YOUR TAPE DRIVE OR
277 CONTROLLER CARD TO DETERMINE THE CORRECT SETTING. If you are already
278 successfully using the tape drive with another operating system then
279 you definitely should use the same settings for the IO base that has
280 proven to work with that other OS.
281
282 Note that this menu lets you specify only the default setting for
283 the DMA channel. The hardware configuration can be changed at boot
284 time (when ftape is compiled into the kernel, i.e. if you said Y to
285 "Floppy tape drive") or module load time (i.e. if you said M to
286 "Floppy tape drive").
287
288 Please read also the file <file:Documentation/ftape.txt> which
289 contains a short description of the parameters that can be set at
290 boot or load time.
291
292config FT_FDC_THR
293 int "Default FIFO threshold (EXPERIMENTAL)"
294 depends on FTAPE && EXPERIMENTAL
295 default "8"
296 help
297 Set the FIFO threshold of the FDC. If this is higher the DMA
298 controller may serve the FDC after a higher latency time. If this is
299 lower, fewer DMA transfers occur leading to less bus contention.
300 You may try to tune this if ftape annoys you with "reduced data
301 rate because of excessive overrun errors" messages. However, this
302 doesn't seem to have too much effect.
303
304 If unsure, don't touch the initial value, i.e. leave it at "8".
305
306config FT_FDC_MAX_RATE
307 int "Maximal data rate to use (EXPERIMENTAL)"
308 depends on FTAPE && EXPERIMENTAL
309 default "2000"
310 ---help---
311 With some motherboard/FDC combinations ftape will not be able to
312 run your FDC/tape drive combination at the highest available
313 speed. If this is the case you'll encounter "reduced data rate
314 because of excessive overrun errors" messages and lots of retries
315 before ftape finally decides to reduce the data rate.
316
317 In this case it might be desirable to tell ftape beforehand that
318 it need not try to run the tape drive at the highest available
319 speed. If unsure, leave this disabled, i.e. leave it at 2000
320 bits/sec.
321
322config FT_ALPHA_CLOCK
323 int "CPU clock frequency of your DEC Alpha" if ALPHA
324 depends on FTAPE
325 default "0"
326 help
327 On some DEC Alpha machines the CPU clock frequency cannot be
328 determined automatically, so you need to specify it here ONLY if
329 running a DEC Alpha, otherwise this setting has no effect.
330
diff --git a/drivers/char/ftape/Makefile b/drivers/char/ftape/Makefile
deleted file mode 100644
index 0e67d2f8b7ec..000000000000
--- a/drivers/char/ftape/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
1#
2# Copyright (C) 1997 Claus Heine.
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 as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to
16# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17#
18# $Source: /homes/cvs/ftape-stacked/ftape/Makefile,v $
19# $Revision: 1.4 $
20# $Date: 1997/10/05 19:17:56 $
21#
22# Makefile for the QIC-40/80/3010/3020 floppy-tape driver for
23# Linux.
24#
25
26obj-$(CONFIG_FTAPE) += lowlevel/
27obj-$(CONFIG_ZFTAPE) += zftape/
28obj-$(CONFIG_ZFT_COMPRESSOR) += compressor/
diff --git a/drivers/char/ftape/README.PCI b/drivers/char/ftape/README.PCI
deleted file mode 100644
index 18de159d36e0..000000000000
--- a/drivers/char/ftape/README.PCI
+++ /dev/null
@@ -1,81 +0,0 @@
1Some notes for ftape users with PCI motherboards:
2=================================================
3
4The problem:
5------------
6
7There have been some problem reports from people using PCI-bus based
8systems getting overrun errors.
9I wasn't able to reproduce these until I ran ftape on a Intel Plato
10(Premiere PCI II) motherboard with bios version 1.00.08AX1.
11It turned out that if GAT (Guaranteed Access Timing) is enabled (?)
12ftape gets a lot of overrun errors.
13The problem disappears when disabling GAT in the bios.
14Note that Intel removed this setting (permanently disabled) from the
151.00.10AX1 bios !
16
17It looks like that if GAT is enabled there are often large periods
18(greater than 120 us !??) on the ISA bus that the DMA controller cannot
19service the floppy disk controller.
20I cannot imagine this being acceptable in a decent PCI implementation.
21Maybe this is a `feature' of the chipset. I can only speculate why
22Intel choose to remove the option from the latest Bios...
23
24The lesson of this all is that there may be other motherboard
25implementations having the same of similar problems.
26If you experience a lot of overrun errors during a backup to tape,
27see if there is some setting in the Bios that may influence the
28bus timing.
29
30I judge this a hardware problem and not a limitation of ftape ;-)
31My DOS backup software seems to be suffering from the same problems
32and even refuses to run at 1 Mbps !
33Ftape will reduce the data-rate from 1 Mbps to 500 Kbps if the number
34of overrun errors on a track exceeds a threshold.
35
36
37Possible solutions:
38-------------------
39
40Some of the problems were solved by upgrading the (flash) bios.
41Other suggest that it has to do with the FDC being on the PCI
42bus, but that is not the case with the Intel Premiere II boards.
43[If upgrading the bios doesn't solve the problem you could try
44a floppy disk controller on the isa-bus].
45
46Here is a list of systems and recommended BIOS settings:
47
48
49 Intel Premiere PCI (Revenge):
50
51Bios version 1.00.09.AF2 is reported to work.
52
53
54
55 Intel Premiere PCI II (Plato):
56
57Bios version 1.00.10.AX1 and version 11 beta are ok.
58If using version 1.00.08.AX1, GAT must be disabled !
59
60
61
62 ASUS PCI/I-SP3G:
63
64Preferred settings: ISA-GAT-mode : disabled
65 DMA-linebuffer-mode : standard
66 ISA-masterbuffer-mode : standard
67
68
69 DELL Dimension XPS P90
70
71Bios version A2 is reported to be broken, while bios version A5 works.
72You can get a flash bios upgrade from http://www.dell.com
73
74
75To see if you're having the GAT problem, try making a backup
76under DOS. If it's very slow and often repositions you're
77probably having this problem.
78
79 --//--
80 LocalWords: ftape PCI bios GAT ISA DMA chipset Mbps Kbps FDC isa AF ok ASUS
81 LocalWords: SP linebuffer masterbuffer XPS http www com
diff --git a/drivers/char/ftape/RELEASE-NOTES b/drivers/char/ftape/RELEASE-NOTES
deleted file mode 100644
index 03799dbc05a4..000000000000
--- a/drivers/char/ftape/RELEASE-NOTES
+++ /dev/null
@@ -1,966 +0,0 @@
1Hey, Emacs, we're -*-Text-*- mode!
2
3===== Release notes for ftape-3.04d 25/11/97 =====
4- The correct pre-processor statement for "else if" is "#elif" not
5 "elsif".
6- Need to call zft_reset_position() when overwriting cartridges
7 previously written with ftape-2.x, sftape, or ancient
8 (pre-ftape-3.x) versions of zftape.
9
10===== Release notes for ftape-3.04c 16/11/97 =====
11- fdc_probe() was calling DUMPREGS with a result length of "1" which
12 was just fine. Undo previous change.
13
14===== Release notes for ftape-3.04b 14/11/97 =====
15
16- patches/2.x.x/floppy.c.diff was somewhat broken, releasing i/o
17 regions it never had allocated.
18- fdc_probe() was calling DUMPREGS with a result length of "1" instead
19 of "10"
20- Writing deleted data marks if the first segents on track zero are
21 should work now.
22- ftformat should now be able to handle those cases where the tape
23 drive sets the read only status bit (QIC-40/80 cartridges with
24 QIC-3010/3020 tape drives) because the header segment is damaged.
25- the MTIOCFTCMD ioctl may now be issued by the superuser ONLY.
26
27===== Release notes for ftape-3.04a 12/11/97 =====
28- Fix an "infinite loop can't be killed by signal" bug in
29 ftape_get_drive_status(). Only relevant when trying to access
30 buggy/misconfigured hardware
31- Try to compensate a bug in the HP Colorado T3000's firmware: it
32 doesn't set the write protect bit for QIC80/QIC40 cartridges.
33
34===== Release notes for ftape-3.04 06/11/97 =====
35- If positioning with fast seeking fails fall back to a slow seek
36 before giving up.
37- (nearly) no retries on "no data errors" when verifying after
38 formatting. Improved tuning of the bad sector map after formatting.
39- the directory layout has changed again to allow for easier kernel
40 integration
41- Module parameter "ftape_tracing" now is called "ft_tracing" because
42 the "ftape_tracing" variable has the version checksum attached to it.
43- `/proc/ftape' interface for 2.0.* kernels. `/proc/ftape' no longer
44 is a directory but a file that contains all the information formerly
45 provided in separate files under the `/proc/ftape/' directory.
46- Most of the configuration options have been prefixed by "CONFIG_FT_"
47 in preparation of the kernel inclusion. The Makefiles under
48 "./ftape/" should be directly usable by the kernel.
49- The MODVERSIONS stuff is now auto-detected.
50- Broke backslashed multi line options in MCONFIG into separate lines
51 using GNU-make's "+=" feature.
52- The html and dvi version of the manual is now installed under
53 '/usr/doc/ftape` with 'make install`
54- New SMP define in MCONFIG. ftape works with SMP if this is defined.
55- attempt to cope with "excessive overrun errors" by gradually
56 increasing FDC FIFO threshold. But this doesn't seem to have too
57 much an effect.
58- New load time configuration parameter "ft_fdc_rate_limit". If you
59 encounter too many overrun errors with a 2Mb controller then you
60 might want to set this to 1000.
61- overrun errors on the last sector in a segment sometimes result in
62 a zero DMA residue. Dunno why, but compensate for it.
63- there were still fdc_read() timeout errors. I think I have fixed it
64 now, please FIXME.
65- Sometimes ftape_write() failed to re-start the tape drive when a
66 segment without a good sector was reached ("wait for empty segment
67 failed"). This is fixed. Especially important for > QIC-3010.
68- sftape (aka ftape-2.x) has vanished. I didn't work on it for
69 ages. It is probably still possible to use the old code with
70 ftape-3.04, if one really needs it (BUT RECOMPILE IT)
71- zftape no longer alters the contents of already existing volume
72 table entries, which makes it possible to fill in missing fields,
73 like time stamps using some user space program.
74- ./contrib/vtblc/ contains such a program.
75- new perl script ./contrib/scripts/listtape that list the contents of a
76 floppy tape cartridge parsing the output of "mt volinfo" + "mt fsf"
77- the MTWEOF implementation has changed a little bit (after I had a
78 look at amanda). Calling MTWEOF while the tape is still held open
79 after writing something to the tape now will terminate the current
80 volume, and start a new one at the current position.
81- the volume table maintained by zftape now is a doubly linked list
82 that grows dynamically as needed.
83
84 formatting floppy tape cartridges
85 ---------------------------------
86 * there is a new user space formatting program that does most of the
87 dirty work in user space (auto-detect, computing the sector
88 coordinates, adjusting time stamps and statistics). It has a
89 simple command line interface.
90 * ftape-format.o has vanished, it has been folded into the low level
91 ftape.o module, and the ioctl interface into zftape.o. Most of the
92 complicated stuff has been moved to user space, so there was no
93 need for a separate module anymore.
94 * there is a new ioctl MTIOCFTCMD that sends a bare QIC-117 command
95 to the tape drive.
96 * there is a new mmap() feature to map the dma buffers into user
97 space to be used by the user level formatting program.
98 * Formatting of yet unformatted or totally degaussed cartridges
99 should be possible now. FIXME.
100
101===== Release notes for ftape-3.03b, <forgot the exact date> ====
102
103ftape-3.03b was released as a beta release only. Its main new feature
104was support of the DITTO-2GB drive. This was made possible by reverse
105engineering done by <fill in his name> after Iomega failed to support
106ftape. Although they had promised to do so (this makes me feel a bit
107sad and uncomfortable about Iomega).
108
109===== Release notes for ftape-3.03a, 22/05/97 ====
110
111- Finally fixed auto-un-loading of modules for kernels > 2.1.18
112- Add an "uninstall" target to the Makefile
113- removed the kdtime hack
114- texi2www didn't properly set the back-reference from a footnote back
115 to the regular text.
116
117 zftape specific
118 ---------------
119 * hide the old compression map volume. Taper doesn't accept the
120 presence of non-Taper volumes and Taper-written volume on the same
121 tape.
122 * EOD (End Of Data) handling was still broken: the expected behavior
123 is to return a zero byte count at the first attempt to read past
124 EOD, return a zero byte count at the second attempt to read past
125 EOD and THEN return -EIO.
126
127 ftape-format specific
128 ---------------------
129 * Detection of QIC-40 cartridges in select_tape_format() was broken
130 and made it impossible to format QIC-3010/3020 cartridges.
131 * There are strange "TR-1 Extra" cartridges out there which weren't
132 detected properly because the don't strictly conform to the
133 QIC-80, Rev. N, spec.
134
135===== Release notes for ftape-3.03, 30/04/97 =====
136
137- Removed kernel integration code from the package. I plan to provide
138 a package that can be integrated into the stock kernel separately
139 (hopefully soon).
140 As a result, a simple `make' command now will build everything.
141- ALL compile time configuration options have been moved to the file
142 `MCONFIG'.
143- Quite a few `low level' changes to allow formatting of cartridges.
144- formatting is implemented as a separate module `ftape-format.o'. The
145 modified `mt' program contains sample code that shows how to use it.
146- The VFS interface has been moved from the `ftape.o' module to the
147 high level modules `zftape.o' resp. `sftape.o'. `ftape.o' contains
148 the hardware support only.
149- A bit of /proc support for kernels > 2.1.28
150- Moved documentation to Doc subdir. INSTALL now contains some real
151 installation notes.
152- `install' target in Makefile.
153
154zftape specific:
155----------------
156
157- zftape works for large cartridges now ( > 2^31 bytes)
158- MTIOCVOLINFO and MTIOCGETSIZE now return the size in KILOBYTES,
159 NO LONGER in bytes.
160
161- permissions for write access to a cartridge have changed:
162 * zftape now also takes the file access mode into account
163 * zftape no longer allows writing in the middle of the recorded
164 media. The tape has to be positioned at BOT or EOD for write
165 access.
166
167- MTBSF has changed. It used to position at the beginning of the
168 previous file when called with count 1. This was different from the
169 expected behavior for other Un*x tape drivers (i.e. SCSI). MTBSF
170 with count 1 should merely position at the beginning of the current
171 volume. Fixed. As a result, `tar --verify' now produces the desired
172 result: it verifies the last written volume, not the pre-last
173 written volume.
174
175- The compression map has vanished --> no need for `mt erase' any
176 more. Fast seeking in a compressed volume is still be possible, but
177 takes slightly longer. As a side effect, you may experience an
178 additional volume showing up in front of all others for old
179 cartridges. This is the tape volume that holds the compression map.
180
181- The compression support for zftape has been moved to a separate
182 module `zft-compressor'. DON'T forget to load it before trying to
183 read back compressed volumes. The stock `zftape.o' module probes for
184 the module `zft-compressor' using the kerneld message channel; you
185 have to install `zft-compressor.o' in a place where modprobe can
186 find it if you want to use this.
187
188- New experimental feature that tries to get the broken down GMT time
189 from user space via a kernel daemon message channel. You need to
190 compile and start the `kdtime' daemon contained in the contrib
191 directory to use it. Needed (?) for time stamps in the header
192 segments and the volume table.
193
194- variable block size mode via MTSETBLK 0
195
196- keep modules locked in memory after the block size has been changed
197
198sftape specific:
199----------------
200
201- end of tape handling should be fixed, i.e. multi volume archives
202 written with `afio' can be read back now.
203
204
205===== Release notes for ftape-3.02a, 09/01/97 =====
206
207No big news:
208- call zft_init() resp. sft_init() when compiling the entire stuff
209 into the kernel image.
210- fix bug in ftape-setup.c when NO_TRACE_AT_ALL was defined.
211- fix bug in sftape-eof.c/zftape-eof.c for old kernels (1.2.*)
212- add support for new module interface for recent kernels
213
214===== Release notes for ftape-3.02, 16/12/96 =====
215- Fixed the `FDC unlock command failed' bug in fdc-io.c. When the FIFO
216 was already locked when ftape was loaded, ftape failed to unlock it.
217- Fixed compilation of `contrib/gnumt'. It now finds `mtio.h' even if
218 ftape is NOT included into the kernel source tree.
219- fc-10.c: include <asm/io.h> for inb() and outb().
220- ftape/sftape/zftape: all global variable now have either a `ftape_',
221 a `ft_', `sft_', `zft_' or `qic_' prefix to prevent name clashes
222 with other parts of the kernel when including ftape into the kernel
223 source tree.
224- Kerneld support has changed. `ftape' now searches for a module
225 `ftape-frontend' when none of the frontend (`sftape' or `zftape') is
226 loaded. Please refer to the `Installation/Loading ftape' section of
227 the TeXinfo manual.
228- Add load resp. boot-time configuration of ftape. There are now
229 variables ft_fdc_base, ft_fdc_dma and ft_fdc_irq corresponding to
230 the former FDC_BASE etc. compile time definitions. One can also use
231 the kernel command line parameters to configure the driver if it is
232 compiled into the kernel. Also, the FC-10/FC-20 support is load-time
233 configurable now as well as the MACH-II hack (ft_probe_fc10,
234 resp. ft_mach2). Please refer to the section `Installation/Configure
235 ftape' of the TeXinfo manual.
236- I removed the MODVERSIONS option from `Makefile.module'. Let me alone
237 with ftape and MODVERSIONS unless you include the ftape sources into
238 the kernel source tree.
239- new vendors in `vendors.h':
240 * HP Colorado T3000
241 * ComByte DoublePlay (including a bug fix for their broken
242 formatting software, thanks to whraven@njackn.com)
243 * Iomega DITTO 2GIG. NOTE: this drive cannot work with ftape because
244 the logical data layout of the cartridges used by this drive does
245 NOT conform to the QIC standards, it is a special Iomega specific
246 format. I've sent mail to Iomega but didn't receive an answer
247 yet. If you want this drive to be supported by ftape, ask Iomega
248 to give me information about it.
249- zftape:
250 * re-introduced the MTIOC_ZFTAPE_GETBLKSZ ioctl for compatibility
251 with zftape 1.06a and earlier. Please don't use it when writing
252 new software, use the MTIOCVOLINFO ioctl instead.
253 * Major overhaul of the code that updates the header segments. Never
254 change the tape label unless erasing the tape. Thus we almost
255 never need to write the header segments, unless we would modify
256 the bad sector map which isn't done yet. Updating of volume table
257 and compression map more secure now although it takes a bit
258 longer.
259 * Fixed bug when aborting a write operation with a signal: zftape
260 now finishes the current volume (i.e. writes an eof marker) at the
261 current position. It didn't before which led to somehow *strange*
262 behavior in this cases.
263 * Keep module locked in memory when using it with the non-rewinding
264 devices and the tape is not logical at BOT. Needed for kerneld
265 support.
266- sftape:
267 * Keep module locked in memory when using it with the non-rewinding
268 devices and the tape is not logical at BOT. Needed for kerneld
269 support.
270
271===== Release notes for ftape-3.01, 14/11/96 =====
272
273- Fixed silly bugs in ftape-3.00:
274 * MAKEDEV.ftape: major device number must be 27, not 23
275 * sftape/sftape-read.c: sftape_read_header_segments() called
276 itself recursively instead of calling ftape_read_header_segment()
277 * zftape/qic-vtbl.h: conversion of ftape's file marks to zftape's
278 internal volume table was broken.
279 * patches/2.x.x/linux-2.0.21.dif: my RCS (resp. CVS) system replaced
280 the `$Revison:' etc. macros in the `ftape.h' concerning part of the
281 patch :-( Fixed.
282 * info/ftape.info: Fixed misspellings (`cp' <-> `cp -r' etc.)
283 * when ftape/sftape or ftape/zftape was compiled into the kernel the
284 variable ftape_status was declared twice. Fixed.
285 * removed reference to undeclared variable kernel_version when not
286 compiling as module
287 * fixed a bug introduced by the use of bit-fields for some flags
288 (i.e. write_protected, no_cartridge, formatted)
289 * flag `header_read' is now reset correctly to zero when tape is
290 removed.
291- fixed a bug in sftape/sftape-eof.c that was already in the original
292 ftape code. MTFSF/BSF was not handled correctly when positioned
293 right before the file mark (think of tar)
294- Changed TRACE macros (following a suggestion of Marcin Dalecki) to use
295 the predefined __FUNCTION__ macro of GCC. Spares about 4k of code.
296- added new vendor id for Iomega DITTO 2GIG
297- fixed a bug already present in zftape-1.06 when aborting a write
298 with a signal: we now finish the current volume at that
299 position. Header segments remain NOT up to date until an explicit call
300 to MTREW or MTOFFL is done.
301
302===== Release notes for ftape-3.00, 14/10/96 =====
303
304- Merged ftape with zftape. There are three modules now:
305 ftape for the hardware support, sftape for the implementation of the
306 original ftape eof mark stuff and zftape that implements zftape's way
307 of handling things (compression, volume table, tape blocks of
308 constant length)
309- Documentation in TeXinfo format in the `info' subdirectory.
310- New ioctls for zftape. See zftape/zftape.h
311- Dummy formatting ioctl for ftape. See ftape.h
312- Kernel patch files for the 2.*.* series to include ftape-3.00 in the
313 kernel source tree. These includes a kernel compatible Config.in
314 script and fairly large online information for the kernel configure
315 script.
316- Support for compiling with Linux-1.2.13.
317- Modified GNU mt from their cpio package that can handle the new
318 ioctls.
319- ftape/sftape/zftape is kerneld save now!
320
321Notes on sftape:
322- sftape implements the eof handling code of the original ftape. If
323 you like to stick with the original ftape stuff, you have to use
324 this module, not zftape.
325- sftape is kerneld save, unlike the original ftape.
326- we keep the entire header segment now in memory, so no need to read
327 it before updating the header segments. Additional memory
328 consumption: 256 bytes.
329
330Notes for zftape:
331- zftape has support for tapes with format code 6 now, which use a
332 slightly different volume table format compared with other floppy
333 tapes.
334- new ioctls for zftape. Have a look at zftape/zftape.h
335- The internal volume table representation has changed for zftape. Old
336 cartridges are converted automatically.
337- zftape no longer uses compression map segments, which have vanished
338 from the QIC specs, but creates volume table entry that reserves
339 enough space for the compression map.
340- zftape is kerneld save now.
341- we keep the entire header segment now in memory, so no need to read
342 it before updating the header segments. Additional memory
343 consumption: 256 bytes.
344
345Notes for contrib/gnumt:
346- modified mt from the GNU cpio package that supports all the new
347 ioctls of zftape.
348Notes for contrib/swapout:
349- This contains the swapout.c program that was written by Kai
350 Harrekilde-Pederson. I simply added a Makefile.
351
352===== Release notes for ftape-2.10, 14/10/96 =====
353
354The ftape maintainer has changed.
355Kai Harrekilde-Petersen <khp@dolphinics.no>
356has resigned from maintaining ftape, and I,
357Claus-Justus Heine <claus@momo.math.rwth-aachen.de>,
358have taken over.
359
360- Added support for tapes with `format code 6', i.e. QIC-3020 tapes
361 with more than 2^16 segments.
362- merged changes made by Bas Laarhoven with ftape-2.09. Refer
363 to his release notes below. I've included them into this
364 file unchanged for your reference.
365- disabled call stack back trace for now. This new feature
366 introduced by the interim release 2.0.x still seems to
367 be buggy.
368- Tried to minimize differences between the ftape version
369 to be included into the kernel source tree and the standalone
370 module version.
371- Reintroduced support for Linux-1.2.13. Please refer to the
372 Install-guide.
373
374===== Release notes for ftape-2.09, 16/06/96 =====
375
376There aren't any really big news in this release, mostly just that I
377(the maintainer) have changed my email address (due to a new job). My
378new address is <khp@dolphinics.no>
379
380- The CLK_48MHZ and FDC_82078SL options has gone (all 2Mbps cards seem
381 to use a 48MHz oscillator anyway and I haven't heard of an 'SL
382 chip out there).
383- The S82078B has been `downgraded' to i82077AA compability.
384- TESTING option revived. Right now, it'll enable the (seriously broken)
385 2Mbps code. If you enable it, you'll experience a tape drive that's
386 *really* out to lunch!
387- Some (bold) changes in the init code. Please notify me if they
388 break things for you.
389
390===== Release notes for ftape-2.08, 14/03/96 =====
391
392If you correct a problem with ftape, please send your patch to
393khp@dolphinics.no too.
394
395- Updated to reflect that NR_MEM_LISTS is gone in 1.3.74
396- Teac 700 added to list of known drives.
397- The registered device name is now "ft" rather than "ftape".
398
399===== Release notes for ftape-2.07a, 14/03/96 =====
400
401Bugfixes by Marcin Dalecki <dalecki@namu03.gwdg.de>:
402- In the last release it just compiled against 1.3.70;
403 now the params to request_irq() and free_irq are() are fixed, so it also
404 works in 1.3.73 :-)
405- Support for modules is now correct for newer kernels.
406
407===== Release notes for ftape-2.07, 04/03/96 =====
408
409
410- ftape updated to compile against 1.3.70.
411- Iomega 700 and Wangtek 3200 recognised.
412
413
414===== Release notes for ftape-2.06b, 13/02/96 =====
415
416Another simple bugfix version.
417
418- Jumbo 700 recognised.
419- Typo in vendors.h fixed.
420
421
422===== Release notes for ftape-2.06a, 10/02/96 =====
423
424This release is a simple bugfix version.
425
426- Linux/SMP: ftape *should* work.
427- FC-10/20: Only accepts IRQs 3-7, or 9. If IRQ 9, properly tell the card
428 to use IRQ 2. Thanks to Greg Crider (gcrider@iclnet.org) for finding and
429 locating this bug and testing the patch.
430- Insight drive recognised correctly again.
431- Motor-on wakeup version of the Iomega 250 drive added
432
433
434===== Release notes for ftape-2.06, 28/01/96 =====
435
436Special thanks go to Neal Friedman and Steven Sorbom for their
437help in producing and testing this release.
438
439I have continued to clean up the code, with an eye towards inclusion
440of ftape in Linus' official kernel (In fact, as I type this, I am
441running on a kernel with ftape support statically linked). I have
442test-compiled ftape against my 1.2.13 tree without problems.
443Hopefully, everything should be OK for the v1.2.x people.
444
445WARNING! Alan Cox has mailed me that ftape does *NOT* work with
446Linux/SMP. If you try to run ftape under Linux/SMP, it will cause a
447kernel deadlock (which is worse than a panic).
448
449- QIC-3020/TR-3: 1Mbps support works. Neal is capable of reading and
450 writing data to a tape. ftape will automatically detect the type of
451 tape (e.g. TR-3 vs QIC-80) and move the fdc in and out of
452 "perpendicular mode" as necessary.
453- 2Mbps support is disabled by default, since it is not fully
454 debugged. If you are adventurous, remove -DFDC_82078SL in the
455 Makefile and see what happens :-)
456- fdc detection: silly bugs removed (Only 2Mbps fdcs were affected)
457 and added detection of the National Semiconductors PC8744 fdc chip
458 (used in the PC873xx "super-IO" chips).
459- Removed warning about incompatible types when compiling with Linux
460 1.2.x.
461- README.PCI updated with info about the DELL Dimension XPS P90.
462- Connor TST3200R added to detected drives.
463- `swapout' utility added to distribution. It will dirty 5Meg of
464 memory, trying to swap out other programs. Just say `make swapout'
465 to build it. ftape will do this automatically Real Soon Now (ie:
466 when I have found out which kernel memory alloc function to call).
467
468
469===== Release notes for ftape-2.05, 08/01/96 =====
470
471- For v1.2.x Kernels, you must apply the patch linux-1.2/ksyms.patch to
472 the kernel and rebuild it (it adds the __get_dma_pages symbol to
473 ksyms.c).
474- Included new asm-i386/io.h file from v1.3.x kernel series, to enable
475 gcc v.2.7.[12] to compile v1.2.x kernels (linux-1.2/io.h).
476- Module versions: If you wish to compile ftape as a versioned module,
477 you must first compile your kernel with CONFIG_MODVERSIONS=y.
478 Otherwise, you will get complaints that <linux/modversions.h> does not
479 exist (if that happens, a `touch modversions.h' will help you out).
480- CLK_48MHZ: new define in the Makefile (default: non-zero). If you have
481 a tape controller card that uses the i82078(-1) chip, but cannot get
482 it to work with ftape, try set it to 0 (and please report this).
483- QIC-3010/3020: Complete support is still missing, but will hopefully
484 come soon. Steven Sorbom has kindly provided me with hints about
485 this. Writing of QIC-3020 tapes definitely does NOT work (do not try
486 it! - the drive will not be in "perpendicular mode" and this will ruin
487 the formatting info on the tape).
488- ftape_num_buffers is out of fashion: use NR_BUFFERS instead (and
489 recompile if you want to change it :-).
490
491
492===== Release notes for ftape-2.04, 01/01/96 =====
493
494This version by Kai Harrekilde-Petersen <khp@dolphinics.no>
495
496- ALERT! Support for Kernels earlier then v1.1.85 is about to go away.
497 I intend to clean up some of the code (getting rid of an annoyingly
498 large numbers of #ifdef mostly), which means that support for
499 pre-1.1.85 kernels must go as well.
500- NR_FTAPE_BUFFERS is gone; You can instead select the number of dma
501 buffers by saying `insmod ftape.o ftape_num_buffer=<n>' instead.
502- Configure script gone. ftape will now automagically determine your
503 kernel version by /usr/include/linux/version.h instead.
504- CONFIG_MODVERSIONS now work. All combinations of versioned /
505 unversioned kernel and ftape module works (at least with my 1.3.52
506 kernel).
507- If you have problems with inserting ftape into an old (1.2.x)
508 kernel (e.g. insmod says "1.2.8 does not match 1.2.8), recompile
509 your modules utilities with your new compiler.
510- Reveal TB1400 drive added to vendors.h
511- Support for the i82078-1 (2Mbps) chip is coming along. The
512 biggest problem is that I don't have such a card, which makes
513 testing / debugging somewhat problematic. The second biggest
514 problem is that I do not have the QIC-3010/3020 standards either.
515 Status right now is that the chip is detected, and it should be
516 possible to put it into 2Mbps mode. However, I do not know what
517 "extras" are needed to complete the support. Although putting the
518 i82078 into 1Mbps mode ought to work out of the box, it doesn't
519 (right now, ftape complains about id am errors).
520
521
522===== Release notes for ftape-2.04beta5, 29/12/95 =====
523
524Bas offline linux-tape
525----------------------
526For reasons only known to the majordomo mail list processor, Bas was
527kicked off the linux-tape list sometime during the summer. Being
528overworked at his for-pay job, he didn't notice it much. Instead I
529(Kai, khp@dolphinics.no) has worked on ftape to produce the 2.04(beta)
530version.
531
532zftape
533------
534Note that there exists a much improved version of ftape, written by
535Claus-Justus Heine <claus@willi.math.rwth-aachen.de> which is named
536zftape, which conforms to the QIC-80 specs on how to mark backups, and
537is capable of doing automatic compression. However, zftape makes
538substantial changes to ftape, and I (Kai) have therefore declined to
539integrate zftape into ftape. Hopefully, this will happen soon.
540
541CONFIG_QIC117 removed from the kernel
542-------------------------------------
543The biggest change of all is that ftape now will allocate its dma
544buffers when it is inserted. The means that the CONFIG_QIC117 option
545has disappeared from the Linux kernel as of v1.3.34. If you have an
546earlier kernel, simply answer 'no' to the question will do the trick
547(if you get complains about __get_free_pages() missing, contact the
548linux-tape mailing list).
549
550Note that ftape-2.04beta will work equally well on kernels with and
551without `ftape support'. The only catch is, that you will waste
552around 96-128Kb of precious DMA'able memory on a box that has ftape
553support compiled in.
554
555Now for the real changes:
556
557- FC-20 can now use DMA channels 1, 2, and 3. Thanks to Daniel
558 Cohen, catman@wpi.edu.
559- ftape no longer requires a (gigantic) 96Kb buffer to be statically
560 allocated by the kernel.
561- Added new Iomega drive (8882) to vendors.h
562- -fno-strength-reduce added to Makefile, since GCC is broken.
563- i82078-1 (2Mbps) FDC support started.
564
565
566===== Release notes for ftape-2.03b, 27/05/95 =====
567
568- Prevented verify_area to return error if called with zero length.
569- Fixed a bug in flush_buffers that caused too much padding to be
570 written when a final segment had bad sectors.
571- Increased maximum fast-seek overshoot value from 5 to 10 segments.
572- Breaking loop after 5 retries when positioning fails.
573- Fixed wrong calculation of tape length for QIC-3010 and QIC-3020
574 tapes (densities were swapped).
575- Fixed wrong calculation of overshoot on seek_forward: Wrong sign
576 of error.
577- Suppress (false) error message due to new tape loaded.
578- Added two new CMS drives (11c3 and 11c5) to vendors.h.
579
580
581===== Release notes for ftape-2.03a, 09/05/95 =====
582
583- Fixed display of old error (even if already cleared) in ftape_open.
584- Improved tape length detection, ioctls would fail for 425 ft tapes.
585 Until the tape length is calculated with data from the header
586 segment, we'll use worst-case values.
587- Clear eof_mark after rewinding ioctls.
588- Fixed wrong version message (2.03 had 2.02g id).
589- Fixed bug that caused the fdc to be reset very frequently.
590 This shouldn't affect normal operation but the timing of the
591 report routines has changed again and that may cause problems.
592 We'll just have to find out....
593- Implemented correct write precompensation setting for QIC-3010/3020.
594- Cleaned up fdc_interrupt_wait routine. Hope it still works :-)
595- Finally removed (already disabled) special eof mark handling for
596 gnu tar.
597- Changed order of get_dma_residue and disable_dma in fdc-isr.c
598 because the current order would fail on at least one system.
599 We're back to the original order again, hope (and expect) this
600 doesn't break any other system.
601
602
603===== Release notes for ftape-2.03, 07/05/95 =====
604
605(Changes refer to the first ftape-2.02 release)
606
607Support for wide and extended length tapes
608------------------------------------------
609The Conner TSM 420 and 850 drives are reported to be working.
610I haven't received any reports about other brands; the TSM 420
611and 850 seem to be the most widely used wide drives.
612Extended length tapes (425 ft) with normal QIC-80 drives
613are operating too (At least I've had no reports stating otherwise).
614_Not_ yet completely supported (although they may work) are
615QIC-3020 drives and 2 Mbps floppy disk controllers won't work at
616the highest speed.
617If someone is kind enough to send me one of these, I'll include
618support for it too ;-)
619
620Easier configuration
621--------------------
622Problems due to wrong settings in the Makefile are prevented
623by using a configuration script that sets the necessary (kernel
624version dependent) compile time options.
625This kernel version is now determined from the sources found
626at /usr/src/linux, or if not found, the old way using
627/proc/version.
628Versioned modules will be used automatically when supported
629by- and configured in- the kernel.
630Note that the current modules code (1.1.87) is still broken
631and _needs_ the fix included in the insmod directory.
632Please don't send me any more Oops reports caused by insmod :-(
633
634Reduced module size
635-------------------
636The standard module size is much reduced and some compile time
637options can even reduce it further. (I don't recommend this
638for normal use but it can be handy for rescue diskettes)
639
640Option: Approx. module size:
641
642<standard> 150 Kb
643NO_TRACE 125 Kb
644NO_TRACE_AT_ALL 67 Kb
645
646
647Much improved driver interruption
648---------------------------------
649Most possible loops have been broken and signal detection
650has been improved.
651In most cases the driver can be aborted by ^C (SIGINT) and
652SIGKILL (kill -9) will generate be a sure kill.
653(Note that aborting a tape operation may damage the last
654data written to tape)
655
656Improved error recovery
657-----------------------
658Ftape now returns an error (ENODATA) to the application if
659a segment proves to be unrecoverable and then skips the
660bad segment.
661This causes most applications to continue to work (tar
662and afio) loosing only a small amount (up to 29 Kb) of data.
663Retried read operations will now be done slightly off-track
664to improve the chance of success. Serious head off-track
665errors will be detected.
666
667FC-10 and FC-20 controllers
668---------------------------
669Ftape now supports both the old CMS FC-10 and the newer FC-20
670controllers.
671Because the operation of these cards is still undocumented,
672thus far they will only work with the default settings (See
673Makefile). Any feed-back on how to use them with other settings
674will be welcome !
675Compilation will fail if one changes the settings to illegal
676values.
677
678Kernels and compilers
679---------------------
680Ftape is currently being developed using the 2.5.8 compiler.
681The older 2.4.5 probably works too (Set option in Makefile!).
682I have no experience with any later compilers nor Elf support.
683Any information on this is welcome.
684The latest kernel I have tested ftape with is 1.2.6.
685
686Compression
687-----------
688An impressive collection of changes for ftape including
689on-the-fly compression is still lying on my desk.
690If 2.03 proves to be reliable I might start integrating these
691but as usual, I'm short in time :-(
692
693Formatting
694----------
695There is still no way to format tapes under Linux. As far as
696I know all attempts to write such a program have died now.
697Since formatted tapes are rather common now, I think all we
698need is a utility that writes a worst case pattern and verifies
699that with the drive put in verify mode, reducing margins.
700Any takers ?
701
702Furthermore
703-----------
704Cleaned up messages.
705Prepared to support multiple tape drives on one fdc.
706Thanks to all the people who sent bug reports and helped me
707improve the driver. Without trying to be complete I'll mention
708Gary Anderson (without his accurate reports and unreliable
709hardware there wouldn't be a 2.03), Stefan Kneifel (FC-20),
710Robert Broughton (FC-20, you were almost there ;-), Bjorn
711Ekwall (for the versioned modules and buggy insmod ;-), Peter
712Fox, Christopher Oliver, Ralph Whittaker and not the least
713Linus Torvalds (for Linux and keeping me busy because of
714changes to the kernel ;-)
715Thanks to anyone I forgot, for the bug reports, the ftape
716bashing and the mental support...
717
718
719That's it for now. Have Fun,
720
721Bas.
722
723
724===== Release notes for ftape-2.02g, 06/05/95 =====
725
726- Added extra test to break read-id loop with signal.
727- Changed rewind code to handle negative overshoot for drives
728 that take very long to start or stop.
729- Let use of get/set i/o-regions depend on kernel version.
730- Changed code to use a more general test for conditional
731 compilations depending on kernel version.
732- Improved micro-step functionality to go off-track only
733 while reading (id & data).
734- Added failure on tape-not-referenced bit in ftape_command.
735- Added FOREVER option to read-wait routine.
736- Changed read-id to use shorter timeout causing smaller
737 rewinds on timeout.
738- Made kernel-interface functions static.
739
740
741===== Release notes for ftape-2.02f, 03/05/95 =====
742
743- Added support for dual tape drives on my system, extended Configure
744 script to detect host 'dodo'.
745- Log media defect in history if ecc failed and no data was returned.
746- Fixed Configure script that was failing for kernel versions with
747 double digit version or revision numbers.
748
749
750===== Release notes for ftape-2.02e, 01/05/95 =====
751
752- Fixed reposition loop at logical eot (failing read_id).
753- Fixed 34 segment offset when rewinding.
754- Added fast seek capability for more than 255 segments.
755- Fixed wrong busy result from ftape_command causing reverse
756 seek to fail.
757- Added breakout from infinite rewind loop (if something fails).
758
759
760===== Release notes for ftape-2.02d, 30/04/95 =====
761
762- Improved abortion on signals: Interrupt will make a graceful
763 exit, Kill will be less nice and should be used if everything
764 else fails.
765- Included check for tape-head off track.
766- Implemented exit from tape-start loop.
767- Added kernel io-port registration.
768- Implemented skip of failing segment (ENODATA) on ecc failure.
769 This allows afio and tar to continue when the tape is damaged.
770- Made distinction between drive names with different codes.
771
772
773===== Release notes for ftape-2.02c, 22/04/95 =====
774
775- Fixed too tight command queueing after tape stop/pause command
776 issued from within interrupt service routine (Showed as timeout
777 on Acknowledge errors during retries on some systems)
778- Tried to fix timeouts when using 425 ft tape because the extended
779 length doesn't seem to be detected by the hardware.
780 We now use the format code from the header segment so adjust the
781 timing after reading the header segment.
782- Fixed some messages stating 'unexpected something...' being not
783 unexpected anymore.
784- Started preparations for merge of dynamic buffer allocation and
785 compression code.
786- Changed some debug messages to include relevant segment information
787 at level 4.
788- Included early bail-out when drive offline, preventing a lot of
789 false messages.
790- Moved ftape_parameter_xxx() offsets into function instead of in calls.
791- Removed 'weird, drive busy but no data' error when caused by
792 an error during a read-id.
793- Improved 'timeout on acknowledge' diagnostics.
794- Moved MODULE option into Configure.
795- Reduced code size when no tracing at all was set (Claus Heine).
796- No longer log error code 0 (no error) as an error.
797
798
799===== Release notes for ftape-2.02b, 09/04/95 =====
800
801- Relaxed timing for status operation and displaying
802 abnormal results. Hopefully this shows what's going
803 wrong with the Conner TSM850R drives.
804- Created script for configuration, using version number
805 of kernel source if available, otherwise /proc/version.
806- Fixed conditionals in kernel-interface.c.
807- Removed unavoidable TRACE output.
808
809
810===== Release notes for ftape-2.02a, 01/04/95 =====
811
812- Implemented `new-style' (versioned) modules support for new
813 kernels.
814- Reduced size of module by moving static data to bss.
815- Now using version number of kernel source instead of running
816 kernel for kernel versions >= 1.1.82
817- Added feedback on drive speeds to vendor information.
818- Included fixed insmod sources to distribution (Let's hope
819 the modules distribution get fixed soon :-/).
820
821Note that I haven't yet implemented any of the code extension I
822received. I hope to find some time to do this soon.
823
824
825===== Release notes for ftape-2.02, 15/01/95 =====
826
827
828- Fixed failing repositioning when overshoot was incremented.
829- Fixed rate selection: Because of a deficiency in the QIC-117
830 specification one cannot distinguish between a not implemented
831 and a failing command. Therefor we now try to find out if the
832 drive does support this command before usage.
833- Fixed error retry using wrong offset in fdc-isr.
834- Improved retry code to retry only once on a single no-data
835 error in a segment.
836- Validate sector number extracted from eof mark because an
837 invalid file mark (due to ???) could cause kernel panic.
838- Split ftape-io.c into ftape-io.c and ftape-ctl.c files.
839- Corrected too high media error count after writing to
840 a bad tape.
841- Added #include <asm/segment.h> again because old kernel versions
842 need it.
843- Fixed fdc not being disabled when open failed because no tape
844 drive was found.
845- Fixed problem with soft error in sector 32 (shift operator with
846 shiftcount 32 is not defined).
847
848
849===== Release notes for ftape-2.01, 08/01/95 =====
850
851
852- Removed TESTING setting from distributed Makefile.
853- Fixed `mt asf' failure: Rewind was deferred to close which
854 overruled the fsf ioctl.
855- Prevented non-interruptible commands being interrupted.
856- Added missing timeout.pause setting.
857- Maximum tape speed read from drive type information table.
858 If the information is not in the table (0) the drive will
859 determine the speed itself and put a message in the logfile.
860 This information should then be added to the table in the
861 vendors.h file (and reported to me).
862- Added call to ftape_init_drive after soft reset for those
863 (antique) drives that don't do an implicit seek_load_point
864 after a reset or power up.
865- Don't try to set data rate if reset failed.
866- Prevent update of seek variables when starting from the
867 beginning or the end of the tape.
868- Fixed wrong adjustment of overshoot in seek_forward().
869- Added sync to Makefile (again).
870- Added code to diagnose timer problems (calibr.c).
871- Replaced time differences by timediff calls.
872- Removed reference to do_floppy from object for recent kernels.
873- Fixed wrong display of 'failing dma controller' message.
874- Removed various no longer used #include statements.
875- Added max. tape speed value to vendor-struct.
876- Changed ftape-command to check pre-conditions and wait
877 if needed.
878- Further updated qic117.h to rev G.
879- Combined command name table and restrictions table to one.
880 Extended this table with some new fields.
881- Increased timeout on Ack timer value and included code to
882 report out of spec behaviour.
883- Increased rewind timeout margin to calculated + 20%.
884- Improved data rate selection so it won't fail on some
885 older (pre standard) drives.
886- Changed initialisation code so drive will be rewound if the
887 driver is reloaded and the tape is not at bot.
888- Moved some of the flush operations from close to the ioctls.
889- Added exit code value to failing verify area message.
890- Loop until tape halted in smart-stop.
891- Fast seek handled specially if located at bot or eot.
892- Being more conservative on overshoot value.
893
894
895===== Release notes for ftape-2.00, 31/12/94 =====
896
897 The Install-guide is completely rewritten and now also includes
898some information on how to use the driver. If you're either new
899to ftape or new to Unix tape devices make sure to read it !
900
901 If you own a pci system and experience problems with the
902ftape driver make sure to read the README.PCI file. It contains
903some hints on how to fix your hardware.
904
905 For anybody who hasn't noticed: The version number of the
906driver has been incremented (The latest released version has
907been version 1.14d).
908 This has been done for two major reasons:
909
910 o A new (better) error recovery scheme is implemented.
911 o Support for new drive types has been added.
912
913 All these improvements/changes will probably include a couple
914of new (and old?) bugs. If you encounter any problems that you think
915I'm not yet aware of, feel free to send a report to <bas@vimec.nl>.
916 I recommend keeping a version of ftape-1.14d available, just
917in case ;-)
918
919 This version should work with all kernel versions from 1.0.9 up
920to 1.1.72 (and probably earlier and later versions too).
921
922
923Major new features:
924
925- Better handling of tapes with defects: When a sector repeatedly
926 (SOFT_RETRIES in ftape.h) cannot be written to or read from it is
927 marked as an hard error and gets skipped.
928 The error correction code can handle up to three of these hard
929 errors provided there are no other errors in that segment (32 Kb).
930
931- Allows writing to tapes with defects (although the risk of loosing
932 data increases !)
933 Look for the media-defects entry printed with the statistics when
934 the tape is closed. A non-zero value here shows a bad tape.
935 [the actual count is wrong (too high), this is a known bug].
936
937- Use of backup header segment if first one is failing.
938
939- Support for extended length tapes with QIC-80: both 425 and 1100 ft.
940 0.25 inch tapes are now recognized and handled.
941
942- Support for new QIC-80 drives with 8 mm `wide' tapes (e.g. Conner
943 TSM 420).
944
945- Support for new QIC-3010 and QIC-3020 drives (experimental) with
946 both 0.25 inch and 8 mm tapes.
947
948Some minor features were added, a couple of small bugs were fixed and
949probably some new ones introduced ;-).
950
951[lseek() didn't make it into this version]
952
953Have fun,
954
955Bas.
956----
957 LocalWords: ftape MCONFIG mt VFS zftape resp sftape proc subdir MTIOCVOLINFO
958 LocalWords: MTIOCGETSIZE BOT EOD MTBSF zft kerneld modprobe kdtime contrib TR
959 LocalWords: MTSETBLK afio uninstall texi www EIO QIC init sft eof aka dma GB
960 LocalWords: SIGKILL MTIOCFTCMD mmap Iomega FDC fdc io gnumt mtio fc asm inb
961 LocalWords: outb ft qic frontend TeXinfo irq mach MODVERSIONS CONFIG html dvi
962 LocalWords: usr doc SMP Mb Dunno FIXME vtblc perl listtape volinfo fsf MTWEOF
963 LocalWords: amanda degaussed ComByte DoublePlay whraven njackn com MTIOC vtbl
964 LocalWords: GETBLKSZ MAKEDEV zftape's linux dif CVS Revison cp MTREW MTOFFL
965 LocalWords: MTFSF BSF Marcin Dalecki GCC Config cpio swapout Kai Harrekilde
966 LocalWords: Pederson khp dolphinics Justus claus momo rwth aachen Laarhoven
diff --git a/drivers/char/ftape/compressor/Makefile b/drivers/char/ftape/compressor/Makefile
deleted file mode 100644
index 1fbd6c4019db..000000000000
--- a/drivers/char/ftape/compressor/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
1#
2# Copyright (C) 1997 Claus-Justus Heine.
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 as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to
16# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17#
18# $Source: /homes/cvs/ftape-stacked/ftape/compressor/Makefile,v $
19# $Revision: 1.1 $
20# $Date: 1997/10/05 19:12:28 $
21#
22# Makefile for the optional compressor for th zftape VFS
23# interface to the QIC-40/80/3010/3020 floppy-tape driver for
24# Linux.
25#
26
27obj-$(CONFIG_ZFT_COMPRESSOR) += zft-compressor.o
28
29zft-compressor-objs := zftape-compress.o lzrw3.o
30
31CFLAGS_lzrw3.o := -O6 -funroll-all-loops
diff --git a/drivers/char/ftape/compressor/lzrw3.c b/drivers/char/ftape/compressor/lzrw3.c
deleted file mode 100644
index a032a0ee2a99..000000000000
--- a/drivers/char/ftape/compressor/lzrw3.c
+++ /dev/null
@@ -1,743 +0,0 @@
1/*
2 * $Source: /homes/cvs/ftape-stacked/ftape/compressor/lzrw3.c,v $
3 * $Revision: 1.1 $
4 * $Date: 1997/10/05 19:12:29 $
5 *
6 * Implementation of Ross Williams lzrw3 algorithm. Adaption for zftape.
7 *
8 */
9
10#include "../compressor/lzrw3.h" /* Defines single exported function "compress". */
11
12/******************************************************************************/
13/* */
14/* LZRW3.C */
15/* */
16/******************************************************************************/
17/* */
18/* Author : Ross Williams. */
19/* Date : 30-Jun-1991. */
20/* Release : 1. */
21/* */
22/******************************************************************************/
23/* */
24/* This file contains an implementation of the LZRW3 data compression */
25/* algorithm in C. */
26/* */
27/* The algorithm is a general purpose compression algorithm that runs fast */
28/* and gives reasonable compression. The algorithm is a member of the Lempel */
29/* Ziv family of algorithms and bases its compression on the presence in the */
30/* data of repeated substrings. */
31/* */
32/* This algorithm is unpatented and the code is public domain. As the */
33/* algorithm is based on the LZ77 class of algorithms, it is unlikely to be */
34/* the subject of a patent challenge. */
35/* */
36/* Unlike the LZRW1 and LZRW1-A algorithms, the LZRW3 algorithm is */
37/* deterministic and is guaranteed to yield the same compressed */
38/* representation for a given file each time it is run. */
39/* */
40/* The LZRW3 algorithm was originally designed and implemented */
41/* by Ross Williams on 31-Dec-1990. */
42/* */
43/* Here are the results of applying this code, compiled under THINK C 4.0 */
44/* and running on a Mac-SE (8MHz 68000), to the standard calgary corpus. */
45/* */
46/* +----------------------------------------------------------------+ */
47/* | DATA COMPRESSION TEST | */
48/* | ===================== | */
49/* | Time of run : Sun 30-Jun-1991 09:31PM | */
50/* | Timing accuracy : One part in 100 | */
51/* | Context length : 262144 bytes (= 256.0000K) | */
52/* | Test suite : Calgary Corpus Suite | */
53/* | Files in suite : 14 | */
54/* | Algorithm : LZRW3 | */
55/* | Note: All averages are calculated from the un-rounded values. | */
56/* +----------------------------------------------------------------+ */
57/* | File Name Length CxB ComLen %Remn Bits Com K/s Dec K/s | */
58/* | ---------- ------ --- ------ ----- ---- ------- ------- | */
59/* | rpus:Bib.D 111261 1 55033 49.5 3.96 19.46 32.27 | */
60/* | us:Book1.D 768771 3 467962 60.9 4.87 17.03 31.07 | */
61/* | us:Book2.D 610856 3 317102 51.9 4.15 19.39 34.15 | */
62/* | rpus:Geo.D 102400 1 82424 80.5 6.44 11.65 18.18 | */
63/* | pus:News.D 377109 2 205670 54.5 4.36 17.14 27.47 | */
64/* | pus:Obj1.D 21504 1 13027 60.6 4.85 13.40 18.95 | */
65/* | pus:Obj2.D 246814 1 116286 47.1 3.77 19.31 30.10 | */
66/* | s:Paper1.D 53161 1 27522 51.8 4.14 18.60 31.15 | */
67/* | s:Paper2.D 82199 1 45160 54.9 4.40 18.45 32.84 | */
68/* | rpus:Pic.D 513216 2 122388 23.8 1.91 35.29 51.05 | */
69/* | us:Progc.D 39611 1 19669 49.7 3.97 18.87 30.64 | */
70/* | us:Progl.D 71646 1 28247 39.4 3.15 24.34 40.66 | */
71/* | us:Progp.D 49379 1 19377 39.2 3.14 23.91 39.23 | */
72/* | us:Trans.D 93695 1 33481 35.7 2.86 25.48 40.37 | */
73/* +----------------------------------------------------------------+ */
74/* | Average 224401 1 110953 50.0 4.00 20.17 32.72 | */
75/* +----------------------------------------------------------------+ */
76/* */
77/******************************************************************************/
78
79/******************************************************************************/
80
81/* The following structure is returned by the "compress" function below when */
82/* the user asks the function to return identifying information. */
83/* The most important field in the record is the working memory field which */
84/* tells the calling program how much working memory should be passed to */
85/* "compress" when it is called to perform a compression or decompression. */
86/* LZRW3 uses the same amount of memory during compression and decompression. */
87/* For more information on this structure see "compress.h". */
88
89#define U(X) ((ULONG) X)
90#define SIZE_P_BYTE (U(sizeof(UBYTE *)))
91#define SIZE_WORD (U(sizeof(UWORD )))
92#define ALIGNMENT_FUDGE (U(16))
93#define MEM_REQ ( U(4096)*(SIZE_P_BYTE) + ALIGNMENT_FUDGE )
94
95static struct compress_identity identity =
96{
97 U(0x032DDEA8), /* Algorithm identification number. */
98 MEM_REQ, /* Working memory (bytes) required. */
99 "LZRW3", /* Name of algorithm. */
100 "1.0", /* Version number of algorithm. */
101 "31-Dec-1990", /* Date of algorithm. */
102 "Public Domain", /* Copyright notice. */
103 "Ross N. Williams", /* Author of algorithm. */
104 "Renaissance Software", /* Affiliation of author. */
105 "Public Domain" /* Vendor of algorithm. */
106};
107
108LOCAL void compress_compress (UBYTE *,UBYTE *,ULONG,UBYTE *, LONG *);
109LOCAL void compress_decompress(UBYTE *,UBYTE *,LONG, UBYTE *, ULONG *);
110
111/******************************************************************************/
112
113/* This function is the only function exported by this module. */
114/* Depending on its first parameter, the function can be requested to */
115/* compress a block of memory, decompress a block of memory, or to identify */
116/* itself. For more information, see the specification file "compress.h". */
117
118EXPORT void lzrw3_compress(
119 UWORD action, /* Action to be performed. */
120 UBYTE *wrk_mem, /* Address of working memory we can use.*/
121 UBYTE *src_adr, /* Address of input data. */
122 LONG src_len, /* Length of input data. */
123 UBYTE *dst_adr, /* Address to put output data. */
124 void *p_dst_len /* Address of longword for length of output data.*/
125)
126{
127 switch (action)
128 {
129 case COMPRESS_ACTION_IDENTITY:
130 *((struct compress_identity **)p_dst_len)= &identity;
131 break;
132 case COMPRESS_ACTION_COMPRESS:
133 compress_compress(wrk_mem,src_adr,src_len,dst_adr,(LONG *)p_dst_len);
134 break;
135 case COMPRESS_ACTION_DECOMPRESS:
136 compress_decompress(wrk_mem,src_adr,src_len,dst_adr,(LONG *)p_dst_len);
137 break;
138 }
139}
140
141/******************************************************************************/
142/* */
143/* BRIEF DESCRIPTION OF THE LZRW3 ALGORITHM */
144/* ======================================== */
145/* The LZRW3 algorithm is identical to the LZRW1-A algorithm except that */
146/* instead of transmitting history offsets, it transmits hash table indexes. */
147/* In order to decode the indexes, the decompressor must maintain an */
148/* identical hash table. Copy items are straightforward:when the decompressor */
149/* receives a copy item, it simply looks up the hash table to translate the */
150/* index into a pointer into the data already decompressed. To update the */
151/* hash table, it replaces the same table entry with a pointer to the start */
152/* of the newly decoded phrase. The tricky part is with literal items, for at */
153/* the time that the decompressor receives a literal item the decompressor */
154/* does not have the three bytes in the Ziv (that the compressor has) to */
155/* perform the three-byte hash. To solve this problem, in LZRW3, both the */
156/* compressor and decompressor are wired up so that they "buffer" these */
157/* literals and update their hash tables only when three bytes are available. */
158/* This makes the maximum buffering 2 bytes. */
159/* */
160/* Replacement of offsets by hash table indexes yields a few percent extra */
161/* compression at the cost of some speed. LZRW3 is slower than LZRW1, LZRW1-A */
162/* and LZRW2, but yields better compression. */
163/* */
164/* Extra compression could be obtained by using a hash table of depth two. */
165/* However, increasing the depth above one incurs a significant decrease in */
166/* compression speed which was not considered worthwhile. Another reason for */
167/* keeping the depth down to one was to allow easy comparison with the */
168/* LZRW1-A and LZRW2 algorithms so as to demonstrate the exact effect of the */
169/* use of direct hash indexes. */
170/* */
171/* +---+ */
172/* |___|4095 */
173/* |___| */
174/* +---------------------*_|<---+ /----+---\ */
175/* | |___| +---|Hash | */
176/* | |___| |Function| */
177/* | |___| \--------/ */
178/* | |___|0 ^ */
179/* | +---+ | */
180/* | Hash +-----+ */
181/* | Table | */
182/* | --- */
183/* v ^^^ */
184/* +-------------------------------------|----------------+ */
185/* |||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
186/* +-------------------------------------|----------------+ */
187/* | |1......18| | */
188/* |<------- Lempel=History ------------>|<--Ziv-->| | */
189/* | (=bytes already processed) |<-Still to go-->| */
190/* |<-------------------- INPUT BLOCK ------------------->| */
191/* */
192/* The diagram above for LZRW3 looks almost identical to the diagram for */
193/* LZRW1. The difference is that in LZRW3, the compressor transmits hash */
194/* table indices instead of Lempel offsets. For this to work, the */
195/* decompressor must maintain a hash table as well as the compressor and both */
196/* compressor and decompressor must "buffer" literals, as the decompressor */
197/* cannot hash phrases commencing with a literal until another two bytes have */
198/* arrived. */
199/* */
200/* LZRW3 Algorithm Execution Summary */
201/* --------------------------------- */
202/* 1. Hash the first three bytes of the Ziv to yield a hash table index h. */
203/* 2. Look up the hash table yielding history pointer p. */
204/* 3. Match where p points with the Ziv. If there is a match of three or */
205/* more bytes, code those bytes (in the Ziv) as a copy item, otherwise */
206/* code the next byte in the Ziv as a literal item. */
207/* 4. Update the hash table as possible subject to the constraint that only */
208/* phrases commencing three bytes back from the Ziv can be hashed and */
209/* entered into the hash table. (This enables the decompressor to keep */
210/* pace). See the description and code for more details. */
211/* */
212/******************************************************************************/
213/* */
214/* DEFINITION OF COMPRESSED FILE FORMAT */
215/* ==================================== */
216/* * A compressed file consists of a COPY FLAG followed by a REMAINDER. */
217/* * The copy flag CF uses up four bytes with the first byte being the */
218/* least significant. */
219/* * If CF=1, then the compressed file represents the remainder of the file */
220/* exactly. Otherwise CF=0 and the remainder of the file consists of zero */
221/* or more GROUPS, each of which represents one or more bytes. */
222/* * Each group consists of two bytes of CONTROL information followed by */
223/* sixteen ITEMs except for the last group which can contain from one */
224/* to sixteen items. */
225/* * An item can be either a LITERAL item or a COPY item. */
226/* * Each item corresponds to a bit in the control bytes. */
227/* * The first control byte corresponds to the first 8 items in the group */
228/* with bit 0 corresponding to the first item in the group and bit 7 to */
229/* the eighth item in the group. */
230/* * The second control byte corresponds to the second 8 items in the group */
231/* with bit 0 corresponding to the ninth item in the group and bit 7 to */
232/* the sixteenth item in the group. */
233/* * A zero bit in a control word means that the corresponding item is a */
234/* literal item. A one bit corresponds to a copy item. */
235/* * A literal item consists of a single byte which represents itself. */
236/* * A copy item consists of two bytes that represent from 3 to 18 bytes. */
237/* * The first byte in a copy item will be denoted C1. */
238/* * The second byte in a copy item will be denoted C2. */
239/* * Bits will be selected using square brackets. */
240/* For example: C1[0..3] is the low nibble of the first control byte. */
241/* of copy item C1. */
242/* * The LENGTH of a copy item is defined to be C1[0..3]+3 which is a number */
243/* in the range [3,18]. */
244/* * The INDEX of a copy item is defined to be C1[4..7]*256+C2[0..8] which */
245/* is a number in the range [0,4095]. */
246/* * A copy item represents the sequence of bytes */
247/* text[POS-OFFSET..POS-OFFSET+LENGTH-1] where */
248/* text is the entire text of the uncompressed string. */
249/* POS is the index in the text of the character following the */
250/* string represented by all the items preceeding the item */
251/* being defined. */
252/* OFFSET is obtained from INDEX by looking up the hash table. */
253/* */
254/******************************************************************************/
255
256/* The following #define defines the length of the copy flag that appears at */
257/* the start of the compressed file. The value of four bytes was chosen */
258/* because the fast_copy routine on my Macintosh runs faster if the source */
259/* and destination blocks are relatively longword aligned. */
260/* The actual flag data appears in the first byte. The rest are zeroed so as */
261/* to normalize the compressed representation (i.e. not non-deterministic). */
262#define FLAG_BYTES 4
263
264/* The following #defines define the meaning of the values of the copy */
265/* flag at the start of the compressed file. */
266#define FLAG_COMPRESS 0 /* Signals that output was result of compression. */
267#define FLAG_COPY 1 /* Signals that output was simply copied over. */
268
269/* The 68000 microprocessor (on which this algorithm was originally developed */
270/* is fussy about non-aligned arrays of words. To avoid these problems the */
271/* following macro can be used to "waste" from 0 to 3 bytes so as to align */
272/* the argument pointer. */
273#define ULONG_ALIGN_UP(X) ((((ULONG)X)+sizeof(ULONG)-1)&~(sizeof(ULONG)-1))
274
275
276/* The following constant defines the maximum length of an uncompressed item. */
277/* This definition must not be changed; its value is hardwired into the code. */
278/* The longest number of bytes that can be spanned by a single item is 18 */
279/* for the longest copy item. */
280#define MAX_RAW_ITEM (18)
281
282/* The following constant defines the maximum length of an uncompressed group.*/
283/* This definition must not be changed; its value is hardwired into the code. */
284/* A group contains at most 16 items which explains this definition. */
285#define MAX_RAW_GROUP (16*MAX_RAW_ITEM)
286
287/* The following constant defines the maximum length of a compressed group. */
288/* This definition must not be changed; its value is hardwired into the code. */
289/* A compressed group consists of two control bytes followed by up to 16 */
290/* compressed items each of which can have a maximum length of two bytes. */
291#define MAX_CMP_GROUP (2+16*2)
292
293/* The following constant defines the number of entries in the hash table. */
294/* This definition must not be changed; its value is hardwired into the code. */
295#define HASH_TABLE_LENGTH (4096)
296
297/* LZRW3, unlike LZRW1(-A), must initialize its hash table so as to enable */
298/* the compressor and decompressor to stay in step maintaining identical hash */
299/* tables. In an early version of the algorithm, the tables were simply */
300/* initialized to zero and a check for zero was included just before the */
301/* matching code. However, this test costs time. A better solution is to */
302/* initialize all the entries in the hash table to point to a constant */
303/* string. The decompressor does the same. This solution requires no extra */
304/* test. The contents of the string do not matter so long as the string is */
305/* the same for the compressor and decompressor and contains at least */
306/* MAX_RAW_ITEM bytes. I chose consecutive decimal digits because they do not */
307/* have white space problems (e.g. there is no chance that the compiler will */
308/* replace more than one space by a TAB) and because they make the length of */
309/* the string obvious by inspection. */
310#define START_STRING_18 ((UBYTE *) "123456789012345678")
311
312/* In this algorithm, hash values have to be calculated at more than one */
313/* point. The following macro neatens the code up for this. */
314#define HASH(PTR) \
315 (((40543*(((*(PTR))<<8)^((*((PTR)+1))<<4)^(*((PTR)+2))))>>4) & 0xFFF)
316
317/******************************************************************************/
318
319/* Input : Hand over the required amount of working memory in p_wrk_mem. */
320/* Input : Specify input block using p_src_first and src_len. */
321/* Input : Point p_dst_first to the start of the output zone (OZ). */
322/* Input : Point p_dst_len to a ULONG to receive the output length. */
323/* Input : Input block and output zone must not overlap. */
324/* Output : Length of output block written to *p_dst_len. */
325/* Output : Output block in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. May */
326/* Output : write in OZ=Mem[p_dst_first..p_dst_first+src_len+MAX_CMP_GROUP-1].*/
327/* Output : Upon completion guaranteed *p_dst_len<=src_len+FLAG_BYTES. */
328LOCAL void compress_compress(UBYTE *p_wrk_mem,
329 UBYTE *p_src_first, ULONG src_len,
330 UBYTE *p_dst_first, LONG *p_dst_len)
331{
332 /* p_src and p_dst step through the source and destination blocks. */
333 register UBYTE *p_src = p_src_first;
334 register UBYTE *p_dst = p_dst_first;
335
336 /* The following variables are never modified and are used in the */
337 /* calculations that determine when the main loop terminates. */
338 UBYTE *p_src_post = p_src_first+src_len;
339 UBYTE *p_dst_post = p_dst_first+src_len;
340 UBYTE *p_src_max1 = p_src_first+src_len-MAX_RAW_ITEM;
341 UBYTE *p_src_max16 = p_src_first+src_len-MAX_RAW_ITEM*16;
342
343 /* The variables 'p_control' and 'control' are used to buffer control bits. */
344 /* Before each group is processed, the next two bytes of the output block */
345 /* are set aside for the control word for the group about to be processed. */
346 /* 'p_control' is set to point to the first byte of that word. Meanwhile, */
347 /* 'control' buffers the control bits being generated during the processing */
348 /* of the group. Instead of having a counter to keep track of how many items */
349 /* have been processed (=the number of bits in the control word), at the */
350 /* start of each group, the top word of 'control' is filled with 1 bits. */
351 /* As 'control' is shifted for each item, the 1 bits in the top word are */
352 /* absorbed or destroyed. When they all run out (i.e. when the top word is */
353 /* all zero bits, we know that we are at the end of a group. */
354# define TOPWORD 0xFFFF0000
355 UBYTE *p_control;
356 register ULONG control=TOPWORD;
357
358 /* THe variable 'hash' always points to the first element of the hash table. */
359 UBYTE **hash= (UBYTE **) ULONG_ALIGN_UP(p_wrk_mem);
360
361 /* The following two variables represent the literal buffer. p_h1 points to */
362 /* the hash table entry corresponding to the youngest literal. p_h2 points */
363 /* to the hash table entry corresponding to the second youngest literal. */
364 /* Note: p_h1=0=>p_h2=0 because zero values denote absence of a pending */
365 /* literal. The variables are initialized to zero meaning an empty "buffer". */
366 UBYTE **p_h1=NULL;
367 UBYTE **p_h2=NULL;
368
369 /* To start, we write the flag bytes. Being optimistic, we set the flag to */
370 /* FLAG_COMPRESS. The remaining flag bytes are zeroed so as to keep the */
371 /* algorithm deterministic. */
372 *p_dst++=FLAG_COMPRESS;
373 {UWORD i; for (i=2;i<=FLAG_BYTES;i++) *p_dst++=0;}
374
375 /* Reserve the first word of output as the control word for the first group. */
376 /* Note: This is undone at the end if the input block is empty. */
377 p_control=p_dst; p_dst+=2;
378
379 /* Initialize all elements of the hash table to point to a constant string. */
380 /* Use of an unrolled loop speeds this up considerably. */
381 {UWORD i; UBYTE **p_h=hash;
382# define ZH *p_h++=START_STRING_18
383 for (i=0;i<256;i++) /* 256=HASH_TABLE_LENGTH/16. */
384 {ZH;ZH;ZH;ZH;
385 ZH;ZH;ZH;ZH;
386 ZH;ZH;ZH;ZH;
387 ZH;ZH;ZH;ZH;}
388 }
389
390 /* The main loop processes either 1 or 16 items per iteration. As its */
391 /* termination logic is complicated, I have opted for an infinite loop */
392 /* structure containing 'break' and 'goto' statements. */
393 while (TRUE)
394 {/* Begin main processing loop. */
395
396 /* Note: All the variables here except unroll should be defined within */
397 /* the inner loop. Unfortunately the loop hasn't got a block. */
398 register UBYTE *p; /* Scans through targ phrase during matching. */
399 register UBYTE *p_ziv= NULL ; /* Points to first byte of current Ziv. */
400 register UWORD unroll; /* Loop counter for unrolled inner loop. */
401 register UWORD index; /* Index of current hash table entry. */
402 register UBYTE **p_h0 = NULL ; /* Pointer to current hash table entry. */
403
404 /* Test for overrun and jump to overrun code if necessary. */
405 if (p_dst>p_dst_post)
406 goto overrun;
407
408 /* The following cascade of if statements efficiently catches and deals */
409 /* with varying degrees of closeness to the end of the input block. */
410 /* When we get very close to the end, we stop updating the table and */
411 /* code the remaining bytes as literals. This makes the code simpler. */
412 unroll=16;
413 if (p_src>p_src_max16)
414 {
415 unroll=1;
416 if (p_src>p_src_max1)
417 {
418 if (p_src==p_src_post)
419 break;
420 else
421 goto literal;
422 }
423 }
424
425 /* This inner unrolled loop processes 'unroll' (whose value is either 1 */
426 /* or 16) items. I have chosen to implement this loop with labels and */
427 /* gotos to heighten the ease with which the loop may be implemented with */
428 /* a single decrement and branch instruction in assembly language and */
429 /* also because the labels act as highly readable place markers. */
430 /* (Also because we jump into the loop for endgame literals (see above)). */
431
432 begin_unrolled_loop:
433
434 /* To process the next phrase, we hash the next three bytes and use */
435 /* the resultant hash table index to look up the hash table. A pointer */
436 /* to the entry is stored in p_h0 so as to avoid an array lookup. The */
437 /* hash table entry *p_h0 is looked up yielding a pointer p to a */
438 /* potential match of the Ziv in the history. */
439 index=HASH(p_src);
440 p_h0=&hash[index];
441 p=*p_h0;
442
443 /* Having looked up the candidate position, we are in a position to */
444 /* attempt a match. The match loop has been unrolled using the PS */
445 /* macro so that failure within the first three bytes automatically */
446 /* results in the literal branch being taken. The coding is simple. */
447 /* p_ziv saves p_src so we can let p_src wander. */
448# define PS *p++!=*p_src++
449 p_ziv=p_src;
450 if (PS || PS || PS)
451 {
452 /* Literal. */
453
454 /* Code the literal byte as itself and a zero control bit. */
455 p_src=p_ziv; literal: *p_dst++=*p_src++; control&=0xFFFEFFFF;
456
457 /* We have just coded a literal. If we had two pending ones, that */
458 /* makes three and we can update the hash table. */
459 if (p_h2!=0)
460 {*p_h2=p_ziv-2;}
461
462 /* In any case, rotate the hash table pointers for next time. */
463 p_h2=p_h1; p_h1=p_h0;
464
465 }
466 else
467 {
468 /* Copy */
469
470 /* Match up to 15 remaining bytes using an unrolled loop and code. */
471#if 0
472 PS || PS || PS || PS || PS || PS || PS || PS ||
473 PS || PS || PS || PS || PS || PS || PS || p_src++;
474#else
475 if (
476 !( PS || PS || PS || PS || PS || PS || PS || PS ||
477 PS || PS || PS || PS || PS || PS || PS )
478 ) p_src++;
479#endif
480 *p_dst++=((index&0xF00)>>4)|(--p_src-p_ziv-3);
481 *p_dst++=index&0xFF;
482
483 /* As we have just coded three bytes, we are now in a position to */
484 /* update the hash table with the literal bytes that were pending */
485 /* upon the arrival of extra context bytes. */
486 if (p_h1!=0)
487 {
488 if (p_h2)
489 {*p_h2=p_ziv-2; p_h2=NULL;}
490 *p_h1=p_ziv-1; p_h1=NULL;
491 }
492
493 /* In any case, we can update the hash table based on the current */
494 /* position as we just coded at least three bytes in a copy items. */
495 *p_h0=p_ziv;
496
497 }
498 control>>=1;
499
500 /* This loop is all set up for a decrement and jump instruction! */
501#ifndef linux
502` end_unrolled_loop: if (--unroll) goto begin_unrolled_loop;
503#else
504 /* end_unrolled_loop: */ if (--unroll) goto begin_unrolled_loop;
505#endif
506
507 /* At this point it will nearly always be the end of a group in which */
508 /* case, we have to do some control-word processing. However, near the */
509 /* end of the input block, the inner unrolled loop is only executed once. */
510 /* This necessitates the 'if' test. */
511 if ((control&TOPWORD)==0)
512 {
513 /* Write the control word to the place we saved for it in the output. */
514 *p_control++= control &0xFF;
515 *p_control = (control>>8) &0xFF;
516
517 /* Reserve the next word in the output block for the control word */
518 /* for the group about to be processed. */
519 p_control=p_dst; p_dst+=2;
520
521 /* Reset the control bits buffer. */
522 control=TOPWORD;
523 }
524
525 } /* End main processing loop. */
526
527 /* After the main processing loop has executed, all the input bytes have */
528 /* been processed. However, the control word has still to be written to the */
529 /* word reserved for it in the output at the start of the most recent group. */
530 /* Before writing, the control word has to be shifted so that all the bits */
531 /* are in the right place. The "empty" bit positions are filled with 1s */
532 /* which partially fill the top word. */
533 while(control&TOPWORD) control>>=1;
534 *p_control++= control &0xFF;
535 *p_control++=(control>>8) &0xFF;
536
537 /* If the last group contained no items, delete the control word too. */
538 if (p_control==p_dst) p_dst-=2;
539
540 /* Write the length of the output block to the dst_len parameter and return. */
541 *p_dst_len=p_dst-p_dst_first;
542 return;
543
544 /* Jump here as soon as an overrun is detected. An overrun is defined to */
545 /* have occurred if p_dst>p_dst_first+src_len. That is, the moment the */
546 /* length of the output written so far exceeds the length of the input block.*/
547 /* The algorithm checks for overruns at least at the end of each group */
548 /* which means that the maximum overrun is MAX_CMP_GROUP bytes. */
549 /* Once an overrun occurs, the only thing to do is to set the copy flag and */
550 /* copy the input over. */
551 overrun:
552#if 0
553 *p_dst_first=FLAG_COPY;
554 fast_copy(p_src_first,p_dst_first+FLAG_BYTES,src_len);
555 *p_dst_len=src_len+FLAG_BYTES;
556#else
557 fast_copy(p_src_first,p_dst_first,src_len);
558 *p_dst_len= -src_len; /* return a negative number to indicate uncompressed data */
559#endif
560}
561
562/******************************************************************************/
563
564/* Input : Hand over the required amount of working memory in p_wrk_mem. */
565/* Input : Specify input block using p_src_first and src_len. */
566/* Input : Point p_dst_first to the start of the output zone. */
567/* Input : Point p_dst_len to a ULONG to receive the output length. */
568/* Input : Input block and output zone must not overlap. User knows */
569/* Input : upperbound on output block length from earlier compression. */
570/* Input : In any case, maximum expansion possible is nine times. */
571/* Output : Length of output block written to *p_dst_len. */
572/* Output : Output block in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */
573/* Output : Writes only in Mem[p_dst_first..p_dst_first+*p_dst_len-1]. */
574LOCAL void compress_decompress( UBYTE *p_wrk_mem,
575 UBYTE *p_src_first, LONG src_len,
576 UBYTE *p_dst_first, ULONG *p_dst_len)
577{
578 /* Byte pointers p_src and p_dst scan through the input and output blocks. */
579 register UBYTE *p_src = p_src_first+FLAG_BYTES;
580 register UBYTE *p_dst = p_dst_first;
581 /* we need to avoid a SEGV when trying to uncompress corrupt data */
582 register UBYTE *p_dst_post = p_dst_first + *p_dst_len;
583
584 /* The following two variables are never modified and are used to control */
585 /* the main loop. */
586 UBYTE *p_src_post = p_src_first+src_len;
587 UBYTE *p_src_max16 = p_src_first+src_len-(MAX_CMP_GROUP-2);
588
589 /* The hash table is the only resident of the working memory. The hash table */
590 /* contains HASH_TABLE_LENGTH=4096 pointers to positions in the history. To */
591 /* keep Macintoshes happy, it is longword aligned. */
592 UBYTE **hash = (UBYTE **) ULONG_ALIGN_UP(p_wrk_mem);
593
594 /* The variable 'control' is used to buffer the control bits which appear in */
595 /* groups of 16 bits (control words) at the start of each compressed group. */
596 /* When each group is read, bit 16 of the register is set to one. Whenever */
597 /* a new bit is needed, the register is shifted right. When the value of the */
598 /* register becomes 1, we know that we have reached the end of a group. */
599 /* Initializing the register to 1 thus instructs the code to follow that it */
600 /* should read a new control word immediately. */
601 register ULONG control=1;
602
603 /* The value of 'literals' is always in the range 0..3. It is the number of */
604 /* consecutive literal items just seen. We have to record this number so as */
605 /* to know when to update the hash table. When literals gets to 3, there */
606 /* have been three consecutive literals and we can update at the position of */
607 /* the oldest of the three. */
608 register UWORD literals=0;
609
610 /* Check the leading copy flag to see if the compressor chose to use a copy */
611 /* operation instead of a compression operation. If a copy operation was */
612 /* used, then all we need to do is copy the data over, set the output length */
613 /* and return. */
614#if 0
615 if (*p_src_first==FLAG_COPY)
616 {
617 fast_copy(p_src_first+FLAG_BYTES,p_dst_first,src_len-FLAG_BYTES);
618 *p_dst_len=src_len-FLAG_BYTES;
619 return;
620 }
621#else
622 if ( src_len < 0 )
623 {
624 fast_copy(p_src_first,p_dst_first,-src_len );
625 *p_dst_len = (ULONG)-src_len;
626 return;
627 }
628#endif
629
630 /* Initialize all elements of the hash table to point to a constant string. */
631 /* Use of an unrolled loop speeds this up considerably. */
632 {UWORD i; UBYTE **p_h=hash;
633# define ZJ *p_h++=START_STRING_18
634 for (i=0;i<256;i++) /* 256=HASH_TABLE_LENGTH/16. */
635 {ZJ;ZJ;ZJ;ZJ;
636 ZJ;ZJ;ZJ;ZJ;
637 ZJ;ZJ;ZJ;ZJ;
638 ZJ;ZJ;ZJ;ZJ;}
639 }
640
641 /* The outer loop processes either 1 or 16 items per iteration depending on */
642 /* how close p_src is to the end of the input block. */
643 while (p_src!=p_src_post)
644 {/* Start of outer loop */
645
646 register UWORD unroll; /* Counts unrolled loop executions. */
647
648 /* When 'control' has the value 1, it means that the 16 buffered control */
649 /* bits that were read in at the start of the current group have all been */
650 /* shifted out and that all that is left is the 1 bit that was injected */
651 /* into bit 16 at the start of the current group. When we reach the end */
652 /* of a group, we have to load a new control word and inject a new 1 bit. */
653 if (control==1)
654 {
655 control=0x10000|*p_src++;
656 control|=(*p_src++)<<8;
657 }
658
659 /* If it is possible that we are within 16 groups from the end of the */
660 /* input, execute the unrolled loop only once, else process a whole group */
661 /* of 16 items by looping 16 times. */
662 unroll= p_src<=p_src_max16 ? 16 : 1;
663
664 /* This inner loop processes one phrase (item) per iteration. */
665 while (unroll--)
666 { /* Begin unrolled inner loop. */
667
668 /* Process a literal or copy item depending on the next control bit. */
669 if (control&1)
670 {
671 /* Copy item. */
672
673 register UBYTE *p; /* Points to place from which to copy. */
674 register UWORD lenmt; /* Length of copy item minus three. */
675 register UBYTE **p_hte; /* Pointer to current hash table entry.*/
676 register UBYTE *p_ziv=p_dst; /* Pointer to start of current Ziv. */
677
678 /* Read and dismantle the copy word. Work out from where to copy. */
679 lenmt=*p_src++;
680 p_hte=&hash[((lenmt&0xF0)<<4)|*p_src++];
681 p=*p_hte;
682 lenmt&=0xF;
683
684 /* Now perform the copy using a half unrolled loop. */
685 *p_dst++=*p++;
686 *p_dst++=*p++;
687 *p_dst++=*p++;
688 while (lenmt--)
689 *p_dst++=*p++;
690
691 /* Because we have just received 3 or more bytes in a copy item */
692 /* (whose bytes we have just installed in the output), we are now */
693 /* in a position to flush all the pending literal hashings that had */
694 /* been postponed for lack of bytes. */
695 if (literals>0)
696 {
697 register UBYTE *r=p_ziv-literals;
698 hash[HASH(r)]=r;
699 if (literals==2)
700 {r++; hash[HASH(r)]=r;}
701 literals=0;
702 }
703
704 /* In any case, we can immediately update the hash table with the */
705 /* current position. We don't need to do a HASH(...) to work out */
706 /* where to put the pointer, as the compressor just told us!!! */
707 *p_hte=p_ziv;
708
709 }
710 else
711 {
712 /* Literal item. */
713
714 /* Copy over the literal byte. */
715 *p_dst++=*p_src++;
716
717 /* If we now have three literals waiting to be hashed into the hash */
718 /* table, we can do one of them now (because there are three). */
719 if (++literals == 3)
720 {register UBYTE *p=p_dst-3; hash[HASH(p)]=p; literals=2;}
721 }
722
723 /* Shift the control buffer so the next control bit is in bit 0. */
724 control>>=1;
725#if 1
726 if (p_dst > p_dst_post)
727 {
728 /* Shit: we tried to decompress corrupt data */
729 *p_dst_len = 0;
730 return;
731 }
732#endif
733 } /* End unrolled inner loop. */
734
735 } /* End of outer loop */
736
737 /* Write the length of the decompressed data before returning. */
738 *p_dst_len=p_dst-p_dst_first;
739}
740
741/******************************************************************************/
742/* End of LZRW3.C */
743/******************************************************************************/
diff --git a/drivers/char/ftape/compressor/lzrw3.h b/drivers/char/ftape/compressor/lzrw3.h
deleted file mode 100644
index 533feba47526..000000000000
--- a/drivers/char/ftape/compressor/lzrw3.h
+++ /dev/null
@@ -1,253 +0,0 @@
1#ifndef _LZRW3_H
2#define _LZRW3_H
3/*
4 * $Source: /homes/cvs/ftape-stacked/ftape/compressor/lzrw3.h,v $
5 * $Revision: 1.1 $
6 * $Date: 1997/10/05 19:12:30 $
7 *
8 * include files for lzrw3. Only slighty modified from the original
9 * version. Assembles the three include files compress.h, port.h and
10 * fastcopy.h from the original lzrw3 package.
11 *
12 */
13
14#include <linux/types.h>
15#include <linux/string.h>
16
17/******************************************************************************/
18/* */
19/* COMPRESS.H */
20/* */
21/******************************************************************************/
22/* */
23/* Author : Ross Williams. */
24/* Date : December 1989. */
25/* */
26/* This header file defines the interface to a set of functions called */
27/* 'compress', each member of which implements a particular data compression */
28/* algorithm. */
29/* */
30/* Normally in C programming, for each .H file, there is a corresponding .C */
31/* file that implements the functions promised in the .H file. */
32/* Here, there are many .C files corresponding to this header file. */
33/* Each comforming implementation file contains a single function */
34/* called 'compress' that implements a single data compression */
35/* algorithm that conforms with the interface specified in this header file. */
36/* Only one algorithm can be linked in at a time in this organization. */
37/* */
38/******************************************************************************/
39/* */
40/* DEFINITION OF FUNCTION COMPRESS */
41/* =============================== */
42/* */
43/* Summary of Function Compress */
44/* ---------------------------- */
45/* The action that 'compress' takes depends on its first argument called */
46/* 'action'. The function provides three actions: */
47/* */
48/* - Return information about the algorithm. */
49/* - Compress a block of memory. */
50/* - Decompress a block of memory. */
51/* */
52/* Parameters */
53/* ---------- */
54/* See the formal C definition later for a description of the parameters. */
55/* */
56/* Constants */
57/* --------- */
58/* COMPRESS_OVERRUN: The constant COMPRESS_OVERRUN defines by how many bytes */
59/* an algorithm is allowed to expand a block during a compression operation. */
60/* */
61/* Although compression algorithms usually compress data, there will always */
62/* be data that a given compressor will expand (this can be proven). */
63/* Fortunately, the degree of expansion can be limited to a single bit, by */
64/* copying over the input data if the data gets bigger during compression. */
65/* To allow for this possibility, the first bit of a compressed */
66/* representation can be used as a flag indicating whether the */
67/* input data was copied over, or truly compressed. In practice, the first */
68/* byte would be used to store this bit so as to maintain byte alignment. */
69/* */
70/* Unfortunately, in general, the only way to tell if an algorithm will */
71/* expand a particular block of data is to run the algorithm on the data. */
72/* If the algorithm does not continuously monitor how many output bytes it */
73/* has written, it might write an output block far larger than the input */
74/* block before realizing that it has done so. */
75/* On the other hand, continuous checks on output length are inefficient. */
76/* */
77/* To cater for all these problems, this interface definition: */
78/* > Allows a compression algorithm to return an output block that is up to */
79/* COMPRESS_OVERRUN bytes longer than the input block. */
80/* > Allows a compression algorithm to write up to COMPRESS_OVERRUN bytes */
81/* more than the length of the input block to the memory of the output */
82/* block regardless of the length of the output block eventually returned. */
83/* This allows an algorithm to overrun the length of the input block in the */
84/* output block by up to COMPRESS_OVERRUN bytes between expansion checks. */
85/* */
86/* The problem does not arise for decompression. */
87/* */
88/* Identity Action */
89/* --------------- */
90/* > action must be COMPRESS_ACTION_IDENTITY. */
91/* > p_dst_len must point to a longword to receive a longword address. */
92/* > The value of the other parameters does not matter. */
93/* > After execution, the longword that p_dst_len points to will be a pointer */
94/* to a structure of type compress_identity. */
95/* Thus, for example, after the call, (*p_dst_len)->memory will return the */
96/* number of bytes of working memory that the algorithm requires to run. */
97/* > The values of the identity structure returned are fixed constant */
98/* attributes of the algorithm and must not vary from call to call. */
99/* */
100/* Common Requirements for Compression and Decompression Actions */
101/* ------------------------------------------------------------- */
102/* > wrk_mem must point to an unused block of memory of a length specified in */
103/* the algorithm's identity block. The identity block can be obtained by */
104/* making a separate call to compress, specifying the identity action. */
105/* > The INPUT BLOCK is defined to be Memory[src_addr,src_addr+src_len-1]. */
106/* > dst_len will be used to denote *p_dst_len. */
107/* > dst_len is not read by compress, only written. */
108/* > The value of dst_len is defined only upon termination. */
109/* > The OUTPUT BLOCK is defined to be Memory[dst_addr,dst_addr+dst_len-1]. */
110/* */
111/* Compression Action */
112/* ------------------ */
113/* > action must be COMPRESS_ACTION_COMPRESS. */
114/* > src_len must be in the range [0,COMPRESS_MAX_ORG]. */
115/* > The OUTPUT ZONE is defined to be */
116/* Memory[dst_addr,dst_addr+src_len-1+COMPRESS_OVERRUN]. */
117/* > The function can modify any part of the output zone regardless of the */
118/* final length of the output block. */
119/* > The input block and the output zone must not overlap. */
120/* > dst_len will be in the range [0,src_len+COMPRESS_OVERRUN]. */
121/* > dst_len will be in the range [0,COMPRESS_MAX_COM] (from prev fact). */
122/* > The output block will consist of a representation of the input block. */
123/* */
124/* Decompression Action */
125/* -------------------- */
126/* > action must be COMPRESS_ACTION_DECOMPRESS. */
127/* > The input block must be the result of an earlier compression operation. */
128/* > If the previous fact is true, the following facts must also be true: */
129/* > src_len will be in the range [0,COMPRESS_MAX_COM]. */
130/* > dst_len will be in the range [0,COMPRESS_MAX_ORG]. */
131/* > The input and output blocks must not overlap. */
132/* > Only the output block is modified. */
133/* > Upon termination, the output block will consist of the bytes contained */
134/* in the input block passed to the earlier compression operation. */
135/* */
136/******************************************************************************/
137
138/******************************************************************************/
139/* */
140/* PORT.H */
141/* */
142/******************************************************************************/
143/* */
144/* This module contains macro definitions and types that are likely to */
145/* change between computers. */
146/* */
147/******************************************************************************/
148
149#ifndef DONE_PORT /* Only do this if not previously done. */
150
151 #ifdef THINK_C
152 #define UBYTE unsigned char /* Unsigned byte */
153 #define UWORD unsigned int /* Unsigned word (2 bytes) */
154 #define ULONG unsigned long /* Unsigned word (4 bytes) */
155 #define BOOL unsigned char /* Boolean */
156 #define FOPEN_BINARY_READ "rb" /* Mode string for binary reading. */
157 #define FOPEN_BINARY_WRITE "wb" /* Mode string for binary writing. */
158 #define FOPEN_TEXT_APPEND "a" /* Mode string for text appending. */
159 #define REAL double /* USed for floating point stuff. */
160 #endif
161 #if defined(LINUX) || defined(linux)
162 #define UBYTE __u8 /* Unsigned byte */
163 #define UWORD __u16 /* Unsigned word (2 bytes) */
164 #define ULONG __u32 /* Unsigned word (4 bytes) */
165 #define LONG __s32 /* Signed word (4 bytes) */
166 #define BOOL is not used here /* Boolean */
167 #define FOPEN_BINARY_READ not used /* Mode string for binary reading. */
168 #define FOPEN_BINARY_WRITE not used /* Mode string for binary writing. */
169 #define FOPEN_TEXT_APPEND not used /* Mode string for text appending. */
170 #define REAL not used /* USed for floating point stuff. */
171 #ifndef TRUE
172 #define TRUE 1
173 #endif
174 #endif
175
176 #define DONE_PORT /* Don't do all this again. */
177 #define MALLOC_FAIL NULL /* Failure status from malloc() */
178 #define LOCAL static /* For non-exported routines. */
179 #define EXPORT /* Signals exported function. */
180 #define then /* Useful for aligning ifs. */
181
182#endif
183
184/******************************************************************************/
185/* End of PORT.H */
186/******************************************************************************/
187
188#define COMPRESS_ACTION_IDENTITY 0
189#define COMPRESS_ACTION_COMPRESS 1
190#define COMPRESS_ACTION_DECOMPRESS 2
191
192#define COMPRESS_OVERRUN 1024
193#define COMPRESS_MAX_COM 0x70000000
194#define COMPRESS_MAX_ORG (COMPRESS_MAX_COM-COMPRESS_OVERRUN)
195
196#define COMPRESS_MAX_STRLEN 255
197
198/* The following structure provides information about the algorithm. */
199/* > The top bit of id must be zero. The remaining bits must be chosen by */
200/* the author of the algorithm by tossing a coin 31 times. */
201/* > The amount of memory requested by the algorithm is specified in bytes */
202/* and must be in the range [0,0x70000000]. */
203/* > All strings s must be such that strlen(s)<=COMPRESS_MAX_STRLEN. */
204struct compress_identity
205 {
206 ULONG id; /* Identifying number of algorithm. */
207 ULONG memory; /* Number of bytes of working memory required. */
208
209 char *name; /* Name of algorithm. */
210 char *version; /* Version number. */
211 char *date; /* Date of release of this version. */
212 char *copyright; /* Copyright message. */
213
214 char *author; /* Author of algorithm. */
215 char *affiliation; /* Affiliation of author. */
216 char *vendor; /* Where the algorithm can be obtained. */
217 };
218
219void lzrw3_compress( /* Single function interface to compression algorithm. */
220UWORD action, /* Action to be performed. */
221UBYTE *wrk_mem, /* Working memory temporarily given to routine to use. */
222UBYTE *src_adr, /* Address of input data. */
223LONG src_len, /* Length of input data. */
224UBYTE *dst_adr, /* Address of output data. */
225void *p_dst_len /* Pointer to a longword where routine will write: */
226 /* If action=..IDENTITY => Adr of id structure. */
227 /* If action=..COMPRESS => Length of output data. */
228 /* If action=..DECOMPRESS => Length of output data. */
229);
230
231/******************************************************************************/
232/* End of COMPRESS.H */
233/******************************************************************************/
234
235
236/******************************************************************************/
237/* fast_copy.h */
238/******************************************************************************/
239
240/* This function copies a block of memory very quickly. */
241/* The exact speed depends on the relative alignment of the blocks of memory. */
242/* PRE : 0<=src_len<=(2^32)-1 . */
243/* PRE : Source and destination blocks must not overlap. */
244/* POST : MEM[dst_adr,dst_adr+src_len-1]=MEM[src_adr,src_adr+src_len-1]. */
245/* POST : MEM[dst_adr,dst_adr+src_len-1] is the only memory changed. */
246
247#define fast_copy(src,dst,len) memcpy(dst,src,len)
248
249/******************************************************************************/
250/* End of fast_copy.h */
251/******************************************************************************/
252
253#endif
diff --git a/drivers/char/ftape/compressor/zftape-compress.c b/drivers/char/ftape/compressor/zftape-compress.c
deleted file mode 100644
index 65ffc0be3df9..000000000000
--- a/drivers/char/ftape/compressor/zftape-compress.c
+++ /dev/null
@@ -1,1203 +0,0 @@
1/*
2 * Copyright (C) 1994-1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2, or (at
7 your option) any later version.
8
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
17 USA.
18
19 *
20 * This file implements a "generic" interface between the *
21 * zftape-driver and a compression-algorithm. The *
22 * compression-algorithm currently used is a LZ77. I use the *
23 * implementation lzrw3 by Ross N. Williams (Renaissance *
24 * Software). The compression program itself is in the file
25 * lzrw3.c * and lzrw3.h. To adopt another compression algorithm
26 * the functions * zft_compress() and zft_uncompress() must be
27 * changed * appropriately. See below.
28 */
29
30#include <linux/errno.h>
31#include <linux/mm.h>
32#include <linux/module.h>
33
34#include <linux/zftape.h>
35
36#include <asm/uaccess.h>
37
38#include "../zftape/zftape-init.h"
39#include "../zftape/zftape-eof.h"
40#include "../zftape/zftape-ctl.h"
41#include "../zftape/zftape-write.h"
42#include "../zftape/zftape-read.h"
43#include "../zftape/zftape-rw.h"
44#include "../compressor/zftape-compress.h"
45#include "../zftape/zftape-vtbl.h"
46#include "../compressor/lzrw3.h"
47
48/*
49 * global variables
50 */
51
52/* I handle the allocation of this buffer as a special case, because
53 * it's size varies depending on the tape length inserted.
54 */
55
56/* local variables
57 */
58static void *zftc_wrk_mem = NULL;
59static __u8 *zftc_buf = NULL;
60static void *zftc_scratch_buf = NULL;
61
62/* compression statistics
63 */
64static unsigned int zftc_wr_uncompressed = 0;
65static unsigned int zftc_wr_compressed = 0;
66static unsigned int zftc_rd_uncompressed = 0;
67static unsigned int zftc_rd_compressed = 0;
68
69/* forward */
70static int zftc_write(int *write_cnt,
71 __u8 *dst_buf, const int seg_sz,
72 const __u8 __user *src_buf, const int req_len,
73 const zft_position *pos, const zft_volinfo *volume);
74static int zftc_read(int *read_cnt,
75 __u8 __user *dst_buf, const int to_do,
76 const __u8 *src_buf, const int seg_sz,
77 const zft_position *pos, const zft_volinfo *volume);
78static int zftc_seek(unsigned int new_block_pos,
79 zft_position *pos, const zft_volinfo *volume,
80 __u8 *buffer);
81static void zftc_lock (void);
82static void zftc_reset (void);
83static void zftc_cleanup(void);
84static void zftc_stats (void);
85
86/* compressed segment. This conforms to QIC-80-MC, Revision K.
87 *
88 * Rev. K applies to tapes with `fixed length format' which is
89 * indicated by format code 2,3 and 5. See below for format code 4 and 6
90 *
91 * 2 bytes: offset of compression segment structure
92 * 29k > offset >= 29k-18: data from previous segment ens in this
93 * segment and no compressed block starts
94 * in this segment
95 * offset == 0: data from previous segment occupies entire
96 * segment and continues in next segment
97 * n bytes: remainder from previous segment
98 *
99 * Rev. K:
100 * 4 bytes: 4 bytes: files set byte offset
101 * Post Rev. K and QIC-3020/3020:
102 * 8 bytes: 8 bytes: files set byte offset
103 * 2 bytes: byte count N (amount of data following)
104 * bit 15 is set if data is compressed, bit 15 is not
105 * set if data is uncompressed
106 * N bytes: data (as much as specified in the byte count)
107 * 2 bytes: byte count N_1 of next cluster
108 * N_1 bytes: data of next cluset
109 * 2 bytes: byte count N_2 of next cluster
110 * N_2 bytes: ...
111 *
112 * Note that the `N' byte count accounts only for the bytes that in the
113 * current segment if the cluster spans to the next segment.
114 */
115
116typedef struct
117{
118 int cmpr_pos; /* actual position in compression buffer */
119 int cmpr_sz; /* what is left in the compression buffer
120 * when copying the compressed data to the
121 * deblock buffer
122 */
123 unsigned int first_block; /* location of header information in
124 * this segment
125 */
126 unsigned int count; /* amount of data of current block
127 * contained in current segment
128 */
129 unsigned int offset; /* offset in current segment */
130 unsigned int spans:1; /* might continue in next segment */
131 unsigned int uncmpr; /* 0x8000 if this block contains
132 * uncompressed data
133 */
134 __s64 foffs; /* file set byte offset, same as in
135 * compression map segment
136 */
137} cmpr_info;
138
139static cmpr_info cseg; /* static data. Must be kept uptodate and shared by
140 * read, write and seek functions
141 */
142
143#define DUMP_CMPR_INFO(level, msg, info) \
144 TRACE(level, msg "\n" \
145 KERN_INFO "cmpr_pos : %d\n" \
146 KERN_INFO "cmpr_sz : %d\n" \
147 KERN_INFO "first_block: %d\n" \
148 KERN_INFO "count : %d\n" \
149 KERN_INFO "offset : %d\n" \
150 KERN_INFO "spans : %d\n" \
151 KERN_INFO "uncmpr : 0x%04x\n" \
152 KERN_INFO "foffs : " LL_X, \
153 (info)->cmpr_pos, (info)->cmpr_sz, (info)->first_block, \
154 (info)->count, (info)->offset, (info)->spans == 1, \
155 (info)->uncmpr, LL((info)->foffs))
156
157/* dispatch compression segment info, return error code
158 *
159 * afterwards, cseg->offset points to start of data of the NEXT
160 * compressed block, and cseg->count contains the amount of data
161 * left in the actual compressed block. cseg->spans is set to 1 if
162 * the block is continued in the following segment. Otherwise it is
163 * set to 0.
164 */
165static int get_cseg (cmpr_info *cinfo, const __u8 *buff,
166 const unsigned int seg_sz,
167 const zft_volinfo *volume)
168{
169 TRACE_FUN(ft_t_flow);
170
171 cinfo->first_block = GET2(buff, 0);
172 if (cinfo->first_block == 0) { /* data spans to next segment */
173 cinfo->count = seg_sz - sizeof(__u16);
174 cinfo->offset = seg_sz;
175 cinfo->spans = 1;
176 } else { /* cluster definetely ends in this segment */
177 if (cinfo->first_block > seg_sz) {
178 /* data corrupted */
179 TRACE_ABORT(-EIO, ft_t_err, "corrupted data:\n"
180 KERN_INFO "segment size: %d\n"
181 KERN_INFO "first block : %d",
182 seg_sz, cinfo->first_block);
183 }
184 cinfo->count = cinfo->first_block - sizeof(__u16);
185 cinfo->offset = cinfo->first_block;
186 cinfo->spans = 0;
187 }
188 /* now get the offset the first block should have in the
189 * uncompressed data stream.
190 *
191 * For this magic `18' refer to CRF-3 standard or QIC-80MC,
192 * Rev. K.
193 */
194 if ((seg_sz - cinfo->offset) > 18) {
195 if (volume->qic113) { /* > revision K */
196 TRACE(ft_t_data_flow, "New QIC-113 compliance");
197 cinfo->foffs = GET8(buff, cinfo->offset);
198 cinfo->offset += sizeof(__s64);
199 } else {
200 TRACE(/* ft_t_data_flow */ ft_t_noise, "pre QIC-113 version");
201 cinfo->foffs = (__s64)GET4(buff, cinfo->offset);
202 cinfo->offset += sizeof(__u32);
203 }
204 }
205 if (cinfo->foffs > volume->size) {
206 TRACE_ABORT(-EIO, ft_t_err, "Inconsistency:\n"
207 KERN_INFO "offset in current volume: %d\n"
208 KERN_INFO "size of current volume : %d",
209 (int)(cinfo->foffs>>10), (int)(volume->size>>10));
210 }
211 if (cinfo->cmpr_pos + cinfo->count > volume->blk_sz) {
212 TRACE_ABORT(-EIO, ft_t_err, "Inconsistency:\n"
213 KERN_INFO "block size : %d\n"
214 KERN_INFO "data record: %d",
215 volume->blk_sz, cinfo->cmpr_pos + cinfo->count);
216 }
217 DUMP_CMPR_INFO(ft_t_noise /* ft_t_any */, "", cinfo);
218 TRACE_EXIT 0;
219}
220
221/* This one is called, when a new cluster starts in same segment.
222 *
223 * Note: if this is the first cluster in the current segment, we must
224 * not check whether there are more than 18 bytes available because
225 * this have already been done in get_cseg() and there may be less
226 * than 18 bytes available due to header information.
227 *
228 */
229static void get_next_cluster(cmpr_info *cluster, const __u8 *buff,
230 const int seg_sz, const int finish)
231{
232 TRACE_FUN(ft_t_flow);
233
234 if (seg_sz - cluster->offset > 18 || cluster->foffs != 0) {
235 cluster->count = GET2(buff, cluster->offset);
236 cluster->uncmpr = cluster->count & 0x8000;
237 cluster->count -= cluster->uncmpr;
238 cluster->offset += sizeof(__u16);
239 cluster->foffs = 0;
240 if ((cluster->offset + cluster->count) < seg_sz) {
241 cluster->spans = 0;
242 } else if (cluster->offset + cluster->count == seg_sz) {
243 cluster->spans = !finish;
244 } else {
245 /* either an error or a volume written by an
246 * old version. If this is a data error, then we'll
247 * catch it later.
248 */
249 TRACE(ft_t_data_flow, "Either error or old volume");
250 cluster->spans = 1;
251 cluster->count = seg_sz - cluster->offset;
252 }
253 } else {
254 cluster->count = 0;
255 cluster->spans = 0;
256 cluster->foffs = 0;
257 }
258 DUMP_CMPR_INFO(ft_t_noise /* ft_t_any */ , "", cluster);
259 TRACE_EXIT;
260}
261
262static void zftc_lock(void)
263{
264}
265
266/* this function is needed for zftape_reset_position in zftape-io.c
267 */
268static void zftc_reset(void)
269{
270 TRACE_FUN(ft_t_flow);
271
272 memset((void *)&cseg, '\0', sizeof(cseg));
273 zftc_stats();
274 TRACE_EXIT;
275}
276
277static int cmpr_mem_initialized = 0;
278static unsigned int alloc_blksz = 0;
279
280static int zft_allocate_cmpr_mem(unsigned int blksz)
281{
282 TRACE_FUN(ft_t_flow);
283
284 if (cmpr_mem_initialized && blksz == alloc_blksz) {
285 TRACE_EXIT 0;
286 }
287 TRACE_CATCH(zft_vmalloc_once(&zftc_wrk_mem, CMPR_WRK_MEM_SIZE),
288 zftc_cleanup());
289 TRACE_CATCH(zft_vmalloc_always(&zftc_buf, blksz + CMPR_OVERRUN),
290 zftc_cleanup());
291 alloc_blksz = blksz;
292 TRACE_CATCH(zft_vmalloc_always(&zftc_scratch_buf, blksz+CMPR_OVERRUN),
293 zftc_cleanup());
294 cmpr_mem_initialized = 1;
295 TRACE_EXIT 0;
296}
297
298static void zftc_cleanup(void)
299{
300 TRACE_FUN(ft_t_flow);
301
302 zft_vfree(&zftc_wrk_mem, CMPR_WRK_MEM_SIZE);
303 zft_vfree(&zftc_buf, alloc_blksz + CMPR_OVERRUN);
304 zft_vfree(&zftc_scratch_buf, alloc_blksz + CMPR_OVERRUN);
305 cmpr_mem_initialized = alloc_blksz = 0;
306 TRACE_EXIT;
307}
308
309/*****************************************************************************
310 * *
311 * The following two functions "ftape_compress()" and *
312 * "ftape_uncompress()" are the interface to the actual compression *
313 * algorithm (i.e. they are calling the "compress()" function from *
314 * the lzrw3 package for now). These routines could quite easily be *
315 * changed to adopt another compression algorithm instead of lzrw3, *
316 * which currently is used. *
317 * *
318 *****************************************************************************/
319
320/* called by zft_compress_write() to perform the compression. Must
321 * return the size of the compressed data.
322 *
323 * NOTE: The size of the compressed data should not exceed the size of
324 * the uncompressed data. Most compression algorithms have means
325 * to store data unchanged if the "compressed" data amount would
326 * exceed the original one. Mostly this is done by storing some
327 * flag-bytes in front of the compressed data to indicate if it
328 * is compressed or not. Thus the worst compression result
329 * length is the original length plus those flag-bytes.
330 *
331 * We don't want that, as the QIC-80 standard provides a means
332 * of marking uncompressed blocks by simply setting bit 15 of
333 * the compressed block's length. Thus a compessed block can
334 * have at most a length of 2^15-1 bytes. The QIC-80 standard
335 * restricts the block-length even further, allowing only 29k -
336 * 6 bytes.
337 *
338 * Currently, the maximum blocksize used by zftape is 28k.
339 *
340 * In short: don't exceed the length of the input-package, set
341 * bit 15 of the compressed size to 1 if you have copied data
342 * instead of compressing it.
343 */
344static int zft_compress(__u8 *in_buffer, unsigned int in_sz, __u8 *out_buffer)
345{
346 __s32 compressed_sz;
347 TRACE_FUN(ft_t_flow);
348
349
350 lzrw3_compress(COMPRESS_ACTION_COMPRESS, zftc_wrk_mem,
351 in_buffer, in_sz, out_buffer, &compressed_sz);
352 if (TRACE_LEVEL >= ft_t_info) {
353 /* the compiler will optimize this away when
354 * compiled with NO_TRACE_AT_ALL option
355 */
356 TRACE(ft_t_data_flow, "\n"
357 KERN_INFO "before compression: %d bytes\n"
358 KERN_INFO "after compresison : %d bytes",
359 in_sz,
360 (int)(compressed_sz < 0
361 ? -compressed_sz : compressed_sz));
362 /* for statistical purposes
363 */
364 zftc_wr_compressed += (compressed_sz < 0
365 ? -compressed_sz : compressed_sz);
366 zftc_wr_uncompressed += in_sz;
367 }
368 TRACE_EXIT (int)compressed_sz;
369}
370
371/* called by zft_compress_read() to decompress the data. Must
372 * return the size of the decompressed data for sanity checks
373 * (compared with zft_blk_sz)
374 *
375 * NOTE: Read the note for zft_compress() above! If bit 15 of the
376 * parameter in_sz is set, then the data in in_buffer isn't
377 * compressed, which must be handled by the un-compression
378 * algorithm. (I changed lzrw3 to handle this.)
379 *
380 * The parameter max_out_sz is needed to prevent buffer overruns when
381 * uncompressing corrupt data.
382 */
383static unsigned int zft_uncompress(__u8 *in_buffer,
384 int in_sz,
385 __u8 *out_buffer,
386 unsigned int max_out_sz)
387{
388 TRACE_FUN(ft_t_flow);
389
390 lzrw3_compress(COMPRESS_ACTION_DECOMPRESS, zftc_wrk_mem,
391 in_buffer, (__s32)in_sz,
392 out_buffer, (__u32 *)&max_out_sz);
393
394 if (TRACE_LEVEL >= ft_t_info) {
395 TRACE(ft_t_data_flow, "\n"
396 KERN_INFO "before decompression: %d bytes\n"
397 KERN_INFO "after decompression : %d bytes",
398 in_sz < 0 ? -in_sz : in_sz,(int)max_out_sz);
399 /* for statistical purposes
400 */
401 zftc_rd_compressed += in_sz < 0 ? -in_sz : in_sz;
402 zftc_rd_uncompressed += max_out_sz;
403 }
404 TRACE_EXIT (unsigned int)max_out_sz;
405}
406
407/* print some statistics about the efficiency of the compression to
408 * the kernel log
409 */
410static void zftc_stats(void)
411{
412 TRACE_FUN(ft_t_flow);
413
414 if (TRACE_LEVEL < ft_t_info) {
415 TRACE_EXIT;
416 }
417 if (zftc_wr_uncompressed != 0) {
418 if (zftc_wr_compressed > (1<<14)) {
419 TRACE(ft_t_info, "compression statistics (writing):\n"
420 KERN_INFO " compr./uncmpr. : %3d %%",
421 (((zftc_wr_compressed>>10) * 100)
422 / (zftc_wr_uncompressed>>10)));
423 } else {
424 TRACE(ft_t_info, "compression statistics (writing):\n"
425 KERN_INFO " compr./uncmpr. : %3d %%",
426 ((zftc_wr_compressed * 100)
427 / zftc_wr_uncompressed));
428 }
429 }
430 if (zftc_rd_uncompressed != 0) {
431 if (zftc_rd_compressed > (1<<14)) {
432 TRACE(ft_t_info, "compression statistics (reading):\n"
433 KERN_INFO " compr./uncmpr. : %3d %%",
434 (((zftc_rd_compressed>>10) * 100)
435 / (zftc_rd_uncompressed>>10)));
436 } else {
437 TRACE(ft_t_info, "compression statistics (reading):\n"
438 KERN_INFO " compr./uncmpr. : %3d %%",
439 ((zftc_rd_compressed * 100)
440 / zftc_rd_uncompressed));
441 }
442 }
443 /* only print it once: */
444 zftc_wr_uncompressed =
445 zftc_wr_compressed =
446 zftc_rd_uncompressed =
447 zftc_rd_compressed = 0;
448 TRACE_EXIT;
449}
450
451/* start new compressed block
452 */
453static int start_new_cseg(cmpr_info *cluster,
454 char *dst_buf,
455 const zft_position *pos,
456 const unsigned int blk_sz,
457 const char *src_buf,
458 const int this_segs_sz,
459 const int qic113)
460{
461 int size_left;
462 int cp_cnt;
463 int buf_pos;
464 TRACE_FUN(ft_t_flow);
465
466 size_left = this_segs_sz - sizeof(__u16) - cluster->cmpr_sz;
467 TRACE(ft_t_data_flow,"\n"
468 KERN_INFO "segment size : %d\n"
469 KERN_INFO "compressed_sz: %d\n"
470 KERN_INFO "size_left : %d",
471 this_segs_sz, cluster->cmpr_sz, size_left);
472 if (size_left > 18) { /* start a new cluseter */
473 cp_cnt = cluster->cmpr_sz;
474 cluster->cmpr_sz = 0;
475 buf_pos = cp_cnt + sizeof(__u16);
476 PUT2(dst_buf, 0, buf_pos);
477
478 if (qic113) {
479 __s64 foffs = pos->volume_pos;
480 if (cp_cnt) foffs += (__s64)blk_sz;
481
482 TRACE(ft_t_data_flow, "new style QIC-113 header");
483 PUT8(dst_buf, buf_pos, foffs);
484 buf_pos += sizeof(__s64);
485 } else {
486 __u32 foffs = (__u32)pos->volume_pos;
487 if (cp_cnt) foffs += (__u32)blk_sz;
488
489 TRACE(ft_t_data_flow, "old style QIC-80MC header");
490 PUT4(dst_buf, buf_pos, foffs);
491 buf_pos += sizeof(__u32);
492 }
493 } else if (size_left >= 0) {
494 cp_cnt = cluster->cmpr_sz;
495 cluster->cmpr_sz = 0;
496 buf_pos = cp_cnt + sizeof(__u16);
497 PUT2(dst_buf, 0, buf_pos);
498 /* zero unused part of segment. */
499 memset(dst_buf + buf_pos, '\0', size_left);
500 buf_pos = this_segs_sz;
501 } else { /* need entire segment and more space */
502 PUT2(dst_buf, 0, 0);
503 cp_cnt = this_segs_sz - sizeof(__u16);
504 cluster->cmpr_sz -= cp_cnt;
505 buf_pos = this_segs_sz;
506 }
507 memcpy(dst_buf + sizeof(__u16), src_buf + cluster->cmpr_pos, cp_cnt);
508 cluster->cmpr_pos += cp_cnt;
509 TRACE_EXIT buf_pos;
510}
511
512/* return-value: the number of bytes removed from the user-buffer
513 * `src_buf' or error code
514 *
515 * int *write_cnt : how much actually has been moved to the
516 * dst_buf. Need not be initialized when
517 * function returns with an error code
518 * (negativ return value)
519 * __u8 *dst_buf : kernel space buffer where the has to be
520 * copied to. The contents of this buffers
521 * goes to a specific segment.
522 * const int seg_sz : the size of the segment dst_buf will be
523 * copied to.
524 * const zft_position *pos : struct containing the coordinates in
525 * the current volume (byte position,
526 * segment id of current segment etc)
527 * const zft_volinfo *volume: information about the current volume,
528 * size etc.
529 * const __u8 *src_buf : user space buffer that contains the
530 * data the user wants to be written to
531 * tape.
532 * const int req_len : the amount of data the user wants to be
533 * written to tape.
534 */
535static int zftc_write(int *write_cnt,
536 __u8 *dst_buf, const int seg_sz,
537 const __u8 __user *src_buf, const int req_len,
538 const zft_position *pos, const zft_volinfo *volume)
539{
540 int req_len_left = req_len;
541 int result;
542 int len_left;
543 int buf_pos_write = pos->seg_byte_pos;
544 TRACE_FUN(ft_t_flow);
545
546 /* Note: we do not unlock the module because
547 * there are some values cached in that `cseg' variable. We
548 * don't don't want to use this information when being
549 * unloaded by kerneld even when the tape is full or when we
550 * cannot allocate enough memory.
551 */
552 if (pos->tape_pos > (volume->size-volume->blk_sz-ZFT_CMPR_OVERHEAD)) {
553 TRACE_EXIT -ENOSPC;
554 }
555 if (zft_allocate_cmpr_mem(volume->blk_sz) < 0) {
556 /* should we unlock the module? But it shouldn't
557 * be locked anyway ...
558 */
559 TRACE_EXIT -ENOMEM;
560 }
561 if (buf_pos_write == 0) { /* fill a new segment */
562 *write_cnt = buf_pos_write = start_new_cseg(&cseg,
563 dst_buf,
564 pos,
565 volume->blk_sz,
566 zftc_buf,
567 seg_sz,
568 volume->qic113);
569 if (cseg.cmpr_sz == 0 && cseg.cmpr_pos != 0) {
570 req_len_left -= result = volume->blk_sz;
571 cseg.cmpr_pos = 0;
572 } else {
573 result = 0;
574 }
575 } else {
576 *write_cnt = result = 0;
577 }
578
579 len_left = seg_sz - buf_pos_write;
580 while ((req_len_left > 0) && (len_left > 18)) {
581 /* now we have some size left for a new compressed
582 * block. We know, that the compression buffer is
583 * empty (else there wouldn't be any space left).
584 */
585 if (copy_from_user(zftc_scratch_buf, src_buf + result,
586 volume->blk_sz) != 0) {
587 TRACE_EXIT -EFAULT;
588 }
589 req_len_left -= volume->blk_sz;
590 cseg.cmpr_sz = zft_compress(zftc_scratch_buf, volume->blk_sz,
591 zftc_buf);
592 if (cseg.cmpr_sz < 0) {
593 cseg.uncmpr = 0x8000;
594 cseg.cmpr_sz = -cseg.cmpr_sz;
595 } else {
596 cseg.uncmpr = 0;
597 }
598 /* increment "result" iff we copied the entire
599 * compressed block to the zft_deblock_buf
600 */
601 len_left -= sizeof(__u16);
602 if (len_left >= cseg.cmpr_sz) {
603 len_left -= cseg.count = cseg.cmpr_sz;
604 cseg.cmpr_pos = cseg.cmpr_sz = 0;
605 result += volume->blk_sz;
606 } else {
607 cseg.cmpr_sz -=
608 cseg.cmpr_pos =
609 cseg.count = len_left;
610 len_left = 0;
611 }
612 PUT2(dst_buf, buf_pos_write, cseg.uncmpr | cseg.count);
613 buf_pos_write += sizeof(__u16);
614 memcpy(dst_buf + buf_pos_write, zftc_buf, cseg.count);
615 buf_pos_write += cseg.count;
616 *write_cnt += cseg.count + sizeof(__u16);
617 FT_SIGNAL_EXIT(_DONT_BLOCK);
618 }
619 /* erase the remainder of the segment if less than 18 bytes
620 * left (18 bytes is due to the QIC-80 standard)
621 */
622 if (len_left <= 18) {
623 memset(dst_buf + buf_pos_write, '\0', len_left);
624 (*write_cnt) += len_left;
625 }
626 TRACE(ft_t_data_flow, "returning %d", result);
627 TRACE_EXIT result;
628}
629
630/* out:
631 *
632 * int *read_cnt: the number of bytes we removed from the zft_deblock_buf
633 * (result)
634 * int *to_do : the remaining size of the read-request.
635 *
636 * in:
637 *
638 * char *buff : buff is the address of the upper part of the user
639 * buffer, that hasn't been filled with data yet.
640
641 * int buf_pos_read : copy of from _ftape_read()
642 * int buf_len_read : copy of buf_len_rd from _ftape_read()
643 * char *zft_deblock_buf: zft_deblock_buf
644 * unsigned short blk_sz: the block size valid for this volume, may differ
645 * from zft_blk_sz.
646 * int finish: if != 0 means that this is the last segment belonging
647 * to this volume
648 * returns the amount of data actually copied to the user-buffer
649 *
650 * to_do MUST NOT SHRINK except to indicate an EOF. In this case *to_do has to
651 * be set to 0
652 */
653static int zftc_read (int *read_cnt,
654 __u8 __user *dst_buf, const int to_do,
655 const __u8 *src_buf, const int seg_sz,
656 const zft_position *pos, const zft_volinfo *volume)
657{
658 int uncompressed_sz;
659 int result = 0;
660 int remaining = to_do;
661 TRACE_FUN(ft_t_flow);
662
663 TRACE_CATCH(zft_allocate_cmpr_mem(volume->blk_sz),);
664 if (pos->seg_byte_pos == 0) {
665 /* new segment just read
666 */
667 TRACE_CATCH(get_cseg(&cseg, src_buf, seg_sz, volume),
668 *read_cnt = 0);
669 memcpy(zftc_buf + cseg.cmpr_pos, src_buf + sizeof(__u16),
670 cseg.count);
671 cseg.cmpr_pos += cseg.count;
672 *read_cnt = cseg.offset;
673 DUMP_CMPR_INFO(ft_t_noise /* ft_t_any */, "", &cseg);
674 } else {
675 *read_cnt = 0;
676 }
677 /* loop and uncompress until user buffer full or
678 * deblock-buffer empty
679 */
680 TRACE(ft_t_data_flow, "compressed_sz: %d, compos : %d, *read_cnt: %d",
681 cseg.cmpr_sz, cseg.cmpr_pos, *read_cnt);
682 while ((cseg.spans == 0) && (remaining > 0)) {
683 if (cseg.cmpr_pos != 0) { /* cmpr buf is not empty */
684 uncompressed_sz =
685 zft_uncompress(zftc_buf,
686 cseg.uncmpr == 0x8000 ?
687 -cseg.cmpr_pos : cseg.cmpr_pos,
688 zftc_scratch_buf,
689 volume->blk_sz);
690 if (uncompressed_sz != volume->blk_sz) {
691 *read_cnt = 0;
692 TRACE_ABORT(-EIO, ft_t_warn,
693 "Uncompressed blk (%d) != blk size (%d)",
694 uncompressed_sz, volume->blk_sz);
695 }
696 if (copy_to_user(dst_buf + result,
697 zftc_scratch_buf,
698 uncompressed_sz) != 0 ) {
699 TRACE_EXIT -EFAULT;
700 }
701 remaining -= uncompressed_sz;
702 result += uncompressed_sz;
703 cseg.cmpr_pos = 0;
704 }
705 if (remaining > 0) {
706 get_next_cluster(&cseg, src_buf, seg_sz,
707 volume->end_seg == pos->seg_pos);
708 if (cseg.count != 0) {
709 memcpy(zftc_buf, src_buf + cseg.offset,
710 cseg.count);
711 cseg.cmpr_pos = cseg.count;
712 cseg.offset += cseg.count;
713 *read_cnt += cseg.count + sizeof(__u16);
714 } else {
715 remaining = 0;
716 }
717 }
718 TRACE(ft_t_data_flow, "\n"
719 KERN_INFO "compressed_sz: %d\n"
720 KERN_INFO "compos : %d\n"
721 KERN_INFO "*read_cnt : %d",
722 cseg.cmpr_sz, cseg.cmpr_pos, *read_cnt);
723 }
724 if (seg_sz - cseg.offset <= 18) {
725 *read_cnt += seg_sz - cseg.offset;
726 TRACE(ft_t_data_flow, "expanding read cnt to: %d", *read_cnt);
727 }
728 TRACE(ft_t_data_flow, "\n"
729 KERN_INFO "segment size : %d\n"
730 KERN_INFO "read count : %d\n"
731 KERN_INFO "buf_pos_read : %d\n"
732 KERN_INFO "remaining : %d",
733 seg_sz, *read_cnt, pos->seg_byte_pos,
734 seg_sz - *read_cnt - pos->seg_byte_pos);
735 TRACE(ft_t_data_flow, "returning: %d", result);
736 TRACE_EXIT result;
737}
738
739/* seeks to the new data-position. Reads sometimes a segment.
740 *
741 * start_seg and end_seg give the boundaries of the current volume
742 * blk_sz is the blk_sz of the current volume as stored in the
743 * volume label
744 *
745 * We don't allow blocksizes less than 1024 bytes, therefore we don't need
746 * a 64 bit argument for new_block_pos.
747 */
748
749static int seek_in_segment(const unsigned int to_do, cmpr_info *c_info,
750 const char *src_buf, const int seg_sz,
751 const int seg_pos, const zft_volinfo *volume);
752static int slow_seek_forward_until_error(const unsigned int distance,
753 cmpr_info *c_info, zft_position *pos,
754 const zft_volinfo *volume, __u8 *buf);
755static int search_valid_segment(unsigned int segment,
756 const unsigned int end_seg,
757 const unsigned int max_foffs,
758 zft_position *pos, cmpr_info *c_info,
759 const zft_volinfo *volume, __u8 *buf);
760static int slow_seek_forward(unsigned int dest, cmpr_info *c_info,
761 zft_position *pos, const zft_volinfo *volume,
762 __u8 *buf);
763static int compute_seg_pos(unsigned int dest, zft_position *pos,
764 const zft_volinfo *volume);
765
766#define ZFT_SLOW_SEEK_THRESHOLD 10 /* segments */
767#define ZFT_FAST_SEEK_MAX_TRIALS 10 /* times */
768#define ZFT_FAST_SEEK_BACKUP 10 /* segments */
769
770static int zftc_seek(unsigned int new_block_pos,
771 zft_position *pos, const zft_volinfo *volume, __u8 *buf)
772{
773 unsigned int dest;
774 int limit;
775 int distance;
776 int result = 0;
777 int seg_dist;
778 int new_seg;
779 int old_seg = 0;
780 int fast_seek_trials = 0;
781 TRACE_FUN(ft_t_flow);
782
783 if (new_block_pos == 0) {
784 pos->seg_pos = volume->start_seg;
785 pos->seg_byte_pos = 0;
786 pos->volume_pos = 0;
787 zftc_reset();
788 TRACE_EXIT 0;
789 }
790 dest = new_block_pos * (volume->blk_sz >> 10);
791 distance = dest - (pos->volume_pos >> 10);
792 while (distance != 0) {
793 seg_dist = compute_seg_pos(dest, pos, volume);
794 TRACE(ft_t_noise, "\n"
795 KERN_INFO "seg_dist: %d\n"
796 KERN_INFO "distance: %d\n"
797 KERN_INFO "dest : %d\n"
798 KERN_INFO "vpos : %d\n"
799 KERN_INFO "seg_pos : %d\n"
800 KERN_INFO "trials : %d",
801 seg_dist, distance, dest,
802 (unsigned int)(pos->volume_pos>>10), pos->seg_pos,
803 fast_seek_trials);
804 if (distance > 0) {
805 if (seg_dist < 0) {
806 TRACE(ft_t_bug, "BUG: distance %d > 0, "
807 "segment difference %d < 0",
808 distance, seg_dist);
809 result = -EIO;
810 break;
811 }
812 new_seg = pos->seg_pos + seg_dist;
813 if (new_seg > volume->end_seg) {
814 new_seg = volume->end_seg;
815 }
816 if (old_seg == new_seg || /* loop */
817 seg_dist <= ZFT_SLOW_SEEK_THRESHOLD ||
818 fast_seek_trials >= ZFT_FAST_SEEK_MAX_TRIALS) {
819 TRACE(ft_t_noise, "starting slow seek:\n"
820 KERN_INFO "fast seek failed too often: %s\n"
821 KERN_INFO "near target position : %s\n"
822 KERN_INFO "looping between two segs : %s",
823 (fast_seek_trials >=
824 ZFT_FAST_SEEK_MAX_TRIALS)
825 ? "yes" : "no",
826 (seg_dist <= ZFT_SLOW_SEEK_THRESHOLD)
827 ? "yes" : "no",
828 (old_seg == new_seg)
829 ? "yes" : "no");
830 result = slow_seek_forward(dest, &cseg,
831 pos, volume, buf);
832 break;
833 }
834 old_seg = new_seg;
835 limit = volume->end_seg;
836 fast_seek_trials ++;
837 for (;;) {
838 result = search_valid_segment(new_seg, limit,
839 volume->size,
840 pos, &cseg,
841 volume, buf);
842 if (result == 0 || result == -EINTR) {
843 break;
844 }
845 if (new_seg == volume->start_seg) {
846 result = -EIO; /* set errror
847 * condition
848 */
849 break;
850 }
851 limit = new_seg;
852 new_seg -= ZFT_FAST_SEEK_BACKUP;
853 if (new_seg < volume->start_seg) {
854 new_seg = volume->start_seg;
855 }
856 }
857 if (result < 0) {
858 TRACE(ft_t_warn,
859 "Couldn't find a readable segment");
860 break;
861 }
862 } else /* if (distance < 0) */ {
863 if (seg_dist > 0) {
864 TRACE(ft_t_bug, "BUG: distance %d < 0, "
865 "segment difference %d >0",
866 distance, seg_dist);
867 result = -EIO;
868 break;
869 }
870 new_seg = pos->seg_pos + seg_dist;
871 if (fast_seek_trials > 0 && seg_dist == 0) {
872 /* this avoids sticking to the same
873 * segment all the time. On the other hand:
874 * if we got here for the first time, and the
875 * deblock_buffer still contains a valid
876 * segment, then there is no need to skip to
877 * the previous segment if the desired position
878 * is inside this segment.
879 */
880 new_seg --;
881 }
882 if (new_seg < volume->start_seg) {
883 new_seg = volume->start_seg;
884 }
885 limit = pos->seg_pos;
886 fast_seek_trials ++;
887 for (;;) {
888 result = search_valid_segment(new_seg, limit,
889 pos->volume_pos,
890 pos, &cseg,
891 volume, buf);
892 if (result == 0 || result == -EINTR) {
893 break;
894 }
895 if (new_seg == volume->start_seg) {
896 result = -EIO; /* set errror
897 * condition
898 */
899 break;
900 }
901 limit = new_seg;
902 new_seg -= ZFT_FAST_SEEK_BACKUP;
903 if (new_seg < volume->start_seg) {
904 new_seg = volume->start_seg;
905 }
906 }
907 if (result < 0) {
908 TRACE(ft_t_warn,
909 "Couldn't find a readable segment");
910 break;
911 }
912 }
913 distance = dest - (pos->volume_pos >> 10);
914 }
915 TRACE_EXIT result;
916}
917
918
919/* advance inside the given segment at most to_do bytes.
920 * of kilobytes moved
921 */
922
923static int seek_in_segment(const unsigned int to_do,
924 cmpr_info *c_info,
925 const char *src_buf,
926 const int seg_sz,
927 const int seg_pos,
928 const zft_volinfo *volume)
929{
930 int result = 0;
931 int blk_sz = volume->blk_sz >> 10;
932 int remaining = to_do;
933 TRACE_FUN(ft_t_flow);
934
935 if (c_info->offset == 0) {
936 /* new segment just read
937 */
938 TRACE_CATCH(get_cseg(c_info, src_buf, seg_sz, volume),);
939 c_info->cmpr_pos += c_info->count;
940 DUMP_CMPR_INFO(ft_t_noise, "", c_info);
941 }
942 /* loop and uncompress until user buffer full or
943 * deblock-buffer empty
944 */
945 TRACE(ft_t_noise, "compressed_sz: %d, compos : %d",
946 c_info->cmpr_sz, c_info->cmpr_pos);
947 while (c_info->spans == 0 && remaining > 0) {
948 if (c_info->cmpr_pos != 0) { /* cmpr buf is not empty */
949 result += blk_sz;
950 remaining -= blk_sz;
951 c_info->cmpr_pos = 0;
952 }
953 if (remaining > 0) {
954 get_next_cluster(c_info, src_buf, seg_sz,
955 volume->end_seg == seg_pos);
956 if (c_info->count != 0) {
957 c_info->cmpr_pos = c_info->count;
958 c_info->offset += c_info->count;
959 } else {
960 break;
961 }
962 }
963 /* Allow escape from this loop on signal!
964 */
965 FT_SIGNAL_EXIT(_DONT_BLOCK);
966 DUMP_CMPR_INFO(ft_t_noise, "", c_info);
967 TRACE(ft_t_noise, "to_do: %d", remaining);
968 }
969 if (seg_sz - c_info->offset <= 18) {
970 c_info->offset = seg_sz;
971 }
972 TRACE(ft_t_noise, "\n"
973 KERN_INFO "segment size : %d\n"
974 KERN_INFO "buf_pos_read : %d\n"
975 KERN_INFO "remaining : %d",
976 seg_sz, c_info->offset,
977 seg_sz - c_info->offset);
978 TRACE_EXIT result;
979}
980
981static int slow_seek_forward_until_error(const unsigned int distance,
982 cmpr_info *c_info,
983 zft_position *pos,
984 const zft_volinfo *volume,
985 __u8 *buf)
986{
987 unsigned int remaining = distance;
988 int seg_sz;
989 int seg_pos;
990 int result;
991 TRACE_FUN(ft_t_flow);
992
993 seg_pos = pos->seg_pos;
994 do {
995 TRACE_CATCH(seg_sz = zft_fetch_segment(seg_pos, buf,
996 FT_RD_AHEAD),);
997 /* now we have the contents of the actual segment in
998 * the deblock buffer
999 */
1000 TRACE_CATCH(result = seek_in_segment(remaining, c_info, buf,
1001 seg_sz, seg_pos,volume),);
1002 remaining -= result;
1003 pos->volume_pos += result<<10;
1004 pos->seg_pos = seg_pos;
1005 pos->seg_byte_pos = c_info->offset;
1006 seg_pos ++;
1007 if (seg_pos <= volume->end_seg && c_info->offset == seg_sz) {
1008 pos->seg_pos ++;
1009 pos->seg_byte_pos = 0;
1010 c_info->offset = 0;
1011 }
1012 /* Allow escape from this loop on signal!
1013 */
1014 FT_SIGNAL_EXIT(_DONT_BLOCK);
1015 TRACE(ft_t_noise, "\n"
1016 KERN_INFO "remaining: %d\n"
1017 KERN_INFO "seg_pos: %d\n"
1018 KERN_INFO "end_seg: %d\n"
1019 KERN_INFO "result: %d",
1020 remaining, seg_pos, volume->end_seg, result);
1021 } while (remaining > 0 && seg_pos <= volume->end_seg);
1022 TRACE_EXIT 0;
1023}
1024
1025/* return segment id of next segment containing valid data, -EIO otherwise
1026 */
1027static int search_valid_segment(unsigned int segment,
1028 const unsigned int end_seg,
1029 const unsigned int max_foffs,
1030 zft_position *pos,
1031 cmpr_info *c_info,
1032 const zft_volinfo *volume,
1033 __u8 *buf)
1034{
1035 cmpr_info tmp_info;
1036 int seg_sz;
1037 TRACE_FUN(ft_t_flow);
1038
1039 memset(&tmp_info, 0, sizeof(cmpr_info));
1040 while (segment <= end_seg) {
1041 FT_SIGNAL_EXIT(_DONT_BLOCK);
1042 TRACE(ft_t_noise,
1043 "Searching readable segment between %d and %d",
1044 segment, end_seg);
1045 seg_sz = zft_fetch_segment(segment, buf, FT_RD_AHEAD);
1046 if ((seg_sz > 0) &&
1047 (get_cseg (&tmp_info, buf, seg_sz, volume) >= 0) &&
1048 (tmp_info.foffs != 0 || segment == volume->start_seg)) {
1049 if ((tmp_info.foffs>>10) > max_foffs) {
1050 TRACE_ABORT(-EIO, ft_t_noise, "\n"
1051 KERN_INFO "cseg.foff: %d\n"
1052 KERN_INFO "dest : %d",
1053 (int)(tmp_info.foffs >> 10),
1054 max_foffs);
1055 }
1056 DUMP_CMPR_INFO(ft_t_noise, "", &tmp_info);
1057 *c_info = tmp_info;
1058 pos->seg_pos = segment;
1059 pos->volume_pos = c_info->foffs;
1060 pos->seg_byte_pos = c_info->offset;
1061 TRACE(ft_t_noise, "found segment at %d", segment);
1062 TRACE_EXIT 0;
1063 }
1064 segment++;
1065 }
1066 TRACE_EXIT -EIO;
1067}
1068
1069static int slow_seek_forward(unsigned int dest,
1070 cmpr_info *c_info,
1071 zft_position *pos,
1072 const zft_volinfo *volume,
1073 __u8 *buf)
1074{
1075 unsigned int distance;
1076 int result = 0;
1077 TRACE_FUN(ft_t_flow);
1078
1079 distance = dest - (pos->volume_pos >> 10);
1080 while ((distance > 0) &&
1081 (result = slow_seek_forward_until_error(distance,
1082 c_info,
1083 pos,
1084 volume,
1085 buf)) < 0) {
1086 if (result == -EINTR) {
1087 break;
1088 }
1089 TRACE(ft_t_noise, "seg_pos: %d", pos->seg_pos);
1090 /* the failing segment is either pos->seg_pos or
1091 * pos->seg_pos + 1. There is no need to further try
1092 * that segment, because ftape_read_segment() already
1093 * has tried very much to read it. So we start with
1094 * following segment, which is pos->seg_pos + 1
1095 */
1096 if(search_valid_segment(pos->seg_pos+1, volume->end_seg, dest,
1097 pos, c_info,
1098 volume, buf) < 0) {
1099 TRACE(ft_t_noise, "search_valid_segment() failed");
1100 result = -EIO;
1101 break;
1102 }
1103 distance = dest - (pos->volume_pos >> 10);
1104 result = 0;
1105 TRACE(ft_t_noise, "segment: %d", pos->seg_pos);
1106 /* found valid segment, retry the seek */
1107 }
1108 TRACE_EXIT result;
1109}
1110
1111static int compute_seg_pos(const unsigned int dest,
1112 zft_position *pos,
1113 const zft_volinfo *volume)
1114{
1115 int segment;
1116 int distance = dest - (pos->volume_pos >> 10);
1117 unsigned int raw_size;
1118 unsigned int virt_size;
1119 unsigned int factor;
1120 TRACE_FUN(ft_t_flow);
1121
1122 if (distance >= 0) {
1123 raw_size = volume->end_seg - pos->seg_pos + 1;
1124 virt_size = ((unsigned int)(volume->size>>10)
1125 - (unsigned int)(pos->volume_pos>>10)
1126 + FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS - 1);
1127 virt_size /= FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS;
1128 if (virt_size == 0 || raw_size == 0) {
1129 TRACE_EXIT 0;
1130 }
1131 if (raw_size >= (1<<25)) {
1132 factor = raw_size/(virt_size>>7);
1133 } else {
1134 factor = (raw_size<<7)/virt_size;
1135 }
1136 segment = distance/(FT_SECTORS_PER_SEGMENT-FT_ECC_SECTORS);
1137 segment = (segment * factor)>>7;
1138 } else {
1139 raw_size = pos->seg_pos - volume->start_seg + 1;
1140 virt_size = ((unsigned int)(pos->volume_pos>>10)
1141 + FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS - 1);
1142 virt_size /= FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS;
1143 if (virt_size == 0 || raw_size == 0) {
1144 TRACE_EXIT 0;
1145 }
1146 if (raw_size >= (1<<25)) {
1147 factor = raw_size/(virt_size>>7);
1148 } else {
1149 factor = (raw_size<<7)/virt_size;
1150 }
1151 segment = distance/(FT_SECTORS_PER_SEGMENT-FT_ECC_SECTORS);
1152 }
1153 TRACE(ft_t_noise, "factor: %d/%d", factor, 1<<7);
1154 TRACE_EXIT segment;
1155}
1156
1157static struct zft_cmpr_ops cmpr_ops = {
1158 zftc_write,
1159 zftc_read,
1160 zftc_seek,
1161 zftc_lock,
1162 zftc_reset,
1163 zftc_cleanup
1164};
1165
1166int zft_compressor_init(void)
1167{
1168 TRACE_FUN(ft_t_flow);
1169
1170#ifdef MODULE
1171 printk(KERN_INFO "zftape compressor v1.00a 970514 for " FTAPE_VERSION "\n");
1172 if (TRACE_LEVEL >= ft_t_info) {
1173 printk(
1174KERN_INFO "(c) 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
1175KERN_INFO "Compressor for zftape (lzrw3 algorithm)\n");
1176 }
1177#else /* !MODULE */
1178 /* print a short no-nonsense boot message */
1179 printk(KERN_INFO "zftape compressor v1.00a 970514\n");
1180 printk(KERN_INFO "For use with " FTAPE_VERSION "\n");
1181#endif /* MODULE */
1182 TRACE(ft_t_info, "zft_compressor_init @ 0x%p", zft_compressor_init);
1183 TRACE(ft_t_info, "installing compressor for zftape ...");
1184 TRACE_CATCH(zft_cmpr_register(&cmpr_ops),);
1185 TRACE_EXIT 0;
1186}
1187
1188#ifdef MODULE
1189
1190MODULE_AUTHOR(
1191 "(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de");
1192MODULE_DESCRIPTION(
1193"Compression routines for zftape. Uses the lzrw3 algorithm by Ross Williams");
1194MODULE_LICENSE("GPL");
1195
1196/* Called by modules package when installing the driver
1197 */
1198int init_module(void)
1199{
1200 return zft_compressor_init();
1201}
1202
1203#endif /* MODULE */
diff --git a/drivers/char/ftape/compressor/zftape-compress.h b/drivers/char/ftape/compressor/zftape-compress.h
deleted file mode 100644
index f200741e33bf..000000000000
--- a/drivers/char/ftape/compressor/zftape-compress.h
+++ /dev/null
@@ -1,83 +0,0 @@
1#ifndef _ZFTAPE_COMPRESS_H
2#define _ZFTAPE_COMPRESS_H
3/*
4 * Copyright (c) 1994-1997 Claus-Justus Heine
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2, or (at
9 your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 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; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19 USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/compressor/zftape-compress.h,v $
23 * $Revision: 1.1 $
24 * $Date: 1997/10/05 19:12:32 $
25 *
26 * This file contains macros and definitions for zftape's
27 * builtin compression code.
28 *
29 */
30
31#include "../zftape/zftape-buffers.h"
32#include "../zftape/zftape-vtbl.h"
33#include "../compressor/lzrw3.h"
34
35/* CMPR_WRK_MEM_SIZE gives the size of the compression wrk_mem */
36/* I got these out of lzrw3.c */
37#define U(X) ((__u32) X)
38#define SIZE_P_BYTE (U(sizeof(__u8 *)))
39#define ALIGNMENT_FUDGE (U(16))
40
41#define CMPR_WRK_MEM_SIZE (U(4096)*(SIZE_P_BYTE) + ALIGNMENT_FUDGE)
42
43/* the maximum number of bytes the size of the "compressed" data can
44 * exceed the uncompressed data. As it is quite useless to compress
45 * data twice it is sometimes the case that it is more efficient to
46 * copy a block of data but to feed it to the "compression"
47 * algorithm. In this case there are some flag bytes or the like
48 * proceding the "compressed" data. THAT MUST NOT BE THE CASE for the
49 * algorithm we use for this driver. Instead, the high bit 15 of
50 * compressed_size:
51 *
52 * compressed_size = ftape_compress()
53 *
54 * must be set in such a case.
55 *
56 * Nevertheless, it might also be as for lzrw3 that there is an
57 * "intermediate" overrun that exceeds the amount of the compressed
58 * data that is actually produced. During the algorithm we need in the
59 * worst case MAX_CMP_GROUP bytes more than the input-size.
60 */
61#define MAX_CMP_GROUP (2+16*2) /* from lzrw3.c */
62
63#define CMPR_OVERRUN MAX_CMP_GROUP /* during compression */
64
65/****************************************************/
66
67#define CMPR_BUFFER_SIZE (MAX_BLOCK_SIZE + CMPR_OVERRUN)
68
69/* the compression map stores the byte offset compressed blocks within
70 * the current volume for catridges with format code 2,3 and 5
71 * (and old versions of zftape) and the offset measured in kilobytes for
72 * format code 4 and 6. This gives us a possible max. size of a
73 * compressed volume of 1024*4GIG which should be enough.
74 */
75typedef __u32 CmprMap;
76
77/* globals
78 */
79
80/* exported functions
81 */
82
83#endif /* _ZFTAPE_COMPRESS_H */
diff --git a/drivers/char/ftape/lowlevel/Makefile b/drivers/char/ftape/lowlevel/Makefile
deleted file mode 100644
index febab07ba427..000000000000
--- a/drivers/char/ftape/lowlevel/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
1#
2# Copyright (C) 1996, 1997 Clau-Justus Heine.
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 as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to
16# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17#
18# $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/Makefile,v $
19# $Revision: 1.4 $
20# $Date: 1997/10/07 09:26:02 $
21#
22# Makefile for the lowlevel part QIC-40/80/3010/3020 floppy-tape
23# driver for Linux.
24#
25
26obj-$(CONFIG_FTAPE) += ftape.o
27
28ftape-objs := ftape-init.o fdc-io.o fdc-isr.o \
29 ftape-bsm.o ftape-ctl.o ftape-read.o ftape-rw.o \
30 ftape-write.o ftape-io.o ftape-calibr.o ftape-ecc.o fc-10.o \
31 ftape-buffer.o ftape-format.o ftape_syms.o
32
33ifeq ($(CONFIG_FTAPE),y)
34ftape-objs += ftape-setup.o
35endif
36
37ifndef CONFIG_FT_NO_TRACE_AT_ALL
38ftape-objs += ftape-tracing.o
39endif
40
41ifeq ($(CONFIG_FT_PROC_FS),y)
42ftape-objs += ftape-proc.o
43endif
diff --git a/drivers/char/ftape/lowlevel/fc-10.c b/drivers/char/ftape/lowlevel/fc-10.c
deleted file mode 100644
index 9bc1cddade76..000000000000
--- a/drivers/char/ftape/lowlevel/fc-10.c
+++ /dev/null
@@ -1,175 +0,0 @@
1/*
2 *
3
4 Copyright (C) 1993,1994 Jon Tombs.
5
6 This program is distributed in the hope that it will be useful,
7 but WITHOUT ANY WARRANTY; without even the implied warranty of
8 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 GNU General Public License for more details.
10
11 The entire guts of this program was written by dosemu, modified to
12 record reads and writes to the ports in the 0x180-0x188 address space,
13 while running the CMS program TAPE.EXE V2.0.5 supplied with the drive.
14
15 Modified to use an array of addresses and generally cleaned up (made
16 much shorter) 4 June 94, dosemu isn't that good at writing short code it
17 would seem :-). Made independent of 0x180, but I doubt it will work
18 at any other address.
19
20 Modified for distribution with ftape source. 21 June 94, SJL.
21
22 Modifications on 20 October 95, by Daniel Cohen (catman@wpi.edu):
23 Modified to support different DMA, IRQ, and IO Ports. Borland's
24 Turbo Debugger in virtual 8086 mode (TD386.EXE with hardware breakpoints
25 provided by the TDH386.SYS Device Driver) was used on the CMS program
26 TAPE V4.0.5. I set breakpoints on I/O to ports 0x180-0x187. Note that
27 CMS's program will not successfully configure the tape drive if you set
28 breakpoints on IO Reads, but you can set them on IO Writes without problems.
29 Known problems:
30 - You can not use DMA Channels 5 or 7.
31
32 Modification on 29 January 96, by Daniel Cohen (catman@wpi.edu):
33 Modified to only accept IRQs 3 - 7, or 9. Since we can only send a 3 bit
34 number representing the IRQ to the card, special handling is required when
35 IRQ 9 is selected. IRQ 2 and 9 are the same, and we should request IRQ 9
36 from the kernel while telling the card to use IRQ 2. Thanks to Greg
37 Crider (gcrider@iclnet.org) for finding and locating this bug, as well as
38 testing the patch.
39
40 Modification on 11 December 96, by Claus Heine (claus@momo.math.rwth-aachen.de):
41 Modified a little to use variahle ft_fdc_base, ft_fdc_irq, ft_fdc_dma
42 instead of preprocessor symbols. Thus we can compile this into the module
43 or kernel and let the user specify the options as command line arguments.
44
45 *
46 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fc-10.c,v $
47 * $Revision: 1.2 $
48 * $Date: 1997/10/05 19:18:04 $
49 *
50 * This file contains code for the CMS FC-10/FC-20 card.
51 */
52
53#include <asm/io.h>
54#include <linux/ftape.h>
55#include "../lowlevel/ftape-tracing.h"
56#include "../lowlevel/fdc-io.h"
57#include "../lowlevel/fc-10.h"
58
59static __u16 inbs_magic[] = {
60 0x3, 0x3, 0x0, 0x4, 0x7, 0x2, 0x5, 0x3, 0x1, 0x4,
61 0x3, 0x5, 0x2, 0x0, 0x3, 0x7, 0x4, 0x2,
62 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7
63};
64
65static __u16 fc10_ports[] = {
66 0x180, 0x210, 0x2A0, 0x300, 0x330, 0x340, 0x370
67};
68
69int fc10_enable(void)
70{
71 int i;
72 __u8 cardConfig = 0x00;
73 __u8 x;
74 TRACE_FUN(ft_t_flow);
75
76/* This code will only work if the FC-10 (or FC-20) is set to
77 * use DMA channels 1, 2, or 3. DMA channels 5 and 7 seem to be
78 * initialized by the same command as channels 1 and 3, respectively.
79 */
80 if (ft_fdc_dma > 3) {
81 TRACE_ABORT(0, ft_t_err,
82"Error: The FC-10/20 must be set to use DMA channels 1, 2, or 3!");
83 }
84/* Only allow the FC-10/20 to use IRQ 3-7, or 9. Note that CMS's program
85 * only accepts IRQ's 2-7, but in linux, IRQ 2 is the same as IRQ 9.
86 */
87 if (ft_fdc_irq < 3 || ft_fdc_irq == 8 || ft_fdc_irq > 9) {
88 TRACE_ABORT(0, ft_t_err,
89"Error: The FC-10/20 must be set to use IRQ levels 3 - 7, or 9!\n"
90KERN_INFO "Note: IRQ 9 is the same as IRQ 2");
91 }
92 /* Clear state machine ???
93 */
94 for (i = 0; i < NR_ITEMS(inbs_magic); i++) {
95 inb(ft_fdc_base + inbs_magic[i]);
96 }
97 outb(0x0, ft_fdc_base);
98
99 x = inb(ft_fdc_base);
100 if (x == 0x13 || x == 0x93) {
101 for (i = 1; i < 8; i++) {
102 if (inb(ft_fdc_base + i) != x) {
103 TRACE_EXIT 0;
104 }
105 }
106 } else {
107 TRACE_EXIT 0;
108 }
109
110 outb(0x8, ft_fdc_base);
111
112 for (i = 0; i < 8; i++) {
113 if (inb(ft_fdc_base + i) != 0x0) {
114 TRACE_EXIT 0;
115 }
116 }
117 outb(0x10, ft_fdc_base);
118
119 for (i = 0; i < 8; i++) {
120 if (inb(ft_fdc_base + i) != 0xff) {
121 TRACE_EXIT 0;
122 }
123 }
124
125 /* Okay, we found a FC-10 card ! ???
126 */
127 outb(0x0, fdc.ccr);
128
129 /* Clear state machine again ???
130 */
131 for (i = 0; i < NR_ITEMS(inbs_magic); i++) {
132 inb(ft_fdc_base + inbs_magic[i]);
133 }
134 /* Send io port */
135 for (i = 0; i < NR_ITEMS(fc10_ports); i++)
136 if (ft_fdc_base == fc10_ports[i])
137 cardConfig = i + 1;
138 if (cardConfig == 0) {
139 TRACE_EXIT 0; /* Invalid I/O Port */
140 }
141 /* and IRQ - If using IRQ 9, tell the FC card it is actually IRQ 2 */
142 if (ft_fdc_irq != 9)
143 cardConfig |= ft_fdc_irq << 3;
144 else
145 cardConfig |= 2 << 3;
146
147 /* and finally DMA Channel */
148 cardConfig |= ft_fdc_dma << 6;
149 outb(cardConfig, ft_fdc_base); /* DMA [2 bits]/IRQ [3 bits]/BASE [3 bits] */
150
151 /* Enable FC-10 ???
152 */
153 outb(0, fdc.ccr);
154 outb(0, fdc.dor2);
155 outb(FDC_DMA_MODE /* 8 */, fdc.dor);
156 outb(FDC_DMA_MODE /* 8 */, fdc.dor);
157 outb(1, fdc.dor2);
158
159 /*************************************
160 *
161 * cH: why the hell should this be necessary? This is done
162 * by fdc_reset()!!!
163 *
164 *************************************/
165 /* Initialize fdc, select drive B:
166 */
167 outb(FDC_DMA_MODE, fdc.dor); /* assert reset, dma & irq enabled */
168 /* 0x08 */
169 outb(FDC_DMA_MODE|FDC_RESET_NOT, fdc.dor); /* release reset */
170 /* 0x08 | 0x04 = 0x0c */
171 outb(FDC_DMA_MODE|FDC_RESET_NOT|FDC_MOTOR_1|FTAPE_SEL_B, fdc.dor);
172 /* 0x08 | 0x04 | 0x20 | 0x01 = 0x2d */
173 /* select drive 1 */ /* why not drive 0 ???? */
174 TRACE_EXIT (x == 0x93) ? 2 : 1;
175}
diff --git a/drivers/char/ftape/lowlevel/fc-10.h b/drivers/char/ftape/lowlevel/fc-10.h
deleted file mode 100644
index da7b88bca889..000000000000
--- a/drivers/char/ftape/lowlevel/fc-10.h
+++ /dev/null
@@ -1,39 +0,0 @@
1#ifndef _FC_10_H
2#define _FC_10_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fc-10.h,v $
23 * $Revision: 1.1 $
24 * $Date: 1997/09/19 09:05:22 $
25 *
26 * This file contains definitions for the FC-10 code
27 * of the QIC-40/80 floppy-tape driver for Linux.
28 */
29
30/*
31 * fc-10.c defined global vars.
32 */
33
34/*
35 * fc-10.c defined global functions.
36 */
37extern int fc10_enable(void);
38
39#endif
diff --git a/drivers/char/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c
deleted file mode 100644
index bbcf918f056f..000000000000
--- a/drivers/char/ftape/lowlevel/fdc-io.c
+++ /dev/null
@@ -1,1349 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-io.c,v $
21 * $Revision: 1.7.4.2 $
22 * $Date: 1997/11/16 14:48:17 $
23 *
24 * This file contains the low-level floppy disk interface code
25 * for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for
26 * Linux.
27 */
28
29#include <linux/errno.h>
30#include <linux/sched.h>
31#include <linux/ioport.h>
32#include <linux/interrupt.h>
33#include <linux/kernel.h>
34#include <asm/system.h>
35#include <asm/io.h>
36#include <asm/dma.h>
37#include <asm/irq.h>
38
39#include <linux/ftape.h>
40#include <linux/qic117.h>
41#include "../lowlevel/ftape-tracing.h"
42#include "../lowlevel/fdc-io.h"
43#include "../lowlevel/fdc-isr.h"
44#include "../lowlevel/ftape-io.h"
45#include "../lowlevel/ftape-rw.h"
46#include "../lowlevel/ftape-ctl.h"
47#include "../lowlevel/ftape-calibr.h"
48#include "../lowlevel/fc-10.h"
49
50/* Global vars.
51 */
52static int ftape_motor;
53volatile int ftape_current_cylinder = -1;
54volatile fdc_mode_enum fdc_mode = fdc_idle;
55fdc_config_info fdc;
56DECLARE_WAIT_QUEUE_HEAD(ftape_wait_intr);
57
58unsigned int ft_fdc_base = CONFIG_FT_FDC_BASE;
59unsigned int ft_fdc_irq = CONFIG_FT_FDC_IRQ;
60unsigned int ft_fdc_dma = CONFIG_FT_FDC_DMA;
61unsigned int ft_fdc_threshold = CONFIG_FT_FDC_THR; /* bytes */
62unsigned int ft_fdc_rate_limit = CONFIG_FT_FDC_MAX_RATE; /* bits/sec */
63int ft_probe_fc10 = CONFIG_FT_PROBE_FC10;
64int ft_mach2 = CONFIG_FT_MACH2;
65
66/* Local vars.
67 */
68static spinlock_t fdc_io_lock;
69static unsigned int fdc_calibr_count;
70static unsigned int fdc_calibr_time;
71static int fdc_status;
72volatile __u8 fdc_head; /* FDC head from sector id */
73volatile __u8 fdc_cyl; /* FDC track from sector id */
74volatile __u8 fdc_sect; /* FDC sector from sector id */
75static int fdc_data_rate = 500; /* data rate (Kbps) */
76static int fdc_rate_code; /* data rate code (0 == 500 Kbps) */
77static int fdc_seek_rate = 2; /* step rate (msec) */
78static void (*do_ftape) (void);
79static int fdc_fifo_state; /* original fifo setting - fifo enabled */
80static int fdc_fifo_thr; /* original fifo setting - threshold */
81static int fdc_lock_state; /* original lock setting - locked */
82static int fdc_fifo_locked; /* has fifo && lock set ? */
83static __u8 fdc_precomp; /* default precomp. value (nsec) */
84static __u8 fdc_prec_code; /* fdc precomp. select code */
85
86static char ftape_id[] = "ftape"; /* used by request irq and free irq */
87
88static int fdc_set_seek_rate(int seek_rate);
89
90void fdc_catch_stray_interrupts(int count)
91{
92 unsigned long flags;
93
94 spin_lock_irqsave(&fdc_io_lock, flags);
95 if (count == 0) {
96 ft_expected_stray_interrupts = 0;
97 } else {
98 ft_expected_stray_interrupts += count;
99 }
100 spin_unlock_irqrestore(&fdc_io_lock, flags);
101}
102
103/* Wait during a timeout period for a given FDC status.
104 * If usecs == 0 then just test status, else wait at least for usecs.
105 * Returns -ETIME on timeout. Function must be calibrated first !
106 */
107static int fdc_wait(unsigned int usecs, __u8 mask, __u8 state)
108{
109 int count_1 = (fdc_calibr_count * usecs +
110 fdc_calibr_count - 1) / fdc_calibr_time;
111
112 do {
113 fdc_status = inb_p(fdc.msr);
114 if ((fdc_status & mask) == state) {
115 return 0;
116 }
117 } while (count_1-- >= 0);
118 return -ETIME;
119}
120
121int fdc_ready_wait(unsigned int usecs)
122{
123 return fdc_wait(usecs, FDC_DATA_READY | FDC_BUSY, FDC_DATA_READY);
124}
125
126/* Why can't we just use udelay()?
127 */
128static void fdc_usec_wait(unsigned int usecs)
129{
130 fdc_wait(usecs, 0, 1); /* will always timeout ! */
131}
132
133static int fdc_ready_out_wait(unsigned int usecs)
134{
135 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
136 return fdc_wait(usecs, FDC_DATA_OUT_READY, FDC_DATA_OUT_READY);
137}
138
139void fdc_wait_calibrate(void)
140{
141 ftape_calibrate("fdc_wait",
142 fdc_usec_wait, &fdc_calibr_count, &fdc_calibr_time);
143}
144
145/* Wait for a (short) while for the FDC to become ready
146 * and transfer the next command byte.
147 * Return -ETIME on timeout on getting ready (depends on hardware!).
148 */
149static int fdc_write(const __u8 data)
150{
151 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
152 if (fdc_wait(150, FDC_DATA_READY_MASK, FDC_DATA_IN_READY) < 0) {
153 return -ETIME;
154 } else {
155 outb(data, fdc.fifo);
156 return 0;
157 }
158}
159
160/* Wait for a (short) while for the FDC to become ready
161 * and transfer the next result byte.
162 * Return -ETIME if timeout on getting ready (depends on hardware!).
163 */
164static int fdc_read(__u8 * data)
165{
166 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
167 if (fdc_wait(150, FDC_DATA_READY_MASK, FDC_DATA_OUT_READY) < 0) {
168 return -ETIME;
169 } else {
170 *data = inb(fdc.fifo);
171 return 0;
172 }
173}
174
175/* Output a cmd_len long command string to the FDC.
176 * The FDC should be ready to receive a new command or
177 * an error (EBUSY or ETIME) will occur.
178 */
179int fdc_command(const __u8 * cmd_data, int cmd_len)
180{
181 int result = 0;
182 unsigned long flags;
183 int count = cmd_len;
184 int retry = 0;
185#ifdef TESTING
186 static unsigned int last_time;
187 unsigned int time;
188#endif
189 TRACE_FUN(ft_t_any);
190
191 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
192 spin_lock_irqsave(&fdc_io_lock, flags);
193 if (!in_interrupt())
194 /* Yes, I know, too much comments inside this function
195 * ...
196 *
197 * Yet another bug in the original driver. All that
198 * havoc is caused by the fact that the isr() sends
199 * itself a command to the floppy tape driver (pause,
200 * micro step pause). Now, the problem is that
201 * commands are transmitted via the fdc_seek
202 * command. But: the fdc performs seeks in the
203 * background i.e. it doesn't signal busy while
204 * sending the step pulses to the drive. Therefore the
205 * non-interrupt level driver has no chance to tell
206 * whether the isr() just has issued a seek. Therefore
207 * we HAVE TO have a look at the ft_hide_interrupt
208 * flag: it signals the non-interrupt level part of
209 * the driver that it has to wait for the fdc until it
210 * has completet seeking.
211 *
212 * THIS WAS PRESUMABLY THE REASON FOR ALL THAT
213 * "fdc_read timeout" errors, I HOPE :-)
214 */
215 if (ft_hide_interrupt) {
216 restore_flags(flags);
217 TRACE(ft_t_info,
218 "Waiting for the isr() completing fdc_seek()");
219 if (fdc_interrupt_wait(2 * FT_SECOND) < 0) {
220 TRACE(ft_t_warn,
221 "Warning: timeout waiting for isr() seek to complete");
222 }
223 if (ft_hide_interrupt || !ft_seek_completed) {
224 /* There cannot be another
225 * interrupt. The isr() only stops
226 * the tape and the next interrupt
227 * won't come until we have send our
228 * command to the drive.
229 */
230 TRACE_ABORT(-EIO, ft_t_bug,
231 "BUG? isr() is still seeking?\n"
232 KERN_INFO "hide: %d\n"
233 KERN_INFO "seek: %d",
234 ft_hide_interrupt,
235 ft_seek_completed);
236
237 }
238 fdc_usec_wait(FT_RQM_DELAY); /* wait for valid RQM status */
239 spin_lock_irqsave(&fdc_io_lock, flags);
240 }
241 fdc_status = inb(fdc.msr);
242 if ((fdc_status & FDC_DATA_READY_MASK) != FDC_DATA_IN_READY) {
243 spin_unlock_irqrestore(&fdc_io_lock, flags);
244 TRACE_ABORT(-EBUSY, ft_t_err, "fdc not ready");
245 }
246 fdc_mode = *cmd_data; /* used by isr */
247#ifdef TESTING
248 if (fdc_mode == FDC_SEEK) {
249 time = ftape_timediff(last_time, ftape_timestamp());
250 if (time < 6000) {
251 TRACE(ft_t_bug,"Warning: short timeout between seek commands: %d",
252 time);
253 }
254 }
255#endif
256 if (!in_interrupt()) {
257 /* shouldn't be cleared if called from isr
258 */
259 ft_interrupt_seen = 0;
260 }
261 while (count) {
262 result = fdc_write(*cmd_data);
263 if (result < 0) {
264 TRACE(ft_t_fdc_dma,
265 "fdc_mode = %02x, status = %02x at index %d",
266 (int) fdc_mode, (int) fdc_status,
267 cmd_len - count);
268 if (++retry <= 3) {
269 TRACE(ft_t_warn, "fdc_write timeout, retry");
270 } else {
271 TRACE(ft_t_err, "fdc_write timeout, fatal");
272 /* recover ??? */
273 break;
274 }
275 } else {
276 --count;
277 ++cmd_data;
278 }
279 }
280#ifdef TESTING
281 if (fdc_mode == FDC_SEEK) {
282 last_time = ftape_timestamp();
283 }
284#endif
285 spin_unlock_irqrestore(&fdc_io_lock, flags);
286 TRACE_EXIT result;
287}
288
289/* Input a res_len long result string from the FDC.
290 * The FDC should be ready to send the result or an error
291 * (EBUSY or ETIME) will occur.
292 */
293int fdc_result(__u8 * res_data, int res_len)
294{
295 int result = 0;
296 unsigned long flags;
297 int count = res_len;
298 int retry = 0;
299 TRACE_FUN(ft_t_any);
300
301 spin_lock_irqsave(&fdc_io_lock, flags);
302 fdc_status = inb(fdc.msr);
303 if ((fdc_status & FDC_DATA_READY_MASK) != FDC_DATA_OUT_READY) {
304 TRACE(ft_t_err, "fdc not ready");
305 result = -EBUSY;
306 } else while (count) {
307 if (!(fdc_status & FDC_BUSY)) {
308 spin_unlock_irqrestore(&fdc_io_lock, flags);
309 TRACE_ABORT(-EIO, ft_t_err, "premature end of result phase");
310 }
311 result = fdc_read(res_data);
312 if (result < 0) {
313 TRACE(ft_t_fdc_dma,
314 "fdc_mode = %02x, status = %02x at index %d",
315 (int) fdc_mode,
316 (int) fdc_status,
317 res_len - count);
318 if (++retry <= 3) {
319 TRACE(ft_t_warn, "fdc_read timeout, retry");
320 } else {
321 TRACE(ft_t_err, "fdc_read timeout, fatal");
322 /* recover ??? */
323 break;
324 ++retry;
325 }
326 } else {
327 --count;
328 ++res_data;
329 }
330 }
331 spin_unlock_irqrestore(&fdc_io_lock, flags);
332 fdc_usec_wait(FT_RQM_DELAY); /* allow FDC to negate BSY */
333 TRACE_EXIT result;
334}
335
336/* Handle command and result phases for
337 * commands without data phase.
338 */
339static int fdc_issue_command(const __u8 * out_data, int out_count,
340 __u8 * in_data, int in_count)
341{
342 TRACE_FUN(ft_t_any);
343
344 if (out_count > 0) {
345 TRACE_CATCH(fdc_command(out_data, out_count),);
346 }
347 /* will take 24 - 30 usec for fdc_sense_drive_status and
348 * fdc_sense_interrupt_status commands.
349 * 35 fails sometimes (5/9/93 SJL)
350 * On a loaded system it incidentally takes longer than
351 * this for the fdc to get ready ! ?????? WHY ??????
352 * So until we know what's going on use a very long timeout.
353 */
354 TRACE_CATCH(fdc_ready_out_wait(500 /* usec */),);
355 if (in_count > 0) {
356 TRACE_CATCH(fdc_result(in_data, in_count),
357 TRACE(ft_t_err, "result phase aborted"));
358 }
359 TRACE_EXIT 0;
360}
361
362/* Wait for FDC interrupt with timeout (in milliseconds).
363 * Signals are blocked so the wait will not be aborted.
364 * Note: interrupts must be enabled ! (23/05/93 SJL)
365 */
366int fdc_interrupt_wait(unsigned int time)
367{
368 DECLARE_WAITQUEUE(wait,current);
369 sigset_t old_sigmask;
370 static int resetting;
371 long timeout;
372
373 TRACE_FUN(ft_t_fdc_dma);
374
375 if (waitqueue_active(&ftape_wait_intr)) {
376 TRACE_ABORT(-EIO, ft_t_err, "error: nested call");
377 }
378 /* timeout time will be up to USPT microseconds too long ! */
379 timeout = (1000 * time + FT_USPT - 1) / FT_USPT;
380
381 spin_lock_irq(&current->sighand->siglock);
382 old_sigmask = current->blocked;
383 sigfillset(&current->blocked);
384 recalc_sigpending();
385 spin_unlock_irq(&current->sighand->siglock);
386
387 set_current_state(TASK_INTERRUPTIBLE);
388 add_wait_queue(&ftape_wait_intr, &wait);
389 while (!ft_interrupt_seen && timeout)
390 timeout = schedule_timeout_interruptible(timeout);
391
392 spin_lock_irq(&current->sighand->siglock);
393 current->blocked = old_sigmask;
394 recalc_sigpending();
395 spin_unlock_irq(&current->sighand->siglock);
396
397 remove_wait_queue(&ftape_wait_intr, &wait);
398 /* the following IS necessary. True: as well
399 * wake_up_interruptible() as the schedule() set TASK_RUNNING
400 * when they wakeup a task, BUT: it may very well be that
401 * ft_interrupt_seen is already set to 1 when we enter here
402 * in which case schedule() gets never called, and
403 * TASK_RUNNING never set. This has the funny effect that we
404 * execute all the code until we leave kernel space, but then
405 * the task is stopped (a task CANNOT be preempted while in
406 * kernel mode. Sending a pair of SIGSTOP/SIGCONT to the
407 * tasks wakes it up again. Funny! :-)
408 */
409 current->state = TASK_RUNNING;
410 if (ft_interrupt_seen) { /* woken up by interrupt */
411 ft_interrupt_seen = 0;
412 TRACE_EXIT 0;
413 }
414 /* Original comment:
415 * In first instance, next statement seems unnecessary since
416 * it will be cleared in fdc_command. However, a small part of
417 * the software seems to rely on this being cleared here
418 * (ftape_close might fail) so stick to it until things get fixed !
419 */
420 /* My deeply sought of knowledge:
421 * Behold NO! It is obvious. fdc_reset() doesn't call fdc_command()
422 * but nevertheless uses fdc_interrupt_wait(). OF COURSE this needs to
423 * be reset here.
424 */
425 ft_interrupt_seen = 0; /* clear for next call */
426 if (!resetting) {
427 resetting = 1; /* break infinite recursion if reset fails */
428 TRACE(ft_t_any, "cleanup reset");
429 fdc_reset();
430 resetting = 0;
431 }
432 TRACE_EXIT (signal_pending(current)) ? -EINTR : -ETIME;
433}
434
435/* Start/stop drive motor. Enable DMA mode.
436 */
437void fdc_motor(int motor)
438{
439 int unit = ft_drive_sel;
440 int data = unit | FDC_RESET_NOT | FDC_DMA_MODE;
441 TRACE_FUN(ft_t_any);
442
443 ftape_motor = motor;
444 if (ftape_motor) {
445 data |= FDC_MOTOR_0 << unit;
446 TRACE(ft_t_noise, "turning motor %d on", unit);
447 } else {
448 TRACE(ft_t_noise, "turning motor %d off", unit);
449 }
450 if (ft_mach2) {
451 outb_p(data, fdc.dor2);
452 } else {
453 outb_p(data, fdc.dor);
454 }
455 ftape_sleep(10 * FT_MILLISECOND);
456 TRACE_EXIT;
457}
458
459static void fdc_update_dsr(void)
460{
461 TRACE_FUN(ft_t_any);
462
463 TRACE(ft_t_flow, "rate = %d Kbps, precomp = %d ns",
464 fdc_data_rate, fdc_precomp);
465 if (fdc.type >= i82077) {
466 outb_p((fdc_rate_code & 0x03) | fdc_prec_code, fdc.dsr);
467 } else {
468 outb_p(fdc_rate_code & 0x03, fdc.ccr);
469 }
470 TRACE_EXIT;
471}
472
473void fdc_set_write_precomp(int precomp)
474{
475 TRACE_FUN(ft_t_any);
476
477 TRACE(ft_t_noise, "New precomp: %d nsec", precomp);
478 fdc_precomp = precomp;
479 /* write precompensation can be set in multiples of 41.67 nsec.
480 * round the parameter to the nearest multiple and convert it
481 * into a fdc setting. Note that 0 means default to the fdc,
482 * 7 is used instead of that.
483 */
484 fdc_prec_code = ((fdc_precomp + 21) / 42) << 2;
485 if (fdc_prec_code == 0 || fdc_prec_code > (6 << 2)) {
486 fdc_prec_code = 7 << 2;
487 }
488 fdc_update_dsr();
489 TRACE_EXIT;
490}
491
492/* Reprogram the 82078 registers to use Data Rate Table 1 on all drives.
493 */
494static void fdc_set_drive_specs(void)
495{
496 __u8 cmd[] = { FDC_DRIVE_SPEC, 0x00, 0x00, 0x00, 0x00, 0xc0};
497 int result;
498 TRACE_FUN(ft_t_any);
499
500 TRACE(ft_t_flow, "Setting of drive specs called");
501 if (fdc.type >= i82078_1) {
502 cmd[1] = (0 << 5) | (2 << 2);
503 cmd[2] = (1 << 5) | (2 << 2);
504 cmd[3] = (2 << 5) | (2 << 2);
505 cmd[4] = (3 << 5) | (2 << 2);
506 result = fdc_command(cmd, NR_ITEMS(cmd));
507 if (result < 0) {
508 TRACE(ft_t_err, "Setting of drive specs failed");
509 }
510 }
511 TRACE_EXIT;
512}
513
514/* Select clock for fdc, must correspond with tape drive setting !
515 * This also influences the fdc timing so we must adjust some values.
516 */
517int fdc_set_data_rate(int rate)
518{
519 int bad_rate = 0;
520 TRACE_FUN(ft_t_any);
521
522 /* Select clock for fdc, must correspond with tape drive setting !
523 * This also influences the fdc timing so we must adjust some values.
524 */
525 TRACE(ft_t_fdc_dma, "new rate = %d", rate);
526 switch (rate) {
527 case 250:
528 fdc_rate_code = fdc_data_rate_250;
529 break;
530 case 500:
531 fdc_rate_code = fdc_data_rate_500;
532 break;
533 case 1000:
534 if (fdc.type < i82077) {
535 bad_rate = 1;
536 } else {
537 fdc_rate_code = fdc_data_rate_1000;
538 }
539 break;
540 case 2000:
541 if (fdc.type < i82078_1) {
542 bad_rate = 1;
543 } else {
544 fdc_rate_code = fdc_data_rate_2000;
545 }
546 break;
547 default:
548 bad_rate = 1;
549 }
550 if (bad_rate) {
551 TRACE_ABORT(-EIO,
552 ft_t_fdc_dma, "%d is not a valid data rate", rate);
553 }
554 fdc_data_rate = rate;
555 fdc_update_dsr();
556 fdc_set_seek_rate(fdc_seek_rate); /* clock changed! */
557 ftape_udelay(1000);
558 TRACE_EXIT 0;
559}
560
561/* keep the unit select if keep_select is != 0,
562 */
563static void fdc_dor_reset(int keep_select)
564{
565 __u8 fdc_ctl = ft_drive_sel;
566
567 if (keep_select != 0) {
568 fdc_ctl |= FDC_DMA_MODE;
569 if (ftape_motor) {
570 fdc_ctl |= FDC_MOTOR_0 << ft_drive_sel;
571 }
572 }
573 ftape_udelay(10); /* ??? but seems to be necessary */
574 if (ft_mach2) {
575 outb_p(fdc_ctl & 0x0f, fdc.dor);
576 outb_p(fdc_ctl, fdc.dor2);
577 } else {
578 outb_p(fdc_ctl, fdc.dor);
579 }
580 fdc_usec_wait(10); /* delay >= 14 fdc clocks */
581 if (keep_select == 0) {
582 fdc_ctl = 0;
583 }
584 fdc_ctl |= FDC_RESET_NOT;
585 if (ft_mach2) {
586 outb_p(fdc_ctl & 0x0f, fdc.dor);
587 outb_p(fdc_ctl, fdc.dor2);
588 } else {
589 outb_p(fdc_ctl, fdc.dor);
590 }
591}
592
593/* Reset the floppy disk controller. Leave the ftape_unit selected.
594 */
595void fdc_reset(void)
596{
597 int st0;
598 int i;
599 int dummy;
600 unsigned long flags;
601 TRACE_FUN(ft_t_any);
602
603 spin_lock_irqsave(&fdc_io_lock, flags);
604
605 fdc_dor_reset(1); /* keep unit selected */
606
607 fdc_mode = fdc_idle;
608
609 /* maybe the spin_lock_irq* pair is not necessary, BUT:
610 * the following line MUST be here. Otherwise fdc_interrupt_wait()
611 * won't wait. Note that fdc_reset() is called from
612 * ftape_dumb_stop() when the fdc is busy transferring data. In this
613 * case fdc_isr() MOST PROBABLY sets ft_interrupt_seen, and tries
614 * to get the result bytes from the fdc etc. CLASH.
615 */
616 ft_interrupt_seen = 0;
617
618 /* Program data rate
619 */
620 fdc_update_dsr(); /* restore data rate and precomp */
621
622 spin_unlock_irqrestore(&fdc_io_lock, flags);
623
624 /*
625 * Wait for first polling cycle to complete
626 */
627 if (fdc_interrupt_wait(1 * FT_SECOND) < 0) {
628 TRACE(ft_t_err, "no drive polling interrupt!");
629 } else { /* clear all disk-changed statuses */
630 for (i = 0; i < 4; ++i) {
631 if(fdc_sense_interrupt_status(&st0, &dummy) != 0) {
632 TRACE(ft_t_err, "sense failed for %d", i);
633 }
634 if (i == ft_drive_sel) {
635 ftape_current_cylinder = dummy;
636 }
637 }
638 TRACE(ft_t_noise, "drive polling completed");
639 }
640 /*
641 * SPECIFY COMMAND
642 */
643 fdc_set_seek_rate(fdc_seek_rate);
644 /*
645 * DRIVE SPECIFICATION COMMAND (if fdc type known)
646 */
647 if (fdc.type >= i82078_1) {
648 fdc_set_drive_specs();
649 }
650 TRACE_EXIT;
651}
652
653#if !defined(CLK_48MHZ)
654# define CLK_48MHZ 1
655#endif
656
657/* When we're done, put the fdc into reset mode so that the regular
658 * floppy disk driver will figure out that something is wrong and
659 * initialize the controller the way it wants.
660 */
661void fdc_disable(void)
662{
663 __u8 cmd1[] = {FDC_CONFIGURE, 0x00, 0x00, 0x00};
664 __u8 cmd2[] = {FDC_LOCK};
665 __u8 cmd3[] = {FDC_UNLOCK};
666 __u8 stat[1];
667 TRACE_FUN(ft_t_flow);
668
669 if (!fdc_fifo_locked) {
670 fdc_reset();
671 TRACE_EXIT;
672 }
673 if (fdc_issue_command(cmd3, 1, stat, 1) < 0 || stat[0] != 0x00) {
674 fdc_dor_reset(0);
675 TRACE_ABORT(/**/, ft_t_bug,
676 "couldn't unlock fifo, configuration remains changed");
677 }
678 fdc_fifo_locked = 0;
679 if (CLK_48MHZ && fdc.type >= i82078) {
680 cmd1[0] |= FDC_CLK48_BIT;
681 }
682 cmd1[2] = ((fdc_fifo_state) ? 0 : 0x20) + (fdc_fifo_thr - 1);
683 if (fdc_command(cmd1, NR_ITEMS(cmd1)) < 0) {
684 fdc_dor_reset(0);
685 TRACE_ABORT(/**/, ft_t_bug,
686 "couldn't reconfigure fifo to old state");
687 }
688 if (fdc_lock_state &&
689 fdc_issue_command(cmd2, 1, stat, 1) < 0) {
690 fdc_dor_reset(0);
691 TRACE_ABORT(/**/, ft_t_bug, "couldn't lock old state again");
692 }
693 TRACE(ft_t_noise, "fifo restored: %sabled, thr. %d, %slocked",
694 fdc_fifo_state ? "en" : "dis",
695 fdc_fifo_thr, (fdc_lock_state) ? "" : "not ");
696 fdc_dor_reset(0);
697 TRACE_EXIT;
698}
699
700/* Specify FDC seek-rate (milliseconds)
701 */
702static int fdc_set_seek_rate(int seek_rate)
703{
704 /* set step rate, dma mode, and minimal head load and unload times
705 */
706 __u8 in[3] = { FDC_SPECIFY, 1, (1 << 1)};
707
708 fdc_seek_rate = seek_rate;
709 in[1] |= (16 - (fdc_data_rate * fdc_seek_rate) / 500) << 4;
710
711 return fdc_command(in, 3);
712}
713
714/* Sense drive status: get unit's drive status (ST3)
715 */
716int fdc_sense_drive_status(int *st3)
717{
718 __u8 out[2];
719 __u8 in[1];
720 TRACE_FUN(ft_t_any);
721
722 out[0] = FDC_SENSED;
723 out[1] = ft_drive_sel;
724 TRACE_CATCH(fdc_issue_command(out, 2, in, 1),);
725 *st3 = in[0];
726 TRACE_EXIT 0;
727}
728
729/* Sense Interrupt Status command:
730 * should be issued at the end of each seek.
731 * get ST0 and current cylinder.
732 */
733int fdc_sense_interrupt_status(int *st0, int *current_cylinder)
734{
735 __u8 out[1];
736 __u8 in[2];
737 TRACE_FUN(ft_t_any);
738
739 out[0] = FDC_SENSEI;
740 TRACE_CATCH(fdc_issue_command(out, 1, in, 2),);
741 *st0 = in[0];
742 *current_cylinder = in[1];
743 TRACE_EXIT 0;
744}
745
746/* step to track
747 */
748int fdc_seek(int track)
749{
750 __u8 out[3];
751 int st0, pcn;
752#ifdef TESTING
753 unsigned int time;
754#endif
755 TRACE_FUN(ft_t_any);
756
757 out[0] = FDC_SEEK;
758 out[1] = ft_drive_sel;
759 out[2] = track;
760#ifdef TESTING
761 time = ftape_timestamp();
762#endif
763 /* We really need this command to work !
764 */
765 ft_seek_completed = 0;
766 TRACE_CATCH(fdc_command(out, 3),
767 fdc_reset();
768 TRACE(ft_t_noise, "destination was: %d, resetting FDC...",
769 track));
770 /* Handle interrupts until ft_seek_completed or timeout.
771 */
772 for (;;) {
773 TRACE_CATCH(fdc_interrupt_wait(2 * FT_SECOND),);
774 if (ft_seek_completed) {
775 TRACE_CATCH(fdc_sense_interrupt_status(&st0, &pcn),);
776 if ((st0 & ST0_SEEK_END) == 0) {
777 TRACE_ABORT(-EIO, ft_t_err,
778 "no seek-end after seek completion !??");
779 }
780 break;
781 }
782 }
783#ifdef TESTING
784 time = ftape_timediff(time, ftape_timestamp()) / abs(track - ftape_current_cylinder);
785 if ((time < 900 || time > 3100) && abs(track - ftape_current_cylinder) > 5) {
786 TRACE(ft_t_warn, "Wrong FDC STEP interval: %d usecs (%d)",
787 time, track - ftape_current_cylinder);
788 }
789#endif
790 /* Verify whether we issued the right tape command.
791 */
792 /* Verify that we seek to the proper track. */
793 if (pcn != track) {
794 TRACE_ABORT(-EIO, ft_t_err, "bad seek..");
795 }
796 ftape_current_cylinder = track;
797 TRACE_EXIT 0;
798}
799
800static int perpend_mode; /* set if fdc is in perpendicular mode */
801
802static int perpend_off(void)
803{
804 __u8 perpend[] = {FDC_PERPEND, 0x00};
805 TRACE_FUN(ft_t_any);
806
807 if (perpend_mode) {
808 /* Turn off perpendicular mode */
809 perpend[1] = 0x80;
810 TRACE_CATCH(fdc_command(perpend, 2),
811 TRACE(ft_t_err,"Perpendicular mode exit failed!"));
812 perpend_mode = 0;
813 }
814 TRACE_EXIT 0;
815}
816
817static int handle_perpend(int segment_id)
818{
819 __u8 perpend[] = {FDC_PERPEND, 0x00};
820 TRACE_FUN(ft_t_any);
821
822 /* When writing QIC-3020 tapes, turn on perpendicular mode
823 * if tape is moving in forward direction (even tracks).
824 */
825 if (ft_qic_std == QIC_TAPE_QIC3020 &&
826 ((segment_id / ft_segments_per_track) & 1) == 0) {
827/* FIXME: some i82077 seem to support perpendicular mode as
828 * well.
829 */
830#if 0
831 if (fdc.type < i82077AA) {}
832#else
833 if (fdc.type < i82077 && ft_data_rate < 1000) {
834#endif
835 /* fdc does not support perpendicular mode: complain
836 */
837 TRACE_ABORT(-EIO, ft_t_err,
838 "Your FDC does not support QIC-3020.");
839 }
840 perpend[1] = 0x03 /* 0x83 + (0x4 << ft_drive_sel) */ ;
841 TRACE_CATCH(fdc_command(perpend, 2),
842 TRACE(ft_t_err,"Perpendicular mode entry failed!"));
843 TRACE(ft_t_flow, "Perpendicular mode set");
844 perpend_mode = 1;
845 TRACE_EXIT 0;
846 }
847 TRACE_EXIT perpend_off();
848}
849
850static inline void fdc_setup_dma(char mode,
851 volatile void *addr, unsigned int count)
852{
853 /* Program the DMA controller.
854 */
855 disable_dma(fdc.dma);
856 clear_dma_ff(fdc.dma);
857 set_dma_mode(fdc.dma, mode);
858 set_dma_addr(fdc.dma, virt_to_bus((void*)addr));
859 set_dma_count(fdc.dma, count);
860 enable_dma(fdc.dma);
861}
862
863/* Setup fdc and dma for formatting the next segment
864 */
865int fdc_setup_formatting(buffer_struct * buff)
866{
867 unsigned long flags;
868 __u8 out[6] = {
869 FDC_FORMAT, 0x00, 3, 4 * FT_SECTORS_PER_SEGMENT, 0x00, 0x6b
870 };
871 TRACE_FUN(ft_t_any);
872
873 TRACE_CATCH(handle_perpend(buff->segment_id),);
874 /* Program the DMA controller.
875 */
876 TRACE(ft_t_fdc_dma,
877 "phys. addr. = %lx", virt_to_bus((void*) buff->ptr));
878 spin_lock_irqsave(&fdc_io_lock, flags);
879 fdc_setup_dma(DMA_MODE_WRITE, buff->ptr, FT_SECTORS_PER_SEGMENT * 4);
880 /* Issue FDC command to start reading/writing.
881 */
882 out[1] = ft_drive_sel;
883 out[4] = buff->gap3;
884 TRACE_CATCH(fdc_setup_error = fdc_command(out, sizeof(out)),
885 restore_flags(flags); fdc_mode = fdc_idle);
886 spin_unlock_irqrestore(&fdc_io_lock, flags);
887 TRACE_EXIT 0;
888}
889
890
891/* Setup Floppy Disk Controller and DMA to read or write the next cluster
892 * of good sectors from or to the current segment.
893 */
894int fdc_setup_read_write(buffer_struct * buff, __u8 operation)
895{
896 unsigned long flags;
897 __u8 out[9];
898 int dma_mode;
899 TRACE_FUN(ft_t_any);
900
901 switch(operation) {
902 case FDC_VERIFY:
903 if (fdc.type < i82077) {
904 operation = FDC_READ;
905 }
906 case FDC_READ:
907 case FDC_READ_DELETED:
908 dma_mode = DMA_MODE_READ;
909 TRACE(ft_t_fdc_dma, "xfer %d sectors to 0x%p",
910 buff->sector_count, buff->ptr);
911 TRACE_CATCH(perpend_off(),);
912 break;
913 case FDC_WRITE_DELETED:
914 TRACE(ft_t_noise, "deleting segment %d", buff->segment_id);
915 case FDC_WRITE:
916 dma_mode = DMA_MODE_WRITE;
917 /* When writing QIC-3020 tapes, turn on perpendicular mode
918 * if tape is moving in forward direction (even tracks).
919 */
920 TRACE_CATCH(handle_perpend(buff->segment_id),);
921 TRACE(ft_t_fdc_dma, "xfer %d sectors from 0x%p",
922 buff->sector_count, buff->ptr);
923 break;
924 default:
925 TRACE_ABORT(-EIO,
926 ft_t_bug, "bug: invalid operation parameter");
927 }
928 TRACE(ft_t_fdc_dma, "phys. addr. = %lx",virt_to_bus((void*)buff->ptr));
929 spin_lock_irqsave(&fdc_io_lock, flags);
930 if (operation != FDC_VERIFY) {
931 fdc_setup_dma(dma_mode, buff->ptr,
932 FT_SECTOR_SIZE * buff->sector_count);
933 }
934 /* Issue FDC command to start reading/writing.
935 */
936 out[0] = operation;
937 out[1] = ft_drive_sel;
938 out[2] = buff->cyl;
939 out[3] = buff->head;
940 out[4] = buff->sect + buff->sector_offset;
941 out[5] = 3; /* Sector size of 1K. */
942 out[6] = out[4] + buff->sector_count - 1; /* last sector */
943 out[7] = 109; /* Gap length. */
944 out[8] = 0xff; /* No limit to transfer size. */
945 TRACE(ft_t_fdc_dma, "C: 0x%02x, H: 0x%02x, R: 0x%02x, cnt: 0x%02x",
946 out[2], out[3], out[4], out[6] - out[4] + 1);
947 spin_unlock_irqrestore(&fdc_io_lock, flags);
948 TRACE_CATCH(fdc_setup_error = fdc_command(out, 9),fdc_mode = fdc_idle);
949 TRACE_EXIT 0;
950}
951
952int fdc_fifo_threshold(__u8 threshold,
953 int *fifo_state, int *lock_state, int *fifo_thr)
954{
955 const __u8 cmd0[] = {FDC_DUMPREGS};
956 __u8 cmd1[] = {FDC_CONFIGURE, 0, (0x0f & (threshold - 1)), 0};
957 const __u8 cmd2[] = {FDC_LOCK};
958 const __u8 cmd3[] = {FDC_UNLOCK};
959 __u8 reg[10];
960 __u8 stat;
961 int i;
962 int result;
963 TRACE_FUN(ft_t_any);
964
965 if (CLK_48MHZ && fdc.type >= i82078) {
966 cmd1[0] |= FDC_CLK48_BIT;
967 }
968 /* Dump fdc internal registers for examination
969 */
970 TRACE_CATCH(fdc_command(cmd0, NR_ITEMS(cmd0)),
971 TRACE(ft_t_warn, "dumpreg cmd failed, fifo unchanged"));
972 /* Now read fdc internal registers from fifo
973 */
974 for (i = 0; i < (int)NR_ITEMS(reg); ++i) {
975 fdc_read(&reg[i]);
976 TRACE(ft_t_fdc_dma, "Register %d = 0x%02x", i, reg[i]);
977 }
978 if (fifo_state && lock_state && fifo_thr) {
979 *fifo_state = (reg[8] & 0x20) == 0;
980 *lock_state = reg[7] & 0x80;
981 *fifo_thr = 1 + (reg[8] & 0x0f);
982 }
983 TRACE(ft_t_noise,
984 "original fifo state: %sabled, threshold %d, %slocked",
985 ((reg[8] & 0x20) == 0) ? "en" : "dis",
986 1 + (reg[8] & 0x0f), (reg[7] & 0x80) ? "" : "not ");
987 /* If fdc is already locked, unlock it first ! */
988 if (reg[7] & 0x80) {
989 fdc_ready_wait(100);
990 TRACE_CATCH(fdc_issue_command(cmd3, NR_ITEMS(cmd3), &stat, 1),
991 TRACE(ft_t_bug, "FDC unlock command failed, "
992 "configuration unchanged"));
993 }
994 fdc_fifo_locked = 0;
995 /* Enable fifo and set threshold at xx bytes to allow a
996 * reasonably large latency and reduce number of dma bursts.
997 */
998 fdc_ready_wait(100);
999 if ((result = fdc_command(cmd1, NR_ITEMS(cmd1))) < 0) {
1000 TRACE(ft_t_bug, "configure cmd failed, fifo unchanged");
1001 }
1002 /* Now lock configuration so reset will not change it
1003 */
1004 if(fdc_issue_command(cmd2, NR_ITEMS(cmd2), &stat, 1) < 0 ||
1005 stat != 0x10) {
1006 TRACE_ABORT(-EIO, ft_t_bug,
1007 "FDC lock command failed, stat = 0x%02x", stat);
1008 }
1009 fdc_fifo_locked = 1;
1010 TRACE_EXIT result;
1011}
1012
1013static int fdc_fifo_enable(void)
1014{
1015 TRACE_FUN(ft_t_any);
1016
1017 if (fdc_fifo_locked) {
1018 TRACE_ABORT(0, ft_t_warn, "Fifo not enabled because locked");
1019 }
1020 TRACE_CATCH(fdc_fifo_threshold(ft_fdc_threshold /* bytes */,
1021 &fdc_fifo_state,
1022 &fdc_lock_state,
1023 &fdc_fifo_thr),);
1024 TRACE_CATCH(fdc_fifo_threshold(ft_fdc_threshold /* bytes */,
1025 NULL, NULL, NULL),);
1026 TRACE_EXIT 0;
1027}
1028
1029/* Determine fd controller type
1030 */
1031static __u8 fdc_save_state[2];
1032
1033static int fdc_probe(void)
1034{
1035 __u8 cmd[1];
1036 __u8 stat[16]; /* must be able to hold dumpregs & save results */
1037 int i;
1038 TRACE_FUN(ft_t_any);
1039
1040 /* Try to find out what kind of fd controller we have to deal with
1041 * Scheme borrowed from floppy driver:
1042 * first try if FDC_DUMPREGS command works
1043 * (this indicates that we have a 82072 or better)
1044 * then try the FDC_VERSION command (82072 doesn't support this)
1045 * then try the FDC_UNLOCK command (some older 82077's don't support this)
1046 * then try the FDC_PARTID command (82078's support this)
1047 */
1048 cmd[0] = FDC_DUMPREGS;
1049 if (fdc_issue_command(cmd, 1, stat, 1) != 0) {
1050 TRACE_ABORT(no_fdc, ft_t_bug, "No FDC found");
1051 }
1052 if (stat[0] == 0x80) {
1053 /* invalid command: must be pre 82072 */
1054 TRACE_ABORT(i8272,
1055 ft_t_warn, "Type 8272A/765A compatible FDC found");
1056 }
1057 fdc_result(&stat[1], 9);
1058 fdc_save_state[0] = stat[7];
1059 fdc_save_state[1] = stat[8];
1060 cmd[0] = FDC_VERSION;
1061 if (fdc_issue_command(cmd, 1, stat, 1) < 0 || stat[0] == 0x80) {
1062 TRACE_ABORT(i8272, ft_t_warn, "Type 82072 FDC found");
1063 }
1064 if (*stat != 0x90) {
1065 TRACE_ABORT(i8272, ft_t_warn, "Unknown FDC found");
1066 }
1067 cmd[0] = FDC_UNLOCK;
1068 if(fdc_issue_command(cmd, 1, stat, 1) < 0 || stat[0] != 0x00) {
1069 TRACE_ABORT(i8272, ft_t_warn,
1070 "Type pre-1991 82077 FDC found, "
1071 "treating it like a 82072");
1072 }
1073 if (fdc_save_state[0] & 0x80) { /* was locked */
1074 cmd[0] = FDC_LOCK; /* restore lock */
1075 (void)fdc_issue_command(cmd, 1, stat, 1);
1076 TRACE(ft_t_warn, "FDC is already locked");
1077 }
1078 /* Test for a i82078 FDC */
1079 cmd[0] = FDC_PARTID;
1080 if (fdc_issue_command(cmd, 1, stat, 1) < 0 || stat[0] == 0x80) {
1081 /* invalid command: not a i82078xx type FDC */
1082 for (i = 0; i < 4; ++i) {
1083 outb_p(i, fdc.tdr);
1084 if ((inb_p(fdc.tdr) & 0x03) != i) {
1085 TRACE_ABORT(i82077,
1086 ft_t_warn, "Type 82077 FDC found");
1087 }
1088 }
1089 TRACE_ABORT(i82077AA, ft_t_warn, "Type 82077AA FDC found");
1090 }
1091 /* FDC_PARTID cmd succeeded */
1092 switch (stat[0] >> 5) {
1093 case 0x0:
1094 /* i82078SL or i82078-1. The SL part cannot run at
1095 * 2Mbps (the SL and -1 dies are identical; they are
1096 * speed graded after production, according to Intel).
1097 * Some SL's can be detected by doing a SAVE cmd and
1098 * look at bit 7 of the first byte (the SEL3V# bit).
1099 * If it is 0, the part runs off 3Volts, and hence it
1100 * is a SL.
1101 */
1102 cmd[0] = FDC_SAVE;
1103 if(fdc_issue_command(cmd, 1, stat, 16) < 0) {
1104 TRACE(ft_t_err, "FDC_SAVE failed. Dunno why");
1105 /* guess we better claim the fdc to be a i82078 */
1106 TRACE_ABORT(i82078,
1107 ft_t_warn,
1108 "Type i82078 FDC (i suppose) found");
1109 }
1110 if ((stat[0] & FDC_SEL3V_BIT)) {
1111 /* fdc running off 5Volts; Pray that it's a i82078-1
1112 */
1113 TRACE_ABORT(i82078_1, ft_t_warn,
1114 "Type i82078-1 or 5Volt i82078SL FDC found");
1115 }
1116 TRACE_ABORT(i82078, ft_t_warn,
1117 "Type 3Volt i82078SL FDC (1Mbps) found");
1118 case 0x1:
1119 case 0x2: /* S82078B */
1120 /* The '78B isn't '78 compatible. Detect it as a '77AA */
1121 TRACE_ABORT(i82077AA, ft_t_warn, "Type i82077AA FDC found");
1122 case 0x3: /* NSC PC8744 core; used in several super-IO chips */
1123 TRACE_ABORT(i82077AA,
1124 ft_t_warn, "Type 82077AA compatible FDC found");
1125 default:
1126 TRACE(ft_t_warn, "A previously undetected FDC found");
1127 TRACE_ABORT(i82077AA, ft_t_warn,
1128 "Treating it as a 82077AA. Please report partid= %d",
1129 stat[0]);
1130 } /* switch(stat[ 0] >> 5) */
1131 TRACE_EXIT no_fdc;
1132}
1133
1134static int fdc_request_regions(void)
1135{
1136 TRACE_FUN(ft_t_flow);
1137
1138 if (ft_mach2 || ft_probe_fc10) {
1139 if (!request_region(fdc.sra, 8, "fdc (ft)")) {
1140#ifndef BROKEN_FLOPPY_DRIVER
1141 TRACE_EXIT -EBUSY;
1142#else
1143 TRACE(ft_t_warn,
1144"address 0x%03x occupied (by floppy driver?), using it anyway", fdc.sra);
1145#endif
1146 }
1147 } else {
1148 if (!request_region(fdc.sra, 6, "fdc (ft)")) {
1149#ifndef BROKEN_FLOPPY_DRIVER
1150 TRACE_EXIT -EBUSY;
1151#else
1152 TRACE(ft_t_warn,
1153"address 0x%03x occupied (by floppy driver?), using it anyway", fdc.sra);
1154#endif
1155 }
1156 if (!request_region(fdc.sra + 7, 1, "fdc (ft)")) {
1157#ifndef BROKEN_FLOPPY_DRIVER
1158 release_region(fdc.sra, 6);
1159 TRACE_EXIT -EBUSY;
1160#else
1161 TRACE(ft_t_warn,
1162"address 0x%03x occupied (by floppy driver?), using it anyway", fdc.sra + 7);
1163#endif
1164 }
1165 }
1166 TRACE_EXIT 0;
1167}
1168
1169void fdc_release_regions(void)
1170{
1171 TRACE_FUN(ft_t_flow);
1172
1173 if (fdc.sra != 0) {
1174 if (fdc.dor2 != 0) {
1175 release_region(fdc.sra, 8);
1176 } else {
1177 release_region(fdc.sra, 6);
1178 release_region(fdc.dir, 1);
1179 }
1180 }
1181 TRACE_EXIT;
1182}
1183
1184static int fdc_config_regs(unsigned int fdc_base,
1185 unsigned int fdc_irq,
1186 unsigned int fdc_dma)
1187{
1188 TRACE_FUN(ft_t_flow);
1189
1190 fdc.irq = fdc_irq;
1191 fdc.dma = fdc_dma;
1192 fdc.sra = fdc_base;
1193 fdc.srb = fdc_base + 1;
1194 fdc.dor = fdc_base + 2;
1195 fdc.tdr = fdc_base + 3;
1196 fdc.msr = fdc.dsr = fdc_base + 4;
1197 fdc.fifo = fdc_base + 5;
1198 fdc.dir = fdc.ccr = fdc_base + 7;
1199 fdc.dor2 = (ft_mach2 || ft_probe_fc10) ? fdc_base + 6 : 0;
1200 TRACE_CATCH(fdc_request_regions(), fdc.sra = 0);
1201 TRACE_EXIT 0;
1202}
1203
1204static int fdc_config(void)
1205{
1206 static int already_done;
1207 TRACE_FUN(ft_t_any);
1208
1209 if (already_done) {
1210 TRACE_CATCH(fdc_request_regions(),);
1211 *(fdc.hook) = fdc_isr; /* hook our handler in */
1212 TRACE_EXIT 0;
1213 }
1214 if (ft_probe_fc10) {
1215 int fc_type;
1216
1217 TRACE_CATCH(fdc_config_regs(ft_fdc_base,
1218 ft_fdc_irq, ft_fdc_dma),);
1219 fc_type = fc10_enable();
1220 if (fc_type != 0) {
1221 TRACE(ft_t_warn, "FC-%c0 controller found", '0' + fc_type);
1222 fdc.type = fc10;
1223 fdc.hook = &do_ftape;
1224 *(fdc.hook) = fdc_isr; /* hook our handler in */
1225 already_done = 1;
1226 TRACE_EXIT 0;
1227 } else {
1228 TRACE(ft_t_warn, "FC-10/20 controller not found");
1229 fdc_release_regions();
1230 fdc.type = no_fdc;
1231 ft_probe_fc10 = 0;
1232 ft_fdc_base = 0x3f0;
1233 ft_fdc_irq = 6;
1234 ft_fdc_dma = 2;
1235 }
1236 }
1237 TRACE(ft_t_warn, "fdc base: 0x%x, irq: %d, dma: %d",
1238 ft_fdc_base, ft_fdc_irq, ft_fdc_dma);
1239 TRACE_CATCH(fdc_config_regs(ft_fdc_base, ft_fdc_irq, ft_fdc_dma),);
1240 fdc.hook = &do_ftape;
1241 *(fdc.hook) = fdc_isr; /* hook our handler in */
1242 already_done = 1;
1243 TRACE_EXIT 0;
1244}
1245
1246static irqreturn_t ftape_interrupt(int irq, void *dev_id)
1247{
1248 void (*handler) (void) = *fdc.hook;
1249 int handled = 0;
1250 TRACE_FUN(ft_t_any);
1251
1252 *fdc.hook = NULL;
1253 if (handler) {
1254 handled = 1;
1255 handler();
1256 } else {
1257 TRACE(ft_t_bug, "Unexpected ftape interrupt");
1258 }
1259 TRACE_EXIT IRQ_RETVAL(handled);
1260}
1261
1262static int fdc_grab_irq_and_dma(void)
1263{
1264 TRACE_FUN(ft_t_any);
1265
1266 if (fdc.hook == &do_ftape) {
1267 /* Get fast interrupt handler.
1268 */
1269 if (request_irq(fdc.irq, ftape_interrupt,
1270 IRQF_DISABLED, "ft", ftape_id)) {
1271 TRACE_ABORT(-EIO, ft_t_bug,
1272 "Unable to grab IRQ%d for ftape driver",
1273 fdc.irq);
1274 }
1275 if (request_dma(fdc.dma, ftape_id)) {
1276 free_irq(fdc.irq, ftape_id);
1277 TRACE_ABORT(-EIO, ft_t_bug,
1278 "Unable to grab DMA%d for ftape driver",
1279 fdc.dma);
1280 }
1281 }
1282 if (ft_fdc_base != 0x3f0 && (ft_fdc_dma == 2 || ft_fdc_irq == 6)) {
1283 /* Using same dma channel or irq as standard fdc, need
1284 * to disable the dma-gate on the std fdc. This
1285 * couldn't be done in the floppy driver as some
1286 * laptops are using the dma-gate to enter a low power
1287 * or even suspended state :-(
1288 */
1289 outb_p(FDC_RESET_NOT, 0x3f2);
1290 TRACE(ft_t_noise, "DMA-gate on standard fdc disabled");
1291 }
1292 TRACE_EXIT 0;
1293}
1294
1295int fdc_release_irq_and_dma(void)
1296{
1297 TRACE_FUN(ft_t_any);
1298
1299 if (fdc.hook == &do_ftape) {
1300 disable_dma(fdc.dma); /* just in case... */
1301 free_dma(fdc.dma);
1302 free_irq(fdc.irq, ftape_id);
1303 }
1304 if (ft_fdc_base != 0x3f0 && (ft_fdc_dma == 2 || ft_fdc_irq == 6)) {
1305 /* Using same dma channel as standard fdc, need to
1306 * disable the dma-gate on the std fdc. This couldn't
1307 * be done in the floppy driver as some laptops are
1308 * using the dma-gate to enter a low power or even
1309 * suspended state :-(
1310 */
1311 outb_p(FDC_RESET_NOT | FDC_DMA_MODE, 0x3f2);
1312 TRACE(ft_t_noise, "DMA-gate on standard fdc enabled again");
1313 }
1314 TRACE_EXIT 0;
1315}
1316
1317int fdc_init(void)
1318{
1319 TRACE_FUN(ft_t_any);
1320
1321 /* find a FDC to use */
1322 TRACE_CATCH(fdc_config(),);
1323 TRACE_CATCH(fdc_grab_irq_and_dma(), fdc_release_regions());
1324 ftape_motor = 0;
1325 fdc_catch_stray_interrupts(0); /* clear number of awainted
1326 * stray interrupte
1327 */
1328 fdc_catch_stray_interrupts(1); /* one always comes (?) */
1329 TRACE(ft_t_flow, "resetting fdc");
1330 fdc_set_seek_rate(2); /* use nominal QIC step rate */
1331 fdc_reset(); /* init fdc & clear track counters */
1332 if (fdc.type == no_fdc) { /* no FC-10 or FC-20 found */
1333 fdc.type = fdc_probe();
1334 fdc_reset(); /* update with new knowledge */
1335 }
1336 if (fdc.type == no_fdc) {
1337 fdc_release_irq_and_dma();
1338 fdc_release_regions();
1339 TRACE_EXIT -ENXIO;
1340 }
1341 if (fdc.type >= i82077) {
1342 if (fdc_fifo_enable() < 0) {
1343 TRACE(ft_t_warn, "couldn't enable fdc fifo !");
1344 } else {
1345 TRACE(ft_t_flow, "fdc fifo enabled and locked");
1346 }
1347 }
1348 TRACE_EXIT 0;
1349}
diff --git a/drivers/char/ftape/lowlevel/fdc-io.h b/drivers/char/ftape/lowlevel/fdc-io.h
deleted file mode 100644
index 7ec3c72178bb..000000000000
--- a/drivers/char/ftape/lowlevel/fdc-io.h
+++ /dev/null
@@ -1,252 +0,0 @@
1#ifndef _FDC_IO_H
2#define _FDC_IO_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-io.h,v $
24 * $Revision: 1.3 $
25 * $Date: 1997/10/05 19:18:06 $
26 *
27 * This file contains the declarations for the low level
28 * functions that communicate with the floppy disk controller,
29 * for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for
30 * Linux.
31 */
32
33#include <linux/fdreg.h>
34
35#include "../lowlevel/ftape-bsm.h"
36
37#define FDC_SK_BIT (0x20)
38#define FDC_MT_BIT (0x80)
39
40#define FDC_READ (FD_READ & ~(FDC_SK_BIT | FDC_MT_BIT))
41#define FDC_WRITE (FD_WRITE & ~FDC_MT_BIT)
42#define FDC_READ_DELETED (0x4c)
43#define FDC_WRITE_DELETED (0x49)
44#define FDC_VERIFY (0x56)
45#define FDC_READID (0x4a)
46#define FDC_SENSED (0x04)
47#define FDC_SENSEI (FD_SENSEI)
48#define FDC_FORMAT (FD_FORMAT)
49#define FDC_RECAL (FD_RECALIBRATE)
50#define FDC_SEEK (FD_SEEK)
51#define FDC_SPECIFY (FD_SPECIFY)
52#define FDC_RECALIBR (FD_RECALIBRATE)
53#define FDC_VERSION (FD_VERSION)
54#define FDC_PERPEND (FD_PERPENDICULAR)
55#define FDC_DUMPREGS (FD_DUMPREGS)
56#define FDC_LOCK (FD_LOCK)
57#define FDC_UNLOCK (FD_UNLOCK)
58#define FDC_CONFIGURE (FD_CONFIGURE)
59#define FDC_DRIVE_SPEC (0x8e) /* i82078 has this (any others?) */
60#define FDC_PARTID (0x18) /* i82078 has this */
61#define FDC_SAVE (0x2e) /* i82078 has this (any others?) */
62#define FDC_RESTORE (0x4e) /* i82078 has this (any others?) */
63
64#define FDC_STATUS_MASK (STATUS_BUSY | STATUS_DMA | STATUS_DIR | STATUS_READY)
65#define FDC_DATA_READY (STATUS_READY)
66#define FDC_DATA_OUTPUT (STATUS_DIR)
67#define FDC_DATA_READY_MASK (STATUS_READY | STATUS_DIR)
68#define FDC_DATA_OUT_READY (STATUS_READY | STATUS_DIR)
69#define FDC_DATA_IN_READY (STATUS_READY)
70#define FDC_BUSY (STATUS_BUSY)
71#define FDC_CLK48_BIT (0x80)
72#define FDC_SEL3V_BIT (0x40)
73
74#define ST0_INT_MASK (ST0_INTR)
75#define FDC_INT_NORMAL (ST0_INTR & 0x00)
76#define FDC_INT_ABNORMAL (ST0_INTR & 0x40)
77#define FDC_INT_INVALID (ST0_INTR & 0x80)
78#define FDC_INT_READYCH (ST0_INTR & 0xC0)
79#define ST0_SEEK_END (ST0_SE)
80#define ST3_TRACK_0 (ST3_TZ)
81
82#define FDC_RESET_NOT (0x04)
83#define FDC_DMA_MODE (0x08)
84#define FDC_MOTOR_0 (0x10)
85#define FDC_MOTOR_1 (0x20)
86
87typedef struct {
88 void (**hook) (void); /* our wedge into the isr */
89 enum {
90 no_fdc, i8272, i82077, i82077AA, fc10,
91 i82078, i82078_1
92 } type; /* FDC type */
93 unsigned int irq; /* FDC irq nr */
94 unsigned int dma; /* FDC dma channel nr */
95 __u16 sra; /* Status register A (PS/2 only) */
96 __u16 srb; /* Status register B (PS/2 only) */
97 __u16 dor; /* Digital output register */
98 __u16 tdr; /* Tape Drive Register (82077SL-1 &
99 82078 only) */
100 __u16 msr; /* Main Status Register */
101 __u16 dsr; /* Datarate Select Register (8207x only) */
102 __u16 fifo; /* Data register / Fifo on 8207x */
103 __u16 dir; /* Digital Input Register */
104 __u16 ccr; /* Configuration Control Register */
105 __u16 dor2; /* Alternate dor on MACH-2 controller,
106 also used with FC-10, meaning unknown */
107} fdc_config_info;
108
109typedef enum {
110 fdc_data_rate_250 = 2,
111 fdc_data_rate_300 = 1, /* any fdc in default configuration */
112 fdc_data_rate_500 = 0,
113 fdc_data_rate_1000 = 3,
114 fdc_data_rate_2000 = 1, /* i82078-1: when using Data Rate Table #2 */
115} fdc_data_rate_type;
116
117typedef enum {
118 fdc_idle = 0,
119 fdc_reading_data = FDC_READ,
120 fdc_seeking = FDC_SEEK,
121 fdc_writing_data = FDC_WRITE,
122 fdc_deleting = FDC_WRITE_DELETED,
123 fdc_reading_id = FDC_READID,
124 fdc_recalibrating = FDC_RECAL,
125 fdc_formatting = FDC_FORMAT,
126 fdc_verifying = FDC_VERIFY
127} fdc_mode_enum;
128
129typedef enum {
130 waiting = 0,
131 reading,
132 writing,
133 formatting,
134 verifying,
135 deleting,
136 done,
137 error,
138 mmapped,
139} buffer_state_enum;
140
141typedef struct {
142 __u8 *address;
143 volatile buffer_state_enum status;
144 volatile __u8 *ptr;
145 volatile unsigned int bytes;
146 volatile unsigned int segment_id;
147
148 /* bitmap for remainder of segment not yet handled.
149 * one bit set for each bad sector that must be skipped.
150 */
151 volatile SectorMap bad_sector_map;
152
153 /* bitmap with bad data blocks in data buffer.
154 * the errors in this map may be retried.
155 */
156 volatile SectorMap soft_error_map;
157
158 /* bitmap with bad data blocks in data buffer
159 * the errors in this map may not be retried.
160 */
161 volatile SectorMap hard_error_map;
162
163 /* retry counter for soft errors.
164 */
165 volatile int retry;
166
167 /* sectors to skip on retry ???
168 */
169 volatile unsigned int skip;
170
171 /* nr of data blocks in data buffer
172 */
173 volatile unsigned int data_offset;
174
175 /* offset in segment for first sector to be handled.
176 */
177 volatile unsigned int sector_offset;
178
179 /* size of cluster of good sectors to be handled.
180 */
181 volatile unsigned int sector_count;
182
183 /* size of remaining part of segment to be handled.
184 */
185 volatile unsigned int remaining;
186
187 /* points to next segment (contiguous) to be handled,
188 * or is zero if no read-ahead is allowed.
189 */
190 volatile unsigned int next_segment;
191
192 /* flag being set if deleted data was read.
193 */
194 volatile int deleted;
195
196 /* floppy coordinates of first sector in segment */
197 volatile __u8 head;
198 volatile __u8 cyl;
199 volatile __u8 sect;
200
201 /* gap to use when formatting */
202 __u8 gap3;
203 /* flag set when buffer is mmaped */
204 int mmapped;
205} buffer_struct;
206
207/*
208 * fdc-io.c defined public variables
209 */
210extern volatile fdc_mode_enum fdc_mode;
211extern int fdc_setup_error; /* outdated ??? */
212extern wait_queue_head_t ftape_wait_intr;
213extern volatile int ftape_current_cylinder; /* track nr FDC thinks we're on */
214extern volatile __u8 fdc_head; /* FDC head */
215extern volatile __u8 fdc_cyl; /* FDC track */
216extern volatile __u8 fdc_sect; /* FDC sector */
217extern fdc_config_info fdc; /* FDC hardware configuration */
218
219extern unsigned int ft_fdc_base;
220extern unsigned int ft_fdc_irq;
221extern unsigned int ft_fdc_dma;
222extern unsigned int ft_fdc_threshold;
223extern unsigned int ft_fdc_rate_limit;
224extern int ft_probe_fc10;
225extern int ft_mach2;
226/*
227 * fdc-io.c defined public functions
228 */
229extern void fdc_catch_stray_interrupts(int count);
230extern int fdc_ready_wait(unsigned int timeout);
231extern int fdc_command(const __u8 * cmd_data, int cmd_len);
232extern int fdc_result(__u8 * res_data, int res_len);
233extern int fdc_interrupt_wait(unsigned int time);
234extern int fdc_seek(int track);
235extern int fdc_sense_drive_status(int *st3);
236extern void fdc_motor(int motor);
237extern void fdc_reset(void);
238extern void fdc_disable(void);
239extern int fdc_fifo_threshold(__u8 threshold,
240 int *fifo_state, int *lock_state, int *fifo_thr);
241extern void fdc_wait_calibrate(void);
242extern int fdc_sense_interrupt_status(int *st0, int *current_cylinder);
243extern void fdc_save_drive_specs(void);
244extern void fdc_restore_drive_specs(void);
245extern int fdc_set_data_rate(int rate);
246extern void fdc_set_write_precomp(int precomp);
247extern int fdc_release_irq_and_dma(void);
248extern void fdc_release_regions(void);
249extern int fdc_init(void);
250extern int fdc_setup_read_write(buffer_struct * buff, __u8 operation);
251extern int fdc_setup_formatting(buffer_struct * buff);
252#endif
diff --git a/drivers/char/ftape/lowlevel/fdc-isr.c b/drivers/char/ftape/lowlevel/fdc-isr.c
deleted file mode 100644
index ad2bc733ae1b..000000000000
--- a/drivers/char/ftape/lowlevel/fdc-isr.c
+++ /dev/null
@@ -1,1170 +0,0 @@
1/*
2 * Copyright (C) 1994-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-isr.c,v $
21 * $Revision: 1.9 $
22 * $Date: 1997/10/17 23:01:53 $
23 *
24 * This file contains the interrupt service routine and
25 * associated code for the QIC-40/80/3010/3020 floppy-tape driver
26 * "ftape" for Linux.
27 */
28
29#include <asm/io.h>
30#include <asm/dma.h>
31
32#define volatile /* */
33
34#include <linux/ftape.h>
35#include <linux/qic117.h>
36#include "../lowlevel/ftape-tracing.h"
37#include "../lowlevel/fdc-isr.h"
38#include "../lowlevel/fdc-io.h"
39#include "../lowlevel/ftape-ctl.h"
40#include "../lowlevel/ftape-rw.h"
41#include "../lowlevel/ftape-io.h"
42#include "../lowlevel/ftape-calibr.h"
43#include "../lowlevel/ftape-bsm.h"
44
45/* Global vars.
46 */
47volatile int ft_expected_stray_interrupts;
48volatile int ft_interrupt_seen;
49volatile int ft_seek_completed;
50volatile int ft_hide_interrupt;
51/* Local vars.
52 */
53typedef enum {
54 no_error = 0, id_am_error = 0x01, id_crc_error = 0x02,
55 data_am_error = 0x04, data_crc_error = 0x08,
56 no_data_error = 0x10, overrun_error = 0x20,
57} error_cause;
58static int stop_read_ahead;
59
60
61static void print_error_cause(int cause)
62{
63 TRACE_FUN(ft_t_any);
64
65 switch (cause) {
66 case no_data_error:
67 TRACE(ft_t_noise, "no data error");
68 break;
69 case id_am_error:
70 TRACE(ft_t_noise, "id am error");
71 break;
72 case id_crc_error:
73 TRACE(ft_t_noise, "id crc error");
74 break;
75 case data_am_error:
76 TRACE(ft_t_noise, "data am error");
77 break;
78 case data_crc_error:
79 TRACE(ft_t_noise, "data crc error");
80 break;
81 case overrun_error:
82 TRACE(ft_t_noise, "overrun error");
83 break;
84 default:;
85 }
86 TRACE_EXIT;
87}
88
89static char *fdc_mode_txt(fdc_mode_enum mode)
90{
91 switch (mode) {
92 case fdc_idle:
93 return "fdc_idle";
94 case fdc_reading_data:
95 return "fdc_reading_data";
96 case fdc_seeking:
97 return "fdc_seeking";
98 case fdc_writing_data:
99 return "fdc_writing_data";
100 case fdc_reading_id:
101 return "fdc_reading_id";
102 case fdc_recalibrating:
103 return "fdc_recalibrating";
104 case fdc_formatting:
105 return "fdc_formatting";
106 case fdc_verifying:
107 return "fdc_verifying";
108 default:
109 return "unknown";
110 }
111}
112
113static inline error_cause decode_irq_cause(fdc_mode_enum mode, __u8 st[])
114{
115 error_cause cause = no_error;
116 TRACE_FUN(ft_t_any);
117
118 /* Valid st[], decode cause of interrupt.
119 */
120 switch (st[0] & ST0_INT_MASK) {
121 case FDC_INT_NORMAL:
122 TRACE(ft_t_fdc_dma,"normal completion: %s",fdc_mode_txt(mode));
123 break;
124 case FDC_INT_ABNORMAL:
125 TRACE(ft_t_flow, "abnormal completion %s", fdc_mode_txt(mode));
126 TRACE(ft_t_fdc_dma, "ST0: 0x%02x, ST1: 0x%02x, ST2: 0x%02x",
127 st[0], st[1], st[2]);
128 TRACE(ft_t_fdc_dma,
129 "C: 0x%02x, H: 0x%02x, R: 0x%02x, N: 0x%02x",
130 st[3], st[4], st[5], st[6]);
131 if (st[1] & 0x01) {
132 if (st[2] & 0x01) {
133 cause = data_am_error;
134 } else {
135 cause = id_am_error;
136 }
137 } else if (st[1] & 0x20) {
138 if (st[2] & 0x20) {
139 cause = data_crc_error;
140 } else {
141 cause = id_crc_error;
142 }
143 } else if (st[1] & 0x04) {
144 cause = no_data_error;
145 } else if (st[1] & 0x10) {
146 cause = overrun_error;
147 }
148 print_error_cause(cause);
149 break;
150 case FDC_INT_INVALID:
151 TRACE(ft_t_flow, "invalid completion %s", fdc_mode_txt(mode));
152 break;
153 case FDC_INT_READYCH:
154 if (st[0] & ST0_SEEK_END) {
155 TRACE(ft_t_flow, "drive poll completed");
156 } else {
157 TRACE(ft_t_flow, "ready change %s",fdc_mode_txt(mode));
158 }
159 break;
160 default:
161 break;
162 }
163 TRACE_EXIT cause;
164}
165
166static void update_history(error_cause cause)
167{
168 switch (cause) {
169 case id_am_error:
170 ft_history.id_am_errors++;
171 break;
172 case id_crc_error:
173 ft_history.id_crc_errors++;
174 break;
175 case data_am_error:
176 ft_history.data_am_errors++;
177 break;
178 case data_crc_error:
179 ft_history.data_crc_errors++;
180 break;
181 case overrun_error:
182 ft_history.overrun_errors++;
183 break;
184 case no_data_error:
185 ft_history.no_data_errors++;
186 break;
187 default:;
188 }
189}
190
191static void skip_bad_sector(buffer_struct * buff)
192{
193 TRACE_FUN(ft_t_any);
194
195 /* Mark sector as soft error and skip it
196 */
197 if (buff->remaining > 0) {
198 ++buff->sector_offset;
199 ++buff->data_offset;
200 --buff->remaining;
201 buff->ptr += FT_SECTOR_SIZE;
202 buff->bad_sector_map >>= 1;
203 } else {
204 /* Hey, what is this????????????? C code: if we shift
205 * more than 31 bits, we get no shift. That's bad!!!!!!
206 */
207 ++buff->sector_offset; /* hack for error maps */
208 TRACE(ft_t_warn, "skipping last sector in segment");
209 }
210 TRACE_EXIT;
211}
212
213static void update_error_maps(buffer_struct * buff, unsigned int error_offset)
214{
215 int hard = 0;
216 TRACE_FUN(ft_t_any);
217
218 if (buff->retry < FT_SOFT_RETRIES) {
219 buff->soft_error_map |= (1 << error_offset);
220 } else {
221 buff->hard_error_map |= (1 << error_offset);
222 buff->soft_error_map &= ~buff->hard_error_map;
223 buff->retry = -1; /* will be set to 0 in setup_segment */
224 hard = 1;
225 }
226 TRACE(ft_t_noise, "sector %d : %s error\n"
227 KERN_INFO "hard map: 0x%08lx\n"
228 KERN_INFO "soft map: 0x%08lx",
229 FT_SECTOR(error_offset), hard ? "hard" : "soft",
230 (long) buff->hard_error_map, (long) buff->soft_error_map);
231 TRACE_EXIT;
232}
233
234static void print_progress(buffer_struct *buff, error_cause cause)
235{
236 TRACE_FUN(ft_t_any);
237
238 switch (cause) {
239 case no_error:
240 TRACE(ft_t_flow,"%d Sector(s) transferred", buff->sector_count);
241 break;
242 case no_data_error:
243 TRACE(ft_t_flow, "Sector %d not found",
244 FT_SECTOR(buff->sector_offset));
245 break;
246 case overrun_error:
247 /* got an overrun error on the first byte, must be a
248 * hardware problem
249 */
250 TRACE(ft_t_bug,
251 "Unexpected error: failing DMA or FDC controller ?");
252 break;
253 case data_crc_error:
254 TRACE(ft_t_flow, "Error in sector %d",
255 FT_SECTOR(buff->sector_offset - 1));
256 break;
257 case id_crc_error:
258 case id_am_error:
259 case data_am_error:
260 TRACE(ft_t_flow, "Error in sector %d",
261 FT_SECTOR(buff->sector_offset));
262 break;
263 default:
264 TRACE(ft_t_flow, "Unexpected error at sector %d",
265 FT_SECTOR(buff->sector_offset));
266 break;
267 }
268 TRACE_EXIT;
269}
270
271/*
272 * Error cause: Amount xferred: Action:
273 *
274 * id_am_error 0 mark bad and skip
275 * id_crc_error 0 mark bad and skip
276 * data_am_error 0 mark bad and skip
277 * data_crc_error % 1024 mark bad and skip
278 * no_data_error 0 retry on write
279 * mark bad and skip on read
280 * overrun_error [ 0..all-1 ] mark bad and skip
281 * no_error all continue
282 */
283
284/* the arg `sector' is returned by the fdc and tells us at which sector we
285 * are positioned at (relative to starting sector of segment)
286 */
287static void determine_verify_progress(buffer_struct *buff,
288 error_cause cause,
289 __u8 sector)
290{
291 TRACE_FUN(ft_t_any);
292
293 if (cause == no_error && sector == 1) {
294 buff->sector_offset = FT_SECTORS_PER_SEGMENT;
295 buff->remaining = 0;
296 if (TRACE_LEVEL >= ft_t_flow) {
297 print_progress(buff, cause);
298 }
299 } else {
300 buff->sector_offset = sector - buff->sect;
301 buff->remaining = FT_SECTORS_PER_SEGMENT - buff->sector_offset;
302 TRACE(ft_t_noise, "%ssector offset: 0x%04x",
303 (cause == no_error) ? "unexpected " : "",
304 buff->sector_offset);
305 switch (cause) {
306 case overrun_error:
307 break;
308#if 0
309 case no_data_error:
310 buff->retry = FT_SOFT_RETRIES;
311 if (buff->hard_error_map &&
312 buff->sector_offset > 1 &&
313 (buff->hard_error_map &
314 (1 << (buff->sector_offset-2)))) {
315 buff->retry --;
316 }
317 break;
318#endif
319 default:
320 buff->retry = FT_SOFT_RETRIES;
321 break;
322 }
323 if (TRACE_LEVEL >= ft_t_flow) {
324 print_progress(buff, cause);
325 }
326 /* Sector_offset points to the problem area Now adjust
327 * sector_offset so it always points one past he failing
328 * sector. I.e. skip the bad sector.
329 */
330 ++buff->sector_offset;
331 --buff->remaining;
332 update_error_maps(buff, buff->sector_offset - 1);
333 }
334 TRACE_EXIT;
335}
336
337static void determine_progress(buffer_struct *buff,
338 error_cause cause,
339 __u8 sector)
340{
341 unsigned int dma_residue;
342 TRACE_FUN(ft_t_any);
343
344 /* Using less preferred order of disable_dma and
345 * get_dma_residue because this seems to fail on at least one
346 * system if reversed!
347 */
348 dma_residue = get_dma_residue(fdc.dma);
349 disable_dma(fdc.dma);
350 if (cause != no_error || dma_residue != 0) {
351 TRACE(ft_t_noise, "%sDMA residue: 0x%04x",
352 (cause == no_error) ? "unexpected " : "",
353 dma_residue);
354 /* adjust to actual value: */
355 if (dma_residue == 0) {
356 /* this happens sometimes with overrun errors.
357 * I don't know whether we could ignore the
358 * overrun error. Play save.
359 */
360 buff->sector_count --;
361 } else {
362 buff->sector_count -= ((dma_residue +
363 (FT_SECTOR_SIZE - 1)) /
364 FT_SECTOR_SIZE);
365 }
366 }
367 /* Update var's influenced by the DMA operation.
368 */
369 if (buff->sector_count > 0) {
370 buff->sector_offset += buff->sector_count;
371 buff->data_offset += buff->sector_count;
372 buff->ptr += (buff->sector_count *
373 FT_SECTOR_SIZE);
374 buff->remaining -= buff->sector_count;
375 buff->bad_sector_map >>= buff->sector_count;
376 }
377 if (TRACE_LEVEL >= ft_t_flow) {
378 print_progress(buff, cause);
379 }
380 if (cause != no_error) {
381 if (buff->remaining == 0) {
382 TRACE(ft_t_warn, "foo?\n"
383 KERN_INFO "count : %d\n"
384 KERN_INFO "offset: %d\n"
385 KERN_INFO "soft : %08x\n"
386 KERN_INFO "hard : %08x",
387 buff->sector_count,
388 buff->sector_offset,
389 buff->soft_error_map,
390 buff->hard_error_map);
391 }
392 /* Sector_offset points to the problem area, except if we got
393 * a data_crc_error. In that case it points one past the
394 * failing sector.
395 *
396 * Now adjust sector_offset so it always points one past he
397 * failing sector. I.e. skip the bad sector.
398 */
399 if (cause != data_crc_error) {
400 skip_bad_sector(buff);
401 }
402 update_error_maps(buff, buff->sector_offset - 1);
403 }
404 TRACE_EXIT;
405}
406
407static int calc_steps(int cmd)
408{
409 if (ftape_current_cylinder > cmd) {
410 return ftape_current_cylinder - cmd;
411 } else {
412 return ftape_current_cylinder + cmd;
413 }
414}
415
416static void pause_tape(int retry, int mode)
417{
418 int result;
419 __u8 out[3] = {FDC_SEEK, ft_drive_sel, 0};
420 TRACE_FUN(ft_t_any);
421
422 /* We'll use a raw seek command to get the tape to rewind and
423 * stop for a retry.
424 */
425 ++ft_history.rewinds;
426 if (qic117_cmds[ftape_current_command].non_intr) {
427 TRACE(ft_t_warn, "motion command may be issued too soon");
428 }
429 if (retry && (mode == fdc_reading_data ||
430 mode == fdc_reading_id ||
431 mode == fdc_verifying)) {
432 ftape_current_command = QIC_MICRO_STEP_PAUSE;
433 ftape_might_be_off_track = 1;
434 } else {
435 ftape_current_command = QIC_PAUSE;
436 }
437 out[2] = calc_steps(ftape_current_command);
438 result = fdc_command(out, 3); /* issue QIC_117 command */
439 ftape_current_cylinder = out[ 2];
440 if (result < 0) {
441 TRACE(ft_t_noise, "qic-pause failed, status = %d", result);
442 } else {
443 ft_location.known = 0;
444 ft_runner_status = idle;
445 ft_hide_interrupt = 1;
446 ftape_tape_running = 0;
447 }
448 TRACE_EXIT;
449}
450
451static void continue_xfer(buffer_struct *buff,
452 fdc_mode_enum mode,
453 unsigned int skip)
454{
455 int write = 0;
456 TRACE_FUN(ft_t_any);
457
458 if (mode == fdc_writing_data || mode == fdc_deleting) {
459 write = 1;
460 }
461 /* This part can be removed if it never happens
462 */
463 if (skip > 0 &&
464 (ft_runner_status != running ||
465 (write && (buff->status != writing)) ||
466 (!write && (buff->status != reading &&
467 buff->status != verifying)))) {
468 TRACE(ft_t_err, "unexpected runner/buffer state %d/%d",
469 ft_runner_status, buff->status);
470 buff->status = error;
471 /* finish this buffer: */
472 (void)ftape_next_buffer(ft_queue_head);
473 ft_runner_status = aborting;
474 fdc_mode = fdc_idle;
475 } else if (buff->remaining > 0 && ftape_calc_next_cluster(buff) > 0) {
476 /* still sectors left in current segment, continue
477 * with this segment
478 */
479 if (fdc_setup_read_write(buff, mode) < 0) {
480 /* failed, abort operation
481 */
482 buff->bytes = buff->ptr - buff->address;
483 buff->status = error;
484 /* finish this buffer: */
485 (void)ftape_next_buffer(ft_queue_head);
486 ft_runner_status = aborting;
487 fdc_mode = fdc_idle;
488 }
489 } else {
490 /* current segment completed
491 */
492 unsigned int last_segment = buff->segment_id;
493 int eot = ((last_segment + 1) % ft_segments_per_track) == 0;
494 unsigned int next = buff->next_segment; /* 0 means stop ! */
495
496 buff->bytes = buff->ptr - buff->address;
497 buff->status = done;
498 buff = ftape_next_buffer(ft_queue_head);
499 if (eot) {
500 /* finished last segment on current track,
501 * can't continue
502 */
503 ft_runner_status = logical_eot;
504 fdc_mode = fdc_idle;
505 TRACE_EXIT;
506 }
507 if (next <= 0) {
508 /* don't continue with next segment
509 */
510 TRACE(ft_t_noise, "no %s allowed, stopping tape",
511 (write) ? "write next" : "read ahead");
512 pause_tape(0, mode);
513 ft_runner_status = idle; /* not quite true until
514 * next irq
515 */
516 TRACE_EXIT;
517 }
518 /* continue with next segment
519 */
520 if (buff->status != waiting) {
521 TRACE(ft_t_noise, "all input buffers %s, pausing tape",
522 (write) ? "empty" : "full");
523 pause_tape(0, mode);
524 ft_runner_status = idle; /* not quite true until
525 * next irq
526 */
527 TRACE_EXIT;
528 }
529 if (write && next != buff->segment_id) {
530 TRACE(ft_t_noise,
531 "segments out of order, aborting write");
532 ft_runner_status = do_abort;
533 fdc_mode = fdc_idle;
534 TRACE_EXIT;
535 }
536 ftape_setup_new_segment(buff, next, 0);
537 if (stop_read_ahead) {
538 buff->next_segment = 0;
539 stop_read_ahead = 0;
540 }
541 if (ftape_calc_next_cluster(buff) == 0 ||
542 fdc_setup_read_write(buff, mode) != 0) {
543 TRACE(ft_t_err, "couldn't start %s-ahead",
544 write ? "write" : "read");
545 ft_runner_status = do_abort;
546 fdc_mode = fdc_idle;
547 } else {
548 /* keep on going */
549 switch (ft_driver_state) {
550 case reading: buff->status = reading; break;
551 case verifying: buff->status = verifying; break;
552 case writing: buff->status = writing; break;
553 case deleting: buff->status = deleting; break;
554 default:
555 TRACE(ft_t_err,
556 "BUG: ft_driver_state %d should be one out of "
557 "{reading, writing, verifying, deleting}",
558 ft_driver_state);
559 buff->status = write ? writing : reading;
560 break;
561 }
562 }
563 }
564 TRACE_EXIT;
565}
566
567static void retry_sector(buffer_struct *buff,
568 int mode,
569 unsigned int skip)
570{
571 TRACE_FUN(ft_t_any);
572
573 TRACE(ft_t_noise, "%s error, will retry",
574 (mode == fdc_writing_data || mode == fdc_deleting) ? "write" : "read");
575 pause_tape(1, mode);
576 ft_runner_status = aborting;
577 buff->status = error;
578 buff->skip = skip;
579 TRACE_EXIT;
580}
581
582static unsigned int find_resume_point(buffer_struct *buff)
583{
584 int i = 0;
585 SectorMap mask;
586 SectorMap map;
587 TRACE_FUN(ft_t_any);
588
589 /* This function is to be called after all variables have been
590 * updated to point past the failing sector.
591 * If there are any soft errors before the failing sector,
592 * find the first soft error and return the sector offset.
593 * Otherwise find the last hard error.
594 * Note: there should always be at least one hard or soft error !
595 */
596 if (buff->sector_offset < 1 || buff->sector_offset > 32) {
597 TRACE(ft_t_bug, "BUG: sector_offset = %d",
598 buff->sector_offset);
599 TRACE_EXIT 0;
600 }
601 if (buff->sector_offset >= 32) { /* C-limitation on shift ! */
602 mask = 0xffffffff;
603 } else {
604 mask = (1 << buff->sector_offset) - 1;
605 }
606 map = buff->soft_error_map & mask;
607 if (map) {
608 while ((map & (1 << i)) == 0) {
609 ++i;
610 }
611 TRACE(ft_t_noise, "at sector %d", FT_SECTOR(i));
612 } else {
613 map = buff->hard_error_map & mask;
614 i = buff->sector_offset - 1;
615 if (map) {
616 while ((map & (1 << i)) == 0) {
617 --i;
618 }
619 TRACE(ft_t_noise, "after sector %d", FT_SECTOR(i));
620 ++i; /* first sector after last hard error */
621 } else {
622 TRACE(ft_t_bug, "BUG: no soft or hard errors");
623 }
624 }
625 TRACE_EXIT i;
626}
627
628/* check possible dma residue when formatting, update position record in
629 * buffer struct. This is, of course, modelled after determine_progress(), but
630 * we don't need to set up for retries because the format process cannot be
631 * interrupted (except at the end of the tape track).
632 */
633static int determine_fmt_progress(buffer_struct *buff, error_cause cause)
634{
635 unsigned int dma_residue;
636 TRACE_FUN(ft_t_any);
637
638 /* Using less preferred order of disable_dma and
639 * get_dma_residue because this seems to fail on at least one
640 * system if reversed!
641 */
642 dma_residue = get_dma_residue(fdc.dma);
643 disable_dma(fdc.dma);
644 if (cause != no_error || dma_residue != 0) {
645 TRACE(ft_t_info, "DMA residue = 0x%04x", dma_residue);
646 fdc_mode = fdc_idle;
647 switch(cause) {
648 case no_error:
649 ft_runner_status = aborting;
650 buff->status = idle;
651 break;
652 case overrun_error:
653 /* got an overrun error on the first byte, must be a
654 * hardware problem
655 */
656 TRACE(ft_t_bug,
657 "Unexpected error: failing DMA controller ?");
658 ft_runner_status = do_abort;
659 buff->status = error;
660 break;
661 default:
662 TRACE(ft_t_noise, "Unexpected error at segment %d",
663 buff->segment_id);
664 ft_runner_status = do_abort;
665 buff->status = error;
666 break;
667 }
668 TRACE_EXIT -EIO; /* can only retry entire track in format mode
669 */
670 }
671 /* Update var's influenced by the DMA operation.
672 */
673 buff->ptr += FT_SECTORS_PER_SEGMENT * 4;
674 buff->bytes -= FT_SECTORS_PER_SEGMENT * 4;
675 buff->remaining -= FT_SECTORS_PER_SEGMENT;
676 buff->segment_id ++; /* done with segment */
677 TRACE_EXIT 0;
678}
679
680/*
681 * Continue formatting, switch buffers if there is no data left in
682 * current buffer. This is, of course, modelled after
683 * continue_xfer(), but we don't need to set up for retries because
684 * the format process cannot be interrupted (except at the end of the
685 * tape track).
686 */
687static void continue_formatting(buffer_struct *buff)
688{
689 TRACE_FUN(ft_t_any);
690
691 if (buff->remaining <= 0) { /* no space left in dma buffer */
692 unsigned int next = buff->next_segment;
693
694 if (next == 0) { /* end of tape track */
695 buff->status = done;
696 ft_runner_status = logical_eot;
697 fdc_mode = fdc_idle;
698 TRACE(ft_t_noise, "Done formatting track %d",
699 ft_location.track);
700 TRACE_EXIT;
701 }
702 /*
703 * switch to next buffer!
704 */
705 buff->status = done;
706 buff = ftape_next_buffer(ft_queue_head);
707
708 if (buff->status != waiting || next != buff->segment_id) {
709 goto format_setup_error;
710 }
711 }
712 if (fdc_setup_formatting(buff) < 0) {
713 goto format_setup_error;
714 }
715 buff->status = formatting;
716 TRACE(ft_t_fdc_dma, "Formatting segment %d on track %d",
717 buff->segment_id, ft_location.track);
718 TRACE_EXIT;
719 format_setup_error:
720 ft_runner_status = do_abort;
721 fdc_mode = fdc_idle;
722 buff->status = error;
723 TRACE(ft_t_err, "Error setting up for segment %d on track %d",
724 buff->segment_id, ft_location.track);
725 TRACE_EXIT;
726
727}
728
729/* this handles writing, read id, reading and formatting
730 */
731static void handle_fdc_busy(buffer_struct *buff)
732{
733 static int no_data_error_count;
734 int retry = 0;
735 error_cause cause;
736 __u8 in[7];
737 int skip;
738 fdc_mode_enum fmode = fdc_mode;
739 TRACE_FUN(ft_t_any);
740
741 if (fdc_result(in, 7) < 0) { /* better get it fast ! */
742 TRACE(ft_t_err,
743 "Probably fatal error during FDC Result Phase\n"
744 KERN_INFO
745 "drive may hang until (power on) reset :-(");
746 /* what to do next ????
747 */
748 TRACE_EXIT;
749 }
750 cause = decode_irq_cause(fdc_mode, in);
751#ifdef TESTING
752 { int i;
753 for (i = 0; i < (int)ft_nr_buffers; ++i)
754 TRACE(ft_t_any, "buffer[%d] status: %d, segment_id: %d",
755 i, ft_buffer[i]->status, ft_buffer[i]->segment_id);
756 }
757#endif
758 if (fmode == fdc_reading_data && ft_driver_state == verifying) {
759 fmode = fdc_verifying;
760 }
761 switch (fmode) {
762 case fdc_verifying:
763 if (ft_runner_status == aborting ||
764 ft_runner_status == do_abort) {
765 TRACE(ft_t_noise,"aborting %s",fdc_mode_txt(fdc_mode));
766 break;
767 }
768 if (buff->retry > 0) {
769 TRACE(ft_t_flow, "this is retry nr %d", buff->retry);
770 }
771 switch (cause) {
772 case no_error:
773 no_data_error_count = 0;
774 determine_verify_progress(buff, cause, in[5]);
775 if (in[2] & 0x40) {
776 /* This should not happen when verifying
777 */
778 TRACE(ft_t_warn,
779 "deleted data in segment %d/%d",
780 buff->segment_id,
781 FT_SECTOR(buff->sector_offset - 1));
782 buff->remaining = 0; /* abort transfer */
783 buff->hard_error_map = EMPTY_SEGMENT;
784 skip = 1;
785 } else {
786 skip = 0;
787 }
788 continue_xfer(buff, fdc_mode, skip);
789 break;
790 case no_data_error:
791 no_data_error_count ++;
792 case overrun_error:
793 retry ++;
794 case id_am_error:
795 case id_crc_error:
796 case data_am_error:
797 case data_crc_error:
798 determine_verify_progress(buff, cause, in[5]);
799 if (cause == no_data_error) {
800 if (no_data_error_count >= 2) {
801 TRACE(ft_t_warn,
802 "retrying because of successive "
803 "no data errors");
804 no_data_error_count = 0;
805 } else {
806 retry --;
807 }
808 } else {
809 no_data_error_count = 0;
810 }
811 if (retry) {
812 skip = find_resume_point(buff);
813 } else {
814 skip = buff->sector_offset;
815 }
816 if (retry && skip < 32) {
817 retry_sector(buff, fdc_mode, skip);
818 } else {
819 continue_xfer(buff, fdc_mode, skip);
820 }
821 update_history(cause);
822 break;
823 default:
824 /* Don't know why this could happen
825 * but find out.
826 */
827 determine_verify_progress(buff, cause, in[5]);
828 retry_sector(buff, fdc_mode, 0);
829 TRACE(ft_t_err, "Error: unexpected error");
830 break;
831 }
832 break;
833 case fdc_reading_data:
834#ifdef TESTING
835 /* I'm sorry, but: NOBODY ever used this trace
836 * messages for ages. I guess that Bas was the last person
837 * that ever really used this (thank you, between the lines)
838 */
839 if (cause == no_error) {
840 TRACE(ft_t_flow,"reading segment %d",buff->segment_id);
841 } else {
842 TRACE(ft_t_noise, "error reading segment %d",
843 buff->segment_id);
844 TRACE(ft_t_noise, "\n"
845 KERN_INFO
846 "IRQ:C: 0x%02x, H: 0x%02x, R: 0x%02x, N: 0x%02x\n"
847 KERN_INFO
848 "BUF:C: 0x%02x, H: 0x%02x, R: 0x%02x",
849 in[3], in[4], in[5], in[6],
850 buff->cyl, buff->head, buff->sect);
851 }
852#endif
853 if (ft_runner_status == aborting ||
854 ft_runner_status == do_abort) {
855 TRACE(ft_t_noise,"aborting %s",fdc_mode_txt(fdc_mode));
856 break;
857 }
858 if (buff->bad_sector_map == FAKE_SEGMENT) {
859 /* This condition occurs when reading a `fake'
860 * sector that's not accessible. Doesn't
861 * really matter as we would have ignored it
862 * anyway !
863 *
864 * Chance is that we're past the next segment
865 * now, so the next operation may fail and
866 * result in a retry.
867 */
868 buff->remaining = 0; /* skip failing sector */
869 /* buff->ptr = buff->address; */
870 /* fake success: */
871 continue_xfer(buff, fdc_mode, 1);
872 /* trace calls are expensive: place them AFTER
873 * the real stuff has been done.
874 *
875 */
876 TRACE(ft_t_noise, "skipping empty segment %d (read), size? %d",
877 buff->segment_id, buff->ptr - buff->address);
878 TRACE_EXIT;
879 }
880 if (buff->retry > 0) {
881 TRACE(ft_t_flow, "this is retry nr %d", buff->retry);
882 }
883 switch (cause) {
884 case no_error:
885 determine_progress(buff, cause, in[5]);
886 if (in[2] & 0x40) {
887 /* Handle deleted data in header segments.
888 * Skip segment and force read-ahead.
889 */
890 TRACE(ft_t_warn,
891 "deleted data in segment %d/%d",
892 buff->segment_id,
893 FT_SECTOR(buff->sector_offset - 1));
894 buff->deleted = 1;
895 buff->remaining = 0;/*abort transfer */
896 buff->soft_error_map |=
897 (-1L << buff->sector_offset);
898 if (buff->segment_id == 0) {
899 /* stop on next segment */
900 stop_read_ahead = 1;
901 }
902 /* force read-ahead: */
903 buff->next_segment =
904 buff->segment_id + 1;
905 skip = (FT_SECTORS_PER_SEGMENT -
906 buff->sector_offset);
907 } else {
908 skip = 0;
909 }
910 continue_xfer(buff, fdc_mode, skip);
911 break;
912 case no_data_error:
913 /* Tape started too far ahead of or behind the
914 * right sector. This may also happen in the
915 * middle of a segment !
916 *
917 * Handle no-data as soft error. If next
918 * sector fails too, a retry (with needed
919 * reposition) will follow.
920 */
921 retry ++;
922 case id_am_error:
923 case id_crc_error:
924 case data_am_error:
925 case data_crc_error:
926 case overrun_error:
927 retry += (buff->soft_error_map != 0 ||
928 buff->hard_error_map != 0);
929 determine_progress(buff, cause, in[5]);
930#if 1 || defined(TESTING)
931 if (cause == overrun_error) retry ++;
932#endif
933 if (retry) {
934 skip = find_resume_point(buff);
935 } else {
936 skip = buff->sector_offset;
937 }
938 /* Try to resume with next sector on single
939 * errors (let ecc correct it), but retry on
940 * no_data (we'll be past the target when we
941 * get here so we cannot retry) or on
942 * multiple errors (reduce chance on ecc
943 * failure).
944 */
945 /* cH: 23/02/97: if the last sector in the
946 * segment was a hard error, then there is
947 * no sense in a retry. This occasion seldom
948 * occurs but ... @:³²¸`@%&§$
949 */
950 if (retry && skip < 32) {
951 retry_sector(buff, fdc_mode, skip);
952 } else {
953 continue_xfer(buff, fdc_mode, skip);
954 }
955 update_history(cause);
956 break;
957 default:
958 /* Don't know why this could happen
959 * but find out.
960 */
961 determine_progress(buff, cause, in[5]);
962 retry_sector(buff, fdc_mode, 0);
963 TRACE(ft_t_err, "Error: unexpected error");
964 break;
965 }
966 break;
967 case fdc_reading_id:
968 if (cause == no_error) {
969 fdc_cyl = in[3];
970 fdc_head = in[4];
971 fdc_sect = in[5];
972 TRACE(ft_t_fdc_dma,
973 "id read: C: 0x%02x, H: 0x%02x, R: 0x%02x",
974 fdc_cyl, fdc_head, fdc_sect);
975 } else { /* no valid information, use invalid sector */
976 fdc_cyl = fdc_head = fdc_sect = 0;
977 TRACE(ft_t_flow, "Didn't find valid sector Id");
978 }
979 fdc_mode = fdc_idle;
980 break;
981 case fdc_deleting:
982 case fdc_writing_data:
983#ifdef TESTING
984 if (cause == no_error) {
985 TRACE(ft_t_flow, "writing segment %d", buff->segment_id);
986 } else {
987 TRACE(ft_t_noise, "error writing segment %d",
988 buff->segment_id);
989 }
990#endif
991 if (ft_runner_status == aborting ||
992 ft_runner_status == do_abort) {
993 TRACE(ft_t_flow, "aborting %s",fdc_mode_txt(fdc_mode));
994 break;
995 }
996 if (buff->retry > 0) {
997 TRACE(ft_t_flow, "this is retry nr %d", buff->retry);
998 }
999 if (buff->bad_sector_map == FAKE_SEGMENT) {
1000 /* This condition occurs when trying to write to a
1001 * `fake' sector that's not accessible. Doesn't really
1002 * matter as it isn't used anyway ! Might be located
1003 * at wrong segment, then we'll fail on the next
1004 * segment.
1005 */
1006 TRACE(ft_t_noise, "skipping empty segment (write)");
1007 buff->remaining = 0; /* skip failing sector */
1008 /* fake success: */
1009 continue_xfer(buff, fdc_mode, 1);
1010 break;
1011 }
1012 switch (cause) {
1013 case no_error:
1014 determine_progress(buff, cause, in[5]);
1015 continue_xfer(buff, fdc_mode, 0);
1016 break;
1017 case no_data_error:
1018 case id_am_error:
1019 case id_crc_error:
1020 case data_am_error:
1021 case overrun_error:
1022 update_history(cause);
1023 determine_progress(buff, cause, in[5]);
1024 skip = find_resume_point(buff);
1025 retry_sector(buff, fdc_mode, skip);
1026 break;
1027 default:
1028 if (in[1] & 0x02) {
1029 TRACE(ft_t_err, "media not writable");
1030 } else {
1031 TRACE(ft_t_bug, "unforeseen write error");
1032 }
1033 fdc_mode = fdc_idle;
1034 break;
1035 }
1036 break; /* fdc_deleting || fdc_writing_data */
1037 case fdc_formatting:
1038 /* The interrupt comes after formatting a segment. We then
1039 * have to set up QUICKLY for the next segment. But
1040 * afterwards, there is plenty of time.
1041 */
1042 switch (cause) {
1043 case no_error:
1044 /* would like to keep most of the formatting stuff
1045 * outside the isr code, but timing is too critical
1046 */
1047 if (determine_fmt_progress(buff, cause) >= 0) {
1048 continue_formatting(buff);
1049 }
1050 break;
1051 case no_data_error:
1052 case id_am_error:
1053 case id_crc_error:
1054 case data_am_error:
1055 case overrun_error:
1056 default:
1057 determine_fmt_progress(buff, cause);
1058 update_history(cause);
1059 if (in[1] & 0x02) {
1060 TRACE(ft_t_err, "media not writable");
1061 } else {
1062 TRACE(ft_t_bug, "unforeseen write error");
1063 }
1064 break;
1065 } /* cause */
1066 break;
1067 default:
1068 TRACE(ft_t_warn, "Warning: unexpected irq during: %s",
1069 fdc_mode_txt(fdc_mode));
1070 fdc_mode = fdc_idle;
1071 break;
1072 }
1073 TRACE_EXIT;
1074}
1075
1076/* FDC interrupt service routine.
1077 */
1078void fdc_isr(void)
1079{
1080 static int isr_active;
1081#ifdef TESTING
1082 unsigned int t0 = ftape_timestamp();
1083#endif
1084 TRACE_FUN(ft_t_any);
1085
1086 if (isr_active++) {
1087 --isr_active;
1088 TRACE(ft_t_bug, "BUG: nested interrupt, not good !");
1089 *fdc.hook = fdc_isr; /* hook our handler into the fdc
1090 * code again
1091 */
1092 TRACE_EXIT;
1093 }
1094 sti();
1095 if (inb_p(fdc.msr) & FDC_BUSY) { /* Entering Result Phase */
1096 ft_hide_interrupt = 0;
1097 handle_fdc_busy(ftape_get_buffer(ft_queue_head));
1098 if (ft_runner_status == do_abort) {
1099 /* cease operation, remember tape position
1100 */
1101 TRACE(ft_t_flow, "runner aborting");
1102 ft_runner_status = aborting;
1103 ++ft_expected_stray_interrupts;
1104 }
1105 } else { /* !FDC_BUSY */
1106 /* clear interrupt, cause should be gotten by issuing
1107 * a Sense Interrupt Status command.
1108 */
1109 if (fdc_mode == fdc_recalibrating || fdc_mode == fdc_seeking) {
1110 if (ft_hide_interrupt) {
1111 int st0;
1112 int pcn;
1113
1114 if (fdc_sense_interrupt_status(&st0, &pcn) < 0)
1115 TRACE(ft_t_err,
1116 "sense interrupt status failed");
1117 ftape_current_cylinder = pcn;
1118 TRACE(ft_t_flow, "handled hidden interrupt");
1119 }
1120 ft_seek_completed = 1;
1121 fdc_mode = fdc_idle;
1122 } else if (!waitqueue_active(&ftape_wait_intr)) {
1123 if (ft_expected_stray_interrupts == 0) {
1124 TRACE(ft_t_warn, "unexpected stray interrupt");
1125 } else {
1126 TRACE(ft_t_flow, "expected stray interrupt");
1127 --ft_expected_stray_interrupts;
1128 }
1129 } else {
1130 if (fdc_mode == fdc_reading_data ||
1131 fdc_mode == fdc_verifying ||
1132 fdc_mode == fdc_writing_data ||
1133 fdc_mode == fdc_deleting ||
1134 fdc_mode == fdc_formatting ||
1135 fdc_mode == fdc_reading_id) {
1136 if (inb_p(fdc.msr) & FDC_BUSY) {
1137 TRACE(ft_t_bug,
1138 "***** FDC failure, busy too late");
1139 } else {
1140 TRACE(ft_t_bug,
1141 "***** FDC failure, no busy");
1142 }
1143 } else {
1144 TRACE(ft_t_fdc_dma, "awaited stray interrupt");
1145 }
1146 }
1147 ft_hide_interrupt = 0;
1148 }
1149 /* Handle sleep code.
1150 */
1151 if (!ft_hide_interrupt) {
1152 ft_interrupt_seen ++;
1153 if (waitqueue_active(&ftape_wait_intr)) {
1154 wake_up_interruptible(&ftape_wait_intr);
1155 }
1156 } else {
1157 TRACE(ft_t_flow, "hiding interrupt while %s",
1158 waitqueue_active(&ftape_wait_intr) ? "waiting":"active");
1159 }
1160#ifdef TESTING
1161 t0 = ftape_timediff(t0, ftape_timestamp());
1162 if (t0 >= 1000) {
1163 /* only tell us about long calls */
1164 TRACE(ft_t_noise, "isr() duration: %5d usec", t0);
1165 }
1166#endif
1167 *fdc.hook = fdc_isr; /* hook our handler into the fdc code again */
1168 --isr_active;
1169 TRACE_EXIT;
1170}
diff --git a/drivers/char/ftape/lowlevel/fdc-isr.h b/drivers/char/ftape/lowlevel/fdc-isr.h
deleted file mode 100644
index 065aa978942d..000000000000
--- a/drivers/char/ftape/lowlevel/fdc-isr.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef _FDC_ISR_H
2#define _FDC_ISR_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/fdc-isr.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:07 $
26 *
27 * This file declares the global variables necessary to
28 * synchronize the interrupt service routine (isr) with the
29 * remainder of the QIC-40/80/3010/3020 floppy-tape driver
30 * "ftape" for Linux.
31 */
32
33/*
34 * fdc-isr.c defined public variables
35 */
36extern volatile int ft_expected_stray_interrupts; /* masks stray interrupts */
37extern volatile int ft_seek_completed; /* flag set by isr */
38extern volatile int ft_interrupt_seen; /* flag set by isr */
39extern volatile int ft_hide_interrupt; /* flag set by isr */
40
41/*
42 * fdc-io.c defined public functions
43 */
44extern void fdc_isr(void);
45
46/*
47 * A kernel hook that steals one interrupt from the floppy
48 * driver (Should be fixed when the new fdc driver gets ready)
49 * See the linux kernel source files:
50 * drivers/block/floppy.c & drivers/block/blk.h
51 * for the details.
52 */
53extern void (*do_floppy) (void);
54
55#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-bsm.c b/drivers/char/ftape/lowlevel/ftape-bsm.c
deleted file mode 100644
index d1a301cc344f..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-bsm.c
+++ /dev/null
@@ -1,491 +0,0 @@
1/*
2 * Copyright (C) 1994-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-bsm.c,v $
21 * $Revision: 1.3 $
22 * $Date: 1997/10/05 19:15:15 $
23 *
24 * This file contains the bad-sector map handling code for
25 * the QIC-117 floppy tape driver for Linux.
26 * QIC-40, QIC-80, QIC-3010 and QIC-3020 maps are implemented.
27 */
28
29#include <linux/string.h>
30
31#include <linux/ftape.h>
32#include "../lowlevel/ftape-tracing.h"
33#include "../lowlevel/ftape-bsm.h"
34#include "../lowlevel/ftape-ctl.h"
35#include "../lowlevel/ftape-rw.h"
36
37/* Global vars.
38 */
39
40/* Local vars.
41 */
42static __u8 *bad_sector_map;
43static SectorCount *bsm_hash_ptr;
44
45typedef enum {
46 forward, backward
47} mode_type;
48
49#if 0
50static void ftape_put_bad_sector_entry(int segment_id, SectorMap new_map);
51#endif
52
53#if 0
54/* fix_tape converts a normal QIC-80 tape into a 'wide' tape.
55 * For testing purposes only !
56 */
57void fix_tape(__u8 * buffer, ft_format_type new_code)
58{
59 static __u8 list[BAD_SECTOR_MAP_SIZE];
60 SectorMap *src_ptr = (SectorMap *) list;
61 __u8 *dst_ptr = bad_sector_map;
62 SectorMap map;
63 unsigned int sector = 1;
64 int i;
65
66 if (format_code != fmt_var && format_code != fmt_big) {
67 memcpy(list, bad_sector_map, sizeof(list));
68 memset(bad_sector_map, 0, sizeof(bad_sector_map));
69 while ((__u8 *) src_ptr - list < sizeof(list)) {
70 map = *src_ptr++;
71 if (map == EMPTY_SEGMENT) {
72 *(SectorMap *) dst_ptr = 0x800000 + sector;
73 dst_ptr += 3;
74 sector += SECTORS_PER_SEGMENT;
75 } else {
76 for (i = 0; i < SECTORS_PER_SEGMENT; ++i) {
77 if (map & 1) {
78 *(SewctorMap *) dst_ptr = sector;
79 dst_ptr += 3;
80 }
81 map >>= 1;
82 ++sector;
83 }
84 }
85 }
86 }
87 bad_sector_map_changed = 1;
88 *(buffer + 4) = new_code; /* put new format code */
89 if (format_code != fmt_var && new_code == fmt_big) {
90 PUT4(buffer, FT_6_HSEG_1, (__u32)GET2(buffer, 6));
91 PUT4(buffer, FT_6_HSEG_2, (__u32)GET2(buffer, 8));
92 PUT4(buffer, FT_6_FRST_SEG, (__u32)GET2(buffer, 10));
93 PUT4(buffer, FT_6_LAST_SEG, (__u32)GET2(buffer, 12));
94 memset(buffer+6, '\0', 8);
95 }
96 format_code = new_code;
97}
98
99#endif
100
101/* given buffer that contains a header segment, find the end of
102 * of the bsm list
103 */
104__u8 * ftape_find_end_of_bsm_list(__u8 * address)
105{
106 __u8 *ptr = address + FT_HEADER_END; /* start of bsm list */
107 __u8 *limit = address + FT_SEGMENT_SIZE;
108 while (ptr + 2 < limit) {
109 if (ptr[0] || ptr[1] || ptr[2]) {
110 ptr += 3;
111 } else {
112 return ptr;
113 }
114 }
115 return NULL;
116}
117
118static inline void put_sector(SectorCount *ptr, unsigned int sector)
119{
120 ptr->bytes[0] = sector & 0xff;
121 sector >>= 8;
122 ptr->bytes[1] = sector & 0xff;
123 sector >>= 8;
124 ptr->bytes[2] = sector & 0xff;
125}
126
127static inline unsigned int get_sector(SectorCount *ptr)
128{
129#if 1
130 unsigned int sector;
131
132 sector = ptr->bytes[0];
133 sector += ptr->bytes[1] << 8;
134 sector += ptr->bytes[2] << 16;
135
136 return sector;
137#else
138 /* GET4 gets the next four bytes in Intel little endian order
139 * and converts them to host byte order and handles unaligned
140 * access.
141 */
142 return (GET4(ptr, 0) & 0x00ffffff); /* back to host byte order */
143#endif
144}
145
146static void bsm_debug_fake(void)
147{
148 /* for testing of bad sector handling at end of tape
149 */
150#if 0
151 ftape_put_bad_sector_entry(segments_per_track * tracks_per_tape - 3,
152 0x000003e0;
153 ftape_put_bad_sector_entry(segments_per_track * tracks_per_tape - 2,
154 0xff3fffff;
155 ftape_put_bad_sector_entry(segments_per_track * tracks_per_tape - 1,
156 0xffffe000;
157#endif
158 /* Enable to test bad sector handling
159 */
160#if 0
161 ftape_put_bad_sector_entry(30, 0xfffffffe)
162 ftape_put_bad_sector_entry(32, 0x7fffffff);
163 ftape_put_bad_sector_entry(34, 0xfffeffff);
164 ftape_put_bad_sector_entry(36, 0x55555555);
165 ftape_put_bad_sector_entry(38, 0xffffffff);
166 ftape_put_bad_sector_entry(50, 0xffff0000);
167 ftape_put_bad_sector_entry(51, 0xffffffff);
168 ftape_put_bad_sector_entry(52, 0xffffffff);
169 ftape_put_bad_sector_entry(53, 0x0000ffff);
170#endif
171 /* Enable when testing multiple volume tar dumps.
172 */
173#if 0
174 {
175 int i;
176
177 for (i = ft_first_data_segment;
178 i <= ft_last_data_segment - 7; ++i) {
179 ftape_put_bad_sector_entry(i, EMPTY_SEGMENT);
180 }
181 }
182#endif
183 /* Enable when testing bit positions in *_error_map
184 */
185#if 0
186 {
187 int i;
188
189 for (i = first_data_segment; i <= last_data_segment; ++i) {
190 ftape_put_bad_sector_entry(i,
191 ftape_get_bad_sector_entry(i)
192 | 0x00ff00ff);
193 }
194 }
195#endif
196}
197
198static void print_bad_sector_map(void)
199{
200 unsigned int good_sectors;
201 unsigned int total_bad = 0;
202 int i;
203 TRACE_FUN(ft_t_flow);
204
205 if (ft_format_code == fmt_big ||
206 ft_format_code == fmt_var ||
207 ft_format_code == fmt_1100ft) {
208 SectorCount *ptr = (SectorCount *)bad_sector_map;
209 unsigned int sector;
210 __u16 *ptr16;
211
212 while((sector = get_sector(ptr++)) != 0) {
213 if ((ft_format_code == fmt_big ||
214 ft_format_code == fmt_var) &&
215 sector & 0x800000) {
216 total_bad += FT_SECTORS_PER_SEGMENT - 3;
217 TRACE(ft_t_noise, "bad segment at sector: %6d",
218 sector & 0x7fffff);
219 } else {
220 ++total_bad;
221 TRACE(ft_t_noise, "bad sector: %6d", sector);
222 }
223 }
224 /* Display old ftape's end-of-file marks
225 */
226 ptr16 = (__u16*)ptr;
227 while ((sector = get_unaligned(ptr16++)) != 0) {
228 TRACE(ft_t_noise, "Old ftape eof mark: %4d/%2d",
229 sector, get_unaligned(ptr16++));
230 }
231 } else { /* fixed size format */
232 for (i = ft_first_data_segment;
233 i < (int)(ft_segments_per_track * ft_tracks_per_tape); ++i) {
234 SectorMap map = ((SectorMap *) bad_sector_map)[i];
235
236 if (map) {
237 TRACE(ft_t_noise,
238 "bsm for segment %4d: 0x%08x", i, (unsigned int)map);
239 total_bad += ((map == EMPTY_SEGMENT)
240 ? FT_SECTORS_PER_SEGMENT - 3
241 : count_ones(map));
242 }
243 }
244 }
245 good_sectors =
246 ((ft_segments_per_track * ft_tracks_per_tape - ft_first_data_segment)
247 * (FT_SECTORS_PER_SEGMENT - 3)) - total_bad;
248 TRACE(ft_t_info, "%d Kb usable on this tape", good_sectors);
249 if (total_bad == 0) {
250 TRACE(ft_t_info,
251 "WARNING: this tape has no bad blocks registered !");
252 } else {
253 TRACE(ft_t_info, "%d bad sectors", total_bad);
254 }
255 TRACE_EXIT;
256}
257
258
259void ftape_extract_bad_sector_map(__u8 * buffer)
260{
261 TRACE_FUN(ft_t_any);
262
263 /* Fill the bad sector map with the contents of buffer.
264 */
265 if (ft_format_code == fmt_var || ft_format_code == fmt_big) {
266 /* QIC-3010/3020 and wide QIC-80 tapes no longer have a failed
267 * sector log but use this area to extend the bad sector map.
268 */
269 bad_sector_map = &buffer[FT_HEADER_END];
270 } else {
271 /* non-wide QIC-80 tapes have a failed sector log area that
272 * mustn't be included in the bad sector map.
273 */
274 bad_sector_map = &buffer[FT_FSL + FT_FSL_SIZE];
275 }
276 if (ft_format_code == fmt_1100ft ||
277 ft_format_code == fmt_var ||
278 ft_format_code == fmt_big) {
279 bsm_hash_ptr = (SectorCount *)bad_sector_map;
280 } else {
281 bsm_hash_ptr = NULL;
282 }
283 bsm_debug_fake();
284 if (TRACE_LEVEL >= ft_t_info) {
285 print_bad_sector_map();
286 }
287 TRACE_EXIT;
288}
289
290static inline SectorMap cvt2map(unsigned int sector)
291{
292 return 1 << (((sector & 0x7fffff) - 1) % FT_SECTORS_PER_SEGMENT);
293}
294
295static inline int cvt2segment(unsigned int sector)
296{
297 return ((sector & 0x7fffff) - 1) / FT_SECTORS_PER_SEGMENT;
298}
299
300static int forward_seek_entry(int segment_id,
301 SectorCount **ptr,
302 SectorMap *map)
303{
304 unsigned int sector;
305 int segment;
306
307 do {
308 sector = get_sector((*ptr)++);
309 segment = cvt2segment(sector);
310 } while (sector != 0 && segment < segment_id);
311 (*ptr) --; /* point to first sector >= segment_id */
312 /* Get all sectors in segment_id
313 */
314 if (sector == 0 || segment != segment_id) {
315 *map = 0;
316 return 0;
317 } else if ((sector & 0x800000) &&
318 (ft_format_code == fmt_var || ft_format_code == fmt_big)) {
319 *map = EMPTY_SEGMENT;
320 return FT_SECTORS_PER_SEGMENT;
321 } else {
322 int count = 1;
323 SectorCount *tmp_ptr = (*ptr) + 1;
324
325 *map = cvt2map(sector);
326 while ((sector = get_sector(tmp_ptr++)) != 0 &&
327 (segment = cvt2segment(sector)) == segment_id) {
328 *map |= cvt2map(sector);
329 ++count;
330 }
331 return count;
332 }
333}
334
335static int backwards_seek_entry(int segment_id,
336 SectorCount **ptr,
337 SectorMap *map)
338{
339 unsigned int sector;
340 int segment; /* max unsigned int */
341
342 if (*ptr <= (SectorCount *)bad_sector_map) {
343 *map = 0;
344 return 0;
345 }
346 do {
347 sector = get_sector(--(*ptr));
348 segment = cvt2segment(sector);
349 } while (*ptr > (SectorCount *)bad_sector_map && segment > segment_id);
350 if (segment > segment_id) { /* at start of list, no entry found */
351 *map = 0;
352 return 0;
353 } else if (segment < segment_id) {
354 /* before smaller entry, adjust for overshoot */
355 (*ptr) ++;
356 *map = 0;
357 return 0;
358 } else if ((sector & 0x800000) &&
359 (ft_format_code == fmt_big || ft_format_code == fmt_var)) {
360 *map = EMPTY_SEGMENT;
361 return FT_SECTORS_PER_SEGMENT;
362 } else { /* get all sectors in segment_id */
363 int count = 1;
364
365 *map = cvt2map(sector);
366 while(*ptr > (SectorCount *)bad_sector_map) {
367 sector = get_sector(--(*ptr));
368 segment = cvt2segment(sector);
369 if (segment != segment_id) {
370 break;
371 }
372 *map |= cvt2map(sector);
373 ++count;
374 }
375 if (segment < segment_id) {
376 (*ptr) ++;
377 }
378 return count;
379 }
380}
381
382#if 0
383static void ftape_put_bad_sector_entry(int segment_id, SectorMap new_map)
384{
385 SectorCount *ptr = (SectorCount *)bad_sector_map;
386 int count;
387 int new_count;
388 SectorMap map;
389 TRACE_FUN(ft_t_any);
390
391 if (ft_format_code == fmt_1100ft ||
392 ft_format_code == fmt_var ||
393 ft_format_code == fmt_big) {
394 count = forward_seek_entry(segment_id, &ptr, &map);
395 new_count = count_ones(new_map);
396 /* If format code == 4 put empty segment instead of 32
397 * bad sectors.
398 */
399 if (ft_format_code == fmt_var || ft_format_code == fmt_big) {
400 if (new_count == FT_SECTORS_PER_SEGMENT) {
401 new_count = 1;
402 }
403 if (count == FT_SECTORS_PER_SEGMENT) {
404 count = 1;
405 }
406 }
407 if (count != new_count) {
408 /* insert (or delete if < 0) new_count - count
409 * entries. Move trailing part of list
410 * including terminating 0.
411 */
412 SectorCount *hi_ptr = ptr;
413
414 do {
415 } while (get_sector(hi_ptr++) != 0);
416 /* Note: ptr is of type byte *, and each bad sector
417 * consumes 3 bytes.
418 */
419 memmove(ptr + new_count, ptr + count,
420 (size_t)(hi_ptr - (ptr + count))*sizeof(SectorCount));
421 }
422 TRACE(ft_t_noise, "putting map 0x%08x at %p, segment %d",
423 (unsigned int)new_map, ptr, segment_id);
424 if (new_count == 1 && new_map == EMPTY_SEGMENT) {
425 put_sector(ptr++, (0x800001 +
426 segment_id *
427 FT_SECTORS_PER_SEGMENT));
428 } else {
429 int i = 0;
430
431 while (new_map) {
432 if (new_map & 1) {
433 put_sector(ptr++,
434 1 + segment_id *
435 FT_SECTORS_PER_SEGMENT + i);
436 }
437 ++i;
438 new_map >>= 1;
439 }
440 }
441 } else {
442 ((SectorMap *) bad_sector_map)[segment_id] = new_map;
443 }
444 TRACE_EXIT;
445}
446#endif /* 0 */
447
448SectorMap ftape_get_bad_sector_entry(int segment_id)
449{
450 if (ft_used_header_segment == -1) {
451 /* When reading header segment we'll need a blank map.
452 */
453 return 0;
454 } else if (bsm_hash_ptr != NULL) {
455 /* Invariants:
456 * map - mask value returned on last call.
457 * bsm_hash_ptr - points to first sector greater or equal to
458 * first sector in last_referenced segment.
459 * last_referenced - segment id used in the last call,
460 * sector and map belong to this id.
461 * This code is designed for sequential access and retries.
462 * For true random access it may have to be redesigned.
463 */
464 static int last_reference = -1;
465 static SectorMap map;
466
467 if (segment_id > last_reference) {
468 /* Skip all sectors before segment_id
469 */
470 forward_seek_entry(segment_id, &bsm_hash_ptr, &map);
471 } else if (segment_id < last_reference) {
472 /* Skip backwards until begin of buffer or
473 * first sector in segment_id
474 */
475 backwards_seek_entry(segment_id, &bsm_hash_ptr, &map);
476 } /* segment_id == last_reference : keep map */
477 last_reference = segment_id;
478 return map;
479 } else {
480 return ((SectorMap *) bad_sector_map)[segment_id];
481 }
482}
483
484/* This is simply here to prevent us from overwriting other kernel
485 * data. Writes will result in NULL Pointer dereference.
486 */
487void ftape_init_bsm(void)
488{
489 bad_sector_map = NULL;
490 bsm_hash_ptr = NULL;
491}
diff --git a/drivers/char/ftape/lowlevel/ftape-bsm.h b/drivers/char/ftape/lowlevel/ftape-bsm.h
deleted file mode 100644
index ed45465af4d4..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-bsm.h
+++ /dev/null
@@ -1,66 +0,0 @@
1#ifndef _FTAPE_BSM_H
2#define _FTAPE_BSM_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-bsm.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:07 $
26 *
27 * This file contains definitions for the bad sector map handling
28 * routines for the QIC-117 floppy-tape driver for Linux.
29 */
30
31#include <linux/ftape.h>
32#include <linux/ftape-header-segment.h>
33
34#define EMPTY_SEGMENT (0xffffffff)
35#define FAKE_SEGMENT (0xfffffffe)
36
37/* maximum (format code 4) bad sector map size (bytes).
38 */
39#define BAD_SECTOR_MAP_SIZE (29 * SECTOR_SIZE - 256)
40
41/* format code 4 bad sector entry, ftape uses this
42 * internally for all format codes
43 */
44typedef __u32 SectorMap;
45/* variable and 1100 ft bad sector map entry. These three bytes represent
46 * a single sector address measured from BOT.
47 */
48typedef struct NewSectorMap {
49 __u8 bytes[3];
50} SectorCount;
51
52
53/*
54 * ftape-bsm.c defined global vars.
55 */
56
57/*
58 * ftape-bsm.c defined global functions.
59 */
60extern void update_bad_sector_map(__u8 * buffer);
61extern void ftape_extract_bad_sector_map(__u8 * buffer);
62extern SectorMap ftape_get_bad_sector_entry(int segment_id);
63extern __u8 *ftape_find_end_of_bsm_list(__u8 * address);
64extern void ftape_init_bsm(void);
65
66#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-buffer.c b/drivers/char/ftape/lowlevel/ftape-buffer.c
deleted file mode 100644
index c706ff162771..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-buffer.c
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 * Copyright (C) 1997 Claus-Justus Heine
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-buffer.c,v $
20 * $Revision: 1.3 $
21 * $Date: 1997/10/16 23:33:11 $
22 *
23 * This file contains the allocator/dealloctor for ftape's dynamic dma
24 * buffer.
25 */
26
27#include <linux/slab.h>
28#include <linux/mm.h>
29#include <linux/mman.h>
30#include <asm/dma.h>
31
32#include <linux/ftape.h>
33#include "../lowlevel/ftape-rw.h"
34#include "../lowlevel/ftape-read.h"
35#include "../lowlevel/ftape-tracing.h"
36#include "../lowlevel/ftape-buffer.h"
37
38/* DMA'able memory allocation stuff.
39 */
40
41static inline void *dmaalloc(size_t size)
42{
43 unsigned long addr;
44
45 if (size == 0) {
46 return NULL;
47 }
48 addr = __get_dma_pages(GFP_KERNEL, get_order(size));
49 if (addr) {
50 struct page *page;
51
52 for (page = virt_to_page(addr); page < virt_to_page(addr+size); page++)
53 SetPageReserved(page);
54 }
55 return (void *)addr;
56}
57
58static inline void dmafree(void *addr, size_t size)
59{
60 if (size > 0) {
61 struct page *page;
62
63 for (page = virt_to_page((unsigned long)addr);
64 page < virt_to_page((unsigned long)addr+size); page++)
65 ClearPageReserved(page);
66 free_pages((unsigned long) addr, get_order(size));
67 }
68}
69
70static int add_one_buffer(void)
71{
72 TRACE_FUN(ft_t_flow);
73
74 if (ft_nr_buffers >= FT_MAX_NR_BUFFERS) {
75 TRACE_EXIT -ENOMEM;
76 }
77 ft_buffer[ft_nr_buffers] = kmalloc(sizeof(buffer_struct), GFP_KERNEL);
78 if (ft_buffer[ft_nr_buffers] == NULL) {
79 TRACE_EXIT -ENOMEM;
80 }
81 memset(ft_buffer[ft_nr_buffers], 0, sizeof(buffer_struct));
82 ft_buffer[ft_nr_buffers]->address = dmaalloc(FT_BUFF_SIZE);
83 if (ft_buffer[ft_nr_buffers]->address == NULL) {
84 kfree(ft_buffer[ft_nr_buffers]);
85 ft_buffer[ft_nr_buffers] = NULL;
86 TRACE_EXIT -ENOMEM;
87 }
88 ft_nr_buffers ++;
89 TRACE(ft_t_info, "buffer nr #%d @ %p, dma area @ %p",
90 ft_nr_buffers,
91 ft_buffer[ft_nr_buffers-1],
92 ft_buffer[ft_nr_buffers-1]->address);
93 TRACE_EXIT 0;
94}
95
96static void del_one_buffer(void)
97{
98 TRACE_FUN(ft_t_flow);
99 if (ft_nr_buffers > 0) {
100 TRACE(ft_t_info, "releasing buffer nr #%d @ %p, dma area @ %p",
101 ft_nr_buffers,
102 ft_buffer[ft_nr_buffers-1],
103 ft_buffer[ft_nr_buffers-1]->address);
104 ft_nr_buffers --;
105 dmafree(ft_buffer[ft_nr_buffers]->address, FT_BUFF_SIZE);
106 kfree(ft_buffer[ft_nr_buffers]);
107 ft_buffer[ft_nr_buffers] = NULL;
108 }
109 TRACE_EXIT;
110}
111
112int ftape_set_nr_buffers(int cnt)
113{
114 int delta = cnt - ft_nr_buffers;
115 TRACE_FUN(ft_t_flow);
116
117 if (delta > 0) {
118 while (delta--) {
119 if (add_one_buffer() < 0) {
120 TRACE_EXIT -ENOMEM;
121 }
122 }
123 } else if (delta < 0) {
124 while (delta++) {
125 del_one_buffer();
126 }
127 }
128 ftape_zap_read_buffers();
129 TRACE_EXIT 0;
130}
diff --git a/drivers/char/ftape/lowlevel/ftape-buffer.h b/drivers/char/ftape/lowlevel/ftape-buffer.h
deleted file mode 100644
index eec99cee8f82..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-buffer.h
+++ /dev/null
@@ -1,32 +0,0 @@
1#ifndef _FTAPE_BUFFER_H
2#define _FTAPE_BUFFER_H
3
4/*
5 * Copyright (C) 1997 Claus-Justus Heine.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-buffer.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:18:08 $
25 *
26 * This file contains the allocator/dealloctor for ftape's dynamic dma
27 * buffer.
28 */
29
30extern int ftape_set_nr_buffers(int cnt);
31
32#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-calibr.c b/drivers/char/ftape/lowlevel/ftape-calibr.c
deleted file mode 100644
index 8e50bfd35a52..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-calibr.c
+++ /dev/null
@@ -1,275 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven.
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-calibr.c,v $
20 * $Revision: 1.2 $
21 * $Date: 1997/10/05 19:18:08 $
22 *
23 * GP calibration routine for processor speed dependent
24 * functions.
25 */
26
27#include <linux/errno.h>
28#include <linux/jiffies.h>
29#include <asm/system.h>
30#include <asm/io.h>
31#if defined(__alpha__)
32# include <asm/hwrpb.h>
33#elif defined(__x86_64__)
34# include <asm/msr.h>
35# include <asm/timex.h>
36#elif defined(__i386__)
37# include <linux/timex.h>
38#endif
39#include <linux/ftape.h>
40#include "../lowlevel/ftape-tracing.h"
41#include "../lowlevel/ftape-calibr.h"
42#include "../lowlevel/fdc-io.h"
43
44#undef DEBUG
45
46#if !defined(__alpha__) && !defined(__i386__) && !defined(__x86_64__)
47# error Ftape is not implemented for this architecture!
48#endif
49
50#if defined(__alpha__) || defined(__x86_64__)
51static unsigned long ps_per_cycle = 0;
52#endif
53
54static spinlock_t calibr_lock;
55
56/*
57 * Note: On Intel PCs, the clock ticks at 100 Hz (HZ==100) which is
58 * too slow for certain timeouts (and that clock doesn't even tick
59 * when interrupts are disabled). For that reason, the 8254 timer is
60 * used directly to implement fine-grained timeouts. However, on
61 * Alpha PCs, the 8254 is *not* used to implement the clock tick
62 * (which is 1024 Hz, normally) and the 8254 timer runs at some
63 * "random" frequency (it seems to run at 18Hz, but it's not safe to
64 * rely on this value). Instead, we use the Alpha's "rpcc"
65 * instruction to read cycle counts. As this is a 32 bit counter,
66 * it will overflow only once per 30 seconds (on a 200MHz machine),
67 * which is plenty.
68 */
69
70unsigned int ftape_timestamp(void)
71{
72#if defined(__alpha__)
73 unsigned long r;
74
75 asm volatile ("rpcc %0" : "=r" (r));
76 return r;
77#elif defined(__x86_64__)
78 unsigned long r;
79 rdtscl(r);
80 return r;
81#elif defined(__i386__)
82
83/*
84 * Note that there is some time between counter underflowing and jiffies
85 * increasing, so the code below won't always give correct output.
86 * -Vojtech
87 */
88
89 unsigned long flags;
90 __u16 lo;
91 __u16 hi;
92
93 spin_lock_irqsave(&calibr_lock, flags);
94 outb_p(0x00, 0x43); /* latch the count ASAP */
95 lo = inb_p(0x40); /* read the latched count */
96 lo |= inb(0x40) << 8;
97 hi = jiffies;
98 spin_unlock_irqrestore(&calibr_lock, flags);
99 return ((hi + 1) * (unsigned int) LATCH) - lo; /* downcounter ! */
100#endif
101}
102
103static unsigned int short_ftape_timestamp(void)
104{
105#if defined(__alpha__) || defined(__x86_64__)
106 return ftape_timestamp();
107#elif defined(__i386__)
108 unsigned int count;
109 unsigned long flags;
110
111 spin_lock_irqsave(&calibr_lock, flags);
112 outb_p(0x00, 0x43); /* latch the count ASAP */
113 count = inb_p(0x40); /* read the latched count */
114 count |= inb(0x40) << 8;
115 spin_unlock_irqrestore(&calibr_lock, flags);
116 return (LATCH - count); /* normal: downcounter */
117#endif
118}
119
120static unsigned int diff(unsigned int t0, unsigned int t1)
121{
122#if defined(__alpha__) || defined(__x86_64__)
123 return (t1 - t0);
124#elif defined(__i386__)
125 /*
126 * This is tricky: to work for both short and full ftape_timestamps
127 * we'll have to discriminate between these.
128 * If it _looks_ like short stamps with wrapping around we'll
129 * asume it are. This will generate a small error if it really
130 * was a (very large) delta from full ftape_timestamps.
131 */
132 return (t1 <= t0 && t0 <= LATCH) ? t1 + LATCH - t0 : t1 - t0;
133#endif
134}
135
136static unsigned int usecs(unsigned int count)
137{
138#if defined(__alpha__) || defined(__x86_64__)
139 return (ps_per_cycle * count) / 1000000UL;
140#elif defined(__i386__)
141 return (10000 * count) / ((CLOCK_TICK_RATE + 50) / 100);
142#endif
143}
144
145unsigned int ftape_timediff(unsigned int t0, unsigned int t1)
146{
147 /*
148 * Calculate difference in usec for ftape_timestamp results t0 & t1.
149 * Note that on the i386 platform with short time-stamps, the
150 * maximum allowed timespan is 1/HZ or we'll lose ticks!
151 */
152 return usecs(diff(t0, t1));
153}
154
155/* To get an indication of the I/O performance,
156 * measure the duration of the inb() function.
157 */
158static void time_inb(void)
159{
160 int i;
161 int t0, t1;
162 unsigned long flags;
163 int status;
164 TRACE_FUN(ft_t_any);
165
166 spin_lock_irqsave(&calibr_lock, flags);
167 t0 = short_ftape_timestamp();
168 for (i = 0; i < 1000; ++i) {
169 status = inb(fdc.msr);
170 }
171 t1 = short_ftape_timestamp();
172 spin_unlock_irqrestore(&calibr_lock, flags);
173 TRACE(ft_t_info, "inb() duration: %d nsec", ftape_timediff(t0, t1));
174 TRACE_EXIT;
175}
176
177static void init_clock(void)
178{
179 TRACE_FUN(ft_t_any);
180
181#if defined(__x86_64__)
182 ps_per_cycle = 1000000000UL / cpu_khz;
183#elif defined(__alpha__)
184 extern struct hwrpb_struct *hwrpb;
185 ps_per_cycle = (1000*1000*1000*1000UL) / hwrpb->cycle_freq;
186#endif
187 TRACE_EXIT;
188}
189
190/*
191 * Input: function taking int count as parameter.
192 * pointers to calculated calibration variables.
193 */
194void ftape_calibrate(char *name,
195 void (*fun) (unsigned int),
196 unsigned int *calibr_count,
197 unsigned int *calibr_time)
198{
199 static int first_time = 1;
200 int i;
201 unsigned int tc = 0;
202 unsigned int count;
203 unsigned int time;
204#if defined(__i386__)
205 unsigned int old_tc = 0;
206 unsigned int old_count = 1;
207 unsigned int old_time = 1;
208#endif
209 TRACE_FUN(ft_t_flow);
210
211 if (first_time) { /* get idea of I/O performance */
212 init_clock();
213 time_inb();
214 first_time = 0;
215 }
216 /* value of timeout must be set so that on very slow systems
217 * it will give a time less than one jiffy, and on
218 * very fast systems it'll give reasonable precision.
219 */
220
221 count = 40;
222 for (i = 0; i < 15; ++i) {
223 unsigned int t0;
224 unsigned int t1;
225 unsigned int once;
226 unsigned int multiple;
227 unsigned long flags;
228
229 *calibr_count =
230 *calibr_time = count; /* set TC to 1 */
231 spin_lock_irqsave(&calibr_lock, flags);
232 fun(0); /* dummy, get code into cache */
233 t0 = short_ftape_timestamp();
234 fun(0); /* overhead + one test */
235 t1 = short_ftape_timestamp();
236 once = diff(t0, t1);
237 t0 = short_ftape_timestamp();
238 fun(count); /* overhead + count tests */
239 t1 = short_ftape_timestamp();
240 multiple = diff(t0, t1);
241 spin_unlock_irqrestore(&calibr_lock, flags);
242 time = ftape_timediff(0, multiple - once);
243 tc = (1000 * time) / (count - 1);
244 TRACE(ft_t_any, "once:%3d us,%6d times:%6d us, TC:%5d ns",
245 usecs(once), count - 1, usecs(multiple), tc);
246#if defined(__alpha__) || defined(__x86_64__)
247 /*
248 * Increase the calibration count exponentially until the
249 * calibration time exceeds 100 ms.
250 */
251 if (time >= 100*1000) {
252 break;
253 }
254#elif defined(__i386__)
255 /*
256 * increase the count until the resulting time nears 2/HZ,
257 * then the tc will drop sharply because we lose LATCH counts.
258 */
259 if (tc <= old_tc / 2) {
260 time = old_time;
261 count = old_count;
262 break;
263 }
264 old_tc = tc;
265 old_count = count;
266 old_time = time;
267#endif
268 count *= 2;
269 }
270 *calibr_count = count - 1;
271 *calibr_time = time;
272 TRACE(ft_t_info, "TC for `%s()' = %d nsec (at %d counts)",
273 name, (1000 * *calibr_time) / *calibr_count, *calibr_count);
274 TRACE_EXIT;
275}
diff --git a/drivers/char/ftape/lowlevel/ftape-calibr.h b/drivers/char/ftape/lowlevel/ftape-calibr.h
deleted file mode 100644
index 0c7e75246c7d..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-calibr.h
+++ /dev/null
@@ -1,37 +0,0 @@
1#ifndef _FTAPE_CALIBR_H
2#define _FTAPE_CALIBR_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-calibr.h,v $
23 * $Revision: 1.1 $
24 * $Date: 1997/09/19 09:05:26 $
25 *
26 * This file contains a gp calibration routine for
27 * hardware dependent timeout functions.
28 */
29
30extern void ftape_calibrate(char *name,
31 void (*fun) (unsigned int),
32 unsigned int *calibr_count,
33 unsigned int *calibr_time);
34extern unsigned int ftape_timestamp(void);
35extern unsigned int ftape_timediff(unsigned int t0, unsigned int t1);
36
37#endif /* _FTAPE_CALIBR_H */
diff --git a/drivers/char/ftape/lowlevel/ftape-ctl.c b/drivers/char/ftape/lowlevel/ftape-ctl.c
deleted file mode 100644
index 5d7c1ce92d59..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-ctl.c
+++ /dev/null
@@ -1,896 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * 1996-1997 Claus-Justus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ctl.c,v $
21 * $Revision: 1.4 $
22 * $Date: 1997/11/11 14:37:44 $
23 *
24 * This file contains the non-read/write ftape functions for the
25 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
26 */
27
28#include <linux/errno.h>
29#include <linux/mm.h>
30#include <linux/mman.h>
31
32#include <linux/ftape.h>
33#include <linux/qic117.h>
34#include <asm/uaccess.h>
35#include <asm/io.h>
36
37/* ease porting between pre-2.4.x and later kernels */
38#define vma_get_pgoff(v) ((v)->vm_pgoff)
39
40#include "../lowlevel/ftape-tracing.h"
41#include "../lowlevel/ftape-io.h"
42#include "../lowlevel/ftape-ctl.h"
43#include "../lowlevel/ftape-write.h"
44#include "../lowlevel/ftape-read.h"
45#include "../lowlevel/ftape-rw.h"
46#include "../lowlevel/ftape-bsm.h"
47
48/* Global vars.
49 */
50ftape_info ftape_status = {
51/* vendor information */
52 { 0, }, /* drive type */
53/* data rates */
54 500, /* used data rate */
55 500, /* drive max rate */
56 500, /* fdc max rate */
57/* drive selection, either FTAPE_SEL_A/B/C/D */
58 -1, /* drive selection */
59/* flags set after decode the drive and tape status */
60 0, /* formatted */
61 1, /* no tape */
62 1, /* write protected */
63 1, /* new tape */
64/* values of last queried drive/tape status and error */
65 {{0,}}, /* last error code */
66 {{0,}}, /* drive status, configuration, tape status */
67/* cartridge geometry */
68 20, /* tracks_per_tape */
69 102, /* segments_per_track */
70/* location of header segments, etc. */
71 -1, /* used_header_segment */
72 -1, /* header_segment_1 */
73 -1, /* header_segment_2 */
74 -1, /* first_data_segment */
75 -1, /* last_data_segment */
76/* the format code as stored in the header segment */
77 fmt_normal, /* format code */
78/* the default for the qic std: unknown */
79 -1,
80/* is tape running? */
81 idle, /* runner_state */
82/* is tape reading/writing/verifying/formatting/deleting */
83 idle, /* driver state */
84/* flags fatal hardware error */
85 1, /* failure */
86/* history record */
87 { 0, } /* history record */
88};
89
90int ftape_segments_per_head = 1020;
91int ftape_segments_per_cylinder = 4;
92int ftape_init_drive_needed = 1; /* need to be global for ftape_reset_drive()
93 * in ftape-io.c
94 */
95
96/* Local vars.
97 */
98static const vendor_struct vendors[] = QIC117_VENDORS;
99static const wakeup_method methods[] = WAKEUP_METHODS;
100
101const ftape_info *ftape_get_status(void)
102{
103#if defined(STATUS_PARANOYA)
104 static ftape_info get_status;
105
106 get_status = ftape_status;
107 return &get_status;
108#else
109 return &ftape_status; /* maybe return only a copy of it to assure
110 * read only access
111 */
112#endif
113}
114
115static int ftape_not_operational(int status)
116{
117 /* return true if status indicates tape can not be used.
118 */
119 return ((status ^ QIC_STATUS_CARTRIDGE_PRESENT) &
120 (QIC_STATUS_ERROR |
121 QIC_STATUS_CARTRIDGE_PRESENT |
122 QIC_STATUS_NEW_CARTRIDGE));
123}
124
125int ftape_seek_to_eot(void)
126{
127 int status;
128 TRACE_FUN(ft_t_any);
129
130 TRACE_CATCH(ftape_ready_wait(ftape_timeout.pause, &status),);
131 while ((status & QIC_STATUS_AT_EOT) == 0) {
132 if (ftape_not_operational(status)) {
133 TRACE_EXIT -EIO;
134 }
135 TRACE_CATCH(ftape_command_wait(QIC_PHYSICAL_FORWARD,
136 ftape_timeout.rewind,&status),);
137 }
138 TRACE_EXIT 0;
139}
140
141int ftape_seek_to_bot(void)
142{
143 int status;
144 TRACE_FUN(ft_t_any);
145
146 TRACE_CATCH(ftape_ready_wait(ftape_timeout.pause, &status),);
147 while ((status & QIC_STATUS_AT_BOT) == 0) {
148 if (ftape_not_operational(status)) {
149 TRACE_EXIT -EIO;
150 }
151 TRACE_CATCH(ftape_command_wait(QIC_PHYSICAL_REVERSE,
152 ftape_timeout.rewind,&status),);
153 }
154 TRACE_EXIT 0;
155}
156
157static int ftape_new_cartridge(void)
158{
159 ft_location.track = -1; /* force seek on first access */
160 ftape_zap_read_buffers();
161 ftape_zap_write_buffers();
162 return 0;
163}
164
165int ftape_abort_operation(void)
166{
167 int result = 0;
168 int status;
169 TRACE_FUN(ft_t_flow);
170
171 if (ft_runner_status == running) {
172 TRACE(ft_t_noise, "aborting runner, waiting");
173
174 ft_runner_status = do_abort;
175 /* set timeout so that the tape will run to logical EOT
176 * if we missed the last sector and there are no queue pulses.
177 */
178 result = ftape_dumb_stop();
179 }
180 if (ft_runner_status != idle) {
181 if (ft_runner_status == do_abort) {
182 TRACE(ft_t_noise, "forcing runner abort");
183 }
184 TRACE(ft_t_noise, "stopping tape");
185 result = ftape_stop_tape(&status);
186 ft_location.known = 0;
187 ft_runner_status = idle;
188 }
189 ftape_reset_buffer();
190 ftape_zap_read_buffers();
191 ftape_set_state(idle);
192 TRACE_EXIT result;
193}
194
195static int lookup_vendor_id(unsigned int vendor_id)
196{
197 int i = 0;
198
199 while (vendors[i].vendor_id != vendor_id) {
200 if (++i >= NR_ITEMS(vendors)) {
201 return -1;
202 }
203 }
204 return i;
205}
206
207static void ftape_detach_drive(void)
208{
209 TRACE_FUN(ft_t_any);
210
211 TRACE(ft_t_flow, "disabling tape drive and fdc");
212 ftape_put_drive_to_sleep(ft_drive_type.wake_up);
213 fdc_catch_stray_interrupts(1); /* one always comes */
214 fdc_disable();
215 fdc_release_irq_and_dma();
216 fdc_release_regions();
217 TRACE_EXIT;
218}
219
220static void clear_history(void)
221{
222 ft_history.used = 0;
223 ft_history.id_am_errors =
224 ft_history.id_crc_errors =
225 ft_history.data_am_errors =
226 ft_history.data_crc_errors =
227 ft_history.overrun_errors =
228 ft_history.no_data_errors =
229 ft_history.retries =
230 ft_history.crc_errors =
231 ft_history.crc_failures =
232 ft_history.ecc_failures =
233 ft_history.corrected =
234 ft_history.defects =
235 ft_history.rewinds = 0;
236}
237
238static int ftape_activate_drive(vendor_struct * drive_type)
239{
240 int result = 0;
241 TRACE_FUN(ft_t_flow);
242
243 /* If we already know the drive type, wake it up.
244 * Else try to find out what kind of drive is attached.
245 */
246 if (drive_type->wake_up != unknown_wake_up) {
247 TRACE(ft_t_flow, "enabling tape drive and fdc");
248 result = ftape_wakeup_drive(drive_type->wake_up);
249 if (result < 0) {
250 TRACE(ft_t_err, "known wakeup method failed");
251 }
252 } else {
253 wake_up_types method;
254 const ft_trace_t old_tracing = TRACE_LEVEL;
255 if (TRACE_LEVEL < ft_t_flow) {
256 SET_TRACE_LEVEL(ft_t_bug);
257 }
258
259 /* Try to awaken the drive using all known methods.
260 * Lower tracing for a while.
261 */
262 for (method=no_wake_up; method < NR_ITEMS(methods); ++method) {
263 drive_type->wake_up = method;
264#ifdef CONFIG_FT_TWO_DRIVES
265 /* Test setup for dual drive configuration.
266 * /dev/rft2 uses mountain wakeup
267 * /dev/rft3 uses colorado wakeup
268 * Other systems will use the normal scheme.
269 */
270 if ((ft_drive_sel < 2) ||
271 (ft_drive_sel == 2 && method == FT_WAKE_UP_1) ||
272 (ft_drive_sel == 3 && method == FT_WAKE_UP_2)) {
273 result=ftape_wakeup_drive(drive_type->wake_up);
274 } else {
275 result = -EIO;
276 }
277#else
278 result = ftape_wakeup_drive(drive_type->wake_up);
279#endif
280 if (result >= 0) {
281 TRACE(ft_t_warn, "drive wakeup method: %s",
282 methods[drive_type->wake_up].name);
283 break;
284 }
285 }
286 SET_TRACE_LEVEL(old_tracing);
287
288 if (method >= NR_ITEMS(methods)) {
289 /* no response at all, cannot open this drive */
290 drive_type->wake_up = unknown_wake_up;
291 TRACE(ft_t_err, "no tape drive found !");
292 result = -ENODEV;
293 }
294 }
295 TRACE_EXIT result;
296}
297
298static int ftape_get_drive_status(void)
299{
300 int result;
301 int status;
302 TRACE_FUN(ft_t_flow);
303
304 ft_no_tape = ft_write_protected = 0;
305 /* Tape drive is activated now.
306 * First clear error status if present.
307 */
308 do {
309 result = ftape_ready_wait(ftape_timeout.reset, &status);
310 if (result < 0) {
311 if (result == -ETIME) {
312 TRACE(ft_t_err, "ftape_ready_wait timeout");
313 } else if (result == -EINTR) {
314 TRACE(ft_t_err, "ftape_ready_wait aborted");
315 } else {
316 TRACE(ft_t_err, "ftape_ready_wait failed");
317 }
318 TRACE_EXIT -EIO;
319 }
320 /* Clear error condition (drive is ready !)
321 */
322 if (status & QIC_STATUS_ERROR) {
323 unsigned int error;
324 qic117_cmd_t command;
325
326 TRACE(ft_t_err, "error status set");
327 result = ftape_report_error(&error, &command, 1);
328 if (result < 0) {
329 TRACE(ft_t_err,
330 "report_error_code failed: %d", result);
331 /* hope it's working next time */
332 ftape_reset_drive();
333 TRACE_EXIT -EIO;
334 } else if (error != 0) {
335 TRACE(ft_t_noise, "error code : %d", error);
336 TRACE(ft_t_noise, "error command: %d", command);
337 }
338 }
339 if (status & QIC_STATUS_NEW_CARTRIDGE) {
340 unsigned int error;
341 qic117_cmd_t command;
342 const ft_trace_t old_tracing = TRACE_LEVEL;
343 SET_TRACE_LEVEL(ft_t_bug);
344
345 /* Undocumented feature: Must clear (not present!)
346 * error here or we'll fail later.
347 */
348 ftape_report_error(&error, &command, 1);
349
350 SET_TRACE_LEVEL(old_tracing);
351 TRACE(ft_t_info, "status: new cartridge");
352 ft_new_tape = 1;
353 } else {
354 ft_new_tape = 0;
355 }
356 FT_SIGNAL_EXIT(_DONT_BLOCK);
357 } while (status & QIC_STATUS_ERROR);
358
359 ft_no_tape = !(status & QIC_STATUS_CARTRIDGE_PRESENT);
360 ft_write_protected = (status & QIC_STATUS_WRITE_PROTECT) != 0;
361 if (ft_no_tape) {
362 TRACE(ft_t_warn, "no cartridge present");
363 } else {
364 if (ft_write_protected) {
365 TRACE(ft_t_noise, "Write protected cartridge");
366 }
367 }
368 TRACE_EXIT 0;
369}
370
371static void ftape_log_vendor_id(void)
372{
373 int vendor_index;
374 TRACE_FUN(ft_t_flow);
375
376 ftape_report_vendor_id(&ft_drive_type.vendor_id);
377 vendor_index = lookup_vendor_id(ft_drive_type.vendor_id);
378 if (ft_drive_type.vendor_id == UNKNOWN_VENDOR &&
379 ft_drive_type.wake_up == wake_up_colorado) {
380 vendor_index = 0;
381 /* hack to get rid of all this mail */
382 ft_drive_type.vendor_id = 0;
383 }
384 if (vendor_index < 0) {
385 /* Unknown vendor id, first time opening device. The
386 * drive_type remains set to type found at wakeup
387 * time, this will probably keep the driver operating
388 * for this new vendor.
389 */
390 TRACE(ft_t_warn, "\n"
391 KERN_INFO "============ unknown vendor id ===========\n"
392 KERN_INFO "A new, yet unsupported tape drive is found\n"
393 KERN_INFO "Please report the following values:\n"
394 KERN_INFO " Vendor id : 0x%04x\n"
395 KERN_INFO " Wakeup method : %s\n"
396 KERN_INFO "And a description of your tape drive\n"
397 KERN_INFO "to "THE_FTAPE_MAINTAINER"\n"
398 KERN_INFO "==========================================",
399 ft_drive_type.vendor_id,
400 methods[ft_drive_type.wake_up].name);
401 ft_drive_type.speed = 0; /* unknown */
402 } else {
403 ft_drive_type.name = vendors[vendor_index].name;
404 ft_drive_type.speed = vendors[vendor_index].speed;
405 TRACE(ft_t_info, "tape drive type: %s", ft_drive_type.name);
406 /* scan all methods for this vendor_id in table */
407 while(ft_drive_type.wake_up != vendors[vendor_index].wake_up) {
408 if (vendor_index < NR_ITEMS(vendors) - 1 &&
409 vendors[vendor_index + 1].vendor_id
410 ==
411 ft_drive_type.vendor_id) {
412 ++vendor_index;
413 } else {
414 break;
415 }
416 }
417 if (ft_drive_type.wake_up != vendors[vendor_index].wake_up) {
418 TRACE(ft_t_warn, "\n"
419 KERN_INFO "==========================================\n"
420 KERN_INFO "wakeup type mismatch:\n"
421 KERN_INFO "found: %s, expected: %s\n"
422 KERN_INFO "please report this to "THE_FTAPE_MAINTAINER"\n"
423 KERN_INFO "==========================================",
424 methods[ft_drive_type.wake_up].name,
425 methods[vendors[vendor_index].wake_up].name);
426 }
427 }
428 TRACE_EXIT;
429}
430
431void ftape_calc_timeouts(unsigned int qic_std,
432 unsigned int data_rate,
433 unsigned int tape_len)
434{
435 int speed; /* deci-ips ! */
436 int ff_speed;
437 int length;
438 TRACE_FUN(ft_t_any);
439
440 /* tape transport speed
441 * data rate: QIC-40 QIC-80 QIC-3010 QIC-3020
442 *
443 * 250 Kbps 25 ips n/a n/a n/a
444 * 500 Kbps 50 ips 34 ips 22.6 ips n/a
445 * 1 Mbps n/a 68 ips 45.2 ips 22.6 ips
446 * 2 Mbps n/a n/a n/a 45.2 ips
447 *
448 * fast tape transport speed is at least 68 ips.
449 */
450 switch (qic_std) {
451 case QIC_TAPE_QIC40:
452 speed = (data_rate == 250) ? 250 : 500;
453 break;
454 case QIC_TAPE_QIC80:
455 speed = (data_rate == 500) ? 340 : 680;
456 break;
457 case QIC_TAPE_QIC3010:
458 speed = (data_rate == 500) ? 226 : 452;
459 break;
460 case QIC_TAPE_QIC3020:
461 speed = (data_rate == 1000) ? 226 : 452;
462 break;
463 default:
464 TRACE(ft_t_bug, "Unknown qic_std (bug) ?");
465 speed = 500;
466 break;
467 }
468 if (ft_drive_type.speed == 0) {
469 unsigned long t0;
470 static int dt = 0; /* keep gcc from complaining */
471 static int first_time = 1;
472
473 /* Measure the time it takes to wind to EOT and back to BOT.
474 * If the tape length is known, calculate the rewind speed.
475 * Else keep the time value for calculation of the rewind
476 * speed later on, when the length _is_ known.
477 * Ask for a report only when length and speed are both known.
478 */
479 if (first_time) {
480 ftape_seek_to_bot();
481 t0 = jiffies;
482 ftape_seek_to_eot();
483 ftape_seek_to_bot();
484 dt = (int) (((jiffies - t0) * FT_USPT) / 1000);
485 if (dt < 1) {
486 dt = 1; /* prevent div by zero on failures */
487 }
488 first_time = 0;
489 TRACE(ft_t_info,
490 "trying to determine seek timeout, got %d msec",
491 dt);
492 }
493 if (tape_len != 0) {
494 ft_drive_type.speed =
495 (2 * 12 * tape_len * 1000) / dt;
496 TRACE(ft_t_warn, "\n"
497 KERN_INFO "==========================================\n"
498 KERN_INFO "drive type: %s\n"
499 KERN_INFO "delta time = %d ms, length = %d ft\n"
500 KERN_INFO "has a maximum tape speed of %d ips\n"
501 KERN_INFO "please report this to "THE_FTAPE_MAINTAINER"\n"
502 KERN_INFO "==========================================",
503 ft_drive_type.name, dt, tape_len,
504 ft_drive_type.speed);
505 }
506 }
507 /* Handle unknown length tapes as very long ones. We'll
508 * determine the actual length from a header segment later.
509 * This is normal for all modern (Wide,TR1/2/3) formats.
510 */
511 if (tape_len <= 0) {
512 TRACE(ft_t_noise,
513 "Unknown tape length, using maximal timeouts");
514 length = QIC_TOP_TAPE_LEN; /* use worst case values */
515 } else {
516 length = tape_len; /* use actual values */
517 }
518 if (ft_drive_type.speed == 0) {
519 ff_speed = speed;
520 } else {
521 ff_speed = ft_drive_type.speed;
522 }
523 /* time to go from bot to eot at normal speed (data rate):
524 * time = (1+delta) * length (ft) * 12 (inch/ft) / speed (ips)
525 * delta = 10 % for seek speed, 20 % for rewind speed.
526 */
527 ftape_timeout.seek = (length * 132 * FT_SECOND) / speed;
528 ftape_timeout.rewind = (length * 144 * FT_SECOND) / (10 * ff_speed);
529 ftape_timeout.reset = 20 * FT_SECOND + ftape_timeout.rewind;
530 TRACE(ft_t_noise, "timeouts for speed = %d, length = %d\n"
531 KERN_INFO "seek timeout : %d sec\n"
532 KERN_INFO "rewind timeout: %d sec\n"
533 KERN_INFO "reset timeout : %d sec",
534 speed, length,
535 (ftape_timeout.seek + 500) / 1000,
536 (ftape_timeout.rewind + 500) / 1000,
537 (ftape_timeout.reset + 500) / 1000);
538 TRACE_EXIT;
539}
540
541/* This function calibrates the datarate (i.e. determines the maximal
542 * usable data rate) and sets the global variable ft_qic_std to qic_std
543 *
544 */
545int ftape_calibrate_data_rate(unsigned int qic_std)
546{
547 int rate = ft_fdc_rate_limit;
548 int result;
549 TRACE_FUN(ft_t_flow);
550
551 ft_qic_std = qic_std;
552
553 if (ft_qic_std == -1) {
554 TRACE_ABORT(-EIO, ft_t_err,
555 "Unable to determine data rate if QIC standard is unknown");
556 }
557
558 /* Select highest rate supported by both fdc and drive.
559 * Start with highest rate supported by the fdc.
560 */
561 while (fdc_set_data_rate(rate) < 0 && rate > 250) {
562 rate /= 2;
563 }
564 TRACE(ft_t_info,
565 "Highest FDC supported data rate: %d Kbps", rate);
566 ft_fdc_max_rate = rate;
567 do {
568 result = ftape_set_data_rate(rate, ft_qic_std);
569 } while (result == -EINVAL && (rate /= 2) > 250);
570 if (result < 0) {
571 TRACE_ABORT(-EIO, ft_t_err, "set datarate failed");
572 }
573 ft_data_rate = rate;
574 TRACE_EXIT 0;
575}
576
577static int ftape_init_drive(void)
578{
579 int status;
580 qic_model model;
581 unsigned int qic_std;
582 unsigned int data_rate;
583 TRACE_FUN(ft_t_flow);
584
585 ftape_init_drive_needed = 0; /* don't retry if this fails ? */
586 TRACE_CATCH(ftape_report_raw_drive_status(&status),);
587 if (status & QIC_STATUS_CARTRIDGE_PRESENT) {
588 if (!(status & QIC_STATUS_AT_BOT)) {
589 /* Antique drives will get here after a soft reset,
590 * modern ones only if the driver is loaded when the
591 * tape wasn't rewound properly.
592 */
593 /* Tape should be at bot if new cartridge ! */
594 ftape_seek_to_bot();
595 }
596 if (!(status & QIC_STATUS_REFERENCED)) {
597 TRACE(ft_t_flow, "starting seek_load_point");
598 TRACE_CATCH(ftape_command_wait(QIC_SEEK_LOAD_POINT,
599 ftape_timeout.reset,
600 &status),);
601 }
602 }
603 ft_formatted = (status & QIC_STATUS_REFERENCED) != 0;
604 if (!ft_formatted) {
605 TRACE(ft_t_warn, "Warning: tape is not formatted !");
606 }
607
608 /* report configuration aborts when ftape_tape_len == -1
609 * unknown qic_std is okay if not formatted.
610 */
611 TRACE_CATCH(ftape_report_configuration(&model,
612 &data_rate,
613 &qic_std,
614 &ftape_tape_len),);
615
616 /* Maybe add the following to the /proc entry
617 */
618 TRACE(ft_t_info, "%s drive @ %d Kbps",
619 (model == prehistoric) ? "prehistoric" :
620 ((model == pre_qic117c) ? "pre QIC-117C" :
621 ((model == post_qic117b) ? "post QIC-117B" :
622 "post QIC-117D")), data_rate);
623
624 if (ft_formatted) {
625 /* initialize ft_used_data_rate to maximum value
626 * and set ft_qic_std
627 */
628 TRACE_CATCH(ftape_calibrate_data_rate(qic_std),);
629 if (ftape_tape_len == 0) {
630 TRACE(ft_t_info, "unknown length QIC-%s tape",
631 (ft_qic_std == QIC_TAPE_QIC40) ? "40" :
632 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
633 ((ft_qic_std == QIC_TAPE_QIC3010)
634 ? "3010" : "3020")));
635 } else {
636 TRACE(ft_t_info, "%d ft. QIC-%s tape", ftape_tape_len,
637 (ft_qic_std == QIC_TAPE_QIC40) ? "40" :
638 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
639 ((ft_qic_std == QIC_TAPE_QIC3010)
640 ? "3010" : "3020")));
641 }
642 ftape_calc_timeouts(ft_qic_std, ft_data_rate, ftape_tape_len);
643 /* soft write-protect QIC-40/QIC-80 cartridges used with a
644 * Colorado T3000 drive. Buggy hardware!
645 */
646 if ((ft_drive_type.vendor_id == 0x011c6) &&
647 ((ft_qic_std == QIC_TAPE_QIC40 ||
648 ft_qic_std == QIC_TAPE_QIC80) &&
649 !ft_write_protected)) {
650 TRACE(ft_t_warn, "\n"
651 KERN_INFO "The famous Colorado T3000 bug:\n"
652 KERN_INFO "%s drives can't write QIC40 and QIC80\n"
653 KERN_INFO "cartridges but don't set the write-protect flag!",
654 ft_drive_type.name);
655 ft_write_protected = 1;
656 }
657 } else {
658 /* Doesn't make too much sense to set the data rate
659 * because we don't know what to use for the write
660 * precompensation.
661 * Need to do this again when formatting the cartridge.
662 */
663 ft_data_rate = data_rate;
664 ftape_calc_timeouts(QIC_TAPE_QIC40,
665 data_rate,
666 ftape_tape_len);
667 }
668 ftape_new_cartridge();
669 TRACE_EXIT 0;
670}
671
672static void ftape_munmap(void)
673{
674 int i;
675 TRACE_FUN(ft_t_flow);
676
677 for (i = 0; i < ft_nr_buffers; i++) {
678 ft_buffer[i]->mmapped = 0;
679 }
680 TRACE_EXIT;
681}
682
683/* Map the dma buffers into the virtual address range given by vma.
684 * We only check the caller doesn't map non-existent buffers. We
685 * don't check for multiple mappings.
686 */
687int ftape_mmap(struct vm_area_struct *vma)
688{
689 int num_buffers;
690 int i;
691 TRACE_FUN(ft_t_flow);
692
693 if (ft_failure) {
694 TRACE_EXIT -ENODEV;
695 }
696 if (!(vma->vm_flags & (VM_READ|VM_WRITE))) {
697 TRACE_ABORT(-EINVAL, ft_t_err, "Undefined mmap() access");
698 }
699 if (vma_get_pgoff(vma) != 0) {
700 TRACE_ABORT(-EINVAL, ft_t_err, "page offset must be 0");
701 }
702 if ((vma->vm_end - vma->vm_start) % FT_BUFF_SIZE != 0) {
703 TRACE_ABORT(-EINVAL, ft_t_err,
704 "size = %ld, should be a multiple of %d",
705 vma->vm_end - vma->vm_start,
706 FT_BUFF_SIZE);
707 }
708 num_buffers = (vma->vm_end - vma->vm_start) / FT_BUFF_SIZE;
709 if (num_buffers > ft_nr_buffers) {
710 TRACE_ABORT(-EINVAL,
711 ft_t_err, "size = %ld, should be less than %d",
712 vma->vm_end - vma->vm_start,
713 ft_nr_buffers * FT_BUFF_SIZE);
714 }
715 if (ft_driver_state != idle) {
716 /* this also clears the buffer states
717 */
718 ftape_abort_operation();
719 } else {
720 ftape_reset_buffer();
721 }
722 for (i = 0; i < num_buffers; i++) {
723 unsigned long pfn;
724
725 pfn = virt_to_phys(ft_buffer[i]->address) >> PAGE_SHIFT;
726 TRACE_CATCH(remap_pfn_range(vma, vma->vm_start +
727 i * FT_BUFF_SIZE,
728 pfn,
729 FT_BUFF_SIZE,
730 vma->vm_page_prot),
731 _res = -EAGAIN);
732 TRACE(ft_t_noise, "remapped dma buffer @ %p to location @ %p",
733 ft_buffer[i]->address,
734 (void *)(vma->vm_start + i * FT_BUFF_SIZE));
735 }
736 for (i = 0; i < num_buffers; i++) {
737 memset(ft_buffer[i]->address, 0xAA, FT_BUFF_SIZE);
738 ft_buffer[i]->mmapped++;
739 }
740 TRACE_EXIT 0;
741}
742
743static void ftape_init_driver(void); /* forward declaration */
744
745/* OPEN routine called by kernel-interface code
746 */
747int ftape_enable(int drive_selection)
748{
749 TRACE_FUN(ft_t_any);
750
751 if (ft_drive_sel == -1 || ft_drive_sel != drive_selection) {
752 /* Other selection than last time
753 */
754 ftape_init_driver();
755 }
756 ft_drive_sel = FTAPE_SEL(drive_selection);
757 ft_failure = 0;
758 TRACE_CATCH(fdc_init(),); /* init & detect fdc */
759 TRACE_CATCH(ftape_activate_drive(&ft_drive_type),
760 fdc_disable();
761 fdc_release_irq_and_dma();
762 fdc_release_regions());
763 TRACE_CATCH(ftape_get_drive_status(), ftape_detach_drive());
764 if (ft_drive_type.vendor_id == UNKNOWN_VENDOR) {
765 ftape_log_vendor_id();
766 }
767 if (ft_new_tape) {
768 ftape_init_drive_needed = 1;
769 }
770 if (!ft_no_tape && ftape_init_drive_needed) {
771 TRACE_CATCH(ftape_init_drive(), ftape_detach_drive());
772 }
773 ftape_munmap(); /* clear the mmap flag */
774 clear_history();
775 TRACE_EXIT 0;
776}
777
778/* release routine called by the high level interface modules
779 * zftape or sftape.
780 */
781void ftape_disable(void)
782{
783 int i;
784 TRACE_FUN(ft_t_any);
785
786 for (i = 0; i < ft_nr_buffers; i++) {
787 if (ft_buffer[i]->mmapped) {
788 TRACE(ft_t_noise, "first byte of buffer %d: 0x%02x",
789 i, *ft_buffer[i]->address);
790 }
791 }
792 if (sigtestsetmask(&current->pending.signal, _DONT_BLOCK) &&
793 !(sigtestsetmask(&current->pending.signal, _NEVER_BLOCK)) &&
794 ftape_tape_running) {
795 TRACE(ft_t_warn,
796 "Interrupted by fatal signal and tape still running");
797 ftape_dumb_stop();
798 ftape_abort_operation(); /* it's annoying */
799 } else {
800 ftape_set_state(idle);
801 }
802 ftape_detach_drive();
803 if (ft_history.used) {
804 TRACE(ft_t_info, "== Non-fatal errors this run: ==");
805 TRACE(ft_t_info, "fdc isr statistics:\n"
806 KERN_INFO " id_am_errors : %3d\n"
807 KERN_INFO " id_crc_errors : %3d\n"
808 KERN_INFO " data_am_errors : %3d\n"
809 KERN_INFO " data_crc_errors : %3d\n"
810 KERN_INFO " overrun_errors : %3d\n"
811 KERN_INFO " no_data_errors : %3d\n"
812 KERN_INFO " retries : %3d",
813 ft_history.id_am_errors, ft_history.id_crc_errors,
814 ft_history.data_am_errors, ft_history.data_crc_errors,
815 ft_history.overrun_errors, ft_history.no_data_errors,
816 ft_history.retries);
817 if (ft_history.used & 1) {
818 TRACE(ft_t_info, "ecc statistics:\n"
819 KERN_INFO " crc_errors : %3d\n"
820 KERN_INFO " crc_failures : %3d\n"
821 KERN_INFO " ecc_failures : %3d\n"
822 KERN_INFO " sectors corrected: %3d",
823 ft_history.crc_errors, ft_history.crc_failures,
824 ft_history.ecc_failures, ft_history.corrected);
825 }
826 if (ft_history.defects > 0) {
827 TRACE(ft_t_warn, "Warning: %d media defects!",
828 ft_history.defects);
829 }
830 if (ft_history.rewinds > 0) {
831 TRACE(ft_t_info, "tape motion statistics:\n"
832 KERN_INFO "repositions : %3d",
833 ft_history.rewinds);
834 }
835 }
836 ft_failure = 1;
837 TRACE_EXIT;
838}
839
840static void ftape_init_driver(void)
841{
842 TRACE_FUN(ft_t_flow);
843
844 ft_drive_type.vendor_id = UNKNOWN_VENDOR;
845 ft_drive_type.speed = 0;
846 ft_drive_type.wake_up = unknown_wake_up;
847 ft_drive_type.name = "Unknown";
848
849 ftape_timeout.seek = 650 * FT_SECOND;
850 ftape_timeout.reset = 670 * FT_SECOND;
851 ftape_timeout.rewind = 650 * FT_SECOND;
852 ftape_timeout.head_seek = 15 * FT_SECOND;
853 ftape_timeout.stop = 5 * FT_SECOND;
854 ftape_timeout.pause = 16 * FT_SECOND;
855
856 ft_qic_std = -1;
857 ftape_tape_len = 0; /* unknown */
858 ftape_current_command = 0;
859 ftape_current_cylinder = -1;
860
861 ft_segments_per_track = 102;
862 ftape_segments_per_head = 1020;
863 ftape_segments_per_cylinder = 4;
864 ft_tracks_per_tape = 20;
865
866 ft_failure = 1;
867
868 ft_formatted = 0;
869 ft_no_tape = 1;
870 ft_write_protected = 1;
871 ft_new_tape = 1;
872
873 ft_driver_state = idle;
874
875 ft_data_rate =
876 ft_fdc_max_rate = 500;
877 ft_drive_max_rate = 0; /* triggers set_rate_test() */
878
879 ftape_init_drive_needed = 1;
880
881 ft_header_segment_1 = -1;
882 ft_header_segment_2 = -1;
883 ft_used_header_segment = -1;
884 ft_first_data_segment = -1;
885 ft_last_data_segment = -1;
886
887 ft_location.track = -1;
888 ft_location.known = 0;
889
890 ftape_tape_running = 0;
891 ftape_might_be_off_track = 1;
892
893 ftape_new_cartridge(); /* init some tape related variables */
894 ftape_init_bsm();
895 TRACE_EXIT;
896}
diff --git a/drivers/char/ftape/lowlevel/ftape-ctl.h b/drivers/char/ftape/lowlevel/ftape-ctl.h
deleted file mode 100644
index 5f5e30bc3615..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-ctl.h
+++ /dev/null
@@ -1,162 +0,0 @@
1#ifndef _FTAPE_CTL_H
2#define _FTAPE_CTL_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ctl.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:09 $
26 *
27 * This file contains the non-standard IOCTL related definitions
28 * for the QIC-40/80/3010/3020 floppy-tape driver "ftape" for
29 * Linux.
30 */
31
32#include <linux/ioctl.h>
33#include <linux/mtio.h>
34#include <linux/ftape-vendors.h>
35
36#include "../lowlevel/ftape-rw.h"
37#include <linux/ftape-header-segment.h>
38
39typedef struct {
40 int used; /* any reading or writing done */
41 /* isr statistics */
42 unsigned int id_am_errors; /* id address mark not found */
43 unsigned int id_crc_errors; /* crc error in id address mark */
44 unsigned int data_am_errors; /* data address mark not found */
45 unsigned int data_crc_errors; /* crc error in data field */
46 unsigned int overrun_errors; /* fdc access timing problem */
47 unsigned int no_data_errors; /* sector not found */
48 unsigned int retries; /* number of tape retries */
49 /* ecc statistics */
50 unsigned int crc_errors; /* crc error in data */
51 unsigned int crc_failures; /* bad data without crc error */
52 unsigned int ecc_failures; /* failed to correct */
53 unsigned int corrected; /* total sectors corrected */
54 /* general statistics */
55 unsigned int rewinds; /* number of tape rewinds */
56 unsigned int defects; /* bad sectors due to media defects */
57} history_record;
58
59/* this structure contains * ALL * information that we want
60 * our child modules to know about, but don't want them to
61 * modify.
62 */
63typedef struct {
64 /* vendor information */
65 vendor_struct fti_drive_type;
66 /* data rates */
67 unsigned int fti_used_data_rate;
68 unsigned int fti_drive_max_rate;
69 unsigned int fti_fdc_max_rate;
70 /* drive selection, either FTAPE_SEL_A/B/C/D */
71 int fti_drive_sel;
72 /* flags set after decode the drive and tape status */
73 unsigned int fti_formatted :1;
74 unsigned int fti_no_tape :1;
75 unsigned int fti_write_protected:1;
76 unsigned int fti_new_tape :1;
77 /* values of last queried drive/tape status and error */
78 ft_drive_error fti_last_error;
79 ft_drive_status fti_last_status;
80 /* cartridge geometry */
81 unsigned int fti_tracks_per_tape;
82 unsigned int fti_segments_per_track;
83 /* location of header segments, etc. */
84 int fti_used_header_segment;
85 int fti_header_segment_1;
86 int fti_header_segment_2;
87 int fti_first_data_segment;
88 int fti_last_data_segment;
89 /* the format code as stored in the header segment */
90 ft_format_type fti_format_code;
91 /* the following is the sole reason for the ftape_set_status() call */
92 unsigned int fti_qic_std;
93 /* is tape running? */
94 volatile enum runner_status_enum fti_runner_status;
95 /* is tape reading/writing/verifying/formatting/deleting */
96 buffer_state_enum fti_state;
97 /* flags fatal hardware error */
98 unsigned int fti_failure:1;
99 /* history record */
100 history_record fti_history;
101} ftape_info;
102
103/* vendor information */
104#define ft_drive_type ftape_status.fti_drive_type
105/* data rates */
106#define ft_data_rate ftape_status.fti_used_data_rate
107#define ft_drive_max_rate ftape_status.fti_drive_max_rate
108#define ft_fdc_max_rate ftape_status.fti_fdc_max_rate
109/* drive selection, either FTAPE_SEL_A/B/C/D */
110#define ft_drive_sel ftape_status.fti_drive_sel
111/* flags set after decode the drive and tape status */
112#define ft_formatted ftape_status.fti_formatted
113#define ft_no_tape ftape_status.fti_no_tape
114#define ft_write_protected ftape_status.fti_write_protected
115#define ft_new_tape ftape_status.fti_new_tape
116/* values of last queried drive/tape status and error */
117#define ft_last_error ftape_status.fti_last_error
118#define ft_last_status ftape_status.fti_last_status
119/* cartridge geometry */
120#define ft_tracks_per_tape ftape_status.fti_tracks_per_tape
121#define ft_segments_per_track ftape_status.fti_segments_per_track
122/* the format code as stored in the header segment */
123#define ft_format_code ftape_status.fti_format_code
124/* the qic status as returned by report drive configuration */
125#define ft_qic_std ftape_status.fti_qic_std
126#define ft_used_header_segment ftape_status.fti_used_header_segment
127#define ft_header_segment_1 ftape_status.fti_header_segment_1
128#define ft_header_segment_2 ftape_status.fti_header_segment_2
129#define ft_first_data_segment ftape_status.fti_first_data_segment
130#define ft_last_data_segment ftape_status.fti_last_data_segment
131/* is tape running? */
132#define ft_runner_status ftape_status.fti_runner_status
133/* is tape reading/writing/verifying/formatting/deleting */
134#define ft_driver_state ftape_status.fti_state
135/* flags fatal hardware error */
136#define ft_failure ftape_status.fti_failure
137/* history record */
138#define ft_history ftape_status.fti_history
139
140/*
141 * ftape-ctl.c defined global vars.
142 */
143extern ftape_info ftape_status;
144extern int ftape_segments_per_head;
145extern int ftape_segments_per_cylinder;
146extern int ftape_init_drive_needed;
147
148/*
149 * ftape-ctl.c defined global functions.
150 */
151extern int ftape_mmap(struct vm_area_struct *vma);
152extern int ftape_enable(int drive_selection);
153extern void ftape_disable(void);
154extern int ftape_seek_to_bot(void);
155extern int ftape_seek_to_eot(void);
156extern int ftape_abort_operation(void);
157extern void ftape_calc_timeouts(unsigned int qic_std,
158 unsigned int data_rate,
159 unsigned int tape_len);
160extern int ftape_calibrate_data_rate(unsigned int qic_std);
161extern const ftape_info *ftape_get_status(void);
162#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-ecc.c b/drivers/char/ftape/lowlevel/ftape-ecc.c
deleted file mode 100644
index e5632f674bc8..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-ecc.c
+++ /dev/null
@@ -1,853 +0,0 @@
1/*
2 *
3 * Copyright (c) 1993 Ning and David Mosberger.
4
5 This is based on code originally written by Bas Laarhoven (bas@vimec.nl)
6 and David L. Brown, Jr., and incorporates improvements suggested by
7 Kai Harrekilde-Petersen.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2, or (at
12 your option) any later version.
13
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 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; see the file COPYING. If not, write to
21 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
22 USA.
23
24 *
25 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ecc.c,v $
26 * $Revision: 1.3 $
27 * $Date: 1997/10/05 19:18:10 $
28 *
29 * This file contains the Reed-Solomon error correction code
30 * for the QIC-40/80 floppy-tape driver for Linux.
31 */
32
33#include <linux/ftape.h>
34
35#include "../lowlevel/ftape-tracing.h"
36#include "../lowlevel/ftape-ecc.h"
37
38/* Machines that are big-endian should define macro BIG_ENDIAN.
39 * Unfortunately, there doesn't appear to be a standard include file
40 * that works for all OSs.
41 */
42
43#if defined(__sparc__) || defined(__hppa)
44#define BIG_ENDIAN
45#endif /* __sparc__ || __hppa */
46
47#if defined(__mips__)
48#error Find a smart way to determine the Endianness of the MIPS CPU
49#endif
50
51/* Notice: to minimize the potential for confusion, we use r to
52 * denote the independent variable of the polynomials in the
53 * Galois Field GF(2^8). We reserve x for polynomials that
54 * that have coefficients in GF(2^8).
55 *
56 * The Galois Field in which coefficient arithmetic is performed are
57 * the polynomials over Z_2 (i.e., 0 and 1) modulo the irreducible
58 * polynomial f(r), where f(r)=r^8 + r^7 + r^2 + r + 1. A polynomial
59 * is represented as a byte with the MSB as the coefficient of r^7 and
60 * the LSB as the coefficient of r^0. For example, the binary
61 * representation of f(x) is 0x187 (of course, this doesn't fit into 8
62 * bits). In this field, the polynomial r is a primitive element.
63 * That is, r^i with i in 0,...,255 enumerates all elements in the
64 * field.
65 *
66 * The generator polynomial for the QIC-80 ECC is
67 *
68 * g(x) = x^3 + r^105*x^2 + r^105*x + 1
69 *
70 * which can be factored into:
71 *
72 * g(x) = (x-r^-1)(x-r^0)(x-r^1)
73 *
74 * the byte representation of the coefficients are:
75 *
76 * r^105 = 0xc0
77 * r^-1 = 0xc3
78 * r^0 = 0x01
79 * r^1 = 0x02
80 *
81 * Notice that r^-1 = r^254 as exponent arithmetic is performed
82 * modulo 2^8-1 = 255.
83 *
84 * For more information on Galois Fields and Reed-Solomon codes, refer
85 * to any good book. I found _An Introduction to Error Correcting
86 * Codes with Applications_ by S. A. Vanstone and P. C. van Oorschot
87 * to be a good introduction into the former. _CODING THEORY: The
88 * Essentials_ I found very useful for its concise description of
89 * Reed-Solomon encoding/decoding.
90 *
91 */
92
93typedef __u8 Matrix[3][3];
94
95/*
96 * gfpow[] is defined such that gfpow[i] returns r^i if
97 * i is in the range [0..255].
98 */
99static const __u8 gfpow[] =
100{
101 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
102 0x87, 0x89, 0x95, 0xad, 0xdd, 0x3d, 0x7a, 0xf4,
103 0x6f, 0xde, 0x3b, 0x76, 0xec, 0x5f, 0xbe, 0xfb,
104 0x71, 0xe2, 0x43, 0x86, 0x8b, 0x91, 0xa5, 0xcd,
105 0x1d, 0x3a, 0x74, 0xe8, 0x57, 0xae, 0xdb, 0x31,
106 0x62, 0xc4, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, 0x67,
107 0xce, 0x1b, 0x36, 0x6c, 0xd8, 0x37, 0x6e, 0xdc,
108 0x3f, 0x7e, 0xfc, 0x7f, 0xfe, 0x7b, 0xf6, 0x6b,
109 0xd6, 0x2b, 0x56, 0xac, 0xdf, 0x39, 0x72, 0xe4,
110 0x4f, 0x9e, 0xbb, 0xf1, 0x65, 0xca, 0x13, 0x26,
111 0x4c, 0x98, 0xb7, 0xe9, 0x55, 0xaa, 0xd3, 0x21,
112 0x42, 0x84, 0x8f, 0x99, 0xb5, 0xed, 0x5d, 0xba,
113 0xf3, 0x61, 0xc2, 0x03, 0x06, 0x0c, 0x18, 0x30,
114 0x60, 0xc0, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0,
115 0x47, 0x8e, 0x9b, 0xb1, 0xe5, 0x4d, 0x9a, 0xb3,
116 0xe1, 0x45, 0x8a, 0x93, 0xa1, 0xc5, 0x0d, 0x1a,
117 0x34, 0x68, 0xd0, 0x27, 0x4e, 0x9c, 0xbf, 0xf9,
118 0x75, 0xea, 0x53, 0xa6, 0xcb, 0x11, 0x22, 0x44,
119 0x88, 0x97, 0xa9, 0xd5, 0x2d, 0x5a, 0xb4, 0xef,
120 0x59, 0xb2, 0xe3, 0x41, 0x82, 0x83, 0x81, 0x85,
121 0x8d, 0x9d, 0xbd, 0xfd, 0x7d, 0xfa, 0x73, 0xe6,
122 0x4b, 0x96, 0xab, 0xd1, 0x25, 0x4a, 0x94, 0xaf,
123 0xd9, 0x35, 0x6a, 0xd4, 0x2f, 0x5e, 0xbc, 0xff,
124 0x79, 0xf2, 0x63, 0xc6, 0x0b, 0x16, 0x2c, 0x58,
125 0xb0, 0xe7, 0x49, 0x92, 0xa3, 0xc1, 0x05, 0x0a,
126 0x14, 0x28, 0x50, 0xa0, 0xc7, 0x09, 0x12, 0x24,
127 0x48, 0x90, 0xa7, 0xc9, 0x15, 0x2a, 0x54, 0xa8,
128 0xd7, 0x29, 0x52, 0xa4, 0xcf, 0x19, 0x32, 0x64,
129 0xc8, 0x17, 0x2e, 0x5c, 0xb8, 0xf7, 0x69, 0xd2,
130 0x23, 0x46, 0x8c, 0x9f, 0xb9, 0xf5, 0x6d, 0xda,
131 0x33, 0x66, 0xcc, 0x1f, 0x3e, 0x7c, 0xf8, 0x77,
132 0xee, 0x5b, 0xb6, 0xeb, 0x51, 0xa2, 0xc3, 0x01
133};
134
135/*
136 * This is a log table. That is, gflog[r^i] returns i (modulo f(r)).
137 * gflog[0] is undefined and the first element is therefore not valid.
138 */
139static const __u8 gflog[256] =
140{
141 0xff, 0x00, 0x01, 0x63, 0x02, 0xc6, 0x64, 0x6a,
142 0x03, 0xcd, 0xc7, 0xbc, 0x65, 0x7e, 0x6b, 0x2a,
143 0x04, 0x8d, 0xce, 0x4e, 0xc8, 0xd4, 0xbd, 0xe1,
144 0x66, 0xdd, 0x7f, 0x31, 0x6c, 0x20, 0x2b, 0xf3,
145 0x05, 0x57, 0x8e, 0xe8, 0xcf, 0xac, 0x4f, 0x83,
146 0xc9, 0xd9, 0xd5, 0x41, 0xbe, 0x94, 0xe2, 0xb4,
147 0x67, 0x27, 0xde, 0xf0, 0x80, 0xb1, 0x32, 0x35,
148 0x6d, 0x45, 0x21, 0x12, 0x2c, 0x0d, 0xf4, 0x38,
149 0x06, 0x9b, 0x58, 0x1a, 0x8f, 0x79, 0xe9, 0x70,
150 0xd0, 0xc2, 0xad, 0xa8, 0x50, 0x75, 0x84, 0x48,
151 0xca, 0xfc, 0xda, 0x8a, 0xd6, 0x54, 0x42, 0x24,
152 0xbf, 0x98, 0x95, 0xf9, 0xe3, 0x5e, 0xb5, 0x15,
153 0x68, 0x61, 0x28, 0xba, 0xdf, 0x4c, 0xf1, 0x2f,
154 0x81, 0xe6, 0xb2, 0x3f, 0x33, 0xee, 0x36, 0x10,
155 0x6e, 0x18, 0x46, 0xa6, 0x22, 0x88, 0x13, 0xf7,
156 0x2d, 0xb8, 0x0e, 0x3d, 0xf5, 0xa4, 0x39, 0x3b,
157 0x07, 0x9e, 0x9c, 0x9d, 0x59, 0x9f, 0x1b, 0x08,
158 0x90, 0x09, 0x7a, 0x1c, 0xea, 0xa0, 0x71, 0x5a,
159 0xd1, 0x1d, 0xc3, 0x7b, 0xae, 0x0a, 0xa9, 0x91,
160 0x51, 0x5b, 0x76, 0x72, 0x85, 0xa1, 0x49, 0xeb,
161 0xcb, 0x7c, 0xfd, 0xc4, 0xdb, 0x1e, 0x8b, 0xd2,
162 0xd7, 0x92, 0x55, 0xaa, 0x43, 0x0b, 0x25, 0xaf,
163 0xc0, 0x73, 0x99, 0x77, 0x96, 0x5c, 0xfa, 0x52,
164 0xe4, 0xec, 0x5f, 0x4a, 0xb6, 0xa2, 0x16, 0x86,
165 0x69, 0xc5, 0x62, 0xfe, 0x29, 0x7d, 0xbb, 0xcc,
166 0xe0, 0xd3, 0x4d, 0x8c, 0xf2, 0x1f, 0x30, 0xdc,
167 0x82, 0xab, 0xe7, 0x56, 0xb3, 0x93, 0x40, 0xd8,
168 0x34, 0xb0, 0xef, 0x26, 0x37, 0x0c, 0x11, 0x44,
169 0x6f, 0x78, 0x19, 0x9a, 0x47, 0x74, 0xa7, 0xc1,
170 0x23, 0x53, 0x89, 0xfb, 0x14, 0x5d, 0xf8, 0x97,
171 0x2e, 0x4b, 0xb9, 0x60, 0x0f, 0xed, 0x3e, 0xe5,
172 0xf6, 0x87, 0xa5, 0x17, 0x3a, 0xa3, 0x3c, 0xb7
173};
174
175/* This is a multiplication table for the factor 0xc0 (i.e., r^105 (mod f(r)).
176 * gfmul_c0[f] returns r^105 * f(r) (modulo f(r)).
177 */
178static const __u8 gfmul_c0[256] =
179{
180 0x00, 0xc0, 0x07, 0xc7, 0x0e, 0xce, 0x09, 0xc9,
181 0x1c, 0xdc, 0x1b, 0xdb, 0x12, 0xd2, 0x15, 0xd5,
182 0x38, 0xf8, 0x3f, 0xff, 0x36, 0xf6, 0x31, 0xf1,
183 0x24, 0xe4, 0x23, 0xe3, 0x2a, 0xea, 0x2d, 0xed,
184 0x70, 0xb0, 0x77, 0xb7, 0x7e, 0xbe, 0x79, 0xb9,
185 0x6c, 0xac, 0x6b, 0xab, 0x62, 0xa2, 0x65, 0xa5,
186 0x48, 0x88, 0x4f, 0x8f, 0x46, 0x86, 0x41, 0x81,
187 0x54, 0x94, 0x53, 0x93, 0x5a, 0x9a, 0x5d, 0x9d,
188 0xe0, 0x20, 0xe7, 0x27, 0xee, 0x2e, 0xe9, 0x29,
189 0xfc, 0x3c, 0xfb, 0x3b, 0xf2, 0x32, 0xf5, 0x35,
190 0xd8, 0x18, 0xdf, 0x1f, 0xd6, 0x16, 0xd1, 0x11,
191 0xc4, 0x04, 0xc3, 0x03, 0xca, 0x0a, 0xcd, 0x0d,
192 0x90, 0x50, 0x97, 0x57, 0x9e, 0x5e, 0x99, 0x59,
193 0x8c, 0x4c, 0x8b, 0x4b, 0x82, 0x42, 0x85, 0x45,
194 0xa8, 0x68, 0xaf, 0x6f, 0xa6, 0x66, 0xa1, 0x61,
195 0xb4, 0x74, 0xb3, 0x73, 0xba, 0x7a, 0xbd, 0x7d,
196 0x47, 0x87, 0x40, 0x80, 0x49, 0x89, 0x4e, 0x8e,
197 0x5b, 0x9b, 0x5c, 0x9c, 0x55, 0x95, 0x52, 0x92,
198 0x7f, 0xbf, 0x78, 0xb8, 0x71, 0xb1, 0x76, 0xb6,
199 0x63, 0xa3, 0x64, 0xa4, 0x6d, 0xad, 0x6a, 0xaa,
200 0x37, 0xf7, 0x30, 0xf0, 0x39, 0xf9, 0x3e, 0xfe,
201 0x2b, 0xeb, 0x2c, 0xec, 0x25, 0xe5, 0x22, 0xe2,
202 0x0f, 0xcf, 0x08, 0xc8, 0x01, 0xc1, 0x06, 0xc6,
203 0x13, 0xd3, 0x14, 0xd4, 0x1d, 0xdd, 0x1a, 0xda,
204 0xa7, 0x67, 0xa0, 0x60, 0xa9, 0x69, 0xae, 0x6e,
205 0xbb, 0x7b, 0xbc, 0x7c, 0xb5, 0x75, 0xb2, 0x72,
206 0x9f, 0x5f, 0x98, 0x58, 0x91, 0x51, 0x96, 0x56,
207 0x83, 0x43, 0x84, 0x44, 0x8d, 0x4d, 0x8a, 0x4a,
208 0xd7, 0x17, 0xd0, 0x10, 0xd9, 0x19, 0xde, 0x1e,
209 0xcb, 0x0b, 0xcc, 0x0c, 0xc5, 0x05, 0xc2, 0x02,
210 0xef, 0x2f, 0xe8, 0x28, 0xe1, 0x21, 0xe6, 0x26,
211 0xf3, 0x33, 0xf4, 0x34, 0xfd, 0x3d, 0xfa, 0x3a
212};
213
214
215/* Returns V modulo 255 provided V is in the range -255,-254,...,509.
216 */
217static inline __u8 mod255(int v)
218{
219 if (v > 0) {
220 if (v < 255) {
221 return v;
222 } else {
223 return v - 255;
224 }
225 } else {
226 return v + 255;
227 }
228}
229
230
231/* Add two numbers in the field. Addition in this field is equivalent
232 * to a bit-wise exclusive OR operation---subtraction is therefore
233 * identical to addition.
234 */
235static inline __u8 gfadd(__u8 a, __u8 b)
236{
237 return a ^ b;
238}
239
240
241/* Add two vectors of numbers in the field. Each byte in A and B gets
242 * added individually.
243 */
244static inline unsigned long gfadd_long(unsigned long a, unsigned long b)
245{
246 return a ^ b;
247}
248
249
250/* Multiply two numbers in the field:
251 */
252static inline __u8 gfmul(__u8 a, __u8 b)
253{
254 if (a && b) {
255 return gfpow[mod255(gflog[a] + gflog[b])];
256 } else {
257 return 0;
258 }
259}
260
261
262/* Just like gfmul, except we have already looked up the log of the
263 * second number.
264 */
265static inline __u8 gfmul_exp(__u8 a, int b)
266{
267 if (a) {
268 return gfpow[mod255(gflog[a] + b)];
269 } else {
270 return 0;
271 }
272}
273
274
275/* Just like gfmul_exp, except that A is a vector of numbers. That
276 * is, each byte in A gets multiplied by gfpow[mod255(B)].
277 */
278static inline unsigned long gfmul_exp_long(unsigned long a, int b)
279{
280 __u8 t;
281
282 if (sizeof(long) == 4) {
283 return (
284 ((t = (__u32)a >> 24 & 0xff) ?
285 (((__u32) gfpow[mod255(gflog[t] + b)]) << 24) : 0) |
286 ((t = (__u32)a >> 16 & 0xff) ?
287 (((__u32) gfpow[mod255(gflog[t] + b)]) << 16) : 0) |
288 ((t = (__u32)a >> 8 & 0xff) ?
289 (((__u32) gfpow[mod255(gflog[t] + b)]) << 8) : 0) |
290 ((t = (__u32)a >> 0 & 0xff) ?
291 (((__u32) gfpow[mod255(gflog[t] + b)]) << 0) : 0));
292 } else if (sizeof(long) == 8) {
293 return (
294 ((t = (__u64)a >> 56 & 0xff) ?
295 (((__u64) gfpow[mod255(gflog[t] + b)]) << 56) : 0) |
296 ((t = (__u64)a >> 48 & 0xff) ?
297 (((__u64) gfpow[mod255(gflog[t] + b)]) << 48) : 0) |
298 ((t = (__u64)a >> 40 & 0xff) ?
299 (((__u64) gfpow[mod255(gflog[t] + b)]) << 40) : 0) |
300 ((t = (__u64)a >> 32 & 0xff) ?
301 (((__u64) gfpow[mod255(gflog[t] + b)]) << 32) : 0) |
302 ((t = (__u64)a >> 24 & 0xff) ?
303 (((__u64) gfpow[mod255(gflog[t] + b)]) << 24) : 0) |
304 ((t = (__u64)a >> 16 & 0xff) ?
305 (((__u64) gfpow[mod255(gflog[t] + b)]) << 16) : 0) |
306 ((t = (__u64)a >> 8 & 0xff) ?
307 (((__u64) gfpow[mod255(gflog[t] + b)]) << 8) : 0) |
308 ((t = (__u64)a >> 0 & 0xff) ?
309 (((__u64) gfpow[mod255(gflog[t] + b)]) << 0) : 0));
310 } else {
311 TRACE_FUN(ft_t_any);
312 TRACE_ABORT(-1, ft_t_err, "Error: size of long is %d bytes",
313 (int)sizeof(long));
314 }
315}
316
317
318/* Divide two numbers in the field. Returns a/b (modulo f(x)).
319 */
320static inline __u8 gfdiv(__u8 a, __u8 b)
321{
322 if (!b) {
323 TRACE_FUN(ft_t_any);
324 TRACE_ABORT(0xff, ft_t_bug, "Error: division by zero");
325 } else if (a == 0) {
326 return 0;
327 } else {
328 return gfpow[mod255(gflog[a] - gflog[b])];
329 }
330}
331
332
333/* The following functions return the inverse of the matrix of the
334 * linear system that needs to be solved to determine the error
335 * magnitudes. The first deals with matrices of rank 3, while the
336 * second deals with matrices of rank 2. The error indices are passed
337 * in arguments L0,..,L2 (0=first sector, 31=last sector). The error
338 * indices must be sorted in ascending order, i.e., L0<L1<L2.
339 *
340 * The linear system that needs to be solved for the error magnitudes
341 * is A * b = s, where s is the known vector of syndromes, b is the
342 * vector of error magnitudes and A in the ORDER=3 case:
343 *
344 * A_3 = {{1/r^L[0], 1/r^L[1], 1/r^L[2]},
345 * { 1, 1, 1},
346 * { r^L[0], r^L[1], r^L[2]}}
347 */
348static inline int gfinv3(__u8 l0,
349 __u8 l1,
350 __u8 l2,
351 Matrix Ainv)
352{
353 __u8 det;
354 __u8 t20, t10, t21, t12, t01, t02;
355 int log_det;
356
357 /* compute some intermediate results: */
358 t20 = gfpow[l2 - l0]; /* t20 = r^l2/r^l0 */
359 t10 = gfpow[l1 - l0]; /* t10 = r^l1/r^l0 */
360 t21 = gfpow[l2 - l1]; /* t21 = r^l2/r^l1 */
361 t12 = gfpow[l1 - l2 + 255]; /* t12 = r^l1/r^l2 */
362 t01 = gfpow[l0 - l1 + 255]; /* t01 = r^l0/r^l1 */
363 t02 = gfpow[l0 - l2 + 255]; /* t02 = r^l0/r^l2 */
364 /* Calculate the determinant of matrix A_3^-1 (sometimes
365 * called the Vandermonde determinant):
366 */
367 det = gfadd(t20, gfadd(t10, gfadd(t21, gfadd(t12, gfadd(t01, t02)))));
368 if (!det) {
369 TRACE_FUN(ft_t_any);
370 TRACE_ABORT(0, ft_t_err,
371 "Inversion failed (3 CRC errors, >0 CRC failures)");
372 }
373 log_det = 255 - gflog[det];
374
375 /* Now, calculate all of the coefficients:
376 */
377 Ainv[0][0]= gfmul_exp(gfadd(gfpow[l1], gfpow[l2]), log_det);
378 Ainv[0][1]= gfmul_exp(gfadd(t21, t12), log_det);
379 Ainv[0][2]= gfmul_exp(gfadd(gfpow[255 - l1], gfpow[255 - l2]),log_det);
380
381 Ainv[1][0]= gfmul_exp(gfadd(gfpow[l0], gfpow[l2]), log_det);
382 Ainv[1][1]= gfmul_exp(gfadd(t20, t02), log_det);
383 Ainv[1][2]= gfmul_exp(gfadd(gfpow[255 - l0], gfpow[255 - l2]),log_det);
384
385 Ainv[2][0]= gfmul_exp(gfadd(gfpow[l0], gfpow[l1]), log_det);
386 Ainv[2][1]= gfmul_exp(gfadd(t10, t01), log_det);
387 Ainv[2][2]= gfmul_exp(gfadd(gfpow[255 - l0], gfpow[255 - l1]),log_det);
388
389 return 1;
390}
391
392
393static inline int gfinv2(__u8 l0, __u8 l1, Matrix Ainv)
394{
395 __u8 det;
396 __u8 t1, t2;
397 int log_det;
398
399 t1 = gfpow[255 - l0];
400 t2 = gfpow[255 - l1];
401 det = gfadd(t1, t2);
402 if (!det) {
403 TRACE_FUN(ft_t_any);
404 TRACE_ABORT(0, ft_t_err,
405 "Inversion failed (2 CRC errors, >0 CRC failures)");
406 }
407 log_det = 255 - gflog[det];
408
409 /* Now, calculate all of the coefficients:
410 */
411 Ainv[0][0] = Ainv[1][0] = gfpow[log_det];
412
413 Ainv[0][1] = gfmul_exp(t2, log_det);
414 Ainv[1][1] = gfmul_exp(t1, log_det);
415
416 return 1;
417}
418
419
420/* Multiply matrix A by vector S and return result in vector B. M is
421 * assumed to be of order NxN, S and B of order Nx1.
422 */
423static inline void gfmat_mul(int n, Matrix A,
424 __u8 *s, __u8 *b)
425{
426 int i, j;
427 __u8 dot_prod;
428
429 for (i = 0; i < n; ++i) {
430 dot_prod = 0;
431 for (j = 0; j < n; ++j) {
432 dot_prod = gfadd(dot_prod, gfmul(A[i][j], s[j]));
433 }
434 b[i] = dot_prod;
435 }
436}
437
438
439
440/* The Reed Solomon ECC codes are computed over the N-th byte of each
441 * block, where N=SECTOR_SIZE. There are up to 29 blocks of data, and
442 * 3 blocks of ECC. The blocks are stored contiguously in memory. A
443 * segment, consequently, is assumed to have at least 4 blocks: one or
444 * more data blocks plus three ECC blocks.
445 *
446 * Notice: In QIC-80 speak, a CRC error is a sector with an incorrect
447 * CRC. A CRC failure is a sector with incorrect data, but
448 * a valid CRC. In the error control literature, the former
449 * is usually called "erasure", the latter "error."
450 */
451/* Compute the parity bytes for C columns of data, where C is the
452 * number of bytes that fit into a long integer. We use a linear
453 * feed-back register to do this. The parity bytes P[0], P[STRIDE],
454 * P[2*STRIDE] are computed such that:
455 *
456 * x^k * p(x) + m(x) = 0 (modulo g(x))
457 *
458 * where k = NBLOCKS,
459 * p(x) = P[0] + P[STRIDE]*x + P[2*STRIDE]*x^2, and
460 * m(x) = sum_{i=0}^k m_i*x^i.
461 * m_i = DATA[i*SECTOR_SIZE]
462 */
463static inline void set_parity(unsigned long *data,
464 int nblocks,
465 unsigned long *p,
466 int stride)
467{
468 unsigned long p0, p1, p2, t1, t2, *end;
469
470 end = data + nblocks * (FT_SECTOR_SIZE / sizeof(long));
471 p0 = p1 = p2 = 0;
472 while (data < end) {
473 /* The new parity bytes p0_i, p1_i, p2_i are computed
474 * from the old values p0_{i-1}, p1_{i-1}, p2_{i-1}
475 * recursively as:
476 *
477 * p0_i = p1_{i-1} + r^105 * (m_{i-1} - p0_{i-1})
478 * p1_i = p2_{i-1} + r^105 * (m_{i-1} - p0_{i-1})
479 * p2_i = (m_{i-1} - p0_{i-1})
480 *
481 * With the initial condition: p0_0 = p1_0 = p2_0 = 0.
482 */
483 t1 = gfadd_long(*data, p0);
484 /*
485 * Multiply each byte in t1 by 0xc0:
486 */
487 if (sizeof(long) == 4) {
488 t2= (((__u32) gfmul_c0[(__u32)t1 >> 24 & 0xff]) << 24 |
489 ((__u32) gfmul_c0[(__u32)t1 >> 16 & 0xff]) << 16 |
490 ((__u32) gfmul_c0[(__u32)t1 >> 8 & 0xff]) << 8 |
491 ((__u32) gfmul_c0[(__u32)t1 >> 0 & 0xff]) << 0);
492 } else if (sizeof(long) == 8) {
493 t2= (((__u64) gfmul_c0[(__u64)t1 >> 56 & 0xff]) << 56 |
494 ((__u64) gfmul_c0[(__u64)t1 >> 48 & 0xff]) << 48 |
495 ((__u64) gfmul_c0[(__u64)t1 >> 40 & 0xff]) << 40 |
496 ((__u64) gfmul_c0[(__u64)t1 >> 32 & 0xff]) << 32 |
497 ((__u64) gfmul_c0[(__u64)t1 >> 24 & 0xff]) << 24 |
498 ((__u64) gfmul_c0[(__u64)t1 >> 16 & 0xff]) << 16 |
499 ((__u64) gfmul_c0[(__u64)t1 >> 8 & 0xff]) << 8 |
500 ((__u64) gfmul_c0[(__u64)t1 >> 0 & 0xff]) << 0);
501 } else {
502 TRACE_FUN(ft_t_any);
503 TRACE(ft_t_err, "Error: long is of size %d",
504 (int) sizeof(long));
505 TRACE_EXIT;
506 }
507 p0 = gfadd_long(t2, p1);
508 p1 = gfadd_long(t2, p2);
509 p2 = t1;
510 data += FT_SECTOR_SIZE / sizeof(long);
511 }
512 *p = p0;
513 p += stride;
514 *p = p1;
515 p += stride;
516 *p = p2;
517 return;
518}
519
520
521/* Compute the 3 syndrome values. DATA should point to the first byte
522 * of the column for which the syndromes are desired. The syndromes
523 * are computed over the first NBLOCKS of rows. The three bytes will
524 * be placed in S[0], S[1], and S[2].
525 *
526 * S[i] is the value of the "message" polynomial m(x) evaluated at the
527 * i-th root of the generator polynomial g(x).
528 *
529 * As g(x)=(x-r^-1)(x-1)(x-r^1) we evaluate the message polynomial at
530 * x=r^-1 to get S[0], at x=r^0=1 to get S[1], and at x=r to get S[2].
531 * This could be done directly and efficiently via the Horner scheme.
532 * However, it would require multiplication tables for the factors
533 * r^-1 (0xc3) and r (0x02). The following scheme does not require
534 * any multiplication tables beyond what's needed for set_parity()
535 * anyway and is slightly faster if there are no errors and slightly
536 * slower if there are errors. The latter is hopefully the infrequent
537 * case.
538 *
539 * To understand the alternative algorithm, notice that set_parity(m,
540 * k, p) computes parity bytes such that:
541 *
542 * x^k * p(x) = m(x) (modulo g(x)).
543 *
544 * That is, to evaluate m(r^m), where r^m is a root of g(x), we can
545 * simply evaluate (r^m)^k*p(r^m). Also, notice that p is 0 if and
546 * only if s is zero. That is, if all parity bytes are 0, we know
547 * there is no error in the data and consequently there is no need to
548 * compute s(x) at all! In all other cases, we compute s(x) from p(x)
549 * by evaluating (r^m)^k*p(r^m) for m=-1, m=0, and m=1. The p(x)
550 * polynomial is evaluated via the Horner scheme.
551 */
552static int compute_syndromes(unsigned long *data, int nblocks, unsigned long *s)
553{
554 unsigned long p[3];
555
556 set_parity(data, nblocks, p, 1);
557 if (p[0] | p[1] | p[2]) {
558 /* Some of the checked columns do not have a zero
559 * syndrome. For simplicity, we compute the syndromes
560 * for all columns that we have computed the
561 * remainders for.
562 */
563 s[0] = gfmul_exp_long(
564 gfadd_long(p[0],
565 gfmul_exp_long(
566 gfadd_long(p[1],
567 gfmul_exp_long(p[2], -1)),
568 -1)),
569 -nblocks);
570 s[1] = gfadd_long(gfadd_long(p[2], p[1]), p[0]);
571 s[2] = gfmul_exp_long(
572 gfadd_long(p[0],
573 gfmul_exp_long(
574 gfadd_long(p[1],
575 gfmul_exp_long(p[2], 1)),
576 1)),
577 nblocks);
578 return 0;
579 } else {
580 return 1;
581 }
582}
583
584
585/* Correct the block in the column pointed to by DATA. There are NBAD
586 * CRC errors and their indices are in BAD_LOC[0], up to
587 * BAD_LOC[NBAD-1]. If NBAD>1, Ainv holds the inverse of the matrix
588 * of the linear system that needs to be solved to determine the error
589 * magnitudes. S[0], S[1], and S[2] are the syndrome values. If row
590 * j gets corrected, then bit j will be set in CORRECTION_MAP.
591 */
592static inline int correct_block(__u8 *data, int nblocks,
593 int nbad, int *bad_loc, Matrix Ainv,
594 __u8 *s,
595 SectorMap * correction_map)
596{
597 int ncorrected = 0;
598 int i;
599 __u8 t1, t2;
600 __u8 c0, c1, c2; /* check bytes */
601 __u8 error_mag[3], log_error_mag;
602 __u8 *dp, l, e;
603 TRACE_FUN(ft_t_any);
604
605 switch (nbad) {
606 case 0:
607 /* might have a CRC failure: */
608 if (s[0] == 0) {
609 /* more than one error */
610 TRACE_ABORT(-1, ft_t_err,
611 "ECC failed (0 CRC errors, >1 CRC failures)");
612 }
613 t1 = gfdiv(s[1], s[0]);
614 if ((bad_loc[nbad++] = gflog[t1]) >= nblocks) {
615 TRACE(ft_t_err,
616 "ECC failed (0 CRC errors, >1 CRC failures)");
617 TRACE_ABORT(-1, ft_t_err,
618 "attempt to correct data at %d", bad_loc[0]);
619 }
620 error_mag[0] = s[1];
621 break;
622 case 1:
623 t1 = gfadd(gfmul_exp(s[1], bad_loc[0]), s[2]);
624 t2 = gfadd(gfmul_exp(s[0], bad_loc[0]), s[1]);
625 if (t1 == 0 && t2 == 0) {
626 /* one erasure, no error: */
627 Ainv[0][0] = gfpow[bad_loc[0]];
628 } else if (t1 == 0 || t2 == 0) {
629 /* one erasure and more than one error: */
630 TRACE_ABORT(-1, ft_t_err,
631 "ECC failed (1 erasure, >1 error)");
632 } else {
633 /* one erasure, one error: */
634 if ((bad_loc[nbad++] = gflog[gfdiv(t1, t2)])
635 >= nblocks) {
636 TRACE(ft_t_err, "ECC failed "
637 "(1 CRC errors, >1 CRC failures)");
638 TRACE_ABORT(-1, ft_t_err,
639 "attempt to correct data at %d",
640 bad_loc[1]);
641 }
642 if (!gfinv2(bad_loc[0], bad_loc[1], Ainv)) {
643 /* inversion failed---must have more
644 * than one error
645 */
646 TRACE_EXIT -1;
647 }
648 }
649 /* FALL THROUGH TO ERROR MAGNITUDE COMPUTATION:
650 */
651 case 2:
652 case 3:
653 /* compute error magnitudes: */
654 gfmat_mul(nbad, Ainv, s, error_mag);
655 break;
656
657 default:
658 TRACE_ABORT(-1, ft_t_err,
659 "Internal Error: number of CRC errors > 3");
660 }
661
662 /* Perform correction by adding ERROR_MAG[i] to the byte at
663 * offset BAD_LOC[i]. Also add the value of the computed
664 * error polynomial to the syndrome values. If the correction
665 * was successful, the resulting check bytes should be zero
666 * (i.e., the corrected data is a valid code word).
667 */
668 c0 = s[0];
669 c1 = s[1];
670 c2 = s[2];
671 for (i = 0; i < nbad; ++i) {
672 e = error_mag[i];
673 if (e) {
674 /* correct the byte at offset L by magnitude E: */
675 l = bad_loc[i];
676 dp = &data[l * FT_SECTOR_SIZE];
677 *dp = gfadd(*dp, e);
678 *correction_map |= 1 << l;
679 ++ncorrected;
680
681 log_error_mag = gflog[e];
682 c0 = gfadd(c0, gfpow[mod255(log_error_mag - l)]);
683 c1 = gfadd(c1, e);
684 c2 = gfadd(c2, gfpow[mod255(log_error_mag + l)]);
685 }
686 }
687 if (c0 || c1 || c2) {
688 TRACE_ABORT(-1, ft_t_err,
689 "ECC self-check failed, too many errors");
690 }
691 TRACE_EXIT ncorrected;
692}
693
694
695#if defined(ECC_SANITY_CHECK) || defined(ECC_PARANOID)
696
697/* Perform a sanity check on the computed parity bytes:
698 */
699static int sanity_check(unsigned long *data, int nblocks)
700{
701 TRACE_FUN(ft_t_any);
702 unsigned long s[3];
703
704 if (!compute_syndromes(data, nblocks, s)) {
705 TRACE_ABORT(0, ft_bug,
706 "Internal Error: syndrome self-check failed");
707 }
708 TRACE_EXIT 1;
709}
710
711#endif /* defined(ECC_SANITY_CHECK) || defined(ECC_PARANOID) */
712
713/* Compute the parity for an entire segment of data.
714 */
715int ftape_ecc_set_segment_parity(struct memory_segment *mseg)
716{
717 int i;
718 __u8 *parity_bytes;
719
720 parity_bytes = &mseg->data[(mseg->blocks - 3) * FT_SECTOR_SIZE];
721 for (i = 0; i < FT_SECTOR_SIZE; i += sizeof(long)) {
722 set_parity((unsigned long *) &mseg->data[i], mseg->blocks - 3,
723 (unsigned long *) &parity_bytes[i],
724 FT_SECTOR_SIZE / sizeof(long));
725#ifdef ECC_PARANOID
726 if (!sanity_check((unsigned long *) &mseg->data[i],
727 mseg->blocks)) {
728 return -1;
729 }
730#endif /* ECC_PARANOID */
731 }
732 return 0;
733}
734
735
736/* Checks and corrects (if possible) the segment MSEG. Returns one of
737 * ECC_OK, ECC_CORRECTED, and ECC_FAILED.
738 */
739int ftape_ecc_correct_data(struct memory_segment *mseg)
740{
741 int col, i, result;
742 int ncorrected = 0;
743 int nerasures = 0; /* # of erasures (CRC errors) */
744 int erasure_loc[3]; /* erasure locations */
745 unsigned long ss[3];
746 __u8 s[3];
747 Matrix Ainv;
748 TRACE_FUN(ft_t_flow);
749
750 mseg->corrected = 0;
751
752 /* find first column that has non-zero syndromes: */
753 for (col = 0; col < FT_SECTOR_SIZE; col += sizeof(long)) {
754 if (!compute_syndromes((unsigned long *) &mseg->data[col],
755 mseg->blocks, ss)) {
756 /* something is wrong---have to fix things */
757 break;
758 }
759 }
760 if (col >= FT_SECTOR_SIZE) {
761 /* all syndromes are ok, therefore nothing to correct */
762 TRACE_EXIT ECC_OK;
763 }
764 /* count the number of CRC errors if there were any: */
765 if (mseg->read_bad) {
766 for (i = 0; i < mseg->blocks; i++) {
767 if (BAD_CHECK(mseg->read_bad, i)) {
768 if (nerasures >= 3) {
769 /* this is too much for ECC */
770 TRACE_ABORT(ECC_FAILED, ft_t_err,
771 "ECC failed (>3 CRC errors)");
772 } /* if */
773 erasure_loc[nerasures++] = i;
774 }
775 }
776 }
777 /*
778 * If there are at least 2 CRC errors, determine inverse of matrix
779 * of linear system to be solved:
780 */
781 switch (nerasures) {
782 case 2:
783 if (!gfinv2(erasure_loc[0], erasure_loc[1], Ainv)) {
784 TRACE_EXIT ECC_FAILED;
785 }
786 break;
787 case 3:
788 if (!gfinv3(erasure_loc[0], erasure_loc[1],
789 erasure_loc[2], Ainv)) {
790 TRACE_EXIT ECC_FAILED;
791 }
792 break;
793 default:
794 /* this is not an error condition... */
795 break;
796 }
797
798 do {
799 for (i = 0; i < sizeof(long); ++i) {
800 s[0] = ss[0];
801 s[1] = ss[1];
802 s[2] = ss[2];
803 if (s[0] | s[1] | s[2]) {
804#ifdef BIG_ENDIAN
805 result = correct_block(
806 &mseg->data[col + sizeof(long) - 1 - i],
807 mseg->blocks,
808 nerasures,
809 erasure_loc,
810 Ainv,
811 s,
812 &mseg->corrected);
813#else
814 result = correct_block(&mseg->data[col + i],
815 mseg->blocks,
816 nerasures,
817 erasure_loc,
818 Ainv,
819 s,
820 &mseg->corrected);
821#endif
822 if (result < 0) {
823 TRACE_EXIT ECC_FAILED;
824 }
825 ncorrected += result;
826 }
827 ss[0] >>= 8;
828 ss[1] >>= 8;
829 ss[2] >>= 8;
830 }
831
832#ifdef ECC_SANITY_CHECK
833 if (!sanity_check((unsigned long *) &mseg->data[col],
834 mseg->blocks)) {
835 TRACE_EXIT ECC_FAILED;
836 }
837#endif /* ECC_SANITY_CHECK */
838
839 /* find next column with non-zero syndromes: */
840 while ((col += sizeof(long)) < FT_SECTOR_SIZE) {
841 if (!compute_syndromes((unsigned long *)
842 &mseg->data[col], mseg->blocks, ss)) {
843 /* something is wrong---have to fix things */
844 break;
845 }
846 }
847 } while (col < FT_SECTOR_SIZE);
848 if (ncorrected && nerasures == 0) {
849 TRACE(ft_t_warn, "block contained error not caught by CRC");
850 }
851 TRACE((ncorrected > 0) ? ft_t_noise : ft_t_any, "number of corrections: %d", ncorrected);
852 TRACE_EXIT ncorrected ? ECC_CORRECTED : ECC_OK;
853}
diff --git a/drivers/char/ftape/lowlevel/ftape-ecc.h b/drivers/char/ftape/lowlevel/ftape-ecc.h
deleted file mode 100644
index 4829146fe9a0..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-ecc.h
+++ /dev/null
@@ -1,84 +0,0 @@
1#ifndef _FTAPE_ECC_H_
2#define _FTAPE_ECC_H_
3
4/*
5 * Copyright (C) 1993 Ning and David Mosberger.
6 * Original:
7 * Copyright (C) 1993 Bas Laarhoven.
8 * Copyright (C) 1992 David L. Brown, Jr.
9
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
14
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 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; see the file COPYING. If not, write to
22 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
23 USA.
24
25 *
26 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-ecc.h,v $
27 * $Revision: 1.2 $
28 * $Date: 1997/10/05 19:18:11 $
29 *
30 * This file contains the definitions for the
31 * Reed-Solomon error correction code
32 * for the QIC-40/80 tape streamer device driver.
33 */
34
35#include "../lowlevel/ftape-bsm.h"
36
37#define BAD_CLEAR(entry) ((entry)=0)
38#define BAD_SET(entry,sector) ((entry)|=(1<<(sector)))
39#define BAD_CHECK(entry,sector) ((entry)&(1<<(sector)))
40
41/*
42 * Return values for ecc_correct_data:
43 */
44enum {
45 ECC_OK, /* Data was correct. */
46 ECC_CORRECTED, /* Correctable error in data. */
47 ECC_FAILED, /* Could not correct data. */
48};
49
50/*
51 * Representation of an in memory segment. MARKED_BAD lists the
52 * sectors that were marked bad during formatting. If the N-th sector
53 * in a segment is marked bad, bit 1<<N will be set in MARKED_BAD.
54 * The sectors should be read in from the disk and packed, as if the
55 * bad sectors were not there, and the segment just contained fewer
56 * sectors. READ_SECTORS is a bitmap of errors encountered while
57 * reading the data. These offsets are relative to the packed data.
58 * BLOCKS is a count of the sectors not marked bad. This is just to
59 * prevent having to count the zero bits in MARKED_BAD each time this
60 * is needed. DATA is the actual sector packed data from (or to) the
61 * tape.
62 */
63 struct memory_segment {
64 SectorMap marked_bad;
65 SectorMap read_bad;
66 int blocks;
67 __u8 *data;
68 SectorMap corrected;
69 };
70
71/*
72 * ecc.c defined global variables:
73 */
74#ifdef TEST
75extern int ftape_ecc_tracing;
76#endif
77
78/*
79 * ecc.c defined global functions:
80 */
81extern int ftape_ecc_correct_data(struct memory_segment *data);
82extern int ftape_ecc_set_segment_parity(struct memory_segment *data);
83
84#endif /* _FTAPE_ECC_H_ */
diff --git a/drivers/char/ftape/lowlevel/ftape-format.c b/drivers/char/ftape/lowlevel/ftape-format.c
deleted file mode 100644
index 5dd4c59a3f34..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-format.c
+++ /dev/null
@@ -1,344 +0,0 @@
1/*
2 * Copyright (C) 1997 Claus-Justus Heine.
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-format.c,v $
20 * $Revision: 1.2.4.1 $
21 * $Date: 1997/11/14 16:05:39 $
22 *
23 * This file contains the code to support formatting of floppy
24 * tape cartridges with the QIC-40/80/3010/3020 floppy-tape
25 * driver "ftape" for Linux.
26 */
27
28#include <linux/string.h>
29#include <linux/errno.h>
30
31#include <linux/ftape.h>
32#include <linux/qic117.h>
33#include "../lowlevel/ftape-tracing.h"
34#include "../lowlevel/ftape-io.h"
35#include "../lowlevel/ftape-ctl.h"
36#include "../lowlevel/ftape-rw.h"
37#include "../lowlevel/ftape-ecc.h"
38#include "../lowlevel/ftape-bsm.h"
39#include "../lowlevel/ftape-format.h"
40
41#if defined(TESTING)
42#define FT_FMT_SEGS_PER_BUF 50
43#else
44#define FT_FMT_SEGS_PER_BUF (FT_BUFF_SIZE/(4*FT_SECTORS_PER_SEGMENT))
45#endif
46
47static spinlock_t ftape_format_lock;
48
49/*
50 * first segment of the new buffer
51 */
52static int switch_segment;
53
54/*
55 * at most 256 segments fit into one 32 kb buffer. Even TR-1 cartridges have
56 * more than this many segments per track, so better be careful.
57 *
58 * buffer_struct *buff: buffer to store the formatting coordinates in
59 * int start: starting segment for this buffer.
60 * int spt: segments per track
61 *
62 * Note: segment ids are relative to the start of the track here.
63 */
64static void setup_format_buffer(buffer_struct *buff, int start, int spt,
65 __u8 gap3)
66{
67 int to_do = spt - start;
68 TRACE_FUN(ft_t_flow);
69
70 if (to_do > FT_FMT_SEGS_PER_BUF) {
71 to_do = FT_FMT_SEGS_PER_BUF;
72 }
73 buff->ptr = buff->address;
74 buff->remaining = to_do * FT_SECTORS_PER_SEGMENT; /* # sectors */
75 buff->bytes = buff->remaining * 4; /* need 4 bytes per sector */
76 buff->gap3 = gap3;
77 buff->segment_id = start;
78 buff->next_segment = start + to_do;
79 if (buff->next_segment >= spt) {
80 buff->next_segment = 0; /* 0 means: stop runner */
81 }
82 buff->status = waiting; /* tells the isr that it can use
83 * this buffer
84 */
85 TRACE_EXIT;
86}
87
88
89/*
90 * start formatting a new track.
91 */
92int ftape_format_track(const unsigned int track, const __u8 gap3)
93{
94 unsigned long flags;
95 buffer_struct *tail, *head;
96 int status;
97 TRACE_FUN(ft_t_flow);
98
99 TRACE_CATCH(ftape_ready_wait(ftape_timeout.pause, &status),);
100 if (track & 1) {
101 if (!(status & QIC_STATUS_AT_EOT)) {
102 TRACE_CATCH(ftape_seek_to_eot(),);
103 }
104 } else {
105 if (!(status & QIC_STATUS_AT_BOT)) {
106 TRACE_CATCH(ftape_seek_to_bot(),);
107 }
108 }
109 ftape_abort_operation(); /* this sets ft_head = ft_tail = 0 */
110 ftape_set_state(formatting);
111
112 TRACE(ft_t_noise,
113 "Formatting track %d, logical: from segment %d to %d",
114 track, track * ft_segments_per_track,
115 (track + 1) * ft_segments_per_track - 1);
116
117 /*
118 * initialize the buffer switching protocol for this track
119 */
120 head = ftape_get_buffer(ft_queue_head); /* tape isn't running yet */
121 tail = ftape_get_buffer(ft_queue_tail); /* tape isn't running yet */
122 switch_segment = 0;
123 do {
124 FT_SIGNAL_EXIT(_DONT_BLOCK);
125 setup_format_buffer(tail, switch_segment,
126 ft_segments_per_track, gap3);
127 switch_segment = tail->next_segment;
128 } while ((switch_segment != 0) &&
129 ((tail = ftape_next_buffer(ft_queue_tail)) != head));
130 /* go */
131 head->status = formatting;
132 TRACE_CATCH(ftape_seek_head_to_track(track),);
133 TRACE_CATCH(ftape_command(QIC_LOGICAL_FORWARD),);
134 spin_lock_irqsave(&ftape_format_lock, flags);
135 TRACE_CATCH(fdc_setup_formatting(head), restore_flags(flags));
136 spin_unlock_irqrestore(&ftape_format_lock, flags);
137 TRACE_EXIT 0;
138}
139
140/* return segment id of segment currently being formatted and do the
141 * buffer switching stuff.
142 */
143int ftape_format_status(unsigned int *segment_id)
144{
145 buffer_struct *tail = ftape_get_buffer(ft_queue_tail);
146 int result;
147 TRACE_FUN(ft_t_flow);
148
149 while (switch_segment != 0 &&
150 ftape_get_buffer(ft_queue_head) != tail) {
151 FT_SIGNAL_EXIT(_DONT_BLOCK);
152 /* need more buffers, first wait for empty buffer
153 */
154 TRACE_CATCH(ftape_wait_segment(formatting),);
155 /* don't worry for gap3. If we ever hit this piece of code,
156 * then all buffer already have the correct gap3 set!
157 */
158 setup_format_buffer(tail, switch_segment,
159 ft_segments_per_track, tail->gap3);
160 switch_segment = tail->next_segment;
161 if (switch_segment != 0) {
162 tail = ftape_next_buffer(ft_queue_tail);
163 }
164 }
165 /* should runner stop ?
166 */
167 if (ft_runner_status == aborting || ft_runner_status == do_abort) {
168 buffer_struct *head = ftape_get_buffer(ft_queue_head);
169 TRACE(ft_t_warn, "Error formatting segment %d",
170 ftape_get_buffer(ft_queue_head)->segment_id);
171 (void)ftape_abort_operation();
172 TRACE_EXIT (head->status != error) ? -EAGAIN : -EIO;
173 }
174 /*
175 * don't care if the timer expires, this is just kind of a
176 * "select" operation that lets the calling process sleep
177 * until something has happened
178 */
179 if (fdc_interrupt_wait(5 * FT_SECOND) < 0) {
180 TRACE(ft_t_noise, "End of track %d at segment %d",
181 ft_location.track,
182 ftape_get_buffer(ft_queue_head)->segment_id);
183 result = 1; /* end of track, unlock module */
184 } else {
185 result = 0;
186 }
187 /*
188 * the calling process should use the seg id to determine
189 * which parts of the dma buffers can be safely overwritten
190 * with new data.
191 */
192 *segment_id = ftape_get_buffer(ft_queue_head)->segment_id;
193 /*
194 * Internally we start counting segment ids from the start of
195 * each track when formatting, but externally we keep them
196 * relative to the start of the tape:
197 */
198 *segment_id += ft_location.track * ft_segments_per_track;
199 TRACE_EXIT result;
200}
201
202/*
203 * The segment id is relative to the start of the tape
204 */
205int ftape_verify_segment(const unsigned int segment_id, SectorMap *bsm)
206{
207 int result;
208 int verify_done = 0;
209 TRACE_FUN(ft_t_flow);
210
211 TRACE(ft_t_noise, "Verifying segment %d", segment_id);
212
213 if (ft_driver_state != verifying) {
214 TRACE(ft_t_noise, "calling ftape_abort_operation");
215 if (ftape_abort_operation() < 0) {
216 TRACE(ft_t_err, "ftape_abort_operation failed");
217 TRACE_EXIT -EIO;
218 }
219 }
220 *bsm = 0x00000000;
221 ftape_set_state(verifying);
222 for (;;) {
223 buffer_struct *tail;
224 /*
225 * Allow escape from this loop on signal
226 */
227 FT_SIGNAL_EXIT(_DONT_BLOCK);
228 /*
229 * Search all full buffers for the first matching the
230 * wanted segment. Clear other buffers on the fly.
231 */
232 tail = ftape_get_buffer(ft_queue_tail);
233 while (!verify_done && tail->status == done) {
234 /*
235 * Allow escape from this loop on signal !
236 */
237 FT_SIGNAL_EXIT(_DONT_BLOCK);
238 if (tail->segment_id == segment_id) {
239 /* If out buffer is already full,
240 * return its contents.
241 */
242 TRACE(ft_t_flow, "found segment in cache: %d",
243 segment_id);
244 if ((tail->soft_error_map |
245 tail->hard_error_map) != 0) {
246 TRACE(ft_t_info,"bsm[%d] = 0x%08lx",
247 segment_id,
248 (unsigned long)
249 (tail->soft_error_map |
250 tail->hard_error_map));
251 *bsm = (tail->soft_error_map |
252 tail->hard_error_map);
253 }
254 verify_done = 1;
255 } else {
256 TRACE(ft_t_flow,"zapping segment in cache: %d",
257 tail->segment_id);
258 }
259 tail->status = waiting;
260 tail = ftape_next_buffer(ft_queue_tail);
261 }
262 if (!verify_done && tail->status == verifying) {
263 if (tail->segment_id == segment_id) {
264 switch(ftape_wait_segment(verifying)) {
265 case 0:
266 break;
267 case -EINTR:
268 TRACE_ABORT(-EINTR, ft_t_warn,
269 "interrupted by "
270 "non-blockable signal");
271 break;
272 default:
273 ftape_abort_operation();
274 ftape_set_state(verifying);
275 /* be picky */
276 TRACE_ABORT(-EIO, ft_t_warn,
277 "wait_segment failed");
278 }
279 } else {
280 /* We're reading the wrong segment,
281 * stop runner.
282 */
283 TRACE(ft_t_noise, "verifying wrong segment");
284 ftape_abort_operation();
285 ftape_set_state(verifying);
286 }
287 }
288 /* should runner stop ?
289 */
290 if (ft_runner_status == aborting) {
291 buffer_struct *head = ftape_get_buffer(ft_queue_head);
292 if (head->status == error ||
293 head->status == verifying) {
294 /* no data or overrun error */
295 head->status = waiting;
296 }
297 TRACE_CATCH(ftape_dumb_stop(),);
298 } else {
299 /* If just passed last segment on tape: wait
300 * for BOT or EOT mark. Sets ft_runner_status to
301 * idle if at lEOT and successful
302 */
303 TRACE_CATCH(ftape_handle_logical_eot(),);
304 }
305 if (verify_done) {
306 TRACE_EXIT 0;
307 }
308 /* Now at least one buffer is idle!
309 * Restart runner & tape if needed.
310 */
311 /* We could optimize the following a little bit. We know that
312 * the bad sector map is empty.
313 */
314 tail = ftape_get_buffer(ft_queue_tail);
315 if (tail->status == waiting) {
316 buffer_struct *head = ftape_get_buffer(ft_queue_head);
317
318 ftape_setup_new_segment(head, segment_id, -1);
319 ftape_calc_next_cluster(head);
320 if (ft_runner_status == idle) {
321 result = ftape_start_tape(segment_id,
322 head->sector_offset);
323 switch(result) {
324 case 0:
325 break;
326 case -ETIME:
327 case -EINTR:
328 TRACE_ABORT(result, ft_t_err, "Error: "
329 "segment %d unreachable",
330 segment_id);
331 break;
332 default:
333 *bsm = EMPTY_SEGMENT;
334 TRACE_EXIT 0;
335 break;
336 }
337 }
338 head->status = verifying;
339 fdc_setup_read_write(head, FDC_VERIFY);
340 }
341 }
342 /* not reached */
343 TRACE_EXIT -EIO;
344}
diff --git a/drivers/char/ftape/lowlevel/ftape-format.h b/drivers/char/ftape/lowlevel/ftape-format.h
deleted file mode 100644
index f15161566643..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-format.h
+++ /dev/null
@@ -1,37 +0,0 @@
1#ifndef _FTAPE_FORMAT_H
2#define _FTAPE_FORMAT_H
3
4/*
5 * Copyright (C) 1996-1997 Claus-Justus Heine.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-format.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:18:13 $
25 *
26 * This file contains the low level definitions for the
27 * formatting support for the QIC-40/80/3010/3020 floppy-tape
28 * driver "ftape" for Linux.
29 */
30
31#ifdef __KERNEL__
32extern int ftape_format_track(const unsigned int track, const __u8 gap3);
33extern int ftape_format_status(unsigned int *segment_id);
34extern int ftape_verify_segment(const unsigned int segment_id, SectorMap *bsm);
35#endif /* __KERNEL__ */
36
37#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-init.c b/drivers/char/ftape/lowlevel/ftape-init.c
deleted file mode 100644
index 4998132a81d1..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-init.c
+++ /dev/null
@@ -1,160 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * This file contains the code that interfaces the kernel
21 * for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
22 */
23
24#include <linux/module.h>
25#include <linux/errno.h>
26#include <linux/fs.h>
27#include <linux/kernel.h>
28#include <linux/signal.h>
29#include <linux/major.h>
30
31#include <linux/ftape.h>
32#include <linux/init.h>
33#include <linux/qic117.h>
34#ifdef CONFIG_ZFTAPE
35#include <linux/zftape.h>
36#endif
37
38#include "../lowlevel/ftape-init.h"
39#include "../lowlevel/ftape-io.h"
40#include "../lowlevel/ftape-read.h"
41#include "../lowlevel/ftape-write.h"
42#include "../lowlevel/ftape-ctl.h"
43#include "../lowlevel/ftape-rw.h"
44#include "../lowlevel/fdc-io.h"
45#include "../lowlevel/ftape-buffer.h"
46#include "../lowlevel/ftape-proc.h"
47#include "../lowlevel/ftape-tracing.h"
48
49
50#if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
51static int ft_tracing = -1;
52#endif
53
54
55/* Called by modules package when installing the driver
56 * or by kernel during the initialization phase
57 */
58static int __init ftape_init(void)
59{
60 TRACE_FUN(ft_t_flow);
61
62#ifdef MODULE
63#ifndef CONFIG_FT_NO_TRACE_AT_ALL
64 if (ft_tracing != -1) {
65 ftape_tracing = ft_tracing;
66 }
67#endif
68 printk(KERN_INFO FTAPE_VERSION "\n");
69 if (TRACE_LEVEL >= ft_t_info) {
70 printk(
71KERN_INFO "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl)\n"
72KERN_INFO "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no)\n"
73KERN_INFO "(c) 1996-1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
74KERN_INFO "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives\n");
75 }
76#else /* !MODULE */
77 /* print a short no-nonsense boot message */
78 printk(KERN_INFO FTAPE_VERSION "\n");
79#endif /* MODULE */
80 TRACE(ft_t_info, "installing QIC-117 floppy tape hardware drive ... ");
81 TRACE(ft_t_info, "ftape_init @ 0x%p", ftape_init);
82 /* Allocate the DMA buffers. They are deallocated at cleanup() time.
83 */
84#ifdef TESTING
85#ifdef MODULE
86 while (ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS) < 0) {
87 ftape_sleep(FT_SECOND/20);
88 if (signal_pending(current)) {
89 (void)ftape_set_nr_buffers(0);
90 TRACE(ft_t_bug,
91 "Killed by signal while allocating buffers.");
92 TRACE_ABORT(-EINTR,
93 ft_t_bug, "Free up memory and retry");
94 }
95 }
96#else
97 TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
98 (void)ftape_set_nr_buffers(0));
99#endif
100#else
101 TRACE_CATCH(ftape_set_nr_buffers(CONFIG_FT_NR_BUFFERS),
102 (void)ftape_set_nr_buffers(0));
103#endif
104 ft_drive_sel = -1;
105 ft_failure = 1; /* inhibit any operation but open */
106 ftape_udelay_calibrate(); /* must be before fdc_wait_calibrate ! */
107 fdc_wait_calibrate();
108#if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
109 (void)ftape_proc_init();
110#endif
111#ifdef CONFIG_ZFTAPE
112 (void)zft_init();
113#endif
114 TRACE_EXIT 0;
115}
116
117module_param(ft_fdc_base, uint, 0);
118MODULE_PARM_DESC(ft_fdc_base, "Base address of FDC controller.");
119module_param(ft_fdc_irq, uint, 0);
120MODULE_PARM_DESC(ft_fdc_irq, "IRQ (interrupt channel) to use.");
121module_param(ft_fdc_dma, uint, 0);
122MODULE_PARM_DESC(ft_fdc_dma, "DMA channel to use.");
123module_param(ft_fdc_threshold, uint, 0);
124MODULE_PARM_DESC(ft_fdc_threshold, "Threshold of the FDC Fifo.");
125module_param(ft_fdc_rate_limit, uint, 0);
126MODULE_PARM_DESC(ft_fdc_rate_limit, "Maximal data rate for FDC.");
127module_param(ft_probe_fc10, bool, 0);
128MODULE_PARM_DESC(ft_probe_fc10,
129 "If non-zero, probe for a Colorado FC-10/FC-20 controller.");
130module_param(ft_mach2, bool, 0);
131MODULE_PARM_DESC(ft_mach2,
132 "If non-zero, probe for a Mountain MACH-2 controller.");
133#if defined(MODULE) && !defined(CONFIG_FT_NO_TRACE_AT_ALL)
134module_param(ft_tracing, int, 0644);
135MODULE_PARM_DESC(ft_tracing,
136 "Amount of debugging output, 0 <= tracing <= 8, default 3.");
137#endif
138
139MODULE_AUTHOR(
140 "(c) 1993-1996 Bas Laarhoven (bas@vimec.nl), "
141 "(c) 1995-1996 Kai Harrekilde-Petersen (khp@dolphinics.no), "
142 "(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)");
143MODULE_DESCRIPTION(
144 "QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives.");
145MODULE_LICENSE("GPL");
146
147static void __exit ftape_exit(void)
148{
149 TRACE_FUN(ft_t_flow);
150
151#if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
152 ftape_proc_destroy();
153#endif
154 (void)ftape_set_nr_buffers(0);
155 printk(KERN_INFO "ftape: unloaded.\n");
156 TRACE_EXIT;
157}
158
159module_init(ftape_init);
160module_exit(ftape_exit);
diff --git a/drivers/char/ftape/lowlevel/ftape-init.h b/drivers/char/ftape/lowlevel/ftape-init.h
deleted file mode 100644
index 99a7b8ab086f..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-init.h
+++ /dev/null
@@ -1,43 +0,0 @@
1#ifndef _FTAPE_INIT_H
2#define _FTAPE_INIT_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-init.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:16 $
26 *
27 * This file contains the definitions for the interface to
28 * the Linux kernel for floppy tape driver ftape.
29 *
30 */
31
32#include <linux/linkage.h>
33#include <linux/signal.h>
34
35#define _NEVER_BLOCK (sigmask(SIGKILL) | sigmask(SIGSTOP))
36#define _DONT_BLOCK (_NEVER_BLOCK | sigmask(SIGINT))
37#define _DO_BLOCK (sigmask(SIGPIPE))
38
39#ifndef QIC117_TAPE_MAJOR
40#define QIC117_TAPE_MAJOR 27
41#endif
42
43#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-io.c b/drivers/char/ftape/lowlevel/ftape-io.c
deleted file mode 100644
index 259015aeff55..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-io.c
+++ /dev/null
@@ -1,992 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996 Kai Harrekilde-Petersen,
4 * (C) 1997 Claus-Justus Heine.
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, or (at your option)
9 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; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 *
21 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-io.c,v $
22 * $Revision: 1.4 $
23 * $Date: 1997/11/11 14:02:36 $
24 *
25 * This file contains the general control functions for the
26 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
27 */
28
29#include <linux/errno.h>
30#include <linux/sched.h>
31#include <linux/mm.h>
32#include <asm/system.h>
33#include <linux/ioctl.h>
34#include <linux/mtio.h>
35#include <linux/delay.h>
36
37#include <linux/ftape.h>
38#include <linux/qic117.h>
39#include "../lowlevel/ftape-tracing.h"
40#include "../lowlevel/fdc-io.h"
41#include "../lowlevel/ftape-io.h"
42#include "../lowlevel/ftape-ctl.h"
43#include "../lowlevel/ftape-rw.h"
44#include "../lowlevel/ftape-write.h"
45#include "../lowlevel/ftape-read.h"
46#include "../lowlevel/ftape-init.h"
47#include "../lowlevel/ftape-calibr.h"
48
49/* Global vars.
50 */
51/* NOTE: sectors start numbering at 1, all others at 0 ! */
52ft_timeout_table ftape_timeout;
53unsigned int ftape_tape_len;
54volatile qic117_cmd_t ftape_current_command;
55const struct qic117_command_table qic117_cmds[] = QIC117_COMMANDS;
56int ftape_might_be_off_track;
57
58/* Local vars.
59 */
60static int diagnostic_mode;
61static unsigned int ftape_udelay_count;
62static unsigned int ftape_udelay_time;
63
64void ftape_udelay(unsigned int usecs)
65{
66 volatile int count = (ftape_udelay_count * usecs +
67 ftape_udelay_count - 1) / ftape_udelay_time;
68 volatile int i;
69
70 while (count-- > 0) {
71 for (i = 0; i < 20; ++i);
72 }
73}
74
75void ftape_udelay_calibrate(void)
76{
77 ftape_calibrate("ftape_udelay",
78 ftape_udelay, &ftape_udelay_count, &ftape_udelay_time);
79}
80
81/* Delay (msec) routine.
82 */
83void ftape_sleep(unsigned int time)
84{
85 TRACE_FUN(ft_t_any);
86
87 time *= 1000; /* msecs -> usecs */
88 if (time < FT_USPT) {
89 /* Time too small for scheduler, do a busy wait ! */
90 ftape_udelay(time);
91 } else {
92 long timeout;
93 unsigned long flags;
94 unsigned int ticks = (time + FT_USPT - 1) / FT_USPT;
95
96 TRACE(ft_t_any, "%d msec, %d ticks", time/1000, ticks);
97 timeout = ticks;
98 save_flags(flags);
99 sti();
100 msleep_interruptible(jiffies_to_msecs(timeout));
101 /* Mmm. Isn't current->blocked == 0xffffffff ?
102 */
103 if (signal_pending(current)) {
104 TRACE(ft_t_err, "awoken by non-blocked signal :-(");
105 }
106 restore_flags(flags);
107 }
108 TRACE_EXIT;
109}
110
111/* send a command or parameter to the drive
112 * Generates # of step pulses.
113 */
114static inline int ft_send_to_drive(int arg)
115{
116 /* Always wait for a command_timeout period to separate
117 * individuals commands and/or parameters.
118 */
119 ftape_sleep(3 * FT_MILLISECOND);
120 /* Keep cylinder nr within range, step towards home if possible.
121 */
122 if (ftape_current_cylinder >= arg) {
123 return fdc_seek(ftape_current_cylinder - arg);
124 } else {
125 return fdc_seek(ftape_current_cylinder + arg);
126 }
127}
128
129/* forward */ int ftape_report_raw_drive_status(int *status);
130
131static int ft_check_cmd_restrictions(qic117_cmd_t command)
132{
133 int status = -1;
134 TRACE_FUN(ft_t_any);
135
136 TRACE(ft_t_flow, "%s", qic117_cmds[command].name);
137 /* A new motion command during an uninterruptible (motion)
138 * command requires a ready status before the new command can
139 * be issued. Otherwise a new motion command needs to be
140 * checked against required status.
141 */
142 if (qic117_cmds[command].cmd_type == motion &&
143 qic117_cmds[ftape_current_command].non_intr) {
144 ftape_report_raw_drive_status(&status);
145 if ((status & QIC_STATUS_READY) == 0) {
146 TRACE(ft_t_noise,
147 "motion cmd (%d) during non-intr cmd (%d)",
148 command, ftape_current_command);
149 TRACE(ft_t_noise, "waiting until drive gets ready");
150 ftape_ready_wait(ftape_timeout.seek,
151 &status);
152 }
153 }
154 if (qic117_cmds[command].mask != 0) {
155 __u8 difference;
156 /* Some commands do require a certain status:
157 */
158 if (status == -1) { /* not yet set */
159 ftape_report_raw_drive_status(&status);
160 }
161 difference = ((status ^ qic117_cmds[command].state) &
162 qic117_cmds[command].mask);
163 /* Wait until the drive gets
164 * ready. This may last forever if
165 * the drive never gets ready...
166 */
167 while ((difference & QIC_STATUS_READY) != 0) {
168 TRACE(ft_t_noise, "command %d issued while not ready",
169 command);
170 TRACE(ft_t_noise, "waiting until drive gets ready");
171 if (ftape_ready_wait(ftape_timeout.seek,
172 &status) == -EINTR) {
173 /* Bail out on signal !
174 */
175 TRACE_ABORT(-EINTR, ft_t_warn,
176 "interrupted by non-blockable signal");
177 }
178 difference = ((status ^ qic117_cmds[command].state) &
179 qic117_cmds[command].mask);
180 }
181 while ((difference & QIC_STATUS_ERROR) != 0) {
182 int err;
183 qic117_cmd_t cmd;
184
185 TRACE(ft_t_noise,
186 "command %d issued while error pending",
187 command);
188 TRACE(ft_t_noise, "clearing error status");
189 ftape_report_error(&err, &cmd, 1);
190 ftape_report_raw_drive_status(&status);
191 difference = ((status ^ qic117_cmds[command].state) &
192 qic117_cmds[command].mask);
193 if ((difference & QIC_STATUS_ERROR) != 0) {
194 /* Bail out on fatal signal !
195 */
196 FT_SIGNAL_EXIT(_NEVER_BLOCK);
197 }
198 }
199 if (difference) {
200 /* Any remaining difference can't be solved
201 * here.
202 */
203 if (difference & (QIC_STATUS_CARTRIDGE_PRESENT |
204 QIC_STATUS_NEW_CARTRIDGE |
205 QIC_STATUS_REFERENCED)) {
206 TRACE(ft_t_warn,
207 "Fatal: tape removed or reinserted !");
208 ft_failure = 1;
209 } else {
210 TRACE(ft_t_err, "wrong state: 0x%02x should be: 0x%02x",
211 status & qic117_cmds[command].mask,
212 qic117_cmds[command].state);
213 }
214 TRACE_EXIT -EIO;
215 }
216 if (~status & QIC_STATUS_READY & qic117_cmds[command].mask) {
217 TRACE_ABORT(-EBUSY, ft_t_err, "Bad: still busy!");
218 }
219 }
220 TRACE_EXIT 0;
221}
222
223/* Issue a tape command:
224 */
225int ftape_command(qic117_cmd_t command)
226{
227 int result = 0;
228 static int level;
229 TRACE_FUN(ft_t_any);
230
231 if ((unsigned int)command > NR_ITEMS(qic117_cmds)) {
232 /* This is a bug we'll want to know about too.
233 */
234 TRACE_ABORT(-EIO, ft_t_bug, "bug - bad command: %d", command);
235 }
236 if (++level > 5) { /* This is a bug we'll want to know about. */
237 --level;
238 TRACE_ABORT(-EIO, ft_t_bug, "bug - recursion for command: %d",
239 command);
240 }
241 /* disable logging and restriction check for some commands,
242 * check all other commands that have a prescribed starting
243 * status.
244 */
245 if (diagnostic_mode) {
246 TRACE(ft_t_flow, "diagnostic command %d", command);
247 } else if (command == QIC_REPORT_DRIVE_STATUS ||
248 command == QIC_REPORT_NEXT_BIT) {
249 TRACE(ft_t_any, "%s", qic117_cmds[command].name);
250 } else {
251 TRACE_CATCH(ft_check_cmd_restrictions(command), --level);
252 }
253 /* Now all conditions are met or result was < 0.
254 */
255 result = ft_send_to_drive((unsigned int)command);
256 if (qic117_cmds[command].cmd_type == motion &&
257 command != QIC_LOGICAL_FORWARD && command != QIC_STOP_TAPE) {
258 ft_location.known = 0;
259 }
260 ftape_current_command = command;
261 --level;
262 TRACE_EXIT result;
263}
264
265/* Send a tape command parameter:
266 * Generates command # of step pulses.
267 * Skips tape-status call !
268 */
269int ftape_parameter(unsigned int parameter)
270{
271 TRACE_FUN(ft_t_any);
272
273 TRACE(ft_t_flow, "called with parameter = %d", parameter);
274 TRACE_EXIT ft_send_to_drive(parameter + 2);
275}
276
277/* Wait for the drive to get ready.
278 * timeout time in milli-seconds
279 * Returned status is valid if result != -EIO
280 *
281 * Should we allow to be killed by SIGINT? (^C)
282 * Would be nice at least for large timeouts.
283 */
284int ftape_ready_wait(unsigned int timeout, int *status)
285{
286 unsigned long t0;
287 unsigned int poll_delay;
288 int signal_retries;
289 TRACE_FUN(ft_t_any);
290
291 /* the following ** REALLY ** reduces the system load when
292 * e.g. one simply rewinds or retensions. The tape is slow
293 * anyway. It is really not necessary to detect error
294 * conditions with 1/10 seconds granularity
295 *
296 * On my AMD 133MHZ 486: 100 ms: 23% system load
297 * 1 sec: 5%
298 * 5 sec: 0.6%, yeah
299 */
300 if (timeout <= FT_SECOND) {
301 poll_delay = 100 * FT_MILLISECOND;
302 signal_retries = 20; /* two seconds */
303 } else if (timeout < 20 * FT_SECOND) {
304 TRACE(ft_t_flow, "setting poll delay to 1 second");
305 poll_delay = FT_SECOND;
306 signal_retries = 2; /* two seconds */
307 } else {
308 TRACE(ft_t_flow, "setting poll delay to 5 seconds");
309 poll_delay = 5 * FT_SECOND;
310 signal_retries = 1; /* five seconds */
311 }
312 for (;;) {
313 t0 = jiffies;
314 TRACE_CATCH(ftape_report_raw_drive_status(status),);
315 if (*status & QIC_STATUS_READY) {
316 TRACE_EXIT 0;
317 }
318 if (!signal_retries--) {
319 FT_SIGNAL_EXIT(_NEVER_BLOCK);
320 }
321 if ((int)timeout >= 0) {
322 /* this will fail when jiffies wraps around about
323 * once every year :-)
324 */
325 timeout -= ((jiffies - t0) * FT_SECOND) / HZ;
326 if (timeout <= 0) {
327 TRACE_ABORT(-ETIME, ft_t_err, "timeout");
328 }
329 ftape_sleep(poll_delay);
330 timeout -= poll_delay;
331 } else {
332 ftape_sleep(poll_delay);
333 }
334 }
335 TRACE_EXIT -ETIME;
336}
337
338/* Issue command and wait up to timeout milli seconds for drive ready
339 */
340int ftape_command_wait(qic117_cmd_t command, unsigned int timeout, int *status)
341{
342 int result;
343
344 /* Drive should be ready, issue command
345 */
346 result = ftape_command(command);
347 if (result >= 0) {
348 result = ftape_ready_wait(timeout, status);
349 }
350 return result;
351}
352
353static int ftape_parameter_wait(unsigned int parm, unsigned int timeout, int *status)
354{
355 int result;
356
357 /* Drive should be ready, issue command
358 */
359 result = ftape_parameter(parm);
360 if (result >= 0) {
361 result = ftape_ready_wait(timeout, status);
362 }
363 return result;
364}
365
366/*--------------------------------------------------------------------------
367 * Report operations
368 */
369
370/* Query the drive about its status. The command is sent and
371 result_length bits of status are returned (2 extra bits are read
372 for start and stop). */
373
374int ftape_report_operation(int *status,
375 qic117_cmd_t command,
376 int result_length)
377{
378 int i, st3;
379 unsigned int t0;
380 unsigned int dt;
381 TRACE_FUN(ft_t_any);
382
383 TRACE_CATCH(ftape_command(command),);
384 t0 = ftape_timestamp();
385 i = 0;
386 do {
387 ++i;
388 ftape_sleep(3 * FT_MILLISECOND); /* see remark below */
389 TRACE_CATCH(fdc_sense_drive_status(&st3),);
390 dt = ftape_timediff(t0, ftape_timestamp());
391 /* Ack should be asserted within Ttimout + Tack = 6 msec.
392 * Looks like some drives fail to do this so extend this
393 * period to 300 msec.
394 */
395 } while (!(st3 & ST3_TRACK_0) && dt < 300000);
396 if (!(st3 & ST3_TRACK_0)) {
397 TRACE(ft_t_err,
398 "No acknowledge after %u msec. (%i iter)", dt / 1000, i);
399 TRACE_ABORT(-EIO, ft_t_err, "timeout on Acknowledge");
400 }
401 /* dt may be larger than expected because of other tasks
402 * scheduled while we were sleeping.
403 */
404 if (i > 1 && dt > 6000) {
405 TRACE(ft_t_err, "Acknowledge after %u msec. (%i iter)",
406 dt / 1000, i);
407 }
408 *status = 0;
409 for (i = 0; i < result_length + 1; i++) {
410 TRACE_CATCH(ftape_command(QIC_REPORT_NEXT_BIT),);
411 TRACE_CATCH(fdc_sense_drive_status(&st3),);
412 if (i < result_length) {
413 *status |= ((st3 & ST3_TRACK_0) ? 1 : 0) << i;
414 } else if ((st3 & ST3_TRACK_0) == 0) {
415 TRACE_ABORT(-EIO, ft_t_err, "missing status stop bit");
416 }
417 }
418 /* this command will put track zero and index back into normal state */
419 (void)ftape_command(QIC_REPORT_NEXT_BIT);
420 TRACE_EXIT 0;
421}
422
423/* Report the current drive status. */
424
425int ftape_report_raw_drive_status(int *status)
426{
427 int result;
428 int count = 0;
429 TRACE_FUN(ft_t_any);
430
431 do {
432 result = ftape_report_operation(status,
433 QIC_REPORT_DRIVE_STATUS, 8);
434 } while (result < 0 && ++count <= 3);
435 if (result < 0) {
436 TRACE_ABORT(-EIO, ft_t_err,
437 "report_operation failed after %d trials", count);
438 }
439 if ((*status & 0xff) == 0xff) {
440 TRACE_ABORT(-EIO, ft_t_err,
441 "impossible drive status 0xff");
442 }
443 if (*status & QIC_STATUS_READY) {
444 ftape_current_command = QIC_NO_COMMAND; /* completed */
445 }
446 ft_last_status.status.drive_status = (__u8)(*status & 0xff);
447 TRACE_EXIT 0;
448}
449
450int ftape_report_drive_status(int *status)
451{
452 TRACE_FUN(ft_t_any);
453
454 TRACE_CATCH(ftape_report_raw_drive_status(status),);
455 if (*status & QIC_STATUS_NEW_CARTRIDGE ||
456 !(*status & QIC_STATUS_CARTRIDGE_PRESENT)) {
457 ft_failure = 1; /* will inhibit further operations */
458 TRACE_EXIT -EIO;
459 }
460 if (*status & QIC_STATUS_READY && *status & QIC_STATUS_ERROR) {
461 /* Let caller handle all errors */
462 TRACE_ABORT(1, ft_t_warn, "warning: error status set!");
463 }
464 TRACE_EXIT 0;
465}
466
467int ftape_report_error(unsigned int *error,
468 qic117_cmd_t *command, int report)
469{
470 static const ftape_error ftape_errors[] = QIC117_ERRORS;
471 int code;
472 TRACE_FUN(ft_t_any);
473
474 TRACE_CATCH(ftape_report_operation(&code, QIC_REPORT_ERROR_CODE, 16),);
475 *error = (unsigned int)(code & 0xff);
476 *command = (qic117_cmd_t)((code>>8)&0xff);
477 /* remember hardware status, maybe useful for status ioctls
478 */
479 ft_last_error.error.command = (__u8)*command;
480 ft_last_error.error.error = (__u8)*error;
481 if (!report) {
482 TRACE_EXIT 0;
483 }
484 if (*error == 0) {
485 TRACE_ABORT(0, ft_t_info, "No error");
486 }
487 TRACE(ft_t_info, "errorcode: %d", *error);
488 if (*error < NR_ITEMS(ftape_errors)) {
489 TRACE(ft_t_noise, "%sFatal ERROR:",
490 (ftape_errors[*error].fatal ? "" : "Non-"));
491 TRACE(ft_t_noise, "%s ...", ftape_errors[*error].message);
492 } else {
493 TRACE(ft_t_noise, "Unknown ERROR !");
494 }
495 if ((unsigned int)*command < NR_ITEMS(qic117_cmds) &&
496 qic117_cmds[*command].name != NULL) {
497 TRACE(ft_t_noise, "... caused by command \'%s\'",
498 qic117_cmds[*command].name);
499 } else {
500 TRACE(ft_t_noise, "... caused by unknown command %d",
501 *command);
502 }
503 TRACE_EXIT 0;
504}
505
506int ftape_report_configuration(qic_model *model,
507 unsigned int *rate,
508 int *qic_std,
509 int *tape_len)
510{
511 int result;
512 int config;
513 int status;
514 static const unsigned int qic_rates[ 4] = { 250, 2000, 500, 1000 };
515 TRACE_FUN(ft_t_any);
516
517 result = ftape_report_operation(&config,
518 QIC_REPORT_DRIVE_CONFIGURATION, 8);
519 if (result < 0) {
520 ft_last_status.status.drive_config = (__u8)0x00;
521 *model = prehistoric;
522 *rate = 500;
523 *qic_std = QIC_TAPE_QIC40;
524 *tape_len = 205;
525 TRACE_EXIT 0;
526 } else {
527 ft_last_status.status.drive_config = (__u8)(config & 0xff);
528 }
529 *rate = qic_rates[(config & QIC_CONFIG_RATE_MASK) >> QIC_CONFIG_RATE_SHIFT];
530 result = ftape_report_operation(&status, QIC_REPORT_TAPE_STATUS, 8);
531 if (result < 0) {
532 ft_last_status.status.tape_status = (__u8)0x00;
533 /* pre- QIC117 rev C spec. drive, QIC_CONFIG_80 bit is valid.
534 */
535 *qic_std = (config & QIC_CONFIG_80) ?
536 QIC_TAPE_QIC80 : QIC_TAPE_QIC40;
537 /* ?? how's about 425ft tapes? */
538 *tape_len = (config & QIC_CONFIG_LONG) ? 307 : 0;
539 *model = pre_qic117c;
540 result = 0;
541 } else {
542 ft_last_status.status.tape_status = (__u8)(status & 0xff);
543 *model = post_qic117b;
544 TRACE(ft_t_any, "report tape status result = %02x", status);
545 /* post- QIC117 rev C spec. drive, QIC_CONFIG_80 bit is
546 * invalid.
547 */
548 switch (status & QIC_TAPE_STD_MASK) {
549 case QIC_TAPE_QIC40:
550 case QIC_TAPE_QIC80:
551 case QIC_TAPE_QIC3020:
552 case QIC_TAPE_QIC3010:
553 *qic_std = status & QIC_TAPE_STD_MASK;
554 break;
555 default:
556 *qic_std = -1;
557 break;
558 }
559 switch (status & QIC_TAPE_LEN_MASK) {
560 case QIC_TAPE_205FT:
561 /* 205 or 425+ ft 550 Oe tape */
562 *tape_len = 0;
563 break;
564 case QIC_TAPE_307FT:
565 /* 307.5 ft 550 Oe Extended Length (XL) tape */
566 *tape_len = 307;
567 break;
568 case QIC_TAPE_VARIABLE:
569 /* Variable length 550 Oe tape */
570 *tape_len = 0;
571 break;
572 case QIC_TAPE_1100FT:
573 /* 1100 ft 550 Oe tape */
574 *tape_len = 1100;
575 break;
576 case QIC_TAPE_FLEX:
577 /* Variable length 900 Oe tape */
578 *tape_len = 0;
579 break;
580 default:
581 *tape_len = -1;
582 break;
583 }
584 if (*qic_std == -1 || *tape_len == -1) {
585 TRACE(ft_t_any,
586 "post qic-117b spec drive with unknown tape");
587 }
588 result = *tape_len == -1 ? -EIO : 0;
589 if (status & QIC_TAPE_WIDE) {
590 switch (*qic_std) {
591 case QIC_TAPE_QIC80:
592 TRACE(ft_t_info, "TR-1 tape detected");
593 break;
594 case QIC_TAPE_QIC3010:
595 TRACE(ft_t_info, "TR-2 tape detected");
596 break;
597 case QIC_TAPE_QIC3020:
598 TRACE(ft_t_info, "TR-3 tape detected");
599 break;
600 default:
601 TRACE(ft_t_warn,
602 "Unknown Travan tape type detected");
603 break;
604 }
605 }
606 }
607 TRACE_EXIT (result < 0) ? -EIO : 0;
608}
609
610static int ftape_report_rom_version(int *version)
611{
612
613 if (ftape_report_operation(version, QIC_REPORT_ROM_VERSION, 8) < 0) {
614 return -EIO;
615 } else {
616 return 0;
617 }
618}
619
620void ftape_report_vendor_id(unsigned int *id)
621{
622 int result;
623 TRACE_FUN(ft_t_any);
624
625 /* We'll try to get a vendor id from the drive. First
626 * according to the QIC-117 spec, a 16-bit id is requested.
627 * If that fails we'll try an 8-bit version, otherwise we'll
628 * try an undocumented query.
629 */
630 result = ftape_report_operation((int *) id, QIC_REPORT_VENDOR_ID, 16);
631 if (result < 0) {
632 result = ftape_report_operation((int *) id,
633 QIC_REPORT_VENDOR_ID, 8);
634 if (result < 0) {
635 /* The following is an undocumented call found
636 * in the CMS code.
637 */
638 result = ftape_report_operation((int *) id, 24, 8);
639 if (result < 0) {
640 *id = UNKNOWN_VENDOR;
641 } else {
642 TRACE(ft_t_noise, "got old 8 bit id: %04x",
643 *id);
644 *id |= 0x20000;
645 }
646 } else {
647 TRACE(ft_t_noise, "got 8 bit id: %04x", *id);
648 *id |= 0x10000;
649 }
650 } else {
651 TRACE(ft_t_noise, "got 16 bit id: %04x", *id);
652 }
653 if (*id == 0x0047) {
654 int version;
655 int sign;
656
657 if (ftape_report_rom_version(&version) < 0) {
658 TRACE(ft_t_bug, "report rom version failed");
659 TRACE_EXIT;
660 }
661 TRACE(ft_t_noise, "CMS rom version: %d", version);
662 ftape_command(QIC_ENTER_DIAGNOSTIC_1);
663 ftape_command(QIC_ENTER_DIAGNOSTIC_1);
664 diagnostic_mode = 1;
665 if (ftape_report_operation(&sign, 9, 8) < 0) {
666 unsigned int error;
667 qic117_cmd_t command;
668
669 ftape_report_error(&error, &command, 1);
670 ftape_command(QIC_ENTER_PRIMARY_MODE);
671 diagnostic_mode = 0;
672 TRACE_EXIT; /* failure ! */
673 } else {
674 TRACE(ft_t_noise, "CMS signature: %02x", sign);
675 }
676 if (sign == 0xa5) {
677 result = ftape_report_operation(&sign, 37, 8);
678 if (result < 0) {
679 if (version >= 63) {
680 *id = 0x8880;
681 TRACE(ft_t_noise,
682 "This is an Iomega drive !");
683 } else {
684 *id = 0x0047;
685 TRACE(ft_t_noise,
686 "This is a real CMS drive !");
687 }
688 } else {
689 *id = 0x0047;
690 TRACE(ft_t_noise, "CMS status: %d", sign);
691 }
692 } else {
693 *id = UNKNOWN_VENDOR;
694 }
695 ftape_command(QIC_ENTER_PRIMARY_MODE);
696 diagnostic_mode = 0;
697 }
698 TRACE_EXIT;
699}
700
701static int qic_rate_code(unsigned int rate)
702{
703 switch (rate) {
704 case 250:
705 return QIC_CONFIG_RATE_250;
706 case 500:
707 return QIC_CONFIG_RATE_500;
708 case 1000:
709 return QIC_CONFIG_RATE_1000;
710 case 2000:
711 return QIC_CONFIG_RATE_2000;
712 default:
713 return QIC_CONFIG_RATE_500;
714 }
715}
716
717static int ftape_set_rate_test(unsigned int *max_rate)
718{
719 unsigned int error;
720 qic117_cmd_t command;
721 int status;
722 int supported = 0;
723 TRACE_FUN(ft_t_any);
724
725 /* Check if the drive does support the select rate command
726 * by testing all different settings. If any one is accepted
727 * we assume the command is supported, else not.
728 */
729 for (*max_rate = 2000; *max_rate >= 250; *max_rate /= 2) {
730 if (ftape_command(QIC_SELECT_RATE) < 0) {
731 continue;
732 }
733 if (ftape_parameter_wait(qic_rate_code(*max_rate),
734 1 * FT_SECOND, &status) < 0) {
735 continue;
736 }
737 if (status & QIC_STATUS_ERROR) {
738 ftape_report_error(&error, &command, 0);
739 continue;
740 }
741 supported = 1; /* did accept a request */
742 break;
743 }
744 TRACE(ft_t_noise, "Select Rate command is%s supported",
745 supported ? "" : " not");
746 TRACE_EXIT supported;
747}
748
749int ftape_set_data_rate(unsigned int new_rate /* Kbps */, unsigned int qic_std)
750{
751 int status;
752 int result = 0;
753 unsigned int data_rate = new_rate;
754 static int supported;
755 int rate_changed = 0;
756 qic_model dummy_model;
757 unsigned int dummy_qic_std, dummy_tape_len;
758 TRACE_FUN(ft_t_any);
759
760 if (ft_drive_max_rate == 0) { /* first time */
761 supported = ftape_set_rate_test(&ft_drive_max_rate);
762 }
763 if (supported) {
764 ftape_command(QIC_SELECT_RATE);
765 result = ftape_parameter_wait(qic_rate_code(new_rate),
766 1 * FT_SECOND, &status);
767 if (result >= 0 && !(status & QIC_STATUS_ERROR)) {
768 rate_changed = 1;
769 }
770 }
771 TRACE_CATCH(result = ftape_report_configuration(&dummy_model,
772 &data_rate,
773 &dummy_qic_std,
774 &dummy_tape_len),);
775 if (data_rate != new_rate) {
776 if (!supported) {
777 TRACE(ft_t_warn, "Rate change not supported!");
778 } else if (rate_changed) {
779 TRACE(ft_t_warn, "Requested: %d, got %d",
780 new_rate, data_rate);
781 } else {
782 TRACE(ft_t_warn, "Rate change failed!");
783 }
784 result = -EINVAL;
785 }
786 /*
787 * Set data rate and write precompensation as specified:
788 *
789 * | QIC-40/80 | QIC-3010/3020
790 * rate | precomp | precomp
791 * ----------+-------------+--------------
792 * 250 Kbps. | 250 ns. | 0 ns.
793 * 500 Kbps. | 125 ns. | 0 ns.
794 * 1 Mbps. | 42 ns. | 0 ns.
795 * 2 Mbps | N/A | 0 ns.
796 */
797 if ((qic_std == QIC_TAPE_QIC40 && data_rate > 500) ||
798 (qic_std == QIC_TAPE_QIC80 && data_rate > 1000)) {
799 TRACE_ABORT(-EINVAL,
800 ft_t_warn, "Datarate too high for QIC-mode");
801 }
802 TRACE_CATCH(fdc_set_data_rate(data_rate),_res = -EINVAL);
803 ft_data_rate = data_rate;
804 if (qic_std == QIC_TAPE_QIC40 || qic_std == QIC_TAPE_QIC80) {
805 switch (data_rate) {
806 case 250:
807 fdc_set_write_precomp(250);
808 break;
809 default:
810 case 500:
811 fdc_set_write_precomp(125);
812 break;
813 case 1000:
814 fdc_set_write_precomp(42);
815 break;
816 }
817 } else {
818 fdc_set_write_precomp(0);
819 }
820 TRACE_EXIT result;
821}
822
823/* The next two functions are used to cope with excessive overrun errors
824 */
825int ftape_increase_threshold(void)
826{
827 TRACE_FUN(ft_t_flow);
828
829 if (fdc.type < i82077 || ft_fdc_threshold >= 12) {
830 TRACE_ABORT(-EIO, ft_t_err, "cannot increase fifo threshold");
831 }
832 if (fdc_fifo_threshold(++ft_fdc_threshold, NULL, NULL, NULL) < 0) {
833 TRACE(ft_t_err, "cannot increase fifo threshold");
834 ft_fdc_threshold --;
835 fdc_reset();
836 }
837 TRACE(ft_t_info, "New FIFO threshold: %d", ft_fdc_threshold);
838 TRACE_EXIT 0;
839}
840
841int ftape_half_data_rate(void)
842{
843 if (ft_data_rate < 500) {
844 return -1;
845 }
846 if (ftape_set_data_rate(ft_data_rate / 2, ft_qic_std) < 0) {
847 return -EIO;
848 }
849 ftape_calc_timeouts(ft_qic_std, ft_data_rate, ftape_tape_len);
850 return 0;
851}
852
853/* Seek the head to the specified track.
854 */
855int ftape_seek_head_to_track(unsigned int track)
856{
857 int status;
858 TRACE_FUN(ft_t_any);
859
860 ft_location.track = -1; /* remains set in case of error */
861 if (track >= ft_tracks_per_tape) {
862 TRACE_ABORT(-EINVAL, ft_t_bug, "track out of bounds");
863 }
864 TRACE(ft_t_flow, "seeking track %d", track);
865 TRACE_CATCH(ftape_command(QIC_SEEK_HEAD_TO_TRACK),);
866 TRACE_CATCH(ftape_parameter_wait(track, ftape_timeout.head_seek,
867 &status),);
868 ft_location.track = track;
869 ftape_might_be_off_track = 0;
870 TRACE_EXIT 0;
871}
872
873int ftape_wakeup_drive(wake_up_types method)
874{
875 int status;
876 int motor_on = 0;
877 TRACE_FUN(ft_t_any);
878
879 switch (method) {
880 case wake_up_colorado:
881 TRACE_CATCH(ftape_command(QIC_PHANTOM_SELECT),);
882 TRACE_CATCH(ftape_parameter(0 /* ft_drive_sel ?? */),);
883 break;
884 case wake_up_mountain:
885 TRACE_CATCH(ftape_command(QIC_SOFT_SELECT),);
886 ftape_sleep(FT_MILLISECOND); /* NEEDED */
887 TRACE_CATCH(ftape_parameter(18),);
888 break;
889 case wake_up_insight:
890 ftape_sleep(100 * FT_MILLISECOND);
891 motor_on = 1;
892 fdc_motor(motor_on); /* enable is done by motor-on */
893 case no_wake_up:
894 break;
895 default:
896 TRACE_EXIT -ENODEV; /* unknown wakeup method */
897 break;
898 }
899 /* If wakeup succeeded we shouldn't get an error here..
900 */
901 TRACE_CATCH(ftape_report_raw_drive_status(&status),
902 if (motor_on) {
903 fdc_motor(0);
904 });
905 TRACE_EXIT 0;
906}
907
908int ftape_put_drive_to_sleep(wake_up_types method)
909{
910 TRACE_FUN(ft_t_any);
911
912 switch (method) {
913 case wake_up_colorado:
914 TRACE_CATCH(ftape_command(QIC_PHANTOM_DESELECT),);
915 break;
916 case wake_up_mountain:
917 TRACE_CATCH(ftape_command(QIC_SOFT_DESELECT),);
918 break;
919 case wake_up_insight:
920 fdc_motor(0); /* enable is done by motor-on */
921 case no_wake_up: /* no wakeup / no sleep ! */
922 break;
923 default:
924 TRACE_EXIT -ENODEV; /* unknown wakeup method */
925 }
926 TRACE_EXIT 0;
927}
928
929int ftape_reset_drive(void)
930{
931 int result = 0;
932 int status;
933 unsigned int err_code;
934 qic117_cmd_t err_command;
935 int i;
936 TRACE_FUN(ft_t_any);
937
938 /* We want to re-establish contact with our drive. Fire a
939 * number of reset commands (single step pulses) and pray for
940 * success.
941 */
942 for (i = 0; i < 2; ++i) {
943 TRACE(ft_t_flow, "Resetting fdc");
944 fdc_reset();
945 ftape_sleep(10 * FT_MILLISECOND);
946 TRACE(ft_t_flow, "Reset command to drive");
947 result = ftape_command(QIC_RESET);
948 if (result == 0) {
949 ftape_sleep(1 * FT_SECOND); /* drive not
950 * accessible
951 * during 1 second
952 */
953 TRACE(ft_t_flow, "Re-selecting drive");
954
955 /* Strange, the QIC-117 specs don't mention
956 * this but the drive gets deselected after a
957 * soft reset ! So we need to enable it
958 * again.
959 */
960 if (ftape_wakeup_drive(ft_drive_type.wake_up) < 0) {
961 TRACE(ft_t_err, "Wakeup failed !");
962 }
963 TRACE(ft_t_flow, "Waiting until drive gets ready");
964 result= ftape_ready_wait(ftape_timeout.reset, &status);
965 if (result == 0 && (status & QIC_STATUS_ERROR)) {
966 result = ftape_report_error(&err_code,
967 &err_command, 1);
968 if (result == 0 && err_code == 27) {
969 /* Okay, drive saw reset
970 * command and responded as it
971 * should
972 */
973 break;
974 } else {
975 result = -EIO;
976 }
977 } else {
978 result = -EIO;
979 }
980 }
981 FT_SIGNAL_EXIT(_DONT_BLOCK);
982 }
983 if (result != 0) {
984 TRACE(ft_t_err, "General failure to reset tape drive");
985 } else {
986 /* Restore correct settings: keep original rate
987 */
988 ftape_set_data_rate(ft_data_rate, ft_qic_std);
989 }
990 ftape_init_drive_needed = 1;
991 TRACE_EXIT result;
992}
diff --git a/drivers/char/ftape/lowlevel/ftape-io.h b/drivers/char/ftape/lowlevel/ftape-io.h
deleted file mode 100644
index 26a7baad8717..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-io.h
+++ /dev/null
@@ -1,90 +0,0 @@
1#ifndef _FTAPE_IO_H
2#define _FTAPE_IO_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-io.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:18 $
26 *
27 * This file contains definitions for the glue part of the
28 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
29 */
30
31#include <linux/qic117.h>
32#include <linux/ftape-vendors.h>
33
34typedef struct {
35 unsigned int seek;
36 unsigned int reset;
37 unsigned int rewind;
38 unsigned int head_seek;
39 unsigned int stop;
40 unsigned int pause;
41} ft_timeout_table;
42
43typedef enum {
44 prehistoric, pre_qic117c, post_qic117b, post_qic117d
45} qic_model;
46
47/*
48 * ftape-io.c defined global vars.
49 */
50extern ft_timeout_table ftape_timeout;
51extern unsigned int ftape_tape_len;
52extern volatile qic117_cmd_t ftape_current_command;
53extern const struct qic117_command_table qic117_cmds[];
54extern int ftape_might_be_off_track;
55
56/*
57 * ftape-io.c defined global functions.
58 */
59extern void ftape_udelay(unsigned int usecs);
60extern void ftape_udelay_calibrate(void);
61extern void ftape_sleep(unsigned int time);
62extern void ftape_report_vendor_id(unsigned int *id);
63extern int ftape_command(qic117_cmd_t command);
64extern int ftape_command_wait(qic117_cmd_t command,
65 unsigned int timeout,
66 int *status);
67extern int ftape_parameter(unsigned int parameter);
68extern int ftape_report_operation(int *status,
69 qic117_cmd_t command,
70 int result_length);
71extern int ftape_report_configuration(qic_model *model,
72 unsigned int *rate,
73 int *qic_std,
74 int *tape_len);
75extern int ftape_report_drive_status(int *status);
76extern int ftape_report_raw_drive_status(int *status);
77extern int ftape_report_status(int *status);
78extern int ftape_ready_wait(unsigned int timeout, int *status);
79extern int ftape_seek_head_to_track(unsigned int track);
80extern int ftape_set_data_rate(unsigned int new_rate, unsigned int qic_std);
81extern int ftape_report_error(unsigned int *error,
82 qic117_cmd_t *command,
83 int report);
84extern int ftape_reset_drive(void);
85extern int ftape_put_drive_to_sleep(wake_up_types method);
86extern int ftape_wakeup_drive(wake_up_types method);
87extern int ftape_increase_threshold(void);
88extern int ftape_half_data_rate(void);
89
90#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-proc.c b/drivers/char/ftape/lowlevel/ftape-proc.c
deleted file mode 100644
index e805b15e0a12..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-proc.c
+++ /dev/null
@@ -1,214 +0,0 @@
1/*
2 * Copyright (C) 1997 Claus-Justus Heine
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-proc.c,v $
20 * $Revision: 1.11 $
21 * $Date: 1997/10/24 14:47:37 $
22 *
23 * This file contains the procfs interface for the
24 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
25
26 * Old code removed, switched to dynamic proc entry.
27 */
28
29
30#if defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS)
31
32#include <linux/proc_fs.h>
33
34#include <linux/ftape.h>
35#include <linux/init.h>
36#include <linux/qic117.h>
37
38#include "../lowlevel/ftape-io.h"
39#include "../lowlevel/ftape-ctl.h"
40#include "../lowlevel/ftape-proc.h"
41#include "../lowlevel/ftape-tracing.h"
42
43static size_t get_driver_info(char *buf)
44{
45 const char *debug_level[] = { "bugs" ,
46 "errors",
47 "warnings",
48 "informational",
49 "noisy",
50 "program flow",
51 "fdc and dma",
52 "data flow",
53 "anything" };
54
55 return sprintf(buf,
56 "version : %s\n"
57 "used data rate: %d kbit/sec\n"
58 "dma memory : %d kb\n"
59 "debug messages: %s\n",
60 FTAPE_VERSION,
61 ft_data_rate,
62 FT_BUFF_SIZE * ft_nr_buffers >> 10,
63 debug_level[TRACE_LEVEL]);
64}
65
66static size_t get_tapedrive_info(char *buf)
67{
68 return sprintf(buf,
69 "vendor id : 0x%04x\n"
70 "drive name: %s\n"
71 "wind speed: %d ips\n"
72 "wakeup : %s\n"
73 "max. rate : %d kbit/sec\n",
74 ft_drive_type.vendor_id,
75 ft_drive_type.name,
76 ft_drive_type.speed,
77 ((ft_drive_type.wake_up == no_wake_up)
78 ? "No wakeup needed" :
79 ((ft_drive_type.wake_up == wake_up_colorado)
80 ? "Colorado" :
81 ((ft_drive_type.wake_up == wake_up_mountain)
82 ? "Mountain" :
83 ((ft_drive_type.wake_up == wake_up_insight)
84 ? "Motor on" :
85 "Unknown")))),
86 ft_drive_max_rate);
87}
88
89static size_t get_cartridge_info(char *buf)
90{
91 if (ftape_init_drive_needed) {
92 return sprintf(buf, "uninitialized\n");
93 }
94 if (ft_no_tape) {
95 return sprintf(buf, "no cartridge inserted\n");
96 }
97 return sprintf(buf,
98 "segments : %5d\n"
99 "tracks : %5d\n"
100 "length : %5dft\n"
101 "formatted : %3s\n"
102 "writable : %3s\n"
103 "QIC spec. : QIC-%s\n"
104 "fmt-code : %1d\n",
105 ft_segments_per_track,
106 ft_tracks_per_tape,
107 ftape_tape_len,
108 (ft_formatted == 1) ? "yes" : "no",
109 (ft_write_protected == 1) ? "no" : "yes",
110 ((ft_qic_std == QIC_TAPE_QIC40) ? "40" :
111 ((ft_qic_std == QIC_TAPE_QIC80) ? "80" :
112 ((ft_qic_std == QIC_TAPE_QIC3010) ? "3010" :
113 ((ft_qic_std == QIC_TAPE_QIC3020) ? "3020" :
114 "???")))),
115 ft_format_code);
116}
117
118static size_t get_controller_info(char *buf)
119{
120 const char *fdc_name[] = { "no fdc",
121 "i8272",
122 "i82077",
123 "i82077AA",
124 "Colorado FC-10 or FC-20",
125 "i82078",
126 "i82078_1" };
127
128 return sprintf(buf,
129 "FDC type : %s\n"
130 "FDC base : 0x%03x\n"
131 "FDC irq : %d\n"
132 "FDC dma : %d\n"
133 "FDC thr. : %d\n"
134 "max. rate : %d kbit/sec\n",
135 ft_mach2 ? "Mountain MACH-2" : fdc_name[fdc.type],
136 fdc.sra, fdc.irq, fdc.dma,
137 ft_fdc_threshold, ft_fdc_max_rate);
138}
139
140static size_t get_history_info(char *buf)
141{
142 size_t len;
143
144 len = sprintf(buf,
145 "\nFDC isr statistics\n"
146 " id_am_errors : %3d\n"
147 " id_crc_errors : %3d\n"
148 " data_am_errors : %3d\n"
149 " data_crc_errors : %3d\n"
150 " overrun_errors : %3d\n"
151 " no_data_errors : %3d\n"
152 " retries : %3d\n",
153 ft_history.id_am_errors, ft_history.id_crc_errors,
154 ft_history.data_am_errors, ft_history.data_crc_errors,
155 ft_history.overrun_errors, ft_history.no_data_errors,
156 ft_history.retries);
157 len += sprintf(buf + len,
158 "\nECC statistics\n"
159 " crc_errors : %3d\n"
160 " crc_failures : %3d\n"
161 " ecc_failures : %3d\n"
162 " sectors corrected: %3d\n",
163 ft_history.crc_errors, ft_history.crc_failures,
164 ft_history.ecc_failures, ft_history.corrected);
165 len += sprintf(buf + len,
166 "\ntape quality statistics\n"
167 " media defects : %3d\n",
168 ft_history.defects);
169 len += sprintf(buf + len,
170 "\ntape motion statistics\n"
171 " repositions : %3d\n",
172 ft_history.rewinds);
173 return len;
174}
175
176static int ftape_read_proc(char *page, char **start, off_t off,
177 int count, int *eof, void *data)
178{
179 char *ptr = page;
180 size_t len;
181
182 ptr += sprintf(ptr, "Kernel Driver\n\n");
183 ptr += get_driver_info(ptr);
184 ptr += sprintf(ptr, "\nTape Drive\n\n");
185 ptr += get_tapedrive_info(ptr);
186 ptr += sprintf(ptr, "\nFDC Controller\n\n");
187 ptr += get_controller_info(ptr);
188 ptr += sprintf(ptr, "\nTape Cartridge\n\n");
189 ptr += get_cartridge_info(ptr);
190 ptr += sprintf(ptr, "\nHistory Record\n\n");
191 ptr += get_history_info(ptr);
192
193 len = strlen(page);
194 *start = NULL;
195 if (off+count >= len) {
196 *eof = 1;
197 } else {
198 *eof = 0;
199 }
200 return len;
201}
202
203int __init ftape_proc_init(void)
204{
205 return create_proc_read_entry("ftape", 0, &proc_root,
206 ftape_read_proc, NULL) != NULL;
207}
208
209void ftape_proc_destroy(void)
210{
211 remove_proc_entry("ftape", &proc_root);
212}
213
214#endif /* defined(CONFIG_PROC_FS) && defined(CONFIG_FT_PROC_FS) */
diff --git a/drivers/char/ftape/lowlevel/ftape-proc.h b/drivers/char/ftape/lowlevel/ftape-proc.h
deleted file mode 100644
index 264dfcc1d22d..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-proc.h
+++ /dev/null
@@ -1,35 +0,0 @@
1#ifndef _FTAPE_PROC_H
2#define _FTAPE_PROC_H
3
4/*
5 * Copyright (C) 1997 Claus-Justus Heine
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-proc.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:18:20 $
25 *
26 * This file contains definitions for the procfs interface of the
27 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
28 */
29
30#include <linux/proc_fs.h>
31
32extern int ftape_proc_init(void);
33extern void ftape_proc_destroy(void);
34
35#endif
diff --git a/drivers/char/ftape/lowlevel/ftape-read.c b/drivers/char/ftape/lowlevel/ftape-read.c
deleted file mode 100644
index d967d8cd86dc..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-read.c
+++ /dev/null
@@ -1,621 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-read.c,v $
21 * $Revision: 1.6 $
22 * $Date: 1997/10/21 14:39:22 $
23 *
24 * This file contains the reading code
25 * for the QIC-117 floppy-tape driver for Linux.
26 *
27 */
28
29#include <linux/string.h>
30#include <linux/errno.h>
31#include <linux/mm.h>
32
33#include <linux/ftape.h>
34#include <linux/qic117.h>
35#include "../lowlevel/ftape-tracing.h"
36#include "../lowlevel/ftape-read.h"
37#include "../lowlevel/ftape-io.h"
38#include "../lowlevel/ftape-ctl.h"
39#include "../lowlevel/ftape-rw.h"
40#include "../lowlevel/ftape-write.h"
41#include "../lowlevel/ftape-ecc.h"
42#include "../lowlevel/ftape-bsm.h"
43
44/* Global vars.
45 */
46
47/* Local vars.
48 */
49
50void ftape_zap_read_buffers(void)
51{
52 int i;
53
54 for (i = 0; i < ft_nr_buffers; ++i) {
55/* changed to "fit" with dynamic allocation of tape_buffer. --khp */
56 ft_buffer[i]->status = waiting;
57 ft_buffer[i]->bytes = 0;
58 ft_buffer[i]->skip = 0;
59 ft_buffer[i]->retry = 0;
60 }
61/* ftape_reset_buffer(); */
62}
63
64static SectorMap convert_sector_map(buffer_struct * buff)
65{
66 int i = 0;
67 SectorMap bad_map = ftape_get_bad_sector_entry(buff->segment_id);
68 SectorMap src_map = buff->soft_error_map | buff->hard_error_map;
69 SectorMap dst_map = 0;
70 TRACE_FUN(ft_t_any);
71
72 if (bad_map || src_map) {
73 TRACE(ft_t_flow, "bad_map = 0x%08lx", (long) bad_map);
74 TRACE(ft_t_flow, "src_map = 0x%08lx", (long) src_map);
75 }
76 while (bad_map) {
77 while ((bad_map & 1) == 0) {
78 if (src_map & 1) {
79 dst_map |= (1 << i);
80 }
81 src_map >>= 1;
82 bad_map >>= 1;
83 ++i;
84 }
85 /* (bad_map & 1) == 1 */
86 src_map >>= 1;
87 bad_map >>= 1;
88 }
89 if (src_map) {
90 dst_map |= (src_map << i);
91 }
92 if (dst_map) {
93 TRACE(ft_t_flow, "dst_map = 0x%08lx", (long) dst_map);
94 }
95 TRACE_EXIT dst_map;
96}
97
98static int correct_and_copy_fraction(buffer_struct *buff, __u8 * destination,
99 int start, int size)
100{
101 struct memory_segment mseg;
102 int result;
103 SectorMap read_bad;
104 TRACE_FUN(ft_t_any);
105
106 mseg.read_bad = convert_sector_map(buff);
107 mseg.marked_bad = 0; /* not used... */
108 mseg.blocks = buff->bytes / FT_SECTOR_SIZE;
109 mseg.data = buff->address;
110 /* If there are no data sectors we can skip this segment.
111 */
112 if (mseg.blocks <= 3) {
113 TRACE_ABORT(0, ft_t_noise, "empty segment");
114 }
115 read_bad = mseg.read_bad;
116 ft_history.crc_errors += count_ones(read_bad);
117 result = ftape_ecc_correct_data(&mseg);
118 if (read_bad != 0 || mseg.corrected != 0) {
119 TRACE(ft_t_noise, "crc error map: 0x%08lx", (unsigned long)read_bad);
120 TRACE(ft_t_noise, "corrected map: 0x%08lx", (unsigned long)mseg.corrected);
121 ft_history.corrected += count_ones(mseg.corrected);
122 }
123 if (result == ECC_CORRECTED || result == ECC_OK) {
124 if (result == ECC_CORRECTED) {
125 TRACE(ft_t_info, "ecc corrected segment: %d", buff->segment_id);
126 }
127 if(start < 0) {
128 start= 0;
129 }
130 if((start+size) > ((mseg.blocks - 3) * FT_SECTOR_SIZE)) {
131 size = (mseg.blocks - 3) * FT_SECTOR_SIZE - start;
132 }
133 if (size < 0) {
134 size= 0;
135 }
136 if(size > 0) {
137 memcpy(destination + start, mseg.data + start, size);
138 }
139 if ((read_bad ^ mseg.corrected) & mseg.corrected) {
140 /* sectors corrected without crc errors set */
141 ft_history.crc_failures++;
142 }
143 TRACE_EXIT size; /* (mseg.blocks - 3) * FT_SECTOR_SIZE; */
144 } else {
145 ft_history.ecc_failures++;
146 TRACE_ABORT(-EAGAIN,
147 ft_t_err, "ecc failure on segment %d",
148 buff->segment_id);
149 }
150 TRACE_EXIT 0;
151}
152
153/* Read given segment into buffer at address.
154 */
155int ftape_read_segment_fraction(const int segment_id,
156 void *address,
157 const ft_read_mode_t read_mode,
158 const int start,
159 const int size)
160{
161 int result = 0;
162 int retry = 0;
163 int bytes_read = 0;
164 int read_done = 0;
165 TRACE_FUN(ft_t_flow);
166
167 ft_history.used |= 1;
168 TRACE(ft_t_data_flow, "segment_id = %d", segment_id);
169 if (ft_driver_state != reading) {
170 TRACE(ft_t_noise, "calling ftape_abort_operation");
171 TRACE_CATCH(ftape_abort_operation(),);
172 ftape_set_state(reading);
173 }
174 for(;;) {
175 buffer_struct *tail;
176 /* Allow escape from this loop on signal !
177 */
178 FT_SIGNAL_EXIT(_DONT_BLOCK);
179 /* Search all full buffers for the first matching the
180 * wanted segment. Clear other buffers on the fly.
181 */
182 tail = ftape_get_buffer(ft_queue_tail);
183 while (!read_done && tail->status == done) {
184 /* Allow escape from this loop on signal !
185 */
186 FT_SIGNAL_EXIT(_DONT_BLOCK);
187 if (tail->segment_id == segment_id) {
188 /* If out buffer is already full,
189 * return its contents.
190 */
191 TRACE(ft_t_flow, "found segment in cache: %d",
192 segment_id);
193 if (tail->deleted) {
194 /* Return a value that
195 * read_header_segment
196 * understands. As this
197 * should only occur when
198 * searching for the header
199 * segments it shouldn't be
200 * misinterpreted elsewhere.
201 */
202 TRACE_EXIT 0;
203 }
204 result = correct_and_copy_fraction(
205 tail,
206 address,
207 start,
208 size);
209 TRACE(ft_t_flow, "segment contains (bytes): %d",
210 result);
211 if (result < 0) {
212 if (result != -EAGAIN) {
213 TRACE_EXIT result;
214 }
215 /* keep read_done == 0, will
216 * trigger
217 * ftape_abort_operation
218 * because reading wrong
219 * segment.
220 */
221 TRACE(ft_t_err, "ecc failed, retry");
222 ++retry;
223 } else {
224 read_done = 1;
225 bytes_read = result;
226 }
227 } else {
228 TRACE(ft_t_flow,"zapping segment in cache: %d",
229 tail->segment_id);
230 }
231 tail->status = waiting;
232 tail = ftape_next_buffer(ft_queue_tail);
233 }
234 if (!read_done && tail->status == reading) {
235 if (tail->segment_id == segment_id) {
236 switch(ftape_wait_segment(reading)) {
237 case 0:
238 break;
239 case -EINTR:
240 TRACE_ABORT(-EINTR, ft_t_warn,
241 "interrupted by "
242 "non-blockable signal");
243 break;
244 default:
245 TRACE(ft_t_noise,
246 "wait_segment failed");
247 ftape_abort_operation();
248 ftape_set_state(reading);
249 break;
250 }
251 } else {
252 /* We're reading the wrong segment,
253 * stop runner.
254 */
255 TRACE(ft_t_noise, "reading wrong segment");
256 ftape_abort_operation();
257 ftape_set_state(reading);
258 }
259 }
260 /* should runner stop ?
261 */
262 if (ft_runner_status == aborting) {
263 buffer_struct *head = ftape_get_buffer(ft_queue_head);
264 switch(head->status) {
265 case error:
266 ft_history.defects +=
267 count_ones(head->hard_error_map);
268 case reading:
269 head->status = waiting;
270 break;
271 default:
272 break;
273 }
274 TRACE_CATCH(ftape_dumb_stop(),);
275 } else {
276 /* If just passed last segment on tape: wait
277 * for BOT or EOT mark. Sets ft_runner_status to
278 * idle if at lEOT and successful
279 */
280 TRACE_CATCH(ftape_handle_logical_eot(),);
281 }
282 /* If we got a segment: quit, or else retry up to limit.
283 *
284 * If segment to read is empty, do not start runner for it,
285 * but wait for next read call.
286 */
287 if (read_done ||
288 ftape_get_bad_sector_entry(segment_id) == EMPTY_SEGMENT ) {
289 /* bytes_read = 0; should still be zero */
290 TRACE_EXIT bytes_read;
291
292 }
293 if (retry > FT_RETRIES_ON_ECC_ERROR) {
294 ft_history.defects++;
295 TRACE_ABORT(-ENODATA, ft_t_err,
296 "too many retries on ecc failure");
297 }
298 /* Now at least one buffer is empty !
299 * Restart runner & tape if needed.
300 */
301 TRACE(ft_t_any, "head: %d, tail: %d, ft_runner_status: %d",
302 ftape_buffer_id(ft_queue_head),
303 ftape_buffer_id(ft_queue_tail),
304 ft_runner_status);
305 TRACE(ft_t_any, "buffer[].status, [head]: %d, [tail]: %d",
306 ftape_get_buffer(ft_queue_head)->status,
307 ftape_get_buffer(ft_queue_tail)->status);
308 tail = ftape_get_buffer(ft_queue_tail);
309 if (tail->status == waiting) {
310 buffer_struct *head = ftape_get_buffer(ft_queue_head);
311
312 ftape_setup_new_segment(head, segment_id, -1);
313 if (read_mode == FT_RD_SINGLE) {
314 /* disable read-ahead */
315 head->next_segment = 0;
316 }
317 ftape_calc_next_cluster(head);
318 if (ft_runner_status == idle) {
319 result = ftape_start_tape(segment_id,
320 head->sector_offset);
321 if (result < 0) {
322 TRACE_ABORT(result, ft_t_err, "Error: "
323 "segment %d unreachable",
324 segment_id);
325 }
326 }
327 head->status = reading;
328 fdc_setup_read_write(head, FDC_READ);
329 }
330 }
331 /* not reached */
332 TRACE_EXIT -EIO;
333}
334
335int ftape_read_header_segment(__u8 *address)
336{
337 int result;
338 int header_segment;
339 int first_failed = 0;
340 int status;
341 TRACE_FUN(ft_t_flow);
342
343 ft_used_header_segment = -1;
344 TRACE_CATCH(ftape_report_drive_status(&status),);
345 TRACE(ft_t_flow, "reading...");
346 /* We're looking for the first header segment.
347 * A header segment cannot contain bad sectors, therefor at the
348 * tape start, segments with bad sectors are (according to QIC-40/80)
349 * written with deleted data marks and must be skipped.
350 */
351 memset(address, '\0', (FT_SECTORS_PER_SEGMENT - 3) * FT_SECTOR_SIZE);
352 result = 0;
353#define HEADER_SEGMENT_BOUNDARY 68 /* why not 42? */
354 for (header_segment = 0;
355 header_segment < HEADER_SEGMENT_BOUNDARY && result == 0;
356 ++header_segment) {
357 /* Set no read-ahead, the isr will force read-ahead whenever
358 * it encounters deleted data !
359 */
360 result = ftape_read_segment(header_segment,
361 address,
362 FT_RD_SINGLE);
363 if (result < 0 && !first_failed) {
364 TRACE(ft_t_err, "header segment damaged, trying backup");
365 first_failed = 1;
366 result = 0; /* force read of next (backup) segment */
367 }
368 }
369 if (result < 0 || header_segment >= HEADER_SEGMENT_BOUNDARY) {
370 TRACE_ABORT(-EIO, ft_t_err,
371 "no readable header segment found");
372 }
373 TRACE_CATCH(ftape_abort_operation(),);
374 ft_used_header_segment = header_segment;
375 result = ftape_decode_header_segment(address);
376 TRACE_EXIT result;
377}
378
379int ftape_decode_header_segment(__u8 *address)
380{
381 unsigned int max_floppy_side;
382 unsigned int max_floppy_track;
383 unsigned int max_floppy_sector;
384 unsigned int new_tape_len;
385 TRACE_FUN(ft_t_flow);
386
387 if (GET4(address, FT_SIGNATURE) == FT_D2G_MAGIC) {
388 /* Ditto 2GB header segment. They encrypt the bad sector map.
389 * We decrypt it and store them in normal format.
390 * I hope this is correct.
391 */
392 int i;
393 TRACE(ft_t_warn,
394 "Found Ditto 2GB tape, "
395 "trying to decrypt bad sector map");
396 for (i=256; i < 29 * FT_SECTOR_SIZE; i++) {
397 address[i] = ~(address[i] - (i&0xff));
398 }
399 PUT4(address, 0,FT_HSEG_MAGIC);
400 } else if (GET4(address, FT_SIGNATURE) != FT_HSEG_MAGIC) {
401 TRACE_ABORT(-EIO, ft_t_err,
402 "wrong signature in header segment");
403 }
404 ft_format_code = (ft_format_type) address[FT_FMT_CODE];
405 if (ft_format_code != fmt_big) {
406 ft_header_segment_1 = GET2(address, FT_HSEG_1);
407 ft_header_segment_2 = GET2(address, FT_HSEG_2);
408 ft_first_data_segment = GET2(address, FT_FRST_SEG);
409 ft_last_data_segment = GET2(address, FT_LAST_SEG);
410 } else {
411 ft_header_segment_1 = GET4(address, FT_6_HSEG_1);
412 ft_header_segment_2 = GET4(address, FT_6_HSEG_2);
413 ft_first_data_segment = GET4(address, FT_6_FRST_SEG);
414 ft_last_data_segment = GET4(address, FT_6_LAST_SEG);
415 }
416 TRACE(ft_t_noise, "first data segment: %d", ft_first_data_segment);
417 TRACE(ft_t_noise, "last data segment: %d", ft_last_data_segment);
418 TRACE(ft_t_noise, "header segments are %d and %d",
419 ft_header_segment_1, ft_header_segment_2);
420
421 /* Verify tape parameters...
422 * QIC-40/80 spec: tape_parameters:
423 *
424 * segments-per-track segments_per_track
425 * tracks-per-cartridge tracks_per_tape
426 * max-floppy-side (segments_per_track *
427 * tracks_per_tape - 1) /
428 * ftape_segments_per_head
429 * max-floppy-track ftape_segments_per_head /
430 * ftape_segments_per_cylinder - 1
431 * max-floppy-sector ftape_segments_per_cylinder *
432 * FT_SECTORS_PER_SEGMENT
433 */
434 ft_segments_per_track = GET2(address, FT_SPT);
435 ft_tracks_per_tape = address[FT_TPC];
436 max_floppy_side = address[FT_FHM];
437 max_floppy_track = address[FT_FTM];
438 max_floppy_sector = address[FT_FSM];
439 TRACE(ft_t_noise, "(fmt/spt/tpc/fhm/ftm/fsm) = %d/%d/%d/%d/%d/%d",
440 ft_format_code, ft_segments_per_track, ft_tracks_per_tape,
441 max_floppy_side, max_floppy_track, max_floppy_sector);
442 new_tape_len = ftape_tape_len;
443 switch (ft_format_code) {
444 case fmt_425ft:
445 new_tape_len = 425;
446 break;
447 case fmt_normal:
448 if (ftape_tape_len == 0) { /* otherwise 307 ft */
449 new_tape_len = 205;
450 }
451 break;
452 case fmt_1100ft:
453 new_tape_len = 1100;
454 break;
455 case fmt_var:{
456 int segments_per_1000_inch = 1; /* non-zero default for switch */
457 switch (ft_qic_std) {
458 case QIC_TAPE_QIC40:
459 segments_per_1000_inch = 332;
460 break;
461 case QIC_TAPE_QIC80:
462 segments_per_1000_inch = 488;
463 break;
464 case QIC_TAPE_QIC3010:
465 segments_per_1000_inch = 730;
466 break;
467 case QIC_TAPE_QIC3020:
468 segments_per_1000_inch = 1430;
469 break;
470 }
471 new_tape_len = (1000 * ft_segments_per_track +
472 (segments_per_1000_inch - 1)) / segments_per_1000_inch;
473 break;
474 }
475 case fmt_big:{
476 int segments_per_1000_inch = 1; /* non-zero default for switch */
477 switch (ft_qic_std) {
478 case QIC_TAPE_QIC40:
479 segments_per_1000_inch = 332;
480 break;
481 case QIC_TAPE_QIC80:
482 segments_per_1000_inch = 488;
483 break;
484 case QIC_TAPE_QIC3010:
485 segments_per_1000_inch = 730;
486 break;
487 case QIC_TAPE_QIC3020:
488 segments_per_1000_inch = 1430;
489 break;
490 default:
491 TRACE_ABORT(-EIO, ft_t_bug,
492 "%x QIC-standard with fmt-code %d, please report",
493 ft_qic_std, ft_format_code);
494 }
495 new_tape_len = ((1000 * ft_segments_per_track +
496 (segments_per_1000_inch - 1)) /
497 segments_per_1000_inch);
498 break;
499 }
500 default:
501 TRACE_ABORT(-EIO, ft_t_err,
502 "unknown tape format, please report !");
503 }
504 if (new_tape_len != ftape_tape_len) {
505 ftape_tape_len = new_tape_len;
506 TRACE(ft_t_info, "calculated tape length is %d ft",
507 ftape_tape_len);
508 ftape_calc_timeouts(ft_qic_std, ft_data_rate, ftape_tape_len);
509 }
510 if (ft_segments_per_track == 0 && ft_tracks_per_tape == 0 &&
511 max_floppy_side == 0 && max_floppy_track == 0 &&
512 max_floppy_sector == 0) {
513 /* QIC-40 Rev E and earlier has no values in the header.
514 */
515 ft_segments_per_track = 68;
516 ft_tracks_per_tape = 20;
517 max_floppy_side = 1;
518 max_floppy_track = 169;
519 max_floppy_sector = 128;
520 }
521 /* This test will compensate for the wrong parameter on tapes
522 * formatted by Conner software.
523 */
524 if (ft_segments_per_track == 150 &&
525 ft_tracks_per_tape == 28 &&
526 max_floppy_side == 7 &&
527 max_floppy_track == 149 &&
528 max_floppy_sector == 128) {
529TRACE(ft_t_info, "the famous CONNER bug: max_floppy_side off by one !");
530 max_floppy_side = 6;
531 }
532 /* These tests will compensate for the wrong parameter on tapes
533 * formatted by ComByte Windows software.
534 *
535 * First, for 205 foot tapes
536 */
537 if (ft_segments_per_track == 100 &&
538 ft_tracks_per_tape == 28 &&
539 max_floppy_side == 9 &&
540 max_floppy_track == 149 &&
541 max_floppy_sector == 128) {
542TRACE(ft_t_info, "the ComByte bug: max_floppy_side incorrect!");
543 max_floppy_side = 4;
544 }
545 /* Next, for 307 foot tapes. */
546 if (ft_segments_per_track == 150 &&
547 ft_tracks_per_tape == 28 &&
548 max_floppy_side == 9 &&
549 max_floppy_track == 149 &&
550 max_floppy_sector == 128) {
551TRACE(ft_t_info, "the ComByte bug: max_floppy_side incorrect!");
552 max_floppy_side = 6;
553 }
554 /* This test will compensate for the wrong parameter on tapes
555 * formatted by Colorado Windows software.
556 */
557 if (ft_segments_per_track == 150 &&
558 ft_tracks_per_tape == 28 &&
559 max_floppy_side == 6 &&
560 max_floppy_track == 150 &&
561 max_floppy_sector == 128) {
562TRACE(ft_t_info, "the famous Colorado bug: max_floppy_track off by one !");
563 max_floppy_track = 149;
564 }
565 ftape_segments_per_head = ((max_floppy_sector/FT_SECTORS_PER_SEGMENT) *
566 (max_floppy_track + 1));
567 /* This test will compensate for some bug reported by Dima
568 * Brodsky. Seems to be a Colorado bug, either. (freebee
569 * Imation tape shipped together with Colorado T3000
570 */
571 if ((ft_format_code == fmt_var || ft_format_code == fmt_big) &&
572 ft_tracks_per_tape == 50 &&
573 max_floppy_side == 54 &&
574 max_floppy_track == 255 &&
575 max_floppy_sector == 128) {
576TRACE(ft_t_info, "the famous ??? bug: max_floppy_track off by one !");
577 max_floppy_track = 254;
578 }
579 /*
580 * Verify drive_configuration with tape parameters
581 */
582 if (ftape_segments_per_head == 0 || ftape_segments_per_cylinder == 0 ||
583 ((ft_segments_per_track * ft_tracks_per_tape - 1) / ftape_segments_per_head
584 != max_floppy_side) ||
585 (ftape_segments_per_head / ftape_segments_per_cylinder - 1 != max_floppy_track) ||
586 (ftape_segments_per_cylinder * FT_SECTORS_PER_SEGMENT != max_floppy_sector)
587#ifdef TESTING
588 || ((ft_format_code == fmt_var || ft_format_code == fmt_big) &&
589 (max_floppy_track != 254 || max_floppy_sector != 128))
590#endif
591 ) {
592 char segperheadz = ftape_segments_per_head ? ' ' : '?';
593 char segpercylz = ftape_segments_per_cylinder ? ' ' : '?';
594 TRACE(ft_t_err,"Tape parameters inconsistency, please report");
595 TRACE(ft_t_err, "reported = %d/%d/%d/%d/%d/%d",
596 ft_format_code,
597 ft_segments_per_track,
598 ft_tracks_per_tape,
599 max_floppy_side,
600 max_floppy_track,
601 max_floppy_sector);
602 TRACE(ft_t_err, "required = %d/%d/%d/%d%c/%d%c/%d",
603 ft_format_code,
604 ft_segments_per_track,
605 ft_tracks_per_tape,
606 ftape_segments_per_head ?
607 ((ft_segments_per_track * ft_tracks_per_tape -1) /
608 ftape_segments_per_head ) :
609 (ft_segments_per_track * ft_tracks_per_tape -1),
610 segperheadz,
611 ftape_segments_per_cylinder ?
612 (ftape_segments_per_head /
613 ftape_segments_per_cylinder - 1 ) :
614 ftape_segments_per_head - 1,
615 segpercylz,
616 (ftape_segments_per_cylinder * FT_SECTORS_PER_SEGMENT));
617 TRACE_EXIT -EIO;
618 }
619 ftape_extract_bad_sector_map(address);
620 TRACE_EXIT 0;
621}
diff --git a/drivers/char/ftape/lowlevel/ftape-read.h b/drivers/char/ftape/lowlevel/ftape-read.h
deleted file mode 100644
index 069f99f2a984..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-read.h
+++ /dev/null
@@ -1,51 +0,0 @@
1#ifndef _FTAPE_READ_H
2#define _FTAPE_READ_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-read.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:22 $
26 *
27 * This file contains the definitions for the read functions
28 * for the QIC-117 floppy-tape driver for Linux.
29 *
30 */
31
32/* ftape-read.c defined global functions.
33 */
34typedef enum {
35 FT_RD_SINGLE = 0,
36 FT_RD_AHEAD = 1,
37} ft_read_mode_t;
38
39extern int ftape_read_header_segment(__u8 *address);
40extern int ftape_decode_header_segment(__u8 *address);
41extern int ftape_read_segment_fraction(const int segment,
42 void *address,
43 const ft_read_mode_t read_mode,
44 const int start,
45 const int size);
46#define ftape_read_segment(segment, address, read_mode) \
47 ftape_read_segment_fraction(segment, address, read_mode, \
48 0, FT_SEGMENT_SIZE)
49extern void ftape_zap_read_buffers(void);
50
51#endif /* _FTAPE_READ_H */
diff --git a/drivers/char/ftape/lowlevel/ftape-rw.c b/drivers/char/ftape/lowlevel/ftape-rw.c
deleted file mode 100644
index c0d6dc2cbfd3..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-rw.c
+++ /dev/null
@@ -1,1092 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-rw.c,v $
21 * $Revision: 1.7 $
22 * $Date: 1997/10/28 14:26:49 $
23 *
24 * This file contains some common code for the segment read and
25 * segment write routines for the QIC-117 floppy-tape driver for
26 * Linux.
27 */
28
29#include <linux/string.h>
30#include <linux/errno.h>
31
32#include <linux/ftape.h>
33#include <linux/qic117.h>
34#include "../lowlevel/ftape-tracing.h"
35#include "../lowlevel/ftape-rw.h"
36#include "../lowlevel/fdc-io.h"
37#include "../lowlevel/ftape-init.h"
38#include "../lowlevel/ftape-io.h"
39#include "../lowlevel/ftape-ctl.h"
40#include "../lowlevel/ftape-read.h"
41#include "../lowlevel/ftape-ecc.h"
42#include "../lowlevel/ftape-bsm.h"
43
44/* Global vars.
45 */
46int ft_nr_buffers;
47buffer_struct *ft_buffer[FT_MAX_NR_BUFFERS];
48static volatile int ft_head;
49static volatile int ft_tail; /* not volatile but need same type as head */
50int fdc_setup_error;
51location_record ft_location = {-1, 0};
52volatile int ftape_tape_running;
53
54/* Local vars.
55 */
56static int overrun_count_offset;
57static int inhibit_correction;
58
59/* maxmimal allowed overshoot when fast seeking
60 */
61#define OVERSHOOT_LIMIT 10
62
63/* Increment cyclic buffer nr.
64 */
65buffer_struct *ftape_next_buffer(ft_buffer_queue_t pos)
66{
67 switch (pos) {
68 case ft_queue_head:
69 if (++ft_head >= ft_nr_buffers) {
70 ft_head = 0;
71 }
72 return ft_buffer[ft_head];
73 case ft_queue_tail:
74 if (++ft_tail >= ft_nr_buffers) {
75 ft_tail = 0;
76 }
77 return ft_buffer[ft_tail];
78 default:
79 return NULL;
80 }
81}
82int ftape_buffer_id(ft_buffer_queue_t pos)
83{
84 switch(pos) {
85 case ft_queue_head: return ft_head;
86 case ft_queue_tail: return ft_tail;
87 default: return -1;
88 }
89}
90buffer_struct *ftape_get_buffer(ft_buffer_queue_t pos)
91{
92 switch(pos) {
93 case ft_queue_head: return ft_buffer[ft_head];
94 case ft_queue_tail: return ft_buffer[ft_tail];
95 default: return NULL;
96 }
97}
98void ftape_reset_buffer(void)
99{
100 ft_head = ft_tail = 0;
101}
102
103buffer_state_enum ftape_set_state(buffer_state_enum new_state)
104{
105 buffer_state_enum old_state = ft_driver_state;
106
107 ft_driver_state = new_state;
108 return old_state;
109}
110/* Calculate Floppy Disk Controller and DMA parameters for a segment.
111 * head: selects buffer struct in array.
112 * offset: number of physical sectors to skip (including bad ones).
113 * count: number of physical sectors to handle (including bad ones).
114 */
115static int setup_segment(buffer_struct * buff,
116 int segment_id,
117 unsigned int sector_offset,
118 unsigned int sector_count,
119 int retry)
120{
121 SectorMap offset_mask;
122 SectorMap mask;
123 TRACE_FUN(ft_t_any);
124
125 buff->segment_id = segment_id;
126 buff->sector_offset = sector_offset;
127 buff->remaining = sector_count;
128 buff->head = segment_id / ftape_segments_per_head;
129 buff->cyl = (segment_id % ftape_segments_per_head) / ftape_segments_per_cylinder;
130 buff->sect = (segment_id % ftape_segments_per_cylinder) * FT_SECTORS_PER_SEGMENT + 1;
131 buff->deleted = 0;
132 offset_mask = (1 << buff->sector_offset) - 1;
133 mask = ftape_get_bad_sector_entry(segment_id) & offset_mask;
134 while (mask) {
135 if (mask & 1) {
136 offset_mask >>= 1; /* don't count bad sector */
137 }
138 mask >>= 1;
139 }
140 buff->data_offset = count_ones(offset_mask); /* good sectors to skip */
141 buff->ptr = buff->address + buff->data_offset * FT_SECTOR_SIZE;
142 TRACE(ft_t_flow, "data offset = %d sectors", buff->data_offset);
143 if (retry) {
144 buff->soft_error_map &= offset_mask; /* keep skipped part */
145 } else {
146 buff->hard_error_map = buff->soft_error_map = 0;
147 }
148 buff->bad_sector_map = ftape_get_bad_sector_entry(buff->segment_id);
149 if (buff->bad_sector_map != 0) {
150 TRACE(ft_t_noise, "segment: %d, bad sector map: %08lx",
151 buff->segment_id, (long)buff->bad_sector_map);
152 } else {
153 TRACE(ft_t_flow, "segment: %d", buff->segment_id);
154 }
155 if (buff->sector_offset > 0) {
156 buff->bad_sector_map >>= buff->sector_offset;
157 }
158 if (buff->sector_offset != 0 || buff->remaining != FT_SECTORS_PER_SEGMENT) {
159 TRACE(ft_t_flow, "sector offset = %d, count = %d",
160 buff->sector_offset, buff->remaining);
161 }
162 /* Segments with 3 or less sectors are not written with valid
163 * data because there is no space left for the ecc. The
164 * data written is whatever happens to be in the buffer.
165 * Reading such a segment will return a zero byte-count.
166 * To allow us to read/write segments with all bad sectors
167 * we fake one readable sector in the segment. This
168 * prevents having to handle these segments in a very
169 * special way. It is not important if the reading of this
170 * bad sector fails or not (the data is ignored). It is
171 * only read to keep the driver running.
172 *
173 * The QIC-40/80 spec. has no information on how to handle
174 * this case, so this is my interpretation.
175 */
176 if (buff->bad_sector_map == EMPTY_SEGMENT) {
177 TRACE(ft_t_flow, "empty segment %d, fake first sector good",
178 buff->segment_id);
179 if (buff->ptr != buff->address) {
180 TRACE(ft_t_bug, "This is a bug: %p/%p",
181 buff->ptr, buff->address);
182 }
183 buff->bad_sector_map = FAKE_SEGMENT;
184 }
185 fdc_setup_error = 0;
186 buff->next_segment = segment_id + 1;
187 TRACE_EXIT 0;
188}
189
190/* Calculate Floppy Disk Controller and DMA parameters for a new segment.
191 */
192int ftape_setup_new_segment(buffer_struct * buff, int segment_id, int skip)
193{
194 int result = 0;
195 static int old_segment_id = -1;
196 static buffer_state_enum old_ft_driver_state = idle;
197 int retry = 0;
198 unsigned offset = 0;
199 int count = FT_SECTORS_PER_SEGMENT;
200 TRACE_FUN(ft_t_flow);
201
202 TRACE(ft_t_flow, "%s segment %d (old = %d)",
203 (ft_driver_state == reading || ft_driver_state == verifying)
204 ? "reading" : "writing",
205 segment_id, old_segment_id);
206 if (ft_driver_state != old_ft_driver_state) { /* when verifying */
207 old_segment_id = -1;
208 old_ft_driver_state = ft_driver_state;
209 }
210 if (segment_id == old_segment_id) {
211 ++buff->retry;
212 ++ft_history.retries;
213 TRACE(ft_t_flow, "setting up for retry nr %d", buff->retry);
214 retry = 1;
215 if (skip && buff->skip > 0) { /* allow skip on retry */
216 offset = buff->skip;
217 count -= offset;
218 TRACE(ft_t_flow, "skipping %d sectors", offset);
219 }
220 } else {
221 buff->retry = 0;
222 buff->skip = 0;
223 old_segment_id = segment_id;
224 }
225 result = setup_segment(buff, segment_id, offset, count, retry);
226 TRACE_EXIT result;
227}
228
229/* Determine size of next cluster of good sectors.
230 */
231int ftape_calc_next_cluster(buffer_struct * buff)
232{
233 /* Skip bad sectors.
234 */
235 while (buff->remaining > 0 && (buff->bad_sector_map & 1) != 0) {
236 buff->bad_sector_map >>= 1;
237 ++buff->sector_offset;
238 --buff->remaining;
239 }
240 /* Find next cluster of good sectors
241 */
242 if (buff->bad_sector_map == 0) { /* speed up */
243 buff->sector_count = buff->remaining;
244 } else {
245 SectorMap map = buff->bad_sector_map;
246
247 buff->sector_count = 0;
248 while (buff->sector_count < buff->remaining && (map & 1) == 0) {
249 ++buff->sector_count;
250 map >>= 1;
251 }
252 }
253 return buff->sector_count;
254}
255
256/* if just passed the last segment on a track, wait for BOT
257 * or EOT mark.
258 */
259int ftape_handle_logical_eot(void)
260{
261 TRACE_FUN(ft_t_flow);
262
263 if (ft_runner_status == logical_eot) {
264 int status;
265
266 TRACE(ft_t_noise, "tape at logical EOT");
267 TRACE_CATCH(ftape_ready_wait(ftape_timeout.seek, &status),);
268 if ((status & (QIC_STATUS_AT_BOT | QIC_STATUS_AT_EOT)) == 0) {
269 TRACE_ABORT(-EIO, ft_t_err, "eot/bot not reached");
270 }
271 ft_runner_status = end_of_tape;
272 }
273 if (ft_runner_status == end_of_tape) {
274 TRACE(ft_t_noise, "runner stopped because of logical EOT");
275 ft_runner_status = idle;
276 }
277 TRACE_EXIT 0;
278}
279
280static int check_bot_eot(int status)
281{
282 TRACE_FUN(ft_t_flow);
283
284 if (status & (QIC_STATUS_AT_BOT | QIC_STATUS_AT_EOT)) {
285 ft_location.bot = ((ft_location.track & 1) == 0 ?
286 (status & QIC_STATUS_AT_BOT) != 0:
287 (status & QIC_STATUS_AT_EOT) != 0);
288 ft_location.eot = !ft_location.bot;
289 ft_location.segment = (ft_location.track +
290 (ft_location.bot ? 0 : 1)) * ft_segments_per_track - 1;
291 ft_location.sector = -1;
292 ft_location.known = 1;
293 TRACE(ft_t_flow, "tape at logical %s",
294 ft_location.bot ? "bot" : "eot");
295 TRACE(ft_t_flow, "segment = %d", ft_location.segment);
296 } else {
297 ft_location.known = 0;
298 }
299 TRACE_EXIT ft_location.known;
300}
301
302/* Read Id of first sector passing tape head.
303 */
304static int ftape_read_id(void)
305{
306 int status;
307 __u8 out[2];
308 TRACE_FUN(ft_t_any);
309
310 /* Assume tape is running on entry, be able to handle
311 * situation where it stopped or is stopping.
312 */
313 ft_location.known = 0; /* default is location not known */
314 out[0] = FDC_READID;
315 out[1] = ft_drive_sel;
316 TRACE_CATCH(fdc_command(out, 2),);
317 switch (fdc_interrupt_wait(20 * FT_SECOND)) {
318 case 0:
319 if (fdc_sect == 0) {
320 if (ftape_report_drive_status(&status) >= 0 &&
321 (status & QIC_STATUS_READY)) {
322 ftape_tape_running = 0;
323 TRACE(ft_t_flow, "tape has stopped");
324 check_bot_eot(status);
325 }
326 } else {
327 ft_location.known = 1;
328 ft_location.segment = (ftape_segments_per_head
329 * fdc_head
330 + ftape_segments_per_cylinder
331 * fdc_cyl
332 + (fdc_sect - 1)
333 / FT_SECTORS_PER_SEGMENT);
334 ft_location.sector = ((fdc_sect - 1)
335 % FT_SECTORS_PER_SEGMENT);
336 ft_location.eot = ft_location.bot = 0;
337 }
338 break;
339 case -ETIME:
340 /* Didn't find id on tape, must be near end: Wait
341 * until stopped.
342 */
343 if (ftape_ready_wait(FT_FOREVER, &status) >= 0) {
344 ftape_tape_running = 0;
345 TRACE(ft_t_flow, "tape has stopped");
346 check_bot_eot(status);
347 }
348 break;
349 default:
350 /* Interrupted or otherwise failing
351 * fdc_interrupt_wait()
352 */
353 TRACE(ft_t_err, "fdc_interrupt_wait failed");
354 break;
355 }
356 if (!ft_location.known) {
357 TRACE_ABORT(-EIO, ft_t_flow, "no id found");
358 }
359 if (ft_location.sector == 0) {
360 TRACE(ft_t_flow, "passing segment %d/%d",
361 ft_location.segment, ft_location.sector);
362 } else {
363 TRACE(ft_t_fdc_dma, "passing segment %d/%d",
364 ft_location.segment, ft_location.sector);
365 }
366 TRACE_EXIT 0;
367}
368
369static int logical_forward(void)
370{
371 ftape_tape_running = 1;
372 return ftape_command(QIC_LOGICAL_FORWARD);
373}
374
375int ftape_stop_tape(int *pstatus)
376{
377 int retry = 0;
378 int result;
379 TRACE_FUN(ft_t_flow);
380
381 do {
382 result = ftape_command_wait(QIC_STOP_TAPE,
383 ftape_timeout.stop, pstatus);
384 if (result == 0) {
385 if ((*pstatus & QIC_STATUS_READY) == 0) {
386 result = -EIO;
387 } else {
388 ftape_tape_running = 0;
389 }
390 }
391 } while (result < 0 && ++retry <= 3);
392 if (result < 0) {
393 TRACE(ft_t_err, "failed ! (fatal)");
394 }
395 TRACE_EXIT result;
396}
397
398int ftape_dumb_stop(void)
399{
400 int result;
401 int status;
402 TRACE_FUN(ft_t_flow);
403
404 /* Abort current fdc operation if it's busy (probably read
405 * or write operation pending) with a reset.
406 */
407 if (fdc_ready_wait(100 /* usec */) < 0) {
408 TRACE(ft_t_noise, "aborting fdc operation");
409 fdc_reset();
410 }
411 /* Reading id's after the last segment on a track may fail
412 * but eventually the drive will become ready (logical eot).
413 */
414 result = ftape_report_drive_status(&status);
415 ft_location.known = 0;
416 do {
417 if (result == 0 && status & QIC_STATUS_READY) {
418 /* Tape is not running any more.
419 */
420 TRACE(ft_t_noise, "tape already halted");
421 check_bot_eot(status);
422 ftape_tape_running = 0;
423 } else if (ftape_tape_running) {
424 /* Tape is (was) still moving.
425 */
426#ifdef TESTING
427 ftape_read_id();
428#endif
429 result = ftape_stop_tape(&status);
430 } else {
431 /* Tape not yet ready but stopped.
432 */
433 result = ftape_ready_wait(ftape_timeout.pause,&status);
434 }
435 } while (ftape_tape_running
436 && !(sigtestsetmask(&current->pending.signal, _NEVER_BLOCK)));
437#ifndef TESTING
438 ft_location.known = 0;
439#endif
440 if (ft_runner_status == aborting || ft_runner_status == do_abort) {
441 ft_runner_status = idle;
442 }
443 TRACE_EXIT result;
444}
445
446/* Wait until runner has finished tail buffer.
447 *
448 */
449int ftape_wait_segment(buffer_state_enum state)
450{
451 int status;
452 int result = 0;
453 TRACE_FUN(ft_t_flow);
454
455 while (ft_buffer[ft_tail]->status == state) {
456 TRACE(ft_t_flow, "state: %d", ft_buffer[ft_tail]->status);
457 /* First buffer still being worked on, wait up to timeout.
458 *
459 * Note: we check two times for being killed. 50
460 * seconds are quite long. Note that
461 * fdc_interrupt_wait() is not killable by any
462 * means. ftape_read_segment() wants us to return
463 * -EINTR in case of a signal.
464 */
465 FT_SIGNAL_EXIT(_DONT_BLOCK);
466 result = fdc_interrupt_wait(50 * FT_SECOND);
467 FT_SIGNAL_EXIT(_DONT_BLOCK);
468 if (result < 0) {
469 TRACE_ABORT(result,
470 ft_t_err, "fdc_interrupt_wait failed");
471 }
472 if (fdc_setup_error) {
473 /* recover... FIXME */
474 TRACE_ABORT(-EIO, ft_t_err, "setup error");
475 }
476 }
477 if (ft_buffer[ft_tail]->status != error) {
478 TRACE_EXIT 0;
479 }
480 TRACE_CATCH(ftape_report_drive_status(&status),);
481 TRACE(ft_t_noise, "ftape_report_drive_status: 0x%02x", status);
482 if ((status & QIC_STATUS_READY) &&
483 (status & QIC_STATUS_ERROR)) {
484 unsigned int error;
485 qic117_cmd_t command;
486
487 /* Report and clear error state.
488 * In case the drive can't operate at the selected
489 * rate, select the next lower data rate.
490 */
491 ftape_report_error(&error, &command, 1);
492 if (error == 31 && command == QIC_LOGICAL_FORWARD) {
493 /* drive does not accept this data rate */
494 if (ft_data_rate > 250) {
495 TRACE(ft_t_info,
496 "Probable data rate conflict");
497 TRACE(ft_t_info,
498 "Lowering data rate to %d Kbps",
499 ft_data_rate / 2);
500 ftape_half_data_rate();
501 if (ft_buffer[ft_tail]->retry > 0) {
502 /* give it a chance */
503 --ft_buffer[ft_tail]->retry;
504 }
505 } else {
506 /* no rate is accepted... */
507 TRACE(ft_t_err, "We're dead :(");
508 }
509 } else {
510 TRACE(ft_t_err, "Unknown error");
511 }
512 TRACE_EXIT -EIO; /* g.p. error */
513 }
514 TRACE_EXIT 0;
515}
516
517/* forward */ static int seek_forward(int segment_id, int fast);
518
519static int fast_seek(int count, int reverse)
520{
521 int result = 0;
522 int status;
523 TRACE_FUN(ft_t_flow);
524
525 if (count > 0) {
526 /* If positioned at begin or end of tape, fast seeking needs
527 * special treatment.
528 * Starting from logical bot needs a (slow) seek to the first
529 * segment before the high speed seek. Most drives do this
530 * automatically but some older don't, so we treat them
531 * all the same.
532 * Starting from logical eot is even more difficult because
533 * we cannot (slow) reverse seek to the last segment.
534 * TO BE IMPLEMENTED.
535 */
536 inhibit_correction = 0;
537 if (ft_location.known &&
538 ((ft_location.bot && !reverse) ||
539 (ft_location.eot && reverse))) {
540 if (!reverse) {
541 /* (slow) skip to first segment on a track
542 */
543 seek_forward(ft_location.track * ft_segments_per_track, 0);
544 --count;
545 } else {
546 /* When seeking backwards from
547 * end-of-tape the number of erased
548 * gaps found seems to be higher than
549 * expected. Therefor the drive must
550 * skip some more segments than
551 * calculated, but we don't know how
552 * many. Thus we will prevent the
553 * re-calculation of offset and
554 * overshoot when seeking backwards.
555 */
556 inhibit_correction = 1;
557 count += 3; /* best guess */
558 }
559 }
560 } else {
561 TRACE(ft_t_flow, "warning: zero or negative count: %d", count);
562 }
563 if (count > 0) {
564 int i;
565 int nibbles = count > 255 ? 3 : 2;
566
567 if (count > 4095) {
568 TRACE(ft_t_noise, "skipping clipped at 4095 segment");
569 count = 4095;
570 }
571 /* Issue this tape command first. */
572 if (!reverse) {
573 TRACE(ft_t_noise, "skipping %d segment(s)", count);
574 result = ftape_command(nibbles == 3 ?
575 QIC_SKIP_EXTENDED_FORWARD : QIC_SKIP_FORWARD);
576 } else {
577 TRACE(ft_t_noise, "backing up %d segment(s)", count);
578 result = ftape_command(nibbles == 3 ?
579 QIC_SKIP_EXTENDED_REVERSE : QIC_SKIP_REVERSE);
580 }
581 if (result < 0) {
582 TRACE(ft_t_noise, "Skip command failed");
583 } else {
584 --count; /* 0 means one gap etc. */
585 for (i = 0; i < nibbles; ++i) {
586 if (result >= 0) {
587 result = ftape_parameter(count & 15);
588 count /= 16;
589 }
590 }
591 result = ftape_ready_wait(ftape_timeout.rewind, &status);
592 if (result >= 0) {
593 ftape_tape_running = 0;
594 }
595 }
596 }
597 TRACE_EXIT result;
598}
599
600static int validate(int id)
601{
602 /* Check to see if position found is off-track as reported
603 * once. Because all tracks in one direction lie next to
604 * each other, if off-track the error will be approximately
605 * 2 * ft_segments_per_track.
606 */
607 if (ft_location.track == -1) {
608 return 1; /* unforseen situation, don't generate error */
609 } else {
610 /* Use margin of ft_segments_per_track on both sides
611 * because ftape needs some margin and the error we're
612 * looking for is much larger !
613 */
614 int lo = (ft_location.track - 1) * ft_segments_per_track;
615 int hi = (ft_location.track + 2) * ft_segments_per_track;
616
617 return (id >= lo && id < hi);
618 }
619}
620
621static int seek_forward(int segment_id, int fast)
622{
623 int failures = 0;
624 int count;
625 static int margin = 1; /* fixed: stop this before target */
626 static int overshoot = 1;
627 static int min_count = 8;
628 int expected = -1;
629 int target = segment_id - margin;
630 int fast_seeking;
631 int prev_segment = ft_location.segment;
632 TRACE_FUN(ft_t_flow);
633
634 if (!ft_location.known) {
635 TRACE_ABORT(-EIO, ft_t_err,
636 "fatal: cannot seek from unknown location");
637 }
638 if (!validate(segment_id)) {
639 ftape_sleep(1 * FT_SECOND);
640 ft_failure = 1;
641 TRACE_ABORT(-EIO, ft_t_err,
642 "fatal: head off track (bad hardware?)");
643 }
644 TRACE(ft_t_noise, "from %d/%d to %d/0 - %d",
645 ft_location.segment, ft_location.sector,segment_id,margin);
646 count = target - ft_location.segment - overshoot;
647 fast_seeking = (fast &&
648 count > (min_count + (ft_location.bot ? 1 : 0)));
649 if (fast_seeking) {
650 TRACE(ft_t_noise, "fast skipping %d segments", count);
651 expected = segment_id - margin;
652 fast_seek(count, 0);
653 }
654 if (!ftape_tape_running) {
655 logical_forward();
656 }
657 while (ft_location.segment < segment_id) {
658 /* This requires at least one sector in a (bad) segment to
659 * have a valid and readable sector id !
660 * It looks like this is not guaranteed, so we must try
661 * to find a way to skip an EMPTY_SEGMENT. !!! FIXME !!!
662 */
663 if (ftape_read_id() < 0 || !ft_location.known ||
664 sigtestsetmask(&current->pending.signal, _DONT_BLOCK)) {
665 ft_location.known = 0;
666 if (!ftape_tape_running ||
667 ++failures > FT_SECTORS_PER_SEGMENT) {
668 TRACE_ABORT(-EIO, ft_t_err,
669 "read_id failed completely");
670 }
671 FT_SIGNAL_EXIT(_DONT_BLOCK);
672 TRACE(ft_t_flow, "read_id failed, retry (%d)",
673 failures);
674 continue;
675 }
676 if (fast_seeking) {
677 TRACE(ft_t_noise, "ended at %d/%d (%d,%d)",
678 ft_location.segment, ft_location.sector,
679 overshoot, inhibit_correction);
680 if (!inhibit_correction &&
681 (ft_location.segment < expected ||
682 ft_location.segment > expected + margin)) {
683 int error = ft_location.segment - expected;
684 TRACE(ft_t_noise,
685 "adjusting overshoot from %d to %d",
686 overshoot, overshoot + error);
687 overshoot += error;
688 /* All overshoots have the same
689 * direction, so it should never
690 * become negative, but who knows.
691 */
692 if (overshoot < -5 ||
693 overshoot > OVERSHOOT_LIMIT) {
694 if (overshoot < 0) {
695 /* keep sane value */
696 overshoot = -5;
697 } else {
698 /* keep sane value */
699 overshoot = OVERSHOOT_LIMIT;
700 }
701 TRACE(ft_t_noise,
702 "clipped overshoot to %d",
703 overshoot);
704 }
705 }
706 fast_seeking = 0;
707 }
708 if (ft_location.known) {
709 if (ft_location.segment > prev_segment + 1) {
710 TRACE(ft_t_noise,
711 "missed segment %d while skipping",
712 prev_segment + 1);
713 }
714 prev_segment = ft_location.segment;
715 }
716 }
717 if (ft_location.segment > segment_id) {
718 TRACE_ABORT(-EIO,
719 ft_t_noise, "failed: skip ended at segment %d/%d",
720 ft_location.segment, ft_location.sector);
721 }
722 TRACE_EXIT 0;
723}
724
725static int skip_reverse(int segment_id, int *pstatus)
726{
727 int failures = 0;
728 static int overshoot = 1;
729 static int min_rewind = 2; /* 1 + overshoot */
730 static const int margin = 1; /* stop this before target */
731 int expected = 0;
732 int count = 1;
733 int short_seek;
734 int target = segment_id - margin;
735 TRACE_FUN(ft_t_flow);
736
737 if (ft_location.known && !validate(segment_id)) {
738 ftape_sleep(1 * FT_SECOND);
739 ft_failure = 1;
740 TRACE_ABORT(-EIO, ft_t_err,
741 "fatal: head off track (bad hardware?)");
742 }
743 do {
744 if (!ft_location.known) {
745 TRACE(ft_t_warn, "warning: location not known");
746 }
747 TRACE(ft_t_noise, "from %d/%d to %d/0 - %d",
748 ft_location.segment, ft_location.sector,
749 segment_id, margin);
750 /* min_rewind == 1 + overshoot_when_doing_minimum_rewind
751 * overshoot == overshoot_when_doing_larger_rewind
752 * Initially min_rewind == 1 + overshoot, optimization
753 * of both values will be done separately.
754 * overshoot and min_rewind can be negative as both are
755 * sums of three components:
756 * any_overshoot == rewind_overshoot -
757 * stop_overshoot -
758 * start_overshoot
759 */
760 if (ft_location.segment - target - (min_rewind - 1) < 1) {
761 short_seek = 1;
762 } else {
763 count = ft_location.segment - target - overshoot;
764 short_seek = (count < 1);
765 }
766 if (short_seek) {
767 count = 1; /* do shortest rewind */
768 expected = ft_location.segment - min_rewind;
769 if (expected/ft_segments_per_track != ft_location.track) {
770 expected = (ft_location.track *
771 ft_segments_per_track);
772 }
773 } else {
774 expected = target;
775 }
776 fast_seek(count, 1);
777 logical_forward();
778 if (ftape_read_id() < 0 || !ft_location.known ||
779 (sigtestsetmask(&current->pending.signal, _DONT_BLOCK))) {
780 if ((!ftape_tape_running && !ft_location.known) ||
781 ++failures > FT_SECTORS_PER_SEGMENT) {
782 TRACE_ABORT(-EIO, ft_t_err,
783 "read_id failed completely");
784 }
785 FT_SIGNAL_EXIT(_DONT_BLOCK);
786 TRACE_CATCH(ftape_report_drive_status(pstatus),);
787 TRACE(ft_t_noise, "ftape_read_id failed, retry (%d)",
788 failures);
789 continue;
790 }
791 TRACE(ft_t_noise, "ended at %d/%d (%d,%d,%d)",
792 ft_location.segment, ft_location.sector,
793 min_rewind, overshoot, inhibit_correction);
794 if (!inhibit_correction &&
795 (ft_location.segment < expected ||
796 ft_location.segment > expected + margin)) {
797 int error = expected - ft_location.segment;
798 if (short_seek) {
799 TRACE(ft_t_noise,
800 "adjusting min_rewind from %d to %d",
801 min_rewind, min_rewind + error);
802 min_rewind += error;
803 if (min_rewind < -5) {
804 /* is this right ? FIXME ! */
805 /* keep sane value */
806 min_rewind = -5;
807 TRACE(ft_t_noise,
808 "clipped min_rewind to %d",
809 min_rewind);
810 }
811 } else {
812 TRACE(ft_t_noise,
813 "adjusting overshoot from %d to %d",
814 overshoot, overshoot + error);
815 overshoot += error;
816 if (overshoot < -5 ||
817 overshoot > OVERSHOOT_LIMIT) {
818 if (overshoot < 0) {
819 /* keep sane value */
820 overshoot = -5;
821 } else {
822 /* keep sane value */
823 overshoot = OVERSHOOT_LIMIT;
824 }
825 TRACE(ft_t_noise,
826 "clipped overshoot to %d",
827 overshoot);
828 }
829 }
830 }
831 } while (ft_location.segment > segment_id);
832 if (ft_location.known) {
833 TRACE(ft_t_noise, "current location: %d/%d",
834 ft_location.segment, ft_location.sector);
835 }
836 TRACE_EXIT 0;
837}
838
839static int determine_position(void)
840{
841 int retry = 0;
842 int status;
843 int result;
844 TRACE_FUN(ft_t_flow);
845
846 if (!ftape_tape_running) {
847 /* This should only happen if tape is stopped by isr.
848 */
849 TRACE(ft_t_flow, "waiting for tape stop");
850 if (ftape_ready_wait(ftape_timeout.pause, &status) < 0) {
851 TRACE(ft_t_flow, "drive still running (fatal)");
852 ftape_tape_running = 1; /* ? */
853 }
854 } else {
855 ftape_report_drive_status(&status);
856 }
857 if (status & QIC_STATUS_READY) {
858 /* Drive must be ready to check error state !
859 */
860 TRACE(ft_t_flow, "drive is ready");
861 if (status & QIC_STATUS_ERROR) {
862 unsigned int error;
863 qic117_cmd_t command;
864
865 /* Report and clear error state, try to continue.
866 */
867 TRACE(ft_t_flow, "error status set");
868 ftape_report_error(&error, &command, 1);
869 ftape_ready_wait(ftape_timeout.reset, &status);
870 ftape_tape_running = 0; /* ? */
871 }
872 if (check_bot_eot(status)) {
873 if (ft_location.bot) {
874 if ((status & QIC_STATUS_READY) == 0) {
875 /* tape moving away from
876 * bot/eot, let's see if we
877 * can catch up with the first
878 * segment on this track.
879 */
880 } else {
881 TRACE(ft_t_flow,
882 "start tape from logical bot");
883 logical_forward(); /* start moving */
884 }
885 } else {
886 if ((status & QIC_STATUS_READY) == 0) {
887 TRACE(ft_t_noise, "waiting for logical end of track");
888 result = ftape_ready_wait(ftape_timeout.reset, &status);
889 /* error handling needed ? */
890 } else {
891 TRACE(ft_t_noise,
892 "tape at logical end of track");
893 }
894 }
895 } else {
896 TRACE(ft_t_flow, "start tape");
897 logical_forward(); /* start moving */
898 ft_location.known = 0; /* not cleared by logical forward ! */
899 }
900 }
901 /* tape should be moving now, start reading id's
902 */
903 while (!ft_location.known &&
904 retry++ < FT_SECTORS_PER_SEGMENT &&
905 (result = ftape_read_id()) < 0) {
906
907 TRACE(ft_t_flow, "location unknown");
908
909 /* exit on signal
910 */
911 FT_SIGNAL_EXIT(_DONT_BLOCK);
912
913 /* read-id somehow failed, tape may
914 * have reached end or some other
915 * error happened.
916 */
917 TRACE(ft_t_flow, "read-id failed");
918 TRACE_CATCH(ftape_report_drive_status(&status),);
919 TRACE(ft_t_err, "ftape_report_drive_status: 0x%02x", status);
920 if (status & QIC_STATUS_READY) {
921 ftape_tape_running = 0;
922 TRACE(ft_t_noise, "tape stopped for unknown reason! "
923 "status = 0x%02x", status);
924 if (status & QIC_STATUS_ERROR ||
925 !check_bot_eot(status)) {
926 /* oops, tape stopped but not at end!
927 */
928 TRACE_EXIT -EIO;
929 }
930 }
931 }
932 TRACE(ft_t_flow,
933 "tape is positioned at segment %d", ft_location.segment);
934 TRACE_EXIT ft_location.known ? 0 : -EIO;
935}
936
937/* Get the tape running and position it just before the
938 * requested segment.
939 * Seek tape-track and reposition as needed.
940 */
941int ftape_start_tape(int segment_id, int sector_offset)
942{
943 int track = segment_id / ft_segments_per_track;
944 int result = -EIO;
945 int status;
946 static int last_segment = -1;
947 static int bad_bus_timing = 0;
948 /* number of segments passing the head between starting the tape
949 * and being able to access the first sector.
950 */
951 static int start_offset = 1;
952 int retry;
953 TRACE_FUN(ft_t_flow);
954
955 /* If sector_offset > 0, seek into wanted segment instead of
956 * into previous.
957 * This allows error recovery if a part of the segment is bad
958 * (erased) causing the tape drive to generate an index pulse
959 * thus causing a no-data error before the requested sector
960 * is reached.
961 */
962 ftape_tape_running = 0;
963 TRACE(ft_t_noise, "target segment: %d/%d%s", segment_id, sector_offset,
964 ft_buffer[ft_head]->retry > 0 ? " retry" : "");
965 if (ft_buffer[ft_head]->retry > 0) { /* this is a retry */
966 int dist = segment_id - last_segment;
967
968 if ((int)ft_history.overrun_errors < overrun_count_offset) {
969 overrun_count_offset = ft_history.overrun_errors;
970 } else if (dist < 0 || dist > 50) {
971 overrun_count_offset = ft_history.overrun_errors;
972 } else if ((ft_history.overrun_errors -
973 overrun_count_offset) >= 8) {
974 if (ftape_increase_threshold() >= 0) {
975 --ft_buffer[ft_head]->retry;
976 overrun_count_offset =
977 ft_history.overrun_errors;
978 TRACE(ft_t_warn, "increased threshold because "
979 "of excessive overrun errors");
980 } else if (!bad_bus_timing && ft_data_rate >= 1000) {
981 ftape_half_data_rate();
982 --ft_buffer[ft_head]->retry;
983 bad_bus_timing = 1;
984 overrun_count_offset =
985 ft_history.overrun_errors;
986 TRACE(ft_t_warn, "reduced datarate because "
987 "of excessive overrun errors");
988 }
989 }
990 }
991 last_segment = segment_id;
992 if (ft_location.track != track ||
993 (ftape_might_be_off_track && ft_buffer[ft_head]->retry== 0)) {
994 /* current track unknown or not equal to destination
995 */
996 ftape_ready_wait(ftape_timeout.seek, &status);
997 ftape_seek_head_to_track(track);
998 /* overrun_count_offset = ft_history.overrun_errors; */
999 }
1000 result = -EIO;
1001 retry = 0;
1002 while (result < 0 &&
1003 retry++ <= 5 &&
1004 !ft_failure &&
1005 !(sigtestsetmask(&current->pending.signal, _DONT_BLOCK))) {
1006
1007 if (retry && start_offset < 5) {
1008 start_offset ++;
1009 }
1010 /* Check if we are able to catch the requested
1011 * segment in time.
1012 */
1013 if ((ft_location.known || (determine_position() == 0)) &&
1014 ft_location.segment >=
1015 (segment_id -
1016 ((ftape_tape_running || ft_location.bot)
1017 ? 0 : start_offset))) {
1018 /* Too far ahead (in or past target segment).
1019 */
1020 if (ftape_tape_running) {
1021 if ((result = ftape_stop_tape(&status)) < 0) {
1022 TRACE(ft_t_err,
1023 "stop tape failed with code %d",
1024 result);
1025 break;
1026 }
1027 TRACE(ft_t_noise, "tape stopped");
1028 ftape_tape_running = 0;
1029 }
1030 TRACE(ft_t_noise, "repositioning");
1031 ++ft_history.rewinds;
1032 if (segment_id % ft_segments_per_track < start_offset){
1033 TRACE(ft_t_noise, "end of track condition\n"
1034 KERN_INFO "segment_id : %d\n"
1035 KERN_INFO "ft_segments_per_track: %d\n"
1036 KERN_INFO "start_offset : %d",
1037 segment_id, ft_segments_per_track,
1038 start_offset);
1039
1040 /* If seeking to first segments on
1041 * track better do a complete rewind
1042 * to logical begin of track to get a
1043 * more steady tape motion.
1044 */
1045 result = ftape_command_wait(
1046 (ft_location.track & 1)
1047 ? QIC_PHYSICAL_FORWARD
1048 : QIC_PHYSICAL_REVERSE,
1049 ftape_timeout.rewind, &status);
1050 check_bot_eot(status); /* update location */
1051 } else {
1052 result= skip_reverse(segment_id - start_offset,
1053 &status);
1054 }
1055 }
1056 if (!ft_location.known) {
1057 TRACE(ft_t_bug, "panic: location not known");
1058 result = -EIO;
1059 continue; /* while() will check for failure */
1060 }
1061 TRACE(ft_t_noise, "current segment: %d/%d",
1062 ft_location.segment, ft_location.sector);
1063 /* We're on the right track somewhere before the
1064 * wanted segment. Start tape movement if needed and
1065 * skip to just before or inside the requested
1066 * segment. Keep tape running.
1067 */
1068 result = 0;
1069 if (ft_location.segment <
1070 (segment_id - ((ftape_tape_running || ft_location.bot)
1071 ? 0 : start_offset))) {
1072 if (sector_offset > 0) {
1073 result = seek_forward(segment_id,
1074 retry <= 3);
1075 } else {
1076 result = seek_forward(segment_id - 1,
1077 retry <= 3);
1078 }
1079 }
1080 if (result == 0 &&
1081 ft_location.segment !=
1082 (segment_id - (sector_offset > 0 ? 0 : 1))) {
1083 result = -EIO;
1084 }
1085 }
1086 if (result < 0) {
1087 TRACE(ft_t_err, "failed to reposition");
1088 } else {
1089 ft_runner_status = running;
1090 }
1091 TRACE_EXIT result;
1092}
diff --git a/drivers/char/ftape/lowlevel/ftape-rw.h b/drivers/char/ftape/lowlevel/ftape-rw.h
deleted file mode 100644
index 32f4feeb887c..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-rw.h
+++ /dev/null
@@ -1,111 +0,0 @@
1#ifndef _FTAPE_RW_H
2#define _FTAPE_RW_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-rw.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:25 $
26 *
27 * This file contains the definitions for the read and write
28 * functions for the QIC-117 floppy-tape driver for Linux.
29 *
30 * Claus-Justus Heine (1996/09/20): Add definition of format code 6
31 * Claus-Justus Heine (1996/10/04): Changed GET/PUT macros to cast to (__u8 *)
32 *
33 */
34
35#include "../lowlevel/fdc-io.h"
36#include "../lowlevel/ftape-init.h"
37#include "../lowlevel/ftape-bsm.h"
38
39#include <asm/unaligned.h>
40
41#define GET2(address, offset) get_unaligned((__u16*)((__u8 *)address + offset))
42#define GET4(address, offset) get_unaligned((__u32*)((__u8 *)address + offset))
43#define GET8(address, offset) get_unaligned((__u64*)((__u8 *)address + offset))
44#define PUT2(address, offset , value) put_unaligned((value), (__u16*)((__u8 *)address + offset))
45#define PUT4(address, offset , value) put_unaligned((value), (__u32*)((__u8 *)address + offset))
46#define PUT8(address, offset , value) put_unaligned((value), (__u64*)((__u8 *)address + offset))
47
48enum runner_status_enum {
49 idle = 0,
50 running,
51 do_abort,
52 aborting,
53 logical_eot,
54 end_of_tape,
55};
56
57typedef enum ft_buffer_queue {
58 ft_queue_head = 0,
59 ft_queue_tail = 1
60} ft_buffer_queue_t;
61
62
63typedef struct {
64 int track; /* tape head position */
65 volatile int segment; /* current segment */
66 volatile int sector; /* sector offset within current segment */
67 volatile unsigned int bot; /* logical begin of track */
68 volatile unsigned int eot; /* logical end of track */
69 volatile unsigned int known; /* validates bot, segment, sector */
70} location_record;
71
72/* Count nr of 1's in pattern.
73 */
74static inline int count_ones(unsigned long mask)
75{
76 int bits;
77
78 for (bits = 0; mask != 0; mask >>= 1) {
79 if (mask & 1) {
80 ++bits;
81 }
82 }
83 return bits;
84}
85
86#define FT_MAX_NR_BUFFERS 16 /* arbitrary value */
87/* ftape-rw.c defined global vars.
88 */
89extern buffer_struct *ft_buffer[FT_MAX_NR_BUFFERS];
90extern int ft_nr_buffers;
91extern location_record ft_location;
92extern volatile int ftape_tape_running;
93
94/* ftape-rw.c defined global functions.
95 */
96extern int ftape_setup_new_segment(buffer_struct * buff,
97 int segment_id,
98 int offset);
99extern int ftape_calc_next_cluster(buffer_struct * buff);
100extern buffer_struct *ftape_next_buffer (ft_buffer_queue_t pos);
101extern buffer_struct *ftape_get_buffer (ft_buffer_queue_t pos);
102extern int ftape_buffer_id (ft_buffer_queue_t pos);
103extern void ftape_reset_buffer(void);
104extern void ftape_tape_parameters(__u8 drive_configuration);
105extern int ftape_wait_segment(buffer_state_enum state);
106extern int ftape_dumb_stop(void);
107extern int ftape_start_tape(int segment_id, int offset);
108extern int ftape_stop_tape(int *pstatus);
109extern int ftape_handle_logical_eot(void);
110extern buffer_state_enum ftape_set_state(buffer_state_enum new_state);
111#endif /* _FTAPE_RW_H */
diff --git a/drivers/char/ftape/lowlevel/ftape-setup.c b/drivers/char/ftape/lowlevel/ftape-setup.c
deleted file mode 100644
index 678340acd0b7..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-setup.c
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine.
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-setup.c,v $
20 * $Revision: 1.7 $
21 * $Date: 1997/10/10 09:57:06 $
22 *
23 * This file contains the code for processing the kernel command
24 * line options for the QIC-40/80/3010/3020 floppy-tape driver
25 * "ftape" for Linux.
26 */
27
28#include <linux/string.h>
29#include <linux/errno.h>
30#include <linux/mm.h>
31
32#include <linux/ftape.h>
33#include <linux/init.h>
34#include "../lowlevel/ftape-tracing.h"
35#include "../lowlevel/fdc-io.h"
36
37static struct param_table {
38 const char *name;
39 int *var;
40 int def_param;
41 int min;
42 int max;
43} config_params[] __initdata = {
44#ifndef CONFIG_FT_NO_TRACE_AT_ALL
45 { "tracing", &ftape_tracing, 3, ft_t_bug, ft_t_any},
46#endif
47 { "ioport", &ft_fdc_base, CONFIG_FT_FDC_BASE, 0x0, 0xfff},
48 { "irq", &ft_fdc_irq, CONFIG_FT_FDC_IRQ, 2, 15},
49 { "dma", &ft_fdc_dma, CONFIG_FT_FDC_DMA, 0, 3},
50 { "threshold", &ft_fdc_threshold, CONFIG_FT_FDC_THR, 1, 16},
51 { "datarate", &ft_fdc_rate_limit, CONFIG_FT_FDC_MAX_RATE, 500, 2000},
52 { "fc10", &ft_probe_fc10, CONFIG_FT_PROBE_FC10, 0, 1},
53 { "mach2", &ft_mach2, CONFIG_FT_MACH2, 0, 1}
54};
55
56static int __init ftape_setup(char *str)
57{
58 int i;
59 int param;
60 int ints[2];
61
62 TRACE_FUN(ft_t_flow);
63
64 str = get_options(str, ARRAY_SIZE(ints), ints);
65 if (str) {
66 for (i=0; i < NR_ITEMS(config_params); i++) {
67 if (strcmp(str,config_params[i].name) == 0){
68 if (ints[0]) {
69 param = ints[1];
70 } else {
71 param = config_params[i].def_param;
72 }
73 if (param < config_params[i].min ||
74 param > config_params[i].max) {
75 TRACE(ft_t_err,
76 "parameter %s out of range %d ... %d",
77 config_params[i].name,
78 config_params[i].min,
79 config_params[i].max);
80 goto out;
81 }
82 if(config_params[i].var) {
83 TRACE(ft_t_info, "%s=%d", str, param);
84 *config_params[i].var = param;
85 }
86 goto out;
87 }
88 }
89 }
90 if (str) {
91 TRACE(ft_t_err, "unknown ftape option [%s]", str);
92
93 TRACE(ft_t_err, "allowed options are:");
94 for (i=0; i < NR_ITEMS(config_params); i++) {
95 TRACE(ft_t_err, " %s",config_params[i].name);
96 }
97 } else {
98 TRACE(ft_t_err, "botched ftape option");
99 }
100 out:
101 TRACE_EXIT 1;
102}
103
104__setup("ftape=", ftape_setup);
diff --git a/drivers/char/ftape/lowlevel/ftape-tracing.c b/drivers/char/ftape/lowlevel/ftape-tracing.c
deleted file mode 100644
index 7fdc6567440b..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-tracing.c
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * Copyright (C) 1993-1996 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-tracing.c,v $
21 * $Revision: 1.2 $
22 * $Date: 1997/10/05 19:18:27 $
23 *
24 * This file contains the reading code
25 * for the QIC-117 floppy-tape driver for Linux.
26 */
27
28#include <linux/ftape.h>
29#include "../lowlevel/ftape-tracing.h"
30
31/* Global vars.
32 */
33/* tracing
34 * set it to: to log :
35 * 0 bugs
36 * 1 + errors
37 * 2 + warnings
38 * 3 + information
39 * 4 + more information
40 * 5 + program flow
41 * 6 + fdc/dma info
42 * 7 + data flow
43 * 8 + everything else
44 */
45ft_trace_t ftape_tracing = ft_t_info; /* Default level: information and up */
46int ftape_function_nest_level;
47
48/* Local vars.
49 */
50static __u8 trace_id;
51static char spacing[] = "* ";
52
53void ftape_trace_call(const char *file, const char *name)
54{
55 char *indent;
56
57 /* Since printk seems not to work with "%*s" format
58 * we'll use this work-around.
59 */
60 if (ftape_function_nest_level < 0) {
61 printk(KERN_INFO "function nest level (%d) < 0\n",
62 ftape_function_nest_level);
63 ftape_function_nest_level = 0;
64 }
65 if (ftape_function_nest_level < sizeof(spacing)) {
66 indent = (spacing +
67 sizeof(spacing) - 1 -
68 ftape_function_nest_level);
69 } else {
70 indent = spacing;
71 }
72 printk(KERN_INFO "[%03d]%s+%s (%s)\n",
73 (int) trace_id++, indent, file, name);
74}
75
76void ftape_trace_exit(const char *file, const char *name)
77{
78 char *indent;
79
80 /* Since printk seems not to work with "%*s" format
81 * we'll use this work-around.
82 */
83 if (ftape_function_nest_level < 0) {
84 printk(KERN_INFO "function nest level (%d) < 0\n", ftape_function_nest_level);
85 ftape_function_nest_level = 0;
86 }
87 if (ftape_function_nest_level < sizeof(spacing)) {
88 indent = (spacing +
89 sizeof(spacing) - 1 -
90 ftape_function_nest_level);
91 } else {
92 indent = spacing;
93 }
94 printk(KERN_INFO "[%03d]%s-%s (%s)\n",
95 (int) trace_id++, indent, file, name);
96}
97
98void ftape_trace_log(const char *file, const char *function)
99{
100 char *indent;
101
102 /* Since printk seems not to work with "%*s" format
103 * we'll use this work-around.
104 */
105 if (ftape_function_nest_level < 0) {
106 printk(KERN_INFO "function nest level (%d) < 0\n", ftape_function_nest_level);
107 ftape_function_nest_level = 0;
108 }
109 if (ftape_function_nest_level < sizeof(spacing)) {
110 indent = (spacing +
111 sizeof(spacing) - 1 -
112 ftape_function_nest_level);
113 } else {
114 indent = spacing;
115 }
116 printk(KERN_INFO "[%03d]%s%s (%s) - ",
117 (int) trace_id++, indent, file, function);
118}
diff --git a/drivers/char/ftape/lowlevel/ftape-tracing.h b/drivers/char/ftape/lowlevel/ftape-tracing.h
deleted file mode 100644
index 2950810c7085..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-tracing.h
+++ /dev/null
@@ -1,179 +0,0 @@
1#ifndef _FTAPE_TRACING_H
2#define _FTAPE_TRACING_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-tracing.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:18:28 $
26 *
27 * This file contains definitions that eases the debugging of the
28 * QIC-40/80/3010/3020 floppy-tape driver "ftape" for Linux.
29 */
30
31#include <linux/kernel.h>
32
33/*
34 * Be very careful with TRACE_EXIT and TRACE_ABORT.
35 *
36 * if (something) TRACE_EXIT error;
37 *
38 * will NOT work. Use
39 *
40 * if (something) {
41 * TRACE_EXIT error;
42 * }
43 *
44 * instead. Maybe a bit dangerous, but save lots of lines of code.
45 */
46
47#define LL_X "%d/%d KB"
48#define LL(x) (unsigned int)((__u64)(x)>>10), (unsigned int)((x)&1023)
49
50typedef enum {
51 ft_t_nil = -1,
52 ft_t_bug,
53 ft_t_err,
54 ft_t_warn,
55 ft_t_info,
56 ft_t_noise,
57 ft_t_flow,
58 ft_t_fdc_dma,
59 ft_t_data_flow,
60 ft_t_any
61} ft_trace_t;
62
63#ifdef CONFIG_FT_NO_TRACE_AT_ALL
64/* the compiler will optimize away most TRACE() macros
65 */
66#define FT_TRACE_TOP_LEVEL ft_t_bug
67#define TRACE_FUN(level) do {} while(0)
68#define TRACE_EXIT return
69#define TRACE(l, m, i...) \
70{ \
71 if ((ft_trace_t)(l) == FT_TRACE_TOP_LEVEL) { \
72 printk(KERN_INFO"ftape%s(%s):\n" \
73 KERN_INFO m".\n" ,__FILE__, __FUNCTION__ , ##i); \
74 } \
75}
76#define SET_TRACE_LEVEL(l) if ((l) == (l)) do {} while(0)
77#define TRACE_LEVEL FT_TRACE_TOP_LEVEL
78
79#else
80
81#ifdef CONFIG_FT_NO_TRACE
82/* the compiler will optimize away many TRACE() macros
83 * the ftape_simple_trace_call() function simply increments
84 * the function nest level.
85 */
86#define FT_TRACE_TOP_LEVEL ft_t_warn
87#define TRACE_FUN(level) ftape_function_nest_level++
88#define TRACE_EXIT ftape_function_nest_level--; return
89
90#else
91#ifdef CONFIG_FT_FULL_DEBUG
92#define FT_TRACE_TOP_LEVEL ft_t_any
93#else
94#define FT_TRACE_TOP_LEVEL ft_t_flow
95#endif
96#define TRACE_FUN(level) \
97 const ft_trace_t _tracing = level; \
98 if (ftape_tracing >= (ft_trace_t)(level) && \
99 (ft_trace_t)(level) <= FT_TRACE_TOP_LEVEL) \
100 ftape_trace_call(__FILE__, __FUNCTION__); \
101 ftape_function_nest_level ++;
102
103#define TRACE_EXIT \
104 --ftape_function_nest_level; \
105 if (ftape_tracing >= (ft_trace_t)(_tracing) && \
106 (ft_trace_t)(_tracing) <= FT_TRACE_TOP_LEVEL) \
107 ftape_trace_exit(__FILE__, __FUNCTION__); \
108 return
109
110#endif
111
112#define TRACE(l, m, i...) \
113{ \
114 if (ftape_tracing >= (ft_trace_t)(l) && \
115 (ft_trace_t)(l) <= FT_TRACE_TOP_LEVEL) { \
116 ftape_trace_log(__FILE__, __FUNCTION__); \
117 printk(m".\n" ,##i); \
118 } \
119}
120
121#define SET_TRACE_LEVEL(l) \
122{ \
123 if ((ft_trace_t)(l) <= FT_TRACE_TOP_LEVEL) { \
124 ftape_tracing = (ft_trace_t)(l); \
125 } else { \
126 ftape_tracing = FT_TRACE_TOP_LEVEL; \
127 } \
128}
129#define TRACE_LEVEL \
130((ftape_tracing <= FT_TRACE_TOP_LEVEL) ? ftape_tracing : FT_TRACE_TOP_LEVEL)
131
132
133/* Global variables declared in tracing.c
134 */
135extern ft_trace_t ftape_tracing; /* sets default level */
136extern int ftape_function_nest_level;
137
138/* Global functions declared in tracing.c
139 */
140extern void ftape_trace_call(const char *file, const char *name);
141extern void ftape_trace_exit(const char *file, const char *name);
142extern void ftape_trace_log (const char *file, const char *name);
143
144#endif /* !defined(CONFIG_FT_NO_TRACE_AT_ALL) */
145
146/*
147 * Abort with a message.
148 */
149#define TRACE_ABORT(res, i...) \
150{ \
151 TRACE(i); \
152 TRACE_EXIT res; \
153}
154
155/* The following transforms the common "if(result < 0) ... " into a
156 * one-liner.
157 */
158#define _TRACE_CATCH(level, fun, action) \
159{ \
160 int _res = (fun); \
161 if (_res < 0) { \
162 do { action /* */ ; } while(0); \
163 TRACE_ABORT(_res, level, "%s failed: %d", #fun, _res); \
164 } \
165}
166
167#define TRACE_CATCH(fun, fail) _TRACE_CATCH(ft_t_err, fun, fail)
168
169/* Abort the current function when signalled. This doesn't belong here,
170 * but rather into ftape-rw.h (maybe)
171 */
172#define FT_SIGNAL_EXIT(sig_mask) \
173 if (sigtestsetmask(&current->pending.signal, sig_mask)) { \
174 TRACE_ABORT(-EINTR, \
175 ft_t_warn, \
176 "interrupted by non-blockable signal"); \
177 }
178
179#endif /* _FTAPE_TRACING_H */
diff --git a/drivers/char/ftape/lowlevel/ftape-write.c b/drivers/char/ftape/lowlevel/ftape-write.c
deleted file mode 100644
index 45601ec801ee..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-write.c
+++ /dev/null
@@ -1,336 +0,0 @@
1/*
2 * Copyright (C) 1993-1995 Bas Laarhoven,
3 * (C) 1996-1997 Claus-Justus Heine.
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, or (at your option)
8 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; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-write.c,v $
21 * $Revision: 1.3.4.1 $
22 * $Date: 1997/11/14 18:07:04 $
23 *
24 * This file contains the writing code
25 * for the QIC-117 floppy-tape driver for Linux.
26 */
27
28#include <linux/string.h>
29#include <linux/errno.h>
30#include <linux/mm.h>
31
32#include <linux/ftape.h>
33#include <linux/qic117.h>
34#include "../lowlevel/ftape-tracing.h"
35#include "../lowlevel/ftape-write.h"
36#include "../lowlevel/ftape-read.h"
37#include "../lowlevel/ftape-io.h"
38#include "../lowlevel/ftape-ctl.h"
39#include "../lowlevel/ftape-rw.h"
40#include "../lowlevel/ftape-ecc.h"
41#include "../lowlevel/ftape-bsm.h"
42#include "../lowlevel/fdc-isr.h"
43
44/* Global vars.
45 */
46
47/* Local vars.
48 */
49static int last_write_failed;
50
51void ftape_zap_write_buffers(void)
52{
53 int i;
54
55 for (i = 0; i < ft_nr_buffers; ++i) {
56 ft_buffer[i]->status = done;
57 }
58 ftape_reset_buffer();
59}
60
61static int copy_and_gen_ecc(void *destination,
62 const void *source,
63 const SectorMap bad_sector_map)
64{
65 int result;
66 struct memory_segment mseg;
67 int bads = count_ones(bad_sector_map);
68 TRACE_FUN(ft_t_any);
69
70 if (bads > 0) {
71 TRACE(ft_t_noise, "bad sectors in map: %d", bads);
72 }
73 if (bads + 3 >= FT_SECTORS_PER_SEGMENT) {
74 TRACE(ft_t_noise, "empty segment");
75 mseg.blocks = 0; /* skip entire segment */
76 result = 0; /* nothing written */
77 } else {
78 mseg.blocks = FT_SECTORS_PER_SEGMENT - bads;
79 mseg.data = destination;
80 memcpy(mseg.data, source, (mseg.blocks - 3) * FT_SECTOR_SIZE);
81 result = ftape_ecc_set_segment_parity(&mseg);
82 if (result < 0) {
83 TRACE(ft_t_err, "ecc_set_segment_parity failed");
84 } else {
85 result = (mseg.blocks - 3) * FT_SECTOR_SIZE;
86 }
87 }
88 TRACE_EXIT result;
89}
90
91
92int ftape_start_writing(const ft_write_mode_t mode)
93{
94 buffer_struct *head = ftape_get_buffer(ft_queue_head);
95 int segment_id = head->segment_id;
96 int result;
97 buffer_state_enum wanted_state = (mode == FT_WR_DELETE
98 ? deleting
99 : writing);
100 TRACE_FUN(ft_t_flow);
101
102 if ((ft_driver_state != wanted_state) || head->status != waiting) {
103 TRACE_EXIT 0;
104 }
105 ftape_setup_new_segment(head, segment_id, 1);
106 if (mode == FT_WR_SINGLE) {
107 /* stop tape instead of pause */
108 head->next_segment = 0;
109 }
110 ftape_calc_next_cluster(head); /* prepare */
111 head->status = ft_driver_state; /* either writing or deleting */
112 if (ft_runner_status == idle) {
113 TRACE(ft_t_noise,
114 "starting runner for segment %d", segment_id);
115 TRACE_CATCH(ftape_start_tape(segment_id,head->sector_offset),);
116 } else {
117 TRACE(ft_t_noise, "runner not idle, not starting tape");
118 }
119 /* go */
120 result = fdc_setup_read_write(head, (mode == FT_WR_DELETE
121 ? FDC_WRITE_DELETED : FDC_WRITE));
122 ftape_set_state(wanted_state); /* should not be necessary */
123 TRACE_EXIT result;
124}
125
126/* Wait until all data is actually written to tape.
127 *
128 * There is a problem: when the tape runs into logical EOT, then this
129 * failes. We need to restart the runner in this case.
130 */
131int ftape_loop_until_writes_done(void)
132{
133 buffer_struct *head;
134 TRACE_FUN(ft_t_flow);
135
136 while ((ft_driver_state == writing || ft_driver_state == deleting) &&
137 ftape_get_buffer(ft_queue_head)->status != done) {
138 /* set the runner status to idle if at lEOT */
139 TRACE_CATCH(ftape_handle_logical_eot(), last_write_failed = 1);
140 /* restart the tape if necessary */
141 if (ft_runner_status == idle) {
142 TRACE(ft_t_noise, "runner is idle, restarting");
143 if (ft_driver_state == deleting) {
144 TRACE_CATCH(ftape_start_writing(FT_WR_DELETE),
145 last_write_failed = 1);
146 } else {
147 TRACE_CATCH(ftape_start_writing(FT_WR_MULTI),
148 last_write_failed = 1);
149 }
150 }
151 TRACE(ft_t_noise, "tail: %d, head: %d",
152 ftape_buffer_id(ft_queue_tail),
153 ftape_buffer_id(ft_queue_head));
154 TRACE_CATCH(fdc_interrupt_wait(5 * FT_SECOND),
155 last_write_failed = 1);
156 head = ftape_get_buffer(ft_queue_head);
157 if (head->status == error) {
158 /* Allow escape from loop when signaled !
159 */
160 FT_SIGNAL_EXIT(_DONT_BLOCK);
161 if (head->hard_error_map != 0) {
162 /* Implement hard write error recovery here
163 */
164 }
165 /* retry this one */
166 head->status = waiting;
167 if (ft_runner_status == aborting) {
168 ftape_dumb_stop();
169 }
170 if (ft_runner_status != idle) {
171 TRACE_ABORT(-EIO, ft_t_err,
172 "unexpected state: "
173 "ft_runner_status != idle");
174 }
175 ftape_start_writing(ft_driver_state == deleting
176 ? FT_WR_MULTI : FT_WR_DELETE);
177 }
178 TRACE(ft_t_noise, "looping until writes done");
179 }
180 ftape_set_state(idle);
181 TRACE_EXIT 0;
182}
183
184/* Write given segment from buffer at address to tape.
185 */
186static int write_segment(const int segment_id,
187 const void *address,
188 const ft_write_mode_t write_mode)
189{
190 int bytes_written = 0;
191 buffer_struct *tail;
192 buffer_state_enum wanted_state = (write_mode == FT_WR_DELETE
193 ? deleting : writing);
194 TRACE_FUN(ft_t_flow);
195
196 TRACE(ft_t_noise, "segment_id = %d", segment_id);
197 if (ft_driver_state != wanted_state) {
198 if (ft_driver_state == deleting ||
199 wanted_state == deleting) {
200 TRACE_CATCH(ftape_loop_until_writes_done(),);
201 }
202 TRACE(ft_t_noise, "calling ftape_abort_operation");
203 TRACE_CATCH(ftape_abort_operation(),);
204 ftape_zap_write_buffers();
205 ftape_set_state(wanted_state);
206 }
207 /* if all buffers full we'll have to wait...
208 */
209 ftape_wait_segment(wanted_state);
210 tail = ftape_get_buffer(ft_queue_tail);
211 switch(tail->status) {
212 case done:
213 ft_history.defects += count_ones(tail->hard_error_map);
214 break;
215 case waiting:
216 /* this could happen with multiple EMPTY_SEGMENTs, but
217 * shouldn't happen any more as we re-start the runner even
218 * with an empty segment.
219 */
220 bytes_written = -EAGAIN;
221 break;
222 case error:
223 /* setup for a retry
224 */
225 tail->status = waiting;
226 bytes_written = -EAGAIN; /* force retry */
227 if (tail->hard_error_map != 0) {
228 TRACE(ft_t_warn,
229 "warning: %d hard error(s) in written segment",
230 count_ones(tail->hard_error_map));
231 TRACE(ft_t_noise, "hard_error_map = 0x%08lx",
232 (long)tail->hard_error_map);
233 /* Implement hard write error recovery here
234 */
235 }
236 break;
237 default:
238 TRACE_ABORT(-EIO, ft_t_err,
239 "wait for empty segment failed, tail status: %d",
240 tail->status);
241 }
242 /* should runner stop ?
243 */
244 if (ft_runner_status == aborting) {
245 buffer_struct *head = ftape_get_buffer(ft_queue_head);
246 if (head->status == wanted_state) {
247 head->status = done; /* ???? */
248 }
249 /* don't call abort_operation(), we don't want to zap
250 * the dma buffers
251 */
252 TRACE_CATCH(ftape_dumb_stop(),);
253 } else {
254 /* If just passed last segment on tape: wait for BOT
255 * or EOT mark. Sets ft_runner_status to idle if at lEOT
256 * and successful
257 */
258 TRACE_CATCH(ftape_handle_logical_eot(),);
259 }
260 if (tail->status == done) {
261 /* now at least one buffer is empty, fill it with our
262 * data. skip bad sectors and generate ecc.
263 * copy_and_gen_ecc return nr of bytes written, range
264 * 0..29 Kb inclusive!
265 *
266 * Empty segments are handled inside coyp_and_gen_ecc()
267 */
268 if (write_mode != FT_WR_DELETE) {
269 TRACE_CATCH(bytes_written = copy_and_gen_ecc(
270 tail->address, address,
271 ftape_get_bad_sector_entry(segment_id)),);
272 }
273 tail->segment_id = segment_id;
274 tail->status = waiting;
275 tail = ftape_next_buffer(ft_queue_tail);
276 }
277 /* Start tape only if all buffers full or flush mode.
278 * This will give higher probability of streaming.
279 */
280 if (ft_runner_status != running &&
281 ((tail->status == waiting &&
282 ftape_get_buffer(ft_queue_head) == tail) ||
283 write_mode != FT_WR_ASYNC)) {
284 TRACE_CATCH(ftape_start_writing(write_mode),);
285 }
286 TRACE_EXIT bytes_written;
287}
288
289/* Write as much as fits from buffer to the given segment on tape
290 * and handle retries.
291 * Return the number of bytes written (>= 0), or:
292 * -EIO write failed
293 * -EINTR interrupted by signal
294 * -ENOSPC device full
295 */
296int ftape_write_segment(const int segment_id,
297 const void *buffer,
298 const ft_write_mode_t flush)
299{
300 int retry = 0;
301 int result;
302 TRACE_FUN(ft_t_flow);
303
304 ft_history.used |= 2;
305 if (segment_id >= ft_tracks_per_tape*ft_segments_per_track) {
306 /* tape full */
307 TRACE_ABORT(-ENOSPC, ft_t_err,
308 "invalid segment id: %d (max %d)",
309 segment_id,
310 ft_tracks_per_tape * ft_segments_per_track -1);
311 }
312 for (;;) {
313 if ((result = write_segment(segment_id, buffer, flush)) >= 0) {
314 if (result == 0) { /* empty segment */
315 TRACE(ft_t_noise,
316 "empty segment, nothing written");
317 }
318 TRACE_EXIT result;
319 }
320 if (result == -EAGAIN) {
321 if (++retry > 100) { /* give up */
322 TRACE_ABORT(-EIO, ft_t_err,
323 "write failed, >100 retries in segment");
324 }
325 TRACE(ft_t_warn, "write error, retry %d (%d)",
326 retry,
327 ftape_get_buffer(ft_queue_tail)->segment_id);
328 } else {
329 TRACE_ABORT(result, ft_t_err,
330 "write_segment failed, error: %d", result);
331 }
332 /* Allow escape from loop when signaled !
333 */
334 FT_SIGNAL_EXIT(_DONT_BLOCK);
335 }
336}
diff --git a/drivers/char/ftape/lowlevel/ftape-write.h b/drivers/char/ftape/lowlevel/ftape-write.h
deleted file mode 100644
index 0e7f898b7af9..000000000000
--- a/drivers/char/ftape/lowlevel/ftape-write.h
+++ /dev/null
@@ -1,53 +0,0 @@
1#ifndef _FTAPE_WRITE_H
2#define _FTAPE_WRITE_H
3
4/*
5 * Copyright (C) 1994-1995 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape-write.h,v $
24 $Author: claus $
25 *
26 $Revision: 1.2 $
27 $Date: 1997/10/05 19:18:30 $
28 $State: Exp $
29 *
30 * This file contains the definitions for the write functions
31 * for the QIC-117 floppy-tape driver for Linux.
32 *
33 */
34
35
36/* ftape-write.c defined global functions.
37 */
38typedef enum {
39 FT_WR_ASYNC = 0, /* start tape only when all buffers are full */
40 FT_WR_MULTI = 1, /* start tape, but don't necessarily stop */
41 FT_WR_SINGLE = 2, /* write a single segment and stop afterwards */
42 FT_WR_DELETE = 3 /* write deleted data marks */
43} ft_write_mode_t;
44
45extern int ftape_start_writing(const ft_write_mode_t mode);
46extern int ftape_write_segment(const int segment,
47 const void *address,
48 const ft_write_mode_t flushing);
49extern void ftape_zap_write_buffers(void);
50extern int ftape_loop_until_writes_done(void);
51
52#endif /* _FTAPE_WRITE_H */
53
diff --git a/drivers/char/ftape/lowlevel/ftape_syms.c b/drivers/char/ftape/lowlevel/ftape_syms.c
deleted file mode 100644
index 8e0dc4a07ca6..000000000000
--- a/drivers/char/ftape/lowlevel/ftape_syms.c
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 * Copyright (C) 1996-1997 Claus-Justus Heine
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/lowlevel/ftape_syms.c,v $
20 * $Revision: 1.4 $
21 * $Date: 1997/10/17 00:03:51 $
22 *
23 * This file contains the symbols that the ftape low level
24 * part of the QIC-40/80/3010/3020 floppy-tape driver "ftape"
25 * exports to its high level clients
26 */
27
28#include <linux/module.h>
29
30#include <linux/ftape.h>
31#include "../lowlevel/ftape-tracing.h"
32#include "../lowlevel/ftape-init.h"
33#include "../lowlevel/fdc-io.h"
34#include "../lowlevel/ftape-read.h"
35#include "../lowlevel/ftape-write.h"
36#include "../lowlevel/ftape-io.h"
37#include "../lowlevel/ftape-ctl.h"
38#include "../lowlevel/ftape-rw.h"
39#include "../lowlevel/ftape-bsm.h"
40#include "../lowlevel/ftape-buffer.h"
41#include "../lowlevel/ftape-format.h"
42
43/* bad sector handling from ftape-bsm.c */
44EXPORT_SYMBOL(ftape_get_bad_sector_entry);
45EXPORT_SYMBOL(ftape_find_end_of_bsm_list);
46/* from ftape-rw.c */
47EXPORT_SYMBOL(ftape_set_state);
48/* from ftape-ctl.c */
49EXPORT_SYMBOL(ftape_seek_to_bot);
50EXPORT_SYMBOL(ftape_seek_to_eot);
51EXPORT_SYMBOL(ftape_abort_operation);
52EXPORT_SYMBOL(ftape_get_status);
53EXPORT_SYMBOL(ftape_enable);
54EXPORT_SYMBOL(ftape_disable);
55EXPORT_SYMBOL(ftape_mmap);
56EXPORT_SYMBOL(ftape_calibrate_data_rate);
57/* from ftape-io.c */
58EXPORT_SYMBOL(ftape_reset_drive);
59EXPORT_SYMBOL(ftape_command);
60EXPORT_SYMBOL(ftape_parameter);
61EXPORT_SYMBOL(ftape_ready_wait);
62EXPORT_SYMBOL(ftape_report_operation);
63EXPORT_SYMBOL(ftape_report_error);
64/* from ftape-read.c */
65EXPORT_SYMBOL(ftape_read_segment_fraction);
66EXPORT_SYMBOL(ftape_zap_read_buffers);
67EXPORT_SYMBOL(ftape_read_header_segment);
68EXPORT_SYMBOL(ftape_decode_header_segment);
69/* from ftape-write.c */
70EXPORT_SYMBOL(ftape_write_segment);
71EXPORT_SYMBOL(ftape_start_writing);
72EXPORT_SYMBOL(ftape_loop_until_writes_done);
73/* from ftape-buffer.h */
74EXPORT_SYMBOL(ftape_set_nr_buffers);
75/* from ftape-format.h */
76EXPORT_SYMBOL(ftape_format_track);
77EXPORT_SYMBOL(ftape_format_status);
78EXPORT_SYMBOL(ftape_verify_segment);
79/* from tracing.c */
80#ifndef CONFIG_FT_NO_TRACE_AT_ALL
81EXPORT_SYMBOL(ftape_tracing);
82EXPORT_SYMBOL(ftape_function_nest_level);
83EXPORT_SYMBOL(ftape_trace_call);
84EXPORT_SYMBOL(ftape_trace_exit);
85EXPORT_SYMBOL(ftape_trace_log);
86#endif
87
diff --git a/drivers/char/ftape/zftape/Makefile b/drivers/char/ftape/zftape/Makefile
deleted file mode 100644
index 6d91c1f77c05..000000000000
--- a/drivers/char/ftape/zftape/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
1#
2# Copyright (C) 1996, 1997 Claus-Justus Heine.
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 as published by
6# the Free Software Foundation; either version 2, or (at your option)
7# any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; see the file COPYING. If not, write to
16# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17#
18# $Source: /homes/cvs/ftape-stacked/ftape/zftape/Makefile,v $
19# $Revision: 1.4 $
20# $Date: 1997/10/05 19:18:58 $
21#
22# Makefile for the QIC-40/80/3010/3020 zftape interface VFS to
23# ftape
24#
25
26
27# ZFT_OBSOLETE - enable the MTIOC_ZFTAPE_GETBLKSZ ioctl. You should
28# leave this enabled for compatibility with taper.
29
30obj-$(CONFIG_ZFTAPE) += zftape.o
31
32zftape-objs := zftape-rw.o zftape-ctl.o zftape-read.o \
33 zftape-write.o zftape-vtbl.o zftape-eof.o \
34 zftape-init.o zftape-buffers.o zftape_syms.o
35
36EXTRA_CFLAGS := -DZFT_OBSOLETE
diff --git a/drivers/char/ftape/zftape/zftape-buffers.c b/drivers/char/ftape/zftape/zftape-buffers.c
deleted file mode 100644
index 7ebce2ec7897..000000000000
--- a/drivers/char/ftape/zftape/zftape-buffers.c
+++ /dev/null
@@ -1,149 +0,0 @@
1/*
2 * Copyright (C) 1995-1997 Claus-Justus Heine.
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-buffers.c,v $
20 * $Revision: 1.2 $
21 * $Date: 1997/10/05 19:18:59 $
22 *
23 * This file contains the dynamic buffer allocation routines
24 * of zftape
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29#include <linux/slab.h>
30#include <linux/delay.h>
31
32#include <linux/zftape.h>
33
34#include <linux/vmalloc.h>
35
36#include "../zftape/zftape-init.h"
37#include "../zftape/zftape-eof.h"
38#include "../zftape/zftape-ctl.h"
39#include "../zftape/zftape-write.h"
40#include "../zftape/zftape-read.h"
41#include "../zftape/zftape-rw.h"
42#include "../zftape/zftape-vtbl.h"
43
44/* global variables
45 */
46
47/* local varibales
48 */
49static unsigned int used_memory;
50static unsigned int peak_memory;
51
52void zft_memory_stats(void)
53{
54 TRACE_FUN(ft_t_flow);
55
56 TRACE(ft_t_noise, "Memory usage (vmalloc allocations):\n"
57 KERN_INFO "total allocated: %d\n"
58 KERN_INFO "peak allocation: %d",
59 used_memory, peak_memory);
60 peak_memory = used_memory;
61 TRACE_EXIT;
62}
63
64int zft_vcalloc_once(void *new, size_t size)
65{
66 TRACE_FUN(ft_t_flow);
67 if (zft_vmalloc_once(new, size) < 0) {
68 TRACE_EXIT -ENOMEM;
69 }
70 memset(*(void **)new, '\0', size);
71 TRACE_EXIT 0;
72}
73int zft_vmalloc_once(void *new, size_t size)
74{
75 TRACE_FUN(ft_t_flow);
76
77 if (*(void **)new != NULL || size == 0) {
78 TRACE_EXIT 0;
79 }
80 if ((*(void **)new = vmalloc(size)) == NULL) {
81 TRACE_EXIT -ENOMEM;
82 }
83 used_memory += size;
84 if (peak_memory < used_memory) {
85 peak_memory = used_memory;
86 }
87 TRACE_ABORT(0, ft_t_noise,
88 "allocated buffer @ %p, %zd bytes", *(void **)new, size);
89}
90int zft_vmalloc_always(void *new, size_t size)
91{
92 TRACE_FUN(ft_t_flow);
93
94 zft_vfree(new, size);
95 TRACE_EXIT zft_vmalloc_once(new, size);
96}
97void zft_vfree(void *old, size_t size)
98{
99 TRACE_FUN(ft_t_flow);
100
101 if (*(void **)old) {
102 vfree(*(void **)old);
103 used_memory -= size;
104 TRACE(ft_t_noise, "released buffer @ %p, %zd bytes",
105 *(void **)old, size);
106 *(void **)old = NULL;
107 }
108 TRACE_EXIT;
109}
110
111void *zft_kmalloc(size_t size)
112{
113 void *new;
114
115 while ((new = kmalloc(size, GFP_KERNEL)) == NULL) {
116 msleep_interruptible(100);
117 }
118 memset(new, 0, size);
119 used_memory += size;
120 if (peak_memory < used_memory) {
121 peak_memory = used_memory;
122 }
123 return new;
124}
125
126void zft_kfree(void *old, size_t size)
127{
128 kfree(old);
129 used_memory -= size;
130}
131
132/* there are some more buffers that are allocated on demand.
133 * cleanup_module() calles this function to be sure to have released
134 * them
135 */
136void zft_uninit_mem(void)
137{
138 TRACE_FUN(ft_t_flow);
139
140 zft_vfree(&zft_hseg_buf, FT_SEGMENT_SIZE);
141 zft_vfree(&zft_deblock_buf, FT_SEGMENT_SIZE); zft_deblock_segment = -1;
142 zft_free_vtbl();
143 if (zft_cmpr_lock(0 /* don't load */) == 0) {
144 (*zft_cmpr_ops->cleanup)();
145 (*zft_cmpr_ops->reset)(); /* unlock it again */
146 }
147 zft_memory_stats();
148 TRACE_EXIT;
149}
diff --git a/drivers/char/ftape/zftape/zftape-buffers.h b/drivers/char/ftape/zftape/zftape-buffers.h
deleted file mode 100644
index 798e3128c682..000000000000
--- a/drivers/char/ftape/zftape/zftape-buffers.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef _FTAPE_DYNMEM_H
2#define _FTAPE_DYNMEM_H
3
4/*
5 * Copyright (C) 1995-1997 Claus-Justus Heine.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-buffers.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:18:59 $
25 *
26 * memory allocation routines.
27 *
28 */
29
30/* we do not allocate all of the really large buffer memory before
31 * someone tries to open the drive. ftape_open() may fail with
32 * -ENOMEM, but that's better having 200k of vmalloced memory which
33 * cannot be swapped out.
34 */
35
36extern void zft_memory_stats(void);
37extern int zft_vmalloc_once(void *new, size_t size);
38extern int zft_vcalloc_once(void *new, size_t size);
39extern int zft_vmalloc_always(void *new, size_t size);
40extern void zft_vfree(void *old, size_t size);
41extern void *zft_kmalloc(size_t size);
42extern void zft_kfree(void *old, size_t size);
43
44/* called by cleanup_module()
45 */
46extern void zft_uninit_mem(void);
47
48#endif
49
50
51
52
53
54
55
diff --git a/drivers/char/ftape/zftape/zftape-ctl.c b/drivers/char/ftape/zftape/zftape-ctl.c
deleted file mode 100644
index 22ba0f5d00cf..000000000000
--- a/drivers/char/ftape/zftape/zftape-ctl.c
+++ /dev/null
@@ -1,1417 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-ctl.c,v $
20 * $Revision: 1.2.6.2 $
21 * $Date: 1997/11/14 18:07:33 $
22 *
23 * This file contains the non-read/write zftape functions
24 * for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29#include <linux/module.h>
30#include <linux/fcntl.h>
31
32#include <linux/zftape.h>
33
34#include <asm/uaccess.h>
35
36#include "../zftape/zftape-init.h"
37#include "../zftape/zftape-eof.h"
38#include "../zftape/zftape-ctl.h"
39#include "../zftape/zftape-write.h"
40#include "../zftape/zftape-read.h"
41#include "../zftape/zftape-rw.h"
42#include "../zftape/zftape-vtbl.h"
43
44/* Global vars.
45 */
46int zft_write_protected; /* this is when cartridge rdonly or O_RDONLY */
47int zft_header_read;
48int zft_offline;
49unsigned int zft_unit;
50int zft_resid;
51int zft_mt_compression;
52
53/* Local vars.
54 */
55static int going_offline;
56
57typedef int (mt_fun)(int *argptr);
58typedef int (*mt_funp)(int *argptr);
59typedef struct
60{
61 mt_funp function;
62 unsigned offline : 1; /* op permitted if offline or no_tape */
63 unsigned write_protected : 1; /* op permitted if write-protected */
64 unsigned not_formatted : 1; /* op permitted if tape not formatted */
65 unsigned raw_mode : 1; /* op permitted if zft_mode == 0 */
66 unsigned need_idle_state : 1; /* need to call def_idle_state */
67 char *name;
68} fun_entry;
69
70static mt_fun mt_dummy, mt_reset, mt_fsr, mt_bsr, mt_rew, mt_offl, mt_nop,
71 mt_weof, mt_erase, mt_ras2, mt_setblk, mt_setdensity,
72 mt_seek, mt_tell, mt_reten, mt_eom, mt_fsf, mt_bsf,
73 mt_fsfm, mt_bsfm, mt_setdrvbuffer, mt_compression;
74
75static fun_entry mt_funs[]=
76{
77 {mt_reset , 1, 1, 1, 1, 0, "MT_RESET" }, /* 0 */
78 {mt_fsf , 0, 1, 0, 0, 1, "MT_FSF" },
79 {mt_bsf , 0, 1, 0, 0, 1, "MT_BSF" },
80 {mt_fsr , 0, 1, 0, 1, 1, "MT_FSR" },
81 {mt_bsr , 0, 1, 0, 1, 1, "MT_BSR" },
82 {mt_weof , 0, 0, 0, 0, 0, "MT_WEOF" }, /* 5 */
83 {mt_rew , 0, 1, 1, 1, 0, "MT_REW" },
84 {mt_offl , 0, 1, 1, 1, 0, "MT_OFFL" },
85 {mt_nop , 1, 1, 1, 1, 0, "MT_NOP" },
86 {mt_reten , 0, 1, 1, 1, 0, "MT_RETEN" },
87 {mt_bsfm , 0, 1, 0, 0, 1, "MT_BSFM" }, /* 10 */
88 {mt_fsfm , 0, 1, 0, 0, 1, "MT_FSFM" },
89 {mt_eom , 0, 1, 0, 0, 1, "MT_EOM" },
90 {mt_erase , 0, 0, 0, 1, 0, "MT_ERASE" },
91 {mt_dummy , 1, 1, 1, 1, 0, "MT_RAS1" },
92 {mt_ras2 , 0, 0, 0, 1, 0, "MT_RAS2" },
93 {mt_dummy , 1, 1, 1, 1, 0, "MT_RAS3" },
94 {mt_dummy , 1, 1, 1, 1, 0, "UNKNOWN" },
95 {mt_dummy , 1, 1, 1, 1, 0, "UNKNOWN" },
96 {mt_dummy , 1, 1, 1, 1, 0, "UNKNOWN" },
97 {mt_setblk , 1, 1, 1, 1, 1, "MT_SETBLK"}, /* 20 */
98 {mt_setdensity , 1, 1, 1, 1, 0, "MT_SETDENSITY"},
99 {mt_seek , 0, 1, 0, 1, 1, "MT_SEEK" },
100 {mt_dummy , 0, 1, 0, 1, 1, "MT_TELL" }, /* wr-only ?! */
101 {mt_setdrvbuffer, 1, 1, 1, 1, 0, "MT_SETDRVBUFFER" },
102 {mt_dummy , 1, 1, 1, 1, 0, "MT_FSS" }, /* 25 */
103 {mt_dummy , 1, 1, 1, 1, 0, "MT_BSS" },
104 {mt_dummy , 1, 1, 1, 1, 0, "MT_WSM" },
105 {mt_dummy , 1, 1, 1, 1, 0, "MT_LOCK" },
106 {mt_dummy , 1, 1, 1, 1, 0, "MT_UNLOCK"},
107 {mt_dummy , 1, 1, 1, 1, 0, "MT_LOAD" }, /* 30 */
108 {mt_dummy , 1, 1, 1, 1, 0, "MT_UNLOAD"},
109 {mt_compression , 1, 1, 1, 0, 1, "MT_COMPRESSION"},
110 {mt_dummy , 1, 1, 1, 1, 0, "MT_SETPART"},
111 {mt_dummy , 1, 1, 1, 1, 0, "MT_MKPART"}
112};
113
114#define NR_MT_CMDS NR_ITEMS(mt_funs)
115
116void zft_reset_position(zft_position *pos)
117{
118 TRACE_FUN(ft_t_flow);
119
120 pos->seg_byte_pos =
121 pos->volume_pos = 0;
122 if (zft_header_read) {
123 /* need to keep track of the volume table and
124 * compression map. We therefor simply
125 * position at the beginning of the first
126 * volume. This covers old ftape archives as
127 * well has various flavours of the
128 * compression map segments. The worst case is
129 * that the compression map shows up as a
130 * additional volume in front of all others.
131 */
132 pos->seg_pos = zft_find_volume(0)->start_seg;
133 pos->tape_pos = zft_calc_tape_pos(pos->seg_pos);
134 } else {
135 pos->tape_pos = 0;
136 pos->seg_pos = -1;
137 }
138 zft_just_before_eof = 0;
139 zft_deblock_segment = -1;
140 zft_io_state = zft_idle;
141 zft_zap_read_buffers();
142 zft_prevent_flush();
143 /* unlock the compresison module if it is loaded.
144 * The zero arg means not to try to load the module.
145 */
146 if (zft_cmpr_lock(0) == 0) {
147 (*zft_cmpr_ops->reset)(); /* unlock */
148 }
149 TRACE_EXIT;
150}
151
152static void zft_init_driver(void)
153{
154 TRACE_FUN(ft_t_flow);
155
156 zft_resid =
157 zft_header_read =
158 zft_old_ftape =
159 zft_offline =
160 zft_write_protected =
161 going_offline =
162 zft_mt_compression =
163 zft_header_changed =
164 zft_volume_table_changed =
165 zft_written_segments = 0;
166 zft_blk_sz = CONFIG_ZFT_DFLT_BLK_SZ;
167 zft_reset_position(&zft_pos); /* does most of the stuff */
168 ftape_zap_read_buffers();
169 ftape_set_state(idle);
170 TRACE_EXIT;
171}
172
173int zft_def_idle_state(void)
174{
175 int result = 0;
176 TRACE_FUN(ft_t_flow);
177
178 if (!zft_header_read) {
179 result = zft_read_header_segments();
180 } else if ((result = zft_flush_buffers()) >= 0 && zft_qic_mode) {
181 /* don't move past eof
182 */
183 (void)zft_close_volume(&zft_pos);
184 }
185 if (ftape_abort_operation() < 0) {
186 TRACE(ft_t_warn, "ftape_abort_operation() failed");
187 result = -EIO;
188 }
189 /* clear remaining read buffers */
190 zft_zap_read_buffers();
191 zft_io_state = zft_idle;
192 TRACE_EXIT result;
193}
194
195/*****************************************************************************
196 * *
197 * functions for the MTIOCTOP commands *
198 * *
199 *****************************************************************************/
200
201static int mt_dummy(int *dummy)
202{
203 TRACE_FUN(ft_t_flow);
204
205 TRACE_EXIT -ENOSYS;
206}
207
208static int mt_reset(int *dummy)
209{
210 TRACE_FUN(ft_t_flow);
211
212 (void)ftape_seek_to_bot();
213 TRACE_CATCH(ftape_reset_drive(),
214 zft_init_driver(); zft_uninit_mem(); zft_offline = 1);
215 /* fake a re-open of the device. This will set all flage and
216 * allocate buffers as appropriate. The new tape condition will
217 * force the open routine to do anything we need.
218 */
219 TRACE_CATCH(_zft_open(-1 /* fake reopen */, 0 /* dummy */),);
220 TRACE_EXIT 0;
221}
222
223static int mt_fsf(int *arg)
224{
225 int result;
226 TRACE_FUN(ft_t_flow);
227
228 result = zft_skip_volumes(*arg, &zft_pos);
229 zft_just_before_eof = 0;
230 TRACE_EXIT result;
231}
232
233static int mt_bsf(int *arg)
234{
235 int result = 0;
236 TRACE_FUN(ft_t_flow);
237
238 if (*arg != 0) {
239 result = zft_skip_volumes(-*arg + 1, &zft_pos);
240 }
241 TRACE_EXIT result;
242}
243
244static int seek_block(__s64 data_offset,
245 __s64 block_increment,
246 zft_position *pos)
247{
248 int result = 0;
249 __s64 new_block_pos;
250 __s64 vol_block_count;
251 const zft_volinfo *volume;
252 int exceed;
253 TRACE_FUN(ft_t_flow);
254
255 volume = zft_find_volume(pos->seg_pos);
256 if (volume->start_seg == 0 || volume->end_seg == 0) {
257 TRACE_EXIT -EIO;
258 }
259 new_block_pos = (zft_div_blksz(data_offset, volume->blk_sz)
260 + block_increment);
261 vol_block_count = zft_div_blksz(volume->size, volume->blk_sz);
262 if (new_block_pos < 0) {
263 TRACE(ft_t_noise,
264 "new_block_pos " LL_X " < 0", LL(new_block_pos));
265 zft_resid = (int)new_block_pos;
266 new_block_pos = 0;
267 exceed = 1;
268 } else if (new_block_pos > vol_block_count) {
269 TRACE(ft_t_noise,
270 "new_block_pos " LL_X " exceeds size of volume " LL_X,
271 LL(new_block_pos), LL(vol_block_count));
272 zft_resid = (int)(vol_block_count - new_block_pos);
273 new_block_pos = vol_block_count;
274 exceed = 1;
275 } else {
276 exceed = 0;
277 }
278 if (zft_use_compression && volume->use_compression) {
279 TRACE_CATCH(zft_cmpr_lock(1 /* try to load */),);
280 result = (*zft_cmpr_ops->seek)(new_block_pos, pos, volume,
281 zft_deblock_buf);
282 pos->tape_pos = zft_calc_tape_pos(pos->seg_pos);
283 pos->tape_pos += pos->seg_byte_pos;
284 } else {
285 pos->volume_pos = zft_mul_blksz(new_block_pos, volume->blk_sz);
286 pos->tape_pos = zft_calc_tape_pos(volume->start_seg);
287 pos->tape_pos += pos->volume_pos;
288 pos->seg_pos = zft_calc_seg_byte_coord(&pos->seg_byte_pos,
289 pos->tape_pos);
290 }
291 zft_just_before_eof = volume->size == pos->volume_pos;
292 if (zft_just_before_eof) {
293 /* why this? because zft_file_no checks agains start
294 * and end segment of a volume. We do not want to
295 * advance to the next volume with this function.
296 */
297 TRACE(ft_t_noise, "set zft_just_before_eof");
298 zft_position_before_eof(pos, volume);
299 }
300 TRACE(ft_t_noise, "\n"
301 KERN_INFO "new_seg_pos : %d\n"
302 KERN_INFO "new_tape_pos: " LL_X "\n"
303 KERN_INFO "vol_size : " LL_X "\n"
304 KERN_INFO "seg_byte_pos: %d\n"
305 KERN_INFO "blk_sz : %d",
306 pos->seg_pos, LL(pos->tape_pos),
307 LL(volume->size), pos->seg_byte_pos,
308 volume->blk_sz);
309 if (!exceed) {
310 zft_resid = new_block_pos - zft_div_blksz(pos->volume_pos,
311 volume->blk_sz);
312 }
313 if (zft_resid < 0) {
314 zft_resid = -zft_resid;
315 }
316 TRACE_EXIT ((exceed || zft_resid != 0) && result >= 0) ? -EINVAL : result;
317}
318
319static int mt_fsr(int *arg)
320{
321 int result;
322 TRACE_FUN(ft_t_flow);
323
324 result = seek_block(zft_pos.volume_pos, *arg, &zft_pos);
325 TRACE_EXIT result;
326}
327
328static int mt_bsr(int *arg)
329{
330 int result;
331 TRACE_FUN(ft_t_flow);
332
333 result = seek_block(zft_pos.volume_pos, -*arg, &zft_pos);
334 TRACE_EXIT result;
335}
336
337static int mt_weof(int *arg)
338{
339 int result;
340 TRACE_FUN(ft_t_flow);
341
342 TRACE_CATCH(zft_flush_buffers(),);
343 result = zft_weof(*arg, &zft_pos);
344 TRACE_EXIT result;
345}
346
347static int mt_rew(int *dummy)
348{
349 int result;
350 TRACE_FUN(ft_t_flow);
351
352 if(zft_header_read) {
353 (void)zft_def_idle_state();
354 }
355 result = ftape_seek_to_bot();
356 zft_reset_position(&zft_pos);
357 TRACE_EXIT result;
358}
359
360static int mt_offl(int *dummy)
361{
362 int result;
363 TRACE_FUN(ft_t_flow);
364
365 going_offline= 1;
366 result = mt_rew(NULL);
367 TRACE_EXIT result;
368}
369
370static int mt_nop(int *dummy)
371{
372 TRACE_FUN(ft_t_flow);
373 /* should we set tape status?
374 */
375 if (!zft_offline) { /* offline includes no_tape */
376 (void)zft_def_idle_state();
377 }
378 TRACE_EXIT 0;
379}
380
381static int mt_reten(int *dummy)
382{
383 int result;
384 TRACE_FUN(ft_t_flow);
385
386 if(zft_header_read) {
387 (void)zft_def_idle_state();
388 }
389 result = ftape_seek_to_eot();
390 if (result >= 0) {
391 result = ftape_seek_to_bot();
392 }
393 TRACE_EXIT(result);
394}
395
396static int fsfbsfm(int arg, zft_position *pos)
397{
398 const zft_volinfo *vtbl;
399 __s64 block_pos;
400 TRACE_FUN(ft_t_flow);
401
402 /* What to do? This should seek to the next file-mark and
403 * position BEFORE. That is, a next write would just extend
404 * the current file. Well. Let's just seek to the end of the
405 * current file, if count == 1. If count > 1, then do a
406 * "mt_fsf(count - 1)", and then seek to the end of that file.
407 * If count == 0, do nothing
408 */
409 if (arg == 0) {
410 TRACE_EXIT 0;
411 }
412 zft_just_before_eof = 0;
413 TRACE_CATCH(zft_skip_volumes(arg < 0 ? arg : arg-1, pos),
414 if (arg > 0) {
415 zft_resid ++;
416 });
417 vtbl = zft_find_volume(pos->seg_pos);
418 block_pos = zft_div_blksz(vtbl->size, vtbl->blk_sz);
419 (void)seek_block(0, block_pos, pos);
420 if (pos->volume_pos != vtbl->size) {
421 zft_just_before_eof = 0;
422 zft_resid = 1;
423 /* we didn't managed to go there */
424 TRACE_ABORT(-EIO, ft_t_err,
425 "wanted file position " LL_X ", arrived at " LL_X,
426 LL(vtbl->size), LL(pos->volume_pos));
427 }
428 zft_just_before_eof = 1;
429 TRACE_EXIT 0;
430}
431
432static int mt_bsfm(int *arg)
433{
434 int result;
435 TRACE_FUN(ft_t_flow);
436
437 result = fsfbsfm(-*arg, &zft_pos);
438 TRACE_EXIT result;
439}
440
441static int mt_fsfm(int *arg)
442{
443 int result;
444 TRACE_FUN(ft_t_flow);
445
446 result = fsfbsfm(*arg, &zft_pos);
447 TRACE_EXIT result;
448}
449
450static int mt_eom(int *dummy)
451{
452 TRACE_FUN(ft_t_flow);
453
454 zft_skip_to_eom(&zft_pos);
455 TRACE_EXIT 0;
456}
457
458static int mt_erase(int *dummy)
459{
460 int result;
461 TRACE_FUN(ft_t_flow);
462
463 result = zft_erase();
464 TRACE_EXIT result;
465}
466
467static int mt_ras2(int *dummy)
468{
469 int result;
470 TRACE_FUN(ft_t_flow);
471
472 result = -ENOSYS;
473 TRACE_EXIT result;
474}
475
476/* Sets the new blocksize in BYTES
477 *
478 */
479static int mt_setblk(int *new_size)
480{
481 TRACE_FUN(ft_t_flow);
482
483 if((unsigned int)(*new_size) > ZFT_MAX_BLK_SZ) {
484 TRACE_ABORT(-EINVAL, ft_t_info,
485 "desired blk_sz (%d) should be <= %d bytes",
486 *new_size, ZFT_MAX_BLK_SZ);
487 }
488 if ((*new_size & (FT_SECTOR_SIZE-1)) != 0) {
489 TRACE_ABORT(-EINVAL, ft_t_info,
490 "desired blk_sz (%d) must be a multiple of %d bytes",
491 *new_size, FT_SECTOR_SIZE);
492 }
493 if (*new_size == 0) {
494 if (zft_use_compression) {
495 TRACE_ABORT(-EINVAL, ft_t_info,
496 "Variable block size not yet "
497 "supported with compression");
498 }
499 *new_size = 1;
500 }
501 zft_blk_sz = *new_size;
502 TRACE_EXIT 0;
503}
504
505static int mt_setdensity(int *arg)
506{
507 TRACE_FUN(ft_t_flow);
508
509 SET_TRACE_LEVEL(*arg);
510 TRACE(TRACE_LEVEL, "tracing set to %d", TRACE_LEVEL);
511 if ((int)TRACE_LEVEL != *arg) {
512 TRACE_EXIT -EINVAL;
513 }
514 TRACE_EXIT 0;
515}
516
517static int mt_seek(int *new_block_pos)
518{
519 int result= 0;
520 TRACE_FUN(ft_t_any);
521
522 result = seek_block(0, (__s64)*new_block_pos, &zft_pos);
523 TRACE_EXIT result;
524}
525
526/* OK, this is totally different from SCSI, but the worst thing that can
527 * happen is that there is not enough defragmentated memory that can be
528 * allocated. Also, there is a hardwired limit of 16 dma buffers in the
529 * stock ftape module. This shouldn't bring the system down.
530 *
531 * NOTE: the argument specifies the total number of dma buffers to use.
532 * The driver needs at least 3 buffers to function at all.
533 *
534 */
535static int mt_setdrvbuffer(int *cnt)
536{
537 TRACE_FUN(ft_t_flow);
538
539 if (*cnt < 3) {
540 TRACE_EXIT -EINVAL;
541 }
542 TRACE_CATCH(ftape_set_nr_buffers(*cnt),);
543 TRACE_EXIT 0;
544}
545/* return the block position from start of volume
546 */
547static int mt_tell(int *arg)
548{
549 TRACE_FUN(ft_t_flow);
550
551 *arg = zft_div_blksz(zft_pos.volume_pos,
552 zft_find_volume(zft_pos.seg_pos)->blk_sz);
553 TRACE_EXIT 0;
554}
555
556static int mt_compression(int *arg)
557{
558 TRACE_FUN(ft_t_flow);
559
560 /* Ok. We could also check whether compression is available at
561 * all by trying to load the compression module. We could
562 * also check for a block size of 1 byte which is illegal
563 * with compression. Instead of doing it here we rely on
564 * zftape_write() to do the proper checks.
565 */
566 if ((unsigned int)*arg > 1) {
567 TRACE_EXIT -EINVAL;
568 }
569 if (*arg != 0 && zft_blk_sz == 1) { /* variable block size */
570 TRACE_ABORT(-EINVAL, ft_t_info,
571 "Compression not yet supported "
572 "with variable block size");
573 }
574 zft_mt_compression = *arg;
575 if ((zft_unit & ZFT_ZIP_MODE) == 0) {
576 zft_use_compression = zft_mt_compression;
577 }
578 TRACE_EXIT 0;
579}
580
581/* check whether write access is allowed. Write access is denied when
582 * + zft_write_protected == 1 -- this accounts for either hard write
583 * protection of the cartridge or for
584 * O_RDONLY access mode of the tape device
585 * + zft_offline == 1 -- this meany that there is either no tape
586 * or that the MTOFFLINE ioctl has been
587 * previously issued (`soft eject')
588 * + ft_formatted == 0 -- this means that the cartridge is not
589 * formatted
590 * Then we distinuguish two cases. When zft_qic_mode is TRUE, then we try
591 * to emulate a `traditional' (aka SCSI like) UN*X tape device. Therefore we
592 * deny writes when
593 * + zft_qic_mode ==1 &&
594 * (!zft_tape_at_lbot() && -- tape no at logical BOT
595 * !(zft_tape_at_eom() || -- tape not at logical EOM (or EOD)
596 * (zft_tape_at_eom() &&
597 * zft_old_ftape()))) -- we can't add new volume to tapes
598 * written by old ftape because ftape
599 * don't use the volume table
600 *
601 * when the drive is in true raw mode (aka /dev/rawft0) then we don't
602 * care about LBOT and EOM conditions. This device is intended for a
603 * user level program that wants to truly implement the QIC-80 compliance
604 * at the logical data layout level of the cartridge, i.e. implement all
605 * that volume table and volume directory stuff etc.<
606 */
607int zft_check_write_access(zft_position *pos)
608{
609 TRACE_FUN(ft_t_flow);
610
611 if (zft_offline) { /* offline includes no_tape */
612 TRACE_ABORT(-ENXIO,
613 ft_t_info, "tape is offline or no cartridge");
614 }
615 if (!ft_formatted) {
616 TRACE_ABORT(-EACCES, ft_t_info, "tape is not formatted");
617 }
618 if (zft_write_protected) {
619 TRACE_ABORT(-EACCES, ft_t_info, "cartridge write protected");
620 }
621 if (zft_qic_mode) {
622 /* check BOT condition */
623 if (!zft_tape_at_lbot(pos)) {
624 /* protect cartridges written by old ftape if
625 * not at BOT because they use the vtbl
626 * segment for storing data
627 */
628 if (zft_old_ftape) {
629 TRACE_ABORT(-EACCES, ft_t_warn,
630 "Cannot write to cartridges written by old ftape when not at BOT");
631 }
632 /* not at BOT, but allow writes at EOD, of course
633 */
634 if (!zft_tape_at_eod(pos)) {
635 TRACE_ABORT(-EACCES, ft_t_info,
636 "tape not at BOT and not at EOD");
637 }
638 }
639 /* fine. Now the tape is either at BOT or at EOD. */
640 }
641 /* or in raw mode in which case we don't care about BOT and EOD */
642 TRACE_EXIT 0;
643}
644
645/* OPEN routine called by kernel-interface code
646 *
647 * NOTE: this is also called by mt_reset() with dev_minor == -1
648 * to fake a reopen after a reset.
649 */
650int _zft_open(unsigned int dev_minor, unsigned int access_mode)
651{
652 static unsigned int tape_unit;
653 static unsigned int file_access_mode;
654 int result;
655 TRACE_FUN(ft_t_flow);
656
657 if ((int)dev_minor == -1) {
658 /* fake reopen */
659 zft_unit = tape_unit;
660 access_mode = file_access_mode;
661 zft_init_driver(); /* reset all static data to defaults */
662 } else {
663 tape_unit = dev_minor;
664 file_access_mode = access_mode;
665 if ((result = ftape_enable(FTAPE_SEL(dev_minor))) < 0) {
666 TRACE_ABORT(-ENXIO, ft_t_err,
667 "ftape_enable failed: %d", result);
668 }
669 if (ft_new_tape || ft_no_tape || !ft_formatted ||
670 (FTAPE_SEL(zft_unit) != FTAPE_SEL(dev_minor)) ||
671 (zft_unit & ZFT_RAW_MODE) != (dev_minor & ZFT_RAW_MODE)) {
672 /* reset all static data to defaults,
673 */
674 zft_init_driver();
675 }
676 zft_unit = dev_minor;
677 }
678 zft_set_flags(zft_unit); /* decode the minor bits */
679 if (zft_blk_sz == 1 && zft_use_compression) {
680 ftape_disable(); /* resets ft_no_tape */
681 TRACE_ABORT(-ENODEV, ft_t_warn, "Variable block size not yet "
682 "supported with compression");
683 }
684 /* no need for most of the buffers when no tape or not
685 * formatted. for the read/write operations, it is the
686 * regardless whether there is no tape, a not-formatted tape
687 * or the whether the driver is soft offline.
688 * Nevertheless we allow some ioctls with non-formatted tapes,
689 * like rewind and reset.
690 */
691 if (ft_no_tape || !ft_formatted) {
692 zft_uninit_mem();
693 }
694 if (ft_no_tape) {
695 zft_offline = 1; /* so we need not test two variables */
696 }
697 if ((access_mode == O_WRONLY || access_mode == O_RDWR) &&
698 (ft_write_protected || ft_no_tape)) {
699 ftape_disable(); /* resets ft_no_tape */
700 TRACE_ABORT(ft_no_tape ? -ENXIO : -EROFS,
701 ft_t_warn, "wrong access mode %s cartridge",
702 ft_no_tape ? "without a" : "with write protected");
703 }
704 zft_write_protected = (access_mode == O_RDONLY ||
705 ft_write_protected != 0);
706 if (zft_write_protected) {
707 TRACE(ft_t_noise,
708 "read only access mode: %d, "
709 "drive write protected: %d",
710 access_mode == O_RDONLY,
711 ft_write_protected != 0);
712 }
713 if (!zft_offline) {
714 TRACE_CATCH(zft_vmalloc_once(&zft_deblock_buf,FT_SEGMENT_SIZE),
715 ftape_disable());
716 }
717 /* zft_seg_pos should be greater than the vtbl segpos but not
718 * if in compatibility mode and only after we read in the
719 * header segments
720 *
721 * might also be a problem if the user makes a backup with a
722 * *qft* device and rewinds it with a raw device.
723 */
724 if (zft_qic_mode &&
725 !zft_old_ftape &&
726 zft_pos.seg_pos >= 0 &&
727 zft_header_read &&
728 zft_pos.seg_pos <= ft_first_data_segment) {
729 TRACE(ft_t_noise, "you probably mixed up the zftape devices!");
730 zft_reset_position(&zft_pos);
731 }
732 TRACE_EXIT 0;
733}
734
735/* RELEASE routine called by kernel-interface code
736 */
737int _zft_close(void)
738{
739 int result = 0;
740 TRACE_FUN(ft_t_flow);
741
742 if (zft_offline) {
743 /* call the hardware release routine. Puts the drive offline */
744 ftape_disable();
745 TRACE_EXIT 0;
746 }
747 if (!(ft_write_protected || zft_old_ftape)) {
748 result = zft_flush_buffers();
749 TRACE(ft_t_noise, "writing file mark at current position");
750 if (zft_qic_mode && zft_close_volume(&zft_pos) == 0) {
751 zft_move_past_eof(&zft_pos);
752 }
753 if ((zft_tape_at_lbot(&zft_pos) ||
754 !(zft_unit & FTAPE_NO_REWIND))) {
755 if (result >= 0) {
756 result = zft_update_header_segments();
757 } else {
758 TRACE(ft_t_err,
759 "Error: unable to update header segments");
760 }
761 }
762 }
763 ftape_abort_operation();
764 if (!(zft_unit & FTAPE_NO_REWIND)) {
765 TRACE(ft_t_noise, "rewinding tape");
766 if (ftape_seek_to_bot() < 0 && result >= 0) {
767 result = -EIO; /* keep old value */
768 }
769 zft_reset_position(&zft_pos);
770 }
771 zft_zap_read_buffers();
772 /* now free up memory as much as possible. We don't destroy
773 * the deblock buffer if it containes a valid segment.
774 */
775 if (zft_deblock_segment == -1) {
776 zft_vfree(&zft_deblock_buf, FT_SEGMENT_SIZE);
777 }
778 /* high level driver status, forces creation of a new volume
779 * when calling ftape_write again and not zft_just_before_eof
780 */
781 zft_io_state = zft_idle;
782 if (going_offline) {
783 zft_init_driver();
784 zft_uninit_mem();
785 going_offline = 0;
786 zft_offline = 1;
787 } else if (zft_cmpr_lock(0 /* don't load */) == 0) {
788 (*zft_cmpr_ops->reset)(); /* unlock it again */
789 }
790 zft_memory_stats();
791 /* call the hardware release routine. Puts the drive offline */
792 ftape_disable();
793 TRACE_EXIT result;
794}
795
796/*
797 * the wrapper function around the wrapper MTIOCTOP ioctl
798 */
799static int mtioctop(struct mtop *mtop, int arg_size)
800{
801 int result = 0;
802 fun_entry *mt_fun_entry;
803 TRACE_FUN(ft_t_flow);
804
805 if (arg_size != sizeof(struct mtop) || mtop->mt_op >= NR_MT_CMDS) {
806 TRACE_EXIT -EINVAL;
807 }
808 TRACE(ft_t_noise, "calling MTIOCTOP command: %s",
809 mt_funs[mtop->mt_op].name);
810 mt_fun_entry= &mt_funs[mtop->mt_op];
811 zft_resid = mtop->mt_count;
812 if (!mt_fun_entry->offline && zft_offline) {
813 if (ft_no_tape) {
814 TRACE_ABORT(-ENXIO, ft_t_info, "no tape present");
815 } else {
816 TRACE_ABORT(-ENXIO, ft_t_info, "drive is offline");
817 }
818 }
819 if (!mt_fun_entry->not_formatted && !ft_formatted) {
820 TRACE_ABORT(-EACCES, ft_t_info, "tape is not formatted");
821 }
822 if (!mt_fun_entry->write_protected) {
823 TRACE_CATCH(zft_check_write_access(&zft_pos),);
824 }
825 if (mt_fun_entry->need_idle_state && !(zft_offline || !ft_formatted)) {
826 TRACE_CATCH(zft_def_idle_state(),);
827 }
828 if (!zft_qic_mode && !mt_fun_entry->raw_mode) {
829 TRACE_ABORT(-EACCES, ft_t_info,
830"Drive needs to be in QIC-80 compatibility mode for this command");
831 }
832 result = (mt_fun_entry->function)(&mtop->mt_count);
833 if (zft_tape_at_lbot(&zft_pos)) {
834 TRACE_CATCH(zft_update_header_segments(),);
835 }
836 if (result >= 0) {
837 zft_resid = 0;
838 }
839 TRACE_EXIT result;
840}
841
842/*
843 * standard MTIOCGET ioctl
844 */
845static int mtiocget(struct mtget *mtget, int arg_size)
846{
847 const zft_volinfo *volume;
848 __s64 max_tape_pos;
849 TRACE_FUN(ft_t_flow);
850
851 if (arg_size != sizeof(struct mtget)) {
852 TRACE_ABORT(-EINVAL, ft_t_info, "bad argument size: %d",
853 arg_size);
854 }
855 mtget->mt_type = ft_drive_type.vendor_id + 0x800000;
856 mtget->mt_dsreg = ft_last_status.space;
857 mtget->mt_erreg = ft_last_error.space; /* error register */
858 mtget->mt_resid = zft_resid; /* residuum of writes, reads and
859 * MTIOCTOP commands
860 */
861 if (!zft_offline) { /* neither no_tape nor soft offline */
862 mtget->mt_gstat = GMT_ONLINE(~0UL);
863 /* should rather return the status of the cartridge
864 * than the access mode of the file, therefor use
865 * ft_write_protected, not zft_write_protected
866 */
867 if (ft_write_protected) {
868 mtget->mt_gstat |= GMT_WR_PROT(~0UL);
869 }
870 if(zft_header_read) { /* this catches non-formatted */
871 volume = zft_find_volume(zft_pos.seg_pos);
872 mtget->mt_fileno = volume->count;
873 max_tape_pos = zft_capacity - zft_blk_sz;
874 if (zft_use_compression) {
875 max_tape_pos -= ZFT_CMPR_OVERHEAD;
876 }
877 if (zft_tape_at_eod(&zft_pos)) {
878 mtget->mt_gstat |= GMT_EOD(~0UL);
879 }
880 if (zft_pos.tape_pos > max_tape_pos) {
881 mtget->mt_gstat |= GMT_EOT(~0UL);
882 }
883 mtget->mt_blkno = zft_div_blksz(zft_pos.volume_pos,
884 volume->blk_sz);
885 if (zft_just_before_eof) {
886 mtget->mt_gstat |= GMT_EOF(~0UL);
887 }
888 if (zft_tape_at_lbot(&zft_pos)) {
889 mtget->mt_gstat |= GMT_BOT(~0UL);
890 }
891 } else {
892 mtget->mt_fileno = mtget->mt_blkno = -1;
893 if (mtget->mt_dsreg & QIC_STATUS_AT_BOT) {
894 mtget->mt_gstat |= GMT_BOT(~0UL);
895 }
896 }
897 } else {
898 if (ft_no_tape) {
899 mtget->mt_gstat = GMT_DR_OPEN(~0UL);
900 } else {
901 mtget->mt_gstat = 0UL;
902 }
903 mtget->mt_fileno = mtget->mt_blkno = -1;
904 }
905 TRACE_EXIT 0;
906}
907
908#ifdef MTIOCRDFTSEG
909/*
910 * Read a floppy tape segment. This is useful for manipulating the
911 * volume table, and read the old header segment before re-formatting
912 * the cartridge.
913 */
914static int mtiocrdftseg(struct mtftseg * mtftseg, int arg_size)
915{
916 TRACE_FUN(ft_t_flow);
917
918 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCRDFTSEG");
919 if (zft_qic_mode) {
920 TRACE_ABORT(-EACCES, ft_t_info,
921 "driver needs to be in raw mode for this ioctl");
922 }
923 if (arg_size != sizeof(struct mtftseg)) {
924 TRACE_ABORT(-EINVAL, ft_t_info, "bad argument size: %d",
925 arg_size);
926 }
927 if (zft_offline) {
928 TRACE_EXIT -ENXIO;
929 }
930 if (mtftseg->mt_mode != FT_RD_SINGLE &&
931 mtftseg->mt_mode != FT_RD_AHEAD) {
932 TRACE_ABORT(-EINVAL, ft_t_info, "invalid read mode");
933 }
934 if (!ft_formatted) {
935 TRACE_EXIT -EACCES; /* -ENXIO ? */
936
937 }
938 if (!zft_header_read) {
939 TRACE_CATCH(zft_def_idle_state(),);
940 }
941 if (mtftseg->mt_segno > ft_last_data_segment) {
942 TRACE_ABORT(-EINVAL, ft_t_info, "segment number is too large");
943 }
944 mtftseg->mt_result = ftape_read_segment(mtftseg->mt_segno,
945 zft_deblock_buf,
946 mtftseg->mt_mode);
947 if (mtftseg->mt_result < 0) {
948 /* a negativ result is not an ioctl error. if
949 * the user wants to read damaged tapes,
950 * it's up to her/him
951 */
952 TRACE_EXIT 0;
953 }
954 if (copy_to_user(mtftseg->mt_data,
955 zft_deblock_buf,
956 mtftseg->mt_result) != 0) {
957 TRACE_EXIT -EFAULT;
958 }
959 TRACE_EXIT 0;
960}
961#endif
962
963#ifdef MTIOCWRFTSEG
964/*
965 * write a floppy tape segment. This version features writing of
966 * deleted address marks, and gracefully ignores the (software)
967 * ft_formatted flag to support writing of header segments after
968 * formatting.
969 */
970static int mtiocwrftseg(struct mtftseg * mtftseg, int arg_size)
971{
972 int result;
973 TRACE_FUN(ft_t_flow);
974
975 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCWRFTSEG");
976 if (zft_write_protected || zft_qic_mode) {
977 TRACE_EXIT -EACCES;
978 }
979 if (arg_size != sizeof(struct mtftseg)) {
980 TRACE_ABORT(-EINVAL, ft_t_info, "bad argument size: %d",
981 arg_size);
982 }
983 if (zft_offline) {
984 TRACE_EXIT -ENXIO;
985 }
986 if (mtftseg->mt_mode != FT_WR_ASYNC &&
987 mtftseg->mt_mode != FT_WR_MULTI &&
988 mtftseg->mt_mode != FT_WR_SINGLE &&
989 mtftseg->mt_mode != FT_WR_DELETE) {
990 TRACE_ABORT(-EINVAL, ft_t_info, "invalid write mode");
991 }
992 /*
993 * We don't check for ft_formatted, because this gives
994 * only the software status of the driver.
995 *
996 * We assume that the user knows what it is
997 * doing. And rely on the low level stuff to fail
998 * when the tape isn't formatted. We only make sure
999 * that The header segment buffer is allocated,
1000 * because it holds the bad sector map.
1001 */
1002 if (zft_hseg_buf == NULL) {
1003 TRACE_EXIT -ENXIO;
1004 }
1005 if (mtftseg->mt_mode != FT_WR_DELETE) {
1006 if (copy_from_user(zft_deblock_buf,
1007 mtftseg->mt_data,
1008 FT_SEGMENT_SIZE) != 0) {
1009 TRACE_EXIT -EFAULT;
1010 }
1011 }
1012 mtftseg->mt_result = ftape_write_segment(mtftseg->mt_segno,
1013 zft_deblock_buf,
1014 mtftseg->mt_mode);
1015 if (mtftseg->mt_result >= 0 && mtftseg->mt_mode == FT_WR_SINGLE) {
1016 /*
1017 * a negativ result is not an ioctl error. if
1018 * the user wants to write damaged tapes,
1019 * it's up to her/him
1020 */
1021 if ((result = ftape_loop_until_writes_done()) < 0) {
1022 mtftseg->mt_result = result;
1023 }
1024 }
1025 TRACE_EXIT 0;
1026}
1027#endif
1028
1029#ifdef MTIOCVOLINFO
1030/*
1031 * get information about volume positioned at.
1032 */
1033static int mtiocvolinfo(struct mtvolinfo *volinfo, int arg_size)
1034{
1035 const zft_volinfo *volume;
1036 TRACE_FUN(ft_t_flow);
1037
1038 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCVOLINFO");
1039 if (arg_size != sizeof(struct mtvolinfo)) {
1040 TRACE_ABORT(-EINVAL,
1041 ft_t_info, "bad argument size: %d", arg_size);
1042 }
1043 if (zft_offline) {
1044 TRACE_EXIT -ENXIO;
1045 }
1046 if (!ft_formatted) {
1047 TRACE_EXIT -EACCES;
1048 }
1049 TRACE_CATCH(zft_def_idle_state(),);
1050 volume = zft_find_volume(zft_pos.seg_pos);
1051 volinfo->mt_volno = volume->count;
1052 volinfo->mt_blksz = volume->blk_sz == 1 ? 0 : volume->blk_sz;
1053 volinfo->mt_size = volume->size >> 10;
1054 volinfo->mt_rawsize = ((zft_calc_tape_pos(volume->end_seg + 1) >> 10) -
1055 (zft_calc_tape_pos(volume->start_seg) >> 10));
1056 volinfo->mt_cmpr = volume->use_compression;
1057 TRACE_EXIT 0;
1058}
1059#endif
1060
1061#ifdef ZFT_OBSOLETE
1062static int mtioc_zftape_getblksz(struct mtblksz *blksz, int arg_size)
1063{
1064 TRACE_FUN(ft_t_flow);
1065
1066 TRACE(ft_t_noise, "\n"
1067 KERN_INFO "Mag tape ioctl command: MTIOC_ZTAPE_GETBLKSZ\n"
1068 KERN_INFO "This ioctl is here merely for compatibility.\n"
1069 KERN_INFO "Please use MTIOCVOLINFO instead");
1070 if (arg_size != sizeof(struct mtblksz)) {
1071 TRACE_ABORT(-EINVAL,
1072 ft_t_info, "bad argument size: %d", arg_size);
1073 }
1074 if (zft_offline) {
1075 TRACE_EXIT -ENXIO;
1076 }
1077 if (!ft_formatted) {
1078 TRACE_EXIT -EACCES;
1079 }
1080 TRACE_CATCH(zft_def_idle_state(),);
1081 blksz->mt_blksz = zft_find_volume(zft_pos.seg_pos)->blk_sz;
1082 TRACE_EXIT 0;
1083}
1084#endif
1085
1086#ifdef MTIOCGETSIZE
1087/*
1088 * get the capacity of the tape cartridge.
1089 */
1090static int mtiocgetsize(struct mttapesize *size, int arg_size)
1091{
1092 TRACE_FUN(ft_t_flow);
1093
1094 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOC_ZFTAPE_GETSIZE");
1095 if (arg_size != sizeof(struct mttapesize)) {
1096 TRACE_ABORT(-EINVAL,
1097 ft_t_info, "bad argument size: %d", arg_size);
1098 }
1099 if (zft_offline) {
1100 TRACE_EXIT -ENXIO;
1101 }
1102 if (!ft_formatted) {
1103 TRACE_EXIT -EACCES;
1104 }
1105 TRACE_CATCH(zft_def_idle_state(),);
1106 size->mt_capacity = (unsigned int)(zft_capacity>>10);
1107 size->mt_used = (unsigned int)(zft_get_eom_pos()>>10);
1108 TRACE_EXIT 0;
1109}
1110#endif
1111
1112static int mtiocpos(struct mtpos *mtpos, int arg_size)
1113{
1114 int result;
1115 TRACE_FUN(ft_t_flow);
1116
1117 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCPOS");
1118 if (arg_size != sizeof(struct mtpos)) {
1119 TRACE_ABORT(-EINVAL,
1120 ft_t_info, "bad argument size: %d", arg_size);
1121 }
1122 result = mt_tell((int *)&mtpos->mt_blkno);
1123 TRACE_EXIT result;
1124}
1125
1126#ifdef MTIOCFTFORMAT
1127/*
1128 * formatting of floppy tape cartridges. This is intended to be used
1129 * together with the MTIOCFTCMD ioctl and the new mmap feature
1130 */
1131
1132/*
1133 * This function uses ftape_decode_header_segment() to inform the low
1134 * level ftape module about the new parameters.
1135 *
1136 * It erases the hseg_buf. The calling process must specify all
1137 * parameters to assure proper operation.
1138 *
1139 * return values: -EINVAL - wrong argument size
1140 * -EINVAL - if ftape_decode_header_segment() failed.
1141 */
1142static int set_format_parms(struct ftfmtparms *p, __u8 *hseg_buf)
1143{
1144 ft_trace_t old_level = TRACE_LEVEL;
1145 TRACE_FUN(ft_t_flow);
1146
1147 TRACE(ft_t_noise, "MTIOCFTFORMAT operation FTFMT_SETPARMS");
1148 memset(hseg_buf, 0, FT_SEGMENT_SIZE);
1149 PUT4(hseg_buf, FT_SIGNATURE, FT_HSEG_MAGIC);
1150
1151 /* fill in user specified parameters
1152 */
1153 hseg_buf[FT_FMT_CODE] = (__u8)p->ft_fmtcode;
1154 PUT2(hseg_buf, FT_SPT, p->ft_spt);
1155 hseg_buf[FT_TPC] = (__u8)p->ft_tpc;
1156 hseg_buf[FT_FHM] = (__u8)p->ft_fhm;
1157 hseg_buf[FT_FTM] = (__u8)p->ft_ftm;
1158
1159 /* fill in sane defaults to make ftape happy.
1160 */
1161 hseg_buf[FT_FSM] = (__u8)128; /* 128 is hard wired all over ftape */
1162 if (p->ft_fmtcode == fmt_big) {
1163 PUT4(hseg_buf, FT_6_HSEG_1, 0);
1164 PUT4(hseg_buf, FT_6_HSEG_2, 1);
1165 PUT4(hseg_buf, FT_6_FRST_SEG, 2);
1166 PUT4(hseg_buf, FT_6_LAST_SEG, p->ft_spt * p->ft_tpc - 1);
1167 } else {
1168 PUT2(hseg_buf, FT_HSEG_1, 0);
1169 PUT2(hseg_buf, FT_HSEG_2, 1);
1170 PUT2(hseg_buf, FT_FRST_SEG, 2);
1171 PUT2(hseg_buf, FT_LAST_SEG, p->ft_spt * p->ft_tpc - 1);
1172 }
1173
1174 /* Synchronize with the low level module. This is particularly
1175 * needed for unformatted cartridges as the QIC std was previously
1176 * unknown BUT is needed to set data rate and to calculate timeouts.
1177 */
1178 TRACE_CATCH(ftape_calibrate_data_rate(p->ft_qicstd&QIC_TAPE_STD_MASK),
1179 _res = -EINVAL);
1180
1181 /* The following will also recalcualte the timeouts for the tape
1182 * length and QIC std we want to format to.
1183 * abort with -EINVAL rather than -EIO
1184 */
1185 SET_TRACE_LEVEL(ft_t_warn);
1186 TRACE_CATCH(ftape_decode_header_segment(hseg_buf),
1187 SET_TRACE_LEVEL(old_level); _res = -EINVAL);
1188 SET_TRACE_LEVEL(old_level);
1189 TRACE_EXIT 0;
1190}
1191
1192/*
1193 * Return the internal SOFTWARE status of the kernel driver. This does
1194 * NOT query the tape drive about its status.
1195 */
1196static int get_format_parms(struct ftfmtparms *p, __u8 *hseg_buffer)
1197{
1198 TRACE_FUN(ft_t_flow);
1199
1200 TRACE(ft_t_noise, "MTIOCFTFORMAT operation FTFMT_GETPARMS");
1201 p->ft_qicstd = ft_qic_std;
1202 p->ft_fmtcode = ft_format_code;
1203 p->ft_fhm = hseg_buffer[FT_FHM];
1204 p->ft_ftm = hseg_buffer[FT_FTM];
1205 p->ft_spt = ft_segments_per_track;
1206 p->ft_tpc = ft_tracks_per_tape;
1207 TRACE_EXIT 0;
1208}
1209
1210static int mtiocftformat(struct mtftformat *mtftformat, int arg_size)
1211{
1212 int result;
1213 union fmt_arg *arg = &mtftformat->fmt_arg;
1214 TRACE_FUN(ft_t_flow);
1215
1216 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCFTFORMAT");
1217 if (zft_offline) {
1218 if (ft_no_tape) {
1219 TRACE_ABORT(-ENXIO, ft_t_info, "no tape present");
1220 } else {
1221 TRACE_ABORT(-ENXIO, ft_t_info, "drive is offline");
1222 }
1223 }
1224 if (zft_qic_mode) {
1225 TRACE_ABORT(-EACCES, ft_t_info,
1226 "driver needs to be in raw mode for this ioctl");
1227 }
1228 if (zft_hseg_buf == NULL) {
1229 TRACE_CATCH(zft_vcalloc_once(&zft_hseg_buf, FT_SEGMENT_SIZE),);
1230 }
1231 zft_header_read = 0;
1232 switch(mtftformat->fmt_op) {
1233 case FTFMT_SET_PARMS:
1234 TRACE_CATCH(set_format_parms(&arg->fmt_parms, zft_hseg_buf),);
1235 TRACE_EXIT 0;
1236 case FTFMT_GET_PARMS:
1237 TRACE_CATCH(get_format_parms(&arg->fmt_parms, zft_hseg_buf),);
1238 TRACE_EXIT 0;
1239 case FTFMT_FORMAT_TRACK:
1240 if ((ft_formatted && zft_check_write_access(&zft_pos) < 0) ||
1241 (!ft_formatted && zft_write_protected)) {
1242 TRACE_ABORT(-EACCES, ft_t_info, "Write access denied");
1243 }
1244 TRACE_CATCH(ftape_format_track(arg->fmt_track.ft_track,
1245 arg->fmt_track.ft_gap3),);
1246 TRACE_EXIT 0;
1247 case FTFMT_STATUS:
1248 TRACE_CATCH(ftape_format_status(&arg->fmt_status.ft_segment),);
1249 TRACE_EXIT 0;
1250 case FTFMT_VERIFY:
1251 TRACE_CATCH(ftape_verify_segment(arg->fmt_verify.ft_segment,
1252 (SectorMap *)&arg->fmt_verify.ft_bsm),);
1253 TRACE_EXIT 0;
1254 default:
1255 TRACE_ABORT(-EINVAL, ft_t_err, "Invalid format operation");
1256 }
1257 TRACE_EXIT result;
1258}
1259#endif
1260
1261#ifdef MTIOCFTCMD
1262/*
1263 * send a QIC-117 command to the drive, with optional timeouts,
1264 * parameter and result bits. This is intended to be used together
1265 * with the formatting ioctl.
1266 */
1267static int mtiocftcmd(struct mtftcmd *ftcmd, int arg_size)
1268{
1269 int i;
1270 TRACE_FUN(ft_t_flow);
1271
1272 TRACE(ft_t_noise, "Mag tape ioctl command: MTIOCFTCMD");
1273 if (!capable(CAP_SYS_ADMIN)) {
1274 TRACE_ABORT(-EPERM, ft_t_info,
1275 "need CAP_SYS_ADMIN capability to send raw qic-117 commands");
1276 }
1277 if (zft_qic_mode) {
1278 TRACE_ABORT(-EACCES, ft_t_info,
1279 "driver needs to be in raw mode for this ioctl");
1280 }
1281 if (arg_size != sizeof(struct mtftcmd)) {
1282 TRACE_ABORT(-EINVAL,
1283 ft_t_info, "bad argument size: %d", arg_size);
1284 }
1285 if (ftcmd->ft_wait_before) {
1286 TRACE_CATCH(ftape_ready_wait(ftcmd->ft_wait_before,
1287 &ftcmd->ft_status),);
1288 }
1289 if (ftcmd->ft_status & QIC_STATUS_ERROR)
1290 goto ftmtcmd_error;
1291 if (ftcmd->ft_result_bits != 0) {
1292 TRACE_CATCH(ftape_report_operation(&ftcmd->ft_result,
1293 ftcmd->ft_cmd,
1294 ftcmd->ft_result_bits),);
1295 } else {
1296 TRACE_CATCH(ftape_command(ftcmd->ft_cmd),);
1297 if (ftcmd->ft_status & QIC_STATUS_ERROR)
1298 goto ftmtcmd_error;
1299 for (i = 0; i < ftcmd->ft_parm_cnt; i++) {
1300 TRACE_CATCH(ftape_parameter(ftcmd->ft_parms[i]&0x0f),);
1301 if (ftcmd->ft_status & QIC_STATUS_ERROR)
1302 goto ftmtcmd_error;
1303 }
1304 }
1305 if (ftcmd->ft_wait_after != 0) {
1306 TRACE_CATCH(ftape_ready_wait(ftcmd->ft_wait_after,
1307 &ftcmd->ft_status),);
1308 }
1309ftmtcmd_error:
1310 if (ftcmd->ft_status & QIC_STATUS_ERROR) {
1311 TRACE(ft_t_noise, "error status set");
1312 TRACE_CATCH(ftape_report_error(&ftcmd->ft_error,
1313 &ftcmd->ft_cmd, 1),);
1314 }
1315 TRACE_EXIT 0; /* this is not an i/o error */
1316}
1317#endif
1318
1319/* IOCTL routine called by kernel-interface code
1320 */
1321int _zft_ioctl(unsigned int command, void __user * arg)
1322{
1323 int result;
1324 union { struct mtop mtop;
1325 struct mtget mtget;
1326 struct mtpos mtpos;
1327#ifdef MTIOCRDFTSEG
1328 struct mtftseg mtftseg;
1329#endif
1330#ifdef MTIOCVOLINFO
1331 struct mtvolinfo mtvolinfo;
1332#endif
1333#ifdef MTIOCGETSIZE
1334 struct mttapesize mttapesize;
1335#endif
1336#ifdef MTIOCFTFORMAT
1337 struct mtftformat mtftformat;
1338#endif
1339#ifdef ZFT_OBSOLETE
1340 struct mtblksz mtblksz;
1341#endif
1342#ifdef MTIOCFTCMD
1343 struct mtftcmd mtftcmd;
1344#endif
1345 } krnl_arg;
1346 int arg_size = _IOC_SIZE(command);
1347 int dir = _IOC_DIR(command);
1348 TRACE_FUN(ft_t_flow);
1349
1350 /* This check will only catch arguments that are too large !
1351 */
1352 if (dir & (_IOC_READ | _IOC_WRITE) && arg_size > sizeof(krnl_arg)) {
1353 TRACE_ABORT(-EINVAL,
1354 ft_t_info, "bad argument size: %d", arg_size);
1355 }
1356 if (dir & _IOC_WRITE) {
1357 if (copy_from_user(&krnl_arg, arg, arg_size) != 0) {
1358 TRACE_EXIT -EFAULT;
1359 }
1360 }
1361 TRACE(ft_t_flow, "called with ioctl command: 0x%08x", command);
1362 switch (command) {
1363 case MTIOCTOP:
1364 result = mtioctop(&krnl_arg.mtop, arg_size);
1365 break;
1366 case MTIOCGET:
1367 result = mtiocget(&krnl_arg.mtget, arg_size);
1368 break;
1369 case MTIOCPOS:
1370 result = mtiocpos(&krnl_arg.mtpos, arg_size);
1371 break;
1372#ifdef MTIOCVOLINFO
1373 case MTIOCVOLINFO:
1374 result = mtiocvolinfo(&krnl_arg.mtvolinfo, arg_size);
1375 break;
1376#endif
1377#ifdef ZFT_OBSOLETE
1378 case MTIOC_ZFTAPE_GETBLKSZ:
1379 result = mtioc_zftape_getblksz(&krnl_arg.mtblksz, arg_size);
1380 break;
1381#endif
1382#ifdef MTIOCRDFTSEG
1383 case MTIOCRDFTSEG: /* read a segment via ioctl */
1384 result = mtiocrdftseg(&krnl_arg.mtftseg, arg_size);
1385 break;
1386#endif
1387#ifdef MTIOCWRFTSEG
1388 case MTIOCWRFTSEG: /* write a segment via ioctl */
1389 result = mtiocwrftseg(&krnl_arg.mtftseg, arg_size);
1390 break;
1391#endif
1392#ifdef MTIOCGETSIZE
1393 case MTIOCGETSIZE:
1394 result = mtiocgetsize(&krnl_arg.mttapesize, arg_size);
1395 break;
1396#endif
1397#ifdef MTIOCFTFORMAT
1398 case MTIOCFTFORMAT:
1399 result = mtiocftformat(&krnl_arg.mtftformat, arg_size);
1400 break;
1401#endif
1402#ifdef MTIOCFTCMD
1403 case MTIOCFTCMD:
1404 result = mtiocftcmd(&krnl_arg.mtftcmd, arg_size);
1405 break;
1406#endif
1407 default:
1408 result = -EINVAL;
1409 break;
1410 }
1411 if ((result >= 0) && (dir & _IOC_READ)) {
1412 if (copy_to_user(arg, &krnl_arg, arg_size) != 0) {
1413 TRACE_EXIT -EFAULT;
1414 }
1415 }
1416 TRACE_EXIT result;
1417}
diff --git a/drivers/char/ftape/zftape/zftape-ctl.h b/drivers/char/ftape/zftape/zftape-ctl.h
deleted file mode 100644
index 8e6f2d7ac74e..000000000000
--- a/drivers/char/ftape/zftape/zftape-ctl.h
+++ /dev/null
@@ -1,58 +0,0 @@
1#ifndef _ZFTAPE_CTL_H
2#define _ZFTAPE_CTL_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-ctl.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:02 $
25 *
26 * This file contains the non-standard IOCTL related definitions
27 * for the QIC-40/80 floppy-tape driver for Linux.
28 */
29
30#include <linux/ioctl.h>
31#include <linux/mtio.h>
32
33#include "../zftape/zftape-rw.h"
34
35#ifdef CONFIG_ZFTAPE_MODULE
36#define ftape_status (*zft_status)
37#endif
38
39extern int zft_offline;
40extern int zft_mt_compression;
41extern int zft_write_protected;
42extern int zft_header_read;
43extern unsigned int zft_unit;
44extern int zft_resid;
45
46extern void zft_reset_position(zft_position *pos);
47extern int zft_check_write_access(zft_position *pos);
48extern int zft_def_idle_state(void);
49
50/* hooks for the VFS interface
51 */
52extern int _zft_open(unsigned int dev_minor, unsigned int access_mode);
53extern int _zft_close(void);
54extern int _zft_ioctl(unsigned int command, void __user *arg);
55#endif
56
57
58
diff --git a/drivers/char/ftape/zftape/zftape-eof.c b/drivers/char/ftape/zftape/zftape-eof.c
deleted file mode 100644
index dcadcaee9ac1..000000000000
--- a/drivers/char/ftape/zftape/zftape-eof.c
+++ /dev/null
@@ -1,199 +0,0 @@
1/*
2 * I use these routines just to decide when I have to fake a
3 * volume-table to preserve compatibility to original ftape.
4 */
5/*
6 * Copyright (C) 1994-1995 Bas Laarhoven.
7 *
8 * Modified for zftape 1996, 1997 Claus Heine.
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, or (at your option)
13 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; see the file COPYING. If not, write to
22 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-eof.c,v $
25 * $Revision: 1.2 $
26 * $Date: 1997/10/05 19:19:02 $
27 *
28 * This file contains the eof mark handling code
29 * for the QIC-40/80 floppy-tape driver for Linux.
30 */
31
32#include <linux/string.h>
33#include <linux/errno.h>
34
35#include <linux/zftape.h>
36
37#include "../zftape/zftape-init.h"
38#include "../zftape/zftape-rw.h"
39#include "../zftape/zftape-eof.h"
40
41/* Global vars.
42 */
43
44/* a copy of the failed sector log from the header segment.
45 */
46eof_mark_union *zft_eof_map;
47
48/* number of eof marks (entries in bad sector log) on tape.
49 */
50int zft_nr_eof_marks = -1;
51
52
53/* Local vars.
54 */
55
56static char linux_tape_label[] = "Linux raw format V";
57enum {
58 min_fmt_version = 1, max_fmt_version = 2
59};
60static unsigned ftape_fmt_version = 0;
61
62
63/* Ftape (mis)uses the bad sector log to record end-of-file marks.
64 * Initially (when the tape is erased) all entries in the bad sector
65 * log are added to the tape's bad sector map. The bad sector log then
66 * is cleared.
67 *
68 * The bad sector log normally contains entries of the form:
69 * even 16-bit word: segment number of bad sector
70 * odd 16-bit word: encoded date
71 * There can be a total of 448 entries (1792 bytes).
72 *
73 * My guess is that no program is using this bad sector log (the *
74 * format seems useless as there is no indication of the bad sector
75 * itself, only the segment) However, if any program does use the bad
76 * sector log, the format used by ftape will let the program think
77 * there are some bad sectors and no harm is done.
78 *
79 * The eof mark entries that ftape stores in the bad sector log: even
80 * 16-bit word: segment number of eof mark odd 16-bit word: sector
81 * number of eof mark [1..32]
82 *
83 * The zft_eof_map as maintained is a sorted list of eof mark entries.
84 *
85 *
86 * The tape name field in the header segments is used to store a linux
87 * tape identification string and a version number. This way the tape
88 * can be recognized as a Linux raw format tape when using tools under
89 * other OS's.
90 *
91 * 'Wide' QIC tapes (format code 4) don't have a failed sector list
92 * anymore. That space is used for the (longer) bad sector map that
93 * now is a variable length list too. We now store our end-of-file
94 * marker list after the bad-sector-map on tape. The list is delimited
95 * by a (__u32) 0 entry.
96 */
97
98int zft_ftape_validate_label(char *label)
99{
100 static char tmp_label[45];
101 int result = 0;
102 TRACE_FUN(ft_t_any);
103
104 memcpy(tmp_label, label, FT_LABEL_SZ);
105 tmp_label[FT_LABEL_SZ] = '\0';
106 TRACE(ft_t_noise, "tape label = `%s'", tmp_label);
107 ftape_fmt_version = 0;
108 if (memcmp(label, linux_tape_label, strlen(linux_tape_label)) == 0) {
109 int pos = strlen(linux_tape_label);
110 while (label[pos] >= '0' && label[pos] <= '9') {
111 ftape_fmt_version *= 10;
112 ftape_fmt_version = label[ pos++] - '0';
113 }
114 result = (ftape_fmt_version >= min_fmt_version &&
115 ftape_fmt_version <= max_fmt_version);
116 }
117 TRACE(ft_t_noise, "format version = %d", ftape_fmt_version);
118 TRACE_EXIT result;
119}
120
121static __u8 * find_end_of_eof_list(__u8 * ptr, __u8 * limit)
122{
123 while (ptr + 3 < limit) {
124
125 if (get_unaligned((__u32*)ptr)) {
126 ptr += sizeof(__u32);
127 } else {
128 return ptr;
129 }
130 }
131 return NULL;
132}
133
134void zft_ftape_extract_file_marks(__u8* address)
135{
136 int i;
137 TRACE_FUN(ft_t_any);
138
139 zft_eof_map = NULL;
140 if (ft_format_code == fmt_var || ft_format_code == fmt_big) {
141 __u8* end;
142 __u8* start = ftape_find_end_of_bsm_list(address);
143
144 zft_nr_eof_marks = 0;
145 if (start) {
146 start += 3; /* skip end of list mark */
147 end = find_end_of_eof_list(start,
148 address + FT_SEGMENT_SIZE);
149 if (end && end - start <= FT_FSL_SIZE) {
150 zft_nr_eof_marks = ((end - start) /
151 sizeof(eof_mark_union));
152 zft_eof_map = (eof_mark_union *)start;
153 } else {
154 TRACE(ft_t_err,
155 "EOF Mark List is too long or damaged!");
156 }
157 } else {
158 TRACE(ft_t_err,
159 "Bad Sector List is too long or damaged !");
160 }
161 } else {
162 zft_eof_map = (eof_mark_union *)&address[FT_FSL];
163 zft_nr_eof_marks = GET2(address, FT_FSL_CNT);
164 }
165 TRACE(ft_t_noise, "number of file marks: %d", zft_nr_eof_marks);
166 if (ftape_fmt_version == 1) {
167 TRACE(ft_t_info, "swapping version 1 fields");
168 /* version 1 format uses swapped sector and segment
169 * fields, correct that !
170 */
171 for (i = 0; i < zft_nr_eof_marks; ++i) {
172 __u16 tmp = GET2(&zft_eof_map[i].mark.segment,0);
173 PUT2(&zft_eof_map[i].mark.segment, 0,
174 GET2(&zft_eof_map[i].mark.date,0));
175 PUT2(&zft_eof_map[i].mark.date, 0, tmp);
176 }
177 }
178 for (i = 0; i < zft_nr_eof_marks; ++i) {
179 TRACE(ft_t_noise, "eof mark: %5d/%2d",
180 GET2(&zft_eof_map[i].mark.segment, 0),
181 GET2(&zft_eof_map[i].mark.date,0));
182 }
183 TRACE_EXIT;
184}
185
186void zft_clear_ftape_file_marks(void)
187{
188 TRACE_FUN(ft_t_flow);
189 /* Clear failed sector log: remove all tape marks. We
190 * don't use old ftape-style EOF-marks.
191 */
192 TRACE(ft_t_info, "Clearing old ftape's eof map");
193 memset(zft_eof_map, 0, zft_nr_eof_marks * sizeof(__u32));
194 zft_nr_eof_marks = 0;
195 PUT2(zft_hseg_buf, FT_FSL_CNT, 0); /* nr of eof-marks */
196 zft_header_changed = 1;
197 zft_update_label(zft_hseg_buf);
198 TRACE_EXIT;
199}
diff --git a/drivers/char/ftape/zftape/zftape-eof.h b/drivers/char/ftape/zftape/zftape-eof.h
deleted file mode 100644
index 26568c26c518..000000000000
--- a/drivers/char/ftape/zftape/zftape-eof.h
+++ /dev/null
@@ -1,52 +0,0 @@
1#ifndef _ZFTAPE_EOF_H
2#define _ZFTAPE_EOF_H
3
4/*
5 * Copyright (C) 1994-1995 Bas Laarhoven.
6 * adaptaed for zftape 1996, 1997 by Claus Heine
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-eof.h,v $
24 * $Revision: 1.2 $
25 * $Date: 1997/10/05 19:19:03 $
26 *
27 * Definitions and declarations for the end of file markers
28 * for the QIC-40/80 floppy-tape driver for Linux.
29 */
30
31#include <linux/ftape-header-segment.h>
32#include "../zftape/zftape-buffers.h"
33/* failed sector log size (only used if format code != 4).
34 */
35
36typedef union {
37 ft_fsl_entry mark;
38 __u32 entry;
39} eof_mark_union;
40
41/* ftape-eof.c defined global vars.
42 */
43extern int zft_nr_eof_marks;
44extern eof_mark_union *zft_eof_map;
45
46/* ftape-eof.c defined global functions.
47 */
48extern void zft_ftape_extract_file_marks(__u8* address);
49extern int zft_ftape_validate_label(char* label);
50extern void zft_clear_ftape_file_marks(void);
51
52#endif
diff --git a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
deleted file mode 100644
index 164a1aa77a2f..000000000000
--- a/drivers/char/ftape/zftape/zftape-init.c
+++ /dev/null
@@ -1,377 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine.
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * This file contains the code that registers the zftape frontend
20 * to the ftape floppy tape driver for Linux
21 */
22
23#include <linux/module.h>
24#include <linux/errno.h>
25#include <linux/fs.h>
26#include <linux/kernel.h>
27#include <linux/signal.h>
28#include <linux/major.h>
29#include <linux/slab.h>
30#ifdef CONFIG_KMOD
31#include <linux/kmod.h>
32#endif
33#include <linux/fcntl.h>
34#include <linux/smp_lock.h>
35
36#include <linux/zftape.h>
37#include <linux/init.h>
38#include <linux/device.h>
39
40#include "../zftape/zftape-init.h"
41#include "../zftape/zftape-read.h"
42#include "../zftape/zftape-write.h"
43#include "../zftape/zftape-ctl.h"
44#include "../zftape/zftape-buffers.h"
45
46MODULE_AUTHOR("(c) 1996, 1997 Claus-Justus Heine "
47 "(claus@momo.math.rwth-aachen.de)");
48MODULE_DESCRIPTION(ZFTAPE_VERSION " - "
49 "VFS interface for the Linux floppy tape driver. "
50 "Support for QIC-113 compatible volume table "
51 "and builtin compression (lzrw3 algorithm)");
52MODULE_SUPPORTED_DEVICE("char-major-27");
53MODULE_LICENSE("GPL");
54
55/* Global vars.
56 */
57struct zft_cmpr_ops *zft_cmpr_ops = NULL;
58const ftape_info *zft_status;
59
60/* Local vars.
61 */
62static unsigned long busy_flag;
63
64static sigset_t orig_sigmask;
65
66/* the interface to the kernel vfs layer
67 */
68
69/* Note about llseek():
70 *
71 * st.c and tpqic.c update fp->f_pos but don't implment llseek() and
72 * initialize the llseek component of the file_ops struct with NULL.
73 * This means that the user will get the default seek, but the tape
74 * device will not respect the new position, but happily read from the
75 * old position. Think a zftape specific llseek() function would be
76 * better, returning -ESPIPE. TODO.
77 */
78
79static int zft_open (struct inode *ino, struct file *filep);
80static int zft_close(struct inode *ino, struct file *filep);
81static int zft_ioctl(struct inode *ino, struct file *filep,
82 unsigned int command, unsigned long arg);
83static int zft_mmap(struct file *filep, struct vm_area_struct *vma);
84static ssize_t zft_read (struct file *fp, char __user *buff,
85 size_t req_len, loff_t *ppos);
86static ssize_t zft_write(struct file *fp, const char __user *buff,
87 size_t req_len, loff_t *ppos);
88
89static const struct file_operations zft_cdev =
90{
91 .owner = THIS_MODULE,
92 .read = zft_read,
93 .write = zft_write,
94 .ioctl = zft_ioctl,
95 .mmap = zft_mmap,
96 .open = zft_open,
97 .release = zft_close,
98};
99
100static struct class *zft_class;
101
102/* Open floppy tape device
103 */
104static int zft_open(struct inode *ino, struct file *filep)
105{
106 int result;
107 TRACE_FUN(ft_t_flow);
108
109 nonseekable_open(ino, filep);
110 TRACE(ft_t_flow, "called for minor %d", iminor(ino));
111 if ( test_and_set_bit(0,&busy_flag) ) {
112 TRACE_ABORT(-EBUSY, ft_t_warn, "failed: already busy");
113 }
114 if ((iminor(ino) & ~(ZFT_MINOR_OP_MASK | FTAPE_NO_REWIND))
115 >
116 FTAPE_SEL_D) {
117 clear_bit(0,&busy_flag);
118 TRACE_ABORT(-ENXIO, ft_t_err, "failed: invalid unit nr");
119 }
120 orig_sigmask = current->blocked;
121 sigfillset(&current->blocked);
122 result = _zft_open(iminor(ino), filep->f_flags & O_ACCMODE);
123 if (result < 0) {
124 current->blocked = orig_sigmask; /* restore mask */
125 clear_bit(0,&busy_flag);
126 TRACE_ABORT(result, ft_t_err, "_ftape_open failed");
127 } else {
128 /* Mask signals that will disturb proper operation of the
129 * program that is calling.
130 */
131 current->blocked = orig_sigmask;
132 sigaddsetmask (&current->blocked, _DO_BLOCK);
133 TRACE_EXIT 0;
134 }
135}
136
137/* Close floppy tape device
138 */
139static int zft_close(struct inode *ino, struct file *filep)
140{
141 int result;
142 TRACE_FUN(ft_t_flow);
143
144 if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit) {
145 TRACE(ft_t_err, "failed: not busy or wrong unit");
146 TRACE_EXIT 0;
147 }
148 sigfillset(&current->blocked);
149 result = _zft_close();
150 if (result < 0) {
151 TRACE(ft_t_err, "_zft_close failed");
152 }
153 current->blocked = orig_sigmask; /* restore before open state */
154 clear_bit(0,&busy_flag);
155 TRACE_EXIT 0;
156}
157
158/* Ioctl for floppy tape device
159 */
160static int zft_ioctl(struct inode *ino, struct file *filep,
161 unsigned int command, unsigned long arg)
162{
163 int result = -EIO;
164 sigset_t old_sigmask;
165 TRACE_FUN(ft_t_flow);
166
167 if ( !test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
168 TRACE_ABORT(-EIO, ft_t_err,
169 "failed: not busy, failure or wrong unit");
170 }
171 old_sigmask = current->blocked; /* save mask */
172 sigfillset(&current->blocked);
173 /* This will work as long as sizeof(void *) == sizeof(long) */
174 result = _zft_ioctl(command, (void __user *) arg);
175 current->blocked = old_sigmask; /* restore mask */
176 TRACE_EXIT result;
177}
178
179/* Ioctl for floppy tape device
180 */
181static int zft_mmap(struct file *filep, struct vm_area_struct *vma)
182{
183 int result = -EIO;
184 sigset_t old_sigmask;
185 TRACE_FUN(ft_t_flow);
186
187 if ( !test_bit(0,&busy_flag) ||
188 iminor(filep->f_dentry->d_inode) != zft_unit ||
189 ft_failure)
190 {
191 TRACE_ABORT(-EIO, ft_t_err,
192 "failed: not busy, failure or wrong unit");
193 }
194 old_sigmask = current->blocked; /* save mask */
195 sigfillset(&current->blocked);
196 if ((result = ftape_mmap(vma)) >= 0) {
197#ifndef MSYNC_BUG_WAS_FIXED
198 static struct vm_operations_struct dummy = { NULL, };
199 vma->vm_ops = &dummy;
200#endif
201 }
202 current->blocked = old_sigmask; /* restore mask */
203 TRACE_EXIT result;
204}
205
206/* Read from floppy tape device
207 */
208static ssize_t zft_read(struct file *fp, char __user *buff,
209 size_t req_len, loff_t *ppos)
210{
211 int result = -EIO;
212 sigset_t old_sigmask;
213 struct inode *ino = fp->f_dentry->d_inode;
214 TRACE_FUN(ft_t_flow);
215
216 TRACE(ft_t_data_flow, "called with count: %ld", (unsigned long)req_len);
217 if (!test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
218 TRACE_ABORT(-EIO, ft_t_err,
219 "failed: not busy, failure or wrong unit");
220 }
221 old_sigmask = current->blocked; /* save mask */
222 sigfillset(&current->blocked);
223 result = _zft_read(buff, req_len);
224 current->blocked = old_sigmask; /* restore mask */
225 TRACE(ft_t_data_flow, "return with count: %d", result);
226 TRACE_EXIT result;
227}
228
229/* Write to tape device
230 */
231static ssize_t zft_write(struct file *fp, const char __user *buff,
232 size_t req_len, loff_t *ppos)
233{
234 int result = -EIO;
235 sigset_t old_sigmask;
236 struct inode *ino = fp->f_dentry->d_inode;
237 TRACE_FUN(ft_t_flow);
238
239 TRACE(ft_t_flow, "called with count: %ld", (unsigned long)req_len);
240 if (!test_bit(0,&busy_flag) || iminor(ino) != zft_unit || ft_failure) {
241 TRACE_ABORT(-EIO, ft_t_err,
242 "failed: not busy, failure or wrong unit");
243 }
244 old_sigmask = current->blocked; /* save mask */
245 sigfillset(&current->blocked);
246 result = _zft_write(buff, req_len);
247 current->blocked = old_sigmask; /* restore mask */
248 TRACE(ft_t_data_flow, "return with count: %d", result);
249 TRACE_EXIT result;
250}
251
252/* END OF VFS INTERFACE
253 *
254 *****************************************************************************/
255
256/* driver/module initialization
257 */
258
259/* the compression module has to call this function to hook into the zftape
260 * code
261 */
262int zft_cmpr_register(struct zft_cmpr_ops *new_ops)
263{
264 TRACE_FUN(ft_t_flow);
265
266 if (zft_cmpr_ops != NULL) {
267 TRACE_EXIT -EBUSY;
268 } else {
269 zft_cmpr_ops = new_ops;
270 TRACE_EXIT 0;
271 }
272}
273
274/* lock the zft-compressor() module.
275 */
276int zft_cmpr_lock(int try_to_load)
277{
278 if (zft_cmpr_ops == NULL) {
279#ifdef CONFIG_KMOD
280 if (try_to_load) {
281 request_module("zft-compressor");
282 if (zft_cmpr_ops == NULL) {
283 return -ENOSYS;
284 }
285 } else {
286 return -ENOSYS;
287 }
288#else
289 return -ENOSYS;
290#endif
291 }
292 (*zft_cmpr_ops->lock)();
293 return 0;
294}
295
296#ifdef CONFIG_ZFT_COMPRESSOR
297extern int zft_compressor_init(void);
298#endif
299
300/* Called by modules package when installing the driver or by kernel
301 * during the initialization phase
302 */
303int __init zft_init(void)
304{
305 int i;
306 TRACE_FUN(ft_t_flow);
307
308#ifdef MODULE
309 printk(KERN_INFO ZFTAPE_VERSION "\n");
310 if (TRACE_LEVEL >= ft_t_info) {
311 printk(
312KERN_INFO
313"(c) 1996, 1997 Claus-Justus Heine (claus@momo.math.rwth-aachen.de)\n"
314KERN_INFO
315"vfs interface for ftape floppy tape driver.\n"
316KERN_INFO
317"Support for QIC-113 compatible volume table, dynamic memory allocation\n"
318KERN_INFO
319"and builtin compression (lzrw3 algorithm).\n");
320 }
321#else /* !MODULE */
322 /* print a short no-nonsense boot message */
323 printk(KERN_INFO ZFTAPE_VERSION "\n");
324#endif /* MODULE */
325 TRACE(ft_t_info, "zft_init @ 0x%p", zft_init);
326 TRACE(ft_t_info,
327 "installing zftape VFS interface for ftape driver ...");
328 TRACE_CATCH(register_chrdev(QIC117_TAPE_MAJOR, "zft", &zft_cdev),);
329
330 zft_class = class_create(THIS_MODULE, "zft");
331 for (i = 0; i < 4; i++) {
332 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
333 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
334 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
335 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
336 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
337 class_device_create(zft_class, NULL, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
338 }
339
340#ifdef CONFIG_ZFT_COMPRESSOR
341 (void)zft_compressor_init();
342#endif
343 zft_status = ftape_get_status(); /* fetch global data of ftape
344 * hardware driver
345 */
346 TRACE_EXIT 0;
347}
348
349
350/* Called by modules package when removing the driver
351 */
352static void zft_exit(void)
353{
354 int i;
355 TRACE_FUN(ft_t_flow);
356
357 if (unregister_chrdev(QIC117_TAPE_MAJOR, "zft") != 0) {
358 TRACE(ft_t_warn, "failed");
359 } else {
360 TRACE(ft_t_info, "successful");
361 }
362 for (i = 0; i < 4; i++) {
363 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i));
364 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4));
365 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16));
366 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20));
367 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32));
368 class_device_destroy(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36));
369 }
370 class_destroy(zft_class);
371 zft_uninit_mem(); /* release remaining memory, if any */
372 printk(KERN_INFO "zftape successfully unloaded.\n");
373 TRACE_EXIT;
374}
375
376module_init(zft_init);
377module_exit(zft_exit);
diff --git a/drivers/char/ftape/zftape/zftape-init.h b/drivers/char/ftape/zftape/zftape-init.h
deleted file mode 100644
index 937e5d48c20e..000000000000
--- a/drivers/char/ftape/zftape/zftape-init.h
+++ /dev/null
@@ -1,77 +0,0 @@
1#ifndef _ZFTAPE_INIT_H
2#define _ZFTAPE_INIT_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus Heine.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-init.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:05 $
25 *
26 * This file contains definitions and macro for the vfs
27 * interface defined by zftape
28 *
29 */
30
31#include <linux/ftape-header-segment.h>
32
33#include "../lowlevel/ftape-tracing.h"
34#include "../lowlevel/ftape-ctl.h"
35#include "../lowlevel/ftape-read.h"
36#include "../lowlevel/ftape-write.h"
37#include "../lowlevel/ftape-bsm.h"
38#include "../lowlevel/ftape-io.h"
39#include "../lowlevel/ftape-buffer.h"
40#include "../lowlevel/ftape-format.h"
41
42#include "../zftape/zftape-rw.h"
43
44#ifdef MODULE
45#define ftape_status (*zft_status)
46#endif
47
48extern const ftape_info *zft_status; /* needed for zftape-vtbl.h */
49
50#include "../zftape/zftape-vtbl.h"
51
52struct zft_cmpr_ops {
53 int (*write)(int *write_cnt,
54 __u8 *dst_buf, const int seg_sz,
55 const __u8 __user *src_buf, const int req_len,
56 const zft_position *pos, const zft_volinfo *volume);
57 int (*read)(int *read_cnt,
58 __u8 __user *dst_buf, const int req_len,
59 const __u8 *src_buf, const int seg_sz,
60 const zft_position *pos, const zft_volinfo *volume);
61 int (*seek)(unsigned int new_block_pos,
62 zft_position *pos, const zft_volinfo *volume,
63 __u8 *buffer);
64 void (*lock) (void);
65 void (*reset) (void);
66 void (*cleanup)(void);
67};
68
69extern struct zft_cmpr_ops *zft_cmpr_ops;
70/* zftape-init.c defined global functions.
71 */
72extern int zft_cmpr_register(struct zft_cmpr_ops *new_ops);
73extern int zft_cmpr_lock(int try_to_load);
74
75#endif
76
77
diff --git a/drivers/char/ftape/zftape/zftape-read.c b/drivers/char/ftape/zftape/zftape-read.c
deleted file mode 100644
index 214bf03dce68..000000000000
--- a/drivers/char/ftape/zftape/zftape-read.c
+++ /dev/null
@@ -1,377 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-read.c,v $
20 * $Revision: 1.2 $
21 * $Date: 1997/10/05 19:19:06 $
22 *
23 * This file contains the high level reading code
24 * for the QIC-117 floppy-tape driver for Linux.
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29
30#include <linux/zftape.h>
31
32#include <asm/uaccess.h>
33
34#include "../zftape/zftape-init.h"
35#include "../zftape/zftape-eof.h"
36#include "../zftape/zftape-ctl.h"
37#include "../zftape/zftape-write.h"
38#include "../zftape/zftape-read.h"
39#include "../zftape/zftape-rw.h"
40#include "../zftape/zftape-vtbl.h"
41
42/* Global vars.
43 */
44int zft_just_before_eof;
45
46/* Local vars.
47 */
48static int buf_len_rd;
49
50void zft_zap_read_buffers(void)
51{
52 buf_len_rd = 0;
53}
54
55int zft_read_header_segments(void)
56{
57 TRACE_FUN(ft_t_flow);
58
59 zft_header_read = 0;
60 TRACE_CATCH(zft_vmalloc_once(&zft_hseg_buf, FT_SEGMENT_SIZE),);
61 TRACE_CATCH(ftape_read_header_segment(zft_hseg_buf),);
62 TRACE(ft_t_info, "Segments written since first format: %d",
63 (int)GET4(zft_hseg_buf, FT_SEG_CNT));
64 zft_qic113 = (ft_format_code != fmt_normal &&
65 ft_format_code != fmt_1100ft &&
66 ft_format_code != fmt_425ft);
67 TRACE(ft_t_info, "ft_first_data_segment: %d, ft_last_data_segment: %d",
68 ft_first_data_segment, ft_last_data_segment);
69 zft_capacity = zft_get_capacity();
70 zft_old_ftape = zft_ftape_validate_label(&zft_hseg_buf[FT_LABEL]);
71 if (zft_old_ftape) {
72 TRACE(ft_t_info,
73"Found old ftaped tape, emulating eof marks, entering read-only mode");
74 zft_ftape_extract_file_marks(zft_hseg_buf);
75 TRACE_CATCH(zft_fake_volume_headers(zft_eof_map,
76 zft_nr_eof_marks),);
77 } else {
78 /* the specs say that the volume table must be
79 * initialized with zeroes during formatting, so it
80 * MUST be readable, i.e. contain vaid ECC
81 * information.
82 */
83 TRACE_CATCH(ftape_read_segment(ft_first_data_segment,
84 zft_deblock_buf,
85 FT_RD_SINGLE),);
86 TRACE_CATCH(zft_extract_volume_headers(zft_deblock_buf),);
87 }
88 zft_header_read = 1;
89 zft_set_flags(zft_unit);
90 zft_reset_position(&zft_pos);
91 TRACE_EXIT 0;
92}
93
94int zft_fetch_segment_fraction(const unsigned int segment, void *buffer,
95 const ft_read_mode_t read_mode,
96 const unsigned int start,
97 const unsigned int size)
98{
99 int seg_sz;
100 TRACE_FUN(ft_t_flow);
101
102 if (segment == zft_deblock_segment) {
103 TRACE(ft_t_data_flow,
104 "re-using segment %d already in deblock buffer",
105 segment);
106 seg_sz = zft_get_seg_sz(segment);
107 if (start > seg_sz) {
108 TRACE_ABORT(-EINVAL, ft_t_bug,
109 "trying to read beyond end of segment:\n"
110 KERN_INFO "seg_sz : %d\n"
111 KERN_INFO "start : %d\n"
112 KERN_INFO "segment: %d",
113 seg_sz, start, segment);
114 }
115 if ((start + size) > seg_sz) {
116 TRACE_EXIT seg_sz - start;
117 }
118 TRACE_EXIT size;
119 }
120 seg_sz = ftape_read_segment_fraction(segment, buffer, read_mode,
121 start, size);
122 TRACE(ft_t_data_flow, "segment %d, result %d", segment, seg_sz);
123 if ((int)seg_sz >= 0 && start == 0 && size == FT_SEGMENT_SIZE) {
124 /* this implicitly assumes that we are always called with
125 * buffer == zft_deblock_buf
126 */
127 zft_deblock_segment = segment;
128 } else {
129 zft_deblock_segment = -1;
130 }
131 TRACE_EXIT seg_sz;
132}
133
134/*
135 * out:
136 *
137 * int *read_cnt: the number of bytes we removed from the
138 * zft_deblock_buf (result)
139 *
140 * int *to_do : the remaining size of the read-request. Is changed.
141 *
142 * in:
143 *
144 * char *buff : buff is the address of the upper part of the user
145 * buffer, that hasn't been filled with data yet.
146 * int buf_pos_read: copy of buf_pos_rd
147 * int buf_len_read: copy of buf_len_rd
148 * char *zft_deblock_buf: ftape_zft_deblock_buf
149 *
150 * returns the amount of data actually copied to the user-buffer
151 *
152 * to_do MUST NOT SHRINK except to indicate an EOT. In this case to_do
153 * has to be set to 0. We cannot return -ENOSPC, because we return the
154 * amount of data actually * copied to the user-buffer
155 */
156static int zft_simple_read (int *read_cnt,
157 __u8 __user *dst_buf,
158 const int to_do,
159 const __u8 *src_buf,
160 const int seg_sz,
161 const zft_position *pos,
162 const zft_volinfo *volume)
163{
164 TRACE_FUN(ft_t_flow);
165
166 if (seg_sz - pos->seg_byte_pos < to_do) {
167 *read_cnt = seg_sz - pos->seg_byte_pos;
168 } else {
169 *read_cnt = to_do;
170 }
171 if (copy_to_user(dst_buf,
172 src_buf + pos->seg_byte_pos, *read_cnt) != 0) {
173 TRACE_EXIT -EFAULT;
174 }
175 TRACE(ft_t_noise, "nr bytes just read: %d", *read_cnt);
176 TRACE_EXIT *read_cnt;
177}
178
179/* req_len: gets clipped due to EOT of EOF.
180 * req_clipped: is a flag indicating whether req_len was clipped or not
181 * volume: contains information on current volume (blk_sz etc.)
182 */
183static int check_read_access(int *req_len,
184 const zft_volinfo **volume,
185 int *req_clipped,
186 const zft_position *pos)
187{
188 static __s64 remaining;
189 static int eod;
190 TRACE_FUN(ft_t_flow);
191
192 if (zft_io_state != zft_reading) {
193 if (zft_offline) { /* offline includes no_tape */
194 TRACE_ABORT(-ENXIO, ft_t_warn,
195 "tape is offline or no cartridge");
196 }
197 if (!ft_formatted) {
198 TRACE_ABORT(-EACCES,
199 ft_t_warn, "tape is not formatted");
200 }
201 /* now enter defined state, read header segment if not
202 * already done and flush write buffers
203 */
204 TRACE_CATCH(zft_def_idle_state(),);
205 zft_io_state = zft_reading;
206 if (zft_tape_at_eod(pos)) {
207 eod = 1;
208 TRACE_EXIT 1;
209 }
210 eod = 0;
211 *volume = zft_find_volume(pos->seg_pos);
212 /* get the space left until EOF */
213 remaining = zft_check_for_eof(*volume, pos);
214 buf_len_rd = 0;
215 TRACE(ft_t_noise, "remaining: " LL_X ", vol_no: %d",
216 LL(remaining), (*volume)->count);
217 } else if (zft_tape_at_eod(pos)) {
218 if (++eod > 2) {
219 TRACE_EXIT -EIO; /* st.c also returns -EIO */
220 } else {
221 TRACE_EXIT 1;
222 }
223 }
224 if ((*req_len % (*volume)->blk_sz) != 0) {
225 /* this message is informational only. The user gets the
226 * proper return value
227 */
228 TRACE_ABORT(-EINVAL, ft_t_info,
229 "req_len %d not a multiple of block size %d",
230 *req_len, (*volume)->blk_sz);
231 }
232 /* As GNU tar doesn't accept partial read counts when the
233 * multiple volume flag is set, we make sure to return the
234 * requested amount of data. Except, of course, at the end of
235 * the tape or file mark.
236 */
237 remaining -= *req_len;
238 if (remaining <= 0) {
239 TRACE(ft_t_noise,
240 "clipped request from %d to %d.",
241 *req_len, (int)(*req_len + remaining));
242 *req_len += remaining;
243 *req_clipped = 1;
244 } else {
245 *req_clipped = 0;
246 }
247 TRACE_EXIT 0;
248}
249
250/* this_segs_size: the current segment's size.
251 * buff: the USER-SPACE buffer provided by the calling function.
252 * req_len: how much data should be read at most.
253 * volume: contains information on current volume (blk_sz etc.)
254 */
255static int empty_deblock_buf(__u8 __user *usr_buf, const int req_len,
256 const __u8 *src_buf, const int seg_sz,
257 zft_position *pos,
258 const zft_volinfo *volume)
259{
260 int cnt;
261 int result = 0;
262 TRACE_FUN(ft_t_flow);
263
264 TRACE(ft_t_data_flow, "this_segs_size: %d", seg_sz);
265 if (zft_use_compression && volume->use_compression) {
266 TRACE_CATCH(zft_cmpr_lock(1 /* try to load */),);
267 TRACE_CATCH(result= (*zft_cmpr_ops->read)(&cnt,
268 usr_buf, req_len,
269 src_buf, seg_sz,
270 pos, volume),);
271 } else {
272 TRACE_CATCH(result= zft_simple_read (&cnt,
273 usr_buf, req_len,
274 src_buf, seg_sz,
275 pos, volume),);
276 }
277 pos->volume_pos += result;
278 pos->tape_pos += cnt;
279 pos->seg_byte_pos += cnt;
280 buf_len_rd -= cnt; /* remaining bytes in buffer */
281 TRACE(ft_t_data_flow, "buf_len_rd: %d, cnt: %d", buf_len_rd, cnt);
282 if(pos->seg_byte_pos >= seg_sz) {
283 pos->seg_pos++;
284 pos->seg_byte_pos = 0;
285 }
286 TRACE(ft_t_data_flow, "bytes moved out of deblock-buffer: %d", cnt);
287 TRACE_EXIT result;
288}
289
290
291/* note: we store the segment id of the segment that is inside the
292 * deblock buffer. This spares a lot of ftape_read_segment()s when we
293 * use small block-sizes. The block-size may be 1kb (SECTOR_SIZE). In
294 * this case a MTFSR 28 maybe still inside the same segment.
295 */
296int _zft_read(char __user *buff, int req_len)
297{
298 int req_clipped;
299 int result = 0;
300 int bytes_read = 0;
301 static unsigned int seg_sz = 0;
302 static const zft_volinfo *volume = NULL;
303 TRACE_FUN(ft_t_flow);
304
305 zft_resid = req_len;
306 result = check_read_access(&req_len, &volume,
307 &req_clipped, &zft_pos);
308 switch(result) {
309 case 0:
310 break; /* nothing special */
311 case 1:
312 TRACE(ft_t_noise, "EOD reached");
313 TRACE_EXIT 0; /* EOD */
314 default:
315 TRACE_ABORT(result, ft_t_noise,
316 "check_read_access() failed with result %d",
317 result);
318 TRACE_EXIT result;
319 }
320 while (req_len > 0) {
321 /* Allow escape from this loop on signal !
322 */
323 FT_SIGNAL_EXIT(_DONT_BLOCK);
324 /* buf_len_rd == 0 means that we need to read a new
325 * segment.
326 */
327 if (buf_len_rd == 0) {
328 while((result = zft_fetch_segment(zft_pos.seg_pos,
329 zft_deblock_buf,
330 FT_RD_AHEAD)) == 0) {
331 zft_pos.seg_pos ++;
332 zft_pos.seg_byte_pos = 0;
333 }
334 if (result < 0) {
335 zft_resid -= bytes_read;
336 TRACE_ABORT(result, ft_t_noise,
337 "zft_fetch_segment(): %d",
338 result);
339 }
340 seg_sz = result;
341 buf_len_rd = seg_sz - zft_pos.seg_byte_pos;
342 }
343 TRACE_CATCH(result = empty_deblock_buf(buff,
344 req_len,
345 zft_deblock_buf,
346 seg_sz,
347 &zft_pos,
348 volume),
349 zft_resid -= bytes_read);
350 TRACE(ft_t_data_flow, "bytes just read: %d", result);
351 bytes_read += result; /* what we got so far */
352 buff += result; /* index in user-buffer */
353 req_len -= result; /* what's left from req_len */
354 } /* while (req_len > 0) */
355 if (req_clipped) {
356 TRACE(ft_t_data_flow,
357 "maybe partial count because of eof mark");
358 if (zft_just_before_eof && bytes_read == 0) {
359 /* req_len was > 0, but user didn't get
360 * anything the user has read in the eof-mark
361 */
362 zft_move_past_eof(&zft_pos);
363 ftape_abort_operation();
364 } else {
365 /* don't skip to the next file before the user
366 * tried to read a second time past EOF Just
367 * mark that we are at EOF and maybe decrement
368 * zft_seg_pos to stay in the same volume;
369 */
370 zft_just_before_eof = 1;
371 zft_position_before_eof(&zft_pos, volume);
372 TRACE(ft_t_noise, "just before eof");
373 }
374 }
375 zft_resid -= result; /* for MTSTATUS */
376 TRACE_EXIT bytes_read;
377}
diff --git a/drivers/char/ftape/zftape/zftape-read.h b/drivers/char/ftape/zftape/zftape-read.h
deleted file mode 100644
index 42941de0c23a..000000000000
--- a/drivers/char/ftape/zftape/zftape-read.h
+++ /dev/null
@@ -1,53 +0,0 @@
1#ifndef _ZFTAPE_READ_H
2#define _ZFTAPE_READ_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-read.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:07 $
25 *
26 * This file contains the definitions for the read functions
27 * for the zftape driver for Linux.
28 *
29 */
30
31#include "../lowlevel/ftape-read.h"
32
33/* ftape-read.c defined global vars.
34 */
35extern int zft_just_before_eof;
36
37/* ftape-read.c defined global functions.
38 */
39extern void zft_zap_read_buffers(void);
40extern int zft_read_header_segments(void);
41extern int zft_fetch_segment_fraction(const unsigned int segment,
42 void *buffer,
43 const ft_read_mode_t read_mode,
44 const unsigned int start,
45 const unsigned int size);
46#define zft_fetch_segment(segment, address, read_mode) \
47 zft_fetch_segment_fraction(segment, address, read_mode, \
48 0, FT_SEGMENT_SIZE)
49/* hook for the VFS interface
50 */
51extern int _zft_read(char __user *buff, int req_len);
52
53#endif /* _ZFTAPE_READ_H */
diff --git a/drivers/char/ftape/zftape/zftape-rw.c b/drivers/char/ftape/zftape/zftape-rw.c
deleted file mode 100644
index dab634686885..000000000000
--- a/drivers/char/ftape/zftape/zftape-rw.c
+++ /dev/null
@@ -1,375 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus-Justus Heine
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-rw.c,v $
20 * $Revision: 1.2 $
21 * $Date: 1997/10/05 19:19:08 $
22 *
23 * This file contains some common code for the r/w code for
24 * zftape.
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29
30#include <linux/zftape.h>
31#include "../zftape/zftape-init.h"
32#include "../zftape/zftape-eof.h"
33#include "../zftape/zftape-ctl.h"
34#include "../zftape/zftape-write.h"
35#include "../zftape/zftape-read.h"
36#include "../zftape/zftape-rw.h"
37#include "../zftape/zftape-vtbl.h"
38
39/* Global vars.
40 */
41
42__u8 *zft_deblock_buf;
43__u8 *zft_hseg_buf;
44int zft_deblock_segment = -1;
45zft_status_enum zft_io_state = zft_idle;
46int zft_header_changed;
47int zft_qic113; /* conform to old specs. and old zftape */
48int zft_use_compression;
49zft_position zft_pos = {
50 -1, /* seg_pos */
51 0, /* seg_byte_pos */
52 0, /* tape_pos */
53 0 /* volume_pos */
54};
55unsigned int zft_blk_sz = CONFIG_ZFT_DFLT_BLK_SZ;
56__s64 zft_capacity;
57
58unsigned int zft_written_segments;
59int zft_label_changed;
60
61/* Local vars.
62 */
63
64unsigned int zft_get_seg_sz(unsigned int segment)
65{
66 int size;
67 TRACE_FUN(ft_t_any);
68
69 size = FT_SEGMENT_SIZE -
70 count_ones(ftape_get_bad_sector_entry(segment))*FT_SECTOR_SIZE;
71 if (size > 0) {
72 TRACE_EXIT (unsigned)size;
73 } else {
74 TRACE_EXIT 0;
75 }
76}
77
78/* ftape_set_flags(). Claus-Justus Heine, 1994/1995
79 */
80void zft_set_flags(unsigned minor_unit)
81{
82 TRACE_FUN(ft_t_flow);
83
84 zft_use_compression = zft_qic_mode = 0;
85 switch (minor_unit & ZFT_MINOR_OP_MASK) {
86 case (ZFT_Q80_MODE | ZFT_ZIP_MODE):
87 case ZFT_ZIP_MODE:
88 zft_use_compression = 1;
89 case 0:
90 case ZFT_Q80_MODE:
91 zft_qic_mode = 1;
92 if (zft_mt_compression) { /* override the default */
93 zft_use_compression = 1;
94 }
95 break;
96 case ZFT_RAW_MODE:
97 TRACE(ft_t_noise, "switching to raw mode");
98 break;
99 default:
100 TRACE(ft_t_warn, "Warning:\n"
101 KERN_INFO "Wrong combination of minor device bits.\n"
102 KERN_INFO "Switching to raw read-only mode.");
103 zft_write_protected = 1;
104 break;
105 }
106 TRACE_EXIT;
107}
108
109/* computes the segment and byte offset inside the segment
110 * corresponding to tape_pos.
111 *
112 * tape_pos gives the offset in bytes from the beginning of the
113 * ft_first_data_segment *seg_byte_pos is the offset in the current
114 * segment in bytes
115 *
116 * Of, if this routine was called often one should cache the last data
117 * pos it was called with, but actually this is only needed in
118 * ftape_seek_block(), that is, almost never.
119 */
120int zft_calc_seg_byte_coord(int *seg_byte_pos, __s64 tape_pos)
121{
122 int segment;
123 int seg_sz;
124 TRACE_FUN(ft_t_flow);
125
126 if (tape_pos == 0) {
127 *seg_byte_pos = 0;
128 segment = ft_first_data_segment;
129 } else {
130 seg_sz = 0;
131
132 for (segment = ft_first_data_segment;
133 ((tape_pos > 0) && (segment <= ft_last_data_segment));
134 segment++) {
135 seg_sz = zft_get_seg_sz(segment);
136 tape_pos -= seg_sz;
137 }
138 if(tape_pos >= 0) {
139 /* the case tape_pos > != 0 means that the
140 * argument tape_pos lies beyond the EOT.
141 */
142 *seg_byte_pos= 0;
143 } else { /* tape_pos < 0 */
144 segment--;
145 *seg_byte_pos= tape_pos + seg_sz;
146 }
147 }
148 TRACE_EXIT(segment);
149}
150
151/* ftape_calc_tape_pos().
152 *
153 * computes the offset in bytes from the beginning of the
154 * ft_first_data_segment inverse to ftape_calc_seg_byte_coord
155 *
156 * We should do some caching. But how:
157 *
158 * Each time the header segments are read in, this routine is called
159 * with ft_tracks_per_tape*segments_per_track argumnet. So this should be
160 * the time to reset the cache.
161 *
162 * Also, it might be in the future that the bad sector map gets
163 * changed. -> reset the cache
164 */
165static int seg_pos;
166static __s64 tape_pos;
167
168__s64 zft_get_capacity(void)
169{
170 seg_pos = ft_first_data_segment;
171 tape_pos = 0;
172
173 while (seg_pos <= ft_last_data_segment) {
174 tape_pos += zft_get_seg_sz(seg_pos ++);
175 }
176 return tape_pos;
177}
178
179__s64 zft_calc_tape_pos(int segment)
180{
181 int d1, d2, d3;
182 TRACE_FUN(ft_t_any);
183
184 if (segment > ft_last_data_segment) {
185 TRACE_EXIT zft_capacity;
186 }
187 if (segment < ft_first_data_segment) {
188 TRACE_EXIT 0;
189 }
190 d2 = segment - seg_pos;
191 if (-d2 > 10) {
192 d1 = segment - ft_first_data_segment;
193 if (-d2 > d1) {
194 tape_pos = 0;
195 seg_pos = ft_first_data_segment;
196 d2 = d1;
197 }
198 }
199 if (d2 > 10) {
200 d3 = ft_last_data_segment - segment;
201 if (d2 > d3) {
202 tape_pos = zft_capacity;
203 seg_pos = ft_last_data_segment + 1;
204 d2 = -d3;
205 }
206 }
207 if (d2 > 0) {
208 while (seg_pos < segment) {
209 tape_pos += zft_get_seg_sz(seg_pos++);
210 }
211 } else {
212 while (seg_pos > segment) {
213 tape_pos -= zft_get_seg_sz(--seg_pos);
214 }
215 }
216 TRACE(ft_t_noise, "new cached pos: %d", seg_pos);
217
218 TRACE_EXIT tape_pos;
219}
220
221/* copy Z-label string to buffer, keeps track of the correct offset in
222 * `buffer'
223 */
224void zft_update_label(__u8 *buffer)
225{
226 TRACE_FUN(ft_t_flow);
227
228 if (strncmp(&buffer[FT_LABEL], ZFTAPE_LABEL,
229 sizeof(ZFTAPE_LABEL)-1) != 0) {
230 TRACE(ft_t_info, "updating label from \"%s\" to \"%s\"",
231 &buffer[FT_LABEL], ZFTAPE_LABEL);
232 strcpy(&buffer[FT_LABEL], ZFTAPE_LABEL);
233 memset(&buffer[FT_LABEL] + sizeof(ZFTAPE_LABEL) - 1, ' ',
234 FT_LABEL_SZ - sizeof(ZFTAPE_LABEL + 1));
235 PUT4(buffer, FT_LABEL_DATE, 0);
236 zft_label_changed = zft_header_changed = 1; /* changed */
237 }
238 TRACE_EXIT;
239}
240
241int zft_verify_write_segments(unsigned int segment,
242 __u8 *data, size_t size,
243 __u8 *buffer)
244{
245 int result;
246 __u8 *write_buf;
247 __u8 *src_buf;
248 int single;
249 int seg_pos;
250 int seg_sz;
251 int remaining;
252 ft_write_mode_t write_mode;
253 TRACE_FUN(ft_t_flow);
254
255 seg_pos = segment;
256 seg_sz = zft_get_seg_sz(seg_pos);
257 src_buf = data;
258 single = size <= seg_sz;
259 remaining = size;
260 do {
261 TRACE(ft_t_noise, "\n"
262 KERN_INFO "remaining: %d\n"
263 KERN_INFO "seg_sz : %d\n"
264 KERN_INFO "segment : %d",
265 remaining, seg_sz, seg_pos);
266 if (remaining == seg_sz) {
267 write_buf = src_buf;
268 write_mode = single ? FT_WR_SINGLE : FT_WR_MULTI;
269 remaining = 0;
270 } else if (remaining > seg_sz) {
271 write_buf = src_buf;
272 write_mode = FT_WR_ASYNC; /* don't start tape */
273 remaining -= seg_sz;
274 } else { /* remaining < seg_sz */
275 write_buf = buffer;
276 memcpy(write_buf, src_buf, remaining);
277 memset(&write_buf[remaining],'\0',seg_sz-remaining);
278 write_mode = single ? FT_WR_SINGLE : FT_WR_MULTI;
279 remaining = 0;
280 }
281 if ((result = ftape_write_segment(seg_pos,
282 write_buf,
283 write_mode)) != seg_sz) {
284 TRACE(ft_t_err, "Error: "
285 "Couldn't write segment %d", seg_pos);
286 TRACE_EXIT result < 0 ? result : -EIO; /* bail out */
287 }
288 zft_written_segments ++;
289 seg_sz = zft_get_seg_sz(++seg_pos);
290 src_buf += result;
291 } while (remaining > 0);
292 if (ftape_get_status()->fti_state == writing) {
293 TRACE_CATCH(ftape_loop_until_writes_done(),);
294 TRACE_CATCH(ftape_abort_operation(),);
295 zft_prevent_flush();
296 }
297 seg_pos = segment;
298 src_buf = data;
299 remaining = size;
300 do {
301 TRACE_CATCH(result = ftape_read_segment(seg_pos, buffer,
302 single ? FT_RD_SINGLE
303 : FT_RD_AHEAD),);
304 if (memcmp(src_buf, buffer,
305 remaining > result ? result : remaining) != 0) {
306 TRACE_ABORT(-EIO, ft_t_err,
307 "Failed to verify written segment %d",
308 seg_pos);
309 }
310 remaining -= result;
311 TRACE(ft_t_noise, "verify successful:\n"
312 KERN_INFO "segment : %d\n"
313 KERN_INFO "segsize : %d\n"
314 KERN_INFO "remaining: %d",
315 seg_pos, result, remaining);
316 src_buf += seg_sz;
317 seg_pos++;
318 } while (remaining > 0);
319 TRACE_EXIT size;
320}
321
322
323/* zft_erase(). implemented compression-handling
324 *
325 * calculate the first data-segment when using/not using compression.
326 *
327 * update header-segment and compression-map-segment.
328 */
329int zft_erase(void)
330{
331 int result = 0;
332 TRACE_FUN(ft_t_flow);
333
334 if (!zft_header_read) {
335 TRACE_CATCH(zft_vmalloc_once((void **)&zft_hseg_buf,
336 FT_SEGMENT_SIZE),);
337 /* no need to read the vtbl and compression map */
338 TRACE_CATCH(ftape_read_header_segment(zft_hseg_buf),);
339 if ((zft_old_ftape =
340 zft_ftape_validate_label(&zft_hseg_buf[FT_LABEL]))) {
341 zft_ftape_extract_file_marks(zft_hseg_buf);
342 }
343 TRACE(ft_t_noise,
344 "ft_first_data_segment: %d, ft_last_data_segment: %d",
345 ft_first_data_segment, ft_last_data_segment);
346 zft_qic113 = (ft_format_code != fmt_normal &&
347 ft_format_code != fmt_1100ft &&
348 ft_format_code != fmt_425ft);
349 }
350 if (zft_old_ftape) {
351 zft_clear_ftape_file_marks();
352 zft_old_ftape = 0; /* no longer old ftape */
353 }
354 PUT2(zft_hseg_buf, FT_CMAP_START, 0);
355 zft_volume_table_changed = 1;
356 zft_capacity = zft_get_capacity();
357 zft_init_vtbl();
358 /* the rest must be done in ftape_update_header_segments
359 */
360 zft_header_read = 1;
361 zft_header_changed = 1; /* force update of timestamp */
362 result = zft_update_header_segments();
363
364 ftape_abort_operation();
365
366 zft_reset_position(&zft_pos);
367 zft_set_flags (zft_unit);
368 TRACE_EXIT result;
369}
370
371unsigned int zft_get_time(void)
372{
373 unsigned int date = FT_TIME_STAMP(2097, 11, 30, 23, 59, 59); /* fun */
374 return date;
375}
diff --git a/drivers/char/ftape/zftape/zftape-rw.h b/drivers/char/ftape/zftape/zftape-rw.h
deleted file mode 100644
index 1ceec22b60bd..000000000000
--- a/drivers/char/ftape/zftape/zftape-rw.h
+++ /dev/null
@@ -1,101 +0,0 @@
1#ifndef _ZFTAPE_RW_H
2#define _ZFTAPE_RW_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-rw.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:09 $
25 *
26 * This file contains the definitions for the read and write
27 * functions for the QIC-117 floppy-tape driver for Linux.
28 *
29 */
30
31#include "../zftape/zftape-buffers.h"
32
33#define SEGMENTS_PER_TAPE (ft_segments_per_track * ft_tracks_per_tape)
34
35/* QIC-113 Rev. G says that `a maximum of 63488 raw bytes may be
36 * compressed into a single frame'.
37 * Maybe we should stick to 32kb to make it more `beautiful'
38 */
39#define ZFT_MAX_BLK_SZ (62*1024) /* bytes */
40#if !defined(CONFIG_ZFT_DFLT_BLK_SZ)
41# define CONFIG_ZFT_DFLT_BLK_SZ (10*1024) /* bytes, default of gnu tar */
42#elif CONFIG_ZFT_DFLT_BLK_SZ == 0
43# undef CONFIG_ZFT_DFLT_BLK_SZ
44# define CONFIG_ZFT_DFLT_BLK_SZ 1
45#elif (CONFIG_ZFT_DFLT_BLK_SZ % 1024) != 0
46# error CONFIG_ZFT_DFLT_BLK_SZ must be 1 or a multiple of 1024
47#endif
48/* The *optional* compression routines need some overhead per tape
49 * block for their purposes. Instead of asking the actual compression
50 * implementation how much it needs, we restrict this overhead to be
51 * maximal of ZFT_CMPT_OVERHEAD size. We need this for EOT
52 * conditions. The tape is assumed to be logical at EOT when the
53 * distance from the physical EOT is less than
54 * one tape block + ZFT_CMPR_OVERHEAD
55 */
56#define ZFT_CMPR_OVERHEAD 16 /* bytes */
57
58typedef enum
59{
60 zft_idle = 0,
61 zft_reading,
62 zft_writing,
63} zft_status_enum;
64
65typedef struct /* all values measured in bytes */
66{
67 int seg_pos; /* segment currently positioned at */
68 int seg_byte_pos; /* offset in current segment */
69 __s64 tape_pos; /* real offset from BOT */
70 __s64 volume_pos; /* pos. in uncompressed data stream in
71 * current volume
72 */
73} zft_position;
74
75extern zft_position zft_pos;
76extern __u8 *zft_deblock_buf;
77extern __u8 *zft_hseg_buf;
78extern int zft_deblock_segment;
79extern zft_status_enum zft_io_state;
80extern int zft_header_changed;
81extern int zft_qic113; /* conform to old specs. and old zftape */
82extern int zft_use_compression;
83extern unsigned int zft_blk_sz;
84extern __s64 zft_capacity;
85extern unsigned int zft_written_segments;
86extern int zft_label_changed;
87
88/* zftape-rw.c exported functions
89 */
90extern unsigned int zft_get_seg_sz(unsigned int segment);
91extern void zft_set_flags(unsigned int minor_unit);
92extern int zft_calc_seg_byte_coord(int *seg_byte_pos, __s64 tape_pos);
93extern __s64 zft_calc_tape_pos(int segment);
94extern __s64 zft_get_capacity(void);
95extern void zft_update_label(__u8 *buffer);
96extern int zft_erase(void);
97extern int zft_verify_write_segments(unsigned int segment,
98 __u8 *data, size_t size, __u8 *buffer);
99extern unsigned int zft_get_time(void);
100#endif /* _ZFTAPE_RW_H */
101
diff --git a/drivers/char/ftape/zftape/zftape-vtbl.c b/drivers/char/ftape/zftape/zftape-vtbl.c
deleted file mode 100644
index ad7f8be6340b..000000000000
--- a/drivers/char/ftape/zftape/zftape-vtbl.c
+++ /dev/null
@@ -1,757 +0,0 @@
1/*
2 * Copyright (c) 1995-1997 Claus-Justus Heine
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2, or (at
7 your option) any later version.
8
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
17 USA.
18
19 *
20 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-vtbl.c,v $
21 * $Revision: 1.7.6.1 $
22 * $Date: 1997/11/24 13:48:31 $
23 *
24 * This file defines a volume table as defined in various QIC
25 * standards.
26 *
27 * This is a minimal implementation, just allowing ordinary DOS
28 * :( prgrams to identify the cartridge as used.
29 */
30
31#include <linux/errno.h>
32#include <linux/mm.h>
33#include <linux/slab.h>
34
35#include <linux/zftape.h>
36#include "../zftape/zftape-init.h"
37#include "../zftape/zftape-eof.h"
38#include "../zftape/zftape-ctl.h"
39#include "../zftape/zftape-write.h"
40#include "../zftape/zftape-read.h"
41#include "../zftape/zftape-rw.h"
42#include "../zftape/zftape-vtbl.h"
43
44#define ZFT_CMAP_HACK /* leave this defined to hide the compression map */
45
46/*
47 * global variables
48 */
49int zft_qic_mode = 1; /* use the vtbl */
50int zft_old_ftape; /* prevents old ftaped tapes to be overwritten */
51int zft_volume_table_changed; /* for write_header_segments() */
52
53/*
54 * private variables (only exported for inline functions)
55 */
56LIST_HEAD(zft_vtbl);
57
58/* We could also allocate these dynamically when extracting the volume table
59 * sizeof(zft_volinfo) is about 32 or something close to that
60 */
61static zft_volinfo tape_vtbl;
62static zft_volinfo eot_vtbl;
63static zft_volinfo *cur_vtbl;
64
65static inline void zft_new_vtbl_entry(void)
66{
67 struct list_head *tmp = &zft_last_vtbl->node;
68 zft_volinfo *new = zft_kmalloc(sizeof(zft_volinfo));
69
70 list_add(&new->node, tmp);
71 new->count = zft_eom_vtbl->count ++;
72}
73
74void zft_free_vtbl(void)
75{
76 for (;;) {
77 struct list_head *tmp = zft_vtbl.prev;
78 zft_volinfo *vtbl;
79
80 if (tmp == &zft_vtbl)
81 break;
82 list_del(tmp);
83 vtbl = list_entry(tmp, zft_volinfo, node);
84 zft_kfree(vtbl, sizeof(zft_volinfo));
85 }
86 INIT_LIST_HEAD(&zft_vtbl);
87 cur_vtbl = NULL;
88}
89
90/* initialize vtbl, called by ftape_new_cartridge()
91 */
92void zft_init_vtbl(void)
93{
94 zft_volinfo *new;
95
96 zft_free_vtbl();
97
98 /* Create the two dummy vtbl entries
99 */
100 new = zft_kmalloc(sizeof(zft_volinfo));
101 list_add(&new->node, &zft_vtbl);
102 new = zft_kmalloc(sizeof(zft_volinfo));
103 list_add(&new->node, &zft_vtbl);
104 zft_head_vtbl->end_seg = ft_first_data_segment;
105 zft_head_vtbl->blk_sz = zft_blk_sz;
106 zft_head_vtbl->count = -1;
107 zft_eom_vtbl->start_seg = ft_first_data_segment + 1;
108 zft_eom_vtbl->end_seg = ft_last_data_segment + 1;
109 zft_eom_vtbl->blk_sz = zft_blk_sz;
110 zft_eom_vtbl->count = 0;
111
112 /* Reset the pointer for zft_find_volume()
113 */
114 cur_vtbl = zft_eom_vtbl;
115
116 /* initialize the dummy vtbl entries for zft_qic_mode == 0
117 */
118 eot_vtbl.start_seg = ft_last_data_segment + 1;
119 eot_vtbl.end_seg = ft_last_data_segment + 1;
120 eot_vtbl.blk_sz = zft_blk_sz;
121 eot_vtbl.count = -1;
122 tape_vtbl.start_seg = ft_first_data_segment;
123 tape_vtbl.end_seg = ft_last_data_segment;
124 tape_vtbl.blk_sz = zft_blk_sz;
125 tape_vtbl.size = zft_capacity;
126 tape_vtbl.count = 0;
127}
128
129/* check for a valid VTBL signature.
130 */
131static int vtbl_signature_valid(__u8 signature[4])
132{
133 const char *vtbl_ids[] = VTBL_IDS; /* valid signatures */
134 int j;
135
136 for (j = 0;
137 (j < NR_ITEMS(vtbl_ids)) && (memcmp(signature, vtbl_ids[j], 4) != 0);
138 j++);
139 return j < NR_ITEMS(vtbl_ids);
140}
141
142/* We used to store the block-size of the volume in the volume-label,
143 * using the keyword "blocksize". The blocksize written to the
144 * volume-label is in bytes.
145 *
146 * We use this now only for compatibility with old zftape version. We
147 * store the blocksize directly as binary number in the vendor
148 * extension part of the volume entry.
149 */
150static int check_volume_label(const char *label, int *blk_sz)
151{
152 int valid_format;
153 char *blocksize;
154 TRACE_FUN(ft_t_flow);
155
156 TRACE(ft_t_noise, "called with \"%s\" / \"%s\"", label, ZFT_VOL_NAME);
157 if (strncmp(label, ZFT_VOL_NAME, strlen(ZFT_VOL_NAME)) != 0) {
158 *blk_sz = 1; /* smallest block size that we allow */
159 valid_format = 0;
160 } else {
161 TRACE(ft_t_noise, "got old style zftape vtbl entry");
162 /* get the default blocksize */
163 /* use the kernel strstr() */
164 blocksize= strstr(label, " blocksize ");
165 if (blocksize) {
166 blocksize += strlen(" blocksize ");
167 for(*blk_sz= 0;
168 *blocksize >= '0' && *blocksize <= '9';
169 blocksize++) {
170 *blk_sz *= 10;
171 *blk_sz += *blocksize - '0';
172 }
173 if (*blk_sz > ZFT_MAX_BLK_SZ) {
174 *blk_sz= 1;
175 valid_format= 0;
176 } else {
177 valid_format = 1;
178 }
179 } else {
180 *blk_sz= 1;
181 valid_format= 0;
182 }
183 }
184 TRACE_EXIT valid_format;
185}
186
187/* check for a zftape volume
188 */
189static int check_volume(__u8 *entry, zft_volinfo *volume)
190{
191 TRACE_FUN(ft_t_flow);
192
193 if(strncmp(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG,
194 strlen(ZFTAPE_SIG)) == 0) {
195 TRACE(ft_t_noise, "got new style zftape vtbl entry");
196 volume->blk_sz = GET2(entry, VTBL_EXT+EXT_ZFTAPE_BLKSZ);
197 volume->qic113 = entry[VTBL_EXT+EXT_ZFTAPE_QIC113];
198 TRACE_EXIT 1;
199 } else {
200 TRACE_EXIT check_volume_label(&entry[VTBL_DESC], &volume->blk_sz);
201 }
202}
203
204
205/* create zftape specific vtbl entry, the volume bounds are inserted
206 * in the calling function, zft_create_volume_headers()
207 */
208static void create_zft_volume(__u8 *entry, zft_volinfo *vtbl)
209{
210 TRACE_FUN(ft_t_flow);
211
212 memset(entry, 0, VTBL_SIZE);
213 memcpy(&entry[VTBL_SIG], VTBL_ID, 4);
214 sprintf(&entry[VTBL_DESC], ZFT_VOL_NAME" %03d", vtbl->count);
215 entry[VTBL_FLAGS] = (VTBL_FL_NOT_VERIFIED | VTBL_FL_SEG_SPANNING);
216 entry[VTBL_M_NO] = 1; /* multi_cartridge_count */
217 strcpy(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG);
218 PUT2(entry, VTBL_EXT+EXT_ZFTAPE_BLKSZ, vtbl->blk_sz);
219 if (zft_qic113) {
220 PUT8(entry, VTBL_DATA_SIZE, vtbl->size);
221 entry[VTBL_CMPR] = VTBL_CMPR_UNREG;
222 if (vtbl->use_compression) { /* use compression: */
223 entry[VTBL_CMPR] |= VTBL_CMPR_USED;
224 }
225 entry[VTBL_EXT+EXT_ZFTAPE_QIC113] = 1;
226 } else {
227 PUT4(entry, VTBL_DATA_SIZE, vtbl->size);
228 entry[VTBL_K_CMPR] = VTBL_CMPR_UNREG;
229 if (vtbl->use_compression) { /* use compression: */
230 entry[VTBL_K_CMPR] |= VTBL_CMPR_USED;
231 }
232 }
233 if (ft_format_code == fmt_big) {
234 /* SCSI like vtbl, store the number of used
235 * segments as 4 byte value
236 */
237 PUT4(entry, VTBL_SCSI_SEGS, vtbl->end_seg-vtbl->start_seg + 1);
238 } else {
239 /* normal, QIC-80MC like vtbl
240 */
241 PUT2(entry, VTBL_START, vtbl->start_seg);
242 PUT2(entry, VTBL_END, vtbl->end_seg);
243 }
244 TRACE_EXIT;
245}
246
247/* this one creates the volume headers for each volume. It is assumed
248 * that buffer already contains the old volume-table, so that vtbl
249 * entries without the zft_volume flag set can savely be ignored.
250 */
251static void zft_create_volume_headers(__u8 *buffer)
252{
253 __u8 *entry;
254 struct list_head *tmp;
255 zft_volinfo *vtbl;
256 TRACE_FUN(ft_t_flow);
257
258#ifdef ZFT_CMAP_HACK
259 if((strncmp(&buffer[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG,
260 strlen(ZFTAPE_SIG)) == 0) &&
261 buffer[VTBL_EXT+EXT_ZFTAPE_CMAP] != 0) {
262 TRACE(ft_t_noise, "deleting cmap volume");
263 memmove(buffer, buffer + VTBL_SIZE,
264 FT_SEGMENT_SIZE - VTBL_SIZE);
265 }
266#endif
267 entry = buffer;
268 for (tmp = zft_head_vtbl->node.next;
269 tmp != &zft_eom_vtbl->node;
270 tmp = tmp->next) {
271 vtbl = list_entry(tmp, zft_volinfo, node);
272 /* we now fill in the values only for newly created volumes.
273 */
274 if (vtbl->new_volume) {
275 create_zft_volume(entry, vtbl);
276 vtbl->new_volume = 0; /* clear the flag */
277 }
278
279 DUMP_VOLINFO(ft_t_noise, &entry[VTBL_DESC], vtbl);
280 entry += VTBL_SIZE;
281 }
282 memset(entry, 0, FT_SEGMENT_SIZE - zft_eom_vtbl->count * VTBL_SIZE);
283 TRACE_EXIT;
284}
285
286/* write volume table to tape. Calls zft_create_volume_headers()
287 */
288int zft_update_volume_table(unsigned int segment)
289{
290 int result = 0;
291 __u8 *verify_buf = NULL;
292 TRACE_FUN(ft_t_flow);
293
294 TRACE_CATCH(result = ftape_read_segment(ft_first_data_segment,
295 zft_deblock_buf,
296 FT_RD_SINGLE),);
297 zft_create_volume_headers(zft_deblock_buf);
298 TRACE(ft_t_noise, "writing volume table segment %d", segment);
299 if (zft_vmalloc_once(&verify_buf, FT_SEGMENT_SIZE) == 0) {
300 TRACE_CATCH(zft_verify_write_segments(segment,
301 zft_deblock_buf, result,
302 verify_buf),
303 zft_vfree(&verify_buf, FT_SEGMENT_SIZE));
304 zft_vfree(&verify_buf, FT_SEGMENT_SIZE);
305 } else {
306 TRACE_CATCH(ftape_write_segment(segment, zft_deblock_buf,
307 FT_WR_SINGLE),);
308 }
309 TRACE_EXIT 0;
310}
311
312/* non zftape volumes are handled in raw mode. Thus we need to
313 * calculate the raw amount of data contained in those segments.
314 */
315static void extract_alien_volume(__u8 *entry, zft_volinfo *vtbl)
316{
317 TRACE_FUN(ft_t_flow);
318
319 vtbl->size = (zft_calc_tape_pos(zft_last_vtbl->end_seg+1) -
320 zft_calc_tape_pos(zft_last_vtbl->start_seg));
321 vtbl->use_compression = 0;
322 vtbl->qic113 = zft_qic113;
323 if (vtbl->qic113) {
324 TRACE(ft_t_noise,
325 "Fake alien volume's size from " LL_X " to " LL_X,
326 LL(GET8(entry, VTBL_DATA_SIZE)), LL(vtbl->size));
327 } else {
328 TRACE(ft_t_noise,
329 "Fake alien volume's size from %d to " LL_X,
330 (int)GET4(entry, VTBL_DATA_SIZE), LL(vtbl->size));
331 }
332 TRACE_EXIT;
333}
334
335
336/* extract an zftape specific volume
337 */
338static void extract_zft_volume(__u8 *entry, zft_volinfo *vtbl)
339{
340 TRACE_FUN(ft_t_flow);
341
342 if (vtbl->qic113) {
343 vtbl->size = GET8(entry, VTBL_DATA_SIZE);
344 vtbl->use_compression =
345 (entry[VTBL_CMPR] & VTBL_CMPR_USED) != 0;
346 } else {
347 vtbl->size = GET4(entry, VTBL_DATA_SIZE);
348 if (entry[VTBL_K_CMPR] & VTBL_CMPR_UNREG) {
349 vtbl->use_compression =
350 (entry[VTBL_K_CMPR] & VTBL_CMPR_USED) != 0;
351 } else if (entry[VTBL_CMPR] & VTBL_CMPR_UNREG) {
352 vtbl->use_compression =
353 (entry[VTBL_CMPR] & VTBL_CMPR_USED) != 0;
354 } else {
355 TRACE(ft_t_warn, "Geeh! There is something wrong:\n"
356 KERN_INFO "QIC compression (Rev = K): %x\n"
357 KERN_INFO "QIC compression (Rev > K): %x",
358 entry[VTBL_K_CMPR], entry[VTBL_CMPR]);
359 }
360 }
361 TRACE_EXIT;
362}
363
364/* extract the volume table from buffer. "buffer" must already contain
365 * the vtbl-segment
366 */
367int zft_extract_volume_headers(__u8 *buffer)
368{
369 __u8 *entry;
370 TRACE_FUN(ft_t_flow);
371
372 zft_init_vtbl();
373 entry = buffer;
374#ifdef ZFT_CMAP_HACK
375 if ((strncmp(&entry[VTBL_EXT+EXT_ZFTAPE_SIG], ZFTAPE_SIG,
376 strlen(ZFTAPE_SIG)) == 0) &&
377 entry[VTBL_EXT+EXT_ZFTAPE_CMAP] != 0) {
378 TRACE(ft_t_noise, "ignoring cmap volume");
379 entry += VTBL_SIZE;
380 }
381#endif
382 /* the end of the vtbl is indicated by an invalid signature
383 */
384 while (vtbl_signature_valid(&entry[VTBL_SIG]) &&
385 (entry - buffer) < FT_SEGMENT_SIZE) {
386 zft_new_vtbl_entry();
387 if (ft_format_code == fmt_big) {
388 /* SCSI like vtbl, stores only the number of
389 * segments used
390 */
391 unsigned int num_segments= GET4(entry, VTBL_SCSI_SEGS);
392 zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg;
393 zft_last_vtbl->end_seg =
394 zft_last_vtbl->start_seg + num_segments - 1;
395 } else {
396 /* `normal', QIC-80 like vtbl
397 */
398 zft_last_vtbl->start_seg = GET2(entry, VTBL_START);
399 zft_last_vtbl->end_seg = GET2(entry, VTBL_END);
400 }
401 zft_eom_vtbl->start_seg = zft_last_vtbl->end_seg + 1;
402 /* check if we created this volume and get the
403 * blk_sz
404 */
405 zft_last_vtbl->zft_volume = check_volume(entry, zft_last_vtbl);
406 if (zft_last_vtbl->zft_volume == 0) {
407 extract_alien_volume(entry, zft_last_vtbl);
408 } else {
409 extract_zft_volume(entry, zft_last_vtbl);
410 }
411 DUMP_VOLINFO(ft_t_noise, &entry[VTBL_DESC], zft_last_vtbl);
412 entry +=VTBL_SIZE;
413 }
414#if 0
415/*
416 * undefine to test end of tape handling
417 */
418 zft_new_vtbl_entry();
419 zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg;
420 zft_last_vtbl->end_seg = ft_last_data_segment - 10;
421 zft_last_vtbl->blk_sz = zft_blk_sz;
422 zft_last_vtbl->zft_volume = 1;
423 zft_last_vtbl->qic113 = zft_qic113;
424 zft_last_vtbl->size = (zft_calc_tape_pos(zft_last_vtbl->end_seg+1)
425 - zft_calc_tape_pos(zft_last_vtbl->start_seg));
426#endif
427 TRACE_EXIT 0;
428}
429
430/* this functions translates the failed_sector_log, misused as
431 * EOF-marker list, into a virtual volume table. The table mustn't be
432 * written to tape, because this would occupy the first data segment,
433 * which should be the volume table, but is actually the first segment
434 * that is filled with data (when using standard ftape). We assume,
435 * that we get a non-empty failed_sector_log.
436 */
437int zft_fake_volume_headers (eof_mark_union *eof_map, int num_failed_sectors)
438{
439 unsigned int segment, sector;
440 int have_eom = 0;
441 int vol_no;
442 TRACE_FUN(ft_t_flow);
443
444 if ((num_failed_sectors >= 2) &&
445 (GET2(&eof_map[num_failed_sectors - 1].mark.segment, 0)
446 ==
447 GET2(&eof_map[num_failed_sectors - 2].mark.segment, 0) + 1) &&
448 (GET2(&eof_map[num_failed_sectors - 1].mark.date, 0) == 1)) {
449 /* this should be eom. We keep the remainder of the
450 * tape as another volume.
451 */
452 have_eom = 1;
453 }
454 zft_init_vtbl();
455 zft_eom_vtbl->start_seg = ft_first_data_segment;
456 for(vol_no = 0; vol_no < num_failed_sectors - have_eom; vol_no ++) {
457 zft_new_vtbl_entry();
458
459 segment = GET2(&eof_map[vol_no].mark.segment, 0);
460 sector = GET2(&eof_map[vol_no].mark.date, 0);
461
462 zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg;
463 zft_last_vtbl->end_seg = segment;
464 zft_eom_vtbl->start_seg = segment + 1;
465 zft_last_vtbl->blk_sz = 1;
466 zft_last_vtbl->size =
467 (zft_calc_tape_pos(zft_last_vtbl->end_seg)
468 - zft_calc_tape_pos(zft_last_vtbl->start_seg)
469 + (sector-1) * FT_SECTOR_SIZE);
470 TRACE(ft_t_noise,
471 "failed sector log: segment: %d, sector: %d",
472 segment, sector);
473 DUMP_VOLINFO(ft_t_noise, "Faked volume", zft_last_vtbl);
474 }
475 if (!have_eom) {
476 zft_new_vtbl_entry();
477 zft_last_vtbl->start_seg = zft_eom_vtbl->start_seg;
478 zft_last_vtbl->end_seg = ft_last_data_segment;
479 zft_eom_vtbl->start_seg = ft_last_data_segment + 1;
480 zft_last_vtbl->size = zft_capacity;
481 zft_last_vtbl->size -= zft_calc_tape_pos(zft_last_vtbl->start_seg);
482 zft_last_vtbl->blk_sz = 1;
483 DUMP_VOLINFO(ft_t_noise, "Faked volume",zft_last_vtbl);
484 }
485 TRACE_EXIT 0;
486}
487
488/* update the internal volume table
489 *
490 * if before start of last volume: erase all following volumes if
491 * inside a volume: set end of volume to infinity
492 *
493 * this function is intended to be called every time _ftape_write() is
494 * called
495 *
496 * return: 0 if no new volume was created, 1 if a new volume was
497 * created
498 *
499 * NOTE: we don't need to check for zft_mode as ftape_write() does
500 * that already. This function gets never called without accessing
501 * zftape via the *qft* devices
502 */
503
504int zft_open_volume(zft_position *pos, int blk_sz, int use_compression)
505{
506 TRACE_FUN(ft_t_flow);
507
508 if (!zft_qic_mode) {
509 TRACE_EXIT 0;
510 }
511 if (zft_tape_at_lbot(pos)) {
512 zft_init_vtbl();
513 if(zft_old_ftape) {
514 /* clear old ftape's eof marks */
515 zft_clear_ftape_file_marks();
516 zft_old_ftape = 0; /* no longer old ftape */
517 }
518 zft_reset_position(pos);
519 }
520 if (pos->seg_pos != zft_last_vtbl->end_seg + 1) {
521 TRACE_ABORT(-EIO, ft_t_bug,
522 "BUG: seg_pos: %d, zft_last_vtbl->end_seg: %d",
523 pos->seg_pos, zft_last_vtbl->end_seg);
524 }
525 TRACE(ft_t_noise, "create new volume");
526 if (zft_eom_vtbl->count >= ZFT_MAX_VOLUMES) {
527 TRACE_ABORT(-ENOSPC, ft_t_err,
528 "Error: maxmimal number of volumes exhausted "
529 "(maxmimum is %d)", ZFT_MAX_VOLUMES);
530 }
531 zft_new_vtbl_entry();
532 pos->volume_pos = pos->seg_byte_pos = 0;
533 zft_last_vtbl->start_seg = pos->seg_pos;
534 zft_last_vtbl->end_seg = ft_last_data_segment; /* infinity */
535 zft_last_vtbl->blk_sz = blk_sz;
536 zft_last_vtbl->size = zft_capacity;
537 zft_last_vtbl->zft_volume = 1;
538 zft_last_vtbl->use_compression = use_compression;
539 zft_last_vtbl->qic113 = zft_qic113;
540 zft_last_vtbl->new_volume = 1;
541 zft_last_vtbl->open = 1;
542 zft_volume_table_changed = 1;
543 zft_eom_vtbl->start_seg = ft_last_data_segment + 1;
544 TRACE_EXIT 0;
545}
546
547/* perform mtfsf, mtbsf, not allowed without zft_qic_mode
548 */
549int zft_skip_volumes(int count, zft_position *pos)
550{
551 const zft_volinfo *vtbl;
552 TRACE_FUN(ft_t_flow);
553
554 TRACE(ft_t_noise, "count: %d", count);
555
556 vtbl= zft_find_volume(pos->seg_pos);
557 while (count > 0 && vtbl != zft_eom_vtbl) {
558 vtbl = list_entry(vtbl->node.next, zft_volinfo, node);
559 count --;
560 }
561 while (count < 0 && vtbl != zft_first_vtbl) {
562 vtbl = list_entry(vtbl->node.prev, zft_volinfo, node);
563 count ++;
564 }
565 pos->seg_pos = vtbl->start_seg;
566 pos->seg_byte_pos = 0;
567 pos->volume_pos = 0;
568 pos->tape_pos = zft_calc_tape_pos(pos->seg_pos);
569 zft_just_before_eof = vtbl->size == 0;
570 if (zft_cmpr_ops) {
571 (*zft_cmpr_ops->reset)();
572 }
573 zft_deblock_segment = -1; /* no need to keep cache */
574 TRACE(ft_t_noise, "repositioning to:\n"
575 KERN_INFO "zft_seg_pos : %d\n"
576 KERN_INFO "zft_seg_byte_pos : %d\n"
577 KERN_INFO "zft_tape_pos : " LL_X "\n"
578 KERN_INFO "zft_volume_pos : " LL_X "\n"
579 KERN_INFO "file number : %d",
580 pos->seg_pos, pos->seg_byte_pos,
581 LL(pos->tape_pos), LL(pos->volume_pos), vtbl->count);
582 zft_resid = count < 0 ? -count : count;
583 TRACE_EXIT zft_resid ? -EINVAL : 0;
584}
585
586/* the following simply returns the raw data position of the EOM
587 * marker, MTIOCSIZE ioctl
588 */
589__s64 zft_get_eom_pos(void)
590{
591 if (zft_qic_mode) {
592 return zft_calc_tape_pos(zft_eom_vtbl->start_seg);
593 } else {
594 /* there is only one volume in raw mode */
595 return zft_capacity;
596 }
597}
598
599/* skip to eom, used for MTEOM
600 */
601void zft_skip_to_eom(zft_position *pos)
602{
603 TRACE_FUN(ft_t_flow);
604 pos->seg_pos = zft_eom_vtbl->start_seg;
605 pos->seg_byte_pos =
606 pos->volume_pos =
607 zft_just_before_eof = 0;
608 pos->tape_pos = zft_calc_tape_pos(pos->seg_pos);
609 TRACE(ft_t_noise, "ftape positioned to segment %d, data pos " LL_X,
610 pos->seg_pos, LL(pos->tape_pos));
611 TRACE_EXIT;
612}
613
614/* write an EOF-marker by setting zft_last_vtbl->end_seg to seg_pos.
615 * NOTE: this function assumes that zft_last_vtbl points to a valid
616 * vtbl entry
617 *
618 * NOTE: this routine always positions before the EOF marker
619 */
620int zft_close_volume(zft_position *pos)
621{
622 TRACE_FUN(ft_t_any);
623
624 if (zft_vtbl_empty || !zft_last_vtbl->open) { /* should not happen */
625 TRACE(ft_t_noise, "There are no volumes to finish");
626 TRACE_EXIT -EIO;
627 }
628 if (pos->seg_byte_pos == 0 &&
629 pos->seg_pos != zft_last_vtbl->start_seg) {
630 pos->seg_pos --;
631 pos->seg_byte_pos = zft_get_seg_sz(pos->seg_pos);
632 }
633 zft_last_vtbl->end_seg = pos->seg_pos;
634 zft_last_vtbl->size = pos->volume_pos;
635 zft_volume_table_changed = 1;
636 zft_just_before_eof = 1;
637 zft_eom_vtbl->start_seg = zft_last_vtbl->end_seg + 1;
638 zft_last_vtbl->open = 0; /* closed */
639 TRACE_EXIT 0;
640}
641
642/* write count file-marks at current position.
643 *
644 * The tape is positioned after the eof-marker, that is at byte 0 of
645 * the segment following the eof-marker
646 *
647 * this function is only allowed in zft_qic_mode
648 *
649 * Only allowed when tape is at BOT or EOD.
650 */
651int zft_weof(unsigned int count, zft_position *pos)
652{
653
654 TRACE_FUN(ft_t_flow);
655
656 if (!count) { /* write zero EOF marks should be a real no-op */
657 TRACE_EXIT 0;
658 }
659 zft_volume_table_changed = 1;
660 if (zft_tape_at_lbot(pos)) {
661 zft_init_vtbl();
662 if(zft_old_ftape) {
663 /* clear old ftape's eof marks */
664 zft_clear_ftape_file_marks();
665 zft_old_ftape = 0; /* no longer old ftape */
666 }
667 }
668 if (zft_last_vtbl->open) {
669 zft_close_volume(pos);
670 zft_move_past_eof(pos);
671 count --;
672 }
673 /* now it's easy, just append eof-marks, that is empty
674 * volumes, to the end of the already recorded media.
675 */
676 while (count > 0 &&
677 pos->seg_pos <= ft_last_data_segment &&
678 zft_eom_vtbl->count < ZFT_MAX_VOLUMES) {
679 TRACE(ft_t_noise,
680 "Writing zero sized file at segment %d", pos->seg_pos);
681 zft_new_vtbl_entry();
682 zft_last_vtbl->start_seg = pos->seg_pos;
683 zft_last_vtbl->end_seg = pos->seg_pos;
684 zft_last_vtbl->size = 0;
685 zft_last_vtbl->blk_sz = zft_blk_sz;
686 zft_last_vtbl->zft_volume = 1;
687 zft_last_vtbl->use_compression = 0;
688 pos->tape_pos += zft_get_seg_sz(pos->seg_pos);
689 zft_eom_vtbl->start_seg = ++ pos->seg_pos;
690 count --;
691 }
692 if (count > 0) {
693 /* there are two possibilities: end of tape, or the
694 * maximum number of files is exhausted.
695 */
696 zft_resid = count;
697 TRACE(ft_t_noise,"Number of marks NOT written: %d", zft_resid);
698 if (zft_eom_vtbl->count == ZFT_MAX_VOLUMES) {
699 TRACE_ABORT(-EINVAL, ft_t_warn,
700 "maximum allowed number of files "
701 "exhausted: %d", ZFT_MAX_VOLUMES);
702 } else {
703 TRACE_ABORT(-ENOSPC,
704 ft_t_noise, "reached end of tape");
705 }
706 }
707 TRACE_EXIT 0;
708}
709
710const zft_volinfo *zft_find_volume(unsigned int seg_pos)
711{
712 TRACE_FUN(ft_t_flow);
713
714 TRACE(ft_t_any, "called with seg_pos %d",seg_pos);
715 if (!zft_qic_mode) {
716 if (seg_pos > ft_last_data_segment) {
717 TRACE_EXIT &eot_vtbl;
718 }
719 tape_vtbl.blk_sz = zft_blk_sz;
720 TRACE_EXIT &tape_vtbl;
721 }
722 if (seg_pos < zft_first_vtbl->start_seg) {
723 TRACE_EXIT (cur_vtbl = zft_first_vtbl);
724 }
725 while (seg_pos > cur_vtbl->end_seg) {
726 cur_vtbl = list_entry(cur_vtbl->node.next, zft_volinfo, node);
727 TRACE(ft_t_noise, "%d - %d", cur_vtbl->start_seg, cur_vtbl->end_seg);
728 }
729 while (seg_pos < cur_vtbl->start_seg) {
730 cur_vtbl = list_entry(cur_vtbl->node.prev, zft_volinfo, node);
731 TRACE(ft_t_noise, "%d - %d", cur_vtbl->start_seg, cur_vtbl->end_seg);
732 }
733 if (seg_pos > cur_vtbl->end_seg || seg_pos < cur_vtbl->start_seg) {
734 TRACE(ft_t_bug, "This cannot happen");
735 }
736 DUMP_VOLINFO(ft_t_noise, "", cur_vtbl);
737 TRACE_EXIT cur_vtbl;
738}
739
740/* this function really assumes that we are just before eof
741 */
742void zft_move_past_eof(zft_position *pos)
743{
744 TRACE_FUN(ft_t_flow);
745
746 TRACE(ft_t_noise, "old seg. pos: %d", pos->seg_pos);
747 pos->tape_pos += zft_get_seg_sz(pos->seg_pos++) - pos->seg_byte_pos;
748 pos->seg_byte_pos = 0;
749 pos->volume_pos = 0;
750 if (zft_cmpr_ops) {
751 (*zft_cmpr_ops->reset)();
752 }
753 zft_just_before_eof = 0;
754 zft_deblock_segment = -1; /* no need to cache it anymore */
755 TRACE(ft_t_noise, "new seg. pos: %d", pos->seg_pos);
756 TRACE_EXIT;
757}
diff --git a/drivers/char/ftape/zftape/zftape-vtbl.h b/drivers/char/ftape/zftape/zftape-vtbl.h
deleted file mode 100644
index f31d196d1759..000000000000
--- a/drivers/char/ftape/zftape/zftape-vtbl.h
+++ /dev/null
@@ -1,227 +0,0 @@
1#ifndef _ZFTAPE_VTBL_H
2#define _ZFTAPE_VTBL_H
3
4/*
5 * Copyright (c) 1995-1997 Claus-Justus Heine
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 as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
20 USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-vtbl.h,v $
24 * $Revision: 1.3 $
25 * $Date: 1997/10/28 14:30:09 $
26 *
27 * This file defines a volume table as defined in the QIC-80
28 * development standards.
29 */
30
31#include <linux/list.h>
32
33#include "../lowlevel/ftape-tracing.h"
34
35#include "../zftape/zftape-eof.h"
36#include "../zftape/zftape-ctl.h"
37#include "../zftape/zftape-rw.h"
38
39#define VTBL_SIZE 128 /* bytes */
40
41/* The following are offsets in the vtbl. */
42#define VTBL_SIG 0
43#define VTBL_START 4
44#define VTBL_END 6
45#define VTBL_DESC 8
46#define VTBL_DATE 52
47#define VTBL_FLAGS 56
48#define VTBL_FL_VENDOR_SPECIFIC (1<<0)
49#define VTBL_FL_MUTLI_CARTRIDGE (1<<1)
50#define VTBL_FL_NOT_VERIFIED (1<<2)
51#define VTBL_FL_REDIR_INHIBIT (1<<3)
52#define VTBL_FL_SEG_SPANNING (1<<4)
53#define VTBL_FL_DIRECTORY_LAST (1<<5)
54#define VTBL_FL_RESERVED_6 (1<<6)
55#define VTBL_FL_RESERVED_7 (1<<7)
56#define VTBL_M_NO 57
57#define VTBL_EXT 58
58#define EXT_ZFTAPE_SIG 0
59#define EXT_ZFTAPE_BLKSZ 10
60#define EXT_ZFTAPE_CMAP 12
61#define EXT_ZFTAPE_QIC113 13
62#define VTBL_PWD 84
63#define VTBL_DIR_SIZE 92
64#define VTBL_DATA_SIZE 96
65#define VTBL_OS_VERSION 104
66#define VTBL_SRC_DRIVE 106
67#define VTBL_DEV 122
68#define VTBL_RESERVED_1 123
69#define VTBL_CMPR 124
70#define VTBL_CMPR_UNREG 0x3f
71#define VTBL_CMPR_USED 0x80
72#define VTBL_FMT 125
73#define VTBL_RESERVED_2 126
74#define VTBL_RESERVED_3 127
75/* compatibility with pre revision K */
76#define VTBL_K_CMPR 120
77
78/* the next is used by QIC-3020 tapes with format code 6 (>2^16
79 * segments) It is specified in QIC-113, Rev. G, Section 5 (SCSI
80 * volume table). The difference is simply, that we only store the
81 * number of segments used, not the starting segment.
82 */
83#define VTBL_SCSI_SEGS 4 /* is a 4 byte value */
84
85/* one vtbl is 128 bytes, that results in a maximum number of
86 * 29*1024/128 = 232 volumes.
87 */
88#define ZFT_MAX_VOLUMES (FT_SEGMENT_SIZE/VTBL_SIZE)
89#define VTBL_ID "VTBL"
90#define VTBL_IDS { VTBL_ID, "XTBL", "UTID", "EXVT" } /* other valid ids */
91#define ZFT_VOL_NAME "zftape volume" /* volume label used by me */
92#define ZFTAPE_SIG "LINUX ZFT"
93
94/* global variables
95 */
96typedef struct zft_internal_vtbl
97{
98 struct list_head node;
99 int count;
100 unsigned int start_seg; /* 32 bits are enough for now */
101 unsigned int end_seg; /* 32 bits are enough for now */
102 __s64 size; /* uncompressed size */
103 unsigned int blk_sz; /* block size for this volume */
104 unsigned int zft_volume :1; /* zftape created this volume */
105 unsigned int use_compression:1; /* compressed volume */
106 unsigned int qic113 :1; /* layout of compressed block
107 * info and vtbl conforms to
108 * QIC-113, Rev. G
109 */
110 unsigned int new_volume :1; /* it was created by us, this
111 * run. this allows the
112 * fields that aren't really
113 * used by zftape to be filled
114 * in by some user level
115 * program.
116 */
117 unsigned int open :1; /* just in progress of being
118 * written
119 */
120} zft_volinfo;
121
122extern struct list_head zft_vtbl;
123#define zft_head_vtbl list_entry(zft_vtbl.next, zft_volinfo, node)
124#define zft_eom_vtbl list_entry(zft_vtbl.prev, zft_volinfo, node)
125#define zft_last_vtbl list_entry(zft_eom_vtbl->node.prev, zft_volinfo, node)
126#define zft_first_vtbl list_entry(zft_head_vtbl->node.next, zft_volinfo, node)
127#define zft_vtbl_empty (zft_eom_vtbl->node.prev == &zft_head_vtbl->node)
128
129#define DUMP_VOLINFO(level, desc, info) \
130{ \
131 char tmp[21]; \
132 strlcpy(tmp, desc, sizeof(tmp)); \
133 TRACE(level, "Volume %d:\n" \
134 KERN_INFO "description : %s\n" \
135 KERN_INFO "first segment: %d\n" \
136 KERN_INFO "last segment: %d\n" \
137 KERN_INFO "size : " LL_X "\n" \
138 KERN_INFO "block size : %d\n" \
139 KERN_INFO "compression : %d\n" \
140 KERN_INFO "zftape volume: %d\n" \
141 KERN_INFO "QIC-113 conf.: %d", \
142 (info)->count, tmp, (info)->start_seg, (info)->end_seg, \
143 LL((info)->size), (info)->blk_sz, \
144 (info)->use_compression != 0, (info)->zft_volume != 0, \
145 (info)->qic113 != 0); \
146}
147
148extern int zft_qic_mode;
149extern int zft_old_ftape;
150extern int zft_volume_table_changed;
151
152/* exported functions */
153extern void zft_init_vtbl (void);
154extern void zft_free_vtbl (void);
155extern int zft_extract_volume_headers(__u8 *buffer);
156extern int zft_update_volume_table (unsigned int segment);
157extern int zft_open_volume (zft_position *pos,
158 int blk_sz, int use_compression);
159extern int zft_close_volume (zft_position *pos);
160extern const zft_volinfo *zft_find_volume(unsigned int seg_pos);
161extern int zft_skip_volumes (int count, zft_position *pos);
162extern __s64 zft_get_eom_pos (void);
163extern void zft_skip_to_eom (zft_position *pos);
164extern int zft_fake_volume_headers (eof_mark_union *eof_map,
165 int num_failed_sectors);
166extern int zft_weof (unsigned int count, zft_position *pos);
167extern void zft_move_past_eof (zft_position *pos);
168
169static inline int zft_tape_at_eod (const zft_position *pos);
170static inline int zft_tape_at_lbot (const zft_position *pos);
171static inline void zft_position_before_eof (zft_position *pos,
172 const zft_volinfo *volume);
173static inline __s64 zft_check_for_eof(const zft_volinfo *vtbl,
174 const zft_position *pos);
175
176/* this function decrements the zft_seg_pos counter if we are right
177 * at the beginning of a segment. This is to handle fsfm/bsfm -- we
178 * need to position before the eof mark. NOTE: zft_tape_pos is not
179 * changed
180 */
181static inline void zft_position_before_eof(zft_position *pos,
182 const zft_volinfo *volume)
183{
184 TRACE_FUN(ft_t_flow);
185
186 if (pos->seg_pos == volume->end_seg + 1 && pos->seg_byte_pos == 0) {
187 pos->seg_pos --;
188 pos->seg_byte_pos = zft_get_seg_sz(pos->seg_pos);
189 }
190 TRACE_EXIT;
191}
192
193/* Mmmh. Is the position at the end of the last volume, that is right
194 * before the last EOF mark also logical an EOD condition?
195 */
196static inline int zft_tape_at_eod(const zft_position *pos)
197{
198 TRACE_FUN(ft_t_any);
199
200 if (zft_qic_mode) {
201 TRACE_EXIT (pos->seg_pos >= zft_eom_vtbl->start_seg ||
202 zft_last_vtbl->open);
203 } else {
204 TRACE_EXIT pos->seg_pos > ft_last_data_segment;
205 }
206}
207
208static inline int zft_tape_at_lbot(const zft_position *pos)
209{
210 if (zft_qic_mode) {
211 return (pos->seg_pos <= zft_first_vtbl->start_seg &&
212 pos->volume_pos == 0);
213 } else {
214 return (pos->seg_pos <= ft_first_data_segment &&
215 pos->volume_pos == 0);
216 }
217}
218
219/* This one checks for EOF. return remaing space (may be negative)
220 */
221static inline __s64 zft_check_for_eof(const zft_volinfo *vtbl,
222 const zft_position *pos)
223{
224 return (__s64)(vtbl->size - pos->volume_pos);
225}
226
227#endif /* _ZFTAPE_VTBL_H */
diff --git a/drivers/char/ftape/zftape/zftape-write.c b/drivers/char/ftape/zftape/zftape-write.c
deleted file mode 100644
index 94327b8c97b9..000000000000
--- a/drivers/char/ftape/zftape/zftape-write.c
+++ /dev/null
@@ -1,483 +0,0 @@
1/*
2 * Copyright (C) 1996, 1997 Claus Heine
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-write.c,v $
20 * $Revision: 1.3 $
21 * $Date: 1997/11/06 00:50:29 $
22 *
23 * This file contains the writing code
24 * for the QIC-117 floppy-tape driver for Linux.
25 */
26
27#include <linux/errno.h>
28#include <linux/mm.h>
29
30#include <linux/zftape.h>
31
32#include <asm/uaccess.h>
33
34#include "../zftape/zftape-init.h"
35#include "../zftape/zftape-eof.h"
36#include "../zftape/zftape-ctl.h"
37#include "../zftape/zftape-write.h"
38#include "../zftape/zftape-read.h"
39#include "../zftape/zftape-rw.h"
40#include "../zftape/zftape-vtbl.h"
41
42/* Global vars.
43 */
44
45/* Local vars.
46 */
47static int last_write_failed;
48static int need_flush;
49
50void zft_prevent_flush(void)
51{
52 need_flush = 0;
53}
54
55static int zft_write_header_segments(__u8* buffer)
56{
57 int header_1_ok = 0;
58 int header_2_ok = 0;
59 unsigned int time_stamp;
60 TRACE_FUN(ft_t_noise);
61
62 TRACE_CATCH(ftape_abort_operation(),);
63 ftape_seek_to_bot(); /* prevents extra rewind */
64 if (GET4(buffer, 0) != FT_HSEG_MAGIC) {
65 TRACE_ABORT(-EIO, ft_t_err,
66 "wrong header signature found, aborting");
67 }
68 /* Be optimistic: */
69 PUT4(buffer, FT_SEG_CNT,
70 zft_written_segments + GET4(buffer, FT_SEG_CNT) + 2);
71 if ((time_stamp = zft_get_time()) != 0) {
72 PUT4(buffer, FT_WR_DATE, time_stamp);
73 if (zft_label_changed) {
74 PUT4(buffer, FT_LABEL_DATE, time_stamp);
75 }
76 }
77 TRACE(ft_t_noise,
78 "writing first header segment %d", ft_header_segment_1);
79 header_1_ok = zft_verify_write_segments(ft_header_segment_1,
80 buffer, FT_SEGMENT_SIZE,
81 zft_deblock_buf) >= 0;
82 TRACE(ft_t_noise,
83 "writing second header segment %d", ft_header_segment_2);
84 header_2_ok = zft_verify_write_segments(ft_header_segment_2,
85 buffer, FT_SEGMENT_SIZE,
86 zft_deblock_buf) >= 0;
87 if (!header_1_ok) {
88 TRACE(ft_t_warn, "Warning: "
89 "update of first header segment failed");
90 }
91 if (!header_2_ok) {
92 TRACE(ft_t_warn, "Warning: "
93 "update of second header segment failed");
94 }
95 if (!header_1_ok && !header_2_ok) {
96 TRACE_ABORT(-EIO, ft_t_err, "Error: "
97 "update of both header segments failed.");
98 }
99 TRACE_EXIT 0;
100}
101
102int zft_update_header_segments(void)
103{
104 TRACE_FUN(ft_t_noise);
105
106 /* must NOT use zft_write_protected, as it also includes the
107 * file access mode. But we also want to update when soft
108 * write protection is enabled (O_RDONLY)
109 */
110 if (ft_write_protected || zft_old_ftape) {
111 TRACE_ABORT(0, ft_t_noise, "Tape set read-only: no update");
112 }
113 if (!zft_header_read) {
114 TRACE_ABORT(0, ft_t_noise, "Nothing to update");
115 }
116 if (!zft_header_changed) {
117 zft_header_changed = zft_written_segments > 0;
118 }
119 if (!zft_header_changed && !zft_volume_table_changed) {
120 TRACE_ABORT(0, ft_t_noise, "Nothing to update");
121 }
122 TRACE(ft_t_noise, "Updating header segments");
123 if (ftape_get_status()->fti_state == writing) {
124 TRACE_CATCH(ftape_loop_until_writes_done(),);
125 }
126 TRACE_CATCH(ftape_abort_operation(),);
127
128 zft_deblock_segment = -1; /* invalidate the cache */
129 if (zft_header_changed) {
130 TRACE_CATCH(zft_write_header_segments(zft_hseg_buf),);
131 }
132 if (zft_volume_table_changed) {
133 TRACE_CATCH(zft_update_volume_table(ft_first_data_segment),);
134 }
135 zft_header_changed =
136 zft_volume_table_changed =
137 zft_label_changed =
138 zft_written_segments = 0;
139 TRACE_CATCH(ftape_abort_operation(),);
140 ftape_seek_to_bot();
141 TRACE_EXIT 0;
142}
143
144static int read_merge_buffer(int seg_pos, __u8 *buffer, int offset, int seg_sz)
145{
146 int result = 0;
147 const ft_trace_t old_tracing = TRACE_LEVEL;
148 TRACE_FUN(ft_t_flow);
149
150 if (zft_qic_mode) {
151 /* writing in the middle of a volume is NOT allowed
152 *
153 */
154 TRACE(ft_t_noise, "No need to read a segment");
155 memset(buffer + offset, 0, seg_sz - offset);
156 TRACE_EXIT 0;
157 }
158 TRACE(ft_t_any, "waiting");
159 ftape_start_writing(FT_WR_MULTI);
160 TRACE_CATCH(ftape_loop_until_writes_done(),);
161
162 TRACE(ft_t_noise, "trying to read segment %d from offset %d",
163 seg_pos, offset);
164 SET_TRACE_LEVEL(ft_t_bug);
165 result = zft_fetch_segment_fraction(seg_pos, buffer,
166 FT_RD_SINGLE,
167 offset, seg_sz - offset);
168 SET_TRACE_LEVEL(old_tracing);
169 if (result != (seg_sz - offset)) {
170 TRACE(ft_t_noise, "Ignore error: read_segment() result: %d",
171 result);
172 memset(buffer + offset, 0, seg_sz - offset);
173 }
174 TRACE_EXIT 0;
175}
176
177/* flush the write buffer to tape and write an eof-marker at the
178 * current position if not in raw mode. This function always
179 * positions the tape before the eof-marker. _ftape_close() should
180 * then advance to the next segment.
181 *
182 * the parameter "finish_volume" describes whether to position before
183 * or after the possibly created file-mark. We always position after
184 * the file-mark when called from ftape_close() and a flush was needed
185 * (that is ftape_write() was the last tape operation before calling
186 * ftape_flush) But we always position before the file-mark when this
187 * function get's called from outside ftape_close()
188 */
189int zft_flush_buffers(void)
190{
191 int result;
192 int data_remaining;
193 int this_segs_size;
194 TRACE_FUN(ft_t_flow);
195
196 TRACE(ft_t_data_flow,
197 "entered, ftape_state = %d", ftape_get_status()->fti_state);
198 if (ftape_get_status()->fti_state != writing && !need_flush) {
199 TRACE_ABORT(0, ft_t_noise, "no need for flush");
200 }
201 zft_io_state = zft_idle; /* triggers some initializations for the
202 * read and write routines
203 */
204 if (last_write_failed) {
205 ftape_abort_operation();
206 TRACE_EXIT -EIO;
207 }
208 TRACE(ft_t_noise, "flushing write buffers");
209 this_segs_size = zft_get_seg_sz(zft_pos.seg_pos);
210 if (this_segs_size == zft_pos.seg_byte_pos) {
211 zft_pos.seg_pos ++;
212 data_remaining = zft_pos.seg_byte_pos = 0;
213 } else {
214 data_remaining = zft_pos.seg_byte_pos;
215 }
216 /* If there is any data not written to tape yet, append zero's
217 * up to the end of the sector (if using compression) or merge
218 * it with the data existing on the tape Then write the
219 * segment(s) to tape.
220 */
221 TRACE(ft_t_noise, "Position:\n"
222 KERN_INFO "seg_pos : %d\n"
223 KERN_INFO "byte pos : %d\n"
224 KERN_INFO "remaining: %d",
225 zft_pos.seg_pos, zft_pos.seg_byte_pos, data_remaining);
226 if (data_remaining > 0) {
227 do {
228 this_segs_size = zft_get_seg_sz(zft_pos.seg_pos);
229 if (this_segs_size > data_remaining) {
230 TRACE_CATCH(read_merge_buffer(zft_pos.seg_pos,
231 zft_deblock_buf,
232 data_remaining,
233 this_segs_size),
234 last_write_failed = 1);
235 }
236 result = ftape_write_segment(zft_pos.seg_pos,
237 zft_deblock_buf,
238 FT_WR_MULTI);
239 if (result != this_segs_size) {
240 TRACE(ft_t_err, "flush buffers failed");
241 zft_pos.tape_pos -= zft_pos.seg_byte_pos;
242 zft_pos.seg_byte_pos = 0;
243
244 last_write_failed = 1;
245 TRACE_EXIT result;
246 }
247 zft_written_segments ++;
248 TRACE(ft_t_data_flow,
249 "flush, moved out buffer: %d", result);
250 /* need next segment for more data (empty segments?)
251 */
252 if (result < data_remaining) {
253 if (result > 0) {
254 /* move remainder to buffer beginning
255 */
256 memmove(zft_deblock_buf,
257 zft_deblock_buf + result,
258 FT_SEGMENT_SIZE - result);
259 }
260 }
261 data_remaining -= result;
262 zft_pos.seg_pos ++;
263 } while (data_remaining > 0);
264 TRACE(ft_t_any, "result: %d", result);
265 zft_deblock_segment = --zft_pos.seg_pos;
266 if (data_remaining == 0) { /* first byte next segment */
267 zft_pos.seg_byte_pos = this_segs_size;
268 } else { /* after data previous segment, data_remaining < 0 */
269 zft_pos.seg_byte_pos = data_remaining + result;
270 }
271 } else {
272 TRACE(ft_t_noise, "zft_deblock_buf empty");
273 zft_pos.seg_pos --;
274 zft_pos.seg_byte_pos = zft_get_seg_sz (zft_pos.seg_pos);
275 ftape_start_writing(FT_WR_MULTI);
276 }
277 TRACE(ft_t_any, "waiting");
278 if ((result = ftape_loop_until_writes_done()) < 0) {
279 /* that's really bad. What to to with zft_tape_pos?
280 */
281 TRACE(ft_t_err, "flush buffers failed");
282 }
283 TRACE(ft_t_any, "zft_seg_pos: %d, zft_seg_byte_pos: %d",
284 zft_pos.seg_pos, zft_pos.seg_byte_pos);
285 last_write_failed =
286 need_flush = 0;
287 TRACE_EXIT result;
288}
289
290/* return-value: the number of bytes removed from the user-buffer
291 *
292 * out:
293 * int *write_cnt: how much actually has been moved to the
294 * zft_deblock_buf
295 * int req_len : MUST NOT BE CHANGED, except at EOT, in
296 * which case it may be adjusted
297 * in :
298 * char *buff : the user buffer
299 * int buf_pos_write : copy of buf_len_wr int
300 * this_segs_size : the size in bytes of the actual segment
301 * char
302 * *zft_deblock_buf : zft_deblock_buf
303 */
304static int zft_simple_write(int *cnt,
305 __u8 *dst_buf, const int seg_sz,
306 const __u8 __user *src_buf, const int req_len,
307 const zft_position *pos,const zft_volinfo *volume)
308{
309 int space_left;
310 TRACE_FUN(ft_t_flow);
311
312 /* volume->size holds the tape capacity while volume is open */
313 if (pos->tape_pos + volume->blk_sz > volume->size) {
314 TRACE_EXIT -ENOSPC;
315 }
316 /* remaining space in this segment, NOT zft_deblock_buf
317 */
318 space_left = seg_sz - pos->seg_byte_pos;
319 *cnt = req_len < space_left ? req_len : space_left;
320 if (copy_from_user(dst_buf + pos->seg_byte_pos, src_buf, *cnt) != 0) {
321 TRACE_EXIT -EFAULT;
322 }
323 TRACE_EXIT *cnt;
324}
325
326static int check_write_access(int req_len,
327 const zft_volinfo **volume,
328 zft_position *pos,
329 const unsigned int blk_sz)
330{
331 int result;
332 TRACE_FUN(ft_t_flow);
333
334 if ((req_len % zft_blk_sz) != 0) {
335 TRACE_ABORT(-EINVAL, ft_t_info,
336 "write-count %d must be multiple of block-size %d",
337 req_len, blk_sz);
338 }
339 if (zft_io_state == zft_writing) {
340 /* all other error conditions have been checked earlier
341 */
342 TRACE_EXIT 0;
343 }
344 zft_io_state = zft_idle;
345 TRACE_CATCH(zft_check_write_access(pos),);
346 /* If we haven't read the header segment yet, do it now.
347 * This will verify the configuration, get the bad sector
348 * table and read the volume table segment
349 */
350 if (!zft_header_read) {
351 TRACE_CATCH(zft_read_header_segments(),);
352 }
353 /* fine. Now the tape is either at BOT or at EOD,
354 * Write start of volume now
355 */
356 TRACE_CATCH(zft_open_volume(pos, blk_sz, zft_use_compression),);
357 *volume = zft_find_volume(pos->seg_pos);
358 DUMP_VOLINFO(ft_t_noise, "", *volume);
359 zft_just_before_eof = 0;
360 /* now merge with old data if necessary */
361 if (!zft_qic_mode && pos->seg_byte_pos != 0){
362 result = zft_fetch_segment(pos->seg_pos,
363 zft_deblock_buf,
364 FT_RD_SINGLE);
365 if (result < 0) {
366 if (result == -EINTR || result == -ENOSPC) {
367 TRACE_EXIT result;
368 }
369 TRACE(ft_t_noise,
370 "ftape_read_segment() result: %d. "
371 "This might be normal when using "
372 "a newly\nformatted tape", result);
373 memset(zft_deblock_buf, '\0', pos->seg_byte_pos);
374 }
375 }
376 zft_io_state = zft_writing;
377 TRACE_EXIT 0;
378}
379
380static int fill_deblock_buf(__u8 *dst_buf, const int seg_sz,
381 zft_position *pos, const zft_volinfo *volume,
382 const char __user *usr_buf, const int req_len)
383{
384 int cnt = 0;
385 int result = 0;
386 TRACE_FUN(ft_t_flow);
387
388 if (seg_sz == 0) {
389 TRACE_ABORT(0, ft_t_data_flow, "empty segment");
390 }
391 TRACE(ft_t_data_flow, "\n"
392 KERN_INFO "remaining req_len: %d\n"
393 KERN_INFO " buf_pos: %d",
394 req_len, pos->seg_byte_pos);
395 /* zft_deblock_buf will not contain a valid segment any longer */
396 zft_deblock_segment = -1;
397 if (zft_use_compression) {
398 TRACE_CATCH(zft_cmpr_lock(1 /* try to load */),);
399 TRACE_CATCH(result= (*zft_cmpr_ops->write)(&cnt,
400 dst_buf, seg_sz,
401 usr_buf, req_len,
402 pos, volume),);
403 } else {
404 TRACE_CATCH(result= zft_simple_write(&cnt,
405 dst_buf, seg_sz,
406 usr_buf, req_len,
407 pos, volume),);
408 }
409 pos->volume_pos += result;
410 pos->seg_byte_pos += cnt;
411 pos->tape_pos += cnt;
412 TRACE(ft_t_data_flow, "\n"
413 KERN_INFO "removed from user-buffer : %d bytes.\n"
414 KERN_INFO "copied to zft_deblock_buf: %d bytes.\n"
415 KERN_INFO "zft_tape_pos : " LL_X " bytes.",
416 result, cnt, LL(pos->tape_pos));
417 TRACE_EXIT result;
418}
419
420
421/* called by the kernel-interface routine "zft_write()"
422 */
423int _zft_write(const char __user *buff, int req_len)
424{
425 int result = 0;
426 int written = 0;
427 int write_cnt;
428 int seg_sz;
429 static const zft_volinfo *volume = NULL;
430 TRACE_FUN(ft_t_flow);
431
432 zft_resid = req_len;
433 last_write_failed = 1; /* reset to 0 when successful */
434 /* check if write is allowed
435 */
436 TRACE_CATCH(check_write_access(req_len, &volume,&zft_pos,zft_blk_sz),);
437 while (req_len > 0) {
438 /* Allow us to escape from this loop with a signal !
439 */
440 FT_SIGNAL_EXIT(_DONT_BLOCK);
441 seg_sz = zft_get_seg_sz(zft_pos.seg_pos);
442 if ((write_cnt = fill_deblock_buf(zft_deblock_buf,
443 seg_sz,
444 &zft_pos,
445 volume,
446 buff,
447 req_len)) < 0) {
448 zft_resid -= written;
449 if (write_cnt == -ENOSPC) {
450 /* leave the remainder to flush_buffers()
451 */
452 TRACE(ft_t_info, "No space left on device");
453 last_write_failed = 0;
454 if (!need_flush) {
455 need_flush = written > 0;
456 }
457 TRACE_EXIT written > 0 ? written : -ENOSPC;
458 } else {
459 TRACE_EXIT result;
460 }
461 }
462 if (zft_pos.seg_byte_pos == seg_sz) {
463 TRACE_CATCH(ftape_write_segment(zft_pos.seg_pos,
464 zft_deblock_buf,
465 FT_WR_ASYNC),
466 zft_resid -= written);
467 zft_written_segments ++;
468 zft_pos.seg_byte_pos = 0;
469 zft_deblock_segment = zft_pos.seg_pos;
470 ++zft_pos.seg_pos;
471 }
472 written += write_cnt;
473 buff += write_cnt;
474 req_len -= write_cnt;
475 } /* while (req_len > 0) */
476 TRACE(ft_t_data_flow, "remaining in blocking buffer: %d",
477 zft_pos.seg_byte_pos);
478 TRACE(ft_t_data_flow, "just written bytes: %d", written);
479 last_write_failed = 0;
480 zft_resid -= written;
481 need_flush = need_flush || written > 0;
482 TRACE_EXIT written; /* bytes written */
483}
diff --git a/drivers/char/ftape/zftape/zftape-write.h b/drivers/char/ftape/zftape/zftape-write.h
deleted file mode 100644
index ea887015b493..000000000000
--- a/drivers/char/ftape/zftape/zftape-write.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef _ZFTAPE_WRITE_H
2#define _ZFTAPE_WRITE_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape-write.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:13 $
25 *
26 * This file contains the definitions for the write functions
27 * for the zftape driver for Linux.
28 *
29 */
30
31extern int zft_flush_buffers(void);
32extern int zft_update_header_segments(void);
33extern void zft_prevent_flush(void);
34
35/* hook for the VFS interface
36 */
37extern int _zft_write(const char __user *buff, int req_len);
38#endif /* _ZFTAPE_WRITE_H */
diff --git a/drivers/char/ftape/zftape/zftape_syms.c b/drivers/char/ftape/zftape/zftape_syms.c
deleted file mode 100644
index 2db1401682df..000000000000
--- a/drivers/char/ftape/zftape/zftape_syms.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) 1997 Claus-Justus Heine
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 as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 *
19 * $Source: /homes/cvs/ftape-stacked/ftape/zftape/zftape_syms.c,v $
20 * $Revision: 1.3 $
21 * $Date: 1997/10/05 19:19:14 $
22 *
23 * This file contains the symbols that the zftape frontend to
24 * the ftape floppy tape driver exports
25 */
26
27#include <linux/module.h>
28
29#include <linux/zftape.h>
30
31#include "../zftape/zftape-init.h"
32#include "../zftape/zftape-read.h"
33#include "../zftape/zftape-buffers.h"
34#include "../zftape/zftape-ctl.h"
35
36/* zftape-init.c */
37EXPORT_SYMBOL(zft_cmpr_register);
38/* zftape-read.c */
39EXPORT_SYMBOL(zft_fetch_segment_fraction);
40/* zftape-buffers.c */
41EXPORT_SYMBOL(zft_vmalloc_once);
42EXPORT_SYMBOL(zft_vmalloc_always);
43EXPORT_SYMBOL(zft_vfree);
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 154a81d328c1..ebace201bec6 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -162,7 +162,8 @@ static struct miscdevice rng_miscdev = {
162}; 162};
163 163
164 164
165static ssize_t hwrng_attr_current_store(struct class_device *class, 165static ssize_t hwrng_attr_current_store(struct device *dev,
166 struct device_attribute *attr,
166 const char *buf, size_t len) 167 const char *buf, size_t len)
167{ 168{
168 int err; 169 int err;
@@ -192,7 +193,8 @@ static ssize_t hwrng_attr_current_store(struct class_device *class,
192 return err ? : len; 193 return err ? : len;
193} 194}
194 195
195static ssize_t hwrng_attr_current_show(struct class_device *class, 196static ssize_t hwrng_attr_current_show(struct device *dev,
197 struct device_attribute *attr,
196 char *buf) 198 char *buf)
197{ 199{
198 int err; 200 int err;
@@ -210,7 +212,8 @@ static ssize_t hwrng_attr_current_show(struct class_device *class,
210 return ret; 212 return ret;
211} 213}
212 214
213static ssize_t hwrng_attr_available_show(struct class_device *class, 215static ssize_t hwrng_attr_available_show(struct device *dev,
216 struct device_attribute *attr,
214 char *buf) 217 char *buf)
215{ 218{
216 int err; 219 int err;
@@ -234,20 +237,18 @@ static ssize_t hwrng_attr_available_show(struct class_device *class,
234 return ret; 237 return ret;
235} 238}
236 239
237static CLASS_DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR, 240static DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR,
238 hwrng_attr_current_show, 241 hwrng_attr_current_show,
239 hwrng_attr_current_store); 242 hwrng_attr_current_store);
240static CLASS_DEVICE_ATTR(rng_available, S_IRUGO, 243static DEVICE_ATTR(rng_available, S_IRUGO,
241 hwrng_attr_available_show, 244 hwrng_attr_available_show,
242 NULL); 245 NULL);
243 246
244 247
245static void unregister_miscdev(void) 248static void unregister_miscdev(void)
246{ 249{
247 class_device_remove_file(rng_miscdev.class, 250 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available);
248 &class_device_attr_rng_available); 251 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
249 class_device_remove_file(rng_miscdev.class,
250 &class_device_attr_rng_current);
251 misc_deregister(&rng_miscdev); 252 misc_deregister(&rng_miscdev);
252} 253}
253 254
@@ -258,20 +259,19 @@ static int register_miscdev(void)
258 err = misc_register(&rng_miscdev); 259 err = misc_register(&rng_miscdev);
259 if (err) 260 if (err)
260 goto out; 261 goto out;
261 err = class_device_create_file(rng_miscdev.class, 262 err = device_create_file(rng_miscdev.this_device,
262 &class_device_attr_rng_current); 263 &dev_attr_rng_current);
263 if (err) 264 if (err)
264 goto err_misc_dereg; 265 goto err_misc_dereg;
265 err = class_device_create_file(rng_miscdev.class, 266 err = device_create_file(rng_miscdev.this_device,
266 &class_device_attr_rng_available); 267 &dev_attr_rng_available);
267 if (err) 268 if (err)
268 goto err_remove_current; 269 goto err_remove_current;
269out: 270out:
270 return err; 271 return err;
271 272
272err_remove_current: 273err_remove_current:
273 class_device_remove_file(rng_miscdev.class, 274 device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
274 &class_device_attr_rng_current);
275err_misc_dereg: 275err_misc_dereg:
276 misc_deregister(&rng_miscdev); 276 misc_deregister(&rng_miscdev);
277 goto out; 277 goto out;
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 55473371b7c6..e67eef4867ba 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -980,10 +980,10 @@ static int __init chr_dev_init(void)
980 980
981 mem_class = class_create(THIS_MODULE, "mem"); 981 mem_class = class_create(THIS_MODULE, "mem");
982 for (i = 0; i < ARRAY_SIZE(devlist); i++) 982 for (i = 0; i < ARRAY_SIZE(devlist); i++)
983 class_device_create(mem_class, NULL, 983 device_create(mem_class, NULL,
984 MKDEV(MEM_MAJOR, devlist[i].minor), 984 MKDEV(MEM_MAJOR, devlist[i].minor),
985 NULL, devlist[i].name); 985 devlist[i].name);
986 986
987 return 0; 987 return 0;
988} 988}
989 989
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 62ebe09656e3..7a484fc7cb9e 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -169,11 +169,6 @@ fail:
169 return err; 169 return err;
170} 170}
171 171
172/*
173 * TODO for 2.7:
174 * - add a struct kref to struct miscdevice and make all usages of
175 * them dynamic.
176 */
177static struct class *misc_class; 172static struct class *misc_class;
178 173
179static const struct file_operations misc_fops = { 174static const struct file_operations misc_fops = {
@@ -228,10 +223,10 @@ int misc_register(struct miscdevice * misc)
228 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 223 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
229 dev = MKDEV(MISC_MAJOR, misc->minor); 224 dev = MKDEV(MISC_MAJOR, misc->minor);
230 225
231 misc->class = class_device_create(misc_class, NULL, dev, misc->dev, 226 misc->this_device = device_create(misc_class, misc->parent, dev,
232 "%s", misc->name); 227 "%s", misc->name);
233 if (IS_ERR(misc->class)) { 228 if (IS_ERR(misc->this_device)) {
234 err = PTR_ERR(misc->class); 229 err = PTR_ERR(misc->this_device);
235 goto out; 230 goto out;
236 } 231 }
237 232
@@ -264,7 +259,7 @@ int misc_deregister(struct miscdevice * misc)
264 259
265 down(&misc_sem); 260 down(&misc_sem);
266 list_del(&misc->list); 261 list_del(&misc->list);
267 class_device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); 262 device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
268 if (i < DYNAMIC_MINORS && i>0) { 263 if (i < DYNAMIC_MINORS && i>0) {
269 misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); 264 misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
270 } 265 }
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index efc485edad1c..c1e3dd837fc8 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -752,13 +752,13 @@ static const struct file_operations pp_fops = {
752 752
753static void pp_attach(struct parport *port) 753static void pp_attach(struct parport *port)
754{ 754{
755 class_device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number), 755 device_create(ppdev_class, NULL, MKDEV(PP_MAJOR, port->number),
756 NULL, "parport%d", port->number); 756 "parport%d", port->number);
757} 757}
758 758
759static void pp_detach(struct parport *port) 759static void pp_detach(struct parport *port)
760{ 760{
761 class_device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number)); 761 device_destroy(ppdev_class, MKDEV(PP_MAJOR, port->number));
762} 762}
763 763
764static struct parport_driver pp_driver = { 764static struct parport_driver pp_driver = {
diff --git a/drivers/char/random.c b/drivers/char/random.c
index fa764688cad1..4c6782a1ecdb 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1466,8 +1466,8 @@ static __init int seqgen_init(void)
1466late_initcall(seqgen_init); 1466late_initcall(seqgen_init);
1467 1467
1468#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1468#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1469__u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr, 1469__u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
1470 __u16 sport, __u16 dport) 1470 __be16 sport, __be16 dport)
1471{ 1471{
1472 struct timeval tv; 1472 struct timeval tv;
1473 __u32 seq; 1473 __u32 seq;
@@ -1479,10 +1479,10 @@ __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr,
1479 */ 1479 */
1480 1480
1481 memcpy(hash, saddr, 16); 1481 memcpy(hash, saddr, 16);
1482 hash[4]=(sport << 16) + dport; 1482 hash[4]=((__force u16)sport << 16) + (__force u16)dport;
1483 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); 1483 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7);
1484 1484
1485 seq = twothirdsMD4Transform(daddr, hash) & HASH_MASK; 1485 seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK;
1486 seq += keyptr->count; 1486 seq += keyptr->count;
1487 1487
1488 do_gettimeofday(&tv); 1488 do_gettimeofday(&tv);
@@ -1496,7 +1496,7 @@ EXPORT_SYMBOL(secure_tcpv6_sequence_number);
1496/* The code below is shamelessly stolen from secure_tcp_sequence_number(). 1496/* The code below is shamelessly stolen from secure_tcp_sequence_number().
1497 * All blames to Andrey V. Savochkin <saw@msu.ru>. 1497 * All blames to Andrey V. Savochkin <saw@msu.ru>.
1498 */ 1498 */
1499__u32 secure_ip_id(__u32 daddr) 1499__u32 secure_ip_id(__be32 daddr)
1500{ 1500{
1501 struct keydata *keyptr; 1501 struct keydata *keyptr;
1502 __u32 hash[4]; 1502 __u32 hash[4];
@@ -1508,7 +1508,7 @@ __u32 secure_ip_id(__u32 daddr)
1508 * The dest ip address is placed in the starting vector, 1508 * The dest ip address is placed in the starting vector,
1509 * which is then hashed with random data. 1509 * which is then hashed with random data.
1510 */ 1510 */
1511 hash[0] = daddr; 1511 hash[0] = (__force __u32)daddr;
1512 hash[1] = keyptr->secret[9]; 1512 hash[1] = keyptr->secret[9];
1513 hash[2] = keyptr->secret[10]; 1513 hash[2] = keyptr->secret[10];
1514 hash[3] = keyptr->secret[11]; 1514 hash[3] = keyptr->secret[11];
@@ -1518,8 +1518,8 @@ __u32 secure_ip_id(__u32 daddr)
1518 1518
1519#ifdef CONFIG_INET 1519#ifdef CONFIG_INET
1520 1520
1521__u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr, 1521__u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
1522 __u16 sport, __u16 dport) 1522 __be16 sport, __be16 dport)
1523{ 1523{
1524 struct timeval tv; 1524 struct timeval tv;
1525 __u32 seq; 1525 __u32 seq;
@@ -1532,9 +1532,9 @@ __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr,
1532 * Note that the words are placed into the starting vector, which is 1532 * Note that the words are placed into the starting vector, which is
1533 * then mixed with a partial MD4 over random data. 1533 * then mixed with a partial MD4 over random data.
1534 */ 1534 */
1535 hash[0]=saddr; 1535 hash[0]=(__force u32)saddr;
1536 hash[1]=daddr; 1536 hash[1]=(__force u32)daddr;
1537 hash[2]=(sport << 16) + dport; 1537 hash[2]=((__force u16)sport << 16) + (__force u16)dport;
1538 hash[3]=keyptr->secret[11]; 1538 hash[3]=keyptr->secret[11];
1539 1539
1540 seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK; 1540 seq = half_md4_transform(hash, keyptr->secret) & HASH_MASK;
@@ -1559,7 +1559,7 @@ __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr,
1559EXPORT_SYMBOL(secure_tcp_sequence_number); 1559EXPORT_SYMBOL(secure_tcp_sequence_number);
1560 1560
1561/* Generate secure starting point for ephemeral IPV4 transport port search */ 1561/* Generate secure starting point for ephemeral IPV4 transport port search */
1562u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport) 1562u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport)
1563{ 1563{
1564 struct keydata *keyptr = get_keyptr(); 1564 struct keydata *keyptr = get_keyptr();
1565 u32 hash[4]; 1565 u32 hash[4];
@@ -1568,25 +1568,25 @@ u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport)
1568 * Pick a unique starting offset for each ephemeral port search 1568 * Pick a unique starting offset for each ephemeral port search
1569 * (saddr, daddr, dport) and 48bits of random data. 1569 * (saddr, daddr, dport) and 48bits of random data.
1570 */ 1570 */
1571 hash[0] = saddr; 1571 hash[0] = (__force u32)saddr;
1572 hash[1] = daddr; 1572 hash[1] = (__force u32)daddr;
1573 hash[2] = dport ^ keyptr->secret[10]; 1573 hash[2] = (__force u32)dport ^ keyptr->secret[10];
1574 hash[3] = keyptr->secret[11]; 1574 hash[3] = keyptr->secret[11];
1575 1575
1576 return half_md4_transform(hash, keyptr->secret); 1576 return half_md4_transform(hash, keyptr->secret);
1577} 1577}
1578 1578
1579#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1579#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1580u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dport) 1580u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, __be16 dport)
1581{ 1581{
1582 struct keydata *keyptr = get_keyptr(); 1582 struct keydata *keyptr = get_keyptr();
1583 u32 hash[12]; 1583 u32 hash[12];
1584 1584
1585 memcpy(hash, saddr, 16); 1585 memcpy(hash, saddr, 16);
1586 hash[4] = dport; 1586 hash[4] = (__force u32)dport;
1587 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7); 1587 memcpy(&hash[5],keyptr->secret,sizeof(__u32) * 7);
1588 1588
1589 return twothirdsMD4Transform(daddr, hash); 1589 return twothirdsMD4Transform((const __u32 *)daddr, hash);
1590} 1590}
1591#endif 1591#endif
1592 1592
@@ -1595,17 +1595,17 @@ u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dpo
1595 * bit's 32-47 increase every key exchange 1595 * bit's 32-47 increase every key exchange
1596 * 0-31 hash(source, dest) 1596 * 0-31 hash(source, dest)
1597 */ 1597 */
1598u64 secure_dccp_sequence_number(__u32 saddr, __u32 daddr, 1598u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
1599 __u16 sport, __u16 dport) 1599 __be16 sport, __be16 dport)
1600{ 1600{
1601 struct timeval tv; 1601 struct timeval tv;
1602 u64 seq; 1602 u64 seq;
1603 __u32 hash[4]; 1603 __u32 hash[4];
1604 struct keydata *keyptr = get_keyptr(); 1604 struct keydata *keyptr = get_keyptr();
1605 1605
1606 hash[0] = saddr; 1606 hash[0] = (__force u32)saddr;
1607 hash[1] = daddr; 1607 hash[1] = (__force u32)daddr;
1608 hash[2] = (sport << 16) + dport; 1608 hash[2] = ((__force u16)sport << 16) + (__force u16)dport;
1609 hash[3] = keyptr->secret[11]; 1609 hash[3] = keyptr->secret[11];
1610 1610
1611 seq = half_md4_transform(hash, keyptr->secret); 1611 seq = half_md4_transform(hash, keyptr->secret);
@@ -1641,7 +1641,7 @@ unsigned int get_random_int(void)
1641 * drain on it), and uses halfMD4Transform within the second. We 1641 * drain on it), and uses halfMD4Transform within the second. We
1642 * also mix it with jiffies and the PID: 1642 * also mix it with jiffies and the PID:
1643 */ 1643 */
1644 return secure_ip_id(current->pid + jiffies); 1644 return secure_ip_id((__force __be32)(current->pid + jiffies));
1645} 1645}
1646 1646
1647/* 1647/*
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 89b718e326e5..3b32313f6eb4 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -127,9 +127,9 @@ raw_ioctl(struct inode *inode, struct file *filp,
127 127
128static void bind_device(struct raw_config_request *rq) 128static void bind_device(struct raw_config_request *rq)
129{ 129{
130 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 130 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
131 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), 131 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
132 NULL, "raw%d", rq->raw_minor); 132 "raw%d", rq->raw_minor);
133} 133}
134 134
135/* 135/*
@@ -200,7 +200,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
200 if (rq.block_major == 0 && rq.block_minor == 0) { 200 if (rq.block_major == 0 && rq.block_minor == 0) {
201 /* unbind */ 201 /* unbind */
202 rawdev->binding = NULL; 202 rawdev->binding = NULL;
203 class_device_destroy(raw_class, 203 device_destroy(raw_class,
204 MKDEV(RAW_MAJOR, rq.raw_minor)); 204 MKDEV(RAW_MAJOR, rq.raw_minor));
205 } else { 205 } else {
206 rawdev->binding = bdget(dev); 206 rawdev->binding = bdget(dev);
@@ -283,7 +283,7 @@ static int __init raw_init(void)
283 ret = PTR_ERR(raw_class); 283 ret = PTR_ERR(raw_class);
284 goto error_region; 284 goto error_region;
285 } 285 }
286 class_device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); 286 device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), "rawctl");
287 287
288 return 0; 288 return 0;
289 289
@@ -295,7 +295,7 @@ error:
295 295
296static void __exit raw_exit(void) 296static void __exit raw_exit(void)
297{ 297{
298 class_device_destroy(raw_class, MKDEV(RAW_MAJOR, 0)); 298 device_destroy(raw_class, MKDEV(RAW_MAJOR, 0));
299 class_destroy(raw_class); 299 class_destroy(raw_class);
300 cdev_del(&raw_cdev); 300 cdev_del(&raw_cdev);
301 unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS); 301 unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS);
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 4df6ab2206a1..167ebc84e8d7 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -922,7 +922,7 @@ int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP)
922** 922**
923** Packet is an actual packet structure to be filled in with the packet 923** Packet is an actual packet structure to be filled in with the packet
924** information associated with the command. You need to fill in everything, 924** information associated with the command. You need to fill in everything,
925** as the command processore doesn't process the command packet in any way. 925** as the command processor doesn't process the command packet in any way.
926** 926**
927** The PreFuncP is called before the packet is enqueued on the host rup. 927** The PreFuncP is called before the packet is enqueued on the host rup.
928** PreFuncP is called as (*PreFuncP)(PreArg, CmdBlkP);. PreFuncP must 928** PreFuncP is called as (*PreFuncP)(PreArg, CmdBlkP);. PreFuncP must
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 99f3df02b61c..0794844369d6 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -222,7 +222,7 @@ int RIOBoardTest(unsigned long paddr, void __iomem *caddr, unsigned char type, i
222** which value will be written into memory. 222** which value will be written into memory.
223** Call with op set to zero means that the RAM will not be read and checked 223** Call with op set to zero means that the RAM will not be read and checked
224** before it is written. 224** before it is written.
225** Call with op not zero, and the RAM will be read and compated with val[op-1] 225** Call with op not zero and the RAM will be read and compared with val[op-1]
226** to check that the data from the previous phase was retained. 226** to check that the data from the previous phase was retained.
227*/ 227*/
228 228
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index 1066d9760704..bb498d24adcc 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -87,8 +87,8 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
87** command bit set onto the port. The command bit is in the len field, 87** command bit set onto the port. The command bit is in the len field,
88** and gets ORed in with the actual byte count. 88** and gets ORed in with the actual byte count.
89** 89**
90** When you send a packet with the command bit set, then the first 90** When you send a packet with the command bit set the first
91** data byte ( data[0] ) is interpretted as the command to execute. 91** data byte (data[0]) is interpreted as the command to execute.
92** It also governs what data structure overlay should accompany the packet. 92** It also governs what data structure overlay should accompany the packet.
93** Commands are defined in cirrus/cirrus.h 93** Commands are defined in cirrus/cirrus.h
94** 94**
@@ -103,7 +103,7 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
103** 103**
104** Most commands do not use the remaining bytes in the data array. The 104** Most commands do not use the remaining bytes in the data array. The
105** exceptions are OPEN MOPEN and CONFIG. (NB. As with the SI CONFIG and 105** exceptions are OPEN MOPEN and CONFIG. (NB. As with the SI CONFIG and
106** OPEN are currently analagous). With these three commands the following 106** OPEN are currently analogous). With these three commands the following
107** 11 data bytes are all used to pass config information such as baud rate etc. 107** 11 data bytes are all used to pass config information such as baud rate etc.
108** The fields are also defined in cirrus.h. Some contain straightforward 108** The fields are also defined in cirrus.h. Some contain straightforward
109** information such as the transmit XON character. Two contain the transmit and 109** information such as the transmit XON character. Two contain the transmit and
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c
index 2444a0e24b31..244d30a03fef 100644
--- a/drivers/char/tlclk.c
+++ b/drivers/char/tlclk.c
@@ -792,15 +792,14 @@ static int __init tlclk_init(void)
792 ret = misc_register(&tlclk_miscdev); 792 ret = misc_register(&tlclk_miscdev);
793 if (ret < 0) { 793 if (ret < 0) {
794 printk(KERN_ERR "tlclk: misc_register returns %d.\n", ret); 794 printk(KERN_ERR "tlclk: misc_register returns %d.\n", ret);
795 ret = -EBUSY;
796 goto out3; 795 goto out3;
797 } 796 }
798 797
799 tlclk_device = platform_device_register_simple("telco_clock", 798 tlclk_device = platform_device_register_simple("telco_clock",
800 -1, NULL, 0); 799 -1, NULL, 0);
801 if (!tlclk_device) { 800 if (IS_ERR(tlclk_device)) {
802 printk(KERN_ERR "tlclk: platform_device_register failed.\n"); 801 printk(KERN_ERR "tlclk: platform_device_register failed.\n");
803 ret = -EBUSY; 802 ret = PTR_ERR(tlclk_device);
804 goto out4; 803 goto out4;
805 } 804 }
806 805
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 36f91a655275..774fa861169a 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1130,7 +1130,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1130 scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); 1130 scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num);
1131 chip->vendor.miscdev.name = devname; 1131 chip->vendor.miscdev.name = devname;
1132 1132
1133 chip->vendor.miscdev.dev = dev; 1133 chip->vendor.miscdev.parent = dev;
1134 chip->dev = get_device(dev); 1134 chip->dev = get_device(dev);
1135 1135
1136 if (misc_register(&chip->vendor.miscdev)) { 1136 if (misc_register(&chip->vendor.miscdev)) {
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 83e9e7d9b58c..b3cfc8bc613c 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3615,7 +3615,8 @@ static struct class *tty_class;
3615 * This field is optional, if there is no known struct device 3615 * This field is optional, if there is no known struct device
3616 * for this tty device it can be set to NULL safely. 3616 * for this tty device it can be set to NULL safely.
3617 * 3617 *
3618 * Returns a pointer to the class device (or ERR_PTR(-EFOO) on error). 3618 * Returns a pointer to the struct device for this tty device
3619 * (or ERR_PTR(-EFOO) on error).
3619 * 3620 *
3620 * This call is required to be made to register an individual tty device 3621 * This call is required to be made to register an individual tty device
3621 * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If 3622 * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If
@@ -3625,8 +3626,8 @@ static struct class *tty_class;
3625 * Locking: ?? 3626 * Locking: ??
3626 */ 3627 */
3627 3628
3628struct class_device *tty_register_device(struct tty_driver *driver, 3629struct device *tty_register_device(struct tty_driver *driver, unsigned index,
3629 unsigned index, struct device *device) 3630 struct device *device)
3630{ 3631{
3631 char name[64]; 3632 char name[64];
3632 dev_t dev = MKDEV(driver->major, driver->minor_start) + index; 3633 dev_t dev = MKDEV(driver->major, driver->minor_start) + index;
@@ -3642,7 +3643,7 @@ struct class_device *tty_register_device(struct tty_driver *driver,
3642 else 3643 else
3643 tty_line_name(driver, index, name); 3644 tty_line_name(driver, index, name);
3644 3645
3645 return class_device_create(tty_class, NULL, dev, device, "%s", name); 3646 return device_create(tty_class, device, dev, name);
3646} 3647}
3647 3648
3648/** 3649/**
@@ -3658,7 +3659,7 @@ struct class_device *tty_register_device(struct tty_driver *driver,
3658 3659
3659void tty_unregister_device(struct tty_driver *driver, unsigned index) 3660void tty_unregister_device(struct tty_driver *driver, unsigned index)
3660{ 3661{
3661 class_device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index); 3662 device_destroy(tty_class, MKDEV(driver->major, driver->minor_start) + index);
3662} 3663}
3663 3664
3664EXPORT_SYMBOL(tty_register_device); 3665EXPORT_SYMBOL(tty_register_device);
@@ -3898,20 +3899,20 @@ static int __init tty_init(void)
3898 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || 3899 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
3899 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) 3900 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
3900 panic("Couldn't register /dev/tty driver\n"); 3901 panic("Couldn't register /dev/tty driver\n");
3901 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty"); 3902 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty");
3902 3903
3903 cdev_init(&console_cdev, &console_fops); 3904 cdev_init(&console_cdev, &console_fops);
3904 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || 3905 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
3905 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) 3906 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
3906 panic("Couldn't register /dev/console driver\n"); 3907 panic("Couldn't register /dev/console driver\n");
3907 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, "console"); 3908 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console");
3908 3909
3909#ifdef CONFIG_UNIX98_PTYS 3910#ifdef CONFIG_UNIX98_PTYS
3910 cdev_init(&ptmx_cdev, &ptmx_fops); 3911 cdev_init(&ptmx_cdev, &ptmx_fops);
3911 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || 3912 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
3912 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) 3913 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
3913 panic("Couldn't register /dev/ptmx driver\n"); 3914 panic("Couldn't register /dev/ptmx driver\n");
3914 class_device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx"); 3915 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx");
3915#endif 3916#endif
3916 3917
3917#ifdef CONFIG_VT 3918#ifdef CONFIG_VT
@@ -3919,7 +3920,7 @@ static int __init tty_init(void)
3919 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) || 3920 if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
3920 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0) 3921 register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
3921 panic("Couldn't register /dev/tty0 driver\n"); 3922 panic("Couldn't register /dev/tty0 driver\n");
3922 class_device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0"); 3923 device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0");
3923 3924
3924 vty_init(); 3925 vty_init();
3925#endif 3926#endif
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index bd7a98c6ea7a..f442b574b44a 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -476,16 +476,16 @@ static struct class *vc_class;
476 476
477void vcs_make_sysfs(struct tty_struct *tty) 477void vcs_make_sysfs(struct tty_struct *tty)
478{ 478{
479 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), 479 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
480 NULL, "vcs%u", tty->index + 1); 480 "vcs%u", tty->index + 1);
481 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), 481 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
482 NULL, "vcsa%u", tty->index + 1); 482 "vcsa%u", tty->index + 1);
483} 483}
484 484
485void vcs_remove_sysfs(struct tty_struct *tty) 485void vcs_remove_sysfs(struct tty_struct *tty)
486{ 486{
487 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1)); 487 device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1));
488 class_device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129)); 488 device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129));
489} 489}
490 490
491int __init vcs_init(void) 491int __init vcs_init(void)
@@ -494,7 +494,7 @@ int __init vcs_init(void)
494 panic("unable to get major %d for vcs device", VCS_MAJOR); 494 panic("unable to get major %d for vcs device", VCS_MAJOR);
495 vc_class = class_create(THIS_MODULE, "vc"); 495 vc_class = class_create(THIS_MODULE, "vc");
496 496
497 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 497 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs");
498 class_device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 498 device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa");
499 return 0; 499 return 0;
500} 500}
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 8ee04adc37f0..75ff0286e1ad 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -112,7 +112,7 @@
112struct con_driver { 112struct con_driver {
113 const struct consw *con; 113 const struct consw *con;
114 const char *desc; 114 const char *desc;
115 struct class_device *class_dev; 115 struct device *dev;
116 int node; 116 int node;
117 int first; 117 int first;
118 int last; 118 int last;
@@ -3023,10 +3023,10 @@ static inline int vt_unbind(struct con_driver *con)
3023} 3023}
3024#endif /* CONFIG_VT_HW_CONSOLE_BINDING */ 3024#endif /* CONFIG_VT_HW_CONSOLE_BINDING */
3025 3025
3026static ssize_t store_bind(struct class_device *class_device, 3026static ssize_t store_bind(struct device *dev, struct device_attribute *attr,
3027 const char *buf, size_t count) 3027 const char *buf, size_t count)
3028{ 3028{
3029 struct con_driver *con = class_get_devdata(class_device); 3029 struct con_driver *con = dev_get_drvdata(dev);
3030 int bind = simple_strtoul(buf, NULL, 0); 3030 int bind = simple_strtoul(buf, NULL, 0);
3031 3031
3032 if (bind) 3032 if (bind)
@@ -3037,17 +3037,19 @@ static ssize_t store_bind(struct class_device *class_device,
3037 return count; 3037 return count;
3038} 3038}
3039 3039
3040static ssize_t show_bind(struct class_device *class_device, char *buf) 3040static ssize_t show_bind(struct device *dev, struct device_attribute *attr,
3041 char *buf)
3041{ 3042{
3042 struct con_driver *con = class_get_devdata(class_device); 3043 struct con_driver *con = dev_get_drvdata(dev);
3043 int bind = con_is_bound(con->con); 3044 int bind = con_is_bound(con->con);
3044 3045
3045 return snprintf(buf, PAGE_SIZE, "%i\n", bind); 3046 return snprintf(buf, PAGE_SIZE, "%i\n", bind);
3046} 3047}
3047 3048
3048static ssize_t show_name(struct class_device *class_device, char *buf) 3049static ssize_t show_name(struct device *dev, struct device_attribute *attr,
3050 char *buf)
3049{ 3051{
3050 struct con_driver *con = class_get_devdata(class_device); 3052 struct con_driver *con = dev_get_drvdata(dev);
3051 3053
3052 return snprintf(buf, PAGE_SIZE, "%s %s\n", 3054 return snprintf(buf, PAGE_SIZE, "%s %s\n",
3053 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)", 3055 (con->flag & CON_DRIVER_FLAG_MODULE) ? "(M)" : "(S)",
@@ -3055,43 +3057,40 @@ static ssize_t show_name(struct class_device *class_device, char *buf)
3055 3057
3056} 3058}
3057 3059
3058static struct class_device_attribute class_device_attrs[] = { 3060static struct device_attribute device_attrs[] = {
3059 __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind), 3061 __ATTR(bind, S_IRUGO|S_IWUSR, show_bind, store_bind),
3060 __ATTR(name, S_IRUGO, show_name, NULL), 3062 __ATTR(name, S_IRUGO, show_name, NULL),
3061}; 3063};
3062 3064
3063static int vtconsole_init_class_device(struct con_driver *con) 3065static int vtconsole_init_device(struct con_driver *con)
3064{ 3066{
3065 int i; 3067 int i;
3066 int error = 0; 3068 int error = 0;
3067 3069
3068 con->flag |= CON_DRIVER_FLAG_ATTR; 3070 con->flag |= CON_DRIVER_FLAG_ATTR;
3069 class_set_devdata(con->class_dev, con); 3071 dev_set_drvdata(con->dev, con);
3070 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { 3072 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
3071 error = class_device_create_file(con->class_dev, 3073 error = device_create_file(con->dev, &device_attrs[i]);
3072 &class_device_attrs[i]);
3073 if (error) 3074 if (error)
3074 break; 3075 break;
3075 } 3076 }
3076 3077
3077 if (error) { 3078 if (error) {
3078 while (--i >= 0) 3079 while (--i >= 0)
3079 class_device_remove_file(con->class_dev, 3080 device_remove_file(con->dev, &device_attrs[i]);
3080 &class_device_attrs[i]);
3081 con->flag &= ~CON_DRIVER_FLAG_ATTR; 3081 con->flag &= ~CON_DRIVER_FLAG_ATTR;
3082 } 3082 }
3083 3083
3084 return error; 3084 return error;
3085} 3085}
3086 3086
3087static void vtconsole_deinit_class_device(struct con_driver *con) 3087static void vtconsole_deinit_device(struct con_driver *con)
3088{ 3088{
3089 int i; 3089 int i;
3090 3090
3091 if (con->flag & CON_DRIVER_FLAG_ATTR) { 3091 if (con->flag & CON_DRIVER_FLAG_ATTR) {
3092 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 3092 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
3093 class_device_remove_file(con->class_dev, 3093 device_remove_file(con->dev, &device_attrs[i]);
3094 &class_device_attrs[i]);
3095 con->flag &= ~CON_DRIVER_FLAG_ATTR; 3094 con->flag &= ~CON_DRIVER_FLAG_ATTR;
3096 } 3095 }
3097} 3096}
@@ -3179,18 +3178,17 @@ int register_con_driver(const struct consw *csw, int first, int last)
3179 if (retval) 3178 if (retval)
3180 goto err; 3179 goto err;
3181 3180
3182 con_driver->class_dev = class_device_create(vtconsole_class, NULL, 3181 con_driver->dev = device_create(vtconsole_class, NULL,
3183 MKDEV(0, con_driver->node), 3182 MKDEV(0, con_driver->node),
3184 NULL, "vtcon%i", 3183 "vtcon%i", con_driver->node);
3185 con_driver->node);
3186 3184
3187 if (IS_ERR(con_driver->class_dev)) { 3185 if (IS_ERR(con_driver->dev)) {
3188 printk(KERN_WARNING "Unable to create class_device for %s; " 3186 printk(KERN_WARNING "Unable to create device for %s; "
3189 "errno = %ld\n", con_driver->desc, 3187 "errno = %ld\n", con_driver->desc,
3190 PTR_ERR(con_driver->class_dev)); 3188 PTR_ERR(con_driver->dev));
3191 con_driver->class_dev = NULL; 3189 con_driver->dev = NULL;
3192 } else { 3190 } else {
3193 vtconsole_init_class_device(con_driver); 3191 vtconsole_init_device(con_driver);
3194 } 3192 }
3195 3193
3196err: 3194err:
@@ -3226,12 +3224,12 @@ int unregister_con_driver(const struct consw *csw)
3226 3224
3227 if (con_driver->con == csw && 3225 if (con_driver->con == csw &&
3228 con_driver->flag & CON_DRIVER_FLAG_MODULE) { 3226 con_driver->flag & CON_DRIVER_FLAG_MODULE) {
3229 vtconsole_deinit_class_device(con_driver); 3227 vtconsole_deinit_device(con_driver);
3230 class_device_destroy(vtconsole_class, 3228 device_destroy(vtconsole_class,
3231 MKDEV(0, con_driver->node)); 3229 MKDEV(0, con_driver->node));
3232 con_driver->con = NULL; 3230 con_driver->con = NULL;
3233 con_driver->desc = NULL; 3231 con_driver->desc = NULL;
3234 con_driver->class_dev = NULL; 3232 con_driver->dev = NULL;
3235 con_driver->node = 0; 3233 con_driver->node = 0;
3236 con_driver->flag = 0; 3234 con_driver->flag = 0;
3237 con_driver->first = 0; 3235 con_driver->first = 0;
@@ -3289,19 +3287,18 @@ static int __init vtconsole_class_init(void)
3289 for (i = 0; i < MAX_NR_CON_DRIVER; i++) { 3287 for (i = 0; i < MAX_NR_CON_DRIVER; i++) {
3290 struct con_driver *con = &registered_con_driver[i]; 3288 struct con_driver *con = &registered_con_driver[i];
3291 3289
3292 if (con->con && !con->class_dev) { 3290 if (con->con && !con->dev) {
3293 con->class_dev = 3291 con->dev = device_create(vtconsole_class, NULL,
3294 class_device_create(vtconsole_class, NULL, 3292 MKDEV(0, con->node),
3295 MKDEV(0, con->node), NULL, 3293 "vtcon%i", con->node);
3296 "vtcon%i", con->node);
3297 3294
3298 if (IS_ERR(con->class_dev)) { 3295 if (IS_ERR(con->dev)) {
3299 printk(KERN_WARNING "Unable to create " 3296 printk(KERN_WARNING "Unable to create "
3300 "class_device for %s; errno = %ld\n", 3297 "device for %s; errno = %ld\n",
3301 con->desc, PTR_ERR(con->class_dev)); 3298 con->desc, PTR_ERR(con->dev));
3302 con->class_dev = NULL; 3299 con->dev = NULL;
3303 } else { 3300 } else {
3304 vtconsole_init_class_device(con); 3301 vtconsole_init_device(con);
3305 } 3302 }
3306 } 3303 }
3307 } 3304 }
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 0187b1185323..ea09d0c974ea 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -340,6 +340,14 @@ config ITCO_WDT
340 To compile this driver as a module, choose M here: the 340 To compile this driver as a module, choose M here: the
341 module will be called iTCO_wdt. 341 module will be called iTCO_wdt.
342 342
343config ITCO_VENDOR_SUPPORT
344 bool "Intel TCO Timer/Watchdog Specific Vendor Support"
345 depends on ITCO_WDT
346 ---help---
347 Add vendor specific support to the intel TCO timer based watchdog
348 devices. At this moment we only have additional support for some
349 SuperMicro Inc. motherboards.
350
343config SC1200_WDT 351config SC1200_WDT
344 tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog" 352 tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"
345 depends on WATCHDOG && X86 353 depends on WATCHDOG && X86
@@ -363,6 +371,20 @@ config SCx200_WDT
363 371
364 If compiled as a module, it will be called scx200_wdt. 372 If compiled as a module, it will be called scx200_wdt.
365 373
374config PC87413_WDT
375 tristate "NS PC87413 watchdog"
376 depends on WATCHDOG && X86
377 ---help---
378 This is the driver for the hardware watchdog on the PC87413 chipset
379 This watchdog simply watches your kernel to make sure it doesn't
380 freeze, and if it does, it reboots your computer after a certain
381 amount of time.
382
383 To compile this driver as a module, choose M here: the
384 module will be called pc87413_wdt.
385
386 Most people will say N.
387
366config 60XX_WDT 388config 60XX_WDT
367 tristate "SBC-60XX Watchdog Timer" 389 tristate "SBC-60XX Watchdog Timer"
368 depends on WATCHDOG && X86 390 depends on WATCHDOG && X86
@@ -553,6 +575,16 @@ config INDYDOG
553 timer expired and no process has written to /dev/watchdog during 575 timer expired and no process has written to /dev/watchdog during
554 that time. 576 that time.
555 577
578config WDT_RM9K_GPI
579 tristate "RM9000/GPI hardware watchdog"
580 depends on WATCHDOG && CPU_RM9000
581 help
582 Watchdog implementation using the GPI hardware found on
583 PMC-Sierra RM9xxx CPUs.
584
585 To compile this driver as a module, choose M here: the
586 module will be called rm9k_wdt.
587
556# S390 Architecture 588# S390 Architecture
557 589
558config ZVM_WATCHDOG 590config ZVM_WATCHDOG
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 36440497047c..2cd8ff8d10ac 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -47,9 +47,10 @@ obj-$(CONFIG_IBMASR) += ibmasr.o
47obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o 47obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
48obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o 48obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o
49obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o 49obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o
50obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o 50obj-$(CONFIG_ITCO_WDT) += iTCO_wdt.o iTCO_vendor_support.o
51obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o 51obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
52obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o 52obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
53obj-$(CONFIG_PC87413_WDT) += pc87413_wdt.o
53obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o 54obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o
54obj-$(CONFIG_SBC8360_WDT) += sbc8360.o 55obj-$(CONFIG_SBC8360_WDT) += sbc8360.o
55obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o 56obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
@@ -72,6 +73,7 @@ obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
72 73
73# MIPS Architecture 74# MIPS Architecture
74obj-$(CONFIG_INDYDOG) += indydog.o 75obj-$(CONFIG_INDYDOG) += indydog.o
76obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o
75 77
76# S390 Architecture 78# S390 Architecture
77 79
diff --git a/drivers/char/watchdog/iTCO_vendor_support.c b/drivers/char/watchdog/iTCO_vendor_support.c
new file mode 100644
index 000000000000..415083990097
--- /dev/null
+++ b/drivers/char/watchdog/iTCO_vendor_support.c
@@ -0,0 +1,307 @@
1/*
2 * intel TCO vendor specific watchdog driver support
3 *
4 * (c) Copyright 2006 Wim Van Sebroeck <wim@iguana.be>.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * Neither Wim Van Sebroeck nor Iguana vzw. admit liability nor
12 * provide warranty for any of this software. This material is
13 * provided "AS-IS" and at no charge.
14 */
15
16/*
17 * Includes, defines, variables, module parameters, ...
18 */
19
20/* Module and version information */
21#define DRV_NAME "iTCO_vendor_support"
22#define DRV_VERSION "1.01"
23#define DRV_RELDATE "11-Nov-2006"
24#define PFX DRV_NAME ": "
25
26/* Includes */
27#include <linux/module.h> /* For module specific items */
28#include <linux/moduleparam.h> /* For new moduleparam's */
29#include <linux/types.h> /* For standard types (like size_t) */
30#include <linux/errno.h> /* For the -ENODEV/... values */
31#include <linux/kernel.h> /* For printk/panic/... */
32#include <linux/init.h> /* For __init/__exit/... */
33#include <linux/ioport.h> /* For io-port access */
34
35#include <asm/io.h> /* For inb/outb/... */
36
37/* iTCO defines */
38#define SMI_EN acpibase + 0x30 /* SMI Control and Enable Register */
39#define TCOBASE acpibase + 0x60 /* TCO base address */
40#define TCO1_STS TCOBASE + 0x04 /* TCO1 Status Register */
41
42/* List of vendor support modes */
43#define SUPERMICRO_OLD_BOARD 1 /* SuperMicro Pentium 3 Era 370SSE+-OEM1/P3TSSE */
44#define SUPERMICRO_NEW_BOARD 2 /* SuperMicro Pentium 4 / Xeon 4 / EMT64T Era Systems */
45
46static int vendorsupport = 0;
47module_param(vendorsupport, int, 0);
48MODULE_PARM_DESC(vendorsupport, "iTCO vendor specific support mode, default=0 (none), 1=SuperMicro Pent3, 2=SuperMicro Pent4+");
49
50/*
51 * Vendor Specific Support
52 */
53
54/*
55 * Vendor Support: 1
56 * Board: Super Micro Computer Inc. 370SSE+-OEM1/P3TSSE
57 * iTCO chipset: ICH2
58 *
59 * Code contributed by: R. Seretny <lkpatches@paypc.com>
60 * Documentation obtained by R. Seretny from SuperMicro Technical Support
61 *
62 * To enable Watchdog function:
63 * BIOS setup -> Power -> TCO Logic SMI Enable -> Within5Minutes
64 * This setting enables SMI to clear the watchdog expired flag.
65 * If BIOS or CPU fail which may cause SMI hang, then system will
66 * reboot. When application starts to use watchdog function,
67 * application has to take over the control from SMI.
68 *
69 * For P3TSSE, J36 jumper needs to be removed to enable the Watchdog
70 * function.
71 *
72 * Note: The system will reboot when Expire Flag is set TWICE.
73 * So, if the watchdog timer is 20 seconds, then the maximum hang
74 * time is about 40 seconds, and the minimum hang time is about
75 * 20.6 seconds.
76 */
77
78static void supermicro_old_pre_start(unsigned long acpibase)
79{
80 unsigned long val32;
81
82 val32 = inl(SMI_EN);
83 val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */
84 outl(val32, SMI_EN); /* Needed to activate watchdog */
85}
86
87static void supermicro_old_pre_stop(unsigned long acpibase)
88{
89 unsigned long val32;
90
91 val32 = inl(SMI_EN);
92 val32 &= 0x00002000; /* Turn on SMI clearing watchdog */
93 outl(val32, SMI_EN); /* Needed to deactivate watchdog */
94}
95
96static void supermicro_old_pre_keepalive(unsigned long acpibase)
97{
98 /* Reload TCO Timer (done in iTCO_wdt_keepalive) + */
99 /* Clear "Expire Flag" (Bit 3 of TC01_STS register) */
100 outb(0x08, TCO1_STS);
101}
102
103/*
104 * Vendor Support: 2
105 * Board: Super Micro Computer Inc. P4SBx, P4DPx
106 * iTCO chipset: ICH4
107 *
108 * Code contributed by: R. Seretny <lkpatches@paypc.com>
109 * Documentation obtained by R. Seretny from SuperMicro Technical Support
110 *
111 * To enable Watchdog function:
112 * 1. BIOS
113 * For P4SBx:
114 * BIOS setup -> Advanced -> Integrated Peripherals -> Watch Dog Feature
115 * For P4DPx:
116 * BIOS setup -> Advanced -> I/O Device Configuration -> Watch Dog
117 * This setting enables or disables Watchdog function. When enabled, the
118 * default watchdog timer is set to be 5 minutes (about 4’35â€). It is
119 * enough to load and run the OS. The application (service or driver) has
120 * to take over the control once OS is running up and before watchdog
121 * expires.
122 *
123 * 2. JUMPER
124 * For P4SBx: JP39
125 * For P4DPx: JP37
126 * This jumper is used for safety. Closed is enabled. This jumper
127 * prevents user enables watchdog in BIOS by accident.
128 *
129 * To enable Watch Dog function, both BIOS and JUMPER must be enabled.
130 *
131 * The documentation lists motherboards P4SBx and P4DPx series as of
132 * 20-March-2002. However, this code works flawlessly with much newer
133 * motherboards, such as my X6DHR-8G2 (SuperServer 6014H-82).
134 *
135 * The original iTCO driver as written does not actually reset the
136 * watchdog timer on these machines, as a result they reboot after five
137 * minutes.
138 *
139 * NOTE: You may leave the Watchdog function disabled in the SuperMicro
140 * BIOS to avoid a "boot-race"... This driver will enable watchdog
141 * functionality even if it's disabled in the BIOS once the /dev/watchdog
142 * file is opened.
143 */
144
145/* I/O Port's */
146#define SM_REGINDEX 0x2e /* SuperMicro ICH4+ Register Index */
147#define SM_DATAIO 0x2f /* SuperMicro ICH4+ Register Data I/O */
148
149/* Control Register's */
150#define SM_CTLPAGESW 0x07 /* SuperMicro ICH4+ Control Page Switch */
151#define SM_CTLPAGE 0x08 /* SuperMicro ICH4+ Control Page Num */
152
153#define SM_WATCHENABLE 0x30 /* Watchdog enable: Bit 0: 0=off, 1=on */
154
155#define SM_WATCHPAGE 0x87 /* Watchdog unlock control page */
156
157#define SM_ENDWATCH 0xAA /* Watchdog lock control page */
158
159#define SM_COUNTMODE 0xf5 /* Watchdog count mode select */
160 /* (Bit 3: 0 = seconds, 1 = minutes */
161
162#define SM_WATCHTIMER 0xf6 /* 8-bits, Watchdog timer counter (RW) */
163
164#define SM_RESETCONTROL 0xf7 /* Watchdog reset control */
165 /* Bit 6: timer is reset by kbd interrupt */
166 /* Bit 7: timer is reset by mouse interrupt */
167
168static void supermicro_new_unlock_watchdog(void)
169{
170 outb(SM_WATCHPAGE, SM_REGINDEX); /* Write 0x87 to port 0x2e twice */
171 outb(SM_WATCHPAGE, SM_REGINDEX);
172
173 outb(SM_CTLPAGESW, SM_REGINDEX); /* Switch to watchdog control page */
174 outb(SM_CTLPAGE, SM_DATAIO);
175}
176
177static void supermicro_new_lock_watchdog(void)
178{
179 outb(SM_ENDWATCH, SM_REGINDEX);
180}
181
182static void supermicro_new_pre_start(unsigned int heartbeat)
183{
184 unsigned int val;
185
186 supermicro_new_unlock_watchdog();
187
188 /* Watchdog timer setting needs to be in seconds*/
189 outb(SM_COUNTMODE, SM_REGINDEX);
190 val = inb(SM_DATAIO);
191 val &= 0xF7;
192 outb(val, SM_DATAIO);
193
194 /* Write heartbeat interval to WDOG */
195 outb (SM_WATCHTIMER, SM_REGINDEX);
196 outb((heartbeat & 255), SM_DATAIO);
197
198 /* Make sure keyboard/mouse interrupts don't interfere */
199 outb(SM_RESETCONTROL, SM_REGINDEX);
200 val = inb(SM_DATAIO);
201 val &= 0x3f;
202 outb(val, SM_DATAIO);
203
204 /* enable watchdog by setting bit 0 of Watchdog Enable to 1 */
205 outb(SM_WATCHENABLE, SM_REGINDEX);
206 val = inb(SM_DATAIO);
207 val |= 0x01;
208 outb(val, SM_DATAIO);
209
210 supermicro_new_lock_watchdog();
211}
212
213static void supermicro_new_pre_stop(void)
214{
215 unsigned int val;
216
217 supermicro_new_unlock_watchdog();
218
219 /* disable watchdog by setting bit 0 of Watchdog Enable to 0 */
220 outb(SM_WATCHENABLE, SM_REGINDEX);
221 val = inb(SM_DATAIO);
222 val &= 0xFE;
223 outb(val, SM_DATAIO);
224
225 supermicro_new_lock_watchdog();
226}
227
228static void supermicro_new_pre_set_heartbeat(unsigned int heartbeat)
229{
230 supermicro_new_unlock_watchdog();
231
232 /* reset watchdog timeout to heartveat value */
233 outb(SM_WATCHTIMER, SM_REGINDEX);
234 outb((heartbeat & 255), SM_DATAIO);
235
236 supermicro_new_lock_watchdog();
237}
238
239/*
240 * Generic Support Functions
241 */
242
243void iTCO_vendor_pre_start(unsigned long acpibase,
244 unsigned int heartbeat)
245{
246 if (vendorsupport == SUPERMICRO_OLD_BOARD)
247 supermicro_old_pre_start(acpibase);
248 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
249 supermicro_new_pre_start(heartbeat);
250}
251EXPORT_SYMBOL(iTCO_vendor_pre_start);
252
253void iTCO_vendor_pre_stop(unsigned long acpibase)
254{
255 if (vendorsupport == SUPERMICRO_OLD_BOARD)
256 supermicro_old_pre_stop(acpibase);
257 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
258 supermicro_new_pre_stop();
259}
260EXPORT_SYMBOL(iTCO_vendor_pre_stop);
261
262void iTCO_vendor_pre_keepalive(unsigned long acpibase, unsigned int heartbeat)
263{
264 if (vendorsupport == SUPERMICRO_OLD_BOARD)
265 supermicro_old_pre_keepalive(acpibase);
266 else if (vendorsupport == SUPERMICRO_NEW_BOARD)
267 supermicro_new_pre_set_heartbeat(heartbeat);
268}
269EXPORT_SYMBOL(iTCO_vendor_pre_keepalive);
270
271void iTCO_vendor_pre_set_heartbeat(unsigned int heartbeat)
272{
273 if (vendorsupport == SUPERMICRO_NEW_BOARD)
274 supermicro_new_pre_set_heartbeat(heartbeat);
275}
276EXPORT_SYMBOL(iTCO_vendor_pre_set_heartbeat);
277
278int iTCO_vendor_check_noreboot_on(void)
279{
280 switch(vendorsupport) {
281 case SUPERMICRO_OLD_BOARD:
282 return 0;
283 default:
284 return 1;
285 }
286}
287EXPORT_SYMBOL(iTCO_vendor_check_noreboot_on);
288
289static int __init iTCO_vendor_init_module(void)
290{
291 printk (KERN_INFO PFX "vendor-support=%d\n", vendorsupport);
292 return 0;
293}
294
295static void __exit iTCO_vendor_exit_module(void)
296{
297 printk (KERN_INFO PFX "Module Unloaded\n");
298}
299
300module_init(iTCO_vendor_init_module);
301module_exit(iTCO_vendor_exit_module);
302
303MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>, R. Seretny <lkpatches@paypc.com>");
304MODULE_DESCRIPTION("Intel TCO Vendor Specific WatchDog Timer Driver Support");
305MODULE_VERSION(DRV_VERSION);
306MODULE_LICENSE("GPL");
307
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index b6f29cb8bd39..7eac922df867 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -48,8 +48,8 @@
48 48
49/* Module and version information */ 49/* Module and version information */
50#define DRV_NAME "iTCO_wdt" 50#define DRV_NAME "iTCO_wdt"
51#define DRV_VERSION "1.00" 51#define DRV_VERSION "1.01"
52#define DRV_RELDATE "08-Oct-2006" 52#define DRV_RELDATE "11-Nov-2006"
53#define PFX DRV_NAME ": " 53#define PFX DRV_NAME ": "
54 54
55/* Includes */ 55/* Includes */
@@ -189,6 +189,21 @@ static int nowayout = WATCHDOG_NOWAYOUT;
189module_param(nowayout, int, 0); 189module_param(nowayout, int, 0);
190MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 190MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
191 191
192/* iTCO Vendor Specific Support hooks */
193#ifdef CONFIG_ITCO_VENDOR_SUPPORT
194extern void iTCO_vendor_pre_start(unsigned long, unsigned int);
195extern void iTCO_vendor_pre_stop(unsigned long);
196extern void iTCO_vendor_pre_keepalive(unsigned long, unsigned int);
197extern void iTCO_vendor_pre_set_heartbeat(unsigned int);
198extern int iTCO_vendor_check_noreboot_on(void);
199#else
200#define iTCO_vendor_pre_start(acpibase, heartbeat) {}
201#define iTCO_vendor_pre_stop(acpibase) {}
202#define iTCO_vendor_pre_keepalive(acpibase,heartbeat) {}
203#define iTCO_vendor_pre_set_heartbeat(heartbeat) {}
204#define iTCO_vendor_check_noreboot_on() 1 /* 1=check noreboot; 0=don't check */
205#endif
206
192/* 207/*
193 * Some TCO specific functions 208 * Some TCO specific functions
194 */ 209 */
@@ -249,6 +264,8 @@ static int iTCO_wdt_start(void)
249 264
250 spin_lock(&iTCO_wdt_private.io_lock); 265 spin_lock(&iTCO_wdt_private.io_lock);
251 266
267 iTCO_vendor_pre_start(iTCO_wdt_private.ACPIBASE, heartbeat);
268
252 /* disable chipset's NO_REBOOT bit */ 269 /* disable chipset's NO_REBOOT bit */
253 if (iTCO_wdt_unset_NO_REBOOT_bit()) { 270 if (iTCO_wdt_unset_NO_REBOOT_bit()) {
254 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); 271 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n");
@@ -273,6 +290,8 @@ static int iTCO_wdt_stop(void)
273 290
274 spin_lock(&iTCO_wdt_private.io_lock); 291 spin_lock(&iTCO_wdt_private.io_lock);
275 292
293 iTCO_vendor_pre_stop(iTCO_wdt_private.ACPIBASE);
294
276 /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */ 295 /* Bit 11: TCO Timer Halt -> 1 = The TCO timer is disabled */
277 val = inw(TCO1_CNT); 296 val = inw(TCO1_CNT);
278 val |= 0x0800; 297 val |= 0x0800;
@@ -293,6 +312,8 @@ static int iTCO_wdt_keepalive(void)
293{ 312{
294 spin_lock(&iTCO_wdt_private.io_lock); 313 spin_lock(&iTCO_wdt_private.io_lock);
295 314
315 iTCO_vendor_pre_keepalive(iTCO_wdt_private.ACPIBASE, heartbeat);
316
296 /* Reload the timer by writing to the TCO Timer Counter register */ 317 /* Reload the timer by writing to the TCO Timer Counter register */
297 if (iTCO_wdt_private.iTCO_version == 2) { 318 if (iTCO_wdt_private.iTCO_version == 2) {
298 outw(0x01, TCO_RLD); 319 outw(0x01, TCO_RLD);
@@ -319,6 +340,8 @@ static int iTCO_wdt_set_heartbeat(int t)
319 ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f))) 340 ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f)))
320 return -EINVAL; 341 return -EINVAL;
321 342
343 iTCO_vendor_pre_set_heartbeat(tmrval);
344
322 /* Write new heartbeat to watchdog */ 345 /* Write new heartbeat to watchdog */
323 if (iTCO_wdt_private.iTCO_version == 2) { 346 if (iTCO_wdt_private.iTCO_version == 2) {
324 spin_lock(&iTCO_wdt_private.io_lock); 347 spin_lock(&iTCO_wdt_private.io_lock);
@@ -569,7 +592,7 @@ static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent,
569 } 592 }
570 593
571 /* Check chipset's NO_REBOOT bit */ 594 /* Check chipset's NO_REBOOT bit */
572 if (iTCO_wdt_unset_NO_REBOOT_bit()) { 595 if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) {
573 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n"); 596 printk(KERN_ERR PFX "failed to reset NO_REBOOT flag, reboot disabled by hardware\n");
574 ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ 597 ret = -ENODEV; /* Cannot reset NO_REBOOT bit */
575 goto out; 598 goto out;
diff --git a/drivers/char/watchdog/pc87413_wdt.c b/drivers/char/watchdog/pc87413_wdt.c
new file mode 100644
index 000000000000..1d447e32af41
--- /dev/null
+++ b/drivers/char/watchdog/pc87413_wdt.c
@@ -0,0 +1,635 @@
1/*
2 * NS pc87413-wdt Watchdog Timer driver for Linux 2.6.x.x
3 *
4 * This code is based on wdt.c with original copyright.
5 *
6 * (C) Copyright 2006 Sven Anders, <anders@anduras.de>
7 * and Marcus Junker, <junker@anduras.de>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 * Neither Sven Anders, Marcus Junker nor ANDURAS AG
15 * admit liability nor provide warranty for any of this software.
16 * This material is provided "AS-IS" and at no charge.
17 *
18 * Release 1.1
19 */
20
21#include <linux/module.h>
22#include <linux/types.h>
23#include <linux/miscdevice.h>
24#include <linux/watchdog.h>
25#include <linux/ioport.h>
26#include <linux/delay.h>
27#include <linux/notifier.h>
28#include <linux/fs.h>
29#include <linux/reboot.h>
30#include <linux/init.h>
31#include <linux/spinlock.h>
32#include <linux/moduleparam.h>
33#include <linux/version.h>
34
35#include <asm/io.h>
36#include <asm/uaccess.h>
37#include <asm/system.h>
38
39/* #define DEBUG 1 */
40
41#define DEFAULT_TIMEOUT 1 /* 1 minute */
42#define MAX_TIMEOUT 255
43
44#define VERSION "1.1"
45#define MODNAME "pc87413 WDT"
46#define PFX MODNAME ": "
47#define DPFX MODNAME " - DEBUG: "
48
49#define WDT_INDEX_IO_PORT (io+0) /* I/O port base (index register) */
50#define WDT_DATA_IO_PORT (WDT_INDEX_IO_PORT+1)
51#define SWC_LDN 0x04
52#define SIOCFG2 0x22 /* Serial IO register */
53#define WDCTL 0x10 /* Watchdog-Timer-Controll-Register */
54#define WDTO 0x11 /* Watchdog timeout register */
55#define WDCFG 0x12 /* Watchdog config register */
56
57static int io = 0x2E; /* Address used on Portwell Boards */
58
59static int timeout = DEFAULT_TIMEOUT; /* timeout value */
60static unsigned long timer_enabled = 0; /* is the timer enabled? */
61
62static char expect_close; /* is the close expected? */
63
64static spinlock_t io_lock; /* to guard the watchdog from io races */
65
66static int nowayout = WATCHDOG_NOWAYOUT;
67
68/* -- Low level function ----------------------------------------*/
69
70/* Select pins for Watchdog output */
71
72static inline void pc87413_select_wdt_out (void)
73{
74 unsigned int cr_data = 0;
75
76 /* Step 1: Select multiple pin,pin55,as WDT output */
77
78 outb_p(SIOCFG2, WDT_INDEX_IO_PORT);
79
80 cr_data = inb (WDT_DATA_IO_PORT);
81
82 cr_data |= 0x80; /* Set Bit7 to 1*/
83 outb_p(SIOCFG2, WDT_INDEX_IO_PORT);
84
85 outb_p(cr_data, WDT_DATA_IO_PORT);
86
87#ifdef DEBUG
88 printk(KERN_INFO DPFX "Select multiple pin,pin55,as WDT output:"
89 " Bit7 to 1: %d\n", cr_data);
90#endif
91}
92
93/* Enable SWC functions */
94
95static inline void pc87413_enable_swc(void)
96{
97 unsigned int cr_data=0;
98
99 /* Step 2: Enable SWC functions */
100
101 outb_p(0x07, WDT_INDEX_IO_PORT); /* Point SWC_LDN (LDN=4) */
102 outb_p(SWC_LDN, WDT_DATA_IO_PORT);
103
104 outb_p(0x30, WDT_INDEX_IO_PORT); /* Read Index 0x30 First */
105 cr_data = inb(WDT_DATA_IO_PORT);
106 cr_data |= 0x01; /* Set Bit0 to 1 */
107 outb_p(0x30, WDT_INDEX_IO_PORT);
108 outb_p(cr_data, WDT_DATA_IO_PORT); /* Index0x30_bit0P1 */
109
110#ifdef DEBUG
111 printk(KERN_INFO DPFX "pc87413 - Enable SWC functions\n");
112#endif
113}
114
115/* Read SWC I/O base address */
116
117static inline unsigned int pc87413_get_swc_base(void)
118{
119 unsigned int swc_base_addr = 0;
120 unsigned char addr_l, addr_h = 0;
121
122 /* Step 3: Read SWC I/O Base Address */
123
124 outb_p(0x60, WDT_INDEX_IO_PORT); /* Read Index 0x60 */
125 addr_h = inb(WDT_DATA_IO_PORT);
126
127 outb_p(0x61, WDT_INDEX_IO_PORT); /* Read Index 0x61 */
128
129 addr_l = inb(WDT_DATA_IO_PORT);
130
131 swc_base_addr = (addr_h << 8) + addr_l;
132
133#ifdef DEBUG
134 printk(KERN_INFO DPFX "Read SWC I/O Base Address: low %d, high %d,"
135 " res %d\n", addr_l, addr_h, swc_base_addr);
136#endif
137
138 return swc_base_addr;
139}
140
141/* Select Bank 3 of SWC */
142
143static inline void pc87413_swc_bank3(unsigned int swc_base_addr)
144{
145 /* Step 4: Select Bank3 of SWC */
146
147 outb_p(inb(swc_base_addr + 0x0f) | 0x03, swc_base_addr + 0x0f);
148
149#ifdef DEBUG
150 printk(KERN_INFO DPFX "Select Bank3 of SWC\n");
151#endif
152}
153
154/* Set watchdog timeout to x minutes */
155
156static inline void pc87413_programm_wdto(unsigned int swc_base_addr,
157 char pc87413_time)
158{
159 /* Step 5: Programm WDTO, Twd. */
160
161 outb_p(pc87413_time, swc_base_addr + WDTO);
162
163#ifdef DEBUG
164 printk(KERN_INFO DPFX "Set WDTO to %d minutes\n", pc87413_time);
165#endif
166}
167
168/* Enable WDEN */
169
170static inline void pc87413_enable_wden(unsigned int swc_base_addr)
171{
172 /* Step 6: Enable WDEN */
173
174 outb_p(inb (swc_base_addr + WDCTL) | 0x01, swc_base_addr + WDCTL);
175
176#ifdef DEBUG
177 printk(KERN_INFO DPFX "Enable WDEN\n");
178#endif
179}
180
181/* Enable SW_WD_TREN */
182static inline void pc87413_enable_sw_wd_tren(unsigned int swc_base_addr)
183{
184 /* Enable SW_WD_TREN */
185
186 outb_p(inb (swc_base_addr + WDCFG) | 0x80, swc_base_addr + WDCFG);
187
188#ifdef DEBUG
189 printk(KERN_INFO DPFX "Enable SW_WD_TREN\n");
190#endif
191}
192
193/* Disable SW_WD_TREN */
194
195static inline void pc87413_disable_sw_wd_tren(unsigned int swc_base_addr)
196{
197 /* Disable SW_WD_TREN */
198
199 outb_p(inb (swc_base_addr + WDCFG) & 0x7f, swc_base_addr + WDCFG);
200
201#ifdef DEBUG
202 printk(KERN_INFO DPFX "pc87413 - Disable SW_WD_TREN\n");
203#endif
204}
205
206/* Enable SW_WD_TRG */
207
208static inline void pc87413_enable_sw_wd_trg(unsigned int swc_base_addr)
209{
210 /* Enable SW_WD_TRG */
211
212 outb_p(inb (swc_base_addr + WDCTL) | 0x80, swc_base_addr + WDCTL);
213
214#ifdef DEBUG
215 printk(KERN_INFO DPFX "pc87413 - Enable SW_WD_TRG\n");
216#endif
217}
218
219/* Disable SW_WD_TRG */
220
221static inline void pc87413_disable_sw_wd_trg(unsigned int swc_base_addr)
222{
223 /* Disable SW_WD_TRG */
224
225 outb_p(inb (swc_base_addr + WDCTL) & 0x7f, swc_base_addr + WDCTL);
226
227#ifdef DEBUG
228 printk(KERN_INFO DPFX "Disable SW_WD_TRG\n");
229#endif
230}
231
232/* -- Higher level functions ------------------------------------*/
233
234/* Enable the watchdog */
235
236static void pc87413_enable(void)
237{
238 unsigned int swc_base_addr;
239
240 spin_lock(&io_lock);
241
242 pc87413_select_wdt_out();
243 pc87413_enable_swc();
244 swc_base_addr = pc87413_get_swc_base();
245 pc87413_swc_bank3(swc_base_addr);
246 pc87413_programm_wdto(swc_base_addr, timeout);
247 pc87413_enable_wden(swc_base_addr);
248 pc87413_enable_sw_wd_tren(swc_base_addr);
249 pc87413_enable_sw_wd_trg(swc_base_addr);
250
251 spin_unlock(&io_lock);
252}
253
254/* Disable the watchdog */
255
256static void pc87413_disable(void)
257{
258 unsigned int swc_base_addr;
259
260 spin_lock(&io_lock);
261
262 pc87413_select_wdt_out();
263 pc87413_enable_swc();
264 swc_base_addr = pc87413_get_swc_base();
265 pc87413_swc_bank3(swc_base_addr);
266 pc87413_disable_sw_wd_tren(swc_base_addr);
267 pc87413_disable_sw_wd_trg(swc_base_addr);
268 pc87413_programm_wdto(swc_base_addr, 0);
269
270 spin_unlock(&io_lock);
271}
272
273/* Refresh the watchdog */
274
275static void pc87413_refresh(void)
276{
277 unsigned int swc_base_addr;
278
279 spin_lock(&io_lock);
280
281 pc87413_select_wdt_out();
282 pc87413_enable_swc();
283 swc_base_addr = pc87413_get_swc_base();
284 pc87413_swc_bank3(swc_base_addr);
285 pc87413_disable_sw_wd_tren(swc_base_addr);
286 pc87413_disable_sw_wd_trg(swc_base_addr);
287 pc87413_programm_wdto(swc_base_addr, timeout);
288 pc87413_enable_wden(swc_base_addr);
289 pc87413_enable_sw_wd_tren(swc_base_addr);
290 pc87413_enable_sw_wd_trg(swc_base_addr);
291
292 spin_unlock(&io_lock);
293}
294
295/* -- File operations -------------------------------------------*/
296
297/**
298 * pc87413_open:
299 * @inode: inode of device
300 * @file: file handle to device
301 *
302 */
303
304static int pc87413_open(struct inode *inode, struct file *file)
305{
306 /* /dev/watchdog can only be opened once */
307
308 if (test_and_set_bit(0, &timer_enabled))
309 return -EBUSY;
310
311 if (nowayout)
312 __module_get(THIS_MODULE);
313
314 /* Reload and activate timer */
315 pc87413_refresh();
316
317 printk(KERN_INFO MODNAME "Watchdog enabled. Timeout set to"
318 " %d minute(s).\n", timeout);
319
320 return nonseekable_open(inode, file);
321}
322
323/**
324 * pc87413_release:
325 * @inode: inode to board
326 * @file: file handle to board
327 *
328 * The watchdog has a configurable API. There is a religious dispute
329 * between people who want their watchdog to be able to shut down and
330 * those who want to be sure if the watchdog manager dies the machine
331 * reboots. In the former case we disable the counters, in the latter
332 * case you have to open it again very soon.
333 */
334
335static int pc87413_release(struct inode *inode, struct file *file)
336{
337 /* Shut off the timer. */
338
339 if (expect_close == 42) {
340 pc87413_disable();
341 printk(KERN_INFO MODNAME "Watchdog disabled,"
342 " sleeping again...\n");
343 } else {
344 printk(KERN_CRIT MODNAME "Unexpected close, not stopping"
345 " watchdog!\n");
346 pc87413_refresh();
347 }
348
349 clear_bit(0, &timer_enabled);
350 expect_close = 0;
351
352 return 0;
353}
354
355/**
356 * pc87413_status:
357 *
358 * return, if the watchdog is enabled (timeout is set...)
359 */
360
361
362static int pc87413_status(void)
363{
364 return 0; /* currently not supported */
365}
366
367/**
368 * pc87413_write:
369 * @file: file handle to the watchdog
370 * @data: data buffer to write
371 * @len: length in bytes
372 * @ppos: pointer to the position to write. No seeks allowed
373 *
374 * A write to a watchdog device is defined as a keepalive signal. Any
375 * write of data will do, as we we don't define content meaning.
376 */
377
378static ssize_t pc87413_write(struct file *file, const char __user *data,
379 size_t len, loff_t *ppos)
380{
381 /* See if we got the magic character 'V' and reload the timer */
382 if (len) {
383 if (!nowayout) {
384 size_t i;
385
386 /* reset expect flag */
387 expect_close = 0;
388
389 /* scan to see whether or not we got the magic character */
390 for (i = 0; i != len; i++) {
391 char c;
392 if (get_user(c, data+i))
393 return -EFAULT;
394 if (c == 'V')
395 expect_close = 42;
396 }
397 }
398
399 /* someone wrote to us, we should reload the timer */
400 pc87413_refresh();
401 }
402 return len;
403}
404
405/**
406 * pc87413_ioctl:
407 * @inode: inode of the device
408 * @file: file handle to the device
409 * @cmd: watchdog command
410 * @arg: argument pointer
411 *
412 * The watchdog API defines a common set of functions for all watchdogs
413 * according to their available features. We only actually usefully support
414 * querying capabilities and current status.
415 */
416
417static int pc87413_ioctl(struct inode *inode, struct file *file,
418 unsigned int cmd, unsigned long arg)
419{
420 int new_timeout;
421
422 union {
423 struct watchdog_info __user *ident;
424 int __user *i;
425 } uarg;
426
427 static struct watchdog_info ident = {
428 .options = WDIOF_KEEPALIVEPING |
429 WDIOF_SETTIMEOUT |
430 WDIOF_MAGICCLOSE,
431 .firmware_version = 1,
432 .identity = "PC87413(HF/F) watchdog"
433 };
434
435 uarg.i = (int __user *)arg;
436
437 switch(cmd) {
438 default:
439 return -ENOTTY;
440
441 case WDIOC_GETSUPPORT:
442 return copy_to_user(uarg.ident, &ident,
443 sizeof(ident)) ? -EFAULT : 0;
444
445 case WDIOC_GETSTATUS:
446 return put_user(pc87413_status(), uarg.i);
447
448 case WDIOC_GETBOOTSTATUS:
449 return put_user(0, uarg.i);
450
451 case WDIOC_KEEPALIVE:
452 pc87413_refresh();
453#ifdef DEBUG
454 printk(KERN_INFO DPFX "keepalive\n");
455#endif
456 return 0;
457
458 case WDIOC_SETTIMEOUT:
459 if (get_user(new_timeout, uarg.i))
460 return -EFAULT;
461
462 // the API states this is given in secs
463 new_timeout /= 60;
464
465 if (new_timeout < 0 || new_timeout > MAX_TIMEOUT)
466 return -EINVAL;
467
468 timeout = new_timeout;
469 pc87413_refresh();
470
471 // fall through and return the new timeout...
472
473 case WDIOC_GETTIMEOUT:
474
475 new_timeout = timeout * 60;
476
477 return put_user(new_timeout, uarg.i);
478
479 case WDIOC_SETOPTIONS:
480 {
481 int options, retval = -EINVAL;
482
483 if (get_user(options, uarg.i))
484 return -EFAULT;
485
486 if (options & WDIOS_DISABLECARD) {
487 pc87413_disable();
488 retval = 0;
489 }
490
491 if (options & WDIOS_ENABLECARD) {
492 pc87413_enable();
493 retval = 0;
494 }
495
496 return retval;
497 }
498 }
499}
500
501/* -- Notifier funtions -----------------------------------------*/
502
503/**
504 * notify_sys:
505 * @this: our notifier block
506 * @code: the event being reported
507 * @unused: unused
508 *
509 * Our notifier is called on system shutdowns. We want to turn the card
510 * off at reboot otherwise the machine will reboot again during memory
511 * test or worse yet during the following fsck. This would suck, in fact
512 * trust me - if it happens it does suck.
513 */
514
515static int pc87413_notify_sys(struct notifier_block *this,
516 unsigned long code,
517 void *unused)
518{
519 if (code == SYS_DOWN || code == SYS_HALT)
520 {
521 /* Turn the card off */
522 pc87413_disable();
523 }
524 return NOTIFY_DONE;
525}
526
527/* -- Module's structures ---------------------------------------*/
528
529static struct file_operations pc87413_fops = {
530 .owner = THIS_MODULE,
531 .llseek = no_llseek,
532 .write = pc87413_write,
533 .ioctl = pc87413_ioctl,
534 .open = pc87413_open,
535 .release = pc87413_release,
536};
537
538static struct notifier_block pc87413_notifier =
539{
540 .notifier_call = pc87413_notify_sys,
541};
542
543static struct miscdevice pc87413_miscdev=
544{
545 .minor = WATCHDOG_MINOR,
546 .name = "watchdog",
547 .fops = &pc87413_fops
548};
549
550/* -- Module init functions -------------------------------------*/
551
552/**
553 * pc87413_init: module's "constructor"
554 *
555 * Set up the WDT watchdog board. All we have to do is grab the
556 * resources we require and bitch if anyone beat us to them.
557 * The open() function will actually kick the board off.
558 */
559
560static int __init pc87413_init(void)
561{
562 int ret;
563
564 spin_lock_init(&io_lock);
565
566 printk(KERN_INFO PFX "Version " VERSION " at io 0x%X\n", WDT_INDEX_IO_PORT);
567
568 /* request_region(io, 2, "pc87413"); */
569
570 ret = register_reboot_notifier(&pc87413_notifier);
571 if (ret != 0) {
572 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
573 ret);
574 }
575
576 ret = misc_register(&pc87413_miscdev);
577
578 if (ret != 0) {
579 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
580 WATCHDOG_MINOR, ret);
581 unregister_reboot_notifier(&pc87413_notifier);
582 return ret;
583 }
584
585 printk(KERN_INFO PFX "initialized. timeout=%d min \n", timeout);
586
587 pc87413_enable();
588
589 return 0;
590}
591
592/**
593 * pc87413_exit: module's "destructor"
594 *
595 * Unload the watchdog. You cannot do this with any file handles open.
596 * If your watchdog is set to continue ticking on close and you unload
597 * it, well it keeps ticking. We won't get the interrupt but the board
598 * will not touch PC memory so all is fine. You just have to load a new
599 * module in 60 seconds or reboot.
600 */
601
602static void __exit pc87413_exit(void)
603{
604 /* Stop the timer before we leave */
605 if (!nowayout)
606 {
607 pc87413_disable();
608 printk(KERN_INFO MODNAME "Watchdog disabled.\n");
609 }
610
611 misc_deregister(&pc87413_miscdev);
612 unregister_reboot_notifier(&pc87413_notifier);
613 /* release_region(io,2); */
614
615 printk(MODNAME " watchdog component driver removed.\n");
616}
617
618module_init(pc87413_init);
619module_exit(pc87413_exit);
620
621MODULE_AUTHOR("Sven Anders <anders@anduras.de>, Marcus Junker <junker@anduras.de>,");
622MODULE_DESCRIPTION("PC87413 WDT driver");
623MODULE_LICENSE("GPL");
624
625MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
626
627module_param(io, int, 0);
628MODULE_PARM_DESC(io, MODNAME " I/O port (default: " __MODULE_STRING(io) ").");
629
630module_param(timeout, int, 0);
631MODULE_PARM_DESC(timeout, "Watchdog timeout in minutes (default=" __MODULE_STRING(timeout) ").");
632
633module_param(nowayout, int, 0);
634MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
635
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index bda45334d802..e275dd4a705d 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -561,8 +561,7 @@ static struct notifier_block usb_pcwd_notifier = {
561 */ 561 */
562static inline void usb_pcwd_delete (struct usb_pcwd_private *usb_pcwd) 562static inline void usb_pcwd_delete (struct usb_pcwd_private *usb_pcwd)
563{ 563{
564 if (usb_pcwd->intr_urb != NULL) 564 usb_free_urb(usb_pcwd->intr_urb);
565 usb_free_urb (usb_pcwd->intr_urb);
566 if (usb_pcwd->intr_buffer != NULL) 565 if (usb_pcwd->intr_buffer != NULL)
567 usb_buffer_free(usb_pcwd->udev, usb_pcwd->intr_size, 566 usb_buffer_free(usb_pcwd->udev, usb_pcwd->intr_size,
568 usb_pcwd->intr_buffer, usb_pcwd->intr_dma); 567 usb_pcwd->intr_buffer, usb_pcwd->intr_dma);
diff --git a/drivers/char/watchdog/rm9k_wdt.c b/drivers/char/watchdog/rm9k_wdt.c
new file mode 100644
index 000000000000..ec3909371c21
--- /dev/null
+++ b/drivers/char/watchdog/rm9k_wdt.c
@@ -0,0 +1,420 @@
1/*
2 * Watchdog implementation for GPI h/w found on PMC-Sierra RM9xxx
3 * chips.
4 *
5 * Copyright (C) 2004 by Basler Vision Technologies AG
6 * Author: Thomas Koeller <thomas.koeller@baslerweb.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/platform_device.h>
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/interrupt.h>
27#include <linux/fs.h>
28#include <linux/reboot.h>
29#include <linux/notifier.h>
30#include <linux/miscdevice.h>
31#include <linux/watchdog.h>
32#include <asm/io.h>
33#include <asm/atomic.h>
34#include <asm/processor.h>
35#include <asm/uaccess.h>
36#include <asm/system.h>
37#include <asm/rm9k-ocd.h>
38
39#include <rm9k_wdt.h>
40
41
42#define CLOCK 125000000
43#define MAX_TIMEOUT_SECONDS 32
44#define CPCCR 0x0080
45#define CPGIG1SR 0x0044
46#define CPGIG1ER 0x0054
47
48
49/* Function prototypes */
50static irqreturn_t wdt_gpi_irqhdl(int, void *, struct pt_regs *);
51static void wdt_gpi_start(void);
52static void wdt_gpi_stop(void);
53static void wdt_gpi_set_timeout(unsigned int);
54static int wdt_gpi_open(struct inode *, struct file *);
55static int wdt_gpi_release(struct inode *, struct file *);
56static ssize_t wdt_gpi_write(struct file *, const char __user *, size_t, loff_t *);
57static long wdt_gpi_ioctl(struct file *, unsigned int, unsigned long);
58static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *);
59static const struct resource *wdt_gpi_get_resource(struct platform_device *, const char *, unsigned int);
60static int __init wdt_gpi_probe(struct device *);
61static int __exit wdt_gpi_remove(struct device *);
62
63
64static const char wdt_gpi_name[] = "wdt_gpi";
65static atomic_t opencnt;
66static int expect_close;
67static int locked;
68
69
70/* These are set from device resources */
71static void __iomem * wd_regs;
72static unsigned int wd_irq, wd_ctr;
73
74
75/* Module arguments */
76static int timeout = MAX_TIMEOUT_SECONDS;
77module_param(timeout, int, 0444);
78MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds");
79
80static unsigned long resetaddr = 0xbffdc200;
81module_param(resetaddr, ulong, 0444);
82MODULE_PARM_DESC(resetaddr, "Address to write to to force a reset");
83
84static unsigned long flagaddr = 0xbffdc104;
85module_param(flagaddr, ulong, 0444);
86MODULE_PARM_DESC(flagaddr, "Address to write to boot flags to");
87
88static int powercycle;
89module_param(powercycle, bool, 0444);
90MODULE_PARM_DESC(powercycle, "Cycle power if watchdog expires");
91
92static int nowayout = WATCHDOG_NOWAYOUT;
93module_param(nowayout, bool, 0444);
94MODULE_PARM_DESC(nowayout, "Watchdog cannot be disabled once started");
95
96
97/* Interrupt handler */
98static irqreturn_t wdt_gpi_irqhdl(int irq, void *ctxt, struct pt_regs *regs)
99{
100 if (!unlikely(__raw_readl(wd_regs + 0x0008) & 0x1))
101 return IRQ_NONE;
102 __raw_writel(0x1, wd_regs + 0x0008);
103
104
105 printk(KERN_CRIT "%s: watchdog expired - resetting system\n",
106 wdt_gpi_name);
107
108 *(volatile char *) flagaddr |= 0x01;
109 *(volatile char *) resetaddr = powercycle ? 0x01 : 0x2;
110 iob();
111 while (1)
112 cpu_relax();
113}
114
115
116/* Watchdog functions */
117static void wdt_gpi_start(void)
118{
119 u32 reg;
120
121 lock_titan_regs();
122 reg = titan_readl(CPGIG1ER);
123 titan_writel(reg | (0x100 << wd_ctr), CPGIG1ER);
124 iob();
125 unlock_titan_regs();
126}
127
128static void wdt_gpi_stop(void)
129{
130 u32 reg;
131
132 lock_titan_regs();
133 reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
134 titan_writel(reg, CPCCR);
135 reg = titan_readl(CPGIG1ER);
136 titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
137 iob();
138 unlock_titan_regs();
139}
140
141static void wdt_gpi_set_timeout(unsigned int to)
142{
143 u32 reg;
144 const u32 wdval = (to * CLOCK) & ~0x0000000f;
145
146 lock_titan_regs();
147 reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
148 titan_writel(reg, CPCCR);
149 wmb();
150 __raw_writel(wdval, wd_regs + 0x0000);
151 wmb();
152 titan_writel(reg | (0x2 << (wd_ctr * 4)), CPCCR);
153 wmb();
154 titan_writel(reg | (0x5 << (wd_ctr * 4)), CPCCR);
155 iob();
156 unlock_titan_regs();
157}
158
159
160/* /dev/watchdog operations */
161static int wdt_gpi_open(struct inode *inode, struct file *file)
162{
163 int res;
164
165 if (unlikely(atomic_dec_if_positive(&opencnt) < 0))
166 return -EBUSY;
167
168 expect_close = 0;
169 if (locked) {
170 module_put(THIS_MODULE);
171 free_irq(wd_irq, &miscdev);
172 locked = 0;
173 }
174
175 res = request_irq(wd_irq, wdt_gpi_irqhdl, SA_SHIRQ | SA_INTERRUPT,
176 wdt_gpi_name, &miscdev);
177 if (unlikely(res))
178 return res;
179
180 wdt_gpi_set_timeout(timeout);
181 wdt_gpi_start();
182
183 printk(KERN_INFO "%s: watchdog started, timeout = %u seconds\n",
184 wdt_gpi_name, timeout);
185 return nonseekable_open(inode, file);
186}
187
188static int wdt_gpi_release(struct inode *inode, struct file *file)
189{
190 if (nowayout) {
191 printk(KERN_INFO "%s: no way out - watchdog left running\n",
192 wdt_gpi_name);
193 __module_get(THIS_MODULE);
194 locked = 1;
195 } else {
196 if (expect_close) {
197 wdt_gpi_stop();
198 free_irq(wd_irq, &miscdev);
199 printk(KERN_INFO "%s: watchdog stopped\n", wdt_gpi_name);
200 } else {
201 printk(KERN_CRIT "%s: unexpected close() -"
202 " watchdog left running\n",
203 wdt_gpi_name);
204 wdt_gpi_set_timeout(timeout);
205 __module_get(THIS_MODULE);
206 locked = 1;
207 }
208 }
209
210 atomic_inc(&opencnt);
211 return 0;
212}
213
214static ssize_t
215wdt_gpi_write(struct file *f, const char __user *d, size_t s, loff_t *o)
216{
217 char val;
218
219 wdt_gpi_set_timeout(timeout);
220 expect_close = (s > 0) && !get_user(val, d) && (val == 'V');
221 return s ? 1 : 0;
222}
223
224static long
225wdt_gpi_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
226{
227 long res = -ENOTTY;
228 const long size = _IOC_SIZE(cmd);
229 int stat;
230 void __user *argp = (void __user *)arg;
231 static struct watchdog_info wdinfo = {
232 .identity = "RM9xxx/GPI watchdog",
233 .firmware_version = 0,
234 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING
235 };
236
237 if (unlikely(_IOC_TYPE(cmd) != WATCHDOG_IOCTL_BASE))
238 return -ENOTTY;
239
240 if ((_IOC_DIR(cmd) & _IOC_READ)
241 && !access_ok(VERIFY_WRITE, arg, size))
242 return -EFAULT;
243
244 if ((_IOC_DIR(cmd) & _IOC_WRITE)
245 && !access_ok(VERIFY_READ, arg, size))
246 return -EFAULT;
247
248 expect_close = 0;
249
250 switch (cmd) {
251 case WDIOC_GETSUPPORT:
252 wdinfo.options = nowayout ?
253 WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING :
254 WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE;
255 res = __copy_to_user(argp, &wdinfo, size) ? -EFAULT : size;
256 break;
257
258 case WDIOC_GETSTATUS:
259 break;
260
261 case WDIOC_GETBOOTSTATUS:
262 stat = (*(volatile char *) flagaddr & 0x01)
263 ? WDIOF_CARDRESET : 0;
264 res = __copy_to_user(argp, &stat, size) ?
265 -EFAULT : size;
266 break;
267
268 case WDIOC_SETOPTIONS:
269 break;
270
271 case WDIOC_KEEPALIVE:
272 wdt_gpi_set_timeout(timeout);
273 res = size;
274 break;
275
276 case WDIOC_SETTIMEOUT:
277 {
278 int val;
279 if (unlikely(__copy_from_user(&val, argp, size))) {
280 res = -EFAULT;
281 break;
282 }
283
284 if (val > MAX_TIMEOUT_SECONDS)
285 val = MAX_TIMEOUT_SECONDS;
286 timeout = val;
287 wdt_gpi_set_timeout(val);
288 res = size;
289 printk(KERN_INFO "%s: timeout set to %u seconds\n",
290 wdt_gpi_name, timeout);
291 }
292 break;
293
294 case WDIOC_GETTIMEOUT:
295 res = __copy_to_user(argp, &timeout, size) ?
296 -EFAULT : size;
297 break;
298 }
299
300 return res;
301}
302
303
304/* Shutdown notifier */
305static int
306wdt_gpi_notify(struct notifier_block *this, unsigned long code, void *unused)
307{
308 if (code == SYS_DOWN || code == SYS_HALT)
309 wdt_gpi_stop();
310
311 return NOTIFY_DONE;
312}
313
314
315/* Kernel interfaces */
316static struct file_operations fops = {
317 .owner = THIS_MODULE,
318 .open = wdt_gpi_open,
319 .release = wdt_gpi_release,
320 .write = wdt_gpi_write,
321 .unlocked_ioctl = wdt_gpi_ioctl,
322};
323
324static struct miscdevice miscdev = {
325 .minor = WATCHDOG_MINOR,
326 .name = wdt_gpi_name,
327 .fops = &fops,
328};
329
330static struct notifier_block wdt_gpi_shutdown = {
331 .notifier_call = wdt_gpi_notify,
332};
333
334
335/* Init & exit procedures */
336static const struct resource *
337wdt_gpi_get_resource(struct platform_device *pdv, const char *name,
338 unsigned int type)
339{
340 char buf[80];
341 if (snprintf(buf, sizeof buf, "%s_0", name) >= sizeof buf)
342 return NULL;
343 return platform_get_resource_byname(pdv, type, buf);
344}
345
346/* No hotplugging on the platform bus - use __init */
347static int __init wdt_gpi_probe(struct device *dev)
348{
349 int res;
350 struct platform_device * const pdv = to_platform_device(dev);
351 const struct resource
352 * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS,
353 IORESOURCE_MEM),
354 * const ri = wdt_gpi_get_resource(pdv, WDT_RESOURCE_IRQ,
355 IORESOURCE_IRQ),
356 * const rc = wdt_gpi_get_resource(pdv, WDT_RESOURCE_COUNTER,
357 0);
358
359 if (unlikely(!rr || !ri || !rc))
360 return -ENXIO;
361
362 wd_regs = ioremap_nocache(rr->start, rr->end + 1 - rr->start);
363 if (unlikely(!wd_regs))
364 return -ENOMEM;
365 wd_irq = ri->start;
366 wd_ctr = rc->start;
367 res = misc_register(&miscdev);
368 if (res)
369 iounmap(wd_regs);
370 else
371 register_reboot_notifier(&wdt_gpi_shutdown);
372 return res;
373}
374
375static int __exit wdt_gpi_remove(struct device *dev)
376{
377 int res;
378
379 unregister_reboot_notifier(&wdt_gpi_shutdown);
380 res = misc_deregister(&miscdev);
381 iounmap(wd_regs);
382 wd_regs = NULL;
383 return res;
384}
385
386
387/* Device driver init & exit */
388static struct device_driver wdt_gpi_driver = {
389 .name = (char *) wdt_gpi_name,
390 .bus = &platform_bus_type,
391 .owner = THIS_MODULE,
392 .probe = wdt_gpi_probe,
393 .remove = __exit_p(wdt_gpi_remove),
394 .shutdown = NULL,
395 .suspend = NULL,
396 .resume = NULL,
397};
398
399static int __init wdt_gpi_init_module(void)
400{
401 atomic_set(&opencnt, 1);
402 if (timeout > MAX_TIMEOUT_SECONDS)
403 timeout = MAX_TIMEOUT_SECONDS;
404 return driver_register(&wdt_gpi_driver);
405}
406
407static void __exit wdt_gpi_cleanup_module(void)
408{
409 driver_unregister(&wdt_gpi_driver);
410}
411
412module_init(wdt_gpi_init_module);
413module_exit(wdt_gpi_cleanup_module);
414
415MODULE_AUTHOR("Thomas Koeller <thomas.koeller@baslerweb.com>");
416MODULE_DESCRIPTION("Basler eXcite watchdog driver for gpi devices");
417MODULE_VERSION("0.1");
418MODULE_LICENSE("GPL");
419MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
420
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 510816c16da3..04bee524e31a 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -125,6 +125,7 @@ config I2C_I801
125 ICH7 125 ICH7
126 ESB2 126 ESB2
127 ICH8 127 ICH8
128 ICH9
128 129
129 This driver can also be built as a module. If so, the module 130 This driver can also be built as a module. If so, the module
130 will be called i2c-i801. 131 will be called i2c-i801.
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index bbb2fbee836f..c7be2fdbd86b 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -33,6 +33,7 @@
33 ICH7 27DA 33 ICH7 27DA
34 ESB2 269B 34 ESB2 269B
35 ICH8 283E 35 ICH8 283E
36 ICH9 2930
36 This driver supports several versions of Intel's I/O Controller Hubs (ICH). 37 This driver supports several versions of Intel's I/O Controller Hubs (ICH).
37 For SMBus support, they are similar to the PIIX4 and are part 38 For SMBus support, they are similar to the PIIX4 and are part
38 of Intel's '810' and other chipsets. 39 of Intel's '810' and other chipsets.
@@ -457,6 +458,7 @@ static struct pci_device_id i801_ids[] = {
457 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) }, 458 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) },
458 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) }, 459 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) },
459 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) }, 460 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) },
461 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_6) },
460 { 0, } 462 { 0, }
461}; 463};
462 464
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index 05fffb9415a2..68fe863f9d54 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -138,7 +138,7 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
138 gpio_line_set(gpio->sda_pin, 0); 138 gpio_line_set(gpio->sda_pin, 0);
139 139
140 err = i2c_bit_add_bus(&drv_data->adapter); 140 err = i2c_bit_add_bus(&drv_data->adapter);
141 if (err != 0) 141 if (err) {
142 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id); 142 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id);
143 143
144 kfree(drv_data); 144 kfree(drv_data);
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 3f869033ed70..94a4e9a3013c 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -42,7 +42,7 @@ static struct i2c_driver i2cdev_driver;
42struct i2c_dev { 42struct i2c_dev {
43 struct list_head list; 43 struct list_head list;
44 struct i2c_adapter *adap; 44 struct i2c_adapter *adap;
45 struct class_device *class_dev; 45 struct device *dev;
46}; 46};
47 47
48#define I2C_MINORS 256 48#define I2C_MINORS 256
@@ -92,15 +92,16 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev)
92 spin_unlock(&i2c_dev_list_lock); 92 spin_unlock(&i2c_dev_list_lock);
93} 93}
94 94
95static ssize_t show_adapter_name(struct class_device *class_dev, char *buf) 95static ssize_t show_adapter_name(struct device *dev,
96 struct device_attribute *attr, char *buf)
96{ 97{
97 struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(class_dev->devt)); 98 struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(dev->devt));
98 99
99 if (!i2c_dev) 100 if (!i2c_dev)
100 return -ENODEV; 101 return -ENODEV;
101 return sprintf(buf, "%s\n", i2c_dev->adap->name); 102 return sprintf(buf, "%s\n", i2c_dev->adap->name);
102} 103}
103static CLASS_DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); 104static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
104 105
105static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count, 106static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count,
106 loff_t *offset) 107 loff_t *offset)
@@ -413,15 +414,14 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
413 return PTR_ERR(i2c_dev); 414 return PTR_ERR(i2c_dev);
414 415
415 /* register this i2c device with the driver core */ 416 /* register this i2c device with the driver core */
416 i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL, 417 i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
417 MKDEV(I2C_MAJOR, adap->nr), 418 MKDEV(I2C_MAJOR, adap->nr),
418 &adap->dev, "i2c-%d", 419 "i2c-%d", adap->nr);
419 adap->nr); 420 if (!i2c_dev->dev) {
420 if (!i2c_dev->class_dev) {
421 res = -ENODEV; 421 res = -ENODEV;
422 goto error; 422 goto error;
423 } 423 }
424 res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name); 424 res = device_create_file(i2c_dev->dev, &dev_attr_name);
425 if (res) 425 if (res)
426 goto error_destroy; 426 goto error_destroy;
427 427
@@ -429,7 +429,7 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
429 adap->name, adap->nr); 429 adap->name, adap->nr);
430 return 0; 430 return 0;
431error_destroy: 431error_destroy:
432 class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 432 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
433error: 433error:
434 return_i2c_dev(i2c_dev); 434 return_i2c_dev(i2c_dev);
435 kfree(i2c_dev); 435 kfree(i2c_dev);
@@ -444,9 +444,9 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
444 if (!i2c_dev) /* attach_adapter must have failed */ 444 if (!i2c_dev) /* attach_adapter must have failed */
445 return 0; 445 return 0;
446 446
447 class_device_remove_file(i2c_dev->class_dev, &class_device_attr_name); 447 device_remove_file(i2c_dev->dev, &dev_attr_name);
448 return_i2c_dev(i2c_dev); 448 return_i2c_dev(i2c_dev);
449 class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); 449 device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
450 kfree(i2c_dev); 450 kfree(i2c_dev);
451 451
452 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); 452 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 8ccee9c769f8..e3a267622bb6 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1635,7 +1635,7 @@ static int idefloppy_begin_format(ide_drive_t *drive, int __user *arg)
1635/* 1635/*
1636** Get ATAPI_FORMAT_UNIT progress indication. 1636** Get ATAPI_FORMAT_UNIT progress indication.
1637** 1637**
1638** Userland gives a pointer to an int. The int is set to a progresss 1638** Userland gives a pointer to an int. The int is set to a progress
1639** indicator 0-65536, with 65536=100%. 1639** indicator 0-65536, with 65536=100%.
1640** 1640**
1641** If the drive does not support format progress indication, we just check 1641** If the drive does not support format progress indication, we just check
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 244f7eb7006d..cfad09accf52 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -768,14 +768,7 @@ ioc4_ide_init(void)
768 return ioc4_register_submodule(&ioc4_ide_submodule); 768 return ioc4_register_submodule(&ioc4_ide_submodule);
769} 769}
770 770
771static void __devexit
772ioc4_ide_exit(void)
773{
774 ioc4_unregister_submodule(&ioc4_ide_submodule);
775}
776
777late_initcall(ioc4_ide_init); /* Call only after IDE init is done */ 771late_initcall(ioc4_ide_init); /* Call only after IDE init is done */
778module_exit(ioc4_ide_exit);
779 772
780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon"); 773MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
781MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card"); 774MODULE_DESCRIPTION("IDE PCI driver module for SGI IOC4 Base-IO Card");
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 84b2f5cb3722..af939796750d 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -139,7 +139,7 @@ static void queue_req(struct addr_req *req)
139 139
140 mutex_lock(&lock); 140 mutex_lock(&lock);
141 list_for_each_entry_reverse(temp_req, &req_list, list) { 141 list_for_each_entry_reverse(temp_req, &req_list, list) {
142 if (time_after(req->timeout, temp_req->timeout)) 142 if (time_after_eq(req->timeout, temp_req->timeout))
143 break; 143 break;
144 } 144 }
145 145
@@ -225,19 +225,17 @@ static void process_req(struct work_struct *work)
225 225
226 mutex_lock(&lock); 226 mutex_lock(&lock);
227 list_for_each_entry_safe(req, temp_req, &req_list, list) { 227 list_for_each_entry_safe(req, temp_req, &req_list, list) {
228 if (req->status) { 228 if (req->status == -ENODATA) {
229 src_in = (struct sockaddr_in *) &req->src_addr; 229 src_in = (struct sockaddr_in *) &req->src_addr;
230 dst_in = (struct sockaddr_in *) &req->dst_addr; 230 dst_in = (struct sockaddr_in *) &req->dst_addr;
231 req->status = addr_resolve_remote(src_in, dst_in, 231 req->status = addr_resolve_remote(src_in, dst_in,
232 req->addr); 232 req->addr);
233 if (req->status && time_after_eq(jiffies, req->timeout))
234 req->status = -ETIMEDOUT;
235 else if (req->status == -ENODATA)
236 continue;
233 } 237 }
234 if (req->status && time_after(jiffies, req->timeout)) 238 list_move_tail(&req->list, &done_list);
235 req->status = -ETIMEDOUT;
236 else if (req->status == -ENODATA)
237 continue;
238
239 list_del(&req->list);
240 list_add_tail(&req->list, &done_list);
241 } 239 }
242 240
243 if (!list_empty(&req_list)) { 241 if (!list_empty(&req_list)) {
@@ -347,8 +345,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr)
347 if (req->addr == addr) { 345 if (req->addr == addr) {
348 req->status = -ECANCELED; 346 req->status = -ECANCELED;
349 req->timeout = jiffies; 347 req->timeout = jiffies;
350 list_del(&req->list); 348 list_move(&req->list, &req_list);
351 list_add(&req->list, &req_list);
352 set_timeout(req->timeout); 349 set_timeout(req->timeout);
353 break; 350 break;
354 } 351 }
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index e1990f531d0a..79c937bf6962 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -147,12 +147,12 @@ struct cm_id_private {
147 __be32 rq_psn; 147 __be32 rq_psn;
148 int timeout_ms; 148 int timeout_ms;
149 enum ib_mtu path_mtu; 149 enum ib_mtu path_mtu;
150 __be16 pkey;
150 u8 private_data_len; 151 u8 private_data_len;
151 u8 max_cm_retries; 152 u8 max_cm_retries;
152 u8 peer_to_peer; 153 u8 peer_to_peer;
153 u8 responder_resources; 154 u8 responder_resources;
154 u8 initiator_depth; 155 u8 initiator_depth;
155 u8 local_ack_timeout;
156 u8 retry_count; 156 u8 retry_count;
157 u8 rnr_retry_count; 157 u8 rnr_retry_count;
158 u8 service_timeout; 158 u8 service_timeout;
@@ -240,11 +240,10 @@ static void * cm_copy_private_data(const void *private_data,
240 if (!private_data || !private_data_len) 240 if (!private_data || !private_data_len)
241 return NULL; 241 return NULL;
242 242
243 data = kmalloc(private_data_len, GFP_KERNEL); 243 data = kmemdup(private_data, private_data_len, GFP_KERNEL);
244 if (!data) 244 if (!data)
245 return ERR_PTR(-ENOMEM); 245 return ERR_PTR(-ENOMEM);
246 246
247 memcpy(data, private_data, private_data_len);
248 return data; 247 return data;
249} 248}
250 249
@@ -690,7 +689,7 @@ static void cm_enter_timewait(struct cm_id_private *cm_id_priv)
690 * timewait before notifying the user that we've exited timewait. 689 * timewait before notifying the user that we've exited timewait.
691 */ 690 */
692 cm_id_priv->id.state = IB_CM_TIMEWAIT; 691 cm_id_priv->id.state = IB_CM_TIMEWAIT;
693 wait_time = cm_convert_to_ms(cm_id_priv->local_ack_timeout); 692 wait_time = cm_convert_to_ms(cm_id_priv->av.packet_life_time + 1);
694 queue_delayed_work(cm.wq, &cm_id_priv->timewait_info->work.work, 693 queue_delayed_work(cm.wq, &cm_id_priv->timewait_info->work.work,
695 msecs_to_jiffies(wait_time)); 694 msecs_to_jiffies(wait_time));
696 cm_id_priv->timewait_info = NULL; 695 cm_id_priv->timewait_info = NULL;
@@ -1009,6 +1008,7 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
1009 cm_id_priv->responder_resources = param->responder_resources; 1008 cm_id_priv->responder_resources = param->responder_resources;
1010 cm_id_priv->retry_count = param->retry_count; 1009 cm_id_priv->retry_count = param->retry_count;
1011 cm_id_priv->path_mtu = param->primary_path->mtu; 1010 cm_id_priv->path_mtu = param->primary_path->mtu;
1011 cm_id_priv->pkey = param->primary_path->pkey;
1012 cm_id_priv->qp_type = param->qp_type; 1012 cm_id_priv->qp_type = param->qp_type;
1013 1013
1014 ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg); 1014 ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg);
@@ -1023,8 +1023,6 @@ int ib_send_cm_req(struct ib_cm_id *cm_id,
1023 1023
1024 cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg); 1024 cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg);
1025 cm_id_priv->rq_psn = cm_req_get_starting_psn(req_msg); 1025 cm_id_priv->rq_psn = cm_req_get_starting_psn(req_msg);
1026 cm_id_priv->local_ack_timeout =
1027 cm_req_get_primary_local_ack_timeout(req_msg);
1028 1026
1029 spin_lock_irqsave(&cm_id_priv->lock, flags); 1027 spin_lock_irqsave(&cm_id_priv->lock, flags);
1030 ret = ib_post_send_mad(cm_id_priv->msg, NULL); 1028 ret = ib_post_send_mad(cm_id_priv->msg, NULL);
@@ -1409,9 +1407,8 @@ static int cm_req_handler(struct cm_work *work)
1409 cm_id_priv->initiator_depth = cm_req_get_resp_res(req_msg); 1407 cm_id_priv->initiator_depth = cm_req_get_resp_res(req_msg);
1410 cm_id_priv->responder_resources = cm_req_get_init_depth(req_msg); 1408 cm_id_priv->responder_resources = cm_req_get_init_depth(req_msg);
1411 cm_id_priv->path_mtu = cm_req_get_path_mtu(req_msg); 1409 cm_id_priv->path_mtu = cm_req_get_path_mtu(req_msg);
1410 cm_id_priv->pkey = req_msg->pkey;
1412 cm_id_priv->sq_psn = cm_req_get_starting_psn(req_msg); 1411 cm_id_priv->sq_psn = cm_req_get_starting_psn(req_msg);
1413 cm_id_priv->local_ack_timeout =
1414 cm_req_get_primary_local_ack_timeout(req_msg);
1415 cm_id_priv->retry_count = cm_req_get_retry_count(req_msg); 1412 cm_id_priv->retry_count = cm_req_get_retry_count(req_msg);
1416 cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg); 1413 cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg);
1417 cm_id_priv->qp_type = cm_req_get_qp_type(req_msg); 1414 cm_id_priv->qp_type = cm_req_get_qp_type(req_msg);
@@ -1715,7 +1712,7 @@ static int cm_establish_handler(struct cm_work *work)
1715 unsigned long flags; 1712 unsigned long flags;
1716 int ret; 1713 int ret;
1717 1714
1718 /* See comment in ib_cm_establish about lookup. */ 1715 /* See comment in cm_establish about lookup. */
1719 cm_id_priv = cm_acquire_id(work->local_id, work->remote_id); 1716 cm_id_priv = cm_acquire_id(work->local_id, work->remote_id);
1720 if (!cm_id_priv) 1717 if (!cm_id_priv)
1721 return -EINVAL; 1718 return -EINVAL;
@@ -2401,11 +2398,16 @@ int ib_send_cm_lap(struct ib_cm_id *cm_id,
2401 cm_id_priv = container_of(cm_id, struct cm_id_private, id); 2398 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
2402 spin_lock_irqsave(&cm_id_priv->lock, flags); 2399 spin_lock_irqsave(&cm_id_priv->lock, flags);
2403 if (cm_id->state != IB_CM_ESTABLISHED || 2400 if (cm_id->state != IB_CM_ESTABLISHED ||
2404 cm_id->lap_state != IB_CM_LAP_IDLE) { 2401 (cm_id->lap_state != IB_CM_LAP_UNINIT &&
2402 cm_id->lap_state != IB_CM_LAP_IDLE)) {
2405 ret = -EINVAL; 2403 ret = -EINVAL;
2406 goto out; 2404 goto out;
2407 } 2405 }
2408 2406
2407 ret = cm_init_av_by_path(alternate_path, &cm_id_priv->alt_av);
2408 if (ret)
2409 goto out;
2410
2409 ret = cm_alloc_msg(cm_id_priv, &msg); 2411 ret = cm_alloc_msg(cm_id_priv, &msg);
2410 if (ret) 2412 if (ret)
2411 goto out; 2413 goto out;
@@ -2430,7 +2432,8 @@ out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
2430} 2432}
2431EXPORT_SYMBOL(ib_send_cm_lap); 2433EXPORT_SYMBOL(ib_send_cm_lap);
2432 2434
2433static void cm_format_path_from_lap(struct ib_sa_path_rec *path, 2435static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv,
2436 struct ib_sa_path_rec *path,
2434 struct cm_lap_msg *lap_msg) 2437 struct cm_lap_msg *lap_msg)
2435{ 2438{
2436 memset(path, 0, sizeof *path); 2439 memset(path, 0, sizeof *path);
@@ -2442,10 +2445,10 @@ static void cm_format_path_from_lap(struct ib_sa_path_rec *path,
2442 path->hop_limit = lap_msg->alt_hop_limit; 2445 path->hop_limit = lap_msg->alt_hop_limit;
2443 path->traffic_class = cm_lap_get_traffic_class(lap_msg); 2446 path->traffic_class = cm_lap_get_traffic_class(lap_msg);
2444 path->reversible = 1; 2447 path->reversible = 1;
2445 /* pkey is same as in REQ */ 2448 path->pkey = cm_id_priv->pkey;
2446 path->sl = cm_lap_get_sl(lap_msg); 2449 path->sl = cm_lap_get_sl(lap_msg);
2447 path->mtu_selector = IB_SA_EQ; 2450 path->mtu_selector = IB_SA_EQ;
2448 /* mtu is same as in REQ */ 2451 path->mtu = cm_id_priv->path_mtu;
2449 path->rate_selector = IB_SA_EQ; 2452 path->rate_selector = IB_SA_EQ;
2450 path->rate = cm_lap_get_packet_rate(lap_msg); 2453 path->rate = cm_lap_get_packet_rate(lap_msg);
2451 path->packet_life_time_selector = IB_SA_EQ; 2454 path->packet_life_time_selector = IB_SA_EQ;
@@ -2471,7 +2474,7 @@ static int cm_lap_handler(struct cm_work *work)
2471 2474
2472 param = &work->cm_event.param.lap_rcvd; 2475 param = &work->cm_event.param.lap_rcvd;
2473 param->alternate_path = &work->path[0]; 2476 param->alternate_path = &work->path[0];
2474 cm_format_path_from_lap(param->alternate_path, lap_msg); 2477 cm_format_path_from_lap(cm_id_priv, param->alternate_path, lap_msg);
2475 work->cm_event.private_data = &lap_msg->private_data; 2478 work->cm_event.private_data = &lap_msg->private_data;
2476 2479
2477 spin_lock_irqsave(&cm_id_priv->lock, flags); 2480 spin_lock_irqsave(&cm_id_priv->lock, flags);
@@ -2479,6 +2482,7 @@ static int cm_lap_handler(struct cm_work *work)
2479 goto unlock; 2482 goto unlock;
2480 2483
2481 switch (cm_id_priv->id.lap_state) { 2484 switch (cm_id_priv->id.lap_state) {
2485 case IB_CM_LAP_UNINIT:
2482 case IB_CM_LAP_IDLE: 2486 case IB_CM_LAP_IDLE:
2483 break; 2487 break;
2484 case IB_CM_MRA_LAP_SENT: 2488 case IB_CM_MRA_LAP_SENT:
@@ -2501,6 +2505,10 @@ static int cm_lap_handler(struct cm_work *work)
2501 2505
2502 cm_id_priv->id.lap_state = IB_CM_LAP_RCVD; 2506 cm_id_priv->id.lap_state = IB_CM_LAP_RCVD;
2503 cm_id_priv->tid = lap_msg->hdr.tid; 2507 cm_id_priv->tid = lap_msg->hdr.tid;
2508 cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
2509 work->mad_recv_wc->recv_buf.grh,
2510 &cm_id_priv->av);
2511 cm_init_av_by_path(param->alternate_path, &cm_id_priv->alt_av);
2504 ret = atomic_inc_and_test(&cm_id_priv->work_count); 2512 ret = atomic_inc_and_test(&cm_id_priv->work_count);
2505 if (!ret) 2513 if (!ret)
2506 list_add_tail(&work->list, &cm_id_priv->work_list); 2514 list_add_tail(&work->list, &cm_id_priv->work_list);
@@ -3039,7 +3047,7 @@ static void cm_work_handler(struct work_struct *_work)
3039 cm_free_work(work); 3047 cm_free_work(work);
3040} 3048}
3041 3049
3042int ib_cm_establish(struct ib_cm_id *cm_id) 3050static int cm_establish(struct ib_cm_id *cm_id)
3043{ 3051{
3044 struct cm_id_private *cm_id_priv; 3052 struct cm_id_private *cm_id_priv;
3045 struct cm_work *work; 3053 struct cm_work *work;
@@ -3087,7 +3095,44 @@ int ib_cm_establish(struct ib_cm_id *cm_id)
3087out: 3095out:
3088 return ret; 3096 return ret;
3089} 3097}
3090EXPORT_SYMBOL(ib_cm_establish); 3098
3099static int cm_migrate(struct ib_cm_id *cm_id)
3100{
3101 struct cm_id_private *cm_id_priv;
3102 unsigned long flags;
3103 int ret = 0;
3104
3105 cm_id_priv = container_of(cm_id, struct cm_id_private, id);
3106 spin_lock_irqsave(&cm_id_priv->lock, flags);
3107 if (cm_id->state == IB_CM_ESTABLISHED &&
3108 (cm_id->lap_state == IB_CM_LAP_UNINIT ||
3109 cm_id->lap_state == IB_CM_LAP_IDLE)) {
3110 cm_id->lap_state = IB_CM_LAP_IDLE;
3111 cm_id_priv->av = cm_id_priv->alt_av;
3112 } else
3113 ret = -EINVAL;
3114 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
3115
3116 return ret;
3117}
3118
3119int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event)
3120{
3121 int ret;
3122
3123 switch (event) {
3124 case IB_EVENT_COMM_EST:
3125 ret = cm_establish(cm_id);
3126 break;
3127 case IB_EVENT_PATH_MIG:
3128 ret = cm_migrate(cm_id);
3129 break;
3130 default:
3131 ret = -EINVAL;
3132 }
3133 return ret;
3134}
3135EXPORT_SYMBOL(ib_cm_notify);
3091 3136
3092static void cm_recv_handler(struct ib_mad_agent *mad_agent, 3137static void cm_recv_handler(struct ib_mad_agent *mad_agent,
3093 struct ib_mad_recv_wc *mad_recv_wc) 3138 struct ib_mad_recv_wc *mad_recv_wc)
@@ -3172,8 +3217,7 @@ static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv,
3172 case IB_CM_ESTABLISHED: 3217 case IB_CM_ESTABLISHED:
3173 *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS | 3218 *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS |
3174 IB_QP_PKEY_INDEX | IB_QP_PORT; 3219 IB_QP_PKEY_INDEX | IB_QP_PORT;
3175 qp_attr->qp_access_flags = IB_ACCESS_LOCAL_WRITE | 3220 qp_attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE;
3176 IB_ACCESS_REMOTE_WRITE;
3177 if (cm_id_priv->responder_resources) 3221 if (cm_id_priv->responder_resources)
3178 qp_attr->qp_access_flags |= IB_ACCESS_REMOTE_READ | 3222 qp_attr->qp_access_flags |= IB_ACCESS_REMOTE_READ |
3179 IB_ACCESS_REMOTE_ATOMIC; 3223 IB_ACCESS_REMOTE_ATOMIC;
@@ -3221,6 +3265,9 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
3221 if (cm_id_priv->alt_av.ah_attr.dlid) { 3265 if (cm_id_priv->alt_av.ah_attr.dlid) {
3222 *qp_attr_mask |= IB_QP_ALT_PATH; 3266 *qp_attr_mask |= IB_QP_ALT_PATH;
3223 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num; 3267 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
3268 qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
3269 qp_attr->alt_timeout =
3270 cm_id_priv->alt_av.packet_life_time + 1;
3224 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr; 3271 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
3225 } 3272 }
3226 ret = 0; 3273 ret = 0;
@@ -3247,19 +3294,31 @@ static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv,
3247 case IB_CM_REP_SENT: 3294 case IB_CM_REP_SENT:
3248 case IB_CM_MRA_REP_RCVD: 3295 case IB_CM_MRA_REP_RCVD:
3249 case IB_CM_ESTABLISHED: 3296 case IB_CM_ESTABLISHED:
3250 *qp_attr_mask = IB_QP_STATE | IB_QP_SQ_PSN; 3297 if (cm_id_priv->id.lap_state == IB_CM_LAP_UNINIT) {
3251 qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn); 3298 *qp_attr_mask = IB_QP_STATE | IB_QP_SQ_PSN;
3252 if (cm_id_priv->qp_type == IB_QPT_RC) { 3299 qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn);
3253 *qp_attr_mask |= IB_QP_TIMEOUT | IB_QP_RETRY_CNT | 3300 if (cm_id_priv->qp_type == IB_QPT_RC) {
3254 IB_QP_RNR_RETRY | 3301 *qp_attr_mask |= IB_QP_TIMEOUT | IB_QP_RETRY_CNT |
3255 IB_QP_MAX_QP_RD_ATOMIC; 3302 IB_QP_RNR_RETRY |
3256 qp_attr->timeout = cm_id_priv->local_ack_timeout; 3303 IB_QP_MAX_QP_RD_ATOMIC;
3257 qp_attr->retry_cnt = cm_id_priv->retry_count; 3304 qp_attr->timeout =
3258 qp_attr->rnr_retry = cm_id_priv->rnr_retry_count; 3305 cm_id_priv->av.packet_life_time + 1;
3259 qp_attr->max_rd_atomic = cm_id_priv->initiator_depth; 3306 qp_attr->retry_cnt = cm_id_priv->retry_count;
3260 } 3307 qp_attr->rnr_retry = cm_id_priv->rnr_retry_count;
3261 if (cm_id_priv->alt_av.ah_attr.dlid) { 3308 qp_attr->max_rd_atomic =
3262 *qp_attr_mask |= IB_QP_PATH_MIG_STATE; 3309 cm_id_priv->initiator_depth;
3310 }
3311 if (cm_id_priv->alt_av.ah_attr.dlid) {
3312 *qp_attr_mask |= IB_QP_PATH_MIG_STATE;
3313 qp_attr->path_mig_state = IB_MIG_REARM;
3314 }
3315 } else {
3316 *qp_attr_mask = IB_QP_ALT_PATH | IB_QP_PATH_MIG_STATE;
3317 qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
3318 qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
3319 qp_attr->alt_timeout =
3320 cm_id_priv->alt_av.packet_life_time + 1;
3321 qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
3263 qp_attr->path_mig_state = IB_MIG_REARM; 3322 qp_attr->path_mig_state = IB_MIG_REARM;
3264 } 3323 }
3265 ret = 0; 3324 ret = 0;
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 189f73f3f721..985a6b564d8f 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -344,7 +344,7 @@ static int cma_init_ib_qp(struct rdma_id_private *id_priv, struct ib_qp *qp)
344 return ret; 344 return ret;
345 345
346 qp_attr.qp_state = IB_QPS_INIT; 346 qp_attr.qp_state = IB_QPS_INIT;
347 qp_attr.qp_access_flags = IB_ACCESS_LOCAL_WRITE; 347 qp_attr.qp_access_flags = 0;
348 qp_attr.port_num = id_priv->id.port_num; 348 qp_attr.port_num = id_priv->id.port_num;
349 return ib_modify_qp(qp, &qp_attr, IB_QP_STATE | IB_QP_ACCESS_FLAGS | 349 return ib_modify_qp(qp, &qp_attr, IB_QP_STATE | IB_QP_ACCESS_FLAGS |
350 IB_QP_PKEY_INDEX | IB_QP_PORT); 350 IB_QP_PKEY_INDEX | IB_QP_PORT);
@@ -935,13 +935,8 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
935 mutex_lock(&lock); 935 mutex_lock(&lock);
936 ret = cma_acquire_dev(conn_id); 936 ret = cma_acquire_dev(conn_id);
937 mutex_unlock(&lock); 937 mutex_unlock(&lock);
938 if (ret) { 938 if (ret)
939 ret = -ENODEV; 939 goto release_conn_id;
940 cma_exch(conn_id, CMA_DESTROYING);
941 cma_release_remove(conn_id);
942 rdma_destroy_id(&conn_id->id);
943 goto out;
944 }
945 940
946 conn_id->cm_id.ib = cm_id; 941 conn_id->cm_id.ib = cm_id;
947 cm_id->context = conn_id; 942 cm_id->context = conn_id;
@@ -951,13 +946,17 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
951 ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0, 946 ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0,
952 ib_event->private_data + offset, 947 ib_event->private_data + offset,
953 IB_CM_REQ_PRIVATE_DATA_SIZE - offset); 948 IB_CM_REQ_PRIVATE_DATA_SIZE - offset);
954 if (ret) { 949 if (!ret)
955 /* Destroy the CM ID by returning a non-zero value. */ 950 goto out;
956 conn_id->cm_id.ib = NULL; 951
957 cma_exch(conn_id, CMA_DESTROYING); 952 /* Destroy the CM ID by returning a non-zero value. */
958 cma_release_remove(conn_id); 953 conn_id->cm_id.ib = NULL;
959 rdma_destroy_id(&conn_id->id); 954
960 } 955release_conn_id:
956 cma_exch(conn_id, CMA_DESTROYING);
957 cma_release_remove(conn_id);
958 rdma_destroy_id(&conn_id->id);
959
961out: 960out:
962 cma_release_remove(listen_id); 961 cma_release_remove(listen_id);
963 return ret; 962 return ret;
@@ -1481,19 +1480,18 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
1481 u8 p; 1480 u8 p;
1482 1481
1483 mutex_lock(&lock); 1482 mutex_lock(&lock);
1483 if (list_empty(&dev_list)) {
1484 ret = -ENODEV;
1485 goto out;
1486 }
1484 list_for_each_entry(cma_dev, &dev_list, list) 1487 list_for_each_entry(cma_dev, &dev_list, list)
1485 for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p) 1488 for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
1486 if (!ib_query_port (cma_dev->device, p, &port_attr) && 1489 if (!ib_query_port(cma_dev->device, p, &port_attr) &&
1487 port_attr.state == IB_PORT_ACTIVE) 1490 port_attr.state == IB_PORT_ACTIVE)
1488 goto port_found; 1491 goto port_found;
1489 1492
1490 if (!list_empty(&dev_list)) { 1493 p = 1;
1491 p = 1; 1494 cma_dev = list_entry(dev_list.next, struct cma_device, list);
1492 cma_dev = list_entry(dev_list.next, struct cma_device, list);
1493 } else {
1494 ret = -ENODEV;
1495 goto out;
1496 }
1497 1495
1498port_found: 1496port_found:
1499 ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid); 1497 ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);
@@ -2123,8 +2121,6 @@ static void cma_add_one(struct ib_device *device)
2123 2121
2124 cma_dev->device = device; 2122 cma_dev->device = device;
2125 cma_dev->node_guid = device->node_guid; 2123 cma_dev->node_guid = device->node_guid;
2126 if (!cma_dev->node_guid)
2127 goto err;
2128 2124
2129 init_completion(&cma_dev->comp); 2125 init_completion(&cma_dev->comp);
2130 atomic_set(&cma_dev->refcount, 1); 2126 atomic_set(&cma_dev->refcount, 1);
@@ -2136,9 +2132,6 @@ static void cma_add_one(struct ib_device *device)
2136 list_for_each_entry(id_priv, &listen_any_list, list) 2132 list_for_each_entry(id_priv, &listen_any_list, list)
2137 cma_listen_on_dev(id_priv, cma_dev); 2133 cma_listen_on_dev(id_priv, cma_dev);
2138 mutex_unlock(&lock); 2134 mutex_unlock(&lock);
2139 return;
2140err:
2141 kfree(cma_dev);
2142} 2135}
2143 2136
2144static int cma_remove_id_dev(struct rdma_id_private *id_priv) 2137static int cma_remove_id_dev(struct rdma_id_private *id_priv)
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index 9bfa785252dc..1039ad57d53b 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -80,7 +80,7 @@ struct iwcm_work {
80 * 1) in the event upcall, cm_event_handler(), for a listening cm_id. If 80 * 1) in the event upcall, cm_event_handler(), for a listening cm_id. If
81 * the backlog is exceeded, then no more connection request events will 81 * the backlog is exceeded, then no more connection request events will
82 * be processed. cm_event_handler() returns -ENOMEM in this case. Its up 82 * be processed. cm_event_handler() returns -ENOMEM in this case. Its up
83 * to the provider to reject the connectino request. 83 * to the provider to reject the connection request.
84 * 2) in the connection request workqueue handler, cm_conn_req_handler(). 84 * 2) in the connection request workqueue handler, cm_conn_req_handler().
85 * If work elements cannot be allocated for the new connect request cm_id, 85 * If work elements cannot be allocated for the new connect request cm_id,
86 * then IWCM will call the provider reject method. This is ok since 86 * then IWCM will call the provider reject method. This is ok since
@@ -131,26 +131,25 @@ static int alloc_work_entries(struct iwcm_id_private *cm_id_priv, int count)
131} 131}
132 132
133/* 133/*
134 * Save private data from incoming connection requests in the 134 * Save private data from incoming connection requests to
135 * cm_id_priv so the low level driver doesn't have to. Adjust 135 * iw_cm_event, so the low level driver doesn't have to. Adjust
136 * the event ptr to point to the local copy. 136 * the event ptr to point to the local copy.
137 */ 137 */
138static int copy_private_data(struct iwcm_id_private *cm_id_priv, 138static int copy_private_data(struct iw_cm_event *event)
139 struct iw_cm_event *event)
140{ 139{
141 void *p; 140 void *p;
142 141
143 p = kmalloc(event->private_data_len, GFP_ATOMIC); 142 p = kmemdup(event->private_data, event->private_data_len, GFP_ATOMIC);
144 if (!p) 143 if (!p)
145 return -ENOMEM; 144 return -ENOMEM;
146 memcpy(p, event->private_data, event->private_data_len);
147 event->private_data = p; 145 event->private_data = p;
148 return 0; 146 return 0;
149} 147}
150 148
151/* 149/*
152 * Release a reference on cm_id. If the last reference is being removed 150 * Release a reference on cm_id. If the last reference is being
153 * and iw_destroy_cm_id is waiting, wake up the waiting thread. 151 * released, enable the waiting thread (in iw_destroy_cm_id) to
152 * get woken up, and return 1 if a thread is already waiting.
154 */ 153 */
155static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv) 154static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv)
156{ 155{
@@ -243,7 +242,7 @@ static int iwcm_modify_qp_sqd(struct ib_qp *qp)
243/* 242/*
244 * CM_ID <-- CLOSING 243 * CM_ID <-- CLOSING
245 * 244 *
246 * Block if a passive or active connection is currenlty being processed. Then 245 * Block if a passive or active connection is currently being processed. Then
247 * process the event as follows: 246 * process the event as follows:
248 * - If we are ESTABLISHED, move to CLOSING and modify the QP state 247 * - If we are ESTABLISHED, move to CLOSING and modify the QP state
249 * based on the abrupt flag 248 * based on the abrupt flag
@@ -408,7 +407,7 @@ int iw_cm_listen(struct iw_cm_id *cm_id, int backlog)
408{ 407{
409 struct iwcm_id_private *cm_id_priv; 408 struct iwcm_id_private *cm_id_priv;
410 unsigned long flags; 409 unsigned long flags;
411 int ret = 0; 410 int ret;
412 411
413 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id); 412 cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
414 413
@@ -535,7 +534,7 @@ EXPORT_SYMBOL(iw_cm_accept);
535int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param) 534int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
536{ 535{
537 struct iwcm_id_private *cm_id_priv; 536 struct iwcm_id_private *cm_id_priv;
538 int ret = 0; 537 int ret;
539 unsigned long flags; 538 unsigned long flags;
540 struct ib_qp *qp; 539 struct ib_qp *qp;
541 540
@@ -620,7 +619,7 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
620 spin_lock_irqsave(&listen_id_priv->lock, flags); 619 spin_lock_irqsave(&listen_id_priv->lock, flags);
621 if (listen_id_priv->state != IW_CM_STATE_LISTEN) { 620 if (listen_id_priv->state != IW_CM_STATE_LISTEN) {
622 spin_unlock_irqrestore(&listen_id_priv->lock, flags); 621 spin_unlock_irqrestore(&listen_id_priv->lock, flags);
623 return; 622 goto out;
624 } 623 }
625 spin_unlock_irqrestore(&listen_id_priv->lock, flags); 624 spin_unlock_irqrestore(&listen_id_priv->lock, flags);
626 625
@@ -629,7 +628,7 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
629 listen_id_priv->id.context); 628 listen_id_priv->id.context);
630 /* If the cm_id could not be created, ignore the request */ 629 /* If the cm_id could not be created, ignore the request */
631 if (IS_ERR(cm_id)) 630 if (IS_ERR(cm_id))
632 return; 631 goto out;
633 632
634 cm_id->provider_data = iw_event->provider_data; 633 cm_id->provider_data = iw_event->provider_data;
635 cm_id->local_addr = iw_event->local_addr; 634 cm_id->local_addr = iw_event->local_addr;
@@ -642,7 +641,7 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
642 if (ret) { 641 if (ret) {
643 iw_cm_reject(cm_id, NULL, 0); 642 iw_cm_reject(cm_id, NULL, 0);
644 iw_destroy_cm_id(cm_id); 643 iw_destroy_cm_id(cm_id);
645 return; 644 goto out;
646 } 645 }
647 646
648 /* Call the client CM handler */ 647 /* Call the client CM handler */
@@ -654,6 +653,7 @@ static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
654 kfree(cm_id); 653 kfree(cm_id);
655 } 654 }
656 655
656out:
657 if (iw_event->private_data_len) 657 if (iw_event->private_data_len)
658 kfree(iw_event->private_data); 658 kfree(iw_event->private_data);
659} 659}
@@ -674,7 +674,7 @@ static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv,
674 struct iw_cm_event *iw_event) 674 struct iw_cm_event *iw_event)
675{ 675{
676 unsigned long flags; 676 unsigned long flags;
677 int ret = 0; 677 int ret;
678 678
679 spin_lock_irqsave(&cm_id_priv->lock, flags); 679 spin_lock_irqsave(&cm_id_priv->lock, flags);
680 680
@@ -704,7 +704,7 @@ static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv,
704 struct iw_cm_event *iw_event) 704 struct iw_cm_event *iw_event)
705{ 705{
706 unsigned long flags; 706 unsigned long flags;
707 int ret = 0; 707 int ret;
708 708
709 spin_lock_irqsave(&cm_id_priv->lock, flags); 709 spin_lock_irqsave(&cm_id_priv->lock, flags);
710 /* 710 /*
@@ -830,8 +830,8 @@ static int process_event(struct iwcm_id_private *cm_id_priv,
830 */ 830 */
831static void cm_work_handler(struct work_struct *_work) 831static void cm_work_handler(struct work_struct *_work)
832{ 832{
833 struct iwcm_work lwork, *work = 833 struct iwcm_work *work = container_of(_work, struct iwcm_work, work);
834 container_of(_work, struct iwcm_work, work); 834 struct iw_cm_event levent;
835 struct iwcm_id_private *cm_id_priv = work->cm_id; 835 struct iwcm_id_private *cm_id_priv = work->cm_id;
836 unsigned long flags; 836 unsigned long flags;
837 int empty; 837 int empty;
@@ -844,11 +844,11 @@ static void cm_work_handler(struct work_struct *_work)
844 struct iwcm_work, list); 844 struct iwcm_work, list);
845 list_del_init(&work->list); 845 list_del_init(&work->list);
846 empty = list_empty(&cm_id_priv->work_list); 846 empty = list_empty(&cm_id_priv->work_list);
847 lwork = *work; 847 levent = work->event;
848 put_work(work); 848 put_work(work);
849 spin_unlock_irqrestore(&cm_id_priv->lock, flags); 849 spin_unlock_irqrestore(&cm_id_priv->lock, flags);
850 850
851 ret = process_event(cm_id_priv, &work->event); 851 ret = process_event(cm_id_priv, &levent);
852 if (ret) { 852 if (ret) {
853 set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags); 853 set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
854 destroy_cm_id(&cm_id_priv->id); 854 destroy_cm_id(&cm_id_priv->id);
@@ -907,7 +907,7 @@ static int cm_event_handler(struct iw_cm_id *cm_id,
907 if ((work->event.event == IW_CM_EVENT_CONNECT_REQUEST || 907 if ((work->event.event == IW_CM_EVENT_CONNECT_REQUEST ||
908 work->event.event == IW_CM_EVENT_CONNECT_REPLY) && 908 work->event.event == IW_CM_EVENT_CONNECT_REPLY) &&
909 work->event.private_data_len) { 909 work->event.private_data_len) {
910 ret = copy_private_data(cm_id_priv, &work->event); 910 ret = copy_private_data(&work->event);
911 if (ret) { 911 if (ret) {
912 put_work(work); 912 put_work(work);
913 goto out; 913 goto out;
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 5a54ac35e961..15f38d94b3a8 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -46,7 +46,7 @@ MODULE_DESCRIPTION("kernel IB MAD API");
46MODULE_AUTHOR("Hal Rosenstock"); 46MODULE_AUTHOR("Hal Rosenstock");
47MODULE_AUTHOR("Sean Hefty"); 47MODULE_AUTHOR("Sean Hefty");
48 48
49static kmem_cache_t *ib_mad_cache; 49static struct kmem_cache *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;
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index ad4f4d5c2924..f15220a0ee75 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -161,12 +161,14 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
161 struct ib_ucm_event, ctx_list); 161 struct ib_ucm_event, ctx_list);
162 list_del(&uevent->file_list); 162 list_del(&uevent->file_list);
163 list_del(&uevent->ctx_list); 163 list_del(&uevent->ctx_list);
164 mutex_unlock(&ctx->file->file_mutex);
164 165
165 /* clear incoming connections. */ 166 /* clear incoming connections. */
166 if (ib_ucm_new_cm_id(uevent->resp.event)) 167 if (ib_ucm_new_cm_id(uevent->resp.event))
167 ib_destroy_cm_id(uevent->cm_id); 168 ib_destroy_cm_id(uevent->cm_id);
168 169
169 kfree(uevent); 170 kfree(uevent);
171 mutex_lock(&ctx->file->file_mutex);
170 } 172 }
171 mutex_unlock(&ctx->file->file_mutex); 173 mutex_unlock(&ctx->file->file_mutex);
172} 174}
@@ -328,20 +330,18 @@ static int ib_ucm_event_process(struct ib_cm_event *evt,
328 } 330 }
329 331
330 if (uvt->data_len) { 332 if (uvt->data_len) {
331 uvt->data = kmalloc(uvt->data_len, GFP_KERNEL); 333 uvt->data = kmemdup(evt->private_data, uvt->data_len, GFP_KERNEL);
332 if (!uvt->data) 334 if (!uvt->data)
333 goto err1; 335 goto err1;
334 336
335 memcpy(uvt->data, evt->private_data, uvt->data_len);
336 uvt->resp.present |= IB_UCM_PRES_DATA; 337 uvt->resp.present |= IB_UCM_PRES_DATA;
337 } 338 }
338 339
339 if (uvt->info_len) { 340 if (uvt->info_len) {
340 uvt->info = kmalloc(uvt->info_len, GFP_KERNEL); 341 uvt->info = kmemdup(info, uvt->info_len, GFP_KERNEL);
341 if (!uvt->info) 342 if (!uvt->info)
342 goto err2; 343 goto err2;
343 344
344 memcpy(uvt->info, info, uvt->info_len);
345 uvt->resp.present |= IB_UCM_PRES_INFO; 345 uvt->resp.present |= IB_UCM_PRES_INFO;
346 } 346 }
347 return 0; 347 return 0;
@@ -685,11 +685,11 @@ out:
685 return result; 685 return result;
686} 686}
687 687
688static ssize_t ib_ucm_establish(struct ib_ucm_file *file, 688static ssize_t ib_ucm_notify(struct ib_ucm_file *file,
689 const char __user *inbuf, 689 const char __user *inbuf,
690 int in_len, int out_len) 690 int in_len, int out_len)
691{ 691{
692 struct ib_ucm_establish cmd; 692 struct ib_ucm_notify cmd;
693 struct ib_ucm_context *ctx; 693 struct ib_ucm_context *ctx;
694 int result; 694 int result;
695 695
@@ -700,7 +700,7 @@ static ssize_t ib_ucm_establish(struct ib_ucm_file *file,
700 if (IS_ERR(ctx)) 700 if (IS_ERR(ctx))
701 return PTR_ERR(ctx); 701 return PTR_ERR(ctx);
702 702
703 result = ib_cm_establish(ctx->cm_id); 703 result = ib_cm_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
704 ib_ucm_ctx_put(ctx); 704 ib_ucm_ctx_put(ctx);
705 return result; 705 return result;
706} 706}
@@ -1107,7 +1107,7 @@ static ssize_t (*ucm_cmd_table[])(struct ib_ucm_file *file,
1107 [IB_USER_CM_CMD_DESTROY_ID] = ib_ucm_destroy_id, 1107 [IB_USER_CM_CMD_DESTROY_ID] = ib_ucm_destroy_id,
1108 [IB_USER_CM_CMD_ATTR_ID] = ib_ucm_attr_id, 1108 [IB_USER_CM_CMD_ATTR_ID] = ib_ucm_attr_id,
1109 [IB_USER_CM_CMD_LISTEN] = ib_ucm_listen, 1109 [IB_USER_CM_CMD_LISTEN] = ib_ucm_listen,
1110 [IB_USER_CM_CMD_ESTABLISH] = ib_ucm_establish, 1110 [IB_USER_CM_CMD_NOTIFY] = ib_ucm_notify,
1111 [IB_USER_CM_CMD_SEND_REQ] = ib_ucm_send_req, 1111 [IB_USER_CM_CMD_SEND_REQ] = ib_ucm_send_req,
1112 [IB_USER_CM_CMD_SEND_REP] = ib_ucm_send_rep, 1112 [IB_USER_CM_CMD_SEND_REP] = ib_ucm_send_rep,
1113 [IB_USER_CM_CMD_SEND_RTU] = ib_ucm_send_rtu, 1113 [IB_USER_CM_CMD_SEND_RTU] = ib_ucm_send_rtu,
diff --git a/drivers/infiniband/hw/amso1100/c2.h b/drivers/infiniband/hw/amso1100/c2.h
index 1b17dcdd0505..04a9db5de881 100644
--- a/drivers/infiniband/hw/amso1100/c2.h
+++ b/drivers/infiniband/hw/amso1100/c2.h
@@ -302,7 +302,7 @@ struct c2_dev {
302 unsigned long pa; /* PA device memory */ 302 unsigned long pa; /* PA device memory */
303 void **qptr_array; 303 void **qptr_array;
304 304
305 kmem_cache_t *host_msg_cache; 305 struct kmem_cache *host_msg_cache;
306 306
307 struct list_head cca_link; /* adapter list */ 307 struct list_head cca_link; /* adapter list */
308 struct list_head eh_wakeup_list; /* event wakeup list */ 308 struct list_head eh_wakeup_list; /* event wakeup list */
diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c
index 5bcf697aa335..179d005ed4a5 100644
--- a/drivers/infiniband/hw/amso1100/c2_qp.c
+++ b/drivers/infiniband/hw/amso1100/c2_qp.c
@@ -564,6 +564,32 @@ int c2_alloc_qp(struct c2_dev *c2dev,
564 return err; 564 return err;
565} 565}
566 566
567static inline void c2_lock_cqs(struct c2_cq *send_cq, struct c2_cq *recv_cq)
568{
569 if (send_cq == recv_cq)
570 spin_lock_irq(&send_cq->lock);
571 else if (send_cq > recv_cq) {
572 spin_lock_irq(&send_cq->lock);
573 spin_lock_nested(&recv_cq->lock, SINGLE_DEPTH_NESTING);
574 } else {
575 spin_lock_irq(&recv_cq->lock);
576 spin_lock_nested(&send_cq->lock, SINGLE_DEPTH_NESTING);
577 }
578}
579
580static inline void c2_unlock_cqs(struct c2_cq *send_cq, struct c2_cq *recv_cq)
581{
582 if (send_cq == recv_cq)
583 spin_unlock_irq(&send_cq->lock);
584 else if (send_cq > recv_cq) {
585 spin_unlock(&recv_cq->lock);
586 spin_unlock_irq(&send_cq->lock);
587 } else {
588 spin_unlock(&send_cq->lock);
589 spin_unlock_irq(&recv_cq->lock);
590 }
591}
592
567void c2_free_qp(struct c2_dev *c2dev, struct c2_qp *qp) 593void c2_free_qp(struct c2_dev *c2dev, struct c2_qp *qp)
568{ 594{
569 struct c2_cq *send_cq; 595 struct c2_cq *send_cq;
@@ -576,15 +602,9 @@ void c2_free_qp(struct c2_dev *c2dev, struct c2_qp *qp)
576 * Lock CQs here, so that CQ polling code can do QP lookup 602 * Lock CQs here, so that CQ polling code can do QP lookup
577 * without taking a lock. 603 * without taking a lock.
578 */ 604 */
579 spin_lock_irq(&send_cq->lock); 605 c2_lock_cqs(send_cq, recv_cq);
580 if (send_cq != recv_cq)
581 spin_lock(&recv_cq->lock);
582
583 c2_free_qpn(c2dev, qp->qpn); 606 c2_free_qpn(c2dev, qp->qpn);
584 607 c2_unlock_cqs(send_cq, recv_cq);
585 if (send_cq != recv_cq)
586 spin_unlock(&recv_cq->lock);
587 spin_unlock_irq(&send_cq->lock);
588 608
589 /* 609 /*
590 * Destory qp in the rnic... 610 * Destory qp in the rnic...
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index 623dc95f91df..1687c511cb2f 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -441,7 +441,7 @@ static int c2_rnic_close(struct c2_dev *c2dev)
441 * involves initalizing the various limits and resouce pools that 441 * involves initalizing the various limits and resouce pools that
442 * comprise the RNIC instance. 442 * comprise the RNIC instance.
443 */ 443 */
444int c2_rnic_init(struct c2_dev *c2dev) 444int __devinit c2_rnic_init(struct c2_dev *c2dev)
445{ 445{
446 int err; 446 int err;
447 u32 qsize, msgsize; 447 u32 qsize, msgsize;
@@ -611,7 +611,7 @@ int c2_rnic_init(struct c2_dev *c2dev)
611/* 611/*
612 * Called by c2_remove to cleanup the RNIC resources. 612 * Called by c2_remove to cleanup the RNIC resources.
613 */ 613 */
614void c2_rnic_term(struct c2_dev *c2dev) 614void __devexit c2_rnic_term(struct c2_dev *c2dev)
615{ 615{
616 616
617 /* Close the open adapter instance */ 617 /* Close the open adapter instance */
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 01f5aa9cb56d..3d1c1c535038 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -52,7 +52,7 @@
52MODULE_LICENSE("Dual BSD/GPL"); 52MODULE_LICENSE("Dual BSD/GPL");
53MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); 53MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>");
54MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver"); 54MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver");
55MODULE_VERSION("SVNEHCA_0018"); 55MODULE_VERSION("SVNEHCA_0019");
56 56
57int ehca_open_aqp1 = 0; 57int ehca_open_aqp1 = 0;
58int ehca_debug_level = 0; 58int ehca_debug_level = 0;
@@ -790,7 +790,7 @@ int __init ehca_module_init(void)
790 int ret; 790 int ret;
791 791
792 printk(KERN_INFO "eHCA Infiniband Device Driver " 792 printk(KERN_INFO "eHCA Infiniband Device Driver "
793 "(Rel.: SVNEHCA_0018)\n"); 793 "(Rel.: SVNEHCA_0019)\n");
794 idr_init(&ehca_qp_idr); 794 idr_init(&ehca_qp_idr);
795 idr_init(&ehca_cq_idr); 795 idr_init(&ehca_cq_idr);
796 spin_lock_init(&ehca_qp_idr_lock); 796 spin_lock_init(&ehca_qp_idr_lock);
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index cf3e50ee2d06..8682aa50c707 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -732,8 +732,7 @@ static int prepare_sqe_rts(struct ehca_qp *my_qp, struct ehca_shca *shca,
732 u64 h_ret; 732 u64 h_ret;
733 struct ipz_queue *squeue; 733 struct ipz_queue *squeue;
734 void *bad_send_wqe_p, *bad_send_wqe_v; 734 void *bad_send_wqe_p, *bad_send_wqe_v;
735 void *squeue_start_p, *squeue_end_p; 735 u64 q_ofs;
736 void *squeue_start_v, *squeue_end_v;
737 struct ehca_wqe *wqe; 736 struct ehca_wqe *wqe;
738 int qp_num = my_qp->ib_qp.qp_num; 737 int qp_num = my_qp->ib_qp.qp_num;
739 738
@@ -755,26 +754,23 @@ static int prepare_sqe_rts(struct ehca_qp *my_qp, struct ehca_shca *shca,
755 if (ehca_debug_level) 754 if (ehca_debug_level)
756 ehca_dmp(bad_send_wqe_v, 32, "qp_num=%x bad_wqe", qp_num); 755 ehca_dmp(bad_send_wqe_v, 32, "qp_num=%x bad_wqe", qp_num);
757 squeue = &my_qp->ipz_squeue; 756 squeue = &my_qp->ipz_squeue;
758 squeue_start_p = (void*)virt_to_abs(ipz_qeit_calc(squeue, 0L)); 757 if (ipz_queue_abs_to_offset(squeue, (u64)bad_send_wqe_p, &q_ofs)) {
759 squeue_end_p = squeue_start_p+squeue->queue_length; 758 ehca_err(&shca->ib_device, "failed to get wqe offset qp_num=%x"
760 squeue_start_v = abs_to_virt((u64)squeue_start_p); 759 " bad_send_wqe_p=%p", qp_num, bad_send_wqe_p);
761 squeue_end_v = abs_to_virt((u64)squeue_end_p); 760 return -EFAULT;
762 ehca_dbg(&shca->ib_device, "qp_num=%x squeue_start_v=%p squeue_end_v=%p", 761 }
763 qp_num, squeue_start_v, squeue_end_v);
764 762
765 /* loop sets wqe's purge bit */ 763 /* loop sets wqe's purge bit */
766 wqe = (struct ehca_wqe*)bad_send_wqe_v; 764 wqe = (struct ehca_wqe*)ipz_qeit_calc(squeue, q_ofs);
767 *bad_wqe_cnt = 0; 765 *bad_wqe_cnt = 0;
768 while (wqe->optype != 0xff && wqe->wqef != 0xff) { 766 while (wqe->optype != 0xff && wqe->wqef != 0xff) {
769 if (ehca_debug_level) 767 if (ehca_debug_level)
770 ehca_dmp(wqe, 32, "qp_num=%x wqe", qp_num); 768 ehca_dmp(wqe, 32, "qp_num=%x wqe", qp_num);
771 wqe->nr_of_data_seg = 0; /* suppress data access */ 769 wqe->nr_of_data_seg = 0; /* suppress data access */
772 wqe->wqef = WQEF_PURGE; /* WQE to be purged */ 770 wqe->wqef = WQEF_PURGE; /* WQE to be purged */
773 wqe = (struct ehca_wqe*)((u8*)wqe+squeue->qe_size); 771 q_ofs = ipz_queue_advance_offset(squeue, q_ofs);
772 wqe = (struct ehca_wqe*)ipz_qeit_calc(squeue, q_ofs);
774 *bad_wqe_cnt = (*bad_wqe_cnt)+1; 773 *bad_wqe_cnt = (*bad_wqe_cnt)+1;
775 if ((void*)wqe >= squeue_end_v) {
776 wqe = squeue_start_v;
777 }
778 } 774 }
779 /* 775 /*
780 * bad wqe will be reprocessed and ignored when pol_cq() is called, 776 * bad wqe will be reprocessed and ignored when pol_cq() is called,
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.c b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
index e028ff1588cc..bf7a40088f61 100644
--- a/drivers/infiniband/hw/ehca/ipz_pt_fn.c
+++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
@@ -70,6 +70,19 @@ void *ipz_qeit_eq_get_inc(struct ipz_queue *queue)
70 return ret; 70 return ret;
71} 71}
72 72
73int ipz_queue_abs_to_offset(struct ipz_queue *queue, u64 addr, u64 *q_offset)
74{
75 int i;
76 for (i = 0; i < queue->queue_length / queue->pagesize; i++) {
77 u64 page = (u64)virt_to_abs(queue->queue_pages[i]);
78 if (addr >= page && addr < page + queue->pagesize) {
79 *q_offset = addr - page + i * queue->pagesize;
80 return 0;
81 }
82 }
83 return -EINVAL;
84}
85
73int ipz_queue_ctor(struct ipz_queue *queue, 86int ipz_queue_ctor(struct ipz_queue *queue,
74 const u32 nr_of_pages, 87 const u32 nr_of_pages,
75 const u32 pagesize, const u32 qe_size, const u32 nr_of_sg) 88 const u32 pagesize, const u32 qe_size, const u32 nr_of_sg)
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.h b/drivers/infiniband/hw/ehca/ipz_pt_fn.h
index 2f13509d5257..dc3bda2634b7 100644
--- a/drivers/infiniband/hw/ehca/ipz_pt_fn.h
+++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.h
@@ -150,6 +150,21 @@ static inline void *ipz_qeit_reset(struct ipz_queue *queue)
150 return ipz_qeit_get(queue); 150 return ipz_qeit_get(queue);
151} 151}
152 152
153/*
154 * return the q_offset corresponding to an absolute address
155 */
156int ipz_queue_abs_to_offset(struct ipz_queue *queue, u64 addr, u64 *q_offset);
157
158/*
159 * return the next queue offset. don't modify the queue.
160 */
161static inline u64 ipz_queue_advance_offset(struct ipz_queue *queue, u64 offset)
162{
163 offset += queue->qe_size;
164 if (offset >= queue->queue_length) offset = 0;
165 return offset;
166}
167
153/* struct generic page table */ 168/* struct generic page table */
154struct ipz_pt { 169struct ipz_pt {
155 u64 entries[EHCA_PT_ENTRIES]; 170 u64 entries[EHCA_PT_ENTRIES];
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index a5456108dbad..acdee33ee1f8 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -1487,7 +1487,7 @@ int ipath_register_ib_device(struct ipath_devdata *dd)
1487 idev->pma_counter_select[1] = IB_PMA_PORT_RCV_DATA; 1487 idev->pma_counter_select[1] = IB_PMA_PORT_RCV_DATA;
1488 idev->pma_counter_select[2] = IB_PMA_PORT_XMIT_PKTS; 1488 idev->pma_counter_select[2] = IB_PMA_PORT_XMIT_PKTS;
1489 idev->pma_counter_select[3] = IB_PMA_PORT_RCV_PKTS; 1489 idev->pma_counter_select[3] = IB_PMA_PORT_RCV_PKTS;
1490 idev->pma_counter_select[5] = IB_PMA_PORT_XMIT_WAIT; 1490 idev->pma_counter_select[4] = IB_PMA_PORT_XMIT_WAIT;
1491 idev->link_width_enabled = 3; /* 1x or 4x */ 1491 idev->link_width_enabled = 3; /* 1x or 4x */
1492 1492
1493 /* Snapshot current HW counters to "clear" them. */ 1493 /* Snapshot current HW counters to "clear" them. */
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c
index 69599455aca2..57cdc1bc5f50 100644
--- a/drivers/infiniband/hw/mthca/mthca_av.c
+++ b/drivers/infiniband/hw/mthca/mthca_av.c
@@ -33,7 +33,6 @@
33 * $Id: mthca_av.c 1349 2004-12-16 21:09:43Z roland $ 33 * $Id: mthca_av.c 1349 2004-12-16 21:09:43Z roland $
34 */ 34 */
35 35
36#include <linux/init.h>
37#include <linux/string.h> 36#include <linux/string.h>
38#include <linux/slab.h> 37#include <linux/slab.h>
39 38
@@ -323,7 +322,7 @@ int mthca_ah_query(struct ib_ah *ibah, struct ib_ah_attr *attr)
323 return 0; 322 return 0;
324} 323}
325 324
326int __devinit mthca_init_av_table(struct mthca_dev *dev) 325int mthca_init_av_table(struct mthca_dev *dev)
327{ 326{
328 int err; 327 int err;
329 328
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 149b36901239..283d50b76c3d 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -36,7 +36,6 @@
36 * $Id: mthca_cq.c 1369 2004-12-20 16:17:07Z roland $ 36 * $Id: mthca_cq.c 1369 2004-12-20 16:17:07Z roland $
37 */ 37 */
38 38
39#include <linux/init.h>
40#include <linux/hardirq.h> 39#include <linux/hardirq.h>
41 40
42#include <asm/io.h> 41#include <asm/io.h>
@@ -970,7 +969,7 @@ void mthca_free_cq(struct mthca_dev *dev,
970 mthca_free_mailbox(dev, mailbox); 969 mthca_free_mailbox(dev, mailbox);
971} 970}
972 971
973int __devinit mthca_init_cq_table(struct mthca_dev *dev) 972int mthca_init_cq_table(struct mthca_dev *dev)
974{ 973{
975 int err; 974 int err;
976 975
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index e284e0613a94..8ec9fa1ff9ea 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -33,7 +33,6 @@
33 * $Id: mthca_eq.c 1382 2004-12-24 02:21:02Z roland $ 33 * $Id: mthca_eq.c 1382 2004-12-24 02:21:02Z roland $
34 */ 34 */
35 35
36#include <linux/init.h>
37#include <linux/errno.h> 36#include <linux/errno.h>
38#include <linux/interrupt.h> 37#include <linux/interrupt.h>
39#include <linux/pci.h> 38#include <linux/pci.h>
@@ -479,10 +478,10 @@ static irqreturn_t mthca_arbel_msi_x_interrupt(int irq, void *eq_ptr)
479 return IRQ_HANDLED; 478 return IRQ_HANDLED;
480} 479}
481 480
482static int __devinit mthca_create_eq(struct mthca_dev *dev, 481static int mthca_create_eq(struct mthca_dev *dev,
483 int nent, 482 int nent,
484 u8 intr, 483 u8 intr,
485 struct mthca_eq *eq) 484 struct mthca_eq *eq)
486{ 485{
487 int npages; 486 int npages;
488 u64 *dma_list = NULL; 487 u64 *dma_list = NULL;
@@ -664,9 +663,9 @@ static void mthca_free_irqs(struct mthca_dev *dev)
664 dev->eq_table.eq + i); 663 dev->eq_table.eq + i);
665} 664}
666 665
667static int __devinit mthca_map_reg(struct mthca_dev *dev, 666static int mthca_map_reg(struct mthca_dev *dev,
668 unsigned long offset, unsigned long size, 667 unsigned long offset, unsigned long size,
669 void __iomem **map) 668 void __iomem **map)
670{ 669{
671 unsigned long base = pci_resource_start(dev->pdev, 0); 670 unsigned long base = pci_resource_start(dev->pdev, 0);
672 671
@@ -691,7 +690,7 @@ static void mthca_unmap_reg(struct mthca_dev *dev, unsigned long offset,
691 iounmap(map); 690 iounmap(map);
692} 691}
693 692
694static int __devinit mthca_map_eq_regs(struct mthca_dev *dev) 693static int mthca_map_eq_regs(struct mthca_dev *dev)
695{ 694{
696 if (mthca_is_memfree(dev)) { 695 if (mthca_is_memfree(dev)) {
697 /* 696 /*
@@ -781,7 +780,7 @@ static void mthca_unmap_eq_regs(struct mthca_dev *dev)
781 } 780 }
782} 781}
783 782
784int __devinit mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt) 783int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt)
785{ 784{
786 int ret; 785 int ret;
787 u8 status; 786 u8 status;
@@ -825,7 +824,7 @@ void mthca_unmap_eq_icm(struct mthca_dev *dev)
825 __free_page(dev->eq_table.icm_page); 824 __free_page(dev->eq_table.icm_page);
826} 825}
827 826
828int __devinit mthca_init_eq_table(struct mthca_dev *dev) 827int mthca_init_eq_table(struct mthca_dev *dev)
829{ 828{
830 int err; 829 int err;
831 u8 status; 830 u8 status;
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
index 45e106f14807..acfa41d968ee 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -317,7 +317,7 @@ err:
317 return ret; 317 return ret;
318} 318}
319 319
320void __devexit mthca_free_agents(struct mthca_dev *dev) 320void mthca_free_agents(struct mthca_dev *dev)
321{ 321{
322 struct ib_mad_agent *agent; 322 struct ib_mad_agent *agent;
323 int p, q; 323 int p, q;
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 47ea02148368..0491ec7a7c0a 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -98,7 +98,7 @@ static struct mthca_profile default_profile = {
98 .uarc_size = 1 << 18, /* Arbel only */ 98 .uarc_size = 1 << 18, /* Arbel only */
99}; 99};
100 100
101static int __devinit mthca_tune_pci(struct mthca_dev *mdev) 101static int mthca_tune_pci(struct mthca_dev *mdev)
102{ 102{
103 int cap; 103 int cap;
104 u16 val; 104 u16 val;
@@ -143,7 +143,7 @@ static int __devinit mthca_tune_pci(struct mthca_dev *mdev)
143 return 0; 143 return 0;
144} 144}
145 145
146static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim) 146static int mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim)
147{ 147{
148 int err; 148 int err;
149 u8 status; 149 u8 status;
@@ -255,7 +255,7 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
255 return 0; 255 return 0;
256} 256}
257 257
258static int __devinit mthca_init_tavor(struct mthca_dev *mdev) 258static int mthca_init_tavor(struct mthca_dev *mdev)
259{ 259{
260 u8 status; 260 u8 status;
261 int err; 261 int err;
@@ -333,7 +333,7 @@ err_disable:
333 return err; 333 return err;
334} 334}
335 335
336static int __devinit mthca_load_fw(struct mthca_dev *mdev) 336static int mthca_load_fw(struct mthca_dev *mdev)
337{ 337{
338 u8 status; 338 u8 status;
339 int err; 339 int err;
@@ -379,10 +379,10 @@ err_free:
379 return err; 379 return err;
380} 380}
381 381
382static int __devinit mthca_init_icm(struct mthca_dev *mdev, 382static int mthca_init_icm(struct mthca_dev *mdev,
383 struct mthca_dev_lim *dev_lim, 383 struct mthca_dev_lim *dev_lim,
384 struct mthca_init_hca_param *init_hca, 384 struct mthca_init_hca_param *init_hca,
385 u64 icm_size) 385 u64 icm_size)
386{ 386{
387 u64 aux_pages; 387 u64 aux_pages;
388 u8 status; 388 u8 status;
@@ -575,7 +575,7 @@ static void mthca_free_icms(struct mthca_dev *mdev)
575 mthca_free_icm(mdev, mdev->fw.arbel.aux_icm); 575 mthca_free_icm(mdev, mdev->fw.arbel.aux_icm);
576} 576}
577 577
578static int __devinit mthca_init_arbel(struct mthca_dev *mdev) 578static int mthca_init_arbel(struct mthca_dev *mdev)
579{ 579{
580 struct mthca_dev_lim dev_lim; 580 struct mthca_dev_lim dev_lim;
581 struct mthca_profile profile; 581 struct mthca_profile profile;
@@ -683,7 +683,7 @@ static void mthca_close_hca(struct mthca_dev *mdev)
683 mthca_SYS_DIS(mdev, &status); 683 mthca_SYS_DIS(mdev, &status);
684} 684}
685 685
686static int __devinit mthca_init_hca(struct mthca_dev *mdev) 686static int mthca_init_hca(struct mthca_dev *mdev)
687{ 687{
688 u8 status; 688 u8 status;
689 int err; 689 int err;
@@ -720,7 +720,7 @@ err_close:
720 return err; 720 return err;
721} 721}
722 722
723static int __devinit mthca_setup_hca(struct mthca_dev *dev) 723static int mthca_setup_hca(struct mthca_dev *dev)
724{ 724{
725 int err; 725 int err;
726 u8 status; 726 u8 status;
@@ -875,8 +875,7 @@ err_uar_table_free:
875 return err; 875 return err;
876} 876}
877 877
878static int __devinit mthca_request_regions(struct pci_dev *pdev, 878static int mthca_request_regions(struct pci_dev *pdev, int ddr_hidden)
879 int ddr_hidden)
880{ 879{
881 int err; 880 int err;
882 881
@@ -928,7 +927,7 @@ static void mthca_release_regions(struct pci_dev *pdev,
928 MTHCA_HCR_SIZE); 927 MTHCA_HCR_SIZE);
929} 928}
930 929
931static int __devinit mthca_enable_msi_x(struct mthca_dev *mdev) 930static int mthca_enable_msi_x(struct mthca_dev *mdev)
932{ 931{
933 struct msix_entry entries[3]; 932 struct msix_entry entries[3];
934 int err; 933 int err;
@@ -1213,7 +1212,7 @@ int __mthca_restart_one(struct pci_dev *pdev)
1213} 1212}
1214 1213
1215static int __devinit mthca_init_one(struct pci_dev *pdev, 1214static int __devinit mthca_init_one(struct pci_dev *pdev,
1216 const struct pci_device_id *id) 1215 const struct pci_device_id *id)
1217{ 1216{
1218 static int mthca_version_printed = 0; 1217 static int mthca_version_printed = 0;
1219 int ret; 1218 int ret;
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index 47ca8a9b7247..a8ad072be074 100644
--- a/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ b/drivers/infiniband/hw/mthca/mthca_mcg.c
@@ -32,7 +32,6 @@
32 * $Id: mthca_mcg.c 1349 2004-12-16 21:09:43Z roland $ 32 * $Id: mthca_mcg.c 1349 2004-12-16 21:09:43Z roland $
33 */ 33 */
34 34
35#include <linux/init.h>
36#include <linux/string.h> 35#include <linux/string.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
38 37
@@ -371,7 +370,7 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
371 return err; 370 return err;
372} 371}
373 372
374int __devinit mthca_init_mcg_table(struct mthca_dev *dev) 373int mthca_init_mcg_table(struct mthca_dev *dev)
375{ 374{
376 int err; 375 int err;
377 int table_size = dev->limits.num_mgms + dev->limits.num_amgms; 376 int table_size = dev->limits.num_mgms + dev->limits.num_amgms;
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
index a486dec1707e..f71ffa88db3a 100644
--- a/drivers/infiniband/hw/mthca/mthca_mr.c
+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
@@ -34,7 +34,6 @@
34 */ 34 */
35 35
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/init.h>
38#include <linux/errno.h> 37#include <linux/errno.h>
39 38
40#include "mthca_dev.h" 39#include "mthca_dev.h"
@@ -135,7 +134,7 @@ static void mthca_buddy_free(struct mthca_buddy *buddy, u32 seg, int order)
135 spin_unlock(&buddy->lock); 134 spin_unlock(&buddy->lock);
136} 135}
137 136
138static int __devinit mthca_buddy_init(struct mthca_buddy *buddy, int max_order) 137static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
139{ 138{
140 int i, s; 139 int i, s;
141 140
@@ -759,7 +758,7 @@ void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr)
759 *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW; 758 *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW;
760} 759}
761 760
762int __devinit mthca_init_mr_table(struct mthca_dev *dev) 761int mthca_init_mr_table(struct mthca_dev *dev)
763{ 762{
764 unsigned long addr; 763 unsigned long addr;
765 int err, i; 764 int err, i;
diff --git a/drivers/infiniband/hw/mthca/mthca_pd.c b/drivers/infiniband/hw/mthca/mthca_pd.c
index 59df51614c85..c1e950764bd8 100644
--- a/drivers/infiniband/hw/mthca/mthca_pd.c
+++ b/drivers/infiniband/hw/mthca/mthca_pd.c
@@ -34,7 +34,6 @@
34 * $Id: mthca_pd.c 1349 2004-12-16 21:09:43Z roland $ 34 * $Id: mthca_pd.c 1349 2004-12-16 21:09:43Z roland $
35 */ 35 */
36 36
37#include <linux/init.h>
38#include <linux/errno.h> 37#include <linux/errno.h>
39 38
40#include "mthca_dev.h" 39#include "mthca_dev.h"
@@ -69,7 +68,7 @@ void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd)
69 mthca_free(&dev->pd_table.alloc, pd->pd_num); 68 mthca_free(&dev->pd_table.alloc, pd->pd_num);
70} 69}
71 70
72int __devinit mthca_init_pd_table(struct mthca_dev *dev) 71int mthca_init_pd_table(struct mthca_dev *dev)
73{ 72{
74 return mthca_alloc_init(&dev->pd_table.alloc, 73 return mthca_alloc_init(&dev->pd_table.alloc,
75 dev->limits.num_pds, 74 dev->limits.num_pds,
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index fc67f780581b..21422a3336ad 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -1100,11 +1100,10 @@ static struct ib_fmr *mthca_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
1100 struct mthca_fmr *fmr; 1100 struct mthca_fmr *fmr;
1101 int err; 1101 int err;
1102 1102
1103 fmr = kmalloc(sizeof *fmr, GFP_KERNEL); 1103 fmr = kmemdup(fmr_attr, sizeof *fmr, GFP_KERNEL);
1104 if (!fmr) 1104 if (!fmr)
1105 return ERR_PTR(-ENOMEM); 1105 return ERR_PTR(-ENOMEM);
1106 1106
1107 memcpy(&fmr->attr, fmr_attr, sizeof *fmr_attr);
1108 err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num, 1107 err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num,
1109 convert_access(mr_access_flags), fmr); 1108 convert_access(mr_access_flags), fmr);
1110 1109
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 6a7822e0fc19..33e3ba7937f1 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -35,7 +35,6 @@
35 * $Id: mthca_qp.c 1355 2004-12-17 15:23:43Z roland $ 35 * $Id: mthca_qp.c 1355 2004-12-17 15:23:43Z roland $
36 */ 36 */
37 37
38#include <linux/init.h>
39#include <linux/string.h> 38#include <linux/string.h>
40#include <linux/slab.h> 39#include <linux/slab.h>
41 40
@@ -2241,7 +2240,7 @@ void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
2241 *new_wqe = 0; 2240 *new_wqe = 0;
2242} 2241}
2243 2242
2244int __devinit mthca_init_qp_table(struct mthca_dev *dev) 2243int mthca_init_qp_table(struct mthca_dev *dev)
2245{ 2244{
2246 int err; 2245 int err;
2247 u8 status; 2246 u8 status;
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index f5d7677d1079..34d2c4768962 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -120,7 +120,7 @@ static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
120 120
121 memset(context, 0, sizeof *context); 121 memset(context, 0, sizeof *context);
122 122
123 logsize = long_log2(srq->max) + srq->wqe_shift; 123 logsize = long_log2(srq->max);
124 context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn); 124 context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn);
125 context->lkey = cpu_to_be32(srq->mr.ibmr.lkey); 125 context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
126 context->db_index = cpu_to_be32(srq->db_index); 126 context->db_index = cpu_to_be32(srq->db_index);
@@ -715,7 +715,7 @@ int mthca_max_srq_sge(struct mthca_dev *dev)
715 sizeof (struct mthca_data_seg)); 715 sizeof (struct mthca_data_seg));
716} 716}
717 717
718int __devinit mthca_init_srq_table(struct mthca_dev *dev) 718int mthca_init_srq_table(struct mthca_dev *dev)
719{ 719{
720 int err; 720 int err;
721 721
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 3b2ee0eba05e..99547996aba2 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -233,7 +233,7 @@ static inline struct ipoib_neigh **to_ipoib_neigh(struct neighbour *neigh)
233} 233}
234 234
235struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neigh); 235struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neigh);
236void ipoib_neigh_free(struct ipoib_neigh *neigh); 236void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh);
237 237
238extern struct workqueue_struct *ipoib_workqueue; 238extern struct workqueue_struct *ipoib_workqueue;
239 239
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 71114a8c12b9..c09280243726 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -264,7 +264,7 @@ static void path_free(struct net_device *dev, struct ipoib_path *path)
264 if (neigh->ah) 264 if (neigh->ah)
265 ipoib_put_ah(neigh->ah); 265 ipoib_put_ah(neigh->ah);
266 266
267 ipoib_neigh_free(neigh); 267 ipoib_neigh_free(dev, neigh);
268 } 268 }
269 269
270 spin_unlock_irqrestore(&priv->lock, flags); 270 spin_unlock_irqrestore(&priv->lock, flags);
@@ -525,10 +525,11 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
525 ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha)); 525 ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha));
526 } else { 526 } else {
527 neigh->ah = NULL; 527 neigh->ah = NULL;
528 __skb_queue_tail(&neigh->queue, skb);
529 528
530 if (!path->query && path_rec_start(dev, path)) 529 if (!path->query && path_rec_start(dev, path))
531 goto err_list; 530 goto err_list;
531
532 __skb_queue_tail(&neigh->queue, skb);
532 } 533 }
533 534
534 spin_unlock(&priv->lock); 535 spin_unlock(&priv->lock);
@@ -538,7 +539,7 @@ err_list:
538 list_del(&neigh->list); 539 list_del(&neigh->list);
539 540
540err_path: 541err_path:
541 ipoib_neigh_free(neigh); 542 ipoib_neigh_free(dev, neigh);
542 ++priv->stats.tx_dropped; 543 ++priv->stats.tx_dropped;
543 dev_kfree_skb_any(skb); 544 dev_kfree_skb_any(skb);
544 545
@@ -655,7 +656,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
655 */ 656 */
656 ipoib_put_ah(neigh->ah); 657 ipoib_put_ah(neigh->ah);
657 list_del(&neigh->list); 658 list_del(&neigh->list);
658 ipoib_neigh_free(neigh); 659 ipoib_neigh_free(dev, neigh);
659 spin_unlock(&priv->lock); 660 spin_unlock(&priv->lock);
660 ipoib_path_lookup(skb, dev); 661 ipoib_path_lookup(skb, dev);
661 goto out; 662 goto out;
@@ -786,7 +787,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
786 if (neigh->ah) 787 if (neigh->ah)
787 ah = neigh->ah; 788 ah = neigh->ah;
788 list_del(&neigh->list); 789 list_del(&neigh->list);
789 ipoib_neigh_free(neigh); 790 ipoib_neigh_free(n->dev, neigh);
790 } 791 }
791 792
792 spin_unlock_irqrestore(&priv->lock, flags); 793 spin_unlock_irqrestore(&priv->lock, flags);
@@ -809,9 +810,15 @@ struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour)
809 return neigh; 810 return neigh;
810} 811}
811 812
812void ipoib_neigh_free(struct ipoib_neigh *neigh) 813void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh)
813{ 814{
815 struct ipoib_dev_priv *priv = netdev_priv(dev);
816 struct sk_buff *skb;
814 *to_ipoib_neigh(neigh->neighbour) = NULL; 817 *to_ipoib_neigh(neigh->neighbour) = NULL;
818 while ((skb = __skb_dequeue(&neigh->queue))) {
819 ++priv->stats.tx_dropped;
820 dev_kfree_skb_any(skb);
821 }
815 kfree(neigh); 822 kfree(neigh);
816} 823}
817 824
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index f0a4fac1a215..b04b72ca32ed 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -114,7 +114,7 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
114 */ 114 */
115 if (neigh->ah) 115 if (neigh->ah)
116 ipoib_put_ah(neigh->ah); 116 ipoib_put_ah(neigh->ah);
117 ipoib_neigh_free(neigh); 117 ipoib_neigh_free(dev, neigh);
118 } 118 }
119 119
120 spin_unlock_irqrestore(&priv->lock, flags); 120 spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index 9c53916f28c2..234e5b061a75 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -283,7 +283,7 @@ struct iser_global {
283 struct mutex connlist_mutex; 283 struct mutex connlist_mutex;
284 struct list_head connlist; /* all iSER IB connections */ 284 struct list_head connlist; /* all iSER IB connections */
285 285
286 kmem_cache_t *desc_cache; 286 struct kmem_cache *desc_cache;
287}; 287};
288 288
289extern struct iser_global ig; 289extern struct iser_global ig;
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 214f66195af2..a6289595557b 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1177,9 +1177,11 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
1177 break; 1177 break;
1178 } 1178 }
1179 1179
1180 target->status = srp_alloc_iu_bufs(target); 1180 if (!target->rx_ring[0]) {
1181 if (target->status) 1181 target->status = srp_alloc_iu_bufs(target);
1182 break; 1182 if (target->status)
1183 break;
1184 }
1183 1185
1184 qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL); 1186 qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
1185 if (!qp_attr) { 1187 if (!qp_attr) {
@@ -1717,7 +1719,8 @@ static ssize_t srp_create_target(struct class_device *class_dev,
1717 if (!target_host) 1719 if (!target_host)
1718 return -ENOMEM; 1720 return -ENOMEM;
1719 1721
1720 target_host->max_lun = SRP_MAX_LUN; 1722 target_host->max_lun = SRP_MAX_LUN;
1723 target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb;
1721 1724
1722 target = host_to_target(target_host); 1725 target = host_to_target(target_host);
1723 1726
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 105112fb7b57..80cdebcbcb99 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -178,9 +178,9 @@ static int iforce_usb_probe(struct usb_interface *intf,
178 178
179fail: 179fail:
180 if (iforce) { 180 if (iforce) {
181 if (iforce->irq) usb_free_urb(iforce->irq); 181 usb_free_urb(iforce->irq);
182 if (iforce->out) usb_free_urb(iforce->out); 182 usb_free_urb(iforce->out);
183 if (iforce->ctrl) usb_free_urb(iforce->ctrl); 183 usb_free_urb(iforce->ctrl);
184 kfree(iforce); 184 kfree(iforce);
185 } 185 }
186 186
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index ba2a2035d648..7c8d0399ae82 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -297,7 +297,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
297 297
298 serio_raw->dev.minor = PSMOUSE_MINOR; 298 serio_raw->dev.minor = PSMOUSE_MINOR;
299 serio_raw->dev.name = serio_raw->name; 299 serio_raw->dev.name = serio_raw->name;
300 serio_raw->dev.dev = &serio->dev; 300 serio_raw->dev.parent = &serio->dev;
301 serio_raw->dev.fops = &serio_raw_fops; 301 serio_raw->dev.fops = &serio_raw_fops;
302 302
303 err = misc_register(&serio_raw->dev); 303 err = misc_register(&serio_raw->dev);
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index 5800beeebb85..defd5743dba6 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -702,7 +702,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
702 cs->open_count = 0; 702 cs->open_count = 0;
703 cs->dev = NULL; 703 cs->dev = NULL;
704 cs->tty = NULL; 704 cs->tty = NULL;
705 cs->class = NULL; 705 cs->tty_dev = NULL;
706 cs->cidmode = cidmode != 0; 706 cs->cidmode = cidmode != 0;
707 707
708 //if(onechannel) { //FIXME 708 //if(onechannel) { //FIXME
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 884bd72c1bf4..06298cc52bf5 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -444,7 +444,7 @@ struct cardstate {
444 struct gigaset_driver *driver; 444 struct gigaset_driver *driver;
445 unsigned minor_index; 445 unsigned minor_index;
446 struct device *dev; 446 struct device *dev;
447 struct class_device *class; 447 struct device *tty_dev;
448 448
449 const struct gigaset_ops *ops; 449 const struct gigaset_ops *ops;
450 450
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 596f3aebe2f7..7edea015867e 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -625,13 +625,13 @@ void gigaset_if_init(struct cardstate *cs)
625 return; 625 return;
626 626
627 tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs); 627 tasklet_init(&cs->if_wake_tasklet, &if_wake, (unsigned long) cs);
628 cs->class = tty_register_device(drv->tty, cs->minor_index, NULL); 628 cs->tty_dev = tty_register_device(drv->tty, cs->minor_index, NULL);
629 629
630 if (!IS_ERR(cs->class)) 630 if (!IS_ERR(cs->tty_dev))
631 class_set_devdata(cs->class, cs); 631 dev_set_drvdata(cs->tty_dev, cs);
632 else { 632 else {
633 warn("could not register device to the tty subsystem"); 633 warn("could not register device to the tty subsystem");
634 cs->class = NULL; 634 cs->tty_dev = NULL;
635 } 635 }
636} 636}
637 637
@@ -645,7 +645,7 @@ void gigaset_if_free(struct cardstate *cs)
645 645
646 tasklet_disable(&cs->if_wake_tasklet); 646 tasklet_disable(&cs->if_wake_tasklet);
647 tasklet_kill(&cs->if_wake_tasklet); 647 tasklet_kill(&cs->if_wake_tasklet);
648 cs->class = NULL; 648 cs->tty_dev = NULL;
649 tty_unregister_device(drv->tty, cs->minor_index); 649 tty_unregister_device(drv->tty, cs->minor_index);
650} 650}
651 651
diff --git a/drivers/isdn/gigaset/proc.c b/drivers/isdn/gigaset/proc.c
index 9ad840e95dbe..e767afa55abf 100644
--- a/drivers/isdn/gigaset/proc.c
+++ b/drivers/isdn/gigaset/proc.c
@@ -16,11 +16,12 @@
16#include "gigaset.h" 16#include "gigaset.h"
17#include <linux/ctype.h> 17#include <linux/ctype.h>
18 18
19static ssize_t show_cidmode(struct class_device *class, char *buf) 19static ssize_t show_cidmode(struct device *dev,
20 struct device_attribute *attr, char *buf)
20{ 21{
21 int ret; 22 int ret;
22 unsigned long flags; 23 unsigned long flags;
23 struct cardstate *cs = class_get_devdata(class); 24 struct cardstate *cs = dev_get_drvdata(dev);
24 25
25 spin_lock_irqsave(&cs->lock, flags); 26 spin_lock_irqsave(&cs->lock, flags);
26 ret = sprintf(buf, "%u\n", cs->cidmode); 27 ret = sprintf(buf, "%u\n", cs->cidmode);
@@ -29,10 +30,10 @@ static ssize_t show_cidmode(struct class_device *class, char *buf)
29 return ret; 30 return ret;
30} 31}
31 32
32static ssize_t set_cidmode(struct class_device *class, 33static ssize_t set_cidmode(struct device *dev, struct device_attribute *attr,
33 const char *buf, size_t count) 34 const char *buf, size_t count)
34{ 35{
35 struct cardstate *cs = class_get_devdata(class); 36 struct cardstate *cs = dev_get_drvdata(dev);
36 long int value; 37 long int value;
37 char *end; 38 char *end;
38 39
@@ -64,25 +65,25 @@ static ssize_t set_cidmode(struct class_device *class,
64 return count; 65 return count;
65} 66}
66 67
67static CLASS_DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode); 68static DEVICE_ATTR(cidmode, S_IRUGO|S_IWUSR, show_cidmode, set_cidmode);
68 69
69/* free sysfs for device */ 70/* free sysfs for device */
70void gigaset_free_dev_sysfs(struct cardstate *cs) 71void gigaset_free_dev_sysfs(struct cardstate *cs)
71{ 72{
72 if (!cs->class) 73 if (!cs->tty_dev)
73 return; 74 return;
74 75
75 gig_dbg(DEBUG_INIT, "removing sysfs entries"); 76 gig_dbg(DEBUG_INIT, "removing sysfs entries");
76 class_device_remove_file(cs->class, &class_device_attr_cidmode); 77 device_remove_file(cs->tty_dev, &dev_attr_cidmode);
77} 78}
78 79
79/* initialize sysfs for device */ 80/* initialize sysfs for device */
80void gigaset_init_dev_sysfs(struct cardstate *cs) 81void gigaset_init_dev_sysfs(struct cardstate *cs)
81{ 82{
82 if (!cs->class) 83 if (!cs->tty_dev)
83 return; 84 return;
84 85
85 gig_dbg(DEBUG_INIT, "setting up sysfs"); 86 gig_dbg(DEBUG_INIT, "setting up sysfs");
86 if (class_device_create_file(cs->class, &class_device_attr_cidmode)) 87 if (device_create_file(cs->tty_dev, &dev_attr_cidmode))
87 dev_err(cs->dev, "could not create sysfs attribute\n"); 88 dev_err(cs->dev, "could not create sysfs attribute\n");
88} 89}
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 4ffa9eb1c28e..5ebf49ac9b23 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -815,14 +815,11 @@ static int gigaset_probe(struct usb_interface *interface,
815 return 0; 815 return 0;
816 816
817error: 817error:
818 if (ucs->read_urb) 818 usb_kill_urb(ucs->read_urb);
819 usb_kill_urb(ucs->read_urb);
820 kfree(ucs->bulk_out_buffer); 819 kfree(ucs->bulk_out_buffer);
821 if (ucs->bulk_out_urb != NULL) 820 usb_free_urb(ucs->bulk_out_urb);
822 usb_free_urb(ucs->bulk_out_urb);
823 kfree(cs->inbuf[0].rcvbuf); 821 kfree(cs->inbuf[0].rcvbuf);
824 if (ucs->read_urb != NULL) 822 usb_free_urb(ucs->read_urb);
825 usb_free_urb(ucs->read_urb);
826 usb_set_intfdata(interface, NULL); 823 usb_set_intfdata(interface, NULL);
827 ucs->read_urb = ucs->bulk_out_urb = NULL; 824 ucs->read_urb = ucs->bulk_out_urb = NULL;
828 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; 825 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
@@ -850,11 +847,9 @@ static void gigaset_disconnect(struct usb_interface *interface)
850 usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */ 847 usb_kill_urb(ucs->bulk_out_urb); /* FIXME: only if active? */
851 848
852 kfree(ucs->bulk_out_buffer); 849 kfree(ucs->bulk_out_buffer);
853 if (ucs->bulk_out_urb != NULL) 850 usb_free_urb(ucs->bulk_out_urb);
854 usb_free_urb(ucs->bulk_out_urb);
855 kfree(cs->inbuf[0].rcvbuf); 851 kfree(cs->inbuf[0].rcvbuf);
856 if (ucs->read_urb != NULL) 852 usb_free_urb(ucs->read_urb);
857 usb_free_urb(ucs->read_urb);
858 ucs->read_urb = ucs->bulk_out_urb = NULL; 853 ucs->read_urb = ucs->bulk_out_urb = NULL;
859 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL; 854 cs->inbuf[0].rcvbuf = ucs->bulk_out_buffer = NULL;
860 855
diff --git a/drivers/isdn/hardware/eicon/os_4bri.c b/drivers/isdn/hardware/eicon/os_4bri.c
index 11e6f937c1e4..7b4ec3f60dbf 100644
--- a/drivers/isdn/hardware/eicon/os_4bri.c
+++ b/drivers/isdn/hardware/eicon/os_4bri.c
@@ -464,7 +464,7 @@ int diva_4bri_init_card(diva_os_xdi_adapter_t * a)
464 464
465/* 465/*
466** Cleanup function will be called for master adapter only 466** Cleanup function will be called for master adapter only
467** this is garanteed by design: cleanup callback is set 467** this is guaranteed by design: cleanup callback is set
468** by master adapter only 468** by master adapter only
469*/ 469*/
470static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t * a) 470static int diva_4bri_cleanup_adapter(diva_os_xdi_adapter_t * a)
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.h b/drivers/isdn/hisax/hfc4s8s_l1.h
index e8f9c077fa85..9d5d2a56b4e9 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.h
+++ b/drivers/isdn/hisax/hfc4s8s_l1.h
@@ -16,7 +16,7 @@
16 16
17/* 17/*
18* include Genero generated HFC-4S/8S header file hfc48scu.h 18* include Genero generated HFC-4S/8S header file hfc48scu.h
19* for comlete register description. This will define _HFC48SCU_H_ 19* for complete register description. This will define _HFC48SCU_H_
20* to prevent redefinitions 20* to prevent redefinitions
21*/ 21*/
22 22
diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c
index 6d0431725555..cd3b5ad53491 100644
--- a/drivers/isdn/hisax/isdnl2.c
+++ b/drivers/isdn/hisax/isdnl2.c
@@ -1442,7 +1442,7 @@ l2_tei_remove(struct FsmInst *fi, int event, void *arg)
1442} 1442}
1443 1443
1444static void 1444static void
1445l2_st14_persistant_da(struct FsmInst *fi, int event, void *arg) 1445l2_st14_persistent_da(struct FsmInst *fi, int event, void *arg)
1446{ 1446{
1447 struct PStack *st = fi->userdata; 1447 struct PStack *st = fi->userdata;
1448 1448
@@ -1453,7 +1453,7 @@ l2_st14_persistant_da(struct FsmInst *fi, int event, void *arg)
1453} 1453}
1454 1454
1455static void 1455static void
1456l2_st5_persistant_da(struct FsmInst *fi, int event, void *arg) 1456l2_st5_persistent_da(struct FsmInst *fi, int event, void *arg)
1457{ 1457{
1458 struct PStack *st = fi->userdata; 1458 struct PStack *st = fi->userdata;
1459 1459
@@ -1466,7 +1466,7 @@ l2_st5_persistant_da(struct FsmInst *fi, int event, void *arg)
1466} 1466}
1467 1467
1468static void 1468static void
1469l2_st6_persistant_da(struct FsmInst *fi, int event, void *arg) 1469l2_st6_persistent_da(struct FsmInst *fi, int event, void *arg)
1470{ 1470{
1471 struct PStack *st = fi->userdata; 1471 struct PStack *st = fi->userdata;
1472 1472
@@ -1477,7 +1477,7 @@ l2_st6_persistant_da(struct FsmInst *fi, int event, void *arg)
1477} 1477}
1478 1478
1479static void 1479static void
1480l2_persistant_da(struct FsmInst *fi, int event, void *arg) 1480l2_persistent_da(struct FsmInst *fi, int event, void *arg)
1481{ 1481{
1482 struct PStack *st = fi->userdata; 1482 struct PStack *st = fi->userdata;
1483 1483
@@ -1612,14 +1612,14 @@ static struct FsmNode L2FnList[] __initdata =
1612 {ST_L2_6, EV_L2_FRAME_ERROR, l2_frame_error}, 1612 {ST_L2_6, EV_L2_FRAME_ERROR, l2_frame_error},
1613 {ST_L2_7, EV_L2_FRAME_ERROR, l2_frame_error_reest}, 1613 {ST_L2_7, EV_L2_FRAME_ERROR, l2_frame_error_reest},
1614 {ST_L2_8, EV_L2_FRAME_ERROR, l2_frame_error_reest}, 1614 {ST_L2_8, EV_L2_FRAME_ERROR, l2_frame_error_reest},
1615 {ST_L2_1, EV_L1_DEACTIVATE, l2_st14_persistant_da}, 1615 {ST_L2_1, EV_L1_DEACTIVATE, l2_st14_persistent_da},
1616 {ST_L2_2, EV_L1_DEACTIVATE, l2_st24_tei_remove}, 1616 {ST_L2_2, EV_L1_DEACTIVATE, l2_st24_tei_remove},
1617 {ST_L2_3, EV_L1_DEACTIVATE, l2_st3_tei_remove}, 1617 {ST_L2_3, EV_L1_DEACTIVATE, l2_st3_tei_remove},
1618 {ST_L2_4, EV_L1_DEACTIVATE, l2_st14_persistant_da}, 1618 {ST_L2_4, EV_L1_DEACTIVATE, l2_st14_persistent_da},
1619 {ST_L2_5, EV_L1_DEACTIVATE, l2_st5_persistant_da}, 1619 {ST_L2_5, EV_L1_DEACTIVATE, l2_st5_persistent_da},
1620 {ST_L2_6, EV_L1_DEACTIVATE, l2_st6_persistant_da}, 1620 {ST_L2_6, EV_L1_DEACTIVATE, l2_st6_persistent_da},
1621 {ST_L2_7, EV_L1_DEACTIVATE, l2_persistant_da}, 1621 {ST_L2_7, EV_L1_DEACTIVATE, l2_persistent_da},
1622 {ST_L2_8, EV_L1_DEACTIVATE, l2_persistant_da}, 1622 {ST_L2_8, EV_L1_DEACTIVATE, l2_persistent_da},
1623}; 1623};
1624 1624
1625#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode)) 1625#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode))
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index dd0bcbe140bd..8458ff3f351e 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -275,8 +275,7 @@ static void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
275 int i; 275 int i;
276 276
277 for (i=0; i<STREAM_URB_COUNT; i++) 277 for (i=0; i<STREAM_URB_COUNT; i++)
278 if (cinergyt2->stream_urb[i]) 278 usb_free_urb(cinergyt2->stream_urb[i]);
279 usb_free_urb(cinergyt2->stream_urb[i]);
280 279
281 usb_buffer_free(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE, 280 usb_buffer_free(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
282 cinergyt2->streambuf, cinergyt2->streambuf_dmahandle); 281 cinergyt2->streambuf, cinergyt2->streambuf_dmahandle);
@@ -320,8 +319,7 @@ static void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
320 cinergyt2_control_stream_transfer(cinergyt2, 0); 319 cinergyt2_control_stream_transfer(cinergyt2, 0);
321 320
322 for (i=0; i<STREAM_URB_COUNT; i++) 321 for (i=0; i<STREAM_URB_COUNT; i++)
323 if (cinergyt2->stream_urb[i]) 322 usb_kill_urb(cinergyt2->stream_urb[i]);
324 usb_kill_urb(cinergyt2->stream_urb[i]);
325} 323}
326 324
327static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2) 325static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 53304e6991ac..a2ab2eebfc68 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -348,7 +348,7 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra
348 348
349static void dvb_frontend_swzigzag(struct dvb_frontend *fe) 349static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
350{ 350{
351 fe_status_t s; 351 fe_status_t s = 0;
352 struct dvb_frontend_private *fepriv = fe->frontend_priv; 352 struct dvb_frontend_private *fepriv = fe->frontend_priv;
353 353
354 /* if we've got no parameters, just keep idling */ 354 /* if we've got no parameters, just keep idling */
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c
index 7456b0b9976b..4c27a2d90a38 100644
--- a/drivers/media/dvb/frontends/tda10086.c
+++ b/drivers/media/dvb/frontends/tda10086.c
@@ -441,6 +441,10 @@ static int tda10086_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa
441 441
442 dprintk ("%s\n", __FUNCTION__); 442 dprintk ("%s\n", __FUNCTION__);
443 443
444 // check for invalid symbol rate
445 if (fe_params->u.qpsk.symbol_rate < 500000)
446 return -EINVAL;
447
444 // calculate the updated frequency (note: we convert from Hz->kHz) 448 // calculate the updated frequency (note: we convert from Hz->kHz)
445 tmp64 = tda10086_read_byte(state, 0x52); 449 tmp64 = tda10086_read_byte(state, 0x52);
446 tmp64 |= (tda10086_read_byte(state, 0x51) << 8); 450 tmp64 |= (tda10086_read_byte(state, 0x51) << 8);
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index fc1267b8c892..9a155396d6ac 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -500,14 +500,14 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
500 500
501/* New design (By Emard) 501/* New design (By Emard)
502** this rps1 code will copy internal HS event to GPIO3 pin. 502** this rps1 code will copy internal HS event to GPIO3 pin.
503** GPIO3 is in budget-patch hardware connectd to port B VSYNC 503** GPIO3 is in budget-patch hardware connected to port B VSYNC
504 504
505** HS is an internal event of 7146, accessible with RPS 505** HS is an internal event of 7146, accessible with RPS
506** and temporarily raised high every n lines 506** and temporarily raised high every n lines
507** (n in defined in the RPS_THRESH1 counter threshold) 507** (n in defined in the RPS_THRESH1 counter threshold)
508** I think HS is raised high on the beginning of the n-th line 508** I think HS is raised high on the beginning of the n-th line
509** and remains high until this n-th line that triggered 509** and remains high until this n-th line that triggered
510** it is completely received. When the receiption of n-th line 510** it is completely received. When the reception of n-th line
511** ends, HS is lowered. 511** ends, HS is lowered.
512 512
513** To transmit data over DMA, 7146 needs changing state at 513** To transmit data over DMA, 7146 needs changing state at
@@ -541,7 +541,7 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
541** hardware debug note: a working budget card (including budget patch) 541** hardware debug note: a working budget card (including budget patch)
542** with vpeirq() interrupt setup in mode "0x90" (every 64K) will 542** with vpeirq() interrupt setup in mode "0x90" (every 64K) will
543** generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes 543** generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
544** and that means 3*25=75 Hz of interrupt freqency, as seen by 544** and that means 3*25=75 Hz of interrupt frequency, as seen by
545** watch cat /proc/interrupts 545** watch cat /proc/interrupts
546** 546**
547** If this frequency is 3x lower (and data received in the DMA 547** If this frequency is 3x lower (and data received in the DMA
@@ -550,7 +550,7 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
550** this means VSYNC line is not connected in the hardware. 550** this means VSYNC line is not connected in the hardware.
551** (check soldering pcb and pins) 551** (check soldering pcb and pins)
552** The same behaviour of missing VSYNC can be duplicated on budget 552** The same behaviour of missing VSYNC can be duplicated on budget
553** cards, by seting DD1_INIT trigger mode 7 in 3rd nibble. 553** cards, by setting DD1_INIT trigger mode 7 in 3rd nibble.
554*/ 554*/
555 555
556 // Setup RPS1 "program" (p35) 556 // Setup RPS1 "program" (p35)
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index e58f0391e9d1..56f1c80defc6 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -46,6 +46,10 @@
46#include "lnbp21.h" 46#include "lnbp21.h"
47#include "bsru6.h" 47#include "bsru6.h"
48 48
49static int diseqc_method;
50module_param(diseqc_method, int, 0444);
51MODULE_PARM_DESC(diseqc_method, "Select DiSEqC method for subsystem id 13c2:1003, 0: default, 1: more reliable (for newer revisions only)");
52
49static void Set22K (struct budget *budget, int state) 53static void Set22K (struct budget *budget, int state)
50{ 54{
51 struct saa7146_dev *dev=budget->dev; 55 struct saa7146_dev *dev=budget->dev;
@@ -382,6 +386,11 @@ static void frontend_init(struct budget *budget)
382 if (budget->dvb_frontend) { 386 if (budget->dvb_frontend) {
383 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 387 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
384 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 388 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
389 if (budget->dev->pci->subsystem_device == 0x1003 && diseqc_method == 0) {
390 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
391 budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
392 budget->dvb_frontend->ops.set_tone = budget_set_tone;
393 }
385 break; 394 break;
386 } 395 }
387 break; 396 break;
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index a1c9fa9919ea..8135f3e76aeb 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1135,8 +1135,7 @@ static void ttusb_dec_free_iso_urbs(struct ttusb_dec *dec)
1135 dprintk("%s\n", __FUNCTION__); 1135 dprintk("%s\n", __FUNCTION__);
1136 1136
1137 for (i = 0; i < ISO_BUF_COUNT; i++) 1137 for (i = 0; i < ISO_BUF_COUNT; i++)
1138 if (dec->iso_urb[i]) 1138 usb_free_urb(dec->iso_urb[i]);
1139 usb_free_urb(dec->iso_urb[i]);
1140 1139
1141 pci_free_consistent(NULL, 1140 pci_free_consistent(NULL,
1142 ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * 1141 ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF *
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index bf267552941f..b8fde5cf4735 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -24,7 +24,7 @@ config VIDEO_HELPER_CHIPS_AUTO
24 decode audio/video standards. This option will autoselect 24 decode audio/video standards. This option will autoselect
25 all pertinent modules to each selected video module. 25 all pertinent modules to each selected video module.
26 26
27 Unselect this only if you know exaclty what you are doing, since 27 Unselect this only if you know exactly what you are doing, since
28 it may break support on some boards. 28 it may break support on some boards.
29 29
30 In doubt, say Y. 30 In doubt, say Y.
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index f786ab11d2cd..86e353b26b53 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -1182,8 +1182,6 @@ static void et61x251_release_resources(struct et61x251_device* cam)
1182 video_set_drvdata(cam->v4ldev, NULL); 1182 video_set_drvdata(cam->v4ldev, NULL);
1183 video_unregister_device(cam->v4ldev); 1183 video_unregister_device(cam->v4ldev);
1184 1184
1185 usb_put_dev(cam->usbdev);
1186
1187 mutex_unlock(&et61x251_sysfs_lock); 1185 mutex_unlock(&et61x251_sysfs_lock);
1188 1186
1189 kfree(cam->control_buffer); 1187 kfree(cam->control_buffer);
@@ -1275,6 +1273,7 @@ static int et61x251_release(struct inode* inode, struct file* filp)
1275 1273
1276 if (cam->state & DEV_DISCONNECTED) { 1274 if (cam->state & DEV_DISCONNECTED) {
1277 et61x251_release_resources(cam); 1275 et61x251_release_resources(cam);
1276 usb_put_dev(cam->usbdev);
1278 mutex_unlock(&cam->dev_mutex); 1277 mutex_unlock(&cam->dev_mutex);
1279 kfree(cam); 1278 kfree(cam);
1280 return 0; 1279 return 0;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index f920e0ccacd3..1f787333d18c 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -1953,8 +1953,8 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1953 return hdw; 1953 return hdw;
1954 fail: 1954 fail:
1955 if (hdw) { 1955 if (hdw) {
1956 if (hdw->ctl_read_urb) usb_free_urb(hdw->ctl_read_urb); 1956 usb_free_urb(hdw->ctl_read_urb);
1957 if (hdw->ctl_write_urb) usb_free_urb(hdw->ctl_write_urb); 1957 usb_free_urb(hdw->ctl_write_urb);
1958 if (hdw->ctl_read_buffer) kfree(hdw->ctl_read_buffer); 1958 if (hdw->ctl_read_buffer) kfree(hdw->ctl_read_buffer);
1959 if (hdw->ctl_write_buffer) kfree(hdw->ctl_write_buffer); 1959 if (hdw->ctl_write_buffer) kfree(hdw->ctl_write_buffer);
1960 if (hdw->controls) kfree(hdw->controls); 1960 if (hdw->controls) kfree(hdw->controls);
@@ -2575,12 +2575,10 @@ static void pvr2_ctl_timeout(unsigned long data)
2575 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; 2575 struct pvr2_hdw *hdw = (struct pvr2_hdw *)data;
2576 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) { 2576 if (hdw->ctl_write_pend_flag || hdw->ctl_read_pend_flag) {
2577 hdw->ctl_timeout_flag = !0; 2577 hdw->ctl_timeout_flag = !0;
2578 if (hdw->ctl_write_pend_flag && hdw->ctl_write_urb) { 2578 if (hdw->ctl_write_pend_flag)
2579 usb_unlink_urb(hdw->ctl_write_urb); 2579 usb_unlink_urb(hdw->ctl_write_urb);
2580 } 2580 if (hdw->ctl_read_pend_flag)
2581 if (hdw->ctl_read_pend_flag && hdw->ctl_read_urb) {
2582 usb_unlink_urb(hdw->ctl_read_urb); 2581 usb_unlink_urb(hdw->ctl_read_urb);
2583 }
2584 } 2582 }
2585} 2583}
2586 2584
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
index 70aa63eba0cb..57fb32033543 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -289,7 +289,7 @@ static void pvr2_buffer_done(struct pvr2_buffer *bp)
289 pvr2_buffer_set_none(bp); 289 pvr2_buffer_set_none(bp);
290 bp->signature = 0; 290 bp->signature = 0;
291 bp->stream = NULL; 291 bp->stream = NULL;
292 if (bp->purb) usb_free_urb(bp->purb); 292 usb_free_urb(bp->purb);
293 pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/" 293 pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/"
294 " bufferDone %p",bp); 294 " bufferDone %p",bp);
295} 295}
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 46c114830884..a996aad79276 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -866,11 +866,9 @@ int pwc_isoc_init(struct pwc_device *pdev)
866 } 866 }
867 if (ret) { 867 if (ret) {
868 /* De-allocate in reverse order */ 868 /* De-allocate in reverse order */
869 while (i >= 0) { 869 while (i--) {
870 if (pdev->sbuf[i].urb != NULL) 870 usb_free_urb(pdev->sbuf[i].urb);
871 usb_free_urb(pdev->sbuf[i].urb);
872 pdev->sbuf[i].urb = NULL; 871 pdev->sbuf[i].urb = NULL;
873 i--;
874 } 872 }
875 return ret; 873 return ret;
876 } 874 }
@@ -1095,8 +1093,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1095 PWC_DEBUG_OPEN(">> video_open called(vdev = 0x%p).\n", vdev); 1093 PWC_DEBUG_OPEN(">> video_open called(vdev = 0x%p).\n", vdev);
1096 1094
1097 pdev = (struct pwc_device *)vdev->priv; 1095 pdev = (struct pwc_device *)vdev->priv;
1098 if (pdev == NULL) 1096 BUG_ON(!pdev);
1099 BUG();
1100 if (pdev->vopen) { 1097 if (pdev->vopen) {
1101 PWC_DEBUG_OPEN("I'm busy, someone is using the device.\n"); 1098 PWC_DEBUG_OPEN("I'm busy, someone is using the device.\n");
1102 return -EBUSY; 1099 return -EBUSY;
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index 8ba05c214ca7..92eabf88a09b 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -212,8 +212,10 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a)
212 if (rd_blocks > s->block_count) 212 if (rd_blocks > s->block_count)
213 rd_blocks = s->block_count; 213 rd_blocks = s->block_count;
214 214
215 if (!rd_blocks) 215 if (!rd_blocks) {
216 spin_unlock_irqrestore(&s->lock, flags);
216 return; 217 return;
218 }
217 219
218 for (i = 0; i < rd_blocks; i++) { 220 for (i = 0; i < rd_blocks; i++) {
219 if (block_to_user_buf(s, buf_ptr)) { 221 if (block_to_user_buf(s, buf_ptr)) {
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index c5719f7bd1ac..f28398dd9d93 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1464,8 +1464,6 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
1464 client->driver = &i2c_driver_saa711x; 1464 client->driver = &i2c_driver_saa711x;
1465 snprintf(client->name, sizeof(client->name) - 1, "saa7115"); 1465 snprintf(client->name, sizeof(client->name) - 1, "saa7115");
1466 1466
1467 v4l_dbg(1, debug, client, "detecting saa7115 client on address 0x%x\n", address << 1);
1468
1469 for (i=0;i<0x0f;i++) { 1467 for (i=0;i<0x0f;i++) {
1470 saa711x_write(client, 0, i); 1468 saa711x_write(client, 0, i);
1471 name[i] = (saa711x_read(client, 0) &0x0f) +'0'; 1469 name[i] = (saa711x_read(client, 0) &0x0f) +'0';
@@ -1477,6 +1475,13 @@ static int saa711x_attach(struct i2c_adapter *adapter, int address, int kind)
1477 saa711x_write(client, 0, 5); 1475 saa711x_write(client, 0, 5);
1478 chip_id = saa711x_read(client, 0) & 0x0f; 1476 chip_id = saa711x_read(client, 0) & 0x0f;
1479 1477
1478 /* Check whether this chip is part of the saa711x series */
1479 if (memcmp(name, "1f711", 5)) {
1480 v4l_dbg(1, debug, client, "chip found @ 0x%x (ID %s) does not match a known saa711x chip.\n",
1481 address << 1, name);
1482 return 0;
1483 }
1484
1480 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id); 1485 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id);
1481 v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, address << 1, adapter->name); 1486 v4l_info(client, "saa711%d found (%s) @ 0x%x (%s)\n", chip_id, name, address << 1, adapter->name);
1482 1487
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index a4702d3c2aca..18458d46c0ff 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -775,7 +775,7 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
775 return 0; 775 return 0;
776 776
777free_urbs: 777free_urbs:
778 for (i = 0; (i < SN9C102_URBS) && cam->urb[i]; i++) 778 for (i = 0; i < SN9C102_URBS; i++)
779 usb_free_urb(cam->urb[i]); 779 usb_free_urb(cam->urb[i]);
780 780
781free_buffers: 781free_buffers:
@@ -1462,8 +1462,6 @@ static void sn9c102_release_resources(struct sn9c102_device* cam)
1462 video_set_drvdata(cam->v4ldev, NULL); 1462 video_set_drvdata(cam->v4ldev, NULL);
1463 video_unregister_device(cam->v4ldev); 1463 video_unregister_device(cam->v4ldev);
1464 1464
1465 usb_put_dev(cam->usbdev);
1466
1467 mutex_unlock(&sn9c102_sysfs_lock); 1465 mutex_unlock(&sn9c102_sysfs_lock);
1468 1466
1469 kfree(cam->control_buffer); 1467 kfree(cam->control_buffer);
@@ -1555,6 +1553,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp)
1555 1553
1556 if (cam->state & DEV_DISCONNECTED) { 1554 if (cam->state & DEV_DISCONNECTED) {
1557 sn9c102_release_resources(cam); 1555 sn9c102_release_resources(cam);
1556 usb_put_dev(cam->usbdev);
1558 mutex_unlock(&cam->dev_mutex); 1557 mutex_unlock(&cam->dev_mutex);
1559 kfree(cam); 1558 kfree(cam);
1560 return 0; 1559 return 0;
diff --git a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c
index 9a26b9484aae..bbf2beeeb449 100644
--- a/drivers/media/video/usbvideo/quickcam_messenger.c
+++ b/drivers/media/video/usbvideo/quickcam_messenger.c
@@ -190,8 +190,7 @@ static int qcm_alloc_int_urb(struct qcm *cam)
190 190
191static void qcm_free_int(struct qcm *cam) 191static void qcm_free_int(struct qcm *cam)
192{ 192{
193 if (cam->button_urb) 193 usb_free_urb(cam->button_urb);
194 usb_free_urb(cam->button_urb);
195} 194}
196#endif /* CONFIG_INPUT */ 195#endif /* CONFIG_INPUT */
197 196
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index 5b5563424422..52d0f759ee00 100644
--- a/drivers/media/video/zc0301/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -489,7 +489,7 @@ static int zc0301_start_transfer(struct zc0301_device* cam)
489 return 0; 489 return 0;
490 490
491free_urbs: 491free_urbs:
492 for (i = 0; (i < ZC0301_URBS) && cam->urb[i]; i++) 492 for (i = 0; i < ZC0301_URBS; i++)
493 usb_free_urb(cam->urb[i]); 493 usb_free_urb(cam->urb[i]);
494 494
495free_buffers: 495free_buffers:
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index e5c72719debc..051b7c5b8f03 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -6185,7 +6185,7 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6185 "Abort", /* 12h */ 6185 "Abort", /* 12h */
6186 "IO Not Yet Executed", /* 13h */ 6186 "IO Not Yet Executed", /* 13h */
6187 "IO Executed", /* 14h */ 6187 "IO Executed", /* 14h */
6188 "Persistant Reservation Out Not Affiliation Owner", /* 15h */ 6188 "Persistent Reservation Out Not Affiliation Owner", /* 15h */
6189 "Open Transmit DMA Abort", /* 16h */ 6189 "Open Transmit DMA Abort", /* 16h */
6190 "IO Device Missing Delay Retry", /* 17h */ 6190 "IO Device Missing Delay Retry", /* 17h */
6191 NULL, /* 18h */ 6191 NULL, /* 18h */
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 62f1ac08332c..8287f95c8c42 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -320,7 +320,6 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
320 struct i2o_controller *c; 320 struct i2o_controller *c;
321 int rc; 321 int rc;
322 struct pci_dev *i960 = NULL; 322 struct pci_dev *i960 = NULL;
323 int enabled = pdev->is_enabled;
324 323
325 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); 324 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
326 325
@@ -330,12 +329,11 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
330 return -ENODEV; 329 return -ENODEV;
331 } 330 }
332 331
333 if (!enabled) 332 if ((rc = pci_enable_device(pdev))) {
334 if ((rc = pci_enable_device(pdev))) { 333 printk(KERN_WARNING "i2o: couldn't enable device %s\n",
335 printk(KERN_WARNING "i2o: couldn't enable device %s\n", 334 pci_name(pdev));
336 pci_name(pdev)); 335 return rc;
337 return rc; 336 }
338 }
339 337
340 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 338 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
341 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n", 339 printk(KERN_WARNING "i2o: no suitable DMA found for %s\n",
@@ -442,8 +440,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
442 i2o_iop_free(c); 440 i2o_iop_free(c);
443 441
444 disable: 442 disable:
445 if (!enabled) 443 pci_disable_device(pdev);
446 pci_disable_device(pdev);
447 444
448 return rc; 445 return rc;
449} 446}
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index ea41852ec8cd..f4f8ccaf5455 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -40,7 +40,7 @@ config MMC_ARMMMCI
40 If unsure, say N. 40 If unsure, say N.
41 41
42config MMC_PXA 42config MMC_PXA
43 tristate "Intel PXA255 Multimedia Card Interface support" 43 tristate "Intel PXA25x/26x/27x Multimedia Card Interface support"
44 depends on ARCH_PXA && MMC 44 depends on ARCH_PXA && MMC
45 help 45 help
46 This selects the Intel(R) PXA(R) Multimedia card Interface. 46 This selects the Intel(R) PXA(R) Multimedia card Interface.
diff --git a/drivers/mmc/at91_mci.c b/drivers/mmc/at91_mci.c
index 494b23fb0a01..6495cd8a9306 100644
--- a/drivers/mmc/at91_mci.c
+++ b/drivers/mmc/at91_mci.c
@@ -793,7 +793,7 @@ int at91_mci_get_ro(struct mmc_host *mmc)
793 return read_only; 793 return read_only;
794} 794}
795 795
796static struct mmc_host_ops at91_mci_ops = { 796static const struct mmc_host_ops at91_mci_ops = {
797 .request = at91_mci_request, 797 .request = at91_mci_request,
798 .set_ios = at91_mci_set_ios, 798 .set_ios = at91_mci_set_ios,
799 .get_ro = at91_mci_get_ro, 799 .get_ro = at91_mci_get_ro,
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c
index 53ffcbb14a97..447fba5825fd 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/au1xmmc.c
@@ -875,7 +875,7 @@ static void au1xmmc_init_dma(struct au1xmmc_host *host)
875 host->rx_chan = rxchan; 875 host->rx_chan = rxchan;
876} 876}
877 877
878struct mmc_host_ops au1xmmc_ops = { 878struct const mmc_host_ops au1xmmc_ops = {
879 .request = au1xmmc_request, 879 .request = au1xmmc_request,
880 .set_ios = au1xmmc_set_ios, 880 .set_ios = au1xmmc_set_ios,
881}; 881};
diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/imxmmc.c
index 659d4a822cc5..06e7fcd19221 100644
--- a/drivers/mmc/imxmmc.c
+++ b/drivers/mmc/imxmmc.c
@@ -877,7 +877,7 @@ static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
877 } 877 }
878} 878}
879 879
880static struct mmc_host_ops imxmci_ops = { 880static const struct mmc_host_ops imxmci_ops = {
881 .request = imxmci_request, 881 .request = imxmci_request,
882 .set_ios = imxmci_set_ios, 882 .set_ios = imxmci_set_ios,
883}; 883};
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 21fd39e4a20f..6f2a282e2b97 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -4,6 +4,7 @@
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved. 4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved. 5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
6 * SD support Copyright (C) 2005 Pierre Ossman, All Rights Reserved. 6 * SD support Copyright (C) 2005 Pierre Ossman, All Rights Reserved.
7 * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved.
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
@@ -396,23 +397,23 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card)
396 return err; 397 return err;
397 398
398 /* 399 /*
399 * Default bus width is 1 bit. 400 * We can only change the bus width of SD cards when
400 */ 401 * they are selected so we have to put the handling
401 host->ios.bus_width = MMC_BUS_WIDTH_1;
402
403 /*
404 * We can only change the bus width of the selected
405 * card so therefore we have to put the handling
406 * here. 402 * here.
403 *
404 * The card is in 1 bit mode by default so
405 * we only need to change if it supports the
406 * wider version.
407 */ 407 */
408 if (host->caps & MMC_CAP_4_BIT_DATA) { 408 if (mmc_card_sd(card) &&
409 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
410
409 /* 411 /*
410 * The card is in 1 bit mode by default so 412 * Default bus width is 1 bit.
411 * we only need to change if it supports the 413 */
412 * wider version. 414 host->ios.bus_width = MMC_BUS_WIDTH_1;
413 */ 415
414 if (mmc_card_sd(card) && 416 if (host->caps & MMC_CAP_4_BIT_DATA) {
415 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) {
416 struct mmc_command cmd; 417 struct mmc_command cmd;
417 cmd.opcode = SD_APP_SET_BUS_WIDTH; 418 cmd.opcode = SD_APP_SET_BUS_WIDTH;
418 cmd.arg = SD_BUS_WIDTH_4; 419 cmd.arg = SD_BUS_WIDTH_4;
@@ -453,11 +454,11 @@ static void mmc_deselect_cards(struct mmc_host *host)
453 454
454static inline void mmc_delay(unsigned int ms) 455static inline void mmc_delay(unsigned int ms)
455{ 456{
456 if (ms < HZ / 1000) { 457 if (ms < 1000 / HZ) {
457 yield(); 458 cond_resched();
458 mdelay(ms); 459 mdelay(ms);
459 } else { 460 } else {
460 msleep_interruptible (ms); 461 msleep(ms);
461 } 462 }
462} 463}
463 464
@@ -953,6 +954,137 @@ static void mmc_read_csds(struct mmc_host *host)
953 } 954 }
954} 955}
955 956
957static void mmc_process_ext_csds(struct mmc_host *host)
958{
959 int err;
960 struct mmc_card *card;
961
962 struct mmc_request mrq;
963 struct mmc_command cmd;
964 struct mmc_data data;
965
966 struct scatterlist sg;
967
968 /*
969 * As the ext_csd is so large and mostly unused, we don't store the
970 * raw block in mmc_card.
971 */
972 u8 *ext_csd;
973 ext_csd = kmalloc(512, GFP_KERNEL);
974 if (!ext_csd) {
975 printk("%s: could not allocate a buffer to receive the ext_csd."
976 "mmc v4 cards will be treated as v3.\n",
977 mmc_hostname(host));
978 return;
979 }
980
981 list_for_each_entry(card, &host->cards, node) {
982 if (card->state & (MMC_STATE_DEAD|MMC_STATE_PRESENT))
983 continue;
984 if (mmc_card_sd(card))
985 continue;
986 if (card->csd.mmca_vsn < CSD_SPEC_VER_4)
987 continue;
988
989 err = mmc_select_card(host, card);
990 if (err != MMC_ERR_NONE) {
991 mmc_card_set_dead(card);
992 continue;
993 }
994
995 memset(&cmd, 0, sizeof(struct mmc_command));
996
997 cmd.opcode = MMC_SEND_EXT_CSD;
998 cmd.arg = 0;
999 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1000
1001 memset(&data, 0, sizeof(struct mmc_data));
1002
1003 mmc_set_data_timeout(&data, card, 0);
1004
1005 data.blksz = 512;
1006 data.blocks = 1;
1007 data.flags = MMC_DATA_READ;
1008 data.sg = &sg;
1009 data.sg_len = 1;
1010
1011 memset(&mrq, 0, sizeof(struct mmc_request));
1012
1013 mrq.cmd = &cmd;
1014 mrq.data = &data;
1015
1016 sg_init_one(&sg, ext_csd, 512);
1017
1018 mmc_wait_for_req(host, &mrq);
1019
1020 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1021 mmc_card_set_dead(card);
1022 continue;
1023 }
1024
1025 switch (ext_csd[EXT_CSD_CARD_TYPE]) {
1026 case EXT_CSD_CARD_TYPE_52 | EXT_CSD_CARD_TYPE_26:
1027 card->ext_csd.hs_max_dtr = 52000000;
1028 break;
1029 case EXT_CSD_CARD_TYPE_26:
1030 card->ext_csd.hs_max_dtr = 26000000;
1031 break;
1032 default:
1033 /* MMC v4 spec says this cannot happen */
1034 printk("%s: card is mmc v4 but doesn't support "
1035 "any high-speed modes.\n",
1036 mmc_hostname(card->host));
1037 mmc_card_set_bad(card);
1038 continue;
1039 }
1040
1041 /* Activate highspeed support. */
1042 cmd.opcode = MMC_SWITCH;
1043 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1044 (EXT_CSD_HS_TIMING << 16) |
1045 (1 << 8) |
1046 EXT_CSD_CMD_SET_NORMAL;
1047 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1048
1049 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1050 if (err != MMC_ERR_NONE) {
1051 printk("%s: failed to switch card to mmc v4 "
1052 "high-speed mode.\n",
1053 mmc_hostname(card->host));
1054 continue;
1055 }
1056
1057 mmc_card_set_highspeed(card);
1058
1059 /* Check for host support for wide-bus modes. */
1060 if (!(host->caps & MMC_CAP_4_BIT_DATA)) {
1061 continue;
1062 }
1063
1064 /* Activate 4-bit support. */
1065 cmd.opcode = MMC_SWITCH;
1066 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1067 (EXT_CSD_BUS_WIDTH << 16) |
1068 (EXT_CSD_BUS_WIDTH_4 << 8) |
1069 EXT_CSD_CMD_SET_NORMAL;
1070 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1071
1072 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1073 if (err != MMC_ERR_NONE) {
1074 printk("%s: failed to switch card to "
1075 "mmc v4 4-bit bus mode.\n",
1076 mmc_hostname(card->host));
1077 continue;
1078 }
1079
1080 host->ios.bus_width = MMC_BUS_WIDTH_4;
1081 }
1082
1083 kfree(ext_csd);
1084
1085 mmc_deselect_cards(host);
1086}
1087
956static void mmc_read_scrs(struct mmc_host *host) 1088static void mmc_read_scrs(struct mmc_host *host)
957{ 1089{
958 int err; 1090 int err;
@@ -1025,14 +1157,133 @@ static void mmc_read_scrs(struct mmc_host *host)
1025 mmc_deselect_cards(host); 1157 mmc_deselect_cards(host);
1026} 1158}
1027 1159
1160static void mmc_read_switch_caps(struct mmc_host *host)
1161{
1162 int err;
1163 struct mmc_card *card;
1164 struct mmc_request mrq;
1165 struct mmc_command cmd;
1166 struct mmc_data data;
1167 unsigned char *status;
1168 struct scatterlist sg;
1169
1170 status = kmalloc(64, GFP_KERNEL);
1171 if (!status) {
1172 printk(KERN_WARNING "%s: Unable to allocate buffer for "
1173 "reading switch capabilities.\n",
1174 mmc_hostname(host));
1175 return;
1176 }
1177
1178 list_for_each_entry(card, &host->cards, node) {
1179 if (card->state & (MMC_STATE_DEAD|MMC_STATE_PRESENT))
1180 continue;
1181 if (!mmc_card_sd(card))
1182 continue;
1183 if (card->scr.sda_vsn < SCR_SPEC_VER_1)
1184 continue;
1185
1186 err = mmc_select_card(host, card);
1187 if (err != MMC_ERR_NONE) {
1188 mmc_card_set_dead(card);
1189 continue;
1190 }
1191
1192 memset(&cmd, 0, sizeof(struct mmc_command));
1193
1194 cmd.opcode = SD_SWITCH;
1195 cmd.arg = 0x00FFFFF1;
1196 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1197
1198 memset(&data, 0, sizeof(struct mmc_data));
1199
1200 mmc_set_data_timeout(&data, card, 0);
1201
1202 data.blksz = 64;
1203 data.blocks = 1;
1204 data.flags = MMC_DATA_READ;
1205 data.sg = &sg;
1206 data.sg_len = 1;
1207
1208 memset(&mrq, 0, sizeof(struct mmc_request));
1209
1210 mrq.cmd = &cmd;
1211 mrq.data = &data;
1212
1213 sg_init_one(&sg, status, 64);
1214
1215 mmc_wait_for_req(host, &mrq);
1216
1217 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1218 mmc_card_set_dead(card);
1219 continue;
1220 }
1221
1222 if (status[13] & 0x02)
1223 card->sw_caps.hs_max_dtr = 50000000;
1224
1225 memset(&cmd, 0, sizeof(struct mmc_command));
1226
1227 cmd.opcode = SD_SWITCH;
1228 cmd.arg = 0x80FFFFF1;
1229 cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
1230
1231 memset(&data, 0, sizeof(struct mmc_data));
1232
1233 mmc_set_data_timeout(&data, card, 0);
1234
1235 data.blksz = 64;
1236 data.blocks = 1;
1237 data.flags = MMC_DATA_READ;
1238 data.sg = &sg;
1239 data.sg_len = 1;
1240
1241 memset(&mrq, 0, sizeof(struct mmc_request));
1242
1243 mrq.cmd = &cmd;
1244 mrq.data = &data;
1245
1246 sg_init_one(&sg, status, 64);
1247
1248 mmc_wait_for_req(host, &mrq);
1249
1250 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
1251 mmc_card_set_dead(card);
1252 continue;
1253 }
1254
1255 if ((status[16] & 0xF) != 1) {
1256 printk(KERN_WARNING "%s: Problem switching card "
1257 "into high-speed mode!\n",
1258 mmc_hostname(host));
1259 continue;
1260 }
1261
1262 mmc_card_set_highspeed(card);
1263 }
1264
1265 kfree(status);
1266
1267 mmc_deselect_cards(host);
1268}
1269
1028static unsigned int mmc_calculate_clock(struct mmc_host *host) 1270static unsigned int mmc_calculate_clock(struct mmc_host *host)
1029{ 1271{
1030 struct mmc_card *card; 1272 struct mmc_card *card;
1031 unsigned int max_dtr = host->f_max; 1273 unsigned int max_dtr = host->f_max;
1032 1274
1033 list_for_each_entry(card, &host->cards, node) 1275 list_for_each_entry(card, &host->cards, node)
1034 if (!mmc_card_dead(card) && max_dtr > card->csd.max_dtr) 1276 if (!mmc_card_dead(card)) {
1035 max_dtr = card->csd.max_dtr; 1277 if (mmc_card_highspeed(card) && mmc_card_sd(card)) {
1278 if (max_dtr > card->sw_caps.hs_max_dtr)
1279 max_dtr = card->sw_caps.hs_max_dtr;
1280 } else if (mmc_card_highspeed(card) && !mmc_card_sd(card)) {
1281 if (max_dtr > card->ext_csd.hs_max_dtr)
1282 max_dtr = card->ext_csd.hs_max_dtr;
1283 } else if (max_dtr > card->csd.max_dtr) {
1284 max_dtr = card->csd.max_dtr;
1285 }
1286 }
1036 1287
1037 pr_debug("%s: selected %d.%03dMHz transfer rate\n", 1288 pr_debug("%s: selected %d.%03dMHz transfer rate\n",
1038 mmc_hostname(host), 1289 mmc_hostname(host),
@@ -1150,8 +1401,11 @@ static void mmc_setup(struct mmc_host *host)
1150 1401
1151 mmc_read_csds(host); 1402 mmc_read_csds(host);
1152 1403
1153 if (host->mode == MMC_MODE_SD) 1404 if (host->mode == MMC_MODE_SD) {
1154 mmc_read_scrs(host); 1405 mmc_read_scrs(host);
1406 mmc_read_switch_caps(host);
1407 } else
1408 mmc_process_ext_csds(host);
1155} 1409}
1156 1410
1157 1411
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index f9027c8db792..87713572293f 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -83,7 +83,6 @@ static void mmc_blk_put(struct mmc_blk_data *md)
83 md->usage--; 83 md->usage--;
84 if (md->usage == 0) { 84 if (md->usage == 0) {
85 put_disk(md->disk); 85 put_disk(md->disk);
86 mmc_cleanup_queue(&md->queue);
87 kfree(md); 86 kfree(md);
88 } 87 }
89 mutex_unlock(&open_lock); 88 mutex_unlock(&open_lock);
@@ -225,10 +224,10 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
225 struct mmc_blk_data *md = mq->data; 224 struct mmc_blk_data *md = mq->data;
226 struct mmc_card *card = md->queue.card; 225 struct mmc_card *card = md->queue.card;
227 struct mmc_blk_request brq; 226 struct mmc_blk_request brq;
228 int ret; 227 int ret = 1;
229 228
230 if (mmc_card_claim_host(card)) 229 if (mmc_card_claim_host(card))
231 goto cmd_err; 230 goto flush_queue;
232 231
233 do { 232 do {
234 struct mmc_command cmd; 233 struct mmc_command cmd;
@@ -345,8 +344,6 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
345 return 1; 344 return 1;
346 345
347 cmd_err: 346 cmd_err:
348 ret = 1;
349
350 /* 347 /*
351 * If this is an SD card and we're writing, we can first 348 * If this is an SD card and we're writing, we can first
352 * mark the known good sectors as ok. 349 * mark the known good sectors as ok.
@@ -380,6 +377,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
380 377
381 mmc_card_release_host(card); 378 mmc_card_release_host(card);
382 379
380flush_queue:
383 spin_lock_irq(&md->lock); 381 spin_lock_irq(&md->lock);
384 while (ret) { 382 while (ret) {
385 ret = end_that_request_chunk(req, 0, 383 ret = end_that_request_chunk(req, 0,
@@ -553,12 +551,11 @@ static void mmc_blk_remove(struct mmc_card *card)
553 if (md) { 551 if (md) {
554 int devidx; 552 int devidx;
555 553
554 /* Stop new requests from getting into the queue */
556 del_gendisk(md->disk); 555 del_gendisk(md->disk);
557 556
558 /* 557 /* Then flush out any already in there */
559 * I think this is needed. 558 mmc_cleanup_queue(&md->queue);
560 */
561 md->disk->queue = NULL;
562 559
563 devidx = md->disk->first_minor >> MMC_SHIFT; 560 devidx = md->disk->first_minor >> MMC_SHIFT;
564 __clear_bit(devidx, dev_use); 561 __clear_bit(devidx, dev_use);
diff --git a/drivers/mmc/mmc_queue.c b/drivers/mmc/mmc_queue.c
index 4ccdd82b680f..a17423a4ed8f 100644
--- a/drivers/mmc/mmc_queue.c
+++ b/drivers/mmc/mmc_queue.c
@@ -10,13 +10,13 @@
10 */ 10 */
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/blkdev.h> 12#include <linux/blkdev.h>
13#include <linux/kthread.h>
13 14
14#include <linux/mmc/card.h> 15#include <linux/mmc/card.h>
15#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
16#include "mmc_queue.h" 17#include "mmc_queue.h"
17 18
18#define MMC_QUEUE_EXIT (1 << 0) 19#define MMC_QUEUE_SUSPENDED (1 << 0)
19#define MMC_QUEUE_SUSPENDED (1 << 1)
20 20
21/* 21/*
22 * Prepare a MMC request. Essentially, this means passing the 22 * Prepare a MMC request. Essentially, this means passing the
@@ -59,7 +59,6 @@ static int mmc_queue_thread(void *d)
59{ 59{
60 struct mmc_queue *mq = d; 60 struct mmc_queue *mq = d;
61 struct request_queue *q = mq->queue; 61 struct request_queue *q = mq->queue;
62 DECLARE_WAITQUEUE(wait, current);
63 62
64 /* 63 /*
65 * Set iothread to ensure that we aren't put to sleep by 64 * Set iothread to ensure that we aren't put to sleep by
@@ -67,12 +66,7 @@ static int mmc_queue_thread(void *d)
67 */ 66 */
68 current->flags |= PF_MEMALLOC|PF_NOFREEZE; 67 current->flags |= PF_MEMALLOC|PF_NOFREEZE;
69 68
70 daemonize("mmcqd");
71
72 complete(&mq->thread_complete);
73
74 down(&mq->thread_sem); 69 down(&mq->thread_sem);
75 add_wait_queue(&mq->thread_wq, &wait);
76 do { 70 do {
77 struct request *req = NULL; 71 struct request *req = NULL;
78 72
@@ -84,7 +78,7 @@ static int mmc_queue_thread(void *d)
84 spin_unlock_irq(q->queue_lock); 78 spin_unlock_irq(q->queue_lock);
85 79
86 if (!req) { 80 if (!req) {
87 if (mq->flags & MMC_QUEUE_EXIT) 81 if (kthread_should_stop())
88 break; 82 break;
89 up(&mq->thread_sem); 83 up(&mq->thread_sem);
90 schedule(); 84 schedule();
@@ -95,10 +89,8 @@ static int mmc_queue_thread(void *d)
95 89
96 mq->issue_fn(mq, req); 90 mq->issue_fn(mq, req);
97 } while (1); 91 } while (1);
98 remove_wait_queue(&mq->thread_wq, &wait);
99 up(&mq->thread_sem); 92 up(&mq->thread_sem);
100 93
101 complete_and_exit(&mq->thread_complete, 0);
102 return 0; 94 return 0;
103} 95}
104 96
@@ -111,9 +103,22 @@ static int mmc_queue_thread(void *d)
111static void mmc_request(request_queue_t *q) 103static void mmc_request(request_queue_t *q)
112{ 104{
113 struct mmc_queue *mq = q->queuedata; 105 struct mmc_queue *mq = q->queuedata;
106 struct request *req;
107 int ret;
108
109 if (!mq) {
110 printk(KERN_ERR "MMC: killing requests for dead queue\n");
111 while ((req = elv_next_request(q)) != NULL) {
112 do {
113 ret = end_that_request_chunk(req, 0,
114 req->current_nr_sectors << 9);
115 } while (ret);
116 }
117 return;
118 }
114 119
115 if (!mq->req) 120 if (!mq->req)
116 wake_up(&mq->thread_wq); 121 wake_up_process(mq->thread);
117} 122}
118 123
119/** 124/**
@@ -130,8 +135,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
130 u64 limit = BLK_BOUNCE_HIGH; 135 u64 limit = BLK_BOUNCE_HIGH;
131 int ret; 136 int ret;
132 137
133 if (host->dev->dma_mask && *host->dev->dma_mask) 138 if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
134 limit = *host->dev->dma_mask; 139 limit = *mmc_dev(host)->dma_mask;
135 140
136 mq->card = card; 141 mq->card = card;
137 mq->queue = blk_init_queue(mmc_request, lock); 142 mq->queue = blk_init_queue(mmc_request, lock);
@@ -152,36 +157,40 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
152 GFP_KERNEL); 157 GFP_KERNEL);
153 if (!mq->sg) { 158 if (!mq->sg) {
154 ret = -ENOMEM; 159 ret = -ENOMEM;
155 goto cleanup; 160 goto cleanup_queue;
156 } 161 }
157 162
158 init_completion(&mq->thread_complete);
159 init_waitqueue_head(&mq->thread_wq);
160 init_MUTEX(&mq->thread_sem); 163 init_MUTEX(&mq->thread_sem);
161 164
162 ret = kernel_thread(mmc_queue_thread, mq, CLONE_KERNEL); 165 mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd");
163 if (ret >= 0) { 166 if (IS_ERR(mq->thread)) {
164 wait_for_completion(&mq->thread_complete); 167 ret = PTR_ERR(mq->thread);
165 init_completion(&mq->thread_complete); 168 goto free_sg;
166 ret = 0;
167 goto out;
168 } 169 }
169 170
170 cleanup: 171 return 0;
172
173 free_sg:
171 kfree(mq->sg); 174 kfree(mq->sg);
172 mq->sg = NULL; 175 mq->sg = NULL;
173 176 cleanup_queue:
174 blk_cleanup_queue(mq->queue); 177 blk_cleanup_queue(mq->queue);
175 out:
176 return ret; 178 return ret;
177} 179}
178EXPORT_SYMBOL(mmc_init_queue); 180EXPORT_SYMBOL(mmc_init_queue);
179 181
180void mmc_cleanup_queue(struct mmc_queue *mq) 182void mmc_cleanup_queue(struct mmc_queue *mq)
181{ 183{
182 mq->flags |= MMC_QUEUE_EXIT; 184 request_queue_t *q = mq->queue;
183 wake_up(&mq->thread_wq); 185 unsigned long flags;
184 wait_for_completion(&mq->thread_complete); 186
187 /* Mark that we should start throwing out stragglers */
188 spin_lock_irqsave(q->queue_lock, flags);
189 q->queuedata = NULL;
190 spin_unlock_irqrestore(q->queue_lock, flags);
191
192 /* Then terminate our worker thread */
193 kthread_stop(mq->thread);
185 194
186 kfree(mq->sg); 195 kfree(mq->sg);
187 mq->sg = NULL; 196 mq->sg = NULL;
diff --git a/drivers/mmc/mmc_queue.h b/drivers/mmc/mmc_queue.h
index 7182d2f69b4e..c9f139e764f6 100644
--- a/drivers/mmc/mmc_queue.h
+++ b/drivers/mmc/mmc_queue.h
@@ -6,8 +6,7 @@ struct task_struct;
6 6
7struct mmc_queue { 7struct mmc_queue {
8 struct mmc_card *card; 8 struct mmc_card *card;
9 struct completion thread_complete; 9 struct task_struct *thread;
10 wait_queue_head_t thread_wq;
11 struct semaphore thread_sem; 10 struct semaphore thread_sem;
12 unsigned int flags; 11 unsigned int flags;
13 struct request *req; 12 struct request *req;
diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c
index fd9a5fc6db7b..e334acd045bc 100644
--- a/drivers/mmc/mmc_sysfs.c
+++ b/drivers/mmc/mmc_sysfs.c
@@ -199,7 +199,7 @@ void mmc_init_card(struct mmc_card *card, struct mmc_host *host)
199 memset(card, 0, sizeof(struct mmc_card)); 199 memset(card, 0, sizeof(struct mmc_card));
200 card->host = host; 200 card->host = host;
201 device_initialize(&card->dev); 201 device_initialize(&card->dev);
202 card->dev.parent = card->host->dev; 202 card->dev.parent = mmc_dev(host);
203 card->dev.bus = &mmc_bus_type; 203 card->dev.bus = &mmc_bus_type;
204 card->dev.release = mmc_release_card; 204 card->dev.release = mmc_release_card;
205} 205}
@@ -242,7 +242,7 @@ void mmc_remove_card(struct mmc_card *card)
242} 242}
243 243
244 244
245static void mmc_host_classdev_release(struct class_device *dev) 245static void mmc_host_classdev_release(struct device *dev)
246{ 246{
247 struct mmc_host *host = cls_dev_to_mmc_host(dev); 247 struct mmc_host *host = cls_dev_to_mmc_host(dev);
248 kfree(host); 248 kfree(host);
@@ -250,7 +250,7 @@ static void mmc_host_classdev_release(struct class_device *dev)
250 250
251static struct class mmc_host_class = { 251static struct class mmc_host_class = {
252 .name = "mmc_host", 252 .name = "mmc_host",
253 .release = mmc_host_classdev_release, 253 .dev_release = mmc_host_classdev_release,
254}; 254};
255 255
256static DEFINE_IDR(mmc_host_idr); 256static DEFINE_IDR(mmc_host_idr);
@@ -267,10 +267,10 @@ struct mmc_host *mmc_alloc_host_sysfs(int extra, struct device *dev)
267 if (host) { 267 if (host) {
268 memset(host, 0, sizeof(struct mmc_host) + extra); 268 memset(host, 0, sizeof(struct mmc_host) + extra);
269 269
270 host->dev = dev; 270 host->parent = dev;
271 host->class_dev.dev = host->dev; 271 host->class_dev.parent = dev;
272 host->class_dev.class = &mmc_host_class; 272 host->class_dev.class = &mmc_host_class;
273 class_device_initialize(&host->class_dev); 273 device_initialize(&host->class_dev);
274 } 274 }
275 275
276 return host; 276 return host;
@@ -292,10 +292,10 @@ int mmc_add_host_sysfs(struct mmc_host *host)
292 if (err) 292 if (err)
293 return err; 293 return err;
294 294
295 snprintf(host->class_dev.class_id, BUS_ID_SIZE, 295 snprintf(host->class_dev.bus_id, BUS_ID_SIZE,
296 "mmc%d", host->index); 296 "mmc%d", host->index);
297 297
298 return class_device_add(&host->class_dev); 298 return device_add(&host->class_dev);
299} 299}
300 300
301/* 301/*
@@ -303,7 +303,7 @@ int mmc_add_host_sysfs(struct mmc_host *host)
303 */ 303 */
304void mmc_remove_host_sysfs(struct mmc_host *host) 304void mmc_remove_host_sysfs(struct mmc_host *host)
305{ 305{
306 class_device_del(&host->class_dev); 306 device_del(&host->class_dev);
307 307
308 spin_lock(&mmc_host_lock); 308 spin_lock(&mmc_host_lock);
309 idr_remove(&mmc_host_idr, host->index); 309 idr_remove(&mmc_host_idr, host->index);
@@ -315,7 +315,7 @@ void mmc_remove_host_sysfs(struct mmc_host *host)
315 */ 315 */
316void mmc_free_host_sysfs(struct mmc_host *host) 316void mmc_free_host_sysfs(struct mmc_host *host)
317{ 317{
318 class_device_put(&host->class_dev); 318 put_device(&host->class_dev);
319} 319}
320 320
321static struct workqueue_struct *workqueue; 321static struct workqueue_struct *workqueue;
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c
index 828503c4ee62..e9b80e920266 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -443,7 +443,7 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
443 } 443 }
444} 444}
445 445
446static struct mmc_host_ops mmci_ops = { 446static const struct mmc_host_ops mmci_ops = {
447 .request = mmci_request, 447 .request = mmci_request,
448 .set_ios = mmci_set_ios, 448 .set_ios = mmci_set_ios,
449}; 449};
diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c
index 762fa2895891..435d331e772a 100644
--- a/drivers/mmc/omap.c
+++ b/drivers/mmc/omap.c
@@ -38,7 +38,57 @@
38#include <asm/arch/fpga.h> 38#include <asm/arch/fpga.h>
39#include <asm/arch/tps65010.h> 39#include <asm/arch/tps65010.h>
40 40
41#include "omap.h" 41#define OMAP_MMC_REG_CMD 0x00
42#define OMAP_MMC_REG_ARGL 0x04
43#define OMAP_MMC_REG_ARGH 0x08
44#define OMAP_MMC_REG_CON 0x0c
45#define OMAP_MMC_REG_STAT 0x10
46#define OMAP_MMC_REG_IE 0x14
47#define OMAP_MMC_REG_CTO 0x18
48#define OMAP_MMC_REG_DTO 0x1c
49#define OMAP_MMC_REG_DATA 0x20
50#define OMAP_MMC_REG_BLEN 0x24
51#define OMAP_MMC_REG_NBLK 0x28
52#define OMAP_MMC_REG_BUF 0x2c
53#define OMAP_MMC_REG_SDIO 0x34
54#define OMAP_MMC_REG_REV 0x3c
55#define OMAP_MMC_REG_RSP0 0x40
56#define OMAP_MMC_REG_RSP1 0x44
57#define OMAP_MMC_REG_RSP2 0x48
58#define OMAP_MMC_REG_RSP3 0x4c
59#define OMAP_MMC_REG_RSP4 0x50
60#define OMAP_MMC_REG_RSP5 0x54
61#define OMAP_MMC_REG_RSP6 0x58
62#define OMAP_MMC_REG_RSP7 0x5c
63#define OMAP_MMC_REG_IOSR 0x60
64#define OMAP_MMC_REG_SYSC 0x64
65#define OMAP_MMC_REG_SYSS 0x68
66
67#define OMAP_MMC_STAT_CARD_ERR (1 << 14)
68#define OMAP_MMC_STAT_CARD_IRQ (1 << 13)
69#define OMAP_MMC_STAT_OCR_BUSY (1 << 12)
70#define OMAP_MMC_STAT_A_EMPTY (1 << 11)
71#define OMAP_MMC_STAT_A_FULL (1 << 10)
72#define OMAP_MMC_STAT_CMD_CRC (1 << 8)
73#define OMAP_MMC_STAT_CMD_TOUT (1 << 7)
74#define OMAP_MMC_STAT_DATA_CRC (1 << 6)
75#define OMAP_MMC_STAT_DATA_TOUT (1 << 5)
76#define OMAP_MMC_STAT_END_BUSY (1 << 4)
77#define OMAP_MMC_STAT_END_OF_DATA (1 << 3)
78#define OMAP_MMC_STAT_CARD_BUSY (1 << 2)
79#define OMAP_MMC_STAT_END_OF_CMD (1 << 0)
80
81#define OMAP_MMC_READ(host, reg) __raw_readw((host)->virt_base + OMAP_MMC_REG_##reg)
82#define OMAP_MMC_WRITE(host, reg, val) __raw_writew((val), (host)->virt_base + OMAP_MMC_REG_##reg)
83
84/*
85 * Command types
86 */
87#define OMAP_MMC_CMDTYPE_BC 0
88#define OMAP_MMC_CMDTYPE_BCR 1
89#define OMAP_MMC_CMDTYPE_AC 2
90#define OMAP_MMC_CMDTYPE_ADTC 3
91
42 92
43#define DRIVER_NAME "mmci-omap" 93#define DRIVER_NAME "mmci-omap"
44#define RSP_TYPE(x) ((x) & ~(MMC_RSP_BUSY|MMC_RSP_OPCODE)) 94#define RSP_TYPE(x) ((x) & ~(MMC_RSP_BUSY|MMC_RSP_OPCODE))
@@ -60,8 +110,9 @@ struct mmc_omap_host {
60 unsigned char id; /* 16xx chips have 2 MMC blocks */ 110 unsigned char id; /* 16xx chips have 2 MMC blocks */
61 struct clk * iclk; 111 struct clk * iclk;
62 struct clk * fclk; 112 struct clk * fclk;
63 struct resource *res; 113 struct resource *mem_res;
64 void __iomem *base; 114 void __iomem *virt_base;
115 unsigned int phys_base;
65 int irq; 116 int irq;
66 unsigned char bus_mode; 117 unsigned char bus_mode;
67 unsigned char hw_bus_mode; 118 unsigned char hw_bus_mode;
@@ -191,16 +242,16 @@ mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd)
191 242
192 clk_enable(host->fclk); 243 clk_enable(host->fclk);
193 244
194 OMAP_MMC_WRITE(host->base, CTO, 200); 245 OMAP_MMC_WRITE(host, CTO, 200);
195 OMAP_MMC_WRITE(host->base, ARGL, cmd->arg & 0xffff); 246 OMAP_MMC_WRITE(host, ARGL, cmd->arg & 0xffff);
196 OMAP_MMC_WRITE(host->base, ARGH, cmd->arg >> 16); 247 OMAP_MMC_WRITE(host, ARGH, cmd->arg >> 16);
197 OMAP_MMC_WRITE(host->base, IE, 248 OMAP_MMC_WRITE(host, IE,
198 OMAP_MMC_STAT_A_EMPTY | OMAP_MMC_STAT_A_FULL | 249 OMAP_MMC_STAT_A_EMPTY | OMAP_MMC_STAT_A_FULL |
199 OMAP_MMC_STAT_CMD_CRC | OMAP_MMC_STAT_CMD_TOUT | 250 OMAP_MMC_STAT_CMD_CRC | OMAP_MMC_STAT_CMD_TOUT |
200 OMAP_MMC_STAT_DATA_CRC | OMAP_MMC_STAT_DATA_TOUT | 251 OMAP_MMC_STAT_DATA_CRC | OMAP_MMC_STAT_DATA_TOUT |
201 OMAP_MMC_STAT_END_OF_CMD | OMAP_MMC_STAT_CARD_ERR | 252 OMAP_MMC_STAT_END_OF_CMD | OMAP_MMC_STAT_CARD_ERR |
202 OMAP_MMC_STAT_END_OF_DATA); 253 OMAP_MMC_STAT_END_OF_DATA);
203 OMAP_MMC_WRITE(host->base, CMD, cmdreg); 254 OMAP_MMC_WRITE(host, CMD, cmdreg);
204} 255}
205 256
206static void 257static void
@@ -296,22 +347,22 @@ mmc_omap_cmd_done(struct mmc_omap_host *host, struct mmc_command *cmd)
296 if (cmd->flags & MMC_RSP_136) { 347 if (cmd->flags & MMC_RSP_136) {
297 /* response type 2 */ 348 /* response type 2 */
298 cmd->resp[3] = 349 cmd->resp[3] =
299 OMAP_MMC_READ(host->base, RSP0) | 350 OMAP_MMC_READ(host, RSP0) |
300 (OMAP_MMC_READ(host->base, RSP1) << 16); 351 (OMAP_MMC_READ(host, RSP1) << 16);
301 cmd->resp[2] = 352 cmd->resp[2] =
302 OMAP_MMC_READ(host->base, RSP2) | 353 OMAP_MMC_READ(host, RSP2) |
303 (OMAP_MMC_READ(host->base, RSP3) << 16); 354 (OMAP_MMC_READ(host, RSP3) << 16);
304 cmd->resp[1] = 355 cmd->resp[1] =
305 OMAP_MMC_READ(host->base, RSP4) | 356 OMAP_MMC_READ(host, RSP4) |
306 (OMAP_MMC_READ(host->base, RSP5) << 16); 357 (OMAP_MMC_READ(host, RSP5) << 16);
307 cmd->resp[0] = 358 cmd->resp[0] =
308 OMAP_MMC_READ(host->base, RSP6) | 359 OMAP_MMC_READ(host, RSP6) |
309 (OMAP_MMC_READ(host->base, RSP7) << 16); 360 (OMAP_MMC_READ(host, RSP7) << 16);
310 } else { 361 } else {
311 /* response types 1, 1b, 3, 4, 5, 6 */ 362 /* response types 1, 1b, 3, 4, 5, 6 */
312 cmd->resp[0] = 363 cmd->resp[0] =
313 OMAP_MMC_READ(host->base, RSP6) | 364 OMAP_MMC_READ(host, RSP6) |
314 (OMAP_MMC_READ(host->base, RSP7) << 16); 365 (OMAP_MMC_READ(host, RSP7) << 16);
315 } 366 }
316 } 367 }
317 368
@@ -354,9 +405,9 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write)
354 host->data->bytes_xfered += n; 405 host->data->bytes_xfered += n;
355 406
356 if (write) { 407 if (write) {
357 __raw_writesw(host->base + OMAP_MMC_REG_DATA, host->buffer, n); 408 __raw_writesw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
358 } else { 409 } else {
359 __raw_readsw(host->base + OMAP_MMC_REG_DATA, host->buffer, n); 410 __raw_readsw(host->virt_base + OMAP_MMC_REG_DATA, host->buffer, n);
360 } 411 }
361} 412}
362 413
@@ -386,11 +437,11 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
386 int transfer_error; 437 int transfer_error;
387 438
388 if (host->cmd == NULL && host->data == NULL) { 439 if (host->cmd == NULL && host->data == NULL) {
389 status = OMAP_MMC_READ(host->base, STAT); 440 status = OMAP_MMC_READ(host, STAT);
390 dev_info(mmc_dev(host->mmc),"spurious irq 0x%04x\n", status); 441 dev_info(mmc_dev(host->mmc),"spurious irq 0x%04x\n", status);
391 if (status != 0) { 442 if (status != 0) {
392 OMAP_MMC_WRITE(host->base, STAT, status); 443 OMAP_MMC_WRITE(host, STAT, status);
393 OMAP_MMC_WRITE(host->base, IE, 0); 444 OMAP_MMC_WRITE(host, IE, 0);
394 } 445 }
395 return IRQ_HANDLED; 446 return IRQ_HANDLED;
396 } 447 }
@@ -399,8 +450,8 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
399 end_transfer = 0; 450 end_transfer = 0;
400 transfer_error = 0; 451 transfer_error = 0;
401 452
402 while ((status = OMAP_MMC_READ(host->base, STAT)) != 0) { 453 while ((status = OMAP_MMC_READ(host, STAT)) != 0) {
403 OMAP_MMC_WRITE(host->base, STAT, status); 454 OMAP_MMC_WRITE(host, STAT, status);
404#ifdef CONFIG_MMC_DEBUG 455#ifdef CONFIG_MMC_DEBUG
405 dev_dbg(mmc_dev(host->mmc), "MMC IRQ %04x (CMD %d): ", 456 dev_dbg(mmc_dev(host->mmc), "MMC IRQ %04x (CMD %d): ",
406 status, host->cmd != NULL ? host->cmd->opcode : -1); 457 status, host->cmd != NULL ? host->cmd->opcode : -1);
@@ -470,8 +521,8 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
470 521
471 if (status & OMAP_MMC_STAT_CARD_ERR) { 522 if (status & OMAP_MMC_STAT_CARD_ERR) {
472 if (host->cmd && host->cmd->opcode == MMC_STOP_TRANSMISSION) { 523 if (host->cmd && host->cmd->opcode == MMC_STOP_TRANSMISSION) {
473 u32 response = OMAP_MMC_READ(host->base, RSP6) 524 u32 response = OMAP_MMC_READ(host, RSP6)
474 | (OMAP_MMC_READ(host->base, RSP7) << 16); 525 | (OMAP_MMC_READ(host, RSP7) << 16);
475 /* STOP sometimes sets must-ignore bits */ 526 /* STOP sometimes sets must-ignore bits */
476 if (!(response & (R1_CC_ERROR 527 if (!(response & (R1_CC_ERROR
477 | R1_ILLEGAL_COMMAND 528 | R1_ILLEGAL_COMMAND
@@ -530,12 +581,6 @@ static void mmc_omap_switch_timer(unsigned long arg)
530 schedule_work(&host->switch_work); 581 schedule_work(&host->switch_work);
531} 582}
532 583
533/* FIXME: Handle card insertion and removal properly. Maybe use a mask
534 * for MMC state? */
535static void mmc_omap_switch_callback(unsigned long data, u8 mmc_mask)
536{
537}
538
539static void mmc_omap_switch_handler(void *data) 584static void mmc_omap_switch_handler(void *data)
540{ 585{
541 struct mmc_omap_host *host = (struct mmc_omap_host *) data; 586 struct mmc_omap_host *host = (struct mmc_omap_host *) data;
@@ -581,7 +626,7 @@ mmc_omap_prepare_dma(struct mmc_omap_host *host, struct mmc_data *data)
581 int dst_port = 0; 626 int dst_port = 0;
582 int sync_dev = 0; 627 int sync_dev = 0;
583 628
584 data_addr = io_v2p((u32) host->base) + OMAP_MMC_REG_DATA; 629 data_addr = host->phys_base + OMAP_MMC_REG_DATA;
585 frame = data->blksz; 630 frame = data->blksz;
586 count = sg_dma_len(sg); 631 count = sg_dma_len(sg);
587 632
@@ -640,10 +685,9 @@ mmc_omap_prepare_dma(struct mmc_omap_host *host, struct mmc_data *data)
640 } 685 }
641 686
642 /* Max limit for DMA frame count is 0xffff */ 687 /* Max limit for DMA frame count is 0xffff */
643 if (unlikely(count > 0xffff)) 688 BUG_ON(count > 0xffff);
644 BUG();
645 689
646 OMAP_MMC_WRITE(host->base, BUF, buf); 690 OMAP_MMC_WRITE(host, BUF, buf);
647 omap_set_dma_transfer_params(dma_ch, OMAP_DMA_DATA_TYPE_S16, 691 omap_set_dma_transfer_params(dma_ch, OMAP_DMA_DATA_TYPE_S16,
648 frame, count, OMAP_DMA_SYNC_FRAME, 692 frame, count, OMAP_DMA_SYNC_FRAME,
649 sync_dev, 0); 693 sync_dev, 0);
@@ -728,11 +772,11 @@ static inline void set_cmd_timeout(struct mmc_omap_host *host, struct mmc_reques
728{ 772{
729 u16 reg; 773 u16 reg;
730 774
731 reg = OMAP_MMC_READ(host->base, SDIO); 775 reg = OMAP_MMC_READ(host, SDIO);
732 reg &= ~(1 << 5); 776 reg &= ~(1 << 5);
733 OMAP_MMC_WRITE(host->base, SDIO, reg); 777 OMAP_MMC_WRITE(host, SDIO, reg);
734 /* Set maximum timeout */ 778 /* Set maximum timeout */
735 OMAP_MMC_WRITE(host->base, CTO, 0xff); 779 OMAP_MMC_WRITE(host, CTO, 0xff);
736} 780}
737 781
738static inline void set_data_timeout(struct mmc_omap_host *host, struct mmc_request *req) 782static inline void set_data_timeout(struct mmc_omap_host *host, struct mmc_request *req)
@@ -746,14 +790,14 @@ static inline void set_data_timeout(struct mmc_omap_host *host, struct mmc_reque
746 timeout = req->data->timeout_clks + req->data->timeout_ns / 500; 790 timeout = req->data->timeout_clks + req->data->timeout_ns / 500;
747 791
748 /* Check if we need to use timeout multiplier register */ 792 /* Check if we need to use timeout multiplier register */
749 reg = OMAP_MMC_READ(host->base, SDIO); 793 reg = OMAP_MMC_READ(host, SDIO);
750 if (timeout > 0xffff) { 794 if (timeout > 0xffff) {
751 reg |= (1 << 5); 795 reg |= (1 << 5);
752 timeout /= 1024; 796 timeout /= 1024;
753 } else 797 } else
754 reg &= ~(1 << 5); 798 reg &= ~(1 << 5);
755 OMAP_MMC_WRITE(host->base, SDIO, reg); 799 OMAP_MMC_WRITE(host, SDIO, reg);
756 OMAP_MMC_WRITE(host->base, DTO, timeout); 800 OMAP_MMC_WRITE(host, DTO, timeout);
757} 801}
758 802
759static void 803static void
@@ -765,19 +809,18 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
765 809
766 host->data = data; 810 host->data = data;
767 if (data == NULL) { 811 if (data == NULL) {
768 OMAP_MMC_WRITE(host->base, BLEN, 0); 812 OMAP_MMC_WRITE(host, BLEN, 0);
769 OMAP_MMC_WRITE(host->base, NBLK, 0); 813 OMAP_MMC_WRITE(host, NBLK, 0);
770 OMAP_MMC_WRITE(host->base, BUF, 0); 814 OMAP_MMC_WRITE(host, BUF, 0);
771 host->dma_in_use = 0; 815 host->dma_in_use = 0;
772 set_cmd_timeout(host, req); 816 set_cmd_timeout(host, req);
773 return; 817 return;
774 } 818 }
775 819
776
777 block_size = data->blksz; 820 block_size = data->blksz;
778 821
779 OMAP_MMC_WRITE(host->base, NBLK, data->blocks - 1); 822 OMAP_MMC_WRITE(host, NBLK, data->blocks - 1);
780 OMAP_MMC_WRITE(host->base, BLEN, block_size - 1); 823 OMAP_MMC_WRITE(host, BLEN, block_size - 1);
781 set_data_timeout(host, req); 824 set_data_timeout(host, req);
782 825
783 /* cope with calling layer confusion; it issues "single 826 /* cope with calling layer confusion; it issues "single
@@ -819,7 +862,7 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
819 862
820 /* Revert to PIO? */ 863 /* Revert to PIO? */
821 if (!use_dma) { 864 if (!use_dma) {
822 OMAP_MMC_WRITE(host->base, BUF, 0x1f1f); 865 OMAP_MMC_WRITE(host, BUF, 0x1f1f);
823 host->total_bytes_left = data->blocks * block_size; 866 host->total_bytes_left = data->blocks * block_size;
824 host->sg_len = sg_len; 867 host->sg_len = sg_len;
825 mmc_omap_sg_to_buf(host); 868 mmc_omap_sg_to_buf(host);
@@ -845,7 +888,6 @@ static void mmc_omap_request(struct mmc_host *mmc, struct mmc_request *req)
845static void innovator_fpga_socket_power(int on) 888static void innovator_fpga_socket_power(int on)
846{ 889{
847#if defined(CONFIG_MACH_OMAP_INNOVATOR) && defined(CONFIG_ARCH_OMAP15XX) 890#if defined(CONFIG_MACH_OMAP_INNOVATOR) && defined(CONFIG_ARCH_OMAP15XX)
848
849 if (on) { 891 if (on) {
850 fpga_write(fpga_read(OMAP1510_FPGA_POWER) | (1 << 3), 892 fpga_write(fpga_read(OMAP1510_FPGA_POWER) | (1 << 3),
851 OMAP1510_FPGA_POWER); 893 OMAP1510_FPGA_POWER);
@@ -871,8 +913,8 @@ static void mmc_omap_power(struct mmc_omap_host *host, int on)
871 /* GPIO 4 of TPS65010 sends SD_EN signal */ 913 /* GPIO 4 of TPS65010 sends SD_EN signal */
872 tps65010_set_gpio_out_value(GPIO4, HIGH); 914 tps65010_set_gpio_out_value(GPIO4, HIGH);
873 else if (cpu_is_omap24xx()) { 915 else if (cpu_is_omap24xx()) {
874 u16 reg = OMAP_MMC_READ(host->base, CON); 916 u16 reg = OMAP_MMC_READ(host, CON);
875 OMAP_MMC_WRITE(host->base, CON, reg | (1 << 11)); 917 OMAP_MMC_WRITE(host, CON, reg | (1 << 11));
876 } else 918 } else
877 if (host->power_pin >= 0) 919 if (host->power_pin >= 0)
878 omap_set_gpio_dataout(host->power_pin, 1); 920 omap_set_gpio_dataout(host->power_pin, 1);
@@ -884,8 +926,8 @@ static void mmc_omap_power(struct mmc_omap_host *host, int on)
884 else if (machine_is_omap_h3()) 926 else if (machine_is_omap_h3())
885 tps65010_set_gpio_out_value(GPIO4, LOW); 927 tps65010_set_gpio_out_value(GPIO4, LOW);
886 else if (cpu_is_omap24xx()) { 928 else if (cpu_is_omap24xx()) {
887 u16 reg = OMAP_MMC_READ(host->base, CON); 929 u16 reg = OMAP_MMC_READ(host, CON);
888 OMAP_MMC_WRITE(host->base, CON, reg & ~(1 << 11)); 930 OMAP_MMC_WRITE(host, CON, reg & ~(1 << 11));
889 } else 931 } else
890 if (host->power_pin >= 0) 932 if (host->power_pin >= 0)
891 omap_set_gpio_dataout(host->power_pin, 0); 933 omap_set_gpio_dataout(host->power_pin, 0);
@@ -927,7 +969,7 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
927 case MMC_POWER_UP: 969 case MMC_POWER_UP:
928 case MMC_POWER_ON: 970 case MMC_POWER_ON:
929 mmc_omap_power(host, 1); 971 mmc_omap_power(host, 1);
930 dsor |= 1<<11; 972 dsor |= 1 << 11;
931 break; 973 break;
932 } 974 }
933 975
@@ -941,14 +983,14 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
941 * which results in the while loop below getting stuck. 983 * which results in the while loop below getting stuck.
942 * Writing to the CON register twice seems to do the trick. */ 984 * Writing to the CON register twice seems to do the trick. */
943 for (i = 0; i < 2; i++) 985 for (i = 0; i < 2; i++)
944 OMAP_MMC_WRITE(host->base, CON, dsor); 986 OMAP_MMC_WRITE(host, CON, dsor);
945 if (ios->power_mode == MMC_POWER_UP) { 987 if (ios->power_mode == MMC_POWER_UP) {
946 /* Send clock cycles, poll completion */ 988 /* Send clock cycles, poll completion */
947 OMAP_MMC_WRITE(host->base, IE, 0); 989 OMAP_MMC_WRITE(host, IE, 0);
948 OMAP_MMC_WRITE(host->base, STAT, 0xffff); 990 OMAP_MMC_WRITE(host, STAT, 0xffff);
949 OMAP_MMC_WRITE(host->base, CMD, 1<<7); 991 OMAP_MMC_WRITE(host, CMD, 1 << 7);
950 while (0 == (OMAP_MMC_READ(host->base, STAT) & 1)); 992 while ((OMAP_MMC_READ(host, STAT) & 1) == 0);
951 OMAP_MMC_WRITE(host->base, STAT, 1); 993 OMAP_MMC_WRITE(host, STAT, 1);
952 } 994 }
953 clk_disable(host->fclk); 995 clk_disable(host->fclk);
954} 996}
@@ -960,7 +1002,7 @@ static int mmc_omap_get_ro(struct mmc_host *mmc)
960 return host->wp_pin && omap_get_gpio_datain(host->wp_pin); 1002 return host->wp_pin && omap_get_gpio_datain(host->wp_pin);
961} 1003}
962 1004
963static struct mmc_host_ops mmc_omap_ops = { 1005static const struct mmc_host_ops mmc_omap_ops = {
964 .request = mmc_omap_request, 1006 .request = mmc_omap_request,
965 .set_ios = mmc_omap_set_ios, 1007 .set_ios = mmc_omap_set_ios,
966 .get_ro = mmc_omap_get_ro, 1008 .get_ro = mmc_omap_get_ro,
@@ -971,25 +1013,29 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
971 struct omap_mmc_conf *minfo = pdev->dev.platform_data; 1013 struct omap_mmc_conf *minfo = pdev->dev.platform_data;
972 struct mmc_host *mmc; 1014 struct mmc_host *mmc;
973 struct mmc_omap_host *host = NULL; 1015 struct mmc_omap_host *host = NULL;
974 struct resource *r; 1016 struct resource *res;
975 int ret = 0; 1017 int ret = 0;
976 int irq; 1018 int irq;
977 1019
978 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1020 if (minfo == NULL) {
1021 dev_err(&pdev->dev, "platform data missing\n");
1022 return -ENXIO;
1023 }
1024
1025 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
979 irq = platform_get_irq(pdev, 0); 1026 irq = platform_get_irq(pdev, 0);
980 if (!r || irq < 0) 1027 if (res == NULL || irq < 0)
981 return -ENXIO; 1028 return -ENXIO;
982 1029
983 r = request_mem_region(pdev->resource[0].start, 1030 res = request_mem_region(res->start, res->end - res->start + 1,
984 pdev->resource[0].end - pdev->resource[0].start + 1, 1031 pdev->name);
985 pdev->name); 1032 if (res == NULL)
986 if (!r)
987 return -EBUSY; 1033 return -EBUSY;
988 1034
989 mmc = mmc_alloc_host(sizeof(struct mmc_omap_host), &pdev->dev); 1035 mmc = mmc_alloc_host(sizeof(struct mmc_omap_host), &pdev->dev);
990 if (!mmc) { 1036 if (mmc == NULL) {
991 ret = -ENOMEM; 1037 ret = -ENOMEM;
992 goto out; 1038 goto err_free_mem_region;
993 } 1039 }
994 1040
995 host = mmc_priv(mmc); 1041 host = mmc_priv(mmc);
@@ -1001,13 +1047,13 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1001 host->dma_timer.data = (unsigned long) host; 1047 host->dma_timer.data = (unsigned long) host;
1002 1048
1003 host->id = pdev->id; 1049 host->id = pdev->id;
1004 host->res = r; 1050 host->mem_res = res;
1005 host->irq = irq; 1051 host->irq = irq;
1006 1052
1007 if (cpu_is_omap24xx()) { 1053 if (cpu_is_omap24xx()) {
1008 host->iclk = clk_get(&pdev->dev, "mmc_ick"); 1054 host->iclk = clk_get(&pdev->dev, "mmc_ick");
1009 if (IS_ERR(host->iclk)) 1055 if (IS_ERR(host->iclk))
1010 goto out; 1056 goto err_free_mmc_host;
1011 clk_enable(host->iclk); 1057 clk_enable(host->iclk);
1012 } 1058 }
1013 1059
@@ -1018,7 +1064,7 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1018 1064
1019 if (IS_ERR(host->fclk)) { 1065 if (IS_ERR(host->fclk)) {
1020 ret = PTR_ERR(host->fclk); 1066 ret = PTR_ERR(host->fclk);
1021 goto out; 1067 goto err_free_iclk;
1022 } 1068 }
1023 1069
1024 /* REVISIT: 1070 /* REVISIT:
@@ -1031,14 +1077,15 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1031 host->use_dma = 1; 1077 host->use_dma = 1;
1032 host->dma_ch = -1; 1078 host->dma_ch = -1;
1033 1079
1034 host->irq = pdev->resource[1].start; 1080 host->irq = irq;
1035 host->base = (void __iomem*)IO_ADDRESS(r->start); 1081 host->phys_base = host->mem_res->start;
1082 host->virt_base = (void __iomem *) IO_ADDRESS(host->phys_base);
1036 1083
1037 mmc->ops = &mmc_omap_ops; 1084 mmc->ops = &mmc_omap_ops;
1038 mmc->f_min = 400000; 1085 mmc->f_min = 400000;
1039 mmc->f_max = 24000000; 1086 mmc->f_max = 24000000;
1040 mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34; 1087 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1041 mmc->caps = MMC_CAP_BYTEBLOCK; 1088 mmc->caps = MMC_CAP_MULTIWRITE | MMC_CAP_BYTEBLOCK;
1042 1089
1043 if (minfo->wire4) 1090 if (minfo->wire4)
1044 mmc->caps |= MMC_CAP_4_BIT_DATA; 1091 mmc->caps |= MMC_CAP_4_BIT_DATA;
@@ -1056,20 +1103,18 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1056 if ((ret = omap_request_gpio(host->power_pin)) != 0) { 1103 if ((ret = omap_request_gpio(host->power_pin)) != 0) {
1057 dev_err(mmc_dev(host->mmc), 1104 dev_err(mmc_dev(host->mmc),
1058 "Unable to get GPIO pin for MMC power\n"); 1105 "Unable to get GPIO pin for MMC power\n");
1059 goto out; 1106 goto err_free_fclk;
1060 } 1107 }
1061 omap_set_gpio_direction(host->power_pin, 0); 1108 omap_set_gpio_direction(host->power_pin, 0);
1062 } 1109 }
1063 1110
1064 ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host); 1111 ret = request_irq(host->irq, mmc_omap_irq, 0, DRIVER_NAME, host);
1065 if (ret) 1112 if (ret)
1066 goto out; 1113 goto err_free_power_gpio;
1067 1114
1068 host->dev = &pdev->dev; 1115 host->dev = &pdev->dev;
1069 platform_set_drvdata(pdev, host); 1116 platform_set_drvdata(pdev, host);
1070 1117
1071 mmc_add_host(mmc);
1072
1073 if (host->switch_pin >= 0) { 1118 if (host->switch_pin >= 0) {
1074 INIT_WORK(&host->switch_work, mmc_omap_switch_handler, host); 1119 INIT_WORK(&host->switch_work, mmc_omap_switch_handler, host);
1075 init_timer(&host->switch_timer); 1120 init_timer(&host->switch_timer);
@@ -1107,10 +1152,11 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
1107 schedule_work(&host->switch_work); 1152 schedule_work(&host->switch_work);
1108 } 1153 }
1109 1154
1110no_switch: 1155 mmc_add_host(mmc);
1156
1111 return 0; 1157 return 0;
1112 1158
1113out: 1159no_switch:
1114 /* FIXME: Free other resources too. */ 1160 /* FIXME: Free other resources too. */
1115 if (host) { 1161 if (host) {
1116 if (host->iclk && !IS_ERR(host->iclk)) 1162 if (host->iclk && !IS_ERR(host->iclk))
@@ -1119,6 +1165,20 @@ out:
1119 clk_put(host->fclk); 1165 clk_put(host->fclk);
1120 mmc_free_host(host->mmc); 1166 mmc_free_host(host->mmc);
1121 } 1167 }
1168err_free_power_gpio:
1169 if (host->power_pin >= 0)
1170 omap_free_gpio(host->power_pin);
1171err_free_fclk:
1172 clk_put(host->fclk);
1173err_free_iclk:
1174 if (host->iclk != NULL) {
1175 clk_disable(host->iclk);
1176 clk_put(host->iclk);
1177 }
1178err_free_mmc_host:
1179 mmc_free_host(host->mmc);
1180err_free_mem_region:
1181 release_mem_region(res->start, res->end - res->start + 1);
1122 return ret; 1182 return ret;
1123} 1183}
1124 1184
@@ -1128,30 +1188,31 @@ static int mmc_omap_remove(struct platform_device *pdev)
1128 1188
1129 platform_set_drvdata(pdev, NULL); 1189 platform_set_drvdata(pdev, NULL);
1130 1190
1131 if (host) { 1191 BUG_ON(host == NULL);
1132 mmc_remove_host(host->mmc); 1192
1133 free_irq(host->irq, host); 1193 mmc_remove_host(host->mmc);
1134 1194 free_irq(host->irq, host);
1135 if (host->power_pin >= 0) 1195
1136 omap_free_gpio(host->power_pin); 1196 if (host->power_pin >= 0)
1137 if (host->switch_pin >= 0) { 1197 omap_free_gpio(host->power_pin);
1138 device_remove_file(&pdev->dev, &dev_attr_enable_poll); 1198 if (host->switch_pin >= 0) {
1139 device_remove_file(&pdev->dev, &dev_attr_cover_switch); 1199 device_remove_file(&pdev->dev, &dev_attr_enable_poll);
1140 free_irq(OMAP_GPIO_IRQ(host->switch_pin), host); 1200 device_remove_file(&pdev->dev, &dev_attr_cover_switch);
1141 omap_free_gpio(host->switch_pin); 1201 free_irq(OMAP_GPIO_IRQ(host->switch_pin), host);
1142 host->switch_pin = -1; 1202 omap_free_gpio(host->switch_pin);
1143 del_timer_sync(&host->switch_timer); 1203 host->switch_pin = -1;
1144 flush_scheduled_work(); 1204 del_timer_sync(&host->switch_timer);
1145 } 1205 flush_scheduled_work();
1146 if (host->iclk && !IS_ERR(host->iclk))
1147 clk_put(host->iclk);
1148 if (host->fclk && !IS_ERR(host->fclk))
1149 clk_put(host->fclk);
1150 mmc_free_host(host->mmc);
1151 } 1206 }
1207 if (host->iclk && !IS_ERR(host->iclk))
1208 clk_put(host->iclk);
1209 if (host->fclk && !IS_ERR(host->fclk))
1210 clk_put(host->fclk);
1152 1211
1153 release_mem_region(pdev->resource[0].start, 1212 release_mem_region(pdev->resource[0].start,
1154 pdev->resource[0].end - pdev->resource[0].start + 1); 1213 pdev->resource[0].end - pdev->resource[0].start + 1);
1214
1215 mmc_free_host(host->mmc);
1155 1216
1156 return 0; 1217 return 0;
1157} 1218}
diff --git a/drivers/mmc/omap.h b/drivers/mmc/omap.h
deleted file mode 100644
index c954d355a5e3..000000000000
--- a/drivers/mmc/omap.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef DRIVERS_MEDIA_MMC_OMAP_H
2#define DRIVERS_MEDIA_MMC_OMAP_H
3
4#define OMAP_MMC_REG_CMD 0x00
5#define OMAP_MMC_REG_ARGL 0x04
6#define OMAP_MMC_REG_ARGH 0x08
7#define OMAP_MMC_REG_CON 0x0c
8#define OMAP_MMC_REG_STAT 0x10
9#define OMAP_MMC_REG_IE 0x14
10#define OMAP_MMC_REG_CTO 0x18
11#define OMAP_MMC_REG_DTO 0x1c
12#define OMAP_MMC_REG_DATA 0x20
13#define OMAP_MMC_REG_BLEN 0x24
14#define OMAP_MMC_REG_NBLK 0x28
15#define OMAP_MMC_REG_BUF 0x2c
16#define OMAP_MMC_REG_SDIO 0x34
17#define OMAP_MMC_REG_REV 0x3c
18#define OMAP_MMC_REG_RSP0 0x40
19#define OMAP_MMC_REG_RSP1 0x44
20#define OMAP_MMC_REG_RSP2 0x48
21#define OMAP_MMC_REG_RSP3 0x4c
22#define OMAP_MMC_REG_RSP4 0x50
23#define OMAP_MMC_REG_RSP5 0x54
24#define OMAP_MMC_REG_RSP6 0x58
25#define OMAP_MMC_REG_RSP7 0x5c
26#define OMAP_MMC_REG_IOSR 0x60
27#define OMAP_MMC_REG_SYSC 0x64
28#define OMAP_MMC_REG_SYSS 0x68
29
30#define OMAP_MMC_STAT_CARD_ERR (1 << 14)
31#define OMAP_MMC_STAT_CARD_IRQ (1 << 13)
32#define OMAP_MMC_STAT_OCR_BUSY (1 << 12)
33#define OMAP_MMC_STAT_A_EMPTY (1 << 11)
34#define OMAP_MMC_STAT_A_FULL (1 << 10)
35#define OMAP_MMC_STAT_CMD_CRC (1 << 8)
36#define OMAP_MMC_STAT_CMD_TOUT (1 << 7)
37#define OMAP_MMC_STAT_DATA_CRC (1 << 6)
38#define OMAP_MMC_STAT_DATA_TOUT (1 << 5)
39#define OMAP_MMC_STAT_END_BUSY (1 << 4)
40#define OMAP_MMC_STAT_END_OF_DATA (1 << 3)
41#define OMAP_MMC_STAT_CARD_BUSY (1 << 2)
42#define OMAP_MMC_STAT_END_OF_CMD (1 << 0)
43
44#define OMAP_MMC_READ(base, reg) __raw_readw((base) + OMAP_MMC_REG_##reg)
45#define OMAP_MMC_WRITE(base, reg, val) __raw_writew((val), (base) + OMAP_MMC_REG_##reg)
46
47/*
48 * Command types
49 */
50#define OMAP_MMC_CMDTYPE_BC 0
51#define OMAP_MMC_CMDTYPE_BCR 1
52#define OMAP_MMC_CMDTYPE_AC 2
53#define OMAP_MMC_CMDTYPE_ADTC 3
54
55#endif
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
index a526698b8c91..471e9f4e0530 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -393,7 +393,7 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
393 host->clkrt, host->cmdat); 393 host->clkrt, host->cmdat);
394} 394}
395 395
396static struct mmc_host_ops pxamci_ops = { 396static const struct mmc_host_ops pxamci_ops = {
397 .request = pxamci_request, 397 .request = pxamci_request,
398 .get_ro = pxamci_get_ro, 398 .get_ro = pxamci_get_ro,
399 .set_ios = pxamci_set_ios, 399 .set_ios = pxamci_set_ios,
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 9a7d39b7cdbf..cd98117632d3 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -616,6 +616,7 @@ static void sdhci_finish_command(struct sdhci_host *host)
616static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) 616static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
617{ 617{
618 int div; 618 int div;
619 u8 ctrl;
619 u16 clk; 620 u16 clk;
620 unsigned long timeout; 621 unsigned long timeout;
621 622
@@ -624,6 +625,13 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
624 625
625 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL); 626 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
626 627
628 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
629 if (clock > 25000000)
630 ctrl |= SDHCI_CTRL_HISPD;
631 else
632 ctrl &= ~SDHCI_CTRL_HISPD;
633 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
634
627 if (clock == 0) 635 if (clock == 0)
628 goto out; 636 goto out;
629 637
@@ -784,7 +792,7 @@ static int sdhci_get_ro(struct mmc_host *mmc)
784 return !(present & SDHCI_WRITE_PROTECT); 792 return !(present & SDHCI_WRITE_PROTECT);
785} 793}
786 794
787static struct mmc_host_ops sdhci_ops = { 795static const struct mmc_host_ops sdhci_ops = {
788 .request = sdhci_request, 796 .request = sdhci_request,
789 .set_ios = sdhci_set_ios, 797 .set_ios = sdhci_set_ios,
790 .get_ro = sdhci_get_ro, 798 .get_ro = sdhci_get_ro,
@@ -1291,6 +1299,13 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1291 else if (caps & SDHCI_CAN_VDD_180) 1299 else if (caps & SDHCI_CAN_VDD_180)
1292 mmc->ocr_avail |= MMC_VDD_17_18|MMC_VDD_18_19; 1300 mmc->ocr_avail |= MMC_VDD_17_18|MMC_VDD_18_19;
1293 1301
1302 if ((host->max_clk > 25000000) && !(caps & SDHCI_CAN_DO_HISPD)) {
1303 printk(KERN_ERR "%s: Controller reports > 25 MHz base clock,"
1304 " but no high speed support.\n",
1305 host->slot_descr);
1306 mmc->f_max = 25000000;
1307 }
1308
1294 if (mmc->ocr_avail == 0) { 1309 if (mmc->ocr_avail == 0) {
1295 printk(KERN_ERR "%s: Hardware doesn't report any " 1310 printk(KERN_ERR "%s: Hardware doesn't report any "
1296 "support voltages.\n", host->slot_descr); 1311 "support voltages.\n", host->slot_descr);
diff --git a/drivers/mmc/sdhci.h b/drivers/mmc/sdhci.h
index 72a67937afe0..f9d1a0a6f03a 100644
--- a/drivers/mmc/sdhci.h
+++ b/drivers/mmc/sdhci.h
@@ -71,6 +71,7 @@
71#define SDHCI_HOST_CONTROL 0x28 71#define SDHCI_HOST_CONTROL 0x28
72#define SDHCI_CTRL_LED 0x01 72#define SDHCI_CTRL_LED 0x01
73#define SDHCI_CTRL_4BITBUS 0x02 73#define SDHCI_CTRL_4BITBUS 0x02
74#define SDHCI_CTRL_HISPD 0x04
74 75
75#define SDHCI_POWER_CONTROL 0x29 76#define SDHCI_POWER_CONTROL 0x29
76#define SDHCI_POWER_ON 0x01 77#define SDHCI_POWER_ON 0x01
@@ -138,6 +139,7 @@
138#define SDHCI_CLOCK_BASE_SHIFT 8 139#define SDHCI_CLOCK_BASE_SHIFT 8
139#define SDHCI_MAX_BLOCK_MASK 0x00030000 140#define SDHCI_MAX_BLOCK_MASK 0x00030000
140#define SDHCI_MAX_BLOCK_SHIFT 16 141#define SDHCI_MAX_BLOCK_SHIFT 16
142#define SDHCI_CAN_DO_HISPD 0x00200000
141#define SDHCI_CAN_DO_DMA 0x00400000 143#define SDHCI_CAN_DO_DMA 0x00400000
142#define SDHCI_CAN_VDD_330 0x01000000 144#define SDHCI_CAN_VDD_330 0x01000000
143#define SDHCI_CAN_VDD_300 0x02000000 145#define SDHCI_CAN_VDD_300 0x02000000
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index ced309b37a8f..7a282672f8e9 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -1021,7 +1021,7 @@ static int wbsd_get_ro(struct mmc_host *mmc)
1021 return csr & WBSD_WRPT; 1021 return csr & WBSD_WRPT;
1022} 1022}
1023 1023
1024static struct mmc_host_ops wbsd_ops = { 1024static const struct mmc_host_ops wbsd_ops = {
1025 .request = wbsd_request, 1025 .request = wbsd_request,
1026 .set_ios = wbsd_set_ios, 1026 .set_ios = wbsd_set_ios,
1027 .get_ro = wbsd_get_ro, 1027 .get_ro = wbsd_get_ro,
@@ -1488,7 +1488,7 @@ static void __devinit wbsd_request_dma(struct wbsd_host *host, int dma)
1488 /* 1488 /*
1489 * Translate the address to a physical address. 1489 * Translate the address to a physical address.
1490 */ 1490 */
1491 host->dma_addr = dma_map_single(host->mmc->dev, host->dma_buffer, 1491 host->dma_addr = dma_map_single(mmc_dev(host->mmc), host->dma_buffer,
1492 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); 1492 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1493 1493
1494 /* 1494 /*
@@ -1512,7 +1512,7 @@ kfree:
1512 */ 1512 */
1513 BUG_ON(1); 1513 BUG_ON(1);
1514 1514
1515 dma_unmap_single(host->mmc->dev, host->dma_addr, 1515 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1516 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); 1516 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1517 host->dma_addr = (dma_addr_t)NULL; 1517 host->dma_addr = (dma_addr_t)NULL;
1518 1518
@@ -1530,7 +1530,7 @@ err:
1530static void __devexit wbsd_release_dma(struct wbsd_host *host) 1530static void __devexit wbsd_release_dma(struct wbsd_host *host)
1531{ 1531{
1532 if (host->dma_addr) { 1532 if (host->dma_addr) {
1533 dma_unmap_single(host->mmc->dev, host->dma_addr, 1533 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1534 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL); 1534 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1535 } 1535 }
1536 kfree(host->dma_buffer); 1536 kfree(host->dma_buffer);
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 7ea49a0d5ec3..296159ec5189 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -1087,7 +1087,7 @@ static int inval_cache_and_wait_for_operation(
1087 } 1087 }
1088 spin_lock(chip->mutex); 1088 spin_lock(chip->mutex);
1089 1089
1090 if (chip->state != chip_state) { 1090 while (chip->state != chip_state) {
1091 /* Someone's suspended the operation: sleep */ 1091 /* Someone's suspended the operation: sleep */
1092 DECLARE_WAITQUEUE(wait, current); 1092 DECLARE_WAITQUEUE(wait, current);
1093 set_current_state(TASK_UNINTERRUPTIBLE); 1093 set_current_state(TASK_UNINTERRUPTIBLE);
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 24747bdc3e19..d132ed571f13 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -607,7 +607,7 @@ config MTD_BAST_MAXSIZE
607 default "4" 607 default "4"
608 608
609config MTD_SHARP_SL 609config MTD_SHARP_SL
610 bool "ROM maped on Sharp SL Series" 610 bool "ROM mapped on Sharp SL Series"
611 depends on MTD && ARCH_PXA 611 depends on MTD && ARCH_PXA
612 help 612 help
613 This enables access to the flash chip on the Sharp SL Series of PDAs. 613 This enables access to the flash chip on the Sharp SL Series of PDAs.
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c
index 92b5d883d7b0..65e5ee552010 100644
--- a/drivers/mtd/maps/cfi_flagadm.c
+++ b/drivers/mtd/maps/cfi_flagadm.c
@@ -80,7 +80,7 @@ struct mtd_partition flagadm_parts[] = {
80 .size = FLASH_PARTITION2_SIZE 80 .size = FLASH_PARTITION2_SIZE
81 }, 81 },
82 { 82 {
83 .name = "Persistant storage", 83 .name = "Persistent storage",
84 .offset = FLASH_PARTITION3_ADDR, 84 .offset = FLASH_PARTITION3_ADDR,
85 .size = FLASH_PARTITION3_SIZE 85 .size = FLASH_PARTITION3_SIZE
86 } 86 }
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index 3d1c599ac3cb..a82807641dcf 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -1,1104 +1,40 @@
1/* 8390.c: A general NS8390 ethernet driver core for linux. */ 1/* 8390 core for usual drivers */
2/*
3 Written 1992-94 by Donald Becker.
4
5 Copyright 1993 United States Government as represented by the
6 Director, National Security Agency.
7
8 This software may be used and distributed according to the terms
9 of the GNU General Public License, incorporated herein by reference.
10
11 The author may be reached as becker@scyld.com, or C/O
12 Scyld Computing Corporation
13 410 Severn Ave., Suite 210
14 Annapolis MD 21403
15
16
17 This is the chip-specific code for many 8390-based ethernet adaptors.
18 This is not a complete driver, it must be combined with board-specific
19 code such as ne.c, wd.c, 3c503.c, etc.
20
21 Seeing how at least eight drivers use this code, (not counting the
22 PCMCIA ones either) it is easy to break some card by what seems like
23 a simple innocent change. Please contact me or Donald if you think
24 you have found something that needs changing. -- PG
25
26
27 Changelog:
28
29 Paul Gortmaker : remove set_bit lock, other cleanups.
30 Paul Gortmaker : add ei_get_8390_hdr() so we can pass skb's to
31 ei_block_input() for eth_io_copy_and_sum().
32 Paul Gortmaker : exchange static int ei_pingpong for a #define,
33 also add better Tx error handling.
34 Paul Gortmaker : rewrite Rx overrun handling as per NS specs.
35 Alexey Kuznetsov : use the 8390's six bit hash multicast filter.
36 Paul Gortmaker : tweak ANK's above multicast changes a bit.
37 Paul Gortmaker : update packet statistics for v2.1.x
38 Alan Cox : support arbitary stupid port mappings on the
39 68K Macintosh. Support >16bit I/O spaces
40 Paul Gortmaker : add kmod support for auto-loading of the 8390
41 module by all drivers that require it.
42 Alan Cox : Spinlocking work, added 'BUG_83C690'
43 Paul Gortmaker : Separate out Tx timeout code from Tx path.
44 Paul Gortmaker : Remove old unused single Tx buffer code.
45 Hayato Fujiwara : Add m32r support.
46 Paul Gortmaker : use skb_padto() instead of stack scratch area
47
48 Sources:
49 The National Semiconductor LAN Databook, and the 3Com 3c503 databook.
50
51 */
52 2
53static const char version[] = 3static const char version[] =
54 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; 4 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
55 5
56#include <linux/module.h> 6#include "lib8390.c"
57#include <linux/kernel.h>
58#include <linux/jiffies.h>
59#include <linux/fs.h>
60#include <linux/types.h>
61#include <linux/string.h>
62#include <linux/bitops.h>
63#include <asm/system.h>
64#include <asm/uaccess.h>
65#include <asm/io.h>
66#include <asm/irq.h>
67#include <linux/delay.h>
68#include <linux/errno.h>
69#include <linux/fcntl.h>
70#include <linux/in.h>
71#include <linux/interrupt.h>
72#include <linux/init.h>
73#include <linux/crc32.h>
74
75#include <linux/netdevice.h>
76#include <linux/etherdevice.h>
77
78#define NS8390_CORE
79#include "8390.h"
80
81#define BUG_83C690
82
83/* These are the operational function interfaces to board-specific
84 routines.
85 void reset_8390(struct net_device *dev)
86 Resets the board associated with DEV, including a hardware reset of
87 the 8390. This is only called when there is a transmit timeout, and
88 it is always followed by 8390_init().
89 void block_output(struct net_device *dev, int count, const unsigned char *buf,
90 int start_page)
91 Write the COUNT bytes of BUF to the packet buffer at START_PAGE. The
92 "page" value uses the 8390's 256-byte pages.
93 void get_8390_hdr(struct net_device *dev, struct e8390_hdr *hdr, int ring_page)
94 Read the 4 byte, page aligned 8390 header. *If* there is a
95 subsequent read, it will be of the rest of the packet.
96 void block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
97 Read COUNT bytes from the packet buffer into the skb data area. Start
98 reading from RING_OFFSET, the address as the 8390 sees it. This will always
99 follow the read of the 8390 header.
100*/
101#define ei_reset_8390 (ei_local->reset_8390)
102#define ei_block_output (ei_local->block_output)
103#define ei_block_input (ei_local->block_input)
104#define ei_get_8390_hdr (ei_local->get_8390_hdr)
105
106/* use 0 for production, 1 for verification, >2 for debug */
107#ifndef ei_debug
108int ei_debug = 1;
109#endif
110
111/* Index to functions. */
112static void ei_tx_intr(struct net_device *dev);
113static void ei_tx_err(struct net_device *dev);
114static void ei_tx_timeout(struct net_device *dev);
115static void ei_receive(struct net_device *dev);
116static void ei_rx_overrun(struct net_device *dev);
117
118/* Routines generic to NS8390-based boards. */
119static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
120 int start_page);
121static void set_multicast_list(struct net_device *dev);
122static void do_set_multicast_list(struct net_device *dev);
123
124/*
125 * SMP and the 8390 setup.
126 *
127 * The 8390 isnt exactly designed to be multithreaded on RX/TX. There is
128 * a page register that controls bank and packet buffer access. We guard
129 * this with ei_local->page_lock. Nobody should assume or set the page other
130 * than zero when the lock is not held. Lock holders must restore page 0
131 * before unlocking. Even pure readers must take the lock to protect in
132 * page 0.
133 *
134 * To make life difficult the chip can also be very slow. We therefore can't
135 * just use spinlocks. For the longer lockups we disable the irq the device
136 * sits on and hold the lock. We must hold the lock because there is a dual
137 * processor case other than interrupts (get stats/set multicast list in
138 * parallel with each other and transmit).
139 *
140 * Note: in theory we can just disable the irq on the card _but_ there is
141 * a latency on SMP irq delivery. So we can easily go "disable irq" "sync irqs"
142 * enter lock, take the queued irq. So we waddle instead of flying.
143 *
144 * Finally by special arrangement for the purpose of being generally
145 * annoying the transmit function is called bh atomic. That places
146 * restrictions on the user context callers as disable_irq won't save
147 * them.
148 */
149
150
151 7
152/**
153 * ei_open - Open/initialize the board.
154 * @dev: network device to initialize
155 *
156 * This routine goes all-out, setting everything
157 * up anew at each open, even though many of these registers should only
158 * need to be set once at boot.
159 */
160int ei_open(struct net_device *dev) 8int ei_open(struct net_device *dev)
161{ 9{
162 unsigned long flags; 10 return __ei_open(dev);
163 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
164
165 /* The card I/O part of the driver (e.g. 3c503) can hook a Tx timeout
166 wrapper that does e.g. media check & then calls ei_tx_timeout. */
167 if (dev->tx_timeout == NULL)
168 dev->tx_timeout = ei_tx_timeout;
169 if (dev->watchdog_timeo <= 0)
170 dev->watchdog_timeo = TX_TIMEOUT;
171
172 /*
173 * Grab the page lock so we own the register set, then call
174 * the init function.
175 */
176
177 spin_lock_irqsave(&ei_local->page_lock, flags);
178 NS8390_init(dev, 1);
179 /* Set the flag before we drop the lock, That way the IRQ arrives
180 after its set and we get no silly warnings */
181 netif_start_queue(dev);
182 spin_unlock_irqrestore(&ei_local->page_lock, flags);
183 ei_local->irqlock = 0;
184 return 0;
185} 11}
186 12
187/**
188 * ei_close - shut down network device
189 * @dev: network device to close
190 *
191 * Opposite of ei_open(). Only used when "ifconfig <devname> down" is done.
192 */
193int ei_close(struct net_device *dev) 13int ei_close(struct net_device *dev)
194{ 14{
195 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 15 return __ei_close(dev);
196 unsigned long flags;
197
198 /*
199 * Hold the page lock during close
200 */
201
202 spin_lock_irqsave(&ei_local->page_lock, flags);
203 NS8390_init(dev, 0);
204 spin_unlock_irqrestore(&ei_local->page_lock, flags);
205 netif_stop_queue(dev);
206 return 0;
207}
208
209/**
210 * ei_tx_timeout - handle transmit time out condition
211 * @dev: network device which has apparently fallen asleep
212 *
213 * Called by kernel when device never acknowledges a transmit has
214 * completed (or failed) - i.e. never posted a Tx related interrupt.
215 */
216
217void ei_tx_timeout(struct net_device *dev)
218{
219 long e8390_base = dev->base_addr;
220 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
221 int txsr, isr, tickssofar = jiffies - dev->trans_start;
222 unsigned long flags;
223
224#if defined(CONFIG_M32R) && defined(CONFIG_SMP)
225 unsigned long icucr;
226
227 local_irq_save(flags);
228 icucr = inl(M32R_ICU_CR1_PORTL);
229 icucr |= M32R_ICUCR_ISMOD11;
230 outl(icucr, M32R_ICU_CR1_PORTL);
231 local_irq_restore(flags);
232#endif
233 ei_local->stat.tx_errors++;
234
235 spin_lock_irqsave(&ei_local->page_lock, flags);
236 txsr = inb(e8390_base+EN0_TSR);
237 isr = inb(e8390_base+EN0_ISR);
238 spin_unlock_irqrestore(&ei_local->page_lock, flags);
239
240 printk(KERN_DEBUG "%s: Tx timed out, %s TSR=%#2x, ISR=%#2x, t=%d.\n",
241 dev->name, (txsr & ENTSR_ABT) ? "excess collisions." :
242 (isr) ? "lost interrupt?" : "cable problem?", txsr, isr, tickssofar);
243
244 if (!isr && !ei_local->stat.tx_packets)
245 {
246 /* The 8390 probably hasn't gotten on the cable yet. */
247 ei_local->interface_num ^= 1; /* Try a different xcvr. */
248 }
249
250 /* Ugly but a reset can be slow, yet must be protected */
251
252 disable_irq_nosync_lockdep(dev->irq);
253 spin_lock(&ei_local->page_lock);
254
255 /* Try to restart the card. Perhaps the user has fixed something. */
256 ei_reset_8390(dev);
257 NS8390_init(dev, 1);
258
259 spin_unlock(&ei_local->page_lock);
260 enable_irq_lockdep(dev->irq);
261 netif_wake_queue(dev);
262}
263
264/**
265 * ei_start_xmit - begin packet transmission
266 * @skb: packet to be sent
267 * @dev: network device to which packet is sent
268 *
269 * Sends a packet to an 8390 network device.
270 */
271
272static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
273{
274 long e8390_base = dev->base_addr;
275 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
276 int send_length = skb->len, output_page;
277 unsigned long flags;
278 char buf[ETH_ZLEN];
279 char *data = skb->data;
280
281 if (skb->len < ETH_ZLEN) {
282 memset(buf, 0, ETH_ZLEN); /* more efficient than doing just the needed bits */
283 memcpy(buf, data, skb->len);
284 send_length = ETH_ZLEN;
285 data = buf;
286 }
287
288 /* Mask interrupts from the ethercard.
289 SMP: We have to grab the lock here otherwise the IRQ handler
290 on another CPU can flip window and race the IRQ mask set. We end
291 up trashing the mcast filter not disabling irqs if we don't lock */
292
293 spin_lock_irqsave(&ei_local->page_lock, flags);
294 outb_p(0x00, e8390_base + EN0_IMR);
295 spin_unlock_irqrestore(&ei_local->page_lock, flags);
296
297
298 /*
299 * Slow phase with lock held.
300 */
301
302 disable_irq_nosync_lockdep_irqsave(dev->irq, &flags);
303
304 spin_lock(&ei_local->page_lock);
305
306 ei_local->irqlock = 1;
307
308 /*
309 * We have two Tx slots available for use. Find the first free
310 * slot, and then perform some sanity checks. With two Tx bufs,
311 * you get very close to transmitting back-to-back packets. With
312 * only one Tx buf, the transmitter sits idle while you reload the
313 * card, leaving a substantial gap between each transmitted packet.
314 */
315
316 if (ei_local->tx1 == 0)
317 {
318 output_page = ei_local->tx_start_page;
319 ei_local->tx1 = send_length;
320 if (ei_debug && ei_local->tx2 > 0)
321 printk(KERN_DEBUG "%s: idle transmitter tx2=%d, lasttx=%d, txing=%d.\n",
322 dev->name, ei_local->tx2, ei_local->lasttx, ei_local->txing);
323 }
324 else if (ei_local->tx2 == 0)
325 {
326 output_page = ei_local->tx_start_page + TX_PAGES/2;
327 ei_local->tx2 = send_length;
328 if (ei_debug && ei_local->tx1 > 0)
329 printk(KERN_DEBUG "%s: idle transmitter, tx1=%d, lasttx=%d, txing=%d.\n",
330 dev->name, ei_local->tx1, ei_local->lasttx, ei_local->txing);
331 }
332 else
333 { /* We should never get here. */
334 if (ei_debug)
335 printk(KERN_DEBUG "%s: No Tx buffers free! tx1=%d tx2=%d last=%d\n",
336 dev->name, ei_local->tx1, ei_local->tx2, ei_local->lasttx);
337 ei_local->irqlock = 0;
338 netif_stop_queue(dev);
339 outb_p(ENISR_ALL, e8390_base + EN0_IMR);
340 spin_unlock(&ei_local->page_lock);
341 enable_irq_lockdep_irqrestore(dev->irq, &flags);
342 ei_local->stat.tx_errors++;
343 return 1;
344 }
345
346 /*
347 * Okay, now upload the packet and trigger a send if the transmitter
348 * isn't already sending. If it is busy, the interrupt handler will
349 * trigger the send later, upon receiving a Tx done interrupt.
350 */
351
352 ei_block_output(dev, send_length, data, output_page);
353
354 if (! ei_local->txing)
355 {
356 ei_local->txing = 1;
357 NS8390_trigger_send(dev, send_length, output_page);
358 dev->trans_start = jiffies;
359 if (output_page == ei_local->tx_start_page)
360 {
361 ei_local->tx1 = -1;
362 ei_local->lasttx = -1;
363 }
364 else
365 {
366 ei_local->tx2 = -1;
367 ei_local->lasttx = -2;
368 }
369 }
370 else ei_local->txqueue++;
371
372 if (ei_local->tx1 && ei_local->tx2)
373 netif_stop_queue(dev);
374 else
375 netif_start_queue(dev);
376
377 /* Turn 8390 interrupts back on. */
378 ei_local->irqlock = 0;
379 outb_p(ENISR_ALL, e8390_base + EN0_IMR);
380
381 spin_unlock(&ei_local->page_lock);
382 enable_irq_lockdep_irqrestore(dev->irq, &flags);
383
384 dev_kfree_skb (skb);
385 ei_local->stat.tx_bytes += send_length;
386
387 return 0;
388} 16}
389 17
390/**
391 * ei_interrupt - handle the interrupts from an 8390
392 * @irq: interrupt number
393 * @dev_id: a pointer to the net_device
394 *
395 * Handle the ether interface interrupts. We pull packets from
396 * the 8390 via the card specific functions and fire them at the networking
397 * stack. We also handle transmit completions and wake the transmit path if
398 * necessary. We also update the counters and do other housekeeping as
399 * needed.
400 */
401
402irqreturn_t ei_interrupt(int irq, void *dev_id) 18irqreturn_t ei_interrupt(int irq, void *dev_id)
403{ 19{
404 struct net_device *dev = dev_id; 20 return __ei_interrupt(irq, dev_id);
405 long e8390_base;
406 int interrupts, nr_serviced = 0;
407 struct ei_device *ei_local;
408
409 e8390_base = dev->base_addr;
410 ei_local = netdev_priv(dev);
411
412 /*
413 * Protect the irq test too.
414 */
415
416 spin_lock(&ei_local->page_lock);
417
418 if (ei_local->irqlock)
419 {
420#if 1 /* This might just be an interrupt for a PCI device sharing this line */
421 /* The "irqlock" check is only for testing. */
422 printk(ei_local->irqlock
423 ? "%s: Interrupted while interrupts are masked! isr=%#2x imr=%#2x.\n"
424 : "%s: Reentering the interrupt handler! isr=%#2x imr=%#2x.\n",
425 dev->name, inb_p(e8390_base + EN0_ISR),
426 inb_p(e8390_base + EN0_IMR));
427#endif
428 spin_unlock(&ei_local->page_lock);
429 return IRQ_NONE;
430 }
431
432 /* Change to page 0 and read the intr status reg. */
433 outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
434 if (ei_debug > 3)
435 printk(KERN_DEBUG "%s: interrupt(isr=%#2.2x).\n", dev->name,
436 inb_p(e8390_base + EN0_ISR));
437
438 /* !!Assumption!! -- we stay in page 0. Don't break this. */
439 while ((interrupts = inb_p(e8390_base + EN0_ISR)) != 0
440 && ++nr_serviced < MAX_SERVICE)
441 {
442 if (!netif_running(dev)) {
443 printk(KERN_WARNING "%s: interrupt from stopped card\n", dev->name);
444 /* rmk - acknowledge the interrupts */
445 outb_p(interrupts, e8390_base + EN0_ISR);
446 interrupts = 0;
447 break;
448 }
449 if (interrupts & ENISR_OVER)
450 ei_rx_overrun(dev);
451 else if (interrupts & (ENISR_RX+ENISR_RX_ERR))
452 {
453 /* Got a good (?) packet. */
454 ei_receive(dev);
455 }
456 /* Push the next to-transmit packet through. */
457 if (interrupts & ENISR_TX)
458 ei_tx_intr(dev);
459 else if (interrupts & ENISR_TX_ERR)
460 ei_tx_err(dev);
461
462 if (interrupts & ENISR_COUNTERS)
463 {
464 ei_local->stat.rx_frame_errors += inb_p(e8390_base + EN0_COUNTER0);
465 ei_local->stat.rx_crc_errors += inb_p(e8390_base + EN0_COUNTER1);
466 ei_local->stat.rx_missed_errors+= inb_p(e8390_base + EN0_COUNTER2);
467 outb_p(ENISR_COUNTERS, e8390_base + EN0_ISR); /* Ack intr. */
468 }
469
470 /* Ignore any RDC interrupts that make it back to here. */
471 if (interrupts & ENISR_RDC)
472 {
473 outb_p(ENISR_RDC, e8390_base + EN0_ISR);
474 }
475
476 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD);
477 }
478
479 if (interrupts && ei_debug)
480 {
481 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD);
482 if (nr_serviced >= MAX_SERVICE)
483 {
484 /* 0xFF is valid for a card removal */
485 if(interrupts!=0xFF)
486 printk(KERN_WARNING "%s: Too much work at interrupt, status %#2.2x\n",
487 dev->name, interrupts);
488 outb_p(ENISR_ALL, e8390_base + EN0_ISR); /* Ack. most intrs. */
489 } else {
490 printk(KERN_WARNING "%s: unknown interrupt %#2x\n", dev->name, interrupts);
491 outb_p(0xff, e8390_base + EN0_ISR); /* Ack. all intrs. */
492 }
493 }
494 spin_unlock(&ei_local->page_lock);
495 return IRQ_RETVAL(nr_serviced > 0);
496} 21}
497 22
498#ifdef CONFIG_NET_POLL_CONTROLLER 23#ifdef CONFIG_NET_POLL_CONTROLLER
499void ei_poll(struct net_device *dev) 24void ei_poll(struct net_device *dev)
500{ 25{
501 disable_irq_lockdep(dev->irq); 26 __ei_poll(dev);
502 ei_interrupt(dev->irq, dev);
503 enable_irq_lockdep(dev->irq);
504} 27}
505#endif 28#endif
506 29
507/**
508 * ei_tx_err - handle transmitter error
509 * @dev: network device which threw the exception
510 *
511 * A transmitter error has happened. Most likely excess collisions (which
512 * is a fairly normal condition). If the error is one where the Tx will
513 * have been aborted, we try and send another one right away, instead of
514 * letting the failed packet sit and collect dust in the Tx buffer. This
515 * is a much better solution as it avoids kernel based Tx timeouts, and
516 * an unnecessary card reset.
517 *
518 * Called with lock held.
519 */
520
521static void ei_tx_err(struct net_device *dev)
522{
523 long e8390_base = dev->base_addr;
524 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
525 unsigned char txsr = inb_p(e8390_base+EN0_TSR);
526 unsigned char tx_was_aborted = txsr & (ENTSR_ABT+ENTSR_FU);
527
528#ifdef VERBOSE_ERROR_DUMP
529 printk(KERN_DEBUG "%s: transmitter error (%#2x): ", dev->name, txsr);
530 if (txsr & ENTSR_ABT)
531 printk("excess-collisions ");
532 if (txsr & ENTSR_ND)
533 printk("non-deferral ");
534 if (txsr & ENTSR_CRS)
535 printk("lost-carrier ");
536 if (txsr & ENTSR_FU)
537 printk("FIFO-underrun ");
538 if (txsr & ENTSR_CDH)
539 printk("lost-heartbeat ");
540 printk("\n");
541#endif
542
543 outb_p(ENISR_TX_ERR, e8390_base + EN0_ISR); /* Ack intr. */
544
545 if (tx_was_aborted)
546 ei_tx_intr(dev);
547 else
548 {
549 ei_local->stat.tx_errors++;
550 if (txsr & ENTSR_CRS) ei_local->stat.tx_carrier_errors++;
551 if (txsr & ENTSR_CDH) ei_local->stat.tx_heartbeat_errors++;
552 if (txsr & ENTSR_OWC) ei_local->stat.tx_window_errors++;
553 }
554}
555
556/**
557 * ei_tx_intr - transmit interrupt handler
558 * @dev: network device for which tx intr is handled
559 *
560 * We have finished a transmit: check for errors and then trigger the next
561 * packet to be sent. Called with lock held.
562 */
563
564static void ei_tx_intr(struct net_device *dev)
565{
566 long e8390_base = dev->base_addr;
567 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
568 int status = inb(e8390_base + EN0_TSR);
569
570 outb_p(ENISR_TX, e8390_base + EN0_ISR); /* Ack intr. */
571
572 /*
573 * There are two Tx buffers, see which one finished, and trigger
574 * the send of another one if it exists.
575 */
576 ei_local->txqueue--;
577
578 if (ei_local->tx1 < 0)
579 {
580 if (ei_local->lasttx != 1 && ei_local->lasttx != -1)
581 printk(KERN_ERR "%s: bogus last_tx_buffer %d, tx1=%d.\n",
582 ei_local->name, ei_local->lasttx, ei_local->tx1);
583 ei_local->tx1 = 0;
584 if (ei_local->tx2 > 0)
585 {
586 ei_local->txing = 1;
587 NS8390_trigger_send(dev, ei_local->tx2, ei_local->tx_start_page + 6);
588 dev->trans_start = jiffies;
589 ei_local->tx2 = -1,
590 ei_local->lasttx = 2;
591 }
592 else ei_local->lasttx = 20, ei_local->txing = 0;
593 }
594 else if (ei_local->tx2 < 0)
595 {
596 if (ei_local->lasttx != 2 && ei_local->lasttx != -2)
597 printk("%s: bogus last_tx_buffer %d, tx2=%d.\n",
598 ei_local->name, ei_local->lasttx, ei_local->tx2);
599 ei_local->tx2 = 0;
600 if (ei_local->tx1 > 0)
601 {
602 ei_local->txing = 1;
603 NS8390_trigger_send(dev, ei_local->tx1, ei_local->tx_start_page);
604 dev->trans_start = jiffies;
605 ei_local->tx1 = -1;
606 ei_local->lasttx = 1;
607 }
608 else
609 ei_local->lasttx = 10, ei_local->txing = 0;
610 }
611// else printk(KERN_WARNING "%s: unexpected TX-done interrupt, lasttx=%d.\n",
612// dev->name, ei_local->lasttx);
613
614 /* Minimize Tx latency: update the statistics after we restart TXing. */
615 if (status & ENTSR_COL)
616 ei_local->stat.collisions++;
617 if (status & ENTSR_PTX)
618 ei_local->stat.tx_packets++;
619 else
620 {
621 ei_local->stat.tx_errors++;
622 if (status & ENTSR_ABT)
623 {
624 ei_local->stat.tx_aborted_errors++;
625 ei_local->stat.collisions += 16;
626 }
627 if (status & ENTSR_CRS)
628 ei_local->stat.tx_carrier_errors++;
629 if (status & ENTSR_FU)
630 ei_local->stat.tx_fifo_errors++;
631 if (status & ENTSR_CDH)
632 ei_local->stat.tx_heartbeat_errors++;
633 if (status & ENTSR_OWC)
634 ei_local->stat.tx_window_errors++;
635 }
636 netif_wake_queue(dev);
637}
638
639/**
640 * ei_receive - receive some packets
641 * @dev: network device with which receive will be run
642 *
643 * We have a good packet(s), get it/them out of the buffers.
644 * Called with lock held.
645 */
646
647static void ei_receive(struct net_device *dev)
648{
649 long e8390_base = dev->base_addr;
650 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
651 unsigned char rxing_page, this_frame, next_frame;
652 unsigned short current_offset;
653 int rx_pkt_count = 0;
654 struct e8390_pkt_hdr rx_frame;
655 int num_rx_pages = ei_local->stop_page-ei_local->rx_start_page;
656
657 while (++rx_pkt_count < 10)
658 {
659 int pkt_len, pkt_stat;
660
661 /* Get the rx page (incoming packet pointer). */
662 outb_p(E8390_NODMA+E8390_PAGE1, e8390_base + E8390_CMD);
663 rxing_page = inb_p(e8390_base + EN1_CURPAG);
664 outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
665
666 /* Remove one frame from the ring. Boundary is always a page behind. */
667 this_frame = inb_p(e8390_base + EN0_BOUNDARY) + 1;
668 if (this_frame >= ei_local->stop_page)
669 this_frame = ei_local->rx_start_page;
670
671 /* Someday we'll omit the previous, iff we never get this message.
672 (There is at least one clone claimed to have a problem.)
673
674 Keep quiet if it looks like a card removal. One problem here
675 is that some clones crash in roughly the same way.
676 */
677 if (ei_debug > 0 && this_frame != ei_local->current_page && (this_frame!=0x0 || rxing_page!=0xFF))
678 printk(KERN_ERR "%s: mismatched read page pointers %2x vs %2x.\n",
679 dev->name, this_frame, ei_local->current_page);
680
681 if (this_frame == rxing_page) /* Read all the frames? */
682 break; /* Done for now */
683
684 current_offset = this_frame << 8;
685 ei_get_8390_hdr(dev, &rx_frame, this_frame);
686
687 pkt_len = rx_frame.count - sizeof(struct e8390_pkt_hdr);
688 pkt_stat = rx_frame.status;
689
690 next_frame = this_frame + 1 + ((pkt_len+4)>>8);
691
692 /* Check for bogosity warned by 3c503 book: the status byte is never
693 written. This happened a lot during testing! This code should be
694 cleaned up someday. */
695 if (rx_frame.next != next_frame
696 && rx_frame.next != next_frame + 1
697 && rx_frame.next != next_frame - num_rx_pages
698 && rx_frame.next != next_frame + 1 - num_rx_pages) {
699 ei_local->current_page = rxing_page;
700 outb(ei_local->current_page-1, e8390_base+EN0_BOUNDARY);
701 ei_local->stat.rx_errors++;
702 continue;
703 }
704
705 if (pkt_len < 60 || pkt_len > 1518)
706 {
707 if (ei_debug)
708 printk(KERN_DEBUG "%s: bogus packet size: %d, status=%#2x nxpg=%#2x.\n",
709 dev->name, rx_frame.count, rx_frame.status,
710 rx_frame.next);
711 ei_local->stat.rx_errors++;
712 ei_local->stat.rx_length_errors++;
713 }
714 else if ((pkt_stat & 0x0F) == ENRSR_RXOK)
715 {
716 struct sk_buff *skb;
717
718 skb = dev_alloc_skb(pkt_len+2);
719 if (skb == NULL)
720 {
721 if (ei_debug > 1)
722 printk(KERN_DEBUG "%s: Couldn't allocate a sk_buff of size %d.\n",
723 dev->name, pkt_len);
724 ei_local->stat.rx_dropped++;
725 break;
726 }
727 else
728 {
729 skb_reserve(skb,2); /* IP headers on 16 byte boundaries */
730 skb->dev = dev;
731 skb_put(skb, pkt_len); /* Make room */
732 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame));
733 skb->protocol=eth_type_trans(skb,dev);
734 netif_rx(skb);
735 dev->last_rx = jiffies;
736 ei_local->stat.rx_packets++;
737 ei_local->stat.rx_bytes += pkt_len;
738 if (pkt_stat & ENRSR_PHY)
739 ei_local->stat.multicast++;
740 }
741 }
742 else
743 {
744 if (ei_debug)
745 printk(KERN_DEBUG "%s: bogus packet: status=%#2x nxpg=%#2x size=%d\n",
746 dev->name, rx_frame.status, rx_frame.next,
747 rx_frame.count);
748 ei_local->stat.rx_errors++;
749 /* NB: The NIC counts CRC, frame and missed errors. */
750 if (pkt_stat & ENRSR_FO)
751 ei_local->stat.rx_fifo_errors++;
752 }
753 next_frame = rx_frame.next;
754
755 /* This _should_ never happen: it's here for avoiding bad clones. */
756 if (next_frame >= ei_local->stop_page) {
757 printk("%s: next frame inconsistency, %#2x\n", dev->name,
758 next_frame);
759 next_frame = ei_local->rx_start_page;
760 }
761 ei_local->current_page = next_frame;
762 outb_p(next_frame-1, e8390_base+EN0_BOUNDARY);
763 }
764
765 /* We used to also ack ENISR_OVER here, but that would sometimes mask
766 a real overrun, leaving the 8390 in a stopped state with rec'vr off. */
767 outb_p(ENISR_RX+ENISR_RX_ERR, e8390_base+EN0_ISR);
768 return;
769}
770
771/**
772 * ei_rx_overrun - handle receiver overrun
773 * @dev: network device which threw exception
774 *
775 * We have a receiver overrun: we have to kick the 8390 to get it started
776 * again. Problem is that you have to kick it exactly as NS prescribes in
777 * the updated datasheets, or "the NIC may act in an unpredictable manner."
778 * This includes causing "the NIC to defer indefinitely when it is stopped
779 * on a busy network." Ugh.
780 * Called with lock held. Don't call this with the interrupts off or your
781 * computer will hate you - it takes 10ms or so.
782 */
783
784static void ei_rx_overrun(struct net_device *dev)
785{
786 long e8390_base = dev->base_addr;
787 unsigned char was_txing, must_resend = 0;
788 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
789
790 /*
791 * Record whether a Tx was in progress and then issue the
792 * stop command.
793 */
794 was_txing = inb_p(e8390_base+E8390_CMD) & E8390_TRANS;
795 outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD);
796
797 if (ei_debug > 1)
798 printk(KERN_DEBUG "%s: Receiver overrun.\n", dev->name);
799 ei_local->stat.rx_over_errors++;
800
801 /*
802 * Wait a full Tx time (1.2ms) + some guard time, NS says 1.6ms total.
803 * Early datasheets said to poll the reset bit, but now they say that
804 * it "is not a reliable indicator and subsequently should be ignored."
805 * We wait at least 10ms.
806 */
807
808 mdelay(10);
809
810 /*
811 * Reset RBCR[01] back to zero as per magic incantation.
812 */
813 outb_p(0x00, e8390_base+EN0_RCNTLO);
814 outb_p(0x00, e8390_base+EN0_RCNTHI);
815
816 /*
817 * See if any Tx was interrupted or not. According to NS, this
818 * step is vital, and skipping it will cause no end of havoc.
819 */
820
821 if (was_txing)
822 {
823 unsigned char tx_completed = inb_p(e8390_base+EN0_ISR) & (ENISR_TX+ENISR_TX_ERR);
824 if (!tx_completed)
825 must_resend = 1;
826 }
827
828 /*
829 * Have to enter loopback mode and then restart the NIC before
830 * you are allowed to slurp packets up off the ring.
831 */
832 outb_p(E8390_TXOFF, e8390_base + EN0_TXCR);
833 outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START, e8390_base + E8390_CMD);
834
835 /*
836 * Clear the Rx ring of all the debris, and ack the interrupt.
837 */
838 ei_receive(dev);
839 outb_p(ENISR_OVER, e8390_base+EN0_ISR);
840
841 /*
842 * Leave loopback mode, and resend any packet that got stopped.
843 */
844 outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR);
845 if (must_resend)
846 outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START + E8390_TRANS, e8390_base + E8390_CMD);
847}
848
849/*
850 * Collect the stats. This is called unlocked and from several contexts.
851 */
852
853static struct net_device_stats *get_stats(struct net_device *dev)
854{
855 long ioaddr = dev->base_addr;
856 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
857 unsigned long flags;
858
859 /* If the card is stopped, just return the present stats. */
860 if (!netif_running(dev))
861 return &ei_local->stat;
862
863 spin_lock_irqsave(&ei_local->page_lock,flags);
864 /* Read the counter registers, assuming we are in page 0. */
865 ei_local->stat.rx_frame_errors += inb_p(ioaddr + EN0_COUNTER0);
866 ei_local->stat.rx_crc_errors += inb_p(ioaddr + EN0_COUNTER1);
867 ei_local->stat.rx_missed_errors+= inb_p(ioaddr + EN0_COUNTER2);
868 spin_unlock_irqrestore(&ei_local->page_lock, flags);
869
870 return &ei_local->stat;
871}
872
873/*
874 * Form the 64 bit 8390 multicast table from the linked list of addresses
875 * associated with this dev structure.
876 */
877
878static inline void make_mc_bits(u8 *bits, struct net_device *dev)
879{
880 struct dev_mc_list *dmi;
881
882 for (dmi=dev->mc_list; dmi; dmi=dmi->next)
883 {
884 u32 crc;
885 if (dmi->dmi_addrlen != ETH_ALEN)
886 {
887 printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name);
888 continue;
889 }
890 crc = ether_crc(ETH_ALEN, dmi->dmi_addr);
891 /*
892 * The 8390 uses the 6 most significant bits of the
893 * CRC to index the multicast table.
894 */
895 bits[crc>>29] |= (1<<((crc>>26)&7));
896 }
897}
898
899/**
900 * do_set_multicast_list - set/clear multicast filter
901 * @dev: net device for which multicast filter is adjusted
902 *
903 * Set or clear the multicast filter for this adaptor. May be called
904 * from a BH in 2.1.x. Must be called with lock held.
905 */
906
907static void do_set_multicast_list(struct net_device *dev)
908{
909 long e8390_base = dev->base_addr;
910 int i;
911 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
912
913 if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI)))
914 {
915 memset(ei_local->mcfilter, 0, 8);
916 if (dev->mc_list)
917 make_mc_bits(ei_local->mcfilter, dev);
918 }
919 else
920 memset(ei_local->mcfilter, 0xFF, 8); /* mcast set to accept-all */
921
922 /*
923 * DP8390 manuals don't specify any magic sequence for altering
924 * the multicast regs on an already running card. To be safe, we
925 * ensure multicast mode is off prior to loading up the new hash
926 * table. If this proves to be not enough, we can always resort
927 * to stopping the NIC, loading the table and then restarting.
928 *
929 * Bug Alert! The MC regs on the SMC 83C690 (SMC Elite and SMC
930 * Elite16) appear to be write-only. The NS 8390 data sheet lists
931 * them as r/w so this is a bug. The SMC 83C790 (SMC Ultra and
932 * Ultra32 EISA) appears to have this bug fixed.
933 */
934
935 if (netif_running(dev))
936 outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
937 outb_p(E8390_NODMA + E8390_PAGE1, e8390_base + E8390_CMD);
938 for(i = 0; i < 8; i++)
939 {
940 outb_p(ei_local->mcfilter[i], e8390_base + EN1_MULT_SHIFT(i));
941#ifndef BUG_83C690
942 if(inb_p(e8390_base + EN1_MULT_SHIFT(i))!=ei_local->mcfilter[i])
943 printk(KERN_ERR "Multicast filter read/write mismap %d\n",i);
944#endif
945 }
946 outb_p(E8390_NODMA + E8390_PAGE0, e8390_base + E8390_CMD);
947
948 if(dev->flags&IFF_PROMISC)
949 outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR);
950 else if(dev->flags&IFF_ALLMULTI || dev->mc_list)
951 outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR);
952 else
953 outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
954 }
955
956/*
957 * Called without lock held. This is invoked from user context and may
958 * be parallel to just about everything else. Its also fairly quick and
959 * not called too often. Must protect against both bh and irq users
960 */
961
962static void set_multicast_list(struct net_device *dev)
963{
964 unsigned long flags;
965 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
966
967 spin_lock_irqsave(&ei_local->page_lock, flags);
968 do_set_multicast_list(dev);
969 spin_unlock_irqrestore(&ei_local->page_lock, flags);
970}
971
972/**
973 * ethdev_setup - init rest of 8390 device struct
974 * @dev: network device structure to init
975 *
976 * Initialize the rest of the 8390 device structure. Do NOT __init
977 * this, as it is used by 8390 based modular drivers too.
978 */
979
980static void ethdev_setup(struct net_device *dev)
981{
982 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
983 if (ei_debug > 1)
984 printk(version);
985
986 dev->hard_start_xmit = &ei_start_xmit;
987 dev->get_stats = get_stats;
988 dev->set_multicast_list = &set_multicast_list;
989
990 ether_setup(dev);
991
992 spin_lock_init(&ei_local->page_lock);
993}
994
995/**
996 * alloc_ei_netdev - alloc_etherdev counterpart for 8390
997 * @size: extra bytes to allocate
998 *
999 * Allocate 8390-specific net_device.
1000 */
1001struct net_device *__alloc_ei_netdev(int size) 30struct net_device *__alloc_ei_netdev(int size)
1002{ 31{
1003 return alloc_netdev(sizeof(struct ei_device) + size, "eth%d", 32 return ____alloc_ei_netdev(size);
1004 ethdev_setup);
1005} 33}
1006 34
1007
1008
1009
1010/* This page of functions should be 8390 generic */
1011/* Follow National Semi's recommendations for initializing the "NIC". */
1012
1013/**
1014 * NS8390_init - initialize 8390 hardware
1015 * @dev: network device to initialize
1016 * @startp: boolean. non-zero value to initiate chip processing
1017 *
1018 * Must be called with lock held.
1019 */
1020
1021void NS8390_init(struct net_device *dev, int startp) 35void NS8390_init(struct net_device *dev, int startp)
1022{ 36{
1023 long e8390_base = dev->base_addr; 37 return __NS8390_init(dev, startp);
1024 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
1025 int i;
1026 int endcfg = ei_local->word16
1027 ? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0))
1028 : 0x48;
1029
1030 if(sizeof(struct e8390_pkt_hdr)!=4)
1031 panic("8390.c: header struct mispacked\n");
1032 /* Follow National Semi's recommendations for initing the DP83902. */
1033 outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD); /* 0x21 */
1034 outb_p(endcfg, e8390_base + EN0_DCFG); /* 0x48 or 0x49 */
1035 /* Clear the remote byte count registers. */
1036 outb_p(0x00, e8390_base + EN0_RCNTLO);
1037 outb_p(0x00, e8390_base + EN0_RCNTHI);
1038 /* Set to monitor and loopback mode -- this is vital!. */
1039 outb_p(E8390_RXOFF, e8390_base + EN0_RXCR); /* 0x20 */
1040 outb_p(E8390_TXOFF, e8390_base + EN0_TXCR); /* 0x02 */
1041 /* Set the transmit page and receive ring. */
1042 outb_p(ei_local->tx_start_page, e8390_base + EN0_TPSR);
1043 ei_local->tx1 = ei_local->tx2 = 0;
1044 outb_p(ei_local->rx_start_page, e8390_base + EN0_STARTPG);
1045 outb_p(ei_local->stop_page-1, e8390_base + EN0_BOUNDARY); /* 3c503 says 0x3f,NS0x26*/
1046 ei_local->current_page = ei_local->rx_start_page; /* assert boundary+1 */
1047 outb_p(ei_local->stop_page, e8390_base + EN0_STOPPG);
1048 /* Clear the pending interrupts and mask. */
1049 outb_p(0xFF, e8390_base + EN0_ISR);
1050 outb_p(0x00, e8390_base + EN0_IMR);
1051
1052 /* Copy the station address into the DS8390 registers. */
1053
1054 outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP, e8390_base+E8390_CMD); /* 0x61 */
1055 for(i = 0; i < 6; i++)
1056 {
1057 outb_p(dev->dev_addr[i], e8390_base + EN1_PHYS_SHIFT(i));
1058 if (ei_debug > 1 && inb_p(e8390_base + EN1_PHYS_SHIFT(i))!=dev->dev_addr[i])
1059 printk(KERN_ERR "Hw. address read/write mismap %d\n",i);
1060 }
1061
1062 outb_p(ei_local->rx_start_page, e8390_base + EN1_CURPAG);
1063 outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD);
1064
1065 netif_start_queue(dev);
1066 ei_local->tx1 = ei_local->tx2 = 0;
1067 ei_local->txing = 0;
1068
1069 if (startp)
1070 {
1071 outb_p(0xff, e8390_base + EN0_ISR);
1072 outb_p(ENISR_ALL, e8390_base + EN0_IMR);
1073 outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base+E8390_CMD);
1074 outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR); /* xmit on. */
1075 /* 3c503 TechMan says rxconfig only after the NIC is started. */
1076 outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); /* rx on, */
1077 do_set_multicast_list(dev); /* (re)load the mcast table */
1078 }
1079}
1080
1081/* Trigger a transmit start, assuming the length is valid.
1082 Always called with the page lock held */
1083
1084static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
1085 int start_page)
1086{
1087 long e8390_base = dev->base_addr;
1088 struct ei_device *ei_local __attribute((unused)) = (struct ei_device *) netdev_priv(dev);
1089
1090 outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD);
1091
1092 if (inb_p(e8390_base + E8390_CMD) & E8390_TRANS)
1093 {
1094 printk(KERN_WARNING "%s: trigger_send() called with the transmitter busy.\n",
1095 dev->name);
1096 return;
1097 }
1098 outb_p(length & 0xff, e8390_base + EN0_TCNTLO);
1099 outb_p(length >> 8, e8390_base + EN0_TCNTHI);
1100 outb_p(start_page, e8390_base + EN0_TPSR);
1101 outb_p(E8390_NODMA+E8390_TRANS+E8390_START, e8390_base+E8390_CMD);
1102} 38}
1103 39
1104EXPORT_SYMBOL(ei_open); 40EXPORT_SYMBOL(ei_open);
diff --git a/drivers/net/8390.h b/drivers/net/8390.h
index f44f1220b3a5..414de5bd228f 100644
--- a/drivers/net/8390.h
+++ b/drivers/net/8390.h
@@ -107,35 +107,14 @@ struct ei_device {
107 * - removed AMIGA_PCMCIA from this list, handled as ISA io now 107 * - removed AMIGA_PCMCIA from this list, handled as ISA io now
108 */ 108 */
109 109
110#if defined(CONFIG_MAC) || \ 110#ifndef ei_inb
111 defined(CONFIG_ZORRO8390) || defined(CONFIG_ZORRO8390_MODULE) || \ 111#define ei_inb(_p) inb(_p)
112 defined(CONFIG_HYDRA) || defined(CONFIG_HYDRA_MODULE) 112#define ei_outb(_v,_p) outb(_v,_p)
113#define EI_SHIFT(x) (ei_local->reg_offset[x]) 113#define ei_inb_p(_p) inb_p(_p)
114#undef inb 114#define ei_outb_p(_v,_p) outb_p(_v,_p)
115#undef inb_p 115#endif
116#undef outb 116
117#undef outb_p 117#ifndef EI_SHIFT
118
119#define inb(port) in_8(port)
120#define outb(val,port) out_8(port,val)
121#define inb_p(port) in_8(port)
122#define outb_p(val,port) out_8(port,val)
123
124#elif defined(CONFIG_ARM_ETHERH) || defined(CONFIG_ARM_ETHERH_MODULE)
125#define EI_SHIFT(x) (ei_local->reg_offset[x])
126#undef inb
127#undef inb_p
128#undef outb
129#undef outb_p
130
131#define inb(_p) readb(_p)
132#define outb(_v,_p) writeb(_v,_p)
133#define inb_p(_p) inb(_p)
134#define outb_p(_v,_p) outb(_v,_p)
135
136#elif defined(CONFIG_NE_H8300) || defined(CONFIG_NE_H8300_MODULE)
137#define EI_SHIFT(x) (ei_local->reg_offset[x])
138#else
139#define EI_SHIFT(x) (x) 118#define EI_SHIFT(x) (x)
140#endif 119#endif
141 120
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 6e863aa9894c..9de0eed6755b 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -32,7 +32,7 @@ config IFB
32 tristate "Intermediate Functional Block support" 32 tristate "Intermediate Functional Block support"
33 depends on NET_CLS_ACT 33 depends on NET_CLS_ACT
34 ---help--- 34 ---help---
35 This is an intermidiate driver that allows sharing of 35 This is an intermediate driver that allows sharing of
36 resources. 36 resources.
37 To compile this driver as a module, choose M here: the module 37 To compile this driver as a module, choose M here: the module
38 will be called ifb. If you want to use more than one ifb 38 will be called ifb. If you want to use more than one ifb
@@ -188,6 +188,17 @@ config MII
188 or internal device. It is safe to say Y or M here even if your 188 or internal device. It is safe to say Y or M here even if your
189 ethernet card lack MII. 189 ethernet card lack MII.
190 190
191config MACB
192 tristate "Atmel MACB support"
193 depends on NET_ETHERNET && AVR32
194 select MII
195 help
196 The Atmel MACB ethernet interface is found on many AT32 and AT91
197 parts. Say Y to include support for the MACB chip.
198
199 To compile this driver as a module, choose M here: the module
200 will be called macb.
201
191source "drivers/net/arm/Kconfig" 202source "drivers/net/arm/Kconfig"
192 203
193config MACE 204config MACE
@@ -1769,8 +1780,8 @@ config VIA_RHINE_NAPI
1769 information. 1780 information.
1770 1781
1771config LAN_SAA9730 1782config LAN_SAA9730
1772 bool "Philips SAA9730 Ethernet support (EXPERIMENTAL)" 1783 bool "Philips SAA9730 Ethernet support"
1773 depends on NET_PCI && EXPERIMENTAL && MIPS 1784 depends on NET_PCI && PCI && MIPS_ATLAS
1774 help 1785 help
1775 The SAA9730 is a combined multimedia and peripheral controller used 1786 The SAA9730 is a combined multimedia and peripheral controller used
1776 in thin clients, Internet access terminals, and diskless 1787 in thin clients, Internet access terminals, and diskless
@@ -2136,7 +2147,7 @@ config SK98LIN
2136 This driver supports the original Yukon chipset. A cleaner driver is 2147 This driver supports the original Yukon chipset. A cleaner driver is
2137 also available (skge) which seems to work better than this one. 2148 also available (skge) which seems to work better than this one.
2138 2149
2139 This driver does not support the newer Yukon2 chipset. A seperate 2150 This driver does not support the newer Yukon2 chipset. A separate
2140 driver, sky2, is provided to support Yukon2-based adapters. 2151 driver, sky2, is provided to support Yukon2-based adapters.
2141 2152
2142 The following adapters are supported by this driver: 2153 The following adapters are supported by this driver:
@@ -2251,6 +2262,14 @@ config SPIDER_NET
2251 This driver supports the Gigabit Ethernet chips present on the 2262 This driver supports the Gigabit Ethernet chips present on the
2252 Cell Processor-Based Blades from IBM. 2263 Cell Processor-Based Blades from IBM.
2253 2264
2265config TSI108_ETH
2266 tristate "Tundra TSI108 gigabit Ethernet support"
2267 depends on TSI108_BRIDGE
2268 help
2269 This driver supports Tundra TSI108 gigabit Ethernet ports.
2270 To compile this driver as a module, choose M here: the module
2271 will be called tsi108_eth.
2272
2254config GIANFAR 2273config GIANFAR
2255 tristate "Gianfar Ethernet" 2274 tristate "Gianfar Ethernet"
2256 depends on 85xx || 83xx || PPC_86xx 2275 depends on 85xx || 83xx || PPC_86xx
@@ -2341,10 +2360,11 @@ menu "Ethernet (10000 Mbit)"
2341config CHELSIO_T1 2360config CHELSIO_T1
2342 tristate "Chelsio 10Gb Ethernet support" 2361 tristate "Chelsio 10Gb Ethernet support"
2343 depends on PCI 2362 depends on PCI
2363 select CRC32
2344 help 2364 help
2345 This driver supports Chelsio N110 and N210 models 10Gb Ethernet 2365 This driver supports Chelsio gigabit and 10-gigabit
2346 cards. More information about adapter features and performance 2366 Ethernet cards. More information about adapter features and
2347 tuning is in <file:Documentation/networking/cxgb.txt>. 2367 performance tuning is in <file:Documentation/networking/cxgb.txt>.
2348 2368
2349 For general information about Chelsio and our products, visit 2369 For general information about Chelsio and our products, visit
2350 our website at <http://www.chelsio.com>. 2370 our website at <http://www.chelsio.com>.
@@ -2357,6 +2377,13 @@ config CHELSIO_T1
2357 To compile this driver as a module, choose M here: the module 2377 To compile this driver as a module, choose M here: the module
2358 will be called cxgb. 2378 will be called cxgb.
2359 2379
2380config CHELSIO_T1_1G
2381 bool "Chelsio gigabit Ethernet support"
2382 depends on CHELSIO_T1
2383 help
2384 Enables support for Chelsio's gigabit Ethernet PCI cards. If you
2385 are using only 10G cards say 'N' here.
2386
2360config EHEA 2387config EHEA
2361 tristate "eHEA Ethernet support" 2388 tristate "eHEA Ethernet support"
2362 depends on IBMEBUS 2389 depends on IBMEBUS
@@ -2447,6 +2474,12 @@ config MYRI10GE
2447 <file:Documentation/networking/net-modules.txt>. The module 2474 <file:Documentation/networking/net-modules.txt>. The module
2448 will be called myri10ge. 2475 will be called myri10ge.
2449 2476
2477config NETXEN_NIC
2478 tristate "NetXen Multi port (1/10) Gigabit Ethernet NIC"
2479 depends on PCI
2480 help
2481 This enables the support for NetXen's Gigabit Ethernet card.
2482
2450endmenu 2483endmenu
2451 2484
2452source "drivers/net/tokenring/Kconfig" 2485source "drivers/net/tokenring/Kconfig"
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index f270bc49e571..4c0d4e5ce42b 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -82,7 +82,7 @@ obj-$(CONFIG_HAMACHI) += hamachi.o
82obj-$(CONFIG_NET) += Space.o loopback.o 82obj-$(CONFIG_NET) += Space.o loopback.o
83obj-$(CONFIG_SEEQ8005) += seeq8005.o 83obj-$(CONFIG_SEEQ8005) += seeq8005.o
84obj-$(CONFIG_NET_SB1000) += sb1000.o 84obj-$(CONFIG_NET_SB1000) += sb1000.o
85obj-$(CONFIG_MAC8390) += mac8390.o 8390.o 85obj-$(CONFIG_MAC8390) += mac8390.o
86obj-$(CONFIG_APNE) += apne.o 8390.o 86obj-$(CONFIG_APNE) += apne.o 8390.o
87obj-$(CONFIG_PCMCIA_PCNET) += 8390.o 87obj-$(CONFIG_PCMCIA_PCNET) += 8390.o
88obj-$(CONFIG_SHAPER) += shaper.o 88obj-$(CONFIG_SHAPER) += shaper.o
@@ -90,7 +90,6 @@ obj-$(CONFIG_HP100) += hp100.o
90obj-$(CONFIG_SMC9194) += smc9194.o 90obj-$(CONFIG_SMC9194) += smc9194.o
91obj-$(CONFIG_FEC) += fec.o 91obj-$(CONFIG_FEC) += fec.o
92obj-$(CONFIG_68360_ENET) += 68360enet.o 92obj-$(CONFIG_68360_ENET) += 68360enet.o
93obj-$(CONFIG_ARM_ETHERH) += 8390.o
94obj-$(CONFIG_WD80x3) += wd.o 8390.o 93obj-$(CONFIG_WD80x3) += wd.o 8390.o
95obj-$(CONFIG_EL2) += 3c503.o 8390.o 94obj-$(CONFIG_EL2) += 3c503.o 8390.o
96obj-$(CONFIG_NE2000) += ne.o 8390.o 95obj-$(CONFIG_NE2000) += ne.o 8390.o
@@ -107,8 +106,9 @@ obj-$(CONFIG_NE3210) += ne3210.o 8390.o
107obj-$(CONFIG_NET_SB1250_MAC) += sb1250-mac.o 106obj-$(CONFIG_NET_SB1250_MAC) += sb1250-mac.o
108obj-$(CONFIG_B44) += b44.o 107obj-$(CONFIG_B44) += b44.o
109obj-$(CONFIG_FORCEDETH) += forcedeth.o 108obj-$(CONFIG_FORCEDETH) += forcedeth.o
110obj-$(CONFIG_NE_H8300) += ne-h8300.o 8390.o 109obj-$(CONFIG_NE_H8300) += ne-h8300.o
111 110
111obj-$(CONFIG_TSI108_ETH) += tsi108_eth.o
112obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o 112obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o
113obj-$(CONFIG_QLA3XXX) += qla3xxx.o 113obj-$(CONFIG_QLA3XXX) += qla3xxx.o
114 114
@@ -165,7 +165,7 @@ obj-$(CONFIG_BVME6000_NET) += 82596.o
165obj-$(CONFIG_LP486E) += lp486e.o 165obj-$(CONFIG_LP486E) += lp486e.o
166 166
167obj-$(CONFIG_ETH16I) += eth16i.o 167obj-$(CONFIG_ETH16I) += eth16i.o
168obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o 168obj-$(CONFIG_ZORRO8390) += zorro8390.o
169obj-$(CONFIG_HPLANCE) += hplance.o 7990.o 169obj-$(CONFIG_HPLANCE) += hplance.o 7990.o
170obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o 170obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o
171obj-$(CONFIG_EQUALIZER) += eql.o 171obj-$(CONFIG_EQUALIZER) += eql.o
@@ -178,7 +178,7 @@ obj-$(CONFIG_ATARILANCE) += atarilance.o
178obj-$(CONFIG_ATARI_BIONET) += atari_bionet.o 178obj-$(CONFIG_ATARI_BIONET) += atari_bionet.o
179obj-$(CONFIG_ATARI_PAMSNET) += atari_pamsnet.o 179obj-$(CONFIG_ATARI_PAMSNET) += atari_pamsnet.o
180obj-$(CONFIG_A2065) += a2065.o 180obj-$(CONFIG_A2065) += a2065.o
181obj-$(CONFIG_HYDRA) += hydra.o 8390.o 181obj-$(CONFIG_HYDRA) += hydra.o
182obj-$(CONFIG_ARIADNE) += ariadne.o 182obj-$(CONFIG_ARIADNE) += ariadne.o
183obj-$(CONFIG_CS89x0) += cs89x0.o 183obj-$(CONFIG_CS89x0) += cs89x0.o
184obj-$(CONFIG_MACSONIC) += macsonic.o 184obj-$(CONFIG_MACSONIC) += macsonic.o
@@ -197,6 +197,8 @@ obj-$(CONFIG_SMC911X) += smc911x.o
197obj-$(CONFIG_DM9000) += dm9000.o 197obj-$(CONFIG_DM9000) += dm9000.o
198obj-$(CONFIG_FEC_8XX) += fec_8xx/ 198obj-$(CONFIG_FEC_8XX) += fec_8xx/
199 199
200obj-$(CONFIG_MACB) += macb.o
201
200obj-$(CONFIG_ARM) += arm/ 202obj-$(CONFIG_ARM) += arm/
201obj-$(CONFIG_DEV_APPLETALK) += appletalk/ 203obj-$(CONFIG_DEV_APPLETALK) += appletalk/
202obj-$(CONFIG_TR) += tokenring/ 204obj-$(CONFIG_TR) += tokenring/
@@ -214,3 +216,4 @@ obj-$(CONFIG_NETCONSOLE) += netconsole.o
214 216
215obj-$(CONFIG_FS_ENET) += fs_enet/ 217obj-$(CONFIG_FS_ENET) += fs_enet/
216 218
219obj-$(CONFIG_NETXEN_NIC) += netxen/
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index a67f5efc983f..602ed31a5dd9 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -33,7 +33,6 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/netlink.h> 35#include <linux/netlink.h>
36#include <linux/divert.h>
37 36
38/* A unified ethernet device probe. This is the easiest way to have every 37/* A unified ethernet device probe. This is the easiest way to have every
39 ethernet adaptor have the name "eth[0123...]". 38 ethernet adaptor have the name "eth[0123...]".
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index ef65e5917c8f..18896f24d407 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -1490,32 +1490,7 @@ static void amd8111e_read_regs(struct amd8111e_priv *lp, u32 *buf)
1490 buf[12] = readl(mmio + STAT0); 1490 buf[12] = readl(mmio + STAT0);
1491} 1491}
1492 1492
1493/*
1494amd8111e crc generator implementation is different from the kernel
1495ether_crc() function.
1496*/
1497static int amd8111e_ether_crc(int len, char* mac_addr)
1498{
1499 int i,byte;
1500 unsigned char octet;
1501 u32 crc= INITCRC;
1502
1503 for(byte=0; byte < len; byte++){
1504 octet = mac_addr[byte];
1505 for( i=0;i < 8; i++){
1506 /*If the next bit form the input stream is 1,subtract the divisor (CRC32) from the dividend(crc).*/
1507 if( (octet & 0x1) ^ (crc & 0x1) ){
1508 crc >>= 1;
1509 crc ^= CRC32;
1510 }
1511 else
1512 crc >>= 1;
1513 1493
1514 octet >>= 1;
1515 }
1516 }
1517 return crc;
1518}
1519/* 1494/*
1520This function sets promiscuos mode, all-multi mode or the multicast address 1495This function sets promiscuos mode, all-multi mode or the multicast address
1521list to the device. 1496list to the device.
@@ -1556,7 +1531,7 @@ static void amd8111e_set_multicast_list(struct net_device *dev)
1556 mc_filter[1] = mc_filter[0] = 0; 1531 mc_filter[1] = mc_filter[0] = 0;
1557 for (i = 0, mc_ptr = dev->mc_list; mc_ptr && i < dev->mc_count; 1532 for (i = 0, mc_ptr = dev->mc_list; mc_ptr && i < dev->mc_count;
1558 i++, mc_ptr = mc_ptr->next) { 1533 i++, mc_ptr = mc_ptr->next) {
1559 bit_num = ( amd8111e_ether_crc(ETH_ALEN,mc_ptr->dmi_addr) >> 26 ) & 0x3f; 1534 bit_num = (ether_crc_le(ETH_ALEN, mc_ptr->dmi_addr) >> 26) & 0x3f;
1560 mc_filter[bit_num >> 5] |= 1 << (bit_num & 31); 1535 mc_filter[bit_num >> 5] |= 1 << (bit_num & 31);
1561 } 1536 }
1562 amd8111e_writeq(*(u64*)mc_filter,lp->mmio+ LADRF); 1537 amd8111e_writeq(*(u64*)mc_filter,lp->mmio+ LADRF);
diff --git a/drivers/net/amd8111e.h b/drivers/net/amd8111e.h
index 7727d328f65e..2007510c4eb6 100644
--- a/drivers/net/amd8111e.h
+++ b/drivers/net/amd8111e.h
@@ -651,10 +651,6 @@ typedef enum {
651/* driver ioctl parameters */ 651/* driver ioctl parameters */
652#define AMD8111E_REG_DUMP_LEN 13*sizeof(u32) 652#define AMD8111E_REG_DUMP_LEN 13*sizeof(u32)
653 653
654/* crc generator constants */
655#define CRC32 0xedb88320
656#define INITCRC 0xFFFFFFFF
657
658/* amd8111e desriptor format */ 654/* amd8111e desriptor format */
659 655
660struct amd8111e_tx_dr{ 656struct amd8111e_tx_dr{
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 4ae98970b282..f3faa4fe58e7 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -52,7 +52,12 @@
52#include <asm/ecard.h> 52#include <asm/ecard.h>
53#include <asm/io.h> 53#include <asm/io.h>
54 54
55#include "../8390.h" 55#define EI_SHIFT(x) (ei_local->reg_offset[x])
56
57#define ei_inb(_p) readb((void __iomem *)_p)
58#define ei_outb(_v,_p) writeb(_v,(void __iomem *)_p)
59#define ei_inb_p(_p) readb((void __iomem *)_p)
60#define ei_outb_p(_v,_p) writeb(_v,(void __iomem *)_p)
56 61
57#define NET_DEBUG 0 62#define NET_DEBUG 0
58#define DEBUG_INIT 2 63#define DEBUG_INIT 2
@@ -60,6 +65,11 @@
60#define DRV_NAME "etherh" 65#define DRV_NAME "etherh"
61#define DRV_VERSION "1.11" 66#define DRV_VERSION "1.11"
62 67
68static char version[] __initdata =
69 "EtherH/EtherM Driver (c) 2002-2004 Russell King " DRV_VERSION "\n";
70
71#include "../lib8390.c"
72
63static unsigned int net_debug = NET_DEBUG; 73static unsigned int net_debug = NET_DEBUG;
64 74
65struct etherh_priv { 75struct etherh_priv {
@@ -87,9 +97,6 @@ MODULE_AUTHOR("Russell King");
87MODULE_DESCRIPTION("EtherH/EtherM driver"); 97MODULE_DESCRIPTION("EtherH/EtherM driver");
88MODULE_LICENSE("GPL"); 98MODULE_LICENSE("GPL");
89 99
90static char version[] __initdata =
91 "EtherH/EtherM Driver (c) 2002-2004 Russell King " DRV_VERSION "\n";
92
93#define ETHERH500_DATAPORT 0x800 /* MEMC */ 100#define ETHERH500_DATAPORT 0x800 /* MEMC */
94#define ETHERH500_NS8390 0x000 /* MEMC */ 101#define ETHERH500_NS8390 0x000 /* MEMC */
95#define ETHERH500_CTRLPORT 0x800 /* IOC */ 102#define ETHERH500_CTRLPORT 0x800 /* IOC */
@@ -177,7 +184,7 @@ etherh_setif(struct net_device *dev)
177 switch (etherh_priv(dev)->id) { 184 switch (etherh_priv(dev)->id) {
178 case PROD_I3_ETHERLAN600: 185 case PROD_I3_ETHERLAN600:
179 case PROD_I3_ETHERLAN600A: 186 case PROD_I3_ETHERLAN600A:
180 addr = (void *)dev->base_addr + EN0_RCNTHI; 187 addr = (void __iomem *)dev->base_addr + EN0_RCNTHI;
181 188
182 switch (dev->if_port) { 189 switch (dev->if_port) {
183 case IF_PORT_10BASE2: 190 case IF_PORT_10BASE2:
@@ -218,7 +225,7 @@ etherh_getifstat(struct net_device *dev)
218 switch (etherh_priv(dev)->id) { 225 switch (etherh_priv(dev)->id) {
219 case PROD_I3_ETHERLAN600: 226 case PROD_I3_ETHERLAN600:
220 case PROD_I3_ETHERLAN600A: 227 case PROD_I3_ETHERLAN600A:
221 addr = (void *)dev->base_addr + EN0_RCNTHI; 228 addr = (void __iomem *)dev->base_addr + EN0_RCNTHI;
222 switch (dev->if_port) { 229 switch (dev->if_port) {
223 case IF_PORT_10BASE2: 230 case IF_PORT_10BASE2:
224 stat = 1; 231 stat = 1;
@@ -281,7 +288,7 @@ static void
281etherh_reset(struct net_device *dev) 288etherh_reset(struct net_device *dev)
282{ 289{
283 struct ei_device *ei_local = netdev_priv(dev); 290 struct ei_device *ei_local = netdev_priv(dev);
284 void __iomem *addr = (void *)dev->base_addr; 291 void __iomem *addr = (void __iomem *)dev->base_addr;
285 292
286 writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, addr); 293 writeb(E8390_NODMA+E8390_PAGE0+E8390_STOP, addr);
287 294
@@ -327,7 +334,7 @@ etherh_block_output (struct net_device *dev, int count, const unsigned char *buf
327 334
328 ei_local->dmaing = 1; 335 ei_local->dmaing = 1;
329 336
330 addr = (void *)dev->base_addr; 337 addr = (void __iomem *)dev->base_addr;
331 dma_base = etherh_priv(dev)->dma_base; 338 dma_base = etherh_priv(dev)->dma_base;
332 339
333 count = (count + 1) & ~1; 340 count = (count + 1) & ~1;
@@ -360,7 +367,7 @@ etherh_block_output (struct net_device *dev, int count, const unsigned char *buf
360 printk(KERN_ERR "%s: timeout waiting for TX RDC\n", 367 printk(KERN_ERR "%s: timeout waiting for TX RDC\n",
361 dev->name); 368 dev->name);
362 etherh_reset (dev); 369 etherh_reset (dev);
363 NS8390_init (dev, 1); 370 __NS8390_init (dev, 1);
364 break; 371 break;
365 } 372 }
366 373
@@ -387,7 +394,7 @@ etherh_block_input (struct net_device *dev, int count, struct sk_buff *skb, int
387 394
388 ei_local->dmaing = 1; 395 ei_local->dmaing = 1;
389 396
390 addr = (void *)dev->base_addr; 397 addr = (void __iomem *)dev->base_addr;
391 dma_base = etherh_priv(dev)->dma_base; 398 dma_base = etherh_priv(dev)->dma_base;
392 399
393 buf = skb->data; 400 buf = skb->data;
@@ -427,7 +434,7 @@ etherh_get_header (struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_p
427 434
428 ei_local->dmaing = 1; 435 ei_local->dmaing = 1;
429 436
430 addr = (void *)dev->base_addr; 437 addr = (void __iomem *)dev->base_addr;
431 dma_base = etherh_priv(dev)->dma_base; 438 dma_base = etherh_priv(dev)->dma_base;
432 439
433 writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD); 440 writeb (E8390_NODMA | E8390_PAGE0 | E8390_START, addr + E8390_CMD);
@@ -465,7 +472,7 @@ etherh_open(struct net_device *dev)
465 return -EINVAL; 472 return -EINVAL;
466 } 473 }
467 474
468 if (request_irq(dev->irq, ei_interrupt, 0, dev->name, dev)) 475 if (request_irq(dev->irq, __ei_interrupt, 0, dev->name, dev))
469 return -EAGAIN; 476 return -EAGAIN;
470 477
471 /* 478 /*
@@ -491,7 +498,7 @@ etherh_open(struct net_device *dev)
491 etherh_setif(dev); 498 etherh_setif(dev);
492 499
493 etherh_reset(dev); 500 etherh_reset(dev);
494 ei_open(dev); 501 __ei_open(dev);
495 502
496 return 0; 503 return 0;
497} 504}
@@ -502,7 +509,7 @@ etherh_open(struct net_device *dev)
502static int 509static int
503etherh_close(struct net_device *dev) 510etherh_close(struct net_device *dev)
504{ 511{
505 ei_close (dev); 512 __ei_close (dev);
506 free_irq (dev->irq, dev); 513 free_irq (dev->irq, dev);
507 return 0; 514 return 0;
508} 515}
@@ -650,7 +657,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
650 if (ret) 657 if (ret)
651 goto out; 658 goto out;
652 659
653 dev = __alloc_ei_netdev(sizeof(struct etherh_priv)); 660 dev = ____alloc_ei_netdev(sizeof(struct etherh_priv));
654 if (!dev) { 661 if (!dev) {
655 ret = -ENOMEM; 662 ret = -ENOMEM;
656 goto release; 663 goto release;
@@ -736,7 +743,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)
736 ei_local->interface_num = 0; 743 ei_local->interface_num = 0;
737 744
738 etherh_reset(dev); 745 etherh_reset(dev);
739 NS8390_init(dev, 0); 746 __NS8390_init(dev, 0);
740 747
741 ret = register_netdev(dev); 748 ret = register_netdev(dev);
742 if (ret) 749 if (ret)
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 7db3c8af0894..f0b6879a1c7d 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -360,7 +360,8 @@ static int mii_probe (struct net_device *dev)
360 BUG_ON(!phydev); 360 BUG_ON(!phydev);
361 BUG_ON(phydev->attached_dev); 361 BUG_ON(phydev->attached_dev);
362 362
363 phydev = phy_connect(dev, phydev->dev.bus_id, &au1000_adjust_link, 0); 363 phydev = phy_connect(dev, phydev->dev.bus_id, &au1000_adjust_link, 0,
364 PHY_INTERFACE_MODE_MII);
364 365
365 if (IS_ERR(phydev)) { 366 if (IS_ERR(phydev)) {
366 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); 367 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index b12cc4596b8d..5bacb7587df4 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -53,11 +53,12 @@
53 53
54#include "bnx2.h" 54#include "bnx2.h"
55#include "bnx2_fw.h" 55#include "bnx2_fw.h"
56#include "bnx2_fw2.h"
56 57
57#define DRV_MODULE_NAME "bnx2" 58#define DRV_MODULE_NAME "bnx2"
58#define PFX DRV_MODULE_NAME ": " 59#define PFX DRV_MODULE_NAME ": "
59#define DRV_MODULE_VERSION "1.4.45" 60#define DRV_MODULE_VERSION "1.5.1"
60#define DRV_MODULE_RELDATE "September 29, 2006" 61#define DRV_MODULE_RELDATE "November 15, 2006"
61 62
62#define RUN_AT(x) (jiffies + (x)) 63#define RUN_AT(x) (jiffies + (x))
63 64
@@ -85,6 +86,7 @@ typedef enum {
85 NC370F, 86 NC370F,
86 BCM5708, 87 BCM5708,
87 BCM5708S, 88 BCM5708S,
89 BCM5709,
88} board_t; 90} board_t;
89 91
90/* indexed by board_t, above */ 92/* indexed by board_t, above */
@@ -98,6 +100,7 @@ static const struct {
98 { "HP NC370F Multifunction Gigabit Server Adapter" }, 100 { "HP NC370F Multifunction Gigabit Server Adapter" },
99 { "Broadcom NetXtreme II BCM5708 1000Base-T" }, 101 { "Broadcom NetXtreme II BCM5708 1000Base-T" },
100 { "Broadcom NetXtreme II BCM5708 1000Base-SX" }, 102 { "Broadcom NetXtreme II BCM5708 1000Base-SX" },
103 { "Broadcom NetXtreme II BCM5709 1000Base-T" },
101 }; 104 };
102 105
103static struct pci_device_id bnx2_pci_tbl[] = { 106static struct pci_device_id bnx2_pci_tbl[] = {
@@ -115,6 +118,8 @@ static struct pci_device_id bnx2_pci_tbl[] = {
115 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706S }, 118 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5706S },
116 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5708S, 119 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5708S,
117 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708S }, 120 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5708S },
121 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5709,
122 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709 },
118 { 0, } 123 { 0, }
119}; 124};
120 125
@@ -236,8 +241,23 @@ static void
236bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val) 241bnx2_ctx_wr(struct bnx2 *bp, u32 cid_addr, u32 offset, u32 val)
237{ 242{
238 offset += cid_addr; 243 offset += cid_addr;
239 REG_WR(bp, BNX2_CTX_DATA_ADR, offset); 244 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
240 REG_WR(bp, BNX2_CTX_DATA, val); 245 int i;
246
247 REG_WR(bp, BNX2_CTX_CTX_DATA, val);
248 REG_WR(bp, BNX2_CTX_CTX_CTRL,
249 offset | BNX2_CTX_CTX_CTRL_WRITE_REQ);
250 for (i = 0; i < 5; i++) {
251 u32 val;
252 val = REG_RD(bp, BNX2_CTX_CTX_CTRL);
253 if ((val & BNX2_CTX_CTX_CTRL_WRITE_REQ) == 0)
254 break;
255 udelay(5);
256 }
257 } else {
258 REG_WR(bp, BNX2_CTX_DATA_ADR, offset);
259 REG_WR(bp, BNX2_CTX_DATA, val);
260 }
241} 261}
242 262
243static int 263static int
@@ -403,6 +423,14 @@ bnx2_free_mem(struct bnx2 *bp)
403{ 423{
404 int i; 424 int i;
405 425
426 for (i = 0; i < bp->ctx_pages; i++) {
427 if (bp->ctx_blk[i]) {
428 pci_free_consistent(bp->pdev, BCM_PAGE_SIZE,
429 bp->ctx_blk[i],
430 bp->ctx_blk_mapping[i]);
431 bp->ctx_blk[i] = NULL;
432 }
433 }
406 if (bp->status_blk) { 434 if (bp->status_blk) {
407 pci_free_consistent(bp->pdev, bp->status_stats_size, 435 pci_free_consistent(bp->pdev, bp->status_stats_size,
408 bp->status_blk, bp->status_blk_mapping); 436 bp->status_blk, bp->status_blk_mapping);
@@ -481,6 +509,18 @@ bnx2_alloc_mem(struct bnx2 *bp)
481 509
482 bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size; 510 bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size;
483 511
512 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
513 bp->ctx_pages = 0x2000 / BCM_PAGE_SIZE;
514 if (bp->ctx_pages == 0)
515 bp->ctx_pages = 1;
516 for (i = 0; i < bp->ctx_pages; i++) {
517 bp->ctx_blk[i] = pci_alloc_consistent(bp->pdev,
518 BCM_PAGE_SIZE,
519 &bp->ctx_blk_mapping[i]);
520 if (bp->ctx_blk[i] == NULL)
521 goto alloc_mem_err;
522 }
523 }
484 return 0; 524 return 0;
485 525
486alloc_mem_err: 526alloc_mem_err:
@@ -803,13 +843,13 @@ bnx2_set_mac_link(struct bnx2 *bp)
803 843
804 val &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX | 844 val &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX |
805 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK | 845 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK |
806 BNX2_EMAC_MODE_25G); 846 BNX2_EMAC_MODE_25G_MODE);
807 847
808 if (bp->link_up) { 848 if (bp->link_up) {
809 switch (bp->line_speed) { 849 switch (bp->line_speed) {
810 case SPEED_10: 850 case SPEED_10:
811 if (CHIP_NUM(bp) == CHIP_NUM_5708) { 851 if (CHIP_NUM(bp) != CHIP_NUM_5706) {
812 val |= BNX2_EMAC_MODE_PORT_MII_10; 852 val |= BNX2_EMAC_MODE_PORT_MII_10M;
813 break; 853 break;
814 } 854 }
815 /* fall through */ 855 /* fall through */
@@ -817,7 +857,7 @@ bnx2_set_mac_link(struct bnx2 *bp)
817 val |= BNX2_EMAC_MODE_PORT_MII; 857 val |= BNX2_EMAC_MODE_PORT_MII;
818 break; 858 break;
819 case SPEED_2500: 859 case SPEED_2500:
820 val |= BNX2_EMAC_MODE_25G; 860 val |= BNX2_EMAC_MODE_25G_MODE;
821 /* fall through */ 861 /* fall through */
822 case SPEED_1000: 862 case SPEED_1000:
823 val |= BNX2_EMAC_MODE_PORT_GMII; 863 val |= BNX2_EMAC_MODE_PORT_GMII;
@@ -860,7 +900,7 @@ bnx2_set_link(struct bnx2 *bp)
860 u32 bmsr; 900 u32 bmsr;
861 u8 link_up; 901 u8 link_up;
862 902
863 if (bp->loopback == MAC_LOOPBACK) { 903 if (bp->loopback == MAC_LOOPBACK || bp->loopback == PHY_LOOPBACK) {
864 bp->link_up = 1; 904 bp->link_up = 1;
865 return 0; 905 return 0;
866 } 906 }
@@ -902,6 +942,7 @@ bnx2_set_link(struct bnx2 *bp)
902 u32 bmcr; 942 u32 bmcr;
903 943
904 bnx2_read_phy(bp, MII_BMCR, &bmcr); 944 bnx2_read_phy(bp, MII_BMCR, &bmcr);
945 bmcr &= ~BCM5708S_BMCR_FORCE_2500;
905 if (!(bmcr & BMCR_ANENABLE)) { 946 if (!(bmcr & BMCR_ANENABLE)) {
906 bnx2_write_phy(bp, MII_BMCR, bmcr | 947 bnx2_write_phy(bp, MII_BMCR, bmcr |
907 BMCR_ANENABLE); 948 BMCR_ANENABLE);
@@ -988,7 +1029,21 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
988 u32 new_bmcr; 1029 u32 new_bmcr;
989 int force_link_down = 0; 1030 int force_link_down = 0;
990 1031
991 if (CHIP_NUM(bp) == CHIP_NUM_5708) { 1032 bnx2_read_phy(bp, MII_ADVERTISE, &adv);
1033 adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
1034
1035 bnx2_read_phy(bp, MII_BMCR, &bmcr);
1036 new_bmcr = bmcr & ~(BMCR_ANENABLE | BCM5708S_BMCR_FORCE_2500);
1037 new_bmcr |= BMCR_SPEED1000;
1038 if (bp->req_line_speed == SPEED_2500) {
1039 new_bmcr |= BCM5708S_BMCR_FORCE_2500;
1040 bnx2_read_phy(bp, BCM5708S_UP1, &up1);
1041 if (!(up1 & BCM5708S_UP1_2G5)) {
1042 up1 |= BCM5708S_UP1_2G5;
1043 bnx2_write_phy(bp, BCM5708S_UP1, up1);
1044 force_link_down = 1;
1045 }
1046 } else if (CHIP_NUM(bp) == CHIP_NUM_5708) {
992 bnx2_read_phy(bp, BCM5708S_UP1, &up1); 1047 bnx2_read_phy(bp, BCM5708S_UP1, &up1);
993 if (up1 & BCM5708S_UP1_2G5) { 1048 if (up1 & BCM5708S_UP1_2G5) {
994 up1 &= ~BCM5708S_UP1_2G5; 1049 up1 &= ~BCM5708S_UP1_2G5;
@@ -997,12 +1052,6 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
997 } 1052 }
998 } 1053 }
999 1054
1000 bnx2_read_phy(bp, MII_ADVERTISE, &adv);
1001 adv &= ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF);
1002
1003 bnx2_read_phy(bp, MII_BMCR, &bmcr);
1004 new_bmcr = bmcr & ~BMCR_ANENABLE;
1005 new_bmcr |= BMCR_SPEED1000;
1006 if (bp->req_duplex == DUPLEX_FULL) { 1055 if (bp->req_duplex == DUPLEX_FULL) {
1007 adv |= ADVERTISE_1000XFULL; 1056 adv |= ADVERTISE_1000XFULL;
1008 new_bmcr |= BMCR_FULLDPLX; 1057 new_bmcr |= BMCR_FULLDPLX;
@@ -1023,6 +1072,7 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
1023 bp->link_up = 0; 1072 bp->link_up = 0;
1024 netif_carrier_off(bp->dev); 1073 netif_carrier_off(bp->dev);
1025 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1074 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
1075 bnx2_report_link(bp);
1026 } 1076 }
1027 bnx2_write_phy(bp, MII_ADVERTISE, adv); 1077 bnx2_write_phy(bp, MII_ADVERTISE, adv);
1028 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1078 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
@@ -1048,30 +1098,26 @@ bnx2_setup_serdes_phy(struct bnx2 *bp)
1048 if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) { 1098 if ((adv != new_adv) || ((bmcr & BMCR_ANENABLE) == 0)) {
1049 /* Force a link down visible on the other side */ 1099 /* Force a link down visible on the other side */
1050 if (bp->link_up) { 1100 if (bp->link_up) {
1051 int i;
1052
1053 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK); 1101 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
1054 for (i = 0; i < 110; i++) { 1102 spin_unlock_bh(&bp->phy_lock);
1055 udelay(100); 1103 msleep(20);
1056 } 1104 spin_lock_bh(&bp->phy_lock);
1057 } 1105 }
1058 1106
1059 bnx2_write_phy(bp, MII_ADVERTISE, new_adv); 1107 bnx2_write_phy(bp, MII_ADVERTISE, new_adv);
1060 bnx2_write_phy(bp, MII_BMCR, bmcr | BMCR_ANRESTART | 1108 bnx2_write_phy(bp, MII_BMCR, bmcr | BMCR_ANRESTART |
1061 BMCR_ANENABLE); 1109 BMCR_ANENABLE);
1062 if (CHIP_NUM(bp) == CHIP_NUM_5706) { 1110 /* Speed up link-up time when the link partner
1063 /* Speed up link-up time when the link partner 1111 * does not autonegotiate which is very common
1064 * does not autonegotiate which is very common 1112 * in blade servers. Some blade servers use
1065 * in blade servers. Some blade servers use 1113 * IPMI for kerboard input and it's important
1066 * IPMI for kerboard input and it's important 1114 * to minimize link disruptions. Autoneg. involves
1067 * to minimize link disruptions. Autoneg. involves 1115 * exchanging base pages plus 3 next pages and
1068 * exchanging base pages plus 3 next pages and 1116 * normally completes in about 120 msec.
1069 * normally completes in about 120 msec. 1117 */
1070 */ 1118 bp->current_interval = SERDES_AN_TIMEOUT;
1071 bp->current_interval = SERDES_AN_TIMEOUT; 1119 bp->serdes_an_pending = 1;
1072 bp->serdes_an_pending = 1; 1120 mod_timer(&bp->timer, jiffies + bp->current_interval);
1073 mod_timer(&bp->timer, jiffies + bp->current_interval);
1074 }
1075 } 1121 }
1076 1122
1077 return 0; 1123 return 0;
@@ -1153,7 +1199,6 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
1153 } 1199 }
1154 if (new_bmcr != bmcr) { 1200 if (new_bmcr != bmcr) {
1155 u32 bmsr; 1201 u32 bmsr;
1156 int i = 0;
1157 1202
1158 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1203 bnx2_read_phy(bp, MII_BMSR, &bmsr);
1159 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1204 bnx2_read_phy(bp, MII_BMSR, &bmsr);
@@ -1161,12 +1206,12 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
1161 if (bmsr & BMSR_LSTATUS) { 1206 if (bmsr & BMSR_LSTATUS) {
1162 /* Force link down */ 1207 /* Force link down */
1163 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK); 1208 bnx2_write_phy(bp, MII_BMCR, BMCR_LOOPBACK);
1164 do { 1209 spin_unlock_bh(&bp->phy_lock);
1165 udelay(100); 1210 msleep(50);
1166 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1211 spin_lock_bh(&bp->phy_lock);
1167 bnx2_read_phy(bp, MII_BMSR, &bmsr); 1212
1168 i++; 1213 bnx2_read_phy(bp, MII_BMSR, &bmsr);
1169 } while ((bmsr & BMSR_LSTATUS) && (i < 620)); 1214 bnx2_read_phy(bp, MII_BMSR, &bmsr);
1170 } 1215 }
1171 1216
1172 bnx2_write_phy(bp, MII_BMCR, new_bmcr); 1217 bnx2_write_phy(bp, MII_BMCR, new_bmcr);
@@ -1258,9 +1303,8 @@ bnx2_init_5706s_phy(struct bnx2 *bp)
1258{ 1303{
1259 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG; 1304 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
1260 1305
1261 if (CHIP_NUM(bp) == CHIP_NUM_5706) { 1306 if (CHIP_NUM(bp) == CHIP_NUM_5706)
1262 REG_WR(bp, BNX2_MISC_UNUSED0, 0x300); 1307 REG_WR(bp, BNX2_MISC_GP_HW_CTL0, 0x300);
1263 }
1264 1308
1265 if (bp->dev->mtu > 1500) { 1309 if (bp->dev->mtu > 1500) {
1266 u32 val; 1310 u32 val;
@@ -1397,13 +1441,13 @@ bnx2_set_phy_loopback(struct bnx2 *bp)
1397 for (i = 0; i < 10; i++) { 1441 for (i = 0; i < 10; i++) {
1398 if (bnx2_test_link(bp) == 0) 1442 if (bnx2_test_link(bp) == 0)
1399 break; 1443 break;
1400 udelay(10); 1444 msleep(100);
1401 } 1445 }
1402 1446
1403 mac_mode = REG_RD(bp, BNX2_EMAC_MODE); 1447 mac_mode = REG_RD(bp, BNX2_EMAC_MODE);
1404 mac_mode &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX | 1448 mac_mode &= ~(BNX2_EMAC_MODE_PORT | BNX2_EMAC_MODE_HALF_DUPLEX |
1405 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK | 1449 BNX2_EMAC_MODE_MAC_LOOP | BNX2_EMAC_MODE_FORCE_LINK |
1406 BNX2_EMAC_MODE_25G); 1450 BNX2_EMAC_MODE_25G_MODE);
1407 1451
1408 mac_mode |= BNX2_EMAC_MODE_PORT_GMII; 1452 mac_mode |= BNX2_EMAC_MODE_PORT_GMII;
1409 REG_WR(bp, BNX2_EMAC_MODE, mac_mode); 1453 REG_WR(bp, BNX2_EMAC_MODE, mac_mode);
@@ -1454,6 +1498,40 @@ bnx2_fw_sync(struct bnx2 *bp, u32 msg_data, int silent)
1454 return 0; 1498 return 0;
1455} 1499}
1456 1500
1501static int
1502bnx2_init_5709_context(struct bnx2 *bp)
1503{
1504 int i, ret = 0;
1505 u32 val;
1506
1507 val = BNX2_CTX_COMMAND_ENABLED | BNX2_CTX_COMMAND_MEM_INIT | (1 << 12);
1508 val |= (BCM_PAGE_BITS - 8) << 16;
1509 REG_WR(bp, BNX2_CTX_COMMAND, val);
1510 for (i = 0; i < bp->ctx_pages; i++) {
1511 int j;
1512
1513 REG_WR(bp, BNX2_CTX_HOST_PAGE_TBL_DATA0,
1514 (bp->ctx_blk_mapping[i] & 0xffffffff) |
1515 BNX2_CTX_HOST_PAGE_TBL_DATA0_VALID);
1516 REG_WR(bp, BNX2_CTX_HOST_PAGE_TBL_DATA1,
1517 (u64) bp->ctx_blk_mapping[i] >> 32);
1518 REG_WR(bp, BNX2_CTX_HOST_PAGE_TBL_CTRL, i |
1519 BNX2_CTX_HOST_PAGE_TBL_CTRL_WRITE_REQ);
1520 for (j = 0; j < 10; j++) {
1521
1522 val = REG_RD(bp, BNX2_CTX_HOST_PAGE_TBL_CTRL);
1523 if (!(val & BNX2_CTX_HOST_PAGE_TBL_CTRL_WRITE_REQ))
1524 break;
1525 udelay(5);
1526 }
1527 if (val & BNX2_CTX_HOST_PAGE_TBL_CTRL_WRITE_REQ) {
1528 ret = -EBUSY;
1529 break;
1530 }
1531 }
1532 return ret;
1533}
1534
1457static void 1535static void
1458bnx2_init_context(struct bnx2 *bp) 1536bnx2_init_context(struct bnx2 *bp)
1459{ 1537{
@@ -1576,9 +1654,8 @@ bnx2_alloc_rx_skb(struct bnx2 *bp, u16 index)
1576 return -ENOMEM; 1654 return -ENOMEM;
1577 } 1655 }
1578 1656
1579 if (unlikely((align = (unsigned long) skb->data & 0x7))) { 1657 if (unlikely((align = (unsigned long) skb->data & (BNX2_RX_ALIGN - 1))))
1580 skb_reserve(skb, 8 - align); 1658 skb_reserve(skb, BNX2_RX_ALIGN - align);
1581 }
1582 1659
1583 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size, 1660 mapping = pci_map_single(bp->pdev, skb->data, bp->rx_buf_use_size,
1584 PCI_DMA_FROMDEVICE); 1661 PCI_DMA_FROMDEVICE);
@@ -2040,7 +2117,8 @@ bnx2_set_rx_mode(struct net_device *dev)
2040 if (dev->flags & IFF_PROMISC) { 2117 if (dev->flags & IFF_PROMISC) {
2041 /* Promiscuous mode. */ 2118 /* Promiscuous mode. */
2042 rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS; 2119 rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS;
2043 sort_mode |= BNX2_RPM_SORT_USER0_PROM_EN; 2120 sort_mode |= BNX2_RPM_SORT_USER0_PROM_EN |
2121 BNX2_RPM_SORT_USER0_PROM_VLAN;
2044 } 2122 }
2045 else if (dev->flags & IFF_ALLMULTI) { 2123 else if (dev->flags & IFF_ALLMULTI) {
2046 for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) { 2124 for (i = 0; i < NUM_MC_HASH_REGISTERS; i++) {
@@ -2208,11 +2286,12 @@ load_rv2p_fw(struct bnx2 *bp, u32 *rv2p_code, u32 rv2p_code_len,
2208 } 2286 }
2209} 2287}
2210 2288
2211static void 2289static int
2212load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw) 2290load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2213{ 2291{
2214 u32 offset; 2292 u32 offset;
2215 u32 val; 2293 u32 val;
2294 int rc;
2216 2295
2217 /* Halt the CPU. */ 2296 /* Halt the CPU. */
2218 val = REG_RD_IND(bp, cpu_reg->mode); 2297 val = REG_RD_IND(bp, cpu_reg->mode);
@@ -2222,7 +2301,18 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2222 2301
2223 /* Load the Text area. */ 2302 /* Load the Text area. */
2224 offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base); 2303 offset = cpu_reg->spad_base + (fw->text_addr - cpu_reg->mips_view_base);
2225 if (fw->text) { 2304 if (fw->gz_text) {
2305 u32 text_len;
2306 void *text;
2307
2308 rc = bnx2_gunzip(bp, fw->gz_text, fw->gz_text_len, &text,
2309 &text_len);
2310 if (rc)
2311 return rc;
2312
2313 fw->text = text;
2314 }
2315 if (fw->gz_text) {
2226 int j; 2316 int j;
2227 2317
2228 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) { 2318 for (j = 0; j < (fw->text_len / 4); j++, offset += 4) {
@@ -2280,13 +2370,15 @@ load_cpu_fw(struct bnx2 *bp, struct cpu_reg *cpu_reg, struct fw_info *fw)
2280 val &= ~cpu_reg->mode_value_halt; 2370 val &= ~cpu_reg->mode_value_halt;
2281 REG_WR_IND(bp, cpu_reg->state, cpu_reg->state_value_clear); 2371 REG_WR_IND(bp, cpu_reg->state, cpu_reg->state_value_clear);
2282 REG_WR_IND(bp, cpu_reg->mode, val); 2372 REG_WR_IND(bp, cpu_reg->mode, val);
2373
2374 return 0;
2283} 2375}
2284 2376
2285static int 2377static int
2286bnx2_init_cpus(struct bnx2 *bp) 2378bnx2_init_cpus(struct bnx2 *bp)
2287{ 2379{
2288 struct cpu_reg cpu_reg; 2380 struct cpu_reg cpu_reg;
2289 struct fw_info fw; 2381 struct fw_info *fw;
2290 int rc = 0; 2382 int rc = 0;
2291 void *text; 2383 void *text;
2292 u32 text_len; 2384 u32 text_len;
@@ -2323,44 +2415,15 @@ bnx2_init_cpus(struct bnx2 *bp)
2323 cpu_reg.spad_base = BNX2_RXP_SCRATCH; 2415 cpu_reg.spad_base = BNX2_RXP_SCRATCH;
2324 cpu_reg.mips_view_base = 0x8000000; 2416 cpu_reg.mips_view_base = 0x8000000;
2325 2417
2326 fw.ver_major = bnx2_RXP_b06FwReleaseMajor; 2418 if (CHIP_NUM(bp) == CHIP_NUM_5709)
2327 fw.ver_minor = bnx2_RXP_b06FwReleaseMinor; 2419 fw = &bnx2_rxp_fw_09;
2328 fw.ver_fix = bnx2_RXP_b06FwReleaseFix; 2420 else
2329 fw.start_addr = bnx2_RXP_b06FwStartAddr; 2421 fw = &bnx2_rxp_fw_06;
2330
2331 fw.text_addr = bnx2_RXP_b06FwTextAddr;
2332 fw.text_len = bnx2_RXP_b06FwTextLen;
2333 fw.text_index = 0;
2334 2422
2335 rc = bnx2_gunzip(bp, bnx2_RXP_b06FwText, sizeof(bnx2_RXP_b06FwText), 2423 rc = load_cpu_fw(bp, &cpu_reg, fw);
2336 &text, &text_len);
2337 if (rc) 2424 if (rc)
2338 goto init_cpu_err; 2425 goto init_cpu_err;
2339 2426
2340 fw.text = text;
2341
2342 fw.data_addr = bnx2_RXP_b06FwDataAddr;
2343 fw.data_len = bnx2_RXP_b06FwDataLen;
2344 fw.data_index = 0;
2345 fw.data = bnx2_RXP_b06FwData;
2346
2347 fw.sbss_addr = bnx2_RXP_b06FwSbssAddr;
2348 fw.sbss_len = bnx2_RXP_b06FwSbssLen;
2349 fw.sbss_index = 0;
2350 fw.sbss = bnx2_RXP_b06FwSbss;
2351
2352 fw.bss_addr = bnx2_RXP_b06FwBssAddr;
2353 fw.bss_len = bnx2_RXP_b06FwBssLen;
2354 fw.bss_index = 0;
2355 fw.bss = bnx2_RXP_b06FwBss;
2356
2357 fw.rodata_addr = bnx2_RXP_b06FwRodataAddr;
2358 fw.rodata_len = bnx2_RXP_b06FwRodataLen;
2359 fw.rodata_index = 0;
2360 fw.rodata = bnx2_RXP_b06FwRodata;
2361
2362 load_cpu_fw(bp, &cpu_reg, &fw);
2363
2364 /* Initialize the TX Processor. */ 2427 /* Initialize the TX Processor. */
2365 cpu_reg.mode = BNX2_TXP_CPU_MODE; 2428 cpu_reg.mode = BNX2_TXP_CPU_MODE;
2366 cpu_reg.mode_value_halt = BNX2_TXP_CPU_MODE_SOFT_HALT; 2429 cpu_reg.mode_value_halt = BNX2_TXP_CPU_MODE_SOFT_HALT;
@@ -2375,44 +2438,15 @@ bnx2_init_cpus(struct bnx2 *bp)
2375 cpu_reg.spad_base = BNX2_TXP_SCRATCH; 2438 cpu_reg.spad_base = BNX2_TXP_SCRATCH;
2376 cpu_reg.mips_view_base = 0x8000000; 2439 cpu_reg.mips_view_base = 0x8000000;
2377 2440
2378 fw.ver_major = bnx2_TXP_b06FwReleaseMajor; 2441 if (CHIP_NUM(bp) == CHIP_NUM_5709)
2379 fw.ver_minor = bnx2_TXP_b06FwReleaseMinor; 2442 fw = &bnx2_txp_fw_09;
2380 fw.ver_fix = bnx2_TXP_b06FwReleaseFix; 2443 else
2381 fw.start_addr = bnx2_TXP_b06FwStartAddr; 2444 fw = &bnx2_txp_fw_06;
2382
2383 fw.text_addr = bnx2_TXP_b06FwTextAddr;
2384 fw.text_len = bnx2_TXP_b06FwTextLen;
2385 fw.text_index = 0;
2386 2445
2387 rc = bnx2_gunzip(bp, bnx2_TXP_b06FwText, sizeof(bnx2_TXP_b06FwText), 2446 rc = load_cpu_fw(bp, &cpu_reg, fw);
2388 &text, &text_len);
2389 if (rc) 2447 if (rc)
2390 goto init_cpu_err; 2448 goto init_cpu_err;
2391 2449
2392 fw.text = text;
2393
2394 fw.data_addr = bnx2_TXP_b06FwDataAddr;
2395 fw.data_len = bnx2_TXP_b06FwDataLen;
2396 fw.data_index = 0;
2397 fw.data = bnx2_TXP_b06FwData;
2398
2399 fw.sbss_addr = bnx2_TXP_b06FwSbssAddr;
2400 fw.sbss_len = bnx2_TXP_b06FwSbssLen;
2401 fw.sbss_index = 0;
2402 fw.sbss = bnx2_TXP_b06FwSbss;
2403
2404 fw.bss_addr = bnx2_TXP_b06FwBssAddr;
2405 fw.bss_len = bnx2_TXP_b06FwBssLen;
2406 fw.bss_index = 0;
2407 fw.bss = bnx2_TXP_b06FwBss;
2408
2409 fw.rodata_addr = bnx2_TXP_b06FwRodataAddr;
2410 fw.rodata_len = bnx2_TXP_b06FwRodataLen;
2411 fw.rodata_index = 0;
2412 fw.rodata = bnx2_TXP_b06FwRodata;
2413
2414 load_cpu_fw(bp, &cpu_reg, &fw);
2415
2416 /* Initialize the TX Patch-up Processor. */ 2450 /* Initialize the TX Patch-up Processor. */
2417 cpu_reg.mode = BNX2_TPAT_CPU_MODE; 2451 cpu_reg.mode = BNX2_TPAT_CPU_MODE;
2418 cpu_reg.mode_value_halt = BNX2_TPAT_CPU_MODE_SOFT_HALT; 2452 cpu_reg.mode_value_halt = BNX2_TPAT_CPU_MODE_SOFT_HALT;
@@ -2427,44 +2461,15 @@ bnx2_init_cpus(struct bnx2 *bp)
2427 cpu_reg.spad_base = BNX2_TPAT_SCRATCH; 2461 cpu_reg.spad_base = BNX2_TPAT_SCRATCH;
2428 cpu_reg.mips_view_base = 0x8000000; 2462 cpu_reg.mips_view_base = 0x8000000;
2429 2463
2430 fw.ver_major = bnx2_TPAT_b06FwReleaseMajor; 2464 if (CHIP_NUM(bp) == CHIP_NUM_5709)
2431 fw.ver_minor = bnx2_TPAT_b06FwReleaseMinor; 2465 fw = &bnx2_tpat_fw_09;
2432 fw.ver_fix = bnx2_TPAT_b06FwReleaseFix; 2466 else
2433 fw.start_addr = bnx2_TPAT_b06FwStartAddr; 2467 fw = &bnx2_tpat_fw_06;
2434
2435 fw.text_addr = bnx2_TPAT_b06FwTextAddr;
2436 fw.text_len = bnx2_TPAT_b06FwTextLen;
2437 fw.text_index = 0;
2438 2468
2439 rc = bnx2_gunzip(bp, bnx2_TPAT_b06FwText, sizeof(bnx2_TPAT_b06FwText), 2469 rc = load_cpu_fw(bp, &cpu_reg, fw);
2440 &text, &text_len);
2441 if (rc) 2470 if (rc)
2442 goto init_cpu_err; 2471 goto init_cpu_err;
2443 2472
2444 fw.text = text;
2445
2446 fw.data_addr = bnx2_TPAT_b06FwDataAddr;
2447 fw.data_len = bnx2_TPAT_b06FwDataLen;
2448 fw.data_index = 0;
2449 fw.data = bnx2_TPAT_b06FwData;
2450
2451 fw.sbss_addr = bnx2_TPAT_b06FwSbssAddr;
2452 fw.sbss_len = bnx2_TPAT_b06FwSbssLen;
2453 fw.sbss_index = 0;
2454 fw.sbss = bnx2_TPAT_b06FwSbss;
2455
2456 fw.bss_addr = bnx2_TPAT_b06FwBssAddr;
2457 fw.bss_len = bnx2_TPAT_b06FwBssLen;
2458 fw.bss_index = 0;
2459 fw.bss = bnx2_TPAT_b06FwBss;
2460
2461 fw.rodata_addr = bnx2_TPAT_b06FwRodataAddr;
2462 fw.rodata_len = bnx2_TPAT_b06FwRodataLen;
2463 fw.rodata_index = 0;
2464 fw.rodata = bnx2_TPAT_b06FwRodata;
2465
2466 load_cpu_fw(bp, &cpu_reg, &fw);
2467
2468 /* Initialize the Completion Processor. */ 2473 /* Initialize the Completion Processor. */
2469 cpu_reg.mode = BNX2_COM_CPU_MODE; 2474 cpu_reg.mode = BNX2_COM_CPU_MODE;
2470 cpu_reg.mode_value_halt = BNX2_COM_CPU_MODE_SOFT_HALT; 2475 cpu_reg.mode_value_halt = BNX2_COM_CPU_MODE_SOFT_HALT;
@@ -2479,44 +2484,36 @@ bnx2_init_cpus(struct bnx2 *bp)
2479 cpu_reg.spad_base = BNX2_COM_SCRATCH; 2484 cpu_reg.spad_base = BNX2_COM_SCRATCH;
2480 cpu_reg.mips_view_base = 0x8000000; 2485 cpu_reg.mips_view_base = 0x8000000;
2481 2486
2482 fw.ver_major = bnx2_COM_b06FwReleaseMajor; 2487 if (CHIP_NUM(bp) == CHIP_NUM_5709)
2483 fw.ver_minor = bnx2_COM_b06FwReleaseMinor; 2488 fw = &bnx2_com_fw_09;
2484 fw.ver_fix = bnx2_COM_b06FwReleaseFix; 2489 else
2485 fw.start_addr = bnx2_COM_b06FwStartAddr; 2490 fw = &bnx2_com_fw_06;
2486
2487 fw.text_addr = bnx2_COM_b06FwTextAddr;
2488 fw.text_len = bnx2_COM_b06FwTextLen;
2489 fw.text_index = 0;
2490 2491
2491 rc = bnx2_gunzip(bp, bnx2_COM_b06FwText, sizeof(bnx2_COM_b06FwText), 2492 rc = load_cpu_fw(bp, &cpu_reg, fw);
2492 &text, &text_len);
2493 if (rc) 2493 if (rc)
2494 goto init_cpu_err; 2494 goto init_cpu_err;
2495 2495
2496 fw.text = text; 2496 /* Initialize the Command Processor. */
2497 2497 cpu_reg.mode = BNX2_CP_CPU_MODE;
2498 fw.data_addr = bnx2_COM_b06FwDataAddr; 2498 cpu_reg.mode_value_halt = BNX2_CP_CPU_MODE_SOFT_HALT;
2499 fw.data_len = bnx2_COM_b06FwDataLen; 2499 cpu_reg.mode_value_sstep = BNX2_CP_CPU_MODE_STEP_ENA;
2500 fw.data_index = 0; 2500 cpu_reg.state = BNX2_CP_CPU_STATE;
2501 fw.data = bnx2_COM_b06FwData; 2501 cpu_reg.state_value_clear = 0xffffff;
2502 2502 cpu_reg.gpr0 = BNX2_CP_CPU_REG_FILE;
2503 fw.sbss_addr = bnx2_COM_b06FwSbssAddr; 2503 cpu_reg.evmask = BNX2_CP_CPU_EVENT_MASK;
2504 fw.sbss_len = bnx2_COM_b06FwSbssLen; 2504 cpu_reg.pc = BNX2_CP_CPU_PROGRAM_COUNTER;
2505 fw.sbss_index = 0; 2505 cpu_reg.inst = BNX2_CP_CPU_INSTRUCTION;
2506 fw.sbss = bnx2_COM_b06FwSbss; 2506 cpu_reg.bp = BNX2_CP_CPU_HW_BREAKPOINT;
2507 2507 cpu_reg.spad_base = BNX2_CP_SCRATCH;
2508 fw.bss_addr = bnx2_COM_b06FwBssAddr; 2508 cpu_reg.mips_view_base = 0x8000000;
2509 fw.bss_len = bnx2_COM_b06FwBssLen;
2510 fw.bss_index = 0;
2511 fw.bss = bnx2_COM_b06FwBss;
2512
2513 fw.rodata_addr = bnx2_COM_b06FwRodataAddr;
2514 fw.rodata_len = bnx2_COM_b06FwRodataLen;
2515 fw.rodata_index = 0;
2516 fw.rodata = bnx2_COM_b06FwRodata;
2517 2509
2518 load_cpu_fw(bp, &cpu_reg, &fw); 2510 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
2511 fw = &bnx2_cp_fw_09;
2519 2512
2513 load_cpu_fw(bp, &cpu_reg, fw);
2514 if (rc)
2515 goto init_cpu_err;
2516 }
2520init_cpu_err: 2517init_cpu_err:
2521 bnx2_gunzip_end(bp); 2518 bnx2_gunzip_end(bp);
2522 return rc; 2519 return rc;
@@ -3288,31 +3285,44 @@ bnx2_reset_chip(struct bnx2 *bp, u32 reset_code)
3288 * before we issue a reset. */ 3285 * before we issue a reset. */
3289 val = REG_RD(bp, BNX2_MISC_ID); 3286 val = REG_RD(bp, BNX2_MISC_ID);
3290 3287
3291 val = BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ | 3288 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
3292 BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA | 3289 REG_WR(bp, BNX2_MISC_COMMAND, BNX2_MISC_COMMAND_SW_RESET);
3293 BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP; 3290 REG_RD(bp, BNX2_MISC_COMMAND);
3291 udelay(5);
3294 3292
3295 /* Chip reset. */ 3293 val = BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA |
3296 REG_WR(bp, BNX2_PCICFG_MISC_CONFIG, val); 3294 BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP;
3297 3295
3298 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) || 3296 pci_write_config_dword(bp->pdev, BNX2_PCICFG_MISC_CONFIG, val);
3299 (CHIP_ID(bp) == CHIP_ID_5706_A1))
3300 msleep(15);
3301 3297
3302 /* Reset takes approximate 30 usec */ 3298 } else {
3303 for (i = 0; i < 10; i++) { 3299 val = BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
3304 val = REG_RD(bp, BNX2_PCICFG_MISC_CONFIG); 3300 BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA |
3305 if ((val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ | 3301 BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP;
3306 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) == 0) { 3302
3307 break; 3303 /* Chip reset. */
3304 REG_WR(bp, BNX2_PCICFG_MISC_CONFIG, val);
3305
3306 if ((CHIP_ID(bp) == CHIP_ID_5706_A0) ||
3307 (CHIP_ID(bp) == CHIP_ID_5706_A1)) {
3308 current->state = TASK_UNINTERRUPTIBLE;
3309 schedule_timeout(HZ / 50);
3308 } 3310 }
3309 udelay(10);
3310 }
3311 3311
3312 if (val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ | 3312 /* Reset takes approximate 30 usec */
3313 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) { 3313 for (i = 0; i < 10; i++) {
3314 printk(KERN_ERR PFX "Chip reset did not complete\n"); 3314 val = REG_RD(bp, BNX2_PCICFG_MISC_CONFIG);
3315 return -EBUSY; 3315 if ((val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
3316 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) == 0)
3317 break;
3318 udelay(10);
3319 }
3320
3321 if (val & (BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ |
3322 BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY)) {
3323 printk(KERN_ERR PFX "Chip reset did not complete\n");
3324 return -EBUSY;
3325 }
3316 } 3326 }
3317 3327
3318 /* Make sure byte swapping is properly configured. */ 3328 /* Make sure byte swapping is properly configured. */
@@ -3390,7 +3400,10 @@ bnx2_init_chip(struct bnx2 *bp)
3390 3400
3391 /* Initialize context mapping and zero out the quick contexts. The 3401 /* Initialize context mapping and zero out the quick contexts. The
3392 * context block must have already been enabled. */ 3402 * context block must have already been enabled. */
3393 bnx2_init_context(bp); 3403 if (CHIP_NUM(bp) == CHIP_NUM_5709)
3404 bnx2_init_5709_context(bp);
3405 else
3406 bnx2_init_context(bp);
3394 3407
3395 if ((rc = bnx2_init_cpus(bp)) != 0) 3408 if ((rc = bnx2_init_cpus(bp)) != 0)
3396 return rc; 3409 return rc;
@@ -3501,12 +3514,40 @@ bnx2_init_chip(struct bnx2 *bp)
3501 return rc; 3514 return rc;
3502} 3515}
3503 3516
3517static void
3518bnx2_init_tx_context(struct bnx2 *bp, u32 cid)
3519{
3520 u32 val, offset0, offset1, offset2, offset3;
3521
3522 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
3523 offset0 = BNX2_L2CTX_TYPE_XI;
3524 offset1 = BNX2_L2CTX_CMD_TYPE_XI;
3525 offset2 = BNX2_L2CTX_TBDR_BHADDR_HI_XI;
3526 offset3 = BNX2_L2CTX_TBDR_BHADDR_LO_XI;
3527 } else {
3528 offset0 = BNX2_L2CTX_TYPE;
3529 offset1 = BNX2_L2CTX_CMD_TYPE;
3530 offset2 = BNX2_L2CTX_TBDR_BHADDR_HI;
3531 offset3 = BNX2_L2CTX_TBDR_BHADDR_LO;
3532 }
3533 val = BNX2_L2CTX_TYPE_TYPE_L2 | BNX2_L2CTX_TYPE_SIZE_L2;
3534 CTX_WR(bp, GET_CID_ADDR(cid), offset0, val);
3535
3536 val = BNX2_L2CTX_CMD_TYPE_TYPE_L2 | (8 << 16);
3537 CTX_WR(bp, GET_CID_ADDR(cid), offset1, val);
3538
3539 val = (u64) bp->tx_desc_mapping >> 32;
3540 CTX_WR(bp, GET_CID_ADDR(cid), offset2, val);
3541
3542 val = (u64) bp->tx_desc_mapping & 0xffffffff;
3543 CTX_WR(bp, GET_CID_ADDR(cid), offset3, val);
3544}
3504 3545
3505static void 3546static void
3506bnx2_init_tx_ring(struct bnx2 *bp) 3547bnx2_init_tx_ring(struct bnx2 *bp)
3507{ 3548{
3508 struct tx_bd *txbd; 3549 struct tx_bd *txbd;
3509 u32 val; 3550 u32 cid;
3510 3551
3511 bp->tx_wake_thresh = bp->tx_ring_size / 2; 3552 bp->tx_wake_thresh = bp->tx_ring_size / 2;
3512 3553
@@ -3520,19 +3561,11 @@ bnx2_init_tx_ring(struct bnx2 *bp)
3520 bp->hw_tx_cons = 0; 3561 bp->hw_tx_cons = 0;
3521 bp->tx_prod_bseq = 0; 3562 bp->tx_prod_bseq = 0;
3522 3563
3523 val = BNX2_L2CTX_TYPE_TYPE_L2; 3564 cid = TX_CID;
3524 val |= BNX2_L2CTX_TYPE_SIZE_L2; 3565 bp->tx_bidx_addr = MB_GET_CID_ADDR(cid) + BNX2_L2CTX_TX_HOST_BIDX;
3525 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TYPE, val); 3566 bp->tx_bseq_addr = MB_GET_CID_ADDR(cid) + BNX2_L2CTX_TX_HOST_BSEQ;
3526 3567
3527 val = BNX2_L2CTX_CMD_TYPE_TYPE_L2; 3568 bnx2_init_tx_context(bp, cid);
3528 val |= 8 << 16;
3529 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_CMD_TYPE, val);
3530
3531 val = (u64) bp->tx_desc_mapping >> 32;
3532 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TBDR_BHADDR_HI, val);
3533
3534 val = (u64) bp->tx_desc_mapping & 0xffffffff;
3535 CTX_WR(bp, GET_CID_ADDR(TX_CID), BNX2_L2CTX_TBDR_BHADDR_LO, val);
3536} 3569}
3537 3570
3538static void 3571static void
@@ -3545,8 +3578,8 @@ bnx2_init_rx_ring(struct bnx2 *bp)
3545 3578
3546 /* 8 for CRC and VLAN */ 3579 /* 8 for CRC and VLAN */
3547 bp->rx_buf_use_size = bp->dev->mtu + ETH_HLEN + bp->rx_offset + 8; 3580 bp->rx_buf_use_size = bp->dev->mtu + ETH_HLEN + bp->rx_offset + 8;
3548 /* 8 for alignment */ 3581 /* hw alignment */
3549 bp->rx_buf_size = bp->rx_buf_use_size + 8; 3582 bp->rx_buf_size = bp->rx_buf_use_size + BNX2_RX_ALIGN;
3550 3583
3551 ring_prod = prod = bp->rx_prod = 0; 3584 ring_prod = prod = bp->rx_prod = 0;
3552 bp->rx_cons = 0; 3585 bp->rx_cons = 0;
@@ -3712,7 +3745,9 @@ bnx2_init_nic(struct bnx2 *bp)
3712 if ((rc = bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET)) != 0) 3745 if ((rc = bnx2_reset_nic(bp, BNX2_DRV_MSG_CODE_RESET)) != 0)
3713 return rc; 3746 return rc;
3714 3747
3748 spin_lock_bh(&bp->phy_lock);
3715 bnx2_init_phy(bp); 3749 bnx2_init_phy(bp);
3750 spin_unlock_bh(&bp->phy_lock);
3716 bnx2_set_link(bp); 3751 bnx2_set_link(bp);
3717 return 0; 3752 return 0;
3718} 3753}
@@ -3952,7 +3987,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
3952 bnx2_set_mac_loopback(bp); 3987 bnx2_set_mac_loopback(bp);
3953 } 3988 }
3954 else if (loopback_mode == BNX2_PHY_LOOPBACK) { 3989 else if (loopback_mode == BNX2_PHY_LOOPBACK) {
3955 bp->loopback = 0; 3990 bp->loopback = PHY_LOOPBACK;
3956 bnx2_set_phy_loopback(bp); 3991 bnx2_set_phy_loopback(bp);
3957 } 3992 }
3958 else 3993 else
@@ -3992,8 +4027,8 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
3992 bp->tx_prod = NEXT_TX_BD(bp->tx_prod); 4027 bp->tx_prod = NEXT_TX_BD(bp->tx_prod);
3993 bp->tx_prod_bseq += pkt_size; 4028 bp->tx_prod_bseq += pkt_size;
3994 4029
3995 REG_WR16(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BIDX, bp->tx_prod); 4030 REG_WR16(bp, bp->tx_bidx_addr, bp->tx_prod);
3996 REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, bp->tx_prod_bseq); 4031 REG_WR(bp, bp->tx_bseq_addr, bp->tx_prod_bseq);
3997 4032
3998 udelay(100); 4033 udelay(100);
3999 4034
@@ -4162,80 +4197,117 @@ bnx2_test_intr(struct bnx2 *bp)
4162} 4197}
4163 4198
4164static void 4199static void
4165bnx2_timer(unsigned long data) 4200bnx2_5706_serdes_timer(struct bnx2 *bp)
4166{ 4201{
4167 struct bnx2 *bp = (struct bnx2 *) data; 4202 spin_lock(&bp->phy_lock);
4168 u32 msg; 4203 if (bp->serdes_an_pending)
4204 bp->serdes_an_pending--;
4205 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
4206 u32 bmcr;
4169 4207
4170 if (!netif_running(bp->dev)) 4208 bp->current_interval = bp->timer_interval;
4171 return;
4172 4209
4173 if (atomic_read(&bp->intr_sem) != 0) 4210 bnx2_read_phy(bp, MII_BMCR, &bmcr);
4174 goto bnx2_restart_timer;
4175 4211
4176 msg = (u32) ++bp->fw_drv_pulse_wr_seq; 4212 if (bmcr & BMCR_ANENABLE) {
4177 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg); 4213 u32 phy1, phy2;
4178 4214
4179 bp->stats_blk->stat_FwRxDrop = REG_RD_IND(bp, BNX2_FW_RX_DROP_COUNT); 4215 bnx2_write_phy(bp, 0x1c, 0x7c00);
4216 bnx2_read_phy(bp, 0x1c, &phy1);
4180 4217
4181 if ((bp->phy_flags & PHY_SERDES_FLAG) && 4218 bnx2_write_phy(bp, 0x17, 0x0f01);
4182 (CHIP_NUM(bp) == CHIP_NUM_5706)) { 4219 bnx2_read_phy(bp, 0x15, &phy2);
4220 bnx2_write_phy(bp, 0x17, 0x0f01);
4221 bnx2_read_phy(bp, 0x15, &phy2);
4183 4222
4184 spin_lock(&bp->phy_lock); 4223 if ((phy1 & 0x10) && /* SIGNAL DETECT */
4185 if (bp->serdes_an_pending) { 4224 !(phy2 & 0x20)) { /* no CONFIG */
4186 bp->serdes_an_pending--; 4225
4226 bmcr &= ~BMCR_ANENABLE;
4227 bmcr |= BMCR_SPEED1000 | BMCR_FULLDPLX;
4228 bnx2_write_phy(bp, MII_BMCR, bmcr);
4229 bp->phy_flags |= PHY_PARALLEL_DETECT_FLAG;
4230 }
4187 } 4231 }
4188 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) { 4232 }
4189 u32 bmcr; 4233 else if ((bp->link_up) && (bp->autoneg & AUTONEG_SPEED) &&
4234 (bp->phy_flags & PHY_PARALLEL_DETECT_FLAG)) {
4235 u32 phy2;
4190 4236
4191 bp->current_interval = bp->timer_interval; 4237 bnx2_write_phy(bp, 0x17, 0x0f01);
4238 bnx2_read_phy(bp, 0x15, &phy2);
4239 if (phy2 & 0x20) {
4240 u32 bmcr;
4192 4241
4193 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4242 bnx2_read_phy(bp, MII_BMCR, &bmcr);
4243 bmcr |= BMCR_ANENABLE;
4244 bnx2_write_phy(bp, MII_BMCR, bmcr);
4194 4245
4195 if (bmcr & BMCR_ANENABLE) { 4246 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG;
4196 u32 phy1, phy2; 4247 }
4248 } else
4249 bp->current_interval = bp->timer_interval;
4197 4250
4198 bnx2_write_phy(bp, 0x1c, 0x7c00); 4251 spin_unlock(&bp->phy_lock);
4199 bnx2_read_phy(bp, 0x1c, &phy1); 4252}
4200 4253
4201 bnx2_write_phy(bp, 0x17, 0x0f01); 4254static void
4202 bnx2_read_phy(bp, 0x15, &phy2); 4255bnx2_5708_serdes_timer(struct bnx2 *bp)
4203 bnx2_write_phy(bp, 0x17, 0x0f01); 4256{
4204 bnx2_read_phy(bp, 0x15, &phy2); 4257 if ((bp->phy_flags & PHY_2_5G_CAPABLE_FLAG) == 0) {
4258 bp->serdes_an_pending = 0;
4259 return;
4260 }
4205 4261
4206 if ((phy1 & 0x10) && /* SIGNAL DETECT */ 4262 spin_lock(&bp->phy_lock);
4207 !(phy2 & 0x20)) { /* no CONFIG */ 4263 if (bp->serdes_an_pending)
4264 bp->serdes_an_pending--;
4265 else if ((bp->link_up == 0) && (bp->autoneg & AUTONEG_SPEED)) {
4266 u32 bmcr;
4208 4267
4209 bmcr &= ~BMCR_ANENABLE; 4268 bnx2_read_phy(bp, MII_BMCR, &bmcr);
4210 bmcr |= BMCR_SPEED1000 | 4269
4211 BMCR_FULLDPLX; 4270 if (bmcr & BMCR_ANENABLE) {
4212 bnx2_write_phy(bp, MII_BMCR, bmcr); 4271 bmcr &= ~BMCR_ANENABLE;
4213 bp->phy_flags |= 4272 bmcr |= BMCR_FULLDPLX | BCM5708S_BMCR_FORCE_2500;
4214 PHY_PARALLEL_DETECT_FLAG; 4273 bnx2_write_phy(bp, MII_BMCR, bmcr);
4215 } 4274 bp->current_interval = SERDES_FORCED_TIMEOUT;
4216 } 4275 } else {
4276 bmcr &= ~(BMCR_FULLDPLX | BCM5708S_BMCR_FORCE_2500);
4277 bmcr |= BMCR_ANENABLE;
4278 bnx2_write_phy(bp, MII_BMCR, bmcr);
4279 bp->serdes_an_pending = 2;
4280 bp->current_interval = bp->timer_interval;
4217 } 4281 }
4218 else if ((bp->link_up) && (bp->autoneg & AUTONEG_SPEED) &&
4219 (bp->phy_flags & PHY_PARALLEL_DETECT_FLAG)) {
4220 u32 phy2;
4221 4282
4222 bnx2_write_phy(bp, 0x17, 0x0f01); 4283 } else
4223 bnx2_read_phy(bp, 0x15, &phy2); 4284 bp->current_interval = bp->timer_interval;
4224 if (phy2 & 0x20) {
4225 u32 bmcr;
4226 4285
4227 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4286 spin_unlock(&bp->phy_lock);
4228 bmcr |= BMCR_ANENABLE; 4287}
4229 bnx2_write_phy(bp, MII_BMCR, bmcr); 4288
4289static void
4290bnx2_timer(unsigned long data)
4291{
4292 struct bnx2 *bp = (struct bnx2 *) data;
4293 u32 msg;
4230 4294
4231 bp->phy_flags &= ~PHY_PARALLEL_DETECT_FLAG; 4295 if (!netif_running(bp->dev))
4296 return;
4232 4297
4233 } 4298 if (atomic_read(&bp->intr_sem) != 0)
4234 } 4299 goto bnx2_restart_timer;
4235 else
4236 bp->current_interval = bp->timer_interval;
4237 4300
4238 spin_unlock(&bp->phy_lock); 4301 msg = (u32) ++bp->fw_drv_pulse_wr_seq;
4302 REG_WR_IND(bp, bp->shmem_base + BNX2_DRV_PULSE_MB, msg);
4303
4304 bp->stats_blk->stat_FwRxDrop = REG_RD_IND(bp, BNX2_FW_RX_DROP_COUNT);
4305
4306 if (bp->phy_flags & PHY_SERDES_FLAG) {
4307 if (CHIP_NUM(bp) == CHIP_NUM_5706)
4308 bnx2_5706_serdes_timer(bp);
4309 else if (CHIP_NUM(bp) == CHIP_NUM_5708)
4310 bnx2_5708_serdes_timer(bp);
4239 } 4311 }
4240 4312
4241bnx2_restart_timer: 4313bnx2_restart_timer:
@@ -4508,8 +4580,8 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4508 prod = NEXT_TX_BD(prod); 4580 prod = NEXT_TX_BD(prod);
4509 bp->tx_prod_bseq += skb->len; 4581 bp->tx_prod_bseq += skb->len;
4510 4582
4511 REG_WR16(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BIDX, prod); 4583 REG_WR16(bp, bp->tx_bidx_addr, prod);
4512 REG_WR(bp, MB_TX_CID_ADDR + BNX2_L2CTX_TX_HOST_BSEQ, bp->tx_prod_bseq); 4584 REG_WR(bp, bp->tx_bseq_addr, bp->tx_prod_bseq);
4513 4585
4514 mmiowb(); 4586 mmiowb();
4515 4587
@@ -4743,10 +4815,14 @@ bnx2_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
4743 } 4815 }
4744 else { 4816 else {
4745 if (bp->phy_flags & PHY_SERDES_FLAG) { 4817 if (bp->phy_flags & PHY_SERDES_FLAG) {
4746 if ((cmd->speed != SPEED_1000) || 4818 if ((cmd->speed != SPEED_1000 &&
4747 (cmd->duplex != DUPLEX_FULL)) { 4819 cmd->speed != SPEED_2500) ||
4820 (cmd->duplex != DUPLEX_FULL))
4821 return -EINVAL;
4822
4823 if (cmd->speed == SPEED_2500 &&
4824 !(bp->phy_flags & PHY_2_5G_CAPABLE_FLAG))
4748 return -EINVAL; 4825 return -EINVAL;
4749 }
4750 } 4826 }
4751 else if (cmd->speed == SPEED_1000) { 4827 else if (cmd->speed == SPEED_1000) {
4752 return -EINVAL; 4828 return -EINVAL;
@@ -4903,11 +4979,10 @@ bnx2_nway_reset(struct net_device *dev)
4903 msleep(20); 4979 msleep(20);
4904 4980
4905 spin_lock_bh(&bp->phy_lock); 4981 spin_lock_bh(&bp->phy_lock);
4906 if (CHIP_NUM(bp) == CHIP_NUM_5706) { 4982
4907 bp->current_interval = SERDES_AN_TIMEOUT; 4983 bp->current_interval = SERDES_AN_TIMEOUT;
4908 bp->serdes_an_pending = 1; 4984 bp->serdes_an_pending = 1;
4909 mod_timer(&bp->timer, jiffies + bp->current_interval); 4985 mod_timer(&bp->timer, jiffies + bp->current_interval);
4910 }
4911 } 4986 }
4912 4987
4913 bnx2_read_phy(bp, MII_BMCR, &bmcr); 4988 bnx2_read_phy(bp, MII_BMCR, &bmcr);
@@ -5288,6 +5363,8 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
5288 5363
5289 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS); 5364 memset(buf, 0, sizeof(u64) * BNX2_NUM_TESTS);
5290 if (etest->flags & ETH_TEST_FL_OFFLINE) { 5365 if (etest->flags & ETH_TEST_FL_OFFLINE) {
5366 int i;
5367
5291 bnx2_netif_stop(bp); 5368 bnx2_netif_stop(bp);
5292 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG); 5369 bnx2_reset_chip(bp, BNX2_DRV_MSG_CODE_DIAG);
5293 bnx2_free_skbs(bp); 5370 bnx2_free_skbs(bp);
@@ -5312,9 +5389,11 @@ bnx2_self_test(struct net_device *dev, struct ethtool_test *etest, u64 *buf)
5312 } 5389 }
5313 5390
5314 /* wait for link up */ 5391 /* wait for link up */
5315 msleep_interruptible(3000); 5392 for (i = 0; i < 7; i++) {
5316 if ((!bp->link_up) && !(bp->phy_flags & PHY_SERDES_FLAG)) 5393 if (bp->link_up)
5317 msleep_interruptible(4000); 5394 break;
5395 msleep_interruptible(1000);
5396 }
5318 } 5397 }
5319 5398
5320 if (bnx2_test_nvram(bp) != 0) { 5399 if (bnx2_test_nvram(bp) != 0) {
@@ -5604,13 +5683,6 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5604 goto err_out_release; 5683 goto err_out_release;
5605 } 5684 }
5606 5685
5607 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
5608 if (bp->pcix_cap == 0) {
5609 dev_err(&pdev->dev, "Cannot find PCIX capability, aborting.\n");
5610 rc = -EIO;
5611 goto err_out_release;
5612 }
5613
5614 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) { 5686 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
5615 bp->flags |= USING_DAC_FLAG; 5687 bp->flags |= USING_DAC_FLAG;
5616 if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) { 5688 if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) {
@@ -5633,7 +5705,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5633 INIT_WORK(&bp->reset_task, bnx2_reset_task); 5705 INIT_WORK(&bp->reset_task, bnx2_reset_task);
5634 5706
5635 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0); 5707 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
5636 mem_len = MB_GET_CID_ADDR(17); 5708 mem_len = MB_GET_CID_ADDR(TX_TSS_CID + 1);
5637 dev->mem_end = dev->mem_start + mem_len; 5709 dev->mem_end = dev->mem_start + mem_len;
5638 dev->irq = pdev->irq; 5710 dev->irq = pdev->irq;
5639 5711
@@ -5657,6 +5729,16 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5657 5729
5658 bp->chip_id = REG_RD(bp, BNX2_MISC_ID); 5730 bp->chip_id = REG_RD(bp, BNX2_MISC_ID);
5659 5731
5732 if (CHIP_NUM(bp) != CHIP_NUM_5709) {
5733 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
5734 if (bp->pcix_cap == 0) {
5735 dev_err(&pdev->dev,
5736 "Cannot find PCIX capability, aborting.\n");
5737 rc = -EIO;
5738 goto err_out_unmap;
5739 }
5740 }
5741
5660 /* Get bus information. */ 5742 /* Get bus information. */
5661 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS); 5743 reg = REG_RD(bp, BNX2_PCICFG_MISC_STATUS);
5662 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) { 5744 if (reg & BNX2_PCICFG_MISC_STATUS_PCIX_DET) {
@@ -5776,10 +5858,15 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5776 bp->phy_addr = 1; 5858 bp->phy_addr = 1;
5777 5859
5778 /* Disable WOL support if we are running on a SERDES chip. */ 5860 /* Disable WOL support if we are running on a SERDES chip. */
5779 if (CHIP_BOND_ID(bp) & CHIP_BOND_ID_SERDES_BIT) { 5861 if (CHIP_NUM(bp) == CHIP_NUM_5709) {
5862 if (CHIP_BOND_ID(bp) != BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID_C)
5863 bp->phy_flags |= PHY_SERDES_FLAG;
5864 } else if (CHIP_BOND_ID(bp) & CHIP_BOND_ID_SERDES_BIT)
5780 bp->phy_flags |= PHY_SERDES_FLAG; 5865 bp->phy_flags |= PHY_SERDES_FLAG;
5866
5867 if (bp->phy_flags & PHY_SERDES_FLAG) {
5781 bp->flags |= NO_WOL_FLAG; 5868 bp->flags |= NO_WOL_FLAG;
5782 if (CHIP_NUM(bp) == CHIP_NUM_5708) { 5869 if (CHIP_NUM(bp) != CHIP_NUM_5706) {
5783 bp->phy_addr = 2; 5870 bp->phy_addr = 2;
5784 reg = REG_RD_IND(bp, bp->shmem_base + 5871 reg = REG_RD_IND(bp, bp->shmem_base +
5785 BNX2_SHARED_HW_CFG_CONFIG); 5872 BNX2_SHARED_HW_CFG_CONFIG);
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index ca31904893ea..13b6f9b11e01 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -56,6 +56,7 @@ struct rx_bd {
56 56
57}; 57};
58 58
59#define BNX2_RX_ALIGN 16
59 60
60/* 61/*
61 * status_block definition 62 * status_block definition
@@ -90,6 +91,7 @@ struct status_block {
90 #define STATUS_ATTN_BITS_DMAE_ABORT (1L<<25) 91 #define STATUS_ATTN_BITS_DMAE_ABORT (1L<<25)
91 #define STATUS_ATTN_BITS_FLSH_ABORT (1L<<26) 92 #define STATUS_ATTN_BITS_FLSH_ABORT (1L<<26)
92 #define STATUS_ATTN_BITS_GRC_ABORT (1L<<27) 93 #define STATUS_ATTN_BITS_GRC_ABORT (1L<<27)
94 #define STATUS_ATTN_BITS_EPB_ERROR (1L<<30)
93 #define STATUS_ATTN_BITS_PARITY_ERROR (1L<<31) 95 #define STATUS_ATTN_BITS_PARITY_ERROR (1L<<31)
94 96
95 u32 status_attn_bits_ack; 97 u32 status_attn_bits_ack;
@@ -117,7 +119,8 @@ struct status_block {
117 u16 status_completion_producer_index; 119 u16 status_completion_producer_index;
118 u16 status_cmd_consumer_index; 120 u16 status_cmd_consumer_index;
119 u16 status_idx; 121 u16 status_idx;
120 u16 status_unused; 122 u8 status_unused;
123 u8 status_blk_num;
121#elif defined(__LITTLE_ENDIAN) 124#elif defined(__LITTLE_ENDIAN)
122 u16 status_tx_quick_consumer_index1; 125 u16 status_tx_quick_consumer_index1;
123 u16 status_tx_quick_consumer_index0; 126 u16 status_tx_quick_consumer_index0;
@@ -141,7 +144,8 @@ struct status_block {
141 u16 status_rx_quick_consumer_index14; 144 u16 status_rx_quick_consumer_index14;
142 u16 status_cmd_consumer_index; 145 u16 status_cmd_consumer_index;
143 u16 status_completion_producer_index; 146 u16 status_completion_producer_index;
144 u16 status_unused; 147 u8 status_blk_num;
148 u8 status_unused;
145 u16 status_idx; 149 u16 status_idx;
146#endif 150#endif
147}; 151};
@@ -301,6 +305,10 @@ struct l2_fhdr {
301#define BNX2_L2CTX_TXP_BIDX 0x000000a8 305#define BNX2_L2CTX_TXP_BIDX 0x000000a8
302#define BNX2_L2CTX_TXP_BSEQ 0x000000ac 306#define BNX2_L2CTX_TXP_BSEQ 0x000000ac
303 307
308#define BNX2_L2CTX_TYPE_XI 0x00000080
309#define BNX2_L2CTX_CMD_TYPE_XI 0x00000240
310#define BNX2_L2CTX_TBDR_BHADDR_HI_XI 0x00000258
311#define BNX2_L2CTX_TBDR_BHADDR_LO_XI 0x0000025c
304 312
305/* 313/*
306 * l2_bd_chain_context definition 314 * l2_bd_chain_context definition
@@ -328,11 +336,15 @@ struct l2_fhdr {
328#define BNX2_PCICFG_MISC_CONFIG 0x00000068 336#define BNX2_PCICFG_MISC_CONFIG 0x00000068
329#define BNX2_PCICFG_MISC_CONFIG_TARGET_BYTE_SWAP (1L<<2) 337#define BNX2_PCICFG_MISC_CONFIG_TARGET_BYTE_SWAP (1L<<2)
330#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP (1L<<3) 338#define BNX2_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP (1L<<3)
339#define BNX2_PCICFG_MISC_CONFIG_RESERVED1 (1L<<4)
331#define BNX2_PCICFG_MISC_CONFIG_CLOCK_CTL_ENA (1L<<5) 340#define BNX2_PCICFG_MISC_CONFIG_CLOCK_CTL_ENA (1L<<5)
332#define BNX2_PCICFG_MISC_CONFIG_TARGET_GRC_WORD_SWAP (1L<<6) 341#define BNX2_PCICFG_MISC_CONFIG_TARGET_GRC_WORD_SWAP (1L<<6)
333#define BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA (1L<<7) 342#define BNX2_PCICFG_MISC_CONFIG_REG_WINDOW_ENA (1L<<7)
334#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ (1L<<8) 343#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_REQ (1L<<8)
335#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY (1L<<9) 344#define BNX2_PCICFG_MISC_CONFIG_CORE_RST_BSY (1L<<9)
345#define BNX2_PCICFG_MISC_CONFIG_GRC_WIN1_SWAP_EN (1L<<10)
346#define BNX2_PCICFG_MISC_CONFIG_GRC_WIN2_SWAP_EN (1L<<11)
347#define BNX2_PCICFG_MISC_CONFIG_GRC_WIN3_SWAP_EN (1L<<12)
336#define BNX2_PCICFG_MISC_CONFIG_ASIC_METAL_REV (0xffL<<16) 348#define BNX2_PCICFG_MISC_CONFIG_ASIC_METAL_REV (0xffL<<16)
337#define BNX2_PCICFG_MISC_CONFIG_ASIC_BASE_REV (0xfL<<24) 349#define BNX2_PCICFG_MISC_CONFIG_ASIC_BASE_REV (0xfL<<24)
338#define BNX2_PCICFG_MISC_CONFIG_ASIC_ID (0xfL<<28) 350#define BNX2_PCICFG_MISC_CONFIG_ASIC_ID (0xfL<<28)
@@ -347,6 +359,7 @@ struct l2_fhdr {
347#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_100 (1L<<4) 359#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_100 (1L<<4)
348#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_133 (2L<<4) 360#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_133 (2L<<4)
349#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_PCI_MODE (3L<<4) 361#define BNX2_PCICFG_MISC_STATUS_PCIX_SPEED_PCI_MODE (3L<<4)
362#define BNX2_PCICFG_MISC_STATUS_BAD_MEM_WRITE_BE (1L<<8)
350 363
351#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS 0x00000070 364#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS 0x00000070
352#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0) 365#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0)
@@ -366,7 +379,7 @@ struct l2_fhdr {
366#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8) 379#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8)
367#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8) 380#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8)
368#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8) 381#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8)
369#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PLAY_DEAD (1L<<11) 382#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_MIN_POWER (1L<<11)
370#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12) 383#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12)
371#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12) 384#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12)
372#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12) 385#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12)
@@ -374,18 +387,21 @@ struct l2_fhdr {
374#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12) 387#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12)
375#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12) 388#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12)
376#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16) 389#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16)
377#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_PCI_PLL_STOP (1L<<17) 390#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_17 (1L<<17)
378#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_18 (1L<<18) 391#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_18 (1L<<18)
379#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_USE_SPD_DET (1L<<19) 392#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED_19 (1L<<19)
380#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED (0xfffL<<20) 393#define BNX2_PCICFG_PCI_CLOCK_CONTROL_BITS_RESERVED (0xfffL<<20)
381 394
382#define BNX2_PCICFG_REG_WINDOW_ADDRESS 0x00000078 395#define BNX2_PCICFG_REG_WINDOW_ADDRESS 0x00000078
396#define BNX2_PCICFG_REG_WINDOW_ADDRESS_VAL (0xfffffL<<2)
397
383#define BNX2_PCICFG_REG_WINDOW 0x00000080 398#define BNX2_PCICFG_REG_WINDOW 0x00000080
384#define BNX2_PCICFG_INT_ACK_CMD 0x00000084 399#define BNX2_PCICFG_INT_ACK_CMD 0x00000084
385#define BNX2_PCICFG_INT_ACK_CMD_INDEX (0xffffL<<0) 400#define BNX2_PCICFG_INT_ACK_CMD_INDEX (0xffffL<<0)
386#define BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID (1L<<16) 401#define BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID (1L<<16)
387#define BNX2_PCICFG_INT_ACK_CMD_USE_INT_HC_PARAM (1L<<17) 402#define BNX2_PCICFG_INT_ACK_CMD_USE_INT_HC_PARAM (1L<<17)
388#define BNX2_PCICFG_INT_ACK_CMD_MASK_INT (1L<<18) 403#define BNX2_PCICFG_INT_ACK_CMD_MASK_INT (1L<<18)
404#define BNX2_PCICFG_INT_ACK_CMD_INTERRUPT_NUM (0xfL<<24)
389 405
390#define BNX2_PCICFG_STATUS_BIT_SET_CMD 0x00000088 406#define BNX2_PCICFG_STATUS_BIT_SET_CMD 0x00000088
391#define BNX2_PCICFG_STATUS_BIT_CLEAR_CMD 0x0000008c 407#define BNX2_PCICFG_STATUS_BIT_CLEAR_CMD 0x0000008c
@@ -398,9 +414,11 @@ struct l2_fhdr {
398 * offset: 0x400 414 * offset: 0x400
399 */ 415 */
400#define BNX2_PCI_GRC_WINDOW_ADDR 0x00000400 416#define BNX2_PCI_GRC_WINDOW_ADDR 0x00000400
401#define BNX2_PCI_GRC_WINDOW_ADDR_PCI_GRC_WINDOW_ADDR_VALUE (0x3ffffL<<8) 417#define BNX2_PCI_GRC_WINDOW_ADDR_VALUE (0x1ffL<<13)
418#define BNX2_PCI_GRC_WINDOW_ADDR_SEP_WIN (1L<<31)
402 419
403#define BNX2_PCI_CONFIG_1 0x00000404 420#define BNX2_PCI_CONFIG_1 0x00000404
421#define BNX2_PCI_CONFIG_1_RESERVED0 (0xffL<<0)
404#define BNX2_PCI_CONFIG_1_READ_BOUNDARY (0x7L<<8) 422#define BNX2_PCI_CONFIG_1_READ_BOUNDARY (0x7L<<8)
405#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_OFF (0L<<8) 423#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_OFF (0L<<8)
406#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_16 (1L<<8) 424#define BNX2_PCI_CONFIG_1_READ_BOUNDARY_16 (1L<<8)
@@ -419,6 +437,7 @@ struct l2_fhdr {
419#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_256 (5L<<11) 437#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_256 (5L<<11)
420#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_512 (6L<<11) 438#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_512 (6L<<11)
421#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_1024 (7L<<11) 439#define BNX2_PCI_CONFIG_1_WRITE_BOUNDARY_1024 (7L<<11)
440#define BNX2_PCI_CONFIG_1_RESERVED1 (0x3ffffL<<14)
422 441
423#define BNX2_PCI_CONFIG_2 0x00000408 442#define BNX2_PCI_CONFIG_2 0x00000408
424#define BNX2_PCI_CONFIG_2_BAR1_SIZE (0xfL<<0) 443#define BNX2_PCI_CONFIG_2_BAR1_SIZE (0xfL<<0)
@@ -468,9 +487,13 @@ struct l2_fhdr {
468#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_MSTR (1L<<23) 487#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_MSTR (1L<<23)
469#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_TGT (1L<<24) 488#define BNX2_PCI_CONFIG_2_FORCE_32_BIT_TGT (1L<<24)
470#define BNX2_PCI_CONFIG_2_KEEP_REQ_ASSERT (1L<<25) 489#define BNX2_PCI_CONFIG_2_KEEP_REQ_ASSERT (1L<<25)
490#define BNX2_PCI_CONFIG_2_RESERVED0 (0x3fL<<26)
491#define BNX2_PCI_CONFIG_2_BAR_PREFETCH_XI (1L<<16)
492#define BNX2_PCI_CONFIG_2_RESERVED0_XI (0x7fffL<<17)
471 493
472#define BNX2_PCI_CONFIG_3 0x0000040c 494#define BNX2_PCI_CONFIG_3 0x0000040c
473#define BNX2_PCI_CONFIG_3_STICKY_BYTE (0xffL<<0) 495#define BNX2_PCI_CONFIG_3_STICKY_BYTE (0xffL<<0)
496#define BNX2_PCI_CONFIG_3_REG_STICKY_BYTE (0xffL<<8)
474#define BNX2_PCI_CONFIG_3_FORCE_PME (1L<<24) 497#define BNX2_PCI_CONFIG_3_FORCE_PME (1L<<24)
475#define BNX2_PCI_CONFIG_3_PME_STATUS (1L<<25) 498#define BNX2_PCI_CONFIG_3_PME_STATUS (1L<<25)
476#define BNX2_PCI_CONFIG_3_PME_ENABLE (1L<<26) 499#define BNX2_PCI_CONFIG_3_PME_ENABLE (1L<<26)
@@ -501,8 +524,10 @@ struct l2_fhdr {
501#define BNX2_PCI_VPD_INTF_INTF_REQ (1L<<0) 524#define BNX2_PCI_VPD_INTF_INTF_REQ (1L<<0)
502 525
503#define BNX2_PCI_VPD_ADDR_FLAG 0x0000042c 526#define BNX2_PCI_VPD_ADDR_FLAG 0x0000042c
504#define BNX2_PCI_VPD_ADDR_FLAG_ADDRESS (0x1fff<<2) 527#define BNX2_PCI_VPD_ADDR_FLAG_MSK 0x0000ffff
505#define BNX2_PCI_VPD_ADDR_FLAG_WR (1<<15) 528#define BNX2_PCI_VPD_ADDR_FLAG_SL 0L
529#define BNX2_PCI_VPD_ADDR_FLAG_ADDRESS (0x1fffL<<2)
530#define BNX2_PCI_VPD_ADDR_FLAG_WR (1L<<15)
506 531
507#define BNX2_PCI_VPD_DATA 0x00000430 532#define BNX2_PCI_VPD_DATA 0x00000430
508#define BNX2_PCI_ID_VAL1 0x00000434 533#define BNX2_PCI_ID_VAL1 0x00000434
@@ -535,19 +560,26 @@ struct l2_fhdr {
535#define BNX2_PCI_ID_VAL4_CAP_ENA_13 (13L<<0) 560#define BNX2_PCI_ID_VAL4_CAP_ENA_13 (13L<<0)
536#define BNX2_PCI_ID_VAL4_CAP_ENA_14 (14L<<0) 561#define BNX2_PCI_ID_VAL4_CAP_ENA_14 (14L<<0)
537#define BNX2_PCI_ID_VAL4_CAP_ENA_15 (15L<<0) 562#define BNX2_PCI_ID_VAL4_CAP_ENA_15 (15L<<0)
563#define BNX2_PCI_ID_VAL4_RESERVED0 (0x3L<<4)
538#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG (0x3L<<6) 564#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG (0x3L<<6)
539#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_0 (0L<<6) 565#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_0 (0L<<6)
540#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_1 (1L<<6) 566#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_1 (1L<<6)
541#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_2 (2L<<6) 567#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_2 (2L<<6)
542#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_3 (3L<<6) 568#define BNX2_PCI_ID_VAL4_PM_SCALE_PRG_3 (3L<<6)
569#define BNX2_PCI_ID_VAL4_MSI_PV_MASK_CAP (1L<<8)
543#define BNX2_PCI_ID_VAL4_MSI_LIMIT (0x7L<<9) 570#define BNX2_PCI_ID_VAL4_MSI_LIMIT (0x7L<<9)
544#define BNX2_PCI_ID_VAL4_MSI_ADVERTIZE (0x7L<<12) 571#define BNX2_PCI_ID_VAL4_MULTI_MSG_CAP (0x7L<<12)
545#define BNX2_PCI_ID_VAL4_MSI_ENABLE (1L<<15) 572#define BNX2_PCI_ID_VAL4_MSI_ENABLE (1L<<15)
546#define BNX2_PCI_ID_VAL4_MAX_64_ADVERTIZE (1L<<16) 573#define BNX2_PCI_ID_VAL4_MAX_64_ADVERTIZE (1L<<16)
547#define BNX2_PCI_ID_VAL4_MAX_133_ADVERTIZE (1L<<17) 574#define BNX2_PCI_ID_VAL4_MAX_133_ADVERTIZE (1L<<17)
548#define BNX2_PCI_ID_VAL4_MAX_MEM_READ_SIZE (0x3L<<21) 575#define BNX2_PCI_ID_VAL4_RESERVED2 (0x7L<<18)
549#define BNX2_PCI_ID_VAL4_MAX_SPLIT_SIZE (0x7L<<23) 576#define BNX2_PCI_ID_VAL4_MAX_CUMULATIVE_SIZE_B21 (0x3L<<21)
550#define BNX2_PCI_ID_VAL4_MAX_CUMULATIVE_SIZE (0x7L<<26) 577#define BNX2_PCI_ID_VAL4_MAX_SPLIT_SIZE_B21 (0x3L<<23)
578#define BNX2_PCI_ID_VAL4_MAX_CUMULATIVE_SIZE_B0 (1L<<25)
579#define BNX2_PCI_ID_VAL4_MAX_MEM_READ_SIZE_B10 (0x3L<<26)
580#define BNX2_PCI_ID_VAL4_MAX_SPLIT_SIZE_B0 (1L<<28)
581#define BNX2_PCI_ID_VAL4_RESERVED3 (0x7L<<29)
582#define BNX2_PCI_ID_VAL4_RESERVED3_XI (0xffffL<<16)
551 583
552#define BNX2_PCI_ID_VAL5 0x00000444 584#define BNX2_PCI_ID_VAL5 0x00000444
553#define BNX2_PCI_ID_VAL5_D1_SUPPORT (1L<<0) 585#define BNX2_PCI_ID_VAL5_D1_SUPPORT (1L<<0)
@@ -556,6 +588,10 @@ struct l2_fhdr {
556#define BNX2_PCI_ID_VAL5_PME_IN_D1 (1L<<3) 588#define BNX2_PCI_ID_VAL5_PME_IN_D1 (1L<<3)
557#define BNX2_PCI_ID_VAL5_PME_IN_D2 (1L<<4) 589#define BNX2_PCI_ID_VAL5_PME_IN_D2 (1L<<4)
558#define BNX2_PCI_ID_VAL5_PME_IN_D3_HOT (1L<<5) 590#define BNX2_PCI_ID_VAL5_PME_IN_D3_HOT (1L<<5)
591#define BNX2_PCI_ID_VAL5_RESERVED0_TE (0x3ffffffL<<6)
592#define BNX2_PCI_ID_VAL5_PM_VERSION_XI (0x7L<<6)
593#define BNX2_PCI_ID_VAL5_NO_SOFT_RESET_XI (1L<<9)
594#define BNX2_PCI_ID_VAL5_RESERVED0_XI (0x3fffffL<<10)
559 595
560#define BNX2_PCI_PCIX_EXTENDED_STATUS 0x00000448 596#define BNX2_PCI_PCIX_EXTENDED_STATUS 0x00000448
561#define BNX2_PCI_PCIX_EXTENDED_STATUS_NO_SNOOP (1L<<8) 597#define BNX2_PCI_PCIX_EXTENDED_STATUS_NO_SNOOP (1L<<8)
@@ -567,12 +603,91 @@ struct l2_fhdr {
567#define BNX2_PCI_ID_VAL6_MAX_LAT (0xffL<<0) 603#define BNX2_PCI_ID_VAL6_MAX_LAT (0xffL<<0)
568#define BNX2_PCI_ID_VAL6_MIN_GNT (0xffL<<8) 604#define BNX2_PCI_ID_VAL6_MIN_GNT (0xffL<<8)
569#define BNX2_PCI_ID_VAL6_BIST (0xffL<<16) 605#define BNX2_PCI_ID_VAL6_BIST (0xffL<<16)
606#define BNX2_PCI_ID_VAL6_RESERVED0 (0xffL<<24)
570 607
571#define BNX2_PCI_MSI_DATA 0x00000450 608#define BNX2_PCI_MSI_DATA 0x00000450
572#define BNX2_PCI_MSI_DATA_PCI_MSI_DATA (0xffffL<<0) 609#define BNX2_PCI_MSI_DATA_MSI_DATA (0xffffL<<0)
573 610
574#define BNX2_PCI_MSI_ADDR_H 0x00000454 611#define BNX2_PCI_MSI_ADDR_H 0x00000454
575#define BNX2_PCI_MSI_ADDR_L 0x00000458 612#define BNX2_PCI_MSI_ADDR_L 0x00000458
613#define BNX2_PCI_MSI_ADDR_L_VAL (0x3fffffffL<<2)
614
615#define BNX2_PCI_CFG_ACCESS_CMD 0x0000045c
616#define BNX2_PCI_CFG_ACCESS_CMD_ADR (0x3fL<<2)
617#define BNX2_PCI_CFG_ACCESS_CMD_RD_REQ (1L<<27)
618#define BNX2_PCI_CFG_ACCESS_CMD_WR_REQ (0xfL<<28)
619
620#define BNX2_PCI_CFG_ACCESS_DATA 0x00000460
621#define BNX2_PCI_MSI_MASK 0x00000464
622#define BNX2_PCI_MSI_MASK_MSI_MASK (0xffffffffL<<0)
623
624#define BNX2_PCI_MSI_PEND 0x00000468
625#define BNX2_PCI_MSI_PEND_MSI_PEND (0xffffffffL<<0)
626
627#define BNX2_PCI_PM_DATA_C 0x0000046c
628#define BNX2_PCI_PM_DATA_C_PM_DATA_8_PRG (0xffL<<0)
629#define BNX2_PCI_PM_DATA_C_RESERVED0 (0xffffffL<<8)
630
631#define BNX2_PCI_MSIX_CONTROL 0x000004c0
632#define BNX2_PCI_MSIX_CONTROL_MSIX_TBL_SIZ (0x7ffL<<0)
633#define BNX2_PCI_MSIX_CONTROL_RESERVED0 (0x1fffffL<<11)
634
635#define BNX2_PCI_MSIX_TBL_OFF_BIR 0x000004c4
636#define BNX2_PCI_MSIX_TBL_OFF_BIR_MSIX_TBL_BIR (0x7L<<0)
637#define BNX2_PCI_MSIX_TBL_OFF_BIR_MSIX_TBL_OFF (0x1fffffffL<<3)
638
639#define BNX2_PCI_MSIX_PBA_OFF_BIT 0x000004c8
640#define BNX2_PCI_MSIX_PBA_OFF_BIT_MSIX_PBA_BIR (0x7L<<0)
641#define BNX2_PCI_MSIX_PBA_OFF_BIT_MSIX_PBA_OFF (0x1fffffffL<<3)
642
643#define BNX2_PCI_PCIE_CAPABILITY 0x000004d0
644#define BNX2_PCI_PCIE_CAPABILITY_INTERRUPT_MSG_NUM (0x1fL<<0)
645#define BNX2_PCI_PCIE_CAPABILITY_COMPLY_PCIE_1_1 (1L<<5)
646
647#define BNX2_PCI_DEVICE_CAPABILITY 0x000004d4
648#define BNX2_PCI_DEVICE_CAPABILITY_MAX_PL_SIZ_SUPPORTED (0x7L<<0)
649#define BNX2_PCI_DEVICE_CAPABILITY_EXTENDED_TAG_SUPPORT (1L<<5)
650#define BNX2_PCI_DEVICE_CAPABILITY_L0S_ACCEPTABLE_LATENCY (0x7L<<6)
651#define BNX2_PCI_DEVICE_CAPABILITY_L1_ACCEPTABLE_LATENCY (0x7L<<9)
652#define BNX2_PCI_DEVICE_CAPABILITY_ROLE_BASED_ERR_RPT (1L<<15)
653
654#define BNX2_PCI_LINK_CAPABILITY 0x000004dc
655#define BNX2_PCI_LINK_CAPABILITY_MAX_LINK_SPEED (0xfL<<0)
656#define BNX2_PCI_LINK_CAPABILITY_MAX_LINK_SPEED_0001 (1L<<0)
657#define BNX2_PCI_LINK_CAPABILITY_MAX_LINK_SPEED_0010 (1L<<0)
658#define BNX2_PCI_LINK_CAPABILITY_MAX_LINK_WIDTH (0x1fL<<4)
659#define BNX2_PCI_LINK_CAPABILITY_CLK_POWER_MGMT (1L<<9)
660#define BNX2_PCI_LINK_CAPABILITY_ASPM_SUPPORT (0x3L<<10)
661#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_LAT (0x7L<<12)
662#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_LAT_101 (5L<<12)
663#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_LAT_110 (6L<<12)
664#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_LAT (0x7L<<15)
665#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_LAT_001 (1L<<15)
666#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_LAT_010 (2L<<15)
667#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_COMM_LAT (0x7L<<18)
668#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_COMM_LAT_101 (5L<<18)
669#define BNX2_PCI_LINK_CAPABILITY_L0S_EXIT_COMM_LAT_110 (6L<<18)
670#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_COMM_LAT (0x7L<<21)
671#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_COMM_LAT_001 (1L<<21)
672#define BNX2_PCI_LINK_CAPABILITY_L1_EXIT_COMM_LAT_010 (2L<<21)
673#define BNX2_PCI_LINK_CAPABILITY_PORT_NUM (0xffL<<24)
674
675#define BNX2_PCI_PCIE_DEVICE_CAPABILITY_2 0x000004e4
676#define BNX2_PCI_PCIE_DEVICE_CAPABILITY_2_CMPL_TO_RANGE_SUPP (0xfL<<0)
677#define BNX2_PCI_PCIE_DEVICE_CAPABILITY_2_CMPL_TO_DISABL_SUPP (1L<<4)
678#define BNX2_PCI_PCIE_DEVICE_CAPABILITY_2_RESERVED (0x7ffffffL<<5)
679
680#define BNX2_PCI_PCIE_LINK_CAPABILITY_2 0x000004e8
681#define BNX2_PCI_PCIE_LINK_CAPABILITY_2_RESERVED (0xffffffffL<<0)
682
683#define BNX2_PCI_GRC_WINDOW1_ADDR 0x00000610
684#define BNX2_PCI_GRC_WINDOW1_ADDR_VALUE (0x1ffL<<13)
685
686#define BNX2_PCI_GRC_WINDOW2_ADDR 0x00000614
687#define BNX2_PCI_GRC_WINDOW2_ADDR_VALUE (0x1ffL<<13)
688
689#define BNX2_PCI_GRC_WINDOW3_ADDR 0x00000618
690#define BNX2_PCI_GRC_WINDOW3_ADDR_VALUE (0x1ffL<<13)
576 691
577 692
578/* 693/*
@@ -582,13 +697,23 @@ struct l2_fhdr {
582#define BNX2_MISC_COMMAND 0x00000800 697#define BNX2_MISC_COMMAND 0x00000800
583#define BNX2_MISC_COMMAND_ENABLE_ALL (1L<<0) 698#define BNX2_MISC_COMMAND_ENABLE_ALL (1L<<0)
584#define BNX2_MISC_COMMAND_DISABLE_ALL (1L<<1) 699#define BNX2_MISC_COMMAND_DISABLE_ALL (1L<<1)
585#define BNX2_MISC_COMMAND_CORE_RESET (1L<<4) 700#define BNX2_MISC_COMMAND_SW_RESET (1L<<4)
586#define BNX2_MISC_COMMAND_HARD_RESET (1L<<5) 701#define BNX2_MISC_COMMAND_POR_RESET (1L<<5)
702#define BNX2_MISC_COMMAND_HD_RESET (1L<<6)
703#define BNX2_MISC_COMMAND_CMN_SW_RESET (1L<<7)
587#define BNX2_MISC_COMMAND_PAR_ERROR (1L<<8) 704#define BNX2_MISC_COMMAND_PAR_ERROR (1L<<8)
705#define BNX2_MISC_COMMAND_CS16_ERR (1L<<9)
706#define BNX2_MISC_COMMAND_CS16_ERR_LOC (0xfL<<12)
588#define BNX2_MISC_COMMAND_PAR_ERR_RAM (0x7fL<<16) 707#define BNX2_MISC_COMMAND_PAR_ERR_RAM (0x7fL<<16)
708#define BNX2_MISC_COMMAND_POWERDOWN_EVENT (1L<<23)
709#define BNX2_MISC_COMMAND_SW_SHUTDOWN (1L<<24)
710#define BNX2_MISC_COMMAND_SHUTDOWN_EN (1L<<25)
711#define BNX2_MISC_COMMAND_DINTEG_ATTN_EN (1L<<26)
712#define BNX2_MISC_COMMAND_PCIE_LINK_IN_L23 (1L<<27)
713#define BNX2_MISC_COMMAND_PCIE_DIS (1L<<28)
589 714
590#define BNX2_MISC_CFG 0x00000804 715#define BNX2_MISC_CFG 0x00000804
591#define BNX2_MISC_CFG_PCI_GRC_TMOUT (1L<<0) 716#define BNX2_MISC_CFG_GRC_TMOUT (1L<<0)
592#define BNX2_MISC_CFG_NVM_WR_EN (0x3L<<1) 717#define BNX2_MISC_CFG_NVM_WR_EN (0x3L<<1)
593#define BNX2_MISC_CFG_NVM_WR_EN_PROTECT (0L<<1) 718#define BNX2_MISC_CFG_NVM_WR_EN_PROTECT (0L<<1)
594#define BNX2_MISC_CFG_NVM_WR_EN_PCI (1L<<1) 719#define BNX2_MISC_CFG_NVM_WR_EN_PCI (1L<<1)
@@ -596,16 +721,45 @@ struct l2_fhdr {
596#define BNX2_MISC_CFG_NVM_WR_EN_ALLOW2 (3L<<1) 721#define BNX2_MISC_CFG_NVM_WR_EN_ALLOW2 (3L<<1)
597#define BNX2_MISC_CFG_BIST_EN (1L<<3) 722#define BNX2_MISC_CFG_BIST_EN (1L<<3)
598#define BNX2_MISC_CFG_CK25_OUT_ALT_SRC (1L<<4) 723#define BNX2_MISC_CFG_CK25_OUT_ALT_SRC (1L<<4)
599#define BNX2_MISC_CFG_BYPASS_BSCAN (1L<<5) 724#define BNX2_MISC_CFG_RESERVED5_TE (1L<<5)
600#define BNX2_MISC_CFG_BYPASS_EJTAG (1L<<6) 725#define BNX2_MISC_CFG_RESERVED6_TE (1L<<6)
601#define BNX2_MISC_CFG_CLK_CTL_OVERRIDE (1L<<7) 726#define BNX2_MISC_CFG_CLK_CTL_OVERRIDE (1L<<7)
602#define BNX2_MISC_CFG_LEDMODE (0x3L<<8) 727#define BNX2_MISC_CFG_LEDMODE (0x7L<<8)
603#define BNX2_MISC_CFG_LEDMODE_MAC (0L<<8) 728#define BNX2_MISC_CFG_LEDMODE_MAC (0L<<8)
604#define BNX2_MISC_CFG_LEDMODE_GPHY1 (1L<<8) 729#define BNX2_MISC_CFG_LEDMODE_PHY1_TE (1L<<8)
605#define BNX2_MISC_CFG_LEDMODE_GPHY2 (2L<<8) 730#define BNX2_MISC_CFG_LEDMODE_PHY2_TE (2L<<8)
731#define BNX2_MISC_CFG_LEDMODE_PHY3_TE (3L<<8)
732#define BNX2_MISC_CFG_LEDMODE_PHY4_TE (4L<<8)
733#define BNX2_MISC_CFG_LEDMODE_PHY5_TE (5L<<8)
734#define BNX2_MISC_CFG_LEDMODE_PHY6_TE (6L<<8)
735#define BNX2_MISC_CFG_LEDMODE_PHY7_TE (7L<<8)
736#define BNX2_MISC_CFG_MCP_GRC_TMOUT_TE (1L<<11)
737#define BNX2_MISC_CFG_DBU_GRC_TMOUT_TE (1L<<12)
738#define BNX2_MISC_CFG_LEDMODE_XI (0xfL<<8)
739#define BNX2_MISC_CFG_LEDMODE_MAC_XI (0L<<8)
740#define BNX2_MISC_CFG_LEDMODE_PHY1_XI (1L<<8)
741#define BNX2_MISC_CFG_LEDMODE_PHY2_XI (2L<<8)
742#define BNX2_MISC_CFG_LEDMODE_PHY3_XI (3L<<8)
743#define BNX2_MISC_CFG_LEDMODE_MAC2_XI (4L<<8)
744#define BNX2_MISC_CFG_LEDMODE_PHY4_XI (5L<<8)
745#define BNX2_MISC_CFG_LEDMODE_PHY5_XI (6L<<8)
746#define BNX2_MISC_CFG_LEDMODE_PHY6_XI (7L<<8)
747#define BNX2_MISC_CFG_LEDMODE_MAC3_XI (8L<<8)
748#define BNX2_MISC_CFG_LEDMODE_PHY7_XI (9L<<8)
749#define BNX2_MISC_CFG_LEDMODE_PHY8_XI (10L<<8)
750#define BNX2_MISC_CFG_LEDMODE_PHY9_XI (11L<<8)
751#define BNX2_MISC_CFG_LEDMODE_MAC4_XI (12L<<8)
752#define BNX2_MISC_CFG_LEDMODE_PHY10_XI (13L<<8)
753#define BNX2_MISC_CFG_LEDMODE_PHY11_XI (14L<<8)
754#define BNX2_MISC_CFG_LEDMODE_UNUSED_XI (15L<<8)
755#define BNX2_MISC_CFG_PORT_SELECT_XI (1L<<13)
756#define BNX2_MISC_CFG_PARITY_MODE_XI (1L<<14)
606 757
607#define BNX2_MISC_ID 0x00000808 758#define BNX2_MISC_ID 0x00000808
608#define BNX2_MISC_ID_BOND_ID (0xfL<<0) 759#define BNX2_MISC_ID_BOND_ID (0xfL<<0)
760#define BNX2_MISC_ID_BOND_ID_X (0L<<0)
761#define BNX2_MISC_ID_BOND_ID_C (3L<<0)
762#define BNX2_MISC_ID_BOND_ID_S (12L<<0)
609#define BNX2_MISC_ID_CHIP_METAL (0xffL<<4) 763#define BNX2_MISC_ID_CHIP_METAL (0xffL<<4)
610#define BNX2_MISC_ID_CHIP_REV (0xfL<<12) 764#define BNX2_MISC_ID_CHIP_REV (0xfL<<12)
611#define BNX2_MISC_ID_CHIP_NUM (0xffffL<<16) 765#define BNX2_MISC_ID_CHIP_NUM (0xffffL<<16)
@@ -639,6 +793,8 @@ struct l2_fhdr {
639#define BNX2_MISC_ENABLE_STATUS_BITS_TIMER_ENABLE (1L<<25) 793#define BNX2_MISC_ENABLE_STATUS_BITS_TIMER_ENABLE (1L<<25)
640#define BNX2_MISC_ENABLE_STATUS_BITS_DMA_ENGINE_ENABLE (1L<<26) 794#define BNX2_MISC_ENABLE_STATUS_BITS_DMA_ENGINE_ENABLE (1L<<26)
641#define BNX2_MISC_ENABLE_STATUS_BITS_UMP_ENABLE (1L<<27) 795#define BNX2_MISC_ENABLE_STATUS_BITS_UMP_ENABLE (1L<<27)
796#define BNX2_MISC_ENABLE_STATUS_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
797#define BNX2_MISC_ENABLE_STATUS_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
642 798
643#define BNX2_MISC_ENABLE_SET_BITS 0x00000810 799#define BNX2_MISC_ENABLE_SET_BITS 0x00000810
644#define BNX2_MISC_ENABLE_SET_BITS_TX_SCHEDULER_ENABLE (1L<<0) 800#define BNX2_MISC_ENABLE_SET_BITS_TX_SCHEDULER_ENABLE (1L<<0)
@@ -669,6 +825,8 @@ struct l2_fhdr {
669#define BNX2_MISC_ENABLE_SET_BITS_TIMER_ENABLE (1L<<25) 825#define BNX2_MISC_ENABLE_SET_BITS_TIMER_ENABLE (1L<<25)
670#define BNX2_MISC_ENABLE_SET_BITS_DMA_ENGINE_ENABLE (1L<<26) 826#define BNX2_MISC_ENABLE_SET_BITS_DMA_ENGINE_ENABLE (1L<<26)
671#define BNX2_MISC_ENABLE_SET_BITS_UMP_ENABLE (1L<<27) 827#define BNX2_MISC_ENABLE_SET_BITS_UMP_ENABLE (1L<<27)
828#define BNX2_MISC_ENABLE_SET_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
829#define BNX2_MISC_ENABLE_SET_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
672 830
673#define BNX2_MISC_ENABLE_CLR_BITS 0x00000814 831#define BNX2_MISC_ENABLE_CLR_BITS 0x00000814
674#define BNX2_MISC_ENABLE_CLR_BITS_TX_SCHEDULER_ENABLE (1L<<0) 832#define BNX2_MISC_ENABLE_CLR_BITS_TX_SCHEDULER_ENABLE (1L<<0)
@@ -699,6 +857,8 @@ struct l2_fhdr {
699#define BNX2_MISC_ENABLE_CLR_BITS_TIMER_ENABLE (1L<<25) 857#define BNX2_MISC_ENABLE_CLR_BITS_TIMER_ENABLE (1L<<25)
700#define BNX2_MISC_ENABLE_CLR_BITS_DMA_ENGINE_ENABLE (1L<<26) 858#define BNX2_MISC_ENABLE_CLR_BITS_DMA_ENGINE_ENABLE (1L<<26)
701#define BNX2_MISC_ENABLE_CLR_BITS_UMP_ENABLE (1L<<27) 859#define BNX2_MISC_ENABLE_CLR_BITS_UMP_ENABLE (1L<<27)
860#define BNX2_MISC_ENABLE_CLR_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
861#define BNX2_MISC_ENABLE_CLR_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
702 862
703#define BNX2_MISC_CLOCK_CONTROL_BITS 0x00000818 863#define BNX2_MISC_CLOCK_CONTROL_BITS 0x00000818
704#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0) 864#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_CLK_SPD_DET (0xfL<<0)
@@ -718,30 +878,41 @@ struct l2_fhdr {
718#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8) 878#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_12 (1L<<8)
719#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8) 879#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_6 (2L<<8)
720#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8) 880#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_SRC_62 (4L<<8)
721#define BNX2_MISC_CLOCK_CONTROL_BITS_PLAY_DEAD (1L<<11) 881#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED0_XI (0x7L<<8)
882#define BNX2_MISC_CLOCK_CONTROL_BITS_MIN_POWER (1L<<11)
722#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12) 883#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED (0xfL<<12)
723#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12) 884#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_100 (0L<<12)
724#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12) 885#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_80 (1L<<12)
725#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_50 (2L<<12) 886#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_50 (2L<<12)
726#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12) 887#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_40 (4L<<12)
727#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12) 888#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_25 (8L<<12)
889#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED1_XI (0xfL<<12)
728#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16) 890#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_STOP (1L<<16)
729#define BNX2_MISC_CLOCK_CONTROL_BITS_PCI_PLL_STOP (1L<<17) 891#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_17_TE (1L<<17)
730#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_18 (1L<<18) 892#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_18_TE (1L<<18)
731#define BNX2_MISC_CLOCK_CONTROL_BITS_USE_SPD_DET (1L<<19) 893#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_19_TE (1L<<19)
732#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED (0xfffL<<20) 894#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED_TE (0xfffL<<20)
733 895#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_ALT_MGMT_XI (1L<<17)
734#define BNX2_MISC_GPIO 0x0000081c 896#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED2_XI (0x3fL<<18)
735#define BNX2_MISC_GPIO_VALUE (0xffL<<0) 897#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_VCO_XI (0x7L<<24)
736#define BNX2_MISC_GPIO_SET (0xffL<<8) 898#define BNX2_MISC_CLOCK_CONTROL_BITS_RESERVED3_XI (1L<<27)
737#define BNX2_MISC_GPIO_CLR (0xffL<<16) 899#define BNX2_MISC_CLOCK_CONTROL_BITS_CORE_CLK_PLL_SPEED_XI (0xfL<<28)
738#define BNX2_MISC_GPIO_FLOAT (0xffL<<24) 900
739 901#define BNX2_MISC_SPIO 0x0000081c
740#define BNX2_MISC_GPIO_INT 0x00000820 902#define BNX2_MISC_SPIO_VALUE (0xffL<<0)
741#define BNX2_MISC_GPIO_INT_INT_STATE (0xfL<<0) 903#define BNX2_MISC_SPIO_SET (0xffL<<8)
742#define BNX2_MISC_GPIO_INT_OLD_VALUE (0xfL<<8) 904#define BNX2_MISC_SPIO_CLR (0xffL<<16)
743#define BNX2_MISC_GPIO_INT_OLD_SET (0xfL<<16) 905#define BNX2_MISC_SPIO_FLOAT (0xffL<<24)
744#define BNX2_MISC_GPIO_INT_OLD_CLR (0xfL<<24) 906
907#define BNX2_MISC_SPIO_INT 0x00000820
908#define BNX2_MISC_SPIO_INT_INT_STATE_TE (0xfL<<0)
909#define BNX2_MISC_SPIO_INT_OLD_VALUE_TE (0xfL<<8)
910#define BNX2_MISC_SPIO_INT_OLD_SET_TE (0xfL<<16)
911#define BNX2_MISC_SPIO_INT_OLD_CLR_TE (0xfL<<24)
912#define BNX2_MISC_SPIO_INT_INT_STATE_XI (0xffL<<0)
913#define BNX2_MISC_SPIO_INT_OLD_VALUE_XI (0xffL<<8)
914#define BNX2_MISC_SPIO_INT_OLD_SET_XI (0xffL<<16)
915#define BNX2_MISC_SPIO_INT_OLD_CLR_XI (0xffL<<24)
745 916
746#define BNX2_MISC_CONFIG_LFSR 0x00000824 917#define BNX2_MISC_CONFIG_LFSR 0x00000824
747#define BNX2_MISC_CONFIG_LFSR_DIV (0xffffL<<0) 918#define BNX2_MISC_CONFIG_LFSR_DIV (0xffffL<<0)
@@ -775,6 +946,8 @@ struct l2_fhdr {
775#define BNX2_MISC_LFSR_MASK_BITS_TIMER_ENABLE (1L<<25) 946#define BNX2_MISC_LFSR_MASK_BITS_TIMER_ENABLE (1L<<25)
776#define BNX2_MISC_LFSR_MASK_BITS_DMA_ENGINE_ENABLE (1L<<26) 947#define BNX2_MISC_LFSR_MASK_BITS_DMA_ENGINE_ENABLE (1L<<26)
777#define BNX2_MISC_LFSR_MASK_BITS_UMP_ENABLE (1L<<27) 948#define BNX2_MISC_LFSR_MASK_BITS_UMP_ENABLE (1L<<27)
949#define BNX2_MISC_LFSR_MASK_BITS_RV2P_CMD_SCHEDULER_ENABLE (1L<<28)
950#define BNX2_MISC_LFSR_MASK_BITS_RSVD_FUTURE_ENABLE (0x7L<<29)
778 951
779#define BNX2_MISC_ARB_REQ0 0x0000082c 952#define BNX2_MISC_ARB_REQ0 0x0000082c
780#define BNX2_MISC_ARB_REQ1 0x00000830 953#define BNX2_MISC_ARB_REQ1 0x00000830
@@ -831,22 +1004,12 @@ struct l2_fhdr {
831#define BNX2_MISC_ARB_GNT3_30 (0x7L<<24) 1004#define BNX2_MISC_ARB_GNT3_30 (0x7L<<24)
832#define BNX2_MISC_ARB_GNT3_31 (0x7L<<28) 1005#define BNX2_MISC_ARB_GNT3_31 (0x7L<<28)
833 1006
834#define BNX2_MISC_PRBS_CONTROL 0x00000878 1007#define BNX2_MISC_RESERVED1 0x00000878
835#define BNX2_MISC_PRBS_CONTROL_EN (1L<<0) 1008#define BNX2_MISC_RESERVED1_MISC_RESERVED1_VALUE (0x3fL<<0)
836#define BNX2_MISC_PRBS_CONTROL_RSTB (1L<<1) 1009
837#define BNX2_MISC_PRBS_CONTROL_INV (1L<<2) 1010#define BNX2_MISC_RESERVED2 0x0000087c
838#define BNX2_MISC_PRBS_CONTROL_ERR_CLR (1L<<3) 1011#define BNX2_MISC_RESERVED2_PCIE_DIS (1L<<0)
839#define BNX2_MISC_PRBS_CONTROL_ORDER (0x3L<<4) 1012#define BNX2_MISC_RESERVED2_LINK_IN_L23 (1L<<1)
840#define BNX2_MISC_PRBS_CONTROL_ORDER_7TH (0L<<4)
841#define BNX2_MISC_PRBS_CONTROL_ORDER_15TH (1L<<4)
842#define BNX2_MISC_PRBS_CONTROL_ORDER_23RD (2L<<4)
843#define BNX2_MISC_PRBS_CONTROL_ORDER_31ST (3L<<4)
844
845#define BNX2_MISC_PRBS_STATUS 0x0000087c
846#define BNX2_MISC_PRBS_STATUS_LOCK (1L<<0)
847#define BNX2_MISC_PRBS_STATUS_STKY (1L<<1)
848#define BNX2_MISC_PRBS_STATUS_ERRORS (0x3fffL<<2)
849#define BNX2_MISC_PRBS_STATUS_STATE (0xfL<<16)
850 1013
851#define BNX2_MISC_SM_ASF_CONTROL 0x00000880 1014#define BNX2_MISC_SM_ASF_CONTROL 0x00000880
852#define BNX2_MISC_SM_ASF_CONTROL_ASF_RST (1L<<0) 1015#define BNX2_MISC_SM_ASF_CONTROL_ASF_RST (1L<<0)
@@ -857,13 +1020,15 @@ struct l2_fhdr {
857#define BNX2_MISC_SM_ASF_CONTROL_PL_TO (1L<<5) 1020#define BNX2_MISC_SM_ASF_CONTROL_PL_TO (1L<<5)
858#define BNX2_MISC_SM_ASF_CONTROL_RT_TO (1L<<6) 1021#define BNX2_MISC_SM_ASF_CONTROL_RT_TO (1L<<6)
859#define BNX2_MISC_SM_ASF_CONTROL_SMB_EVENT (1L<<7) 1022#define BNX2_MISC_SM_ASF_CONTROL_SMB_EVENT (1L<<7)
860#define BNX2_MISC_SM_ASF_CONTROL_RES (0xfL<<8) 1023#define BNX2_MISC_SM_ASF_CONTROL_STRETCH_EN (1L<<8)
1024#define BNX2_MISC_SM_ASF_CONTROL_STRETCH_PULSE (1L<<9)
1025#define BNX2_MISC_SM_ASF_CONTROL_RES (0x3L<<10)
861#define BNX2_MISC_SM_ASF_CONTROL_SMB_EN (1L<<12) 1026#define BNX2_MISC_SM_ASF_CONTROL_SMB_EN (1L<<12)
862#define BNX2_MISC_SM_ASF_CONTROL_SMB_BB_EN (1L<<13) 1027#define BNX2_MISC_SM_ASF_CONTROL_SMB_BB_EN (1L<<13)
863#define BNX2_MISC_SM_ASF_CONTROL_SMB_NO_ADDR_FILT (1L<<14) 1028#define BNX2_MISC_SM_ASF_CONTROL_SMB_NO_ADDR_FILT (1L<<14)
864#define BNX2_MISC_SM_ASF_CONTROL_SMB_AUTOREAD (1L<<15) 1029#define BNX2_MISC_SM_ASF_CONTROL_SMB_AUTOREAD (1L<<15)
865#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR1 (0x3fL<<16) 1030#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR1 (0x7fL<<16)
866#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR2 (0x3fL<<24) 1031#define BNX2_MISC_SM_ASF_CONTROL_NIC_SMB_ADDR2 (0x7fL<<23)
867#define BNX2_MISC_SM_ASF_CONTROL_EN_NIC_SMB_ADDR_0 (1L<<30) 1032#define BNX2_MISC_SM_ASF_CONTROL_EN_NIC_SMB_ADDR_0 (1L<<30)
868#define BNX2_MISC_SM_ASF_CONTROL_SMB_EARLY_ATTN (1L<<31) 1033#define BNX2_MISC_SM_ASF_CONTROL_SMB_EARLY_ATTN (1L<<31)
869 1034
@@ -891,13 +1056,13 @@ struct l2_fhdr {
891#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS (0xfL<<20) 1056#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS (0xfL<<20)
892#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_OK (0L<<20) 1057#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_OK (0L<<20)
893#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_NACK (1L<<20) 1058#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_NACK (1L<<20)
894#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_NACK (9L<<20)
895#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_UFLOW (2L<<20) 1059#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_UFLOW (2L<<20)
896#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_STOP (3L<<20) 1060#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_STOP (3L<<20)
897#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_TIMEOUT (4L<<20) 1061#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_TIMEOUT (4L<<20)
898#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_LOST (5L<<20) 1062#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_FIRST_LOST (5L<<20)
1063#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_BADACK (6L<<20)
1064#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_NACK (9L<<20)
899#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_LOST (0xdL<<20) 1065#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_SUB_LOST (0xdL<<20)
900#define BNX2_MISC_SMB_OUT_SMB_OUT_STATUS_BADACK (0x6L<<20)
901#define BNX2_MISC_SMB_OUT_SMB_OUT_SLAVEMODE (1L<<24) 1066#define BNX2_MISC_SMB_OUT_SMB_OUT_SLAVEMODE (1L<<24)
902#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_EN (1L<<25) 1067#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_EN (1L<<25)
903#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_IN (1L<<26) 1068#define BNX2_MISC_SMB_OUT_SMB_OUT_DAT_IN (1L<<26)
@@ -955,6 +1120,38 @@ struct l2_fhdr {
955#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPC (1L<<29) 1120#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPC (1L<<29)
956#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPM (1L<<30) 1121#define BNX2_MISC_PERR_ENA0_RDE_MISC_RPM (1L<<30)
957#define BNX2_MISC_PERR_ENA0_RV2P_MISC_CB0REGS (1L<<31) 1122#define BNX2_MISC_PERR_ENA0_RV2P_MISC_CB0REGS (1L<<31)
1123#define BNX2_MISC_PERR_ENA0_COM_DMAE_PERR_EN_XI (1L<<0)
1124#define BNX2_MISC_PERR_ENA0_CP_DMAE_PERR_EN_XI (1L<<1)
1125#define BNX2_MISC_PERR_ENA0_RPM_ACPIBEMEM_PERR_EN_XI (1L<<2)
1126#define BNX2_MISC_PERR_ENA0_CTX_USAGE_CNT_PERR_EN_XI (1L<<3)
1127#define BNX2_MISC_PERR_ENA0_CTX_PGTBL_PERR_EN_XI (1L<<4)
1128#define BNX2_MISC_PERR_ENA0_CTX_CACHE_PERR_EN_XI (1L<<5)
1129#define BNX2_MISC_PERR_ENA0_CTX_MIRROR_PERR_EN_XI (1L<<6)
1130#define BNX2_MISC_PERR_ENA0_COM_CTXC_PERR_EN_XI (1L<<7)
1131#define BNX2_MISC_PERR_ENA0_COM_SCPAD_PERR_EN_XI (1L<<8)
1132#define BNX2_MISC_PERR_ENA0_CP_CTXC_PERR_EN_XI (1L<<9)
1133#define BNX2_MISC_PERR_ENA0_CP_SCPAD_PERR_EN_XI (1L<<10)
1134#define BNX2_MISC_PERR_ENA0_RXP_RBUFC_PERR_EN_XI (1L<<11)
1135#define BNX2_MISC_PERR_ENA0_RXP_CTXC_PERR_EN_XI (1L<<12)
1136#define BNX2_MISC_PERR_ENA0_RXP_SCPAD_PERR_EN_XI (1L<<13)
1137#define BNX2_MISC_PERR_ENA0_TPAT_SCPAD_PERR_EN_XI (1L<<14)
1138#define BNX2_MISC_PERR_ENA0_TXP_CTXC_PERR_EN_XI (1L<<15)
1139#define BNX2_MISC_PERR_ENA0_TXP_SCPAD_PERR_EN_XI (1L<<16)
1140#define BNX2_MISC_PERR_ENA0_CS_TMEM_PERR_EN_XI (1L<<17)
1141#define BNX2_MISC_PERR_ENA0_MQ_CTX_PERR_EN_XI (1L<<18)
1142#define BNX2_MISC_PERR_ENA0_RPM_DFIFOMEM_PERR_EN_XI (1L<<19)
1143#define BNX2_MISC_PERR_ENA0_RPC_DFIFOMEM_PERR_EN_XI (1L<<20)
1144#define BNX2_MISC_PERR_ENA0_RBUF_PTRMEM_PERR_EN_XI (1L<<21)
1145#define BNX2_MISC_PERR_ENA0_RBUF_DATAMEM_PERR_EN_XI (1L<<22)
1146#define BNX2_MISC_PERR_ENA0_RV2P_P2IRAM_PERR_EN_XI (1L<<23)
1147#define BNX2_MISC_PERR_ENA0_RV2P_P1IRAM_PERR_EN_XI (1L<<24)
1148#define BNX2_MISC_PERR_ENA0_RV2P_CB1REGS_PERR_EN_XI (1L<<25)
1149#define BNX2_MISC_PERR_ENA0_RV2P_CB0REGS_PERR_EN_XI (1L<<26)
1150#define BNX2_MISC_PERR_ENA0_TPBUF_PERR_EN_XI (1L<<27)
1151#define BNX2_MISC_PERR_ENA0_THBUF_PERR_EN_XI (1L<<28)
1152#define BNX2_MISC_PERR_ENA0_TDMA_PERR_EN_XI (1L<<29)
1153#define BNX2_MISC_PERR_ENA0_TBDC_PERR_EN_XI (1L<<30)
1154#define BNX2_MISC_PERR_ENA0_TSCH_LR_PERR_EN_XI (1L<<31)
958 1155
959#define BNX2_MISC_PERR_ENA1 0x000008a8 1156#define BNX2_MISC_PERR_ENA1 0x000008a8
960#define BNX2_MISC_PERR_ENA1_RV2P_MISC_CB1REGS (1L<<0) 1157#define BNX2_MISC_PERR_ENA1_RV2P_MISC_CB1REGS (1L<<0)
@@ -989,6 +1186,35 @@ struct l2_fhdr {
989#define BNX2_MISC_PERR_ENA1_RXPQ_MISC (1L<<29) 1186#define BNX2_MISC_PERR_ENA1_RXPQ_MISC (1L<<29)
990#define BNX2_MISC_PERR_ENA1_RXPCQ_MISC (1L<<30) 1187#define BNX2_MISC_PERR_ENA1_RXPCQ_MISC (1L<<30)
991#define BNX2_MISC_PERR_ENA1_RLUPQ_MISC (1L<<31) 1188#define BNX2_MISC_PERR_ENA1_RLUPQ_MISC (1L<<31)
1189#define BNX2_MISC_PERR_ENA1_RBDC_PERR_EN_XI (1L<<0)
1190#define BNX2_MISC_PERR_ENA1_RDMA_DFIFO_PERR_EN_XI (1L<<2)
1191#define BNX2_MISC_PERR_ENA1_HC_STATS_PERR_EN_XI (1L<<3)
1192#define BNX2_MISC_PERR_ENA1_HC_MSIX_PERR_EN_XI (1L<<4)
1193#define BNX2_MISC_PERR_ENA1_HC_PRODUCSTB_PERR_EN_XI (1L<<5)
1194#define BNX2_MISC_PERR_ENA1_HC_CONSUMSTB_PERR_EN_XI (1L<<6)
1195#define BNX2_MISC_PERR_ENA1_TPATQ_PERR_EN_XI (1L<<7)
1196#define BNX2_MISC_PERR_ENA1_MCPQ_PERR_EN_XI (1L<<8)
1197#define BNX2_MISC_PERR_ENA1_TDMAQ_PERR_EN_XI (1L<<9)
1198#define BNX2_MISC_PERR_ENA1_TXPQ_PERR_EN_XI (1L<<10)
1199#define BNX2_MISC_PERR_ENA1_COMTQ_PERR_EN_XI (1L<<11)
1200#define BNX2_MISC_PERR_ENA1_COMQ_PERR_EN_XI (1L<<12)
1201#define BNX2_MISC_PERR_ENA1_RLUPQ_PERR_EN_XI (1L<<13)
1202#define BNX2_MISC_PERR_ENA1_RXPQ_PERR_EN_XI (1L<<14)
1203#define BNX2_MISC_PERR_ENA1_RV2PPQ_PERR_EN_XI (1L<<15)
1204#define BNX2_MISC_PERR_ENA1_RDMAQ_PERR_EN_XI (1L<<16)
1205#define BNX2_MISC_PERR_ENA1_TASQ_PERR_EN_XI (1L<<17)
1206#define BNX2_MISC_PERR_ENA1_TBDRQ_PERR_EN_XI (1L<<18)
1207#define BNX2_MISC_PERR_ENA1_TSCHQ_PERR_EN_XI (1L<<19)
1208#define BNX2_MISC_PERR_ENA1_COMXQ_PERR_EN_XI (1L<<20)
1209#define BNX2_MISC_PERR_ENA1_RXPCQ_PERR_EN_XI (1L<<21)
1210#define BNX2_MISC_PERR_ENA1_RV2PTQ_PERR_EN_XI (1L<<22)
1211#define BNX2_MISC_PERR_ENA1_RV2PMQ_PERR_EN_XI (1L<<23)
1212#define BNX2_MISC_PERR_ENA1_CPQ_PERR_EN_XI (1L<<24)
1213#define BNX2_MISC_PERR_ENA1_CSQ_PERR_EN_XI (1L<<25)
1214#define BNX2_MISC_PERR_ENA1_RLUP_CID_PERR_EN_XI (1L<<26)
1215#define BNX2_MISC_PERR_ENA1_RV2PCS_TMEM_PERR_EN_XI (1L<<27)
1216#define BNX2_MISC_PERR_ENA1_RV2PCSQ_PERR_EN_XI (1L<<28)
1217#define BNX2_MISC_PERR_ENA1_MQ_IDX_PERR_EN_XI (1L<<29)
992 1218
993#define BNX2_MISC_PERR_ENA2 0x000008ac 1219#define BNX2_MISC_PERR_ENA2 0x000008ac
994#define BNX2_MISC_PERR_ENA2_COMQ_MISC (1L<<0) 1220#define BNX2_MISC_PERR_ENA2_COMQ_MISC (1L<<0)
@@ -1000,19 +1226,498 @@ struct l2_fhdr {
1000#define BNX2_MISC_PERR_ENA2_TDMAQ_MISC (1L<<6) 1226#define BNX2_MISC_PERR_ENA2_TDMAQ_MISC (1L<<6)
1001#define BNX2_MISC_PERR_ENA2_TPATQ_MISC (1L<<7) 1227#define BNX2_MISC_PERR_ENA2_TPATQ_MISC (1L<<7)
1002#define BNX2_MISC_PERR_ENA2_TASQ_MISC (1L<<8) 1228#define BNX2_MISC_PERR_ENA2_TASQ_MISC (1L<<8)
1229#define BNX2_MISC_PERR_ENA2_TGT_FIFO_PERR_EN_XI (1L<<0)
1230#define BNX2_MISC_PERR_ENA2_UMP_TX_PERR_EN_XI (1L<<1)
1231#define BNX2_MISC_PERR_ENA2_UMP_RX_PERR_EN_XI (1L<<2)
1232#define BNX2_MISC_PERR_ENA2_MCP_ROM_PERR_EN_XI (1L<<3)
1233#define BNX2_MISC_PERR_ENA2_MCP_SCPAD_PERR_EN_XI (1L<<4)
1234#define BNX2_MISC_PERR_ENA2_HB_MEM_PERR_EN_XI (1L<<5)
1235#define BNX2_MISC_PERR_ENA2_PCIE_REPLAY_PERR_EN_XI (1L<<6)
1003 1236
1004#define BNX2_MISC_DEBUG_VECTOR_SEL 0x000008b0 1237#define BNX2_MISC_DEBUG_VECTOR_SEL 0x000008b0
1005#define BNX2_MISC_DEBUG_VECTOR_SEL_0 (0xfffL<<0) 1238#define BNX2_MISC_DEBUG_VECTOR_SEL_0 (0xfffL<<0)
1006#define BNX2_MISC_DEBUG_VECTOR_SEL_1 (0xfffL<<12) 1239#define BNX2_MISC_DEBUG_VECTOR_SEL_1 (0xfffL<<12)
1240#define BNX2_MISC_DEBUG_VECTOR_SEL_1_XI (0xfffL<<15)
1007 1241
1008#define BNX2_MISC_VREG_CONTROL 0x000008b4 1242#define BNX2_MISC_VREG_CONTROL 0x000008b4
1009#define BNX2_MISC_VREG_CONTROL_1_2 (0xfL<<0) 1243#define BNX2_MISC_VREG_CONTROL_1_2 (0xfL<<0)
1244#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_XI (0xfL<<0)
1245#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS14_XI (0L<<0)
1246#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS12_XI (1L<<0)
1247#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS10_XI (2L<<0)
1248#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS8_XI (3L<<0)
1249#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS6_XI (4L<<0)
1250#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS4_XI (5L<<0)
1251#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_PLUS2_XI (6L<<0)
1252#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_NOM_XI (7L<<0)
1253#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS2_XI (8L<<0)
1254#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS4_XI (9L<<0)
1255#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS6_XI (10L<<0)
1256#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS8_XI (11L<<0)
1257#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS10_XI (12L<<0)
1258#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS12_XI (13L<<0)
1259#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS14_XI (14L<<0)
1260#define BNX2_MISC_VREG_CONTROL_1_0_MAIN_MINUS16_XI (15L<<0)
1010#define BNX2_MISC_VREG_CONTROL_2_5 (0xfL<<4) 1261#define BNX2_MISC_VREG_CONTROL_2_5 (0xfL<<4)
1262#define BNX2_MISC_VREG_CONTROL_2_5_PLUS14 (0L<<4)
1263#define BNX2_MISC_VREG_CONTROL_2_5_PLUS12 (1L<<4)
1264#define BNX2_MISC_VREG_CONTROL_2_5_PLUS10 (2L<<4)
1265#define BNX2_MISC_VREG_CONTROL_2_5_PLUS8 (3L<<4)
1266#define BNX2_MISC_VREG_CONTROL_2_5_PLUS6 (4L<<4)
1267#define BNX2_MISC_VREG_CONTROL_2_5_PLUS4 (5L<<4)
1268#define BNX2_MISC_VREG_CONTROL_2_5_PLUS2 (6L<<4)
1269#define BNX2_MISC_VREG_CONTROL_2_5_NOM (7L<<4)
1270#define BNX2_MISC_VREG_CONTROL_2_5_MINUS2 (8L<<4)
1271#define BNX2_MISC_VREG_CONTROL_2_5_MINUS4 (9L<<4)
1272#define BNX2_MISC_VREG_CONTROL_2_5_MINUS6 (10L<<4)
1273#define BNX2_MISC_VREG_CONTROL_2_5_MINUS8 (11L<<4)
1274#define BNX2_MISC_VREG_CONTROL_2_5_MINUS10 (12L<<4)
1275#define BNX2_MISC_VREG_CONTROL_2_5_MINUS12 (13L<<4)
1276#define BNX2_MISC_VREG_CONTROL_2_5_MINUS14 (14L<<4)
1277#define BNX2_MISC_VREG_CONTROL_2_5_MINUS16 (15L<<4)
1278#define BNX2_MISC_VREG_CONTROL_1_0_MGMT (0xfL<<8)
1279#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS14 (0L<<8)
1280#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS12 (1L<<8)
1281#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS10 (2L<<8)
1282#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS8 (3L<<8)
1283#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS6 (4L<<8)
1284#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS4 (5L<<8)
1285#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_PLUS2 (6L<<8)
1286#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_NOM (7L<<8)
1287#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS2 (8L<<8)
1288#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS4 (9L<<8)
1289#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS6 (10L<<8)
1290#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS8 (11L<<8)
1291#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS10 (12L<<8)
1292#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS12 (13L<<8)
1293#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS14 (14L<<8)
1294#define BNX2_MISC_VREG_CONTROL_1_0_MGMT_MINUS16 (15L<<8)
1011 1295
1012#define BNX2_MISC_FINAL_CLK_CTL_VAL 0x000008b8 1296#define BNX2_MISC_FINAL_CLK_CTL_VAL 0x000008b8
1013#define BNX2_MISC_FINAL_CLK_CTL_VAL_MISC_FINAL_CLK_CTL_VAL (0x3ffffffL<<6) 1297#define BNX2_MISC_FINAL_CLK_CTL_VAL_MISC_FINAL_CLK_CTL_VAL (0x3ffffffL<<6)
1014 1298
1015#define BNX2_MISC_UNUSED0 0x000008bc 1299#define BNX2_MISC_GP_HW_CTL0 0x000008bc
1300#define BNX2_MISC_GP_HW_CTL0_TX_DRIVE (1L<<0)
1301#define BNX2_MISC_GP_HW_CTL0_RMII_MODE (1L<<1)
1302#define BNX2_MISC_GP_HW_CTL0_RMII_CRSDV_SEL (1L<<2)
1303#define BNX2_MISC_GP_HW_CTL0_RVMII_MODE (1L<<3)
1304#define BNX2_MISC_GP_HW_CTL0_FLASH_SAMP_SCLK_NEGEDGE_TE (1L<<4)
1305#define BNX2_MISC_GP_HW_CTL0_HIDDEN_REVISION_ID_TE (1L<<5)
1306#define BNX2_MISC_GP_HW_CTL0_HC_CNTL_TMOUT_CTR_RST_TE (1L<<6)
1307#define BNX2_MISC_GP_HW_CTL0_RESERVED1_XI (0x7L<<4)
1308#define BNX2_MISC_GP_HW_CTL0_ENA_CORE_RST_ON_MAIN_PWR_GOING_AWAY (1L<<7)
1309#define BNX2_MISC_GP_HW_CTL0_ENA_SEL_VAUX_B_IN_L2_TE (1L<<8)
1310#define BNX2_MISC_GP_HW_CTL0_GRC_BNK_FREE_FIX_TE (1L<<9)
1311#define BNX2_MISC_GP_HW_CTL0_LED_ACT_SEL_TE (1L<<10)
1312#define BNX2_MISC_GP_HW_CTL0_RESERVED2_XI (0x7L<<8)
1313#define BNX2_MISC_GP_HW_CTL0_UP1_DEF0 (1L<<11)
1314#define BNX2_MISC_GP_HW_CTL0_FIBER_MODE_DIS_DEF (1L<<12)
1315#define BNX2_MISC_GP_HW_CTL0_FORCE2500_DEF (1L<<13)
1316#define BNX2_MISC_GP_HW_CTL0_AUTODETECT_DIS_DEF (1L<<14)
1317#define BNX2_MISC_GP_HW_CTL0_PARALLEL_DETECT_DEF (1L<<15)
1318#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI (0xfL<<16)
1319#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_3MA (0L<<16)
1320#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_2P5MA (1L<<16)
1321#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_2P0MA (3L<<16)
1322#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_1P5MA (5L<<16)
1323#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_1P0MA (7L<<16)
1324#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_DAI_PWRDN (15L<<16)
1325#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PRE2DIS (1L<<20)
1326#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PRE1DIS (1L<<21)
1327#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT (0x3L<<22)
1328#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT_M6P (0L<<22)
1329#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT_M0P (1L<<22)
1330#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT_P0P (2L<<22)
1331#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_CTAT_P6P (3L<<22)
1332#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT (0x3L<<24)
1333#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT_M6P (0L<<24)
1334#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT_M0P (1L<<24)
1335#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT_P0P (2L<<24)
1336#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_PTAT_P6P (3L<<24)
1337#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ (0x3L<<26)
1338#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ_240UA (0L<<26)
1339#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ_160UA (1L<<26)
1340#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ_400UA (2L<<26)
1341#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_IAMP_ADJ_320UA (3L<<26)
1342#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ (0x3L<<28)
1343#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ_240UA (0L<<28)
1344#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ_160UA (1L<<28)
1345#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ_400UA (2L<<28)
1346#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_ICBUF_ADJ_320UA (3L<<28)
1347#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ (0x3L<<30)
1348#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ_1P57 (0L<<30)
1349#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ_1P45 (1L<<30)
1350#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ_1P62 (2L<<30)
1351#define BNX2_MISC_GP_HW_CTL0_OSCCTRL_XTAL_ADJ_1P66 (3L<<30)
1352
1353#define BNX2_MISC_GP_HW_CTL1 0x000008c0
1354#define BNX2_MISC_GP_HW_CTL1_1_ATTN_BTN_PRSNT_TE (1L<<0)
1355#define BNX2_MISC_GP_HW_CTL1_1_ATTN_IND_PRSNT_TE (1L<<1)
1356#define BNX2_MISC_GP_HW_CTL1_1_PWR_IND_PRSNT_TE (1L<<2)
1357#define BNX2_MISC_GP_HW_CTL1_0_PCIE_LOOPBACK_TE (1L<<3)
1358#define BNX2_MISC_GP_HW_CTL1_RESERVED_SOFT_XI (0xffffL<<0)
1359#define BNX2_MISC_GP_HW_CTL1_RESERVED_HARD_XI (0xffffL<<16)
1360
1361#define BNX2_MISC_NEW_HW_CTL 0x000008c4
1362#define BNX2_MISC_NEW_HW_CTL_MAIN_POR_BYPASS (1L<<0)
1363#define BNX2_MISC_NEW_HW_CTL_RINGOSC_ENABLE (1L<<1)
1364#define BNX2_MISC_NEW_HW_CTL_RINGOSC_SEL0 (1L<<2)
1365#define BNX2_MISC_NEW_HW_CTL_RINGOSC_SEL1 (1L<<3)
1366#define BNX2_MISC_NEW_HW_CTL_RESERVED_SHARED (0xfffL<<4)
1367#define BNX2_MISC_NEW_HW_CTL_RESERVED_SPLIT (0xffffL<<16)
1368
1369#define BNX2_MISC_NEW_CORE_CTL 0x000008c8
1370#define BNX2_MISC_NEW_CORE_CTL_LINK_HOLDOFF_SUCCESS (1L<<0)
1371#define BNX2_MISC_NEW_CORE_CTL_LINK_HOLDOFF_REQ (1L<<1)
1372#define BNX2_MISC_NEW_CORE_CTL_RESERVED_CMN (0x3fffL<<2)
1373#define BNX2_MISC_NEW_CORE_CTL_RESERVED_TC (0xffffL<<16)
1374
1375#define BNX2_MISC_ECO_HW_CTL 0x000008cc
1376#define BNX2_MISC_ECO_HW_CTL_LARGE_GRC_TMOUT_EN (1L<<0)
1377#define BNX2_MISC_ECO_HW_CTL_RESERVED_SOFT (0x7fffL<<1)
1378#define BNX2_MISC_ECO_HW_CTL_RESERVED_HARD (0xffffL<<16)
1379
1380#define BNX2_MISC_ECO_CORE_CTL 0x000008d0
1381#define BNX2_MISC_ECO_CORE_CTL_RESERVED_SOFT (0xffffL<<0)
1382#define BNX2_MISC_ECO_CORE_CTL_RESERVED_HARD (0xffffL<<16)
1383
1384#define BNX2_MISC_PPIO 0x000008d4
1385#define BNX2_MISC_PPIO_VALUE (0xfL<<0)
1386#define BNX2_MISC_PPIO_SET (0xfL<<8)
1387#define BNX2_MISC_PPIO_CLR (0xfL<<16)
1388#define BNX2_MISC_PPIO_FLOAT (0xfL<<24)
1389
1390#define BNX2_MISC_PPIO_INT 0x000008d8
1391#define BNX2_MISC_PPIO_INT_INT_STATE (0xfL<<0)
1392#define BNX2_MISC_PPIO_INT_OLD_VALUE (0xfL<<8)
1393#define BNX2_MISC_PPIO_INT_OLD_SET (0xfL<<16)
1394#define BNX2_MISC_PPIO_INT_OLD_CLR (0xfL<<24)
1395
1396#define BNX2_MISC_RESET_NUMS 0x000008dc
1397#define BNX2_MISC_RESET_NUMS_NUM_HARD_RESETS (0x7L<<0)
1398#define BNX2_MISC_RESET_NUMS_NUM_PCIE_RESETS (0x7L<<4)
1399#define BNX2_MISC_RESET_NUMS_NUM_PERSTB_RESETS (0x7L<<8)
1400#define BNX2_MISC_RESET_NUMS_NUM_CMN_RESETS (0x7L<<12)
1401#define BNX2_MISC_RESET_NUMS_NUM_PORT_RESETS (0x7L<<16)
1402
1403#define BNX2_MISC_CS16_ERR 0x000008e0
1404#define BNX2_MISC_CS16_ERR_ENA_PCI (1L<<0)
1405#define BNX2_MISC_CS16_ERR_ENA_RDMA (1L<<1)
1406#define BNX2_MISC_CS16_ERR_ENA_TDMA (1L<<2)
1407#define BNX2_MISC_CS16_ERR_ENA_EMAC (1L<<3)
1408#define BNX2_MISC_CS16_ERR_ENA_CTX (1L<<4)
1409#define BNX2_MISC_CS16_ERR_ENA_TBDR (1L<<5)
1410#define BNX2_MISC_CS16_ERR_ENA_RBDC (1L<<6)
1411#define BNX2_MISC_CS16_ERR_ENA_COM (1L<<7)
1412#define BNX2_MISC_CS16_ERR_ENA_CP (1L<<8)
1413#define BNX2_MISC_CS16_ERR_STA_PCI (1L<<16)
1414#define BNX2_MISC_CS16_ERR_STA_RDMA (1L<<17)
1415#define BNX2_MISC_CS16_ERR_STA_TDMA (1L<<18)
1416#define BNX2_MISC_CS16_ERR_STA_EMAC (1L<<19)
1417#define BNX2_MISC_CS16_ERR_STA_CTX (1L<<20)
1418#define BNX2_MISC_CS16_ERR_STA_TBDR (1L<<21)
1419#define BNX2_MISC_CS16_ERR_STA_RBDC (1L<<22)
1420#define BNX2_MISC_CS16_ERR_STA_COM (1L<<23)
1421#define BNX2_MISC_CS16_ERR_STA_CP (1L<<24)
1422
1423#define BNX2_MISC_SPIO_EVENT 0x000008e4
1424#define BNX2_MISC_SPIO_EVENT_ENABLE (0xffL<<0)
1425
1426#define BNX2_MISC_PPIO_EVENT 0x000008e8
1427#define BNX2_MISC_PPIO_EVENT_ENABLE (0xfL<<0)
1428
1429#define BNX2_MISC_DUAL_MEDIA_CTRL 0x000008ec
1430#define BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID (0xffL<<0)
1431#define BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID_X (0L<<0)
1432#define BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID_C (3L<<0)
1433#define BNX2_MISC_DUAL_MEDIA_CTRL_BOND_ID_S (12L<<0)
1434#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_CTRL_STRAP (0x7L<<8)
1435#define BNX2_MISC_DUAL_MEDIA_CTRL_PORT_SWAP_PIN (1L<<11)
1436#define BNX2_MISC_DUAL_MEDIA_CTRL_SERDES1_SIGDET (1L<<12)
1437#define BNX2_MISC_DUAL_MEDIA_CTRL_SERDES0_SIGDET (1L<<13)
1438#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY1_SIGDET (1L<<14)
1439#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY0_SIGDET (1L<<15)
1440#define BNX2_MISC_DUAL_MEDIA_CTRL_LCPLL_RST (1L<<16)
1441#define BNX2_MISC_DUAL_MEDIA_CTRL_SERDES1_RST (1L<<17)
1442#define BNX2_MISC_DUAL_MEDIA_CTRL_SERDES0_RST (1L<<18)
1443#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY1_RST (1L<<19)
1444#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY0_RST (1L<<20)
1445#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_CTRL (0x7L<<21)
1446#define BNX2_MISC_DUAL_MEDIA_CTRL_PORT_SWAP (1L<<24)
1447#define BNX2_MISC_DUAL_MEDIA_CTRL_STRAP_OVERRIDE (1L<<25)
1448#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ (0xfL<<26)
1449#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ_SER1_IDDQ (1L<<26)
1450#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ_SER0_IDDQ (2L<<26)
1451#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ_PHY1_IDDQ (4L<<26)
1452#define BNX2_MISC_DUAL_MEDIA_CTRL_PHY_SERDES_IDDQ_PHY0_IDDQ (8L<<26)
1453
1454#define BNX2_MISC_OTP_CMD1 0x000008f0
1455#define BNX2_MISC_OTP_CMD1_FMODE (0x7L<<0)
1456#define BNX2_MISC_OTP_CMD1_FMODE_IDLE (0L<<0)
1457#define BNX2_MISC_OTP_CMD1_FMODE_WRITE (1L<<0)
1458#define BNX2_MISC_OTP_CMD1_FMODE_INIT (2L<<0)
1459#define BNX2_MISC_OTP_CMD1_FMODE_SET (3L<<0)
1460#define BNX2_MISC_OTP_CMD1_FMODE_RST (4L<<0)
1461#define BNX2_MISC_OTP_CMD1_FMODE_VERIFY (5L<<0)
1462#define BNX2_MISC_OTP_CMD1_FMODE_RESERVED0 (6L<<0)
1463#define BNX2_MISC_OTP_CMD1_FMODE_RESERVED1 (7L<<0)
1464#define BNX2_MISC_OTP_CMD1_USEPINS (1L<<8)
1465#define BNX2_MISC_OTP_CMD1_PROGSEL (1L<<9)
1466#define BNX2_MISC_OTP_CMD1_PROGSTART (1L<<10)
1467#define BNX2_MISC_OTP_CMD1_PCOUNT (0x7L<<16)
1468#define BNX2_MISC_OTP_CMD1_PBYP (1L<<19)
1469#define BNX2_MISC_OTP_CMD1_VSEL (0xfL<<20)
1470#define BNX2_MISC_OTP_CMD1_TM (0x7L<<27)
1471#define BNX2_MISC_OTP_CMD1_SADBYP (1L<<30)
1472#define BNX2_MISC_OTP_CMD1_DEBUG (1L<<31)
1473
1474#define BNX2_MISC_OTP_CMD2 0x000008f4
1475#define BNX2_MISC_OTP_CMD2_OTP_ROM_ADDR (0x3ffL<<0)
1476#define BNX2_MISC_OTP_CMD2_DOSEL (0x7fL<<16)
1477#define BNX2_MISC_OTP_CMD2_DOSEL_0 (0L<<16)
1478#define BNX2_MISC_OTP_CMD2_DOSEL_1 (1L<<16)
1479#define BNX2_MISC_OTP_CMD2_DOSEL_127 (127L<<16)
1480
1481#define BNX2_MISC_OTP_STATUS 0x000008f8
1482#define BNX2_MISC_OTP_STATUS_DATA (0xffL<<0)
1483#define BNX2_MISC_OTP_STATUS_VALID (1L<<8)
1484#define BNX2_MISC_OTP_STATUS_BUSY (1L<<9)
1485#define BNX2_MISC_OTP_STATUS_BUSYSM (1L<<10)
1486#define BNX2_MISC_OTP_STATUS_DONE (1L<<11)
1487
1488#define BNX2_MISC_OTP_SHIFT1_CMD 0x000008fc
1489#define BNX2_MISC_OTP_SHIFT1_CMD_RESET_MODE_N (1L<<0)
1490#define BNX2_MISC_OTP_SHIFT1_CMD_SHIFT_DONE (1L<<1)
1491#define BNX2_MISC_OTP_SHIFT1_CMD_SHIFT_START (1L<<2)
1492#define BNX2_MISC_OTP_SHIFT1_CMD_LOAD_DATA (1L<<3)
1493#define BNX2_MISC_OTP_SHIFT1_CMD_SHIFT_SELECT (0x1fL<<8)
1494
1495#define BNX2_MISC_OTP_SHIFT1_DATA 0x00000900
1496#define BNX2_MISC_OTP_SHIFT2_CMD 0x00000904
1497#define BNX2_MISC_OTP_SHIFT2_CMD_RESET_MODE_N (1L<<0)
1498#define BNX2_MISC_OTP_SHIFT2_CMD_SHIFT_DONE (1L<<1)
1499#define BNX2_MISC_OTP_SHIFT2_CMD_SHIFT_START (1L<<2)
1500#define BNX2_MISC_OTP_SHIFT2_CMD_LOAD_DATA (1L<<3)
1501#define BNX2_MISC_OTP_SHIFT2_CMD_SHIFT_SELECT (0x1fL<<8)
1502
1503#define BNX2_MISC_OTP_SHIFT2_DATA 0x00000908
1504#define BNX2_MISC_BIST_CS0 0x0000090c
1505#define BNX2_MISC_BIST_CS0_MBIST_EN (1L<<0)
1506#define BNX2_MISC_BIST_CS0_BIST_SETUP (0x3L<<1)
1507#define BNX2_MISC_BIST_CS0_MBIST_ASYNC_RESET (1L<<3)
1508#define BNX2_MISC_BIST_CS0_MBIST_DONE (1L<<8)
1509#define BNX2_MISC_BIST_CS0_MBIST_GO (1L<<9)
1510#define BNX2_MISC_BIST_CS0_BIST_OVERRIDE (1L<<31)
1511
1512#define BNX2_MISC_BIST_MEMSTATUS0 0x00000910
1513#define BNX2_MISC_BIST_CS1 0x00000914
1514#define BNX2_MISC_BIST_CS1_MBIST_EN (1L<<0)
1515#define BNX2_MISC_BIST_CS1_BIST_SETUP (0x3L<<1)
1516#define BNX2_MISC_BIST_CS1_MBIST_ASYNC_RESET (1L<<3)
1517#define BNX2_MISC_BIST_CS1_MBIST_DONE (1L<<8)
1518#define BNX2_MISC_BIST_CS1_MBIST_GO (1L<<9)
1519
1520#define BNX2_MISC_BIST_MEMSTATUS1 0x00000918
1521#define BNX2_MISC_BIST_CS2 0x0000091c
1522#define BNX2_MISC_BIST_CS2_MBIST_EN (1L<<0)
1523#define BNX2_MISC_BIST_CS2_BIST_SETUP (0x3L<<1)
1524#define BNX2_MISC_BIST_CS2_MBIST_ASYNC_RESET (1L<<3)
1525#define BNX2_MISC_BIST_CS2_MBIST_DONE (1L<<8)
1526#define BNX2_MISC_BIST_CS2_MBIST_GO (1L<<9)
1527
1528#define BNX2_MISC_BIST_MEMSTATUS2 0x00000920
1529#define BNX2_MISC_BIST_CS3 0x00000924
1530#define BNX2_MISC_BIST_CS3_MBIST_EN (1L<<0)
1531#define BNX2_MISC_BIST_CS3_BIST_SETUP (0x3L<<1)
1532#define BNX2_MISC_BIST_CS3_MBIST_ASYNC_RESET (1L<<3)
1533#define BNX2_MISC_BIST_CS3_MBIST_DONE (1L<<8)
1534#define BNX2_MISC_BIST_CS3_MBIST_GO (1L<<9)
1535
1536#define BNX2_MISC_BIST_MEMSTATUS3 0x00000928
1537#define BNX2_MISC_BIST_CS4 0x0000092c
1538#define BNX2_MISC_BIST_CS4_MBIST_EN (1L<<0)
1539#define BNX2_MISC_BIST_CS4_BIST_SETUP (0x3L<<1)
1540#define BNX2_MISC_BIST_CS4_MBIST_ASYNC_RESET (1L<<3)
1541#define BNX2_MISC_BIST_CS4_MBIST_DONE (1L<<8)
1542#define BNX2_MISC_BIST_CS4_MBIST_GO (1L<<9)
1543
1544#define BNX2_MISC_BIST_MEMSTATUS4 0x00000930
1545#define BNX2_MISC_BIST_CS5 0x00000934
1546#define BNX2_MISC_BIST_CS5_MBIST_EN (1L<<0)
1547#define BNX2_MISC_BIST_CS5_BIST_SETUP (0x3L<<1)
1548#define BNX2_MISC_BIST_CS5_MBIST_ASYNC_RESET (1L<<3)
1549#define BNX2_MISC_BIST_CS5_MBIST_DONE (1L<<8)
1550#define BNX2_MISC_BIST_CS5_MBIST_GO (1L<<9)
1551
1552#define BNX2_MISC_BIST_MEMSTATUS5 0x00000938
1553#define BNX2_MISC_MEM_TM0 0x0000093c
1554#define BNX2_MISC_MEM_TM0_PCIE_REPLAY_TM (0xfL<<0)
1555#define BNX2_MISC_MEM_TM0_MCP_SCPAD (0xfL<<8)
1556#define BNX2_MISC_MEM_TM0_UMP_TM (0xffL<<16)
1557#define BNX2_MISC_MEM_TM0_HB_MEM_TM (0xfL<<24)
1558
1559#define BNX2_MISC_USPLL_CTRL 0x00000940
1560#define BNX2_MISC_USPLL_CTRL_PH_DET_DIS (1L<<0)
1561#define BNX2_MISC_USPLL_CTRL_FREQ_DET_DIS (1L<<1)
1562#define BNX2_MISC_USPLL_CTRL_LCPX (0x3fL<<2)
1563#define BNX2_MISC_USPLL_CTRL_RX (0x3L<<8)
1564#define BNX2_MISC_USPLL_CTRL_VC_EN (1L<<10)
1565#define BNX2_MISC_USPLL_CTRL_VCO_MG (0x3L<<11)
1566#define BNX2_MISC_USPLL_CTRL_KVCO_XF (0x7L<<13)
1567#define BNX2_MISC_USPLL_CTRL_KVCO_XS (0x7L<<16)
1568#define BNX2_MISC_USPLL_CTRL_TESTD_EN (1L<<19)
1569#define BNX2_MISC_USPLL_CTRL_TESTD_SEL (0x7L<<20)
1570#define BNX2_MISC_USPLL_CTRL_TESTA_EN (1L<<23)
1571#define BNX2_MISC_USPLL_CTRL_TESTA_SEL (0x3L<<24)
1572#define BNX2_MISC_USPLL_CTRL_ATTEN_FREF (1L<<26)
1573#define BNX2_MISC_USPLL_CTRL_DIGITAL_RST (1L<<27)
1574#define BNX2_MISC_USPLL_CTRL_ANALOG_RST (1L<<28)
1575#define BNX2_MISC_USPLL_CTRL_LOCK (1L<<29)
1576
1577#define BNX2_MISC_PERR_STATUS0 0x00000944
1578#define BNX2_MISC_PERR_STATUS0_COM_DMAE_PERR (1L<<0)
1579#define BNX2_MISC_PERR_STATUS0_CP_DMAE_PERR (1L<<1)
1580#define BNX2_MISC_PERR_STATUS0_RPM_ACPIBEMEM_PERR (1L<<2)
1581#define BNX2_MISC_PERR_STATUS0_CTX_USAGE_CNT_PERR (1L<<3)
1582#define BNX2_MISC_PERR_STATUS0_CTX_PGTBL_PERR (1L<<4)
1583#define BNX2_MISC_PERR_STATUS0_CTX_CACHE_PERR (1L<<5)
1584#define BNX2_MISC_PERR_STATUS0_CTX_MIRROR_PERR (1L<<6)
1585#define BNX2_MISC_PERR_STATUS0_COM_CTXC_PERR (1L<<7)
1586#define BNX2_MISC_PERR_STATUS0_COM_SCPAD_PERR (1L<<8)
1587#define BNX2_MISC_PERR_STATUS0_CP_CTXC_PERR (1L<<9)
1588#define BNX2_MISC_PERR_STATUS0_CP_SCPAD_PERR (1L<<10)
1589#define BNX2_MISC_PERR_STATUS0_RXP_RBUFC_PERR (1L<<11)
1590#define BNX2_MISC_PERR_STATUS0_RXP_CTXC_PERR (1L<<12)
1591#define BNX2_MISC_PERR_STATUS0_RXP_SCPAD_PERR (1L<<13)
1592#define BNX2_MISC_PERR_STATUS0_TPAT_SCPAD_PERR (1L<<14)
1593#define BNX2_MISC_PERR_STATUS0_TXP_CTXC_PERR (1L<<15)
1594#define BNX2_MISC_PERR_STATUS0_TXP_SCPAD_PERR (1L<<16)
1595#define BNX2_MISC_PERR_STATUS0_CS_TMEM_PERR (1L<<17)
1596#define BNX2_MISC_PERR_STATUS0_MQ_CTX_PERR (1L<<18)
1597#define BNX2_MISC_PERR_STATUS0_RPM_DFIFOMEM_PERR (1L<<19)
1598#define BNX2_MISC_PERR_STATUS0_RPC_DFIFOMEM_PERR (1L<<20)
1599#define BNX2_MISC_PERR_STATUS0_RBUF_PTRMEM_PERR (1L<<21)
1600#define BNX2_MISC_PERR_STATUS0_RBUF_DATAMEM_PERR (1L<<22)
1601#define BNX2_MISC_PERR_STATUS0_RV2P_P2IRAM_PERR (1L<<23)
1602#define BNX2_MISC_PERR_STATUS0_RV2P_P1IRAM_PERR (1L<<24)
1603#define BNX2_MISC_PERR_STATUS0_RV2P_CB1REGS_PERR (1L<<25)
1604#define BNX2_MISC_PERR_STATUS0_RV2P_CB0REGS_PERR (1L<<26)
1605#define BNX2_MISC_PERR_STATUS0_TPBUF_PERR (1L<<27)
1606#define BNX2_MISC_PERR_STATUS0_THBUF_PERR (1L<<28)
1607#define BNX2_MISC_PERR_STATUS0_TDMA_PERR (1L<<29)
1608#define BNX2_MISC_PERR_STATUS0_TBDC_PERR (1L<<30)
1609#define BNX2_MISC_PERR_STATUS0_TSCH_LR_PERR (1L<<31)
1610
1611#define BNX2_MISC_PERR_STATUS1 0x00000948
1612#define BNX2_MISC_PERR_STATUS1_RBDC_PERR (1L<<0)
1613#define BNX2_MISC_PERR_STATUS1_RDMA_DFIFO_PERR (1L<<2)
1614#define BNX2_MISC_PERR_STATUS1_HC_STATS_PERR (1L<<3)
1615#define BNX2_MISC_PERR_STATUS1_HC_MSIX_PERR (1L<<4)
1616#define BNX2_MISC_PERR_STATUS1_HC_PRODUCSTB_PERR (1L<<5)
1617#define BNX2_MISC_PERR_STATUS1_HC_CONSUMSTB_PERR (1L<<6)
1618#define BNX2_MISC_PERR_STATUS1_TPATQ_PERR (1L<<7)
1619#define BNX2_MISC_PERR_STATUS1_MCPQ_PERR (1L<<8)
1620#define BNX2_MISC_PERR_STATUS1_TDMAQ_PERR (1L<<9)
1621#define BNX2_MISC_PERR_STATUS1_TXPQ_PERR (1L<<10)
1622#define BNX2_MISC_PERR_STATUS1_COMTQ_PERR (1L<<11)
1623#define BNX2_MISC_PERR_STATUS1_COMQ_PERR (1L<<12)
1624#define BNX2_MISC_PERR_STATUS1_RLUPQ_PERR (1L<<13)
1625#define BNX2_MISC_PERR_STATUS1_RXPQ_PERR (1L<<14)
1626#define BNX2_MISC_PERR_STATUS1_RV2PPQ_PERR (1L<<15)
1627#define BNX2_MISC_PERR_STATUS1_RDMAQ_PERR (1L<<16)
1628#define BNX2_MISC_PERR_STATUS1_TASQ_PERR (1L<<17)
1629#define BNX2_MISC_PERR_STATUS1_TBDRQ_PERR (1L<<18)
1630#define BNX2_MISC_PERR_STATUS1_TSCHQ_PERR (1L<<19)
1631#define BNX2_MISC_PERR_STATUS1_COMXQ_PERR (1L<<20)
1632#define BNX2_MISC_PERR_STATUS1_RXPCQ_PERR (1L<<21)
1633#define BNX2_MISC_PERR_STATUS1_RV2PTQ_PERR (1L<<22)
1634#define BNX2_MISC_PERR_STATUS1_RV2PMQ_PERR (1L<<23)
1635#define BNX2_MISC_PERR_STATUS1_CPQ_PERR (1L<<24)
1636#define BNX2_MISC_PERR_STATUS1_CSQ_PERR (1L<<25)
1637#define BNX2_MISC_PERR_STATUS1_RLUP_CID_PERR (1L<<26)
1638#define BNX2_MISC_PERR_STATUS1_RV2PCS_TMEM_PERR (1L<<27)
1639#define BNX2_MISC_PERR_STATUS1_RV2PCSQ_PERR (1L<<28)
1640#define BNX2_MISC_PERR_STATUS1_MQ_IDX_PERR (1L<<29)
1641
1642#define BNX2_MISC_PERR_STATUS2 0x0000094c
1643#define BNX2_MISC_PERR_STATUS2_TGT_FIFO_PERR (1L<<0)
1644#define BNX2_MISC_PERR_STATUS2_UMP_TX_PERR (1L<<1)
1645#define BNX2_MISC_PERR_STATUS2_UMP_RX_PERR (1L<<2)
1646#define BNX2_MISC_PERR_STATUS2_MCP_ROM_PERR (1L<<3)
1647#define BNX2_MISC_PERR_STATUS2_MCP_SCPAD_PERR (1L<<4)
1648#define BNX2_MISC_PERR_STATUS2_HB_MEM_PERR (1L<<5)
1649#define BNX2_MISC_PERR_STATUS2_PCIE_REPLAY_PERR (1L<<6)
1650
1651#define BNX2_MISC_LCPLL_CTRL0 0x00000950
1652#define BNX2_MISC_LCPLL_CTRL0_OAC (0x7L<<0)
1653#define BNX2_MISC_LCPLL_CTRL0_OAC_NEGTWENTY (0L<<0)
1654#define BNX2_MISC_LCPLL_CTRL0_OAC_ZERO (1L<<0)
1655#define BNX2_MISC_LCPLL_CTRL0_OAC_TWENTY (3L<<0)
1656#define BNX2_MISC_LCPLL_CTRL0_OAC_FORTY (7L<<0)
1657#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL (0x7L<<3)
1658#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL_360 (0L<<3)
1659#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL_480 (1L<<3)
1660#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL_600 (3L<<3)
1661#define BNX2_MISC_LCPLL_CTRL0_ICP_CTRL_720 (7L<<3)
1662#define BNX2_MISC_LCPLL_CTRL0_BIAS_CTRL (0x3L<<6)
1663#define BNX2_MISC_LCPLL_CTRL0_PLL_OBSERVE (0x7L<<8)
1664#define BNX2_MISC_LCPLL_CTRL0_VTH_CTRL (0x3L<<11)
1665#define BNX2_MISC_LCPLL_CTRL0_VTH_CTRL_0 (0L<<11)
1666#define BNX2_MISC_LCPLL_CTRL0_VTH_CTRL_1 (1L<<11)
1667#define BNX2_MISC_LCPLL_CTRL0_VTH_CTRL_2 (2L<<11)
1668#define BNX2_MISC_LCPLL_CTRL0_PLLSEQSTART (1L<<13)
1669#define BNX2_MISC_LCPLL_CTRL0_RESERVED (1L<<14)
1670#define BNX2_MISC_LCPLL_CTRL0_CAPRETRY_EN (1L<<15)
1671#define BNX2_MISC_LCPLL_CTRL0_FREQMONITOR_EN (1L<<16)
1672#define BNX2_MISC_LCPLL_CTRL0_FREQDETRESTART_EN (1L<<17)
1673#define BNX2_MISC_LCPLL_CTRL0_FREQDETRETRY_EN (1L<<18)
1674#define BNX2_MISC_LCPLL_CTRL0_PLLFORCEFDONE_EN (1L<<19)
1675#define BNX2_MISC_LCPLL_CTRL0_PLLFORCEFDONE (1L<<20)
1676#define BNX2_MISC_LCPLL_CTRL0_PLLFORCEFPASS (1L<<21)
1677#define BNX2_MISC_LCPLL_CTRL0_PLLFORCECAPDONE_EN (1L<<22)
1678#define BNX2_MISC_LCPLL_CTRL0_PLLFORCECAPDONE (1L<<23)
1679#define BNX2_MISC_LCPLL_CTRL0_PLLFORCECAPPASS_EN (1L<<24)
1680#define BNX2_MISC_LCPLL_CTRL0_PLLFORCECAPPASS (1L<<25)
1681#define BNX2_MISC_LCPLL_CTRL0_CAPRESTART (1L<<26)
1682#define BNX2_MISC_LCPLL_CTRL0_CAPSELECTM_EN (1L<<27)
1683
1684#define BNX2_MISC_LCPLL_CTRL1 0x00000954
1685#define BNX2_MISC_LCPLL_CTRL1_CAPSELECTM (0x1fL<<0)
1686#define BNX2_MISC_LCPLL_CTRL1_CAPFORCESLOWDOWN_EN (1L<<5)
1687#define BNX2_MISC_LCPLL_CTRL1_CAPFORCESLOWDOWN (1L<<6)
1688#define BNX2_MISC_LCPLL_CTRL1_SLOWDN_XOR (1L<<7)
1689
1690#define BNX2_MISC_LCPLL_STATUS 0x00000958
1691#define BNX2_MISC_LCPLL_STATUS_FREQDONE_SM (1L<<0)
1692#define BNX2_MISC_LCPLL_STATUS_FREQPASS_SM (1L<<1)
1693#define BNX2_MISC_LCPLL_STATUS_PLLSEQDONE (1L<<2)
1694#define BNX2_MISC_LCPLL_STATUS_PLLSEQPASS (1L<<3)
1695#define BNX2_MISC_LCPLL_STATUS_PLLSTATE (0x7L<<4)
1696#define BNX2_MISC_LCPLL_STATUS_CAPSTATE (0x7L<<7)
1697#define BNX2_MISC_LCPLL_STATUS_CAPSELECT (0x1fL<<10)
1698#define BNX2_MISC_LCPLL_STATUS_SLOWDN_INDICATOR (1L<<15)
1699#define BNX2_MISC_LCPLL_STATUS_SLOWDN_INDICATOR_0 (0L<<15)
1700#define BNX2_MISC_LCPLL_STATUS_SLOWDN_INDICATOR_1 (1L<<15)
1701
1702#define BNX2_MISC_OSCFUNDS_CTRL 0x0000095c
1703#define BNX2_MISC_OSCFUNDS_CTRL_FREQ_MON (1L<<5)
1704#define BNX2_MISC_OSCFUNDS_CTRL_FREQ_MON_OFF (0L<<5)
1705#define BNX2_MISC_OSCFUNDS_CTRL_FREQ_MON_ON (1L<<5)
1706#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM (0x3L<<6)
1707#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM_0 (0L<<6)
1708#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM_1 (1L<<6)
1709#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM_2 (2L<<6)
1710#define BNX2_MISC_OSCFUNDS_CTRL_XTAL_ADJCM_3 (3L<<6)
1711#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ (0x3L<<8)
1712#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ_0 (0L<<8)
1713#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ_1 (1L<<8)
1714#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ_2 (2L<<8)
1715#define BNX2_MISC_OSCFUNDS_CTRL_ICBUF_ADJ_3 (3L<<8)
1716#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ (0x3L<<10)
1717#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ_0 (0L<<10)
1718#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ_1 (1L<<10)
1719#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ_2 (2L<<10)
1720#define BNX2_MISC_OSCFUNDS_CTRL_IAMP_ADJ_3 (3L<<10)
1016 1721
1017 1722
1018/* 1723/*
@@ -1031,11 +1736,35 @@ struct l2_fhdr {
1031#define BNX2_NVM_COMMAND_WRDI (1L<<17) 1736#define BNX2_NVM_COMMAND_WRDI (1L<<17)
1032#define BNX2_NVM_COMMAND_EWSR (1L<<18) 1737#define BNX2_NVM_COMMAND_EWSR (1L<<18)
1033#define BNX2_NVM_COMMAND_WRSR (1L<<19) 1738#define BNX2_NVM_COMMAND_WRSR (1L<<19)
1739#define BNX2_NVM_COMMAND_RD_ID (1L<<20)
1740#define BNX2_NVM_COMMAND_RD_STATUS (1L<<21)
1741#define BNX2_NVM_COMMAND_MODE_256 (1L<<22)
1034 1742
1035#define BNX2_NVM_STATUS 0x00006404 1743#define BNX2_NVM_STATUS 0x00006404
1036#define BNX2_NVM_STATUS_PI_FSM_STATE (0xfL<<0) 1744#define BNX2_NVM_STATUS_PI_FSM_STATE (0xfL<<0)
1037#define BNX2_NVM_STATUS_EE_FSM_STATE (0xfL<<4) 1745#define BNX2_NVM_STATUS_EE_FSM_STATE (0xfL<<4)
1038#define BNX2_NVM_STATUS_EQ_FSM_STATE (0xfL<<8) 1746#define BNX2_NVM_STATUS_EQ_FSM_STATE (0xfL<<8)
1747#define BNX2_NVM_STATUS_SPI_FSM_STATE_XI (0x1fL<<0)
1748#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_IDLE_XI (0L<<0)
1749#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CMD0_XI (1L<<0)
1750#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CMD1_XI (2L<<0)
1751#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CMD_FINISH0_XI (3L<<0)
1752#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CMD_FINISH1_XI (4L<<0)
1753#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_ADDR0_XI (5L<<0)
1754#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_WRITE_DATA0_XI (6L<<0)
1755#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_WRITE_DATA1_XI (7L<<0)
1756#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_WRITE_DATA2_XI (8L<<0)
1757#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_DATA0_XI (9L<<0)
1758#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_DATA1_XI (10L<<0)
1759#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_DATA2_XI (11L<<0)
1760#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID0_XI (12L<<0)
1761#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID1_XI (13L<<0)
1762#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID2_XI (14L<<0)
1763#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID3_XI (15L<<0)
1764#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_READ_STATUS_RDID4_XI (16L<<0)
1765#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_CHECK_BUSY0_XI (17L<<0)
1766#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_ST_WREN_XI (18L<<0)
1767#define BNX2_NVM_STATUS_SPI_FSM_STATE_SPI_WAIT_XI (19L<<0)
1039 1768
1040#define BNX2_NVM_WRITE 0x00006408 1769#define BNX2_NVM_WRITE 0x00006408
1041#define BNX2_NVM_WRITE_NVM_WRITE_VALUE (0xffffffffL<<0) 1770#define BNX2_NVM_WRITE_NVM_WRITE_VALUE (0xffffffffL<<0)
@@ -1046,6 +1775,10 @@ struct l2_fhdr {
1046#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_CS_B (8L<<0) 1775#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_CS_B (8L<<0)
1047#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SO (16L<<0) 1776#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SO (16L<<0)
1048#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SI (32L<<0) 1777#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SI (32L<<0)
1778#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SI_XI (1L<<0)
1779#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SO_XI (2L<<0)
1780#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_CS_B_XI (4L<<0)
1781#define BNX2_NVM_WRITE_NVM_WRITE_VALUE_SCLK_XI (8L<<0)
1049 1782
1050#define BNX2_NVM_ADDR 0x0000640c 1783#define BNX2_NVM_ADDR 0x0000640c
1051#define BNX2_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0) 1784#define BNX2_NVM_ADDR_NVM_ADDR_VALUE (0xffffffL<<0)
@@ -1056,6 +1789,10 @@ struct l2_fhdr {
1056#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_CS_B (8L<<0) 1789#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_CS_B (8L<<0)
1057#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SO (16L<<0) 1790#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SO (16L<<0)
1058#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SI (32L<<0) 1791#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SI (32L<<0)
1792#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SI_XI (1L<<0)
1793#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SO_XI (2L<<0)
1794#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_CS_B_XI (4L<<0)
1795#define BNX2_NVM_ADDR_NVM_ADDR_VALUE_SCLK_XI (8L<<0)
1059 1796
1060#define BNX2_NVM_READ 0x00006410 1797#define BNX2_NVM_READ 0x00006410
1061#define BNX2_NVM_READ_NVM_READ_VALUE (0xffffffffL<<0) 1798#define BNX2_NVM_READ_NVM_READ_VALUE (0xffffffffL<<0)
@@ -1066,6 +1803,10 @@ struct l2_fhdr {
1066#define BNX2_NVM_READ_NVM_READ_VALUE_CS_B (8L<<0) 1803#define BNX2_NVM_READ_NVM_READ_VALUE_CS_B (8L<<0)
1067#define BNX2_NVM_READ_NVM_READ_VALUE_SO (16L<<0) 1804#define BNX2_NVM_READ_NVM_READ_VALUE_SO (16L<<0)
1068#define BNX2_NVM_READ_NVM_READ_VALUE_SI (32L<<0) 1805#define BNX2_NVM_READ_NVM_READ_VALUE_SI (32L<<0)
1806#define BNX2_NVM_READ_NVM_READ_VALUE_SI_XI (1L<<0)
1807#define BNX2_NVM_READ_NVM_READ_VALUE_SO_XI (2L<<0)
1808#define BNX2_NVM_READ_NVM_READ_VALUE_CS_B_XI (4L<<0)
1809#define BNX2_NVM_READ_NVM_READ_VALUE_SCLK_XI (8L<<0)
1069 1810
1070#define BNX2_NVM_CFG1 0x00006414 1811#define BNX2_NVM_CFG1 0x00006414
1071#define BNX2_NVM_CFG1_FLASH_MODE (1L<<0) 1812#define BNX2_NVM_CFG1_FLASH_MODE (1L<<0)
@@ -1077,14 +1818,21 @@ struct l2_fhdr {
1077#define BNX2_NVM_CFG1_STATUS_BIT_BUFFER_RDY (7L<<4) 1818#define BNX2_NVM_CFG1_STATUS_BIT_BUFFER_RDY (7L<<4)
1078#define BNX2_NVM_CFG1_SPI_CLK_DIV (0xfL<<7) 1819#define BNX2_NVM_CFG1_SPI_CLK_DIV (0xfL<<7)
1079#define BNX2_NVM_CFG1_SEE_CLK_DIV (0x7ffL<<11) 1820#define BNX2_NVM_CFG1_SEE_CLK_DIV (0x7ffL<<11)
1821#define BNX2_NVM_CFG1_STRAP_CONTROL_0 (1L<<23)
1080#define BNX2_NVM_CFG1_PROTECT_MODE (1L<<24) 1822#define BNX2_NVM_CFG1_PROTECT_MODE (1L<<24)
1081#define BNX2_NVM_CFG1_FLASH_SIZE (1L<<25) 1823#define BNX2_NVM_CFG1_FLASH_SIZE (1L<<25)
1824#define BNX2_NVM_CFG1_FW_USTRAP_1 (1L<<26)
1825#define BNX2_NVM_CFG1_FW_USTRAP_0 (1L<<27)
1826#define BNX2_NVM_CFG1_FW_USTRAP_2 (1L<<28)
1827#define BNX2_NVM_CFG1_FW_USTRAP_3 (1L<<29)
1828#define BNX2_NVM_CFG1_FW_FLASH_TYPE_EN (1L<<30)
1082#define BNX2_NVM_CFG1_COMPAT_BYPASSS (1L<<31) 1829#define BNX2_NVM_CFG1_COMPAT_BYPASSS (1L<<31)
1083 1830
1084#define BNX2_NVM_CFG2 0x00006418 1831#define BNX2_NVM_CFG2 0x00006418
1085#define BNX2_NVM_CFG2_ERASE_CMD (0xffL<<0) 1832#define BNX2_NVM_CFG2_ERASE_CMD (0xffL<<0)
1086#define BNX2_NVM_CFG2_DUMMY (0xffL<<8) 1833#define BNX2_NVM_CFG2_DUMMY (0xffL<<8)
1087#define BNX2_NVM_CFG2_STATUS_CMD (0xffL<<16) 1834#define BNX2_NVM_CFG2_STATUS_CMD (0xffL<<16)
1835#define BNX2_NVM_CFG2_READ_ID (0xffL<<24)
1088 1836
1089#define BNX2_NVM_CFG3 0x0000641c 1837#define BNX2_NVM_CFG3 0x0000641c
1090#define BNX2_NVM_CFG3_BUFFER_RD_CMD (0xffL<<0) 1838#define BNX2_NVM_CFG3_BUFFER_RD_CMD (0xffL<<0)
@@ -1119,6 +1867,35 @@ struct l2_fhdr {
1119#define BNX2_NVM_WRITE1_WRDI_CMD (0xffL<<8) 1867#define BNX2_NVM_WRITE1_WRDI_CMD (0xffL<<8)
1120#define BNX2_NVM_WRITE1_SR_DATA (0xffL<<16) 1868#define BNX2_NVM_WRITE1_SR_DATA (0xffL<<16)
1121 1869
1870#define BNX2_NVM_CFG4 0x0000642c
1871#define BNX2_NVM_CFG4_FLASH_SIZE (0x7L<<0)
1872#define BNX2_NVM_CFG4_FLASH_SIZE_1MBIT (0L<<0)
1873#define BNX2_NVM_CFG4_FLASH_SIZE_2MBIT (1L<<0)
1874#define BNX2_NVM_CFG4_FLASH_SIZE_4MBIT (2L<<0)
1875#define BNX2_NVM_CFG4_FLASH_SIZE_8MBIT (3L<<0)
1876#define BNX2_NVM_CFG4_FLASH_SIZE_16MBIT (4L<<0)
1877#define BNX2_NVM_CFG4_FLASH_SIZE_32MBIT (5L<<0)
1878#define BNX2_NVM_CFG4_FLASH_SIZE_64MBIT (6L<<0)
1879#define BNX2_NVM_CFG4_FLASH_SIZE_128MBIT (7L<<0)
1880#define BNX2_NVM_CFG4_FLASH_VENDOR (1L<<3)
1881#define BNX2_NVM_CFG4_FLASH_VENDOR_ST (0L<<3)
1882#define BNX2_NVM_CFG4_FLASH_VENDOR_ATMEL (1L<<3)
1883#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC (0x3L<<4)
1884#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC_BIT8 (0L<<4)
1885#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC_BIT9 (1L<<4)
1886#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC_BIT10 (2L<<4)
1887#define BNX2_NVM_CFG4_MODE_256_EMPTY_BIT_LOC_BIT11 (3L<<4)
1888#define BNX2_NVM_CFG4_STATUS_BIT_POLARITY (1L<<6)
1889#define BNX2_NVM_CFG4_RESERVED (0x1ffffffL<<7)
1890
1891#define BNX2_NVM_RECONFIG 0x00006430
1892#define BNX2_NVM_RECONFIG_ORIG_STRAP_VALUE (0xfL<<0)
1893#define BNX2_NVM_RECONFIG_ORIG_STRAP_VALUE_ST (0L<<0)
1894#define BNX2_NVM_RECONFIG_ORIG_STRAP_VALUE_ATMEL (1L<<0)
1895#define BNX2_NVM_RECONFIG_RECONFIG_STRAP_VALUE (0xfL<<4)
1896#define BNX2_NVM_RECONFIG_RESERVED (0x7fffffL<<8)
1897#define BNX2_NVM_RECONFIG_RECONFIG_DONE (1L<<31)
1898
1122 1899
1123 1900
1124/* 1901/*
@@ -1140,6 +1917,8 @@ struct l2_fhdr {
1140#define BNX2_DMA_STATUS_BIG_WRITE_TRANSFERS_STAT (1L<<23) 1917#define BNX2_DMA_STATUS_BIG_WRITE_TRANSFERS_STAT (1L<<23)
1141#define BNX2_DMA_STATUS_BIG_WRITE_DELAY_PCI_CLKS_STAT (1L<<24) 1918#define BNX2_DMA_STATUS_BIG_WRITE_DELAY_PCI_CLKS_STAT (1L<<24)
1142#define BNX2_DMA_STATUS_BIG_WRITE_RETRY_AFTER_DATA_STAT (1L<<25) 1919#define BNX2_DMA_STATUS_BIG_WRITE_RETRY_AFTER_DATA_STAT (1L<<25)
1920#define BNX2_DMA_STATUS_GLOBAL_ERR_XI (1L<<0)
1921#define BNX2_DMA_STATUS_BME_XI (1L<<4)
1143 1922
1144#define BNX2_DMA_CONFIG 0x00000c08 1923#define BNX2_DMA_CONFIG 0x00000c08
1145#define BNX2_DMA_CONFIG_DATA_BYTE_SWAP (1L<<0) 1924#define BNX2_DMA_CONFIG_DATA_BYTE_SWAP (1L<<0)
@@ -1161,85 +1940,315 @@ struct l2_fhdr {
1161#define BNX2_DMA_CONFIG_BIG_SIZE_128 (0x2L<<24) 1940#define BNX2_DMA_CONFIG_BIG_SIZE_128 (0x2L<<24)
1162#define BNX2_DMA_CONFIG_BIG_SIZE_256 (0x4L<<24) 1941#define BNX2_DMA_CONFIG_BIG_SIZE_256 (0x4L<<24)
1163#define BNX2_DMA_CONFIG_BIG_SIZE_512 (0x8L<<24) 1942#define BNX2_DMA_CONFIG_BIG_SIZE_512 (0x8L<<24)
1943#define BNX2_DMA_CONFIG_DAT_WBSWAP_MODE_XI (0x3L<<0)
1944#define BNX2_DMA_CONFIG_CTL_WBSWAP_MODE_XI (0x3L<<4)
1945#define BNX2_DMA_CONFIG_MAX_PL_XI (0x7L<<12)
1946#define BNX2_DMA_CONFIG_MAX_PL_128B_XI (0L<<12)
1947#define BNX2_DMA_CONFIG_MAX_PL_256B_XI (1L<<12)
1948#define BNX2_DMA_CONFIG_MAX_PL_512B_XI (2L<<12)
1949#define BNX2_DMA_CONFIG_MAX_PL_EN_XI (1L<<15)
1950#define BNX2_DMA_CONFIG_MAX_RRS_XI (0x7L<<16)
1951#define BNX2_DMA_CONFIG_MAX_RRS_128B_XI (0L<<16)
1952#define BNX2_DMA_CONFIG_MAX_RRS_256B_XI (1L<<16)
1953#define BNX2_DMA_CONFIG_MAX_RRS_512B_XI (2L<<16)
1954#define BNX2_DMA_CONFIG_MAX_RRS_1024B_XI (3L<<16)
1955#define BNX2_DMA_CONFIG_MAX_RRS_2048B_XI (4L<<16)
1956#define BNX2_DMA_CONFIG_MAX_RRS_4096B_XI (5L<<16)
1957#define BNX2_DMA_CONFIG_MAX_RRS_EN_XI (1L<<19)
1958#define BNX2_DMA_CONFIG_NO_64SWAP_EN_XI (1L<<31)
1164 1959
1165#define BNX2_DMA_BLACKOUT 0x00000c0c 1960#define BNX2_DMA_BLACKOUT 0x00000c0c
1166#define BNX2_DMA_BLACKOUT_RD_RETRY_BLACKOUT (0xffL<<0) 1961#define BNX2_DMA_BLACKOUT_RD_RETRY_BLACKOUT (0xffL<<0)
1167#define BNX2_DMA_BLACKOUT_2ND_RD_RETRY_BLACKOUT (0xffL<<8) 1962#define BNX2_DMA_BLACKOUT_2ND_RD_RETRY_BLACKOUT (0xffL<<8)
1168#define BNX2_DMA_BLACKOUT_WR_RETRY_BLACKOUT (0xffL<<16) 1963#define BNX2_DMA_BLACKOUT_WR_RETRY_BLACKOUT (0xffL<<16)
1169 1964
1170#define BNX2_DMA_RCHAN_STAT 0x00000c30 1965#define BNX2_DMA_READ_MASTER_SETTING_0 0x00000c10
1171#define BNX2_DMA_RCHAN_STAT_COMP_CODE_0 (0x7L<<0) 1966#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_NO_SNOOP (1L<<0)
1172#define BNX2_DMA_RCHAN_STAT_PAR_ERR_0 (1L<<3) 1967#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_RELAX_ORDER (1L<<1)
1173#define BNX2_DMA_RCHAN_STAT_COMP_CODE_1 (0x7L<<4) 1968#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_PRIORITY (1L<<2)
1174#define BNX2_DMA_RCHAN_STAT_PAR_ERR_1 (1L<<7) 1969#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_TRAFFIC_CLASS (0x7L<<4)
1175#define BNX2_DMA_RCHAN_STAT_COMP_CODE_2 (0x7L<<8) 1970#define BNX2_DMA_READ_MASTER_SETTING_0_TBDC_PARAM_EN (1L<<7)
1176#define BNX2_DMA_RCHAN_STAT_PAR_ERR_2 (1L<<11) 1971#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_NO_SNOOP (1L<<8)
1177#define BNX2_DMA_RCHAN_STAT_COMP_CODE_3 (0x7L<<12) 1972#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_RELAX_ORDER (1L<<9)
1178#define BNX2_DMA_RCHAN_STAT_PAR_ERR_3 (1L<<15) 1973#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_PRIORITY (1L<<10)
1179#define BNX2_DMA_RCHAN_STAT_COMP_CODE_4 (0x7L<<16) 1974#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_TRAFFIC_CLASS (0x7L<<12)
1180#define BNX2_DMA_RCHAN_STAT_PAR_ERR_4 (1L<<19) 1975#define BNX2_DMA_READ_MASTER_SETTING_0_RBDC_PARAM_EN (1L<<15)
1181#define BNX2_DMA_RCHAN_STAT_COMP_CODE_5 (0x7L<<20) 1976#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_NO_SNOOP (1L<<16)
1182#define BNX2_DMA_RCHAN_STAT_PAR_ERR_5 (1L<<23) 1977#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_RELAX_ORDER (1L<<17)
1183#define BNX2_DMA_RCHAN_STAT_COMP_CODE_6 (0x7L<<24) 1978#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_PRIORITY (1L<<18)
1184#define BNX2_DMA_RCHAN_STAT_PAR_ERR_6 (1L<<27) 1979#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_TRAFFIC_CLASS (0x7L<<20)
1185#define BNX2_DMA_RCHAN_STAT_COMP_CODE_7 (0x7L<<28) 1980#define BNX2_DMA_READ_MASTER_SETTING_0_TDMA_PARAM_EN (1L<<23)
1186#define BNX2_DMA_RCHAN_STAT_PAR_ERR_7 (1L<<31) 1981#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_NO_SNOOP (1L<<24)
1187 1982#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_RELAX_ORDER (1L<<25)
1188#define BNX2_DMA_WCHAN_STAT 0x00000c34 1983#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_PRIORITY (1L<<26)
1189#define BNX2_DMA_WCHAN_STAT_COMP_CODE_0 (0x7L<<0) 1984#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_TRAFFIC_CLASS (0x7L<<28)
1190#define BNX2_DMA_WCHAN_STAT_PAR_ERR_0 (1L<<3) 1985#define BNX2_DMA_READ_MASTER_SETTING_0_CTX_PARAM_EN (1L<<31)
1191#define BNX2_DMA_WCHAN_STAT_COMP_CODE_1 (0x7L<<4) 1986
1192#define BNX2_DMA_WCHAN_STAT_PAR_ERR_1 (1L<<7) 1987#define BNX2_DMA_READ_MASTER_SETTING_1 0x00000c14
1193#define BNX2_DMA_WCHAN_STAT_COMP_CODE_2 (0x7L<<8) 1988#define BNX2_DMA_READ_MASTER_SETTING_1_COM_NO_SNOOP (1L<<0)
1194#define BNX2_DMA_WCHAN_STAT_PAR_ERR_2 (1L<<11) 1989#define BNX2_DMA_READ_MASTER_SETTING_1_COM_RELAX_ORDER (1L<<1)
1195#define BNX2_DMA_WCHAN_STAT_COMP_CODE_3 (0x7L<<12) 1990#define BNX2_DMA_READ_MASTER_SETTING_1_COM_PRIORITY (1L<<2)
1196#define BNX2_DMA_WCHAN_STAT_PAR_ERR_3 (1L<<15) 1991#define BNX2_DMA_READ_MASTER_SETTING_1_COM_TRAFFIC_CLASS (0x7L<<4)
1197#define BNX2_DMA_WCHAN_STAT_COMP_CODE_4 (0x7L<<16) 1992#define BNX2_DMA_READ_MASTER_SETTING_1_COM_PARAM_EN (1L<<7)
1198#define BNX2_DMA_WCHAN_STAT_PAR_ERR_4 (1L<<19) 1993#define BNX2_DMA_READ_MASTER_SETTING_1_CP_NO_SNOOP (1L<<8)
1199#define BNX2_DMA_WCHAN_STAT_COMP_CODE_5 (0x7L<<20) 1994#define BNX2_DMA_READ_MASTER_SETTING_1_CP_RELAX_ORDER (1L<<9)
1200#define BNX2_DMA_WCHAN_STAT_PAR_ERR_5 (1L<<23) 1995#define BNX2_DMA_READ_MASTER_SETTING_1_CP_PRIORITY (1L<<10)
1201#define BNX2_DMA_WCHAN_STAT_COMP_CODE_6 (0x7L<<24) 1996#define BNX2_DMA_READ_MASTER_SETTING_1_CP_TRAFFIC_CLASS (0x7L<<12)
1202#define BNX2_DMA_WCHAN_STAT_PAR_ERR_6 (1L<<27) 1997#define BNX2_DMA_READ_MASTER_SETTING_1_CP_PARAM_EN (1L<<15)
1203#define BNX2_DMA_WCHAN_STAT_COMP_CODE_7 (0x7L<<28) 1998
1204#define BNX2_DMA_WCHAN_STAT_PAR_ERR_7 (1L<<31) 1999#define BNX2_DMA_WRITE_MASTER_SETTING_0 0x00000c18
1205 2000#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_NO_SNOOP (1L<<0)
1206#define BNX2_DMA_RCHAN_ASSIGNMENT 0x00000c38 2001#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_RELAX_ORDER (1L<<1)
1207#define BNX2_DMA_RCHAN_ASSIGNMENT_0 (0xfL<<0) 2002#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_PRIORITY (1L<<2)
1208#define BNX2_DMA_RCHAN_ASSIGNMENT_1 (0xfL<<4) 2003#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_CS_VLD (1L<<3)
1209#define BNX2_DMA_RCHAN_ASSIGNMENT_2 (0xfL<<8) 2004#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_TRAFFIC_CLASS (0x7L<<4)
1210#define BNX2_DMA_RCHAN_ASSIGNMENT_3 (0xfL<<12) 2005#define BNX2_DMA_WRITE_MASTER_SETTING_0_HC_PARAM_EN (1L<<7)
1211#define BNX2_DMA_RCHAN_ASSIGNMENT_4 (0xfL<<16) 2006#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_NO_SNOOP (1L<<8)
1212#define BNX2_DMA_RCHAN_ASSIGNMENT_5 (0xfL<<20) 2007#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_RELAX_ORDER (1L<<9)
1213#define BNX2_DMA_RCHAN_ASSIGNMENT_6 (0xfL<<24) 2008#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_PRIORITY (1L<<10)
1214#define BNX2_DMA_RCHAN_ASSIGNMENT_7 (0xfL<<28) 2009#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_CS_VLD (1L<<11)
1215 2010#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_TRAFFIC_CLASS (0x7L<<12)
1216#define BNX2_DMA_WCHAN_ASSIGNMENT 0x00000c3c 2011#define BNX2_DMA_WRITE_MASTER_SETTING_0_RDMA_PARAM_EN (1L<<15)
1217#define BNX2_DMA_WCHAN_ASSIGNMENT_0 (0xfL<<0) 2012#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_NO_SNOOP (1L<<24)
1218#define BNX2_DMA_WCHAN_ASSIGNMENT_1 (0xfL<<4) 2013#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_RELAX_ORDER (1L<<25)
1219#define BNX2_DMA_WCHAN_ASSIGNMENT_2 (0xfL<<8) 2014#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_PRIORITY (1L<<26)
1220#define BNX2_DMA_WCHAN_ASSIGNMENT_3 (0xfL<<12) 2015#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_CS_VLD (1L<<27)
1221#define BNX2_DMA_WCHAN_ASSIGNMENT_4 (0xfL<<16) 2016#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_TRAFFIC_CLASS (0x7L<<28)
1222#define BNX2_DMA_WCHAN_ASSIGNMENT_5 (0xfL<<20) 2017#define BNX2_DMA_WRITE_MASTER_SETTING_0_CTX_PARAM_EN (1L<<31)
1223#define BNX2_DMA_WCHAN_ASSIGNMENT_6 (0xfL<<24) 2018
1224#define BNX2_DMA_WCHAN_ASSIGNMENT_7 (0xfL<<28) 2019#define BNX2_DMA_WRITE_MASTER_SETTING_1 0x00000c1c
1225 2020#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_NO_SNOOP (1L<<0)
1226#define BNX2_DMA_RCHAN_STAT_00 0x00000c40 2021#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_RELAX_ORDER (1L<<1)
1227#define BNX2_DMA_RCHAN_STAT_00_RCHAN_STA_HOST_ADDR_LOW (0xffffffffL<<0) 2022#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_PRIORITY (1L<<2)
1228 2023#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_CS_VLD (1L<<3)
1229#define BNX2_DMA_RCHAN_STAT_01 0x00000c44 2024#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_TRAFFIC_CLASS (0x7L<<4)
1230#define BNX2_DMA_RCHAN_STAT_01_RCHAN_STA_HOST_ADDR_HIGH (0xffffffffL<<0) 2025#define BNX2_DMA_WRITE_MASTER_SETTING_1_COM_PARAM_EN (1L<<7)
1231 2026#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_NO_SNOOP (1L<<8)
1232#define BNX2_DMA_RCHAN_STAT_02 0x00000c48 2027#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_RELAX_ORDER (1L<<9)
1233#define BNX2_DMA_RCHAN_STAT_02_LENGTH (0xffffL<<0) 2028#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_PRIORITY (1L<<10)
1234#define BNX2_DMA_RCHAN_STAT_02_WORD_SWAP (1L<<16) 2029#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_CS_VLD (1L<<11)
1235#define BNX2_DMA_RCHAN_STAT_02_BYTE_SWAP (1L<<17) 2030#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_TRAFFIC_CLASS (0x7L<<12)
1236#define BNX2_DMA_RCHAN_STAT_02_PRIORITY_LVL (1L<<18) 2031#define BNX2_DMA_WRITE_MASTER_SETTING_1_CP_PARAM_EN (1L<<15)
1237 2032
1238#define BNX2_DMA_RCHAN_STAT_10 0x00000c4c 2033#define BNX2_DMA_ARBITER 0x00000c20
1239#define BNX2_DMA_RCHAN_STAT_11 0x00000c50 2034#define BNX2_DMA_ARBITER_NUM_READS (0x7L<<0)
1240#define BNX2_DMA_RCHAN_STAT_12 0x00000c54 2035#define BNX2_DMA_ARBITER_WR_ARB_MODE (1L<<4)
1241#define BNX2_DMA_RCHAN_STAT_20 0x00000c58 2036#define BNX2_DMA_ARBITER_WR_ARB_MODE_STRICT (0L<<4)
1242#define BNX2_DMA_RCHAN_STAT_21 0x00000c5c 2037#define BNX2_DMA_ARBITER_WR_ARB_MODE_RND_RBN (1L<<4)
2038#define BNX2_DMA_ARBITER_RD_ARB_MODE (0x3L<<5)
2039#define BNX2_DMA_ARBITER_RD_ARB_MODE_STRICT (0L<<5)
2040#define BNX2_DMA_ARBITER_RD_ARB_MODE_RND_RBN (1L<<5)
2041#define BNX2_DMA_ARBITER_RD_ARB_MODE_WGT_RND_RBN (2L<<5)
2042#define BNX2_DMA_ARBITER_ALT_MODE_EN (1L<<8)
2043#define BNX2_DMA_ARBITER_RR_MODE (1L<<9)
2044#define BNX2_DMA_ARBITER_TIMER_MODE (1L<<10)
2045#define BNX2_DMA_ARBITER_OUSTD_READ_REQ (0xfL<<12)
2046
2047#define BNX2_DMA_ARB_TIMERS 0x00000c24
2048#define BNX2_DMA_ARB_TIMERS_RD_DRR_WAIT_TIME (0xffL<<0)
2049#define BNX2_DMA_ARB_TIMERS_TM_MIN_TIMEOUT (0xffL<<12)
2050#define BNX2_DMA_ARB_TIMERS_TM_MAX_TIMEOUT (0xfffL<<20)
2051
2052#define BNX2_DMA_DEBUG_VECT_PEEK 0x00000c2c
2053#define BNX2_DMA_DEBUG_VECT_PEEK_1_VALUE (0x7ffL<<0)
2054#define BNX2_DMA_DEBUG_VECT_PEEK_1_PEEK_EN (1L<<11)
2055#define BNX2_DMA_DEBUG_VECT_PEEK_1_SEL (0xfL<<12)
2056#define BNX2_DMA_DEBUG_VECT_PEEK_2_VALUE (0x7ffL<<16)
2057#define BNX2_DMA_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
2058#define BNX2_DMA_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
2059
2060#define BNX2_DMA_TAG_RAM_00 0x00000c30
2061#define BNX2_DMA_TAG_RAM_00_CHANNEL (0xfL<<0)
2062#define BNX2_DMA_TAG_RAM_00_MASTER (0x7L<<4)
2063#define BNX2_DMA_TAG_RAM_00_MASTER_CTX (0L<<4)
2064#define BNX2_DMA_TAG_RAM_00_MASTER_RBDC (1L<<4)
2065#define BNX2_DMA_TAG_RAM_00_MASTER_TBDC (2L<<4)
2066#define BNX2_DMA_TAG_RAM_00_MASTER_COM (3L<<4)
2067#define BNX2_DMA_TAG_RAM_00_MASTER_CP (4L<<4)
2068#define BNX2_DMA_TAG_RAM_00_MASTER_TDMA (5L<<4)
2069#define BNX2_DMA_TAG_RAM_00_SWAP (0x3L<<7)
2070#define BNX2_DMA_TAG_RAM_00_SWAP_CONFIG (0L<<7)
2071#define BNX2_DMA_TAG_RAM_00_SWAP_DATA (1L<<7)
2072#define BNX2_DMA_TAG_RAM_00_SWAP_CONTROL (2L<<7)
2073#define BNX2_DMA_TAG_RAM_00_FUNCTION (1L<<9)
2074#define BNX2_DMA_TAG_RAM_00_VALID (1L<<10)
2075
2076#define BNX2_DMA_TAG_RAM_01 0x00000c34
2077#define BNX2_DMA_TAG_RAM_01_CHANNEL (0xfL<<0)
2078#define BNX2_DMA_TAG_RAM_01_MASTER (0x7L<<4)
2079#define BNX2_DMA_TAG_RAM_01_MASTER_CTX (0L<<4)
2080#define BNX2_DMA_TAG_RAM_01_MASTER_RBDC (1L<<4)
2081#define BNX2_DMA_TAG_RAM_01_MASTER_TBDC (2L<<4)
2082#define BNX2_DMA_TAG_RAM_01_MASTER_COM (3L<<4)
2083#define BNX2_DMA_TAG_RAM_01_MASTER_CP (4L<<4)
2084#define BNX2_DMA_TAG_RAM_01_MASTER_TDMA (5L<<4)
2085#define BNX2_DMA_TAG_RAM_01_SWAP (0x3L<<7)
2086#define BNX2_DMA_TAG_RAM_01_SWAP_CONFIG (0L<<7)
2087#define BNX2_DMA_TAG_RAM_01_SWAP_DATA (1L<<7)
2088#define BNX2_DMA_TAG_RAM_01_SWAP_CONTROL (2L<<7)
2089#define BNX2_DMA_TAG_RAM_01_FUNCTION (1L<<9)
2090#define BNX2_DMA_TAG_RAM_01_VALID (1L<<10)
2091
2092#define BNX2_DMA_TAG_RAM_02 0x00000c38
2093#define BNX2_DMA_TAG_RAM_02_CHANNEL (0xfL<<0)
2094#define BNX2_DMA_TAG_RAM_02_MASTER (0x7L<<4)
2095#define BNX2_DMA_TAG_RAM_02_MASTER_CTX (0L<<4)
2096#define BNX2_DMA_TAG_RAM_02_MASTER_RBDC (1L<<4)
2097#define BNX2_DMA_TAG_RAM_02_MASTER_TBDC (2L<<4)
2098#define BNX2_DMA_TAG_RAM_02_MASTER_COM (3L<<4)
2099#define BNX2_DMA_TAG_RAM_02_MASTER_CP (4L<<4)
2100#define BNX2_DMA_TAG_RAM_02_MASTER_TDMA (5L<<4)
2101#define BNX2_DMA_TAG_RAM_02_SWAP (0x3L<<7)
2102#define BNX2_DMA_TAG_RAM_02_SWAP_CONFIG (0L<<7)
2103#define BNX2_DMA_TAG_RAM_02_SWAP_DATA (1L<<7)
2104#define BNX2_DMA_TAG_RAM_02_SWAP_CONTROL (2L<<7)
2105#define BNX2_DMA_TAG_RAM_02_FUNCTION (1L<<9)
2106#define BNX2_DMA_TAG_RAM_02_VALID (1L<<10)
2107
2108#define BNX2_DMA_TAG_RAM_03 0x00000c3c
2109#define BNX2_DMA_TAG_RAM_03_CHANNEL (0xfL<<0)
2110#define BNX2_DMA_TAG_RAM_03_MASTER (0x7L<<4)
2111#define BNX2_DMA_TAG_RAM_03_MASTER_CTX (0L<<4)
2112#define BNX2_DMA_TAG_RAM_03_MASTER_RBDC (1L<<4)
2113#define BNX2_DMA_TAG_RAM_03_MASTER_TBDC (2L<<4)
2114#define BNX2_DMA_TAG_RAM_03_MASTER_COM (3L<<4)
2115#define BNX2_DMA_TAG_RAM_03_MASTER_CP (4L<<4)
2116#define BNX2_DMA_TAG_RAM_03_MASTER_TDMA (5L<<4)
2117#define BNX2_DMA_TAG_RAM_03_SWAP (0x3L<<7)
2118#define BNX2_DMA_TAG_RAM_03_SWAP_CONFIG (0L<<7)
2119#define BNX2_DMA_TAG_RAM_03_SWAP_DATA (1L<<7)
2120#define BNX2_DMA_TAG_RAM_03_SWAP_CONTROL (2L<<7)
2121#define BNX2_DMA_TAG_RAM_03_FUNCTION (1L<<9)
2122#define BNX2_DMA_TAG_RAM_03_VALID (1L<<10)
2123
2124#define BNX2_DMA_TAG_RAM_04 0x00000c40
2125#define BNX2_DMA_TAG_RAM_04_CHANNEL (0xfL<<0)
2126#define BNX2_DMA_TAG_RAM_04_MASTER (0x7L<<4)
2127#define BNX2_DMA_TAG_RAM_04_MASTER_CTX (0L<<4)
2128#define BNX2_DMA_TAG_RAM_04_MASTER_RBDC (1L<<4)
2129#define BNX2_DMA_TAG_RAM_04_MASTER_TBDC (2L<<4)
2130#define BNX2_DMA_TAG_RAM_04_MASTER_COM (3L<<4)
2131#define BNX2_DMA_TAG_RAM_04_MASTER_CP (4L<<4)
2132#define BNX2_DMA_TAG_RAM_04_MASTER_TDMA (5L<<4)
2133#define BNX2_DMA_TAG_RAM_04_SWAP (0x3L<<7)
2134#define BNX2_DMA_TAG_RAM_04_SWAP_CONFIG (0L<<7)
2135#define BNX2_DMA_TAG_RAM_04_SWAP_DATA (1L<<7)
2136#define BNX2_DMA_TAG_RAM_04_SWAP_CONTROL (2L<<7)
2137#define BNX2_DMA_TAG_RAM_04_FUNCTION (1L<<9)
2138#define BNX2_DMA_TAG_RAM_04_VALID (1L<<10)
2139
2140#define BNX2_DMA_TAG_RAM_05 0x00000c44
2141#define BNX2_DMA_TAG_RAM_05_CHANNEL (0xfL<<0)
2142#define BNX2_DMA_TAG_RAM_05_MASTER (0x7L<<4)
2143#define BNX2_DMA_TAG_RAM_05_MASTER_CTX (0L<<4)
2144#define BNX2_DMA_TAG_RAM_05_MASTER_RBDC (1L<<4)
2145#define BNX2_DMA_TAG_RAM_05_MASTER_TBDC (2L<<4)
2146#define BNX2_DMA_TAG_RAM_05_MASTER_COM (3L<<4)
2147#define BNX2_DMA_TAG_RAM_05_MASTER_CP (4L<<4)
2148#define BNX2_DMA_TAG_RAM_05_MASTER_TDMA (5L<<4)
2149#define BNX2_DMA_TAG_RAM_05_SWAP (0x3L<<7)
2150#define BNX2_DMA_TAG_RAM_05_SWAP_CONFIG (0L<<7)
2151#define BNX2_DMA_TAG_RAM_05_SWAP_DATA (1L<<7)
2152#define BNX2_DMA_TAG_RAM_05_SWAP_CONTROL (2L<<7)
2153#define BNX2_DMA_TAG_RAM_05_FUNCTION (1L<<9)
2154#define BNX2_DMA_TAG_RAM_05_VALID (1L<<10)
2155
2156#define BNX2_DMA_TAG_RAM_06 0x00000c48
2157#define BNX2_DMA_TAG_RAM_06_CHANNEL (0xfL<<0)
2158#define BNX2_DMA_TAG_RAM_06_MASTER (0x7L<<4)
2159#define BNX2_DMA_TAG_RAM_06_MASTER_CTX (0L<<4)
2160#define BNX2_DMA_TAG_RAM_06_MASTER_RBDC (1L<<4)
2161#define BNX2_DMA_TAG_RAM_06_MASTER_TBDC (2L<<4)
2162#define BNX2_DMA_TAG_RAM_06_MASTER_COM (3L<<4)
2163#define BNX2_DMA_TAG_RAM_06_MASTER_CP (4L<<4)
2164#define BNX2_DMA_TAG_RAM_06_MASTER_TDMA (5L<<4)
2165#define BNX2_DMA_TAG_RAM_06_SWAP (0x3L<<7)
2166#define BNX2_DMA_TAG_RAM_06_SWAP_CONFIG (0L<<7)
2167#define BNX2_DMA_TAG_RAM_06_SWAP_DATA (1L<<7)
2168#define BNX2_DMA_TAG_RAM_06_SWAP_CONTROL (2L<<7)
2169#define BNX2_DMA_TAG_RAM_06_FUNCTION (1L<<9)
2170#define BNX2_DMA_TAG_RAM_06_VALID (1L<<10)
2171
2172#define BNX2_DMA_TAG_RAM_07 0x00000c4c
2173#define BNX2_DMA_TAG_RAM_07_CHANNEL (0xfL<<0)
2174#define BNX2_DMA_TAG_RAM_07_MASTER (0x7L<<4)
2175#define BNX2_DMA_TAG_RAM_07_MASTER_CTX (0L<<4)
2176#define BNX2_DMA_TAG_RAM_07_MASTER_RBDC (1L<<4)
2177#define BNX2_DMA_TAG_RAM_07_MASTER_TBDC (2L<<4)
2178#define BNX2_DMA_TAG_RAM_07_MASTER_COM (3L<<4)
2179#define BNX2_DMA_TAG_RAM_07_MASTER_CP (4L<<4)
2180#define BNX2_DMA_TAG_RAM_07_MASTER_TDMA (5L<<4)
2181#define BNX2_DMA_TAG_RAM_07_SWAP (0x3L<<7)
2182#define BNX2_DMA_TAG_RAM_07_SWAP_CONFIG (0L<<7)
2183#define BNX2_DMA_TAG_RAM_07_SWAP_DATA (1L<<7)
2184#define BNX2_DMA_TAG_RAM_07_SWAP_CONTROL (2L<<7)
2185#define BNX2_DMA_TAG_RAM_07_FUNCTION (1L<<9)
2186#define BNX2_DMA_TAG_RAM_07_VALID (1L<<10)
2187
2188#define BNX2_DMA_TAG_RAM_08 0x00000c50
2189#define BNX2_DMA_TAG_RAM_08_CHANNEL (0xfL<<0)
2190#define BNX2_DMA_TAG_RAM_08_MASTER (0x7L<<4)
2191#define BNX2_DMA_TAG_RAM_08_MASTER_CTX (0L<<4)
2192#define BNX2_DMA_TAG_RAM_08_MASTER_RBDC (1L<<4)
2193#define BNX2_DMA_TAG_RAM_08_MASTER_TBDC (2L<<4)
2194#define BNX2_DMA_TAG_RAM_08_MASTER_COM (3L<<4)
2195#define BNX2_DMA_TAG_RAM_08_MASTER_CP (4L<<4)
2196#define BNX2_DMA_TAG_RAM_08_MASTER_TDMA (5L<<4)
2197#define BNX2_DMA_TAG_RAM_08_SWAP (0x3L<<7)
2198#define BNX2_DMA_TAG_RAM_08_SWAP_CONFIG (0L<<7)
2199#define BNX2_DMA_TAG_RAM_08_SWAP_DATA (1L<<7)
2200#define BNX2_DMA_TAG_RAM_08_SWAP_CONTROL (2L<<7)
2201#define BNX2_DMA_TAG_RAM_08_FUNCTION (1L<<9)
2202#define BNX2_DMA_TAG_RAM_08_VALID (1L<<10)
2203
2204#define BNX2_DMA_TAG_RAM_09 0x00000c54
2205#define BNX2_DMA_TAG_RAM_09_CHANNEL (0xfL<<0)
2206#define BNX2_DMA_TAG_RAM_09_MASTER (0x7L<<4)
2207#define BNX2_DMA_TAG_RAM_09_MASTER_CTX (0L<<4)
2208#define BNX2_DMA_TAG_RAM_09_MASTER_RBDC (1L<<4)
2209#define BNX2_DMA_TAG_RAM_09_MASTER_TBDC (2L<<4)
2210#define BNX2_DMA_TAG_RAM_09_MASTER_COM (3L<<4)
2211#define BNX2_DMA_TAG_RAM_09_MASTER_CP (4L<<4)
2212#define BNX2_DMA_TAG_RAM_09_MASTER_TDMA (5L<<4)
2213#define BNX2_DMA_TAG_RAM_09_SWAP (0x3L<<7)
2214#define BNX2_DMA_TAG_RAM_09_SWAP_CONFIG (0L<<7)
2215#define BNX2_DMA_TAG_RAM_09_SWAP_DATA (1L<<7)
2216#define BNX2_DMA_TAG_RAM_09_SWAP_CONTROL (2L<<7)
2217#define BNX2_DMA_TAG_RAM_09_FUNCTION (1L<<9)
2218#define BNX2_DMA_TAG_RAM_09_VALID (1L<<10)
2219
2220#define BNX2_DMA_TAG_RAM_10 0x00000c58
2221#define BNX2_DMA_TAG_RAM_10_CHANNEL (0xfL<<0)
2222#define BNX2_DMA_TAG_RAM_10_MASTER (0x7L<<4)
2223#define BNX2_DMA_TAG_RAM_10_MASTER_CTX (0L<<4)
2224#define BNX2_DMA_TAG_RAM_10_MASTER_RBDC (1L<<4)
2225#define BNX2_DMA_TAG_RAM_10_MASTER_TBDC (2L<<4)
2226#define BNX2_DMA_TAG_RAM_10_MASTER_COM (3L<<4)
2227#define BNX2_DMA_TAG_RAM_10_MASTER_CP (4L<<4)
2228#define BNX2_DMA_TAG_RAM_10_MASTER_TDMA (5L<<4)
2229#define BNX2_DMA_TAG_RAM_10_SWAP (0x3L<<7)
2230#define BNX2_DMA_TAG_RAM_10_SWAP_CONFIG (0L<<7)
2231#define BNX2_DMA_TAG_RAM_10_SWAP_DATA (1L<<7)
2232#define BNX2_DMA_TAG_RAM_10_SWAP_CONTROL (2L<<7)
2233#define BNX2_DMA_TAG_RAM_10_FUNCTION (1L<<9)
2234#define BNX2_DMA_TAG_RAM_10_VALID (1L<<10)
2235
2236#define BNX2_DMA_TAG_RAM_11 0x00000c5c
2237#define BNX2_DMA_TAG_RAM_11_CHANNEL (0xfL<<0)
2238#define BNX2_DMA_TAG_RAM_11_MASTER (0x7L<<4)
2239#define BNX2_DMA_TAG_RAM_11_MASTER_CTX (0L<<4)
2240#define BNX2_DMA_TAG_RAM_11_MASTER_RBDC (1L<<4)
2241#define BNX2_DMA_TAG_RAM_11_MASTER_TBDC (2L<<4)
2242#define BNX2_DMA_TAG_RAM_11_MASTER_COM (3L<<4)
2243#define BNX2_DMA_TAG_RAM_11_MASTER_CP (4L<<4)
2244#define BNX2_DMA_TAG_RAM_11_MASTER_TDMA (5L<<4)
2245#define BNX2_DMA_TAG_RAM_11_SWAP (0x3L<<7)
2246#define BNX2_DMA_TAG_RAM_11_SWAP_CONFIG (0L<<7)
2247#define BNX2_DMA_TAG_RAM_11_SWAP_DATA (1L<<7)
2248#define BNX2_DMA_TAG_RAM_11_SWAP_CONTROL (2L<<7)
2249#define BNX2_DMA_TAG_RAM_11_FUNCTION (1L<<9)
2250#define BNX2_DMA_TAG_RAM_11_VALID (1L<<10)
2251
1243#define BNX2_DMA_RCHAN_STAT_22 0x00000c60 2252#define BNX2_DMA_RCHAN_STAT_22 0x00000c60
1244#define BNX2_DMA_RCHAN_STAT_30 0x00000c64 2253#define BNX2_DMA_RCHAN_STAT_30 0x00000c64
1245#define BNX2_DMA_RCHAN_STAT_31 0x00000c68 2254#define BNX2_DMA_RCHAN_STAT_31 0x00000c68
@@ -1336,6 +2345,25 @@ struct l2_fhdr {
1336 */ 2345 */
1337#define BNX2_CTX_COMMAND 0x00001000 2346#define BNX2_CTX_COMMAND 0x00001000
1338#define BNX2_CTX_COMMAND_ENABLED (1L<<0) 2347#define BNX2_CTX_COMMAND_ENABLED (1L<<0)
2348#define BNX2_CTX_COMMAND_DISABLE_USAGE_CNT (1L<<1)
2349#define BNX2_CTX_COMMAND_DISABLE_PLRU (1L<<2)
2350#define BNX2_CTX_COMMAND_DISABLE_COMBINE_READ (1L<<3)
2351#define BNX2_CTX_COMMAND_FLUSH_AHEAD (0x1fL<<8)
2352#define BNX2_CTX_COMMAND_MEM_INIT (1L<<13)
2353#define BNX2_CTX_COMMAND_PAGE_SIZE (0xfL<<16)
2354#define BNX2_CTX_COMMAND_PAGE_SIZE_256 (0L<<16)
2355#define BNX2_CTX_COMMAND_PAGE_SIZE_512 (1L<<16)
2356#define BNX2_CTX_COMMAND_PAGE_SIZE_1K (2L<<16)
2357#define BNX2_CTX_COMMAND_PAGE_SIZE_2K (3L<<16)
2358#define BNX2_CTX_COMMAND_PAGE_SIZE_4K (4L<<16)
2359#define BNX2_CTX_COMMAND_PAGE_SIZE_8K (5L<<16)
2360#define BNX2_CTX_COMMAND_PAGE_SIZE_16K (6L<<16)
2361#define BNX2_CTX_COMMAND_PAGE_SIZE_32K (7L<<16)
2362#define BNX2_CTX_COMMAND_PAGE_SIZE_64K (8L<<16)
2363#define BNX2_CTX_COMMAND_PAGE_SIZE_128K (9L<<16)
2364#define BNX2_CTX_COMMAND_PAGE_SIZE_256K (10L<<16)
2365#define BNX2_CTX_COMMAND_PAGE_SIZE_512K (11L<<16)
2366#define BNX2_CTX_COMMAND_PAGE_SIZE_1M (12L<<16)
1339 2367
1340#define BNX2_CTX_STATUS 0x00001004 2368#define BNX2_CTX_STATUS 0x00001004
1341#define BNX2_CTX_STATUS_LOCK_WAIT (1L<<0) 2369#define BNX2_CTX_STATUS_LOCK_WAIT (1L<<0)
@@ -1343,6 +2371,13 @@ struct l2_fhdr {
1343#define BNX2_CTX_STATUS_WRITE_STAT (1L<<17) 2371#define BNX2_CTX_STATUS_WRITE_STAT (1L<<17)
1344#define BNX2_CTX_STATUS_ACC_STALL_STAT (1L<<18) 2372#define BNX2_CTX_STATUS_ACC_STALL_STAT (1L<<18)
1345#define BNX2_CTX_STATUS_LOCK_STALL_STAT (1L<<19) 2373#define BNX2_CTX_STATUS_LOCK_STALL_STAT (1L<<19)
2374#define BNX2_CTX_STATUS_EXT_READ_STAT (1L<<20)
2375#define BNX2_CTX_STATUS_EXT_WRITE_STAT (1L<<21)
2376#define BNX2_CTX_STATUS_MISS_STAT (1L<<22)
2377#define BNX2_CTX_STATUS_HIT_STAT (1L<<23)
2378#define BNX2_CTX_STATUS_DEAD_LOCK (1L<<24)
2379#define BNX2_CTX_STATUS_USAGE_CNT_ERR (1L<<25)
2380#define BNX2_CTX_STATUS_INVALID_PAGE (1L<<26)
1346 2381
1347#define BNX2_CTX_VIRT_ADDR 0x00001008 2382#define BNX2_CTX_VIRT_ADDR 0x00001008
1348#define BNX2_CTX_VIRT_ADDR_VIRT_ADDR (0x7fffL<<6) 2383#define BNX2_CTX_VIRT_ADDR_VIRT_ADDR (0x7fffL<<6)
@@ -1357,10 +2392,15 @@ struct l2_fhdr {
1357#define BNX2_CTX_LOCK 0x00001018 2392#define BNX2_CTX_LOCK 0x00001018
1358#define BNX2_CTX_LOCK_TYPE (0x7L<<0) 2393#define BNX2_CTX_LOCK_TYPE (0x7L<<0)
1359#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_VOID (0x0L<<0) 2394#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_VOID (0x0L<<0)
1360#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_COMPLETE (0x7L<<0)
1361#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_PROTOCOL (0x1L<<0) 2395#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_PROTOCOL (0x1L<<0)
1362#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TX (0x2L<<0) 2396#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TX (0x2L<<0)
1363#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TIMER (0x4L<<0) 2397#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_TIMER (0x4L<<0)
2398#define BNX2_CTX_LOCK_TYPE_LOCK_TYPE_COMPLETE (0x7L<<0)
2399#define BNX2_CTX_LOCK_TYPE_VOID_XI (0L<<0)
2400#define BNX2_CTX_LOCK_TYPE_PROTOCOL_XI (1L<<0)
2401#define BNX2_CTX_LOCK_TYPE_TX_XI (2L<<0)
2402#define BNX2_CTX_LOCK_TYPE_TIMER_XI (4L<<0)
2403#define BNX2_CTX_LOCK_TYPE_COMPLETE_XI (7L<<0)
1364#define BNX2_CTX_LOCK_CID_VALUE (0x3fffL<<7) 2404#define BNX2_CTX_LOCK_CID_VALUE (0x3fffL<<7)
1365#define BNX2_CTX_LOCK_GRANTED (1L<<26) 2405#define BNX2_CTX_LOCK_GRANTED (1L<<26)
1366#define BNX2_CTX_LOCK_MODE (0x7L<<27) 2406#define BNX2_CTX_LOCK_MODE (0x7L<<27)
@@ -1370,21 +2410,89 @@ struct l2_fhdr {
1370#define BNX2_CTX_LOCK_STATUS (1L<<30) 2410#define BNX2_CTX_LOCK_STATUS (1L<<30)
1371#define BNX2_CTX_LOCK_REQ (1L<<31) 2411#define BNX2_CTX_LOCK_REQ (1L<<31)
1372 2412
2413#define BNX2_CTX_CTX_CTRL 0x0000101c
2414#define BNX2_CTX_CTX_CTRL_CTX_ADDR (0x7ffffL<<2)
2415#define BNX2_CTX_CTX_CTRL_MOD_USAGE_CNT (0x3L<<21)
2416#define BNX2_CTX_CTX_CTRL_NO_RAM_ACC (1L<<23)
2417#define BNX2_CTX_CTX_CTRL_PREFETCH_SIZE (0x3L<<24)
2418#define BNX2_CTX_CTX_CTRL_ATTR (1L<<26)
2419#define BNX2_CTX_CTX_CTRL_WRITE_REQ (1L<<30)
2420#define BNX2_CTX_CTX_CTRL_READ_REQ (1L<<31)
2421
2422#define BNX2_CTX_CTX_DATA 0x00001020
1373#define BNX2_CTX_ACCESS_STATUS 0x00001040 2423#define BNX2_CTX_ACCESS_STATUS 0x00001040
1374#define BNX2_CTX_ACCESS_STATUS_MASTERENCODED (0xfL<<0) 2424#define BNX2_CTX_ACCESS_STATUS_MASTERENCODED (0xfL<<0)
1375#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYSM (0x3L<<10) 2425#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYSM (0x3L<<10)
1376#define BNX2_CTX_ACCESS_STATUS_PAGETABLEINITSM (0x3L<<12) 2426#define BNX2_CTX_ACCESS_STATUS_PAGETABLEINITSM (0x3L<<12)
1377#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYINITSM (0x3L<<14) 2427#define BNX2_CTX_ACCESS_STATUS_ACCESSMEMORYINITSM (0x3L<<14)
1378#define BNX2_CTX_ACCESS_STATUS_QUALIFIED_REQUEST (0x7ffL<<17) 2428#define BNX2_CTX_ACCESS_STATUS_QUALIFIED_REQUEST (0x7ffL<<17)
2429#define BNX2_CTX_ACCESS_STATUS_CAMMASTERENCODED_XI (0x1fL<<0)
2430#define BNX2_CTX_ACCESS_STATUS_CACHEMASTERENCODED_XI (0x1fL<<5)
2431#define BNX2_CTX_ACCESS_STATUS_REQUEST_XI (0x3fffffL<<10)
1379 2432
1380#define BNX2_CTX_DBG_LOCK_STATUS 0x00001044 2433#define BNX2_CTX_DBG_LOCK_STATUS 0x00001044
1381#define BNX2_CTX_DBG_LOCK_STATUS_SM (0x3ffL<<0) 2434#define BNX2_CTX_DBG_LOCK_STATUS_SM (0x3ffL<<0)
1382#define BNX2_CTX_DBG_LOCK_STATUS_MATCH (0x3ffL<<22) 2435#define BNX2_CTX_DBG_LOCK_STATUS_MATCH (0x3ffL<<22)
1383 2436
2437#define BNX2_CTX_CACHE_CTRL_STATUS 0x00001048
2438#define BNX2_CTX_CACHE_CTRL_STATUS_RFIFO_OVERFLOW (1L<<0)
2439#define BNX2_CTX_CACHE_CTRL_STATUS_INVALID_READ_COMP (1L<<1)
2440#define BNX2_CTX_CACHE_CTRL_STATUS_FLUSH_START (1L<<6)
2441#define BNX2_CTX_CACHE_CTRL_STATUS_FREE_ENTRY_CNT (0x3fL<<7)
2442#define BNX2_CTX_CACHE_CTRL_STATUS_CACHE_ENTRY_NEEDED (0x3fL<<13)
2443#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN0_ACTIVE (1L<<19)
2444#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN1_ACTIVE (1L<<20)
2445#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN2_ACTIVE (1L<<21)
2446#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN3_ACTIVE (1L<<22)
2447#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN4_ACTIVE (1L<<23)
2448#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN5_ACTIVE (1L<<24)
2449#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN6_ACTIVE (1L<<25)
2450#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN7_ACTIVE (1L<<26)
2451#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN8_ACTIVE (1L<<27)
2452#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN9_ACTIVE (1L<<28)
2453#define BNX2_CTX_CACHE_CTRL_STATUS_RD_CHAN10_ACTIVE (1L<<29)
2454
2455#define BNX2_CTX_CACHE_CTRL_SM_STATUS 0x0000104c
2456#define BNX2_CTX_CACHE_CTRL_SM_STATUS_CS_DWC (0x7L<<0)
2457#define BNX2_CTX_CACHE_CTRL_SM_STATUS_CS_WFIFOC (0x7L<<3)
2458#define BNX2_CTX_CACHE_CTRL_SM_STATUS_CS_RTAGC (0x7L<<6)
2459#define BNX2_CTX_CACHE_CTRL_SM_STATUS_CS_RFIFOC (0x7L<<9)
2460#define BNX2_CTX_CACHE_CTRL_SM_STATUS_INVALID_BLK_ADDR (0x7fffL<<16)
2461
2462#define BNX2_CTX_CACHE_STATUS 0x00001050
2463#define BNX2_CTX_CACHE_STATUS_HELD_ENTRIES (0x3ffL<<0)
2464#define BNX2_CTX_CACHE_STATUS_MAX_HELD_ENTRIES (0x3ffL<<16)
2465
2466#define BNX2_CTX_DMA_STATUS 0x00001054
2467#define BNX2_CTX_DMA_STATUS_RD_CHAN0_STATUS (0x3L<<0)
2468#define BNX2_CTX_DMA_STATUS_RD_CHAN1_STATUS (0x3L<<2)
2469#define BNX2_CTX_DMA_STATUS_RD_CHAN2_STATUS (0x3L<<4)
2470#define BNX2_CTX_DMA_STATUS_RD_CHAN3_STATUS (0x3L<<6)
2471#define BNX2_CTX_DMA_STATUS_RD_CHAN4_STATUS (0x3L<<8)
2472#define BNX2_CTX_DMA_STATUS_RD_CHAN5_STATUS (0x3L<<10)
2473#define BNX2_CTX_DMA_STATUS_RD_CHAN6_STATUS (0x3L<<12)
2474#define BNX2_CTX_DMA_STATUS_RD_CHAN7_STATUS (0x3L<<14)
2475#define BNX2_CTX_DMA_STATUS_RD_CHAN8_STATUS (0x3L<<16)
2476#define BNX2_CTX_DMA_STATUS_RD_CHAN9_STATUS (0x3L<<18)
2477#define BNX2_CTX_DMA_STATUS_RD_CHAN10_STATUS (0x3L<<20)
2478
2479#define BNX2_CTX_REP_STATUS 0x00001058
2480#define BNX2_CTX_REP_STATUS_ERROR_ENTRY (0x3ffL<<0)
2481#define BNX2_CTX_REP_STATUS_ERROR_CLIENT_ID (0x1fL<<10)
2482#define BNX2_CTX_REP_STATUS_USAGE_CNT_MAX_ERR (1L<<16)
2483#define BNX2_CTX_REP_STATUS_USAGE_CNT_MIN_ERR (1L<<17)
2484#define BNX2_CTX_REP_STATUS_USAGE_CNT_MISS_ERR (1L<<18)
2485
2486#define BNX2_CTX_CKSUM_ERROR_STATUS 0x0000105c
2487#define BNX2_CTX_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
2488#define BNX2_CTX_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
2489
1384#define BNX2_CTX_CHNL_LOCK_STATUS_0 0x00001080 2490#define BNX2_CTX_CHNL_LOCK_STATUS_0 0x00001080
1385#define BNX2_CTX_CHNL_LOCK_STATUS_0_CID (0x3fffL<<0) 2491#define BNX2_CTX_CHNL_LOCK_STATUS_0_CID (0x3fffL<<0)
1386#define BNX2_CTX_CHNL_LOCK_STATUS_0_TYPE (0x3L<<14) 2492#define BNX2_CTX_CHNL_LOCK_STATUS_0_TYPE (0x3L<<14)
1387#define BNX2_CTX_CHNL_LOCK_STATUS_0_MODE (1L<<16) 2493#define BNX2_CTX_CHNL_LOCK_STATUS_0_MODE (1L<<16)
2494#define BNX2_CTX_CHNL_LOCK_STATUS_0_MODE_XI (1L<<14)
2495#define BNX2_CTX_CHNL_LOCK_STATUS_0_TYPE_XI (0x7L<<15)
1388 2496
1389#define BNX2_CTX_CHNL_LOCK_STATUS_1 0x00001084 2497#define BNX2_CTX_CHNL_LOCK_STATUS_1 0x00001084
1390#define BNX2_CTX_CHNL_LOCK_STATUS_2 0x00001088 2498#define BNX2_CTX_CHNL_LOCK_STATUS_2 0x00001088
@@ -1394,6 +2502,26 @@ struct l2_fhdr {
1394#define BNX2_CTX_CHNL_LOCK_STATUS_6 0x00001098 2502#define BNX2_CTX_CHNL_LOCK_STATUS_6 0x00001098
1395#define BNX2_CTX_CHNL_LOCK_STATUS_7 0x0000109c 2503#define BNX2_CTX_CHNL_LOCK_STATUS_7 0x0000109c
1396#define BNX2_CTX_CHNL_LOCK_STATUS_8 0x000010a0 2504#define BNX2_CTX_CHNL_LOCK_STATUS_8 0x000010a0
2505#define BNX2_CTX_CHNL_LOCK_STATUS_9 0x000010a4
2506
2507#define BNX2_CTX_CACHE_DATA 0x000010c4
2508#define BNX2_CTX_HOST_PAGE_TBL_CTRL 0x000010c8
2509#define BNX2_CTX_HOST_PAGE_TBL_CTRL_PAGE_TBL_ADDR (0x1ffL<<0)
2510#define BNX2_CTX_HOST_PAGE_TBL_CTRL_WRITE_REQ (1L<<30)
2511#define BNX2_CTX_HOST_PAGE_TBL_CTRL_READ_REQ (1L<<31)
2512
2513#define BNX2_CTX_HOST_PAGE_TBL_DATA0 0x000010cc
2514#define BNX2_CTX_HOST_PAGE_TBL_DATA0_VALID (1L<<0)
2515#define BNX2_CTX_HOST_PAGE_TBL_DATA0_VALUE (0xffffffL<<8)
2516
2517#define BNX2_CTX_HOST_PAGE_TBL_DATA1 0x000010d0
2518#define BNX2_CTX_CAM_CTRL 0x000010d4
2519#define BNX2_CTX_CAM_CTRL_CAM_ADDR (0x3ffL<<0)
2520#define BNX2_CTX_CAM_CTRL_RESET (1L<<27)
2521#define BNX2_CTX_CAM_CTRL_INVALIDATE (1L<<28)
2522#define BNX2_CTX_CAM_CTRL_SEARCH (1L<<29)
2523#define BNX2_CTX_CAM_CTRL_WRITE_REQ (1L<<30)
2524#define BNX2_CTX_CAM_CTRL_READ_REQ (1L<<31)
1397 2525
1398 2526
1399/* 2527/*
@@ -1407,14 +2535,16 @@ struct l2_fhdr {
1407#define BNX2_EMAC_MODE_PORT_NONE (0L<<2) 2535#define BNX2_EMAC_MODE_PORT_NONE (0L<<2)
1408#define BNX2_EMAC_MODE_PORT_MII (1L<<2) 2536#define BNX2_EMAC_MODE_PORT_MII (1L<<2)
1409#define BNX2_EMAC_MODE_PORT_GMII (2L<<2) 2537#define BNX2_EMAC_MODE_PORT_GMII (2L<<2)
1410#define BNX2_EMAC_MODE_PORT_MII_10 (3L<<2) 2538#define BNX2_EMAC_MODE_PORT_MII_10M (3L<<2)
1411#define BNX2_EMAC_MODE_MAC_LOOP (1L<<4) 2539#define BNX2_EMAC_MODE_MAC_LOOP (1L<<4)
1412#define BNX2_EMAC_MODE_25G (1L<<5) 2540#define BNX2_EMAC_MODE_25G_MODE (1L<<5)
1413#define BNX2_EMAC_MODE_TAGGED_MAC_CTL (1L<<7) 2541#define BNX2_EMAC_MODE_TAGGED_MAC_CTL (1L<<7)
1414#define BNX2_EMAC_MODE_TX_BURST (1L<<8) 2542#define BNX2_EMAC_MODE_TX_BURST (1L<<8)
1415#define BNX2_EMAC_MODE_MAX_DEFER_DROP_ENA (1L<<9) 2543#define BNX2_EMAC_MODE_MAX_DEFER_DROP_ENA (1L<<9)
1416#define BNX2_EMAC_MODE_EXT_LINK_POL (1L<<10) 2544#define BNX2_EMAC_MODE_EXT_LINK_POL (1L<<10)
1417#define BNX2_EMAC_MODE_FORCE_LINK (1L<<11) 2545#define BNX2_EMAC_MODE_FORCE_LINK (1L<<11)
2546#define BNX2_EMAC_MODE_SERDES_MODE (1L<<12)
2547#define BNX2_EMAC_MODE_BOND_OVRD (1L<<13)
1418#define BNX2_EMAC_MODE_MPKT (1L<<18) 2548#define BNX2_EMAC_MODE_MPKT (1L<<18)
1419#define BNX2_EMAC_MODE_MPKT_RCVD (1L<<19) 2549#define BNX2_EMAC_MODE_MPKT_RCVD (1L<<19)
1420#define BNX2_EMAC_MODE_ACPI_RCVD (1L<<20) 2550#define BNX2_EMAC_MODE_ACPI_RCVD (1L<<20)
@@ -1422,6 +2552,11 @@ struct l2_fhdr {
1422#define BNX2_EMAC_STATUS 0x00001404 2552#define BNX2_EMAC_STATUS 0x00001404
1423#define BNX2_EMAC_STATUS_LINK (1L<<11) 2553#define BNX2_EMAC_STATUS_LINK (1L<<11)
1424#define BNX2_EMAC_STATUS_LINK_CHANGE (1L<<12) 2554#define BNX2_EMAC_STATUS_LINK_CHANGE (1L<<12)
2555#define BNX2_EMAC_STATUS_SERDES_AUTONEG_COMPLETE (1L<<13)
2556#define BNX2_EMAC_STATUS_SERDES_AUTONEG_CHANGE (1L<<14)
2557#define BNX2_EMAC_STATUS_SERDES_NXT_PG_CHANGE (1L<<16)
2558#define BNX2_EMAC_STATUS_SERDES_RX_CONFIG_IS_0 (1L<<17)
2559#define BNX2_EMAC_STATUS_SERDES_RX_CONFIG_IS_0_CHANGE (1L<<18)
1425#define BNX2_EMAC_STATUS_MI_COMPLETE (1L<<22) 2560#define BNX2_EMAC_STATUS_MI_COMPLETE (1L<<22)
1426#define BNX2_EMAC_STATUS_MI_INT (1L<<23) 2561#define BNX2_EMAC_STATUS_MI_INT (1L<<23)
1427#define BNX2_EMAC_STATUS_AP_ERROR (1L<<24) 2562#define BNX2_EMAC_STATUS_AP_ERROR (1L<<24)
@@ -1429,6 +2564,9 @@ struct l2_fhdr {
1429 2564
1430#define BNX2_EMAC_ATTENTION_ENA 0x00001408 2565#define BNX2_EMAC_ATTENTION_ENA 0x00001408
1431#define BNX2_EMAC_ATTENTION_ENA_LINK (1L<<11) 2566#define BNX2_EMAC_ATTENTION_ENA_LINK (1L<<11)
2567#define BNX2_EMAC_ATTENTION_ENA_AUTONEG_CHANGE (1L<<14)
2568#define BNX2_EMAC_ATTENTION_ENA_NXT_PG_CHANGE (1L<<16)
2569#define BNX2_EMAC_ATTENTION_ENA_SERDES_RX_CONFIG_IS_0_CHANGE (1L<<18)
1432#define BNX2_EMAC_ATTENTION_ENA_MI_COMPLETE (1L<<22) 2570#define BNX2_EMAC_ATTENTION_ENA_MI_COMPLETE (1L<<22)
1433#define BNX2_EMAC_ATTENTION_ENA_MI_INT (1L<<23) 2571#define BNX2_EMAC_ATTENTION_ENA_MI_INT (1L<<23)
1434#define BNX2_EMAC_ATTENTION_ENA_AP_ERROR (1L<<24) 2572#define BNX2_EMAC_ATTENTION_ENA_AP_ERROR (1L<<24)
@@ -1445,6 +2583,13 @@ struct l2_fhdr {
1445#define BNX2_EMAC_LED_100MB (1L<<8) 2583#define BNX2_EMAC_LED_100MB (1L<<8)
1446#define BNX2_EMAC_LED_10MB (1L<<9) 2584#define BNX2_EMAC_LED_10MB (1L<<9)
1447#define BNX2_EMAC_LED_TRAFFIC_STAT (1L<<10) 2585#define BNX2_EMAC_LED_TRAFFIC_STAT (1L<<10)
2586#define BNX2_EMAC_LED_2500MB (1L<<11)
2587#define BNX2_EMAC_LED_2500MB_OVERRIDE (1L<<12)
2588#define BNX2_EMAC_LED_ACTIVITY_SEL (0x3L<<17)
2589#define BNX2_EMAC_LED_ACTIVITY_SEL_0 (0L<<17)
2590#define BNX2_EMAC_LED_ACTIVITY_SEL_1 (1L<<17)
2591#define BNX2_EMAC_LED_ACTIVITY_SEL_2 (2L<<17)
2592#define BNX2_EMAC_LED_ACTIVITY_SEL_3 (3L<<17)
1448#define BNX2_EMAC_LED_BLNK_RATE (0xfffL<<19) 2593#define BNX2_EMAC_LED_BLNK_RATE (0xfffL<<19)
1449#define BNX2_EMAC_LED_BLNK_RATE_ENA (1L<<31) 2594#define BNX2_EMAC_LED_BLNK_RATE_ENA (1L<<31)
1450 2595
@@ -1515,9 +2660,15 @@ struct l2_fhdr {
1515#define BNX2_EMAC_MDIO_COMM_PHY_ADDR (0x1fL<<21) 2660#define BNX2_EMAC_MDIO_COMM_PHY_ADDR (0x1fL<<21)
1516#define BNX2_EMAC_MDIO_COMM_COMMAND (0x3L<<26) 2661#define BNX2_EMAC_MDIO_COMM_COMMAND (0x3L<<26)
1517#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_0 (0L<<26) 2662#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_0 (0L<<26)
2663#define BNX2_EMAC_MDIO_COMM_COMMAND_ADDRESS (0L<<26)
1518#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE (1L<<26) 2664#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE (1L<<26)
1519#define BNX2_EMAC_MDIO_COMM_COMMAND_READ (2L<<26) 2665#define BNX2_EMAC_MDIO_COMM_COMMAND_READ (2L<<26)
2666#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE_22_XI (1L<<26)
2667#define BNX2_EMAC_MDIO_COMM_COMMAND_WRITE_45_XI (1L<<26)
2668#define BNX2_EMAC_MDIO_COMM_COMMAND_READ_22_XI (2L<<26)
2669#define BNX2_EMAC_MDIO_COMM_COMMAND_READ_INC_45_XI (2L<<26)
1520#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_3 (3L<<26) 2670#define BNX2_EMAC_MDIO_COMM_COMMAND_UNDEFINED_3 (3L<<26)
2671#define BNX2_EMAC_MDIO_COMM_COMMAND_READ_45 (3L<<26)
1521#define BNX2_EMAC_MDIO_COMM_FAIL (1L<<28) 2672#define BNX2_EMAC_MDIO_COMM_FAIL (1L<<28)
1522#define BNX2_EMAC_MDIO_COMM_START_BUSY (1L<<29) 2673#define BNX2_EMAC_MDIO_COMM_START_BUSY (1L<<29)
1523#define BNX2_EMAC_MDIO_COMM_DISEXT (1L<<30) 2674#define BNX2_EMAC_MDIO_COMM_DISEXT (1L<<30)
@@ -1534,13 +2685,17 @@ struct l2_fhdr {
1534#define BNX2_EMAC_MDIO_MODE_MDIO_OE (1L<<10) 2685#define BNX2_EMAC_MDIO_MODE_MDIO_OE (1L<<10)
1535#define BNX2_EMAC_MDIO_MODE_MDC (1L<<11) 2686#define BNX2_EMAC_MDIO_MODE_MDC (1L<<11)
1536#define BNX2_EMAC_MDIO_MODE_MDINT (1L<<12) 2687#define BNX2_EMAC_MDIO_MODE_MDINT (1L<<12)
2688#define BNX2_EMAC_MDIO_MODE_EXT_MDINT (1L<<13)
1537#define BNX2_EMAC_MDIO_MODE_CLOCK_CNT (0x1fL<<16) 2689#define BNX2_EMAC_MDIO_MODE_CLOCK_CNT (0x1fL<<16)
2690#define BNX2_EMAC_MDIO_MODE_CLOCK_CNT_XI (0x3fL<<16)
2691#define BNX2_EMAC_MDIO_MODE_CLAUSE_45_XI (1L<<31)
1538 2692
1539#define BNX2_EMAC_MDIO_AUTO_STATUS 0x000014b8 2693#define BNX2_EMAC_MDIO_AUTO_STATUS 0x000014b8
1540#define BNX2_EMAC_MDIO_AUTO_STATUS_AUTO_ERR (1L<<0) 2694#define BNX2_EMAC_MDIO_AUTO_STATUS_AUTO_ERR (1L<<0)
1541 2695
1542#define BNX2_EMAC_TX_MODE 0x000014bc 2696#define BNX2_EMAC_TX_MODE 0x000014bc
1543#define BNX2_EMAC_TX_MODE_RESET (1L<<0) 2697#define BNX2_EMAC_TX_MODE_RESET (1L<<0)
2698#define BNX2_EMAC_TX_MODE_CS16_TEST (1L<<2)
1544#define BNX2_EMAC_TX_MODE_EXT_PAUSE_EN (1L<<3) 2699#define BNX2_EMAC_TX_MODE_EXT_PAUSE_EN (1L<<3)
1545#define BNX2_EMAC_TX_MODE_FLOW_EN (1L<<4) 2700#define BNX2_EMAC_TX_MODE_FLOW_EN (1L<<4)
1546#define BNX2_EMAC_TX_MODE_BIG_BACKOFF (1L<<5) 2701#define BNX2_EMAC_TX_MODE_BIG_BACKOFF (1L<<5)
@@ -1553,6 +2708,7 @@ struct l2_fhdr {
1553#define BNX2_EMAC_TX_STATUS_XON_SENT (1L<<2) 2708#define BNX2_EMAC_TX_STATUS_XON_SENT (1L<<2)
1554#define BNX2_EMAC_TX_STATUS_LINK_UP (1L<<3) 2709#define BNX2_EMAC_TX_STATUS_LINK_UP (1L<<3)
1555#define BNX2_EMAC_TX_STATUS_UNDERRUN (1L<<4) 2710#define BNX2_EMAC_TX_STATUS_UNDERRUN (1L<<4)
2711#define BNX2_EMAC_TX_STATUS_CS16_ERROR (1L<<5)
1556 2712
1557#define BNX2_EMAC_TX_LENGTHS 0x000014c4 2713#define BNX2_EMAC_TX_LENGTHS 0x000014c4
1558#define BNX2_EMAC_TX_LENGTHS_SLOT (0xffL<<0) 2714#define BNX2_EMAC_TX_LENGTHS_SLOT (0xffL<<0)
@@ -1586,6 +2742,10 @@ struct l2_fhdr {
1586#define BNX2_EMAC_MULTICAST_HASH5 0x000014e4 2742#define BNX2_EMAC_MULTICAST_HASH5 0x000014e4
1587#define BNX2_EMAC_MULTICAST_HASH6 0x000014e8 2743#define BNX2_EMAC_MULTICAST_HASH6 0x000014e8
1588#define BNX2_EMAC_MULTICAST_HASH7 0x000014ec 2744#define BNX2_EMAC_MULTICAST_HASH7 0x000014ec
2745#define BNX2_EMAC_CKSUM_ERROR_STATUS 0x000014f0
2746#define BNX2_EMAC_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
2747#define BNX2_EMAC_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
2748
1589#define BNX2_EMAC_RX_STAT_IFHCINOCTETS 0x00001500 2749#define BNX2_EMAC_RX_STAT_IFHCINOCTETS 0x00001500
1590#define BNX2_EMAC_RX_STAT_IFHCINBADOCTETS 0x00001504 2750#define BNX2_EMAC_RX_STAT_IFHCINBADOCTETS 0x00001504
1591#define BNX2_EMAC_RX_STAT_ETHERSTATSFRAGMENTS 0x00001508 2751#define BNX2_EMAC_RX_STAT_ETHERSTATSFRAGMENTS 0x00001508
@@ -1608,7 +2768,7 @@ struct l2_fhdr {
1608#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x0000154c 2768#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x0000154c
1609#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001550 2769#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001550
1610#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x00001554 2770#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x00001554
1611#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTS1523OCTETSTO9022OCTETS 0x00001558 2771#define BNX2_EMAC_RX_STAT_ETHERSTATSPKTSOVER1522OCTETS 0x00001558
1612#define BNX2_EMAC_RXMAC_DEBUG0 0x0000155c 2772#define BNX2_EMAC_RXMAC_DEBUG0 0x0000155c
1613#define BNX2_EMAC_RXMAC_DEBUG1 0x00001560 2773#define BNX2_EMAC_RXMAC_DEBUG1 0x00001560
1614#define BNX2_EMAC_RXMAC_DEBUG1_LENGTH_NE_BYTE_COUNT (1L<<0) 2774#define BNX2_EMAC_RXMAC_DEBUG1_LENGTH_NE_BYTE_COUNT (1L<<0)
@@ -1661,9 +2821,9 @@ struct l2_fhdr {
1661#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC2 (0x1L<<16) 2821#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC2 (0x1L<<16)
1662#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC3 (0x2L<<16) 2822#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UMAC3 (0x2L<<16)
1663#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UNI (0x3L<<16) 2823#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_UNI (0x3L<<16)
1664#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC2 (0x7L<<16)
1665#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC3 (0x5L<<16) 2824#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC3 (0x5L<<16)
1666#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA1 (0x6L<<16) 2825#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA1 (0x6L<<16)
2826#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MMAC2 (0x7L<<16)
1667#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA2 (0x7L<<16) 2827#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA2 (0x7L<<16)
1668#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA3 (0x8L<<16) 2828#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_PSA3 (0x8L<<16)
1669#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MC2 (0x9L<<16) 2829#define BNX2_EMAC_RXMAC_DEBUG4_FILT_STATE_MC2 (0x9L<<16)
@@ -1701,7 +2861,7 @@ struct l2_fhdr {
1701#define BNX2_EMAC_RXMAC_DEBUG4_SLOT_FILLED (1L<<23) 2861#define BNX2_EMAC_RXMAC_DEBUG4_SLOT_FILLED (1L<<23)
1702#define BNX2_EMAC_RXMAC_DEBUG4_FALSE_CARRIER (1L<<24) 2862#define BNX2_EMAC_RXMAC_DEBUG4_FALSE_CARRIER (1L<<24)
1703#define BNX2_EMAC_RXMAC_DEBUG4_LAST_DATA (1L<<25) 2863#define BNX2_EMAC_RXMAC_DEBUG4_LAST_DATA (1L<<25)
1704#define BNX2_EMAC_RXMAC_DEBUG4_sfd_FOUND (1L<<26) 2864#define BNX2_EMAC_RXMAC_DEBUG4_SFD_FOUND (1L<<26)
1705#define BNX2_EMAC_RXMAC_DEBUG4_ADVANCE (1L<<27) 2865#define BNX2_EMAC_RXMAC_DEBUG4_ADVANCE (1L<<27)
1706#define BNX2_EMAC_RXMAC_DEBUG4_START (1L<<28) 2866#define BNX2_EMAC_RXMAC_DEBUG4_START (1L<<28)
1707 2867
@@ -1733,6 +2893,7 @@ struct l2_fhdr {
1733#define BNX2_EMAC_RXMAC_DEBUG5_IDI_RPM_ACCEPT (1L<<19) 2893#define BNX2_EMAC_RXMAC_DEBUG5_IDI_RPM_ACCEPT (1L<<19)
1734#define BNX2_EMAC_RXMAC_DEBUG5_FMLEN (0xfffL<<20) 2894#define BNX2_EMAC_RXMAC_DEBUG5_FMLEN (0xfffL<<20)
1735 2895
2896#define BNX2_EMAC_RX_STAT_FALSECARRIERERRORS 0x00001574
1736#define BNX2_EMAC_RX_STAT_AC0 0x00001580 2897#define BNX2_EMAC_RX_STAT_AC0 0x00001580
1737#define BNX2_EMAC_RX_STAT_AC1 0x00001584 2898#define BNX2_EMAC_RX_STAT_AC1 0x00001584
1738#define BNX2_EMAC_RX_STAT_AC2 0x00001588 2899#define BNX2_EMAC_RX_STAT_AC2 0x00001588
@@ -1757,6 +2918,7 @@ struct l2_fhdr {
1757#define BNX2_EMAC_RX_STAT_AC21 0x000015d4 2918#define BNX2_EMAC_RX_STAT_AC21 0x000015d4
1758#define BNX2_EMAC_RX_STAT_AC22 0x000015d8 2919#define BNX2_EMAC_RX_STAT_AC22 0x000015d8
1759#define BNX2_EMAC_RXMAC_SUC_DBG_OVERRUNVEC 0x000015dc 2920#define BNX2_EMAC_RXMAC_SUC_DBG_OVERRUNVEC 0x000015dc
2921#define BNX2_EMAC_RX_STAT_AC_28 0x000015f4
1760#define BNX2_EMAC_TX_STAT_IFHCOUTOCTETS 0x00001600 2922#define BNX2_EMAC_TX_STAT_IFHCOUTOCTETS 0x00001600
1761#define BNX2_EMAC_TX_STAT_IFHCOUTBADOCTETS 0x00001604 2923#define BNX2_EMAC_TX_STAT_IFHCOUTBADOCTETS 0x00001604
1762#define BNX2_EMAC_TX_STAT_ETHERSTATSCOLLISIONS 0x00001608 2924#define BNX2_EMAC_TX_STAT_ETHERSTATSCOLLISIONS 0x00001608
@@ -1777,7 +2939,7 @@ struct l2_fhdr {
1777#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x00001644 2939#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS256OCTETSTO511OCTETS 0x00001644
1778#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001648 2940#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS512OCTETSTO1023OCTETS 0x00001648
1779#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x0000164c 2941#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS1024OCTETSTO1522OCTETS 0x0000164c
1780#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTS1523OCTETSTO9022OCTETS 0x00001650 2942#define BNX2_EMAC_TX_STAT_ETHERSTATSPKTSOVER1522OCTETS 0x00001650
1781#define BNX2_EMAC_TX_STAT_DOT3STATSINTERNALMACTRANSMITERRORS 0x00001654 2943#define BNX2_EMAC_TX_STAT_DOT3STATSINTERNALMACTRANSMITERRORS 0x00001654
1782#define BNX2_EMAC_TXMAC_DEBUG0 0x00001658 2944#define BNX2_EMAC_TXMAC_DEBUG0 0x00001658
1783#define BNX2_EMAC_TXMAC_DEBUG1 0x0000165c 2945#define BNX2_EMAC_TXMAC_DEBUG1 0x0000165c
@@ -1843,16 +3005,16 @@ struct l2_fhdr {
1843#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_IDLE (0x0L<<16) 3005#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_IDLE (0x0L<<16)
1844#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA1 (0x2L<<16) 3006#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA1 (0x2L<<16)
1845#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA2 (0x3L<<16) 3007#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA2 (0x3L<<16)
3008#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC3 (0x4L<<16)
3009#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC2 (0x5L<<16)
1846#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA3 (0x6L<<16) 3010#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_MCA3 (0x6L<<16)
1847#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC1 (0x7L<<16) 3011#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC1 (0x7L<<16)
1848#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC2 (0x5L<<16)
1849#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_SRC3 (0x4L<<16)
1850#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TYPE (0xcL<<16)
1851#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CMD (0xeL<<16)
1852#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TIME (0xaL<<16)
1853#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC1 (0x8L<<16) 3012#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC1 (0x8L<<16)
1854#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC2 (0x9L<<16) 3013#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CRC2 (0x9L<<16)
3014#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TIME (0xaL<<16)
3015#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_TYPE (0xcL<<16)
1855#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_WAIT (0xdL<<16) 3016#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_WAIT (0xdL<<16)
3017#define BNX2_EMAC_TXMAC_DEBUG4_PAUSE_STATE_CMD (0xeL<<16)
1856#define BNX2_EMAC_TXMAC_DEBUG4_STATS0_VALID (1L<<20) 3018#define BNX2_EMAC_TXMAC_DEBUG4_STATS0_VALID (1L<<20)
1857#define BNX2_EMAC_TXMAC_DEBUG4_APPEND_CRC (1L<<21) 3019#define BNX2_EMAC_TXMAC_DEBUG4_APPEND_CRC (1L<<21)
1858#define BNX2_EMAC_TXMAC_DEBUG4_SLOT_FILLED (1L<<22) 3020#define BNX2_EMAC_TXMAC_DEBUG4_SLOT_FILLED (1L<<22)
@@ -1887,8 +3049,11 @@ struct l2_fhdr {
1887#define BNX2_EMAC_TX_STAT_AC18 0x000016c8 3049#define BNX2_EMAC_TX_STAT_AC18 0x000016c8
1888#define BNX2_EMAC_TX_STAT_AC19 0x000016cc 3050#define BNX2_EMAC_TX_STAT_AC19 0x000016cc
1889#define BNX2_EMAC_TX_STAT_AC20 0x000016d0 3051#define BNX2_EMAC_TX_STAT_AC20 0x000016d0
1890#define BNX2_EMAC_TX_STAT_AC21 0x000016d4
1891#define BNX2_EMAC_TXMAC_SUC_DBG_OVERRUNVEC 0x000016d8 3052#define BNX2_EMAC_TXMAC_SUC_DBG_OVERRUNVEC 0x000016d8
3053#define BNX2_EMAC_TX_RATE_LIMIT_CTRL 0x000016fc
3054#define BNX2_EMAC_TX_RATE_LIMIT_CTRL_TX_THROTTLE_INC (0x7fL<<0)
3055#define BNX2_EMAC_TX_RATE_LIMIT_CTRL_TX_THROTTLE_NUM (0x7fL<<16)
3056#define BNX2_EMAC_TX_RATE_LIMIT_CTRL_RATE_LIMITER_EN (1L<<31)
1892 3057
1893 3058
1894/* 3059/*
@@ -1909,8 +3074,15 @@ struct l2_fhdr {
1909#define BNX2_RPM_CONFIG_ACPI_KEEP (1L<<2) 3074#define BNX2_RPM_CONFIG_ACPI_KEEP (1L<<2)
1910#define BNX2_RPM_CONFIG_MP_KEEP (1L<<3) 3075#define BNX2_RPM_CONFIG_MP_KEEP (1L<<3)
1911#define BNX2_RPM_CONFIG_SORT_VECT_VAL (0xfL<<4) 3076#define BNX2_RPM_CONFIG_SORT_VECT_VAL (0xfL<<4)
3077#define BNX2_RPM_CONFIG_DISABLE_WOL_ASSERT (1L<<30)
1912#define BNX2_RPM_CONFIG_IGNORE_VLAN (1L<<31) 3078#define BNX2_RPM_CONFIG_IGNORE_VLAN (1L<<31)
1913 3079
3080#define BNX2_RPM_MGMT_PKT_CTRL 0x0000180c
3081#define BNX2_RPM_MGMT_PKT_CTRL_MGMT_SORT (0xfL<<0)
3082#define BNX2_RPM_MGMT_PKT_CTRL_MGMT_RULE (0xfL<<4)
3083#define BNX2_RPM_MGMT_PKT_CTRL_MGMT_DISCARD_EN (1L<<30)
3084#define BNX2_RPM_MGMT_PKT_CTRL_MGMT_EN (1L<<31)
3085
1914#define BNX2_RPM_VLAN_MATCH0 0x00001810 3086#define BNX2_RPM_VLAN_MATCH0 0x00001810
1915#define BNX2_RPM_VLAN_MATCH0_RPM_VLAN_MTCH0_VALUE (0xfffL<<0) 3087#define BNX2_RPM_VLAN_MATCH0_RPM_VLAN_MTCH0_VALUE (0xfffL<<0)
1916 3088
@@ -1931,6 +3103,7 @@ struct l2_fhdr {
1931#define BNX2_RPM_SORT_USER0_PROM_EN (1L<<19) 3103#define BNX2_RPM_SORT_USER0_PROM_EN (1L<<19)
1932#define BNX2_RPM_SORT_USER0_VLAN_EN (0xfL<<20) 3104#define BNX2_RPM_SORT_USER0_VLAN_EN (0xfL<<20)
1933#define BNX2_RPM_SORT_USER0_PROM_VLAN (1L<<24) 3105#define BNX2_RPM_SORT_USER0_PROM_VLAN (1L<<24)
3106#define BNX2_RPM_SORT_USER0_VLAN_NOTMATCH (1L<<25)
1934#define BNX2_RPM_SORT_USER0_ENA (1L<<31) 3107#define BNX2_RPM_SORT_USER0_ENA (1L<<31)
1935 3108
1936#define BNX2_RPM_SORT_USER1 0x00001824 3109#define BNX2_RPM_SORT_USER1 0x00001824
@@ -1968,11 +3141,187 @@ struct l2_fhdr {
1968#define BNX2_RPM_STAT_IFINFTQDISCARDS 0x00001848 3141#define BNX2_RPM_STAT_IFINFTQDISCARDS 0x00001848
1969#define BNX2_RPM_STAT_IFINMBUFDISCARD 0x0000184c 3142#define BNX2_RPM_STAT_IFINMBUFDISCARD 0x0000184c
1970#define BNX2_RPM_STAT_RULE_CHECKER_P4_HIT 0x00001850 3143#define BNX2_RPM_STAT_RULE_CHECKER_P4_HIT 0x00001850
3144#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0 0x00001854
3145#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0_NEXT_HEADER_LEN (0xffL<<0)
3146#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0_NEXT_HEADER (0xffL<<16)
3147#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0_NEXT_HEADER_LEN_TYPE (1L<<30)
3148#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION0_NEXT_HEADER_EN (1L<<31)
3149
3150#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1 0x00001858
3151#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1_NEXT_HEADER_LEN (0xffL<<0)
3152#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1_NEXT_HEADER (0xffL<<16)
3153#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1_NEXT_HEADER_LEN_TYPE (1L<<30)
3154#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION1_NEXT_HEADER_EN (1L<<31)
3155
3156#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2 0x0000185c
3157#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2_NEXT_HEADER_LEN (0xffL<<0)
3158#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2_NEXT_HEADER (0xffL<<16)
3159#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2_NEXT_HEADER_LEN_TYPE (1L<<30)
3160#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION2_NEXT_HEADER_EN (1L<<31)
3161
3162#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3 0x00001860
3163#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3_NEXT_HEADER_LEN (0xffL<<0)
3164#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3_NEXT_HEADER (0xffL<<16)
3165#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3_NEXT_HEADER_LEN_TYPE (1L<<30)
3166#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION3_NEXT_HEADER_EN (1L<<31)
3167
3168#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4 0x00001864
3169#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4_NEXT_HEADER_LEN (0xffL<<0)
3170#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4_NEXT_HEADER (0xffL<<16)
3171#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4_NEXT_HEADER_LEN_TYPE (1L<<30)
3172#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION4_NEXT_HEADER_EN (1L<<31)
3173
3174#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5 0x00001868
3175#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5_NEXT_HEADER_LEN (0xffL<<0)
3176#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5_NEXT_HEADER (0xffL<<16)
3177#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5_NEXT_HEADER_LEN_TYPE (1L<<30)
3178#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION5_NEXT_HEADER_EN (1L<<31)
3179
3180#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6 0x0000186c
3181#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6_NEXT_HEADER_LEN (0xffL<<0)
3182#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6_NEXT_HEADER (0xffL<<16)
3183#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6_NEXT_HEADER_LEN_TYPE (1L<<30)
3184#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION6_NEXT_HEADER_EN (1L<<31)
3185
3186#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7 0x00001870
3187#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7_NEXT_HEADER_LEN (0xffL<<0)
3188#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7_NEXT_HEADER (0xffL<<16)
3189#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7_NEXT_HEADER_LEN_TYPE (1L<<30)
3190#define BNX2_RPM_IPV6_PROGRAMMABLE_EXTENSION7_NEXT_HEADER_EN (1L<<31)
3191
1971#define BNX2_RPM_STAT_AC0 0x00001880 3192#define BNX2_RPM_STAT_AC0 0x00001880
1972#define BNX2_RPM_STAT_AC1 0x00001884 3193#define BNX2_RPM_STAT_AC1 0x00001884
1973#define BNX2_RPM_STAT_AC2 0x00001888 3194#define BNX2_RPM_STAT_AC2 0x00001888
1974#define BNX2_RPM_STAT_AC3 0x0000188c 3195#define BNX2_RPM_STAT_AC3 0x0000188c
1975#define BNX2_RPM_STAT_AC4 0x00001890 3196#define BNX2_RPM_STAT_AC4 0x00001890
3197#define BNX2_RPM_RC_CNTL_16 0x000018e0
3198#define BNX2_RPM_RC_CNTL_16_OFFSET (0xffL<<0)
3199#define BNX2_RPM_RC_CNTL_16_CLASS (0x7L<<8)
3200#define BNX2_RPM_RC_CNTL_16_PRIORITY (1L<<11)
3201#define BNX2_RPM_RC_CNTL_16_P4 (1L<<12)
3202#define BNX2_RPM_RC_CNTL_16_HDR_TYPE (0x7L<<13)
3203#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_START (0L<<13)
3204#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_IP (1L<<13)
3205#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_TCP (2L<<13)
3206#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_UDP (3L<<13)
3207#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_DATA (4L<<13)
3208#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_TCP_UDP (5L<<13)
3209#define BNX2_RPM_RC_CNTL_16_HDR_TYPE_ICMPV6 (6L<<13)
3210#define BNX2_RPM_RC_CNTL_16_COMP (0x3L<<16)
3211#define BNX2_RPM_RC_CNTL_16_COMP_EQUAL (0L<<16)
3212#define BNX2_RPM_RC_CNTL_16_COMP_NEQUAL (1L<<16)
3213#define BNX2_RPM_RC_CNTL_16_COMP_GREATER (2L<<16)
3214#define BNX2_RPM_RC_CNTL_16_COMP_LESS (3L<<16)
3215#define BNX2_RPM_RC_CNTL_16_MAP (1L<<18)
3216#define BNX2_RPM_RC_CNTL_16_SBIT (1L<<19)
3217#define BNX2_RPM_RC_CNTL_16_CMDSEL (0x1fL<<20)
3218#define BNX2_RPM_RC_CNTL_16_DISCARD (1L<<25)
3219#define BNX2_RPM_RC_CNTL_16_MASK (1L<<26)
3220#define BNX2_RPM_RC_CNTL_16_P1 (1L<<27)
3221#define BNX2_RPM_RC_CNTL_16_P2 (1L<<28)
3222#define BNX2_RPM_RC_CNTL_16_P3 (1L<<29)
3223#define BNX2_RPM_RC_CNTL_16_NBIT (1L<<30)
3224
3225#define BNX2_RPM_RC_VALUE_MASK_16 0x000018e4
3226#define BNX2_RPM_RC_VALUE_MASK_16_VALUE (0xffffL<<0)
3227#define BNX2_RPM_RC_VALUE_MASK_16_MASK (0xffffL<<16)
3228
3229#define BNX2_RPM_RC_CNTL_17 0x000018e8
3230#define BNX2_RPM_RC_CNTL_17_OFFSET (0xffL<<0)
3231#define BNX2_RPM_RC_CNTL_17_CLASS (0x7L<<8)
3232#define BNX2_RPM_RC_CNTL_17_PRIORITY (1L<<11)
3233#define BNX2_RPM_RC_CNTL_17_P4 (1L<<12)
3234#define BNX2_RPM_RC_CNTL_17_HDR_TYPE (0x7L<<13)
3235#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_START (0L<<13)
3236#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_IP (1L<<13)
3237#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_TCP (2L<<13)
3238#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_UDP (3L<<13)
3239#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_DATA (4L<<13)
3240#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_TCP_UDP (5L<<13)
3241#define BNX2_RPM_RC_CNTL_17_HDR_TYPE_ICMPV6 (6L<<13)
3242#define BNX2_RPM_RC_CNTL_17_COMP (0x3L<<16)
3243#define BNX2_RPM_RC_CNTL_17_COMP_EQUAL (0L<<16)
3244#define BNX2_RPM_RC_CNTL_17_COMP_NEQUAL (1L<<16)
3245#define BNX2_RPM_RC_CNTL_17_COMP_GREATER (2L<<16)
3246#define BNX2_RPM_RC_CNTL_17_COMP_LESS (3L<<16)
3247#define BNX2_RPM_RC_CNTL_17_MAP (1L<<18)
3248#define BNX2_RPM_RC_CNTL_17_SBIT (1L<<19)
3249#define BNX2_RPM_RC_CNTL_17_CMDSEL (0x1fL<<20)
3250#define BNX2_RPM_RC_CNTL_17_DISCARD (1L<<25)
3251#define BNX2_RPM_RC_CNTL_17_MASK (1L<<26)
3252#define BNX2_RPM_RC_CNTL_17_P1 (1L<<27)
3253#define BNX2_RPM_RC_CNTL_17_P2 (1L<<28)
3254#define BNX2_RPM_RC_CNTL_17_P3 (1L<<29)
3255#define BNX2_RPM_RC_CNTL_17_NBIT (1L<<30)
3256
3257#define BNX2_RPM_RC_VALUE_MASK_17 0x000018ec
3258#define BNX2_RPM_RC_VALUE_MASK_17_VALUE (0xffffL<<0)
3259#define BNX2_RPM_RC_VALUE_MASK_17_MASK (0xffffL<<16)
3260
3261#define BNX2_RPM_RC_CNTL_18 0x000018f0
3262#define BNX2_RPM_RC_CNTL_18_OFFSET (0xffL<<0)
3263#define BNX2_RPM_RC_CNTL_18_CLASS (0x7L<<8)
3264#define BNX2_RPM_RC_CNTL_18_PRIORITY (1L<<11)
3265#define BNX2_RPM_RC_CNTL_18_P4 (1L<<12)
3266#define BNX2_RPM_RC_CNTL_18_HDR_TYPE (0x7L<<13)
3267#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_START (0L<<13)
3268#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_IP (1L<<13)
3269#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_TCP (2L<<13)
3270#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_UDP (3L<<13)
3271#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_DATA (4L<<13)
3272#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_TCP_UDP (5L<<13)
3273#define BNX2_RPM_RC_CNTL_18_HDR_TYPE_ICMPV6 (6L<<13)
3274#define BNX2_RPM_RC_CNTL_18_COMP (0x3L<<16)
3275#define BNX2_RPM_RC_CNTL_18_COMP_EQUAL (0L<<16)
3276#define BNX2_RPM_RC_CNTL_18_COMP_NEQUAL (1L<<16)
3277#define BNX2_RPM_RC_CNTL_18_COMP_GREATER (2L<<16)
3278#define BNX2_RPM_RC_CNTL_18_COMP_LESS (3L<<16)
3279#define BNX2_RPM_RC_CNTL_18_MAP (1L<<18)
3280#define BNX2_RPM_RC_CNTL_18_SBIT (1L<<19)
3281#define BNX2_RPM_RC_CNTL_18_CMDSEL (0x1fL<<20)
3282#define BNX2_RPM_RC_CNTL_18_DISCARD (1L<<25)
3283#define BNX2_RPM_RC_CNTL_18_MASK (1L<<26)
3284#define BNX2_RPM_RC_CNTL_18_P1 (1L<<27)
3285#define BNX2_RPM_RC_CNTL_18_P2 (1L<<28)
3286#define BNX2_RPM_RC_CNTL_18_P3 (1L<<29)
3287#define BNX2_RPM_RC_CNTL_18_NBIT (1L<<30)
3288
3289#define BNX2_RPM_RC_VALUE_MASK_18 0x000018f4
3290#define BNX2_RPM_RC_VALUE_MASK_18_VALUE (0xffffL<<0)
3291#define BNX2_RPM_RC_VALUE_MASK_18_MASK (0xffffL<<16)
3292
3293#define BNX2_RPM_RC_CNTL_19 0x000018f8
3294#define BNX2_RPM_RC_CNTL_19_OFFSET (0xffL<<0)
3295#define BNX2_RPM_RC_CNTL_19_CLASS (0x7L<<8)
3296#define BNX2_RPM_RC_CNTL_19_PRIORITY (1L<<11)
3297#define BNX2_RPM_RC_CNTL_19_P4 (1L<<12)
3298#define BNX2_RPM_RC_CNTL_19_HDR_TYPE (0x7L<<13)
3299#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_START (0L<<13)
3300#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_IP (1L<<13)
3301#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_TCP (2L<<13)
3302#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_UDP (3L<<13)
3303#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_DATA (4L<<13)
3304#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_TCP_UDP (5L<<13)
3305#define BNX2_RPM_RC_CNTL_19_HDR_TYPE_ICMPV6 (6L<<13)
3306#define BNX2_RPM_RC_CNTL_19_COMP (0x3L<<16)
3307#define BNX2_RPM_RC_CNTL_19_COMP_EQUAL (0L<<16)
3308#define BNX2_RPM_RC_CNTL_19_COMP_NEQUAL (1L<<16)
3309#define BNX2_RPM_RC_CNTL_19_COMP_GREATER (2L<<16)
3310#define BNX2_RPM_RC_CNTL_19_COMP_LESS (3L<<16)
3311#define BNX2_RPM_RC_CNTL_19_MAP (1L<<18)
3312#define BNX2_RPM_RC_CNTL_19_SBIT (1L<<19)
3313#define BNX2_RPM_RC_CNTL_19_CMDSEL (0x1fL<<20)
3314#define BNX2_RPM_RC_CNTL_19_DISCARD (1L<<25)
3315#define BNX2_RPM_RC_CNTL_19_MASK (1L<<26)
3316#define BNX2_RPM_RC_CNTL_19_P1 (1L<<27)
3317#define BNX2_RPM_RC_CNTL_19_P2 (1L<<28)
3318#define BNX2_RPM_RC_CNTL_19_P3 (1L<<29)
3319#define BNX2_RPM_RC_CNTL_19_NBIT (1L<<30)
3320
3321#define BNX2_RPM_RC_VALUE_MASK_19 0x000018fc
3322#define BNX2_RPM_RC_VALUE_MASK_19_VALUE (0xffffL<<0)
3323#define BNX2_RPM_RC_VALUE_MASK_19_MASK (0xffffL<<16)
3324
1976#define BNX2_RPM_RC_CNTL_0 0x00001900 3325#define BNX2_RPM_RC_CNTL_0 0x00001900
1977#define BNX2_RPM_RC_CNTL_0_OFFSET (0xffL<<0) 3326#define BNX2_RPM_RC_CNTL_0_OFFSET (0xffL<<0)
1978#define BNX2_RPM_RC_CNTL_0_CLASS (0x7L<<8) 3327#define BNX2_RPM_RC_CNTL_0_CLASS (0x7L<<8)
@@ -1984,14 +3333,18 @@ struct l2_fhdr {
1984#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_TCP (2L<<13) 3333#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_TCP (2L<<13)
1985#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_UDP (3L<<13) 3334#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_UDP (3L<<13)
1986#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_DATA (4L<<13) 3335#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_DATA (4L<<13)
3336#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_TCP_UDP (5L<<13)
3337#define BNX2_RPM_RC_CNTL_0_HDR_TYPE_ICMPV6 (6L<<13)
1987#define BNX2_RPM_RC_CNTL_0_COMP (0x3L<<16) 3338#define BNX2_RPM_RC_CNTL_0_COMP (0x3L<<16)
1988#define BNX2_RPM_RC_CNTL_0_COMP_EQUAL (0L<<16) 3339#define BNX2_RPM_RC_CNTL_0_COMP_EQUAL (0L<<16)
1989#define BNX2_RPM_RC_CNTL_0_COMP_NEQUAL (1L<<16) 3340#define BNX2_RPM_RC_CNTL_0_COMP_NEQUAL (1L<<16)
1990#define BNX2_RPM_RC_CNTL_0_COMP_GREATER (2L<<16) 3341#define BNX2_RPM_RC_CNTL_0_COMP_GREATER (2L<<16)
1991#define BNX2_RPM_RC_CNTL_0_COMP_LESS (3L<<16) 3342#define BNX2_RPM_RC_CNTL_0_COMP_LESS (3L<<16)
3343#define BNX2_RPM_RC_CNTL_0_MAP_XI (1L<<18)
1992#define BNX2_RPM_RC_CNTL_0_SBIT (1L<<19) 3344#define BNX2_RPM_RC_CNTL_0_SBIT (1L<<19)
1993#define BNX2_RPM_RC_CNTL_0_CMDSEL (0xfL<<20) 3345#define BNX2_RPM_RC_CNTL_0_CMDSEL (0xfL<<20)
1994#define BNX2_RPM_RC_CNTL_0_MAP (1L<<24) 3346#define BNX2_RPM_RC_CNTL_0_MAP (1L<<24)
3347#define BNX2_RPM_RC_CNTL_0_CMDSEL_XI (0x1fL<<20)
1995#define BNX2_RPM_RC_CNTL_0_DISCARD (1L<<25) 3348#define BNX2_RPM_RC_CNTL_0_DISCARD (1L<<25)
1996#define BNX2_RPM_RC_CNTL_0_MASK (1L<<26) 3349#define BNX2_RPM_RC_CNTL_0_MASK (1L<<26)
1997#define BNX2_RPM_RC_CNTL_0_P1 (1L<<27) 3350#define BNX2_RPM_RC_CNTL_0_P1 (1L<<27)
@@ -2006,81 +3359,518 @@ struct l2_fhdr {
2006#define BNX2_RPM_RC_CNTL_1 0x00001908 3359#define BNX2_RPM_RC_CNTL_1 0x00001908
2007#define BNX2_RPM_RC_CNTL_1_A (0x3ffffL<<0) 3360#define BNX2_RPM_RC_CNTL_1_A (0x3ffffL<<0)
2008#define BNX2_RPM_RC_CNTL_1_B (0xfffL<<19) 3361#define BNX2_RPM_RC_CNTL_1_B (0xfffL<<19)
3362#define BNX2_RPM_RC_CNTL_1_OFFSET_XI (0xffL<<0)
3363#define BNX2_RPM_RC_CNTL_1_CLASS_XI (0x7L<<8)
3364#define BNX2_RPM_RC_CNTL_1_PRIORITY_XI (1L<<11)
3365#define BNX2_RPM_RC_CNTL_1_P4_XI (1L<<12)
3366#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_XI (0x7L<<13)
3367#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_START_XI (0L<<13)
3368#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_IP_XI (1L<<13)
3369#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_TCP_XI (2L<<13)
3370#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_UDP_XI (3L<<13)
3371#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_DATA_XI (4L<<13)
3372#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_TCP_UDP_XI (5L<<13)
3373#define BNX2_RPM_RC_CNTL_1_HDR_TYPE_ICMPV6_XI (6L<<13)
3374#define BNX2_RPM_RC_CNTL_1_COMP_XI (0x3L<<16)
3375#define BNX2_RPM_RC_CNTL_1_COMP_EQUAL_XI (0L<<16)
3376#define BNX2_RPM_RC_CNTL_1_COMP_NEQUAL_XI (1L<<16)
3377#define BNX2_RPM_RC_CNTL_1_COMP_GREATER_XI (2L<<16)
3378#define BNX2_RPM_RC_CNTL_1_COMP_LESS_XI (3L<<16)
3379#define BNX2_RPM_RC_CNTL_1_MAP_XI (1L<<18)
3380#define BNX2_RPM_RC_CNTL_1_SBIT_XI (1L<<19)
3381#define BNX2_RPM_RC_CNTL_1_CMDSEL_XI (0x1fL<<20)
3382#define BNX2_RPM_RC_CNTL_1_DISCARD_XI (1L<<25)
3383#define BNX2_RPM_RC_CNTL_1_MASK_XI (1L<<26)
3384#define BNX2_RPM_RC_CNTL_1_P1_XI (1L<<27)
3385#define BNX2_RPM_RC_CNTL_1_P2_XI (1L<<28)
3386#define BNX2_RPM_RC_CNTL_1_P3_XI (1L<<29)
3387#define BNX2_RPM_RC_CNTL_1_NBIT_XI (1L<<30)
2009 3388
2010#define BNX2_RPM_RC_VALUE_MASK_1 0x0000190c 3389#define BNX2_RPM_RC_VALUE_MASK_1 0x0000190c
3390#define BNX2_RPM_RC_VALUE_MASK_1_VALUE (0xffffL<<0)
3391#define BNX2_RPM_RC_VALUE_MASK_1_MASK (0xffffL<<16)
3392
2011#define BNX2_RPM_RC_CNTL_2 0x00001910 3393#define BNX2_RPM_RC_CNTL_2 0x00001910
2012#define BNX2_RPM_RC_CNTL_2_A (0x3ffffL<<0) 3394#define BNX2_RPM_RC_CNTL_2_A (0x3ffffL<<0)
2013#define BNX2_RPM_RC_CNTL_2_B (0xfffL<<19) 3395#define BNX2_RPM_RC_CNTL_2_B (0xfffL<<19)
3396#define BNX2_RPM_RC_CNTL_2_OFFSET_XI (0xffL<<0)
3397#define BNX2_RPM_RC_CNTL_2_CLASS_XI (0x7L<<8)
3398#define BNX2_RPM_RC_CNTL_2_PRIORITY_XI (1L<<11)
3399#define BNX2_RPM_RC_CNTL_2_P4_XI (1L<<12)
3400#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_XI (0x7L<<13)
3401#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_START_XI (0L<<13)
3402#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_IP_XI (1L<<13)
3403#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_TCP_XI (2L<<13)
3404#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_UDP_XI (3L<<13)
3405#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_DATA_XI (4L<<13)
3406#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_TCP_UDP_XI (5L<<13)
3407#define BNX2_RPM_RC_CNTL_2_HDR_TYPE_ICMPV6_XI (6L<<13)
3408#define BNX2_RPM_RC_CNTL_2_COMP_XI (0x3L<<16)
3409#define BNX2_RPM_RC_CNTL_2_COMP_EQUAL_XI (0L<<16)
3410#define BNX2_RPM_RC_CNTL_2_COMP_NEQUAL_XI (1L<<16)
3411#define BNX2_RPM_RC_CNTL_2_COMP_GREATER_XI (2L<<16)
3412#define BNX2_RPM_RC_CNTL_2_COMP_LESS_XI (3L<<16)
3413#define BNX2_RPM_RC_CNTL_2_MAP_XI (1L<<18)
3414#define BNX2_RPM_RC_CNTL_2_SBIT_XI (1L<<19)
3415#define BNX2_RPM_RC_CNTL_2_CMDSEL_XI (0x1fL<<20)
3416#define BNX2_RPM_RC_CNTL_2_DISCARD_XI (1L<<25)
3417#define BNX2_RPM_RC_CNTL_2_MASK_XI (1L<<26)
3418#define BNX2_RPM_RC_CNTL_2_P1_XI (1L<<27)
3419#define BNX2_RPM_RC_CNTL_2_P2_XI (1L<<28)
3420#define BNX2_RPM_RC_CNTL_2_P3_XI (1L<<29)
3421#define BNX2_RPM_RC_CNTL_2_NBIT_XI (1L<<30)
2014 3422
2015#define BNX2_RPM_RC_VALUE_MASK_2 0x00001914 3423#define BNX2_RPM_RC_VALUE_MASK_2 0x00001914
3424#define BNX2_RPM_RC_VALUE_MASK_2_VALUE (0xffffL<<0)
3425#define BNX2_RPM_RC_VALUE_MASK_2_MASK (0xffffL<<16)
3426
2016#define BNX2_RPM_RC_CNTL_3 0x00001918 3427#define BNX2_RPM_RC_CNTL_3 0x00001918
2017#define BNX2_RPM_RC_CNTL_3_A (0x3ffffL<<0) 3428#define BNX2_RPM_RC_CNTL_3_A (0x3ffffL<<0)
2018#define BNX2_RPM_RC_CNTL_3_B (0xfffL<<19) 3429#define BNX2_RPM_RC_CNTL_3_B (0xfffL<<19)
3430#define BNX2_RPM_RC_CNTL_3_OFFSET_XI (0xffL<<0)
3431#define BNX2_RPM_RC_CNTL_3_CLASS_XI (0x7L<<8)
3432#define BNX2_RPM_RC_CNTL_3_PRIORITY_XI (1L<<11)
3433#define BNX2_RPM_RC_CNTL_3_P4_XI (1L<<12)
3434#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_XI (0x7L<<13)
3435#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_START_XI (0L<<13)
3436#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_IP_XI (1L<<13)
3437#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_TCP_XI (2L<<13)
3438#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_UDP_XI (3L<<13)
3439#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_DATA_XI (4L<<13)
3440#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_TCP_UDP_XI (5L<<13)
3441#define BNX2_RPM_RC_CNTL_3_HDR_TYPE_ICMPV6_XI (6L<<13)
3442#define BNX2_RPM_RC_CNTL_3_COMP_XI (0x3L<<16)
3443#define BNX2_RPM_RC_CNTL_3_COMP_EQUAL_XI (0L<<16)
3444#define BNX2_RPM_RC_CNTL_3_COMP_NEQUAL_XI (1L<<16)
3445#define BNX2_RPM_RC_CNTL_3_COMP_GREATER_XI (2L<<16)
3446#define BNX2_RPM_RC_CNTL_3_COMP_LESS_XI (3L<<16)
3447#define BNX2_RPM_RC_CNTL_3_MAP_XI (1L<<18)
3448#define BNX2_RPM_RC_CNTL_3_SBIT_XI (1L<<19)
3449#define BNX2_RPM_RC_CNTL_3_CMDSEL_XI (0x1fL<<20)
3450#define BNX2_RPM_RC_CNTL_3_DISCARD_XI (1L<<25)
3451#define BNX2_RPM_RC_CNTL_3_MASK_XI (1L<<26)
3452#define BNX2_RPM_RC_CNTL_3_P1_XI (1L<<27)
3453#define BNX2_RPM_RC_CNTL_3_P2_XI (1L<<28)
3454#define BNX2_RPM_RC_CNTL_3_P3_XI (1L<<29)
3455#define BNX2_RPM_RC_CNTL_3_NBIT_XI (1L<<30)
2019 3456
2020#define BNX2_RPM_RC_VALUE_MASK_3 0x0000191c 3457#define BNX2_RPM_RC_VALUE_MASK_3 0x0000191c
3458#define BNX2_RPM_RC_VALUE_MASK_3_VALUE (0xffffL<<0)
3459#define BNX2_RPM_RC_VALUE_MASK_3_MASK (0xffffL<<16)
3460
2021#define BNX2_RPM_RC_CNTL_4 0x00001920 3461#define BNX2_RPM_RC_CNTL_4 0x00001920
2022#define BNX2_RPM_RC_CNTL_4_A (0x3ffffL<<0) 3462#define BNX2_RPM_RC_CNTL_4_A (0x3ffffL<<0)
2023#define BNX2_RPM_RC_CNTL_4_B (0xfffL<<19) 3463#define BNX2_RPM_RC_CNTL_4_B (0xfffL<<19)
3464#define BNX2_RPM_RC_CNTL_4_OFFSET_XI (0xffL<<0)
3465#define BNX2_RPM_RC_CNTL_4_CLASS_XI (0x7L<<8)
3466#define BNX2_RPM_RC_CNTL_4_PRIORITY_XI (1L<<11)
3467#define BNX2_RPM_RC_CNTL_4_P4_XI (1L<<12)
3468#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_XI (0x7L<<13)
3469#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_START_XI (0L<<13)
3470#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_IP_XI (1L<<13)
3471#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_TCP_XI (2L<<13)
3472#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_UDP_XI (3L<<13)
3473#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_DATA_XI (4L<<13)
3474#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_TCP_UDP_XI (5L<<13)
3475#define BNX2_RPM_RC_CNTL_4_HDR_TYPE_ICMPV6_XI (6L<<13)
3476#define BNX2_RPM_RC_CNTL_4_COMP_XI (0x3L<<16)
3477#define BNX2_RPM_RC_CNTL_4_COMP_EQUAL_XI (0L<<16)
3478#define BNX2_RPM_RC_CNTL_4_COMP_NEQUAL_XI (1L<<16)
3479#define BNX2_RPM_RC_CNTL_4_COMP_GREATER_XI (2L<<16)
3480#define BNX2_RPM_RC_CNTL_4_COMP_LESS_XI (3L<<16)
3481#define BNX2_RPM_RC_CNTL_4_MAP_XI (1L<<18)
3482#define BNX2_RPM_RC_CNTL_4_SBIT_XI (1L<<19)
3483#define BNX2_RPM_RC_CNTL_4_CMDSEL_XI (0x1fL<<20)
3484#define BNX2_RPM_RC_CNTL_4_DISCARD_XI (1L<<25)
3485#define BNX2_RPM_RC_CNTL_4_MASK_XI (1L<<26)
3486#define BNX2_RPM_RC_CNTL_4_P1_XI (1L<<27)
3487#define BNX2_RPM_RC_CNTL_4_P2_XI (1L<<28)
3488#define BNX2_RPM_RC_CNTL_4_P3_XI (1L<<29)
3489#define BNX2_RPM_RC_CNTL_4_NBIT_XI (1L<<30)
2024 3490
2025#define BNX2_RPM_RC_VALUE_MASK_4 0x00001924 3491#define BNX2_RPM_RC_VALUE_MASK_4 0x00001924
3492#define BNX2_RPM_RC_VALUE_MASK_4_VALUE (0xffffL<<0)
3493#define BNX2_RPM_RC_VALUE_MASK_4_MASK (0xffffL<<16)
3494
2026#define BNX2_RPM_RC_CNTL_5 0x00001928 3495#define BNX2_RPM_RC_CNTL_5 0x00001928
2027#define BNX2_RPM_RC_CNTL_5_A (0x3ffffL<<0) 3496#define BNX2_RPM_RC_CNTL_5_A (0x3ffffL<<0)
2028#define BNX2_RPM_RC_CNTL_5_B (0xfffL<<19) 3497#define BNX2_RPM_RC_CNTL_5_B (0xfffL<<19)
3498#define BNX2_RPM_RC_CNTL_5_OFFSET_XI (0xffL<<0)
3499#define BNX2_RPM_RC_CNTL_5_CLASS_XI (0x7L<<8)
3500#define BNX2_RPM_RC_CNTL_5_PRIORITY_XI (1L<<11)
3501#define BNX2_RPM_RC_CNTL_5_P4_XI (1L<<12)
3502#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_XI (0x7L<<13)
3503#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_START_XI (0L<<13)
3504#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_IP_XI (1L<<13)
3505#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_TCP_XI (2L<<13)
3506#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_UDP_XI (3L<<13)
3507#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_DATA_XI (4L<<13)
3508#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_TCP_UDP_XI (5L<<13)
3509#define BNX2_RPM_RC_CNTL_5_HDR_TYPE_ICMPV6_XI (6L<<13)
3510#define BNX2_RPM_RC_CNTL_5_COMP_XI (0x3L<<16)
3511#define BNX2_RPM_RC_CNTL_5_COMP_EQUAL_XI (0L<<16)
3512#define BNX2_RPM_RC_CNTL_5_COMP_NEQUAL_XI (1L<<16)
3513#define BNX2_RPM_RC_CNTL_5_COMP_GREATER_XI (2L<<16)
3514#define BNX2_RPM_RC_CNTL_5_COMP_LESS_XI (3L<<16)
3515#define BNX2_RPM_RC_CNTL_5_MAP_XI (1L<<18)
3516#define BNX2_RPM_RC_CNTL_5_SBIT_XI (1L<<19)
3517#define BNX2_RPM_RC_CNTL_5_CMDSEL_XI (0x1fL<<20)
3518#define BNX2_RPM_RC_CNTL_5_DISCARD_XI (1L<<25)
3519#define BNX2_RPM_RC_CNTL_5_MASK_XI (1L<<26)
3520#define BNX2_RPM_RC_CNTL_5_P1_XI (1L<<27)
3521#define BNX2_RPM_RC_CNTL_5_P2_XI (1L<<28)
3522#define BNX2_RPM_RC_CNTL_5_P3_XI (1L<<29)
3523#define BNX2_RPM_RC_CNTL_5_NBIT_XI (1L<<30)
2029 3524
2030#define BNX2_RPM_RC_VALUE_MASK_5 0x0000192c 3525#define BNX2_RPM_RC_VALUE_MASK_5 0x0000192c
3526#define BNX2_RPM_RC_VALUE_MASK_5_VALUE (0xffffL<<0)
3527#define BNX2_RPM_RC_VALUE_MASK_5_MASK (0xffffL<<16)
3528
2031#define BNX2_RPM_RC_CNTL_6 0x00001930 3529#define BNX2_RPM_RC_CNTL_6 0x00001930
2032#define BNX2_RPM_RC_CNTL_6_A (0x3ffffL<<0) 3530#define BNX2_RPM_RC_CNTL_6_A (0x3ffffL<<0)
2033#define BNX2_RPM_RC_CNTL_6_B (0xfffL<<19) 3531#define BNX2_RPM_RC_CNTL_6_B (0xfffL<<19)
3532#define BNX2_RPM_RC_CNTL_6_OFFSET_XI (0xffL<<0)
3533#define BNX2_RPM_RC_CNTL_6_CLASS_XI (0x7L<<8)
3534#define BNX2_RPM_RC_CNTL_6_PRIORITY_XI (1L<<11)
3535#define BNX2_RPM_RC_CNTL_6_P4_XI (1L<<12)
3536#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_XI (0x7L<<13)
3537#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_START_XI (0L<<13)
3538#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_IP_XI (1L<<13)
3539#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_TCP_XI (2L<<13)
3540#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_UDP_XI (3L<<13)
3541#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_DATA_XI (4L<<13)
3542#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_TCP_UDP_XI (5L<<13)
3543#define BNX2_RPM_RC_CNTL_6_HDR_TYPE_ICMPV6_XI (6L<<13)
3544#define BNX2_RPM_RC_CNTL_6_COMP_XI (0x3L<<16)
3545#define BNX2_RPM_RC_CNTL_6_COMP_EQUAL_XI (0L<<16)
3546#define BNX2_RPM_RC_CNTL_6_COMP_NEQUAL_XI (1L<<16)
3547#define BNX2_RPM_RC_CNTL_6_COMP_GREATER_XI (2L<<16)
3548#define BNX2_RPM_RC_CNTL_6_COMP_LESS_XI (3L<<16)
3549#define BNX2_RPM_RC_CNTL_6_MAP_XI (1L<<18)
3550#define BNX2_RPM_RC_CNTL_6_SBIT_XI (1L<<19)
3551#define BNX2_RPM_RC_CNTL_6_CMDSEL_XI (0x1fL<<20)
3552#define BNX2_RPM_RC_CNTL_6_DISCARD_XI (1L<<25)
3553#define BNX2_RPM_RC_CNTL_6_MASK_XI (1L<<26)
3554#define BNX2_RPM_RC_CNTL_6_P1_XI (1L<<27)
3555#define BNX2_RPM_RC_CNTL_6_P2_XI (1L<<28)
3556#define BNX2_RPM_RC_CNTL_6_P3_XI (1L<<29)
3557#define BNX2_RPM_RC_CNTL_6_NBIT_XI (1L<<30)
2034 3558
2035#define BNX2_RPM_RC_VALUE_MASK_6 0x00001934 3559#define BNX2_RPM_RC_VALUE_MASK_6 0x00001934
3560#define BNX2_RPM_RC_VALUE_MASK_6_VALUE (0xffffL<<0)
3561#define BNX2_RPM_RC_VALUE_MASK_6_MASK (0xffffL<<16)
3562
2036#define BNX2_RPM_RC_CNTL_7 0x00001938 3563#define BNX2_RPM_RC_CNTL_7 0x00001938
2037#define BNX2_RPM_RC_CNTL_7_A (0x3ffffL<<0) 3564#define BNX2_RPM_RC_CNTL_7_A (0x3ffffL<<0)
2038#define BNX2_RPM_RC_CNTL_7_B (0xfffL<<19) 3565#define BNX2_RPM_RC_CNTL_7_B (0xfffL<<19)
3566#define BNX2_RPM_RC_CNTL_7_OFFSET_XI (0xffL<<0)
3567#define BNX2_RPM_RC_CNTL_7_CLASS_XI (0x7L<<8)
3568#define BNX2_RPM_RC_CNTL_7_PRIORITY_XI (1L<<11)
3569#define BNX2_RPM_RC_CNTL_7_P4_XI (1L<<12)
3570#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_XI (0x7L<<13)
3571#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_START_XI (0L<<13)
3572#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_IP_XI (1L<<13)
3573#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_TCP_XI (2L<<13)
3574#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_UDP_XI (3L<<13)
3575#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_DATA_XI (4L<<13)
3576#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_TCP_UDP_XI (5L<<13)
3577#define BNX2_RPM_RC_CNTL_7_HDR_TYPE_ICMPV6_XI (6L<<13)
3578#define BNX2_RPM_RC_CNTL_7_COMP_XI (0x3L<<16)
3579#define BNX2_RPM_RC_CNTL_7_COMP_EQUAL_XI (0L<<16)
3580#define BNX2_RPM_RC_CNTL_7_COMP_NEQUAL_XI (1L<<16)
3581#define BNX2_RPM_RC_CNTL_7_COMP_GREATER_XI (2L<<16)
3582#define BNX2_RPM_RC_CNTL_7_COMP_LESS_XI (3L<<16)
3583#define BNX2_RPM_RC_CNTL_7_MAP_XI (1L<<18)
3584#define BNX2_RPM_RC_CNTL_7_SBIT_XI (1L<<19)
3585#define BNX2_RPM_RC_CNTL_7_CMDSEL_XI (0x1fL<<20)
3586#define BNX2_RPM_RC_CNTL_7_DISCARD_XI (1L<<25)
3587#define BNX2_RPM_RC_CNTL_7_MASK_XI (1L<<26)
3588#define BNX2_RPM_RC_CNTL_7_P1_XI (1L<<27)
3589#define BNX2_RPM_RC_CNTL_7_P2_XI (1L<<28)
3590#define BNX2_RPM_RC_CNTL_7_P3_XI (1L<<29)
3591#define BNX2_RPM_RC_CNTL_7_NBIT_XI (1L<<30)
2039 3592
2040#define BNX2_RPM_RC_VALUE_MASK_7 0x0000193c 3593#define BNX2_RPM_RC_VALUE_MASK_7 0x0000193c
3594#define BNX2_RPM_RC_VALUE_MASK_7_VALUE (0xffffL<<0)
3595#define BNX2_RPM_RC_VALUE_MASK_7_MASK (0xffffL<<16)
3596
2041#define BNX2_RPM_RC_CNTL_8 0x00001940 3597#define BNX2_RPM_RC_CNTL_8 0x00001940
2042#define BNX2_RPM_RC_CNTL_8_A (0x3ffffL<<0) 3598#define BNX2_RPM_RC_CNTL_8_A (0x3ffffL<<0)
2043#define BNX2_RPM_RC_CNTL_8_B (0xfffL<<19) 3599#define BNX2_RPM_RC_CNTL_8_B (0xfffL<<19)
3600#define BNX2_RPM_RC_CNTL_8_OFFSET_XI (0xffL<<0)
3601#define BNX2_RPM_RC_CNTL_8_CLASS_XI (0x7L<<8)
3602#define BNX2_RPM_RC_CNTL_8_PRIORITY_XI (1L<<11)
3603#define BNX2_RPM_RC_CNTL_8_P4_XI (1L<<12)
3604#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_XI (0x7L<<13)
3605#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_START_XI (0L<<13)
3606#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_IP_XI (1L<<13)
3607#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_TCP_XI (2L<<13)
3608#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_UDP_XI (3L<<13)
3609#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_DATA_XI (4L<<13)
3610#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_TCP_UDP_XI (5L<<13)
3611#define BNX2_RPM_RC_CNTL_8_HDR_TYPE_ICMPV6_XI (6L<<13)
3612#define BNX2_RPM_RC_CNTL_8_COMP_XI (0x3L<<16)
3613#define BNX2_RPM_RC_CNTL_8_COMP_EQUAL_XI (0L<<16)
3614#define BNX2_RPM_RC_CNTL_8_COMP_NEQUAL_XI (1L<<16)
3615#define BNX2_RPM_RC_CNTL_8_COMP_GREATER_XI (2L<<16)
3616#define BNX2_RPM_RC_CNTL_8_COMP_LESS_XI (3L<<16)
3617#define BNX2_RPM_RC_CNTL_8_MAP_XI (1L<<18)
3618#define BNX2_RPM_RC_CNTL_8_SBIT_XI (1L<<19)
3619#define BNX2_RPM_RC_CNTL_8_CMDSEL_XI (0x1fL<<20)
3620#define BNX2_RPM_RC_CNTL_8_DISCARD_XI (1L<<25)
3621#define BNX2_RPM_RC_CNTL_8_MASK_XI (1L<<26)
3622#define BNX2_RPM_RC_CNTL_8_P1_XI (1L<<27)
3623#define BNX2_RPM_RC_CNTL_8_P2_XI (1L<<28)
3624#define BNX2_RPM_RC_CNTL_8_P3_XI (1L<<29)
3625#define BNX2_RPM_RC_CNTL_8_NBIT_XI (1L<<30)
2044 3626
2045#define BNX2_RPM_RC_VALUE_MASK_8 0x00001944 3627#define BNX2_RPM_RC_VALUE_MASK_8 0x00001944
3628#define BNX2_RPM_RC_VALUE_MASK_8_VALUE (0xffffL<<0)
3629#define BNX2_RPM_RC_VALUE_MASK_8_MASK (0xffffL<<16)
3630
2046#define BNX2_RPM_RC_CNTL_9 0x00001948 3631#define BNX2_RPM_RC_CNTL_9 0x00001948
2047#define BNX2_RPM_RC_CNTL_9_A (0x3ffffL<<0) 3632#define BNX2_RPM_RC_CNTL_9_A (0x3ffffL<<0)
2048#define BNX2_RPM_RC_CNTL_9_B (0xfffL<<19) 3633#define BNX2_RPM_RC_CNTL_9_B (0xfffL<<19)
3634#define BNX2_RPM_RC_CNTL_9_OFFSET_XI (0xffL<<0)
3635#define BNX2_RPM_RC_CNTL_9_CLASS_XI (0x7L<<8)
3636#define BNX2_RPM_RC_CNTL_9_PRIORITY_XI (1L<<11)
3637#define BNX2_RPM_RC_CNTL_9_P4_XI (1L<<12)
3638#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_XI (0x7L<<13)
3639#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_START_XI (0L<<13)
3640#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_IP_XI (1L<<13)
3641#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_TCP_XI (2L<<13)
3642#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_UDP_XI (3L<<13)
3643#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_DATA_XI (4L<<13)
3644#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_TCP_UDP_XI (5L<<13)
3645#define BNX2_RPM_RC_CNTL_9_HDR_TYPE_ICMPV6_XI (6L<<13)
3646#define BNX2_RPM_RC_CNTL_9_COMP_XI (0x3L<<16)
3647#define BNX2_RPM_RC_CNTL_9_COMP_EQUAL_XI (0L<<16)
3648#define BNX2_RPM_RC_CNTL_9_COMP_NEQUAL_XI (1L<<16)
3649#define BNX2_RPM_RC_CNTL_9_COMP_GREATER_XI (2L<<16)
3650#define BNX2_RPM_RC_CNTL_9_COMP_LESS_XI (3L<<16)
3651#define BNX2_RPM_RC_CNTL_9_MAP_XI (1L<<18)
3652#define BNX2_RPM_RC_CNTL_9_SBIT_XI (1L<<19)
3653#define BNX2_RPM_RC_CNTL_9_CMDSEL_XI (0x1fL<<20)
3654#define BNX2_RPM_RC_CNTL_9_DISCARD_XI (1L<<25)
3655#define BNX2_RPM_RC_CNTL_9_MASK_XI (1L<<26)
3656#define BNX2_RPM_RC_CNTL_9_P1_XI (1L<<27)
3657#define BNX2_RPM_RC_CNTL_9_P2_XI (1L<<28)
3658#define BNX2_RPM_RC_CNTL_9_P3_XI (1L<<29)
3659#define BNX2_RPM_RC_CNTL_9_NBIT_XI (1L<<30)
2049 3660
2050#define BNX2_RPM_RC_VALUE_MASK_9 0x0000194c 3661#define BNX2_RPM_RC_VALUE_MASK_9 0x0000194c
3662#define BNX2_RPM_RC_VALUE_MASK_9_VALUE (0xffffL<<0)
3663#define BNX2_RPM_RC_VALUE_MASK_9_MASK (0xffffL<<16)
3664
2051#define BNX2_RPM_RC_CNTL_10 0x00001950 3665#define BNX2_RPM_RC_CNTL_10 0x00001950
2052#define BNX2_RPM_RC_CNTL_10_A (0x3ffffL<<0) 3666#define BNX2_RPM_RC_CNTL_10_A (0x3ffffL<<0)
2053#define BNX2_RPM_RC_CNTL_10_B (0xfffL<<19) 3667#define BNX2_RPM_RC_CNTL_10_B (0xfffL<<19)
3668#define BNX2_RPM_RC_CNTL_10_OFFSET_XI (0xffL<<0)
3669#define BNX2_RPM_RC_CNTL_10_CLASS_XI (0x7L<<8)
3670#define BNX2_RPM_RC_CNTL_10_PRIORITY_XI (1L<<11)
3671#define BNX2_RPM_RC_CNTL_10_P4_XI (1L<<12)
3672#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_XI (0x7L<<13)
3673#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_START_XI (0L<<13)
3674#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_IP_XI (1L<<13)
3675#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_TCP_XI (2L<<13)
3676#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_UDP_XI (3L<<13)
3677#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_DATA_XI (4L<<13)
3678#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_TCP_UDP_XI (5L<<13)
3679#define BNX2_RPM_RC_CNTL_10_HDR_TYPE_ICMPV6_XI (6L<<13)
3680#define BNX2_RPM_RC_CNTL_10_COMP_XI (0x3L<<16)
3681#define BNX2_RPM_RC_CNTL_10_COMP_EQUAL_XI (0L<<16)
3682#define BNX2_RPM_RC_CNTL_10_COMP_NEQUAL_XI (1L<<16)
3683#define BNX2_RPM_RC_CNTL_10_COMP_GREATER_XI (2L<<16)
3684#define BNX2_RPM_RC_CNTL_10_COMP_LESS_XI (3L<<16)
3685#define BNX2_RPM_RC_CNTL_10_MAP_XI (1L<<18)
3686#define BNX2_RPM_RC_CNTL_10_SBIT_XI (1L<<19)
3687#define BNX2_RPM_RC_CNTL_10_CMDSEL_XI (0x1fL<<20)
3688#define BNX2_RPM_RC_CNTL_10_DISCARD_XI (1L<<25)
3689#define BNX2_RPM_RC_CNTL_10_MASK_XI (1L<<26)
3690#define BNX2_RPM_RC_CNTL_10_P1_XI (1L<<27)
3691#define BNX2_RPM_RC_CNTL_10_P2_XI (1L<<28)
3692#define BNX2_RPM_RC_CNTL_10_P3_XI (1L<<29)
3693#define BNX2_RPM_RC_CNTL_10_NBIT_XI (1L<<30)
2054 3694
2055#define BNX2_RPM_RC_VALUE_MASK_10 0x00001954 3695#define BNX2_RPM_RC_VALUE_MASK_10 0x00001954
3696#define BNX2_RPM_RC_VALUE_MASK_10_VALUE (0xffffL<<0)
3697#define BNX2_RPM_RC_VALUE_MASK_10_MASK (0xffffL<<16)
3698
2056#define BNX2_RPM_RC_CNTL_11 0x00001958 3699#define BNX2_RPM_RC_CNTL_11 0x00001958
2057#define BNX2_RPM_RC_CNTL_11_A (0x3ffffL<<0) 3700#define BNX2_RPM_RC_CNTL_11_A (0x3ffffL<<0)
2058#define BNX2_RPM_RC_CNTL_11_B (0xfffL<<19) 3701#define BNX2_RPM_RC_CNTL_11_B (0xfffL<<19)
3702#define BNX2_RPM_RC_CNTL_11_OFFSET_XI (0xffL<<0)
3703#define BNX2_RPM_RC_CNTL_11_CLASS_XI (0x7L<<8)
3704#define BNX2_RPM_RC_CNTL_11_PRIORITY_XI (1L<<11)
3705#define BNX2_RPM_RC_CNTL_11_P4_XI (1L<<12)
3706#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_XI (0x7L<<13)
3707#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_START_XI (0L<<13)
3708#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_IP_XI (1L<<13)
3709#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_TCP_XI (2L<<13)
3710#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_UDP_XI (3L<<13)
3711#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_DATA_XI (4L<<13)
3712#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_TCP_UDP_XI (5L<<13)
3713#define BNX2_RPM_RC_CNTL_11_HDR_TYPE_ICMPV6_XI (6L<<13)
3714#define BNX2_RPM_RC_CNTL_11_COMP_XI (0x3L<<16)
3715#define BNX2_RPM_RC_CNTL_11_COMP_EQUAL_XI (0L<<16)
3716#define BNX2_RPM_RC_CNTL_11_COMP_NEQUAL_XI (1L<<16)
3717#define BNX2_RPM_RC_CNTL_11_COMP_GREATER_XI (2L<<16)
3718#define BNX2_RPM_RC_CNTL_11_COMP_LESS_XI (3L<<16)
3719#define BNX2_RPM_RC_CNTL_11_MAP_XI (1L<<18)
3720#define BNX2_RPM_RC_CNTL_11_SBIT_XI (1L<<19)
3721#define BNX2_RPM_RC_CNTL_11_CMDSEL_XI (0x1fL<<20)
3722#define BNX2_RPM_RC_CNTL_11_DISCARD_XI (1L<<25)
3723#define BNX2_RPM_RC_CNTL_11_MASK_XI (1L<<26)
3724#define BNX2_RPM_RC_CNTL_11_P1_XI (1L<<27)
3725#define BNX2_RPM_RC_CNTL_11_P2_XI (1L<<28)
3726#define BNX2_RPM_RC_CNTL_11_P3_XI (1L<<29)
3727#define BNX2_RPM_RC_CNTL_11_NBIT_XI (1L<<30)
2059 3728
2060#define BNX2_RPM_RC_VALUE_MASK_11 0x0000195c 3729#define BNX2_RPM_RC_VALUE_MASK_11 0x0000195c
3730#define BNX2_RPM_RC_VALUE_MASK_11_VALUE (0xffffL<<0)
3731#define BNX2_RPM_RC_VALUE_MASK_11_MASK (0xffffL<<16)
3732
2061#define BNX2_RPM_RC_CNTL_12 0x00001960 3733#define BNX2_RPM_RC_CNTL_12 0x00001960
2062#define BNX2_RPM_RC_CNTL_12_A (0x3ffffL<<0) 3734#define BNX2_RPM_RC_CNTL_12_A (0x3ffffL<<0)
2063#define BNX2_RPM_RC_CNTL_12_B (0xfffL<<19) 3735#define BNX2_RPM_RC_CNTL_12_B (0xfffL<<19)
3736#define BNX2_RPM_RC_CNTL_12_OFFSET_XI (0xffL<<0)
3737#define BNX2_RPM_RC_CNTL_12_CLASS_XI (0x7L<<8)
3738#define BNX2_RPM_RC_CNTL_12_PRIORITY_XI (1L<<11)
3739#define BNX2_RPM_RC_CNTL_12_P4_XI (1L<<12)
3740#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_XI (0x7L<<13)
3741#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_START_XI (0L<<13)
3742#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_IP_XI (1L<<13)
3743#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_TCP_XI (2L<<13)
3744#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_UDP_XI (3L<<13)
3745#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_DATA_XI (4L<<13)
3746#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_TCP_UDP_XI (5L<<13)
3747#define BNX2_RPM_RC_CNTL_12_HDR_TYPE_ICMPV6_XI (6L<<13)
3748#define BNX2_RPM_RC_CNTL_12_COMP_XI (0x3L<<16)
3749#define BNX2_RPM_RC_CNTL_12_COMP_EQUAL_XI (0L<<16)
3750#define BNX2_RPM_RC_CNTL_12_COMP_NEQUAL_XI (1L<<16)
3751#define BNX2_RPM_RC_CNTL_12_COMP_GREATER_XI (2L<<16)
3752#define BNX2_RPM_RC_CNTL_12_COMP_LESS_XI (3L<<16)
3753#define BNX2_RPM_RC_CNTL_12_MAP_XI (1L<<18)
3754#define BNX2_RPM_RC_CNTL_12_SBIT_XI (1L<<19)
3755#define BNX2_RPM_RC_CNTL_12_CMDSEL_XI (0x1fL<<20)
3756#define BNX2_RPM_RC_CNTL_12_DISCARD_XI (1L<<25)
3757#define BNX2_RPM_RC_CNTL_12_MASK_XI (1L<<26)
3758#define BNX2_RPM_RC_CNTL_12_P1_XI (1L<<27)
3759#define BNX2_RPM_RC_CNTL_12_P2_XI (1L<<28)
3760#define BNX2_RPM_RC_CNTL_12_P3_XI (1L<<29)
3761#define BNX2_RPM_RC_CNTL_12_NBIT_XI (1L<<30)
2064 3762
2065#define BNX2_RPM_RC_VALUE_MASK_12 0x00001964 3763#define BNX2_RPM_RC_VALUE_MASK_12 0x00001964
3764#define BNX2_RPM_RC_VALUE_MASK_12_VALUE (0xffffL<<0)
3765#define BNX2_RPM_RC_VALUE_MASK_12_MASK (0xffffL<<16)
3766
2066#define BNX2_RPM_RC_CNTL_13 0x00001968 3767#define BNX2_RPM_RC_CNTL_13 0x00001968
2067#define BNX2_RPM_RC_CNTL_13_A (0x3ffffL<<0) 3768#define BNX2_RPM_RC_CNTL_13_A (0x3ffffL<<0)
2068#define BNX2_RPM_RC_CNTL_13_B (0xfffL<<19) 3769#define BNX2_RPM_RC_CNTL_13_B (0xfffL<<19)
3770#define BNX2_RPM_RC_CNTL_13_OFFSET_XI (0xffL<<0)
3771#define BNX2_RPM_RC_CNTL_13_CLASS_XI (0x7L<<8)
3772#define BNX2_RPM_RC_CNTL_13_PRIORITY_XI (1L<<11)
3773#define BNX2_RPM_RC_CNTL_13_P4_XI (1L<<12)
3774#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_XI (0x7L<<13)
3775#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_START_XI (0L<<13)
3776#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_IP_XI (1L<<13)
3777#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_TCP_XI (2L<<13)
3778#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_UDP_XI (3L<<13)
3779#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_DATA_XI (4L<<13)
3780#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_TCP_UDP_XI (5L<<13)
3781#define BNX2_RPM_RC_CNTL_13_HDR_TYPE_ICMPV6_XI (6L<<13)
3782#define BNX2_RPM_RC_CNTL_13_COMP_XI (0x3L<<16)
3783#define BNX2_RPM_RC_CNTL_13_COMP_EQUAL_XI (0L<<16)
3784#define BNX2_RPM_RC_CNTL_13_COMP_NEQUAL_XI (1L<<16)
3785#define BNX2_RPM_RC_CNTL_13_COMP_GREATER_XI (2L<<16)
3786#define BNX2_RPM_RC_CNTL_13_COMP_LESS_XI (3L<<16)
3787#define BNX2_RPM_RC_CNTL_13_MAP_XI (1L<<18)
3788#define BNX2_RPM_RC_CNTL_13_SBIT_XI (1L<<19)
3789#define BNX2_RPM_RC_CNTL_13_CMDSEL_XI (0x1fL<<20)
3790#define BNX2_RPM_RC_CNTL_13_DISCARD_XI (1L<<25)
3791#define BNX2_RPM_RC_CNTL_13_MASK_XI (1L<<26)
3792#define BNX2_RPM_RC_CNTL_13_P1_XI (1L<<27)
3793#define BNX2_RPM_RC_CNTL_13_P2_XI (1L<<28)
3794#define BNX2_RPM_RC_CNTL_13_P3_XI (1L<<29)
3795#define BNX2_RPM_RC_CNTL_13_NBIT_XI (1L<<30)
2069 3796
2070#define BNX2_RPM_RC_VALUE_MASK_13 0x0000196c 3797#define BNX2_RPM_RC_VALUE_MASK_13 0x0000196c
3798#define BNX2_RPM_RC_VALUE_MASK_13_VALUE (0xffffL<<0)
3799#define BNX2_RPM_RC_VALUE_MASK_13_MASK (0xffffL<<16)
3800
2071#define BNX2_RPM_RC_CNTL_14 0x00001970 3801#define BNX2_RPM_RC_CNTL_14 0x00001970
2072#define BNX2_RPM_RC_CNTL_14_A (0x3ffffL<<0) 3802#define BNX2_RPM_RC_CNTL_14_A (0x3ffffL<<0)
2073#define BNX2_RPM_RC_CNTL_14_B (0xfffL<<19) 3803#define BNX2_RPM_RC_CNTL_14_B (0xfffL<<19)
3804#define BNX2_RPM_RC_CNTL_14_OFFSET_XI (0xffL<<0)
3805#define BNX2_RPM_RC_CNTL_14_CLASS_XI (0x7L<<8)
3806#define BNX2_RPM_RC_CNTL_14_PRIORITY_XI (1L<<11)
3807#define BNX2_RPM_RC_CNTL_14_P4_XI (1L<<12)
3808#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_XI (0x7L<<13)
3809#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_START_XI (0L<<13)
3810#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_IP_XI (1L<<13)
3811#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_TCP_XI (2L<<13)
3812#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_UDP_XI (3L<<13)
3813#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_DATA_XI (4L<<13)
3814#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_TCP_UDP_XI (5L<<13)
3815#define BNX2_RPM_RC_CNTL_14_HDR_TYPE_ICMPV6_XI (6L<<13)
3816#define BNX2_RPM_RC_CNTL_14_COMP_XI (0x3L<<16)
3817#define BNX2_RPM_RC_CNTL_14_COMP_EQUAL_XI (0L<<16)
3818#define BNX2_RPM_RC_CNTL_14_COMP_NEQUAL_XI (1L<<16)
3819#define BNX2_RPM_RC_CNTL_14_COMP_GREATER_XI (2L<<16)
3820#define BNX2_RPM_RC_CNTL_14_COMP_LESS_XI (3L<<16)
3821#define BNX2_RPM_RC_CNTL_14_MAP_XI (1L<<18)
3822#define BNX2_RPM_RC_CNTL_14_SBIT_XI (1L<<19)
3823#define BNX2_RPM_RC_CNTL_14_CMDSEL_XI (0x1fL<<20)
3824#define BNX2_RPM_RC_CNTL_14_DISCARD_XI (1L<<25)
3825#define BNX2_RPM_RC_CNTL_14_MASK_XI (1L<<26)
3826#define BNX2_RPM_RC_CNTL_14_P1_XI (1L<<27)
3827#define BNX2_RPM_RC_CNTL_14_P2_XI (1L<<28)
3828#define BNX2_RPM_RC_CNTL_14_P3_XI (1L<<29)
3829#define BNX2_RPM_RC_CNTL_14_NBIT_XI (1L<<30)
2074 3830
2075#define BNX2_RPM_RC_VALUE_MASK_14 0x00001974 3831#define BNX2_RPM_RC_VALUE_MASK_14 0x00001974
3832#define BNX2_RPM_RC_VALUE_MASK_14_VALUE (0xffffL<<0)
3833#define BNX2_RPM_RC_VALUE_MASK_14_MASK (0xffffL<<16)
3834
2076#define BNX2_RPM_RC_CNTL_15 0x00001978 3835#define BNX2_RPM_RC_CNTL_15 0x00001978
2077#define BNX2_RPM_RC_CNTL_15_A (0x3ffffL<<0) 3836#define BNX2_RPM_RC_CNTL_15_A (0x3ffffL<<0)
2078#define BNX2_RPM_RC_CNTL_15_B (0xfffL<<19) 3837#define BNX2_RPM_RC_CNTL_15_B (0xfffL<<19)
3838#define BNX2_RPM_RC_CNTL_15_OFFSET_XI (0xffL<<0)
3839#define BNX2_RPM_RC_CNTL_15_CLASS_XI (0x7L<<8)
3840#define BNX2_RPM_RC_CNTL_15_PRIORITY_XI (1L<<11)
3841#define BNX2_RPM_RC_CNTL_15_P4_XI (1L<<12)
3842#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_XI (0x7L<<13)
3843#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_START_XI (0L<<13)
3844#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_IP_XI (1L<<13)
3845#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_TCP_XI (2L<<13)
3846#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_UDP_XI (3L<<13)
3847#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_DATA_XI (4L<<13)
3848#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_TCP_UDP_XI (5L<<13)
3849#define BNX2_RPM_RC_CNTL_15_HDR_TYPE_ICMPV6_XI (6L<<13)
3850#define BNX2_RPM_RC_CNTL_15_COMP_XI (0x3L<<16)
3851#define BNX2_RPM_RC_CNTL_15_COMP_EQUAL_XI (0L<<16)
3852#define BNX2_RPM_RC_CNTL_15_COMP_NEQUAL_XI (1L<<16)
3853#define BNX2_RPM_RC_CNTL_15_COMP_GREATER_XI (2L<<16)
3854#define BNX2_RPM_RC_CNTL_15_COMP_LESS_XI (3L<<16)
3855#define BNX2_RPM_RC_CNTL_15_MAP_XI (1L<<18)
3856#define BNX2_RPM_RC_CNTL_15_SBIT_XI (1L<<19)
3857#define BNX2_RPM_RC_CNTL_15_CMDSEL_XI (0x1fL<<20)
3858#define BNX2_RPM_RC_CNTL_15_DISCARD_XI (1L<<25)
3859#define BNX2_RPM_RC_CNTL_15_MASK_XI (1L<<26)
3860#define BNX2_RPM_RC_CNTL_15_P1_XI (1L<<27)
3861#define BNX2_RPM_RC_CNTL_15_P2_XI (1L<<28)
3862#define BNX2_RPM_RC_CNTL_15_P3_XI (1L<<29)
3863#define BNX2_RPM_RC_CNTL_15_NBIT_XI (1L<<30)
2079 3864
2080#define BNX2_RPM_RC_VALUE_MASK_15 0x0000197c 3865#define BNX2_RPM_RC_VALUE_MASK_15 0x0000197c
3866#define BNX2_RPM_RC_VALUE_MASK_15_VALUE (0xffffL<<0)
3867#define BNX2_RPM_RC_VALUE_MASK_15_MASK (0xffffL<<16)
3868
2081#define BNX2_RPM_RC_CONFIG 0x00001980 3869#define BNX2_RPM_RC_CONFIG 0x00001980
2082#define BNX2_RPM_RC_CONFIG_RULE_ENABLE (0xffffL<<0) 3870#define BNX2_RPM_RC_CONFIG_RULE_ENABLE (0xffffL<<0)
3871#define BNX2_RPM_RC_CONFIG_RULE_ENABLE_XI (0xfffffL<<0)
2083#define BNX2_RPM_RC_CONFIG_DEF_CLASS (0x7L<<24) 3872#define BNX2_RPM_RC_CONFIG_DEF_CLASS (0x7L<<24)
3873#define BNX2_RPM_RC_CONFIG_KNUM_OVERWRITE (1L<<31)
2084 3874
2085#define BNX2_RPM_DEBUG0 0x00001984 3875#define BNX2_RPM_DEBUG0 0x00001984
2086#define BNX2_RPM_DEBUG0_FM_BCNT (0xffffL<<0) 3876#define BNX2_RPM_DEBUG0_FM_BCNT (0xffffL<<0)
@@ -2236,6 +4026,16 @@ struct l2_fhdr {
2236#define BNX2_RPM_DEBUG9_INFIFO_OVERRUN_OCCURRED (1L<<29) 4026#define BNX2_RPM_DEBUG9_INFIFO_OVERRUN_OCCURRED (1L<<29)
2237#define BNX2_RPM_DEBUG9_ACPI_MATCH_INT (1L<<30) 4027#define BNX2_RPM_DEBUG9_ACPI_MATCH_INT (1L<<30)
2238#define BNX2_RPM_DEBUG9_ACPI_ENABLE_SYN (1L<<31) 4028#define BNX2_RPM_DEBUG9_ACPI_ENABLE_SYN (1L<<31)
4029#define BNX2_RPM_DEBUG9_BEMEM_R_XI (0x1fL<<0)
4030#define BNX2_RPM_DEBUG9_EO_XI (1L<<5)
4031#define BNX2_RPM_DEBUG9_AEOF_DE_XI (1L<<6)
4032#define BNX2_RPM_DEBUG9_SO_XI (1L<<7)
4033#define BNX2_RPM_DEBUG9_WD64_CT_XI (0x1fL<<8)
4034#define BNX2_RPM_DEBUG9_EOF_VLDBYTE_XI (0x7L<<13)
4035#define BNX2_RPM_DEBUG9_ACPI_RDE_PAT_ID_XI (0xfL<<16)
4036#define BNX2_RPM_DEBUG9_CALCRC_RESULT_XI (0x3ffL<<20)
4037#define BNX2_RPM_DEBUG9_DATA_IN_VL_XI (1L<<30)
4038#define BNX2_RPM_DEBUG9_CALCRC_BUFFER_VLD_XI (1L<<31)
2239 4039
2240#define BNX2_RPM_ACPI_DBG_BUF_W00 0x000019c0 4040#define BNX2_RPM_ACPI_DBG_BUF_W00 0x000019c0
2241#define BNX2_RPM_ACPI_DBG_BUF_W01 0x000019c4 4041#define BNX2_RPM_ACPI_DBG_BUF_W01 0x000019c4
@@ -2253,6 +4053,56 @@ struct l2_fhdr {
2253#define BNX2_RPM_ACPI_DBG_BUF_W31 0x000019f4 4053#define BNX2_RPM_ACPI_DBG_BUF_W31 0x000019f4
2254#define BNX2_RPM_ACPI_DBG_BUF_W32 0x000019f8 4054#define BNX2_RPM_ACPI_DBG_BUF_W32 0x000019f8
2255#define BNX2_RPM_ACPI_DBG_BUF_W33 0x000019fc 4055#define BNX2_RPM_ACPI_DBG_BUF_W33 0x000019fc
4056#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL 0x00001a00
4057#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_BYTE_ADDRESS (0xffffL<<0)
4058#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_DEBUGRD (1L<<28)
4059#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_MODE (1L<<29)
4060#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_INIT (1L<<30)
4061#define BNX2_RPM_ACPI_BYTE_ENABLE_CTRL_WR (1L<<31)
4062
4063#define BNX2_RPM_ACPI_PATTERN_CTRL 0x00001a04
4064#define BNX2_RPM_ACPI_PATTERN_CTRL_PATTERN_ID (0xfL<<0)
4065#define BNX2_RPM_ACPI_PATTERN_CTRL_CRC_SM_CLR (1L<<30)
4066#define BNX2_RPM_ACPI_PATTERN_CTRL_WR (1L<<31)
4067
4068#define BNX2_RPM_ACPI_DATA 0x00001a08
4069#define BNX2_RPM_ACPI_DATA_PATTERN_BE (0xffffffffL<<0)
4070
4071#define BNX2_RPM_ACPI_PATTERN_LEN0 0x00001a0c
4072#define BNX2_RPM_ACPI_PATTERN_LEN0_PATTERN_LEN3 (0xffL<<0)
4073#define BNX2_RPM_ACPI_PATTERN_LEN0_PATTERN_LEN2 (0xffL<<8)
4074#define BNX2_RPM_ACPI_PATTERN_LEN0_PATTERN_LEN1 (0xffL<<16)
4075#define BNX2_RPM_ACPI_PATTERN_LEN0_PATTERN_LEN0 (0xffL<<24)
4076
4077#define BNX2_RPM_ACPI_PATTERN_LEN1 0x00001a10
4078#define BNX2_RPM_ACPI_PATTERN_LEN1_PATTERN_LEN7 (0xffL<<0)
4079#define BNX2_RPM_ACPI_PATTERN_LEN1_PATTERN_LEN6 (0xffL<<8)
4080#define BNX2_RPM_ACPI_PATTERN_LEN1_PATTERN_LEN5 (0xffL<<16)
4081#define BNX2_RPM_ACPI_PATTERN_LEN1_PATTERN_LEN4 (0xffL<<24)
4082
4083#define BNX2_RPM_ACPI_PATTERN_CRC0 0x00001a18
4084#define BNX2_RPM_ACPI_PATTERN_CRC0_PATTERN_CRC0 (0xffffffffL<<0)
4085
4086#define BNX2_RPM_ACPI_PATTERN_CRC1 0x00001a1c
4087#define BNX2_RPM_ACPI_PATTERN_CRC1_PATTERN_CRC1 (0xffffffffL<<0)
4088
4089#define BNX2_RPM_ACPI_PATTERN_CRC2 0x00001a20
4090#define BNX2_RPM_ACPI_PATTERN_CRC2_PATTERN_CRC2 (0xffffffffL<<0)
4091
4092#define BNX2_RPM_ACPI_PATTERN_CRC3 0x00001a24
4093#define BNX2_RPM_ACPI_PATTERN_CRC3_PATTERN_CRC3 (0xffffffffL<<0)
4094
4095#define BNX2_RPM_ACPI_PATTERN_CRC4 0x00001a28
4096#define BNX2_RPM_ACPI_PATTERN_CRC4_PATTERN_CRC4 (0xffffffffL<<0)
4097
4098#define BNX2_RPM_ACPI_PATTERN_CRC5 0x00001a2c
4099#define BNX2_RPM_ACPI_PATTERN_CRC5_PATTERN_CRC5 (0xffffffffL<<0)
4100
4101#define BNX2_RPM_ACPI_PATTERN_CRC6 0x00001a30
4102#define BNX2_RPM_ACPI_PATTERN_CRC6_PATTERN_CRC6 (0xffffffffL<<0)
4103
4104#define BNX2_RPM_ACPI_PATTERN_CRC7 0x00001a34
4105#define BNX2_RPM_ACPI_PATTERN_CRC7_PATTERN_CRC7 (0xffffffffL<<0)
2256 4106
2257 4107
2258/* 4108/*
@@ -2263,15 +4113,20 @@ struct l2_fhdr {
2263#define BNX2_RBUF_COMMAND_ENABLED (1L<<0) 4113#define BNX2_RBUF_COMMAND_ENABLED (1L<<0)
2264#define BNX2_RBUF_COMMAND_FREE_INIT (1L<<1) 4114#define BNX2_RBUF_COMMAND_FREE_INIT (1L<<1)
2265#define BNX2_RBUF_COMMAND_RAM_INIT (1L<<2) 4115#define BNX2_RBUF_COMMAND_RAM_INIT (1L<<2)
4116#define BNX2_RBUF_COMMAND_PKT_OFFSET_OVFL (1L<<3)
2266#define BNX2_RBUF_COMMAND_OVER_FREE (1L<<4) 4117#define BNX2_RBUF_COMMAND_OVER_FREE (1L<<4)
2267#define BNX2_RBUF_COMMAND_ALLOC_REQ (1L<<5) 4118#define BNX2_RBUF_COMMAND_ALLOC_REQ (1L<<5)
4119#define BNX2_RBUF_COMMAND_EN_PRI_CHNGE_TE (1L<<6)
4120#define BNX2_RBUF_COMMAND_CU_ISOLATE_XI (1L<<5)
4121#define BNX2_RBUF_COMMAND_EN_PRI_CHANGE_XI (1L<<6)
4122#define BNX2_RBUF_COMMAND_GRC_ENDIAN_CONV_DIS_XI (1L<<7)
2268 4123
2269#define BNX2_RBUF_STATUS1 0x00200004 4124#define BNX2_RBUF_STATUS1 0x00200004
2270#define BNX2_RBUF_STATUS1_FREE_COUNT (0x3ffL<<0) 4125#define BNX2_RBUF_STATUS1_FREE_COUNT (0x3ffL<<0)
2271 4126
2272#define BNX2_RBUF_STATUS2 0x00200008 4127#define BNX2_RBUF_STATUS2 0x00200008
2273#define BNX2_RBUF_STATUS2_FREE_TAIL (0x3ffL<<0) 4128#define BNX2_RBUF_STATUS2_FREE_TAIL (0x1ffL<<0)
2274#define BNX2_RBUF_STATUS2_FREE_HEAD (0x3ffL<<16) 4129#define BNX2_RBUF_STATUS2_FREE_HEAD (0x1ffL<<16)
2275 4130
2276#define BNX2_RBUF_CONFIG 0x0020000c 4131#define BNX2_RBUF_CONFIG 0x0020000c
2277#define BNX2_RBUF_CONFIG_XOFF_TRIP (0x3ffL<<0) 4132#define BNX2_RBUF_CONFIG_XOFF_TRIP (0x3ffL<<0)
@@ -2279,16 +4134,21 @@ struct l2_fhdr {
2279 4134
2280#define BNX2_RBUF_FW_BUF_ALLOC 0x00200010 4135#define BNX2_RBUF_FW_BUF_ALLOC 0x00200010
2281#define BNX2_RBUF_FW_BUF_ALLOC_VALUE (0x1ffL<<7) 4136#define BNX2_RBUF_FW_BUF_ALLOC_VALUE (0x1ffL<<7)
4137#define BNX2_RBUF_FW_BUF_ALLOC_TYPE (1L<<16)
4138#define BNX2_RBUF_FW_BUF_ALLOC_ALLOC_REQ (1L<<31)
2282 4139
2283#define BNX2_RBUF_FW_BUF_FREE 0x00200014 4140#define BNX2_RBUF_FW_BUF_FREE 0x00200014
2284#define BNX2_RBUF_FW_BUF_FREE_COUNT (0x7fL<<0) 4141#define BNX2_RBUF_FW_BUF_FREE_COUNT (0x7fL<<0)
2285#define BNX2_RBUF_FW_BUF_FREE_TAIL (0x1ffL<<7) 4142#define BNX2_RBUF_FW_BUF_FREE_TAIL (0x1ffL<<7)
2286#define BNX2_RBUF_FW_BUF_FREE_HEAD (0x1ffL<<16) 4143#define BNX2_RBUF_FW_BUF_FREE_HEAD (0x1ffL<<16)
4144#define BNX2_RBUF_FW_BUF_FREE_TYPE (1L<<25)
4145#define BNX2_RBUF_FW_BUF_FREE_FREE_REQ (1L<<31)
2287 4146
2288#define BNX2_RBUF_FW_BUF_SEL 0x00200018 4147#define BNX2_RBUF_FW_BUF_SEL 0x00200018
2289#define BNX2_RBUF_FW_BUF_SEL_COUNT (0x7fL<<0) 4148#define BNX2_RBUF_FW_BUF_SEL_COUNT (0x7fL<<0)
2290#define BNX2_RBUF_FW_BUF_SEL_TAIL (0x1ffL<<7) 4149#define BNX2_RBUF_FW_BUF_SEL_TAIL (0x1ffL<<7)
2291#define BNX2_RBUF_FW_BUF_SEL_HEAD (0x1ffL<<16) 4150#define BNX2_RBUF_FW_BUF_SEL_HEAD (0x1ffL<<16)
4151#define BNX2_RBUF_FW_BUF_SEL_SEL_REQ (1L<<31)
2292 4152
2293#define BNX2_RBUF_CONFIG2 0x0020001c 4153#define BNX2_RBUF_CONFIG2 0x0020001c
2294#define BNX2_RBUF_CONFIG2_MAC_DROP_TRIP (0x3ffL<<0) 4154#define BNX2_RBUF_CONFIG2_MAC_DROP_TRIP (0x3ffL<<0)
@@ -2376,6 +4236,8 @@ struct l2_fhdr {
2376#define BNX2_RV2P_INSTR_HIGH_HIGH (0x1fL<<0) 4236#define BNX2_RV2P_INSTR_HIGH_HIGH (0x1fL<<0)
2377 4237
2378#define BNX2_RV2P_INSTR_LOW 0x00002834 4238#define BNX2_RV2P_INSTR_LOW 0x00002834
4239#define BNX2_RV2P_INSTR_LOW_LOW (0xffffffffL<<0)
4240
2379#define BNX2_RV2P_PROC1_ADDR_CMD 0x00002838 4241#define BNX2_RV2P_PROC1_ADDR_CMD 0x00002838
2380#define BNX2_RV2P_PROC1_ADDR_CMD_ADD (0x3ffL<<0) 4242#define BNX2_RV2P_PROC1_ADDR_CMD_ADD (0x3ffL<<0)
2381#define BNX2_RV2P_PROC1_ADDR_CMD_RDWR (1L<<31) 4243#define BNX2_RV2P_PROC1_ADDR_CMD_RDWR (1L<<31)
@@ -2395,7 +4257,29 @@ struct l2_fhdr {
2395#define BNX2_RV2P_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27) 4257#define BNX2_RV2P_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
2396#define BNX2_RV2P_DEBUG_VECT_PEEK_2_SEL (0xfL<<28) 4258#define BNX2_RV2P_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
2397 4259
2398#define BNX2_RV2P_PFTQ_DATA 0x00002b40 4260#define BNX2_RV2P_MPFE_PFE_CTL 0x00002afc
4261#define BNX2_RV2P_MPFE_PFE_CTL_INC_USAGE_CNT (1L<<0)
4262#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE (0xfL<<4)
4263#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_0 (0L<<4)
4264#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_1 (1L<<4)
4265#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_2 (2L<<4)
4266#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_3 (3L<<4)
4267#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_4 (4L<<4)
4268#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_5 (5L<<4)
4269#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_6 (6L<<4)
4270#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_7 (7L<<4)
4271#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_8 (8L<<4)
4272#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_9 (9L<<4)
4273#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_10 (10L<<4)
4274#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_11 (11L<<4)
4275#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_12 (12L<<4)
4276#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_13 (13L<<4)
4277#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_14 (14L<<4)
4278#define BNX2_RV2P_MPFE_PFE_CTL_PFE_SIZE_15 (15L<<4)
4279#define BNX2_RV2P_MPFE_PFE_CTL_PFE_COUNT (0xfL<<12)
4280#define BNX2_RV2P_MPFE_PFE_CTL_OFFSET (0x1ffL<<16)
4281
4282#define BNX2_RV2P_RV2PPQ 0x00002b40
2399#define BNX2_RV2P_PFTQ_CMD 0x00002b78 4283#define BNX2_RV2P_PFTQ_CMD 0x00002b78
2400#define BNX2_RV2P_PFTQ_CMD_OFFSET (0x3ffL<<0) 4284#define BNX2_RV2P_PFTQ_CMD_OFFSET (0x3ffL<<0)
2401#define BNX2_RV2P_PFTQ_CMD_WR_TOP (1L<<10) 4285#define BNX2_RV2P_PFTQ_CMD_WR_TOP (1L<<10)
@@ -2416,7 +4300,7 @@ struct l2_fhdr {
2416#define BNX2_RV2P_PFTQ_CTL_MAX_DEPTH (0x3ffL<<12) 4300#define BNX2_RV2P_PFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2417#define BNX2_RV2P_PFTQ_CTL_CUR_DEPTH (0x3ffL<<22) 4301#define BNX2_RV2P_PFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2418 4302
2419#define BNX2_RV2P_TFTQ_DATA 0x00002b80 4303#define BNX2_RV2P_RV2PTQ 0x00002b80
2420#define BNX2_RV2P_TFTQ_CMD 0x00002bb8 4304#define BNX2_RV2P_TFTQ_CMD 0x00002bb8
2421#define BNX2_RV2P_TFTQ_CMD_OFFSET (0x3ffL<<0) 4305#define BNX2_RV2P_TFTQ_CMD_OFFSET (0x3ffL<<0)
2422#define BNX2_RV2P_TFTQ_CMD_WR_TOP (1L<<10) 4306#define BNX2_RV2P_TFTQ_CMD_WR_TOP (1L<<10)
@@ -2437,7 +4321,7 @@ struct l2_fhdr {
2437#define BNX2_RV2P_TFTQ_CTL_MAX_DEPTH (0x3ffL<<12) 4321#define BNX2_RV2P_TFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
2438#define BNX2_RV2P_TFTQ_CTL_CUR_DEPTH (0x3ffL<<22) 4322#define BNX2_RV2P_TFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
2439 4323
2440#define BNX2_RV2P_MFTQ_DATA 0x00002bc0 4324#define BNX2_RV2P_RV2PMQ 0x00002bc0
2441#define BNX2_RV2P_MFTQ_CMD 0x00002bf8 4325#define BNX2_RV2P_MFTQ_CMD 0x00002bf8
2442#define BNX2_RV2P_MFTQ_CMD_OFFSET (0x3ffL<<0) 4326#define BNX2_RV2P_MFTQ_CMD_OFFSET (0x3ffL<<0)
2443#define BNX2_RV2P_MFTQ_CMD_WR_TOP (1L<<10) 4327#define BNX2_RV2P_MFTQ_CMD_WR_TOP (1L<<10)
@@ -2466,18 +4350,26 @@ struct l2_fhdr {
2466 */ 4350 */
2467#define BNX2_MQ_COMMAND 0x00003c00 4351#define BNX2_MQ_COMMAND 0x00003c00
2468#define BNX2_MQ_COMMAND_ENABLED (1L<<0) 4352#define BNX2_MQ_COMMAND_ENABLED (1L<<0)
4353#define BNX2_MQ_COMMAND_INIT (1L<<1)
2469#define BNX2_MQ_COMMAND_OVERFLOW (1L<<4) 4354#define BNX2_MQ_COMMAND_OVERFLOW (1L<<4)
2470#define BNX2_MQ_COMMAND_WR_ERROR (1L<<5) 4355#define BNX2_MQ_COMMAND_WR_ERROR (1L<<5)
2471#define BNX2_MQ_COMMAND_RD_ERROR (1L<<6) 4356#define BNX2_MQ_COMMAND_RD_ERROR (1L<<6)
4357#define BNX2_MQ_COMMAND_IDB_CFG_ERROR (1L<<7)
4358#define BNX2_MQ_COMMAND_IDB_OVERFLOW (1L<<10)
4359#define BNX2_MQ_COMMAND_NO_BIN_ERROR (1L<<11)
4360#define BNX2_MQ_COMMAND_NO_MAP_ERROR (1L<<12)
2472 4361
2473#define BNX2_MQ_STATUS 0x00003c04 4362#define BNX2_MQ_STATUS 0x00003c04
2474#define BNX2_MQ_STATUS_CTX_ACCESS_STAT (1L<<16) 4363#define BNX2_MQ_STATUS_CTX_ACCESS_STAT (1L<<16)
2475#define BNX2_MQ_STATUS_CTX_ACCESS64_STAT (1L<<17) 4364#define BNX2_MQ_STATUS_CTX_ACCESS64_STAT (1L<<17)
2476#define BNX2_MQ_STATUS_PCI_STALL_STAT (1L<<18) 4365#define BNX2_MQ_STATUS_PCI_STALL_STAT (1L<<18)
4366#define BNX2_MQ_STATUS_IDB_OFLOW_STAT (1L<<19)
2477 4367
2478#define BNX2_MQ_CONFIG 0x00003c08 4368#define BNX2_MQ_CONFIG 0x00003c08
2479#define BNX2_MQ_CONFIG_TX_HIGH_PRI (1L<<0) 4369#define BNX2_MQ_CONFIG_TX_HIGH_PRI (1L<<0)
2480#define BNX2_MQ_CONFIG_HALT_DIS (1L<<1) 4370#define BNX2_MQ_CONFIG_HALT_DIS (1L<<1)
4371#define BNX2_MQ_CONFIG_BIN_MQ_MODE (1L<<2)
4372#define BNX2_MQ_CONFIG_DIS_IDB_DROP (1L<<3)
2481#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE (0x7L<<4) 4373#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE (0x7L<<4)
2482#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256 (0L<<4) 4374#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_256 (0L<<4)
2483#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_512 (1L<<4) 4375#define BNX2_MQ_CONFIG_KNL_BYP_BLK_SIZE_512 (1L<<4)
@@ -2533,6 +4425,7 @@ struct l2_fhdr {
2533 4425
2534#define BNX2_MQ_MEM_WR_DATA2 0x00003c80 4426#define BNX2_MQ_MEM_WR_DATA2 0x00003c80
2535#define BNX2_MQ_MEM_WR_DATA2_VALUE (0x3fffffffL<<0) 4427#define BNX2_MQ_MEM_WR_DATA2_VALUE (0x3fffffffL<<0)
4428#define BNX2_MQ_MEM_WR_DATA2_VALUE_XI (0x7fffffffL<<0)
2536 4429
2537#define BNX2_MQ_MEM_RD_ADDR 0x00003c84 4430#define BNX2_MQ_MEM_RD_ADDR 0x00003c84
2538#define BNX2_MQ_MEM_RD_ADDR_VALUE (0x3fL<<0) 4431#define BNX2_MQ_MEM_RD_ADDR_VALUE (0x3fL<<0)
@@ -2545,6 +4438,16 @@ struct l2_fhdr {
2545 4438
2546#define BNX2_MQ_MEM_RD_DATA2 0x00003c90 4439#define BNX2_MQ_MEM_RD_DATA2 0x00003c90
2547#define BNX2_MQ_MEM_RD_DATA2_VALUE (0x3fffffffL<<0) 4440#define BNX2_MQ_MEM_RD_DATA2_VALUE (0x3fffffffL<<0)
4441#define BNX2_MQ_MEM_RD_DATA2_VALUE_XI (0x7fffffffL<<0)
4442
4443
4444/*
4445 * tsch_reg definition
4446 * offset: 0x4c00
4447 */
4448#define BNX2_TSCH_TSS_CFG 0x00004c1c
4449#define BNX2_TSCH_TSS_CFG_TSS_START_CID (0x7ffL<<8)
4450#define BNX2_TSCH_TSS_CFG_NUM_OF_TSS_CON (0xfL<<24)
2548 4451
2549 4452
2550 4453
@@ -2594,7 +4497,11 @@ struct l2_fhdr {
2594#define BNX2_TBDR_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27) 4497#define BNX2_TBDR_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
2595#define BNX2_TBDR_DEBUG_VECT_PEEK_2_SEL (0xfL<<28) 4498#define BNX2_TBDR_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
2596 4499
2597#define BNX2_TBDR_FTQ_DATA 0x000053c0 4500#define BNX2_TBDR_CKSUM_ERROR_STATUS 0x00005010
4501#define BNX2_TBDR_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
4502#define BNX2_TBDR_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
4503
4504#define BNX2_TBDR_TBDRQ 0x000053c0
2598#define BNX2_TBDR_FTQ_CMD 0x000053f8 4505#define BNX2_TBDR_FTQ_CMD 0x000053f8
2599#define BNX2_TBDR_FTQ_CMD_OFFSET (0x3ffL<<0) 4506#define BNX2_TBDR_FTQ_CMD_OFFSET (0x3ffL<<0)
2600#define BNX2_TBDR_FTQ_CMD_WR_TOP (1L<<10) 4507#define BNX2_TBDR_FTQ_CMD_WR_TOP (1L<<10)
@@ -2624,7 +4531,15 @@ struct l2_fhdr {
2624#define BNX2_TDMA_COMMAND 0x00005c00 4531#define BNX2_TDMA_COMMAND 0x00005c00
2625#define BNX2_TDMA_COMMAND_ENABLED (1L<<0) 4532#define BNX2_TDMA_COMMAND_ENABLED (1L<<0)
2626#define BNX2_TDMA_COMMAND_MASTER_ABORT (1L<<4) 4533#define BNX2_TDMA_COMMAND_MASTER_ABORT (1L<<4)
4534#define BNX2_TDMA_COMMAND_CS16_ERR (1L<<5)
2627#define BNX2_TDMA_COMMAND_BAD_L2_LENGTH_ABORT (1L<<7) 4535#define BNX2_TDMA_COMMAND_BAD_L2_LENGTH_ABORT (1L<<7)
4536#define BNX2_TDMA_COMMAND_MASK_CS1 (1L<<20)
4537#define BNX2_TDMA_COMMAND_MASK_CS2 (1L<<21)
4538#define BNX2_TDMA_COMMAND_MASK_CS3 (1L<<22)
4539#define BNX2_TDMA_COMMAND_MASK_CS4 (1L<<23)
4540#define BNX2_TDMA_COMMAND_FORCE_ILOCK_CKERR (1L<<24)
4541#define BNX2_TDMA_COMMAND_OFIFO_CLR (1L<<30)
4542#define BNX2_TDMA_COMMAND_IFIFO_CLR (1L<<31)
2628 4543
2629#define BNX2_TDMA_STATUS 0x00005c04 4544#define BNX2_TDMA_STATUS 0x00005c04
2630#define BNX2_TDMA_STATUS_DMA_WAIT (1L<<0) 4545#define BNX2_TDMA_STATUS_DMA_WAIT (1L<<0)
@@ -2633,10 +4548,18 @@ struct l2_fhdr {
2633#define BNX2_TDMA_STATUS_LOCK_WAIT (1L<<3) 4548#define BNX2_TDMA_STATUS_LOCK_WAIT (1L<<3)
2634#define BNX2_TDMA_STATUS_FTQ_ENTRY_CNT (1L<<16) 4549#define BNX2_TDMA_STATUS_FTQ_ENTRY_CNT (1L<<16)
2635#define BNX2_TDMA_STATUS_BURST_CNT (1L<<17) 4550#define BNX2_TDMA_STATUS_BURST_CNT (1L<<17)
4551#define BNX2_TDMA_STATUS_MAX_IFIFO_DEPTH (0x3fL<<20)
4552#define BNX2_TDMA_STATUS_OFIFO_OVERFLOW (1L<<30)
4553#define BNX2_TDMA_STATUS_IFIFO_OVERFLOW (1L<<31)
2636 4554
2637#define BNX2_TDMA_CONFIG 0x00005c08 4555#define BNX2_TDMA_CONFIG 0x00005c08
2638#define BNX2_TDMA_CONFIG_ONE_DMA (1L<<0) 4556#define BNX2_TDMA_CONFIG_ONE_DMA (1L<<0)
2639#define BNX2_TDMA_CONFIG_ONE_RECORD (1L<<1) 4557#define BNX2_TDMA_CONFIG_ONE_RECORD (1L<<1)
4558#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN (0x3L<<2)
4559#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN_0 (0L<<2)
4560#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN_1 (1L<<2)
4561#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN_2 (2L<<2)
4562#define BNX2_TDMA_CONFIG_NUM_DMA_CHAN_3 (3L<<2)
2640#define BNX2_TDMA_CONFIG_LIMIT_SZ (0xfL<<4) 4563#define BNX2_TDMA_CONFIG_LIMIT_SZ (0xfL<<4)
2641#define BNX2_TDMA_CONFIG_LIMIT_SZ_64 (0L<<4) 4564#define BNX2_TDMA_CONFIG_LIMIT_SZ_64 (0L<<4)
2642#define BNX2_TDMA_CONFIG_LIMIT_SZ_128 (0x4L<<4) 4565#define BNX2_TDMA_CONFIG_LIMIT_SZ_128 (0x4L<<4)
@@ -2649,7 +4572,35 @@ struct l2_fhdr {
2649#define BNX2_TDMA_CONFIG_LINE_SZ_512 (8L<<8) 4572#define BNX2_TDMA_CONFIG_LINE_SZ_512 (8L<<8)
2650#define BNX2_TDMA_CONFIG_ALIGN_ENA (1L<<15) 4573#define BNX2_TDMA_CONFIG_ALIGN_ENA (1L<<15)
2651#define BNX2_TDMA_CONFIG_CHK_L2_BD (1L<<16) 4574#define BNX2_TDMA_CONFIG_CHK_L2_BD (1L<<16)
4575#define BNX2_TDMA_CONFIG_CMPL_ENTRY (1L<<17)
4576#define BNX2_TDMA_CONFIG_OFIFO_CMP (1L<<19)
4577#define BNX2_TDMA_CONFIG_OFIFO_CMP_3 (0L<<19)
4578#define BNX2_TDMA_CONFIG_OFIFO_CMP_2 (1L<<19)
2652#define BNX2_TDMA_CONFIG_FIFO_CMP (0xfL<<20) 4579#define BNX2_TDMA_CONFIG_FIFO_CMP (0xfL<<20)
4580#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_XI (0x7L<<20)
4581#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_0_XI (0L<<20)
4582#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_4_XI (1L<<20)
4583#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_8_XI (2L<<20)
4584#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_16_XI (3L<<20)
4585#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_32_XI (4L<<20)
4586#define BNX2_TDMA_CONFIG_IFIFO_DEPTH_64_XI (5L<<20)
4587#define BNX2_TDMA_CONFIG_FIFO_CMP_EN_XI (1L<<23)
4588#define BNX2_TDMA_CONFIG_BYTES_OST_XI (0x7L<<24)
4589#define BNX2_TDMA_CONFIG_BYTES_OST_512_XI (0L<<24)
4590#define BNX2_TDMA_CONFIG_BYTES_OST_1024_XI (1L<<24)
4591#define BNX2_TDMA_CONFIG_BYTES_OST_2048_XI (2L<<24)
4592#define BNX2_TDMA_CONFIG_BYTES_OST_4096_XI (3L<<24)
4593#define BNX2_TDMA_CONFIG_BYTES_OST_8192_XI (4L<<24)
4594#define BNX2_TDMA_CONFIG_BYTES_OST_16384_XI (5L<<24)
4595#define BNX2_TDMA_CONFIG_HC_BYPASS_XI (1L<<27)
4596#define BNX2_TDMA_CONFIG_LCL_MRRS_XI (0x7L<<28)
4597#define BNX2_TDMA_CONFIG_LCL_MRRS_128_XI (0L<<28)
4598#define BNX2_TDMA_CONFIG_LCL_MRRS_256_XI (1L<<28)
4599#define BNX2_TDMA_CONFIG_LCL_MRRS_512_XI (2L<<28)
4600#define BNX2_TDMA_CONFIG_LCL_MRRS_1024_XI (3L<<28)
4601#define BNX2_TDMA_CONFIG_LCL_MRRS_2048_XI (4L<<28)
4602#define BNX2_TDMA_CONFIG_LCL_MRRS_4096_XI (5L<<28)
4603#define BNX2_TDMA_CONFIG_LCL_MRRS_EN_XI (1L<<31)
2653 4604
2654#define BNX2_TDMA_PAYLOAD_PROD 0x00005c0c 4605#define BNX2_TDMA_PAYLOAD_PROD 0x00005c0c
2655#define BNX2_TDMA_PAYLOAD_PROD_VALUE (0x1fffL<<3) 4606#define BNX2_TDMA_PAYLOAD_PROD_VALUE (0x1fffL<<3)
@@ -2685,7 +4636,22 @@ struct l2_fhdr {
2685#define BNX2_TDMA_DR_INTF_STATUS_NXT_PNTR (0xfL<<12) 4636#define BNX2_TDMA_DR_INTF_STATUS_NXT_PNTR (0xfL<<12)
2686#define BNX2_TDMA_DR_INTF_STATUS_BYTE_COUNT (0x7L<<16) 4637#define BNX2_TDMA_DR_INTF_STATUS_BYTE_COUNT (0x7L<<16)
2687 4638
2688#define BNX2_TDMA_FTQ_DATA 0x00005fc0 4639#define BNX2_TDMA_PUSH_FSM 0x00005c90
4640#define BNX2_TDMA_BD_IF_DEBUG 0x00005c94
4641#define BNX2_TDMA_DMAD_IF_DEBUG 0x00005c98
4642#define BNX2_TDMA_CTX_IF_DEBUG 0x00005c9c
4643#define BNX2_TDMA_TPBUF_IF_DEBUG 0x00005ca0
4644#define BNX2_TDMA_DR_IF_DEBUG 0x00005ca4
4645#define BNX2_TDMA_TPATQ_IF_DEBUG 0x00005ca8
4646#define BNX2_TDMA_TDMA_ILOCK_CKSUM 0x00005cac
4647#define BNX2_TDMA_TDMA_ILOCK_CKSUM_CALCULATED (0xffffL<<0)
4648#define BNX2_TDMA_TDMA_ILOCK_CKSUM_EXPECTED (0xffffL<<16)
4649
4650#define BNX2_TDMA_TDMA_PCIE_CKSUM 0x00005cb0
4651#define BNX2_TDMA_TDMA_PCIE_CKSUM_CALCULATED (0xffffL<<0)
4652#define BNX2_TDMA_TDMA_PCIE_CKSUM_EXPECTED (0xffffL<<16)
4653
4654#define BNX2_TDMA_TDMAQ 0x00005fc0
2689#define BNX2_TDMA_FTQ_CMD 0x00005ff8 4655#define BNX2_TDMA_FTQ_CMD 0x00005ff8
2690#define BNX2_TDMA_FTQ_CMD_OFFSET (0x3ffL<<0) 4656#define BNX2_TDMA_FTQ_CMD_OFFSET (0x3ffL<<0)
2691#define BNX2_TDMA_FTQ_CMD_WR_TOP (1L<<10) 4657#define BNX2_TDMA_FTQ_CMD_WR_TOP (1L<<10)
@@ -2724,6 +4690,8 @@ struct l2_fhdr {
2724#define BNX2_HC_COMMAND_FORCE_INT_LOW (2L<<19) 4690#define BNX2_HC_COMMAND_FORCE_INT_LOW (2L<<19)
2725#define BNX2_HC_COMMAND_FORCE_INT_FREE (3L<<19) 4691#define BNX2_HC_COMMAND_FORCE_INT_FREE (3L<<19)
2726#define BNX2_HC_COMMAND_CLR_STAT_NOW (1L<<21) 4692#define BNX2_HC_COMMAND_CLR_STAT_NOW (1L<<21)
4693#define BNX2_HC_COMMAND_MAIN_PWR_INT (1L<<22)
4694#define BNX2_HC_COMMAND_COAL_ON_NEXT_EVENT (1L<<27)
2727 4695
2728#define BNX2_HC_STATUS 0x00006804 4696#define BNX2_HC_STATUS 0x00006804
2729#define BNX2_HC_STATUS_MASTER_ABORT (1L<<0) 4697#define BNX2_HC_STATUS_MASTER_ABORT (1L<<0)
@@ -2746,6 +4714,23 @@ struct l2_fhdr {
2746#define BNX2_HC_CONFIG_STATISTIC_PRIORITY (1L<<5) 4714#define BNX2_HC_CONFIG_STATISTIC_PRIORITY (1L<<5)
2747#define BNX2_HC_CONFIG_STATUS_PRIORITY (1L<<6) 4715#define BNX2_HC_CONFIG_STATUS_PRIORITY (1L<<6)
2748#define BNX2_HC_CONFIG_STAT_MEM_ADDR (0xffL<<8) 4716#define BNX2_HC_CONFIG_STAT_MEM_ADDR (0xffL<<8)
4717#define BNX2_HC_CONFIG_PER_MODE (1L<<16)
4718#define BNX2_HC_CONFIG_ONE_SHOT (1L<<17)
4719#define BNX2_HC_CONFIG_USE_INT_PARAM (1L<<18)
4720#define BNX2_HC_CONFIG_SET_MASK_AT_RD (1L<<19)
4721#define BNX2_HC_CONFIG_PER_COLLECT_LIMIT (0xfL<<20)
4722#define BNX2_HC_CONFIG_SB_ADDR_INC (0x7L<<24)
4723#define BNX2_HC_CONFIG_SB_ADDR_INC_64B (0L<<24)
4724#define BNX2_HC_CONFIG_SB_ADDR_INC_128B (1L<<24)
4725#define BNX2_HC_CONFIG_SB_ADDR_INC_256B (2L<<24)
4726#define BNX2_HC_CONFIG_SB_ADDR_INC_512B (3L<<24)
4727#define BNX2_HC_CONFIG_SB_ADDR_INC_1024B (4L<<24)
4728#define BNX2_HC_CONFIG_SB_ADDR_INC_2048B (5L<<24)
4729#define BNX2_HC_CONFIG_SB_ADDR_INC_4096B (6L<<24)
4730#define BNX2_HC_CONFIG_SB_ADDR_INC_8192B (7L<<24)
4731#define BNX2_HC_CONFIG_GEN_STAT_AVG_INTR (1L<<29)
4732#define BNX2_HC_CONFIG_UNMASK_ALL (1L<<30)
4733#define BNX2_HC_CONFIG_TX_SEL (1L<<31)
2749 4734
2750#define BNX2_HC_ATTN_BITS_ENABLE 0x0000680c 4735#define BNX2_HC_ATTN_BITS_ENABLE 0x0000680c
2751#define BNX2_HC_STATUS_ADDR_L 0x00006810 4736#define BNX2_HC_STATUS_ADDR_L 0x00006810
@@ -2782,6 +4767,7 @@ struct l2_fhdr {
2782 4767
2783#define BNX2_HC_PERIODIC_TICKS 0x0000683c 4768#define BNX2_HC_PERIODIC_TICKS 0x0000683c
2784#define BNX2_HC_PERIODIC_TICKS_HC_PERIODIC_TICKS (0xffffL<<0) 4769#define BNX2_HC_PERIODIC_TICKS_HC_PERIODIC_TICKS (0xffffL<<0)
4770#define BNX2_HC_PERIODIC_TICKS_HC_INT_PERIODIC_TICKS (0xffffL<<16)
2785 4771
2786#define BNX2_HC_STAT_COLLECT_TICKS 0x00006840 4772#define BNX2_HC_STAT_COLLECT_TICKS 0x00006840
2787#define BNX2_HC_STAT_COLLECT_TICKS_HC_STAT_COLL_TICKS (0xffL<<4) 4773#define BNX2_HC_STAT_COLLECT_TICKS_HC_STAT_COLL_TICKS (0xffL<<4)
@@ -2789,6 +4775,10 @@ struct l2_fhdr {
2789#define BNX2_HC_STATS_TICKS 0x00006844 4775#define BNX2_HC_STATS_TICKS 0x00006844
2790#define BNX2_HC_STATS_TICKS_HC_STAT_TICKS (0xffffL<<8) 4776#define BNX2_HC_STATS_TICKS_HC_STAT_TICKS (0xffffL<<8)
2791 4777
4778#define BNX2_HC_STATS_INTERRUPT_STATUS 0x00006848
4779#define BNX2_HC_STATS_INTERRUPT_STATUS_SB_STATUS (0x1ffL<<0)
4780#define BNX2_HC_STATS_INTERRUPT_STATUS_INT_STATUS (0x1ffL<<16)
4781
2792#define BNX2_HC_STAT_MEM_DATA 0x0000684c 4782#define BNX2_HC_STAT_MEM_DATA 0x0000684c
2793#define BNX2_HC_STAT_GEN_SEL_0 0x00006850 4783#define BNX2_HC_STAT_GEN_SEL_0 0x00006850
2794#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0 (0x7fL<<0) 4784#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0 (0x7fL<<0)
@@ -2917,24 +4907,108 @@ struct l2_fhdr {
2917#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_1 (0x7fL<<8) 4907#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_1 (0x7fL<<8)
2918#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_2 (0x7fL<<16) 4908#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_2 (0x7fL<<16)
2919#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_3 (0x7fL<<24) 4909#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_3 (0x7fL<<24)
4910#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_XI (0xffL<<0)
4911#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UMP_RX_FRAME_DROP_XI (52L<<0)
4912#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S0_XI (57L<<0)
4913#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S1_XI (58L<<0)
4914#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S2_XI (85L<<0)
4915#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S3_XI (86L<<0)
4916#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S4_XI (87L<<0)
4917#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S5_XI (88L<<0)
4918#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S6_XI (89L<<0)
4919#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S7_XI (90L<<0)
4920#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S8_XI (91L<<0)
4921#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S9_XI (92L<<0)
4922#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_UNUSED_S10_XI (93L<<0)
4923#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_MQ_IDB_OFLOW_XI (94L<<0)
4924#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_BLK_RD_CNT_XI (123L<<0)
4925#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_BLK_WR_CNT_XI (124L<<0)
4926#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_HITS_XI (125L<<0)
4927#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_CTX_MISSES_XI (126L<<0)
4928#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC1_XI (128L<<0)
4929#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC1_XI (129L<<0)
4930#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC1_XI (130L<<0)
4931#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC1_XI (131L<<0)
4932#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC1_XI (132L<<0)
4933#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC1_XI (133L<<0)
4934#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC2_XI (134L<<0)
4935#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC2_XI (135L<<0)
4936#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC2_XI (136L<<0)
4937#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC2_XI (137L<<0)
4938#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC2_XI (138L<<0)
4939#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC2_XI (139L<<0)
4940#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC3_XI (140L<<0)
4941#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC3_XI (141L<<0)
4942#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC3_XI (142L<<0)
4943#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC3_XI (143L<<0)
4944#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC3_XI (144L<<0)
4945#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC3_XI (145L<<0)
4946#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC4_XI (146L<<0)
4947#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC4_XI (147L<<0)
4948#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC4_XI (148L<<0)
4949#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC4_XI (149L<<0)
4950#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC4_XI (150L<<0)
4951#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC4_XI (151L<<0)
4952#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC5_XI (152L<<0)
4953#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC5_XI (153L<<0)
4954#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC5_XI (154L<<0)
4955#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC5_XI (155L<<0)
4956#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC5_XI (156L<<0)
4957#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC5_XI (157L<<0)
4958#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC6_XI (158L<<0)
4959#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC6_XI (159L<<0)
4960#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC6_XI (160L<<0)
4961#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC6_XI (161L<<0)
4962#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC6_XI (162L<<0)
4963#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC6_XI (163L<<0)
4964#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC7_XI (164L<<0)
4965#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC7_XI (165L<<0)
4966#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC7_XI (166L<<0)
4967#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC7_XI (167L<<0)
4968#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC7_XI (168L<<0)
4969#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC7_XI (169L<<0)
4970#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_STATUS_BLOCKS_VEC8_XI (170L<<0)
4971#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_GEN_VEC8_XI (171L<<0)
4972#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_NUM_INT_MBOX_WR_VEC8_XI (172L<<0)
4973#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_HW_INTACK_VEC8_XI (173L<<0)
4974#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_TO_SW_INTACK_VEC8_XI (174L<<0)
4975#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_HC_CORE_CLKS_DURING_SW_INTACK_VEC8_XI (175L<<0)
4976#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PCS_CMD_CNT_XI (176L<<0)
4977#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PCS_SLOT_CNT_XI (177L<<0)
4978#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_0_RV2PCSQ_VALID_CNT_XI (178L<<0)
4979#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_1_XI (0xffL<<8)
4980#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_2_XI (0xffL<<16)
4981#define BNX2_HC_STAT_GEN_SEL_0_GEN_SEL_3_XI (0xffL<<24)
2920 4982
2921#define BNX2_HC_STAT_GEN_SEL_1 0x00006854 4983#define BNX2_HC_STAT_GEN_SEL_1 0x00006854
2922#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_4 (0x7fL<<0) 4984#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_4 (0x7fL<<0)
2923#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_5 (0x7fL<<8) 4985#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_5 (0x7fL<<8)
2924#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_6 (0x7fL<<16) 4986#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_6 (0x7fL<<16)
2925#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_7 (0x7fL<<24) 4987#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_7 (0x7fL<<24)
4988#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_4_XI (0xffL<<0)
4989#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_5_XI (0xffL<<8)
4990#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_6_XI (0xffL<<16)
4991#define BNX2_HC_STAT_GEN_SEL_1_GEN_SEL_7_XI (0xffL<<24)
2926 4992
2927#define BNX2_HC_STAT_GEN_SEL_2 0x00006858 4993#define BNX2_HC_STAT_GEN_SEL_2 0x00006858
2928#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_8 (0x7fL<<0) 4994#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_8 (0x7fL<<0)
2929#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_9 (0x7fL<<8) 4995#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_9 (0x7fL<<8)
2930#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_10 (0x7fL<<16) 4996#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_10 (0x7fL<<16)
2931#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_11 (0x7fL<<24) 4997#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_11 (0x7fL<<24)
4998#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_8_XI (0xffL<<0)
4999#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_9_XI (0xffL<<8)
5000#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_10_XI (0xffL<<16)
5001#define BNX2_HC_STAT_GEN_SEL_2_GEN_SEL_11_XI (0xffL<<24)
2932 5002
2933#define BNX2_HC_STAT_GEN_SEL_3 0x0000685c 5003#define BNX2_HC_STAT_GEN_SEL_3 0x0000685c
2934#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_12 (0x7fL<<0) 5004#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_12 (0x7fL<<0)
2935#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_13 (0x7fL<<8) 5005#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_13 (0x7fL<<8)
2936#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_14 (0x7fL<<16) 5006#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_14 (0x7fL<<16)
2937#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_15 (0x7fL<<24) 5007#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_15 (0x7fL<<24)
5008#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_12_XI (0xffL<<0)
5009#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_13_XI (0xffL<<8)
5010#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_14_XI (0xffL<<16)
5011#define BNX2_HC_STAT_GEN_SEL_3_GEN_SEL_15_XI (0xffL<<24)
2938 5012
2939#define BNX2_HC_STAT_GEN_STAT0 0x00006888 5013#define BNX2_HC_STAT_GEN_STAT0 0x00006888
2940#define BNX2_HC_STAT_GEN_STAT1 0x0000688c 5014#define BNX2_HC_STAT_GEN_STAT1 0x0000688c
@@ -2968,6 +5042,7 @@ struct l2_fhdr {
2968#define BNX2_HC_STAT_GEN_STAT_AC13 0x000068fc 5042#define BNX2_HC_STAT_GEN_STAT_AC13 0x000068fc
2969#define BNX2_HC_STAT_GEN_STAT_AC14 0x00006900 5043#define BNX2_HC_STAT_GEN_STAT_AC14 0x00006900
2970#define BNX2_HC_STAT_GEN_STAT_AC15 0x00006904 5044#define BNX2_HC_STAT_GEN_STAT_AC15 0x00006904
5045#define BNX2_HC_STAT_GEN_STAT_AC 0x000068c8
2971#define BNX2_HC_VIS 0x00006908 5046#define BNX2_HC_VIS 0x00006908
2972#define BNX2_HC_VIS_STAT_BUILD_STATE (0xfL<<0) 5047#define BNX2_HC_VIS_STAT_BUILD_STATE (0xfL<<0)
2973#define BNX2_HC_VIS_STAT_BUILD_STATE_IDLE (0L<<0) 5048#define BNX2_HC_VIS_STAT_BUILD_STATE_IDLE (0L<<0)
@@ -3038,6 +5113,349 @@ struct l2_fhdr {
3038#define BNX2_HC_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27) 5113#define BNX2_HC_DEBUG_VECT_PEEK_2_PEEK_EN (1L<<27)
3039#define BNX2_HC_DEBUG_VECT_PEEK_2_SEL (0xfL<<28) 5114#define BNX2_HC_DEBUG_VECT_PEEK_2_SEL (0xfL<<28)
3040 5115
5116#define BNX2_HC_COALESCE_NOW 0x00006914
5117#define BNX2_HC_COALESCE_NOW_COAL_NOW (0x1ffL<<1)
5118#define BNX2_HC_COALESCE_NOW_COAL_NOW_WO_INT (0x1ffL<<11)
5119#define BNX2_HC_COALESCE_NOW_COAL_ON_NXT_EVENT (0x1ffL<<21)
5120
5121#define BNX2_HC_MSIX_BIT_VECTOR 0x00006918
5122#define BNX2_HC_MSIX_BIT_VECTOR_VAL (0x1ffL<<0)
5123
5124#define BNX2_HC_SB_CONFIG_1 0x00006a00
5125#define BNX2_HC_SB_CONFIG_1_RX_TMR_MODE (1L<<1)
5126#define BNX2_HC_SB_CONFIG_1_TX_TMR_MODE (1L<<2)
5127#define BNX2_HC_SB_CONFIG_1_COM_TMR_MODE (1L<<3)
5128#define BNX2_HC_SB_CONFIG_1_CMD_TMR_MODE (1L<<4)
5129#define BNX2_HC_SB_CONFIG_1_PER_MODE (1L<<16)
5130#define BNX2_HC_SB_CONFIG_1_ONE_SHOT (1L<<17)
5131#define BNX2_HC_SB_CONFIG_1_USE_INT_PARAM (1L<<18)
5132#define BNX2_HC_SB_CONFIG_1_PER_COLLECT_LIMIT (0xfL<<20)
5133
5134#define BNX2_HC_TX_QUICK_CONS_TRIP_1 0x00006a04
5135#define BNX2_HC_TX_QUICK_CONS_TRIP_1_VALUE (0xffL<<0)
5136#define BNX2_HC_TX_QUICK_CONS_TRIP_1_INT (0xffL<<16)
5137
5138#define BNX2_HC_COMP_PROD_TRIP_1 0x00006a08
5139#define BNX2_HC_COMP_PROD_TRIP_1_VALUE (0xffL<<0)
5140#define BNX2_HC_COMP_PROD_TRIP_1_INT (0xffL<<16)
5141
5142#define BNX2_HC_RX_QUICK_CONS_TRIP_1 0x00006a0c
5143#define BNX2_HC_RX_QUICK_CONS_TRIP_1_VALUE (0xffL<<0)
5144#define BNX2_HC_RX_QUICK_CONS_TRIP_1_INT (0xffL<<16)
5145
5146#define BNX2_HC_RX_TICKS_1 0x00006a10
5147#define BNX2_HC_RX_TICKS_1_VALUE (0x3ffL<<0)
5148#define BNX2_HC_RX_TICKS_1_INT (0x3ffL<<16)
5149
5150#define BNX2_HC_TX_TICKS_1 0x00006a14
5151#define BNX2_HC_TX_TICKS_1_VALUE (0x3ffL<<0)
5152#define BNX2_HC_TX_TICKS_1_INT (0x3ffL<<16)
5153
5154#define BNX2_HC_COM_TICKS_1 0x00006a18
5155#define BNX2_HC_COM_TICKS_1_VALUE (0x3ffL<<0)
5156#define BNX2_HC_COM_TICKS_1_INT (0x3ffL<<16)
5157
5158#define BNX2_HC_CMD_TICKS_1 0x00006a1c
5159#define BNX2_HC_CMD_TICKS_1_VALUE (0x3ffL<<0)
5160#define BNX2_HC_CMD_TICKS_1_INT (0x3ffL<<16)
5161
5162#define BNX2_HC_PERIODIC_TICKS_1 0x00006a20
5163#define BNX2_HC_PERIODIC_TICKS_1_HC_PERIODIC_TICKS (0xffffL<<0)
5164#define BNX2_HC_PERIODIC_TICKS_1_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5165
5166#define BNX2_HC_SB_CONFIG_2 0x00006a24
5167#define BNX2_HC_SB_CONFIG_2_RX_TMR_MODE (1L<<1)
5168#define BNX2_HC_SB_CONFIG_2_TX_TMR_MODE (1L<<2)
5169#define BNX2_HC_SB_CONFIG_2_COM_TMR_MODE (1L<<3)
5170#define BNX2_HC_SB_CONFIG_2_CMD_TMR_MODE (1L<<4)
5171#define BNX2_HC_SB_CONFIG_2_PER_MODE (1L<<16)
5172#define BNX2_HC_SB_CONFIG_2_ONE_SHOT (1L<<17)
5173#define BNX2_HC_SB_CONFIG_2_USE_INT_PARAM (1L<<18)
5174#define BNX2_HC_SB_CONFIG_2_PER_COLLECT_LIMIT (0xfL<<20)
5175
5176#define BNX2_HC_TX_QUICK_CONS_TRIP_2 0x00006a28
5177#define BNX2_HC_TX_QUICK_CONS_TRIP_2_VALUE (0xffL<<0)
5178#define BNX2_HC_TX_QUICK_CONS_TRIP_2_INT (0xffL<<16)
5179
5180#define BNX2_HC_COMP_PROD_TRIP_2 0x00006a2c
5181#define BNX2_HC_COMP_PROD_TRIP_2_VALUE (0xffL<<0)
5182#define BNX2_HC_COMP_PROD_TRIP_2_INT (0xffL<<16)
5183
5184#define BNX2_HC_RX_QUICK_CONS_TRIP_2 0x00006a30
5185#define BNX2_HC_RX_QUICK_CONS_TRIP_2_VALUE (0xffL<<0)
5186#define BNX2_HC_RX_QUICK_CONS_TRIP_2_INT (0xffL<<16)
5187
5188#define BNX2_HC_RX_TICKS_2 0x00006a34
5189#define BNX2_HC_RX_TICKS_2_VALUE (0x3ffL<<0)
5190#define BNX2_HC_RX_TICKS_2_INT (0x3ffL<<16)
5191
5192#define BNX2_HC_TX_TICKS_2 0x00006a38
5193#define BNX2_HC_TX_TICKS_2_VALUE (0x3ffL<<0)
5194#define BNX2_HC_TX_TICKS_2_INT (0x3ffL<<16)
5195
5196#define BNX2_HC_COM_TICKS_2 0x00006a3c
5197#define BNX2_HC_COM_TICKS_2_VALUE (0x3ffL<<0)
5198#define BNX2_HC_COM_TICKS_2_INT (0x3ffL<<16)
5199
5200#define BNX2_HC_CMD_TICKS_2 0x00006a40
5201#define BNX2_HC_CMD_TICKS_2_VALUE (0x3ffL<<0)
5202#define BNX2_HC_CMD_TICKS_2_INT (0x3ffL<<16)
5203
5204#define BNX2_HC_PERIODIC_TICKS_2 0x00006a44
5205#define BNX2_HC_PERIODIC_TICKS_2_HC_PERIODIC_TICKS (0xffffL<<0)
5206#define BNX2_HC_PERIODIC_TICKS_2_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5207
5208#define BNX2_HC_SB_CONFIG_3 0x00006a48
5209#define BNX2_HC_SB_CONFIG_3_RX_TMR_MODE (1L<<1)
5210#define BNX2_HC_SB_CONFIG_3_TX_TMR_MODE (1L<<2)
5211#define BNX2_HC_SB_CONFIG_3_COM_TMR_MODE (1L<<3)
5212#define BNX2_HC_SB_CONFIG_3_CMD_TMR_MODE (1L<<4)
5213#define BNX2_HC_SB_CONFIG_3_PER_MODE (1L<<16)
5214#define BNX2_HC_SB_CONFIG_3_ONE_SHOT (1L<<17)
5215#define BNX2_HC_SB_CONFIG_3_USE_INT_PARAM (1L<<18)
5216#define BNX2_HC_SB_CONFIG_3_PER_COLLECT_LIMIT (0xfL<<20)
5217
5218#define BNX2_HC_TX_QUICK_CONS_TRIP_3 0x00006a4c
5219#define BNX2_HC_TX_QUICK_CONS_TRIP_3_VALUE (0xffL<<0)
5220#define BNX2_HC_TX_QUICK_CONS_TRIP_3_INT (0xffL<<16)
5221
5222#define BNX2_HC_COMP_PROD_TRIP_3 0x00006a50
5223#define BNX2_HC_COMP_PROD_TRIP_3_VALUE (0xffL<<0)
5224#define BNX2_HC_COMP_PROD_TRIP_3_INT (0xffL<<16)
5225
5226#define BNX2_HC_RX_QUICK_CONS_TRIP_3 0x00006a54
5227#define BNX2_HC_RX_QUICK_CONS_TRIP_3_VALUE (0xffL<<0)
5228#define BNX2_HC_RX_QUICK_CONS_TRIP_3_INT (0xffL<<16)
5229
5230#define BNX2_HC_RX_TICKS_3 0x00006a58
5231#define BNX2_HC_RX_TICKS_3_VALUE (0x3ffL<<0)
5232#define BNX2_HC_RX_TICKS_3_INT (0x3ffL<<16)
5233
5234#define BNX2_HC_TX_TICKS_3 0x00006a5c
5235#define BNX2_HC_TX_TICKS_3_VALUE (0x3ffL<<0)
5236#define BNX2_HC_TX_TICKS_3_INT (0x3ffL<<16)
5237
5238#define BNX2_HC_COM_TICKS_3 0x00006a60
5239#define BNX2_HC_COM_TICKS_3_VALUE (0x3ffL<<0)
5240#define BNX2_HC_COM_TICKS_3_INT (0x3ffL<<16)
5241
5242#define BNX2_HC_CMD_TICKS_3 0x00006a64
5243#define BNX2_HC_CMD_TICKS_3_VALUE (0x3ffL<<0)
5244#define BNX2_HC_CMD_TICKS_3_INT (0x3ffL<<16)
5245
5246#define BNX2_HC_PERIODIC_TICKS_3 0x00006a68
5247#define BNX2_HC_PERIODIC_TICKS_3_HC_PERIODIC_TICKS (0xffffL<<0)
5248#define BNX2_HC_PERIODIC_TICKS_3_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5249
5250#define BNX2_HC_SB_CONFIG_4 0x00006a6c
5251#define BNX2_HC_SB_CONFIG_4_RX_TMR_MODE (1L<<1)
5252#define BNX2_HC_SB_CONFIG_4_TX_TMR_MODE (1L<<2)
5253#define BNX2_HC_SB_CONFIG_4_COM_TMR_MODE (1L<<3)
5254#define BNX2_HC_SB_CONFIG_4_CMD_TMR_MODE (1L<<4)
5255#define BNX2_HC_SB_CONFIG_4_PER_MODE (1L<<16)
5256#define BNX2_HC_SB_CONFIG_4_ONE_SHOT (1L<<17)
5257#define BNX2_HC_SB_CONFIG_4_USE_INT_PARAM (1L<<18)
5258#define BNX2_HC_SB_CONFIG_4_PER_COLLECT_LIMIT (0xfL<<20)
5259
5260#define BNX2_HC_TX_QUICK_CONS_TRIP_4 0x00006a70
5261#define BNX2_HC_TX_QUICK_CONS_TRIP_4_VALUE (0xffL<<0)
5262#define BNX2_HC_TX_QUICK_CONS_TRIP_4_INT (0xffL<<16)
5263
5264#define BNX2_HC_COMP_PROD_TRIP_4 0x00006a74
5265#define BNX2_HC_COMP_PROD_TRIP_4_VALUE (0xffL<<0)
5266#define BNX2_HC_COMP_PROD_TRIP_4_INT (0xffL<<16)
5267
5268#define BNX2_HC_RX_QUICK_CONS_TRIP_4 0x00006a78
5269#define BNX2_HC_RX_QUICK_CONS_TRIP_4_VALUE (0xffL<<0)
5270#define BNX2_HC_RX_QUICK_CONS_TRIP_4_INT (0xffL<<16)
5271
5272#define BNX2_HC_RX_TICKS_4 0x00006a7c
5273#define BNX2_HC_RX_TICKS_4_VALUE (0x3ffL<<0)
5274#define BNX2_HC_RX_TICKS_4_INT (0x3ffL<<16)
5275
5276#define BNX2_HC_TX_TICKS_4 0x00006a80
5277#define BNX2_HC_TX_TICKS_4_VALUE (0x3ffL<<0)
5278#define BNX2_HC_TX_TICKS_4_INT (0x3ffL<<16)
5279
5280#define BNX2_HC_COM_TICKS_4 0x00006a84
5281#define BNX2_HC_COM_TICKS_4_VALUE (0x3ffL<<0)
5282#define BNX2_HC_COM_TICKS_4_INT (0x3ffL<<16)
5283
5284#define BNX2_HC_CMD_TICKS_4 0x00006a88
5285#define BNX2_HC_CMD_TICKS_4_VALUE (0x3ffL<<0)
5286#define BNX2_HC_CMD_TICKS_4_INT (0x3ffL<<16)
5287
5288#define BNX2_HC_PERIODIC_TICKS_4 0x00006a8c
5289#define BNX2_HC_PERIODIC_TICKS_4_HC_PERIODIC_TICKS (0xffffL<<0)
5290#define BNX2_HC_PERIODIC_TICKS_4_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5291
5292#define BNX2_HC_SB_CONFIG_5 0x00006a90
5293#define BNX2_HC_SB_CONFIG_5_RX_TMR_MODE (1L<<1)
5294#define BNX2_HC_SB_CONFIG_5_TX_TMR_MODE (1L<<2)
5295#define BNX2_HC_SB_CONFIG_5_COM_TMR_MODE (1L<<3)
5296#define BNX2_HC_SB_CONFIG_5_CMD_TMR_MODE (1L<<4)
5297#define BNX2_HC_SB_CONFIG_5_PER_MODE (1L<<16)
5298#define BNX2_HC_SB_CONFIG_5_ONE_SHOT (1L<<17)
5299#define BNX2_HC_SB_CONFIG_5_USE_INT_PARAM (1L<<18)
5300#define BNX2_HC_SB_CONFIG_5_PER_COLLECT_LIMIT (0xfL<<20)
5301
5302#define BNX2_HC_TX_QUICK_CONS_TRIP_5 0x00006a94
5303#define BNX2_HC_TX_QUICK_CONS_TRIP_5_VALUE (0xffL<<0)
5304#define BNX2_HC_TX_QUICK_CONS_TRIP_5_INT (0xffL<<16)
5305
5306#define BNX2_HC_COMP_PROD_TRIP_5 0x00006a98
5307#define BNX2_HC_COMP_PROD_TRIP_5_VALUE (0xffL<<0)
5308#define BNX2_HC_COMP_PROD_TRIP_5_INT (0xffL<<16)
5309
5310#define BNX2_HC_RX_QUICK_CONS_TRIP_5 0x00006a9c
5311#define BNX2_HC_RX_QUICK_CONS_TRIP_5_VALUE (0xffL<<0)
5312#define BNX2_HC_RX_QUICK_CONS_TRIP_5_INT (0xffL<<16)
5313
5314#define BNX2_HC_RX_TICKS_5 0x00006aa0
5315#define BNX2_HC_RX_TICKS_5_VALUE (0x3ffL<<0)
5316#define BNX2_HC_RX_TICKS_5_INT (0x3ffL<<16)
5317
5318#define BNX2_HC_TX_TICKS_5 0x00006aa4
5319#define BNX2_HC_TX_TICKS_5_VALUE (0x3ffL<<0)
5320#define BNX2_HC_TX_TICKS_5_INT (0x3ffL<<16)
5321
5322#define BNX2_HC_COM_TICKS_5 0x00006aa8
5323#define BNX2_HC_COM_TICKS_5_VALUE (0x3ffL<<0)
5324#define BNX2_HC_COM_TICKS_5_INT (0x3ffL<<16)
5325
5326#define BNX2_HC_CMD_TICKS_5 0x00006aac
5327#define BNX2_HC_CMD_TICKS_5_VALUE (0x3ffL<<0)
5328#define BNX2_HC_CMD_TICKS_5_INT (0x3ffL<<16)
5329
5330#define BNX2_HC_PERIODIC_TICKS_5 0x00006ab0
5331#define BNX2_HC_PERIODIC_TICKS_5_HC_PERIODIC_TICKS (0xffffL<<0)
5332#define BNX2_HC_PERIODIC_TICKS_5_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5333
5334#define BNX2_HC_SB_CONFIG_6 0x00006ab4
5335#define BNX2_HC_SB_CONFIG_6_RX_TMR_MODE (1L<<1)
5336#define BNX2_HC_SB_CONFIG_6_TX_TMR_MODE (1L<<2)
5337#define BNX2_HC_SB_CONFIG_6_COM_TMR_MODE (1L<<3)
5338#define BNX2_HC_SB_CONFIG_6_CMD_TMR_MODE (1L<<4)
5339#define BNX2_HC_SB_CONFIG_6_PER_MODE (1L<<16)
5340#define BNX2_HC_SB_CONFIG_6_ONE_SHOT (1L<<17)
5341#define BNX2_HC_SB_CONFIG_6_USE_INT_PARAM (1L<<18)
5342#define BNX2_HC_SB_CONFIG_6_PER_COLLECT_LIMIT (0xfL<<20)
5343
5344#define BNX2_HC_TX_QUICK_CONS_TRIP_6 0x00006ab8
5345#define BNX2_HC_TX_QUICK_CONS_TRIP_6_VALUE (0xffL<<0)
5346#define BNX2_HC_TX_QUICK_CONS_TRIP_6_INT (0xffL<<16)
5347
5348#define BNX2_HC_COMP_PROD_TRIP_6 0x00006abc
5349#define BNX2_HC_COMP_PROD_TRIP_6_VALUE (0xffL<<0)
5350#define BNX2_HC_COMP_PROD_TRIP_6_INT (0xffL<<16)
5351
5352#define BNX2_HC_RX_QUICK_CONS_TRIP_6 0x00006ac0
5353#define BNX2_HC_RX_QUICK_CONS_TRIP_6_VALUE (0xffL<<0)
5354#define BNX2_HC_RX_QUICK_CONS_TRIP_6_INT (0xffL<<16)
5355
5356#define BNX2_HC_RX_TICKS_6 0x00006ac4
5357#define BNX2_HC_RX_TICKS_6_VALUE (0x3ffL<<0)
5358#define BNX2_HC_RX_TICKS_6_INT (0x3ffL<<16)
5359
5360#define BNX2_HC_TX_TICKS_6 0x00006ac8
5361#define BNX2_HC_TX_TICKS_6_VALUE (0x3ffL<<0)
5362#define BNX2_HC_TX_TICKS_6_INT (0x3ffL<<16)
5363
5364#define BNX2_HC_COM_TICKS_6 0x00006acc
5365#define BNX2_HC_COM_TICKS_6_VALUE (0x3ffL<<0)
5366#define BNX2_HC_COM_TICKS_6_INT (0x3ffL<<16)
5367
5368#define BNX2_HC_CMD_TICKS_6 0x00006ad0
5369#define BNX2_HC_CMD_TICKS_6_VALUE (0x3ffL<<0)
5370#define BNX2_HC_CMD_TICKS_6_INT (0x3ffL<<16)
5371
5372#define BNX2_HC_PERIODIC_TICKS_6 0x00006ad4
5373#define BNX2_HC_PERIODIC_TICKS_6_HC_PERIODIC_TICKS (0xffffL<<0)
5374#define BNX2_HC_PERIODIC_TICKS_6_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5375
5376#define BNX2_HC_SB_CONFIG_7 0x00006ad8
5377#define BNX2_HC_SB_CONFIG_7_RX_TMR_MODE (1L<<1)
5378#define BNX2_HC_SB_CONFIG_7_TX_TMR_MODE (1L<<2)
5379#define BNX2_HC_SB_CONFIG_7_COM_TMR_MODE (1L<<3)
5380#define BNX2_HC_SB_CONFIG_7_CMD_TMR_MODE (1L<<4)
5381#define BNX2_HC_SB_CONFIG_7_PER_MODE (1L<<16)
5382#define BNX2_HC_SB_CONFIG_7_ONE_SHOT (1L<<17)
5383#define BNX2_HC_SB_CONFIG_7_USE_INT_PARAM (1L<<18)
5384#define BNX2_HC_SB_CONFIG_7_PER_COLLECT_LIMIT (0xfL<<20)
5385
5386#define BNX2_HC_TX_QUICK_CONS_TRIP_7 0x00006adc
5387#define BNX2_HC_TX_QUICK_CONS_TRIP_7_VALUE (0xffL<<0)
5388#define BNX2_HC_TX_QUICK_CONS_TRIP_7_INT (0xffL<<16)
5389
5390#define BNX2_HC_COMP_PROD_TRIP_7 0x00006ae0
5391#define BNX2_HC_COMP_PROD_TRIP_7_VALUE (0xffL<<0)
5392#define BNX2_HC_COMP_PROD_TRIP_7_INT (0xffL<<16)
5393
5394#define BNX2_HC_RX_QUICK_CONS_TRIP_7 0x00006ae4
5395#define BNX2_HC_RX_QUICK_CONS_TRIP_7_VALUE (0xffL<<0)
5396#define BNX2_HC_RX_QUICK_CONS_TRIP_7_INT (0xffL<<16)
5397
5398#define BNX2_HC_RX_TICKS_7 0x00006ae8
5399#define BNX2_HC_RX_TICKS_7_VALUE (0x3ffL<<0)
5400#define BNX2_HC_RX_TICKS_7_INT (0x3ffL<<16)
5401
5402#define BNX2_HC_TX_TICKS_7 0x00006aec
5403#define BNX2_HC_TX_TICKS_7_VALUE (0x3ffL<<0)
5404#define BNX2_HC_TX_TICKS_7_INT (0x3ffL<<16)
5405
5406#define BNX2_HC_COM_TICKS_7 0x00006af0
5407#define BNX2_HC_COM_TICKS_7_VALUE (0x3ffL<<0)
5408#define BNX2_HC_COM_TICKS_7_INT (0x3ffL<<16)
5409
5410#define BNX2_HC_CMD_TICKS_7 0x00006af4
5411#define BNX2_HC_CMD_TICKS_7_VALUE (0x3ffL<<0)
5412#define BNX2_HC_CMD_TICKS_7_INT (0x3ffL<<16)
5413
5414#define BNX2_HC_PERIODIC_TICKS_7 0x00006af8
5415#define BNX2_HC_PERIODIC_TICKS_7_HC_PERIODIC_TICKS (0xffffL<<0)
5416#define BNX2_HC_PERIODIC_TICKS_7_HC_INT_PERIODIC_TICKS (0xffffL<<16)
5417
5418#define BNX2_HC_SB_CONFIG_8 0x00006afc
5419#define BNX2_HC_SB_CONFIG_8_RX_TMR_MODE (1L<<1)
5420#define BNX2_HC_SB_CONFIG_8_TX_TMR_MODE (1L<<2)
5421#define BNX2_HC_SB_CONFIG_8_COM_TMR_MODE (1L<<3)
5422#define BNX2_HC_SB_CONFIG_8_CMD_TMR_MODE (1L<<4)
5423#define BNX2_HC_SB_CONFIG_8_PER_MODE (1L<<16)
5424#define BNX2_HC_SB_CONFIG_8_ONE_SHOT (1L<<17)
5425#define BNX2_HC_SB_CONFIG_8_USE_INT_PARAM (1L<<18)
5426#define BNX2_HC_SB_CONFIG_8_PER_COLLECT_LIMIT (0xfL<<20)
5427
5428#define BNX2_HC_TX_QUICK_CONS_TRIP_8 0x00006b00
5429#define BNX2_HC_TX_QUICK_CONS_TRIP_8_VALUE (0xffL<<0)
5430#define BNX2_HC_TX_QUICK_CONS_TRIP_8_INT (0xffL<<16)
5431
5432#define BNX2_HC_COMP_PROD_TRIP_8 0x00006b04
5433#define BNX2_HC_COMP_PROD_TRIP_8_VALUE (0xffL<<0)
5434#define BNX2_HC_COMP_PROD_TRIP_8_INT (0xffL<<16)
5435
5436#define BNX2_HC_RX_QUICK_CONS_TRIP_8 0x00006b08
5437#define BNX2_HC_RX_QUICK_CONS_TRIP_8_VALUE (0xffL<<0)
5438#define BNX2_HC_RX_QUICK_CONS_TRIP_8_INT (0xffL<<16)
5439
5440#define BNX2_HC_RX_TICKS_8 0x00006b0c
5441#define BNX2_HC_RX_TICKS_8_VALUE (0x3ffL<<0)
5442#define BNX2_HC_RX_TICKS_8_INT (0x3ffL<<16)
5443
5444#define BNX2_HC_TX_TICKS_8 0x00006b10
5445#define BNX2_HC_TX_TICKS_8_VALUE (0x3ffL<<0)
5446#define BNX2_HC_TX_TICKS_8_INT (0x3ffL<<16)
5447
5448#define BNX2_HC_COM_TICKS_8 0x00006b14
5449#define BNX2_HC_COM_TICKS_8_VALUE (0x3ffL<<0)
5450#define BNX2_HC_COM_TICKS_8_INT (0x3ffL<<16)
5451
5452#define BNX2_HC_CMD_TICKS_8 0x00006b18
5453#define BNX2_HC_CMD_TICKS_8_VALUE (0x3ffL<<0)
5454#define BNX2_HC_CMD_TICKS_8_INT (0x3ffL<<16)
5455
5456#define BNX2_HC_PERIODIC_TICKS_8 0x00006b1c
5457#define BNX2_HC_PERIODIC_TICKS_8_HC_PERIODIC_TICKS (0xffffL<<0)
5458#define BNX2_HC_PERIODIC_TICKS_8_HC_INT_PERIODIC_TICKS (0xffffL<<16)
3041 5459
3042 5460
3043/* 5461/*
@@ -3063,7 +5481,7 @@ struct l2_fhdr {
3063#define BNX2_TXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5481#define BNX2_TXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3064#define BNX2_TXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5482#define BNX2_TXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3065#define BNX2_TXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5483#define BNX2_TXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3066#define BNX2_TXP_CPU_STATE_BAD_pc_HALTED (1L<<6) 5484#define BNX2_TXP_CPU_STATE_BAD_PC_HALTED (1L<<6)
3067#define BNX2_TXP_CPU_STATE_ALIGN_HALTED (1L<<7) 5485#define BNX2_TXP_CPU_STATE_ALIGN_HALTED (1L<<7)
3068#define BNX2_TXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5486#define BNX2_TXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3069#define BNX2_TXP_CPU_STATE_SOFT_HALTED (1L<<10) 5487#define BNX2_TXP_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3111,7 +5529,7 @@ struct l2_fhdr {
3111#define BNX2_TXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 5529#define BNX2_TXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3112 5530
3113#define BNX2_TXP_CPU_REG_FILE 0x00045200 5531#define BNX2_TXP_CPU_REG_FILE 0x00045200
3114#define BNX2_TXP_FTQ_DATA 0x000453c0 5532#define BNX2_TXP_TXPQ 0x000453c0
3115#define BNX2_TXP_FTQ_CMD 0x000453f8 5533#define BNX2_TXP_FTQ_CMD 0x000453f8
3116#define BNX2_TXP_FTQ_CMD_OFFSET (0x3ffL<<0) 5534#define BNX2_TXP_FTQ_CMD_OFFSET (0x3ffL<<0)
3117#define BNX2_TXP_FTQ_CMD_WR_TOP (1L<<10) 5535#define BNX2_TXP_FTQ_CMD_WR_TOP (1L<<10)
@@ -3158,7 +5576,7 @@ struct l2_fhdr {
3158#define BNX2_TPAT_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5576#define BNX2_TPAT_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3159#define BNX2_TPAT_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5577#define BNX2_TPAT_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3160#define BNX2_TPAT_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5578#define BNX2_TPAT_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3161#define BNX2_TPAT_CPU_STATE_BAD_pc_HALTED (1L<<6) 5579#define BNX2_TPAT_CPU_STATE_BAD_PC_HALTED (1L<<6)
3162#define BNX2_TPAT_CPU_STATE_ALIGN_HALTED (1L<<7) 5580#define BNX2_TPAT_CPU_STATE_ALIGN_HALTED (1L<<7)
3163#define BNX2_TPAT_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5581#define BNX2_TPAT_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3164#define BNX2_TPAT_CPU_STATE_SOFT_HALTED (1L<<10) 5582#define BNX2_TPAT_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3206,7 +5624,7 @@ struct l2_fhdr {
3206#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 5624#define BNX2_TPAT_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3207 5625
3208#define BNX2_TPAT_CPU_REG_FILE 0x00085200 5626#define BNX2_TPAT_CPU_REG_FILE 0x00085200
3209#define BNX2_TPAT_FTQ_DATA 0x000853c0 5627#define BNX2_TPAT_TPATQ 0x000853c0
3210#define BNX2_TPAT_FTQ_CMD 0x000853f8 5628#define BNX2_TPAT_FTQ_CMD 0x000853f8
3211#define BNX2_TPAT_FTQ_CMD_OFFSET (0x3ffL<<0) 5629#define BNX2_TPAT_FTQ_CMD_OFFSET (0x3ffL<<0)
3212#define BNX2_TPAT_FTQ_CMD_WR_TOP (1L<<10) 5630#define BNX2_TPAT_FTQ_CMD_WR_TOP (1L<<10)
@@ -3253,7 +5671,7 @@ struct l2_fhdr {
3253#define BNX2_RXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5671#define BNX2_RXP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3254#define BNX2_RXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5672#define BNX2_RXP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3255#define BNX2_RXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5673#define BNX2_RXP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3256#define BNX2_RXP_CPU_STATE_BAD_pc_HALTED (1L<<6) 5674#define BNX2_RXP_CPU_STATE_BAD_PC_HALTED (1L<<6)
3257#define BNX2_RXP_CPU_STATE_ALIGN_HALTED (1L<<7) 5675#define BNX2_RXP_CPU_STATE_ALIGN_HALTED (1L<<7)
3258#define BNX2_RXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5676#define BNX2_RXP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3259#define BNX2_RXP_CPU_STATE_SOFT_HALTED (1L<<10) 5677#define BNX2_RXP_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3301,7 +5719,29 @@ struct l2_fhdr {
3301#define BNX2_RXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 5719#define BNX2_RXP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3302 5720
3303#define BNX2_RXP_CPU_REG_FILE 0x000c5200 5721#define BNX2_RXP_CPU_REG_FILE 0x000c5200
3304#define BNX2_RXP_CFTQ_DATA 0x000c5380 5722#define BNX2_RXP_PFE_PFE_CTL 0x000c537c
5723#define BNX2_RXP_PFE_PFE_CTL_INC_USAGE_CNT (1L<<0)
5724#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE (0xfL<<4)
5725#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_0 (0L<<4)
5726#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_1 (1L<<4)
5727#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_2 (2L<<4)
5728#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_3 (3L<<4)
5729#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_4 (4L<<4)
5730#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_5 (5L<<4)
5731#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_6 (6L<<4)
5732#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_7 (7L<<4)
5733#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_8 (8L<<4)
5734#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_9 (9L<<4)
5735#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_10 (10L<<4)
5736#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_11 (11L<<4)
5737#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_12 (12L<<4)
5738#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_13 (13L<<4)
5739#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_14 (14L<<4)
5740#define BNX2_RXP_PFE_PFE_CTL_PFE_SIZE_15 (15L<<4)
5741#define BNX2_RXP_PFE_PFE_CTL_PFE_COUNT (0xfL<<12)
5742#define BNX2_RXP_PFE_PFE_CTL_OFFSET (0x1ffL<<16)
5743
5744#define BNX2_RXP_RXPCQ 0x000c5380
3305#define BNX2_RXP_CFTQ_CMD 0x000c53b8 5745#define BNX2_RXP_CFTQ_CMD 0x000c53b8
3306#define BNX2_RXP_CFTQ_CMD_OFFSET (0x3ffL<<0) 5746#define BNX2_RXP_CFTQ_CMD_OFFSET (0x3ffL<<0)
3307#define BNX2_RXP_CFTQ_CMD_WR_TOP (1L<<10) 5747#define BNX2_RXP_CFTQ_CMD_WR_TOP (1L<<10)
@@ -3322,7 +5762,7 @@ struct l2_fhdr {
3322#define BNX2_RXP_CFTQ_CTL_MAX_DEPTH (0x3ffL<<12) 5762#define BNX2_RXP_CFTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3323#define BNX2_RXP_CFTQ_CTL_CUR_DEPTH (0x3ffL<<22) 5763#define BNX2_RXP_CFTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3324 5764
3325#define BNX2_RXP_FTQ_DATA 0x000c53c0 5765#define BNX2_RXP_RXPQ 0x000c53c0
3326#define BNX2_RXP_FTQ_CMD 0x000c53f8 5766#define BNX2_RXP_FTQ_CMD 0x000c53f8
3327#define BNX2_RXP_FTQ_CMD_OFFSET (0x3ffL<<0) 5767#define BNX2_RXP_FTQ_CMD_OFFSET (0x3ffL<<0)
3328#define BNX2_RXP_FTQ_CMD_WR_TOP (1L<<10) 5768#define BNX2_RXP_FTQ_CMD_WR_TOP (1L<<10)
@@ -3350,6 +5790,10 @@ struct l2_fhdr {
3350 * com_reg definition 5790 * com_reg definition
3351 * offset: 0x100000 5791 * offset: 0x100000
3352 */ 5792 */
5793#define BNX2_COM_CKSUM_ERROR_STATUS 0x00100000
5794#define BNX2_COM_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
5795#define BNX2_COM_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
5796
3353#define BNX2_COM_CPU_MODE 0x00105000 5797#define BNX2_COM_CPU_MODE 0x00105000
3354#define BNX2_COM_CPU_MODE_LOCAL_RST (1L<<0) 5798#define BNX2_COM_CPU_MODE_LOCAL_RST (1L<<0)
3355#define BNX2_COM_CPU_MODE_STEP_ENA (1L<<1) 5799#define BNX2_COM_CPU_MODE_STEP_ENA (1L<<1)
@@ -3369,7 +5813,7 @@ struct l2_fhdr {
3369#define BNX2_COM_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5813#define BNX2_COM_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3370#define BNX2_COM_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5814#define BNX2_COM_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3371#define BNX2_COM_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5815#define BNX2_COM_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3372#define BNX2_COM_CPU_STATE_BAD_pc_HALTED (1L<<6) 5816#define BNX2_COM_CPU_STATE_BAD_PC_HALTED (1L<<6)
3373#define BNX2_COM_CPU_STATE_ALIGN_HALTED (1L<<7) 5817#define BNX2_COM_CPU_STATE_ALIGN_HALTED (1L<<7)
3374#define BNX2_COM_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5818#define BNX2_COM_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3375#define BNX2_COM_CPU_STATE_SOFT_HALTED (1L<<10) 5819#define BNX2_COM_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3417,7 +5861,29 @@ struct l2_fhdr {
3417#define BNX2_COM_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 5861#define BNX2_COM_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3418 5862
3419#define BNX2_COM_CPU_REG_FILE 0x00105200 5863#define BNX2_COM_CPU_REG_FILE 0x00105200
3420#define BNX2_COM_COMXQ_FTQ_DATA 0x00105340 5864#define BNX2_COM_COMTQ_PFE_PFE_CTL 0x001052bc
5865#define BNX2_COM_COMTQ_PFE_PFE_CTL_INC_USAGE_CNT (1L<<0)
5866#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE (0xfL<<4)
5867#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_0 (0L<<4)
5868#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_1 (1L<<4)
5869#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_2 (2L<<4)
5870#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_3 (3L<<4)
5871#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_4 (4L<<4)
5872#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_5 (5L<<4)
5873#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_6 (6L<<4)
5874#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_7 (7L<<4)
5875#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_8 (8L<<4)
5876#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_9 (9L<<4)
5877#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_10 (10L<<4)
5878#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_11 (11L<<4)
5879#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_12 (12L<<4)
5880#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_13 (13L<<4)
5881#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_14 (14L<<4)
5882#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_SIZE_15 (15L<<4)
5883#define BNX2_COM_COMTQ_PFE_PFE_CTL_PFE_COUNT (0xfL<<12)
5884#define BNX2_COM_COMTQ_PFE_PFE_CTL_OFFSET (0x1ffL<<16)
5885
5886#define BNX2_COM_COMXQ 0x00105340
3421#define BNX2_COM_COMXQ_FTQ_CMD 0x00105378 5887#define BNX2_COM_COMXQ_FTQ_CMD 0x00105378
3422#define BNX2_COM_COMXQ_FTQ_CMD_OFFSET (0x3ffL<<0) 5888#define BNX2_COM_COMXQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3423#define BNX2_COM_COMXQ_FTQ_CMD_WR_TOP (1L<<10) 5889#define BNX2_COM_COMXQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3438,7 +5904,7 @@ struct l2_fhdr {
3438#define BNX2_COM_COMXQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12) 5904#define BNX2_COM_COMXQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3439#define BNX2_COM_COMXQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22) 5905#define BNX2_COM_COMXQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3440 5906
3441#define BNX2_COM_COMTQ_FTQ_DATA 0x00105380 5907#define BNX2_COM_COMTQ 0x00105380
3442#define BNX2_COM_COMTQ_FTQ_CMD 0x001053b8 5908#define BNX2_COM_COMTQ_FTQ_CMD 0x001053b8
3443#define BNX2_COM_COMTQ_FTQ_CMD_OFFSET (0x3ffL<<0) 5909#define BNX2_COM_COMTQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3444#define BNX2_COM_COMTQ_FTQ_CMD_WR_TOP (1L<<10) 5910#define BNX2_COM_COMTQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3459,7 +5925,7 @@ struct l2_fhdr {
3459#define BNX2_COM_COMTQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12) 5925#define BNX2_COM_COMTQ_FTQ_CTL_MAX_DEPTH (0x3ffL<<12)
3460#define BNX2_COM_COMTQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22) 5926#define BNX2_COM_COMTQ_FTQ_CTL_CUR_DEPTH (0x3ffL<<22)
3461 5927
3462#define BNX2_COM_COMQ_FTQ_DATA 0x001053c0 5928#define BNX2_COM_COMQ 0x001053c0
3463#define BNX2_COM_COMQ_FTQ_CMD 0x001053f8 5929#define BNX2_COM_COMQ_FTQ_CMD 0x001053f8
3464#define BNX2_COM_COMQ_FTQ_CMD_OFFSET (0x3ffL<<0) 5930#define BNX2_COM_COMQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3465#define BNX2_COM_COMQ_FTQ_CMD_WR_TOP (1L<<10) 5931#define BNX2_COM_COMQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3489,6 +5955,10 @@ struct l2_fhdr {
3489 * cp_reg definition 5955 * cp_reg definition
3490 * offset: 0x180000 5956 * offset: 0x180000
3491 */ 5957 */
5958#define BNX2_CP_CKSUM_ERROR_STATUS 0x00180000
5959#define BNX2_CP_CKSUM_ERROR_STATUS_CALCULATED (0xffffL<<0)
5960#define BNX2_CP_CKSUM_ERROR_STATUS_EXPECTED (0xffffL<<16)
5961
3492#define BNX2_CP_CPU_MODE 0x00185000 5962#define BNX2_CP_CPU_MODE 0x00185000
3493#define BNX2_CP_CPU_MODE_LOCAL_RST (1L<<0) 5963#define BNX2_CP_CPU_MODE_LOCAL_RST (1L<<0)
3494#define BNX2_CP_CPU_MODE_STEP_ENA (1L<<1) 5964#define BNX2_CP_CPU_MODE_STEP_ENA (1L<<1)
@@ -3508,7 +5978,7 @@ struct l2_fhdr {
3508#define BNX2_CP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 5978#define BNX2_CP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3509#define BNX2_CP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 5979#define BNX2_CP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3510#define BNX2_CP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 5980#define BNX2_CP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3511#define BNX2_CP_CPU_STATE_BAD_pc_HALTED (1L<<6) 5981#define BNX2_CP_CPU_STATE_BAD_PC_HALTED (1L<<6)
3512#define BNX2_CP_CPU_STATE_ALIGN_HALTED (1L<<7) 5982#define BNX2_CP_CPU_STATE_ALIGN_HALTED (1L<<7)
3513#define BNX2_CP_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 5983#define BNX2_CP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3514#define BNX2_CP_CPU_STATE_SOFT_HALTED (1L<<10) 5984#define BNX2_CP_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3556,7 +6026,29 @@ struct l2_fhdr {
3556#define BNX2_CP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 6026#define BNX2_CP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3557 6027
3558#define BNX2_CP_CPU_REG_FILE 0x00185200 6028#define BNX2_CP_CPU_REG_FILE 0x00185200
3559#define BNX2_CP_CPQ_FTQ_DATA 0x001853c0 6029#define BNX2_CP_CPQ_PFE_PFE_CTL 0x001853bc
6030#define BNX2_CP_CPQ_PFE_PFE_CTL_INC_USAGE_CNT (1L<<0)
6031#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE (0xfL<<4)
6032#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_0 (0L<<4)
6033#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_1 (1L<<4)
6034#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_2 (2L<<4)
6035#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_3 (3L<<4)
6036#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_4 (4L<<4)
6037#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_5 (5L<<4)
6038#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_6 (6L<<4)
6039#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_7 (7L<<4)
6040#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_8 (8L<<4)
6041#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_9 (9L<<4)
6042#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_10 (10L<<4)
6043#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_11 (11L<<4)
6044#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_12 (12L<<4)
6045#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_13 (13L<<4)
6046#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_14 (14L<<4)
6047#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_SIZE_15 (15L<<4)
6048#define BNX2_CP_CPQ_PFE_PFE_CTL_PFE_COUNT (0xfL<<12)
6049#define BNX2_CP_CPQ_PFE_PFE_CTL_OFFSET (0x1ffL<<16)
6050
6051#define BNX2_CP_CPQ 0x001853c0
3560#define BNX2_CP_CPQ_FTQ_CMD 0x001853f8 6052#define BNX2_CP_CPQ_FTQ_CMD 0x001853f8
3561#define BNX2_CP_CPQ_FTQ_CMD_OFFSET (0x3ffL<<0) 6053#define BNX2_CP_CPQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3562#define BNX2_CP_CPQ_FTQ_CMD_WR_TOP (1L<<10) 6054#define BNX2_CP_CPQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3584,6 +6076,59 @@ struct l2_fhdr {
3584 * mcp_reg definition 6076 * mcp_reg definition
3585 * offset: 0x140000 6077 * offset: 0x140000
3586 */ 6078 */
6079#define BNX2_MCP_MCP_CONTROL 0x00140080
6080#define BNX2_MCP_MCP_CONTROL_SMBUS_SEL (1L<<30)
6081#define BNX2_MCP_MCP_CONTROL_MCP_ISOLATE (1L<<31)
6082
6083#define BNX2_MCP_MCP_ATTENTION_STATUS 0x00140084
6084#define BNX2_MCP_MCP_ATTENTION_STATUS_DRV_DOORBELL (1L<<29)
6085#define BNX2_MCP_MCP_ATTENTION_STATUS_WATCHDOG_TIMEOUT (1L<<30)
6086#define BNX2_MCP_MCP_ATTENTION_STATUS_CPU_EVENT (1L<<31)
6087
6088#define BNX2_MCP_MCP_HEARTBEAT_CONTROL 0x00140088
6089#define BNX2_MCP_MCP_HEARTBEAT_CONTROL_MCP_HEARTBEAT_ENABLE (1L<<31)
6090
6091#define BNX2_MCP_MCP_HEARTBEAT_STATUS 0x0014008c
6092#define BNX2_MCP_MCP_HEARTBEAT_STATUS_MCP_HEARTBEAT_PERIOD (0x7ffL<<0)
6093#define BNX2_MCP_MCP_HEARTBEAT_STATUS_VALID (1L<<31)
6094
6095#define BNX2_MCP_MCP_HEARTBEAT 0x00140090
6096#define BNX2_MCP_MCP_HEARTBEAT_MCP_HEARTBEAT_COUNT (0x3fffffffL<<0)
6097#define BNX2_MCP_MCP_HEARTBEAT_MCP_HEARTBEAT_INC (1L<<30)
6098#define BNX2_MCP_MCP_HEARTBEAT_MCP_HEARTBEAT_RESET (1L<<31)
6099
6100#define BNX2_MCP_WATCHDOG_RESET 0x00140094
6101#define BNX2_MCP_WATCHDOG_RESET_WATCHDOG_RESET (1L<<31)
6102
6103#define BNX2_MCP_WATCHDOG_CONTROL 0x00140098
6104#define BNX2_MCP_WATCHDOG_CONTROL_WATCHDOG_TIMEOUT (0xfffffffL<<0)
6105#define BNX2_MCP_WATCHDOG_CONTROL_WATCHDOG_ATTN (1L<<29)
6106#define BNX2_MCP_WATCHDOG_CONTROL_MCP_RST_ENABLE (1L<<30)
6107#define BNX2_MCP_WATCHDOG_CONTROL_WATCHDOG_ENABLE (1L<<31)
6108
6109#define BNX2_MCP_ACCESS_LOCK 0x0014009c
6110#define BNX2_MCP_ACCESS_LOCK_LOCK (1L<<31)
6111
6112#define BNX2_MCP_TOE_ID 0x001400a0
6113#define BNX2_MCP_TOE_ID_FUNCTION_ID (1L<<31)
6114
6115#define BNX2_MCP_MAILBOX_CFG 0x001400a4
6116#define BNX2_MCP_MAILBOX_CFG_MAILBOX_OFFSET (0x3fffL<<0)
6117#define BNX2_MCP_MAILBOX_CFG_MAILBOX_SIZE (0xfffL<<20)
6118
6119#define BNX2_MCP_MAILBOX_CFG_OTHER_FUNC 0x001400a8
6120#define BNX2_MCP_MAILBOX_CFG_OTHER_FUNC_MAILBOX_OFFSET (0x3fffL<<0)
6121#define BNX2_MCP_MAILBOX_CFG_OTHER_FUNC_MAILBOX_SIZE (0xfffL<<20)
6122
6123#define BNX2_MCP_MCP_DOORBELL 0x001400ac
6124#define BNX2_MCP_MCP_DOORBELL_MCP_DOORBELL (1L<<31)
6125
6126#define BNX2_MCP_DRIVER_DOORBELL 0x001400b0
6127#define BNX2_MCP_DRIVER_DOORBELL_DRIVER_DOORBELL (1L<<31)
6128
6129#define BNX2_MCP_DRIVER_DOORBELL_OTHER_FUNC 0x001400b4
6130#define BNX2_MCP_DRIVER_DOORBELL_OTHER_FUNC_DRIVER_DOORBELL (1L<<31)
6131
3587#define BNX2_MCP_CPU_MODE 0x00145000 6132#define BNX2_MCP_CPU_MODE 0x00145000
3588#define BNX2_MCP_CPU_MODE_LOCAL_RST (1L<<0) 6133#define BNX2_MCP_CPU_MODE_LOCAL_RST (1L<<0)
3589#define BNX2_MCP_CPU_MODE_STEP_ENA (1L<<1) 6134#define BNX2_MCP_CPU_MODE_STEP_ENA (1L<<1)
@@ -3603,7 +6148,7 @@ struct l2_fhdr {
3603#define BNX2_MCP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3) 6148#define BNX2_MCP_CPU_STATE_PAGE_0_DATA_HALTED (1L<<3)
3604#define BNX2_MCP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4) 6149#define BNX2_MCP_CPU_STATE_PAGE_0_INST_HALTED (1L<<4)
3605#define BNX2_MCP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5) 6150#define BNX2_MCP_CPU_STATE_BAD_DATA_ADDR_HALTED (1L<<5)
3606#define BNX2_MCP_CPU_STATE_BAD_pc_HALTED (1L<<6) 6151#define BNX2_MCP_CPU_STATE_BAD_PC_HALTED (1L<<6)
3607#define BNX2_MCP_CPU_STATE_ALIGN_HALTED (1L<<7) 6152#define BNX2_MCP_CPU_STATE_ALIGN_HALTED (1L<<7)
3608#define BNX2_MCP_CPU_STATE_FIO_ABORT_HALTED (1L<<8) 6153#define BNX2_MCP_CPU_STATE_FIO_ABORT_HALTED (1L<<8)
3609#define BNX2_MCP_CPU_STATE_SOFT_HALTED (1L<<10) 6154#define BNX2_MCP_CPU_STATE_SOFT_HALTED (1L<<10)
@@ -3651,7 +6196,7 @@ struct l2_fhdr {
3651#define BNX2_MCP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2) 6196#define BNX2_MCP_CPU_LAST_BRANCH_ADDR_LBA (0x3fffffffL<<2)
3652 6197
3653#define BNX2_MCP_CPU_REG_FILE 0x00145200 6198#define BNX2_MCP_CPU_REG_FILE 0x00145200
3654#define BNX2_MCP_MCPQ_FTQ_DATA 0x001453c0 6199#define BNX2_MCP_MCPQ 0x001453c0
3655#define BNX2_MCP_MCPQ_FTQ_CMD 0x001453f8 6200#define BNX2_MCP_MCPQ_FTQ_CMD 0x001453f8
3656#define BNX2_MCP_MCPQ_FTQ_CMD_OFFSET (0x3ffL<<0) 6201#define BNX2_MCP_MCPQ_FTQ_CMD_OFFSET (0x3ffL<<0)
3657#define BNX2_MCP_MCPQ_FTQ_CMD_WR_TOP (1L<<10) 6202#define BNX2_MCP_MCPQ_FTQ_CMD_WR_TOP (1L<<10)
@@ -3696,6 +6241,8 @@ struct l2_fhdr {
3696 6241
3697/* 5708 Serdes PHY registers */ 6242/* 5708 Serdes PHY registers */
3698 6243
6244#define BCM5708S_BMCR_FORCE_2500 0x20
6245
3699#define BCM5708S_UP1 0xb 6246#define BCM5708S_UP1 0xb
3700 6247
3701#define BCM5708S_UP1_2G5 0x1 6248#define BCM5708S_UP1_2G5 0x1
@@ -3804,6 +6351,7 @@ struct l2_fhdr {
3804#define INVALID_CID_ADDR 0xffffffff 6351#define INVALID_CID_ADDR 0xffffffff
3805 6352
3806#define TX_CID 16 6353#define TX_CID 16
6354#define TX_TSS_CID 32
3807#define RX_CID 0 6355#define RX_CID 0
3808 6356
3809#define MB_TX_CID_ADDR MB_GET_CID_ADDR(TX_CID) 6357#define MB_TX_CID_ADDR MB_GET_CID_ADDR(TX_CID)
@@ -3889,6 +6437,8 @@ struct bnx2 {
3889 6437
3890 u32 tx_prod_bseq __attribute__((aligned(L1_CACHE_BYTES))); 6438 u32 tx_prod_bseq __attribute__((aligned(L1_CACHE_BYTES)));
3891 u16 tx_prod; 6439 u16 tx_prod;
6440 u32 tx_bidx_addr;
6441 u32 tx_bseq_addr;
3892 6442
3893 u16 tx_cons __attribute__((aligned(L1_CACHE_BYTES))); 6443 u16 tx_cons __attribute__((aligned(L1_CACHE_BYTES)));
3894 u16 hw_tx_cons; 6444 u16 hw_tx_cons;
@@ -3945,6 +6495,7 @@ struct bnx2 {
3945#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000) 6495#define CHIP_NUM(bp) (((bp)->chip_id) & 0xffff0000)
3946#define CHIP_NUM_5706 0x57060000 6496#define CHIP_NUM_5706 0x57060000
3947#define CHIP_NUM_5708 0x57080000 6497#define CHIP_NUM_5708 0x57080000
6498#define CHIP_NUM_5709 0x57090000
3948 6499
3949#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000) 6500#define CHIP_REV(bp) (((bp)->chip_id) & 0x0000f000)
3950#define CHIP_REV_Ax 0x00000000 6501#define CHIP_REV_Ax 0x00000000
@@ -4007,6 +6558,10 @@ struct bnx2 {
4007 struct statistics_block *stats_blk; 6558 struct statistics_block *stats_blk;
4008 dma_addr_t stats_blk_mapping; 6559 dma_addr_t stats_blk_mapping;
4009 6560
6561 int ctx_pages;
6562 void *ctx_blk[4];
6563 dma_addr_t ctx_blk_mapping[4];
6564
4010 u32 hc_cmd; 6565 u32 hc_cmd;
4011 u32 rx_mode; 6566 u32 rx_mode;
4012 6567
@@ -4038,6 +6593,7 @@ struct bnx2 {
4038 6593
4039 u8 serdes_an_pending; 6594 u8 serdes_an_pending;
4040#define SERDES_AN_TIMEOUT (HZ / 3) 6595#define SERDES_AN_TIMEOUT (HZ / 3)
6596#define SERDES_FORCED_TIMEOUT (HZ / 10)
4041 6597
4042 u8 mac_addr[8]; 6598 u8 mac_addr[8];
4043 6599
@@ -4104,41 +6660,43 @@ struct cpu_reg {
4104}; 6660};
4105 6661
4106struct fw_info { 6662struct fw_info {
4107 u32 ver_major; 6663 const u32 ver_major;
4108 u32 ver_minor; 6664 const u32 ver_minor;
4109 u32 ver_fix; 6665 const u32 ver_fix;
4110 6666
4111 u32 start_addr; 6667 const u32 start_addr;
4112 6668
4113 /* Text section. */ 6669 /* Text section. */
4114 u32 text_addr; 6670 const u32 text_addr;
4115 u32 text_len; 6671 const u32 text_len;
4116 u32 text_index; 6672 const u32 text_index;
4117 u32 *text; 6673 u32 *text;
6674 u8 *gz_text;
6675 const u32 gz_text_len;
4118 6676
4119 /* Data section. */ 6677 /* Data section. */
4120 u32 data_addr; 6678 const u32 data_addr;
4121 u32 data_len; 6679 const u32 data_len;
4122 u32 data_index; 6680 const u32 data_index;
4123 u32 *data; 6681 const u32 *data;
4124 6682
4125 /* SBSS section. */ 6683 /* SBSS section. */
4126 u32 sbss_addr; 6684 const u32 sbss_addr;
4127 u32 sbss_len; 6685 const u32 sbss_len;
4128 u32 sbss_index; 6686 const u32 sbss_index;
4129 u32 *sbss; 6687 const u32 *sbss;
4130 6688
4131 /* BSS section. */ 6689 /* BSS section. */
4132 u32 bss_addr; 6690 const u32 bss_addr;
4133 u32 bss_len; 6691 const u32 bss_len;
4134 u32 bss_index; 6692 const u32 bss_index;
4135 u32 *bss; 6693 const u32 *bss;
4136 6694
4137 /* Read-only section. */ 6695 /* Read-only section. */
4138 u32 rodata_addr; 6696 const u32 rodata_addr;
4139 u32 rodata_len; 6697 const u32 rodata_len;
4140 u32 rodata_index; 6698 const u32 rodata_index;
4141 u32 *rodata; 6699 const u32 *rodata;
4142}; 6700};
4143 6701
4144#define RV2P_PROC1 0 6702#define RV2P_PROC1 0
diff --git a/drivers/net/bnx2_fw.h b/drivers/net/bnx2_fw.h
index 2d753dca0d75..21d368ff424d 100644
--- a/drivers/net/bnx2_fw.h
+++ b/drivers/net/bnx2_fw.h
@@ -14,20 +14,6 @@
14 * accompanying it. 14 * accompanying it.
15 */ 15 */
16 16
17static const int bnx2_COM_b06FwReleaseMajor = 0x1;
18static const int bnx2_COM_b06FwReleaseMinor = 0x0;
19static const int bnx2_COM_b06FwReleaseFix = 0x0;
20static const u32 bnx2_COM_b06FwStartAddr = 0x080008b4;
21static const u32 bnx2_COM_b06FwTextAddr = 0x08000000;
22static const int bnx2_COM_b06FwTextLen = 0x57bc;
23static const u32 bnx2_COM_b06FwDataAddr = 0x08005840;
24static const int bnx2_COM_b06FwDataLen = 0x0;
25static const u32 bnx2_COM_b06FwRodataAddr = 0x080057c0;
26static const int bnx2_COM_b06FwRodataLen = 0x58;
27static const u32 bnx2_COM_b06FwBssAddr = 0x08005860;
28static const int bnx2_COM_b06FwBssLen = 0x88;
29static const u32 bnx2_COM_b06FwSbssAddr = 0x08005840;
30static const int bnx2_COM_b06FwSbssLen = 0x1c;
31static u8 bnx2_COM_b06FwText[] = { 17static u8 bnx2_COM_b06FwText[] = {
32 0x1f, 0x8b, 0x08, 0x08, 0x09, 0x83, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 18 0x1f, 0x8b, 0x08, 0x08, 0x09, 0x83, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
33 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5b, 0x7d, 0x6c, 19 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5b, 0x7d, 0x6c,
@@ -673,389 +659,752 @@ static u32 bnx2_COM_b06FwRodata[(0x58/4) + 1] = {
673static u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x0 }; 659static u32 bnx2_COM_b06FwBss[(0x88/4) + 1] = { 0x0 };
674static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x0 }; 660static u32 bnx2_COM_b06FwSbss[(0x1c/4) + 1] = { 0x0 };
675 661
676static int bnx2_RXP_b06FwReleaseMajor = 0x1; 662static struct fw_info bnx2_com_fw_06 = {
677static int bnx2_RXP_b06FwReleaseMinor = 0x0; 663 .ver_major = 0x1,
678static int bnx2_RXP_b06FwReleaseFix = 0x0; 664 .ver_minor = 0x0,
679static u32 bnx2_RXP_b06FwStartAddr = 0x08003184; 665 .ver_fix = 0x0,
680static u32 bnx2_RXP_b06FwTextAddr = 0x08000000; 666
681static int bnx2_RXP_b06FwTextLen = 0x588c; 667 .start_addr = 0x080008b4,
682static u32 bnx2_RXP_b06FwDataAddr = 0x080058e0; 668
683static int bnx2_RXP_b06FwDataLen = 0x0; 669 .text_addr = 0x08000000,
684static u32 bnx2_RXP_b06FwRodataAddr = 0x08005890; 670 .text_len = 0x57bc,
685static int bnx2_RXP_b06FwRodataLen = 0x28; 671 .text_index = 0x0,
686static u32 bnx2_RXP_b06FwBssAddr = 0x08005900; 672 .gz_text = bnx2_COM_b06FwText,
687static int bnx2_RXP_b06FwBssLen = 0x13a4; 673 .gz_text_len = sizeof(bnx2_COM_b06FwText),
688static u32 bnx2_RXP_b06FwSbssAddr = 0x080058e0; 674
689static int bnx2_RXP_b06FwSbssLen = 0x1c; 675 .data_addr = 0x08005840,
676 .data_len = 0x0,
677 .data_index = 0x0,
678 .data = bnx2_COM_b06FwData,
679
680 .sbss_addr = 0x08005840,
681 .sbss_len = 0x1c,
682 .sbss_index = 0x0,
683 .sbss = bnx2_COM_b06FwSbss,
684
685 .bss_addr = 0x08005860,
686 .bss_len = 0x88,
687 .bss_index = 0x0,
688 .bss = bnx2_COM_b06FwBss,
689
690 .rodata_addr = 0x080057c0,
691 .rodata_len = 0x58,
692 .rodata_index = 0x0,
693 .rodata = bnx2_COM_b06FwRodata,
694};
695
690static u8 bnx2_RXP_b06FwText[] = { 696static u8 bnx2_RXP_b06FwText[] = {
691 0x1f, 0x8b, 0x08, 0x08, 0x07, 0x87, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 697 0x1f, 0x8b, 0x08, 0x08, 0xcb, 0xa3, 0x46, 0x45, 0x00, 0x03, 0x74, 0x65,
692 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xed, 0x5c, 0x5d, 0x6c, 698 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5c, 0x6f, 0x6c,
693 0x1c, 0xd7, 0x75, 0x3e, 0xf3, 0x43, 0x71, 0x49, 0x91, 0xd4, 0x70, 0xb9, 699 0x1c, 0xc7, 0x75, 0x7f, 0x3b, 0xbb, 0xa4, 0x4e, 0xd4, 0x91, 0x5c, 0x1e,
694 0x62, 0x57, 0x12, 0x65, 0xed, 0x8a, 0x43, 0x71, 0x6d, 0x31, 0xce, 0x50, 700 0x4f, 0xf4, 0x49, 0x66, 0x94, 0x5d, 0x71, 0x25, 0x5e, 0x2d, 0xc6, 0x5d,
695 0x58, 0xdb, 0x82, 0xb1, 0x48, 0xc7, 0xb3, 0xa4, 0xc8, 0x24, 0x02, 0x42, 701 0x31, 0x57, 0x9b, 0x08, 0xce, 0xf1, 0x79, 0xef, 0x64, 0xb1, 0x86, 0x0a,
696 0x1b, 0x42, 0xab, 0xa4, 0xa9, 0xc1, 0x90, 0x72, 0x91, 0x22, 0x2c, 0xa0, 702 0x51, 0x0d, 0x1d, 0x1b, 0x85, 0x6b, 0xb0, 0x47, 0x39, 0xae, 0xdb, 0x7e,
697 0x1a, 0x79, 0xf0, 0x43, 0x10, 0x2f, 0x56, 0x3f, 0xa6, 0xd1, 0x8d, 0x96, 703 0x90, 0x65, 0x1b, 0x30, 0xda, 0x10, 0xbe, 0x1c, 0xe9, 0x46, 0x75, 0x2f,
698 0xb6, 0x1c, 0x53, 0x08, 0x82, 0x82, 0xe5, 0x52, 0x52, 0x0b, 0x2c, 0xb4, 704 0xdc, 0x8b, 0xc4, 0x98, 0x06, 0xfa, 0x07, 0x57, 0x92, 0xfa, 0x83, 0xe0,
699 0x96, 0xed, 0x36, 0x7e, 0xa8, 0x23, 0x9a, 0x92, 0x8d, 0xa6, 0x68, 0x81, 705 0xa0, 0x93, 0xe2, 0x26, 0xf5, 0x17, 0x57, 0x84, 0x2a, 0xc7, 0xf9, 0xe0,
700 0x22, 0xad, 0xd1, 0xf4, 0x4d, 0x95, 0x9a, 0x4a, 0x75, 0x5f, 0xd4, 0xa2, 706 0x02, 0x4e, 0x63, 0x20, 0x06, 0xea, 0x16, 0xaa, 0xec, 0xd8, 0x46, 0x81,
701 0x48, 0xda, 0x46, 0xcd, 0xf4, 0xfb, 0xee, 0xcc, 0x88, 0xd4, 0x9a, 0xb2, 707 0xa2, 0x42, 0x1c, 0xd8, 0x46, 0xfc, 0x67, 0xfb, 0x7b, 0x33, 0xbb, 0xd4,
702 0x2c, 0x3b, 0x0d, 0x62, 0x74, 0x0e, 0x30, 0xd8, 0xb9, 0x7f, 0xe7, 0xef, 708 0x91, 0x96, 0x6d, 0xa0, 0x1f, 0xfa, 0xa5, 0x3b, 0xc0, 0x61, 0x67, 0x66,
703 0x9e, 0x73, 0xee, 0x39, 0x77, 0x28, 0x7d, 0xa5, 0x43, 0xda, 0x25, 0x84, 709 0xe7, 0xbd, 0x79, 0xf3, 0xfe, 0xbf, 0x59, 0x4a, 0x7f, 0x90, 0xa4, 0x2e,
704 0x4e, 0x3c, 0x99, 0xc3, 0xcf, 0x3c, 0xfd, 0xe0, 0xc3, 0x0f, 0xee, 0xc1, 710 0x0a, 0x5b, 0x37, 0x7e, 0xd6, 0x91, 0xc7, 0x8f, 0xde, 0x3c, 0x76, 0xf3,
705 0xeb, 0xb0, 0xa1, 0x6d, 0xd0, 0xa3, 0xfe, 0x18, 0x62, 0x88, 0x21, 0x86, 711 0x28, 0xd1, 0x97, 0x47, 0xf5, 0x1b, 0x12, 0x22, 0x9a, 0x8f, 0x5b, 0xdc,
706 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 712 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2,
707 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 713 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16,
708 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 714 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7,
709 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0x18, 0x62, 0x88, 715 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8,
710 0x21, 0x86, 0x18, 0x62, 0x88, 0x21, 0x86, 0xff, 0xef, 0x60, 0x88, 0x58, 716 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5,
711 0xfc, 0xed, 0x0c, 0x1f, 0x49, 0xe8, 0x85, 0xcb, 0x07, 0x3d, 0x5b, 0x12, 717 0x2d, 0x6e, 0x71, 0xfb, 0xff, 0xde, 0x74, 0x22, 0x93, 0x9f, 0xdd, 0xe1,
712 0x46, 0x61, 0x69, 0x66, 0xda, 0x16, 0x71, 0xeb, 0xbb, 0x33, 0x45, 0xf9, 718 0x8f, 0x12, 0x22, 0xbf, 0xfa, 0x90, 0xe7, 0x50, 0x42, 0xcf, 0xbf, 0x34,
713 0x1f, 0xbf, 0x94, 0x32, 0x85, 0xfd, 0xdb, 0x0b, 0x37, 0x9f, 0x7d, 0xf3, 719 0x33, 0xed, 0x10, 0x15, 0x9a, 0x7b, 0xac, 0x22, 0x7d, 0x14, 0x54, 0xd2,
714 0x91, 0xec, 0x8d, 0x05, 0x43, 0x12, 0x56, 0xe1, 0xe8, 0xb0, 0xb5, 0x4b, 720 0x06, 0xf1, 0xfc, 0x17, 0xf2, 0x1f, 0x3e, 0xf1, 0xfc, 0xad, 0xf6, 0xd5,
715 0x12, 0x7d, 0x58, 0xf3, 0xdd, 0xc1, 0xcf, 0x59, 0xd2, 0x15, 0xe1, 0xba, 721 0x86, 0x4e, 0x09, 0x33, 0x3f, 0xb7, 0xd7, 0xdc, 0x4d, 0x89, 0x41, 0xc0,
716 0xee, 0xbf, 0x39, 0x68, 0xc9, 0x2b, 0x8d, 0x94, 0x5c, 0x68, 0x6c, 0xdf, 722 0xfc, 0xf5, 0xf0, 0x7f, 0xf4, 0x50, 0x0f, 0x5d, 0xc3, 0xe3, 0x24, 0xe8,
717 0x24, 0x5d, 0xd9, 0x52, 0x09, 0xfd, 0x6e, 0x8a, 0xe3, 0x96, 0x94, 0xab, 723 0xb2, 0xfe, 0x9c, 0xe6, 0xb5, 0x82, 0xe0, 0xa4, 0x1b, 0x04, 0x3f, 0xc6,
718 0x2d, 0xe2, 0x2a, 0xba, 0x7d, 0x5a, 0x71, 0xfe, 0x3e, 0xcd, 0x9b, 0x7f, 724 0xef, 0x2d, 0x17, 0x63, 0xff, 0xe3, 0xa0, 0x60, 0xe8, 0x24, 0x9c, 0xbf,
719 0x9e, 0xff, 0x1e, 0x24, 0xa5, 0xcb, 0x7d, 0x68, 0xf7, 0xa1, 0xcd, 0xf7, 725 0xd4, 0xbc, 0xe5, 0x2e, 0xaa, 0x2e, 0x1a, 0x34, 0xeb, 0xa7, 0xe9, 0x98,
720 0x81, 0xf4, 0x94, 0x98, 0x72, 0xa4, 0x91, 0x90, 0xa3, 0xd5, 0x8c, 0xe8, 726 0x5f, 0xd1, 0x4a, 0xad, 0x9a, 0xb6, 0xef, 0xf4, 0xbc, 0x76, 0xe7, 0xe9,
721 0x05, 0x71, 0xbd, 0xbc, 0x9d, 0x2e, 0xa3, 0x6f, 0xea, 0x00, 0xdb, 0x29, 727 0x63, 0xda, 0xfe, 0xd3, 0x75, 0xcd, 0x3b, 0x4d, 0x15, 0xb1, 0x37, 0x49,
722 0xe0, 0xf9, 0x0e, 0xd7, 0x59, 0x5e, 0x5e, 0x4a, 0xb7, 0xc6, 0x14, 0x0d, 728 0x05, 0xf3, 0x8c, 0x56, 0x6c, 0x0d, 0x68, 0xde, 0x89, 0x0f, 0xc9, 0x73,
723 0x8e, 0xb1, 0x0f, 0xbf, 0x58, 0x5f, 0xae, 0x76, 0x00, 0x6f, 0xd6, 0x71, 729 0x6d, 0xf3, 0xf7, 0xc8, 0x28, 0x80, 0x16, 0xf2, 0x6a, 0x41, 0xe0, 0xb9,
724 0x41, 0xdc, 0x73, 0x2c, 0xd0, 0xf6, 0xfd, 0xdf, 0x75, 0x32, 0xb2, 0xe2, 730 0x06, 0x15, 0xd2, 0x41, 0x20, 0xf2, 0xc1, 0x13, 0x5e, 0xce, 0x31, 0x85,
725 0x74, 0x81, 0xa7, 0x16, 0x69, 0xb5, 0xc5, 0xd2, 0x0b, 0xb6, 0xb5, 0x22, 731 0x96, 0xa6, 0x6a, 0x6b, 0x00, 0x78, 0x93, 0x5a, 0x71, 0xd1, 0xd0, 0x4a,
726 0x6d, 0x1c, 0xeb, 0x34, 0x0a, 0xbe, 0x3f, 0x9d, 0x97, 0xae, 0xa0, 0x6f, 732 0x7e, 0x70, 0xc1, 0x73, 0x69, 0x50, 0xa7, 0x20, 0x98, 0x73, 0x77, 0x65,
727 0xb7, 0xe2, 0x63, 0x72, 0x42, 0xc3, 0xbc, 0x57, 0x49, 0x0f, 0x3a, 0xe2, 733 0x0e, 0xd3, 0x29, 0xe0, 0x6d, 0x02, 0x1f, 0x99, 0x22, 0xcf, 0xf4, 0x31,
728 0x3b, 0x7f, 0xf3, 0x52, 0xac, 0x6c, 0x97, 0xc9, 0x54, 0xf6, 0xa0, 0x1b, 734 0x9d, 0x4c, 0x72, 0x45, 0x2b, 0x0e, 0x47, 0xf4, 0x91, 0xc5, 0xf4, 0x97,
729 0xd0, 0x74, 0x3d, 0x67, 0x2b, 0x70, 0x6a, 0xe0, 0x4f, 0xdb, 0x81, 0xf5, 735 0x57, 0x04, 0xe8, 0xdc, 0x42, 0xe5, 0x86, 0x49, 0x53, 0x2b, 0x1b, 0xd7,
730 0xee, 0x0a, 0x68, 0x1a, 0x85, 0xcd, 0x62, 0x6c, 0x66, 0x9f, 0xe8, 0x3b, 736 0x5f, 0x0e, 0x9e, 0x1f, 0x36, 0xe9, 0x5c, 0xcb, 0xae, 0x54, 0x28, 0x41,
731 0x87, 0x93, 0xe1, 0x78, 0x97, 0x36, 0x32, 0x6f, 0x88, 0x6e, 0xff, 0x81, 737 0x73, 0xbe, 0x45, 0x22, 0x4f, 0x05, 0x2f, 0x37, 0x48, 0x17, 0x5a, 0x19,
732 0xe6, 0xd5, 0x7a, 0xe5, 0xd8, 0xbc, 0x8e, 0x77, 0x5d, 0xae, 0xe6, 0x4b, 738 0xfa, 0x41, 0xcb, 0xc9, 0x54, 0x69, 0x13, 0x95, 0xd3, 0x69, 0x3a, 0xdf,
733 0x9a, 0xdb, 0xa8, 0x68, 0xde, 0xd9, 0x59, 0xad, 0x78, 0xd6, 0x94, 0xa3, 739 0x4a, 0xe3, 0x8c, 0xc1, 0x05, 0xe1, 0x38, 0x66, 0x15, 0x6b, 0xab, 0xad,
734 0xb6, 0x7f, 0xe1, 0xb4, 0x73, 0x42, 0x1b, 0x39, 0x7b, 0x46, 0x1b, 0x3d, 740 0x97, 0xf8, 0xdf, 0xbf, 0x98, 0xd3, 0x39, 0x09, 0x53, 0x01, 0xdd, 0xe1,
735 0xfb, 0x86, 0x36, 0xde, 0xd8, 0xb2, 0x49, 0xda, 0xb3, 0xd0, 0x1e, 0x71, 741 0x5a, 0x3e, 0x87, 0x5c, 0x2b, 0xcf, 0xa2, 0xd6, 0x52, 0x65, 0x3a, 0x87,
736 0x90, 0xbf, 0x4f, 0x87, 0xba, 0xec, 0xa2, 0xde, 0x4a, 0xe4, 0x7d, 0x9f, 742 0xb9, 0xd6, 0x1d, 0x6b, 0xfc, 0x2d, 0xa4, 0xf9, 0x69, 0x52, 0xd5, 0xef,
737 0xf3, 0x86, 0xe6, 0x55, 0x6d, 0x8b, 0xfb, 0xe6, 0xa6, 0x22, 0x1a, 0xed, 743 0x00, 0x6f, 0xb8, 0x3f, 0x88, 0xb3, 0xee, 0xd0, 0xbc, 0xc5, 0x7f, 0x65,
738 0x72, 0x74, 0xde, 0x94, 0x63, 0xd5, 0x94, 0x3c, 0x57, 0x2d, 0x29, 0x5a, 744 0xbc, 0x69, 0x41, 0x3b, 0x30, 0x1e, 0xc4, 0x98, 0xfb, 0xbb, 0x32, 0x65,
739 0x86, 0x5d, 0xd2, 0xbc, 0x06, 0xc7, 0x2b, 0xa0, 0x75, 0x42, 0xdb, 0x07, 745 0x02, 0x8f, 0x5b, 0x49, 0x8c, 0x99, 0xce, 0x20, 0xd8, 0xef, 0x92, 0x59,
740 0x9a, 0xde, 0x59, 0x29, 0x5d, 0x71, 0xe6, 0x40, 0xaf, 0x03, 0x78, 0xff, 746 0x75, 0x7b, 0x01, 0x6b, 0x51, 0xd5, 0xed, 0x01, 0xbe, 0x0e, 0xea, 0x73,
741 0x58, 0x1b, 0x6d, 0xf4, 0x6a, 0xde, 0xc9, 0x9b, 0xe2, 0x39, 0x59, 0xeb, 747 0xf8, 0x7c, 0xbc, 0xe7, 0x66, 0xcc, 0x07, 0xdd, 0x7a, 0x3e, 0x08, 0xa6,
742 0x4b, 0x62, 0xba, 0xb0, 0x01, 0xc8, 0x0c, 0xfd, 0x38, 0xd0, 0x49, 0xca, 748 0x73, 0xd4, 0xa3, 0xe6, 0xf6, 0x48, 0x1c, 0x53, 0x13, 0x1a, 0xd6, 0xbd,
743 0xf7, 0xf5, 0x82, 0xff, 0x2c, 0x74, 0x6f, 0x5d, 0xa1, 0xfc, 0x8d, 0x5e, 749 0xc3, 0x7b, 0x24, 0x52, 0x79, 0xee, 0xf3, 0x33, 0x47, 0xde, 0xfc, 0x8e,
744 0x29, 0xcf, 0x53, 0xd7, 0xa6, 0x36, 0x52, 0xf5, 0x2f, 0x78, 0x8e, 0xf4, 750 0x90, 0xa6, 0x0c, 0x68, 0xba, 0x31, 0xec, 0x43, 0x0e, 0x3e, 0xf8, 0xe1,
745 0x19, 0xe2, 0xfb, 0x47, 0x9d, 0x81, 0xf4, 0x21, 0x39, 0x03, 0xdc, 0x75, 751 0xde, 0x80, 0xb1, 0xf6, 0x45, 0xe0, 0xc9, 0x56, 0x89, 0xf7, 0xe8, 0xa7,
746 0xad, 0xd8, 0xa0, 0xae, 0xc1, 0xdf, 0x2d, 0x39, 0x02, 0xbd, 0x15, 0x9d, 752 0xa5, 0x34, 0x89, 0x2b, 0x6e, 0x5f, 0xb8, 0xae, 0x07, 0xb4, 0x46, 0xfa,
747 0x5e, 0x99, 0xb4, 0xb2, 0x2e, 0xf6, 0x68, 0x53, 0x20, 0x57, 0x32, 0xb4, 753 0x30, 0x40, 0x73, 0x8b, 0xcc, 0xf3, 0x1a, 0x64, 0x24, 0x68, 0xe7, 0x2d,
748 0x17, 0xd2, 0xe7, 0xde, 0x67, 0xd3, 0x9e, 0xa1, 0xcb, 0x53, 0x2f, 0x3d, 754 0x15, 0xad, 0xd0, 0x3a, 0x86, 0xbe, 0x41, 0xd3, 0x4e, 0x70, 0x61, 0xce,
749 0xdf, 0xb3, 0x38, 0xb4, 0x91, 0x32, 0x43, 0xff, 0xf2, 0x45, 0xcf, 0xf6, 755 0x9d, 0xd7, 0x8a, 0xa7, 0x4f, 0x69, 0xa5, 0xd3, 0xcf, 0x69, 0xfb, 0x5a,
750 0xb6, 0xb4, 0x48, 0x29, 0x6d, 0x48, 0x16, 0xfb, 0xb4, 0x43, 0x4e, 0x3b, 756 0x2f, 0x76, 0x53, 0x97, 0x8d, 0xd3, 0x27, 0xe8, 0x49, 0x5f, 0x23, 0xa6,
751 0x22, 0x87, 0x2a, 0xd0, 0x8d, 0x6d, 0x5a, 0x8b, 0x62, 0x67, 0xca, 0x32, 757 0x73, 0x09, 0x3c, 0x2c, 0x98, 0x15, 0x32, 0x9c, 0x1e, 0xed, 0x4e, 0xe0,
752 0x50, 0x32, 0x75, 0x74, 0x26, 0x49, 0x97, 0x3a, 0xd2, 0xe5, 0x7a, 0x9e, 758 0xe9, 0x70, 0xfe, 0x2c, 0x49, 0x3d, 0x3a, 0x6d, 0x72, 0xa2, 0xb5, 0x69,
753 0x7a, 0xa2, 0x3d, 0x7f, 0x28, 0x5d, 0x69, 0xab, 0xba, 0x5a, 0xd5, 0xd3, 759 0xfa, 0x73, 0xd0, 0x74, 0xd1, 0xdd, 0xca, 0x7c, 0xeb, 0x55, 0x30, 0xa9,
754 0xf8, 0x2f, 0x5d, 0x4f, 0xd4, 0xc9, 0x72, 0x28, 0xb7, 0x03, 0xdc, 0x8f, 760 0x90, 0x0e, 0xd6, 0x2f, 0x96, 0x9f, 0x6d, 0x7a, 0xba, 0xa0, 0xd2, 0xc2,
755 0x40, 0x5f, 0xe2, 0xea, 0xc3, 0x0f, 0xb1, 0x6f, 0x93, 0x51, 0xb0, 0xd3, 761 0x5f, 0xf4, 0x57, 0x47, 0xb6, 0xf0, 0x3a, 0xd8, 0xc2, 0xd5, 0x87, 0xa6,
756 0x17, 0x61, 0x14, 0x7a, 0x61, 0x37, 0x64, 0x19, 0xa6, 0xee, 0xe0, 0xc3, 762 0x1d, 0xaf, 0xcf, 0xa0, 0x8a, 0x29, 0xc8, 0x36, 0x8b, 0xf4, 0x45, 0x9a,
757 0x1f, 0x49, 0x5e, 0xf9, 0xd5, 0x90, 0x97, 0xfc, 0xdb, 0x32, 0x55, 0x49, 763 0x73, 0x89, 0x8a, 0x35, 0xec, 0xeb, 0x18, 0xe0, 0x8f, 0x03, 0xfe, 0xec,
758 0x80, 0x06, 0x65, 0xd4, 0xe5, 0xbd, 0x7c, 0x64, 0x1b, 0x7b, 0x20, 0x5f, 764 0xaa, 0xe8, 0xe2, 0x1e, 0xa0, 0xa9, 0x68, 0x46, 0xc8, 0xcb, 0x25, 0xba,
759 0x5e, 0xa6, 0xbe, 0x45, 0x7f, 0xa2, 0xfd, 0xf3, 0x9d, 0xb2, 0xfe, 0xcc, 765 0x4b, 0xc2, 0x8b, 0xbc, 0x0b, 0x5d, 0xed, 0xe2, 0x3e, 0xf6, 0x4e, 0xc8,
760 0xbf, 0xee, 0x7c, 0x92, 0xf6, 0x96, 0x7c, 0x27, 0xe4, 0x78, 0x35, 0xc9, 766 0xbd, 0xf5, 0xbc, 0x93, 0x59, 0x26, 0xd2, 0x44, 0x7e, 0x0f, 0xf0, 0xb1,
761 0x3d, 0xd4, 0x56, 0x54, 0x6c, 0x8a, 0x64, 0x14, 0xdd, 0x28, 0x74, 0x48, 767 0x0e, 0xf3, 0xba, 0x79, 0xd0, 0xc9, 0xf4, 0x73, 0xdf, 0x01, 0x4c, 0x02,
762 0x51, 0xed, 0xf7, 0x5e, 0xd0, 0x43, 0x2c, 0xa8, 0xf2, 0xbd, 0xa0, 0x64, 768 0xfa, 0xde, 0xdd, 0x46, 0x2b, 0xe8, 0x49, 0x33, 0xbf, 0x99, 0x7f, 0xf2,
763 0x9b, 0xb6, 0xed, 0xcc, 0x11, 0xc9, 0xc2, 0xbe, 0x45, 0x8e, 0xcc, 0x99, 769 0xac, 0xda, 0xb5, 0xb3, 0x7e, 0x10, 0x0c, 0x8f, 0x1a, 0xf4, 0x63, 0x79,
764 0x32, 0x6d, 0xff, 0x63, 0xa7, 0xb4, 0x2f, 0xdf, 0x6f, 0xa8, 0xb8, 0xae, 770 0x66, 0xb6, 0x37, 0x5e, 0x97, 0x0e, 0xf5, 0x23, 0x01, 0x9d, 0x22, 0xad,
765 0xf7, 0x6e, 0x90, 0x4d, 0xe0, 0x77, 0xf9, 0x7e, 0x5d, 0xe4, 0xa6, 0x59, 771 0xec, 0x9a, 0x6b, 0xb8, 0xca, 0x44, 0x42, 0xcf, 0x27, 0xa9, 0x28, 0xe9,
766 0xc8, 0x5a, 0x23, 0x08, 0xf6, 0x46, 0x81, 0xb1, 0x4c, 0x43, 0x2c, 0x93, 772 0x1b, 0xc3, 0x5e, 0x6c, 0x87, 0xb0, 0x27, 0x87, 0xcf, 0xc2, 0x73, 0x79,
767 0x44, 0x8b, 0x4d, 0x7d, 0xf9, 0xfe, 0xf8, 0xf0, 0xdd, 0xf5, 0x75, 0x64, 773 0xd8, 0xbb, 0xcd, 0x7d, 0x2a, 0xd7, 0xd9, 0xf6, 0x99, 0xb6, 0x55, 0x5b,
768 0x9e, 0xb4, 0xa9, 0x2f, 0xc6, 0xa8, 0x12, 0xf4, 0xc1, 0xf8, 0x74, 0xbb, 774 0xfe, 0xd3, 0x2c, 0x89, 0x4f, 0x0c, 0xe8, 0xd4, 0x4b, 0x13, 0xee, 0x87,
769 0xae, 0x8a, 0xa1, 0xae, 0x46, 0xfe, 0xef, 0xed, 0xc2, 0xf5, 0xaa, 0xa2, 775 0x81, 0xd8, 0x8d, 0xf7, 0x23, 0x19, 0xd0, 0x66, 0x5b, 0xb0, 0xca, 0x94,
770 0x79, 0xce, 0xbb, 0xa1, 0x2f, 0xd8, 0x32, 0x02, 0x7f, 0x37, 0xec, 0x4f, 776 0x4e, 0x1a, 0xe8, 0xde, 0x93, 0x31, 0xc9, 0xc1, 0xd9, 0xc0, 0xdf, 0x89,
771 0xcb, 0x91, 0x54, 0x76, 0xc2, 0x95, 0xc0, 0xe6, 0xaf, 0xad, 0xb1, 0xf9, 777 0x55, 0x30, 0xff, 0xd3, 0xe8, 0x54, 0x78, 0x41, 0x66, 0xc1, 0x03, 0x8d,
772 0xd1, 0xbb, 0xc8, 0x75, 0x3c, 0x94, 0xcb, 0x0d, 0xe5, 0x1a, 0x85, 0x5c, 778 0x9e, 0xfb, 0x65, 0xc9, 0x33, 0x13, 0xe7, 0xd7, 0xe7, 0x99, 0xbf, 0x5d,
773 0x63, 0x90, 0x6b, 0xe5, 0x23, 0xc8, 0xb5, 0xf2, 0x91, 0xe5, 0xd2, 0xa4, 779 0xb0, 0x0b, 0x8d, 0xca, 0x2e, 0xe3, 0x8e, 0x70, 0x08, 0x1a, 0xbe, 0xa5,
774 0xec, 0x3c, 0x08, 0x5a, 0xa6, 0xfc, 0xab, 0x13, 0xd8, 0xf2, 0xbf, 0x38, 780 0x1d, 0x47, 0x24, 0x5f, 0xd6, 0x5d, 0x83, 0x46, 0x47, 0x79, 0x2d, 0xaf,
775 0x9f, 0x14, 0x19, 0x7c, 0x7f, 0x70, 0xd8, 0x16, 0xef, 0x5b, 0xe0, 0xd5, 781 0xe3, 0xf5, 0xf6, 0x98, 0x25, 0x3e, 0x08, 0xf6, 0xae, 0xdb, 0xd3, 0x21,
776 0x71, 0x40, 0x8b, 0xef, 0xef, 0x97, 0xe1, 0x6e, 0xfe, 0x38, 0x8b, 0x7d, 782 0x31, 0x0f, 0x9a, 0x95, 0x2c, 0xc0, 0xc3, 0xcf, 0x5b, 0xcb, 0x72, 0xd8,
777 0x5d, 0xcf, 0x1f, 0x29, 0x87, 0x3e, 0x7c, 0xef, 0xfe, 0xa8, 0x6b, 0x1f, 783 0xc8, 0x6f, 0x5e, 0xdb, 0xbe, 0x0e, 0xfa, 0x3c, 0xc0, 0x34, 0x9c, 0x4c,
778 0x55, 0x0e, 0xc6, 0x9c, 0x4f, 0x35, 0x9d, 0xab, 0x1f, 0x56, 0x86, 0xf5, 784 0x2a, 0x3b, 0x8d, 0x68, 0x8a, 0x64, 0xa9, 0x85, 0x38, 0x3e, 0xeb, 0x1c,
779 0x63, 0xca, 0x2f, 0x4f, 0x86, 0xc7, 0x64, 0x72, 0x33, 0xed, 0xa9, 0xa4, 785 0xbc, 0x1e, 0xfe, 0xc3, 0x87, 0xff, 0x80, 0x4f, 0x3c, 0xef, 0xc3, 0xbf,
780 0x8d, 0x0c, 0x92, 0xef, 0xb5, 0xfc, 0x4a, 0x26, 0xe0, 0x0d, 0x39, 0xd1, 786 0xf8, 0xec, 0x6f, 0x2c, 0x7a, 0x7e, 0x18, 0xfe, 0xf1, 0x9a, 0x7f, 0x42,
781 0xd2, 0x46, 0x39, 0xb2, 0x60, 0x49, 0x69, 0xe9, 0x4e, 0x71, 0x57, 0x03, 787 0x1b, 0x47, 0x5f, 0x90, 0x0e, 0xff, 0x34, 0xdb, 0x10, 0xb0, 0x73, 0xf8,
782 0x6f, 0xb4, 0x47, 0xf6, 0x7d, 0xd2, 0x7c, 0x2a, 0xc8, 0x2b, 0x2e, 0x54, 788 0x8a, 0x15, 0x9e, 0x83, 0x5f, 0x58, 0x29, 0xe1, 0xe9, 0x50, 0xb5, 0xc9,
783 0x91, 0x83, 0x56, 0x13, 0x72, 0xd9, 0x48, 0xcb, 0x9b, 0x83, 0x87, 0xe5, 789 0x7a, 0x18, 0xf9, 0x61, 0xf6, 0x57, 0x19, 0xf8, 0x26, 0xf6, 0x47, 0xec,
784 0xf3, 0xd5, 0x24, 0xe8, 0x31, 0x9f, 0x2c, 0xe7, 0x10, 0x17, 0xb5, 0xb2, 790 0xb7, 0x78, 0x6d, 0x10, 0x94, 0x5c, 0x86, 0x0d, 0x20, 0x47, 0xb6, 0xbb,
785 0x63, 0x08, 0x79, 0xaf, 0xd9, 0x9c, 0x13, 0xc4, 0x96, 0x72, 0x10, 0x83, 791 0x24, 0x89, 0x54, 0x45, 0x3b, 0x34, 0x0c, 0x7b, 0xbc, 0x89, 0x7d, 0x0b,
786 0x5d, 0x6f, 0x50, 0xe5, 0x14, 0x90, 0x4f, 0x64, 0x0c, 0xb1, 0xb7, 0x66, 792 0xdb, 0xe5, 0x8d, 0x44, 0x9d, 0xbc, 0xdf, 0xaf, 0xbb, 0xd5, 0xbf, 0xd9,
787 0xb3, 0xcd, 0xfe, 0xa0, 0xef, 0xb3, 0x95, 0x5e, 0xad, 0xc8, 0xbc, 0x64, 793 0xdb, 0x84, 0x35, 0xf2, 0xd9, 0xa3, 0xc6, 0x66, 0xe8, 0x97, 0xf8, 0xbd,
788 0xf0, 0xa6, 0x4c, 0x3b, 0x41, 0xdf, 0xe7, 0x2a, 0xa3, 0x9b, 0x98, 0x1f, 794 0x6d, 0x15, 0x68, 0x57, 0x38, 0xe6, 0xfe, 0x1a, 0xbd, 0xae, 0xb8, 0x25,
789 0x1a, 0x05, 0xc9, 0x94, 0x9d, 0xf7, 0x7c, 0xd7, 0xba, 0x7d, 0xcd, 0xfa, 795 0x41, 0x3b, 0x4f, 0x29, 0x7f, 0xba, 0x73, 0x09, 0x9a, 0x71, 0x4a, 0xd1,
790 0x78, 0xb2, 0x13, 0x81, 0xce, 0x45, 0xfb, 0xaa, 0xad, 0xf7, 0xb6, 0x4a, 796 0xb8, 0xf3, 0x6c, 0xe4, 0x57, 0x93, 0xc0, 0x07, 0xfa, 0xfc, 0xb5, 0x18,
791 0x09, 0x27, 0x5d, 0xd6, 0x1a, 0x47, 0xe7, 0xbe, 0x4a, 0x79, 0x5b, 0xab, 797 0x82, 0xf6, 0x9e, 0x06, 0xd3, 0xc2, 0xdc, 0x46, 0x5e, 0xb0, 0x2f, 0x67,
792 0xdc, 0x34, 0x80, 0x3f, 0x6d, 0x68, 0x62, 0x1e, 0xaa, 0x94, 0xbb, 0xd9, 798 0xfb, 0x34, 0xdb, 0xed, 0x73, 0x2f, 0xec, 0xd3, 0xed, 0x24, 0xdb, 0xfd,
793 0xa6, 0xbe, 0x74, 0x4d, 0x12, 0xa3, 0x15, 0x5f, 0xae, 0x3a, 0x41, 0xee, 799 0x27, 0xd8, 0xe7, 0xb7, 0x5d, 0x0d, 0xbc, 0x21, 0xba, 0x54, 0xcb, 0xc0,
794 0x63, 0x68, 0x7a, 0x6f, 0x5b, 0xb8, 0x56, 0xd7, 0x76, 0x39, 0x97, 0x44, 800 0x3f, 0x18, 0x99, 0xd7, 0x69, 0x97, 0x35, 0x0b, 0xbd, 0x3c, 0xc9, 0x73,
795 0x3a, 0x0e, 0x55, 0xc4, 0x2a, 0x56, 0x76, 0x39, 0x6f, 0x4b, 0xb9, 0xa7, 801 0x4d, 0xcc, 0x49, 0x3f, 0xae, 0xfc, 0xc7, 0x65, 0xfd, 0xbb, 0xa0, 0x2b,
796 0x6d, 0x75, 0x5d, 0x8a, 0xeb, 0x76, 0x0e, 0xaf, 0x9d, 0xbb, 0xcb, 0xb9, 802 0x08, 0x66, 0x81, 0xb3, 0x3c, 0xa2, 0x87, 0xb6, 0x18, 0xcd, 0x5f, 0x45,
797 0x28, 0xe5, 0x2d, 0x6d, 0xab, 0xb4, 0xd2, 0x58, 0xdb, 0x17, 0xac, 0xe5, 803 0x3c, 0xf4, 0x7e, 0x43, 0xa7, 0x4a, 0xb6, 0x83, 0xec, 0xec, 0x12, 0x70,
798 0xf8, 0x66, 0x71, 0xbb, 0x39, 0x47, 0xef, 0x6d, 0xbf, 0x45, 0x43, 0x32, 804 0x4f, 0xbb, 0xca, 0xee, 0xd9, 0x36, 0x96, 0x81, 0x7f, 0xce, 0x1f, 0x86,
799 0xc5, 0x4a, 0xb9, 0xa7, 0x7d, 0x15, 0xaf, 0x4d, 0xbc, 0xde, 0x1a, 0xbc, 805 0x5f, 0x60, 0xbb, 0x01, 0x5d, 0xc0, 0xbf, 0x0c, 0xfc, 0x73, 0xad, 0x0e,
800 0xc4, 0xd9, 0xbe, 0x8a, 0x33, 0x07, 0x9c, 0x43, 0xab, 0x38, 0x39, 0x7e, 806 0xfa, 0x96, 0x11, 0xc5, 0xd9, 0xe8, 0x3c, 0xdb, 0xb0, 0x2c, 0xda, 0xf7,
801 0x58, 0x8a, 0x38, 0xd3, 0x5a, 0x0a, 0x32, 0xbc, 0x54, 0xc9, 0x48, 0x79, 807 0x08, 0xdd, 0xe5, 0xa7, 0xe0, 0x73, 0xd8, 0x27, 0x57, 0xb3, 0xb0, 0x2b,
802 0x28, 0x01, 0xdd, 0xf7, 0x1f, 0xfc, 0x9a, 0xaa, 0x43, 0xcc, 0x61, 0x0f, 808 0xad, 0xea, 0xf2, 0xde, 0x3a, 0x2d, 0xaf, 0xad, 0xa1, 0x42, 0x55, 0xd9,
803 0xba, 0x32, 0x55, 0x5e, 0x87, 0xd8, 0x08, 0xdb, 0xf8, 0x5a, 0x5d, 0x86, 809 0x6c, 0xc1, 0x1b, 0xae, 0x64, 0x74, 0xe9, 0x7b, 0x88, 0xee, 0x84, 0xad,
804 0x17, 0xeb, 0xa6, 0x1c, 0x6f, 0x70, 0xbf, 0x98, 0xe3, 0x05, 0x75, 0xc6, 810 0x2e, 0x3b, 0x3c, 0xe6, 0x79, 0x35, 0x37, 0x5e, 0x1b, 0xd0, 0x8a, 0xec,
805 0x85, 0x46, 0x4e, 0xdb, 0x87, 0xbd, 0x66, 0x9d, 0xb0, 0xaf, 0x61, 0x6a, 811 0xbf, 0x86, 0x3f, 0x04, 0x7d, 0x6a, 0xee, 0xb7, 0x6b, 0x0f, 0xb1, 0x8c,
806 0xa3, 0x3c, 0x1f, 0x80, 0x97, 0x76, 0x7e, 0xac, 0x41, 0xdb, 0x79, 0x03, 812 0x70, 0x16, 0xb2, 0xaa, 0xee, 0x7f, 0x06, 0xd0, 0xdf, 0x75, 0x30, 0xd7,
807 0xb6, 0x41, 0xce, 0xa3, 0x9c, 0xbd, 0x95, 0xb9, 0x53, 0x66, 0xd1, 0x51, 813 0xc7, 0x63, 0x8f, 0x2b, 0x9d, 0x25, 0x6d, 0xbf, 0x23, 0x06, 0x3a, 0x43,
808 0x75, 0x88, 0x56, 0xcb, 0x77, 0x20, 0x07, 0x4d, 0xa0, 0xd6, 0x80, 0xcd, 814 0x9f, 0xb7, 0x1f, 0x93, 0xfb, 0x6a, 0xd5, 0xfe, 0x4e, 0xfa, 0x50, 0xe7,
809 0xdb, 0x78, 0x6f, 0x70, 0xde, 0x32, 0xe6, 0x6d, 0xe0, 0x3c, 0xec, 0xcd, 815 0x18, 0x7c, 0x85, 0xc8, 0xf0, 0x6a, 0xbb, 0xc1, 0x8f, 0x6a, 0x5f, 0xdb,
810 0x25, 0xe5, 0x0f, 0xa6, 0xcd, 0xf1, 0x77, 0xb1, 0xc7, 0x68, 0xd7, 0x59, 816 0x5c, 0xa2, 0x54, 0x0b, 0xe8, 0xa2, 0xab, 0x60, 0x30, 0x4e, 0x16, 0x6b,
811 0x57, 0x58, 0x02, 0x5f, 0xc1, 0x3e, 0xa2, 0x6e, 0x48, 0xed, 0x60, 0x7e, 817 0x62, 0x20, 0x41, 0x6b, 0x63, 0x93, 0x61, 0x56, 0x68, 0x77, 0x76, 0x99,
812 0x8f, 0xb9, 0x19, 0xcc, 0xcd, 0x66, 0x18, 0xcf, 0x3d, 0xfb, 0x99, 0x0e, 818 0x24, 0x6c, 0x7f, 0xe2, 0x1a, 0x6c, 0xba, 0x54, 0xab, 0xf6, 0xb5, 0x8d,
813 0xe9, 0x42, 0xbb, 0xce, 0x35, 0xd9, 0x0c, 0x72, 0x5b, 0xdf, 0xcb, 0xb7, 819 0x33, 0x45, 0xe0, 0x12, 0x7b, 0xd7, 0x60, 0x07, 0xaf, 0xc1, 0x6e, 0x25,
814 0xc9, 0x4a, 0xca, 0xbf, 0x60, 0xd8, 0xd1, 0xdc, 0x08, 0x6f, 0xf3, 0x5c, 820 0xab, 0x8f, 0xe1, 0xc5, 0xc0, 0xe6, 0x6b, 0xb8, 0xad, 0x90, 0x9e, 0xfe,
815 0xe6, 0xc5, 0xc4, 0xbd, 0x21, 0xcc, 0x83, 0xc7, 0xc5, 0x6d, 0xfc, 0x49, 821 0xcd, 0xd7, 0x70, 0x38, 0x8c, 0xb3, 0x6d, 0x9c, 0x65, 0x9c, 0x3b, 0xaf,
816 0xb7, 0x74, 0xb9, 0xf8, 0x8d, 0xe6, 0x4c, 0x6f, 0x0e, 0x6a, 0x2e, 0xbe, 822 0xe1, 0x1c, 0x59, 0x4f, 0xcf, 0x11, 0x82, 0x0f, 0x4a, 0x74, 0xe6, 0x69,
817 0xb7, 0x50, 0x3e, 0x17, 0xe7, 0xa1, 0x56, 0xac, 0x66, 0x26, 0x59, 0x1f, 823 0xef, 0xa5, 0xda, 0xd0, 0xc4, 0x5d, 0x84, 0xf8, 0x38, 0xb2, 0x29, 0xf4,
818 0x15, 0xeb, 0x6c, 0xef, 0x85, 0x3f, 0x04, 0x75, 0xd7, 0x85, 0x5b, 0xbe, 824 0xe1, 0xc6, 0x5e, 0x0f, 0xbc, 0x32, 0x88, 0x7d, 0xa2, 0x46, 0x55, 0xc8,
819 0x70, 0x19, 0x7a, 0x4b, 0x43, 0x6f, 0x29, 0x39, 0xdf, 0x60, 0x9d, 0xe6, 825 0xf9, 0x8f, 0x9a, 0xb4, 0xf7, 0x62, 0xd3, 0x08, 0x75, 0x89, 0x75, 0xe2,
820 0x42, 0x5f, 0x19, 0xf1, 0x1a, 0xe3, 0x58, 0x2b, 0x87, 0x81, 0x03, 0x3a, 826 0x6d, 0xd8, 0x58, 0x72, 0xca, 0x40, 0x0c, 0xbf, 0x20, 0x6d, 0x8c, 0x26,
821 0x17, 0x47, 0x2f, 0x64, 0x65, 0xca, 0xda, 0x1d, 0xf1, 0x00, 0x5c, 0x88, 827 0xaa, 0x35, 0xaa, 0x6c, 0xcf, 0x3f, 0x11, 0x40, 0x17, 0xa7, 0xe0, 0xd3,
822 0x1f, 0x85, 0x36, 0xf4, 0xf1, 0x1d, 0x9a, 0x53, 0xff, 0x86, 0x7f, 0x94, 828 0xc0, 0xe3, 0xe4, 0x98, 0x97, 0xc3, 0x7c, 0x93, 0x6d, 0x0b, 0x7e, 0x05,
823 0xed, 0x09, 0xbd, 0x30, 0xd6, 0xd4, 0xbf, 0x6e, 0xfc, 0xa1, 0x1c, 0x68, 829 0xb0, 0xd0, 0xb5, 0x84, 0x3e, 0xbf, 0xeb, 0x55, 0x4f, 0xe7, 0x7d, 0x2c,
824 0x33, 0x06, 0x31, 0xfe, 0xe8, 0xa8, 0xf3, 0x18, 0x8b, 0x48, 0xd7, 0x92, 830 0xe4, 0x5c, 0x89, 0x84, 0x98, 0xbf, 0x1a, 0xb0, 0x9e, 0x4d, 0x8f, 0x5c,
825 0x23, 0x4b, 0x23, 0xdc, 0x37, 0x8b, 0xf1, 0xa7, 0x5c, 0xe7, 0x9e, 0x29, 831 0x45, 0x8e, 0x63, 0x92, 0x37, 0x06, 0xff, 0x01, 0x7d, 0x9f, 0x6d, 0x11,
826 0x5c, 0xc0, 0x19, 0xad, 0xf1, 0xfd, 0x11, 0x87, 0x6b, 0x7c, 0x99, 0x70, 832 0x72, 0x82, 0x3f, 0xed, 0x55, 0x36, 0xf6, 0x9d, 0xad, 0xea, 0x49, 0x06,
827 0x3a, 0xc4, 0x48, 0x96, 0xb4, 0xc7, 0x07, 0x11, 0x7b, 0x1e, 0xe0, 0x3e, 833 0xfb, 0xf2, 0xe9, 0x1c, 0xe7, 0x0f, 0x9d, 0x09, 0x2f, 0x37, 0xbe, 0x4d,
828 0x32, 0x06, 0x6d, 0x17, 0xb0, 0xea, 0xb4, 0x3c, 0x3c, 0xc8, 0x75, 0xa0, 834 0x3f, 0x7b, 0x60, 0x9b, 0x38, 0x5b, 0xd9, 0x26, 0x10, 0x03, 0x60, 0x53,
829 0xdd, 0x2a, 0x7a, 0x92, 0x34, 0xf3, 0x21, 0x4f, 0x43, 0xdd, 0x81, 0xbe, 835 0xc2, 0xcb, 0xa1, 0x7f, 0x36, 0xb2, 0xa1, 0x0c, 0x6c, 0x88, 0x69, 0x65,
830 0x06, 0xac, 0x40, 0x7f, 0x9f, 0xe9, 0x5e, 0xd5, 0x1f, 0xd7, 0x35, 0xf3, 836 0x3a, 0x7f, 0x04, 0x7b, 0x95, 0xb4, 0xd2, 0x84, 0x0f, 0x9a, 0x46, 0x3f,
831 0xcb, 0x18, 0x96, 0x90, 0x81, 0x33, 0x1b, 0x65, 0xe7, 0xa2, 0x25, 0xf6, 837 0x82, 0x9e, 0xe0, 0x2c, 0xf0, 0x81, 0x05, 0x70, 0x49, 0x8c, 0xfe, 0x2a,
832 0x99, 0x55, 0xfe, 0x76, 0x9e, 0x5b, 0xcb, 0x5f, 0xf4, 0x7f, 0x15, 0x5c, 838 0xb4, 0x67, 0xee, 0xbf, 0x1b, 0xa8, 0x78, 0x72, 0x30, 0xdc, 0xff, 0x17,
833 0xd0, 0xc5, 0x8e, 0xfa, 0x1e, 0x4b, 0x05, 0xb8, 0xa3, 0xf6, 0x7b, 0xe1, 839 0xa1, 0x0f, 0x88, 0x70, 0x31, 0x9e, 0xac, 0x36, 0x81, 0x5c, 0x68, 0xa2,
834 0x5e, 0xf1, 0xfd, 0x99, 0x70, 0x4f, 0xb0, 0x07, 0x88, 0x95, 0xe7, 0x6f, 840 0x65, 0x68, 0xec, 0xcf, 0x8b, 0x3e, 0xe7, 0x30, 0x9c, 0xbf, 0x3c, 0x1e,
835 0xc5, 0xa9, 0x0c, 0xf6, 0x06, 0xb6, 0xa7, 0xe2, 0x11, 0xe3, 0x18, 0xed, 841 0xfa, 0x45, 0xce, 0x5b, 0x92, 0x21, 0x4f, 0x73, 0x51, 0x5c, 0x94, 0xf6,
836 0xbb, 0x63, 0xd2, 0x2c, 0xb0, 0x8e, 0xe6, 0x3e, 0xc9, 0x44, 0xb9, 0x22, 842 0x86, 0x18, 0x65, 0x95, 0x5d, 0x99, 0xd3, 0x68, 0xd3, 0xb9, 0x24, 0xd6,
837 0xa5, 0xad, 0x85, 0x67, 0x7d, 0xd8, 0xcf, 0xa4, 0xa5, 0x6c, 0xaf, 0x63, 843 0x61, 0xae, 0x85, 0x73, 0xc3, 0x2f, 0x21, 0x0f, 0xe2, 0xdc, 0x14, 0xeb,
838 0xaf, 0x97, 0x37, 0xa0, 0x1b, 0x8c, 0xc1, 0x26, 0xf5, 0x42, 0x42, 0x8a, 844 0x3b, 0x43, 0x9b, 0xbf, 0x44, 0x65, 0xf8, 0x54, 0xc3, 0xe1, 0xf7, 0x5e,
839 0x8d, 0x44, 0xc2, 0x3c, 0x31, 0xf0, 0x23, 0xcf, 0x48, 0x24, 0xf4, 0x13, 845 0x2f, 0x75, 0x61, 0xdc, 0xc4, 0x5e, 0xf0, 0x13, 0xba, 0xe4, 0x33, 0x62,
840 0x81, 0x9d, 0x4d, 0xd6, 0x6f, 0x20, 0x56, 0x6a, 0x72, 0x74, 0xe8, 0x86, 846 0x41, 0xfa, 0x06, 0xce, 0xaf, 0xb0, 0xd6, 0xc2, 0x5a, 0xf6, 0xbb, 0xbc,
841 0xcf, 0x1a, 0xd8, 0xdb, 0x0b, 0x9b, 0x1b, 0x82, 0xcf, 0x80, 0x8f, 0x72, 847 0xf6, 0x3c, 0xe8, 0xc0, 0xb8, 0xc9, 0x30, 0xec, 0xa3, 0x82, 0xf7, 0xbc,
842 0xa3, 0xa3, 0x37, 0xe0, 0xed, 0x2b, 0x11, 0x8f, 0xa6, 0x8e, 0xdc, 0xd3, 848 0xdc, 0x1e, 0x73, 0x82, 0x12, 0x21, 0x5e, 0xab, 0x0d, 0xef, 0xc6, 0xb5,
843 0xcb, 0xfb, 0xbe, 0x51, 0xd8, 0x90, 0x98, 0xce, 0x8f, 0x6f, 0xd1, 0xcf, 849 0x9c, 0xd3, 0x04, 0x17, 0x74, 0x87, 0xf1, 0x47, 0x79, 0x18, 0xd1, 0xf4,
844 0xed, 0xdf, 0x62, 0x9c, 0x2b, 0x6d, 0x01, 0x3e, 0xdd, 0xcb, 0xe3, 0xf7, 850 0x09, 0xe4, 0x71, 0x4e, 0x07, 0xe2, 0x14, 0x8f, 0x86, 0x4c, 0x75, 0xce,
845 0x9c, 0xc8, 0x44, 0x15, 0x3a, 0xdf, 0x03, 0x3d, 0x59, 0xf0, 0xc5, 0x3d, 851 0x08, 0xe6, 0x81, 0xfe, 0xf5, 0xe3, 0xbb, 0x53, 0xd7, 0xfc, 0x23, 0x5b,
846 0xa6, 0xca, 0xd1, 0xf5, 0x3d, 0x2f, 0x6e, 0x0a, 0x70, 0xf0, 0xfd, 0x27, 852 0x17, 0x15, 0x10, 0x1f, 0xc0, 0x27, 0x6b, 0x8a, 0x73, 0xbf, 0x62, 0x53,
847 0x7e, 0x70, 0x86, 0x5e, 0x0e, 0xfb, 0x7e, 0x3f, 0xdc, 0x87, 0x5f, 0x45, 853 0xa2, 0xc4, 0xdc, 0x18, 0x7c, 0xa2, 0xca, 0xa3, 0x2e, 0xf8, 0x1b, 0xe5,
848 0xb9, 0x78, 0x5e, 0x44, 0xb2, 0xad, 0x3d, 0x37, 0xb2, 0xe3, 0x25, 0x9c, 854 0x66, 0x82, 0xd7, 0x05, 0xf0, 0xd7, 0x82, 0xfe, 0x8c, 0x03, 0x96, 0x8e,
849 0x33, 0xa7, 0x1d, 0xdf, 0x7f, 0x07, 0xcf, 0x35, 0xa7, 0xd9, 0x46, 0xde, 855 0x00, 0x07, 0xc7, 0x6a, 0x57, 0xe4, 0x53, 0x54, 0x36, 0x39, 0xa7, 0xe8,
850 0x7f, 0xf6, 0x31, 0x07, 0xf8, 0x2c, 0xce, 0xbd, 0xd1, 0xa6, 0xb3, 0xff, 856 0x64, 0xfa, 0x0a, 0x6c, 0xfb, 0x22, 0xbf, 0x19, 0x73, 0xdc, 0x7f, 0xac,
851 0x5e, 0xcf, 0xbd, 0x7b, 0x3f, 0xfb, 0xc9, 0xf3, 0x1d, 0x7d, 0xef, 0x03, 857 0x57, 0xc9, 0xab, 0x9b, 0xc7, 0x13, 0x22, 0xdf, 0xbb, 0x61, 0xfe, 0x9f,
852 0xce, 0xfe, 0x0f, 0x5c, 0x77, 0x0f, 0x3e, 0x1b, 0xd8, 0x6d, 0xb1, 0xd1, 858 0xbb, 0x15, 0x6d, 0x72, 0x8c, 0xf9, 0x7f, 0xdb, 0x30, 0xfe, 0xe3, 0xd4,
853 0x1c, 0x5f, 0xee, 0xd5, 0x7f, 0x7f, 0xad, 0xfb, 0x76, 0xff, 0xb5, 0xbb, 859 0xfa, 0xf1, 0xdd, 0xdb, 0x42, 0xfd, 0x43, 0xff, 0xf1, 0x90, 0x5e, 0xd0,
854 0x6f, 0xf7, 0xdf, 0xcd, 0xdd, 0xbf, 0x18, 0xff, 0xcd, 0x01, 0x0f, 0x7d, 860 0xb6, 0x46, 0x6b, 0x94, 0x2b, 0x53, 0x5d, 0x20, 0x5f, 0xf4, 0x72, 0xbb,
855 0x70, 0xad, 0xff, 0xae, 0xe7, 0x93, 0xd4, 0xf7, 0xf3, 0x3d, 0xe5, 0xa1, 861 0xac, 0x2a, 0x6c, 0xaa, 0xd4, 0x02, 0xdd, 0x6b, 0x71, 0x6c, 0x6d, 0x4d,
856 0xce, 0x30, 0x1f, 0x52, 0xe7, 0xf5, 0x17, 0xa7, 0x6d, 0xef, 0x7e, 0x53, 862 0xe5, 0xda, 0x1a, 0xe5, 0xe7, 0x4b, 0xad, 0x00, 0x79, 0x56, 0x7b, 0xcc,
857 0x4a, 0xb9, 0x16, 0xc9, 0xe6, 0x6a, 0xb2, 0x43, 0x8e, 0x3b, 0x22, 0x4b, 863 0xcb, 0xa2, 0x5f, 0xc1, 0x3e, 0x05, 0x9a, 0xf6, 0x2f, 0x16, 0x84, 0x73,
858 0xaa, 0x16, 0x31, 0x51, 0x8b, 0x0f, 0xa0, 0x3e, 0x0b, 0xf4, 0xba, 0xa4, 864 0x4c, 0xe6, 0x89, 0xc2, 0x79, 0x4a, 0x2b, 0x2d, 0x73, 0xfe, 0x08, 0x5b,
859 0xf4, 0xf2, 0x02, 0x78, 0x89, 0xf0, 0x74, 0xdd, 0x05, 0x0f, 0x71, 0x10, 865 0x72, 0x64, 0xdd, 0x80, 0x98, 0x72, 0x5c, 0x2b, 0x9c, 0x5e, 0x40, 0xfe,
860 0x17, 0xf1, 0x0c, 0xe2, 0x7c, 0xb7, 0xd7, 0xc1, 0x85, 0x73, 0xea, 0x25, 866 0xb8, 0x82, 0xdf, 0x19, 0xfc, 0x9a, 0xf8, 0x45, 0xf9, 0xfb, 0x33, 0xc8,
861 0xd4, 0x64, 0xb6, 0xde, 0xa3, 0x07, 0x67, 0xb2, 0x5b, 0x96, 0xdd, 0xe9, 867 0xff, 0xa5, 0x7f, 0x45, 0x2c, 0x50, 0xfb, 0xff, 0x62, 0x05, 0x3a, 0xb6,
862 0xeb, 0xf2, 0x05, 0x9e, 0x59, 0x0a, 0xae, 0xce, 0x21, 0x56, 0x0f, 0x8d, 868 0x90, 0xa6, 0x6f, 0x3b, 0xa2, 0x5f, 0x28, 0x9f, 0x52, 0x40, 0xde, 0x6b,
863 0x85, 0x75, 0xd2, 0xdc, 0x41, 0xcf, 0x8e, 0xee, 0x49, 0x78, 0x47, 0x92, 869 0xbe, 0x4d, 0xbf, 0x13, 0xe6, 0x50, 0x44, 0xaf, 0xd7, 0xc1, 0xc7, 0x91,
864 0x90, 0x92, 0x9a, 0xb5, 0x04, 0x1d, 0x68, 0x72, 0x0d, 0x67, 0xd0, 0xd5, 870 0xfd, 0xa1, 0xbe, 0x66, 0x1f, 0xf4, 0xa4, 0xef, 0x0c, 0x73, 0x24, 0xe4,
865 0xb9, 0x76, 0xe0, 0x45, 0xee, 0x77, 0x20, 0xbb, 0x57, 0xb4, 0x7e, 0xab, 871 0x6a, 0x05, 0xb9, 0xea, 0xfb, 0xe0, 0x8d, 0x46, 0x6f, 0x41, 0x7f, 0x5e,
866 0x55, 0x6b, 0x87, 0x2f, 0x65, 0xc4, 0x55, 0x6d, 0x9e, 0xd3, 0xa7, 0x66, 872 0xaf, 0x77, 0x81, 0x1e, 0x87, 0xca, 0x93, 0xf6, 0x18, 0x69, 0x43, 0xe6,
867 0x16, 0x2b, 0xc8, 0x03, 0x6d, 0x9c, 0xaf, 0x79, 0xbc, 0xd7, 0x49, 0x43, 873 0x26, 0xad, 0x0b, 0x36, 0x0c, 0xfb, 0x96, 0x63, 0x4a, 0x74, 0xe4, 0xcf,
868 0x93, 0x2b, 0x73, 0xba, 0xfc, 0xd3, 0x9c, 0x21, 0xff, 0x8c, 0x3a, 0xf4, 874 0xcd, 0x2c, 0xd5, 0x04, 0xd6, 0x22, 0xef, 0xc9, 0xa1, 0x0f, 0xd9, 0x5f,
869 0x9a, 0x7d, 0x6a, 0xe6, 0xb4, 0x2d, 0xf7, 0x81, 0xd5, 0xf0, 0x0e, 0x4f, 875 0xa9, 0x33, 0x9c, 0xa0, 0x37, 0xea, 0x3a, 0xbd, 0x89, 0xbc, 0xeb, 0x2d,
870 0x76, 0x9a, 0x42, 0x5b, 0x1d, 0x48, 0xff, 0x8e, 0x20, 0xff, 0xc1, 0x9a, 876 0xe7, 0xdc, 0x0c, 0x62, 0xd6, 0x00, 0xe2, 0x03, 0x6a, 0x98, 0x5d, 0xec,
871 0x2b, 0x73, 0xa4, 0xb5, 0x76, 0x8d, 0xf4, 0x22, 0x1f, 0x83, 0x5d, 0x0f, 877 0xa3, 0x77, 0x1a, 0x78, 0x96, 0xf0, 0xbb, 0x13, 0x79, 0xe3, 0xf5, 0x61,
872 0x30, 0x27, 0xe2, 0x7c, 0xd4, 0xab, 0x03, 0xd6, 0x3e, 0xc5, 0x5b, 0x42, 878 0x3e, 0x6d, 0x3d, 0xd3, 0x96, 0x00, 0x0c, 0xaf, 0x37, 0x40, 0x5b, 0x0f,
873 0x16, 0xeb, 0x9c, 0x6f, 0x82, 0xb7, 0x2e, 0x9c, 0x31, 0x59, 0x6b, 0x52, 879 0xe4, 0x6f, 0x9b, 0x53, 0xf4, 0xcb, 0x5e, 0x99, 0xab, 0x68, 0x3c, 0xaf,
874 0xfe, 0xb0, 0x5b, 0xe5, 0xaa, 0x1a, 0xfb, 0x0d, 0xb5, 0xc7, 0xef, 0xef, 880 0xfc, 0xd2, 0x27, 0xe7, 0x99, 0xcf, 0x3a, 0x74, 0x9c, 0xc7, 0xfc, 0x8e,
875 0xe7, 0xde, 0x1b, 0x32, 0x95, 0x62, 0x9b, 0x63, 0x59, 0xd4, 0x9c, 0xc4, 881 0xfd, 0x27, 0xe3, 0xb3, 0xc7, 0x0a, 0x38, 0xcc, 0x95, 0xba, 0xea, 0x47,
876 0x97, 0xdd, 0xeb, 0x0a, 0x79, 0x0e, 0xde, 0xaf, 0x08, 0x65, 0xdb, 0x6d, 882 0x73, 0xa4, 0x45, 0x31, 0x8c, 0xfd, 0x62, 0x89, 0x0a, 0x92, 0xef, 0x13,
877 0x5d, 0x97, 0xd7, 0x7d, 0xf7, 0x00, 0xe5, 0x89, 0x72, 0x8b, 0x39, 0x9f, 883 0x24, 0x65, 0xb0, 0x4e, 0x9e, 0x94, 0x30, 0xf2, 0xf5, 0x99, 0x39, 0x87,
878 0xb1, 0xd8, 0x28, 0xcc, 0xc0, 0x8e, 0xbf, 0x2a, 0xdf, 0x6f, 0x1c, 0x92, 884 0xe5, 0x0a, 0xff, 0x56, 0x8b, 0xe4, 0xca, 0x32, 0xea, 0xa4, 0x6a, 0xfd,
879 0xef, 0x35, 0x26, 0xe5, 0xcf, 0x1a, 0x5f, 0x96, 0x3f, 0x6d, 0x1c, 0x94, 885 0x29, 0xc8, 0x55, 0x84, 0xf5, 0x01, 0xec, 0x7b, 0x81, 0xe5, 0x8b, 0xba,
880 0xd7, 0x1b, 0x07, 0xe4, 0xb5, 0xc6, 0x84, 0xbc, 0xda, 0xd8, 0x0f, 0x1b, 886 0xb1, 0x8e, 0xbc, 0xa7, 0x4e, 0x29, 0x55, 0xdf, 0x1c, 0x47, 0x5d, 0x00,
881 0x1f, 0x87, 0x8d, 0x9f, 0x9a, 0x99, 0xac, 0xf7, 0xcb, 0xd4, 0x49, 0xc4, 887 0xf9, 0xd5, 0x16, 0x80, 0x03, 0x36, 0x5a, 0x5b, 0xc1, 0x13, 0xb5, 0x48,
882 0x20, 0xe7, 0x1b, 0xba, 0xba, 0xe3, 0xb3, 0xe9, 0xe7, 0x2d, 0x32, 0xad, 888 0xed, 0x0c, 0x9e, 0x83, 0x78, 0x36, 0x59, 0x37, 0xc3, 0x3c, 0xe3, 0x13,
883 0xee, 0xaf, 0x34, 0xe4, 0x89, 0x2d, 0xbc, 0x2b, 0x7c, 0xc5, 0x33, 0x2e, 889 0xf4, 0xc0, 0x9e, 0x4a, 0x6c, 0x4f, 0xf4, 0x8f, 0xad, 0x3c, 0xfd, 0x43,
884 0x87, 0xf1, 0xe8, 0xe1, 0x94, 0xb4, 0x03, 0xbf, 0xca, 0x4b, 0x4d, 0x9e, 890 0x6b, 0x8c, 0x7e, 0xd4, 0xca, 0xd1, 0x0f, 0x5b, 0x2e, 0xfd, 0x7d, 0x6b,
885 0xdb, 0x62, 0x86, 0xf7, 0x9c, 0x87, 0x24, 0xc9, 0xfb, 0xb0, 0x9c, 0x67, 891 0x84, 0x9e, 0x6d, 0x65, 0xb9, 0x96, 0x43, 0xce, 0x64, 0x71, 0xce, 0x44,
886 0xa0, 0xde, 0x5e, 0xd7, 0x27, 0x73, 0xb4, 0x65, 0xe8, 0xc6, 0x95, 0x43, 892 0x0f, 0xfa, 0xb7, 0xc3, 0xde, 0x59, 0xfe, 0xe7, 0x66, 0x0a, 0xcd, 0x21,
887 0xb0, 0x53, 0xc3, 0x7e, 0xcb, 0xa5, 0x1e, 0x16, 0x97, 0x28, 0xf7, 0x46, 893 0x2a, 0x9f, 0x80, 0x6f, 0x76, 0x6f, 0xe3, 0x1a, 0x94, 0x1e, 0x73, 0xb9,
888 0x59, 0x5c, 0xa0, 0x6f, 0xff, 0x1b, 0x64, 0x6c, 0x97, 0xda, 0x82, 0x89, 894 0x86, 0xe8, 0xe0, 0xf7, 0xa8, 0x23, 0xe0, 0xbb, 0xe1, 0xcb, 0xa6, 0xd2,
889 0xb9, 0x6e, 0x98, 0xab, 0x6c, 0xa7, 0x3d, 0x00, 0x1f, 0xf1, 0x7e, 0x10, 895 0xf6, 0x39, 0x4f, 0x1f, 0x08, 0x7d, 0xc0, 0x5d, 0x29, 0xea, 0xc2, 0x5e,
890 0x4e, 0xab, 0x09, 0x27, 0xf1, 0x24, 0x54, 0x0c, 0x08, 0x70, 0x5b, 0x52, 896 0xf0, 0x7f, 0x17, 0x9f, 0x86, 0x0d, 0xc8, 0x1a, 0x28, 0x01, 0x5f, 0xc3,
891 0x5b, 0x4a, 0xca, 0xc2, 0x42, 0x0f, 0x9e, 0x94, 0x2c, 0xd4, 0x6d, 0x3c, 897 0x79, 0x80, 0xc1, 0x76, 0xcc, 0xf5, 0x87, 0xe5, 0xe9, 0x5c, 0x17, 0xb2,
892 0x39, 0x3c, 0x43, 0x78, 0xd2, 0xb0, 0x53, 0xca, 0xc8, 0xd8, 0x12, 0xc9, 898 0x3d, 0xeb, 0x08, 0x1a, 0x0c, 0x37, 0x69, 0xb2, 0xdc, 0x0c, 0x87, 0x7d,
893 0x88, 0x78, 0x5c, 0xed, 0x0d, 0x6b, 0x2a, 0xf2, 0xa3, 0x85, 0xfc, 0x74, 899 0x6a, 0x21, 0xf4, 0x6f, 0x89, 0x50, 0x2f, 0x4d, 0xcc, 0x3f, 0x15, 0xfa,
894 0x87, 0x7d, 0x1d, 0x52, 0xab, 0x38, 0x32, 0x55, 0xfd, 0x94, 0x3e, 0xa5, 900 0xe3, 0x8d, 0xfb, 0x20, 0x56, 0x20, 0x97, 0x54, 0xeb, 0x18, 0x56, 0x0b,
895 0x74, 0x07, 0xfc, 0x95, 0x21, 0xb4, 0xef, 0x0f, 0xdb, 0x8f, 0xca, 0xf4, 901 0x61, 0xfb, 0xc3, 0xb9, 0x24, 0xf8, 0xed, 0x52, 0xd9, 0x7f, 0x43, 0xe3,
896 0xbc, 0xc8, 0xca, 0xcb, 0x03, 0x7a, 0x51, 0xb5, 0xf7, 0xa2, 0xad, 0xa3, 902 0x1c, 0x5b, 0x38, 0xcc, 0xff, 0x11, 0x8c, 0x2f, 0x87, 0xe3, 0xaf, 0xd0,
897 0x9d, 0x0d, 0xdb, 0xcc, 0x8f, 0x0e, 0xe0, 0x71, 0xd5, 0xf3, 0xf5, 0xea, 903 0xf4, 0x22, 0x81, 0xd6, 0xd7, 0xb4, 0xa2, 0x1c, 0x8f, 0x61, 0x2c, 0x30,
898 0xb8, 0x3c, 0x55, 0xed, 0x77, 0x5e, 0x87, 0xcd, 0xbd, 0x65, 0x46, 0xf7, 904 0xd6, 0xb9, 0x6e, 0xe0, 0x0c, 0x23, 0xc5, 0xba, 0x2e, 0x9c, 0x71, 0xf0,
899 0xd2, 0x04, 0x24, 0x79, 0xf6, 0x56, 0x75, 0xf7, 0xf1, 0x04, 0xe2, 0xad, 905 0x71, 0x12, 0xbf, 0x82, 0xfc, 0x3d, 0xe2, 0x0f, 0x15, 0xde, 0x41, 0xbc,
900 0x9b, 0x34, 0xe5, 0x6f, 0x4f, 0x64, 0xad, 0xa7, 0xf5, 0x5c, 0x52, 0xda, 906 0xd0, 0x3a, 0xa2, 0xdc, 0x67, 0x3b, 0x6a, 0xcf, 0x20, 0x38, 0x84, 0x5a,
901 0x7d, 0xff, 0x71, 0x3b, 0x3b, 0x3b, 0xa9, 0x77, 0xca, 0xdf, 0xbf, 0x98, 907 0xdd, 0x4a, 0x19, 0xf4, 0x2f, 0xf3, 0xb6, 0x79, 0x48, 0xcc, 0xe1, 0x4c,
902 0x91, 0x85, 0xb3, 0x5b, 0x65, 0xa1, 0x06, 0x99, 0x1a, 0xbf, 0x8e, 0x7d, 908 0x41, 0x30, 0xe1, 0xd8, 0x95, 0x82, 0xe8, 0xa6, 0x9f, 0x1f, 0xe7, 0xb8,
903 0x35, 0xe5, 0xea, 0x9e, 0x47, 0xb1, 0x27, 0x8c, 0x5d, 0x49, 0xe4, 0x6c, 909 0x5b, 0x9f, 0x79, 0x01, 0xba, 0xd7, 0x58, 0xe9, 0xa4, 0x46, 0xc3, 0xa0,
904 0x1b, 0xc4, 0xec, 0x25, 0x5d, 0x49, 0x98, 0x85, 0x9c, 0x1c, 0x81, 0xdf, 910 0x2b, 0xa3, 0x43, 0xa0, 0xd3, 0xa4, 0x46, 0x33, 0x85, 0x5c, 0x6e, 0x33,
905 0x4f, 0xdb, 0xb9, 0x1e, 0x69, 0xc7, 0x7b, 0x7d, 0x04, 0x7c, 0x5b, 0x32, 911 0xa1, 0x3c, 0x94, 0x0e, 0x43, 0xcf, 0x67, 0xa5, 0x8f, 0xf6, 0x1c, 0x3c,
906 0xd5, 0x6b, 0xc9, 0x99, 0xc1, 0x68, 0xff, 0xb6, 0x62, 0x6e, 0x46, 0x16, 912 0x9b, 0x1f, 0xf4, 0xae, 0x3f, 0x73, 0x09, 0xf4, 0xf7, 0xa0, 0x0a, 0xd9,
907 0xcf, 0x66, 0xf0, 0x9b, 0x83, 0xfd, 0xec, 0x94, 0x57, 0x6a, 0xfd, 0xb2, 913 0x2e, 0xe5, 0x5c, 0xf6, 0x87, 0x4c, 0x4f, 0x20, 0x6e, 0x19, 0x43, 0xe6,
908 0x54, 0xdb, 0x2a, 0x8b, 0xb5, 0xe6, 0x7d, 0xe8, 0xec, 0x09, 0xe2, 0x1d, 914 0x7e, 0xf1, 0xab, 0xe0, 0x0e, 0x83, 0x65, 0xf7, 0xaa, 0xac, 0x77, 0x64,
909 0xf1, 0xf4, 0x5b, 0x53, 0xfa, 0x56, 0x71, 0xcd, 0x7e, 0xeb, 0x29, 0xfd, 915 0x9c, 0xc3, 0x7e, 0x4b, 0x2b, 0xaf, 0x81, 0x16, 0x93, 0x9e, 0x6d, 0x6e,
910 0x1f, 0xe4, 0x31, 0x33, 0xa0, 0xa9, 0x17, 0x7e, 0xa4, 0xee, 0x84, 0x26, 916 0x0f, 0xc7, 0x96, 0xe4, 0xc5, 0xb3, 0xcd, 0x2e, 0xfa, 0x61, 0x63, 0x0b,
911 0x79, 0xf6, 0x2a, 0xbc, 0x4f, 0x26, 0x49, 0xfb, 0xf5, 0xc6, 0x07, 0xd1, 917 0x2d, 0x37, 0xf8, 0x7d, 0x27, 0x2d, 0x35, 0x86, 0xae, 0x1e, 0x15, 0x03,
912 0x59, 0xcb, 0xcf, 0x9d, 0x68, 0x52, 0x06, 0xe2, 0xec, 0xbf, 0x71, 0x52, 918 0xb4, 0x7a, 0xe3, 0x4d, 0xe6, 0x57, 0x05, 0xf2, 0x82, 0xc9, 0x8f, 0xe9,
913 0xef, 0x95, 0xe5, 0x6d, 0x0f, 0x58, 0x4f, 0xea, 0xad, 0x88, 0x01, 0x3f, 919 0xbd, 0xd1, 0x5e, 0xfa, 0xe9, 0x3d, 0x76, 0xfd, 0x7e, 0x01, 0x1b, 0x18,
914 0x97, 0x9f, 0xee, 0xd9, 0x24, 0x3f, 0xfc, 0xcd, 0xec, 0xa9, 0x6f, 0x22, 920 0x4d, 0xb2, 0x6d, 0xa3, 0xcf, 0xf3, 0xf6, 0x55, 0x4b, 0xb0, 0x6e, 0xff,
915 0xd9, 0xbf, 0xb2, 0xa7, 0x83, 0x71, 0x01, 0xef, 0xec, 0xcf, 0xde, 0x70, 921 0x04, 0x3c, 0xb5, 0x8f, 0x29, 0x3b, 0x60, 0xdc, 0x8c, 0x17, 0xba, 0xe1,
916 0x75, 0xea, 0xe1, 0x2f, 0xa0, 0x87, 0xec, 0x9c, 0xba, 0x9b, 0x56, 0x3c, 922 0xbc, 0x08, 0x9c, 0x78, 0xd7, 0x1c, 0x02, 0xae, 0x17, 0x25, 0x2f, 0x0e,
917 0x90, 0x3e, 0xf5, 0x52, 0x06, 0x6f, 0x18, 0xab, 0xf7, 0x03, 0x57, 0x59, 923 0xb9, 0xf6, 0x55, 0x42, 0x0e, 0x79, 0xc5, 0x19, 0xca, 0x0a, 0xb1, 0x9d,
918 0xe9, 0xf9, 0x09, 0x27, 0x7b, 0x03, 0xe9, 0xb0, 0xbf, 0x68, 0xf7, 0xa7, 924 0x1a, 0x99, 0x9b, 0xcc, 0xf3, 0xf0, 0xff, 0xa8, 0xab, 0x2a, 0x97, 0xa9,
919 0x77, 0xea, 0x3b, 0x64, 0x32, 0xfd, 0x80, 0xf5, 0xb4, 0x6c, 0x21, 0xce, 925 0x3e, 0x73, 0xc9, 0x61, 0xfd, 0x67, 0xbf, 0xf1, 0x12, 0xf2, 0x4e, 0x93,
920 0xd9, 0x05, 0xc1, 0xda, 0x79, 0xe2, 0xfb, 0x2b, 0xe0, 0x0b, 0x70, 0x28, 926 0x4e, 0x34, 0xd9, 0x5f, 0x32, 0x2e, 0xce, 0xfd, 0x77, 0x9b, 0x5f, 0x13,
921 0xff, 0x51, 0x38, 0x77, 0x59, 0x5f, 0xd7, 0x79, 0xc6, 0x63, 0x0c, 0x71, 927 0x9c, 0x23, 0xe0, 0x1d, 0xe6, 0xf5, 0x2f, 0xb1, 0x9c, 0x3b, 0x18, 0x36,
922 0xe1, 0xe2, 0x10, 0x65, 0x40, 0x82, 0x95, 0xca, 0xa6, 0x5d, 0xfd, 0xc3, 928 0x6b, 0x89, 0x60, 0x03, 0x8f, 0x86, 0xcc, 0x5d, 0x82, 0xf7, 0xfb, 0x6f,
923 0xc8, 0x47, 0xfc, 0xfd, 0x56, 0x51, 0x27, 0x0f, 0xe7, 0xc0, 0xcb, 0x4f, 929 0xec, 0xfb, 0x2e, 0x68, 0x1d, 0x02, 0x2c, 0xe2, 0x65, 0xa6, 0x7d, 0x8f,
924 0xc0, 0x7f, 0x3f, 0x70, 0xa2, 0xf6, 0x48, 0x47, 0x74, 0xff, 0x4e, 0xd1, 930 0x57, 0xe4, 0x1e, 0xc7, 0x9b, 0xc8, 0xf3, 0xd6, 0xf6, 0xc0, 0x5c, 0x53,
925 0x7d, 0xad, 0x21, 0xe6, 0x2a, 0x5d, 0xf4, 0xd5, 0x75, 0xc8, 0xdd, 0x07, 931 0xe0, 0x9c, 0x86, 0x94, 0xcb, 0x95, 0x51, 0xe6, 0xef, 0x6d, 0x7d, 0x9c,
926 0x7b, 0xb5, 0xf0, 0xcb, 0xbd, 0xe9, 0x0c, 0xf7, 0x98, 0xeb, 0x22, 0xba, 932 0x63, 0xea, 0xf9, 0xbf, 0x09, 0xa2, 0x5a, 0xf3, 0x95, 0xf9, 0x49, 0xf8,
927 0x11, 0xbf, 0x5c, 0x73, 0x27, 0x1e, 0xee, 0x75, 0x3e, 0xea, 0xd4, 0x03, 933 0xe7, 0x20, 0xa8, 0xee, 0x1e, 0x52, 0x71, 0x68, 0x90, 0xdf, 0x1f, 0x90,
928 0x09, 0x79, 0xf7, 0x44, 0xb4, 0x37, 0x07, 0x64, 0xba, 0x0a, 0xdd, 0xed, 934 0xb2, 0xa8, 0x8a, 0x4e, 0xba, 0xc3, 0xb0, 0x00, 0xcb, 0x73, 0x2f, 0x87,
929 0xea, 0x0f, 0xfc, 0x27, 0x1d, 0xf1, 0x40, 0xde, 0xff, 0x06, 0xbc, 0x07, 935 0x72, 0x84, 0x11, 0x75, 0xa1, 0xdf, 0x8c, 0xf4, 0x32, 0x05, 0x1d, 0xdb,
930 0xb8, 0x5b, 0x0b, 0xcd, 0xba, 0xc3, 0x58, 0x3d, 0xa0, 0x31, 0xb6, 0x0e, 936 0x63, 0x1e, 0x0a, 0x63, 0x32, 0xc7, 0xb4, 0x9f, 0x42, 0xe7, 0xac, 0x14,
931 0x4f, 0x57, 0xf6, 0x44, 0xbe, 0x98, 0x84, 0x5f, 0xed, 0xb6, 0x9e, 0x10, 937 0xeb, 0x4d, 0xaa, 0xef, 0x9a, 0xde, 0xf0, 0xbb, 0xfa, 0x8c, 0x07, 0xda,
932 0xd6, 0x63, 0xc4, 0x9b, 0x94, 0x1f, 0xbe, 0x0c, 0x1e, 0x92, 0xf4, 0x93, 938 0x8a, 0x0b, 0x9d, 0x54, 0xaa, 0x27, 0x90, 0x03, 0x19, 0x34, 0x97, 0xc3,
933 0x7f, 0x5f, 0xe3, 0x27, 0x1c, 0xdb, 0x2a, 0x35, 0xd4, 0xd4, 0x5e, 0xde, 939 0x18, 0x3a, 0x54, 0x6a, 0xb0, 0xce, 0x57, 0x42, 0x9d, 0x4f, 0x86, 0xb8,
934 0x94, 0x69, 0x25, 0x03, 0xda, 0x35, 0xfa, 0x77, 0x29, 0xf4, 0xef, 0x47, 940 0x4f, 0x82, 0x17, 0xb6, 0xb5, 0x2a, 0xb8, 0x76, 0xda, 0x26, 0xeb, 0x5f,
935 0x80, 0xa3, 0x5d, 0x8c, 0x47, 0x1f, 0xc7, 0x59, 0x9d, 0xcd, 0x2c, 0xeb, 941 0x1d, 0xb6, 0x5c, 0xae, 0x71, 0xed, 0x89, 0xfc, 0xdb, 0x3c, 0x37, 0x33,
936 0xcc, 0x03, 0x76, 0x4b, 0x51, 0xdd, 0x4f, 0xdf, 0x8b, 0xee, 0xa2, 0xd8, 942 0xed, 0x18, 0xa0, 0x6b, 0x44, 0x2b, 0xb7, 0x1c, 0xad, 0xec, 0x33, 0x7d,
937 0x94, 0x96, 0x8b, 0x95, 0x28, 0x2e, 0xa5, 0x71, 0x9e, 0xb4, 0xcb, 0xa5, 943 0xbb, 0x41, 0xb7, 0x26, 0x6b, 0xdc, 0xa5, 0xd6, 0x7b, 0xc1, 0xd2, 0xee,
938 0xb9, 0x28, 0xe6, 0xb5, 0xcb, 0x12, 0xf2, 0x9a, 0x95, 0x97, 0x2c, 0x8c, 944 0x4d, 0xe8, 0x43, 0xe7, 0x27, 0x58, 0xae, 0x5f, 0x60, 0xba, 0xac, 0x82,
939 0x25, 0xe5, 0xe2, 0x5c, 0x12, 0x31, 0xab, 0x47, 0x56, 0xe6, 0x7a, 0x30, 945 0x60, 0x3e, 0xa7, 0xe9, 0xd4, 0xf0, 0xdf, 0xf5, 0x72, 0x3e, 0x75, 0x7a,
940 0x96, 0xc2, 0xba, 0x14, 0xe6, 0xdb, 0xb2, 0x52, 0xb1, 0x81, 0x27, 0x87, 946 0x98, 0xf1, 0x83, 0x8e, 0x74, 0x9a, 0x96, 0x7d, 0xde, 0xa3, 0x3e, 0xc3,
941 0x76, 0x0e, 0xed, 0x21, 0xb9, 0xa4, 0xbe, 0x17, 0x30, 0x2f, 0x18, 0x42, 947 0x3c, 0x2c, 0x2f, 0x98, 0xf4, 0x88, 0x94, 0xdb, 0x6b, 0xd2, 0xa6, 0xcb,
942 0xdc, 0x62, 0x5e, 0x30, 0x82, 0x18, 0x32, 0x81, 0x27, 0x8a, 0x5d, 0xa7, 948 0x2b, 0xb0, 0xa5, 0xd4, 0x90, 0x79, 0x94, 0xec, 0xab, 0x17, 0x75, 0xbb,
943 0x66, 0xa6, 0x2a, 0xbc, 0x73, 0x84, 0x0e, 0xac, 0x53, 0x33, 0xd3, 0xb6, 949 0x3e, 0x05, 0x7b, 0x5e, 0x5a, 0xd4, 0x69, 0xa7, 0xac, 0xb1, 0x58, 0x36,
944 0x89, 0xba, 0xed, 0x1b, 0xda, 0x54, 0x83, 0x72, 0x41, 0xb7, 0x43, 0x1d, 950 0xf6, 0x31, 0x58, 0x7c, 0x78, 0xf6, 0x43, 0x6d, 0x67, 0xef, 0xa1, 0x4b,
945 0xa2, 0x3f, 0x4a, 0x9b, 0xe4, 0x79, 0x67, 0x20, 0xc6, 0x77, 0x01, 0x9f, 951 0x4f, 0xff, 0x16, 0x7c, 0x0d, 0xf3, 0xd5, 0xb0, 0x0e, 0x23, 0x9f, 0x58,
946 0x23, 0xfa, 0x6f, 0xd0, 0x17, 0xa0, 0xc3, 0x27, 0xba, 0xe4, 0xd2, 0xcb, 952 0x40, 0xee, 0x51, 0x45, 0x6e, 0x5c, 0xc8, 0x30, 0x6c, 0xc4, 0xef, 0xad,
947 0x8c, 0x35, 0xae, 0xbc, 0x7a, 0x96, 0x3a, 0x2c, 0xf6, 0xac, 0xea, 0x90, 953 0x92, 0xff, 0x42, 0xf2, 0x7f, 0x07, 0x55, 0xa5, 0x0d, 0x65, 0xe4, 0x3b,
948 0x63, 0x0f, 0xe1, 0x8c, 0xd8, 0x0f, 0x7b, 0x32, 0x33, 0x87, 0x90, 0xcb, 954 0x01, 0x1c, 0xea, 0x1d, 0x8f, 0x91, 0x2b, 0xc9, 0x77, 0xf7, 0x2a, 0x38,
949 0x7c, 0x1b, 0xf6, 0x59, 0x66, 0xcd, 0x9d, 0x0e, 0x6a, 0x84, 0x20, 0x06, 955 0xf6, 0x11, 0x19, 0x7e, 0x77, 0x14, 0x7b, 0x32, 0x8f, 0xa3, 0xf9, 0x6e,
950 0xa0, 0xdd, 0x47, 0x5d, 0xb1, 0xdd, 0x07, 0xbb, 0xe3, 0x58, 0x9f, 0x1a, 956 0x52, 0x36, 0x14, 0xf1, 0x1d, 0x89, 0x44, 0x33, 0x4d, 0xbf, 0x8b, 0x9a,
951 0x5b, 0x04, 0x8e, 0x60, 0x8c, 0xed, 0xcd, 0xb2, 0xa8, 0xc6, 0x0e, 0xaa, 957 0x67, 0xb2, 0x39, 0x48, 0xa5, 0xa6, 0x05, 0x19, 0xcc, 0xf4, 0xf1, 0xd9,
952 0xb1, 0xb2, 0xb2, 0x0f, 0x8e, 0x1d, 0x52, 0xb1, 0xe9, 0x7c, 0x23, 0xea, 958 0x8a, 0x2b, 0x38, 0x8f, 0x60, 0x5a, 0xef, 0xa5, 0xc3, 0x7e, 0x44, 0x4f,
953 0xdf, 0x88, 0x58, 0xc2, 0x7e, 0xf6, 0xe5, 0x61, 0xeb, 0x7b, 0x71, 0xae, 959 0x32, 0xa4, 0x6f, 0x32, 0x1c, 0x27, 0x42, 0x1a, 0xda, 0xf1, 0x25, 0x81,
954 0x15, 0x64, 0xa9, 0x81, 0x3a, 0x30, 0xff, 0x7b, 0x98, 0xcb, 0x3d, 0xc8, 960 0x0b, 0x31, 0x3e, 0xf7, 0x57, 0x21, 0x1e, 0xf6, 0x1f, 0xa0, 0x75, 0x32,
955 0x9e, 0x2a, 0xe9, 0xe4, 0xf1, 0x20, 0xce, 0x83, 0xfd, 0x21, 0xad, 0xb6, 961 0x43, 0x2b, 0x3e, 0xd3, 0xb1, 0x85, 0xaa, 0x69, 0xee, 0x1f, 0x80, 0x9e,
956 0x90, 0xaf, 0x03, 0x61, 0xbb, 0x25, 0xa4, 0x4d, 0x3c, 0x36, 0x70, 0x1c, 962 0x31, 0x9e, 0x4d, 0x9c, 0xc7, 0xac, 0xe3, 0xf1, 0x91, 0x66, 0x05, 0x3c,
957 0xc3, 0x5a, 0x17, 0x38, 0x18, 0x63, 0x11, 0x23, 0x52, 0x29, 0xe8, 0x82, 963 0x66, 0xfe, 0xf2, 0xba, 0x24, 0x2d, 0x7d, 0x85, 0xe5, 0xb7, 0x07, 0xf9,
958 0x34, 0xdb, 0xa4, 0xac, 0xde, 0xf7, 0xc3, 0x76, 0xb9, 0x16, 0x3a, 0xb4, 964 0x3b, 0xeb, 0xc2, 0x96, 0x50, 0xaf, 0xd4, 0x9e, 0xa5, 0x85, 0x1e, 0xc8,
959 0xa2, 0x75, 0xa5, 0x70, 0xcf, 0x53, 0xea, 0x9c, 0xd1, 0x93, 0x9b, 0xc3, 965 0x8a, 0xf7, 0xed, 0xa2, 0xbb, 0x61, 0xef, 0xc5, 0x06, 0xef, 0x3f, 0x09,
960 0x9c, 0x10, 0x7a, 0x45, 0x9c, 0xd5, 0x93, 0x8c, 0x37, 0xef, 0x84, 0x76, 966 0x3d, 0x7a, 0x59, 0xee, 0x5f, 0x5a, 0x19, 0x08, 0xe1, 0x19, 0xb6, 0x67,
961 0xda, 0x8b, 0xbe, 0x87, 0x44, 0xef, 0x65, 0xdf, 0x51, 0xe0, 0x61, 0xed, 967 0x03, 0x6c, 0x27, 0xed, 0xab, 0x9b, 0xd7, 0x81, 0xff, 0x7d, 0xc0, 0x0b,
962 0x3c, 0x0c, 0x99, 0xd9, 0xe6, 0xfa, 0x6c, 0xd3, 0xfa, 0xc4, 0x3a, 0xeb, 968 0x3a, 0x99, 0x63, 0x78, 0xc6, 0x83, 0x75, 0x8d, 0xf4, 0x67, 0xe0, 0x49,
963 0x3b, 0x9a, 0xfa, 0x32, 0x52, 0x9b, 0xef, 0x52, 0xf1, 0xf2, 0x7c, 0x18, 969 0xc9, 0x5a, 0xbe, 0xd8, 0xe8, 0xa4, 0x62, 0x3d, 0xc2, 0xc5, 0x78, 0x3e,
964 0x2f, 0x17, 0x6b, 0x94, 0x05, 0x7e, 0x96, 0x7f, 0x5b, 0xe9, 0xa2, 0x76, 970 0x46, 0xad, 0x7b, 0x9f, 0xc4, 0x35, 0x2d, 0x71, 0xe1, 0x7d, 0x83, 0x7d,
965 0x36, 0xb0, 0xf5, 0xa5, 0x93, 0x3c, 0x17, 0x57, 0xe7, 0xd5, 0xd4, 0xbc, 971 0xcd, 0xad, 0x80, 0x47, 0xbd, 0xee, 0x80, 0xb6, 0x54, 0x37, 0x2d, 0xc9,
966 0xdf, 0x06, 0xff, 0xba, 0x1c, 0x55, 0x32, 0x70, 0x3e, 0xe6, 0xd5, 0x02, 972 0x7a, 0xbd, 0x4b, 0xf9, 0x98, 0xd4, 0x66, 0xbc, 0xdf, 0x02, 0x5b, 0xdf,
967 0xbf, 0x31, 0x6c, 0xce, 0xa1, 0x8f, 0x44, 0x6b, 0x38, 0xff, 0xe7, 0xa8, 973 0x83, 0x3c, 0xa6, 0x07, 0x73, 0xd6, 0x86, 0xb9, 0x8d, 0xf4, 0x27, 0x36,
968 0x55, 0xbe, 0xac, 0xd6, 0xac, 0xfa, 0x0c, 0xf9, 0x71, 0x42, 0x9e, 0x7b, 974 0xd0, 0xdf, 0x89, 0x75, 0xfd, 0xd8, 0x53, 0xad, 0x2b, 0x61, 0xdd, 0xec,
969 0xc0, 0x5f, 0x67, 0x28, 0x43, 0x7b, 0x28, 0x03, 0xf1, 0xfd, 0x27, 0x70, 975 0x02, 0x6c, 0x82, 0x73, 0xf3, 0x34, 0xc7, 0xe4, 0x1b, 0x25, 0x2d, 0xb3,
970 0xb7, 0x61, 0x1e, 0x79, 0xdd, 0x86, 0x3e, 0xbe, 0xff, 0x17, 0xfa, 0x76, 976 0x2b, 0xef, 0xe1, 0x5c, 0x03, 0x80, 0x8d, 0xc6, 0x8a, 0x0f, 0x75, 0xe0,
971 0x23, 0xff, 0x23, 0x6f, 0x89, 0x26, 0xde, 0xfe, 0x03, 0x63, 0x3d, 0x4a, 977 0xf9, 0x5e, 0x43, 0xde, 0x4b, 0x40, 0x06, 0x9b, 0x53, 0x7c, 0xf6, 0x6a,
972 0xb7, 0x35, 0xd4, 0x26, 0x53, 0xbc, 0xef, 0x48, 0xe1, 0x1c, 0x38, 0xb9, 978 0xe3, 0xf3, 0x78, 0x76, 0x63, 0x1b, 0xbf, 0x98, 0x57, 0x4c, 0x2f, 0xd3,
973 0x4d, 0xd1, 0xad, 0x9d, 0xbd, 0x86, 0xf1, 0x5e, 0xac, 0x89, 0xda, 0xcd, 979 0x0a, 0x3d, 0x25, 0xd8, 0x9b, 0x8b, 0x9a, 0x2f, 0xa5, 0x53, 0x29, 0x87,
974 0xb2, 0xe9, 0x58, 0xfb, 0x53, 0x25, 0xcf, 0x62, 0xed, 0x4e, 0xf2, 0x6f, 980 0x78, 0xee, 0xf3, 0x5d, 0x2d, 0xdb, 0xe5, 0xa0, 0xaa, 0x0b, 0x1c, 0x8e,
975 0x5b, 0x23, 0x3b, 0xe5, 0x26, 0x4f, 0xe4, 0xa7, 0x1f, 0x4f, 0x2b, 0x72, 981 0xeb, 0x86, 0x3c, 0xfb, 0xe1, 0x15, 0xbe, 0xaf, 0xb5, 0x10, 0x4f, 0xed,
976 0x21, 0xd8, 0x6d, 0xd2, 0x90, 0xd1, 0x7c, 0x9a, 0xdf, 0xf9, 0x12, 0xbc, 982 0x2c, 0xe1, 0xec, 0x0f, 0xaf, 0x38, 0xf4, 0x68, 0x33, 0x4b, 0x47, 0x9b,
977 0x17, 0x1d, 0x19, 0xe4, 0x9e, 0xa1, 0xdd, 0x60, 0x4e, 0x47, 0x7f, 0x4b, 983 0xb6, 0x79, 0x3f, 0x7c, 0x40, 0x79, 0xed, 0x1e, 0x77, 0x57, 0x8a, 0xfd,
978 0xc8, 0x31, 0xd4, 0x24, 0xe5, 0x85, 0x8c, 0x56, 0x3c, 0x99, 0x45, 0x16, 984 0x96, 0x81, 0x9c, 0xb3, 0xc3, 0x51, 0x39, 0x48, 0x95, 0xeb, 0xb1, 0x05,
979 0xad, 0xbe, 0xd5, 0xc9, 0x8b, 0x4b, 0xb6, 0x7c, 0x1b, 0x7e, 0x7a, 0xb2, 985 0x9b, 0xef, 0x68, 0xcc, 0x06, 0x6d, 0xcc, 0x53, 0xfe, 0x2f, 0x73, 0x14,
980 0x9e, 0x4d, 0x7f, 0x13, 0xf9, 0xc1, 0x91, 0x25, 0xe6, 0x13, 0x3d, 0x29, 986 0xde, 0x9f, 0xfd, 0x34, 0x72, 0x12, 0x1f, 0x39, 0x89, 0x8f, 0x9c, 0xc4,
981 0x65, 0x9b, 0xf3, 0x9a, 0x6c, 0x60, 0x4c, 0x9b, 0x47, 0x7e, 0x6a, 0xdd, 987 0x47, 0x4e, 0xe2, 0x23, 0x27, 0xf1, 0x91, 0x93, 0xf8, 0xc8, 0x49, 0x7c,
982 0x2d, 0x47, 0x82, 0x9f, 0x57, 0xd7, 0xc6, 0x0c, 0xca, 0xb1, 0x36, 0x66, 988 0xe4, 0x24, 0xc8, 0xff, 0x55, 0x5d, 0x30, 0x8e, 0x5c, 0x1b, 0xfe, 0xcb,
983 0x10, 0x0f, 0x63, 0xc6, 0x4e, 0xec, 0x13, 0x63, 0x06, 0xf6, 0xff, 0x24, 989 0xff, 0x6a, 0x98, 0x53, 0x44, 0x31, 0x99, 0xe7, 0x56, 0x37, 0x79, 0x6e,
984 0x63, 0x86, 0x8d, 0x75, 0x8c, 0x19, 0x79, 0x59, 0xac, 0x32, 0x66, 0xec, 990 0x74, 0x4f, 0x7c, 0x00, 0x73, 0x13, 0x61, 0xee, 0xc3, 0x6b, 0xa2, 0x98,
985 0x45, 0x9b, 0x31, 0xa3, 0x80, 0x76, 0x10, 0x2f, 0x16, 0x55, 0xbc, 0xc8, 991 0xcd, 0xeb, 0x68, 0xcc, 0x43, 0xbd, 0x59, 0x98, 0xe4, 0xdc, 0x48, 0xc5,
986 0x5a, 0xcb, 0xc2, 0x38, 0x81, 0x3c, 0xb1, 0x8a, 0x3c, 0xb1, 0x8a, 0x3c, 992 0x2a, 0x95, 0x97, 0xbf, 0x8a, 0xfc, 0xc8, 0x42, 0x7e, 0x34, 0x88, 0x5c,
987 0xb1, 0x8a, 0x3c, 0xb1, 0x8a, 0x3c, 0x11, 0xb6, 0xfe, 0x5a, 0x15, 0x79, 993 0x88, 0xef, 0xb5, 0xa3, 0xfb, 0xa3, 0x82, 0x76, 0xc8, 0x1f, 0xd7, 0xbe,
988 0x22, 0xfc, 0xe7, 0x3c, 0x72, 0x92, 0xa0, 0xa6, 0x38, 0x8c, 0x9a, 0xc2, 994 0xe6, 0x73, 0xde, 0xee, 0x58, 0x65, 0x21, 0x16, 0xfa, 0x29, 0xa0, 0xe2,
989 0xd5, 0xc6, 0xaa, 0xe3, 0xda, 0xbe, 0x2a, 0x6a, 0x43, 0xf5, 0x9d, 0x58, 995 0xe8, 0xb7, 0x90, 0x23, 0x7f, 0x4f, 0xde, 0x95, 0x4d, 0x0c, 0xb3, 0xcc,
990 0x1f, 0xda, 0x80, 0xba, 0xa8, 0xe6, 0x6c, 0x01, 0x5f, 0xd7, 0xe0, 0x1b, 996 0x27, 0x3e, 0x25, 0x4f, 0x8e, 0xf8, 0xab, 0xee, 0xf8, 0xc4, 0x12, 0xf3,
991 0xd4, 0xd3, 0x56, 0x99, 0xca, 0xed, 0x80, 0x7c, 0xd8, 0x7f, 0xfb, 0xfb, 997 0x8f, 0xa8, 0xef, 0x2c, 0x18, 0x7e, 0x36, 0x41, 0xa9, 0x53, 0x5b, 0x30,
992 0xe8, 0x43, 0x3e, 0x9f, 0x63, 0x0d, 0xc2, 0x78, 0xb5, 0x0f, 0x6d, 0x1d, 998 0x67, 0x52, 0xbf, 0xbc, 0x27, 0x82, 0x28, 0xcf, 0xfe, 0x1a, 0xf2, 0x72,
993 0x6d, 0xec, 0xe9, 0x04, 0x7c, 0xc4, 0x7e, 0x90, 0xf9, 0x62, 0x7a, 0x41, 999 0x48, 0x9c, 0xe5, 0xdb, 0x04, 0xc6, 0xcb, 0xfe, 0xb5, 0x32, 0x53, 0x6c,
994 0x9e, 0xdc, 0x1c, 0xd8, 0xf4, 0x6f, 0x31, 0x27, 0x5e, 0xd3, 0xde, 0x88, 1000 0x54, 0xa4, 0x4e, 0x1d, 0x6a, 0x96, 0x90, 0x3f, 0xf5, 0xf6, 0x53, 0x97,
995 0x39, 0xf0, 0x17, 0xd8, 0x97, 0x5a, 0x03, 0x5c, 0xba, 0xfd, 0xe7, 0xc4, 1001 0x81, 0x1a, 0x2a, 0xc2, 0xcd, 0x38, 0x7f, 0x99, 0x92, 0xb5, 0xcd, 0xd9,
996 0xd1, 0xb7, 0xe1, 0xd6, 0x1c, 0xda, 0xd5, 0xf7, 0x9a, 0xfa, 0xb2, 0x98, 1002 0x35, 0x79, 0x42, 0xd6, 0xbc, 0x4f, 0x65, 0xa6, 0x5a, 0xb7, 0x33, 0x5c,
997 0xcf, 0xef, 0xe2, 0x3b, 0xf0, 0xfb, 0x16, 0x7e, 0x61, 0x77, 0xf6, 0x05, 1003 0xd7, 0x82, 0xd6, 0x99, 0x27, 0x81, 0x63, 0x19, 0x39, 0x81, 0x2e, 0xf7,
998 0xcc, 0xe9, 0xc3, 0xef, 0x77, 0x9a, 0xe6, 0x42, 0x0a, 0xfb, 0x2f, 0xd1, 1004 0xae, 0xcc, 0xcc, 0xd6, 0xd5, 0x5d, 0x95, 0xa2, 0x01, 0xf1, 0x2f, 0xd7,
999 0x77, 0x31, 0xa4, 0xc1, 0x6f, 0x89, 0x5f, 0x6a, 0xe2, 0xe3, 0x07, 0xe8, 1005 0x45, 0xfa, 0x92, 0xba, 0xb3, 0x12, 0x12, 0x96, 0xe1, 0x18, 0xde, 0x00,
1000 0xfb, 0x6b, 0xf4, 0xf9, 0xfe, 0xdb, 0x4e, 0xd4, 0x27, 0xa5, 0x96, 0x70, 1006 0x1c, 0xcb, 0x2d, 0x0b, 0x58, 0x96, 0x1d, 0xd3, 0x50, 0x99, 0xa9, 0x34,
1001 0xef, 0x46, 0xd5, 0xde, 0x69, 0xca, 0xe6, 0x8f, 0x2c, 0xe9, 0xaa, 0x0e, 1007 0xda, 0x69, 0x60, 0x3c, 0x8c, 0x37, 0x3a, 0x0f, 0x9f, 0x25, 0x45, 0xe2,
1002 0x7a, 0xae, 0x8e, 0xea, 0x08, 0x71, 0xbe, 0xbc, 0x10, 0xd4, 0xad, 0xc7, 1008 0x54, 0x10, 0x94, 0x47, 0x07, 0xc3, 0x3a, 0x12, 0xf5, 0xe3, 0x09, 0x43,
1003 0x51, 0x73, 0x16, 0xab, 0xb4, 0x91, 0x1c, 0xfa, 0x6d, 0x9c, 0x69, 0x32, 1009 0xea, 0xb9, 0x1a, 0x7f, 0x53, 0xc6, 0x29, 0x4b, 0xf0, 0x3c, 0x3f, 0xf1,
1004 0x69, 0xdc, 0xaa, 0x63, 0x13, 0x89, 0xc9, 0x7a, 0x9b, 0x48, 0x37, 0x69, 1010 0x2e, 0xf7, 0x24, 0xe6, 0x30, 0x5e, 0x8e, 0xd6, 0x8a, 0x70, 0x6d, 0x77,
1005 0x32, 0x4f, 0x22, 0x8e, 0xd9, 0x99, 0xe2, 0xc2, 0xec, 0x8c, 0x07, 0x9c, 1011 0x1b, 0x3f, 0x3b, 0xc2, 0xfd, 0x98, 0x26, 0x3e, 0xe7, 0x65, 0xec, 0xc5,
1006 0x63, 0x75, 0xae, 0xe5, 0x3c, 0x93, 0xf7, 0x63, 0x4d, 0x74, 0x69, 0x13, 1012 0x74, 0xf1, 0x1a, 0x13, 0xb4, 0x41, 0x96, 0xfe, 0xff, 0x96, 0xf7, 0xed,
1007 0x60, 0x06, 0xf4, 0x9e, 0xab, 0x93, 0x7e, 0x40, 0xb3, 0xac, 0x68, 0xda, 1013 0x67, 0x62, 0x9e, 0x1a, 0x80, 0xe1, 0xf5, 0x8c, 0x23, 0x82, 0xc1, 0x8b,
1008 0xe8, 0x8f, 0xea, 0xc7, 0x1c, 0x6a, 0x5d, 0x99, 0x64, 0xed, 0x5c, 0x0c, 1014 0xb3, 0x0a, 0x4e, 0xac, 0xdd, 0xed, 0x7d, 0xd6, 0xbe, 0xed, 0xb4, 0x46,
1009 0x69, 0xba, 0x75, 0x49, 0x24, 0x0a, 0xcd, 0xf8, 0x82, 0x8c, 0xf3, 0xb9, 1015 0xfb, 0x47, 0x78, 0xb2, 0x4a, 0x6e, 0x6b, 0xf0, 0xf2, 0xff, 0x0a, 0xc3,
1010 0xfa, 0xec, 0x8c, 0xfe, 0x42, 0x36, 0xc7, 0x3b, 0x11, 0xd7, 0x9a, 0x9d, 1016 0x13, 0xba, 0xf8, 0x89, 0x3b, 0xd2, 0x6c, 0x5b, 0x6d, 0x1c, 0xdd, 0x35,
1011 0x69, 0x1d, 0x48, 0xc8, 0x8f, 0x91, 0xbb, 0x1d, 0x53, 0x34, 0x66, 0x67, 1017 0x70, 0xcd, 0xcf, 0x35, 0x3c, 0x7f, 0x47, 0x68, 0xaf, 0x4b, 0x4b, 0x61,
1012 0x8c, 0x17, 0x02, 0x5b, 0x0c, 0xe8, 0xe0, 0x3c, 0xc9, 0xb7, 0x43, 0x4e, 1018 0x2c, 0x83, 0x2e, 0xaa, 0xbb, 0xd4, 0x70, 0x6c, 0x70, 0x6c, 0x43, 0xe3,
1013 0xd2, 0x62, 0x4d, 0x1d, 0x8c, 0x4f, 0xaa, 0x7a, 0xd1, 0x94, 0x2b, 0x15, 1019 0x1c, 0x3f, 0xb2, 0x91, 0xf6, 0x7b, 0x42, 0x95, 0x9b, 0x9c, 0x59, 0x8c,
1014 0x45, 0x3b, 0xac, 0xdb, 0xc9, 0xc3, 0xec, 0x8c, 0xfc, 0xd1, 0x2d, 0x1e, 1020 0x7c, 0x0e, 0xfc, 0xc1, 0xb0, 0x11, 0xfa, 0xed, 0x24, 0xfc, 0x56, 0x0f,
1015 0xd6, 0x91, 0x87, 0x78, 0x49, 0x27, 0xd0, 0x5b, 0xc0, 0x7f, 0x12, 0xf5, 1021 0xed, 0x83, 0xbf, 0xb9, 0x13, 0xfe, 0x66, 0x3f, 0xea, 0xca, 0xf1, 0x95,
1016 0x7b, 0x54, 0xab, 0xfb, 0xfe, 0x8a, 0x93, 0x43, 0x5c, 0xe0, 0x3e, 0xb6, 1022 0xf6, 0xfb, 0x57, 0xae, 0x65, 0xab, 0x74, 0x58, 0xca, 0xae, 0x12, 0xe8,
1017 0xa8, 0x3c, 0xd7, 0x73, 0x32, 0xbc, 0xef, 0x9b, 0xe3, 0xdf, 0x39, 0x78, 1023 0xce, 0xc7, 0x90, 0xdf, 0x2e, 0x99, 0xa3, 0x29, 0x79, 0xc2, 0x57, 0xba,
1018 0xf9, 0x01, 0xd4, 0x4d, 0xbc, 0x1b, 0xa4, 0x7f, 0xe1, 0xf7, 0x36, 0xff, 1024 0xfc, 0x2d, 0x62, 0xe3, 0x3d, 0x6f, 0x16, 0x7a, 0xdd, 0x55, 0x10, 0x32,
1019 0xe2, 0x7c, 0xf6, 0x93, 0xe7, 0x81, 0xf4, 0x55, 0xf0, 0xe7, 0xe5, 0xd1, 1025 0xff, 0x52, 0x7c, 0xab, 0x36, 0x14, 0xdf, 0xe0, 0x53, 0x81, 0xdf, 0xa0,
1020 0x87, 0x58, 0x51, 0x6c, 0x44, 0xb8, 0x78, 0xc7, 0xce, 0x39, 0x2a, 0xff, 1026 0x4a, 0xd3, 0xa4, 0x0a, 0xf6, 0xad, 0x60, 0xdf, 0x0a, 0xea, 0xc1, 0xd9,
1021 0x6e, 0xf2, 0xd1, 0x96, 0xf0, 0xdc, 0xa5, 0x8e, 0xc8, 0x27, 0xf9, 0xe9, 1027 0x66, 0xfb, 0x77, 0xaa, 0xee, 0xb0, 0xc6, 0x66, 0xd8, 0xa8, 0x6f, 0x86,
1022 0x84, 0x4d, 0x90, 0x17, 0xce, 0x8f, 0xee, 0x25, 0xd8, 0xfe, 0xb8, 0x36, 1028 0xe7, 0xd2, 0xda, 0x9e, 0xc7, 0xc0, 0xbb, 0x47, 0xc1, 0xbb, 0x23, 0xa8,
1023 0x12, 0xdd, 0xa9, 0x7d, 0x9c, 0x3d, 0x8f, 0x74, 0x76, 0x37, 0x7e, 0x88, 1029 0x83, 0xfe, 0x04, 0x75, 0xd0, 0x1f, 0xa2, 0x0e, 0x3a, 0x8c, 0x3a, 0x68,
1024 0x83, 0xb4, 0x23, 0xbe, 0x22, 0x9e, 0x88, 0x8f, 0xfc, 0x44, 0xbc, 0x28, 1030 0x0a, 0x75, 0xd0, 0x7d, 0xb0, 0xfd, 0x7b, 0x61, 0xfb, 0x93, 0xb0, 0xfd,
1025 0x1b, 0x5d, 0x97, 0x9f, 0x60, 0x5d, 0xc0, 0x4f, 0x69, 0x21, 0x0d, 0x9d, 1031 0x09, 0x79, 0xc7, 0x73, 0xc8, 0xdf, 0x78, 0xef, 0x11, 0xed, 0xc5, 0xed,
1026 0x90, 0xa7, 0x11, 0x6d, 0xa4, 0xba, 0xde, 0x1d, 0xc7, 0x0f, 0x5c, 0xc6, 1032 0x4d, 0x22, 0x88, 0xaf, 0x7c, 0x62, 0x9c, 0x1a, 0x2d, 0xae, 0x87, 0x5c,
1027 0xd5, 0xb1, 0x06, 0xef, 0xa1, 0x48, 0x97, 0x7f, 0x3b, 0xb2, 0xa4, 0x8d, 1033 0x79, 0x7f, 0x35, 0xed, 0x4e, 0x6a, 0x53, 0xc8, 0xb9, 0xef, 0x1f, 0xe1,
1028 0x34, 0xf8, 0x9d, 0xa9, 0xae, 0xb9, 0x8d, 0x88, 0xde, 0x5a, 0x9d, 0x46, 1034 0x3a, 0x29, 0xa5, 0xee, 0x2b, 0x73, 0xf6, 0x73, 0x1e, 0xd2, 0x2e, 0xe4,
1029 0xbf, 0xbc, 0x2b, 0xff, 0x0c, 0xf6, 0xa9, 0x3b, 0xf8, 0xbb, 0x14, 0x55, 1035 0x6d, 0x38, 0xb3, 0x7d, 0xa6, 0xa8, 0x47, 0x35, 0x4a, 0xdf, 0x5a, 0x8d,
1030 0x47, 0xb1, 0x6f, 0xb9, 0xd5, 0x73, 0xa2, 0xbf, 0xd3, 0xd9, 0x1f, 0xe6, 1036 0xb2, 0x3c, 0xcf, 0x35, 0xca, 0xab, 0x6b, 0x35, 0xca, 0xf2, 0x3c, 0xd7,
1031 0x43, 0x51, 0x6d, 0x1c, 0xd5, 0x59, 0xea, 0x9e, 0x7d, 0xaf, 0xe7, 0x68, 1037 0x28, 0xaf, 0xac, 0xab, 0x51, 0xae, 0x3c, 0xfd, 0xf2, 0xba, 0x1a, 0xe5,
1032 0xc8, 0x4f, 0x99, 0x33, 0x05, 0x3a, 0x08, 0xf1, 0xde, 0x91, 0xcf, 0x91, 1038 0xca, 0xd3, 0x2f, 0x85, 0x63, 0xa6, 0x03, 0x7e, 0xc9, 0x0d, 0x69, 0x35,
1033 0x26, 0x3e, 0x47, 0xc1, 0xe7, 0x3e, 0xf0, 0x39, 0x76, 0x8b, 0xcf, 0x5b, 1039 0x5d, 0x3c, 0x7b, 0xc3, 0x7c, 0xe1, 0xfb, 0xfd, 0xeb, 0xff, 0x1f, 0x3a,
1034 0xb6, 0x97, 0x29, 0xc3, 0xf6, 0x46, 0xd6, 0xb5, 0xbd, 0x55, 0x3a, 0xab, 1040 0x6e, 0x9d, 0x1a, 0x39, 0xdf, 0xd8, 0xaa, 0xea, 0x9a, 0xf6, 0xf9, 0xde,
1035 0x73, 0x83, 0xfb, 0x9a, 0x91, 0x86, 0x2f, 0xc7, 0x9d, 0x8f, 0x53, 0x37, 1041 0xb6, 0xf9, 0x55, 0xf9, 0x6d, 0xb4, 0x5c, 0xdb, 0xfc, 0x3e, 0xbc, 0x27,
1036 0xb7, 0xcb, 0x99, 0x85, 0xbb, 0xd5, 0xb7, 0x11, 0xaf, 0x2a, 0x77, 0x94, 1042 0xad, 0x0c, 0xdb, 0xf5, 0x02, 0x7d, 0x1c, 0xf0, 0xf7, 0x3d, 0x4f, 0x74,
1037 0x4b, 0xf5, 0x80, 0x9f, 0x1f, 0x2f, 0xb1, 0x3d, 0x12, 0xea, 0x8a, 0x3a, 1043 0xc9, 0xef, 0x6a, 0x9e, 0xcc, 0x91, 0x61, 0xa3, 0xa3, 0x47, 0xb7, 0x2a,
1038 0xcb, 0x3a, 0x25, 0xb9, 0x1b, 0x2f, 0xbf, 0xf8, 0x9c, 0x76, 0xa5, 0x12, 1044 0x3b, 0xe6, 0x7e, 0x5a, 0x53, 0xbe, 0xf9, 0x41, 0xe0, 0x01, 0xaf, 0x7d,
1039 0x9d, 0x4f, 0x5a, 0x78, 0xc6, 0xae, 0xe5, 0x29, 0xfa, 0x6e, 0x32, 0x66, 1045 0x43, 0xde, 0xe1, 0xa8, 0xf3, 0xaa, 0xbb, 0x6c, 0x23, 0xbf, 0x8a, 0x38,
1040 0x45, 0xf7, 0x67, 0x22, 0xfc, 0xfe, 0xc0, 0xef, 0x75, 0x6b, 0xbf, 0x13, 1046 0x03, 0x59, 0x4b, 0xdc, 0x5c, 0xf3, 0x71, 0x9d, 0x18, 0xf9, 0xef, 0x08,
1041 0xf0, 0x7c, 0x8a, 0x78, 0xd7, 0x53, 0x3c, 0x9f, 0xc6, 0x9c, 0x66, 0x19, 1047 0xd7, 0xcf, 0xd2, 0x8a, 0xee, 0xdb, 0x50, 0xef, 0xf1, 0x9a, 0x68, 0xdc,
1042 0x5c, 0xd8, 0xa4, 0x9e, 0xe4, 0x98, 0xe7, 0xd0, 0x2f, 0x4c, 0xd0, 0x0c, 1048 0x5e, 0x1f, 0x26, 0xc3, 0xfb, 0xac, 0x55, 0x95, 0x13, 0x49, 0x7c, 0x46,
1043 0xee, 0xdd, 0x6a, 0x4b, 0xbe, 0x5c, 0x74, 0x36, 0x06, 0xe7, 0x28, 0x64, 1049 0x88, 0xef, 0xbf, 0x02, 0xe5, 0x37, 0x18, 0xde, 0x6c, 0x83, 0x1f, 0x47,
1044 0xba, 0x6c, 0xf1, 0xfe, 0x0a, 0x31, 0x8c, 0x67, 0x83, 0xb2, 0xb5, 0x16, 1050 0x9e, 0xc6, 0x77, 0x2b, 0x9c, 0x6f, 0x19, 0xf4, 0xee, 0x7c, 0x37, 0xbd,
1045 0xf5, 0x5c, 0x39, 0xd0, 0x0e, 0x1d, 0xb3, 0xdd, 0xd6, 0xcb, 0xfb, 0x0a, 1051 0x73, 0x1c, 0xf9, 0xa6, 0x6b, 0x67, 0x5f, 0x46, 0xbd, 0x70, 0x8a, 0xf3,
1046 0xca, 0xbc, 0xa0, 0xf6, 0x21, 0xd2, 0x71, 0xf4, 0x7d, 0xae, 0x55, 0x96, 1052 0xe2, 0x51, 0xa6, 0x73, 0xc8, 0x9a, 0x25, 0xab, 0x5f, 0xe5, 0xd1, 0x47,
1047 0xc3, 0xbb, 0xad, 0xc5, 0x8a, 0xef, 0xbf, 0x83, 0x3c, 0xfc, 0x34, 0x74, 1053 0xb4, 0x4f, 0xd2, 0x2d, 0xc2, 0x7d, 0x7e, 0xd6, 0xb6, 0x8f, 0xd5, 0xb6,
1048 0x5f, 0xae, 0xff, 0xcc, 0x5f, 0x4e, 0xf1, 0x6f, 0xa5, 0x22, 0x9b, 0xd8, 1054 0x4f, 0x81, 0xed, 0xad, 0xf1, 0x75, 0x9c, 0xb9, 0xb2, 0xfd, 0x26, 0x33,
1049 0xd1, 0xcb, 0x7b, 0x20, 0xf8, 0x96, 0x1c, 0xaf, 0x87, 0x65, 0xbf, 0x70, 1055 0x1d, 0xd6, 0x52, 0x8f, 0x8c, 0x6e, 0xa6, 0xfa, 0x80, 0x7d, 0xee, 0x15,
1050 0x9c, 0x7d, 0xff, 0x0d, 0xbe, 0x7d, 0xff, 0xf4, 0xaa, 0x9d, 0x02, 0xfe, 1056 0xe4, 0xda, 0xe5, 0x51, 0xcc, 0xa5, 0x87, 0xf0, 0x8e, 0xe7, 0xed, 0x06,
1051 0x17, 0x33, 0xe1, 0x9b, 0xdd, 0x90, 0x58, 0x00, 0x00, 0x00 }; 1057 0x09, 0xfb, 0x5c, 0x83, 0x90, 0x4c, 0x77, 0xd9, 0x15, 0xbe, 0x63, 0x4b,
1058 0x0b, 0xee, 0x4b, 0xda, 0x1a, 0xa1, 0xfd, 0x66, 0x2e, 0xe2, 0xcc, 0x53,
1059 0xa8, 0x99, 0x8e, 0xa8, 0xbb, 0xaf, 0x70, 0x9f, 0x5b, 0xb4, 0x8b, 0x32,
1060 0xaf, 0xcd, 0x69, 0x95, 0xb4, 0x3a, 0xe3, 0x37, 0x60, 0xeb, 0xba, 0x60,
1061 0xd8, 0x77, 0x81, 0x5b, 0xa3, 0xa5, 0xe3, 0xba, 0xbc, 0xeb, 0x2c, 0x8f,
1062 0xb2, 0xac, 0xf9, 0x79, 0x3d, 0xde, 0x45, 0x67, 0xfa, 0xdb, 0xf0, 0x4c,
1063 0x5f, 0x0a, 0x6b, 0xed, 0xe8, 0x4c, 0x09, 0x7a, 0x63, 0xde, 0x04, 0xec,
1064 0x08, 0xf8, 0x51, 0xa2, 0x95, 0x96, 0xf5, 0x39, 0x78, 0x6a, 0x6d, 0xbc,
1065 0x31, 0x36, 0xc8, 0x30, 0xaa, 0x59, 0xc0, 0x83, 0x89, 0x0c, 0xec, 0x70,
1066 0xba, 0x3f, 0xba, 0x83, 0xd5, 0x1d, 0xa1, 0xa9, 0xda, 0x9b, 0xe7, 0x07,
1067 0x61, 0x8b, 0x16, 0xec, 0x93, 0xf3, 0x9d, 0x12, 0xd7, 0x19, 0xe1, 0xf7,
1068 0x4b, 0xdb, 0x9c, 0xa4, 0x2c, 0x6a, 0x15, 0x3e, 0x7f, 0x9e, 0x96, 0x5b,
1069 0x11, 0x0d, 0x39, 0xd8, 0xe3, 0x18, 0x7e, 0x23, 0x78, 0xe7, 0xe2, 0xc7,
1070 0x75, 0x4e, 0x81, 0x1e, 0x93, 0x79, 0x34, 0xf2, 0xe4, 0x61, 0xa6, 0xef,
1071 0x00, 0xd6, 0xb3, 0x3e, 0xb3, 0x9e, 0x1e, 0x20, 0x6f, 0x80, 0x7d, 0x45,
1072 0x06, 0xb8, 0x01, 0xe3, 0xbf, 0x0e, 0x5b, 0x1f, 0xc4, 0xd3, 0x36, 0xcb,
1073 0xcc, 0x5b, 0x89, 0x3f, 0x08, 0xf4, 0x1c, 0x7f, 0x3b, 0x18, 0x0f, 0xc7,
1074 0x43, 0xe6, 0xdd, 0xac, 0x7b, 0x99, 0x1d, 0x74, 0x6e, 0x31, 0x8a, 0x61,
1075 0x33, 0xb0, 0x41, 0xbe, 0x53, 0x1d, 0x07, 0x5f, 0x78, 0xac, 0x85, 0xb1,
1076 0x0c, 0xf3, 0xcb, 0x0b, 0x38, 0x77, 0x9e, 0x4e, 0xa1, 0x66, 0xa7, 0x01,
1077 0x7e, 0x22, 0x57, 0xf5, 0xb7, 0x84, 0xfa, 0xbe, 0x1e, 0x5e, 0x77, 0xb8,
1078 0x3f, 0x0e, 0xfa, 0x8c, 0x36, 0x78, 0x86, 0x51, 0xb5, 0xc5, 0x45, 0x42,
1079 0x2c, 0xcd, 0x04, 0xb7, 0x8b, 0xfc, 0x7d, 0xf4, 0x80, 0x3c, 0x53, 0x9e,
1080 0x0e, 0x2f, 0x06, 0x81, 0x97, 0x1b, 0xca, 0x2e, 0x93, 0x9d, 0x7d, 0x92,
1081 0xf6, 0x98, 0xfb, 0x48, 0x97, 0xdf, 0xe0, 0x50, 0x13, 0xdf, 0xde, 0x91,
1082 0x0f, 0x82, 0x93, 0xa0, 0xfd, 0x05, 0xb9, 0xcf, 0x7d, 0xa0, 0x1f, 0xbc,
1083 0x92, 0xf5, 0x04, 0xd3, 0x0a, 0xde, 0xa4, 0x99, 0xde, 0x24, 0x1d, 0x6e,
1084 0x9d, 0x0f, 0x65, 0xf3, 0x28, 0x79, 0xfe, 0xdb, 0x3a, 0xdf, 0x47, 0x97,
1085 0x5b, 0x4f, 0x86, 0xb4, 0xe5, 0x41, 0x2f, 0xf6, 0x6f, 0xbd, 0x90, 0x66,
1086 0xdf, 0xc0, 0x32, 0xf7, 0x90, 0xf1, 0x79, 0xa3, 0xcf, 0x40, 0x07, 0x3f,
1087 0xcd, 0x0f, 0xa4, 0x68, 0xbd, 0x1f, 0x60, 0xb8, 0xd4, 0x75, 0x74, 0x85,
1088 0xe9, 0x20, 0xe9, 0x3f, 0x85, 0xb3, 0x19, 0xf4, 0x30, 0x3e, 0x7d, 0x83,
1089 0x2f, 0xa8, 0xc8, 0xe7, 0xaa, 0xce, 0xbe, 0x89, 0xe3, 0x14, 0xeb, 0x70,
1090 0x0f, 0xfc, 0x1f, 0x74, 0x10, 0x76, 0x5c, 0x5c, 0xe4, 0x3b, 0x85, 0x61,
1091 0xbe, 0x87, 0x3a, 0x53, 0x82, 0x6c, 0x97, 0xf8, 0xbb, 0x60, 0x5a, 0xe5,
1092 0x82, 0xaa, 0x76, 0xb2, 0xd8, 0x17, 0x32, 0xaf, 0xa5, 0x9f, 0x2c, 0xc9,
1093 0xef, 0x80, 0x29, 0xac, 0x09, 0xf0, 0x6c, 0xff, 0x9b, 0x88, 0x9f, 0x14,
1094 0xd4, 0xdf, 0x44, 0x84, 0xdf, 0x64, 0x1b, 0x2a, 0x07, 0x78, 0xb8, 0x69,
1095 0xd0, 0x54, 0x33, 0xfa, 0x1b, 0x09, 0x96, 0x83, 0x83, 0x3a, 0x3e, 0x8a,
1096 0xfb, 0x81, 0x8c, 0x2f, 0xd5, 0x75, 0xb2, 0xfc, 0x66, 0x98, 0xcf, 0x70,
1097 0xfe, 0xce, 0x3c, 0xc4, 0x78, 0x59, 0xc9, 0x6f, 0x49, 0xec, 0x84, 0xfc,
1098 0xc0, 0x73, 0xdf, 0x80, 0x2d, 0x65, 0xc2, 0x98, 0x6c, 0x72, 0x7d, 0x18,
1099 0xd6, 0xac, 0xdb, 0xa9, 0x3a, 0xc9, 0xef, 0x13, 0xf4, 0xfa, 0xfc, 0xa0,
1100 0x7c, 0x5f, 0xa6, 0x44, 0xf8, 0x9e, 0xc7, 0x29, 0x2a, 0xcb, 0xf7, 0xf7,
1101 0x86, 0xf8, 0x50, 0x63, 0xdd, 0x1b, 0x8d, 0x33, 0x90, 0xa3, 0x82, 0x9b,
1102 0x46, 0x2c, 0x7b, 0x0c, 0x71, 0x6c, 0x1a, 0x7c, 0x2f, 0x4e, 0x54, 0x68,
1103 0x87, 0xc3, 0x3a, 0x0e, 0x99, 0xa5, 0x58, 0xc7, 0x58, 0xbf, 0x18, 0xa6,
1104 0x17, 0x79, 0x26, 0xce, 0x3b, 0x4a, 0x53, 0x7a, 0xfe, 0xfd, 0x83, 0xe5,
1105 0x9a, 0x6d, 0x16, 0xe8, 0xa3, 0xc0, 0x33, 0x78, 0xbc, 0x7a, 0xf0, 0x61,
1106 0x75, 0x4f, 0x2f, 0x44, 0xfe, 0xd2, 0xc1, 0xb2, 0xea, 0xe3, 0xcc, 0xef,
1107 0x87, 0x7d, 0x86, 0xd3, 0xe5, 0xf7, 0xd3, 0x7f, 0xbf, 0xd5, 0xa0, 0x8b,
1108 0xb7, 0x06, 0xc1, 0xfd, 0xfc, 0x0d, 0x27, 0xac, 0x41, 0xd5, 0x77, 0x71,
1109 0x8e, 0x13, 0xa8, 0x37, 0x46, 0x2d, 0xad, 0x04, 0xdb, 0x3d, 0xe5, 0xa3,
1110 0x5e, 0x11, 0xf6, 0xd8, 0xaa, 0x30, 0x11, 0x7f, 0xb9, 0x96, 0xff, 0xcd,
1111 0x7e, 0xfe, 0x26, 0x3c, 0xe7, 0xf2, 0x9a, 0x6d, 0xea, 0xae, 0xea, 0xe6,
1112 0xdb, 0xa4, 0xcf, 0x25, 0x0a, 0xe3, 0xd0, 0xcd, 0xed, 0xf6, 0xd1, 0x9e,
1113 0x23, 0xb2, 0x5d, 0xd0, 0x94, 0x01, 0x7a, 0xaa, 0xb5, 0x28, 0xdf, 0xe2,
1114 0xef, 0xfd, 0xab, 0x07, 0xbf, 0xdb, 0xbc, 0x74, 0x70, 0x16, 0xf2, 0xe1,
1115 0x33, 0xcd, 0x36, 0x23, 0xfd, 0x8b, 0x72, 0x7e, 0xee, 0x23, 0xfe, 0xfb,
1116 0x88, 0xff, 0x3e, 0xe2, 0xbf, 0x8f, 0xf8, 0xef, 0x23, 0xfe, 0xfb, 0x88,
1117 0xff, 0xe0, 0xe1, 0x0f, 0xa0, 0x2f, 0xe7, 0xfd, 0x89, 0x30, 0xdf, 0x7a,
1118 0x7c, 0x2d, 0xdf, 0x3a, 0xd7, 0xe2, 0x6f, 0x3f, 0x92, 0x96, 0x4a, 0x85,
1119 0x54, 0xbe, 0x4a, 0x82, 0xf3, 0x9b, 0x28, 0x5f, 0xbd, 0xfe, 0x37, 0x0c,
1120 0x05, 0xc7, 0xb9, 0x1a, 0xc3, 0x55, 0x34, 0xe1, 0x30, 0x9c, 0xca, 0xd7,
1121 0xb8, 0x46, 0x5a, 0x0f, 0xc3, 0xdf, 0xc9, 0xd8, 0xb7, 0xa9, 0x6f, 0x34,
1122 0xea, 0x7b, 0xd0, 0xe3, 0x5f, 0xf7, 0x10, 0x8b, 0xcb, 0x4d, 0x19, 0x8f,
1123 0x31, 0x7e, 0x06, 0x63, 0x83, 0xf5, 0x8f, 0xdf, 0xdd, 0xc3, 0x75, 0x41,
1124 0xb9, 0x89, 0xbc, 0x68, 0x39, 0xca, 0x85, 0x00, 0xe7, 0xbf, 0xa9, 0x95,
1125 0xea, 0x2c, 0x67, 0x41, 0xb3, 0x69, 0x30, 0xc5, 0x69, 0xaf, 0x75, 0x5e,
1126 0x96, 0xb5, 0x8e, 0xfa, 0x9b, 0x9e, 0x11, 0xd0, 0x16, 0xdd, 0xfd, 0x12,
1127 0xe9, 0xf3, 0x69, 0xf9, 0x77, 0x00, 0x29, 0x67, 0x58, 0xfe, 0x3d, 0x42,
1128 0x1f, 0xf6, 0x11, 0xf3, 0x3b, 0xdb, 0xee, 0x56, 0xa9, 0xa0, 0x7c, 0x76,
1129 0xa7, 0xfa, 0x3b, 0x08, 0x91, 0x86, 0xed, 0xde, 0xb6, 0x0d, 0x67, 0x83,
1130 0x5c, 0x5f, 0xdd, 0x2a, 0xf3, 0x67, 0xf8, 0xd1, 0x93, 0xc3, 0x7d, 0x03,
1131 0xd4, 0xb3, 0x9d, 0x4e, 0x0d, 0x73, 0xad, 0xb5, 0x19, 0xf8, 0x78, 0xad,
1132 0x9d, 0x2d, 0x88, 0xed, 0x74, 0x7a, 0x11, 0x7e, 0x76, 0xd1, 0x76, 0x59,
1133 0x97, 0x97, 0x86, 0xd3, 0xf0, 0xcf, 0x63, 0x03, 0x1c, 0x9f, 0x97, 0x5b,
1134 0xac, 0x2b, 0x7d, 0x80, 0x1f, 0x84, 0x5e, 0x6e, 0x82, 0x3d, 0x09, 0xec,
1135 0x1f, 0xe1, 0xfe, 0xb9, 0xc4, 0xdd, 0xe7, 0xec, 0xd9, 0x26, 0x75, 0x43,
1136 0xd8, 0xa6, 0x25, 0x40, 0xfb, 0x27, 0x6a, 0x44, 0x97, 0xf8, 0x6c, 0xb3,
1137 0x7e, 0xfb, 0xb7, 0xba, 0x37, 0xb5, 0x72, 0x9d, 0xff, 0x0e, 0x61, 0x98,
1138 0xf6, 0x41, 0xbf, 0x4c, 0xe7, 0x4d, 0xed, 0x81, 0xc6, 0xff, 0x14, 0x6e,
1139 0x75, 0xb1, 0x71, 0x5c, 0x55, 0xf8, 0xdc, 0x59, 0xaf, 0xed, 0x38, 0x6b,
1140 0x67, 0xe2, 0x6c, 0xec, 0xb5, 0x15, 0xc4, 0xce, 0x7a, 0x12, 0x4f, 0xb5,
1141 0x8e, 0x3a, 0xb6, 0x12, 0xb4, 0x42, 0x96, 0x58, 0xed, 0x7a, 0x5d, 0x87,
1142 0x92, 0xb2, 0x85, 0x50, 0x05, 0x09, 0x55, 0x96, 0x9d, 0xd2, 0x54, 0x80,
1143 0x90, 0xfa, 0x80, 0x78, 0xcb, 0x6a, 0x6d, 0x87, 0xa4, 0xec, 0x76, 0x6d,
1144 0x62, 0xd7, 0x2f, 0x3c, 0x2c, 0xeb, 0x75, 0x6a, 0xbb, 0x9b, 0xac, 0x42,
1145 0xfb, 0x50, 0x9e, 0x62, 0x99, 0x92, 0xc2, 0x4b, 0x85, 0xc4, 0x03, 0x02,
1146 0x54, 0xa9, 0x4a, 0xda, 0x34, 0x0f, 0x25, 0x11, 0xbc, 0x50, 0x0a, 0xd2,
1147 0xf0, 0x7d, 0x77, 0x66, 0x1d, 0x27, 0x50, 0x61, 0x69, 0x35, 0x77, 0xee,
1148 0xdc, 0x3b, 0x73, 0x7f, 0xce, 0xf9, 0xce, 0x77, 0xce, 0x3d, 0x66, 0x1b,
1149 0x1b, 0x65, 0xfa, 0xd3, 0xab, 0x6a, 0xa6, 0xda, 0x2b, 0x0b, 0x90, 0xe3,
1150 0xe2, 0x48, 0x38, 0x88, 0x97, 0x76, 0x05, 0xfa, 0x0c, 0xc7, 0xdf, 0xb7,
1151 0x57, 0x9a, 0x57, 0x16, 0xcd, 0x4e, 0xcd, 0xab, 0x1e, 0x7d, 0x76, 0x0a,
1152 0x63, 0x8a, 0x61, 0x1d, 0xba, 0xfb, 0x34, 0x36, 0x19, 0xbc, 0xef, 0x7f,
1153 0xec, 0xbe, 0xef, 0xb1, 0xfb, 0xc3, 0xff, 0xa3, 0x3d, 0xcb, 0x8f, 0xcb,
1154 0x03, 0xc7, 0x69, 0xa5, 0xf8, 0x95, 0x62, 0xc9, 0x36, 0x66, 0x4b, 0x56,
1155 0x9a, 0xbc, 0x20, 0x2b, 0x9e, 0xca, 0xba, 0xed, 0xc0, 0xbb, 0x76, 0x99,
1156 0x5f, 0x86, 0xcc, 0x63, 0x1e, 0x1d, 0x36, 0xcf, 0xb4, 0x13, 0x7d, 0xd4,
1157 0x99, 0x4e, 0x6c, 0x83, 0x61, 0x0f, 0xc5, 0xd0, 0xce, 0x7b, 0xc9, 0x4d,
1158 0x9a, 0xe7, 0x74, 0x1c, 0x86, 0x7c, 0xc6, 0x53, 0x45, 0x9d, 0x9f, 0xc1,
1159 0x36, 0x6d, 0x72, 0xc7, 0xce, 0xf4, 0x06, 0xf9, 0x3e, 0xf0, 0x5b, 0xc7,
1160 0xfa, 0xc8, 0x35, 0x5e, 0x74, 0x77, 0xeb, 0xcc, 0xdb, 0xc2, 0x3c, 0x2a,
1161 0x08, 0xcd, 0xb3, 0x22, 0xd5, 0xba, 0xc8, 0xeb, 0xf8, 0xfd, 0xae, 0x1e,
1162 0xf8, 0x0a, 0x8a, 0x3e, 0xf3, 0xb8, 0x6c, 0x55, 0xbe, 0x2c, 0x0d, 0xd8,
1163 0x9f, 0x4d, 0xd7, 0xf3, 0xee, 0xb9, 0x71, 0xbd, 0xe6, 0x3f, 0x29, 0x29,
1164 0x49, 0x8c, 0xd2, 0xbe, 0xb5, 0xcb, 0x4f, 0x97, 0xdb, 0x64, 0xdb, 0xb4,
1165 0xcc, 0x7b, 0xc2, 0x5c, 0xb6, 0x98, 0x4c, 0x45, 0x43, 0x9a, 0xa3, 0xca,
1166 0xb7, 0xc0, 0xa0, 0xf1, 0xec, 0xee, 0xf2, 0x33, 0x7d, 0x8c, 0x9d, 0x7c,
1167 0xb4, 0xcc, 0x7b, 0x03, 0x57, 0x43, 0x76, 0xec, 0x10, 0xb8, 0x2c, 0x40,
1168 0xc8, 0xe4, 0xba, 0x73, 0xbe, 0xcf, 0x71, 0x6c, 0xa8, 0xa3, 0x2f, 0xda,
1169 0x2e, 0xc5, 0xa3, 0xc0, 0x44, 0x35, 0xa4, 0x73, 0x8a, 0x76, 0xa2, 0x1a,
1170 0xa3, 0x43, 0x35, 0xe6, 0xc8, 0x99, 0xfb, 0x35, 0x5e, 0x67, 0xae, 0x7d,
1171 0x5f, 0xcf, 0x05, 0xe5, 0x42, 0xcd, 0xa5, 0xac, 0x9a, 0xb2, 0x09, 0x5d,
1172 0xdb, 0x68, 0x2e, 0xf5, 0x73, 0xaf, 0xb6, 0x9a, 0x3f, 0xe8, 0xf3, 0x7d,
1173 0x2d, 0xd6, 0xfd, 0xb0, 0xcf, 0xaf, 0x8b, 0x07, 0xbe, 0x13, 0x7d, 0xac,
1174 0x2a, 0xe6, 0xf6, 0xb2, 0x34, 0x57, 0x7f, 0x2c, 0x6f, 0x57, 0x7e, 0x24,
1175 0xbf, 0x5a, 0x3d, 0x0b, 0xfe, 0x61, 0x55, 0x0b, 0xb0, 0x27, 0x37, 0x9a,
1176 0x9e, 0x77, 0xc3, 0x3d, 0x03, 0x5f, 0xc1, 0xf3, 0xfe, 0xe0, 0x6e, 0x4b,
1177 0x62, 0xec, 0x3b, 0x98, 0x73, 0x1e, 0x3a, 0x44, 0x2c, 0x9c, 0x82, 0xbc,
1178 0x25, 0xfb, 0xa5, 0x2b, 0xa2, 0xe5, 0x64, 0x68, 0x2c, 0x8c, 0x39, 0x18,
1179 0x01, 0x27, 0xe7, 0x5c, 0x46, 0xfa, 0x29, 0x33, 0x46, 0xf3, 0x15, 0x7c,
1180 0x3f, 0x0c, 0xbd, 0xd8, 0x8f, 0x9f, 0x92, 0x7b, 0xa3, 0x18, 0xeb, 0x28,
1181 0x65, 0x2f, 0x2c, 0x89, 0x27, 0x31, 0x8f, 0x7c, 0x9b, 0xdc, 0x2f, 0x5d,
1182 0xe9, 0x63, 0x5c, 0xee, 0x7e, 0x89, 0x65, 0xe3, 0x4b, 0x3d, 0xe2, 0x49,
1183 0x1b, 0x6c, 0xf9, 0xfc, 0x09, 0x9f, 0x37, 0xfd, 0x5a, 0x0d, 0xa3, 0xbd,
1184 0x5d, 0x78, 0x47, 0x91, 0xe7, 0x15, 0xbc, 0x30, 0x78, 0x79, 0x0e, 0x7c,
1185 0x28, 0xd3, 0xbc, 0x20, 0x3b, 0xa3, 0x11, 0xb4, 0x21, 0x5f, 0xd1, 0x58,
1186 0x22, 0xd9, 0x12, 0x73, 0xb0, 0x98, 0x0f, 0x85, 0x31, 0x9e, 0x21, 0x6e,
1187 0x70, 0x8c, 0xed, 0x3c, 0xb7, 0x0b, 0xea, 0x6c, 0xc8, 0x08, 0xeb, 0x28,
1188 0xdf, 0x69, 0xcd, 0xa9, 0x60, 0x43, 0xf1, 0xbe, 0x11, 0xc9, 0xe8, 0x72,
1189 0x0f, 0xde, 0x77, 0x41, 0xe7, 0x25, 0xfa, 0xef, 0x4c, 0xa1, 0x0d, 0x71,
1190 0x26, 0x05, 0x2e, 0xf1, 0xa1, 0x9a, 0x00, 0xbd, 0x99, 0x29, 0xf5, 0xc9,
1191 0x84, 0xb9, 0x6f, 0xcf, 0x1c, 0x0b, 0xda, 0x57, 0x30, 0x8c, 0x91, 0x60,
1192 0x4c, 0x3d, 0x7b, 0xc6, 0xc4, 0xfe, 0xf8, 0xc1, 0xc7, 0xcd, 0x2c, 0x2f,
1193 0x02, 0xa7, 0x16, 0x7f, 0x9b, 0x71, 0x9f, 0x97, 0x6c, 0xb4, 0x5d, 0xfb,
1194 0x36, 0x35, 0xec, 0x4b, 0xb6, 0xc4, 0x78, 0xd4, 0xb7, 0x81, 0x43, 0xfb,
1195 0x82, 0x3a, 0xb6, 0x15, 0x23, 0x83, 0xb5, 0x4f, 0x6b, 0x3d, 0x64, 0xdd,
1196 0x17, 0x25, 0xb3, 0x98, 0x97, 0x49, 0xdd, 0x8f, 0x6b, 0x38, 0xa8, 0x79,
1197 0x08, 0x75, 0x35, 0x71, 0x08, 0x6b, 0x99, 0x0c, 0x07, 0x6d, 0xf7, 0x91,
1198 0xc9, 0xe3, 0xef, 0xd3, 0x40, 0x67, 0xf1, 0xec, 0x10, 0xf7, 0xa8, 0x5d,
1199 0x12, 0xdf, 0x84, 0xbd, 0x2c, 0xb5, 0xea, 0x23, 0xf2, 0x49, 0xe9, 0xb3,
1200 0x3e, 0x9e, 0x93, 0xfc, 0xb5, 0x64, 0xca, 0x47, 0x25, 0x7d, 0x7e, 0x3a,
1201 0x1d, 0x12, 0xeb, 0xbc, 0xef, 0x67, 0x1f, 0x9d, 0x9e, 0x57, 0x7c, 0x7e,
1202 0xf4, 0xfc, 0xba, 0xea, 0x44, 0xdb, 0x08, 0xda, 0x71, 0x1c, 0xa6, 0xe4,
1203 0x4a, 0x7f, 0xf7, 0x66, 0x8e, 0x79, 0xde, 0xa4, 0xce, 0xe1, 0x4a, 0x9a,
1204 0xf3, 0xaa, 0xc5, 0xcf, 0x1d, 0x29, 0x45, 0x3b, 0xf0, 0xad, 0xa4, 0xb9,
1205 0xae, 0x8e, 0x62, 0x3c, 0x2c, 0x1f, 0xa2, 0x4e, 0xc4, 0xb6, 0x85, 0xef,
1206 0xb7, 0xa6, 0xd6, 0x54, 0x32, 0x3e, 0xa4, 0xac, 0x74, 0x11, 0xbf, 0x36,
1207 0xa5, 0xcf, 0x1e, 0x63, 0x71, 0x05, 0xdd, 0xc5, 0x9c, 0xec, 0xe3, 0x9e,
1208 0x37, 0x65, 0xb3, 0x3e, 0x69, 0x46, 0x14, 0xe3, 0x26, 0x5d, 0xfa, 0x8c,
1209 0xf2, 0xd2, 0xe1, 0xa4, 0x79, 0x5c, 0x1d, 0x0c, 0xee, 0x53, 0xc0, 0xcc,
1210 0xdd, 0xf7, 0x9d, 0x5d, 0x53, 0xa6, 0x5c, 0x2e, 0x25, 0xe3, 0xb3, 0xca,
1211 0xca, 0xe3, 0x9d, 0xf9, 0x09, 0x45, 0xdc, 0x48, 0x9a, 0x5d, 0x8a, 0xb1,
1212 0xcd, 0x0e, 0x3d, 0xef, 0x29, 0xf4, 0x4f, 0xaa, 0xb6, 0x60, 0x3c, 0xdc,
1213 0xaf, 0xcb, 0xfd, 0xbe, 0xce, 0x10, 0x73, 0x06, 0x8c, 0x99, 0x45, 0xe6,
1214 0x83, 0xe9, 0x3c, 0x84, 0x74, 0x62, 0x8c, 0xf7, 0x86, 0x3c, 0x38, 0xf9,
1215 0x0f, 0xd4, 0xa1, 0x5c, 0x65, 0x9d, 0x13, 0xe8, 0xdb, 0x31, 0xcd, 0x9f,
1216 0x1f, 0x9c, 0x2c, 0xe8, 0xfc, 0xc4, 0x1d, 0x95, 0x08, 0xe6, 0xbd, 0xbb,
1217 0x67, 0xf1, 0x8c, 0xfb, 0x05, 0xbe, 0x67, 0x31, 0x34, 0xde, 0x21, 0xcc,
1218 0x07, 0xcd, 0x55, 0x5a, 0xb2, 0xc1, 0xd8, 0x00, 0xcf, 0xf7, 0x5b, 0x67,
1219 0xe5, 0x17, 0xc4, 0x18, 0xeb, 0xdc, 0x23, 0x27, 0xe0, 0x9d, 0xe0, 0xab,
1220 0x75, 0xbc, 0xa7, 0xb8, 0x2c, 0x05, 0xbf, 0xbf, 0x74, 0x32, 0xff, 0xb4,
1221 0x58, 0xff, 0xbc, 0x77, 0xf8, 0x36, 0x30, 0x87, 0xfb, 0x07, 0x27, 0x29,
1222 0x9f, 0x5c, 0x9b, 0xb8, 0x9a, 0xbc, 0xc2, 0xf1, 0x0c, 0x4a, 0x6e, 0x19,
1223 0xdc, 0x08, 0xbf, 0xf9, 0x65, 0x7f, 0xdf, 0xd6, 0xc1, 0xb3, 0x73, 0x25,
1224 0x53, 0xeb, 0xeb, 0xac, 0xcb, 0xb3, 0x0f, 0xe8, 0x8a, 0xce, 0x7b, 0x62,
1225 0x5f, 0xe6, 0x0a, 0x1e, 0xa1, 0x7d, 0x74, 0x6a, 0x12, 0x45, 0x5b, 0x72,
1226 0x56, 0xd6, 0x83, 0xbf, 0xc3, 0x66, 0x16, 0x5f, 0x8d, 0x08, 0x30, 0x39,
1227 0x15, 0x0f, 0x1d, 0x90, 0x79, 0xd7, 0x95, 0x46, 0xf3, 0x84, 0x5c, 0x6b,
1228 0x3a, 0xfa, 0x19, 0xed, 0xd9, 0xc2, 0x6b, 0xfa, 0x5c, 0x3a, 0xfe, 0xa1,
1229 0xb2, 0x9c, 0xab, 0xf0, 0x6b, 0xbe, 0x7b, 0x8c, 0x79, 0xc2, 0xe1, 0x81,
1230 0x87, 0x79, 0x70, 0xc0, 0x0e, 0x70, 0x8e, 0xb7, 0xc0, 0x39, 0xde, 0x04,
1231 0xe7, 0xf8, 0x25, 0x38, 0xf6, 0x8d, 0xca, 0x54, 0x80, 0xff, 0xd3, 0xc0,
1232 0x21, 0xda, 0x6a, 0xeb, 0x2c, 0xf6, 0x74, 0xba, 0x00, 0x19, 0xfc, 0x00,
1233 0xfe, 0xc7, 0x56, 0x25, 0x23, 0x1b, 0xab, 0x93, 0xb2, 0xb9, 0xea, 0xe7,
1234 0x1c, 0xbf, 0xcb, 0x3c, 0xad, 0x51, 0xee, 0x93, 0x03, 0x1c, 0xda, 0x27,
1235 0x89, 0xe3, 0xc4, 0x8f, 0x4e, 0x59, 0x2b, 0xaf, 0x69, 0x1c, 0x5a, 0x2b,
1236 0xb3, 0x1c, 0x12, 0x9d, 0xf3, 0x75, 0x66, 0x5b, 0x6a, 0xee, 0x16, 0xea,
1237 0xbb, 0x99, 0xdb, 0x15, 0xc4, 0xd6, 0x89, 0x97, 0x7f, 0x0e, 0xf6, 0x5e,
1238 0xe9, 0x5c, 0xb8, 0x19, 0xf3, 0x00, 0xda, 0xb5, 0xb0, 0x6b, 0xc8, 0x3f,
1239 0x27, 0x57, 0x7f, 0x41, 0x1b, 0x7c, 0x03, 0x9c, 0xf1, 0x2a, 0x6c, 0xc8,
1240 0x8e, 0x73, 0x40, 0x73, 0xbf, 0x1d, 0xe7, 0x88, 0xce, 0xad, 0xe5, 0x7b,
1241 0x8a, 0x65, 0x5b, 0xe6, 0xca, 0x56, 0xbc, 0x00, 0xf9, 0xbb, 0x06, 0xbf,
1242 0x6d, 0x03, 0x7b, 0xb0, 0x89, 0xb5, 0xd8, 0x6a, 0xd2, 0xce, 0xbf, 0xaf,
1243 0xb1, 0x77, 0xad, 0xf9, 0x27, 0xbc, 0xc7, 0x3a, 0x9b, 0x96, 0x3f, 0xf6,
1244 0x13, 0x03, 0x99, 0x8f, 0x97, 0xd5, 0xfd, 0xfd, 0x7e, 0x1b, 0x68, 0xbb,
1245 0xd9, 0x24, 0x1e, 0x8b, 0x5c, 0x2c, 0xd9, 0xb0, 0x25, 0x17, 0x63, 0xe4,
1246 0x00, 0x55, 0xd5, 0xea, 0xe7, 0x05, 0x63, 0xf6, 0xbc, 0xfd, 0x36, 0xc7,
1247 0xe5, 0x04, 0xb8, 0x4d, 0xdb, 0xbf, 0xad, 0xb9, 0x4d, 0xa9, 0xf2, 0xbc,
1248 0x5c, 0x5f, 0x4d, 0x05, 0x1c, 0x27, 0x2f, 0x6f, 0x80, 0xe3, 0x35, 0x2b,
1249 0xad, 0x1c, 0xed, 0x71, 0xac, 0x53, 0x45, 0xcd, 0x2d, 0x75, 0xc9, 0xa5,
1250 0x95, 0xa2, 0xba, 0xbc, 0x52, 0x52, 0xaf, 0x2c, 0x95, 0x55, 0x71, 0xc9,
1251 0xf3, 0xfe, 0xe9, 0xce, 0xc8, 0xdb, 0xab, 0x9e, 0x9c, 0x76, 0x8d, 0x81,
1252 0x90, 0xb4, 0xf2, 0xdf, 0x3c, 0xaf, 0x13, 0xd8, 0xbc, 0x75, 0xd8, 0xf3,
1253 0x9e, 0x18, 0x1d, 0x15, 0xe7, 0x30, 0x39, 0xca, 0x70, 0x8c, 0x39, 0xac,
1254 0xc4, 0x9c, 0x8c, 0x6d, 0x9f, 0xaf, 0x29, 0x05, 0x7c, 0x3b, 0xe0, 0xf3,
1255 0x97, 0x27, 0xbb, 0x83, 0x33, 0x8f, 0xb3, 0x2f, 0x31, 0x26, 0x1c, 0xfb,
1256 0xaf, 0x98, 0xb0, 0x29, 0xe7, 0xca, 0x58, 0x88, 0xae, 0xa8, 0x7c, 0xaf,
1257 0x1c, 0x79, 0xac, 0x6c, 0xe2, 0xea, 0x18, 0xc5, 0xf2, 0x7d, 0x6f, 0x48,
1258 0xc7, 0xfe, 0xc1, 0x49, 0x4c, 0xcf, 0x9b, 0x75, 0xf9, 0xbd, 0x03, 0x8c,
1259 0xc9, 0x98, 0xdd, 0xb0, 0xff, 0xa7, 0xb5, 0x7d, 0xae, 0xaa, 0x8c, 0x4d,
1260 0xfd, 0x8e, 0xca, 0x44, 0x19, 0x36, 0x5e, 0x31, 0x2f, 0x94, 0x5c, 0xc1,
1261 0x8a, 0xcd, 0x02, 0x3b, 0x66, 0x80, 0x37, 0x4f, 0xeb, 0xb3, 0xd1, 0x43,
1262 0x1a, 0x7b, 0xe6, 0x58, 0xce, 0x4b, 0xba, 0xe6, 0xf6, 0xea, 0xf5, 0xbb,
1263 0x7d, 0xad, 0x18, 0xf3, 0xf7, 0x1c, 0x7a, 0x9c, 0xe7, 0xf9, 0x40, 0xaf,
1264 0x64, 0xd7, 0xcf, 0x40, 0x27, 0x62, 0x58, 0xdb, 0xb0, 0xd6, 0x87, 0x1d,
1265 0xd8, 0xef, 0x1d, 0x27, 0x1c, 0x60, 0x6a, 0x27, 0xee, 0xd9, 0x6e, 0x12,
1266 0xfd, 0x3a, 0x24, 0xb3, 0xd4, 0xae, 0x71, 0xf5, 0xd1, 0xba, 0x34, 0x78,
1267 0x48, 0x0e, 0xe5, 0x10, 0xea, 0xe2, 0x41, 0x99, 0xdc, 0x6b, 0x1a, 0xe5,
1268 0x36, 0x5c, 0xd9, 0xe6, 0x28, 0x78, 0x05, 0xae, 0xbf, 0xc0, 0xfb, 0x46,
1269 0x31, 0xe6, 0xbc, 0x29, 0xef, 0x9d, 0xa4, 0x2d, 0x71, 0x0c, 0xe6, 0x1a,
1270 0xcf, 0xda, 0xb8, 0x36, 0xca, 0x2a, 0xbb, 0xc8, 0x32, 0xae, 0x55, 0xff,
1271 0xf9, 0x23, 0x98, 0x84, 0x3e, 0x99, 0x15, 0x1f, 0x93, 0xde, 0xdb, 0xc5,
1272 0x24, 0xd6, 0x75, 0xc8, 0xc4, 0x52, 0x5c, 0x9d, 0xba, 0x62, 0x42, 0xde,
1273 0xba, 0x24, 0xbb, 0x12, 0xd5, 0x7c, 0xb4, 0x06, 0x59, 0x5c, 0x87, 0x5c,
1274 0xad, 0x41, 0xa6, 0x32, 0x65, 0x2b, 0x35, 0xad, 0xe2, 0x3a, 0x2e, 0x30,
1275 0x05, 0x79, 0x0d, 0xbf, 0x4a, 0x2e, 0x4a, 0xfd, 0x75, 0xd0, 0x46, 0x68,
1276 0x47, 0xd3, 0x61, 0x65, 0x43, 0x0e, 0x21, 0x97, 0x65, 0x5f, 0x7f, 0xdf,
1277 0x51, 0x1a, 0x57, 0x53, 0x77, 0x24, 0xe9, 0xdc, 0x11, 0xcb, 0xdd, 0xc1,
1278 0xef, 0x37, 0xe2, 0xca, 0x55, 0xe8, 0xfb, 0xeb, 0xf8, 0x4e, 0xf8, 0x35,
1279 0x43, 0x8e, 0x0d, 0x6b, 0x9d, 0x4e, 0x49, 0xc8, 0x72, 0x36, 0xc5, 0xd7,
1280 0xf1, 0x75, 0xad, 0xe3, 0x90, 0x37, 0x60, 0x90, 0xaf, 0xd3, 0xe9, 0x40,
1281 0x46, 0xbf, 0x01, 0xfd, 0xb5, 0xe0, 0x95, 0xc5, 0x65, 0x1e, 0xfa, 0x7f,
1282 0x15, 0xcf, 0x6f, 0x36, 0x3f, 0x56, 0x73, 0x8b, 0x2a, 0xc8, 0x3f, 0x79,
1283 0x0e, 0x3c, 0xf9, 0xf7, 0x58, 0xbb, 0x1e, 0xcd, 0xdd, 0x13, 0xa3, 0x3c,
1284 0x07, 0xfb, 0xb7, 0xba, 0x64, 0x1f, 0x97, 0xdb, 0x23, 0x27, 0x50, 0xee,
1285 0xc6, 0xd5, 0xc0, 0x3a, 0x44, 0xf4, 0xf9, 0xf5, 0x5a, 0x69, 0xc4, 0x28,
1286 0xea, 0x33, 0xe6, 0x31, 0xf4, 0x25, 0x96, 0x1d, 0xc6, 0x73, 0xc6, 0x65,
1287 0x38, 0x37, 0x70, 0x26, 0x15, 0xd3, 0x39, 0xa1, 0x35, 0x70, 0x89, 0x75,
1288 0xbc, 0xef, 0x16, 0xe3, 0x7a, 0x0d, 0xe8, 0xf0, 0xc8, 0x67, 0x5e, 0x3a,
1289 0xca, 0xbc, 0xf3, 0xf7, 0x63, 0xbe, 0xfd, 0xfb, 0xc4, 0xbb, 0x6d, 0xcf,
1290 0xa5, 0x0c, 0xdc, 0x7c, 0x60, 0x02, 0xef, 0xc8, 0xdb, 0x61, 0x8b, 0xaa,
1291 0x5a, 0x7e, 0xd9, 0xce, 0xef, 0x5b, 0x6c, 0x24, 0xcd, 0x77, 0xc5, 0xef,
1292 0x3b, 0x6f, 0xd3, 0xee, 0x74, 0x00, 0x5f, 0xe2, 0x9a, 0x57, 0xde, 0xb2,
1293 0x0b, 0x40, 0x05, 0x2b, 0x3e, 0x05, 0x19, 0x6d, 0x17, 0xcb, 0xc9, 0xc9,
1294 0xc3, 0xef, 0xce, 0xea, 0xbe, 0x6c, 0xdb, 0xea, 0xdb, 0xfa, 0x2e, 0xc7,
1295 0xcf, 0xb9, 0x70, 0x0e, 0xf0, 0x6d, 0x4c, 0x53, 0xcb, 0xe8, 0x4e, 0xc3,
1296 0x18, 0xf0, 0x65, 0xb4, 0x35, 0x8f, 0xe8, 0xff, 0x99, 0x07, 0xe5, 0x64,
1297 0xc4, 0xf0, 0xcf, 0xdb, 0x71, 0x6d, 0x70, 0x3d, 0x3f, 0x06, 0xbf, 0xdf,
1298 0x2b, 0x3f, 0xad, 0x38, 0xa3, 0x2f, 0x3f, 0x4f, 0xec, 0xca, 0x0f, 0x7d,
1299 0xd4, 0x2e, 0xc9, 0xad, 0xd8, 0x32, 0x59, 0xd6, 0xfb, 0x0d, 0xae, 0xc9,
1300 0xf8, 0xd1, 0x09, 0xc8, 0x0d, 0x65, 0x9d, 0xba, 0x65, 0x4a, 0x15, 0x72,
1301 0x54, 0x05, 0x3e, 0x55, 0x21, 0x53, 0xe4, 0x40, 0x55, 0xe0, 0x5b, 0xb5,
1302 0x69, 0x39, 0x75, 0xcc, 0x99, 0x36, 0x7b, 0x1d, 0x72, 0x74, 0xb5, 0xc9,
1303 0xfd, 0xd7, 0x63, 0x36, 0x69, 0x07, 0x6f, 0xee, 0xee, 0xfd, 0xa7, 0xd8,
1304 0xfb, 0x23, 0x72, 0x0d, 0x7e, 0xcb, 0xf5, 0xca, 0x08, 0x30, 0x49, 0x80,
1305 0x51, 0x2e, 0x64, 0x23, 0x25, 0x1b, 0x95, 0x71, 0xd9, 0x84, 0x7d, 0xda,
1306 0x5a, 0x4d, 0x80, 0x4f, 0x03, 0x47, 0xaf, 0x1c, 0x93, 0x37, 0x56, 0x95,
1307 0xcc, 0xd8, 0xb0, 0x33, 0x6b, 0x8c, 0xc1, 0x43, 0x9e, 0xab, 0x5d, 0xfa,
1308 0xbc, 0x7d, 0xa2, 0xee, 0xc7, 0xe2, 0x73, 0xf5, 0x1e, 0x99, 0xac, 0x9b,
1309 0xf2, 0x54, 0xbd, 0x57, 0xbe, 0x5a, 0x8f, 0xca, 0xe9, 0x46, 0x4c, 0xbe,
1310 0x56, 0x1f, 0x94, 0xa7, 0xeb, 0x47, 0xe4, 0x99, 0x46, 0x5c, 0xbe, 0x0e,
1311 0xbf, 0x30, 0xdf, 0x70, 0x64, 0xaa, 0x31, 0x22, 0xa7, 0x1a, 0x8c, 0xb1,
1312 0xe3, 0x7b, 0xf8, 0x65, 0x77, 0x63, 0x17, 0x1c, 0x57, 0x27, 0xc6, 0xe5,
1313 0xa8, 0x9c, 0x3e, 0x6f, 0x94, 0xbc, 0x1f, 0xff, 0x10, 0x79, 0x01, 0x7d,
1314 0x17, 0xae, 0x28, 0xa9, 0xe9, 0xef, 0xb7, 0xfe, 0x47, 0x24, 0xa2, 0x7d,
1315 0xa3, 0x17, 0xaa, 0x83, 0x68, 0x63, 0xd3, 0x27, 0x09, 0xe2, 0x20, 0xad,
1316 0xf8, 0x7f, 0xcb, 0xf7, 0x32, 0x74, 0x0c, 0xfb, 0x26, 0x7d, 0x2f, 0xbd,
1317 0xf6, 0xc4, 0x0f, 0xfa, 0x39, 0xf4, 0xb5, 0xf6, 0x9e, 0x51, 0xb4, 0xbe,
1318 0xbb, 0x90, 0x7f, 0xf4, 0x7f, 0x51, 0xfc, 0xb3, 0xa6, 0x73, 0x8d, 0x41,
1319 0xfe, 0x4f, 0x0a, 0xc6, 0xf2, 0xf9, 0xf9, 0xdd, 0x93, 0x95, 0x09, 0xf5,
1320 0x54, 0x85, 0x8c, 0xc6, 0x93, 0x85, 0xdd, 0x3c, 0xba, 0xaf, 0xc8, 0x9a,
1321 0x1b, 0xd1, 0x63, 0xf0, 0xe3, 0xf6, 0x69, 0x9d, 0x53, 0x37, 0x31, 0x4c,
1322 0xf9, 0xe3, 0x19, 0x5a, 0x4f, 0x70, 0xb6, 0x00, 0x6e, 0xeb, 0x9a, 0x72,
1323 0xb1, 0xee, 0xc7, 0xaf, 0xe6, 0xb4, 0xbc, 0x5c, 0x87, 0xcc, 0xf1, 0xfc,
1324 0xc1, 0xbf, 0x16, 0xaa, 0x7e, 0xdf, 0xec, 0xb0, 0x43, 0x7f, 0x1c, 0xf3,
1325 0x35, 0x7a, 0xf9, 0x2d, 0xfe, 0x4f, 0x0e, 0xca, 0xc1, 0x78, 0x99, 0x0f,
1326 0x6c, 0x6b, 0x59, 0xf4, 0xcf, 0x67, 0x1d, 0x79, 0x11, 0x7b, 0x51, 0x33,
1327 0x39, 0xfe, 0x4e, 0xa9, 0x39, 0xf4, 0x6d, 0x89, 0xdf, 0xc3, 0x52, 0xc5,
1328 0x77, 0x6a, 0x4e, 0x2b, 0x36, 0xe6, 0xe3, 0x6c, 0xcd, 0x7c, 0xf8, 0xdd,
1329 0xe9, 0xea, 0x41, 0xdc, 0xa3, 0xce, 0x01, 0x67, 0x3a, 0xc3, 0xfb, 0x05,
1330 0x94, 0x19, 0x1b, 0x99, 0xc3, 0x35, 0x16, 0xd4, 0xfd, 0x7c, 0x40, 0x73,
1331 0xf5, 0xf1, 0x87, 0xfd, 0x66, 0xaa, 0x56, 0x21, 0x13, 0xba, 0xab, 0x8c,
1332 0x9f, 0xad, 0x0f, 0x10, 0x73, 0x0f, 0xda, 0xfc, 0x45, 0xe4, 0x6f, 0xa6,
1333 0x8e, 0x29, 0x04, 0xcf, 0xf6, 0xc9, 0xb3, 0x26, 0x73, 0xcd, 0xd3, 0x6a,
1334 0xa2, 0xf2, 0x72, 0x90, 0x57, 0x7b, 0x57, 0x1d, 0xac, 0x35, 0x07, 0xfc,
1335 0xbc, 0x74, 0xbe, 0x7b, 0x6f, 0x2e, 0xfa, 0x5e, 0x39, 0x61, 0x4e, 0x7a,
1336 0x07, 0x78, 0xab, 0x36, 0x62, 0xd0, 0x41, 0xe0, 0x9d, 0xdd, 0xa6, 0xf5,
1337 0xb1, 0xd8, 0xf8, 0x97, 0xb7, 0xad, 0xf5, 0xb9, 0x15, 0x63, 0xb8, 0x35,
1338 0x40, 0xdf, 0x96, 0xb8, 0x71, 0xd1, 0x8f, 0x1b, 0x69, 0x1f, 0x1a, 0x58,
1339 0x81, 0x3a, 0xea, 0x2a, 0xf4, 0x64, 0xb7, 0x2d, 0xff, 0xfe, 0x03, 0x7d,
1340 0xe7, 0x95, 0xf0, 0x2c, 0x67, 0x00, 0x00, 0x00 };
1052 1341
1053static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 }; 1342static u32 bnx2_RXP_b06FwData[(0x0/4) + 1] = { 0x0 };
1054static u32 bnx2_RXP_b06FwRodata[(0x28/4) + 1] = { 1343static u32 bnx2_RXP_b06FwRodata[(0x278/4) + 1] = {
1055 0x0800468c, 0x0800458c, 0x08004630, 0x08004648, 0x08004660, 0x08004680, 1344 0x08003fdc, 0x08003edc, 0x08003f80, 0x08003f98, 0x08003fb0, 0x08003fd0,
1056 0x0800468c, 0x0800468c, 0x08004594, 0x00000000, 0x00000000 }; 1345 0x08003fdc, 0x08003fdc, 0x08003ee4, 0x00000000, 0x08004a04, 0x08004a3c,
1057static u32 bnx2_RXP_b06FwBss[(0x13a4/4) + 1] = { 0x0 }; 1346 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004a74, 0x08004c38,
1058static u32 bnx2_RXP_b06FwSbss[(0x1c/4) + 1] = { 0x0 }; 1347 0x08004b80, 0x08004bb8, 0x08004c38, 0x08004b08, 0x08004c38, 0x08004c38,
1348 0x08004bb8, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1349 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004bf8,
1350 0x08004c38, 0x08004bf8, 0x08004b80, 0x08004c38, 0x08004c38, 0x08004bf8,
1351 0x08004bf8, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1352 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1353 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1354 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1355 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1356 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1357 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1358 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1359 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1360 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1361 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1362 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1363 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1364 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1365 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1366 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38, 0x08004c38,
1367 0x08004ae4, 0x00000000, 0x08006018, 0x08006030, 0x08006030, 0x08006030,
1368 0x08006018, 0x08006030, 0x08006030, 0x08006030, 0x08006018, 0x08006030,
1369 0x08006030, 0x08006030, 0x08006018, 0x08006030, 0x08006030, 0x08006030,
1370 0x08006024, 0x00000000, 0x00000000 };
1371
1372static u32 bnx2_RXP_b06FwBss[(0x13dc/4) + 1] = { 0x0 };
1373static u32 bnx2_RXP_b06FwSbss[(0x2c/4) + 1] = { 0x0 };
1374
1375static struct fw_info bnx2_rxp_fw_06 = {
1376 .ver_major = 0x2,
1377 .ver_minor = 0x8,
1378 .ver_fix = 0x17,
1379
1380 .start_addr = 0x08003184,
1381
1382 .text_addr = 0x08000000,
1383 .text_len = 0x6728,
1384 .text_index = 0x0,
1385 .gz_text = bnx2_RXP_b06FwText,
1386 .gz_text_len = sizeof(bnx2_RXP_b06FwText),
1387
1388 .data_addr = 0x080069c0,
1389 .data_len = 0x0,
1390 .data_index = 0x0,
1391 .data = bnx2_RXP_b06FwData,
1392
1393 .sbss_addr = 0x080069c0,
1394 .sbss_len = 0x2c,
1395 .sbss_index = 0x0,
1396 .sbss = bnx2_RXP_b06FwSbss,
1397
1398 .bss_addr = 0x080069f0,
1399 .bss_len = 0x13dc,
1400 .bss_index = 0x0,
1401 .bss = bnx2_RXP_b06FwBss,
1402
1403 .rodata_addr = 0x08006728,
1404 .rodata_len = 0x278,
1405 .rodata_index = 0x0,
1406 .rodata = bnx2_RXP_b06FwRodata,
1407};
1059 1408
1060static u8 bnx2_rv2p_proc1[] = { 1409static u8 bnx2_rv2p_proc1[] = {
1061 0x1f, 0x8b, 0x08, 0x08, 0x5e, 0xd0, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 1410 0x1f, 0x8b, 0x08, 0x08, 0x5e, 0xd0, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
@@ -1316,20 +1665,6 @@ static u8 bnx2_rv2p_proc2[] = {
1316 0x63, 0xd6, 0x11, 0x8f, 0x47, 0xd5, 0x5f, 0x3f, 0x97, 0x8f, 0x31, 0xd8, 1665 0x63, 0xd6, 0x11, 0x8f, 0x47, 0xd5, 0x5f, 0x3f, 0x97, 0x8f, 0x31, 0xd8,
1317 0x17, 0x00, 0x00, 0x00 }; 1666 0x17, 0x00, 0x00, 0x00 };
1318 1667
1319static const int bnx2_TPAT_b06FwReleaseMajor = 0x1;
1320static const int bnx2_TPAT_b06FwReleaseMinor = 0x0;
1321static const int bnx2_TPAT_b06FwReleaseFix = 0x0;
1322static const u32 bnx2_TPAT_b06FwStartAddr = 0x08000860;
1323static const u32 bnx2_TPAT_b06FwTextAddr = 0x08000800;
1324static const int bnx2_TPAT_b06FwTextLen = 0x122c;
1325static const u32 bnx2_TPAT_b06FwDataAddr = 0x08001a60;
1326static const int bnx2_TPAT_b06FwDataLen = 0x0;
1327static const u32 bnx2_TPAT_b06FwRodataAddr = 0x00000000;
1328static const int bnx2_TPAT_b06FwRodataLen = 0x0;
1329static const u32 bnx2_TPAT_b06FwBssAddr = 0x08001aa0;
1330static const int bnx2_TPAT_b06FwBssLen = 0x250;
1331static const u32 bnx2_TPAT_b06FwSbssAddr = 0x08001a60;
1332static const int bnx2_TPAT_b06FwSbssLen = 0x34;
1333static u8 bnx2_TPAT_b06FwText[] = { 1668static u8 bnx2_TPAT_b06FwText[] = {
1334 0x1f, 0x8b, 0x08, 0x08, 0x47, 0xd2, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 1669 0x1f, 0x8b, 0x08, 0x08, 0x47, 0xd2, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
1335 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x57, 0x4d, 0x68, 1670 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x57, 0x4d, 0x68,
@@ -1529,20 +1864,40 @@ static u32 bnx2_TPAT_b06FwRodata[(0x0/4) + 1] = { 0x0 };
1529static u32 bnx2_TPAT_b06FwBss[(0x250/4) + 1] = { 0x0 }; 1864static u32 bnx2_TPAT_b06FwBss[(0x250/4) + 1] = { 0x0 };
1530static u32 bnx2_TPAT_b06FwSbss[(0x34/4) + 1] = { 0x0 }; 1865static u32 bnx2_TPAT_b06FwSbss[(0x34/4) + 1] = { 0x0 };
1531 1866
1532static const int bnx2_TXP_b06FwReleaseMajor = 0x1; 1867static struct fw_info bnx2_tpat_fw_06 = {
1533static const int bnx2_TXP_b06FwReleaseMinor = 0x0; 1868 .ver_major = 0x1,
1534static const int bnx2_TXP_b06FwReleaseFix = 0x0; 1869 .ver_minor = 0x0,
1535static const u32 bnx2_TXP_b06FwStartAddr = 0x080034b0; 1870 .ver_fix = 0x0,
1536static const u32 bnx2_TXP_b06FwTextAddr = 0x08000000; 1871
1537static const int bnx2_TXP_b06FwTextLen = 0x5748; 1872 .start_addr = 0x08000860,
1538static const u32 bnx2_TXP_b06FwDataAddr = 0x08005760; 1873
1539static const int bnx2_TXP_b06FwDataLen = 0x0; 1874 .text_addr = 0x08000800,
1540static const u32 bnx2_TXP_b06FwRodataAddr = 0x00000000; 1875 .text_len = 0x122c,
1541static const int bnx2_TXP_b06FwRodataLen = 0x0; 1876 .text_index = 0x0,
1542static const u32 bnx2_TXP_b06FwBssAddr = 0x080057a0; 1877 .gz_text = bnx2_TPAT_b06FwText,
1543static const int bnx2_TXP_b06FwBssLen = 0x1c4; 1878 .gz_text_len = sizeof(bnx2_TPAT_b06FwText),
1544static const u32 bnx2_TXP_b06FwSbssAddr = 0x08005760; 1879
1545static const int bnx2_TXP_b06FwSbssLen = 0x38; 1880 .data_addr = 0x08001a60,
1881 .data_len = 0x0,
1882 .data_index = 0x0,
1883 .data = bnx2_TPAT_b06FwData,
1884
1885 .sbss_addr = 0x08001a60,
1886 .sbss_len = 0x34,
1887 .sbss_index = 0x0,
1888 .sbss = bnx2_TPAT_b06FwSbss,
1889
1890 .bss_addr = 0x08001aa0,
1891 .bss_len = 0x250,
1892 .bss_index = 0x0,
1893 .bss = bnx2_TPAT_b06FwBss,
1894
1895 .rodata_addr = 0x00000000,
1896 .rodata_len = 0x0,
1897 .rodata_index = 0x0,
1898 .rodata = bnx2_TPAT_b06FwRodata,
1899};
1900
1546static u8 bnx2_TXP_b06FwText[] = { 1901static u8 bnx2_TXP_b06FwText[] = {
1547 0x1f, 0x8b, 0x08, 0x08, 0x21, 0xd3, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65, 1902 0x1f, 0x8b, 0x08, 0x08, 0x21, 0xd3, 0x41, 0x44, 0x00, 0x03, 0x74, 0x65,
1548 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xed, 0x5c, 0x6d, 0x6c, 1903 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xed, 0x5c, 0x6d, 0x6c,
@@ -1964,3 +2319,38 @@ static u32 bnx2_TXP_b06FwData[(0x0/4) + 1] = { 0x0 };
1964static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x0 }; 2319static u32 bnx2_TXP_b06FwRodata[(0x0/4) + 1] = { 0x0 };
1965static u32 bnx2_TXP_b06FwBss[(0x1c4/4) + 1] = { 0x0 }; 2320static u32 bnx2_TXP_b06FwBss[(0x1c4/4) + 1] = { 0x0 };
1966static u32 bnx2_TXP_b06FwSbss[(0x38/4) + 1] = { 0x0 }; 2321static u32 bnx2_TXP_b06FwSbss[(0x38/4) + 1] = { 0x0 };
2322
2323static struct fw_info bnx2_txp_fw_06 = {
2324 .ver_major = 0x1,
2325 .ver_minor = 0x0,
2326 .ver_fix = 0x0,
2327
2328 .start_addr = 0x080034b0,
2329
2330 .text_addr = 0x08000000,
2331 .text_len = 0x5748,
2332 .text_index = 0x0,
2333 .gz_text = bnx2_TXP_b06FwText,
2334 .gz_text_len = sizeof(bnx2_TXP_b06FwText),
2335
2336 .data_addr = 0x08005760,
2337 .data_len = 0x0,
2338 .data_index = 0x0,
2339 .data = bnx2_TXP_b06FwData,
2340
2341 .sbss_addr = 0x08005760,
2342 .sbss_len = 0x38,
2343 .sbss_index = 0x0,
2344 .sbss = bnx2_TXP_b06FwSbss,
2345
2346 .bss_addr = 0x080057a0,
2347 .bss_len = 0x1c4,
2348 .bss_index = 0x0,
2349 .bss = bnx2_TXP_b06FwBss,
2350
2351 .rodata_addr = 0x00000000,
2352 .rodata_len = 0x0,
2353 .rodata_index = 0x0,
2354 .rodata = bnx2_TXP_b06FwRodata,
2355};
2356
diff --git a/drivers/net/bnx2_fw2.h b/drivers/net/bnx2_fw2.h
new file mode 100644
index 000000000000..680c769a3fc0
--- /dev/null
+++ b/drivers/net/bnx2_fw2.h
@@ -0,0 +1,4086 @@
1/* bnx2_fw2.h: Broadcom NX2 network driver.
2 *
3 * Copyright (c) 2006 Broadcom Corporation
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, except as noted below.
8 *
9 * This file contains firmware data derived from proprietary unpublished
10 * source code, Copyright (c) 2006 Broadcom Corporation.
11 *
12 * Permission is hereby granted for the distribution of this firmware data
13 * in hexadecimal or equivalent format, provided this copyright notice is
14 * accompanying it.
15 */
16
17static u8 bnx2_COM_b09FwText[] = {
18 0x1f, 0x8b, 0x08, 0x08, 0xac, 0xfb, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
19 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xdc, 0x5b, 0x6b, 0x70,
20 0x1b, 0xd7, 0x75, 0x3e, 0xfb, 0x00, 0x09, 0x91, 0x10, 0xb5, 0xa4, 0x60,
21 0x1a, 0x96, 0x68, 0x07, 0x20, 0x57, 0x22, 0x6a, 0xb1, 0x29, 0x4c, 0x33,
22 0x16, 0x9b, 0xc2, 0x12, 0x02, 0x50, 0xae, 0x26, 0xc3, 0x3a, 0x94, 0xcd,
23 0xd8, 0x4a, 0xaa, 0xc9, 0x30, 0x00, 0xa5, 0xf4, 0x61, 0xb7, 0x92, 0xab,
24 0xa9, 0x5d, 0xd7, 0xaa, 0x21, 0x92, 0x6a, 0xf5, 0x83, 0xe5, 0x2a, 0x16,
25 0x43, 0xa9, 0xd3, 0x74, 0xc2, 0x12, 0x56, 0xac, 0x4e, 0x31, 0x85, 0xfc,
26 0xd6, 0x38, 0xb1, 0xc9, 0x4a, 0x76, 0xeb, 0xf4, 0xe1, 0xa6, 0x33, 0xcd,
27 0xa3, 0x9d, 0x36, 0xf6, 0xa8, 0x3f, 0xea, 0xe9, 0xd3, 0x33, 0x6e, 0xa7,
28 0xea, 0xd8, 0x0e, 0xfa, 0x7d, 0x77, 0x77, 0x81, 0x25, 0x48, 0xbd, 0xfc,
29 0xc8, 0x8f, 0x70, 0x06, 0xb3, 0x7b, 0xef, 0xde, 0xbd, 0xf7, 0xdc, 0xf3,
30 0xf8, 0xce, 0x63, 0x2f, 0xfb, 0x44, 0x5a, 0xc4, 0xfb, 0x5b, 0x8b, 0x5f,
31 0xfc, 0xfe, 0x5f, 0x2d, 0x7c, 0x7c, 0xf0, 0xe3, 0xfd, 0x22, 0xb7, 0xdc,
32 0xa2, 0xb7, 0x86, 0x75, 0xf6, 0x1b, 0xf8, 0x45, 0xf1, 0xeb, 0xf7, 0xee,
33 0x57, 0xfb, 0xb3, 0xf0, 0x7b, 0x13, 0x0f, 0xc7, 0xfe, 0x55, 0x44, 0xbb,
34 0xc4, 0x98, 0xe0, 0x5f, 0xb5, 0x7a, 0xf9, 0xe7, 0x5c, 0x38, 0x7e, 0x89,
35 0x67, 0x86, 0xbb, 0x9c, 0xa2, 0x97, 0x3f, 0x09, 0xeb, 0x69, 0x39, 0x94,
36 0xb5, 0x25, 0x6c, 0xa4, 0xdf, 0x3c, 0x54, 0xb0, 0x45, 0x32, 0xe5, 0x2d,
37 0xf1, 0x9c, 0xbc, 0x57, 0x2d, 0x46, 0x4d, 0x61, 0xff, 0x8d, 0xe9, 0x77,
38 0xbf, 0xf6, 0xe2, 0xd6, 0xc4, 0x5b, 0xf3, 0x86, 0x84, 0xad, 0xf4, 0x19,
39 0xb1, 0x36, 0x4b, 0xb8, 0x0b, 0xef, 0x7c, 0xb5, 0xf7, 0x3d, 0x91, 0x36,
40 0x7f, 0xae, 0x37, 0xab, 0x2f, 0xf6, 0x4a, 0x71, 0x43, 0x3a, 0x2c, 0x7a,
41 0x7a, 0xd3, 0xf7, 0xb3, 0x86, 0x35, 0x66, 0xa4, 0x2d, 0x59, 0xac, 0xc8,
42 0xc8, 0xde, 0x69, 0x09, 0x87, 0xd3, 0x47, 0x9b, 0x9b, 0x37, 0x49, 0xd8,
43 0x4c, 0x8f, 0x1d, 0xfa, 0x6d, 0xfb, 0xd1, 0xaa, 0x6e, 0xdb, 0xc9, 0x05,
44 0x89, 0x0c, 0x9e, 0x1a, 0xc0, 0xf3, 0x72, 0x22, 0x29, 0xb2, 0x55, 0x74,
45 0xbb, 0x18, 0x31, 0xec, 0xb0, 0x64, 0x2b, 0xb6, 0xe4, 0x2a, 0x22, 0x7f,
46 0x5e, 0xd6, 0xe4, 0x94, 0xdd, 0x29, 0x0b, 0x7d, 0xef, 0x56, 0x33, 0xa0,
47 0xe5, 0xcf, 0xec, 0xb1, 0x43, 0x53, 0x36, 0xe9, 0x9d, 0x6d, 0x76, 0xe9,
48 0x9d, 0x6a, 0x2a, 0xd8, 0xa6, 0x4c, 0x94, 0xd9, 0x37, 0xa2, 0xb3, 0x2f,
49 0x94, 0x7e, 0x68, 0xcd, 0x29, 0x3b, 0xe2, 0xf5, 0xed, 0xdc, 0x9e, 0xc5,
50 0x7c, 0x93, 0x65, 0x8e, 0x3d, 0x93, 0x2a, 0xd8, 0x51, 0xaf, 0x3f, 0x79,
51 0x5b, 0xd6, 0x8e, 0xa1, 0xbf, 0xcb, 0x7b, 0x76, 0xf2, 0xbe, 0x82, 0x6d,
52 0x7b, 0xcf, 0xbe, 0x8a, 0xb9, 0x93, 0x5e, 0xff, 0x7d, 0xdb, 0x0a, 0x76,
53 0x9f, 0xd7, 0x3f, 0xbd, 0x2d, 0x6b, 0xa7, 0xbc, 0xfe, 0xe4, 0xee, 0x82,
54 0x3d, 0xe0, 0xf5, 0x9f, 0xbd, 0x3d, 0x6b, 0x0f, 0x7a, 0xfd, 0x0f, 0x6d,
55 0x2d, 0xd8, 0x69, 0xf4, 0x1f, 0x6d, 0xd6, 0x37, 0x59, 0x72, 0xa4, 0x1c,
56 0xc7, 0x2f, 0x83, 0x67, 0x43, 0xe8, 0xdb, 0x89, 0xdf, 0x30, 0x7e, 0xbf,
57 0xb8, 0x4e, 0xda, 0x46, 0x70, 0xfd, 0xc6, 0x46, 0x97, 0x77, 0xe0, 0x91,
58 0x13, 0x96, 0x37, 0x8c, 0x98, 0xbc, 0xd8, 0xfb, 0x06, 0x78, 0x68, 0xc9,
59 0x99, 0x8a, 0x68, 0x23, 0xbd, 0x31, 0xf0, 0x2e, 0x2a, 0x4f, 0x56, 0x5a,
60 0xc5, 0x78, 0xcc, 0x00, 0x6f, 0x3e, 0x2f, 0xf9, 0x68, 0x58, 0xda, 0xe7,
61 0x34, 0xe9, 0xee, 0x0f, 0x4b, 0xc6, 0x52, 0x72, 0x13, 0x7d, 0x26, 0x2a,
62 0xc6, 0x5c, 0x66, 0xbd, 0x2e, 0x9b, 0xac, 0x9c, 0x14, 0xc1, 0xbb, 0xef,
63 0x51, 0x27, 0xf1, 0x2c, 0x2e, 0xb9, 0xe9, 0x9b, 0x65, 0xcc, 0x22, 0x5d,
64 0x3b, 0x6f, 0x74, 0xd7, 0x0a, 0x6b, 0xd9, 0x13, 0x23, 0x72, 0xc4, 0x89,
65 0x68, 0xb9, 0x13, 0xdb, 0x24, 0x9b, 0x92, 0x28, 0xde, 0x8b, 0xe5, 0xf1,
66 0xa4, 0x54, 0x1e, 0x91, 0x29, 0x47, 0xb4, 0xac, 0x43, 0x7e, 0x76, 0xe2,
67 0x79, 0x9b, 0x1a, 0x8b, 0xbe, 0x2e, 0x43, 0xcd, 0x1d, 0x46, 0xbf, 0x85,
68 0xfe, 0x0e, 0x6d, 0x48, 0xcd, 0xa1, 0xfa, 0xe3, 0x93, 0x12, 0x91, 0xc7,
69 0xcb, 0x51, 0x6f, 0x6c, 0xb5, 0x9a, 0x4d, 0x59, 0x18, 0x37, 0x22, 0x93,
70 0x4e, 0x54, 0xc6, 0x70, 0x9d, 0x70, 0xb8, 0x7e, 0x0c, 0x3a, 0xf5, 0xda,
71 0xa1, 0xfc, 0xac, 0x9a, 0x2f, 0x6e, 0xa4, 0x39, 0x5f, 0x17, 0xc6, 0x4d,
72 0x80, 0x2e, 0x4d, 0x4c, 0x25, 0xcb, 0x8c, 0xe4, 0xa7, 0x35, 0xe8, 0x1b,
73 0xae, 0x8a, 0xaf, 0x43, 0xa0, 0xdf, 0x14, 0xbb, 0x5f, 0x93, 0x02, 0x64,
74 0x55, 0xb4, 0xd0, 0x2e, 0x9f, 0xd5, 0xb3, 0x4e, 0xb3, 0xe4, 0xcc, 0xb8,
75 0x18, 0x33, 0x4a, 0x97, 0x64, 0x12, 0xef, 0xe8, 0x36, 0xc7, 0x5c, 0xc4,
76 0xbe, 0xc7, 0x94, 0x1c, 0x9a, 0xd2, 0x45, 0x3d, 0x57, 0xe9, 0x14, 0x7d,
77 0x6e, 0x8f, 0xbc, 0x3c, 0x2d, 0x96, 0x91, 0x7e, 0xb7, 0x9a, 0xb5, 0xa7,
78 0xf4, 0xec, 0x13, 0xa6, 0x84, 0x66, 0x34, 0x99, 0xb2, 0x13, 0xb0, 0x80,
79 0xa3, 0xfa, 0x8e, 0xca, 0x59, 0x8c, 0xe3, 0x7b, 0x18, 0x57, 0xd6, 0xc1,
80 0x57, 0xde, 0x6f, 0xb1, 0x74, 0xa5, 0xcf, 0x1c, 0x03, 0x19, 0x60, 0x1f,
81 0x4f, 0x3a, 0x90, 0x89, 0x92, 0x51, 0x1c, 0x32, 0x7a, 0x15, 0x32, 0x1a,
82 0x80, 0x6c, 0x52, 0xf2, 0x52, 0xa5, 0x4f, 0x9e, 0xaf, 0x24, 0xe5, 0x39,
83 0xe8, 0xeb, 0xb3, 0x95, 0xb8, 0x3c, 0x53, 0xe9, 0x92, 0xa7, 0x2b, 0x31,
84 0x79, 0x4a, 0xc9, 0x2d, 0x07, 0xdb, 0x50, 0xb2, 0x0c, 0x5f, 0x9f, 0x96,
85 0x70, 0x27, 0xe4, 0xd1, 0x01, 0xfd, 0x69, 0x87, 0x6e, 0x7e, 0xa5, 0x37,
86 0x2c, 0xb3, 0xbd, 0x92, 0x59, 0x8f, 0xfe, 0x9b, 0xd2, 0xa6, 0xe2, 0x91,
87 0x89, 0xe7, 0x93, 0xd3, 0x21, 0xc9, 0x59, 0x8f, 0xcb, 0x85, 0x19, 0x53,
88 0x26, 0x2b, 0xdb, 0x6f, 0x72, 0x65, 0xc6, 0xf6, 0xbc, 0x9c, 0x9f, 0x69,
89 0xc2, 0xb3, 0x79, 0x79, 0x79, 0xb3, 0x2e, 0x13, 0xb3, 0x6f, 0x89, 0x09,
90 0x1e, 0x0e, 0x29, 0x79, 0x3f, 0x2e, 0xff, 0xfc, 0x27, 0x22, 0x23, 0xe0,
91 0x8b, 0xde, 0xff, 0xef, 0xd5, 0x8c, 0x05, 0x7e, 0xf4, 0xf7, 0x41, 0x3f,
92 0x74, 0x5c, 0x29, 0xcf, 0x38, 0xc6, 0x98, 0x5a, 0xce, 0x39, 0x0d, 0x9b,
93 0x6a, 0xd5, 0xb2, 0xc7, 0x45, 0x0a, 0xc7, 0xab, 0x52, 0x48, 0x85, 0xe4,
94 0x01, 0xab, 0x2a, 0x43, 0xa9, 0x26, 0x39, 0x60, 0x75, 0xca, 0x44, 0xdf,
95 0xcf, 0x68, 0x3e, 0x96, 0x7d, 0xa5, 0x92, 0xc6, 0x3d, 0xfb, 0x44, 0x66,
96 0xd5, 0xbd, 0xdb, 0x5f, 0xac, 0x84, 0x24, 0x13, 0x2d, 0xc6, 0x4c, 0xb9,
97 0xa0, 0xb9, 0xb4, 0xed, 0xf4, 0x9f, 0x41, 0x5e, 0x63, 0xc0, 0x90, 0x84,
98 0xd2, 0xa5, 0xfc, 0xf4, 0x9a, 0x8b, 0x19, 0xd5, 0x1d, 0x52, 0x7a, 0x6a,
99 0xa4, 0x4d, 0xd2, 0x31, 0xa6, 0xa5, 0xa3, 0xd2, 0xad, 0xec, 0x64, 0x00,
100 0x63, 0x06, 0xb5, 0xbb, 0x2b, 0x94, 0x37, 0xee, 0xcb, 0xa4, 0x75, 0x03,
101 0xc6, 0x9a, 0xb8, 0x66, 0x3c, 0x9a, 0x83, 0x74, 0x72, 0x2e, 0xd2, 0xc9,
102 0xeb, 0xde, 0x00, 0x9d, 0xfb, 0x6a, 0xf7, 0xb3, 0x81, 0xfb, 0x62, 0xe5,
103 0xd7, 0x5b, 0x5c, 0xfa, 0xc8, 0xd7, 0x41, 0x99, 0x98, 0x7e, 0xc8, 0x5b,
104 0x0b, 0xf7, 0x65, 0xae, 0xb1, 0x00, 0x3e, 0xa9, 0x91, 0x57, 0x58, 0xab,
105 0x18, 0x58, 0xeb, 0x70, 0x60, 0xad, 0xc3, 0x81, 0xb5, 0x8a, 0xe0, 0xad,
106 0xac, 0xd3, 0x81, 0x33, 0x79, 0xc2, 0xbc, 0x1c, 0xc5, 0x9c, 0x6f, 0x88,
107 0x91, 0xa6, 0x2d, 0xf8, 0x36, 0xf9, 0x07, 0x18, 0x9f, 0x96, 0x73, 0x0e,
108 0x78, 0x73, 0x3c, 0x24, 0x77, 0xa9, 0x71, 0xff, 0xb1, 0xc6, 0xa5, 0x31,
109 0xf8, 0x2c, 0x2c, 0xbb, 0xa2, 0xbc, 0xf7, 0x9f, 0x99, 0xe0, 0x37, 0xdb,
110 0x93, 0x37, 0xb8, 0x6d, 0xde, 0x9f, 0xf5, 0xf6, 0xd2, 0xee, 0xbe, 0x57,
111 0x79, 0x53, 0x61, 0xc6, 0x62, 0x85, 0xb6, 0x2d, 0x29, 0xc3, 0x96, 0xfd,
112 0x43, 0xa9, 0x4e, 0x99, 0xb4, 0xb4, 0xd4, 0x44, 0xb2, 0x99, 0xfc, 0xcf,
113 0xe8, 0x76, 0x2b, 0xec, 0x47, 0xe2, 0x3a, 0x71, 0x51, 0xed, 0xeb, 0x5b,
114 0x1e, 0xfd, 0x16, 0xdb, 0x23, 0xba, 0xdd, 0xd1, 0xd0, 0x4f, 0xfd, 0xff,
115 0x4b, 0xdc, 0xd3, 0x06, 0xfa, 0x75, 0x77, 0xed, 0xbf, 0x42, 0x9b, 0x58,
116 0x15, 0xf1, 0xda, 0xfe, 0xf3, 0xff, 0x32, 0x96, 0xb7, 0x8f, 0x6d, 0x5c,
117 0xde, 0xf6, 0x6d, 0x29, 0x88, 0x73, 0xdc, 0x2b, 0x6c, 0xd8, 0xa6, 0xfe,
118 0x85, 0x40, 0x6b, 0x0a, 0x36, 0xdc, 0xec, 0xd1, 0xf0, 0xba, 0x47, 0x03,
119 0x68, 0xc5, 0xb8, 0x89, 0x0a, 0xdf, 0x51, 0xa2, 0x6c, 0x68, 0x93, 0xf7,
120 0xfe, 0xfd, 0x5a, 0xf5, 0xfc, 0x0d, 0x83, 0xeb, 0xf8, 0x57, 0xd1, 0x86,
121 0x60, 0x67, 0x93, 0xb3, 0xa6, 0xe4, 0x53, 0x31, 0x65, 0x0f, 0xf9, 0x54,
122 0x1d, 0x3f, 0x26, 0xa7, 0x1b, 0xf1, 0x83, 0xef, 0x11, 0x3f, 0x5c, 0xec,
123 0x98, 0x98, 0x25, 0x8e, 0xd4, 0x71, 0xe3, 0xc8, 0xb4, 0x8f, 0x25, 0x9c,
124 0x9b, 0x18, 0xe2, 0xe3, 0x07, 0xdf, 0x23, 0x7e, 0x18, 0x90, 0x15, 0xe7,
125 0xf4, 0xd7, 0x9f, 0x6a, 0x98, 0x7b, 0x4a, 0x61, 0x93, 0x8b, 0xcb, 0x6f,
126 0x06, 0x70, 0xbe, 0x0b, 0x18, 0x1d, 0x85, 0xfc, 0x7c, 0x8c, 0x26, 0x76,
127 0xc6, 0x80, 0xeb, 0xe0, 0x91, 0xc2, 0xe4, 0x08, 0x70, 0xcc, 0xf4, 0x30,
128 0x35, 0xec, 0x61, 0x6a, 0x04, 0x78, 0xca, 0xb6, 0xe5, 0xb5, 0xa3, 0x5e,
129 0x3b, 0x86, 0x36, 0xfc, 0xef, 0x1c, 0x6d, 0xec, 0xb5, 0x43, 0xe3, 0xb3,
130 0x0a, 0xa7, 0x89, 0xf1, 0xc0, 0x0a, 0xe2, 0x2c, 0xf1, 0xb6, 0x4b, 0x16,
131 0xca, 0x58, 0xaf, 0x86, 0x69, 0x94, 0x47, 0x90, 0x1e, 0xd2, 0xb2, 0x46,
132 0xf4, 0xc7, 0xdc, 0xfd, 0xe8, 0xe9, 0xcf, 0xeb, 0xd2, 0xc2, 0x7d, 0x90,
133 0xee, 0x1b, 0x41, 0x2b, 0xf7, 0xf6, 0xa3, 0xa4, 0x95, 0xeb, 0x35, 0xd2,
134 0x7b, 0x1a, 0xf4, 0x66, 0x80, 0xb7, 0xa2, 0x8d, 0xf6, 0x8e, 0x82, 0xde,
135 0x11, 0x60, 0xf1, 0x30, 0xb0, 0x78, 0x27, 0xb0, 0x78, 0x08, 0x58, 0x9c,
136 0x06, 0x0e, 0x0f, 0x02, 0x87, 0x07, 0x80, 0xc3, 0x29, 0xec, 0x2b, 0x2a,
137 0xf3, 0xc0, 0xe5, 0x79, 0xe0, 0xf3, 0x3c, 0xe4, 0x35, 0x31, 0x27, 0xda,
138 0x17, 0xb0, 0xfe, 0x63, 0x33, 0x89, 0xd3, 0xd0, 0xcd, 0x58, 0x51, 0x87,
139 0x3d, 0xa5, 0x06, 0xa1, 0x23, 0x49, 0x29, 0x55, 0x46, 0xa5, 0x40, 0x3f,
140 0xb6, 0xb9, 0x07, 0xb6, 0x0b, 0xfb, 0x89, 0xf9, 0x71, 0xd3, 0x5a, 0xef,
141 0xfa, 0xf7, 0x22, 0xf6, 0x1f, 0x83, 0x27, 0x89, 0xb8, 0xc8, 0xb0, 0xe4,
142 0x9d, 0x1e, 0x2b, 0xab, 0x27, 0x31, 0x8e, 0xed, 0xb8, 0xb6, 0xf7, 0x78,
143 0x42, 0x1b, 0x3f, 0xce, 0x3d, 0x4d, 0x03, 0xe3, 0xaa, 0x32, 0x95, 0xa2,
144 0xad, 0x56, 0xe5, 0x54, 0x2a, 0x31, 0x58, 0x94, 0x56, 0x39, 0x12, 0x9d,
145 0x56, 0xfe, 0xcd, 0x4c, 0x1f, 0x53, 0xfa, 0x51, 0xb0, 0x71, 0x2d, 0x77,
146 0x6b, 0xf9, 0xe3, 0xf4, 0x3b, 0x3d, 0xf8, 0x85, 0x40, 0x0b, 0xe7, 0x37,
147 0x65, 0x68, 0x40, 0xb4, 0x7d, 0xbd, 0x45, 0xa0, 0x62, 0xc2, 0x3a, 0x87,
148 0x95, 0x73, 0xd3, 0x3d, 0xb1, 0x9c, 0x6e, 0xca, 0x98, 0xa9, 0xc9, 0x04,
149 0xec, 0x65, 0x28, 0xf5, 0x7f, 0xd5, 0x23, 0x51, 0x3e, 0x6f, 0x96, 0xdf,
150 0x51, 0x38, 0x8b, 0xb5, 0x4b, 0xb3, 0x58, 0x37, 0x04, 0xfe, 0x71, 0x5d,
151 0xce, 0x83, 0x36, 0x30, 0xcf, 0xb4, 0x13, 0xa7, 0x8b, 0xb2, 0x1d, 0x76,
152 0xb7, 0x4e, 0xb2, 0x7d, 0x4d, 0x92, 0x19, 0x89, 0xcb, 0xc4, 0xcc, 0x76,
153 0xe0, 0x1e, 0x64, 0x60, 0xb7, 0x48, 0x7e, 0x34, 0x2e, 0x5f, 0x9e, 0x61,
154 0x5f, 0x06, 0xfb, 0x4f, 0x1c, 0xcd, 0x08, 0xf7, 0x1f, 0x52, 0xfb, 0x8a,
155 0xeb, 0x19, 0x39, 0xe0, 0xbc, 0xa4, 0xbb, 0x76, 0xe9, 0xb6, 0xf7, 0x42,
156 0x1e, 0xa7, 0xc0, 0xef, 0xbc, 0x63, 0xcb, 0x02, 0xfc, 0x4a, 0xee, 0x38,
157 0x70, 0xd5, 0x6e, 0x03, 0x06, 0x26, 0xce, 0xd2, 0x3e, 0x0c, 0xc4, 0x5a,
158 0x25, 0xc5, 0xeb, 0x2e, 0x39, 0x3e, 0xa3, 0xcb, 0xb3, 0xb7, 0xc5, 0xd1,
159 0x06, 0xd6, 0xa6, 0x12, 0x67, 0xc6, 0xf4, 0x2e, 0xb9, 0xb5, 0x23, 0x86,
160 0xf7, 0x52, 0x5a, 0xde, 0xf9, 0x37, 0xf2, 0xf2, 0x64, 0x5c, 0xe7, 0x58,
161 0x5d, 0x72, 0x29, 0x03, 0x3a, 0x56, 0xc4, 0xf8, 0x7f, 0x40, 0x7f, 0x97,
162 0xcc, 0x21, 0xbe, 0x99, 0x03, 0x4d, 0xd9, 0x14, 0xb1, 0x30, 0x71, 0x72,
163 0x49, 0x07, 0x66, 0xcd, 0x41, 0x37, 0x47, 0x11, 0x3f, 0xcc, 0xfc, 0x37,
164 0xc6, 0xc4, 0x21, 0xd3, 0x1e, 0x6b, 0x02, 0xf8, 0x92, 0xe9, 0xe2, 0x3d,
165 0xe7, 0xb4, 0xe5, 0x94, 0x43, 0x1d, 0x8a, 0xcb, 0xe3, 0x15, 0xbe, 0xd7,
166 0x73, 0xf6, 0x69, 0xb1, 0xe5, 0x41, 0xe7, 0x7f, 0x30, 0xfe, 0x1d, 0xc4,
167 0x9e, 0x96, 0x94, 0x20, 0xb7, 0x02, 0x78, 0x99, 0x89, 0xb9, 0xed, 0x89,
168 0xb9, 0xc4, 0xd9, 0x0b, 0x3a, 0xef, 0xed, 0xe2, 0x82, 0x7e, 0xb3, 0x48,
169 0x07, 0xf9, 0x99, 0x02, 0x2f, 0x6d, 0x4b, 0xd7, 0x37, 0x7b, 0xf1, 0x16,
170 0x6d, 0xc0, 0x06, 0x7d, 0xa6, 0x2c, 0xf4, 0x07, 0x6d, 0x80, 0x7e, 0xd6,
171 0xb7, 0x81, 0x44, 0x6c, 0x49, 0xd7, 0xf1, 0xdc, 0x94, 0x63, 0xaa, 0xad,
172 0x81, 0xd6, 0x44, 0x8c, 0xfb, 0x9b, 0x2c, 0x27, 0xe5, 0x71, 0x87, 0xe3,
173 0xc1, 0xe7, 0xe9, 0x88, 0x37, 0x1e, 0xf1, 0x8e, 0xc3, 0x98, 0x29, 0x09,
174 0x9a, 0x5d, 0xbb, 0x58, 0x98, 0x8e, 0xaa, 0x67, 0x47, 0x1c, 0x37, 0x36,
175 0xd2, 0x11, 0x3f, 0xcd, 0x23, 0x7e, 0xca, 0x29, 0x1b, 0xb1, 0x32, 0x88,
176 0xaf, 0xe1, 0x67, 0x5d, 0xfb, 0x28, 0x95, 0x49, 0xcb, 0x3d, 0xa0, 0x2f,
177 0x51, 0x04, 0x31, 0xc7, 0x74, 0xb8, 0xeb, 0xec, 0x80, 0x14, 0x19, 0x63,
178 0x9d, 0x33, 0x1e, 0x91, 0xb1, 0x12, 0xfd, 0x1b, 0x7e, 0x8e, 0x6d, 0x31,
179 0xa6, 0xcf, 0x28, 0xdf, 0xd3, 0x03, 0x3d, 0x80, 0x5f, 0x4a, 0xb5, 0x8b,
180 0xeb, 0x07, 0xf7, 0x40, 0x9e, 0xc3, 0x90, 0x7b, 0x5a, 0xc6, 0x4f, 0x8c,
181 0x53, 0xa7, 0x93, 0x25, 0x49, 0x24, 0x8f, 0xc8, 0x16, 0x6b, 0x01, 0xbe,
182 0x30, 0x33, 0x5a, 0xdd, 0xae, 0xa7, 0xf9, 0xce, 0xa3, 0x78, 0x07, 0xd7,
183 0xd2, 0xb8, 0x3c, 0x50, 0x61, 0xdf, 0x9d, 0x86, 0xb4, 0xc0, 0x56, 0x06,
184 0xf6, 0x78, 0x76, 0x80, 0xf9, 0x4c, 0x7f, 0xbe, 0x71, 0x6f, 0x3e, 0x8e,
185 0xe3, 0x18, 0xbe, 0x53, 0x9f, 0x77, 0x07, 0x7d, 0x1b, 0xb0, 0x64, 0x87,
186 0x5e, 0xdd, 0x1e, 0xc2, 0xf3, 0x53, 0x03, 0xbc, 0xc7, 0x3c, 0xf0, 0x6d,
187 0x96, 0x3d, 0x8c, 0xb1, 0xa3, 0x98, 0x73, 0x8d, 0x64, 0x3b, 0x7d, 0x7a,
188 0xa9, 0x03, 0x8c, 0x3f, 0xd8, 0x8e, 0xae, 0x77, 0x79, 0xff, 0x25, 0xc3,
189 0xd5, 0xc9, 0x11, 0xb4, 0x69, 0x7f, 0x07, 0x25, 0xe7, 0x24, 0xb0, 0x4f,
190 0xf0, 0xb6, 0x32, 0xe1, 0xed, 0x11, 0xfc, 0x1f, 0x39, 0x0c, 0x3e, 0x48,
191 0xd1, 0xe5, 0x0d, 0xf9, 0x42, 0x9e, 0xfc, 0x16, 0x74, 0xff, 0x61, 0x8c,
192 0x81, 0x7f, 0x50, 0x3c, 0x58, 0xea, 0x70, 0x63, 0xd1, 0x44, 0x31, 0xc3,
193 0xfc, 0xa9, 0x83, 0x98, 0x07, 0xfc, 0xa9, 0x40, 0xb1, 0x30, 0xf7, 0x92,
194 0xbe, 0x86, 0xf4, 0xc6, 0x97, 0x0c, 0x83, 0xed, 0xe4, 0x12, 0x74, 0xb8,
195 0x04, 0xf9, 0x64, 0xfb, 0x68, 0xb3, 0x36, 0xe4, 0x31, 0x63, 0x50, 0x5f,
196 0x4b, 0x88, 0x05, 0xf3, 0xce, 0x16, 0xeb, 0x5e, 0xf2, 0xcd, 0xb2, 0xe4,
197 0x69, 0x27, 0x88, 0x1d, 0x3b, 0x30, 0x94, 0x7a, 0x18, 0x85, 0x1e, 0x98,
198 0xf0, 0xc9, 0x31, 0xc8, 0xfc, 0xc5, 0x0e, 0x77, 0x2f, 0xbc, 0x37, 0x65,
199 0xde, 0xc2, 0x9a, 0xce, 0xef, 0xaf, 0x73, 0xfb, 0x78, 0xcf, 0xb8, 0xc8,
200 0x97, 0xab, 0x4f, 0x3b, 0xe5, 0xdb, 0x28, 0xd3, 0x43, 0xd8, 0x0b, 0xfb,
201 0x71, 0x2d, 0x1d, 0x94, 0x71, 0xd0, 0x56, 0x18, 0xd8, 0x14, 0x3b, 0x8f,
202 0xf1, 0x39, 0xe0, 0x79, 0xd1, 0xe4, 0xb3, 0x8b, 0x5a, 0xfd, 0x1d, 0xc4,
203 0x5c, 0x36, 0xfd, 0xd9, 0x92, 0xf6, 0x85, 0xca, 0xcb, 0x5a, 0xb6, 0x74,
204 0x51, 0xcb, 0x41, 0x4f, 0x4a, 0x0e, 0x73, 0x06, 0xda, 0x8f, 0x85, 0xb5,
205 0x13, 0xb1, 0xb7, 0xf5, 0x9e, 0xf8, 0x02, 0xb0, 0x60, 0x2f, 0x6c, 0x3a,
206 0x67, 0xee, 0x94, 0x02, 0xb0, 0x35, 0x7f, 0x62, 0x0b, 0xec, 0x2d, 0x1e,
207 0xa0, 0x8b, 0x78, 0x56, 0xa4, 0x4f, 0xd5, 0x76, 0x38, 0x52, 0x6c, 0x4a,
208 0x13, 0xd7, 0x36, 0x41, 0x77, 0xd0, 0x57, 0xae, 0xeb, 0xdf, 0x1d, 0x2b,
209 0x68, 0x45, 0x7e, 0x39, 0xb0, 0x9c, 0xde, 0x92, 0x5c, 0x99, 0xde, 0x1d,
210 0x35, 0x7a, 0x89, 0x19, 0xc0, 0x7f, 0xd8, 0xcd, 0x4b, 0xd0, 0xdf, 0xe7,
211 0x1d, 0xe0, 0xbf, 0x03, 0xfc, 0x87, 0x4d, 0x3d, 0x03, 0xdd, 0x7b, 0xda,
212 0x81, 0x0f, 0x70, 0xe0, 0x03, 0x1c, 0xf8, 0x00, 0x27, 0x0b, 0x39, 0x11,
213 0xe7, 0xe9, 0x43, 0x76, 0xd7, 0x7c, 0x9e, 0x1b, 0x37, 0xdd, 0xe0, 0xc5,
214 0x22, 0xa3, 0x88, 0x45, 0x36, 0xc8, 0x44, 0xf2, 0x7a, 0xec, 0xad, 0x05,
215 0xd7, 0x56, 0x5c, 0xb1, 0x46, 0xf2, 0x76, 0xcf, 0x4e, 0x1e, 0x06, 0x5d,
216 0x88, 0xbf, 0x93, 0x3f, 0x0d, 0x3d, 0x6c, 0x02, 0x3d, 0x3f, 0xe5, 0xc5,
217 0x2c, 0x0f, 0x9a, 0xae, 0x1e, 0xb6, 0xa2, 0xef, 0x93, 0xe8, 0x6b, 0xc5,
218 0x98, 0x03, 0x18, 0xc3, 0x98, 0xa7, 0xcd, 0xeb, 0x0b, 0x8e, 0x63, 0xec,
219 0xf3, 0x19, 0xac, 0x95, 0xc0, 0xb8, 0x36, 0xcc, 0xdd, 0x85, 0x31, 0xdb,
220 0x30, 0xe6, 0x46, 0xb4, 0x19, 0x33, 0x6f, 0x44, 0xfb, 0x13, 0x0d, 0xef,
221 0x7c, 0x0c, 0x7d, 0xb7, 0x37, 0xf4, 0x9d, 0x43, 0x1f, 0xf2, 0x50, 0xeb,
222 0xbc, 0xf7, 0x5e, 0x11, 0xed, 0xce, 0x86, 0x31, 0xaf, 0xa2, 0x0f, 0x71,
223 0xaf, 0xf5, 0x2d, 0x5c, 0x91, 0x7f, 0x5a, 0xa4, 0xc9, 0x7f, 0xc6, 0xb8,
224 0x37, 0x8e, 0xfe, 0x90, 0x17, 0xbb, 0xfe, 0xa6, 0x09, 0xbd, 0xd3, 0x86,
225 0x9c, 0xdf, 0x30, 0xdd, 0x58, 0xef, 0x4e, 0xcb, 0xd5, 0x43, 0xbf, 0xfd,
226 0x70, 0x43, 0x9b, 0x63, 0x17, 0x1a, 0xfa, 0xfe, 0xa5, 0xa1, 0xfd, 0xdd,
227 0xd0, 0xca, 0x77, 0x06, 0xdb, 0x97, 0xf7, 0x15, 0x3a, 0x96, 0xb7, 0xed,
228 0xa6, 0x95, 0xef, 0xe8, 0xeb, 0x96, 0xf7, 0xdd, 0xb8, 0xbe, 0x61, 0x0c,
229 0x74, 0x2a, 0x8a, 0x1c, 0xc9, 0x1f, 0x1f, 0xbe, 0xce, 0x7d, 0x4e, 0xfe,
230 0x36, 0xea, 0x92, 0xda, 0x3a, 0xda, 0x3a, 0xe4, 0xb0, 0xa4, 0xc1, 0x9e,
231 0x2c, 0x3d, 0xfd, 0xb2, 0x96, 0x83, 0x4e, 0x65, 0x2b, 0xfe, 0x7c, 0xb4,
232 0xd9, 0xc6, 0xdc, 0xdc, 0xcf, 0xc9, 0x19, 0x2b, 0x45, 0xa0, 0x37, 0xf7,
233 0xd0, 0x27, 0x1d, 0x2d, 0x4a, 0xdd, 0x3e, 0xbb, 0xf5, 0x4b, 0xd9, 0xe7,
234 0xed, 0x1e, 0x46, 0x1d, 0x06, 0x9d, 0x55, 0x19, 0x49, 0x35, 0xd3, 0xc7,
235 0x78, 0xd8, 0x45, 0xdc, 0xa9, 0x56, 0x8d, 0xcd, 0x55, 0xd9, 0x9f, 0x7a,
236 0xa7, 0x2a, 0x0a, 0xf3, 0x06, 0x15, 0xee, 0xc4, 0xf5, 0x1e, 0xc8, 0xc8,
237 0x42, 0x6e, 0x82, 0x7c, 0x3a, 0x4a, 0x9f, 0x74, 0x90, 0xf1, 0xc9, 0xa3,
238 0x2e, 0xa6, 0x12, 0x77, 0xd0, 0x46, 0x5e, 0x96, 0x3f, 0xce, 0xf5, 0x71,
239 0x2d, 0x11, 0xc7, 0x47, 0x95, 0x4f, 0xc9, 0x5b, 0x9c, 0x77, 0x35, 0x6c,
240 0x3c, 0x6b, 0x32, 0xa6, 0x33, 0xed, 0xd3, 0xf0, 0x6f, 0x7c, 0xc6, 0x58,
241 0xe1, 0x34, 0xe3, 0x92, 0x00, 0x56, 0x6d, 0x35, 0xe0, 0x32, 0x8b, 0xcb,
242 0xf7, 0xb5, 0x81, 0x79, 0xc4, 0x55, 0xec, 0x75, 0x75, 0x2c, 0xea, 0xd1,
243 0xaf, 0x6c, 0xdb, 0xbb, 0x6a, 0xb6, 0xed, 0xeb, 0xde, 0x6a, 0x39, 0xf8,
244 0xf7, 0x95, 0x2c, 0x9e, 0xaa, 0x24, 0x8e, 0x15, 0x61, 0x4b, 0x8b, 0x2a,
245 0xef, 0xf6, 0xe5, 0xc2, 0x18, 0x27, 0x71, 0x72, 0x1e, 0x6f, 0x8e, 0xab,
246 0x1c, 0x83, 0xf9, 0x45, 0x55, 0x76, 0xa4, 0x5a, 0xa3, 0xe4, 0x43, 0x46,
247 0xff, 0x76, 0x88, 0x31, 0xc3, 0xa2, 0x43, 0x9e, 0xa5, 0xf0, 0x3c, 0x05,
248 0x4c, 0xf8, 0x27, 0xc9, 0x45, 0xd9, 0xf7, 0x76, 0x75, 0x01, 0x71, 0x95,
249 0x8a, 0x8f, 0x94, 0xbf, 0x67, 0x7c, 0xb7, 0x1f, 0xfc, 0x22, 0x4f, 0x47,
250 0xc0, 0x67, 0x3f, 0x06, 0x78, 0x8d, 0x75, 0x15, 0x59, 0x1e, 0x07, 0x8b,
251 0x3c, 0x50, 0x7e, 0x19, 0x73, 0xea, 0x6e, 0xac, 0xc2, 0x3c, 0xdc, 0x66,
252 0x7f, 0x47, 0x88, 0xb1, 0x9c, 0xeb, 0xeb, 0x0d, 0xac, 0x87, 0xdc, 0xbe,
253 0xfc, 0x8f, 0x2a, 0x6e, 0x2a, 0x28, 0x79, 0x20, 0x86, 0xaa, 0xf0, 0x19,
254 0xfb, 0xc2, 0x5e, 0xec, 0x1c, 0xf1, 0x62, 0x65, 0xcb, 0x8b, 0x95, 0x49,
255 0x07, 0x6b, 0x6f, 0x7e, 0x5c, 0x40, 0x99, 0x2d, 0x1d, 0xd2, 0x37, 0x33,
256 0x2e, 0x68, 0x93, 0xd5, 0xe3, 0x02, 0x9f, 0xa6, 0x6d, 0xa0, 0x89, 0x71,
257 0x9e, 0xaa, 0xbd, 0x74, 0xb8, 0xf5, 0x1e, 0xd2, 0xe0, 0xfb, 0x47, 0xe5,
258 0x87, 0x8f, 0xc2, 0xe5, 0x61, 0x6f, 0x69, 0xd0, 0xba, 0x53, 0xb2, 0xd3,
259 0xdb, 0x3c, 0x7f, 0xcb, 0x1c, 0x80, 0xf1, 0xb7, 0xab, 0xb3, 0xd9, 0xd4,
260 0x84, 0x3f, 0x4f, 0x27, 0x3c, 0x64, 0xa0, 0x2e, 0xc4, 0xb5, 0x18, 0xc7,
261 0xf8, 0x31, 0xcd, 0x4e, 0x2f, 0xa6, 0x19, 0x96, 0xfd, 0x8e, 0x1b, 0xf3,
262 0x8f, 0xa0, 0x3f, 0xef, 0x28, 0xda, 0x63, 0x8c, 0x2d, 0x75, 0xc4, 0xdc,
263 0x99, 0x3d, 0x09, 0x24, 0x0f, 0xee, 0x5e, 0xba, 0xb1, 0x97, 0x52, 0x6d,
264 0x2f, 0xad, 0x4b, 0xcb, 0xf7, 0x32, 0xaa, 0xde, 0x9d, 0x5a, 0xf1, 0xae,
265 0x60, 0x1f, 0xbb, 0x2f, 0xf1, 0x8c, 0x7b, 0x64, 0xdc, 0x60, 0x79, 0x7b,
266 0xf4, 0xe5, 0x74, 0x00, 0x7b, 0x4c, 0x6a, 0x79, 0x15, 0x6b, 0xed, 0x51,
267 0x3c, 0xcf, 0x97, 0xc7, 0x70, 0xa5, 0x7d, 0xa8, 0x79, 0x94, 0x8d, 0x4c,
268 0x28, 0x3e, 0x8f, 0xab, 0x7d, 0x2c, 0x94, 0x7f, 0x41, 0x0a, 0x27, 0x7e,
269 0x09, 0x7e, 0x2f, 0x58, 0x0f, 0x63, 0x2d, 0x91, 0xfc, 0x28, 0x06, 0xf0,
270 0x93, 0x7b, 0x65, 0xad, 0xeb, 0x0f, 0x43, 0x6e, 0x7e, 0x10, 0x81, 0x8c,
271 0x35, 0xf7, 0xb9, 0x5a, 0xdf, 0xe7, 0x6b, 0x53, 0x80, 0x9e, 0x2a, 0x62,
272 0xce, 0x18, 0x68, 0x08, 0xbe, 0x73, 0x50, 0x86, 0x1c, 0xca, 0xa3, 0x27,
273 0x36, 0x2e, 0xb6, 0x95, 0x17, 0x3f, 0xce, 0xe0, 0xfa, 0xb4, 0xf9, 0x5c,
274 0xcc, 0x10, 0xd6, 0x2f, 0x7d, 0xde, 0xf9, 0x7c, 0x8b, 0x2c, 0x35, 0xea,
275 0xc0, 0x14, 0xe8, 0x29, 0x38, 0xe4, 0x93, 0xaf, 0x9b, 0xfe, 0xda, 0xaf,
276 0xaa, 0xfd, 0x4c, 0xaa, 0x9a, 0xdd, 0x73, 0x35, 0x1d, 0x9d, 0x40, 0x0c,
277 0xe2, 0xea, 0xdc, 0x7d, 0x1e, 0x6f, 0x7c, 0xdd, 0x8c, 0x78, 0x72, 0x66,
278 0x1e, 0x47, 0xdb, 0xf1, 0xf5, 0x60, 0x93, 0x75, 0xb7, 0xe2, 0x05, 0x9f,
279 0x11, 0x53, 0x5c, 0x59, 0x8e, 0xd5, 0x64, 0xb9, 0xb6, 0x41, 0x2f, 0xbf,
280 0xb7, 0xce, 0xb5, 0x43, 0xda, 0x1b, 0xec, 0x16, 0xf4, 0x3d, 0xb5, 0xcc,
281 0xbe, 0x93, 0x97, 0xa8, 0x83, 0x46, 0xc4, 0x98, 0xfb, 0x53, 0xf0, 0xf2,
282 0x63, 0xc8, 0x55, 0x44, 0xcc, 0x19, 0xe2, 0x10, 0xe3, 0x8d, 0x7a, 0xbc,
283 0xbb, 0x20, 0xab, 0xc5, 0xba, 0x57, 0x8a, 0x35, 0x7e, 0xf2, 0x2a, 0x63,
284 0x8d, 0x78, 0x93, 0xb4, 0x10, 0x8b, 0x86, 0x11, 0xdb, 0x6a, 0xd2, 0x64,
285 0x3f, 0x08, 0x1f, 0x76, 0xc6, 0x6c, 0xb6, 0x7d, 0x4c, 0x88, 0x48, 0xfb,
286 0xdc, 0x06, 0x85, 0x0b, 0xd6, 0x4c, 0x1d, 0x17, 0x26, 0xc0, 0xfb, 0x11,
287 0xb7, 0xb6, 0x1a, 0x6d, 0x97, 0xab, 0xcd, 0x8d, 0xeb, 0x71, 0xff, 0x58,
288 0x2d, 0xee, 0xbf, 0xa1, 0x81, 0x8f, 0xab, 0xe1, 0xe2, 0x19, 0xf0, 0x2d,
289 0x8d, 0xfc, 0x97, 0x79, 0xed, 0x10, 0xf2, 0x61, 0xe6, 0x62, 0x19, 0xe4,
290 0xc4, 0x89, 0x33, 0xc0, 0x2a, 0xe4, 0xc8, 0x89, 0xb7, 0xe0, 0x57, 0x90,
291 0x37, 0x27, 0xe6, 0x99, 0xbb, 0x2e, 0x22, 0x3f, 0x7e, 0x1a, 0xf9, 0xf1,
292 0x53, 0x95, 0x3e, 0xf0, 0x37, 0xa9, 0xb0, 0x73, 0xef, 0x71, 0xd1, 0xee,
293 0x52, 0xf5, 0x61, 0xda, 0x73, 0x14, 0x7e, 0xb4, 0x5a, 0x3d, 0x90, 0xea,
294 0x41, 0x4e, 0x1e, 0x97, 0x4f, 0x99, 0xcc, 0x63, 0x35, 0xb3, 0xbb, 0x7f,
295 0xc1, 0x08, 0xc6, 0xa4, 0xd9, 0x2b, 0xfa, 0x81, 0x95, 0xbc, 0xcf, 0x29,
296 0x5f, 0x70, 0xcc, 0xb8, 0x1c, 0xef, 0xef, 0xaa, 0xf1, 0xfe, 0xc2, 0x1a,
297 0x69, 0x19, 0x56, 0x35, 0x80, 0xee, 0xfe, 0x03, 0xc4, 0xab, 0x14, 0xfc,
298 0x3a, 0xfc, 0x6f, 0x55, 0xee, 0x48, 0x5d, 0xac, 0x9e, 0xb7, 0xd7, 0x49,
299 0xbe, 0xef, 0x8b, 0x1e, 0x66, 0x8f, 0x3d, 0x92, 0xb5, 0x8b, 0xb0, 0x0f,
300 0xb7, 0x16, 0x39, 0x3e, 0x1d, 0x46, 0x14, 0xca, 0xbf, 0x0e, 0x59, 0x18,
301 0xfc, 0x1b, 0xc8, 0x70, 0xcb, 0x69, 0x16, 0xb0, 0x74, 0xe0, 0xf0, 0x42,
302 0x34, 0xa2, 0xea, 0x33, 0xd7, 0xd9, 0xec, 0xb7, 0x20, 0xd3, 0x51, 0x59,
303 0x40, 0xfc, 0x50, 0x1a, 0x04, 0x8d, 0x7d, 0x9d, 0x18, 0x4f, 0xbb, 0x23,
304 0xcf, 0x47, 0xe1, 0x7b, 0xc9, 0xd3, 0x28, 0xc6, 0xef, 0xc2, 0x98, 0x0e,
305 0x5c, 0xbf, 0x68, 0x2c, 0x58, 0xcc, 0x9d, 0x7f, 0x0e, 0x6d, 0xce, 0x11,
306 0xf4, 0x9d, 0x9f, 0x0e, 0x89, 0x9a, 0x93, 0xef, 0x74, 0x2a, 0xfb, 0xaf,
307 0xaf, 0xc5, 0x75, 0xf8, 0xec, 0xbd, 0xea, 0x2d, 0xfd, 0x83, 0x81, 0xf5,
308 0xda, 0x02, 0xeb, 0x0d, 0x06, 0xd6, 0x23, 0x9d, 0x1d, 0x01, 0x3a, 0x3b,
309 0xf0, 0x7e, 0x0e, 0x6b, 0x0f, 0xab, 0x98, 0xa7, 0xbe, 0xe6, 0xfd, 0x81,
310 0x35, 0xfd, 0xfd, 0x75, 0x06, 0xde, 0x7b, 0x07, 0xeb, 0xb1, 0x2f, 0x1a,
311 0xe8, 0x23, 0x0d, 0xeb, 0xd1, 0xc7, 0x76, 0x47, 0x80, 0x2e, 0xd2, 0xba,
312 0x16, 0xfd, 0x2a, 0x7e, 0x02, 0x9f, 0x5b, 0xe0, 0xb7, 0x74, 0xf8, 0x0e,
313 0xd6, 0xa0, 0x1b, 0xf7, 0xfa, 0x65, 0xac, 0xeb, 0xcf, 0x17, 0xc5, 0x1c,
314 0x1c, 0xcf, 0xb1, 0x86, 0xf7, 0x3e, 0xfb, 0xf9, 0xfc, 0x1b, 0xd5, 0xaf,
315 0x2b, 0xbe, 0xad, 0x07, 0xed, 0xaa, 0xee, 0x22, 0xf3, 0x1d, 0x26, 0xe4,
316 0xc9, 0xfc, 0x58, 0x93, 0x9b, 0x6c, 0x5d, 0xeb, 0xe9, 0xa7, 0xec, 0xd7,
317 0x79, 0x58, 0xda, 0xa2, 0x65, 0x8f, 0xb3, 0x5e, 0xd0, 0xea, 0xe5, 0x7c,
318 0xc8, 0x3d, 0x94, 0x8f, 0x31, 0xbd, 0xe7, 0xf4, 0x31, 0x8c, 0x5b, 0xe8,
319 0x3f, 0x33, 0xde, 0x3d, 0xae, 0xd0, 0xe1, 0x7d, 0xa5, 0x0e, 0x39, 0xaf,
320 0x78, 0x6a, 0xc9, 0xb9, 0x1a, 0x4f, 0x43, 0xde, 0xb7, 0x90, 0x83, 0xde,
321 0x77, 0x06, 0x03, 0x71, 0x11, 0xee, 0xcb, 0x19, 0xd0, 0x10, 0x97, 0x9e,
322 0x7e, 0xe6, 0x6e, 0x45, 0x5c, 0x59, 0xa7, 0xd0, 0x70, 0x75, 0xeb, 0x17,
323 0x3d, 0xfd, 0xf0, 0x4b, 0xc0, 0xa1, 0x9e, 0xfe, 0xef, 0xa8, 0x7c, 0xae,
324 0x54, 0xb1, 0xb4, 0x3b, 0x1c, 0xb7, 0x46, 0x74, 0xce, 0xbe, 0x5c, 0x8d,
325 0x68, 0xa0, 0x99, 0x75, 0x0d, 0xbf, 0x46, 0x74, 0x4e, 0x54, 0x8d, 0xe8,
326 0xe4, 0x15, 0x6a, 0x44, 0x99, 0xab, 0xaf, 0x11, 0x71, 0x7e, 0x53, 0xee,
327 0x1e, 0x10, 0xed, 0x4b, 0x5e, 0x8d, 0xe8, 0x82, 0xb8, 0x35, 0xa2, 0xf3,
328 0xb2, 0x7a, 0x8d, 0xe8, 0x68, 0x43, 0x8d, 0x68, 0xbd, 0xaa, 0x11, 0x71,
329 0x1e, 0xb7, 0x46, 0xc4, 0x76, 0xbe, 0x7f, 0x30, 0x50, 0xeb, 0x00, 0xfe,
330 0x3a, 0xb7, 0x82, 0x6f, 0x96, 0x36, 0xea, 0xf8, 0x98, 0x46, 0xec, 0xbf,
331 0xbe, 0xe6, 0xbf, 0xea, 0xf8, 0xa6, 0x29, 0x9d, 0xbb, 0x12, 0xbe, 0x8d,
332 0xba, 0x71, 0xc9, 0x32, 0x6c, 0x9b, 0xaa, 0xc5, 0x2e, 0xbf, 0xdc, 0xcc,
333 0x1c, 0x7a, 0xb2, 0x5c, 0x9f, 0x77, 0x12, 0xf2, 0x1e, 0xab, 0xd5, 0x49,
334 0x2e, 0x15, 0x1f, 0x45, 0xe5, 0xe0, 0xaa, 0xdf, 0x9a, 0x62, 0x99, 0x95,
335 0xdf, 0x9a, 0x34, 0x89, 0x82, 0xce, 0x7c, 0x7f, 0x5e, 0xe5, 0x5d, 0x0b,
336 0xce, 0xcf, 0xcb, 0xd2, 0xbd, 0x16, 0xf0, 0xc7, 0xaf, 0x9f, 0x50, 0xbe,
337 0x75, 0x9f, 0x92, 0xd5, 0x3f, 0xba, 0x1a, 0xca, 0x3e, 0x55, 0x43, 0xf9,
338 0x5a, 0x73, 0xb0, 0x86, 0x72, 0x4e, 0x2e, 0x5f, 0x43, 0xd9, 0xb7, 0x4a,
339 0x0d, 0xe5, 0x15, 0xa9, 0xd7, 0x50, 0x5e, 0x11, 0xbf, 0x86, 0x62, 0xc8,
340 0xd2, 0x7a, 0xce, 0xb3, 0x1f, 0xef, 0x8c, 0xe0, 0x37, 0x8c, 0x9f, 0x5b,
341 0x53, 0x39, 0x57, 0xa3, 0x7f, 0xb5, 0x9a, 0xca, 0x37, 0x9b, 0xdf, 0x4f,
342 0x4d, 0xc5, 0xf5, 0x01, 0x7e, 0x4d, 0xa5, 0x05, 0xf1, 0x0e, 0x7c, 0x8e,
343 0x1e, 0xac, 0xa9, 0xfc, 0x2d, 0xed, 0x01, 0x7d, 0x2a, 0x46, 0x40, 0x3f,
344 0xec, 0x02, 0x7e, 0x29, 0xa3, 0x6a, 0x1c, 0x9f, 0xf6, 0x78, 0xb8, 0x1b,
345 0x7b, 0x8e, 0x43, 0x16, 0xe4, 0x63, 0x8f, 0x8a, 0x2d, 0x33, 0x66, 0x4c,
346 0xcb, 0xf6, 0xc2, 0x9b, 0x4d, 0xf3, 0x5b, 0x74, 0x4c, 0xc6, 0x2b, 0xd4,
347 0xf1, 0x2e, 0xc4, 0xe2, 0x26, 0xfa, 0x76, 0xa3, 0xed, 0xc7, 0x54, 0xfd,
348 0xb5, 0x39, 0x68, 0x9b, 0x0b, 0xc0, 0x59, 0xe0, 0xc4, 0x55, 0xf8, 0xa8,
349 0x6d, 0xa0, 0x39, 0xb8, 0x8f, 0x22, 0xfc, 0x13, 0xfa, 0x94, 0xcc, 0x19,
350 0x5b, 0xfa, 0xb4, 0xc4, 0x69, 0xe7, 0x57, 0x31, 0x1f, 0xfb, 0xb6, 0xa9,
351 0x7c, 0xac, 0x30, 0xc0, 0xbd, 0xd2, 0xd7, 0x2d, 0x82, 0x3e, 0xf4, 0x95,
352 0x98, 0x03, 0xd2, 0xef, 0xf9, 0x39, 0x5a, 0x44, 0xe5, 0x68, 0x9d, 0x8a,
353 0x1f, 0xe4, 0xf5, 0x8d, 0x61, 0x62, 0x65, 0xa7, 0xcd, 0x3d, 0x0c, 0x7b,
354 0x58, 0xc7, 0xb6, 0x9b, 0x0b, 0x66, 0x74, 0xde, 0x3f, 0x02, 0xb9, 0xb2,
355 0x4e, 0xe3, 0xcb, 0xef, 0x21, 0x6f, 0xdf, 0x83, 0x52, 0xec, 0x94, 0xf0,
356 0x7a, 0xd0, 0x93, 0x9f, 0x61, 0xdc, 0xfd, 0x09, 0x95, 0x83, 0x44, 0xed,
357 0x4b, 0xdb, 0xed, 0x5d, 0xd7, 0x60, 0xb7, 0x23, 0x97, 0xb5, 0xdb, 0xcf,
358 0x85, 0x83, 0x76, 0x7b, 0xd7, 0x35, 0xd8, 0xed, 0xfe, 0x6b, 0xb2, 0x5b,
359 0xee, 0x8d, 0x98, 0xe4, 0xd7, 0xc4, 0x56, 0xc6, 0x59, 0xfe, 0xba, 0x13,
360 0x58, 0x33, 0x73, 0x89, 0x35, 0xc7, 0x2e, 0x59, 0x5b, 0x6d, 0x8c, 0xb1,
361 0xae, 0x46, 0xde, 0xcc, 0xad, 0xe8, 0x6f, 0x23, 0x9e, 0x5f, 0xba, 0xdd,
362 0xcb, 0xe7, 0xfd, 0xbc, 0x3e, 0x68, 0x3f, 0xd4, 0x0b, 0xea, 0xc2, 0x63,
363 0xe0, 0x17, 0xf5, 0xc1, 0xb7, 0xb9, 0x9e, 0x06, 0x1d, 0x5c, 0x44, 0xbe,
364 0xdf, 0xe3, 0xe9, 0x20, 0x65, 0xdd, 0xab, 0xbe, 0x11, 0x95, 0x9c, 0x47,
365 0xdc, 0x3c, 0x1f, 0x3a, 0x90, 0x2f, 0xf9, 0xb6, 0x06, 0x9e, 0x44, 0xfd,
366 0x67, 0xe4, 0xa3, 0x8d, 0x98, 0x67, 0x0b, 0xe2, 0x35, 0xf0, 0x48, 0xf5,
367 0x2f, 0xaf, 0x09, 0x5f, 0x1e, 0xcf, 0xa4, 0x18, 0xc2, 0xd8, 0x53, 0x03,
368 0xb0, 0xf1, 0x01, 0x62, 0x54, 0x1a, 0x79, 0x0f, 0xf5, 0x90, 0xba, 0xb9,
369 0x29, 0xb9, 0x43, 0x67, 0x4c, 0xb5, 0x07, 0xb6, 0x47, 0x7d, 0x8d, 0xcb,
370 0x8e, 0xca, 0xa6, 0x33, 0xe7, 0x74, 0xae, 0x51, 0xad, 0xe6, 0x99, 0x2b,
371 0x5a, 0xa2, 0x77, 0xf7, 0xff, 0x45, 0x98, 0x7e, 0xe9, 0x7a, 0xdb, 0xf0,
372 0x74, 0x2d, 0x83, 0x7b, 0xea, 0xed, 0xeb, 0xf0, 0xf7, 0xfc, 0xc6, 0xfe,
373 0x03, 0xf4, 0xc7, 0x60, 0xf3, 0xf4, 0xef, 0xcc, 0x47, 0xb6, 0x7a, 0xe3,
374 0x7a, 0xd4, 0xf7, 0xcf, 0x6c, 0xea, 0x56, 0xef, 0xbb, 0x13, 0xfd, 0x4f,
375 0x82, 0x3e, 0x7b, 0x99, 0x9c, 0x79, 0x46, 0x21, 0xa7, 0xf2, 0x19, 0xbe,
376 0xaf, 0x74, 0x12, 0x39, 0x88, 0x19, 0xa8, 0xa5, 0x87, 0xbd, 0xdc, 0x8d,
377 0x36, 0x16, 0x81, 0x0c, 0xb7, 0x7b, 0xb9, 0x0a, 0xf3, 0xd7, 0xe5, 0x67,
378 0x13, 0x56, 0xd7, 0x81, 0x0d, 0xef, 0x43, 0x07, 0x1a, 0xe5, 0x17, 0x86,
379 0xed, 0xfb, 0xf2, 0xf3, 0xe3, 0x98, 0x79, 0x6f, 0xdf, 0x3d, 0xae, 0x0c,
380 0x7f, 0x2c, 0xf6, 0xa9, 0x05, 0xf6, 0xe9, 0xe3, 0xd1, 0x3e, 0x6f, 0x9f,
381 0x5b, 0x1b, 0xf0, 0x68, 0xa4, 0xc1, 0x66, 0x3f, 0x4a, 0x3c, 0x3a, 0xb4,
382 0xe6, 0xa3, 0xc7, 0x23, 0xee, 0x6b, 0xe3, 0xaa, 0x38, 0xe4, 0xee, 0xe3,
383 0x77, 0x45, 0x4f, 0x7f, 0x98, 0xf9, 0xde, 0xfb, 0x91, 0x4f, 0x10, 0x47,
384 0x28, 0x93, 0x36, 0x15, 0xc3, 0xba, 0xb6, 0x07, 0x5f, 0x5e, 0x0a, 0xc9,
385 0x1b, 0xf7, 0x84, 0xe5, 0x7f, 0x6f, 0xe3, 0xf7, 0x30, 0xd3, 0xab, 0x69,
386 0xb1, 0xfd, 0xc2, 0x1a, 0xd7, 0x0f, 0xbd, 0xd0, 0xee, 0xfa, 0x1d, 0xbe,
387 0xe3, 0xdb, 0xb3, 0x85, 0xe7, 0x7c, 0xb6, 0x91, 0x5f, 0x4c, 0xae, 0x21,
388 0x07, 0xdc, 0x64, 0x5d, 0xd0, 0x57, 0xcb, 0x01, 0x2f, 0x5f, 0x0f, 0xac,
389 0xe7, 0x80, 0xc4, 0xd9, 0x0e, 0xa5, 0x1b, 0xf9, 0x28, 0x73, 0x1f, 0xc3,
390 0xc3, 0x4e, 0xde, 0x23, 0xb7, 0x75, 0x90, 0xef, 0x42, 0xb6, 0xcf, 0x21,
391 0x5e, 0x7a, 0xd6, 0x41, 0x8e, 0xeb, 0x20, 0xb7, 0x75, 0x90, 0xdb, 0x3a,
392 0xc8, 0x6d, 0x9d, 0xa4, 0x97, 0x23, 0x8f, 0x78, 0x75, 0x7f, 0x7e, 0xe3,
393 0x66, 0x7d, 0xa1, 0x08, 0x5f, 0x32, 0xc5, 0x73, 0x13, 0x7a, 0x36, 0xb5,
394 0xc6, 0xdb, 0x9f, 0x5f, 0x13, 0xef, 0xf2, 0x6a, 0x36, 0xdf, 0x54, 0x75,
395 0x43, 0xd1, 0x1f, 0x68, 0x71, 0xbf, 0x83, 0xf3, 0x7c, 0xc7, 0xaf, 0x21,
396 0x2e, 0x51, 0x67, 0x88, 0x68, 0xa3, 0x55, 0x3d, 0xcd, 0x9a, 0x8c, 0xe8,
397 0x7a, 0xfa, 0x16, 0xbc, 0xb3, 0xc5, 0xcd, 0x09, 0xa2, 0x62, 0xe8, 0xe9,
398 0x56, 0xf2, 0x54, 0xd3, 0xd3, 0x6b, 0xbd, 0xb9, 0xf6, 0xb7, 0xb8, 0xb1,
399 0x55, 0x2f, 0xdb, 0xa6, 0xce, 0x38, 0x41, 0xc5, 0xda, 0x7e, 0xff, 0xc5,
400 0xf6, 0xe5, 0x6b, 0x85, 0x14, 0xbe, 0x67, 0x53, 0xf7, 0x62, 0x3e, 0xb6,
401 0xeb, 0xfc, 0xd6, 0x2f, 0xc9, 0xef, 0x90, 0xc7, 0x6f, 0x97, 0xc7, 0x06,
402 0xc7, 0xa9, 0xba, 0x30, 0x79, 0xed, 0xcf, 0xa7, 0xea, 0x7a, 0x58, 0x47,
403 0x9d, 0xcd, 0xc0, 0xf5, 0x07, 0xa6, 0xb4, 0x8d, 0xee, 0x0e, 0xd9, 0xc1,
404 0x75, 0xfd, 0x6f, 0xe2, 0x57, 0xb3, 0x66, 0x8f, 0xfa, 0x8e, 0xe6, 0xfa,
405 0x8c, 0x90, 0xd2, 0x41, 0x33, 0xcd, 0x7d, 0xfd, 0x50, 0x9d, 0xa9, 0xa1,
406 0xfe, 0xe5, 0x90, 0xc7, 0x4c, 0x0d, 0x6c, 0x8a, 0x9b, 0xfa, 0x48, 0x0b,
407 0xeb, 0xaf, 0x43, 0x15, 0x1f, 0xf7, 0xb8, 0x5e, 0xa3, 0x1f, 0x67, 0x5d,
408 0xcd, 0xc7, 0x33, 0xd9, 0xe0, 0xd6, 0xdb, 0x3e, 0x88, 0x2d, 0xb5, 0x34,
409 0xd8, 0x92, 0xbf, 0x4f, 0xee, 0x9f, 0xd7, 0xd5, 0xcf, 0x43, 0x2c, 0x56,
410 0x02, 0xdf, 0x47, 0x6a, 0xba, 0xc1, 0xb3, 0x2a, 0x9f, 0x85, 0x0e, 0xf2,
411 0xdb, 0xc0, 0x4e, 0xd8, 0x51, 0xb5, 0x3a, 0xc4, 0x1a, 0x73, 0xdf, 0x67,
412 0x54, 0x7e, 0xa9, 0xa7, 0xe7, 0x55, 0xfd, 0xc1, 0x5c, 0x51, 0x7f, 0x18,
413 0x82, 0xae, 0x20, 0x06, 0x70, 0xda, 0x54, 0x4c, 0xa7, 0xe2, 0x85, 0x4a,
414 0xe3, 0xf7, 0x97, 0xfb, 0x5b, 0x5d, 0x3e, 0xfc, 0x5d, 0x8b, 0xfb, 0x0d,
415 0xe2, 0x8f, 0xa2, 0xcb, 0xdb, 0x7c, 0xff, 0xaf, 0x5b, 0xfc, 0xb3, 0x3b,
416 0x85, 0x13, 0x43, 0xd0, 0x45, 0xe4, 0xe4, 0x6a, 0x3e, 0xc4, 0xbb, 0x4f,
417 0xcc, 0x76, 0x2c, 0x1f, 0x8f, 0xbe, 0x13, 0xfe, 0xf8, 0x8e, 0x86, 0xf1,
418 0x1d, 0x18, 0xff, 0x7b, 0x0d, 0xe3, 0x3b, 0x02, 0xe3, 0xa3, 0x0d, 0xe3,
419 0xa3, 0x18, 0xff, 0x7c, 0xc3, 0xf8, 0x68, 0x60, 0x7c, 0x67, 0xc3, 0xf8,
420 0x4e, 0x8c, 0x7f, 0xa1, 0x61, 0x3c, 0xfa, 0x4e, 0x34, 0x79, 0xdf, 0xc5,
421 0x88, 0xb1, 0xfb, 0xbd, 0x5c, 0x1c, 0xd7, 0x72, 0xe3, 0xb7, 0x16, 0xea,
422 0x5d, 0x17, 0x64, 0xe0, 0x9f, 0xa7, 0xa3, 0xbd, 0x66, 0x60, 0xaf, 0xf5,
423 0x58, 0xc6, 0xd5, 0xc7, 0xa0, 0x2e, 0x12, 0x1f, 0x8a, 0x62, 0xd8, 0xd0,
424 0x9d, 0x12, 0x74, 0xa8, 0xe4, 0xfb, 0x24, 0x9e, 0x83, 0xe2, 0x19, 0x53,
425 0xd7, 0xf7, 0x86, 0xec, 0x45, 0x2f, 0x07, 0x7b, 0x9b, 0xb4, 0x03, 0x2f,
426 0x7d, 0xcc, 0x94, 0x63, 0xae, 0xdd, 0x50, 0x7f, 0x39, 0xbf, 0x67, 0x3f,
427 0xd4, 0x55, 0x6f, 0x9d, 0xa1, 0x15, 0xb8, 0x16, 0x5f, 0x51, 0xdb, 0x32,
428 0xae, 0x02, 0xd7, 0x46, 0x6a, 0xb8, 0xf6, 0x59, 0x99, 0xaf, 0xe5, 0xdb,
429 0xc3, 0x72, 0xc0, 0xd9, 0xc5, 0x33, 0x36, 0xc7, 0x32, 0xf2, 0xe1, 0xe4,
430 0xdb, 0xbb, 0x6a, 0x7e, 0x92, 0x67, 0x3a, 0x96, 0x0e, 0x31, 0x87, 0xf2,
431 0x6b, 0xb3, 0x53, 0xce, 0xcf, 0xb6, 0x42, 0x2e, 0xb0, 0x8d, 0x6b, 0xcd,
432 0xb7, 0x39, 0x5f, 0x54, 0x0e, 0xb8, 0xe7, 0x1d, 0x6a, 0xf3, 0x16, 0x6b,
433 0xf3, 0xc6, 0x3c, 0x7b, 0xa3, 0x0f, 0xae, 0xfb, 0xcb, 0x1c, 0xfc, 0xe5,
434 0x18, 0x72, 0xee, 0x45, 0x67, 0xb5, 0xfa, 0xe8, 0xb5, 0xfa, 0xcb, 0xc6,
435 0x3a, 0x73, 0xa3, 0xbf, 0xe4, 0x3a, 0x8d, 0xb5, 0xe5, 0x78, 0x03, 0xfe,
436 0x53, 0x9f, 0x0e, 0x7b, 0x31, 0x35, 0xae, 0xa5, 0xc3, 0xb0, 0x47, 0x5d,
437 0xc6, 0x94, 0xfe, 0xb2, 0xed, 0xe7, 0x96, 0xbb, 0x6b, 0xb9, 0x65, 0x3d,
438 0x1f, 0x44, 0xec, 0x9a, 0xfc, 0xa4, 0x87, 0x8f, 0x8c, 0x91, 0xa7, 0xd0,
439 0x7f, 0x0c, 0x3a, 0xc0, 0x67, 0xac, 0x97, 0xde, 0x2c, 0x9f, 0x32, 0x5d,
440 0xff, 0xe4, 0xd6, 0xa6, 0x76, 0xab, 0xf8, 0x9f, 0xdf, 0x0b, 0x0a, 0xa9,
441 0x76, 0x2f, 0xde, 0xbb, 0x12, 0xae, 0x2e, 0xcf, 0x4d, 0x75, 0xfd, 0x51,
442 0xbc, 0xcb, 0xdc, 0xd4, 0x8c, 0x10, 0x43, 0xb3, 0x95, 0xcb, 0xbe, 0x5f,
443 0xa4, 0x7f, 0x29, 0xa8, 0xef, 0x82, 0x2a, 0x0f, 0xc5, 0xb8, 0x45, 0xef,
444 0x7d, 0x37, 0x0f, 0xcd, 0x56, 0xbe, 0xdd, 0xea, 0xe2, 0xe0, 0xe5, 0x72,
445 0x96, 0x9f, 0x88, 0xb0, 0xae, 0xb7, 0xe8, 0x5c, 0x89, 0xd6, 0x95, 0x79,
446 0xaf, 0xb1, 0x22, 0xef, 0x1d, 0xf5, 0xf2, 0xda, 0xcf, 0xa9, 0xbc, 0xd7,
447 0xe5, 0x31, 0xf7, 0x12, 0xcc, 0xa3, 0x6c, 0x60, 0x21, 0xbf, 0xa9, 0x10,
448 0x1f, 0x26, 0x94, 0xdf, 0xca, 0x4f, 0xdf, 0x09, 0x3e, 0x47, 0x57, 0xd1,
449 0x9b, 0x8f, 0xda, 0x4f, 0xf8, 0x7b, 0x3f, 0x2c, 0x6e, 0xbd, 0x6e, 0x27,
450 0x68, 0x61, 0x6e, 0x15, 0xf2, 0xf4, 0xe1, 0xbb, 0xde, 0x39, 0x53, 0x7f,
451 0x9c, 0x9f, 0xc7, 0xd7, 0xbe, 0xbb, 0x16, 0x33, 0xcb, 0xea, 0x27, 0x1b,
452 0x09, 0xc3, 0x90, 0x7b, 0xe6, 0x1a, 0xbe, 0x5b, 0x7c, 0x90, 0xf3, 0x11,
453 0x8d, 0x7e, 0x8d, 0xdf, 0x4d, 0xf9, 0xad, 0x54, 0xb4, 0xbb, 0x7b, 0x6d,
454 0xd8, 0x00, 0xcf, 0x2c, 0x07, 0xf1, 0x35, 0x2c, 0xf9, 0x39, 0x09, 0x47,
455 0xd3, 0xfc, 0x06, 0x40, 0xff, 0xff, 0xba, 0xb7, 0xcf, 0x98, 0xec, 0x9f,
456 0x71, 0x6b, 0x9e, 0xfa, 0x65, 0xcf, 0xc5, 0x1d, 0x00, 0x1f, 0x12, 0x47,
457 0xfd, 0x9a, 0xa7, 0xee, 0x9e, 0x8b, 0x3b, 0xfa, 0xe1, 0x9d, 0x8b, 0xe3,
458 0xfc, 0xa6, 0xec, 0x5a, 0xe5, 0x5c, 0x9c, 0x71, 0x95, 0xe7, 0xe2, 0xda,
459 0x55, 0xcd, 0x93, 0xf3, 0xb8, 0x35, 0x4f, 0xb6, 0xbb, 0xfb, 0x59, 0x2b,
460 0xe1, 0xd9, 0xb7, 0x01, 0x75, 0x06, 0xb9, 0xbb, 0xff, 0x47, 0x91, 0xa3,
461 0x7c, 0x3d, 0xf2, 0xd1, 0xe7, 0x28, 0xdc, 0xcb, 0xaf, 0xb8, 0xdf, 0x77,
462 0xe5, 0x5a, 0xea, 0x00, 0x1f, 0xac, 0xae, 0xb9, 0x5f, 0xd5, 0x35, 0xbf,
463 0x13, 0x09, 0xd6, 0x35, 0xf5, 0x2b, 0x9c, 0x0d, 0xdb, 0xbf, 0x4a, 0x5d,
464 0x33, 0x14, 0x38, 0x1b, 0x16, 0xf2, 0xce, 0x86, 0xb5, 0xdb, 0xc8, 0x25,
465 0xbd, 0x3a, 0xa6, 0x7e, 0xd9, 0xb3, 0x61, 0xff, 0x19, 0xf9, 0xe0, 0x75,
466 0xcc, 0x15, 0x67, 0xc3, 0xe0, 0xeb, 0x36, 0x48, 0xfc, 0x9a, 0xf2, 0x9e,
467 0x0f, 0x92, 0xf3, 0xf0, 0xbc, 0x7e, 0x13, 0xf6, 0x1c, 0x92, 0x5d, 0x51,
468 0xea, 0x27, 0xcf, 0x36, 0xf6, 0xc2, 0x16, 0x70, 0xad, 0xb0, 0x9d, 0xa4,
469 0x8c, 0xb4, 0x91, 0xde, 0xe5, 0xe7, 0x10, 0xea, 0xe7, 0x71, 0xc3, 0xb5,
470 0xf3, 0xb8, 0x47, 0xa0, 0x37, 0xfa, 0x4c, 0x58, 0x16, 0x02, 0x3a, 0x35,
471 0x85, 0x78, 0x4f, 0x9f, 0xb3, 0xbc, 0xe7, 0xfc, 0x9f, 0x8a, 0x28, 0x30,
472 0x8f, 0x67, 0x78, 0xdb, 0xc4, 0x98, 0x73, 0xbf, 0x59, 0xba, 0xff, 0x57,
473 0x12, 0xc3, 0x18, 0x9e, 0xf1, 0x0c, 0xc9, 0x01, 0x55, 0xb3, 0xf0, 0x75,
474 0x79, 0xc7, 0x5a, 0x69, 0x59, 0x9f, 0xa9, 0xb7, 0xa3, 0xab, 0xf8, 0x7d,
475 0xc4, 0x91, 0x33, 0xd4, 0xe7, 0x5b, 0x25, 0xe7, 0xd5, 0x83, 0x0a, 0x95,
476 0x6d, 0x5e, 0x7e, 0xa1, 0xbe, 0xed, 0x80, 0x97, 0xdd, 0x9e, 0x0f, 0xc6,
477 0xb5, 0xd4, 0x4d, 0x9f, 0x87, 0x35, 0x4e, 0xca, 0xd0, 0xf4, 0x96, 0xd8,
478 0x38, 0xf0, 0x6e, 0x4c, 0xad, 0x79, 0x2d, 0x3c, 0xd7, 0x2e, 0xf1, 0xbd,
479 0xf1, 0x6a, 0xf9, 0xee, 0xc7, 0xc7, 0x8f, 0x62, 0x7f, 0xdd, 0xd0, 0x8f,
480 0x87, 0x25, 0x77, 0xe2, 0x66, 0x19, 0x9a, 0x4d, 0x80, 0x9e, 0x1f, 0x56,
481 0x0b, 0x29, 0xc4, 0xd2, 0x4f, 0xf0, 0xdc, 0x18, 0x30, 0x14, 0x7c, 0x7b,
482 0x66, 0xc5, 0x77, 0xec, 0xe0, 0x59, 0xb3, 0x64, 0xed, 0xec, 0xd0, 0x53,
483 0x15, 0x09, 0x77, 0x90, 0xe6, 0x99, 0xfa, 0xd9, 0xef, 0xc5, 0xca, 0x0e,
484 0xe5, 0xdb, 0x9e, 0xac, 0x2c, 0xab, 0xfd, 0x28, 0x19, 0x4e, 0x94, 0x9f,
485 0x04, 0x2f, 0x5e, 0x51, 0xfe, 0xed, 0x88, 0x23, 0x37, 0x19, 0x42, 0x79,
486 0x88, 0x06, 0x1e, 0xa8, 0x33, 0x1c, 0xee, 0xf7, 0xfd, 0x2e, 0x25, 0x57,
487 0x17, 0x2b, 0x76, 0x06, 0xce, 0x60, 0xd4, 0x65, 0xeb, 0x9e, 0xcd, 0x70,
488 0x65, 0xe1, 0x9e, 0x1f, 0x21, 0x3f, 0x97, 0x0e, 0xed, 0xb2, 0xdd, 0xf3,
489 0x23, 0x3d, 0x73, 0xec, 0xeb, 0x6c, 0xf0, 0x7d, 0x61, 0xe8, 0x00, 0xcf,
490 0x1d, 0xf1, 0xcc, 0x37, 0x69, 0x56, 0xb5, 0x8e, 0x55, 0xbf, 0x6d, 0x5f,
491 0x5b, 0xcd, 0xd5, 0x5d, 0xb3, 0x5b, 0xad, 0x79, 0x9d, 0x87, 0x59, 0xfe,
492 0x59, 0xef, 0x94, 0xf6, 0xff, 0xd4, 0x5d, 0x7b, 0x6c, 0x1b, 0xf7, 0x7d,
493 0xff, 0xf2, 0x48, 0x3d, 0xac, 0xe7, 0x49, 0xa6, 0x64, 0x5a, 0x52, 0x94,
494 0x3b, 0xe9, 0x64, 0x29, 0xb1, 0x12, 0x70, 0x9e, 0xba, 0x0a, 0x88, 0x9a,
495 0xb0, 0x24, 0xfd, 0x58, 0x10, 0x0c, 0xb4, 0xad, 0x64, 0xee, 0x92, 0xad,
496 0x0e, 0x25, 0xa7, 0x1d, 0x30, 0x60, 0x6e, 0xd6, 0x02, 0x69, 0x07, 0xc7,
497 0x0c, 0x65, 0x27, 0xc6, 0xaa, 0x88, 0x4c, 0xcc, 0x6a, 0x1d, 0xb0, 0x62,
498 0x1c, 0xa5, 0x38, 0x69, 0xa7, 0x80, 0x69, 0xda, 0x04, 0xc5, 0xfe, 0xb1,
499 0x26, 0x3b, 0x7b, 0x61, 0x7f, 0x04, 0xdb, 0x80, 0x1a, 0x5b, 0x81, 0xba,
500 0x76, 0x8a, 0x65, 0x1b, 0xe0, 0x34, 0xdb, 0xb0, 0x75, 0x58, 0x0b, 0xee,
501 0xfb, 0xf9, 0x3d, 0xc8, 0x23, 0x79, 0xd4, 0xc3, 0x71, 0x06, 0x4c, 0x80,
502 0x40, 0xde, 0xf1, 0x77, 0x77, 0xbf, 0xdf, 0xf7, 0xf7, 0x7d, 0xbf, 0x6e,
503 0x2e, 0x33, 0x1e, 0xf2, 0x33, 0x7e, 0xcf, 0x15, 0x61, 0x5f, 0x37, 0xd2,
504 0xe1, 0x36, 0x83, 0x67, 0xa4, 0x0e, 0x9e, 0xd5, 0x34, 0xc1, 0xf6, 0x78,
505 0x99, 0x77, 0x4b, 0xd8, 0xc9, 0xf3, 0xc8, 0x63, 0xd7, 0x39, 0x0e, 0x12,
506 0x76, 0x65, 0x1a, 0x5a, 0x72, 0xe7, 0x37, 0x54, 0x60, 0x77, 0xb2, 0x0c,
507 0xbb, 0x3d, 0xff, 0x8f, 0x60, 0x77, 0x4d, 0xe8, 0xbf, 0xdf, 0x2e, 0x22,
508 0x6f, 0x4d, 0xeb, 0x00, 0xba, 0x6e, 0x09, 0x70, 0x04, 0x3f, 0xb5, 0xf3,
509 0xeb, 0x04, 0x9e, 0x8a, 0xbc, 0xe2, 0x52, 0xe9, 0x3b, 0xe1, 0xb2, 0x9f,
510 0x92, 0xed, 0x12, 0xd8, 0x27, 0xf0, 0xe7, 0x35, 0x96, 0x91, 0x47, 0x6f,
511 0x4b, 0x46, 0x42, 0x57, 0xaa, 0xb5, 0x4f, 0x7e, 0xbb, 0xcb, 0x6d, 0x9f,
512 0x1c, 0xdd, 0xa1, 0x7d, 0x72, 0x5a, 0xda, 0x27, 0xa9, 0xed, 0xdb, 0x27,
513 0x03, 0x75, 0x79, 0x5d, 0x95, 0xf5, 0xec, 0xdc, 0x3e, 0x31, 0x36, 0xb5,
514 0x4f, 0x46, 0x5d, 0xbe, 0x18, 0xcc, 0xf7, 0x57, 0x29, 0x75, 0x0c, 0x3c,
515 0x4e, 0xc3, 0x19, 0x30, 0x3e, 0x56, 0xe3, 0x17, 0xfe, 0x38, 0x61, 0xfd,
516 0xd7, 0xff, 0xc7, 0xb0, 0x1e, 0xac, 0xf3, 0x79, 0x57, 0xd6, 0x03, 0x21,
517 0xfe, 0x51, 0x60, 0x3d, 0xd8, 0xd0, 0x77, 0xda, 0x38, 0x67, 0xb1, 0xda,
518 0x77, 0x3a, 0x62, 0x34, 0xe2, 0xed, 0x7f, 0xe4, 0xf2, 0xa9, 0xba, 0xf9,
519 0x3b, 0x68, 0x8a, 0x7c, 0x47, 0xc7, 0xf5, 0xb3, 0x40, 0x4b, 0x76, 0x2a,
520 0x45, 0xb0, 0x99, 0xf0, 0xbc, 0x90, 0xa0, 0xb5, 0x1a, 0x7d, 0x8b, 0x9f,
521 0xc7, 0xeb, 0x7b, 0xf5, 0x09, 0x21, 0xa7, 0xa4, 0xff, 0x01, 0xe3, 0x27,
522 0x7c, 0xf3, 0x62, 0xac, 0xcc, 0x6f, 0x52, 0xfe, 0x08, 0xa5, 0xfb, 0x37,
523 0xf2, 0x43, 0xd4, 0xcb, 0xbc, 0x9d, 0xd9, 0x0a, 0x9a, 0xc6, 0xef, 0xe6,
524 0x7d, 0x09, 0x55, 0xd9, 0x5a, 0xe0, 0x9f, 0xa7, 0x59, 0x2f, 0x18, 0x29,
525 0xeb, 0x04, 0xd5, 0x7b, 0x73, 0x4e, 0xd8, 0x74, 0x9a, 0x77, 0x26, 0x64,
526 0xee, 0xa9, 0x38, 0x0f, 0x3d, 0x4d, 0xf3, 0xce, 0x5a, 0x3d, 0xf8, 0x6e,
527 0x0f, 0xbc, 0xf0, 0xca, 0x69, 0x2a, 0xef, 0x9d, 0x85, 0x9c, 0xf3, 0xb8,
528 0xe7, 0xde, 0x95, 0x6b, 0xc2, 0x52, 0x95, 0xb1, 0xf2, 0xfa, 0xb8, 0x58,
529 0xd7, 0x0f, 0x8e, 0x44, 0x51, 0xfb, 0x56, 0xae, 0x17, 0xab, 0xad, 0x77,
530 0x82, 0x1c, 0xd0, 0x74, 0xa8, 0x6b, 0xa2, 0x01, 0x8b, 0x61, 0x8f, 0x7a,
531 0x27, 0xb7, 0x2c, 0xc1, 0x75, 0xb5, 0xb0, 0xa8, 0xc8, 0x91, 0xf3, 0x4a,
532 0x8e, 0x14, 0x5c, 0x7c, 0xbc, 0x5e, 0x6f, 0xef, 0xf5, 0xd0, 0xdb, 0xbd,
533 0x6a, 0x9e, 0x30, 0xa7, 0x67, 0x58, 0x0f, 0xb9, 0x1f, 0x7a, 0x88, 0x89,
534 0xba, 0x25, 0xa9, 0x8b, 0xe0, 0x77, 0x96, 0x35, 0xaf, 0x86, 0x18, 0x57,
535 0x8e, 0xd0, 0x53, 0xac, 0x6b, 0x5f, 0xa2, 0x7b, 0x94, 0x7d, 0x16, 0x71,
536 0xe5, 0x99, 0x22, 0x8f, 0xdf, 0x47, 0xa9, 0x27, 0xec, 0x89, 0x08, 0x1d,
537 0xa1, 0x53, 0x22, 0x67, 0x06, 0xf1, 0x3d, 0xe4, 0x1c, 0xdc, 0x2b, 0x9e,
538 0x2f, 0x7d, 0x19, 0x77, 0x22, 0xa7, 0x6e, 0xfb, 0xf9, 0xfb, 0xba, 0x56,
539 0x2f, 0x2a, 0x9e, 0xb9, 0xaa, 0x68, 0x4a, 0x9c, 0xe3, 0xeb, 0x9f, 0x31,
540 0xea, 0xaf, 0x8f, 0x18, 0xf1, 0x62, 0xdc, 0x88, 0xae, 0x60, 0xdc, 0x33,
541 0x46, 0xac, 0x08, 0x1b, 0x52, 0xe3, 0x88, 0x1d, 0x06, 0xbd, 0x6d, 0xd0,
542 0xd6, 0xb1, 0x88, 0x02, 0xd5, 0xd4, 0x49, 0x6c, 0x63, 0xde, 0x87, 0xaa,
543 0xe6, 0xad, 0xe1, 0x8b, 0xef, 0xf0, 0xf7, 0x44, 0x18, 0xa6, 0x5a, 0xaf,
544 0x6d, 0x83, 0x7f, 0x7d, 0x22, 0x45, 0x9b, 0xe9, 0xb5, 0x76, 0x9d, 0x5e,
545 0x5b, 0xd8, 0x72, 0xde, 0x1f, 0x95, 0xc6, 0x65, 0x3d, 0xa2, 0xdf, 0x11,
546 0xfa, 0x2b, 0xcf, 0xbb, 0x4a, 0xb7, 0xad, 0xc1, 0x29, 0x8c, 0xd1, 0x7e,
547 0x70, 0xed, 0x07, 0xeb, 0x52, 0xf9, 0xc0, 0x3a, 0x3f, 0xa1, 0x0d, 0xf5,
548 0x5e, 0xa6, 0xcc, 0x6b, 0x85, 0x8d, 0xb5, 0xce, 0xf3, 0x83, 0xbd, 0xf5,
549 0xa0, 0x98, 0x23, 0xdb, 0x5b, 0x56, 0x8c, 0xa4, 0xaf, 0x7b, 0xbe, 0x58,
550 0x55, 0xff, 0xe9, 0x51, 0x07, 0x39, 0xe2, 0x51, 0x07, 0xe9, 0xa6, 0xb5,
551 0x80, 0x8b, 0xd6, 0x42, 0x2e, 0xbd, 0x6d, 0x88, 0xed, 0x96, 0x0e, 0xe6,
552 0x21, 0xb0, 0x5b, 0xda, 0xc8, 0xff, 0xb2, 0xdb, 0x6e, 0xa9, 0xad, 0x45,
553 0x07, 0xdd, 0x41, 0x37, 0x93, 0x36, 0x4c, 0x3c, 0x57, 0xae, 0x63, 0xe7,
554 0x75, 0x57, 0x6a, 0x0e, 0x57, 0xea, 0xea, 0x23, 0xbd, 0xe6, 0x3b, 0x5c,
555 0x37, 0x5f, 0xc8, 0xaf, 0x48, 0x43, 0x9d, 0xce, 0xcb, 0xae, 0xba, 0x53,
556 0xf3, 0xab, 0xe5, 0x67, 0x78, 0xd6, 0x88, 0xf0, 0x79, 0xa7, 0xca, 0xbc,
557 0x6c, 0x5a, 0xce, 0x37, 0x53, 0x6d, 0x67, 0xf8, 0x97, 0x48, 0xc1, 0xce,
558 0x9b, 0xb7, 0xef, 0xcc, 0x7f, 0xd6, 0x5e, 0x23, 0x77, 0xdf, 0x33, 0xa5,
559 0x5f, 0xac, 0x49, 0xe5, 0x61, 0xf7, 0x29, 0x7b, 0x6f, 0x2b, 0x7c, 0xc7,
560 0xb9, 0x26, 0xe5, 0x4b, 0xb4, 0xad, 0x3c, 0x01, 0xcf, 0x8f, 0x9d, 0x68,
561 0x72, 0x4c, 0x15, 0xcb, 0x42, 0xbc, 0x0a, 0x78, 0xaf, 0xef, 0x0f, 0x9e,
562 0xbd, 0x9d, 0x3d, 0xb3, 0xea, 0xf6, 0x4c, 0xe2, 0x15, 0x6c, 0x2d, 0xe4,
563 0x17, 0x4f, 0xd6, 0xe4, 0x78, 0x7f, 0x14, 0x58, 0x74, 0x79, 0xe4, 0x3d,
564 0x23, 0x6f, 0xb9, 0xd1, 0x3c, 0xaf, 0xbb, 0xf4, 0x72, 0xcc, 0xb7, 0x54,
565 0x7a, 0x23, 0x3c, 0x20, 0x65, 0x71, 0xd1, 0x5b, 0x47, 0x32, 0xb7, 0x3d,
566 0xbf, 0x5a, 0xd9, 0xbb, 0x77, 0x9b, 0xb2, 0x57, 0xf4, 0xf4, 0xf0, 0x1d,
567 0x14, 0x3c, 0xa0, 0x83, 0x56, 0x72, 0xc8, 0xbf, 0xfe, 0x05, 0xd0, 0x3c,
568 0xf3, 0x59, 0x57, 0x4d, 0x9a, 0xf7, 0x3e, 0x96, 0x63, 0x2a, 0x81, 0x19,
569 0xc4, 0xfe, 0x90, 0x5b, 0xd2, 0xcb, 0xbc, 0x07, 0xe3, 0xc7, 0xac, 0xab,
570 0xf0, 0xf7, 0x2a, 0xff, 0x53, 0x5c, 0xc9, 0x97, 0x83, 0xdb, 0x88, 0xad,
571 0xec, 0x8c, 0x4f, 0xdb, 0xd6, 0x3a, 0x21, 0xee, 0x83, 0x7c, 0xe1, 0xfb,
572 0xba, 0xa8, 0xeb, 0x33, 0x2d, 0x2d, 0xce, 0x97, 0x7a, 0x64, 0x2c, 0x0a,
573 0xbf, 0x75, 0xd0, 0x2b, 0x39, 0xe4, 0x72, 0xe3, 0xb7, 0xdf, 0xe0, 0xdf,
574 0xbc, 0x78, 0x94, 0xce, 0x45, 0x87, 0x2e, 0x27, 0xf7, 0x27, 0x4f, 0xb0,
575 0x95, 0x4a, 0xf4, 0xb7, 0xe1, 0x5f, 0x94, 0xf1, 0x8c, 0xe2, 0x9d, 0x8e,
576 0xd5, 0x78, 0xf9, 0x0b, 0xdf, 0xec, 0xb9, 0xdd, 0xdc, 0xc8, 0x2f, 0x6c,
577 0xcb, 0x5f, 0x88, 0x38, 0xff, 0x76, 0x62, 0x26, 0x3a, 0x36, 0x3c, 0x25,
578 0x6a, 0x4e, 0xdd, 0x78, 0x70, 0x67, 0xe2, 0xc3, 0xc0, 0x87, 0xe1, 0x3a,
579 0x5e, 0xf5, 0xd1, 0xfd, 0xfd, 0xb5, 0x70, 0x6d, 0xf3, 0xf4, 0x55, 0x79,
580 0xc7, 0x81, 0x11, 0xf3, 0x87, 0x9f, 0xfa, 0x21, 0x9a, 0xbf, 0x08, 0x1c,
581 0x36, 0x18, 0xdb, 0x46, 0x69, 0x21, 0x88, 0xba, 0x22, 0x51, 0x9b, 0xa3,
582 0xe2, 0x86, 0xb2, 0x56, 0x68, 0x5e, 0xd4, 0x40, 0x8e, 0x85, 0x6e, 0xf2,
583 0xbc, 0xe7, 0x8b, 0x29, 0x3a, 0xc5, 0x32, 0xf6, 0xd4, 0x4a, 0x45, 0x77,
584 0xaf, 0xaf, 0x83, 0xac, 0xc6, 0xf1, 0x9b, 0x02, 0xc7, 0x87, 0x36, 0xc5,
585 0xf1, 0xc3, 0x65, 0x1c, 0xff, 0x44, 0xaf, 0xc4, 0xe7, 0x67, 0xf9, 0x5e,
586 0x5d, 0x74, 0x50, 0xdc, 0x37, 0xc5, 0xdf, 0xdb, 0xe9, 0xa0, 0xec, 0x61,
587 0xc1, 0xcf, 0x66, 0x1e, 0x9f, 0x49, 0xd1, 0x53, 0x17, 0x53, 0xbe, 0xb8,
588 0xa8, 0x5f, 0x70, 0xf7, 0xe8, 0xd0, 0xd7, 0x63, 0x5c, 0x23, 0xfc, 0xd7,
589 0x7c, 0x49, 0xd6, 0x5c, 0xe5, 0x25, 0x7f, 0xa2, 0x77, 0xc3, 0x83, 0x35,
590 0xf8, 0x5f, 0x6d, 0x3b, 0x9e, 0x56, 0x32, 0xf0, 0xd8, 0x26, 0x7e, 0x8d,
591 0x7a, 0xbc, 0xec, 0xf1, 0xd0, 0x87, 0x7f, 0xbd, 0x57, 0xc6, 0xa9, 0x36,
592 0xf3, 0x6b, 0xb8, 0x71, 0xb4, 0x2a, 0x6e, 0xcf, 0x7c, 0xff, 0xbf, 0x55,
593 0x1c, 0xfd, 0xa5, 0x5e, 0x29, 0x2f, 0x50, 0x1f, 0x98, 0x60, 0x38, 0x9c,
594 0x64, 0x5d, 0x65, 0x90, 0x9a, 0x5f, 0xd6, 0x6b, 0x1d, 0x14, 0xfc, 0xd6,
595 0xed, 0xa7, 0x39, 0xa7, 0x6a, 0xbb, 0xd3, 0xae, 0x35, 0x9d, 0x13, 0x36,
596 0x4e, 0x63, 0x7a, 0x6b, 0x9c, 0x73, 0x35, 0x54, 0x23, 0x13, 0x6a, 0xf1,
597 0x0d, 0xbd, 0x4f, 0xb0, 0xbf, 0x64, 0x48, 0x3d, 0x78, 0x9a, 0xf5, 0xdb,
598 0x9d, 0xc6, 0x8b, 0x3e, 0xaa, 0x8e, 0x58, 0xdb, 0x53, 0xa3, 0xf6, 0x3b,
599 0xf6, 0x41, 0xda, 0x1c, 0xc9, 0x57, 0x1f, 0x12, 0xbc, 0xe0, 0xdc, 0x64,
600 0x89, 0x62, 0xe1, 0x4e, 0x4a, 0x4e, 0xf2, 0xb3, 0xa7, 0x1d, 0xb6, 0xbd,
601 0xfc, 0x94, 0x62, 0xfa, 0x4d, 0x4e, 0xee, 0x52, 0xfa, 0xa2, 0xf6, 0xa7,
602 0xb7, 0xa8, 0x3c, 0x87, 0x67, 0x45, 0x5c, 0x52, 0xf6, 0xc6, 0xe0, 0xef,
603 0x2b, 0xfa, 0xde, 0xcf, 0x8a, 0xf8, 0x68, 0xf2, 0x62, 0xb3, 0x1a, 0xd7,
604 0xee, 0x1a, 0x87, 0x31, 0xed, 0x6a, 0x2c, 0xee, 0xa9, 0x75, 0x8a, 0x56,
605 0xc5, 0x6f, 0x1f, 0x11, 0x75, 0x60, 0xb2, 0x56, 0x0f, 0xbf, 0x9f, 0xa6,
606 0xb9, 0xf2, 0x5a, 0xda, 0x79, 0xec, 0xcf, 0x4a, 0x11, 0x61, 0xcb, 0xb5,
607 0xb3, 0xce, 0x8b, 0x79, 0xd7, 0xcf, 0x09, 0x6b, 0xf1, 0x8b, 0xf8, 0x10,
608 0x7f, 0x57, 0xcf, 0x39, 0x59, 0x9e, 0x13, 0x72, 0x34, 0xec, 0x90, 0xbc,
609 0x97, 0x1e, 0xd7, 0xee, 0x1a, 0xa7, 0x79, 0x85, 0x8e, 0x3f, 0xfc, 0x80,
610 0xe7, 0xf1, 0x37, 0x2a, 0x87, 0xd7, 0x14, 0xf1, 0x53, 0x99, 0xa3, 0xa1,
611 0xbf, 0xc3, 0xbf, 0x8c, 0x9c, 0x0a, 0xe4, 0x49, 0xb8, 0xf9, 0x8d, 0x5c,
612 0x6f, 0x00, 0xb2, 0xa8, 0x88, 0xb8, 0x29, 0xe2, 0x15, 0x8d, 0x74, 0xe7,
613 0xbd, 0xc8, 0xcd, 0xdf, 0x81, 0x0e, 0xba, 0x1d, 0xfa, 0xb3, 0x3c, 0xe8,
614 0xcf, 0xfd, 0x7c, 0xd4, 0xc1, 0xa1, 0x1e, 0x2e, 0x35, 0x61, 0x50, 0x89,
615 0x6d, 0x05, 0x83, 0xf2, 0xa6, 0x8f, 0x9e, 0x72, 0xec, 0xf0, 0x0a, 0xc9,
616 0x9a, 0xc9, 0xd8, 0xa2, 0x3d, 0xb1, 0x4e, 0xfb, 0x45, 0xcd, 0x38, 0x7a,
617 0x1f, 0xe4, 0x59, 0x06, 0x9f, 0xa4, 0x09, 0xb6, 0x8f, 0xd8, 0xfe, 0x9c,
618 0x45, 0xbc, 0x45, 0xef, 0x0b, 0x6a, 0xe0, 0xf1, 0x39, 0xc1, 0x70, 0x7a,
619 0x6c, 0x37, 0xb5, 0x45, 0xf8, 0x9e, 0x13, 0xe0, 0x4f, 0xe8, 0xe7, 0x45,
620 0x51, 0xb6, 0x93, 0x60, 0xb3, 0x9e, 0x9c, 0xb5, 0xcd, 0x3c, 0x19, 0x3c,
621 0x16, 0xb6, 0x2b, 0xee, 0x83, 0xeb, 0x23, 0x66, 0x13, 0xd5, 0xd6, 0xe4,
622 0x3e, 0x2b, 0xea, 0x14, 0xdf, 0x0d, 0xdf, 0x47, 0x46, 0x3f, 0xf8, 0x15,
623 0xf6, 0xed, 0x5e, 0x15, 0x27, 0x3a, 0xcb, 0xdf, 0xc7, 0xd5, 0xf7, 0xaf,
624 0x88, 0xfd, 0x94, 0xdf, 0x35, 0x7e, 0xe3, 0xef, 0x5f, 0x5a, 0xc8, 0xf9,
625 0xa1, 0xca, 0x59, 0xa9, 0xca, 0x05, 0x09, 0x8d, 0x1a, 0x5f, 0xa1, 0xd3,
626 0x2b, 0x9b, 0xf9, 0x5f, 0xbc, 0x6a, 0x5d, 0xbb, 0xb7, 0x59, 0xeb, 0xfa,
627 0x07, 0xbb, 0x65, 0x6d, 0x99, 0x7b, 0x2e, 0xff, 0xc9, 0x73, 0xf1, 0xd2,
628 0xc9, 0xea, 0xf4, 0x44, 0x5e, 0x6f, 0x89, 0xfe, 0x29, 0xfc, 0x49, 0xba,
629 0x1e, 0x0c, 0xa9, 0x9c, 0x25, 0xe4, 0x28, 0xdd, 0xa7, 0xf0, 0x5a, 0xf3,
630 0x7e, 0xf2, 0xe0, 0xfd, 0x8f, 0x89, 0x5c, 0x4d, 0x29, 0x3b, 0x06, 0x15,
631 0x3c, 0x00, 0xb3, 0x90, 0x0b, 0x66, 0x7d, 0x2e, 0x98, 0x19, 0xea, 0x7b,
632 0xa7, 0x38, 0x3e, 0xbd, 0xf2, 0x99, 0x6e, 0x59, 0x2f, 0x8e, 0x58, 0xe2,
633 0xbc, 0xfa, 0xbe, 0xd5, 0x7a, 0x7f, 0xce, 0x6b, 0x15, 0xfe, 0x26, 0xd7,
634 0x5a, 0x5f, 0x27, 0x72, 0x5a, 0x82, 0xf5, 0x30, 0xf8, 0x8e, 0xeb, 0x3c,
635 0xe6, 0x38, 0xe6, 0x9a, 0xe3, 0x88, 0x6b, 0x8e, 0x77, 0x37, 0x98, 0x23,
636 0xf3, 0xf8, 0xe2, 0x69, 0xfe, 0xbf, 0xdd, 0xb9, 0xca, 0x79, 0xce, 0x0b,
637 0x78, 0xb6, 0x53, 0x3a, 0x18, 0x52, 0xb2, 0xe3, 0xfb, 0xaa, 0x16, 0xdd,
638 0x6b, 0xce, 0xff, 0x40, 0x8d, 0xf7, 0xcd, 0x8d, 0xab, 0xee, 0xfa, 0xe3,
639 0x97, 0x28, 0x26, 0xeb, 0xc8, 0x15, 0x6d, 0x7f, 0xb5, 0x81, 0x1f, 0xfa,
640 0x41, 0xa1, 0xff, 0xcc, 0xcb, 0x78, 0xd0, 0x80, 0xec, 0xbf, 0x16, 0xa0,
641 0xd5, 0x72, 0x2d, 0xaf, 0x5f, 0xd5, 0xee, 0xdc, 0x1f, 0xbc, 0xb3, 0x75,
642 0xbc, 0x38, 0xff, 0x88, 0xf0, 0xe5, 0xc9, 0xf8, 0x51, 0x42, 0xd5, 0x23,
643 0xdb, 0x16, 0x72, 0x03, 0x0a, 0x6b, 0xf0, 0xbf, 0x36, 0xaa, 0xdd, 0xc5,
644 0xb5, 0xf0, 0x03, 0x6a, 0x3b, 0xfe, 0x84, 0xe0, 0x89, 0xd2, 0x3f, 0x26,
645 0xeb, 0x6f, 0x0b, 0x6b, 0x27, 0x45, 0xcd, 0x6b, 0x54, 0xd5, 0xf1, 0x26,
646 0xa9, 0x43, 0xe8, 0xb9, 0xb7, 0x5f, 0x7f, 0xfb, 0x5c, 0x70, 0xe7, 0xf5,
647 0xb7, 0xee, 0x6b, 0x76, 0x56, 0x7f, 0x6b, 0xf2, 0xda, 0x8d, 0x65, 0x59,
648 0x7f, 0x5b, 0x1d, 0x93, 0x91, 0xfe, 0xc0, 0xa4, 0x4b, 0x7f, 0x90, 0xfa,
649 0xfa, 0x6f, 0xb9, 0xf2, 0xb7, 0x65, 0x6d, 0x6d, 0xa1, 0xac, 0xb3, 0xca,
650 0xda, 0x5a, 0x99, 0xef, 0xed, 0xee, 0x03, 0x23, 0x63, 0x3f, 0xf2, 0x39,
651 0x9d, 0x35, 0xb1, 0x1f, 0x59, 0x53, 0x6b, 0x19, 0x8d, 0x6c, 0x38, 0xd1,
652 0xe7, 0xa2, 0x8f, 0xba, 0x22, 0x8c, 0xbb, 0xed, 0x0d, 0xfa, 0x21, 0x44,
653 0x1a, 0xf4, 0x43, 0x70, 0xf3, 0x7e, 0xb7, 0x8e, 0x05, 0x9d, 0x18, 0xb2,
654 0x11, 0xba, 0x30, 0xfa, 0x19, 0x84, 0xe9, 0x74, 0x59, 0xf7, 0xbc, 0x8f,
655 0x12, 0x4a, 0xf7, 0x3c, 0xbd, 0xa2, 0xf9, 0xd1, 0x48, 0x0d, 0x3f, 0xf2,
656 0xd2, 0x45, 0x6d, 0x95, 0xe7, 0xa3, 0xe9, 0x35, 0xe5, 0xa2, 0xd7, 0x94,
657 0x07, 0xbd, 0x8a, 0x67, 0x34, 0x98, 0xf7, 0xf7, 0xd5, 0x35, 0xf8, 0x4f,
658 0x84, 0xd0, 0xb3, 0x85, 0x79, 0x6a, 0x50, 0xe9, 0x7f, 0x2e, 0x7a, 0x3d,
659 0xc5, 0xf4, 0xaa, 0xcf, 0x63, 0xbe, 0x0d, 0x73, 0x41, 0x95, 0xce, 0x38,
660 0xe8, 0x3b, 0x74, 0xf1, 0x1b, 0x22, 0x4f, 0xaa, 0xda, 0x5e, 0xd4, 0xfa,
661 0xc4, 0x3e, 0x41, 0x4b, 0xd7, 0xfd, 0xc8, 0x5b, 0xd1, 0xe7, 0x4c, 0xe5,
662 0x27, 0xd3, 0xb0, 0x68, 0xae, 0xd2, 0x39, 0x2a, 0xfa, 0x86, 0xc8, 0xf1,
663 0x75, 0xcd, 0xed, 0x43, 0x9e, 0x9b, 0x3e, 0xaf, 0x65, 0xe6, 0xb5, 0x2a,
664 0x7f, 0xc6, 0xe5, 0xaa, 0x9e, 0x83, 0xf0, 0x1d, 0x75, 0x26, 0x0c, 0x27,
665 0x2e, 0x72, 0x4c, 0x7b, 0x1c, 0xf8, 0xc9, 0xa2, 0x4c, 0xfb, 0x3d, 0x09,
666 0xe4, 0x33, 0xf7, 0x2c, 0x59, 0x74, 0x3c, 0x73, 0xff, 0x5d, 0x12, 0x57,
667 0xce, 0x8a, 0x3e, 0x92, 0xe8, 0x67, 0x16, 0x63, 0xf9, 0x1c, 0xf5, 0x4f,
668 0xd3, 0xf9, 0x62, 0x0b, 0x15, 0x58, 0xbb, 0xf7, 0x3b, 0x79, 0xe1, 0xeb,
669 0x63, 0x9e, 0x94, 0x45, 0x2f, 0x51, 0x63, 0xb9, 0x99, 0xef, 0xdb, 0x4f,
670 0xab, 0xb9, 0x31, 0xd1, 0x13, 0x4a, 0xf6, 0x17, 0xc1, 0x58, 0x1f, 0xf5,
671 0x3a, 0x07, 0xfb, 0xa8, 0xed, 0xb3, 0x22, 0xc7, 0xb2, 0x90, 0x3d, 0x2b,
672 0x3f, 0xf3, 0x0f, 0xa8, 0x67, 0xf0, 0xf3, 0x8a, 0x7f, 0x4a, 0x91, 0x5e,
673 0xcb, 0x65, 0xcb, 0xb9, 0xff, 0xbc, 0xf5, 0x95, 0xa3, 0x3b, 0xd2, 0x57,
674 0x52, 0x89, 0x8a, 0xbe, 0xe2, 0xbe, 0x77, 0x39, 0x07, 0xa6, 0x5f, 0xf6,
675 0x7b, 0x00, 0x0c, 0xda, 0xa1, 0x8b, 0x25, 0x00, 0x4b, 0x63, 0xc6, 0x0e,
676 0x45, 0xfd, 0x53, 0xb4, 0x50, 0x1c, 0x32, 0x92, 0x59, 0xe8, 0xcc, 0xfc,
677 0x99, 0x8f, 0xee, 0x91, 0x3e, 0x1a, 0x7d, 0x0d, 0xf8, 0xca, 0x6e, 0x1e,
678 0xff, 0x7a, 0xbf, 0xcc, 0xcb, 0x76, 0x9f, 0xef, 0xe2, 0xf3, 0x7b, 0x42,
679 0xd5, 0xe7, 0x77, 0xf1, 0xf9, 0xde, 0x04, 0xf6, 0xd0, 0x58, 0x82, 0x5f,
680 0xd2, 0xa1, 0x34, 0xef, 0xcd, 0x42, 0x91, 0x65, 0xeb, 0xcb, 0xcc, 0x47,
681 0x57, 0xf4, 0xb8, 0x3e, 0xd4, 0xec, 0x88, 0x3d, 0x31, 0x78, 0xcc, 0xb9,
682 0xcc, 0x04, 0x8f, 0x1b, 0x24, 0xff, 0xcb, 0x6c, 0x8b, 0xae, 0x68, 0x5c,
683 0xd5, 0xf9, 0xf6, 0xdf, 0xe8, 0x93, 0x39, 0x55, 0xdf, 0xdd, 0x23, 0xe1,
684 0xe7, 0x08, 0x9e, 0x72, 0x9e, 0xe1, 0xf2, 0xbc, 0xc0, 0x43, 0x7b, 0xda,
685 0x2a, 0x3f, 0xbf, 0x13, 0x78, 0xd5, 0x8a, 0xbc, 0xd9, 0xc0, 0x12, 0xf3,
686 0xc5, 0x19, 0xc7, 0x4c, 0x97, 0x73, 0xd5, 0x1e, 0x1f, 0x90, 0xd7, 0xbf,
687 0xd9, 0x27, 0xfb, 0x83, 0x7e, 0x6b, 0x40, 0xf7, 0x48, 0x94, 0x32, 0x07,
688 0xf9, 0xcb, 0x3e, 0x01, 0x1b, 0xff, 0x32, 0xf8, 0xa5, 0xc1, 0xdf, 0x79,
689 0x3d, 0x09, 0xcc, 0xf1, 0x4a, 0x9f, 0xee, 0x17, 0x23, 0xd7, 0x15, 0xe7,
690 0xf9, 0x46, 0x78, 0x5d, 0xfa, 0xfc, 0x0c, 0x1f, 0x7b, 0xed, 0x2f, 0xee,
691 0xd5, 0x96, 0x90, 0xfd, 0xc5, 0xda, 0x12, 0xc9, 0x09, 0xb9, 0xcf, 0x15,
692 0x9f, 0x6e, 0xa8, 0xec, 0xd3, 0x3d, 0x9f, 0xb9, 0xd5, 0x07, 0xff, 0x86,
693 0xb1, 0xc4, 0xfb, 0x1d, 0x7c, 0x9e, 0xc7, 0xa2, 0x56, 0x21, 0xcd, 0x9f,
694 0x1d, 0x2a, 0xaf, 0xa7, 0x1e, 0x57, 0x64, 0x9e, 0x84, 0x96, 0x5b, 0xb8,
695 0xf6, 0x43, 0xbe, 0x87, 0x94, 0x5d, 0x8d, 0x9f, 0x43, 0x75, 0x79, 0x30,
696 0xf5, 0x38, 0xb6, 0x99, 0x1f, 0x56, 0xc4, 0x13, 0x3d, 0xf0, 0x6c, 0xb3,
697 0x7e, 0x06, 0xd7, 0x84, 0x1f, 0x2d, 0x56, 0x47, 0xaf, 0xa0, 0xe3, 0x00,
698 0xfd, 0xce, 0x62, 0x8a, 0x76, 0xf1, 0x5e, 0xfd, 0xa6, 0xf1, 0x00, 0xe2,
699 0xed, 0x24, 0x73, 0x9e, 0x18, 0xc6, 0x19, 0x67, 0xe2, 0x94, 0x11, 0x01,
700 0xbf, 0x2c, 0x05, 0x9c, 0x0e, 0x6a, 0x66, 0x5a, 0xfd, 0x65, 0x1a, 0x65,
701 0xfb, 0x0f, 0x34, 0xeb, 0x84, 0xe2, 0x04, 0x7a, 0xb3, 0xcd, 0x43, 0xac,
702 0x13, 0xc7, 0x8a, 0xc0, 0x67, 0x83, 0x3e, 0x9f, 0x23, 0xfa, 0x5c, 0x6e,
703 0xd4, 0xfc, 0x26, 0x39, 0x56, 0xe5, 0x77, 0xdb, 0x8c, 0xf2, 0x3c, 0xe2,
704 0xc5, 0x2f, 0xd3, 0xfb, 0xa2, 0xcf, 0x09, 0xe0, 0xa8, 0xf7, 0xfd, 0x4b,
705 0x74, 0x32, 0x81, 0x79, 0x6f, 0x9f, 0x3e, 0x8f, 0xef, 0x88, 0x3e, 0xdb,
706 0x3c, 0xe8, 0xf3, 0xc5, 0x7e, 0x89, 0x37, 0x25, 0xc6, 0xd1, 0x36, 0x9a,
707 0xcb, 0x22, 0x07, 0xec, 0xd3, 0xe8, 0x3b, 0x95, 0x4d, 0x32, 0x5f, 0x4a,
708 0x56, 0xf8, 0xd2, 0x85, 0x28, 0x1b, 0xc3, 0x4c, 0xe3, 0xe8, 0xcb, 0xa6,
709 0xf2, 0x7e, 0xb0, 0x8e, 0x01, 0x1a, 0x5d, 0x6e, 0xe7, 0x6b, 0x69, 0x3d,
710 0x3a, 0x15, 0x51, 0xb5, 0xfe, 0xb6, 0x15, 0x63, 0xfe, 0x78, 0x9e, 0x69,
711 0x39, 0x9d, 0xbd, 0x97, 0x0a, 0xc1, 0x21, 0x1a, 0x59, 0xd6, 0xfd, 0x4d,
712 0x44, 0xce, 0xc6, 0xa0, 0xe4, 0x49, 0x7a, 0xdd, 0x9f, 0x10, 0xbe, 0x0b,
713 0xeb, 0xd2, 0xc7, 0xb5, 0xee, 0xf6, 0x2d, 0xf8, 0xd2, 0x25, 0x45, 0xb3,
714 0xa5, 0xcb, 0xd1, 0x30, 0xa5, 0xa2, 0x53, 0xaf, 0xf4, 0x03, 0xff, 0x47,
715 0x2e, 0xc1, 0x0f, 0x07, 0x1e, 0x6d, 0x51, 0x22, 0x53, 0x0b, 0x8b, 0x21,
716 0x5e, 0x37, 0x7e, 0x2f, 0x7d, 0x30, 0x17, 0x7e, 0x40, 0xc8, 0xfe, 0xd1,
717 0x4b, 0x3c, 0x4e, 0xca, 0x26, 0xc5, 0x37, 0xbc, 0xf0, 0x50, 0xf7, 0xc5,
718 0xd4, 0xb8, 0x28, 0x73, 0x3d, 0x59, 0x7f, 0x33, 0x13, 0xfe, 0x5a, 0x9c,
719 0xbc, 0xe6, 0x3b, 0xba, 0x68, 0xd1, 0xb1, 0x8c, 0xfd, 0xf5, 0x14, 0x4d,
720 0x31, 0x5d, 0xbb, 0xe5, 0x05, 0x8f, 0x27, 0xe0, 0xd9, 0x34, 0xd3, 0x3e,
721 0xdb, 0xcd, 0x59, 0x4b, 0xe6, 0xdd, 0x89, 0xde, 0x73, 0x38, 0x46, 0xdd,
722 0xf1, 0x5f, 0xf5, 0x6b, 0x79, 0x90, 0xcc, 0xa2, 0x8e, 0x90, 0x3f, 0xf3,
723 0x3c, 0x1e, 0xb9, 0xff, 0x39, 0xdc, 0x07, 0xf2, 0x0e, 0x73, 0xe7, 0xe3,
724 0x55, 0xb9, 0xaf, 0x23, 0x7c, 0x6f, 0xd4, 0xdd, 0x1f, 0x2b, 0x4e, 0xf2,
725 0xfe, 0x76, 0x09, 0xde, 0x2c, 0xf7, 0x73, 0x9a, 0xce, 0x79, 0xf2, 0x15,
726 0xb9, 0x2f, 0x49, 0x17, 0x7d, 0x27, 0x05, 0x7d, 0x4f, 0x8b, 0xfd, 0x48,
727 0xe6, 0x0c, 0xd6, 0xd7, 0xb4, 0xef, 0x81, 0xed, 0xec, 0x5c, 0x40, 0xe7,
728 0x06, 0xf2, 0xf7, 0x0f, 0xfb, 0x45, 0x5e, 0x22, 0xec, 0xef, 0x1c, 0x3e,
729 0xa7, 0xe9, 0x79, 0x96, 0xeb, 0x2f, 0x64, 0x5a, 0xe8, 0x6a, 0xb6, 0x85,
730 0xde, 0xc9, 0x0e, 0xd1, 0x95, 0xc5, 0x6e, 0x3a, 0xc7, 0x3a, 0xf3, 0x39,
731 0x27, 0x60, 0xa5, 0xa9, 0x1b, 0xf1, 0x45, 0xe4, 0x0c, 0x31, 0xdd, 0x61,
732 0x3c, 0xf4, 0xbf, 0xe8, 0x5e, 0xc6, 0x39, 0xd6, 0xbd, 0x5b, 0xe9, 0x3d,
733 0x7e, 0x66, 0x3a, 0xa3, 0x73, 0x1d, 0xe0, 0x93, 0x1f, 0x2b, 0xeb, 0xaf,
734 0x5b, 0xe3, 0x88, 0xb9, 0x05, 0x8e, 0x4c, 0x8b, 0xf8, 0xd6, 0xc2, 0x22,
735 0xff, 0xbe, 0x08, 0xff, 0x39, 0xc3, 0x9b, 0xf9, 0xf3, 0x93, 0x01, 0x8c,
736 0xc7, 0x39, 0x47, 0xe6, 0x4a, 0x8a, 0xb5, 0x85, 0xf8, 0xd8, 0x27, 0x6a,
737 0xa4, 0x25, 0x1c, 0x5a, 0x79, 0x7d, 0x3e, 0x31, 0x3e, 0xb9, 0xda, 0x4a,
738 0xf3, 0x39, 0xd6, 0x41, 0x72, 0x7e, 0xb6, 0x61, 0x30, 0xf6, 0xef, 0x54,
739 0x6f, 0x61, 0xdc, 0xbf, 0x8b, 0xd2, 0x62, 0x1c, 0x7f, 0xae, 0x76, 0xd1,
740 0x42, 0xae, 0x43, 0x1d, 0xdf, 0x2b, 0x72, 0xdc, 0x65, 0x1f, 0x23, 0xfc,
741 0xb6, 0x19, 0x7f, 0x7b, 0x97, 0x71, 0x0a, 0x32, 0x55, 0xda, 0xa5, 0xe0,
742 0x35, 0x97, 0xeb, 0x7a, 0x22, 0x03, 0xe7, 0xa6, 0xe8, 0x25, 0x96, 0xb7,
743 0x23, 0x2f, 0xc3, 0x7f, 0xfc, 0x38, 0xf0, 0x26, 0x9f, 0xa2, 0x41, 0x3e,
744 0x46, 0x5f, 0x24, 0xbf, 0xa8, 0x73, 0x8a, 0x05, 0x27, 0x44, 0x6d, 0x88,
745 0xa4, 0xd1, 0x59, 0xd1, 0x8b, 0xee, 0x2d, 0xc1, 0x9b, 0xec, 0x94, 0x65,
746 0x40, 0x1f, 0x81, 0x0f, 0x46, 0xe6, 0x60, 0x1d, 0x77, 0x7a, 0xde, 0xed,
747 0x9b, 0x19, 0xa7, 0x48, 0x3f, 0xf0, 0x5e, 0xd2, 0xac, 0xea, 0x2f, 0x20,
748 0xf8, 0xbd, 0xb9, 0x4f, 0xd7, 0x4b, 0xea, 0x63, 0x2d, 0x2b, 0xf4, 0x71,
749 0x47, 0xcd, 0xef, 0x66, 0xcd, 0xef, 0xe5, 0x7c, 0x39, 0x96, 0x79, 0x2c,
750 0xe7, 0x49, 0xf6, 0x28, 0x4a, 0x2e, 0x4b, 0xfc, 0x33, 0xf7, 0x8d, 0x99,
751 0x8f, 0x2a, 0x1d, 0x3c, 0xb9, 0x36, 0x1a, 0xea, 0x31, 0x26, 0x8c, 0xe4,
752 0xe4, 0x3f, 0x96, 0x22, 0x09, 0xe8, 0x45, 0x4f, 0xee, 0x51, 0xf9, 0xa7,
753 0x3c, 0xaf, 0x54, 0x18, 0xaa, 0xdb, 0xec, 0x5a, 0x07, 0xad, 0x8b, 0x9e,
754 0x5c, 0x42, 0xc7, 0xe0, 0xeb, 0x71, 0x9f, 0x94, 0xd9, 0x44, 0xe8, 0x73,
755 0x0e, 0x1a, 0xdf, 0x1f, 0xba, 0xc4, 0xfb, 0x19, 0x5f, 0xfb, 0x69, 0xe9,
756 0xa4, 0xe8, 0x71, 0x83, 0xb1, 0x5d, 0x34, 0x27, 0x74, 0x7e, 0xd6, 0x5f,
757 0xaa, 0xec, 0xaa, 0x29, 0xcc, 0x33, 0x85, 0xd8, 0x8a, 0xe1, 0xfc, 0xbe,
758 0x2f, 0x99, 0x97, 0xb1, 0xf2, 0x78, 0x4d, 0xac, 0x7c, 0x56, 0xc4, 0xca,
759 0x11, 0x27, 0x07, 0x5c, 0x01, 0x4b, 0xaf, 0x9c, 0x16, 0xec, 0x63, 0x98,
760 0x90, 0x1b, 0x7e, 0xee, 0xa2, 0xe0, 0x37, 0xe1, 0x98, 0x5f, 0xe6, 0x57,
761 0xc7, 0x79, 0xc6, 0x06, 0x5d, 0x60, 0x7c, 0xb0, 0x27, 0x36, 0x58, 0x97,
762 0x58, 0xc9, 0x7e, 0x99, 0xae, 0xe4, 0x9b, 0x58, 0xd7, 0x5b, 0xa0, 0x8d,
763 0x3c, 0xb1, 0x4e, 0xd8, 0x4d, 0x0b, 0x61, 0xc6, 0xb1, 0x89, 0x36, 0xde,
764 0x4f, 0xd6, 0x6b, 0x27, 0x98, 0xee, 0x78, 0xee, 0x2b, 0xb9, 0xd2, 0x8f,
765 0xd2, 0xe1, 0x88, 0x15, 0x9d, 0xea, 0x60, 0xbb, 0xc5, 0xe4, 0x7f, 0x87,
766 0xff, 0x77, 0x85, 0x00, 0x93, 0xc2, 0x2a, 0x7e, 0x67, 0x9d, 0x27, 0x53,
767 0xfa, 0xd1, 0x1c, 0x8f, 0x99, 0x9b, 0x82, 0xfd, 0x03, 0x3b, 0xcf, 0xe1,
768 0x7f, 0x39, 0x66, 0x65, 0x95, 0xf1, 0xfb, 0x62, 0x2a, 0x64, 0x08, 0xde,
769 0xbe, 0xce, 0x3c, 0xfe, 0x02, 0xcd, 0xf1, 0x1c, 0xae, 0x10, 0xae, 0xb5,
770 0x28, 0x19, 0xde, 0xc7, 0x78, 0xdf, 0xcd, 0x9f, 0xa8, 0xbf, 0x6a, 0xa7,
771 0x85, 0xc9, 0x31, 0x55, 0x7f, 0xf5, 0xbd, 0x06, 0xf5, 0x57, 0xb8, 0x8e,
772 0xe5, 0xfe, 0x62, 0xe9, 0xe6, 0x5c, 0xd8, 0xfd, 0x3c, 0x32, 0x92, 0xe1,
773 0x4e, 0xa1, 0x23, 0xad, 0xac, 0xfa, 0xf8, 0xd9, 0x11, 0x2b, 0x39, 0xc5,
774 0x73, 0xcc, 0xb9, 0xe7, 0x5d, 0xba, 0x19, 0x0b, 0x63, 0x9c, 0xbf, 0x66,
775 0x1c, 0xdb, 0xca, 0x53, 0x72, 0x3d, 0x85, 0x5c, 0xe9, 0xe7, 0xd1, 0xb0,
776 0x5e, 0x9f, 0xfb, 0x5a, 0xac, 0x03, 0xf4, 0xc4, 0x9f, 0x2b, 0x5d, 0xbe,
777 0x2b, 0x59, 0xd8, 0xdf, 0x06, 0xe3, 0x39, 0x66, 0x34, 0x44, 0xa9, 0x15,
778 0xa6, 0xef, 0x8b, 0x1d, 0xbe, 0x8d, 0xec, 0x95, 0x52, 0xb2, 0x2a, 0x97,
779 0xa5, 0xda, 0xef, 0x2e, 0x6d, 0xae, 0x21, 0x72, 0x96, 0x20, 0x33, 0x21,
780 0x2f, 0x53, 0x25, 0xbf, 0x03, 0xfd, 0x0e, 0xb6, 0xd0, 0x59, 0xe6, 0x57,
781 0x32, 0x1f, 0x89, 0x79, 0x27, 0xf3, 0x2c, 0x49, 0x2f, 0xf1, 0xaa, 0xd7,
782 0x0d, 0x48, 0x9c, 0x1d, 0xa9, 0xe4, 0x41, 0xba, 0xe2, 0xe9, 0x01, 0x57,
783 0x3c, 0xdd, 0x74, 0xe5, 0x41, 0x06, 0x85, 0x3e, 0x56, 0xd1, 0xa1, 0x82,
784 0x4a, 0x87, 0x82, 0xae, 0x25, 0x79, 0x59, 0xa1, 0xcc, 0xcb, 0x76, 0x6f,
785 0xc1, 0xcb, 0xbc, 0x6c, 0xd3, 0x75, 0xc5, 0x37, 0xec, 0x30, 0xe4, 0xfc,
786 0xe5, 0xe2, 0x34, 0xbd, 0xcd, 0x3c, 0xe2, 0xad, 0x62, 0x98, 0xf9, 0xc6,
787 0x24, 0xf3, 0x8d, 0x09, 0xe6, 0x1b, 0x0e, 0xc3, 0xc0, 0xe2, 0xb5, 0x5f,
788 0xf3, 0x5d, 0x59, 0x84, 0xbc, 0x98, 0xa2, 0xe7, 0x8b, 0xe0, 0xc1, 0x93,
789 0xac, 0xf3, 0x5c, 0xf3, 0x6d, 0x2c, 0x76, 0x31, 0xbe, 0x4a, 0x3d, 0xa7,
790 0xda, 0x8e, 0x41, 0xaf, 0x15, 0xf8, 0x87, 0xaf, 0x82, 0xcf, 0xbc, 0x91,
791 0xa2, 0x4e, 0x86, 0x3d, 0xe0, 0xbc, 0x8e, 0xde, 0x14, 0xaf, 0x81, 0x96,
792 0xd1, 0x13, 0xf8, 0xbb, 0xe3, 0x53, 0x3c, 0xf7, 0x4e, 0xdf, 0x02, 0xef,
793 0xcb, 0xd3, 0xe1, 0x94, 0xd9, 0xcb, 0x38, 0x7f, 0xac, 0x82, 0xf3, 0xa9,
794 0x34, 0xaf, 0xa0, 0x67, 0xb9, 0x9b, 0xc6, 0x0e, 0x44, 0xf7, 0xf6, 0x30,
795 0x9d, 0x22, 0x37, 0xa2, 0xd2, 0xa7, 0xc7, 0x4f, 0x27, 0x83, 0x6d, 0xaa,
796 0xbf, 0x8f, 0xc5, 0xf2, 0xf1, 0x03, 0xbe, 0xcf, 0x2d, 0x5f, 0x3a, 0xfb,
797 0x2a, 0x3f, 0x03, 0xc7, 0x5f, 0x85, 0xff, 0x93, 0xed, 0x83, 0x56, 0xe1,
798 0x3f, 0x2a, 0x88, 0xb1, 0x38, 0xb6, 0x27, 0x98, 0x97, 0x85, 0xd7, 0x0d,
799 0x7b, 0x3a, 0x62, 0x30, 0xd1, 0x75, 0x99, 0xbc, 0xde, 0xd2, 0xa0, 0x8c,
800 0xc1, 0xed, 0xdd, 0x2b, 0xf9, 0x06, 0xe3, 0x66, 0x30, 0x22, 0x6c, 0xb4,
801 0xa6, 0x25, 0x29, 0x27, 0x0b, 0xbc, 0xcf, 0x2b, 0xe1, 0x09, 0xde, 0xe7,
802 0x0e, 0x25, 0x23, 0x53, 0xfc, 0xbb, 0x90, 0xbf, 0x2c, 0x2b, 0x87, 0xd0,
803 0xb3, 0xda, 0x14, 0xfd, 0x20, 0x66, 0xd1, 0x6f, 0xa7, 0x83, 0xef, 0x6b,
804 0x33, 0xd6, 0x82, 0x4f, 0x7c, 0xe0, 0x4b, 0x66, 0xf1, 0x5c, 0xe0, 0x21,
805 0x7f, 0xcf, 0x4f, 0xd1, 0x85, 0x8c, 0x9e, 0xc3, 0x80, 0x61, 0xbc, 0x84,
806 0x79, 0xf8, 0x68, 0xb7, 0xf3, 0x43, 0x86, 0x17, 0x1f, 0xff, 0x71, 0xed,
807 0x9c, 0x86, 0xd5, 0x9c, 0xd0, 0xd3, 0xb2, 0x05, 0x3d, 0x7c, 0x08, 0xbd,
808 0x8f, 0x0a, 0xa2, 0xe7, 0x64, 0xb3, 0xb0, 0x4d, 0x0b, 0xc2, 0xc6, 0x28,
809 0x85, 0x2a, 0x7d, 0x30, 0xef, 0xa9, 0x39, 0xf7, 0x13, 0x5f, 0x7a, 0xf1,
810 0xa0, 0xd0, 0xc5, 0x46, 0x0e, 0xec, 0x55, 0xf5, 0xa7, 0x5d, 0xe2, 0xbe,
811 0xc6, 0x32, 0x7e, 0x7b, 0x50, 0xfd, 0xf6, 0x49, 0xa1, 0x03, 0x23, 0x2f,
812 0x2e, 0xb0, 0x24, 0xf0, 0x9c, 0xf7, 0xd7, 0x99, 0x60, 0x3c, 0x0f, 0xad,
813 0xc0, 0x77, 0x2f, 0xe0, 0xa9, 0xe1, 0x01, 0x58, 0x00, 0xf7, 0x3b, 0x14,
814 0xde, 0xdb, 0x56, 0xdc, 0xaf, 0xd7, 0xdd, 0x08, 0xce, 0xac, 0xd3, 0x64,
815 0xb0, 0x56, 0xac, 0x69, 0x8f, 0x2f, 0x92, 0xb7, 0x8c, 0xf4, 0x22, 0x6c,
816 0x1a, 0xd4, 0xb5, 0xdc, 0x85, 0xbc, 0x29, 0x9e, 0xc3, 0x1e, 0x8a, 0x24,
817 0x30, 0x2f, 0x8c, 0xd3, 0x30, 0xf8, 0xb7, 0x1a, 0x58, 0xb8, 0xaf, 0xeb,
818 0x56, 0xd7, 0xb5, 0x8a, 0xbd, 0x20, 0x03, 0xcf, 0xd1, 0xcf, 0xc6, 0x73,
819 0xf1, 0x7c, 0x5c, 0x87, 0xfb, 0xc9, 0xfb, 0xf6, 0x31, 0x7f, 0x8e, 0x4e,
820 0xc9, 0x7b, 0x19, 0x97, 0xe4, 0x6f, 0x7d, 0x8e, 0xf7, 0x7c, 0xe5, 0xfe,
821 0xf9, 0x54, 0xbf, 0x1e, 0xec, 0x5f, 0x37, 0xe5, 0x85, 0x8f, 0x13, 0xbf,
822 0x75, 0x8a, 0xdf, 0xa2, 0x4e, 0xa7, 0xd8, 0xd7, 0xf3, 0x7c, 0x3c, 0x9f,
823 0xed, 0xf2, 0xc1, 0x36, 0x4f, 0x27, 0x3a, 0x7d, 0xf9, 0x3c, 0xd6, 0xdb,
824 0xe9, 0x8b, 0x33, 0xee, 0xc7, 0xb2, 0xf1, 0xd2, 0x82, 0xe0, 0x31, 0xac,
825 0xd3, 0xf6, 0xda, 0xe6, 0x49, 0xe3, 0x4f, 0x86, 0x64, 0x6f, 0x5b, 0x7c,
826 0x67, 0xfa, 0xcb, 0x30, 0xfd, 0x65, 0x98, 0xfe, 0x32, 0x4c, 0x7f, 0x19,
827 0xa6, 0x3f, 0xb6, 0x4b, 0xdf, 0x64, 0x99, 0xf1, 0x6d, 0x96, 0x19, 0x92,
828 0x66, 0x23, 0xca, 0x8f, 0xa9, 0x69, 0xb6, 0xb6, 0x3e, 0x53, 0xd3, 0x28,
829 0xe4, 0x34, 0xf9, 0x0e, 0x8f, 0x57, 0xd3, 0xea, 0x55, 0xa6, 0xd5, 0xa6,
830 0x99, 0x7e, 0xba, 0x91, 0xc3, 0x9e, 0xd9, 0xd6, 0x79, 0xe6, 0xd1, 0x71,
831 0x3f, 0x74, 0xaa, 0x00, 0xd3, 0x13, 0x74, 0x4a, 0x9b, 0xe1, 0xde, 0x4f,
832 0x37, 0x99, 0x4f, 0xdf, 0xc8, 0x81, 0x76, 0xef, 0x52, 0xc7, 0x19, 0xa6,
833 0x5d, 0xc8, 0xb9, 0x25, 0xdf, 0xd5, 0xac, 0xc1, 0xba, 0x57, 0xc0, 0x4c,
834 0x12, 0xf8, 0xa8, 0xd0, 0xc7, 0x78, 0xdf, 0xd7, 0x99, 0xdf, 0xc3, 0x57,
835 0x87, 0xbe, 0x5f, 0x79, 0x1f, 0xcb, 0x89, 0xd0, 0x15, 0xe6, 0xa3, 0xa7,
836 0x73, 0x4b, 0x4c, 0xef, 0xbd, 0xf4, 0x85, 0x1c, 0xe4, 0x31, 0x60, 0xc4,
837 0xc7, 0x79, 0x12, 0x3e, 0x30, 0x63, 0x06, 0x6b, 0x1f, 0x4b, 0x19, 0x02,
838 0x4f, 0x9e, 0x01, 0x1c, 0x18, 0xf6, 0x67, 0xf6, 0xa2, 0x67, 0x7d, 0xc4,
839 0x68, 0x56, 0x3e, 0x45, 0x7c, 0xc7, 0x78, 0x8c, 0x05, 0xdc, 0x70, 0xdc,
840 0x28, 0xfe, 0x88, 0xf7, 0x42, 0x84, 0x19, 0x1e, 0xb5, 0x7c, 0xeb, 0x02,
841 0x7a, 0x91, 0x02, 0x5e, 0xd3, 0x51, 0x3f, 0x6a, 0xc5, 0xe9, 0x39, 0xbc,
842 0xff, 0xe0, 0x85, 0x22, 0xe6, 0xbd, 0x48, 0x0b, 0x41, 0xf0, 0x21, 0x3b,
843 0x7c, 0x9d, 0x24, 0xec, 0x5a, 0x59, 0xbf, 0xfc, 0xbc, 0x37, 0x6f, 0xb3,
844 0xa2, 0x42, 0x1f, 0x6e, 0x61, 0xfb, 0x06, 0xb0, 0x79, 0x8b, 0x71, 0x2d,
845 0x0c, 0x9b, 0x5f, 0xf1, 0xb5, 0x37, 0x99, 0xe7, 0x60, 0xcf, 0x3a, 0x85,
846 0x8c, 0xf1, 0xe2, 0x65, 0x1b, 0x8a, 0x97, 0x39, 0x2e, 0x5e, 0x96, 0x2e,
847 0xf3, 0x32, 0xc6, 0x09, 0xc1, 0xc3, 0xc0, 0xa3, 0x66, 0x59, 0x4f, 0x94,
848 0xdf, 0xa1, 0xff, 0xed, 0x16, 0x3c, 0x8b, 0x79, 0x3d, 0xdb, 0x0d, 0x85,
849 0x62, 0xca, 0x77, 0x48, 0xf0, 0x0e, 0x8d, 0xd7, 0xff, 0xa3, 0xe8, 0xa1,
850 0x55, 0xf0, 0x81, 0xf4, 0x2c, 0xf8, 0x95, 0xd7, 0xf8, 0xff, 0x02, 0x6c,
851 0x79, 0xbc, 0x13, 0x7a, 0x8d, 0xf9, 0x58, 0x21, 0x0c, 0x9b, 0xb5, 0x43,
852 0xd9, 0x36, 0xe8, 0xbb, 0xb5, 0x07, 0xb9, 0x96, 0x56, 0xb4, 0xcc, 0xc7,
853 0x76, 0x2b, 0xbf, 0x05, 0xfc, 0x8c, 0xd8, 0xeb, 0x3a, 0x5d, 0xc0, 0x82,
854 0x2e, 0xc0, 0x63, 0x03, 0x0c, 0x1f, 0xd1, 0x1b, 0x9c, 0xe8, 0x16, 0xc3,
855 0x01, 0xfb, 0x7c, 0x0b, 0xfb, 0xcc, 0xba, 0x2c, 0x05, 0xe6, 0xa6, 0x02,
856 0x03, 0x98, 0xdf, 0xc2, 0x6a, 0x85, 0x1f, 0x9e, 0xcf, 0x0c, 0x18, 0x85,
857 0xac, 0x9c, 0xe3, 0xca, 0xb8, 0xe4, 0x79, 0x85, 0x3c, 0x7a, 0x7b, 0x89,
858 0xb9, 0xf2, 0x1c, 0xf5, 0xfa, 0x04, 0xff, 0x52, 0x74, 0xbf, 0x1d, 0x5a,
859 0x4b, 0x30, 0x5d, 0x61, 0x4f, 0x52, 0x2e, 0x9c, 0x79, 0x94, 0x9f, 0x8f,
860 0x73, 0x8d, 0xd7, 0x71, 0xb3, 0xbc, 0x8e, 0x08, 0xaf, 0x03, 0x63, 0x6f,
861 0xf9, 0x6e, 0xa8, 0x75, 0xdc, 0x28, 0xaf, 0x63, 0x56, 0xad, 0x83, 0xd2,
862 0xc6, 0xcc, 0x6e, 0xa5, 0xc7, 0x6f, 0x79, 0xcf, 0xd6, 0x28, 0xeb, 0x27,
863 0xe9, 0x55, 0xc0, 0xf3, 0x1e, 0x85, 0x2f, 0x6e, 0x7f, 0xa8, 0x7b, 0x6e,
864 0xf6, 0xc4, 0x75, 0xfa, 0x5d, 0xba, 0x29, 0xf4, 0x93, 0x61, 0xd6, 0x4f,
865 0x70, 0x9e, 0x16, 0xc0, 0x87, 0xd3, 0x41, 0xf4, 0x9b, 0x1d, 0x64, 0x98,
866 0xb1, 0x5d, 0x35, 0xc5, 0x9f, 0xc2, 0x4f, 0x86, 0xfb, 0xe8, 0xeb, 0xbf,
867 0x48, 0x37, 0x17, 0xc1, 0xab, 0xa1, 0x8f, 0xca, 0x9e, 0xb4, 0x37, 0xd7,
868 0xa4, 0x9f, 0x36, 0xee, 0xe9, 0xa7, 0x85, 0x8f, 0x36, 0x0c, 0x7d, 0xdd,
869 0x84, 0x3f, 0x37, 0x26, 0xde, 0x67, 0xc1, 0xc7, 0x45, 0xdc, 0xcb, 0x8b,
870 0xef, 0x4c, 0xbb, 0x72, 0xdc, 0x90, 0x73, 0x92, 0x62, 0x3e, 0xe2, 0x98,
871 0x4d, 0x86, 0xac, 0x9d, 0xb9, 0x5c, 0xd4, 0x3a, 0x51, 0x9c, 0xf7, 0xc8,
872 0x09, 0x1b, 0x46, 0x44, 0xf8, 0x0c, 0x5a, 0x9d, 0x0e, 0x6a, 0x61, 0x39,
873 0x79, 0x8a, 0xd0, 0x13, 0xcd, 0xb6, 0xe0, 0xcb, 0xbf, 0xc0, 0xb8, 0xb7,
874 0x10, 0xb6, 0x43, 0x9f, 0x13, 0xf6, 0x25, 0xe4, 0x07, 0xde, 0xa7, 0x02,
875 0x18, 0x63, 0x0e, 0xfc, 0x7d, 0x15, 0xfd, 0x30, 0xc3, 0xbc, 0x7e, 0xf8,
876 0x81, 0x47, 0xad, 0x77, 0x58, 0xee, 0x5c, 0x10, 0xfe, 0x95, 0xb3, 0x94,
877 0x66, 0x3a, 0x3c, 0x2c, 0xe8, 0xd0, 0x18, 0x66, 0x6a, 0x61, 0xfa, 0x41,
878 0x8e, 0xc1, 0x98, 0xe8, 0xbf, 0x23, 0x6d, 0x16, 0x5e, 0xe5, 0x9a, 0xea,
879 0x6b, 0x90, 0x00, 0x6f, 0xd8, 0xbe, 0x6f, 0x21, 0xf1, 0x91, 0x7d, 0x2a,
880 0x6e, 0x5d, 0xab, 0xd6, 0x87, 0x0d, 0xfb, 0xcc, 0x12, 0x7d, 0x1f, 0x01,
881 0x3b, 0xe1, 0x17, 0x34, 0x26, 0x19, 0x6e, 0xfa, 0xdd, 0x35, 0x6e, 0xfb,
882 0xff, 0x29, 0x51, 0x9f, 0xff, 0x46, 0x51, 0xca, 0xd8, 0x34, 0xdb, 0xe6,
883 0x0b, 0x07, 0xdc, 0x3a, 0x87, 0x9d, 0x8d, 0x09, 0x9f, 0xcc, 0x00, 0x45,
884 0x97, 0x27, 0xe9, 0xb1, 0x0c, 0x78, 0x14, 0x5d, 0x8f, 0x3a, 0x78, 0xc3,
885 0x06, 0x68, 0x79, 0x92, 0xe2, 0x45, 0xc0, 0xc8, 0x47, 0x0b, 0x2c, 0x05,
886 0xd2, 0x59, 0xc4, 0xee, 0xf9, 0x7b, 0x1e, 0xef, 0x57, 0xf9, 0x15, 0xe5,
887 0xf7, 0x1e, 0xa2, 0xd8, 0x32, 0xa5, 0x92, 0xe1, 0x87, 0x45, 0xcf, 0xea,
888 0x64, 0x78, 0x5c, 0xf9, 0x68, 0x42, 0x7c, 0x1e, 0x7e, 0x2f, 0x8b, 0x1e,
889 0xcd, 0xd8, 0xa9, 0x24, 0x49, 0xdf, 0x03, 0xf1, 0x1c, 0x0c, 0x96, 0xad,
890 0xbb, 0x99, 0x57, 0x1c, 0x17, 0xfe, 0x07, 0xd6, 0x44, 0x16, 0x31, 0x1e,
891 0xbe, 0x83, 0x5e, 0x82, 0xbd, 0x95, 0xcc, 0x3e, 0xa0, 0xc6, 0x96, 0xc8,
892 0x64, 0x5c, 0x30, 0x7f, 0xc9, 0x49, 0x85, 0x8d, 0xca, 0xf5, 0xf0, 0x5d,
893 0x1c, 0x17, 0xfa, 0xe1, 0x30, 0xdb, 0x30, 0x62, 0x5c, 0x69, 0x4e, 0xf8,
894 0x21, 0xf8, 0x38, 0xff, 0xd3, 0x01, 0xfd, 0x6e, 0x03, 0x9c, 0x97, 0xfe,
895 0x09, 0xbe, 0x67, 0x9e, 0xe7, 0x51, 0x95, 0x17, 0x3f, 0x44, 0x91, 0x1d,
896 0xf8, 0x8b, 0x66, 0xef, 0xa8, 0xbf, 0x88, 0x61, 0xcd, 0xb2, 0xe5, 0x32,
897 0xd3, 0xc6, 0xdb, 0x5b, 0xda, 0x71, 0xef, 0x6b, 0x19, 0xcd, 0xb0, 0x32,
898 0xc5, 0xfb, 0x2f, 0xd0, 0xeb, 0x73, 0xa1, 0xf8, 0x29, 0xbc, 0x47, 0xc6,
899 0x97, 0x10, 0x3a, 0x6f, 0x88, 0x75, 0x17, 0xe8, 0x30, 0xa3, 0x22, 0xbe,
900 0x15, 0x79, 0xc2, 0x32, 0x16, 0xd6, 0xfa, 0xc9, 0x0f, 0xbf, 0x9a, 0xa3,
901 0x73, 0x22, 0x5a, 0x45, 0xfe, 0xba, 0x8c, 0x2b, 0x42, 0xfe, 0x82, 0x07,
902 0xfe, 0xc4, 0x97, 0x5c, 0xf3, 0xf7, 0xe9, 0x7c, 0xb7, 0x48, 0xb0, 0x9c,
903 0x4f, 0xa3, 0x78, 0x8a, 0xc6, 0x3d, 0x1d, 0xb3, 0x70, 0xbf, 0xd7, 0x0a,
904 0xb4, 0xeb, 0xd6, 0x19, 0xe0, 0x67, 0x12, 0x7b, 0x74, 0x01, 0x71, 0x5c,
905 0xa3, 0x2a, 0x1e, 0xd1, 0xc2, 0xfb, 0x04, 0x3b, 0x0f, 0xfe, 0xbb, 0xcf,
906 0xf2, 0x27, 0xe2, 0x0a, 0x27, 0x07, 0xa1, 0x27, 0xf5, 0x38, 0x8c, 0x33,
907 0x53, 0x38, 0xee, 0x67, 0xbb, 0x4b, 0xeb, 0xb5, 0xd2, 0xa7, 0xc4, 0xb6,
908 0x98, 0xda, 0x2f, 0xf8, 0x93, 0x46, 0x54, 0xbf, 0x01, 0x9b, 0xac, 0x5e,
909 0xc0, 0xe9, 0xe3, 0xa2, 0xc7, 0xad, 0x62, 0x10, 0xdb, 0xc9, 0x59, 0xc2,
910 0x3b, 0xb7, 0xd0, 0x77, 0xf3, 0x6e, 0xc0, 0x9e, 0xf7, 0xc8, 0x1d, 0xa3,
911 0xf8, 0x94, 0x7a, 0xff, 0xcf, 0x9d, 0xda, 0xb7, 0x5d, 0x1e, 0xfb, 0xf6,
912 0xbd, 0x41, 0x19, 0x03, 0xbb, 0x4b, 0x8d, 0xf1, 0xca, 0x53, 0xfd, 0xfb,
913 0xa7, 0xe1, 0x4f, 0xaa, 0xd4, 0x51, 0x5c, 0x13, 0x7c, 0xa5, 0xde, 0xa7,
914 0x1d, 0x62, 0x7e, 0x2a, 0xe9, 0xf8, 0xb8, 0x07, 0x1d, 0xf7, 0xce, 0x40,
915 0x2f, 0xb9, 0x7d, 0x3a, 0x3e, 0xd6, 0x90, 0x8e, 0xff, 0x75, 0x50, 0xfa,
916 0x54, 0xeb, 0xe9, 0x18, 0xb5, 0x3c, 0xc7, 0x8b, 0x8d, 0xfc, 0x57, 0xd8,
917 0x07, 0xd4, 0xa4, 0xc3, 0xe7, 0x01, 0x58, 0x69, 0xbf, 0x07, 0xe2, 0x7e,
918 0xc0, 0x47, 0xc4, 0x4e, 0xfe, 0x90, 0xe2, 0x8b, 0xb5, 0xb1, 0xd0, 0xcd,
919 0xae, 0xf9, 0x96, 0xc7, 0x35, 0xd0, 0xc5, 0x41, 0x0b, 0x76, 0x48, 0xda,
920 0xf4, 0x1a, 0x5e, 0xef, 0xf9, 0x0e, 0xe5, 0xec, 0x54, 0x9e, 0xe0, 0xa3,
921 0x0e, 0xd2, 0x53, 0x88, 0x2b, 0x2b, 0x1f, 0xf0, 0xd1, 0x8c, 0x5c, 0xb7,
922 0x79, 0x40, 0xe0, 0x03, 0xf4, 0xd5, 0x50, 0xc2, 0x9f, 0xe0, 0x3d, 0x95,
923 0xfe, 0xdf, 0xe4, 0x6a, 0x48, 0xed, 0x13, 0x8f, 0xc5, 0xfd, 0x3c, 0xeb,
924 0xfc, 0xb0, 0x3f, 0xf6, 0xd7, 0xd7, 0xcb, 0x79, 0xc5, 0x90, 0x05, 0x25,
925 0xfa, 0x0f, 0x96, 0x73, 0xfe, 0x03, 0xa6, 0xe8, 0xb9, 0x70, 0xb9, 0x78,
926 0x80, 0xf5, 0x47, 0xec, 0x21, 0x7c, 0x87, 0xda, 0xb7, 0xfb, 0xf6, 0x30,
927 0x75, 0xed, 0x67, 0xa9, 0x6f, 0x90, 0xc3, 0x7a, 0xa3, 0x71, 0x00, 0xf9,
928 0xe1, 0x16, 0x5f, 0x83, 0x5e, 0x51, 0x63, 0x56, 0x9c, 0x3a, 0xe0, 0x4f,
929 0x40, 0x0f, 0x68, 0x2b, 0x5d, 0x45, 0x53, 0xb3, 0x82, 0xa6, 0xe2, 0x6b,
930 0xb3, 0x8a, 0xa6, 0x66, 0x95, 0xff, 0x7c, 0x56, 0xd1, 0xd4, 0xac, 0xa2,
931 0xa9, 0x59, 0x45, 0x53, 0xb3, 0x8c, 0xd7, 0xa3, 0xac, 0xaf, 0x42, 0xf7,
932 0xd0, 0xfe, 0xcb, 0x2e, 0x4a, 0xe6, 0x70, 0x1e, 0xf2, 0xb8, 0x96, 0xae,
933 0x7e, 0x6d, 0x58, 0xfb, 0x47, 0x0b, 0x32, 0xcf, 0x8e, 0x9f, 0x85, 0x3d,
934 0x78, 0x98, 0xe1, 0x77, 0xcd, 0x37, 0xbf, 0x88, 0xb9, 0xfa, 0x28, 0x26,
935 0x7a, 0xc0, 0x36, 0x51, 0xd4, 0xad, 0xe3, 0x9a, 0xa8, 0xeb, 0x92, 0xb6,
936 0x5c, 0xaa, 0x61, 0x8d, 0x97, 0xc6, 0x8b, 0x69, 0xb5, 0x5f, 0xb5, 0x76,
937 0x4e, 0x0b, 0x25, 0xb2, 0x80, 0x2b, 0x72, 0x21, 0x2d, 0xde, 0x1b, 0x01,
938 0xa7, 0x94, 0xe9, 0x01, 0x83, 0xa3, 0x0a, 0x06, 0x4f, 0x8b, 0x35, 0x22,
939 0x97, 0x10, 0x3e, 0xc8, 0xc6, 0x70, 0x48, 0x67, 0x46, 0xf9, 0x3e, 0x8c,
940 0xfb, 0x07, 0x42, 0xcc, 0x83, 0xb6, 0x0b, 0x07, 0xf7, 0xda, 0x1b, 0xf1,
941 0x9a, 0xed, 0xd6, 0xd3, 0x5c, 0x77, 0xc9, 0x8e, 0x90, 0x92, 0x1b, 0x52,
942 0xef, 0xdd, 0xe5, 0xd8, 0x89, 0x14, 0xcf, 0xed, 0x2f, 0xc2, 0x7f, 0x39,
943 0x44, 0x6d, 0x25, 0x3a, 0x12, 0x06, 0x3e, 0x77, 0xb1, 0x5d, 0xc9, 0x73,
944 0x18, 0x2b, 0xd1, 0x85, 0xf0, 0x3e, 0xb6, 0x5d, 0xf6, 0xb3, 0x0e, 0x3a,
945 0xca, 0xff, 0x4e, 0xc4, 0xef, 0xc3, 0xbc, 0x3a, 0xf8, 0xda, 0x7e, 0x32,
946 0x7a, 0x52, 0x66, 0x2b, 0xeb, 0x07, 0x47, 0x2a, 0xf6, 0x88, 0x05, 0xff,
947 0x1c, 0xeb, 0xb6, 0xc6, 0x5c, 0xb8, 0x5b, 0xd5, 0x9c, 0xc1, 0x87, 0x8d,
948 0xf8, 0xd6, 0x3f, 0x97, 0x64, 0xaf, 0x80, 0x21, 0x75, 0xfc, 0xe3, 0x52,
949 0x64, 0x08, 0xc7, 0x78, 0xe7, 0x90, 0x3d, 0x11, 0xf1, 0xfd, 0x58, 0xea,
950 0xf2, 0x3e, 0xfb, 0x88, 0x7c, 0x3f, 0x80, 0x6d, 0x5a, 0x3e, 0x2f, 0xbc,
951 0x97, 0x3a, 0x4f, 0x25, 0x5f, 0x15, 0x74, 0x50, 0xa2, 0x7f, 0x67, 0x9a,
952 0x35, 0x09, 0xb1, 0x8c, 0x29, 0x51, 0x0b, 0x8d, 0x7c, 0xe5, 0xf9, 0x45,
953 0x3d, 0x2f, 0x47, 0xed, 0xf5, 0xfd, 0xc8, 0x37, 0xcb, 0x16, 0x68, 0x73,
954 0x99, 0x01, 0x3f, 0xda, 0xe8, 0xf2, 0x46, 0x4f, 0x50, 0xd4, 0x66, 0x77,
955 0xb3, 0x8e, 0xa3, 0xf3, 0x92, 0xc7, 0xf8, 0xfe, 0x01, 0xf1, 0xbe, 0xb9,
956 0xd8, 0x12, 0xc6, 0x35, 0xd3, 0xc8, 0x72, 0xe9, 0x21, 0xfe, 0x5d, 0xc4,
957 0x11, 0x93, 0xd4, 0xaa, 0x62, 0x04, 0x1d, 0x2a, 0xae, 0x14, 0x62, 0x5a,
958 0xaa, 0xd4, 0x1c, 0x8f, 0x94, 0x7d, 0x6d, 0xc0, 0xf1, 0x5a, 0x5f, 0xdb,
959 0x73, 0x5b, 0xc8, 0x9b, 0xad, 0xf0, 0x1a, 0x39, 0xa5, 0x2d, 0xa4, 0x7c,
960 0x88, 0xd6, 0x02, 0x6d, 0xb7, 0xb6, 0x6e, 0xc7, 0xd7, 0xb4, 0x36, 0xcf,
961 0xac, 0x9f, 0x79, 0xc7, 0x69, 0x53, 0xf8, 0xd4, 0x4c, 0xf3, 0xb9, 0x36,
962 0x96, 0xd9, 0xa8, 0x97, 0x02, 0xbc, 0xfc, 0x43, 0xa8, 0x37, 0x79, 0x32,
963 0xd0, 0x4c, 0xab, 0xab, 0xc8, 0x79, 0x78, 0xfc, 0x2e, 0x99, 0xe7, 0xfb,
964 0x08, 0xc3, 0x65, 0x3f, 0xcb, 0x37, 0x43, 0xc5, 0x70, 0x70, 0x0e, 0xbc,
965 0x41, 0xf4, 0xfd, 0x0c, 0x3c, 0x3c, 0xde, 0xc6, 0x7a, 0xbd, 0x8c, 0x01,
966 0x1c, 0xe4, 0x7b, 0x7f, 0x33, 0xf7, 0x08, 0xfc, 0x59, 0xe6, 0x61, 0xbe,
967 0x7f, 0x8c, 0xf5, 0x81, 0x08, 0x35, 0xd3, 0xca, 0x6a, 0x33, 0xeb, 0xf5,
968 0xcd, 0xac, 0x0f, 0x8c, 0x9a, 0x23, 0x3e, 0xf1, 0x2c, 0x51, 0xdb, 0xf2,
969 0xe9, 0xc0, 0x7e, 0xc6, 0x41, 0x3c, 0xeb, 0x8b, 0xea, 0x59, 0xb5, 0xcf,
970 0xb8, 0x55, 0xc2, 0xf1, 0x61, 0xff, 0xfa, 0x99, 0xab, 0x78, 0x2f, 0xd4,
971 0xe2, 0x34, 0xeb, 0xbe, 0x41, 0xf1, 0x6e, 0x46, 0x63, 0x66, 0x86, 0xed,
972 0x80, 0x30, 0x1f, 0x1f, 0xa1, 0x54, 0x31, 0x41, 0xbf, 0x57, 0x74, 0xfb,
973 0x6a, 0x8f, 0xf0, 0x9c, 0x65, 0x6d, 0x7d, 0x0b, 0xcf, 0xeb, 0x7d, 0xa7,
974 0x96, 0x67, 0xb4, 0x91, 0xff, 0x6b, 0x41, 0x6a, 0x7e, 0x11, 0xbe, 0x91,
975 0x12, 0x65, 0xc3, 0xf6, 0x85, 0xeb, 0xe2, 0xbd, 0x1b, 0x16, 0xbd, 0x22,
976 0xf2, 0x5b, 0xf9, 0x7a, 0xbe, 0xe7, 0x79, 0x8c, 0x7b, 0xc5, 0xa2, 0x2b,
977 0x8e, 0x84, 0xf7, 0x9f, 0x05, 0x82, 0xe4, 0x7f, 0x1d, 0x39, 0x48, 0xd0,
978 0xb5, 0xd6, 0xcf, 0x38, 0xfb, 0x98, 0x5f, 0xbf, 0x88, 0xeb, 0xf8, 0xf3,
979 0x75, 0x1c, 0xb7, 0xf1, 0x3a, 0x21, 0x6f, 0x91, 0x77, 0x02, 0x3e, 0xb7,
980 0x3f, 0x64, 0x0a, 0xfc, 0x3b, 0xc2, 0x38, 0xd5, 0x24, 0x7c, 0x81, 0xbd,
981 0x18, 0xeb, 0x0c, 0xb2, 0x6e, 0xb0, 0x7e, 0x66, 0x7c, 0x1f, 0x8e, 0x23,
982 0x3d, 0x7e, 0x86, 0x91, 0xc4, 0xa1, 0xb0, 0x78, 0xff, 0xa1, 0xeb, 0x2f,
983 0x70, 0x70, 0x9c, 0x78, 0x3f, 0xa1, 0x3f, 0xf0, 0x7e, 0x9a, 0xe8, 0xb3,
984 0xd4, 0x46, 0x71, 0x7e, 0x46, 0x2c, 0x27, 0xd7, 0x7d, 0xbe, 0xe8, 0x27,
985 0xe9, 0x47, 0x6a, 0x1e, 0xd6, 0xef, 0x29, 0xa4, 0x7e, 0xdc, 0x5b, 0xd3,
986 0x0a, 0xbe, 0x77, 0xd1, 0x8d, 0x5c, 0x07, 0xdd, 0x54, 0xb1, 0xa5, 0x1b,
987 0xc2, 0xae, 0x62, 0x9e, 0x9c, 0xe8, 0xa2, 0xeb, 0xab, 0x4d, 0x44, 0xbd,
988 0x6d, 0x22, 0xf6, 0x7b, 0x23, 0x97, 0xc7, 0xf3, 0x87, 0xa5, 0xdf, 0xa5,
989 0x82, 0x23, 0x37, 0x3c, 0x70, 0xe4, 0x3d, 0x81, 0x23, 0xef, 0x6d, 0x81,
990 0x23, 0x7b, 0x95, 0x2d, 0xd1, 0x46, 0xcd, 0x0a, 0x3f, 0x5e, 0x63, 0xfc,
991 0x78, 0x81, 0xf1, 0xe3, 0x50, 0x03, 0xfc, 0x30, 0x6a, 0xf0, 0xe3, 0xb0,
992 0xc0, 0x8f, 0x9f, 0x6d, 0x8a, 0x1f, 0x87, 0xfc, 0x9b, 0xf9, 0x82, 0x34,
993 0x6e, 0x0e, 0xd0, 0x4a, 0xce, 0xa1, 0xd5, 0x45, 0x9b, 0x2d, 0x7b, 0xd8,
994 0xe6, 0x88, 0x19, 0xce, 0x88, 0x7a, 0x97, 0x82, 0xc0, 0x2b, 0x96, 0xe3,
995 0x33, 0xa8, 0x69, 0xaa, 0xdb, 0x03, 0x12, 0xef, 0xa5, 0x14, 0xf0, 0x97,
996 0x7b, 0x12, 0xcb, 0xac, 0x9f, 0xf9, 0x73, 0xde, 0xc7, 0x2b, 0x6b, 0x81,
997 0x00, 0x7e, 0xf3, 0xcf, 0x04, 0x69, 0x63, 0x8d, 0xed, 0x54, 0xc6, 0xb1,
998 0xab, 0xb9, 0x21, 0xba, 0x92, 0x1b, 0xa0, 0x8d, 0xdc, 0x30, 0xbd, 0x93,
999 0xc3, 0x33, 0x00, 0x73, 0x3e, 0x16, 0x30, 0x37, 0xe8, 0x60, 0x90, 0xc7,
1000 0xac, 0x0e, 0xd0, 0xfa, 0xaa, 0xc6, 0x57, 0xe0, 0x2a, 0xf6, 0x3f, 0xd2,
1001 0x23, 0xeb, 0xd0, 0xea, 0x71, 0x20, 0x56, 0x85, 0x03, 0xf2, 0x1a, 0xec,
1002 0xfd, 0x42, 0x7d, 0x0d, 0x6d, 0xab, 0x39, 0x83, 0x1c, 0xb8, 0x36, 0xb6,
1003 0xc9, 0x6d, 0xe1, 0x73, 0x3d, 0xe8, 0x87, 0x4e, 0x6b, 0xdc, 0x4d, 0x5d,
1004 0xbc, 0x07, 0x0e, 0xf2, 0x87, 0x86, 0x59, 0x3f, 0xed, 0x16, 0xfa, 0x68,
1005 0xd4, 0x09, 0x84, 0x62, 0x54, 0x3a, 0x6b, 0x38, 0xe8, 0x93, 0xf8, 0x08,
1006 0xdf, 0xcf, 0x50, 0x7e, 0x9e, 0x4e, 0x17, 0x3e, 0xd5, 0xea, 0x9e, 0x88,
1007 0xd1, 0x9e, 0xe0, 0x39, 0x43, 0x4e, 0x56, 0xe2, 0x22, 0x54, 0x8e, 0x8b,
1008 0xb4, 0xf2, 0xba, 0x25, 0x2d, 0xcd, 0x39, 0x3c, 0xae, 0xc8, 0xe3, 0x8a,
1009 0x88, 0xa9, 0xf1, 0xf9, 0x55, 0xc4, 0x73, 0x87, 0x68, 0x63, 0x11, 0x34,
1010 0x07, 0xff, 0x44, 0x25, 0x86, 0xba, 0xb1, 0x86, 0xf3, 0xf0, 0x51, 0x54,
1011 0x62, 0xa8, 0x1b, 0x2a, 0x86, 0xba, 0xb1, 0x36, 0x2d, 0xf8, 0xf0, 0x42,
1012 0x8e, 0x79, 0x40, 0xce, 0xaf, 0xf2, 0x07, 0xf7, 0xa9, 0x77, 0xf6, 0x9c,
1013 0x10, 0x3e, 0xe4, 0x1e, 0x67, 0x73, 0x18, 0x1e, 0xac, 0x83, 0xe1, 0xb4,
1014 0xd0, 0x83, 0xe2, 0x7c, 0xcf, 0x58, 0xee, 0x04, 0xc3, 0x73, 0x96, 0x69,
1015 0x69, 0xb7, 0xa2, 0x25, 0x1d, 0x93, 0xed, 0x26, 0xf5, 0xfe, 0x1f, 0xa1,
1016 0xeb, 0x4b, 0xfe, 0x33, 0x54, 0xc3, 0x7f, 0x28, 0x10, 0x1d, 0x97, 0xd7,
1017 0xa7, 0x8b, 0xaf, 0x0c, 0x6b, 0xff, 0x5b, 0x9a, 0xef, 0xbb, 0x90, 0xdb,
1018 0x49, 0x4c, 0x97, 0xe5, 0xa6, 0x67, 0xce, 0xe0, 0x76, 0x9f, 0xad, 0x71,
1019 0xe1, 0xc4, 0x6d, 0xe0, 0x93, 0xbc, 0x47, 0x05, 0x9f, 0xfe, 0x77, 0x16,
1020 0xc0, 0xb2, 0x93, 0x05, 0x98, 0x57, 0x84, 0x80, 0xf5, 0x03, 0x03, 0xb4,
1021 0x8e, 0x39, 0x00, 0x1e, 0x53, 0x68, 0x02, 0xe6, 0x19, 0xa7, 0xf5, 0x40,
1022 0xfb, 0xfb, 0x95, 0xc1, 0xeb, 0x5d, 0x1b, 0xa0, 0x67, 0x4f, 0x2d, 0xea,
1023 0x79, 0x2c, 0x07, 0xca, 0xa3, 0x4e, 0x2a, 0x0c, 0x24, 0xe6, 0x27, 0x90,
1024 0xff, 0x80, 0xfe, 0x00, 0xf9, 0x11, 0x98, 0x9f, 0x9c, 0x81, 0x72, 0xa0,
1025 0x35, 0x53, 0xcd, 0x6b, 0x40, 0xfa, 0x40, 0x61, 0x08, 0x2a, 0x53, 0x41,
1026 0x63, 0x1d, 0x40, 0xf6, 0x12, 0x21, 0x68, 0xd8, 0x01, 0x69, 0x20, 0xbb,
1027 0x79, 0x8a, 0x08, 0x98, 0x9f, 0x14, 0x20, 0xc4, 0xd0, 0x00, 0xcf, 0x4f,
1028 0xec, 0x40, 0x97, 0xc2, 0xdc, 0xf4, 0xff, 0xff, 0x31, 0x15, 0x16, 0x60,
1029 0xda, 0x03, 0xad, 0xf9, 0xfc, 0xfd, 0xff, 0x80, 0x08, 0x0b, 0x43, 0x0b,
1030 0x7c, 0xed, 0x9e, 0xb0, 0x3c, 0xa8, 0x9c, 0x5b, 0x00, 0x64, 0xb5, 0xc1,
1031 0xeb, 0x6d, 0x16, 0xf0, 0x7d, 0xc4, 0x0b, 0x18, 0x7e, 0x01, 0xcb, 0x95,
1032 0xff, 0xff, 0x97, 0xc2, 0xd5, 0x82, 0x00, 0x00, 0xd4, 0xc2, 0xcb, 0x42,
1033 0x60, 0x7c, 0x00, 0x00, 0x00 };
1034static u32 bnx2_COM_b09FwData[(0x0/4) + 1] = { 0x0 };
1035static u32 bnx2_COM_b09FwRodata[(0x88/4) + 1] = {
1036 0x08001ad8, 0x08001b14, 0x08001b14, 0x08001b14, 0x08001b14, 0x08001b14,
1037 0x08001a24, 0x08001b14, 0x08001a98, 0x08001b14, 0x080019ac, 0x08001b14,
1038 0x08001b14, 0x08001b14, 0x080019b8, 0x0, 0x08002a2c, 0x08002a7c,
1039 0x08002aac, 0x08002adc, 0x08002b0c, 0x0, 0x08005fac, 0x08005fac,
1040 0x08005fac, 0x08005fac, 0x08005fac, 0x08005fd8, 0x08005fd8, 0x08006018,
1041 0x08006024, 0x08006024, 0x08005fac, 0x0, 0x0 };
1042static u32 bnx2_COM_b09FwBss[(0x88/4) + 1] = { 0x0 };
1043static u32 bnx2_COM_b09FwSbss[(0x5c/4) + 1] = { 0x0 };
1044
1045static struct fw_info bnx2_com_fw_09 = {
1046 .ver_major = 0x1,
1047 .ver_minor = 0x0,
1048 .ver_fix = 0x0,
1049
1050 .start_addr = 0x080000b0,
1051
1052 .text_addr = 0x08000000,
1053 .text_len = 0x7c5c,
1054 .text_index = 0x0,
1055 .gz_text = bnx2_COM_b09FwText,
1056 .gz_text_len = sizeof(bnx2_COM_b09FwText),
1057
1058 .data_addr = 0x08007d00,
1059 .data_len = 0x0,
1060 .data_index = 0x0,
1061 .data = bnx2_COM_b09FwData,
1062
1063 .sbss_addr = 0x08007d00,
1064 .sbss_len = 0x5c,
1065 .sbss_index = 0x0,
1066 .sbss = bnx2_COM_b09FwSbss,
1067
1068 .bss_addr = 0x08007d60,
1069 .bss_len = 0x88,
1070 .bss_index = 0x0,
1071 .bss = bnx2_COM_b09FwBss,
1072
1073 .rodata_addr = 0x08007c60,
1074 .rodata_len = 0x88,
1075 .rodata_index = 0x0,
1076 .rodata = bnx2_COM_b09FwRodata,
1077};
1078
1079static u8 bnx2_CP_b09FwText[] = {
1080 0x1f, 0x8b, 0x08, 0x08, 0x8e, 0xfc, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
1081 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xbd, 0x7d, 0x0d, 0x74,
1082 0x5c, 0x57, 0x7d, 0xe7, 0xff, 0xdd, 0x79, 0x92, 0xc6, 0xb2, 0x2c, 0x3f,
1083 0xcb, 0x63, 0x65, 0x22, 0x0b, 0x7b, 0x46, 0x7a, 0xb2, 0x95, 0x58, 0x64,
1084 0xc7, 0xae, 0x00, 0x6d, 0x3b, 0x85, 0xe9, 0x48, 0xb2, 0x9d, 0x0f, 0x8a,
1085 0x4c, 0x44, 0x4f, 0x5a, 0xe8, 0x22, 0xc6, 0x76, 0x48, 0x80, 0xb2, 0x4e,
1086 0x09, 0x69, 0x80, 0x04, 0x0f, 0x23, 0xf9, 0x83, 0x74, 0xec, 0x51, 0x12,
1087 0xc5, 0x76, 0x4f, 0x73, 0x58, 0x55, 0x92, 0x1d, 0x43, 0xa7, 0x1e, 0x27,
1088 0x71, 0x68, 0xf6, 0x6c, 0x68, 0xb4, 0x4a, 0xe2, 0xa6, 0x3d, 0xd9, 0xd6,
1089 0xf4, 0x84, 0x6e, 0xda, 0x43, 0x77, 0x85, 0x71, 0x88, 0x4b, 0xb3, 0x4b,
1090 0xf8, 0x68, 0x61, 0xa1, 0xe5, 0xed, 0xef, 0x77, 0xef, 0x7d, 0xd2, 0xe8,
1091 0xc3, 0x09, 0xa1, 0xbb, 0xf5, 0x39, 0xcf, 0x6f, 0xde, 0xfd, 0xfc, 0xdf,
1092 0xff, 0xfd, 0x7f, 0xdf, 0x0f, 0xad, 0x17, 0xa9, 0x17, 0xfb, 0x6f, 0x15,
1093 0x9e, 0x6d, 0x89, 0x7d, 0xbb, 0xb7, 0x5e, 0xd7, 0x73, 0x1d, 0x7e, 0x6e,
1094 0x75, 0x57, 0x46, 0x95, 0xbc, 0x89, 0x7f, 0x89, 0x9f, 0xa1, 0x4c, 0x44,
1095 0xc4, 0x0b, 0xfb, 0xe2, 0x23, 0x51, 0x95, 0x1e, 0xfc, 0x64, 0xd6, 0x97,
1096 0x68, 0x24, 0x7d, 0xf6, 0xb3, 0xbb, 0x7d, 0x91, 0x4c, 0x79, 0x4b, 0xa2,
1097 0x57, 0xfe, 0x25, 0xc8, 0xc7, 0x5c, 0x61, 0xfa, 0x5b, 0xd2, 0xff, 0xfc,
1098 0x9f, 0xbe, 0xf2, 0x8e, 0xe4, 0x6b, 0xe3, 0x11, 0x89, 0x7a, 0xe9, 0x8f,
1099 0x89, 0xb7, 0x49, 0xa2, 0xad, 0xe9, 0x81, 0x4f, 0x3e, 0xbc, 0xf9, 0x6f,
1100 0x44, 0x1a, 0xc3, 0xb6, 0x2e, 0x07, 0x5f, 0xd9, 0x2c, 0xf9, 0x96, 0x74,
1101 0x7c, 0xc8, 0x4d, 0x7b, 0xf2, 0x74, 0x45, 0x06, 0x0a, 0xc5, 0xa8, 0x44,
1102 0xd2, 0x1d, 0x2f, 0xf5, 0x46, 0xf6, 0x07, 0x11, 0xdf, 0xf7, 0x7a, 0xa5,
1103 0xa1, 0x27, 0xdb, 0x8d, 0xf4, 0xf2, 0x56, 0x51, 0x7e, 0x54, 0xb2, 0x15,
1104 0x69, 0x50, 0xbe, 0x8f, 0x77, 0xbd, 0xa8, 0x74, 0xd2, 0xcb, 0x46, 0x5c,
1105 0x29, 0x54, 0x2e, 0xac, 0x30, 0x6d, 0x96, 0xec, 0xfb, 0x6f, 0xa2, 0xe6,
1106 0x8d, 0x36, 0x4b, 0x51, 0x99, 0x8d, 0xc4, 0x05, 0xfd, 0x00, 0xe6, 0x06,
1107 0x19, 0x2e, 0x25, 0x24, 0x5b, 0x64, 0xbf, 0xae, 0xe4, 0x3c, 0xf6, 0xd9,
1108 0x80, 0xfa, 0x2b, 0x9d, 0xe5, 0xcb, 0xb3, 0xec, 0x4b, 0x28, 0x9b, 0x40,
1109 0xb9, 0x56, 0x79, 0xbc, 0x12, 0x97, 0xc7, 0x2a, 0x31, 0x79, 0xb4, 0x72,
1110 0x87, 0x64, 0x50, 0xf7, 0x6c, 0x05, 0x7d, 0x97, 0x6a, 0xa5, 0x77, 0xac,
1111 0x5e, 0xb2, 0x63, 0xed, 0xf1, 0x9c, 0x04, 0xc1, 0x27, 0x52, 0x1f, 0x95,
1112 0xa1, 0x26, 0x94, 0x2f, 0x31, 0x2f, 0xbe, 0x20, 0x2f, 0x97, 0xda, 0xe2,
1113 0xe5, 0x94, 0x23, 0x99, 0xc1, 0x64, 0x7c, 0x48, 0xf1, 0xbb, 0x46, 0xb2,
1114 0x5d, 0xf8, 0x1e, 0x70, 0x25, 0xe2, 0x07, 0xc1, 0x1d, 0xa9, 0x26, 0xc0,
1115 0x91, 0x4c, 0x24, 0x14, 0xeb, 0xb2, 0x5e, 0x32, 0x9f, 0x50, 0x51, 0xc9,
1116 0x57, 0xae, 0x93, 0x44, 0x53, 0x10, 0xbc, 0x37, 0xe5, 0x21, 0x5d, 0xa4,
1117 0xb7, 0x28, 0xfb, 0x54, 0xda, 0x47, 0x9b, 0x92, 0x52, 0xe9, 0xb5, 0x18,
1118 0xc7, 0x16, 0xe0, 0xa9, 0x56, 0x32, 0x31, 0xc9, 0xa8, 0xb4, 0x24, 0x54,
1119 0x7a, 0x05, 0xd2, 0x1c, 0xa9, 0xf1, 0xa7, 0x2c, 0x9d, 0xac, 0xc6, 0xb7,
1120 0x0c, 0xa8, 0x74, 0xd3, 0xa2, 0xf4, 0x64, 0x42, 0xd4, 0x8f, 0xea, 0xd0,
1121 0x67, 0x67, 0x46, 0x31, 0x0d, 0x6f, 0x9d, 0x76, 0xfd, 0x32, 0x69, 0x1f,
1122 0x74, 0x16, 0xa6, 0x3d, 0xb5, 0x8a, 0xb0, 0x8a, 0xe2, 0xef, 0x28, 0xe0,
1123 0x6a, 0x41, 0xff, 0xed, 0x5e, 0x0d, 0xc6, 0x35, 0x90, 0x4a, 0x7a, 0xfd,
1124 0xea, 0xc5, 0x40, 0x9a, 0x09, 0x33, 0xf3, 0x14, 0xf2, 0x50, 0x34, 0x9d,
1125 0xc2, 0xbc, 0xb9, 0x72, 0x08, 0x63, 0xbb, 0x38, 0x96, 0xf4, 0xda, 0x14,
1126 0xde, 0x53, 0xfc, 0xdd, 0x34, 0x14, 0x49, 0x07, 0x41, 0x36, 0x35, 0x2e,
1127 0xb9, 0x72, 0xd2, 0x9b, 0x05, 0x70, 0xbd, 0x63, 0x71, 0x8c, 0x1f, 0xe3,
1128 0x88, 0x65, 0x92, 0x6b, 0xa4, 0xcb, 0xce, 0xcf, 0x5f, 0xa2, 0xef, 0x76,
1129 0xef, 0x0e, 0xd5, 0xee, 0xa5, 0x54, 0xd2, 0x9b, 0x90, 0x3f, 0xc4, 0x77,
1130 0x10, 0xec, 0x4a, 0x25, 0xe3, 0x79, 0xcc, 0xdd, 0xa5, 0x62, 0x4c, 0x5e,
1131 0x2e, 0x26, 0x41, 0xa9, 0xc9, 0xce, 0x49, 0xd9, 0x92, 0x9a, 0x04, 0xdc,
1132 0x05, 0x3c, 0x07, 0x99, 0x57, 0x46, 0x5e, 0x99, 0x75, 0x83, 0xe0, 0xe6,
1133 0xd4, 0x89, 0x60, 0xa8, 0xd9, 0xd0, 0xfe, 0xd3, 0x25, 0xcc, 0x2b, 0xe6,
1134 0xe9, 0xb1, 0x12, 0xe6, 0xb5, 0x84, 0x39, 0xd5, 0xf3, 0xdf, 0x89, 0xf9,
1135 0x27, 0x8d, 0x90, 0x3e, 0xb6, 0x59, 0x7a, 0x7d, 0xb7, 0x7d, 0x8b, 0x64,
1136 0x4b, 0x8e, 0x64, 0x53, 0x3f, 0x09, 0x32, 0x9a, 0x27, 0xc4, 0xe9, 0x2d,
1137 0x91, 0x26, 0x6b, 0x00, 0x2b, 0x3f, 0x7f, 0xdd, 0x96, 0x8b, 0x3a, 0x18,
1138 0x06, 0xe7, 0x83, 0xf9, 0x51, 0xe5, 0xd7, 0xd9, 0xfc, 0x90, 0xf6, 0xf9,
1139 0x0f, 0x74, 0xe7, 0xcf, 0x97, 0xcb, 0x92, 0x36, 0x2b, 0x22, 0xb9, 0x07,
1140 0x03, 0xe9, 0x4d, 0x01, 0x5f, 0x6c, 0xd3, 0x4b, 0x89, 0xae, 0xeb, 0xb1,
1141 0x8c, 0x2e, 0x8b, 0x7f, 0x3f, 0xae, 0x41, 0x1f, 0x4e, 0x5f, 0x69, 0xbe,
1142 0x6e, 0x5f, 0xe9, 0x85, 0x98, 0x85, 0x0f, 0xdf, 0x3d, 0x4e, 0xb6, 0xf2,
1143 0x77, 0x76, 0x8e, 0xc3, 0x71, 0x74, 0x2d, 0x43, 0xe3, 0x2e, 0xf8, 0xc1,
1144 0x93, 0x5c, 0xb1, 0x07, 0xfd, 0xc6, 0xf0, 0x0e, 0x82, 0x91, 0x54, 0x26,
1145 0xe9, 0x4a, 0x1a, 0xdf, 0x03, 0x98, 0xaf, 0x0e, 0xe0, 0x4f, 0xdc, 0xec,
1146 0xe6, 0x94, 0xf4, 0x55, 0x40, 0x7b, 0x95, 0x37, 0x96, 0x14, 0x7a, 0x0c,
1147 0xa9, 0x7f, 0xb1, 0xb8, 0x61, 0x3f, 0x7c, 0xbb, 0x32, 0x02, 0xfa, 0x28,
1148 0x8c, 0xf9, 0x32, 0x5c, 0x9c, 0xf6, 0x94, 0x24, 0x41, 0xbb, 0x69, 0xe9,
1149 0xad, 0xf8, 0x52, 0x28, 0xe2, 0x5d, 0x6a, 0x07, 0xfd, 0xba, 0x92, 0x89,
1150 0x9b, 0x39, 0x29, 0x14, 0x7f, 0x09, 0xe3, 0x02, 0x8e, 0x7d, 0xfe, 0xee,
1151 0xb1, 0xb0, 0x80, 0xf7, 0xbb, 0x53, 0x1a, 0x3f, 0x6f, 0x0e, 0x06, 0xf6,
1152 0x8d, 0x31, 0x60, 0x9c, 0x85, 0xb2, 0x8b, 0x77, 0x0c, 0xef, 0x90, 0x16,
1153 0xe3, 0x80, 0xa9, 0x55, 0x86, 0x41, 0x8b, 0xbd, 0x82, 0xdf, 0x53, 0x84,
1154 0x91, 0xfd, 0xb6, 0xe8, 0xdf, 0xc3, 0x63, 0x1b, 0xf4, 0x77, 0x6e, 0xa0,
1155 0x45, 0xf2, 0x53, 0xe1, 0x58, 0x28, 0x0f, 0x28, 0x03, 0x92, 0x87, 0x45,
1156 0x28, 0x13, 0x82, 0xe0, 0xc1, 0x14, 0xe5, 0x42, 0x10, 0x3c, 0x96, 0xa2,
1157 0x9c, 0x38, 0x07, 0xfe, 0xa7, 0x6c, 0x20, 0xaf, 0xae, 0x55, 0x9c, 0x83,
1158 0x6c, 0x11, 0x7d, 0x40, 0x4e, 0xe4, 0xba, 0x4e, 0x40, 0x6e, 0x50, 0xae,
1159 0x5c, 0xf8, 0x44, 0xd6, 0xcf, 0xc7, 0x23, 0x1a, 0x0f, 0x98, 0x6f, 0xc8,
1160 0xbc, 0x8c, 0x86, 0xbc, 0x4d, 0x0a, 0x5d, 0xa3, 0xb6, 0xcc, 0x65, 0x5d,
1161 0xc6, 0x5d, 0x52, 0xe6, 0x76, 0x65, 0xf8, 0xae, 0x15, 0xf3, 0xb1, 0x42,
1162 0x11, 0x4f, 0x6d, 0x9b, 0xf8, 0x2d, 0xd1, 0x9a, 0xf4, 0x97, 0x90, 0x37,
1163 0x7d, 0xd7, 0x49, 0x7f, 0xb9, 0xbc, 0x59, 0x77, 0x69, 0xde, 0x88, 0xb8,
1164 0x7e, 0xb2, 0x73, 0x97, 0x9a, 0x01, 0x3d, 0x05, 0xc1, 0xc9, 0x54, 0x98,
1165 0xfe, 0x8f, 0xee, 0xd2, 0x3e, 0x12, 0x35, 0x4b, 0xd3, 0xee, 0x5d, 0x26,
1166 0xed, 0xc4, 0x32, 0x69, 0x1b, 0x6a, 0x97, 0xa6, 0xbd, 0x7f, 0x99, 0xb4,
1167 0xfb, 0x97, 0x49, 0xfb, 0x5f, 0xcb, 0xa4, 0x7d, 0x67, 0x99, 0xb4, 0xef,
1168 0x2d, 0x93, 0xd6, 0x52, 0xb7, 0x34, 0xcd, 0x05, 0x3f, 0x6d, 0x92, 0x42,
1169 0xec, 0x73, 0x1c, 0xbb, 0xc5, 0xcd, 0xfe, 0xc8, 0x52, 0xdc, 0xd4, 0xa0,
1170 0x5c, 0xeb, 0xa2, 0x72, 0x53, 0xcb, 0x94, 0xab, 0x45, 0xb9, 0xa6, 0x45,
1171 0xe5, 0x92, 0xcb, 0xe0, 0xba, 0x4e, 0xeb, 0xaf, 0x85, 0xe5, 0x0a, 0xcb,
1172 0x94, 0x63, 0xfa, 0x1e, 0xdb, 0xcf, 0x16, 0x68, 0x99, 0xd7, 0x9b, 0xaf,
1173 0x5a, 0x91, 0x66, 0xa6, 0xb7, 0x42, 0x47, 0xac, 0x50, 0x86, 0xdf, 0x29,
1174 0x5b, 0x98, 0xe6, 0x81, 0xee, 0xa3, 0xa0, 0x3b, 0xca, 0x47, 0xf0, 0x91,
1175 0x4f, 0xfe, 0x5d, 0x25, 0x43, 0xb1, 0x2d, 0xde, 0x2f, 0xa8, 0x06, 0xd0,
1176 0x58, 0xd2, 0x4b, 0x28, 0xf2, 0x97, 0xe4, 0x23, 0x69, 0x3f, 0xdf, 0x2b,
1177 0x2a, 0xa6, 0x24, 0x90, 0xbe, 0x94, 0x6a, 0x52, 0xb2, 0x1f, 0xfc, 0x93,
1178 0x81, 0x4e, 0xda, 0x15, 0xf4, 0x6a, 0x1e, 0x32, 0x65, 0xaf, 0x2c, 0x2b,
1179 0x7d, 0x39, 0x48, 0x19, 0x97, 0xce, 0xdc, 0x95, 0xf5, 0xa7, 0x7b, 0x6a,
1180 0x41, 0xb3, 0x17, 0x51, 0x67, 0x07, 0x6a, 0xee, 0x2d, 0xbb, 0xd2, 0x57,
1181 0xee, 0x04, 0x2f, 0x38, 0x72, 0xde, 0x5f, 0x2d, 0xe7, 0x53, 0x28, 0x5b,
1182 0x89, 0xc8, 0x4c, 0xcc, 0x91, 0x19, 0x7c, 0x67, 0x53, 0xc8, 0xab, 0x84,
1183 0xbc, 0xd5, 0x29, 0x07, 0x4a, 0xbe, 0x1c, 0x2e, 0xfd, 0x92, 0x0a, 0xf5,
1184 0x56, 0x7f, 0x6a, 0xa5, 0x9c, 0xf6, 0x4c, 0xdb, 0x3b, 0xfc, 0x69, 0x68,
1185 0x4c, 0x57, 0x2e, 0xfa, 0xc9, 0xf8, 0x8c, 0xe6, 0x89, 0x1f, 0x06, 0x7d,
1186 0x68, 0x67, 0xc2, 0x4f, 0x7a, 0x7f, 0x8a, 0xef, 0xa1, 0x32, 0xed, 0x90,
1187 0xf9, 0xb6, 0x86, 0xd1, 0xd6, 0xa1, 0xd2, 0x2a, 0xf9, 0xb0, 0xad, 0xbf,
1188 0xdd, 0x9f, 0xee, 0x04, 0xcf, 0x79, 0xa7, 0x28, 0x23, 0x8a, 0x80, 0x6b,
1189 0x10, 0xbc, 0x8d, 0xba, 0xcf, 0x69, 0x39, 0x05, 0xbb, 0xa5, 0xb8, 0x1a,
1190 0x72, 0xf7, 0x1f, 0x83, 0x0f, 0xc7, 0x58, 0x9e, 0x69, 0xd4, 0x25, 0x32,
1191 0xaa, 0xd2, 0x90, 0x09, 0xdd, 0x94, 0x85, 0x09, 0xc8, 0x41, 0xc8, 0x96,
1192 0xd2, 0x4f, 0x83, 0x8c, 0x5b, 0x2d, 0xdf, 0x24, 0x3f, 0x5f, 0x86, 0x69,
1193 0x09, 0x23, 0x2f, 0x4b, 0xb3, 0x73, 0xb2, 0x22, 0x0f, 0xf9, 0xf2, 0x74,
1194 0x85, 0x72, 0xe1, 0x7a, 0xf0, 0x68, 0xab, 0xf4, 0x15, 0x93, 0xf9, 0x8c,
1195 0x6c, 0xc2, 0xfc, 0x7d, 0x1e, 0x73, 0xea, 0xe2, 0xb9, 0xaf, 0x5e, 0x1a,
1196 0x53, 0xd0, 0xcd, 0x4c, 0x47, 0xa3, 0xcd, 0x51, 0xc8, 0xa8, 0xdf, 0x03,
1197 0x1e, 0x86, 0x39, 0xe7, 0xf1, 0x6c, 0xc4, 0x19, 0xa0, 0x3d, 0x32, 0x40,
1198 0xfd, 0x50, 0x66, 0xdb, 0x84, 0x37, 0x6e, 0x7f, 0x47, 0xb5, 0x8c, 0x31,
1199 0xbf, 0x1b, 0xf0, 0x3b, 0x61, 0x7f, 0x7b, 0xf8, 0xed, 0xdb, 0xdf, 0x31,
1200 0xfc, 0xee, 0xb4, 0xbf, 0xa1, 0x5b, 0x8b, 0x5d, 0xfa, 0xf7, 0x48, 0x69,
1201 0xfb, 0x76, 0xe5, 0x5f, 0x27, 0xb9, 0xa9, 0x56, 0x39, 0x50, 0xf4, 0xad,
1202 0x6c, 0xc1, 0x23, 0x4f, 0x3a, 0x66, 0x9c, 0x80, 0x9b, 0xb2, 0xb3, 0x94,
1203 0x77, 0x06, 0x08, 0x3f, 0x68, 0xa0, 0xb7, 0xb8, 0xc5, 0x5b, 0x23, 0xa4,
1204 0x81, 0x11, 0xa7, 0xb7, 0xe2, 0x64, 0x60, 0xaf, 0xc5, 0x87, 0xe5, 0x30,
1205 0x7e, 0x8b, 0x17, 0x49, 0x3f, 0x89, 0xb7, 0xc1, 0x01, 0xf5, 0xce, 0x70,
1206 0x89, 0xf2, 0xd2, 0xc7, 0xd8, 0x13, 0x72, 0x6e, 0x81, 0x0d, 0x45, 0x5c,
1207 0x28, 0xc9, 0x8d, 0x25, 0x4f, 0xe4, 0x25, 0x99, 0x1f, 0x07, 0x43, 0xec,
1208 0x4a, 0xb9, 0xf2, 0xde, 0x14, 0x68, 0xf7, 0x3a, 0x47, 0xb6, 0x5f, 0xe7,
1209 0xc2, 0xe6, 0xf1, 0xc7, 0xb7, 0x83, 0xfe, 0x31, 0xcf, 0x9a, 0x1e, 0xd4,
1210 0x19, 0x81, 0x9d, 0x08, 0x6c, 0x9f, 0xe9, 0xea, 0x1b, 0x2e, 0xe6, 0x3e,
1211 0xa6, 0xd2, 0xfb, 0x3e, 0x95, 0xed, 0xbe, 0x46, 0x72, 0x83, 0x0a, 0x38,
1212 0x6a, 0x1e, 0x82, 0x1e, 0xc4, 0xb8, 0x82, 0x00, 0xf4, 0x0c, 0x79, 0x7e,
1213 0xf3, 0xcd, 0x91, 0x74, 0x8d, 0xf4, 0x0e, 0x36, 0xa3, 0x0e, 0xf3, 0x88,
1214 0xaf, 0xaf, 0xa2, 0x9d, 0x64, 0xa2, 0x4f, 0xe4, 0x9e, 0x91, 0xee, 0x59,
1215 0x67, 0x78, 0xf4, 0x37, 0xc0, 0x93, 0x5b, 0x51, 0xff, 0x01, 0xd4, 0x7f,
1216 0xcd, 0x29, 0x8c, 0xfd, 0xc8, 0x19, 0x1e, 0xfb, 0x9e, 0x33, 0x32, 0xb6,
1217 0x61, 0x43, 0x7f, 0xcf, 0x86, 0x0d, 0xbb, 0x7b, 0x5c, 0x99, 0x00, 0x8f,
1218 0x65, 0xbc, 0x0d, 0x1b, 0x46, 0x7a, 0xba, 0x80, 0x83, 0x2d, 0x5e, 0x9f,
1219 0xf8, 0xde, 0x76, 0x01, 0xff, 0xc4, 0xd8, 0x67, 0x14, 0xf9, 0x49, 0xe4,
1220 0xb3, 0x7e, 0x5c, 0xe7, 0xf7, 0xca, 0x96, 0x78, 0x93, 0xb0, 0xff, 0x88,
1221 0x2d, 0x53, 0x13, 0x91, 0xfa, 0x07, 0xec, 0xfc, 0x66, 0x9c, 0x1a, 0x9f,
1222 0xe9, 0x1c, 0x0b, 0xd3, 0x39, 0xb7, 0x7f, 0x67, 0x6d, 0xd5, 0xd5, 0x48,
1223 0xe7, 0x37, 0x71, 0x46, 0xbc, 0xd0, 0xc6, 0xa8, 0xd1, 0xb6, 0x61, 0xae,
1224 0x48, 0x9a, 0x71, 0x65, 0x4f, 0xd1, 0x41, 0x1d, 0xd0, 0xc5, 0x19, 0xfb,
1225 0x1c, 0x05, 0x6c, 0x83, 0x68, 0xeb, 0xe8, 0x21, 0xd4, 0xa3, 0xcc, 0x48,
1226 0x76, 0x8a, 0xfa, 0x00, 0xca, 0x6c, 0xf1, 0xd6, 0x0a, 0x6d, 0x89, 0x3b,
1227 0x25, 0x57, 0x22, 0x7f, 0x77, 0x00, 0x9e, 0xa8, 0x24, 0x9a, 0xf1, 0x5d,
1228 0x81, 0x4d, 0xf1, 0x60, 0x8d, 0x58, 0xdb, 0x45, 0xe6, 0x6d, 0x91, 0x3b,
1229 0x94, 0xc0, 0xde, 0x18, 0x9a, 0x5c, 0x8f, 0x72, 0x0e, 0xf0, 0x42, 0xfb,
1230 0x03, 0xb4, 0x36, 0x99, 0x91, 0xec, 0x26, 0xf0, 0xc9, 0xa4, 0x87, 0x6f,
1231 0xc0, 0x35, 0xf9, 0x16, 0xbc, 0x23, 0xfa, 0xdb, 0xc0, 0x09, 0xbc, 0xa6,
1232 0x22, 0x56, 0x67, 0x75, 0xa1, 0xef, 0xf7, 0x48, 0x76, 0x34, 0x4e, 0x5b,
1233 0x62, 0x75, 0xd6, 0xcf, 0x40, 0xd7, 0x2b, 0x28, 0x41, 0x8c, 0x61, 0xd2,
1234 0x81, 0x3c, 0xa9, 0x95, 0xdd, 0x8f, 0xe0, 0xf7, 0x83, 0xc6, 0xe6, 0xdd,
1235 0x3d, 0xc9, 0x7e, 0x1a, 0x00, 0x13, 0x6c, 0x90, 0x47, 0x60, 0x9b, 0x3e,
1236 0x02, 0x1b, 0xe4, 0x91, 0x66, 0x3c, 0x1c, 0x1b, 0xdb, 0x9f, 0x59, 0x03,
1237 0x31, 0xa9, 0xbf, 0x73, 0xa4, 0x57, 0xd8, 0xea, 0xb9, 0x62, 0xca, 0x94,
1238 0x2f, 0x76, 0xeb, 0xb7, 0xa1, 0xeb, 0x1e, 0xfb, 0x3b, 0xae, 0xf9, 0x3a,
1239 0xdf, 0x04, 0x9a, 0xaf, 0x74, 0x69, 0x99, 0x93, 0xf5, 0xf1, 0x86, 0xcd,
1240 0x99, 0x69, 0xe2, 0x18, 0xe3, 0x36, 0x2d, 0xae, 0xd3, 0x12, 0x4d, 0xd6,
1241 0xde, 0x28, 0x59, 0x5b, 0x03, 0xb8, 0x19, 0x6a, 0x06, 0xc4, 0x94, 0xcf,
1242 0x12, 0xe2, 0x93, 0x32, 0x00, 0xf4, 0x0b, 0x9b, 0xe2, 0xdc, 0x15, 0xe5,
1243 0xdf, 0xac, 0xb6, 0xb1, 0xce, 0x56, 0x48, 0xc7, 0xa4, 0xed, 0x20, 0xb8,
1244 0x3f, 0x55, 0x87, 0xf6, 0xc9, 0xf3, 0xb0, 0x40, 0x8e, 0x02, 0x26, 0x60,
1245 0xa2, 0xc6, 0x3f, 0xab, 0x69, 0xa0, 0xd6, 0x27, 0x0d, 0x57, 0xf3, 0x97,
1246 0xe8, 0xf1, 0x9e, 0x05, 0x8f, 0xc1, 0xbe, 0x81, 0xfd, 0xd6, 0x01, 0xdb,
1247 0x98, 0x7d, 0x1c, 0xe6, 0xb7, 0xa7, 0xc0, 0x53, 0xd9, 0x39, 0x9e, 0x12,
1248 0x99, 0x28, 0x12, 0x37, 0xa1, 0x5d, 0xc7, 0x79, 0x26, 0x7e, 0x32, 0x18,
1249 0x33, 0xdf, 0x7d, 0x16, 0x4f, 0x3b, 0x2d, 0x9e, 0x6e, 0xb2, 0xef, 0x11,
1250 0xbc, 0x69, 0xe3, 0x0d, 0xe0, 0xcd, 0xf9, 0x19, 0xc4, 0x9b, 0xbc, 0x75,
1251 0x0b, 0xde, 0x28, 0x5b, 0xca, 0xc8, 0x6e, 0x6d, 0x87, 0x45, 0xe4, 0x57,
1252 0xb4, 0x6c, 0xfb, 0x02, 0xe6, 0xb2, 0x48, 0xfa, 0x95, 0x7c, 0x2c, 0x02,
1253 0x9c, 0x14, 0xf0, 0xfb, 0x4e, 0xd7, 0xd0, 0x2a, 0x71, 0xb2, 0xc0, 0x57,
1254 0xaa, 0x82, 0x29, 0x66, 0xe5, 0x5c, 0x42, 0xdb, 0xfa, 0xb9, 0xe2, 0x07,
1255 0x34, 0x5c, 0xb7, 0x42, 0xde, 0xe5, 0x45, 0x35, 0x43, 0x37, 0x80, 0x16,
1256 0x54, 0x0c, 0x9a, 0x2b, 0x78, 0x06, 0x7a, 0x29, 0x37, 0x49, 0xdb, 0xb8,
1257 0x8d, 0x7e, 0x49, 0x34, 0xd7, 0xd5, 0x48, 0x3a, 0x52, 0x0a, 0xf6, 0x17,
1258 0xbe, 0x55, 0xae, 0x4b, 0xd3, 0xa9, 0xa3, 0xfc, 0x98, 0xb6, 0x7f, 0x5d,
1259 0x1f, 0xd2, 0xd6, 0xf8, 0xbd, 0xae, 0xf2, 0xd7, 0x2e, 0x4e, 0x4b, 0x50,
1260 0x0f, 0xa3, 0x5e, 0x22, 0xd7, 0xd5, 0x4c, 0x1e, 0xf3, 0x40, 0xbf, 0x19,
1261 0xe5, 0x6b, 0xdf, 0x27, 0xaf, 0xba, 0x57, 0x2f, 0x2a, 0xaf, 0xdf, 0x8e,
1262 0xfd, 0x76, 0xed, 0xdb, 0xb3, 0xef, 0x84, 0x7d, 0xe7, 0xdd, 0x6e, 0xbe,
1263 0x1d, 0x71, 0xd3, 0x7c, 0x83, 0x92, 0xd3, 0x6c, 0x43, 0xf3, 0x95, 0x95,
1264 0x33, 0x1d, 0x5e, 0x41, 0xc8, 0x57, 0x9f, 0x93, 0x5b, 0x27, 0x8d, 0xfc,
1265 0xdd, 0x0e, 0x19, 0x04, 0xff, 0xcc, 0x9b, 0x11, 0xc0, 0x3f, 0x98, 0x96,
1266 0x5b, 0x2b, 0xc4, 0xdb, 0xef, 0x02, 0x7f, 0x60, 0xe2, 0x7a, 0xea, 0x74,
1267 0xca, 0xdd, 0x3b, 0x61, 0xf7, 0xa2, 0x7c, 0x91, 0x38, 0x1f, 0xd2, 0x73,
1268 0x53, 0x28, 0xee, 0xd1, 0x73, 0x73, 0xb0, 0x38, 0x03, 0xfc, 0xdc, 0x06,
1269 0xba, 0x0f, 0x82, 0x99, 0x54, 0x01, 0x94, 0xf3, 0x11, 0xfc, 0x86, 0x1d,
1270 0x50, 0xfc, 0x18, 0xf2, 0x1b, 0xa5, 0x30, 0x4a, 0x9e, 0x73, 0x2d, 0x0f,
1271 0xbf, 0x13, 0xfc, 0x14, 0x45, 0xbb, 0x48, 0xeb, 0xe6, 0xef, 0x9f, 0x20,
1272 0x0f, 0xef, 0x49, 0x4c, 0x62, 0x33, 0x6d, 0x1d, 0xf6, 0xcd, 0xb9, 0xe3,
1273 0x9c, 0xc5, 0xb4, 0x2c, 0x3f, 0x3b, 0x37, 0x6f, 0x97, 0xe7, 0xe8, 0x36,
1274 0x4f, 0x1f, 0x8f, 0xf9, 0x1a, 0x56, 0xd2, 0xfd, 0xb7, 0xb4, 0x5c, 0x72,
1275 0x8f, 0xce, 0xac, 0x30, 0xef, 0xc5, 0x75, 0x39, 0xe7, 0xd5, 0x34, 0x48,
1276 0xbf, 0x25, 0xd9, 0x93, 0x07, 0x3f, 0x61, 0x9c, 0xd2, 0xa7, 0x7d, 0x1d,
1277 0xd2, 0x04, 0x69, 0x60, 0xdc, 0xd2, 0xe6, 0x94, 0xa5, 0xcd, 0x27, 0xf1,
1278 0xc6, 0x53, 0xba, 0x60, 0x69, 0xf3, 0x29, 0xbc, 0xf1, 0x94, 0x5e, 0x9c,
1279 0xe3, 0xe3, 0x5e, 0xf8, 0x72, 0xdb, 0xa1, 0xdf, 0x76, 0x57, 0x40, 0xbf,
1280 0xe0, 0xbb, 0x1c, 0x7c, 0x80, 0x5c, 0x69, 0x1f, 0xde, 0xec, 0x67, 0xa3,
1281 0x6d, 0x3f, 0x23, 0x7b, 0x4a, 0x01, 0xc6, 0x78, 0x37, 0xc6, 0xfb, 0x39,
1282 0xbc, 0x3f, 0xa3, 0xe5, 0x8c, 0xf2, 0x0f, 0x5b, 0x79, 0xf5, 0x79, 0xbc,
1283 0xdb, 0xe3, 0x07, 0xa5, 0xdd, 0x8b, 0xc8, 0x34, 0xda, 0xfa, 0xba, 0xec,
1284 0xa9, 0xcc, 0xe2, 0xb9, 0x84, 0xe7, 0x55, 0x3c, 0x97, 0xd1, 0xde, 0x0b,
1285 0x48, 0x5f, 0x29, 0xd3, 0x5e, 0x3d, 0xca, 0xbf, 0x86, 0xdf, 0xcf, 0xcb,
1286 0xd0, 0x23, 0x2f, 0xe1, 0xf9, 0x01, 0xf2, 0x9f, 0x45, 0xfd, 0x60, 0xf5,
1287 0x8c, 0x4f, 0x19, 0xf6, 0x9c, 0x6d, 0x3b, 0xe5, 0xe4, 0x2a, 0xa0, 0xe9,
1288 0xd2, 0x00, 0xfa, 0xde, 0xa3, 0x79, 0xa6, 0x0f, 0x32, 0x3f, 0x07, 0x19,
1289 0x37, 0xa4, 0x61, 0x6a, 0x07, 0x7c, 0x79, 0xcc, 0x05, 0xde, 0x93, 0xb5,
1290 0x32, 0x1b, 0xa3, 0x1d, 0x79, 0x93, 0x2e, 0x9f, 0x2b, 0x35, 0x69, 0xbb,
1291 0x7a, 0x7c, 0x09, 0xff, 0xd0, 0xef, 0x0a, 0xe5, 0x81, 0x91, 0xc6, 0x13,
1292 0x45, 0xca, 0x02, 0xe8, 0x9f, 0xe2, 0x08, 0xde, 0xb5, 0x5a, 0x26, 0x14,
1293 0x24, 0x94, 0x07, 0xac, 0x47, 0x99, 0x50, 0x2d, 0x77, 0x28, 0x6b, 0x28,
1294 0x7b, 0x28, 0x4b, 0xcc, 0x7c, 0xec, 0x7e, 0x90, 0x32, 0x1c, 0xb4, 0x10,
1295 0xa3, 0xfd, 0xe1, 0x19, 0x1f, 0x64, 0xec, 0x3e, 0x2b, 0x4f, 0x47, 0xf5,
1296 0x5c, 0xec, 0x29, 0xaa, 0x98, 0x2b, 0xa7, 0x91, 0x86, 0xe7, 0xf8, 0xc3,
1297 0x78, 0x7f, 0x49, 0xf6, 0xe0, 0xc9, 0x1d, 0xff, 0x02, 0x7e, 0x73, 0x6e,
1298 0xca, 0x28, 0x87, 0xa7, 0x74, 0x02, 0x6f, 0x3c, 0xa5, 0x31, 0x2b, 0x47,
1299 0xc6, 0xad, 0x1c, 0xe1, 0x9c, 0xde, 0x04, 0x3c, 0x70, 0x7c, 0x4a, 0xc7,
1300 0x17, 0xc0, 0xcf, 0x4e, 0x6e, 0xf2, 0x5d, 0xd6, 0x8f, 0x6d, 0x14, 0xc3,
1301 0x83, 0x78, 0x3a, 0xc9, 0xcf, 0x0d, 0xda, 0x0e, 0xce, 0x69, 0xda, 0xfd,
1302 0x2b, 0xd7, 0xf0, 0x62, 0xcc, 0xe8, 0x14, 0xaf, 0x59, 0x34, 0xef, 0xcf,
1303 0xe1, 0x31, 0x63, 0xf1, 0xc8, 0xdf, 0xca, 0xfe, 0x86, 0xdc, 0x82, 0x4d,
1304 0x9b, 0xf5, 0x7d, 0xcc, 0x03, 0xc6, 0x72, 0x7c, 0x14, 0x7d, 0x3b, 0xb2,
1305 0xdb, 0xa7, 0x0c, 0x67, 0x0c, 0x81, 0xe3, 0x63, 0xbb, 0x48, 0xd7, 0x38,
1306 0x48, 0xc9, 0xbc, 0x6f, 0x7e, 0x13, 0xe6, 0x2c, 0x23, 0x7b, 0x4b, 0xf7,
1307 0x6a, 0x5f, 0xb9, 0xf6, 0x68, 0x93, 0xf5, 0x73, 0xc2, 0x72, 0xa0, 0xd5,
1308 0x18, 0x6d, 0x9b, 0x2f, 0xc5, 0x0c, 0xcd, 0xf3, 0x37, 0xe5, 0x73, 0xb5,
1309 0xbc, 0x37, 0x76, 0x4d, 0x61, 0x81, 0xac, 0xa3, 0x6d, 0x81, 0x39, 0x2b,
1310 0x57, 0xe3, 0x9d, 0xbe, 0x3b, 0xf9, 0x8a, 0xfc, 0x74, 0x10, 0x3c, 0xf1,
1311 0x5d, 0xcb, 0xfb, 0xf4, 0x35, 0xd8, 0xe7, 0x62, 0x7e, 0xf2, 0x60, 0xfb,
1312 0xba, 0x72, 0x0a, 0xb6, 0xdb, 0xf6, 0xb9, 0x36, 0xae, 0x06, 0x3c, 0x51,
1313 0x79, 0xa4, 0xd8, 0x20, 0x93, 0x45, 0xd5, 0x1c, 0xb1, 0xb2, 0x33, 0x22,
1314 0x09, 0x4d, 0xdf, 0xb4, 0xef, 0x7a, 0xc7, 0x22, 0x96, 0xee, 0xd6, 0xd5,
1315 0x48, 0xfd, 0xef, 0x42, 0xc7, 0xa6, 0xa1, 0x63, 0x1b, 0xa1, 0x83, 0x17,
1316 0xcb, 0x88, 0x35, 0x35, 0x4b, 0x65, 0x04, 0xeb, 0x24, 0xe1, 0x75, 0x1f,
1317 0x44, 0xbd, 0x90, 0xfe, 0xa2, 0x9a, 0xd6, 0x72, 0x92, 0x77, 0xb6, 0x57,
1318 0x46, 0x9c, 0x1d, 0x95, 0xc5, 0x3a, 0x68, 0x8b, 0xe7, 0x8a, 0x81, 0xf5,
1319 0x91, 0x22, 0x6d, 0xd4, 0x64, 0x2a, 0x0b, 0x9c, 0xec, 0x00, 0xcc, 0xcf,
1320 0x8c, 0xc2, 0x4f, 0xa7, 0x5c, 0x06, 0xcc, 0xa7, 0x01, 0xf3, 0xc4, 0xa8,
1321 0x13, 0xda, 0x06, 0xc2, 0xa0, 0xc8, 0xc4, 0x58, 0x97, 0xcc, 0x4c, 0x91,
1322 0x0e, 0x21, 0x03, 0x46, 0x31, 0x9f, 0xa9, 0x15, 0xb0, 0x03, 0xd8, 0x3f,
1323 0xe4, 0xf6, 0x58, 0x8b, 0xce, 0x33, 0xfa, 0xbc, 0x55, 0x66, 0xca, 0x69,
1324 0x0b, 0xdb, 0xe1, 0x2a, 0xd8, 0x56, 0xcc, 0xc1, 0xb6, 0x03, 0xb0, 0xed,
1325 0x5c, 0x16, 0xb6, 0xe5, 0x74, 0x71, 0x1b, 0x6c, 0x1a, 0xa3, 0x8b, 0x0d,
1326 0x5e, 0x9b, 0x2d, 0x3d, 0xbc, 0xdf, 0xda, 0xbb, 0xb4, 0x89, 0x7e, 0x0a,
1327 0x78, 0x48, 0x63, 0xf8, 0x3d, 0x79, 0x2f, 0x65, 0x19, 0xd2, 0xf9, 0xbd,
1328 0x07, 0x65, 0xf0, 0x3d, 0xf9, 0x67, 0x2b, 0x4c, 0xd9, 0xbb, 0x2d, 0x2c,
1329 0xb4, 0x13, 0x32, 0xb0, 0x89, 0xfb, 0x9c, 0xec, 0x24, 0x61, 0xf8, 0x8f,
1330 0x80, 0x17, 0x79, 0x95, 0xea, 0x36, 0xf9, 0x66, 0xbb, 0xd7, 0xda, 0x76,
1331 0xd8, 0x76, 0x38, 0x96, 0x95, 0x56, 0xcf, 0x87, 0xf4, 0x15, 0xda, 0xd7,
1332 0x23, 0x4e, 0x66, 0xc9, 0xb8, 0xaa, 0x69, 0x8e, 0xf2, 0xd6, 0x95, 0x7e,
1333 0xd0, 0x49, 0xff, 0x02, 0x5a, 0x33, 0x72, 0xc3, 0xd0, 0xf1, 0x0a, 0x3b,
1334 0xbe, 0x1a, 0xc3, 0x37, 0xa9, 0x28, 0xf4, 0x21, 0xe5, 0xcd, 0x0e, 0xe3,
1335 0x9b, 0xcb, 0x43, 0x80, 0x35, 0xfc, 0x3e, 0xa8, 0x6d, 0xce, 0xa7, 0x4b,
1336 0x94, 0x49, 0xf3, 0xb4, 0x68, 0x7c, 0x97, 0x56, 0xf4, 0x55, 0x6d, 0xaf,
1337 0xbb, 0x32, 0x60, 0xe6, 0xfc, 0x30, 0xe7, 0x9c, 0xbe, 0x48, 0xfb, 0x03,
1338 0x03, 0x96, 0xbf, 0x92, 0xa3, 0x79, 0x79, 0xbb, 0x1d, 0xfb, 0x1f, 0x2e,
1339 0x33, 0x77, 0x8d, 0x73, 0x73, 0x37, 0x50, 0x59, 0x3c, 0x46, 0x91, 0xb6,
1340 0x07, 0x58, 0xcf, 0x85, 0x8d, 0x94, 0x92, 0x5a, 0x9f, 0xf2, 0x93, 0xb6,
1341 0x12, 0xd2, 0x27, 0xb6, 0x78, 0x4d, 0xf0, 0x01, 0x9e, 0x5e, 0x62, 0x77,
1342 0x25, 0xac, 0xdc, 0xa4, 0x1f, 0x1c, 0xf6, 0x91, 0xb7, 0x72, 0x32, 0x8f,
1343 0xf6, 0x47, 0x9c, 0xfe, 0xca, 0x72, 0xf2, 0x32, 0x94, 0x93, 0x1c, 0x8f,
1344 0x23, 0x77, 0x3c, 0x48, 0x1e, 0x7d, 0xbf, 0xb6, 0xaf, 0xb7, 0x6e, 0xab,
1345 0x01, 0xfe, 0x08, 0xc7, 0xcc, 0x1a, 0xa2, 0x33, 0xf7, 0x08, 0x6c, 0x22,
1346 0x3b, 0x6f, 0xbb, 0xe7, 0xe6, 0x5f, 0xd3, 0x05, 0x7e, 0x33, 0x8e, 0x6a,
1347 0x68, 0xa4, 0xc6, 0x77, 0x34, 0x2d, 0xd4, 0x2e, 0xb1, 0x65, 0x39, 0x06,
1348 0xda, 0xb3, 0xb5, 0xc6, 0x16, 0x2c, 0xd1, 0xfe, 0xa4, 0xec, 0xa2, 0xfd,
1349 0xf9, 0x43, 0xe0, 0x88, 0xe3, 0xe9, 0xb2, 0x69, 0xb4, 0x53, 0x17, 0x8f,
1350 0x6f, 0xb1, 0xff, 0x48, 0x38, 0x09, 0xb7, 0xa1, 0xad, 0x84, 0x22, 0x6c,
1351 0x81, 0x0c, 0x80, 0x97, 0x39, 0x07, 0x8a, 0xb6, 0xeb, 0xb6, 0xbf, 0xa8,
1352 0x31, 0x31, 0xe4, 0xd5, 0xb5, 0x52, 0xcf, 0x3e, 0xc9, 0x7f, 0x7c, 0xaf,
1353 0xd2, 0xf6, 0xef, 0x52, 0x59, 0x56, 0xad, 0x7b, 0xae, 0x9e, 0xc3, 0x5f,
1354 0xff, 0x82, 0x39, 0x0a, 0xf1, 0x17, 0xd2, 0x45, 0x35, 0x0e, 0x49, 0x13,
1355 0x86, 0x16, 0x0c, 0x2d, 0x6e, 0xb4, 0xfa, 0x26, 0xa4, 0xbd, 0xab, 0x40,
1356 0x7b, 0xf7, 0x81, 0xc6, 0x28, 0xc3, 0x19, 0x97, 0x5b, 0x8b, 0xef, 0x23,
1357 0xf8, 0x0e, 0xf9, 0xe4, 0x4a, 0x32, 0x9c, 0xf2, 0x9b, 0x75, 0xb2, 0x56,
1358 0xee, 0x87, 0x7e, 0x2e, 0xeb, 0x70, 0xdc, 0x94, 0xff, 0xff, 0x15, 0xed,
1359 0xac, 0xad, 0x35, 0xf6, 0xca, 0x8d, 0xb5, 0x94, 0xaf, 0x6b, 0xe4, 0x60,
1360 0x55, 0xda, 0x95, 0xe4, 0x77, 0xf5, 0x98, 0xd7, 0xff, 0x3f, 0x18, 0x73,
1361 0x7c, 0xd1, 0x98, 0x3d, 0x3b, 0xe6, 0x77, 0x21, 0xbf, 0xc9, 0xf8, 0x38,
1362 0x1e, 0xf9, 0x2e, 0x1c, 0xb3, 0xc5, 0x85, 0x1e, 0x57, 0xb5, 0x9c, 0x08,
1363 0x65, 0x04, 0xc7, 0x35, 0x60, 0xc7, 0xf0, 0xb9, 0xaa, 0x71, 0x0d, 0xbc,
1364 0x89, 0x71, 0xb5, 0x2e, 0x18, 0xd7, 0xf6, 0x2b, 0x8e, 0x6b, 0x39, 0x1e,
1365 0x27, 0x2f, 0x87, 0xe3, 0x8b, 0xca, 0xae, 0x22, 0xc7, 0xd8, 0x8f, 0x31,
1366 0x1e, 0xd4, 0xfe, 0x80, 0x19, 0x63, 0xda, 0x8e, 0x51, 0x54, 0xdb, 0xb6,
1367 0x7f, 0x8f, 0xdf, 0xd5, 0xe3, 0xa3, 0xee, 0xff, 0x3e, 0x68, 0xba, 0x4e,
1368 0xb2, 0x5d, 0x75, 0x56, 0xfe, 0xdf, 0x24, 0x1f, 0x2e, 0x71, 0xae, 0x93,
1369 0x19, 0x91, 0x51, 0xe8, 0xe0, 0xff, 0x5c, 0xcb, 0xd8, 0xfd, 0xf6, 0x94,
1370 0xd5, 0x63, 0xd0, 0x17, 0x3b, 0x60, 0xf3, 0xf5, 0x17, 0x55, 0x77, 0x44,
1371 0x82, 0xe0, 0xb6, 0xd4, 0xa7, 0xd1, 0xf7, 0x7e, 0xed, 0xab, 0x2e, 0x8d,
1372 0x9b, 0x3f, 0x57, 0x2b, 0x3e, 0xed, 0x0d, 0xea, 0x73, 0xe8, 0xbb, 0xe3,
1373 0xb4, 0xc1, 0xb2, 0xb0, 0x93, 0x33, 0xf1, 0x88, 0xb6, 0xc5, 0xa8, 0x13,
1374 0x93, 0xf1, 0x8c, 0xa4, 0xd1, 0x5f, 0x26, 0xae, 0x84, 0x7d, 0xc0, 0x56,
1375 0x83, 0x0d, 0xf9, 0xe1, 0xca, 0x3e, 0x3c, 0x0f, 0xcb, 0xad, 0xb0, 0x77,
1376 0x6e, 0x7d, 0xe4, 0x0b, 0x72, 0x1b, 0x6c, 0x9d, 0xdb, 0x1e, 0x19, 0x93,
1377 0xbd, 0xb0, 0x6d, 0xf6, 0xc2, 0xce, 0xd9, 0x5b, 0xa1, 0xed, 0x39, 0x8e,
1378 0xb2, 0xad, 0x55, 0xb4, 0x46, 0x1b, 0x87, 0xe3, 0x23, 0xee, 0x0f, 0x72,
1379 0x0e, 0x52, 0x09, 0xf5, 0x8a, 0x9e, 0x97, 0xa6, 0x05, 0x69, 0xaf, 0x27,
1380 0xab, 0x42, 0xfd, 0xb4, 0xca, 0xc6, 0x8d, 0x8c, 0x0d, 0x78, 0x65, 0xda,
1381 0x22, 0x8d, 0x78, 0xc0, 0x33, 0xf1, 0x47, 0xda, 0xaa, 0x1e, 0x7f, 0x63,
1382 0x9d, 0xf8, 0x2b, 0xeb, 0xa4, 0xfe, 0x73, 0x90, 0xaf, 0xd5, 0x34, 0xc5,
1383 0xb7, 0x67, 0x75, 0x0d, 0x69, 0x8b, 0x32, 0x38, 0xa4, 0x87, 0x8d, 0xaf,
1384 0x23, 0x7f, 0xaf, 0x48, 0x4f, 0xfb, 0xb9, 0x2e, 0xb3, 0xbb, 0x5b, 0x56,
1385 0x33, 0x1e, 0x90, 0xad, 0xcc, 0xc7, 0x04, 0x94, 0x5f, 0x1d, 0x13, 0xa0,
1386 0x9f, 0xf5, 0x01, 0xe0, 0xec, 0x16, 0x3c, 0xfb, 0x64, 0x88, 0x71, 0x87,
1387 0x4a, 0x68, 0x97, 0x7f, 0xd5, 0xda, 0xe5, 0x21, 0x1c, 0x09, 0xc0, 0x61,
1388 0xe4, 0xf3, 0x52, 0x3d, 0xb7, 0x50, 0x7f, 0xe7, 0xe7, 0x6c, 0xda, 0x84,
1389 0xec, 0x2a, 0x71, 0xdc, 0x94, 0xc1, 0xc4, 0x4d, 0xb5, 0x0c, 0x8e, 0x5b,
1390 0x3b, 0x0a, 0x65, 0xb4, 0xfc, 0x5c, 0x2a, 0x3b, 0x29, 0xf7, 0x18, 0x9f,
1391 0x7f, 0x20, 0x45, 0x5a, 0x7f, 0xb7, 0x64, 0xe6, 0xe2, 0xf3, 0x02, 0x7a,
1392 0x93, 0x54, 0x24, 0xad, 0xd7, 0xd3, 0xbc, 0x09, 0xd9, 0x21, 0xbd, 0x31,
1393 0xc6, 0x3a, 0x19, 0xcf, 0xf3, 0xf3, 0x13, 0xb0, 0x1f, 0x86, 0x4b, 0x0a,
1394 0x16, 0x7c, 0xad, 0x0c, 0x79, 0x81, 0x6c, 0x4f, 0x39, 0x3a, 0x76, 0x6c,
1395 0x74, 0x6d, 0xa9, 0xce, 0xd8, 0xae, 0x8e, 0x8e, 0xff, 0xce, 0x80, 0xfa,
1396 0x66, 0xb4, 0x7d, 0xab, 0xb4, 0xfe, 0x9d, 0xd6, 0x65, 0x46, 0xeb, 0xc2,
1397 0x38, 0xe6, 0x8c, 0x17, 0xb1, 0xe5, 0xaa, 0xd3, 0xa7, 0xea, 0x42, 0x5b,
1398 0xb0, 0x50, 0x09, 0xd3, 0x9e, 0x5c, 0x26, 0xed, 0x85, 0x65, 0xd2, 0xfe,
1399 0x76, 0x99, 0x34, 0x13, 0x17, 0xec, 0x2f, 0x5e, 0x46, 0xde, 0x88, 0xe6,
1400 0x55, 0x69, 0x36, 0xf6, 0x75, 0x7e, 0xae, 0xcc, 0x2a, 0xeb, 0x97, 0x31,
1401 0x46, 0x6c, 0x62, 0xc3, 0x39, 0x1d, 0x1b, 0xde, 0xe2, 0x6d, 0x53, 0x8c,
1402 0x75, 0x11, 0x17, 0x09, 0xd9, 0xab, 0xf1, 0x42, 0x9c, 0x7c, 0x85, 0x31,
1403 0xe0, 0x3c, 0xd7, 0x5a, 0x13, 0xea, 0x4a, 0xb4, 0x3d, 0x6f, 0x9b, 0x98,
1404 0x79, 0x8b, 0xe9, 0x75, 0xd5, 0x3e, 0xd8, 0x0a, 0xfd, 0xc5, 0x26, 0xd9,
1405 0x3e, 0x96, 0x58, 0x41, 0xbd, 0xb5, 0x63, 0xcc, 0xf8, 0x83, 0x7b, 0xc1,
1406 0x57, 0x19, 0x21, 0x8c, 0xc9, 0x94, 0x08, 0x6d, 0xe2, 0xa5, 0xb6, 0xf0,
1407 0xeb, 0xb7, 0xd7, 0x7b, 0x85, 0xf6, 0x1c, 0xd8, 0x0e, 0x3f, 0x6b, 0x7b,
1408 0xf5, 0xd2, 0x37, 0x16, 0xe2, 0x4a, 0xfd, 0x9c, 0xf5, 0x22, 0x57, 0xa8,
1409 0xa7, 0xed, 0x12, 0x79, 0x66, 0x4e, 0x16, 0x6f, 0x84, 0xcd, 0x24, 0x41,
1410 0xb6, 0x5b, 0x5a, 0x23, 0xa2, 0x63, 0x3c, 0x29, 0x23, 0x9b, 0x3b, 0xb8,
1411 0xb6, 0x03, 0xfa, 0x37, 0xb6, 0x8a, 0x89, 0x9b, 0x86, 0x76, 0xca, 0x72,
1412 0xb4, 0x7b, 0xbd, 0xa5, 0x5d, 0xae, 0xa9, 0xee, 0xa0, 0xcc, 0xc5, 0x9c,
1413 0x18, 0x3a, 0xde, 0x5e, 0x94, 0x44, 0x48, 0xc7, 0x33, 0xf0, 0x8b, 0xab,
1414 0xe9, 0x78, 0x46, 0x52, 0x9a, 0x8e, 0x6b, 0x17, 0xd0, 0x71, 0xab, 0xa5,
1415 0xe3, 0x77, 0x44, 0x0d, 0x5d, 0x28, 0xad, 0xa7, 0x48, 0xa7, 0x86, 0x8e,
1416 0x1d, 0x4d, 0xc7, 0x33, 0x78, 0xbb, 0x7e, 0x8f, 0x2d, 0x13, 0xb1, 0x69,
1417 0xfc, 0x1d, 0xa6, 0x51, 0x2e, 0xfe, 0x66, 0xd4, 0xe8, 0xa5, 0x14, 0xe8,
1418 0x28, 0x4c, 0xff, 0x60, 0xd4, 0xd0, 0x67, 0x75, 0x9a, 0x89, 0x8f, 0xf4,
1419 0x17, 0xdf, 0x13, 0x5d, 0x48, 0x9f, 0x29, 0xd0, 0x67, 0x58, 0xe6, 0xf5,
1420 0xe8, 0xb3, 0xde, 0xae, 0x5b, 0x44, 0xf5, 0xba, 0x7b, 0x26, 0x66, 0x68,
1421 0xf5, 0x56, 0x3d, 0x76, 0x8e, 0xfb, 0xd9, 0x9f, 0x81, 0x56, 0xcd, 0xdc,
1422 0x9c, 0x9f, 0xf7, 0xb7, 0x19, 0x8b, 0x4a, 0x98, 0x18, 0x36, 0xe3, 0xa4,
1423 0x57, 0xb2, 0x1d, 0x8d, 0x7c, 0xaa, 0xd1, 0xf2, 0xa9, 0x71, 0x48, 0xa5,
1424 0xab, 0x65, 0x76, 0x37, 0x74, 0x05, 0x6d, 0x6c, 0x2d, 0xa7, 0x91, 0xd7,
1425 0x9a, 0xc8, 0x16, 0xff, 0xd9, 0xee, 0x5f, 0xe0, 0xba, 0x80, 0x0c, 0x39,
1426 0x48, 0x6b, 0x2b, 0x9b, 0x71, 0x29, 0xbf, 0x11, 0xdf, 0xdd, 0xd2, 0x56,
1427 0x56, 0x72, 0xfb, 0x58, 0x83, 0xec, 0x2b, 0xba, 0xf2, 0x51, 0xd4, 0xff,
1428 0x48, 0xd1, 0x83, 0x3f, 0x3e, 0x1e, 0xa5, 0x5d, 0xb8, 0xb7, 0xc8, 0xf5,
1429 0x49, 0xc7, 0xac, 0x19, 0x2d, 0x58, 0xf3, 0x8c, 0x48, 0x5b, 0x47, 0x01,
1430 0x9e, 0x8a, 0xb8, 0x3b, 0x01, 0x47, 0x5d, 0x3a, 0x2d, 0xaf, 0x74, 0x0f,
1431 0x38, 0xda, 0x97, 0x70, 0x7a, 0xe4, 0xc6, 0x4a, 0x5a, 0x6e, 0xa8, 0x98,
1432 0x75, 0xd2, 0xf9, 0x75, 0xd0, 0xa4, 0x37, 0x0d, 0x9d, 0x93, 0xf1, 0x82,
1433 0xe0, 0x3c, 0xe4, 0xb7, 0x3a, 0xe2, 0x4a, 0xb4, 0x23, 0x19, 0x9f, 0x16,
1434 0xf3, 0x7d, 0xb1, 0xfc, 0xe3, 0x60, 0x28, 0xe6, 0xca, 0x2b, 0x3e, 0xc7,
1435 0xd5, 0x23, 0xd7, 0x97, 0xab, 0xfb, 0xe3, 0x5a, 0xe9, 0x13, 0x51, 0xae,
1436 0x4d, 0x64, 0x2b, 0xe5, 0x28, 0xe3, 0xe7, 0x22, 0x79, 0x69, 0x7b, 0x2b,
1437 0x7c, 0x37, 0x48, 0xeb, 0xb6, 0xb7, 0x82, 0x56, 0x62, 0xd0, 0xf3, 0x5b,
1438 0x01, 0xd7, 0x56, 0xc6, 0xbb, 0x18, 0xe7, 0xe2, 0xf7, 0x5f, 0xa2, 0x5f,
1439 0xd6, 0xfd, 0x5d, 0xbd, 0x66, 0x25, 0x8a, 0x73, 0x6e, 0xf8, 0x65, 0x79,
1440 0x5d, 0xd3, 0x38, 0x14, 0x4d, 0x8b, 0x13, 0x7d, 0x5b, 0x5c, 0x56, 0xf8,
1441 0xd5, 0xfd, 0x73, 0xed, 0x57, 0x14, 0x70, 0xe8, 0xee, 0xd8, 0xdc, 0x23,
1442 0x7d, 0x18, 0x5f, 0xff, 0x92, 0xf1, 0xed, 0x17, 0xc6, 0x54, 0x2f, 0x16,
1443 0x39, 0x86, 0xf9, 0x71, 0xa9, 0x3f, 0x32, 0xe3, 0x8a, 0x76, 0x2c, 0x1e,
1444 0x8f, 0xae, 0xaf, 0x4e, 0x01, 0x96, 0xe7, 0xf4, 0x1e, 0x81, 0x20, 0xb8,
1445 0xa6, 0xe3, 0x62, 0x90, 0x58, 0x97, 0xec, 0x9c, 0x9e, 0x5f, 0xd3, 0x19,
1446 0x8a, 0xa4, 0x33, 0x1a, 0xff, 0xf8, 0x4e, 0xe4, 0xca, 0xdd, 0x98, 0x3b,
1447 0x71, 0x73, 0x5d, 0xae, 0xe6, 0x8d, 0x9c, 0xdf, 0x6d, 0xd7, 0xad, 0x42,
1448 0xbf, 0x29, 0x08, 0x94, 0xbf, 0x58, 0x56, 0x50, 0x47, 0x61, 0xec, 0xb2,
1449 0xdb, 0xee, 0x4b, 0x49, 0x31, 0x6e, 0x38, 0xe4, 0xa6, 0xa3, 0x89, 0x42,
1450 0xb9, 0x0b, 0xbf, 0x1b, 0xf0, 0xfe, 0x45, 0xd8, 0x28, 0x3d, 0xb0, 0x61,
1451 0x24, 0xa6, 0x8c, 0x3c, 0x00, 0xfd, 0x76, 0xe4, 0x95, 0x22, 0x3f, 0x7a,
1452 0x89, 0xe1, 0x72, 0x2c, 0x31, 0x5a, 0xde, 0xcb, 0xfa, 0x28, 0x7b, 0xa5,
1453 0xf8, 0x1d, 0xfb, 0x62, 0x1f, 0xf4, 0x79, 0x7f, 0x96, 0x3e, 0x5c, 0xdb,
1454 0x36, 0xdb, 0x0c, 0xf1, 0xe2, 0xd2, 0x0d, 0xc7, 0xbf, 0x6e, 0xeb, 0x8f,
1455 0x70, 0x7c, 0x7b, 0x2d, 0xdc, 0x8b, 0xfb, 0x7d, 0x49, 0xdb, 0x2c, 0x8f,
1456 0x55, 0x68, 0x27, 0x72, 0x4d, 0x27, 0x79, 0x62, 0x5c, 0x08, 0x47, 0x10,
1457 0x5c, 0x48, 0x19, 0x7d, 0xfd, 0x74, 0x85, 0xeb, 0x1a, 0x41, 0xf0, 0x5d,
1458 0xda, 0xc2, 0x83, 0x25, 0xf4, 0x17, 0xe2, 0x60, 0x63, 0xde, 0x85, 0x2c,
1459 0x1c, 0xe9, 0x26, 0x7e, 0x05, 0x5e, 0x69, 0x87, 0xb7, 0x4b, 0xa2, 0x89,
1460 0xdf, 0x2e, 0x37, 0x24, 0x3e, 0x51, 0xf6, 0x80, 0x67, 0x8e, 0x3b, 0x96,
1461 0xd8, 0x63, 0xc7, 0xcc, 0xfd, 0x20, 0xaf, 0xbf, 0x4f, 0xe3, 0xa5, 0x05,
1462 0x3e, 0x12, 0x61, 0x9a, 0x87, 0x85, 0xb0, 0x25, 0x2c, 0x6e, 0x82, 0xe0,
1463 0xfb, 0x29, 0xf6, 0xd9, 0xcd, 0xfd, 0x00, 0x23, 0xe8, 0x37, 0xbf, 0x56,
1464 0x11, 0x0f, 0xd1, 0xc4, 0x1d, 0xe8, 0xfb, 0xb7, 0xd1, 0xf7, 0xbe, 0x32,
1465 0xfb, 0x83, 0x7c, 0xc0, 0xd8, 0x47, 0x2a, 0x21, 0xbc, 0xcb, 0xf5, 0x1d,
1466 0xce, 0x79, 0xa7, 0xb5, 0xeb, 0xc2, 0x6f, 0x8d, 0x48, 0x4f, 0xc1, 0x97,
1467 0xcb, 0x56, 0x66, 0xd6, 0xb8, 0xf2, 0x2e, 0xc8, 0xda, 0x40, 0x4e, 0x42,
1468 0x86, 0xcd, 0x68, 0xba, 0xc9, 0xae, 0xe7, 0xff, 0x11, 0xf9, 0xe4, 0x0a,
1469 0xc6, 0x94, 0x7b, 0x7d, 0xda, 0xab, 0xb3, 0xc1, 0x8c, 0x4f, 0x99, 0xbc,
1470 0x4a, 0xc6, 0xbd, 0x7c, 0x27, 0xf4, 0x03, 0xd2, 0x1a, 0xe9, 0x63, 0x27,
1471 0xb2, 0x91, 0x64, 0x62, 0x58, 0xb8, 0xc7, 0x89, 0xfb, 0x13, 0xb8, 0xef,
1472 0x87, 0xf2, 0xc0, 0x85, 0x9c, 0xe3, 0x1c, 0x9a, 0xfe, 0x86, 0xcb, 0xf3,
1473 0x65, 0x0f, 0x08, 0xd7, 0x09, 0x93, 0xf1, 0xbd, 0xda, 0x26, 0x01, 0xd5,
1474 0x15, 0x59, 0x76, 0x33, 0x2c, 0x12, 0xbf, 0xaa, 0xbc, 0xde, 0x73, 0x05,
1475 0x3e, 0x67, 0x1c, 0x21, 0x1a, 0xcd, 0x16, 0xe5, 0xb5, 0x48, 0xb7, 0xbc,
1476 0x96, 0x4d, 0xd5, 0x4b, 0xaf, 0x96, 0xf9, 0xcc, 0xd3, 0xe9, 0xb3, 0x26,
1477 0xdd, 0x85, 0x2e, 0xe1, 0x9c, 0xf4, 0x40, 0x46, 0x4f, 0x00, 0x6e, 0xe2,
1478 0xb0, 0x87, 0x32, 0x89, 0xf3, 0xa7, 0x54, 0x3a, 0x16, 0xcd, 0x95, 0xa5,
1479 0x2f, 0x57, 0xb4, 0xb1, 0x9e, 0x01, 0x8e, 0x7f, 0x95, 0xc5, 0x43, 0xa3,
1480 0xb8, 0x80, 0xad, 0x2f, 0x92, 0x70, 0xe0, 0x2b, 0x43, 0xd7, 0x3f, 0xba,
1481 0x4a, 0x1a, 0x89, 0x9b, 0x1e, 0xf0, 0x52, 0x0d, 0x74, 0xd1, 0xfd, 0xcd,
1482 0x5c, 0x37, 0xd5, 0x36, 0x64, 0xec, 0x63, 0xbf, 0xac, 0xd2, 0x7f, 0x1b,
1483 0x57, 0xe9, 0x51, 0x2b, 0x2f, 0xa3, 0x7d, 0x94, 0x97, 0x4f, 0x97, 0x08,
1484 0x8f, 0x78, 0x11, 0x3f, 0xd1, 0xd7, 0x5b, 0x16, 0x15, 0x49, 0x7b, 0xd1,
1485 0xde, 0xf2, 0x42, 0xfa, 0x7f, 0xba, 0xf2, 0x61, 0x6b, 0x0b, 0x56, 0xc7,
1486 0x54, 0xab, 0xf3, 0xc8, 0x83, 0xcb, 0xe5, 0x11, 0x26, 0x89, 0xae, 0x48,
1487 0x5f, 0xf8, 0x54, 0x7b, 0x47, 0xde, 0xab, 0x15, 0xe2, 0x39, 0x80, 0xdc,
1488 0x06, 0xae, 0xcb, 0x5c, 0xaf, 0xde, 0x8f, 0x79, 0xfb, 0x3f, 0x41, 0x26,
1489 0xc6, 0x7c, 0x4f, 0xea, 0xe0, 0xdb, 0xbe, 0x0c, 0xdd, 0xf9, 0x8a, 0x7f,
1490 0xe1, 0x53, 0x9d, 0x1d, 0x41, 0xf0, 0xac, 0x9f, 0x4f, 0xb8, 0x90, 0x1f,
1491 0x87, 0x2d, 0xbe, 0x87, 0x81, 0xef, 0x89, 0x39, 0x7c, 0x27, 0xe4, 0x62,
1492 0xd7, 0xf7, 0x03, 0xae, 0xf5, 0x0d, 0x97, 0x6f, 0xbd, 0x55, 0xa5, 0x3f,
1493 0xfe, 0xa1, 0x6c, 0x37, 0xfb, 0x1b, 0x91, 0xc3, 0x95, 0x9b, 0x88, 0xbf,
1494 0x28, 0xc6, 0x7a, 0x4f, 0x9f, 0x6f, 0xfa, 0xed, 0x5b, 0xd0, 0x2f, 0xe9,
1495 0xe5, 0x47, 0xac, 0x8b, 0x32, 0xd5, 0x75, 0x33, 0xa0, 0xcb, 0xbc, 0xad,
1496 0x3b, 0x70, 0x85, 0xba, 0xde, 0x15, 0xea, 0x1e, 0x46, 0xdd, 0x3d, 0xb6,
1497 0xee, 0x85, 0xcf, 0xbc, 0xb9, 0x7e, 0x07, 0xb8, 0xc7, 0x0e, 0x3e, 0x80,
1498 0xb8, 0x11, 0xff, 0x36, 0xfc, 0xbe, 0x85, 0xed, 0x28, 0xda, 0xf7, 0x23,
1499 0x95, 0x21, 0x19, 0xae, 0xec, 0xc4, 0x33, 0x88, 0xb4, 0x3e, 0x3c, 0xfb,
1500 0xf0, 0x3b, 0x8d, 0x47, 0xa2, 0x6e, 0xfa, 0xc2, 0x5d, 0xc3, 0x7e, 0x88,
1501 0x57, 0xae, 0xcd, 0xb3, 0x0f, 0xd8, 0x17, 0x5d, 0x3f, 0x41, 0x1f, 0x61,
1502 0xfa, 0x07, 0x50, 0x67, 0x1a, 0x69, 0x2b, 0x69, 0x7b, 0x62, 0xae, 0xab,
1503 0xeb, 0x54, 0xc3, 0x36, 0x1d, 0xce, 0x05, 0xf2, 0x0d, 0x8d, 0xf6, 0x16,
1504 0x43, 0x18, 0xef, 0x44, 0x1b, 0xe3, 0x57, 0x29, 0xff, 0x1e, 0xc2, 0x15,
1505 0x57, 0xfe, 0xc7, 0xf0, 0x7e, 0x2d, 0xd8, 0x9d, 0x62, 0x4c, 0x9e, 0xf3,
1506 0x7e, 0xdd, 0xaa, 0xa5, 0x7b, 0x9f, 0x42, 0x1a, 0xe8, 0x84, 0x4e, 0x69,
1507 0xb0, 0x74, 0x5a, 0x80, 0xe5, 0x43, 0x1a, 0xe5, 0x98, 0x17, 0x97, 0x4d,
1508 0x76, 0xe6, 0xa5, 0x07, 0xba, 0x8c, 0xb2, 0xf6, 0xd3, 0xf5, 0x26, 0x0e,
1509 0x03, 0xcb, 0xd1, 0xef, 0x04, 0x3d, 0x37, 0x88, 0x87, 0xfa, 0x03, 0x11,
1510 0x0f, 0x34, 0x18, 0xd6, 0x4f, 0x7a, 0x03, 0x11, 0x8e, 0x19, 0x1c, 0x5f,
1511 0xe6, 0xba, 0x34, 0x6d, 0x6b, 0xd6, 0x0f, 0x6d, 0x1c, 0xfe, 0x7b, 0x59,
1512 0xc4, 0x67, 0x1a, 0xdb, 0x0b, 0xde, 0x55, 0xe3, 0x2f, 0x59, 0x63, 0xc1,
1513 0x38, 0xf3, 0x49, 0x68, 0x30, 0xaf, 0x4f, 0xcb, 0xe9, 0xfc, 0x35, 0x35,
1514 0xd2, 0xe0, 0xf5, 0xeb, 0xdf, 0x2c, 0xd3, 0xe0, 0x81, 0x4f, 0x17, 0x95,
1515 0x61, 0x1a, 0xf3, 0x0a, 0x6b, 0x94, 0xde, 0xab, 0xa4, 0xf7, 0x28, 0xc9,
1516 0x83, 0xa9, 0x64, 0x62, 0x48, 0x25, 0xbd, 0x71, 0xd9, 0x0f, 0xb9, 0x43,
1517 0x39, 0x39, 0x73, 0x7f, 0x44, 0xb8, 0x9f, 0xef, 0x5d, 0x92, 0xf5, 0x29,
1518 0x3f, 0x0b, 0x9f, 0x57, 0x94, 0x75, 0x95, 0x97, 0x1a, 0xcc, 0xd8, 0xb8,
1519 0x0f, 0x01, 0x70, 0x36, 0xd1, 0x86, 0xbb, 0xb5, 0x81, 0x3c, 0x94, 0x50,
1520 0x11, 0xd9, 0x45, 0x3f, 0x5f, 0x7d, 0xb1, 0x5e, 0xea, 0xa7, 0xd7, 0x78,
1521 0x52, 0xd1, 0xe9, 0x66, 0x7f, 0x60, 0xb2, 0x73, 0x48, 0x89, 0x1e, 0x7b,
1522 0x46, 0xbd, 0x91, 0xcc, 0x9e, 0xb5, 0xfa, 0x23, 0x90, 0xc7, 0xb4, 0xbe,
1523 0x98, 0xf9, 0xbc, 0x2b, 0x17, 0x82, 0xb6, 0x4d, 0x17, 0xda, 0xb3, 0x5d,
1524 0xb4, 0x73, 0x57, 0xd9, 0xfd, 0x95, 0x8c, 0x63, 0xbd, 0x4b, 0x9e, 0xf3,
1525 0x0b, 0x18, 0xf7, 0x7e, 0xb9, 0xe0, 0xb3, 0xbf, 0x99, 0xcf, 0x79, 0xc2,
1526 0x74, 0xc2, 0x6e, 0xfa, 0x13, 0xf5, 0xa7, 0x80, 0x87, 0x7d, 0x52, 0x07,
1527 0x5f, 0xc9, 0xee, 0x4b, 0x0e, 0xe4, 0x45, 0xcf, 0x4b, 0x8f, 0xa0, 0xad,
1528 0x15, 0x3e, 0xf8, 0x10, 0x76, 0x73, 0xcd, 0x91, 0xab, 0x21, 0x77, 0x1d,
1529 0xbd, 0xc7, 0x02, 0x93, 0xe1, 0x4d, 0x61, 0xde, 0x33, 0x03, 0x2c, 0x57,
1530 0x2f, 0xd3, 0x31, 0xf2, 0xba, 0xe6, 0x97, 0x4f, 0x65, 0xfd, 0x76, 0x4f,
1531 0x39, 0xc3, 0x8c, 0x31, 0x00, 0xaf, 0xa4, 0xcd, 0x54, 0x6c, 0xbb, 0xcf,
1532 0xb6, 0x58, 0xe6, 0x2a, 0xf9, 0xf6, 0xc0, 0x85, 0x7f, 0x78, 0xd6, 0xff,
1533 0x7b, 0xc0, 0x91, 0x81, 0x4c, 0xe0, 0xf3, 0x6a, 0x90, 0x8f, 0x31, 0xa6,
1534 0xf5, 0xbf, 0xeb, 0xad, 0x9d, 0xac, 0x79, 0x7f, 0x58, 0xef, 0x93, 0x79,
1535 0xfe, 0x33, 0x59, 0xae, 0x77, 0xc0, 0x36, 0xc9, 0x69, 0xb9, 0x18, 0xfd,
1536 0x69, 0x0e, 0xf0, 0x14, 0x2a, 0xb4, 0x43, 0xfe, 0x06, 0x76, 0x88, 0xd6,
1537 0x93, 0xf2, 0xed, 0x41, 0xe6, 0xb1, 0xdd, 0xec, 0xd5, 0xae, 0xd6, 0x0b,
1538 0x21, 0x2c, 0xc9, 0xce, 0x1c, 0xf2, 0x47, 0xb4, 0x1d, 0xef, 0xc9, 0xac,
1539 0xe7, 0xea, 0x7d, 0x27, 0xf9, 0xc1, 0x20, 0x78, 0xc5, 0x77, 0xe5, 0xa4,
1540 0x86, 0xf9, 0x05, 0xf4, 0xe1, 0xc8, 0xc4, 0x80, 0xfb, 0xd3, 0x93, 0x3e,
1541 0xc7, 0xc7, 0x3c, 0xae, 0x2b, 0x6d, 0x8e, 0x1b, 0xf8, 0x68, 0x9b, 0x7e,
1542 0x2f, 0x98, 0x8d, 0x71, 0xdd, 0x02, 0x3c, 0x5d, 0x6a, 0xf7, 0x6e, 0x90,
1543 0xdb, 0xe6, 0x6c, 0x9a, 0x69, 0x31, 0x36, 0xa3, 0xd1, 0x69, 0x17, 0xfe,
1544 0x61, 0xc4, 0xbf, 0xb0, 0xba, 0x80, 0xb9, 0x81, 0x0e, 0x5b, 0x0c, 0x4b,
1545 0x8a, 0xb0, 0x0c, 0x6b, 0x58, 0x62, 0xc0, 0xa5, 0x0b, 0xd9, 0x77, 0x9b,
1546 0x1c, 0x02, 0xde, 0x87, 0x06, 0x45, 0x9e, 0x85, 0x4d, 0x76, 0xbe, 0x0a,
1547 0x9e, 0x19, 0xc0, 0x73, 0xde, 0xe7, 0x5e, 0x00, 0xe6, 0xf9, 0xde, 0xb0,
1548 0x70, 0x2f, 0x00, 0x71, 0xd8, 0x81, 0xdf, 0x22, 0x33, 0xd0, 0xbf, 0x27,
1549 0xfd, 0xd7, 0x82, 0xf1, 0x18, 0x75, 0x23, 0xda, 0x99, 0xdb, 0x1b, 0x14,
1550 0xc8, 0xe7, 0x53, 0xd4, 0x43, 0xb5, 0xd2, 0xb6, 0x8e, 0x7e, 0x88, 0x91,
1551 0x9f, 0x37, 0xf8, 0x19, 0xf4, 0xf5, 0x5b, 0x2b, 0xa5, 0x3e, 0x2f, 0xfd,
1552 0x1d, 0x75, 0xc8, 0x73, 0x6d, 0xde, 0x80, 0xce, 0xeb, 0xef, 0x38, 0x8c,
1553 0xfc, 0x8f, 0xaf, 0x64, 0xbc, 0xdb, 0xf5, 0xd7, 0x4b, 0xdb, 0x1a, 0xe6,
1554 0x55, 0xf3, 0xe0, 0xab, 0xdc, 0x83, 0x69, 0x75, 0x38, 0x64, 0x59, 0x29,
1555 0xef, 0x71, 0xa7, 0xdd, 0x21, 0xcc, 0xc5, 0x6e, 0x9f, 0xb2, 0xed, 0xbf,
1556 0xa3, 0x6e, 0x4a, 0x6e, 0xf4, 0x07, 0x91, 0x37, 0x8d, 0xbc, 0xc3, 0x36,
1557 0x6f, 0xd0, 0xe6, 0x6d, 0x43, 0xde, 0x3e, 0xe0, 0xef, 0x6e, 0x9d, 0x9e,
1558 0xe5, 0x6f, 0x53, 0xc7, 0x5b, 0xd9, 0x71, 0xe1, 0x33, 0x37, 0xf8, 0x84,
1559 0x0b, 0x79, 0x25, 0xae, 0x8b, 0xde, 0x26, 0x79, 0x2f, 0x79, 0x0b, 0x7b,
1560 0xfd, 0x66, 0xb1, 0x0e, 0xb2, 0x89, 0x7b, 0x80, 0x69, 0xb3, 0x6e, 0xf1,
1561 0x5e, 0x96, 0xff, 0x40, 0xba, 0xeb, 0xc9, 0x38, 0x5f, 0x5b, 0xc9, 0xb8,
1562 0xd8, 0x88, 0x4f, 0xfb, 0x3a, 0x90, 0x9c, 0x5e, 0x3f, 0xa1, 0x7f, 0x5b,
1563 0x44, 0x3a, 0xe9, 0x41, 0x35, 0x45, 0xf4, 0x3e, 0x2d, 0x7e, 0x47, 0x61,
1564 0xf7, 0x06, 0x42, 0x9f, 0x8f, 0x36, 0x5d, 0xc6, 0xe3, 0xda, 0x50, 0x98,
1565 0xe7, 0x21, 0x4f, 0x6d, 0x8a, 0xc0, 0x26, 0xaa, 0xf5, 0x1d, 0x1d, 0xa3,
1566 0x2e, 0xe8, 0x75, 0x00, 0xc6, 0xdf, 0x32, 0xf0, 0x63, 0x02, 0xe9, 0x47,
1567 0xdf, 0xa4, 0xfd, 0x68, 0x87, 0xef, 0x1d, 0x10, 0xee, 0x67, 0x65, 0x7a,
1568 0xbb, 0xf7, 0x6d, 0x99, 0xa7, 0xf3, 0x19, 0x49, 0x66, 0x94, 0x03, 0xff,
1569 0x75, 0xab, 0x23, 0xf5, 0xb0, 0x3d, 0x6e, 0x30, 0xfa, 0xcd, 0xe3, 0x9e,
1570 0xc4, 0x8b, 0xda, 0x56, 0x6b, 0xb4, 0xf3, 0x91, 0x05, 0x6e, 0xb8, 0x1f,
1571 0x7c, 0xe0, 0x9e, 0xdd, 0x7e, 0x21, 0x09, 0x6a, 0xd4, 0xba, 0x71, 0x18,
1572 0xb4, 0x91, 0x4d, 0x19, 0xdd, 0x78, 0xc3, 0x9c, 0x6e, 0xfc, 0xf3, 0x95,
1573 0xe4, 0x89, 0xe1, 0x72, 0x1c, 0x75, 0xf5, 0x3a, 0x4a, 0x82, 0x75, 0x6b,
1574 0x31, 0x9f, 0xe7, 0xfd, 0xec, 0x35, 0xa0, 0x2f, 0xc8, 0xe1, 0x64, 0xe7,
1575 0x29, 0xd4, 0x2d, 0xa0, 0xee, 0xe4, 0x5c, 0x5d, 0x47, 0x46, 0x7c, 0xbd,
1576 0xef, 0x59, 0x26, 0xcb, 0x21, 0x1d, 0x26, 0xe3, 0xb7, 0x6a, 0x5e, 0xe0,
1577 0x7e, 0x30, 0x37, 0x71, 0x9f, 0x6c, 0xd6, 0xb4, 0xdd, 0x27, 0xdc, 0x27,
1578 0xc5, 0xb6, 0xef, 0x0b, 0xda, 0xd6, 0x10, 0xbe, 0x12, 0xde, 0xa4, 0x8d,
1579 0x31, 0xbc, 0xc3, 0xf9, 0x37, 0xf3, 0x3e, 0xe4, 0x10, 0xdf, 0xbf, 0x1f,
1580 0xe4, 0x07, 0x39, 0x2f, 0xfc, 0x9e, 0xa7, 0xb9, 0x11, 0xd0, 0x5c, 0xc4,
1581 0x7f, 0xbb, 0x0c, 0xeb, 0x3d, 0x10, 0x29, 0x99, 0xd0, 0xf1, 0xcc, 0x0b,
1582 0xc1, 0x23, 0x0b, 0xe4, 0xf8, 0x47, 0x94, 0xa1, 0x21, 0xfe, 0x2e, 0x24,
1583 0xea, 0x64, 0x66, 0x4d, 0x9d, 0xde, 0xf1, 0x41, 0x7c, 0x8c, 0xde, 0x73,
1584 0x3b, 0xf8, 0xf5, 0xfa, 0xb9, 0xb1, 0x00, 0xdf, 0xc0, 0xe3, 0x4e, 0x63,
1585 0xeb, 0x63, 0x1c, 0x19, 0xed, 0xbf, 0x67, 0x8b, 0x4a, 0xef, 0x0b, 0xa2,
1586 0x8e, 0x3f, 0x00, 0x9d, 0x6a, 0xf6, 0xa4, 0xe0, 0x5d, 0xe1, 0xbc, 0x29,
1587 0xed, 0x73, 0x1c, 0x04, 0x0f, 0x1f, 0xf4, 0xb3, 0x6b, 0x6a, 0x75, 0xdb,
1588 0x49, 0xef, 0x7a, 0x6d, 0x13, 0x6e, 0x94, 0x99, 0x14, 0xdb, 0x23, 0x5e,
1589 0xfe, 0x47, 0x30, 0xe4, 0xcd, 0xa0, 0x7f, 0x43, 0xff, 0x59, 0x5f, 0xb5,
1590 0xd4, 0x49, 0xf5, 0x3e, 0x53, 0xe2, 0xc9, 0x85, 0xbd, 0xd2, 0x01, 0xfc,
1591 0x18, 0x78, 0x73, 0xe5, 0xb7, 0x49, 0x21, 0xe6, 0xda, 0xb1, 0x45, 0xb4,
1592 0x2f, 0x37, 0x91, 0xaa, 0x83, 0x2d, 0xf8, 0x17, 0xc1, 0xe4, 0x82, 0x31,
1593 0x1e, 0xac, 0x1a, 0xe3, 0x4c, 0x02, 0xd8, 0x68, 0x89, 0xcc, 0xc9, 0x01,
1594 0xf6, 0x65, 0x64, 0x52, 0x38, 0xc6, 0x3a, 0x8c, 0x71, 0xc7, 0xdc, 0x18,
1595 0x0f, 0x2f, 0x1a, 0xe3, 0x61, 0x8c, 0x11, 0xf6, 0x42, 0x29, 0xd3, 0xe9,
1596 0xce, 0xcf, 0xfb, 0xd5, 0x35, 0x73, 0xf3, 0x29, 0xdc, 0xeb, 0x84, 0xf1,
1597 0xd3, 0xa6, 0xd8, 0x08, 0x78, 0x74, 0x5b, 0x90, 0x71, 0x0e, 0x64, 0x5b,
1598 0x76, 0x4d, 0x8d, 0x1d, 0xff, 0x76, 0x96, 0x2b, 0x1b, 0x1c, 0x9c, 0x4c,
1599 0xb9, 0x9d, 0x8f, 0xa0, 0xbf, 0xbd, 0x76, 0x5c, 0xbd, 0xe5, 0xab, 0x31,
1600 0xae, 0x0b, 0xdf, 0xc1, 0x18, 0xe0, 0xb3, 0x9d, 0xa0, 0x0f, 0x9c, 0x18,
1601 0x92, 0x05, 0xb2, 0xeb, 0x33, 0xf3, 0x72, 0xd4, 0xc0, 0x4c, 0xdb, 0xba,
1602 0x30, 0x07, 0xf3, 0xdd, 0x8b, 0x60, 0xbe, 0x1b, 0x30, 0xef, 0xb3, 0xf3,
1603 0xb2, 0xaf, 0x6a, 0xcf, 0x62, 0x48, 0x47, 0xfc, 0xfd, 0xbc, 0xf5, 0x45,
1604 0x3e, 0x20, 0xf7, 0x97, 0x3a, 0xe5, 0xcb, 0x95, 0xe4, 0x59, 0xc6, 0xd1,
1605 0xcf, 0x55, 0x92, 0xe3, 0x22, 0x5d, 0xf2, 0xc7, 0xb0, 0x73, 0xae, 0x82,
1606 0x6f, 0xf1, 0x34, 0xfc, 0xd7, 0x3f, 0xa9, 0xf8, 0xf2, 0xc4, 0xdc, 0x7e,
1607 0x38, 0xea, 0xba, 0xb4, 0x9c, 0x84, 0x4f, 0xbb, 0xed, 0x68, 0x1b, 0xf7,
1608 0x2a, 0x11, 0xbe, 0xbb, 0xa8, 0x73, 0xda, 0x94, 0xe6, 0xc5, 0xef, 0x62,
1609 0xbc, 0xa7, 0xa9, 0x6b, 0xd6, 0xfa, 0xbe, 0x77, 0xb3, 0x5a, 0x47, 0x99,
1610 0x90, 0xff, 0x5a, 0xe4, 0x03, 0xf5, 0x26, 0xc6, 0x92, 0xf1, 0x9a, 0xc9,
1611 0x1b, 0xdb, 0x3a, 0x12, 0x7d, 0x42, 0x5b, 0x82, 0xfe, 0x36, 0x6c, 0xa1,
1612 0xd2, 0xe6, 0xf8, 0x5a, 0xa1, 0x4c, 0xa2, 0x5d, 0x94, 0x96, 0x09, 0xc0,
1613 0x3e, 0x06, 0x89, 0x50, 0x68, 0xf6, 0x47, 0x7b, 0xd5, 0x44, 0x03, 0x79,
1614 0x70, 0xdb, 0x19, 0xd0, 0xd7, 0x36, 0x8c, 0xa9, 0x2b, 0x79, 0x76, 0x46,
1615 0x65, 0x4e, 0xac, 0x95, 0x57, 0x82, 0xa1, 0x66, 0x47, 0x9e, 0xd8, 0xc4,
1616 0x3c, 0x2d, 0xb7, 0x3f, 0xd5, 0x0b, 0xf9, 0xd4, 0xce, 0x73, 0x0b, 0x03,
1617 0xf2, 0x2f, 0x77, 0x80, 0x06, 0x7f, 0xb8, 0xe9, 0x6b, 0xc1, 0x6c, 0xb3,
1618 0x2b, 0x5b, 0x37, 0x25, 0xbd, 0xbc, 0xc2, 0x78, 0x4a, 0x18, 0x4f, 0x09,
1619 0xe3, 0xe3, 0x98, 0x4b, 0x18, 0xd7, 0x15, 0xf7, 0x4a, 0xf5, 0x2c, 0x88,
1620 0xcb, 0x1a, 0x3f, 0x2d, 0x93, 0x77, 0x65, 0x83, 0xdd, 0x2b, 0x35, 0x5c,
1621 0x1f, 0xae, 0xb1, 0x65, 0x64, 0x3c, 0x28, 0xf8, 0x7f, 0x70, 0x55, 0xb6,
1622 0x2b, 0xb6, 0x58, 0xe7, 0xdc, 0x35, 0xaf, 0x73, 0x44, 0x9e, 0x33, 0xf3,
1623 0x86, 0x39, 0xf3, 0xbd, 0x49, 0x6e, 0x86, 0x87, 0x0e, 0xdc, 0xaa, 0xf7,
1624 0x3c, 0x77, 0xe0, 0x9b, 0x36, 0xd5, 0xa7, 0xf5, 0x3a, 0xe2, 0x4c, 0xf9,
1625 0x1e, 0x3b, 0x77, 0xf7, 0x68, 0x3d, 0xbb, 0x75, 0xd3, 0xa5, 0x80, 0xfb,
1626 0xdc, 0xbc, 0x4d, 0xcb, 0xc5, 0x22, 0x68, 0xef, 0xd5, 0x69, 0xde, 0xe7,
1627 0x7a, 0x76, 0x41, 0x9f, 0x13, 0x01, 0xde, 0xe6, 0xe2, 0x62, 0xf5, 0x48,
1628 0xa3, 0xbe, 0xf8, 0x69, 0x83, 0x59, 0x47, 0xa5, 0x6c, 0x58, 0x83, 0x34,
1629 0xd7, 0xec, 0x05, 0x5e, 0x90, 0xf7, 0xdf, 0xea, 0xcd, 0x9e, 0x8f, 0xea,
1630 0xb2, 0xe0, 0x31, 0xbd, 0x2f, 0x84, 0xfb, 0x03, 0x7f, 0x79, 0xa5, 0xb1,
1631 0x4d, 0xc3, 0x7c, 0xa6, 0xff, 0x38, 0x98, 0xd0, 0x31, 0x36, 0xf6, 0xf5,
1632 0x43, 0xfc, 0x5e, 0xbc, 0x5f, 0x24, 0xb4, 0x5d, 0xeb, 0x40, 0xf7, 0xda,
1633 0x5f, 0x16, 0x94, 0x89, 0xe7, 0x25, 0x22, 0x13, 0x55, 0x30, 0x4e, 0x10,
1634 0xee, 0x52, 0xd7, 0xaa, 0xf9, 0xd8, 0xdd, 0x6a, 0xa4, 0x11, 0xc6, 0x75,
1635 0x8b, 0xf2, 0xc8, 0x1b, 0xad, 0x2b, 0x49, 0x37, 0xd3, 0xc2, 0xb4, 0xf9,
1636 0x31, 0xcd, 0x68, 0xfb, 0xb9, 0x6d, 0x95, 0xde, 0xfb, 0xc4, 0x35, 0x46,
1637 0xc6, 0x08, 0x63, 0x26, 0xdf, 0xf5, 0xff, 0x56, 0xd7, 0x19, 0x9a, 0xab,
1638 0xa3, 0xe7, 0x02, 0xf9, 0x6e, 0x55, 0x5e, 0x35, 0xdc, 0xd4, 0x5f, 0x43,
1639 0x9d, 0x75, 0xd0, 0x89, 0x17, 0x53, 0xab, 0xc3, 0xbd, 0xf0, 0xb0, 0x21,
1640 0xb2, 0xd7, 0xd4, 0x5a, 0x99, 0x3f, 0x81, 0x79, 0x7d, 0x26, 0x65, 0x78,
1641 0x51, 0xf3, 0x61, 0xf1, 0x36, 0xf8, 0xeb, 0xa1, 0xde, 0xa0, 0x9c, 0x26,
1642 0x6f, 0x22, 0xad, 0x42, 0x9f, 0xe0, 0xc2, 0xea, 0x99, 0xae, 0x57, 0x03,
1643 0xee, 0xb3, 0x7c, 0x45, 0xdb, 0x51, 0x43, 0xb2, 0xb0, 0xed, 0xd1, 0x7b,
1644 0x5e, 0xbf, 0xed, 0xa1, 0x65, 0xda, 0x1e, 0xb2, 0x6d, 0x8b, 0x6b, 0xda,
1645 0x8e, 0x5e, 0xa1, 0xed, 0x81, 0x37, 0x68, 0x7b, 0x70, 0x99, 0xb6, 0x07,
1646 0xc3, 0xb6, 0x95, 0x69, 0xdb, 0x0b, 0xdb, 0x4e, 0x2c, 0xc2, 0xc9, 0x67,
1647 0x5e, 0xbf, 0xed, 0x7d, 0xcb, 0xb4, 0xbd, 0x6f, 0x11, 0xdc, 0xc4, 0x49,
1648 0x2d, 0x74, 0xff, 0x3d, 0xda, 0xe6, 0xac, 0x03, 0xdf, 0x5c, 0x84, 0xfc,
1649 0x36, 0xfe, 0xc8, 0x85, 0xbb, 0x66, 0xcb, 0xe0, 0x2b, 0xf8, 0xd7, 0x99,
1650 0x72, 0x03, 0x9e, 0x71, 0xd8, 0x33, 0x28, 0x07, 0x7b, 0xbc, 0x26, 0x1d,
1651 0xc8, 0xc9, 0x6e, 0x96, 0xcd, 0xc7, 0x6b, 0xe7, 0xf4, 0xc6, 0x3d, 0xe8,
1652 0x8f, 0x6d, 0xfb, 0x5e, 0xbf, 0xbc, 0xa6, 0xfb, 0xcb, 0x95, 0xe9, 0x8f,
1653 0x21, 0xbd, 0x42, 0x1f, 0x97, 0xf5, 0x42, 0x19, 0x58, 0x67, 0xd7, 0x3e,
1654 0x68, 0x6b, 0x32, 0x0e, 0xa7, 0xed, 0x51, 0x29, 0x94, 0x7f, 0x12, 0x4c,
1655 0x83, 0x2e, 0x46, 0xe6, 0x74, 0xc8, 0x93, 0xab, 0x68, 0xb3, 0x8f, 0x53,
1656 0xb3, 0x54, 0xc5, 0xa0, 0x46, 0x7c, 0xa6, 0xfd, 0x98, 0x6d, 0xc2, 0x0e,
1657 0x0c, 0xcb, 0x32, 0x6e, 0x6c, 0x62, 0x4e, 0x67, 0x21, 0x33, 0xcd, 0x9e,
1658 0x0e, 0xfa, 0x2a, 0x4f, 0x81, 0x97, 0xf7, 0x43, 0x76, 0x24, 0xf3, 0x22,
1659 0x3d, 0x8d, 0xe6, 0xac, 0x45, 0x4c, 0x72, 0x5d, 0xbf, 0x69, 0xf1, 0xb8,
1660 0xef, 0xce, 0xe5, 0xcf, 0x59, 0x40, 0x3e, 0x38, 0x94, 0x91, 0xd7, 0x37,
1661 0x9a, 0x75, 0xbb, 0xb7, 0x36, 0x32, 0x1e, 0xa3, 0x36, 0x75, 0xaf, 0xd6,
1662 0xf2, 0xc7, 0x09, 0xbf, 0xbf, 0xb2, 0xe8, 0x3b, 0xac, 0xf7, 0x93, 0xd5,
1663 0x0b, 0xeb, 0x85, 0xe9, 0x70, 0x4d, 0x16, 0xa4, 0x1f, 0x58, 0xb3, 0xb0,
1664 0x7e, 0xac, 0x69, 0xe1, 0xf7, 0xe0, 0xa2, 0xef, 0xcf, 0x2c, 0xfa, 0x7e,
1665 0x61, 0xd1, 0xf7, 0x75, 0x6b, 0x17, 0x95, 0x5f, 0xf4, 0xfd, 0xe5, 0xb5,
1666 0xcb, 0xc3, 0xfb, 0x57, 0x6b, 0x17, 0xc2, 0xf5, 0x94, 0x5e, 0x73, 0x1d,
1667 0xaf, 0xb8, 0xb2, 0xbd, 0x88, 0x7c, 0xe7, 0xd6, 0x18, 0xf2, 0xe1, 0xcb,
1668 0x54, 0xe7, 0x73, 0x8d, 0xe3, 0x1d, 0xb1, 0x85, 0xed, 0xcd, 0xd7, 0xdb,
1669 0x31, 0x5f, 0x2f, 0x35, 0x5f, 0xcf, 0xf8, 0x23, 0x13, 0x15, 0xe6, 0x31,
1670 0x3d, 0x6c, 0xd7, 0xd4, 0x1d, 0x29, 0x79, 0xfa, 0x3c, 0xc2, 0x80, 0x3e,
1671 0x8f, 0x90, 0x80, 0x6f, 0xf4, 0x94, 0x8e, 0xeb, 0xaf, 0x51, 0x48, 0xaf,
1672 0x34, 0xea, 0xd8, 0xbe, 0xe8, 0x33, 0x09, 0x03, 0xb0, 0xb9, 0x78, 0x0e,
1673 0x21, 0x90, 0x9d, 0x29, 0xf3, 0x36, 0xe7, 0x12, 0x0e, 0x07, 0xbd, 0x5e,
1674 0x10, 0x0c, 0xfb, 0x67, 0xad, 0x2c, 0xc7, 0xbb, 0x62, 0xea, 0xd0, 0xd7,
1675 0x7c, 0x14, 0xfa, 0x66, 0xde, 0xc7, 0x7c, 0x8a, 0xf6, 0x3a, 0x68, 0xa6,
1676 0x1b, 0x7a, 0x37, 0xf9, 0xa4, 0x68, 0xdd, 0xd1, 0x05, 0x9d, 0xeb, 0xdd,
1677 0xfb, 0x3e, 0xd8, 0x3a, 0x5f, 0x06, 0xad, 0x1f, 0x4b, 0xf5, 0x68, 0xff,
1678 0xff, 0x1c, 0x74, 0x31, 0xe3, 0x84, 0x8f, 0x69, 0xda, 0x22, 0x8d, 0x35,
1679 0xe8, 0xb3, 0x50, 0x27, 0x53, 0x4e, 0x34, 0xdb, 0x75, 0xde, 0xc4, 0xcd,
1680 0x53, 0xed, 0xde, 0x73, 0xe0, 0xb5, 0x7e, 0x7f, 0x03, 0x6c, 0x66, 0xd1,
1681 0x3a, 0xbf, 0x50, 0x5a, 0x6f, 0x6d, 0x83, 0x66, 0x19, 0x77, 0xb9, 0x56,
1682 0x93, 0xec, 0x19, 0x32, 0x3e, 0x66, 0x3c, 0xa1, 0x18, 0x23, 0xe6, 0xfa,
1683 0x05, 0xcf, 0x39, 0x70, 0x9d, 0x9b, 0xf1, 0x90, 0xf1, 0x7b, 0x47, 0xfc,
1684 0xbc, 0x17, 0xb1, 0x67, 0x23, 0xb2, 0x45, 0x43, 0x9b, 0x7b, 0xb4, 0xad,
1685 0x1a, 0x05, 0x3f, 0x7d, 0x0f, 0x74, 0xcf, 0xba, 0xa4, 0xfd, 0xef, 0x04,
1686 0x93, 0xae, 0x89, 0x4f, 0x29, 0xd4, 0xcb, 0x6a, 0x5c, 0x3d, 0x25, 0x07,
1687 0x4a, 0xe4, 0xff, 0xa8, 0x96, 0xe5, 0xbb, 0x53, 0x94, 0x07, 0x51, 0xe0,
1688 0x71, 0x0a, 0xf8, 0x6b, 0x90, 0xdd, 0x5d, 0x45, 0x94, 0x89, 0xc8, 0xd0,
1689 0x40, 0x03, 0x78, 0x8f, 0x76, 0x09, 0xdf, 0x2e, 0xca, 0x7b, 0x32, 0x55,
1690 0x1c, 0xd7, 0x7b, 0x9e, 0x1f, 0x43, 0xdd, 0xc7, 0xf1, 0x4c, 0x14, 0xcb,
1691 0xa8, 0xf3, 0xb0, 0x2e, 0x3f, 0x31, 0xca, 0x73, 0x22, 0x02, 0x7b, 0xff,
1692 0x49, 0x29, 0x4c, 0xb6, 0xc1, 0x2f, 0x99, 0x1e, 0x77, 0xe7, 0xe2, 0xe4,
1693 0xff, 0xa5, 0x91, 0xeb, 0xcc, 0x85, 0xeb, 0xb8, 0x27, 0x47, 0xdc, 0x81,
1694 0xcd, 0xaa, 0xb3, 0x49, 0xaf, 0xf9, 0xf4, 0x48, 0x3f, 0x6c, 0x8a, 0x9b,
1695 0x2b, 0xcf, 0xc4, 0xcc, 0xda, 0xc0, 0x82, 0xf5, 0x86, 0xc3, 0xc4, 0x8a,
1696 0x3a, 0xea, 0xf2, 0xdc, 0xa7, 0x4c, 0x9c, 0x81, 0xf6, 0x39, 0x1a, 0xae,
1697 0xe7, 0x30, 0xcd, 0x93, 0xb6, 0xeb, 0x00, 0xd7, 0x99, 0x7f, 0xd2, 0xf2,
1698 0xf5, 0x89, 0x4d, 0x61, 0x5f, 0xf9, 0x60, 0x6c, 0x53, 0x5e, 0x3e, 0x81,
1699 0x27, 0x77, 0x5d, 0x72, 0x34, 0xab, 0xd8, 0xef, 0x37, 0x02, 0xc6, 0x02,
1700 0x54, 0xba, 0x55, 0xf2, 0x4d, 0xd5, 0xfd, 0x33, 0xad, 0xc3, 0x2b, 0xa8,
1701 0xd7, 0x83, 0x63, 0x26, 0x11, 0x03, 0x0e, 0xf2, 0x6f, 0x08, 0xcf, 0x16,
1702 0xcf, 0x57, 0xcb, 0xc1, 0x73, 0xc2, 0xae, 0xd7, 0x70, 0x0d, 0x66, 0x05,
1703 0xf0, 0xd2, 0x80, 0xf4, 0x09, 0x19, 0x39, 0xfe, 0x3b, 0x31, 0xee, 0x17,
1704 0xaa, 0xd1, 0x7e, 0xf5, 0x7d, 0xf5, 0x26, 0x06, 0xf2, 0x2c, 0xca, 0x30,
1705 0x7f, 0x1c, 0x75, 0x92, 0xf9, 0x6c, 0x64, 0xad, 0x0c, 0xe9, 0x7e, 0x83,
1706 0x48, 0xdb, 0xb6, 0x7a, 0xbd, 0x4f, 0x5f, 0xce, 0x30, 0x6e, 0x11, 0xd6,
1707 0x7d, 0x56, 0xef, 0x83, 0x73, 0xd3, 0xc9, 0x7c, 0x5f, 0x84, 0xf2, 0xa9,
1708 0x53, 0x7a, 0xb9, 0xce, 0x73, 0x66, 0x5c, 0xd3, 0x76, 0xfb, 0x26, 0x9e,
1709 0x07, 0xdd, 0x02, 0xfb, 0xef, 0x3b, 0x80, 0x89, 0x30, 0x9e, 0x40, 0x3a,
1710 0x7c, 0xc2, 0xd7, 0x85, 0x61, 0xfa, 0x4d, 0xc2, 0x30, 0xfd, 0x26, 0x61,
1711 0x20, 0x2e, 0x00, 0x47, 0xa5, 0x7d, 0x75, 0x68, 0x53, 0x5c, 0x85, 0x71,
1712 0x1c, 0x2c, 0x4d, 0xc3, 0xbf, 0xd5, 0x31, 0x94, 0xce, 0x69, 0x45, 0x9e,
1713 0xf7, 0xc0, 0x73, 0xe0, 0xad, 0x12, 0x78, 0x0f, 0xb6, 0xe1, 0x97, 0x61,
1714 0x1b, 0x3e, 0x01, 0xdb, 0xf0, 0x1c, 0x6c, 0xc3, 0xc7, 0x31, 0x37, 0x8f,
1715 0x2d, 0xe0, 0xd5, 0x8c, 0xe6, 0xd5, 0x42, 0xe9, 0x02, 0x78, 0xb5, 0xeb,
1716 0x0a, 0xfc, 0xe8, 0xc2, 0xc6, 0xa7, 0x0d, 0xed, 0xc0, 0x96, 0xff, 0xb8,
1717 0xf6, 0x8b, 0x1f, 0x4c, 0x8d, 0xb1, 0x0e, 0x68, 0x38, 0x49, 0x9f, 0x16,
1718 0xf2, 0x3f, 0x99, 0x07, 0xef, 0x61, 0xac, 0x8e, 0xa3, 0xae, 0x5b, 0x23,
1719 0xd4, 0x1f, 0xee, 0x36, 0xee, 0xef, 0xe6, 0x58, 0x13, 0x8b, 0xf0, 0x64,
1720 0xf8, 0x73, 0x8f, 0x4f, 0x3d, 0x42, 0xbe, 0x4c, 0x7c, 0x76, 0xc4, 0xaf,
1721 0xe6, 0xc5, 0x1d, 0x1c, 0x5f, 0xe0, 0x6d, 0x5a, 0xae, 0xee, 0x7c, 0xf9,
1722 0x35, 0x73, 0xe5, 0x75, 0xff, 0xa3, 0xe4, 0x37, 0xe8, 0x6e, 0xe2, 0x3e,
1723 0x91, 0x8d, 0x6c, 0xb0, 0xb8, 0xdf, 0x2f, 0x6d, 0xdb, 0x60, 0xaf, 0x0f,
1724 0x82, 0x7e, 0xa7, 0x02, 0xf1, 0xb7, 0x85, 0x6d, 0xce, 0xb7, 0xe3, 0xd9,
1725 0x76, 0x76, 0xc3, 0x96, 0xed, 0xdb, 0xc4, 0xb5, 0x5e, 0xd8, 0xf2, 0xa9,
1726 0x70, 0x3e, 0x60, 0xf9, 0xea, 0x39, 0xa7, 0x0c, 0xa5, 0xec, 0x6c, 0xb0,
1727 0xf1, 0x7e, 0xb6, 0x77, 0x61, 0xd1, 0x3c, 0x5d, 0x0a, 0x78, 0xce, 0x76,
1728 0xc4, 0x1f, 0xab, 0xa2, 0x95, 0xbf, 0xb2, 0xb4, 0xa2, 0x16, 0x8d, 0xe3,
1729 0x9c, 0xa5, 0x95, 0x10, 0xde, 0x58, 0x48, 0x2b, 0x75, 0x21, 0xad, 0xe4,
1730 0xc7, 0x43, 0x5a, 0x61, 0xdd, 0x73, 0x21, 0xad, 0x24, 0xaa, 0x69, 0x25,
1731 0x3f, 0xee, 0xe0, 0x59, 0x0c, 0x07, 0xe9, 0x85, 0xed, 0x90, 0x5e, 0x00,
1732 0x4b, 0xa5, 0x32, 0x47, 0x2f, 0x31, 0xb4, 0x73, 0xa8, 0xa4, 0x34, 0xad,
1733 0x0c, 0xa9, 0x50, 0x47, 0x78, 0x98, 0x73, 0xcc, 0xfd, 0x15, 0x69, 0x24,
1734 0x65, 0x69, 0x64, 0xfe, 0x2c, 0xd1, 0x22, 0xda, 0x00, 0xee, 0x79, 0x5e,
1735 0x60, 0xb3, 0xa6, 0x8d, 0xfb, 0x53, 0x2f, 0xa0, 0xec, 0x28, 0x68, 0x23,
1736 0xc4, 0xc1, 0x03, 0x16, 0x07, 0x8b, 0xe7, 0xf2, 0xb4, 0xc5, 0xc1, 0xa8,
1737 0xc5, 0x81, 0xe6, 0x97, 0x3c, 0xe7, 0x4c, 0x69, 0x1c, 0xd4, 0x69, 0x1c,
1738 0x88, 0x0a, 0xeb, 0x9e, 0x5e, 0x06, 0x07, 0x2c, 0x33, 0xaa, 0xc7, 0x1f,
1739 0xc1, 0xf8, 0xf7, 0x61, 0xfc, 0x4a, 0x8f, 0x9f, 0xf3, 0xc0, 0xf1, 0x03,
1740 0x96, 0xca, 0x77, 0xe6, 0xc6, 0xdf, 0x84, 0x36, 0x0e, 0x6a, 0xdb, 0x99,
1741 0xf1, 0x54, 0xea, 0x46, 0x33, 0xfe, 0xc7, 0x2a, 0xe6, 0x8c, 0xc9, 0x63,
1742 0x4b, 0xf4, 0xd8, 0x0b, 0x96, 0x37, 0x7c, 0xbd, 0xce, 0xc6, 0x73, 0x6d,
1743 0xe7, 0xa0, 0xbb, 0xc6, 0x52, 0x09, 0x7b, 0xe6, 0xd4, 0xd8, 0x43, 0x5f,
1744 0x4d, 0x91, 0x77, 0x3e, 0xaa, 0xf7, 0xfa, 0x9d, 0xa5, 0x5d, 0x54, 0x6a,
1745 0x92, 0xbe, 0xb1, 0x6a, 0xb8, 0x09, 0x6f, 0x3e, 0x50, 0x3e, 0x63, 0x37,
1746 0xfb, 0xa1, 0x3b, 0x4c, 0xdc, 0x1a, 0xb4, 0x84, 0xf4, 0x64, 0xbe, 0x37,
1747 0x52, 0x27, 0xea, 0x81, 0x0f, 0x60, 0xcc, 0x2e, 0x7c, 0xcc, 0x76, 0x6f,
1748 0x9b, 0xa2, 0xae, 0xbb, 0xba, 0x4a, 0xd7, 0x35, 0x5b, 0x5d, 0xb7, 0x86,
1749 0xba, 0x0e, 0x70, 0x3f, 0x25, 0x87, 0x4b, 0x9c, 0xbf, 0x7c, 0xa2, 0x4e,
1750 0xc7, 0x40, 0x1d, 0x1b, 0xe7, 0x4b, 0xc6, 0x0f, 0x6b, 0x5a, 0xa6, 0xce,
1751 0x4a, 0xea, 0xb8, 0xe4, 0x4c, 0xd7, 0x3f, 0xd9, 0x75, 0x10, 0xea, 0xb5,
1752 0xef, 0x07, 0x7f, 0xb0, 0x8c, 0x5e, 0x83, 0xfe, 0xd1, 0xf6, 0x59, 0x0d,
1753 0x64, 0xad, 0x9c, 0x6a, 0xc6, 0xb3, 0x9a, 0xe7, 0xc1, 0x3a, 0x3b, 0x54,
1754 0xbd, 0xd4, 0x9c, 0x6a, 0x94, 0x3d, 0x63, 0x7a, 0xdd, 0x5c, 0xd4, 0x29,
1755 0xe0, 0xff, 0x14, 0xcf, 0x14, 0x88, 0x3e, 0x03, 0x95, 0x1b, 0x85, 0x3f,
1756 0x33, 0xf1, 0x94, 0xd9, 0x1b, 0x38, 0x56, 0xa3, 0x7f, 0xd3, 0xc6, 0x28,
1757 0xa4, 0x32, 0xfa, 0xec, 0xd0, 0x1e, 0xb4, 0xd9, 0xbe, 0xa9, 0x16, 0x63,
1758 0x8e, 0xa1, 0x2e, 0xf7, 0x16, 0xaa, 0x36, 0x57, 0x6a, 0xc5, 0x9d, 0x88,
1759 0xea, 0xf3, 0x4b, 0x3c, 0x7f, 0x9f, 0xed, 0x69, 0x42, 0x5e, 0x44, 0xaf,
1760 0x15, 0xd4, 0x9c, 0x9a, 0x3f, 0xa7, 0xae, 0x8e, 0x8a, 0x5d, 0xc3, 0x4f,
1761 0x6b, 0xbd, 0x12, 0x39, 0x4a, 0x9d, 0xc3, 0xfd, 0x55, 0x3d, 0x98, 0xf7,
1762 0xe5, 0xf4, 0x8d, 0x31, 0x62, 0xb3, 0x98, 0x3f, 0x75, 0x86, 0x67, 0x8d,
1763 0x5b, 0xf1, 0x0e, 0xdb, 0x0b, 0xf5, 0x08, 0x74, 0xdf, 0xdb, 0x3f, 0xe1,
1764 0x49, 0x3d, 0xf0, 0x3d, 0xa1, 0x80, 0x6b, 0x57, 0xd3, 0x42, 0x5e, 0x85,
1765 0xb1, 0x69, 0x43, 0x0f, 0x8f, 0xbf, 0x21, 0x3f, 0x90, 0x26, 0x3a, 0x6d,
1766 0x6c, 0xc1, 0xb7, 0x31, 0x7e, 0xd2, 0xb6, 0xa1, 0x87, 0x47, 0x53, 0x19,
1767 0xc5, 0xbd, 0x51, 0x66, 0x1d, 0x94, 0xb4, 0x41, 0x9a, 0x4f, 0xe8, 0xf5,
1768 0xd1, 0x8c, 0xbc, 0x2c, 0x99, 0xa6, 0x76, 0xd8, 0x5d, 0xff, 0xb6, 0x73,
1769 0x6c, 0xee, 0x2e, 0xd0, 0x34, 0x07, 0xdd, 0xc4, 0x7d, 0xca, 0x9d, 0xf2,
1770 0x5e, 0x9e, 0x57, 0x98, 0x70, 0xa0, 0x94, 0x9f, 0xd2, 0x7b, 0xbf, 0x77,
1771 0x14, 0x57, 0xcb, 0xad, 0xa9, 0xa8, 0x5d, 0xe7, 0xac, 0x05, 0x1d, 0x40,
1772 0x50, 0x9f, 0xaa, 0xc5, 0x13, 0x75, 0x38, 0x7f, 0x17, 0x53, 0x99, 0xa4,
1773 0x22, 0xb3, 0xc3, 0xe7, 0x9f, 0x91, 0x2d, 0xde, 0x1e, 0x7d, 0xce, 0x4e,
1774 0x9c, 0xba, 0x53, 0x7f, 0xe9, 0xd1, 0x06, 0x25, 0xfd, 0xcc, 0xf8, 0xb5,
1775 0x7a, 0x5d, 0xab, 0x3f, 0x15, 0x04, 0x39, 0xcc, 0x5f, 0x41, 0x4c, 0xfc,
1776 0x6c, 0xc2, 0x67, 0x1a, 0xfd, 0xda, 0x06, 0xa7, 0xf6, 0x4c, 0xa3, 0x63,
1777 0x68, 0x45, 0x22, 0x2a, 0x5d, 0xef, 0xd4, 0x9c, 0xba, 0x93, 0x73, 0x06,
1778 0xba, 0xf2, 0x1c, 0x43, 0x57, 0x31, 0x67, 0x9e, 0xae, 0xd6, 0xd9, 0xdf,
1779 0x2a, 0x5d, 0x27, 0x99, 0x64, 0x1d, 0xc6, 0xdb, 0x5b, 0x0c, 0x61, 0x3c,
1780 0x0c, 0xb8, 0x08, 0xcf, 0xdd, 0x18, 0xc3, 0x30, 0x9e, 0x3c, 0x60, 0x01,
1781 0xb3, 0x9f, 0x2a, 0x00, 0xe6, 0x83, 0x78, 0x18, 0x27, 0x6b, 0x76, 0x22,
1782 0x13, 0xd5, 0xf0, 0x12, 0xc6, 0x1f, 0x5b, 0x78, 0x5f, 0x0f, 0x56, 0x4f,
1783 0x66, 0xba, 0x8b, 0x80, 0x87, 0x70, 0xde, 0x07, 0x18, 0x69, 0x97, 0x8e,
1784 0xe2, 0xdb, 0x03, 0x7c, 0x63, 0x16, 0x26, 0xd0, 0xe3, 0xd8, 0x43, 0xf3,
1785 0xbf, 0x8b, 0xb4, 0x93, 0x8f, 0xd9, 0xef, 0xd6, 0x45, 0x32, 0xe0, 0x15,
1786 0x87, 0x78, 0x1e, 0x29, 0xbd, 0xe6, 0xc0, 0x0e, 0x00, 0xdf, 0xbf, 0xe4,
1787 0x44, 0xce, 0xc4, 0xe5, 0x50, 0x91, 0x31, 0x84, 0xe3, 0x0e, 0xe7, 0x41,
1788 0xf9, 0x57, 0xa1, 0x4c, 0x5c, 0xc9, 0xc4, 0xd5, 0x78, 0xde, 0x82, 0x67,
1789 0x03, 0x9e, 0x8d, 0x78, 0xd6, 0xe3, 0x69, 0xc5, 0xf3, 0x2d, 0x94, 0x53,
1790 0xb1, 0x3a, 0xe1, 0x7e, 0xd5, 0x16, 0xa5, 0x34, 0x1f, 0x71, 0xcf, 0xc2,
1791 0x65, 0xc0, 0xe5, 0x2b, 0xd0, 0x3b, 0x1e, 0x9e, 0xf1, 0xf8, 0x3a, 0xfa,
1792 0x98, 0xc5, 0xd3, 0xa9, 0xe4, 0x4c, 0x17, 0x9e, 0x14, 0x9e, 0x6e, 0x3c,
1793 0x3d, 0x78, 0xd2, 0x78, 0x5e, 0x75, 0x0c, 0xcf, 0x5d, 0x02, 0xbe, 0x42,
1794 0x1e, 0x01, 0xce, 0x17, 0xf0, 0x9c, 0xe7, 0xbc, 0x09, 0x9e, 0x73, 0x2c,
1795 0xcf, 0x39, 0xf3, 0x3c, 0x57, 0xeb, 0xa8, 0x63, 0xf5, 0x4e, 0xe4, 0x18,
1796 0x7d, 0x85, 0x5a, 0xc7, 0xf0, 0x7f, 0x44, 0x7a, 0x07, 0x41, 0x4b, 0xc7,
1797 0x30, 0x67, 0xc7, 0x48, 0x57, 0x2e, 0xd2, 0xc7, 0x16, 0xf5, 0x3b, 0xfa,
1798 0x26, 0xfa, 0x3d, 0x61, 0xfb, 0x7d, 0xb8, 0xaa, 0xdf, 0x83, 0x68, 0xfb,
1799 0x3e, 0xdb, 0xef, 0xc1, 0xaa, 0x7e, 0x41, 0x2b, 0xc7, 0xf2, 0x78, 0x48,
1800 0x17, 0x23, 0x48, 0x0f, 0x65, 0xc2, 0xdd, 0x6b, 0xa4, 0xbe, 0x46, 0x9f,
1801 0x27, 0x8d, 0xf9, 0x35, 0x73, 0xba, 0x31, 0x53, 0xa5, 0x1f, 0x7e, 0x16,
1802 0xfd, 0x38, 0x5c, 0xa2, 0x8d, 0x38, 0x5d, 0x25, 0x17, 0xe8, 0xfb, 0x04,
1803 0x72, 0x5c, 0xfb, 0x39, 0xf4, 0x79, 0xe8, 0xff, 0x2c, 0xb6, 0xad, 0x3e,
1804 0xae, 0xf7, 0xe7, 0xde, 0x55, 0x6c, 0x95, 0x4f, 0x14, 0x69, 0x13, 0x92,
1805 0x5e, 0x82, 0x60, 0xcf, 0x36, 0xda, 0xa7, 0xf9, 0x60, 0x9d, 0x9f, 0xd4,
1806 0xb1, 0xb5, 0x4f, 0x2e, 0xd5, 0x19, 0xa3, 0xbd, 0xf0, 0xcd, 0xb3, 0x47,
1807 0x3f, 0x08, 0x9d, 0x51, 0x03, 0xb8, 0x9f, 0xd2, 0x77, 0x80, 0xec, 0x1a,
1808 0x55, 0x23, 0x6b, 0x25, 0x2e, 0x37, 0x17, 0x6b, 0x61, 0xf7, 0x30, 0x56,
1809 0x5e, 0x2f, 0xed, 0xdb, 0xa2, 0xe6, 0x6c, 0x8d, 0x17, 0xc3, 0x6f, 0xcf,
1810 0x9c, 0xf5, 0x89, 0xc5, 0x91, 0x1f, 0x69, 0xa2, 0x1c, 0x8c, 0xf9, 0xef,
1811 0xd4, 0xfb, 0x26, 0xdb, 0xb6, 0xd1, 0x6e, 0xb9, 0x41, 0xeb, 0x70, 0x77,
1812 0x89, 0x9d, 0xa4, 0x5a, 0x3c, 0x99, 0xb7, 0xd1, 0x76, 0x17, 0x93, 0x09,
1813 0xc2, 0xf5, 0x90, 0x70, 0x3f, 0xc1, 0x7e, 0x29, 0xa4, 0x1a, 0x25, 0x92,
1814 0xe6, 0xba, 0x5c, 0xb2, 0x93, 0xb6, 0xd1, 0xc4, 0x98, 0x67, 0xcf, 0x9e,
1815 0xac, 0x96, 0x0b, 0xba, 0x9f, 0x5a, 0x0d, 0xa3, 0x39, 0x8f, 0xc6, 0x35,
1816 0x2f, 0x9e, 0x81, 0x72, 0xf1, 0x6e, 0xd0, 0x7a, 0x67, 0xa2, 0xcc, 0xb3,
1817 0x4e, 0xf0, 0x97, 0xca, 0x31, 0x7d, 0xc6, 0xd4, 0x7b, 0x3b, 0xfc, 0xd8,
1818 0xf2, 0x06, 0xd9, 0x3d, 0xb6, 0x82, 0xeb, 0x28, 0xb1, 0xb5, 0xd0, 0x1f,
1819 0xac, 0xd3, 0xb6, 0x0d, 0xfe, 0xdf, 0xf8, 0x46, 0x79, 0x7c, 0x9c, 0x6d,
1820 0xb7, 0xc8, 0xe4, 0x94, 0x38, 0xde, 0xdb, 0x57, 0xa2, 0x8c, 0xc7, 0xf1,
1821 0x08, 0xf7, 0x3c, 0xb5, 0x6d, 0x13, 0xe5, 0xbd, 0xdd, 0x95, 0xf3, 0xdd,
1822 0x11, 0xbd, 0x26, 0xe3, 0x82, 0x4e, 0xd8, 0xde, 0xf9, 0xee, 0x56, 0x39,
1823 0x3b, 0x05, 0x9a, 0x80, 0xdc, 0xef, 0x3b, 0x45, 0x98, 0x44, 0xb6, 0x4f,
1824 0xc0, 0x5e, 0x90, 0x76, 0x3c, 0xa0, 0x0f, 0xc8, 0xef, 0x5b, 0xbb, 0xd9,
1825 0x17, 0xf4, 0x12, 0x74, 0x5c, 0xdb, 0x36, 0x23, 0x0b, 0x32, 0x13, 0x35,
1826 0x48, 0x67, 0xbb, 0xf0, 0x0f, 0x07, 0xd9, 0x4e, 0x58, 0x57, 0x61, 0x4c,
1827 0xb5, 0x9a, 0x5e, 0x66, 0x17, 0xe9, 0x8f, 0x73, 0x3f, 0x97, 0xfd, 0xcd,
1828 0x36, 0x3a, 0x41, 0x2b, 0xbe, 0xde, 0xc3, 0x63, 0x6c, 0x2b, 0xce, 0x09,
1829 0x6d, 0x22, 0xda, 0x55, 0xd7, 0x6a, 0xfb, 0x62, 0xb2, 0xc2, 0x19, 0xe4,
1830 0xda, 0x48, 0x38, 0x47, 0x71, 0x39, 0x59, 0x9a, 0x9b, 0xa7, 0x0d, 0x35,
1831 0x0b, 0xe7, 0x89, 0xb4, 0x92, 0x1a, 0xb2, 0xb6, 0xc7, 0x8c, 0x3c, 0x0f,
1832 0xbb, 0xac, 0x53, 0xcf, 0xd9, 0x0c, 0x6c, 0x59, 0x3b, 0x67, 0xda, 0x9e,
1833 0x2d, 0x84, 0x73, 0x36, 0x00, 0x8d, 0x53, 0xbe, 0x41, 0xcf, 0x99, 0x07,
1834 0xba, 0xc9, 0x03, 0xef, 0x79, 0xcc, 0x53, 0x1e, 0x73, 0x94, 0x2f, 0xb7,
1835 0xc8, 0xc4, 0x71, 0xd5, 0x5a, 0x23, 0x92, 0xd8, 0xed, 0xb7, 0xc8, 0xf0,
1836 0x14, 0x63, 0x05, 0x1b, 0x60, 0x83, 0x6d, 0xc4, 0xd3, 0x8a, 0x6f, 0xd6,
1837 0xe3, 0x1d, 0x1f, 0x0a, 0x75, 0xeb, 0x96, 0xd8, 0x59, 0x67, 0xd1, 0xf7,
1838 0xd3, 0xc0, 0xc3, 0xa3, 0xc0, 0xc3, 0x3c, 0xef, 0xbc, 0x50, 0x15, 0x5f,
1839 0xe2, 0x58, 0xb5, 0x0e, 0xc5, 0x78, 0x63, 0x7a, 0x3e, 0x75, 0x9c, 0xa9,
1840 0x54, 0xfb, 0x66, 0xec, 0xa9, 0x38, 0xed, 0xa9, 0xdc, 0xa8, 0x67, 0xce,
1841 0x60, 0x0d, 0xc0, 0x77, 0xf2, 0xf7, 0x69, 0x5a, 0x1f, 0x1a, 0x27, 0x5c,
1842 0xd1, 0x10, 0xae, 0x05, 0x73, 0xc6, 0x33, 0xb3, 0x4b, 0xe3, 0x18, 0x2f,
1843 0xcc, 0xed, 0x11, 0x87, 0x2e, 0x97, 0xd1, 0x14, 0xe3, 0x24, 0xad, 0xcb,
1844 0xc0, 0xf4, 0x94, 0xb6, 0x61, 0x45, 0x9d, 0x96, 0x03, 0x25, 0x9e, 0xb7,
1845 0xe5, 0x1a, 0xcc, 0xef, 0x31, 0x7e, 0xd4, 0x39, 0x21, 0xc7, 0xd0, 0x37,
1846 0xd7, 0xc5, 0x95, 0x8d, 0xcf, 0xac, 0xb2, 0x7b, 0xf2, 0xaa, 0x63, 0x34,
1847 0x66, 0xdd, 0x7c, 0xe1, 0xd9, 0x93, 0xe4, 0xc0, 0xac, 0x5e, 0x77, 0xe5,
1848 0x9a, 0xa1, 0x8c, 0x46, 0xa0, 0xfd, 0x76, 0x77, 0x27, 0x7b, 0xcc, 0x59,
1849 0xc3, 0x84, 0xf4, 0x97, 0xcc, 0xf8, 0x2f, 0xea, 0x7d, 0x93, 0x66, 0x7f,
1850 0xb8, 0xd9, 0x53, 0xb9, 0x5f, 0x2e, 0xa6, 0xa2, 0x55, 0x73, 0x5b, 0x27,
1851 0xc3, 0xc0, 0x85, 0x5e, 0xcb, 0x84, 0x5d, 0x9c, 0xeb, 0x7e, 0xbc, 0x89,
1852 0x67, 0xd1, 0xa2, 0x98, 0x9f, 0xc2, 0x38, 0xcf, 0xa7, 0xb3, 0xdd, 0x2b,
1853 0xb5, 0x45, 0x31, 0xcb, 0xb3, 0x4e, 0x90, 0x95, 0x6f, 0xdd, 0x12, 0xaf,
1854 0xd7, 0xf9, 0x2b, 0xec, 0x99, 0x16, 0xd8, 0x0d, 0xbb, 0x02, 0xf9, 0x33,
1855 0xe8, 0xc9, 0xd3, 0x76, 0x4c, 0x09, 0x1d, 0x93, 0x92, 0xe0, 0x7c, 0x2a,
1856 0x6e, 0xe3, 0xce, 0x1c, 0xcb, 0x98, 0xa5, 0x6f, 0x63, 0xff, 0xcc, 0xdb,
1857 0xd0, 0x5d, 0x9a, 0xd6, 0x1f, 0xd7, 0xb2, 0xb0, 0xcb, 0xda, 0xce, 0x3a,
1858 0x8e, 0x73, 0x42, 0xf4, 0x1e, 0xac, 0xd0, 0x37, 0xea, 0xa8, 0xf2, 0x0b,
1859 0x8c, 0x2f, 0x57, 0x18, 0x5b, 0x4e, 0x46, 0xcd, 0xfb, 0x84, 0xf4, 0xe5,
1860 0xf6, 0x6c, 0xe2, 0xdd, 0x30, 0xa1, 0x2f, 0xd7, 0x65, 0x7d, 0xb9, 0x46,
1861 0xed, 0xcb, 0x99, 0xd8, 0x43, 0xe3, 0x9c, 0x2f, 0x57, 0x18, 0xcb, 0x83,
1862 0x56, 0x6a, 0xed, 0x59, 0x09, 0x63, 0x0b, 0x0d, 0x17, 0x5d, 0xbd, 0x6f,
1863 0x24, 0x37, 0xa0, 0xe0, 0x37, 0x18, 0x1f, 0x8b, 0xb1, 0x0a, 0xa5, 0xfe,
1864 0xce, 0xfa, 0x17, 0x1b, 0x24, 0xd3, 0xbc, 0x02, 0xe3, 0x7e, 0x4a, 0xcf,
1865 0xb9, 0x59, 0xc3, 0x82, 0x5c, 0x1b, 0x64, 0xcc, 0x87, 0x67, 0x47, 0x35,
1866 0x7f, 0x25, 0x7a, 0x23, 0x9d, 0xc6, 0x9e, 0xf5, 0x13, 0x6b, 0xa5, 0xfe,
1867 0xb8, 0x53, 0x18, 0x8f, 0xda, 0x7e, 0x13, 0x80, 0xa9, 0x06, 0x73, 0xf3,
1868 0x4e, 0x2b, 0x93, 0xd9, 0xf7, 0x3b, 0xea, 0x18, 0x1b, 0x98, 0x2a, 0x9a,
1869 0x18, 0x60, 0x5f, 0x31, 0x12, 0x9e, 0x5b, 0x57, 0x5c, 0x47, 0xce, 0x0c,
1870 0xae, 0x00, 0x2c, 0x2b, 0x96, 0xb5, 0x59, 0x1f, 0x7b, 0x43, 0x1d, 0x45,
1871 0x9a, 0x7a, 0x4a, 0xef, 0x2f, 0x5c, 0xd9, 0x9d, 0xdc, 0xa9, 0xcf, 0x23,
1872 0xe9, 0x58, 0x62, 0x5e, 0xb8, 0x7f, 0xf7, 0x9b, 0xf2, 0x36, 0x2d, 0xfb,
1873 0x0f, 0xa4, 0xa8, 0xc7, 0xb6, 0xe9, 0xdf, 0xb5, 0xe9, 0x20, 0x38, 0xdf,
1874 0xfd, 0x2c, 0x6c, 0x16, 0xdf, 0xfb, 0x96, 0xb4, 0xc7, 0x7b, 0xb5, 0x0d,
1875 0x85, 0xb9, 0x1a, 0xac, 0x97, 0x15, 0xfe, 0xb8, 0xdd, 0xab, 0x68, 0xd6,
1876 0x03, 0x0b, 0xc2, 0xfb, 0x17, 0x3a, 0x6c, 0x5e, 0x3e, 0xa8, 0x07, 0x3d,
1877 0x7d, 0x44, 0x8c, 0xac, 0xc9, 0xcd, 0xcb, 0x1a, 0xee, 0xa7, 0xcb, 0x90,
1878 0xa0, 0xdd, 0x23, 0x92, 0xe4, 0xdd, 0x49, 0xec, 0xbb, 0x20, 0x57, 0x41,
1879 0x3f, 0xb3, 0x1e, 0x6d, 0x56, 0x7e, 0x73, 0x0f, 0x8a, 0xef, 0x1d, 0x84,
1880 0x8e, 0xb9, 0x61, 0xa9, 0x8e, 0x89, 0xd3, 0xbf, 0xcf, 0x8d, 0xd2, 0x47,
1881 0x5c, 0x89, 0x3a, 0x2d, 0xf2, 0xd1, 0xb1, 0xdf, 0x5a, 0x4b, 0x1e, 0x1b,
1882 0x82, 0x7c, 0x57, 0xf7, 0x87, 0xe7, 0x2e, 0x99, 0xc6, 0x7c, 0xb6, 0x5b,
1883 0x27, 0x89, 0xf7, 0x79, 0xf2, 0xc5, 0x4a, 0x32, 0x31, 0x0b, 0x1d, 0x35,
1884 0xe4, 0x0c, 0xb7, 0x9a, 0xd8, 0xe9, 0xa7, 0xd6, 0x9a, 0x73, 0x5a, 0xf5,
1885 0xc0, 0x69, 0x18, 0x4f, 0xad, 0xa6, 0xdd, 0x59, 0x2b, 0x97, 0x83, 0xa0,
1886 0xbe, 0x5b, 0xcb, 0xe2, 0x9d, 0x94, 0xc5, 0x07, 0x52, 0x1d, 0x86, 0x07,
1887 0xb4, 0xef, 0xc4, 0x3d, 0x00, 0xc0, 0x43, 0xb7, 0xcb, 0xbd, 0xd0, 0x96,
1888 0x4f, 0xfd, 0xcc, 0x8c, 0x95, 0x4f, 0xca, 0x59, 0xca, 0x9f, 0x6a, 0x6b,
1889 0x74, 0x81, 0xec, 0x3d, 0x34, 0x46, 0xbd, 0x9c, 0x9a, 0xfe, 0x26, 0xe4,
1890 0x55, 0x4e, 0xe3, 0xa1, 0x45, 0xee, 0x1b, 0x93, 0xcc, 0x45, 0xe8, 0xac,
1891 0xc2, 0xd4, 0x42, 0x1e, 0x5d, 0xda, 0x1e, 0xc7, 0x7a, 0x7a, 0xad, 0xf1,
1892 0x71, 0x17, 0x8e, 0x75, 0x9a, 0x7b, 0x8c, 0xf4, 0x58, 0xb9, 0x37, 0xff,
1893 0x9c, 0x1d, 0xeb, 0xca, 0x70, 0xac, 0x3d, 0x0b, 0xc7, 0x1a, 0xfa, 0xf8,
1894 0xa1, 0xfc, 0x4d, 0xe8, 0xb3, 0x49, 0xfa, 0x4c, 0xcc, 0xd8, 0x4a, 0xe9,
1895 0x1d, 0x6d, 0xb4, 0x72, 0xd3, 0x83, 0x0e, 0xe2, 0x79, 0xa1, 0xe9, 0xcf,
1896 0x79, 0x62, 0x71, 0xa6, 0x88, 0x07, 0xca, 0xdc, 0x26, 0x7d, 0x9e, 0x71,
1897 0x02, 0x7e, 0xd6, 0x87, 0x8b, 0x2c, 0x1b, 0xe6, 0x5f, 0x29, 0x46, 0x1c,
1898 0xfa, 0xd6, 0xf4, 0x9f, 0x3a, 0x97, 0xc4, 0x16, 0x4c, 0x1c, 0x98, 0xf1,
1899 0x5f, 0x73, 0xcf, 0x02, 0xf7, 0x7d, 0xdf, 0x01, 0xde, 0xfa, 0xed, 0x62,
1900 0xb2, 0x27, 0x1b, 0xa1, 0x3c, 0x9d, 0x95, 0x43, 0x95, 0x3e, 0x69, 0xd3,
1901 0x67, 0xed, 0xdf, 0x30, 0x46, 0x9c, 0xa9, 0x8e, 0x11, 0x8b, 0x63, 0x62,
1902 0xc4, 0x3b, 0x7f, 0x8e, 0x18, 0xb1, 0x38, 0x26, 0x46, 0xbc, 0x9c, 0x9f,
1903 0x35, 0x52, 0x9a, 0xc5, 0xb8, 0xea, 0x21, 0x53, 0x94, 0x93, 0x9b, 0x6a,
1904 0xc0, 0xbb, 0x16, 0x6f, 0xc0, 0x32, 0x56, 0xc0, 0xdb, 0xc3, 0xfb, 0x20,
1905 0xde, 0x31, 0x19, 0x99, 0xd3, 0x1d, 0xb3, 0x90, 0x1f, 0xd4, 0x69, 0xac,
1906 0x6b, 0xfc, 0x82, 0xc9, 0x72, 0x33, 0xca, 0x5d, 0x72, 0x26, 0x58, 0xaf,
1907 0xd4, 0x28, 0xc3, 0x63, 0x94, 0xdd, 0x4d, 0x32, 0x3a, 0x16, 0xda, 0xb8,
1908 0x9f, 0x5d, 0xcf, 0xb5, 0x81, 0x21, 0x09, 0x6d, 0xd8, 0x67, 0xd6, 0x9b,
1909 0xb5, 0xdb, 0x2d, 0x31, 0xa9, 0x5f, 0x8d, 0x39, 0x38, 0xee, 0x5c, 0x1c,
1910 0x5f, 0xbd, 0xc0, 0x96, 0x4d, 0xd8, 0xd8, 0xe0, 0xb8, 0xd5, 0xc1, 0xcb,
1911 0xcb, 0x88, 0xea, 0xf9, 0x8f, 0xdb, 0x73, 0xbc, 0x51, 0x7b, 0xd7, 0x5f,
1912 0x42, 0xcf, 0xcf, 0x40, 0x65, 0x16, 0xfd, 0xad, 0x57, 0x99, 0x71, 0x8e,
1913 0x73, 0xee, 0x7e, 0x1e, 0xc8, 0xc5, 0x56, 0x35, 0x34, 0xbe, 0x80, 0x2e,
1914 0x41, 0xb7, 0x1c, 0x9b, 0x03, 0xda, 0xbd, 0x57, 0x26, 0x46, 0x09, 0x5f,
1915 0x47, 0x3c, 0xa2, 0xcf, 0xf5, 0xe2, 0x7b, 0xdc, 0x9c, 0x27, 0xea, 0xad,
1916 0x84, 0x67, 0x7a, 0xd7, 0x00, 0xde, 0xc5, 0xe7, 0x7a, 0xad, 0x9e, 0xd6,
1917 0x36, 0x04, 0xcf, 0xf7, 0x86, 0x63, 0x58, 0x8e, 0x9e, 0x02, 0x19, 0xd6,
1918 0xfb, 0x7d, 0xd7, 0xca, 0xe9, 0x07, 0xe7, 0xce, 0x17, 0x34, 0xc1, 0x56,
1919 0x69, 0x85, 0xa9, 0x3c, 0xe0, 0xa6, 0xb9, 0xef, 0x82, 0xfb, 0x0b, 0x3a,
1920 0xe2, 0xb7, 0xe9, 0x73, 0x1f, 0xf3, 0x67, 0xac, 0xe7, 0xcf, 0x7e, 0x84,
1921 0x67, 0x5a, 0xe3, 0xd2, 0x07, 0x3a, 0xec, 0xd7, 0xe9, 0x31, 0x8c, 0x87,
1922 0x6b, 0xbe, 0x1a, 0x0f, 0x90, 0x3d, 0x5c, 0xfb, 0xc5, 0xd8, 0x2b, 0x2d,
1923 0x2a, 0xa7, 0xcf, 0x58, 0x47, 0x2d, 0x8d, 0x5d, 0x76, 0xf6, 0x94, 0x13,
1924 0x6a, 0x4f, 0xd9, 0x57, 0x7b, 0xcb, 0x36, 0xaf, 0xfb, 0x01, 0xcc, 0x07,
1925 0x7e, 0x8f, 0x17, 0x9d, 0x21, 0xe0, 0xab, 0x50, 0x3a, 0xe2, 0x64, 0xf4,
1926 0xfb, 0xa8, 0x7d, 0x43, 0x0e, 0x60, 0xae, 0x7a, 0xc7, 0xa3, 0x5a, 0xde,
1927 0xcf, 0xdf, 0xd3, 0x17, 0xce, 0xeb, 0x0b, 0x7a, 0x0d, 0x68, 0x5a, 0x88,
1928 0x6b, 0xcf, 0xda, 0x10, 0xc7, 0x9d, 0x9c, 0xc6, 0x3d, 0xcb, 0x7c, 0x4b,
1929 0xff, 0x06, 0x9d, 0x2b, 0xd3, 0x5e, 0x2b, 0xde, 0x8b, 0xf7, 0x4d, 0x86,
1930 0xfa, 0x86, 0x70, 0xdf, 0x09, 0xbd, 0x16, 0xec, 0x37, 0xf2, 0x6a, 0x56,
1931 0x46, 0x2a, 0x5c, 0xc3, 0x64, 0x3b, 0x48, 0x2f, 0xd7, 0xc0, 0x1e, 0x58,
1932 0x78, 0xbe, 0xba, 0x7f, 0x7e, 0x1e, 0x12, 0xe3, 0x42, 0x58, 0xee, 0xd6,
1933 0x67, 0x17, 0xab, 0xef, 0x1e, 0xb9, 0xf2, 0xbf, 0x70, 0xfd, 0xd0, 0xc8,
1934 0x50, 0x0b, 0x47, 0x86, 0xf2, 0xce, 0xc8, 0x95, 0xaf, 0xcb, 0x41, 0xe0,
1935 0xf1, 0x30, 0x60, 0x52, 0xf7, 0xf3, 0xce, 0xab, 0x57, 0xa5, 0x30, 0x59,
1936 0x2f, 0xea, 0xa1, 0x82, 0xe3, 0x3e, 0x54, 0x2b, 0x91, 0x87, 0x94, 0x53,
1937 0xf3, 0x50, 0xbb, 0xf6, 0xcf, 0x77, 0xa4, 0xda, 0xe3, 0x7b, 0xe5, 0xb8,
1938 0xe3, 0xde, 0xaf, 0xf4, 0x59, 0xdb, 0x82, 0xc7, 0x58, 0xdf, 0x71, 0x27,
1939 0x72, 0x7f, 0xd4, 0x9e, 0xd3, 0x37, 0xf1, 0xbd, 0x59, 0xcd, 0xf7, 0xdf,
1940 0x58, 0x47, 0x9c, 0xcd, 0x0a, 0xf1, 0xf1, 0x59, 0xc8, 0xad, 0x4f, 0x4b,
1941 0x76, 0x34, 0x31, 0x57, 0xc6, 0xec, 0xb3, 0xdf, 0xb0, 0xce, 0xf0, 0x0b,
1942 0xcb, 0xbc, 0xe2, 0xf0, 0xce, 0x1c, 0xa3, 0x33, 0x3e, 0xdf, 0x12, 0xee,
1943 0xb9, 0x37, 0x73, 0xca, 0xfc, 0xc6, 0x75, 0x52, 0xff, 0x0a, 0xe6, 0x8b,
1944 0xfd, 0x11, 0x57, 0xab, 0xf4, 0x3d, 0x05, 0x9e, 0x6c, 0x89, 0xd7, 0xcd,
1945 0xd9, 0x43, 0x46, 0xf6, 0xd6, 0x01, 0x6e, 0xc0, 0x6f, 0xec, 0x3b, 0x21,
1946 0x9d, 0x0a, 0x24, 0x37, 0x69, 0xb6, 0xa3, 0x67, 0x87, 0x98, 0x39, 0x33,
1947 0x34, 0xb3, 0xc2, 0xd8, 0x91, 0xf8, 0x36, 0x74, 0xa1, 0x64, 0xfb, 0xd8,
1948 0x4b, 0x4e, 0x3f, 0xcf, 0x3c, 0x8a, 0xb6, 0x1b, 0x97, 0xb3, 0x09, 0xc1,
1949 0x4b, 0xcf, 0x5b, 0xff, 0x32, 0x08, 0xc6, 0x52, 0x29, 0xde, 0x2b, 0xb8,
1950 0x8c, 0x4f, 0xb9, 0xca, 0x99, 0x1c, 0x6d, 0x70, 0x26, 0x46, 0x03, 0xd9,
1951 0x93, 0xe2, 0x9d, 0x49, 0xdc, 0x93, 0xa0, 0xe3, 0xe3, 0x48, 0x6b, 0x87,
1952 0x6e, 0x7d, 0xc7, 0x3a, 0xee, 0x71, 0xbb, 0xd9, 0x6f, 0xb4, 0xe5, 0x88,
1953 0x63, 0xfa, 0xca, 0xed, 0x27, 0x72, 0xc2, 0xbb, 0x8b, 0xb6, 0xc4, 0x63,
1954 0x7a, 0x7f, 0xe2, 0x17, 0x50, 0x0f, 0x7d, 0x94, 0xd8, 0xaf, 0xeb, 0x4c,
1955 0x40, 0x9e, 0x4d, 0x8e, 0xf1, 0xbe, 0x14, 0x9e, 0x63, 0x88, 0xb4, 0x2a,
1956 0xb9, 0xd6, 0x1b, 0xb6, 0xf7, 0x69, 0xe6, 0xe1, 0x0a, 0x45, 0x74, 0xda,
1957 0x16, 0x6f, 0xf7, 0xdc, 0x1d, 0x9b, 0x61, 0x5a, 0x78, 0xd7, 0xa6, 0xd2,
1958 0x67, 0x56, 0xe0, 0xd3, 0x9e, 0x1e, 0x92, 0xb8, 0x33, 0x55, 0x6c, 0x75,
1959 0x4e, 0x16, 0x33, 0x5b, 0xd7, 0x81, 0x3e, 0xce, 0xa7, 0x3e, 0x46, 0xf9,
1960 0x05, 0xdb, 0xef, 0x45, 0xc9, 0x57, 0x3e, 0x24, 0xe3, 0x2d, 0xed, 0xde,
1961 0xfd, 0x7a, 0x6e, 0x2e, 0x03, 0x67, 0x2d, 0x2a, 0x3b, 0xfa, 0xc4, 0x3a,
1962 0xea, 0xb7, 0xdd, 0x45, 0x05, 0x5e, 0x56, 0xbf, 0x88, 0x07, 0x36, 0x6e,
1963 0xad, 0xb6, 0x51, 0xf6, 0xa6, 0x58, 0xae, 0xc1, 0xe9, 0x1d, 0x5d, 0x85,
1964 0x79, 0xdc, 0x05, 0xfd, 0xe9, 0xc0, 0x46, 0x22, 0xae, 0x1b, 0x9c, 0x3d,
1965 0xa3, 0x79, 0xf4, 0xc8, 0x7d, 0xd6, 0xbc, 0xf7, 0xf0, 0x30, 0xc6, 0xa8,
1966 0xe5, 0x2b, 0x78, 0xf7, 0x12, 0xd7, 0xdb, 0x83, 0x49, 0xd8, 0x06, 0xb9,
1967 0xae, 0x7f, 0x67, 0xd7, 0xab, 0xa7, 0xaf, 0xb0, 0x5e, 0xed, 0xc9, 0x23,
1968 0x15, 0x7d, 0x6f, 0x48, 0xe7, 0xb8, 0xe2, 0x3a, 0x6e, 0xf3, 0x55, 0x7a,
1969 0x7e, 0x54, 0x87, 0xdd, 0x1b, 0x78, 0x72, 0x9d, 0xbd, 0xd3, 0x06, 0x70,
1970 0x5c, 0x05, 0x18, 0x36, 0x62, 0xfc, 0x84, 0xc1, 0xd4, 0x11, 0x75, 0x4b,
1971 0x9c, 0x3a, 0x70, 0x56, 0x4e, 0xaf, 0x0b, 0xf7, 0x7b, 0xa0, 0x1d, 0xc8,
1972 0xb5, 0x47, 0xe3, 0x46, 0x37, 0xae, 0x5d, 0xa6, 0x9d, 0x70, 0x3c, 0x8e,
1973 0x1d, 0x0f, 0x69, 0x75, 0x43, 0x0b, 0xfd, 0x89, 0x59, 0xa9, 0x5b, 0x54,
1974 0x9e, 0xf1, 0xfc, 0x5d, 0xad, 0x66, 0xdf, 0x11, 0xcb, 0x7a, 0xb0, 0x4b,
1975 0x69, 0xe3, 0x12, 0x77, 0x7a, 0xae, 0x8a, 0xdc, 0x5b, 0x9c, 0xf3, 0x2f,
1976 0x43, 0x9e, 0x5c, 0xeb, 0xbd, 0x4d, 0x91, 0xf6, 0x42, 0xfc, 0x12, 0xb7,
1977 0x09, 0xe0, 0x95, 0x71, 0x95, 0xd3, 0x41, 0x66, 0x80, 0x7c, 0xc5, 0x36,
1978 0x98, 0xff, 0xa2, 0x8e, 0xe5, 0x0e, 0xa6, 0x18, 0x27, 0x6a, 0x3f, 0x71,
1979 0x87, 0x0a, 0x65, 0xd3, 0x2c, 0xd7, 0x10, 0x1c, 0xde, 0x21, 0xba, 0x0b,
1980 0x1d, 0x5e, 0x9c, 0x52, 0xce, 0x37, 0xc7, 0x5c, 0x7c, 0xd7, 0xd8, 0xfb,
1981 0x42, 0x8d, 0x6e, 0x12, 0xf9, 0xeb, 0x70, 0xbc, 0xf1, 0x3c, 0xe6, 0xfb,
1982 0x12, 0xe6, 0x7b, 0xf9, 0xfb, 0x41, 0x91, 0x57, 0x46, 0x5e, 0xf9, 0x43,
1983 0x41, 0xa6, 0x89, 0xf4, 0x47, 0x9a, 0x7b, 0x3d, 0x9f, 0x59, 0xef, 0x63,
1984 0x02, 0x6c, 0x67, 0xc1, 0x0b, 0x19, 0xae, 0x25, 0x07, 0xc7, 0x52, 0x37,
1985 0x81, 0x17, 0x76, 0xca, 0x9f, 0xc0, 0x16, 0xf8, 0xe3, 0x4a, 0x1a, 0x3c,
1986 0xd1, 0x03, 0x1e, 0xe9, 0x06, 0x5f, 0xa4, 0xb4, 0x5d, 0xfc, 0x28, 0x74,
1987 0xde, 0xd9, 0x4a, 0xc9, 0xd9, 0x3b, 0x5a, 0x74, 0x72, 0xa3, 0x47, 0x41,
1988 0x17, 0xdc, 0x03, 0xab, 0xae, 0xa9, 0x11, 0x37, 0x3e, 0x29, 0xa4, 0xff,
1989 0x76, 0xee, 0xed, 0x68, 0x06, 0xae, 0xce, 0x10, 0x57, 0x93, 0x95, 0x2d,
1990 0xde, 0x3a, 0xf0, 0x41, 0xb3, 0xe6, 0x83, 0x46, 0x27, 0xe3, 0xdd, 0x64,
1991 0xf9, 0x60, 0x04, 0x7c, 0x50, 0x58, 0xc2, 0x07, 0xcf, 0x58, 0x9a, 0x9f,
1992 0xae, 0xe2, 0x83, 0x49, 0x9b, 0x36, 0x7e, 0x05, 0x3e, 0xb8, 0xca, 0x4f,
1993 0x3e, 0x39, 0x24, 0x27, 0xc0, 0x07, 0x0f, 0x6b, 0x3e, 0xb8, 0x4a, 0xf3,
1994 0x01, 0xe3, 0x46, 0xe4, 0x85, 0x56, 0xc8, 0x0e, 0xf2, 0xc2, 0xb3, 0x32,
1995 0x0b, 0x5e, 0x78, 0x51, 0xb1, 0xef, 0xcb, 0xb4, 0x0f, 0x46, 0xe9, 0x8f,
1996 0x9d, 0x2a, 0x15, 0xc1, 0xbb, 0x4a, 0xbe, 0x30, 0x16, 0x04, 0x33, 0xf0,
1997 0xd1, 0x1f, 0x84, 0x0d, 0xef, 0xea, 0x3b, 0x69, 0xa7, 0x61, 0xbb, 0x10,
1998 0x36, 0xda, 0xe4, 0xe3, 0x0e, 0xe8, 0xfd, 0xf0, 0x04, 0xc6, 0xb0, 0x47,
1999 0xfd, 0x3e, 0xfc, 0x60, 0x0f, 0xf3, 0x4a, 0xdb, 0xfe, 0xb8, 0xe6, 0x9b,
2000 0x1a, 0xe8, 0x80, 0x93, 0xdd, 0x8c, 0x33, 0xf9, 0xde, 0x5e, 0xd5, 0x9e,
2001 0xef, 0x03, 0xcc, 0x11, 0x75, 0xbf, 0x30, 0xc6, 0xd1, 0xb4, 0xc8, 0xb6,
2002 0xa7, 0x5c, 0x18, 0x90, 0xfb, 0x6c, 0x5e, 0x3e, 0xa8, 0x83, 0x1d, 0x5a,
2003 0xa7, 0x8c, 0x5d, 0xae, 0xb6, 0x25, 0xbd, 0xdf, 0x80, 0xd0, 0xac, 0x4d,
2004 0x9b, 0x3d, 0x81, 0x7d, 0xc5, 0x6a, 0xbb, 0xfe, 0x5e, 0xd8, 0xf5, 0xac,
2005 0x23, 0xae, 0xb1, 0xeb, 0xef, 0xb2, 0xbc, 0xc6, 0xdf, 0x9e, 0xb6, 0xf1,
2006 0x0f, 0x00, 0xbe, 0x1d, 0x73, 0x36, 0x3e, 0xdb, 0xa0, 0xad, 0x21, 0x72,
2007 0x03, 0xec, 0xbc, 0x1b, 0xc1, 0x83, 0x37, 0xc1, 0x8f, 0x7a, 0x77, 0xd1,
2008 0x93, 0x9d, 0xc5, 0x66, 0xf8, 0xdb, 0xad, 0xf2, 0xab, 0x63, 0x1b, 0xa5,
2009 0x7f, 0xf4, 0x77, 0x9a, 0xa1, 0x57, 0x61, 0x97, 0xbe, 0x08, 0x38, 0x23,
2010 0x56, 0x56, 0x47, 0xc1, 0x03, 0xed, 0x89, 0x1f, 0xa8, 0x44, 0xab, 0x91,
2011 0xed, 0x3c, 0x4b, 0xbe, 0x5c, 0x3b, 0x31, 0xd4, 0x67, 0x1c, 0xa5, 0x45,
2012 0xce, 0x1c, 0xa7, 0xe7, 0x95, 0x80, 0x2d, 0x9e, 0x82, 0x1d, 0xb2, 0x01,
2013 0xed, 0x31, 0x96, 0xbc, 0x5a, 0x9e, 0xd9, 0xea, 0xde, 0x9d, 0xd3, 0x7c,
2014 0x78, 0xc9, 0xc9, 0x8e, 0xdd, 0x24, 0x85, 0xc1, 0x28, 0xc6, 0xa0, 0x9a,
2015 0xd7, 0xca, 0xf5, 0xd2, 0xaf, 0xc7, 0x73, 0x59, 0x0e, 0x42, 0x1f, 0xff,
2016 0x69, 0xb1, 0x5f, 0x66, 0x07, 0x9a, 0xf0, 0x1d, 0x95, 0x67, 0x8a, 0x5b,
2017 0xe0, 0xef, 0xfc, 0x0a, 0x70, 0x54, 0x8b, 0xef, 0x5a, 0xe9, 0x5d, 0x47,
2018 0x5e, 0x6d, 0x90, 0x19, 0xa4, 0xdf, 0x28, 0xbf, 0x64, 0xd3, 0x99, 0x46,
2019 0xde, 0x68, 0x40, 0xdd, 0xa8, 0x9c, 0x2f, 0xd2, 0x96, 0xd4, 0x3c, 0xd1,
2020 0xf3, 0xb2, 0x6c, 0xc9, 0xbc, 0x0c, 0xdb, 0xf4, 0x59, 0x3c, 0xcf, 0x4b,
2021 0x72, 0xe7, 0x6e, 0x67, 0x4b, 0xa2, 0xdd, 0x81, 0xbe, 0xc4, 0xe3, 0x3a,
2022 0x5b, 0xbc, 0x5a, 0xe7, 0x5a, 0xdb, 0x46, 0x8d, 0x3c, 0x3f, 0xa8, 0xe2,
2023 0x0d, 0x98, 0x93, 0xcd, 0x4e, 0x87, 0x4d, 0xe3, 0xb7, 0xbe, 0x2f, 0x51,
2024 0xda, 0xcf, 0xa8, 0x0d, 0xab, 0x44, 0xda, 0x1a, 0x60, 0xe7, 0xec, 0x11,
2025 0xd5, 0xdc, 0x20, 0xae, 0xb4, 0x4f, 0xa8, 0x56, 0xa4, 0xf9, 0x36, 0x2d,
2026 0xd6, 0x00, 0x9d, 0x80, 0xb4, 0x16, 0xa4, 0x6d, 0xb2, 0x69, 0x4d, 0x0d,
2027 0x52, 0x8b, 0xb4, 0xcb, 0x9a, 0xe7, 0x2f, 0x76, 0xf8, 0x5e, 0xce, 0xa9,
2028 0x97, 0xb6, 0x53, 0x0d, 0x90, 0x0d, 0xab, 0x65, 0x66, 0x6b, 0x9d, 0xb4,
2029 0x21, 0x8f, 0x31, 0xee, 0xd4, 0xa9, 0xa8, 0xbc, 0xf3, 0x54, 0x7b, 0xfc,
2030 0xa3, 0x18, 0x43, 0xfb, 0x19, 0xc6, 0xbc, 0xff, 0xac, 0x99, 0x31, 0x9f,
2031 0xb6, 0x33, 0x7c, 0xd7, 0x69, 0xf9, 0x43, 0x7c, 0x98, 0x3b, 0xdf, 0x60,
2032 0x63, 0x94, 0x8e, 0x3b, 0xc3, 0xa3, 0xd4, 0xdb, 0xed, 0xf6, 0x7e, 0xa2,
2033 0xff, 0xd9, 0x4c, 0x5f, 0x6d, 0x82, 0x36, 0x54, 0x89, 0xfc, 0x48, 0xdd,
2034 0x83, 0xf7, 0xb8, 0x23, 0x85, 0x79, 0x99, 0x35, 0x45, 0xbe, 0x3a, 0xae,
2035 0xb8, 0x4f, 0x05, 0x69, 0x95, 0x77, 0x05, 0x66, 0x8e, 0xc9, 0x0b, 0x46,
2036 0x2e, 0xfd, 0x9a, 0x91, 0x4b, 0xa7, 0xcf, 0x2d, 0x90, 0x4b, 0x05, 0x2d,
2037 0x97, 0x06, 0x05, 0xef, 0xa9, 0x02, 0xe4, 0xd2, 0x08, 0xbe, 0x3d, 0x2d,
2038 0x97, 0x62, 0x62, 0x6d, 0x64, 0x89, 0x5e, 0xc5, 0xfe, 0x27, 0x4b, 0xae,
2039 0xb6, 0xa5, 0x0a, 0xe3, 0xb0, 0x43, 0x4a, 0x23, 0x56, 0x67, 0x4b, 0xba,
2040 0x49, 0x3a, 0x7a, 0x7e, 0x2a, 0xa1, 0x9d, 0x39, 0xdb, 0xcc, 0x3b, 0x8f,
2041 0x5f, 0x54, 0x94, 0x61, 0x27, 0x20, 0xc3, 0x1e, 0xbe, 0x82, 0x0c, 0x43,
2042 0x5e, 0x19, 0x79, 0x65, 0xb6, 0xfb, 0xdd, 0x9f, 0x0e, 0x79, 0x94, 0x1f,
2043 0x94, 0x19, 0x90, 0x49, 0x25, 0xc8, 0xa4, 0x12, 0xe4, 0x54, 0x09, 0x72,
2044 0xa9, 0x04, 0xb9, 0x54, 0x82, 0x5c, 0x2a, 0x41, 0x2e, 0x41, 0xc6, 0x3d,
2045 0x0a, 0x19, 0x67, 0x64, 0xda, 0x00, 0xed, 0x35, 0xb9, 0xcf, 0xea, 0x77,
2046 0x13, 0x27, 0xe9, 0xb2, 0x7e, 0x91, 0xd9, 0xb3, 0x7a, 0xae, 0x2a, 0x2e,
2047 0xb8, 0xeb, 0x88, 0xe6, 0x77, 0xcf, 0x57, 0xd7, 0x3a, 0xdc, 0x1f, 0xf3,
2048 0x03, 0xed, 0xb3, 0x6f, 0xe6, 0x6f, 0xa9, 0x03, 0x5f, 0xbf, 0x62, 0xf9,
2049 0x7a, 0xf3, 0x1c, 0x5f, 0x27, 0x1d, 0xc6, 0x89, 0x97, 0xe7, 0xeb, 0x16,
2050 0x9b, 0x97, 0x0f, 0x56, 0x80, 0xaf, 0x57, 0x2c, 0xe2, 0xeb, 0x28, 0xf8,
2051 0x7a, 0xe7, 0x12, 0xbe, 0x5e, 0xe5, 0xf4, 0xea, 0x3a, 0x3c, 0x83, 0xc6,
2052 0xef, 0x5a, 0x67, 0x9e, 0xaf, 0xf7, 0x6b, 0xbe, 0x3e, 0x04, 0xbe, 0xbe,
2053 0xbe, 0x8a, 0xaf, 0x77, 0x4a, 0xf2, 0x96, 0x6c, 0x64, 0xa3, 0xec, 0xbe,
2054 0x5f, 0x35, 0xaf, 0x91, 0x7f, 0x11, 0x53, 0xdf, 0xf0, 0x58, 0xef, 0x58,
2055 0xb3, 0xe4, 0x1e, 0xfa, 0x11, 0xd7, 0x06, 0xc8, 0x23, 0x43, 0x19, 0xc7,
2056 0x93, 0x83, 0x47, 0x7e, 0x20, 0xd3, 0x9a, 0xb7, 0x44, 0xf6, 0x1c, 0x89,
2057 0xca, 0xf0, 0x11, 0xc6, 0x1e, 0xbe, 0x63, 0xe9, 0xbd, 0x4e, 0x86, 0x07,
2058 0xb9, 0x5f, 0xd2, 0x95, 0xdd, 0x47, 0xe0, 0x63, 0x1d, 0x61, 0xec, 0xe1,
2059 0xf2, 0x1c, 0x8f, 0x4d, 0x43, 0xb6, 0xec, 0x3e, 0xa2, 0xe7, 0x1a, 0xed,
2060 0x34, 0xc8, 0xa1, 0x23, 0x22, 0xb7, 0x1d, 0x71, 0xe5, 0xf6, 0x23, 0x73,
2061 0xbc, 0x36, 0x10, 0xf2, 0xda, 0x9f, 0x83, 0xd7, 0xda, 0x2d, 0xaf, 0xa9,
2062 0x39, 0x5e, 0xfb, 0x5a, 0x15, 0xaf, 0xb1, 0x3e, 0x79, 0xed, 0x82, 0x4d,
2063 0xe3, 0xb7, 0x2b, 0x7b, 0x8f, 0xb4, 0xca, 0xee, 0x87, 0xde, 0x22, 0x7b,
2064 0xee, 0x27, 0xac, 0xe6, 0x9e, 0x3c, 0xda, 0x5f, 0xe3, 0x95, 0x76, 0xb4,
2065 0x1f, 0xee, 0x0f, 0xd2, 0x77, 0x65, 0x75, 0x4e, 0x48, 0x32, 0xcf, 0xfe,
2066 0x6a, 0xe1, 0x3b, 0x9f, 0x82, 0x4f, 0xb1, 0x17, 0x30, 0xdd, 0x7a, 0x44,
2067 0x92, 0xae, 0xbc, 0x26, 0x23, 0xa9, 0x47, 0x5b, 0x8d, 0x3d, 0x71, 0x09,
2068 0xbc, 0x42, 0xfa, 0xcf, 0x48, 0xee, 0xed, 0x81, 0xf6, 0x2b, 0x46, 0xcb,
2069 0x42, 0xff, 0x9f, 0x31, 0x73, 0xc7, 0xdc, 0x77, 0xc7, 0xf3, 0xbe, 0x35,
2070 0xfa, 0xbc, 0x9b, 0x8e, 0xd7, 0x76, 0x33, 0xbf, 0x46, 0xef, 0x37, 0xcd,
2071 0xe9, 0xb3, 0xdc, 0xac, 0xcf, 0x76, 0x62, 0x3a, 0x9e, 0x5e, 0x28, 0xf3,
2072 0x8e, 0x30, 0xde, 0xbd, 0xcc, 0xbb, 0x06, 0xff, 0xf8, 0x2a, 0x13, 0x9b,
2073 0x25, 0xdf, 0x7d, 0xdd, 0xc9, 0x15, 0x2f, 0xe9, 0x7d, 0x85, 0x59, 0x1f,
2074 0xbf, 0xcb, 0xfc, 0x66, 0xf9, 0x4b, 0x8c, 0x71, 0x24, 0x12, 0xea, 0x81,
2075 0x56, 0xee, 0x3b, 0x18, 0x9c, 0x32, 0x76, 0x94, 0xe1, 0xd1, 0x06, 0xed,
2076 0x6b, 0x8c, 0xe0, 0x7b, 0xf7, 0x68, 0xa3, 0x53, 0xa0, 0x6d, 0x32, 0xd0,
2077 0xe0, 0xe4, 0xc7, 0xf7, 0xb4, 0x1a, 0x9b, 0x79, 0x20, 0xce, 0x3d, 0x85,
2078 0x19, 0xb5, 0x54, 0x26, 0x9f, 0x92, 0x50, 0x26, 0x27, 0x6f, 0xc9, 0xc0,
2079 0xb6, 0xce, 0x1d, 0xd1, 0xf7, 0xf7, 0x25, 0xda, 0x15, 0xc7, 0xf4, 0x09,
2080 0xc8, 0xd7, 0x90, 0x16, 0xe2, 0xf2, 0xf1, 0x23, 0xa4, 0x07, 0x15, 0x6b,
2081 0x94, 0xdf, 0xb2, 0xf4, 0x70, 0x59, 0x8a, 0x90, 0x3b, 0x47, 0x8e, 0xdc,
2082 0x2e, 0xe3, 0xbb, 0x16, 0xd3, 0xc3, 0x9e, 0x79, 0x7a, 0x88, 0xc1, 0x3e,
2083 0x73, 0xaa, 0xe9, 0xe1, 0x37, 0xe7, 0xe8, 0x61, 0xdc, 0xf9, 0xd7, 0xd2,
2084 0xc3, 0x0d, 0x0b, 0xe8, 0x61, 0x44, 0xd3, 0x43, 0xff, 0x1c, 0x3d, 0x8c,
2085 0x1c, 0x61, 0xbf, 0x7a, 0x5d, 0xd4, 0x9b, 0x71, 0x38, 0xe7, 0x73, 0xb4,
2086 0x90, 0x18, 0xd6, 0xfb, 0x44, 0x93, 0x79, 0x9e, 0x25, 0x5d, 0xa5, 0x18,
2087 0x1b, 0x99, 0x9f, 0xff, 0xc6, 0x7f, 0xd3, 0xf9, 0x7f, 0x47, 0xfc, 0xff,
2088 0xef, 0xfc, 0x5f, 0x8f, 0xf6, 0x29, 0x8b, 0x43, 0x79, 0x1c, 0xd2, 0xc3,
2089 0x7b, 0xe2, 0x46, 0x2f, 0x70, 0x8e, 0xf9, 0x6d, 0xf6, 0xac, 0x9f, 0x83,
2090 0xfc, 0x7b, 0x1c, 0xf2, 0xef, 0xb1, 0x05, 0xeb, 0x01, 0x3d, 0x36, 0x06,
2091 0x11, 0xc8, 0xc1, 0xd4, 0x3c, 0x3e, 0x66, 0xba, 0x89, 0x0f, 0xb3, 0xf7,
2092 0xe4, 0x6c, 0x65, 0x31, 0x4e, 0x5c, 0xbd, 0xdf, 0xe8, 0x64, 0xaa, 0x1a,
2093 0x27, 0x84, 0x7b, 0xb6, 0x6a, 0x8c, 0xf8, 0x5d, 0xe6, 0xf7, 0x65, 0xbd,
2094 0x87, 0xa4, 0xa0, 0xd7, 0x9f, 0x88, 0x17, 0xae, 0x3f, 0x11, 0x27, 0xae,
2095 0xb6, 0xf7, 0x0b, 0xe5, 0x3a, 0xbd, 0x2f, 0xfc, 0xc0, 0x54, 0x4c, 0x66,
2096 0x62, 0x8c, 0xeb, 0xf1, 0xde, 0x57, 0xfa, 0xca, 0x7e, 0xbc, 0x20, 0x79,
2097 0x7b, 0xd6, 0x67, 0x95, 0xa5, 0x6d, 0xc6, 0x03, 0x79, 0x27, 0x42, 0xb8,
2098 0x0e, 0xd1, 0x69, 0x65, 0x5d, 0x43, 0x55, 0x9c, 0x12, 0x78, 0x1f, 0x93,
2099 0x44, 0xb6, 0x1b, 0xef, 0x29, 0xf6, 0xfd, 0xa4, 0x8c, 0x3c, 0x58, 0x86,
2100 0x2d, 0xf7, 0x30, 0x74, 0x8e, 0x23, 0x10, 0x93, 0xfa, 0x2e, 0x14, 0xc2,
2101 0x30, 0xa1, 0xef, 0xf5, 0xa3, 0xdf, 0x47, 0x7a, 0x88, 0xe3, 0xfb, 0xb2,
2102 0x8d, 0x25, 0xc5, 0xa5, 0x50, 0xfc, 0x01, 0xe0, 0xe7, 0x1d, 0x94, 0x3f,
2103 0xc2, 0xfb, 0x8d, 0xe6, 0xc3, 0xf8, 0x21, 0x03, 0xfa, 0xcd, 0xb9, 0x79,
2104 0xcd, 0xc9, 0x94, 0xcd, 0xfe, 0x96, 0xaa, 0xfb, 0xf5, 0xe5, 0xb0, 0xb6,
2105 0x9f, 0xd3, 0x76, 0x5f, 0x0b, 0xcf, 0xe7, 0x19, 0x1b, 0xfa, 0xcb, 0xb0,
2106 0xa1, 0x9f, 0xa8, 0x64, 0xf4, 0x1a, 0xd6, 0x63, 0xb0, 0xa1, 0x1f, 0x85,
2107 0xee, 0xa1, 0xce, 0x89, 0x59, 0x9d, 0x33, 0xa2, 0x76, 0x69, 0x9d, 0xf3,
2108 0xd7, 0x5a, 0xe7, 0xfc, 0xea, 0x12, 0x9d, 0x73, 0x48, 0xb5, 0x8f, 0x52,
2109 0xe7, 0xf4, 0xaa, 0x9d, 0x0e, 0xed, 0xc5, 0xb5, 0xcb, 0xe8, 0x9c, 0xf7,
2110 0xca, 0xaf, 0xd8, 0xbc, 0xfd, 0xf2, 0xbe, 0x6d, 0x7a, 0xdd, 0xc6, 0x9b,
2111 0x50, 0xbc, 0xcb, 0xce, 0xe8, 0xa0, 0xeb, 0x55, 0xa7, 0x5e, 0xef, 0xfd,
2112 0x6a, 0x95, 0xce, 0x69, 0x53, 0xdd, 0x4e, 0xaf, 0xae, 0xc3, 0x78, 0x04,
2113 0xbf, 0x53, 0x4e, 0x66, 0xa0, 0x0e, 0xdf, 0x71, 0x89, 0x1c, 0xc1, 0xd8,
2114 0xcd, 0x7d, 0x7b, 0xca, 0xe4, 0x5d, 0x63, 0xf3, 0x54, 0x98, 0xee, 0x9a,
2115 0xf4, 0x76, 0x9b, 0x6e, 0x74, 0x55, 0x9b, 0x6a, 0xd5, 0xba, 0x6a, 0x33,
2116 0x18, 0x6a, 0x02, 0xfa, 0x75, 0xa2, 0x14, 0xea, 0x2c, 0xfe, 0x66, 0xbc,
2117 0x99, 0x71, 0x89, 0x30, 0x6e, 0x9d, 0x40, 0x19, 0x3c, 0xa5, 0xd0, 0xa6,
2118 0xe4, 0x6f, 0xf8, 0x0a, 0x78, 0xa6, 0x80, 0xd7, 0x5b, 0xc0, 0x3f, 0xbf,
2119 0x5e, 0x64, 0xdc, 0xb3, 0x59, 0x8e, 0x8e, 0x55, 0xe7, 0xb5, 0xca, 0xbb,
2120 0xc7, 0x36, 0xc8, 0xbe, 0x51, 0xff, 0x6a, 0xa9, 0xdf, 0x28, 0x23, 0xa3,
2121 0x2f, 0xea, 0xfb, 0x40, 0xd6, 0xe8, 0x7b, 0x92, 0x78, 0x7f, 0x98, 0x91,
2122 0x91, 0xfd, 0x8e, 0x91, 0x91, 0x19, 0x35, 0x6f, 0xb3, 0x86, 0x6d, 0xf2,
2123 0x6e, 0xa6, 0xbe, 0xd1, 0xb8, 0xbe, 0x43, 0x7a, 0xa2, 0x72, 0xad, 0xfc,
2124 0xd1, 0x71, 0x75, 0xa7, 0x9a, 0xbf, 0x4b, 0x41, 0xdb, 0xac, 0x93, 0x0b,
2125 0x6c, 0xd6, 0xbf, 0x97, 0x99, 0xf7, 0x45, 0x31, 0x4e, 0xd0, 0xf0, 0x75,
2126 0x2f, 0x73, 0x1d, 0xb4, 0x39, 0x26, 0x97, 0xa4, 0x4f, 0xe3, 0x8f, 0xf2,
2127 0xb4, 0x01, 0x72, 0x70, 0x56, 0xeb, 0xd7, 0xb5, 0xbc, 0xf3, 0xf8, 0x08,
2128 0x6d, 0xd7, 0xaf, 0x6b, 0x79, 0xb6, 0xd6, 0xda, 0xae, 0xd3, 0x90, 0xd3,
2129 0x94, 0xa3, 0x37, 0xca, 0x5f, 0xdb, 0x74, 0xa6, 0x25, 0xe3, 0xb3, 0x42,
2130 0x7d, 0x17, 0x83, 0x0c, 0xa5, 0x3c, 0xfd, 0x59, 0x6d, 0xd7, 0xe7, 0x6c,
2131 0x1b, 0x94, 0x9f, 0x46, 0x76, 0x6f, 0x76, 0xa6, 0x6d, 0x1a, 0xbf, 0xc3,
2132 0x18, 0xba, 0x9f, 0xc9, 0x59, 0x3e, 0x53, 0xce, 0x93, 0xc8, 0x5f, 0x83,
2133 0x7c, 0xf2, 0xd9, 0x63, 0x9a, 0xcf, 0xb4, 0x7d, 0xe2, 0x74, 0xd9, 0x35,
2134 0x85, 0xb9, 0xf5, 0x80, 0x3c, 0xf9, 0x4c, 0x1d, 0xf5, 0xa6, 0x8d, 0x3c,
2135 0xf0, 0x90, 0xfe, 0x45, 0xe8, 0x0e, 0xd6, 0x45, 0xfa, 0xb1, 0x0c, 0xe6,
2136 0xf0, 0x24, 0xfc, 0x9f, 0x46, 0x7c, 0x37, 0xe3, 0x7b, 0x42, 0x7e, 0x75,
2137 0x30, 0xaa, 0xc7, 0x3d, 0x82, 0x71, 0x1c, 0x38, 0x82, 0x31, 0x39, 0xc6,
2138 0x76, 0x76, 0xcf, 0xb8, 0x52, 0x73, 0x86, 0x7c, 0xc7, 0x33, 0x86, 0x41,
2139 0xb0, 0xb7, 0x8b, 0x74, 0x9b, 0xf4, 0xfa, 0xf5, 0xf9, 0xb7, 0xcd, 0xf1,
2140 0x08, 0x70, 0x72, 0x00, 0xf3, 0x31, 0x52, 0xf4, 0xbd, 0xac, 0xe3, 0xc7,
2141 0x31, 0x4e, 0xd8, 0x80, 0xed, 0xb0, 0x05, 0xdb, 0x61, 0x07, 0xb6, 0xc3,
2142 0x0e, 0x5c, 0x2d, 0xa7, 0xb6, 0x72, 0x7f, 0x49, 0xfe, 0x9d, 0xbc, 0x77,
2143 0xf9, 0x1b, 0x3a, 0x36, 0x5f, 0x7b, 0x4b, 0x1f, 0x7c, 0x76, 0xf1, 0x92,
2144 0x03, 0xdc, 0x63, 0x3f, 0xeb, 0xd5, 0xde, 0xd2, 0x2f, 0xed, 0x3d, 0xc8,
2145 0xef, 0xb9, 0x24, 0x1d, 0xb7, 0x7c, 0xd8, 0xa9, 0x1d, 0xe8, 0x03, 0x1e,
2146 0x33, 0x4e, 0x32, 0x3e, 0xe4, 0x30, 0x4e, 0x91, 0xdd, 0x1c, 0xd1, 0x67,
2147 0xc4, 0xa6, 0x19, 0x8b, 0xb8, 0xa5, 0x3d, 0xb2, 0x25, 0xb1, 0xdb, 0x49,
2148 0x0e, 0xa8, 0x48, 0x72, 0xa0, 0xcf, 0x09, 0xcb, 0xf1, 0x0e, 0x6a, 0xc8,
2149 0x19, 0xc0, 0x7a, 0xa0, 0xf4, 0x75, 0xd0, 0xd3, 0x79, 0x29, 0x1c, 0x6f,
2150 0x90, 0xa9, 0x62, 0xbb, 0x97, 0x55, 0x31, 0xe1, 0xbe, 0x12, 0x75, 0x0a,
2151 0x44, 0x7f, 0x26, 0x2a, 0x13, 0xa3, 0x1b, 0x45, 0x69, 0xdb, 0xbd, 0x45,
2152 0xb2, 0x63, 0xa3, 0x72, 0xbe, 0x5b, 0x9a, 0x14, 0xda, 0xe7, 0xdd, 0xde,
2153 0xea, 0x14, 0xd7, 0x11, 0x43, 0x5e, 0x58, 0x4f, 0x3e, 0x19, 0x05, 0x0e,
2154 0x41, 0xb7, 0x8c, 0xeb, 0xd6, 0x09, 0xe5, 0xde, 0xed, 0x3a, 0x66, 0xca,
2155 0x38, 0x6d, 0xf5, 0x7a, 0x03, 0xf9, 0x23, 0xba, 0x2c, 0x7f, 0x4c, 0x96,
2156 0xb8, 0x36, 0x23, 0x79, 0x97, 0x71, 0x61, 0x1f, 0xbf, 0xc7, 0x59, 0xb6,
2157 0x4e, 0x46, 0xba, 0xf3, 0x76, 0x8f, 0xc7, 0x37, 0xc1, 0x07, 0x1c, 0x9f,
2158 0x5e, 0x27, 0x01, 0xaf, 0x2f, 0x5e, 0xcf, 0x88, 0x56, 0xc9, 0x03, 0x47,
2159 0x66, 0x46, 0xc3, 0xf5, 0x0f, 0xb6, 0x87, 0xef, 0x71, 0x23, 0x6f, 0xb3,
2160 0x4b, 0xea, 0x11, 0x2e, 0xae, 0x55, 0x2e, 0x94, 0xb1, 0x4a, 0x9f, 0x13,
2161 0xf6, 0xb4, 0x7c, 0x3d, 0x5d, 0x31, 0xb2, 0x75, 0xbc, 0x12, 0xea, 0x96,
2162 0xa8, 0xd1, 0xa5, 0x4b, 0xf4, 0x89, 0x89, 0x60, 0xce, 0xeb, 0x93, 0x4b,
2163 0x3a, 0x46, 0xf7, 0x6b, 0x53, 0x2d, 0xe2, 0x1e, 0x93, 0xd9, 0x11, 0xff,
2164 0x54, 0x2b, 0xf7, 0x69, 0x8c, 0xa4, 0xde, 0x8c, 0x7e, 0x8c, 0xb5, 0x50,
2165 0x1f, 0x0e, 0xa9, 0xb5, 0x78, 0xaf, 0xd1, 0xf4, 0x07, 0x9e, 0xc2, 0xb7,
2166 0xf1, 0x13, 0xbe, 0x0c, 0x3f, 0xe1, 0x09, 0xe8, 0xba, 0x73, 0xf0, 0x13,
2167 0x1e, 0x87, 0x9f, 0xf0, 0x18, 0xfc, 0x84, 0x47, 0xa1, 0x27, 0xab, 0xfd,
2168 0x83, 0xe1, 0x05, 0xfe, 0x41, 0xa0, 0xf9, 0x9f, 0x31, 0xc0, 0xc7, 0xab,
2169 0x7c, 0x83, 0xbd, 0x46, 0x5f, 0xc1, 0xef, 0x37, 0x7c, 0xd4, 0xa6, 0x6e,
2170 0xd6, 0xfa, 0xd1, 0xec, 0xd9, 0x1d, 0x98, 0xd3, 0x57, 0x6d, 0xca, 0xe8,
2171 0xab, 0x89, 0x79, 0x7d, 0x65, 0xf8, 0xe8, 0xd8, 0xa8, 0x44, 0xfc, 0xd1,
2172 0xe9, 0x6c, 0x6a, 0xbb, 0xe6, 0xa1, 0x26, 0x7f, 0xa3, 0x44, 0x1e, 0x50,
2173 0xcd, 0x35, 0x92, 0xb5, 0xdf, 0xa0, 0xaf, 0xa3, 0x5f, 0x47, 0x5b, 0xef,
2174 0x94, 0x9c, 0xb6, 0xcf, 0xae, 0x8c, 0xef, 0x47, 0x17, 0xe1, 0xbb, 0x50,
2175 0x7a, 0x56, 0xe3, 0xfc, 0x7e, 0x7d, 0x26, 0xbf, 0x41, 0x86, 0xcb, 0x21,
2176 0xce, 0x79, 0x06, 0x8e, 0xfb, 0x30, 0x5a, 0x25, 0x72, 0xac, 0x45, 0xfa,
2177 0x53, 0xa2, 0x72, 0xa9, 0x95, 0x7a, 0xff, 0xca, 0xa9, 0x6e, 0x89, 0xe7,
2178 0xba, 0x49, 0xab, 0xf7, 0xc9, 0x84, 0x9e, 0x8b, 0x16, 0xa9, 0x39, 0x46,
2179 0x1b, 0x25, 0x5c, 0xc3, 0xbb, 0xbd, 0xc5, 0xde, 0x41, 0x1d, 0x35, 0xe5,
2180 0x44, 0x0e, 0xea, 0xf9, 0x9a, 0xd5, 0x7b, 0x0c, 0x6f, 0x9e, 0x62, 0x2c,
2181 0x9e, 0xf7, 0xfd, 0x31, 0x0e, 0xff, 0xaf, 0x99, 0xbf, 0x42, 0x8b, 0xb1,
2182 0x67, 0xd6, 0x58, 0x3b, 0xc6, 0xc4, 0xa9, 0x96, 0xb7, 0x61, 0xd8, 0x4e,
2183 0xf5, 0x1d, 0xb5, 0xab, 0xe0, 0x03, 0x37, 0xa0, 0x4d, 0xae, 0x63, 0xdb,
2184 0xbf, 0x17, 0xe4, 0xfd, 0xb3, 0x73, 0xc0, 0x5f, 0x85, 0xb4, 0x06, 0xe4,
2185 0x31, 0x66, 0xf3, 0x85, 0x16, 0xc6, 0x65, 0xb3, 0x7e, 0xa3, 0x4d, 0x5b,
2186 0xe5, 0x8c, 0x8c, 0xb6, 0xc3, 0x37, 0xe7, 0x39, 0x76, 0xe6, 0xf7, 0x73,
2187 0xee, 0x84, 0x7f, 0xab, 0x69, 0x12, 0xf2, 0x67, 0x8f, 0x5c, 0x6b, 0xe3,
2188 0xce, 0xd4, 0xc3, 0xbf, 0xb8, 0x60, 0xbd, 0xf6, 0x10, 0xf4, 0xd8, 0xad,
2189 0x90, 0x47, 0xd4, 0xc3, 0x87, 0xe4, 0x17, 0x2c, 0x3d, 0x2f, 0xd4, 0xc3,
2190 0x17, 0x85, 0xb1, 0xe1, 0x2e, 0xe4, 0xe5, 0x83, 0x28, 0xe8, 0xe1, 0x70,
2191 0x95, 0xaf, 0x46, 0xbf, 0xaf, 0x2e, 0x6d, 0xd6, 0xc0, 0x16, 0xfa, 0x7d,
2192 0x90, 0x03, 0xb1, 0xd0, 0xcf, 0xab, 0x9d, 0x5b, 0xa3, 0xdd, 0x69, 0xeb,
2193 0x8e, 0xa4, 0x5e, 0x22, 0x8e, 0x12, 0x87, 0xe4, 0xf6, 0xf5, 0xbc, 0x26,
2194 0xcf, 0xf5, 0xbf, 0xa5, 0x71, 0x26, 0x8a, 0xb4, 0xb7, 0x46, 0xc3, 0x68,
2195 0xe5, 0x7c, 0x22, 0xdc, 0xbf, 0x51, 0xb0, 0x75, 0xf7, 0xd8, 0xf5, 0xf8,
2196 0x82, 0x7c, 0x9b, 0x71, 0xce, 0x44, 0x5f, 0x64, 0x25, 0xcf, 0x64, 0xa3,
2197 0xee, 0xed, 0xda, 0x6f, 0xcf, 0x48, 0xd8, 0x16, 0xbf, 0x6b, 0xaa, 0xda,
2198 0xa6, 0x1d, 0xc5, 0xf7, 0xe2, 0xfb, 0x1b, 0x9e, 0xd7, 0x6b, 0x8b, 0xe6,
2199 0x6e, 0x9a, 0x90, 0x4f, 0xc8, 0x3b, 0x09, 0x7d, 0x8e, 0xc9, 0x3f, 0x46,
2200 0xbb, 0x87, 0xeb, 0xae, 0xde, 0xf4, 0x70, 0xea, 0x23, 0xfa, 0x0e, 0xd5,
2201 0x71, 0x11, 0xa7, 0x90, 0xda, 0xab, 0xf7, 0x9d, 0x14, 0x74, 0x7c, 0x39,
2202 0x8f, 0xf7, 0xbc, 0x8f, 0xda, 0x76, 0x8c, 0x7f, 0x0b, 0x88, 0x69, 0x1f,
2203 0x04, 0x6c, 0xd4, 0x21, 0x94, 0xbd, 0x31, 0x69, 0x3b, 0xfa, 0x7e, 0xcd,
2204 0x0b, 0x6b, 0xe1, 0x0b, 0xf4, 0x1e, 0x85, 0xae, 0x3e, 0x1a, 0x97, 0xfe,
2205 0xa3, 0x5a, 0x37, 0x66, 0x96, 0xc6, 0x0a, 0xb6, 0x78, 0x2e, 0xfd, 0x89,
2206 0x98, 0x27, 0xd7, 0x1c, 0x8d, 0xc8, 0xe1, 0xd8, 0x16, 0xaf, 0xc3, 0xb9,
2207 0xd1, 0xea, 0x42, 0x43, 0x7f, 0xa0, 0x15, 0xd4, 0x37, 0xeb, 0x90, 0xbd,
2208 0xf3, 0xb1, 0x6b, 0xd4, 0x7f, 0x49, 0x46, 0xc8, 0x4b, 0x95, 0x88, 0x8c,
2209 0x0f, 0xb6, 0x02, 0x9e, 0xb7, 0xae, 0x07, 0x0e, 0x40, 0x53, 0x98, 0x1f,
2210 0xfd, 0xf7, 0x3c, 0xdc, 0x38, 0xe5, 0x57, 0x1b, 0xfa, 0xef, 0x3b, 0x4a,
2211 0x1d, 0xe6, 0x6b, 0xbe, 0x46, 0xbf, 0x5e, 0x8d, 0xf6, 0x3d, 0xc8, 0x8b,
2212 0x6f, 0x11, 0xff, 0x01, 0xc8, 0xb5, 0xa3, 0x51, 0xe9, 0x38, 0xda, 0x20,
2213 0x9b, 0x8e, 0xd2, 0xf7, 0xa8, 0xf6, 0x45, 0x69, 0x8b, 0x5e, 0xc2, 0xb8,
2214 0x6e, 0x34, 0xf7, 0x0d, 0x4e, 0x45, 0x65, 0x1f, 0xf9, 0x15, 0x65, 0x73,
2215 0xb0, 0x93, 0xb3, 0x47, 0x3d, 0xbd, 0x16, 0x9a, 0xc5, 0x38, 0xf9, 0x37,
2216 0x2c, 0xfa, 0x8e, 0x1a, 0x39, 0x53, 0xa0, 0x6f, 0x32, 0xd0, 0x02, 0xbc,
2217 0x3e, 0x60, 0xf9, 0xe5, 0x3d, 0xeb, 0x2d, 0x5f, 0xfe, 0x9c, 0xfc, 0x96,
2218 0x5b, 0x6f, 0xe4, 0xe5, 0x87, 0xd6, 0x73, 0x2f, 0xd2, 0x5a, 0x9f, 0xef,
2219 0x3a, 0x6d, 0x43, 0x18, 0xb9, 0xf9, 0x7a, 0xfc, 0x27, 0xc0, 0x51, 0xb8,
2220 0xfe, 0x44, 0x3e, 0xe4, 0x1a, 0xb2, 0x3e, 0xb3, 0x92, 0x9a, 0xd1, 0x7f,
2221 0x53, 0x89, 0x6b, 0x61, 0xf3, 0xf7, 0x59, 0x6d, 0xaf, 0x30, 0x36, 0xfe,
2222 0x4c, 0xf8, 0x37, 0x9c, 0xaa, 0xf6, 0x19, 0x56, 0xaf, 0x75, 0x31, 0xbe,
2223 0x34, 0xb7, 0x17, 0x28, 0x18, 0xd5, 0x77, 0xc2, 0xc5, 0x9c, 0x8b, 0xc5,
2224 0x5a, 0xe7, 0x9b, 0x63, 0x12, 0xb8, 0x7e, 0xdc, 0xf9, 0x96, 0xcf, 0xb5,
2225 0x71, 0xcf, 0x79, 0xb9, 0xe8, 0x83, 0xf7, 0xfe, 0x02, 0xe3, 0x68, 0x75,
2226 0x5e, 0xc1, 0x9c, 0x1e, 0x2c, 0x65, 0x92, 0x9e, 0x8d, 0x83, 0x3f, 0x5b,
2227 0x6c, 0x75, 0x9e, 0x9b, 0x8f, 0x21, 0xf5, 0x84, 0x74, 0x71, 0x88, 0x79,
2228 0x65, 0xe4, 0x95, 0x19, 0xeb, 0xad, 0x77, 0x26, 0xc7, 0xec, 0x7e, 0x12,
2229 0xa3, 0x8b, 0xe6, 0xd6, 0x5f, 0x06, 0xf4, 0xfa, 0x84, 0xeb, 0x4c, 0x4e,
2230 0x4d, 0xaf, 0x37, 0xfb, 0x8a, 0x6a, 0x91, 0x67, 0xf6, 0x58, 0x4e, 0x4c,
2231 0xd5, 0xa2, 0x4c, 0xbd, 0x33, 0xa1, 0x63, 0x5e, 0xda, 0xf6, 0x70, 0xc6,
2232 0xa7, 0xea, 0x9d, 0x29, 0xbd, 0xd6, 0x1c, 0x75, 0x4e, 0x8e, 0xb1, 0xed,
2233 0x28, 0xca, 0x88, 0x73, 0x0a, 0xed, 0x4d, 0x8d, 0xb5, 0xc7, 0xf7, 0x49,
2234 0x3b, 0x6c, 0x01, 0xfe, 0x8d, 0x34, 0xde, 0x17, 0xe0, 0x3a, 0x53, 0x73,
2235 0xed, 0x2a, 0xb4, 0xc3, 0xb2, 0xa4, 0x41, 0xf6, 0xeb, 0xa2, 0xfd, 0xa5,
2236 0x6b, 0x52, 0x4b, 0x71, 0x32, 0x06, 0x9c, 0x1c, 0xb4, 0x38, 0x39, 0x61,
2237 0x71, 0x32, 0x5a, 0x85, 0x93, 0x87, 0x17, 0xe1, 0xe4, 0x04, 0x70, 0xf2,
2238 0xf0, 0x15, 0x70, 0x82, 0xbc, 0xf2, 0xc3, 0x16, 0x27, 0xf7, 0x2d, 0xc2,
2239 0x49, 0x7e, 0x2e, 0x16, 0x6f, 0x70, 0x32, 0x02, 0x9c, 0xd4, 0xb4, 0x1a,
2240 0xd8, 0x0f, 0x5a, 0x9c, 0xe0, 0x3d, 0x75, 0x10, 0x65, 0xee, 0xab, 0xc2,
2241 0xc9, 0x41, 0xe0, 0xe4, 0x3e, 0x8b, 0x93, 0xc3, 0x16, 0x27, 0x87, 0x51,
2242 0x26, 0x0f, 0x9c, 0x14, 0x96, 0xc1, 0xc9, 0x08, 0x70, 0x12, 0xb6, 0x5b,
2243 0x40, 0x3b, 0x87, 0xab, 0x70, 0x32, 0xb2, 0x0c, 0x4e, 0xb8, 0xe6, 0x1a,
2244 0xee, 0xe1, 0xbe, 0xfc, 0x06, 0x7b, 0xb8, 0x53, 0x9f, 0x7d, 0xe3, 0x3d,
2245 0xdc, 0x2c, 0x73, 0xb9, 0xea, 0xcc, 0xfb, 0xb3, 0x76, 0x4f, 0x9a, 0xd9,
2246 0xfb, 0x37, 0x7f, 0x0f, 0x5e, 0x3b, 0xf8, 0xbc, 0x90, 0xf7, 0xc4, 0xec,
2247 0x21, 0x75, 0xb7, 0x4d, 0x81, 0xd7, 0x8e, 0xca, 0x81, 0xe3, 0xb5, 0x87,
2248 0x73, 0x36, 0xcd, 0xdf, 0xd6, 0x9e, 0x57, 0x8a, 0x79, 0xe1, 0xde, 0x83,
2249 0x17, 0xcd, 0x5d, 0x50, 0x31, 0x9e, 0xc7, 0xa8, 0x5e, 0x7b, 0x7e, 0xd1,
2250 0xde, 0x55, 0xe4, 0xdd, 0x9b, 0xf5, 0xa7, 0x13, 0xdc, 0x57, 0x55, 0xd0,
2251 0xf0, 0x72, 0x2d, 0xad, 0x47, 0xef, 0xa5, 0xca, 0x16, 0x69, 0x67, 0x27,
2252 0xb8, 0x27, 0x0d, 0xf6, 0x31, 0xf7, 0xed, 0x9a, 0x7d, 0xba, 0xbd, 0x0b,
2253 0xf6, 0xe9, 0x56, 0x9f, 0xef, 0x26, 0xdf, 0xcd, 0xd3, 0xcd, 0xc1, 0xb9,
2254 0xbb, 0x57, 0x8f, 0x3b, 0xcf, 0xe8, 0xf8, 0x70, 0x3d, 0xe6, 0x27, 0x08,
2255 0x4e, 0xa7, 0x4c, 0x5c, 0x76, 0x46, 0xc7, 0x65, 0x05, 0x1e, 0xf8, 0xb0,
2256 0x8d, 0xcd, 0x76, 0xf4, 0x5c, 0x9e, 0x8b, 0xcb, 0x2e, 0xd8, 0xa3, 0xa3,
2257 0xef, 0xff, 0xc8, 0x8e, 0x5e, 0xd2, 0x7b, 0x71, 0xfa, 0x52, 0x8e, 0x14,
2258 0x20, 0x23, 0xf6, 0x8c, 0xbf, 0x2a, 0xc3, 0x0f, 0xf2, 0x9b, 0x3a, 0x2d,
2259 0x02, 0xbd, 0x45, 0xb9, 0x9d, 0x97, 0x6c, 0x0f, 0xd3, 0x4c, 0x9d, 0x3e,
2260 0xed, 0x23, 0x1f, 0x77, 0x7a, 0xe7, 0xfa, 0x27, 0x7e, 0xc3, 0x35, 0x70,
2261 0xfe, 0xa6, 0x9d, 0x93, 0x71, 0xb2, 0x15, 0xe6, 0x87, 0x6b, 0xe1, 0x77,
2262 0xdb, 0xfb, 0x08, 0x99, 0x5f, 0x7d, 0xff, 0xb5, 0xe1, 0xd3, 0xac, 0xfe,
2263 0x3b, 0x22, 0x23, 0x4e, 0x1f, 0xea, 0x4c, 0x7b, 0x0d, 0x03, 0x2a, 0x7d,
2264 0xd3, 0x00, 0xcf, 0xca, 0x4d, 0x2c, 0xf9, 0xfb, 0x01, 0xf3, 0xba, 0xb0,
2265 0xa0, 0xe7, 0x94, 0xfb, 0xb0, 0xa6, 0x41, 0x8b, 0x9a, 0xb6, 0x34, 0xfd,
2266 0x1f, 0x98, 0xd3, 0x91, 0xd4, 0xad, 0xd4, 0x93, 0xa1, 0x8e, 0x4c, 0xc6,
2267 0xfb, 0x78, 0x7f, 0x84, 0xa6, 0x71, 0x7b, 0x97, 0xc4, 0xd4, 0x39, 0xad,
2268 0xdf, 0x47, 0x52, 0xbc, 0x5f, 0x66, 0x99, 0xb2, 0xa3, 0x55, 0x65, 0xf5,
2269 0xb8, 0x3d, 0xf9, 0x43, 0xcc, 0xcd, 0x17, 0x61, 0x6f, 0xf6, 0x8e, 0xbd,
2270 0x0a, 0x9f, 0x31, 0x2e, 0x5f, 0x2a, 0xbd, 0x04, 0x7a, 0xcd, 0xaf, 0xb5,
2271 0x77, 0xe1, 0x65, 0x01, 0x37, 0xcf, 0x38, 0xeb, 0xfd, 0xc3, 0x91, 0x3f,
2272 0x02, 0x5d, 0xfc, 0xc1, 0x4b, 0xec, 0x03, 0xb0, 0x44, 0x60, 0xcf, 0xc3,
2273 0x36, 0x18, 0x7f, 0x49, 0xef, 0x95, 0xbb, 0xbe, 0xfc, 0x92, 0x8e, 0x53,
2274 0xf4, 0x97, 0x5b, 0x65, 0x7b, 0xb9, 0x41, 0x76, 0x40, 0x2f, 0xec, 0x28,
2275 0xfb, 0x78, 0xa2, 0x72, 0x63, 0xd9, 0xcc, 0xd3, 0x47, 0xca, 0x9c, 0xef,
2276 0x6d, 0x32, 0x71, 0xbc, 0x9a, 0x66, 0xa7, 0xed, 0xde, 0x31, 0xd2, 0x0f,
2277 0x9e, 0x52, 0x32, 0x3f, 0xad, 0xc7, 0xce, 0x5d, 0xac, 0xc9, 0xc3, 0xb3,
2278 0xc2, 0xbd, 0xf8, 0xfc, 0x1b, 0x74, 0xdf, 0x68, 0xe5, 0x19, 0x77, 0xde,
2279 0x8f, 0xd8, 0x5f, 0x09, 0xf7, 0x86, 0xbf, 0xfe, 0x19, 0x10, 0xfd, 0x77,
2280 0x5d, 0xf4, 0xde, 0x70, 0x4d, 0x7b, 0xd2, 0x76, 0x26, 0xa6, 0x75, 0x84,
2281 0xa1, 0xf1, 0xf9, 0xbf, 0xe7, 0x22, 0xf2, 0x7f, 0x01, 0x95, 0xf6, 0x2d,
2282 0x58, 0xd0, 0x73, 0x00, 0x00, 0x00 };
2283static u32 bnx2_CP_b09FwData[(0x50/4) + 1] = {
2284 0x00010030, 0x00000030, 0x00000000, 0x00000001, 0x00010fd0, 0x00000fd0,
2285 0x00001430, 0x0000007f, 0x00030400, 0x00001000, 0x00000030, 0x00000020,
2286 0x00050200, 0x00001000, 0x00000030, 0x00000010, 0x00010400, 0x00000400,
2287 0x00001030, 0x00000020, 0x00000000 };
2288static u32 bnx2_CP_b09FwRodata[(0x118/4) + 1] = {
2289 0x080005d8, 0x080007f8, 0x0800073c, 0x08000764, 0x0800078c, 0x080007b4,
2290 0x08000610, 0x080005fc, 0x08000820, 0x08000820, 0x0800062c, 0x08000648,
2291 0x08000648, 0x08000820, 0x08000660, 0x08000674, 0x08000820, 0x08000688,
2292 0x08000820, 0x08000820, 0x0800069c, 0x08000820, 0x08000820, 0x08000820,
2293 0x08000820, 0x08000820, 0x08000820, 0x08000820, 0x08000820, 0x08000820,
2294 0x08000820, 0x080006b0, 0x08000820, 0x080006c4, 0x080006d8, 0x080006ec,
2295 0x08000820, 0x08000700, 0x08000714, 0x08000728, 0x08003740, 0x08003758,
2296 0x08003768, 0x08003778, 0x08003790, 0x080037a8, 0x080037b8, 0x080037c8,
2297 0x080037e8, 0x080037f8, 0x08003808, 0x08003898, 0x080037d8, 0x08003818,
2298 0x08003828, 0x08003840, 0x08003860, 0x08003898, 0x08003878, 0x08003878,
2299 0x080055f0, 0x080055f0, 0x080055f0, 0x080055f0, 0x080055f0, 0x08005618,
2300 0x08005618, 0x08005640, 0x08005690, 0x08005660, 0x00000000 };
2301static u32 bnx2_CP_b09FwBss[(0x870/4) + 1] = { 0x0 };
2302static u32 bnx2_CP_b09FwSbss[(0xe9/4) + 1] = { 0x0 };
2303
2304static struct fw_info bnx2_cp_fw_09 = {
2305 .ver_major = 0x1,
2306 .ver_minor = 0x0,
2307 .ver_fix = 0x0,
2308
2309 .start_addr = 0x0800006c,
2310
2311 .text_addr = 0x08000000,
2312 .text_len = 0x73cc,
2313 .text_index = 0x0,
2314 .gz_text = bnx2_CP_b09FwText,
2315 .gz_text_len = sizeof(bnx2_CP_b09FwText),
2316
2317 .data_addr = 0x08007500,
2318 .data_len = 0x50,
2319 .data_index = 0x0,
2320 .data = bnx2_CP_b09FwData,
2321
2322 .sbss_addr = 0x08007554,
2323 .sbss_len = 0xe9,
2324 .sbss_index = 0x0,
2325 .sbss = bnx2_CP_b09FwSbss,
2326
2327 .bss_addr = 0x08007640,
2328 .bss_len = 0x870,
2329 .bss_index = 0x0,
2330 .bss = bnx2_CP_b09FwBss,
2331
2332 .rodata_addr = 0x080073d0,
2333 .rodata_len = 0x118,
2334 .rodata_index = 0x0,
2335 .rodata = bnx2_CP_b09FwRodata,
2336};
2337
2338static u8 bnx2_RXP_b09FwText[] = {
2339 0x1f, 0x8b, 0x08, 0x08, 0x19, 0xfd, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
2340 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xec, 0x5c, 0x6b, 0x6c,
2341 0x1c, 0xd7, 0x75, 0x3e, 0xf3, 0x20, 0xb5, 0xa2, 0xf8, 0x18, 0x2e, 0x57,
2342 0xcc, 0x4a, 0x66, 0xec, 0x5d, 0x71, 0x24, 0xb2, 0x16, 0x6b, 0x8c, 0xd8,
2343 0xad, 0x4d, 0x04, 0x6b, 0x7b, 0x33, 0xbb, 0x92, 0x98, 0x54, 0x85, 0x29,
2344 0x87, 0x75, 0x0c, 0xc3, 0x75, 0xd9, 0xa5, 0x1a, 0xbb, 0xae, 0x51, 0xc8,
2345 0x8f, 0xc4, 0x06, 0x6a, 0xd6, 0x9b, 0x25, 0xdd, 0xa8, 0xe9, 0x82, 0x43,
2346 0x4b, 0xaa, 0xe9, 0x02, 0x69, 0xbb, 0x20, 0xa9, 0xc7, 0x8f, 0x85, 0x56,
2347 0x76, 0x52, 0xc7, 0xf9, 0xe1, 0x48, 0x50, 0x95, 0x20, 0x28, 0x0c, 0x43,
2348 0x48, 0x8d, 0xd6, 0x3f, 0xda, 0x40, 0x95, 0x9f, 0x68, 0x92, 0x42, 0x41,
2349 0x0b, 0xc7, 0x68, 0x6c, 0x4f, 0xbf, 0xef, 0xce, 0x0c, 0xb9, 0xa4, 0x5f,
2350 0x40, 0x7f, 0xf4, 0x4f, 0xe7, 0x02, 0x8b, 0xb9, 0xf7, 0xce, 0x3d, 0xe7,
2351 0x9e, 0x7b, 0xde, 0xe7, 0x0e, 0xa5, 0xdf, 0xef, 0x94, 0x0e, 0x09, 0x5b,
2352 0x17, 0x7e, 0x99, 0xc3, 0x8f, 0x3d, 0x74, 0xc3, 0xd8, 0x0d, 0xa3, 0x22,
2353 0x7b, 0xf6, 0x18, 0x5b, 0x12, 0x7a, 0x34, 0x1f, 0xb7, 0xb8, 0xc5, 0x2d,
2354 0x6e, 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e,
2355 0x71, 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71,
2356 0x8b, 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b,
2357 0x5b, 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b,
2358 0xdc, 0xe2, 0x16, 0xb7, 0xb8, 0xc5, 0x2d, 0x6e, 0x71, 0x8b, 0x5b, 0xdc,
2359 0xe2, 0xf6, 0xff, 0xbd, 0x19, 0x22, 0x16, 0x9f, 0x5d, 0xe1, 0x4f, 0x12,
2360 0x7a, 0xfe, 0xf2, 0x1f, 0xba, 0xb6, 0x24, 0x8c, 0xfc, 0xcf, 0x66, 0xa6,
2361 0x6d, 0x91, 0x42, 0x63, 0x77, 0xa6, 0x28, 0xef, 0xfb, 0x95, 0x94, 0x29,
2362 0x9c, 0xff, 0x6c, 0xfe, 0xbd, 0xbf, 0x7d, 0xf1, 0xa6, 0xec, 0xd5, 0xba,
2363 0x21, 0x09, 0x2b, 0x3f, 0xb7, 0xc7, 0xda, 0x25, 0x89, 0x01, 0xc0, 0x7c,
2364 0x6b, 0xe8, 0xc7, 0xdd, 0xd2, 0x2d, 0x6b, 0x78, 0xec, 0x84, 0x5c, 0x36,
2365 0x5e, 0xd0, 0xdc, 0xa6, 0xef, 0x9f, 0x70, 0x7c, 0xff, 0x87, 0xf8, 0xbd,
2366 0xe5, 0x60, 0xec, 0x7d, 0xe0, 0x17, 0x4c, 0x43, 0x74, 0xfb, 0x2f, 0x34,
2367 0x77, 0xb9, 0x43, 0xaa, 0x8b, 0xa6, 0xcc, 0x7a, 0x29, 0x39, 0xe2, 0x55,
2368 0xb4, 0x52, 0xb3, 0xa6, 0xed, 0x3d, 0x35, 0xaf, 0xed, 0x3b, 0x75, 0x44,
2369 0xdb, 0x7f, 0x6a, 0x41, 0x73, 0x4f, 0x49, 0x45, 0xdf, 0xd3, 0x29, 0x05,
2370 0xeb, 0xb4, 0x56, 0x6c, 0xf6, 0x6b, 0xee, 0xe2, 0x7b, 0xbe, 0xeb, 0x64,
2371 0xad, 0xbb, 0xc4, 0x2c, 0x80, 0x16, 0x71, 0x6b, 0x3e, 0xc6, 0xa6, 0x14,
2372 0x52, 0xbe, 0xaf, 0xe7, 0xfd, 0x27, 0xdc, 0x9c, 0x6d, 0xe9, 0x5a, 0x4a,
2373 0xaa, 0xcd, 0x7e, 0xe0, 0xed, 0xd4, 0x8a, 0x8b, 0xa6, 0x56, 0xf2, 0xfc,
2374 0x73, 0xae, 0x23, 0x03, 0x86, 0xf8, 0xfe, 0x9c, 0xb3, 0x33, 0x7d, 0x48,
2375 0x4e, 0x02, 0x6f, 0x03, 0xf8, 0xc4, 0xd2, 0xf3, 0xa4, 0x8f, 0x74, 0x92,
2376 0xe4, 0x8a, 0x56, 0x1c, 0x8a, 0xe8, 0x93, 0x0c, 0xe9, 0x2f, 0xaf, 0xe8,
2377 0xa0, 0x73, 0x8b, 0x94, 0xeb, 0x96, 0x4c, 0xad, 0x6c, 0x5c, 0x7f, 0xd9,
2378 0x7f, 0x71, 0x28, 0x25, 0xcf, 0x36, 0xb3, 0x47, 0x2a, 0x92, 0x90, 0x39,
2379 0x2f, 0x23, 0x7a, 0x5e, 0x0a, 0x6e, 0x6e, 0x40, 0xce, 0x35, 0xd3, 0xf2,
2380 0x5c, 0xd3, 0x4e, 0x57, 0x65, 0x93, 0x94, 0x53, 0x96, 0x9c, 0x6d, 0xa6,
2381 0x70, 0x46, 0xff, 0x9c, 0x6e, 0xdb, 0x56, 0x15, 0x6b, 0xab, 0xcd, 0x97,
2382 0xf8, 0xef, 0x5f, 0xac, 0xe9, 0x9c, 0x82, 0xa9, 0x80, 0xee, 0x70, 0x2d,
2383 0xcf, 0xa1, 0xd6, 0xaa, 0xb3, 0x04, 0x6b, 0xa5, 0x32, 0x9d, 0xc3, 0x5c,
2384 0x73, 0x34, 0xe4, 0xef, 0x16, 0x9c, 0x97, 0x4f, 0x4b, 0xaa, 0x9e, 0x01,
2385 0xde, 0xb0, 0xff, 0xcf, 0xc0, 0x37, 0x80, 0xf3, 0x5e, 0xab, 0x7e, 0xee,
2386 0xa2, 0xa4, 0x74, 0xd9, 0x99, 0x2e, 0x0b, 0x78, 0xdb, 0xec, 0xc4, 0x98,
2387 0xf4, 0xf9, 0xfe, 0x7e, 0x47, 0xac, 0xaa, 0xd3, 0x03, 0x98, 0x8c, 0x54,
2388 0x9d, 0x6e, 0xe0, 0x69, 0x13, 0xcb, 0xe6, 0xb9, 0xb8, 0xd7, 0x66, 0xcc,
2389 0xfb, 0x5d, 0x46, 0xde, 0xf7, 0xa7, 0x73, 0xd2, 0x1d, 0xcc, 0xed, 0x56,
2390 0x38, 0xa6, 0x26, 0x34, 0xac, 0xfb, 0x05, 0x69, 0x4e, 0x24, 0xf3, 0xec,
2391 0xf3, 0x99, 0x13, 0x77, 0xfe, 0xda, 0x90, 0x96, 0x34, 0x68, 0xb9, 0x26,
2392 0xec, 0x83, 0xff, 0x1e, 0xf8, 0xe0, 0x7c, 0x06, 0x63, 0xed, 0x3a, 0xe0,
2393 0x19, 0xae, 0x0a, 0xf7, 0xe8, 0x93, 0xa5, 0x94, 0xe8, 0x57, 0x9c, 0xde,
2394 0x70, 0x5d, 0x37, 0x68, 0x8d, 0xf4, 0xa0, 0x5f, 0xe6, 0x16, 0xc9, 0xeb,
2395 0x1a, 0x64, 0x83, 0xe7, 0x8d, 0x15, 0xad, 0xd0, 0x3c, 0x82, 0xbe, 0x29,
2396 0xd3, 0xb6, 0x7f, 0x6e, 0xce, 0x99, 0xd7, 0x8a, 0xa7, 0x4e, 0x6a, 0xa5,
2397 0x53, 0x2f, 0x68, 0x7b, 0x9b, 0x2f, 0x74, 0x49, 0x47, 0x16, 0xa7, 0x4e,
2398 0xc8, 0x93, 0x9e, 0x26, 0xa4, 0x73, 0x09, 0xbc, 0x2b, 0x58, 0x15, 0x31,
2399 0xed, 0x6e, 0x6d, 0x1f, 0xf0, 0xb4, 0xd9, 0x7f, 0xd2, 0x29, 0xdd, 0x86,
2400 0x6c, 0xb2, 0xa3, 0xb5, 0x29, 0xf9, 0x33, 0xd0, 0x74, 0xc1, 0x49, 0x91,
2401 0x5f, 0x3d, 0x01, 0x4c, 0x44, 0x07, 0xf5, 0x8a, 0x3a, 0xa5, 0x17, 0x4a,
2402 0xc7, 0xff, 0xbc, 0xaf, 0x3a, 0xb2, 0x85, 0x6b, 0xa0, 0xff, 0xd6, 0xfd,
2403 0xd3, 0xb6, 0xdb, 0x6b, 0x4a, 0xc5, 0xd2, 0x25, 0x6b, 0x15, 0xe5, 0x3a,
2404 0x99, 0x73, 0x44, 0x8a, 0x35, 0xec, 0x69, 0x9b, 0xe0, 0x8d, 0x0d, 0xde,
2405 0xec, 0x3c, 0x32, 0xa8, 0xff, 0x96, 0x64, 0xfa, 0x2b, 0x9a, 0x19, 0xf2,
2406 0x71, 0x49, 0x6e, 0x51, 0xf0, 0x7a, 0xde, 0x81, 0x7e, 0x76, 0xb0, 0x8f,
2407 0x7d, 0x13, 0x6a, 0x5f, 0x23, 0x6f, 0xa7, 0x97, 0x45, 0x34, 0x3d, 0xbf,
2408 0x1b, 0xf8, 0xa8, 0xb7, 0x5c, 0xf7, 0x04, 0x68, 0x24, 0xed, 0xec, 0xdb,
2409 0x80, 0x49, 0x88, 0xeb, 0x74, 0xb5, 0xd0, 0x49, 0x79, 0x93, 0xd7, 0xe4,
2410 0x9d, 0x3a, 0xa7, 0xb6, 0x76, 0xce, 0x5f, 0xf9, 0x9b, 0x46, 0x4d, 0xf9,
2411 0xa1, 0x3a, 0x2f, 0x6d, 0x8c, 0xeb, 0x52, 0xa1, 0x4e, 0x24, 0xa0, 0x47,
2412 0xa2, 0x95, 0x1d, 0x6b, 0x15, 0x57, 0x59, 0x44, 0x37, 0xf2, 0x9d, 0x52,
2413 0x54, 0xf4, 0x8d, 0x61, 0x2f, 0xda, 0x1e, 0x6c, 0xc8, 0xe6, 0x59, 0x38,
2414 0x97, 0x87, 0x8d, 0x67, 0xd9, 0x97, 0xf2, 0x02, 0xed, 0x9d, 0xb4, 0x9d,
2415 0xcf, 0xaa, 0x7f, 0x8e, 0x45, 0x5d, 0x3c, 0xd6, 0x03, 0xda, 0x38, 0x86,
2416 0x1d, 0xda, 0x78, 0x3f, 0xa2, 0x89, 0x3b, 0x36, 0x08, 0xfe, 0x70, 0x9d,
2417 0x9d, 0x81, 0x9c, 0x0b, 0x2e, 0xf6, 0x74, 0x9d, 0xdf, 0x50, 0x3c, 0xe8,
2418 0xc5, 0x79, 0x06, 0xe7, 0xc9, 0xaf, 0x0e, 0xe8, 0xb6, 0x26, 0x65, 0x27,
2419 0x9b, 0xa1, 0xdc, 0x03, 0xda, 0x75, 0xd9, 0x74, 0x63, 0x2b, 0xed, 0x91,
2420 0xac, 0xa8, 0x87, 0xa6, 0x24, 0x47, 0xb9, 0x96, 0xeb, 0xb8, 0x3e, 0x3b,
2421 0x26, 0xfa, 0xaf, 0x7c, 0x6b, 0xdd, 0x59, 0x6d, 0xd9, 0x31, 0x0f, 0x1a,
2422 0x02, 0xde, 0x82, 0x27, 0x9f, 0xb6, 0x96, 0x7c, 0xdd, 0xc8, 0x3f, 0xae,
2423 0x6d, 0x5d, 0x07, 0x9d, 0xe8, 0x27, 0x0d, 0x27, 0x3a, 0x03, 0x5b, 0x8b,
2424 0x68, 0x8a, 0x64, 0xa3, 0x85, 0x38, 0x3e, 0xe9, 0x1c, 0x5c, 0x0f, 0x1f,
2425 0xe0, 0xc1, 0x07, 0xc0, 0xaf, 0x3d, 0xeb, 0xc1, 0xfe, 0x3d, 0xfa, 0x8c,
2426 0x8c, 0xbc, 0x38, 0x04, 0x1f, 0xb7, 0xe6, 0x63, 0xd0, 0xc6, 0xd1, 0xd7,
2427 0xc5, 0x80, 0x8f, 0x99, 0xad, 0xeb, 0xb0, 0x59, 0xf0, 0x78, 0x85, 0x73,
2428 0xb0, 0xed, 0x95, 0x12, 0x9e, 0xb6, 0x54, 0x1b, 0xd4, 0xab, 0xc8, 0x97,
2429 0xd2, 0xe7, 0xa4, 0xe1, 0x5f, 0xe8, 0x77, 0xe8, 0x57, 0xb8, 0xd6, 0xf7,
2430 0x4b, 0x0e, 0x61, 0x7d, 0x99, 0x70, 0x68, 0x43, 0x9d, 0xa2, 0x27, 0x2b,
2431 0xda, 0xc1, 0x21, 0xd8, 0xd6, 0xf5, 0x6d, 0xa0, 0x95, 0x36, 0x76, 0x8d,
2432 0x48, 0x3b, 0xf7, 0xfb, 0x69, 0x57, 0xf0, 0xef, 0xee, 0x36, 0x61, 0x0d,
2433 0x9f, 0xef, 0x86, 0x63, 0x2d, 0xf4, 0x2d, 0x7c, 0x9f, 0xcd, 0x14, 0xa4,
2434 0x3f, 0x1c, 0xb3, 0xbf, 0x4a, 0xaf, 0xa3, 0xdf, 0x98, 0x90, 0x1d, 0x27,
2435 0x03, 0x9f, 0xb8, 0x63, 0xc9, 0x12, 0xfb, 0x64, 0x40, 0xe3, 0x8e, 0x33,
2436 0x91, 0x6f, 0x7c, 0x1f, 0xf0, 0xa0, 0xcf, 0x5b, 0x8d, 0x03, 0x68, 0x3f,
2437 0xd3, 0x60, 0x2a, 0x98, 0xdb, 0xc8, 0x0b, 0xfa, 0x63, 0xda, 0x9b, 0xd5,
2438 0x6a, 0x6f, 0x7b, 0x60, 0x6f, 0x4e, 0xbb, 0x64, 0x9d, 0xbf, 0x87, 0xbd,
2439 0x7d, 0xc3, 0xd1, 0xc0, 0x1b, 0x91, 0x8b, 0xb5, 0x34, 0x6c, 0xdd, 0x4c,
2440 0xbf, 0x26, 0x3b, 0x33, 0xb3, 0xa2, 0xc9, 0x09, 0xce, 0x35, 0x30, 0xa7,
2441 0x7c, 0x71, 0xe0, 0x0b, 0x2e, 0x1b, 0x4f, 0x81, 0x2e, 0xdf, 0x9f, 0x05,
2442 0xce, 0xf2, 0x88, 0x11, 0xda, 0x56, 0x34, 0x6f, 0xdd, 0xef, 0xda, 0xee,
2443 0xaf, 0x19, 0x52, 0x19, 0x6e, 0x93, 0xec, 0xf0, 0x12, 0x70, 0x4f, 0x3b,
2444 0x81, 0x1d, 0x53, 0xd7, 0x97, 0x81, 0x7f, 0xce, 0x1b, 0x82, 0x1e, 0xd3,
2445 0x0e, 0x40, 0x17, 0xf0, 0x2f, 0x03, 0xff, 0x5c, 0xb3, 0x4d, 0xbe, 0x6e,
2446 0x46, 0xb1, 0x32, 0x3a, 0x4f, 0x37, 0x96, 0x45, 0xfb, 0x1e, 0x96, 0x2f,
2447 0x7a, 0x49, 0xcd, 0x3d, 0x46, 0xff, 0x5a, 0x1d, 0x86, 0x9d, 0x68, 0x55,
2448 0x87, 0x7b, 0x1b, 0xb2, 0xbc, 0xba, 0x46, 0x0a, 0xd5, 0xc0, 0x06, 0x0b,
2449 0xee, 0x50, 0x25, 0x6d, 0x28, 0x5f, 0x22, 0xb2, 0x0f, 0xb6, 0xb7, 0x6c,
2450 0x73, 0xcc, 0xf9, 0x60, 0x6e, 0xbc, 0xd6, 0x0f, 0x9f, 0xc8, 0xf1, 0x7b,
2451 0xfe, 0xb4, 0x13, 0xcc, 0x7d, 0xa1, 0x76, 0x57, 0x37, 0xfd, 0x2e, 0xe2,
2452 0x44, 0xa6, 0xea, 0xfc, 0xbb, 0x0f, 0xfd, 0x5d, 0x07, 0xf3, 0xd1, 0x78,
2453 0xb2, 0xe3, 0x81, 0xce, 0x8a, 0xb6, 0xdf, 0xd6, 0xfb, 0xdb, 0x43, 0x1f,
2454 0xb6, 0x1f, 0x93, 0x7b, 0x6b, 0xd5, 0xbe, 0x76, 0x79, 0xcf, 0x60, 0x1c,
2455 0xbd, 0x22, 0x62, 0xba, 0xb5, 0x5d, 0xe0, 0x47, 0xb5, 0xb7, 0x65, 0x2e,
2456 0x51, 0xaa, 0xf9, 0x72, 0xc1, 0x09, 0x60, 0x30, 0xee, 0x2c, 0xd6, 0xf4,
2457 0xfe, 0x84, 0xac, 0x8e, 0x2d, 0xc2, 0xac, 0xc8, 0xae, 0xe1, 0x65, 0x51,
2458 0xb0, 0x7d, 0x89, 0x35, 0xd8, 0x54, 0xa9, 0x56, 0xed, 0x6d, 0x19, 0xa7,
2459 0x8b, 0xc0, 0xa5, 0xef, 0x59, 0x85, 0x1d, 0x58, 0x83, 0xdd, 0x2a, 0x99,
2460 0x5e, 0xc2, 0xeb, 0xfd, 0x9b, 0xd7, 0x70, 0x67, 0x42, 0x7a, 0xfa, 0x36,
2461 0xaf, 0xe1, 0xb0, 0x89, 0xb3, 0x65, 0x3c, 0x4c, 0x9c, 0x3b, 0xd6, 0x70,
2462 0x8e, 0xac, 0xa7, 0xe7, 0xb0, 0xc0, 0x07, 0x25, 0xda, 0xf3, 0xb2, 0xe7,
2463 0x62, 0x6d, 0x70, 0xe2, 0x8b, 0x82, 0x58, 0x37, 0xb2, 0x29, 0xf4, 0xc9,
2464 0xe6, 0x1e, 0x17, 0xbc, 0x32, 0x85, 0x3e, 0x4e, 0x93, 0x2a, 0xe4, 0x7c,
2465 0x7f, 0x43, 0xf6, 0x5c, 0x68, 0x98, 0xa1, 0x2e, 0x51, 0x27, 0xde, 0x86,
2466 0x8d, 0x75, 0x4e, 0x99, 0x88, 0xc3, 0xe7, 0x94, 0x8d, 0xc9, 0x44, 0xb5,
2467 0x26, 0x95, 0xed, 0xf9, 0x27, 0x7c, 0xe8, 0xe2, 0x94, 0x05, 0x3f, 0x5a,
2468 0x94, 0xce, 0x31, 0x37, 0x87, 0xf9, 0x06, 0x6d, 0x0b, 0x7e, 0x05, 0xb0,
2469 0xd0, 0xb5, 0x84, 0x31, 0xbf, 0xf3, 0x55, 0xd7, 0xe0, 0x3e, 0x19, 0xe4,
2470 0x4d, 0x89, 0x84, 0x3e, 0x7f, 0xd5, 0xa7, 0x9e, 0x4d, 0x8f, 0x5c, 0x45,
2471 0x9e, 0x62, 0xc1, 0x57, 0xc2, 0x7f, 0x40, 0xdf, 0x67, 0x9b, 0x82, 0xb8,
2472 0xfe, 0x40, 0x4f, 0x60, 0x63, 0x47, 0xb7, 0x06, 0x4f, 0x31, 0xe9, 0x9b,
2473 0xa7, 0x73, 0xcc, 0x01, 0xda, 0x13, 0x6e, 0x6e, 0x7c, 0x9b, 0x71, 0xe6,
2474 0xc0, 0x36, 0xfd, 0x4c, 0x65, 0x9b, 0x0e, 0x9f, 0x0e, 0x9b, 0xd2, 0xdd,
2475 0x1c, 0xfa, 0x67, 0x22, 0x1b, 0x4a, 0xc3, 0x86, 0xde, 0x56, 0x39, 0xc8,
2476 0xb9, 0xe6, 0x29, 0xd8, 0xab, 0xa2, 0x55, 0x26, 0x90, 0x13, 0xe8, 0xa3,
2477 0xef, 0x43, 0x4f, 0x70, 0x16, 0xf8, 0xc0, 0x02, 0xb8, 0xa4, 0x8f, 0xbe,
2478 0x11, 0xda, 0x33, 0xfb, 0xef, 0xf8, 0x41, 0x7c, 0xf8, 0x7c, 0xb8, 0xff,
2479 0x3f, 0x75, 0x07, 0x3e, 0x20, 0xc2, 0x45, 0x3c, 0xc3, 0xda, 0x04, 0xf2,
2480 0x99, 0x89, 0xa6, 0xa9, 0xd1, 0x9f, 0x17, 0x3d, 0xe6, 0x21, 0xcc, 0x41,
2481 0x1e, 0x0b, 0xfd, 0x22, 0x73, 0x8f, 0xce, 0x90, 0xa7, 0xb9, 0x28, 0xce,
2482 0x29, 0x7b, 0x43, 0xcc, 0xc9, 0x94, 0x9d, 0x36, 0xe5, 0x93, 0xa7, 0x73,
2483 0x9d, 0x58, 0x87, 0xb9, 0x26, 0xce, 0x0d, 0xbf, 0x84, 0x5c, 0x06, 0x6b,
2484 0xce, 0x63, 0x7d, 0x7b, 0x68, 0xf3, 0x17, 0xa5, 0x0c, 0x9f, 0x6a, 0xda,
2485 0x7c, 0x9f, 0xeb, 0x91, 0x0e, 0x8c, 0x1b, 0xd8, 0x0b, 0x7e, 0xc2, 0x50,
2486 0x7c, 0x46, 0x2c, 0x48, 0x5d, 0xc7, 0x1c, 0x09, 0x6b, 0x33, 0x58, 0x4b,
2487 0xbf, 0xcb, 0xb5, 0xcf, 0x82, 0x0e, 0x8c, 0x1b, 0x84, 0xa1, 0x8f, 0x12,
2488 0xdf, 0xcd, 0x6d, 0x86, 0x26, 0xf9, 0xe7, 0x0c, 0x3b, 0x5a, 0x1b, 0xe1,
2489 0xdd, 0xb8, 0x96, 0xf9, 0x09, 0x71, 0xf7, 0x84, 0xf1, 0x7f, 0x5c, 0x0a,
2490 0xcd, 0x02, 0x7e, 0x22, 0xd3, 0xc7, 0x90, 0x8f, 0xd9, 0x6d, 0x88, 0x55,
2491 0x9c, 0xdf, 0x6a, 0x05, 0x67, 0x8d, 0xe0, 0xee, 0xef, 0x5b, 0x3f, 0xfe,
2492 0x42, 0x72, 0xcd, 0x47, 0xd2, 0xc2, 0xa4, 0x80, 0x18, 0x01, 0x5e, 0x65,
2493 0xa6, 0x98, 0xc3, 0x15, 0x1b, 0x4a, 0xa6, 0x98, 0x1b, 0x83, 0x5f, 0x0c,
2494 0xf2, 0xa2, 0x73, 0xde, 0x46, 0xd9, 0x59, 0xe0, 0x77, 0x01, 0x3c, 0xce,
2495 0x40, 0x87, 0xc6, 0x01, 0x2b, 0x87, 0x81, 0x83, 0xf1, 0xd7, 0xd1, 0xf3,
2496 0x49, 0x29, 0x5b, 0xcc, 0x13, 0xda, 0x49, 0x67, 0x81, 0xf6, 0xaf, 0xe7,
2497 0x37, 0x63, 0x8e, 0xfd, 0x7b, 0x7b, 0x02, 0x99, 0x75, 0x71, 0x3c, 0xa1,
2498 0xe7, 0x7b, 0x36, 0xcc, 0x7f, 0xbf, 0x2b, 0xa0, 0x4d, 0x8d, 0x31, 0xff,
2499 0xf2, 0x86, 0xf1, 0xef, 0x25, 0xd7, 0x8f, 0xef, 0xda, 0x16, 0xea, 0x20,
2500 0xfa, 0x8f, 0x85, 0xf4, 0x82, 0xb6, 0x55, 0x5a, 0xa3, 0x9c, 0x57, 0x16,
2501 0x74, 0xe4, 0x7f, 0x6e, 0x6e, 0x27, 0x62, 0x7d, 0x46, 0x4a, 0x4d, 0xd0,
2502 0xbd, 0x1a, 0xcb, 0x56, 0xd7, 0x54, 0xd6, 0xd6, 0x04, 0xbe, 0xbe, 0xd4,
2503 0xf4, 0x91, 0x3b, 0xb5, 0xc6, 0xbd, 0x61, 0xf4, 0x2b, 0xd8, 0xa7, 0x20,
2504 0xd3, 0xde, 0x85, 0x82, 0x6e, 0x1f, 0x09, 0xf2, 0x3e, 0xfb, 0x9b, 0x5a,
2505 0x69, 0x99, 0xf9, 0x20, 0xec, 0xc9, 0x56, 0xf9, 0x3f, 0xe2, 0xca, 0x51,
2506 0xad, 0x70, 0xea, 0x38, 0xf2, 0xc1, 0x15, 0xfc, 0x4e, 0xe3, 0xd7, 0xc0,
2507 0x2f, 0xca, 0xc3, 0x9f, 0x41, 0x1e, 0xaf, 0x7c, 0x2c, 0xe2, 0x41, 0xb0,
2508 0xff, 0x1b, 0x2b, 0xd0, 0xb3, 0xe3, 0x29, 0xf9, 0x86, 0xad, 0xf7, 0xe9,
2509 0x81, 0x5f, 0x29, 0x20, 0x8f, 0xb5, 0xde, 0x96, 0xdf, 0x0e, 0xf3, 0x22,
2510 0x91, 0xd7, 0x16, 0xc0, 0xc7, 0x91, 0xfd, 0xa1, 0xce, 0x16, 0xee, 0x75,
2511 0x95, 0xff, 0x0c, 0xf3, 0x1e, 0xe4, 0x5f, 0x05, 0xb5, 0xea, 0x5b, 0xe0,
2512 0x8d, 0x26, 0x6f, 0x41, 0x87, 0x5e, 0x5b, 0xe8, 0x00, 0x3d, 0xb6, 0x94,
2513 0x27, 0x91, 0x2f, 0x68, 0x83, 0xd6, 0x26, 0xad, 0x03, 0x76, 0x0c, 0x1b,
2514 0x57, 0x63, 0x49, 0xb4, 0xe5, 0x2f, 0xcd, 0x2c, 0xd5, 0x74, 0xac, 0x45,
2515 0xee, 0x93, 0x43, 0x1f, 0xb2, 0xbf, 0xb2, 0x40, 0x38, 0x5d, 0x5e, 0x5f,
2516 0x30, 0xe4, 0x4d, 0xe4, 0x52, 0x6f, 0xd9, 0x97, 0x66, 0x10, 0xb7, 0xfa,
2517 0x11, 0x23, 0x50, 0x8b, 0xec, 0xa4, 0x9f, 0xde, 0x61, 0xe2, 0x59, 0xc2,
2518 0x6f, 0x1f, 0x72, 0xc1, 0x8f, 0x86, 0xf9, 0xb8, 0xf5, 0xa4, 0x2d, 0x01,
2519 0x18, 0xae, 0x37, 0x41, 0x5b, 0x37, 0xe4, 0x9f, 0xb5, 0xa6, 0xe4, 0xf5,
2520 0x1e, 0x95, 0xaf, 0x68, 0x9c, 0x0f, 0x7c, 0xd3, 0x87, 0xe7, 0xc9, 0x67,
2521 0x03, 0x3a, 0xce, 0x31, 0xdf, 0xd1, 0x87, 0x12, 0x5f, 0x76, 0xac, 0x80,
2522 0xc3, 0x5c, 0x59, 0x08, 0xfa, 0xd1, 0x9c, 0x68, 0x51, 0x1c, 0xa3, 0x6f,
2523 0x2c, 0xc1, 0x4e, 0x38, 0x9e, 0x10, 0x25, 0x83, 0x75, 0xf2, 0x94, 0x84,
2524 0x99, 0x3f, 0x3b, 0x33, 0x67, 0x53, 0xae, 0xf0, 0x71, 0xb5, 0x48, 0xae,
2525 0x94, 0x51, 0xbb, 0x54, 0x17, 0xbe, 0x09, 0xb9, 0xea, 0x61, 0xbe, 0x0f,
2526 0x1b, 0x3f, 0x4e, 0xf9, 0xa2, 0xfe, 0x5b, 0x40, 0xee, 0xb3, 0x20, 0xc9,
2527 0xa0, 0x5e, 0x39, 0x8a, 0x3c, 0x1f, 0xf2, 0xab, 0x1d, 0x07, 0x0e, 0xd8,
2528 0x69, 0x6d, 0x05, 0x4f, 0xd4, 0x16, 0xb5, 0xd3, 0x78, 0x0e, 0xe0, 0xd9,
2529 0xa0, 0x6e, 0x86, 0xb9, 0xc6, 0x87, 0xe8, 0x81, 0x3d, 0x95, 0x68, 0x4f,
2530 0xf2, 0xfd, 0x66, 0x5e, 0xbe, 0xdb, 0x1c, 0x93, 0xe7, 0x9b, 0x39, 0xf9,
2531 0xbb, 0xa6, 0x23, 0xdf, 0x69, 0x8e, 0xc8, 0xb7, 0x9b, 0xc3, 0xac, 0xc9,
2532 0x90, 0x37, 0x65, 0x98, 0x37, 0xc9, 0xbd, 0xde, 0xad, 0xb0, 0x77, 0xca,
2533 0xff, 0xd2, 0x4c, 0xa1, 0x31, 0x28, 0xe5, 0x63, 0xf0, 0xcf, 0xce, 0xcd,
2534 0xac, 0x25, 0xe5, 0x11, 0x87, 0x35, 0x41, 0x1b, 0xdf, 0xa3, 0xce, 0x84,
2535 0xff, 0x86, 0x3f, 0x9b, 0x4a, 0x65, 0x4f, 0xbb, 0x46, 0x47, 0xe8, 0x03,
2536 0x6e, 0x49, 0x4a, 0x07, 0xf6, 0x82, 0x0f, 0x5c, 0x7a, 0x1a, 0x36, 0xa0,
2537 0x6a, 0x9a, 0x04, 0xfc, 0x0d, 0x73, 0x01, 0x93, 0x76, 0x8c, 0x3a, 0x30,
2538 0x9b, 0x71, 0x0d, 0xd6, 0x77, 0xb4, 0x67, 0x03, 0x81, 0x83, 0x70, 0xfb,
2539 0x2c, 0xca, 0xcd, 0xb4, 0xe9, 0x57, 0x0b, 0xa1, 0x8f, 0x4b, 0x84, 0x7a,
2540 0x69, 0x61, 0xfe, 0xf1, 0xd0, 0x27, 0x6f, 0xdc, 0x07, 0xf1, 0x02, 0xf9,
2541 0x64, 0xb0, 0x8e, 0xb0, 0x5a, 0x08, 0xdb, 0x17, 0xce, 0x75, 0x82, 0xdf,
2542 0x8e, 0x94, 0xbd, 0x37, 0x35, 0xe6, 0xd9, 0xc8, 0x77, 0x30, 0x1e, 0xc1,
2543 0xf8, 0x4a, 0x38, 0xfe, 0x9c, 0x4c, 0x2f, 0x0a, 0x68, 0xfd, 0x89, 0x56,
2544 0x54, 0xe3, 0x31, 0x8c, 0x75, 0x8c, 0x0d, 0xd6, 0x02, 0x68, 0x37, 0x27,
2545 0xa9, 0xeb, 0xba, 0x4d, 0x5f, 0x38, 0x19, 0xfa, 0xc3, 0x82, 0x1c, 0xf6,
2546 0x06, 0x0b, 0x57, 0x11, 0x33, 0xb4, 0xb6, 0x28, 0xff, 0xd9, 0x0e, 0xbe,
2547 0xf8, 0xfe, 0xed, 0xac, 0xb9, 0x93, 0xa6, 0x7c, 0x7b, 0x3e, 0x6b, 0x3d,
2548 0xa4, 0x7f, 0x0d, 0x67, 0xf2, 0xfd, 0x83, 0x76, 0xf6, 0xc8, 0x94, 0xde,
2549 0x25, 0xdf, 0x3d, 0xca, 0xd8, 0x7b, 0x76, 0xe6, 0x07, 0xd0, 0xbd, 0xfa,
2550 0x4a, 0xbb, 0xd4, 0xeb, 0xa6, 0x5c, 0x19, 0x1d, 0x04, 0x9d, 0x96, 0xd4,
2551 0x1b, 0x49, 0xe4, 0x73, 0x9b, 0x65, 0xb6, 0x5f, 0x19, 0x18, 0xfc, 0xf4,
2552 0xb0, 0xf2, 0xd3, 0xae, 0x8d, 0x67, 0xe3, 0xe7, 0x3d, 0xeb, 0xcf, 0x5c,
2553 0x02, 0xfd, 0xd0, 0xeb, 0xe4, 0x76, 0x25, 0xe7, 0xb2, 0x37, 0x68, 0x95,
2554 0x75, 0xc4, 0x2e, 0x73, 0xd0, 0xba, 0x57, 0xff, 0x2f, 0xff, 0xf3, 0x26,
2555 0x65, 0xf7, 0xaa, 0xaa, 0x61, 0x54, 0xac, 0xc3, 0x7e, 0x4b, 0x2b, 0x2f,
2556 0x83, 0x16, 0xf8, 0xd8, 0xc6, 0xf6, 0x70, 0x9c, 0x51, 0xbc, 0x38, 0xdb,
2557 0xe8, 0x90, 0xef, 0xd4, 0xb7, 0xc8, 0x72, 0x9d, 0xef, 0xdb, 0x65, 0xa9,
2558 0x3e, 0x78, 0xb5, 0x4f, 0xef, 0x97, 0xf3, 0xd7, 0x5c, 0x6f, 0xdd, 0xa3,
2559 0x23, 0x37, 0x98, 0xfc, 0x40, 0x7e, 0x39, 0xda, 0x23, 0x3f, 0xfe, 0x72,
2560 0xf6, 0x99, 0x3f, 0xd5, 0x61, 0x03, 0xa3, 0x9d, 0xb4, 0x6d, 0xf4, 0x39,
2561 0x9f, 0xbd, 0x5a, 0xd0, 0xa9, 0xdb, 0x3f, 0x02, 0x4f, 0xb3, 0x0b, 0x81,
2562 0x1d, 0x10, 0x37, 0xf1, 0x42, 0x37, 0xec, 0xef, 0x01, 0x27, 0xde, 0x35,
2563 0x06, 0x81, 0xeb, 0x7b, 0x8a, 0x17, 0xb7, 0x3b, 0xd9, 0xab, 0x08, 0x49,
2564 0xfe, 0x15, 0x7b, 0x70, 0x78, 0x87, 0xbe, 0x5d, 0xea, 0xe9, 0xeb, 0xad,
2565 0xe7, 0xe0, 0xff, 0x0b, 0xa9, 0xec, 0x91, 0xcb, 0x72, 0x76, 0xe6, 0xa2,
2566 0x4d, 0xfd, 0xa7, 0xdf, 0x78, 0x09, 0xb9, 0xa7, 0x25, 0x0b, 0x0d, 0xfa,
2567 0x4b, 0xe2, 0x62, 0xfe, 0xbf, 0xcb, 0x3a, 0xac, 0x33, 0x4f, 0xc0, 0x3b,
2568 0xcc, 0x1b, 0xbf, 0x4e, 0x39, 0xb7, 0x11, 0x76, 0xb8, 0xa0, 0xff, 0x62,
2569 0x03, 0x8f, 0x06, 0xad, 0xbd, 0x3a, 0xf7, 0xfb, 0x37, 0xec, 0xfb, 0x0e,
2570 0x68, 0x1d, 0x04, 0x2c, 0x62, 0x66, 0xba, 0x75, 0x8f, 0x57, 0xd4, 0x1e,
2571 0xc7, 0x1a, 0xc8, 0xf5, 0x56, 0xf7, 0xc0, 0x5c, 0x43, 0xc7, 0x39, 0x4d,
2572 0x25, 0x97, 0x2b, 0xa3, 0xe4, 0xef, 0x9e, 0x5e, 0xe6, 0x99, 0x46, 0xfe,
2573 0xaf, 0xfd, 0xa8, 0x7e, 0x7c, 0x7e, 0x7e, 0x12, 0xfe, 0xd9, 0xf7, 0x2f,
2574 0xec, 0x1a, 0x04, 0x0d, 0xa8, 0x43, 0xd3, 0xe4, 0xf9, 0xd9, 0x19, 0x17,
2575 0x38, 0x8a, 0x0a, 0xf7, 0x25, 0x59, 0x01, 0xee, 0x09, 0xf2, 0x01, 0xb8,
2576 0xe7, 0x38, 0xaf, 0x64, 0x80, 0xf9, 0x46, 0x06, 0x78, 0x23, 0xfd, 0x4c,
2577 0x42, 0xd7, 0x76, 0x5b, 0xb7, 0x07, 0xba, 0x9e, 0x60, 0x6c, 0x7b, 0x0e,
2578 0xba, 0x57, 0x48, 0x52, 0x7f, 0xda, 0x7b, 0xd7, 0xf4, 0xa7, 0x15, 0x7f,
2579 0xbb, 0x94, 0x16, 0x12, 0xc0, 0x6b, 0xca, 0x5c, 0x8e, 0x78, 0x31, 0xae,
2580 0x53, 0xf7, 0x2b, 0xa1, 0xee, 0x77, 0x86, 0xb8, 0x17, 0xc1, 0x93, 0x6c,
2581 0xa6, 0xae, 0xb3, 0x8e, 0xda, 0xa6, 0x6a, 0x5b, 0x03, 0x36, 0x5d, 0xae,
2582 0xb1, 0x0e, 0xe5, 0xfd, 0xc8, 0xa5, 0x99, 0x69, 0xd4, 0xaa, 0xe5, 0xda,
2583 0x88, 0x56, 0x6e, 0xda, 0x5a, 0xd9, 0xa3, 0xbe, 0xed, 0xb2, 0x2e, 0x28,
2584 0x1e, 0xa7, 0x65, 0xa9, 0xf9, 0x4b, 0xbf, 0xba, 0x6b, 0x13, 0xfa, 0xd0,
2585 0xfd, 0x09, 0xca, 0xf7, 0xb3, 0xa4, 0x0b, 0x41, 0x9c, 0xfc, 0x4e, 0xc9,
2586 0xc9, 0x21, 0x14, 0xbd, 0xc8, 0xad, 0x4e, 0x0d, 0x11, 0x3f, 0xe8, 0x48,
2587 0xa5, 0x64, 0xd9, 0xe3, 0x1e, 0x67, 0x67, 0xc8, 0xcb, 0xf2, 0x71, 0x4b,
2588 0x0e, 0x2b, 0xf9, 0xbd, 0xac, 0x6c, 0xbb, 0xbc, 0x62, 0xc8, 0x74, 0x72,
2589 0xd0, 0x7a, 0x58, 0xb2, 0x57, 0x2f, 0x18, 0xd9, 0x67, 0xa6, 0x60, 0xd7,
2590 0x4b, 0x8b, 0x86, 0xb8, 0xaa, 0xde, 0xa2, 0x8c, 0xb2, 0x0b, 0xb0, 0xfc,
2591 0xf0, 0xec, 0x7b, 0x5b, 0xce, 0xde, 0x2d, 0x2b, 0x4f, 0xff, 0x26, 0x7c,
2592 0xce, 0x01, 0xc8, 0xc2, 0xcc, 0x1c, 0x42, 0x5e, 0xf1, 0xb4, 0x0c, 0x5a,
2593 0x55, 0xe4, 0xc9, 0xe0, 0x3b, 0xda, 0x01, 0x65, 0x03, 0x17, 0x74, 0x8c,
2594 0x07, 0xc8, 0x27, 0x8e, 0xaf, 0x95, 0x0b, 0xca, 0x96, 0xd2, 0xea, 0xdd,
2595 0x0e, 0xe0, 0x08, 0xde, 0x71, 0xfc, 0x19, 0xd9, 0xa1, 0xde, 0xdd, 0xa9,
2596 0xde, 0x55, 0xe9, 0x2b, 0x94, 0xfc, 0xbe, 0x82, 0x3d, 0xc9, 0xe3, 0x68,
2597 0xbe, 0x4b, 0x02, 0x5b, 0x8a, 0xf8, 0x6e, 0xc9, 0xc1, 0x46, 0x4a, 0xbe,
2598 0x84, 0xfa, 0xe7, 0x8e, 0xc6, 0x80, 0x94, 0x20, 0xc7, 0xe9, 0xdc, 0x83,
2599 0xbd, 0x3c, 0x5b, 0x71, 0x25, 0xfb, 0x8c, 0xe8, 0xa4, 0xf5, 0x4e, 0x39,
2600 0xe4, 0x45, 0xf4, 0x74, 0x86, 0xf4, 0x4d, 0x86, 0xe3, 0x44, 0x48, 0x43,
2601 0x2b, 0xbe, 0x4e, 0xe0, 0x42, 0xac, 0xcf, 0x79, 0x21, 0x1e, 0xfa, 0x11,
2602 0xd0, 0x3a, 0x99, 0x96, 0x15, 0x8f, 0x74, 0x6c, 0x91, 0x6a, 0x8a, 0xfd,
2603 0x03, 0xd0, 0x37, 0xe2, 0xd9, 0xc4, 0x7c, 0x66, 0x1d, 0x8f, 0x1f, 0x6c,
2604 0x54, 0xc0, 0x63, 0xf2, 0x97, 0xeb, 0x10, 0x23, 0x3e, 0x47, 0xf9, 0xed,
2605 0x46, 0x2e, 0x6f, 0x07, 0xba, 0x69, 0xad, 0xed, 0x59, 0x3a, 0xde, 0x0d,
2606 0x59, 0x71, 0xdf, 0x0e, 0x99, 0x84, 0xdd, 0x17, 0xeb, 0xdc, 0x7f, 0x12,
2607 0x7a, 0x74, 0x51, 0xed, 0x5f, 0x5a, 0xe9, 0x0f, 0xe1, 0x09, 0xdb, 0xbd,
2608 0x01, 0xb6, 0x5d, 0xf6, 0x2e, 0x58, 0x1f, 0x01, 0xff, 0xbb, 0x80, 0xd7,
2609 0xe5, 0x44, 0x8e, 0xf0, 0xc4, 0x83, 0x75, 0xf5, 0xd4, 0x27, 0xe0, 0x49,
2610 0xaa, 0xba, 0xbe, 0x58, 0x6f, 0x97, 0xe2, 0x42, 0x84, 0x8b, 0x78, 0x3e,
2611 0x40, 0xdd, 0x7b, 0xb7, 0xc2, 0x35, 0xad, 0x70, 0xe1, 0x7d, 0x9d, 0x3e,
2612 0xe7, 0x26, 0xc0, 0xa3, 0x76, 0xb7, 0x41, 0x5b, 0xb2, 0x4b, 0xaa, 0xaa,
2613 0x76, 0xef, 0x50, 0xbe, 0xa6, 0x9a, 0xdc, 0x8c, 0xf7, 0x3e, 0xf6, 0xdc,
2614 0x8d, 0x7c, 0xa6, 0x1b, 0x73, 0x99, 0x0d, 0x73, 0x1b, 0xe9, 0x4f, 0x6c,
2615 0xa0, 0xff, 0xbf, 0x7b, 0x19, 0x52, 0xe6, 0x72, 0xc1, 0xba, 0x12, 0xd6,
2616 0xcd, 0x1e, 0x87, 0x4d, 0x30, 0x4f, 0x4f, 0x31, 0x36, 0x5f, 0xa3, 0x68,
2617 0x99, 0x5d, 0xf9, 0x29, 0xd6, 0xf5, 0x03, 0x36, 0x1a, 0x07, 0x7c, 0x78,
2618 0x0a, 0x78, 0x8e, 0xd7, 0xd5, 0x1d, 0x05, 0x64, 0xf0, 0xbe, 0x3a, 0x7b,
2619 0xb5, 0xfe, 0x69, 0x3c, 0xbb, 0xa6, 0x85, 0x5f, 0xe4, 0x15, 0xe9, 0x25,
2620 0xad, 0xbc, 0x2f, 0x82, 0xbd, 0x39, 0xd0, 0xe3, 0xa4, 0x21, 0xa5, 0x1c,
2621 0xe2, 0xba, 0xc7, 0xbb, 0x57, 0xda, 0xe5, 0x40, 0x50, 0x23, 0xd8, 0x8c,
2622 0xef, 0xa6, 0x3a, 0xfb, 0xa1, 0x15, 0xde, 0xbf, 0x66, 0x78, 0x47, 0x37,
2623 0x8c, 0xda, 0x5b, 0x1e, 0x5a, 0xb1, 0xe5, 0x6b, 0x8d, 0x61, 0x79, 0xb8,
2624 0x91, 0xb5, 0xee, 0x81, 0x0f, 0x28, 0xaf, 0xde, 0xcb, 0x6e, 0x4b, 0xd2,
2625 0x7f, 0x99, 0xc8, 0x3d, 0xdb, 0xec, 0x20, 0x17, 0xa9, 0xb2, 0x36, 0x3b,
2626 0x9e, 0xe5, 0x7d, 0x8d, 0x55, 0x97, 0x8d, 0xf9, 0xca, 0xff, 0x65, 0xae,
2627 0xc2, 0xfd, 0xe9, 0xaf, 0x91, 0x9b, 0x78, 0xc8, 0x4d, 0x3c, 0xe4, 0x26,
2628 0x1e, 0x72, 0x13, 0x0f, 0xb9, 0x89, 0x87, 0xdc, 0xc4, 0x43, 0x6e, 0xe2,
2629 0x21, 0x37, 0x41, 0x1d, 0x10, 0xd4, 0x07, 0xe3, 0xc8, 0xb9, 0xe1, 0xbf,
2630 0xbc, 0x5b, 0xc2, 0xdc, 0x22, 0x8a, 0xcd, 0x9c, 0x3b, 0xbf, 0xc9, 0x0d,
2631 0xea, 0x2b, 0xe5, 0x13, 0x0a, 0xcd, 0x89, 0x30, 0x07, 0xe2, 0x9a, 0x28,
2632 0x76, 0x73, 0x9d, 0x8c, 0xb9, 0xa8, 0x3d, 0x0b, 0x93, 0xcc, 0x91, 0x82,
2633 0x98, 0x15, 0xe4, 0xe7, 0xaf, 0x22, 0x4f, 0xca, 0x20, 0x4f, 0x1a, 0x40,
2634 0x4e, 0xc4, 0x7b, 0xea, 0xe8, 0x2e, 0xa9, 0xa0, 0x1d, 0xf4, 0xc6, 0xb5,
2635 0x2f, 0x79, 0xcc, 0xdf, 0xed, 0x4c, 0x59, 0xd7, 0x8f, 0xf7, 0x89, 0x2f,
2636 0xc5, 0xd1, 0xaf, 0x23, 0x57, 0xfe, 0x4b, 0x75, 0x6f, 0x36, 0x31, 0x44,
2637 0x99, 0xdf, 0xf7, 0x31, 0xf9, 0x72, 0xc4, 0xdf, 0xe0, 0xbe, 0x4f, 0x5f,
2638 0x22, 0xff, 0x44, 0x7a, 0xcf, 0x80, 0xe1, 0x67, 0x12, 0x92, 0x3c, 0xb9,
2639 0x05, 0x73, 0x96, 0xf4, 0xa9, 0x3b, 0x23, 0x88, 0xf2, 0xcc, 0x7f, 0x40,
2640 0x5e, 0xb6, 0xe8, 0x67, 0x78, 0xb3, 0x40, 0xbc, 0xf4, 0xaf, 0xf5, 0x99,
2641 0x62, 0xbd, 0xae, 0x74, 0xea, 0x60, 0xa3, 0x84, 0x3c, 0xca, 0xe8, 0x93,
2642 0x0e, 0x13, 0xb5, 0x54, 0x84, 0x9b, 0x38, 0xdf, 0x4c, 0xaa, 0x1a, 0xe7,
2643 0xcc, 0xaa, 0x3c, 0x21, 0x6b, 0xee, 0x53, 0x9f, 0xa9, 0x2e, 0x64, 0xd3,
2644 0xac, 0x71, 0x0b, 0x56, 0x7d, 0xe6, 0x49, 0xe0, 0x58, 0x46, 0x6e, 0x60,
2645 0xa8, 0xbd, 0xeb, 0x33, 0xb3, 0x0b, 0xc1, 0xbd, 0x55, 0x40, 0x03, 0xe3,
2646 0x55, 0x87, 0x18, 0x4b, 0xc1, 0xfd, 0x95, 0xae, 0x60, 0x09, 0x47, 0x78,
2647 0x13, 0x70, 0x94, 0xdb, 0x30, 0x60, 0x29, 0x3b, 0xd2, 0x50, 0x9f, 0xa9,
2648 0xd4, 0x5b, 0x69, 0x20, 0x1e, 0xe2, 0x8d, 0xce, 0xc3, 0xb3, 0x24, 0x45,
2649 0x3f, 0xe9, 0xfb, 0xe5, 0xd1, 0x81, 0xb0, 0xae, 0x44, 0x1d, 0x79, 0xcc,
2650 0x0c, 0xf4, 0x5c, 0x8d, 0xff, 0x58, 0xc5, 0xa9, 0x8c, 0xce, 0x79, 0x3e,
2651 0xf1, 0x2e, 0xf7, 0x28, 0xe6, 0x30, 0x5e, 0x8e, 0xd6, 0xea, 0xe1, 0xda,
2652 0xae, 0x16, 0x7e, 0xb6, 0x85, 0xfb, 0x91, 0x26, 0x9e, 0xf3, 0x15, 0xec,
2653 0x45, 0xba, 0xb8, 0xc6, 0x04, 0x6d, 0x90, 0xa5, 0xf7, 0xbf, 0xe5, 0x7d,
2654 0xeb, 0x99, 0xc8, 0x53, 0x13, 0x30, 0x5c, 0x4f, 0x1c, 0x11, 0x0c, 0x5e,
2655 0x9c, 0x09, 0xe0, 0xf4, 0xd5, 0x7b, 0xbe, 0x4f, 0xda, 0xb7, 0x95, 0xd6,
2656 0x68, 0xff, 0x08, 0xcf, 0x70, 0x20, 0xb7, 0x55, 0x78, 0xf5, 0x7f, 0x7f,
2657 0xe1, 0x09, 0x5d, 0xfc, 0xd0, 0x7d, 0xe9, 0x70, 0x4b, 0x8d, 0x1c, 0xdd,
2658 0x3b, 0xb0, 0xfe, 0x67, 0x3d, 0xcf, 0xef, 0x03, 0xad, 0xf5, 0x69, 0x29,
2659 0x8c, 0x65, 0xdb, 0xa4, 0x60, 0xb2, 0x56, 0x19, 0x0f, 0xc7, 0x5b, 0x11,
2660 0xdb, 0x38, 0xbe, 0x15, 0xfc, 0x85, 0x2e, 0x3b, 0x1d, 0x61, 0xad, 0x94,
2661 0x0c, 0xbe, 0xeb, 0x0c, 0xd3, 0x8e, 0x58, 0x6b, 0x6e, 0x0e, 0xe7, 0x22,
2662 0x3b, 0xa2, 0x1f, 0x36, 0xc3, 0x39, 0xfa, 0x5b, 0x1d, 0xf5, 0x12, 0xfb,
2663 0xc0, 0xb3, 0xdc, 0x6a, 0x4b, 0xd1, 0x33, 0x29, 0xa7, 0x17, 0x23, 0xbf,
2664 0x05, 0x9f, 0x32, 0x64, 0x86, 0xbe, 0xbf, 0x13, 0xbe, 0xaf, 0x5b, 0xf6,
2665 0xc2, 0x67, 0xed, 0x83, 0xcf, 0xda, 0x8f, 0x1a, 0x75, 0x7c, 0xa5, 0xf5,
2666 0x3e, 0x97, 0x75, 0x71, 0x55, 0x0e, 0x29, 0xf9, 0x57, 0x7c, 0xc3, 0xfe,
2667 0x00, 0x3a, 0xb0, 0x53, 0xe5, 0x7b, 0x81, 0x4e, 0xc0, 0xdf, 0x3a, 0x49,
2668 0xe8, 0xc4, 0xc6, 0x7b, 0xe3, 0x61, 0xd8, 0x46, 0x47, 0x41, 0xc5, 0x86,
2669 0x95, 0x80, 0xf7, 0xd5, 0x7a, 0xc0, 0x7b, 0xf8, 0x65, 0xe0, 0x37, 0xa5,
2670 0xd2, 0xb0, 0xa4, 0x82, 0x7d, 0x2b, 0xd8, 0xb7, 0x82, 0xda, 0x72, 0xb6,
2671 0xd1, 0xfa, 0xed, 0xaa, 0x2b, 0xa4, 0x9d, 0xb0, 0x51, 0xdf, 0x6a, 0x39,
2672 0x7f, 0xf4, 0x3c, 0x02, 0xfe, 0x3f, 0x02, 0xfe, 0x1f, 0x46, 0x4d, 0xf5,
2673 0x00, 0x6a, 0xaa, 0xfb, 0x50, 0x53, 0x1d, 0x42, 0x4d, 0x35, 0x85, 0x9a,
2674 0xea, 0x6e, 0xf8, 0x8f, 0x3b, 0xe1, 0x3f, 0x26, 0xe1, 0x3f, 0x26, 0xd4,
2675 0x9d, 0xd1, 0x41, 0x6f, 0xe3, 0x1d, 0x4a, 0xb4, 0x17, 0xdb, 0x1b, 0x22,
2676 0x50, 0x81, 0xf2, 0xb1, 0x71, 0xa9, 0x37, 0x59, 0x5b, 0x39, 0xea, 0x3e,
2677 0x6c, 0xda, 0x99, 0xd4, 0xa6, 0x90, 0xbf, 0xdf, 0x33, 0xc2, 0x9a, 0x2b,
2678 0xa9, 0x15, 0x55, 0xcd, 0x95, 0x7d, 0xc1, 0x45, 0x8a, 0x84, 0xdc, 0x0f,
2679 0x67, 0xce, 0x9e, 0x2e, 0x1a, 0x51, 0xbd, 0xd3, 0xbb, 0x5a, 0xef, 0x2c,
2680 0xcf, 0xb3, 0xde, 0x79, 0x75, 0xb5, 0xde, 0x59, 0x9e, 0x67, 0xbd, 0xf3,
2681 0xca, 0xba, 0x7a, 0xe7, 0xca, 0xd3, 0x97, 0xd6, 0xd5, 0x3b, 0x57, 0x9e,
2682 0x7e, 0x29, 0x1c, 0x4b, 0xa8, 0x0f, 0x21, 0xad, 0x96, 0x83, 0x67, 0x4f,
2683 0x98, 0x73, 0x34, 0xfb, 0xd6, 0xff, 0xdf, 0x74, 0xca, 0x96, 0x35, 0xb1,
2684 0xff, 0x68, 0x6b, 0x50, 0x23, 0xb5, 0xce, 0x77, 0xb7, 0xcc, 0x5f, 0x56,
2685 0xdf, 0x4b, 0xcb, 0xb5, 0xcd, 0xef, 0xc2, 0x03, 0xcb, 0xca, 0x10, 0xf3,
2686 0xbc, 0x0f, 0x7c, 0x7e, 0xf3, 0x73, 0xf5, 0x0e, 0xf5, 0xcd, 0xcd, 0x55,
2687 0xf9, 0x36, 0xec, 0x7c, 0xf4, 0xd1, 0xad, 0x81, 0x2f, 0x60, 0x3f, 0xa5,
2688 0x05, 0xfe, 0xfd, 0x01, 0xe0, 0x01, 0xaf, 0x3d, 0x53, 0xdd, 0x07, 0x05,
2689 0xe7, 0x0d, 0xee, 0xc6, 0xcd, 0xfc, 0xe5, 0x19, 0xe6, 0xd6, 0x55, 0x85,
2690 0x9b, 0xf5, 0x23, 0x6b, 0xce, 0x28, 0x06, 0x44, 0xb8, 0x5e, 0x4d, 0x05,
2691 0x74, 0xbb, 0xa8, 0x1d, 0xb9, 0x26, 0x1a, 0xb7, 0xd6, 0x9a, 0x9d, 0xe1,
2692 0xbd, 0xdb, 0xe5, 0x20, 0xaf, 0x52, 0xf8, 0xcc, 0x10, 0xdf, 0xcf, 0xfd,
2693 0xc0, 0xf7, 0x10, 0xde, 0x6a, 0x81, 0x1f, 0x47, 0xae, 0xc7, 0x7b, 0x1a,
2694 0xe6, 0x6c, 0xa6, 0xbc, 0x33, 0xdf, 0x25, 0xff, 0x79, 0xd4, 0xf7, 0x27,
2695 0x9c, 0xec, 0xf0, 0x25, 0xd4, 0x1e, 0x27, 0x69, 0x27, 0xa3, 0xa4, 0x73,
2696 0x30, 0x33, 0x2b, 0xa9, 0x3e, 0xd2, 0x72, 0x5e, 0x3f, 0xac, 0x7d, 0x98,
2697 0x6e, 0x3d, 0xdc, 0xe7, 0x1f, 0x5b, 0xf6, 0xc9, 0xb4, 0xec, 0x53, 0xa0,
2698 0xcd, 0xd6, 0xef, 0xc0, 0x99, 0x2b, 0xdb, 0xaf, 0xb7, 0x52, 0x61, 0x5d,
2699 0xf6, 0xf0, 0xe8, 0x66, 0x59, 0xe8, 0xcf, 0x9e, 0x7d, 0x05, 0xf9, 0x7a,
2700 0x79, 0x14, 0x73, 0xa9, 0x41, 0xbc, 0xe3, 0x7c, 0xb6, 0x8e, 0x5c, 0xf4,
2701 0x6c, 0x5d, 0xb6, 0x01, 0x3e, 0x5b, 0x11, 0xe1, 0x3c, 0xfb, 0x8a, 0xb6,
2702 0x7a, 0xe8, 0x03, 0xd2, 0x17, 0x70, 0xe6, 0x29, 0xd4, 0x5f, 0x87, 0x83,
2703 0x7b, 0xb4, 0x70, 0x9f, 0x1b, 0xb5, 0x20, 0x6f, 0xce, 0x69, 0x95, 0xf0,
2704 0x0e, 0xf0, 0x2b, 0xf0, 0x17, 0x86, 0x4e, 0xd8, 0x77, 0x80, 0x5b, 0x93,
2705 0xa5, 0xa3, 0x86, 0xba, 0x3b, 0x2d, 0x8f, 0x52, 0xd6, 0x7c, 0x7e, 0x14,
2706 0xef, 0xa2, 0x33, 0xfd, 0x4d, 0x78, 0xa6, 0xd1, 0xb0, 0x6e, 0x8f, 0xce,
2707 0x94, 0x90, 0xd7, 0xe7, 0x2d, 0xc0, 0x8e, 0x80, 0x1f, 0x25, 0x59, 0x69,
2708 0x66, 0x3e, 0x05, 0x4f, 0xad, 0x85, 0x37, 0xe6, 0x06, 0x19, 0x46, 0x75,
2709 0x0f, 0x78, 0x30, 0x91, 0x86, 0x1d, 0xde, 0xd7, 0x17, 0xdd, 0xe9, 0x1a,
2710 0xb6, 0xae, 0x05, 0x75, 0x3c, 0xe7, 0x07, 0x60, 0x8b, 0x19, 0xd8, 0x27,
2711 0x73, 0xa6, 0x12, 0x6b, 0x15, 0xda, 0x93, 0xe5, 0x1a, 0x59, 0x6b, 0x52,
2712 0x86, 0x51, 0xef, 0xf0, 0xfc, 0x79, 0x59, 0x6e, 0x46, 0x34, 0xe4, 0x60,
2713 0x8f, 0x63, 0xf8, 0x8d, 0xe0, 0x9d, 0x83, 0x1f, 0x6b, 0xa5, 0x82, 0x7c,
2714 0x55, 0xe5, 0xe2, 0xc8, 0xb5, 0x87, 0x48, 0xdf, 0x01, 0xac, 0xa7, 0x3e,
2715 0x53, 0x4f, 0x0f, 0x88, 0xdb, 0x4f, 0x5f, 0x91, 0x06, 0x6e, 0xc0, 0x78,
2716 0xaf, 0xc1, 0xd6, 0x07, 0xf0, 0xcc, 0x5a, 0x65, 0xf2, 0x56, 0xe1, 0xf7,
2717 0x7d, 0x23, 0xc7, 0x6f, 0x11, 0xe3, 0xe1, 0x78, 0xd0, 0xfa, 0x1d, 0xea,
2718 0x5e, 0xfa, 0x5a, 0x39, 0xbb, 0x18, 0xc5, 0xc1, 0x19, 0xd8, 0x20, 0xef,
2719 0x68, 0xc7, 0xc1, 0x17, 0x8e, 0xb5, 0x30, 0x1e, 0x62, 0x7e, 0xf9, 0xaf,
2720 0x70, 0xee, 0xbc, 0x9c, 0x44, 0xfd, 0x2f, 0xfd, 0x7c, 0x66, 0x80, 0x7f,
2721 0x4b, 0xa8, 0xef, 0xeb, 0xe1, 0x0d, 0x9b, 0xfd, 0x71, 0xd0, 0x67, 0xb6,
2722 0xc0, 0x13, 0x26, 0xac, 0x4f, 0x04, 0xf1, 0x38, 0xed, 0xdf, 0xaa, 0xe7,
2723 0xef, 0x96, 0x3f, 0x50, 0x67, 0xca, 0xcb, 0xa1, 0x45, 0xdf, 0x77, 0x73,
2724 0x83, 0xc3, 0xcb, 0x92, 0x1d, 0x7e, 0x52, 0x76, 0x5b, 0x7b, 0x59, 0x8f,
2725 0x59, 0xc4, 0xe3, 0xdf, 0xda, 0x96, 0xf7, 0xfd, 0x13, 0xa0, 0xfd, 0x07,
2726 0x6a, 0x9f, 0xbb, 0x41, 0x3f, 0x78, 0xa5, 0x6a, 0x12, 0xd2, 0x0a, 0xde,
2727 0xa4, 0x48, 0x6f, 0xa7, 0x1c, 0x6a, 0x3e, 0x1f, 0xca, 0xe6, 0x11, 0x71,
2728 0xbd, 0xb7, 0x0d, 0xde, 0x6f, 0x97, 0x9b, 0x8f, 0x86, 0xb4, 0xe5, 0x41,
2729 0x2f, 0xf6, 0x6f, 0xfe, 0x43, 0x8a, 0xbe, 0x81, 0x32, 0x77, 0x91, 0x35,
2730 0xba, 0xa3, 0xcf, 0x40, 0x07, 0x3f, 0xce, 0x0f, 0x24, 0x65, 0xbd, 0x1f,
2731 0x20, 0x5c, 0xf2, 0x23, 0x74, 0x85, 0x74, 0x88, 0xf2, 0x9f, 0x2a, 0x6e,
2732 0x29, 0x7c, 0xc6, 0x06, 0x5f, 0xf0, 0xa4, 0x7a, 0x9e, 0x37, 0xe8, 0x9b,
2733 0x18, 0xff, 0xa8, 0xc3, 0xdd, 0xf0, 0x7f, 0xd0, 0x41, 0xd8, 0x71, 0x71,
2734 0x91, 0xf7, 0x13, 0x43, 0xea, 0x4e, 0xab, 0x04, 0xd9, 0x2e, 0xf1, 0x3b,
2735 0x63, 0x2a, 0xc8, 0x27, 0x83, 0xfa, 0x2b, 0x43, 0x5f, 0x88, 0xf6, 0xb8,
2736 0xf2, 0x93, 0x25, 0xf5, 0x5d, 0x31, 0x89, 0x35, 0x3e, 0x9e, 0xad, 0x7f,
2737 0x27, 0xf1, 0xa3, 0x42, 0xf0, 0x77, 0x12, 0xe1, 0x37, 0xde, 0x7a, 0x90,
2738 0x47, 0x3c, 0xd8, 0x30, 0x65, 0xaa, 0x11, 0xfd, 0xdd, 0x04, 0xe5, 0x60,
2739 0x4b, 0xb9, 0x11, 0xe5, 0x0e, 0x7e, 0x50, 0xd3, 0xac, 0x93, 0xe5, 0xe3,
2740 0x61, 0x4e, 0xc4, 0x1a, 0x80, 0x3c, 0xc4, 0x78, 0x39, 0x90, 0xdf, 0x92,
2741 0xbe, 0x03, 0xf2, 0x03, 0xcf, 0x3d, 0x13, 0xb6, 0x94, 0x0e, 0xe3, 0xba,
2742 0xc5, 0x1a, 0x33, 0xac, 0x7b, 0xb7, 0x4b, 0x75, 0x92, 0xef, 0x13, 0xf2,
2743 0xda, 0xfc, 0x40, 0x70, 0x4f, 0x24, 0x89, 0xf0, 0x3d, 0xc7, 0x49, 0x29,
2744 0xab, 0xf7, 0x77, 0x86, 0xf8, 0x50, 0xa7, 0xdd, 0x19, 0x8d, 0xd3, 0x90,
2745 0x63, 0x00, 0x37, 0x8d, 0x58, 0xf6, 0x55, 0xc4, 0xb1, 0x69, 0xf0, 0xbd,
2746 0x38, 0x51, 0x91, 0x6b, 0x6d, 0x4b, 0xc5, 0x7d, 0x37, 0x49, 0x1d, 0xa3,
2747 0x7e, 0x11, 0xa6, 0x07, 0xb9, 0x2a, 0xce, 0x3b, 0x2a, 0x53, 0x46, 0xfe,
2748 0xdd, 0xdb, 0xca, 0xb5, 0xac, 0x55, 0x90, 0xf7, 0x7d, 0xd7, 0xe4, 0xf8,
2749 0xfc, 0x6d, 0x0f, 0x06, 0x77, 0xfe, 0xba, 0x9e, 0xbf, 0x78, 0x5b, 0x39,
2750 0xe8, 0xe3, 0xcc, 0xef, 0x86, 0x7d, 0xc2, 0x19, 0xea, 0x7b, 0xec, 0x4f,
2751 0x6e, 0x32, 0xe5, 0xc2, 0x4d, 0xbe, 0x7f, 0x0f, 0xbf, 0x09, 0x85, 0x75,
2752 0xac, 0xa5, 0xea, 0xd8, 0x0e, 0x95, 0x8f, 0xb8, 0xa3, 0x19, 0xad, 0x04,
2753 0xdb, 0x3d, 0xe9, 0xa1, 0xe6, 0xd1, 0xb3, 0x63, 0xe7, 0x75, 0x0b, 0xf1,
2754 0x37, 0x9b, 0x39, 0x2e, 0xb9, 0x3e, 0x7e, 0x63, 0x9e, 0x73, 0xb8, 0x66,
2755 0x5b, 0x70, 0xef, 0x75, 0x83, 0xab, 0x7c, 0xae, 0x48, 0x18, 0x87, 0x6e,
2756 0x68, 0xb5, 0x8f, 0xd6, 0x3c, 0x93, 0x76, 0x21, 0x53, 0x26, 0xe8, 0xa9,
2757 0xd6, 0xa2, 0x9c, 0x8d, 0x7f, 0x0f, 0x70, 0xfe, 0xb6, 0xa7, 0x1a, 0x17,
2758 0x6f, 0x9b, 0x85, 0x7c, 0x78, 0xa6, 0xd9, 0x46, 0xa4, 0x7f, 0x51, 0xdd,
2759 0xc0, 0x3e, 0xe2, 0xbf, 0x87, 0xf8, 0xef, 0x21, 0xfe, 0x7b, 0x88, 0xff,
2760 0x1e, 0xe2, 0xbf, 0x87, 0xf8, 0x0f, 0x1e, 0x3e, 0x07, 0x7d, 0x79, 0xd6,
2761 0x9b, 0x08, 0x73, 0xb6, 0xc7, 0x56, 0x73, 0x36, 0xfe, 0xcd, 0xcb, 0xb9,
2762 0xa6, 0xa2, 0xa5, 0x52, 0x91, 0x20, 0xe7, 0x15, 0x9d, 0xf9, 0x4d, 0x94,
2763 0xf3, 0x7e, 0xf4, 0xf7, 0x90, 0x00, 0x8e, 0xf9, 0x1e, 0xe1, 0x2a, 0x9a,
2764 0x6e, 0x13, 0x2e, 0xc8, 0xf9, 0x58, 0x67, 0xad, 0x87, 0xe1, 0x77, 0x37,
2765 0xfa, 0xb6, 0xe0, 0x9b, 0x4f, 0xf0, 0x7d, 0xa9, 0x76, 0x87, 0x8b, 0x58,
2766 0x5c, 0x6e, 0xa8, 0x78, 0x8c, 0x71, 0xe3, 0x0e, 0xfe, 0xad, 0x02, 0x64,
2767 0xc0, 0x77, 0x5f, 0x66, 0x6d, 0x51, 0x6e, 0x20, 0x2f, 0x5a, 0x8e, 0x72,
2768 0x21, 0xc0, 0x79, 0x6f, 0x6a, 0xa5, 0x05, 0xca, 0x59, 0x97, 0xd9, 0x14,
2769 0x98, 0x62, 0xb7, 0xe6, 0x78, 0x97, 0x54, 0xbd, 0x74, 0xb6, 0x49, 0x7a,
2770 0x46, 0x40, 0x5b, 0x74, 0x8f, 0x2c, 0x62, 0xcc, 0xa7, 0x44, 0x9f, 0x47,
2771 0x7e, 0x6b, 0x0f, 0xa9, 0xbf, 0x6f, 0xe8, 0xc5, 0x3e, 0xfa, 0xfc, 0x8e,
2772 0x96, 0x7b, 0x5a, 0x29, 0x04, 0x3e, 0x9b, 0xb1, 0x87, 0xe7, 0x48, 0xc1,
2773 0x76, 0xdd, 0x6d, 0x38, 0x1b, 0xe4, 0xfa, 0xaf, 0x5b, 0x55, 0x0e, 0x0e,
2774 0x3f, 0x7a, 0x62, 0xa8, 0xbf, 0x5f, 0xba, 0xb7, 0xcb, 0xc9, 0x21, 0xd6,
2775 0x6b, 0x9b, 0x81, 0x8f, 0x6b, 0x79, 0xff, 0xb4, 0x5d, 0x4e, 0x2d, 0xc2,
2776 0xcf, 0x2e, 0x66, 0x1d, 0xea, 0xf2, 0xd2, 0x50, 0x0a, 0xfe, 0xf9, 0xe6,
2777 0x7e, 0xc6, 0xe7, 0xe5, 0x26, 0x75, 0xa5, 0x17, 0xf0, 0x03, 0xd0, 0xcb,
2778 0x4d, 0xb0, 0x27, 0x1d, 0xfb, 0x47, 0xb8, 0xff, 0x45, 0xe1, 0xee, 0xb5,
2779 0x9d, 0x6d, 0x4a, 0x37, 0xf4, 0xac, 0x95, 0xd1, 0x41, 0xfb, 0xff, 0x14,
2780 0x6e, 0x6d, 0x31, 0x71, 0x5c, 0x67, 0xf8, 0x3f, 0xb3, 0xdc, 0x8c, 0xd7,
2781 0x30, 0x86, 0xf5, 0xb2, 0x58, 0xae, 0xba, 0x03, 0x63, 0x33, 0xd1, 0x62,
2782 0x65, 0xb0, 0xec, 0x16, 0x55, 0x96, 0xba, 0xda, 0x05, 0x42, 0xe2, 0x3a,
2783 0xdd, 0x24, 0xb4, 0x72, 0xd5, 0x2a, 0x42, 0x60, 0x37, 0x8e, 0xfa, 0xd2,
2784 0x46, 0x55, 0xdb, 0x37, 0xaf, 0x16, 0xec, 0x38, 0xcd, 0xac, 0x17, 0x37,
2785 0x38, 0xf4, 0x71, 0xb3, 0x2c, 0x0e, 0x90, 0x75, 0x56, 0x6e, 0xf2, 0x90,
2786 0x3e, 0x19, 0x6d, 0xa2, 0x24, 0x55, 0xa5, 0xbc, 0x54, 0x7d, 0xab, 0x5a,
2787 0x0b, 0x27, 0xc4, 0x0f, 0xa9, 0xad, 0xf6, 0xa5, 0x77, 0x4d, 0xbf, 0xef,
2788 0xcc, 0x2c, 0xc6, 0xa4, 0x51, 0x91, 0x56, 0x73, 0xe6, 0xcc, 0xb9, 0x9f,
2789 0xff, 0xf2, 0xfd, 0x17, 0x3e, 0x67, 0x67, 0xba, 0xc2, 0xbd, 0xcd, 0x95,
2790 0x76, 0xc6, 0xfe, 0xb6, 0xd4, 0xcc, 0x02, 0xf3, 0x1a, 0x86, 0x64, 0xdc,
2791 0x64, 0xae, 0xcf, 0x96, 0x3a, 0x57, 0x66, 0x1b, 0x1b, 0x65, 0xda, 0xe4,
2792 0x4b, 0x6a, 0xa6, 0xdc, 0x23, 0x17, 0x41, 0xc7, 0x85, 0xe1, 0xd6, 0xd0,
2793 0xf7, 0xda, 0x19, 0xf2, 0x73, 0x77, 0x3c, 0xd4, 0x57, 0x1a, 0x57, 0x16,
2794 0x34, 0xb6, 0xee, 0xde, 0xf5, 0xed, 0x49, 0xac, 0x29, 0x41, 0x5f, 0x79,
2795 0x5c, 0xcb, 0x26, 0x83, 0xef, 0x7d, 0xbb, 0xde, 0xe3, 0xbb, 0xde, 0x0f,
2796 0xfc, 0x8f, 0xf6, 0x2c, 0xef, 0xa6, 0x07, 0xae, 0xd3, 0x1a, 0xe5, 0x2c,
2797 0x05, 0xcf, 0x36, 0x66, 0x3d, 0x2b, 0x4d, 0x5c, 0x90, 0x15, 0x5f, 0x65,
2798 0xdd, 0x36, 0xc8, 0xbb, 0x36, 0x99, 0x5f, 0x04, 0xcd, 0x63, 0x1f, 0xed,
2799 0x36, 0x63, 0xe4, 0x43, 0x71, 0xf2, 0x4c, 0x07, 0xae, 0xc1, 0xb0, 0x07,
2800 0x13, 0x68, 0xe7, 0x3f, 0xef, 0xa6, 0xcc, 0xb3, 0xda, 0x97, 0x43, 0x3c,
2801 0xe3, 0xab, 0x82, 0xce, 0xf7, 0x60, 0x9b, 0x16, 0xb9, 0x63, 0x67, 0x7a,
2802 0xc2, 0x7c, 0x20, 0xd8, 0xbe, 0x5f, 0x8d, 0x13, 0x6b, 0x3c, 0xe7, 0x6e,
2803 0xd7, 0x99, 0x9b, 0xc2, 0x1c, 0x2b, 0x10, 0xcd, 0x53, 0x22, 0xe5, 0xaa,
2804 0xc8, 0xeb, 0xf8, 0xfd, 0xa6, 0x1a, 0xc6, 0x4f, 0x14, 0xed, 0xee, 0x93,
2805 0xb2, 0x5e, 0xfa, 0x9a, 0xd4, 0xa0, 0x7f, 0xd6, 0x5c, 0xdf, 0xbf, 0xeb,
2806 0x26, 0xf5, 0x99, 0xbf, 0xe8, 0x29, 0x19, 0x18, 0xa1, 0x7e, 0x6b, 0x93,
2807 0x97, 0x17, 0x5b, 0x64, 0xc3, 0xb4, 0xcc, 0xbb, 0x44, 0x01, 0x5e, 0x42,
2808 0x26, 0x63, 0x11, 0x8d, 0x51, 0xe5, 0x5b, 0x22, 0x5b, 0xf8, 0xb6, 0xb5,
2809 0xf8, 0x4c, 0x9c, 0xfe, 0x97, 0x4f, 0x16, 0xf9, 0x6e, 0xe0, 0x69, 0x48,
2810 0xc3, 0x8e, 0x00, 0xcb, 0x42, 0x08, 0x99, 0x3c, 0x77, 0xee, 0xf7, 0xbb,
2811 0x5c, 0x1b, 0xea, 0x68, 0xcf, 0xb6, 0x49, 0xe1, 0x30, 0x64, 0xa2, 0x1a,
2812 0xd4, 0x39, 0x47, 0x8d, 0x98, 0x96, 0xd1, 0x91, 0x0a, 0x7d, 0xf8, 0xe6,
2813 0x5e, 0x2d, 0xaf, 0x33, 0x37, 0x7e, 0xa4, 0xf7, 0x82, 0x72, 0xbe, 0xe2,
2814 0x92, 0x56, 0x4d, 0x59, 0x03, 0xaf, 0xad, 0xd6, 0x5f, 0xed, 0xe3, 0x5d,
2815 0xad, 0xd7, 0x5f, 0x88, 0x07, 0xf6, 0x1a, 0xeb, 0x7e, 0x1c, 0x0f, 0xea,
2816 0x92, 0xa1, 0xfd, 0x45, 0x3b, 0xad, 0x8c, 0xbd, 0xbd, 0x20, 0xf5, 0xa5,
2817 0x9f, 0xc9, 0x3b, 0xa5, 0x9f, 0xc8, 0xaf, 0x97, 0xce, 0x00, 0x7f, 0x58,
2818 0xe5, 0x3c, 0xf4, 0xc9, 0xcd, 0xba, 0xef, 0xdf, 0x74, 0xa7, 0x60, 0x2b,
2819 0xf8, 0xfe, 0xef, 0xdc, 0x0d, 0x19, 0x38, 0xf6, 0x3d, 0xec, 0x39, 0x07,
2820 0x1e, 0xa2, 0x2c, 0x9c, 0x04, 0xbd, 0xb9, 0x7d, 0xd2, 0x19, 0xd5, 0x74,
2821 0x32, 0x78, 0xac, 0x15, 0x7b, 0x30, 0x42, 0x4c, 0xce, 0xbd, 0x8c, 0xf4,
2822 0x91, 0x66, 0x8c, 0x7a, 0x09, 0xf3, 0xb7, 0x82, 0x2f, 0xf6, 0xe2, 0xa7,
2823 0xe4, 0xee, 0x08, 0xd6, 0x3a, 0x42, 0xda, 0x6b, 0x95, 0x81, 0x47, 0xb1,
2824 0x8f, 0x5c, 0x8b, 0xdc, 0xf3, 0x7e, 0x19, 0xa7, 0x6f, 0xef, 0x9e, 0xc7,
2825 0xb2, 0xf1, 0x95, 0x2e, 0xf1, 0xa5, 0x05, 0xba, 0x7c, 0xfe, 0x78, 0x80,
2826 0x9b, 0xde, 0x55, 0x43, 0x68, 0x6f, 0xe7, 0xdf, 0x53, 0xc4, 0x79, 0x79,
2827 0xbf, 0x15, 0xb8, 0x7c, 0x1c, 0x78, 0x28, 0x53, 0xbf, 0x20, 0x8d, 0x91,
2828 0x28, 0xda, 0x10, 0xaf, 0x68, 0x59, 0x22, 0x59, 0x8f, 0x39, 0x5a, 0xcc,
2829 0x97, 0xc2, 0x1a, 0xa7, 0x74, 0x2e, 0x57, 0x1f, 0xcf, 0x9c, 0x58, 0x3e,
2830 0xa8, 0xb3, 0x41, 0x23, 0xac, 0x23, 0x7d, 0xa7, 0x35, 0xa6, 0x82, 0x0e,
2831 0xc5, 0x78, 0xc3, 0x92, 0xd1, 0xe5, 0x2e, 0x8c, 0x77, 0x41, 0x32, 0x6e,
2832 0x73, 0xcc, 0x51, 0xb4, 0xa1, 0x9c, 0x19, 0x05, 0x96, 0xf8, 0x58, 0x8d,
2833 0x2d, 0xc6, 0xa0, 0xcb, 0xe3, 0x32, 0x66, 0xee, 0xd9, 0xb1, 0xc7, 0xbc,
2834 0xb6, 0x15, 0x0c, 0x63, 0x38, 0x5c, 0x53, 0xd7, 0x8e, 0x35, 0xb1, 0x3f,
2835 0x7e, 0xb0, 0x93, 0x33, 0x8b, 0x0b, 0x90, 0x53, 0x0b, 0x1f, 0x66, 0xdc,
2836 0x67, 0x25, 0x1b, 0x6b, 0xd3, 0xb6, 0x4d, 0x05, 0xf7, 0x92, 0xf5, 0xe8,
2837 0xd3, 0xfa, 0x0e, 0xe4, 0xd0, 0x9e, 0xb0, 0x8e, 0x6d, 0xc5, 0xc8, 0xe0,
2838 0xec, 0x03, 0x1b, 0x97, 0x75, 0x5f, 0x96, 0xcc, 0x42, 0x4e, 0x26, 0x74,
2839 0x3f, 0x9e, 0xe1, 0x41, 0x8d, 0x43, 0xc8, 0xab, 0x03, 0xbd, 0x38, 0xcb,
2840 0xd4, 0x03, 0x7b, 0x38, 0xd9, 0x4b, 0x2e, 0xfa, 0x4f, 0xc8, 0xb3, 0xf8,
2841 0xd6, 0xcb, 0x3b, 0x6a, 0x93, 0x81, 0x67, 0xa0, 0x2f, 0xbd, 0x66, 0x7d,
2842 0x54, 0x3e, 0xf3, 0xfc, 0x38, 0x63, 0x2e, 0x7f, 0xf6, 0x4c, 0xf9, 0xc4,
2843 0xd3, 0xb1, 0xd8, 0xe9, 0x88, 0x58, 0xe7, 0x03, 0x5b, 0xfd, 0xf0, 0xf4,
2844 0xbc, 0xe2, 0xf7, 0xc3, 0xe7, 0x57, 0x54, 0x07, 0xda, 0x46, 0xd1, 0x8e,
2845 0xeb, 0x30, 0x65, 0xdc, 0xfb, 0xab, 0x3f, 0x73, 0xc4, 0xf7, 0x27, 0x74,
2846 0x4e, 0x58, 0xca, 0x9c, 0x57, 0x4d, 0x7c, 0xee, 0x88, 0x17, 0x6b, 0xc7,
2847 0x5c, 0x29, 0x73, 0x45, 0x1d, 0xc6, 0x7a, 0x58, 0xee, 0x25, 0x4f, 0x24,
2848 0x36, 0x84, 0xe3, 0x5b, 0x93, 0xcb, 0x2a, 0x95, 0x1c, 0x54, 0x56, 0xba,
2849 0x80, 0x5f, 0x8b, 0xd2, 0x71, 0xcc, 0x44, 0x52, 0x81, 0x77, 0xb1, 0x27,
2850 0xfb, 0xa8, 0xef, 0x4f, 0xda, 0xac, 0x4f, 0x99, 0x51, 0x45, 0xdf, 0x4b,
2851 0xa7, 0x8e, 0x77, 0x5e, 0x3e, 0x90, 0x32, 0x8f, 0xaa, 0xfd, 0xe1, 0xfb,
2852 0x28, 0x64, 0xe6, 0xf6, 0x78, 0x67, 0x96, 0x95, 0x29, 0x2f, 0x79, 0xa9,
2853 0xe4, 0xac, 0xb2, 0x72, 0x18, 0x33, 0x37, 0xa6, 0x28, 0x37, 0x52, 0x66,
2854 0xa7, 0xa2, 0x7f, 0xb4, 0x5d, 0xef, 0x7b, 0x12, 0xfd, 0x53, 0xaa, 0x25,
2855 0x5c, 0x0f, 0xef, 0xeb, 0x4a, 0x5f, 0xc0, 0x33, 0x94, 0x39, 0xfd, 0xc6,
2856 0xcc, 0x02, 0xf3, 0xcb, 0x74, 0x5e, 0x43, 0x7a, 0xe0, 0x18, 0xdf, 0x0d,
2857 0xb9, 0x7f, 0xe2, 0x6f, 0xa8, 0x43, 0xb9, 0xcc, 0x3a, 0x27, 0xe4, 0xb7,
2858 0x23, 0x1a, 0x3f, 0xdf, 0x3f, 0x91, 0xd7, 0xb9, 0x8b, 0x0d, 0x35, 0x10,
2859 0xee, 0x7b, 0xfb, 0xce, 0x92, 0x19, 0xf7, 0x4b, 0x1c, 0x67, 0x21, 0x72,
2860 0xb2, 0x5d, 0x98, 0x23, 0x3a, 0x5e, 0x6a, 0xd2, 0x06, 0x7d, 0x03, 0xcc,
2861 0x15, 0x68, 0xc6, 0xdd, 0x2f, 0x88, 0x71, 0xac, 0x63, 0x07, 0x9d, 0x00,
2862 0x77, 0x02, 0xaf, 0x56, 0x31, 0x4e, 0x61, 0x51, 0xf2, 0x41, 0x7f, 0xe9,
2863 0x60, 0x4e, 0x6a, 0xa1, 0xfa, 0x45, 0x63, 0x04, 0x3a, 0x70, 0x1c, 0xef,
2864 0xf7, 0x4f, 0x90, 0x3e, 0x79, 0x36, 0x49, 0x35, 0xbe, 0xc4, 0xf5, 0x1c,
2865 0x94, 0x89, 0x45, 0x60, 0x23, 0xfc, 0xe6, 0x17, 0x83, 0x7b, 0xbb, 0x0e,
2866 0x9c, 0x3d, 0xe1, 0x99, 0x9a, 0x5f, 0x67, 0x5d, 0xc6, 0x4f, 0xc0, 0x2b,
2867 0x3a, 0x8f, 0x8a, 0x7d, 0x99, 0x4b, 0x78, 0x88, 0xfa, 0xd1, 0x6d, 0x48,
2868 0x0c, 0x6d, 0x89, 0x59, 0x59, 0x6f, 0x8d, 0x26, 0x23, 0xdd, 0x32, 0x0f,
2869 0x79, 0x57, 0x81, 0xee, 0x2c, 0x5c, 0x89, 0xca, 0xac, 0xa7, 0xe3, 0xd9,
2870 0xc9, 0x8f, 0x95, 0x2b, 0xb5, 0xfa, 0x71, 0xb9, 0x51, 0x77, 0xf4, 0x37,
2871 0xea, 0xb5, 0xc2, 0xab, 0x86, 0x7c, 0xff, 0x88, 0xce, 0xa5, 0x73, 0x2a,
2872 0xd2, 0xd9, 0x4f, 0xcc, 0xb3, 0xa2, 0xf3, 0xea, 0x20, 0x3b, 0x80, 0x39,
2873 0xde, 0x06, 0xe6, 0x78, 0x0b, 0x98, 0xe3, 0x57, 0xc0, 0xd8, 0x37, 0x4b,
2874 0x93, 0xa1, 0xfc, 0x9f, 0x86, 0x1c, 0xa2, 0xae, 0xb6, 0xce, 0xe0, 0x4e,
2875 0xa7, 0xf3, 0xa0, 0xc1, 0xdb, 0xb0, 0x3f, 0xd6, 0x4b, 0x19, 0x59, 0x5d,
2876 0x9a, 0x90, 0xb5, 0xa5, 0x20, 0x0f, 0xf9, 0x03, 0xe6, 0x7d, 0x8d, 0xf0,
2877 0x9e, 0x1c, 0xc8, 0xa1, 0x3d, 0x32, 0x70, 0x94, 0xf2, 0xa3, 0x43, 0x96,
2878 0x8b, 0xab, 0x5a, 0x0e, 0x2d, 0x17, 0x59, 0x8e, 0x88, 0xce, 0x21, 0x9b,
2879 0xda, 0x90, 0x8a, 0x5b, 0x47, 0xfd, 0x3e, 0xed, 0x0f, 0x0a, 0xfc, 0xf3,
2880 0x94, 0x97, 0x7f, 0x0a, 0xef, 0x5e, 0xe9, 0xdc, 0xba, 0x19, 0xb3, 0x1b,
2881 0xed, 0x9a, 0xb2, 0x6b, 0x30, 0x88, 0xb9, 0xab, 0xdb, 0x68, 0x83, 0x39,
2882 0x80, 0x19, 0xaf, 0x43, 0x87, 0x34, 0x9c, 0x6e, 0x8d, 0xfd, 0x1a, 0xce,
2883 0x21, 0x9d, 0x77, 0xcb, 0x71, 0x0a, 0x45, 0x5b, 0xe6, 0x8a, 0x56, 0x32,
2884 0x0f, 0xfa, 0xbb, 0x01, 0xbb, 0x6d, 0x15, 0x77, 0xb0, 0x86, 0x33, 0x58,
2885 0xaf, 0x53, 0xcf, 0x6f, 0x6a, 0xd9, 0xbb, 0x5c, 0xff, 0x23, 0xc6, 0xb1,
2886 0xce, 0xa4, 0xe5, 0x0f, 0x7d, 0x94, 0x81, 0xf4, 0x4d, 0x65, 0x75, 0xff,
2887 0xa0, 0xdf, 0x2a, 0xda, 0xae, 0xd5, 0x29, 0x8f, 0x45, 0x2e, 0x79, 0x36,
2888 0x74, 0xc9, 0xcb, 0x09, 0x62, 0x80, 0xb2, 0x6a, 0xf6, 0xf3, 0xc3, 0x35,
2889 0xfb, 0xfe, 0x5e, 0x9b, 0xeb, 0x72, 0x42, 0xb9, 0x4d, 0xdd, 0xbf, 0xa1,
2890 0xb1, 0x8d, 0x57, 0x7a, 0x56, 0xde, 0xc4, 0x7d, 0x07, 0x18, 0x27, 0x27,
2891 0x6f, 0x00, 0xe3, 0xd5, 0x4b, 0xcd, 0xbc, 0xed, 0x93, 0x38, 0xa7, 0x92,
2892 0x9a, 0xbb, 0xda, 0x29, 0x97, 0xaf, 0x15, 0xd4, 0x4b, 0xd7, 0x3c, 0xf5,
2893 0xf3, 0xab, 0x45, 0x55, 0xb8, 0xea, 0xfb, 0xff, 0x70, 0x67, 0xe4, 0x9d,
2894 0x25, 0x5f, 0x4e, 0xbb, 0x46, 0x7f, 0x44, 0x9a, 0xf9, 0x74, 0xbe, 0xdf,
2895 0x01, 0xd9, 0xbc, 0x7e, 0xc0, 0xf7, 0x1f, 0x19, 0x19, 0x11, 0xe7, 0x00,
2896 0x31, 0xca, 0x70, 0x82, 0x39, 0xae, 0x94, 0x39, 0x19, 0xdb, 0x3e, 0x5f,
2897 0x51, 0x0a, 0xf2, 0xad, 0x3b, 0xc0, 0x2f, 0x8f, 0xee, 0x0b, 0xe3, 0x26,
2898 0x3f, 0x7c, 0x9e, 0x7e, 0xe5, 0xc4, 0xe7, 0xfc, 0xca, 0xa6, 0x9c, 0x2d,
2899 0xf6, 0xa2, 0x7f, 0x4c, 0x7e, 0x50, 0x8c, 0xee, 0x2a, 0x9b, 0x78, 0x3a,
2900 0x46, 0xa1, 0x78, 0xcf, 0x1f, 0xd4, 0xf1, 0x03, 0x60, 0x12, 0xd3, 0xf7,
2901 0x67, 0x5d, 0xce, 0xd7, 0x8d, 0xf9, 0x36, 0xcc, 0x7d, 0xd0, 0xff, 0xa7,
2902 0xb5, 0x7e, 0x2e, 0x2b, 0xd8, 0xc1, 0xe0, 0xef, 0x98, 0x8c, 0x15, 0xa1,
2903 0xe3, 0x15, 0xf3, 0x4c, 0x89, 0x15, 0xac, 0xc4, 0x2c, 0x64, 0xc7, 0x0c,
2904 0xe4, 0xcd, 0x29, 0x1d, 0x67, 0xed, 0xd5, 0xb2, 0x67, 0x8e, 0xe5, 0x9c,
2905 0xa4, 0x2b, 0x6e, 0x8f, 0x3e, 0xbf, 0xcd, 0x1b, 0x2f, 0x26, 0x82, 0x3b,
2906 0x07, 0x1f, 0xe7, 0x94, 0xb4, 0xc1, 0x1e, 0xca, 0xae, 0x4c, 0x81, 0x27,
2907 0x12, 0x38, 0xdb, 0x56, 0xcd, 0x0f, 0x0d, 0xe8, 0xef, 0x86, 0xf6, 0x29,
2908 0x06, 0xb1, 0x8b, 0x86, 0xc9, 0x76, 0xa7, 0xd0, 0xaf, 0x5d, 0x32, 0x57,
2909 0xdb, 0xb4, 0x5c, 0x7d, 0xb8, 0x2e, 0x0d, 0x1c, 0xf2, 0x04, 0xca, 0x11,
2910 0xd4, 0x25, 0xc3, 0xb2, 0x81, 0xf2, 0x34, 0xca, 0x2d, 0x78, 0xb2, 0xcd,
2911 0x61, 0xe0, 0x0a, 0x3c, 0x5f, 0xc3, 0x78, 0x23, 0x58, 0x73, 0xce, 0x94,
2912 0x8f, 0x4e, 0x50, 0x97, 0x38, 0x06, 0x73, 0x91, 0x67, 0x6d, 0x3c, 0x6b,
2913 0x45, 0x95, 0x5d, 0x60, 0x19, 0xcf, 0x72, 0xf0, 0xfd, 0x21, 0x99, 0x84,
2914 0x3e, 0x99, 0x6b, 0x81, 0x4c, 0xfa, 0x68, 0x5b, 0x26, 0xb1, 0xae, 0x5d,
2915 0xc6, 0xae, 0x92, 0xd7, 0x4d, 0xd0, 0x5b, 0xa7, 0x64, 0xaf, 0xc5, 0x34,
2916 0x1e, 0xad, 0x80, 0x16, 0xaf, 0x83, 0xae, 0x96, 0x41, 0x53, 0x99, 0xa2,
2917 0x35, 0x3a, 0xad, 0x92, 0xda, 0x2f, 0xf0, 0x38, 0xe8, 0xb5, 0xe3, 0x0a,
2918 0xb1, 0x28, 0x79, 0xd9, 0x01, 0xed, 0x89, 0xdf, 0x61, 0xdb, 0x93, 0x8e,
2919 0xb2, 0x41, 0x83, 0xa0, 0xcb, 0x62, 0xc0, 0xd3, 0xef, 0x29, 0x2d, 0x57,
2920 0x47, 0xef, 0x48, 0x2a, 0x7d, 0x47, 0x2c, 0xc8, 0x02, 0xcb, 0xfd, 0x50,
2921 0x5c, 0x8c, 0x79, 0x5c, 0x5e, 0xc7, 0x3c, 0x06, 0xf8, 0xfb, 0xc8, 0x90,
2922 0xe6, 0xef, 0x51, 0x89, 0xec, 0xe6, 0x71, 0xd0, 0x1b, 0x64, 0x50, 0xc0,
2923 0xd3, 0xe9, 0x90, 0x46, 0x9f, 0x06, 0xff, 0x5a, 0xb0, 0xca, 0x92, 0x32,
2924 0x0f, 0xfe, 0xbf, 0x8e, 0xef, 0xb7, 0xea, 0x9f, 0xaa, 0xb9, 0x05, 0x15,
2925 0xe6, 0xb2, 0x7c, 0x1b, 0x38, 0xf9, 0xf7, 0x38, 0xbb, 0x2e, 0x8d, 0xdd,
2926 0x07, 0x46, 0x18, 0x4b, 0xfb, 0xb7, 0xba, 0x6c, 0x1f, 0x95, 0xcd, 0xe1,
2927 0xe3, 0x28, 0xef, 0xc3, 0xd3, 0xc0, 0x39, 0x44, 0x75, 0x2c, 0x7c, 0xd9,
2928 0x1b, 0x36, 0x0a, 0x3a, 0xef, 0xe0, 0x98, 0xce, 0xcf, 0x37, 0xec, 0x03,
2929 0xf8, 0x4e, 0xbf, 0x0c, 0xf7, 0x06, 0xcc, 0xa4, 0x12, 0x3a, 0xc7, 0xb4,
2930 0x02, 0x2c, 0xb1, 0x82, 0xf1, 0xde, 0xa7, 0x5f, 0xaf, 0x06, 0x1e, 0x1e,
2931 0xfe, 0xa7, 0x9f, 0x8e, 0x31, 0x27, 0x7d, 0x33, 0x11, 0xe8, 0xbf, 0xcf,
2932 0xfc, 0x4d, 0x7b, 0x6e, 0xd4, 0xc0, 0xcb, 0x6d, 0x33, 0x86, 0xb6, 0xd0,
2933 0x65, 0xd0, 0x45, 0x65, 0x4d, 0xbf, 0x6c, 0x17, 0xf4, 0x2d, 0xd4, 0x52,
2934 0xe6, 0x07, 0x12, 0xf4, 0x9d, 0xb7, 0xa9, 0x77, 0xda, 0x21, 0x5f, 0x92,
2935 0x1a, 0x57, 0xbe, 0x6f, 0xe7, 0x21, 0x15, 0xac, 0xe4, 0x24, 0x68, 0xb4,
2936 0x4d, 0x2c, 0x67, 0x5c, 0x1e, 0xcc, 0x3b, 0xab, 0xfb, 0xb2, 0x6d, 0xb3,
2937 0x6f, 0x73, 0x5e, 0xae, 0x9f, 0x7b, 0xe1, 0x1e, 0xe8, 0xa7, 0x36, 0x35,
2938 0x8d, 0x36, 0x6a, 0xed, 0xfd, 0x01, 0x8d, 0x36, 0xf7, 0x11, 0xfb, 0x3f,
2939 0xfb, 0x20, 0x9d, 0x0c, 0x1b, 0x41, 0x0e, 0x06, 0x9e, 0x35, 0x9e, 0xe7,
2940 0xa7, 0xc0, 0xf7, 0x3b, 0xe9, 0xa7, 0xe9, 0x67, 0x0c, 0xe8, 0xe7, 0x91,
2941 0x6d, 0xfa, 0x21, 0xdd, 0x74, 0xca, 0xd8, 0x35, 0x5b, 0x26, 0x8a, 0xfa,
2942 0xbe, 0x81, 0x35, 0xe9, 0x3f, 0x3a, 0x0e, 0xba, 0x21, 0xad, 0x93, 0xb7,
2943 0x4c, 0x29, 0x83, 0x8e, 0xca, 0x90, 0x4f, 0x65, 0xd0, 0x14, 0x31, 0x50,
2944 0x19, 0xf2, 0xad, 0x5c, 0xb7, 0x9c, 0x2a, 0xf6, 0x4c, 0x9d, 0xbd, 0x02,
2945 0x3a, 0xba, 0x5e, 0xe7, 0xfd, 0xeb, 0x35, 0x9b, 0xd4, 0x83, 0xb7, 0xb6,
2946 0xef, 0xfe, 0xef, 0xb8, 0xfb, 0x43, 0x72, 0x03, 0x76, 0xcb, 0x9b, 0xa5,
2947 0x61, 0xc8, 0x24, 0x21, 0x5e, 0x04, 0x6d, 0x8c, 0xca, 0x6a, 0xe9, 0xa4,
2948 0xac, 0x41, 0x3f, 0xad, 0x2f, 0x0d, 0x00, 0x4f, 0x43, 0x8e, 0xbe, 0x72,
2949 0x44, 0xde, 0x58, 0x52, 0x32, 0x63, 0x43, 0xbf, 0x2c, 0xd3, 0x07, 0x0f,
2950 0x7a, 0x2e, 0x77, 0xea, 0x98, 0xfd, 0x58, 0x35, 0xf0, 0xc5, 0x8f, 0x57,
2951 0xbb, 0x64, 0xa2, 0x6a, 0xca, 0x63, 0xd5, 0x1e, 0x79, 0xa2, 0x1a, 0x93,
2952 0xd3, 0xb5, 0x84, 0x7c, 0xa3, 0x7a, 0x50, 0x4e, 0x55, 0x0f, 0xc9, 0x93,
2953 0xb5, 0xa4, 0x7c, 0x13, 0x76, 0x61, 0xae, 0xe6, 0xc8, 0x64, 0x6d, 0x58,
2954 0x1e, 0xaf, 0xd1, 0xc7, 0x8e, 0xf9, 0xf0, 0xcb, 0x6e, 0xfb, 0x2e, 0xb8,
2955 0xae, 0x0e, 0xac, 0xcb, 0x51, 0xe3, 0x3a, 0x66, 0x29, 0xb9, 0xc0, 0xff,
2956 0x21, 0x72, 0x0e, 0x7d, 0x2f, 0xbe, 0xa2, 0xa4, 0xa2, 0xe7, 0x6f, 0xfe,
2957 0xdf, 0x48, 0x54, 0xdb, 0x46, 0xe7, 0xca, 0x07, 0xd1, 0xc6, 0xa6, 0x4d,
2958 0x12, 0xfa, 0x41, 0x9a, 0xfe, 0xff, 0xa6, 0xed, 0x65, 0x68, 0x1f, 0xf6,
2959 0x2d, 0xda, 0x5e, 0xfa, 0xec, 0x29, 0x3f, 0x68, 0xe7, 0xd0, 0xd6, 0xda,
2960 0x19, 0xe7, 0x68, 0xce, 0x7b, 0x31, 0xf7, 0xf0, 0xff, 0xa7, 0x04, 0xf1,
2961 0xaa, 0xb3, 0xb5, 0x83, 0xfc, 0x3f, 0x15, 0xac, 0xe5, 0x8b, 0xf3, 0xc5,
2962 0x27, 0x4a, 0x63, 0xea, 0xb1, 0x12, 0x11, 0x8d, 0x2f, 0x17, 0xb7, 0x73,
2963 0xf2, 0xbe, 0x2e, 0xcb, 0x6e, 0x54, 0xaf, 0x21, 0xf0, 0xdb, 0xa7, 0x75,
2964 0x7e, 0xde, 0xd8, 0x10, 0xe9, 0x8f, 0x71, 0xb8, 0xae, 0x30, 0xb6, 0x00,
2965 0x6c, 0xeb, 0x9a, 0x72, 0xa9, 0x1a, 0xf8, 0xaf, 0xe6, 0x34, 0xbd, 0xbc,
2966 0x05, 0x9a, 0x63, 0xfc, 0x21, 0x78, 0xe6, 0xcb, 0x41, 0xdf, 0xec, 0x90,
2967 0x43, 0x7b, 0x1c, 0xfb, 0x35, 0x7a, 0x38, 0x17, 0xff, 0x4f, 0x07, 0xe5,
2968 0x70, 0xbd, 0xcc, 0x2f, 0xb6, 0x35, 0x2d, 0x06, 0x31, 0x5e, 0x47, 0x9e,
2969 0xc3, 0x5d, 0x54, 0x4c, 0xae, 0xbf, 0x43, 0x2a, 0x0e, 0x6d, 0x5b, 0xca,
2970 0xef, 0x21, 0x29, 0x63, 0x9e, 0x8a, 0xd3, 0xf4, 0x8d, 0x05, 0x72, 0xb6,
2971 0x62, 0x3e, 0x98, 0x77, 0xba, 0xbc, 0x1f, 0xef, 0xa8, 0x73, 0x80, 0x99,
2972 0xa6, 0xf8, 0x7e, 0x11, 0x65, 0xfa, 0x46, 0xe6, 0xf0, 0x4c, 0x84, 0x75,
2973 0xaf, 0xf5, 0x6b, 0xac, 0x7e, 0xf2, 0x41, 0xbf, 0x99, 0xb2, 0x95, 0xcf,
2974 0x44, 0xb6, 0x94, 0xf1, 0x8b, 0xf5, 0x7e, 0xca, 0xdc, 0xfd, 0x36, 0x7f,
2975 0x51, 0xf9, 0x8b, 0xa9, 0x7d, 0x0a, 0xe1, 0xb7, 0x3d, 0xf2, 0x94, 0xc9,
2976 0xdc, 0xf5, 0xb4, 0x1a, 0x2b, 0xfd, 0x34, 0xcc, 0xd3, 0xdd, 0x52, 0xfb,
2977 0x2b, 0x6f, 0xf7, 0x07, 0x79, 0xee, 0x1c, 0x7b, 0x67, 0x6e, 0xfb, 0x4e,
2978 0x3a, 0x61, 0x8e, 0x7b, 0x3b, 0x70, 0xab, 0x56, 0x62, 0xe0, 0x41, 0xc8,
2979 0x3b, 0xbb, 0x45, 0xf3, 0x63, 0xa1, 0xf6, 0x2f, 0x7f, 0x43, 0xf3, 0x73,
2980 0xd3, 0xc7, 0xf0, 0xdb, 0x7e, 0xda, 0xb6, 0x94, 0x1b, 0x97, 0x02, 0xbf,
2981 0x91, 0xb6, 0xa1, 0x21, 0x2b, 0x50, 0x47, 0x5e, 0x05, 0x9f, 0x6c, 0xb7,
2982 0xe5, 0xdf, 0x7f, 0x01, 0x99, 0xe7, 0xd3, 0x46, 0x40, 0x67, 0x00, 0x00,
2983 0x00 };
2984static u32 bnx2_RXP_b09FwData[(0x0/4) + 1] = { 0x0 };
2985static u32 bnx2_RXP_b09FwRodata[(0x278/4) + 1] = {
2986 0x08003fa4, 0x08003ea4, 0x08003f48, 0x08003f60, 0x08003f78, 0x08003f98,
2987 0x08003fa4, 0x08003fa4, 0x08003eac, 0x00000000, 0x080049d4, 0x08004a0c,
2988 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004a44, 0x08004c08,
2989 0x08004b50, 0x08004b88, 0x08004c08, 0x08004ad8, 0x08004c08, 0x08004c08,
2990 0x08004b88, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2991 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004bc8,
2992 0x08004c08, 0x08004bc8, 0x08004b50, 0x08004c08, 0x08004c08, 0x08004bc8,
2993 0x08004bc8, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2994 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2995 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2996 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2997 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2998 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
2999 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3000 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3001 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3002 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3003 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3004 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3005 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3006 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3007 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3008 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08, 0x08004c08,
3009 0x08004ab4, 0x00000000, 0x0800602c, 0x08006044, 0x08006044, 0x08006044,
3010 0x0800602c, 0x08006044, 0x08006044, 0x08006044, 0x0800602c, 0x08006044,
3011 0x08006044, 0x08006044, 0x0800602c, 0x08006044, 0x08006044, 0x08006044,
3012 0x08006038, 0x00000000, 0x00000000 };
3013static u32 bnx2_RXP_b09FwBss[(0x13dc/4) + 1] = { 0x0 };
3014static u32 bnx2_RXP_b09FwSbss[(0x2c/4) + 1] = { 0x0 };
3015
3016static struct fw_info bnx2_rxp_fw_09 = {
3017 .ver_major = 0x1,
3018 .ver_minor = 0x0,
3019 .ver_fix = 0x0,
3020
3021 .start_addr = 0x08003184,
3022
3023 .text_addr = 0x08000000,
3024 .text_len = 0x673c,
3025 .text_index = 0x0,
3026 .gz_text = bnx2_RXP_b09FwText,
3027 .gz_text_len = sizeof(bnx2_RXP_b09FwText),
3028
3029 .data_addr = 0x080069e0,
3030 .data_len = 0x0,
3031 .data_index = 0x0,
3032 .data = bnx2_RXP_b09FwData,
3033
3034 .sbss_addr = 0x080069e0,
3035 .sbss_len = 0x2c,
3036 .sbss_index = 0x0,
3037 .sbss = bnx2_RXP_b09FwSbss,
3038
3039 .bss_addr = 0x08006a10,
3040 .bss_len = 0x13dc,
3041 .bss_index = 0x0,
3042 .bss = bnx2_RXP_b09FwBss,
3043
3044 .rodata_addr = 0x08006740,
3045 .rodata_len = 0x278,
3046 .rodata_index = 0x0,
3047 .rodata = bnx2_RXP_b09FwRodata,
3048};
3049
3050static u8 bnx2_TPAT_b09FwText[] = {
3051 0x1f, 0x8b, 0x08, 0x08, 0xdb, 0xfd, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
3052 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xc5, 0x58, 0x5d, 0x6c,
3053 0x1c, 0x57, 0x15, 0x3e, 0xf3, 0xbb, 0x13, 0x77, 0xed, 0xbd, 0x49, 0x97,
3054 0x6a, 0x13, 0xb9, 0x74, 0xc6, 0x1e, 0x3b, 0x8b, 0x1c, 0x35, 0x93, 0xb0,
3055 0x24, 0x16, 0x5a, 0xd1, 0xc9, 0xcc, 0xae, 0x6b, 0xe5, 0x29, 0x86, 0xbc,
3056 0xf1, 0xb2, 0xac, 0xed, 0x46, 0x54, 0x48, 0x4d, 0x51, 0x84, 0x22, 0x81,
3057 0x94, 0x65, 0x76, 0x53, 0x40, 0x5a, 0x65, 0xc1, 0xa0, 0x04, 0x21, 0x84,
3058 0x22, 0x9b, 0x66, 0x91, 0x58, 0x3c, 0x4d, 0xe9, 0x6b, 0x94, 0xbc, 0x90,
3059 0x96, 0x17, 0x9e, 0x4b, 0x9e, 0xac, 0x02, 0x12, 0x0f, 0xa8, 0x8a, 0x78,
3060 0x40, 0x15, 0x0d, 0x1e, 0xbe, 0x33, 0x3f, 0x9b, 0x5d, 0xd7, 0x29, 0x79,
3061 0xa8, 0x84, 0xa5, 0xf1, 0xcc, 0xfd, 0x39, 0xf7, 0xe7, 0x7c, 0xdf, 0x77,
3062 0xee, 0xb9, 0x5b, 0x92, 0x69, 0x82, 0xd2, 0xbf, 0x49, 0x3c, 0x97, 0xbe,
3063 0x71, 0xf1, 0xd2, 0xe2, 0x8b, 0x27, 0x4d, 0x3a, 0x71, 0xe2, 0x45, 0xe9,
3064 0x19, 0x43, 0xa6, 0xcf, 0xe0, 0x4f, 0x21, 0x12, 0xd9, 0xf8, 0xfc, 0x90,
3065 0x21, 0x57, 0x6f, 0x4e, 0x7b, 0x36, 0x19, 0x4a, 0xd5, 0x79, 0x61, 0xd5,
3066 0x26, 0x72, 0x07, 0x0b, 0xa6, 0x4f, 0xff, 0x89, 0x5a, 0x45, 0x95, 0xb8,
3067 0xfe, 0xf9, 0xea, 0xa3, 0xe3, 0x77, 0x4e, 0x5b, 0x0f, 0x6f, 0x2a, 0x64,
3068 0x88, 0x6a, 0xc3, 0x10, 0xf3, 0x64, 0x4c, 0xc3, 0xe6, 0x97, 0x47, 0x57,
3069 0x34, 0x9a, 0xca, 0xc6, 0x12, 0x14, 0xf4, 0x0c, 0xaa, 0x77, 0x31, 0x8e,
3070 0x7d, 0x59, 0xf2, 0x43, 0x55, 0xf2, 0x6f, 0x18, 0x24, 0x57, 0x5d, 0xc9,
3071 0x0b, 0x6d, 0xb4, 0x49, 0xe4, 0x39, 0x39, 0x72, 0x45, 0x14, 0x7d, 0xd3,
3072 0x91, 0x49, 0xb6, 0x77, 0xa3, 0xd9, 0xb9, 0x25, 0xc9, 0xeb, 0x2f, 0x4b,
3073 0x7e, 0xdf, 0xe3, 0x7d, 0x63, 0x1d, 0x4b, 0x92, 0xdb, 0xe7, 0x77, 0xd5,
3074 0xf0, 0xbb, 0x53, 0xd4, 0x28, 0x52, 0x41, 0xb6, 0xd9, 0xd6, 0x24, 0xdf,
3075 0x59, 0x28, 0x29, 0x34, 0x8b, 0xe7, 0x00, 0xad, 0x3b, 0x94, 0xf7, 0x1c,
3076 0x52, 0x15, 0x5b, 0x26, 0xbf, 0x28, 0xd1, 0xaf, 0x2b, 0x1a, 0x9e, 0xb3,
3077 0x52, 0xad, 0xbf, 0x96, 0x8e, 0x53, 0xa4, 0x36, 0xd6, 0xd2, 0x2c, 0xf2,
3078 0xda, 0x12, 0x7b, 0xcf, 0x59, 0x10, 0x32, 0xcd, 0xe2, 0x99, 0xc4, 0x77,
3079 0x13, 0xfd, 0x34, 0xf2, 0x2a, 0x7b, 0xdb, 0x0e, 0xe0, 0x1b, 0xeb, 0xc4,
3080 0x58, 0x5e, 0xbc, 0x0e, 0x13, 0xeb, 0xb0, 0xa9, 0xd3, 0x5b, 0xc6, 0x3e,
3081 0xe6, 0x4a, 0x4d, 0xd2, 0xa9, 0x13, 0xaf, 0x7d, 0x92, 0x02, 0xa1, 0x50,
3082 0x70, 0x4c, 0x23, 0xf7, 0x9c, 0x8a, 0xf2, 0x21, 0x6a, 0x09, 0x09, 0x7d,
3083 0x3a, 0x29, 0x7e, 0x39, 0xb4, 0xeb, 0xa8, 0x2f, 0x50, 0x50, 0x3c, 0x28,
3084 0xc9, 0xd5, 0xef, 0xa1, 0x7e, 0x4e, 0x34, 0xe9, 0xbb, 0x78, 0x4b, 0x28,
3085 0x1f, 0xe4, 0xf1, 0x50, 0x96, 0x48, 0xb1, 0x49, 0x78, 0xa1, 0x49, 0xed,
3086 0x30, 0xb3, 0xe5, 0xfa, 0xa4, 0xae, 0x15, 0xee, 0xc5, 0x0e, 0xfd, 0x7a,
3087 0x75, 0x6a, 0x08, 0x6a, 0xa9, 0x55, 0xf4, 0xe9, 0xd9, 0xa2, 0x06, 0x9c,
3088 0xdc, 0x18, 0xcf, 0x97, 0xb8, 0x9e, 0xff, 0x50, 0x6f, 0x92, 0x52, 0xb5,
3089 0x85, 0x4f, 0x5f, 0xa6, 0xa4, 0x8d, 0xf7, 0x29, 0x63, 0x6f, 0xa7, 0xd2,
3090 0x72, 0x51, 0x78, 0x37, 0xbe, 0x48, 0x6e, 0xec, 0x1f, 0x03, 0xdf, 0x02,
3091 0x7b, 0xd4, 0x81, 0x75, 0xe0, 0xca, 0xd4, 0x2a, 0x19, 0x64, 0x2d, 0xae,
3092 0xa1, 0xe5, 0x6f, 0x5d, 0x05, 0x7e, 0x67, 0xdc, 0xd4, 0xd4, 0x8e, 0x71,
3093 0xfe, 0x23, 0xd6, 0xd9, 0x12, 0x06, 0xf0, 0x6e, 0x9c, 0x8f, 0xa2, 0x37,
3094 0x9d, 0x28, 0xd2, 0xab, 0x76, 0xf9, 0x16, 0x2d, 0x94, 0x34, 0x9a, 0x17,
3095 0x78, 0xc3, 0x8f, 0x36, 0x7c, 0xa5, 0x65, 0xeb, 0xc9, 0x78, 0x86, 0xbf,
3096 0xcb, 0x12, 0x96, 0x42, 0x1f, 0x74, 0xdf, 0x63, 0x7f, 0x94, 0x97, 0x62,
3097 0x9b, 0x28, 0xda, 0x5c, 0xfc, 0x34, 0x9b, 0xef, 0xa7, 0x36, 0x51, 0x54,
3098 0xaf, 0xf0, 0xbc, 0x16, 0xf6, 0xcc, 0x5c, 0x25, 0xaa, 0x0f, 0x1c, 0xa3,
3099 0xd9, 0xc5, 0xfa, 0x6c, 0xbc, 0x07, 0x25, 0xec, 0xc1, 0x2a, 0x9b, 0x92,
3100 0x41, 0x81, 0x1d, 0xbd, 0x00, 0x7e, 0xb8, 0xbe, 0x6d, 0xbd, 0xef, 0x2b,
3101 0x05, 0xda, 0x72, 0xf2, 0xd4, 0x09, 0x4b, 0x14, 0x84, 0x1d, 0xf2, 0x42,
3102 0x19, 0x73, 0x14, 0x68, 0xd3, 0x7e, 0x18, 0xd5, 0x1d, 0x07, 0x7e, 0x21,
3103 0xb6, 0x2b, 0xd5, 0x69, 0x1a, 0xed, 0x0b, 0x62, 0x8d, 0x1c, 0x60, 0x21,
3104 0xc3, 0x37, 0xb3, 0xf1, 0x77, 0x10, 0x3a, 0x68, 0xa7, 0x96, 0x5c, 0xb1,
3105 0x44, 0x40, 0x56, 0xc9, 0x53, 0x48, 0xc8, 0x55, 0x81, 0x3e, 0x2d, 0xaa,
3106 0x85, 0x06, 0xed, 0x28, 0x97, 0x63, 0x7e, 0xb7, 0x7b, 0x3b, 0xd1, 0x9d,
3107 0xa3, 0x25, 0xba, 0x1b, 0x16, 0xe9, 0x76, 0x48, 0x72, 0xd3, 0x01, 0x37,
3108 0x8a, 0x82, 0xde, 0x0a, 0x47, 0xf7, 0xf2, 0x1b, 0xec, 0x25, 0x38, 0xa2,
3109 0x40, 0x83, 0xab, 0xce, 0x3d, 0x30, 0xc8, 0x02, 0x46, 0x2d, 0xec, 0x3d,
3110 0x7b, 0xf3, 0xbe, 0x76, 0xa6, 0x57, 0x6d, 0xeb, 0x87, 0x3e, 0xa3, 0x76,
3111 0x4d, 0x43, 0xed, 0x5e, 0x7f, 0x0c, 0x30, 0x86, 0xa0, 0xab, 0xd0, 0x93,
3112 0x0c, 0xbf, 0xcc, 0x6c, 0x1b, 0xd4, 0xef, 0xe6, 0xc8, 0xdc, 0x54, 0xa9,
3113 0xd9, 0x2b, 0x92, 0x33, 0x6f, 0x99, 0x24, 0xcb, 0x45, 0x99, 0x54, 0x9a,
3114 0xd9, 0x8c, 0x68, 0x09, 0xeb, 0xb8, 0x6f, 0xff, 0x48, 0xa7, 0xa9, 0xc0,
3115 0xd1, 0x89, 0xfb, 0x18, 0x34, 0x73, 0xcb, 0x90, 0xfc, 0x1e, 0xef, 0x83,
3116 0x7d, 0x6e, 0xa4, 0x3e, 0x57, 0x25, 0xef, 0x46, 0x8e, 0x66, 0x37, 0xfe,
3117 0x11, 0x79, 0x36, 0x7c, 0x0d, 0x9e, 0xaf, 0x56, 0xbe, 0xa0, 0xd0, 0x04,
3118 0xea, 0x36, 0xb9, 0xed, 0x61, 0x5a, 0xcf, 0x63, 0x44, 0x91, 0xe7, 0x3c,
3119 0x4b, 0x1e, 0xf3, 0xff, 0x3c, 0xdb, 0xe4, 0x68, 0x66, 0x83, 0x75, 0x83,
3120 0xf7, 0x26, 0x97, 0x79, 0x6d, 0x07, 0xa8, 0x89, 0x1d, 0x35, 0xcb, 0x45,
3121 0xf8, 0x41, 0x8e, 0x35, 0xd2, 0xc4, 0x8e, 0x65, 0x7b, 0x02, 0x6f, 0x9e,
3122 0xef, 0xac, 0x92, 0xf0, 0x9d, 0xe3, 0x46, 0x9e, 0x7c, 0xe0, 0xab, 0x62,
3123 0x3d, 0x6b, 0x34, 0x57, 0x5a, 0x8f, 0xdb, 0x50, 0x37, 0xe0, 0x36, 0xb1,
3124 0xa7, 0x0d, 0xe5, 0x41, 0xb6, 0x06, 0x70, 0xda, 0x6e, 0x63, 0x16, 0x2d,
3125 0xde, 0x6b, 0xdd, 0xe1, 0xfe, 0xdc, 0xb7, 0x55, 0xd6, 0xc8, 0x2a, 0x6f,
3126 0x62, 0xf4, 0x7e, 0x17, 0xfb, 0xbd, 0xce, 0xb1, 0xc8, 0x36, 0xff, 0x4a,
3127 0xdc, 0x7f, 0x16, 0x7b, 0x9e, 0x5b, 0x6c, 0x73, 0xdb, 0x40, 0x23, 0x7b,
3128 0xa3, 0x25, 0x54, 0xf8, 0x5f, 0x86, 0xf3, 0xfd, 0x1f, 0xff, 0x2b, 0xd2,
3129 0xaa, 0xe0, 0x74, 0xa5, 0x00, 0x7c, 0x2c, 0xb3, 0x0d, 0xbd, 0xdb, 0x18,
3130 0x37, 0x70, 0x14, 0xd8, 0x25, 0x38, 0x71, 0xbf, 0xa5, 0x6e, 0x44, 0xed,
3131 0x78, 0xae, 0x2b, 0x3c, 0x17, 0x62, 0x92, 0xbd, 0xf8, 0x07, 0x70, 0xa3,
3132 0x49, 0x79, 0x9a, 0xdf, 0xce, 0xd3, 0x85, 0x41, 0x9e, 0x66, 0xae, 0xe9,
3133 0xf0, 0x43, 0x14, 0x75, 0x2a, 0xac, 0x51, 0xe0, 0x6d, 0x73, 0x3f, 0xab,
3134 0xa4, 0xc8, 0xbc, 0x0e, 0xb4, 0x6f, 0x13, 0xad, 0x0d, 0x74, 0xf8, 0x4d,
3135 0x1d, 0x19, 0x5b, 0xa6, 0x97, 0x7f, 0x46, 0xf4, 0xf2, 0x80, 0x6d, 0x79,
3136 0xfc, 0xc4, 0xa6, 0x89, 0x3d, 0xcb, 0xc0, 0xfc, 0xc2, 0x40, 0x46, 0xbc,
3137 0x40, 0x3c, 0xed, 0x7b, 0x88, 0x93, 0x35, 0x3c, 0x4b, 0x88, 0x9d, 0x8c,
3138 0x0d, 0xc7, 0x91, 0x5d, 0xe0, 0xb3, 0x8c, 0xb6, 0xb3, 0xa8, 0x4b, 0xf4,
3139 0xae, 0xd8, 0x3a, 0xd5, 0x9c, 0x49, 0x6a, 0x67, 0xb1, 0x4a, 0x70, 0xac,
3140 0x3a, 0x08, 0x4e, 0x1d, 0x40, 0xfc, 0xf9, 0x9d, 0x32, 0x1e, 0xab, 0x10,
3141 0xd3, 0x8a, 0x87, 0x11, 0x9b, 0xfa, 0xa8, 0xe7, 0xf1, 0x6e, 0xe1, 0x7d,
3142 0x00, 0xe5, 0xc3, 0xe8, 0x3b, 0x1a, 0xa7, 0x32, 0xbb, 0x27, 0xc5, 0x28,
3143 0xf0, 0x6e, 0xc3, 0x40, 0x7f, 0x13, 0xba, 0x61, 0x7f, 0xe7, 0x10, 0x3f,
3144 0xd8, 0xe7, 0x39, 0xf8, 0x54, 0xc7, 0xdc, 0x82, 0x66, 0xb7, 0xa9, 0xa5,
3145 0xa4, 0xf1, 0xcb, 0x1f, 0xc6, 0xaf, 0x52, 0xcc, 0x83, 0x20, 0x14, 0xb0,
3146 0x61, 0xfd, 0x66, 0x7a, 0x65, 0xec, 0xc8, 0xf5, 0xa0, 0x65, 0x4f, 0x89,
3147 0xa2, 0x55, 0xa7, 0x40, 0x4d, 0xe0, 0xee, 0x42, 0xc3, 0x4d, 0x68, 0xd8,
3148 0x1f, 0xd1, 0xb0, 0xff, 0x3f, 0x35, 0x0c, 0x7d, 0x42, 0x23, 0xb7, 0xc1,
3149 0xa9, 0xb7, 0x7a, 0xfb, 0xe9, 0x99, 0xb5, 0xcc, 0x9a, 0x36, 0xe9, 0xce,
3150 0xd1, 0xa7, 0xd5, 0x74, 0x49, 0x7e, 0x4a, 0x4d, 0xb7, 0x58, 0xd3, 0x2a,
3151 0x6b, 0xba, 0xb8, 0x57, 0xd3, 0xd3, 0x18, 0x23, 0xd1, 0xe6, 0x19, 0xb5,
3152 0x48, 0xda, 0x3c, 0xf0, 0xd8, 0xc8, 0x93, 0x72, 0xed, 0x31, 0xef, 0x98,
3153 0xcb, 0xfe, 0x00, 0xff, 0xb6, 0x35, 0xb4, 0x49, 0xe3, 0xf5, 0x88, 0x81,
3154 0x6a, 0xd5, 0x2a, 0xad, 0xc5, 0x7d, 0x54, 0xd2, 0xe1, 0xff, 0xd7, 0x8f,
3155 0x5a, 0xa6, 0x29, 0x8f, 0x6a, 0x1f, 0xea, 0xdf, 0x88, 0xae, 0x68, 0x55,
3156 0x9e, 0xa7, 0x65, 0x82, 0xf3, 0xe6, 0x4f, 0x80, 0x55, 0xbb, 0xcb, 0x7c,
3157 0xb7, 0x45, 0x3d, 0xe6, 0x19, 0xca, 0xd0, 0x84, 0x06, 0xde, 0xe6, 0xd0,
3158 0x4f, 0xdd, 0x48, 0x74, 0x74, 0x1b, 0xe3, 0x6e, 0x75, 0x99, 0x67, 0x06,
3159 0xe9, 0xd7, 0xed, 0xd2, 0x85, 0x38, 0x06, 0xcf, 0x8a, 0x25, 0x62, 0x0d,
3160 0xf2, 0xb9, 0x88, 0xf6, 0x41, 0x8e, 0x94, 0x58, 0xf7, 0x13, 0xa9, 0xee,
3161 0x9f, 0x87, 0xaf, 0x26, 0x50, 0x66, 0xed, 0x1f, 0x4e, 0xb5, 0x3f, 0x85,
3162 0x37, 0xd7, 0xad, 0xa8, 0x09, 0x87, 0xc0, 0xc7, 0x0d, 0xc6, 0x37, 0x8f,
3163 0x58, 0xc7, 0xf3, 0xff, 0x33, 0x5a, 0xb5, 0x19, 0x63, 0xdb, 0xfc, 0x01,
3164 0xcd, 0x41, 0x7f, 0xa8, 0xdf, 0xe6, 0xbe, 0x6c, 0x93, 0xf5, 0x15, 0x69,
3165 0xdf, 0x0f, 0xf7, 0xf4, 0x45, 0xfd, 0x36, 0xf7, 0x63, 0x7d, 0x1c, 0x22,
3166 0xe5, 0x3a, 0x9f, 0xdb, 0x1e, 0xeb, 0x03, 0x76, 0x35, 0xd4, 0x71, 0x6e,
3167 0xc1, 0xf6, 0x7c, 0x86, 0xf3, 0x3a, 0x39, 0xef, 0xe0, 0x73, 0x7e, 0xcf,
3168 0x79, 0x3e, 0xd4, 0xc8, 0x19, 0xf0, 0xfe, 0x3b, 0xea, 0x27, 0x35, 0xb2,
3169 0x02, 0x4d, 0x5c, 0x54, 0x13, 0x8d, 0xbc, 0x86, 0xf7, 0x19, 0x94, 0x57,
3170 0xf6, 0x68, 0x24, 0xb3, 0x7b, 0xf2, 0x39, 0x1e, 0xf4, 0x4a, 0xf1, 0x99,
3171 0xcb, 0xf3, 0x29, 0x1b, 0xd4, 0xd2, 0x52, 0x3d, 0xd4, 0x87, 0x7a, 0x98,
3172 0x40, 0xcc, 0xc8, 0xa5, 0x5c, 0xc7, 0xdb, 0xfe, 0x48, 0xf1, 0x1d, 0x4b,
3173 0xb4, 0x89, 0xb5, 0x31, 0x7a, 0x9e, 0xfd, 0xbf, 0xf4, 0x41, 0xe0, 0x51,
3174 0x3c, 0x37, 0x72, 0x11, 0x3e, 0x17, 0xa2, 0xe8, 0x15, 0x07, 0xed, 0x59,
3175 0x4e, 0x12, 0x63, 0x9f, 0xc3, 0xd9, 0xcb, 0x78, 0x20, 0x0f, 0xb4, 0x67,
3176 0xa1, 0x07, 0x8e, 0x05, 0xbb, 0xd1, 0x96, 0xed, 0xa1, 0xae, 0x06, 0xff,
3177 0x33, 0x26, 0xcb, 0xd2, 0x52, 0xdf, 0x60, 0x3b, 0xe8, 0x6d, 0xbf, 0x5c,
3178 0x4c, 0x87, 0xae, 0x1e, 0xe3, 0xc4, 0x3c, 0x6a, 0x8e, 0xe0, 0xd4, 0x88,
3179 0x71, 0xda, 0x19, 0xe2, 0xd4, 0x4c, 0x71, 0x6a, 0xc6, 0x38, 0x3d, 0x48,
3180 0x71, 0xfa, 0xf3, 0x13, 0x70, 0xda, 0x79, 0x0a, 0x9c, 0x0c, 0xda, 0xb2,
3181 0x4b, 0x38, 0x6f, 0xf5, 0x38, 0x77, 0xbd, 0xef, 0xec, 0x97, 0x7b, 0xb1,
3182 0xdf, 0xc7, 0xb0, 0x8a, 0x18, 0xab, 0x2d, 0x1a, 0xcd, 0x43, 0x2c, 0xf3,
3183 0x1e, 0x15, 0x70, 0x6e, 0xe4, 0xe9, 0xea, 0x9e, 0x5c, 0x24, 0x00, 0x4e,
3184 0xb5, 0x14, 0xa7, 0xab, 0xc0, 0xa9, 0x96, 0xe2, 0xb4, 0x3e, 0x82, 0xd3,
3185 0xfa, 0x18, 0x4e, 0x1c, 0x53, 0x2a, 0xc6, 0x7a, 0x37, 0xc3, 0x28, 0xc3,
3186 0x47, 0xa7, 0x9b, 0x62, 0x0a, 0xfb, 0x3f, 0x4e, 0xed, 0x9f, 0xaa, 0x9c,
3187 0xff, 0x02, 0xbb, 0x97, 0x54, 0x39, 0x3e, 0x17, 0xf8, 0xfb, 0x71, 0xbe,
3188 0x82, 0xb9, 0x5c, 0xcf, 0xe1, 0x3d, 0x21, 0xcf, 0xb5, 0x47, 0x63, 0xd1,
3189 0x07, 0x88, 0x45, 0x5c, 0xc7, 0xfd, 0x54, 0xa9, 0x06, 0xcd, 0x2b, 0xc8,
3190 0xe1, 0xfd, 0x61, 0x0e, 0x9f, 0xf8, 0xe1, 0x6a, 0x9a, 0xc3, 0x6f, 0xd9,
3191 0x9c, 0xc3, 0x9f, 0xd0, 0x68, 0x62, 0x39, 0xc5, 0x93, 0x79, 0x3d, 0x89,
3192 0xb6, 0xb3, 0x31, 0xee, 0x6d, 0xc4, 0xf2, 0x55, 0xf8, 0xa0, 0x19, 0xf3,
3193 0x13, 0x79, 0x57, 0xca, 0x5d, 0xe4, 0xbb, 0xe4, 0x87, 0x09, 0x4f, 0x3f,
3194 0xdb, 0x5c, 0xec, 0xef, 0x88, 0xd9, 0x46, 0x43, 0xc5, 0x1d, 0xe0, 0x6e,
3195 0x18, 0xc7, 0xea, 0x73, 0x41, 0x97, 0x5a, 0x47, 0xaa, 0x57, 0x22, 0xe0,
3196 0xee, 0x7e, 0xfd, 0x34, 0x9f, 0x39, 0xf9, 0x45, 0xaf, 0x82, 0xfa, 0x81,
3197 0x41, 0xc8, 0x83, 0x70, 0xa7, 0xa1, 0x96, 0x77, 0x5a, 0x42, 0xbe, 0x83,
3198 0x32, 0x6c, 0x82, 0x70, 0xba, 0x21, 0x57, 0x4b, 0xe0, 0x43, 0x8b, 0x5c,
3199 0xac, 0xd3, 0x0d, 0xe3, 0x7b, 0x4d, 0x43, 0xa9, 0x1a, 0xc8, 0x37, 0xc9,
3200 0xc0, 0x99, 0x0f, 0x9f, 0x98, 0x46, 0x7b, 0x80, 0x9c, 0x08, 0x79, 0x80,
3201 0xb7, 0x08, 0xbf, 0x1c, 0x03, 0x76, 0xa1, 0x0a, 0xdb, 0x6f, 0xe9, 0xc9,
3202 0x9d, 0x88, 0xc8, 0x8b, 0xfd, 0xf5, 0x71, 0xca, 0x91, 0x38, 0xe7, 0x92,
3203 0x6a, 0x3d, 0x32, 0x9b, 0x0e, 0xb8, 0x8e, 0x33, 0xa5, 0x13, 0x72, 0x5e,
3204 0x7d, 0xcc, 0x90, 0xaf, 0x71, 0x3c, 0x7f, 0x00, 0x1f, 0xe2, 0x7b, 0x9b,
3205 0xcf, 0x19, 0x85, 0x73, 0x73, 0xdc, 0x7d, 0xca, 0x88, 0x37, 0x34, 0x89,
3206 0xd8, 0x87, 0xd8, 0x3b, 0xcd, 0x58, 0xb9, 0xc9, 0x19, 0xc4, 0xe3, 0x1d,
3207 0x97, 0x93, 0x79, 0xfe, 0xa4, 0x25, 0x1c, 0xc6, 0x7d, 0x07, 0xfe, 0x5b,
3208 0xed, 0x39, 0x1c, 0x73, 0x3f, 0xaf, 0xd0, 0x43, 0x8a, 0x39, 0x29, 0x4e,
3209 0x20, 0x16, 0x9f, 0x86, 0x8d, 0x1b, 0xeb, 0x31, 0xc9, 0xbd, 0x32, 0x9b,
3210 0x0f, 0xf7, 0x8c, 0xf1, 0x17, 0x65, 0xbc, 0xec, 0x82, 0xd3, 0x95, 0x74,
3211 0xbe, 0x51, 0x8e, 0x2c, 0x20, 0xe5, 0x79, 0xa0, 0x0d, 0xf3, 0xb7, 0xa2,
3212 0x8e, 0x7e, 0xbc, 0x46, 0xd6, 0x25, 0xdb, 0x1c, 0xd1, 0xc6, 0xc7, 0x99,
3213 0xdd, 0x67, 0x8c, 0xea, 0xc8, 0x18, 0x45, 0xde, 0x9b, 0x68, 0x3a, 0xcf,
3214 0xa4, 0xf7, 0x0c, 0x8e, 0x2d, 0x02, 0x3a, 0x95, 0x9f, 0x93, 0xb1, 0x0f,
3215 0x0f, 0x7b, 0xf6, 0xe3, 0xfa, 0x5f, 0xe9, 0xe3, 0xe3, 0xfe, 0x56, 0x4d,
3216 0xca, 0xc7, 0x12, 0x6e, 0xda, 0x78, 0x87, 0x0f, 0x46, 0xd6, 0xae, 0xed,
3217 0x33, 0xef, 0xd7, 0x38, 0x5d, 0x43, 0xbc, 0x21, 0x57, 0xc1, 0x1d, 0xcc,
3218 0x27, 0x7c, 0x87, 0xaf, 0x67, 0x3e, 0x04, 0x6f, 0xe8, 0x5c, 0x3b, 0xe5,
3219 0x8b, 0x9c, 0xf0, 0x85, 0xf3, 0xba, 0xc5, 0x55, 0xf0, 0xa5, 0x0d, 0xbe,
3220 0xc0, 0xae, 0xa1, 0x55, 0xa7, 0xc1, 0x05, 0x8e, 0x4d, 0x28, 0x87, 0xcc,
3221 0x1d, 0xe6, 0x0a, 0xf3, 0xe6, 0x31, 0x5f, 0x5e, 0xe9, 0x1a, 0xc6, 0xe6,
3222 0xa7, 0x70, 0xe5, 0x8d, 0x98, 0x2b, 0xcc, 0xd9, 0x24, 0x7e, 0x74, 0x80,
3223 0x55, 0x90, 0xc6, 0x8f, 0x00, 0xf1, 0xa3, 0xc6, 0xf9, 0x4f, 0x1c, 0x0b,
3224 0x12, 0xfd, 0xac, 0x41, 0x3f, 0x35, 0x85, 0xf3, 0x23, 0xd6, 0x0e, 0xdb,
3225 0xb1, 0x7e, 0xd8, 0xae, 0x90, 0xda, 0x8d, 0xc7, 0x91, 0x76, 0xcf, 0x32,
3226 0xb3, 0x38, 0xd2, 0x86, 0x76, 0x3a, 0xa9, 0x8e, 0xda, 0xa9, 0x8e, 0xd0,
3227 0xa7, 0xa5, 0x54, 0xf8, 0x4c, 0xb0, 0x4c, 0x1f, 0xf1, 0xa3, 0x13, 0x8f,
3228 0xd9, 0xa2, 0xe4, 0x2e, 0xc3, 0xda, 0xe6, 0xb8, 0x3b, 0x12, 0x6f, 0xd3,
3229 0x7b, 0x6e, 0x23, 0xbe, 0xe7, 0x7e, 0x45, 0x1f, 0x8f, 0xb7, 0x38, 0x6b,
3230 0xe2, 0x7b, 0xee, 0x29, 0x9d, 0xef, 0xb9, 0x01, 0x7d, 0x49, 0x1f, 0xbd,
3231 0xe7, 0x06, 0x63, 0xf7, 0xdc, 0xcc, 0x96, 0xeb, 0xf7, 0x8b, 0xbb, 0x99,
3232 0x4f, 0x38, 0xf6, 0x32, 0x9f, 0xf6, 0xcb, 0x15, 0xb3, 0x3e, 0x1c, 0x93,
3233 0x58, 0xef, 0x1c, 0xcb, 0x92, 0xdc, 0xec, 0x6e, 0x98, 0xe9, 0xe2, 0x55,
3234 0xcc, 0x83, 0x72, 0x6f, 0x3f, 0x5d, 0x18, 0xa9, 0x2e, 0x26, 0x13, 0x9b,
3235 0xde, 0xa8, 0x36, 0x5e, 0xd5, 0xc7, 0xb5, 0x91, 0x8d, 0x93, 0x69, 0x23,
3236 0x19, 0x73, 0x47, 0x29, 0xe1, 0x0c, 0x2c, 0x23, 0x1e, 0x09, 0xbe, 0xa3,
3237 0x21, 0x5e, 0x54, 0xf3, 0xb8, 0xa7, 0x14, 0x78, 0xec, 0x76, 0xf8, 0x2c,
3238 0x35, 0x8a, 0x8c, 0x0b, 0xaf, 0xff, 0x61, 0x7c, 0x7f, 0xc0, 0xba, 0x0b,
3239 0x01, 0xff, 0xfe, 0xf1, 0x09, 0x3e, 0xbe, 0x06, 0x3e, 0x66, 0xfb, 0x19,
3240 0xad, 0xbf, 0x34, 0x52, 0x5f, 0x4e, 0x31, 0x4f, 0x7c, 0x7e, 0x2f, 0xd5,
3241 0xc8, 0x26, 0x72, 0xb7, 0xfb, 0xc8, 0x8b, 0xde, 0x44, 0xfc, 0x0e, 0x06,
3242 0x1f, 0x47, 0xf7, 0x8a, 0x2a, 0x75, 0x86, 0x36, 0xbf, 0xc0, 0xba, 0x2d,
3243 0x71, 0x13, 0x5f, 0x6f, 0x0c, 0xb2, 0xb1, 0xb9, 0x9d, 0xeb, 0xfe, 0x8d,
3244 0xf3, 0x19, 0x79, 0xdf, 0xb0, 0xef, 0xfb, 0x11, 0xe7, 0xbb, 0x77, 0x81,
3245 0xc5, 0x3b, 0xe1, 0x34, 0xfd, 0x1e, 0x1c, 0x7b, 0x3b, 0xce, 0x79, 0x93,
3246 0x5c, 0x17, 0xfe, 0xc3, 0x99, 0xc7, 0x67, 0xbd, 0xf7, 0x39, 0x99, 0x2e,
3247 0xd3, 0x57, 0x1d, 0xae, 0x93, 0xa9, 0x7e, 0x2a, 0x8a, 0x2e, 0xe2, 0xdc,
3248 0x5f, 0x19, 0x3b, 0xf7, 0x71, 0x07, 0x3c, 0xc9, 0xf9, 0x7f, 0x96, 0xf3,
3249 0xef, 0x46, 0x33, 0xf3, 0xd6, 0x4d, 0x97, 0x5c, 0xa9, 0xde, 0xe7, 0x7c,
3250 0x6c, 0x98, 0x8b, 0x11, 0x1d, 0x7a, 0x14, 0xc9, 0xf3, 0x7c, 0x36, 0xbd,
3251 0x9b, 0xfa, 0x1c, 0x6d, 0x37, 0x1e, 0xe1, 0x1e, 0x53, 0x8b, 0x7f, 0x17,
3252 0x72, 0xfb, 0x3c, 0x0f, 0x97, 0xf1, 0x0e, 0x39, 0x47, 0x78, 0xd2, 0x6f,
3253 0x35, 0x2a, 0xf0, 0xb5, 0xcc, 0x75, 0x85, 0xe2, 0x7b, 0x21, 0xee, 0x6e,
3254 0x3f, 0x6f, 0x53, 0x12, 0x3b, 0x6a, 0xce, 0x39, 0xac, 0x05, 0x98, 0x88,
3255 0x06, 0x30, 0x9e, 0x47, 0xac, 0xb2, 0xcc, 0x93, 0x72, 0xf2, 0x5b, 0xd5,
3256 0x1a, 0xc6, 0x56, 0x4e, 0x72, 0x2e, 0xf9, 0x51, 0xb4, 0x36, 0x88, 0xcf,
3257 0x44, 0x87, 0xb9, 0xe6, 0x87, 0x07, 0x65, 0x7e, 0xbb, 0x21, 0x7f, 0xeb,
3258 0x98, 0xc7, 0x7c, 0x02, 0x0f, 0x8b, 0xa2, 0x76, 0xc3, 0x14, 0xf5, 0x9e,
3259 0x29, 0x96, 0x7a, 0x32, 0x54, 0x52, 0xc8, 0xd1, 0x14, 0xe7, 0x08, 0x3a,
3260 0xd1, 0x73, 0x58, 0xcb, 0x2d, 0x53, 0xf8, 0xc8, 0xa3, 0xbe, 0xad, 0x58,
3261 0x62, 0x85, 0x76, 0xb1, 0xc7, 0x47, 0x51, 0x72, 0xa7, 0x35, 0x45, 0x6d,
3262 0x38, 0xf7, 0x23, 0xcc, 0xcd, 0x6b, 0x62, 0x2d, 0xf3, 0x79, 0xb6, 0x2c,
3263 0x9d, 0x83, 0x8f, 0xce, 0xf7, 0x77, 0x11, 0x43, 0xf9, 0x3c, 0xcb, 0x23,
3264 0xe6, 0x59, 0x26, 0x5f, 0xf6, 0xef, 0x62, 0xff, 0xef, 0xf4, 0x80, 0x0f,
3265 0x72, 0xc7, 0xb7, 0x87, 0x79, 0x1a, 0x63, 0x58, 0x06, 0x17, 0xd9, 0x3e,
3266 0x8a, 0x82, 0xc5, 0x38, 0x47, 0xc1, 0x5a, 0xe6, 0xca, 0xb7, 0x90, 0xa7,
3267 0xd7, 0x69, 0xa1, 0x5c, 0x8f, 0xdf, 0x11, 0x72, 0x12, 0xfe, 0x5d, 0xc0,
3268 0x12, 0x4d, 0x7c, 0xd7, 0xd2, 0xef, 0x80, 0x73, 0xf8, 0x45, 0x1e, 0x83,
3269 0x73, 0x79, 0xd6, 0xe1, 0x7f, 0x01, 0x17, 0xc6, 0xf1, 0xb2, 0x84, 0x14,
3270 0x00, 0x00, 0x00 };
3271static u32 bnx2_TPAT_b09FwData[(0x0/4) + 1] = { 0x0 };
3272static u32 bnx2_TPAT_b09FwRodata[(0x0/4) + 1] = { 0x0 };
3273static u32 bnx2_TPAT_b09FwBss[(0x250/4) + 1] = { 0x0 };
3274static u32 bnx2_TPAT_b09FwSbss[(0x34/4) + 1] = { 0x0 };
3275
3276static struct fw_info bnx2_tpat_fw_09 = {
3277 .ver_major = 0x1,
3278 .ver_minor = 0x0,
3279 .ver_fix = 0x0,
3280
3281 .start_addr = 0x08000860,
3282
3283 .text_addr = 0x08000800,
3284 .text_len = 0x1480,
3285 .text_index = 0x0,
3286 .gz_text = bnx2_TPAT_b09FwText,
3287 .gz_text_len = sizeof(bnx2_TPAT_b09FwText),
3288
3289 .data_addr = 0x08001ca0,
3290 .data_len = 0x0,
3291 .data_index = 0x0,
3292 .data = bnx2_TPAT_b09FwData,
3293
3294 .sbss_addr = 0x08001ca0,
3295 .sbss_len = 0x34,
3296 .sbss_index = 0x0,
3297 .sbss = bnx2_TPAT_b09FwSbss,
3298
3299 .bss_addr = 0x08001ce0,
3300 .bss_len = 0x250,
3301 .bss_index = 0x0,
3302 .bss = bnx2_TPAT_b09FwBss,
3303
3304 .rodata_addr = 0x00000000,
3305 .rodata_len = 0x0,
3306 .rodata_index = 0x0,
3307 .rodata = bnx2_TPAT_b09FwRodata,
3308};
3309
3310static u8 bnx2_TXP_b09FwText[] = {
3311 0x1f, 0x8b, 0x08, 0x08, 0x51, 0xfe, 0x2f, 0x45, 0x00, 0x03, 0x74, 0x65,
3312 0x73, 0x74, 0x31, 0x2e, 0x62, 0x69, 0x6e, 0x00, 0xcd, 0x7b, 0x7f, 0x70,
3313 0x1b, 0xe7, 0x99, 0xde, 0xbb, 0x0b, 0x80, 0x04, 0x29, 0x8a, 0x5a, 0x31,
3314 0x30, 0x83, 0x38, 0xb4, 0x8d, 0x15, 0x17, 0x34, 0x6d, 0xf2, 0x1c, 0x58,
3315 0xe5, 0xf9, 0xd8, 0x06, 0xb5, 0xd7, 0xc0, 0x92, 0xa2, 0x63, 0x26, 0x47,
3316 0xbb, 0xcc, 0x9d, 0x92, 0x51, 0x7d, 0x28, 0x48, 0x29, 0x6e, 0xe3, 0xb4,
3317 0xaa, 0xe3, 0x3f, 0x34, 0x4d, 0x5b, 0xc3, 0x00, 0x25, 0xcb, 0x2e, 0x44,
3318 0xd0, 0x16, 0x63, 0xa5, 0x33, 0x37, 0x53, 0x18, 0x80, 0x28, 0xe7, 0xba,
3319 0x24, 0xdc, 0xe4, 0x2e, 0xe9, 0x1f, 0xc9, 0x99, 0xa5, 0x6c, 0xc5, 0x6d,
3320 0xae, 0x33, 0xbe, 0x3f, 0xda, 0xa6, 0x37, 0xd7, 0x19, 0x8d, 0xfc, 0x23,
3321 0xce, 0x8f, 0xb9, 0xb8, 0x69, 0x7a, 0x56, 0x5b, 0xd9, 0xe8, 0xf3, 0x7c,
3322 0xbb, 0x4b, 0x82, 0x32, 0x15, 0x5b, 0xd7, 0x76, 0xa6, 0x9c, 0xc1, 0x10,
3323 0xfb, 0xed, 0xb7, 0xdf, 0xf7, 0xfe, 0x7e, 0xdf, 0xe7, 0xfd, 0x16, 0x71,
3324 0x91, 0x6e, 0xf1, 0xff, 0x76, 0xe3, 0x93, 0x38, 0x7a, 0xec, 0xb1, 0x3b,
3325 0xc6, 0xef, 0xd8, 0x2f, 0x72, 0xe7, 0x9d, 0xb2, 0x2b, 0xaa, 0xf3, 0xe6,
3326 0xdb, 0x21, 0x91, 0xdc, 0x4f, 0xe5, 0xaf, 0xfc, 0x87, 0xc7, 0x8d, 0x60,
3327 0x7d, 0x7e, 0x24, 0xaa, 0xa7, 0x5f, 0xcc, 0x64, 0x2c, 0x89, 0x86, 0xd2,
3328 0x33, 0x9f, 0x9d, 0xb3, 0x44, 0x6c, 0x77, 0x24, 0x91, 0x95, 0xf7, 0x5a,
3329 0x85, 0x58, 0x58, 0x38, 0x7e, 0x53, 0xfa, 0xca, 0xe3, 0xdf, 0xff, 0x2d,
3330 0xf3, 0x9d, 0x6a, 0x48, 0xa2, 0x46, 0x3a, 0x27, 0xc6, 0x90, 0x44, 0x07,
3331 0xf0, 0xcc, 0xef, 0xdf, 0x3a, 0xa5, 0x4b, 0x6f, 0xb0, 0x56, 0x5c, 0x16,
3332 0x2a, 0x6f, 0xb7, 0xbe, 0x7f, 0x6b, 0x4c, 0xfe, 0x55, 0xd3, 0x90, 0x17,
3333 0x9b, 0x61, 0x6d, 0xb2, 0xd2, 0x23, 0xa5, 0x8a, 0x2b, 0xc7, 0xcb, 0x05,
3334 0xc9, 0x36, 0x5f, 0x90, 0xe2, 0xb2, 0xd1, 0x9b, 0x39, 0xf7, 0x07, 0x52,
3335 0x5a, 0xee, 0xeb, 0xcd, 0x9e, 0x73, 0xa5, 0x58, 0x8e, 0xf7, 0x66, 0x9a,
3336 0x46, 0x6f, 0xf6, 0x4c, 0x0c, 0xd7, 0x7d, 0xbd, 0x99, 0x33, 0x66, 0x41,
3337 0xa4, 0x1f, 0x73, 0xe2, 0xbd, 0xd9, 0x8a, 0x99, 0x13, 0x19, 0x4c, 0xbd,
3338 0x22, 0x03, 0xbd, 0xd9, 0x66, 0x4d, 0x5b, 0x37, 0x34, 0x29, 0xfe, 0x86,
3339 0x18, 0xbd, 0xe9, 0xcb, 0xad, 0x4f, 0x58, 0x86, 0xec, 0xb5, 0x64, 0xcf,
3340 0x1e, 0x4b, 0x9e, 0x88, 0xa7, 0xa3, 0x92, 0x3f, 0xdd, 0x25, 0xb6, 0xe2,
3341 0xc9, 0x90, 0xfc, 0x99, 0x11, 0x63, 0x43, 0x22, 0x62, 0xc7, 0x82, 0xeb,
3342 0x56, 0x2b, 0x93, 0xfa, 0x02, 0xe5, 0x8a, 0xbd, 0xa4, 0x77, 0xb2, 0x29,
3343 0x92, 0xa9, 0x44, 0x25, 0x93, 0x7a, 0xaf, 0xe5, 0x3d, 0x13, 0xc5, 0xbe,
3344 0xe1, 0xde, 0x89, 0x4a, 0xab, 0xe5, 0xa4, 0xb0, 0x47, 0x2a, 0x78, 0x36,
3345 0x22, 0xd5, 0x98, 0x5d, 0x2d, 0xa5, 0x4c, 0xdd, 0xd3, 0x09, 0x79, 0xe4,
3346 0xb5, 0x2d, 0xba, 0xf5, 0xdb, 0x92, 0x8f, 0x49, 0xb5, 0x98, 0xba, 0x4b,
3347 0x9e, 0x4e, 0x19, 0x72, 0x12, 0xeb, 0x3d, 0x95, 0x82, 0x1c, 0xad, 0x63,
3348 0x5a, 0xa6, 0x69, 0xc6, 0x45, 0x7b, 0x5a, 0x32, 0x67, 0x06, 0x8d, 0xac,
3349 0x60, 0x6f, 0xab, 0x75, 0x4b, 0x26, 0x85, 0xfd, 0x46, 0xff, 0x67, 0xcb,
3350 0x8e, 0x99, 0xb9, 0xaa, 0x0c, 0x48, 0xb1, 0x32, 0x98, 0xfa, 0x13, 0xd1,
3351 0xa4, 0xd3, 0xa2, 0x7c, 0x5a, 0x72, 0x3f, 0xf6, 0xcd, 0x58, 0x18, 0x6f,
3352 0x8a, 0xad, 0x27, 0x23, 0xf2, 0x0f, 0x0c, 0x33, 0x91, 0x09, 0xf5, 0x4b,
3353 0xf1, 0x74, 0x27, 0xe8, 0xb4, 0xfb, 0x74, 0xcc, 0x3d, 0x30, 0x26, 0xb1,
3354 0x5d, 0x22, 0x5a, 0x28, 0x9d, 0xc4, 0xba, 0x22, 0x45, 0x77, 0x00, 0xcf,
3355 0x26, 0xc7, 0x7f, 0x2a, 0x7b, 0x24, 0xb1, 0x37, 0x2c, 0x25, 0xb7, 0x1b,
3356 0x72, 0x34, 0xa0, 0x83, 0xe4, 0xf8, 0x5f, 0x40, 0x29, 0xba, 0x95, 0x8c,
3357 0x1f, 0x93, 0x9c, 0x96, 0x6d, 0x76, 0x48, 0x29, 0x19, 0x95, 0x05, 0xd0,
3358 0xb1, 0x90, 0xfa, 0xa2, 0x96, 0x39, 0x77, 0x50, 0xcb, 0x9e, 0xc3, 0xbc,
3359 0x66, 0xdd, 0xb7, 0x35, 0x03, 0xeb, 0xe8, 0x52, 0x4c, 0x1e, 0xc4, 0xbd,
3360 0xa8, 0xcc, 0x61, 0xde, 0x1c, 0x78, 0x2a, 0x35, 0xf7, 0xc8, 0xfa, 0x6c,
3361 0xac, 0x37, 0x03, 0x1d, 0x16, 0x71, 0xff, 0xb7, 0x67, 0x34, 0x31, 0x2c,
3362 0x5b, 0x7e, 0x3c, 0x06, 0x1d, 0x9e, 0x81, 0xfe, 0xce, 0xc4, 0xe5, 0x78,
3363 0x45, 0x62, 0xba, 0x24, 0xe3, 0x79, 0x79, 0x41, 0xea, 0x2e, 0xf5, 0x0f,
3364 0x7d, 0x42, 0xdf, 0x45, 0x97, 0xcf, 0x41, 0x6f, 0x15, 0x07, 0xf2, 0x98,
3365 0x02, 0x0d, 0x0f, 0x6a, 0xf7, 0xd7, 0x67, 0xb5, 0x03, 0xcd, 0x1f, 0x6b,
3366 0xd2, 0x7d, 0x4c, 0xfb, 0x5c, 0xf3, 0x88, 0xe6, 0xcb, 0x1e, 0xba, 0x8b,
3367 0x8a, 0x3d, 0x13, 0x95, 0x95, 0xa6, 0xa7, 0xbb, 0x1a, 0xec, 0xd3, 0x36,
3368 0x6c, 0xe8, 0xe1, 0x6f, 0x6f, 0xce, 0x59, 0x69, 0xc6, 0x64, 0x01, 0xb4,
3369 0x1d, 0x6f, 0x72, 0xfe, 0xef, 0x41, 0x3f, 0x51, 0x71, 0x6f, 0xed, 0x91,
3370 0x1c, 0xc6, 0x8b, 0x67, 0xc4, 0xce, 0xa4, 0x74, 0x3c, 0xd3, 0x2b, 0x21,
3371 0xab, 0x1f, 0x9f, 0x6e, 0x99, 0xab, 0x77, 0xda, 0x21, 0x2b, 0x26, 0x73,
3372 0x4d, 0xca, 0x10, 0xff, 0x2b, 0x81, 0x1c, 0x49, 0x2b, 0xc7, 0xf9, 0x1c,
3373 0xc7, 0x0d, 0x8c, 0xb7, 0x8f, 0xd1, 0x2e, 0x7a, 0x41, 0x8f, 0x39, 0x2c,
3374 0x18, 0xcb, 0x57, 0x92, 0xc6, 0xe7, 0xf8, 0xbf, 0x49, 0xd9, 0x06, 0x32,
3375 0x0d, 0x63, 0xae, 0x2e, 0xf9, 0x3a, 0xf6, 0x39, 0x7d, 0xa5, 0x15, 0x19,
3376 0xc3, 0xb5, 0xf5, 0x4b, 0xc8, 0x92, 0xfb, 0x86, 0x41, 0x93, 0x2e, 0xb9,
3377 0x3a, 0xd7, 0xe2, 0x7d, 0x81, 0xee, 0x8b, 0x7b, 0x75, 0x19, 0x86, 0x7e,
3378 0x4d, 0xec, 0xd3, 0x85, 0x39, 0x3d, 0x90, 0x1f, 0x78, 0x3d, 0x87, 0xef,
3379 0xe0, 0x5d, 0xb7, 0x74, 0x3c, 0xdf, 0x29, 0x73, 0x29, 0xda, 0x0b, 0xe9,
3380 0xdc, 0x85, 0xb5, 0xbb, 0x64, 0xfe, 0x34, 0xe5, 0x01, 0xbb, 0xaa, 0xc4,
3381 0xa4, 0x74, 0xc6, 0x34, 0x1c, 0x31, 0x21, 0x1b, 0x1b, 0xf3, 0x3a, 0x25,
3382 0x67, 0xb4, 0x5a, 0x13, 0xa9, 0x11, 0xe3, 0x9b, 0xca, 0xce, 0x47, 0x8c,
3383 0xa4, 0x26, 0x85, 0x8e, 0xf4, 0x10, 0x64, 0x6b, 0x1e, 0x14, 0xe1, 0xf5,
3384 0x0f, 0xc4, 0x9e, 0xa5, 0xff, 0xc4, 0xb8, 0x17, 0xfc, 0xa9, 0x1f, 0xf4,
3385 0xd3, 0xe7, 0x06, 0xa0, 0x97, 0xb8, 0xf2, 0x83, 0x89, 0x1d, 0xfd, 0xc0,
3386 0x9c, 0xaa, 0x82, 0xdf, 0xe2, 0xb9, 0x30, 0xfd, 0x2f, 0x05, 0x73, 0x93,
3387 0x5d, 0x56, 0x14, 0xb6, 0x40, 0x5a, 0xc6, 0xb1, 0x7e, 0xab, 0xf5, 0xd9,
3388 0x94, 0x47, 0x53, 0xf1, 0x8c, 0x8d, 0x67, 0xc3, 0x90, 0xbb, 0xf9, 0x70,
3389 0x42, 0xed, 0x3f, 0xee, 0xef, 0x6f, 0xc8, 0x1c, 0xe8, 0x2e, 0x56, 0x42,
3390 0x92, 0x35, 0xb8, 0xc6, 0x9f, 0x71, 0x3c, 0xe7, 0xad, 0x05, 0xbb, 0x3d,
3391 0x35, 0x68, 0xdc, 0x07, 0x5f, 0xa2, 0x8f, 0x15, 0x57, 0x29, 0x63, 0xac,
3392 0x33, 0x46, 0x19, 0x1b, 0x8a, 0xc6, 0xcc, 0x19, 0xda, 0x91, 0x0c, 0x84,
3393 0x84, 0x76, 0x8e, 0x98, 0x01, 0xbb, 0x2a, 0xf9, 0x76, 0x95, 0x77, 0xa9,
3394 0xff, 0xbb, 0x7d, 0xff, 0xd4, 0x65, 0x28, 0x49, 0x7b, 0x7f, 0x5a, 0xb2,
3395 0xf0, 0xf1, 0x39, 0xec, 0x54, 0x07, 0x4f, 0xb5, 0xca, 0x20, 0x64, 0x15,
3396 0xf8, 0x1d, 0xf4, 0x3b, 0xfa, 0x6e, 0x2b, 0x88, 0x05, 0xc5, 0x0a, 0x7d,
3397 0xa6, 0x68, 0xe8, 0x52, 0xc0, 0x07, 0x76, 0x63, 0x99, 0xc3, 0x99, 0x90,
3398 0x39, 0x93, 0x03, 0x6d, 0xb0, 0x7b, 0xc9, 0xdc, 0x49, 0x7b, 0xc6, 0x9c,
3399 0xa6, 0xec, 0x0f, 0xfc, 0xac, 0xe6, 0x52, 0x4f, 0xdd, 0xd8, 0x37, 0xa0,
3400 0x29, 0x8c, 0x31, 0xae, 0x13, 0x85, 0xcd, 0x07, 0x36, 0x43, 0xfb, 0x33,
3401 0xed, 0x75, 0xe9, 0x90, 0xe1, 0x24, 0x62, 0xd9, 0x19, 0x1d, 0xfa, 0x1b,
3402 0x40, 0x4c, 0x09, 0xcb, 0x11, 0xc8, 0xea, 0x4b, 0x15, 0xd2, 0xe7, 0xc0,
3403 0xef, 0x10, 0xdb, 0xce, 0x4c, 0xc2, 0xcf, 0xa6, 0xb4, 0x09, 0xf8, 0xc4,
3404 0x67, 0xea, 0xa4, 0xa9, 0x25, 0xf4, 0x4b, 0xe7, 0x5c, 0x4e, 0x9b, 0x6c,
3405 0x1e, 0xd4, 0xa6, 0xce, 0xd1, 0x4f, 0xe8, 0x23, 0xa6, 0xf1, 0x80, 0x78,
3406 0x3c, 0x14, 0x9b, 0xaf, 0x68, 0xf4, 0xd5, 0xe2, 0xa9, 0x2e, 0xd0, 0xb1,
3407 0x0b, 0xf4, 0x18, 0xf0, 0x3d, 0xd8, 0x97, 0x65, 0xce, 0xd0, 0x66, 0x9c,
3408 0xa4, 0x95, 0xf8, 0xe7, 0xf2, 0x41, 0x39, 0x4c, 0x6c, 0xca, 0x61, 0x04,
3409 0x32, 0xd9, 0x2e, 0x87, 0x85, 0x0f, 0xca, 0xc1, 0x2e, 0x40, 0x0e, 0x0b,
3410 0x88, 0x43, 0x0b, 0x4d, 0xf2, 0xdc, 0x12, 0xfd, 0x4e, 0x81, 0x75, 0xca,
3411 0xbd, 0x7a, 0x9a, 0x36, 0x4a, 0x3f, 0x49, 0x26, 0x4a, 0x58, 0xa1, 0xe1,
3412 0xf6, 0x28, 0xdf, 0x98, 0x54, 0xb2, 0xf8, 0x30, 0x7e, 0xc9, 0xdf, 0x16,
3413 0xcf, 0x53, 0x75, 0xc6, 0x1b, 0xd8, 0x79, 0xd2, 0x32, 0xbe, 0x20, 0x5b,
3414 0x7c, 0xdf, 0xb7, 0xc5, 0x37, 0xf6, 0x09, 0x62, 0x10, 0x79, 0x0e, 0xe2,
3415 0x31, 0x6d, 0xe5, 0xa5, 0x56, 0xc8, 0xb2, 0xa0, 0x03, 0xda, 0x0b, 0x69,
3416 0x30, 0x8d, 0xcf, 0x0a, 0xfe, 0x23, 0x2e, 0xd0, 0x97, 0x72, 0x6a, 0x5e,
3417 0x87, 0xe4, 0xf6, 0x7a, 0xf3, 0xe7, 0x2a, 0xad, 0x5f, 0xe8, 0xe9, 0xf7,
3418 0x5b, 0x99, 0x31, 0xcb, 0xf7, 0xf1, 0xa8, 0x7c, 0xb9, 0x6e, 0xe6, 0x12,
3419 0x5a, 0x8f, 0x14, 0x6e, 0x40, 0x5c, 0xa9, 0xd0, 0x3f, 0xfa, 0xaf, 0x11,
3420 0xcb, 0x06, 0xfc, 0x58, 0xf6, 0x13, 0xc8, 0x9e, 0xb9, 0xe7, 0xf0, 0xfb,
3421 0xeb, 0x31, 0xfe, 0x4f, 0x1a, 0x33, 0xf2, 0x05, 0xe6, 0x9b, 0x3d, 0xba,
3422 0x8a, 0xdf, 0x16, 0x73, 0x41, 0x21, 0x9c, 0xee, 0x96, 0xc2, 0x5e, 0x29,
3423 0x84, 0xd2, 0xf4, 0x23, 0xfa, 0x46, 0x87, 0x4f, 0x77, 0x90, 0x3b, 0xf8,
3424 0x77, 0x4c, 0x17, 0x8b, 0x73, 0x90, 0x27, 0x2a, 0xe4, 0xe3, 0xbd, 0x40,
3425 0x27, 0x78, 0x46, 0x22, 0x9e, 0xcd, 0x4d, 0x23, 0x66, 0x52, 0xa6, 0xed,
3426 0xf6, 0xc2, 0x58, 0x2a, 0x09, 0xdd, 0x62, 0x2c, 0x15, 0x23, 0x94, 0x7e,
3427 0x50, 0xb3, 0xeb, 0x5f, 0xd4, 0x6c, 0xc8, 0xce, 0x86, 0xec, 0x6c, 0xc8,
3428 0x2e, 0x03, 0xd9, 0x65, 0x9b, 0xa4, 0x87, 0xb4, 0x78, 0xeb, 0x3b, 0xde,
3429 0xfa, 0xa0, 0xb3, 0x5f, 0xf2, 0xca, 0xc7, 0xc9, 0x2f, 0x62, 0xb2, 0x8a,
3430 0x07, 0x93, 0x9a, 0x17, 0x0f, 0xb8, 0xde, 0x14, 0x9e, 0xbf, 0x1b, 0x79,
3431 0xce, 0xd6, 0x75, 0x6b, 0x4b, 0x26, 0x0b, 0x6d, 0x32, 0x29, 0xb9, 0x94,
3432 0x11, 0xe7, 0xd3, 0x97, 0x5d, 0xe8, 0x3d, 0x90, 0xcb, 0x34, 0x68, 0xe8,
3433 0x24, 0xef, 0x3e, 0x1f, 0x5c, 0xbf, 0xcf, 0x5f, 0xff, 0xd3, 0x58, 0x93,
3434 0xbe, 0xbb, 0xd3, 0xbe, 0xdc, 0x93, 0xb9, 0xf4, 0xd7, 0xf1, 0x83, 0x5a,
3435 0x02, 0x31, 0xfa, 0x45, 0xf8, 0xda, 0xc5, 0x50, 0x5c, 0xbe, 0x7f, 0xeb,
3436 0x6b, 0xa8, 0x2f, 0xa4, 0x70, 0x63, 0xba, 0x95, 0x08, 0xa7, 0xdf, 0x6b,
3437 0x2d, 0x8c, 0x21, 0x7e, 0xa6, 0xcd, 0x78, 0x26, 0x34, 0x2a, 0x2f, 0x35,
3438 0x87, 0xe5, 0x3b, 0x4d, 0x4b, 0xfe, 0xa8, 0x99, 0x90, 0x3f, 0x6c, 0x0e,
3439 0xc8, 0xb7, 0x9b, 0x71, 0xf9, 0x56, 0x33, 0xa8, 0x45, 0xe2, 0xb4, 0xa5,
3440 0x5e, 0xa7, 0xb9, 0x53, 0x3d, 0x04, 0x3b, 0xc7, 0x5a, 0x99, 0xb1, 0x70,
3441 0x2e, 0x94, 0x56, 0x35, 0xc2, 0xcc, 0xd1, 0xf2, 0xe3, 0x2d, 0xdd, 0xb2,
3442 0x0a, 0xba, 0xde, 0x33, 0x6e, 0xdc, 0x25, 0x39, 0x3d, 0x8d, 0x31, 0x77,
3443 0x3c, 0xec, 0x94, 0xbb, 0x90, 0x5f, 0xa2, 0xa8, 0x65, 0x06, 0xa4, 0x80,
3444 0x75, 0x0b, 0xcd, 0x56, 0x6b, 0x29, 0xf5, 0x0f, 0x3f, 0x65, 0xfc, 0x8d,
3445 0x7f, 0xd9, 0x29, 0xbd, 0xdf, 0x5e, 0x37, 0x86, 0xfe, 0xbb, 0x5f, 0x0f,
3446 0xa1, 0xc6, 0xea, 0x57, 0x8b, 0xe7, 0xb4, 0xf4, 0xa8, 0x93, 0x70, 0x37,
3447 0x70, 0x5f, 0xa2, 0xfd, 0xd6, 0xcf, 0x51, 0x85, 0xc8, 0xee, 0x98, 0xc5,
3448 0x9a, 0x6b, 0x26, 0xfb, 0x79, 0xfc, 0xff, 0x58, 0x5a, 0xf6, 0xf4, 0xe1,
3449 0xff, 0xde, 0x34, 0x4c, 0x2a, 0xcd, 0x98, 0xac, 0xb5, 0xc5, 0x64, 0xd1,
3450 0x1c, 0xe4, 0xdf, 0x05, 0xf0, 0xe4, 0x40, 0x1e, 0xbf, 0xd3, 0x8c, 0x6a,
3451 0xd9, 0xd3, 0xfd, 0x52, 0xaa, 0x33, 0xaf, 0x71, 0x5e, 0xd4, 0xaf, 0x7b,
3452 0x78, 0xdd, 0x81, 0x6b, 0x41, 0xae, 0xf9, 0x94, 0x48, 0xaf, 0xf9, 0xa3,
3453 0xcf, 0x4b, 0xdd, 0xaf, 0x5b, 0x22, 0xb2, 0xac, 0x6c, 0x8c, 0xe3, 0xaf,
3454 0x65, 0xbf, 0x36, 0xb4, 0x35, 0xfe, 0xec, 0xe6, 0xf8, 0x3b, 0xd9, 0x4f,
3455 0x6f, 0x8e, 0x77, 0x87, 0x3d, 0x1e, 0xc6, 0xb5, 0x99, 0x66, 0xc1, 0x1f,
3456 0xbb, 0x0c, 0xb9, 0xb7, 0x5a, 0x0b, 0xc8, 0x3d, 0x45, 0xeb, 0x32, 0xea,
3457 0x24, 0xc6, 0x9f, 0xeb, 0x89, 0x37, 0xdb, 0x62, 0x8d, 0x91, 0x09, 0x51,
3458 0x9f, 0x51, 0xf1, 0xd6, 0xe4, 0xfd, 0x4e, 0xc4, 0x9d, 0xcb, 0xf8, 0xce,
3459 0x3c, 0x17, 0xc4, 0x3c, 0xce, 0xe1, 0xf3, 0x6f, 0x5f, 0x43, 0xe7, 0x31,
3460 0xe8, 0xfc, 0xff, 0x1b, 0xdd, 0xe2, 0x4f, 0xe9, 0x56, 0xc5, 0x9d, 0x97,
3461 0xb6, 0xd9, 0x2c, 0xe9, 0xef, 0xf6, 0x69, 0x96, 0x68, 0x38, 0x6d, 0x38,
3462 0x0b, 0xd6, 0x8d, 0x12, 0x41, 0x0d, 0x4b, 0x9b, 0x2d, 0x35, 0xbf, 0x8b,
3463 0xe7, 0x99, 0x27, 0x25, 0x1a, 0x49, 0xd3, 0x2e, 0xd6, 0x07, 0x32, 0xd6,
3464 0x31, 0xa7, 0xe6, 0x1e, 0x73, 0xce, 0x2a, 0x3b, 0x59, 0xbf, 0xc9, 0xab,
3465 0xcd, 0x7f, 0x74, 0x13, 0x6a, 0x73, 0x3c, 0xcf, 0x98, 0xcb, 0xf1, 0x46,
3466 0x4f, 0xc6, 0x62, 0x0e, 0x5a, 0x72, 0x8a, 0xf8, 0x2c, 0xa8, 0xb9, 0xaf,
3467 0x0e, 0x70, 0x6e, 0x67, 0x3a, 0x76, 0xd3, 0x8f, 0xf1, 0xbf, 0x23, 0xfd,
3468 0xce, 0x4d, 0x17, 0x2c, 0xae, 0x3b, 0x75, 0xd3, 0x59, 0xb5, 0x46, 0x18,
3469 0xf1, 0x8c, 0xf3, 0x2e, 0xdf, 0xc4, 0x67, 0x9f, 0x44, 0x1c, 0x3f, 0xe1,
3470 0x42, 0x97, 0xee, 0x8b, 0x4e, 0x1e, 0x9f, 0x39, 0xd2, 0x54, 0xe1, 0x7d,
3471 0xe3, 0xe6, 0x8c, 0x15, 0x56, 0xf9, 0xf6, 0x4b, 0x98, 0x73, 0x04, 0x73,
3472 0x0e, 0xbb, 0x01, 0x3f, 0xea, 0xbe, 0x93, 0xc5, 0xfd, 0xc3, 0x65, 0xc3,
3473 0x71, 0xca, 0xe6, 0x38, 0x6a, 0x8e, 0xf8, 0x71, 0xe4, 0xe3, 0x1c, 0x72,
3474 0xa0, 0x2d, 0xe6, 0x70, 0x41, 0xd2, 0x5d, 0x93, 0xa8, 0xe5, 0x56, 0x90,
3475 0x4f, 0x50, 0x87, 0xa4, 0xaa, 0x32, 0xd8, 0x95, 0x39, 0xad, 0xc3, 0x3e,
3476 0xef, 0x80, 0xbd, 0x1a, 0x8e, 0x9e, 0x44, 0x5c, 0x47, 0xdc, 0x5c, 0xa8,
3477 0x58, 0x5a, 0xb6, 0x3c, 0x68, 0x94, 0xe4, 0x56, 0x59, 0x37, 0xcc, 0xf8,
3478 0xa4, 0xec, 0x92, 0x6c, 0x18, 0xf3, 0x86, 0x3f, 0x2e, 0xb9, 0xb8, 0x86,
3479 0xd8, 0x70, 0x03, 0xe2, 0x16, 0xeb, 0xe4, 0xf6, 0x18, 0xfa, 0x0b, 0x11,
3480 0xeb, 0x8b, 0x21, 0xc6, 0x9e, 0x4e, 0x8b, 0x75, 0x3f, 0xe7, 0xed, 0x92,
3481 0x8d, 0x0f, 0xcc, 0x7b, 0xb7, 0x6d, 0x5e, 0xfb, 0xf8, 0x7b, 0x18, 0xdf,
3482 0x25, 0x17, 0x41, 0x47, 0x38, 0x39, 0x26, 0x25, 0xf0, 0x10, 0x39, 0xd5,
3483 0x6a, 0x5d, 0x00, 0x3f, 0x3a, 0xf8, 0x2f, 0x56, 0x59, 0x0b, 0x84, 0xa4,
3484 0x6a, 0xe0, 0x9e, 0xdb, 0x6a, 0xd5, 0x10, 0x46, 0xf5, 0x55, 0xd2, 0x1c,
3485 0x95, 0x49, 0x77, 0x48, 0xec, 0x06, 0xe5, 0x60, 0xc2, 0xeb, 0xfe, 0xac,
3486 0x2b, 0x7b, 0x86, 0x39, 0x13, 0x16, 0xb1, 0xfa, 0xe7, 0x5d, 0x19, 0xe4,
3487 0x3e, 0x7d, 0xf5, 0x62, 0x57, 0x16, 0x7a, 0x0f, 0xad, 0xfe, 0xe7, 0x2e,
3488 0xe7, 0x34, 0xe9, 0x0a, 0x21, 0xf7, 0xdd, 0x22, 0x45, 0xa3, 0x25, 0xdf,
3489 0x44, 0x8d, 0x50, 0x1c, 0x46, 0x2e, 0x83, 0x17, 0xe8, 0xa0, 0xbb, 0x60,
3490 0x48, 0xb4, 0x3b, 0xfd, 0x7d, 0xd0, 0x37, 0x06, 0xd9, 0xec, 0xc2, 0x9c,
3491 0x10, 0xc6, 0x87, 0xf0, 0xbf, 0x7d, 0xfc, 0x8d, 0x2e, 0xe4, 0x05, 0xc4,
3492 0x60, 0x89, 0x66, 0xc6, 0x7a, 0xb0, 0xfe, 0xf7, 0x30, 0x8e, 0x09, 0xc9,
3493 0xcd, 0xf1, 0x27, 0xbc, 0xf1, 0xb7, 0x41, 0x0b, 0x9f, 0x63, 0x8d, 0x22,
3494 0xd1, 0xb9, 0x31, 0x03, 0x34, 0x70, 0x6e, 0x4c, 0xcd, 0x75, 0xce, 0xd0,
3495 0x06, 0x0c, 0xa7, 0x66, 0xdd, 0x2c, 0xd9, 0xe5, 0x7e, 0x99, 0x5c, 0xee,
3496 0x93, 0x03, 0xcb, 0xe6, 0x4c, 0x95, 0xd8, 0x0f, 0x3c, 0x0b, 0xea, 0x30,
3497 0x7d, 0x55, 0x20, 0x01, 0x33, 0x7e, 0x44, 0x06, 0xe3, 0x5f, 0x92, 0x5f,
3498 0xb6, 0x90, 0xef, 0x91, 0xeb, 0x7b, 0x24, 0xac, 0xd6, 0x89, 0x07, 0x7b,
3499 0xd2, 0x46, 0xb7, 0xed, 0xeb, 0x9c, 0xb9, 0xd6, 0xba, 0x70, 0xfe, 0xd5,
3500 0xf8, 0x55, 0xeb, 0xfe, 0x85, 0xbf, 0xae, 0x81, 0x75, 0x07, 0xb0, 0x26,
3501 0x79, 0x34, 0xbb, 0x26, 0x4e, 0x8b, 0xdd, 0x09, 0xfa, 0x9c, 0xe4, 0x8d,
3502 0xc0, 0x86, 0xfd, 0x72, 0x62, 0x99, 0xf1, 0x42, 0xfa, 0xf1, 0x19, 0x8d,
3503 0x48, 0x72, 0xf8, 0x1c, 0xea, 0xae, 0x09, 0xb5, 0x86, 0x57, 0x93, 0xe9,
3504 0xab, 0x29, 0xd4, 0xc4, 0x3f, 0x05, 0x3d, 0xac, 0x15, 0xc8, 0x73, 0x18,
3505 0xfc, 0xa6, 0x50, 0x8b, 0x11, 0x47, 0xb5, 0x1e, 0xcf, 0xa4, 0xf0, 0xfd,
3506 0x5c, 0xa2, 0x2b, 0x8b, 0x98, 0x08, 0xff, 0xbe, 0x39, 0xa4, 0x72, 0x18,
3507 0xf5, 0x32, 0xda, 0x45, 0x3c, 0x83, 0xe7, 0xa1, 0x27, 0xca, 0x68, 0xbc,
3508 0xcb, 0xa9, 0x50, 0x46, 0x02, 0x7a, 0x2c, 0xd8, 0x64, 0x58, 0x61, 0x29,
3509 0x7d, 0xd5, 0xc6, 0xbc, 0xb7, 0x42, 0xac, 0x77, 0x33, 0x16, 0xbf, 0x23,
3510 0xe6, 0xac, 0x4e, 0x61, 0x2e, 0xbf, 0xdf, 0x85, 0x75, 0x07, 0x87, 0x8b,
3511 0xd2, 0x31, 0x7c, 0x18, 0xf1, 0x4e, 0x1f, 0x1b, 0x01, 0x6d, 0xb4, 0xf3,
3512 0x16, 0xb0, 0xc0, 0x6f, 0x81, 0x1f, 0xf8, 0x46, 0xd2, 0x92, 0xf9, 0x25,
3513 0xca, 0x55, 0x3e, 0x0e, 0x1e, 0xc0, 0x7f, 0x12, 0x71, 0x8d, 0x3c, 0x70,
3514 0x6f, 0x41, 0x8e, 0xbe, 0x5b, 0xf2, 0x4b, 0x51, 0x55, 0xeb, 0xdb, 0x06,
3515 0xf7, 0xd7, 0x34, 0x3d, 0xdd, 0x0d, 0x1d, 0x93, 0xb7, 0x1c, 0x68, 0x7b,
3516 0x0c, 0x79, 0x80, 0xbc, 0x91, 0x2f, 0xfa, 0xca, 0x28, 0xfc, 0x84, 0xf4,
3517 0xfb, 0xb6, 0xa7, 0xad, 0x23, 0xa6, 0xa8, 0x38, 0x98, 0xca, 0x20, 0xb0,
3518 0xbd, 0xd4, 0x1c, 0x97, 0x3f, 0x6e, 0x8e, 0xc9, 0x77, 0x9b, 0x29, 0xe4,
3519 0xc0, 0x51, 0xe4, 0xc0, 0x61, 0xe4, 0x40, 0x0b, 0x39, 0x30, 0x81, 0x1c,
3520 0x38, 0x80, 0x1c, 0x18, 0x47, 0x9c, 0x14, 0x39, 0xa1, 0xf2, 0x6d, 0x2c,
3521 0x0a, 0xcc, 0x1d, 0xb5, 0x9b, 0x0e, 0x78, 0x99, 0xc1, 0x5e, 0xb3, 0xe0,
3522 0xeb, 0x50, 0xd7, 0x44, 0x65, 0x1c, 0x31, 0xd7, 0x42, 0x3c, 0x4a, 0x20,
3523 0xdf, 0x8c, 0x01, 0x6b, 0x89, 0x6c, 0x2c, 0x25, 0x10, 0x13, 0x5b, 0xe2,
3524 0x00, 0x13, 0x97, 0x8c, 0x14, 0x9e, 0xdd, 0xab, 0xec, 0x33, 0x94, 0xbe,
3525 0x3b, 0x2c, 0xdd, 0xa3, 0x92, 0x2f, 0x9f, 0xc4, 0x58, 0x1c, 0xeb, 0x75,
3526 0x21, 0x2f, 0x31, 0x2e, 0x30, 0x06, 0x2c, 0x39, 0xbf, 0x6b, 0xd1, 0xd7,
3527 0xba, 0xb5, 0xcc, 0xe9, 0x82, 0x30, 0x96, 0x23, 0x0f, 0xc0, 0x1e, 0x38,
3528 0x36, 0x89, 0xe7, 0xf8, 0xfd, 0x2f, 0xfd, 0x98, 0xf9, 0xb1, 0x4e, 0x81,
3529 0xd1, 0xbe, 0xc4, 0x9c, 0x67, 0x61, 0x3d, 0xb7, 0xdd, 0x4f, 0x9f, 0x47,
3530 0xad, 0x14, 0xdc, 0x27, 0xae, 0x66, 0x3f, 0xe1, 0x24, 0x68, 0x1e, 0x04,
3531 0xbe, 0x47, 0x6d, 0x75, 0xb0, 0x8a, 0xef, 0xed, 0xf3, 0x5d, 0xcc, 0x57,
3532 0x63, 0x51, 0x23, 0x6d, 0xb1, 0x9e, 0x43, 0xac, 0x3c, 0x86, 0xb8, 0x68,
3533 0x3b, 0xfa, 0x5a, 0x03, 0x7c, 0x42, 0x8e, 0x65, 0xdb, 0x09, 0x0f, 0xbd,
3534 0xd6, 0x7a, 0xd6, 0x1a, 0x96, 0x89, 0xb5, 0x31, 0xc9, 0xae, 0x0d, 0xc6,
3535 0xcf, 0x4b, 0xd7, 0x65, 0x5b, 0x5e, 0x6b, 0x95, 0x5c, 0xf3, 0xa4, 0x0d,
3536 0xbb, 0xdc, 0xb7, 0xdf, 0x90, 0x1a, 0x30, 0xdc, 0xbe, 0xfd, 0x9d, 0xac,
3537 0xe9, 0x5f, 0x14, 0x3d, 0x21, 0x99, 0x45, 0x5b, 0xc6, 0xf6, 0x07, 0xb5,
3538 0xe7, 0x2f, 0x3b, 0xa4, 0x1b, 0x63, 0x6b, 0x09, 0xcc, 0x61, 0xdd, 0xaf,
3539 0xfa, 0x27, 0xe0, 0x59, 0xf3, 0x9e, 0x51, 0x39, 0x8f, 0x98, 0x19, 0xbc,
3540 0x37, 0x6d, 0xe7, 0xfc, 0x22, 0x70, 0x0d, 0xe4, 0x99, 0x59, 0x24, 0xee,
3541 0xda, 0x05, 0x39, 0x45, 0x60, 0x23, 0xd4, 0xfd, 0x20, 0x9e, 0x6d, 0xc9,
3542 0x57, 0x53, 0xb4, 0x87, 0xc7, 0x20, 0x4b, 0xac, 0x15, 0x0e, 0xf8, 0xf9,
3543 0x9a, 0xcc, 0x2d, 0x51, 0x7e, 0x71, 0xd4, 0x96, 0xdc, 0x5b, 0xa2, 0x5d,
3544 0xe9, 0xab, 0xeb, 0x46, 0xdb, 0xd9, 0x58, 0xc4, 0xfa, 0x43, 0xc4, 0xd8,
3545 0x88, 0xd5, 0x65, 0xf6, 0x06, 0x58, 0x53, 0x1d, 0x80, 0x4e, 0xa6, 0x15,
3546 0xe6, 0xce, 0xd4, 0x53, 0x62, 0x9d, 0x62, 0xac, 0x92, 0x44, 0xc8, 0x22,
3547 0xbe, 0x17, 0x43, 0x4f, 0xcf, 0xe2, 0x1e, 0xe5, 0xc9, 0x5a, 0x1f, 0xf7,
3548 0x57, 0xff, 0xa3, 0xd2, 0x49, 0x08, 0xba, 0xcb, 0xef, 0x67, 0x11, 0x22,
3549 0x4b, 0xa1, 0x34, 0x62, 0xe0, 0x18, 0x79, 0x50, 0x7b, 0xa3, 0x9e, 0xa4,
3550 0xdf, 0x81, 0x67, 0xd8, 0x46, 0x5b, 0x5d, 0xa9, 0xfe, 0x4a, 0x95, 0x08,
3551 0x6c, 0x59, 0x0a, 0x91, 0x34, 0x78, 0x1a, 0xc3, 0x77, 0x38, 0xff, 0x09,
3552 0xe8, 0xf3, 0x2c, 0x9e, 0x5f, 0x00, 0x5f, 0x1b, 0x65, 0xd2, 0x9d, 0x4c,
3553 0x1c, 0x57, 0xbe, 0x8b, 0x6b, 0x97, 0xb5, 0xcc, 0xd7, 0xe4, 0xbc, 0xe2,
3554 0xef, 0x13, 0xac, 0x9d, 0xa1, 0xa7, 0xeb, 0xe1, 0x6f, 0xf2, 0x3a, 0xf9,
3555 0xf3, 0xd6, 0x67, 0xce, 0xca, 0x58, 0x09, 0xc9, 0x96, 0x5f, 0x6a, 0x85,
3556 0x2d, 0x2b, 0x3e, 0xef, 0xeb, 0x31, 0xeb, 0x46, 0x41, 0x07, 0xfb, 0x00,
3557 0xfb, 0x95, 0x2e, 0x41, 0x07, 0x6d, 0xa7, 0x10, 0x4d, 0x3f, 0x2e, 0x2b,
3558 0x4b, 0xff, 0x54, 0x6a, 0x4b, 0x05, 0xa9, 0x2f, 0xfd, 0x23, 0x39, 0xb7,
3559 0xd4, 0x92, 0x0b, 0x29, 0x15, 0x93, 0xac, 0x0e, 0xe5, 0xcf, 0x72, 0xa3,
3560 0x87, 0x07, 0x93, 0xe3, 0x97, 0x20, 0xc0, 0x95, 0xaa, 0x47, 0xfb, 0x54,
3561 0x1b, 0xed, 0x17, 0x60, 0x6b, 0xaf, 0x58, 0xa4, 0x7f, 0x4c, 0x6a, 0x65,
3562 0xd2, 0xfe, 0xa0, 0xa2, 0xfd, 0xc0, 0x26, 0xed, 0x92, 0x0b, 0x59, 0xa4,
3563 0x7f, 0x27, 0xda, 0x81, 0xf3, 0xfb, 0x49, 0x7f, 0x02, 0xcf, 0x7e, 0xd0,
3564 0xfe, 0x6a, 0xee, 0x6b, 0xad, 0x8d, 0x72, 0x44, 0xd1, 0x1c, 0x4a, 0x8f,
3565 0x41, 0x3e, 0xaf, 0xb5, 0xd6, 0x5d, 0xfa, 0x11, 0xbe, 0xbb, 0xf7, 0x20,
3566 0x46, 0xf5, 0x61, 0xaf, 0x5e, 0xc9, 0xcf, 0x46, 0x11, 0x27, 0xc7, 0xa1,
3567 0xdb, 0x2e, 0xe5, 0x87, 0x08, 0x17, 0xd0, 0xd9, 0x34, 0xe6, 0x1f, 0xa2,
3568 0xbf, 0x29, 0xb9, 0x38, 0x90, 0x4b, 0xb1, 0x9c, 0x8e, 0xa0, 0xfe, 0xc7,
3569 0x3e, 0x86, 0x93, 0x73, 0xf9, 0xcc, 0x00, 0x62, 0x1a, 0xff, 0x7f, 0x64,
3570 0x7b, 0x28, 0x20, 0xd6, 0x42, 0xe7, 0x3d, 0x90, 0x1f, 0xe8, 0x18, 0x9b,
3571 0x41, 0x6e, 0x4d, 0x0e, 0xd7, 0x54, 0x7f, 0x91, 0x71, 0xe5, 0x28, 0xf2,
3572 0xe9, 0x21, 0x7c, 0xbc, 0xfd, 0x26, 0x9a, 0xdc, 0x73, 0x3b, 0x4f, 0x45,
3573 0x77, 0x7d, 0x2f, 0x01, 0x52, 0xa6, 0xc9, 0x7d, 0x0b, 0x12, 0x4a, 0x87,
3574 0xb0, 0x2f, 0xc7, 0x7a, 0x10, 0x63, 0x06, 0xa2, 0xd9, 0xe6, 0xcf, 0x31,
3575 0x4e, 0x5f, 0x66, 0x7c, 0x0f, 0x68, 0x1f, 0xc5, 0x9a, 0x8c, 0xbb, 0x63,
3576 0xe0, 0x99, 0x35, 0x26, 0xe3, 0x26, 0xf2, 0x48, 0xe3, 0x47, 0xcc, 0x2d,
3577 0xf8, 0x3e, 0xe0, 0x7f, 0xe7, 0x7d, 0x89, 0xde, 0x9c, 0x36, 0xab, 0x05,
3578 0x31, 0xb1, 0x27, 0x74, 0x6e, 0xc5, 0xa5, 0xd8, 0x30, 0x5f, 0x20, 0x66,
3579 0xd4, 0x29, 0x83, 0x35, 0xca, 0x89, 0xfd, 0x27, 0xd4, 0x7f, 0xb5, 0xe7,
3580 0x21, 0x8f, 0xa8, 0xec, 0xb5, 0x0e, 0x22, 0xa6, 0x80, 0xfe, 0xca, 0x18,
3581 0x78, 0x63, 0x8f, 0x66, 0x10, 0xf9, 0x2b, 0x04, 0x21, 0xa0, 0x96, 0x5a,
3582 0x0b, 0xc9, 0xbd, 0xe1, 0x11, 0xa3, 0x28, 0x8f, 0x46, 0x58, 0x36, 0x17,
3583 0xd6, 0x98, 0x07, 0xc2, 0xb2, 0xb0, 0x26, 0x72, 0x69, 0x91, 0x71, 0x45,
3584 0xfd, 0x41, 0xe6, 0x86, 0x33, 0x8f, 0x3c, 0x5b, 0x5a, 0x62, 0x8c, 0x61,
3585 0x9c, 0xb8, 0x01, 0xba, 0x48, 0x7e, 0xe3, 0xab, 0xc8, 0x49, 0xa5, 0xf2,
3586 0x20, 0x62, 0xa6, 0xac, 0xeb, 0x90, 0x29, 0x72, 0x19, 0x6b, 0xd4, 0x1d,
3587 0xfa, 0x32, 0x41, 0x4f, 0x26, 0x2a, 0xc5, 0x45, 0xf6, 0x63, 0xa2, 0xa0,
3588 0x85, 0x35, 0x76, 0x48, 0xd5, 0x3f, 0x37, 0xa8, 0xd8, 0xca, 0xff, 0xe1,
3589 0xb6, 0x7d, 0x93, 0x27, 0xf7, 0xe9, 0x8c, 0x63, 0x37, 0x8b, 0x3d, 0x63,
3590 0x77, 0x1d, 0xa8, 0x74, 0x48, 0xb5, 0x8f, 0x76, 0x49, 0xfd, 0xbf, 0xa0,
3591 0x62, 0xed, 0x02, 0x78, 0x2a, 0x2e, 0x12, 0xe3, 0x86, 0x31, 0x2f, 0xe6,
3592 0xcf, 0xa3, 0x5c, 0xff, 0x89, 0xcc, 0xed, 0x7f, 0x17, 0x74, 0x79, 0x71,
3593 0x2d, 0xbf, 0x1f, 0xf1, 0x76, 0x46, 0x97, 0x3b, 0xef, 0x1a, 0xc7, 0xb3,
3594 0xcc, 0x81, 0xef, 0xf8, 0x78, 0x92, 0x63, 0xec, 0x61, 0x81, 0xbe, 0x15,
3595 0x03, 0xff, 0xfb, 0xa4, 0xb0, 0x12, 0x85, 0x1c, 0x90, 0x4b, 0x6b, 0xde,
3596 0x5a, 0xac, 0x77, 0x4f, 0x42, 0x47, 0xfa, 0xa9, 0xa8, 0x44, 0x4e, 0xf5,
3597 0x49, 0xf8, 0xeb, 0xdd, 0xd2, 0xf1, 0xf5, 0x21, 0x09, 0x7d, 0xdd, 0x64,
3598 0x4e, 0x4f, 0x9c, 0x80, 0xbe, 0xe6, 0x65, 0x5c, 0x9e, 0x44, 0xde, 0x62,
3599 0x5e, 0x57, 0x76, 0x6a, 0xf4, 0x4b, 0x08, 0x05, 0xab, 0xfe, 0x8c, 0x2d,
3600 0x8f, 0xee, 0xff, 0x85, 0xea, 0x33, 0x01, 0xc3, 0x8b, 0xfe, 0xfc, 0x94,
3601 0xd8, 0xcd, 0x77, 0x21, 0x6b, 0xc3, 0x79, 0xed, 0xd6, 0xa0, 0xa6, 0x1c,
3602 0x56, 0xfd, 0xc2, 0x47, 0xf7, 0x7b, 0x35, 0x25, 0xf0, 0xb8, 0xe6, 0xa8,
3603 0x9a, 0x12, 0xf1, 0x35, 0xcc, 0x79, 0xfd, 0xa2, 0x63, 0xaf, 0xbc, 0x0c,
3604 0x42, 0x4f, 0xb7, 0x88, 0x7d, 0x08, 0x7e, 0xf1, 0x9c, 0x2c, 0xe9, 0x69,
3605 0x4d, 0xad, 0x19, 0x7a, 0x86, 0x71, 0x8a, 0xf1, 0x8b, 0x36, 0x9e, 0x4c,
3606 0x14, 0x61, 0x7f, 0xa1, 0xe7, 0x19, 0xa3, 0x3c, 0xdb, 0x9e, 0x68, 0x8b,
3607 0x75, 0x0b, 0x95, 0x7b, 0xa0, 0x43, 0xd4, 0xf2, 0x16, 0xe2, 0x9c, 0x81,
3608 0x5c, 0x6e, 0xf1, 0xda, 0xeb, 0xe1, 0xe5, 0x63, 0x31, 0x75, 0x5d, 0xac,
3609 0x7a, 0x18, 0xdc, 0x5b, 0x9f, 0x75, 0x07, 0x62, 0x4c, 0x93, 0x74, 0x70,
3610 0xdf, 0x01, 0x09, 0x3d, 0x17, 0x93, 0xf0, 0x73, 0xb4, 0x3f, 0x33, 0xe1,
3611 0x40, 0x7e, 0x0b, 0x16, 0x31, 0xd0, 0x0a, 0xb0, 0xc5, 0xcd, 0xa2, 0xaf,
3612 0x0c, 0xc0, 0x77, 0xcc, 0x78, 0x55, 0x92, 0x12, 0xaa, 0x45, 0xe5, 0xad,
3613 0x45, 0x33, 0x41, 0x7b, 0x39, 0x6b, 0x61, 0xbc, 0xd9, 0x75, 0x79, 0x5d,
3614 0x51, 0xc1, 0xb1, 0x2f, 0x87, 0x80, 0x19, 0x86, 0x6d, 0xbd, 0x47, 0x5e,
3615 0x87, 0xbe, 0x73, 0x6a, 0xec, 0x66, 0xac, 0x0b, 0x1a, 0x9e, 0x33, 0xc1,
3616 0x03, 0xd7, 0xfd, 0x1e, 0xd6, 0x54, 0xf8, 0xca, 0xd9, 0x60, 0x4d, 0xba,
3617 0x48, 0xdb, 0xed, 0x83, 0xdd, 0xe1, 0xba, 0xd9, 0x21, 0xb9, 0xd9, 0x84,
3618 0xe8, 0x8b, 0x9f, 0x91, 0xc1, 0xfd, 0xba, 0xc7, 0x8f, 0xe2, 0x91, 0x63,
3619 0xec, 0xc7, 0xdd, 0xae, 0xfc, 0x51, 0x5f, 0x83, 0xcd, 0x3c, 0x48, 0x1d,
3620 0x23, 0xf7, 0x23, 0x8f, 0x31, 0x8e, 0x85, 0x90, 0xc7, 0xb2, 0x4d, 0x4f,
3621 0xef, 0xd5, 0x07, 0xfb, 0xe5, 0xc9, 0xe7, 0x68, 0x4f, 0xb8, 0xb7, 0x69,
3622 0x53, 0x41, 0x0f, 0x98, 0xf7, 0x2c, 0x39, 0xf9, 0x6c, 0x50, 0x73, 0xb0,
3623 0xbe, 0x32, 0xe3, 0x07, 0xc0, 0x8f, 0x7e, 0x27, 0xe3, 0x81, 0xae, 0x6c,
3624 0x37, 0x6f, 0x59, 0x5e, 0xdd, 0x51, 0x49, 0xb0, 0x2f, 0x6e, 0xb0, 0x4e,
3625 0xb3, 0xe3, 0x9e, 0xbc, 0x8b, 0x18, 0x2b, 0x35, 0x67, 0x11, 0xa3, 0x23,
3626 0x72, 0x71, 0xd6, 0x86, 0xee, 0x3f, 0x0b, 0xba, 0x0e, 0x75, 0x11, 0x23,
3627 0x5f, 0x9c, 0x75, 0x70, 0x7d, 0x48, 0xd5, 0x66, 0xa1, 0x3b, 0x61, 0xc7,
3628 0xcd, 0x7e, 0xfa, 0x91, 0xaf, 0xa7, 0x84, 0x56, 0x5c, 0x32, 0xb5, 0x12,
3629 0x62, 0xf6, 0x64, 0x8a, 0x39, 0xbe, 0x53, 0xf5, 0x4d, 0xd9, 0xaf, 0xc9,
3630 0x2b, 0xbc, 0xb0, 0x4f, 0x2b, 0x56, 0x19, 0xe7, 0x0b, 0xf1, 0x0e, 0x21,
3631 0x0e, 0x11, 0xad, 0x66, 0x51, 0x27, 0x9a, 0x9c, 0x57, 0xbd, 0x58, 0x11,
3632 0xc7, 0x3d, 0x42, 0x19, 0x68, 0xf5, 0xea, 0x3e, 0xad, 0x50, 0x0d, 0xc9,
3633 0xc5, 0x18, 0xe9, 0x4e, 0xa8, 0xfa, 0x7d, 0xbf, 0xb2, 0xb5, 0x1e, 0xe4,
3634 0x12, 0xd8, 0x4c, 0xea, 0x93, 0xd8, 0x57, 0x8d, 0xc1, 0xa6, 0xa8, 0x7b,
3635 0xea, 0x5d, 0xc5, 0x48, 0x5f, 0xf7, 0x3b, 0xe5, 0x4c, 0xd0, 0x51, 0x26,
3636 0x7e, 0xef, 0xf4, 0xf1, 0xfb, 0xa2, 0x5f, 0x0f, 0x3d, 0x26, 0xac, 0x53,
3637 0x16, 0x2a, 0xa4, 0x05, 0xf1, 0xd6, 0xdd, 0xc9, 0x96, 0x28, 0x47, 0x2f,
3638 0xa6, 0x1c, 0x45, 0x1d, 0xa3, 0xaf, 0x19, 0xbe, 0x0d, 0xf0, 0x6f, 0x14,
3639 0xf7, 0xbc, 0x5a, 0xaa, 0xd8, 0x8c, 0xc0, 0xdf, 0xa7, 0x21, 0x23, 0xea,
3640 0x06, 0xfa, 0x5b, 0xe3, 0x99, 0x0a, 0xf4, 0xb7, 0xf6, 0xf2, 0xfb, 0x76,
3641 0x1f, 0x63, 0xde, 0xb0, 0x3c, 0x89, 0xf1, 0x13, 0x67, 0x48, 0xcf, 0xb8,
3642 0x8f, 0xc7, 0x12, 0x90, 0x09, 0x63, 0xfc, 0xa8, 0xbc, 0xd5, 0x70, 0x14,
3643 0xfe, 0xdb, 0xb7, 0x7f, 0x46, 0xe6, 0xdd, 0x59, 0xe0, 0x3f, 0xc8, 0xdf,
3644 0x48, 0xc0, 0x3f, 0xe3, 0x2a, 0x3e, 0x1e, 0xfe, 0x68, 0x35, 0x49, 0xd8,
3645 0xcb, 0xd9, 0xf7, 0x5e, 0x67, 0xce, 0xde, 0x0d, 0xfc, 0xf5, 0x91, 0xd6,
3646 0x0f, 0x79, 0xeb, 0xff, 0x17, 0xe8, 0xea, 0x73, 0xd8, 0x23, 0x0a, 0xfa,
3647 0xfa, 0x29, 0xd3, 0x0f, 0x7b, 0x4e, 0xf7, 0x9e, 0xbb, 0xff, 0x3a, 0xe9,
3648 0x32, 0xa4, 0x01, 0x8c, 0x50, 0x50, 0x79, 0x94, 0xb5, 0x62, 0xc4, 0xd7,
3649 0xdf, 0x31, 0x60, 0x67, 0xae, 0x1b, 0xc4, 0xde, 0x4e, 0x29, 0xf4, 0x05,
3650 0xf5, 0x27, 0x62, 0xf6, 0xe6, 0x78, 0x50, 0xcf, 0xf2, 0xf9, 0x94, 0x93,
3651 0x2f, 0xb3, 0x4f, 0xc8, 0x5c, 0xc0, 0x31, 0x65, 0x87, 0x1f, 0x42, 0xb7,
3652 0x09, 0xcf, 0x20, 0xdd, 0xf7, 0x29, 0xba, 0x1d, 0x45, 0x37, 0xfd, 0x8b,
3653 0x67, 0x3a, 0xec, 0xa3, 0x05, 0x7d, 0x33, 0xae, 0x07, 0x4c, 0x00, 0x7d,
3654 0x7f, 0x17, 0x3a, 0xfe, 0x4e, 0x05, 0x98, 0xa0, 0x02, 0x4c, 0x80, 0x3d,
3655 0xbe, 0x0d, 0x1d, 0x7f, 0xab, 0x02, 0x4c, 0x50, 0x89, 0xfb, 0x3d, 0x0a,
3656 0x9b, 0x98, 0xfe, 0x23, 0xda, 0x6e, 0xd0, 0x93, 0xb9, 0xda, 0x2e, 0x39,
3657 0xce, 0xf9, 0x01, 0x36, 0x8e, 0xc2, 0x8e, 0x78, 0x6e, 0x11, 0xf4, 0x3b,
3658 0xfc, 0x1c, 0xd1, 0xe0, 0xb9, 0x00, 0x72, 0x44, 0x83, 0xe7, 0x18, 0x23,
3659 0xf1, 0x10, 0x30, 0x61, 0x48, 0xe2, 0xc2, 0x5e, 0xef, 0xdc, 0x18, 0xd6,
3660 0x1a, 0x1d, 0x84, 0x27, 0x75, 0xa8, 0xbe, 0xd6, 0x71, 0xd5, 0x6f, 0x40,
3661 0x5c, 0xa8, 0x06, 0xb5, 0x5b, 0x52, 0x26, 0x96, 0x88, 0x33, 0x65, 0xaf,
3662 0x9e, 0x86, 0x0e, 0x5c, 0x62, 0xc3, 0xcd, 0xbe, 0xf4, 0x70, 0x1d, 0x7b,
3663 0x16, 0x2d, 0x8f, 0xbe, 0xe3, 0xee, 0xd6, 0x33, 0x07, 0x10, 0x9f, 0xa7,
3664 0xca, 0x09, 0x99, 0x2c, 0x7b, 0x98, 0x00, 0xf5, 0xcf, 0x55, 0xfd, 0x51,
3665 0x9b, 0x7a, 0x80, 0xfe, 0x36, 0x6d, 0x23, 0x71, 0x3e, 0x45, 0x19, 0x53,
3666 0xff, 0xd3, 0xaa, 0x67, 0x7d, 0xa0, 0xee, 0xf5, 0xe5, 0x27, 0x95, 0x2d,
3667 0x84, 0x19, 0x67, 0xa8, 0x3f, 0xcf, 0x87, 0x61, 0x17, 0x79, 0x37, 0x90,
3668 0x4b, 0x3b, 0x1e, 0xf9, 0xbc, 0x26, 0xd6, 0x4e, 0xe3, 0xb9, 0xb6, 0xf1,
3669 0xcd, 0xfb, 0x3e, 0xbd, 0x88, 0x7d, 0x9b, 0x3d, 0x06, 0xc6, 0xa9, 0xad,
3670 0xf1, 0x10, 0xea, 0x87, 0xb0, 0xba, 0x8f, 0x18, 0xde, 0x88, 0x49, 0xb6,
3671 0x61, 0x89, 0x53, 0xe5, 0x3c, 0xf6, 0x2d, 0x18, 0x8f, 0x9e, 0x90, 0xec,
3672 0x52, 0xaf, 0xe4, 0x62, 0x66, 0xca, 0x96, 0xbf, 0x27, 0x1b, 0xcb, 0x85,
3673 0x04, 0xcf, 0x0d, 0x0b, 0x33, 0x1a, 0x9e, 0x7b, 0x18, 0xd7, 0xa4, 0xd9,
3674 0x92, 0xc3, 0x65, 0xe6, 0x9d, 0x91, 0x78, 0x03, 0xf7, 0x72, 0xb3, 0xec,
3675 0xd5, 0x54, 0x61, 0x93, 0x66, 0xa2, 0x8a, 0x78, 0xf0, 0x72, 0x99, 0xfb,
3676 0x01, 0x1b, 0x95, 0xd9, 0xcf, 0x09, 0xee, 0x3f, 0x01, 0x1c, 0x88, 0x58,
3677 0x1d, 0xf3, 0xe7, 0x28, 0x5e, 0x6d, 0x23, 0x2c, 0x81, 0xae, 0x3b, 0x65,
3678 0xdd, 0x8f, 0xbb, 0xb5, 0xb2, 0xd7, 0x47, 0x39, 0x4b, 0x7a, 0xdc, 0xff,
3679 0xd5, 0x5a, 0x8f, 0xa1, 0x16, 0xda, 0xe4, 0xf5, 0x8f, 0xb9, 0x8f, 0x81,
3680 0xb0, 0x2b, 0x27, 0xdc, 0x40, 0x26, 0xbc, 0xcf, 0x31, 0x9e, 0x8d, 0xb6,
3681 0x5a, 0x67, 0xad, 0xf6, 0x9e, 0xdf, 0xf5, 0xf4, 0xcc, 0xde, 0xb8, 0x2d,
3682 0x63, 0xbd, 0xe6, 0xa0, 0x26, 0xf6, 0x7b, 0x66, 0x87, 0x46, 0xbc, 0x9e,
3683 0xd9, 0xfc, 0xc8, 0xf6, 0x9e, 0xd9, 0xcf, 0x6f, 0xf3, 0x7a, 0x66, 0x17,
3684 0x9d, 0x22, 0x3e, 0x5e, 0xcf, 0x6c, 0xf8, 0x76, 0xaf, 0x67, 0xf6, 0xf0,
3685 0xed, 0x5e, 0xcf, 0xec, 0x91, 0x11, 0xaf, 0x67, 0xf6, 0xfb, 0xb7, 0x6f,
3686 0xef, 0x99, 0x3d, 0x36, 0xb2, 0xbd, 0x67, 0x26, 0x13, 0xc8, 0x77, 0x13,
3687 0x5b, 0x3d, 0xb3, 0xf2, 0xc8, 0xb5, 0x7b, 0x66, 0xaf, 0x06, 0x78, 0x1d,
3688 0xfc, 0x8c, 0x81, 0x87, 0x14, 0xf0, 0xfa, 0x28, 0xf0, 0xfa, 0xaf, 0xeb,
3689 0x59, 0x87, 0xc1, 0xe7, 0xcd, 0x7e, 0x5e, 0xb8, 0x1e, 0xdc, 0x7e, 0xbb,
3690 0xff, 0x8c, 0xa0, 0xde, 0x4d, 0xf8, 0xb5, 0x0a, 0xb1, 0xfb, 0x1e, 0xbf,
3691 0x66, 0xfb, 0x6b, 0xd1, 0xad, 0xf3, 0xec, 0xf6, 0xff, 0x37, 0xa0, 0xf4,
3692 0x0e, 0xf0, 0x3c, 0xf9, 0x79, 0x0d, 0xb5, 0x1f, 0xf9, 0x47, 0xa2, 0xef,
3693 0xbe, 0xe8, 0x7c, 0xd5, 0x22, 0xc6, 0x7f, 0x1c, 0xbe, 0x6a, 0xef, 0x0d,
3694 0xc9, 0x3a, 0xfc, 0x96, 0x39, 0xea, 0xa4, 0x64, 0x31, 0x3f, 0xab, 0xe6,
3695 0x27, 0x26, 0xb6, 0xe6, 0xa7, 0x26, 0xbe, 0xaa, 0x6a, 0x52, 0xf3, 0x5f,
3696 0xe3, 0xf3, 0x0d, 0x65, 0xdf, 0x96, 0x87, 0xe1, 0x9d, 0x4a, 0x80, 0xb7,
3697 0xc2, 0x3e, 0x76, 0x36, 0x1c, 0xdb, 0x9d, 0xc0, 0x33, 0xe6, 0x8b, 0xb6,
3698 0x34, 0x14, 0x7e, 0x0f, 0xa5, 0xcd, 0x17, 0x73, 0xaa, 0x5e, 0x33, 0x9c,
3699 0xbc, 0x1b, 0xd4, 0xdf, 0xa8, 0xa1, 0x86, 0x06, 0xd5, 0xf9, 0x9b, 0xbe,
3700 0x36, 0x8c, 0x3c, 0xd6, 0x5e, 0x63, 0xb3, 0xae, 0xd6, 0xfd, 0xba, 0xda,
3701 0x90, 0xbb, 0xf7, 0xb7, 0x63, 0x73, 0x99, 0xf8, 0x5b, 0x0a, 0x9b, 0xef,
3702 0x42, 0x6d, 0x4e, 0xec, 0x4d, 0x1c, 0x43, 0x0c, 0x41, 0x7c, 0xce, 0x7e,
3703 0x01, 0xeb, 0x19, 0xe6, 0x46, 0xd6, 0x37, 0x31, 0x7c, 0xf8, 0xbe, 0x41,
3704 0x80, 0xd1, 0x3b, 0xfc, 0xf8, 0xce, 0xba, 0x28, 0xc0, 0x2a, 0x77, 0x75,
3705 0x7b, 0xb5, 0xd1, 0x2e, 0xcd, 0xab, 0x3f, 0x13, 0xfe, 0x9c, 0xf0, 0x26,
3706 0x16, 0x0e, 0x6f, 0x62, 0xe1, 0x6d, 0xe7, 0x30, 0xa2, 0xde, 0x6d, 0x50,
3707 0xe7, 0x39, 0x3c, 0xdf, 0x11, 0x4d, 0x4f, 0xf3, 0x8c, 0x07, 0x38, 0xc7,
3708 0xe2, 0x99, 0x0f, 0x7d, 0xe9, 0x41, 0x2d, 0x5b, 0x37, 0x10, 0xef, 0x99,
3709 0x7f, 0x90, 0x6b, 0xcb, 0xc1, 0xd9, 0x62, 0xa0, 0x27, 0xca, 0x8e, 0x63,
3710 0x7f, 0xaa, 0xa1, 0xe6, 0x4d, 0x45, 0xac, 0x43, 0xa0, 0x65, 0x0a, 0xff,
3711 0x03, 0x99, 0xde, 0xa3, 0x72, 0x5f, 0x27, 0x6c, 0xf6, 0x78, 0x85, 0xd8,
3712 0xf5, 0x71, 0x69, 0xf8, 0xf8, 0x75, 0x65, 0xc9, 0xc3, 0xae, 0xe1, 0xed,
3713 0xd8, 0x35, 0xb5, 0x21, 0x1e, 0x8d, 0x07, 0x76, 0xa4, 0xd1, 0x70, 0x5e,
3714 0x19, 0x22, 0x66, 0x25, 0x9d, 0xcc, 0x3d, 0xd3, 0x88, 0x81, 0xcc, 0x39,
3715 0xcc, 0x37, 0xc4, 0xa5, 0xd7, 0xa2, 0x4f, 0x8d, 0x1d, 0xed, 0xb0, 0xa2,
3716 0xf8, 0xcc, 0x83, 0x8e, 0x19, 0x3c, 0x93, 0x96, 0x85, 0xd3, 0x5f, 0xd1,
3717 0x9c, 0xfa, 0x3c, 0xe8, 0x99, 0x42, 0xae, 0xa3, 0x2d, 0x15, 0x0c, 0xcf,
3718 0x8e, 0xd6, 0x11, 0xf7, 0x5d, 0xc6, 0x02, 0xd4, 0xae, 0xa8, 0x47, 0xca,
3719 0x8c, 0xbd, 0x3c, 0xeb, 0x0a, 0x62, 0x2e, 0xfb, 0x26, 0xa8, 0x59, 0x59,
3720 0xbb, 0x2e, 0x72, 0xdf, 0xed, 0xba, 0xa8, 0xb9, 0xc4, 0x5d, 0x86, 0xb3,
3721 0xbe, 0x46, 0xdc, 0xf8, 0x51, 0x31, 0xa4, 0xe1, 0xbc, 0x3c, 0x44, 0x1c,
3722 0x79, 0x3d, 0xf8, 0xd1, 0x84, 0x34, 0xcd, 0x17, 0xd6, 0xf5, 0x76, 0xfc,
3723 0xe8, 0x61, 0xc7, 0xcc, 0xda, 0x41, 0xac, 0xc9, 0xda, 0x8c, 0x38, 0xd1,
3724 0x44, 0x98, 0x1b, 0xc4, 0xb3, 0x83, 0xe0, 0xc7, 0xc3, 0x8a, 0x59, 0x60,
3725 0xc5, 0xbf, 0x03, 0xac, 0x58, 0x92, 0xf7, 0xa2, 0xc4, 0x8a, 0xb6, 0x8f,
3726 0x15, 0x1d, 0xd8, 0x71, 0x7e, 0x9b, 0x1d, 0x6b, 0xaa, 0x07, 0xc5, 0x7b,
3727 0x79, 0x60, 0xbd, 0xec, 0xa2, 0x79, 0x1d, 0xf8, 0x50, 0x93, 0x98, 0x3a,
3728 0xaf, 0x0f, 0xb7, 0xad, 0x19, 0xe0, 0xc0, 0x7d, 0x0a, 0xdf, 0xdd, 0x57,
3729 0xd9, 0x85, 0xda, 0x44, 0xe1, 0x3d, 0xff, 0x9c, 0x2f, 0x7c, 0xd5, 0xd9,
3730 0x67, 0xb8, 0xed, 0xec, 0x73, 0x0b, 0x17, 0xe2, 0x39, 0xbf, 0xc7, 0x17,
3731 0x81, 0xde, 0xfe, 0x07, 0x69, 0x82, 0x5f, 0xd1, 0x07, 0x34, 0xcf, 0x4f,
3732 0xb6, 0xe1, 0xc3, 0xff, 0x7a, 0x15, 0x3e, 0x44, 0xce, 0x5a, 0x89, 0x49,
3733 0x06, 0xd8, 0xd0, 0x5e, 0xe3, 0x5a, 0xf4, 0xe5, 0x51, 0xe9, 0x00, 0x7f,
3734 0x9d, 0x8b, 0x7d, 0xc0, 0x44, 0xdd, 0x12, 0x05, 0x36, 0x8a, 0x28, 0x6c,
3735 0x34, 0x44, 0x0c, 0x33, 0x7c, 0x18, 0x98, 0xa6, 0xb1, 0x89, 0x8f, 0xcc,
3736 0xd4, 0x0f, 0xa0, 0x97, 0x87, 0x95, 0xad, 0x8c, 0xcb, 0x53, 0x88, 0x9d,
3737 0x1d, 0x6b, 0xc0, 0x75, 0x2b, 0x1e, 0x6e, 0x8a, 0x5c, 0x85, 0x9b, 0x8e,
3738 0xec, 0x88, 0x9b, 0x54, 0xbf, 0x7e, 0x9c, 0x32, 0x79, 0xdd, 0xf5, 0xfa,
3739 0xf5, 0x97, 0x5c, 0xaf, 0x5f, 0xff, 0xba, 0xdb, 0xde, 0xaf, 0xbf, 0x49,
3740 0x8a, 0x86, 0x69, 0x5f, 0x94, 0xab, 0xfa, 0xf5, 0x33, 0xec, 0x7f, 0x57,
3741 0xbb, 0xbc, 0xbe, 0x7c, 0xb7, 0xdf, 0xaf, 0x37, 0xa5, 0xb8, 0x6d, 0xdc,
3742 0x90, 0xb7, 0xad, 0xa0, 0x5f, 0xff, 0x2f, 0x30, 0xd6, 0x83, 0x3d, 0xb6,
3743 0xf7, 0xea, 0x2f, 0xb9, 0xec, 0xd5, 0xc7, 0x38, 0xcf, 0xef, 0xd5, 0x73,
3744 0x1e, 0x6a, 0x78, 0x97, 0x7d, 0xfa, 0x9b, 0x21, 0x8b, 0x7e, 0xc8, 0xa1,
3745 0x4f, 0x3a, 0x9e, 0x8b, 0x73, 0x8e, 0xea, 0xcf, 0x5f, 0x74, 0x63, 0x78,
3746 0xce, 0xeb, 0xa3, 0x1f, 0x86, 0x5d, 0x1d, 0xd9, 0xec, 0xcf, 0x7b, 0x7b,
3747 0xbc, 0xe1, 0x6e, 0x5f, 0x7f, 0xfb, 0x3a, 0x03, 0xfe, 0x3a, 0x31, 0xac,
3748 0x13, 0xbf, 0x6a, 0x9d, 0xad, 0x7e, 0xfc, 0x1b, 0xae, 0xd7, 0x8b, 0x77,
3749 0x4e, 0x8b, 0xdd, 0x81, 0x98, 0xfc, 0xe2, 0xd0, 0x8d, 0xfe, 0x1a, 0x9b,
3750 0xbd, 0x78, 0xc6, 0x0e, 0xe0, 0x75, 0xc6, 0x0f, 0x3e, 0xff, 0xff, 0xbe,
3751 0x17, 0xcf, 0x3e, 0xbc, 0x77, 0x9e, 0x42, 0xff, 0x04, 0x2e, 0x7f, 0xd6,
3752 0xeb, 0xc1, 0x4f, 0x54, 0x82, 0xde, 0x3a, 0xeb, 0xc6, 0xe0, 0xbd, 0x8c,
3753 0xc1, 0xc4, 0x71, 0xa1, 0xad, 0x90, 0x3e, 0xae, 0xdb, 0x23, 0x73, 0x0a,
3754 0x17, 0xc1, 0xa6, 0x92, 0xd7, 0xc6, 0xc6, 0xb5, 0xc5, 0x00, 0x1b, 0xc7,
3755 0x14, 0x36, 0xae, 0xad, 0x05, 0xd8, 0x38, 0x73, 0x0d, 0x6c, 0xfc, 0xdf,
3756 0xba, 0xbc, 0xf8, 0x1f, 0x95, 0x82, 0xc2, 0xc6, 0xd7, 0x7a, 0xc7, 0x86,
3757 0xf7, 0xba, 0x89, 0x03, 0xc4, 0x3b, 0x17, 0xef, 0xbb, 0x86, 0xaf, 0x05,
3758 0x78, 0x99, 0xb9, 0xbe, 0x5f, 0x66, 0x9e, 0xdb, 0xc2, 0xcb, 0x1e, 0x26,
3759 0x36, 0x13, 0x47, 0x55, 0x2e, 0x04, 0x3e, 0x68, 0xb2, 0xef, 0x7d, 0x48,
3760 0xd9, 0x6e, 0xa9, 0x32, 0xab, 0x70, 0x59, 0x1e, 0xb5, 0x6d, 0x51, 0xe1,
3761 0x60, 0x62, 0xe0, 0x2e, 0x91, 0xbe, 0x20, 0x17, 0x05, 0x18, 0x33, 0xec,
3762 0xc7, 0x67, 0x9e, 0x29, 0xbc, 0x1d, 0xca, 0x10, 0x03, 0xbb, 0x41, 0x8d,
3763 0x40, 0x39, 0x0f, 0x23, 0x76, 0x19, 0xbe, 0xac, 0x3c, 0x9f, 0xdd, 0xb7,
3764 0xff, 0x87, 0xef, 0xdb, 0x06, 0xe3, 0x5a, 0x80, 0x11, 0x51, 0x03, 0x55,
3765 0xc6, 0xd5, 0xbb, 0x0e, 0x1e, 0x46, 0xf4, 0xf0, 0x61, 0xd6, 0x9d, 0x01,
3766 0x4e, 0x9e, 0x95, 0x09, 0xe0, 0xf3, 0xf5, 0xdf, 0x65, 0xef, 0x29, 0xc0,
3767 0x44, 0x36, 0xfe, 0xb7, 0xf7, 0xa2, 0x78, 0xdd, 0xa1, 0xce, 0xfe, 0xce,
3768 0x0f, 0x45, 0xdb, 0xc6, 0xff, 0x3e, 0xe2, 0x37, 0xea, 0xa1, 0x0a, 0x73,
3769 0x1d, 0xb1, 0xd0, 0x6f, 0x40, 0x07, 0x63, 0xd7, 0xc0, 0x42, 0x57, 0xe7,
3770 0x26, 0xe6, 0xcb, 0xad, 0xbc, 0xe4, 0x6c, 0xe6, 0x25, 0xee, 0xf1, 0xeb,
3771 0x72, 0x27, 0xc7, 0x6c, 0x23, 0x62, 0x4d, 0xe1, 0x33, 0x8f, 0x7c, 0xbd,
3772 0x3d, 0x37, 0xcd, 0x5d, 0x47, 0x6e, 0x9a, 0x50, 0xb9, 0x89, 0xf4, 0xa2,
3773 0x9e, 0x83, 0x4c, 0xbe, 0x0b, 0x59, 0x7e, 0x07, 0xb4, 0xff, 0x11, 0xf8,
3774 0xf9, 0x43, 0x60, 0xac, 0x6f, 0x03, 0x63, 0x7d, 0xab, 0xd2, 0xfe, 0x0e,
3775 0xc3, 0xb8, 0xb0, 0x0e, 0xf4, 0xea, 0x66, 0x0f, 0xc3, 0x1f, 0x86, 0x57,
3776 0x35, 0xca, 0x86, 0x33, 0x57, 0x1e, 0x31, 0xe6, 0xbd, 0xf3, 0xd2, 0x44,
3777 0x4e, 0xd2, 0x88, 0x11, 0xcc, 0x15, 0xea, 0x3a, 0xce, 0x7e, 0x25, 0xb1,
3778 0x42, 0x5d, 0xd5, 0x93, 0x43, 0x52, 0x6d, 0x78, 0xf8, 0x6a, 0xe1, 0x8c,
3779 0xb7, 0xc6, 0x9c, 0x8f, 0xaf, 0xf2, 0x3e, 0xbe, 0xca, 0x35, 0x36, 0x12,
3780 0xac, 0xcf, 0x17, 0x52, 0xdb, 0x31, 0xd5, 0x61, 0x1f, 0x53, 0xcd, 0xff,
3781 0x15, 0x31, 0x15, 0xf7, 0xca, 0xe3, 0x99, 0xc9, 0xa5, 0x84, 0x1c, 0x80,
3782 0x7c, 0x27, 0xca, 0xd4, 0x93, 0x69, 0xc3, 0x6e, 0x3e, 0x44, 0x57, 0x8e,
3783 0xd2, 0x4b, 0x28, 0xe9, 0xe9, 0x69, 0x12, 0x7a, 0x9a, 0xf8, 0xb5, 0xf5,
3784 0x8d, 0x1a, 0x33, 0xde, 0x1c, 0x8b, 0xe2, 0xf3, 0x7f, 0xaa, 0x23, 0xd2,
3785 0x4f, 0x3d, 0x5d, 0x8d, 0xb9, 0xae, 0x07, 0x7b, 0x6d, 0xc7, 0x5d, 0xb6,
3786 0xc2, 0x5d, 0x1d, 0xfe, 0x9c, 0x99, 0x89, 0x49, 0xe8, 0xf0, 0xdf, 0x63,
3787 0xce, 0x9f, 0xc0, 0xb7, 0x7e, 0x88, 0x78, 0xfd, 0xef, 0xa0, 0x8b, 0x7f,
3788 0x8b, 0xda, 0xe0, 0x55, 0xe4, 0x9f, 0x1f, 0x60, 0x6c, 0x0b, 0xc7, 0xa8,
3789 0x33, 0xfa, 0xd1, 0x8c, 0x95, 0x98, 0x28, 0xba, 0x89, 0x09, 0x0f, 0x7f,
3790 0xfc, 0xea, 0x6f, 0x66, 0xac, 0x29, 0xbe, 0xc3, 0x00, 0xf9, 0xfe, 0xf9,
3791 0xdd, 0x73, 0x0a, 0x7b, 0x04, 0x98, 0x23, 0x67, 0x73, 0xff, 0x92, 0x9b,
3792 0x9a, 0xa8, 0xe1, 0xe3, 0x61, 0x9b, 0xef, 0xd9, 0x1e, 0xb6, 0x59, 0xfa,
3793 0xeb, 0xd4, 0xbb, 0x87, 0x6b, 0x1e, 0x4e, 0xd3, 0xaf, 0xeb, 0xc0, 0x1c,
3794 0x35, 0xf8, 0x64, 0xa1, 0x69, 0xab, 0xcf, 0xf1, 0x8a, 0x6d, 0x46, 0x20,
3795 0x1f, 0xf6, 0x58, 0x4f, 0xd1, 0x0b, 0x5d, 0xd3, 0x28, 0x13, 0x81, 0xba,
3796 0x66, 0xfc, 0x9f, 0xf9, 0xd7, 0x4f, 0xfb, 0xd7, 0x4f, 0xf9, 0xd7, 0x27,
3797 0x91, 0x77, 0x9f, 0x54, 0xb9, 0x93, 0xe3, 0x1c, 0x83, 0x72, 0x5d, 0xac,
3798 0x85, 0xf5, 0xce, 0x8e, 0xfe, 0xb4, 0x55, 0x8d, 0x79, 0xfe, 0x5c, 0x68,
3799 0x3a, 0xf8, 0xfc, 0x63, 0x7c, 0x0e, 0xe2, 0x33, 0x8d, 0xcf, 0x63, 0xf8,
3800 0x6c, 0xca, 0x54, 0xcb, 0x56, 0xa8, 0xa3, 0x61, 0xc9, 0x62, 0xbc, 0x88,
3801 0x3a, 0x34, 0x93, 0x7a, 0x44, 0x8a, 0xf5, 0x92, 0x94, 0x96, 0x34, 0xe9,
3802 0xb6, 0xd2, 0x52, 0xaa, 0x1f, 0x93, 0xe3, 0x4b, 0xde, 0xb9, 0x61, 0x57,
3803 0xda, 0xc6, 0xdc, 0x96, 0x3c, 0x9c, 0x7a, 0x5c, 0xf4, 0x3b, 0x8f, 0x61,
3804 0x9e, 0xe8, 0xc5, 0xd1, 0xdb, 0xd4, 0xf9, 0x58, 0x3d, 0xe5, 0xc9, 0xf8,
3805 0x80, 0x65, 0x9b, 0xc8, 0x5b, 0xc3, 0x4f, 0x62, 0xed, 0x8c, 0x7a, 0x3f,
3806 0x30, 0x2d, 0x27, 0x4e, 0x6f, 0xec, 0xf5, 0x62, 0xa9, 0x69, 0xbc, 0x81,
3807 0x4d, 0xeb, 0xe0, 0xc3, 0x46, 0xec, 0x9b, 0x82, 0x9d, 0x1f, 0x71, 0xc3,
3808 0xda, 0x04, 0x62, 0xe0, 0x84, 0xab, 0x6a, 0x3d, 0xc4, 0x2a, 0xc3, 0x49,
3809 0x9e, 0x8a, 0xe1, 0x9a, 0xef, 0xd0, 0x20, 0x0f, 0x2a, 0x5b, 0xd9, 0x00,
3810 0x8e, 0xd1, 0x54, 0xbf, 0xaf, 0xb4, 0x79, 0x0e, 0xa4, 0xfa, 0xff, 0x4e,
3811 0x32, 0xa9, 0x4b, 0x7e, 0x8c, 0x38, 0xd6, 0x56, 0xb9, 0xa8, 0x51, 0xb6,
3812 0x3f, 0xc1, 0xda, 0xf0, 0x75, 0x61, 0x5e, 0xbb, 0x07, 0xf3, 0x06, 0x10,
3813 0x7f, 0x71, 0xaf, 0x09, 0x5e, 0x4e, 0x93, 0x57, 0x3e, 0x83, 0xda, 0xb6,
3814 0xfa, 0x49, 0xbd, 0xb8, 0xe4, 0xd7, 0x44, 0xaa, 0x76, 0x48, 0x48, 0x7d,
3815 0xf3, 0xcc, 0xc9, 0xeb, 0x93, 0xd4, 0xdd, 0x00, 0x3b, 0xf4, 0x60, 0x0e,
3816 0xeb, 0x08, 0xc8, 0xc8, 0x3b, 0x27, 0x53, 0x67, 0x64, 0x45, 0xf7, 0x93,
3817 0x7a, 0x69, 0x29, 0x83, 0x71, 0xf6, 0xa4, 0xf1, 0xbd, 0xaa, 0x2b, 0xec,
3818 0x7f, 0x31, 0x74, 0x58, 0x1a, 0xd5, 0x16, 0xe8, 0x45, 0x8e, 0xdd, 0x7b,
3819 0x58, 0x6a, 0xd5, 0x79, 0x79, 0xa1, 0xba, 0xb1, 0x0b, 0xd8, 0x09, 0x32,
3820 0x25, 0xfd, 0x3d, 0x3e, 0xfd, 0x54, 0x41, 0x30, 0x0e, 0x79, 0x9e, 0x2e,
3821 0xc4, 0xbd, 0xba, 0x96, 0xb8, 0xed, 0x24, 0xdf, 0x1b, 0x8c, 0xf3, 0x3d,
3822 0xbe, 0x23, 0xcb, 0xb4, 0xc9, 0x8b, 0xf7, 0x2e, 0x58, 0x9f, 0x92, 0x0b,
3823 0xa9, 0x3d, 0xb2, 0x91, 0x52, 0xf5, 0x2f, 0xf1, 0x01, 0x7c, 0xdb, 0x34,
3824 0xd6, 0xe5, 0x6e, 0x39, 0x01, 0x3f, 0xbd, 0x90, 0xca, 0xa9, 0xf3, 0x9b,
3825 0xe3, 0x4d, 0x62, 0xfb, 0x79, 0xd6, 0x54, 0xb2, 0xae, 0x7a, 0x60, 0xad,
3826 0xd6, 0x64, 0x8a, 0xb1, 0xa7, 0x43, 0x36, 0x14, 0xd6, 0xf2, 0x7a, 0xe3,
3827 0x1b, 0xb3, 0x9e, 0x6f, 0x84, 0x94, 0xbd, 0xff, 0x1b, 0xd0, 0x71, 0x0c,
3828 0x36, 0x1b, 0x51, 0x73, 0x42, 0xe9, 0x4e, 0x7f, 0x8e, 0xc2, 0x66, 0x6d,
3829 0x73, 0xc6, 0xc7, 0x33, 0x96, 0xf1, 0xa9, 0x8c, 0x35, 0x36, 0xe1, 0xf5,
3830 0x53, 0x4c, 0xc3, 0xd6, 0x2e, 0xb6, 0x82, 0xf7, 0x4d, 0xa6, 0xe0, 0x4f,
3831 0x2f, 0x6d, 0x62, 0x63, 0x18, 0xe7, 0xf3, 0x0b, 0xd0, 0x6b, 0x58, 0x3a,
3832 0x4e, 0xb5, 0xee, 0x99, 0x4b, 0x8d, 0x24, 0x8e, 0x08, 0xdf, 0x30, 0x62,
3833 0xfd, 0x6c, 0x82, 0xda, 0x05, 0xe4, 0xc3, 0x2b, 0xc4, 0x08, 0xc3, 0xe7,
3834 0xe5, 0xca, 0x3d, 0x99, 0xd4, 0x7e, 0xad, 0x36, 0x8b, 0xea, 0xe4, 0xf9,
3835 0x29, 0xe6, 0xd3, 0xa3, 0xec, 0x7d, 0x86, 0x4e, 0xbd, 0xad, 0x39, 0x65,
3836 0xf5, 0x8e, 0x39, 0xf4, 0xd2, 0xd2, 0xe6, 0x21, 0x37, 0x3c, 0x3f, 0xc3,
3837 0x04, 0xa8, 0x5b, 0x83, 0x09, 0x47, 0x72, 0xec, 0x71, 0x49, 0x7e, 0x59,
3838 0xf6, 0x65, 0x10, 0x47, 0xed, 0x99, 0x0e, 0x99, 0x6f, 0x18, 0xce, 0xe0,
3839 0xe2, 0x51, 0xac, 0x31, 0x87, 0xb5, 0xa6, 0x51, 0x83, 0xcc, 0x22, 0x27,
3840 0x53, 0xae, 0x8c, 0xd5, 0x0f, 0x43, 0x46, 0x37, 0xf1, 0xcc, 0x78, 0x3c,
3841 0x27, 0xe6, 0x4c, 0x41, 0xad, 0xfb, 0x9e, 0x96, 0x1f, 0xfd, 0x18, 0x72,
3842 0x5a, 0x58, 0x0e, 0x24, 0x45, 0x9f, 0x4e, 0x86, 0xdf, 0x9f, 0xb3, 0x38,
3843 0x16, 0xe5, 0x98, 0x8e, 0xb1, 0xf0, 0xe7, 0x92, 0x51, 0x3d, 0x93, 0x34,
3844 0xc7, 0xd9, 0xef, 0x0d, 0x59, 0x73, 0x12, 0x7a, 0xbe, 0xb7, 0x47, 0xba,
3845 0xa7, 0xa5, 0x77, 0xd5, 0x1c, 0x7f, 0x1d, 0xb4, 0x84, 0x55, 0x6c, 0x9f,
3846 0x13, 0xdd, 0x1f, 0xef, 0xd9, 0x1c, 0x0f, 0xfb, 0xe3, 0xd3, 0xd2, 0xbd,
3847 0x3a, 0x62, 0xbc, 0x29, 0x87, 0xb1, 0x66, 0x48, 0x2e, 0xa1, 0xa6, 0xb1,
3848 0x86, 0xe6, 0xe0, 0x73, 0x0f, 0x91, 0x96, 0x83, 0xc0, 0x14, 0xf0, 0x09,
3849 0xd4, 0xd9, 0xd6, 0x27, 0xe5, 0x4b, 0x46, 0x97, 0xe4, 0x55, 0x4d, 0x1b,
3850 0xf6, 0x7a, 0xa5, 0xb0, 0xf3, 0x5b, 0x87, 0xa6, 0x77, 0x7b, 0xfd, 0x00,
3851 0x9e, 0x67, 0x8c, 0x62, 0xec, 0x4a, 0x6b, 0xc5, 0xe2, 0x18, 0xef, 0x5d,
3852 0x69, 0xd5, 0xad, 0x11, 0x23, 0xab, 0x45, 0xfd, 0x73, 0xed, 0x79, 0xc5,
3853 0x7b, 0xa1, 0x3a, 0x68, 0xd4, 0xe4, 0x16, 0x2d, 0x7b, 0x03, 0xf2, 0x83,
3854 0xfb, 0x19, 0xcc, 0xbd, 0xd2, 0xca, 0x58, 0xf3, 0xaa, 0x7f, 0x5f, 0x93,
3855 0xe0, 0x9a, 0xeb, 0x8c, 0x18, 0x93, 0xea, 0xd9, 0x11, 0xe3, 0x84, 0xd6,
3856 0xfe, 0xac, 0xa1, 0x4d, 0x6e, 0x7b, 0xb6, 0x5b, 0xc9, 0x28, 0x64, 0x79,
3857 0x73, 0x4a, 0xd5, 0x69, 0x79, 0xda, 0xe5, 0xbc, 0x2b, 0xad, 0xac, 0x15,
3858 0xd1, 0x4e, 0xdc, 0xc0, 0x18, 0xc8, 0xb9, 0x97, 0xaf, 0xda, 0x87, 0xd7,
3859 0xd7, 0xda, 0xe3, 0x5d, 0xd9, 0xbe, 0xc7, 0x2e, 0x35, 0xe7, 0x82, 0x9a,
3860 0x13, 0x56, 0xb2, 0xde, 0xbe, 0xcf, 0xcf, 0x64, 0xfb, 0x3e, 0xdd, 0x9b,
3861 0x3c, 0x97, 0xb0, 0xe6, 0x93, 0x98, 0x5b, 0x76, 0x07, 0xe3, 0x75, 0xb9,
3862 0xdc, 0xca, 0x5b, 0x17, 0xe5, 0xc2, 0xe6, 0xda, 0xbf, 0xc2, 0x75, 0x3b,
3863 0x4d, 0xbf, 0xf2, 0x69, 0xe4, 0x77, 0x8e, 0x3d, 0xaa, 0xe4, 0xbd, 0xdb,
3864 0x1a, 0x3c, 0x58, 0xd3, 0xcc, 0xf1, 0x9f, 0x09, 0x75, 0x75, 0x44, 0xc5,
3865 0x98, 0xdb, 0xa0, 0xa7, 0x7d, 0xcf, 0xc0, 0x67, 0x47, 0x6d, 0x35, 0xe7,
3866 0x92, 0x35, 0x2d, 0xfb, 0x4e, 0x0d, 0x1a, 0x97, 0x10, 0xdb, 0x9c, 0x18,
3867 0xaf, 0x51, 0x2b, 0x59, 0x7c, 0x27, 0xfe, 0x4e, 0xd6, 0x01, 0xd0, 0xe5,
3868 0xe0, 0xf0, 0xcf, 0xe4, 0xa8, 0x9c, 0xa8, 0x1c, 0x43, 0x2e, 0x9c, 0x93,
3869 0xe1, 0x67, 0x90, 0x37, 0x2a, 0x05, 0x3c, 0x49, 0x9f, 0xf5, 0x72, 0xe0,
3870 0x9c, 0x7a, 0xcf, 0xfc, 0x24, 0xea, 0x64, 0xd8, 0x6e, 0x79, 0x70, 0x78,
3871 0x05, 0xcf, 0xbc, 0xa0, 0x70, 0xa8, 0x2b, 0x0d, 0xf8, 0x40, 0xe2, 0xf9,
3872 0x3d, 0xb2, 0xfb, 0x01, 0xda, 0x22, 0x32, 0xfd, 0x6d, 0x11, 0xf5, 0xee,
3873 0xbd, 0x6e, 0x75, 0x8a, 0xec, 0xa5, 0xdd, 0x34, 0x61, 0x63, 0x73, 0xde,
3874 0x99, 0xd6, 0xb6, 0x6b, 0x73, 0xe6, 0xa2, 0xac, 0x2a, 0xfb, 0xbb, 0x7d,
3875 0xd5, 0xfb, 0x3f, 0xba, 0x8a, 0x72, 0x38, 0x39, 0x2d, 0x77, 0xac, 0x7a,
3876 0xf6, 0x56, 0x5a, 0x3a, 0xaa, 0xe4, 0x3a, 0xa7, 0xe4, 0xda, 0x92, 0xc3,
3877 0x29, 0xca, 0x9c, 0xbc, 0xf0, 0xbd, 0x40, 0x4f, 0x16, 0xf7, 0xfb, 0xf6,
3878 0x33, 0xf8, 0x0c, 0x7f, 0x57, 0x42, 0xd9, 0xb0, 0xee, 0xbe, 0x7f, 0x37,
3879 0xcf, 0x59, 0xf7, 0xad, 0x92, 0xcf, 0x1b, 0xb7, 0xf1, 0xf9, 0x14, 0x62,
3880 0xea, 0xd0, 0x90, 0xc7, 0xeb, 0xab, 0x4b, 0x1f, 0xce, 0xeb, 0x37, 0x37,
3881 0x79, 0x0d, 0x49, 0x43, 0xd5, 0xaf, 0x5d, 0xbd, 0xd2, 0x8d, 0xa8, 0x07,
3882 0x7b, 0xf8, 0x09, 0xf6, 0x9a, 0x12, 0xd2, 0xe0, 0xed, 0xb7, 0xe1, 0x92,
3883 0x96, 0x80, 0x76, 0xd2, 0x73, 0x9f, 0xaf, 0x2f, 0xee, 0x7f, 0x74, 0xc7,
3884 0x7b, 0x97, 0xc4, 0x70, 0x86, 0x31, 0xa6, 0x2b, 0x9d, 0x65, 0x7d, 0xff,
3885 0x9a, 0x16, 0x5d, 0xe9, 0xcc, 0xde, 0xd4, 0xd9, 0xeb, 0xd0, 0x59, 0x5d,
3886 0x7e, 0x13, 0xbc, 0xc0, 0x9f, 0x9f, 0x19, 0x31, 0x0e, 0x13, 0x5b, 0x18,
3887 0x5c, 0x0f, 0x31, 0xd4, 0xd7, 0x5d, 0xc7, 0x47, 0xd0, 0xdd, 0x9b, 0xa2,
3888 0xf4, 0x07, 0x7e, 0x90, 0x7f, 0xd4, 0xf3, 0x8c, 0x61, 0xe4, 0xa9, 0x43,
3889 0xf9, 0x3e, 0x69, 0x53, 0x67, 0xfc, 0x33, 0x9e, 0x3e, 0x95, 0x6f, 0xfb,
3890 0xfa, 0xcc, 0xcd, 0x50, 0x67, 0xe6, 0x6e, 0x4f, 0x7f, 0x9d, 0x6a, 0xce,
3891 0x62, 0x32, 0xa1, 0xfc, 0xda, 0x1a, 0xba, 0x65, 0x37, 0x75, 0xf8, 0xb4,
3892 0xeb, 0xfd, 0x2f, 0xbb, 0xd3, 0xb2, 0xe8, 0x7e, 0x98, 0x1e, 0x3d, 0x1d,
3893 0x4e, 0x88, 0xe7, 0x3f, 0x57, 0xeb, 0x4f, 0x5f, 0x0d, 0x2b, 0x5b, 0x9d,
3894 0x80, 0xec, 0x4e, 0x56, 0x3e, 0xe6, 0xdb, 0xb7, 0xc7, 0xeb, 0xd0, 0x87,
3895 0xf0, 0x7a, 0xb8, 0x3c, 0x68, 0xbc, 0x8d, 0xb5, 0x26, 0x15, 0x86, 0x8b,
3896 0x88, 0xe3, 0xf3, 0x9a, 0xd8, 0xe4, 0x35, 0xa0, 0xcd, 0x9b, 0x97, 0x65,
3897 0x5d, 0xea, 0x32, 0x3e, 0x3d, 0xaa, 0xde, 0xbf, 0x7f, 0xa3, 0xcc, 0xb8,
3898 0x0c, 0xcc, 0x13, 0xeb, 0x93, 0x4b, 0x8d, 0x84, 0x5c, 0x22, 0x96, 0x18,
3899 0xc3, 0x7f, 0xf7, 0x98, 0x9f, 0x9b, 0xa3, 0xf2, 0x66, 0xb9, 0xbd, 0x56,
3900 0x1c, 0x95, 0xd7, 0xcb, 0x41, 0xbd, 0x48, 0x2c, 0xcb, 0xfc, 0x3f, 0x27,
3901 0x6f, 0x2d, 0x0d, 0xca, 0xfa, 0x0c, 0xf2, 0xf8, 0x10, 0x65, 0x30, 0x62,
3902 0x7c, 0x46, 0xfd, 0xbe, 0xe2, 0x4a, 0xeb, 0xbc, 0x85, 0x75, 0x97, 0x5b,
3903 0x72, 0x84, 0xe7, 0xd0, 0xfc, 0xde, 0xf8, 0x04, 0x56, 0xe1, 0xbc, 0x3e,
3904 0xa9, 0x2d, 0xa3, 0x2e, 0x2f, 0x73, 0x5d, 0xca, 0x69, 0x5a, 0x7d, 0x9f,
3905 0xc4, 0x3e, 0xf7, 0xf3, 0xbd, 0xf4, 0x18, 0x75, 0x71, 0xa5, 0xb5, 0x61,
3906 0xf1, 0x1c, 0x72, 0x4e, 0x1a, 0xd0, 0xd7, 0x97, 0x93, 0x3c, 0x27, 0xcf,
3907 0x0b, 0x7f, 0x9f, 0x52, 0x6b, 0xcc, 0xa0, 0x16, 0xb8, 0xd2, 0x5a, 0xb0,
3908 0x9e, 0x52, 0x7a, 0x6a, 0x54, 0x1f, 0xf0, 0xc7, 0x79, 0xcd, 0x7b, 0x86,
3909 0xb3, 0x6f, 0x88, 0xf5, 0xe7, 0x03, 0xc8, 0xff, 0xac, 0x3d, 0x89, 0xb7,
3910 0x28, 0x8b, 0x04, 0x6a, 0x5c, 0xae, 0xc5, 0xdf, 0x04, 0x25, 0x87, 0xf3,
3911 0x32, 0x09, 0x7a, 0x80, 0xcb, 0x5c, 0xc6, 0xfd, 0x5b, 0x65, 0x23, 0xe6,
3912 0xc5, 0x77, 0xbe, 0xaf, 0xb5, 0x81, 0x98, 0xbf, 0xb1, 0x19, 0xf3, 0xfb,
3913 0x71, 0x6d, 0x38, 0xa9, 0xa1, 0xff, 0x84, 0xf5, 0xd9, 0x77, 0x61, 0xcc,
3914 0x1f, 0xc7, 0x7c, 0x8e, 0xf5, 0x49, 0x69, 0x59, 0x6c, 0xf6, 0x99, 0x6a,
3915 0xc2, 0x77, 0x31, 0x72, 0xb2, 0xd8, 0x18, 0x8c, 0x9f, 0xd7, 0x1c, 0xf5,
3916 0xce, 0x46, 0x72, 0x88, 0x7d, 0xb7, 0x3e, 0x69, 0x2c, 0x4b, 0x22, 0x94,
3917 0x7e, 0x48, 0xdc, 0x86, 0x87, 0xb9, 0x17, 0x34, 0xf6, 0xdf, 0x6c, 0x69,
3918 0x6c, 0x9f, 0x63, 0x84, 0xd2, 0x87, 0xe4, 0x0f, 0xfc, 0x39, 0x8e, 0x9a,
3919 0xf3, 0x1f, 0x76, 0xf3, 0xec, 0xab, 0xe1, 0xf6, 0x82, 0x06, 0xd2, 0x76,
3920 0x63, 0xfb, 0xbe, 0x89, 0xad, 0x7d, 0xb9, 0x27, 0x6a, 0x98, 0xbd, 0x36,
3921 0xf6, 0x7d, 0x15, 0xcf, 0x3c, 0x04, 0x3a, 0xae, 0x84, 0x74, 0xeb, 0x21,
3922 0x29, 0x36, 0xae, 0xde, 0xa3, 0x9d, 0x06, 0x3e, 0xc3, 0xf5, 0xb9, 0xcf,
3923 0x21, 0xd0, 0x77, 0x45, 0xd3, 0xad, 0x43, 0x90, 0xa5, 0xb7, 0x47, 0xe8,
3924 0x39, 0xd3, 0xf8, 0xa1, 0x0c, 0x89, 0xbe, 0xa2, 0x29, 0xf9, 0xeb, 0xb5,
3925 0x51, 0x38, 0xc4, 0x94, 0x74, 0xaf, 0xcd, 0x4a, 0x68, 0x8d, 0x3d, 0x00,
3926 0xda, 0x22, 0xf5, 0xb8, 0x0b, 0x7e, 0x2c, 0x76, 0xd8, 0x22, 0xde, 0x67,
3927 0x1f, 0x77, 0xb5, 0x57, 0x7a, 0x89, 0xf7, 0x59, 0x0f, 0x1c, 0xc4, 0x7f,
3928 0xd6, 0x04, 0x2f, 0xb5, 0x32, 0xa9, 0x77, 0x54, 0xde, 0xcc, 0x37, 0x78,
3929 0xdf, 0x4c, 0x88, 0xf0, 0x1e, 0xe3, 0x43, 0x9f, 0x44, 0xbe, 0x3e, 0x8c,
3930 0x98, 0x90, 0x03, 0x76, 0xc6, 0xba, 0xa7, 0x86, 0x24, 0xec, 0xbd, 0xeb,
3931 0xa0, 0xfa, 0x25, 0x6f, 0x2d, 0x9b, 0xfe, 0xef, 0x53, 0x64, 0xdf, 0xf9,
3932 0x14, 0x7b, 0x9a, 0x03, 0xb0, 0x53, 0xd6, 0x23, 0xa2, 0x6f, 0xa0, 0xde,
3933 0xbc, 0xd4, 0x88, 0xf6, 0xf2, 0x7d, 0xcb, 0xd7, 0x5d, 0x5c, 0x13, 0xbb,
3934 0xc7, 0x14, 0x56, 0xf4, 0xef, 0xf1, 0x3b, 0xea, 0xa0, 0x6d, 0x98, 0x32,
3935 0x01, 0x4c, 0xc9, 0x3a, 0x69, 0xca, 0x7f, 0xe7, 0xcd, 0x70, 0x4e, 0x6c,
3936 0xab, 0x95, 0x86, 0x65, 0x03, 0x38, 0x6b, 0xdd, 0xb5, 0x10, 0x07, 0xdf,
3937 0xd6, 0xea, 0x65, 0xf5, 0xbb, 0x34, 0xed, 0x01, 0x60, 0xac, 0x44, 0x9f,
3938 0xaa, 0x75, 0x4e, 0x3e, 0x20, 0x9e, 0xbd, 0xc3, 0xca, 0x54, 0xcc, 0x5a,
3939 0xaf, 0x7a, 0xb5, 0xc5, 0x46, 0x75, 0x4a, 0xfe, 0xd4, 0x5d, 0x50, 0xbd,
3940 0xd2, 0x25, 0xd4, 0x1b, 0xe1, 0x45, 0x55, 0x6b, 0xb5, 0xe1, 0x54, 0xc4,
3941 0xb7, 0x67, 0x8f, 0xc0, 0x07, 0x4d, 0xf5, 0x6e, 0x81, 0xbe, 0xd2, 0x6a,
3942 0x65, 0x11, 0x2f, 0x74, 0xcb, 0x32, 0x8a, 0xc8, 0x73, 0x59, 0xf5, 0x7e,
3943 0x0a, 0xfd, 0xf7, 0xf7, 0x54, 0x1c, 0x96, 0x1a, 0x64, 0xf3, 0x5c, 0x02,
3944 0xeb, 0x68, 0xca, 0x3e, 0x43, 0x4a, 0x0f, 0x0f, 0x28, 0xec, 0x1a, 0x5a,
3945 0x41, 0x80, 0x5a, 0x1b, 0x12, 0x59, 0x81, 0xbf, 0xc2, 0x77, 0xc3, 0x6b,
3946 0xd4, 0x01, 0x65, 0x3b, 0x2b, 0x11, 0xc8, 0x9e, 0x58, 0x22, 0xb4, 0x48,
3947 0x19, 0xc7, 0x61, 0x17, 0x5c, 0x07, 0x32, 0xe6, 0xbb, 0x2c, 0xcb, 0x1d,
3948 0xf2, 0x4c, 0xc3, 0xf4, 0xdf, 0x3d, 0x7f, 0x89, 0xef, 0xa3, 0xeb, 0x73,
3949 0x63, 0x03, 0xc4, 0x4f, 0x52, 0x6a, 0x00, 0x63, 0x9c, 0x66, 0x0d, 0xce,
3950 0x18, 0x50, 0x88, 0x47, 0x94, 0xaf, 0xb3, 0x06, 0xf6, 0x7c, 0x9f, 0xf8,
3951 0x3a, 0x62, 0x11, 0xdb, 0x8e, 0x62, 0x8f, 0x9d, 0xe4, 0xea, 0xd5, 0x9e,
3952 0x93, 0xa0, 0xf3, 0xfc, 0x92, 0x39, 0x55, 0x90, 0x14, 0xdf, 0x71, 0x9e,
3953 0xb1, 0xc1, 0xf7, 0x06, 0xe2, 0xe4, 0x42, 0x85, 0xef, 0x33, 0x17, 0xe1,
3954 0x59, 0x53, 0x72, 0xbe, 0xcc, 0x1a, 0xf0, 0x76, 0xe8, 0x8b, 0xd7, 0xc5,
3955 0xf1, 0x10, 0xfc, 0xff, 0xa2, 0xc1, 0xdf, 0x91, 0xf1, 0x77, 0x41, 0x66,
3956 0x2a, 0xa1, 0x1d, 0x84, 0x8e, 0x0b, 0x46, 0xc4, 0xb7, 0x03, 0xa7, 0x4c,
3957 0x8c, 0x35, 0x62, 0x9c, 0xc3, 0xf7, 0x97, 0xdd, 0xcb, 0x2d, 0xd6, 0x3f,
3958 0x17, 0x10, 0xe7, 0xa6, 0x92, 0x53, 0xb0, 0x9d, 0x42, 0xbc, 0x13, 0xb4,
3959 0xfe, 0x5d, 0xdc, 0xcb, 0xbb, 0xdc, 0xc7, 0x4c, 0x5d, 0x94, 0x22, 0x30,
3960 0xfd, 0x48, 0xe2, 0x65, 0xd9, 0x83, 0x3a, 0x55, 0x93, 0x37, 0x2d, 0x73,
3961 0x5c, 0x34, 0xb5, 0xde, 0xf0, 0x7d, 0xb0, 0xbd, 0x37, 0x10, 0xdf, 0x3a,
3962 0xfc, 0xda, 0x3d, 0x5b, 0x26, 0x16, 0x3a, 0xaa, 0xde, 0x05, 0xb8, 0x60,
3963 0xb1, 0x7f, 0xc7, 0xdf, 0x44, 0xfe, 0xa5, 0xda, 0x63, 0xeb, 0x8c, 0x8d,
3964 0xfd, 0x63, 0xd2, 0xe7, 0xf1, 0x78, 0xc0, 0xf2, 0x68, 0xe4, 0x3a, 0x91,
3965 0xb6, 0x75, 0xce, 0xfb, 0xeb, 0x9c, 0xf5, 0xd7, 0xa9, 0xf9, 0xeb, 0x5c,
3966 0xd8, 0x5c, 0xe7, 0x6e, 0xe8, 0xbf, 0xd5, 0x7a, 0x0a, 0xf8, 0x21, 0x93,
3967 0x6a, 0xb5, 0x1c, 0xd4, 0x59, 0xa5, 0xd1, 0x79, 0x75, 0x46, 0xaa, 0xa7,
3968 0xbf, 0x71, 0x6f, 0xc6, 0x2a, 0xc4, 0xc3, 0x0a, 0x7b, 0xa0, 0x92, 0x82,
3969 0x1d, 0x16, 0xc4, 0xc3, 0xdc, 0x3c, 0xb7, 0xf3, 0xce, 0xf5, 0xba, 0xa1,
3970 0xc3, 0x1c, 0x72, 0x86, 0x91, 0x39, 0x67, 0x49, 0x61, 0xdf, 0x6f, 0xea,
3971 0xb0, 0xf3, 0x5e, 0xe4, 0x87, 0x9f, 0xc0, 0x66, 0x8c, 0x4c, 0xbd, 0x91,
3972 0x43, 0xbd, 0xc3, 0xf9, 0x77, 0x40, 0x8f, 0x85, 0x4c, 0xad, 0x51, 0xc8,
3973 0x9c, 0xe5, 0x79, 0x0e, 0xe6, 0xd5, 0x1a, 0x3d, 0x90, 0x7b, 0x8f, 0xea,
3974 0x8b, 0xbc, 0x5c, 0x8e, 0x31, 0x06, 0xc1, 0xd6, 0x63, 0x18, 0x8b, 0xab,
3975 0xdf, 0x68, 0xd5, 0xdd, 0x65, 0xf8, 0x74, 0x02, 0xe3, 0xd5, 0xae, 0x49,
3976 0x85, 0x47, 0x2d, 0x59, 0x71, 0x7f, 0xa5, 0x15, 0xcb, 0x97, 0xb5, 0x52,
3977 0x79, 0x18, 0x73, 0x46, 0xf9, 0x5b, 0x9f, 0x3d, 0xc0, 0x49, 0x53, 0xd5,
3978 0x1d, 0x69, 0x4a, 0x80, 0x26, 0xbd, 0x8d, 0xa6, 0x04, 0xe8, 0x41, 0xcc,
3979 0x3c, 0xc5, 0xde, 0xf1, 0xa8, 0x9c, 0x28, 0xf3, 0x9d, 0x26, 0xfe, 0x46,
3980 0xd5, 0x90, 0x30, 0xb0, 0x65, 0xe4, 0x94, 0x19, 0x5f, 0x57, 0xbd, 0x1a,
3981 0x73, 0xb8, 0x2e, 0x23, 0xa9, 0xba, 0xa8, 0xfc, 0x92, 0x38, 0x81, 0x7c,
3982 0xf5, 0x86, 0xdb, 0x23, 0x6f, 0xfa, 0x7b, 0x5d, 0x14, 0x9e, 0x33, 0x6e,
3983 0xdf, 0xeb, 0xc9, 0x4a, 0x2a, 0xf3, 0x8a, 0x15, 0xf2, 0xf9, 0xea, 0xc3,
3984 0x5e, 0x7b, 0x30, 0x37, 0x95, 0x39, 0xdf, 0xd8, 0x69, 0xae, 0x83, 0xb9,
3985 0x91, 0xb6, 0xb9, 0x0e, 0xe6, 0xf5, 0x20, 0xef, 0xf5, 0x28, 0x9e, 0x4a,
3986 0xa0, 0xeb, 0x52, 0x99, 0x3c, 0xf1, 0x0c, 0x82, 0x7b, 0x1a, 0xc4, 0xc6,
3987 0x53, 0xe2, 0x9f, 0xd9, 0xf2, 0xf7, 0x7a, 0x57, 0xf5, 0x6b, 0x94, 0x0d,
3988 0x4c, 0x58, 0x3c, 0x9b, 0x99, 0xd1, 0xb2, 0xf5, 0x3c, 0x72, 0xd5, 0x8d,
3989 0xc4, 0x43, 0x29, 0x1b, 0xb9, 0x92, 0xe7, 0x3c, 0x8d, 0x72, 0x81, 0xef,
3990 0x3d, 0xc3, 0x2e, 0xde, 0x21, 0x5e, 0xbe, 0x31, 0xa4, 0xde, 0x43, 0x70,
3991 0xfc, 0x73, 0x20, 0x31, 0x32, 0x63, 0x7c, 0xf7, 0xe0, 0x6e, 0xa9, 0x2f,
3992 0x7f, 0x11, 0x63, 0x19, 0xe4, 0xc5, 0x43, 0x5a, 0xe6, 0xdc, 0x24, 0xae,
3993 0x1f, 0xc2, 0x35, 0xe2, 0xf0, 0x72, 0x0e, 0xf7, 0x1f, 0xc2, 0xf5, 0xbc,
3994 0x96, 0x6d, 0xe6, 0x70, 0xfd, 0x30, 0xae, 0x27, 0x48, 0x9b, 0xf3, 0x8a,
3995 0x35, 0xa5, 0xd9, 0x58, 0xcb, 0x3e, 0x37, 0x89, 0x4f, 0xfb, 0x7a, 0xbc,
3996 0x07, 0x3d, 0x95, 0x79, 0x3e, 0x96, 0x04, 0x4d, 0x0f, 0x6a, 0x4e, 0xbd,
3997 0x1b, 0x6b, 0x0c, 0xe1, 0x79, 0xda, 0x54, 0xfb, 0x39, 0xd4, 0x6d, 0xaa,
3998 0x67, 0x14, 0x4a, 0xa7, 0x81, 0x77, 0x1f, 0x41, 0xde, 0xd7, 0xc4, 0xb1,
3999 0x1e, 0x97, 0x62, 0x2a, 0x2d, 0x0b, 0xf5, 0x90, 0x64, 0x63, 0x05, 0x7c,
4000 0x2f, 0x48, 0x66, 0x1c, 0xf7, 0xeb, 0xb4, 0x05, 0xce, 0x2b, 0x49, 0xb1,
4001 0x4a, 0xfc, 0xce, 0x7e, 0xd1, 0x57, 0xc0, 0x37, 0xfb, 0x44, 0x79, 0xc8,
4002 0x20, 0x46, 0xfb, 0xdd, 0xa1, 0xa7, 0xe5, 0xbd, 0xd3, 0x8c, 0x7c, 0xac,
4003 0x65, 0xea, 0xfe, 0x59, 0x9d, 0xc5, 0xdf, 0x2b, 0xb1, 0x47, 0x25, 0xc5,
4004 0x50, 0x9a, 0x7d, 0x0e, 0xd5, 0x17, 0x4f, 0x79, 0x67, 0x7a, 0xed, 0xef,
4005 0x90, 0x04, 0xfe, 0xc2, 0x7d, 0xbf, 0x82, 0xe7, 0xbd, 0xbe, 0x54, 0xb6,
4006 0xf9, 0x41, 0x5d, 0xf0, 0x5d, 0xfd, 0x15, 0xe8, 0xe2, 0xfc, 0x87, 0xf6,
4007 0xb9, 0xd8, 0xe3, 0x9a, 0x47, 0x2c, 0x62, 0x7f, 0x2c, 0x90, 0xdf, 0xd5,
4008 0x34, 0x92, 0xbe, 0xc3, 0x58, 0x4b, 0x52, 0x8c, 0xb3, 0xb9, 0x58, 0x42,
4009 0xd5, 0xbe, 0x1b, 0x4b, 0xf2, 0xc4, 0x16, 0xbd, 0xa4, 0x95, 0x72, 0x78,
4010 0x04, 0xf5, 0x1a, 0x7f, 0xff, 0xf0, 0xb8, 0xe4, 0x53, 0xec, 0xd1, 0x84,
4011 0x90, 0x0b, 0x0b, 0xf8, 0xbe, 0x25, 0xb7, 0x92, 0x2f, 0xb7, 0x7c, 0xf5,
4012 0x5b, 0x4a, 0x77, 0x35, 0x8b, 0xfb, 0x05, 0xbd, 0x8b, 0x69, 0xa5, 0xb3,
4013 0x9a, 0x7a, 0xcf, 0x36, 0xe0, 0x3d, 0xe8, 0xbf, 0xed, 0x6c, 0x73, 0x93,
4014 0x16, 0x69, 0xfb, 0x38, 0xdf, 0x5b, 0x18, 0xb6, 0x85, 0xf4, 0x93, 0x0f,
4015 0xe6, 0xac, 0xe0, 0x5c, 0x34, 0xe0, 0x21, 0xe0, 0xf3, 0xa3, 0xca, 0x85,
4016 0x74, 0xee, 0x31, 0xa4, 0x7b, 0xca, 0x08, 0x59, 0xcc, 0x01, 0x9f, 0xf6,
4017 0xfb, 0xf8, 0xff, 0x37, 0xe5, 0xea, 0xf1, 0x1e, 0x86, 0xa8, 0xfc, 0xdf,
4018 0x8b, 0xee, 0xa0, 0xf7, 0xab, 0xcf, 0x80, 0x0d, 0xe7, 0xac, 0xb5, 0xc5,
4019 0x67, 0x6d, 0x07, 0x3e, 0x6b, 0x3e, 0x9f, 0x1f, 0x7e, 0x4e, 0xea, 0xd1,
4020 0x59, 0x5b, 0xb2, 0xc1, 0x23, 0x6d, 0x6a, 0x27, 0x7b, 0xe3, 0x6f, 0x9c,
4021 0xd4, 0xef, 0xad, 0xa2, 0xb6, 0x7b, 0xad, 0x5e, 0x27, 0xeb, 0x64, 0xcf,
4022 0xee, 0xce, 0x22, 0xd7, 0x55, 0xab, 0x5e, 0xcd, 0x5c, 0x75, 0xd9, 0x6b,
4023 0xde, 0x69, 0x6f, 0x0d, 0x34, 0xff, 0x8e, 0x7a, 0xef, 0xa4, 0xe4, 0x7a,
4024 0x7d, 0xa9, 0x6a, 0xb5, 0x3d, 0x57, 0xde, 0xc0, 0x3c, 0x39, 0x5c, 0x90,
4025 0x19, 0xe8, 0x31, 0x89, 0xeb, 0x9b, 0xe5, 0xe5, 0x65, 0x75, 0x86, 0xe4,
4026 0x9f, 0xd5, 0xf0, 0x0c, 0x46, 0x9d, 0x43, 0x23, 0x5e, 0xcd, 0xaa, 0x78,
4027 0xbd, 0xb1, 0xac, 0xee, 0xa9, 0xdf, 0x3c, 0xd4, 0xdd, 0x19, 0xc4, 0x73,
4028 0xd4, 0x06, 0xd6, 0x6e, 0x29, 0xa2, 0x86, 0x3e, 0x6b, 0xcd, 0x18, 0xc4,
4029 0x29, 0x5c, 0x6b, 0x03, 0x6b, 0x9d, 0x5f, 0x96, 0xbd, 0x7c, 0xa7, 0xa3,
4030 0xaa, 0xce, 0xbd, 0xbc, 0x7e, 0xf5, 0xbc, 0x04, 0xbf, 0xd7, 0x8d, 0xfa,
4031 0x39, 0x8e, 0xef, 0x95, 0xf0, 0xb7, 0xa7, 0x8c, 0x01, 0xa8, 0x6b, 0x66,
4032 0x0a, 0x58, 0xaf, 0xd5, 0xf2, 0xfa, 0xd9, 0x2d, 0xd8, 0x7d, 0x84, 0xbf,
4033 0x65, 0xc0, 0xdf, 0x23, 0xb0, 0x13, 0xf8, 0xc1, 0xe6, 0x38, 0xaf, 0x59,
4034 0x4b, 0x04, 0xd7, 0x4c, 0x58, 0xff, 0x1b, 0xed, 0xcc, 0xfa, 0xa1, 0x98,
4035 0x41, 0x00, 0x00, 0x00 };
4036static u32 bnx2_TXP_b09FwData[(0xd0/4) + 1] = {
4037 0x00000000, 0x00000014, 0x00000014, 0x00000014, 0x00000014, 0x00000010,
4038 0x00000030, 0x00000030, 0x00000000, 0x00000000, 0x00000000, 0x00000010,
4039 0x00008000, 0x00000000, 0x00000000, 0x00000000, 0x00008002, 0x00000000,
4040 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
4041 0x00000000, 0x00000005, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
4042 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000006,
4043 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
4044 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
4045 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 };
4046static u32 bnx2_TXP_b09FwRodata[(0x30/4) + 1] = {
4047 0x08003be8, 0x08003c14, 0x08003c5c, 0x08003c5c, 0x08003ae8, 0x08003b14,
4048 0x08003b14, 0x08003c5c, 0x08003c5c, 0x08003c5c, 0x08003b7c, 0x00000000,
4049 0x00000000 };
4050static u32 bnx2_TXP_b09FwBss[(0xa20/4) + 1] = { 0x0 };
4051static u32 bnx2_TXP_b09FwSbss[(0x80/4) + 1] = { 0x0 };
4052
4053static struct fw_info bnx2_txp_fw_09 = {
4054 .ver_major = 0x1,
4055 .ver_minor = 0x0,
4056 .ver_fix = 0x0,
4057
4058 .start_addr = 0x08000060,
4059
4060 .text_addr = 0x08000000,
4061 .text_len = 0x4194,
4062 .text_index = 0x0,
4063 .gz_text = bnx2_TXP_b09FwText,
4064 .gz_text_len = sizeof(bnx2_TXP_b09FwText),
4065
4066 .data_addr = 0x080041e0,
4067 .data_len = 0xd0,
4068 .data_index = 0x0,
4069 .data = bnx2_TXP_b09FwData,
4070
4071 .sbss_addr = 0x080042b0,
4072 .sbss_len = 0x80,
4073 .sbss_index = 0x0,
4074 .sbss = bnx2_TXP_b09FwSbss,
4075
4076 .bss_addr = 0x08004330,
4077 .bss_len = 0xa20,
4078 .bss_index = 0x0,
4079 .bss = bnx2_TXP_b09FwBss,
4080
4081 .rodata_addr = 0x08004198,
4082 .rodata_len = 0x30,
4083 .rodata_index = 0x0,
4084 .rodata = bnx2_TXP_b09FwRodata,
4085};
4086
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 17a461152d39..488d8ed9e740 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1336,6 +1336,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1336 goto err_undo_flags; 1336 goto err_undo_flags;
1337 } 1337 }
1338 1338
1339 if (slave_dev->get_stats == NULL) {
1340 printk(KERN_NOTICE DRV_NAME
1341 ": %s: the driver for slave device %s does not provide "
1342 "get_stats function, network statistics will be "
1343 "inaccurate.\n", bond_dev->name, slave_dev->name);
1344 }
1345
1339 new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL); 1346 new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL);
1340 if (!new_slave) { 1347 if (!new_slave) {
1341 res = -ENOMEM; 1348 res = -ENOMEM;
@@ -3605,33 +3612,35 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
3605 read_lock_bh(&bond->lock); 3612 read_lock_bh(&bond->lock);
3606 3613
3607 bond_for_each_slave(bond, slave, i) { 3614 bond_for_each_slave(bond, slave, i) {
3608 sstats = slave->dev->get_stats(slave->dev); 3615 if (slave->dev->get_stats) {
3609 3616 sstats = slave->dev->get_stats(slave->dev);
3610 stats->rx_packets += sstats->rx_packets; 3617
3611 stats->rx_bytes += sstats->rx_bytes; 3618 stats->rx_packets += sstats->rx_packets;
3612 stats->rx_errors += sstats->rx_errors; 3619 stats->rx_bytes += sstats->rx_bytes;
3613 stats->rx_dropped += sstats->rx_dropped; 3620 stats->rx_errors += sstats->rx_errors;
3614 3621 stats->rx_dropped += sstats->rx_dropped;
3615 stats->tx_packets += sstats->tx_packets; 3622
3616 stats->tx_bytes += sstats->tx_bytes; 3623 stats->tx_packets += sstats->tx_packets;
3617 stats->tx_errors += sstats->tx_errors; 3624 stats->tx_bytes += sstats->tx_bytes;
3618 stats->tx_dropped += sstats->tx_dropped; 3625 stats->tx_errors += sstats->tx_errors;
3619 3626 stats->tx_dropped += sstats->tx_dropped;
3620 stats->multicast += sstats->multicast; 3627
3621 stats->collisions += sstats->collisions; 3628 stats->multicast += sstats->multicast;
3622 3629 stats->collisions += sstats->collisions;
3623 stats->rx_length_errors += sstats->rx_length_errors; 3630
3624 stats->rx_over_errors += sstats->rx_over_errors; 3631 stats->rx_length_errors += sstats->rx_length_errors;
3625 stats->rx_crc_errors += sstats->rx_crc_errors; 3632 stats->rx_over_errors += sstats->rx_over_errors;
3626 stats->rx_frame_errors += sstats->rx_frame_errors; 3633 stats->rx_crc_errors += sstats->rx_crc_errors;
3627 stats->rx_fifo_errors += sstats->rx_fifo_errors; 3634 stats->rx_frame_errors += sstats->rx_frame_errors;
3628 stats->rx_missed_errors += sstats->rx_missed_errors; 3635 stats->rx_fifo_errors += sstats->rx_fifo_errors;
3629 3636 stats->rx_missed_errors += sstats->rx_missed_errors;
3630 stats->tx_aborted_errors += sstats->tx_aborted_errors; 3637
3631 stats->tx_carrier_errors += sstats->tx_carrier_errors; 3638 stats->tx_aborted_errors += sstats->tx_aborted_errors;
3632 stats->tx_fifo_errors += sstats->tx_fifo_errors; 3639 stats->tx_carrier_errors += sstats->tx_carrier_errors;
3633 stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors; 3640 stats->tx_fifo_errors += sstats->tx_fifo_errors;
3634 stats->tx_window_errors += sstats->tx_window_errors; 3641 stats->tx_heartbeat_errors += sstats->tx_heartbeat_errors;
3642 stats->tx_window_errors += sstats->tx_window_errors;
3643 }
3635 } 3644 }
3636 3645
3637 read_unlock_bh(&bond->lock); 3646 read_unlock_bh(&bond->lock);
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index fe08f3845491..c8126484c2be 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -2825,7 +2825,7 @@ static inline int cas_xmit_tx_ringN(struct cas *cp, int ring,
2825 u64 csum_start_off, csum_stuff_off; 2825 u64 csum_start_off, csum_stuff_off;
2826 2826
2827 csum_start_off = (u64) (skb->h.raw - skb->data); 2827 csum_start_off = (u64) (skb->h.raw - skb->data);
2828 csum_stuff_off = (u64) ((skb->h.raw + skb->csum) - skb->data); 2828 csum_stuff_off = csum_start_off + skb->csum_offset;
2829 2829
2830 ctrl = TX_DESC_CSUM_EN | 2830 ctrl = TX_DESC_CSUM_EN |
2831 CAS_BASE(TX_DESC_CSUM_START, csum_start_off) | 2831 CAS_BASE(TX_DESC_CSUM_START, csum_start_off) |
diff --git a/drivers/net/chelsio/Makefile b/drivers/net/chelsio/Makefile
index 54c78d94f48b..382d23f810ab 100644
--- a/drivers/net/chelsio/Makefile
+++ b/drivers/net/chelsio/Makefile
@@ -1,11 +1,11 @@
1# 1#
2# Chelsio 10Gb NIC driver for Linux. 2# Chelsio T1 driver
3# 3#
4 4
5obj-$(CONFIG_CHELSIO_T1) += cxgb.o 5obj-$(CONFIG_CHELSIO_T1) += cxgb.o
6 6
7EXTRA_CFLAGS += -Idrivers/net/chelsio $(DEBUG_FLAGS) 7cxgb-$(CONFIG_CHELSIO_T1_1G) += ixf1010.o mac.o mv88e1xxx.o vsc7326.o vsc8244.o
8cxgb-objs := cxgb2.o espi.o tp.o pm3393.o sge.o subr.o \
9 mv88x201x.o my3126.o $(cxgb-y)
8 10
9 11
10cxgb-objs := cxgb2.o espi.o pm3393.o sge.o subr.o mv88x201x.o
11
diff --git a/drivers/net/chelsio/common.h b/drivers/net/chelsio/common.h
index 8b1bedbce0d5..74758d2c7af8 100644
--- a/drivers/net/chelsio/common.h
+++ b/drivers/net/chelsio/common.h
@@ -45,6 +45,7 @@
45#include <linux/delay.h> 45#include <linux/delay.h>
46#include <linux/pci.h> 46#include <linux/pci.h>
47#include <linux/ethtool.h> 47#include <linux/ethtool.h>
48#include <linux/if_vlan.h>
48#include <linux/mii.h> 49#include <linux/mii.h>
49#include <linux/crc32.h> 50#include <linux/crc32.h>
50#include <linux/init.h> 51#include <linux/init.h>
@@ -53,13 +54,30 @@
53 54
54#define DRV_DESCRIPTION "Chelsio 10Gb Ethernet Driver" 55#define DRV_DESCRIPTION "Chelsio 10Gb Ethernet Driver"
55#define DRV_NAME "cxgb" 56#define DRV_NAME "cxgb"
56#define DRV_VERSION "2.1.1" 57#define DRV_VERSION "2.2"
57#define PFX DRV_NAME ": " 58#define PFX DRV_NAME ": "
58 59
59#define CH_ERR(fmt, ...) printk(KERN_ERR PFX fmt, ## __VA_ARGS__) 60#define CH_ERR(fmt, ...) printk(KERN_ERR PFX fmt, ## __VA_ARGS__)
60#define CH_WARN(fmt, ...) printk(KERN_WARNING PFX fmt, ## __VA_ARGS__) 61#define CH_WARN(fmt, ...) printk(KERN_WARNING PFX fmt, ## __VA_ARGS__)
61#define CH_ALERT(fmt, ...) printk(KERN_ALERT PFX fmt, ## __VA_ARGS__) 62#define CH_ALERT(fmt, ...) printk(KERN_ALERT PFX fmt, ## __VA_ARGS__)
62 63
64/*
65 * More powerful macro that selectively prints messages based on msg_enable.
66 * For info and debugging messages.
67 */
68#define CH_MSG(adapter, level, category, fmt, ...) do { \
69 if ((adapter)->msg_enable & NETIF_MSG_##category) \
70 printk(KERN_##level PFX "%s: " fmt, (adapter)->name, \
71 ## __VA_ARGS__); \
72} while (0)
73
74#ifdef DEBUG
75# define CH_DBG(adapter, category, fmt, ...) \
76 CH_MSG(adapter, DEBUG, category, fmt, ## __VA_ARGS__)
77#else
78# define CH_DBG(fmt, ...)
79#endif
80
63#define CH_DEVICE(devid, ssid, idx) \ 81#define CH_DEVICE(devid, ssid, idx) \
64 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, ssid, 0, 0, idx } 82 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, ssid, 0, 0, idx }
65 83
@@ -71,10 +89,6 @@
71 89
72typedef struct adapter adapter_t; 90typedef struct adapter adapter_t;
73 91
74void t1_elmer0_ext_intr(adapter_t *adapter);
75void t1_link_changed(adapter_t *adapter, int port_id, int link_status,
76 int speed, int duplex, int fc);
77
78struct t1_rx_mode { 92struct t1_rx_mode {
79 struct net_device *dev; 93 struct net_device *dev;
80 u32 idx; 94 u32 idx;
@@ -97,26 +111,53 @@ static inline u8 *t1_get_next_mcaddr(struct t1_rx_mode *rm)
97} 111}
98 112
99#define MAX_NPORTS 4 113#define MAX_NPORTS 4
114#define PORT_MASK ((1 << MAX_NPORTS) - 1)
115#define NMTUS 8
116#define TCB_SIZE 128
100 117
101#define SPEED_INVALID 0xffff 118#define SPEED_INVALID 0xffff
102#define DUPLEX_INVALID 0xff 119#define DUPLEX_INVALID 0xff
103 120
104enum { 121enum {
105 CHBT_BOARD_N110, 122 CHBT_BOARD_N110,
106 CHBT_BOARD_N210 123 CHBT_BOARD_N210,
124 CHBT_BOARD_7500,
125 CHBT_BOARD_8000,
126 CHBT_BOARD_CHT101,
127 CHBT_BOARD_CHT110,
128 CHBT_BOARD_CHT210,
129 CHBT_BOARD_CHT204,
130 CHBT_BOARD_CHT204V,
131 CHBT_BOARD_CHT204E,
132 CHBT_BOARD_CHN204,
133 CHBT_BOARD_COUGAR,
134 CHBT_BOARD_6800,
135 CHBT_BOARD_SIMUL,
107}; 136};
108 137
109enum { 138enum {
139 CHBT_TERM_FPGA,
110 CHBT_TERM_T1, 140 CHBT_TERM_T1,
111 CHBT_TERM_T2 141 CHBT_TERM_T2,
142 CHBT_TERM_T3
112}; 143};
113 144
114enum { 145enum {
146 CHBT_MAC_CHELSIO_A,
147 CHBT_MAC_IXF1010,
115 CHBT_MAC_PM3393, 148 CHBT_MAC_PM3393,
149 CHBT_MAC_VSC7321,
150 CHBT_MAC_DUMMY
116}; 151};
117 152
118enum { 153enum {
154 CHBT_PHY_88E1041,
155 CHBT_PHY_88E1111,
119 CHBT_PHY_88X2010, 156 CHBT_PHY_88X2010,
157 CHBT_PHY_XPAK,
158 CHBT_PHY_MY3126,
159 CHBT_PHY_8244,
160 CHBT_PHY_DUMMY
120}; 161};
121 162
122enum { 163enum {
@@ -150,16 +191,44 @@ struct chelsio_pci_params {
150 unsigned char is_pcix; 191 unsigned char is_pcix;
151}; 192};
152 193
194struct tp_params {
195 unsigned int pm_size;
196 unsigned int cm_size;
197 unsigned int pm_rx_base;
198 unsigned int pm_tx_base;
199 unsigned int pm_rx_pg_size;
200 unsigned int pm_tx_pg_size;
201 unsigned int pm_rx_num_pgs;
202 unsigned int pm_tx_num_pgs;
203 unsigned int rx_coalescing_size;
204 unsigned int use_5tuple_mode;
205};
206
207struct mc5_params {
208 unsigned int mode; /* selects MC5 width */
209 unsigned int nservers; /* size of server region */
210 unsigned int nroutes; /* size of routing region */
211};
212
213/* Default MC5 region sizes */
214#define DEFAULT_SERVER_REGION_LEN 256
215#define DEFAULT_RT_REGION_LEN 1024
216
153struct adapter_params { 217struct adapter_params {
154 struct sge_params sge; 218 struct sge_params sge;
219 struct mc5_params mc5;
220 struct tp_params tp;
155 struct chelsio_pci_params pci; 221 struct chelsio_pci_params pci;
156 222
157 const struct board_info *brd_info; 223 const struct board_info *brd_info;
158 224
225 unsigned short mtus[NMTUS];
159 unsigned int nports; /* # of ethernet ports */ 226 unsigned int nports; /* # of ethernet ports */
160 unsigned int stats_update_period; 227 unsigned int stats_update_period;
161 unsigned short chip_revision; 228 unsigned short chip_revision;
162 unsigned char chip_version; 229 unsigned char chip_version;
230 unsigned char is_asic;
231 unsigned char has_msi;
163}; 232};
164 233
165struct link_config { 234struct link_config {
@@ -207,17 +276,20 @@ struct adapter {
207 /* Terminator modules. */ 276 /* Terminator modules. */
208 struct sge *sge; 277 struct sge *sge;
209 struct peespi *espi; 278 struct peespi *espi;
279 struct petp *tp;
210 280
211 struct port_info port[MAX_NPORTS]; 281 struct port_info port[MAX_NPORTS];
212 struct delayed_work stats_update_task; 282 struct delayed_work stats_update_task;
213 struct timer_list stats_update_timer; 283 struct timer_list stats_update_timer;
214 284
215 struct semaphore mib_mutex;
216 spinlock_t tpi_lock; 285 spinlock_t tpi_lock;
217 spinlock_t work_lock; 286 spinlock_t work_lock;
287 spinlock_t mac_lock;
288
218 /* guards async operations */ 289 /* guards async operations */
219 spinlock_t async_lock ____cacheline_aligned; 290 spinlock_t async_lock ____cacheline_aligned;
220 u32 slow_intr_mask; 291 u32 slow_intr_mask;
292 int t1powersave;
221}; 293};
222 294
223enum { /* adapter flags */ 295enum { /* adapter flags */
@@ -256,6 +328,11 @@ struct board_info {
256 const char *desc; 328 const char *desc;
257}; 329};
258 330
331static inline int t1_is_asic(const adapter_t *adapter)
332{
333 return adapter->params.is_asic;
334}
335
259extern struct pci_device_id t1_pci_tbl[]; 336extern struct pci_device_id t1_pci_tbl[];
260 337
261static inline int adapter_matches_type(const adapter_t *adapter, 338static inline int adapter_matches_type(const adapter_t *adapter,
@@ -285,13 +362,15 @@ static inline unsigned int core_ticks_per_usec(const adapter_t *adap)
285 return board_info(adap)->clock_core / 1000000; 362 return board_info(adap)->clock_core / 1000000;
286} 363}
287 364
365extern int __t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp);
366extern int __t1_tpi_write(adapter_t *adapter, u32 addr, u32 value);
288extern int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value); 367extern int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value);
289extern int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *value); 368extern int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *value);
290 369
291extern void t1_interrupts_enable(adapter_t *adapter); 370extern void t1_interrupts_enable(adapter_t *adapter);
292extern void t1_interrupts_disable(adapter_t *adapter); 371extern void t1_interrupts_disable(adapter_t *adapter);
293extern void t1_interrupts_clear(adapter_t *adapter); 372extern void t1_interrupts_clear(adapter_t *adapter);
294extern int elmer0_ext_intr_handler(adapter_t *adapter); 373extern int t1_elmer0_ext_intr_handler(adapter_t *adapter);
295extern int t1_slow_intr_handler(adapter_t *adapter); 374extern int t1_slow_intr_handler(adapter_t *adapter);
296 375
297extern int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc); 376extern int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc);
@@ -305,9 +384,7 @@ extern int t1_init_hw_modules(adapter_t *adapter);
305extern int t1_init_sw_modules(adapter_t *adapter, const struct board_info *bi); 384extern int t1_init_sw_modules(adapter_t *adapter, const struct board_info *bi);
306extern void t1_free_sw_modules(adapter_t *adapter); 385extern void t1_free_sw_modules(adapter_t *adapter);
307extern void t1_fatal_err(adapter_t *adapter); 386extern void t1_fatal_err(adapter_t *adapter);
308 387extern void t1_link_changed(adapter_t *adapter, int port_id);
309extern void t1_tp_set_udp_checksum_offload(adapter_t *adapter, int enable); 388extern void t1_link_negotiated(adapter_t *adapter, int port_id, int link_stat,
310extern void t1_tp_set_tcp_checksum_offload(adapter_t *adapter, int enable); 389 int speed, int duplex, int pause);
311extern void t1_tp_set_ip_checksum_offload(adapter_t *adapter, int enable);
312
313#endif /* _CXGB_COMMON_H_ */ 390#endif /* _CXGB_COMMON_H_ */
diff --git a/drivers/net/chelsio/cphy.h b/drivers/net/chelsio/cphy.h
index 3412342f7345..60901f25014e 100644
--- a/drivers/net/chelsio/cphy.h
+++ b/drivers/net/chelsio/cphy.h
@@ -52,7 +52,14 @@ struct mdio_ops {
52/* PHY interrupt types */ 52/* PHY interrupt types */
53enum { 53enum {
54 cphy_cause_link_change = 0x1, 54 cphy_cause_link_change = 0x1,
55 cphy_cause_error = 0x2 55 cphy_cause_error = 0x2,
56 cphy_cause_fifo_error = 0x3
57};
58
59enum {
60 PHY_LINK_UP = 0x1,
61 PHY_AUTONEG_RDY = 0x2,
62 PHY_AUTONEG_EN = 0x4
56}; 63};
57 64
58struct cphy; 65struct cphy;
@@ -81,7 +88,18 @@ struct cphy_ops {
81/* A PHY instance */ 88/* A PHY instance */
82struct cphy { 89struct cphy {
83 int addr; /* PHY address */ 90 int addr; /* PHY address */
91 int state; /* Link status state machine */
84 adapter_t *adapter; /* associated adapter */ 92 adapter_t *adapter; /* associated adapter */
93
94 struct work_struct phy_update;
95
96 u16 bmsr;
97 int count;
98 int act_count;
99 int act_on;
100
101 u32 elmer_gpo;
102
85 struct cphy_ops *ops; /* PHY operations */ 103 struct cphy_ops *ops; /* PHY operations */
86 int (*mdio_read)(adapter_t *adapter, int phy_addr, int mmd_addr, 104 int (*mdio_read)(adapter_t *adapter, int phy_addr, int mmd_addr,
87 int reg_addr, unsigned int *val); 105 int reg_addr, unsigned int *val);
@@ -142,6 +160,10 @@ struct gphy {
142 int (*reset)(adapter_t *adapter); 160 int (*reset)(adapter_t *adapter);
143}; 161};
144 162
163extern struct gphy t1_my3126_ops;
164extern struct gphy t1_mv88e1xxx_ops;
165extern struct gphy t1_vsc8244_ops;
166extern struct gphy t1_xpak_ops;
145extern struct gphy t1_mv88x201x_ops; 167extern struct gphy t1_mv88x201x_ops;
146extern struct gphy t1_dummy_phy_ops; 168extern struct gphy t1_dummy_phy_ops;
147 169
diff --git a/drivers/net/chelsio/cpl5_cmd.h b/drivers/net/chelsio/cpl5_cmd.h
index 5b357d9e88d6..35f565be4fd3 100644
--- a/drivers/net/chelsio/cpl5_cmd.h
+++ b/drivers/net/chelsio/cpl5_cmd.h
@@ -46,24 +46,385 @@
46#endif 46#endif
47 47
48enum CPL_opcode { 48enum CPL_opcode {
49 CPL_PASS_OPEN_REQ = 0x1,
50 CPL_PASS_OPEN_RPL = 0x2,
51 CPL_PASS_ESTABLISH = 0x3,
52 CPL_PASS_ACCEPT_REQ = 0xE,
53 CPL_PASS_ACCEPT_RPL = 0x4,
54 CPL_ACT_OPEN_REQ = 0x5,
55 CPL_ACT_OPEN_RPL = 0x6,
56 CPL_CLOSE_CON_REQ = 0x7,
57 CPL_CLOSE_CON_RPL = 0x8,
58 CPL_CLOSE_LISTSRV_REQ = 0x9,
59 CPL_CLOSE_LISTSRV_RPL = 0xA,
60 CPL_ABORT_REQ = 0xB,
61 CPL_ABORT_RPL = 0xC,
62 CPL_PEER_CLOSE = 0xD,
63 CPL_ACT_ESTABLISH = 0x17,
64
65 CPL_GET_TCB = 0x24,
66 CPL_GET_TCB_RPL = 0x25,
67 CPL_SET_TCB = 0x26,
68 CPL_SET_TCB_FIELD = 0x27,
69 CPL_SET_TCB_RPL = 0x28,
70 CPL_PCMD = 0x29,
71
72 CPL_PCMD_READ = 0x31,
73 CPL_PCMD_READ_RPL = 0x32,
74
75
76 CPL_RX_DATA = 0xA0,
77 CPL_RX_DATA_DDP = 0xA1,
78 CPL_RX_DATA_ACK = 0xA3,
49 CPL_RX_PKT = 0xAD, 79 CPL_RX_PKT = 0xAD,
80 CPL_RX_ISCSI_HDR = 0xAF,
81 CPL_TX_DATA_ACK = 0xB0,
82 CPL_TX_DATA = 0xB1,
50 CPL_TX_PKT = 0xB2, 83 CPL_TX_PKT = 0xB2,
51 CPL_TX_PKT_LSO = 0xB6, 84 CPL_TX_PKT_LSO = 0xB6,
85
86 CPL_RTE_DELETE_REQ = 0xC0,
87 CPL_RTE_DELETE_RPL = 0xC1,
88 CPL_RTE_WRITE_REQ = 0xC2,
89 CPL_RTE_WRITE_RPL = 0xD3,
90 CPL_RTE_READ_REQ = 0xC3,
91 CPL_RTE_READ_RPL = 0xC4,
92 CPL_L2T_WRITE_REQ = 0xC5,
93 CPL_L2T_WRITE_RPL = 0xD4,
94 CPL_L2T_READ_REQ = 0xC6,
95 CPL_L2T_READ_RPL = 0xC7,
96 CPL_SMT_WRITE_REQ = 0xC8,
97 CPL_SMT_WRITE_RPL = 0xD5,
98 CPL_SMT_READ_REQ = 0xC9,
99 CPL_SMT_READ_RPL = 0xCA,
100 CPL_ARP_MISS_REQ = 0xCD,
101 CPL_ARP_MISS_RPL = 0xCE,
102 CPL_MIGRATE_C2T_REQ = 0xDC,
103 CPL_MIGRATE_C2T_RPL = 0xDD,
104 CPL_ERROR = 0xD7,
105
106 /* internal: driver -> TOM */
107 CPL_MSS_CHANGE = 0xE1
52}; 108};
53 109
54enum { /* TX_PKT_LSO ethernet types */ 110#define NUM_CPL_CMDS 256
111
112enum CPL_error {
113 CPL_ERR_NONE = 0,
114 CPL_ERR_TCAM_PARITY = 1,
115 CPL_ERR_TCAM_FULL = 3,
116 CPL_ERR_CONN_RESET = 20,
117 CPL_ERR_CONN_EXIST = 22,
118 CPL_ERR_ARP_MISS = 23,
119 CPL_ERR_BAD_SYN = 24,
120 CPL_ERR_CONN_TIMEDOUT = 30,
121 CPL_ERR_XMIT_TIMEDOUT = 31,
122 CPL_ERR_PERSIST_TIMEDOUT = 32,
123 CPL_ERR_FINWAIT2_TIMEDOUT = 33,
124 CPL_ERR_KEEPALIVE_TIMEDOUT = 34,
125 CPL_ERR_ABORT_FAILED = 42,
126 CPL_ERR_GENERAL = 99
127};
128
129enum {
130 CPL_CONN_POLICY_AUTO = 0,
131 CPL_CONN_POLICY_ASK = 1,
132 CPL_CONN_POLICY_DENY = 3
133};
134
135enum {
136 ULP_MODE_NONE = 0,
137 ULP_MODE_TCPDDP = 1,
138 ULP_MODE_ISCSI = 2,
139 ULP_MODE_IWARP = 3,
140 ULP_MODE_SSL = 4
141};
142
143enum {
144 CPL_PASS_OPEN_ACCEPT,
145 CPL_PASS_OPEN_REJECT
146};
147
148enum {
149 CPL_ABORT_SEND_RST = 0,
150 CPL_ABORT_NO_RST,
151 CPL_ABORT_POST_CLOSE_REQ = 2
152};
153
154enum { // TX_PKT_LSO ethernet types
55 CPL_ETH_II, 155 CPL_ETH_II,
56 CPL_ETH_II_VLAN, 156 CPL_ETH_II_VLAN,
57 CPL_ETH_802_3, 157 CPL_ETH_802_3,
58 CPL_ETH_802_3_VLAN 158 CPL_ETH_802_3_VLAN
59}; 159};
60 160
61struct cpl_rx_data { 161union opcode_tid {
162 u32 opcode_tid;
163 u8 opcode;
164};
165
166#define S_OPCODE 24
167#define V_OPCODE(x) ((x) << S_OPCODE)
168#define G_OPCODE(x) (((x) >> S_OPCODE) & 0xFF)
169#define G_TID(x) ((x) & 0xFFFFFF)
170
171/* tid is assumed to be 24-bits */
172#define MK_OPCODE_TID(opcode, tid) (V_OPCODE(opcode) | (tid))
173
174#define OPCODE_TID(cmd) ((cmd)->ot.opcode_tid)
175
176/* extract the TID from a CPL command */
177#define GET_TID(cmd) (G_TID(ntohl(OPCODE_TID(cmd))))
178
179struct tcp_options {
180 u16 mss;
181 u8 wsf;
182#if defined(__LITTLE_ENDIAN_BITFIELD)
183 u8 rsvd:4;
184 u8 ecn:1;
185 u8 sack:1;
186 u8 tstamp:1;
187#else
188 u8 tstamp:1;
189 u8 sack:1;
190 u8 ecn:1;
191 u8 rsvd:4;
192#endif
193};
194
195struct cpl_pass_open_req {
196 union opcode_tid ot;
197 u16 local_port;
198 u16 peer_port;
199 u32 local_ip;
200 u32 peer_ip;
201 u32 opt0h;
202 u32 opt0l;
203 u32 peer_netmask;
204 u32 opt1;
205};
206
207struct cpl_pass_open_rpl {
208 union opcode_tid ot;
209 u16 local_port;
210 u16 peer_port;
211 u32 local_ip;
212 u32 peer_ip;
213 u8 resvd[7];
214 u8 status;
215};
216
217struct cpl_pass_establish {
218 union opcode_tid ot;
219 u16 local_port;
220 u16 peer_port;
221 u32 local_ip;
222 u32 peer_ip;
223 u32 tos_tid;
224 u8 l2t_idx;
225 u8 rsvd[3];
226 u32 snd_isn;
227 u32 rcv_isn;
228};
229
230struct cpl_pass_accept_req {
231 union opcode_tid ot;
232 u16 local_port;
233 u16 peer_port;
234 u32 local_ip;
235 u32 peer_ip;
236 u32 tos_tid;
237 struct tcp_options tcp_options;
238 u8 dst_mac[6];
239 u16 vlan_tag;
240 u8 src_mac[6];
241 u8 rsvd[2];
242 u32 rcv_isn;
243 u32 unknown_tcp_options;
244};
245
246struct cpl_pass_accept_rpl {
247 union opcode_tid ot;
248 u32 rsvd0;
249 u32 rsvd1;
250 u32 peer_ip;
251 u32 opt0h;
252 union {
253 u32 opt0l;
254 struct {
255 u8 rsvd[3];
256 u8 status;
257 };
258 };
259};
260
261struct cpl_act_open_req {
262 union opcode_tid ot;
263 u16 local_port;
264 u16 peer_port;
265 u32 local_ip;
266 u32 peer_ip;
267 u32 opt0h;
268 u32 opt0l;
269 u32 iff_vlantag;
270 u32 rsvd;
271};
272
273struct cpl_act_open_rpl {
274 union opcode_tid ot;
275 u16 local_port;
276 u16 peer_port;
277 u32 local_ip;
278 u32 peer_ip;
279 u32 new_tid;
280 u8 rsvd[3];
281 u8 status;
282};
283
284struct cpl_act_establish {
285 union opcode_tid ot;
286 u16 local_port;
287 u16 peer_port;
288 u32 local_ip;
289 u32 peer_ip;
290 u32 tos_tid;
291 u32 rsvd;
292 u32 snd_isn;
293 u32 rcv_isn;
294};
295
296struct cpl_get_tcb {
297 union opcode_tid ot;
298 u32 rsvd;
299};
300
301struct cpl_get_tcb_rpl {
302 union opcode_tid ot;
303 u16 len;
304 u8 rsvd;
305 u8 status;
306};
307
308struct cpl_set_tcb {
309 union opcode_tid ot;
310 u16 len;
311 u16 rsvd;
312};
313
314struct cpl_set_tcb_field {
315 union opcode_tid ot;
316 u8 rsvd[3];
317 u8 offset;
318 u32 mask;
319 u32 val;
320};
321
322struct cpl_set_tcb_rpl {
323 union opcode_tid ot;
324 u8 rsvd[3];
325 u8 status;
326};
327
328struct cpl_pcmd {
329 union opcode_tid ot;
330 u16 dlen_in;
331 u16 dlen_out;
332 u32 pcmd_parm[2];
333};
334
335struct cpl_pcmd_read {
336 union opcode_tid ot;
337 u32 rsvd1;
338 u16 rsvd2;
339 u32 addr;
340 u16 len;
341};
342
343struct cpl_pcmd_read_rpl {
344 union opcode_tid ot;
345 u16 len;
346};
347
348struct cpl_close_con_req {
349 union opcode_tid ot;
350 u32 rsvd;
351};
352
353struct cpl_close_con_rpl {
354 union opcode_tid ot;
355 u8 rsvd[3];
356 u8 status;
357 u32 snd_nxt;
358 u32 rcv_nxt;
359};
360
361struct cpl_close_listserv_req {
362 union opcode_tid ot;
363 u32 rsvd;
364};
365
366struct cpl_close_listserv_rpl {
367 union opcode_tid ot;
368 u8 rsvd[3];
369 u8 status;
370};
371
372struct cpl_abort_req {
373 union opcode_tid ot;
62 u32 rsvd0; 374 u32 rsvd0;
375 u8 rsvd1;
376 u8 cmd;
377 u8 rsvd2[6];
378};
379
380struct cpl_abort_rpl {
381 union opcode_tid ot;
382 u32 rsvd0;
383 u8 rsvd1;
384 u8 status;
385 u8 rsvd2[6];
386};
387
388struct cpl_peer_close {
389 union opcode_tid ot;
390 u32 rsvd;
391};
392
393struct cpl_tx_data {
394 union opcode_tid ot;
395 u32 len;
396 u32 rsvd0;
397 u16 urg;
398 u16 flags;
399};
400
401struct cpl_tx_data_ack {
402 union opcode_tid ot;
403 u32 ack_seq;
404};
405
406struct cpl_rx_data {
407 union opcode_tid ot;
63 u32 len; 408 u32 len;
64 u32 seq; 409 u32 seq;
65 u16 urg; 410 u16 urg;
66 u8 rsvd1; 411 u8 rsvd;
412 u8 status;
413};
414
415struct cpl_rx_data_ack {
416 union opcode_tid ot;
417 u32 credit;
418};
419
420struct cpl_rx_data_ddp {
421 union opcode_tid ot;
422 u32 len;
423 u32 seq;
424 u32 nxt_seq;
425 u32 ulp_crc;
426 u16 ddp_status;
427 u8 rsvd;
67 u8 status; 428 u8 status;
68}; 429};
69 430
@@ -99,9 +460,9 @@ struct cpl_tx_pkt_lso {
99 u8 ip_csum_dis:1; 460 u8 ip_csum_dis:1;
100 u8 l4_csum_dis:1; 461 u8 l4_csum_dis:1;
101 u8 vlan_valid:1; 462 u8 vlan_valid:1;
102 u8 rsvd:1; 463 u8 :1;
103#else 464#else
104 u8 rsvd:1; 465 u8 :1;
105 u8 vlan_valid:1; 466 u8 vlan_valid:1;
106 u8 l4_csum_dis:1; 467 u8 l4_csum_dis:1;
107 u8 ip_csum_dis:1; 468 u8 ip_csum_dis:1;
@@ -110,8 +471,7 @@ struct cpl_tx_pkt_lso {
110 u16 vlan; 471 u16 vlan;
111 __be32 len; 472 __be32 len;
112 473
113 u32 rsvd2; 474 u8 rsvd[5];
114 u8 rsvd3;
115#if defined(__LITTLE_ENDIAN_BITFIELD) 475#if defined(__LITTLE_ENDIAN_BITFIELD)
116 u8 tcp_hdr_words:4; 476 u8 tcp_hdr_words:4;
117 u8 ip_hdr_words:4; 477 u8 ip_hdr_words:4;
@@ -138,8 +498,142 @@ struct cpl_rx_pkt {
138 u8 iff:4; 498 u8 iff:4;
139#endif 499#endif
140 u16 csum; 500 u16 csum;
141 __be16 vlan; 501 u16 vlan;
142 u16 len; 502 u16 len;
143}; 503};
144 504
505struct cpl_l2t_write_req {
506 union opcode_tid ot;
507 u32 params;
508 u8 rsvd1[2];
509 u8 dst_mac[6];
510};
511
512struct cpl_l2t_write_rpl {
513 union opcode_tid ot;
514 u8 status;
515 u8 rsvd[3];
516};
517
518struct cpl_l2t_read_req {
519 union opcode_tid ot;
520 u8 rsvd[3];
521 u8 l2t_idx;
522};
523
524struct cpl_l2t_read_rpl {
525 union opcode_tid ot;
526 u32 params;
527 u8 rsvd1[2];
528 u8 dst_mac[6];
529};
530
531struct cpl_smt_write_req {
532 union opcode_tid ot;
533 u8 rsvd0;
534#if defined(__LITTLE_ENDIAN_BITFIELD)
535 u8 rsvd1:1;
536 u8 mtu_idx:3;
537 u8 iff:4;
538#else
539 u8 iff:4;
540 u8 mtu_idx:3;
541 u8 rsvd1:1;
542#endif
543 u16 rsvd2;
544 u16 rsvd3;
545 u8 src_mac1[6];
546 u16 rsvd4;
547 u8 src_mac0[6];
548};
549
550struct cpl_smt_write_rpl {
551 union opcode_tid ot;
552 u8 status;
553 u8 rsvd[3];
554};
555
556struct cpl_smt_read_req {
557 union opcode_tid ot;
558 u8 rsvd0;
559#if defined(__LITTLE_ENDIAN_BITFIELD)
560 u8 rsvd1:4;
561 u8 iff:4;
562#else
563 u8 iff:4;
564 u8 rsvd1:4;
565#endif
566 u16 rsvd2;
567};
568
569struct cpl_smt_read_rpl {
570 union opcode_tid ot;
571 u8 status;
572#if defined(__LITTLE_ENDIAN_BITFIELD)
573 u8 rsvd1:1;
574 u8 mtu_idx:3;
575 u8 rsvd0:4;
576#else
577 u8 rsvd0:4;
578 u8 mtu_idx:3;
579 u8 rsvd1:1;
580#endif
581 u16 rsvd2;
582 u16 rsvd3;
583 u8 src_mac1[6];
584 u16 rsvd4;
585 u8 src_mac0[6];
586};
587
588struct cpl_rte_delete_req {
589 union opcode_tid ot;
590 u32 params;
591};
592
593struct cpl_rte_delete_rpl {
594 union opcode_tid ot;
595 u8 status;
596 u8 rsvd[3];
597};
598
599struct cpl_rte_write_req {
600 union opcode_tid ot;
601 u32 params;
602 u32 netmask;
603 u32 faddr;
604};
605
606struct cpl_rte_write_rpl {
607 union opcode_tid ot;
608 u8 status;
609 u8 rsvd[3];
610};
611
612struct cpl_rte_read_req {
613 union opcode_tid ot;
614 u32 params;
615};
616
617struct cpl_rte_read_rpl {
618 union opcode_tid ot;
619 u8 status;
620 u8 rsvd0[2];
621 u8 l2t_idx;
622#if defined(__LITTLE_ENDIAN_BITFIELD)
623 u8 rsvd1:7;
624 u8 select:1;
625#else
626 u8 select:1;
627 u8 rsvd1:7;
628#endif
629 u8 rsvd2[3];
630 u32 addr;
631};
632
633struct cpl_mss_change {
634 union opcode_tid ot;
635 u32 mss;
636};
637
145#endif /* _CXGB_CPL5_CMD_H_ */ 638#endif /* _CXGB_CPL5_CMD_H_ */
639
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index f607cc6a276b..de48eadddbc4 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -45,7 +45,6 @@
45#include <linux/if_vlan.h> 45#include <linux/if_vlan.h>
46#include <linux/mii.h> 46#include <linux/mii.h>
47#include <linux/sockios.h> 47#include <linux/sockios.h>
48#include <linux/proc_fs.h>
49#include <linux/dma-mapping.h> 48#include <linux/dma-mapping.h>
50#include <asm/uaccess.h> 49#include <asm/uaccess.h>
51 50
@@ -54,36 +53,10 @@
54#include "gmac.h" 53#include "gmac.h"
55#include "cphy.h" 54#include "cphy.h"
56#include "sge.h" 55#include "sge.h"
56#include "tp.h"
57#include "espi.h" 57#include "espi.h"
58#include "elmer0.h"
58 59
59#ifdef work_struct
60#include <linux/tqueue.h>
61#define INIT_WORK INIT_TQUEUE
62#define schedule_work schedule_task
63#define flush_scheduled_work flush_scheduled_tasks
64
65static inline void schedule_mac_stats_update(struct adapter *ap, int secs)
66{
67 mod_timer(&ap->stats_update_timer, jiffies + secs * HZ);
68}
69
70static inline void cancel_mac_stats_update(struct adapter *ap)
71{
72 del_timer_sync(&ap->stats_update_timer);
73 flush_scheduled_tasks();
74}
75
76/*
77 * Stats update timer for 2.4. It schedules a task to do the actual update as
78 * we need to access MAC statistics in process context.
79 */
80static void mac_stats_timer(unsigned long data)
81{
82 struct adapter *ap = (struct adapter *)data;
83
84 schedule_task(&ap->stats_update_task);
85}
86#else
87#include <linux/workqueue.h> 60#include <linux/workqueue.h>
88 61
89static inline void schedule_mac_stats_update(struct adapter *ap, int secs) 62static inline void schedule_mac_stats_update(struct adapter *ap, int secs)
@@ -95,7 +68,6 @@ static inline void cancel_mac_stats_update(struct adapter *ap)
95{ 68{
96 cancel_delayed_work(&ap->stats_update_task); 69 cancel_delayed_work(&ap->stats_update_task);
97} 70}
98#endif
99 71
100#define MAX_CMDQ_ENTRIES 16384 72#define MAX_CMDQ_ENTRIES 16384
101#define MAX_CMDQ1_ENTRIES 1024 73#define MAX_CMDQ1_ENTRIES 1024
@@ -103,10 +75,9 @@ static inline void cancel_mac_stats_update(struct adapter *ap)
103#define MAX_RX_JUMBO_BUFFERS 16384 75#define MAX_RX_JUMBO_BUFFERS 16384
104#define MAX_TX_BUFFERS_HIGH 16384U 76#define MAX_TX_BUFFERS_HIGH 16384U
105#define MAX_TX_BUFFERS_LOW 1536U 77#define MAX_TX_BUFFERS_LOW 1536U
78#define MAX_TX_BUFFERS 1460U
106#define MIN_FL_ENTRIES 32 79#define MIN_FL_ENTRIES 32
107 80
108#define PORT_MASK ((1 << MAX_NPORTS) - 1)
109
110#define DFLT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | \ 81#define DFLT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | \
111 NETIF_MSG_TIMER | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP |\ 82 NETIF_MSG_TIMER | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP |\
112 NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) 83 NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
@@ -124,8 +95,21 @@ MODULE_LICENSE("GPL");
124static int dflt_msg_enable = DFLT_MSG_ENABLE; 95static int dflt_msg_enable = DFLT_MSG_ENABLE;
125 96
126module_param(dflt_msg_enable, int, 0); 97module_param(dflt_msg_enable, int, 0);
127MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T1 message enable bitmap"); 98MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T1 default message enable bitmap");
99
100#define HCLOCK 0x0
101#define LCLOCK 0x1
102
103/* T1 cards powersave mode */
104static int t1_clock(struct adapter *adapter, int mode);
105static int t1powersave = 1; /* HW default is powersave mode. */
128 106
107module_param(t1powersave, int, 0);
108MODULE_PARM_DESC(t1powersave, "Enable/Disable T1 powersaving mode");
109
110static int disable_msi = 0;
111module_param(disable_msi, int, 0);
112MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
129 113
130static const char pci_speed[][4] = { 114static const char pci_speed[][4] = {
131 "33", "66", "100", "133" 115 "33", "66", "100", "133"
@@ -149,7 +133,7 @@ static void t1_set_rxmode(struct net_device *dev)
149static void link_report(struct port_info *p) 133static void link_report(struct port_info *p)
150{ 134{
151 if (!netif_carrier_ok(p->dev)) 135 if (!netif_carrier_ok(p->dev))
152 printk(KERN_INFO "%s: link down\n", p->dev->name); 136 printk(KERN_INFO "%s: link down\n", p->dev->name);
153 else { 137 else {
154 const char *s = "10Mbps"; 138 const char *s = "10Mbps";
155 139
@@ -159,13 +143,13 @@ static void link_report(struct port_info *p)
159 case SPEED_100: s = "100Mbps"; break; 143 case SPEED_100: s = "100Mbps"; break;
160 } 144 }
161 145
162 printk(KERN_INFO "%s: link up, %s, %s-duplex\n", 146 printk(KERN_INFO "%s: link up, %s, %s-duplex\n",
163 p->dev->name, s, 147 p->dev->name, s,
164 p->link_config.duplex == DUPLEX_FULL ? "full" : "half"); 148 p->link_config.duplex == DUPLEX_FULL ? "full" : "half");
165 } 149 }
166} 150}
167 151
168void t1_link_changed(struct adapter *adapter, int port_id, int link_stat, 152void t1_link_negotiated(struct adapter *adapter, int port_id, int link_stat,
169 int speed, int duplex, int pause) 153 int speed, int duplex, int pause)
170{ 154{
171 struct port_info *p = &adapter->port[port_id]; 155 struct port_info *p = &adapter->port[port_id];
@@ -177,6 +161,22 @@ void t1_link_changed(struct adapter *adapter, int port_id, int link_stat,
177 netif_carrier_off(p->dev); 161 netif_carrier_off(p->dev);
178 link_report(p); 162 link_report(p);
179 163
164 /* multi-ports: inform toe */
165 if ((speed > 0) && (adapter->params.nports > 1)) {
166 unsigned int sched_speed = 10;
167 switch (speed) {
168 case SPEED_1000:
169 sched_speed = 1000;
170 break;
171 case SPEED_100:
172 sched_speed = 100;
173 break;
174 case SPEED_10:
175 sched_speed = 10;
176 break;
177 }
178 t1_sched_update_parms(adapter->sge, port_id, 0, sched_speed);
179 }
180 } 180 }
181} 181}
182 182
@@ -195,8 +195,10 @@ static void link_start(struct port_info *p)
195static void enable_hw_csum(struct adapter *adapter) 195static void enable_hw_csum(struct adapter *adapter)
196{ 196{
197 if (adapter->flags & TSO_CAPABLE) 197 if (adapter->flags & TSO_CAPABLE)
198 t1_tp_set_ip_checksum_offload(adapter, 1); /* for TSO only */ 198 t1_tp_set_ip_checksum_offload(adapter->tp, 1); /* for TSO only */
199 t1_tp_set_tcp_checksum_offload(adapter, 1); 199 if (adapter->flags & UDP_CSUM_CAPABLE)
200 t1_tp_set_udp_checksum_offload(adapter->tp, 1);
201 t1_tp_set_tcp_checksum_offload(adapter->tp, 1);
200} 202}
201 203
202/* 204/*
@@ -217,11 +219,19 @@ static int cxgb_up(struct adapter *adapter)
217 } 219 }
218 220
219 t1_interrupts_clear(adapter); 221 t1_interrupts_clear(adapter);
220 if ((err = request_irq(adapter->pdev->irq, 222
221 t1_select_intr_handler(adapter), IRQF_SHARED, 223 adapter->params.has_msi = !disable_msi && pci_enable_msi(adapter->pdev) == 0;
222 adapter->name, adapter))) { 224 err = request_irq(adapter->pdev->irq,
225 t1_select_intr_handler(adapter),
226 adapter->params.has_msi ? 0 : IRQF_SHARED,
227 adapter->name, adapter);
228 if (err) {
229 if (adapter->params.has_msi)
230 pci_disable_msi(adapter->pdev);
231
223 goto out_err; 232 goto out_err;
224 } 233 }
234
225 t1_sge_start(adapter->sge); 235 t1_sge_start(adapter->sge);
226 t1_interrupts_enable(adapter); 236 t1_interrupts_enable(adapter);
227 out_err: 237 out_err:
@@ -236,6 +246,8 @@ static void cxgb_down(struct adapter *adapter)
236 t1_sge_stop(adapter->sge); 246 t1_sge_stop(adapter->sge);
237 t1_interrupts_disable(adapter); 247 t1_interrupts_disable(adapter);
238 free_irq(adapter->pdev->irq, adapter); 248 free_irq(adapter->pdev->irq, adapter);
249 if (adapter->params.has_msi)
250 pci_disable_msi(adapter->pdev);
239} 251}
240 252
241static int cxgb_open(struct net_device *dev) 253static int cxgb_open(struct net_device *dev)
@@ -290,7 +302,7 @@ static struct net_device_stats *t1_get_stats(struct net_device *dev)
290 302
291 /* Do a full update of the MAC stats */ 303 /* Do a full update of the MAC stats */
292 pstats = p->mac->ops->statistics_update(p->mac, 304 pstats = p->mac->ops->statistics_update(p->mac,
293 MAC_STATS_UPDATE_FULL); 305 MAC_STATS_UPDATE_FULL);
294 306
295 ns->tx_packets = pstats->TxUnicastFramesOK + 307 ns->tx_packets = pstats->TxUnicastFramesOK +
296 pstats->TxMulticastFramesOK + pstats->TxBroadcastFramesOK; 308 pstats->TxMulticastFramesOK + pstats->TxBroadcastFramesOK;
@@ -344,47 +356,53 @@ static void set_msglevel(struct net_device *dev, u32 val)
344} 356}
345 357
346static char stats_strings[][ETH_GSTRING_LEN] = { 358static char stats_strings[][ETH_GSTRING_LEN] = {
347 "TxOctetsOK", 359 "TxOctetsOK",
348 "TxOctetsBad", 360 "TxOctetsBad",
349 "TxUnicastFramesOK", 361 "TxUnicastFramesOK",
350 "TxMulticastFramesOK", 362 "TxMulticastFramesOK",
351 "TxBroadcastFramesOK", 363 "TxBroadcastFramesOK",
352 "TxPauseFrames", 364 "TxPauseFrames",
353 "TxFramesWithDeferredXmissions", 365 "TxFramesWithDeferredXmissions",
354 "TxLateCollisions", 366 "TxLateCollisions",
355 "TxTotalCollisions", 367 "TxTotalCollisions",
356 "TxFramesAbortedDueToXSCollisions", 368 "TxFramesAbortedDueToXSCollisions",
357 "TxUnderrun", 369 "TxUnderrun",
358 "TxLengthErrors", 370 "TxLengthErrors",
359 "TxInternalMACXmitError", 371 "TxInternalMACXmitError",
360 "TxFramesWithExcessiveDeferral", 372 "TxFramesWithExcessiveDeferral",
361 "TxFCSErrors", 373 "TxFCSErrors",
362 374
363 "RxOctetsOK", 375 "RxOctetsOK",
364 "RxOctetsBad", 376 "RxOctetsBad",
365 "RxUnicastFramesOK", 377 "RxUnicastFramesOK",
366 "RxMulticastFramesOK", 378 "RxMulticastFramesOK",
367 "RxBroadcastFramesOK", 379 "RxBroadcastFramesOK",
368 "RxPauseFrames", 380 "RxPauseFrames",
369 "RxFCSErrors", 381 "RxFCSErrors",
370 "RxAlignErrors", 382 "RxAlignErrors",
371 "RxSymbolErrors", 383 "RxSymbolErrors",
372 "RxDataErrors", 384 "RxDataErrors",
373 "RxSequenceErrors", 385 "RxSequenceErrors",
374 "RxRuntErrors", 386 "RxRuntErrors",
375 "RxJabberErrors", 387 "RxJabberErrors",
376 "RxInternalMACRcvError", 388 "RxInternalMACRcvError",
377 "RxInRangeLengthErrors", 389 "RxInRangeLengthErrors",
378 "RxOutOfRangeLengthField", 390 "RxOutOfRangeLengthField",
379 "RxFrameTooLongErrors", 391 "RxFrameTooLongErrors",
380 392
381 "TSO", 393 /* Port stats */
382 "VLANextractions", 394 "RxPackets",
383 "VLANinsertions",
384 "RxCsumGood", 395 "RxCsumGood",
396 "TxPackets",
385 "TxCsumOffload", 397 "TxCsumOffload",
386 "RxDrops" 398 "TxTso",
387 399 "RxVlan",
400 "TxVlan",
401
402 /* Interrupt stats */
403 "rx drops",
404 "pure_rsps",
405 "unhandled irqs",
388 "respQ_empty", 406 "respQ_empty",
389 "respQ_overflow", 407 "respQ_overflow",
390 "freelistQ_empty", 408 "freelistQ_empty",
@@ -392,11 +410,7 @@ static char stats_strings[][ETH_GSTRING_LEN] = {
392 "pkt_mismatch", 410 "pkt_mismatch",
393 "cmdQ_full0", 411 "cmdQ_full0",
394 "cmdQ_full1", 412 "cmdQ_full1",
395 "tx_ipfrags", 413
396 "tx_reg_pkts",
397 "tx_lso_pkts",
398 "tx_do_cksum",
399
400 "espi_DIP2ParityErr", 414 "espi_DIP2ParityErr",
401 "espi_DIP4Err", 415 "espi_DIP4Err",
402 "espi_RxDrops", 416 "espi_RxDrops",
@@ -404,7 +418,7 @@ static char stats_strings[][ETH_GSTRING_LEN] = {
404 "espi_RxOvfl", 418 "espi_RxOvfl",
405 "espi_ParityErr" 419 "espi_ParityErr"
406}; 420};
407 421
408#define T2_REGMAP_SIZE (3 * 1024) 422#define T2_REGMAP_SIZE (3 * 1024)
409 423
410static int get_regs_len(struct net_device *dev) 424static int get_regs_len(struct net_device *dev)
@@ -439,65 +453,77 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
439 struct adapter *adapter = dev->priv; 453 struct adapter *adapter = dev->priv;
440 struct cmac *mac = adapter->port[dev->if_port].mac; 454 struct cmac *mac = adapter->port[dev->if_port].mac;
441 const struct cmac_statistics *s; 455 const struct cmac_statistics *s;
442 const struct sge_port_stats *ss;
443 const struct sge_intr_counts *t; 456 const struct sge_intr_counts *t;
457 struct sge_port_stats ss;
444 458
445 s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL); 459 s = mac->ops->statistics_update(mac, MAC_STATS_UPDATE_FULL);
446 ss = t1_sge_get_port_stats(adapter->sge, dev->if_port);
447 t = t1_sge_get_intr_counts(adapter->sge);
448 460
449 *data++ = s->TxOctetsOK; 461 *data++ = s->TxOctetsOK;
450 *data++ = s->TxOctetsBad; 462 *data++ = s->TxOctetsBad;
451 *data++ = s->TxUnicastFramesOK; 463 *data++ = s->TxUnicastFramesOK;
452 *data++ = s->TxMulticastFramesOK; 464 *data++ = s->TxMulticastFramesOK;
453 *data++ = s->TxBroadcastFramesOK; 465 *data++ = s->TxBroadcastFramesOK;
454 *data++ = s->TxPauseFrames; 466 *data++ = s->TxPauseFrames;
455 *data++ = s->TxFramesWithDeferredXmissions; 467 *data++ = s->TxFramesWithDeferredXmissions;
456 *data++ = s->TxLateCollisions; 468 *data++ = s->TxLateCollisions;
457 *data++ = s->TxTotalCollisions; 469 *data++ = s->TxTotalCollisions;
458 *data++ = s->TxFramesAbortedDueToXSCollisions; 470 *data++ = s->TxFramesAbortedDueToXSCollisions;
459 *data++ = s->TxUnderrun; 471 *data++ = s->TxUnderrun;
460 *data++ = s->TxLengthErrors; 472 *data++ = s->TxLengthErrors;
461 *data++ = s->TxInternalMACXmitError; 473 *data++ = s->TxInternalMACXmitError;
462 *data++ = s->TxFramesWithExcessiveDeferral; 474 *data++ = s->TxFramesWithExcessiveDeferral;
463 *data++ = s->TxFCSErrors; 475 *data++ = s->TxFCSErrors;
464 476
465 *data++ = s->RxOctetsOK; 477 *data++ = s->RxOctetsOK;
466 *data++ = s->RxOctetsBad; 478 *data++ = s->RxOctetsBad;
467 *data++ = s->RxUnicastFramesOK; 479 *data++ = s->RxUnicastFramesOK;
468 *data++ = s->RxMulticastFramesOK; 480 *data++ = s->RxMulticastFramesOK;
469 *data++ = s->RxBroadcastFramesOK; 481 *data++ = s->RxBroadcastFramesOK;
470 *data++ = s->RxPauseFrames; 482 *data++ = s->RxPauseFrames;
471 *data++ = s->RxFCSErrors; 483 *data++ = s->RxFCSErrors;
472 *data++ = s->RxAlignErrors; 484 *data++ = s->RxAlignErrors;
473 *data++ = s->RxSymbolErrors; 485 *data++ = s->RxSymbolErrors;
474 *data++ = s->RxDataErrors; 486 *data++ = s->RxDataErrors;
475 *data++ = s->RxSequenceErrors; 487 *data++ = s->RxSequenceErrors;
476 *data++ = s->RxRuntErrors; 488 *data++ = s->RxRuntErrors;
477 *data++ = s->RxJabberErrors; 489 *data++ = s->RxJabberErrors;
478 *data++ = s->RxInternalMACRcvError; 490 *data++ = s->RxInternalMACRcvError;
479 *data++ = s->RxInRangeLengthErrors; 491 *data++ = s->RxInRangeLengthErrors;
480 *data++ = s->RxOutOfRangeLengthField; 492 *data++ = s->RxOutOfRangeLengthField;
481 *data++ = s->RxFrameTooLongErrors; 493 *data++ = s->RxFrameTooLongErrors;
482 494
483 *data++ = ss->tso; 495 t1_sge_get_port_stats(adapter->sge, dev->if_port, &ss);
484 *data++ = ss->vlan_xtract; 496 *data++ = ss.rx_packets;
485 *data++ = ss->vlan_insert; 497 *data++ = ss.rx_cso_good;
486 *data++ = ss->rx_cso_good; 498 *data++ = ss.tx_packets;
487 *data++ = ss->tx_cso; 499 *data++ = ss.tx_cso;
488 *data++ = ss->rx_drops; 500 *data++ = ss.tx_tso;
489 501 *data++ = ss.vlan_xtract;
490 *data++ = (u64)t->respQ_empty; 502 *data++ = ss.vlan_insert;
491 *data++ = (u64)t->respQ_overflow; 503
492 *data++ = (u64)t->freelistQ_empty; 504 t = t1_sge_get_intr_counts(adapter->sge);
493 *data++ = (u64)t->pkt_too_big; 505 *data++ = t->rx_drops;
494 *data++ = (u64)t->pkt_mismatch; 506 *data++ = t->pure_rsps;
495 *data++ = (u64)t->cmdQ_full[0]; 507 *data++ = t->unhandled_irqs;
496 *data++ = (u64)t->cmdQ_full[1]; 508 *data++ = t->respQ_empty;
497 *data++ = (u64)t->tx_ipfrags; 509 *data++ = t->respQ_overflow;
498 *data++ = (u64)t->tx_reg_pkts; 510 *data++ = t->freelistQ_empty;
499 *data++ = (u64)t->tx_lso_pkts; 511 *data++ = t->pkt_too_big;
500 *data++ = (u64)t->tx_do_cksum; 512 *data++ = t->pkt_mismatch;
513 *data++ = t->cmdQ_full[0];
514 *data++ = t->cmdQ_full[1];
515
516 if (adapter->espi) {
517 const struct espi_intr_counts *e;
518
519 e = t1_espi_get_intr_counts(adapter->espi);
520 *data++ = e->DIP2_parity_err;
521 *data++ = e->DIP4_err;
522 *data++ = e->rx_drops;
523 *data++ = e->tx_drops;
524 *data++ = e->rx_ovflw;
525 *data++ = e->parity_err;
526 }
501} 527}
502 528
503static inline void reg_block_dump(struct adapter *ap, void *buf, 529static inline void reg_block_dump(struct adapter *ap, void *buf,
@@ -521,6 +547,15 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
521 547
522 memset(buf, 0, T2_REGMAP_SIZE); 548 memset(buf, 0, T2_REGMAP_SIZE);
523 reg_block_dump(ap, buf, 0, A_SG_RESPACCUTIMER); 549 reg_block_dump(ap, buf, 0, A_SG_RESPACCUTIMER);
550 reg_block_dump(ap, buf, A_MC3_CFG, A_MC4_INT_CAUSE);
551 reg_block_dump(ap, buf, A_TPI_ADDR, A_TPI_PAR);
552 reg_block_dump(ap, buf, A_TP_IN_CONFIG, A_TP_TX_DROP_COUNT);
553 reg_block_dump(ap, buf, A_RAT_ROUTE_CONTROL, A_RAT_INTR_CAUSE);
554 reg_block_dump(ap, buf, A_CSPI_RX_AE_WM, A_CSPI_INTR_ENABLE);
555 reg_block_dump(ap, buf, A_ESPI_SCH_TOKEN0, A_ESPI_GOSTAT);
556 reg_block_dump(ap, buf, A_ULP_ULIMIT, A_ULP_PIO_CTRL);
557 reg_block_dump(ap, buf, A_PL_ENABLE, A_PL_CAUSE);
558 reg_block_dump(ap, buf, A_MC5_CONFIG, A_MC5_MASK_WRITE_CMD);
524} 559}
525 560
526static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 561static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -539,12 +574,12 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
539 cmd->duplex = -1; 574 cmd->duplex = -1;
540 } 575 }
541 576
542 cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE; 577 cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
543 cmd->phy_address = p->phy->addr; 578 cmd->phy_address = p->phy->addr;
544 cmd->transceiver = XCVR_EXTERNAL; 579 cmd->transceiver = XCVR_EXTERNAL;
545 cmd->autoneg = p->link_config.autoneg; 580 cmd->autoneg = p->link_config.autoneg;
546 cmd->maxtxpkt = 0; 581 cmd->maxtxpkt = 0;
547 cmd->maxrxpkt = 0; 582 cmd->maxrxpkt = 0;
548 return 0; 583 return 0;
549} 584}
550 585
@@ -715,7 +750,7 @@ static int set_sge_param(struct net_device *dev, struct ethtool_ringparam *e)
715 return -EINVAL; 750 return -EINVAL;
716 751
717 if (adapter->flags & FULL_INIT_DONE) 752 if (adapter->flags & FULL_INIT_DONE)
718 return -EBUSY; 753 return -EBUSY;
719 754
720 adapter->params.sge.freelQ_size[!jumbo_fl] = e->rx_pending; 755 adapter->params.sge.freelQ_size[!jumbo_fl] = e->rx_pending;
721 adapter->params.sge.freelQ_size[jumbo_fl] = e->rx_jumbo_pending; 756 adapter->params.sge.freelQ_size[jumbo_fl] = e->rx_jumbo_pending;
@@ -759,7 +794,9 @@ static int get_coalesce(struct net_device *dev, struct ethtool_coalesce *c)
759 794
760static int get_eeprom_len(struct net_device *dev) 795static int get_eeprom_len(struct net_device *dev)
761{ 796{
762 return EEPROM_SIZE; 797 struct adapter *adapter = dev->priv;
798
799 return t1_is_asic(adapter) ? EEPROM_SIZE : 0;
763} 800}
764 801
765#define EEPROM_MAGIC(ap) \ 802#define EEPROM_MAGIC(ap) \
@@ -809,47 +846,36 @@ static const struct ethtool_ops t1_ethtool_ops = {
809 .set_tso = set_tso, 846 .set_tso = set_tso,
810}; 847};
811 848
812static void cxgb_proc_cleanup(struct adapter *adapter,
813 struct proc_dir_entry *dir)
814{
815 const char *name;
816 name = adapter->name;
817 remove_proc_entry(name, dir);
818}
819//#define chtoe_setup_toedev(adapter) NULL
820#define update_mtu_tab(adapter)
821#define write_smt_entry(adapter, idx)
822
823static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 849static int t1_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
824{ 850{
825 struct adapter *adapter = dev->priv; 851 struct adapter *adapter = dev->priv;
826 struct mii_ioctl_data *data = if_mii(req); 852 struct mii_ioctl_data *data = if_mii(req);
827 853
828 switch (cmd) { 854 switch (cmd) {
829 case SIOCGMIIPHY: 855 case SIOCGMIIPHY:
830 data->phy_id = adapter->port[dev->if_port].phy->addr; 856 data->phy_id = adapter->port[dev->if_port].phy->addr;
831 /* FALLTHRU */ 857 /* FALLTHRU */
832 case SIOCGMIIREG: { 858 case SIOCGMIIREG: {
833 struct cphy *phy = adapter->port[dev->if_port].phy; 859 struct cphy *phy = adapter->port[dev->if_port].phy;
834 u32 val; 860 u32 val;
835 861
836 if (!phy->mdio_read) 862 if (!phy->mdio_read)
837 return -EOPNOTSUPP; 863 return -EOPNOTSUPP;
838 phy->mdio_read(adapter, data->phy_id, 0, data->reg_num & 0x1f, 864 phy->mdio_read(adapter, data->phy_id, 0, data->reg_num & 0x1f,
839 &val); 865 &val);
840 data->val_out = val; 866 data->val_out = val;
841 break; 867 break;
842 } 868 }
843 case SIOCSMIIREG: { 869 case SIOCSMIIREG: {
844 struct cphy *phy = adapter->port[dev->if_port].phy; 870 struct cphy *phy = adapter->port[dev->if_port].phy;
845 871
846 if (!capable(CAP_NET_ADMIN)) 872 if (!capable(CAP_NET_ADMIN))
847 return -EPERM; 873 return -EPERM;
848 if (!phy->mdio_write) 874 if (!phy->mdio_write)
849 return -EOPNOTSUPP; 875 return -EOPNOTSUPP;
850 phy->mdio_write(adapter, data->phy_id, 0, data->reg_num & 0x1f, 876 phy->mdio_write(adapter, data->phy_id, 0, data->reg_num & 0x1f,
851 data->val_in); 877 data->val_in);
852 break; 878 break;
853 } 879 }
854 880
855 default: 881 default:
@@ -865,9 +891,9 @@ static int t1_change_mtu(struct net_device *dev, int new_mtu)
865 struct cmac *mac = adapter->port[dev->if_port].mac; 891 struct cmac *mac = adapter->port[dev->if_port].mac;
866 892
867 if (!mac->ops->set_mtu) 893 if (!mac->ops->set_mtu)
868 return -EOPNOTSUPP; 894 return -EOPNOTSUPP;
869 if (new_mtu < 68) 895 if (new_mtu < 68)
870 return -EINVAL; 896 return -EINVAL;
871 if ((ret = mac->ops->set_mtu(mac, new_mtu))) 897 if ((ret = mac->ops->set_mtu(mac, new_mtu)))
872 return ret; 898 return ret;
873 dev->mtu = new_mtu; 899 dev->mtu = new_mtu;
@@ -918,7 +944,7 @@ static void t1_netpoll(struct net_device *dev)
918 struct adapter *adapter = dev->priv; 944 struct adapter *adapter = dev->priv;
919 945
920 local_irq_save(flags); 946 local_irq_save(flags);
921 t1_select_intr_handler(adapter)(adapter->pdev->irq, adapter); 947 t1_select_intr_handler(adapter)(adapter->pdev->irq, adapter);
922 local_irq_restore(flags); 948 local_irq_restore(flags);
923} 949}
924#endif 950#endif
@@ -957,14 +983,14 @@ static void ext_intr_task(struct work_struct *work)
957 struct adapter *adapter = 983 struct adapter *adapter =
958 container_of(work, struct adapter, ext_intr_handler_task); 984 container_of(work, struct adapter, ext_intr_handler_task);
959 985
960 elmer0_ext_intr_handler(adapter); 986 t1_elmer0_ext_intr_handler(adapter);
961 987
962 /* Now reenable external interrupts */ 988 /* Now reenable external interrupts */
963 spin_lock_irq(&adapter->async_lock); 989 spin_lock_irq(&adapter->async_lock);
964 adapter->slow_intr_mask |= F_PL_INTR_EXT; 990 adapter->slow_intr_mask |= F_PL_INTR_EXT;
965 writel(F_PL_INTR_EXT, adapter->regs + A_PL_CAUSE); 991 writel(F_PL_INTR_EXT, adapter->regs + A_PL_CAUSE);
966 writel(adapter->slow_intr_mask | F_PL_INTR_SGE_DATA, 992 writel(adapter->slow_intr_mask | F_PL_INTR_SGE_DATA,
967 adapter->regs + A_PL_ENABLE); 993 adapter->regs + A_PL_ENABLE);
968 spin_unlock_irq(&adapter->async_lock); 994 spin_unlock_irq(&adapter->async_lock);
969} 995}
970 996
@@ -980,7 +1006,7 @@ void t1_elmer0_ext_intr(struct adapter *adapter)
980 */ 1006 */
981 adapter->slow_intr_mask &= ~F_PL_INTR_EXT; 1007 adapter->slow_intr_mask &= ~F_PL_INTR_EXT;
982 writel(adapter->slow_intr_mask | F_PL_INTR_SGE_DATA, 1008 writel(adapter->slow_intr_mask | F_PL_INTR_SGE_DATA,
983 adapter->regs + A_PL_ENABLE); 1009 adapter->regs + A_PL_ENABLE);
984 schedule_work(&adapter->ext_intr_handler_task); 1010 schedule_work(&adapter->ext_intr_handler_task);
985} 1011}
986 1012
@@ -1013,7 +1039,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1013 1039
1014 err = pci_enable_device(pdev); 1040 err = pci_enable_device(pdev);
1015 if (err) 1041 if (err)
1016 return err; 1042 return err;
1017 1043
1018 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 1044 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
1019 CH_ERR("%s: cannot find PCI device memory base address\n", 1045 CH_ERR("%s: cannot find PCI device memory base address\n",
@@ -1045,7 +1071,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1045 1071
1046 pci_set_master(pdev); 1072 pci_set_master(pdev);
1047 1073
1048 mmio_start = pci_resource_start(pdev, 0); 1074 mmio_start = pci_resource_start(pdev, 0);
1049 mmio_len = pci_resource_len(pdev, 0); 1075 mmio_len = pci_resource_len(pdev, 0);
1050 bi = t1_get_board_info(ent->driver_data); 1076 bi = t1_get_board_info(ent->driver_data);
1051 1077
@@ -1083,21 +1109,15 @@ static int __devinit init_one(struct pci_dev *pdev,
1083 adapter->msg_enable = dflt_msg_enable; 1109 adapter->msg_enable = dflt_msg_enable;
1084 adapter->mmio_len = mmio_len; 1110 adapter->mmio_len = mmio_len;
1085 1111
1086 init_MUTEX(&adapter->mib_mutex);
1087 spin_lock_init(&adapter->tpi_lock); 1112 spin_lock_init(&adapter->tpi_lock);
1088 spin_lock_init(&adapter->work_lock); 1113 spin_lock_init(&adapter->work_lock);
1089 spin_lock_init(&adapter->async_lock); 1114 spin_lock_init(&adapter->async_lock);
1115 spin_lock_init(&adapter->mac_lock);
1090 1116
1091 INIT_WORK(&adapter->ext_intr_handler_task, 1117 INIT_WORK(&adapter->ext_intr_handler_task,
1092 ext_intr_task); 1118 ext_intr_task);
1093 INIT_DELAYED_WORK(&adapter->stats_update_task, 1119 INIT_DELAYED_WORK(&adapter->stats_update_task,
1094 mac_stats_task); 1120 mac_stats_task);
1095#ifdef work_struct
1096 init_timer(&adapter->stats_update_timer);
1097 adapter->stats_update_timer.function = mac_stats_timer;
1098 adapter->stats_update_timer.data =
1099 (unsigned long)adapter;
1100#endif
1101 1121
1102 pci_set_drvdata(pdev, netdev); 1122 pci_set_drvdata(pdev, netdev);
1103 } 1123 }
@@ -1124,16 +1144,19 @@ static int __devinit init_one(struct pci_dev *pdev,
1124 netdev->vlan_rx_register = vlan_rx_register; 1144 netdev->vlan_rx_register = vlan_rx_register;
1125 netdev->vlan_rx_kill_vid = vlan_rx_kill_vid; 1145 netdev->vlan_rx_kill_vid = vlan_rx_kill_vid;
1126#endif 1146#endif
1127 adapter->flags |= TSO_CAPABLE; 1147
1128 netdev->features |= NETIF_F_TSO; 1148 /* T204: disable TSO */
1149 if (!(is_T2(adapter)) || bi->port_number != 4) {
1150 adapter->flags |= TSO_CAPABLE;
1151 netdev->features |= NETIF_F_TSO;
1152 }
1129 } 1153 }
1130 1154
1131 netdev->open = cxgb_open; 1155 netdev->open = cxgb_open;
1132 netdev->stop = cxgb_close; 1156 netdev->stop = cxgb_close;
1133 netdev->hard_start_xmit = t1_start_xmit; 1157 netdev->hard_start_xmit = t1_start_xmit;
1134 netdev->hard_header_len += (adapter->flags & TSO_CAPABLE) ? 1158 netdev->hard_header_len += (adapter->flags & TSO_CAPABLE) ?
1135 sizeof(struct cpl_tx_pkt_lso) : 1159 sizeof(struct cpl_tx_pkt_lso) : sizeof(struct cpl_tx_pkt);
1136 sizeof(struct cpl_tx_pkt);
1137 netdev->get_stats = t1_get_stats; 1160 netdev->get_stats = t1_get_stats;
1138 netdev->set_multicast_list = t1_set_rxmode; 1161 netdev->set_multicast_list = t1_set_rxmode;
1139 netdev->do_ioctl = t1_ioctl; 1162 netdev->do_ioctl = t1_ioctl;
@@ -1144,7 +1167,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1144#endif 1167#endif
1145 netdev->weight = 64; 1168 netdev->weight = 64;
1146 1169
1147 SET_ETHTOOL_OPS(netdev, &t1_ethtool_ops); 1170 SET_ETHTOOL_OPS(netdev, &t1_ethtool_ops);
1148 } 1171 }
1149 1172
1150 if (t1_init_sw_modules(adapter, bi) < 0) { 1173 if (t1_init_sw_modules(adapter, bi) < 0) {
@@ -1171,7 +1194,7 @@ static int __devinit init_one(struct pci_dev *pdev,
1171 if (!adapter->registered_device_map) 1194 if (!adapter->registered_device_map)
1172 adapter->name = adapter->port[i].dev->name; 1195 adapter->name = adapter->port[i].dev->name;
1173 1196
1174 __set_bit(i, &adapter->registered_device_map); 1197 __set_bit(i, &adapter->registered_device_map);
1175 } 1198 }
1176 } 1199 }
1177 if (!adapter->registered_device_map) { 1200 if (!adapter->registered_device_map) {
@@ -1184,18 +1207,28 @@ static int __devinit init_one(struct pci_dev *pdev,
1184 bi->desc, adapter->params.chip_revision, 1207 bi->desc, adapter->params.chip_revision,
1185 adapter->params.pci.is_pcix ? "PCIX" : "PCI", 1208 adapter->params.pci.is_pcix ? "PCIX" : "PCI",
1186 adapter->params.pci.speed, adapter->params.pci.width); 1209 adapter->params.pci.speed, adapter->params.pci.width);
1210
1211 /*
1212 * Set the T1B ASIC and memory clocks.
1213 */
1214 if (t1powersave)
1215 adapter->t1powersave = LCLOCK; /* HW default is powersave mode. */
1216 else
1217 adapter->t1powersave = HCLOCK;
1218 if (t1_is_T1B(adapter))
1219 t1_clock(adapter, t1powersave);
1220
1187 return 0; 1221 return 0;
1188 1222
1189 out_release_adapter_res: 1223 out_release_adapter_res:
1190 t1_free_sw_modules(adapter); 1224 t1_free_sw_modules(adapter);
1191 out_free_dev: 1225 out_free_dev:
1192 if (adapter) { 1226 if (adapter) {
1193 if (adapter->regs) iounmap(adapter->regs); 1227 if (adapter->regs)
1228 iounmap(adapter->regs);
1194 for (i = bi->port_number - 1; i >= 0; --i) 1229 for (i = bi->port_number - 1; i >= 0; --i)
1195 if (adapter->port[i].dev) { 1230 if (adapter->port[i].dev)
1196 cxgb_proc_cleanup(adapter, proc_root_driver); 1231 free_netdev(adapter->port[i].dev);
1197 kfree(adapter->port[i].dev);
1198 }
1199 } 1232 }
1200 pci_release_regions(pdev); 1233 pci_release_regions(pdev);
1201 out_disable_pdev: 1234 out_disable_pdev:
@@ -1204,6 +1237,155 @@ static int __devinit init_one(struct pci_dev *pdev,
1204 return err; 1237 return err;
1205} 1238}
1206 1239
1240static void bit_bang(struct adapter *adapter, int bitdata, int nbits)
1241{
1242 int data;
1243 int i;
1244 u32 val;
1245
1246 enum {
1247 S_CLOCK = 1 << 3,
1248 S_DATA = 1 << 4
1249 };
1250
1251 for (i = (nbits - 1); i > -1; i--) {
1252
1253 udelay(50);
1254
1255 data = ((bitdata >> i) & 0x1);
1256 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1257
1258 if (data)
1259 val |= S_DATA;
1260 else
1261 val &= ~S_DATA;
1262
1263 udelay(50);
1264
1265 /* Set SCLOCK low */
1266 val &= ~S_CLOCK;
1267 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1268
1269 udelay(50);
1270
1271 /* Write SCLOCK high */
1272 val |= S_CLOCK;
1273 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1274
1275 }
1276}
1277
1278static int t1_clock(struct adapter *adapter, int mode)
1279{
1280 u32 val;
1281 int M_CORE_VAL;
1282 int M_MEM_VAL;
1283
1284 enum {
1285 M_CORE_BITS = 9,
1286 T_CORE_VAL = 0,
1287 T_CORE_BITS = 2,
1288 N_CORE_VAL = 0,
1289 N_CORE_BITS = 2,
1290 M_MEM_BITS = 9,
1291 T_MEM_VAL = 0,
1292 T_MEM_BITS = 2,
1293 N_MEM_VAL = 0,
1294 N_MEM_BITS = 2,
1295 NP_LOAD = 1 << 17,
1296 S_LOAD_MEM = 1 << 5,
1297 S_LOAD_CORE = 1 << 6,
1298 S_CLOCK = 1 << 3
1299 };
1300
1301 if (!t1_is_T1B(adapter))
1302 return -ENODEV; /* Can't re-clock this chip. */
1303
1304 if (mode & 2) {
1305 return 0; /* show current mode. */
1306 }
1307
1308 if ((adapter->t1powersave & 1) == (mode & 1))
1309 return -EALREADY; /* ASIC already running in mode. */
1310
1311 if ((mode & 1) == HCLOCK) {
1312 M_CORE_VAL = 0x14;
1313 M_MEM_VAL = 0x18;
1314 adapter->t1powersave = HCLOCK; /* overclock */
1315 } else {
1316 M_CORE_VAL = 0xe;
1317 M_MEM_VAL = 0x10;
1318 adapter->t1powersave = LCLOCK; /* underclock */
1319 }
1320
1321 /* Don't interrupt this serial stream! */
1322 spin_lock(&adapter->tpi_lock);
1323
1324 /* Initialize for ASIC core */
1325 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1326 val |= NP_LOAD;
1327 udelay(50);
1328 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1329 udelay(50);
1330 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1331 val &= ~S_LOAD_CORE;
1332 val &= ~S_CLOCK;
1333 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1334 udelay(50);
1335
1336 /* Serial program the ASIC clock synthesizer */
1337 bit_bang(adapter, T_CORE_VAL, T_CORE_BITS);
1338 bit_bang(adapter, N_CORE_VAL, N_CORE_BITS);
1339 bit_bang(adapter, M_CORE_VAL, M_CORE_BITS);
1340 udelay(50);
1341
1342 /* Finish ASIC core */
1343 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1344 val |= S_LOAD_CORE;
1345 udelay(50);
1346 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1347 udelay(50);
1348 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1349 val &= ~S_LOAD_CORE;
1350 udelay(50);
1351 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1352 udelay(50);
1353
1354 /* Initialize for memory */
1355 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1356 val |= NP_LOAD;
1357 udelay(50);
1358 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1359 udelay(50);
1360 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1361 val &= ~S_LOAD_MEM;
1362 val &= ~S_CLOCK;
1363 udelay(50);
1364 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1365 udelay(50);
1366
1367 /* Serial program the memory clock synthesizer */
1368 bit_bang(adapter, T_MEM_VAL, T_MEM_BITS);
1369 bit_bang(adapter, N_MEM_VAL, N_MEM_BITS);
1370 bit_bang(adapter, M_MEM_VAL, M_MEM_BITS);
1371 udelay(50);
1372
1373 /* Finish memory */
1374 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1375 val |= S_LOAD_MEM;
1376 udelay(50);
1377 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1378 udelay(50);
1379 __t1_tpi_read(adapter, A_ELMER0_GPO, &val);
1380 val &= ~S_LOAD_MEM;
1381 udelay(50);
1382 __t1_tpi_write(adapter, A_ELMER0_GPO, val);
1383
1384 spin_unlock(&adapter->tpi_lock);
1385
1386 return 0;
1387}
1388
1207static inline void t1_sw_reset(struct pci_dev *pdev) 1389static inline void t1_sw_reset(struct pci_dev *pdev)
1208{ 1390{
1209 pci_write_config_dword(pdev, A_PCICFG_PM_CSR, 3); 1391 pci_write_config_dword(pdev, A_PCICFG_PM_CSR, 3);
@@ -1225,10 +1407,9 @@ static void __devexit remove_one(struct pci_dev *pdev)
1225 t1_free_sw_modules(adapter); 1407 t1_free_sw_modules(adapter);
1226 iounmap(adapter->regs); 1408 iounmap(adapter->regs);
1227 while (--i >= 0) 1409 while (--i >= 0)
1228 if (adapter->port[i].dev) { 1410 if (adapter->port[i].dev)
1229 cxgb_proc_cleanup(adapter, proc_root_driver); 1411 free_netdev(adapter->port[i].dev);
1230 kfree(adapter->port[i].dev); 1412
1231 }
1232 pci_release_regions(pdev); 1413 pci_release_regions(pdev);
1233 pci_disable_device(pdev); 1414 pci_disable_device(pdev);
1234 pci_set_drvdata(pdev, NULL); 1415 pci_set_drvdata(pdev, NULL);
diff --git a/drivers/net/chelsio/elmer0.h b/drivers/net/chelsio/elmer0.h
index 5590cb2dac19..9ebecaa97d31 100644
--- a/drivers/net/chelsio/elmer0.h
+++ b/drivers/net/chelsio/elmer0.h
@@ -39,6 +39,12 @@
39#ifndef _CXGB_ELMER0_H_ 39#ifndef _CXGB_ELMER0_H_
40#define _CXGB_ELMER0_H_ 40#define _CXGB_ELMER0_H_
41 41
42/* ELMER0 flavors */
43enum {
44 ELMER0_XC2S300E_6FT256_C,
45 ELMER0_XC2S100E_6TQ144_C
46};
47
42/* ELMER0 registers */ 48/* ELMER0 registers */
43#define A_ELMER0_VERSION 0x100000 49#define A_ELMER0_VERSION 0x100000
44#define A_ELMER0_PHY_CFG 0x100004 50#define A_ELMER0_PHY_CFG 0x100004
@@ -149,3 +155,4 @@
149#define MI1_OP_INDIRECT_READ 3 155#define MI1_OP_INDIRECT_READ 3
150 156
151#endif /* _CXGB_ELMER0_H_ */ 157#endif /* _CXGB_ELMER0_H_ */
158
diff --git a/drivers/net/chelsio/espi.c b/drivers/net/chelsio/espi.c
index 542e5e065c6f..4192f0f5b3ee 100644
--- a/drivers/net/chelsio/espi.c
+++ b/drivers/net/chelsio/espi.c
@@ -81,46 +81,36 @@ static int tricn_write(adapter_t *adapter, int bundle_addr, int module_addr,
81 return busy; 81 return busy;
82} 82}
83 83
84/* 1. Deassert rx_reset_core. */
85/* 2. Program TRICN_CNFG registers. */
86/* 3. Deassert rx_reset_link */
87static int tricn_init(adapter_t *adapter) 84static int tricn_init(adapter_t *adapter)
88{ 85{
89 int i = 0; 86 int i, sme = 1;
90 int stat = 0;
91 int timeout = 0;
92 int is_ready = 0;
93 87
94 /* 1 */ 88 if (!(readl(adapter->regs + A_ESPI_RX_RESET) & F_RX_CLK_STATUS)) {
95 timeout=1000; 89 CH_ERR("%s: ESPI clock not ready\n", adapter->name);
96 do { 90 return -1;
97 stat = readl(adapter->regs + A_ESPI_RX_RESET);
98 is_ready = (stat & 0x4);
99 timeout--;
100 udelay(5);
101 } while (!is_ready || (timeout==0));
102 writel(0x2, adapter->regs + A_ESPI_RX_RESET);
103 if (timeout==0)
104 {
105 CH_ERR("ESPI : ERROR : Timeout tricn_init() \n");
106 t1_fatal_err(adapter);
107 } 91 }
108 92
109 /* 2 */ 93 writel(F_ESPI_RX_CORE_RST, adapter->regs + A_ESPI_RX_RESET);
110 tricn_write(adapter, 0, 0, 0, TRICN_CNFG, 0x81); 94
111 tricn_write(adapter, 0, 1, 0, TRICN_CNFG, 0x81); 95 if (sme) {
112 tricn_write(adapter, 0, 2, 0, TRICN_CNFG, 0x81); 96 tricn_write(adapter, 0, 0, 0, TRICN_CNFG, 0x81);
113 for (i=1; i<= 8; i++) tricn_write(adapter, 0, 0, i, TRICN_CNFG, 0xf1); 97 tricn_write(adapter, 0, 1, 0, TRICN_CNFG, 0x81);
114 for (i=1; i<= 2; i++) tricn_write(adapter, 0, 1, i, TRICN_CNFG, 0xf1); 98 tricn_write(adapter, 0, 2, 0, TRICN_CNFG, 0x81);
115 for (i=1; i<= 3; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xe1); 99 }
116 for (i=4; i<= 4; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xf1); 100 for (i = 1; i <= 8; i++)
117 for (i=5; i<= 5; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xe1); 101 tricn_write(adapter, 0, 0, i, TRICN_CNFG, 0xf1);
118 for (i=6; i<= 6; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xf1); 102 for (i = 1; i <= 2; i++)
119 for (i=7; i<= 7; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0x80); 103 tricn_write(adapter, 0, 1, i, TRICN_CNFG, 0xf1);
120 for (i=8; i<= 8; i++) tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xf1); 104 for (i = 1; i <= 3; i++)
121 105 tricn_write(adapter, 0, 2, i, TRICN_CNFG, 0xe1);
122 /* 3 */ 106 tricn_write(adapter, 0, 2, 4, TRICN_CNFG, 0xf1);
123 writel(0x3, adapter->regs + A_ESPI_RX_RESET); 107 tricn_write(adapter, 0, 2, 5, TRICN_CNFG, 0xe1);
108 tricn_write(adapter, 0, 2, 6, TRICN_CNFG, 0xf1);
109 tricn_write(adapter, 0, 2, 7, TRICN_CNFG, 0x80);
110 tricn_write(adapter, 0, 2, 8, TRICN_CNFG, 0xf1);
111
112 writel(F_ESPI_RX_CORE_RST | F_ESPI_RX_LNK_RST,
113 adapter->regs + A_ESPI_RX_RESET);
124 114
125 return 0; 115 return 0;
126} 116}
@@ -143,6 +133,7 @@ void t1_espi_intr_enable(struct peespi *espi)
143 133
144void t1_espi_intr_clear(struct peespi *espi) 134void t1_espi_intr_clear(struct peespi *espi)
145{ 135{
136 readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT);
146 writel(0xffffffff, espi->adapter->regs + A_ESPI_INTR_STATUS); 137 writel(0xffffffff, espi->adapter->regs + A_ESPI_INTR_STATUS);
147 writel(F_PL_INTR_ESPI, espi->adapter->regs + A_PL_CAUSE); 138 writel(F_PL_INTR_ESPI, espi->adapter->regs + A_PL_CAUSE);
148} 139}
@@ -157,7 +148,6 @@ void t1_espi_intr_disable(struct peespi *espi)
157 148
158int t1_espi_intr_handler(struct peespi *espi) 149int t1_espi_intr_handler(struct peespi *espi)
159{ 150{
160 u32 cnt;
161 u32 status = readl(espi->adapter->regs + A_ESPI_INTR_STATUS); 151 u32 status = readl(espi->adapter->regs + A_ESPI_INTR_STATUS);
162 152
163 if (status & F_DIP4ERR) 153 if (status & F_DIP4ERR)
@@ -177,7 +167,7 @@ int t1_espi_intr_handler(struct peespi *espi)
177 * Must read the error count to clear the interrupt 167 * Must read the error count to clear the interrupt
178 * that it causes. 168 * that it causes.
179 */ 169 */
180 cnt = readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT); 170 readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT);
181 } 171 }
182 172
183 /* 173 /*
@@ -192,7 +182,7 @@ int t1_espi_intr_handler(struct peespi *espi)
192 182
193const struct espi_intr_counts *t1_espi_get_intr_counts(struct peespi *espi) 183const struct espi_intr_counts *t1_espi_get_intr_counts(struct peespi *espi)
194{ 184{
195 return &espi->intr_cnt; 185 return &espi->intr_cnt;
196} 186}
197 187
198static void espi_setup_for_pm3393(adapter_t *adapter) 188static void espi_setup_for_pm3393(adapter_t *adapter)
@@ -210,17 +200,45 @@ static void espi_setup_for_pm3393(adapter_t *adapter)
210 writel(V_RX_NPORTS(1) | V_TX_NPORTS(1), adapter->regs + A_PORT_CONFIG); 200 writel(V_RX_NPORTS(1) | V_TX_NPORTS(1), adapter->regs + A_PORT_CONFIG);
211} 201}
212 202
213/* T2 Init part -- */ 203static void espi_setup_for_vsc7321(adapter_t *adapter)
214/* 1. Set T_ESPI_MISCCTRL_ADDR */ 204{
215/* 2. Init ESPI registers. */ 205 writel(0x1f4, adapter->regs + A_ESPI_SCH_TOKEN0);
216/* 3. Init TriCN Hard Macro */ 206 writel(0x1f401f4, adapter->regs + A_ESPI_SCH_TOKEN1);
217int t1_espi_init(struct peespi *espi, int mac_type, int nports) 207 writel(0x1f4, adapter->regs + A_ESPI_SCH_TOKEN2);
208 writel(0xa00, adapter->regs + A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK);
209 writel(0x1ff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK);
210 writel(1, adapter->regs + A_ESPI_CALENDAR_LENGTH);
211 writel(V_RX_NPORTS(4) | V_TX_NPORTS(4), adapter->regs + A_PORT_CONFIG);
212
213 writel(0x08000008, adapter->regs + A_ESPI_TRAIN);
214}
215
216/*
217 * Note that T1B requires at least 2 ports for IXF1010 due to a HW bug.
218 */
219static void espi_setup_for_ixf1010(adapter_t *adapter, int nports)
218{ 220{
219 u32 cnt; 221 writel(1, adapter->regs + A_ESPI_CALENDAR_LENGTH);
222 if (nports == 4) {
223 if (is_T2(adapter)) {
224 writel(0xf00, adapter->regs + A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK);
225 writel(0x3c0, adapter->regs + A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK);
226 } else {
227 writel(0x7ff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK);
228 writel(0x1ff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK);
229 }
230 } else {
231 writel(0x1fff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK);
232 writel(0x7ff, adapter->regs + A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK);
233 }
234 writel(V_RX_NPORTS(nports) | V_TX_NPORTS(nports), adapter->regs + A_PORT_CONFIG);
220 235
236}
237
238int t1_espi_init(struct peespi *espi, int mac_type, int nports)
239{
221 u32 status_enable_extra = 0; 240 u32 status_enable_extra = 0;
222 adapter_t *adapter = espi->adapter; 241 adapter_t *adapter = espi->adapter;
223 u32 status, burstval = 0x800100;
224 242
225 /* Disable ESPI training. MACs that can handle it enable it below. */ 243 /* Disable ESPI training. MACs that can handle it enable it below. */
226 writel(0, adapter->regs + A_ESPI_TRAIN); 244 writel(0, adapter->regs + A_ESPI_TRAIN);
@@ -229,38 +247,20 @@ int t1_espi_init(struct peespi *espi, int mac_type, int nports)
229 writel(V_OUT_OF_SYNC_COUNT(4) | 247 writel(V_OUT_OF_SYNC_COUNT(4) |
230 V_DIP2_PARITY_ERR_THRES(3) | 248 V_DIP2_PARITY_ERR_THRES(3) |
231 V_DIP4_THRES(1), adapter->regs + A_ESPI_MISC_CONTROL); 249 V_DIP4_THRES(1), adapter->regs + A_ESPI_MISC_CONTROL);
232 if (nports == 4) { 250 writel(nports == 4 ? 0x200040 : 0x1000080,
233 /* T204: maxburst1 = 0x40, maxburst2 = 0x20 */ 251 adapter->regs + A_ESPI_MAXBURST1_MAXBURST2);
234 burstval = 0x200040; 252 } else
235 } 253 writel(0x800100, adapter->regs + A_ESPI_MAXBURST1_MAXBURST2);
236 }
237 writel(burstval, adapter->regs + A_ESPI_MAXBURST1_MAXBURST2);
238 254
239 switch (mac_type) { 255 if (mac_type == CHBT_MAC_PM3393)
240 case CHBT_MAC_PM3393:
241 espi_setup_for_pm3393(adapter); 256 espi_setup_for_pm3393(adapter);
242 break; 257 else if (mac_type == CHBT_MAC_VSC7321)
243 default: 258 espi_setup_for_vsc7321(adapter);
259 else if (mac_type == CHBT_MAC_IXF1010) {
260 status_enable_extra = F_INTEL1010MODE;
261 espi_setup_for_ixf1010(adapter, nports);
262 } else
244 return -1; 263 return -1;
245 }
246
247 /*
248 * Make sure any pending interrupts from the SPI are
249 * Cleared before enabling the interrupt.
250 */
251 writel(ESPI_INTR_MASK, espi->adapter->regs + A_ESPI_INTR_ENABLE);
252 status = readl(espi->adapter->regs + A_ESPI_INTR_STATUS);
253 if (status & F_DIP2PARITYERR) {
254 cnt = readl(espi->adapter->regs + A_ESPI_DIP2_ERR_COUNT);
255 }
256
257 /*
258 * For T1B we need to write 1 to clear ESPI interrupts. For T2+ we
259 * write the status as is.
260 */
261 if (status && t1_is_T1B(espi->adapter))
262 status = 1;
263 writel(status, espi->adapter->regs + A_ESPI_INTR_STATUS);
264 264
265 writel(status_enable_extra | F_RXSTATUSENABLE, 265 writel(status_enable_extra | F_RXSTATUSENABLE,
266 adapter->regs + A_ESPI_FIFO_STATUS_ENABLE); 266 adapter->regs + A_ESPI_FIFO_STATUS_ENABLE);
@@ -271,9 +271,11 @@ int t1_espi_init(struct peespi *espi, int mac_type, int nports)
271 * Always position the control at the 1st port egress IN 271 * Always position the control at the 1st port egress IN
272 * (sop,eop) counter to reduce PIOs for T/N210 workaround. 272 * (sop,eop) counter to reduce PIOs for T/N210 workaround.
273 */ 273 */
274 espi->misc_ctrl = (readl(adapter->regs + A_ESPI_MISC_CONTROL) 274 espi->misc_ctrl = readl(adapter->regs + A_ESPI_MISC_CONTROL);
275 & ~MON_MASK) | (F_MONITORED_DIRECTION 275 espi->misc_ctrl &= ~MON_MASK;
276 | F_MONITORED_INTERFACE); 276 espi->misc_ctrl |= F_MONITORED_DIRECTION;
277 if (adapter->params.nports == 1)
278 espi->misc_ctrl |= F_MONITORED_INTERFACE;
277 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL); 279 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
278 spin_lock_init(&espi->lock); 280 spin_lock_init(&espi->lock);
279 } 281 }
@@ -299,8 +301,7 @@ void t1_espi_set_misc_ctrl(adapter_t *adapter, u32 val)
299{ 301{
300 struct peespi *espi = adapter->espi; 302 struct peespi *espi = adapter->espi;
301 303
302 if (!is_T2(adapter)) 304 if (!is_T2(adapter)) return;
303 return;
304 spin_lock(&espi->lock); 305 spin_lock(&espi->lock);
305 espi->misc_ctrl = (val & ~MON_MASK) | 306 espi->misc_ctrl = (val & ~MON_MASK) |
306 (espi->misc_ctrl & MON_MASK); 307 (espi->misc_ctrl & MON_MASK);
@@ -310,27 +311,61 @@ void t1_espi_set_misc_ctrl(adapter_t *adapter, u32 val)
310 311
311u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait) 312u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait)
312{ 313{
313 u32 sel;
314
315 struct peespi *espi = adapter->espi; 314 struct peespi *espi = adapter->espi;
315 u32 sel;
316 316
317 if (!is_T2(adapter)) 317 if (!is_T2(adapter))
318 return 0; 318 return 0;
319
319 sel = V_MONITORED_PORT_NUM((addr & 0x3c) >> 2); 320 sel = V_MONITORED_PORT_NUM((addr & 0x3c) >> 2);
320 if (!wait) { 321 if (!wait) {
321 if (!spin_trylock(&espi->lock)) 322 if (!spin_trylock(&espi->lock))
322 return 0; 323 return 0;
323 } 324 } else
324 else
325 spin_lock(&espi->lock); 325 spin_lock(&espi->lock);
326
326 if ((sel != (espi->misc_ctrl & MON_MASK))) { 327 if ((sel != (espi->misc_ctrl & MON_MASK))) {
327 writel(((espi->misc_ctrl & ~MON_MASK) | sel), 328 writel(((espi->misc_ctrl & ~MON_MASK) | sel),
328 adapter->regs + A_ESPI_MISC_CONTROL); 329 adapter->regs + A_ESPI_MISC_CONTROL);
329 sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3); 330 sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3);
330 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL); 331 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
331 } 332 } else
332 else
333 sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3); 333 sel = readl(adapter->regs + A_ESPI_SCH_TOKEN3);
334 spin_unlock(&espi->lock); 334 spin_unlock(&espi->lock);
335 return sel; 335 return sel;
336} 336}
337
338/*
339 * This function is for T204 only.
340 * compare with t1_espi_get_mon(), it reads espiInTxSop[0 ~ 3] in
341 * one shot, since there is no per port counter on the out side.
342 */
343int
344t1_espi_get_mon_t204(adapter_t *adapter, u32 *valp, u8 wait)
345{
346 struct peespi *espi = adapter->espi;
347 u8 i, nport = (u8)adapter->params.nports;
348
349 if (!wait) {
350 if (!spin_trylock(&espi->lock))
351 return -1;
352 } else
353 spin_lock(&espi->lock);
354
355 if ( (espi->misc_ctrl & MON_MASK) != F_MONITORED_DIRECTION ) {
356 espi->misc_ctrl = (espi->misc_ctrl & ~MON_MASK) |
357 F_MONITORED_DIRECTION;
358 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
359 }
360 for (i = 0 ; i < nport; i++, valp++) {
361 if (i) {
362 writel(espi->misc_ctrl | V_MONITORED_PORT_NUM(i),
363 adapter->regs + A_ESPI_MISC_CONTROL);
364 }
365 *valp = readl(adapter->regs + A_ESPI_SCH_TOKEN3);
366 }
367
368 writel(espi->misc_ctrl, adapter->regs + A_ESPI_MISC_CONTROL);
369 spin_unlock(&espi->lock);
370 return 0;
371}
diff --git a/drivers/net/chelsio/espi.h b/drivers/net/chelsio/espi.h
index c90e37f8457c..84f2c98bc4cc 100644
--- a/drivers/net/chelsio/espi.h
+++ b/drivers/net/chelsio/espi.h
@@ -64,5 +64,6 @@ const struct espi_intr_counts *t1_espi_get_intr_counts(struct peespi *espi);
64 64
65void t1_espi_set_misc_ctrl(adapter_t *adapter, u32 val); 65void t1_espi_set_misc_ctrl(adapter_t *adapter, u32 val);
66u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait); 66u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait);
67int t1_espi_get_mon_t204(adapter_t *, u32 *, u8);
67 68
68#endif /* _CXGB_ESPI_H_ */ 69#endif /* _CXGB_ESPI_H_ */
diff --git a/drivers/net/chelsio/fpga_defs.h b/drivers/net/chelsio/fpga_defs.h
new file mode 100644
index 000000000000..17a3c2ba36a3
--- /dev/null
+++ b/drivers/net/chelsio/fpga_defs.h
@@ -0,0 +1,232 @@
1/* $Date: 2005/03/07 23:59:05 $ $RCSfile: fpga_defs.h,v $ $Revision: 1.4 $ */
2
3/*
4 * FPGA specific definitions
5 */
6
7#ifndef __CHELSIO_FPGA_DEFS_H__
8#define __CHELSIO_FPGA_DEFS_H__
9
10#define FPGA_PCIX_ADDR_VERSION 0xA08
11#define FPGA_PCIX_ADDR_STAT 0xA0C
12
13/* FPGA master interrupt Cause/Enable bits */
14#define FPGA_PCIX_INTERRUPT_SGE_ERROR 0x1
15#define FPGA_PCIX_INTERRUPT_SGE_DATA 0x2
16#define FPGA_PCIX_INTERRUPT_TP 0x4
17#define FPGA_PCIX_INTERRUPT_MC3 0x8
18#define FPGA_PCIX_INTERRUPT_GMAC 0x10
19#define FPGA_PCIX_INTERRUPT_PCIX 0x20
20
21/* TP interrupt register addresses */
22#define FPGA_TP_ADDR_INTERRUPT_ENABLE 0xA10
23#define FPGA_TP_ADDR_INTERRUPT_CAUSE 0xA14
24#define FPGA_TP_ADDR_VERSION 0xA18
25
26/* TP interrupt Cause/Enable bits */
27#define FPGA_TP_INTERRUPT_MC4 0x1
28#define FPGA_TP_INTERRUPT_MC5 0x2
29
30/*
31 * PM interrupt register addresses
32 */
33#define FPGA_MC3_REG_INTRENABLE 0xA20
34#define FPGA_MC3_REG_INTRCAUSE 0xA24
35#define FPGA_MC3_REG_VERSION 0xA28
36
37/*
38 * GMAC interrupt register addresses
39 */
40#define FPGA_GMAC_ADDR_INTERRUPT_ENABLE 0xA30
41#define FPGA_GMAC_ADDR_INTERRUPT_CAUSE 0xA34
42#define FPGA_GMAC_ADDR_VERSION 0xA38
43
44/* GMAC Cause/Enable bits */
45#define FPGA_GMAC_INTERRUPT_PORT0 0x1
46#define FPGA_GMAC_INTERRUPT_PORT1 0x2
47#define FPGA_GMAC_INTERRUPT_PORT2 0x4
48#define FPGA_GMAC_INTERRUPT_PORT3 0x8
49
50/* MI0 registers */
51#define A_MI0_CLK 0xb00
52
53#define S_MI0_CLK_DIV 0
54#define M_MI0_CLK_DIV 0xff
55#define V_MI0_CLK_DIV(x) ((x) << S_MI0_CLK_DIV)
56#define G_MI0_CLK_DIV(x) (((x) >> S_MI0_CLK_DIV) & M_MI0_CLK_DIV)
57
58#define S_MI0_CLK_CNT 8
59#define M_MI0_CLK_CNT 0xff
60#define V_MI0_CLK_CNT(x) ((x) << S_MI0_CLK_CNT)
61#define G_MI0_CLK_CNT(x) (((x) >> S_MI0_CLK_CNT) & M_MI0_CLK_CNT)
62
63#define A_MI0_CSR 0xb04
64
65#define S_MI0_CSR_POLL 0
66#define V_MI0_CSR_POLL(x) ((x) << S_MI0_CSR_POLL)
67#define F_MI0_CSR_POLL V_MI0_CSR_POLL(1U)
68
69#define S_MI0_PREAMBLE 1
70#define V_MI0_PREAMBLE(x) ((x) << S_MI0_PREAMBLE)
71#define F_MI0_PREAMBLE V_MI0_PREAMBLE(1U)
72
73#define S_MI0_INTR_ENABLE 2
74#define V_MI0_INTR_ENABLE(x) ((x) << S_MI0_INTR_ENABLE)
75#define F_MI0_INTR_ENABLE V_MI0_INTR_ENABLE(1U)
76
77#define S_MI0_BUSY 3
78#define V_MI0_BUSY(x) ((x) << S_MI0_BUSY)
79#define F_MI0_BUSY V_MI0_BUSY(1U)
80
81#define S_MI0_MDIO 4
82#define V_MI0_MDIO(x) ((x) << S_MI0_MDIO)
83#define F_MI0_MDIO V_MI0_MDIO(1U)
84
85#define A_MI0_ADDR 0xb08
86
87#define S_MI0_PHY_REG_ADDR 0
88#define M_MI0_PHY_REG_ADDR 0x1f
89#define V_MI0_PHY_REG_ADDR(x) ((x) << S_MI0_PHY_REG_ADDR)
90#define G_MI0_PHY_REG_ADDR(x) (((x) >> S_MI0_PHY_REG_ADDR) & M_MI0_PHY_REG_ADDR)
91
92#define S_MI0_PHY_ADDR 5
93#define M_MI0_PHY_ADDR 0x1f
94#define V_MI0_PHY_ADDR(x) ((x) << S_MI0_PHY_ADDR)
95#define G_MI0_PHY_ADDR(x) (((x) >> S_MI0_PHY_ADDR) & M_MI0_PHY_ADDR)
96
97#define A_MI0_DATA_EXT 0xb0c
98#define A_MI0_DATA_INT 0xb10
99
100/* GMAC registers */
101#define A_GMAC_MACID_LO 0x28
102#define A_GMAC_MACID_HI 0x2c
103#define A_GMAC_CSR 0x30
104
105#define S_INTERFACE 0
106#define M_INTERFACE 0x3
107#define V_INTERFACE(x) ((x) << S_INTERFACE)
108#define G_INTERFACE(x) (((x) >> S_INTERFACE) & M_INTERFACE)
109
110#define S_MAC_TX_ENABLE 2
111#define V_MAC_TX_ENABLE(x) ((x) << S_MAC_TX_ENABLE)
112#define F_MAC_TX_ENABLE V_MAC_TX_ENABLE(1U)
113
114#define S_MAC_RX_ENABLE 3
115#define V_MAC_RX_ENABLE(x) ((x) << S_MAC_RX_ENABLE)
116#define F_MAC_RX_ENABLE V_MAC_RX_ENABLE(1U)
117
118#define S_MAC_LB_ENABLE 4
119#define V_MAC_LB_ENABLE(x) ((x) << S_MAC_LB_ENABLE)
120#define F_MAC_LB_ENABLE V_MAC_LB_ENABLE(1U)
121
122#define S_MAC_SPEED 5
123#define M_MAC_SPEED 0x3
124#define V_MAC_SPEED(x) ((x) << S_MAC_SPEED)
125#define G_MAC_SPEED(x) (((x) >> S_MAC_SPEED) & M_MAC_SPEED)
126
127#define S_MAC_HD_FC_ENABLE 7
128#define V_MAC_HD_FC_ENABLE(x) ((x) << S_MAC_HD_FC_ENABLE)
129#define F_MAC_HD_FC_ENABLE V_MAC_HD_FC_ENABLE(1U)
130
131#define S_MAC_HALF_DUPLEX 8
132#define V_MAC_HALF_DUPLEX(x) ((x) << S_MAC_HALF_DUPLEX)
133#define F_MAC_HALF_DUPLEX V_MAC_HALF_DUPLEX(1U)
134
135#define S_MAC_PROMISC 9
136#define V_MAC_PROMISC(x) ((x) << S_MAC_PROMISC)
137#define F_MAC_PROMISC V_MAC_PROMISC(1U)
138
139#define S_MAC_MC_ENABLE 10
140#define V_MAC_MC_ENABLE(x) ((x) << S_MAC_MC_ENABLE)
141#define F_MAC_MC_ENABLE V_MAC_MC_ENABLE(1U)
142
143#define S_MAC_RESET 11
144#define V_MAC_RESET(x) ((x) << S_MAC_RESET)
145#define F_MAC_RESET V_MAC_RESET(1U)
146
147#define S_MAC_RX_PAUSE_ENABLE 12
148#define V_MAC_RX_PAUSE_ENABLE(x) ((x) << S_MAC_RX_PAUSE_ENABLE)
149#define F_MAC_RX_PAUSE_ENABLE V_MAC_RX_PAUSE_ENABLE(1U)
150
151#define S_MAC_TX_PAUSE_ENABLE 13
152#define V_MAC_TX_PAUSE_ENABLE(x) ((x) << S_MAC_TX_PAUSE_ENABLE)
153#define F_MAC_TX_PAUSE_ENABLE V_MAC_TX_PAUSE_ENABLE(1U)
154
155#define S_MAC_LWM_ENABLE 14
156#define V_MAC_LWM_ENABLE(x) ((x) << S_MAC_LWM_ENABLE)
157#define F_MAC_LWM_ENABLE V_MAC_LWM_ENABLE(1U)
158
159#define S_MAC_MAGIC_PKT_ENABLE 15
160#define V_MAC_MAGIC_PKT_ENABLE(x) ((x) << S_MAC_MAGIC_PKT_ENABLE)
161#define F_MAC_MAGIC_PKT_ENABLE V_MAC_MAGIC_PKT_ENABLE(1U)
162
163#define S_MAC_ISL_ENABLE 16
164#define V_MAC_ISL_ENABLE(x) ((x) << S_MAC_ISL_ENABLE)
165#define F_MAC_ISL_ENABLE V_MAC_ISL_ENABLE(1U)
166
167#define S_MAC_JUMBO_ENABLE 17
168#define V_MAC_JUMBO_ENABLE(x) ((x) << S_MAC_JUMBO_ENABLE)
169#define F_MAC_JUMBO_ENABLE V_MAC_JUMBO_ENABLE(1U)
170
171#define S_MAC_RX_PAD_ENABLE 18
172#define V_MAC_RX_PAD_ENABLE(x) ((x) << S_MAC_RX_PAD_ENABLE)
173#define F_MAC_RX_PAD_ENABLE V_MAC_RX_PAD_ENABLE(1U)
174
175#define S_MAC_RX_CRC_ENABLE 19
176#define V_MAC_RX_CRC_ENABLE(x) ((x) << S_MAC_RX_CRC_ENABLE)
177#define F_MAC_RX_CRC_ENABLE V_MAC_RX_CRC_ENABLE(1U)
178
179#define A_GMAC_IFS 0x34
180
181#define S_MAC_IFS2 0
182#define M_MAC_IFS2 0x3f
183#define V_MAC_IFS2(x) ((x) << S_MAC_IFS2)
184#define G_MAC_IFS2(x) (((x) >> S_MAC_IFS2) & M_MAC_IFS2)
185
186#define S_MAC_IFS1 8
187#define M_MAC_IFS1 0x7f
188#define V_MAC_IFS1(x) ((x) << S_MAC_IFS1)
189#define G_MAC_IFS1(x) (((x) >> S_MAC_IFS1) & M_MAC_IFS1)
190
191#define A_GMAC_JUMBO_FRAME_LEN 0x38
192#define A_GMAC_LNK_DLY 0x3c
193#define A_GMAC_PAUSETIME 0x40
194#define A_GMAC_MCAST_LO 0x44
195#define A_GMAC_MCAST_HI 0x48
196#define A_GMAC_MCAST_MASK_LO 0x4c
197#define A_GMAC_MCAST_MASK_HI 0x50
198#define A_GMAC_RMT_CNT 0x54
199#define A_GMAC_RMT_DATA 0x58
200#define A_GMAC_BACKOFF_SEED 0x5c
201#define A_GMAC_TXF_THRES 0x60
202
203#define S_TXF_READ_THRESHOLD 0
204#define M_TXF_READ_THRESHOLD 0xff
205#define V_TXF_READ_THRESHOLD(x) ((x) << S_TXF_READ_THRESHOLD)
206#define G_TXF_READ_THRESHOLD(x) (((x) >> S_TXF_READ_THRESHOLD) & M_TXF_READ_THRESHOLD)
207
208#define S_TXF_WRITE_THRESHOLD 16
209#define M_TXF_WRITE_THRESHOLD 0xff
210#define V_TXF_WRITE_THRESHOLD(x) ((x) << S_TXF_WRITE_THRESHOLD)
211#define G_TXF_WRITE_THRESHOLD(x) (((x) >> S_TXF_WRITE_THRESHOLD) & M_TXF_WRITE_THRESHOLD)
212
213#define MAC_REG_BASE 0x600
214#define MAC_REG_ADDR(idx, reg) (MAC_REG_BASE + (idx) * 128 + (reg))
215
216#define MAC_REG_IDLO(idx) MAC_REG_ADDR(idx, A_GMAC_MACID_LO)
217#define MAC_REG_IDHI(idx) MAC_REG_ADDR(idx, A_GMAC_MACID_HI)
218#define MAC_REG_CSR(idx) MAC_REG_ADDR(idx, A_GMAC_CSR)
219#define MAC_REG_IFS(idx) MAC_REG_ADDR(idx, A_GMAC_IFS)
220#define MAC_REG_LARGEFRAMELENGTH(idx) MAC_REG_ADDR(idx, A_GMAC_JUMBO_FRAME_LEN)
221#define MAC_REG_LINKDLY(idx) MAC_REG_ADDR(idx, A_GMAC_LNK_DLY)
222#define MAC_REG_PAUSETIME(idx) MAC_REG_ADDR(idx, A_GMAC_PAUSETIME)
223#define MAC_REG_CASTLO(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_LO)
224#define MAC_REG_MCASTHI(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_HI)
225#define MAC_REG_CASTMASKLO(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_MASK_LO)
226#define MAC_REG_MCASTMASKHI(idx) MAC_REG_ADDR(idx, A_GMAC_MCAST_MASK_HI)
227#define MAC_REG_RMCNT(idx) MAC_REG_ADDR(idx, A_GMAC_RMT_CNT)
228#define MAC_REG_RMDATA(idx) MAC_REG_ADDR(idx, A_GMAC_RMT_DATA)
229#define MAC_REG_GMRANDBACKOFFSEED(idx) MAC_REG_ADDR(idx, A_GMAC_BACKOFF_SEED)
230#define MAC_REG_TXFTHRESHOLDS(idx) MAC_REG_ADDR(idx, A_GMAC_TXF_THRES)
231
232#endif
diff --git a/drivers/net/chelsio/gmac.h b/drivers/net/chelsio/gmac.h
index 746b0eeea964..a2b8ad9b5535 100644
--- a/drivers/net/chelsio/gmac.h
+++ b/drivers/net/chelsio/gmac.h
@@ -62,6 +62,8 @@ struct cmac_statistics {
62 u64 TxInternalMACXmitError; 62 u64 TxInternalMACXmitError;
63 u64 TxFramesWithExcessiveDeferral; 63 u64 TxFramesWithExcessiveDeferral;
64 u64 TxFCSErrors; 64 u64 TxFCSErrors;
65 u64 TxJumboFramesOK;
66 u64 TxJumboOctetsOK;
65 67
66 /* Receive */ 68 /* Receive */
67 u64 RxOctetsOK; 69 u64 RxOctetsOK;
@@ -81,6 +83,8 @@ struct cmac_statistics {
81 u64 RxInRangeLengthErrors; 83 u64 RxInRangeLengthErrors;
82 u64 RxOutOfRangeLengthField; 84 u64 RxOutOfRangeLengthField;
83 u64 RxFrameTooLongErrors; 85 u64 RxFrameTooLongErrors;
86 u64 RxJumboFramesOK;
87 u64 RxJumboOctetsOK;
84}; 88};
85 89
86struct cmac_ops { 90struct cmac_ops {
@@ -128,6 +132,7 @@ struct gmac {
128extern struct gmac t1_pm3393_ops; 132extern struct gmac t1_pm3393_ops;
129extern struct gmac t1_chelsio_mac_ops; 133extern struct gmac t1_chelsio_mac_ops;
130extern struct gmac t1_vsc7321_ops; 134extern struct gmac t1_vsc7321_ops;
135extern struct gmac t1_vsc7326_ops;
131extern struct gmac t1_ixf1010_ops; 136extern struct gmac t1_ixf1010_ops;
132extern struct gmac t1_dummy_mac_ops; 137extern struct gmac t1_dummy_mac_ops;
133 138
diff --git a/drivers/net/chelsio/ixf1010.c b/drivers/net/chelsio/ixf1010.c
new file mode 100644
index 000000000000..5b8f144e83d4
--- /dev/null
+++ b/drivers/net/chelsio/ixf1010.c
@@ -0,0 +1,485 @@
1/* $Date: 2005/11/12 02:13:49 $ $RCSfile: ixf1010.c,v $ $Revision: 1.36 $ */
2#include "gmac.h"
3#include "elmer0.h"
4
5/* Update fast changing statistics every 15 seconds */
6#define STATS_TICK_SECS 15
7/* 30 minutes for full statistics update */
8#define MAJOR_UPDATE_TICKS (1800 / STATS_TICK_SECS)
9
10/*
11 * The IXF1010 can handle frames up to 16383 bytes but it's optimized for
12 * frames up to 9831 (0x2667) bytes, so we limit jumbo frame size to this.
13 * This length includes ethernet header and FCS.
14 */
15#define MAX_FRAME_SIZE 0x2667
16
17/* MAC registers */
18enum {
19 /* Per-port registers */
20 REG_MACADDR_LOW = 0,
21 REG_MACADDR_HIGH = 0x4,
22 REG_FDFC_TYPE = 0xC,
23 REG_FC_TX_TIMER_VALUE = 0x1c,
24 REG_IPG_RX_TIME1 = 0x28,
25 REG_IPG_RX_TIME2 = 0x2c,
26 REG_IPG_TX_TIME = 0x30,
27 REG_PAUSE_THRES = 0x38,
28 REG_MAX_FRAME_SIZE = 0x3c,
29 REG_RGMII_SPEED = 0x40,
30 REG_FC_ENABLE = 0x48,
31 REG_DISCARD_CTRL_FRAMES = 0x54,
32 REG_DIVERSE_CONFIG = 0x60,
33 REG_RX_FILTER = 0x64,
34 REG_MC_ADDR_LOW = 0x68,
35 REG_MC_ADDR_HIGH = 0x6c,
36
37 REG_RX_OCTETS_OK = 0x80,
38 REG_RX_OCTETS_BAD = 0x84,
39 REG_RX_UC_PKTS = 0x88,
40 REG_RX_MC_PKTS = 0x8c,
41 REG_RX_BC_PKTS = 0x90,
42 REG_RX_FCS_ERR = 0xb0,
43 REG_RX_TAGGED = 0xb4,
44 REG_RX_DATA_ERR = 0xb8,
45 REG_RX_ALIGN_ERR = 0xbc,
46 REG_RX_LONG_ERR = 0xc0,
47 REG_RX_JABBER_ERR = 0xc4,
48 REG_RX_PAUSE_FRAMES = 0xc8,
49 REG_RX_UNKNOWN_CTRL_FRAMES = 0xcc,
50 REG_RX_VERY_LONG_ERR = 0xd0,
51 REG_RX_RUNT_ERR = 0xd4,
52 REG_RX_SHORT_ERR = 0xd8,
53 REG_RX_SYMBOL_ERR = 0xe4,
54
55 REG_TX_OCTETS_OK = 0x100,
56 REG_TX_OCTETS_BAD = 0x104,
57 REG_TX_UC_PKTS = 0x108,
58 REG_TX_MC_PKTS = 0x10c,
59 REG_TX_BC_PKTS = 0x110,
60 REG_TX_EXCESSIVE_LEN_DROP = 0x14c,
61 REG_TX_UNDERRUN = 0x150,
62 REG_TX_TAGGED = 0x154,
63 REG_TX_PAUSE_FRAMES = 0x15C,
64
65 /* Global registers */
66 REG_PORT_ENABLE = 0x1400,
67
68 REG_JTAG_ID = 0x1430,
69
70 RX_FIFO_HIGH_WATERMARK_BASE = 0x1600,
71 RX_FIFO_LOW_WATERMARK_BASE = 0x1628,
72 RX_FIFO_FRAMES_REMOVED_BASE = 0x1650,
73
74 REG_RX_ERR_DROP = 0x167c,
75 REG_RX_FIFO_OVERFLOW_EVENT = 0x1680,
76
77 TX_FIFO_HIGH_WATERMARK_BASE = 0x1800,
78 TX_FIFO_LOW_WATERMARK_BASE = 0x1828,
79 TX_FIFO_XFER_THRES_BASE = 0x1850,
80
81 REG_TX_FIFO_OVERFLOW_EVENT = 0x1878,
82 REG_TX_FIFO_OOS_EVENT = 0x1884,
83
84 TX_FIFO_FRAMES_REMOVED_BASE = 0x1888,
85
86 REG_SPI_RX_BURST = 0x1c00,
87 REG_SPI_RX_TRAINING = 0x1c04,
88 REG_SPI_RX_CALENDAR = 0x1c08,
89 REG_SPI_TX_SYNC = 0x1c0c
90};
91
92enum { /* RMON registers */
93 REG_RxOctetsTotalOK = 0x80,
94 REG_RxOctetsBad = 0x84,
95 REG_RxUCPkts = 0x88,
96 REG_RxMCPkts = 0x8c,
97 REG_RxBCPkts = 0x90,
98 REG_RxJumboPkts = 0xac,
99 REG_RxFCSErrors = 0xb0,
100 REG_RxDataErrors = 0xb8,
101 REG_RxAlignErrors = 0xbc,
102 REG_RxLongErrors = 0xc0,
103 REG_RxJabberErrors = 0xc4,
104 REG_RxPauseMacControlCounter = 0xc8,
105 REG_RxVeryLongErrors = 0xd0,
106 REG_RxRuntErrors = 0xd4,
107 REG_RxShortErrors = 0xd8,
108 REG_RxSequenceErrors = 0xe0,
109 REG_RxSymbolErrors = 0xe4,
110
111 REG_TxOctetsTotalOK = 0x100,
112 REG_TxOctetsBad = 0x104,
113 REG_TxUCPkts = 0x108,
114 REG_TxMCPkts = 0x10c,
115 REG_TxBCPkts = 0x110,
116 REG_TxJumboPkts = 0x12C,
117 REG_TxTotalCollisions = 0x134,
118 REG_TxExcessiveLengthDrop = 0x14c,
119 REG_TxUnderrun = 0x150,
120 REG_TxCRCErrors = 0x158,
121 REG_TxPauseFrames = 0x15c
122};
123
124enum {
125 DIVERSE_CONFIG_PAD_ENABLE = 0x80,
126 DIVERSE_CONFIG_CRC_ADD = 0x40
127};
128
129#define MACREG_BASE 0
130#define MACREG(mac, mac_reg) ((mac)->instance->mac_base + (mac_reg))
131
132struct _cmac_instance {
133 u32 mac_base;
134 u32 index;
135 u32 version;
136 u32 ticks;
137};
138
139static void disable_port(struct cmac *mac)
140{
141 u32 val;
142
143 t1_tpi_read(mac->adapter, REG_PORT_ENABLE, &val);
144 val &= ~(1 << mac->instance->index);
145 t1_tpi_write(mac->adapter, REG_PORT_ENABLE, val);
146}
147
148#define RMON_UPDATE(mac, name, stat_name) \
149 t1_tpi_read((mac)->adapter, MACREG(mac, REG_##name), &val); \
150 (mac)->stats.stat_name += val;
151
152/*
153 * Read the current values of the RMON counters and add them to the cumulative
154 * port statistics. The HW RMON counters are cleared by this operation.
155 */
156static void port_stats_update(struct cmac *mac)
157{
158 u32 val;
159
160 /* Rx stats */
161 RMON_UPDATE(mac, RxOctetsTotalOK, RxOctetsOK);
162 RMON_UPDATE(mac, RxOctetsBad, RxOctetsBad);
163 RMON_UPDATE(mac, RxUCPkts, RxUnicastFramesOK);
164 RMON_UPDATE(mac, RxMCPkts, RxMulticastFramesOK);
165 RMON_UPDATE(mac, RxBCPkts, RxBroadcastFramesOK);
166 RMON_UPDATE(mac, RxJumboPkts, RxJumboFramesOK);
167 RMON_UPDATE(mac, RxFCSErrors, RxFCSErrors);
168 RMON_UPDATE(mac, RxAlignErrors, RxAlignErrors);
169 RMON_UPDATE(mac, RxLongErrors, RxFrameTooLongErrors);
170 RMON_UPDATE(mac, RxVeryLongErrors, RxFrameTooLongErrors);
171 RMON_UPDATE(mac, RxPauseMacControlCounter, RxPauseFrames);
172 RMON_UPDATE(mac, RxDataErrors, RxDataErrors);
173 RMON_UPDATE(mac, RxJabberErrors, RxJabberErrors);
174 RMON_UPDATE(mac, RxRuntErrors, RxRuntErrors);
175 RMON_UPDATE(mac, RxShortErrors, RxRuntErrors);
176 RMON_UPDATE(mac, RxSequenceErrors, RxSequenceErrors);
177 RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors);
178
179 /* Tx stats (skip collision stats as we are full-duplex only) */
180 RMON_UPDATE(mac, TxOctetsTotalOK, TxOctetsOK);
181 RMON_UPDATE(mac, TxOctetsBad, TxOctetsBad);
182 RMON_UPDATE(mac, TxUCPkts, TxUnicastFramesOK);
183 RMON_UPDATE(mac, TxMCPkts, TxMulticastFramesOK);
184 RMON_UPDATE(mac, TxBCPkts, TxBroadcastFramesOK);
185 RMON_UPDATE(mac, TxJumboPkts, TxJumboFramesOK);
186 RMON_UPDATE(mac, TxPauseFrames, TxPauseFrames);
187 RMON_UPDATE(mac, TxExcessiveLengthDrop, TxLengthErrors);
188 RMON_UPDATE(mac, TxUnderrun, TxUnderrun);
189 RMON_UPDATE(mac, TxCRCErrors, TxFCSErrors);
190}
191
192/* No-op interrupt operation as this MAC does not support interrupts */
193static int mac_intr_op(struct cmac *mac)
194{
195 return 0;
196}
197
198/* Expect MAC address to be in network byte order. */
199static int mac_set_address(struct cmac *mac, u8 addr[6])
200{
201 u32 addr_lo, addr_hi;
202
203 addr_lo = addr[2];
204 addr_lo = (addr_lo << 8) | addr[3];
205 addr_lo = (addr_lo << 8) | addr[4];
206 addr_lo = (addr_lo << 8) | addr[5];
207
208 addr_hi = addr[0];
209 addr_hi = (addr_hi << 8) | addr[1];
210
211 t1_tpi_write(mac->adapter, MACREG(mac, REG_MACADDR_LOW), addr_lo);
212 t1_tpi_write(mac->adapter, MACREG(mac, REG_MACADDR_HIGH), addr_hi);
213 return 0;
214}
215
216static int mac_get_address(struct cmac *mac, u8 addr[6])
217{
218 u32 addr_lo, addr_hi;
219
220 t1_tpi_read(mac->adapter, MACREG(mac, REG_MACADDR_LOW), &addr_lo);
221 t1_tpi_read(mac->adapter, MACREG(mac, REG_MACADDR_HIGH), &addr_hi);
222
223 addr[0] = (u8) (addr_hi >> 8);
224 addr[1] = (u8) addr_hi;
225 addr[2] = (u8) (addr_lo >> 24);
226 addr[3] = (u8) (addr_lo >> 16);
227 addr[4] = (u8) (addr_lo >> 8);
228 addr[5] = (u8) addr_lo;
229 return 0;
230}
231
232/* This is intended to reset a port, not the whole MAC */
233static int mac_reset(struct cmac *mac)
234{
235 return 0;
236}
237
238static int mac_set_rx_mode(struct cmac *mac, struct t1_rx_mode *rm)
239{
240 u32 val, new_mode;
241 adapter_t *adapter = mac->adapter;
242 u32 addr_lo, addr_hi;
243 u8 *addr;
244
245 t1_tpi_read(adapter, MACREG(mac, REG_RX_FILTER), &val);
246 new_mode = val & ~7;
247 if (!t1_rx_mode_promisc(rm) && mac->instance->version > 0)
248 new_mode |= 1; /* only set if version > 0 due to erratum */
249 if (!t1_rx_mode_promisc(rm) && !t1_rx_mode_allmulti(rm)
250 && t1_rx_mode_mc_cnt(rm) <= 1)
251 new_mode |= 2;
252 if (new_mode != val)
253 t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), new_mode);
254 switch (t1_rx_mode_mc_cnt(rm)) {
255 case 0:
256 t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_LOW), 0);
257 t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_HIGH), 0);
258 break;
259 case 1:
260 addr = t1_get_next_mcaddr(rm);
261 addr_lo = (addr[2] << 24) | (addr[3] << 16) | (addr[4] << 8) |
262 addr[5];
263 addr_hi = (addr[0] << 8) | addr[1];
264 t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_LOW), addr_lo);
265 t1_tpi_write(adapter, MACREG(mac, REG_MC_ADDR_HIGH), addr_hi);
266 break;
267 default:
268 break;
269 }
270 return 0;
271}
272
273static int mac_set_mtu(struct cmac *mac, int mtu)
274{
275 /* MAX_FRAME_SIZE inludes header + FCS, mtu doesn't */
276 if (mtu > (MAX_FRAME_SIZE - 14 - 4)) return -EINVAL;
277 t1_tpi_write(mac->adapter, MACREG(mac, REG_MAX_FRAME_SIZE),
278 mtu + 14 + 4);
279 return 0;
280}
281
282static int mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex,
283 int fc)
284{
285 u32 val;
286
287 if (speed >= 0 && speed != SPEED_100 && speed != SPEED_1000)
288 return -1;
289 if (duplex >= 0 && duplex != DUPLEX_FULL)
290 return -1;
291
292 if (speed >= 0) {
293 val = speed == SPEED_100 ? 1 : 2;
294 t1_tpi_write(mac->adapter, MACREG(mac, REG_RGMII_SPEED), val);
295 }
296
297 t1_tpi_read(mac->adapter, MACREG(mac, REG_FC_ENABLE), &val);
298 val &= ~3;
299 if (fc & PAUSE_RX)
300 val |= 1;
301 if (fc & PAUSE_TX)
302 val |= 2;
303 t1_tpi_write(mac->adapter, MACREG(mac, REG_FC_ENABLE), val);
304 return 0;
305}
306
307static int mac_get_speed_duplex_fc(struct cmac *mac, int *speed, int *duplex,
308 int *fc)
309{
310 u32 val;
311
312 if (duplex)
313 *duplex = DUPLEX_FULL;
314 if (speed) {
315 t1_tpi_read(mac->adapter, MACREG(mac, REG_RGMII_SPEED),
316 &val);
317 *speed = (val & 2) ? SPEED_1000 : SPEED_100;
318 }
319 if (fc) {
320 t1_tpi_read(mac->adapter, MACREG(mac, REG_FC_ENABLE), &val);
321 *fc = 0;
322 if (val & 1)
323 *fc |= PAUSE_RX;
324 if (val & 2)
325 *fc |= PAUSE_TX;
326 }
327 return 0;
328}
329
330static void enable_port(struct cmac *mac)
331{
332 u32 val;
333 u32 index = mac->instance->index;
334 adapter_t *adapter = mac->adapter;
335
336 t1_tpi_read(adapter, MACREG(mac, REG_DIVERSE_CONFIG), &val);
337 val |= DIVERSE_CONFIG_CRC_ADD | DIVERSE_CONFIG_PAD_ENABLE;
338 t1_tpi_write(adapter, MACREG(mac, REG_DIVERSE_CONFIG), val);
339 if (mac->instance->version > 0)
340 t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), 3);
341 else /* Don't enable unicast address filtering due to IXF1010 bug */
342 t1_tpi_write(adapter, MACREG(mac, REG_RX_FILTER), 2);
343
344 t1_tpi_read(adapter, REG_RX_ERR_DROP, &val);
345 val |= (1 << index);
346 t1_tpi_write(adapter, REG_RX_ERR_DROP, val);
347
348 /*
349 * Clear the port RMON registers by adding their current values to the
350 * cumulatice port stats and then clearing the stats. Really.
351 */
352 port_stats_update(mac);
353 memset(&mac->stats, 0, sizeof(struct cmac_statistics));
354 mac->instance->ticks = 0;
355
356 t1_tpi_read(adapter, REG_PORT_ENABLE, &val);
357 val |= (1 << index);
358 t1_tpi_write(adapter, REG_PORT_ENABLE, val);
359
360 index <<= 2;
361 if (is_T2(adapter)) {
362 /* T204: set the Fifo water level & threshold */
363 t1_tpi_write(adapter, RX_FIFO_HIGH_WATERMARK_BASE + index, 0x740);
364 t1_tpi_write(adapter, RX_FIFO_LOW_WATERMARK_BASE + index, 0x730);
365 t1_tpi_write(adapter, TX_FIFO_HIGH_WATERMARK_BASE + index, 0x600);
366 t1_tpi_write(adapter, TX_FIFO_LOW_WATERMARK_BASE + index, 0x1d0);
367 t1_tpi_write(adapter, TX_FIFO_XFER_THRES_BASE + index, 0x1100);
368 } else {
369 /*
370 * Set the TX Fifo Threshold to 0x400 instead of 0x100 to work around
371 * Underrun problem. Intel has blessed this solution.
372 */
373 t1_tpi_write(adapter, TX_FIFO_XFER_THRES_BASE + index, 0x400);
374 }
375}
376
377/* IXF1010 ports do not have separate enables for TX and RX */
378static int mac_enable(struct cmac *mac, int which)
379{
380 if (which & (MAC_DIRECTION_RX | MAC_DIRECTION_TX))
381 enable_port(mac);
382 return 0;
383}
384
385static int mac_disable(struct cmac *mac, int which)
386{
387 if (which & (MAC_DIRECTION_RX | MAC_DIRECTION_TX))
388 disable_port(mac);
389 return 0;
390}
391
392/*
393 * This function is called periodically to accumulate the current values of the
394 * RMON counters into the port statistics. Since the counters are only 32 bits
395 * some of them can overflow in less than a minute at GigE speeds, so this
396 * function should be called every 30 seconds or so.
397 *
398 * To cut down on reading costs we update only the octet counters at each tick
399 * and do a full update at major ticks, which can be every 30 minutes or more.
400 */
401static const struct cmac_statistics *mac_update_statistics(struct cmac *mac,
402 int flag)
403{
404 if (flag == MAC_STATS_UPDATE_FULL ||
405 MAJOR_UPDATE_TICKS <= mac->instance->ticks) {
406 port_stats_update(mac);
407 mac->instance->ticks = 0;
408 } else {
409 u32 val;
410
411 RMON_UPDATE(mac, RxOctetsTotalOK, RxOctetsOK);
412 RMON_UPDATE(mac, TxOctetsTotalOK, TxOctetsOK);
413 mac->instance->ticks++;
414 }
415 return &mac->stats;
416}
417
418static void mac_destroy(struct cmac *mac)
419{
420 kfree(mac);
421}
422
423static struct cmac_ops ixf1010_ops = {
424 .destroy = mac_destroy,
425 .reset = mac_reset,
426 .interrupt_enable = mac_intr_op,
427 .interrupt_disable = mac_intr_op,
428 .interrupt_clear = mac_intr_op,
429 .enable = mac_enable,
430 .disable = mac_disable,
431 .set_mtu = mac_set_mtu,
432 .set_rx_mode = mac_set_rx_mode,
433 .set_speed_duplex_fc = mac_set_speed_duplex_fc,
434 .get_speed_duplex_fc = mac_get_speed_duplex_fc,
435 .statistics_update = mac_update_statistics,
436 .macaddress_get = mac_get_address,
437 .macaddress_set = mac_set_address,
438};
439
440static int ixf1010_mac_reset(adapter_t *adapter)
441{
442 u32 val;
443
444 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
445 if ((val & 1) != 0) {
446 val &= ~1;
447 t1_tpi_write(adapter, A_ELMER0_GPO, val);
448 udelay(2);
449 }
450 val |= 1;
451 t1_tpi_write(adapter, A_ELMER0_GPO, val);
452 udelay(2);
453
454 t1_tpi_write(adapter, REG_PORT_ENABLE, 0);
455 return 0;
456}
457
458static struct cmac *ixf1010_mac_create(adapter_t *adapter, int index)
459{
460 struct cmac *mac;
461 u32 val;
462
463 if (index > 9) return NULL;
464
465 mac = kzalloc(sizeof(*mac) + sizeof(cmac_instance), GFP_KERNEL);
466 if (!mac) return NULL;
467
468 mac->ops = &ixf1010_ops;
469 mac->instance = (cmac_instance *)(mac + 1);
470
471 mac->instance->mac_base = MACREG_BASE + (index * 0x200);
472 mac->instance->index = index;
473 mac->adapter = adapter;
474 mac->instance->ticks = 0;
475
476 t1_tpi_read(adapter, REG_JTAG_ID, &val);
477 mac->instance->version = val >> 28;
478 return mac;
479}
480
481struct gmac t1_ixf1010_ops = {
482 STATS_TICK_SECS,
483 ixf1010_mac_create,
484 ixf1010_mac_reset
485};
diff --git a/drivers/net/chelsio/mac.c b/drivers/net/chelsio/mac.c
new file mode 100644
index 000000000000..6af39dc70459
--- /dev/null
+++ b/drivers/net/chelsio/mac.c
@@ -0,0 +1,368 @@
1/* $Date: 2005/10/22 00:42:59 $ $RCSfile: mac.c,v $ $Revision: 1.32 $ */
2#include "gmac.h"
3#include "regs.h"
4#include "fpga_defs.h"
5
6#define MAC_CSR_INTERFACE_GMII 0x0
7#define MAC_CSR_INTERFACE_TBI 0x1
8#define MAC_CSR_INTERFACE_MII 0x2
9#define MAC_CSR_INTERFACE_RMII 0x3
10
11/* Chelsio's MAC statistics. */
12struct mac_statistics {
13
14 /* Transmit */
15 u32 TxFramesTransmittedOK;
16 u32 TxReserved1;
17 u32 TxReserved2;
18 u32 TxOctetsTransmittedOK;
19 u32 TxFramesWithDeferredXmissions;
20 u32 TxLateCollisions;
21 u32 TxFramesAbortedDueToXSCollisions;
22 u32 TxFramesLostDueToIntMACXmitError;
23 u32 TxReserved3;
24 u32 TxMulticastFrameXmittedOK;
25 u32 TxBroadcastFramesXmittedOK;
26 u32 TxFramesWithExcessiveDeferral;
27 u32 TxPAUSEMACCtrlFramesTransmitted;
28
29 /* Receive */
30 u32 RxFramesReceivedOK;
31 u32 RxFrameCheckSequenceErrors;
32 u32 RxAlignmentErrors;
33 u32 RxOctetsReceivedOK;
34 u32 RxFramesLostDueToIntMACRcvError;
35 u32 RxMulticastFramesReceivedOK;
36 u32 RxBroadcastFramesReceivedOK;
37 u32 RxInRangeLengthErrors;
38 u32 RxTxOutOfRangeLengthField;
39 u32 RxFrameTooLongErrors;
40 u32 RxPAUSEMACCtrlFramesReceived;
41};
42
43static int static_aPorts[] = {
44 FPGA_GMAC_INTERRUPT_PORT0,
45 FPGA_GMAC_INTERRUPT_PORT1,
46 FPGA_GMAC_INTERRUPT_PORT2,
47 FPGA_GMAC_INTERRUPT_PORT3
48};
49
50struct _cmac_instance {
51 u32 index;
52};
53
54static int mac_intr_enable(struct cmac *mac)
55{
56 u32 mac_intr;
57
58 if (t1_is_asic(mac->adapter)) {
59 /* ASIC */
60
61 /* We don't use the on chip MAC for ASIC products. */
62 } else {
63 /* FPGA */
64
65 /* Set parent gmac interrupt. */
66 mac_intr = readl(mac->adapter->regs + A_PL_ENABLE);
67 mac_intr |= FPGA_PCIX_INTERRUPT_GMAC;
68 writel(mac_intr, mac->adapter->regs + A_PL_ENABLE);
69
70 mac_intr = readl(mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
71 mac_intr |= static_aPorts[mac->instance->index];
72 writel(mac_intr,
73 mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
74 }
75
76 return 0;
77}
78
79static int mac_intr_disable(struct cmac *mac)
80{
81 u32 mac_intr;
82
83 if (t1_is_asic(mac->adapter)) {
84 /* ASIC */
85
86 /* We don't use the on chip MAC for ASIC products. */
87 } else {
88 /* FPGA */
89
90 /* Set parent gmac interrupt. */
91 mac_intr = readl(mac->adapter->regs + A_PL_ENABLE);
92 mac_intr &= ~FPGA_PCIX_INTERRUPT_GMAC;
93 writel(mac_intr, mac->adapter->regs + A_PL_ENABLE);
94
95 mac_intr = readl(mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
96 mac_intr &= ~(static_aPorts[mac->instance->index]);
97 writel(mac_intr,
98 mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_ENABLE);
99 }
100
101 return 0;
102}
103
104static int mac_intr_clear(struct cmac *mac)
105{
106 u32 mac_intr;
107
108 if (t1_is_asic(mac->adapter)) {
109 /* ASIC */
110
111 /* We don't use the on chip MAC for ASIC products. */
112 } else {
113 /* FPGA */
114
115 /* Set parent gmac interrupt. */
116 writel(FPGA_PCIX_INTERRUPT_GMAC,
117 mac->adapter->regs + A_PL_CAUSE);
118 mac_intr = readl(mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
119 mac_intr |= (static_aPorts[mac->instance->index]);
120 writel(mac_intr,
121 mac->adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
122 }
123
124 return 0;
125}
126
127static int mac_get_address(struct cmac *mac, u8 addr[6])
128{
129 u32 data32_lo, data32_hi;
130
131 data32_lo = readl(mac->adapter->regs
132 + MAC_REG_IDLO(mac->instance->index));
133 data32_hi = readl(mac->adapter->regs
134 + MAC_REG_IDHI(mac->instance->index));
135
136 addr[0] = (u8) ((data32_hi >> 8) & 0xFF);
137 addr[1] = (u8) ((data32_hi) & 0xFF);
138 addr[2] = (u8) ((data32_lo >> 24) & 0xFF);
139 addr[3] = (u8) ((data32_lo >> 16) & 0xFF);
140 addr[4] = (u8) ((data32_lo >> 8) & 0xFF);
141 addr[5] = (u8) ((data32_lo) & 0xFF);
142 return 0;
143}
144
145static int mac_reset(struct cmac *mac)
146{
147 u32 data32;
148 int mac_in_reset, time_out = 100;
149 int idx = mac->instance->index;
150
151 data32 = readl(mac->adapter->regs + MAC_REG_CSR(idx));
152 writel(data32 | F_MAC_RESET,
153 mac->adapter->regs + MAC_REG_CSR(idx));
154
155 do {
156 data32 = readl(mac->adapter->regs + MAC_REG_CSR(idx));
157
158 mac_in_reset = data32 & F_MAC_RESET;
159 if (mac_in_reset)
160 udelay(1);
161 } while (mac_in_reset && --time_out);
162
163 if (mac_in_reset) {
164 CH_ERR("%s: MAC %d reset timed out\n",
165 mac->adapter->name, idx);
166 return 2;
167 }
168
169 return 0;
170}
171
172static int mac_set_rx_mode(struct cmac *mac, struct t1_rx_mode *rm)
173{
174 u32 val;
175
176 val = readl(mac->adapter->regs
177 + MAC_REG_CSR(mac->instance->index));
178 val &= ~(F_MAC_PROMISC | F_MAC_MC_ENABLE);
179 val |= V_MAC_PROMISC(t1_rx_mode_promisc(rm) != 0);
180 val |= V_MAC_MC_ENABLE(t1_rx_mode_allmulti(rm) != 0);
181 writel(val,
182 mac->adapter->regs + MAC_REG_CSR(mac->instance->index));
183
184 return 0;
185}
186
187static int mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex,
188 int fc)
189{
190 u32 data32;
191
192 data32 = readl(mac->adapter->regs
193 + MAC_REG_CSR(mac->instance->index));
194 data32 &= ~(F_MAC_HALF_DUPLEX | V_MAC_SPEED(M_MAC_SPEED) |
195 V_INTERFACE(M_INTERFACE) | F_MAC_TX_PAUSE_ENABLE |
196 F_MAC_RX_PAUSE_ENABLE);
197
198 switch (speed) {
199 case SPEED_10:
200 case SPEED_100:
201 data32 |= V_INTERFACE(MAC_CSR_INTERFACE_MII);
202 data32 |= V_MAC_SPEED(speed == SPEED_10 ? 0 : 1);
203 break;
204 case SPEED_1000:
205 data32 |= V_INTERFACE(MAC_CSR_INTERFACE_GMII);
206 data32 |= V_MAC_SPEED(2);
207 break;
208 }
209
210 if (duplex >= 0)
211 data32 |= V_MAC_HALF_DUPLEX(duplex == DUPLEX_HALF);
212
213 if (fc >= 0) {
214 data32 |= V_MAC_RX_PAUSE_ENABLE((fc & PAUSE_RX) != 0);
215 data32 |= V_MAC_TX_PAUSE_ENABLE((fc & PAUSE_TX) != 0);
216 }
217
218 writel(data32,
219 mac->adapter->regs + MAC_REG_CSR(mac->instance->index));
220 return 0;
221}
222
223static int mac_enable(struct cmac *mac, int which)
224{
225 u32 val;
226
227 val = readl(mac->adapter->regs
228 + MAC_REG_CSR(mac->instance->index));
229 if (which & MAC_DIRECTION_RX)
230 val |= F_MAC_RX_ENABLE;
231 if (which & MAC_DIRECTION_TX)
232 val |= F_MAC_TX_ENABLE;
233 writel(val,
234 mac->adapter->regs + MAC_REG_CSR(mac->instance->index));
235 return 0;
236}
237
238static int mac_disable(struct cmac *mac, int which)
239{
240 u32 val;
241
242 val = readl(mac->adapter->regs
243 + MAC_REG_CSR(mac->instance->index));
244 if (which & MAC_DIRECTION_RX)
245 val &= ~F_MAC_RX_ENABLE;
246 if (which & MAC_DIRECTION_TX)
247 val &= ~F_MAC_TX_ENABLE;
248 writel(val,
249 mac->adapter->regs + MAC_REG_CSR(mac->instance->index));
250 return 0;
251}
252
253#if 0
254static int mac_set_ifs(struct cmac *mac, u32 mode)
255{
256 t1_write_reg_4(mac->adapter,
257 MAC_REG_IFS(mac->instance->index),
258 mode);
259 return 0;
260}
261
262static int mac_enable_isl(struct cmac *mac)
263{
264 u32 data32 = readl(mac->adapter->regs
265 + MAC_REG_CSR(mac->instance->index));
266 data32 |= F_MAC_RX_ENABLE | F_MAC_TX_ENABLE;
267 t1_write_reg_4(mac->adapter,
268 MAC_REG_CSR(mac->instance->index),
269 data32);
270 return 0;
271}
272#endif
273
274static int mac_set_mtu(struct cmac *mac, int mtu)
275{
276 if (mtu > 9600)
277 return -EINVAL;
278 writel(mtu + ETH_HLEN + VLAN_HLEN,
279 mac->adapter->regs + MAC_REG_LARGEFRAMELENGTH(mac->instance->index));
280
281 return 0;
282}
283
284static const struct cmac_statistics *mac_update_statistics(struct cmac *mac,
285 int flag)
286{
287 struct mac_statistics st;
288 u32 *p = (u32 *) & st, i;
289
290 writel(0,
291 mac->adapter->regs + MAC_REG_RMCNT(mac->instance->index));
292
293 for (i = 0; i < sizeof(st) / sizeof(u32); i++)
294 *p++ = readl(mac->adapter->regs
295 + MAC_REG_RMDATA(mac->instance->index));
296
297 /* XXX convert stats */
298 return &mac->stats;
299}
300
301static void mac_destroy(struct cmac *mac)
302{
303 kfree(mac);
304}
305
306static struct cmac_ops chelsio_mac_ops = {
307 .destroy = mac_destroy,
308 .reset = mac_reset,
309 .interrupt_enable = mac_intr_enable,
310 .interrupt_disable = mac_intr_disable,
311 .interrupt_clear = mac_intr_clear,
312 .enable = mac_enable,
313 .disable = mac_disable,
314 .set_mtu = mac_set_mtu,
315 .set_rx_mode = mac_set_rx_mode,
316 .set_speed_duplex_fc = mac_set_speed_duplex_fc,
317 .macaddress_get = mac_get_address,
318 .statistics_update = mac_update_statistics,
319};
320
321static struct cmac *mac_create(adapter_t *adapter, int index)
322{
323 struct cmac *mac;
324 u32 data32;
325
326 if (index >= 4)
327 return NULL;
328
329 mac = kzalloc(sizeof(*mac) + sizeof(cmac_instance), GFP_KERNEL);
330 if (!mac)
331 return NULL;
332
333 mac->ops = &chelsio_mac_ops;
334 mac->instance = (cmac_instance *) (mac + 1);
335
336 mac->instance->index = index;
337 mac->adapter = adapter;
338
339 data32 = readl(adapter->regs + MAC_REG_CSR(mac->instance->index));
340 data32 &= ~(F_MAC_RESET | F_MAC_PROMISC | F_MAC_PROMISC |
341 F_MAC_LB_ENABLE | F_MAC_RX_ENABLE | F_MAC_TX_ENABLE);
342 data32 |= F_MAC_JUMBO_ENABLE;
343 writel(data32, adapter->regs + MAC_REG_CSR(mac->instance->index));
344
345 /* Initialize the random backoff seed. */
346 data32 = 0x55aa + (3 * index);
347 writel(data32,
348 adapter->regs + MAC_REG_GMRANDBACKOFFSEED(mac->instance->index));
349
350 /* Check to see if the mac address needs to be set manually. */
351 data32 = readl(adapter->regs + MAC_REG_IDLO(mac->instance->index));
352 if (data32 == 0 || data32 == 0xffffffff) {
353 /*
354 * Add a default MAC address if we can't read one.
355 */
356 writel(0x43FFFFFF - index,
357 adapter->regs + MAC_REG_IDLO(mac->instance->index));
358 writel(0x0007,
359 adapter->regs + MAC_REG_IDHI(mac->instance->index));
360 }
361
362 (void) mac_set_mtu(mac, 1500);
363 return mac;
364}
365
366struct gmac t1_chelsio_mac_ops = {
367 .create = mac_create
368};
diff --git a/drivers/net/chelsio/mv88e1xxx.c b/drivers/net/chelsio/mv88e1xxx.c
new file mode 100644
index 000000000000..28ac93ff7c4f
--- /dev/null
+++ b/drivers/net/chelsio/mv88e1xxx.c
@@ -0,0 +1,397 @@
1/* $Date: 2005/10/24 23:18:13 $ $RCSfile: mv88e1xxx.c,v $ $Revision: 1.49 $ */
2#include "common.h"
3#include "mv88e1xxx.h"
4#include "cphy.h"
5#include "elmer0.h"
6
7/* MV88E1XXX MDI crossover register values */
8#define CROSSOVER_MDI 0
9#define CROSSOVER_MDIX 1
10#define CROSSOVER_AUTO 3
11
12#define INTR_ENABLE_MASK 0x6CA0
13
14/*
15 * Set the bits given by 'bitval' in PHY register 'reg'.
16 */
17static void mdio_set_bit(struct cphy *cphy, int reg, u32 bitval)
18{
19 u32 val;
20
21 (void) simple_mdio_read(cphy, reg, &val);
22 (void) simple_mdio_write(cphy, reg, val | bitval);
23}
24
25/*
26 * Clear the bits given by 'bitval' in PHY register 'reg'.
27 */
28static void mdio_clear_bit(struct cphy *cphy, int reg, u32 bitval)
29{
30 u32 val;
31
32 (void) simple_mdio_read(cphy, reg, &val);
33 (void) simple_mdio_write(cphy, reg, val & ~bitval);
34}
35
36/*
37 * NAME: phy_reset
38 *
39 * DESC: Reset the given PHY's port. NOTE: This is not a global
40 * chip reset.
41 *
42 * PARAMS: cphy - Pointer to PHY instance data.
43 *
44 * RETURN: 0 - Successfull reset.
45 * -1 - Timeout.
46 */
47static int mv88e1xxx_reset(struct cphy *cphy, int wait)
48{
49 u32 ctl;
50 int time_out = 1000;
51
52 mdio_set_bit(cphy, MII_BMCR, BMCR_RESET);
53
54 do {
55 (void) simple_mdio_read(cphy, MII_BMCR, &ctl);
56 ctl &= BMCR_RESET;
57 if (ctl)
58 udelay(1);
59 } while (ctl && --time_out);
60
61 return ctl ? -1 : 0;
62}
63
64static int mv88e1xxx_interrupt_enable(struct cphy *cphy)
65{
66 /* Enable PHY interrupts. */
67 (void) simple_mdio_write(cphy, MV88E1XXX_INTERRUPT_ENABLE_REGISTER,
68 INTR_ENABLE_MASK);
69
70 /* Enable Marvell interrupts through Elmer0. */
71 if (t1_is_asic(cphy->adapter)) {
72 u32 elmer;
73
74 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
75 elmer |= ELMER0_GP_BIT1;
76 if (is_T2(cphy->adapter)) {
77 elmer |= ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4;
78 }
79 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
80 }
81 return 0;
82}
83
84static int mv88e1xxx_interrupt_disable(struct cphy *cphy)
85{
86 /* Disable all phy interrupts. */
87 (void) simple_mdio_write(cphy, MV88E1XXX_INTERRUPT_ENABLE_REGISTER, 0);
88
89 /* Disable Marvell interrupts through Elmer0. */
90 if (t1_is_asic(cphy->adapter)) {
91 u32 elmer;
92
93 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
94 elmer &= ~ELMER0_GP_BIT1;
95 if (is_T2(cphy->adapter)) {
96 elmer &= ~(ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4);
97 }
98 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
99 }
100 return 0;
101}
102
103static int mv88e1xxx_interrupt_clear(struct cphy *cphy)
104{
105 u32 elmer;
106
107 /* Clear PHY interrupts by reading the register. */
108 (void) simple_mdio_read(cphy,
109 MV88E1XXX_INTERRUPT_STATUS_REGISTER, &elmer);
110
111 /* Clear Marvell interrupts through Elmer0. */
112 if (t1_is_asic(cphy->adapter)) {
113 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer);
114 elmer |= ELMER0_GP_BIT1;
115 if (is_T2(cphy->adapter)) {
116 elmer |= ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4;
117 }
118 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer);
119 }
120 return 0;
121}
122
123/*
124 * Set the PHY speed and duplex. This also disables auto-negotiation, except
125 * for 1Gb/s, where auto-negotiation is mandatory.
126 */
127static int mv88e1xxx_set_speed_duplex(struct cphy *phy, int speed, int duplex)
128{
129 u32 ctl;
130
131 (void) simple_mdio_read(phy, MII_BMCR, &ctl);
132 if (speed >= 0) {
133 ctl &= ~(BMCR_SPEED100 | BMCR_SPEED1000 | BMCR_ANENABLE);
134 if (speed == SPEED_100)
135 ctl |= BMCR_SPEED100;
136 else if (speed == SPEED_1000)
137 ctl |= BMCR_SPEED1000;
138 }
139 if (duplex >= 0) {
140 ctl &= ~(BMCR_FULLDPLX | BMCR_ANENABLE);
141 if (duplex == DUPLEX_FULL)
142 ctl |= BMCR_FULLDPLX;
143 }
144 if (ctl & BMCR_SPEED1000) /* auto-negotiation required for 1Gb/s */
145 ctl |= BMCR_ANENABLE;
146 (void) simple_mdio_write(phy, MII_BMCR, ctl);
147 return 0;
148}
149
150static int mv88e1xxx_crossover_set(struct cphy *cphy, int crossover)
151{
152 u32 data32;
153
154 (void) simple_mdio_read(cphy,
155 MV88E1XXX_SPECIFIC_CNTRL_REGISTER, &data32);
156 data32 &= ~V_PSCR_MDI_XOVER_MODE(M_PSCR_MDI_XOVER_MODE);
157 data32 |= V_PSCR_MDI_XOVER_MODE(crossover);
158 (void) simple_mdio_write(cphy,
159 MV88E1XXX_SPECIFIC_CNTRL_REGISTER, data32);
160 return 0;
161}
162
163static int mv88e1xxx_autoneg_enable(struct cphy *cphy)
164{
165 u32 ctl;
166
167 (void) mv88e1xxx_crossover_set(cphy, CROSSOVER_AUTO);
168
169 (void) simple_mdio_read(cphy, MII_BMCR, &ctl);
170 /* restart autoneg for change to take effect */
171 ctl |= BMCR_ANENABLE | BMCR_ANRESTART;
172 (void) simple_mdio_write(cphy, MII_BMCR, ctl);
173 return 0;
174}
175
176static int mv88e1xxx_autoneg_disable(struct cphy *cphy)
177{
178 u32 ctl;
179
180 /*
181 * Crossover *must* be set to manual in order to disable auto-neg.
182 * The Alaska FAQs document highlights this point.
183 */
184 (void) mv88e1xxx_crossover_set(cphy, CROSSOVER_MDI);
185
186 /*
187 * Must include autoneg reset when disabling auto-neg. This
188 * is described in the Alaska FAQ document.
189 */
190 (void) simple_mdio_read(cphy, MII_BMCR, &ctl);
191 ctl &= ~BMCR_ANENABLE;
192 (void) simple_mdio_write(cphy, MII_BMCR, ctl | BMCR_ANRESTART);
193 return 0;
194}
195
196static int mv88e1xxx_autoneg_restart(struct cphy *cphy)
197{
198 mdio_set_bit(cphy, MII_BMCR, BMCR_ANRESTART);
199 return 0;
200}
201
202static int mv88e1xxx_advertise(struct cphy *phy, unsigned int advertise_map)
203{
204 u32 val = 0;
205
206 if (advertise_map &
207 (ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full)) {
208 (void) simple_mdio_read(phy, MII_GBCR, &val);
209 val &= ~(GBCR_ADV_1000HALF | GBCR_ADV_1000FULL);
210 if (advertise_map & ADVERTISED_1000baseT_Half)
211 val |= GBCR_ADV_1000HALF;
212 if (advertise_map & ADVERTISED_1000baseT_Full)
213 val |= GBCR_ADV_1000FULL;
214 }
215 (void) simple_mdio_write(phy, MII_GBCR, val);
216
217 val = 1;
218 if (advertise_map & ADVERTISED_10baseT_Half)
219 val |= ADVERTISE_10HALF;
220 if (advertise_map & ADVERTISED_10baseT_Full)
221 val |= ADVERTISE_10FULL;
222 if (advertise_map & ADVERTISED_100baseT_Half)
223 val |= ADVERTISE_100HALF;
224 if (advertise_map & ADVERTISED_100baseT_Full)
225 val |= ADVERTISE_100FULL;
226 if (advertise_map & ADVERTISED_PAUSE)
227 val |= ADVERTISE_PAUSE;
228 if (advertise_map & ADVERTISED_ASYM_PAUSE)
229 val |= ADVERTISE_PAUSE_ASYM;
230 (void) simple_mdio_write(phy, MII_ADVERTISE, val);
231 return 0;
232}
233
234static int mv88e1xxx_set_loopback(struct cphy *cphy, int on)
235{
236 if (on)
237 mdio_set_bit(cphy, MII_BMCR, BMCR_LOOPBACK);
238 else
239 mdio_clear_bit(cphy, MII_BMCR, BMCR_LOOPBACK);
240 return 0;
241}
242
243static int mv88e1xxx_get_link_status(struct cphy *cphy, int *link_ok,
244 int *speed, int *duplex, int *fc)
245{
246 u32 status;
247 int sp = -1, dplx = -1, pause = 0;
248
249 (void) simple_mdio_read(cphy,
250 MV88E1XXX_SPECIFIC_STATUS_REGISTER, &status);
251 if ((status & V_PSSR_STATUS_RESOLVED) != 0) {
252 if (status & V_PSSR_RX_PAUSE)
253 pause |= PAUSE_RX;
254 if (status & V_PSSR_TX_PAUSE)
255 pause |= PAUSE_TX;
256 dplx = (status & V_PSSR_DUPLEX) ? DUPLEX_FULL : DUPLEX_HALF;
257 sp = G_PSSR_SPEED(status);
258 if (sp == 0)
259 sp = SPEED_10;
260 else if (sp == 1)
261 sp = SPEED_100;
262 else
263 sp = SPEED_1000;
264 }
265 if (link_ok)
266 *link_ok = (status & V_PSSR_LINK) != 0;
267 if (speed)
268 *speed = sp;
269 if (duplex)
270 *duplex = dplx;
271 if (fc)
272 *fc = pause;
273 return 0;
274}
275
276static int mv88e1xxx_downshift_set(struct cphy *cphy, int downshift_enable)
277{
278 u32 val;
279
280 (void) simple_mdio_read(cphy,
281 MV88E1XXX_EXT_PHY_SPECIFIC_CNTRL_REGISTER, &val);
282
283 /*
284 * Set the downshift counter to 2 so we try to establish Gb link
285 * twice before downshifting.
286 */
287 val &= ~(V_DOWNSHIFT_ENABLE | V_DOWNSHIFT_CNT(M_DOWNSHIFT_CNT));
288
289 if (downshift_enable)
290 val |= V_DOWNSHIFT_ENABLE | V_DOWNSHIFT_CNT(2);
291 (void) simple_mdio_write(cphy,
292 MV88E1XXX_EXT_PHY_SPECIFIC_CNTRL_REGISTER, val);
293 return 0;
294}
295
296static int mv88e1xxx_interrupt_handler(struct cphy *cphy)
297{
298 int cphy_cause = 0;
299 u32 status;
300
301 /*
302 * Loop until cause reads zero. Need to handle bouncing interrupts.
303 */
304 while (1) {
305 u32 cause;
306
307 (void) simple_mdio_read(cphy,
308 MV88E1XXX_INTERRUPT_STATUS_REGISTER,
309 &cause);
310 cause &= INTR_ENABLE_MASK;
311 if (!cause) break;
312
313 if (cause & MV88E1XXX_INTR_LINK_CHNG) {
314 (void) simple_mdio_read(cphy,
315 MV88E1XXX_SPECIFIC_STATUS_REGISTER, &status);
316
317 if (status & MV88E1XXX_INTR_LINK_CHNG) {
318 cphy->state |= PHY_LINK_UP;
319 } else {
320 cphy->state &= ~PHY_LINK_UP;
321 if (cphy->state & PHY_AUTONEG_EN)
322 cphy->state &= ~PHY_AUTONEG_RDY;
323 cphy_cause |= cphy_cause_link_change;
324 }
325 }
326
327 if (cause & MV88E1XXX_INTR_AUTONEG_DONE)
328 cphy->state |= PHY_AUTONEG_RDY;
329
330 if ((cphy->state & (PHY_LINK_UP | PHY_AUTONEG_RDY)) ==
331 (PHY_LINK_UP | PHY_AUTONEG_RDY))
332 cphy_cause |= cphy_cause_link_change;
333 }
334 return cphy_cause;
335}
336
337static void mv88e1xxx_destroy(struct cphy *cphy)
338{
339 kfree(cphy);
340}
341
342static struct cphy_ops mv88e1xxx_ops = {
343 .destroy = mv88e1xxx_destroy,
344 .reset = mv88e1xxx_reset,
345 .interrupt_enable = mv88e1xxx_interrupt_enable,
346 .interrupt_disable = mv88e1xxx_interrupt_disable,
347 .interrupt_clear = mv88e1xxx_interrupt_clear,
348 .interrupt_handler = mv88e1xxx_interrupt_handler,
349 .autoneg_enable = mv88e1xxx_autoneg_enable,
350 .autoneg_disable = mv88e1xxx_autoneg_disable,
351 .autoneg_restart = mv88e1xxx_autoneg_restart,
352 .advertise = mv88e1xxx_advertise,
353 .set_loopback = mv88e1xxx_set_loopback,
354 .set_speed_duplex = mv88e1xxx_set_speed_duplex,
355 .get_link_status = mv88e1xxx_get_link_status,
356};
357
358static struct cphy *mv88e1xxx_phy_create(adapter_t *adapter, int phy_addr,
359 struct mdio_ops *mdio_ops)
360{
361 struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
362
363 if (!cphy) return NULL;
364
365 cphy_init(cphy, adapter, phy_addr, &mv88e1xxx_ops, mdio_ops);
366
367 /* Configure particular PHY's to run in a different mode. */
368 if ((board_info(adapter)->caps & SUPPORTED_TP) &&
369 board_info(adapter)->chip_phy == CHBT_PHY_88E1111) {
370 /*
371 * Configure the PHY transmitter as class A to reduce EMI.
372 */
373 (void) simple_mdio_write(cphy,
374 MV88E1XXX_EXTENDED_ADDR_REGISTER, 0xB);
375 (void) simple_mdio_write(cphy,
376 MV88E1XXX_EXTENDED_REGISTER, 0x8004);
377 }
378 (void) mv88e1xxx_downshift_set(cphy, 1); /* Enable downshift */
379
380 /* LED */
381 if (is_T2(adapter)) {
382 (void) simple_mdio_write(cphy,
383 MV88E1XXX_LED_CONTROL_REGISTER, 0x1);
384 }
385
386 return cphy;
387}
388
389static int mv88e1xxx_phy_reset(adapter_t* adapter)
390{
391 return 0;
392}
393
394struct gphy t1_mv88e1xxx_ops = {
395 mv88e1xxx_phy_create,
396 mv88e1xxx_phy_reset
397};
diff --git a/drivers/net/chelsio/mv88e1xxx.h b/drivers/net/chelsio/mv88e1xxx.h
new file mode 100644
index 000000000000..967cc4286359
--- /dev/null
+++ b/drivers/net/chelsio/mv88e1xxx.h
@@ -0,0 +1,127 @@
1/* $Date: 2005/03/07 23:59:05 $ $RCSfile: mv88e1xxx.h,v $ $Revision: 1.13 $ */
2#ifndef CHELSIO_MV8E1XXX_H
3#define CHELSIO_MV8E1XXX_H
4
5#ifndef BMCR_SPEED1000
6# define BMCR_SPEED1000 0x40
7#endif
8
9#ifndef ADVERTISE_PAUSE
10# define ADVERTISE_PAUSE 0x400
11#endif
12#ifndef ADVERTISE_PAUSE_ASYM
13# define ADVERTISE_PAUSE_ASYM 0x800
14#endif
15
16/* Gigabit MII registers */
17#define MII_GBCR 9 /* 1000Base-T control register */
18#define MII_GBSR 10 /* 1000Base-T status register */
19
20/* 1000Base-T control register fields */
21#define GBCR_ADV_1000HALF 0x100
22#define GBCR_ADV_1000FULL 0x200
23#define GBCR_PREFER_MASTER 0x400
24#define GBCR_MANUAL_AS_MASTER 0x800
25#define GBCR_MANUAL_CONFIG_ENABLE 0x1000
26
27/* 1000Base-T status register fields */
28#define GBSR_LP_1000HALF 0x400
29#define GBSR_LP_1000FULL 0x800
30#define GBSR_REMOTE_OK 0x1000
31#define GBSR_LOCAL_OK 0x2000
32#define GBSR_LOCAL_MASTER 0x4000
33#define GBSR_MASTER_FAULT 0x8000
34
35/* Marvell PHY interrupt status bits. */
36#define MV88E1XXX_INTR_JABBER 0x0001
37#define MV88E1XXX_INTR_POLARITY_CHNG 0x0002
38#define MV88E1XXX_INTR_ENG_DETECT_CHNG 0x0010
39#define MV88E1XXX_INTR_DOWNSHIFT 0x0020
40#define MV88E1XXX_INTR_MDI_XOVER_CHNG 0x0040
41#define MV88E1XXX_INTR_FIFO_OVER_UNDER 0x0080
42#define MV88E1XXX_INTR_FALSE_CARRIER 0x0100
43#define MV88E1XXX_INTR_SYMBOL_ERROR 0x0200
44#define MV88E1XXX_INTR_LINK_CHNG 0x0400
45#define MV88E1XXX_INTR_AUTONEG_DONE 0x0800
46#define MV88E1XXX_INTR_PAGE_RECV 0x1000
47#define MV88E1XXX_INTR_DUPLEX_CHNG 0x2000
48#define MV88E1XXX_INTR_SPEED_CHNG 0x4000
49#define MV88E1XXX_INTR_AUTONEG_ERR 0x8000
50
51/* Marvell PHY specific registers. */
52#define MV88E1XXX_SPECIFIC_CNTRL_REGISTER 16
53#define MV88E1XXX_SPECIFIC_STATUS_REGISTER 17
54#define MV88E1XXX_INTERRUPT_ENABLE_REGISTER 18
55#define MV88E1XXX_INTERRUPT_STATUS_REGISTER 19
56#define MV88E1XXX_EXT_PHY_SPECIFIC_CNTRL_REGISTER 20
57#define MV88E1XXX_RECV_ERR_CNTR_REGISTER 21
58#define MV88E1XXX_RES_REGISTER 22
59#define MV88E1XXX_GLOBAL_STATUS_REGISTER 23
60#define MV88E1XXX_LED_CONTROL_REGISTER 24
61#define MV88E1XXX_MANUAL_LED_OVERRIDE_REGISTER 25
62#define MV88E1XXX_EXT_PHY_SPECIFIC_CNTRL_2_REGISTER 26
63#define MV88E1XXX_EXT_PHY_SPECIFIC_STATUS_REGISTER 27
64#define MV88E1XXX_VIRTUAL_CABLE_TESTER_REGISTER 28
65#define MV88E1XXX_EXTENDED_ADDR_REGISTER 29
66#define MV88E1XXX_EXTENDED_REGISTER 30
67
68/* PHY specific control register fields */
69#define S_PSCR_MDI_XOVER_MODE 5
70#define M_PSCR_MDI_XOVER_MODE 0x3
71#define V_PSCR_MDI_XOVER_MODE(x) ((x) << S_PSCR_MDI_XOVER_MODE)
72#define G_PSCR_MDI_XOVER_MODE(x) (((x) >> S_PSCR_MDI_XOVER_MODE) & M_PSCR_MDI_XOVER_MODE)
73
74/* Extended PHY specific control register fields */
75#define S_DOWNSHIFT_ENABLE 8
76#define V_DOWNSHIFT_ENABLE (1 << S_DOWNSHIFT_ENABLE)
77
78#define S_DOWNSHIFT_CNT 9
79#define M_DOWNSHIFT_CNT 0x7
80#define V_DOWNSHIFT_CNT(x) ((x) << S_DOWNSHIFT_CNT)
81#define G_DOWNSHIFT_CNT(x) (((x) >> S_DOWNSHIFT_CNT) & M_DOWNSHIFT_CNT)
82
83/* PHY specific status register fields */
84#define S_PSSR_JABBER 0
85#define V_PSSR_JABBER (1 << S_PSSR_JABBER)
86
87#define S_PSSR_POLARITY 1
88#define V_PSSR_POLARITY (1 << S_PSSR_POLARITY)
89
90#define S_PSSR_RX_PAUSE 2
91#define V_PSSR_RX_PAUSE (1 << S_PSSR_RX_PAUSE)
92
93#define S_PSSR_TX_PAUSE 3
94#define V_PSSR_TX_PAUSE (1 << S_PSSR_TX_PAUSE)
95
96#define S_PSSR_ENERGY_DETECT 4
97#define V_PSSR_ENERGY_DETECT (1 << S_PSSR_ENERGY_DETECT)
98
99#define S_PSSR_DOWNSHIFT_STATUS 5
100#define V_PSSR_DOWNSHIFT_STATUS (1 << S_PSSR_DOWNSHIFT_STATUS)
101
102#define S_PSSR_MDI 6
103#define V_PSSR_MDI (1 << S_PSSR_MDI)
104
105#define S_PSSR_CABLE_LEN 7
106#define M_PSSR_CABLE_LEN 0x7
107#define V_PSSR_CABLE_LEN(x) ((x) << S_PSSR_CABLE_LEN)
108#define G_PSSR_CABLE_LEN(x) (((x) >> S_PSSR_CABLE_LEN) & M_PSSR_CABLE_LEN)
109
110#define S_PSSR_LINK 10
111#define V_PSSR_LINK (1 << S_PSSR_LINK)
112
113#define S_PSSR_STATUS_RESOLVED 11
114#define V_PSSR_STATUS_RESOLVED (1 << S_PSSR_STATUS_RESOLVED)
115
116#define S_PSSR_PAGE_RECEIVED 12
117#define V_PSSR_PAGE_RECEIVED (1 << S_PSSR_PAGE_RECEIVED)
118
119#define S_PSSR_DUPLEX 13
120#define V_PSSR_DUPLEX (1 << S_PSSR_DUPLEX)
121
122#define S_PSSR_SPEED 14
123#define M_PSSR_SPEED 0x3
124#define V_PSSR_SPEED(x) ((x) << S_PSSR_SPEED)
125#define G_PSSR_SPEED(x) (((x) >> S_PSSR_SPEED) & M_PSSR_SPEED)
126
127#endif
diff --git a/drivers/net/chelsio/mv88x201x.c b/drivers/net/chelsio/mv88x201x.c
index db5034282782..c8e89480d906 100644
--- a/drivers/net/chelsio/mv88x201x.c
+++ b/drivers/net/chelsio/mv88x201x.c
@@ -85,29 +85,33 @@ static int mv88x201x_reset(struct cphy *cphy, int wait)
85 85
86static int mv88x201x_interrupt_enable(struct cphy *cphy) 86static int mv88x201x_interrupt_enable(struct cphy *cphy)
87{ 87{
88 u32 elmer;
89
90 /* Enable PHY LASI interrupts. */ 88 /* Enable PHY LASI interrupts. */
91 mdio_write(cphy, 0x1, 0x9002, 0x1); 89 mdio_write(cphy, 0x1, 0x9002, 0x1);
92 90
93 /* Enable Marvell interrupts through Elmer0. */ 91 /* Enable Marvell interrupts through Elmer0. */
94 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer); 92 if (t1_is_asic(cphy->adapter)) {
95 elmer |= ELMER0_GP_BIT6; 93 u32 elmer;
96 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer); 94
95 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
96 elmer |= ELMER0_GP_BIT6;
97 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
98 }
97 return 0; 99 return 0;
98} 100}
99 101
100static int mv88x201x_interrupt_disable(struct cphy *cphy) 102static int mv88x201x_interrupt_disable(struct cphy *cphy)
101{ 103{
102 u32 elmer;
103
104 /* Disable PHY LASI interrupts. */ 104 /* Disable PHY LASI interrupts. */
105 mdio_write(cphy, 0x1, 0x9002, 0x0); 105 mdio_write(cphy, 0x1, 0x9002, 0x0);
106 106
107 /* Disable Marvell interrupts through Elmer0. */ 107 /* Disable Marvell interrupts through Elmer0. */
108 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer); 108 if (t1_is_asic(cphy->adapter)) {
109 elmer &= ~ELMER0_GP_BIT6; 109 u32 elmer;
110 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer); 110
111 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
112 elmer &= ~ELMER0_GP_BIT6;
113 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
114 }
111 return 0; 115 return 0;
112} 116}
113 117
@@ -140,9 +144,11 @@ static int mv88x201x_interrupt_clear(struct cphy *cphy)
140#endif 144#endif
141 145
142 /* Clear Marvell interrupts through Elmer0. */ 146 /* Clear Marvell interrupts through Elmer0. */
143 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer); 147 if (t1_is_asic(cphy->adapter)) {
144 elmer |= ELMER0_GP_BIT6; 148 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer);
145 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer); 149 elmer |= ELMER0_GP_BIT6;
150 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer);
151 }
146 return 0; 152 return 0;
147} 153}
148 154
@@ -205,11 +211,11 @@ static struct cphy *mv88x201x_phy_create(adapter_t *adapter, int phy_addr,
205 struct mdio_ops *mdio_ops) 211 struct mdio_ops *mdio_ops)
206{ 212{
207 u32 val; 213 u32 val;
208 struct cphy *cphy = kmalloc(sizeof(*cphy), GFP_KERNEL); 214 struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
209 215
210 if (!cphy) 216 if (!cphy)
211 return NULL; 217 return NULL;
212 memset(cphy, 0, sizeof(*cphy)); 218
213 cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops); 219 cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops);
214 220
215 /* Commands the PHY to enable XFP's clock. */ 221 /* Commands the PHY to enable XFP's clock. */
diff --git a/drivers/net/chelsio/my3126.c b/drivers/net/chelsio/my3126.c
new file mode 100644
index 000000000000..0b90014d5b3e
--- /dev/null
+++ b/drivers/net/chelsio/my3126.c
@@ -0,0 +1,204 @@
1/* $Date: 2005/11/12 02:13:49 $ $RCSfile: my3126.c,v $ $Revision: 1.15 $ */
2#include "cphy.h"
3#include "elmer0.h"
4#include "suni1x10gexp_regs.h"
5
6/* Port Reset */
7static int my3126_reset(struct cphy *cphy, int wait)
8{
9 /*
10 * This can be done through registers. It is not required since
11 * a full chip reset is used.
12 */
13 return (0);
14}
15
16static int my3126_interrupt_enable(struct cphy *cphy)
17{
18 schedule_delayed_work(&cphy->phy_update, HZ/30);
19 t1_tpi_read(cphy->adapter, A_ELMER0_GPO, &cphy->elmer_gpo);
20 return (0);
21}
22
23static int my3126_interrupt_disable(struct cphy *cphy)
24{
25 cancel_rearming_delayed_work(&cphy->phy_update);
26 return (0);
27}
28
29static int my3126_interrupt_clear(struct cphy *cphy)
30{
31 return (0);
32}
33
34#define OFFSET(REG_ADDR) (REG_ADDR << 2)
35
36static int my3126_interrupt_handler(struct cphy *cphy)
37{
38 u32 val;
39 u16 val16;
40 u16 status;
41 u32 act_count;
42 adapter_t *adapter;
43 adapter = cphy->adapter;
44
45 if (cphy->count == 50) {
46 mdio_read(cphy, 0x1, 0x1, &val);
47 val16 = (u16) val;
48 status = cphy->bmsr ^ val16;
49
50 if (status & BMSR_LSTATUS)
51 t1_link_changed(adapter, 0);
52 cphy->bmsr = val16;
53
54 /* We have only enabled link change interrupts so it
55 must be that
56 */
57 cphy->count = 0;
58 }
59
60 t1_tpi_write(adapter, OFFSET(SUNI1x10GEXP_REG_MSTAT_CONTROL),
61 SUNI1x10GEXP_BITMSK_MSTAT_SNAP);
62 t1_tpi_read(adapter,
63 OFFSET(SUNI1x10GEXP_REG_MSTAT_COUNTER_1_LOW), &act_count);
64 t1_tpi_read(adapter,
65 OFFSET(SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW), &val);
66 act_count += val;
67
68 /* Populate elmer_gpo with the register value */
69 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
70 cphy->elmer_gpo = val;
71
72 if ( (val & (1 << 8)) || (val & (1 << 19)) ||
73 (cphy->act_count == act_count) || cphy->act_on ) {
74 if (is_T2(adapter))
75 val |= (1 << 9);
76 else if (t1_is_T1B(adapter))
77 val |= (1 << 20);
78 cphy->act_on = 0;
79 } else {
80 if (is_T2(adapter))
81 val &= ~(1 << 9);
82 else if (t1_is_T1B(adapter))
83 val &= ~(1 << 20);
84 cphy->act_on = 1;
85 }
86
87 t1_tpi_write(adapter, A_ELMER0_GPO, val);
88
89 cphy->elmer_gpo = val;
90 cphy->act_count = act_count;
91 cphy->count++;
92
93 return cphy_cause_link_change;
94}
95
96static void my3216_poll(void *arg)
97{
98 my3126_interrupt_handler(arg);
99}
100
101static int my3126_set_loopback(struct cphy *cphy, int on)
102{
103 return (0);
104}
105
106/* To check the activity LED */
107static int my3126_get_link_status(struct cphy *cphy,
108 int *link_ok, int *speed, int *duplex, int *fc)
109{
110 u32 val;
111 u16 val16;
112 adapter_t *adapter;
113
114 adapter = cphy->adapter;
115 mdio_read(cphy, 0x1, 0x1, &val);
116 val16 = (u16) val;
117
118 /* Populate elmer_gpo with the register value */
119 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
120 cphy->elmer_gpo = val;
121
122 *link_ok = (val16 & BMSR_LSTATUS);
123
124 if (*link_ok) {
125 /* Turn on the LED. */
126 if (is_T2(adapter))
127 val &= ~(1 << 8);
128 else if (t1_is_T1B(adapter))
129 val &= ~(1 << 19);
130 } else {
131 /* Turn off the LED. */
132 if (is_T2(adapter))
133 val |= (1 << 8);
134 else if (t1_is_T1B(adapter))
135 val |= (1 << 19);
136 }
137
138 t1_tpi_write(adapter, A_ELMER0_GPO, val);
139 cphy->elmer_gpo = val;
140 *speed = SPEED_10000;
141 *duplex = DUPLEX_FULL;
142
143 /* need to add flow control */
144 if (fc)
145 *fc = PAUSE_RX | PAUSE_TX;
146
147 return (0);
148}
149
150static void my3126_destroy(struct cphy *cphy)
151{
152 kfree(cphy);
153}
154
155static struct cphy_ops my3126_ops = {
156 .destroy = my3126_destroy,
157 .reset = my3126_reset,
158 .interrupt_enable = my3126_interrupt_enable,
159 .interrupt_disable = my3126_interrupt_disable,
160 .interrupt_clear = my3126_interrupt_clear,
161 .interrupt_handler = my3126_interrupt_handler,
162 .get_link_status = my3126_get_link_status,
163 .set_loopback = my3126_set_loopback,
164};
165
166static struct cphy *my3126_phy_create(adapter_t *adapter,
167 int phy_addr, struct mdio_ops *mdio_ops)
168{
169 struct cphy *cphy = kzalloc(sizeof (*cphy), GFP_KERNEL);
170
171 if (cphy)
172 cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops);
173
174 INIT_WORK(&cphy->phy_update, my3216_poll, cphy);
175 cphy->bmsr = 0;
176
177 return (cphy);
178}
179
180/* Chip Reset */
181static int my3126_phy_reset(adapter_t * adapter)
182{
183 u32 val;
184
185 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
186 val &= ~4;
187 t1_tpi_write(adapter, A_ELMER0_GPO, val);
188 msleep(100);
189
190 t1_tpi_write(adapter, A_ELMER0_GPO, val | 4);
191 msleep(1000);
192
193 /* Now lets enable the Laser. Delay 100us */
194 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
195 val |= 0x8000;
196 t1_tpi_write(adapter, A_ELMER0_GPO, val);
197 udelay(100);
198 return (0);
199}
200
201struct gphy t1_my3126_ops = {
202 my3126_phy_create,
203 my3126_phy_reset
204};
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c
index 04a1404fc65e..63cabeb98afe 100644
--- a/drivers/net/chelsio/pm3393.c
+++ b/drivers/net/chelsio/pm3393.c
@@ -43,21 +43,7 @@
43#include "elmer0.h" 43#include "elmer0.h"
44#include "suni1x10gexp_regs.h" 44#include "suni1x10gexp_regs.h"
45 45
46/* 802.3ae 10Gb/s MDIO Manageable Device(MMD) 46#include <linux/crc32.h>
47 */
48enum {
49 MMD_RESERVED,
50 MMD_PMAPMD,
51 MMD_WIS,
52 MMD_PCS,
53 MMD_PHY_XGXS, /* XGMII Extender Sublayer */
54 MMD_DTE_XGXS,
55};
56
57enum {
58 PHY_XGXS_CTRL_1,
59 PHY_XGXS_STATUS_1
60};
61 47
62#define OFFSET(REG_ADDR) (REG_ADDR << 2) 48#define OFFSET(REG_ADDR) (REG_ADDR << 2)
63 49
@@ -88,6 +74,8 @@ enum { /* RMON registers */
88 RxJabbers = SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW, 74 RxJabbers = SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW,
89 RxFragments = SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW, 75 RxFragments = SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW,
90 RxUndersizedFrames = SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW, 76 RxUndersizedFrames = SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW,
77 RxJumboFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_25_LOW,
78 RxJumboOctetsReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_26_LOW,
91 79
92 TxOctetsTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW, 80 TxOctetsTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW,
93 TxFramesLostDueToInternalMACTransmissionError = SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW, 81 TxFramesLostDueToInternalMACTransmissionError = SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW,
@@ -95,7 +83,9 @@ enum { /* RMON registers */
95 TxUnicastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW, 83 TxUnicastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW,
96 TxMulticastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW, 84 TxMulticastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW,
97 TxBroadcastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW, 85 TxBroadcastFramesTransmittedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW,
98 TxPAUSEMACCtrlFramesTransmitted = SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW 86 TxPAUSEMACCtrlFramesTransmitted = SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW,
87 TxJumboFramesReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_51_LOW,
88 TxJumboOctetsReceivedOK = SUNI1x10GEXP_REG_MSTAT_COUNTER_52_LOW
99}; 89};
100 90
101struct _cmac_instance { 91struct _cmac_instance {
@@ -124,12 +114,12 @@ static int pm3393_reset(struct cmac *cmac)
124 114
125/* 115/*
126 * Enable interrupts for the PM3393 116 * Enable interrupts for the PM3393
127 117 *
128 1. Enable PM3393 BLOCK interrupts. 118 * 1. Enable PM3393 BLOCK interrupts.
129 2. Enable PM3393 Master Interrupt bit(INTE) 119 * 2. Enable PM3393 Master Interrupt bit(INTE)
130 3. Enable ELMER's PM3393 bit. 120 * 3. Enable ELMER's PM3393 bit.
131 4. Enable Terminator external interrupt. 121 * 4. Enable Terminator external interrupt.
132*/ 122 */
133static int pm3393_interrupt_enable(struct cmac *cmac) 123static int pm3393_interrupt_enable(struct cmac *cmac)
134{ 124{
135 u32 pl_intr; 125 u32 pl_intr;
@@ -257,14 +247,12 @@ static int pm3393_interrupt_clear(struct cmac *cmac)
257static int pm3393_interrupt_handler(struct cmac *cmac) 247static int pm3393_interrupt_handler(struct cmac *cmac)
258{ 248{
259 u32 master_intr_status; 249 u32 master_intr_status;
260/* 250
261 1. Read master interrupt register.
262 2. Read BLOCK's interrupt status registers.
263 3. Handle BLOCK interrupts.
264*/
265 /* Read the master interrupt status register. */ 251 /* Read the master interrupt status register. */
266 pmread(cmac, SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS, 252 pmread(cmac, SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS,
267 &master_intr_status); 253 &master_intr_status);
254 CH_DBG(cmac->adapter, INTR, "PM3393 intr cause 0x%x\n",
255 master_intr_status);
268 256
269 /* TBD XXX Lets just clear everything for now */ 257 /* TBD XXX Lets just clear everything for now */
270 pm3393_interrupt_clear(cmac); 258 pm3393_interrupt_clear(cmac);
@@ -307,11 +295,7 @@ static int pm3393_enable_port(struct cmac *cmac, int which)
307 * The PHY doesn't give us link status indication on its own so have 295 * The PHY doesn't give us link status indication on its own so have
308 * the link management code query it instead. 296 * the link management code query it instead.
309 */ 297 */
310 { 298 t1_link_changed(cmac->adapter, 0);
311 extern void link_changed(adapter_t *adapter, int port_id);
312
313 link_changed(cmac->adapter, 0);
314 }
315 return 0; 299 return 0;
316} 300}
317 301
@@ -363,33 +347,6 @@ static int pm3393_set_mtu(struct cmac *cmac, int mtu)
363 return 0; 347 return 0;
364} 348}
365 349
366static u32 calc_crc(u8 *b, int len)
367{
368 int i;
369 u32 crc = (u32)~0;
370
371 /* calculate crc one bit at a time */
372 while (len--) {
373 crc ^= *b++;
374 for (i = 0; i < 8; i++) {
375 if (crc & 0x1)
376 crc = (crc >> 1) ^ 0xedb88320;
377 else
378 crc = (crc >> 1);
379 }
380 }
381
382 /* reverse bits */
383 crc = ((crc >> 4) & 0x0f0f0f0f) | ((crc << 4) & 0xf0f0f0f0);
384 crc = ((crc >> 2) & 0x33333333) | ((crc << 2) & 0xcccccccc);
385 crc = ((crc >> 1) & 0x55555555) | ((crc << 1) & 0xaaaaaaaa);
386 /* swap bytes */
387 crc = (crc >> 16) | (crc << 16);
388 crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00);
389
390 return crc;
391}
392
393static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm) 350static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm)
394{ 351{
395 int enabled = cmac->instance->enabled & MAC_DIRECTION_RX; 352 int enabled = cmac->instance->enabled & MAC_DIRECTION_RX;
@@ -423,7 +380,7 @@ static int pm3393_set_rx_mode(struct cmac *cmac, struct t1_rx_mode *rm)
423 u16 mc_filter[4] = { 0, }; 380 u16 mc_filter[4] = { 0, };
424 381
425 while ((addr = t1_get_next_mcaddr(rm))) { 382 while ((addr = t1_get_next_mcaddr(rm))) {
426 bit = (calc_crc(addr, ETH_ALEN) >> 23) & 0x3f; /* bit[23:28] */ 383 bit = (ether_crc(ETH_ALEN, addr) >> 23) & 0x3f; /* bit[23:28] */
427 mc_filter[bit >> 4] |= 1 << (bit & 0xf); 384 mc_filter[bit >> 4] |= 1 << (bit & 0xf);
428 } 385 }
429 pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0]); 386 pmwrite(cmac, SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW, mc_filter[0]);
@@ -471,20 +428,29 @@ static int pm3393_set_speed_duplex_fc(struct cmac *cmac, int speed, int duplex,
471 return 0; 428 return 0;
472} 429}
473 430
431static void pm3393_rmon_update(struct adapter *adapter, u32 offs, u64 *val,
432 int over)
433{
434 u32 val0, val1, val2;
435
436 t1_tpi_read(adapter, offs, &val0);
437 t1_tpi_read(adapter, offs + 4, &val1);
438 t1_tpi_read(adapter, offs + 8, &val2);
439
440 *val &= ~0ull << 40;
441 *val |= val0 & 0xffff;
442 *val |= (val1 & 0xffff) << 16;
443 *val |= (u64)(val2 & 0xff) << 32;
444
445 if (over)
446 *val += 1ull << 40;
447}
448
474#define RMON_UPDATE(mac, name, stat_name) \ 449#define RMON_UPDATE(mac, name, stat_name) \
475 { \ 450 pm3393_rmon_update((mac)->adapter, OFFSET(name), \
476 t1_tpi_read((mac)->adapter, OFFSET(name), &val0); \ 451 &(mac)->stats.stat_name, \
477 t1_tpi_read((mac)->adapter, OFFSET(((name)+1)), &val1); \ 452 (ro &((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2)))
478 t1_tpi_read((mac)->adapter, OFFSET(((name)+2)), &val2); \ 453
479 (mac)->stats.stat_name = ((u64)val0 & 0xffff) | \
480 (((u64)val1 & 0xffff) << 16) | \
481 (((u64)val2 & 0xff) << 32) | \
482 ((mac)->stats.stat_name & \
483 (~(u64)0 << 40)); \
484 if (ro & \
485 ((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2)) \
486 (mac)->stats.stat_name += ((u64)1 << 40); \
487 }
488 454
489static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, 455static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
490 int flag) 456 int flag)
@@ -519,6 +485,8 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
519 RMON_UPDATE(mac, RxJabbers, RxJabberErrors); 485 RMON_UPDATE(mac, RxJabbers, RxJabberErrors);
520 RMON_UPDATE(mac, RxFragments, RxRuntErrors); 486 RMON_UPDATE(mac, RxFragments, RxRuntErrors);
521 RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors); 487 RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors);
488 RMON_UPDATE(mac, RxJumboFramesReceivedOK, RxJumboFramesOK);
489 RMON_UPDATE(mac, RxJumboOctetsReceivedOK, RxJumboOctetsOK);
522 490
523 /* Tx stats */ 491 /* Tx stats */
524 RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK); 492 RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK);
@@ -529,6 +497,8 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
529 RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK); 497 RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK);
530 RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK); 498 RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK);
531 RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames); 499 RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames);
500 RMON_UPDATE(mac, TxJumboFramesReceivedOK, TxJumboFramesOK);
501 RMON_UPDATE(mac, TxJumboOctetsReceivedOK, TxJumboOctetsOK);
532 502
533 return &mac->stats; 503 return &mac->stats;
534} 504}
@@ -631,10 +601,9 @@ static struct cmac *pm3393_mac_create(adapter_t *adapter, int index)
631{ 601{
632 struct cmac *cmac; 602 struct cmac *cmac;
633 603
634 cmac = kmalloc(sizeof(*cmac) + sizeof(cmac_instance), GFP_KERNEL); 604 cmac = kzalloc(sizeof(*cmac) + sizeof(cmac_instance), GFP_KERNEL);
635 if (!cmac) 605 if (!cmac)
636 return NULL; 606 return NULL;
637 memset(cmac, 0, sizeof(*cmac));
638 607
639 cmac->ops = &pm3393_ops; 608 cmac->ops = &pm3393_ops;
640 cmac->instance = (cmac_instance *) (cmac + 1); 609 cmac->instance = (cmac_instance *) (cmac + 1);
@@ -815,6 +784,12 @@ static int pm3393_mac_reset(adapter_t * adapter)
815 784
816 successful_reset = (is_pl4_reset_finished && !is_pl4_outof_lock 785 successful_reset = (is_pl4_reset_finished && !is_pl4_outof_lock
817 && is_xaui_mabc_pll_locked); 786 && is_xaui_mabc_pll_locked);
787
788 CH_DBG(adapter, HW,
789 "PM3393 HW reset %d: pl4_reset 0x%x, val 0x%x, "
790 "is_pl4_outof_lock 0x%x, xaui_locked 0x%x\n",
791 i, is_pl4_reset_finished, val, is_pl4_outof_lock,
792 is_xaui_mabc_pll_locked);
818 } 793 }
819 return successful_reset ? 0 : 1; 794 return successful_reset ? 0 : 1;
820} 795}
diff --git a/drivers/net/chelsio/regs.h b/drivers/net/chelsio/regs.h
index b90e11f40d1f..c80bf4d6d0a6 100644
--- a/drivers/net/chelsio/regs.h
+++ b/drivers/net/chelsio/regs.h
@@ -71,6 +71,10 @@
71#define V_CMDQ_PRIORITY(x) ((x) << S_CMDQ_PRIORITY) 71#define V_CMDQ_PRIORITY(x) ((x) << S_CMDQ_PRIORITY)
72#define G_CMDQ_PRIORITY(x) (((x) >> S_CMDQ_PRIORITY) & M_CMDQ_PRIORITY) 72#define G_CMDQ_PRIORITY(x) (((x) >> S_CMDQ_PRIORITY) & M_CMDQ_PRIORITY)
73 73
74#define S_DISABLE_CMDQ0_GTS 8
75#define V_DISABLE_CMDQ0_GTS(x) ((x) << S_DISABLE_CMDQ0_GTS)
76#define F_DISABLE_CMDQ0_GTS V_DISABLE_CMDQ0_GTS(1U)
77
74#define S_DISABLE_CMDQ1_GTS 9 78#define S_DISABLE_CMDQ1_GTS 9
75#define V_DISABLE_CMDQ1_GTS(x) ((x) << S_DISABLE_CMDQ1_GTS) 79#define V_DISABLE_CMDQ1_GTS(x) ((x) << S_DISABLE_CMDQ1_GTS)
76#define F_DISABLE_CMDQ1_GTS V_DISABLE_CMDQ1_GTS(1U) 80#define F_DISABLE_CMDQ1_GTS V_DISABLE_CMDQ1_GTS(1U)
@@ -87,12 +91,18 @@
87#define V_ENABLE_BIG_ENDIAN(x) ((x) << S_ENABLE_BIG_ENDIAN) 91#define V_ENABLE_BIG_ENDIAN(x) ((x) << S_ENABLE_BIG_ENDIAN)
88#define F_ENABLE_BIG_ENDIAN V_ENABLE_BIG_ENDIAN(1U) 92#define F_ENABLE_BIG_ENDIAN V_ENABLE_BIG_ENDIAN(1U)
89 93
94#define S_FL_SELECTION_CRITERIA 13
95#define V_FL_SELECTION_CRITERIA(x) ((x) << S_FL_SELECTION_CRITERIA)
96#define F_FL_SELECTION_CRITERIA V_FL_SELECTION_CRITERIA(1U)
97
90#define S_ISCSI_COALESCE 14 98#define S_ISCSI_COALESCE 14
91#define V_ISCSI_COALESCE(x) ((x) << S_ISCSI_COALESCE) 99#define V_ISCSI_COALESCE(x) ((x) << S_ISCSI_COALESCE)
92#define F_ISCSI_COALESCE V_ISCSI_COALESCE(1U) 100#define F_ISCSI_COALESCE V_ISCSI_COALESCE(1U)
93 101
94#define S_RX_PKT_OFFSET 15 102#define S_RX_PKT_OFFSET 15
103#define M_RX_PKT_OFFSET 0x7
95#define V_RX_PKT_OFFSET(x) ((x) << S_RX_PKT_OFFSET) 104#define V_RX_PKT_OFFSET(x) ((x) << S_RX_PKT_OFFSET)
105#define G_RX_PKT_OFFSET(x) (((x) >> S_RX_PKT_OFFSET) & M_RX_PKT_OFFSET)
96 106
97#define S_VLAN_XTRACT 18 107#define S_VLAN_XTRACT 18
98#define V_VLAN_XTRACT(x) ((x) << S_VLAN_XTRACT) 108#define V_VLAN_XTRACT(x) ((x) << S_VLAN_XTRACT)
@@ -108,16 +118,114 @@
108#define A_SG_FL1BASELWR 0x20 118#define A_SG_FL1BASELWR 0x20
109#define A_SG_FL1BASEUPR 0x24 119#define A_SG_FL1BASEUPR 0x24
110#define A_SG_CMD0SIZE 0x28 120#define A_SG_CMD0SIZE 0x28
121
122#define S_CMDQ0_SIZE 0
123#define M_CMDQ0_SIZE 0x1ffff
124#define V_CMDQ0_SIZE(x) ((x) << S_CMDQ0_SIZE)
125#define G_CMDQ0_SIZE(x) (((x) >> S_CMDQ0_SIZE) & M_CMDQ0_SIZE)
126
111#define A_SG_FL0SIZE 0x2c 127#define A_SG_FL0SIZE 0x2c
128
129#define S_FL0_SIZE 0
130#define M_FL0_SIZE 0x1ffff
131#define V_FL0_SIZE(x) ((x) << S_FL0_SIZE)
132#define G_FL0_SIZE(x) (((x) >> S_FL0_SIZE) & M_FL0_SIZE)
133
112#define A_SG_RSPSIZE 0x30 134#define A_SG_RSPSIZE 0x30
135
136#define S_RESPQ_SIZE 0
137#define M_RESPQ_SIZE 0x1ffff
138#define V_RESPQ_SIZE(x) ((x) << S_RESPQ_SIZE)
139#define G_RESPQ_SIZE(x) (((x) >> S_RESPQ_SIZE) & M_RESPQ_SIZE)
140
113#define A_SG_RSPBASELWR 0x34 141#define A_SG_RSPBASELWR 0x34
114#define A_SG_RSPBASEUPR 0x38 142#define A_SG_RSPBASEUPR 0x38
115#define A_SG_FLTHRESHOLD 0x3c 143#define A_SG_FLTHRESHOLD 0x3c
144
145#define S_FL_THRESHOLD 0
146#define M_FL_THRESHOLD 0xffff
147#define V_FL_THRESHOLD(x) ((x) << S_FL_THRESHOLD)
148#define G_FL_THRESHOLD(x) (((x) >> S_FL_THRESHOLD) & M_FL_THRESHOLD)
149
116#define A_SG_RSPQUEUECREDIT 0x40 150#define A_SG_RSPQUEUECREDIT 0x40
151
152#define S_RESPQ_CREDIT 0
153#define M_RESPQ_CREDIT 0x1ffff
154#define V_RESPQ_CREDIT(x) ((x) << S_RESPQ_CREDIT)
155#define G_RESPQ_CREDIT(x) (((x) >> S_RESPQ_CREDIT) & M_RESPQ_CREDIT)
156
117#define A_SG_SLEEPING 0x48 157#define A_SG_SLEEPING 0x48
158
159#define S_SLEEPING 0
160#define M_SLEEPING 0xffff
161#define V_SLEEPING(x) ((x) << S_SLEEPING)
162#define G_SLEEPING(x) (((x) >> S_SLEEPING) & M_SLEEPING)
163
118#define A_SG_INTRTIMER 0x4c 164#define A_SG_INTRTIMER 0x4c
165
166#define S_INTERRUPT_TIMER_COUNT 0
167#define M_INTERRUPT_TIMER_COUNT 0xffffff
168#define V_INTERRUPT_TIMER_COUNT(x) ((x) << S_INTERRUPT_TIMER_COUNT)
169#define G_INTERRUPT_TIMER_COUNT(x) (((x) >> S_INTERRUPT_TIMER_COUNT) & M_INTERRUPT_TIMER_COUNT)
170
171#define A_SG_CMD0PTR 0x50
172
173#define S_CMDQ0_POINTER 0
174#define M_CMDQ0_POINTER 0xffff
175#define V_CMDQ0_POINTER(x) ((x) << S_CMDQ0_POINTER)
176#define G_CMDQ0_POINTER(x) (((x) >> S_CMDQ0_POINTER) & M_CMDQ0_POINTER)
177
178#define S_CURRENT_GENERATION_BIT 16
179#define V_CURRENT_GENERATION_BIT(x) ((x) << S_CURRENT_GENERATION_BIT)
180#define F_CURRENT_GENERATION_BIT V_CURRENT_GENERATION_BIT(1U)
181
182#define A_SG_CMD1PTR 0x54
183
184#define S_CMDQ1_POINTER 0
185#define M_CMDQ1_POINTER 0xffff
186#define V_CMDQ1_POINTER(x) ((x) << S_CMDQ1_POINTER)
187#define G_CMDQ1_POINTER(x) (((x) >> S_CMDQ1_POINTER) & M_CMDQ1_POINTER)
188
189#define A_SG_FL0PTR 0x58
190
191#define S_FL0_POINTER 0
192#define M_FL0_POINTER 0xffff
193#define V_FL0_POINTER(x) ((x) << S_FL0_POINTER)
194#define G_FL0_POINTER(x) (((x) >> S_FL0_POINTER) & M_FL0_POINTER)
195
196#define A_SG_FL1PTR 0x5c
197
198#define S_FL1_POINTER 0
199#define M_FL1_POINTER 0xffff
200#define V_FL1_POINTER(x) ((x) << S_FL1_POINTER)
201#define G_FL1_POINTER(x) (((x) >> S_FL1_POINTER) & M_FL1_POINTER)
202
203#define A_SG_VERSION 0x6c
204
205#define S_DAY 0
206#define M_DAY 0x1f
207#define V_DAY(x) ((x) << S_DAY)
208#define G_DAY(x) (((x) >> S_DAY) & M_DAY)
209
210#define S_MONTH 5
211#define M_MONTH 0xf
212#define V_MONTH(x) ((x) << S_MONTH)
213#define G_MONTH(x) (((x) >> S_MONTH) & M_MONTH)
214
119#define A_SG_CMD1SIZE 0xb0 215#define A_SG_CMD1SIZE 0xb0
216
217#define S_CMDQ1_SIZE 0
218#define M_CMDQ1_SIZE 0x1ffff
219#define V_CMDQ1_SIZE(x) ((x) << S_CMDQ1_SIZE)
220#define G_CMDQ1_SIZE(x) (((x) >> S_CMDQ1_SIZE) & M_CMDQ1_SIZE)
221
120#define A_SG_FL1SIZE 0xb4 222#define A_SG_FL1SIZE 0xb4
223
224#define S_FL1_SIZE 0
225#define M_FL1_SIZE 0x1ffff
226#define V_FL1_SIZE(x) ((x) << S_FL1_SIZE)
227#define G_FL1_SIZE(x) (((x) >> S_FL1_SIZE) & M_FL1_SIZE)
228
121#define A_SG_INT_ENABLE 0xb8 229#define A_SG_INT_ENABLE 0xb8
122 230
123#define S_RESPQ_EXHAUSTED 0 231#define S_RESPQ_EXHAUSTED 0
@@ -144,21 +252,369 @@
144#define A_SG_RESPACCUTIMER 0xc0 252#define A_SG_RESPACCUTIMER 0xc0
145 253
146/* MC3 registers */ 254/* MC3 registers */
255#define A_MC3_CFG 0x100
256
257#define S_CLK_ENABLE 0
258#define V_CLK_ENABLE(x) ((x) << S_CLK_ENABLE)
259#define F_CLK_ENABLE V_CLK_ENABLE(1U)
147 260
148#define S_READY 1 261#define S_READY 1
149#define V_READY(x) ((x) << S_READY) 262#define V_READY(x) ((x) << S_READY)
150#define F_READY V_READY(1U) 263#define F_READY V_READY(1U)
151 264
152/* MC4 registers */ 265#define S_READ_TO_WRITE_DELAY 2
266#define M_READ_TO_WRITE_DELAY 0x7
267#define V_READ_TO_WRITE_DELAY(x) ((x) << S_READ_TO_WRITE_DELAY)
268#define G_READ_TO_WRITE_DELAY(x) (((x) >> S_READ_TO_WRITE_DELAY) & M_READ_TO_WRITE_DELAY)
269
270#define S_WRITE_TO_READ_DELAY 5
271#define M_WRITE_TO_READ_DELAY 0x7
272#define V_WRITE_TO_READ_DELAY(x) ((x) << S_WRITE_TO_READ_DELAY)
273#define G_WRITE_TO_READ_DELAY(x) (((x) >> S_WRITE_TO_READ_DELAY) & M_WRITE_TO_READ_DELAY)
153 274
275#define S_MC3_BANK_CYCLE 8
276#define M_MC3_BANK_CYCLE 0xf
277#define V_MC3_BANK_CYCLE(x) ((x) << S_MC3_BANK_CYCLE)
278#define G_MC3_BANK_CYCLE(x) (((x) >> S_MC3_BANK_CYCLE) & M_MC3_BANK_CYCLE)
279
280#define S_REFRESH_CYCLE 12
281#define M_REFRESH_CYCLE 0xf
282#define V_REFRESH_CYCLE(x) ((x) << S_REFRESH_CYCLE)
283#define G_REFRESH_CYCLE(x) (((x) >> S_REFRESH_CYCLE) & M_REFRESH_CYCLE)
284
285#define S_PRECHARGE_CYCLE 16
286#define M_PRECHARGE_CYCLE 0x3
287#define V_PRECHARGE_CYCLE(x) ((x) << S_PRECHARGE_CYCLE)
288#define G_PRECHARGE_CYCLE(x) (((x) >> S_PRECHARGE_CYCLE) & M_PRECHARGE_CYCLE)
289
290#define S_ACTIVE_TO_READ_WRITE_DELAY 18
291#define V_ACTIVE_TO_READ_WRITE_DELAY(x) ((x) << S_ACTIVE_TO_READ_WRITE_DELAY)
292#define F_ACTIVE_TO_READ_WRITE_DELAY V_ACTIVE_TO_READ_WRITE_DELAY(1U)
293
294#define S_ACTIVE_TO_PRECHARGE_DELAY 19
295#define M_ACTIVE_TO_PRECHARGE_DELAY 0x7
296#define V_ACTIVE_TO_PRECHARGE_DELAY(x) ((x) << S_ACTIVE_TO_PRECHARGE_DELAY)
297#define G_ACTIVE_TO_PRECHARGE_DELAY(x) (((x) >> S_ACTIVE_TO_PRECHARGE_DELAY) & M_ACTIVE_TO_PRECHARGE_DELAY)
298
299#define S_WRITE_RECOVERY_DELAY 22
300#define M_WRITE_RECOVERY_DELAY 0x3
301#define V_WRITE_RECOVERY_DELAY(x) ((x) << S_WRITE_RECOVERY_DELAY)
302#define G_WRITE_RECOVERY_DELAY(x) (((x) >> S_WRITE_RECOVERY_DELAY) & M_WRITE_RECOVERY_DELAY)
303
304#define S_DENSITY 24
305#define M_DENSITY 0x3
306#define V_DENSITY(x) ((x) << S_DENSITY)
307#define G_DENSITY(x) (((x) >> S_DENSITY) & M_DENSITY)
308
309#define S_ORGANIZATION 26
310#define V_ORGANIZATION(x) ((x) << S_ORGANIZATION)
311#define F_ORGANIZATION V_ORGANIZATION(1U)
312
313#define S_BANKS 27
314#define V_BANKS(x) ((x) << S_BANKS)
315#define F_BANKS V_BANKS(1U)
316
317#define S_UNREGISTERED 28
318#define V_UNREGISTERED(x) ((x) << S_UNREGISTERED)
319#define F_UNREGISTERED V_UNREGISTERED(1U)
320
321#define S_MC3_WIDTH 29
322#define M_MC3_WIDTH 0x3
323#define V_MC3_WIDTH(x) ((x) << S_MC3_WIDTH)
324#define G_MC3_WIDTH(x) (((x) >> S_MC3_WIDTH) & M_MC3_WIDTH)
325
326#define S_MC3_SLOW 31
327#define V_MC3_SLOW(x) ((x) << S_MC3_SLOW)
328#define F_MC3_SLOW V_MC3_SLOW(1U)
329
330#define A_MC3_MODE 0x104
331
332#define S_MC3_MODE 0
333#define M_MC3_MODE 0x3fff
334#define V_MC3_MODE(x) ((x) << S_MC3_MODE)
335#define G_MC3_MODE(x) (((x) >> S_MC3_MODE) & M_MC3_MODE)
336
337#define S_BUSY 31
338#define V_BUSY(x) ((x) << S_BUSY)
339#define F_BUSY V_BUSY(1U)
340
341#define A_MC3_EXT_MODE 0x108
342
343#define S_MC3_EXTENDED_MODE 0
344#define M_MC3_EXTENDED_MODE 0x3fff
345#define V_MC3_EXTENDED_MODE(x) ((x) << S_MC3_EXTENDED_MODE)
346#define G_MC3_EXTENDED_MODE(x) (((x) >> S_MC3_EXTENDED_MODE) & M_MC3_EXTENDED_MODE)
347
348#define A_MC3_PRECHARG 0x10c
349#define A_MC3_REFRESH 0x110
350
351#define S_REFRESH_ENABLE 0
352#define V_REFRESH_ENABLE(x) ((x) << S_REFRESH_ENABLE)
353#define F_REFRESH_ENABLE V_REFRESH_ENABLE(1U)
354
355#define S_REFRESH_DIVISOR 1
356#define M_REFRESH_DIVISOR 0x3fff
357#define V_REFRESH_DIVISOR(x) ((x) << S_REFRESH_DIVISOR)
358#define G_REFRESH_DIVISOR(x) (((x) >> S_REFRESH_DIVISOR) & M_REFRESH_DIVISOR)
359
360#define A_MC3_STROBE 0x114
361
362#define S_MASTER_DLL_RESET 0
363#define V_MASTER_DLL_RESET(x) ((x) << S_MASTER_DLL_RESET)
364#define F_MASTER_DLL_RESET V_MASTER_DLL_RESET(1U)
365
366#define S_MASTER_DLL_TAP_COUNT 1
367#define M_MASTER_DLL_TAP_COUNT 0xff
368#define V_MASTER_DLL_TAP_COUNT(x) ((x) << S_MASTER_DLL_TAP_COUNT)
369#define G_MASTER_DLL_TAP_COUNT(x) (((x) >> S_MASTER_DLL_TAP_COUNT) & M_MASTER_DLL_TAP_COUNT)
370
371#define S_MASTER_DLL_LOCKED 9
372#define V_MASTER_DLL_LOCKED(x) ((x) << S_MASTER_DLL_LOCKED)
373#define F_MASTER_DLL_LOCKED V_MASTER_DLL_LOCKED(1U)
374
375#define S_MASTER_DLL_MAX_TAP_COUNT 10
376#define V_MASTER_DLL_MAX_TAP_COUNT(x) ((x) << S_MASTER_DLL_MAX_TAP_COUNT)
377#define F_MASTER_DLL_MAX_TAP_COUNT V_MASTER_DLL_MAX_TAP_COUNT(1U)
378
379#define S_MASTER_DLL_TAP_COUNT_OFFSET 11
380#define M_MASTER_DLL_TAP_COUNT_OFFSET 0x3f
381#define V_MASTER_DLL_TAP_COUNT_OFFSET(x) ((x) << S_MASTER_DLL_TAP_COUNT_OFFSET)
382#define G_MASTER_DLL_TAP_COUNT_OFFSET(x) (((x) >> S_MASTER_DLL_TAP_COUNT_OFFSET) & M_MASTER_DLL_TAP_COUNT_OFFSET)
383
384#define S_SLAVE_DLL_RESET 11
385#define V_SLAVE_DLL_RESET(x) ((x) << S_SLAVE_DLL_RESET)
386#define F_SLAVE_DLL_RESET V_SLAVE_DLL_RESET(1U)
387
388#define S_SLAVE_DLL_DELTA 12
389#define M_SLAVE_DLL_DELTA 0xf
390#define V_SLAVE_DLL_DELTA(x) ((x) << S_SLAVE_DLL_DELTA)
391#define G_SLAVE_DLL_DELTA(x) (((x) >> S_SLAVE_DLL_DELTA) & M_SLAVE_DLL_DELTA)
392
393#define S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT 17
394#define M_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT 0x3f
395#define V_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT(x) ((x) << S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT)
396#define G_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT(x) (((x) >> S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT) & M_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT)
397
398#define S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE 23
399#define V_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE(x) ((x) << S_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE)
400#define F_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE V_SLAVE_DELAY_LINE_MANUAL_TAP_COUNT_ENABLE(1U)
401
402#define S_SLAVE_DELAY_LINE_TAP_COUNT 24
403#define M_SLAVE_DELAY_LINE_TAP_COUNT 0x3f
404#define V_SLAVE_DELAY_LINE_TAP_COUNT(x) ((x) << S_SLAVE_DELAY_LINE_TAP_COUNT)
405#define G_SLAVE_DELAY_LINE_TAP_COUNT(x) (((x) >> S_SLAVE_DELAY_LINE_TAP_COUNT) & M_SLAVE_DELAY_LINE_TAP_COUNT)
406
407#define A_MC3_ECC_CNTL 0x118
408
409#define S_ECC_GENERATION_ENABLE 0
410#define V_ECC_GENERATION_ENABLE(x) ((x) << S_ECC_GENERATION_ENABLE)
411#define F_ECC_GENERATION_ENABLE V_ECC_GENERATION_ENABLE(1U)
412
413#define S_ECC_CHECK_ENABLE 1
414#define V_ECC_CHECK_ENABLE(x) ((x) << S_ECC_CHECK_ENABLE)
415#define F_ECC_CHECK_ENABLE V_ECC_CHECK_ENABLE(1U)
416
417#define S_CORRECTABLE_ERROR_COUNT 2
418#define M_CORRECTABLE_ERROR_COUNT 0xff
419#define V_CORRECTABLE_ERROR_COUNT(x) ((x) << S_CORRECTABLE_ERROR_COUNT)
420#define G_CORRECTABLE_ERROR_COUNT(x) (((x) >> S_CORRECTABLE_ERROR_COUNT) & M_CORRECTABLE_ERROR_COUNT)
421
422#define S_UNCORRECTABLE_ERROR_COUNT 10
423#define M_UNCORRECTABLE_ERROR_COUNT 0xff
424#define V_UNCORRECTABLE_ERROR_COUNT(x) ((x) << S_UNCORRECTABLE_ERROR_COUNT)
425#define G_UNCORRECTABLE_ERROR_COUNT(x) (((x) >> S_UNCORRECTABLE_ERROR_COUNT) & M_UNCORRECTABLE_ERROR_COUNT)
426
427#define A_MC3_CE_ADDR 0x11c
428
429#define S_MC3_CE_ADDR 4
430#define M_MC3_CE_ADDR 0xfffffff
431#define V_MC3_CE_ADDR(x) ((x) << S_MC3_CE_ADDR)
432#define G_MC3_CE_ADDR(x) (((x) >> S_MC3_CE_ADDR) & M_MC3_CE_ADDR)
433
434#define A_MC3_CE_DATA0 0x120
435#define A_MC3_CE_DATA1 0x124
436#define A_MC3_CE_DATA2 0x128
437#define A_MC3_CE_DATA3 0x12c
438#define A_MC3_CE_DATA4 0x130
439#define A_MC3_UE_ADDR 0x134
440
441#define S_MC3_UE_ADDR 4
442#define M_MC3_UE_ADDR 0xfffffff
443#define V_MC3_UE_ADDR(x) ((x) << S_MC3_UE_ADDR)
444#define G_MC3_UE_ADDR(x) (((x) >> S_MC3_UE_ADDR) & M_MC3_UE_ADDR)
445
446#define A_MC3_UE_DATA0 0x138
447#define A_MC3_UE_DATA1 0x13c
448#define A_MC3_UE_DATA2 0x140
449#define A_MC3_UE_DATA3 0x144
450#define A_MC3_UE_DATA4 0x148
451#define A_MC3_BD_ADDR 0x14c
452#define A_MC3_BD_DATA0 0x150
453#define A_MC3_BD_DATA1 0x154
454#define A_MC3_BD_DATA2 0x158
455#define A_MC3_BD_DATA3 0x15c
456#define A_MC3_BD_DATA4 0x160
457#define A_MC3_BD_OP 0x164
458
459#define S_BACK_DOOR_OPERATION 0
460#define V_BACK_DOOR_OPERATION(x) ((x) << S_BACK_DOOR_OPERATION)
461#define F_BACK_DOOR_OPERATION V_BACK_DOOR_OPERATION(1U)
462
463#define A_MC3_BIST_ADDR_BEG 0x168
464#define A_MC3_BIST_ADDR_END 0x16c
465#define A_MC3_BIST_DATA 0x170
466#define A_MC3_BIST_OP 0x174
467
468#define S_OP 0
469#define V_OP(x) ((x) << S_OP)
470#define F_OP V_OP(1U)
471
472#define S_DATA_PATTERN 1
473#define M_DATA_PATTERN 0x3
474#define V_DATA_PATTERN(x) ((x) << S_DATA_PATTERN)
475#define G_DATA_PATTERN(x) (((x) >> S_DATA_PATTERN) & M_DATA_PATTERN)
476
477#define S_CONTINUOUS 3
478#define V_CONTINUOUS(x) ((x) << S_CONTINUOUS)
479#define F_CONTINUOUS V_CONTINUOUS(1U)
480
481#define A_MC3_INT_ENABLE 0x178
482
483#define S_MC3_CORR_ERR 0
484#define V_MC3_CORR_ERR(x) ((x) << S_MC3_CORR_ERR)
485#define F_MC3_CORR_ERR V_MC3_CORR_ERR(1U)
486
487#define S_MC3_UNCORR_ERR 1
488#define V_MC3_UNCORR_ERR(x) ((x) << S_MC3_UNCORR_ERR)
489#define F_MC3_UNCORR_ERR V_MC3_UNCORR_ERR(1U)
490
491#define S_MC3_PARITY_ERR 2
492#define M_MC3_PARITY_ERR 0xff
493#define V_MC3_PARITY_ERR(x) ((x) << S_MC3_PARITY_ERR)
494#define G_MC3_PARITY_ERR(x) (((x) >> S_MC3_PARITY_ERR) & M_MC3_PARITY_ERR)
495
496#define S_MC3_ADDR_ERR 10
497#define V_MC3_ADDR_ERR(x) ((x) << S_MC3_ADDR_ERR)
498#define F_MC3_ADDR_ERR V_MC3_ADDR_ERR(1U)
499
500#define A_MC3_INT_CAUSE 0x17c
501
502/* MC4 registers */
154#define A_MC4_CFG 0x180 503#define A_MC4_CFG 0x180
504
505#define S_POWER_UP 0
506#define V_POWER_UP(x) ((x) << S_POWER_UP)
507#define F_POWER_UP V_POWER_UP(1U)
508
509#define S_MC4_BANK_CYCLE 8
510#define M_MC4_BANK_CYCLE 0x7
511#define V_MC4_BANK_CYCLE(x) ((x) << S_MC4_BANK_CYCLE)
512#define G_MC4_BANK_CYCLE(x) (((x) >> S_MC4_BANK_CYCLE) & M_MC4_BANK_CYCLE)
513
514#define S_MC4_NARROW 24
515#define V_MC4_NARROW(x) ((x) << S_MC4_NARROW)
516#define F_MC4_NARROW V_MC4_NARROW(1U)
517
155#define S_MC4_SLOW 25 518#define S_MC4_SLOW 25
156#define V_MC4_SLOW(x) ((x) << S_MC4_SLOW) 519#define V_MC4_SLOW(x) ((x) << S_MC4_SLOW)
157#define F_MC4_SLOW V_MC4_SLOW(1U) 520#define F_MC4_SLOW V_MC4_SLOW(1U)
158 521
159/* TPI registers */ 522#define S_MC4A_WIDTH 24
523#define M_MC4A_WIDTH 0x3
524#define V_MC4A_WIDTH(x) ((x) << S_MC4A_WIDTH)
525#define G_MC4A_WIDTH(x) (((x) >> S_MC4A_WIDTH) & M_MC4A_WIDTH)
526
527#define S_MC4A_SLOW 26
528#define V_MC4A_SLOW(x) ((x) << S_MC4A_SLOW)
529#define F_MC4A_SLOW V_MC4A_SLOW(1U)
530
531#define A_MC4_MODE 0x184
532
533#define S_MC4_MODE 0
534#define M_MC4_MODE 0x7fff
535#define V_MC4_MODE(x) ((x) << S_MC4_MODE)
536#define G_MC4_MODE(x) (((x) >> S_MC4_MODE) & M_MC4_MODE)
537
538#define A_MC4_EXT_MODE 0x188
539
540#define S_MC4_EXTENDED_MODE 0
541#define M_MC4_EXTENDED_MODE 0x7fff
542#define V_MC4_EXTENDED_MODE(x) ((x) << S_MC4_EXTENDED_MODE)
543#define G_MC4_EXTENDED_MODE(x) (((x) >> S_MC4_EXTENDED_MODE) & M_MC4_EXTENDED_MODE)
544
545#define A_MC4_REFRESH 0x190
546#define A_MC4_STROBE 0x194
547#define A_MC4_ECC_CNTL 0x198
548#define A_MC4_CE_ADDR 0x19c
549
550#define S_MC4_CE_ADDR 4
551#define M_MC4_CE_ADDR 0xffffff
552#define V_MC4_CE_ADDR(x) ((x) << S_MC4_CE_ADDR)
553#define G_MC4_CE_ADDR(x) (((x) >> S_MC4_CE_ADDR) & M_MC4_CE_ADDR)
554
555#define A_MC4_CE_DATA0 0x1a0
556#define A_MC4_CE_DATA1 0x1a4
557#define A_MC4_CE_DATA2 0x1a8
558#define A_MC4_CE_DATA3 0x1ac
559#define A_MC4_CE_DATA4 0x1b0
560#define A_MC4_UE_ADDR 0x1b4
561
562#define S_MC4_UE_ADDR 4
563#define M_MC4_UE_ADDR 0xffffff
564#define V_MC4_UE_ADDR(x) ((x) << S_MC4_UE_ADDR)
565#define G_MC4_UE_ADDR(x) (((x) >> S_MC4_UE_ADDR) & M_MC4_UE_ADDR)
566
567#define A_MC4_UE_DATA0 0x1b8
568#define A_MC4_UE_DATA1 0x1bc
569#define A_MC4_UE_DATA2 0x1c0
570#define A_MC4_UE_DATA3 0x1c4
571#define A_MC4_UE_DATA4 0x1c8
572#define A_MC4_BD_ADDR 0x1cc
573
574#define S_MC4_BACK_DOOR_ADDR 0
575#define M_MC4_BACK_DOOR_ADDR 0xfffffff
576#define V_MC4_BACK_DOOR_ADDR(x) ((x) << S_MC4_BACK_DOOR_ADDR)
577#define G_MC4_BACK_DOOR_ADDR(x) (((x) >> S_MC4_BACK_DOOR_ADDR) & M_MC4_BACK_DOOR_ADDR)
578
579#define A_MC4_BD_DATA0 0x1d0
580#define A_MC4_BD_DATA1 0x1d4
581#define A_MC4_BD_DATA2 0x1d8
582#define A_MC4_BD_DATA3 0x1dc
583#define A_MC4_BD_DATA4 0x1e0
584#define A_MC4_BD_OP 0x1e4
585
586#define S_OPERATION 0
587#define V_OPERATION(x) ((x) << S_OPERATION)
588#define F_OPERATION V_OPERATION(1U)
589
590#define A_MC4_BIST_ADDR_BEG 0x1e8
591#define A_MC4_BIST_ADDR_END 0x1ec
592#define A_MC4_BIST_DATA 0x1f0
593#define A_MC4_BIST_OP 0x1f4
594#define A_MC4_INT_ENABLE 0x1f8
595
596#define S_MC4_CORR_ERR 0
597#define V_MC4_CORR_ERR(x) ((x) << S_MC4_CORR_ERR)
598#define F_MC4_CORR_ERR V_MC4_CORR_ERR(1U)
599
600#define S_MC4_UNCORR_ERR 1
601#define V_MC4_UNCORR_ERR(x) ((x) << S_MC4_UNCORR_ERR)
602#define F_MC4_UNCORR_ERR V_MC4_UNCORR_ERR(1U)
603
604#define S_MC4_ADDR_ERR 2
605#define V_MC4_ADDR_ERR(x) ((x) << S_MC4_ADDR_ERR)
606#define F_MC4_ADDR_ERR V_MC4_ADDR_ERR(1U)
607
608#define A_MC4_INT_CAUSE 0x1fc
160 609
610/* TPI registers */
161#define A_TPI_ADDR 0x280 611#define A_TPI_ADDR 0x280
612
613#define S_TPI_ADDRESS 0
614#define M_TPI_ADDRESS 0xffffff
615#define V_TPI_ADDRESS(x) ((x) << S_TPI_ADDRESS)
616#define G_TPI_ADDRESS(x) (((x) >> S_TPI_ADDRESS) & M_TPI_ADDRESS)
617
162#define A_TPI_WR_DATA 0x284 618#define A_TPI_WR_DATA 0x284
163#define A_TPI_RD_DATA 0x288 619#define A_TPI_RD_DATA 0x288
164#define A_TPI_CSR 0x28c 620#define A_TPI_CSR 0x28c
@@ -171,6 +627,10 @@
171#define V_TPIRDY(x) ((x) << S_TPIRDY) 627#define V_TPIRDY(x) ((x) << S_TPIRDY)
172#define F_TPIRDY V_TPIRDY(1U) 628#define F_TPIRDY V_TPIRDY(1U)
173 629
630#define S_INT_DIR 31
631#define V_INT_DIR(x) ((x) << S_INT_DIR)
632#define F_INT_DIR V_INT_DIR(1U)
633
174#define A_TPI_PAR 0x29c 634#define A_TPI_PAR 0x29c
175 635
176#define S_TPIPAR 0 636#define S_TPIPAR 0
@@ -178,14 +638,26 @@
178#define V_TPIPAR(x) ((x) << S_TPIPAR) 638#define V_TPIPAR(x) ((x) << S_TPIPAR)
179#define G_TPIPAR(x) (((x) >> S_TPIPAR) & M_TPIPAR) 639#define G_TPIPAR(x) (((x) >> S_TPIPAR) & M_TPIPAR)
180 640
181/* TP registers */
182 641
642/* TP registers */
183#define A_TP_IN_CONFIG 0x300 643#define A_TP_IN_CONFIG 0x300
184 644
645#define S_TP_IN_CSPI_TUNNEL 0
646#define V_TP_IN_CSPI_TUNNEL(x) ((x) << S_TP_IN_CSPI_TUNNEL)
647#define F_TP_IN_CSPI_TUNNEL V_TP_IN_CSPI_TUNNEL(1U)
648
649#define S_TP_IN_CSPI_ETHERNET 1
650#define V_TP_IN_CSPI_ETHERNET(x) ((x) << S_TP_IN_CSPI_ETHERNET)
651#define F_TP_IN_CSPI_ETHERNET V_TP_IN_CSPI_ETHERNET(1U)
652
185#define S_TP_IN_CSPI_CPL 3 653#define S_TP_IN_CSPI_CPL 3
186#define V_TP_IN_CSPI_CPL(x) ((x) << S_TP_IN_CSPI_CPL) 654#define V_TP_IN_CSPI_CPL(x) ((x) << S_TP_IN_CSPI_CPL)
187#define F_TP_IN_CSPI_CPL V_TP_IN_CSPI_CPL(1U) 655#define F_TP_IN_CSPI_CPL V_TP_IN_CSPI_CPL(1U)
188 656
657#define S_TP_IN_CSPI_POS 4
658#define V_TP_IN_CSPI_POS(x) ((x) << S_TP_IN_CSPI_POS)
659#define F_TP_IN_CSPI_POS V_TP_IN_CSPI_POS(1U)
660
189#define S_TP_IN_CSPI_CHECK_IP_CSUM 5 661#define S_TP_IN_CSPI_CHECK_IP_CSUM 5
190#define V_TP_IN_CSPI_CHECK_IP_CSUM(x) ((x) << S_TP_IN_CSPI_CHECK_IP_CSUM) 662#define V_TP_IN_CSPI_CHECK_IP_CSUM(x) ((x) << S_TP_IN_CSPI_CHECK_IP_CSUM)
191#define F_TP_IN_CSPI_CHECK_IP_CSUM V_TP_IN_CSPI_CHECK_IP_CSUM(1U) 663#define F_TP_IN_CSPI_CHECK_IP_CSUM V_TP_IN_CSPI_CHECK_IP_CSUM(1U)
@@ -194,10 +666,22 @@
194#define V_TP_IN_CSPI_CHECK_TCP_CSUM(x) ((x) << S_TP_IN_CSPI_CHECK_TCP_CSUM) 666#define V_TP_IN_CSPI_CHECK_TCP_CSUM(x) ((x) << S_TP_IN_CSPI_CHECK_TCP_CSUM)
195#define F_TP_IN_CSPI_CHECK_TCP_CSUM V_TP_IN_CSPI_CHECK_TCP_CSUM(1U) 667#define F_TP_IN_CSPI_CHECK_TCP_CSUM V_TP_IN_CSPI_CHECK_TCP_CSUM(1U)
196 668
669#define S_TP_IN_ESPI_TUNNEL 7
670#define V_TP_IN_ESPI_TUNNEL(x) ((x) << S_TP_IN_ESPI_TUNNEL)
671#define F_TP_IN_ESPI_TUNNEL V_TP_IN_ESPI_TUNNEL(1U)
672
197#define S_TP_IN_ESPI_ETHERNET 8 673#define S_TP_IN_ESPI_ETHERNET 8
198#define V_TP_IN_ESPI_ETHERNET(x) ((x) << S_TP_IN_ESPI_ETHERNET) 674#define V_TP_IN_ESPI_ETHERNET(x) ((x) << S_TP_IN_ESPI_ETHERNET)
199#define F_TP_IN_ESPI_ETHERNET V_TP_IN_ESPI_ETHERNET(1U) 675#define F_TP_IN_ESPI_ETHERNET V_TP_IN_ESPI_ETHERNET(1U)
200 676
677#define S_TP_IN_ESPI_CPL 10
678#define V_TP_IN_ESPI_CPL(x) ((x) << S_TP_IN_ESPI_CPL)
679#define F_TP_IN_ESPI_CPL V_TP_IN_ESPI_CPL(1U)
680
681#define S_TP_IN_ESPI_POS 11
682#define V_TP_IN_ESPI_POS(x) ((x) << S_TP_IN_ESPI_POS)
683#define F_TP_IN_ESPI_POS V_TP_IN_ESPI_POS(1U)
684
201#define S_TP_IN_ESPI_CHECK_IP_CSUM 12 685#define S_TP_IN_ESPI_CHECK_IP_CSUM 12
202#define V_TP_IN_ESPI_CHECK_IP_CSUM(x) ((x) << S_TP_IN_ESPI_CHECK_IP_CSUM) 686#define V_TP_IN_ESPI_CHECK_IP_CSUM(x) ((x) << S_TP_IN_ESPI_CHECK_IP_CSUM)
203#define F_TP_IN_ESPI_CHECK_IP_CSUM V_TP_IN_ESPI_CHECK_IP_CSUM(1U) 687#define F_TP_IN_ESPI_CHECK_IP_CSUM V_TP_IN_ESPI_CHECK_IP_CSUM(1U)
@@ -212,14 +696,42 @@
212 696
213#define A_TP_OUT_CONFIG 0x304 697#define A_TP_OUT_CONFIG 0x304
214 698
699#define S_TP_OUT_C_ETH 0
700#define V_TP_OUT_C_ETH(x) ((x) << S_TP_OUT_C_ETH)
701#define F_TP_OUT_C_ETH V_TP_OUT_C_ETH(1U)
702
215#define S_TP_OUT_CSPI_CPL 2 703#define S_TP_OUT_CSPI_CPL 2
216#define V_TP_OUT_CSPI_CPL(x) ((x) << S_TP_OUT_CSPI_CPL) 704#define V_TP_OUT_CSPI_CPL(x) ((x) << S_TP_OUT_CSPI_CPL)
217#define F_TP_OUT_CSPI_CPL V_TP_OUT_CSPI_CPL(1U) 705#define F_TP_OUT_CSPI_CPL V_TP_OUT_CSPI_CPL(1U)
218 706
707#define S_TP_OUT_CSPI_POS 3
708#define V_TP_OUT_CSPI_POS(x) ((x) << S_TP_OUT_CSPI_POS)
709#define F_TP_OUT_CSPI_POS V_TP_OUT_CSPI_POS(1U)
710
711#define S_TP_OUT_CSPI_GENERATE_IP_CSUM 4
712#define V_TP_OUT_CSPI_GENERATE_IP_CSUM(x) ((x) << S_TP_OUT_CSPI_GENERATE_IP_CSUM)
713#define F_TP_OUT_CSPI_GENERATE_IP_CSUM V_TP_OUT_CSPI_GENERATE_IP_CSUM(1U)
714
715#define S_TP_OUT_CSPI_GENERATE_TCP_CSUM 5
716#define V_TP_OUT_CSPI_GENERATE_TCP_CSUM(x) ((x) << S_TP_OUT_CSPI_GENERATE_TCP_CSUM)
717#define F_TP_OUT_CSPI_GENERATE_TCP_CSUM V_TP_OUT_CSPI_GENERATE_TCP_CSUM(1U)
718
219#define S_TP_OUT_ESPI_ETHERNET 6 719#define S_TP_OUT_ESPI_ETHERNET 6
220#define V_TP_OUT_ESPI_ETHERNET(x) ((x) << S_TP_OUT_ESPI_ETHERNET) 720#define V_TP_OUT_ESPI_ETHERNET(x) ((x) << S_TP_OUT_ESPI_ETHERNET)
221#define F_TP_OUT_ESPI_ETHERNET V_TP_OUT_ESPI_ETHERNET(1U) 721#define F_TP_OUT_ESPI_ETHERNET V_TP_OUT_ESPI_ETHERNET(1U)
222 722
723#define S_TP_OUT_ESPI_TAG_ETHERNET 7
724#define V_TP_OUT_ESPI_TAG_ETHERNET(x) ((x) << S_TP_OUT_ESPI_TAG_ETHERNET)
725#define F_TP_OUT_ESPI_TAG_ETHERNET V_TP_OUT_ESPI_TAG_ETHERNET(1U)
726
727#define S_TP_OUT_ESPI_CPL 8
728#define V_TP_OUT_ESPI_CPL(x) ((x) << S_TP_OUT_ESPI_CPL)
729#define F_TP_OUT_ESPI_CPL V_TP_OUT_ESPI_CPL(1U)
730
731#define S_TP_OUT_ESPI_POS 9
732#define V_TP_OUT_ESPI_POS(x) ((x) << S_TP_OUT_ESPI_POS)
733#define F_TP_OUT_ESPI_POS V_TP_OUT_ESPI_POS(1U)
734
223#define S_TP_OUT_ESPI_GENERATE_IP_CSUM 10 735#define S_TP_OUT_ESPI_GENERATE_IP_CSUM 10
224#define V_TP_OUT_ESPI_GENERATE_IP_CSUM(x) ((x) << S_TP_OUT_ESPI_GENERATE_IP_CSUM) 736#define V_TP_OUT_ESPI_GENERATE_IP_CSUM(x) ((x) << S_TP_OUT_ESPI_GENERATE_IP_CSUM)
225#define F_TP_OUT_ESPI_GENERATE_IP_CSUM V_TP_OUT_ESPI_GENERATE_IP_CSUM(1U) 737#define F_TP_OUT_ESPI_GENERATE_IP_CSUM V_TP_OUT_ESPI_GENERATE_IP_CSUM(1U)
@@ -233,6 +745,16 @@
233#define S_IP_TTL 0 745#define S_IP_TTL 0
234#define M_IP_TTL 0xff 746#define M_IP_TTL 0xff
235#define V_IP_TTL(x) ((x) << S_IP_TTL) 747#define V_IP_TTL(x) ((x) << S_IP_TTL)
748#define G_IP_TTL(x) (((x) >> S_IP_TTL) & M_IP_TTL)
749
750#define S_TCAM_SERVER_REGION_USAGE 8
751#define M_TCAM_SERVER_REGION_USAGE 0x3
752#define V_TCAM_SERVER_REGION_USAGE(x) ((x) << S_TCAM_SERVER_REGION_USAGE)
753#define G_TCAM_SERVER_REGION_USAGE(x) (((x) >> S_TCAM_SERVER_REGION_USAGE) & M_TCAM_SERVER_REGION_USAGE)
754
755#define S_QOS_MAPPING 10
756#define V_QOS_MAPPING(x) ((x) << S_QOS_MAPPING)
757#define F_QOS_MAPPING V_QOS_MAPPING(1U)
236 758
237#define S_TCP_CSUM 11 759#define S_TCP_CSUM 11
238#define V_TCP_CSUM(x) ((x) << S_TCP_CSUM) 760#define V_TCP_CSUM(x) ((x) << S_TCP_CSUM)
@@ -246,31 +768,476 @@
246#define V_IP_CSUM(x) ((x) << S_IP_CSUM) 768#define V_IP_CSUM(x) ((x) << S_IP_CSUM)
247#define F_IP_CSUM V_IP_CSUM(1U) 769#define F_IP_CSUM V_IP_CSUM(1U)
248 770
771#define S_IP_ID_SPLIT 14
772#define V_IP_ID_SPLIT(x) ((x) << S_IP_ID_SPLIT)
773#define F_IP_ID_SPLIT V_IP_ID_SPLIT(1U)
774
249#define S_PATH_MTU 15 775#define S_PATH_MTU 15
250#define V_PATH_MTU(x) ((x) << S_PATH_MTU) 776#define V_PATH_MTU(x) ((x) << S_PATH_MTU)
251#define F_PATH_MTU V_PATH_MTU(1U) 777#define F_PATH_MTU V_PATH_MTU(1U)
252 778
253#define S_5TUPLE_LOOKUP 17 779#define S_5TUPLE_LOOKUP 17
780#define M_5TUPLE_LOOKUP 0x3
254#define V_5TUPLE_LOOKUP(x) ((x) << S_5TUPLE_LOOKUP) 781#define V_5TUPLE_LOOKUP(x) ((x) << S_5TUPLE_LOOKUP)
782#define G_5TUPLE_LOOKUP(x) (((x) >> S_5TUPLE_LOOKUP) & M_5TUPLE_LOOKUP)
783
784#define S_IP_FRAGMENT_DROP 19
785#define V_IP_FRAGMENT_DROP(x) ((x) << S_IP_FRAGMENT_DROP)
786#define F_IP_FRAGMENT_DROP V_IP_FRAGMENT_DROP(1U)
787
788#define S_PING_DROP 20
789#define V_PING_DROP(x) ((x) << S_PING_DROP)
790#define F_PING_DROP V_PING_DROP(1U)
791
792#define S_PROTECT_MODE 21
793#define V_PROTECT_MODE(x) ((x) << S_PROTECT_MODE)
794#define F_PROTECT_MODE V_PROTECT_MODE(1U)
795
796#define S_SYN_COOKIE_ALGORITHM 22
797#define V_SYN_COOKIE_ALGORITHM(x) ((x) << S_SYN_COOKIE_ALGORITHM)
798#define F_SYN_COOKIE_ALGORITHM V_SYN_COOKIE_ALGORITHM(1U)
799
800#define S_ATTACK_FILTER 23
801#define V_ATTACK_FILTER(x) ((x) << S_ATTACK_FILTER)
802#define F_ATTACK_FILTER V_ATTACK_FILTER(1U)
803
804#define S_INTERFACE_TYPE 24
805#define V_INTERFACE_TYPE(x) ((x) << S_INTERFACE_TYPE)
806#define F_INTERFACE_TYPE V_INTERFACE_TYPE(1U)
807
808#define S_DISABLE_RX_FLOW_CONTROL 25
809#define V_DISABLE_RX_FLOW_CONTROL(x) ((x) << S_DISABLE_RX_FLOW_CONTROL)
810#define F_DISABLE_RX_FLOW_CONTROL V_DISABLE_RX_FLOW_CONTROL(1U)
255 811
256#define S_SYN_COOKIE_PARAMETER 26 812#define S_SYN_COOKIE_PARAMETER 26
813#define M_SYN_COOKIE_PARAMETER 0x3f
257#define V_SYN_COOKIE_PARAMETER(x) ((x) << S_SYN_COOKIE_PARAMETER) 814#define V_SYN_COOKIE_PARAMETER(x) ((x) << S_SYN_COOKIE_PARAMETER)
815#define G_SYN_COOKIE_PARAMETER(x) (((x) >> S_SYN_COOKIE_PARAMETER) & M_SYN_COOKIE_PARAMETER)
816
817#define A_TP_GLOBAL_RX_CREDITS 0x30c
818#define A_TP_CM_SIZE 0x310
819#define A_TP_CM_MM_BASE 0x314
820
821#define S_CM_MEMMGR_BASE 0
822#define M_CM_MEMMGR_BASE 0xfffffff
823#define V_CM_MEMMGR_BASE(x) ((x) << S_CM_MEMMGR_BASE)
824#define G_CM_MEMMGR_BASE(x) (((x) >> S_CM_MEMMGR_BASE) & M_CM_MEMMGR_BASE)
825
826#define A_TP_CM_TIMER_BASE 0x318
827
828#define S_CM_TIMER_BASE 0
829#define M_CM_TIMER_BASE 0xfffffff
830#define V_CM_TIMER_BASE(x) ((x) << S_CM_TIMER_BASE)
831#define G_CM_TIMER_BASE(x) (((x) >> S_CM_TIMER_BASE) & M_CM_TIMER_BASE)
832
833#define A_TP_PM_SIZE 0x31c
834#define A_TP_PM_TX_BASE 0x320
835#define A_TP_PM_DEFRAG_BASE 0x324
836#define A_TP_PM_RX_BASE 0x328
837#define A_TP_PM_RX_PG_SIZE 0x32c
838#define A_TP_PM_RX_MAX_PGS 0x330
839#define A_TP_PM_TX_PG_SIZE 0x334
840#define A_TP_PM_TX_MAX_PGS 0x338
841#define A_TP_TCP_OPTIONS 0x340
842
843#define S_TIMESTAMP 0
844#define M_TIMESTAMP 0x3
845#define V_TIMESTAMP(x) ((x) << S_TIMESTAMP)
846#define G_TIMESTAMP(x) (((x) >> S_TIMESTAMP) & M_TIMESTAMP)
847
848#define S_WINDOW_SCALE 2
849#define M_WINDOW_SCALE 0x3
850#define V_WINDOW_SCALE(x) ((x) << S_WINDOW_SCALE)
851#define G_WINDOW_SCALE(x) (((x) >> S_WINDOW_SCALE) & M_WINDOW_SCALE)
852
853#define S_SACK 4
854#define M_SACK 0x3
855#define V_SACK(x) ((x) << S_SACK)
856#define G_SACK(x) (((x) >> S_SACK) & M_SACK)
857
858#define S_ECN 6
859#define M_ECN 0x3
860#define V_ECN(x) ((x) << S_ECN)
861#define G_ECN(x) (((x) >> S_ECN) & M_ECN)
862
863#define S_SACK_ALGORITHM 8
864#define M_SACK_ALGORITHM 0x3
865#define V_SACK_ALGORITHM(x) ((x) << S_SACK_ALGORITHM)
866#define G_SACK_ALGORITHM(x) (((x) >> S_SACK_ALGORITHM) & M_SACK_ALGORITHM)
867
868#define S_MSS 10
869#define V_MSS(x) ((x) << S_MSS)
870#define F_MSS V_MSS(1U)
871
872#define S_DEFAULT_PEER_MSS 16
873#define M_DEFAULT_PEER_MSS 0xffff
874#define V_DEFAULT_PEER_MSS(x) ((x) << S_DEFAULT_PEER_MSS)
875#define G_DEFAULT_PEER_MSS(x) (((x) >> S_DEFAULT_PEER_MSS) & M_DEFAULT_PEER_MSS)
876
877#define A_TP_DACK_CONFIG 0x344
878
879#define S_DACK_MODE 0
880#define V_DACK_MODE(x) ((x) << S_DACK_MODE)
881#define F_DACK_MODE V_DACK_MODE(1U)
882
883#define S_DACK_AUTO_MGMT 1
884#define V_DACK_AUTO_MGMT(x) ((x) << S_DACK_AUTO_MGMT)
885#define F_DACK_AUTO_MGMT V_DACK_AUTO_MGMT(1U)
886
887#define S_DACK_AUTO_CAREFUL 2
888#define V_DACK_AUTO_CAREFUL(x) ((x) << S_DACK_AUTO_CAREFUL)
889#define F_DACK_AUTO_CAREFUL V_DACK_AUTO_CAREFUL(1U)
890
891#define S_DACK_MSS_SELECTOR 3
892#define M_DACK_MSS_SELECTOR 0x3
893#define V_DACK_MSS_SELECTOR(x) ((x) << S_DACK_MSS_SELECTOR)
894#define G_DACK_MSS_SELECTOR(x) (((x) >> S_DACK_MSS_SELECTOR) & M_DACK_MSS_SELECTOR)
895
896#define S_DACK_BYTE_THRESHOLD 5
897#define M_DACK_BYTE_THRESHOLD 0xfffff
898#define V_DACK_BYTE_THRESHOLD(x) ((x) << S_DACK_BYTE_THRESHOLD)
899#define G_DACK_BYTE_THRESHOLD(x) (((x) >> S_DACK_BYTE_THRESHOLD) & M_DACK_BYTE_THRESHOLD)
258 900
259#define A_TP_PC_CONFIG 0x348 901#define A_TP_PC_CONFIG 0x348
902
903#define S_TP_ACCESS_LATENCY 0
904#define M_TP_ACCESS_LATENCY 0xf
905#define V_TP_ACCESS_LATENCY(x) ((x) << S_TP_ACCESS_LATENCY)
906#define G_TP_ACCESS_LATENCY(x) (((x) >> S_TP_ACCESS_LATENCY) & M_TP_ACCESS_LATENCY)
907
908#define S_HELD_FIN_DISABLE 4
909#define V_HELD_FIN_DISABLE(x) ((x) << S_HELD_FIN_DISABLE)
910#define F_HELD_FIN_DISABLE V_HELD_FIN_DISABLE(1U)
911
912#define S_DDP_FC_ENABLE 5
913#define V_DDP_FC_ENABLE(x) ((x) << S_DDP_FC_ENABLE)
914#define F_DDP_FC_ENABLE V_DDP_FC_ENABLE(1U)
915
916#define S_RDMA_ERR_ENABLE 6
917#define V_RDMA_ERR_ENABLE(x) ((x) << S_RDMA_ERR_ENABLE)
918#define F_RDMA_ERR_ENABLE V_RDMA_ERR_ENABLE(1U)
919
920#define S_FAST_PDU_DELIVERY 7
921#define V_FAST_PDU_DELIVERY(x) ((x) << S_FAST_PDU_DELIVERY)
922#define F_FAST_PDU_DELIVERY V_FAST_PDU_DELIVERY(1U)
923
924#define S_CLEAR_FIN 8
925#define V_CLEAR_FIN(x) ((x) << S_CLEAR_FIN)
926#define F_CLEAR_FIN V_CLEAR_FIN(1U)
927
260#define S_DIS_TX_FILL_WIN_PUSH 12 928#define S_DIS_TX_FILL_WIN_PUSH 12
261#define V_DIS_TX_FILL_WIN_PUSH(x) ((x) << S_DIS_TX_FILL_WIN_PUSH) 929#define V_DIS_TX_FILL_WIN_PUSH(x) ((x) << S_DIS_TX_FILL_WIN_PUSH)
262#define F_DIS_TX_FILL_WIN_PUSH V_DIS_TX_FILL_WIN_PUSH(1U) 930#define F_DIS_TX_FILL_WIN_PUSH V_DIS_TX_FILL_WIN_PUSH(1U)
263 931
264#define S_TP_PC_REV 30 932#define S_TP_PC_REV 30
265#define M_TP_PC_REV 0x3 933#define M_TP_PC_REV 0x3
934#define V_TP_PC_REV(x) ((x) << S_TP_PC_REV)
266#define G_TP_PC_REV(x) (((x) >> S_TP_PC_REV) & M_TP_PC_REV) 935#define G_TP_PC_REV(x) (((x) >> S_TP_PC_REV) & M_TP_PC_REV)
936
937#define A_TP_BACKOFF0 0x350
938
939#define S_ELEMENT0 0
940#define M_ELEMENT0 0xff
941#define V_ELEMENT0(x) ((x) << S_ELEMENT0)
942#define G_ELEMENT0(x) (((x) >> S_ELEMENT0) & M_ELEMENT0)
943
944#define S_ELEMENT1 8
945#define M_ELEMENT1 0xff
946#define V_ELEMENT1(x) ((x) << S_ELEMENT1)
947#define G_ELEMENT1(x) (((x) >> S_ELEMENT1) & M_ELEMENT1)
948
949#define S_ELEMENT2 16
950#define M_ELEMENT2 0xff
951#define V_ELEMENT2(x) ((x) << S_ELEMENT2)
952#define G_ELEMENT2(x) (((x) >> S_ELEMENT2) & M_ELEMENT2)
953
954#define S_ELEMENT3 24
955#define M_ELEMENT3 0xff
956#define V_ELEMENT3(x) ((x) << S_ELEMENT3)
957#define G_ELEMENT3(x) (((x) >> S_ELEMENT3) & M_ELEMENT3)
958
959#define A_TP_BACKOFF1 0x354
960#define A_TP_BACKOFF2 0x358
961#define A_TP_BACKOFF3 0x35c
962#define A_TP_PARA_REG0 0x360
963
964#define S_VAR_MULT 0
965#define M_VAR_MULT 0xf
966#define V_VAR_MULT(x) ((x) << S_VAR_MULT)
967#define G_VAR_MULT(x) (((x) >> S_VAR_MULT) & M_VAR_MULT)
968
969#define S_VAR_GAIN 4
970#define M_VAR_GAIN 0xf
971#define V_VAR_GAIN(x) ((x) << S_VAR_GAIN)
972#define G_VAR_GAIN(x) (((x) >> S_VAR_GAIN) & M_VAR_GAIN)
973
974#define S_SRTT_GAIN 8
975#define M_SRTT_GAIN 0xf
976#define V_SRTT_GAIN(x) ((x) << S_SRTT_GAIN)
977#define G_SRTT_GAIN(x) (((x) >> S_SRTT_GAIN) & M_SRTT_GAIN)
978
979#define S_RTTVAR_INIT 12
980#define M_RTTVAR_INIT 0xf
981#define V_RTTVAR_INIT(x) ((x) << S_RTTVAR_INIT)
982#define G_RTTVAR_INIT(x) (((x) >> S_RTTVAR_INIT) & M_RTTVAR_INIT)
983
984#define S_DUP_THRESH 20
985#define M_DUP_THRESH 0xf
986#define V_DUP_THRESH(x) ((x) << S_DUP_THRESH)
987#define G_DUP_THRESH(x) (((x) >> S_DUP_THRESH) & M_DUP_THRESH)
988
989#define S_INIT_CONG_WIN 24
990#define M_INIT_CONG_WIN 0x7
991#define V_INIT_CONG_WIN(x) ((x) << S_INIT_CONG_WIN)
992#define G_INIT_CONG_WIN(x) (((x) >> S_INIT_CONG_WIN) & M_INIT_CONG_WIN)
993
994#define A_TP_PARA_REG1 0x364
995
996#define S_INITIAL_SLOW_START_THRESHOLD 0
997#define M_INITIAL_SLOW_START_THRESHOLD 0xffff
998#define V_INITIAL_SLOW_START_THRESHOLD(x) ((x) << S_INITIAL_SLOW_START_THRESHOLD)
999#define G_INITIAL_SLOW_START_THRESHOLD(x) (((x) >> S_INITIAL_SLOW_START_THRESHOLD) & M_INITIAL_SLOW_START_THRESHOLD)
1000
1001#define S_RECEIVE_BUFFER_SIZE 16
1002#define M_RECEIVE_BUFFER_SIZE 0xffff
1003#define V_RECEIVE_BUFFER_SIZE(x) ((x) << S_RECEIVE_BUFFER_SIZE)
1004#define G_RECEIVE_BUFFER_SIZE(x) (((x) >> S_RECEIVE_BUFFER_SIZE) & M_RECEIVE_BUFFER_SIZE)
1005
1006#define A_TP_PARA_REG2 0x368
1007
1008#define S_RX_COALESCE_SIZE 0
1009#define M_RX_COALESCE_SIZE 0xffff
1010#define V_RX_COALESCE_SIZE(x) ((x) << S_RX_COALESCE_SIZE)
1011#define G_RX_COALESCE_SIZE(x) (((x) >> S_RX_COALESCE_SIZE) & M_RX_COALESCE_SIZE)
1012
1013#define S_MAX_RX_SIZE 16
1014#define M_MAX_RX_SIZE 0xffff
1015#define V_MAX_RX_SIZE(x) ((x) << S_MAX_RX_SIZE)
1016#define G_MAX_RX_SIZE(x) (((x) >> S_MAX_RX_SIZE) & M_MAX_RX_SIZE)
1017
1018#define A_TP_PARA_REG3 0x36c
1019
1020#define S_RX_COALESCING_PSH_DELIVER 0
1021#define V_RX_COALESCING_PSH_DELIVER(x) ((x) << S_RX_COALESCING_PSH_DELIVER)
1022#define F_RX_COALESCING_PSH_DELIVER V_RX_COALESCING_PSH_DELIVER(1U)
1023
1024#define S_RX_COALESCING_ENABLE 1
1025#define V_RX_COALESCING_ENABLE(x) ((x) << S_RX_COALESCING_ENABLE)
1026#define F_RX_COALESCING_ENABLE V_RX_COALESCING_ENABLE(1U)
1027
1028#define S_TAHOE_ENABLE 2
1029#define V_TAHOE_ENABLE(x) ((x) << S_TAHOE_ENABLE)
1030#define F_TAHOE_ENABLE V_TAHOE_ENABLE(1U)
1031
1032#define S_MAX_REORDER_FRAGMENTS 12
1033#define M_MAX_REORDER_FRAGMENTS 0x7
1034#define V_MAX_REORDER_FRAGMENTS(x) ((x) << S_MAX_REORDER_FRAGMENTS)
1035#define G_MAX_REORDER_FRAGMENTS(x) (((x) >> S_MAX_REORDER_FRAGMENTS) & M_MAX_REORDER_FRAGMENTS)
1036
1037#define A_TP_TIMER_RESOLUTION 0x390
1038
1039#define S_DELAYED_ACK_TIMER_RESOLUTION 0
1040#define M_DELAYED_ACK_TIMER_RESOLUTION 0x3f
1041#define V_DELAYED_ACK_TIMER_RESOLUTION(x) ((x) << S_DELAYED_ACK_TIMER_RESOLUTION)
1042#define G_DELAYED_ACK_TIMER_RESOLUTION(x) (((x) >> S_DELAYED_ACK_TIMER_RESOLUTION) & M_DELAYED_ACK_TIMER_RESOLUTION)
1043
1044#define S_GENERIC_TIMER_RESOLUTION 16
1045#define M_GENERIC_TIMER_RESOLUTION 0x3f
1046#define V_GENERIC_TIMER_RESOLUTION(x) ((x) << S_GENERIC_TIMER_RESOLUTION)
1047#define G_GENERIC_TIMER_RESOLUTION(x) (((x) >> S_GENERIC_TIMER_RESOLUTION) & M_GENERIC_TIMER_RESOLUTION)
1048
1049#define A_TP_2MSL 0x394
1050
1051#define S_2MSL 0
1052#define M_2MSL 0x3fffffff
1053#define V_2MSL(x) ((x) << S_2MSL)
1054#define G_2MSL(x) (((x) >> S_2MSL) & M_2MSL)
1055
1056#define A_TP_RXT_MIN 0x398
1057
1058#define S_RETRANSMIT_TIMER_MIN 0
1059#define M_RETRANSMIT_TIMER_MIN 0xffff
1060#define V_RETRANSMIT_TIMER_MIN(x) ((x) << S_RETRANSMIT_TIMER_MIN)
1061#define G_RETRANSMIT_TIMER_MIN(x) (((x) >> S_RETRANSMIT_TIMER_MIN) & M_RETRANSMIT_TIMER_MIN)
1062
1063#define A_TP_RXT_MAX 0x39c
1064
1065#define S_RETRANSMIT_TIMER_MAX 0
1066#define M_RETRANSMIT_TIMER_MAX 0x3fffffff
1067#define V_RETRANSMIT_TIMER_MAX(x) ((x) << S_RETRANSMIT_TIMER_MAX)
1068#define G_RETRANSMIT_TIMER_MAX(x) (((x) >> S_RETRANSMIT_TIMER_MAX) & M_RETRANSMIT_TIMER_MAX)
1069
1070#define A_TP_PERS_MIN 0x3a0
1071
1072#define S_PERSIST_TIMER_MIN 0
1073#define M_PERSIST_TIMER_MIN 0xffff
1074#define V_PERSIST_TIMER_MIN(x) ((x) << S_PERSIST_TIMER_MIN)
1075#define G_PERSIST_TIMER_MIN(x) (((x) >> S_PERSIST_TIMER_MIN) & M_PERSIST_TIMER_MIN)
1076
1077#define A_TP_PERS_MAX 0x3a4
1078
1079#define S_PERSIST_TIMER_MAX 0
1080#define M_PERSIST_TIMER_MAX 0x3fffffff
1081#define V_PERSIST_TIMER_MAX(x) ((x) << S_PERSIST_TIMER_MAX)
1082#define G_PERSIST_TIMER_MAX(x) (((x) >> S_PERSIST_TIMER_MAX) & M_PERSIST_TIMER_MAX)
1083
1084#define A_TP_KEEP_IDLE 0x3ac
1085
1086#define S_KEEP_ALIVE_IDLE_TIME 0
1087#define M_KEEP_ALIVE_IDLE_TIME 0x3fffffff
1088#define V_KEEP_ALIVE_IDLE_TIME(x) ((x) << S_KEEP_ALIVE_IDLE_TIME)
1089#define G_KEEP_ALIVE_IDLE_TIME(x) (((x) >> S_KEEP_ALIVE_IDLE_TIME) & M_KEEP_ALIVE_IDLE_TIME)
1090
1091#define A_TP_KEEP_INTVL 0x3b0
1092
1093#define S_KEEP_ALIVE_INTERVAL_TIME 0
1094#define M_KEEP_ALIVE_INTERVAL_TIME 0x3fffffff
1095#define V_KEEP_ALIVE_INTERVAL_TIME(x) ((x) << S_KEEP_ALIVE_INTERVAL_TIME)
1096#define G_KEEP_ALIVE_INTERVAL_TIME(x) (((x) >> S_KEEP_ALIVE_INTERVAL_TIME) & M_KEEP_ALIVE_INTERVAL_TIME)
1097
1098#define A_TP_INIT_SRTT 0x3b4
1099
1100#define S_INITIAL_SRTT 0
1101#define M_INITIAL_SRTT 0xffff
1102#define V_INITIAL_SRTT(x) ((x) << S_INITIAL_SRTT)
1103#define G_INITIAL_SRTT(x) (((x) >> S_INITIAL_SRTT) & M_INITIAL_SRTT)
1104
1105#define A_TP_DACK_TIME 0x3b8
1106
1107#define S_DELAYED_ACK_TIME 0
1108#define M_DELAYED_ACK_TIME 0x7ff
1109#define V_DELAYED_ACK_TIME(x) ((x) << S_DELAYED_ACK_TIME)
1110#define G_DELAYED_ACK_TIME(x) (((x) >> S_DELAYED_ACK_TIME) & M_DELAYED_ACK_TIME)
1111
1112#define A_TP_FINWAIT2_TIME 0x3bc
1113
1114#define S_FINWAIT2_TIME 0
1115#define M_FINWAIT2_TIME 0x3fffffff
1116#define V_FINWAIT2_TIME(x) ((x) << S_FINWAIT2_TIME)
1117#define G_FINWAIT2_TIME(x) (((x) >> S_FINWAIT2_TIME) & M_FINWAIT2_TIME)
1118
1119#define A_TP_FAST_FINWAIT2_TIME 0x3c0
1120
1121#define S_FAST_FINWAIT2_TIME 0
1122#define M_FAST_FINWAIT2_TIME 0x3fffffff
1123#define V_FAST_FINWAIT2_TIME(x) ((x) << S_FAST_FINWAIT2_TIME)
1124#define G_FAST_FINWAIT2_TIME(x) (((x) >> S_FAST_FINWAIT2_TIME) & M_FAST_FINWAIT2_TIME)
1125
1126#define A_TP_SHIFT_CNT 0x3c4
1127
1128#define S_KEEPALIVE_MAX 0
1129#define M_KEEPALIVE_MAX 0xff
1130#define V_KEEPALIVE_MAX(x) ((x) << S_KEEPALIVE_MAX)
1131#define G_KEEPALIVE_MAX(x) (((x) >> S_KEEPALIVE_MAX) & M_KEEPALIVE_MAX)
1132
1133#define S_WINDOWPROBE_MAX 8
1134#define M_WINDOWPROBE_MAX 0xff
1135#define V_WINDOWPROBE_MAX(x) ((x) << S_WINDOWPROBE_MAX)
1136#define G_WINDOWPROBE_MAX(x) (((x) >> S_WINDOWPROBE_MAX) & M_WINDOWPROBE_MAX)
1137
1138#define S_RETRANSMISSION_MAX 16
1139#define M_RETRANSMISSION_MAX 0xff
1140#define V_RETRANSMISSION_MAX(x) ((x) << S_RETRANSMISSION_MAX)
1141#define G_RETRANSMISSION_MAX(x) (((x) >> S_RETRANSMISSION_MAX) & M_RETRANSMISSION_MAX)
1142
1143#define S_SYN_MAX 24
1144#define M_SYN_MAX 0xff
1145#define V_SYN_MAX(x) ((x) << S_SYN_MAX)
1146#define G_SYN_MAX(x) (((x) >> S_SYN_MAX) & M_SYN_MAX)
1147
1148#define A_TP_QOS_REG0 0x3e0
1149
1150#define S_L3_VALUE 0
1151#define M_L3_VALUE 0x3f
1152#define V_L3_VALUE(x) ((x) << S_L3_VALUE)
1153#define G_L3_VALUE(x) (((x) >> S_L3_VALUE) & M_L3_VALUE)
1154
1155#define A_TP_QOS_REG1 0x3e4
1156#define A_TP_QOS_REG2 0x3e8
1157#define A_TP_QOS_REG3 0x3ec
1158#define A_TP_QOS_REG4 0x3f0
1159#define A_TP_QOS_REG5 0x3f4
1160#define A_TP_QOS_REG6 0x3f8
1161#define A_TP_QOS_REG7 0x3fc
1162#define A_TP_MTU_REG0 0x404
1163#define A_TP_MTU_REG1 0x408
1164#define A_TP_MTU_REG2 0x40c
1165#define A_TP_MTU_REG3 0x410
1166#define A_TP_MTU_REG4 0x414
1167#define A_TP_MTU_REG5 0x418
1168#define A_TP_MTU_REG6 0x41c
1169#define A_TP_MTU_REG7 0x420
267#define A_TP_RESET 0x44c 1170#define A_TP_RESET 0x44c
1171
268#define S_TP_RESET 0 1172#define S_TP_RESET 0
269#define V_TP_RESET(x) ((x) << S_TP_RESET) 1173#define V_TP_RESET(x) ((x) << S_TP_RESET)
270#define F_TP_RESET V_TP_RESET(1U) 1174#define F_TP_RESET V_TP_RESET(1U)
271 1175
1176#define S_CM_MEMMGR_INIT 1
1177#define V_CM_MEMMGR_INIT(x) ((x) << S_CM_MEMMGR_INIT)
1178#define F_CM_MEMMGR_INIT V_CM_MEMMGR_INIT(1U)
1179
1180#define A_TP_MIB_INDEX 0x450
1181#define A_TP_MIB_DATA 0x454
1182#define A_TP_SYNC_TIME_HI 0x458
1183#define A_TP_SYNC_TIME_LO 0x45c
1184#define A_TP_CM_MM_RX_FLST_BASE 0x460
1185
1186#define S_CM_MEMMGR_RX_FREE_LIST_BASE 0
1187#define M_CM_MEMMGR_RX_FREE_LIST_BASE 0xfffffff
1188#define V_CM_MEMMGR_RX_FREE_LIST_BASE(x) ((x) << S_CM_MEMMGR_RX_FREE_LIST_BASE)
1189#define G_CM_MEMMGR_RX_FREE_LIST_BASE(x) (((x) >> S_CM_MEMMGR_RX_FREE_LIST_BASE) & M_CM_MEMMGR_RX_FREE_LIST_BASE)
1190
1191#define A_TP_CM_MM_TX_FLST_BASE 0x464
1192
1193#define S_CM_MEMMGR_TX_FREE_LIST_BASE 0
1194#define M_CM_MEMMGR_TX_FREE_LIST_BASE 0xfffffff
1195#define V_CM_MEMMGR_TX_FREE_LIST_BASE(x) ((x) << S_CM_MEMMGR_TX_FREE_LIST_BASE)
1196#define G_CM_MEMMGR_TX_FREE_LIST_BASE(x) (((x) >> S_CM_MEMMGR_TX_FREE_LIST_BASE) & M_CM_MEMMGR_TX_FREE_LIST_BASE)
1197
1198#define A_TP_CM_MM_P_FLST_BASE 0x468
1199
1200#define S_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE 0
1201#define M_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE 0xfffffff
1202#define V_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE(x) ((x) << S_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE)
1203#define G_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE(x) (((x) >> S_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE) & M_CM_MEMMGR_PSTRUCT_FREE_LIST_BASE)
1204
1205#define A_TP_CM_MM_MAX_P 0x46c
1206
1207#define S_CM_MEMMGR_MAX_PSTRUCT 0
1208#define M_CM_MEMMGR_MAX_PSTRUCT 0xfffffff
1209#define V_CM_MEMMGR_MAX_PSTRUCT(x) ((x) << S_CM_MEMMGR_MAX_PSTRUCT)
1210#define G_CM_MEMMGR_MAX_PSTRUCT(x) (((x) >> S_CM_MEMMGR_MAX_PSTRUCT) & M_CM_MEMMGR_MAX_PSTRUCT)
1211
272#define A_TP_INT_ENABLE 0x470 1212#define A_TP_INT_ENABLE 0x470
1213
1214#define S_TX_FREE_LIST_EMPTY 0
1215#define V_TX_FREE_LIST_EMPTY(x) ((x) << S_TX_FREE_LIST_EMPTY)
1216#define F_TX_FREE_LIST_EMPTY V_TX_FREE_LIST_EMPTY(1U)
1217
1218#define S_RX_FREE_LIST_EMPTY 1
1219#define V_RX_FREE_LIST_EMPTY(x) ((x) << S_RX_FREE_LIST_EMPTY)
1220#define F_RX_FREE_LIST_EMPTY V_RX_FREE_LIST_EMPTY(1U)
1221
273#define A_TP_INT_CAUSE 0x474 1222#define A_TP_INT_CAUSE 0x474
1223#define A_TP_TIMER_SEPARATOR 0x4a4
1224
1225#define S_DISABLE_PAST_TIMER_INSERTION 0
1226#define V_DISABLE_PAST_TIMER_INSERTION(x) ((x) << S_DISABLE_PAST_TIMER_INSERTION)
1227#define F_DISABLE_PAST_TIMER_INSERTION V_DISABLE_PAST_TIMER_INSERTION(1U)
1228
1229#define S_MODULATION_TIMER_SEPARATOR 1
1230#define M_MODULATION_TIMER_SEPARATOR 0x7fff
1231#define V_MODULATION_TIMER_SEPARATOR(x) ((x) << S_MODULATION_TIMER_SEPARATOR)
1232#define G_MODULATION_TIMER_SEPARATOR(x) (((x) >> S_MODULATION_TIMER_SEPARATOR) & M_MODULATION_TIMER_SEPARATOR)
1233
1234#define S_GLOBAL_TIMER_SEPARATOR 16
1235#define M_GLOBAL_TIMER_SEPARATOR 0xffff
1236#define V_GLOBAL_TIMER_SEPARATOR(x) ((x) << S_GLOBAL_TIMER_SEPARATOR)
1237#define G_GLOBAL_TIMER_SEPARATOR(x) (((x) >> S_GLOBAL_TIMER_SEPARATOR) & M_GLOBAL_TIMER_SEPARATOR)
1238
1239#define A_TP_CM_FC_MODE 0x4b0
1240#define A_TP_PC_CONGESTION_CNTL 0x4b4
274#define A_TP_TX_DROP_CONFIG 0x4b8 1241#define A_TP_TX_DROP_CONFIG 0x4b8
275 1242
276#define S_ENABLE_TX_DROP 31 1243#define S_ENABLE_TX_DROP 31
@@ -282,12 +1249,108 @@
282#define F_ENABLE_TX_ERROR V_ENABLE_TX_ERROR(1U) 1249#define F_ENABLE_TX_ERROR V_ENABLE_TX_ERROR(1U)
283 1250
284#define S_DROP_TICKS_CNT 4 1251#define S_DROP_TICKS_CNT 4
1252#define M_DROP_TICKS_CNT 0x3ffffff
285#define V_DROP_TICKS_CNT(x) ((x) << S_DROP_TICKS_CNT) 1253#define V_DROP_TICKS_CNT(x) ((x) << S_DROP_TICKS_CNT)
1254#define G_DROP_TICKS_CNT(x) (((x) >> S_DROP_TICKS_CNT) & M_DROP_TICKS_CNT)
286 1255
287#define S_NUM_PKTS_DROPPED 0 1256#define S_NUM_PKTS_DROPPED 0
1257#define M_NUM_PKTS_DROPPED 0xf
288#define V_NUM_PKTS_DROPPED(x) ((x) << S_NUM_PKTS_DROPPED) 1258#define V_NUM_PKTS_DROPPED(x) ((x) << S_NUM_PKTS_DROPPED)
1259#define G_NUM_PKTS_DROPPED(x) (((x) >> S_NUM_PKTS_DROPPED) & M_NUM_PKTS_DROPPED)
1260
1261#define A_TP_TX_DROP_COUNT 0x4bc
1262
1263/* RAT registers */
1264#define A_RAT_ROUTE_CONTROL 0x580
1265
1266#define S_USE_ROUTE_TABLE 0
1267#define V_USE_ROUTE_TABLE(x) ((x) << S_USE_ROUTE_TABLE)
1268#define F_USE_ROUTE_TABLE V_USE_ROUTE_TABLE(1U)
1269
1270#define S_ENABLE_CSPI 1
1271#define V_ENABLE_CSPI(x) ((x) << S_ENABLE_CSPI)
1272#define F_ENABLE_CSPI V_ENABLE_CSPI(1U)
1273
1274#define S_ENABLE_PCIX 2
1275#define V_ENABLE_PCIX(x) ((x) << S_ENABLE_PCIX)
1276#define F_ENABLE_PCIX V_ENABLE_PCIX(1U)
1277
1278#define A_RAT_ROUTE_TABLE_INDEX 0x584
1279
1280#define S_ROUTE_TABLE_INDEX 0
1281#define M_ROUTE_TABLE_INDEX 0xf
1282#define V_ROUTE_TABLE_INDEX(x) ((x) << S_ROUTE_TABLE_INDEX)
1283#define G_ROUTE_TABLE_INDEX(x) (((x) >> S_ROUTE_TABLE_INDEX) & M_ROUTE_TABLE_INDEX)
1284
1285#define A_RAT_ROUTE_TABLE_DATA 0x588
1286#define A_RAT_NO_ROUTE 0x58c
1287
1288#define S_CPL_OPCODE 0
1289#define M_CPL_OPCODE 0xff
1290#define V_CPL_OPCODE(x) ((x) << S_CPL_OPCODE)
1291#define G_CPL_OPCODE(x) (((x) >> S_CPL_OPCODE) & M_CPL_OPCODE)
1292
1293#define A_RAT_INTR_ENABLE 0x590
1294
1295#define S_ZEROROUTEERROR 0
1296#define V_ZEROROUTEERROR(x) ((x) << S_ZEROROUTEERROR)
1297#define F_ZEROROUTEERROR V_ZEROROUTEERROR(1U)
1298
1299#define S_CSPIFRAMINGERROR 1
1300#define V_CSPIFRAMINGERROR(x) ((x) << S_CSPIFRAMINGERROR)
1301#define F_CSPIFRAMINGERROR V_CSPIFRAMINGERROR(1U)
1302
1303#define S_SGEFRAMINGERROR 2
1304#define V_SGEFRAMINGERROR(x) ((x) << S_SGEFRAMINGERROR)
1305#define F_SGEFRAMINGERROR V_SGEFRAMINGERROR(1U)
1306
1307#define S_TPFRAMINGERROR 3
1308#define V_TPFRAMINGERROR(x) ((x) << S_TPFRAMINGERROR)
1309#define F_TPFRAMINGERROR V_TPFRAMINGERROR(1U)
1310
1311#define A_RAT_INTR_CAUSE 0x594
289 1312
290/* CSPI registers */ 1313/* CSPI registers */
1314#define A_CSPI_RX_AE_WM 0x810
1315#define A_CSPI_RX_AF_WM 0x814
1316#define A_CSPI_CALENDAR_LEN 0x818
1317
1318#define S_CALENDARLENGTH 0
1319#define M_CALENDARLENGTH 0xffff
1320#define V_CALENDARLENGTH(x) ((x) << S_CALENDARLENGTH)
1321#define G_CALENDARLENGTH(x) (((x) >> S_CALENDARLENGTH) & M_CALENDARLENGTH)
1322
1323#define A_CSPI_FIFO_STATUS_ENABLE 0x820
1324
1325#define S_FIFOSTATUSENABLE 0
1326#define V_FIFOSTATUSENABLE(x) ((x) << S_FIFOSTATUSENABLE)
1327#define F_FIFOSTATUSENABLE V_FIFOSTATUSENABLE(1U)
1328
1329#define A_CSPI_MAXBURST1_MAXBURST2 0x828
1330
1331#define S_MAXBURST1 0
1332#define M_MAXBURST1 0xffff
1333#define V_MAXBURST1(x) ((x) << S_MAXBURST1)
1334#define G_MAXBURST1(x) (((x) >> S_MAXBURST1) & M_MAXBURST1)
1335
1336#define S_MAXBURST2 16
1337#define M_MAXBURST2 0xffff
1338#define V_MAXBURST2(x) ((x) << S_MAXBURST2)
1339#define G_MAXBURST2(x) (((x) >> S_MAXBURST2) & M_MAXBURST2)
1340
1341#define A_CSPI_TRAIN 0x82c
1342
1343#define S_CSPI_TRAIN_ALPHA 0
1344#define M_CSPI_TRAIN_ALPHA 0xffff
1345#define V_CSPI_TRAIN_ALPHA(x) ((x) << S_CSPI_TRAIN_ALPHA)
1346#define G_CSPI_TRAIN_ALPHA(x) (((x) >> S_CSPI_TRAIN_ALPHA) & M_CSPI_TRAIN_ALPHA)
1347
1348#define S_CSPI_TRAIN_DATA_MAXT 16
1349#define M_CSPI_TRAIN_DATA_MAXT 0xffff
1350#define V_CSPI_TRAIN_DATA_MAXT(x) ((x) << S_CSPI_TRAIN_DATA_MAXT)
1351#define G_CSPI_TRAIN_DATA_MAXT(x) (((x) >> S_CSPI_TRAIN_DATA_MAXT) & M_CSPI_TRAIN_DATA_MAXT)
1352
1353#define A_CSPI_INTR_STATUS 0x848
291 1354
292#define S_DIP4ERR 0 1355#define S_DIP4ERR 0
293#define V_DIP4ERR(x) ((x) << S_DIP4ERR) 1356#define V_DIP4ERR(x) ((x) << S_DIP4ERR)
@@ -309,22 +1372,63 @@
309#define V_RAMPARITYERR(x) ((x) << S_RAMPARITYERR) 1372#define V_RAMPARITYERR(x) ((x) << S_RAMPARITYERR)
310#define F_RAMPARITYERR V_RAMPARITYERR(1U) 1373#define F_RAMPARITYERR V_RAMPARITYERR(1U)
311 1374
312/* ESPI registers */ 1375#define A_CSPI_INTR_ENABLE 0x84c
313 1376
1377/* ESPI registers */
314#define A_ESPI_SCH_TOKEN0 0x880 1378#define A_ESPI_SCH_TOKEN0 0x880
1379
1380#define S_SCHTOKEN0 0
1381#define M_SCHTOKEN0 0xffff
1382#define V_SCHTOKEN0(x) ((x) << S_SCHTOKEN0)
1383#define G_SCHTOKEN0(x) (((x) >> S_SCHTOKEN0) & M_SCHTOKEN0)
1384
315#define A_ESPI_SCH_TOKEN1 0x884 1385#define A_ESPI_SCH_TOKEN1 0x884
1386
1387#define S_SCHTOKEN1 0
1388#define M_SCHTOKEN1 0xffff
1389#define V_SCHTOKEN1(x) ((x) << S_SCHTOKEN1)
1390#define G_SCHTOKEN1(x) (((x) >> S_SCHTOKEN1) & M_SCHTOKEN1)
1391
316#define A_ESPI_SCH_TOKEN2 0x888 1392#define A_ESPI_SCH_TOKEN2 0x888
1393
1394#define S_SCHTOKEN2 0
1395#define M_SCHTOKEN2 0xffff
1396#define V_SCHTOKEN2(x) ((x) << S_SCHTOKEN2)
1397#define G_SCHTOKEN2(x) (((x) >> S_SCHTOKEN2) & M_SCHTOKEN2)
1398
317#define A_ESPI_SCH_TOKEN3 0x88c 1399#define A_ESPI_SCH_TOKEN3 0x88c
1400
1401#define S_SCHTOKEN3 0
1402#define M_SCHTOKEN3 0xffff
1403#define V_SCHTOKEN3(x) ((x) << S_SCHTOKEN3)
1404#define G_SCHTOKEN3(x) (((x) >> S_SCHTOKEN3) & M_SCHTOKEN3)
1405
318#define A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK 0x890 1406#define A_ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK 0x890
1407
1408#define S_ALMOSTEMPTY 0
1409#define M_ALMOSTEMPTY 0xffff
1410#define V_ALMOSTEMPTY(x) ((x) << S_ALMOSTEMPTY)
1411#define G_ALMOSTEMPTY(x) (((x) >> S_ALMOSTEMPTY) & M_ALMOSTEMPTY)
1412
319#define A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK 0x894 1413#define A_ESPI_RX_FIFO_ALMOST_FULL_WATERMARK 0x894
1414
1415#define S_ALMOSTFULL 0
1416#define M_ALMOSTFULL 0xffff
1417#define V_ALMOSTFULL(x) ((x) << S_ALMOSTFULL)
1418#define G_ALMOSTFULL(x) (((x) >> S_ALMOSTFULL) & M_ALMOSTFULL)
1419
320#define A_ESPI_CALENDAR_LENGTH 0x898 1420#define A_ESPI_CALENDAR_LENGTH 0x898
321#define A_PORT_CONFIG 0x89c 1421#define A_PORT_CONFIG 0x89c
322 1422
323#define S_RX_NPORTS 0 1423#define S_RX_NPORTS 0
1424#define M_RX_NPORTS 0xff
324#define V_RX_NPORTS(x) ((x) << S_RX_NPORTS) 1425#define V_RX_NPORTS(x) ((x) << S_RX_NPORTS)
1426#define G_RX_NPORTS(x) (((x) >> S_RX_NPORTS) & M_RX_NPORTS)
325 1427
326#define S_TX_NPORTS 8 1428#define S_TX_NPORTS 8
1429#define M_TX_NPORTS 0xff
327#define V_TX_NPORTS(x) ((x) << S_TX_NPORTS) 1430#define V_TX_NPORTS(x) ((x) << S_TX_NPORTS)
1431#define G_TX_NPORTS(x) (((x) >> S_TX_NPORTS) & M_TX_NPORTS)
328 1432
329#define A_ESPI_FIFO_STATUS_ENABLE 0x8a0 1433#define A_ESPI_FIFO_STATUS_ENABLE 0x8a0
330 1434
@@ -332,12 +1436,124 @@
332#define V_RXSTATUSENABLE(x) ((x) << S_RXSTATUSENABLE) 1436#define V_RXSTATUSENABLE(x) ((x) << S_RXSTATUSENABLE)
333#define F_RXSTATUSENABLE V_RXSTATUSENABLE(1U) 1437#define F_RXSTATUSENABLE V_RXSTATUSENABLE(1U)
334 1438
1439#define S_TXDROPENABLE 1
1440#define V_TXDROPENABLE(x) ((x) << S_TXDROPENABLE)
1441#define F_TXDROPENABLE V_TXDROPENABLE(1U)
1442
1443#define S_RXENDIANMODE 2
1444#define V_RXENDIANMODE(x) ((x) << S_RXENDIANMODE)
1445#define F_RXENDIANMODE V_RXENDIANMODE(1U)
1446
1447#define S_TXENDIANMODE 3
1448#define V_TXENDIANMODE(x) ((x) << S_TXENDIANMODE)
1449#define F_TXENDIANMODE V_TXENDIANMODE(1U)
1450
335#define S_INTEL1010MODE 4 1451#define S_INTEL1010MODE 4
336#define V_INTEL1010MODE(x) ((x) << S_INTEL1010MODE) 1452#define V_INTEL1010MODE(x) ((x) << S_INTEL1010MODE)
337#define F_INTEL1010MODE V_INTEL1010MODE(1U) 1453#define F_INTEL1010MODE V_INTEL1010MODE(1U)
338 1454
339#define A_ESPI_MAXBURST1_MAXBURST2 0x8a8 1455#define A_ESPI_MAXBURST1_MAXBURST2 0x8a8
340#define A_ESPI_TRAIN 0x8ac 1456#define A_ESPI_TRAIN 0x8ac
1457
1458#define S_MAXTRAINALPHA 0
1459#define M_MAXTRAINALPHA 0xffff
1460#define V_MAXTRAINALPHA(x) ((x) << S_MAXTRAINALPHA)
1461#define G_MAXTRAINALPHA(x) (((x) >> S_MAXTRAINALPHA) & M_MAXTRAINALPHA)
1462
1463#define S_MAXTRAINDATA 16
1464#define M_MAXTRAINDATA 0xffff
1465#define V_MAXTRAINDATA(x) ((x) << S_MAXTRAINDATA)
1466#define G_MAXTRAINDATA(x) (((x) >> S_MAXTRAINDATA) & M_MAXTRAINDATA)
1467
1468#define A_RAM_STATUS 0x8b0
1469
1470#define S_RXFIFOPARITYERROR 0
1471#define M_RXFIFOPARITYERROR 0x3ff
1472#define V_RXFIFOPARITYERROR(x) ((x) << S_RXFIFOPARITYERROR)
1473#define G_RXFIFOPARITYERROR(x) (((x) >> S_RXFIFOPARITYERROR) & M_RXFIFOPARITYERROR)
1474
1475#define S_TXFIFOPARITYERROR 10
1476#define M_TXFIFOPARITYERROR 0x3ff
1477#define V_TXFIFOPARITYERROR(x) ((x) << S_TXFIFOPARITYERROR)
1478#define G_TXFIFOPARITYERROR(x) (((x) >> S_TXFIFOPARITYERROR) & M_TXFIFOPARITYERROR)
1479
1480#define S_RXFIFOOVERFLOW 20
1481#define M_RXFIFOOVERFLOW 0x3ff
1482#define V_RXFIFOOVERFLOW(x) ((x) << S_RXFIFOOVERFLOW)
1483#define G_RXFIFOOVERFLOW(x) (((x) >> S_RXFIFOOVERFLOW) & M_RXFIFOOVERFLOW)
1484
1485#define A_TX_DROP_COUNT0 0x8b4
1486
1487#define S_TXPORT0DROPCNT 0
1488#define M_TXPORT0DROPCNT 0xffff
1489#define V_TXPORT0DROPCNT(x) ((x) << S_TXPORT0DROPCNT)
1490#define G_TXPORT0DROPCNT(x) (((x) >> S_TXPORT0DROPCNT) & M_TXPORT0DROPCNT)
1491
1492#define S_TXPORT1DROPCNT 16
1493#define M_TXPORT1DROPCNT 0xffff
1494#define V_TXPORT1DROPCNT(x) ((x) << S_TXPORT1DROPCNT)
1495#define G_TXPORT1DROPCNT(x) (((x) >> S_TXPORT1DROPCNT) & M_TXPORT1DROPCNT)
1496
1497#define A_TX_DROP_COUNT1 0x8b8
1498
1499#define S_TXPORT2DROPCNT 0
1500#define M_TXPORT2DROPCNT 0xffff
1501#define V_TXPORT2DROPCNT(x) ((x) << S_TXPORT2DROPCNT)
1502#define G_TXPORT2DROPCNT(x) (((x) >> S_TXPORT2DROPCNT) & M_TXPORT2DROPCNT)
1503
1504#define S_TXPORT3DROPCNT 16
1505#define M_TXPORT3DROPCNT 0xffff
1506#define V_TXPORT3DROPCNT(x) ((x) << S_TXPORT3DROPCNT)
1507#define G_TXPORT3DROPCNT(x) (((x) >> S_TXPORT3DROPCNT) & M_TXPORT3DROPCNT)
1508
1509#define A_RX_DROP_COUNT0 0x8bc
1510
1511#define S_RXPORT0DROPCNT 0
1512#define M_RXPORT0DROPCNT 0xffff
1513#define V_RXPORT0DROPCNT(x) ((x) << S_RXPORT0DROPCNT)
1514#define G_RXPORT0DROPCNT(x) (((x) >> S_RXPORT0DROPCNT) & M_RXPORT0DROPCNT)
1515
1516#define S_RXPORT1DROPCNT 16
1517#define M_RXPORT1DROPCNT 0xffff
1518#define V_RXPORT1DROPCNT(x) ((x) << S_RXPORT1DROPCNT)
1519#define G_RXPORT1DROPCNT(x) (((x) >> S_RXPORT1DROPCNT) & M_RXPORT1DROPCNT)
1520
1521#define A_RX_DROP_COUNT1 0x8c0
1522
1523#define S_RXPORT2DROPCNT 0
1524#define M_RXPORT2DROPCNT 0xffff
1525#define V_RXPORT2DROPCNT(x) ((x) << S_RXPORT2DROPCNT)
1526#define G_RXPORT2DROPCNT(x) (((x) >> S_RXPORT2DROPCNT) & M_RXPORT2DROPCNT)
1527
1528#define S_RXPORT3DROPCNT 16
1529#define M_RXPORT3DROPCNT 0xffff
1530#define V_RXPORT3DROPCNT(x) ((x) << S_RXPORT3DROPCNT)
1531#define G_RXPORT3DROPCNT(x) (((x) >> S_RXPORT3DROPCNT) & M_RXPORT3DROPCNT)
1532
1533#define A_DIP4_ERROR_COUNT 0x8c4
1534
1535#define S_DIP4ERRORCNT 0
1536#define M_DIP4ERRORCNT 0xfff
1537#define V_DIP4ERRORCNT(x) ((x) << S_DIP4ERRORCNT)
1538#define G_DIP4ERRORCNT(x) (((x) >> S_DIP4ERRORCNT) & M_DIP4ERRORCNT)
1539
1540#define S_DIP4ERRORCNTSHADOW 12
1541#define M_DIP4ERRORCNTSHADOW 0xfff
1542#define V_DIP4ERRORCNTSHADOW(x) ((x) << S_DIP4ERRORCNTSHADOW)
1543#define G_DIP4ERRORCNTSHADOW(x) (((x) >> S_DIP4ERRORCNTSHADOW) & M_DIP4ERRORCNTSHADOW)
1544
1545#define S_TRICN_RX_TRAIN_ERR 24
1546#define V_TRICN_RX_TRAIN_ERR(x) ((x) << S_TRICN_RX_TRAIN_ERR)
1547#define F_TRICN_RX_TRAIN_ERR V_TRICN_RX_TRAIN_ERR(1U)
1548
1549#define S_TRICN_RX_TRAINING 25
1550#define V_TRICN_RX_TRAINING(x) ((x) << S_TRICN_RX_TRAINING)
1551#define F_TRICN_RX_TRAINING V_TRICN_RX_TRAINING(1U)
1552
1553#define S_TRICN_RX_TRAIN_OK 26
1554#define V_TRICN_RX_TRAIN_OK(x) ((x) << S_TRICN_RX_TRAIN_OK)
1555#define F_TRICN_RX_TRAIN_OK V_TRICN_RX_TRAIN_OK(1U)
1556
341#define A_ESPI_INTR_STATUS 0x8c8 1557#define A_ESPI_INTR_STATUS 0x8c8
342 1558
343#define S_DIP2PARITYERR 5 1559#define S_DIP2PARITYERR 5
@@ -347,19 +1563,56 @@
347#define A_ESPI_INTR_ENABLE 0x8cc 1563#define A_ESPI_INTR_ENABLE 0x8cc
348#define A_RX_DROP_THRESHOLD 0x8d0 1564#define A_RX_DROP_THRESHOLD 0x8d0
349#define A_ESPI_RX_RESET 0x8ec 1565#define A_ESPI_RX_RESET 0x8ec
1566
1567#define S_ESPI_RX_LNK_RST 0
1568#define V_ESPI_RX_LNK_RST(x) ((x) << S_ESPI_RX_LNK_RST)
1569#define F_ESPI_RX_LNK_RST V_ESPI_RX_LNK_RST(1U)
1570
1571#define S_ESPI_RX_CORE_RST 1
1572#define V_ESPI_RX_CORE_RST(x) ((x) << S_ESPI_RX_CORE_RST)
1573#define F_ESPI_RX_CORE_RST V_ESPI_RX_CORE_RST(1U)
1574
1575#define S_RX_CLK_STATUS 2
1576#define V_RX_CLK_STATUS(x) ((x) << S_RX_CLK_STATUS)
1577#define F_RX_CLK_STATUS V_RX_CLK_STATUS(1U)
1578
350#define A_ESPI_MISC_CONTROL 0x8f0 1579#define A_ESPI_MISC_CONTROL 0x8f0
351 1580
352#define S_OUT_OF_SYNC_COUNT 0 1581#define S_OUT_OF_SYNC_COUNT 0
1582#define M_OUT_OF_SYNC_COUNT 0xf
353#define V_OUT_OF_SYNC_COUNT(x) ((x) << S_OUT_OF_SYNC_COUNT) 1583#define V_OUT_OF_SYNC_COUNT(x) ((x) << S_OUT_OF_SYNC_COUNT)
1584#define G_OUT_OF_SYNC_COUNT(x) (((x) >> S_OUT_OF_SYNC_COUNT) & M_OUT_OF_SYNC_COUNT)
1585
1586#define S_DIP2_COUNT_MODE_ENABLE 4
1587#define V_DIP2_COUNT_MODE_ENABLE(x) ((x) << S_DIP2_COUNT_MODE_ENABLE)
1588#define F_DIP2_COUNT_MODE_ENABLE V_DIP2_COUNT_MODE_ENABLE(1U)
354 1589
355#define S_DIP2_PARITY_ERR_THRES 5 1590#define S_DIP2_PARITY_ERR_THRES 5
1591#define M_DIP2_PARITY_ERR_THRES 0xf
356#define V_DIP2_PARITY_ERR_THRES(x) ((x) << S_DIP2_PARITY_ERR_THRES) 1592#define V_DIP2_PARITY_ERR_THRES(x) ((x) << S_DIP2_PARITY_ERR_THRES)
1593#define G_DIP2_PARITY_ERR_THRES(x) (((x) >> S_DIP2_PARITY_ERR_THRES) & M_DIP2_PARITY_ERR_THRES)
357 1594
358#define S_DIP4_THRES 9 1595#define S_DIP4_THRES 9
1596#define M_DIP4_THRES 0xfff
359#define V_DIP4_THRES(x) ((x) << S_DIP4_THRES) 1597#define V_DIP4_THRES(x) ((x) << S_DIP4_THRES)
1598#define G_DIP4_THRES(x) (((x) >> S_DIP4_THRES) & M_DIP4_THRES)
1599
1600#define S_DIP4_THRES_ENABLE 21
1601#define V_DIP4_THRES_ENABLE(x) ((x) << S_DIP4_THRES_ENABLE)
1602#define F_DIP4_THRES_ENABLE V_DIP4_THRES_ENABLE(1U)
1603
1604#define S_FORCE_DISABLE_STATUS 22
1605#define V_FORCE_DISABLE_STATUS(x) ((x) << S_FORCE_DISABLE_STATUS)
1606#define F_FORCE_DISABLE_STATUS V_FORCE_DISABLE_STATUS(1U)
1607
1608#define S_DYNAMIC_DESKEW 23
1609#define V_DYNAMIC_DESKEW(x) ((x) << S_DYNAMIC_DESKEW)
1610#define F_DYNAMIC_DESKEW V_DYNAMIC_DESKEW(1U)
360 1611
361#define S_MONITORED_PORT_NUM 25 1612#define S_MONITORED_PORT_NUM 25
1613#define M_MONITORED_PORT_NUM 0x3
362#define V_MONITORED_PORT_NUM(x) ((x) << S_MONITORED_PORT_NUM) 1614#define V_MONITORED_PORT_NUM(x) ((x) << S_MONITORED_PORT_NUM)
1615#define G_MONITORED_PORT_NUM(x) (((x) >> S_MONITORED_PORT_NUM) & M_MONITORED_PORT_NUM)
363 1616
364#define S_MONITORED_DIRECTION 27 1617#define S_MONITORED_DIRECTION 27
365#define V_MONITORED_DIRECTION(x) ((x) << S_MONITORED_DIRECTION) 1618#define V_MONITORED_DIRECTION(x) ((x) << S_MONITORED_DIRECTION)
@@ -370,33 +1623,125 @@
370#define F_MONITORED_INTERFACE V_MONITORED_INTERFACE(1U) 1623#define F_MONITORED_INTERFACE V_MONITORED_INTERFACE(1U)
371 1624
372#define A_ESPI_DIP2_ERR_COUNT 0x8f4 1625#define A_ESPI_DIP2_ERR_COUNT 0x8f4
1626
1627#define S_DIP2_ERR_CNT 0
1628#define M_DIP2_ERR_CNT 0xf
1629#define V_DIP2_ERR_CNT(x) ((x) << S_DIP2_ERR_CNT)
1630#define G_DIP2_ERR_CNT(x) (((x) >> S_DIP2_ERR_CNT) & M_DIP2_ERR_CNT)
1631
373#define A_ESPI_CMD_ADDR 0x8f8 1632#define A_ESPI_CMD_ADDR 0x8f8
374 1633
375#define S_WRITE_DATA 0 1634#define S_WRITE_DATA 0
1635#define M_WRITE_DATA 0xff
376#define V_WRITE_DATA(x) ((x) << S_WRITE_DATA) 1636#define V_WRITE_DATA(x) ((x) << S_WRITE_DATA)
1637#define G_WRITE_DATA(x) (((x) >> S_WRITE_DATA) & M_WRITE_DATA)
377 1638
378#define S_REGISTER_OFFSET 8 1639#define S_REGISTER_OFFSET 8
1640#define M_REGISTER_OFFSET 0xf
379#define V_REGISTER_OFFSET(x) ((x) << S_REGISTER_OFFSET) 1641#define V_REGISTER_OFFSET(x) ((x) << S_REGISTER_OFFSET)
1642#define G_REGISTER_OFFSET(x) (((x) >> S_REGISTER_OFFSET) & M_REGISTER_OFFSET)
380 1643
381#define S_CHANNEL_ADDR 12 1644#define S_CHANNEL_ADDR 12
1645#define M_CHANNEL_ADDR 0xf
382#define V_CHANNEL_ADDR(x) ((x) << S_CHANNEL_ADDR) 1646#define V_CHANNEL_ADDR(x) ((x) << S_CHANNEL_ADDR)
1647#define G_CHANNEL_ADDR(x) (((x) >> S_CHANNEL_ADDR) & M_CHANNEL_ADDR)
383 1648
384#define S_MODULE_ADDR 16 1649#define S_MODULE_ADDR 16
1650#define M_MODULE_ADDR 0x3
385#define V_MODULE_ADDR(x) ((x) << S_MODULE_ADDR) 1651#define V_MODULE_ADDR(x) ((x) << S_MODULE_ADDR)
1652#define G_MODULE_ADDR(x) (((x) >> S_MODULE_ADDR) & M_MODULE_ADDR)
386 1653
387#define S_BUNDLE_ADDR 20 1654#define S_BUNDLE_ADDR 20
1655#define M_BUNDLE_ADDR 0x3
388#define V_BUNDLE_ADDR(x) ((x) << S_BUNDLE_ADDR) 1656#define V_BUNDLE_ADDR(x) ((x) << S_BUNDLE_ADDR)
1657#define G_BUNDLE_ADDR(x) (((x) >> S_BUNDLE_ADDR) & M_BUNDLE_ADDR)
389 1658
390#define S_SPI4_COMMAND 24 1659#define S_SPI4_COMMAND 24
1660#define M_SPI4_COMMAND 0xff
391#define V_SPI4_COMMAND(x) ((x) << S_SPI4_COMMAND) 1661#define V_SPI4_COMMAND(x) ((x) << S_SPI4_COMMAND)
1662#define G_SPI4_COMMAND(x) (((x) >> S_SPI4_COMMAND) & M_SPI4_COMMAND)
392 1663
393#define A_ESPI_GOSTAT 0x8fc 1664#define A_ESPI_GOSTAT 0x8fc
1665
1666#define S_READ_DATA 0
1667#define M_READ_DATA 0xff
1668#define V_READ_DATA(x) ((x) << S_READ_DATA)
1669#define G_READ_DATA(x) (((x) >> S_READ_DATA) & M_READ_DATA)
1670
394#define S_ESPI_CMD_BUSY 8 1671#define S_ESPI_CMD_BUSY 8
395#define V_ESPI_CMD_BUSY(x) ((x) << S_ESPI_CMD_BUSY) 1672#define V_ESPI_CMD_BUSY(x) ((x) << S_ESPI_CMD_BUSY)
396#define F_ESPI_CMD_BUSY V_ESPI_CMD_BUSY(1U) 1673#define F_ESPI_CMD_BUSY V_ESPI_CMD_BUSY(1U)
397 1674
398/* PL registers */ 1675#define S_ERROR_ACK 9
1676#define V_ERROR_ACK(x) ((x) << S_ERROR_ACK)
1677#define F_ERROR_ACK V_ERROR_ACK(1U)
1678
1679#define S_UNMAPPED_ERR 10
1680#define V_UNMAPPED_ERR(x) ((x) << S_UNMAPPED_ERR)
1681#define F_UNMAPPED_ERR V_UNMAPPED_ERR(1U)
1682
1683#define S_TRANSACTION_TIMER 16
1684#define M_TRANSACTION_TIMER 0xff
1685#define V_TRANSACTION_TIMER(x) ((x) << S_TRANSACTION_TIMER)
1686#define G_TRANSACTION_TIMER(x) (((x) >> S_TRANSACTION_TIMER) & M_TRANSACTION_TIMER)
1687
1688
1689/* ULP registers */
1690#define A_ULP_ULIMIT 0x980
1691#define A_ULP_TAGMASK 0x984
1692#define A_ULP_HREG_INDEX 0x988
1693#define A_ULP_HREG_DATA 0x98c
1694#define A_ULP_INT_ENABLE 0x990
1695#define A_ULP_INT_CAUSE 0x994
399 1696
1697#define S_HREG_PAR_ERR 0
1698#define V_HREG_PAR_ERR(x) ((x) << S_HREG_PAR_ERR)
1699#define F_HREG_PAR_ERR V_HREG_PAR_ERR(1U)
1700
1701#define S_EGRS_DATA_PAR_ERR 1
1702#define V_EGRS_DATA_PAR_ERR(x) ((x) << S_EGRS_DATA_PAR_ERR)
1703#define F_EGRS_DATA_PAR_ERR V_EGRS_DATA_PAR_ERR(1U)
1704
1705#define S_INGRS_DATA_PAR_ERR 2
1706#define V_INGRS_DATA_PAR_ERR(x) ((x) << S_INGRS_DATA_PAR_ERR)
1707#define F_INGRS_DATA_PAR_ERR V_INGRS_DATA_PAR_ERR(1U)
1708
1709#define S_PM_INTR 3
1710#define V_PM_INTR(x) ((x) << S_PM_INTR)
1711#define F_PM_INTR V_PM_INTR(1U)
1712
1713#define S_PM_E2C_SYNC_ERR 4
1714#define V_PM_E2C_SYNC_ERR(x) ((x) << S_PM_E2C_SYNC_ERR)
1715#define F_PM_E2C_SYNC_ERR V_PM_E2C_SYNC_ERR(1U)
1716
1717#define S_PM_C2E_SYNC_ERR 5
1718#define V_PM_C2E_SYNC_ERR(x) ((x) << S_PM_C2E_SYNC_ERR)
1719#define F_PM_C2E_SYNC_ERR V_PM_C2E_SYNC_ERR(1U)
1720
1721#define S_PM_E2C_EMPTY_ERR 6
1722#define V_PM_E2C_EMPTY_ERR(x) ((x) << S_PM_E2C_EMPTY_ERR)
1723#define F_PM_E2C_EMPTY_ERR V_PM_E2C_EMPTY_ERR(1U)
1724
1725#define S_PM_C2E_EMPTY_ERR 7
1726#define V_PM_C2E_EMPTY_ERR(x) ((x) << S_PM_C2E_EMPTY_ERR)
1727#define F_PM_C2E_EMPTY_ERR V_PM_C2E_EMPTY_ERR(1U)
1728
1729#define S_PM_PAR_ERR 8
1730#define M_PM_PAR_ERR 0xffff
1731#define V_PM_PAR_ERR(x) ((x) << S_PM_PAR_ERR)
1732#define G_PM_PAR_ERR(x) (((x) >> S_PM_PAR_ERR) & M_PM_PAR_ERR)
1733
1734#define S_PM_E2C_WRT_FULL 24
1735#define V_PM_E2C_WRT_FULL(x) ((x) << S_PM_E2C_WRT_FULL)
1736#define F_PM_E2C_WRT_FULL V_PM_E2C_WRT_FULL(1U)
1737
1738#define S_PM_C2E_WRT_FULL 25
1739#define V_PM_C2E_WRT_FULL(x) ((x) << S_PM_C2E_WRT_FULL)
1740#define F_PM_C2E_WRT_FULL V_PM_C2E_WRT_FULL(1U)
1741
1742#define A_ULP_PIO_CTRL 0x998
1743
1744/* PL registers */
400#define A_PL_ENABLE 0xa00 1745#define A_PL_ENABLE 0xa00
401 1746
402#define S_PL_INTR_SGE_ERR 0 1747#define S_PL_INTR_SGE_ERR 0
@@ -407,14 +1752,38 @@
407#define V_PL_INTR_SGE_DATA(x) ((x) << S_PL_INTR_SGE_DATA) 1752#define V_PL_INTR_SGE_DATA(x) ((x) << S_PL_INTR_SGE_DATA)
408#define F_PL_INTR_SGE_DATA V_PL_INTR_SGE_DATA(1U) 1753#define F_PL_INTR_SGE_DATA V_PL_INTR_SGE_DATA(1U)
409 1754
1755#define S_PL_INTR_MC3 2
1756#define V_PL_INTR_MC3(x) ((x) << S_PL_INTR_MC3)
1757#define F_PL_INTR_MC3 V_PL_INTR_MC3(1U)
1758
1759#define S_PL_INTR_MC4 3
1760#define V_PL_INTR_MC4(x) ((x) << S_PL_INTR_MC4)
1761#define F_PL_INTR_MC4 V_PL_INTR_MC4(1U)
1762
1763#define S_PL_INTR_MC5 4
1764#define V_PL_INTR_MC5(x) ((x) << S_PL_INTR_MC5)
1765#define F_PL_INTR_MC5 V_PL_INTR_MC5(1U)
1766
1767#define S_PL_INTR_RAT 5
1768#define V_PL_INTR_RAT(x) ((x) << S_PL_INTR_RAT)
1769#define F_PL_INTR_RAT V_PL_INTR_RAT(1U)
1770
410#define S_PL_INTR_TP 6 1771#define S_PL_INTR_TP 6
411#define V_PL_INTR_TP(x) ((x) << S_PL_INTR_TP) 1772#define V_PL_INTR_TP(x) ((x) << S_PL_INTR_TP)
412#define F_PL_INTR_TP V_PL_INTR_TP(1U) 1773#define F_PL_INTR_TP V_PL_INTR_TP(1U)
413 1774
1775#define S_PL_INTR_ULP 7
1776#define V_PL_INTR_ULP(x) ((x) << S_PL_INTR_ULP)
1777#define F_PL_INTR_ULP V_PL_INTR_ULP(1U)
1778
414#define S_PL_INTR_ESPI 8 1779#define S_PL_INTR_ESPI 8
415#define V_PL_INTR_ESPI(x) ((x) << S_PL_INTR_ESPI) 1780#define V_PL_INTR_ESPI(x) ((x) << S_PL_INTR_ESPI)
416#define F_PL_INTR_ESPI V_PL_INTR_ESPI(1U) 1781#define F_PL_INTR_ESPI V_PL_INTR_ESPI(1U)
417 1782
1783#define S_PL_INTR_CSPI 9
1784#define V_PL_INTR_CSPI(x) ((x) << S_PL_INTR_CSPI)
1785#define F_PL_INTR_CSPI V_PL_INTR_CSPI(1U)
1786
418#define S_PL_INTR_PCIX 10 1787#define S_PL_INTR_PCIX 10
419#define V_PL_INTR_PCIX(x) ((x) << S_PL_INTR_PCIX) 1788#define V_PL_INTR_PCIX(x) ((x) << S_PL_INTR_PCIX)
420#define F_PL_INTR_PCIX V_PL_INTR_PCIX(1U) 1789#define F_PL_INTR_PCIX V_PL_INTR_PCIX(1U)
@@ -426,43 +1795,374 @@
426#define A_PL_CAUSE 0xa04 1795#define A_PL_CAUSE 0xa04
427 1796
428/* MC5 registers */ 1797/* MC5 registers */
429
430#define A_MC5_CONFIG 0xc04 1798#define A_MC5_CONFIG 0xc04
431 1799
1800#define S_MODE 0
1801#define V_MODE(x) ((x) << S_MODE)
1802#define F_MODE V_MODE(1U)
1803
432#define S_TCAM_RESET 1 1804#define S_TCAM_RESET 1
433#define V_TCAM_RESET(x) ((x) << S_TCAM_RESET) 1805#define V_TCAM_RESET(x) ((x) << S_TCAM_RESET)
434#define F_TCAM_RESET V_TCAM_RESET(1U) 1806#define F_TCAM_RESET V_TCAM_RESET(1U)
435 1807
1808#define S_TCAM_READY 2
1809#define V_TCAM_READY(x) ((x) << S_TCAM_READY)
1810#define F_TCAM_READY V_TCAM_READY(1U)
1811
1812#define S_DBGI_ENABLE 4
1813#define V_DBGI_ENABLE(x) ((x) << S_DBGI_ENABLE)
1814#define F_DBGI_ENABLE V_DBGI_ENABLE(1U)
1815
436#define S_M_BUS_ENABLE 5 1816#define S_M_BUS_ENABLE 5
437#define V_M_BUS_ENABLE(x) ((x) << S_M_BUS_ENABLE) 1817#define V_M_BUS_ENABLE(x) ((x) << S_M_BUS_ENABLE)
438#define F_M_BUS_ENABLE V_M_BUS_ENABLE(1U) 1818#define F_M_BUS_ENABLE V_M_BUS_ENABLE(1U)
439 1819
440/* PCICFG registers */ 1820#define S_PARITY_ENABLE 6
1821#define V_PARITY_ENABLE(x) ((x) << S_PARITY_ENABLE)
1822#define F_PARITY_ENABLE V_PARITY_ENABLE(1U)
1823
1824#define S_SYN_ISSUE_MODE 7
1825#define M_SYN_ISSUE_MODE 0x3
1826#define V_SYN_ISSUE_MODE(x) ((x) << S_SYN_ISSUE_MODE)
1827#define G_SYN_ISSUE_MODE(x) (((x) >> S_SYN_ISSUE_MODE) & M_SYN_ISSUE_MODE)
1828
1829#define S_BUILD 16
1830#define V_BUILD(x) ((x) << S_BUILD)
1831#define F_BUILD V_BUILD(1U)
1832
1833#define S_COMPRESSION_ENABLE 17
1834#define V_COMPRESSION_ENABLE(x) ((x) << S_COMPRESSION_ENABLE)
1835#define F_COMPRESSION_ENABLE V_COMPRESSION_ENABLE(1U)
1836
1837#define S_NUM_LIP 18
1838#define M_NUM_LIP 0x3f
1839#define V_NUM_LIP(x) ((x) << S_NUM_LIP)
1840#define G_NUM_LIP(x) (((x) >> S_NUM_LIP) & M_NUM_LIP)
1841
1842#define S_TCAM_PART_CNT 24
1843#define M_TCAM_PART_CNT 0x3
1844#define V_TCAM_PART_CNT(x) ((x) << S_TCAM_PART_CNT)
1845#define G_TCAM_PART_CNT(x) (((x) >> S_TCAM_PART_CNT) & M_TCAM_PART_CNT)
1846
1847#define S_TCAM_PART_TYPE 26
1848#define M_TCAM_PART_TYPE 0x3
1849#define V_TCAM_PART_TYPE(x) ((x) << S_TCAM_PART_TYPE)
1850#define G_TCAM_PART_TYPE(x) (((x) >> S_TCAM_PART_TYPE) & M_TCAM_PART_TYPE)
1851
1852#define S_TCAM_PART_SIZE 28
1853#define M_TCAM_PART_SIZE 0x3
1854#define V_TCAM_PART_SIZE(x) ((x) << S_TCAM_PART_SIZE)
1855#define G_TCAM_PART_SIZE(x) (((x) >> S_TCAM_PART_SIZE) & M_TCAM_PART_SIZE)
1856
1857#define S_TCAM_PART_TYPE_HI 30
1858#define V_TCAM_PART_TYPE_HI(x) ((x) << S_TCAM_PART_TYPE_HI)
1859#define F_TCAM_PART_TYPE_HI V_TCAM_PART_TYPE_HI(1U)
1860
1861#define A_MC5_SIZE 0xc08
1862
1863#define S_SIZE 0
1864#define M_SIZE 0x3fffff
1865#define V_SIZE(x) ((x) << S_SIZE)
1866#define G_SIZE(x) (((x) >> S_SIZE) & M_SIZE)
1867
1868#define A_MC5_ROUTING_TABLE_INDEX 0xc0c
441 1869
1870#define S_START_OF_ROUTING_TABLE 0
1871#define M_START_OF_ROUTING_TABLE 0x3fffff
1872#define V_START_OF_ROUTING_TABLE(x) ((x) << S_START_OF_ROUTING_TABLE)
1873#define G_START_OF_ROUTING_TABLE(x) (((x) >> S_START_OF_ROUTING_TABLE) & M_START_OF_ROUTING_TABLE)
1874
1875#define A_MC5_SERVER_INDEX 0xc14
1876
1877#define S_START_OF_SERVER_INDEX 0
1878#define M_START_OF_SERVER_INDEX 0x3fffff
1879#define V_START_OF_SERVER_INDEX(x) ((x) << S_START_OF_SERVER_INDEX)
1880#define G_START_OF_SERVER_INDEX(x) (((x) >> S_START_OF_SERVER_INDEX) & M_START_OF_SERVER_INDEX)
1881
1882#define A_MC5_LIP_RAM_ADDR 0xc18
1883
1884#define S_LOCAL_IP_RAM_ADDR 0
1885#define M_LOCAL_IP_RAM_ADDR 0x3f
1886#define V_LOCAL_IP_RAM_ADDR(x) ((x) << S_LOCAL_IP_RAM_ADDR)
1887#define G_LOCAL_IP_RAM_ADDR(x) (((x) >> S_LOCAL_IP_RAM_ADDR) & M_LOCAL_IP_RAM_ADDR)
1888
1889#define S_RAM_WRITE_ENABLE 8
1890#define V_RAM_WRITE_ENABLE(x) ((x) << S_RAM_WRITE_ENABLE)
1891#define F_RAM_WRITE_ENABLE V_RAM_WRITE_ENABLE(1U)
1892
1893#define A_MC5_LIP_RAM_DATA 0xc1c
1894#define A_MC5_RSP_LATENCY 0xc20
1895
1896#define S_SEARCH_RESPONSE_LATENCY 0
1897#define M_SEARCH_RESPONSE_LATENCY 0x1f
1898#define V_SEARCH_RESPONSE_LATENCY(x) ((x) << S_SEARCH_RESPONSE_LATENCY)
1899#define G_SEARCH_RESPONSE_LATENCY(x) (((x) >> S_SEARCH_RESPONSE_LATENCY) & M_SEARCH_RESPONSE_LATENCY)
1900
1901#define S_LEARN_RESPONSE_LATENCY 8
1902#define M_LEARN_RESPONSE_LATENCY 0x1f
1903#define V_LEARN_RESPONSE_LATENCY(x) ((x) << S_LEARN_RESPONSE_LATENCY)
1904#define G_LEARN_RESPONSE_LATENCY(x) (((x) >> S_LEARN_RESPONSE_LATENCY) & M_LEARN_RESPONSE_LATENCY)
1905
1906#define A_MC5_PARITY_LATENCY 0xc24
1907
1908#define S_SRCHLAT 0
1909#define M_SRCHLAT 0x1f
1910#define V_SRCHLAT(x) ((x) << S_SRCHLAT)
1911#define G_SRCHLAT(x) (((x) >> S_SRCHLAT) & M_SRCHLAT)
1912
1913#define S_PARLAT 8
1914#define M_PARLAT 0x1f
1915#define V_PARLAT(x) ((x) << S_PARLAT)
1916#define G_PARLAT(x) (((x) >> S_PARLAT) & M_PARLAT)
1917
1918#define A_MC5_WR_LRN_VERIFY 0xc28
1919
1920#define S_POVEREN 0
1921#define V_POVEREN(x) ((x) << S_POVEREN)
1922#define F_POVEREN V_POVEREN(1U)
1923
1924#define S_LRNVEREN 1
1925#define V_LRNVEREN(x) ((x) << S_LRNVEREN)
1926#define F_LRNVEREN V_LRNVEREN(1U)
1927
1928#define S_VWVEREN 2
1929#define V_VWVEREN(x) ((x) << S_VWVEREN)
1930#define F_VWVEREN V_VWVEREN(1U)
1931
1932#define A_MC5_PART_ID_INDEX 0xc2c
1933
1934#define S_IDINDEX 0
1935#define M_IDINDEX 0xf
1936#define V_IDINDEX(x) ((x) << S_IDINDEX)
1937#define G_IDINDEX(x) (((x) >> S_IDINDEX) & M_IDINDEX)
1938
1939#define A_MC5_RESET_MAX 0xc30
1940
1941#define S_RSTMAX 0
1942#define M_RSTMAX 0x1ff
1943#define V_RSTMAX(x) ((x) << S_RSTMAX)
1944#define G_RSTMAX(x) (((x) >> S_RSTMAX) & M_RSTMAX)
1945
1946#define A_MC5_INT_ENABLE 0xc40
1947
1948#define S_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR 0
1949#define V_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR(x) ((x) << S_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR)
1950#define F_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR V_MC5_INT_HIT_OUT_ACTIVE_REGION_ERR(1U)
1951
1952#define S_MC5_INT_HIT_IN_ACTIVE_REGION_ERR 1
1953#define V_MC5_INT_HIT_IN_ACTIVE_REGION_ERR(x) ((x) << S_MC5_INT_HIT_IN_ACTIVE_REGION_ERR)
1954#define F_MC5_INT_HIT_IN_ACTIVE_REGION_ERR V_MC5_INT_HIT_IN_ACTIVE_REGION_ERR(1U)
1955
1956#define S_MC5_INT_HIT_IN_RT_REGION_ERR 2
1957#define V_MC5_INT_HIT_IN_RT_REGION_ERR(x) ((x) << S_MC5_INT_HIT_IN_RT_REGION_ERR)
1958#define F_MC5_INT_HIT_IN_RT_REGION_ERR V_MC5_INT_HIT_IN_RT_REGION_ERR(1U)
1959
1960#define S_MC5_INT_MISS_ERR 3
1961#define V_MC5_INT_MISS_ERR(x) ((x) << S_MC5_INT_MISS_ERR)
1962#define F_MC5_INT_MISS_ERR V_MC5_INT_MISS_ERR(1U)
1963
1964#define S_MC5_INT_LIP0_ERR 4
1965#define V_MC5_INT_LIP0_ERR(x) ((x) << S_MC5_INT_LIP0_ERR)
1966#define F_MC5_INT_LIP0_ERR V_MC5_INT_LIP0_ERR(1U)
1967
1968#define S_MC5_INT_LIP_MISS_ERR 5
1969#define V_MC5_INT_LIP_MISS_ERR(x) ((x) << S_MC5_INT_LIP_MISS_ERR)
1970#define F_MC5_INT_LIP_MISS_ERR V_MC5_INT_LIP_MISS_ERR(1U)
1971
1972#define S_MC5_INT_PARITY_ERR 6
1973#define V_MC5_INT_PARITY_ERR(x) ((x) << S_MC5_INT_PARITY_ERR)
1974#define F_MC5_INT_PARITY_ERR V_MC5_INT_PARITY_ERR(1U)
1975
1976#define S_MC5_INT_ACTIVE_REGION_FULL 7
1977#define V_MC5_INT_ACTIVE_REGION_FULL(x) ((x) << S_MC5_INT_ACTIVE_REGION_FULL)
1978#define F_MC5_INT_ACTIVE_REGION_FULL V_MC5_INT_ACTIVE_REGION_FULL(1U)
1979
1980#define S_MC5_INT_NFA_SRCH_ERR 8
1981#define V_MC5_INT_NFA_SRCH_ERR(x) ((x) << S_MC5_INT_NFA_SRCH_ERR)
1982#define F_MC5_INT_NFA_SRCH_ERR V_MC5_INT_NFA_SRCH_ERR(1U)
1983
1984#define S_MC5_INT_SYN_COOKIE 9
1985#define V_MC5_INT_SYN_COOKIE(x) ((x) << S_MC5_INT_SYN_COOKIE)
1986#define F_MC5_INT_SYN_COOKIE V_MC5_INT_SYN_COOKIE(1U)
1987
1988#define S_MC5_INT_SYN_COOKIE_BAD 10
1989#define V_MC5_INT_SYN_COOKIE_BAD(x) ((x) << S_MC5_INT_SYN_COOKIE_BAD)
1990#define F_MC5_INT_SYN_COOKIE_BAD V_MC5_INT_SYN_COOKIE_BAD(1U)
1991
1992#define S_MC5_INT_SYN_COOKIE_OFF 11
1993#define V_MC5_INT_SYN_COOKIE_OFF(x) ((x) << S_MC5_INT_SYN_COOKIE_OFF)
1994#define F_MC5_INT_SYN_COOKIE_OFF V_MC5_INT_SYN_COOKIE_OFF(1U)
1995
1996#define S_MC5_INT_UNKNOWN_CMD 15
1997#define V_MC5_INT_UNKNOWN_CMD(x) ((x) << S_MC5_INT_UNKNOWN_CMD)
1998#define F_MC5_INT_UNKNOWN_CMD V_MC5_INT_UNKNOWN_CMD(1U)
1999
2000#define S_MC5_INT_REQUESTQ_PARITY_ERR 16
2001#define V_MC5_INT_REQUESTQ_PARITY_ERR(x) ((x) << S_MC5_INT_REQUESTQ_PARITY_ERR)
2002#define F_MC5_INT_REQUESTQ_PARITY_ERR V_MC5_INT_REQUESTQ_PARITY_ERR(1U)
2003
2004#define S_MC5_INT_DISPATCHQ_PARITY_ERR 17
2005#define V_MC5_INT_DISPATCHQ_PARITY_ERR(x) ((x) << S_MC5_INT_DISPATCHQ_PARITY_ERR)
2006#define F_MC5_INT_DISPATCHQ_PARITY_ERR V_MC5_INT_DISPATCHQ_PARITY_ERR(1U)
2007
2008#define S_MC5_INT_DEL_ACT_EMPTY 18
2009#define V_MC5_INT_DEL_ACT_EMPTY(x) ((x) << S_MC5_INT_DEL_ACT_EMPTY)
2010#define F_MC5_INT_DEL_ACT_EMPTY V_MC5_INT_DEL_ACT_EMPTY(1U)
2011
2012#define A_MC5_INT_CAUSE 0xc44
2013#define A_MC5_INT_TID 0xc48
2014#define A_MC5_INT_PTID 0xc4c
2015#define A_MC5_DBGI_CONFIG 0xc74
2016#define A_MC5_DBGI_REQ_CMD 0xc78
2017
2018#define S_CMDMODE 0
2019#define M_CMDMODE 0x7
2020#define V_CMDMODE(x) ((x) << S_CMDMODE)
2021#define G_CMDMODE(x) (((x) >> S_CMDMODE) & M_CMDMODE)
2022
2023#define S_SADRSEL 4
2024#define V_SADRSEL(x) ((x) << S_SADRSEL)
2025#define F_SADRSEL V_SADRSEL(1U)
2026
2027#define S_WRITE_BURST_SIZE 22
2028#define M_WRITE_BURST_SIZE 0x3ff
2029#define V_WRITE_BURST_SIZE(x) ((x) << S_WRITE_BURST_SIZE)
2030#define G_WRITE_BURST_SIZE(x) (((x) >> S_WRITE_BURST_SIZE) & M_WRITE_BURST_SIZE)
2031
2032#define A_MC5_DBGI_REQ_ADDR0 0xc7c
2033#define A_MC5_DBGI_REQ_ADDR1 0xc80
2034#define A_MC5_DBGI_REQ_ADDR2 0xc84
2035#define A_MC5_DBGI_REQ_DATA0 0xc88
2036#define A_MC5_DBGI_REQ_DATA1 0xc8c
2037#define A_MC5_DBGI_REQ_DATA2 0xc90
2038#define A_MC5_DBGI_REQ_DATA3 0xc94
2039#define A_MC5_DBGI_REQ_DATA4 0xc98
2040#define A_MC5_DBGI_REQ_MASK0 0xc9c
2041#define A_MC5_DBGI_REQ_MASK1 0xca0
2042#define A_MC5_DBGI_REQ_MASK2 0xca4
2043#define A_MC5_DBGI_REQ_MASK3 0xca8
2044#define A_MC5_DBGI_REQ_MASK4 0xcac
2045#define A_MC5_DBGI_RSP_STATUS 0xcb0
2046
2047#define S_DBGI_RSP_VALID 0
2048#define V_DBGI_RSP_VALID(x) ((x) << S_DBGI_RSP_VALID)
2049#define F_DBGI_RSP_VALID V_DBGI_RSP_VALID(1U)
2050
2051#define S_DBGI_RSP_HIT 1
2052#define V_DBGI_RSP_HIT(x) ((x) << S_DBGI_RSP_HIT)
2053#define F_DBGI_RSP_HIT V_DBGI_RSP_HIT(1U)
2054
2055#define S_DBGI_RSP_ERR 2
2056#define V_DBGI_RSP_ERR(x) ((x) << S_DBGI_RSP_ERR)
2057#define F_DBGI_RSP_ERR V_DBGI_RSP_ERR(1U)
2058
2059#define S_DBGI_RSP_ERR_REASON 8
2060#define M_DBGI_RSP_ERR_REASON 0x7
2061#define V_DBGI_RSP_ERR_REASON(x) ((x) << S_DBGI_RSP_ERR_REASON)
2062#define G_DBGI_RSP_ERR_REASON(x) (((x) >> S_DBGI_RSP_ERR_REASON) & M_DBGI_RSP_ERR_REASON)
2063
2064#define A_MC5_DBGI_RSP_DATA0 0xcb4
2065#define A_MC5_DBGI_RSP_DATA1 0xcb8
2066#define A_MC5_DBGI_RSP_DATA2 0xcbc
2067#define A_MC5_DBGI_RSP_DATA3 0xcc0
2068#define A_MC5_DBGI_RSP_DATA4 0xcc4
2069#define A_MC5_DBGI_RSP_LAST_CMD 0xcc8
2070#define A_MC5_POPEN_DATA_WR_CMD 0xccc
2071#define A_MC5_POPEN_MASK_WR_CMD 0xcd0
2072#define A_MC5_AOPEN_SRCH_CMD 0xcd4
2073#define A_MC5_AOPEN_LRN_CMD 0xcd8
2074#define A_MC5_SYN_SRCH_CMD 0xcdc
2075#define A_MC5_SYN_LRN_CMD 0xce0
2076#define A_MC5_ACK_SRCH_CMD 0xce4
2077#define A_MC5_ACK_LRN_CMD 0xce8
2078#define A_MC5_ILOOKUP_CMD 0xcec
2079#define A_MC5_ELOOKUP_CMD 0xcf0
2080#define A_MC5_DATA_WRITE_CMD 0xcf4
2081#define A_MC5_DATA_READ_CMD 0xcf8
2082#define A_MC5_MASK_WRITE_CMD 0xcfc
2083
2084/* PCICFG registers */
442#define A_PCICFG_PM_CSR 0x44 2085#define A_PCICFG_PM_CSR 0x44
443#define A_PCICFG_VPD_ADDR 0x4a 2086#define A_PCICFG_VPD_ADDR 0x4a
444 2087
2088#define S_VPD_ADDR 0
2089#define M_VPD_ADDR 0x7fff
2090#define V_VPD_ADDR(x) ((x) << S_VPD_ADDR)
2091#define G_VPD_ADDR(x) (((x) >> S_VPD_ADDR) & M_VPD_ADDR)
2092
445#define S_VPD_OP_FLAG 15 2093#define S_VPD_OP_FLAG 15
446#define V_VPD_OP_FLAG(x) ((x) << S_VPD_OP_FLAG) 2094#define V_VPD_OP_FLAG(x) ((x) << S_VPD_OP_FLAG)
447#define F_VPD_OP_FLAG V_VPD_OP_FLAG(1U) 2095#define F_VPD_OP_FLAG V_VPD_OP_FLAG(1U)
448 2096
449#define A_PCICFG_VPD_DATA 0x4c 2097#define A_PCICFG_VPD_DATA 0x4c
450 2098#define A_PCICFG_PCIX_CMD 0x60
451#define A_PCICFG_INTR_ENABLE 0xf4 2099#define A_PCICFG_INTR_ENABLE 0xf4
452#define A_PCICFG_INTR_CAUSE 0xf8
453 2100
2101#define S_MASTER_PARITY_ERR 0
2102#define V_MASTER_PARITY_ERR(x) ((x) << S_MASTER_PARITY_ERR)
2103#define F_MASTER_PARITY_ERR V_MASTER_PARITY_ERR(1U)
2104
2105#define S_SIG_TARGET_ABORT 1
2106#define V_SIG_TARGET_ABORT(x) ((x) << S_SIG_TARGET_ABORT)
2107#define F_SIG_TARGET_ABORT V_SIG_TARGET_ABORT(1U)
2108
2109#define S_RCV_TARGET_ABORT 2
2110#define V_RCV_TARGET_ABORT(x) ((x) << S_RCV_TARGET_ABORT)
2111#define F_RCV_TARGET_ABORT V_RCV_TARGET_ABORT(1U)
2112
2113#define S_RCV_MASTER_ABORT 3
2114#define V_RCV_MASTER_ABORT(x) ((x) << S_RCV_MASTER_ABORT)
2115#define F_RCV_MASTER_ABORT V_RCV_MASTER_ABORT(1U)
2116
2117#define S_SIG_SYS_ERR 4
2118#define V_SIG_SYS_ERR(x) ((x) << S_SIG_SYS_ERR)
2119#define F_SIG_SYS_ERR V_SIG_SYS_ERR(1U)
2120
2121#define S_DET_PARITY_ERR 5
2122#define V_DET_PARITY_ERR(x) ((x) << S_DET_PARITY_ERR)
2123#define F_DET_PARITY_ERR V_DET_PARITY_ERR(1U)
2124
2125#define S_PIO_PARITY_ERR 6
2126#define V_PIO_PARITY_ERR(x) ((x) << S_PIO_PARITY_ERR)
2127#define F_PIO_PARITY_ERR V_PIO_PARITY_ERR(1U)
2128
2129#define S_WF_PARITY_ERR 7
2130#define V_WF_PARITY_ERR(x) ((x) << S_WF_PARITY_ERR)
2131#define F_WF_PARITY_ERR V_WF_PARITY_ERR(1U)
2132
2133#define S_RF_PARITY_ERR 8
2134#define M_RF_PARITY_ERR 0x3
2135#define V_RF_PARITY_ERR(x) ((x) << S_RF_PARITY_ERR)
2136#define G_RF_PARITY_ERR(x) (((x) >> S_RF_PARITY_ERR) & M_RF_PARITY_ERR)
2137
2138#define S_CF_PARITY_ERR 10
2139#define M_CF_PARITY_ERR 0x3
2140#define V_CF_PARITY_ERR(x) ((x) << S_CF_PARITY_ERR)
2141#define G_CF_PARITY_ERR(x) (((x) >> S_CF_PARITY_ERR) & M_CF_PARITY_ERR)
2142
2143#define A_PCICFG_INTR_CAUSE 0xf8
454#define A_PCICFG_MODE 0xfc 2144#define A_PCICFG_MODE 0xfc
455 2145
456#define S_PCI_MODE_64BIT 0 2146#define S_PCI_MODE_64BIT 0
457#define V_PCI_MODE_64BIT(x) ((x) << S_PCI_MODE_64BIT) 2147#define V_PCI_MODE_64BIT(x) ((x) << S_PCI_MODE_64BIT)
458#define F_PCI_MODE_64BIT V_PCI_MODE_64BIT(1U) 2148#define F_PCI_MODE_64BIT V_PCI_MODE_64BIT(1U)
459 2149
2150#define S_PCI_MODE_66MHZ 1
2151#define V_PCI_MODE_66MHZ(x) ((x) << S_PCI_MODE_66MHZ)
2152#define F_PCI_MODE_66MHZ V_PCI_MODE_66MHZ(1U)
2153
2154#define S_PCI_MODE_PCIX_INITPAT 2
2155#define M_PCI_MODE_PCIX_INITPAT 0x7
2156#define V_PCI_MODE_PCIX_INITPAT(x) ((x) << S_PCI_MODE_PCIX_INITPAT)
2157#define G_PCI_MODE_PCIX_INITPAT(x) (((x) >> S_PCI_MODE_PCIX_INITPAT) & M_PCI_MODE_PCIX_INITPAT)
2158
460#define S_PCI_MODE_PCIX 5 2159#define S_PCI_MODE_PCIX 5
461#define V_PCI_MODE_PCIX(x) ((x) << S_PCI_MODE_PCIX) 2160#define V_PCI_MODE_PCIX(x) ((x) << S_PCI_MODE_PCIX)
462#define F_PCI_MODE_PCIX V_PCI_MODE_PCIX(1U) 2161#define F_PCI_MODE_PCIX V_PCI_MODE_PCIX(1U)
463 2162
464#define S_PCI_MODE_CLK 6 2163#define S_PCI_MODE_CLK 6
465#define M_PCI_MODE_CLK 0x3 2164#define M_PCI_MODE_CLK 0x3
2165#define V_PCI_MODE_CLK(x) ((x) << S_PCI_MODE_CLK)
466#define G_PCI_MODE_CLK(x) (((x) >> S_PCI_MODE_CLK) & M_PCI_MODE_CLK) 2166#define G_PCI_MODE_CLK(x) (((x) >> S_PCI_MODE_CLK) & M_PCI_MODE_CLK)
467 2167
468#endif /* _CXGB_REGS_H_ */ 2168#endif /* _CXGB_REGS_H_ */
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 9799c12380fc..0ca8d876e16f 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -42,12 +42,14 @@
42#include <linux/types.h> 42#include <linux/types.h>
43#include <linux/errno.h> 43#include <linux/errno.h>
44#include <linux/pci.h> 44#include <linux/pci.h>
45#include <linux/ktime.h>
45#include <linux/netdevice.h> 46#include <linux/netdevice.h>
46#include <linux/etherdevice.h> 47#include <linux/etherdevice.h>
47#include <linux/if_vlan.h> 48#include <linux/if_vlan.h>
48#include <linux/skbuff.h> 49#include <linux/skbuff.h>
49#include <linux/init.h> 50#include <linux/init.h>
50#include <linux/mm.h> 51#include <linux/mm.h>
52#include <linux/tcp.h>
51#include <linux/ip.h> 53#include <linux/ip.h>
52#include <linux/in.h> 54#include <linux/in.h>
53#include <linux/if_arp.h> 55#include <linux/if_arp.h>
@@ -57,10 +59,8 @@
57#include "regs.h" 59#include "regs.h"
58#include "espi.h" 60#include "espi.h"
59 61
60 62/* This belongs in if_ether.h */
61#ifdef NETIF_F_TSO 63#define ETH_P_CPL5 0xf
62#include <linux/tcp.h>
63#endif
64 64
65#define SGE_CMDQ_N 2 65#define SGE_CMDQ_N 2
66#define SGE_FREELQ_N 2 66#define SGE_FREELQ_N 2
@@ -73,6 +73,7 @@
73#define SGE_INTRTIMER_NRES 1000 73#define SGE_INTRTIMER_NRES 1000
74#define SGE_RX_COPY_THRES 256 74#define SGE_RX_COPY_THRES 256
75#define SGE_RX_SM_BUF_SIZE 1536 75#define SGE_RX_SM_BUF_SIZE 1536
76#define SGE_TX_DESC_MAX_PLEN 16384
76 77
77# define SGE_RX_DROP_THRES 2 78# define SGE_RX_DROP_THRES 2
78 79
@@ -184,17 +185,17 @@ struct cmdQ {
184 unsigned long status; /* HW DMA fetch status */ 185 unsigned long status; /* HW DMA fetch status */
185 unsigned int in_use; /* # of in-use command descriptors */ 186 unsigned int in_use; /* # of in-use command descriptors */
186 unsigned int size; /* # of descriptors */ 187 unsigned int size; /* # of descriptors */
187 unsigned int processed; /* total # of descs HW has processed */ 188 unsigned int processed; /* total # of descs HW has processed */
188 unsigned int cleaned; /* total # of descs SW has reclaimed */ 189 unsigned int cleaned; /* total # of descs SW has reclaimed */
189 unsigned int stop_thres; /* SW TX queue suspend threshold */ 190 unsigned int stop_thres; /* SW TX queue suspend threshold */
190 u16 pidx; /* producer index (SW) */ 191 u16 pidx; /* producer index (SW) */
191 u16 cidx; /* consumer index (HW) */ 192 u16 cidx; /* consumer index (HW) */
192 u8 genbit; /* current generation (=valid) bit */ 193 u8 genbit; /* current generation (=valid) bit */
193 u8 sop; /* is next entry start of packet? */ 194 u8 sop; /* is next entry start of packet? */
194 struct cmdQ_e *entries; /* HW command descriptor Q */ 195 struct cmdQ_e *entries; /* HW command descriptor Q */
195 struct cmdQ_ce *centries; /* SW command context descriptor Q */ 196 struct cmdQ_ce *centries; /* SW command context descriptor Q */
196 spinlock_t lock; /* Lock to protect cmdQ enqueuing */
197 dma_addr_t dma_addr; /* DMA addr HW command descriptor Q */ 197 dma_addr_t dma_addr; /* DMA addr HW command descriptor Q */
198 spinlock_t lock; /* Lock to protect cmdQ enqueuing */
198}; 199};
199 200
200struct freelQ { 201struct freelQ {
@@ -203,8 +204,8 @@ struct freelQ {
203 u16 pidx; /* producer index (SW) */ 204 u16 pidx; /* producer index (SW) */
204 u16 cidx; /* consumer index (HW) */ 205 u16 cidx; /* consumer index (HW) */
205 u16 rx_buffer_size; /* Buffer size on this free list */ 206 u16 rx_buffer_size; /* Buffer size on this free list */
206 u16 dma_offset; /* DMA offset to align IP headers */ 207 u16 dma_offset; /* DMA offset to align IP headers */
207 u16 recycleq_idx; /* skb recycle q to use */ 208 u16 recycleq_idx; /* skb recycle q to use */
208 u8 genbit; /* current generation (=valid) bit */ 209 u8 genbit; /* current generation (=valid) bit */
209 struct freelQ_e *entries; /* HW freelist descriptor Q */ 210 struct freelQ_e *entries; /* HW freelist descriptor Q */
210 struct freelQ_ce *centries; /* SW freelist context descriptor Q */ 211 struct freelQ_ce *centries; /* SW freelist context descriptor Q */
@@ -226,6 +227,29 @@ enum {
226 CMDQ_STAT_LAST_PKT_DB = 2 /* last packet rung the doorbell */ 227 CMDQ_STAT_LAST_PKT_DB = 2 /* last packet rung the doorbell */
227}; 228};
228 229
230/* T204 TX SW scheduler */
231
232/* Per T204 TX port */
233struct sched_port {
234 unsigned int avail; /* available bits - quota */
235 unsigned int drain_bits_per_1024ns; /* drain rate */
236 unsigned int speed; /* drain rate, mbps */
237 unsigned int mtu; /* mtu size */
238 struct sk_buff_head skbq; /* pending skbs */
239};
240
241/* Per T204 device */
242struct sched {
243 ktime_t last_updated; /* last time quotas were computed */
244 unsigned int max_avail; /* max bits to be sent to any port */
245 unsigned int port; /* port index (round robin ports) */
246 unsigned int num; /* num skbs in per port queues */
247 struct sched_port p[MAX_NPORTS];
248 struct tasklet_struct sched_tsk;/* tasklet used to run scheduler */
249};
250static void restart_sched(unsigned long);
251
252
229/* 253/*
230 * Main SGE data structure 254 * Main SGE data structure
231 * 255 *
@@ -243,18 +267,240 @@ struct sge {
243 unsigned int rx_pkt_pad; /* RX padding for L2 packets */ 267 unsigned int rx_pkt_pad; /* RX padding for L2 packets */
244 unsigned int jumbo_fl; /* jumbo freelist Q index */ 268 unsigned int jumbo_fl; /* jumbo freelist Q index */
245 unsigned int intrtimer_nres; /* no-resource interrupt timer */ 269 unsigned int intrtimer_nres; /* no-resource interrupt timer */
246 unsigned int fixed_intrtimer;/* non-adaptive interrupt timer */ 270 unsigned int fixed_intrtimer;/* non-adaptive interrupt timer */
247 struct timer_list tx_reclaim_timer; /* reclaims TX buffers */ 271 struct timer_list tx_reclaim_timer; /* reclaims TX buffers */
248 struct timer_list espibug_timer; 272 struct timer_list espibug_timer;
249 unsigned int espibug_timeout; 273 unsigned long espibug_timeout;
250 struct sk_buff *espibug_skb; 274 struct sk_buff *espibug_skb[MAX_NPORTS];
251 u32 sge_control; /* shadow value of sge control reg */ 275 u32 sge_control; /* shadow value of sge control reg */
252 struct sge_intr_counts stats; 276 struct sge_intr_counts stats;
253 struct sge_port_stats port_stats[MAX_NPORTS]; 277 struct sge_port_stats *port_stats[MAX_NPORTS];
278 struct sched *tx_sched;
254 struct cmdQ cmdQ[SGE_CMDQ_N] ____cacheline_aligned_in_smp; 279 struct cmdQ cmdQ[SGE_CMDQ_N] ____cacheline_aligned_in_smp;
255}; 280};
256 281
257/* 282/*
283 * stop tasklet and free all pending skb's
284 */
285static void tx_sched_stop(struct sge *sge)
286{
287 struct sched *s = sge->tx_sched;
288 int i;
289
290 tasklet_kill(&s->sched_tsk);
291
292 for (i = 0; i < MAX_NPORTS; i++)
293 __skb_queue_purge(&s->p[s->port].skbq);
294}
295
296/*
297 * t1_sched_update_parms() is called when the MTU or link speed changes. It
298 * re-computes scheduler parameters to scope with the change.
299 */
300unsigned int t1_sched_update_parms(struct sge *sge, unsigned int port,
301 unsigned int mtu, unsigned int speed)
302{
303 struct sched *s = sge->tx_sched;
304 struct sched_port *p = &s->p[port];
305 unsigned int max_avail_segs;
306
307 pr_debug("t1_sched_update_params mtu=%d speed=%d\n", mtu, speed);
308 if (speed)
309 p->speed = speed;
310 if (mtu)
311 p->mtu = mtu;
312
313 if (speed || mtu) {
314 unsigned long long drain = 1024ULL * p->speed * (p->mtu - 40);
315 do_div(drain, (p->mtu + 50) * 1000);
316 p->drain_bits_per_1024ns = (unsigned int) drain;
317
318 if (p->speed < 1000)
319 p->drain_bits_per_1024ns =
320 90 * p->drain_bits_per_1024ns / 100;
321 }
322
323 if (board_info(sge->adapter)->board == CHBT_BOARD_CHT204) {
324 p->drain_bits_per_1024ns -= 16;
325 s->max_avail = max(4096U, p->mtu + 16 + 14 + 4);
326 max_avail_segs = max(1U, 4096 / (p->mtu - 40));
327 } else {
328 s->max_avail = 16384;
329 max_avail_segs = max(1U, 9000 / (p->mtu - 40));
330 }
331
332 pr_debug("t1_sched_update_parms: mtu %u speed %u max_avail %u "
333 "max_avail_segs %u drain_bits_per_1024ns %u\n", p->mtu,
334 p->speed, s->max_avail, max_avail_segs,
335 p->drain_bits_per_1024ns);
336
337 return max_avail_segs * (p->mtu - 40);
338}
339
340/*
341 * t1_sched_max_avail_bytes() tells the scheduler the maximum amount of
342 * data that can be pushed per port.
343 */
344void t1_sched_set_max_avail_bytes(struct sge *sge, unsigned int val)
345{
346 struct sched *s = sge->tx_sched;
347 unsigned int i;
348
349 s->max_avail = val;
350 for (i = 0; i < MAX_NPORTS; i++)
351 t1_sched_update_parms(sge, i, 0, 0);
352}
353
354/*
355 * t1_sched_set_drain_bits_per_us() tells the scheduler at which rate a port
356 * is draining.
357 */
358void t1_sched_set_drain_bits_per_us(struct sge *sge, unsigned int port,
359 unsigned int val)
360{
361 struct sched *s = sge->tx_sched;
362 struct sched_port *p = &s->p[port];
363 p->drain_bits_per_1024ns = val * 1024 / 1000;
364 t1_sched_update_parms(sge, port, 0, 0);
365}
366
367
368/*
369 * get_clock() implements a ns clock (see ktime_get)
370 */
371static inline ktime_t get_clock(void)
372{
373 struct timespec ts;
374
375 ktime_get_ts(&ts);
376 return timespec_to_ktime(ts);
377}
378
379/*
380 * tx_sched_init() allocates resources and does basic initialization.
381 */
382static int tx_sched_init(struct sge *sge)
383{
384 struct sched *s;
385 int i;
386
387 s = kzalloc(sizeof (struct sched), GFP_KERNEL);
388 if (!s)
389 return -ENOMEM;
390
391 pr_debug("tx_sched_init\n");
392 tasklet_init(&s->sched_tsk, restart_sched, (unsigned long) sge);
393 sge->tx_sched = s;
394
395 for (i = 0; i < MAX_NPORTS; i++) {
396 skb_queue_head_init(&s->p[i].skbq);
397 t1_sched_update_parms(sge, i, 1500, 1000);
398 }
399
400 return 0;
401}
402
403/*
404 * sched_update_avail() computes the delta since the last time it was called
405 * and updates the per port quota (number of bits that can be sent to the any
406 * port).
407 */
408static inline int sched_update_avail(struct sge *sge)
409{
410 struct sched *s = sge->tx_sched;
411 ktime_t now = get_clock();
412 unsigned int i;
413 long long delta_time_ns;
414
415 delta_time_ns = ktime_to_ns(ktime_sub(now, s->last_updated));
416
417 pr_debug("sched_update_avail delta=%lld\n", delta_time_ns);
418 if (delta_time_ns < 15000)
419 return 0;
420
421 for (i = 0; i < MAX_NPORTS; i++) {
422 struct sched_port *p = &s->p[i];
423 unsigned int delta_avail;
424
425 delta_avail = (p->drain_bits_per_1024ns * delta_time_ns) >> 13;
426 p->avail = min(p->avail + delta_avail, s->max_avail);
427 }
428
429 s->last_updated = now;
430
431 return 1;
432}
433
434/*
435 * sched_skb() is called from two different places. In the tx path, any
436 * packet generating load on an output port will call sched_skb()
437 * (skb != NULL). In addition, sched_skb() is called from the irq/soft irq
438 * context (skb == NULL).
439 * The scheduler only returns a skb (which will then be sent) if the
440 * length of the skb is <= the current quota of the output port.
441 */
442static struct sk_buff *sched_skb(struct sge *sge, struct sk_buff *skb,
443 unsigned int credits)
444{
445 struct sched *s = sge->tx_sched;
446 struct sk_buff_head *skbq;
447 unsigned int i, len, update = 1;
448
449 pr_debug("sched_skb %p\n", skb);
450 if (!skb) {
451 if (!s->num)
452 return NULL;
453 } else {
454 skbq = &s->p[skb->dev->if_port].skbq;
455 __skb_queue_tail(skbq, skb);
456 s->num++;
457 skb = NULL;
458 }
459
460 if (credits < MAX_SKB_FRAGS + 1)
461 goto out;
462
463 again:
464 for (i = 0; i < MAX_NPORTS; i++) {
465 s->port = ++s->port & (MAX_NPORTS - 1);
466 skbq = &s->p[s->port].skbq;
467
468 skb = skb_peek(skbq);
469
470 if (!skb)
471 continue;
472
473 len = skb->len;
474 if (len <= s->p[s->port].avail) {
475 s->p[s->port].avail -= len;
476 s->num--;
477 __skb_unlink(skb, skbq);
478 goto out;
479 }
480 skb = NULL;
481 }
482
483 if (update-- && sched_update_avail(sge))
484 goto again;
485
486 out:
487 /* If there are more pending skbs, we use the hardware to schedule us
488 * again.
489 */
490 if (s->num && !skb) {
491 struct cmdQ *q = &sge->cmdQ[0];
492 clear_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
493 if (test_and_set_bit(CMDQ_STAT_RUNNING, &q->status) == 0) {
494 set_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
495 writel(F_CMDQ0_ENABLE, sge->adapter->regs + A_SG_DOORBELL);
496 }
497 }
498 pr_debug("sched_skb ret %p\n", skb);
499
500 return skb;
501}
502
503/*
258 * PIO to indicate that memory mapped Q contains valid descriptor(s). 504 * PIO to indicate that memory mapped Q contains valid descriptor(s).
259 */ 505 */
260static inline void doorbell_pio(struct adapter *adapter, u32 val) 506static inline void doorbell_pio(struct adapter *adapter, u32 val)
@@ -335,10 +581,9 @@ static int alloc_rx_resources(struct sge *sge, struct sge_params *p)
335 goto err_no_mem; 581 goto err_no_mem;
336 memset(q->entries, 0, size); 582 memset(q->entries, 0, size);
337 size = sizeof(struct freelQ_ce) * q->size; 583 size = sizeof(struct freelQ_ce) * q->size;
338 q->centries = kmalloc(size, GFP_KERNEL); 584 q->centries = kzalloc(size, GFP_KERNEL);
339 if (!q->centries) 585 if (!q->centries)
340 goto err_no_mem; 586 goto err_no_mem;
341 memset(q->centries, 0, size);
342 } 587 }
343 588
344 /* 589 /*
@@ -351,8 +596,11 @@ static int alloc_rx_resources(struct sge *sge, struct sge_params *p)
351 sge->freelQ[!sge->jumbo_fl].rx_buffer_size = SGE_RX_SM_BUF_SIZE + 596 sge->freelQ[!sge->jumbo_fl].rx_buffer_size = SGE_RX_SM_BUF_SIZE +
352 sizeof(struct cpl_rx_data) + 597 sizeof(struct cpl_rx_data) +
353 sge->freelQ[!sge->jumbo_fl].dma_offset; 598 sge->freelQ[!sge->jumbo_fl].dma_offset;
354 sge->freelQ[sge->jumbo_fl].rx_buffer_size = (16 * 1024) - 599
355 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); 600 size = (16 * 1024) -
601 SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
602
603 sge->freelQ[sge->jumbo_fl].rx_buffer_size = size;
356 604
357 /* 605 /*
358 * Setup which skb recycle Q should be used when recycling buffers from 606 * Setup which skb recycle Q should be used when recycling buffers from
@@ -389,17 +637,23 @@ static void free_cmdQ_buffers(struct sge *sge, struct cmdQ *q, unsigned int n)
389 q->in_use -= n; 637 q->in_use -= n;
390 ce = &q->centries[cidx]; 638 ce = &q->centries[cidx];
391 while (n--) { 639 while (n--) {
392 if (q->sop) 640 if (q->sop) {
393 pci_unmap_single(pdev, pci_unmap_addr(ce, dma_addr), 641 if (likely(pci_unmap_len(ce, dma_len))) {
394 pci_unmap_len(ce, dma_len), 642 pci_unmap_single(pdev,
395 PCI_DMA_TODEVICE); 643 pci_unmap_addr(ce, dma_addr),
396 else 644 pci_unmap_len(ce, dma_len),
397 pci_unmap_page(pdev, pci_unmap_addr(ce, dma_addr), 645 PCI_DMA_TODEVICE);
398 pci_unmap_len(ce, dma_len), 646 q->sop = 0;
399 PCI_DMA_TODEVICE); 647 }
400 q->sop = 0; 648 } else {
649 if (likely(pci_unmap_len(ce, dma_len))) {
650 pci_unmap_page(pdev, pci_unmap_addr(ce, dma_addr),
651 pci_unmap_len(ce, dma_len),
652 PCI_DMA_TODEVICE);
653 }
654 }
401 if (ce->skb) { 655 if (ce->skb) {
402 dev_kfree_skb(ce->skb); 656 dev_kfree_skb_any(ce->skb);
403 q->sop = 1; 657 q->sop = 1;
404 } 658 }
405 ce++; 659 ce++;
@@ -463,10 +717,9 @@ static int alloc_tx_resources(struct sge *sge, struct sge_params *p)
463 goto err_no_mem; 717 goto err_no_mem;
464 memset(q->entries, 0, size); 718 memset(q->entries, 0, size);
465 size = sizeof(struct cmdQ_ce) * q->size; 719 size = sizeof(struct cmdQ_ce) * q->size;
466 q->centries = kmalloc(size, GFP_KERNEL); 720 q->centries = kzalloc(size, GFP_KERNEL);
467 if (!q->centries) 721 if (!q->centries)
468 goto err_no_mem; 722 goto err_no_mem;
469 memset(q->centries, 0, size);
470 } 723 }
471 724
472 /* 725 /*
@@ -506,7 +759,7 @@ void t1_set_vlan_accel(struct adapter *adapter, int on_off)
506 sge->sge_control |= F_VLAN_XTRACT; 759 sge->sge_control |= F_VLAN_XTRACT;
507 if (adapter->open_device_map) { 760 if (adapter->open_device_map) {
508 writel(sge->sge_control, adapter->regs + A_SG_CONTROL); 761 writel(sge->sge_control, adapter->regs + A_SG_CONTROL);
509 readl(adapter->regs + A_SG_CONTROL); /* flush */ 762 readl(adapter->regs + A_SG_CONTROL); /* flush */
510 } 763 }
511} 764}
512 765
@@ -540,7 +793,6 @@ static void configure_sge(struct sge *sge, struct sge_params *p)
540 sge->sge_control = F_CMDQ0_ENABLE | F_CMDQ1_ENABLE | F_FL0_ENABLE | 793 sge->sge_control = F_CMDQ0_ENABLE | F_CMDQ1_ENABLE | F_FL0_ENABLE |
541 F_FL1_ENABLE | F_CPL_ENABLE | F_RESPONSE_QUEUE_ENABLE | 794 F_FL1_ENABLE | F_CPL_ENABLE | F_RESPONSE_QUEUE_ENABLE |
542 V_CMDQ_PRIORITY(2) | F_DISABLE_CMDQ1_GTS | F_ISCSI_COALESCE | 795 V_CMDQ_PRIORITY(2) | F_DISABLE_CMDQ1_GTS | F_ISCSI_COALESCE |
543 F_DISABLE_FL0_GTS | F_DISABLE_FL1_GTS |
544 V_RX_PKT_OFFSET(sge->rx_pkt_pad); 796 V_RX_PKT_OFFSET(sge->rx_pkt_pad);
545 797
546#if defined(__BIG_ENDIAN_BITFIELD) 798#if defined(__BIG_ENDIAN_BITFIELD)
@@ -568,9 +820,12 @@ static inline unsigned int jumbo_payload_capacity(const struct sge *sge)
568 */ 820 */
569void t1_sge_destroy(struct sge *sge) 821void t1_sge_destroy(struct sge *sge)
570{ 822{
571 if (sge->espibug_skb) 823 int i;
572 kfree_skb(sge->espibug_skb);
573 824
825 for_each_port(sge->adapter, i)
826 free_percpu(sge->port_stats[i]);
827
828 kfree(sge->tx_sched);
574 free_tx_resources(sge); 829 free_tx_resources(sge);
575 free_rx_resources(sge); 830 free_rx_resources(sge);
576 kfree(sge); 831 kfree(sge);
@@ -735,14 +990,28 @@ int t1_sge_intr_error_handler(struct sge *sge)
735 return 0; 990 return 0;
736} 991}
737 992
738const struct sge_intr_counts *t1_sge_get_intr_counts(struct sge *sge) 993const struct sge_intr_counts *t1_sge_get_intr_counts(const struct sge *sge)
739{ 994{
740 return &sge->stats; 995 return &sge->stats;
741} 996}
742 997
743const struct sge_port_stats *t1_sge_get_port_stats(struct sge *sge, int port) 998void t1_sge_get_port_stats(const struct sge *sge, int port,
999 struct sge_port_stats *ss)
744{ 1000{
745 return &sge->port_stats[port]; 1001 int cpu;
1002
1003 memset(ss, 0, sizeof(*ss));
1004 for_each_possible_cpu(cpu) {
1005 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[port], cpu);
1006
1007 ss->rx_packets += st->rx_packets;
1008 ss->rx_cso_good += st->rx_cso_good;
1009 ss->tx_packets += st->tx_packets;
1010 ss->tx_cso += st->tx_cso;
1011 ss->tx_tso += st->tx_tso;
1012 ss->vlan_xtract += st->vlan_xtract;
1013 ss->vlan_insert += st->vlan_insert;
1014 }
746} 1015}
747 1016
748/** 1017/**
@@ -856,6 +1125,99 @@ static void unexpected_offload(struct adapter *adapter, struct freelQ *fl)
856} 1125}
857 1126
858/* 1127/*
1128 * T1/T2 SGE limits the maximum DMA size per TX descriptor to
1129 * SGE_TX_DESC_MAX_PLEN (16KB). If the PAGE_SIZE is larger than 16KB, the
1130 * stack might send more than SGE_TX_DESC_MAX_PLEN in a contiguous manner.
1131 * Note that the *_large_page_tx_descs stuff will be optimized out when
1132 * PAGE_SIZE <= SGE_TX_DESC_MAX_PLEN.
1133 *
1134 * compute_large_page_descs() computes how many additional descriptors are
1135 * required to break down the stack's request.
1136 */
1137static inline unsigned int compute_large_page_tx_descs(struct sk_buff *skb)
1138{
1139 unsigned int count = 0;
1140 if (PAGE_SIZE > SGE_TX_DESC_MAX_PLEN) {
1141 unsigned int nfrags = skb_shinfo(skb)->nr_frags;
1142 unsigned int i, len = skb->len - skb->data_len;
1143 while (len > SGE_TX_DESC_MAX_PLEN) {
1144 count++;
1145 len -= SGE_TX_DESC_MAX_PLEN;
1146 }
1147 for (i = 0; nfrags--; i++) {
1148 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1149 len = frag->size;
1150 while (len > SGE_TX_DESC_MAX_PLEN) {
1151 count++;
1152 len -= SGE_TX_DESC_MAX_PLEN;
1153 }
1154 }
1155 }
1156 return count;
1157}
1158
1159/*
1160 * Write a cmdQ entry.
1161 *
1162 * Since this function writes the 'flags' field, it must not be used to
1163 * write the first cmdQ entry.
1164 */
1165static inline void write_tx_desc(struct cmdQ_e *e, dma_addr_t mapping,
1166 unsigned int len, unsigned int gen,
1167 unsigned int eop)
1168{
1169 if (unlikely(len > SGE_TX_DESC_MAX_PLEN))
1170 BUG();
1171 e->addr_lo = (u32)mapping;
1172 e->addr_hi = (u64)mapping >> 32;
1173 e->len_gen = V_CMD_LEN(len) | V_CMD_GEN1(gen);
1174 e->flags = F_CMD_DATAVALID | V_CMD_EOP(eop) | V_CMD_GEN2(gen);
1175}
1176
1177/*
1178 * See comment for previous function.
1179 *
1180 * write_tx_descs_large_page() writes additional SGE tx descriptors if
1181 * *desc_len exceeds HW's capability.
1182 */
1183static inline unsigned int write_large_page_tx_descs(unsigned int pidx,
1184 struct cmdQ_e **e,
1185 struct cmdQ_ce **ce,
1186 unsigned int *gen,
1187 dma_addr_t *desc_mapping,
1188 unsigned int *desc_len,
1189 unsigned int nfrags,
1190 struct cmdQ *q)
1191{
1192 if (PAGE_SIZE > SGE_TX_DESC_MAX_PLEN) {
1193 struct cmdQ_e *e1 = *e;
1194 struct cmdQ_ce *ce1 = *ce;
1195
1196 while (*desc_len > SGE_TX_DESC_MAX_PLEN) {
1197 *desc_len -= SGE_TX_DESC_MAX_PLEN;
1198 write_tx_desc(e1, *desc_mapping, SGE_TX_DESC_MAX_PLEN,
1199 *gen, nfrags == 0 && *desc_len == 0);
1200 ce1->skb = NULL;
1201 pci_unmap_len_set(ce1, dma_len, 0);
1202 *desc_mapping += SGE_TX_DESC_MAX_PLEN;
1203 if (*desc_len) {
1204 ce1++;
1205 e1++;
1206 if (++pidx == q->size) {
1207 pidx = 0;
1208 *gen ^= 1;
1209 ce1 = q->centries;
1210 e1 = q->entries;
1211 }
1212 }
1213 }
1214 *e = e1;
1215 *ce = ce1;
1216 }
1217 return pidx;
1218}
1219
1220/*
859 * Write the command descriptors to transmit the given skb starting at 1221 * Write the command descriptors to transmit the given skb starting at
860 * descriptor pidx with the given generation. 1222 * descriptor pidx with the given generation.
861 */ 1223 */
@@ -863,50 +1225,84 @@ static inline void write_tx_descs(struct adapter *adapter, struct sk_buff *skb,
863 unsigned int pidx, unsigned int gen, 1225 unsigned int pidx, unsigned int gen,
864 struct cmdQ *q) 1226 struct cmdQ *q)
865{ 1227{
866 dma_addr_t mapping; 1228 dma_addr_t mapping, desc_mapping;
867 struct cmdQ_e *e, *e1; 1229 struct cmdQ_e *e, *e1;
868 struct cmdQ_ce *ce; 1230 struct cmdQ_ce *ce;
869 unsigned int i, flags, nfrags = skb_shinfo(skb)->nr_frags; 1231 unsigned int i, flags, first_desc_len, desc_len,
1232 nfrags = skb_shinfo(skb)->nr_frags;
870 1233
871 mapping = pci_map_single(adapter->pdev, skb->data, 1234 e = e1 = &q->entries[pidx];
872 skb->len - skb->data_len, PCI_DMA_TODEVICE);
873 ce = &q->centries[pidx]; 1235 ce = &q->centries[pidx];
1236
1237 mapping = pci_map_single(adapter->pdev, skb->data,
1238 skb->len - skb->data_len, PCI_DMA_TODEVICE);
1239
1240 desc_mapping = mapping;
1241 desc_len = skb->len - skb->data_len;
1242
1243 flags = F_CMD_DATAVALID | F_CMD_SOP |
1244 V_CMD_EOP(nfrags == 0 && desc_len <= SGE_TX_DESC_MAX_PLEN) |
1245 V_CMD_GEN2(gen);
1246 first_desc_len = (desc_len <= SGE_TX_DESC_MAX_PLEN) ?
1247 desc_len : SGE_TX_DESC_MAX_PLEN;
1248 e->addr_lo = (u32)desc_mapping;
1249 e->addr_hi = (u64)desc_mapping >> 32;
1250 e->len_gen = V_CMD_LEN(first_desc_len) | V_CMD_GEN1(gen);
1251 ce->skb = NULL;
1252 pci_unmap_len_set(ce, dma_len, 0);
1253
1254 if (PAGE_SIZE > SGE_TX_DESC_MAX_PLEN &&
1255 desc_len > SGE_TX_DESC_MAX_PLEN) {
1256 desc_mapping += first_desc_len;
1257 desc_len -= first_desc_len;
1258 e1++;
1259 ce++;
1260 if (++pidx == q->size) {
1261 pidx = 0;
1262 gen ^= 1;
1263 e1 = q->entries;
1264 ce = q->centries;
1265 }
1266 pidx = write_large_page_tx_descs(pidx, &e1, &ce, &gen,
1267 &desc_mapping, &desc_len,
1268 nfrags, q);
1269
1270 if (likely(desc_len))
1271 write_tx_desc(e1, desc_mapping, desc_len, gen,
1272 nfrags == 0);
1273 }
1274
874 ce->skb = NULL; 1275 ce->skb = NULL;
875 pci_unmap_addr_set(ce, dma_addr, mapping); 1276 pci_unmap_addr_set(ce, dma_addr, mapping);
876 pci_unmap_len_set(ce, dma_len, skb->len - skb->data_len); 1277 pci_unmap_len_set(ce, dma_len, skb->len - skb->data_len);
877 1278
878 flags = F_CMD_DATAVALID | F_CMD_SOP | V_CMD_EOP(nfrags == 0) | 1279 for (i = 0; nfrags--; i++) {
879 V_CMD_GEN2(gen);
880 e = &q->entries[pidx];
881 e->addr_lo = (u32)mapping;
882 e->addr_hi = (u64)mapping >> 32;
883 e->len_gen = V_CMD_LEN(skb->len - skb->data_len) | V_CMD_GEN1(gen);
884 for (e1 = e, i = 0; nfrags--; i++) {
885 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 1280 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
886
887 ce++;
888 e1++; 1281 e1++;
1282 ce++;
889 if (++pidx == q->size) { 1283 if (++pidx == q->size) {
890 pidx = 0; 1284 pidx = 0;
891 gen ^= 1; 1285 gen ^= 1;
892 ce = q->centries;
893 e1 = q->entries; 1286 e1 = q->entries;
1287 ce = q->centries;
894 } 1288 }
895 1289
896 mapping = pci_map_page(adapter->pdev, frag->page, 1290 mapping = pci_map_page(adapter->pdev, frag->page,
897 frag->page_offset, frag->size, 1291 frag->page_offset, frag->size,
898 PCI_DMA_TODEVICE); 1292 PCI_DMA_TODEVICE);
1293 desc_mapping = mapping;
1294 desc_len = frag->size;
1295
1296 pidx = write_large_page_tx_descs(pidx, &e1, &ce, &gen,
1297 &desc_mapping, &desc_len,
1298 nfrags, q);
1299 if (likely(desc_len))
1300 write_tx_desc(e1, desc_mapping, desc_len, gen,
1301 nfrags == 0);
899 ce->skb = NULL; 1302 ce->skb = NULL;
900 pci_unmap_addr_set(ce, dma_addr, mapping); 1303 pci_unmap_addr_set(ce, dma_addr, mapping);
901 pci_unmap_len_set(ce, dma_len, frag->size); 1304 pci_unmap_len_set(ce, dma_len, frag->size);
902
903 e1->addr_lo = (u32)mapping;
904 e1->addr_hi = (u64)mapping >> 32;
905 e1->len_gen = V_CMD_LEN(frag->size) | V_CMD_GEN1(gen);
906 e1->flags = F_CMD_DATAVALID | V_CMD_EOP(nfrags == 0) |
907 V_CMD_GEN2(gen);
908 } 1305 }
909
910 ce->skb = skb; 1306 ce->skb = skb;
911 wmb(); 1307 wmb();
912 e->flags = flags; 1308 e->flags = flags;
@@ -920,26 +1316,56 @@ static inline void reclaim_completed_tx(struct sge *sge, struct cmdQ *q)
920 unsigned int reclaim = q->processed - q->cleaned; 1316 unsigned int reclaim = q->processed - q->cleaned;
921 1317
922 if (reclaim) { 1318 if (reclaim) {
1319 pr_debug("reclaim_completed_tx processed:%d cleaned:%d\n",
1320 q->processed, q->cleaned);
923 free_cmdQ_buffers(sge, q, reclaim); 1321 free_cmdQ_buffers(sge, q, reclaim);
924 q->cleaned += reclaim; 1322 q->cleaned += reclaim;
925 } 1323 }
926} 1324}
927 1325
928#ifndef SET_ETHTOOL_OPS
929# define __netif_rx_complete(dev) netif_rx_complete(dev)
930#endif
931
932/* 1326/*
933 * We cannot use the standard netif_rx_schedule_prep() because we have multiple 1327 * Called from tasklet. Checks the scheduler for any
934 * ports plus the TOE all multiplexing onto a single response queue, therefore 1328 * pending skbs that can be sent.
935 * accepting new responses cannot depend on the state of any particular port.
936 * So define our own equivalent that omits the netif_running() test.
937 */ 1329 */
938static inline int napi_schedule_prep(struct net_device *dev) 1330static void restart_sched(unsigned long arg)
939{ 1331{
940 return !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state); 1332 struct sge *sge = (struct sge *) arg;
941} 1333 struct adapter *adapter = sge->adapter;
1334 struct cmdQ *q = &sge->cmdQ[0];
1335 struct sk_buff *skb;
1336 unsigned int credits, queued_skb = 0;
942 1337
1338 spin_lock(&q->lock);
1339 reclaim_completed_tx(sge, q);
1340
1341 credits = q->size - q->in_use;
1342 pr_debug("restart_sched credits=%d\n", credits);
1343 while ((skb = sched_skb(sge, NULL, credits)) != NULL) {
1344 unsigned int genbit, pidx, count;
1345 count = 1 + skb_shinfo(skb)->nr_frags;
1346 count += compute_large_page_tx_descs(skb);
1347 q->in_use += count;
1348 genbit = q->genbit;
1349 pidx = q->pidx;
1350 q->pidx += count;
1351 if (q->pidx >= q->size) {
1352 q->pidx -= q->size;
1353 q->genbit ^= 1;
1354 }
1355 write_tx_descs(adapter, skb, pidx, genbit, q);
1356 credits = q->size - q->in_use;
1357 queued_skb = 1;
1358 }
1359
1360 if (queued_skb) {
1361 clear_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
1362 if (test_and_set_bit(CMDQ_STAT_RUNNING, &q->status) == 0) {
1363 set_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
1364 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
1365 }
1366 }
1367 spin_unlock(&q->lock);
1368}
943 1369
944/** 1370/**
945 * sge_rx - process an ingress ethernet packet 1371 * sge_rx - process an ingress ethernet packet
@@ -954,31 +1380,39 @@ static int sge_rx(struct sge *sge, struct freelQ *fl, unsigned int len)
954 struct sk_buff *skb; 1380 struct sk_buff *skb;
955 struct cpl_rx_pkt *p; 1381 struct cpl_rx_pkt *p;
956 struct adapter *adapter = sge->adapter; 1382 struct adapter *adapter = sge->adapter;
1383 struct sge_port_stats *st;
957 1384
958 sge->stats.ethernet_pkts++;
959 skb = get_packet(adapter->pdev, fl, len - sge->rx_pkt_pad, 1385 skb = get_packet(adapter->pdev, fl, len - sge->rx_pkt_pad,
960 sge->rx_pkt_pad, 2, SGE_RX_COPY_THRES, 1386 sge->rx_pkt_pad, 2, SGE_RX_COPY_THRES,
961 SGE_RX_DROP_THRES); 1387 SGE_RX_DROP_THRES);
962 if (!skb) { 1388 if (unlikely(!skb)) {
963 sge->port_stats[0].rx_drops++; /* charge only port 0 for now */ 1389 sge->stats.rx_drops++;
964 return 0; 1390 return 0;
965 } 1391 }
966 1392
967 p = (struct cpl_rx_pkt *)skb->data; 1393 p = (struct cpl_rx_pkt *)skb->data;
968 skb_pull(skb, sizeof(*p)); 1394 skb_pull(skb, sizeof(*p));
1395 if (p->iff >= adapter->params.nports) {
1396 kfree_skb(skb);
1397 return 0;
1398 }
1399
969 skb->dev = adapter->port[p->iff].dev; 1400 skb->dev = adapter->port[p->iff].dev;
970 skb->dev->last_rx = jiffies; 1401 skb->dev->last_rx = jiffies;
1402 st = per_cpu_ptr(sge->port_stats[p->iff], smp_processor_id());
1403 st->rx_packets++;
1404
971 skb->protocol = eth_type_trans(skb, skb->dev); 1405 skb->protocol = eth_type_trans(skb, skb->dev);
972 if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff && 1406 if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff &&
973 skb->protocol == htons(ETH_P_IP) && 1407 skb->protocol == htons(ETH_P_IP) &&
974 (skb->data[9] == IPPROTO_TCP || skb->data[9] == IPPROTO_UDP)) { 1408 (skb->data[9] == IPPROTO_TCP || skb->data[9] == IPPROTO_UDP)) {
975 sge->port_stats[p->iff].rx_cso_good++; 1409 ++st->rx_cso_good;
976 skb->ip_summed = CHECKSUM_UNNECESSARY; 1410 skb->ip_summed = CHECKSUM_UNNECESSARY;
977 } else 1411 } else
978 skb->ip_summed = CHECKSUM_NONE; 1412 skb->ip_summed = CHECKSUM_NONE;
979 1413
980 if (unlikely(adapter->vlan_grp && p->vlan_valid)) { 1414 if (unlikely(adapter->vlan_grp && p->vlan_valid)) {
981 sge->port_stats[p->iff].vlan_xtract++; 1415 st->vlan_xtract++;
982 if (adapter->params.sge.polling) 1416 if (adapter->params.sge.polling)
983 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp, 1417 vlan_hwaccel_receive_skb(skb, adapter->vlan_grp,
984 ntohs(p->vlan)); 1418 ntohs(p->vlan));
@@ -1039,18 +1473,24 @@ static unsigned int update_tx_info(struct adapter *adapter,
1039 struct cmdQ *cmdq = &sge->cmdQ[0]; 1473 struct cmdQ *cmdq = &sge->cmdQ[0];
1040 1474
1041 cmdq->processed += pr0; 1475 cmdq->processed += pr0;
1042 1476 if (flags & (F_FL0_ENABLE | F_FL1_ENABLE)) {
1477 freelQs_empty(sge);
1478 flags &= ~(F_FL0_ENABLE | F_FL1_ENABLE);
1479 }
1043 if (flags & F_CMDQ0_ENABLE) { 1480 if (flags & F_CMDQ0_ENABLE) {
1044 clear_bit(CMDQ_STAT_RUNNING, &cmdq->status); 1481 clear_bit(CMDQ_STAT_RUNNING, &cmdq->status);
1045 1482
1046 if (cmdq->cleaned + cmdq->in_use != cmdq->processed && 1483 if (cmdq->cleaned + cmdq->in_use != cmdq->processed &&
1047 !test_and_set_bit(CMDQ_STAT_LAST_PKT_DB, &cmdq->status)) { 1484 !test_and_set_bit(CMDQ_STAT_LAST_PKT_DB, &cmdq->status)) {
1048 set_bit(CMDQ_STAT_RUNNING, &cmdq->status); 1485 set_bit(CMDQ_STAT_RUNNING, &cmdq->status);
1049 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL); 1486 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
1050 } 1487 }
1051 flags &= ~F_CMDQ0_ENABLE; 1488 if (sge->tx_sched)
1489 tasklet_hi_schedule(&sge->tx_sched->sched_tsk);
1490
1491 flags &= ~F_CMDQ0_ENABLE;
1052 } 1492 }
1053 1493
1054 if (unlikely(sge->stopped_tx_queues != 0)) 1494 if (unlikely(sge->stopped_tx_queues != 0))
1055 restart_tx_queues(sge); 1495 restart_tx_queues(sge);
1056 1496
@@ -1241,20 +1681,21 @@ static irqreturn_t t1_interrupt_napi(int irq, void *data)
1241 if (e->GenerationBit == q->genbit) { 1681 if (e->GenerationBit == q->genbit) {
1242 if (e->DataValid || 1682 if (e->DataValid ||
1243 process_pure_responses(adapter, e)) { 1683 process_pure_responses(adapter, e)) {
1244 if (likely(napi_schedule_prep(sge->netdev))) 1684 if (likely(__netif_rx_schedule_prep(sge->netdev)))
1245 __netif_rx_schedule(sge->netdev); 1685 __netif_rx_schedule(sge->netdev);
1246 else 1686 else if (net_ratelimit())
1247 printk(KERN_CRIT 1687 printk(KERN_INFO
1248 "NAPI schedule failure!\n"); 1688 "NAPI schedule failure!\n");
1249 } else 1689 } else
1250 writel(q->cidx, adapter->regs + A_SG_SLEEPING); 1690 writel(q->cidx, adapter->regs + A_SG_SLEEPING);
1691
1251 handled = 1; 1692 handled = 1;
1252 goto unlock; 1693 goto unlock;
1253 } else 1694 } else
1254 writel(q->cidx, adapter->regs + A_SG_SLEEPING); 1695 writel(q->cidx, adapter->regs + A_SG_SLEEPING);
1255 } else 1696 } else if (readl(adapter->regs + A_PL_CAUSE) & F_PL_INTR_SGE_DATA) {
1256 if (readl(adapter->regs + A_PL_CAUSE) & F_PL_INTR_SGE_DATA) 1697 printk(KERN_ERR "data interrupt while NAPI running\n");
1257 printk(KERN_ERR "data interrupt while NAPI running\n"); 1698 }
1258 1699
1259 handled = t1_slow_intr_handler(adapter); 1700 handled = t1_slow_intr_handler(adapter);
1260 if (!handled) 1701 if (!handled)
@@ -1335,34 +1776,59 @@ static int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
1335{ 1776{
1336 struct sge *sge = adapter->sge; 1777 struct sge *sge = adapter->sge;
1337 struct cmdQ *q = &sge->cmdQ[qid]; 1778 struct cmdQ *q = &sge->cmdQ[qid];
1338 unsigned int credits, pidx, genbit, count; 1779 unsigned int credits, pidx, genbit, count, use_sched_skb = 0;
1780
1781 if (!spin_trylock(&q->lock))
1782 return NETDEV_TX_LOCKED;
1339 1783
1340 spin_lock(&q->lock);
1341 reclaim_completed_tx(sge, q); 1784 reclaim_completed_tx(sge, q);
1342 1785
1343 pidx = q->pidx; 1786 pidx = q->pidx;
1344 credits = q->size - q->in_use; 1787 credits = q->size - q->in_use;
1345 count = 1 + skb_shinfo(skb)->nr_frags; 1788 count = 1 + skb_shinfo(skb)->nr_frags;
1789 count += compute_large_page_tx_descs(skb);
1346 1790
1347 { /* Ethernet packet */ 1791 /* Ethernet packet */
1348 if (unlikely(credits < count)) { 1792 if (unlikely(credits < count)) {
1793 if (!netif_queue_stopped(dev)) {
1349 netif_stop_queue(dev); 1794 netif_stop_queue(dev);
1350 set_bit(dev->if_port, &sge->stopped_tx_queues); 1795 set_bit(dev->if_port, &sge->stopped_tx_queues);
1351 sge->stats.cmdQ_full[2]++; 1796 sge->stats.cmdQ_full[2]++;
1352 spin_unlock(&q->lock); 1797 CH_ERR("%s: Tx ring full while queue awake!\n",
1353 if (!netif_queue_stopped(dev)) 1798 adapter->name);
1354 CH_ERR("%s: Tx ring full while queue awake!\n",
1355 adapter->name);
1356 return NETDEV_TX_BUSY;
1357 } 1799 }
1358 if (unlikely(credits - count < q->stop_thres)) { 1800 spin_unlock(&q->lock);
1359 sge->stats.cmdQ_full[2]++; 1801 return NETDEV_TX_BUSY;
1360 netif_stop_queue(dev); 1802 }
1361 set_bit(dev->if_port, &sge->stopped_tx_queues); 1803
1804 if (unlikely(credits - count < q->stop_thres)) {
1805 netif_stop_queue(dev);
1806 set_bit(dev->if_port, &sge->stopped_tx_queues);
1807 sge->stats.cmdQ_full[2]++;
1808 }
1809
1810 /* T204 cmdQ0 skbs that are destined for a certain port have to go
1811 * through the scheduler.
1812 */
1813 if (sge->tx_sched && !qid && skb->dev) {
1814 use_sched:
1815 use_sched_skb = 1;
1816 /* Note that the scheduler might return a different skb than
1817 * the one passed in.
1818 */
1819 skb = sched_skb(sge, skb, credits);
1820 if (!skb) {
1821 spin_unlock(&q->lock);
1822 return NETDEV_TX_OK;
1362 } 1823 }
1824 pidx = q->pidx;
1825 count = 1 + skb_shinfo(skb)->nr_frags;
1826 count += compute_large_page_tx_descs(skb);
1363 } 1827 }
1828
1364 q->in_use += count; 1829 q->in_use += count;
1365 genbit = q->genbit; 1830 genbit = q->genbit;
1831 pidx = q->pidx;
1366 q->pidx += count; 1832 q->pidx += count;
1367 if (q->pidx >= q->size) { 1833 if (q->pidx >= q->size) {
1368 q->pidx -= q->size; 1834 q->pidx -= q->size;
@@ -1388,6 +1854,14 @@ static int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
1388 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL); 1854 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
1389 } 1855 }
1390 } 1856 }
1857
1858 if (use_sched_skb) {
1859 if (spin_trylock(&q->lock)) {
1860 credits = q->size - q->in_use;
1861 skb = NULL;
1862 goto use_sched;
1863 }
1864 }
1391 return NETDEV_TX_OK; 1865 return NETDEV_TX_OK;
1392} 1866}
1393 1867
@@ -1412,16 +1886,20 @@ static inline int eth_hdr_len(const void *data)
1412int t1_start_xmit(struct sk_buff *skb, struct net_device *dev) 1886int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1413{ 1887{
1414 struct adapter *adapter = dev->priv; 1888 struct adapter *adapter = dev->priv;
1415 struct sge_port_stats *st = &adapter->sge->port_stats[dev->if_port];
1416 struct sge *sge = adapter->sge; 1889 struct sge *sge = adapter->sge;
1890 struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port], smp_processor_id());
1417 struct cpl_tx_pkt *cpl; 1891 struct cpl_tx_pkt *cpl;
1892 struct sk_buff *orig_skb = skb;
1893 int ret;
1894
1895 if (skb->protocol == htons(ETH_P_CPL5))
1896 goto send;
1418 1897
1419#ifdef NETIF_F_TSO 1898 if (skb_shinfo(skb)->gso_size) {
1420 if (skb_is_gso(skb)) {
1421 int eth_type; 1899 int eth_type;
1422 struct cpl_tx_pkt_lso *hdr; 1900 struct cpl_tx_pkt_lso *hdr;
1423 1901
1424 st->tso++; 1902 ++st->tx_tso;
1425 1903
1426 eth_type = skb->nh.raw - skb->data == ETH_HLEN ? 1904 eth_type = skb->nh.raw - skb->data == ETH_HLEN ?
1427 CPL_ETH_II : CPL_ETH_II_VLAN; 1905 CPL_ETH_II : CPL_ETH_II_VLAN;
@@ -1432,13 +1910,10 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1432 hdr->ip_hdr_words = skb->nh.iph->ihl; 1910 hdr->ip_hdr_words = skb->nh.iph->ihl;
1433 hdr->tcp_hdr_words = skb->h.th->doff; 1911 hdr->tcp_hdr_words = skb->h.th->doff;
1434 hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type, 1912 hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type,
1435 skb_shinfo(skb)->gso_size)); 1913 skb_shinfo(skb)->gso_size));
1436 hdr->len = htonl(skb->len - sizeof(*hdr)); 1914 hdr->len = htonl(skb->len - sizeof(*hdr));
1437 cpl = (struct cpl_tx_pkt *)hdr; 1915 cpl = (struct cpl_tx_pkt *)hdr;
1438 sge->stats.tx_lso_pkts++; 1916 } else {
1439 } else
1440#endif
1441 {
1442 /* 1917 /*
1443 * Packets shorter than ETH_HLEN can break the MAC, drop them 1918 * Packets shorter than ETH_HLEN can break the MAC, drop them
1444 * early. Also, we may get oversized packets because some 1919 * early. Also, we may get oversized packets because some
@@ -1447,6 +1922,8 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1447 */ 1922 */
1448 if (unlikely(skb->len < ETH_HLEN || 1923 if (unlikely(skb->len < ETH_HLEN ||
1449 skb->len > dev->mtu + eth_hdr_len(skb->data))) { 1924 skb->len > dev->mtu + eth_hdr_len(skb->data))) {
1925 pr_debug("%s: packet size %d hdr %d mtu%d\n", dev->name,
1926 skb->len, eth_hdr_len(skb->data), dev->mtu);
1450 dev_kfree_skb_any(skb); 1927 dev_kfree_skb_any(skb);
1451 return NETDEV_TX_OK; 1928 return NETDEV_TX_OK;
1452 } 1929 }
@@ -1456,9 +1933,9 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1456 * components, such as pktgen, do not handle it right. 1933 * components, such as pktgen, do not handle it right.
1457 * Complain when this happens but try to fix things up. 1934 * Complain when this happens but try to fix things up.
1458 */ 1935 */
1459 if (unlikely(skb_headroom(skb) < 1936 if (unlikely(skb_headroom(skb) < dev->hard_header_len - ETH_HLEN)) {
1460 dev->hard_header_len - ETH_HLEN)) { 1937 pr_debug("%s: headroom %d header_len %d\n", dev->name,
1461 struct sk_buff *orig_skb = skb; 1938 skb_headroom(skb), dev->hard_header_len);
1462 1939
1463 if (net_ratelimit()) 1940 if (net_ratelimit())
1464 printk(KERN_ERR "%s: inadequate headroom in " 1941 printk(KERN_ERR "%s: inadequate headroom in "
@@ -1471,19 +1948,21 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1471 1948
1472 if (!(adapter->flags & UDP_CSUM_CAPABLE) && 1949 if (!(adapter->flags & UDP_CSUM_CAPABLE) &&
1473 skb->ip_summed == CHECKSUM_PARTIAL && 1950 skb->ip_summed == CHECKSUM_PARTIAL &&
1474 skb->nh.iph->protocol == IPPROTO_UDP) 1951 skb->nh.iph->protocol == IPPROTO_UDP) {
1475 if (unlikely(skb_checksum_help(skb))) { 1952 if (unlikely(skb_checksum_help(skb))) {
1953 pr_debug("%s: unable to do udp checksum\n", dev->name);
1476 dev_kfree_skb_any(skb); 1954 dev_kfree_skb_any(skb);
1477 return NETDEV_TX_OK; 1955 return NETDEV_TX_OK;
1478 } 1956 }
1957 }
1479 1958
1480 /* Hmmm, assuming to catch the gratious arp... and we'll use 1959 /* Hmmm, assuming to catch the gratious arp... and we'll use
1481 * it to flush out stuck espi packets... 1960 * it to flush out stuck espi packets...
1482 */ 1961 */
1483 if (unlikely(!adapter->sge->espibug_skb)) { 1962 if ((unlikely(!adapter->sge->espibug_skb[dev->if_port]))) {
1484 if (skb->protocol == htons(ETH_P_ARP) && 1963 if (skb->protocol == htons(ETH_P_ARP) &&
1485 skb->nh.arph->ar_op == htons(ARPOP_REQUEST)) { 1964 skb->nh.arph->ar_op == htons(ARPOP_REQUEST)) {
1486 adapter->sge->espibug_skb = skb; 1965 adapter->sge->espibug_skb[dev->if_port] = skb;
1487 /* We want to re-use this skb later. We 1966 /* We want to re-use this skb later. We
1488 * simply bump the reference count and it 1967 * simply bump the reference count and it
1489 * will not be freed... 1968 * will not be freed...
@@ -1499,8 +1978,6 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1499 /* the length field isn't used so don't bother setting it */ 1978 /* the length field isn't used so don't bother setting it */
1500 1979
1501 st->tx_cso += (skb->ip_summed == CHECKSUM_PARTIAL); 1980 st->tx_cso += (skb->ip_summed == CHECKSUM_PARTIAL);
1502 sge->stats.tx_do_cksum += (skb->ip_summed == CHECKSUM_PARTIAL);
1503 sge->stats.tx_reg_pkts++;
1504 } 1981 }
1505 cpl->iff = dev->if_port; 1982 cpl->iff = dev->if_port;
1506 1983
@@ -1513,8 +1990,19 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1513#endif 1990#endif
1514 cpl->vlan_valid = 0; 1991 cpl->vlan_valid = 0;
1515 1992
1993send:
1994 st->tx_packets++;
1516 dev->trans_start = jiffies; 1995 dev->trans_start = jiffies;
1517 return t1_sge_tx(skb, adapter, 0, dev); 1996 ret = t1_sge_tx(skb, adapter, 0, dev);
1997
1998 /* If transmit busy, and we reallocated skb's due to headroom limit,
1999 * then silently discard to avoid leak.
2000 */
2001 if (unlikely(ret != NETDEV_TX_OK && skb != orig_skb)) {
2002 dev_kfree_skb_any(skb);
2003 ret = NETDEV_TX_OK;
2004 }
2005 return ret;
1518} 2006}
1519 2007
1520/* 2008/*
@@ -1532,10 +2020,9 @@ static void sge_tx_reclaim_cb(unsigned long data)
1532 continue; 2020 continue;
1533 2021
1534 reclaim_completed_tx(sge, q); 2022 reclaim_completed_tx(sge, q);
1535 if (i == 0 && q->in_use) /* flush pending credits */ 2023 if (i == 0 && q->in_use) { /* flush pending credits */
1536 writel(F_CMDQ0_ENABLE, 2024 writel(F_CMDQ0_ENABLE, sge->adapter->regs + A_SG_DOORBELL);
1537 sge->adapter->regs + A_SG_DOORBELL); 2025 }
1538
1539 spin_unlock(&q->lock); 2026 spin_unlock(&q->lock);
1540 } 2027 }
1541 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD); 2028 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD);
@@ -1582,11 +2069,20 @@ int t1_sge_configure(struct sge *sge, struct sge_params *p)
1582 */ 2069 */
1583void t1_sge_stop(struct sge *sge) 2070void t1_sge_stop(struct sge *sge)
1584{ 2071{
2072 int i;
1585 writel(0, sge->adapter->regs + A_SG_CONTROL); 2073 writel(0, sge->adapter->regs + A_SG_CONTROL);
1586 (void) readl(sge->adapter->regs + A_SG_CONTROL); /* flush */ 2074 readl(sge->adapter->regs + A_SG_CONTROL); /* flush */
2075
1587 if (is_T2(sge->adapter)) 2076 if (is_T2(sge->adapter))
1588 del_timer_sync(&sge->espibug_timer); 2077 del_timer_sync(&sge->espibug_timer);
2078
1589 del_timer_sync(&sge->tx_reclaim_timer); 2079 del_timer_sync(&sge->tx_reclaim_timer);
2080 if (sge->tx_sched)
2081 tx_sched_stop(sge);
2082
2083 for (i = 0; i < MAX_NPORTS; i++)
2084 if (sge->espibug_skb[i])
2085 kfree_skb(sge->espibug_skb[i]);
1590} 2086}
1591 2087
1592/* 2088/*
@@ -1599,74 +2095,128 @@ void t1_sge_start(struct sge *sge)
1599 2095
1600 writel(sge->sge_control, sge->adapter->regs + A_SG_CONTROL); 2096 writel(sge->sge_control, sge->adapter->regs + A_SG_CONTROL);
1601 doorbell_pio(sge->adapter, F_FL0_ENABLE | F_FL1_ENABLE); 2097 doorbell_pio(sge->adapter, F_FL0_ENABLE | F_FL1_ENABLE);
1602 (void) readl(sge->adapter->regs + A_SG_CONTROL); /* flush */ 2098 readl(sge->adapter->regs + A_SG_CONTROL); /* flush */
1603 2099
1604 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD); 2100 mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD);
1605 2101
1606 if (is_T2(sge->adapter)) 2102 if (is_T2(sge->adapter))
1607 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout); 2103 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
1608} 2104}
1609 2105
1610/* 2106/*
1611 * Callback for the T2 ESPI 'stuck packet feature' workaorund 2107 * Callback for the T2 ESPI 'stuck packet feature' workaorund
1612 */ 2108 */
1613static void espibug_workaround(void *data) 2109static void espibug_workaround_t204(unsigned long data)
1614{ 2110{
1615 struct adapter *adapter = (struct adapter *)data; 2111 struct adapter *adapter = (struct adapter *)data;
1616 struct sge *sge = adapter->sge; 2112 struct sge *sge = adapter->sge;
2113 unsigned int nports = adapter->params.nports;
2114 u32 seop[MAX_NPORTS];
1617 2115
1618 if (netif_running(adapter->port[0].dev)) { 2116 if (adapter->open_device_map & PORT_MASK) {
1619 struct sk_buff *skb = sge->espibug_skb; 2117 int i;
1620 2118 if (t1_espi_get_mon_t204(adapter, &(seop[0]), 0) < 0) {
1621 u32 seop = t1_espi_get_mon(adapter, 0x930, 0); 2119 return;
1622 2120 }
1623 if ((seop & 0xfff0fff) == 0xfff && skb) { 2121 for (i = 0; i < nports; i++) {
1624 if (!skb->cb[0]) { 2122 struct sk_buff *skb = sge->espibug_skb[i];
1625 u8 ch_mac_addr[ETH_ALEN] = 2123 if ( (netif_running(adapter->port[i].dev)) &&
1626 {0x0, 0x7, 0x43, 0x0, 0x0, 0x0}; 2124 !(netif_queue_stopped(adapter->port[i].dev)) &&
1627 memcpy(skb->data + sizeof(struct cpl_tx_pkt), 2125 (seop[i] && ((seop[i] & 0xfff) == 0)) &&
1628 ch_mac_addr, ETH_ALEN); 2126 skb ) {
1629 memcpy(skb->data + skb->len - 10, ch_mac_addr, 2127 if (!skb->cb[0]) {
1630 ETH_ALEN); 2128 u8 ch_mac_addr[ETH_ALEN] =
1631 skb->cb[0] = 0xff; 2129 {0x0, 0x7, 0x43, 0x0, 0x0, 0x0};
2130 memcpy(skb->data + sizeof(struct cpl_tx_pkt),
2131 ch_mac_addr, ETH_ALEN);
2132 memcpy(skb->data + skb->len - 10,
2133 ch_mac_addr, ETH_ALEN);
2134 skb->cb[0] = 0xff;
2135 }
2136
2137 /* bump the reference count to avoid freeing of
2138 * the skb once the DMA has completed.
2139 */
2140 skb = skb_get(skb);
2141 t1_sge_tx(skb, adapter, 0, adapter->port[i].dev);
1632 } 2142 }
1633
1634 /* bump the reference count to avoid freeing of the
1635 * skb once the DMA has completed.
1636 */
1637 skb = skb_get(skb);
1638 t1_sge_tx(skb, adapter, 0, adapter->port[0].dev);
1639 } 2143 }
1640 } 2144 }
1641 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout); 2145 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
1642} 2146}
1643 2147
2148static void espibug_workaround(unsigned long data)
2149{
2150 struct adapter *adapter = (struct adapter *)data;
2151 struct sge *sge = adapter->sge;
2152
2153 if (netif_running(adapter->port[0].dev)) {
2154 struct sk_buff *skb = sge->espibug_skb[0];
2155 u32 seop = t1_espi_get_mon(adapter, 0x930, 0);
2156
2157 if ((seop & 0xfff0fff) == 0xfff && skb) {
2158 if (!skb->cb[0]) {
2159 u8 ch_mac_addr[ETH_ALEN] =
2160 {0x0, 0x7, 0x43, 0x0, 0x0, 0x0};
2161 memcpy(skb->data + sizeof(struct cpl_tx_pkt),
2162 ch_mac_addr, ETH_ALEN);
2163 memcpy(skb->data + skb->len - 10, ch_mac_addr,
2164 ETH_ALEN);
2165 skb->cb[0] = 0xff;
2166 }
2167
2168 /* bump the reference count to avoid freeing of the
2169 * skb once the DMA has completed.
2170 */
2171 skb = skb_get(skb);
2172 t1_sge_tx(skb, adapter, 0, adapter->port[0].dev);
2173 }
2174 }
2175 mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
2176}
2177
1644/* 2178/*
1645 * Creates a t1_sge structure and returns suggested resource parameters. 2179 * Creates a t1_sge structure and returns suggested resource parameters.
1646 */ 2180 */
1647struct sge * __devinit t1_sge_create(struct adapter *adapter, 2181struct sge * __devinit t1_sge_create(struct adapter *adapter,
1648 struct sge_params *p) 2182 struct sge_params *p)
1649{ 2183{
1650 struct sge *sge = kmalloc(sizeof(*sge), GFP_KERNEL); 2184 struct sge *sge = kzalloc(sizeof(*sge), GFP_KERNEL);
2185 int i;
1651 2186
1652 if (!sge) 2187 if (!sge)
1653 return NULL; 2188 return NULL;
1654 memset(sge, 0, sizeof(*sge));
1655 2189
1656 sge->adapter = adapter; 2190 sge->adapter = adapter;
1657 sge->netdev = adapter->port[0].dev; 2191 sge->netdev = adapter->port[0].dev;
1658 sge->rx_pkt_pad = t1_is_T1B(adapter) ? 0 : 2; 2192 sge->rx_pkt_pad = t1_is_T1B(adapter) ? 0 : 2;
1659 sge->jumbo_fl = t1_is_T1B(adapter) ? 1 : 0; 2193 sge->jumbo_fl = t1_is_T1B(adapter) ? 1 : 0;
1660 2194
2195 for_each_port(adapter, i) {
2196 sge->port_stats[i] = alloc_percpu(struct sge_port_stats);
2197 if (!sge->port_stats[i])
2198 goto nomem_port;
2199 }
2200
1661 init_timer(&sge->tx_reclaim_timer); 2201 init_timer(&sge->tx_reclaim_timer);
1662 sge->tx_reclaim_timer.data = (unsigned long)sge; 2202 sge->tx_reclaim_timer.data = (unsigned long)sge;
1663 sge->tx_reclaim_timer.function = sge_tx_reclaim_cb; 2203 sge->tx_reclaim_timer.function = sge_tx_reclaim_cb;
1664 2204
1665 if (is_T2(sge->adapter)) { 2205 if (is_T2(sge->adapter)) {
1666 init_timer(&sge->espibug_timer); 2206 init_timer(&sge->espibug_timer);
1667 sge->espibug_timer.function = (void *)&espibug_workaround; 2207
2208 if (adapter->params.nports > 1) {
2209 tx_sched_init(sge);
2210 sge->espibug_timer.function = espibug_workaround_t204;
2211 } else {
2212 sge->espibug_timer.function = espibug_workaround;
2213 }
1668 sge->espibug_timer.data = (unsigned long)sge->adapter; 2214 sge->espibug_timer.data = (unsigned long)sge->adapter;
2215
1669 sge->espibug_timeout = 1; 2216 sge->espibug_timeout = 1;
2217 /* for T204, every 10ms */
2218 if (adapter->params.nports > 1)
2219 sge->espibug_timeout = HZ/100;
1670 } 2220 }
1671 2221
1672 2222
@@ -1674,10 +2224,25 @@ struct sge * __devinit t1_sge_create(struct adapter *adapter,
1674 p->cmdQ_size[1] = SGE_CMDQ1_E_N; 2224 p->cmdQ_size[1] = SGE_CMDQ1_E_N;
1675 p->freelQ_size[!sge->jumbo_fl] = SGE_FREEL_SIZE; 2225 p->freelQ_size[!sge->jumbo_fl] = SGE_FREEL_SIZE;
1676 p->freelQ_size[sge->jumbo_fl] = SGE_JUMBO_FREEL_SIZE; 2226 p->freelQ_size[sge->jumbo_fl] = SGE_JUMBO_FREEL_SIZE;
1677 p->rx_coalesce_usecs = 50; 2227 if (sge->tx_sched) {
2228 if (board_info(sge->adapter)->board == CHBT_BOARD_CHT204)
2229 p->rx_coalesce_usecs = 15;
2230 else
2231 p->rx_coalesce_usecs = 50;
2232 } else
2233 p->rx_coalesce_usecs = 50;
2234
1678 p->coalesce_enable = 0; 2235 p->coalesce_enable = 0;
1679 p->sample_interval_usecs = 0; 2236 p->sample_interval_usecs = 0;
1680 p->polling = 0; 2237 p->polling = 0;
1681 2238
1682 return sge; 2239 return sge;
2240nomem_port:
2241 while (i >= 0) {
2242 free_percpu(sge->port_stats[i]);
2243 --i;
2244 }
2245 kfree(sge);
2246 return NULL;
2247
1683} 2248}
diff --git a/drivers/net/chelsio/sge.h b/drivers/net/chelsio/sge.h
index 91af47bab7be..7ceb0117d039 100644
--- a/drivers/net/chelsio/sge.h
+++ b/drivers/net/chelsio/sge.h
@@ -44,6 +44,9 @@
44#include <asm/byteorder.h> 44#include <asm/byteorder.h>
45 45
46struct sge_intr_counts { 46struct sge_intr_counts {
47 unsigned int rx_drops; /* # of packets dropped due to no mem */
48 unsigned int pure_rsps; /* # of non-payload responses */
49 unsigned int unhandled_irqs; /* # of unhandled interrupts */
47 unsigned int respQ_empty; /* # times respQ empty */ 50 unsigned int respQ_empty; /* # times respQ empty */
48 unsigned int respQ_overflow; /* # respQ overflow (fatal) */ 51 unsigned int respQ_overflow; /* # respQ overflow (fatal) */
49 unsigned int freelistQ_empty; /* # times freelist empty */ 52 unsigned int freelistQ_empty; /* # times freelist empty */
@@ -51,24 +54,16 @@ struct sge_intr_counts {
51 unsigned int pkt_mismatch; 54 unsigned int pkt_mismatch;
52 unsigned int cmdQ_full[3]; /* not HW IRQ, host cmdQ[] full */ 55 unsigned int cmdQ_full[3]; /* not HW IRQ, host cmdQ[] full */
53 unsigned int cmdQ_restarted[3];/* # of times cmdQ X was restarted */ 56 unsigned int cmdQ_restarted[3];/* # of times cmdQ X was restarted */
54 unsigned int ethernet_pkts; /* # of Ethernet packets received */
55 unsigned int offload_pkts; /* # of offload packets received */
56 unsigned int offload_bundles; /* # of offload pkt bundles delivered */
57 unsigned int pure_rsps; /* # of non-payload responses */
58 unsigned int unhandled_irqs; /* # of unhandled interrupts */
59 unsigned int tx_ipfrags;
60 unsigned int tx_reg_pkts;
61 unsigned int tx_lso_pkts;
62 unsigned int tx_do_cksum;
63}; 57};
64 58
65struct sge_port_stats { 59struct sge_port_stats {
66 unsigned long rx_cso_good; /* # of successful RX csum offloads */ 60 u64 rx_packets; /* # of Ethernet packets received */
67 unsigned long tx_cso; /* # of TX checksum offloads */ 61 u64 rx_cso_good; /* # of successful RX csum offloads */
68 unsigned long vlan_xtract; /* # of VLAN tag extractions */ 62 u64 tx_packets; /* # of TX packets */
69 unsigned long vlan_insert; /* # of VLAN tag extractions */ 63 u64 tx_cso; /* # of TX checksum offloads */
70 unsigned long tso; /* # of TSO requests */ 64 u64 tx_tso; /* # of TSO requests */
71 unsigned long rx_drops; /* # of packets dropped due to no mem */ 65 u64 vlan_xtract; /* # of VLAN tag extractions */
66 u64 vlan_insert; /* # of VLAN tag insertions */
72}; 67};
73 68
74struct sk_buff; 69struct sk_buff;
@@ -90,7 +85,11 @@ int t1_sge_intr_error_handler(struct sge *);
90void t1_sge_intr_enable(struct sge *); 85void t1_sge_intr_enable(struct sge *);
91void t1_sge_intr_disable(struct sge *); 86void t1_sge_intr_disable(struct sge *);
92void t1_sge_intr_clear(struct sge *); 87void t1_sge_intr_clear(struct sge *);
93const struct sge_intr_counts *t1_sge_get_intr_counts(struct sge *sge); 88const struct sge_intr_counts *t1_sge_get_intr_counts(const struct sge *sge);
94const struct sge_port_stats *t1_sge_get_port_stats(struct sge *sge, int port); 89void t1_sge_get_port_stats(const struct sge *sge, int port, struct sge_port_stats *);
90void t1_sched_set_max_avail_bytes(struct sge *, unsigned int);
91void t1_sched_set_drain_bits_per_us(struct sge *, unsigned int, unsigned int);
92unsigned int t1_sched_update_parms(struct sge *, unsigned int, unsigned int,
93 unsigned int);
95 94
96#endif /* _CXGB_SGE_H_ */ 95#endif /* _CXGB_SGE_H_ */
diff --git a/drivers/net/chelsio/subr.c b/drivers/net/chelsio/subr.c
index 12e4e96dba2d..22ed9a383c08 100644
--- a/drivers/net/chelsio/subr.c
+++ b/drivers/net/chelsio/subr.c
@@ -43,6 +43,7 @@
43#include "gmac.h" 43#include "gmac.h"
44#include "cphy.h" 44#include "cphy.h"
45#include "sge.h" 45#include "sge.h"
46#include "tp.h"
46#include "espi.h" 47#include "espi.h"
47 48
48/** 49/**
@@ -59,7 +60,7 @@
59 * otherwise. 60 * otherwise.
60 */ 61 */
61static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity, 62static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity,
62 int attempts, int delay) 63 int attempts, int delay)
63{ 64{
64 while (1) { 65 while (1) {
65 u32 val = readl(adapter->regs + reg) & mask; 66 u32 val = readl(adapter->regs + reg) & mask;
@@ -78,7 +79,7 @@ static int t1_wait_op_done(adapter_t *adapter, int reg, u32 mask, int polarity,
78/* 79/*
79 * Write a register over the TPI interface (unlocked and locked versions). 80 * Write a register over the TPI interface (unlocked and locked versions).
80 */ 81 */
81static int __t1_tpi_write(adapter_t *adapter, u32 addr, u32 value) 82int __t1_tpi_write(adapter_t *adapter, u32 addr, u32 value)
82{ 83{
83 int tpi_busy; 84 int tpi_busy;
84 85
@@ -98,16 +99,16 @@ int t1_tpi_write(adapter_t *adapter, u32 addr, u32 value)
98{ 99{
99 int ret; 100 int ret;
100 101
101 spin_lock(&(adapter)->tpi_lock); 102 spin_lock(&adapter->tpi_lock);
102 ret = __t1_tpi_write(adapter, addr, value); 103 ret = __t1_tpi_write(adapter, addr, value);
103 spin_unlock(&(adapter)->tpi_lock); 104 spin_unlock(&adapter->tpi_lock);
104 return ret; 105 return ret;
105} 106}
106 107
107/* 108/*
108 * Read a register over the TPI interface (unlocked and locked versions). 109 * Read a register over the TPI interface (unlocked and locked versions).
109 */ 110 */
110static int __t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp) 111int __t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp)
111{ 112{
112 int tpi_busy; 113 int tpi_busy;
113 114
@@ -128,18 +129,26 @@ int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp)
128{ 129{
129 int ret; 130 int ret;
130 131
131 spin_lock(&(adapter)->tpi_lock); 132 spin_lock(&adapter->tpi_lock);
132 ret = __t1_tpi_read(adapter, addr, valp); 133 ret = __t1_tpi_read(adapter, addr, valp);
133 spin_unlock(&(adapter)->tpi_lock); 134 spin_unlock(&adapter->tpi_lock);
134 return ret; 135 return ret;
135} 136}
136 137
137/* 138/*
139 * Set a TPI parameter.
140 */
141static void t1_tpi_par(adapter_t *adapter, u32 value)
142{
143 writel(V_TPIPAR(value), adapter->regs + A_TPI_PAR);
144}
145
146/*
138 * Called when a port's link settings change to propagate the new values to the 147 * Called when a port's link settings change to propagate the new values to the
139 * associated PHY and MAC. After performing the common tasks it invokes an 148 * associated PHY and MAC. After performing the common tasks it invokes an
140 * OS-specific handler. 149 * OS-specific handler.
141 */ 150 */
142/* static */ void link_changed(adapter_t *adapter, int port_id) 151void t1_link_changed(adapter_t *adapter, int port_id)
143{ 152{
144 int link_ok, speed, duplex, fc; 153 int link_ok, speed, duplex, fc;
145 struct cphy *phy = adapter->port[port_id].phy; 154 struct cphy *phy = adapter->port[port_id].phy;
@@ -159,23 +168,83 @@ int t1_tpi_read(adapter_t *adapter, u32 addr, u32 *valp)
159 mac->ops->set_speed_duplex_fc(mac, speed, duplex, fc); 168 mac->ops->set_speed_duplex_fc(mac, speed, duplex, fc);
160 lc->fc = (unsigned char)fc; 169 lc->fc = (unsigned char)fc;
161 } 170 }
162 t1_link_changed(adapter, port_id, link_ok, speed, duplex, fc); 171 t1_link_negotiated(adapter, port_id, link_ok, speed, duplex, fc);
163} 172}
164 173
165static int t1_pci_intr_handler(adapter_t *adapter) 174static int t1_pci_intr_handler(adapter_t *adapter)
166{ 175{
167 u32 pcix_cause; 176 u32 pcix_cause;
168 177
169 pci_read_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, &pcix_cause); 178 pci_read_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, &pcix_cause);
170 179
171 if (pcix_cause) { 180 if (pcix_cause) {
172 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, 181 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE,
173 pcix_cause); 182 pcix_cause);
174 t1_fatal_err(adapter); /* PCI errors are fatal */ 183 t1_fatal_err(adapter); /* PCI errors are fatal */
175 } 184 }
176 return 0; 185 return 0;
177} 186}
178 187
188#ifdef CONFIG_CHELSIO_T1_COUGAR
189#include "cspi.h"
190#endif
191#ifdef CONFIG_CHELSIO_T1_1G
192#include "fpga_defs.h"
193
194/*
195 * PHY interrupt handler for FPGA boards.
196 */
197static int fpga_phy_intr_handler(adapter_t *adapter)
198{
199 int p;
200 u32 cause = readl(adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
201
202 for_each_port(adapter, p)
203 if (cause & (1 << p)) {
204 struct cphy *phy = adapter->port[p].phy;
205 int phy_cause = phy->ops->interrupt_handler(phy);
206
207 if (phy_cause & cphy_cause_link_change)
208 t1_link_changed(adapter, p);
209 }
210 writel(cause, adapter->regs + FPGA_GMAC_ADDR_INTERRUPT_CAUSE);
211 return 0;
212}
213
214/*
215 * Slow path interrupt handler for FPGAs.
216 */
217static int fpga_slow_intr(adapter_t *adapter)
218{
219 u32 cause = readl(adapter->regs + A_PL_CAUSE);
220
221 cause &= ~F_PL_INTR_SGE_DATA;
222 if (cause & F_PL_INTR_SGE_ERR)
223 t1_sge_intr_error_handler(adapter->sge);
224
225 if (cause & FPGA_PCIX_INTERRUPT_GMAC)
226 fpga_phy_intr_handler(adapter);
227
228 if (cause & FPGA_PCIX_INTERRUPT_TP) {
229 /*
230 * FPGA doesn't support MC4 interrupts and it requires
231 * this odd layer of indirection for MC5.
232 */
233 u32 tp_cause = readl(adapter->regs + FPGA_TP_ADDR_INTERRUPT_CAUSE);
234
235 /* Clear TP interrupt */
236 writel(tp_cause, adapter->regs + FPGA_TP_ADDR_INTERRUPT_CAUSE);
237 }
238 if (cause & FPGA_PCIX_INTERRUPT_PCIX)
239 t1_pci_intr_handler(adapter);
240
241 /* Clear the interrupts just processed. */
242 if (cause)
243 writel(cause, adapter->regs + A_PL_CAUSE);
244
245 return cause != 0;
246}
247#endif
179 248
180/* 249/*
181 * Wait until Elmer's MI1 interface is ready for new operations. 250 * Wait until Elmer's MI1 interface is ready for new operations.
@@ -212,12 +281,62 @@ static void mi1_mdio_init(adapter_t *adapter, const struct board_info *bi)
212 t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_CFG, val); 281 t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_CFG, val);
213} 282}
214 283
284#if defined(CONFIG_CHELSIO_T1_1G) || defined(CONFIG_CHELSIO_T1_COUGAR)
285/*
286 * Elmer MI1 MDIO read/write operations.
287 */
288static int mi1_mdio_read(adapter_t *adapter, int phy_addr, int mmd_addr,
289 int reg_addr, unsigned int *valp)
290{
291 u32 addr = V_MI1_REG_ADDR(reg_addr) | V_MI1_PHY_ADDR(phy_addr);
292
293 if (mmd_addr)
294 return -EINVAL;
295
296 spin_lock(&adapter->tpi_lock);
297 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
298 __t1_tpi_write(adapter,
299 A_ELMER0_PORT0_MI1_OP, MI1_OP_DIRECT_READ);
300 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
301 __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp);
302 spin_unlock(&adapter->tpi_lock);
303 return 0;
304}
305
306static int mi1_mdio_write(adapter_t *adapter, int phy_addr, int mmd_addr,
307 int reg_addr, unsigned int val)
308{
309 u32 addr = V_MI1_REG_ADDR(reg_addr) | V_MI1_PHY_ADDR(phy_addr);
310
311 if (mmd_addr)
312 return -EINVAL;
313
314 spin_lock(&adapter->tpi_lock);
315 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
316 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val);
317 __t1_tpi_write(adapter,
318 A_ELMER0_PORT0_MI1_OP, MI1_OP_DIRECT_WRITE);
319 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
320 spin_unlock(&adapter->tpi_lock);
321 return 0;
322}
323
324#if defined(CONFIG_CHELSIO_T1_1G) || defined(CONFIG_CHELSIO_T1_COUGAR)
325static struct mdio_ops mi1_mdio_ops = {
326 mi1_mdio_init,
327 mi1_mdio_read,
328 mi1_mdio_write
329};
330#endif
331
332#endif
333
215static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr, 334static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr,
216 int reg_addr, unsigned int *valp) 335 int reg_addr, unsigned int *valp)
217{ 336{
218 u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr); 337 u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr);
219 338
220 spin_lock(&(adapter)->tpi_lock); 339 spin_lock(&adapter->tpi_lock);
221 340
222 /* Write the address we want. */ 341 /* Write the address we want. */
223 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr); 342 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
@@ -227,12 +346,13 @@ static int mi1_mdio_ext_read(adapter_t *adapter, int phy_addr, int mmd_addr,
227 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); 346 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
228 347
229 /* Write the operation we want. */ 348 /* Write the operation we want. */
230 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_READ); 349 __t1_tpi_write(adapter,
350 A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_READ);
231 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); 351 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
232 352
233 /* Read the data. */ 353 /* Read the data. */
234 __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp); 354 __t1_tpi_read(adapter, A_ELMER0_PORT0_MI1_DATA, valp);
235 spin_unlock(&(adapter)->tpi_lock); 355 spin_unlock(&adapter->tpi_lock);
236 return 0; 356 return 0;
237} 357}
238 358
@@ -241,7 +361,7 @@ static int mi1_mdio_ext_write(adapter_t *adapter, int phy_addr, int mmd_addr,
241{ 361{
242 u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr); 362 u32 addr = V_MI1_REG_ADDR(mmd_addr) | V_MI1_PHY_ADDR(phy_addr);
243 363
244 spin_lock(&(adapter)->tpi_lock); 364 spin_lock(&adapter->tpi_lock);
245 365
246 /* Write the address we want. */ 366 /* Write the address we want. */
247 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr); 367 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_ADDR, addr);
@@ -254,7 +374,7 @@ static int mi1_mdio_ext_write(adapter_t *adapter, int phy_addr, int mmd_addr,
254 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val); 374 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_DATA, val);
255 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_WRITE); 375 __t1_tpi_write(adapter, A_ELMER0_PORT0_MI1_OP, MI1_OP_INDIRECT_WRITE);
256 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP); 376 mi1_wait_until_ready(adapter, A_ELMER0_PORT0_MI1_OP);
257 spin_unlock(&(adapter)->tpi_lock); 377 spin_unlock(&adapter->tpi_lock);
258 return 0; 378 return 0;
259} 379}
260 380
@@ -265,12 +385,25 @@ static struct mdio_ops mi1_mdio_ext_ops = {
265}; 385};
266 386
267enum { 387enum {
388 CH_BRD_T110_1CU,
268 CH_BRD_N110_1F, 389 CH_BRD_N110_1F,
269 CH_BRD_N210_1F, 390 CH_BRD_N210_1F,
391 CH_BRD_T210_1F,
392 CH_BRD_T210_1CU,
393 CH_BRD_N204_4CU,
270}; 394};
271 395
272static struct board_info t1_board[] = { 396static struct board_info t1_board[] = {
273 397
398{ CHBT_BOARD_CHT110, 1/*ports#*/,
399 SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T1,
400 CHBT_MAC_PM3393, CHBT_PHY_MY3126,
401 125000000/*clk-core*/, 150000000/*clk-mc3*/, 125000000/*clk-mc4*/,
402 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 1/*mdien*/,
403 1/*mdiinv*/, 1/*mdc*/, 1/*phybaseaddr*/, &t1_pm3393_ops,
404 &t1_my3126_ops, &mi1_mdio_ext_ops,
405 "Chelsio T110 1x10GBase-CX4 TOE" },
406
274{ CHBT_BOARD_N110, 1/*ports#*/, 407{ CHBT_BOARD_N110, 1/*ports#*/,
275 SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE /*caps*/, CHBT_TERM_T1, 408 SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE /*caps*/, CHBT_TERM_T1,
276 CHBT_MAC_PM3393, CHBT_PHY_88X2010, 409 CHBT_MAC_PM3393, CHBT_PHY_88X2010,
@@ -289,12 +422,47 @@ static struct board_info t1_board[] = {
289 &t1_mv88x201x_ops, &mi1_mdio_ext_ops, 422 &t1_mv88x201x_ops, &mi1_mdio_ext_ops,
290 "Chelsio N210 1x10GBaseX NIC" }, 423 "Chelsio N210 1x10GBaseX NIC" },
291 424
425{ CHBT_BOARD_CHT210, 1/*ports#*/,
426 SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T2,
427 CHBT_MAC_PM3393, CHBT_PHY_88X2010,
428 125000000/*clk-core*/, 133000000/*clk-mc3*/, 125000000/*clk-mc4*/,
429 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 0/*mdien*/,
430 0/*mdiinv*/, 1/*mdc*/, 0/*phybaseaddr*/, &t1_pm3393_ops,
431 &t1_mv88x201x_ops, &mi1_mdio_ext_ops,
432 "Chelsio T210 1x10GBaseX TOE" },
433
434{ CHBT_BOARD_CHT210, 1/*ports#*/,
435 SUPPORTED_10000baseT_Full /*caps*/, CHBT_TERM_T2,
436 CHBT_MAC_PM3393, CHBT_PHY_MY3126,
437 125000000/*clk-core*/, 133000000/*clk-mc3*/, 125000000/*clk-mc4*/,
438 1/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 1/*mdien*/,
439 1/*mdiinv*/, 1/*mdc*/, 1/*phybaseaddr*/, &t1_pm3393_ops,
440 &t1_my3126_ops, &mi1_mdio_ext_ops,
441 "Chelsio T210 1x10GBase-CX4 TOE" },
442
443#ifdef CONFIG_CHELSIO_T1_1G
444{ CHBT_BOARD_CHN204, 4/*ports#*/,
445 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half |
446 SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full | SUPPORTED_Autoneg |
447 SUPPORTED_PAUSE | SUPPORTED_TP /*caps*/, CHBT_TERM_T2, CHBT_MAC_VSC7321, CHBT_PHY_88E1111,
448 100000000/*clk-core*/, 0/*clk-mc3*/, 0/*clk-mc4*/,
449 4/*espi-ports*/, 0/*clk-cspi*/, 44/*clk-elmer0*/, 0/*mdien*/,
450 0/*mdiinv*/, 1/*mdc*/, 4/*phybaseaddr*/, &t1_vsc7326_ops,
451 &t1_mv88e1xxx_ops, &mi1_mdio_ops,
452 "Chelsio N204 4x100/1000BaseT NIC" },
453#endif
454
292}; 455};
293 456
294struct pci_device_id t1_pci_tbl[] = { 457struct pci_device_id t1_pci_tbl[] = {
458 CH_DEVICE(8, 0, CH_BRD_T110_1CU),
459 CH_DEVICE(8, 1, CH_BRD_T110_1CU),
295 CH_DEVICE(7, 0, CH_BRD_N110_1F), 460 CH_DEVICE(7, 0, CH_BRD_N110_1F),
296 CH_DEVICE(10, 1, CH_BRD_N210_1F), 461 CH_DEVICE(10, 1, CH_BRD_N210_1F),
297 { 0, } 462 CH_DEVICE(11, 1, CH_BRD_T210_1F),
463 CH_DEVICE(14, 1, CH_BRD_T210_1CU),
464 CH_DEVICE(16, 1, CH_BRD_N204_4CU),
465 { 0 }
298}; 466};
299 467
300MODULE_DEVICE_TABLE(pci, t1_pci_tbl); 468MODULE_DEVICE_TABLE(pci, t1_pci_tbl);
@@ -390,9 +558,14 @@ int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc)
390 if (lc->supported & SUPPORTED_Autoneg) { 558 if (lc->supported & SUPPORTED_Autoneg) {
391 lc->advertising &= ~(ADVERTISED_ASYM_PAUSE | ADVERTISED_PAUSE); 559 lc->advertising &= ~(ADVERTISED_ASYM_PAUSE | ADVERTISED_PAUSE);
392 if (fc) { 560 if (fc) {
393 lc->advertising |= ADVERTISED_ASYM_PAUSE; 561 if (fc == ((PAUSE_RX | PAUSE_TX) &
394 if (fc == (PAUSE_RX | PAUSE_TX)) 562 (mac->adapter->params.nports < 2)))
395 lc->advertising |= ADVERTISED_PAUSE; 563 lc->advertising |= ADVERTISED_PAUSE;
564 else {
565 lc->advertising |= ADVERTISED_ASYM_PAUSE;
566 if (fc == PAUSE_RX)
567 lc->advertising |= ADVERTISED_PAUSE;
568 }
396 } 569 }
397 phy->ops->advertise(phy, lc->advertising); 570 phy->ops->advertise(phy, lc->advertising);
398 571
@@ -403,11 +576,15 @@ int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc)
403 mac->ops->set_speed_duplex_fc(mac, lc->speed, 576 mac->ops->set_speed_duplex_fc(mac, lc->speed,
404 lc->duplex, fc); 577 lc->duplex, fc);
405 /* Also disables autoneg */ 578 /* Also disables autoneg */
579 phy->state = PHY_AUTONEG_RDY;
406 phy->ops->set_speed_duplex(phy, lc->speed, lc->duplex); 580 phy->ops->set_speed_duplex(phy, lc->speed, lc->duplex);
407 phy->ops->reset(phy, 0); 581 phy->ops->reset(phy, 0);
408 } else 582 } else {
583 phy->state = PHY_AUTONEG_EN;
409 phy->ops->autoneg_enable(phy); /* also resets PHY */ 584 phy->ops->autoneg_enable(phy); /* also resets PHY */
585 }
410 } else { 586 } else {
587 phy->state = PHY_AUTONEG_RDY;
411 mac->ops->set_speed_duplex_fc(mac, -1, -1, fc); 588 mac->ops->set_speed_duplex_fc(mac, -1, -1, fc);
412 lc->fc = (unsigned char)fc; 589 lc->fc = (unsigned char)fc;
413 phy->ops->reset(phy, 0); 590 phy->ops->reset(phy, 0);
@@ -418,24 +595,109 @@ int t1_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc)
418/* 595/*
419 * External interrupt handler for boards using elmer0. 596 * External interrupt handler for boards using elmer0.
420 */ 597 */
421int elmer0_ext_intr_handler(adapter_t *adapter) 598int t1_elmer0_ext_intr_handler(adapter_t *adapter)
422{ 599{
423 struct cphy *phy; 600 struct cphy *phy;
424 int phy_cause; 601 int phy_cause;
425 u32 cause; 602 u32 cause;
426 603
427 t1_tpi_read(adapter, A_ELMER0_INT_CAUSE, &cause); 604 t1_tpi_read(adapter, A_ELMER0_INT_CAUSE, &cause);
428 605
429 switch (board_info(adapter)->board) { 606 switch (board_info(adapter)->board) {
607#ifdef CONFIG_CHELSIO_T1_1G
608 case CHBT_BOARD_CHT204:
609 case CHBT_BOARD_CHT204E:
610 case CHBT_BOARD_CHN204:
611 case CHBT_BOARD_CHT204V: {
612 int i, port_bit;
613 for_each_port(adapter, i) {
614 port_bit = i + 1;
615 if (!(cause & (1 << port_bit))) continue;
616
617 phy = adapter->port[i].phy;
618 phy_cause = phy->ops->interrupt_handler(phy);
619 if (phy_cause & cphy_cause_link_change)
620 t1_link_changed(adapter, i);
621 }
622 break;
623 }
624 case CHBT_BOARD_CHT101:
625 if (cause & ELMER0_GP_BIT1) { /* Marvell 88E1111 interrupt */
626 phy = adapter->port[0].phy;
627 phy_cause = phy->ops->interrupt_handler(phy);
628 if (phy_cause & cphy_cause_link_change)
629 t1_link_changed(adapter, 0);
630 }
631 break;
632 case CHBT_BOARD_7500: {
633 int p;
634 /*
635 * Elmer0's interrupt cause isn't useful here because there is
636 * only one bit that can be set for all 4 ports. This means
637 * we are forced to check every PHY's interrupt status
638 * register to see who initiated the interrupt.
639 */
640 for_each_port(adapter, p) {
641 phy = adapter->port[p].phy;
642 phy_cause = phy->ops->interrupt_handler(phy);
643 if (phy_cause & cphy_cause_link_change)
644 t1_link_changed(adapter, p);
645 }
646 break;
647 }
648#endif
649 case CHBT_BOARD_CHT210:
430 case CHBT_BOARD_N210: 650 case CHBT_BOARD_N210:
431 case CHBT_BOARD_N110: 651 case CHBT_BOARD_N110:
432 if (cause & ELMER0_GP_BIT6) { /* Marvell 88x2010 interrupt */ 652 if (cause & ELMER0_GP_BIT6) { /* Marvell 88x2010 interrupt */
433 phy = adapter->port[0].phy; 653 phy = adapter->port[0].phy;
434 phy_cause = phy->ops->interrupt_handler(phy); 654 phy_cause = phy->ops->interrupt_handler(phy);
435 if (phy_cause & cphy_cause_link_change) 655 if (phy_cause & cphy_cause_link_change)
436 link_changed(adapter, 0); 656 t1_link_changed(adapter, 0);
657 }
658 break;
659 case CHBT_BOARD_8000:
660 case CHBT_BOARD_CHT110:
661 CH_DBG(adapter, INTR, "External interrupt cause 0x%x\n",
662 cause);
663 if (cause & ELMER0_GP_BIT1) { /* PMC3393 INTB */
664 struct cmac *mac = adapter->port[0].mac;
665
666 mac->ops->interrupt_handler(mac);
437 } 667 }
668 if (cause & ELMER0_GP_BIT5) { /* XPAK MOD_DETECT */
669 u32 mod_detect;
670
671 t1_tpi_read(adapter,
672 A_ELMER0_GPI_STAT, &mod_detect);
673 CH_MSG(adapter, INFO, LINK, "XPAK %s\n",
674 mod_detect ? "removed" : "inserted");
675 }
438 break; 676 break;
677#ifdef CONFIG_CHELSIO_T1_COUGAR
678 case CHBT_BOARD_COUGAR:
679 if (adapter->params.nports == 1) {
680 if (cause & ELMER0_GP_BIT1) { /* Vitesse MAC */
681 struct cmac *mac = adapter->port[0].mac;
682 mac->ops->interrupt_handler(mac);
683 }
684 if (cause & ELMER0_GP_BIT5) { /* XPAK MOD_DETECT */
685 }
686 } else {
687 int i, port_bit;
688
689 for_each_port(adapter, i) {
690 port_bit = i ? i + 1 : 0;
691 if (!(cause & (1 << port_bit))) continue;
692
693 phy = adapter->port[i].phy;
694 phy_cause = phy->ops->interrupt_handler(phy);
695 if (phy_cause & cphy_cause_link_change)
696 t1_link_changed(adapter, i);
697 }
698 }
699 break;
700#endif
439 } 701 }
440 t1_tpi_write(adapter, A_ELMER0_INT_CAUSE, cause); 702 t1_tpi_write(adapter, A_ELMER0_INT_CAUSE, cause);
441 return 0; 703 return 0;
@@ -445,11 +707,11 @@ int elmer0_ext_intr_handler(adapter_t *adapter)
445void t1_interrupts_enable(adapter_t *adapter) 707void t1_interrupts_enable(adapter_t *adapter)
446{ 708{
447 unsigned int i; 709 unsigned int i;
448 u32 pl_intr;
449 710
450 adapter->slow_intr_mask = F_PL_INTR_SGE_ERR; 711 adapter->slow_intr_mask = F_PL_INTR_SGE_ERR | F_PL_INTR_TP;
451 712
452 t1_sge_intr_enable(adapter->sge); 713 t1_sge_intr_enable(adapter->sge);
714 t1_tp_intr_enable(adapter->tp);
453 if (adapter->espi) { 715 if (adapter->espi) {
454 adapter->slow_intr_mask |= F_PL_INTR_ESPI; 716 adapter->slow_intr_mask |= F_PL_INTR_ESPI;
455 t1_espi_intr_enable(adapter->espi); 717 t1_espi_intr_enable(adapter->espi);
@@ -462,15 +724,17 @@ void t1_interrupts_enable(adapter_t *adapter)
462 } 724 }
463 725
464 /* Enable PCIX & external chip interrupts on ASIC boards. */ 726 /* Enable PCIX & external chip interrupts on ASIC boards. */
465 pl_intr = readl(adapter->regs + A_PL_ENABLE); 727 if (t1_is_asic(adapter)) {
728 u32 pl_intr = readl(adapter->regs + A_PL_ENABLE);
466 729
467 /* PCI-X interrupts */ 730 /* PCI-X interrupts */
468 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE, 731 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE,
469 0xffffffff); 732 0xffffffff);
470 733
471 adapter->slow_intr_mask |= F_PL_INTR_EXT | F_PL_INTR_PCIX; 734 adapter->slow_intr_mask |= F_PL_INTR_EXT | F_PL_INTR_PCIX;
472 pl_intr |= F_PL_INTR_EXT | F_PL_INTR_PCIX; 735 pl_intr |= F_PL_INTR_EXT | F_PL_INTR_PCIX;
473 writel(pl_intr, adapter->regs + A_PL_ENABLE); 736 writel(pl_intr, adapter->regs + A_PL_ENABLE);
737 }
474} 738}
475 739
476/* Disables all interrupts. */ 740/* Disables all interrupts. */
@@ -479,6 +743,7 @@ void t1_interrupts_disable(adapter_t* adapter)
479 unsigned int i; 743 unsigned int i;
480 744
481 t1_sge_intr_disable(adapter->sge); 745 t1_sge_intr_disable(adapter->sge);
746 t1_tp_intr_disable(adapter->tp);
482 if (adapter->espi) 747 if (adapter->espi)
483 t1_espi_intr_disable(adapter->espi); 748 t1_espi_intr_disable(adapter->espi);
484 749
@@ -489,7 +754,8 @@ void t1_interrupts_disable(adapter_t* adapter)
489 } 754 }
490 755
491 /* Disable PCIX & external chip interrupts. */ 756 /* Disable PCIX & external chip interrupts. */
492 writel(0, adapter->regs + A_PL_ENABLE); 757 if (t1_is_asic(adapter))
758 writel(0, adapter->regs + A_PL_ENABLE);
493 759
494 /* PCI-X interrupts */ 760 /* PCI-X interrupts */
495 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE, 0); 761 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_ENABLE, 0);
@@ -501,10 +767,9 @@ void t1_interrupts_disable(adapter_t* adapter)
501void t1_interrupts_clear(adapter_t* adapter) 767void t1_interrupts_clear(adapter_t* adapter)
502{ 768{
503 unsigned int i; 769 unsigned int i;
504 u32 pl_intr;
505
506 770
507 t1_sge_intr_clear(adapter->sge); 771 t1_sge_intr_clear(adapter->sge);
772 t1_tp_intr_clear(adapter->tp);
508 if (adapter->espi) 773 if (adapter->espi)
509 t1_espi_intr_clear(adapter->espi); 774 t1_espi_intr_clear(adapter->espi);
510 775
@@ -515,10 +780,12 @@ void t1_interrupts_clear(adapter_t* adapter)
515 } 780 }
516 781
517 /* Enable interrupts for external devices. */ 782 /* Enable interrupts for external devices. */
518 pl_intr = readl(adapter->regs + A_PL_CAUSE); 783 if (t1_is_asic(adapter)) {
784 u32 pl_intr = readl(adapter->regs + A_PL_CAUSE);
519 785
520 writel(pl_intr | F_PL_INTR_EXT | F_PL_INTR_PCIX, 786 writel(pl_intr | F_PL_INTR_EXT | F_PL_INTR_PCIX,
521 adapter->regs + A_PL_CAUSE); 787 adapter->regs + A_PL_CAUSE);
788 }
522 789
523 /* PCI-X interrupts */ 790 /* PCI-X interrupts */
524 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, 0xffffffff); 791 pci_write_config_dword(adapter->pdev, A_PCICFG_INTR_CAUSE, 0xffffffff);
@@ -527,7 +794,7 @@ void t1_interrupts_clear(adapter_t* adapter)
527/* 794/*
528 * Slow path interrupt handler for ASICs. 795 * Slow path interrupt handler for ASICs.
529 */ 796 */
530int t1_slow_intr_handler(adapter_t *adapter) 797static int asic_slow_intr(adapter_t *adapter)
531{ 798{
532 u32 cause = readl(adapter->regs + A_PL_CAUSE); 799 u32 cause = readl(adapter->regs + A_PL_CAUSE);
533 800
@@ -536,89 +803,54 @@ int t1_slow_intr_handler(adapter_t *adapter)
536 return 0; 803 return 0;
537 if (cause & F_PL_INTR_SGE_ERR) 804 if (cause & F_PL_INTR_SGE_ERR)
538 t1_sge_intr_error_handler(adapter->sge); 805 t1_sge_intr_error_handler(adapter->sge);
806 if (cause & F_PL_INTR_TP)
807 t1_tp_intr_handler(adapter->tp);
539 if (cause & F_PL_INTR_ESPI) 808 if (cause & F_PL_INTR_ESPI)
540 t1_espi_intr_handler(adapter->espi); 809 t1_espi_intr_handler(adapter->espi);
541 if (cause & F_PL_INTR_PCIX) 810 if (cause & F_PL_INTR_PCIX)
542 t1_pci_intr_handler(adapter); 811 t1_pci_intr_handler(adapter);
543 if (cause & F_PL_INTR_EXT) 812 if (cause & F_PL_INTR_EXT)
544 t1_elmer0_ext_intr(adapter); 813 t1_elmer0_ext_intr_handler(adapter);
545 814
546 /* Clear the interrupts just processed. */ 815 /* Clear the interrupts just processed. */
547 writel(cause, adapter->regs + A_PL_CAUSE); 816 writel(cause, adapter->regs + A_PL_CAUSE);
548 (void)readl(adapter->regs + A_PL_CAUSE); /* flush writes */ 817 readl(adapter->regs + A_PL_CAUSE); /* flush writes */
549 return 1; 818 return 1;
550} 819}
551 820
552/* Pause deadlock avoidance parameters */ 821int t1_slow_intr_handler(adapter_t *adapter)
553#define DROP_MSEC 16
554#define DROP_PKTS_CNT 1
555
556static void set_csum_offload(adapter_t *adapter, u32 csum_bit, int enable)
557{
558 u32 val = readl(adapter->regs + A_TP_GLOBAL_CONFIG);
559
560 if (enable)
561 val |= csum_bit;
562 else
563 val &= ~csum_bit;
564 writel(val, adapter->regs + A_TP_GLOBAL_CONFIG);
565}
566
567void t1_tp_set_ip_checksum_offload(adapter_t *adapter, int enable)
568{
569 set_csum_offload(adapter, F_IP_CSUM, enable);
570}
571
572void t1_tp_set_udp_checksum_offload(adapter_t *adapter, int enable)
573{
574 set_csum_offload(adapter, F_UDP_CSUM, enable);
575}
576
577void t1_tp_set_tcp_checksum_offload(adapter_t *adapter, int enable)
578{ 822{
579 set_csum_offload(adapter, F_TCP_CSUM, enable); 823#ifdef CONFIG_CHELSIO_T1_1G
824 if (!t1_is_asic(adapter))
825 return fpga_slow_intr(adapter);
826#endif
827 return asic_slow_intr(adapter);
580} 828}
581 829
582static void t1_tp_reset(adapter_t *adapter, unsigned int tp_clk) 830/* Power sequencing is a work-around for Intel's XPAKs. */
831static void power_sequence_xpak(adapter_t* adapter)
583{ 832{
584 u32 val; 833 u32 mod_detect;
585 834 u32 gpo;
586 val = F_TP_IN_CSPI_CPL | F_TP_IN_CSPI_CHECK_IP_CSUM | 835
587 F_TP_IN_CSPI_CHECK_TCP_CSUM | F_TP_IN_ESPI_ETHERNET; 836 /* Check for XPAK */
588 val |= F_TP_IN_ESPI_CHECK_IP_CSUM | 837 t1_tpi_read(adapter, A_ELMER0_GPI_STAT, &mod_detect);
589 F_TP_IN_ESPI_CHECK_TCP_CSUM; 838 if (!(ELMER0_GP_BIT5 & mod_detect)) {
590 writel(val, adapter->regs + A_TP_IN_CONFIG); 839 /* XPAK is present */
591 writel(F_TP_OUT_CSPI_CPL | 840 t1_tpi_read(adapter, A_ELMER0_GPO, &gpo);
592 F_TP_OUT_ESPI_ETHERNET | 841 gpo |= ELMER0_GP_BIT18;
593 F_TP_OUT_ESPI_GENERATE_IP_CSUM | 842 t1_tpi_write(adapter, A_ELMER0_GPO, gpo);
594 F_TP_OUT_ESPI_GENERATE_TCP_CSUM,
595 adapter->regs + A_TP_OUT_CONFIG);
596
597 val = readl(adapter->regs + A_TP_GLOBAL_CONFIG);
598 val &= ~(F_IP_CSUM | F_UDP_CSUM | F_TCP_CSUM);
599 writel(val, adapter->regs + A_TP_GLOBAL_CONFIG);
600
601 /*
602 * Enable pause frame deadlock prevention.
603 */
604 if (is_T2(adapter)) {
605 u32 drop_ticks = DROP_MSEC * (tp_clk / 1000);
606
607 writel(F_ENABLE_TX_DROP | F_ENABLE_TX_ERROR |
608 V_DROP_TICKS_CNT(drop_ticks) |
609 V_NUM_PKTS_DROPPED(DROP_PKTS_CNT),
610 adapter->regs + A_TP_TX_DROP_CONFIG);
611 } 843 }
612
613 writel(F_TP_RESET, adapter->regs + A_TP_RESET);
614} 844}
615 845
616int __devinit t1_get_board_rev(adapter_t *adapter, const struct board_info *bi, 846int __devinit t1_get_board_rev(adapter_t *adapter, const struct board_info *bi,
617 struct adapter_params *p) 847 struct adapter_params *p)
618{ 848{
619 p->chip_version = bi->chip_term; 849 p->chip_version = bi->chip_term;
850 p->is_asic = (p->chip_version != CHBT_TERM_FPGA);
620 if (p->chip_version == CHBT_TERM_T1 || 851 if (p->chip_version == CHBT_TERM_T1 ||
621 p->chip_version == CHBT_TERM_T2) { 852 p->chip_version == CHBT_TERM_T2 ||
853 p->chip_version == CHBT_TERM_FPGA) {
622 u32 val = readl(adapter->regs + A_TP_PC_CONFIG); 854 u32 val = readl(adapter->regs + A_TP_PC_CONFIG);
623 855
624 val = G_TP_PC_REV(val); 856 val = G_TP_PC_REV(val);
@@ -640,11 +872,38 @@ int __devinit t1_get_board_rev(adapter_t *adapter, const struct board_info *bi,
640static int board_init(adapter_t *adapter, const struct board_info *bi) 872static int board_init(adapter_t *adapter, const struct board_info *bi)
641{ 873{
642 switch (bi->board) { 874 switch (bi->board) {
875 case CHBT_BOARD_8000:
643 case CHBT_BOARD_N110: 876 case CHBT_BOARD_N110:
644 case CHBT_BOARD_N210: 877 case CHBT_BOARD_N210:
645 writel(V_TPIPAR(0xf), adapter->regs + A_TPI_PAR); 878 case CHBT_BOARD_CHT210:
879 case CHBT_BOARD_COUGAR:
880 t1_tpi_par(adapter, 0xf);
646 t1_tpi_write(adapter, A_ELMER0_GPO, 0x800); 881 t1_tpi_write(adapter, A_ELMER0_GPO, 0x800);
647 break; 882 break;
883 case CHBT_BOARD_CHT110:
884 t1_tpi_par(adapter, 0xf);
885 t1_tpi_write(adapter, A_ELMER0_GPO, 0x1800);
886
887 /* TBD XXX Might not need. This fixes a problem
888 * described in the Intel SR XPAK errata.
889 */
890 power_sequence_xpak(adapter);
891 break;
892#ifdef CONFIG_CHELSIO_T1_1G
893 case CHBT_BOARD_CHT204E:
894 /* add config space write here */
895 case CHBT_BOARD_CHT204:
896 case CHBT_BOARD_CHT204V:
897 case CHBT_BOARD_CHN204:
898 t1_tpi_par(adapter, 0xf);
899 t1_tpi_write(adapter, A_ELMER0_GPO, 0x804);
900 break;
901 case CHBT_BOARD_CHT101:
902 case CHBT_BOARD_7500:
903 t1_tpi_par(adapter, 0xf);
904 t1_tpi_write(adapter, A_ELMER0_GPO, 0x1804);
905 break;
906#endif
648 } 907 }
649 return 0; 908 return 0;
650} 909}
@@ -666,11 +925,16 @@ int t1_init_hw_modules(adapter_t *adapter)
666 adapter->regs + A_MC5_CONFIG); 925 adapter->regs + A_MC5_CONFIG);
667 } 926 }
668 927
928#ifdef CONFIG_CHELSIO_T1_COUGAR
929 if (adapter->cspi && t1_cspi_init(adapter->cspi))
930 goto out_err;
931#endif
669 if (adapter->espi && t1_espi_init(adapter->espi, bi->chip_mac, 932 if (adapter->espi && t1_espi_init(adapter->espi, bi->chip_mac,
670 bi->espi_nports)) 933 bi->espi_nports))
671 goto out_err; 934 goto out_err;
672 935
673 t1_tp_reset(adapter, bi->clock_core); 936 if (t1_tp_reset(adapter->tp, &adapter->params.tp, bi->clock_core))
937 goto out_err;
674 938
675 err = t1_sge_configure(adapter->sge, &adapter->params.sge); 939 err = t1_sge_configure(adapter->sge, &adapter->params.sge);
676 if (err) 940 if (err)
@@ -714,8 +978,14 @@ void t1_free_sw_modules(adapter_t *adapter)
714 978
715 if (adapter->sge) 979 if (adapter->sge)
716 t1_sge_destroy(adapter->sge); 980 t1_sge_destroy(adapter->sge);
981 if (adapter->tp)
982 t1_tp_destroy(adapter->tp);
717 if (adapter->espi) 983 if (adapter->espi)
718 t1_espi_destroy(adapter->espi); 984 t1_espi_destroy(adapter->espi);
985#ifdef CONFIG_CHELSIO_T1_COUGAR
986 if (adapter->cspi)
987 t1_cspi_destroy(adapter->cspi);
988#endif
719} 989}
720 990
721static void __devinit init_link_config(struct link_config *lc, 991static void __devinit init_link_config(struct link_config *lc,
@@ -735,6 +1005,13 @@ static void __devinit init_link_config(struct link_config *lc,
735 } 1005 }
736} 1006}
737 1007
1008#ifdef CONFIG_CHELSIO_T1_COUGAR
1009 if (bi->clock_cspi && !(adapter->cspi = t1_cspi_create(adapter))) {
1010 CH_ERR("%s: CSPI initialization failed\n",
1011 adapter->name);
1012 goto error;
1013 }
1014#endif
738 1015
739/* 1016/*
740 * Allocate and initialize the data structures that hold the SW state of 1017 * Allocate and initialize the data structures that hold the SW state of
@@ -762,6 +1039,13 @@ int __devinit t1_init_sw_modules(adapter_t *adapter,
762 goto error; 1039 goto error;
763 } 1040 }
764 1041
1042 adapter->tp = t1_tp_create(adapter, &adapter->params.tp);
1043 if (!adapter->tp) {
1044 CH_ERR("%s: TP initialization failed\n",
1045 adapter->name);
1046 goto error;
1047 }
1048
765 board_init(adapter, bi); 1049 board_init(adapter, bi);
766 bi->mdio_ops->init(adapter, bi); 1050 bi->mdio_ops->init(adapter, bi);
767 if (bi->gphy->reset) 1051 if (bi->gphy->reset)
@@ -793,7 +1077,9 @@ int __devinit t1_init_sw_modules(adapter_t *adapter,
793 * Get the port's MAC addresses either from the EEPROM if one 1077 * Get the port's MAC addresses either from the EEPROM if one
794 * exists or the one hardcoded in the MAC. 1078 * exists or the one hardcoded in the MAC.
795 */ 1079 */
796 if (vpd_macaddress_get(adapter, i, hw_addr)) { 1080 if (!t1_is_asic(adapter) || bi->chip_mac == CHBT_MAC_DUMMY)
1081 mac->ops->macaddress_get(mac, hw_addr);
1082 else if (vpd_macaddress_get(adapter, i, hw_addr)) {
797 CH_ERR("%s: could not read MAC address from VPD ROM\n", 1083 CH_ERR("%s: could not read MAC address from VPD ROM\n",
798 adapter->port[i].dev->name); 1084 adapter->port[i].dev->name);
799 goto error; 1085 goto error;
@@ -806,7 +1092,7 @@ int __devinit t1_init_sw_modules(adapter_t *adapter,
806 t1_interrupts_clear(adapter); 1092 t1_interrupts_clear(adapter);
807 return 0; 1093 return 0;
808 1094
809 error: 1095error:
810 t1_free_sw_modules(adapter); 1096 t1_free_sw_modules(adapter);
811 return -1; 1097 return -1;
812} 1098}
diff --git a/drivers/net/chelsio/suni1x10gexp_regs.h b/drivers/net/chelsio/suni1x10gexp_regs.h
index 81816c2b708a..269d097dd927 100644
--- a/drivers/net/chelsio/suni1x10gexp_regs.h
+++ b/drivers/net/chelsio/suni1x10gexp_regs.h
@@ -32,6 +32,30 @@
32#ifndef _CXGB_SUNI1x10GEXP_REGS_H_ 32#ifndef _CXGB_SUNI1x10GEXP_REGS_H_
33#define _CXGB_SUNI1x10GEXP_REGS_H_ 33#define _CXGB_SUNI1x10GEXP_REGS_H_
34 34
35/*
36** Space allocated for each Exact Match Filter
37** There are 8 filter configurations
38*/
39#define SUNI1x10GEXP_REG_SIZEOF_MAC_FILTER 0x0003
40
41#define mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId) ( (filterId) * SUNI1x10GEXP_REG_SIZEOF_MAC_FILTER )
42
43/*
44** Space allocated for VLAN-Id Filter
45** There are 8 filter configurations
46*/
47#define SUNI1x10GEXP_REG_SIZEOF_MAC_VID_FILTER 0x0001
48
49#define mSUNI1x10GEXP_MAC_VID_FILTER_OFFSET(filterId) ( (filterId) * SUNI1x10GEXP_REG_SIZEOF_MAC_VID_FILTER )
50
51/*
52** Space allocated for each MSTAT Counter
53*/
54#define SUNI1x10GEXP_REG_SIZEOF_MSTAT_COUNT 0x0004
55
56#define mSUNI1x10GEXP_MSTAT_COUNT_OFFSET(countId) ( (countId) * SUNI1x10GEXP_REG_SIZEOF_MSTAT_COUNT )
57
58
35/******************************************************************************/ 59/******************************************************************************/
36/** S/UNI-1x10GE-XP REGISTER ADDRESS MAP **/ 60/** S/UNI-1x10GE-XP REGISTER ADDRESS MAP **/
37/******************************************************************************/ 61/******************************************************************************/
@@ -39,33 +63,125 @@
39/* to the S/UNI-1x10GE-XP Data Sheet for the signification of each bit */ 63/* to the S/UNI-1x10GE-XP Data Sheet for the signification of each bit */
40/******************************************************************************/ 64/******************************************************************************/
41 65
66
67#define SUNI1x10GEXP_REG_IDENTIFICATION 0x0000
68#define SUNI1x10GEXP_REG_PRODUCT_REVISION 0x0001
69#define SUNI1x10GEXP_REG_CONFIG_AND_RESET_CONTROL 0x0002
70#define SUNI1x10GEXP_REG_LOOPBACK_MISC_CTRL 0x0003
42#define SUNI1x10GEXP_REG_DEVICE_STATUS 0x0004 71#define SUNI1x10GEXP_REG_DEVICE_STATUS 0x0004
72#define SUNI1x10GEXP_REG_GLOBAL_PERFORMANCE_MONITOR_UPDATE 0x0005
73
74#define SUNI1x10GEXP_REG_MDIO_COMMAND 0x0006
75#define SUNI1x10GEXP_REG_MDIO_INTERRUPT_ENABLE 0x0007
76#define SUNI1x10GEXP_REG_MDIO_INTERRUPT_STATUS 0x0008
77#define SUNI1x10GEXP_REG_MMD_PHY_ADDRESS 0x0009
78#define SUNI1x10GEXP_REG_MMD_CONTROL_ADDRESS_DATA 0x000A
79#define SUNI1x10GEXP_REG_MDIO_READ_STATUS_DATA 0x000B
80
81#define SUNI1x10GEXP_REG_OAM_INTF_CTRL 0x000C
43#define SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS 0x000D 82#define SUNI1x10GEXP_REG_MASTER_INTERRUPT_STATUS 0x000D
44#define SUNI1x10GEXP_REG_GLOBAL_INTERRUPT_ENABLE 0x000E 83#define SUNI1x10GEXP_REG_GLOBAL_INTERRUPT_ENABLE 0x000E
84#define SUNI1x10GEXP_REG_FREE 0x000F
85
86#define SUNI1x10GEXP_REG_XTEF_MISC_CTRL 0x0010
87#define SUNI1x10GEXP_REG_XRF_MISC_CTRL 0x0011
88
89#define SUNI1x10GEXP_REG_SERDES_3125_CONFIG_1 0x0100
90#define SUNI1x10GEXP_REG_SERDES_3125_CONFIG_2 0x0101
45#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_ENABLE 0x0102 91#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_ENABLE 0x0102
92#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_VISIBLE 0x0103
46#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_STATUS 0x0104 93#define SUNI1x10GEXP_REG_SERDES_3125_INTERRUPT_STATUS 0x0104
94#define SUNI1x10GEXP_REG_SERDES_3125_TEST_CONFIG 0x0107
95
47#define SUNI1x10GEXP_REG_RXXG_CONFIG_1 0x2040 96#define SUNI1x10GEXP_REG_RXXG_CONFIG_1 0x2040
97#define SUNI1x10GEXP_REG_RXXG_CONFIG_2 0x2041
48#define SUNI1x10GEXP_REG_RXXG_CONFIG_3 0x2042 98#define SUNI1x10GEXP_REG_RXXG_CONFIG_3 0x2042
49#define SUNI1x10GEXP_REG_RXXG_INTERRUPT 0x2043 99#define SUNI1x10GEXP_REG_RXXG_INTERRUPT 0x2043
50#define SUNI1x10GEXP_REG_RXXG_MAX_FRAME_LENGTH 0x2045 100#define SUNI1x10GEXP_REG_RXXG_MAX_FRAME_LENGTH 0x2045
51#define SUNI1x10GEXP_REG_RXXG_SA_15_0 0x2046 101#define SUNI1x10GEXP_REG_RXXG_SA_15_0 0x2046
52#define SUNI1x10GEXP_REG_RXXG_SA_31_16 0x2047 102#define SUNI1x10GEXP_REG_RXXG_SA_31_16 0x2047
53#define SUNI1x10GEXP_REG_RXXG_SA_47_32 0x2048 103#define SUNI1x10GEXP_REG_RXXG_SA_47_32 0x2048
104#define SUNI1x10GEXP_REG_RXXG_RECEIVE_FIFO_THRESHOLD 0x2049
105#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_LOW(filterId) (0x204A + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
106#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_MID(filterId) (0x204B + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
107#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_HIGH(filterId)(0x204C + mSUNI1x10GEXP_MAC_FILTER_OFFSET(filterId))
108#define mSUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID(filterId) (0x2062 + mSUNI1x10GEXP_MAC_VID_FILTER_OFFSET(filterId)
109#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_LOW 0x204A
110#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_MID 0x204B
111#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_0_HIGH 0x204C
54#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_LOW 0x204D 112#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_LOW 0x204D
55#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_MID 0x204E 113#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_MID 0x204E
56#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_HIGH 0x204F 114#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_1_HIGH 0x204F
115#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_2_LOW 0x2050
116#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_2_MID 0x2051
117#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_2_HIGH 0x2052
118#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_3_LOW 0x2053
119#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_3_MID 0x2054
120#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_3_HIGH 0x2055
121#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_4_LOW 0x2056
122#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_4_MID 0x2057
123#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_4_HIGH 0x2058
124#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_5_LOW 0x2059
125#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_5_MID 0x205A
126#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_5_HIGH 0x205B
127#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_6_LOW 0x205C
128#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_6_MID 0x205D
129#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_6_HIGH 0x205E
130#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_7_LOW 0x205F
131#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_7_MID 0x2060
132#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_ADDR_7_HIGH 0x2061
133#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_0 0x2062
134#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_1 0x2063
135#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_2 0x2064
136#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_3 0x2065
137#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_4 0x2066
138#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_5 0x2067
139#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_6 0x2068
140#define SUNI1x10GEXP_REG_RXXG_EXACT_MATCH_VID_7 0x2069
57#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW 0x206A 141#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_LOW 0x206A
58#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDLOW 0x206B 142#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDLOW 0x206B
59#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDHIGH 0x206C 143#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_MIDHIGH 0x206C
60#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_HIGH 0x206D 144#define SUNI1x10GEXP_REG_RXXG_MULTICAST_HASH_HIGH 0x206D
61#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_0 0x206E 145#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_0 0x206E
146#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_1 0x206F
62#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_2 0x2070 147#define SUNI1x10GEXP_REG_RXXG_ADDRESS_FILTER_CONTROL_2 0x2070
148
149#define SUNI1x10GEXP_REG_XRF_PATTERN_GEN_CTRL 0x2081
150#define SUNI1x10GEXP_REG_XRF_8BTB_ERR_COUNT_LANE_0 0x2084
151#define SUNI1x10GEXP_REG_XRF_8BTB_ERR_COUNT_LANE_1 0x2085
152#define SUNI1x10GEXP_REG_XRF_8BTB_ERR_COUNT_LANE_2 0x2086
153#define SUNI1x10GEXP_REG_XRF_8BTB_ERR_COUNT_LANE_3 0x2087
63#define SUNI1x10GEXP_REG_XRF_INTERRUPT_ENABLE 0x2088 154#define SUNI1x10GEXP_REG_XRF_INTERRUPT_ENABLE 0x2088
64#define SUNI1x10GEXP_REG_XRF_INTERRUPT_STATUS 0x2089 155#define SUNI1x10GEXP_REG_XRF_INTERRUPT_STATUS 0x2089
156#define SUNI1x10GEXP_REG_XRF_ERR_STATUS 0x208A
65#define SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_ENABLE 0x208B 157#define SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_ENABLE 0x208B
66#define SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_STATUS 0x208C 158#define SUNI1x10GEXP_REG_XRF_DIAG_INTERRUPT_STATUS 0x208C
159#define SUNI1x10GEXP_REG_XRF_CODE_ERR_THRES 0x2092
160
161#define SUNI1x10GEXP_REG_RXOAM_CONFIG 0x20C0
162#define SUNI1x10GEXP_REG_RXOAM_FILTER_1_CONFIG 0x20C1
163#define SUNI1x10GEXP_REG_RXOAM_FILTER_2_CONFIG 0x20C2
164#define SUNI1x10GEXP_REG_RXOAM_CONFIG_2 0x20C3
165#define SUNI1x10GEXP_REG_RXOAM_HEC_CONFIG 0x20C4
166#define SUNI1x10GEXP_REG_RXOAM_HEC_ERR_THRES 0x20C5
67#define SUNI1x10GEXP_REG_RXOAM_INTERRUPT_ENABLE 0x20C7 167#define SUNI1x10GEXP_REG_RXOAM_INTERRUPT_ENABLE 0x20C7
68#define SUNI1x10GEXP_REG_RXOAM_INTERRUPT_STATUS 0x20C8 168#define SUNI1x10GEXP_REG_RXOAM_INTERRUPT_STATUS 0x20C8
169#define SUNI1x10GEXP_REG_RXOAM_STATUS 0x20C9
170#define SUNI1x10GEXP_REG_RXOAM_HEC_ERR_COUNT 0x20CA
171#define SUNI1x10GEXP_REG_RXOAM_FIFO_OVERFLOW_COUNT 0x20CB
172#define SUNI1x10GEXP_REG_RXOAM_FILTER_MISMATCH_COUNT_LSB 0x20CC
173#define SUNI1x10GEXP_REG_RXOAM_FILTER_MISMATCH_COUNT_MSB 0x20CD
174#define SUNI1x10GEXP_REG_RXOAM_FILTER_1_MISMATCH_COUNT_LSB 0x20CE
175#define SUNI1x10GEXP_REG_RXOAM_FILTER_1_MISMATCH_COUNT_MSB 0x20CF
176#define SUNI1x10GEXP_REG_RXOAM_FILTER_2_MISMATCH_COUNT_LSB 0x20D0
177#define SUNI1x10GEXP_REG_RXOAM_FILTER_2_MISMATCH_COUNT_MSB 0x20D1
178#define SUNI1x10GEXP_REG_RXOAM_OAM_EXTRACT_COUNT_LSB 0x20D2
179#define SUNI1x10GEXP_REG_RXOAM_OAM_EXTRACT_COUNT_MSB 0x20D3
180#define SUNI1x10GEXP_REG_RXOAM_MINI_PACKET_COUNT_LSB 0x20D4
181#define SUNI1x10GEXP_REG_RXOAM_MINI_PACKET_COUNT_MSB 0x20D5
182#define SUNI1x10GEXP_REG_RXOAM_FILTER_MISMATCH_THRES_LSB 0x20D6
183#define SUNI1x10GEXP_REG_RXOAM_FILTER_MISMATCH_THRES_MSB 0x20D7
184
69#define SUNI1x10GEXP_REG_MSTAT_CONTROL 0x2100 185#define SUNI1x10GEXP_REG_MSTAT_CONTROL 0x2100
70#define SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_0 0x2101 186#define SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_0 0x2101
71#define SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_1 0x2102 187#define SUNI1x10GEXP_REG_MSTAT_COUNTER_ROLLOVER_1 0x2102
@@ -75,50 +191,321 @@
75#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_1 0x2106 191#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_1 0x2106
76#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_2 0x2107 192#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_2 0x2107
77#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_3 0x2108 193#define SUNI1x10GEXP_REG_MSTAT_INTERRUPT_MASK_3 0x2108
194#define SUNI1x10GEXP_REG_MSTAT_COUNTER_WRITE_ADDRESS 0x2109
195#define SUNI1x10GEXP_REG_MSTAT_COUNTER_WRITE_DATA_LOW 0x210A
196#define SUNI1x10GEXP_REG_MSTAT_COUNTER_WRITE_DATA_MIDDLE 0x210B
197#define SUNI1x10GEXP_REG_MSTAT_COUNTER_WRITE_DATA_HIGH 0x210C
198#define mSUNI1x10GEXP_REG_MSTAT_COUNTER_LOW(countId) (0x2110 + mSUNI1x10GEXP_MSTAT_COUNT_OFFSET(countId))
199#define mSUNI1x10GEXP_REG_MSTAT_COUNTER_MID(countId) (0x2111 + mSUNI1x10GEXP_MSTAT_COUNT_OFFSET(countId))
200#define mSUNI1x10GEXP_REG_MSTAT_COUNTER_HIGH(countId) (0x2112 + mSUNI1x10GEXP_MSTAT_COUNT_OFFSET(countId))
78#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW 0x2110 201#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW 0x2110
202#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_MID 0x2111
203#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_HIGH 0x2112
204#define SUNI1x10GEXP_REG_MSTAT_COUNTER_0_RESVD 0x2113
79#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_LOW 0x2114 205#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_LOW 0x2114
206#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_MID 0x2115
207#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_HIGH 0x2116
208#define SUNI1x10GEXP_REG_MSTAT_COUNTER_1_RESVD 0x2117
209#define SUNI1x10GEXP_REG_MSTAT_COUNTER_2_LOW 0x2118
210#define SUNI1x10GEXP_REG_MSTAT_COUNTER_2_MID 0x2119
211#define SUNI1x10GEXP_REG_MSTAT_COUNTER_2_HIGH 0x211A
212#define SUNI1x10GEXP_REG_MSTAT_COUNTER_2_RESVD 0x211B
213#define SUNI1x10GEXP_REG_MSTAT_COUNTER_3_LOW 0x211C
214#define SUNI1x10GEXP_REG_MSTAT_COUNTER_3_MID 0x211D
215#define SUNI1x10GEXP_REG_MSTAT_COUNTER_3_HIGH 0x211E
216#define SUNI1x10GEXP_REG_MSTAT_COUNTER_3_RESVD 0x211F
80#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_LOW 0x2120 217#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_LOW 0x2120
218#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_MID 0x2121
219#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_HIGH 0x2122
220#define SUNI1x10GEXP_REG_MSTAT_COUNTER_4_RESVD 0x2123
81#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_LOW 0x2124 221#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_LOW 0x2124
222#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_MID 0x2125
223#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_HIGH 0x2126
224#define SUNI1x10GEXP_REG_MSTAT_COUNTER_5_RESVD 0x2127
82#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_LOW 0x2128 225#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_LOW 0x2128
226#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_MID 0x2129
227#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_HIGH 0x212A
228#define SUNI1x10GEXP_REG_MSTAT_COUNTER_6_RESVD 0x212B
229#define SUNI1x10GEXP_REG_MSTAT_COUNTER_7_LOW 0x212C
230#define SUNI1x10GEXP_REG_MSTAT_COUNTER_7_MID 0x212D
231#define SUNI1x10GEXP_REG_MSTAT_COUNTER_7_HIGH 0x212E
232#define SUNI1x10GEXP_REG_MSTAT_COUNTER_7_RESVD 0x212F
83#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_LOW 0x2130 233#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_LOW 0x2130
234#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_MID 0x2131
235#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_HIGH 0x2132
236#define SUNI1x10GEXP_REG_MSTAT_COUNTER_8_RESVD 0x2133
237#define SUNI1x10GEXP_REG_MSTAT_COUNTER_9_LOW 0x2134
238#define SUNI1x10GEXP_REG_MSTAT_COUNTER_9_MID 0x2135
239#define SUNI1x10GEXP_REG_MSTAT_COUNTER_9_HIGH 0x2136
240#define SUNI1x10GEXP_REG_MSTAT_COUNTER_9_RESVD 0x2137
84#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_LOW 0x2138 241#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_LOW 0x2138
242#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_MID 0x2139
243#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_HIGH 0x213A
244#define SUNI1x10GEXP_REG_MSTAT_COUNTER_10_RESVD 0x213B
85#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_LOW 0x213C 245#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_LOW 0x213C
246#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_MID 0x213D
247#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_HIGH 0x213E
248#define SUNI1x10GEXP_REG_MSTAT_COUNTER_11_RESVD 0x213F
86#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_LOW 0x2140 249#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_LOW 0x2140
250#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_MID 0x2141
251#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_HIGH 0x2142
252#define SUNI1x10GEXP_REG_MSTAT_COUNTER_12_RESVD 0x2143
87#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_LOW 0x2144 253#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_LOW 0x2144
254#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_MID 0x2145
255#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_HIGH 0x2146
256#define SUNI1x10GEXP_REG_MSTAT_COUNTER_13_RESVD 0x2147
257#define SUNI1x10GEXP_REG_MSTAT_COUNTER_14_LOW 0x2148
258#define SUNI1x10GEXP_REG_MSTAT_COUNTER_14_MID 0x2149
259#define SUNI1x10GEXP_REG_MSTAT_COUNTER_14_HIGH 0x214A
260#define SUNI1x10GEXP_REG_MSTAT_COUNTER_14_RESVD 0x214B
88#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_LOW 0x214C 261#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_LOW 0x214C
262#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_MID 0x214D
263#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_HIGH 0x214E
264#define SUNI1x10GEXP_REG_MSTAT_COUNTER_15_RESVD 0x214F
89#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW 0x2150 265#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_LOW 0x2150
266#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_MID 0x2151
267#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_HIGH 0x2152
268#define SUNI1x10GEXP_REG_MSTAT_COUNTER_16_RESVD 0x2153
90#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW 0x2154 269#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_LOW 0x2154
270#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_MID 0x2155
271#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_HIGH 0x2156
272#define SUNI1x10GEXP_REG_MSTAT_COUNTER_17_RESVD 0x2157
91#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW 0x2158 273#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_LOW 0x2158
274#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_MID 0x2159
275#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_HIGH 0x215A
276#define SUNI1x10GEXP_REG_MSTAT_COUNTER_18_RESVD 0x215B
277#define SUNI1x10GEXP_REG_MSTAT_COUNTER_19_LOW 0x215C
278#define SUNI1x10GEXP_REG_MSTAT_COUNTER_19_MID 0x215D
279#define SUNI1x10GEXP_REG_MSTAT_COUNTER_19_HIGH 0x215E
280#define SUNI1x10GEXP_REG_MSTAT_COUNTER_19_RESVD 0x215F
281#define SUNI1x10GEXP_REG_MSTAT_COUNTER_20_LOW 0x2160
282#define SUNI1x10GEXP_REG_MSTAT_COUNTER_20_MID 0x2161
283#define SUNI1x10GEXP_REG_MSTAT_COUNTER_20_HIGH 0x2162
284#define SUNI1x10GEXP_REG_MSTAT_COUNTER_20_RESVD 0x2163
285#define SUNI1x10GEXP_REG_MSTAT_COUNTER_21_LOW 0x2164
286#define SUNI1x10GEXP_REG_MSTAT_COUNTER_21_MID 0x2165
287#define SUNI1x10GEXP_REG_MSTAT_COUNTER_21_HIGH 0x2166
288#define SUNI1x10GEXP_REG_MSTAT_COUNTER_21_RESVD 0x2167
289#define SUNI1x10GEXP_REG_MSTAT_COUNTER_22_LOW 0x2168
290#define SUNI1x10GEXP_REG_MSTAT_COUNTER_22_MID 0x2169
291#define SUNI1x10GEXP_REG_MSTAT_COUNTER_22_HIGH 0x216A
292#define SUNI1x10GEXP_REG_MSTAT_COUNTER_22_RESVD 0x216B
293#define SUNI1x10GEXP_REG_MSTAT_COUNTER_23_LOW 0x216C
294#define SUNI1x10GEXP_REG_MSTAT_COUNTER_23_MID 0x216D
295#define SUNI1x10GEXP_REG_MSTAT_COUNTER_23_HIGH 0x216E
296#define SUNI1x10GEXP_REG_MSTAT_COUNTER_23_RESVD 0x216F
297#define SUNI1x10GEXP_REG_MSTAT_COUNTER_24_LOW 0x2170
298#define SUNI1x10GEXP_REG_MSTAT_COUNTER_24_MID 0x2171
299#define SUNI1x10GEXP_REG_MSTAT_COUNTER_24_HIGH 0x2172
300#define SUNI1x10GEXP_REG_MSTAT_COUNTER_24_RESVD 0x2173
301#define SUNI1x10GEXP_REG_MSTAT_COUNTER_25_LOW 0x2174
302#define SUNI1x10GEXP_REG_MSTAT_COUNTER_25_MID 0x2175
303#define SUNI1x10GEXP_REG_MSTAT_COUNTER_25_HIGH 0x2176
304#define SUNI1x10GEXP_REG_MSTAT_COUNTER_25_RESVD 0x2177
305#define SUNI1x10GEXP_REG_MSTAT_COUNTER_26_LOW 0x2178
306#define SUNI1x10GEXP_REG_MSTAT_COUNTER_26_MID 0x2179
307#define SUNI1x10GEXP_REG_MSTAT_COUNTER_26_HIGH 0x217a
308#define SUNI1x10GEXP_REG_MSTAT_COUNTER_26_RESVD 0x217b
309#define SUNI1x10GEXP_REG_MSTAT_COUNTER_27_LOW 0x217c
310#define SUNI1x10GEXP_REG_MSTAT_COUNTER_27_MID 0x217d
311#define SUNI1x10GEXP_REG_MSTAT_COUNTER_27_HIGH 0x217e
312#define SUNI1x10GEXP_REG_MSTAT_COUNTER_27_RESVD 0x217f
313#define SUNI1x10GEXP_REG_MSTAT_COUNTER_28_LOW 0x2180
314#define SUNI1x10GEXP_REG_MSTAT_COUNTER_28_MID 0x2181
315#define SUNI1x10GEXP_REG_MSTAT_COUNTER_28_HIGH 0x2182
316#define SUNI1x10GEXP_REG_MSTAT_COUNTER_28_RESVD 0x2183
317#define SUNI1x10GEXP_REG_MSTAT_COUNTER_29_LOW 0x2184
318#define SUNI1x10GEXP_REG_MSTAT_COUNTER_29_MID 0x2185
319#define SUNI1x10GEXP_REG_MSTAT_COUNTER_29_HIGH 0x2186
320#define SUNI1x10GEXP_REG_MSTAT_COUNTER_29_RESVD 0x2187
321#define SUNI1x10GEXP_REG_MSTAT_COUNTER_30_LOW 0x2188
322#define SUNI1x10GEXP_REG_MSTAT_COUNTER_30_MID 0x2189
323#define SUNI1x10GEXP_REG_MSTAT_COUNTER_30_HIGH 0x218A
324#define SUNI1x10GEXP_REG_MSTAT_COUNTER_30_RESVD 0x218B
325#define SUNI1x10GEXP_REG_MSTAT_COUNTER_31_LOW 0x218C
326#define SUNI1x10GEXP_REG_MSTAT_COUNTER_31_MID 0x218D
327#define SUNI1x10GEXP_REG_MSTAT_COUNTER_31_HIGH 0x218E
328#define SUNI1x10GEXP_REG_MSTAT_COUNTER_31_RESVD 0x218F
329#define SUNI1x10GEXP_REG_MSTAT_COUNTER_32_LOW 0x2190
330#define SUNI1x10GEXP_REG_MSTAT_COUNTER_32_MID 0x2191
331#define SUNI1x10GEXP_REG_MSTAT_COUNTER_32_HIGH 0x2192
332#define SUNI1x10GEXP_REG_MSTAT_COUNTER_32_RESVD 0x2193
92#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW 0x2194 333#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_LOW 0x2194
334#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_MID 0x2195
335#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_HIGH 0x2196
336#define SUNI1x10GEXP_REG_MSTAT_COUNTER_33_RESVD 0x2197
337#define SUNI1x10GEXP_REG_MSTAT_COUNTER_34_LOW 0x2198
338#define SUNI1x10GEXP_REG_MSTAT_COUNTER_34_MID 0x2199
339#define SUNI1x10GEXP_REG_MSTAT_COUNTER_34_HIGH 0x219A
340#define SUNI1x10GEXP_REG_MSTAT_COUNTER_34_RESVD 0x219B
93#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW 0x219C 341#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_LOW 0x219C
342#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_MID 0x219D
343#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_HIGH 0x219E
344#define SUNI1x10GEXP_REG_MSTAT_COUNTER_35_RESVD 0x219F
94#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_LOW 0x21A0 345#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_LOW 0x21A0
346#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_MID 0x21A1
347#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_HIGH 0x21A2
348#define SUNI1x10GEXP_REG_MSTAT_COUNTER_36_RESVD 0x21A3
349#define SUNI1x10GEXP_REG_MSTAT_COUNTER_37_LOW 0x21A4
350#define SUNI1x10GEXP_REG_MSTAT_COUNTER_37_MID 0x21A5
351#define SUNI1x10GEXP_REG_MSTAT_COUNTER_37_HIGH 0x21A6
352#define SUNI1x10GEXP_REG_MSTAT_COUNTER_37_RESVD 0x21A7
95#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW 0x21A8 353#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_LOW 0x21A8
354#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_MID 0x21A9
355#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_HIGH 0x21AA
356#define SUNI1x10GEXP_REG_MSTAT_COUNTER_38_RESVD 0x21AB
357#define SUNI1x10GEXP_REG_MSTAT_COUNTER_39_LOW 0x21AC
358#define SUNI1x10GEXP_REG_MSTAT_COUNTER_39_MID 0x21AD
359#define SUNI1x10GEXP_REG_MSTAT_COUNTER_39_HIGH 0x21AE
360#define SUNI1x10GEXP_REG_MSTAT_COUNTER_39_RESVD 0x21AF
96#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW 0x21B0 361#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_LOW 0x21B0
362#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_MID 0x21B1
363#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_HIGH 0x21B2
364#define SUNI1x10GEXP_REG_MSTAT_COUNTER_40_RESVD 0x21B3
365#define SUNI1x10GEXP_REG_MSTAT_COUNTER_41_LOW 0x21B4
366#define SUNI1x10GEXP_REG_MSTAT_COUNTER_41_MID 0x21B5
367#define SUNI1x10GEXP_REG_MSTAT_COUNTER_41_HIGH 0x21B6
368#define SUNI1x10GEXP_REG_MSTAT_COUNTER_41_RESVD 0x21B7
97#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW 0x21B8 369#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_LOW 0x21B8
370#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_MID 0x21B9
371#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_HIGH 0x21BA
372#define SUNI1x10GEXP_REG_MSTAT_COUNTER_42_RESVD 0x21BB
98#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW 0x21BC 373#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_LOW 0x21BC
374#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_MID 0x21BD
375#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_HIGH 0x21BE
376#define SUNI1x10GEXP_REG_MSTAT_COUNTER_43_RESVD 0x21BF
377#define SUNI1x10GEXP_REG_MSTAT_COUNTER_44_LOW 0x21C0
378#define SUNI1x10GEXP_REG_MSTAT_COUNTER_44_MID 0x21C1
379#define SUNI1x10GEXP_REG_MSTAT_COUNTER_44_HIGH 0x21C2
380#define SUNI1x10GEXP_REG_MSTAT_COUNTER_44_RESVD 0x21C3
381#define SUNI1x10GEXP_REG_MSTAT_COUNTER_45_LOW 0x21C4
382#define SUNI1x10GEXP_REG_MSTAT_COUNTER_45_MID 0x21C5
383#define SUNI1x10GEXP_REG_MSTAT_COUNTER_45_HIGH 0x21C6
384#define SUNI1x10GEXP_REG_MSTAT_COUNTER_45_RESVD 0x21C7
385#define SUNI1x10GEXP_REG_MSTAT_COUNTER_46_LOW 0x21C8
386#define SUNI1x10GEXP_REG_MSTAT_COUNTER_46_MID 0x21C9
387#define SUNI1x10GEXP_REG_MSTAT_COUNTER_46_HIGH 0x21CA
388#define SUNI1x10GEXP_REG_MSTAT_COUNTER_46_RESVD 0x21CB
389#define SUNI1x10GEXP_REG_MSTAT_COUNTER_47_LOW 0x21CC
390#define SUNI1x10GEXP_REG_MSTAT_COUNTER_47_MID 0x21CD
391#define SUNI1x10GEXP_REG_MSTAT_COUNTER_47_HIGH 0x21CE
392#define SUNI1x10GEXP_REG_MSTAT_COUNTER_47_RESVD 0x21CF
393#define SUNI1x10GEXP_REG_MSTAT_COUNTER_48_LOW 0x21D0
394#define SUNI1x10GEXP_REG_MSTAT_COUNTER_48_MID 0x21D1
395#define SUNI1x10GEXP_REG_MSTAT_COUNTER_48_HIGH 0x21D2
396#define SUNI1x10GEXP_REG_MSTAT_COUNTER_48_RESVD 0x21D3
397#define SUNI1x10GEXP_REG_MSTAT_COUNTER_49_LOW 0x21D4
398#define SUNI1x10GEXP_REG_MSTAT_COUNTER_49_MID 0x21D5
399#define SUNI1x10GEXP_REG_MSTAT_COUNTER_49_HIGH 0x21D6
400#define SUNI1x10GEXP_REG_MSTAT_COUNTER_49_RESVD 0x21D7
401#define SUNI1x10GEXP_REG_MSTAT_COUNTER_50_LOW 0x21D8
402#define SUNI1x10GEXP_REG_MSTAT_COUNTER_50_MID 0x21D9
403#define SUNI1x10GEXP_REG_MSTAT_COUNTER_50_HIGH 0x21DA
404#define SUNI1x10GEXP_REG_MSTAT_COUNTER_50_RESVD 0x21DB
405#define SUNI1x10GEXP_REG_MSTAT_COUNTER_51_LOW 0x21DC
406#define SUNI1x10GEXP_REG_MSTAT_COUNTER_51_MID 0x21DD
407#define SUNI1x10GEXP_REG_MSTAT_COUNTER_51_HIGH 0x21DE
408#define SUNI1x10GEXP_REG_MSTAT_COUNTER_51_RESVD 0x21DF
409#define SUNI1x10GEXP_REG_MSTAT_COUNTER_52_LOW 0x21E0
410#define SUNI1x10GEXP_REG_MSTAT_COUNTER_52_MID 0x21E1
411#define SUNI1x10GEXP_REG_MSTAT_COUNTER_52_HIGH 0x21E2
412#define SUNI1x10GEXP_REG_MSTAT_COUNTER_52_RESVD 0x21E3
413#define SUNI1x10GEXP_REG_MSTAT_COUNTER_53_LOW 0x21E4
414#define SUNI1x10GEXP_REG_MSTAT_COUNTER_53_MID 0x21E5
415#define SUNI1x10GEXP_REG_MSTAT_COUNTER_53_HIGH 0x21E6
416#define SUNI1x10GEXP_CNTR_MAC_ETHERNET_NUM 51
417
418#define SUNI1x10GEXP_REG_IFLX_GLOBAL_CONFIG 0x2200
419#define SUNI1x10GEXP_REG_IFLX_CHANNEL_PROVISION 0x2201
99#define SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_ENABLE 0x2209 420#define SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_ENABLE 0x2209
100#define SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_INTERRUPT 0x220A 421#define SUNI1x10GEXP_REG_IFLX_FIFO_OVERFLOW_INTERRUPT 0x220A
422#define SUNI1x10GEXP_REG_IFLX_INDIR_CHANNEL_ADDRESS 0x220D
423#define SUNI1x10GEXP_REG_IFLX_INDIR_LOGICAL_FIFO_LOW_LIMIT_PROVISION 0x220E
424#define SUNI1x10GEXP_REG_IFLX_INDIR_LOGICAL_FIFO_HIGH_LIMIT 0x220F
425#define SUNI1x10GEXP_REG_IFLX_INDIR_FULL_ALMOST_FULL_STATUS_LIMIT 0x2210
426#define SUNI1x10GEXP_REG_IFLX_INDIR_EMPTY_ALMOST_EMPTY_STATUS_LIMIT 0x2211
427
428#define SUNI1x10GEXP_REG_PL4MOS_CONFIG 0x2240
429#define SUNI1x10GEXP_REG_PL4MOS_MASK 0x2241
430#define SUNI1x10GEXP_REG_PL4MOS_FAIRNESS_MASKING 0x2242
431#define SUNI1x10GEXP_REG_PL4MOS_MAXBURST1 0x2243
432#define SUNI1x10GEXP_REG_PL4MOS_MAXBURST2 0x2244
433#define SUNI1x10GEXP_REG_PL4MOS_TRANSFER_SIZE 0x2245
434
435#define SUNI1x10GEXP_REG_PL4ODP_CONFIG 0x2280
101#define SUNI1x10GEXP_REG_PL4ODP_INTERRUPT_MASK 0x2282 436#define SUNI1x10GEXP_REG_PL4ODP_INTERRUPT_MASK 0x2282
102#define SUNI1x10GEXP_REG_PL4ODP_INTERRUPT 0x2283 437#define SUNI1x10GEXP_REG_PL4ODP_INTERRUPT 0x2283
438#define SUNI1x10GEXP_REG_PL4ODP_CONFIG_MAX_T 0x2284
439
103#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_STATUS 0x2300 440#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_STATUS 0x2300
104#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_CHANGE 0x2301 441#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_CHANGE 0x2301
105#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_MASK 0x2302 442#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_MASK 0x2302
443#define SUNI1x10GEXP_REG_PL4IO_LOCK_DETECT_LIMITS 0x2303
444#define SUNI1x10GEXP_REG_PL4IO_CALENDAR_REPETITIONS 0x2304
445#define SUNI1x10GEXP_REG_PL4IO_CONFIG 0x2305
446
106#define SUNI1x10GEXP_REG_TXXG_CONFIG_1 0x3040 447#define SUNI1x10GEXP_REG_TXXG_CONFIG_1 0x3040
448#define SUNI1x10GEXP_REG_TXXG_CONFIG_2 0x3041
107#define SUNI1x10GEXP_REG_TXXG_CONFIG_3 0x3042 449#define SUNI1x10GEXP_REG_TXXG_CONFIG_3 0x3042
108#define SUNI1x10GEXP_REG_TXXG_INTERRUPT 0x3043 450#define SUNI1x10GEXP_REG_TXXG_INTERRUPT 0x3043
451#define SUNI1x10GEXP_REG_TXXG_STATUS 0x3044
109#define SUNI1x10GEXP_REG_TXXG_MAX_FRAME_SIZE 0x3045 452#define SUNI1x10GEXP_REG_TXXG_MAX_FRAME_SIZE 0x3045
453#define SUNI1x10GEXP_REG_TXXG_MIN_FRAME_SIZE 0x3046
110#define SUNI1x10GEXP_REG_TXXG_SA_15_0 0x3047 454#define SUNI1x10GEXP_REG_TXXG_SA_15_0 0x3047
111#define SUNI1x10GEXP_REG_TXXG_SA_31_16 0x3048 455#define SUNI1x10GEXP_REG_TXXG_SA_31_16 0x3048
112#define SUNI1x10GEXP_REG_TXXG_SA_47_32 0x3049 456#define SUNI1x10GEXP_REG_TXXG_SA_47_32 0x3049
457#define SUNI1x10GEXP_REG_TXXG_PAUSE_TIMER 0x304D
458#define SUNI1x10GEXP_REG_TXXG_PAUSE_TIMER_INTERVAL 0x304E
459#define SUNI1x10GEXP_REG_TXXG_FILTER_ERROR_COUNTER 0x3051
460#define SUNI1x10GEXP_REG_TXXG_PAUSE_QUANTUM_CONFIG 0x3052
461
462#define SUNI1x10GEXP_REG_XTEF_CTRL 0x3080
113#define SUNI1x10GEXP_REG_XTEF_INTERRUPT_STATUS 0x3084 463#define SUNI1x10GEXP_REG_XTEF_INTERRUPT_STATUS 0x3084
114#define SUNI1x10GEXP_REG_XTEF_INTERRUPT_ENABLE 0x3085 464#define SUNI1x10GEXP_REG_XTEF_INTERRUPT_ENABLE 0x3085
465#define SUNI1x10GEXP_REG_XTEF_VISIBILITY 0x3086
466
467#define SUNI1x10GEXP_REG_TXOAM_OAM_CONFIG 0x30C0
468#define SUNI1x10GEXP_REG_TXOAM_MINI_RATE_CONFIG 0x30C1
469#define SUNI1x10GEXP_REG_TXOAM_MINI_GAP_FIFO_CONFIG 0x30C2
470#define SUNI1x10GEXP_REG_TXOAM_P1P2_STATIC_VALUES 0x30C3
471#define SUNI1x10GEXP_REG_TXOAM_P3P4_STATIC_VALUES 0x30C4
472#define SUNI1x10GEXP_REG_TXOAM_P5P6_STATIC_VALUES 0x30C5
115#define SUNI1x10GEXP_REG_TXOAM_INTERRUPT_ENABLE 0x30C6 473#define SUNI1x10GEXP_REG_TXOAM_INTERRUPT_ENABLE 0x30C6
116#define SUNI1x10GEXP_REG_TXOAM_INTERRUPT_STATUS 0x30C7 474#define SUNI1x10GEXP_REG_TXOAM_INTERRUPT_STATUS 0x30C7
475#define SUNI1x10GEXP_REG_TXOAM_INSERT_COUNT_LSB 0x30C8
476#define SUNI1x10GEXP_REG_TXOAM_INSERT_COUNT_MSB 0x30C9
477#define SUNI1x10GEXP_REG_TXOAM_OAM_MINI_COUNT_LSB 0x30CA
478#define SUNI1x10GEXP_REG_TXOAM_OAM_MINI_COUNT_MSB 0x30CB
479#define SUNI1x10GEXP_REG_TXOAM_P1P2_MINI_MASK 0x30CC
480#define SUNI1x10GEXP_REG_TXOAM_P3P4_MINI_MASK 0x30CD
481#define SUNI1x10GEXP_REG_TXOAM_P5P6_MINI_MASK 0x30CE
482#define SUNI1x10GEXP_REG_TXOAM_COSET 0x30CF
483#define SUNI1x10GEXP_REG_TXOAM_EMPTY_FIFO_INS_OP_CNT_LSB 0x30D0
484#define SUNI1x10GEXP_REG_TXOAM_EMPTY_FIFO_INS_OP_CNT_MSB 0x30D1
485#define SUNI1x10GEXP_REG_TXOAM_STATIC_VALUE_MINI_COUNT_LSB 0x30D2
486#define SUNI1x10GEXP_REG_TXOAM_STATIC_VALUE_MINI_COUNT_MSB 0x30D3
487
488
489#define SUNI1x10GEXP_REG_EFLX_GLOBAL_CONFIG 0x3200
490#define SUNI1x10GEXP_REG_EFLX_ERCU_GLOBAL_STATUS 0x3201
491#define SUNI1x10GEXP_REG_EFLX_INDIR_CHANNEL_ADDRESS 0x3202
492#define SUNI1x10GEXP_REG_EFLX_INDIR_FIFO_LOW_LIMIT 0x3203
493#define SUNI1x10GEXP_REG_EFLX_INDIR_FIFO_HIGH_LIMIT 0x3204
494#define SUNI1x10GEXP_REG_EFLX_INDIR_FULL_ALMOST_FULL_STATUS_AND_LIMIT 0x3205
495#define SUNI1x10GEXP_REG_EFLX_INDIR_EMPTY_ALMOST_EMPTY_STATUS_AND_LIMIT 0x3206
496#define SUNI1x10GEXP_REG_EFLX_INDIR_FIFO_CUT_THROUGH_THRESHOLD 0x3207
117#define SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_ENABLE 0x320C 497#define SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_ENABLE 0x320C
118#define SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_INDICATION 0x320D 498#define SUNI1x10GEXP_REG_EFLX_FIFO_OVERFLOW_ERROR_INDICATION 0x320D
499#define SUNI1x10GEXP_REG_EFLX_CHANNEL_PROVISION 0x3210
500
501#define SUNI1x10GEXP_REG_PL4IDU_CONFIG 0x3280
119#define SUNI1x10GEXP_REG_PL4IDU_INTERRUPT_MASK 0x3282 502#define SUNI1x10GEXP_REG_PL4IDU_INTERRUPT_MASK 0x3282
120#define SUNI1x10GEXP_REG_PL4IDU_INTERRUPT 0x3283 503#define SUNI1x10GEXP_REG_PL4IDU_INTERRUPT 0x3283
121 504
505
506/*----------------------------------------*/
507#define SUNI1x10GEXP_REG_MAX_OFFSET 0x3480
508
122/******************************************************************************/ 509/******************************************************************************/
123/* -- End register offset definitions -- */ 510/* -- End register offset definitions -- */
124/******************************************************************************/ 511/******************************************************************************/
@@ -127,6 +514,81 @@
127/** SUNI-1x10GE-XP REGISTER BIT MASKS **/ 514/** SUNI-1x10GE-XP REGISTER BIT MASKS **/
128/******************************************************************************/ 515/******************************************************************************/
129 516
517#define SUNI1x10GEXP_BITMSK_BITS_1 0x00001
518#define SUNI1x10GEXP_BITMSK_BITS_2 0x00003
519#define SUNI1x10GEXP_BITMSK_BITS_3 0x00007
520#define SUNI1x10GEXP_BITMSK_BITS_4 0x0000f
521#define SUNI1x10GEXP_BITMSK_BITS_5 0x0001f
522#define SUNI1x10GEXP_BITMSK_BITS_6 0x0003f
523#define SUNI1x10GEXP_BITMSK_BITS_7 0x0007f
524#define SUNI1x10GEXP_BITMSK_BITS_8 0x000ff
525#define SUNI1x10GEXP_BITMSK_BITS_9 0x001ff
526#define SUNI1x10GEXP_BITMSK_BITS_10 0x003ff
527#define SUNI1x10GEXP_BITMSK_BITS_11 0x007ff
528#define SUNI1x10GEXP_BITMSK_BITS_12 0x00fff
529#define SUNI1x10GEXP_BITMSK_BITS_13 0x01fff
530#define SUNI1x10GEXP_BITMSK_BITS_14 0x03fff
531#define SUNI1x10GEXP_BITMSK_BITS_15 0x07fff
532#define SUNI1x10GEXP_BITMSK_BITS_16 0x0ffff
533
534#define mSUNI1x10GEXP_CLR_MSBITS_1(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_15)
535#define mSUNI1x10GEXP_CLR_MSBITS_2(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_14)
536#define mSUNI1x10GEXP_CLR_MSBITS_3(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_13)
537#define mSUNI1x10GEXP_CLR_MSBITS_4(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_12)
538#define mSUNI1x10GEXP_CLR_MSBITS_5(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_11)
539#define mSUNI1x10GEXP_CLR_MSBITS_6(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_10)
540#define mSUNI1x10GEXP_CLR_MSBITS_7(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_9)
541#define mSUNI1x10GEXP_CLR_MSBITS_8(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_8)
542#define mSUNI1x10GEXP_CLR_MSBITS_9(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_7)
543#define mSUNI1x10GEXP_CLR_MSBITS_10(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_6)
544#define mSUNI1x10GEXP_CLR_MSBITS_11(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_5)
545#define mSUNI1x10GEXP_CLR_MSBITS_12(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_4)
546#define mSUNI1x10GEXP_CLR_MSBITS_13(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_3)
547#define mSUNI1x10GEXP_CLR_MSBITS_14(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_2)
548#define mSUNI1x10GEXP_CLR_MSBITS_15(v) ((v) & SUNI1x10GEXP_BITMSK_BITS_1)
549
550#define mSUNI1x10GEXP_GET_BIT(val, bitMsk) (((val)&(bitMsk)) ? 1:0)
551
552
553
554/*----------------------------------------------------------------------------
555 * Register 0x0001: S/UNI-1x10GE-XP Product Revision
556 * Bit 3-0 REVISION
557 *----------------------------------------------------------------------------*/
558#define SUNI1x10GEXP_BITMSK_REVISION 0x000F
559
560/*----------------------------------------------------------------------------
561 * Register 0x0002: S/UNI-1x10GE-XP Configuration and Reset Control
562 * Bit 2 XAUI_ARESETB
563 * Bit 1 PL4_ARESETB
564 * Bit 0 DRESETB
565 *----------------------------------------------------------------------------*/
566#define SUNI1x10GEXP_BITMSK_XAUI_ARESET 0x0004
567#define SUNI1x10GEXP_BITMSK_PL4_ARESET 0x0002
568#define SUNI1x10GEXP_BITMSK_DRESETB 0x0001
569
570/*----------------------------------------------------------------------------
571 * Register 0x0003: S/UNI-1x10GE-XP Loop Back and Miscellaneous Control
572 * Bit 11 PL4IO_OUTCLKSEL
573 * Bit 9 SYSPCSLB
574 * Bit 8 LINEPCSLB
575 * Bit 7 MSTAT_BYPASS
576 * Bit 6 RXXG_BYPASS
577 * Bit 5 TXXG_BYPASS
578 * Bit 4 SOP_PAD_EN
579 * Bit 1 LOS_INV
580 * Bit 0 OVERRIDE_LOS
581 *----------------------------------------------------------------------------*/
582#define SUNI1x10GEXP_BITMSK_PL4IO_OUTCLKSEL 0x0800
583#define SUNI1x10GEXP_BITMSK_SYSPCSLB 0x0200
584#define SUNI1x10GEXP_BITMSK_LINEPCSLB 0x0100
585#define SUNI1x10GEXP_BITMSK_MSTAT_BYPASS 0x0080
586#define SUNI1x10GEXP_BITMSK_RXXG_BYPASS 0x0040
587#define SUNI1x10GEXP_BITMSK_TXXG_BYPASS 0x0020
588#define SUNI1x10GEXP_BITMSK_SOP_PAD_EN 0x0010
589#define SUNI1x10GEXP_BITMSK_LOS_INV 0x0002
590#define SUNI1x10GEXP_BITMSK_OVERRIDE_LOS 0x0001
591
130/*---------------------------------------------------------------------------- 592/*----------------------------------------------------------------------------
131 * Register 0x0004: S/UNI-1x10GE-XP Device Status 593 * Register 0x0004: S/UNI-1x10GE-XP Device Status
132 * Bit 9 TOP_SXRA_EXPIRED 594 * Bit 9 TOP_SXRA_EXPIRED
@@ -141,7 +603,10 @@
141 * Bit 0 TOP_PL4_OUT_ROOL 603 * Bit 0 TOP_PL4_OUT_ROOL
142 *----------------------------------------------------------------------------*/ 604 *----------------------------------------------------------------------------*/
143#define SUNI1x10GEXP_BITMSK_TOP_SXRA_EXPIRED 0x0200 605#define SUNI1x10GEXP_BITMSK_TOP_SXRA_EXPIRED 0x0200
606#define SUNI1x10GEXP_BITMSK_TOP_MDIO_BUSY 0x0100
607#define SUNI1x10GEXP_BITMSK_TOP_DTRB 0x0080
144#define SUNI1x10GEXP_BITMSK_TOP_EXPIRED 0x0040 608#define SUNI1x10GEXP_BITMSK_TOP_EXPIRED 0x0040
609#define SUNI1x10GEXP_BITMSK_TOP_PAUSED 0x0020
145#define SUNI1x10GEXP_BITMSK_TOP_PL4_ID_DOOL 0x0010 610#define SUNI1x10GEXP_BITMSK_TOP_PL4_ID_DOOL 0x0010
146#define SUNI1x10GEXP_BITMSK_TOP_PL4_IS_DOOL 0x0008 611#define SUNI1x10GEXP_BITMSK_TOP_PL4_IS_DOOL 0x0008
147#define SUNI1x10GEXP_BITMSK_TOP_PL4_ID_ROOL 0x0004 612#define SUNI1x10GEXP_BITMSK_TOP_PL4_ID_ROOL 0x0004
@@ -149,12 +614,219 @@
149#define SUNI1x10GEXP_BITMSK_TOP_PL4_OUT_ROOL 0x0001 614#define SUNI1x10GEXP_BITMSK_TOP_PL4_OUT_ROOL 0x0001
150 615
151/*---------------------------------------------------------------------------- 616/*----------------------------------------------------------------------------
617 * Register 0x0005: Global Performance Update and Clock Monitors
618 * Bit 15 TIP
619 * Bit 8 XAUI_REF_CLKA
620 * Bit 7 RXLANE3CLKA
621 * Bit 6 RXLANE2CLKA
622 * Bit 5 RXLANE1CLKA
623 * Bit 4 RXLANE0CLKA
624 * Bit 3 CSUCLKA
625 * Bit 2 TDCLKA
626 * Bit 1 RSCLKA
627 * Bit 0 RDCLKA
628 *----------------------------------------------------------------------------*/
629#define SUNI1x10GEXP_BITMSK_TIP 0x8000
630#define SUNI1x10GEXP_BITMSK_XAUI_REF_CLKA 0x0100
631#define SUNI1x10GEXP_BITMSK_RXLANE3CLKA 0x0080
632#define SUNI1x10GEXP_BITMSK_RXLANE2CLKA 0x0040
633#define SUNI1x10GEXP_BITMSK_RXLANE1CLKA 0x0020
634#define SUNI1x10GEXP_BITMSK_RXLANE0CLKA 0x0010
635#define SUNI1x10GEXP_BITMSK_CSUCLKA 0x0008
636#define SUNI1x10GEXP_BITMSK_TDCLKA 0x0004
637#define SUNI1x10GEXP_BITMSK_RSCLKA 0x0002
638#define SUNI1x10GEXP_BITMSK_RDCLKA 0x0001
639
640/*----------------------------------------------------------------------------
641 * Register 0x0006: MDIO Command
642 * Bit 4 MDIO_RDINC
643 * Bit 3 MDIO_RSTAT
644 * Bit 2 MDIO_LCTLD
645 * Bit 1 MDIO_LCTLA
646 * Bit 0 MDIO_SPRE
647 *----------------------------------------------------------------------------*/
648#define SUNI1x10GEXP_BITMSK_MDIO_RDINC 0x0010
649#define SUNI1x10GEXP_BITMSK_MDIO_RSTAT 0x0008
650#define SUNI1x10GEXP_BITMSK_MDIO_LCTLD 0x0004
651#define SUNI1x10GEXP_BITMSK_MDIO_LCTLA 0x0002
652#define SUNI1x10GEXP_BITMSK_MDIO_SPRE 0x0001
653
654/*----------------------------------------------------------------------------
655 * Register 0x0007: MDIO Interrupt Enable
656 * Bit 0 MDIO_BUSY_EN
657 *----------------------------------------------------------------------------*/
658#define SUNI1x10GEXP_BITMSK_MDIO_BUSY_EN 0x0001
659
660/*----------------------------------------------------------------------------
661 * Register 0x0008: MDIO Interrupt Status
662 * Bit 0 MDIO_BUSYI
663 *----------------------------------------------------------------------------*/
664#define SUNI1x10GEXP_BITMSK_MDIO_BUSYI 0x0001
665
666/*----------------------------------------------------------------------------
667 * Register 0x0009: MMD PHY Address
668 * Bit 12-8 MDIO_DEVADR
669 * Bit 4-0 MDIO_PRTADR
670 *----------------------------------------------------------------------------*/
671#define SUNI1x10GEXP_BITMSK_MDIO_DEVADR 0x1F00
672#define SUNI1x10GEXP_BITOFF_MDIO_DEVADR 8
673#define SUNI1x10GEXP_BITMSK_MDIO_PRTADR 0x001F
674#define SUNI1x10GEXP_BITOFF_MDIO_PRTADR 0
675
676/*----------------------------------------------------------------------------
677 * Register 0x000C: OAM Interface Control
678 * Bit 6 MDO_OD_ENB
679 * Bit 5 MDI_INV
680 * Bit 4 MDI_SEL
681 * Bit 3 RXOAMEN
682 * Bit 2 RXOAMCLKEN
683 * Bit 1 TXOAMEN
684 * Bit 0 TXOAMCLKEN
685 *----------------------------------------------------------------------------*/
686#define SUNI1x10GEXP_BITMSK_MDO_OD_ENB 0x0040
687#define SUNI1x10GEXP_BITMSK_MDI_INV 0x0020
688#define SUNI1x10GEXP_BITMSK_MDI_SEL 0x0010
689#define SUNI1x10GEXP_BITMSK_RXOAMEN 0x0008
690#define SUNI1x10GEXP_BITMSK_RXOAMCLKEN 0x0004
691#define SUNI1x10GEXP_BITMSK_TXOAMEN 0x0002
692#define SUNI1x10GEXP_BITMSK_TXOAMCLKEN 0x0001
693
694/*----------------------------------------------------------------------------
695 * Register 0x000D: S/UNI-1x10GE-XP Master Interrupt Status
696 * Bit 15 TOP_PL4IO_INT
697 * Bit 14 TOP_IRAM_INT
698 * Bit 13 TOP_ERAM_INT
699 * Bit 12 TOP_XAUI_INT
700 * Bit 11 TOP_MSTAT_INT
701 * Bit 10 TOP_RXXG_INT
702 * Bit 9 TOP_TXXG_INT
703 * Bit 8 TOP_XRF_INT
704 * Bit 7 TOP_XTEF_INT
705 * Bit 6 TOP_MDIO_BUSY_INT
706 * Bit 5 TOP_RXOAM_INT
707 * Bit 4 TOP_TXOAM_INT
708 * Bit 3 TOP_IFLX_INT
709 * Bit 2 TOP_EFLX_INT
710 * Bit 1 TOP_PL4ODP_INT
711 * Bit 0 TOP_PL4IDU_INT
712 *----------------------------------------------------------------------------*/
713#define SUNI1x10GEXP_BITMSK_TOP_PL4IO_INT 0x8000
714#define SUNI1x10GEXP_BITMSK_TOP_IRAM_INT 0x4000
715#define SUNI1x10GEXP_BITMSK_TOP_ERAM_INT 0x2000
716#define SUNI1x10GEXP_BITMSK_TOP_XAUI_INT 0x1000
717#define SUNI1x10GEXP_BITMSK_TOP_MSTAT_INT 0x0800
718#define SUNI1x10GEXP_BITMSK_TOP_RXXG_INT 0x0400
719#define SUNI1x10GEXP_BITMSK_TOP_TXXG_INT 0x0200
720#define SUNI1x10GEXP_BITMSK_TOP_XRF_INT 0x0100
721#define SUNI1x10GEXP_BITMSK_TOP_XTEF_INT 0x0080
722#define SUNI1x10GEXP_BITMSK_TOP_MDIO_BUSY_INT 0x0040
723#define SUNI1x10GEXP_BITMSK_TOP_RXOAM_INT 0x0020
724#define SUNI1x10GEXP_BITMSK_TOP_TXOAM_INT 0x0010
725#define SUNI1x10GEXP_BITMSK_TOP_IFLX_INT 0x0008
726#define SUNI1x10GEXP_BITMSK_TOP_EFLX_INT 0x0004
727#define SUNI1x10GEXP_BITMSK_TOP_PL4ODP_INT 0x0002
728#define SUNI1x10GEXP_BITMSK_TOP_PL4IDU_INT 0x0001
729
730/*----------------------------------------------------------------------------
152 * Register 0x000E:PM3393 Global interrupt enable 731 * Register 0x000E:PM3393 Global interrupt enable
153 * Bit 15 TOP_INTE 732 * Bit 15 TOP_INTE
154 *----------------------------------------------------------------------------*/ 733 *----------------------------------------------------------------------------*/
155#define SUNI1x10GEXP_BITMSK_TOP_INTE 0x8000 734#define SUNI1x10GEXP_BITMSK_TOP_INTE 0x8000
156 735
157/*---------------------------------------------------------------------------- 736/*----------------------------------------------------------------------------
737 * Register 0x0010: XTEF Miscellaneous Control
738 * Bit 7 RF_VAL
739 * Bit 6 RF_OVERRIDE
740 * Bit 5 LF_VAL
741 * Bit 4 LF_OVERRIDE
742 *----------------------------------------------------------------------------*/
743#define SUNI1x10GEXP_BITMSK_RF_VAL 0x0080
744#define SUNI1x10GEXP_BITMSK_RF_OVERRIDE 0x0040
745#define SUNI1x10GEXP_BITMSK_LF_VAL 0x0020
746#define SUNI1x10GEXP_BITMSK_LF_OVERRIDE 0x0010
747#define SUNI1x10GEXP_BITMSK_LFRF_OVERRIDE_VAL 0x00F0
748
749/*----------------------------------------------------------------------------
750 * Register 0x0011: XRF Miscellaneous Control
751 * Bit 6-4 EN_IDLE_REP
752 *----------------------------------------------------------------------------*/
753#define SUNI1x10GEXP_BITMSK_EN_IDLE_REP 0x0070
754
755/*----------------------------------------------------------------------------
756 * Register 0x0100: SERDES 3125 Configuration Register 1
757 * Bit 10 RXEQB_3
758 * Bit 8 RXEQB_2
759 * Bit 6 RXEQB_1
760 * Bit 4 RXEQB_0
761 *----------------------------------------------------------------------------*/
762#define SUNI1x10GEXP_BITMSK_RXEQB 0x0FF0
763#define SUNI1x10GEXP_BITOFF_RXEQB_3 10
764#define SUNI1x10GEXP_BITOFF_RXEQB_2 8
765#define SUNI1x10GEXP_BITOFF_RXEQB_1 6
766#define SUNI1x10GEXP_BITOFF_RXEQB_0 4
767
768/*----------------------------------------------------------------------------
769 * Register 0x0101: SERDES 3125 Configuration Register 2
770 * Bit 12 YSEL
771 * Bit 7 PRE_EMPH_3
772 * Bit 6 PRE_EMPH_2
773 * Bit 5 PRE_EMPH_1
774 * Bit 4 PRE_EMPH_0
775 *----------------------------------------------------------------------------*/
776#define SUNI1x10GEXP_BITMSK_YSEL 0x1000
777#define SUNI1x10GEXP_BITMSK_PRE_EMPH 0x00F0
778#define SUNI1x10GEXP_BITMSK_PRE_EMPH_3 0x0080
779#define SUNI1x10GEXP_BITMSK_PRE_EMPH_2 0x0040
780#define SUNI1x10GEXP_BITMSK_PRE_EMPH_1 0x0020
781#define SUNI1x10GEXP_BITMSK_PRE_EMPH_0 0x0010
782
783/*----------------------------------------------------------------------------
784 * Register 0x0102: SERDES 3125 Interrupt Enable Register
785 * Bit 3 LASIE
786 * Bit 2 SPLL_RAE
787 * Bit 1 MPLL_RAE
788 * Bit 0 PLL_LOCKE
789 *----------------------------------------------------------------------------*/
790#define SUNI1x10GEXP_BITMSK_LASIE 0x0008
791#define SUNI1x10GEXP_BITMSK_SPLL_RAE 0x0004
792#define SUNI1x10GEXP_BITMSK_MPLL_RAE 0x0002
793#define SUNI1x10GEXP_BITMSK_PLL_LOCKE 0x0001
794
795/*----------------------------------------------------------------------------
796 * Register 0x0103: SERDES 3125 Interrupt Visibility Register
797 * Bit 3 LASIV
798 * Bit 2 SPLL_RAV
799 * Bit 1 MPLL_RAV
800 * Bit 0 PLL_LOCKV
801 *----------------------------------------------------------------------------*/
802#define SUNI1x10GEXP_BITMSK_LASIV 0x0008
803#define SUNI1x10GEXP_BITMSK_SPLL_RAV 0x0004
804#define SUNI1x10GEXP_BITMSK_MPLL_RAV 0x0002
805#define SUNI1x10GEXP_BITMSK_PLL_LOCKV 0x0001
806
807/*----------------------------------------------------------------------------
808 * Register 0x0104: SERDES 3125 Interrupt Status Register
809 * Bit 3 LASII
810 * Bit 2 SPLL_RAI
811 * Bit 1 MPLL_RAI
812 * Bit 0 PLL_LOCKI
813 *----------------------------------------------------------------------------*/
814#define SUNI1x10GEXP_BITMSK_LASII 0x0008
815#define SUNI1x10GEXP_BITMSK_SPLL_RAI 0x0004
816#define SUNI1x10GEXP_BITMSK_MPLL_RAI 0x0002
817#define SUNI1x10GEXP_BITMSK_PLL_LOCKI 0x0001
818
819/*----------------------------------------------------------------------------
820 * Register 0x0107: SERDES 3125 Test Configuration
821 * Bit 12 DUALTX
822 * Bit 10 HC_1
823 * Bit 9 HC_0
824 *----------------------------------------------------------------------------*/
825#define SUNI1x10GEXP_BITMSK_DUALTX 0x1000
826#define SUNI1x10GEXP_BITMSK_HC 0x0600
827#define SUNI1x10GEXP_BITOFF_HC_0 9
828
829/*----------------------------------------------------------------------------
158 * Register 0x2040: RXXG Configuration 1 830 * Register 0x2040: RXXG Configuration 1
159 * Bit 15 RXXG_RXEN 831 * Bit 15 RXXG_RXEN
160 * Bit 14 RXXG_ROCF 832 * Bit 14 RXXG_ROCF
@@ -168,11 +840,84 @@
168 * Bit 2-0 RXXG_MIFG 840 * Bit 2-0 RXXG_MIFG
169 *----------------------------------------------------------------------------*/ 841 *----------------------------------------------------------------------------*/
170#define SUNI1x10GEXP_BITMSK_RXXG_RXEN 0x8000 842#define SUNI1x10GEXP_BITMSK_RXXG_RXEN 0x8000
843#define SUNI1x10GEXP_BITMSK_RXXG_ROCF 0x4000
844#define SUNI1x10GEXP_BITMSK_RXXG_PAD_STRIP 0x2000
171#define SUNI1x10GEXP_BITMSK_RXXG_PUREP 0x0400 845#define SUNI1x10GEXP_BITMSK_RXXG_PUREP 0x0400
846#define SUNI1x10GEXP_BITMSK_RXXG_LONGP 0x0200
847#define SUNI1x10GEXP_BITMSK_RXXG_PARF 0x0100
172#define SUNI1x10GEXP_BITMSK_RXXG_FLCHK 0x0080 848#define SUNI1x10GEXP_BITMSK_RXXG_FLCHK 0x0080
849#define SUNI1x10GEXP_BITMSK_RXXG_PASS_CTRL 0x0020
173#define SUNI1x10GEXP_BITMSK_RXXG_CRC_STRIP 0x0008 850#define SUNI1x10GEXP_BITMSK_RXXG_CRC_STRIP 0x0008
174 851
175/*---------------------------------------------------------------------------- 852/*----------------------------------------------------------------------------
853 * Register 0x02041: RXXG Configuration 2
854 * Bit 7-0 RXXG_HDRSIZE
855 *----------------------------------------------------------------------------*/
856#define SUNI1x10GEXP_BITMSK_RXXG_HDRSIZE 0x00FF
857
858/*----------------------------------------------------------------------------
859 * Register 0x2042: RXXG Configuration 3
860 * Bit 15 RXXG_MIN_LERRE
861 * Bit 14 RXXG_MAX_LERRE
862 * Bit 12 RXXG_LINE_ERRE
863 * Bit 10 RXXG_RX_OVRE
864 * Bit 9 RXXG_ADR_FILTERE
865 * Bit 8 RXXG_ERR_FILTERE
866 * Bit 5 RXXG_PRMB_ERRE
867 *----------------------------------------------------------------------------*/
868#define SUNI1x10GEXP_BITMSK_RXXG_MIN_LERRE 0x8000
869#define SUNI1x10GEXP_BITMSK_RXXG_MAX_LERRE 0x4000
870#define SUNI1x10GEXP_BITMSK_RXXG_LINE_ERRE 0x1000
871#define SUNI1x10GEXP_BITMSK_RXXG_RX_OVRE 0x0400
872#define SUNI1x10GEXP_BITMSK_RXXG_ADR_FILTERE 0x0200
873#define SUNI1x10GEXP_BITMSK_RXXG_ERR_FILTERRE 0x0100
874#define SUNI1x10GEXP_BITMSK_RXXG_PRMB_ERRE 0x0020
875
876/*----------------------------------------------------------------------------
877 * Register 0x2043: RXXG Interrupt
878 * Bit 15 RXXG_MIN_LERRI
879 * Bit 14 RXXG_MAX_LERRI
880 * Bit 12 RXXG_LINE_ERRI
881 * Bit 10 RXXG_RX_OVRI
882 * Bit 9 RXXG_ADR_FILTERI
883 * Bit 8 RXXG_ERR_FILTERI
884 * Bit 5 RXXG_PRMB_ERRE
885 *----------------------------------------------------------------------------*/
886#define SUNI1x10GEXP_BITMSK_RXXG_MIN_LERRI 0x8000
887#define SUNI1x10GEXP_BITMSK_RXXG_MAX_LERRI 0x4000
888#define SUNI1x10GEXP_BITMSK_RXXG_LINE_ERRI 0x1000
889#define SUNI1x10GEXP_BITMSK_RXXG_RX_OVRI 0x0400
890#define SUNI1x10GEXP_BITMSK_RXXG_ADR_FILTERI 0x0200
891#define SUNI1x10GEXP_BITMSK_RXXG_ERR_FILTERI 0x0100
892#define SUNI1x10GEXP_BITMSK_RXXG_PRMB_ERRE 0x0020
893
894/*----------------------------------------------------------------------------
895 * Register 0x2049: RXXG Receive FIFO Threshold
896 * Bit 2-0 RXXG_CUT_THRU
897 *----------------------------------------------------------------------------*/
898#define SUNI1x10GEXP_BITMSK_RXXG_CUT_THRU 0x0007
899#define SUNI1x10GEXP_BITOFF_RXXG_CUT_THRU 0
900
901/*----------------------------------------------------------------------------
902 * Register 0x2062H - 0x2069: RXXG Exact Match VID
903 * Bit 11-0 RXXG_VID_MATCH
904 *----------------------------------------------------------------------------*/
905#define SUNI1x10GEXP_BITMSK_RXXG_VID_MATCH 0x0FFF
906#define SUNI1x10GEXP_BITOFF_RXXG_VID_MATCH 0
907
908/*----------------------------------------------------------------------------
909 * Register 0x206EH - 0x206F: RXXG Address Filter Control
910 * Bit 3 RXXG_FORWARD_ENABLE
911 * Bit 2 RXXG_VLAN_ENABLE
912 * Bit 1 RXXG_SRC_ADDR
913 * Bit 0 RXXG_MATCH_ENABLE
914 *----------------------------------------------------------------------------*/
915#define SUNI1x10GEXP_BITMSK_RXXG_FORWARD_ENABLE 0x0008
916#define SUNI1x10GEXP_BITMSK_RXXG_VLAN_ENABLE 0x0004
917#define SUNI1x10GEXP_BITMSK_RXXG_SRC_ADDR 0x0002
918#define SUNI1x10GEXP_BITMSK_RXXG_MATCH_ENABLE 0x0001
919
920/*----------------------------------------------------------------------------
176 * Register 0x2070: RXXG Address Filter Control 2 921 * Register 0x2070: RXXG Address Filter Control 2
177 * Bit 1 RXXG_PMODE 922 * Bit 1 RXXG_PMODE
178 * Bit 0 RXXG_MHASH_EN 923 * Bit 0 RXXG_MHASH_EN
@@ -181,15 +926,446 @@
181#define SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN 0x0001 926#define SUNI1x10GEXP_BITMSK_RXXG_MHASH_EN 0x0001
182 927
183/*---------------------------------------------------------------------------- 928/*----------------------------------------------------------------------------
929 * Register 0x2081: XRF Control Register 2
930 * Bit 6 EN_PKT_GEN
931 * Bit 4-2 PATT
932 *----------------------------------------------------------------------------*/
933#define SUNI1x10GEXP_BITMSK_EN_PKT_GEN 0x0040
934#define SUNI1x10GEXP_BITMSK_PATT 0x001C
935#define SUNI1x10GEXP_BITOFF_PATT 2
936
937/*----------------------------------------------------------------------------
938 * Register 0x2088: XRF Interrupt Enable
939 * Bit 12-9 LANE_HICERE
940 * Bit 8-5 HS_SD_LANEE
941 * Bit 4 ALIGN_STATUS_ERRE
942 * Bit 3-0 LANE_SYNC_STAT_ERRE
943 *----------------------------------------------------------------------------*/
944#define SUNI1x10GEXP_BITMSK_LANE_HICERE 0x1E00
945#define SUNI1x10GEXP_BITOFF_LANE_HICERE 9
946#define SUNI1x10GEXP_BITMSK_HS_SD_LANEE 0x01E0
947#define SUNI1x10GEXP_BITOFF_HS_SD_LANEE 5
948#define SUNI1x10GEXP_BITMSK_ALIGN_STATUS_ERRE 0x0010
949#define SUNI1x10GEXP_BITMSK_LANE_SYNC_STAT_ERRE 0x000F
950#define SUNI1x10GEXP_BITOFF_LANE_SYNC_STAT_ERRE 0
951
952/*----------------------------------------------------------------------------
953 * Register 0x2089: XRF Interrupt Status
954 * Bit 12-9 LANE_HICERI
955 * Bit 8-5 HS_SD_LANEI
956 * Bit 4 ALIGN_STATUS_ERRI
957 * Bit 3-0 LANE_SYNC_STAT_ERRI
958 *----------------------------------------------------------------------------*/
959#define SUNI1x10GEXP_BITMSK_LANE_HICERI 0x1E00
960#define SUNI1x10GEXP_BITOFF_LANE_HICERI 9
961#define SUNI1x10GEXP_BITMSK_HS_SD_LANEI 0x01E0
962#define SUNI1x10GEXP_BITOFF_HS_SD_LANEI 5
963#define SUNI1x10GEXP_BITMSK_ALIGN_STATUS_ERRI 0x0010
964#define SUNI1x10GEXP_BITMSK_LANE_SYNC_STAT_ERRI 0x000F
965#define SUNI1x10GEXP_BITOFF_LANE_SYNC_STAT_ERRI 0
966
967/*----------------------------------------------------------------------------
968 * Register 0x208A: XRF Error Status
969 * Bit 8-5 HS_SD_LANE
970 * Bit 4 ALIGN_STATUS_ERR
971 * Bit 3-0 LANE_SYNC_STAT_ERR
972 *----------------------------------------------------------------------------*/
973#define SUNI1x10GEXP_BITMSK_HS_SD_LANE3 0x0100
974#define SUNI1x10GEXP_BITMSK_HS_SD_LANE2 0x0080
975#define SUNI1x10GEXP_BITMSK_HS_SD_LANE1 0x0040
976#define SUNI1x10GEXP_BITMSK_HS_SD_LANE0 0x0020
977#define SUNI1x10GEXP_BITMSK_ALIGN_STATUS_ERR 0x0010
978#define SUNI1x10GEXP_BITMSK_LANE3_SYNC_STAT_ERR 0x0008
979#define SUNI1x10GEXP_BITMSK_LANE2_SYNC_STAT_ERR 0x0004
980#define SUNI1x10GEXP_BITMSK_LANE1_SYNC_STAT_ERR 0x0002
981#define SUNI1x10GEXP_BITMSK_LANE0_SYNC_STAT_ERR 0x0001
982
983/*----------------------------------------------------------------------------
984 * Register 0x208B: XRF Diagnostic Interrupt Enable
985 * Bit 7-4 LANE_OVERRUNE
986 * Bit 3-0 LANE_UNDERRUNE
987 *----------------------------------------------------------------------------*/
988#define SUNI1x10GEXP_BITMSK_LANE_OVERRUNE 0x00F0
989#define SUNI1x10GEXP_BITOFF_LANE_OVERRUNE 4
990#define SUNI1x10GEXP_BITMSK_LANE_UNDERRUNE 0x000F
991#define SUNI1x10GEXP_BITOFF_LANE_UNDERRUNE 0
992
993/*----------------------------------------------------------------------------
994 * Register 0x208C: XRF Diagnostic Interrupt Status
995 * Bit 7-4 LANE_OVERRUNI
996 * Bit 3-0 LANE_UNDERRUNI
997 *----------------------------------------------------------------------------*/
998#define SUNI1x10GEXP_BITMSK_LANE_OVERRUNI 0x00F0
999#define SUNI1x10GEXP_BITOFF_LANE_OVERRUNI 4
1000#define SUNI1x10GEXP_BITMSK_LANE_UNDERRUNI 0x000F
1001#define SUNI1x10GEXP_BITOFF_LANE_UNDERRUNI 0
1002
1003/*----------------------------------------------------------------------------
1004 * Register 0x20C0: RXOAM Configuration
1005 * Bit 15 RXOAM_BUSY
1006 * Bit 14-12 RXOAM_F2_SEL
1007 * Bit 10-8 RXOAM_F1_SEL
1008 * Bit 7-6 RXOAM_FILTER_CTRL
1009 * Bit 5-0 RXOAM_PX_EN
1010 *----------------------------------------------------------------------------*/
1011#define SUNI1x10GEXP_BITMSK_RXOAM_BUSY 0x8000
1012#define SUNI1x10GEXP_BITMSK_RXOAM_F2_SEL 0x7000
1013#define SUNI1x10GEXP_BITOFF_RXOAM_F2_SEL 12
1014#define SUNI1x10GEXP_BITMSK_RXOAM_F1_SEL 0x0700
1015#define SUNI1x10GEXP_BITOFF_RXOAM_F1_SEL 8
1016#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_CTRL 0x00C0
1017#define SUNI1x10GEXP_BITOFF_RXOAM_FILTER_CTRL 6
1018#define SUNI1x10GEXP_BITMSK_RXOAM_PX_EN 0x003F
1019#define SUNI1x10GEXP_BITOFF_RXOAM_PX_EN 0
1020
1021/*----------------------------------------------------------------------------
1022 * Register 0x20C1,0x20C2: RXOAM Filter Configuration
1023 * Bit 15-8 RXOAM_FX_MASK
1024 * Bit 7-0 RXOAM_FX_VAL
1025 *----------------------------------------------------------------------------*/
1026#define SUNI1x10GEXP_BITMSK_RXOAM_FX_MASK 0xFF00
1027#define SUNI1x10GEXP_BITOFF_RXOAM_FX_MASK 8
1028#define SUNI1x10GEXP_BITMSK_RXOAM_FX_VAL 0x00FF
1029#define SUNI1x10GEXP_BITOFF_RXOAM_FX_VAl 0
1030
1031/*----------------------------------------------------------------------------
1032 * Register 0x20C3: RXOAM Configuration Register 2
1033 * Bit 13 RXOAM_REC_BYTE_VAL
1034 * Bit 11-10 RXOAM_BYPASS_MODE
1035 * Bit 5-0 RXOAM_PX_CLEAR
1036 *----------------------------------------------------------------------------*/
1037#define SUNI1x10GEXP_BITMSK_RXOAM_REC_BYTE_VAL 0x2000
1038#define SUNI1x10GEXP_BITMSK_RXOAM_BYPASS_MODE 0x0C00
1039#define SUNI1x10GEXP_BITOFF_RXOAM_BYPASS_MODE 10
1040#define SUNI1x10GEXP_BITMSK_RXOAM_PX_CLEAR 0x003F
1041#define SUNI1x10GEXP_BITOFF_RXOAM_PX_CLEAR 0
1042
1043/*----------------------------------------------------------------------------
1044 * Register 0x20C4: RXOAM HEC Configuration
1045 * Bit 15-8 RXOAM_COSET
1046 * Bit 2 RXOAM_HEC_ERR_PKT
1047 * Bit 0 RXOAM_HEC_EN
1048 *----------------------------------------------------------------------------*/
1049#define SUNI1x10GEXP_BITMSK_RXOAM_COSET 0xFF00
1050#define SUNI1x10GEXP_BITOFF_RXOAM_COSET 8
1051#define SUNI1x10GEXP_BITMSK_RXOAM_HEC_ERR_PKT 0x0004
1052#define SUNI1x10GEXP_BITMSK_RXOAM_HEC_EN 0x0001
1053
1054/*----------------------------------------------------------------------------
1055 * Register 0x20C7: RXOAM Interrupt Enable
1056 * Bit 10 RXOAM_FILTER_THRSHE
1057 * Bit 9 RXOAM_OAM_ERRE
1058 * Bit 8 RXOAM_HECE_THRSHE
1059 * Bit 7 RXOAM_SOPE
1060 * Bit 6 RXOAM_RFE
1061 * Bit 5 RXOAM_LFE
1062 * Bit 4 RXOAM_DV_ERRE
1063 * Bit 3 RXOAM_DATA_INVALIDE
1064 * Bit 2 RXOAM_FILTER_DROPE
1065 * Bit 1 RXOAM_HECE
1066 * Bit 0 RXOAM_OFLE
1067 *----------------------------------------------------------------------------*/
1068#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_THRSHE 0x0400
1069#define SUNI1x10GEXP_BITMSK_RXOAM_OAM_ERRE 0x0200
1070#define SUNI1x10GEXP_BITMSK_RXOAM_HECE_THRSHE 0x0100
1071#define SUNI1x10GEXP_BITMSK_RXOAM_SOPE 0x0080
1072#define SUNI1x10GEXP_BITMSK_RXOAM_RFE 0x0040
1073#define SUNI1x10GEXP_BITMSK_RXOAM_LFE 0x0020
1074#define SUNI1x10GEXP_BITMSK_RXOAM_DV_ERRE 0x0010
1075#define SUNI1x10GEXP_BITMSK_RXOAM_DATA_INVALIDE 0x0008
1076#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_DROPE 0x0004
1077#define SUNI1x10GEXP_BITMSK_RXOAM_HECE 0x0002
1078#define SUNI1x10GEXP_BITMSK_RXOAM_OFLE 0x0001
1079
1080/*----------------------------------------------------------------------------
1081 * Register 0x20C8: RXOAM Interrupt Status
1082 * Bit 10 RXOAM_FILTER_THRSHI
1083 * Bit 9 RXOAM_OAM_ERRI
1084 * Bit 8 RXOAM_HECE_THRSHI
1085 * Bit 7 RXOAM_SOPI
1086 * Bit 6 RXOAM_RFI
1087 * Bit 5 RXOAM_LFI
1088 * Bit 4 RXOAM_DV_ERRI
1089 * Bit 3 RXOAM_DATA_INVALIDI
1090 * Bit 2 RXOAM_FILTER_DROPI
1091 * Bit 1 RXOAM_HECI
1092 * Bit 0 RXOAM_OFLI
1093 *----------------------------------------------------------------------------*/
1094#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_THRSHI 0x0400
1095#define SUNI1x10GEXP_BITMSK_RXOAM_OAM_ERRI 0x0200
1096#define SUNI1x10GEXP_BITMSK_RXOAM_HECE_THRSHI 0x0100
1097#define SUNI1x10GEXP_BITMSK_RXOAM_SOPI 0x0080
1098#define SUNI1x10GEXP_BITMSK_RXOAM_RFI 0x0040
1099#define SUNI1x10GEXP_BITMSK_RXOAM_LFI 0x0020
1100#define SUNI1x10GEXP_BITMSK_RXOAM_DV_ERRI 0x0010
1101#define SUNI1x10GEXP_BITMSK_RXOAM_DATA_INVALIDI 0x0008
1102#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_DROPI 0x0004
1103#define SUNI1x10GEXP_BITMSK_RXOAM_HECI 0x0002
1104#define SUNI1x10GEXP_BITMSK_RXOAM_OFLI 0x0001
1105
1106/*----------------------------------------------------------------------------
1107 * Register 0x20C9: RXOAM Status
1108 * Bit 10 RXOAM_FILTER_THRSHV
1109 * Bit 8 RXOAM_HECE_THRSHV
1110 * Bit 6 RXOAM_RFV
1111 * Bit 5 RXOAM_LFV
1112 *----------------------------------------------------------------------------*/
1113#define SUNI1x10GEXP_BITMSK_RXOAM_FILTER_THRSHV 0x0400
1114#define SUNI1x10GEXP_BITMSK_RXOAM_HECE_THRSHV 0x0100
1115#define SUNI1x10GEXP_BITMSK_RXOAM_RFV 0x0040
1116#define SUNI1x10GEXP_BITMSK_RXOAM_LFV 0x0020
1117
1118/*----------------------------------------------------------------------------
184 * Register 0x2100: MSTAT Control 1119 * Register 0x2100: MSTAT Control
185 * Bit 2 MSTAT_WRITE 1120 * Bit 2 MSTAT_WRITE
186 * Bit 1 MSTAT_CLEAR 1121 * Bit 1 MSTAT_CLEAR
187 * Bit 0 MSTAT_SNAP 1122 * Bit 0 MSTAT_SNAP
188 *----------------------------------------------------------------------------*/ 1123 *----------------------------------------------------------------------------*/
1124#define SUNI1x10GEXP_BITMSK_MSTAT_WRITE 0x0004
189#define SUNI1x10GEXP_BITMSK_MSTAT_CLEAR 0x0002 1125#define SUNI1x10GEXP_BITMSK_MSTAT_CLEAR 0x0002
190#define SUNI1x10GEXP_BITMSK_MSTAT_SNAP 0x0001 1126#define SUNI1x10GEXP_BITMSK_MSTAT_SNAP 0x0001
191 1127
192/*---------------------------------------------------------------------------- 1128/*----------------------------------------------------------------------------
1129 * Register 0x2109: MSTAT Counter Write Address
1130 * Bit 5-0 MSTAT_WRITE_ADDRESS
1131 *----------------------------------------------------------------------------*/
1132#define SUNI1x10GEXP_BITMSK_MSTAT_WRITE_ADDRESS 0x003F
1133#define SUNI1x10GEXP_BITOFF_MSTAT_WRITE_ADDRESS 0
1134
1135/*----------------------------------------------------------------------------
1136 * Register 0x2200: IFLX Global Configuration Register
1137 * Bit 15 IFLX_IRCU_ENABLE
1138 * Bit 14 IFLX_IDSWT_ENABLE
1139 * Bit 13-0 IFLX_IFD_CNT
1140 *----------------------------------------------------------------------------*/
1141#define SUNI1x10GEXP_BITMSK_IFLX_IRCU_ENABLE 0x8000
1142#define SUNI1x10GEXP_BITMSK_IFLX_IDSWT_ENABLE 0x4000
1143#define SUNI1x10GEXP_BITMSK_IFLX_IFD_CNT 0x3FFF
1144#define SUNI1x10GEXP_BITOFF_IFLX_IFD_CNT 0
1145
1146/*----------------------------------------------------------------------------
1147 * Register 0x2209: IFLX FIFO Overflow Enable
1148 * Bit 0 IFLX_OVFE
1149 *----------------------------------------------------------------------------*/
1150#define SUNI1x10GEXP_BITMSK_IFLX_OVFE 0x0001
1151
1152/*----------------------------------------------------------------------------
1153 * Register 0x220A: IFLX FIFO Overflow Interrupt
1154 * Bit 0 IFLX_OVFI
1155 *----------------------------------------------------------------------------*/
1156#define SUNI1x10GEXP_BITMSK_IFLX_OVFI 0x0001
1157
1158/*----------------------------------------------------------------------------
1159 * Register 0x220D: IFLX Indirect Channel Address
1160 * Bit 15 IFLX_BUSY
1161 * Bit 14 IFLX_RWB
1162 *----------------------------------------------------------------------------*/
1163#define SUNI1x10GEXP_BITMSK_IFLX_BUSY 0x8000
1164#define SUNI1x10GEXP_BITMSK_IFLX_RWB 0x4000
1165
1166/*----------------------------------------------------------------------------
1167 * Register 0x220E: IFLX Indirect Logical FIFO Low Limit & Provision
1168 * Bit 9-0 IFLX_LOLIM
1169 *----------------------------------------------------------------------------*/
1170#define SUNI1x10GEXP_BITMSK_IFLX_LOLIM 0x03FF
1171#define SUNI1x10GEXP_BITOFF_IFLX_LOLIM 0
1172
1173/*----------------------------------------------------------------------------
1174 * Register 0x220F: IFLX Indirect Logical FIFO High Limit
1175 * Bit 9-0 IFLX_HILIM
1176 *----------------------------------------------------------------------------*/
1177#define SUNI1x10GEXP_BITMSK_IFLX_HILIM 0x03FF
1178#define SUNI1x10GEXP_BITOFF_IFLX_HILIM 0
1179
1180/*----------------------------------------------------------------------------
1181 * Register 0x2210: IFLX Indirect Full/Almost Full Status & Limit
1182 * Bit 15 IFLX_FULL
1183 * Bit 14 IFLX_AFULL
1184 * Bit 13-0 IFLX_AFTH
1185 *----------------------------------------------------------------------------*/
1186#define SUNI1x10GEXP_BITMSK_IFLX_FULL 0x8000
1187#define SUNI1x10GEXP_BITMSK_IFLX_AFULL 0x4000
1188#define SUNI1x10GEXP_BITMSK_IFLX_AFTH 0x3FFF
1189#define SUNI1x10GEXP_BITOFF_IFLX_AFTH 0
1190
1191/*----------------------------------------------------------------------------
1192 * Register 0x2211: IFLX Indirect Empty/Almost Empty Status & Limit
1193 * Bit 15 IFLX_EMPTY
1194 * Bit 14 IFLX_AEMPTY
1195 * Bit 13-0 IFLX_AETH
1196 *----------------------------------------------------------------------------*/
1197#define SUNI1x10GEXP_BITMSK_IFLX_EMPTY 0x8000
1198#define SUNI1x10GEXP_BITMSK_IFLX_AEMPTY 0x4000
1199#define SUNI1x10GEXP_BITMSK_IFLX_AETH 0x3FFF
1200#define SUNI1x10GEXP_BITOFF_IFLX_AETH 0
1201
1202/*----------------------------------------------------------------------------
1203 * Register 0x2240: PL4MOS Configuration Register
1204 * Bit 3 PL4MOS_RE_INIT
1205 * Bit 2 PL4MOS_EN
1206 * Bit 1 PL4MOS_NO_STATUS
1207 *----------------------------------------------------------------------------*/
1208#define SUNI1x10GEXP_BITMSK_PL4MOS_RE_INIT 0x0008
1209#define SUNI1x10GEXP_BITMSK_PL4MOS_EN 0x0004
1210#define SUNI1x10GEXP_BITMSK_PL4MOS_NO_STATUS 0x0002
1211
1212/*----------------------------------------------------------------------------
1213 * Register 0x2243: PL4MOS MaxBurst1 Register
1214 * Bit 11-0 PL4MOS_MAX_BURST1
1215 *----------------------------------------------------------------------------*/
1216#define SUNI1x10GEXP_BITMSK_PL4MOS_MAX_BURST1 0x0FFF
1217#define SUNI1x10GEXP_BITOFF_PL4MOS_MAX_BURST1 0
1218
1219/*----------------------------------------------------------------------------
1220 * Register 0x2244: PL4MOS MaxBurst2 Register
1221 * Bit 11-0 PL4MOS_MAX_BURST2
1222 *----------------------------------------------------------------------------*/
1223#define SUNI1x10GEXP_BITMSK_PL4MOS_MAX_BURST2 0x0FFF
1224#define SUNI1x10GEXP_BITOFF_PL4MOS_MAX_BURST2 0
1225
1226/*----------------------------------------------------------------------------
1227 * Register 0x2245: PL4MOS Transfer Size Register
1228 * Bit 7-0 PL4MOS_MAX_TRANSFER
1229 *----------------------------------------------------------------------------*/
1230#define SUNI1x10GEXP_BITMSK_PL4MOS_MAX_TRANSFER 0x00FF
1231#define SUNI1x10GEXP_BITOFF_PL4MOS_MAX_TRANSFER 0
1232
1233/*----------------------------------------------------------------------------
1234 * Register 0x2280: PL4ODP Configuration
1235 * Bit 15-12 PL4ODP_REPEAT_T
1236 * Bit 8 PL4ODP_SOP_RULE
1237 * Bit 1 PL4ODP_EN_PORTS
1238 * Bit 0 PL4ODP_EN_DFWD
1239 *----------------------------------------------------------------------------*/
1240#define SUNI1x10GEXP_BITMSK_PL4ODP_REPEAT_T 0xF000
1241#define SUNI1x10GEXP_BITOFF_PL4ODP_REPEAT_T 12
1242#define SUNI1x10GEXP_BITMSK_PL4ODP_SOP_RULE 0x0100
1243#define SUNI1x10GEXP_BITMSK_PL4ODP_EN_PORTS 0x0002
1244#define SUNI1x10GEXP_BITMSK_PL4ODP_EN_DFWD 0x0001
1245
1246/*----------------------------------------------------------------------------
1247 * Register 0x2282: PL4ODP Interrupt Mask
1248 * Bit 0 PL4ODP_OUT_DISE
1249 *----------------------------------------------------------------------------*/
1250#define SUNI1x10GEXP_BITMSK_PL4ODP_OUT_DISE 0x0001
1251
1252
1253
1254#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_EOPEOBE 0x0080
1255#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_ERREOPE 0x0040
1256#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_MEOPE 0x0008
1257#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_MSOPE 0x0004
1258#define SUNI1x10GEXP_BITMSK_PL4ODP_ES_OVRE 0x0002
1259
1260
1261/*----------------------------------------------------------------------------
1262 * Register 0x2283: PL4ODP Interrupt
1263 * Bit 0 PL4ODP_OUT_DISI
1264 *----------------------------------------------------------------------------*/
1265#define SUNI1x10GEXP_BITMSK_PL4ODP_OUT_DISI 0x0001
1266
1267
1268
1269#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_EOPEOBI 0x0080
1270#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_ERREOPI 0x0040
1271#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_MEOPI 0x0008
1272#define SUNI1x10GEXP_BITMSK_PL4ODP_PPE_MSOPI 0x0004
1273#define SUNI1x10GEXP_BITMSK_PL4ODP_ES_OVRI 0x0002
1274
1275/*----------------------------------------------------------------------------
1276 * Register 0x2300: PL4IO Lock Detect Status
1277 * Bit 15 PL4IO_OUT_ROOLV
1278 * Bit 12 PL4IO_IS_ROOLV
1279 * Bit 11 PL4IO_DIP2_ERRV
1280 * Bit 8 PL4IO_ID_ROOLV
1281 * Bit 4 PL4IO_IS_DOOLV
1282 * Bit 0 PL4IO_ID_DOOLV
1283 *----------------------------------------------------------------------------*/
1284#define SUNI1x10GEXP_BITMSK_PL4IO_OUT_ROOLV 0x8000
1285#define SUNI1x10GEXP_BITMSK_PL4IO_IS_ROOLV 0x1000
1286#define SUNI1x10GEXP_BITMSK_PL4IO_DIP2_ERRV 0x0800
1287#define SUNI1x10GEXP_BITMSK_PL4IO_ID_ROOLV 0x0100
1288#define SUNI1x10GEXP_BITMSK_PL4IO_IS_DOOLV 0x0010
1289#define SUNI1x10GEXP_BITMSK_PL4IO_ID_DOOLV 0x0001
1290
1291/*----------------------------------------------------------------------------
1292 * Register 0x2301: PL4IO Lock Detect Change
1293 * Bit 15 PL4IO_OUT_ROOLI
1294 * Bit 12 PL4IO_IS_ROOLI
1295 * Bit 11 PL4IO_DIP2_ERRI
1296 * Bit 8 PL4IO_ID_ROOLI
1297 * Bit 4 PL4IO_IS_DOOLI
1298 * Bit 0 PL4IO_ID_DOOLI
1299 *----------------------------------------------------------------------------*/
1300#define SUNI1x10GEXP_BITMSK_PL4IO_OUT_ROOLI 0x8000
1301#define SUNI1x10GEXP_BITMSK_PL4IO_IS_ROOLI 0x1000
1302#define SUNI1x10GEXP_BITMSK_PL4IO_DIP2_ERRI 0x0800
1303#define SUNI1x10GEXP_BITMSK_PL4IO_ID_ROOLI 0x0100
1304#define SUNI1x10GEXP_BITMSK_PL4IO_IS_DOOLI 0x0010
1305#define SUNI1x10GEXP_BITMSK_PL4IO_ID_DOOLI 0x0001
1306
1307/*----------------------------------------------------------------------------
1308 * Register 0x2302: PL4IO Lock Detect Mask
1309 * Bit 15 PL4IO_OUT_ROOLE
1310 * Bit 12 PL4IO_IS_ROOLE
1311 * Bit 11 PL4IO_DIP2_ERRE
1312 * Bit 8 PL4IO_ID_ROOLE
1313 * Bit 4 PL4IO_IS_DOOLE
1314 * Bit 0 PL4IO_ID_DOOLE
1315 *----------------------------------------------------------------------------*/
1316#define SUNI1x10GEXP_BITMSK_PL4IO_OUT_ROOLE 0x8000
1317#define SUNI1x10GEXP_BITMSK_PL4IO_IS_ROOLE 0x1000
1318#define SUNI1x10GEXP_BITMSK_PL4IO_DIP2_ERRE 0x0800
1319#define SUNI1x10GEXP_BITMSK_PL4IO_ID_ROOLE 0x0100
1320#define SUNI1x10GEXP_BITMSK_PL4IO_IS_DOOLE 0x0010
1321#define SUNI1x10GEXP_BITMSK_PL4IO_ID_DOOLE 0x0001
1322
1323/*----------------------------------------------------------------------------
1324 * Register 0x2303: PL4IO Lock Detect Limits
1325 * Bit 15-8 PL4IO_REF_LIMIT
1326 * Bit 7-0 PL4IO_TRAN_LIMIT
1327 *----------------------------------------------------------------------------*/
1328#define SUNI1x10GEXP_BITMSK_PL4IO_REF_LIMIT 0xFF00
1329#define SUNI1x10GEXP_BITOFF_PL4IO_REF_LIMIT 8
1330#define SUNI1x10GEXP_BITMSK_PL4IO_TRAN_LIMIT 0x00FF
1331#define SUNI1x10GEXP_BITOFF_PL4IO_TRAN_LIMIT 0
1332
1333/*----------------------------------------------------------------------------
1334 * Register 0x2304: PL4IO Calendar Repetitions
1335 * Bit 15-8 PL4IO_IN_MUL
1336 * Bit 7-0 PL4IO_OUT_MUL
1337 *----------------------------------------------------------------------------*/
1338#define SUNI1x10GEXP_BITMSK_PL4IO_IN_MUL 0xFF00
1339#define SUNI1x10GEXP_BITOFF_PL4IO_IN_MUL 8
1340#define SUNI1x10GEXP_BITMSK_PL4IO_OUT_MUL 0x00FF
1341#define SUNI1x10GEXP_BITOFF_PL4IO_OUT_MUL 0
1342
1343/*----------------------------------------------------------------------------
1344 * Register 0x2305: PL4IO Configuration
1345 * Bit 15 PL4IO_DIP2_ERR_CHK
1346 * Bit 11 PL4IO_ODAT_DIS
1347 * Bit 10 PL4IO_TRAIN_DIS
1348 * Bit 9 PL4IO_OSTAT_DIS
1349 * Bit 8 PL4IO_ISTAT_DIS
1350 * Bit 7 PL4IO_NO_ISTAT
1351 * Bit 6 PL4IO_STAT_OUTSEL
1352 * Bit 5 PL4IO_INSEL
1353 * Bit 4 PL4IO_DLSEL
1354 * Bit 1-0 PL4IO_OUTSEL
1355 *----------------------------------------------------------------------------*/
1356#define SUNI1x10GEXP_BITMSK_PL4IO_DIP2_ERR_CHK 0x8000
1357#define SUNI1x10GEXP_BITMSK_PL4IO_ODAT_DIS 0x0800
1358#define SUNI1x10GEXP_BITMSK_PL4IO_TRAIN_DIS 0x0400
1359#define SUNI1x10GEXP_BITMSK_PL4IO_OSTAT_DIS 0x0200
1360#define SUNI1x10GEXP_BITMSK_PL4IO_ISTAT_DIS 0x0100
1361#define SUNI1x10GEXP_BITMSK_PL4IO_NO_ISTAT 0x0080
1362#define SUNI1x10GEXP_BITMSK_PL4IO_STAT_OUTSEL 0x0040
1363#define SUNI1x10GEXP_BITMSK_PL4IO_INSEL 0x0020
1364#define SUNI1x10GEXP_BITMSK_PL4IO_DLSEL 0x0010
1365#define SUNI1x10GEXP_BITMSK_PL4IO_OUTSEL 0x0003
1366#define SUNI1x10GEXP_BITOFF_PL4IO_OUTSEL 0
1367
1368/*----------------------------------------------------------------------------
193 * Register 0x3040: TXXG Configuration Register 1 1369 * Register 0x3040: TXXG Configuration Register 1
194 * Bit 15 TXXG_TXEN0 1370 * Bit 15 TXXG_TXEN0
195 * Bit 13 TXXG_HOSTPAUSE 1371 * Bit 13 TXXG_HOSTPAUSE
@@ -202,12 +1378,266 @@
202 * Bit 0 TXXG_SPRE 1378 * Bit 0 TXXG_SPRE
203 *----------------------------------------------------------------------------*/ 1379 *----------------------------------------------------------------------------*/
204#define SUNI1x10GEXP_BITMSK_TXXG_TXEN0 0x8000 1380#define SUNI1x10GEXP_BITMSK_TXXG_TXEN0 0x8000
1381#define SUNI1x10GEXP_BITMSK_TXXG_HOSTPAUSE 0x2000
1382#define SUNI1x10GEXP_BITMSK_TXXG_IPGT 0x1F80
205#define SUNI1x10GEXP_BITOFF_TXXG_IPGT 7 1383#define SUNI1x10GEXP_BITOFF_TXXG_IPGT 7
206#define SUNI1x10GEXP_BITMSK_TXXG_32BIT_ALIGN 0x0020 1384#define SUNI1x10GEXP_BITMSK_TXXG_32BIT_ALIGN 0x0020
207#define SUNI1x10GEXP_BITMSK_TXXG_CRCEN 0x0010 1385#define SUNI1x10GEXP_BITMSK_TXXG_CRCEN 0x0010
208#define SUNI1x10GEXP_BITMSK_TXXG_FCTX 0x0008 1386#define SUNI1x10GEXP_BITMSK_TXXG_FCTX 0x0008
209#define SUNI1x10GEXP_BITMSK_TXXG_FCRX 0x0004 1387#define SUNI1x10GEXP_BITMSK_TXXG_FCRX 0x0004
210#define SUNI1x10GEXP_BITMSK_TXXG_PADEN 0x0002 1388#define SUNI1x10GEXP_BITMSK_TXXG_PADEN 0x0002
1389#define SUNI1x10GEXP_BITMSK_TXXG_SPRE 0x0001
1390
1391/*----------------------------------------------------------------------------
1392 * Register 0x3041: TXXG Configuration Register 2
1393 * Bit 7-0 TXXG_HDRSIZE
1394 *----------------------------------------------------------------------------*/
1395#define SUNI1x10GEXP_BITMSK_TXXG_HDRSIZE 0x00FF
1396
1397/*----------------------------------------------------------------------------
1398 * Register 0x3042: TXXG Configuration Register 3
1399 * Bit 15 TXXG_FIFO_ERRE
1400 * Bit 14 TXXG_FIFO_UDRE
1401 * Bit 13 TXXG_MAX_LERRE
1402 * Bit 12 TXXG_MIN_LERRE
1403 * Bit 11 TXXG_XFERE
1404 *----------------------------------------------------------------------------*/
1405#define SUNI1x10GEXP_BITMSK_TXXG_FIFO_ERRE 0x8000
1406#define SUNI1x10GEXP_BITMSK_TXXG_FIFO_UDRE 0x4000
1407#define SUNI1x10GEXP_BITMSK_TXXG_MAX_LERRE 0x2000
1408#define SUNI1x10GEXP_BITMSK_TXXG_MIN_LERRE 0x1000
1409#define SUNI1x10GEXP_BITMSK_TXXG_XFERE 0x0800
1410
1411/*----------------------------------------------------------------------------
1412 * Register 0x3043: TXXG Interrupt
1413 * Bit 15 TXXG_FIFO_ERRI
1414 * Bit 14 TXXG_FIFO_UDRI
1415 * Bit 13 TXXG_MAX_LERRI
1416 * Bit 12 TXXG_MIN_LERRI
1417 * Bit 11 TXXG_XFERI
1418 *----------------------------------------------------------------------------*/
1419#define SUNI1x10GEXP_BITMSK_TXXG_FIFO_ERRI 0x8000
1420#define SUNI1x10GEXP_BITMSK_TXXG_FIFO_UDRI 0x4000
1421#define SUNI1x10GEXP_BITMSK_TXXG_MAX_LERRI 0x2000
1422#define SUNI1x10GEXP_BITMSK_TXXG_MIN_LERRI 0x1000
1423#define SUNI1x10GEXP_BITMSK_TXXG_XFERI 0x0800
1424
1425/*----------------------------------------------------------------------------
1426 * Register 0x3044: TXXG Status Register
1427 * Bit 1 TXXG_TXACTIVE
1428 * Bit 0 TXXG_PAUSED
1429 *----------------------------------------------------------------------------*/
1430#define SUNI1x10GEXP_BITMSK_TXXG_TXACTIVE 0x0002
1431#define SUNI1x10GEXP_BITMSK_TXXG_PAUSED 0x0001
1432
1433/*----------------------------------------------------------------------------
1434 * Register 0x3046: TXXG TX_MINFR - Transmit Min Frame Size Register
1435 * Bit 7-0 TXXG_TX_MINFR
1436 *----------------------------------------------------------------------------*/
1437#define SUNI1x10GEXP_BITMSK_TXXG_TX_MINFR 0x00FF
1438#define SUNI1x10GEXP_BITOFF_TXXG_TX_MINFR 0
1439
1440/*----------------------------------------------------------------------------
1441 * Register 0x3052: TXXG Pause Quantum Value Configuration Register
1442 * Bit 7-0 TXXG_FC_PAUSE_QNTM
1443 *----------------------------------------------------------------------------*/
1444#define SUNI1x10GEXP_BITMSK_TXXG_FC_PAUSE_QNTM 0x00FF
1445#define SUNI1x10GEXP_BITOFF_TXXG_FC_PAUSE_QNTM 0
1446
1447/*----------------------------------------------------------------------------
1448 * Register 0x3080: XTEF Control
1449 * Bit 3-0 XTEF_FORCE_PARITY_ERR
1450 *----------------------------------------------------------------------------*/
1451#define SUNI1x10GEXP_BITMSK_XTEF_FORCE_PARITY_ERR 0x000F
1452#define SUNI1x10GEXP_BITOFF_XTEF_FORCE_PARITY_ERR 0
1453
1454/*----------------------------------------------------------------------------
1455 * Register 0x3084: XTEF Interrupt Event Register
1456 * Bit 0 XTEF_LOST_SYNCI
1457 *----------------------------------------------------------------------------*/
1458#define SUNI1x10GEXP_BITMSK_XTEF_LOST_SYNCI 0x0001
1459
1460/*----------------------------------------------------------------------------
1461 * Register 0x3085: XTEF Interrupt Enable Register
1462 * Bit 0 XTEF_LOST_SYNCE
1463 *----------------------------------------------------------------------------*/
1464#define SUNI1x10GEXP_BITMSK_XTEF_LOST_SYNCE 0x0001
1465
1466/*----------------------------------------------------------------------------
1467 * Register 0x3086: XTEF Visibility Register
1468 * Bit 0 XTEF_LOST_SYNCV
1469 *----------------------------------------------------------------------------*/
1470#define SUNI1x10GEXP_BITMSK_XTEF_LOST_SYNCV 0x0001
1471
1472/*----------------------------------------------------------------------------
1473 * Register 0x30C0: TXOAM OAM Configuration
1474 * Bit 15 TXOAM_HEC_EN
1475 * Bit 14 TXOAM_EMPTYCODE_EN
1476 * Bit 13 TXOAM_FORCE_IDLE
1477 * Bit 12 TXOAM_IGNORE_IDLE
1478 * Bit 11-6 TXOAM_PX_OVERWRITE
1479 * Bit 5-0 TXOAM_PX_SEL
1480 *----------------------------------------------------------------------------*/
1481#define SUNI1x10GEXP_BITMSK_TXOAM_HEC_EN 0x8000
1482#define SUNI1x10GEXP_BITMSK_TXOAM_EMPTYCODE_EN 0x4000
1483#define SUNI1x10GEXP_BITMSK_TXOAM_FORCE_IDLE 0x2000
1484#define SUNI1x10GEXP_BITMSK_TXOAM_IGNORE_IDLE 0x1000
1485#define SUNI1x10GEXP_BITMSK_TXOAM_PX_OVERWRITE 0x0FC0
1486#define SUNI1x10GEXP_BITOFF_TXOAM_PX_OVERWRITE 6
1487#define SUNI1x10GEXP_BITMSK_TXOAM_PX_SEL 0x003F
1488#define SUNI1x10GEXP_BITOFF_TXOAM_PX_SEL 0
1489
1490/*----------------------------------------------------------------------------
1491 * Register 0x30C1: TXOAM Mini-Packet Rate Configuration
1492 * Bit 15 TXOAM_MINIDIS
1493 * Bit 14 TXOAM_BUSY
1494 * Bit 13 TXOAM_TRANS_EN
1495 * Bit 10-0 TXOAM_MINIRATE
1496 *----------------------------------------------------------------------------*/
1497#define SUNI1x10GEXP_BITMSK_TXOAM_MINIDIS 0x8000
1498#define SUNI1x10GEXP_BITMSK_TXOAM_BUSY 0x4000
1499#define SUNI1x10GEXP_BITMSK_TXOAM_TRANS_EN 0x2000
1500#define SUNI1x10GEXP_BITMSK_TXOAM_MINIRATE 0x07FF
1501
1502/*----------------------------------------------------------------------------
1503 * Register 0x30C2: TXOAM Mini-Packet Gap and FIFO Configuration
1504 * Bit 13-10 TXOAM_FTHRESH
1505 * Bit 9-6 TXOAM_MINIPOST
1506 * Bit 5-0 TXOAM_MINIPRE
1507 *----------------------------------------------------------------------------*/
1508#define SUNI1x10GEXP_BITMSK_TXOAM_FTHRESH 0x3C00
1509#define SUNI1x10GEXP_BITOFF_TXOAM_FTHRESH 10
1510#define SUNI1x10GEXP_BITMSK_TXOAM_MINIPOST 0x03C0
1511#define SUNI1x10GEXP_BITOFF_TXOAM_MINIPOST 6
1512#define SUNI1x10GEXP_BITMSK_TXOAM_MINIPRE 0x003F
1513
1514/*----------------------------------------------------------------------------
1515 * Register 0x30C6: TXOAM Interrupt Enable
1516 * Bit 2 TXOAM_SOP_ERRE
1517 * Bit 1 TXOAM_OFLE
1518 * Bit 0 TXOAM_ERRE
1519 *----------------------------------------------------------------------------*/
1520#define SUNI1x10GEXP_BITMSK_TXOAM_SOP_ERRE 0x0004
1521#define SUNI1x10GEXP_BITMSK_TXOAM_OFLE 0x0002
1522#define SUNI1x10GEXP_BITMSK_TXOAM_ERRE 0x0001
1523
1524/*----------------------------------------------------------------------------
1525 * Register 0x30C7: TXOAM Interrupt Status
1526 * Bit 2 TXOAM_SOP_ERRI
1527 * Bit 1 TXOAM_OFLI
1528 * Bit 0 TXOAM_ERRI
1529 *----------------------------------------------------------------------------*/
1530#define SUNI1x10GEXP_BITMSK_TXOAM_SOP_ERRI 0x0004
1531#define SUNI1x10GEXP_BITMSK_TXOAM_OFLI 0x0002
1532#define SUNI1x10GEXP_BITMSK_TXOAM_ERRI 0x0001
1533
1534/*----------------------------------------------------------------------------
1535 * Register 0x30CF: TXOAM Coset
1536 * Bit 7-0 TXOAM_COSET
1537 *----------------------------------------------------------------------------*/
1538#define SUNI1x10GEXP_BITMSK_TXOAM_COSET 0x00FF
1539
1540/*----------------------------------------------------------------------------
1541 * Register 0x3200: EFLX Global Configuration
1542 * Bit 15 EFLX_ERCU_EN
1543 * Bit 7 EFLX_EN_EDSWT
1544 *----------------------------------------------------------------------------*/
1545#define SUNI1x10GEXP_BITMSK_EFLX_ERCU_EN 0x8000
1546#define SUNI1x10GEXP_BITMSK_EFLX_EN_EDSWT 0x0080
1547
1548/*----------------------------------------------------------------------------
1549 * Register 0x3201: EFLX ERCU Global Status
1550 * Bit 13 EFLX_OVF_ERR
1551 *----------------------------------------------------------------------------*/
1552#define SUNI1x10GEXP_BITMSK_EFLX_OVF_ERR 0x2000
1553
1554/*----------------------------------------------------------------------------
1555 * Register 0x3202: EFLX Indirect Channel Address
1556 * Bit 15 EFLX_BUSY
1557 * Bit 14 EFLX_RDWRB
1558 *----------------------------------------------------------------------------*/
1559#define SUNI1x10GEXP_BITMSK_EFLX_BUSY 0x8000
1560#define SUNI1x10GEXP_BITMSK_EFLX_RDWRB 0x4000
1561
1562/*----------------------------------------------------------------------------
1563 * Register 0x3203: EFLX Indirect Logical FIFO Low Limit
1564 *----------------------------------------------------------------------------*/
1565#define SUNI1x10GEXP_BITMSK_EFLX_LOLIM 0x03FF
1566#define SUNI1x10GEXP_BITOFF_EFLX_LOLIM 0
1567
1568/*----------------------------------------------------------------------------
1569 * Register 0x3204: EFLX Indirect Logical FIFO High Limit
1570 *----------------------------------------------------------------------------*/
1571#define SUNI1x10GEXP_BITMSK_EFLX_HILIM 0x03FF
1572#define SUNI1x10GEXP_BITOFF_EFLX_HILIM 0
1573
1574/*----------------------------------------------------------------------------
1575 * Register 0x3205: EFLX Indirect Full/Almost-Full Status and Limit
1576 * Bit 15 EFLX_FULL
1577 * Bit 14 EFLX_AFULL
1578 * Bit 13-0 EFLX_AFTH
1579 *----------------------------------------------------------------------------*/
1580#define SUNI1x10GEXP_BITMSK_EFLX_FULL 0x8000
1581#define SUNI1x10GEXP_BITMSK_EFLX_AFULL 0x4000
1582#define SUNI1x10GEXP_BITMSK_EFLX_AFTH 0x3FFF
1583#define SUNI1x10GEXP_BITOFF_EFLX_AFTH 0
1584
1585/*----------------------------------------------------------------------------
1586 * Register 0x3206: EFLX Indirect Empty/Almost-Empty Status and Limit
1587 * Bit 15 EFLX_EMPTY
1588 * Bit 14 EFLX_AEMPTY
1589 * Bit 13-0 EFLX_AETH
1590 *----------------------------------------------------------------------------*/
1591#define SUNI1x10GEXP_BITMSK_EFLX_EMPTY 0x8000
1592#define SUNI1x10GEXP_BITMSK_EFLX_AEMPTY 0x4000
1593#define SUNI1x10GEXP_BITMSK_EFLX_AETH 0x3FFF
1594#define SUNI1x10GEXP_BITOFF_EFLX_AETH 0
1595
1596/*----------------------------------------------------------------------------
1597 * Register 0x3207: EFLX Indirect FIFO Cut-Through Threshold
1598 *----------------------------------------------------------------------------*/
1599#define SUNI1x10GEXP_BITMSK_EFLX_CUT_THRU 0x3FFF
1600#define SUNI1x10GEXP_BITOFF_EFLX_CUT_THRU 0
1601
1602/*----------------------------------------------------------------------------
1603 * Register 0x320C: EFLX FIFO Overflow Error Enable
1604 * Bit 0 EFLX_OVFE
1605 *----------------------------------------------------------------------------*/
1606#define SUNI1x10GEXP_BITMSK_EFLX_OVFE 0x0001
1607
1608/*----------------------------------------------------------------------------
1609 * Register 0x320D: EFLX FIFO Overflow Error Indication
1610 * Bit 0 EFLX_OVFI
1611 *----------------------------------------------------------------------------*/
1612#define SUNI1x10GEXP_BITMSK_EFLX_OVFI 0x0001
1613
1614/*----------------------------------------------------------------------------
1615 * Register 0x3210: EFLX Channel Provision
1616 * Bit 0 EFLX_PROV
1617 *----------------------------------------------------------------------------*/
1618#define SUNI1x10GEXP_BITMSK_EFLX_PROV 0x0001
1619
1620/*----------------------------------------------------------------------------
1621 * Register 0x3280: PL4IDU Configuration
1622 * Bit 2 PL4IDU_SYNCH_ON_TRAIN
1623 * Bit 1 PL4IDU_EN_PORTS
1624 * Bit 0 PL4IDU_EN_DFWD
1625 *----------------------------------------------------------------------------*/
1626#define SUNI1x10GEXP_BITMSK_PL4IDU_SYNCH_ON_TRAIN 0x0004
1627#define SUNI1x10GEXP_BITMSK_PL4IDU_EN_PORTS 0x0002
1628#define SUNI1x10GEXP_BITMSK_PL4IDU_EN_DFWD 0x0001
1629
1630/*----------------------------------------------------------------------------
1631 * Register 0x3282: PL4IDU Interrupt Mask
1632 * Bit 1 PL4IDU_DIP4E
1633 *----------------------------------------------------------------------------*/
1634#define SUNI1x10GEXP_BITMSK_PL4IDU_DIP4E 0x0002
1635
1636/*----------------------------------------------------------------------------
1637 * Register 0x3283: PL4IDU Interrupt
1638 * Bit 1 PL4IDU_DIP4I
1639 *----------------------------------------------------------------------------*/
1640#define SUNI1x10GEXP_BITMSK_PL4IDU_DIP4I 0x0002
211 1641
212#endif /* _CXGB_SUNI1x10GEXP_REGS_H_ */ 1642#endif /* _CXGB_SUNI1x10GEXP_REGS_H_ */
213 1643
diff --git a/drivers/net/chelsio/tp.c b/drivers/net/chelsio/tp.c
new file mode 100644
index 000000000000..0ca0b6e19e43
--- /dev/null
+++ b/drivers/net/chelsio/tp.c
@@ -0,0 +1,178 @@
1/* $Date: 2006/02/07 04:21:54 $ $RCSfile: tp.c,v $ $Revision: 1.73 $ */
2#include "common.h"
3#include "regs.h"
4#include "tp.h"
5#ifdef CONFIG_CHELSIO_T1_1G
6#include "fpga_defs.h"
7#endif
8
9struct petp {
10 adapter_t *adapter;
11};
12
13/* Pause deadlock avoidance parameters */
14#define DROP_MSEC 16
15#define DROP_PKTS_CNT 1
16
17static void tp_init(adapter_t * ap, const struct tp_params *p,
18 unsigned int tp_clk)
19{
20 if (t1_is_asic(ap)) {
21 u32 val;
22
23 val = F_TP_IN_CSPI_CPL | F_TP_IN_CSPI_CHECK_IP_CSUM |
24 F_TP_IN_CSPI_CHECK_TCP_CSUM | F_TP_IN_ESPI_ETHERNET;
25 if (!p->pm_size)
26 val |= F_OFFLOAD_DISABLE;
27 else
28 val |= F_TP_IN_ESPI_CHECK_IP_CSUM |
29 F_TP_IN_ESPI_CHECK_TCP_CSUM;
30 writel(val, ap->regs + A_TP_IN_CONFIG);
31 writel(F_TP_OUT_CSPI_CPL |
32 F_TP_OUT_ESPI_ETHERNET |
33 F_TP_OUT_ESPI_GENERATE_IP_CSUM |
34 F_TP_OUT_ESPI_GENERATE_TCP_CSUM,
35 ap->regs + A_TP_OUT_CONFIG);
36 writel(V_IP_TTL(64) |
37 F_PATH_MTU /* IP DF bit */ |
38 V_5TUPLE_LOOKUP(p->use_5tuple_mode) |
39 V_SYN_COOKIE_PARAMETER(29),
40 ap->regs + A_TP_GLOBAL_CONFIG);
41 /*
42 * Enable pause frame deadlock prevention.
43 */
44 if (is_T2(ap) && ap->params.nports > 1) {
45 u32 drop_ticks = DROP_MSEC * (tp_clk / 1000);
46
47 writel(F_ENABLE_TX_DROP | F_ENABLE_TX_ERROR |
48 V_DROP_TICKS_CNT(drop_ticks) |
49 V_NUM_PKTS_DROPPED(DROP_PKTS_CNT),
50 ap->regs + A_TP_TX_DROP_CONFIG);
51 }
52
53 }
54}
55
56void t1_tp_destroy(struct petp *tp)
57{
58 kfree(tp);
59}
60
61struct petp *__devinit t1_tp_create(adapter_t * adapter, struct tp_params *p)
62{
63 struct petp *tp = kzalloc(sizeof(*tp), GFP_KERNEL);
64 if (!tp)
65 return NULL;
66
67 tp->adapter = adapter;
68
69 return tp;
70}
71
72void t1_tp_intr_enable(struct petp *tp)
73{
74 u32 tp_intr = readl(tp->adapter->regs + A_PL_ENABLE);
75
76#ifdef CONFIG_CHELSIO_T1_1G
77 if (!t1_is_asic(tp->adapter)) {
78 /* FPGA */
79 writel(0xffffffff,
80 tp->adapter->regs + FPGA_TP_ADDR_INTERRUPT_ENABLE);
81 writel(tp_intr | FPGA_PCIX_INTERRUPT_TP,
82 tp->adapter->regs + A_PL_ENABLE);
83 } else
84#endif
85 {
86 /* We don't use any TP interrupts */
87 writel(0, tp->adapter->regs + A_TP_INT_ENABLE);
88 writel(tp_intr | F_PL_INTR_TP,
89 tp->adapter->regs + A_PL_ENABLE);
90 }
91}
92
93void t1_tp_intr_disable(struct petp *tp)
94{
95 u32 tp_intr = readl(tp->adapter->regs + A_PL_ENABLE);
96
97#ifdef CONFIG_CHELSIO_T1_1G
98 if (!t1_is_asic(tp->adapter)) {
99 /* FPGA */
100 writel(0, tp->adapter->regs + FPGA_TP_ADDR_INTERRUPT_ENABLE);
101 writel(tp_intr & ~FPGA_PCIX_INTERRUPT_TP,
102 tp->adapter->regs + A_PL_ENABLE);
103 } else
104#endif
105 {
106 writel(0, tp->adapter->regs + A_TP_INT_ENABLE);
107 writel(tp_intr & ~F_PL_INTR_TP,
108 tp->adapter->regs + A_PL_ENABLE);
109 }
110}
111
112void t1_tp_intr_clear(struct petp *tp)
113{
114#ifdef CONFIG_CHELSIO_T1_1G
115 if (!t1_is_asic(tp->adapter)) {
116 writel(0xffffffff,
117 tp->adapter->regs + FPGA_TP_ADDR_INTERRUPT_CAUSE);
118 writel(FPGA_PCIX_INTERRUPT_TP, tp->adapter->regs + A_PL_CAUSE);
119 return;
120 }
121#endif
122 writel(0xffffffff, tp->adapter->regs + A_TP_INT_CAUSE);
123 writel(F_PL_INTR_TP, tp->adapter->regs + A_PL_CAUSE);
124}
125
126int t1_tp_intr_handler(struct petp *tp)
127{
128 u32 cause;
129
130#ifdef CONFIG_CHELSIO_T1_1G
131 /* FPGA doesn't support TP interrupts. */
132 if (!t1_is_asic(tp->adapter))
133 return 1;
134#endif
135
136 cause = readl(tp->adapter->regs + A_TP_INT_CAUSE);
137 writel(cause, tp->adapter->regs + A_TP_INT_CAUSE);
138 return 0;
139}
140
141static void set_csum_offload(struct petp *tp, u32 csum_bit, int enable)
142{
143 u32 val = readl(tp->adapter->regs + A_TP_GLOBAL_CONFIG);
144
145 if (enable)
146 val |= csum_bit;
147 else
148 val &= ~csum_bit;
149 writel(val, tp->adapter->regs + A_TP_GLOBAL_CONFIG);
150}
151
152void t1_tp_set_ip_checksum_offload(struct petp *tp, int enable)
153{
154 set_csum_offload(tp, F_IP_CSUM, enable);
155}
156
157void t1_tp_set_udp_checksum_offload(struct petp *tp, int enable)
158{
159 set_csum_offload(tp, F_UDP_CSUM, enable);
160}
161
162void t1_tp_set_tcp_checksum_offload(struct petp *tp, int enable)
163{
164 set_csum_offload(tp, F_TCP_CSUM, enable);
165}
166
167/*
168 * Initialize TP state. tp_params contains initial settings for some TP
169 * parameters, particularly the one-time PM and CM settings.
170 */
171int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk)
172{
173 adapter_t *adapter = tp->adapter;
174
175 tp_init(adapter, p, tp_clk);
176 writel(F_TP_RESET, adapter->regs + A_TP_RESET);
177 return 0;
178}
diff --git a/drivers/net/chelsio/tp.h b/drivers/net/chelsio/tp.h
new file mode 100644
index 000000000000..32fc71e58913
--- /dev/null
+++ b/drivers/net/chelsio/tp.h
@@ -0,0 +1,73 @@
1/* $Date: 2005/03/07 23:59:05 $ $RCSfile: tp.h,v $ $Revision: 1.20 $ */
2#ifndef CHELSIO_TP_H
3#define CHELSIO_TP_H
4
5#include "common.h"
6
7#define TP_MAX_RX_COALESCING_SIZE 16224U
8
9struct tp_mib_statistics {
10
11 /* IP */
12 u32 ipInReceive_hi;
13 u32 ipInReceive_lo;
14 u32 ipInHdrErrors_hi;
15 u32 ipInHdrErrors_lo;
16 u32 ipInAddrErrors_hi;
17 u32 ipInAddrErrors_lo;
18 u32 ipInUnknownProtos_hi;
19 u32 ipInUnknownProtos_lo;
20 u32 ipInDiscards_hi;
21 u32 ipInDiscards_lo;
22 u32 ipInDelivers_hi;
23 u32 ipInDelivers_lo;
24 u32 ipOutRequests_hi;
25 u32 ipOutRequests_lo;
26 u32 ipOutDiscards_hi;
27 u32 ipOutDiscards_lo;
28 u32 ipOutNoRoutes_hi;
29 u32 ipOutNoRoutes_lo;
30 u32 ipReasmTimeout;
31 u32 ipReasmReqds;
32 u32 ipReasmOKs;
33 u32 ipReasmFails;
34
35 u32 reserved[8];
36
37 /* TCP */
38 u32 tcpActiveOpens;
39 u32 tcpPassiveOpens;
40 u32 tcpAttemptFails;
41 u32 tcpEstabResets;
42 u32 tcpOutRsts;
43 u32 tcpCurrEstab;
44 u32 tcpInSegs_hi;
45 u32 tcpInSegs_lo;
46 u32 tcpOutSegs_hi;
47 u32 tcpOutSegs_lo;
48 u32 tcpRetransSeg_hi;
49 u32 tcpRetransSeg_lo;
50 u32 tcpInErrs_hi;
51 u32 tcpInErrs_lo;
52 u32 tcpRtoMin;
53 u32 tcpRtoMax;
54};
55
56struct petp;
57struct tp_params;
58
59struct petp *t1_tp_create(adapter_t *adapter, struct tp_params *p);
60void t1_tp_destroy(struct petp *tp);
61
62void t1_tp_intr_disable(struct petp *tp);
63void t1_tp_intr_enable(struct petp *tp);
64void t1_tp_intr_clear(struct petp *tp);
65int t1_tp_intr_handler(struct petp *tp);
66
67void t1_tp_get_mib_statistics(adapter_t *adap, struct tp_mib_statistics *tps);
68void t1_tp_set_udp_checksum_offload(struct petp *tp, int enable);
69void t1_tp_set_tcp_checksum_offload(struct petp *tp, int enable);
70void t1_tp_set_ip_checksum_offload(struct petp *tp, int enable);
71int t1_tp_set_coalescing_size(struct petp *tp, unsigned int size);
72int t1_tp_reset(struct petp *tp, struct tp_params *p, unsigned int tp_clk);
73#endif
diff --git a/drivers/net/chelsio/vsc7326.c b/drivers/net/chelsio/vsc7326.c
new file mode 100644
index 000000000000..85dc3b1dc309
--- /dev/null
+++ b/drivers/net/chelsio/vsc7326.c
@@ -0,0 +1,725 @@
1/* $Date: 2006/04/28 19:20:06 $ $RCSfile: vsc7326.c,v $ $Revision: 1.19 $ */
2
3/* Driver for Vitesse VSC7326 (Schaumburg) MAC */
4
5#include "gmac.h"
6#include "elmer0.h"
7#include "vsc7326_reg.h"
8
9/* Update fast changing statistics every 15 seconds */
10#define STATS_TICK_SECS 15
11/* 30 minutes for full statistics update */
12#define MAJOR_UPDATE_TICKS (1800 / STATS_TICK_SECS)
13
14#define MAX_MTU 9600
15
16/* The egress WM value 0x01a01fff should be used only when the
17 * interface is down (MAC port disabled). This is a workaround
18 * for disabling the T2/MAC flow-control. When the interface is
19 * enabled, the WM value should be set to 0x014a03F0.
20 */
21#define WM_DISABLE 0x01a01fff
22#define WM_ENABLE 0x014a03F0
23
24struct init_table {
25 u32 addr;
26 u32 data;
27};
28
29struct _cmac_instance {
30 u32 index;
31 u32 ticks;
32};
33
34#define INITBLOCK_SLEEP 0xffffffff
35
36static void vsc_read(adapter_t *adapter, u32 addr, u32 *val)
37{
38 u32 status, vlo, vhi;
39 int i;
40
41 spin_lock_bh(&adapter->mac_lock);
42 t1_tpi_read(adapter, (addr << 2) + 4, &vlo);
43 i = 0;
44 do {
45 t1_tpi_read(adapter, (REG_LOCAL_STATUS << 2) + 4, &vlo);
46 t1_tpi_read(adapter, REG_LOCAL_STATUS << 2, &vhi);
47 status = (vhi << 16) | vlo;
48 i++;
49 } while (((status & 1) == 0) && (i < 50));
50 if (i == 50)
51 CH_ERR("Invalid tpi read from MAC, breaking loop.\n");
52
53 t1_tpi_read(adapter, (REG_LOCAL_DATA << 2) + 4, &vlo);
54 t1_tpi_read(adapter, REG_LOCAL_DATA << 2, &vhi);
55
56 *val = (vhi << 16) | vlo;
57
58 /* CH_ERR("rd: block: 0x%x sublock: 0x%x reg: 0x%x data: 0x%x\n",
59 ((addr&0xe000)>>13), ((addr&0x1e00)>>9),
60 ((addr&0x01fe)>>1), *val); */
61 spin_unlock_bh(&adapter->mac_lock);
62}
63
64static void vsc_write(adapter_t *adapter, u32 addr, u32 data)
65{
66 spin_lock_bh(&adapter->mac_lock);
67 t1_tpi_write(adapter, (addr << 2) + 4, data & 0xFFFF);
68 t1_tpi_write(adapter, addr << 2, (data >> 16) & 0xFFFF);
69 /* CH_ERR("wr: block: 0x%x sublock: 0x%x reg: 0x%x data: 0x%x\n",
70 ((addr&0xe000)>>13), ((addr&0x1e00)>>9),
71 ((addr&0x01fe)>>1), data); */
72 spin_unlock_bh(&adapter->mac_lock);
73}
74
75/* Hard reset the MAC. This wipes out *all* configuration. */
76static void vsc7326_full_reset(adapter_t* adapter)
77{
78 u32 val;
79 u32 result = 0xffff;
80
81 t1_tpi_read(adapter, A_ELMER0_GPO, &val);
82 val &= ~1;
83 t1_tpi_write(adapter, A_ELMER0_GPO, val);
84 udelay(2);
85 val |= 0x1; /* Enable mac MAC itself */
86 val |= 0x800; /* Turn off the red LED */
87 t1_tpi_write(adapter, A_ELMER0_GPO, val);
88 mdelay(1);
89 vsc_write(adapter, REG_SW_RESET, 0x80000001);
90 do {
91 mdelay(1);
92 vsc_read(adapter, REG_SW_RESET, &result);
93 } while (result != 0x0);
94}
95
96static struct init_table vsc7326_reset[] = {
97 { REG_IFACE_MODE, 0x00000000 },
98 { REG_CRC_CFG, 0x00000020 },
99 { REG_PLL_CLK_SPEED, 0x00050c00 },
100 { REG_PLL_CLK_SPEED, 0x00050c00 },
101 { REG_MSCH, 0x00002f14 },
102 { REG_SPI4_MISC, 0x00040409 },
103 { REG_SPI4_DESKEW, 0x00080000 },
104 { REG_SPI4_ING_SETUP2, 0x08080004 },
105 { REG_SPI4_ING_SETUP0, 0x04111004 },
106 { REG_SPI4_EGR_SETUP0, 0x80001a04 },
107 { REG_SPI4_ING_SETUP1, 0x02010000 },
108 { REG_AGE_INC(0), 0x00000000 },
109 { REG_AGE_INC(1), 0x00000000 },
110 { REG_ING_CONTROL, 0x0a200011 },
111 { REG_EGR_CONTROL, 0xa0010091 },
112};
113
114static struct init_table vsc7326_portinit[4][22] = {
115 { /* Port 0 */
116 /* FIFO setup */
117 { REG_DBG(0), 0x000004f0 },
118 { REG_HDX(0), 0x00073101 },
119 { REG_TEST(0,0), 0x00000022 },
120 { REG_TEST(1,0), 0x00000022 },
121 { REG_TOP_BOTTOM(0,0), 0x003f0000 },
122 { REG_TOP_BOTTOM(1,0), 0x00120000 },
123 { REG_HIGH_LOW_WM(0,0), 0x07460757 },
124 { REG_HIGH_LOW_WM(1,0), WM_DISABLE },
125 { REG_CT_THRHLD(0,0), 0x00000000 },
126 { REG_CT_THRHLD(1,0), 0x00000000 },
127 { REG_BUCKE(0), 0x0002ffff },
128 { REG_BUCKI(0), 0x0002ffff },
129 { REG_TEST(0,0), 0x00000020 },
130 { REG_TEST(1,0), 0x00000020 },
131 /* Port config */
132 { REG_MAX_LEN(0), 0x00002710 },
133 { REG_PORT_FAIL(0), 0x00000002 },
134 { REG_NORMALIZER(0), 0x00000a64 },
135 { REG_DENORM(0), 0x00000010 },
136 { REG_STICK_BIT(0), 0x03baa370 },
137 { REG_DEV_SETUP(0), 0x00000083 },
138 { REG_DEV_SETUP(0), 0x00000082 },
139 { REG_MODE_CFG(0), 0x0200259f },
140 },
141 { /* Port 1 */
142 /* FIFO setup */
143 { REG_DBG(1), 0x000004f0 },
144 { REG_HDX(1), 0x00073101 },
145 { REG_TEST(0,1), 0x00000022 },
146 { REG_TEST(1,1), 0x00000022 },
147 { REG_TOP_BOTTOM(0,1), 0x007e003f },
148 { REG_TOP_BOTTOM(1,1), 0x00240012 },
149 { REG_HIGH_LOW_WM(0,1), 0x07460757 },
150 { REG_HIGH_LOW_WM(1,1), WM_DISABLE },
151 { REG_CT_THRHLD(0,1), 0x00000000 },
152 { REG_CT_THRHLD(1,1), 0x00000000 },
153 { REG_BUCKE(1), 0x0002ffff },
154 { REG_BUCKI(1), 0x0002ffff },
155 { REG_TEST(0,1), 0x00000020 },
156 { REG_TEST(1,1), 0x00000020 },
157 /* Port config */
158 { REG_MAX_LEN(1), 0x00002710 },
159 { REG_PORT_FAIL(1), 0x00000002 },
160 { REG_NORMALIZER(1), 0x00000a64 },
161 { REG_DENORM(1), 0x00000010 },
162 { REG_STICK_BIT(1), 0x03baa370 },
163 { REG_DEV_SETUP(1), 0x00000083 },
164 { REG_DEV_SETUP(1), 0x00000082 },
165 { REG_MODE_CFG(1), 0x0200259f },
166 },
167 { /* Port 2 */
168 /* FIFO setup */
169 { REG_DBG(2), 0x000004f0 },
170 { REG_HDX(2), 0x00073101 },
171 { REG_TEST(0,2), 0x00000022 },
172 { REG_TEST(1,2), 0x00000022 },
173 { REG_TOP_BOTTOM(0,2), 0x00bd007e },
174 { REG_TOP_BOTTOM(1,2), 0x00360024 },
175 { REG_HIGH_LOW_WM(0,2), 0x07460757 },
176 { REG_HIGH_LOW_WM(1,2), WM_DISABLE },
177 { REG_CT_THRHLD(0,2), 0x00000000 },
178 { REG_CT_THRHLD(1,2), 0x00000000 },
179 { REG_BUCKE(2), 0x0002ffff },
180 { REG_BUCKI(2), 0x0002ffff },
181 { REG_TEST(0,2), 0x00000020 },
182 { REG_TEST(1,2), 0x00000020 },
183 /* Port config */
184 { REG_MAX_LEN(2), 0x00002710 },
185 { REG_PORT_FAIL(2), 0x00000002 },
186 { REG_NORMALIZER(2), 0x00000a64 },
187 { REG_DENORM(2), 0x00000010 },
188 { REG_STICK_BIT(2), 0x03baa370 },
189 { REG_DEV_SETUP(2), 0x00000083 },
190 { REG_DEV_SETUP(2), 0x00000082 },
191 { REG_MODE_CFG(2), 0x0200259f },
192 },
193 { /* Port 3 */
194 /* FIFO setup */
195 { REG_DBG(3), 0x000004f0 },
196 { REG_HDX(3), 0x00073101 },
197 { REG_TEST(0,3), 0x00000022 },
198 { REG_TEST(1,3), 0x00000022 },
199 { REG_TOP_BOTTOM(0,3), 0x00fc00bd },
200 { REG_TOP_BOTTOM(1,3), 0x00480036 },
201 { REG_HIGH_LOW_WM(0,3), 0x07460757 },
202 { REG_HIGH_LOW_WM(1,3), WM_DISABLE },
203 { REG_CT_THRHLD(0,3), 0x00000000 },
204 { REG_CT_THRHLD(1,3), 0x00000000 },
205 { REG_BUCKE(3), 0x0002ffff },
206 { REG_BUCKI(3), 0x0002ffff },
207 { REG_TEST(0,3), 0x00000020 },
208 { REG_TEST(1,3), 0x00000020 },
209 /* Port config */
210 { REG_MAX_LEN(3), 0x00002710 },
211 { REG_PORT_FAIL(3), 0x00000002 },
212 { REG_NORMALIZER(3), 0x00000a64 },
213 { REG_DENORM(3), 0x00000010 },
214 { REG_STICK_BIT(3), 0x03baa370 },
215 { REG_DEV_SETUP(3), 0x00000083 },
216 { REG_DEV_SETUP(3), 0x00000082 },
217 { REG_MODE_CFG(3), 0x0200259f },
218 },
219};
220
221static void run_table(adapter_t *adapter, struct init_table *ib, int len)
222{
223 int i;
224
225 for (i = 0; i < len; i++) {
226 if (ib[i].addr == INITBLOCK_SLEEP) {
227 udelay( ib[i].data );
228 CH_ERR("sleep %d us\n",ib[i].data);
229 } else {
230 vsc_write( adapter, ib[i].addr, ib[i].data );
231 }
232 }
233}
234
235static int bist_rd(adapter_t *adapter, int moduleid, int address)
236{
237 int data=0;
238 u32 result=0;
239
240 if( (address != 0x0) &&
241 (address != 0x1) &&
242 (address != 0x2) &&
243 (address != 0xd) &&
244 (address != 0xe))
245 CH_ERR("No bist address: 0x%x\n", address);
246
247 data = ((0x00 << 24) | ((address & 0xff) << 16) | (0x00 << 8) |
248 ((moduleid & 0xff) << 0));
249 vsc_write(adapter, REG_RAM_BIST_CMD, data);
250
251 udelay(10);
252
253 vsc_read(adapter, REG_RAM_BIST_RESULT, &result);
254 if((result & (1<<9)) != 0x0)
255 CH_ERR("Still in bist read: 0x%x\n", result);
256 else if((result & (1<<8)) != 0x0)
257 CH_ERR("bist read error: 0x%x\n", result);
258
259 return(result & 0xff);
260}
261
262static int bist_wr(adapter_t *adapter, int moduleid, int address, int value)
263{
264 int data=0;
265 u32 result=0;
266
267 if( (address != 0x0) &&
268 (address != 0x1) &&
269 (address != 0x2) &&
270 (address != 0xd) &&
271 (address != 0xe))
272 CH_ERR("No bist address: 0x%x\n", address);
273
274 if( value>255 )
275 CH_ERR("Suspicious write out of range value: 0x%x\n", value);
276
277 data = ((0x01 << 24) | ((address & 0xff) << 16) | (value << 8) |
278 ((moduleid & 0xff) << 0));
279 vsc_write(adapter, REG_RAM_BIST_CMD, data);
280
281 udelay(5);
282
283 vsc_read(adapter, REG_RAM_BIST_CMD, &result);
284 if((result & (1<<27)) != 0x0)
285 CH_ERR("Still in bist write: 0x%x\n", result);
286 else if((result & (1<<26)) != 0x0)
287 CH_ERR("bist write error: 0x%x\n", result);
288
289 return(0);
290}
291
292static int run_bist(adapter_t *adapter, int moduleid)
293{
294 /*run bist*/
295 (void) bist_wr(adapter,moduleid, 0x00, 0x02);
296 (void) bist_wr(adapter,moduleid, 0x01, 0x01);
297
298 return(0);
299}
300
301static int check_bist(adapter_t *adapter, int moduleid)
302{
303 int result=0;
304 int column=0;
305 /*check bist*/
306 result = bist_rd(adapter,moduleid, 0x02);
307 column = ((bist_rd(adapter,moduleid, 0x0e)<<8) +
308 (bist_rd(adapter,moduleid, 0x0d)));
309 if ((result & 3) != 0x3)
310 CH_ERR("Result: 0x%x BIST error in ram %d, column: 0x%04x\n",
311 result, moduleid, column);
312 return(0);
313}
314
315static int enable_mem(adapter_t *adapter, int moduleid)
316{
317 /*enable mem*/
318 (void) bist_wr(adapter,moduleid, 0x00, 0x00);
319 return(0);
320}
321
322static int run_bist_all(adapter_t *adapter)
323{
324 int port=0;
325 u32 val=0;
326
327 vsc_write(adapter, REG_MEM_BIST, 0x5);
328 vsc_read(adapter, REG_MEM_BIST, &val);
329
330 for(port=0; port<12; port++){
331 vsc_write(adapter, REG_DEV_SETUP(port), 0x0);
332 }
333
334 udelay(300);
335 vsc_write(adapter, REG_SPI4_MISC, 0x00040409);
336 udelay(300);
337
338 (void) run_bist(adapter,13);
339 (void) run_bist(adapter,14);
340 (void) run_bist(adapter,20);
341 (void) run_bist(adapter,21);
342 mdelay(200);
343 (void) check_bist(adapter,13);
344 (void) check_bist(adapter,14);
345 (void) check_bist(adapter,20);
346 (void) check_bist(adapter,21);
347 udelay(100);
348 (void) enable_mem(adapter,13);
349 (void) enable_mem(adapter,14);
350 (void) enable_mem(adapter,20);
351 (void) enable_mem(adapter,21);
352 udelay(300);
353 vsc_write(adapter, REG_SPI4_MISC, 0x60040400);
354 udelay(300);
355 for(port=0; port<12; port++){
356 vsc_write(adapter, REG_DEV_SETUP(port), 0x1);
357 }
358 udelay(300);
359 vsc_write(adapter, REG_MEM_BIST, 0x0);
360 mdelay(10);
361 return(0);
362}
363
364static int mac_intr_handler(struct cmac *mac)
365{
366 return 0;
367}
368
369static int mac_intr_enable(struct cmac *mac)
370{
371 return 0;
372}
373
374static int mac_intr_disable(struct cmac *mac)
375{
376 return 0;
377}
378
379static int mac_intr_clear(struct cmac *mac)
380{
381 return 0;
382}
383
384/* Expect MAC address to be in network byte order. */
385static int mac_set_address(struct cmac* mac, u8 addr[6])
386{
387 u32 val;
388 int port = mac->instance->index;
389
390 vsc_write(mac->adapter, REG_MAC_LOW_ADDR(port),
391 (addr[3] << 16) | (addr[4] << 8) | addr[5]);
392 vsc_write(mac->adapter, REG_MAC_HIGH_ADDR(port),
393 (addr[0] << 16) | (addr[1] << 8) | addr[2]);
394
395 vsc_read(mac->adapter, REG_ING_FFILT_UM_EN, &val);
396 val &= ~0xf0000000;
397 vsc_write(mac->adapter, REG_ING_FFILT_UM_EN, val | (port << 28));
398
399 vsc_write(mac->adapter, REG_ING_FFILT_MASK0,
400 0xffff0000 | (addr[4] << 8) | addr[5]);
401 vsc_write(mac->adapter, REG_ING_FFILT_MASK1,
402 0xffff0000 | (addr[2] << 8) | addr[3]);
403 vsc_write(mac->adapter, REG_ING_FFILT_MASK2,
404 0xffff0000 | (addr[0] << 8) | addr[1]);
405 return 0;
406}
407
408static int mac_get_address(struct cmac *mac, u8 addr[6])
409{
410 u32 addr_lo, addr_hi;
411 int port = mac->instance->index;
412
413 vsc_read(mac->adapter, REG_MAC_LOW_ADDR(port), &addr_lo);
414 vsc_read(mac->adapter, REG_MAC_HIGH_ADDR(port), &addr_hi);
415
416 addr[0] = (u8) (addr_hi >> 16);
417 addr[1] = (u8) (addr_hi >> 8);
418 addr[2] = (u8) addr_hi;
419 addr[3] = (u8) (addr_lo >> 16);
420 addr[4] = (u8) (addr_lo >> 8);
421 addr[5] = (u8) addr_lo;
422 return 0;
423}
424
425/* This is intended to reset a port, not the whole MAC */
426static int mac_reset(struct cmac *mac)
427{
428 int index = mac->instance->index;
429
430 run_table(mac->adapter, vsc7326_portinit[index],
431 ARRAY_SIZE(vsc7326_portinit[index]));
432
433 return 0;
434}
435
436static int mac_set_rx_mode(struct cmac *mac, struct t1_rx_mode *rm)
437{
438 u32 v;
439 int port = mac->instance->index;
440
441 vsc_read(mac->adapter, REG_ING_FFILT_UM_EN, &v);
442 v |= 1 << 12;
443
444 if (t1_rx_mode_promisc(rm))
445 v &= ~(1 << (port + 16));
446 else
447 v |= 1 << (port + 16);
448
449 vsc_write(mac->adapter, REG_ING_FFILT_UM_EN, v);
450 return 0;
451}
452
453static int mac_set_mtu(struct cmac *mac, int mtu)
454{
455 int port = mac->instance->index;
456
457 if (mtu > MAX_MTU)
458 return -EINVAL;
459
460 /* max_len includes header and FCS */
461 vsc_write(mac->adapter, REG_MAX_LEN(port), mtu + 14 + 4);
462 return 0;
463}
464
465static int mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex,
466 int fc)
467{
468 u32 v;
469 int enable, port = mac->instance->index;
470
471 if (speed >= 0 && speed != SPEED_10 && speed != SPEED_100 &&
472 speed != SPEED_1000)
473 return -1;
474 if (duplex > 0 && duplex != DUPLEX_FULL)
475 return -1;
476
477 if (speed >= 0) {
478 vsc_read(mac->adapter, REG_MODE_CFG(port), &v);
479 enable = v & 3; /* save tx/rx enables */
480 v &= ~0xf;
481 v |= 4; /* full duplex */
482 if (speed == SPEED_1000)
483 v |= 8; /* GigE */
484 enable |= v;
485 vsc_write(mac->adapter, REG_MODE_CFG(port), v);
486
487 if (speed == SPEED_1000)
488 v = 0x82;
489 else if (speed == SPEED_100)
490 v = 0x84;
491 else /* SPEED_10 */
492 v = 0x86;
493 vsc_write(mac->adapter, REG_DEV_SETUP(port), v | 1); /* reset */
494 vsc_write(mac->adapter, REG_DEV_SETUP(port), v);
495 vsc_read(mac->adapter, REG_DBG(port), &v);
496 v &= ~0xff00;
497 if (speed == SPEED_1000)
498 v |= 0x400;
499 else if (speed == SPEED_100)
500 v |= 0x2000;
501 else /* SPEED_10 */
502 v |= 0xff00;
503 vsc_write(mac->adapter, REG_DBG(port), v);
504
505 vsc_write(mac->adapter, REG_TX_IFG(port),
506 speed == SPEED_1000 ? 5 : 0x11);
507 if (duplex == DUPLEX_HALF)
508 enable = 0x0; /* 100 or 10 */
509 else if (speed == SPEED_1000)
510 enable = 0xc;
511 else /* SPEED_100 or 10 */
512 enable = 0x4;
513 enable |= 0x9 << 10; /* IFG1 */
514 enable |= 0x6 << 6; /* IFG2 */
515 enable |= 0x1 << 4; /* VLAN */
516 enable |= 0x3; /* RX/TX EN */
517 vsc_write(mac->adapter, REG_MODE_CFG(port), enable);
518
519 }
520
521 vsc_read(mac->adapter, REG_PAUSE_CFG(port), &v);
522 v &= 0xfff0ffff;
523 v |= 0x20000; /* xon/xoff */
524 if (fc & PAUSE_RX)
525 v |= 0x40000;
526 if (fc & PAUSE_TX)
527 v |= 0x80000;
528 if (fc == (PAUSE_RX | PAUSE_TX))
529 v |= 0x10000;
530 vsc_write(mac->adapter, REG_PAUSE_CFG(port), v);
531 return 0;
532}
533
534static int mac_enable(struct cmac *mac, int which)
535{
536 u32 val;
537 int port = mac->instance->index;
538
539 /* Write the correct WM value when the port is enabled. */
540 vsc_write(mac->adapter, REG_HIGH_LOW_WM(1,port), WM_ENABLE);
541
542 vsc_read(mac->adapter, REG_MODE_CFG(port), &val);
543 if (which & MAC_DIRECTION_RX)
544 val |= 0x2;
545 if (which & MAC_DIRECTION_TX)
546 val |= 1;
547 vsc_write(mac->adapter, REG_MODE_CFG(port), val);
548 return 0;
549}
550
551static int mac_disable(struct cmac *mac, int which)
552{
553 u32 val;
554 int i, port = mac->instance->index;
555
556 /* Reset the port, this also writes the correct WM value */
557 mac_reset(mac);
558
559 vsc_read(mac->adapter, REG_MODE_CFG(port), &val);
560 if (which & MAC_DIRECTION_RX)
561 val &= ~0x2;
562 if (which & MAC_DIRECTION_TX)
563 val &= ~0x1;
564 vsc_write(mac->adapter, REG_MODE_CFG(port), val);
565 vsc_read(mac->adapter, REG_MODE_CFG(port), &val);
566
567 /* Clear stats */
568 for (i = 0; i <= 0x3a; ++i)
569 vsc_write(mac->adapter, CRA(4, port, i), 0);
570
571 /* Clear sofware counters */
572 memset(&mac->stats, 0, sizeof(struct cmac_statistics));
573
574 return 0;
575}
576
577static void rmon_update(struct cmac *mac, unsigned int addr, u64 *stat)
578{
579 u32 v, lo;
580
581 vsc_read(mac->adapter, addr, &v);
582 lo = *stat;
583 *stat = *stat - lo + v;
584
585 if (v == 0)
586 return;
587
588 if (v < lo)
589 *stat += (1ULL << 32);
590}
591
592static void port_stats_update(struct cmac *mac)
593{
594 int port = mac->instance->index;
595
596 /* Rx stats */
597 rmon_update(mac, REG_RX_OK_BYTES(port), &mac->stats.RxOctetsOK);
598 rmon_update(mac, REG_RX_BAD_BYTES(port), &mac->stats.RxOctetsBad);
599 rmon_update(mac, REG_RX_UNICAST(port), &mac->stats.RxUnicastFramesOK);
600 rmon_update(mac, REG_RX_MULTICAST(port),
601 &mac->stats.RxMulticastFramesOK);
602 rmon_update(mac, REG_RX_BROADCAST(port),
603 &mac->stats.RxBroadcastFramesOK);
604 rmon_update(mac, REG_CRC(port), &mac->stats.RxFCSErrors);
605 rmon_update(mac, REG_RX_ALIGNMENT(port), &mac->stats.RxAlignErrors);
606 rmon_update(mac, REG_RX_OVERSIZE(port),
607 &mac->stats.RxFrameTooLongErrors);
608 rmon_update(mac, REG_RX_PAUSE(port), &mac->stats.RxPauseFrames);
609 rmon_update(mac, REG_RX_JABBERS(port), &mac->stats.RxJabberErrors);
610 rmon_update(mac, REG_RX_FRAGMENTS(port), &mac->stats.RxRuntErrors);
611 rmon_update(mac, REG_RX_UNDERSIZE(port), &mac->stats.RxRuntErrors);
612 rmon_update(mac, REG_RX_SYMBOL_CARRIER(port),
613 &mac->stats.RxSymbolErrors);
614 rmon_update(mac, REG_RX_SIZE_1519_TO_MAX(port),
615 &mac->stats.RxJumboFramesOK);
616
617 /* Tx stats (skip collision stats as we are full-duplex only) */
618 rmon_update(mac, REG_TX_OK_BYTES(port), &mac->stats.TxOctetsOK);
619 rmon_update(mac, REG_TX_UNICAST(port), &mac->stats.TxUnicastFramesOK);
620 rmon_update(mac, REG_TX_MULTICAST(port),
621 &mac->stats.TxMulticastFramesOK);
622 rmon_update(mac, REG_TX_BROADCAST(port),
623 &mac->stats.TxBroadcastFramesOK);
624 rmon_update(mac, REG_TX_PAUSE(port), &mac->stats.TxPauseFrames);
625 rmon_update(mac, REG_TX_UNDERRUN(port), &mac->stats.TxUnderrun);
626 rmon_update(mac, REG_TX_SIZE_1519_TO_MAX(port),
627 &mac->stats.TxJumboFramesOK);
628}
629
630/*
631 * This function is called periodically to accumulate the current values of the
632 * RMON counters into the port statistics. Since the counters are only 32 bits
633 * some of them can overflow in less than a minute at GigE speeds, so this
634 * function should be called every 30 seconds or so.
635 *
636 * To cut down on reading costs we update only the octet counters at each tick
637 * and do a full update at major ticks, which can be every 30 minutes or more.
638 */
639static const struct cmac_statistics *mac_update_statistics(struct cmac *mac,
640 int flag)
641{
642 if (flag == MAC_STATS_UPDATE_FULL ||
643 mac->instance->ticks >= MAJOR_UPDATE_TICKS) {
644 port_stats_update(mac);
645 mac->instance->ticks = 0;
646 } else {
647 int port = mac->instance->index;
648
649 rmon_update(mac, REG_RX_OK_BYTES(port),
650 &mac->stats.RxOctetsOK);
651 rmon_update(mac, REG_RX_BAD_BYTES(port),
652 &mac->stats.RxOctetsBad);
653 rmon_update(mac, REG_TX_OK_BYTES(port),
654 &mac->stats.TxOctetsOK);
655 mac->instance->ticks++;
656 }
657 return &mac->stats;
658}
659
660static void mac_destroy(struct cmac *mac)
661{
662 kfree(mac);
663}
664
665static struct cmac_ops vsc7326_ops = {
666 .destroy = mac_destroy,
667 .reset = mac_reset,
668 .interrupt_handler = mac_intr_handler,
669 .interrupt_enable = mac_intr_enable,
670 .interrupt_disable = mac_intr_disable,
671 .interrupt_clear = mac_intr_clear,
672 .enable = mac_enable,
673 .disable = mac_disable,
674 .set_mtu = mac_set_mtu,
675 .set_rx_mode = mac_set_rx_mode,
676 .set_speed_duplex_fc = mac_set_speed_duplex_fc,
677 .statistics_update = mac_update_statistics,
678 .macaddress_get = mac_get_address,
679 .macaddress_set = mac_set_address,
680};
681
682static struct cmac *vsc7326_mac_create(adapter_t *adapter, int index)
683{
684 struct cmac *mac;
685 u32 val;
686 int i;
687
688 mac = kzalloc(sizeof(*mac) + sizeof(cmac_instance), GFP_KERNEL);
689 if (!mac) return NULL;
690
691 mac->ops = &vsc7326_ops;
692 mac->instance = (cmac_instance *)(mac + 1);
693 mac->adapter = adapter;
694
695 mac->instance->index = index;
696 mac->instance->ticks = 0;
697
698 i = 0;
699 do {
700 u32 vhi, vlo;
701
702 vhi = vlo = 0;
703 t1_tpi_read(adapter, (REG_LOCAL_STATUS << 2) + 4, &vlo);
704 udelay(1);
705 t1_tpi_read(adapter, REG_LOCAL_STATUS << 2, &vhi);
706 udelay(5);
707 val = (vhi << 16) | vlo;
708 } while ((++i < 10000) && (val == 0xffffffff));
709
710 return mac;
711}
712
713static int vsc7326_mac_reset(adapter_t *adapter)
714{
715 vsc7326_full_reset(adapter);
716 (void) run_bist_all(adapter);
717 run_table(adapter, vsc7326_reset, ARRAY_SIZE(vsc7326_reset));
718 return 0;
719}
720
721struct gmac t1_vsc7326_ops = {
722 .stats_update_period = STATS_TICK_SECS,
723 .create = vsc7326_mac_create,
724 .reset = vsc7326_mac_reset,
725};
diff --git a/drivers/net/chelsio/vsc7326_reg.h b/drivers/net/chelsio/vsc7326_reg.h
new file mode 100644
index 000000000000..491bcf75c4fb
--- /dev/null
+++ b/drivers/net/chelsio/vsc7326_reg.h
@@ -0,0 +1,286 @@
1/* $Date: 2006/04/28 19:20:17 $ $RCSfile: vsc7326_reg.h,v $ $Revision: 1.5 $ */
2#ifndef _VSC7321_REG_H_
3#define _VSC7321_REG_H_
4
5/* Register definitions for Vitesse VSC7321 (Meigs II) MAC
6 *
7 * Straight off the data sheet, VMDS-10038 Rev 2.0 and
8 * PD0011-01-14-Meigs-II 2002-12-12
9 */
10
11/* Just 'cause it's in here doesn't mean it's used. */
12
13#define CRA(blk,sub,adr) ((((blk) & 0x7) << 13) | (((sub) & 0xf) << 9) | (((adr) & 0xff) << 1))
14
15/* System and CPU comm's registers */
16#define REG_CHIP_ID CRA(0x7,0xf,0x00) /* Chip ID */
17#define REG_BLADE_ID CRA(0x7,0xf,0x01) /* Blade ID */
18#define REG_SW_RESET CRA(0x7,0xf,0x02) /* Global Soft Reset */
19#define REG_MEM_BIST CRA(0x7,0xf,0x04) /* mem */
20#define REG_IFACE_MODE CRA(0x7,0xf,0x07) /* Interface mode */
21#define REG_MSCH CRA(0x7,0x2,0x06) /* CRC error count */
22#define REG_CRC_CNT CRA(0x7,0x2,0x0a) /* CRC error count */
23#define REG_CRC_CFG CRA(0x7,0x2,0x0b) /* CRC config */
24#define REG_SI_TRANSFER_SEL CRA(0x7,0xf,0x18) /* SI Transfer Select */
25#define REG_PLL_CLK_SPEED CRA(0x7,0xf,0x19) /* Clock Speed Selection */
26#define REG_SYS_CLK_SELECT CRA(0x7,0xf,0x1c) /* System Clock Select */
27#define REG_GPIO_CTRL CRA(0x7,0xf,0x1d) /* GPIO Control */
28#define REG_GPIO_OUT CRA(0x7,0xf,0x1e) /* GPIO Out */
29#define REG_GPIO_IN CRA(0x7,0xf,0x1f) /* GPIO In */
30#define REG_CPU_TRANSFER_SEL CRA(0x7,0xf,0x20) /* CPU Transfer Select */
31#define REG_LOCAL_DATA CRA(0x7,0xf,0xfe) /* Local CPU Data Register */
32#define REG_LOCAL_STATUS CRA(0x7,0xf,0xff) /* Local CPU Status Register */
33
34/* Aggregator registers */
35#define REG_AGGR_SETUP CRA(0x7,0x1,0x00) /* Aggregator Setup */
36#define REG_PMAP_TABLE CRA(0x7,0x1,0x01) /* Port map table */
37#define REG_MPLS_BIT0 CRA(0x7,0x1,0x08) /* MPLS bit0 position */
38#define REG_MPLS_BIT1 CRA(0x7,0x1,0x09) /* MPLS bit1 position */
39#define REG_MPLS_BIT2 CRA(0x7,0x1,0x0a) /* MPLS bit2 position */
40#define REG_MPLS_BIT3 CRA(0x7,0x1,0x0b) /* MPLS bit3 position */
41#define REG_MPLS_BITMASK CRA(0x7,0x1,0x0c) /* MPLS bit mask */
42#define REG_PRE_BIT0POS CRA(0x7,0x1,0x10) /* Preamble bit0 position */
43#define REG_PRE_BIT1POS CRA(0x7,0x1,0x11) /* Preamble bit1 position */
44#define REG_PRE_BIT2POS CRA(0x7,0x1,0x12) /* Preamble bit2 position */
45#define REG_PRE_BIT3POS CRA(0x7,0x1,0x13) /* Preamble bit3 position */
46#define REG_PRE_ERR_CNT CRA(0x7,0x1,0x14) /* Preamble parity error count */
47
48/* BIST registers */
49/*#define REG_RAM_BIST_CMD CRA(0x7,0x2,0x00)*/ /* RAM BIST Command Register */
50/*#define REG_RAM_BIST_RESULT CRA(0x7,0x2,0x01)*/ /* RAM BIST Read Status/Result */
51#define REG_RAM_BIST_CMD CRA(0x7,0x1,0x00) /* RAM BIST Command Register */
52#define REG_RAM_BIST_RESULT CRA(0x7,0x1,0x01) /* RAM BIST Read Status/Result */
53#define BIST_PORT_SELECT 0x00 /* BIST port select */
54#define BIST_COMMAND 0x01 /* BIST enable/disable */
55#define BIST_STATUS 0x02 /* BIST operation status */
56#define BIST_ERR_CNT_LSB 0x03 /* BIST error count lo 8b */
57#define BIST_ERR_CNT_MSB 0x04 /* BIST error count hi 8b */
58#define BIST_ERR_SEL_LSB 0x05 /* BIST error select lo 8b */
59#define BIST_ERR_SEL_MSB 0x06 /* BIST error select hi 8b */
60#define BIST_ERROR_STATE 0x07 /* BIST engine internal state */
61#define BIST_ERR_ADR0 0x08 /* BIST error address lo 8b */
62#define BIST_ERR_ADR1 0x09 /* BIST error address lomid 8b */
63#define BIST_ERR_ADR2 0x0a /* BIST error address himid 8b */
64#define BIST_ERR_ADR3 0x0b /* BIST error address hi 8b */
65
66/* FIFO registers
67 * ie = 0 for ingress, 1 for egress
68 * fn = FIFO number, 0-9
69 */
70#define REG_TEST(ie,fn) CRA(0x2,ie&1,0x00+fn) /* Mode & Test Register */
71#define REG_TOP_BOTTOM(ie,fn) CRA(0x2,ie&1,0x10+fn) /* FIFO Buffer Top & Bottom */
72#define REG_TAIL(ie,fn) CRA(0x2,ie&1,0x20+fn) /* FIFO Write Pointer */
73#define REG_HEAD(ie,fn) CRA(0x2,ie&1,0x30+fn) /* FIFO Read Pointer */
74#define REG_HIGH_LOW_WM(ie,fn) CRA(0x2,ie&1,0x40+fn) /* Flow Control Water Marks */
75#define REG_CT_THRHLD(ie,fn) CRA(0x2,ie&1,0x50+fn) /* Cut Through Threshold */
76#define REG_FIFO_DROP_CNT(ie,fn) CRA(0x2,ie&1,0x60+fn) /* Drop & CRC Error Counter */
77#define REG_DEBUG_BUF_CNT(ie,fn) CRA(0x2,ie&1,0x70+fn) /* Input Side Debug Counter */
78#define REG_BUCKI(fn) CRA(0x2,2,0x20+fn) /* Input Side Debug Counter */
79#define REG_BUCKE(fn) CRA(0x2,3,0x20+fn) /* Input Side Debug Counter */
80
81/* Traffic shaper buckets
82 * ie = 0 for ingress, 1 for egress
83 * bn = bucket number 0-10 (yes, 11 buckets)
84 */
85/* OK, this one's kinda ugly. Some hardware designers are perverse. */
86#define REG_TRAFFIC_SHAPER_BUCKET(ie,bn) CRA(0x2,ie&1,0x0a + (bn>7) | ((bn&7)<<4))
87#define REG_TRAFFIC_SHAPER_CONTROL(ie) CRA(0x2,ie&1,0x3b)
88
89#define REG_SRAM_ADR(ie) CRA(0x2,ie&1,0x0e) /* FIFO SRAM address */
90#define REG_SRAM_WR_STRB(ie) CRA(0x2,ie&1,0x1e) /* FIFO SRAM write strobe */
91#define REG_SRAM_RD_STRB(ie) CRA(0x2,ie&1,0x2e) /* FIFO SRAM read strobe */
92#define REG_SRAM_DATA_0(ie) CRA(0x2,ie&1,0x3e) /* FIFO SRAM data lo 8b */
93#define REG_SRAM_DATA_1(ie) CRA(0x2,ie&1,0x4e) /* FIFO SRAM data lomid 8b */
94#define REG_SRAM_DATA_2(ie) CRA(0x2,ie&1,0x5e) /* FIFO SRAM data himid 8b */
95#define REG_SRAM_DATA_3(ie) CRA(0x2,ie&1,0x6e) /* FIFO SRAM data hi 8b */
96#define REG_SRAM_DATA_BLK_TYPE(ie) CRA(0x2,ie&1,0x7e) /* FIFO SRAM tag */
97/* REG_ING_CONTROL equals REG_CONTROL with ie = 0, likewise REG_EGR_CONTROL is ie = 1 */
98#define REG_CONTROL(ie) CRA(0x2,ie&1,0x0f) /* FIFO control */
99#define REG_ING_CONTROL CRA(0x2,0x0,0x0f) /* Ingress control (alias) */
100#define REG_EGR_CONTROL CRA(0x2,0x1,0x0f) /* Egress control (alias) */
101#define REG_AGE_TIMER(ie) CRA(0x2,ie&1,0x1f) /* Aging timer */
102#define REG_AGE_INC(ie) CRA(0x2,ie&1,0x2f) /* Aging increment */
103#define DEBUG_OUT(ie) CRA(0x2,ie&1,0x3f) /* Output debug counter control */
104#define DEBUG_CNT(ie) CRA(0x2,ie&1,0x4f) /* Output debug counter */
105
106/* SPI4 interface */
107#define REG_SPI4_MISC CRA(0x5,0x0,0x00) /* Misc Register */
108#define REG_SPI4_STATUS CRA(0x5,0x0,0x01) /* CML Status */
109#define REG_SPI4_ING_SETUP0 CRA(0x5,0x0,0x02) /* Ingress Status Channel Setup */
110#define REG_SPI4_ING_SETUP1 CRA(0x5,0x0,0x03) /* Ingress Data Training Setup */
111#define REG_SPI4_ING_SETUP2 CRA(0x5,0x0,0x04) /* Ingress Data Burst Size Setup */
112#define REG_SPI4_EGR_SETUP0 CRA(0x5,0x0,0x05) /* Egress Status Channel Setup */
113#define REG_SPI4_DBG_CNT(n) CRA(0x5,0x0,0x10+n) /* Debug counters 0-9 */
114#define REG_SPI4_DBG_SETUP CRA(0x5,0x0,0x1A) /* Debug counters setup */
115#define REG_SPI4_TEST CRA(0x5,0x0,0x20) /* Test Setup Register */
116#define REG_TPGEN_UP0 CRA(0x5,0x0,0x21) /* Test Pattern generator user pattern 0 */
117#define REG_TPGEN_UP1 CRA(0x5,0x0,0x22) /* Test Pattern generator user pattern 1 */
118#define REG_TPCHK_UP0 CRA(0x5,0x0,0x23) /* Test Pattern checker user pattern 0 */
119#define REG_TPCHK_UP1 CRA(0x5,0x0,0x24) /* Test Pattern checker user pattern 1 */
120#define REG_TPSAM_P0 CRA(0x5,0x0,0x25) /* Sampled pattern 0 */
121#define REG_TPSAM_P1 CRA(0x5,0x0,0x26) /* Sampled pattern 1 */
122#define REG_TPERR_CNT CRA(0x5,0x0,0x27) /* Pattern checker error counter */
123#define REG_SPI4_STICKY CRA(0x5,0x0,0x30) /* Sticky bits register */
124#define REG_SPI4_DBG_INH CRA(0x5,0x0,0x31) /* Core egress & ingress inhibit */
125#define REG_SPI4_DBG_STATUS CRA(0x5,0x0,0x32) /* Sampled ingress status */
126#define REG_SPI4_DBG_GRANT CRA(0x5,0x0,0x33) /* Ingress cranted credit value */
127
128#define REG_SPI4_DESKEW CRA(0x5,0x0,0x43) /* Ingress cranted credit value */
129
130/* 10GbE MAC Block Registers */
131/* Note that those registers that are exactly the same for 10GbE as for
132 * tri-speed are only defined with the version that needs a port number.
133 * Pass 0xa in those cases.
134 *
135 * Also note that despite the presence of a MAC address register, this part
136 * does no ingress MAC address filtering. That register is used only for
137 * pause frame detection and generation.
138 */
139/* 10GbE specific, and different from tri-speed */
140#define REG_MISC_10G CRA(0x1,0xa,0x00) /* Misc 10GbE setup */
141#define REG_PAUSE_10G CRA(0x1,0xa,0x01) /* Pause register */
142#define REG_NORMALIZER_10G CRA(0x1,0xa,0x05) /* 10G normalizer */
143#define REG_STICKY_RX CRA(0x1,0xa,0x06) /* RX debug register */
144#define REG_DENORM_10G CRA(0x1,0xa,0x07) /* Denormalizer */
145#define REG_STICKY_TX CRA(0x1,0xa,0x08) /* TX sticky bits */
146#define REG_MAX_RXHIGH CRA(0x1,0xa,0x0a) /* XGMII lane 0-3 debug */
147#define REG_MAX_RXLOW CRA(0x1,0xa,0x0b) /* XGMII lane 4-7 debug */
148#define REG_MAC_TX_STICKY CRA(0x1,0xa,0x0c) /* MAC Tx state sticky debug */
149#define REG_MAC_TX_RUNNING CRA(0x1,0xa,0x0d) /* MAC Tx state running debug */
150#define REG_TX_ABORT_AGE CRA(0x1,0xa,0x14) /* Aged Tx frames discarded */
151#define REG_TX_ABORT_SHORT CRA(0x1,0xa,0x15) /* Short Tx frames discarded */
152#define REG_TX_ABORT_TAXI CRA(0x1,0xa,0x16) /* Taxi error frames discarded */
153#define REG_TX_ABORT_UNDERRUN CRA(0x1,0xa,0x17) /* Tx Underrun abort counter */
154#define REG_TX_DENORM_DISCARD CRA(0x1,0xa,0x18) /* Tx denormalizer discards */
155#define REG_XAUI_STAT_A CRA(0x1,0xa,0x20) /* XAUI status A */
156#define REG_XAUI_STAT_B CRA(0x1,0xa,0x21) /* XAUI status B */
157#define REG_XAUI_STAT_C CRA(0x1,0xa,0x22) /* XAUI status C */
158#define REG_XAUI_CONF_A CRA(0x1,0xa,0x23) /* XAUI configuration A */
159#define REG_XAUI_CONF_B CRA(0x1,0xa,0x24) /* XAUI configuration B */
160#define REG_XAUI_CODE_GRP_CNT CRA(0x1,0xa,0x25) /* XAUI code group error count */
161#define REG_XAUI_CONF_TEST_A CRA(0x1,0xa,0x26) /* XAUI test register A */
162#define REG_PDERRCNT CRA(0x1,0xa,0x27) /* XAUI test register B */
163
164/* pn = port number 0-9 for tri-speed, 10 for 10GbE */
165/* Both tri-speed and 10GbE */
166#define REG_MAX_LEN(pn) CRA(0x1,pn,0x02) /* Max length */
167#define REG_MAC_HIGH_ADDR(pn) CRA(0x1,pn,0x03) /* Upper 24 bits of MAC addr */
168#define REG_MAC_LOW_ADDR(pn) CRA(0x1,pn,0x04) /* Lower 24 bits of MAC addr */
169
170/* tri-speed only
171 * pn = port number, 0-9
172 */
173#define REG_MODE_CFG(pn) CRA(0x1,pn,0x00) /* Mode configuration */
174#define REG_PAUSE_CFG(pn) CRA(0x1,pn,0x01) /* Pause configuration */
175#define REG_NORMALIZER(pn) CRA(0x1,pn,0x05) /* Normalizer */
176#define REG_TBI_STATUS(pn) CRA(0x1,pn,0x06) /* TBI status */
177#define REG_PCS_STATUS_DBG(pn) CRA(0x1,pn,0x07) /* PCS status debug */
178#define REG_PCS_CTRL(pn) CRA(0x1,pn,0x08) /* PCS control */
179#define REG_TBI_CONFIG(pn) CRA(0x1,pn,0x09) /* TBI configuration */
180#define REG_STICK_BIT(pn) CRA(0x1,pn,0x0a) /* Sticky bits */
181#define REG_DEV_SETUP(pn) CRA(0x1,pn,0x0b) /* MAC clock/reset setup */
182#define REG_DROP_CNT(pn) CRA(0x1,pn,0x0c) /* Drop counter */
183#define REG_PORT_POS(pn) CRA(0x1,pn,0x0d) /* Preamble port position */
184#define REG_PORT_FAIL(pn) CRA(0x1,pn,0x0e) /* Preamble port position */
185#define REG_SERDES_CONF(pn) CRA(0x1,pn,0x0f) /* SerDes configuration */
186#define REG_SERDES_TEST(pn) CRA(0x1,pn,0x10) /* SerDes test */
187#define REG_SERDES_STAT(pn) CRA(0x1,pn,0x11) /* SerDes status */
188#define REG_SERDES_COM_CNT(pn) CRA(0x1,pn,0x12) /* SerDes comma counter */
189#define REG_DENORM(pn) CRA(0x1,pn,0x15) /* Frame denormalization */
190#define REG_DBG(pn) CRA(0x1,pn,0x16) /* Device 1G debug */
191#define REG_TX_IFG(pn) CRA(0x1,pn,0x18) /* Tx IFG config */
192#define REG_HDX(pn) CRA(0x1,pn,0x19) /* Half-duplex config */
193
194/* Statistics */
195/* pn = port number, 0-a, a = 10GbE */
196#define REG_RX_IN_BYTES(pn) CRA(0x4,pn,0x00) /* # Rx in octets */
197#define REG_RX_SYMBOL_CARRIER(pn) CRA(0x4,pn,0x01) /* Frames w/ symbol errors */
198#define REG_RX_PAUSE(pn) CRA(0x4,pn,0x02) /* # pause frames received */
199#define REG_RX_UNSUP_OPCODE(pn) CRA(0x4,pn,0x03) /* # control frames with unsupported opcode */
200#define REG_RX_OK_BYTES(pn) CRA(0x4,pn,0x04) /* # octets in good frames */
201#define REG_RX_BAD_BYTES(pn) CRA(0x4,pn,0x05) /* # octets in bad frames */
202#define REG_RX_UNICAST(pn) CRA(0x4,pn,0x06) /* # good unicast frames */
203#define REG_RX_MULTICAST(pn) CRA(0x4,pn,0x07) /* # good multicast frames */
204#define REG_RX_BROADCAST(pn) CRA(0x4,pn,0x08) /* # good broadcast frames */
205#define REG_CRC(pn) CRA(0x4,pn,0x09) /* # frames w/ bad CRC only */
206#define REG_RX_ALIGNMENT(pn) CRA(0x4,pn,0x0a) /* # frames w/ alignment err */
207#define REG_RX_UNDERSIZE(pn) CRA(0x4,pn,0x0b) /* # frames undersize */
208#define REG_RX_FRAGMENTS(pn) CRA(0x4,pn,0x0c) /* # frames undersize w/ crc err */
209#define REG_RX_IN_RANGE_LENGTH_ERROR(pn) CRA(0x4,pn,0x0d) /* # frames with length error */
210#define REG_RX_OUT_OF_RANGE_ERROR(pn) CRA(0x4,pn,0x0e) /* # frames with illegal length field */
211#define REG_RX_OVERSIZE(pn) CRA(0x4,pn,0x0f) /* # frames oversize */
212#define REG_RX_JABBERS(pn) CRA(0x4,pn,0x10) /* # frames oversize w/ crc err */
213#define REG_RX_SIZE_64(pn) CRA(0x4,pn,0x11) /* # frames 64 octets long */
214#define REG_RX_SIZE_65_TO_127(pn) CRA(0x4,pn,0x12) /* # frames 65-127 octets */
215#define REG_RX_SIZE_128_TO_255(pn) CRA(0x4,pn,0x13) /* # frames 128-255 */
216#define REG_RX_SIZE_256_TO_511(pn) CRA(0x4,pn,0x14) /* # frames 256-511 */
217#define REG_RX_SIZE_512_TO_1023(pn) CRA(0x4,pn,0x15) /* # frames 512-1023 */
218#define REG_RX_SIZE_1024_TO_1518(pn) CRA(0x4,pn,0x16) /* # frames 1024-1518 */
219#define REG_RX_SIZE_1519_TO_MAX(pn) CRA(0x4,pn,0x17) /* # frames 1519-max */
220
221#define REG_TX_OUT_BYTES(pn) CRA(0x4,pn,0x18) /* # octets tx */
222#define REG_TX_PAUSE(pn) CRA(0x4,pn,0x19) /* # pause frames sent */
223#define REG_TX_OK_BYTES(pn) CRA(0x4,pn,0x1a) /* # octets tx OK */
224#define REG_TX_UNICAST(pn) CRA(0x4,pn,0x1b) /* # frames unicast */
225#define REG_TX_MULTICAST(pn) CRA(0x4,pn,0x1c) /* # frames multicast */
226#define REG_TX_BROADCAST(pn) CRA(0x4,pn,0x1d) /* # frames broadcast */
227#define REG_TX_MULTIPLE_COLL(pn) CRA(0x4,pn,0x1e) /* # frames tx after multiple collisions */
228#define REG_TX_LATE_COLL(pn) CRA(0x4,pn,0x1f) /* # late collisions detected */
229#define REG_TX_XCOLL(pn) CRA(0x4,pn,0x20) /* # frames lost, excessive collisions */
230#define REG_TX_DEFER(pn) CRA(0x4,pn,0x21) /* # frames deferred on first tx attempt */
231#define REG_TX_XDEFER(pn) CRA(0x4,pn,0x22) /* # frames excessively deferred */
232#define REG_TX_CSENSE(pn) CRA(0x4,pn,0x23) /* carrier sense errors at frame end */
233#define REG_TX_SIZE_64(pn) CRA(0x4,pn,0x24) /* # frames 64 octets long */
234#define REG_TX_SIZE_65_TO_127(pn) CRA(0x4,pn,0x25) /* # frames 65-127 octets */
235#define REG_TX_SIZE_128_TO_255(pn) CRA(0x4,pn,0x26) /* # frames 128-255 */
236#define REG_TX_SIZE_256_TO_511(pn) CRA(0x4,pn,0x27) /* # frames 256-511 */
237#define REG_TX_SIZE_512_TO_1023(pn) CRA(0x4,pn,0x28) /* # frames 512-1023 */
238#define REG_TX_SIZE_1024_TO_1518(pn) CRA(0x4,pn,0x29) /* # frames 1024-1518 */
239#define REG_TX_SIZE_1519_TO_MAX(pn) CRA(0x4,pn,0x2a) /* # frames 1519-max */
240#define REG_TX_SINGLE_COLL(pn) CRA(0x4,pn,0x2b) /* # frames tx after single collision */
241#define REG_TX_BACKOFF2(pn) CRA(0x4,pn,0x2c) /* # frames tx ok after 2 backoffs/collisions */
242#define REG_TX_BACKOFF3(pn) CRA(0x4,pn,0x2d) /* after 3 backoffs/collisions */
243#define REG_TX_BACKOFF4(pn) CRA(0x4,pn,0x2e) /* after 4 */
244#define REG_TX_BACKOFF5(pn) CRA(0x4,pn,0x2f) /* after 5 */
245#define REG_TX_BACKOFF6(pn) CRA(0x4,pn,0x30) /* after 6 */
246#define REG_TX_BACKOFF7(pn) CRA(0x4,pn,0x31) /* after 7 */
247#define REG_TX_BACKOFF8(pn) CRA(0x4,pn,0x32) /* after 8 */
248#define REG_TX_BACKOFF9(pn) CRA(0x4,pn,0x33) /* after 9 */
249#define REG_TX_BACKOFF10(pn) CRA(0x4,pn,0x34) /* after 10 */
250#define REG_TX_BACKOFF11(pn) CRA(0x4,pn,0x35) /* after 11 */
251#define REG_TX_BACKOFF12(pn) CRA(0x4,pn,0x36) /* after 12 */
252#define REG_TX_BACKOFF13(pn) CRA(0x4,pn,0x37) /* after 13 */
253#define REG_TX_BACKOFF14(pn) CRA(0x4,pn,0x38) /* after 14 */
254#define REG_TX_BACKOFF15(pn) CRA(0x4,pn,0x39) /* after 15 */
255#define REG_TX_UNDERRUN(pn) CRA(0x4,pn,0x3a) /* # frames dropped from underrun */
256#define REG_RX_XGMII_PROT_ERR CRA(0x4,0xa,0x3b) /* # protocol errors detected on XGMII interface */
257#define REG_RX_IPG_SHRINK(pn) CRA(0x4,pn,0x3c) /* # of IPG shrinks detected */
258
259#define REG_STAT_STICKY1G(pn) CRA(0x4,pn,0x3e) /* tri-speed sticky bits */
260#define REG_STAT_STICKY10G CRA(0x4,0xa,0x3e) /* 10GbE sticky bits */
261#define REG_STAT_INIT(pn) CRA(0x4,pn,0x3f) /* Clear all statistics */
262
263/* MII-Management Block registers */
264/* These are for MII-M interface 0, which is the bidirectional LVTTL one. If
265 * we hooked up to the one with separate directions, the middle 0x0 needs to
266 * change to 0x1. And the current errata states that MII-M 1 doesn't work.
267 */
268
269#define REG_MIIM_STATUS CRA(0x3,0x0,0x00) /* MII-M Status */
270#define REG_MIIM_CMD CRA(0x3,0x0,0x01) /* MII-M Command */
271#define REG_MIIM_DATA CRA(0x3,0x0,0x02) /* MII-M Data */
272#define REG_MIIM_PRESCALE CRA(0x3,0x0,0x03) /* MII-M MDC Prescale */
273
274#define REG_ING_FFILT_UM_EN CRA(0x2, 0, 0xd)
275#define REG_ING_FFILT_BE_EN CRA(0x2, 0, 0x1d)
276#define REG_ING_FFILT_VAL0 CRA(0x2, 0, 0x2d)
277#define REG_ING_FFILT_VAL1 CRA(0x2, 0, 0x3d)
278#define REG_ING_FFILT_MASK0 CRA(0x2, 0, 0x4d)
279#define REG_ING_FFILT_MASK1 CRA(0x2, 0, 0x5d)
280#define REG_ING_FFILT_MASK2 CRA(0x2, 0, 0x6d)
281#define REG_ING_FFILT_ETYPE CRA(0x2, 0, 0x7d)
282
283
284/* Whew. */
285
286#endif
diff --git a/drivers/net/chelsio/vsc8244.c b/drivers/net/chelsio/vsc8244.c
new file mode 100644
index 000000000000..c493e783d459
--- /dev/null
+++ b/drivers/net/chelsio/vsc8244.c
@@ -0,0 +1,368 @@
1/*
2 * This file is part of the Chelsio T2 Ethernet driver.
3 *
4 * Copyright (C) 2005 Chelsio Communications. All rights reserved.
5 *
6 * This program is distributed in the hope that it will be useful, but WITHOUT
7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8 * FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file included in this
9 * release for licensing terms and conditions.
10 */
11
12#include "common.h"
13#include "cphy.h"
14#include "elmer0.h"
15
16#ifndef ADVERTISE_PAUSE_CAP
17# define ADVERTISE_PAUSE_CAP 0x400
18#endif
19#ifndef ADVERTISE_PAUSE_ASYM
20# define ADVERTISE_PAUSE_ASYM 0x800
21#endif
22
23/* Gigabit MII registers */
24#ifndef MII_CTRL1000
25# define MII_CTRL1000 9
26#endif
27
28#ifndef ADVERTISE_1000FULL
29# define ADVERTISE_1000FULL 0x200
30# define ADVERTISE_1000HALF 0x100
31#endif
32
33/* VSC8244 PHY specific registers. */
34enum {
35 VSC8244_INTR_ENABLE = 25,
36 VSC8244_INTR_STATUS = 26,
37 VSC8244_AUX_CTRL_STAT = 28,
38};
39
40enum {
41 VSC_INTR_RX_ERR = 1 << 0,
42 VSC_INTR_MS_ERR = 1 << 1, /* master/slave resolution error */
43 VSC_INTR_CABLE = 1 << 2, /* cable impairment */
44 VSC_INTR_FALSE_CARR = 1 << 3, /* false carrier */
45 VSC_INTR_MEDIA_CHG = 1 << 4, /* AMS media change */
46 VSC_INTR_RX_FIFO = 1 << 5, /* Rx FIFO over/underflow */
47 VSC_INTR_TX_FIFO = 1 << 6, /* Tx FIFO over/underflow */
48 VSC_INTR_DESCRAMBL = 1 << 7, /* descrambler lock-lost */
49 VSC_INTR_SYMBOL_ERR = 1 << 8, /* symbol error */
50 VSC_INTR_NEG_DONE = 1 << 10, /* autoneg done */
51 VSC_INTR_NEG_ERR = 1 << 11, /* autoneg error */
52 VSC_INTR_LINK_CHG = 1 << 13, /* link change */
53 VSC_INTR_ENABLE = 1 << 15, /* interrupt enable */
54};
55
56#define CFG_CHG_INTR_MASK (VSC_INTR_LINK_CHG | VSC_INTR_NEG_ERR | \
57 VSC_INTR_NEG_DONE)
58#define INTR_MASK (CFG_CHG_INTR_MASK | VSC_INTR_TX_FIFO | VSC_INTR_RX_FIFO | \
59 VSC_INTR_ENABLE)
60
61/* PHY specific auxiliary control & status register fields */
62#define S_ACSR_ACTIPHY_TMR 0
63#define M_ACSR_ACTIPHY_TMR 0x3
64#define V_ACSR_ACTIPHY_TMR(x) ((x) << S_ACSR_ACTIPHY_TMR)
65
66#define S_ACSR_SPEED 3
67#define M_ACSR_SPEED 0x3
68#define G_ACSR_SPEED(x) (((x) >> S_ACSR_SPEED) & M_ACSR_SPEED)
69
70#define S_ACSR_DUPLEX 5
71#define F_ACSR_DUPLEX (1 << S_ACSR_DUPLEX)
72
73#define S_ACSR_ACTIPHY 6
74#define F_ACSR_ACTIPHY (1 << S_ACSR_ACTIPHY)
75
76/*
77 * Reset the PHY. This PHY completes reset immediately so we never wait.
78 */
79static int vsc8244_reset(struct cphy *cphy, int wait)
80{
81 int err;
82 unsigned int ctl;
83
84 err = simple_mdio_read(cphy, MII_BMCR, &ctl);
85 if (err)
86 return err;
87
88 ctl &= ~BMCR_PDOWN;
89 ctl |= BMCR_RESET;
90 return simple_mdio_write(cphy, MII_BMCR, ctl);
91}
92
93static int vsc8244_intr_enable(struct cphy *cphy)
94{
95 simple_mdio_write(cphy, VSC8244_INTR_ENABLE, INTR_MASK);
96
97 /* Enable interrupts through Elmer */
98 if (t1_is_asic(cphy->adapter)) {
99 u32 elmer;
100
101 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
102 elmer |= ELMER0_GP_BIT1;
103 if (is_T2(cphy->adapter)) {
104 elmer |= ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4;
105 }
106 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
107 }
108
109 return 0;
110}
111
112static int vsc8244_intr_disable(struct cphy *cphy)
113{
114 simple_mdio_write(cphy, VSC8244_INTR_ENABLE, 0);
115
116 if (t1_is_asic(cphy->adapter)) {
117 u32 elmer;
118
119 t1_tpi_read(cphy->adapter, A_ELMER0_INT_ENABLE, &elmer);
120 elmer &= ~ELMER0_GP_BIT1;
121 if (is_T2(cphy->adapter)) {
122 elmer &= ~(ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4);
123 }
124 t1_tpi_write(cphy->adapter, A_ELMER0_INT_ENABLE, elmer);
125 }
126
127 return 0;
128}
129
130static int vsc8244_intr_clear(struct cphy *cphy)
131{
132 u32 val;
133 u32 elmer;
134
135 /* Clear PHY interrupts by reading the register. */
136 simple_mdio_read(cphy, VSC8244_INTR_ENABLE, &val);
137
138 if (t1_is_asic(cphy->adapter)) {
139 t1_tpi_read(cphy->adapter, A_ELMER0_INT_CAUSE, &elmer);
140 elmer |= ELMER0_GP_BIT1;
141 if (is_T2(cphy->adapter)) {
142 elmer |= ELMER0_GP_BIT2|ELMER0_GP_BIT3|ELMER0_GP_BIT4;
143 }
144 t1_tpi_write(cphy->adapter, A_ELMER0_INT_CAUSE, elmer);
145 }
146
147 return 0;
148}
149
150/*
151 * Force the PHY speed and duplex. This also disables auto-negotiation, except
152 * for 1Gb/s, where auto-negotiation is mandatory.
153 */
154static int vsc8244_set_speed_duplex(struct cphy *phy, int speed, int duplex)
155{
156 int err;
157 unsigned int ctl;
158
159 err = simple_mdio_read(phy, MII_BMCR, &ctl);
160 if (err)
161 return err;
162
163 if (speed >= 0) {
164 ctl &= ~(BMCR_SPEED100 | BMCR_SPEED1000 | BMCR_ANENABLE);
165 if (speed == SPEED_100)
166 ctl |= BMCR_SPEED100;
167 else if (speed == SPEED_1000)
168 ctl |= BMCR_SPEED1000;
169 }
170 if (duplex >= 0) {
171 ctl &= ~(BMCR_FULLDPLX | BMCR_ANENABLE);
172 if (duplex == DUPLEX_FULL)
173 ctl |= BMCR_FULLDPLX;
174 }
175 if (ctl & BMCR_SPEED1000) /* auto-negotiation required for 1Gb/s */
176 ctl |= BMCR_ANENABLE;
177 return simple_mdio_write(phy, MII_BMCR, ctl);
178}
179
180int t1_mdio_set_bits(struct cphy *phy, int mmd, int reg, unsigned int bits)
181{
182 int ret;
183 unsigned int val;
184
185 ret = mdio_read(phy, mmd, reg, &val);
186 if (!ret)
187 ret = mdio_write(phy, mmd, reg, val | bits);
188 return ret;
189}
190
191static int vsc8244_autoneg_enable(struct cphy *cphy)
192{
193 return t1_mdio_set_bits(cphy, 0, MII_BMCR,
194 BMCR_ANENABLE | BMCR_ANRESTART);
195}
196
197static int vsc8244_autoneg_restart(struct cphy *cphy)
198{
199 return t1_mdio_set_bits(cphy, 0, MII_BMCR, BMCR_ANRESTART);
200}
201
202static int vsc8244_advertise(struct cphy *phy, unsigned int advertise_map)
203{
204 int err;
205 unsigned int val = 0;
206
207 err = simple_mdio_read(phy, MII_CTRL1000, &val);
208 if (err)
209 return err;
210
211 val &= ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);
212 if (advertise_map & ADVERTISED_1000baseT_Half)
213 val |= ADVERTISE_1000HALF;
214 if (advertise_map & ADVERTISED_1000baseT_Full)
215 val |= ADVERTISE_1000FULL;
216
217 err = simple_mdio_write(phy, MII_CTRL1000, val);
218 if (err)
219 return err;
220
221 val = 1;
222 if (advertise_map & ADVERTISED_10baseT_Half)
223 val |= ADVERTISE_10HALF;
224 if (advertise_map & ADVERTISED_10baseT_Full)
225 val |= ADVERTISE_10FULL;
226 if (advertise_map & ADVERTISED_100baseT_Half)
227 val |= ADVERTISE_100HALF;
228 if (advertise_map & ADVERTISED_100baseT_Full)
229 val |= ADVERTISE_100FULL;
230 if (advertise_map & ADVERTISED_PAUSE)
231 val |= ADVERTISE_PAUSE_CAP;
232 if (advertise_map & ADVERTISED_ASYM_PAUSE)
233 val |= ADVERTISE_PAUSE_ASYM;
234 return simple_mdio_write(phy, MII_ADVERTISE, val);
235}
236
237static int vsc8244_get_link_status(struct cphy *cphy, int *link_ok,
238 int *speed, int *duplex, int *fc)
239{
240 unsigned int bmcr, status, lpa, adv;
241 int err, sp = -1, dplx = -1, pause = 0;
242
243 err = simple_mdio_read(cphy, MII_BMCR, &bmcr);
244 if (!err)
245 err = simple_mdio_read(cphy, MII_BMSR, &status);
246 if (err)
247 return err;
248
249 if (link_ok) {
250 /*
251 * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it
252 * once more to get the current link state.
253 */
254 if (!(status & BMSR_LSTATUS))
255 err = simple_mdio_read(cphy, MII_BMSR, &status);
256 if (err)
257 return err;
258 *link_ok = (status & BMSR_LSTATUS) != 0;
259 }
260 if (!(bmcr & BMCR_ANENABLE)) {
261 dplx = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
262 if (bmcr & BMCR_SPEED1000)
263 sp = SPEED_1000;
264 else if (bmcr & BMCR_SPEED100)
265 sp = SPEED_100;
266 else
267 sp = SPEED_10;
268 } else if (status & BMSR_ANEGCOMPLETE) {
269 err = simple_mdio_read(cphy, VSC8244_AUX_CTRL_STAT, &status);
270 if (err)
271 return err;
272
273 dplx = (status & F_ACSR_DUPLEX) ? DUPLEX_FULL : DUPLEX_HALF;
274 sp = G_ACSR_SPEED(status);
275 if (sp == 0)
276 sp = SPEED_10;
277 else if (sp == 1)
278 sp = SPEED_100;
279 else
280 sp = SPEED_1000;
281
282 if (fc && dplx == DUPLEX_FULL) {
283 err = simple_mdio_read(cphy, MII_LPA, &lpa);
284 if (!err)
285 err = simple_mdio_read(cphy, MII_ADVERTISE,
286 &adv);
287 if (err)
288 return err;
289
290 if (lpa & adv & ADVERTISE_PAUSE_CAP)
291 pause = PAUSE_RX | PAUSE_TX;
292 else if ((lpa & ADVERTISE_PAUSE_CAP) &&
293 (lpa & ADVERTISE_PAUSE_ASYM) &&
294 (adv & ADVERTISE_PAUSE_ASYM))
295 pause = PAUSE_TX;
296 else if ((lpa & ADVERTISE_PAUSE_ASYM) &&
297 (adv & ADVERTISE_PAUSE_CAP))
298 pause = PAUSE_RX;
299 }
300 }
301 if (speed)
302 *speed = sp;
303 if (duplex)
304 *duplex = dplx;
305 if (fc)
306 *fc = pause;
307 return 0;
308}
309
310static int vsc8244_intr_handler(struct cphy *cphy)
311{
312 unsigned int cause;
313 int err, cphy_cause = 0;
314
315 err = simple_mdio_read(cphy, VSC8244_INTR_STATUS, &cause);
316 if (err)
317 return err;
318
319 cause &= INTR_MASK;
320 if (cause & CFG_CHG_INTR_MASK)
321 cphy_cause |= cphy_cause_link_change;
322 if (cause & (VSC_INTR_RX_FIFO | VSC_INTR_TX_FIFO))
323 cphy_cause |= cphy_cause_fifo_error;
324 return cphy_cause;
325}
326
327static void vsc8244_destroy(struct cphy *cphy)
328{
329 kfree(cphy);
330}
331
332static struct cphy_ops vsc8244_ops = {
333 .destroy = vsc8244_destroy,
334 .reset = vsc8244_reset,
335 .interrupt_enable = vsc8244_intr_enable,
336 .interrupt_disable = vsc8244_intr_disable,
337 .interrupt_clear = vsc8244_intr_clear,
338 .interrupt_handler = vsc8244_intr_handler,
339 .autoneg_enable = vsc8244_autoneg_enable,
340 .autoneg_restart = vsc8244_autoneg_restart,
341 .advertise = vsc8244_advertise,
342 .set_speed_duplex = vsc8244_set_speed_duplex,
343 .get_link_status = vsc8244_get_link_status
344};
345
346static struct cphy* vsc8244_phy_create(adapter_t *adapter, int phy_addr, struct mdio_ops *mdio_ops)
347{
348 struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL);
349
350 if (!cphy) return NULL;
351
352 cphy_init(cphy, adapter, phy_addr, &vsc8244_ops, mdio_ops);
353
354 return cphy;
355}
356
357
358static int vsc8244_phy_reset(adapter_t* adapter)
359{
360 return 0;
361}
362
363struct gphy t1_vsc8244_ops = {
364 vsc8244_phy_create,
365 vsc8244_phy_reset
366};
367
368
diff --git a/drivers/net/chelsio/vsc8244_reg.h b/drivers/net/chelsio/vsc8244_reg.h
new file mode 100644
index 000000000000..d3c1829055cb
--- /dev/null
+++ b/drivers/net/chelsio/vsc8244_reg.h
@@ -0,0 +1,172 @@
1/* $Date: 2005/11/23 16:28:53 $ $RCSfile: vsc8244_reg.h,v $ $Revision: 1.1 $ */
2#ifndef CHELSIO_MV8E1XXX_H
3#define CHELSIO_MV8E1XXX_H
4
5#ifndef BMCR_SPEED1000
6# define BMCR_SPEED1000 0x40
7#endif
8
9#ifndef ADVERTISE_PAUSE
10# define ADVERTISE_PAUSE 0x400
11#endif
12#ifndef ADVERTISE_PAUSE_ASYM
13# define ADVERTISE_PAUSE_ASYM 0x800
14#endif
15
16/* Gigabit MII registers */
17#define MII_GBMR 1 /* 1000Base-T mode register */
18#define MII_GBCR 9 /* 1000Base-T control register */
19#define MII_GBSR 10 /* 1000Base-T status register */
20
21/* 1000Base-T control register fields */
22#define GBCR_ADV_1000HALF 0x100
23#define GBCR_ADV_1000FULL 0x200
24#define GBCR_PREFER_MASTER 0x400
25#define GBCR_MANUAL_AS_MASTER 0x800
26#define GBCR_MANUAL_CONFIG_ENABLE 0x1000
27
28/* 1000Base-T status register fields */
29#define GBSR_LP_1000HALF 0x400
30#define GBSR_LP_1000FULL 0x800
31#define GBSR_REMOTE_OK 0x1000
32#define GBSR_LOCAL_OK 0x2000
33#define GBSR_LOCAL_MASTER 0x4000
34#define GBSR_MASTER_FAULT 0x8000
35
36/* Vitesse PHY interrupt status bits. */
37#if 0
38#define VSC8244_INTR_JABBER 0x0001
39#define VSC8244_INTR_POLARITY_CHNG 0x0002
40#define VSC8244_INTR_ENG_DETECT_CHNG 0x0010
41#define VSC8244_INTR_DOWNSHIFT 0x0020
42#define VSC8244_INTR_MDI_XOVER_CHNG 0x0040
43#define VSC8244_INTR_FIFO_OVER_UNDER 0x0080
44#define VSC8244_INTR_FALSE_CARRIER 0x0100
45#define VSC8244_INTR_SYMBOL_ERROR 0x0200
46#define VSC8244_INTR_LINK_CHNG 0x0400
47#define VSC8244_INTR_AUTONEG_DONE 0x0800
48#define VSC8244_INTR_PAGE_RECV 0x1000
49#define VSC8244_INTR_DUPLEX_CHNG 0x2000
50#define VSC8244_INTR_SPEED_CHNG 0x4000
51#define VSC8244_INTR_AUTONEG_ERR 0x8000
52#else
53//#define VSC8244_INTR_JABBER 0x0001
54//#define VSC8244_INTR_POLARITY_CHNG 0x0002
55//#define VSC8244_INTR_BIT2 0x0004
56//#define VSC8244_INTR_BIT3 0x0008
57#define VSC8244_INTR_RX_ERR 0x0001
58#define VSC8244_INTR_MASTER_SLAVE 0x0002
59#define VSC8244_INTR_CABLE_IMPAIRED 0x0004
60#define VSC8244_INTR_FALSE_CARRIER 0x0008
61//#define VSC8244_INTR_ENG_DETECT_CHNG 0x0010
62//#define VSC8244_INTR_DOWNSHIFT 0x0020
63//#define VSC8244_INTR_MDI_XOVER_CHNG 0x0040
64//#define VSC8244_INTR_FIFO_OVER_UNDER 0x0080
65#define VSC8244_INTR_BIT4 0x0010
66#define VSC8244_INTR_FIFO_RX 0x0020
67#define VSC8244_INTR_FIFO_OVER_UNDER 0x0040
68#define VSC8244_INTR_LOCK_LOST 0x0080
69//#define VSC8244_INTR_FALSE_CARRIER 0x0100
70//#define VSC8244_INTR_SYMBOL_ERROR 0x0200
71//#define VSC8244_INTR_LINK_CHNG 0x0400
72//#define VSC8244_INTR_AUTONEG_DONE 0x0800
73#define VSC8244_INTR_SYMBOL_ERROR 0x0100
74#define VSC8244_INTR_ENG_DETECT_CHNG 0x0200
75#define VSC8244_INTR_AUTONEG_DONE 0x0400
76#define VSC8244_INTR_AUTONEG_ERR 0x0800
77//#define VSC8244_INTR_PAGE_RECV 0x1000
78//#define VSC8244_INTR_DUPLEX_CHNG 0x2000
79//#define VSC8244_INTR_SPEED_CHNG 0x4000
80//#define VSC8244_INTR_AUTONEG_ERR 0x8000
81#define VSC8244_INTR_DUPLEX_CHNG 0x1000
82#define VSC8244_INTR_LINK_CHNG 0x2000
83#define VSC8244_INTR_SPEED_CHNG 0x4000
84#define VSC8244_INTR_STATUS 0x8000
85#endif
86
87
88/* Vitesse PHY specific registers. */
89#define VSC8244_SPECIFIC_CNTRL_REGISTER 16
90#define VSC8244_SPECIFIC_STATUS_REGISTER 0x1c
91#define VSC8244_INTERRUPT_ENABLE_REGISTER 0x19
92#define VSC8244_INTERRUPT_STATUS_REGISTER 0x1a
93#define VSC8244_EXT_PHY_SPECIFIC_CNTRL_REGISTER 20
94#define VSC8244_RECV_ERR_CNTR_REGISTER 21
95#define VSC8244_RES_REGISTER 22
96#define VSC8244_GLOBAL_STATUS_REGISTER 23
97#define VSC8244_LED_CONTROL_REGISTER 24
98#define VSC8244_MANUAL_LED_OVERRIDE_REGISTER 25
99#define VSC8244_EXT_PHY_SPECIFIC_CNTRL_2_REGISTER 26
100#define VSC8244_EXT_PHY_SPECIFIC_STATUS_REGISTER 27
101#define VSC8244_VIRTUAL_CABLE_TESTER_REGISTER 28
102#define VSC8244_EXTENDED_ADDR_REGISTER 29
103#define VSC8244_EXTENDED_REGISTER 30
104
105/* PHY specific control register fields */
106#define S_PSCR_MDI_XOVER_MODE 5
107#define M_PSCR_MDI_XOVER_MODE 0x3
108#define V_PSCR_MDI_XOVER_MODE(x) ((x) << S_PSCR_MDI_XOVER_MODE)
109#define G_PSCR_MDI_XOVER_MODE(x) (((x) >> S_PSCR_MDI_XOVER_MODE) & M_PSCR_MDI_XOVER_MODE)
110
111/* Extended PHY specific control register fields */
112#define S_DOWNSHIFT_ENABLE 8
113#define V_DOWNSHIFT_ENABLE (1 << S_DOWNSHIFT_ENABLE)
114
115#define S_DOWNSHIFT_CNT 9
116#define M_DOWNSHIFT_CNT 0x7
117#define V_DOWNSHIFT_CNT(x) ((x) << S_DOWNSHIFT_CNT)
118#define G_DOWNSHIFT_CNT(x) (((x) >> S_DOWNSHIFT_CNT) & M_DOWNSHIFT_CNT)
119
120/* PHY specific status register fields */
121#define S_PSSR_JABBER 0
122#define V_PSSR_JABBER (1 << S_PSSR_JABBER)
123
124#define S_PSSR_POLARITY 1
125#define V_PSSR_POLARITY (1 << S_PSSR_POLARITY)
126
127#define S_PSSR_RX_PAUSE 2
128#define V_PSSR_RX_PAUSE (1 << S_PSSR_RX_PAUSE)
129
130#define S_PSSR_TX_PAUSE 3
131#define V_PSSR_TX_PAUSE (1 << S_PSSR_TX_PAUSE)
132
133#define S_PSSR_ENERGY_DETECT 4
134#define V_PSSR_ENERGY_DETECT (1 << S_PSSR_ENERGY_DETECT)
135
136#define S_PSSR_DOWNSHIFT_STATUS 5
137#define V_PSSR_DOWNSHIFT_STATUS (1 << S_PSSR_DOWNSHIFT_STATUS)
138
139#define S_PSSR_MDI 6
140#define V_PSSR_MDI (1 << S_PSSR_MDI)
141
142#define S_PSSR_CABLE_LEN 7
143#define M_PSSR_CABLE_LEN 0x7
144#define V_PSSR_CABLE_LEN(x) ((x) << S_PSSR_CABLE_LEN)
145#define G_PSSR_CABLE_LEN(x) (((x) >> S_PSSR_CABLE_LEN) & M_PSSR_CABLE_LEN)
146
147//#define S_PSSR_LINK 10
148//#define S_PSSR_LINK 13
149#define S_PSSR_LINK 2
150#define V_PSSR_LINK (1 << S_PSSR_LINK)
151
152//#define S_PSSR_STATUS_RESOLVED 11
153//#define S_PSSR_STATUS_RESOLVED 10
154#define S_PSSR_STATUS_RESOLVED 15
155#define V_PSSR_STATUS_RESOLVED (1 << S_PSSR_STATUS_RESOLVED)
156
157#define S_PSSR_PAGE_RECEIVED 12
158#define V_PSSR_PAGE_RECEIVED (1 << S_PSSR_PAGE_RECEIVED)
159
160//#define S_PSSR_DUPLEX 13
161//#define S_PSSR_DUPLEX 12
162#define S_PSSR_DUPLEX 5
163#define V_PSSR_DUPLEX (1 << S_PSSR_DUPLEX)
164
165//#define S_PSSR_SPEED 14
166//#define S_PSSR_SPEED 14
167#define S_PSSR_SPEED 3
168#define M_PSSR_SPEED 0x3
169#define V_PSSR_SPEED(x) ((x) << S_PSSR_SPEED)
170#define G_PSSR_SPEED(x) (((x) >> S_PSSR_SPEED) & M_PSSR_SPEED)
171
172#endif
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index 4ffc9b44a8e1..dec70c2b374a 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -588,10 +588,10 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
588 goto out2; 588 goto out2;
589 } 589 }
590 } 590 }
591 printk(KERN_DEBUG "PP_addr at %x[%x]: 0x%x\n",
592 ioaddr, ADD_PORT, readword(ioaddr, ADD_PORT));
593 591
594 ioaddr &= ~3; 592 ioaddr &= ~3;
593 printk(KERN_DEBUG "PP_addr at %x[%x]: 0x%x\n",
594 ioaddr, ADD_PORT, readword(ioaddr, ADD_PORT));
595 writeword(ioaddr, ADD_PORT, PP_ChipID); 595 writeword(ioaddr, ADD_PORT, PP_ChipID);
596 596
597 tmp = readword(ioaddr, DATA_PORT); 597 tmp = readword(ioaddr, DATA_PORT);
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index 8f514cc0debd..dc3ab3b5c8cb 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -192,6 +192,7 @@
192 * 04 Aug 2003 macro Converted to the DMA API. 192 * 04 Aug 2003 macro Converted to the DMA API.
193 * 14 Aug 2004 macro Fix device names reported. 193 * 14 Aug 2004 macro Fix device names reported.
194 * 14 Jun 2005 macro Use irqreturn_t. 194 * 14 Jun 2005 macro Use irqreturn_t.
195 * 23 Oct 2006 macro Big-endian host support.
195 */ 196 */
196 197
197/* Include files */ 198/* Include files */
@@ -218,8 +219,8 @@
218 219
219/* Version information string should be updated prior to each new release! */ 220/* Version information string should be updated prior to each new release! */
220#define DRV_NAME "defxx" 221#define DRV_NAME "defxx"
221#define DRV_VERSION "v1.08" 222#define DRV_VERSION "v1.09"
222#define DRV_RELDATE "2005/06/14" 223#define DRV_RELDATE "2006/10/23"
223 224
224static char version[] __devinitdata = 225static char version[] __devinitdata =
225 DRV_NAME ": " DRV_VERSION " " DRV_RELDATE 226 DRV_NAME ": " DRV_VERSION " " DRV_RELDATE
@@ -859,6 +860,7 @@ static int __devinit dfx_driver_init(struct net_device *dev,
859 print_name); 860 print_name);
860 return(DFX_K_FAILURE); 861 return(DFX_K_FAILURE);
861 } 862 }
863 data = cpu_to_le32(data);
862 memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32)); 864 memcpy(&bp->factory_mac_addr[0], &data, sizeof(u32));
863 865
864 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0, 866 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_MLA, PI_PDATA_A_MLA_K_HI, 0,
@@ -867,6 +869,7 @@ static int __devinit dfx_driver_init(struct net_device *dev,
867 print_name); 869 print_name);
868 return(DFX_K_FAILURE); 870 return(DFX_K_FAILURE);
869 } 871 }
872 data = cpu_to_le32(data);
870 memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16)); 873 memcpy(&bp->factory_mac_addr[4], &data, sizeof(u16));
871 874
872 /* 875 /*
@@ -1085,27 +1088,23 @@ static int dfx_adap_init(DFX_board_t *bp, int get_buffers)
1085 } 1088 }
1086 1089
1087 /* 1090 /*
1088 * Set base address of Descriptor Block and bring adapter to DMA_AVAILABLE state 1091 * Set the base address of Descriptor Block and bring adapter
1092 * to DMA_AVAILABLE state.
1089 * 1093 *
1090 * Note: We also set the literal and data swapping requirements in this 1094 * Note: We also set the literal and data swapping requirements
1091 * command. Since this driver presently runs on Intel platforms 1095 * in this command.
1092 * which are Little Endian, we'll tell the adapter to byte swap
1093 * data only. This code will need to change when we support
1094 * Big Endian systems (eg. PowerPC).
1095 * 1096 *
1096 * Assumption: 32-bit physical address of descriptor block is 8Kbyte 1097 * Assumption: 32-bit physical address of descriptor block
1097 * aligned. That is, bits 0-12 of the address must be zero. 1098 * is 8Kbyte aligned.
1098 */ 1099 */
1099 1100 if (dfx_hw_port_ctrl_req(bp, PI_PCTRL_M_INIT,
1100 if (dfx_hw_port_ctrl_req(bp, 1101 (u32)(bp->descr_block_phys |
1101 PI_PCTRL_M_INIT, 1102 PI_PDATA_A_INIT_M_BSWAP_INIT),
1102 (u32) (bp->descr_block_phys | PI_PDATA_A_INIT_M_BSWAP_DATA), 1103 0, NULL) != DFX_K_SUCCESS) {
1103 0, 1104 printk("%s: Could not set descriptor block address!\n",
1104 NULL) != DFX_K_SUCCESS) 1105 bp->dev->name);
1105 { 1106 return DFX_K_FAILURE;
1106 printk("%s: Could not set descriptor block address!\n", bp->dev->name); 1107 }
1107 return(DFX_K_FAILURE);
1108 }
1109 1108
1110 /* Set transmit flush timeout value */ 1109 /* Set transmit flush timeout value */
1111 1110
diff --git a/drivers/net/defxx.h b/drivers/net/defxx.h
index 8b1e9a11ca21..2ce8f97253eb 100644
--- a/drivers/net/defxx.h
+++ b/drivers/net/defxx.h
@@ -25,6 +25,7 @@
25 * macros to DEFXX.C. 25 * macros to DEFXX.C.
26 * 12-Sep-96 LVS Removed packet request header pointers. 26 * 12-Sep-96 LVS Removed packet request header pointers.
27 * 04 Aug 2003 macro Converted to the DMA API. 27 * 04 Aug 2003 macro Converted to the DMA API.
28 * 23 Oct 2006 macro Big-endian host support.
28 */ 29 */
29 30
30#ifndef _DEFXX_H_ 31#ifndef _DEFXX_H_
@@ -1344,7 +1345,7 @@ typedef struct
1344 1345
1345/* Register definition structures are defined for both big and little endian systems */ 1346/* Register definition structures are defined for both big and little endian systems */
1346 1347
1347#ifndef BIG_ENDIAN 1348#ifndef __BIG_ENDIAN
1348 1349
1349/* Little endian format of Type 1 Producer register */ 1350/* Little endian format of Type 1 Producer register */
1350 1351
@@ -1402,7 +1403,11 @@ typedef union
1402 } index; 1403 } index;
1403 } PI_TYPE_2_CONSUMER; 1404 } PI_TYPE_2_CONSUMER;
1404 1405
1405#else 1406/* Define swapping required by DMA transfers. */
1407#define PI_PDATA_A_INIT_M_BSWAP_INIT \
1408 (PI_PDATA_A_INIT_M_BSWAP_DATA)
1409
1410#else /* __BIG_ENDIAN */
1406 1411
1407/* Big endian format of Type 1 Producer register */ 1412/* Big endian format of Type 1 Producer register */
1408 1413
@@ -1460,7 +1465,11 @@ typedef union
1460 } index; 1465 } index;
1461 } PI_TYPE_2_CONSUMER; 1466 } PI_TYPE_2_CONSUMER;
1462 1467
1463#endif /* #ifndef BIG_ENDIAN */ 1468/* Define swapping required by DMA transfers. */
1469#define PI_PDATA_A_INIT_M_BSWAP_INIT \
1470 (PI_PDATA_A_INIT_M_BSWAP_DATA | PI_PDATA_A_INIT_M_BSWAP_LITERAL)
1471
1472#endif /* __BIG_ENDIAN */
1464 1473
1465/* Define EISA controller register offsets */ 1474/* Define EISA controller register offsets */
1466 1475
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index f87f6e3dc721..5113eef755b9 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -1252,24 +1252,22 @@ static void set_multicast_list(struct net_device *dev)
1252 struct depca_private *lp = (struct depca_private *) dev->priv; 1252 struct depca_private *lp = (struct depca_private *) dev->priv;
1253 u_long ioaddr = dev->base_addr; 1253 u_long ioaddr = dev->base_addr;
1254 1254
1255 if (dev) { 1255 netif_stop_queue(dev);
1256 netif_stop_queue(dev); 1256 while (lp->tx_old != lp->tx_new); /* Wait for the ring to empty */
1257 while (lp->tx_old != lp->tx_new); /* Wait for the ring to empty */
1258
1259 STOP_DEPCA; /* Temporarily stop the depca. */
1260 depca_init_ring(dev); /* Initialize the descriptor rings */
1261 1257
1262 if (dev->flags & IFF_PROMISC) { /* Set promiscuous mode */ 1258 STOP_DEPCA; /* Temporarily stop the depca. */
1263 lp->init_block.mode |= PROM; 1259 depca_init_ring(dev); /* Initialize the descriptor rings */
1264 } else {
1265 SetMulticastFilter(dev);
1266 lp->init_block.mode &= ~PROM; /* Unset promiscuous mode */
1267 }
1268 1260
1269 LoadCSRs(dev); /* Reload CSR3 */ 1261 if (dev->flags & IFF_PROMISC) { /* Set promiscuous mode */
1270 InitRestartDepca(dev); /* Resume normal operation. */ 1262 lp->init_block.mode |= PROM;
1271 netif_start_queue(dev); /* Unlock the TX ring */ 1263 } else {
1264 SetMulticastFilter(dev);
1265 lp->init_block.mode &= ~PROM; /* Unset promiscuous mode */
1272 } 1266 }
1267
1268 LoadCSRs(dev); /* Reload CSR3 */
1269 InitRestartDepca(dev); /* Resume normal operation. */
1270 netif_start_queue(dev); /* Unlock the TX ring */
1273} 1271}
1274 1272
1275/* 1273/*
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index e7737d02bb05..03bf164f9e8d 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1215,7 +1215,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb
1215* the literal in the instruction before the code is loaded, the 1215* the literal in the instruction before the code is loaded, the
1216* driver can change the algorithm. 1216* driver can change the algorithm.
1217* 1217*
1218* INTDELAY - This loads the dead-man timer with its inital value. 1218* INTDELAY - This loads the dead-man timer with its initial value.
1219* When this timer expires the interrupt is asserted, and the 1219* When this timer expires the interrupt is asserted, and the
1220* timer is reset each time a new packet is received. (see 1220* timer is reset each time a new packet is received. (see
1221* BUNDLEMAX below to set the limit on number of chained packets) 1221* BUNDLEMAX below to set the limit on number of chained packets)
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 7ecce438d258..f091042b146e 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -59,6 +59,9 @@
59#include <linux/capability.h> 59#include <linux/capability.h>
60#include <linux/in.h> 60#include <linux/in.h>
61#include <linux/ip.h> 61#include <linux/ip.h>
62#ifdef NETIF_F_TSO6
63#include <linux/ipv6.h>
64#endif
62#include <linux/tcp.h> 65#include <linux/tcp.h>
63#include <linux/udp.h> 66#include <linux/udp.h>
64#include <net/pkt_sched.h> 67#include <net/pkt_sched.h>
@@ -254,6 +257,17 @@ struct e1000_adapter {
254 spinlock_t tx_queue_lock; 257 spinlock_t tx_queue_lock;
255#endif 258#endif
256 atomic_t irq_sem; 259 atomic_t irq_sem;
260 unsigned int detect_link;
261 unsigned int total_tx_bytes;
262 unsigned int total_tx_packets;
263 unsigned int total_rx_bytes;
264 unsigned int total_rx_packets;
265 /* Interrupt Throttle Rate */
266 uint32_t itr;
267 uint32_t itr_setting;
268 uint16_t tx_itr;
269 uint16_t rx_itr;
270
257 struct work_struct reset_task; 271 struct work_struct reset_task;
258 uint8_t fc_autoneg; 272 uint8_t fc_autoneg;
259 273
@@ -262,6 +276,7 @@ struct e1000_adapter {
262 276
263 /* TX */ 277 /* TX */
264 struct e1000_tx_ring *tx_ring; /* One per active queue */ 278 struct e1000_tx_ring *tx_ring; /* One per active queue */
279 unsigned int restart_queue;
265 unsigned long tx_queue_len; 280 unsigned long tx_queue_len;
266 uint32_t txd_cmd; 281 uint32_t txd_cmd;
267 uint32_t tx_int_delay; 282 uint32_t tx_int_delay;
@@ -310,8 +325,6 @@ struct e1000_adapter {
310 uint64_t gorcl_old; 325 uint64_t gorcl_old;
311 uint16_t rx_ps_bsize0; 326 uint16_t rx_ps_bsize0;
312 327
313 /* Interrupt Throttle Rate */
314 uint32_t itr;
315 328
316 /* OS defined structs */ 329 /* OS defined structs */
317 struct net_device *netdev; 330 struct net_device *netdev;
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index c564adbd669b..da459f7177c6 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -85,6 +85,7 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
85 { "tx_single_coll_ok", E1000_STAT(stats.scc) }, 85 { "tx_single_coll_ok", E1000_STAT(stats.scc) },
86 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) }, 86 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
87 { "tx_timeout_count", E1000_STAT(tx_timeout_count) }, 87 { "tx_timeout_count", E1000_STAT(tx_timeout_count) },
88 { "tx_restart_queue", E1000_STAT(restart_queue) },
88 { "rx_long_length_errors", E1000_STAT(stats.roc) }, 89 { "rx_long_length_errors", E1000_STAT(stats.roc) },
89 { "rx_short_length_errors", E1000_STAT(stats.ruc) }, 90 { "rx_short_length_errors", E1000_STAT(stats.ruc) },
90 { "rx_align_errors", E1000_STAT(stats.algnerrc) }, 91 { "rx_align_errors", E1000_STAT(stats.algnerrc) },
@@ -133,9 +134,7 @@ e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
133 134
134 if (hw->autoneg == 1) { 135 if (hw->autoneg == 1) {
135 ecmd->advertising |= ADVERTISED_Autoneg; 136 ecmd->advertising |= ADVERTISED_Autoneg;
136
137 /* the e1000 autoneg seems to match ethtool nicely */ 137 /* the e1000 autoneg seems to match ethtool nicely */
138
139 ecmd->advertising |= hw->autoneg_advertised; 138 ecmd->advertising |= hw->autoneg_advertised;
140 } 139 }
141 140
@@ -285,7 +284,7 @@ e1000_set_pauseparam(struct net_device *netdev,
285 e1000_reset(adapter); 284 e1000_reset(adapter);
286 } else 285 } else
287 retval = ((hw->media_type == e1000_media_type_fiber) ? 286 retval = ((hw->media_type == e1000_media_type_fiber) ?
288 e1000_setup_link(hw) : e1000_force_mac_fc(hw)); 287 e1000_setup_link(hw) : e1000_force_mac_fc(hw));
289 288
290 clear_bit(__E1000_RESETTING, &adapter->flags); 289 clear_bit(__E1000_RESETTING, &adapter->flags);
291 return retval; 290 return retval;
@@ -350,6 +349,13 @@ e1000_set_tso(struct net_device *netdev, uint32_t data)
350 else 349 else
351 netdev->features &= ~NETIF_F_TSO; 350 netdev->features &= ~NETIF_F_TSO;
352 351
352#ifdef NETIF_F_TSO6
353 if (data)
354 netdev->features |= NETIF_F_TSO6;
355 else
356 netdev->features &= ~NETIF_F_TSO6;
357#endif
358
353 DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled"); 359 DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled");
354 adapter->tso_force = TRUE; 360 adapter->tso_force = TRUE;
355 return 0; 361 return 0;
@@ -774,7 +780,7 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
774 /* The status register is Read Only, so a write should fail. 780 /* The status register is Read Only, so a write should fail.
775 * Some bits that get toggled are ignored. 781 * Some bits that get toggled are ignored.
776 */ 782 */
777 switch (adapter->hw.mac_type) { 783 switch (adapter->hw.mac_type) {
778 /* there are several bits on newer hardware that are r/w */ 784 /* there are several bits on newer hardware that are r/w */
779 case e1000_82571: 785 case e1000_82571:
780 case e1000_82572: 786 case e1000_82572:
@@ -802,12 +808,14 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
802 } 808 }
803 /* restore previous status */ 809 /* restore previous status */
804 E1000_WRITE_REG(&adapter->hw, STATUS, before); 810 E1000_WRITE_REG(&adapter->hw, STATUS, before);
811
805 if (adapter->hw.mac_type != e1000_ich8lan) { 812 if (adapter->hw.mac_type != e1000_ich8lan) {
806 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF); 813 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
807 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF); 814 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
808 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF); 815 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
809 REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF); 816 REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
810 } 817 }
818
811 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF); 819 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
812 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF); 820 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
813 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF); 821 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
@@ -820,8 +828,9 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
820 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF); 828 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
821 829
822 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000); 830 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
831
823 before = (adapter->hw.mac_type == e1000_ich8lan ? 832 before = (adapter->hw.mac_type == e1000_ich8lan ?
824 0x06C3B33E : 0x06DFB3FE); 833 0x06C3B33E : 0x06DFB3FE);
825 REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB); 834 REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB);
826 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000); 835 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
827 836
@@ -834,10 +843,10 @@ e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
834 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 843 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
835 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF); 844 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
836 value = (adapter->hw.mac_type == e1000_ich8lan ? 845 value = (adapter->hw.mac_type == e1000_ich8lan ?
837 E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES); 846 E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES);
838 for (i = 0; i < value; i++) { 847 for (i = 0; i < value; i++) {
839 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF, 848 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
840 0xFFFFFFFF); 849 0xFFFFFFFF);
841 } 850 }
842 851
843 } else { 852 } else {
@@ -883,8 +892,7 @@ e1000_eeprom_test(struct e1000_adapter *adapter, uint64_t *data)
883} 892}
884 893
885static irqreturn_t 894static irqreturn_t
886e1000_test_intr(int irq, 895e1000_test_intr(int irq, void *data)
887 void *data)
888{ 896{
889 struct net_device *netdev = (struct net_device *) data; 897 struct net_device *netdev = (struct net_device *) data;
890 struct e1000_adapter *adapter = netdev_priv(netdev); 898 struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -905,11 +913,11 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
905 913
906 /* NOTE: we don't test MSI interrupts here, yet */ 914 /* NOTE: we don't test MSI interrupts here, yet */
907 /* Hook up test interrupt handler just for this test */ 915 /* Hook up test interrupt handler just for this test */
908 if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, 916 if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
909 netdev->name, netdev)) 917 netdev))
910 shared_int = FALSE; 918 shared_int = FALSE;
911 else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED, 919 else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
912 netdev->name, netdev)) { 920 netdev->name, netdev)) {
913 *data = 1; 921 *data = 1;
914 return -1; 922 return -1;
915 } 923 }
@@ -925,6 +933,7 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
925 933
926 if (adapter->hw.mac_type == e1000_ich8lan && i == 8) 934 if (adapter->hw.mac_type == e1000_ich8lan && i == 8)
927 continue; 935 continue;
936
928 /* Interrupt to test */ 937 /* Interrupt to test */
929 mask = 1 << i; 938 mask = 1 << i;
930 939
@@ -1674,7 +1683,7 @@ e1000_diag_test(struct net_device *netdev,
1674 if (e1000_link_test(adapter, &data[4])) 1683 if (e1000_link_test(adapter, &data[4]))
1675 eth_test->flags |= ETH_TEST_FL_FAILED; 1684 eth_test->flags |= ETH_TEST_FL_FAILED;
1676 1685
1677 /* Offline tests aren't run; pass by default */ 1686 /* Online tests aren't run; pass by default */
1678 data[0] = 0; 1687 data[0] = 0;
1679 data[1] = 0; 1688 data[1] = 0;
1680 data[2] = 0; 1689 data[2] = 0;
@@ -1717,6 +1726,7 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wol
1717 retval = 0; 1726 retval = 0;
1718 break; 1727 break;
1719 case E1000_DEV_ID_82571EB_QUAD_COPPER: 1728 case E1000_DEV_ID_82571EB_QUAD_COPPER:
1729 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
1720 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 1730 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
1721 /* quad port adapters only support WoL on port A */ 1731 /* quad port adapters only support WoL on port A */
1722 if (!adapter->quad_port_a) { 1732 if (!adapter->quad_port_a) {
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index 65077f39da69..3655d902b0bd 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -385,6 +385,7 @@ e1000_set_mac_type(struct e1000_hw *hw)
385 case E1000_DEV_ID_82571EB_FIBER: 385 case E1000_DEV_ID_82571EB_FIBER:
386 case E1000_DEV_ID_82571EB_SERDES: 386 case E1000_DEV_ID_82571EB_SERDES:
387 case E1000_DEV_ID_82571EB_QUAD_COPPER: 387 case E1000_DEV_ID_82571EB_QUAD_COPPER:
388 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
388 hw->mac_type = e1000_82571; 389 hw->mac_type = e1000_82571;
389 break; 390 break;
390 case E1000_DEV_ID_82572EI_COPPER: 391 case E1000_DEV_ID_82572EI_COPPER:
@@ -408,6 +409,8 @@ e1000_set_mac_type(struct e1000_hw *hw)
408 case E1000_DEV_ID_ICH8_IGP_AMT: 409 case E1000_DEV_ID_ICH8_IGP_AMT:
409 case E1000_DEV_ID_ICH8_IGP_C: 410 case E1000_DEV_ID_ICH8_IGP_C:
410 case E1000_DEV_ID_ICH8_IFE: 411 case E1000_DEV_ID_ICH8_IFE:
412 case E1000_DEV_ID_ICH8_IFE_GT:
413 case E1000_DEV_ID_ICH8_IFE_G:
411 case E1000_DEV_ID_ICH8_IGP_M: 414 case E1000_DEV_ID_ICH8_IGP_M:
412 hw->mac_type = e1000_ich8lan; 415 hw->mac_type = e1000_ich8lan;
413 break; 416 break;
@@ -2367,6 +2370,7 @@ e1000_phy_force_speed_duplex(struct e1000_hw *hw)
2367 2370
2368 /* Need to reset the PHY or these changes will be ignored */ 2371 /* Need to reset the PHY or these changes will be ignored */
2369 mii_ctrl_reg |= MII_CR_RESET; 2372 mii_ctrl_reg |= MII_CR_RESET;
2373
2370 /* Disable MDI-X support for 10/100 */ 2374 /* Disable MDI-X support for 10/100 */
2371 } else if (hw->phy_type == e1000_phy_ife) { 2375 } else if (hw->phy_type == e1000_phy_ife) {
2372 ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data); 2376 ret_val = e1000_read_phy_reg(hw, IFE_PHY_MDIX_CONTROL, &phy_data);
@@ -2379,6 +2383,7 @@ e1000_phy_force_speed_duplex(struct e1000_hw *hw)
2379 ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data); 2383 ret_val = e1000_write_phy_reg(hw, IFE_PHY_MDIX_CONTROL, phy_data);
2380 if (ret_val) 2384 if (ret_val)
2381 return ret_val; 2385 return ret_val;
2386
2382 } else { 2387 } else {
2383 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI 2388 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI
2384 * forced whenever speed or duplex are forced. 2389 * forced whenever speed or duplex are forced.
@@ -3868,7 +3873,7 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
3868* 3873*
3869* hw - Struct containing variables accessed by shared code 3874* hw - Struct containing variables accessed by shared code
3870* 3875*
3871* Sets bit 15 of the MII Control regiser 3876* Sets bit 15 of the MII Control register
3872******************************************************************************/ 3877******************************************************************************/
3873int32_t 3878int32_t
3874e1000_phy_reset(struct e1000_hw *hw) 3879e1000_phy_reset(struct e1000_hw *hw)
@@ -3940,14 +3945,15 @@ e1000_phy_powerdown_workaround(struct e1000_hw *hw)
3940 E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE | 3945 E1000_WRITE_REG(hw, PHY_CTRL, reg | E1000_PHY_CTRL_GBE_DISABLE |
3941 E1000_PHY_CTRL_NOND0A_GBE_DISABLE); 3946 E1000_PHY_CTRL_NOND0A_GBE_DISABLE);
3942 3947
3943 /* Write VR power-down enable */ 3948 /* Write VR power-down enable - bits 9:8 should be 10b */
3944 e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data); 3949 e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data);
3945 e1000_write_phy_reg(hw, IGP3_VR_CTRL, phy_data | 3950 phy_data |= (1 << 9);
3946 IGP3_VR_CTRL_MODE_SHUT); 3951 phy_data &= ~(1 << 8);
3952 e1000_write_phy_reg(hw, IGP3_VR_CTRL, phy_data);
3947 3953
3948 /* Read it back and test */ 3954 /* Read it back and test */
3949 e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data); 3955 e1000_read_phy_reg(hw, IGP3_VR_CTRL, &phy_data);
3950 if ((phy_data & IGP3_VR_CTRL_MODE_SHUT) || retry) 3956 if (((phy_data & IGP3_VR_CTRL_MODE_MASK) == IGP3_VR_CTRL_MODE_SHUT) || retry)
3951 break; 3957 break;
3952 3958
3953 /* Issue PHY reset and repeat at most one more time */ 3959 /* Issue PHY reset and repeat at most one more time */
@@ -4549,7 +4555,7 @@ e1000_init_eeprom_params(struct e1000_hw *hw)
4549 case e1000_ich8lan: 4555 case e1000_ich8lan:
4550 { 4556 {
4551 int32_t i = 0; 4557 int32_t i = 0;
4552 uint32_t flash_size = E1000_READ_ICH8_REG(hw, ICH8_FLASH_GFPREG); 4558 uint32_t flash_size = E1000_READ_ICH_FLASH_REG(hw, ICH_FLASH_GFPREG);
4553 4559
4554 eeprom->type = e1000_eeprom_ich8; 4560 eeprom->type = e1000_eeprom_ich8;
4555 eeprom->use_eerd = FALSE; 4561 eeprom->use_eerd = FALSE;
@@ -4565,12 +4571,14 @@ e1000_init_eeprom_params(struct e1000_hw *hw)
4565 } 4571 }
4566 } 4572 }
4567 4573
4568 hw->flash_base_addr = (flash_size & ICH8_GFPREG_BASE_MASK) * 4574 hw->flash_base_addr = (flash_size & ICH_GFPREG_BASE_MASK) *
4569 ICH8_FLASH_SECTOR_SIZE; 4575 ICH_FLASH_SECTOR_SIZE;
4576
4577 hw->flash_bank_size = ((flash_size >> 16) & ICH_GFPREG_BASE_MASK) + 1;
4578 hw->flash_bank_size -= (flash_size & ICH_GFPREG_BASE_MASK);
4579
4580 hw->flash_bank_size *= ICH_FLASH_SECTOR_SIZE;
4570 4581
4571 hw->flash_bank_size = ((flash_size >> 16) & ICH8_GFPREG_BASE_MASK) + 1;
4572 hw->flash_bank_size -= (flash_size & ICH8_GFPREG_BASE_MASK);
4573 hw->flash_bank_size *= ICH8_FLASH_SECTOR_SIZE;
4574 hw->flash_bank_size /= 2 * sizeof(uint16_t); 4582 hw->flash_bank_size /= 2 * sizeof(uint16_t);
4575 4583
4576 break; 4584 break;
@@ -5620,8 +5628,8 @@ e1000_commit_shadow_ram(struct e1000_hw *hw)
5620 * signature is valid. We want to do this after the write 5628 * signature is valid. We want to do this after the write
5621 * has completed so that we don't mark the segment valid 5629 * has completed so that we don't mark the segment valid
5622 * while the write is still in progress */ 5630 * while the write is still in progress */
5623 if (i == E1000_ICH8_NVM_SIG_WORD) 5631 if (i == E1000_ICH_NVM_SIG_WORD)
5624 high_byte = E1000_ICH8_NVM_SIG_MASK | high_byte; 5632 high_byte = E1000_ICH_NVM_SIG_MASK | high_byte;
5625 5633
5626 error = e1000_verify_write_ich8_byte(hw, 5634 error = e1000_verify_write_ich8_byte(hw,
5627 (i << 1) + new_bank_offset + 1, high_byte); 5635 (i << 1) + new_bank_offset + 1, high_byte);
@@ -5643,18 +5651,18 @@ e1000_commit_shadow_ram(struct e1000_hw *hw)
5643 * erase as well since these bits are 11 to start with 5651 * erase as well since these bits are 11 to start with
5644 * and we need to change bit 14 to 0b */ 5652 * and we need to change bit 14 to 0b */
5645 e1000_read_ich8_byte(hw, 5653 e1000_read_ich8_byte(hw,
5646 E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset, 5654 E1000_ICH_NVM_SIG_WORD * 2 + 1 + new_bank_offset,
5647 &high_byte); 5655 &high_byte);
5648 high_byte &= 0xBF; 5656 high_byte &= 0xBF;
5649 error = e1000_verify_write_ich8_byte(hw, 5657 error = e1000_verify_write_ich8_byte(hw,
5650 E1000_ICH8_NVM_SIG_WORD * 2 + 1 + new_bank_offset, high_byte); 5658 E1000_ICH_NVM_SIG_WORD * 2 + 1 + new_bank_offset, high_byte);
5651 /* And invalidate the previously valid segment by setting 5659 /* And invalidate the previously valid segment by setting
5652 * its signature word (0x13) high_byte to 0b. This can be 5660 * its signature word (0x13) high_byte to 0b. This can be
5653 * done without an erase because flash erase sets all bits 5661 * done without an erase because flash erase sets all bits
5654 * to 1's. We can write 1's to 0's without an erase */ 5662 * to 1's. We can write 1's to 0's without an erase */
5655 if (error == E1000_SUCCESS) { 5663 if (error == E1000_SUCCESS) {
5656 error = e1000_verify_write_ich8_byte(hw, 5664 error = e1000_verify_write_ich8_byte(hw,
5657 E1000_ICH8_NVM_SIG_WORD * 2 + 1 + old_bank_offset, 0); 5665 E1000_ICH_NVM_SIG_WORD * 2 + 1 + old_bank_offset, 0);
5658 } 5666 }
5659 5667
5660 /* Clear the now not used entry in the cache */ 5668 /* Clear the now not used entry in the cache */
@@ -5841,6 +5849,7 @@ e1000_mta_set(struct e1000_hw *hw,
5841 hash_reg = (hash_value >> 5) & 0x7F; 5849 hash_reg = (hash_value >> 5) & 0x7F;
5842 if (hw->mac_type == e1000_ich8lan) 5850 if (hw->mac_type == e1000_ich8lan)
5843 hash_reg &= 0x1F; 5851 hash_reg &= 0x1F;
5852
5844 hash_bit = hash_value & 0x1F; 5853 hash_bit = hash_value & 0x1F;
5845 5854
5846 mta = E1000_READ_REG_ARRAY(hw, MTA, hash_reg); 5855 mta = E1000_READ_REG_ARRAY(hw, MTA, hash_reg);
@@ -6026,6 +6035,7 @@ e1000_id_led_init(struct e1000_hw * hw)
6026 else 6035 else
6027 eeprom_data = ID_LED_DEFAULT; 6036 eeprom_data = ID_LED_DEFAULT;
6028 } 6037 }
6038
6029 for (i = 0; i < 4; i++) { 6039 for (i = 0; i < 4; i++) {
6030 temp = (eeprom_data >> (i << 2)) & led_mask; 6040 temp = (eeprom_data >> (i << 2)) & led_mask;
6031 switch (temp) { 6041 switch (temp) {
@@ -8486,7 +8496,7 @@ e1000_ich8_cycle_init(struct e1000_hw *hw)
8486 8496
8487 DEBUGFUNC("e1000_ich8_cycle_init"); 8497 DEBUGFUNC("e1000_ich8_cycle_init");
8488 8498
8489 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8499 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8490 8500
8491 /* May be check the Flash Des Valid bit in Hw status */ 8501 /* May be check the Flash Des Valid bit in Hw status */
8492 if (hsfsts.hsf_status.fldesvalid == 0) { 8502 if (hsfsts.hsf_status.fldesvalid == 0) {
@@ -8499,7 +8509,7 @@ e1000_ich8_cycle_init(struct e1000_hw *hw)
8499 hsfsts.hsf_status.flcerr = 1; 8509 hsfsts.hsf_status.flcerr = 1;
8500 hsfsts.hsf_status.dael = 1; 8510 hsfsts.hsf_status.dael = 1;
8501 8511
8502 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 8512 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
8503 8513
8504 /* Either we should have a hardware SPI cycle in progress bit to check 8514 /* Either we should have a hardware SPI cycle in progress bit to check
8505 * against, in order to start a new cycle or FDONE bit should be changed 8515 * against, in order to start a new cycle or FDONE bit should be changed
@@ -8514,13 +8524,13 @@ e1000_ich8_cycle_init(struct e1000_hw *hw)
8514 /* There is no cycle running at present, so we can start a cycle */ 8524 /* There is no cycle running at present, so we can start a cycle */
8515 /* Begin by setting Flash Cycle Done. */ 8525 /* Begin by setting Flash Cycle Done. */
8516 hsfsts.hsf_status.flcdone = 1; 8526 hsfsts.hsf_status.flcdone = 1;
8517 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 8527 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
8518 error = E1000_SUCCESS; 8528 error = E1000_SUCCESS;
8519 } else { 8529 } else {
8520 /* otherwise poll for sometime so the current cycle has a chance 8530 /* otherwise poll for sometime so the current cycle has a chance
8521 * to end before giving up. */ 8531 * to end before giving up. */
8522 for (i = 0; i < ICH8_FLASH_COMMAND_TIMEOUT; i++) { 8532 for (i = 0; i < ICH_FLASH_COMMAND_TIMEOUT; i++) {
8523 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8533 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8524 if (hsfsts.hsf_status.flcinprog == 0) { 8534 if (hsfsts.hsf_status.flcinprog == 0) {
8525 error = E1000_SUCCESS; 8535 error = E1000_SUCCESS;
8526 break; 8536 break;
@@ -8531,7 +8541,7 @@ e1000_ich8_cycle_init(struct e1000_hw *hw)
8531 /* Successful in waiting for previous cycle to timeout, 8541 /* Successful in waiting for previous cycle to timeout,
8532 * now set the Flash Cycle Done. */ 8542 * now set the Flash Cycle Done. */
8533 hsfsts.hsf_status.flcdone = 1; 8543 hsfsts.hsf_status.flcdone = 1;
8534 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFSTS, hsfsts.regval); 8544 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval);
8535 } else { 8545 } else {
8536 DEBUGOUT("Flash controller busy, cannot get access"); 8546 DEBUGOUT("Flash controller busy, cannot get access");
8537 } 8547 }
@@ -8553,13 +8563,13 @@ e1000_ich8_flash_cycle(struct e1000_hw *hw, uint32_t timeout)
8553 uint32_t i = 0; 8563 uint32_t i = 0;
8554 8564
8555 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ 8565 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
8556 hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8566 hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
8557 hsflctl.hsf_ctrl.flcgo = 1; 8567 hsflctl.hsf_ctrl.flcgo = 1;
8558 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8568 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
8559 8569
8560 /* wait till FDONE bit is set to 1 */ 8570 /* wait till FDONE bit is set to 1 */
8561 do { 8571 do {
8562 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8572 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8563 if (hsfsts.hsf_status.flcdone == 1) 8573 if (hsfsts.hsf_status.flcdone == 1)
8564 break; 8574 break;
8565 udelay(1); 8575 udelay(1);
@@ -8593,10 +8603,10 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
8593 DEBUGFUNC("e1000_read_ich8_data"); 8603 DEBUGFUNC("e1000_read_ich8_data");
8594 8604
8595 if (size < 1 || size > 2 || data == 0x0 || 8605 if (size < 1 || size > 2 || data == 0x0 ||
8596 index > ICH8_FLASH_LINEAR_ADDR_MASK) 8606 index > ICH_FLASH_LINEAR_ADDR_MASK)
8597 return error; 8607 return error;
8598 8608
8599 flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) + 8609 flash_linear_address = (ICH_FLASH_LINEAR_ADDR_MASK & index) +
8600 hw->flash_base_addr; 8610 hw->flash_base_addr;
8601 8611
8602 do { 8612 do {
@@ -8606,25 +8616,25 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
8606 if (error != E1000_SUCCESS) 8616 if (error != E1000_SUCCESS)
8607 break; 8617 break;
8608 8618
8609 hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8619 hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
8610 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ 8620 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
8611 hsflctl.hsf_ctrl.fldbcount = size - 1; 8621 hsflctl.hsf_ctrl.fldbcount = size - 1;
8612 hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_READ; 8622 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ;
8613 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8623 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
8614 8624
8615 /* Write the last 24 bits of index into Flash Linear address field in 8625 /* Write the last 24 bits of index into Flash Linear address field in
8616 * Flash Address */ 8626 * Flash Address */
8617 /* TODO: TBD maybe check the index against the size of flash */ 8627 /* TODO: TBD maybe check the index against the size of flash */
8618 8628
8619 E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 8629 E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
8620 8630
8621 error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_COMMAND_TIMEOUT); 8631 error = e1000_ich8_flash_cycle(hw, ICH_FLASH_COMMAND_TIMEOUT);
8622 8632
8623 /* Check if FCERR is set to 1, if set to 1, clear it and try the whole 8633 /* Check if FCERR is set to 1, if set to 1, clear it and try the whole
8624 * sequence a few more times, else read in (shift in) the Flash Data0, 8634 * sequence a few more times, else read in (shift in) the Flash Data0,
8625 * the order is least significant byte first msb to lsb */ 8635 * the order is least significant byte first msb to lsb */
8626 if (error == E1000_SUCCESS) { 8636 if (error == E1000_SUCCESS) {
8627 flash_data = E1000_READ_ICH8_REG(hw, ICH8_FLASH_FDATA0); 8637 flash_data = E1000_READ_ICH_FLASH_REG(hw, ICH_FLASH_FDATA0);
8628 if (size == 1) { 8638 if (size == 1) {
8629 *data = (uint8_t)(flash_data & 0x000000FF); 8639 *data = (uint8_t)(flash_data & 0x000000FF);
8630 } else if (size == 2) { 8640 } else if (size == 2) {
@@ -8634,9 +8644,9 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
8634 } else { 8644 } else {
8635 /* If we've gotten here, then things are probably completely hosed, 8645 /* If we've gotten here, then things are probably completely hosed,
8636 * but if the error condition is detected, it won't hurt to give 8646 * but if the error condition is detected, it won't hurt to give
8637 * it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times. 8647 * it another try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
8638 */ 8648 */
8639 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8649 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8640 if (hsfsts.hsf_status.flcerr == 1) { 8650 if (hsfsts.hsf_status.flcerr == 1) {
8641 /* Repeat for some time before giving up. */ 8651 /* Repeat for some time before giving up. */
8642 continue; 8652 continue;
@@ -8645,7 +8655,7 @@ e1000_read_ich8_data(struct e1000_hw *hw, uint32_t index,
8645 break; 8655 break;
8646 } 8656 }
8647 } 8657 }
8648 } while (count++ < ICH8_FLASH_CYCLE_REPEAT_COUNT); 8658 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
8649 8659
8650 return error; 8660 return error;
8651} 8661}
@@ -8672,10 +8682,10 @@ e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size,
8672 DEBUGFUNC("e1000_write_ich8_data"); 8682 DEBUGFUNC("e1000_write_ich8_data");
8673 8683
8674 if (size < 1 || size > 2 || data > size * 0xff || 8684 if (size < 1 || size > 2 || data > size * 0xff ||
8675 index > ICH8_FLASH_LINEAR_ADDR_MASK) 8685 index > ICH_FLASH_LINEAR_ADDR_MASK)
8676 return error; 8686 return error;
8677 8687
8678 flash_linear_address = (ICH8_FLASH_LINEAR_ADDR_MASK & index) + 8688 flash_linear_address = (ICH_FLASH_LINEAR_ADDR_MASK & index) +
8679 hw->flash_base_addr; 8689 hw->flash_base_addr;
8680 8690
8681 do { 8691 do {
@@ -8685,34 +8695,34 @@ e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size,
8685 if (error != E1000_SUCCESS) 8695 if (error != E1000_SUCCESS)
8686 break; 8696 break;
8687 8697
8688 hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8698 hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
8689 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ 8699 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
8690 hsflctl.hsf_ctrl.fldbcount = size -1; 8700 hsflctl.hsf_ctrl.fldbcount = size -1;
8691 hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_WRITE; 8701 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE;
8692 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8702 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
8693 8703
8694 /* Write the last 24 bits of index into Flash Linear address field in 8704 /* Write the last 24 bits of index into Flash Linear address field in
8695 * Flash Address */ 8705 * Flash Address */
8696 E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 8706 E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
8697 8707
8698 if (size == 1) 8708 if (size == 1)
8699 flash_data = (uint32_t)data & 0x00FF; 8709 flash_data = (uint32_t)data & 0x00FF;
8700 else 8710 else
8701 flash_data = (uint32_t)data; 8711 flash_data = (uint32_t)data;
8702 8712
8703 E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FDATA0, flash_data); 8713 E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data);
8704 8714
8705 /* check if FCERR is set to 1 , if set to 1, clear it and try the whole 8715 /* check if FCERR is set to 1 , if set to 1, clear it and try the whole
8706 * sequence a few more times else done */ 8716 * sequence a few more times else done */
8707 error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_COMMAND_TIMEOUT); 8717 error = e1000_ich8_flash_cycle(hw, ICH_FLASH_COMMAND_TIMEOUT);
8708 if (error == E1000_SUCCESS) { 8718 if (error == E1000_SUCCESS) {
8709 break; 8719 break;
8710 } else { 8720 } else {
8711 /* If we're here, then things are most likely completely hosed, 8721 /* If we're here, then things are most likely completely hosed,
8712 * but if the error condition is detected, it won't hurt to give 8722 * but if the error condition is detected, it won't hurt to give
8713 * it another try...ICH8_FLASH_CYCLE_REPEAT_COUNT times. 8723 * it another try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
8714 */ 8724 */
8715 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8725 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8716 if (hsfsts.hsf_status.flcerr == 1) { 8726 if (hsfsts.hsf_status.flcerr == 1) {
8717 /* Repeat for some time before giving up. */ 8727 /* Repeat for some time before giving up. */
8718 continue; 8728 continue;
@@ -8721,7 +8731,7 @@ e1000_write_ich8_data(struct e1000_hw *hw, uint32_t index, uint32_t size,
8721 break; 8731 break;
8722 } 8732 }
8723 } 8733 }
8724 } while (count++ < ICH8_FLASH_CYCLE_REPEAT_COUNT); 8734 } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT);
8725 8735
8726 return error; 8736 return error;
8727} 8737}
@@ -8840,7 +8850,7 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8840 int32_t j = 0; 8850 int32_t j = 0;
8841 int32_t error_flag = 0; 8851 int32_t error_flag = 0;
8842 8852
8843 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8853 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8844 8854
8845 /* Determine HW Sector size: Read BERASE bits of Hw flash Status register */ 8855 /* Determine HW Sector size: Read BERASE bits of Hw flash Status register */
8846 /* 00: The Hw sector is 256 bytes, hence we need to erase 16 8856 /* 00: The Hw sector is 256 bytes, hence we need to erase 16
@@ -8853,19 +8863,14 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8853 * 11: The Hw sector size is 64K bytes */ 8863 * 11: The Hw sector size is 64K bytes */
8854 if (hsfsts.hsf_status.berasesz == 0x0) { 8864 if (hsfsts.hsf_status.berasesz == 0x0) {
8855 /* Hw sector size 256 */ 8865 /* Hw sector size 256 */
8856 sub_sector_size = ICH8_FLASH_SEG_SIZE_256; 8866 sub_sector_size = ICH_FLASH_SEG_SIZE_256;
8857 bank_size = ICH8_FLASH_SECTOR_SIZE; 8867 bank_size = ICH_FLASH_SECTOR_SIZE;
8858 iteration = ICH8_FLASH_SECTOR_SIZE / ICH8_FLASH_SEG_SIZE_256; 8868 iteration = ICH_FLASH_SECTOR_SIZE / ICH_FLASH_SEG_SIZE_256;
8859 } else if (hsfsts.hsf_status.berasesz == 0x1) { 8869 } else if (hsfsts.hsf_status.berasesz == 0x1) {
8860 bank_size = ICH8_FLASH_SEG_SIZE_4K; 8870 bank_size = ICH_FLASH_SEG_SIZE_4K;
8861 iteration = 1;
8862 } else if (hw->mac_type != e1000_ich8lan &&
8863 hsfsts.hsf_status.berasesz == 0x2) {
8864 /* 8K erase size invalid for ICH8 - added in for ICH9 */
8865 bank_size = ICH9_FLASH_SEG_SIZE_8K;
8866 iteration = 1; 8871 iteration = 1;
8867 } else if (hsfsts.hsf_status.berasesz == 0x3) { 8872 } else if (hsfsts.hsf_status.berasesz == 0x3) {
8868 bank_size = ICH8_FLASH_SEG_SIZE_64K; 8873 bank_size = ICH_FLASH_SEG_SIZE_64K;
8869 iteration = 1; 8874 iteration = 1;
8870 } else { 8875 } else {
8871 return error; 8876 return error;
@@ -8883,9 +8888,9 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8883 8888
8884 /* Write a value 11 (block Erase) in Flash Cycle field in Hw flash 8889 /* Write a value 11 (block Erase) in Flash Cycle field in Hw flash
8885 * Control */ 8890 * Control */
8886 hsflctl.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFCTL); 8891 hsflctl.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL);
8887 hsflctl.hsf_ctrl.flcycle = ICH8_CYCLE_ERASE; 8892 hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE;
8888 E1000_WRITE_ICH8_REG16(hw, ICH8_FLASH_HSFCTL, hsflctl.regval); 8893 E1000_WRITE_ICH_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval);
8889 8894
8890 /* Write the last 24 bits of an index within the block into Flash 8895 /* Write the last 24 bits of an index within the block into Flash
8891 * Linear address field in Flash Address. This probably needs to 8896 * Linear address field in Flash Address. This probably needs to
@@ -8893,17 +8898,17 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8893 * the software bank size (4, 8 or 64 KBytes) */ 8898 * the software bank size (4, 8 or 64 KBytes) */
8894 flash_linear_address = bank * bank_size + j * sub_sector_size; 8899 flash_linear_address = bank * bank_size + j * sub_sector_size;
8895 flash_linear_address += hw->flash_base_addr; 8900 flash_linear_address += hw->flash_base_addr;
8896 flash_linear_address &= ICH8_FLASH_LINEAR_ADDR_MASK; 8901 flash_linear_address &= ICH_FLASH_LINEAR_ADDR_MASK;
8897 8902
8898 E1000_WRITE_ICH8_REG(hw, ICH8_FLASH_FADDR, flash_linear_address); 8903 E1000_WRITE_ICH_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_address);
8899 8904
8900 error = e1000_ich8_flash_cycle(hw, ICH8_FLASH_ERASE_TIMEOUT); 8905 error = e1000_ich8_flash_cycle(hw, ICH_FLASH_ERASE_TIMEOUT);
8901 /* Check if FCERR is set to 1. If 1, clear it and try the whole 8906 /* Check if FCERR is set to 1. If 1, clear it and try the whole
8902 * sequence a few more times else Done */ 8907 * sequence a few more times else Done */
8903 if (error == E1000_SUCCESS) { 8908 if (error == E1000_SUCCESS) {
8904 break; 8909 break;
8905 } else { 8910 } else {
8906 hsfsts.regval = E1000_READ_ICH8_REG16(hw, ICH8_FLASH_HSFSTS); 8911 hsfsts.regval = E1000_READ_ICH_FLASH_REG16(hw, ICH_FLASH_HSFSTS);
8907 if (hsfsts.hsf_status.flcerr == 1) { 8912 if (hsfsts.hsf_status.flcerr == 1) {
8908 /* repeat for some time before giving up */ 8913 /* repeat for some time before giving up */
8909 continue; 8914 continue;
@@ -8912,7 +8917,7 @@ e1000_erase_ich8_4k_segment(struct e1000_hw *hw, uint32_t bank)
8912 break; 8917 break;
8913 } 8918 }
8914 } 8919 }
8915 } while ((count < ICH8_FLASH_CYCLE_REPEAT_COUNT) && !error_flag); 8920 } while ((count < ICH_FLASH_CYCLE_REPEAT_COUNT) && !error_flag);
8916 if (error_flag == 1) 8921 if (error_flag == 1)
8917 break; 8922 break;
8918 } 8923 }
@@ -9013,5 +9018,3 @@ e1000_init_lcd_from_nvm(struct e1000_hw *hw)
9013 return E1000_SUCCESS; 9018 return E1000_SUCCESS;
9014} 9019}
9015 9020
9016
9017
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 449a60303e07..3321fb13bfa9 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -128,11 +128,13 @@ typedef enum {
128/* PCI bus widths */ 128/* PCI bus widths */
129typedef enum { 129typedef enum {
130 e1000_bus_width_unknown = 0, 130 e1000_bus_width_unknown = 0,
131 /* These PCIe values should literally match the possible return values
132 * from config space */
133 e1000_bus_width_pciex_1 = 1,
134 e1000_bus_width_pciex_2 = 2,
135 e1000_bus_width_pciex_4 = 4,
131 e1000_bus_width_32, 136 e1000_bus_width_32,
132 e1000_bus_width_64, 137 e1000_bus_width_64,
133 e1000_bus_width_pciex_1,
134 e1000_bus_width_pciex_2,
135 e1000_bus_width_pciex_4,
136 e1000_bus_width_reserved 138 e1000_bus_width_reserved
137} e1000_bus_width; 139} e1000_bus_width;
138 140
@@ -326,6 +328,7 @@ int32_t e1000_phy_hw_reset(struct e1000_hw *hw);
326int32_t e1000_phy_reset(struct e1000_hw *hw); 328int32_t e1000_phy_reset(struct e1000_hw *hw);
327int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info); 329int32_t e1000_phy_get_info(struct e1000_hw *hw, struct e1000_phy_info *phy_info);
328int32_t e1000_validate_mdi_setting(struct e1000_hw *hw); 330int32_t e1000_validate_mdi_setting(struct e1000_hw *hw);
331
329void e1000_phy_powerdown_workaround(struct e1000_hw *hw); 332void e1000_phy_powerdown_workaround(struct e1000_hw *hw);
330 333
331/* EEPROM Functions */ 334/* EEPROM Functions */
@@ -390,7 +393,6 @@ int32_t e1000_mng_write_dhcp_info(struct e1000_hw *hw, uint8_t *buffer,
390 uint16_t length); 393 uint16_t length);
391boolean_t e1000_check_mng_mode(struct e1000_hw *hw); 394boolean_t e1000_check_mng_mode(struct e1000_hw *hw);
392boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw); 395boolean_t e1000_enable_tx_pkt_filtering(struct e1000_hw *hw);
393
394int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data); 396int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t reg, uint16_t words, uint16_t *data);
395int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw); 397int32_t e1000_validate_eeprom_checksum(struct e1000_hw *hw);
396int32_t e1000_update_eeprom_checksum(struct e1000_hw *hw); 398int32_t e1000_update_eeprom_checksum(struct e1000_hw *hw);
@@ -473,6 +475,7 @@ int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
473#define E1000_DEV_ID_82571EB_FIBER 0x105F 475#define E1000_DEV_ID_82571EB_FIBER 0x105F
474#define E1000_DEV_ID_82571EB_SERDES 0x1060 476#define E1000_DEV_ID_82571EB_SERDES 0x1060
475#define E1000_DEV_ID_82571EB_QUAD_COPPER 0x10A4 477#define E1000_DEV_ID_82571EB_QUAD_COPPER 0x10A4
478#define E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE 0x10BC
476#define E1000_DEV_ID_82572EI_COPPER 0x107D 479#define E1000_DEV_ID_82572EI_COPPER 0x107D
477#define E1000_DEV_ID_82572EI_FIBER 0x107E 480#define E1000_DEV_ID_82572EI_FIBER 0x107E
478#define E1000_DEV_ID_82572EI_SERDES 0x107F 481#define E1000_DEV_ID_82572EI_SERDES 0x107F
@@ -490,6 +493,8 @@ int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
490#define E1000_DEV_ID_ICH8_IGP_AMT 0x104A 493#define E1000_DEV_ID_ICH8_IGP_AMT 0x104A
491#define E1000_DEV_ID_ICH8_IGP_C 0x104B 494#define E1000_DEV_ID_ICH8_IGP_C 0x104B
492#define E1000_DEV_ID_ICH8_IFE 0x104C 495#define E1000_DEV_ID_ICH8_IFE 0x104C
496#define E1000_DEV_ID_ICH8_IFE_GT 0x10C4
497#define E1000_DEV_ID_ICH8_IFE_G 0x10C5
493#define E1000_DEV_ID_ICH8_IGP_M 0x104D 498#define E1000_DEV_ID_ICH8_IGP_M 0x104D
494 499
495 500
@@ -576,6 +581,7 @@ int32_t e1000_check_phy_reset_block(struct e1000_hw *hw);
576 * E1000_RAR_ENTRIES - 1 multicast addresses. 581 * E1000_RAR_ENTRIES - 1 multicast addresses.
577 */ 582 */
578#define E1000_RAR_ENTRIES 15 583#define E1000_RAR_ENTRIES 15
584
579#define E1000_RAR_ENTRIES_ICH8LAN 6 585#define E1000_RAR_ENTRIES_ICH8LAN 6
580 586
581#define MIN_NUMBER_OF_DESCRIPTORS 8 587#define MIN_NUMBER_OF_DESCRIPTORS 8
@@ -1335,9 +1341,9 @@ struct e1000_hw_stats {
1335 uint64_t gotch; 1341 uint64_t gotch;
1336 uint64_t rnbc; 1342 uint64_t rnbc;
1337 uint64_t ruc; 1343 uint64_t ruc;
1344 uint64_t rfc;
1338 uint64_t roc; 1345 uint64_t roc;
1339 uint64_t rlerrc; 1346 uint64_t rlerrc;
1340 uint64_t rfc;
1341 uint64_t rjc; 1347 uint64_t rjc;
1342 uint64_t mgprc; 1348 uint64_t mgprc;
1343 uint64_t mgpdc; 1349 uint64_t mgpdc;
@@ -1577,8 +1583,8 @@ struct e1000_hw {
1577#define E1000_HICR_FW_RESET 0xC0 1583#define E1000_HICR_FW_RESET 0xC0
1578 1584
1579#define E1000_SHADOW_RAM_WORDS 2048 1585#define E1000_SHADOW_RAM_WORDS 2048
1580#define E1000_ICH8_NVM_SIG_WORD 0x13 1586#define E1000_ICH_NVM_SIG_WORD 0x13
1581#define E1000_ICH8_NVM_SIG_MASK 0xC0 1587#define E1000_ICH_NVM_SIG_MASK 0xC0
1582 1588
1583/* EEPROM Read */ 1589/* EEPROM Read */
1584#define E1000_EERD_START 0x00000001 /* Start Read */ 1590#define E1000_EERD_START 0x00000001 /* Start Read */
@@ -3172,6 +3178,7 @@ struct e1000_host_command_info {
3172#define IGP3_VR_CTRL \ 3178#define IGP3_VR_CTRL \
3173 PHY_REG(776, 18) /* Voltage regulator control register */ 3179 PHY_REG(776, 18) /* Voltage regulator control register */
3174#define IGP3_VR_CTRL_MODE_SHUT 0x0200 /* Enter powerdown, shutdown VRs */ 3180#define IGP3_VR_CTRL_MODE_SHUT 0x0200 /* Enter powerdown, shutdown VRs */
3181#define IGP3_VR_CTRL_MODE_MASK 0x0300 /* Shutdown VR Mask */
3175 3182
3176#define IGP3_CAPABILITY \ 3183#define IGP3_CAPABILITY \
3177 PHY_REG(776, 19) /* IGP3 Capability Register */ 3184 PHY_REG(776, 19) /* IGP3 Capability Register */
@@ -3256,41 +3263,40 @@ struct e1000_host_command_info {
3256#define IFE_PSCL_PROBE_LEDS_OFF 0x0006 /* Force LEDs 0 and 2 off */ 3263#define IFE_PSCL_PROBE_LEDS_OFF 0x0006 /* Force LEDs 0 and 2 off */
3257#define IFE_PSCL_PROBE_LEDS_ON 0x0007 /* Force LEDs 0 and 2 on */ 3264#define IFE_PSCL_PROBE_LEDS_ON 0x0007 /* Force LEDs 0 and 2 on */
3258 3265
3259#define ICH8_FLASH_COMMAND_TIMEOUT 5000 /* 5000 uSecs - adjusted */ 3266#define ICH_FLASH_COMMAND_TIMEOUT 5000 /* 5000 uSecs - adjusted */
3260#define ICH8_FLASH_ERASE_TIMEOUT 3000000 /* Up to 3 seconds - worst case */ 3267#define ICH_FLASH_ERASE_TIMEOUT 3000000 /* Up to 3 seconds - worst case */
3261#define ICH8_FLASH_CYCLE_REPEAT_COUNT 10 /* 10 cycles */ 3268#define ICH_FLASH_CYCLE_REPEAT_COUNT 10 /* 10 cycles */
3262#define ICH8_FLASH_SEG_SIZE_256 256 3269#define ICH_FLASH_SEG_SIZE_256 256
3263#define ICH8_FLASH_SEG_SIZE_4K 4096 3270#define ICH_FLASH_SEG_SIZE_4K 4096
3264#define ICH9_FLASH_SEG_SIZE_8K 8192 3271#define ICH_FLASH_SEG_SIZE_64K 65536
3265#define ICH8_FLASH_SEG_SIZE_64K 65536 3272
3266 3273#define ICH_CYCLE_READ 0x0
3267#define ICH8_CYCLE_READ 0x0 3274#define ICH_CYCLE_RESERVED 0x1
3268#define ICH8_CYCLE_RESERVED 0x1 3275#define ICH_CYCLE_WRITE 0x2
3269#define ICH8_CYCLE_WRITE 0x2 3276#define ICH_CYCLE_ERASE 0x3
3270#define ICH8_CYCLE_ERASE 0x3 3277
3271 3278#define ICH_FLASH_GFPREG 0x0000
3272#define ICH8_FLASH_GFPREG 0x0000 3279#define ICH_FLASH_HSFSTS 0x0004
3273#define ICH8_FLASH_HSFSTS 0x0004 3280#define ICH_FLASH_HSFCTL 0x0006
3274#define ICH8_FLASH_HSFCTL 0x0006 3281#define ICH_FLASH_FADDR 0x0008
3275#define ICH8_FLASH_FADDR 0x0008 3282#define ICH_FLASH_FDATA0 0x0010
3276#define ICH8_FLASH_FDATA0 0x0010 3283#define ICH_FLASH_FRACC 0x0050
3277#define ICH8_FLASH_FRACC 0x0050 3284#define ICH_FLASH_FREG0 0x0054
3278#define ICH8_FLASH_FREG0 0x0054 3285#define ICH_FLASH_FREG1 0x0058
3279#define ICH8_FLASH_FREG1 0x0058 3286#define ICH_FLASH_FREG2 0x005C
3280#define ICH8_FLASH_FREG2 0x005C 3287#define ICH_FLASH_FREG3 0x0060
3281#define ICH8_FLASH_FREG3 0x0060 3288#define ICH_FLASH_FPR0 0x0074
3282#define ICH8_FLASH_FPR0 0x0074 3289#define ICH_FLASH_FPR1 0x0078
3283#define ICH8_FLASH_FPR1 0x0078 3290#define ICH_FLASH_SSFSTS 0x0090
3284#define ICH8_FLASH_SSFSTS 0x0090 3291#define ICH_FLASH_SSFCTL 0x0092
3285#define ICH8_FLASH_SSFCTL 0x0092 3292#define ICH_FLASH_PREOP 0x0094
3286#define ICH8_FLASH_PREOP 0x0094 3293#define ICH_FLASH_OPTYPE 0x0096
3287#define ICH8_FLASH_OPTYPE 0x0096 3294#define ICH_FLASH_OPMENU 0x0098
3288#define ICH8_FLASH_OPMENU 0x0098 3295
3289 3296#define ICH_FLASH_REG_MAPSIZE 0x00A0
3290#define ICH8_FLASH_REG_MAPSIZE 0x00A0 3297#define ICH_FLASH_SECTOR_SIZE 4096
3291#define ICH8_FLASH_SECTOR_SIZE 4096 3298#define ICH_GFPREG_BASE_MASK 0x1FFF
3292#define ICH8_GFPREG_BASE_MASK 0x1FFF 3299#define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
3293#define ICH8_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
3294 3300
3295/* ICH8 GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ 3301/* ICH8 GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
3296/* Offset 04h HSFSTS */ 3302/* Offset 04h HSFSTS */
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 03294400bc90..73f3a85fd238 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -27,6 +27,7 @@
27*******************************************************************************/ 27*******************************************************************************/
28 28
29#include "e1000.h" 29#include "e1000.h"
30#include <net/ip6_checksum.h>
30 31
31char e1000_driver_name[] = "e1000"; 32char e1000_driver_name[] = "e1000";
32static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; 33static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
@@ -35,7 +36,7 @@ static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver";
35#else 36#else
36#define DRIVERNAPI "-NAPI" 37#define DRIVERNAPI "-NAPI"
37#endif 38#endif
38#define DRV_VERSION "7.2.9-k4"DRIVERNAPI 39#define DRV_VERSION "7.3.15-k2"DRIVERNAPI
39char e1000_driver_version[] = DRV_VERSION; 40char e1000_driver_version[] = DRV_VERSION;
40static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; 41static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
41 42
@@ -103,6 +104,9 @@ static struct pci_device_id e1000_pci_tbl[] = {
103 INTEL_E1000_ETHERNET_DEVICE(0x10B9), 104 INTEL_E1000_ETHERNET_DEVICE(0x10B9),
104 INTEL_E1000_ETHERNET_DEVICE(0x10BA), 105 INTEL_E1000_ETHERNET_DEVICE(0x10BA),
105 INTEL_E1000_ETHERNET_DEVICE(0x10BB), 106 INTEL_E1000_ETHERNET_DEVICE(0x10BB),
107 INTEL_E1000_ETHERNET_DEVICE(0x10BC),
108 INTEL_E1000_ETHERNET_DEVICE(0x10C4),
109 INTEL_E1000_ETHERNET_DEVICE(0x10C5),
106 /* required last entry */ 110 /* required last entry */
107 {0,} 111 {0,}
108}; 112};
@@ -154,6 +158,9 @@ static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
154static int e1000_change_mtu(struct net_device *netdev, int new_mtu); 158static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
155static int e1000_set_mac(struct net_device *netdev, void *p); 159static int e1000_set_mac(struct net_device *netdev, void *p);
156static irqreturn_t e1000_intr(int irq, void *data); 160static irqreturn_t e1000_intr(int irq, void *data);
161#ifdef CONFIG_PCI_MSI
162static irqreturn_t e1000_intr_msi(int irq, void *data);
163#endif
157static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter, 164static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter,
158 struct e1000_tx_ring *tx_ring); 165 struct e1000_tx_ring *tx_ring);
159#ifdef CONFIG_E1000_NAPI 166#ifdef CONFIG_E1000_NAPI
@@ -285,7 +292,7 @@ static int e1000_request_irq(struct e1000_adapter *adapter)
285 292
286 flags = IRQF_SHARED; 293 flags = IRQF_SHARED;
287#ifdef CONFIG_PCI_MSI 294#ifdef CONFIG_PCI_MSI
288 if (adapter->hw.mac_type > e1000_82547_rev_2) { 295 if (adapter->hw.mac_type >= e1000_82571) {
289 adapter->have_msi = TRUE; 296 adapter->have_msi = TRUE;
290 if ((err = pci_enable_msi(adapter->pdev))) { 297 if ((err = pci_enable_msi(adapter->pdev))) {
291 DPRINTK(PROBE, ERR, 298 DPRINTK(PROBE, ERR,
@@ -293,8 +300,14 @@ static int e1000_request_irq(struct e1000_adapter *adapter)
293 adapter->have_msi = FALSE; 300 adapter->have_msi = FALSE;
294 } 301 }
295 } 302 }
296 if (adapter->have_msi) 303 if (adapter->have_msi) {
297 flags &= ~IRQF_SHARED; 304 flags &= ~IRQF_SHARED;
305 err = request_irq(adapter->pdev->irq, &e1000_intr_msi, flags,
306 netdev->name, netdev);
307 if (err)
308 DPRINTK(PROBE, ERR,
309 "Unable to allocate interrupt Error: %d\n", err);
310 } else
298#endif 311#endif
299 if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags, 312 if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags,
300 netdev->name, netdev))) 313 netdev->name, netdev)))
@@ -375,7 +388,7 @@ e1000_update_mng_vlan(struct e1000_adapter *adapter)
375 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit. 388 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit.
376 * For ASF and Pass Through versions of f/w this means that the 389 * For ASF and Pass Through versions of f/w this means that the
377 * driver is no longer loaded. For AMT version (only with 82573) i 390 * driver is no longer loaded. For AMT version (only with 82573) i
378 * of the f/w this means that the netowrk i/f is closed. 391 * of the f/w this means that the network i/f is closed.
379 * 392 *
380 **/ 393 **/
381 394
@@ -416,7 +429,7 @@ e1000_release_hw_control(struct e1000_adapter *adapter)
416 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit. 429 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
417 * For ASF and Pass Through versions of f/w this means that 430 * For ASF and Pass Through versions of f/w this means that
418 * the driver is loaded. For AMT version (only with 82573) 431 * the driver is loaded. For AMT version (only with 82573)
419 * of the f/w this means that the netowrk i/f is open. 432 * of the f/w this means that the network i/f is open.
420 * 433 *
421 **/ 434 **/
422 435
@@ -426,6 +439,7 @@ e1000_get_hw_control(struct e1000_adapter *adapter)
426 uint32_t ctrl_ext; 439 uint32_t ctrl_ext;
427 uint32_t swsm; 440 uint32_t swsm;
428 uint32_t extcnf; 441 uint32_t extcnf;
442
429 /* Let firmware know the driver has taken over */ 443 /* Let firmware know the driver has taken over */
430 switch (adapter->hw.mac_type) { 444 switch (adapter->hw.mac_type) {
431 case e1000_82571: 445 case e1000_82571:
@@ -601,9 +615,6 @@ void
601e1000_reset(struct e1000_adapter *adapter) 615e1000_reset(struct e1000_adapter *adapter)
602{ 616{
603 uint32_t pba, manc; 617 uint32_t pba, manc;
604#ifdef DISABLE_MULR
605 uint32_t tctl;
606#endif
607 uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF; 618 uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
608 619
609 /* Repartition Pba for greater than 9k mtu 620 /* Repartition Pba for greater than 9k mtu
@@ -670,12 +681,7 @@ e1000_reset(struct e1000_adapter *adapter)
670 e1000_reset_hw(&adapter->hw); 681 e1000_reset_hw(&adapter->hw);
671 if (adapter->hw.mac_type >= e1000_82544) 682 if (adapter->hw.mac_type >= e1000_82544)
672 E1000_WRITE_REG(&adapter->hw, WUC, 0); 683 E1000_WRITE_REG(&adapter->hw, WUC, 0);
673#ifdef DISABLE_MULR
674 /* disable Multiple Reads in Transmit Control Register for debugging */
675 tctl = E1000_READ_REG(hw, TCTL);
676 E1000_WRITE_REG(hw, TCTL, tctl & ~E1000_TCTL_MULR);
677 684
678#endif
679 if (e1000_init_hw(&adapter->hw)) 685 if (e1000_init_hw(&adapter->hw))
680 DPRINTK(PROBE, ERR, "Hardware Error\n"); 686 DPRINTK(PROBE, ERR, "Hardware Error\n");
681 e1000_update_mng_vlan(adapter); 687 e1000_update_mng_vlan(adapter);
@@ -851,9 +857,9 @@ e1000_probe(struct pci_dev *pdev,
851 (adapter->hw.mac_type != e1000_82547)) 857 (adapter->hw.mac_type != e1000_82547))
852 netdev->features |= NETIF_F_TSO; 858 netdev->features |= NETIF_F_TSO;
853 859
854#ifdef NETIF_F_TSO_IPV6 860#ifdef NETIF_F_TSO6
855 if (adapter->hw.mac_type > e1000_82547_rev_2) 861 if (adapter->hw.mac_type > e1000_82547_rev_2)
856 netdev->features |= NETIF_F_TSO_IPV6; 862 netdev->features |= NETIF_F_TSO6;
857#endif 863#endif
858#endif 864#endif
859 if (pci_using_dac) 865 if (pci_using_dac)
@@ -967,6 +973,7 @@ e1000_probe(struct pci_dev *pdev,
967 break; 973 break;
968 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: 974 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
969 case E1000_DEV_ID_82571EB_QUAD_COPPER: 975 case E1000_DEV_ID_82571EB_QUAD_COPPER:
976 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
970 /* if quad port adapter, disable WoL on all but port A */ 977 /* if quad port adapter, disable WoL on all but port A */
971 if (global_quad_port_a != 0) 978 if (global_quad_port_a != 0)
972 adapter->eeprom_wol = 0; 979 adapter->eeprom_wol = 0;
@@ -1278,12 +1285,10 @@ e1000_open(struct net_device *netdev)
1278 return -EBUSY; 1285 return -EBUSY;
1279 1286
1280 /* allocate transmit descriptors */ 1287 /* allocate transmit descriptors */
1281
1282 if ((err = e1000_setup_all_tx_resources(adapter))) 1288 if ((err = e1000_setup_all_tx_resources(adapter)))
1283 goto err_setup_tx; 1289 goto err_setup_tx;
1284 1290
1285 /* allocate receive descriptors */ 1291 /* allocate receive descriptors */
1286
1287 if ((err = e1000_setup_all_rx_resources(adapter))) 1292 if ((err = e1000_setup_all_rx_resources(adapter)))
1288 goto err_setup_rx; 1293 goto err_setup_rx;
1289 1294
@@ -1568,6 +1573,8 @@ e1000_configure_tx(struct e1000_adapter *adapter)
1568 1573
1569 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) { 1574 if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
1570 tarc = E1000_READ_REG(hw, TARC0); 1575 tarc = E1000_READ_REG(hw, TARC0);
1576 /* set the speed mode bit, we'll clear it if we're not at
1577 * gigabit link later */
1571 tarc |= (1 << 21); 1578 tarc |= (1 << 21);
1572 E1000_WRITE_REG(hw, TARC0, tarc); 1579 E1000_WRITE_REG(hw, TARC0, tarc);
1573 } else if (hw->mac_type == e1000_80003es2lan) { 1580 } else if (hw->mac_type == e1000_80003es2lan) {
@@ -1582,8 +1589,11 @@ e1000_configure_tx(struct e1000_adapter *adapter)
1582 e1000_config_collision_dist(hw); 1589 e1000_config_collision_dist(hw);
1583 1590
1584 /* Setup Transmit Descriptor Settings for eop descriptor */ 1591 /* Setup Transmit Descriptor Settings for eop descriptor */
1585 adapter->txd_cmd = E1000_TXD_CMD_IDE | E1000_TXD_CMD_EOP | 1592 adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
1586 E1000_TXD_CMD_IFCS; 1593
1594 /* only set IDE if we are delaying interrupts using the timers */
1595 if (adapter->tx_int_delay)
1596 adapter->txd_cmd |= E1000_TXD_CMD_IDE;
1587 1597
1588 if (hw->mac_type < e1000_82543) 1598 if (hw->mac_type < e1000_82543)
1589 adapter->txd_cmd |= E1000_TXD_CMD_RPS; 1599 adapter->txd_cmd |= E1000_TXD_CMD_RPS;
@@ -1820,8 +1830,11 @@ e1000_setup_rctl(struct e1000_adapter *adapter)
1820 /* Configure extra packet-split registers */ 1830 /* Configure extra packet-split registers */
1821 rfctl = E1000_READ_REG(&adapter->hw, RFCTL); 1831 rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
1822 rfctl |= E1000_RFCTL_EXTEN; 1832 rfctl |= E1000_RFCTL_EXTEN;
1823 /* disable IPv6 packet split support */ 1833 /* disable packet split support for IPv6 extension headers,
1824 rfctl |= E1000_RFCTL_IPV6_DIS; 1834 * because some malformed IPv6 headers can hang the RX */
1835 rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
1836 E1000_RFCTL_NEW_IPV6_EXT_DIS);
1837
1825 E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl); 1838 E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
1826 1839
1827 rctl |= E1000_RCTL_DTYP_PS; 1840 rctl |= E1000_RCTL_DTYP_PS;
@@ -1884,7 +1897,7 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1884 1897
1885 if (hw->mac_type >= e1000_82540) { 1898 if (hw->mac_type >= e1000_82540) {
1886 E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay); 1899 E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
1887 if (adapter->itr > 1) 1900 if (adapter->itr_setting != 0)
1888 E1000_WRITE_REG(hw, ITR, 1901 E1000_WRITE_REG(hw, ITR,
1889 1000000000 / (adapter->itr * 256)); 1902 1000000000 / (adapter->itr * 256));
1890 } 1903 }
@@ -1894,11 +1907,11 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1894 /* Reset delay timers after every interrupt */ 1907 /* Reset delay timers after every interrupt */
1895 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR; 1908 ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
1896#ifdef CONFIG_E1000_NAPI 1909#ifdef CONFIG_E1000_NAPI
1897 /* Auto-Mask interrupts upon ICR read. */ 1910 /* Auto-Mask interrupts upon ICR access */
1898 ctrl_ext |= E1000_CTRL_EXT_IAME; 1911 ctrl_ext |= E1000_CTRL_EXT_IAME;
1912 E1000_WRITE_REG(hw, IAM, 0xffffffff);
1899#endif 1913#endif
1900 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); 1914 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
1901 E1000_WRITE_REG(hw, IAM, ~0);
1902 E1000_WRITE_FLUSH(hw); 1915 E1000_WRITE_FLUSH(hw);
1903 } 1916 }
1904 1917
@@ -1937,6 +1950,12 @@ e1000_configure_rx(struct e1000_adapter *adapter)
1937 E1000_WRITE_REG(hw, RXCSUM, rxcsum); 1950 E1000_WRITE_REG(hw, RXCSUM, rxcsum);
1938 } 1951 }
1939 1952
1953 /* enable early receives on 82573, only takes effect if using > 2048
1954 * byte total frame size. for example only for jumbo frames */
1955#define E1000_ERT_2048 0x100
1956 if (hw->mac_type == e1000_82573)
1957 E1000_WRITE_REG(hw, ERT, E1000_ERT_2048);
1958
1940 /* Enable Receives */ 1959 /* Enable Receives */
1941 E1000_WRITE_REG(hw, RCTL, rctl); 1960 E1000_WRITE_REG(hw, RCTL, rctl);
1942} 1961}
@@ -1990,10 +2009,13 @@ e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
1990 buffer_info->dma, 2009 buffer_info->dma,
1991 buffer_info->length, 2010 buffer_info->length,
1992 PCI_DMA_TODEVICE); 2011 PCI_DMA_TODEVICE);
2012 buffer_info->dma = 0;
1993 } 2013 }
1994 if (buffer_info->skb) 2014 if (buffer_info->skb) {
1995 dev_kfree_skb_any(buffer_info->skb); 2015 dev_kfree_skb_any(buffer_info->skb);
1996 memset(buffer_info, 0, sizeof(struct e1000_buffer)); 2016 buffer_info->skb = NULL;
2017 }
2018 /* buffer_info must be completely set up in the transmit path */
1997} 2019}
1998 2020
1999/** 2021/**
@@ -2417,6 +2439,7 @@ e1000_watchdog(unsigned long data)
2417 DPRINTK(LINK, INFO, 2439 DPRINTK(LINK, INFO,
2418 "Gigabit has been disabled, downgrading speed\n"); 2440 "Gigabit has been disabled, downgrading speed\n");
2419 } 2441 }
2442
2420 if (adapter->hw.mac_type == e1000_82573) { 2443 if (adapter->hw.mac_type == e1000_82573) {
2421 e1000_enable_tx_pkt_filtering(&adapter->hw); 2444 e1000_enable_tx_pkt_filtering(&adapter->hw);
2422 if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id) 2445 if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)
@@ -2461,13 +2484,12 @@ e1000_watchdog(unsigned long data)
2461 if ((adapter->hw.mac_type == e1000_82571 || 2484 if ((adapter->hw.mac_type == e1000_82571 ||
2462 adapter->hw.mac_type == e1000_82572) && 2485 adapter->hw.mac_type == e1000_82572) &&
2463 txb2b == 0) { 2486 txb2b == 0) {
2464#define SPEED_MODE_BIT (1 << 21)
2465 uint32_t tarc0; 2487 uint32_t tarc0;
2466 tarc0 = E1000_READ_REG(&adapter->hw, TARC0); 2488 tarc0 = E1000_READ_REG(&adapter->hw, TARC0);
2467 tarc0 &= ~SPEED_MODE_BIT; 2489 tarc0 &= ~(1 << 21);
2468 E1000_WRITE_REG(&adapter->hw, TARC0, tarc0); 2490 E1000_WRITE_REG(&adapter->hw, TARC0, tarc0);
2469 } 2491 }
2470 2492
2471#ifdef NETIF_F_TSO 2493#ifdef NETIF_F_TSO
2472 /* disable TSO for pcie and 10/100 speeds, to avoid 2494 /* disable TSO for pcie and 10/100 speeds, to avoid
2473 * some hardware issues */ 2495 * some hardware issues */
@@ -2479,9 +2501,15 @@ e1000_watchdog(unsigned long data)
2479 DPRINTK(PROBE,INFO, 2501 DPRINTK(PROBE,INFO,
2480 "10/100 speed: disabling TSO\n"); 2502 "10/100 speed: disabling TSO\n");
2481 netdev->features &= ~NETIF_F_TSO; 2503 netdev->features &= ~NETIF_F_TSO;
2504#ifdef NETIF_F_TSO6
2505 netdev->features &= ~NETIF_F_TSO6;
2506#endif
2482 break; 2507 break;
2483 case SPEED_1000: 2508 case SPEED_1000:
2484 netdev->features |= NETIF_F_TSO; 2509 netdev->features |= NETIF_F_TSO;
2510#ifdef NETIF_F_TSO6
2511 netdev->features |= NETIF_F_TSO6;
2512#endif
2485 break; 2513 break;
2486 default: 2514 default:
2487 /* oops */ 2515 /* oops */
@@ -2548,19 +2576,6 @@ e1000_watchdog(unsigned long data)
2548 } 2576 }
2549 } 2577 }
2550 2578
2551 /* Dynamic mode for Interrupt Throttle Rate (ITR) */
2552 if (adapter->hw.mac_type >= e1000_82540 && adapter->itr == 1) {
2553 /* Symmetric Tx/Rx gets a reduced ITR=2000; Total
2554 * asymmetrical Tx or Rx gets ITR=8000; everyone
2555 * else is between 2000-8000. */
2556 uint32_t goc = (adapter->gotcl + adapter->gorcl) / 10000;
2557 uint32_t dif = (adapter->gotcl > adapter->gorcl ?
2558 adapter->gotcl - adapter->gorcl :
2559 adapter->gorcl - adapter->gotcl) / 10000;
2560 uint32_t itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000;
2561 E1000_WRITE_REG(&adapter->hw, ITR, 1000000000 / (itr * 256));
2562 }
2563
2564 /* Cause software interrupt to ensure rx ring is cleaned */ 2579 /* Cause software interrupt to ensure rx ring is cleaned */
2565 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0); 2580 E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
2566 2581
@@ -2576,6 +2591,135 @@ e1000_watchdog(unsigned long data)
2576 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 2591 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
2577} 2592}
2578 2593
2594enum latency_range {
2595 lowest_latency = 0,
2596 low_latency = 1,
2597 bulk_latency = 2,
2598 latency_invalid = 255
2599};
2600
2601/**
2602 * e1000_update_itr - update the dynamic ITR value based on statistics
2603 * Stores a new ITR value based on packets and byte
2604 * counts during the last interrupt. The advantage of per interrupt
2605 * computation is faster updates and more accurate ITR for the current
2606 * traffic pattern. Constants in this function were computed
2607 * based on theoretical maximum wire speed and thresholds were set based
2608 * on testing data as well as attempting to minimize response time
2609 * while increasing bulk throughput.
2610 * this functionality is controlled by the InterruptThrottleRate module
2611 * parameter (see e1000_param.c)
2612 * @adapter: pointer to adapter
2613 * @itr_setting: current adapter->itr
2614 * @packets: the number of packets during this measurement interval
2615 * @bytes: the number of bytes during this measurement interval
2616 **/
2617static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
2618 uint16_t itr_setting,
2619 int packets,
2620 int bytes)
2621{
2622 unsigned int retval = itr_setting;
2623 struct e1000_hw *hw = &adapter->hw;
2624
2625 if (unlikely(hw->mac_type < e1000_82540))
2626 goto update_itr_done;
2627
2628 if (packets == 0)
2629 goto update_itr_done;
2630
2631
2632 switch (itr_setting) {
2633 case lowest_latency:
2634 if ((packets < 5) && (bytes > 512))
2635 retval = low_latency;
2636 break;
2637 case low_latency: /* 50 usec aka 20000 ints/s */
2638 if (bytes > 10000) {
2639 if ((packets < 10) ||
2640 ((bytes/packets) > 1200))
2641 retval = bulk_latency;
2642 else if ((packets > 35))
2643 retval = lowest_latency;
2644 } else if (packets <= 2 && bytes < 512)
2645 retval = lowest_latency;
2646 break;
2647 case bulk_latency: /* 250 usec aka 4000 ints/s */
2648 if (bytes > 25000) {
2649 if (packets > 35)
2650 retval = low_latency;
2651 } else {
2652 if (bytes < 6000)
2653 retval = low_latency;
2654 }
2655 break;
2656 }
2657
2658update_itr_done:
2659 return retval;
2660}
2661
2662static void e1000_set_itr(struct e1000_adapter *adapter)
2663{
2664 struct e1000_hw *hw = &adapter->hw;
2665 uint16_t current_itr;
2666 uint32_t new_itr = adapter->itr;
2667
2668 if (unlikely(hw->mac_type < e1000_82540))
2669 return;
2670
2671 /* for non-gigabit speeds, just fix the interrupt rate at 4000 */
2672 if (unlikely(adapter->link_speed != SPEED_1000)) {
2673 current_itr = 0;
2674 new_itr = 4000;
2675 goto set_itr_now;
2676 }
2677
2678 adapter->tx_itr = e1000_update_itr(adapter,
2679 adapter->tx_itr,
2680 adapter->total_tx_packets,
2681 adapter->total_tx_bytes);
2682 adapter->rx_itr = e1000_update_itr(adapter,
2683 adapter->rx_itr,
2684 adapter->total_rx_packets,
2685 adapter->total_rx_bytes);
2686
2687 current_itr = max(adapter->rx_itr, adapter->tx_itr);
2688
2689 /* conservative mode eliminates the lowest_latency setting */
2690 if (current_itr == lowest_latency && (adapter->itr_setting == 3))
2691 current_itr = low_latency;
2692
2693 switch (current_itr) {
2694 /* counts and packets in update_itr are dependent on these numbers */
2695 case lowest_latency:
2696 new_itr = 70000;
2697 break;
2698 case low_latency:
2699 new_itr = 20000; /* aka hwitr = ~200 */
2700 break;
2701 case bulk_latency:
2702 new_itr = 4000;
2703 break;
2704 default:
2705 break;
2706 }
2707
2708set_itr_now:
2709 if (new_itr != adapter->itr) {
2710 /* this attempts to bias the interrupt rate towards Bulk
2711 * by adding intermediate steps when interrupt rate is
2712 * increasing */
2713 new_itr = new_itr > adapter->itr ?
2714 min(adapter->itr + (new_itr >> 2), new_itr) :
2715 new_itr;
2716 adapter->itr = new_itr;
2717 E1000_WRITE_REG(hw, ITR, 1000000000 / (new_itr * 256));
2718 }
2719
2720 return;
2721}
2722
2579#define E1000_TX_FLAGS_CSUM 0x00000001 2723#define E1000_TX_FLAGS_CSUM 0x00000001
2580#define E1000_TX_FLAGS_VLAN 0x00000002 2724#define E1000_TX_FLAGS_VLAN 0x00000002
2581#define E1000_TX_FLAGS_TSO 0x00000004 2725#define E1000_TX_FLAGS_TSO 0x00000004
@@ -2616,7 +2760,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2616 0); 2760 0);
2617 cmd_length = E1000_TXD_CMD_IP; 2761 cmd_length = E1000_TXD_CMD_IP;
2618 ipcse = skb->h.raw - skb->data - 1; 2762 ipcse = skb->h.raw - skb->data - 1;
2619#ifdef NETIF_F_TSO_IPV6 2763#ifdef NETIF_F_TSO6
2620 } else if (skb->protocol == htons(ETH_P_IPV6)) { 2764 } else if (skb->protocol == htons(ETH_P_IPV6)) {
2621 skb->nh.ipv6h->payload_len = 0; 2765 skb->nh.ipv6h->payload_len = 0;
2622 skb->h.th->check = 2766 skb->h.th->check =
@@ -2652,6 +2796,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2652 context_desc->cmd_and_length = cpu_to_le32(cmd_length); 2796 context_desc->cmd_and_length = cpu_to_le32(cmd_length);
2653 2797
2654 buffer_info->time_stamp = jiffies; 2798 buffer_info->time_stamp = jiffies;
2799 buffer_info->next_to_watch = i;
2655 2800
2656 if (++i == tx_ring->count) i = 0; 2801 if (++i == tx_ring->count) i = 0;
2657 tx_ring->next_to_use = i; 2802 tx_ring->next_to_use = i;
@@ -2680,12 +2825,13 @@ e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2680 context_desc = E1000_CONTEXT_DESC(*tx_ring, i); 2825 context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
2681 2826
2682 context_desc->upper_setup.tcp_fields.tucss = css; 2827 context_desc->upper_setup.tcp_fields.tucss = css;
2683 context_desc->upper_setup.tcp_fields.tucso = css + skb->csum; 2828 context_desc->upper_setup.tcp_fields.tucso = css + skb->csum_offset;
2684 context_desc->upper_setup.tcp_fields.tucse = 0; 2829 context_desc->upper_setup.tcp_fields.tucse = 0;
2685 context_desc->tcp_seg_setup.data = 0; 2830 context_desc->tcp_seg_setup.data = 0;
2686 context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT); 2831 context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
2687 2832
2688 buffer_info->time_stamp = jiffies; 2833 buffer_info->time_stamp = jiffies;
2834 buffer_info->next_to_watch = i;
2689 2835
2690 if (unlikely(++i == tx_ring->count)) i = 0; 2836 if (unlikely(++i == tx_ring->count)) i = 0;
2691 tx_ring->next_to_use = i; 2837 tx_ring->next_to_use = i;
@@ -2754,6 +2900,7 @@ e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2754 size, 2900 size,
2755 PCI_DMA_TODEVICE); 2901 PCI_DMA_TODEVICE);
2756 buffer_info->time_stamp = jiffies; 2902 buffer_info->time_stamp = jiffies;
2903 buffer_info->next_to_watch = i;
2757 2904
2758 len -= size; 2905 len -= size;
2759 offset += size; 2906 offset += size;
@@ -2793,6 +2940,7 @@ e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2793 size, 2940 size,
2794 PCI_DMA_TODEVICE); 2941 PCI_DMA_TODEVICE);
2795 buffer_info->time_stamp = jiffies; 2942 buffer_info->time_stamp = jiffies;
2943 buffer_info->next_to_watch = i;
2796 2944
2797 len -= size; 2945 len -= size;
2798 offset += size; 2946 offset += size;
@@ -2858,6 +3006,9 @@ e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2858 3006
2859 tx_ring->next_to_use = i; 3007 tx_ring->next_to_use = i;
2860 writel(i, adapter->hw.hw_addr + tx_ring->tdt); 3008 writel(i, adapter->hw.hw_addr + tx_ring->tdt);
3009 /* we need this if more than one processor can write to our tail
3010 * at a time, it syncronizes IO on IA64/Altix systems */
3011 mmiowb();
2861} 3012}
2862 3013
2863/** 3014/**
@@ -2951,6 +3102,7 @@ static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
2951 3102
2952 /* A reprieve! */ 3103 /* A reprieve! */
2953 netif_start_queue(netdev); 3104 netif_start_queue(netdev);
3105 ++adapter->restart_queue;
2954 return 0; 3106 return 0;
2955} 3107}
2956 3108
@@ -3009,9 +3161,9 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3009 max_per_txd = min(mss << 2, max_per_txd); 3161 max_per_txd = min(mss << 2, max_per_txd);
3010 max_txd_pwr = fls(max_per_txd) - 1; 3162 max_txd_pwr = fls(max_per_txd) - 1;
3011 3163
3012 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data 3164 /* TSO Workaround for 82571/2/3 Controllers -- if skb->data
3013 * points to just header, pull a few bytes of payload from 3165 * points to just header, pull a few bytes of payload from
3014 * frags into skb->data */ 3166 * frags into skb->data */
3015 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); 3167 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
3016 if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) { 3168 if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
3017 switch (adapter->hw.mac_type) { 3169 switch (adapter->hw.mac_type) {
@@ -3316,12 +3468,12 @@ e1000_update_stats(struct e1000_adapter *adapter)
3316 adapter->stats.roc += E1000_READ_REG(hw, ROC); 3468 adapter->stats.roc += E1000_READ_REG(hw, ROC);
3317 3469
3318 if (adapter->hw.mac_type != e1000_ich8lan) { 3470 if (adapter->hw.mac_type != e1000_ich8lan) {
3319 adapter->stats.prc64 += E1000_READ_REG(hw, PRC64); 3471 adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
3320 adapter->stats.prc127 += E1000_READ_REG(hw, PRC127); 3472 adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
3321 adapter->stats.prc255 += E1000_READ_REG(hw, PRC255); 3473 adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
3322 adapter->stats.prc511 += E1000_READ_REG(hw, PRC511); 3474 adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
3323 adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023); 3475 adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
3324 adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522); 3476 adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
3325 } 3477 }
3326 3478
3327 adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS); 3479 adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
@@ -3352,12 +3504,12 @@ e1000_update_stats(struct e1000_adapter *adapter)
3352 adapter->stats.tpr += E1000_READ_REG(hw, TPR); 3504 adapter->stats.tpr += E1000_READ_REG(hw, TPR);
3353 3505
3354 if (adapter->hw.mac_type != e1000_ich8lan) { 3506 if (adapter->hw.mac_type != e1000_ich8lan) {
3355 adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64); 3507 adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
3356 adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127); 3508 adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
3357 adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255); 3509 adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
3358 adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511); 3510 adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
3359 adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023); 3511 adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
3360 adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522); 3512 adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
3361 } 3513 }
3362 3514
3363 adapter->stats.mptc += E1000_READ_REG(hw, MPTC); 3515 adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
@@ -3383,18 +3535,17 @@ e1000_update_stats(struct e1000_adapter *adapter)
3383 adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC); 3535 adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
3384 3536
3385 if (adapter->hw.mac_type != e1000_ich8lan) { 3537 if (adapter->hw.mac_type != e1000_ich8lan) {
3386 adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC); 3538 adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
3387 adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC); 3539 adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
3388 adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC); 3540 adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
3389 adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC); 3541 adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
3390 adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC); 3542 adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
3391 adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC); 3543 adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
3392 adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC); 3544 adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
3393 } 3545 }
3394 } 3546 }
3395 3547
3396 /* Fill out the OS statistics structure */ 3548 /* Fill out the OS statistics structure */
3397
3398 adapter->net_stats.rx_packets = adapter->stats.gprc; 3549 adapter->net_stats.rx_packets = adapter->stats.gprc;
3399 adapter->net_stats.tx_packets = adapter->stats.gptc; 3550 adapter->net_stats.tx_packets = adapter->stats.gptc;
3400 adapter->net_stats.rx_bytes = adapter->stats.gorcl; 3551 adapter->net_stats.rx_bytes = adapter->stats.gorcl;
@@ -3426,7 +3577,6 @@ e1000_update_stats(struct e1000_adapter *adapter)
3426 /* Tx Dropped needs to be maintained elsewhere */ 3577 /* Tx Dropped needs to be maintained elsewhere */
3427 3578
3428 /* Phy Stats */ 3579 /* Phy Stats */
3429
3430 if (hw->media_type == e1000_media_type_copper) { 3580 if (hw->media_type == e1000_media_type_copper) {
3431 if ((adapter->link_speed == SPEED_1000) && 3581 if ((adapter->link_speed == SPEED_1000) &&
3432 (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) { 3582 (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
@@ -3442,6 +3592,95 @@ e1000_update_stats(struct e1000_adapter *adapter)
3442 3592
3443 spin_unlock_irqrestore(&adapter->stats_lock, flags); 3593 spin_unlock_irqrestore(&adapter->stats_lock, flags);
3444} 3594}
3595#ifdef CONFIG_PCI_MSI
3596
3597/**
3598 * e1000_intr_msi - Interrupt Handler
3599 * @irq: interrupt number
3600 * @data: pointer to a network interface device structure
3601 **/
3602
3603static
3604irqreturn_t e1000_intr_msi(int irq, void *data)
3605{
3606 struct net_device *netdev = data;
3607 struct e1000_adapter *adapter = netdev_priv(netdev);
3608 struct e1000_hw *hw = &adapter->hw;
3609#ifndef CONFIG_E1000_NAPI
3610 int i;
3611#endif
3612
3613 /* this code avoids the read of ICR but has to get 1000 interrupts
3614 * at every link change event before it will notice the change */
3615 if (++adapter->detect_link >= 1000) {
3616 uint32_t icr = E1000_READ_REG(hw, ICR);
3617#ifdef CONFIG_E1000_NAPI
3618 /* read ICR disables interrupts using IAM, so keep up with our
3619 * enable/disable accounting */
3620 atomic_inc(&adapter->irq_sem);
3621#endif
3622 adapter->detect_link = 0;
3623 if ((icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) &&
3624 (icr & E1000_ICR_INT_ASSERTED)) {
3625 hw->get_link_status = 1;
3626 /* 80003ES2LAN workaround--
3627 * For packet buffer work-around on link down event;
3628 * disable receives here in the ISR and
3629 * reset adapter in watchdog
3630 */
3631 if (netif_carrier_ok(netdev) &&
3632 (adapter->hw.mac_type == e1000_80003es2lan)) {
3633 /* disable receives */
3634 uint32_t rctl = E1000_READ_REG(hw, RCTL);
3635 E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
3636 }
3637 /* guard against interrupt when we're going down */
3638 if (!test_bit(__E1000_DOWN, &adapter->flags))
3639 mod_timer(&adapter->watchdog_timer,
3640 jiffies + 1);
3641 }
3642 } else {
3643 E1000_WRITE_REG(hw, ICR, (0xffffffff & ~(E1000_ICR_RXSEQ |
3644 E1000_ICR_LSC)));
3645 /* bummer we have to flush here, but things break otherwise as
3646 * some event appears to be lost or delayed and throughput
3647 * drops. In almost all tests this flush is un-necessary */
3648 E1000_WRITE_FLUSH(hw);
3649#ifdef CONFIG_E1000_NAPI
3650 /* Interrupt Auto-Mask (IAM)...upon writing ICR, interrupts are
3651 * masked. No need for the IMC write, but it does mean we
3652 * should account for it ASAP. */
3653 atomic_inc(&adapter->irq_sem);
3654#endif
3655 }
3656
3657#ifdef CONFIG_E1000_NAPI
3658 if (likely(netif_rx_schedule_prep(netdev))) {
3659 adapter->total_tx_bytes = 0;
3660 adapter->total_tx_packets = 0;
3661 adapter->total_rx_bytes = 0;
3662 adapter->total_rx_packets = 0;
3663 __netif_rx_schedule(netdev);
3664 } else
3665 e1000_irq_enable(adapter);
3666#else
3667 adapter->total_tx_bytes = 0;
3668 adapter->total_rx_bytes = 0;
3669 adapter->total_tx_packets = 0;
3670 adapter->total_rx_packets = 0;
3671
3672 for (i = 0; i < E1000_MAX_INTR; i++)
3673 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
3674 !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
3675 break;
3676
3677 if (likely(adapter->itr_setting & 3))
3678 e1000_set_itr(adapter);
3679#endif
3680
3681 return IRQ_HANDLED;
3682}
3683#endif
3445 3684
3446/** 3685/**
3447 * e1000_intr - Interrupt Handler 3686 * e1000_intr - Interrupt Handler
@@ -3458,7 +3697,17 @@ e1000_intr(int irq, void *data)
3458 uint32_t rctl, icr = E1000_READ_REG(hw, ICR); 3697 uint32_t rctl, icr = E1000_READ_REG(hw, ICR);
3459#ifndef CONFIG_E1000_NAPI 3698#ifndef CONFIG_E1000_NAPI
3460 int i; 3699 int i;
3461#else 3700#endif
3701 if (unlikely(!icr))
3702 return IRQ_NONE; /* Not our interrupt */
3703
3704#ifdef CONFIG_E1000_NAPI
3705 /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
3706 * not set, then the adapter didn't send an interrupt */
3707 if (unlikely(hw->mac_type >= e1000_82571 &&
3708 !(icr & E1000_ICR_INT_ASSERTED)))
3709 return IRQ_NONE;
3710
3462 /* Interrupt Auto-Mask...upon reading ICR, 3711 /* Interrupt Auto-Mask...upon reading ICR,
3463 * interrupts are masked. No need for the 3712 * interrupts are masked. No need for the
3464 * IMC write, but it does mean we should 3713 * IMC write, but it does mean we should
@@ -3467,14 +3716,6 @@ e1000_intr(int irq, void *data)
3467 atomic_inc(&adapter->irq_sem); 3716 atomic_inc(&adapter->irq_sem);
3468#endif 3717#endif
3469 3718
3470 if (unlikely(!icr)) {
3471#ifdef CONFIG_E1000_NAPI
3472 if (hw->mac_type >= e1000_82571)
3473 e1000_irq_enable(adapter);
3474#endif
3475 return IRQ_NONE; /* Not our interrupt */
3476 }
3477
3478 if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) { 3719 if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
3479 hw->get_link_status = 1; 3720 hw->get_link_status = 1;
3480 /* 80003ES2LAN workaround-- 3721 /* 80003ES2LAN workaround--
@@ -3495,13 +3736,20 @@ e1000_intr(int irq, void *data)
3495 3736
3496#ifdef CONFIG_E1000_NAPI 3737#ifdef CONFIG_E1000_NAPI
3497 if (unlikely(hw->mac_type < e1000_82571)) { 3738 if (unlikely(hw->mac_type < e1000_82571)) {
3739 /* disable interrupts, without the synchronize_irq bit */
3498 atomic_inc(&adapter->irq_sem); 3740 atomic_inc(&adapter->irq_sem);
3499 E1000_WRITE_REG(hw, IMC, ~0); 3741 E1000_WRITE_REG(hw, IMC, ~0);
3500 E1000_WRITE_FLUSH(hw); 3742 E1000_WRITE_FLUSH(hw);
3501 } 3743 }
3502 if (likely(netif_rx_schedule_prep(netdev))) 3744 if (likely(netif_rx_schedule_prep(netdev))) {
3745 adapter->total_tx_bytes = 0;
3746 adapter->total_tx_packets = 0;
3747 adapter->total_rx_bytes = 0;
3748 adapter->total_rx_packets = 0;
3503 __netif_rx_schedule(netdev); 3749 __netif_rx_schedule(netdev);
3504 else 3750 } else
3751 /* this really should not happen! if it does it is basically a
3752 * bug, but not a hard error, so enable ints and continue */
3505 e1000_irq_enable(adapter); 3753 e1000_irq_enable(adapter);
3506#else 3754#else
3507 /* Writing IMC and IMS is needed for 82547. 3755 /* Writing IMC and IMS is needed for 82547.
@@ -3519,16 +3767,23 @@ e1000_intr(int irq, void *data)
3519 E1000_WRITE_REG(hw, IMC, ~0); 3767 E1000_WRITE_REG(hw, IMC, ~0);
3520 } 3768 }
3521 3769
3770 adapter->total_tx_bytes = 0;
3771 adapter->total_rx_bytes = 0;
3772 adapter->total_tx_packets = 0;
3773 adapter->total_rx_packets = 0;
3774
3522 for (i = 0; i < E1000_MAX_INTR; i++) 3775 for (i = 0; i < E1000_MAX_INTR; i++)
3523 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) & 3776 if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
3524 !e1000_clean_tx_irq(adapter, adapter->tx_ring))) 3777 !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
3525 break; 3778 break;
3526 3779
3780 if (likely(adapter->itr_setting & 3))
3781 e1000_set_itr(adapter);
3782
3527 if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2) 3783 if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)
3528 e1000_irq_enable(adapter); 3784 e1000_irq_enable(adapter);
3529 3785
3530#endif 3786#endif
3531
3532 return IRQ_HANDLED; 3787 return IRQ_HANDLED;
3533} 3788}
3534 3789
@@ -3572,6 +3827,8 @@ e1000_clean(struct net_device *poll_dev, int *budget)
3572 if ((!tx_cleaned && (work_done == 0)) || 3827 if ((!tx_cleaned && (work_done == 0)) ||
3573 !netif_running(poll_dev)) { 3828 !netif_running(poll_dev)) {
3574quit_polling: 3829quit_polling:
3830 if (likely(adapter->itr_setting & 3))
3831 e1000_set_itr(adapter);
3575 netif_rx_complete(poll_dev); 3832 netif_rx_complete(poll_dev);
3576 e1000_irq_enable(adapter); 3833 e1000_irq_enable(adapter);
3577 return 0; 3834 return 0;
@@ -3598,6 +3855,7 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3598 unsigned int count = 0; 3855 unsigned int count = 0;
3599#endif 3856#endif
3600 boolean_t cleaned = FALSE; 3857 boolean_t cleaned = FALSE;
3858 unsigned int total_tx_bytes=0, total_tx_packets=0;
3601 3859
3602 i = tx_ring->next_to_clean; 3860 i = tx_ring->next_to_clean;
3603 eop = tx_ring->buffer_info[i].next_to_watch; 3861 eop = tx_ring->buffer_info[i].next_to_watch;
@@ -3609,13 +3867,19 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3609 buffer_info = &tx_ring->buffer_info[i]; 3867 buffer_info = &tx_ring->buffer_info[i];
3610 cleaned = (i == eop); 3868 cleaned = (i == eop);
3611 3869
3870 if (cleaned) {
3871 /* this packet count is wrong for TSO but has a
3872 * tendency to make dynamic ITR change more
3873 * towards bulk */
3874 total_tx_packets++;
3875 total_tx_bytes += buffer_info->skb->len;
3876 }
3612 e1000_unmap_and_free_tx_resource(adapter, buffer_info); 3877 e1000_unmap_and_free_tx_resource(adapter, buffer_info);
3613 memset(tx_desc, 0, sizeof(struct e1000_tx_desc)); 3878 tx_desc->upper.data = 0;
3614 3879
3615 if (unlikely(++i == tx_ring->count)) i = 0; 3880 if (unlikely(++i == tx_ring->count)) i = 0;
3616 } 3881 }
3617 3882
3618
3619 eop = tx_ring->buffer_info[i].next_to_watch; 3883 eop = tx_ring->buffer_info[i].next_to_watch;
3620 eop_desc = E1000_TX_DESC(*tx_ring, eop); 3884 eop_desc = E1000_TX_DESC(*tx_ring, eop);
3621#ifdef CONFIG_E1000_NAPI 3885#ifdef CONFIG_E1000_NAPI
@@ -3634,8 +3898,10 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3634 * sees the new next_to_clean. 3898 * sees the new next_to_clean.
3635 */ 3899 */
3636 smp_mb(); 3900 smp_mb();
3637 if (netif_queue_stopped(netdev)) 3901 if (netif_queue_stopped(netdev)) {
3638 netif_wake_queue(netdev); 3902 netif_wake_queue(netdev);
3903 ++adapter->restart_queue;
3904 }
3639 } 3905 }
3640 3906
3641 if (adapter->detect_tx_hung) { 3907 if (adapter->detect_tx_hung) {
@@ -3673,6 +3939,8 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3673 netif_stop_queue(netdev); 3939 netif_stop_queue(netdev);
3674 } 3940 }
3675 } 3941 }
3942 adapter->total_tx_bytes += total_tx_bytes;
3943 adapter->total_tx_packets += total_tx_packets;
3676 return cleaned; 3944 return cleaned;
3677} 3945}
3678 3946
@@ -3752,6 +4020,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3752 unsigned int i; 4020 unsigned int i;
3753 int cleaned_count = 0; 4021 int cleaned_count = 0;
3754 boolean_t cleaned = FALSE; 4022 boolean_t cleaned = FALSE;
4023 unsigned int total_rx_bytes=0, total_rx_packets=0;
3755 4024
3756 i = rx_ring->next_to_clean; 4025 i = rx_ring->next_to_clean;
3757 rx_desc = E1000_RX_DESC(*rx_ring, i); 4026 rx_desc = E1000_RX_DESC(*rx_ring, i);
@@ -3760,6 +4029,7 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3760 while (rx_desc->status & E1000_RXD_STAT_DD) { 4029 while (rx_desc->status & E1000_RXD_STAT_DD) {
3761 struct sk_buff *skb; 4030 struct sk_buff *skb;
3762 u8 status; 4031 u8 status;
4032
3763#ifdef CONFIG_E1000_NAPI 4033#ifdef CONFIG_E1000_NAPI
3764 if (*work_done >= work_to_do) 4034 if (*work_done >= work_to_do)
3765 break; 4035 break;
@@ -3817,6 +4087,10 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3817 * done after the TBI_ACCEPT workaround above */ 4087 * done after the TBI_ACCEPT workaround above */
3818 length -= 4; 4088 length -= 4;
3819 4089
4090 /* probably a little skewed due to removing CRC */
4091 total_rx_bytes += length;
4092 total_rx_packets++;
4093
3820 /* code added for copybreak, this should improve 4094 /* code added for copybreak, this should improve
3821 * performance for small packets with large amounts 4095 * performance for small packets with large amounts
3822 * of reassembly being done in the stack */ 4096 * of reassembly being done in the stack */
@@ -3832,12 +4106,11 @@ e1000_clean_rx_irq(struct e1000_adapter *adapter,
3832 /* save the skb in buffer_info as good */ 4106 /* save the skb in buffer_info as good */
3833 buffer_info->skb = skb; 4107 buffer_info->skb = skb;
3834 skb = new_skb; 4108 skb = new_skb;
3835 skb_put(skb, length);
3836 } 4109 }
3837 } else 4110 /* else just continue with the old one */
3838 skb_put(skb, length); 4111 }
3839
3840 /* end copybreak code */ 4112 /* end copybreak code */
4113 skb_put(skb, length);
3841 4114
3842 /* Receive Checksum Offload */ 4115 /* Receive Checksum Offload */
3843 e1000_rx_checksum(adapter, 4116 e1000_rx_checksum(adapter,
@@ -3886,6 +4159,8 @@ next_desc:
3886 if (cleaned_count) 4159 if (cleaned_count)
3887 adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); 4160 adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
3888 4161
4162 adapter->total_rx_packets += total_rx_packets;
4163 adapter->total_rx_bytes += total_rx_bytes;
3889 return cleaned; 4164 return cleaned;
3890} 4165}
3891 4166
@@ -3915,6 +4190,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
3915 uint32_t length, staterr; 4190 uint32_t length, staterr;
3916 int cleaned_count = 0; 4191 int cleaned_count = 0;
3917 boolean_t cleaned = FALSE; 4192 boolean_t cleaned = FALSE;
4193 unsigned int total_rx_bytes=0, total_rx_packets=0;
3918 4194
3919 i = rx_ring->next_to_clean; 4195 i = rx_ring->next_to_clean;
3920 rx_desc = E1000_RX_DESC_PS(*rx_ring, i); 4196 rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
@@ -3999,7 +4275,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
3999 goto copydone; 4275 goto copydone;
4000 } /* if */ 4276 } /* if */
4001 } 4277 }
4002 4278
4003 for (j = 0; j < adapter->rx_ps_pages; j++) { 4279 for (j = 0; j < adapter->rx_ps_pages; j++) {
4004 if (!(length= le16_to_cpu(rx_desc->wb.upper.length[j]))) 4280 if (!(length= le16_to_cpu(rx_desc->wb.upper.length[j])))
4005 break; 4281 break;
@@ -4019,6 +4295,9 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
4019 pskb_trim(skb, skb->len - 4); 4295 pskb_trim(skb, skb->len - 4);
4020 4296
4021copydone: 4297copydone:
4298 total_rx_bytes += skb->len;
4299 total_rx_packets++;
4300
4022 e1000_rx_checksum(adapter, staterr, 4301 e1000_rx_checksum(adapter, staterr,
4023 le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb); 4302 le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
4024 skb->protocol = eth_type_trans(skb, netdev); 4303 skb->protocol = eth_type_trans(skb, netdev);
@@ -4067,6 +4346,8 @@ next_desc:
4067 if (cleaned_count) 4346 if (cleaned_count)
4068 adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); 4347 adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
4069 4348
4349 adapter->total_rx_packets += total_rx_packets;
4350 adapter->total_rx_bytes += total_rx_bytes;
4070 return cleaned; 4351 return cleaned;
4071} 4352}
4072 4353
@@ -4234,7 +4515,7 @@ e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
4234 } 4515 }
4235 4516
4236 skb = netdev_alloc_skb(netdev, 4517 skb = netdev_alloc_skb(netdev,
4237 adapter->rx_ps_bsize0 + NET_IP_ALIGN); 4518 adapter->rx_ps_bsize0 + NET_IP_ALIGN);
4238 4519
4239 if (unlikely(!skb)) { 4520 if (unlikely(!skb)) {
4240 adapter->alloc_rx_buff_failed++; 4521 adapter->alloc_rx_buff_failed++;
@@ -4511,7 +4792,6 @@ e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
4511 return E1000_SUCCESS; 4792 return E1000_SUCCESS;
4512} 4793}
4513 4794
4514
4515void 4795void
4516e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value) 4796e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value)
4517{ 4797{
@@ -4534,12 +4814,12 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
4534 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 4814 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
4535 4815
4536 if (adapter->hw.mac_type != e1000_ich8lan) { 4816 if (adapter->hw.mac_type != e1000_ich8lan) {
4537 /* enable VLAN receive filtering */ 4817 /* enable VLAN receive filtering */
4538 rctl = E1000_READ_REG(&adapter->hw, RCTL); 4818 rctl = E1000_READ_REG(&adapter->hw, RCTL);
4539 rctl |= E1000_RCTL_VFE; 4819 rctl |= E1000_RCTL_VFE;
4540 rctl &= ~E1000_RCTL_CFIEN; 4820 rctl &= ~E1000_RCTL_CFIEN;
4541 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 4821 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
4542 e1000_update_mng_vlan(adapter); 4822 e1000_update_mng_vlan(adapter);
4543 } 4823 }
4544 } else { 4824 } else {
4545 /* disable VLAN tag insert/strip */ 4825 /* disable VLAN tag insert/strip */
@@ -4548,14 +4828,16 @@ e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
4548 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl); 4828 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
4549 4829
4550 if (adapter->hw.mac_type != e1000_ich8lan) { 4830 if (adapter->hw.mac_type != e1000_ich8lan) {
4551 /* disable VLAN filtering */ 4831 /* disable VLAN filtering */
4552 rctl = E1000_READ_REG(&adapter->hw, RCTL); 4832 rctl = E1000_READ_REG(&adapter->hw, RCTL);
4553 rctl &= ~E1000_RCTL_VFE; 4833 rctl &= ~E1000_RCTL_VFE;
4554 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 4834 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
4555 if (adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) { 4835 if (adapter->mng_vlan_id !=
4556 e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id); 4836 (uint16_t)E1000_MNG_VLAN_NONE) {
4557 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; 4837 e1000_vlan_rx_kill_vid(netdev,
4558 } 4838 adapter->mng_vlan_id);
4839 adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
4840 }
4559 } 4841 }
4560 } 4842 }
4561 4843
diff --git a/drivers/net/e1000/e1000_osdep.h b/drivers/net/e1000/e1000_osdep.h
index a464cb290621..18afc0c25dac 100644
--- a/drivers/net/e1000/e1000_osdep.h
+++ b/drivers/net/e1000/e1000_osdep.h
@@ -107,17 +107,16 @@ typedef enum {
107 107
108#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS) 108#define E1000_WRITE_FLUSH(a) E1000_READ_REG(a, STATUS)
109 109
110#define E1000_WRITE_ICH8_REG(a, reg, value) ( \ 110#define E1000_WRITE_ICH_FLASH_REG(a, reg, value) ( \
111 writel((value), ((a)->flash_address + reg))) 111 writel((value), ((a)->flash_address + reg)))
112 112
113#define E1000_READ_ICH8_REG(a, reg) ( \ 113#define E1000_READ_ICH_FLASH_REG(a, reg) ( \
114 readl((a)->flash_address + reg)) 114 readl((a)->flash_address + reg))
115 115
116#define E1000_WRITE_ICH8_REG16(a, reg, value) ( \ 116#define E1000_WRITE_ICH_FLASH_REG16(a, reg, value) ( \
117 writew((value), ((a)->flash_address + reg))) 117 writew((value), ((a)->flash_address + reg)))
118 118
119#define E1000_READ_ICH8_REG16(a, reg) ( \ 119#define E1000_READ_ICH_FLASH_REG16(a, reg) ( \
120 readw((a)->flash_address + reg)) 120 readw((a)->flash_address + reg))
121 121
122
123#endif /* _E1000_OSDEP_H_ */ 122#endif /* _E1000_OSDEP_H_ */
diff --git a/drivers/net/e1000/e1000_param.c b/drivers/net/e1000/e1000_param.c
index 9c3c1acefccc..cbfcd7f2889f 100644
--- a/drivers/net/e1000/e1000_param.c
+++ b/drivers/net/e1000/e1000_param.c
@@ -44,16 +44,6 @@
44 */ 44 */
45 45
46#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET } 46#define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }
47/* Module Parameters are always initialized to -1, so that the driver
48 * can tell the difference between no user specified value or the
49 * user asking for the default value.
50 * The true default values are loaded in when e1000_check_options is called.
51 *
52 * This is a GCC extension to ANSI C.
53 * See the item "Labeled Elements in Initializers" in the section
54 * "Extensions to the C Language Family" of the GCC documentation.
55 */
56
57#define E1000_PARAM(X, desc) \ 47#define E1000_PARAM(X, desc) \
58 static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \ 48 static int __devinitdata X[E1000_MAX_NIC+1] = E1000_PARAM_INIT; \
59 static int num_##X = 0; \ 49 static int num_##X = 0; \
@@ -67,7 +57,6 @@
67 * 57 *
68 * Default Value: 256 58 * Default Value: 256
69 */ 59 */
70
71E1000_PARAM(TxDescriptors, "Number of transmit descriptors"); 60E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
72 61
73/* Receive Descriptor Count 62/* Receive Descriptor Count
@@ -77,7 +66,6 @@ E1000_PARAM(TxDescriptors, "Number of transmit descriptors");
77 * 66 *
78 * Default Value: 256 67 * Default Value: 256
79 */ 68 */
80
81E1000_PARAM(RxDescriptors, "Number of receive descriptors"); 69E1000_PARAM(RxDescriptors, "Number of receive descriptors");
82 70
83/* User Specified Speed Override 71/* User Specified Speed Override
@@ -90,7 +78,6 @@ E1000_PARAM(RxDescriptors, "Number of receive descriptors");
90 * 78 *
91 * Default Value: 0 79 * Default Value: 0
92 */ 80 */
93
94E1000_PARAM(Speed, "Speed setting"); 81E1000_PARAM(Speed, "Speed setting");
95 82
96/* User Specified Duplex Override 83/* User Specified Duplex Override
@@ -102,7 +89,6 @@ E1000_PARAM(Speed, "Speed setting");
102 * 89 *
103 * Default Value: 0 90 * Default Value: 0
104 */ 91 */
105
106E1000_PARAM(Duplex, "Duplex setting"); 92E1000_PARAM(Duplex, "Duplex setting");
107 93
108/* Auto-negotiation Advertisement Override 94/* Auto-negotiation Advertisement Override
@@ -119,8 +105,9 @@ E1000_PARAM(Duplex, "Duplex setting");
119 * 105 *
120 * Default Value: 0x2F (copper); 0x20 (fiber) 106 * Default Value: 0x2F (copper); 0x20 (fiber)
121 */ 107 */
122
123E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting"); 108E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
109#define AUTONEG_ADV_DEFAULT 0x2F
110#define AUTONEG_ADV_MASK 0x2F
124 111
125/* User Specified Flow Control Override 112/* User Specified Flow Control Override
126 * 113 *
@@ -132,8 +119,8 @@ E1000_PARAM(AutoNeg, "Advertised auto-negotiation setting");
132 * 119 *
133 * Default Value: Read flow control settings from the EEPROM 120 * Default Value: Read flow control settings from the EEPROM
134 */ 121 */
135
136E1000_PARAM(FlowControl, "Flow Control setting"); 122E1000_PARAM(FlowControl, "Flow Control setting");
123#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
137 124
138/* XsumRX - Receive Checksum Offload Enable/Disable 125/* XsumRX - Receive Checksum Offload Enable/Disable
139 * 126 *
@@ -144,53 +131,54 @@ E1000_PARAM(FlowControl, "Flow Control setting");
144 * 131 *
145 * Default Value: 1 132 * Default Value: 1
146 */ 133 */
147
148E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload"); 134E1000_PARAM(XsumRX, "Disable or enable Receive Checksum offload");
149 135
150/* Transmit Interrupt Delay in units of 1.024 microseconds 136/* Transmit Interrupt Delay in units of 1.024 microseconds
137 * Tx interrupt delay needs to typically be set to something non zero
151 * 138 *
152 * Valid Range: 0-65535 139 * Valid Range: 0-65535
153 *
154 * Default Value: 64
155 */ 140 */
156
157E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay"); 141E1000_PARAM(TxIntDelay, "Transmit Interrupt Delay");
142#define DEFAULT_TIDV 8
143#define MAX_TXDELAY 0xFFFF
144#define MIN_TXDELAY 0
158 145
159/* Transmit Absolute Interrupt Delay in units of 1.024 microseconds 146/* Transmit Absolute Interrupt Delay in units of 1.024 microseconds
160 * 147 *
161 * Valid Range: 0-65535 148 * Valid Range: 0-65535
162 *
163 * Default Value: 0
164 */ 149 */
165
166E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay"); 150E1000_PARAM(TxAbsIntDelay, "Transmit Absolute Interrupt Delay");
151#define DEFAULT_TADV 32
152#define MAX_TXABSDELAY 0xFFFF
153#define MIN_TXABSDELAY 0
167 154
168/* Receive Interrupt Delay in units of 1.024 microseconds 155/* Receive Interrupt Delay in units of 1.024 microseconds
156 * hardware will likely hang if you set this to anything but zero.
169 * 157 *
170 * Valid Range: 0-65535 158 * Valid Range: 0-65535
171 *
172 * Default Value: 0
173 */ 159 */
174
175E1000_PARAM(RxIntDelay, "Receive Interrupt Delay"); 160E1000_PARAM(RxIntDelay, "Receive Interrupt Delay");
161#define DEFAULT_RDTR 0
162#define MAX_RXDELAY 0xFFFF
163#define MIN_RXDELAY 0
176 164
177/* Receive Absolute Interrupt Delay in units of 1.024 microseconds 165/* Receive Absolute Interrupt Delay in units of 1.024 microseconds
178 * 166 *
179 * Valid Range: 0-65535 167 * Valid Range: 0-65535
180 *
181 * Default Value: 128
182 */ 168 */
183
184E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay"); 169E1000_PARAM(RxAbsIntDelay, "Receive Absolute Interrupt Delay");
170#define DEFAULT_RADV 8
171#define MAX_RXABSDELAY 0xFFFF
172#define MIN_RXABSDELAY 0
185 173
186/* Interrupt Throttle Rate (interrupts/sec) 174/* Interrupt Throttle Rate (interrupts/sec)
187 * 175 *
188 * Valid Range: 100-100000 (0=off, 1=dynamic) 176 * Valid Range: 100-100000 (0=off, 1=dynamic, 3=dynamic conservative)
189 *
190 * Default Value: 8000
191 */ 177 */
192
193E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate"); 178E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
179#define DEFAULT_ITR 3
180#define MAX_ITR 100000
181#define MIN_ITR 100
194 182
195/* Enable Smart Power Down of the PHY 183/* Enable Smart Power Down of the PHY
196 * 184 *
@@ -198,7 +186,6 @@ E1000_PARAM(InterruptThrottleRate, "Interrupt Throttling Rate");
198 * 186 *
199 * Default Value: 0 (disabled) 187 * Default Value: 0 (disabled)
200 */ 188 */
201
202E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down"); 189E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
203 190
204/* Enable Kumeran Lock Loss workaround 191/* Enable Kumeran Lock Loss workaround
@@ -207,33 +194,8 @@ E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
207 * 194 *
208 * Default Value: 1 (enabled) 195 * Default Value: 1 (enabled)
209 */ 196 */
210
211E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); 197E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
212 198
213#define AUTONEG_ADV_DEFAULT 0x2F
214#define AUTONEG_ADV_MASK 0x2F
215#define FLOW_CONTROL_DEFAULT FLOW_CONTROL_FULL
216
217#define DEFAULT_RDTR 0
218#define MAX_RXDELAY 0xFFFF
219#define MIN_RXDELAY 0
220
221#define DEFAULT_RADV 128
222#define MAX_RXABSDELAY 0xFFFF
223#define MIN_RXABSDELAY 0
224
225#define DEFAULT_TIDV 64
226#define MAX_TXDELAY 0xFFFF
227#define MIN_TXDELAY 0
228
229#define DEFAULT_TADV 64
230#define MAX_TXABSDELAY 0xFFFF
231#define MIN_TXABSDELAY 0
232
233#define DEFAULT_ITR 8000
234#define MAX_ITR 100000
235#define MIN_ITR 100
236
237struct e1000_option { 199struct e1000_option {
238 enum { enable_option, range_option, list_option } type; 200 enum { enable_option, range_option, list_option } type;
239 char *name; 201 char *name;
@@ -510,15 +472,27 @@ e1000_check_options(struct e1000_adapter *adapter)
510 break; 472 break;
511 case 1: 473 case 1:
512 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n", 474 DPRINTK(PROBE, INFO, "%s set to dynamic mode\n",
513 opt.name); 475 opt.name);
476 adapter->itr_setting = adapter->itr;
477 adapter->itr = 20000;
478 break;
479 case 3:
480 DPRINTK(PROBE, INFO,
481 "%s set to dynamic conservative mode\n",
482 opt.name);
483 adapter->itr_setting = adapter->itr;
484 adapter->itr = 20000;
514 break; 485 break;
515 default: 486 default:
516 e1000_validate_option(&adapter->itr, &opt, 487 e1000_validate_option(&adapter->itr, &opt,
517 adapter); 488 adapter);
489 /* save the setting, because the dynamic bits change itr */
490 adapter->itr_setting = adapter->itr;
518 break; 491 break;
519 } 492 }
520 } else { 493 } else {
521 adapter->itr = opt.def; 494 adapter->itr_setting = opt.def;
495 adapter->itr = 20000;
522 } 496 }
523 } 497 }
524 { /* Smart Power Down */ 498 { /* Smart Power Down */
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index c5ed635bce36..439f41338291 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -110,6 +110,8 @@
110 * 0.55: 22 Mar 2006: Add flow control (pause frame). 110 * 0.55: 22 Mar 2006: Add flow control (pause frame).
111 * 0.56: 22 Mar 2006: Additional ethtool config and moduleparam support. 111 * 0.56: 22 Mar 2006: Additional ethtool config and moduleparam support.
112 * 0.57: 14 May 2006: Mac address set in probe/remove and order corrections. 112 * 0.57: 14 May 2006: Mac address set in probe/remove and order corrections.
113 * 0.58: 30 Oct 2006: Added support for sideband management unit.
114 * 0.59: 30 Oct 2006: Added support for recoverable error.
113 * 115 *
114 * Known bugs: 116 * Known bugs:
115 * We suspect that on some hardware no TX done interrupts are generated. 117 * We suspect that on some hardware no TX done interrupts are generated.
@@ -126,7 +128,7 @@
126#else 128#else
127#define DRIVERNAPI 129#define DRIVERNAPI
128#endif 130#endif
129#define FORCEDETH_VERSION "0.57" 131#define FORCEDETH_VERSION "0.59"
130#define DRV_NAME "forcedeth" 132#define DRV_NAME "forcedeth"
131 133
132#include <linux/module.h> 134#include <linux/module.h>
@@ -174,11 +176,12 @@
174#define DEV_HAS_PAUSEFRAME_TX 0x0200 /* device supports tx pause frames */ 176#define DEV_HAS_PAUSEFRAME_TX 0x0200 /* device supports tx pause frames */
175#define DEV_HAS_STATISTICS 0x0400 /* device supports hw statistics */ 177#define DEV_HAS_STATISTICS 0x0400 /* device supports hw statistics */
176#define DEV_HAS_TEST_EXTENDED 0x0800 /* device supports extended diagnostic test */ 178#define DEV_HAS_TEST_EXTENDED 0x0800 /* device supports extended diagnostic test */
179#define DEV_HAS_MGMT_UNIT 0x1000 /* device supports management unit */
177 180
178enum { 181enum {
179 NvRegIrqStatus = 0x000, 182 NvRegIrqStatus = 0x000,
180#define NVREG_IRQSTAT_MIIEVENT 0x040 183#define NVREG_IRQSTAT_MIIEVENT 0x040
181#define NVREG_IRQSTAT_MASK 0x1ff 184#define NVREG_IRQSTAT_MASK 0x81ff
182 NvRegIrqMask = 0x004, 185 NvRegIrqMask = 0x004,
183#define NVREG_IRQ_RX_ERROR 0x0001 186#define NVREG_IRQ_RX_ERROR 0x0001
184#define NVREG_IRQ_RX 0x0002 187#define NVREG_IRQ_RX 0x0002
@@ -189,15 +192,16 @@ enum {
189#define NVREG_IRQ_LINK 0x0040 192#define NVREG_IRQ_LINK 0x0040
190#define NVREG_IRQ_RX_FORCED 0x0080 193#define NVREG_IRQ_RX_FORCED 0x0080
191#define NVREG_IRQ_TX_FORCED 0x0100 194#define NVREG_IRQ_TX_FORCED 0x0100
195#define NVREG_IRQ_RECOVER_ERROR 0x8000
192#define NVREG_IRQMASK_THROUGHPUT 0x00df 196#define NVREG_IRQMASK_THROUGHPUT 0x00df
193#define NVREG_IRQMASK_CPU 0x0040 197#define NVREG_IRQMASK_CPU 0x0040
194#define NVREG_IRQ_TX_ALL (NVREG_IRQ_TX_ERR|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_FORCED) 198#define NVREG_IRQ_TX_ALL (NVREG_IRQ_TX_ERR|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_FORCED)
195#define NVREG_IRQ_RX_ALL (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_RX_FORCED) 199#define NVREG_IRQ_RX_ALL (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_RX_FORCED)
196#define NVREG_IRQ_OTHER (NVREG_IRQ_TIMER|NVREG_IRQ_LINK) 200#define NVREG_IRQ_OTHER (NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RECOVER_ERROR)
197 201
198#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \ 202#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \
199 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RX_FORCED| \ 203 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_RX_FORCED| \
200 NVREG_IRQ_TX_FORCED)) 204 NVREG_IRQ_TX_FORCED|NVREG_IRQ_RECOVER_ERROR))
201 205
202 NvRegUnknownSetupReg6 = 0x008, 206 NvRegUnknownSetupReg6 = 0x008,
203#define NVREG_UNKSETUP6_VAL 3 207#define NVREG_UNKSETUP6_VAL 3
@@ -222,6 +226,15 @@ enum {
222#define NVREG_MAC_RESET_ASSERT 0x0F3 226#define NVREG_MAC_RESET_ASSERT 0x0F3
223 NvRegTransmitterControl = 0x084, 227 NvRegTransmitterControl = 0x084,
224#define NVREG_XMITCTL_START 0x01 228#define NVREG_XMITCTL_START 0x01
229#define NVREG_XMITCTL_MGMT_ST 0x40000000
230#define NVREG_XMITCTL_SYNC_MASK 0x000f0000
231#define NVREG_XMITCTL_SYNC_NOT_READY 0x0
232#define NVREG_XMITCTL_SYNC_PHY_INIT 0x00040000
233#define NVREG_XMITCTL_MGMT_SEMA_MASK 0x00000f00
234#define NVREG_XMITCTL_MGMT_SEMA_FREE 0x0
235#define NVREG_XMITCTL_HOST_SEMA_MASK 0x0000f000
236#define NVREG_XMITCTL_HOST_SEMA_ACQ 0x0000f000
237#define NVREG_XMITCTL_HOST_LOADED 0x00004000
225 NvRegTransmitterStatus = 0x088, 238 NvRegTransmitterStatus = 0x088,
226#define NVREG_XMITSTAT_BUSY 0x01 239#define NVREG_XMITSTAT_BUSY 0x01
227 240
@@ -304,8 +317,8 @@ enum {
304#define NVREG_MIISTAT_LINKCHANGE 0x0008 317#define NVREG_MIISTAT_LINKCHANGE 0x0008
305#define NVREG_MIISTAT_MASK 0x000f 318#define NVREG_MIISTAT_MASK 0x000f
306#define NVREG_MIISTAT_MASK2 0x000f 319#define NVREG_MIISTAT_MASK2 0x000f
307 NvRegUnknownSetupReg4 = 0x184, 320 NvRegMIIMask = 0x184,
308#define NVREG_UNKSETUP4_VAL 8 321#define NVREG_MII_LINKCHANGE 0x0008
309 322
310 NvRegAdapterControl = 0x188, 323 NvRegAdapterControl = 0x188,
311#define NVREG_ADAPTCTL_START 0x02 324#define NVREG_ADAPTCTL_START 0x02
@@ -707,6 +720,7 @@ struct fe_priv {
707 unsigned int phy_model; 720 unsigned int phy_model;
708 u16 gigabit; 721 u16 gigabit;
709 int intr_test; 722 int intr_test;
723 int recover_error;
710 724
711 /* General data: RO fields */ 725 /* General data: RO fields */
712 dma_addr_t ring_addr; 726 dma_addr_t ring_addr;
@@ -719,6 +733,7 @@ struct fe_priv {
719 u32 driver_data; 733 u32 driver_data;
720 u32 register_size; 734 u32 register_size;
721 int rx_csum; 735 int rx_csum;
736 u32 mac_in_use;
722 737
723 void __iomem *base; 738 void __iomem *base;
724 739
@@ -2443,6 +2458,23 @@ static irqreturn_t nv_nic_irq(int foo, void *data)
2443 printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n", 2458 printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n",
2444 dev->name, events); 2459 dev->name, events);
2445 } 2460 }
2461 if (unlikely(events & NVREG_IRQ_RECOVER_ERROR)) {
2462 spin_lock(&np->lock);
2463 /* disable interrupts on the nic */
2464 if (!(np->msi_flags & NV_MSI_X_ENABLED))
2465 writel(0, base + NvRegIrqMask);
2466 else
2467 writel(np->irqmask, base + NvRegIrqMask);
2468 pci_push(base);
2469
2470 if (!np->in_shutdown) {
2471 np->nic_poll_irq = np->irqmask;
2472 np->recover_error = 1;
2473 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2474 }
2475 spin_unlock(&np->lock);
2476 break;
2477 }
2446#ifdef CONFIG_FORCEDETH_NAPI 2478#ifdef CONFIG_FORCEDETH_NAPI
2447 if (events & NVREG_IRQ_RX_ALL) { 2479 if (events & NVREG_IRQ_RX_ALL) {
2448 netif_rx_schedule(dev); 2480 netif_rx_schedule(dev);
@@ -2673,6 +2705,20 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2673 spin_unlock_irqrestore(&np->lock, flags); 2705 spin_unlock_irqrestore(&np->lock, flags);
2674 np->link_timeout = jiffies + LINK_TIMEOUT; 2706 np->link_timeout = jiffies + LINK_TIMEOUT;
2675 } 2707 }
2708 if (events & NVREG_IRQ_RECOVER_ERROR) {
2709 spin_lock_irq(&np->lock);
2710 /* disable interrupts on the nic */
2711 writel(NVREG_IRQ_OTHER, base + NvRegIrqMask);
2712 pci_push(base);
2713
2714 if (!np->in_shutdown) {
2715 np->nic_poll_irq |= NVREG_IRQ_OTHER;
2716 np->recover_error = 1;
2717 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2718 }
2719 spin_unlock_irq(&np->lock);
2720 break;
2721 }
2676 if (events & (NVREG_IRQ_UNKNOWN)) { 2722 if (events & (NVREG_IRQ_UNKNOWN)) {
2677 printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n", 2723 printk(KERN_DEBUG "%s: received irq with unknown events 0x%x. Please report\n",
2678 dev->name, events); 2724 dev->name, events);
@@ -2902,6 +2948,42 @@ static void nv_do_nic_poll(unsigned long data)
2902 } 2948 }
2903 np->nic_poll_irq = 0; 2949 np->nic_poll_irq = 0;
2904 2950
2951 if (np->recover_error) {
2952 np->recover_error = 0;
2953 printk(KERN_INFO "forcedeth: MAC in recoverable error state\n");
2954 if (netif_running(dev)) {
2955 netif_tx_lock_bh(dev);
2956 spin_lock(&np->lock);
2957 /* stop engines */
2958 nv_stop_rx(dev);
2959 nv_stop_tx(dev);
2960 nv_txrx_reset(dev);
2961 /* drain rx queue */
2962 nv_drain_rx(dev);
2963 nv_drain_tx(dev);
2964 /* reinit driver view of the rx queue */
2965 set_bufsize(dev);
2966 if (nv_init_ring(dev)) {
2967 if (!np->in_shutdown)
2968 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
2969 }
2970 /* reinit nic view of the rx queue */
2971 writel(np->rx_buf_sz, base + NvRegOffloadConfig);
2972 setup_hw_rings(dev, NV_SETUP_RX_RING | NV_SETUP_TX_RING);
2973 writel( ((np->rx_ring_size-1) << NVREG_RINGSZ_RXSHIFT) + ((np->tx_ring_size-1) << NVREG_RINGSZ_TXSHIFT),
2974 base + NvRegRingSizes);
2975 pci_push(base);
2976 writel(NVREG_TXRXCTL_KICK|np->txrxctl_bits, get_hwbase(dev) + NvRegTxRxControl);
2977 pci_push(base);
2978
2979 /* restart rx engine */
2980 nv_start_rx(dev);
2981 nv_start_tx(dev);
2982 spin_unlock(&np->lock);
2983 netif_tx_unlock_bh(dev);
2984 }
2985 }
2986
2905 /* FIXME: Do we need synchronize_irq(dev->irq) here? */ 2987 /* FIXME: Do we need synchronize_irq(dev->irq) here? */
2906 2988
2907 writel(mask, base + NvRegIrqMask); 2989 writel(mask, base + NvRegIrqMask);
@@ -4030,6 +4112,54 @@ static void nv_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
4030 /* nothing to do */ 4112 /* nothing to do */
4031}; 4113};
4032 4114
4115/* The mgmt unit and driver use a semaphore to access the phy during init */
4116static int nv_mgmt_acquire_sema(struct net_device *dev)
4117{
4118 u8 __iomem *base = get_hwbase(dev);
4119 int i;
4120 u32 tx_ctrl, mgmt_sema;
4121
4122 for (i = 0; i < 10; i++) {
4123 mgmt_sema = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_MGMT_SEMA_MASK;
4124 if (mgmt_sema == NVREG_XMITCTL_MGMT_SEMA_FREE)
4125 break;
4126 msleep(500);
4127 }
4128
4129 if (mgmt_sema != NVREG_XMITCTL_MGMT_SEMA_FREE)
4130 return 0;
4131
4132 for (i = 0; i < 2; i++) {
4133 tx_ctrl = readl(base + NvRegTransmitterControl);
4134 tx_ctrl |= NVREG_XMITCTL_HOST_SEMA_ACQ;
4135 writel(tx_ctrl, base + NvRegTransmitterControl);
4136
4137 /* verify that semaphore was acquired */
4138 tx_ctrl = readl(base + NvRegTransmitterControl);
4139 if (((tx_ctrl & NVREG_XMITCTL_HOST_SEMA_MASK) == NVREG_XMITCTL_HOST_SEMA_ACQ) &&
4140 ((tx_ctrl & NVREG_XMITCTL_MGMT_SEMA_MASK) == NVREG_XMITCTL_MGMT_SEMA_FREE))
4141 return 1;
4142 else
4143 udelay(50);
4144 }
4145
4146 return 0;
4147}
4148
4149/* Indicate to mgmt unit whether driver is loaded or not */
4150static void nv_mgmt_driver_loaded(struct net_device *dev, int loaded)
4151{
4152 u8 __iomem *base = get_hwbase(dev);
4153 u32 tx_ctrl;
4154
4155 tx_ctrl = readl(base + NvRegTransmitterControl);
4156 if (loaded)
4157 tx_ctrl |= NVREG_XMITCTL_HOST_LOADED;
4158 else
4159 tx_ctrl &= ~NVREG_XMITCTL_HOST_LOADED;
4160 writel(tx_ctrl, base + NvRegTransmitterControl);
4161}
4162
4033static int nv_open(struct net_device *dev) 4163static int nv_open(struct net_device *dev)
4034{ 4164{
4035 struct fe_priv *np = netdev_priv(dev); 4165 struct fe_priv *np = netdev_priv(dev);
@@ -4085,7 +4215,7 @@ static int nv_open(struct net_device *dev)
4085 NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX, 4215 NV_SETUP5_DELAY, NV_SETUP5_DELAYMAX,
4086 KERN_INFO "open: SetupReg5, Bit 31 remained off\n"); 4216 KERN_INFO "open: SetupReg5, Bit 31 remained off\n");
4087 4217
4088 writel(0, base + NvRegUnknownSetupReg4); 4218 writel(0, base + NvRegMIIMask);
4089 writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus); 4219 writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus);
4090 writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus); 4220 writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus);
4091 4221
@@ -4111,7 +4241,7 @@ static int nv_open(struct net_device *dev)
4111 writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING, 4241 writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING,
4112 base + NvRegAdapterControl); 4242 base + NvRegAdapterControl);
4113 writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed); 4243 writel(NVREG_MIISPEED_BIT8|NVREG_MIIDELAY, base + NvRegMIISpeed);
4114 writel(NVREG_UNKSETUP4_VAL, base + NvRegUnknownSetupReg4); 4244 writel(NVREG_MII_LINKCHANGE, base + NvRegMIIMask);
4115 if (np->wolenabled) 4245 if (np->wolenabled)
4116 writel(NVREG_WAKEUPFLAGS_ENABLE , base + NvRegWakeUpFlags); 4246 writel(NVREG_WAKEUPFLAGS_ENABLE , base + NvRegWakeUpFlags);
4117 4247
@@ -4230,6 +4360,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4230 u8 __iomem *base; 4360 u8 __iomem *base;
4231 int err, i; 4361 int err, i;
4232 u32 powerstate, txreg; 4362 u32 powerstate, txreg;
4363 u32 phystate_orig = 0, phystate;
4364 int phyinitialized = 0;
4233 4365
4234 dev = alloc_etherdev(sizeof(struct fe_priv)); 4366 dev = alloc_etherdev(sizeof(struct fe_priv));
4235 err = -ENOMEM; 4367 err = -ENOMEM;
@@ -4514,6 +4646,48 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4514 np->need_linktimer = 0; 4646 np->need_linktimer = 0;
4515 } 4647 }
4516 4648
4649 /* clear phy state and temporarily halt phy interrupts */
4650 writel(0, base + NvRegMIIMask);
4651 phystate = readl(base + NvRegAdapterControl);
4652 if (phystate & NVREG_ADAPTCTL_RUNNING) {
4653 phystate_orig = 1;
4654 phystate &= ~NVREG_ADAPTCTL_RUNNING;
4655 writel(phystate, base + NvRegAdapterControl);
4656 }
4657 writel(NVREG_MIISTAT_MASK, base + NvRegMIIStatus);
4658
4659 if (id->driver_data & DEV_HAS_MGMT_UNIT) {
4660 writel(0x1, base + 0x204); pci_push(base);
4661 msleep(500);
4662 /* management unit running on the mac? */
4663 np->mac_in_use = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_MGMT_ST;
4664 if (np->mac_in_use) {
4665 u32 mgmt_sync;
4666 /* management unit setup the phy already? */
4667 mgmt_sync = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_SYNC_MASK;
4668 if (mgmt_sync == NVREG_XMITCTL_SYNC_NOT_READY) {
4669 if (!nv_mgmt_acquire_sema(dev)) {
4670 for (i = 0; i < 5000; i++) {
4671 msleep(1);
4672 mgmt_sync = readl(base + NvRegTransmitterControl) & NVREG_XMITCTL_SYNC_MASK;
4673 if (mgmt_sync == NVREG_XMITCTL_SYNC_NOT_READY)
4674 continue;
4675 if (mgmt_sync == NVREG_XMITCTL_SYNC_PHY_INIT)
4676 phyinitialized = 1;
4677 break;
4678 }
4679 } else {
4680 /* we need to init the phy */
4681 }
4682 } else if (mgmt_sync == NVREG_XMITCTL_SYNC_PHY_INIT) {
4683 /* phy is inited by SMU */
4684 phyinitialized = 1;
4685 } else {
4686 /* we need to init the phy */
4687 }
4688 }
4689 }
4690
4517 /* find a suitable phy */ 4691 /* find a suitable phy */
4518 for (i = 1; i <= 32; i++) { 4692 for (i = 1; i <= 32; i++) {
4519 int id1, id2; 4693 int id1, id2;
@@ -4545,8 +4719,14 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4545 goto out_error; 4719 goto out_error;
4546 } 4720 }
4547 4721
4548 /* reset it */ 4722 if (!phyinitialized) {
4549 phy_init(dev); 4723 /* reset it */
4724 phy_init(dev);
4725 }
4726
4727 if (id->driver_data & DEV_HAS_MGMT_UNIT) {
4728 nv_mgmt_driver_loaded(dev, 1);
4729 }
4550 4730
4551 /* set default link speed settings */ 4731 /* set default link speed settings */
4552 np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; 4732 np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
@@ -4565,6 +4745,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
4565 return 0; 4745 return 0;
4566 4746
4567out_error: 4747out_error:
4748 if (phystate_orig)
4749 writel(phystate|NVREG_ADAPTCTL_RUNNING, base + NvRegAdapterControl);
4750 if (np->mac_in_use)
4751 nv_mgmt_driver_loaded(dev, 0);
4568 pci_set_drvdata(pci_dev, NULL); 4752 pci_set_drvdata(pci_dev, NULL);
4569out_freering: 4753out_freering:
4570 free_rings(dev); 4754 free_rings(dev);
@@ -4594,6 +4778,9 @@ static void __devexit nv_remove(struct pci_dev *pci_dev)
4594 writel(np->orig_mac[0], base + NvRegMacAddrA); 4778 writel(np->orig_mac[0], base + NvRegMacAddrA);
4595 writel(np->orig_mac[1], base + NvRegMacAddrB); 4779 writel(np->orig_mac[1], base + NvRegMacAddrB);
4596 4780
4781 if (np->mac_in_use)
4782 nv_mgmt_driver_loaded(dev, 0);
4783
4597 /* free all structures */ 4784 /* free all structures */
4598 free_rings(dev); 4785 free_rings(dev);
4599 iounmap(get_hwbase(dev)); 4786 iounmap(get_hwbase(dev));
@@ -4603,6 +4790,50 @@ static void __devexit nv_remove(struct pci_dev *pci_dev)
4603 pci_set_drvdata(pci_dev, NULL); 4790 pci_set_drvdata(pci_dev, NULL);
4604} 4791}
4605 4792
4793#ifdef CONFIG_PM
4794static int nv_suspend(struct pci_dev *pdev, pm_message_t state)
4795{
4796 struct net_device *dev = pci_get_drvdata(pdev);
4797 struct fe_priv *np = netdev_priv(dev);
4798
4799 if (!netif_running(dev))
4800 goto out;
4801
4802 netif_device_detach(dev);
4803
4804 // Gross.
4805 nv_close(dev);
4806
4807 pci_save_state(pdev);
4808 pci_enable_wake(pdev, pci_choose_state(pdev, state), np->wolenabled);
4809 pci_set_power_state(pdev, pci_choose_state(pdev, state));
4810out:
4811 return 0;
4812}
4813
4814static int nv_resume(struct pci_dev *pdev)
4815{
4816 struct net_device *dev = pci_get_drvdata(pdev);
4817 int rc = 0;
4818
4819 if (!netif_running(dev))
4820 goto out;
4821
4822 netif_device_attach(dev);
4823
4824 pci_set_power_state(pdev, PCI_D0);
4825 pci_restore_state(pdev);
4826 pci_enable_wake(pdev, PCI_D0, 0);
4827
4828 rc = nv_open(dev);
4829out:
4830 return rc;
4831}
4832#else
4833#define nv_suspend NULL
4834#define nv_resume NULL
4835#endif /* CONFIG_PM */
4836
4606static struct pci_device_id pci_tbl[] = { 4837static struct pci_device_id pci_tbl[] = {
4607 { /* nForce Ethernet Controller */ 4838 { /* nForce Ethernet Controller */
4608 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_1), 4839 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_1),
@@ -4658,43 +4889,59 @@ static struct pci_device_id pci_tbl[] = {
4658 }, 4889 },
4659 { /* MCP55 Ethernet Controller */ 4890 { /* MCP55 Ethernet Controller */
4660 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14), 4891 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14),
4661 .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, 4892 .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|DEV_HAS_MGMT_UNIT,
4662 }, 4893 },
4663 { /* MCP55 Ethernet Controller */ 4894 { /* MCP55 Ethernet Controller */
4664 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15), 4895 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15),
4665 .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, 4896 .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|DEV_HAS_MGMT_UNIT,
4666 }, 4897 },
4667 { /* MCP61 Ethernet Controller */ 4898 { /* MCP61 Ethernet Controller */
4668 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16), 4899 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16),
4669 .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, 4900 .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|DEV_HAS_MGMT_UNIT,
4670 }, 4901 },
4671 { /* MCP61 Ethernet Controller */ 4902 { /* MCP61 Ethernet Controller */
4672 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17), 4903 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17),
4673 .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, 4904 .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|DEV_HAS_MGMT_UNIT,
4674 }, 4905 },
4675 { /* MCP61 Ethernet Controller */ 4906 { /* MCP61 Ethernet Controller */
4676 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18), 4907 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18),
4677 .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, 4908 .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|DEV_HAS_MGMT_UNIT,
4678 }, 4909 },
4679 { /* MCP61 Ethernet Controller */ 4910 { /* MCP61 Ethernet Controller */
4680 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19), 4911 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19),
4681 .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, 4912 .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|DEV_HAS_MGMT_UNIT,
4682 }, 4913 },
4683 { /* MCP65 Ethernet Controller */ 4914 { /* MCP65 Ethernet Controller */
4684 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20), 4915 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20),
4685 .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, 4916 .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|DEV_HAS_MGMT_UNIT,
4686 }, 4917 },
4687 { /* MCP65 Ethernet Controller */ 4918 { /* MCP65 Ethernet Controller */
4688 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21), 4919 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21),
4689 .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, 4920 .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|DEV_HAS_MGMT_UNIT,
4690 }, 4921 },
4691 { /* MCP65 Ethernet Controller */ 4922 { /* MCP65 Ethernet Controller */
4692 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22), 4923 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22),
4693 .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, 4924 .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|DEV_HAS_MGMT_UNIT,
4694 }, 4925 },
4695 { /* MCP65 Ethernet Controller */ 4926 { /* MCP65 Ethernet Controller */
4696 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23), 4927 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23),
4697 .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, 4928 .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|DEV_HAS_MGMT_UNIT,
4929 },
4930 { /* MCP67 Ethernet Controller */
4931 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_24),
4932 .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|DEV_HAS_MGMT_UNIT,
4933 },
4934 { /* MCP67 Ethernet Controller */
4935 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_25),
4936 .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|DEV_HAS_MGMT_UNIT,
4937 },
4938 { /* MCP67 Ethernet Controller */
4939 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_26),
4940 .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|DEV_HAS_MGMT_UNIT,
4941 },
4942 { /* MCP67 Ethernet Controller */
4943 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_27),
4944 .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|DEV_HAS_MGMT_UNIT,
4698 }, 4945 },
4699 {0,}, 4946 {0,},
4700}; 4947};
@@ -4704,9 +4951,10 @@ static struct pci_driver driver = {
4704 .id_table = pci_tbl, 4951 .id_table = pci_tbl,
4705 .probe = nv_probe, 4952 .probe = nv_probe,
4706 .remove = __devexit_p(nv_remove), 4953 .remove = __devexit_p(nv_remove),
4954 .suspend = nv_suspend,
4955 .resume = nv_resume,
4707}; 4956};
4708 4957
4709
4710static int __init init_nic(void) 4958static int __init init_nic(void)
4711{ 4959{
4712 printk(KERN_INFO "forcedeth.c: Reverse Engineered nForce ethernet driver. Version %s.\n", FORCEDETH_VERSION); 4960 printk(KERN_INFO "forcedeth.c: Reverse Engineered nForce ethernet driver. Version %s.\n", FORCEDETH_VERSION);
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index cb3958704a87..889d3a13e95e 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -779,7 +779,8 @@ static int fs_init_phy(struct net_device *dev)
779 fep->oldspeed = 0; 779 fep->oldspeed = 0;
780 fep->oldduplex = -1; 780 fep->oldduplex = -1;
781 if(fep->fpi->bus_id) 781 if(fep->fpi->bus_id)
782 phydev = phy_connect(dev, fep->fpi->bus_id, &fs_adjust_link, 0); 782 phydev = phy_connect(dev, fep->fpi->bus_id, &fs_adjust_link, 0,
783 PHY_INTERFACE_MODE_MII);
783 else { 784 else {
784 printk("No phy bus ID specified in BSP code\n"); 785 printk("No phy bus ID specified in BSP code\n");
785 return -EINVAL; 786 return -EINVAL;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index a06d8d1aaceb..baa35144134c 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -9,7 +9,7 @@
9 * Author: Andy Fleming 9 * Author: Andy Fleming
10 * Maintainer: Kumar Gala 10 * Maintainer: Kumar Gala
11 * 11 *
12 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 12 * Copyright (c) 2002-2006 Freescale Semiconductor, Inc.
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it 14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the 15 * under the terms of the GNU General Public License as published by the
@@ -133,6 +133,9 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
133#ifdef CONFIG_GFAR_NAPI 133#ifdef CONFIG_GFAR_NAPI
134static int gfar_poll(struct net_device *dev, int *budget); 134static int gfar_poll(struct net_device *dev, int *budget);
135#endif 135#endif
136#ifdef CONFIG_NET_POLL_CONTROLLER
137static void gfar_netpoll(struct net_device *dev);
138#endif
136int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit); 139int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
137static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length); 140static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length);
138static void gfar_vlan_rx_register(struct net_device *netdev, 141static void gfar_vlan_rx_register(struct net_device *netdev,
@@ -260,6 +263,9 @@ static int gfar_probe(struct platform_device *pdev)
260 dev->poll = gfar_poll; 263 dev->poll = gfar_poll;
261 dev->weight = GFAR_DEV_WEIGHT; 264 dev->weight = GFAR_DEV_WEIGHT;
262#endif 265#endif
266#ifdef CONFIG_NET_POLL_CONTROLLER
267 dev->poll_controller = gfar_netpoll;
268#endif
263 dev->stop = gfar_close; 269 dev->stop = gfar_close;
264 dev->get_stats = gfar_get_stats; 270 dev->get_stats = gfar_get_stats;
265 dev->change_mtu = gfar_change_mtu; 271 dev->change_mtu = gfar_change_mtu;
@@ -392,6 +398,38 @@ static int gfar_remove(struct platform_device *pdev)
392} 398}
393 399
394 400
401/* Reads the controller's registers to determine what interface
402 * connects it to the PHY.
403 */
404static phy_interface_t gfar_get_interface(struct net_device *dev)
405{
406 struct gfar_private *priv = netdev_priv(dev);
407 u32 ecntrl = gfar_read(&priv->regs->ecntrl);
408
409 if (ecntrl & ECNTRL_SGMII_MODE)
410 return PHY_INTERFACE_MODE_SGMII;
411
412 if (ecntrl & ECNTRL_TBI_MODE) {
413 if (ecntrl & ECNTRL_REDUCED_MODE)
414 return PHY_INTERFACE_MODE_RTBI;
415 else
416 return PHY_INTERFACE_MODE_TBI;
417 }
418
419 if (ecntrl & ECNTRL_REDUCED_MODE) {
420 if (ecntrl & ECNTRL_REDUCED_MII_MODE)
421 return PHY_INTERFACE_MODE_RMII;
422 else
423 return PHY_INTERFACE_MODE_RGMII;
424 }
425
426 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_GIGABIT)
427 return PHY_INTERFACE_MODE_GMII;
428
429 return PHY_INTERFACE_MODE_MII;
430}
431
432
395/* Initializes driver's PHY state, and attaches to the PHY. 433/* Initializes driver's PHY state, and attaches to the PHY.
396 * Returns 0 on success. 434 * Returns 0 on success.
397 */ 435 */
@@ -403,6 +441,7 @@ static int init_phy(struct net_device *dev)
403 SUPPORTED_1000baseT_Full : 0; 441 SUPPORTED_1000baseT_Full : 0;
404 struct phy_device *phydev; 442 struct phy_device *phydev;
405 char phy_id[BUS_ID_SIZE]; 443 char phy_id[BUS_ID_SIZE];
444 phy_interface_t interface;
406 445
407 priv->oldlink = 0; 446 priv->oldlink = 0;
408 priv->oldspeed = 0; 447 priv->oldspeed = 0;
@@ -410,7 +449,9 @@ static int init_phy(struct net_device *dev)
410 449
411 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, priv->einfo->bus_id, priv->einfo->phy_id); 450 snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, priv->einfo->bus_id, priv->einfo->phy_id);
412 451
413 phydev = phy_connect(dev, phy_id, &adjust_link, 0); 452 interface = gfar_get_interface(dev);
453
454 phydev = phy_connect(dev, phy_id, &adjust_link, 0, interface);
414 455
415 if (IS_ERR(phydev)) { 456 if (IS_ERR(phydev)) {
416 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); 457 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
@@ -1536,6 +1577,33 @@ static int gfar_poll(struct net_device *dev, int *budget)
1536} 1577}
1537#endif 1578#endif
1538 1579
1580#ifdef CONFIG_NET_POLL_CONTROLLER
1581/*
1582 * Polling 'interrupt' - used by things like netconsole to send skbs
1583 * without having to re-enable interrupts. It's not called while
1584 * the interrupt routine is executing.
1585 */
1586static void gfar_netpoll(struct net_device *dev)
1587{
1588 struct gfar_private *priv = netdev_priv(dev);
1589
1590 /* If the device has multiple interrupts, run tx/rx */
1591 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) {
1592 disable_irq(priv->interruptTransmit);
1593 disable_irq(priv->interruptReceive);
1594 disable_irq(priv->interruptError);
1595 gfar_interrupt(priv->interruptTransmit, dev);
1596 enable_irq(priv->interruptError);
1597 enable_irq(priv->interruptReceive);
1598 enable_irq(priv->interruptTransmit);
1599 } else {
1600 disable_irq(priv->interruptTransmit);
1601 gfar_interrupt(priv->interruptTransmit, dev);
1602 enable_irq(priv->interruptTransmit);
1603 }
1604}
1605#endif
1606
1539/* The interrupt handler for devices with one interrupt */ 1607/* The interrupt handler for devices with one interrupt */
1540static irqreturn_t gfar_interrupt(int irq, void *dev_id) 1608static irqreturn_t gfar_interrupt(int irq, void *dev_id)
1541{ 1609{
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 9e81a50cf2be..39e9e321fcbc 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -160,7 +160,10 @@ extern const char gfar_driver_version[];
160 160
161#define ECNTRL_INIT_SETTINGS 0x00001000 161#define ECNTRL_INIT_SETTINGS 0x00001000
162#define ECNTRL_TBI_MODE 0x00000020 162#define ECNTRL_TBI_MODE 0x00000020
163#define ECNTRL_REDUCED_MODE 0x00000010
163#define ECNTRL_R100 0x00000008 164#define ECNTRL_R100 0x00000008
165#define ECNTRL_REDUCED_MII_MODE 0x00000004
166#define ECNTRL_SGMII_MODE 0x00000002
164 167
165#define MRBLR_INIT_SETTINGS DEFAULT_RX_BUFFER_SIZE 168#define MRBLR_INIT_SETTINGS DEFAULT_RX_BUFFER_SIZE
166 169
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 86b3bb9bec2d..92420f007b97 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -914,7 +914,7 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd)
914 printk(KERN_DEBUG "6pack: protocol violation\n"); 914 printk(KERN_DEBUG "6pack: protocol violation\n");
915 else 915 else
916 sp->status = 0; 916 sp->status = 0;
917 cmd &= !SIXP_RX_DCD_MASK; 917 cmd &= ~SIXP_RX_DCD_MASK;
918 } 918 }
919 sp->status = cmd & SIXP_PRIO_DATA_MASK; 919 sp->status = cmd & SIXP_PRIO_DATA_MASK;
920 } else { /* output watchdog char if idle */ 920 } else { /* output watchdog char if idle */
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index 91326ea3e12b..f970bfbb9db2 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -31,7 +31,16 @@
31#include <asm/amigahw.h> 31#include <asm/amigahw.h>
32#include <linux/zorro.h> 32#include <linux/zorro.h>
33 33
34#include "8390.h" 34#define EI_SHIFT(x) (ei_local->reg_offset[x])
35#define ei_inb(port) in_8(port)
36#define ei_outb(val,port) out_8(port,val)
37#define ei_inb_p(port) in_8(port)
38#define ei_outb_p(val,port) out_8(port,val)
39
40static const char version[] =
41 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
42
43#include "lib8390.c"
35 44
36#define NE_EN0_DCFG (0x0e*2) 45#define NE_EN0_DCFG (0x0e*2)
37 46
@@ -100,7 +109,7 @@ static int __devinit hydra_init(struct zorro_dev *z)
100 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e, 109 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
101 }; 110 };
102 111
103 dev = alloc_ei_netdev(); 112 dev = ____alloc_ei_netdev(0);
104 if (!dev) 113 if (!dev)
105 return -ENOMEM; 114 return -ENOMEM;
106 SET_MODULE_OWNER(dev); 115 SET_MODULE_OWNER(dev);
@@ -117,7 +126,7 @@ static int __devinit hydra_init(struct zorro_dev *z)
117 dev->irq = IRQ_AMIGA_PORTS; 126 dev->irq = IRQ_AMIGA_PORTS;
118 127
119 /* Install the Interrupt handler */ 128 /* Install the Interrupt handler */
120 if (request_irq(IRQ_AMIGA_PORTS, ei_interrupt, IRQF_SHARED, "Hydra Ethernet", 129 if (request_irq(IRQ_AMIGA_PORTS, __ei_interrupt, IRQF_SHARED, "Hydra Ethernet",
121 dev)) { 130 dev)) {
122 free_netdev(dev); 131 free_netdev(dev);
123 return -EAGAIN; 132 return -EAGAIN;
@@ -139,10 +148,10 @@ static int __devinit hydra_init(struct zorro_dev *z)
139 dev->open = &hydra_open; 148 dev->open = &hydra_open;
140 dev->stop = &hydra_close; 149 dev->stop = &hydra_close;
141#ifdef CONFIG_NET_POLL_CONTROLLER 150#ifdef CONFIG_NET_POLL_CONTROLLER
142 dev->poll_controller = ei_poll; 151 dev->poll_controller = __ei_poll;
143#endif 152#endif
144 153
145 NS8390_init(dev, 0); 154 __NS8390_init(dev, 0);
146 155
147 err = register_netdev(dev); 156 err = register_netdev(dev);
148 if (err) { 157 if (err) {
@@ -164,7 +173,7 @@ static int __devinit hydra_init(struct zorro_dev *z)
164 173
165static int hydra_open(struct net_device *dev) 174static int hydra_open(struct net_device *dev)
166{ 175{
167 ei_open(dev); 176 __ei_open(dev);
168 return 0; 177 return 0;
169} 178}
170 179
@@ -172,7 +181,7 @@ static int hydra_close(struct net_device *dev)
172{ 181{
173 if (ei_debug > 1) 182 if (ei_debug > 1)
174 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); 183 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
175 ei_close(dev); 184 __ei_close(dev);
176 return 0; 185 return 0;
177} 186}
178 187
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index f56b00ee385e..f0d30cf67b5f 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -57,7 +57,6 @@
57#include <net/ip.h> 57#include <net/ip.h>
58 58
59#include <asm/byteorder.h> 59#include <asm/byteorder.h>
60#include <asm/checksum.h>
61#include <asm/io.h> 60#include <asm/io.h>
62#include <asm/pgtable.h> 61#include <asm/pgtable.h>
63#include <asm/uaccess.h> 62#include <asm/uaccess.h>
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 14bda765c2fa..6e95645e7245 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1793,10 +1793,8 @@ err_out_3:
1793err_out_2: 1793err_out_2:
1794 usb_free_urb(self->tx_urb); 1794 usb_free_urb(self->tx_urb);
1795err_out_1: 1795err_out_1:
1796 for (i = 0; i < self->max_rx_urb; i++) { 1796 for (i = 0; i < self->max_rx_urb; i++)
1797 if (self->rx_urb[i]) 1797 usb_free_urb(self->rx_urb[i]);
1798 usb_free_urb(self->rx_urb[i]);
1799 }
1800 free_netdev(net); 1798 free_netdev(net);
1801err_out: 1799err_out:
1802 return ret; 1800 return ret;
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index d1ebb91ed278..e628126c9c49 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -1248,7 +1248,7 @@ ixgb_tx_csum(struct ixgb_adapter *adapter, struct sk_buff *skb)
1248 if(likely(skb->ip_summed == CHECKSUM_PARTIAL)) { 1248 if(likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
1249 struct ixgb_buffer *buffer_info; 1249 struct ixgb_buffer *buffer_info;
1250 css = skb->h.raw - skb->data; 1250 css = skb->h.raw - skb->data;
1251 cso = (skb->h.raw + skb->csum) - skb->data; 1251 cso = css + skb->csum_offset;
1252 1252
1253 i = adapter->tx_ring.next_to_use; 1253 i = adapter->tx_ring.next_to_use;
1254 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i); 1254 context_desc = IXGB_CONTEXT_DESC(adapter->tx_ring, i);
diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c
new file mode 100644
index 000000000000..e726c06b8dc6
--- /dev/null
+++ b/drivers/net/lib8390.c
@@ -0,0 +1,1097 @@
1/* 8390.c: A general NS8390 ethernet driver core for linux. */
2/*
3 Written 1992-94 by Donald Becker.
4
5 Copyright 1993 United States Government as represented by the
6 Director, National Security Agency.
7
8 This software may be used and distributed according to the terms
9 of the GNU General Public License, incorporated herein by reference.
10
11 The author may be reached as becker@scyld.com, or C/O
12 Scyld Computing Corporation
13 410 Severn Ave., Suite 210
14 Annapolis MD 21403
15
16
17 This is the chip-specific code for many 8390-based ethernet adaptors.
18 This is not a complete driver, it must be combined with board-specific
19 code such as ne.c, wd.c, 3c503.c, etc.
20
21 Seeing how at least eight drivers use this code, (not counting the
22 PCMCIA ones either) it is easy to break some card by what seems like
23 a simple innocent change. Please contact me or Donald if you think
24 you have found something that needs changing. -- PG
25
26
27 Changelog:
28
29 Paul Gortmaker : remove set_bit lock, other cleanups.
30 Paul Gortmaker : add ei_get_8390_hdr() so we can pass skb's to
31 ei_block_input() for eth_io_copy_and_sum().
32 Paul Gortmaker : exchange static int ei_pingpong for a #define,
33 also add better Tx error handling.
34 Paul Gortmaker : rewrite Rx overrun handling as per NS specs.
35 Alexey Kuznetsov : use the 8390's six bit hash multicast filter.
36 Paul Gortmaker : tweak ANK's above multicast changes a bit.
37 Paul Gortmaker : update packet statistics for v2.1.x
38 Alan Cox : support arbitary stupid port mappings on the
39 68K Macintosh. Support >16bit I/O spaces
40 Paul Gortmaker : add kmod support for auto-loading of the 8390
41 module by all drivers that require it.
42 Alan Cox : Spinlocking work, added 'BUG_83C690'
43 Paul Gortmaker : Separate out Tx timeout code from Tx path.
44 Paul Gortmaker : Remove old unused single Tx buffer code.
45 Hayato Fujiwara : Add m32r support.
46 Paul Gortmaker : use skb_padto() instead of stack scratch area
47
48 Sources:
49 The National Semiconductor LAN Databook, and the 3Com 3c503 databook.
50
51 */
52
53#include <linux/module.h>
54#include <linux/kernel.h>
55#include <linux/jiffies.h>
56#include <linux/fs.h>
57#include <linux/types.h>
58#include <linux/string.h>
59#include <linux/bitops.h>
60#include <asm/system.h>
61#include <asm/uaccess.h>
62#include <asm/io.h>
63#include <asm/irq.h>
64#include <linux/delay.h>
65#include <linux/errno.h>
66#include <linux/fcntl.h>
67#include <linux/in.h>
68#include <linux/interrupt.h>
69#include <linux/init.h>
70#include <linux/crc32.h>
71
72#include <linux/netdevice.h>
73#include <linux/etherdevice.h>
74
75#define NS8390_CORE
76#include "8390.h"
77
78#define BUG_83C690
79
80/* These are the operational function interfaces to board-specific
81 routines.
82 void reset_8390(struct net_device *dev)
83 Resets the board associated with DEV, including a hardware reset of
84 the 8390. This is only called when there is a transmit timeout, and
85 it is always followed by 8390_init().
86 void block_output(struct net_device *dev, int count, const unsigned char *buf,
87 int start_page)
88 Write the COUNT bytes of BUF to the packet buffer at START_PAGE. The
89 "page" value uses the 8390's 256-byte pages.
90 void get_8390_hdr(struct net_device *dev, struct e8390_hdr *hdr, int ring_page)
91 Read the 4 byte, page aligned 8390 header. *If* there is a
92 subsequent read, it will be of the rest of the packet.
93 void block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
94 Read COUNT bytes from the packet buffer into the skb data area. Start
95 reading from RING_OFFSET, the address as the 8390 sees it. This will always
96 follow the read of the 8390 header.
97*/
98#define ei_reset_8390 (ei_local->reset_8390)
99#define ei_block_output (ei_local->block_output)
100#define ei_block_input (ei_local->block_input)
101#define ei_get_8390_hdr (ei_local->get_8390_hdr)
102
103/* use 0 for production, 1 for verification, >2 for debug */
104#ifndef ei_debug
105int ei_debug = 1;
106#endif
107
108/* Index to functions. */
109static void ei_tx_intr(struct net_device *dev);
110static void ei_tx_err(struct net_device *dev);
111static void ei_tx_timeout(struct net_device *dev);
112static void ei_receive(struct net_device *dev);
113static void ei_rx_overrun(struct net_device *dev);
114
115/* Routines generic to NS8390-based boards. */
116static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
117 int start_page);
118static void set_multicast_list(struct net_device *dev);
119static void do_set_multicast_list(struct net_device *dev);
120static void __NS8390_init(struct net_device *dev, int startp);
121
122/*
123 * SMP and the 8390 setup.
124 *
125 * The 8390 isnt exactly designed to be multithreaded on RX/TX. There is
126 * a page register that controls bank and packet buffer access. We guard
127 * this with ei_local->page_lock. Nobody should assume or set the page other
128 * than zero when the lock is not held. Lock holders must restore page 0
129 * before unlocking. Even pure readers must take the lock to protect in
130 * page 0.
131 *
132 * To make life difficult the chip can also be very slow. We therefore can't
133 * just use spinlocks. For the longer lockups we disable the irq the device
134 * sits on and hold the lock. We must hold the lock because there is a dual
135 * processor case other than interrupts (get stats/set multicast list in
136 * parallel with each other and transmit).
137 *
138 * Note: in theory we can just disable the irq on the card _but_ there is
139 * a latency on SMP irq delivery. So we can easily go "disable irq" "sync irqs"
140 * enter lock, take the queued irq. So we waddle instead of flying.
141 *
142 * Finally by special arrangement for the purpose of being generally
143 * annoying the transmit function is called bh atomic. That places
144 * restrictions on the user context callers as disable_irq won't save
145 * them.
146 */
147
148
149
150/**
151 * ei_open - Open/initialize the board.
152 * @dev: network device to initialize
153 *
154 * This routine goes all-out, setting everything
155 * up anew at each open, even though many of these registers should only
156 * need to be set once at boot.
157 */
158static int __ei_open(struct net_device *dev)
159{
160 unsigned long flags;
161 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
162
163 /* The card I/O part of the driver (e.g. 3c503) can hook a Tx timeout
164 wrapper that does e.g. media check & then calls ei_tx_timeout. */
165 if (dev->tx_timeout == NULL)
166 dev->tx_timeout = ei_tx_timeout;
167 if (dev->watchdog_timeo <= 0)
168 dev->watchdog_timeo = TX_TIMEOUT;
169
170 /*
171 * Grab the page lock so we own the register set, then call
172 * the init function.
173 */
174
175 spin_lock_irqsave(&ei_local->page_lock, flags);
176 __NS8390_init(dev, 1);
177 /* Set the flag before we drop the lock, That way the IRQ arrives
178 after its set and we get no silly warnings */
179 netif_start_queue(dev);
180 spin_unlock_irqrestore(&ei_local->page_lock, flags);
181 ei_local->irqlock = 0;
182 return 0;
183}
184
185/**
186 * ei_close - shut down network device
187 * @dev: network device to close
188 *
189 * Opposite of ei_open(). Only used when "ifconfig <devname> down" is done.
190 */
191static int __ei_close(struct net_device *dev)
192{
193 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
194 unsigned long flags;
195
196 /*
197 * Hold the page lock during close
198 */
199
200 spin_lock_irqsave(&ei_local->page_lock, flags);
201 __NS8390_init(dev, 0);
202 spin_unlock_irqrestore(&ei_local->page_lock, flags);
203 netif_stop_queue(dev);
204 return 0;
205}
206
207/**
208 * ei_tx_timeout - handle transmit time out condition
209 * @dev: network device which has apparently fallen asleep
210 *
211 * Called by kernel when device never acknowledges a transmit has
212 * completed (or failed) - i.e. never posted a Tx related interrupt.
213 */
214
215static void ei_tx_timeout(struct net_device *dev)
216{
217 unsigned long e8390_base = dev->base_addr;
218 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
219 int txsr, isr, tickssofar = jiffies - dev->trans_start;
220 unsigned long flags;
221
222#if defined(CONFIG_M32R) && defined(CONFIG_SMP)
223 unsigned long icucr;
224
225 local_irq_save(flags);
226 icucr = inl(M32R_ICU_CR1_PORTL);
227 icucr |= M32R_ICUCR_ISMOD11;
228 outl(icucr, M32R_ICU_CR1_PORTL);
229 local_irq_restore(flags);
230#endif
231 ei_local->stat.tx_errors++;
232
233 spin_lock_irqsave(&ei_local->page_lock, flags);
234 txsr = ei_inb(e8390_base+EN0_TSR);
235 isr = ei_inb(e8390_base+EN0_ISR);
236 spin_unlock_irqrestore(&ei_local->page_lock, flags);
237
238 printk(KERN_DEBUG "%s: Tx timed out, %s TSR=%#2x, ISR=%#2x, t=%d.\n",
239 dev->name, (txsr & ENTSR_ABT) ? "excess collisions." :
240 (isr) ? "lost interrupt?" : "cable problem?", txsr, isr, tickssofar);
241
242 if (!isr && !ei_local->stat.tx_packets)
243 {
244 /* The 8390 probably hasn't gotten on the cable yet. */
245 ei_local->interface_num ^= 1; /* Try a different xcvr. */
246 }
247
248 /* Ugly but a reset can be slow, yet must be protected */
249
250 disable_irq_nosync_lockdep(dev->irq);
251 spin_lock(&ei_local->page_lock);
252
253 /* Try to restart the card. Perhaps the user has fixed something. */
254 ei_reset_8390(dev);
255 __NS8390_init(dev, 1);
256
257 spin_unlock(&ei_local->page_lock);
258 enable_irq_lockdep(dev->irq);
259 netif_wake_queue(dev);
260}
261
262/**
263 * ei_start_xmit - begin packet transmission
264 * @skb: packet to be sent
265 * @dev: network device to which packet is sent
266 *
267 * Sends a packet to an 8390 network device.
268 */
269
270static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
271{
272 unsigned long e8390_base = dev->base_addr;
273 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
274 int send_length = skb->len, output_page;
275 unsigned long flags;
276 char buf[ETH_ZLEN];
277 char *data = skb->data;
278
279 if (skb->len < ETH_ZLEN) {
280 memset(buf, 0, ETH_ZLEN); /* more efficient than doing just the needed bits */
281 memcpy(buf, data, skb->len);
282 send_length = ETH_ZLEN;
283 data = buf;
284 }
285
286 /* Mask interrupts from the ethercard.
287 SMP: We have to grab the lock here otherwise the IRQ handler
288 on another CPU can flip window and race the IRQ mask set. We end
289 up trashing the mcast filter not disabling irqs if we don't lock */
290
291 spin_lock_irqsave(&ei_local->page_lock, flags);
292 ei_outb_p(0x00, e8390_base + EN0_IMR);
293 spin_unlock_irqrestore(&ei_local->page_lock, flags);
294
295
296 /*
297 * Slow phase with lock held.
298 */
299
300 disable_irq_nosync_lockdep_irqsave(dev->irq, &flags);
301
302 spin_lock(&ei_local->page_lock);
303
304 ei_local->irqlock = 1;
305
306 /*
307 * We have two Tx slots available for use. Find the first free
308 * slot, and then perform some sanity checks. With two Tx bufs,
309 * you get very close to transmitting back-to-back packets. With
310 * only one Tx buf, the transmitter sits idle while you reload the
311 * card, leaving a substantial gap between each transmitted packet.
312 */
313
314 if (ei_local->tx1 == 0)
315 {
316 output_page = ei_local->tx_start_page;
317 ei_local->tx1 = send_length;
318 if (ei_debug && ei_local->tx2 > 0)
319 printk(KERN_DEBUG "%s: idle transmitter tx2=%d, lasttx=%d, txing=%d.\n",
320 dev->name, ei_local->tx2, ei_local->lasttx, ei_local->txing);
321 }
322 else if (ei_local->tx2 == 0)
323 {
324 output_page = ei_local->tx_start_page + TX_PAGES/2;
325 ei_local->tx2 = send_length;
326 if (ei_debug && ei_local->tx1 > 0)
327 printk(KERN_DEBUG "%s: idle transmitter, tx1=%d, lasttx=%d, txing=%d.\n",
328 dev->name, ei_local->tx1, ei_local->lasttx, ei_local->txing);
329 }
330 else
331 { /* We should never get here. */
332 if (ei_debug)
333 printk(KERN_DEBUG "%s: No Tx buffers free! tx1=%d tx2=%d last=%d\n",
334 dev->name, ei_local->tx1, ei_local->tx2, ei_local->lasttx);
335 ei_local->irqlock = 0;
336 netif_stop_queue(dev);
337 ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR);
338 spin_unlock(&ei_local->page_lock);
339 enable_irq_lockdep_irqrestore(dev->irq, &flags);
340 ei_local->stat.tx_errors++;
341 return 1;
342 }
343
344 /*
345 * Okay, now upload the packet and trigger a send if the transmitter
346 * isn't already sending. If it is busy, the interrupt handler will
347 * trigger the send later, upon receiving a Tx done interrupt.
348 */
349
350 ei_block_output(dev, send_length, data, output_page);
351
352 if (! ei_local->txing)
353 {
354 ei_local->txing = 1;
355 NS8390_trigger_send(dev, send_length, output_page);
356 dev->trans_start = jiffies;
357 if (output_page == ei_local->tx_start_page)
358 {
359 ei_local->tx1 = -1;
360 ei_local->lasttx = -1;
361 }
362 else
363 {
364 ei_local->tx2 = -1;
365 ei_local->lasttx = -2;
366 }
367 }
368 else ei_local->txqueue++;
369
370 if (ei_local->tx1 && ei_local->tx2)
371 netif_stop_queue(dev);
372 else
373 netif_start_queue(dev);
374
375 /* Turn 8390 interrupts back on. */
376 ei_local->irqlock = 0;
377 ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR);
378
379 spin_unlock(&ei_local->page_lock);
380 enable_irq_lockdep_irqrestore(dev->irq, &flags);
381
382 dev_kfree_skb (skb);
383 ei_local->stat.tx_bytes += send_length;
384
385 return 0;
386}
387
388/**
389 * ei_interrupt - handle the interrupts from an 8390
390 * @irq: interrupt number
391 * @dev_id: a pointer to the net_device
392 *
393 * Handle the ether interface interrupts. We pull packets from
394 * the 8390 via the card specific functions and fire them at the networking
395 * stack. We also handle transmit completions and wake the transmit path if
396 * necessary. We also update the counters and do other housekeeping as
397 * needed.
398 */
399
400static irqreturn_t __ei_interrupt(int irq, void *dev_id)
401{
402 struct net_device *dev = dev_id;
403 unsigned long e8390_base = dev->base_addr;
404 int interrupts, nr_serviced = 0;
405 struct ei_device *ei_local = netdev_priv(dev);
406
407 /*
408 * Protect the irq test too.
409 */
410
411 spin_lock(&ei_local->page_lock);
412
413 if (ei_local->irqlock)
414 {
415#if 1 /* This might just be an interrupt for a PCI device sharing this line */
416 /* The "irqlock" check is only for testing. */
417 printk(ei_local->irqlock
418 ? "%s: Interrupted while interrupts are masked! isr=%#2x imr=%#2x.\n"
419 : "%s: Reentering the interrupt handler! isr=%#2x imr=%#2x.\n",
420 dev->name, ei_inb_p(e8390_base + EN0_ISR),
421 ei_inb_p(e8390_base + EN0_IMR));
422#endif
423 spin_unlock(&ei_local->page_lock);
424 return IRQ_NONE;
425 }
426
427 /* Change to page 0 and read the intr status reg. */
428 ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
429 if (ei_debug > 3)
430 printk(KERN_DEBUG "%s: interrupt(isr=%#2.2x).\n", dev->name,
431 ei_inb_p(e8390_base + EN0_ISR));
432
433 /* !!Assumption!! -- we stay in page 0. Don't break this. */
434 while ((interrupts = ei_inb_p(e8390_base + EN0_ISR)) != 0
435 && ++nr_serviced < MAX_SERVICE)
436 {
437 if (!netif_running(dev)) {
438 printk(KERN_WARNING "%s: interrupt from stopped card\n", dev->name);
439 /* rmk - acknowledge the interrupts */
440 ei_outb_p(interrupts, e8390_base + EN0_ISR);
441 interrupts = 0;
442 break;
443 }
444 if (interrupts & ENISR_OVER)
445 ei_rx_overrun(dev);
446 else if (interrupts & (ENISR_RX+ENISR_RX_ERR))
447 {
448 /* Got a good (?) packet. */
449 ei_receive(dev);
450 }
451 /* Push the next to-transmit packet through. */
452 if (interrupts & ENISR_TX)
453 ei_tx_intr(dev);
454 else if (interrupts & ENISR_TX_ERR)
455 ei_tx_err(dev);
456
457 if (interrupts & ENISR_COUNTERS)
458 {
459 ei_local->stat.rx_frame_errors += ei_inb_p(e8390_base + EN0_COUNTER0);
460 ei_local->stat.rx_crc_errors += ei_inb_p(e8390_base + EN0_COUNTER1);
461 ei_local->stat.rx_missed_errors+= ei_inb_p(e8390_base + EN0_COUNTER2);
462 ei_outb_p(ENISR_COUNTERS, e8390_base + EN0_ISR); /* Ack intr. */
463 }
464
465 /* Ignore any RDC interrupts that make it back to here. */
466 if (interrupts & ENISR_RDC)
467 {
468 ei_outb_p(ENISR_RDC, e8390_base + EN0_ISR);
469 }
470
471 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD);
472 }
473
474 if (interrupts && ei_debug)
475 {
476 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base + E8390_CMD);
477 if (nr_serviced >= MAX_SERVICE)
478 {
479 /* 0xFF is valid for a card removal */
480 if(interrupts!=0xFF)
481 printk(KERN_WARNING "%s: Too much work at interrupt, status %#2.2x\n",
482 dev->name, interrupts);
483 ei_outb_p(ENISR_ALL, e8390_base + EN0_ISR); /* Ack. most intrs. */
484 } else {
485 printk(KERN_WARNING "%s: unknown interrupt %#2x\n", dev->name, interrupts);
486 ei_outb_p(0xff, e8390_base + EN0_ISR); /* Ack. all intrs. */
487 }
488 }
489 spin_unlock(&ei_local->page_lock);
490 return IRQ_RETVAL(nr_serviced > 0);
491}
492
493#ifdef CONFIG_NET_POLL_CONTROLLER
494static void __ei_poll(struct net_device *dev)
495{
496 disable_irq_lockdep(dev->irq);
497 __ei_interrupt(dev->irq, dev);
498 enable_irq_lockdep(dev->irq);
499}
500#endif
501
502/**
503 * ei_tx_err - handle transmitter error
504 * @dev: network device which threw the exception
505 *
506 * A transmitter error has happened. Most likely excess collisions (which
507 * is a fairly normal condition). If the error is one where the Tx will
508 * have been aborted, we try and send another one right away, instead of
509 * letting the failed packet sit and collect dust in the Tx buffer. This
510 * is a much better solution as it avoids kernel based Tx timeouts, and
511 * an unnecessary card reset.
512 *
513 * Called with lock held.
514 */
515
516static void ei_tx_err(struct net_device *dev)
517{
518 unsigned long e8390_base = dev->base_addr;
519 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
520 unsigned char txsr = ei_inb_p(e8390_base+EN0_TSR);
521 unsigned char tx_was_aborted = txsr & (ENTSR_ABT+ENTSR_FU);
522
523#ifdef VERBOSE_ERROR_DUMP
524 printk(KERN_DEBUG "%s: transmitter error (%#2x): ", dev->name, txsr);
525 if (txsr & ENTSR_ABT)
526 printk("excess-collisions ");
527 if (txsr & ENTSR_ND)
528 printk("non-deferral ");
529 if (txsr & ENTSR_CRS)
530 printk("lost-carrier ");
531 if (txsr & ENTSR_FU)
532 printk("FIFO-underrun ");
533 if (txsr & ENTSR_CDH)
534 printk("lost-heartbeat ");
535 printk("\n");
536#endif
537
538 ei_outb_p(ENISR_TX_ERR, e8390_base + EN0_ISR); /* Ack intr. */
539
540 if (tx_was_aborted)
541 ei_tx_intr(dev);
542 else
543 {
544 ei_local->stat.tx_errors++;
545 if (txsr & ENTSR_CRS) ei_local->stat.tx_carrier_errors++;
546 if (txsr & ENTSR_CDH) ei_local->stat.tx_heartbeat_errors++;
547 if (txsr & ENTSR_OWC) ei_local->stat.tx_window_errors++;
548 }
549}
550
551/**
552 * ei_tx_intr - transmit interrupt handler
553 * @dev: network device for which tx intr is handled
554 *
555 * We have finished a transmit: check for errors and then trigger the next
556 * packet to be sent. Called with lock held.
557 */
558
559static void ei_tx_intr(struct net_device *dev)
560{
561 unsigned long e8390_base = dev->base_addr;
562 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
563 int status = ei_inb(e8390_base + EN0_TSR);
564
565 ei_outb_p(ENISR_TX, e8390_base + EN0_ISR); /* Ack intr. */
566
567 /*
568 * There are two Tx buffers, see which one finished, and trigger
569 * the send of another one if it exists.
570 */
571 ei_local->txqueue--;
572
573 if (ei_local->tx1 < 0)
574 {
575 if (ei_local->lasttx != 1 && ei_local->lasttx != -1)
576 printk(KERN_ERR "%s: bogus last_tx_buffer %d, tx1=%d.\n",
577 ei_local->name, ei_local->lasttx, ei_local->tx1);
578 ei_local->tx1 = 0;
579 if (ei_local->tx2 > 0)
580 {
581 ei_local->txing = 1;
582 NS8390_trigger_send(dev, ei_local->tx2, ei_local->tx_start_page + 6);
583 dev->trans_start = jiffies;
584 ei_local->tx2 = -1,
585 ei_local->lasttx = 2;
586 }
587 else ei_local->lasttx = 20, ei_local->txing = 0;
588 }
589 else if (ei_local->tx2 < 0)
590 {
591 if (ei_local->lasttx != 2 && ei_local->lasttx != -2)
592 printk("%s: bogus last_tx_buffer %d, tx2=%d.\n",
593 ei_local->name, ei_local->lasttx, ei_local->tx2);
594 ei_local->tx2 = 0;
595 if (ei_local->tx1 > 0)
596 {
597 ei_local->txing = 1;
598 NS8390_trigger_send(dev, ei_local->tx1, ei_local->tx_start_page);
599 dev->trans_start = jiffies;
600 ei_local->tx1 = -1;
601 ei_local->lasttx = 1;
602 }
603 else
604 ei_local->lasttx = 10, ei_local->txing = 0;
605 }
606// else printk(KERN_WARNING "%s: unexpected TX-done interrupt, lasttx=%d.\n",
607// dev->name, ei_local->lasttx);
608
609 /* Minimize Tx latency: update the statistics after we restart TXing. */
610 if (status & ENTSR_COL)
611 ei_local->stat.collisions++;
612 if (status & ENTSR_PTX)
613 ei_local->stat.tx_packets++;
614 else
615 {
616 ei_local->stat.tx_errors++;
617 if (status & ENTSR_ABT)
618 {
619 ei_local->stat.tx_aborted_errors++;
620 ei_local->stat.collisions += 16;
621 }
622 if (status & ENTSR_CRS)
623 ei_local->stat.tx_carrier_errors++;
624 if (status & ENTSR_FU)
625 ei_local->stat.tx_fifo_errors++;
626 if (status & ENTSR_CDH)
627 ei_local->stat.tx_heartbeat_errors++;
628 if (status & ENTSR_OWC)
629 ei_local->stat.tx_window_errors++;
630 }
631 netif_wake_queue(dev);
632}
633
634/**
635 * ei_receive - receive some packets
636 * @dev: network device with which receive will be run
637 *
638 * We have a good packet(s), get it/them out of the buffers.
639 * Called with lock held.
640 */
641
642static void ei_receive(struct net_device *dev)
643{
644 unsigned long e8390_base = dev->base_addr;
645 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
646 unsigned char rxing_page, this_frame, next_frame;
647 unsigned short current_offset;
648 int rx_pkt_count = 0;
649 struct e8390_pkt_hdr rx_frame;
650 int num_rx_pages = ei_local->stop_page-ei_local->rx_start_page;
651
652 while (++rx_pkt_count < 10)
653 {
654 int pkt_len, pkt_stat;
655
656 /* Get the rx page (incoming packet pointer). */
657 ei_outb_p(E8390_NODMA+E8390_PAGE1, e8390_base + E8390_CMD);
658 rxing_page = ei_inb_p(e8390_base + EN1_CURPAG);
659 ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
660
661 /* Remove one frame from the ring. Boundary is always a page behind. */
662 this_frame = ei_inb_p(e8390_base + EN0_BOUNDARY) + 1;
663 if (this_frame >= ei_local->stop_page)
664 this_frame = ei_local->rx_start_page;
665
666 /* Someday we'll omit the previous, iff we never get this message.
667 (There is at least one clone claimed to have a problem.)
668
669 Keep quiet if it looks like a card removal. One problem here
670 is that some clones crash in roughly the same way.
671 */
672 if (ei_debug > 0 && this_frame != ei_local->current_page && (this_frame!=0x0 || rxing_page!=0xFF))
673 printk(KERN_ERR "%s: mismatched read page pointers %2x vs %2x.\n",
674 dev->name, this_frame, ei_local->current_page);
675
676 if (this_frame == rxing_page) /* Read all the frames? */
677 break; /* Done for now */
678
679 current_offset = this_frame << 8;
680 ei_get_8390_hdr(dev, &rx_frame, this_frame);
681
682 pkt_len = rx_frame.count - sizeof(struct e8390_pkt_hdr);
683 pkt_stat = rx_frame.status;
684
685 next_frame = this_frame + 1 + ((pkt_len+4)>>8);
686
687 /* Check for bogosity warned by 3c503 book: the status byte is never
688 written. This happened a lot during testing! This code should be
689 cleaned up someday. */
690 if (rx_frame.next != next_frame
691 && rx_frame.next != next_frame + 1
692 && rx_frame.next != next_frame - num_rx_pages
693 && rx_frame.next != next_frame + 1 - num_rx_pages) {
694 ei_local->current_page = rxing_page;
695 ei_outb(ei_local->current_page-1, e8390_base+EN0_BOUNDARY);
696 ei_local->stat.rx_errors++;
697 continue;
698 }
699
700 if (pkt_len < 60 || pkt_len > 1518)
701 {
702 if (ei_debug)
703 printk(KERN_DEBUG "%s: bogus packet size: %d, status=%#2x nxpg=%#2x.\n",
704 dev->name, rx_frame.count, rx_frame.status,
705 rx_frame.next);
706 ei_local->stat.rx_errors++;
707 ei_local->stat.rx_length_errors++;
708 }
709 else if ((pkt_stat & 0x0F) == ENRSR_RXOK)
710 {
711 struct sk_buff *skb;
712
713 skb = dev_alloc_skb(pkt_len+2);
714 if (skb == NULL)
715 {
716 if (ei_debug > 1)
717 printk(KERN_DEBUG "%s: Couldn't allocate a sk_buff of size %d.\n",
718 dev->name, pkt_len);
719 ei_local->stat.rx_dropped++;
720 break;
721 }
722 else
723 {
724 skb_reserve(skb,2); /* IP headers on 16 byte boundaries */
725 skb->dev = dev;
726 skb_put(skb, pkt_len); /* Make room */
727 ei_block_input(dev, pkt_len, skb, current_offset + sizeof(rx_frame));
728 skb->protocol=eth_type_trans(skb,dev);
729 netif_rx(skb);
730 dev->last_rx = jiffies;
731 ei_local->stat.rx_packets++;
732 ei_local->stat.rx_bytes += pkt_len;
733 if (pkt_stat & ENRSR_PHY)
734 ei_local->stat.multicast++;
735 }
736 }
737 else
738 {
739 if (ei_debug)
740 printk(KERN_DEBUG "%s: bogus packet: status=%#2x nxpg=%#2x size=%d\n",
741 dev->name, rx_frame.status, rx_frame.next,
742 rx_frame.count);
743 ei_local->stat.rx_errors++;
744 /* NB: The NIC counts CRC, frame and missed errors. */
745 if (pkt_stat & ENRSR_FO)
746 ei_local->stat.rx_fifo_errors++;
747 }
748 next_frame = rx_frame.next;
749
750 /* This _should_ never happen: it's here for avoiding bad clones. */
751 if (next_frame >= ei_local->stop_page) {
752 printk("%s: next frame inconsistency, %#2x\n", dev->name,
753 next_frame);
754 next_frame = ei_local->rx_start_page;
755 }
756 ei_local->current_page = next_frame;
757 ei_outb_p(next_frame-1, e8390_base+EN0_BOUNDARY);
758 }
759
760 /* We used to also ack ENISR_OVER here, but that would sometimes mask
761 a real overrun, leaving the 8390 in a stopped state with rec'vr off. */
762 ei_outb_p(ENISR_RX+ENISR_RX_ERR, e8390_base+EN0_ISR);
763 return;
764}
765
766/**
767 * ei_rx_overrun - handle receiver overrun
768 * @dev: network device which threw exception
769 *
770 * We have a receiver overrun: we have to kick the 8390 to get it started
771 * again. Problem is that you have to kick it exactly as NS prescribes in
772 * the updated datasheets, or "the NIC may act in an unpredictable manner."
773 * This includes causing "the NIC to defer indefinitely when it is stopped
774 * on a busy network." Ugh.
775 * Called with lock held. Don't call this with the interrupts off or your
776 * computer will hate you - it takes 10ms or so.
777 */
778
779static void ei_rx_overrun(struct net_device *dev)
780{
781 unsigned long e8390_base = dev->base_addr;
782 unsigned char was_txing, must_resend = 0;
783 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
784
785 /*
786 * Record whether a Tx was in progress and then issue the
787 * stop command.
788 */
789 was_txing = ei_inb_p(e8390_base+E8390_CMD) & E8390_TRANS;
790 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD);
791
792 if (ei_debug > 1)
793 printk(KERN_DEBUG "%s: Receiver overrun.\n", dev->name);
794 ei_local->stat.rx_over_errors++;
795
796 /*
797 * Wait a full Tx time (1.2ms) + some guard time, NS says 1.6ms total.
798 * Early datasheets said to poll the reset bit, but now they say that
799 * it "is not a reliable indicator and subsequently should be ignored."
800 * We wait at least 10ms.
801 */
802
803 mdelay(10);
804
805 /*
806 * Reset RBCR[01] back to zero as per magic incantation.
807 */
808 ei_outb_p(0x00, e8390_base+EN0_RCNTLO);
809 ei_outb_p(0x00, e8390_base+EN0_RCNTHI);
810
811 /*
812 * See if any Tx was interrupted or not. According to NS, this
813 * step is vital, and skipping it will cause no end of havoc.
814 */
815
816 if (was_txing)
817 {
818 unsigned char tx_completed = ei_inb_p(e8390_base+EN0_ISR) & (ENISR_TX+ENISR_TX_ERR);
819 if (!tx_completed)
820 must_resend = 1;
821 }
822
823 /*
824 * Have to enter loopback mode and then restart the NIC before
825 * you are allowed to slurp packets up off the ring.
826 */
827 ei_outb_p(E8390_TXOFF, e8390_base + EN0_TXCR);
828 ei_outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START, e8390_base + E8390_CMD);
829
830 /*
831 * Clear the Rx ring of all the debris, and ack the interrupt.
832 */
833 ei_receive(dev);
834 ei_outb_p(ENISR_OVER, e8390_base+EN0_ISR);
835
836 /*
837 * Leave loopback mode, and resend any packet that got stopped.
838 */
839 ei_outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR);
840 if (must_resend)
841 ei_outb_p(E8390_NODMA + E8390_PAGE0 + E8390_START + E8390_TRANS, e8390_base + E8390_CMD);
842}
843
844/*
845 * Collect the stats. This is called unlocked and from several contexts.
846 */
847
848static struct net_device_stats *get_stats(struct net_device *dev)
849{
850 unsigned long ioaddr = dev->base_addr;
851 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
852 unsigned long flags;
853
854 /* If the card is stopped, just return the present stats. */
855 if (!netif_running(dev))
856 return &ei_local->stat;
857
858 spin_lock_irqsave(&ei_local->page_lock,flags);
859 /* Read the counter registers, assuming we are in page 0. */
860 ei_local->stat.rx_frame_errors += ei_inb_p(ioaddr + EN0_COUNTER0);
861 ei_local->stat.rx_crc_errors += ei_inb_p(ioaddr + EN0_COUNTER1);
862 ei_local->stat.rx_missed_errors+= ei_inb_p(ioaddr + EN0_COUNTER2);
863 spin_unlock_irqrestore(&ei_local->page_lock, flags);
864
865 return &ei_local->stat;
866}
867
868/*
869 * Form the 64 bit 8390 multicast table from the linked list of addresses
870 * associated with this dev structure.
871 */
872
873static inline void make_mc_bits(u8 *bits, struct net_device *dev)
874{
875 struct dev_mc_list *dmi;
876
877 for (dmi=dev->mc_list; dmi; dmi=dmi->next)
878 {
879 u32 crc;
880 if (dmi->dmi_addrlen != ETH_ALEN)
881 {
882 printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name);
883 continue;
884 }
885 crc = ether_crc(ETH_ALEN, dmi->dmi_addr);
886 /*
887 * The 8390 uses the 6 most significant bits of the
888 * CRC to index the multicast table.
889 */
890 bits[crc>>29] |= (1<<((crc>>26)&7));
891 }
892}
893
894/**
895 * do_set_multicast_list - set/clear multicast filter
896 * @dev: net device for which multicast filter is adjusted
897 *
898 * Set or clear the multicast filter for this adaptor. May be called
899 * from a BH in 2.1.x. Must be called with lock held.
900 */
901
902static void do_set_multicast_list(struct net_device *dev)
903{
904 unsigned long e8390_base = dev->base_addr;
905 int i;
906 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
907
908 if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI)))
909 {
910 memset(ei_local->mcfilter, 0, 8);
911 if (dev->mc_list)
912 make_mc_bits(ei_local->mcfilter, dev);
913 }
914 else
915 memset(ei_local->mcfilter, 0xFF, 8); /* mcast set to accept-all */
916
917 /*
918 * DP8390 manuals don't specify any magic sequence for altering
919 * the multicast regs on an already running card. To be safe, we
920 * ensure multicast mode is off prior to loading up the new hash
921 * table. If this proves to be not enough, we can always resort
922 * to stopping the NIC, loading the table and then restarting.
923 *
924 * Bug Alert! The MC regs on the SMC 83C690 (SMC Elite and SMC
925 * Elite16) appear to be write-only. The NS 8390 data sheet lists
926 * them as r/w so this is a bug. The SMC 83C790 (SMC Ultra and
927 * Ultra32 EISA) appears to have this bug fixed.
928 */
929
930 if (netif_running(dev))
931 ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
932 ei_outb_p(E8390_NODMA + E8390_PAGE1, e8390_base + E8390_CMD);
933 for(i = 0; i < 8; i++)
934 {
935 ei_outb_p(ei_local->mcfilter[i], e8390_base + EN1_MULT_SHIFT(i));
936#ifndef BUG_83C690
937 if(ei_inb_p(e8390_base + EN1_MULT_SHIFT(i))!=ei_local->mcfilter[i])
938 printk(KERN_ERR "Multicast filter read/write mismap %d\n",i);
939#endif
940 }
941 ei_outb_p(E8390_NODMA + E8390_PAGE0, e8390_base + E8390_CMD);
942
943 if(dev->flags&IFF_PROMISC)
944 ei_outb_p(E8390_RXCONFIG | 0x18, e8390_base + EN0_RXCR);
945 else if(dev->flags&IFF_ALLMULTI || dev->mc_list)
946 ei_outb_p(E8390_RXCONFIG | 0x08, e8390_base + EN0_RXCR);
947 else
948 ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR);
949 }
950
951/*
952 * Called without lock held. This is invoked from user context and may
953 * be parallel to just about everything else. Its also fairly quick and
954 * not called too often. Must protect against both bh and irq users
955 */
956
957static void set_multicast_list(struct net_device *dev)
958{
959 unsigned long flags;
960 struct ei_device *ei_local = (struct ei_device*)netdev_priv(dev);
961
962 spin_lock_irqsave(&ei_local->page_lock, flags);
963 do_set_multicast_list(dev);
964 spin_unlock_irqrestore(&ei_local->page_lock, flags);
965}
966
967/**
968 * ethdev_setup - init rest of 8390 device struct
969 * @dev: network device structure to init
970 *
971 * Initialize the rest of the 8390 device structure. Do NOT __init
972 * this, as it is used by 8390 based modular drivers too.
973 */
974
975static void ethdev_setup(struct net_device *dev)
976{
977 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
978 if (ei_debug > 1)
979 printk(version);
980
981 dev->hard_start_xmit = &ei_start_xmit;
982 dev->get_stats = get_stats;
983 dev->set_multicast_list = &set_multicast_list;
984
985 ether_setup(dev);
986
987 spin_lock_init(&ei_local->page_lock);
988}
989
990/**
991 * alloc_ei_netdev - alloc_etherdev counterpart for 8390
992 * @size: extra bytes to allocate
993 *
994 * Allocate 8390-specific net_device.
995 */
996static struct net_device *____alloc_ei_netdev(int size)
997{
998 return alloc_netdev(sizeof(struct ei_device) + size, "eth%d",
999 ethdev_setup);
1000}
1001
1002
1003
1004
1005/* This page of functions should be 8390 generic */
1006/* Follow National Semi's recommendations for initializing the "NIC". */
1007
1008/**
1009 * NS8390_init - initialize 8390 hardware
1010 * @dev: network device to initialize
1011 * @startp: boolean. non-zero value to initiate chip processing
1012 *
1013 * Must be called with lock held.
1014 */
1015
1016static void __NS8390_init(struct net_device *dev, int startp)
1017{
1018 unsigned long e8390_base = dev->base_addr;
1019 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
1020 int i;
1021 int endcfg = ei_local->word16
1022 ? (0x48 | ENDCFG_WTS | (ei_local->bigendian ? ENDCFG_BOS : 0))
1023 : 0x48;
1024
1025 if(sizeof(struct e8390_pkt_hdr)!=4)
1026 panic("8390.c: header struct mispacked\n");
1027 /* Follow National Semi's recommendations for initing the DP83902. */
1028 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD); /* 0x21 */
1029 ei_outb_p(endcfg, e8390_base + EN0_DCFG); /* 0x48 or 0x49 */
1030 /* Clear the remote byte count registers. */
1031 ei_outb_p(0x00, e8390_base + EN0_RCNTLO);
1032 ei_outb_p(0x00, e8390_base + EN0_RCNTHI);
1033 /* Set to monitor and loopback mode -- this is vital!. */
1034 ei_outb_p(E8390_RXOFF, e8390_base + EN0_RXCR); /* 0x20 */
1035 ei_outb_p(E8390_TXOFF, e8390_base + EN0_TXCR); /* 0x02 */
1036 /* Set the transmit page and receive ring. */
1037 ei_outb_p(ei_local->tx_start_page, e8390_base + EN0_TPSR);
1038 ei_local->tx1 = ei_local->tx2 = 0;
1039 ei_outb_p(ei_local->rx_start_page, e8390_base + EN0_STARTPG);
1040 ei_outb_p(ei_local->stop_page-1, e8390_base + EN0_BOUNDARY); /* 3c503 says 0x3f,NS0x26*/
1041 ei_local->current_page = ei_local->rx_start_page; /* assert boundary+1 */
1042 ei_outb_p(ei_local->stop_page, e8390_base + EN0_STOPPG);
1043 /* Clear the pending interrupts and mask. */
1044 ei_outb_p(0xFF, e8390_base + EN0_ISR);
1045 ei_outb_p(0x00, e8390_base + EN0_IMR);
1046
1047 /* Copy the station address into the DS8390 registers. */
1048
1049 ei_outb_p(E8390_NODMA + E8390_PAGE1 + E8390_STOP, e8390_base+E8390_CMD); /* 0x61 */
1050 for(i = 0; i < 6; i++)
1051 {
1052 ei_outb_p(dev->dev_addr[i], e8390_base + EN1_PHYS_SHIFT(i));
1053 if (ei_debug > 1 && ei_inb_p(e8390_base + EN1_PHYS_SHIFT(i))!=dev->dev_addr[i])
1054 printk(KERN_ERR "Hw. address read/write mismap %d\n",i);
1055 }
1056
1057 ei_outb_p(ei_local->rx_start_page, e8390_base + EN1_CURPAG);
1058 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_STOP, e8390_base+E8390_CMD);
1059
1060 netif_start_queue(dev);
1061 ei_local->tx1 = ei_local->tx2 = 0;
1062 ei_local->txing = 0;
1063
1064 if (startp)
1065 {
1066 ei_outb_p(0xff, e8390_base + EN0_ISR);
1067 ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR);
1068 ei_outb_p(E8390_NODMA+E8390_PAGE0+E8390_START, e8390_base+E8390_CMD);
1069 ei_outb_p(E8390_TXCONFIG, e8390_base + EN0_TXCR); /* xmit on. */
1070 /* 3c503 TechMan says rxconfig only after the NIC is started. */
1071 ei_outb_p(E8390_RXCONFIG, e8390_base + EN0_RXCR); /* rx on, */
1072 do_set_multicast_list(dev); /* (re)load the mcast table */
1073 }
1074}
1075
1076/* Trigger a transmit start, assuming the length is valid.
1077 Always called with the page lock held */
1078
1079static void NS8390_trigger_send(struct net_device *dev, unsigned int length,
1080 int start_page)
1081{
1082 unsigned long e8390_base = dev->base_addr;
1083 struct ei_device *ei_local __attribute((unused)) = (struct ei_device *) netdev_priv(dev);
1084
1085 ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD);
1086
1087 if (ei_inb_p(e8390_base + E8390_CMD) & E8390_TRANS)
1088 {
1089 printk(KERN_WARNING "%s: trigger_send() called with the transmitter busy.\n",
1090 dev->name);
1091 return;
1092 }
1093 ei_outb_p(length & 0xff, e8390_base + EN0_TCNTLO);
1094 ei_outb_p(length >> 8, e8390_base + EN0_TCNTHI);
1095 ei_outb_p(start_page, e8390_base + EN0_TPSR);
1096 ei_outb_p(E8390_NODMA+E8390_TRANS+E8390_START, e8390_base+E8390_CMD);
1097}
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index ade6ff852e1a..a12bb64e3694 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -39,7 +39,16 @@
39#include <asm/hwtest.h> 39#include <asm/hwtest.h>
40#include <asm/macints.h> 40#include <asm/macints.h>
41 41
42#include "8390.h" 42static char version[] =
43 "mac8390.c: v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n";
44
45#define EI_SHIFT(x) (ei_local->reg_offset[x])
46#define ei_inb(port) in_8(port)
47#define ei_outb(val,port) out_8(port,val)
48#define ei_inb_p(port) in_8(port)
49#define ei_outb_p(val,port) out_8(port,val)
50
51#include "lib8390.c"
43 52
44#define WD_START_PG 0x00 /* First page of TX buffer */ 53#define WD_START_PG 0x00 /* First page of TX buffer */
45#define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */ 54#define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */
@@ -116,9 +125,6 @@ static int useresources[] = {
116 1, /* dayna-lc */ 125 1, /* dayna-lc */
117}; 126};
118 127
119static char version[] __initdata =
120 "mac8390.c: v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n";
121
122extern enum mac8390_type mac8390_ident(struct nubus_dev * dev); 128extern enum mac8390_type mac8390_ident(struct nubus_dev * dev);
123extern int mac8390_memsize(unsigned long membase); 129extern int mac8390_memsize(unsigned long membase);
124extern int mac8390_memtest(struct net_device * dev); 130extern int mac8390_memtest(struct net_device * dev);
@@ -237,7 +243,7 @@ struct net_device * __init mac8390_probe(int unit)
237 if (!MACH_IS_MAC) 243 if (!MACH_IS_MAC)
238 return ERR_PTR(-ENODEV); 244 return ERR_PTR(-ENODEV);
239 245
240 dev = alloc_ei_netdev(); 246 dev = ____alloc_ei_netdev(0);
241 if (!dev) 247 if (!dev)
242 return ERR_PTR(-ENOMEM); 248 return ERR_PTR(-ENOMEM);
243 249
@@ -438,7 +444,7 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
438 dev->open = &mac8390_open; 444 dev->open = &mac8390_open;
439 dev->stop = &mac8390_close; 445 dev->stop = &mac8390_close;
440#ifdef CONFIG_NET_POLL_CONTROLLER 446#ifdef CONFIG_NET_POLL_CONTROLLER
441 dev->poll_controller = ei_poll; 447 dev->poll_controller = __ei_poll;
442#endif 448#endif
443 449
444 /* GAR, ei_status is actually a macro even though it looks global */ 450 /* GAR, ei_status is actually a macro even though it looks global */
@@ -510,7 +516,7 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
510 return -ENODEV; 516 return -ENODEV;
511 } 517 }
512 518
513 NS8390_init(dev, 0); 519 __NS8390_init(dev, 0);
514 520
515 /* Good, done, now spit out some messages */ 521 /* Good, done, now spit out some messages */
516 printk(KERN_INFO "%s: %s in slot %X (type %s)\n", 522 printk(KERN_INFO "%s: %s in slot %X (type %s)\n",
@@ -532,8 +538,8 @@ static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * nd
532 538
533static int mac8390_open(struct net_device *dev) 539static int mac8390_open(struct net_device *dev)
534{ 540{
535 ei_open(dev); 541 __ei_open(dev);
536 if (request_irq(dev->irq, ei_interrupt, 0, "8390 Ethernet", dev)) { 542 if (request_irq(dev->irq, __ei_interrupt, 0, "8390 Ethernet", dev)) {
537 printk ("%s: unable to get IRQ %d.\n", dev->name, dev->irq); 543 printk ("%s: unable to get IRQ %d.\n", dev->name, dev->irq);
538 return -EAGAIN; 544 return -EAGAIN;
539 } 545 }
@@ -543,7 +549,7 @@ static int mac8390_open(struct net_device *dev)
543static int mac8390_close(struct net_device *dev) 549static int mac8390_close(struct net_device *dev)
544{ 550{
545 free_irq(dev->irq, dev); 551 free_irq(dev->irq, dev);
546 ei_close(dev); 552 __ei_close(dev);
547 return 0; 553 return 0;
548} 554}
549 555
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
new file mode 100644
index 000000000000..bd0ce98c939c
--- /dev/null
+++ b/drivers/net/macb.c
@@ -0,0 +1,1210 @@
1/*
2 * Atmel MACB Ethernet Controller driver
3 *
4 * Copyright (C) 2004-2006 Atmel Corporation
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/clk.h>
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/slab.h>
17#include <linux/init.h>
18#include <linux/netdevice.h>
19#include <linux/etherdevice.h>
20#include <linux/mii.h>
21#include <linux/mutex.h>
22#include <linux/dma-mapping.h>
23#include <linux/ethtool.h>
24#include <linux/platform_device.h>
25
26#include <asm/arch/board.h>
27
28#include "macb.h"
29
30#define to_net_dev(class) container_of(class, struct net_device, class_dev)
31
32#define RX_BUFFER_SIZE 128
33#define RX_RING_SIZE 512
34#define RX_RING_BYTES (sizeof(struct dma_desc) * RX_RING_SIZE)
35
36/* Make the IP header word-aligned (the ethernet header is 14 bytes) */
37#define RX_OFFSET 2
38
39#define TX_RING_SIZE 128
40#define DEF_TX_RING_PENDING (TX_RING_SIZE - 1)
41#define TX_RING_BYTES (sizeof(struct dma_desc) * TX_RING_SIZE)
42
43#define TX_RING_GAP(bp) \
44 (TX_RING_SIZE - (bp)->tx_pending)
45#define TX_BUFFS_AVAIL(bp) \
46 (((bp)->tx_tail <= (bp)->tx_head) ? \
47 (bp)->tx_tail + (bp)->tx_pending - (bp)->tx_head : \
48 (bp)->tx_tail - (bp)->tx_head - TX_RING_GAP(bp))
49#define NEXT_TX(n) (((n) + 1) & (TX_RING_SIZE - 1))
50
51#define NEXT_RX(n) (((n) + 1) & (RX_RING_SIZE - 1))
52
53/* minimum number of free TX descriptors before waking up TX process */
54#define MACB_TX_WAKEUP_THRESH (TX_RING_SIZE / 4)
55
56#define MACB_RX_INT_FLAGS (MACB_BIT(RCOMP) | MACB_BIT(RXUBR) \
57 | MACB_BIT(ISR_ROVR))
58
59static void __macb_set_hwaddr(struct macb *bp)
60{
61 u32 bottom;
62 u16 top;
63
64 bottom = cpu_to_le32(*((u32 *)bp->dev->dev_addr));
65 macb_writel(bp, SA1B, bottom);
66 top = cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4)));
67 macb_writel(bp, SA1T, top);
68}
69
70static void __init macb_get_hwaddr(struct macb *bp)
71{
72 u32 bottom;
73 u16 top;
74 u8 addr[6];
75
76 bottom = macb_readl(bp, SA1B);
77 top = macb_readl(bp, SA1T);
78
79 addr[0] = bottom & 0xff;
80 addr[1] = (bottom >> 8) & 0xff;
81 addr[2] = (bottom >> 16) & 0xff;
82 addr[3] = (bottom >> 24) & 0xff;
83 addr[4] = top & 0xff;
84 addr[5] = (top >> 8) & 0xff;
85
86 if (is_valid_ether_addr(addr))
87 memcpy(bp->dev->dev_addr, addr, sizeof(addr));
88}
89
90static void macb_enable_mdio(struct macb *bp)
91{
92 unsigned long flags;
93 u32 reg;
94
95 spin_lock_irqsave(&bp->lock, flags);
96 reg = macb_readl(bp, NCR);
97 reg |= MACB_BIT(MPE);
98 macb_writel(bp, NCR, reg);
99 macb_writel(bp, IER, MACB_BIT(MFD));
100 spin_unlock_irqrestore(&bp->lock, flags);
101}
102
103static void macb_disable_mdio(struct macb *bp)
104{
105 unsigned long flags;
106 u32 reg;
107
108 spin_lock_irqsave(&bp->lock, flags);
109 reg = macb_readl(bp, NCR);
110 reg &= ~MACB_BIT(MPE);
111 macb_writel(bp, NCR, reg);
112 macb_writel(bp, IDR, MACB_BIT(MFD));
113 spin_unlock_irqrestore(&bp->lock, flags);
114}
115
116static int macb_mdio_read(struct net_device *dev, int phy_id, int location)
117{
118 struct macb *bp = netdev_priv(dev);
119 int value;
120
121 mutex_lock(&bp->mdio_mutex);
122
123 macb_enable_mdio(bp);
124 macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF)
125 | MACB_BF(RW, MACB_MAN_READ)
126 | MACB_BF(PHYA, phy_id)
127 | MACB_BF(REGA, location)
128 | MACB_BF(CODE, MACB_MAN_CODE)));
129
130 wait_for_completion(&bp->mdio_complete);
131
132 value = MACB_BFEXT(DATA, macb_readl(bp, MAN));
133 macb_disable_mdio(bp);
134 mutex_unlock(&bp->mdio_mutex);
135
136 return value;
137}
138
139static void macb_mdio_write(struct net_device *dev, int phy_id,
140 int location, int val)
141{
142 struct macb *bp = netdev_priv(dev);
143
144 dev_dbg(&bp->pdev->dev, "mdio_write %02x:%02x <- %04x\n",
145 phy_id, location, val);
146
147 mutex_lock(&bp->mdio_mutex);
148 macb_enable_mdio(bp);
149
150 macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF)
151 | MACB_BF(RW, MACB_MAN_WRITE)
152 | MACB_BF(PHYA, phy_id)
153 | MACB_BF(REGA, location)
154 | MACB_BF(CODE, MACB_MAN_CODE)
155 | MACB_BF(DATA, val)));
156
157 wait_for_completion(&bp->mdio_complete);
158
159 macb_disable_mdio(bp);
160 mutex_unlock(&bp->mdio_mutex);
161}
162
163static int macb_phy_probe(struct macb *bp)
164{
165 int phy_address;
166 u16 phyid1, phyid2;
167
168 for (phy_address = 0; phy_address < 32; phy_address++) {
169 phyid1 = macb_mdio_read(bp->dev, phy_address, MII_PHYSID1);
170 phyid2 = macb_mdio_read(bp->dev, phy_address, MII_PHYSID2);
171
172 if (phyid1 != 0xffff && phyid1 != 0x0000
173 && phyid2 != 0xffff && phyid2 != 0x0000)
174 break;
175 }
176
177 if (phy_address == 32)
178 return -ENODEV;
179
180 dev_info(&bp->pdev->dev,
181 "detected PHY at address %d (ID %04x:%04x)\n",
182 phy_address, phyid1, phyid2);
183
184 bp->mii.phy_id = phy_address;
185 return 0;
186}
187
188static void macb_set_media(struct macb *bp, int media)
189{
190 u32 reg;
191
192 spin_lock_irq(&bp->lock);
193 reg = macb_readl(bp, NCFGR);
194 reg &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
195 if (media & (ADVERTISE_100HALF | ADVERTISE_100FULL))
196 reg |= MACB_BIT(SPD);
197 if (media & ADVERTISE_FULL)
198 reg |= MACB_BIT(FD);
199 macb_writel(bp, NCFGR, reg);
200 spin_unlock_irq(&bp->lock);
201}
202
203static void macb_check_media(struct macb *bp, int ok_to_print, int init_media)
204{
205 struct mii_if_info *mii = &bp->mii;
206 unsigned int old_carrier, new_carrier;
207 int advertise, lpa, media, duplex;
208
209 /* if forced media, go no further */
210 if (mii->force_media)
211 return;
212
213 /* check current and old link status */
214 old_carrier = netif_carrier_ok(mii->dev) ? 1 : 0;
215 new_carrier = (unsigned int) mii_link_ok(mii);
216
217 /* if carrier state did not change, assume nothing else did */
218 if (!init_media && old_carrier == new_carrier)
219 return;
220
221 /* no carrier, nothing much to do */
222 if (!new_carrier) {
223 netif_carrier_off(mii->dev);
224 printk(KERN_INFO "%s: link down\n", mii->dev->name);
225 return;
226 }
227
228 /*
229 * we have carrier, see who's on the other end
230 */
231 netif_carrier_on(mii->dev);
232
233 /* get MII advertise and LPA values */
234 if (!init_media && mii->advertising) {
235 advertise = mii->advertising;
236 } else {
237 advertise = mii->mdio_read(mii->dev, mii->phy_id, MII_ADVERTISE);
238 mii->advertising = advertise;
239 }
240 lpa = mii->mdio_read(mii->dev, mii->phy_id, MII_LPA);
241
242 /* figure out media and duplex from advertise and LPA values */
243 media = mii_nway_result(lpa & advertise);
244 duplex = (media & ADVERTISE_FULL) ? 1 : 0;
245
246 if (ok_to_print)
247 printk(KERN_INFO "%s: link up, %sMbps, %s-duplex, lpa 0x%04X\n",
248 mii->dev->name,
249 media & (ADVERTISE_100FULL | ADVERTISE_100HALF) ? "100" : "10",
250 duplex ? "full" : "half", lpa);
251
252 mii->full_duplex = duplex;
253
254 /* Let the MAC know about the new link state */
255 macb_set_media(bp, media);
256}
257
258static void macb_update_stats(struct macb *bp)
259{
260 u32 __iomem *reg = bp->regs + MACB_PFR;
261 u32 *p = &bp->hw_stats.rx_pause_frames;
262 u32 *end = &bp->hw_stats.tx_pause_frames + 1;
263
264 WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
265
266 for(; p < end; p++, reg++)
267 *p += readl(reg);
268}
269
270static void macb_periodic_task(void *arg)
271{
272 struct macb *bp = arg;
273
274 macb_update_stats(bp);
275 macb_check_media(bp, 1, 0);
276
277 schedule_delayed_work(&bp->periodic_task, HZ);
278}
279
280static void macb_tx(struct macb *bp)
281{
282 unsigned int tail;
283 unsigned int head;
284 u32 status;
285
286 status = macb_readl(bp, TSR);
287 macb_writel(bp, TSR, status);
288
289 dev_dbg(&bp->pdev->dev, "macb_tx status = %02lx\n",
290 (unsigned long)status);
291
292 if (status & MACB_BIT(UND)) {
293 printk(KERN_ERR "%s: TX underrun, resetting buffers\n",
294 bp->dev->name);
295 bp->tx_head = bp->tx_tail = 0;
296 }
297
298 if (!(status & MACB_BIT(COMP)))
299 /*
300 * This may happen when a buffer becomes complete
301 * between reading the ISR and scanning the
302 * descriptors. Nothing to worry about.
303 */
304 return;
305
306 head = bp->tx_head;
307 for (tail = bp->tx_tail; tail != head; tail = NEXT_TX(tail)) {
308 struct ring_info *rp = &bp->tx_skb[tail];
309 struct sk_buff *skb = rp->skb;
310 u32 bufstat;
311
312 BUG_ON(skb == NULL);
313
314 rmb();
315 bufstat = bp->tx_ring[tail].ctrl;
316
317 if (!(bufstat & MACB_BIT(TX_USED)))
318 break;
319
320 dev_dbg(&bp->pdev->dev, "skb %u (data %p) TX complete\n",
321 tail, skb->data);
322 dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len,
323 DMA_TO_DEVICE);
324 bp->stats.tx_packets++;
325 bp->stats.tx_bytes += skb->len;
326 rp->skb = NULL;
327 dev_kfree_skb_irq(skb);
328 }
329
330 bp->tx_tail = tail;
331 if (netif_queue_stopped(bp->dev) &&
332 TX_BUFFS_AVAIL(bp) > MACB_TX_WAKEUP_THRESH)
333 netif_wake_queue(bp->dev);
334}
335
336static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
337 unsigned int last_frag)
338{
339 unsigned int len;
340 unsigned int frag;
341 unsigned int offset = 0;
342 struct sk_buff *skb;
343
344 len = MACB_BFEXT(RX_FRMLEN, bp->rx_ring[last_frag].ctrl);
345
346 dev_dbg(&bp->pdev->dev, "macb_rx_frame frags %u - %u (len %u)\n",
347 first_frag, last_frag, len);
348
349 skb = dev_alloc_skb(len + RX_OFFSET);
350 if (!skb) {
351 bp->stats.rx_dropped++;
352 for (frag = first_frag; ; frag = NEXT_RX(frag)) {
353 bp->rx_ring[frag].addr &= ~MACB_BIT(RX_USED);
354 if (frag == last_frag)
355 break;
356 }
357 wmb();
358 return 1;
359 }
360
361 skb_reserve(skb, RX_OFFSET);
362 skb->dev = bp->dev;
363 skb->ip_summed = CHECKSUM_NONE;
364 skb_put(skb, len);
365
366 for (frag = first_frag; ; frag = NEXT_RX(frag)) {
367 unsigned int frag_len = RX_BUFFER_SIZE;
368
369 if (offset + frag_len > len) {
370 BUG_ON(frag != last_frag);
371 frag_len = len - offset;
372 }
373 memcpy(skb->data + offset,
374 bp->rx_buffers + (RX_BUFFER_SIZE * frag),
375 frag_len);
376 offset += RX_BUFFER_SIZE;
377 bp->rx_ring[frag].addr &= ~MACB_BIT(RX_USED);
378 wmb();
379
380 if (frag == last_frag)
381 break;
382 }
383
384 skb->protocol = eth_type_trans(skb, bp->dev);
385
386 bp->stats.rx_packets++;
387 bp->stats.rx_bytes += len;
388 bp->dev->last_rx = jiffies;
389 dev_dbg(&bp->pdev->dev, "received skb of length %u, csum: %08x\n",
390 skb->len, skb->csum);
391 netif_receive_skb(skb);
392
393 return 0;
394}
395
396/* Mark DMA descriptors from begin up to and not including end as unused */
397static void discard_partial_frame(struct macb *bp, unsigned int begin,
398 unsigned int end)
399{
400 unsigned int frag;
401
402 for (frag = begin; frag != end; frag = NEXT_RX(frag))
403 bp->rx_ring[frag].addr &= ~MACB_BIT(RX_USED);
404 wmb();
405
406 /*
407 * When this happens, the hardware stats registers for
408 * whatever caused this is updated, so we don't have to record
409 * anything.
410 */
411}
412
413static int macb_rx(struct macb *bp, int budget)
414{
415 int received = 0;
416 unsigned int tail = bp->rx_tail;
417 int first_frag = -1;
418
419 for (; budget > 0; tail = NEXT_RX(tail)) {
420 u32 addr, ctrl;
421
422 rmb();
423 addr = bp->rx_ring[tail].addr;
424 ctrl = bp->rx_ring[tail].ctrl;
425
426 if (!(addr & MACB_BIT(RX_USED)))
427 break;
428
429 if (ctrl & MACB_BIT(RX_SOF)) {
430 if (first_frag != -1)
431 discard_partial_frame(bp, first_frag, tail);
432 first_frag = tail;
433 }
434
435 if (ctrl & MACB_BIT(RX_EOF)) {
436 int dropped;
437 BUG_ON(first_frag == -1);
438
439 dropped = macb_rx_frame(bp, first_frag, tail);
440 first_frag = -1;
441 if (!dropped) {
442 received++;
443 budget--;
444 }
445 }
446 }
447
448 if (first_frag != -1)
449 bp->rx_tail = first_frag;
450 else
451 bp->rx_tail = tail;
452
453 return received;
454}
455
456static int macb_poll(struct net_device *dev, int *budget)
457{
458 struct macb *bp = netdev_priv(dev);
459 int orig_budget, work_done, retval = 0;
460 u32 status;
461
462 status = macb_readl(bp, RSR);
463 macb_writel(bp, RSR, status);
464
465 if (!status) {
466 /*
467 * This may happen if an interrupt was pending before
468 * this function was called last time, and no packets
469 * have been received since.
470 */
471 netif_rx_complete(dev);
472 goto out;
473 }
474
475 dev_dbg(&bp->pdev->dev, "poll: status = %08lx, budget = %d\n",
476 (unsigned long)status, *budget);
477
478 if (!(status & MACB_BIT(REC))) {
479 dev_warn(&bp->pdev->dev,
480 "No RX buffers complete, status = %02lx\n",
481 (unsigned long)status);
482 netif_rx_complete(dev);
483 goto out;
484 }
485
486 orig_budget = *budget;
487 if (orig_budget > dev->quota)
488 orig_budget = dev->quota;
489
490 work_done = macb_rx(bp, orig_budget);
491 if (work_done < orig_budget) {
492 netif_rx_complete(dev);
493 retval = 0;
494 } else {
495 retval = 1;
496 }
497
498 /*
499 * We've done what we can to clean the buffers. Make sure we
500 * get notified when new packets arrive.
501 */
502out:
503 macb_writel(bp, IER, MACB_RX_INT_FLAGS);
504
505 /* TODO: Handle errors */
506
507 return retval;
508}
509
510static irqreturn_t macb_interrupt(int irq, void *dev_id)
511{
512 struct net_device *dev = dev_id;
513 struct macb *bp = netdev_priv(dev);
514 u32 status;
515
516 status = macb_readl(bp, ISR);
517
518 if (unlikely(!status))
519 return IRQ_NONE;
520
521 spin_lock(&bp->lock);
522
523 while (status) {
524 if (status & MACB_BIT(MFD))
525 complete(&bp->mdio_complete);
526
527 /* close possible race with dev_close */
528 if (unlikely(!netif_running(dev))) {
529 macb_writel(bp, IDR, ~0UL);
530 break;
531 }
532
533 if (status & MACB_RX_INT_FLAGS) {
534 if (netif_rx_schedule_prep(dev)) {
535 /*
536 * There's no point taking any more interrupts
537 * until we have processed the buffers
538 */
539 macb_writel(bp, IDR, MACB_RX_INT_FLAGS);
540 dev_dbg(&bp->pdev->dev, "scheduling RX softirq\n");
541 __netif_rx_schedule(dev);
542 }
543 }
544
545 if (status & (MACB_BIT(TCOMP) | MACB_BIT(ISR_TUND)))
546 macb_tx(bp);
547
548 /*
549 * Link change detection isn't possible with RMII, so we'll
550 * add that if/when we get our hands on a full-blown MII PHY.
551 */
552
553 if (status & MACB_BIT(HRESP)) {
554 /*
555 * TODO: Reset the hardware, and maybe move the printk
556 * to a lower-priority context as well (work queue?)
557 */
558 printk(KERN_ERR "%s: DMA bus error: HRESP not OK\n",
559 dev->name);
560 }
561
562 status = macb_readl(bp, ISR);
563 }
564
565 spin_unlock(&bp->lock);
566
567 return IRQ_HANDLED;
568}
569
570static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
571{
572 struct macb *bp = netdev_priv(dev);
573 dma_addr_t mapping;
574 unsigned int len, entry;
575 u32 ctrl;
576
577#ifdef DEBUG
578 int i;
579 dev_dbg(&bp->pdev->dev,
580 "start_xmit: len %u head %p data %p tail %p end %p\n",
581 skb->len, skb->head, skb->data, skb->tail, skb->end);
582 dev_dbg(&bp->pdev->dev,
583 "data:");
584 for (i = 0; i < 16; i++)
585 printk(" %02x", (unsigned int)skb->data[i]);
586 printk("\n");
587#endif
588
589 len = skb->len;
590 spin_lock_irq(&bp->lock);
591
592 /* This is a hard error, log it. */
593 if (TX_BUFFS_AVAIL(bp) < 1) {
594 netif_stop_queue(dev);
595 spin_unlock_irq(&bp->lock);
596 dev_err(&bp->pdev->dev,
597 "BUG! Tx Ring full when queue awake!\n");
598 dev_dbg(&bp->pdev->dev, "tx_head = %u, tx_tail = %u\n",
599 bp->tx_head, bp->tx_tail);
600 return 1;
601 }
602
603 entry = bp->tx_head;
604 dev_dbg(&bp->pdev->dev, "Allocated ring entry %u\n", entry);
605 mapping = dma_map_single(&bp->pdev->dev, skb->data,
606 len, DMA_TO_DEVICE);
607 bp->tx_skb[entry].skb = skb;
608 bp->tx_skb[entry].mapping = mapping;
609 dev_dbg(&bp->pdev->dev, "Mapped skb data %p to DMA addr %08lx\n",
610 skb->data, (unsigned long)mapping);
611
612 ctrl = MACB_BF(TX_FRMLEN, len);
613 ctrl |= MACB_BIT(TX_LAST);
614 if (entry == (TX_RING_SIZE - 1))
615 ctrl |= MACB_BIT(TX_WRAP);
616
617 bp->tx_ring[entry].addr = mapping;
618 bp->tx_ring[entry].ctrl = ctrl;
619 wmb();
620
621 entry = NEXT_TX(entry);
622 bp->tx_head = entry;
623
624 macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(TSTART));
625
626 if (TX_BUFFS_AVAIL(bp) < 1)
627 netif_stop_queue(dev);
628
629 spin_unlock_irq(&bp->lock);
630
631 dev->trans_start = jiffies;
632
633 return 0;
634}
635
636static void macb_free_consistent(struct macb *bp)
637{
638 if (bp->tx_skb) {
639 kfree(bp->tx_skb);
640 bp->tx_skb = NULL;
641 }
642 if (bp->rx_ring) {
643 dma_free_coherent(&bp->pdev->dev, RX_RING_BYTES,
644 bp->rx_ring, bp->rx_ring_dma);
645 bp->rx_ring = NULL;
646 }
647 if (bp->tx_ring) {
648 dma_free_coherent(&bp->pdev->dev, TX_RING_BYTES,
649 bp->tx_ring, bp->tx_ring_dma);
650 bp->tx_ring = NULL;
651 }
652 if (bp->rx_buffers) {
653 dma_free_coherent(&bp->pdev->dev,
654 RX_RING_SIZE * RX_BUFFER_SIZE,
655 bp->rx_buffers, bp->rx_buffers_dma);
656 bp->rx_buffers = NULL;
657 }
658}
659
660static int macb_alloc_consistent(struct macb *bp)
661{
662 int size;
663
664 size = TX_RING_SIZE * sizeof(struct ring_info);
665 bp->tx_skb = kmalloc(size, GFP_KERNEL);
666 if (!bp->tx_skb)
667 goto out_err;
668
669 size = RX_RING_BYTES;
670 bp->rx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
671 &bp->rx_ring_dma, GFP_KERNEL);
672 if (!bp->rx_ring)
673 goto out_err;
674 dev_dbg(&bp->pdev->dev,
675 "Allocated RX ring of %d bytes at %08lx (mapped %p)\n",
676 size, (unsigned long)bp->rx_ring_dma, bp->rx_ring);
677
678 size = TX_RING_BYTES;
679 bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size,
680 &bp->tx_ring_dma, GFP_KERNEL);
681 if (!bp->tx_ring)
682 goto out_err;
683 dev_dbg(&bp->pdev->dev,
684 "Allocated TX ring of %d bytes at %08lx (mapped %p)\n",
685 size, (unsigned long)bp->tx_ring_dma, bp->tx_ring);
686
687 size = RX_RING_SIZE * RX_BUFFER_SIZE;
688 bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size,
689 &bp->rx_buffers_dma, GFP_KERNEL);
690 if (!bp->rx_buffers)
691 goto out_err;
692 dev_dbg(&bp->pdev->dev,
693 "Allocated RX buffers of %d bytes at %08lx (mapped %p)\n",
694 size, (unsigned long)bp->rx_buffers_dma, bp->rx_buffers);
695
696 return 0;
697
698out_err:
699 macb_free_consistent(bp);
700 return -ENOMEM;
701}
702
703static void macb_init_rings(struct macb *bp)
704{
705 int i;
706 dma_addr_t addr;
707
708 addr = bp->rx_buffers_dma;
709 for (i = 0; i < RX_RING_SIZE; i++) {
710 bp->rx_ring[i].addr = addr;
711 bp->rx_ring[i].ctrl = 0;
712 addr += RX_BUFFER_SIZE;
713 }
714 bp->rx_ring[RX_RING_SIZE - 1].addr |= MACB_BIT(RX_WRAP);
715
716 for (i = 0; i < TX_RING_SIZE; i++) {
717 bp->tx_ring[i].addr = 0;
718 bp->tx_ring[i].ctrl = MACB_BIT(TX_USED);
719 }
720 bp->tx_ring[TX_RING_SIZE - 1].ctrl |= MACB_BIT(TX_WRAP);
721
722 bp->rx_tail = bp->tx_head = bp->tx_tail = 0;
723}
724
725static void macb_reset_hw(struct macb *bp)
726{
727 /* Make sure we have the write buffer for ourselves */
728 wmb();
729
730 /*
731 * Disable RX and TX (XXX: Should we halt the transmission
732 * more gracefully?)
733 */
734 macb_writel(bp, NCR, 0);
735
736 /* Clear the stats registers (XXX: Update stats first?) */
737 macb_writel(bp, NCR, MACB_BIT(CLRSTAT));
738
739 /* Clear all status flags */
740 macb_writel(bp, TSR, ~0UL);
741 macb_writel(bp, RSR, ~0UL);
742
743 /* Disable all interrupts */
744 macb_writel(bp, IDR, ~0UL);
745 macb_readl(bp, ISR);
746}
747
748static void macb_init_hw(struct macb *bp)
749{
750 u32 config;
751
752 macb_reset_hw(bp);
753 __macb_set_hwaddr(bp);
754
755 config = macb_readl(bp, NCFGR) & MACB_BF(CLK, -1L);
756 config |= MACB_BIT(PAE); /* PAuse Enable */
757 config |= MACB_BIT(DRFCS); /* Discard Rx FCS */
758 if (bp->dev->flags & IFF_PROMISC)
759 config |= MACB_BIT(CAF); /* Copy All Frames */
760 if (!(bp->dev->flags & IFF_BROADCAST))
761 config |= MACB_BIT(NBC); /* No BroadCast */
762 macb_writel(bp, NCFGR, config);
763
764 /* Initialize TX and RX buffers */
765 macb_writel(bp, RBQP, bp->rx_ring_dma);
766 macb_writel(bp, TBQP, bp->tx_ring_dma);
767
768 /* Enable TX and RX */
769 macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE));
770
771 /* Enable interrupts */
772 macb_writel(bp, IER, (MACB_BIT(RCOMP)
773 | MACB_BIT(RXUBR)
774 | MACB_BIT(ISR_TUND)
775 | MACB_BIT(ISR_RLE)
776 | MACB_BIT(TXERR)
777 | MACB_BIT(TCOMP)
778 | MACB_BIT(ISR_ROVR)
779 | MACB_BIT(HRESP)));
780}
781
782static void macb_init_phy(struct net_device *dev)
783{
784 struct macb *bp = netdev_priv(dev);
785
786 /* Set some reasonable default settings */
787 macb_mdio_write(dev, bp->mii.phy_id, MII_ADVERTISE,
788 ADVERTISE_CSMA | ADVERTISE_ALL);
789 macb_mdio_write(dev, bp->mii.phy_id, MII_BMCR,
790 (BMCR_SPEED100 | BMCR_ANENABLE
791 | BMCR_ANRESTART | BMCR_FULLDPLX));
792}
793
794static int macb_open(struct net_device *dev)
795{
796 struct macb *bp = netdev_priv(dev);
797 int err;
798
799 dev_dbg(&bp->pdev->dev, "open\n");
800
801 if (!is_valid_ether_addr(dev->dev_addr))
802 return -EADDRNOTAVAIL;
803
804 err = macb_alloc_consistent(bp);
805 if (err) {
806 printk(KERN_ERR
807 "%s: Unable to allocate DMA memory (error %d)\n",
808 dev->name, err);
809 return err;
810 }
811
812 macb_init_rings(bp);
813 macb_init_hw(bp);
814 macb_init_phy(dev);
815
816 macb_check_media(bp, 1, 1);
817 netif_start_queue(dev);
818
819 schedule_delayed_work(&bp->periodic_task, HZ);
820
821 return 0;
822}
823
824static int macb_close(struct net_device *dev)
825{
826 struct macb *bp = netdev_priv(dev);
827 unsigned long flags;
828
829 cancel_rearming_delayed_work(&bp->periodic_task);
830
831 netif_stop_queue(dev);
832
833 spin_lock_irqsave(&bp->lock, flags);
834 macb_reset_hw(bp);
835 netif_carrier_off(dev);
836 spin_unlock_irqrestore(&bp->lock, flags);
837
838 macb_free_consistent(bp);
839
840 return 0;
841}
842
843static struct net_device_stats *macb_get_stats(struct net_device *dev)
844{
845 struct macb *bp = netdev_priv(dev);
846 struct net_device_stats *nstat = &bp->stats;
847 struct macb_stats *hwstat = &bp->hw_stats;
848
849 /* Convert HW stats into netdevice stats */
850 nstat->rx_errors = (hwstat->rx_fcs_errors +
851 hwstat->rx_align_errors +
852 hwstat->rx_resource_errors +
853 hwstat->rx_overruns +
854 hwstat->rx_oversize_pkts +
855 hwstat->rx_jabbers +
856 hwstat->rx_undersize_pkts +
857 hwstat->sqe_test_errors +
858 hwstat->rx_length_mismatch);
859 nstat->tx_errors = (hwstat->tx_late_cols +
860 hwstat->tx_excessive_cols +
861 hwstat->tx_underruns +
862 hwstat->tx_carrier_errors);
863 nstat->collisions = (hwstat->tx_single_cols +
864 hwstat->tx_multiple_cols +
865 hwstat->tx_excessive_cols);
866 nstat->rx_length_errors = (hwstat->rx_oversize_pkts +
867 hwstat->rx_jabbers +
868 hwstat->rx_undersize_pkts +
869 hwstat->rx_length_mismatch);
870 nstat->rx_over_errors = hwstat->rx_resource_errors;
871 nstat->rx_crc_errors = hwstat->rx_fcs_errors;
872 nstat->rx_frame_errors = hwstat->rx_align_errors;
873 nstat->rx_fifo_errors = hwstat->rx_overruns;
874 /* XXX: What does "missed" mean? */
875 nstat->tx_aborted_errors = hwstat->tx_excessive_cols;
876 nstat->tx_carrier_errors = hwstat->tx_carrier_errors;
877 nstat->tx_fifo_errors = hwstat->tx_underruns;
878 /* Don't know about heartbeat or window errors... */
879
880 return nstat;
881}
882
883static int macb_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
884{
885 struct macb *bp = netdev_priv(dev);
886 int ret;
887 unsigned long flags;
888
889 spin_lock_irqsave(&bp->lock, flags);
890 ret = mii_ethtool_gset(&bp->mii, cmd);
891 spin_unlock_irqrestore(&bp->lock, flags);
892
893 return ret;
894}
895
896static int macb_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
897{
898 struct macb *bp = netdev_priv(dev);
899 int ret;
900 unsigned long flags;
901
902 spin_lock_irqsave(&bp->lock, flags);
903 ret = mii_ethtool_sset(&bp->mii, cmd);
904 spin_unlock_irqrestore(&bp->lock, flags);
905
906 return ret;
907}
908
909static void macb_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
910{
911 struct macb *bp = netdev_priv(dev);
912
913 strcpy(info->driver, bp->pdev->dev.driver->name);
914 strcpy(info->version, "$Revision: 1.14 $");
915 strcpy(info->bus_info, bp->pdev->dev.bus_id);
916}
917
918static int macb_nway_reset(struct net_device *dev)
919{
920 struct macb *bp = netdev_priv(dev);
921 return mii_nway_restart(&bp->mii);
922}
923
924static struct ethtool_ops macb_ethtool_ops = {
925 .get_settings = macb_get_settings,
926 .set_settings = macb_set_settings,
927 .get_drvinfo = macb_get_drvinfo,
928 .nway_reset = macb_nway_reset,
929 .get_link = ethtool_op_get_link,
930};
931
932static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
933{
934 struct macb *bp = netdev_priv(dev);
935 int ret;
936 unsigned long flags;
937
938 if (!netif_running(dev))
939 return -EINVAL;
940
941 spin_lock_irqsave(&bp->lock, flags);
942 ret = generic_mii_ioctl(&bp->mii, if_mii(rq), cmd, NULL);
943 spin_unlock_irqrestore(&bp->lock, flags);
944
945 return ret;
946}
947
948static ssize_t macb_mii_show(const struct class_device *cd, char *buf,
949 unsigned long addr)
950{
951 struct net_device *dev = to_net_dev(cd);
952 struct macb *bp = netdev_priv(dev);
953 ssize_t ret = -EINVAL;
954
955 if (netif_running(dev)) {
956 int value;
957 value = macb_mdio_read(dev, bp->mii.phy_id, addr);
958 ret = sprintf(buf, "0x%04x\n", (uint16_t)value);
959 }
960
961 return ret;
962}
963
964#define MII_ENTRY(name, addr) \
965static ssize_t show_##name(struct class_device *cd, char *buf) \
966{ \
967 return macb_mii_show(cd, buf, addr); \
968} \
969static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
970
971MII_ENTRY(bmcr, MII_BMCR);
972MII_ENTRY(bmsr, MII_BMSR);
973MII_ENTRY(physid1, MII_PHYSID1);
974MII_ENTRY(physid2, MII_PHYSID2);
975MII_ENTRY(advertise, MII_ADVERTISE);
976MII_ENTRY(lpa, MII_LPA);
977MII_ENTRY(expansion, MII_EXPANSION);
978
979static struct attribute *macb_mii_attrs[] = {
980 &class_device_attr_bmcr.attr,
981 &class_device_attr_bmsr.attr,
982 &class_device_attr_physid1.attr,
983 &class_device_attr_physid2.attr,
984 &class_device_attr_advertise.attr,
985 &class_device_attr_lpa.attr,
986 &class_device_attr_expansion.attr,
987 NULL,
988};
989
990static struct attribute_group macb_mii_group = {
991 .name = "mii",
992 .attrs = macb_mii_attrs,
993};
994
995static void macb_unregister_sysfs(struct net_device *net)
996{
997 struct class_device *class_dev = &net->class_dev;
998
999 sysfs_remove_group(&class_dev->kobj, &macb_mii_group);
1000}
1001
1002static int macb_register_sysfs(struct net_device *net)
1003{
1004 struct class_device *class_dev = &net->class_dev;
1005 int ret;
1006
1007 ret = sysfs_create_group(&class_dev->kobj, &macb_mii_group);
1008 if (ret)
1009 printk(KERN_WARNING
1010 "%s: sysfs mii attribute registration failed: %d\n",
1011 net->name, ret);
1012 return ret;
1013}
1014static int __devinit macb_probe(struct platform_device *pdev)
1015{
1016 struct eth_platform_data *pdata;
1017 struct resource *regs;
1018 struct net_device *dev;
1019 struct macb *bp;
1020 unsigned long pclk_hz;
1021 u32 config;
1022 int err = -ENXIO;
1023
1024 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1025 if (!regs) {
1026 dev_err(&pdev->dev, "no mmio resource defined\n");
1027 goto err_out;
1028 }
1029
1030 err = -ENOMEM;
1031 dev = alloc_etherdev(sizeof(*bp));
1032 if (!dev) {
1033 dev_err(&pdev->dev, "etherdev alloc failed, aborting.\n");
1034 goto err_out;
1035 }
1036
1037 SET_MODULE_OWNER(dev);
1038 SET_NETDEV_DEV(dev, &pdev->dev);
1039
1040 /* TODO: Actually, we have some interesting features... */
1041 dev->features |= 0;
1042
1043 bp = netdev_priv(dev);
1044 bp->pdev = pdev;
1045 bp->dev = dev;
1046
1047 spin_lock_init(&bp->lock);
1048
1049 bp->pclk = clk_get(&pdev->dev, "pclk");
1050 if (IS_ERR(bp->pclk)) {
1051 dev_err(&pdev->dev, "failed to get pclk\n");
1052 goto err_out_free_dev;
1053 }
1054 bp->hclk = clk_get(&pdev->dev, "hclk");
1055 if (IS_ERR(bp->hclk)) {
1056 dev_err(&pdev->dev, "failed to get hclk\n");
1057 goto err_out_put_pclk;
1058 }
1059
1060 clk_enable(bp->pclk);
1061 clk_enable(bp->hclk);
1062
1063 bp->regs = ioremap(regs->start, regs->end - regs->start + 1);
1064 if (!bp->regs) {
1065 dev_err(&pdev->dev, "failed to map registers, aborting.\n");
1066 err = -ENOMEM;
1067 goto err_out_disable_clocks;
1068 }
1069
1070 dev->irq = platform_get_irq(pdev, 0);
1071 err = request_irq(dev->irq, macb_interrupt, SA_SAMPLE_RANDOM,
1072 dev->name, dev);
1073 if (err) {
1074 printk(KERN_ERR
1075 "%s: Unable to request IRQ %d (error %d)\n",
1076 dev->name, dev->irq, err);
1077 goto err_out_iounmap;
1078 }
1079
1080 dev->open = macb_open;
1081 dev->stop = macb_close;
1082 dev->hard_start_xmit = macb_start_xmit;
1083 dev->get_stats = macb_get_stats;
1084 dev->do_ioctl = macb_ioctl;
1085 dev->poll = macb_poll;
1086 dev->weight = 64;
1087 dev->ethtool_ops = &macb_ethtool_ops;
1088
1089 dev->base_addr = regs->start;
1090
1091 INIT_WORK(&bp->periodic_task, macb_periodic_task, bp);
1092 mutex_init(&bp->mdio_mutex);
1093 init_completion(&bp->mdio_complete);
1094
1095 /* Set MII management clock divider */
1096 pclk_hz = clk_get_rate(bp->pclk);
1097 if (pclk_hz <= 20000000)
1098 config = MACB_BF(CLK, MACB_CLK_DIV8);
1099 else if (pclk_hz <= 40000000)
1100 config = MACB_BF(CLK, MACB_CLK_DIV16);
1101 else if (pclk_hz <= 80000000)
1102 config = MACB_BF(CLK, MACB_CLK_DIV32);
1103 else
1104 config = MACB_BF(CLK, MACB_CLK_DIV64);
1105 macb_writel(bp, NCFGR, config);
1106
1107 bp->mii.dev = dev;
1108 bp->mii.mdio_read = macb_mdio_read;
1109 bp->mii.mdio_write = macb_mdio_write;
1110 bp->mii.phy_id_mask = 0x1f;
1111 bp->mii.reg_num_mask = 0x1f;
1112
1113 macb_get_hwaddr(bp);
1114 err = macb_phy_probe(bp);
1115 if (err) {
1116 dev_err(&pdev->dev, "Failed to detect PHY, aborting.\n");
1117 goto err_out_free_irq;
1118 }
1119
1120 pdata = pdev->dev.platform_data;
1121 if (pdata && pdata->is_rmii)
1122 macb_writel(bp, USRIO, 0);
1123 else
1124 macb_writel(bp, USRIO, MACB_BIT(MII));
1125
1126 bp->tx_pending = DEF_TX_RING_PENDING;
1127
1128 err = register_netdev(dev);
1129 if (err) {
1130 dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
1131 goto err_out_free_irq;
1132 }
1133
1134 platform_set_drvdata(pdev, dev);
1135
1136 macb_register_sysfs(dev);
1137
1138 printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d "
1139 "(%02x:%02x:%02x:%02x:%02x:%02x)\n",
1140 dev->name, dev->base_addr, dev->irq,
1141 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1142 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
1143
1144 return 0;
1145
1146err_out_free_irq:
1147 free_irq(dev->irq, dev);
1148err_out_iounmap:
1149 iounmap(bp->regs);
1150err_out_disable_clocks:
1151 clk_disable(bp->hclk);
1152 clk_disable(bp->pclk);
1153 clk_put(bp->hclk);
1154err_out_put_pclk:
1155 clk_put(bp->pclk);
1156err_out_free_dev:
1157 free_netdev(dev);
1158err_out:
1159 platform_set_drvdata(pdev, NULL);
1160 return err;
1161}
1162
1163static int __devexit macb_remove(struct platform_device *pdev)
1164{
1165 struct net_device *dev;
1166 struct macb *bp;
1167
1168 dev = platform_get_drvdata(pdev);
1169
1170 if (dev) {
1171 bp = netdev_priv(dev);
1172 macb_unregister_sysfs(dev);
1173 unregister_netdev(dev);
1174 free_irq(dev->irq, dev);
1175 iounmap(bp->regs);
1176 clk_disable(bp->hclk);
1177 clk_disable(bp->pclk);
1178 clk_put(bp->hclk);
1179 clk_put(bp->pclk);
1180 free_netdev(dev);
1181 platform_set_drvdata(pdev, NULL);
1182 }
1183
1184 return 0;
1185}
1186
1187static struct platform_driver macb_driver = {
1188 .probe = macb_probe,
1189 .remove = __devexit_p(macb_remove),
1190 .driver = {
1191 .name = "macb",
1192 },
1193};
1194
1195static int __init macb_init(void)
1196{
1197 return platform_driver_register(&macb_driver);
1198}
1199
1200static void __exit macb_exit(void)
1201{
1202 platform_driver_unregister(&macb_driver);
1203}
1204
1205module_init(macb_init);
1206module_exit(macb_exit);
1207
1208MODULE_LICENSE("GPL");
1209MODULE_DESCRIPTION("Atmel MACB Ethernet driver");
1210MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
new file mode 100644
index 000000000000..8c253db69881
--- /dev/null
+++ b/drivers/net/macb.h
@@ -0,0 +1,387 @@
1/*
2 * Atmel MACB Ethernet Controller driver
3 *
4 * Copyright (C) 2004-2006 Atmel Corporation
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#ifndef _MACB_H
11#define _MACB_H
12
13/* MACB register offsets */
14#define MACB_NCR 0x0000
15#define MACB_NCFGR 0x0004
16#define MACB_NSR 0x0008
17#define MACB_TSR 0x0014
18#define MACB_RBQP 0x0018
19#define MACB_TBQP 0x001c
20#define MACB_RSR 0x0020
21#define MACB_ISR 0x0024
22#define MACB_IER 0x0028
23#define MACB_IDR 0x002c
24#define MACB_IMR 0x0030
25#define MACB_MAN 0x0034
26#define MACB_PTR 0x0038
27#define MACB_PFR 0x003c
28#define MACB_FTO 0x0040
29#define MACB_SCF 0x0044
30#define MACB_MCF 0x0048
31#define MACB_FRO 0x004c
32#define MACB_FCSE 0x0050
33#define MACB_ALE 0x0054
34#define MACB_DTF 0x0058
35#define MACB_LCOL 0x005c
36#define MACB_EXCOL 0x0060
37#define MACB_TUND 0x0064
38#define MACB_CSE 0x0068
39#define MACB_RRE 0x006c
40#define MACB_ROVR 0x0070
41#define MACB_RSE 0x0074
42#define MACB_ELE 0x0078
43#define MACB_RJA 0x007c
44#define MACB_USF 0x0080
45#define MACB_STE 0x0084
46#define MACB_RLE 0x0088
47#define MACB_TPF 0x008c
48#define MACB_HRB 0x0090
49#define MACB_HRT 0x0094
50#define MACB_SA1B 0x0098
51#define MACB_SA1T 0x009c
52#define MACB_SA2B 0x00a0
53#define MACB_SA2T 0x00a4
54#define MACB_SA3B 0x00a8
55#define MACB_SA3T 0x00ac
56#define MACB_SA4B 0x00b0
57#define MACB_SA4T 0x00b4
58#define MACB_TID 0x00b8
59#define MACB_TPQ 0x00bc
60#define MACB_USRIO 0x00c0
61#define MACB_WOL 0x00c4
62
63/* Bitfields in NCR */
64#define MACB_LB_OFFSET 0
65#define MACB_LB_SIZE 1
66#define MACB_LLB_OFFSET 1
67#define MACB_LLB_SIZE 1
68#define MACB_RE_OFFSET 2
69#define MACB_RE_SIZE 1
70#define MACB_TE_OFFSET 3
71#define MACB_TE_SIZE 1
72#define MACB_MPE_OFFSET 4
73#define MACB_MPE_SIZE 1
74#define MACB_CLRSTAT_OFFSET 5
75#define MACB_CLRSTAT_SIZE 1
76#define MACB_INCSTAT_OFFSET 6
77#define MACB_INCSTAT_SIZE 1
78#define MACB_WESTAT_OFFSET 7
79#define MACB_WESTAT_SIZE 1
80#define MACB_BP_OFFSET 8
81#define MACB_BP_SIZE 1
82#define MACB_TSTART_OFFSET 9
83#define MACB_TSTART_SIZE 1
84#define MACB_THALT_OFFSET 10
85#define MACB_THALT_SIZE 1
86#define MACB_NCR_TPF_OFFSET 11
87#define MACB_NCR_TPF_SIZE 1
88#define MACB_TZQ_OFFSET 12
89#define MACB_TZQ_SIZE 1
90
91/* Bitfields in NCFGR */
92#define MACB_SPD_OFFSET 0
93#define MACB_SPD_SIZE 1
94#define MACB_FD_OFFSET 1
95#define MACB_FD_SIZE 1
96#define MACB_BIT_RATE_OFFSET 2
97#define MACB_BIT_RATE_SIZE 1
98#define MACB_JFRAME_OFFSET 3
99#define MACB_JFRAME_SIZE 1
100#define MACB_CAF_OFFSET 4
101#define MACB_CAF_SIZE 1
102#define MACB_NBC_OFFSET 5
103#define MACB_NBC_SIZE 1
104#define MACB_NCFGR_MTI_OFFSET 6
105#define MACB_NCFGR_MTI_SIZE 1
106#define MACB_UNI_OFFSET 7
107#define MACB_UNI_SIZE 1
108#define MACB_BIG_OFFSET 8
109#define MACB_BIG_SIZE 1
110#define MACB_EAE_OFFSET 9
111#define MACB_EAE_SIZE 1
112#define MACB_CLK_OFFSET 10
113#define MACB_CLK_SIZE 2
114#define MACB_RTY_OFFSET 12
115#define MACB_RTY_SIZE 1
116#define MACB_PAE_OFFSET 13
117#define MACB_PAE_SIZE 1
118#define MACB_RBOF_OFFSET 14
119#define MACB_RBOF_SIZE 2
120#define MACB_RLCE_OFFSET 16
121#define MACB_RLCE_SIZE 1
122#define MACB_DRFCS_OFFSET 17
123#define MACB_DRFCS_SIZE 1
124#define MACB_EFRHD_OFFSET 18
125#define MACB_EFRHD_SIZE 1
126#define MACB_IRXFCS_OFFSET 19
127#define MACB_IRXFCS_SIZE 1
128
129/* Bitfields in NSR */
130#define MACB_NSR_LINK_OFFSET 0
131#define MACB_NSR_LINK_SIZE 1
132#define MACB_MDIO_OFFSET 1
133#define MACB_MDIO_SIZE 1
134#define MACB_IDLE_OFFSET 2
135#define MACB_IDLE_SIZE 1
136
137/* Bitfields in TSR */
138#define MACB_UBR_OFFSET 0
139#define MACB_UBR_SIZE 1
140#define MACB_COL_OFFSET 1
141#define MACB_COL_SIZE 1
142#define MACB_TSR_RLE_OFFSET 2
143#define MACB_TSR_RLE_SIZE 1
144#define MACB_TGO_OFFSET 3
145#define MACB_TGO_SIZE 1
146#define MACB_BEX_OFFSET 4
147#define MACB_BEX_SIZE 1
148#define MACB_COMP_OFFSET 5
149#define MACB_COMP_SIZE 1
150#define MACB_UND_OFFSET 6
151#define MACB_UND_SIZE 1
152
153/* Bitfields in RSR */
154#define MACB_BNA_OFFSET 0
155#define MACB_BNA_SIZE 1
156#define MACB_REC_OFFSET 1
157#define MACB_REC_SIZE 1
158#define MACB_OVR_OFFSET 2
159#define MACB_OVR_SIZE 1
160
161/* Bitfields in ISR/IER/IDR/IMR */
162#define MACB_MFD_OFFSET 0
163#define MACB_MFD_SIZE 1
164#define MACB_RCOMP_OFFSET 1
165#define MACB_RCOMP_SIZE 1
166#define MACB_RXUBR_OFFSET 2
167#define MACB_RXUBR_SIZE 1
168#define MACB_TXUBR_OFFSET 3
169#define MACB_TXUBR_SIZE 1
170#define MACB_ISR_TUND_OFFSET 4
171#define MACB_ISR_TUND_SIZE 1
172#define MACB_ISR_RLE_OFFSET 5
173#define MACB_ISR_RLE_SIZE 1
174#define MACB_TXERR_OFFSET 6
175#define MACB_TXERR_SIZE 1
176#define MACB_TCOMP_OFFSET 7
177#define MACB_TCOMP_SIZE 1
178#define MACB_ISR_LINK_OFFSET 9
179#define MACB_ISR_LINK_SIZE 1
180#define MACB_ISR_ROVR_OFFSET 10
181#define MACB_ISR_ROVR_SIZE 1
182#define MACB_HRESP_OFFSET 11
183#define MACB_HRESP_SIZE 1
184#define MACB_PFR_OFFSET 12
185#define MACB_PFR_SIZE 1
186#define MACB_PTZ_OFFSET 13
187#define MACB_PTZ_SIZE 1
188
189/* Bitfields in MAN */
190#define MACB_DATA_OFFSET 0
191#define MACB_DATA_SIZE 16
192#define MACB_CODE_OFFSET 16
193#define MACB_CODE_SIZE 2
194#define MACB_REGA_OFFSET 18
195#define MACB_REGA_SIZE 5
196#define MACB_PHYA_OFFSET 23
197#define MACB_PHYA_SIZE 5
198#define MACB_RW_OFFSET 28
199#define MACB_RW_SIZE 2
200#define MACB_SOF_OFFSET 30
201#define MACB_SOF_SIZE 2
202
203/* Bitfields in USRIO */
204#define MACB_MII_OFFSET 0
205#define MACB_MII_SIZE 1
206#define MACB_EAM_OFFSET 1
207#define MACB_EAM_SIZE 1
208#define MACB_TX_PAUSE_OFFSET 2
209#define MACB_TX_PAUSE_SIZE 1
210#define MACB_TX_PAUSE_ZERO_OFFSET 3
211#define MACB_TX_PAUSE_ZERO_SIZE 1
212
213/* Bitfields in WOL */
214#define MACB_IP_OFFSET 0
215#define MACB_IP_SIZE 16
216#define MACB_MAG_OFFSET 16
217#define MACB_MAG_SIZE 1
218#define MACB_ARP_OFFSET 17
219#define MACB_ARP_SIZE 1
220#define MACB_SA1_OFFSET 18
221#define MACB_SA1_SIZE 1
222#define MACB_WOL_MTI_OFFSET 19
223#define MACB_WOL_MTI_SIZE 1
224
225/* Constants for CLK */
226#define MACB_CLK_DIV8 0
227#define MACB_CLK_DIV16 1
228#define MACB_CLK_DIV32 2
229#define MACB_CLK_DIV64 3
230
231/* Constants for MAN register */
232#define MACB_MAN_SOF 1
233#define MACB_MAN_WRITE 1
234#define MACB_MAN_READ 2
235#define MACB_MAN_CODE 2
236
237/* Bit manipulation macros */
238#define MACB_BIT(name) \
239 (1 << MACB_##name##_OFFSET)
240#define MACB_BF(name,value) \
241 (((value) & ((1 << MACB_##name##_SIZE) - 1)) \
242 << MACB_##name##_OFFSET)
243#define MACB_BFEXT(name,value)\
244 (((value) >> MACB_##name##_OFFSET) \
245 & ((1 << MACB_##name##_SIZE) - 1))
246#define MACB_BFINS(name,value,old) \
247 (((old) & ~(((1 << MACB_##name##_SIZE) - 1) \
248 << MACB_##name##_OFFSET)) \
249 | MACB_BF(name,value))
250
251/* Register access macros */
252#define macb_readl(port,reg) \
253 readl((port)->regs + MACB_##reg)
254#define macb_writel(port,reg,value) \
255 writel((value), (port)->regs + MACB_##reg)
256
257struct dma_desc {
258 u32 addr;
259 u32 ctrl;
260};
261
262/* DMA descriptor bitfields */
263#define MACB_RX_USED_OFFSET 0
264#define MACB_RX_USED_SIZE 1
265#define MACB_RX_WRAP_OFFSET 1
266#define MACB_RX_WRAP_SIZE 1
267#define MACB_RX_WADDR_OFFSET 2
268#define MACB_RX_WADDR_SIZE 30
269
270#define MACB_RX_FRMLEN_OFFSET 0
271#define MACB_RX_FRMLEN_SIZE 12
272#define MACB_RX_OFFSET_OFFSET 12
273#define MACB_RX_OFFSET_SIZE 2
274#define MACB_RX_SOF_OFFSET 14
275#define MACB_RX_SOF_SIZE 1
276#define MACB_RX_EOF_OFFSET 15
277#define MACB_RX_EOF_SIZE 1
278#define MACB_RX_CFI_OFFSET 16
279#define MACB_RX_CFI_SIZE 1
280#define MACB_RX_VLAN_PRI_OFFSET 17
281#define MACB_RX_VLAN_PRI_SIZE 3
282#define MACB_RX_PRI_TAG_OFFSET 20
283#define MACB_RX_PRI_TAG_SIZE 1
284#define MACB_RX_VLAN_TAG_OFFSET 21
285#define MACB_RX_VLAN_TAG_SIZE 1
286#define MACB_RX_TYPEID_MATCH_OFFSET 22
287#define MACB_RX_TYPEID_MATCH_SIZE 1
288#define MACB_RX_SA4_MATCH_OFFSET 23
289#define MACB_RX_SA4_MATCH_SIZE 1
290#define MACB_RX_SA3_MATCH_OFFSET 24
291#define MACB_RX_SA3_MATCH_SIZE 1
292#define MACB_RX_SA2_MATCH_OFFSET 25
293#define MACB_RX_SA2_MATCH_SIZE 1
294#define MACB_RX_SA1_MATCH_OFFSET 26
295#define MACB_RX_SA1_MATCH_SIZE 1
296#define MACB_RX_EXT_MATCH_OFFSET 28
297#define MACB_RX_EXT_MATCH_SIZE 1
298#define MACB_RX_UHASH_MATCH_OFFSET 29
299#define MACB_RX_UHASH_MATCH_SIZE 1
300#define MACB_RX_MHASH_MATCH_OFFSET 30
301#define MACB_RX_MHASH_MATCH_SIZE 1
302#define MACB_RX_BROADCAST_OFFSET 31
303#define MACB_RX_BROADCAST_SIZE 1
304
305#define MACB_TX_FRMLEN_OFFSET 0
306#define MACB_TX_FRMLEN_SIZE 11
307#define MACB_TX_LAST_OFFSET 15
308#define MACB_TX_LAST_SIZE 1
309#define MACB_TX_NOCRC_OFFSET 16
310#define MACB_TX_NOCRC_SIZE 1
311#define MACB_TX_BUF_EXHAUSTED_OFFSET 27
312#define MACB_TX_BUF_EXHAUSTED_SIZE 1
313#define MACB_TX_UNDERRUN_OFFSET 28
314#define MACB_TX_UNDERRUN_SIZE 1
315#define MACB_TX_ERROR_OFFSET 29
316#define MACB_TX_ERROR_SIZE 1
317#define MACB_TX_WRAP_OFFSET 30
318#define MACB_TX_WRAP_SIZE 1
319#define MACB_TX_USED_OFFSET 31
320#define MACB_TX_USED_SIZE 1
321
322struct ring_info {
323 struct sk_buff *skb;
324 dma_addr_t mapping;
325};
326
327/*
328 * Hardware-collected statistics. Used when updating the network
329 * device stats by a periodic timer.
330 */
331struct macb_stats {
332 u32 rx_pause_frames;
333 u32 tx_ok;
334 u32 tx_single_cols;
335 u32 tx_multiple_cols;
336 u32 rx_ok;
337 u32 rx_fcs_errors;
338 u32 rx_align_errors;
339 u32 tx_deferred;
340 u32 tx_late_cols;
341 u32 tx_excessive_cols;
342 u32 tx_underruns;
343 u32 tx_carrier_errors;
344 u32 rx_resource_errors;
345 u32 rx_overruns;
346 u32 rx_symbol_errors;
347 u32 rx_oversize_pkts;
348 u32 rx_jabbers;
349 u32 rx_undersize_pkts;
350 u32 sqe_test_errors;
351 u32 rx_length_mismatch;
352 u32 tx_pause_frames;
353};
354
355struct macb {
356 void __iomem *regs;
357
358 unsigned int rx_tail;
359 struct dma_desc *rx_ring;
360 void *rx_buffers;
361
362 unsigned int tx_head, tx_tail;
363 struct dma_desc *tx_ring;
364 struct ring_info *tx_skb;
365
366 spinlock_t lock;
367 struct platform_device *pdev;
368 struct clk *pclk;
369 struct clk *hclk;
370 struct net_device *dev;
371 struct net_device_stats stats;
372 struct macb_stats hw_stats;
373
374 dma_addr_t rx_ring_dma;
375 dma_addr_t tx_ring_dma;
376 dma_addr_t rx_buffers_dma;
377
378 unsigned int rx_pending, tx_pending;
379
380 struct work_struct periodic_task;
381
382 struct mutex mdio_mutex;
383 struct completion mdio_complete;
384 struct mii_if_info mii;
385};
386
387#endif /* _MACB_H */
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index c1aa60b9a982..e1d97cdf649e 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -33,7 +33,6 @@
33#include <asm/ip32/ip32_ints.h> 33#include <asm/ip32/ip32_ints.h>
34 34
35#include <asm/io.h> 35#include <asm/io.h>
36#include <asm/checksum.h>
37#include <asm/scatterlist.h> 36#include <asm/scatterlist.h>
38#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
39 38
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index 98703e086ee7..38df42802386 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -1955,7 +1955,7 @@ again:
1955 flags = (MXGEFW_FLAGS_NO_TSO | MXGEFW_FLAGS_FIRST); 1955 flags = (MXGEFW_FLAGS_NO_TSO | MXGEFW_FLAGS_FIRST);
1956 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { 1956 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
1957 cksum_offset = (skb->h.raw - skb->data); 1957 cksum_offset = (skb->h.raw - skb->data);
1958 pseudo_hdr_offset = (skb->h.raw + skb->csum) - skb->data; 1958 pseudo_hdr_offset = cksum_offset + skb->csum_offset;
1959 /* If the headers are excessively large, then we must 1959 /* If the headers are excessively large, then we must
1960 * fall back to a software checksum */ 1960 * fall back to a software checksum */
1961 if (unlikely(cksum_offset > 255 || pseudo_hdr_offset > 127)) { 1961 if (unlikely(cksum_offset > 255 || pseudo_hdr_offset > 127)) {
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 7747bfd99f91..ee26ef52289f 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -39,7 +39,6 @@ static char version[] =
39#include <asm/auxio.h> 39#include <asm/auxio.h>
40#include <asm/pgtable.h> 40#include <asm/pgtable.h>
41#include <asm/irq.h> 41#include <asm/irq.h>
42#include <asm/checksum.h>
43 42
44#include "myri_sbus.h" 43#include "myri_sbus.h"
45#include "myri_code.h" 44#include "myri_code.h"
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index eb893d7e8834..38fd525f0f13 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -33,6 +33,8 @@ static const char version1[] =
33#include <asm/io.h> 33#include <asm/io.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35 35
36#define EI_SHIFT(x) (ei_local->reg_offset[x])
37
36#include "8390.h" 38#include "8390.h"
37 39
38#define DRV_NAME "ne-h8300" 40#define DRV_NAME "ne-h8300"
@@ -52,6 +54,11 @@ static const char version1[] =
52 54
53/* ---- No user-serviceable parts below ---- */ 55/* ---- No user-serviceable parts below ---- */
54 56
57static const char version[] =
58 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
59
60#include "lib8390.c"
61
55#define NE_BASE (dev->base_addr) 62#define NE_BASE (dev->base_addr)
56#define NE_CMD 0x00 63#define NE_CMD 0x00
57#define NE_DATAPORT (ei_status.word16?0x20:0x10) /* NatSemi-defined port window offset. */ 64#define NE_DATAPORT (ei_status.word16?0x20:0x10) /* NatSemi-defined port window offset. */
@@ -162,7 +169,7 @@ static void cleanup_card(struct net_device *dev)
162#ifndef MODULE 169#ifndef MODULE
163struct net_device * __init ne_probe(int unit) 170struct net_device * __init ne_probe(int unit)
164{ 171{
165 struct net_device *dev = alloc_ei_netdev(); 172 struct net_device *dev = ____alloc_ei_netdev(0);
166 int err; 173 int err;
167 174
168 if (!dev) 175 if (!dev)
@@ -283,7 +290,7 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
283 290
284 /* Snarf the interrupt now. There's no point in waiting since we cannot 291 /* Snarf the interrupt now. There's no point in waiting since we cannot
285 share and the board will usually be enabled. */ 292 share and the board will usually be enabled. */
286 ret = request_irq(dev->irq, ei_interrupt, 0, name, dev); 293 ret = request_irq(dev->irq, __ei_interrupt, 0, name, dev);
287 if (ret) { 294 if (ret) {
288 printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret); 295 printk (" unable to get IRQ %d (errno=%d).\n", dev->irq, ret);
289 goto err_out; 296 goto err_out;
@@ -318,9 +325,9 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr)
318 dev->open = &ne_open; 325 dev->open = &ne_open;
319 dev->stop = &ne_close; 326 dev->stop = &ne_close;
320#ifdef CONFIG_NET_POLL_CONTROLLER 327#ifdef CONFIG_NET_POLL_CONTROLLER
321 dev->poll_controller = ei_poll; 328 dev->poll_controller = __ei_poll;
322#endif 329#endif
323 NS8390_init(dev, 0); 330 __NS8390_init(dev, 0);
324 331
325 ret = register_netdev(dev); 332 ret = register_netdev(dev);
326 if (ret) 333 if (ret)
@@ -335,7 +342,7 @@ err_out:
335 342
336static int ne_open(struct net_device *dev) 343static int ne_open(struct net_device *dev)
337{ 344{
338 ei_open(dev); 345 __ei_open(dev);
339 return 0; 346 return 0;
340} 347}
341 348
@@ -343,7 +350,7 @@ static int ne_close(struct net_device *dev)
343{ 350{
344 if (ei_debug > 1) 351 if (ei_debug > 1)
345 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); 352 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
346 ei_close(dev); 353 __ei_close(dev);
347 return 0; 354 return 0;
348} 355}
349 356
@@ -584,7 +591,7 @@ retry:
584 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */ 591 if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
585 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name); 592 printk(KERN_WARNING "%s: timeout waiting for Tx RDC.\n", dev->name);
586 ne_reset_8390(dev); 593 ne_reset_8390(dev);
587 NS8390_init(dev,1); 594 __NS8390_init(dev,1);
588 break; 595 break;
589 } 596 }
590 597
@@ -620,7 +627,7 @@ int init_module(void)
620 int err; 627 int err;
621 628
622 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) { 629 for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
623 struct net_device *dev = alloc_ei_netdev(); 630 struct net_device *dev = ____alloc_ei_netdev(0);
624 if (!dev) 631 if (!dev)
625 break; 632 break;
626 if (io[this_dev]) { 633 if (io[this_dev]) {
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index bf58db29e2ed..69233f6aa05c 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -60,7 +60,6 @@ static struct netpoll np = {
60 .local_port = 6665, 60 .local_port = 6665,
61 .remote_port = 6666, 61 .remote_port = 6666,
62 .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, 62 .remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
63 .drop = netpoll_queue,
64}; 63};
65static int configured = 0; 64static int configured = 0;
66 65
@@ -102,6 +101,8 @@ __setup("netconsole=", option_setup);
102 101
103static int init_netconsole(void) 102static int init_netconsole(void)
104{ 103{
104 int err;
105
105 if(strlen(config)) 106 if(strlen(config))
106 option_setup(config); 107 option_setup(config);
107 108
@@ -110,8 +111,9 @@ static int init_netconsole(void)
110 return 0; 111 return 0;
111 } 112 }
112 113
113 if(netpoll_setup(&np)) 114 err = netpoll_setup(&np);
114 return -EINVAL; 115 if (err)
116 return err;
115 117
116 register_console(&netconsole); 118 register_console(&netconsole);
117 printk(KERN_INFO "netconsole: network logging started\n"); 119 printk(KERN_INFO "netconsole: network logging started\n");
diff --git a/drivers/net/netxen/Makefile b/drivers/net/netxen/Makefile
new file mode 100644
index 000000000000..a07cdc6f7384
--- /dev/null
+++ b/drivers/net/netxen/Makefile
@@ -0,0 +1,35 @@
1# Copyright (C) 2003 - 2006 NetXen, Inc.
2# All rights reserved.
3#
4# This program is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License
6# as published by the Free Software Foundation; either version 2
7# of the License, or (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston,
17# MA 02111-1307, USA.
18#
19# The full GNU General Public License is included in this distribution
20# in the file called LICENSE.
21#
22# Contact Information:
23# info@netxen.com
24# NetXen,
25# 3965 Freedom Circle, Fourth floor,
26# Santa Clara, CA 95054
27#
28# Makefile for the NetXen NIC Driver
29#
30
31
32obj-$(CONFIG_NETXEN_NIC) := netxen_nic.o
33
34netxen_nic-y := netxen_nic_hw.o netxen_nic_main.o netxen_nic_init.o \
35 netxen_nic_isr.o netxen_nic_ethtool.o netxen_nic_niu.o
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
new file mode 100644
index 000000000000..d925053fe597
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic.h
@@ -0,0 +1,1028 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef _NETXEN_NIC_H_
31#define _NETXEN_NIC_H_
32
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/types.h>
36#include <linux/compiler.h>
37#include <linux/slab.h>
38#include <linux/delay.h>
39#include <linux/init.h>
40#include <linux/ioport.h>
41#include <linux/pci.h>
42#include <linux/netdevice.h>
43#include <linux/etherdevice.h>
44#include <linux/ip.h>
45#include <linux/in.h>
46#include <linux/tcp.h>
47#include <linux/skbuff.h>
48#include <linux/version.h>
49
50#include <linux/ethtool.h>
51#include <linux/mii.h>
52#include <linux/interrupt.h>
53#include <linux/timer.h>
54
55#include <linux/mm.h>
56#include <linux/mman.h>
57
58#include <asm/system.h>
59#include <asm/io.h>
60#include <asm/byteorder.h>
61#include <asm/uaccess.h>
62#include <asm/pgtable.h>
63
64#include "netxen_nic_hw.h"
65
66#define NETXEN_NIC_BUILD_NO "5"
67#define _NETXEN_NIC_LINUX_MAJOR 2
68#define _NETXEN_NIC_LINUX_MINOR 3
69#define _NETXEN_NIC_LINUX_SUBVERSION 59
70#define NETXEN_NIC_LINUX_VERSIONID "2.3.59" "-" NETXEN_NIC_BUILD_NO
71#define NETXEN_NIC_FW_VERSIONID "2.3.59"
72
73#define RCV_DESC_RINGSIZE \
74 (sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
75#define STATUS_DESC_RINGSIZE \
76 (sizeof(struct status_desc)* adapter->max_rx_desc_count)
77#define TX_RINGSIZE \
78 (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
79#define RCV_BUFFSIZE \
80 (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
81#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
82
83#define NETXEN_NETDEV_STATUS 0x1
84
85#define ADDR_IN_WINDOW1(off) \
86 ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
87
88/*
89 * normalize a 64MB crb address to 32MB PCI window
90 * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
91 */
92#define NETXEN_CRB_NORMAL(reg) \
93 (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST
94
95#define NETXEN_CRB_NORMALIZE(adapter, reg) \
96 pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
97
98#define FIRST_PAGE_GROUP_START 0
99#define FIRST_PAGE_GROUP_END 0x400000
100
101#define SECOND_PAGE_GROUP_START 0x4000000
102#define SECOND_PAGE_GROUP_END 0x66BC000
103
104#define THIRD_PAGE_GROUP_START 0x70E4000
105#define THIRD_PAGE_GROUP_END 0x8000000
106
107#define FIRST_PAGE_GROUP_SIZE FIRST_PAGE_GROUP_END - FIRST_PAGE_GROUP_START
108#define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START
109#define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
110
111#define MAX_RX_BUFFER_LENGTH 2000
112#define MAX_RX_JUMBO_BUFFER_LENGTH 9046
113#define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - NET_IP_ALIGN)
114#define RX_JUMBO_DMA_MAP_LEN \
115 (MAX_RX_JUMBO_BUFFER_LENGTH - NET_IP_ALIGN)
116#define NETXEN_ROM_ROUNDUP 0x80000000ULL
117
118/*
119 * Maximum number of ring contexts
120 */
121#define MAX_RING_CTX 1
122
123/* Opcodes to be used with the commands */
124enum {
125 TX_ETHER_PKT = 0x01,
126/* The following opcodes are for IP checksum */
127 TX_TCP_PKT,
128 TX_UDP_PKT,
129 TX_IP_PKT,
130 TX_TCP_LSO,
131 TX_IPSEC,
132 TX_IPSEC_CMD
133};
134
135/* The following opcodes are for internal consumption. */
136#define NETXEN_CONTROL_OP 0x10
137#define PEGNET_REQUEST 0x11
138
139#define MAX_NUM_CARDS 4
140
141#define MAX_BUFFERS_PER_CMD 32
142
143/*
144 * Following are the states of the Phantom. Phantom will set them and
145 * Host will read to check if the fields are correct.
146 */
147#define PHAN_INITIALIZE_START 0xff00
148#define PHAN_INITIALIZE_FAILED 0xffff
149#define PHAN_INITIALIZE_COMPLETE 0xff01
150
151/* Host writes the following to notify that it has done the init-handshake */
152#define PHAN_INITIALIZE_ACK 0xf00f
153
154#define NUM_RCV_DESC_RINGS 2 /* No of Rcv Descriptor contexts */
155
156/* descriptor types */
157#define RCV_DESC_NORMAL 0x01
158#define RCV_DESC_JUMBO 0x02
159#define RCV_DESC_NORMAL_CTXID 0
160#define RCV_DESC_JUMBO_CTXID 1
161
162#define RCV_DESC_TYPE(ID) \
163 ((ID == RCV_DESC_JUMBO_CTXID) ? RCV_DESC_JUMBO : RCV_DESC_NORMAL)
164
165#define MAX_CMD_DESCRIPTORS 1024
166#define MAX_RCV_DESCRIPTORS 32768
167#define MAX_JUMBO_RCV_DESCRIPTORS 1024
168#define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS
169#define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
170#define MAX_RCV_DESC MAX_RCV_DESCRIPTORS
171#define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS
172#define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS)
173#define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8)
174
175#define MIN_TX_COUNT 4096
176#define MIN_RX_COUNT 4096
177
178#define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */
179
180#define PHAN_PEG_RCV_INITIALIZED 0xff01
181#define PHAN_PEG_RCV_START_INITIALIZE 0xff00
182
183#define get_next_index(index, length) \
184 (((index) + 1) & ((length) - 1))
185
186#define get_index_range(index,length,count) \
187 (((index) + (count)) & ((length) - 1))
188
189/*
190 * Following data structures describe the descriptors that will be used.
191 * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when
192 * we are doing LSO (above the 1500 size packet) only.
193 */
194
195/*
196 * The size of reference handle been changed to 16 bits to pass the MSS fields
197 * for the LSO packet
198 */
199
200#define FLAGS_CHECKSUM_ENABLED 0x01
201#define FLAGS_LSO_ENABLED 0x02
202#define FLAGS_IPSEC_SA_ADD 0x04
203#define FLAGS_IPSEC_SA_DELETE 0x08
204#define FLAGS_VLAN_TAGGED 0x10
205
206#define CMD_DESC_TOTAL_LENGTH(cmd_desc) \
207 ((cmd_desc)->length_tcp_hdr & 0x00FFFFFF)
208#define CMD_DESC_TCP_HDR_OFFSET(cmd_desc) \
209 (((cmd_desc)->length_tcp_hdr >> 24) & 0x0FF)
210#define CMD_DESC_PORT(cmd_desc) ((cmd_desc)->port_ctxid & 0x0F)
211#define CMD_DESC_CTX_ID(cmd_desc) (((cmd_desc)->port_ctxid >> 4) & 0x0F)
212
213#define CMD_DESC_TOTAL_LENGTH_WRT(cmd_desc, var) \
214 ((cmd_desc)->length_tcp_hdr |= ((var) & 0x00FFFFFF))
215#define CMD_DESC_TCP_HDR_OFFSET_WRT(cmd_desc, var) \
216 ((cmd_desc)->length_tcp_hdr |= (((var) << 24) & 0xFF000000))
217#define CMD_DESC_PORT_WRT(cmd_desc, var) \
218 ((cmd_desc)->port_ctxid |= ((var) & 0x0F))
219
220struct cmd_desc_type0 {
221 u64 netxen_next; /* for fragments handled by Phantom */
222 union {
223 struct {
224 u32 addr_low_part2;
225 u32 addr_high_part2;
226 };
227 u64 addr_buffer2;
228 };
229
230 /* Bit pattern: 0-23 total length, 24-32 tcp header offset */
231 u32 length_tcp_hdr;
232 u8 ip_hdr_offset; /* For LSO only */
233 u8 num_of_buffers; /* total number of segments */
234 u8 flags; /* as defined above */
235 u8 opcode;
236
237 u16 reference_handle; /* changed to u16 to add mss */
238 u16 mss; /* passed by NDIS_PACKET for LSO */
239 /* Bit pattern 0-3 port, 0-3 ctx id */
240 u8 port_ctxid;
241 u8 total_hdr_length; /* LSO only : MAC+IP+TCP Hdr size */
242 u16 conn_id; /* IPSec offoad only */
243
244 union {
245 struct {
246 u32 addr_low_part3;
247 u32 addr_high_part3;
248 };
249 u64 addr_buffer3;
250 };
251
252 union {
253 struct {
254 u32 addr_low_part1;
255 u32 addr_high_part1;
256 };
257 u64 addr_buffer1;
258 };
259
260 u16 buffer1_length;
261 u16 buffer2_length;
262 u16 buffer3_length;
263 u16 buffer4_length;
264
265 union {
266 struct {
267 u32 addr_low_part4;
268 u32 addr_high_part4;
269 };
270 u64 addr_buffer4;
271 };
272
273} __attribute__ ((aligned(64)));
274
275/* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
276struct rcv_desc {
277 u16 reference_handle;
278 u16 reserved;
279 u32 buffer_length; /* allocated buffer length (usually 2K) */
280 u64 addr_buffer;
281};
282
283/* opcode field in status_desc */
284#define RCV_NIC_PKT (0xA)
285#define STATUS_NIC_PKT ((RCV_NIC_PKT) << 12)
286
287/* for status field in status_desc */
288#define STATUS_NEED_CKSUM (1)
289#define STATUS_CKSUM_OK (2)
290
291/* owner bits of status_desc */
292#define STATUS_OWNER_HOST (0x1)
293#define STATUS_OWNER_PHANTOM (0x2)
294
295#define NETXEN_PROT_IP (1)
296#define NETXEN_PROT_UNKNOWN (0)
297
298/* Note: sizeof(status_desc) should always be a mutliple of 2 */
299#define STATUS_DESC_PORT(status_desc) \
300 ((status_desc)->port_status_type_op & 0x0F)
301#define STATUS_DESC_STATUS(status_desc) \
302 (((status_desc)->port_status_type_op >> 4) & 0x0F)
303#define STATUS_DESC_TYPE(status_desc) \
304 (((status_desc)->port_status_type_op >> 8) & 0x0F)
305#define STATUS_DESC_OPCODE(status_desc) \
306 (((status_desc)->port_status_type_op >> 12) & 0x0F)
307
308struct status_desc {
309 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-15 opcode */
310 u16 port_status_type_op;
311 u16 total_length; /* NIC mode */
312 u16 reference_handle; /* handle for the associated packet */
313 /* Bit pattern: 0-1 owner, 2-5 protocol */
314 u16 owner; /* Owner of the descriptor */
315} __attribute__ ((aligned(8)));
316
317enum {
318 NETXEN_RCV_PEG_0 = 0,
319 NETXEN_RCV_PEG_1
320};
321/* The version of the main data structure */
322#define NETXEN_BDINFO_VERSION 1
323
324/* Magic number to let user know flash is programmed */
325#define NETXEN_BDINFO_MAGIC 0x12345678
326
327/* Max number of Gig ports on a Phantom board */
328#define NETXEN_MAX_PORTS 4
329
330typedef enum {
331 NETXEN_BRDTYPE_P1_BD = 0x0000,
332 NETXEN_BRDTYPE_P1_SB = 0x0001,
333 NETXEN_BRDTYPE_P1_SMAX = 0x0002,
334 NETXEN_BRDTYPE_P1_SOCK = 0x0003,
335
336 NETXEN_BRDTYPE_P2_SOCK_31 = 0x0008,
337 NETXEN_BRDTYPE_P2_SOCK_35 = 0x0009,
338 NETXEN_BRDTYPE_P2_SB35_4G = 0x000a,
339 NETXEN_BRDTYPE_P2_SB31_10G = 0x000b,
340 NETXEN_BRDTYPE_P2_SB31_2G = 0x000c,
341
342 NETXEN_BRDTYPE_P2_SB31_10G_IMEZ = 0x000d,
343 NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e,
344 NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f
345} netxen_brdtype_t;
346
347typedef enum {
348 NETXEN_BRDMFG_INVENTEC = 1
349} netxen_brdmfg;
350
351typedef enum {
352 MEM_ORG_128Mbx4 = 0x0, /* DDR1 only */
353 MEM_ORG_128Mbx8 = 0x1, /* DDR1 only */
354 MEM_ORG_128Mbx16 = 0x2, /* DDR1 only */
355 MEM_ORG_256Mbx4 = 0x3,
356 MEM_ORG_256Mbx8 = 0x4,
357 MEM_ORG_256Mbx16 = 0x5,
358 MEM_ORG_512Mbx4 = 0x6,
359 MEM_ORG_512Mbx8 = 0x7,
360 MEM_ORG_512Mbx16 = 0x8,
361 MEM_ORG_1Gbx4 = 0x9,
362 MEM_ORG_1Gbx8 = 0xa,
363 MEM_ORG_1Gbx16 = 0xb,
364 MEM_ORG_2Gbx4 = 0xc,
365 MEM_ORG_2Gbx8 = 0xd,
366 MEM_ORG_2Gbx16 = 0xe,
367 MEM_ORG_128Mbx32 = 0x10002, /* GDDR only */
368 MEM_ORG_256Mbx32 = 0x10005 /* GDDR only */
369} netxen_mn_mem_org_t;
370
371typedef enum {
372 MEM_ORG_512Kx36 = 0x0,
373 MEM_ORG_1Mx36 = 0x1,
374 MEM_ORG_2Mx36 = 0x2
375} netxen_sn_mem_org_t;
376
377typedef enum {
378 MEM_DEPTH_4MB = 0x1,
379 MEM_DEPTH_8MB = 0x2,
380 MEM_DEPTH_16MB = 0x3,
381 MEM_DEPTH_32MB = 0x4,
382 MEM_DEPTH_64MB = 0x5,
383 MEM_DEPTH_128MB = 0x6,
384 MEM_DEPTH_256MB = 0x7,
385 MEM_DEPTH_512MB = 0x8,
386 MEM_DEPTH_1GB = 0x9,
387 MEM_DEPTH_2GB = 0xa,
388 MEM_DEPTH_4GB = 0xb,
389 MEM_DEPTH_8GB = 0xc,
390 MEM_DEPTH_16GB = 0xd,
391 MEM_DEPTH_32GB = 0xe
392} netxen_mem_depth_t;
393
394struct netxen_board_info {
395 u32 header_version;
396
397 u32 board_mfg;
398 u32 board_type;
399 u32 board_num;
400 u32 chip_id;
401 u32 chip_minor;
402 u32 chip_major;
403 u32 chip_pkg;
404 u32 chip_lot;
405
406 u32 port_mask; /* available niu ports */
407 u32 peg_mask; /* available pegs */
408 u32 icache_ok; /* can we run with icache? */
409 u32 dcache_ok; /* can we run with dcache? */
410 u32 casper_ok;
411
412 u32 mac_addr_lo_0;
413 u32 mac_addr_lo_1;
414 u32 mac_addr_lo_2;
415 u32 mac_addr_lo_3;
416
417 /* MN-related config */
418 u32 mn_sync_mode; /* enable/ sync shift cclk/ sync shift mclk */
419 u32 mn_sync_shift_cclk;
420 u32 mn_sync_shift_mclk;
421 u32 mn_wb_en;
422 u32 mn_crystal_freq; /* in MHz */
423 u32 mn_speed; /* in MHz */
424 u32 mn_org;
425 u32 mn_depth;
426 u32 mn_ranks_0; /* ranks per slot */
427 u32 mn_ranks_1; /* ranks per slot */
428 u32 mn_rd_latency_0;
429 u32 mn_rd_latency_1;
430 u32 mn_rd_latency_2;
431 u32 mn_rd_latency_3;
432 u32 mn_rd_latency_4;
433 u32 mn_rd_latency_5;
434 u32 mn_rd_latency_6;
435 u32 mn_rd_latency_7;
436 u32 mn_rd_latency_8;
437 u32 mn_dll_val[18];
438 u32 mn_mode_reg; /* MIU DDR Mode Register */
439 u32 mn_ext_mode_reg; /* MIU DDR Extended Mode Register */
440 u32 mn_timing_0; /* MIU Memory Control Timing Rgister */
441 u32 mn_timing_1; /* MIU Extended Memory Ctrl Timing Register */
442 u32 mn_timing_2; /* MIU Extended Memory Ctrl Timing2 Register */
443
444 /* SN-related config */
445 u32 sn_sync_mode; /* enable/ sync shift cclk / sync shift mclk */
446 u32 sn_pt_mode; /* pass through mode */
447 u32 sn_ecc_en;
448 u32 sn_wb_en;
449 u32 sn_crystal_freq;
450 u32 sn_speed;
451 u32 sn_org;
452 u32 sn_depth;
453 u32 sn_dll_tap;
454 u32 sn_rd_latency;
455
456 u32 mac_addr_hi_0;
457 u32 mac_addr_hi_1;
458 u32 mac_addr_hi_2;
459 u32 mac_addr_hi_3;
460
461 u32 magic; /* indicates flash has been initialized */
462
463 u32 mn_rdimm;
464 u32 mn_dll_override;
465
466};
467
468#define FLASH_NUM_PORTS (4)
469
470struct netxen_flash_mac_addr {
471 u32 flash_addr[32];
472};
473
474struct netxen_user_old_info {
475 u8 flash_md5[16];
476 u8 crbinit_md5[16];
477 u8 brdcfg_md5[16];
478 /* bootloader */
479 u32 bootld_version;
480 u32 bootld_size;
481 u8 bootld_md5[16];
482 /* image */
483 u32 image_version;
484 u32 image_size;
485 u8 image_md5[16];
486 /* primary image status */
487 u32 primary_status;
488 u32 secondary_present;
489
490 /* MAC address , 4 ports */
491 struct netxen_flash_mac_addr mac_addr[FLASH_NUM_PORTS];
492};
493#define FLASH_NUM_MAC_PER_PORT 32
494struct netxen_user_info {
495 u8 flash_md5[16 * 64];
496 /* bootloader */
497 u32 bootld_version;
498 u32 bootld_size;
499 /* image */
500 u32 image_version;
501 u32 image_size;
502 /* primary image status */
503 u32 primary_status;
504 u32 secondary_present;
505
506 /* MAC address , 4 ports, 32 address per port */
507 u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
508 u32 sub_sys_id;
509 u8 serial_num[32];
510
511 /* Any user defined data */
512};
513
514/*
515 * Flash Layout - new format.
516 */
517struct netxen_new_user_info {
518 u8 flash_md5[16 * 64];
519 /* bootloader */
520 u32 bootld_version;
521 u32 bootld_size;
522 /* image */
523 u32 image_version;
524 u32 image_size;
525 /* primary image status */
526 u32 primary_status;
527 u32 secondary_present;
528
529 /* MAC address , 4 ports, 32 address per port */
530 u64 mac_addr[FLASH_NUM_PORTS * FLASH_NUM_MAC_PER_PORT];
531 u32 sub_sys_id;
532 u8 serial_num[32];
533
534 /* Any user defined data */
535};
536
537#define SECONDARY_IMAGE_PRESENT 0xb3b4b5b6
538#define SECONDARY_IMAGE_ABSENT 0xffffffff
539#define PRIMARY_IMAGE_GOOD 0x5a5a5a5a
540#define PRIMARY_IMAGE_BAD 0xffffffff
541
542/* Flash memory map */
543typedef enum {
544 CRBINIT_START = 0, /* Crbinit section */
545 BRDCFG_START = 0x4000, /* board config */
546 INITCODE_START = 0x6000, /* pegtune code */
547 BOOTLD_START = 0x10000, /* bootld */
548 IMAGE_START = 0x43000, /* compressed image */
549 SECONDARY_START = 0x200000, /* backup images */
550 PXE_START = 0x3E0000, /* user defined region */
551 USER_START = 0x3E8000, /* User defined region for new boards */
552 FIXED_START = 0x3F0000 /* backup of crbinit */
553} netxen_flash_map_t;
554
555#define USER_START_OLD PXE_START /* for backward compatibility */
556
557#define FLASH_START (CRBINIT_START)
558#define INIT_SECTOR (0)
559#define PRIMARY_START (BOOTLD_START)
560#define FLASH_CRBINIT_SIZE (0x4000)
561#define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info))
562#define FLASH_USER_SIZE (sizeof(netxen_user_info)/sizeof(u32))
563#define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START)
564#define NUM_PRIMARY_SECTORS (0x20)
565#define NUM_CONFIG_SECTORS (1)
566#define PFX "netxen: "
567
568/* Note: Make sure to not call this before adapter->port is valid */
569#if !defined(NETXEN_DEBUG)
570#define DPRINTK(klevel, fmt, args...) do { \
571 } while (0)
572#else
573#define DPRINTK(klevel, fmt, args...) do { \
574 printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
575 (adapter != NULL && adapter->port != NULL && \
576 adapter->port[0] != NULL && \
577 adapter->port[0]->netdev != NULL) ? \
578 adapter->port[0]->netdev->name : NULL, \
579 ## args); } while(0)
580#endif
581
582/* Number of status descriptors to handle per interrupt */
583#define MAX_STATUS_HANDLE (128)
584
585/*
586 * netxen_skb_frag{} is to contain mapping info for each SG list. This
587 * has to be freed when DMA is complete. This is part of netxen_tx_buffer{}.
588 */
589struct netxen_skb_frag {
590 u64 dma;
591 u32 length;
592};
593
594/* Following defines are for the state of the buffers */
595#define NETXEN_BUFFER_FREE 0
596#define NETXEN_BUFFER_BUSY 1
597
598/*
599 * There will be one netxen_buffer per skb packet. These will be
600 * used to save the dma info for pci_unmap_page()
601 */
602struct netxen_cmd_buffer {
603 struct sk_buff *skb;
604 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1];
605 u32 total_length;
606 u32 mss;
607 u16 port;
608 u8 cmd;
609 u8 frag_count;
610 unsigned long time_stamp;
611 u32 state;
612 u32 no_of_descriptors;
613};
614
615/* In rx_buffer, we do not need multiple fragments as is a single buffer */
616struct netxen_rx_buffer {
617 struct sk_buff *skb;
618 u64 dma;
619 u16 ref_handle;
620 u16 state;
621};
622
623/* Board types */
624#define NETXEN_NIC_GBE 0x01
625#define NETXEN_NIC_XGBE 0x02
626
627/*
628 * One hardware_context{} per adapter
629 * contains interrupt info as well shared hardware info.
630 */
631struct netxen_hardware_context {
632 struct pci_dev *pdev;
633 void __iomem *pci_base0;
634 void __iomem *pci_base1;
635 void __iomem *pci_base2;
636
637 u8 revision_id;
638 u16 board_type;
639 u16 max_ports;
640 struct netxen_board_info boardcfg;
641 u32 xg_linkup;
642 u32 qg_linksup;
643 /* Address of cmd ring in Phantom */
644 struct cmd_desc_type0 *cmd_desc_head;
645 char *pauseaddr;
646 struct pci_dev *cmd_desc_pdev;
647 dma_addr_t cmd_desc_phys_addr;
648 dma_addr_t pause_physaddr;
649 struct pci_dev *pause_pdev;
650 struct netxen_adapter *adapter;
651};
652
653#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
654#define ETHERNET_FCS_SIZE 4
655
656struct netxen_adapter_stats {
657 u64 ints;
658 u64 hostints;
659 u64 otherints;
660 u64 process_rcv;
661 u64 process_xmit;
662 u64 noxmitdone;
663 u64 xmitcsummed;
664 u64 post_called;
665 u64 posted;
666 u64 lastposted;
667 u64 goodskbposts;
668};
669
670/*
671 * Rcv Descriptor Context. One such per Rcv Descriptor. There may
672 * be one Rcv Descriptor for normal packets, one for jumbo and may be others.
673 */
674struct netxen_rcv_desc_ctx {
675 u32 flags;
676 u32 producer;
677 u32 rcv_pending; /* Num of bufs posted in phantom */
678 u32 rcv_free; /* Num of bufs in free list */
679 dma_addr_t phys_addr;
680 struct pci_dev *phys_pdev;
681 struct rcv_desc *desc_head; /* address of rx ring in Phantom */
682 u32 max_rx_desc_count;
683 u32 dma_size;
684 u32 skb_size;
685 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */
686 int begin_alloc;
687};
688
689/*
690 * Receive context. There is one such structure per instance of the
691 * receive processing. Any state information that is relevant to
692 * the receive, and is must be in this structure. The global data may be
693 * present elsewhere.
694 */
695struct netxen_recv_context {
696 struct netxen_rcv_desc_ctx rcv_desc[NUM_RCV_DESC_RINGS];
697 u32 status_rx_producer;
698 u32 status_rx_consumer;
699 dma_addr_t rcv_status_desc_phys_addr;
700 struct pci_dev *rcv_status_desc_pdev;
701 struct status_desc *rcv_status_desc_head;
702};
703
704#define NETXEN_NIC_MSI_ENABLED 0x02
705
706struct netxen_drvops;
707
708struct netxen_adapter {
709 struct netxen_hardware_context ahw;
710 int port_count; /* Number of configured ports */
711 int active_ports; /* Number of open ports */
712 struct netxen_port *port[NETXEN_MAX_PORTS]; /* ptr to each port */
713 spinlock_t tx_lock;
714 spinlock_t lock;
715 struct work_struct watchdog_task;
716 struct work_struct tx_timeout_task;
717 struct timer_list watchdog_timer;
718
719 u32 curr_window;
720
721 u32 cmd_producer;
722 u32 cmd_consumer;
723
724 u32 last_cmd_consumer;
725 u32 max_tx_desc_count;
726 u32 max_rx_desc_count;
727 u32 max_jumbo_rx_desc_count;
728 /* Num of instances active on cmd buffer ring */
729 u32 proc_cmd_buf_counter;
730
731 u32 num_threads, total_threads; /*Use to keep track of xmit threads */
732
733 u32 flags;
734 u32 irq;
735 int driver_mismatch;
736 u32 temp;
737
738 struct netxen_adapter_stats stats;
739
740 struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */
741
742 /*
743 * Receive instances. These can be either one per port,
744 * or one per peg, etc.
745 */
746 struct netxen_recv_context recv_ctx[MAX_RCV_CTX];
747
748 int is_up;
749 int work_done;
750 struct netxen_drvops *ops;
751}; /* netxen_adapter structure */
752
753/* Max number of xmit producer threads that can run simultaneously */
754#define MAX_XMIT_PRODUCERS 16
755
756struct netxen_port_stats {
757 u64 rcvdbadskb;
758 u64 xmitcalled;
759 u64 xmitedframes;
760 u64 xmitfinished;
761 u64 badskblen;
762 u64 nocmddescriptor;
763 u64 polled;
764 u64 uphappy;
765 u64 updropped;
766 u64 uplcong;
767 u64 uphcong;
768 u64 upmcong;
769 u64 updunno;
770 u64 skbfreed;
771 u64 txdropped;
772 u64 txnullskb;
773 u64 csummed;
774 u64 no_rcv;
775 u64 rxbytes;
776 u64 txbytes;
777};
778
779struct netxen_port {
780 struct netxen_adapter *adapter;
781
782 u16 portnum; /* GBE port number */
783 u16 link_speed;
784 u16 link_duplex;
785 u16 link_autoneg;
786
787 int flags;
788
789 struct net_device *netdev;
790 struct pci_dev *pdev;
791 struct net_device_stats net_stats;
792 struct netxen_port_stats stats;
793};
794
795#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
796 ((adapter)->ahw.pci_base0 + (off))
797#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
798 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
799#define PCI_OFFSET_THIRD_RANGE(adapter, off) \
800 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
801
802static inline void __iomem *pci_base_offset(struct netxen_adapter *adapter,
803 unsigned long off)
804{
805 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
806 return (adapter->ahw.pci_base0 + off);
807 } else if ((off < SECOND_PAGE_GROUP_END) &&
808 (off >= SECOND_PAGE_GROUP_START)) {
809 return (adapter->ahw.pci_base1 + off - SECOND_PAGE_GROUP_START);
810 } else if ((off < THIRD_PAGE_GROUP_END) &&
811 (off >= THIRD_PAGE_GROUP_START)) {
812 return (adapter->ahw.pci_base2 + off - THIRD_PAGE_GROUP_START);
813 }
814 return NULL;
815}
816
817static inline void __iomem *pci_base(struct netxen_adapter *adapter,
818 unsigned long off)
819{
820 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
821 return adapter->ahw.pci_base0;
822 } else if ((off < SECOND_PAGE_GROUP_END) &&
823 (off >= SECOND_PAGE_GROUP_START)) {
824 return adapter->ahw.pci_base1;
825 } else if ((off < THIRD_PAGE_GROUP_END) &&
826 (off >= THIRD_PAGE_GROUP_START)) {
827 return adapter->ahw.pci_base2;
828 }
829 return NULL;
830}
831
832struct netxen_drvops {
833 int (*enable_phy_interrupts) (struct netxen_adapter *, int);
834 int (*disable_phy_interrupts) (struct netxen_adapter *, int);
835 void (*handle_phy_intr) (struct netxen_adapter *);
836 int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t);
837 int (*set_mtu) (struct netxen_port *, int);
838 int (*set_promisc) (struct netxen_adapter *, int,
839 netxen_niu_prom_mode_t);
840 int (*unset_promisc) (struct netxen_adapter *, int,
841 netxen_niu_prom_mode_t);
842 int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *);
843 int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val);
844 int (*init_port) (struct netxen_adapter *, int);
845 void (*init_niu) (struct netxen_adapter *);
846 int (*stop_port) (struct netxen_adapter *, int);
847};
848
849extern char netxen_nic_driver_name[];
850
851int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter,
852 int port);
853int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter,
854 int port);
855int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter,
856 int port);
857int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter,
858 int port);
859int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter,
860 int port);
861int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter,
862 int port);
863void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter);
864void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter);
865void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter, int port,
866 long enable);
867void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter, int port,
868 long enable);
869int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, long reg,
870 __le32 * readval);
871int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long phy,
872 long reg, __le32 val);
873
874/* Functions available from netxen_nic_hw.c */
875int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu);
876int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu);
877void netxen_nic_init_niu_gb(struct netxen_adapter *adapter);
878void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw);
879void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
880int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off);
881void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value);
882void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 * value);
883
884int netxen_nic_get_board_info(struct netxen_adapter *adapter);
885int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
886 int len);
887int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
888 int len);
889void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
890 unsigned long off, int data);
891
892/* Functions from netxen_nic_init.c */
893void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
894void netxen_load_firmware(struct netxen_adapter *adapter);
895int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
896int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
897int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data);
898int netxen_rom_se(struct netxen_adapter *adapter, int addr);
899int netxen_do_rom_se(struct netxen_adapter *adapter, int addr);
900
901/* Functions from netxen_nic_isr.c */
902void netxen_nic_isr_other(struct netxen_adapter *adapter);
903void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 port,
904 u32 link);
905void netxen_handle_port_int(struct netxen_adapter *adapter, u32 port,
906 u32 enable);
907void netxen_nic_stop_all_ports(struct netxen_adapter *adapter);
908void netxen_initialize_adapter_sw(struct netxen_adapter *adapter);
909void netxen_initialize_adapter_hw(struct netxen_adapter *adapter);
910void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
911 struct pci_dev **used_dev);
912void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
913int netxen_init_firmware(struct netxen_adapter *adapter);
914void netxen_free_hw_resources(struct netxen_adapter *adapter);
915void netxen_tso_check(struct netxen_adapter *adapter,
916 struct cmd_desc_type0 *desc, struct sk_buff *skb);
917int netxen_nic_hw_resources(struct netxen_adapter *adapter);
918void netxen_nic_clear_stats(struct netxen_adapter *adapter);
919int
920netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
921 struct netxen_port *port);
922int netxen_nic_rx_has_work(struct netxen_adapter *adapter);
923int netxen_nic_tx_has_work(struct netxen_adapter *adapter);
924void netxen_watchdog_task(unsigned long v);
925void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
926 u32 ringid);
927void netxen_process_cmd_ring(unsigned long data);
928u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
929void netxen_nic_set_multi(struct net_device *netdev);
930int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
931int netxen_nic_set_mac(struct net_device *netdev, void *p);
932struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev);
933
934static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
935{
936 /*
937 * ISR_INT_MASK: Can be read from window 0 or 1.
938 */
939 writel(0x7ff, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
940
941}
942
943static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
944{
945 u32 mask;
946
947 switch (adapter->ahw.board_type) {
948 case NETXEN_NIC_GBE:
949 mask = 0x77b;
950 break;
951 case NETXEN_NIC_XGBE:
952 mask = 0x77f;
953 break;
954 default:
955 mask = 0x7ff;
956 break;
957 }
958
959 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK));
960
961 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
962 mask = 0xbff;
963 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
964 ISR_INT_TARGET_MASK));
965 }
966}
967
968/*
969 * NetXen Board information
970 */
971
972#define NETXEN_MAX_SHORT_NAME 16
973struct netxen_brdinfo {
974 netxen_brdtype_t brdtype; /* type of board */
975 long ports; /* max no of physical ports */
976 char short_name[NETXEN_MAX_SHORT_NAME];
977};
978
979static const struct netxen_brdinfo netxen_boards[] = {
980 {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"},
981 {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"},
982 {NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"},
983 {NETXEN_BRDTYPE_P2_SB31_10G, 1, "XGb XFP"},
984 {NETXEN_BRDTYPE_P2_SB35_4G, 4, "Quad Gb"},
985 {NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"},
986};
987
988#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(struct netxen_brdinfo))
989
990static inline void get_brd_port_by_type(u32 type, int *ports)
991{
992 int i, found = 0;
993 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
994 if (netxen_boards[i].brdtype == type) {
995 *ports = netxen_boards[i].ports;
996 found = 1;
997 break;
998 }
999 }
1000 if (!found)
1001 *ports = 0;
1002}
1003
1004static inline void get_brd_name_by_type(u32 type, char *name)
1005{
1006 int i, found = 0;
1007 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
1008 if (netxen_boards[i].brdtype == type) {
1009 strcpy(name, netxen_boards[i].short_name);
1010 found = 1;
1011 break;
1012 }
1013
1014 }
1015 if (!found)
1016 name = "Unknown";
1017}
1018
1019int netxen_is_flash_supported(struct netxen_adapter *adapter);
1020int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
1021
1022extern void netxen_change_ringparam(struct netxen_adapter *adapter);
1023extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
1024 int *valp);
1025
1026extern struct ethtool_ops netxen_nic_ethtool_ops;
1027
1028#endif /* __NETXEN_NIC_H_ */
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
new file mode 100644
index 000000000000..9a914aeba5bc
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -0,0 +1,741 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * ethtool support for netxen nic
31 *
32 */
33
34#include <linux/types.h>
35#include <asm/uaccess.h>
36#include <linux/pci.h>
37#include <asm/io.h>
38#include <linux/netdevice.h>
39#include <linux/ethtool.h>
40#include <linux/version.h>
41
42#include "netxen_nic_hw.h"
43#include "netxen_nic.h"
44#include "netxen_nic_phan_reg.h"
45#include "netxen_nic_ioctl.h"
46
47struct netxen_nic_stats {
48 char stat_string[ETH_GSTRING_LEN];
49 int sizeof_stat;
50 int stat_offset;
51};
52
53#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \
54 offsetof(struct netxen_port, m)
55
56#define NETXEN_NIC_PORT_WINDOW 0x10000
57#define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
58
59static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = {
60 {"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)},
61 {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)},
62 {"xmited_frames", NETXEN_NIC_STAT(stats.xmitedframes)},
63 {"xmit_finished", NETXEN_NIC_STAT(stats.xmitfinished)},
64 {"bad_skb_len", NETXEN_NIC_STAT(stats.badskblen)},
65 {"no_cmd_desc", NETXEN_NIC_STAT(stats.nocmddescriptor)},
66 {"polled", NETXEN_NIC_STAT(stats.polled)},
67 {"uphappy", NETXEN_NIC_STAT(stats.uphappy)},
68 {"updropped", NETXEN_NIC_STAT(stats.updropped)},
69 {"uplcong", NETXEN_NIC_STAT(stats.uplcong)},
70 {"uphcong", NETXEN_NIC_STAT(stats.uphcong)},
71 {"upmcong", NETXEN_NIC_STAT(stats.upmcong)},
72 {"updunno", NETXEN_NIC_STAT(stats.updunno)},
73 {"skb_freed", NETXEN_NIC_STAT(stats.skbfreed)},
74 {"tx_dropped", NETXEN_NIC_STAT(stats.txdropped)},
75 {"tx_null_skb", NETXEN_NIC_STAT(stats.txnullskb)},
76 {"csummed", NETXEN_NIC_STAT(stats.csummed)},
77 {"no_rcv", NETXEN_NIC_STAT(stats.no_rcv)},
78 {"rx_bytes", NETXEN_NIC_STAT(stats.rxbytes)},
79 {"tx_bytes", NETXEN_NIC_STAT(stats.txbytes)},
80};
81
82#define NETXEN_NIC_STATS_LEN \
83 sizeof(netxen_nic_gstrings_stats) / sizeof(struct netxen_nic_stats)
84
85static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = {
86 "Register_Test_offline", "EEPROM_Test_offline",
87 "Interrupt_Test_offline", "Loopback_Test_offline",
88 "Link_Test_on_offline"
89};
90
91#define NETXEN_NIC_TEST_LEN sizeof(netxen_nic_gstrings_test) / ETH_GSTRING_LEN
92
93#define NETXEN_NIC_REGS_COUNT 42
94#define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32))
95#define NETXEN_MAX_EEPROM_LEN 1024
96
97static int netxen_nic_get_eeprom_len(struct net_device *dev)
98{
99 struct netxen_port *port = netdev_priv(dev);
100 struct netxen_adapter *adapter = port->adapter;
101 int n;
102
103 if ((netxen_rom_fast_read(adapter, 0, &n) == 0)
104 && (n & NETXEN_ROM_ROUNDUP)) {
105 n &= ~NETXEN_ROM_ROUNDUP;
106 if (n < NETXEN_MAX_EEPROM_LEN)
107 return n;
108 }
109 return 0;
110}
111
112static void
113netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
114{
115 struct netxen_port *port = netdev_priv(dev);
116 struct netxen_adapter *adapter = port->adapter;
117 u32 fw_major = 0;
118 u32 fw_minor = 0;
119 u32 fw_build = 0;
120
121 strncpy(drvinfo->driver, "netxen_nic", 32);
122 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
123 fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
124 NETXEN_FW_VERSION_MAJOR));
125 fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter,
126 NETXEN_FW_VERSION_MINOR));
127 fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
128 sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
129
130 strncpy(drvinfo->bus_info, pci_name(port->pdev), 32);
131 drvinfo->n_stats = NETXEN_NIC_STATS_LEN;
132 drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN;
133 drvinfo->regdump_len = NETXEN_NIC_REGS_LEN;
134 drvinfo->eedump_len = netxen_nic_get_eeprom_len(dev);
135}
136
137static int
138netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
139{
140 struct netxen_port *port = netdev_priv(dev);
141 struct netxen_adapter *adapter = port->adapter;
142 struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg;
143
144 /* read which mode */
145 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
146 ecmd->supported = (SUPPORTED_10baseT_Half |
147 SUPPORTED_10baseT_Full |
148 SUPPORTED_100baseT_Half |
149 SUPPORTED_100baseT_Full |
150 SUPPORTED_1000baseT_Half |
151 SUPPORTED_1000baseT_Full);
152
153 ecmd->advertising = (ADVERTISED_100baseT_Half |
154 ADVERTISED_100baseT_Full |
155 ADVERTISED_1000baseT_Half |
156 ADVERTISED_1000baseT_Full);
157
158 ecmd->port = PORT_TP;
159
160 if (netif_running(dev)) {
161 ecmd->speed = port->link_speed;
162 ecmd->duplex = port->link_duplex;
163 } else
164 return -EIO; /* link absent */
165 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
166 ecmd->supported = (SUPPORTED_TP |
167 SUPPORTED_1000baseT_Full |
168 SUPPORTED_10000baseT_Full);
169 ecmd->advertising = (ADVERTISED_TP |
170 ADVERTISED_1000baseT_Full |
171 ADVERTISED_10000baseT_Full);
172 ecmd->port = PORT_TP;
173
174 ecmd->speed = SPEED_10000;
175 ecmd->duplex = DUPLEX_FULL;
176 ecmd->autoneg = AUTONEG_DISABLE;
177 } else
178 return -EIO;
179
180 ecmd->phy_address = port->portnum;
181 ecmd->transceiver = XCVR_EXTERNAL;
182
183 switch ((netxen_brdtype_t) boardinfo->board_type) {
184 case NETXEN_BRDTYPE_P2_SB35_4G:
185 case NETXEN_BRDTYPE_P2_SB31_2G:
186 ecmd->supported |= SUPPORTED_Autoneg;
187 ecmd->advertising |= ADVERTISED_Autoneg;
188 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
189 ecmd->supported |= SUPPORTED_TP;
190 ecmd->advertising |= ADVERTISED_TP;
191 ecmd->port = PORT_TP;
192 ecmd->autoneg = (boardinfo->board_type ==
193 NETXEN_BRDTYPE_P2_SB31_10G_CX4) ?
194 (AUTONEG_DISABLE) : (port->link_autoneg);
195 break;
196 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
197 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
198 ecmd->supported |= SUPPORTED_MII;
199 ecmd->advertising |= ADVERTISED_MII;
200 ecmd->port = PORT_FIBRE;
201 ecmd->autoneg = AUTONEG_DISABLE;
202 break;
203 case NETXEN_BRDTYPE_P2_SB31_10G:
204 ecmd->supported |= SUPPORTED_FIBRE;
205 ecmd->advertising |= ADVERTISED_FIBRE;
206 ecmd->port = PORT_FIBRE;
207 ecmd->autoneg = AUTONEG_DISABLE;
208 break;
209 default:
210 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
211 (netxen_brdtype_t) boardinfo->board_type);
212 return -EIO;
213
214 }
215
216 return 0;
217}
218
219static int
220netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
221{
222 struct netxen_port *port = netdev_priv(dev);
223 struct netxen_adapter *adapter = port->adapter;
224 __le32 status;
225
226 /* read which mode */
227 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
228 /* autonegotiation */
229 if (adapter->ops->phy_write
230 && adapter->ops->phy_write(adapter, port->portnum,
231 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
232 (__le32) ecmd->autoneg) != 0)
233 return -EIO;
234 else
235 port->link_autoneg = ecmd->autoneg;
236
237 if (adapter->ops->phy_read
238 && adapter->ops->phy_read(adapter, port->portnum,
239 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
240 &status) != 0)
241 return -EIO;
242
243 /* speed */
244 switch (ecmd->speed) {
245 case SPEED_10:
246 netxen_set_phy_speed(status, 0);
247 break;
248 case SPEED_100:
249 netxen_set_phy_speed(status, 1);
250 break;
251 case SPEED_1000:
252 netxen_set_phy_speed(status, 2);
253 break;
254 }
255 /* set duplex mode */
256 if (ecmd->duplex == DUPLEX_HALF)
257 netxen_clear_phy_duplex(status);
258 if (ecmd->duplex == DUPLEX_FULL)
259 netxen_set_phy_duplex(status);
260 if (adapter->ops->phy_write
261 && adapter->ops->phy_write(adapter, port->portnum,
262 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
263 *((int *)&status)) != 0)
264 return -EIO;
265 else {
266 port->link_speed = ecmd->speed;
267 port->link_duplex = ecmd->duplex;
268 }
269 } else
270 return -EOPNOTSUPP;
271
272 if (netif_running(dev)) {
273 dev->stop(dev);
274 dev->open(dev);
275 }
276 return 0;
277}
278
279static int netxen_nic_get_regs_len(struct net_device *dev)
280{
281 return NETXEN_NIC_REGS_LEN;
282}
283
284struct netxen_niu_regs {
285 __le32 reg[NETXEN_NIC_REGS_COUNT];
286};
287
288static struct netxen_niu_regs niu_registers[] = {
289 {
290 /* GB Mode */
291 {
292 NETXEN_NIU_GB_SERDES_RESET,
293 NETXEN_NIU_GB0_MII_MODE,
294 NETXEN_NIU_GB1_MII_MODE,
295 NETXEN_NIU_GB2_MII_MODE,
296 NETXEN_NIU_GB3_MII_MODE,
297 NETXEN_NIU_GB0_GMII_MODE,
298 NETXEN_NIU_GB1_GMII_MODE,
299 NETXEN_NIU_GB2_GMII_MODE,
300 NETXEN_NIU_GB3_GMII_MODE,
301 NETXEN_NIU_REMOTE_LOOPBACK,
302 NETXEN_NIU_GB0_HALF_DUPLEX,
303 NETXEN_NIU_GB1_HALF_DUPLEX,
304 NETXEN_NIU_RESET_SYS_FIFOS,
305 NETXEN_NIU_GB_CRC_DROP,
306 NETXEN_NIU_GB_DROP_WRONGADDR,
307 NETXEN_NIU_TEST_MUX_CTL,
308
309 NETXEN_NIU_GB_MAC_CONFIG_0(0),
310 NETXEN_NIU_GB_MAC_CONFIG_1(0),
311 NETXEN_NIU_GB_HALF_DUPLEX_CTRL(0),
312 NETXEN_NIU_GB_MAX_FRAME_SIZE(0),
313 NETXEN_NIU_GB_TEST_REG(0),
314 NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
315 NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
316 NETXEN_NIU_GB_MII_MGMT_ADDR(0),
317 NETXEN_NIU_GB_MII_MGMT_CTRL(0),
318 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
319 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
320 NETXEN_NIU_GB_INTERFACE_CTRL(0),
321 NETXEN_NIU_GB_INTERFACE_STATUS(0),
322 NETXEN_NIU_GB_STATION_ADDR_0(0),
323 NETXEN_NIU_GB_STATION_ADDR_1(0),
324 -1,
325 }
326 },
327 {
328 /* XG Mode */
329 {
330 NETXEN_NIU_XG_SINGLE_TERM,
331 NETXEN_NIU_XG_DRIVE_HI,
332 NETXEN_NIU_XG_DRIVE_LO,
333 NETXEN_NIU_XG_DTX,
334 NETXEN_NIU_XG_DEQ,
335 NETXEN_NIU_XG_WORD_ALIGN,
336 NETXEN_NIU_XG_RESET,
337 NETXEN_NIU_XG_POWER_DOWN,
338 NETXEN_NIU_XG_RESET_PLL,
339 NETXEN_NIU_XG_SERDES_LOOPBACK,
340 NETXEN_NIU_XG_DO_BYTE_ALIGN,
341 NETXEN_NIU_XG_TX_ENABLE,
342 NETXEN_NIU_XG_RX_ENABLE,
343 NETXEN_NIU_XG_STATUS,
344 NETXEN_NIU_XG_PAUSE_THRESHOLD,
345 NETXEN_NIU_XGE_CONFIG_0,
346 NETXEN_NIU_XGE_CONFIG_1,
347 NETXEN_NIU_XGE_IPG,
348 NETXEN_NIU_XGE_STATION_ADDR_0_HI,
349 NETXEN_NIU_XGE_STATION_ADDR_0_1,
350 NETXEN_NIU_XGE_STATION_ADDR_1_LO,
351 NETXEN_NIU_XGE_STATUS,
352 NETXEN_NIU_XGE_MAX_FRAME_SIZE,
353 NETXEN_NIU_XGE_PAUSE_FRAME_VALUE,
354 NETXEN_NIU_XGE_TX_BYTE_CNT,
355 NETXEN_NIU_XGE_TX_FRAME_CNT,
356 NETXEN_NIU_XGE_RX_BYTE_CNT,
357 NETXEN_NIU_XGE_RX_FRAME_CNT,
358 NETXEN_NIU_XGE_AGGR_ERROR_CNT,
359 NETXEN_NIU_XGE_MULTICAST_FRAME_CNT,
360 NETXEN_NIU_XGE_UNICAST_FRAME_CNT,
361 NETXEN_NIU_XGE_CRC_ERROR_CNT,
362 NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
363 NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
364 NETXEN_NIU_XGE_LOCAL_ERROR_CNT,
365 NETXEN_NIU_XGE_REMOTE_ERROR_CNT,
366 NETXEN_NIU_XGE_CONTROL_CHAR_CNT,
367 NETXEN_NIU_XGE_PAUSE_FRAME_CNT,
368 -1,
369 }
370 }
371};
372
373static void
374netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
375{
376 struct netxen_port *port = netdev_priv(dev);
377 struct netxen_adapter *adapter = port->adapter;
378 __le32 mode, *regs_buff = p;
379 void __iomem *addr;
380 int i, window;
381
382 memset(p, 0, NETXEN_NIC_REGS_LEN);
383 regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
384 (port->pdev)->device;
385 /* which mode */
386 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, &regs_buff[0]);
387 mode = regs_buff[0];
388
389 /* Common registers to all the modes */
390 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER,
391 &regs_buff[2]);
392 /* GB/XGB Mode */
393 mode = (mode / 2) - 1;
394 window = 0;
395 if (mode <= 1) {
396 for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) {
397 /* GB: port specific registers */
398 if (mode == 0 && i >= 19)
399 window = port->portnum * NETXEN_NIC_PORT_WINDOW;
400
401 NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode].
402 reg[i - 3] + window,
403 &regs_buff[i]);
404 }
405
406 }
407}
408
409static void
410netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
411{
412 wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
413 /* options can be added depending upon the mode */
414 wol->wolopts = 0;
415}
416
417static u32 netxen_nic_get_link(struct net_device *dev)
418{
419 struct netxen_port *port = netdev_priv(dev);
420 struct netxen_adapter *adapter = port->adapter;
421 __le32 status;
422
423 /* read which mode */
424 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
425 if (adapter->ops->phy_read
426 && adapter->ops->phy_read(adapter, port->portnum,
427 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
428 &status) != 0)
429 return -EIO;
430 else
431 return (netxen_get_phy_link(status));
432 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
433 int val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
434 return val == XG_LINK_UP;
435 }
436 return -EIO;
437}
438
439static int
440netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
441 u8 * bytes)
442{
443 struct netxen_port *port = netdev_priv(dev);
444 struct netxen_adapter *adapter = port->adapter;
445 int offset;
446
447 if (eeprom->len == 0)
448 return -EINVAL;
449
450 eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16);
451 for (offset = 0; offset < eeprom->len; offset++)
452 if (netxen_rom_fast_read
453 (adapter, (8 * offset) + 8, (int *)eeprom->data) == -1)
454 return -EIO;
455 return 0;
456}
457
458static void
459netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
460{
461 struct netxen_port *port = netdev_priv(dev);
462 struct netxen_adapter *adapter = port->adapter;
463 int i, j;
464
465 ring->rx_pending = 0;
466 for (i = 0; i < MAX_RCV_CTX; ++i) {
467 for (j = 0; j < NUM_RCV_DESC_RINGS; j++)
468 ring->rx_pending +=
469 adapter->recv_ctx[i].rcv_desc[j].rcv_pending;
470 }
471
472 ring->rx_max_pending = adapter->max_rx_desc_count;
473 ring->tx_max_pending = adapter->max_tx_desc_count;
474 ring->rx_mini_max_pending = 0;
475 ring->rx_mini_pending = 0;
476 ring->rx_jumbo_max_pending = 0;
477 ring->rx_jumbo_pending = 0;
478}
479
480static void
481netxen_nic_get_pauseparam(struct net_device *dev,
482 struct ethtool_pauseparam *pause)
483{
484 struct netxen_port *port = netdev_priv(dev);
485 struct netxen_adapter *adapter = port->adapter;
486 __le32 val;
487
488 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
489 /* get flow control settings */
490 netxen_nic_read_w0(adapter,
491 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
492 (u32 *) & val);
493 pause->rx_pause = netxen_gb_get_rx_flowctl(val);
494 pause->tx_pause = netxen_gb_get_tx_flowctl(val);
495 /* get autoneg settings */
496 pause->autoneg = port->link_autoneg;
497 }
498}
499
500static int
501netxen_nic_set_pauseparam(struct net_device *dev,
502 struct ethtool_pauseparam *pause)
503{
504 struct netxen_port *port = netdev_priv(dev);
505 struct netxen_adapter *adapter = port->adapter;
506 __le32 val;
507 unsigned int autoneg;
508
509 /* read mode */
510 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
511 /* set flow control */
512 netxen_nic_read_w0(adapter,
513 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
514 (u32 *) & val);
515 if (pause->tx_pause)
516 netxen_gb_tx_flowctl(val);
517 else
518 netxen_gb_unset_tx_flowctl(val);
519 if (pause->rx_pause)
520 netxen_gb_rx_flowctl(val);
521 else
522 netxen_gb_unset_rx_flowctl(val);
523
524 netxen_nic_write_w0(adapter,
525 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum),
526 *(u32 *) (&val));
527 /* set autoneg */
528 autoneg = pause->autoneg;
529 if (adapter->ops->phy_write
530 && adapter->ops->phy_write(adapter, port->portnum,
531 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
532 (__le32) autoneg) != 0)
533 return -EIO;
534 else {
535 port->link_autoneg = pause->autoneg;
536 return 0;
537 }
538 } else
539 return -EOPNOTSUPP;
540}
541
542static int netxen_nic_reg_test(struct net_device *dev)
543{
544 struct netxen_port *port = netdev_priv(dev);
545 struct netxen_adapter *adapter = port->adapter;
546 u32 data_read, data_written, save;
547 __le32 mode;
548
549 /*
550 * first test the "Read Only" registers by writing which mode
551 */
552 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode);
553 if (netxen_get_niu_enable_ge(mode)) { /* GB Mode */
554 netxen_nic_read_w0(adapter,
555 NETXEN_NIU_GB_MII_MGMT_STATUS(port->portnum),
556 &data_read);
557
558 save = data_read;
559 if (data_read)
560 data_written = data_read & NETXEN_NIC_INVALID_DATA;
561 else
562 data_written = NETXEN_NIC_INVALID_DATA;
563 netxen_nic_write_w0(adapter,
564 NETXEN_NIU_GB_MII_MGMT_STATUS(port->
565 portnum),
566 data_written);
567 netxen_nic_read_w0(adapter,
568 NETXEN_NIU_GB_MII_MGMT_STATUS(port->portnum),
569 &data_read);
570
571 if (data_written == data_read) {
572 netxen_nic_write_w0(adapter,
573 NETXEN_NIU_GB_MII_MGMT_STATUS(port->
574 portnum),
575 save);
576
577 return 0;
578 }
579
580 /* netxen_niu_gb_mii_mgmt_indicators is read only */
581 netxen_nic_read_w0(adapter,
582 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
583 portnum),
584 &data_read);
585
586 save = data_read;
587 if (data_read)
588 data_written = data_read & NETXEN_NIC_INVALID_DATA;
589 else
590 data_written = NETXEN_NIC_INVALID_DATA;
591 netxen_nic_write_w0(adapter,
592 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
593 portnum),
594 data_written);
595
596 netxen_nic_read_w0(adapter,
597 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
598 portnum),
599 &data_read);
600
601 if (data_written == data_read) {
602 netxen_nic_write_w0(adapter,
603 NETXEN_NIU_GB_MII_MGMT_INDICATE
604 (port->portnum), save);
605 return 0;
606 }
607
608 /* netxen_niu_gb_interface_status is read only */
609 netxen_nic_read_w0(adapter,
610 NETXEN_NIU_GB_INTERFACE_STATUS(port->
611 portnum),
612 &data_read);
613
614 save = data_read;
615 if (data_read)
616 data_written = data_read & NETXEN_NIC_INVALID_DATA;
617 else
618 data_written = NETXEN_NIC_INVALID_DATA;
619 netxen_nic_write_w0(adapter,
620 NETXEN_NIU_GB_INTERFACE_STATUS(port->
621 portnum),
622 data_written);
623
624 netxen_nic_read_w0(adapter,
625 NETXEN_NIU_GB_INTERFACE_STATUS(port->
626 portnum),
627 &data_read);
628
629 if (data_written == data_read) {
630 netxen_nic_write_w0(adapter,
631 NETXEN_NIU_GB_INTERFACE_STATUS
632 (port->portnum), save);
633
634 return 0;
635 }
636 } /* GB Mode */
637 return 1;
638}
639
640static int netxen_nic_diag_test_count(struct net_device *dev)
641{
642 return NETXEN_NIC_TEST_LEN;
643}
644
645static void
646netxen_nic_diag_test(struct net_device *dev, struct ethtool_test *eth_test,
647 u64 * data)
648{
649 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { /* offline tests */
650 /* link test */
651 if (!(data[4] = (u64) netxen_nic_get_link(dev)))
652 eth_test->flags |= ETH_TEST_FL_FAILED;
653
654 if (netif_running(dev))
655 dev->stop(dev);
656
657 /* register tests */
658 if (!(data[0] = netxen_nic_reg_test(dev)))
659 eth_test->flags |= ETH_TEST_FL_FAILED;
660 /* other tests pass as of now */
661 data[1] = data[2] = data[3] = 1;
662 if (netif_running(dev))
663 dev->open(dev);
664 } else { /* online tests */
665 /* link test */
666 if (!(data[4] = (u64) netxen_nic_get_link(dev)))
667 eth_test->flags |= ETH_TEST_FL_FAILED;
668
669 /* other tests pass by default */
670 data[0] = data[1] = data[2] = data[3] = 1;
671 }
672}
673
674static void
675netxen_nic_get_strings(struct net_device *dev, u32 stringset, u8 * data)
676{
677 int index;
678
679 switch (stringset) {
680 case ETH_SS_TEST:
681 memcpy(data, *netxen_nic_gstrings_test,
682 NETXEN_NIC_TEST_LEN * ETH_GSTRING_LEN);
683 break;
684 case ETH_SS_STATS:
685 for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
686 memcpy(data + index * ETH_GSTRING_LEN,
687 netxen_nic_gstrings_stats[index].stat_string,
688 ETH_GSTRING_LEN);
689 }
690 break;
691 }
692}
693
694static int netxen_nic_get_stats_count(struct net_device *dev)
695{
696 return NETXEN_NIC_STATS_LEN;
697}
698
699static void
700netxen_nic_get_ethtool_stats(struct net_device *dev,
701 struct ethtool_stats *stats, u64 * data)
702{
703 struct netxen_port *port = netdev_priv(dev);
704 int index;
705
706 for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
707 char *p =
708 (char *)port + netxen_nic_gstrings_stats[index].stat_offset;
709 data[index] =
710 (netxen_nic_gstrings_stats[index].sizeof_stat ==
711 sizeof(u64)) ? *(u64 *) p : *(u32 *) p;
712 }
713
714}
715
716struct ethtool_ops netxen_nic_ethtool_ops = {
717 .get_settings = netxen_nic_get_settings,
718 .set_settings = netxen_nic_set_settings,
719 .get_drvinfo = netxen_nic_get_drvinfo,
720 .get_regs_len = netxen_nic_get_regs_len,
721 .get_regs = netxen_nic_get_regs,
722 .get_wol = netxen_nic_get_wol,
723 .get_link = netxen_nic_get_link,
724 .get_eeprom_len = netxen_nic_get_eeprom_len,
725 .get_eeprom = netxen_nic_get_eeprom,
726 .get_ringparam = netxen_nic_get_ringparam,
727 .get_pauseparam = netxen_nic_get_pauseparam,
728 .set_pauseparam = netxen_nic_set_pauseparam,
729 .get_tx_csum = ethtool_op_get_tx_csum,
730 .set_tx_csum = ethtool_op_set_tx_csum,
731 .get_sg = ethtool_op_get_sg,
732 .set_sg = ethtool_op_set_sg,
733 .get_tso = ethtool_op_get_tso,
734 .set_tso = ethtool_op_set_tso,
735 .self_test_count = netxen_nic_diag_test_count,
736 .self_test = netxen_nic_diag_test,
737 .get_strings = netxen_nic_get_strings,
738 .get_stats_count = netxen_nic_get_stats_count,
739 .get_ethtool_stats = netxen_nic_get_ethtool_stats,
740 .get_perm_addr = ethtool_op_get_perm_addr,
741};
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
new file mode 100644
index 000000000000..72c6ec4ee2a0
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -0,0 +1,678 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef __NETXEN_NIC_HDR_H_
31#define __NETXEN_NIC_HDR_H_
32
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/version.h>
36
37#include <asm/semaphore.h>
38#include <linux/spinlock.h>
39#include <asm/irq.h>
40#include <linux/init.h>
41#include <linux/errno.h>
42#include <linux/pci.h>
43#include <linux/types.h>
44#include <asm/uaccess.h>
45#include <asm/string.h> /* for memset */
46
47/*
48 * The basic unit of access when reading/writing control registers.
49 */
50
51typedef __le32 netxen_crbword_t; /* single word in CRB space */
52
53enum {
54 NETXEN_HW_H0_CH_HUB_ADR = 0x05,
55 NETXEN_HW_H1_CH_HUB_ADR = 0x0E,
56 NETXEN_HW_H2_CH_HUB_ADR = 0x03,
57 NETXEN_HW_H3_CH_HUB_ADR = 0x01,
58 NETXEN_HW_H4_CH_HUB_ADR = 0x06,
59 NETXEN_HW_H5_CH_HUB_ADR = 0x07,
60 NETXEN_HW_H6_CH_HUB_ADR = 0x08
61};
62
63/* Hub 0 */
64enum {
65 NETXEN_HW_MN_CRB_AGT_ADR = 0x15,
66 NETXEN_HW_MS_CRB_AGT_ADR = 0x25
67};
68
69/* Hub 1 */
70enum {
71 NETXEN_HW_PS_CRB_AGT_ADR = 0x73,
72 NETXEN_HW_SS_CRB_AGT_ADR = 0x20,
73 NETXEN_HW_RPMX3_CRB_AGT_ADR = 0x0b,
74 NETXEN_HW_QMS_CRB_AGT_ADR = 0x00,
75 NETXEN_HW_SQGS0_CRB_AGT_ADR = 0x01,
76 NETXEN_HW_SQGS1_CRB_AGT_ADR = 0x02,
77 NETXEN_HW_SQGS2_CRB_AGT_ADR = 0x03,
78 NETXEN_HW_SQGS3_CRB_AGT_ADR = 0x04,
79 NETXEN_HW_C2C0_CRB_AGT_ADR = 0x58,
80 NETXEN_HW_C2C1_CRB_AGT_ADR = 0x59,
81 NETXEN_HW_C2C2_CRB_AGT_ADR = 0x5a,
82 NETXEN_HW_RPMX2_CRB_AGT_ADR = 0x0a,
83 NETXEN_HW_RPMX4_CRB_AGT_ADR = 0x0c,
84 NETXEN_HW_RPMX7_CRB_AGT_ADR = 0x0f,
85 NETXEN_HW_RPMX9_CRB_AGT_ADR = 0x12,
86 NETXEN_HW_SMB_CRB_AGT_ADR = 0x18
87};
88
89/* Hub 2 */
90enum {
91 NETXEN_HW_NIU_CRB_AGT_ADR = 0x31,
92 NETXEN_HW_I2C0_CRB_AGT_ADR = 0x19,
93 NETXEN_HW_I2C1_CRB_AGT_ADR = 0x29,
94
95 NETXEN_HW_SN_CRB_AGT_ADR = 0x10,
96 NETXEN_HW_I2Q_CRB_AGT_ADR = 0x20,
97 NETXEN_HW_LPC_CRB_AGT_ADR = 0x22,
98 NETXEN_HW_ROMUSB_CRB_AGT_ADR = 0x21,
99 NETXEN_HW_QM_CRB_AGT_ADR = 0x66,
100 NETXEN_HW_SQG0_CRB_AGT_ADR = 0x60,
101 NETXEN_HW_SQG1_CRB_AGT_ADR = 0x61,
102 NETXEN_HW_SQG2_CRB_AGT_ADR = 0x62,
103 NETXEN_HW_SQG3_CRB_AGT_ADR = 0x63,
104 NETXEN_HW_RPMX1_CRB_AGT_ADR = 0x09,
105 NETXEN_HW_RPMX5_CRB_AGT_ADR = 0x0d,
106 NETXEN_HW_RPMX6_CRB_AGT_ADR = 0x0e,
107 NETXEN_HW_RPMX8_CRB_AGT_ADR = 0x11
108};
109
110/* Hub 3 */
111enum {
112 NETXEN_HW_PH_CRB_AGT_ADR = 0x1A,
113 NETXEN_HW_SRE_CRB_AGT_ADR = 0x50,
114 NETXEN_HW_EG_CRB_AGT_ADR = 0x51,
115 NETXEN_HW_RPMX0_CRB_AGT_ADR = 0x08
116};
117
118/* Hub 4 */
119enum {
120 NETXEN_HW_PEGN0_CRB_AGT_ADR = 0x40,
121 NETXEN_HW_PEGN1_CRB_AGT_ADR,
122 NETXEN_HW_PEGN2_CRB_AGT_ADR,
123 NETXEN_HW_PEGN3_CRB_AGT_ADR,
124 NETXEN_HW_PEGNI_CRB_AGT_ADR,
125 NETXEN_HW_PEGND_CRB_AGT_ADR,
126 NETXEN_HW_PEGNC_CRB_AGT_ADR,
127 NETXEN_HW_PEGR0_CRB_AGT_ADR,
128 NETXEN_HW_PEGR1_CRB_AGT_ADR,
129 NETXEN_HW_PEGR2_CRB_AGT_ADR,
130 NETXEN_HW_PEGR3_CRB_AGT_ADR
131};
132
133/* Hub 5 */
134enum {
135 NETXEN_HW_PEGS0_CRB_AGT_ADR = 0x40,
136 NETXEN_HW_PEGS1_CRB_AGT_ADR,
137 NETXEN_HW_PEGS2_CRB_AGT_ADR,
138 NETXEN_HW_PEGS3_CRB_AGT_ADR,
139 NETXEN_HW_PEGSI_CRB_AGT_ADR,
140 NETXEN_HW_PEGSD_CRB_AGT_ADR,
141 NETXEN_HW_PEGSC_CRB_AGT_ADR
142};
143
144/* Hub 6 */
145enum {
146 NETXEN_HW_CAS0_CRB_AGT_ADR = 0x46,
147 NETXEN_HW_CAS1_CRB_AGT_ADR = 0x47,
148 NETXEN_HW_CAS2_CRB_AGT_ADR = 0x48,
149 NETXEN_HW_CAS3_CRB_AGT_ADR = 0x49,
150 NETXEN_HW_NCM_CRB_AGT_ADR = 0x16,
151 NETXEN_HW_TMR_CRB_AGT_ADR = 0x17,
152 NETXEN_HW_XDMA_CRB_AGT_ADR = 0x05,
153 NETXEN_HW_OCM0_CRB_AGT_ADR = 0x06,
154 NETXEN_HW_OCM1_CRB_AGT_ADR = 0x07
155};
156
157/* Floaters - non existent modules */
158#define NETXEN_HW_EFC_RPMX0_CRB_AGT_ADR 0x67
159
160/* This field defines PCI/X adr [25:20] of agents on the CRB */
161enum {
162 NETXEN_HW_PX_MAP_CRB_PH = 0,
163 NETXEN_HW_PX_MAP_CRB_PS,
164 NETXEN_HW_PX_MAP_CRB_MN,
165 NETXEN_HW_PX_MAP_CRB_MS,
166 NETXEN_HW_PX_MAP_CRB_PGR1,
167 NETXEN_HW_PX_MAP_CRB_SRE,
168 NETXEN_HW_PX_MAP_CRB_NIU,
169 NETXEN_HW_PX_MAP_CRB_QMN,
170 NETXEN_HW_PX_MAP_CRB_SQN0,
171 NETXEN_HW_PX_MAP_CRB_SQN1,
172 NETXEN_HW_PX_MAP_CRB_SQN2,
173 NETXEN_HW_PX_MAP_CRB_SQN3,
174 NETXEN_HW_PX_MAP_CRB_QMS,
175 NETXEN_HW_PX_MAP_CRB_SQS0,
176 NETXEN_HW_PX_MAP_CRB_SQS1,
177 NETXEN_HW_PX_MAP_CRB_SQS2,
178 NETXEN_HW_PX_MAP_CRB_SQS3,
179 NETXEN_HW_PX_MAP_CRB_PGN0,
180 NETXEN_HW_PX_MAP_CRB_PGN1,
181 NETXEN_HW_PX_MAP_CRB_PGN2,
182 NETXEN_HW_PX_MAP_CRB_PGN3,
183 NETXEN_HW_PX_MAP_CRB_PGND,
184 NETXEN_HW_PX_MAP_CRB_PGNI,
185 NETXEN_HW_PX_MAP_CRB_PGS0,
186 NETXEN_HW_PX_MAP_CRB_PGS1,
187 NETXEN_HW_PX_MAP_CRB_PGS2,
188 NETXEN_HW_PX_MAP_CRB_PGS3,
189 NETXEN_HW_PX_MAP_CRB_PGSD,
190 NETXEN_HW_PX_MAP_CRB_PGSI,
191 NETXEN_HW_PX_MAP_CRB_SN,
192 NETXEN_HW_PX_MAP_CRB_PGR2,
193 NETXEN_HW_PX_MAP_CRB_EG,
194 NETXEN_HW_PX_MAP_CRB_PH2,
195 NETXEN_HW_PX_MAP_CRB_PS2,
196 NETXEN_HW_PX_MAP_CRB_CAM,
197 NETXEN_HW_PX_MAP_CRB_CAS0,
198 NETXEN_HW_PX_MAP_CRB_CAS1,
199 NETXEN_HW_PX_MAP_CRB_CAS2,
200 NETXEN_HW_PX_MAP_CRB_C2C0,
201 NETXEN_HW_PX_MAP_CRB_C2C1,
202 NETXEN_HW_PX_MAP_CRB_TIMR,
203 NETXEN_HW_PX_MAP_CRB_PGR3,
204 NETXEN_HW_PX_MAP_CRB_RPMX1,
205 NETXEN_HW_PX_MAP_CRB_RPMX2,
206 NETXEN_HW_PX_MAP_CRB_RPMX3,
207 NETXEN_HW_PX_MAP_CRB_RPMX4,
208 NETXEN_HW_PX_MAP_CRB_RPMX5,
209 NETXEN_HW_PX_MAP_CRB_RPMX6,
210 NETXEN_HW_PX_MAP_CRB_RPMX7,
211 NETXEN_HW_PX_MAP_CRB_XDMA,
212 NETXEN_HW_PX_MAP_CRB_I2Q,
213 NETXEN_HW_PX_MAP_CRB_ROMUSB,
214 NETXEN_HW_PX_MAP_CRB_CAS3,
215 NETXEN_HW_PX_MAP_CRB_RPMX0,
216 NETXEN_HW_PX_MAP_CRB_RPMX8,
217 NETXEN_HW_PX_MAP_CRB_RPMX9,
218 NETXEN_HW_PX_MAP_CRB_OCM0,
219 NETXEN_HW_PX_MAP_CRB_OCM1,
220 NETXEN_HW_PX_MAP_CRB_SMB,
221 NETXEN_HW_PX_MAP_CRB_I2C0,
222 NETXEN_HW_PX_MAP_CRB_I2C1,
223 NETXEN_HW_PX_MAP_CRB_LPC,
224 NETXEN_HW_PX_MAP_CRB_PGNC,
225 NETXEN_HW_PX_MAP_CRB_PGR0
226};
227
228/* This field defines CRB adr [31:20] of the agents */
229
230#define NETXEN_HW_CRB_HUB_AGT_ADR_MN \
231 ((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_MN_CRB_AGT_ADR)
232#define NETXEN_HW_CRB_HUB_AGT_ADR_PH \
233 ((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_PH_CRB_AGT_ADR)
234#define NETXEN_HW_CRB_HUB_AGT_ADR_MS \
235 ((NETXEN_HW_H0_CH_HUB_ADR << 7) | NETXEN_HW_MS_CRB_AGT_ADR)
236
237#define NETXEN_HW_CRB_HUB_AGT_ADR_PS \
238 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_PS_CRB_AGT_ADR)
239#define NETXEN_HW_CRB_HUB_AGT_ADR_SS \
240 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SS_CRB_AGT_ADR)
241#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX3 \
242 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX3_CRB_AGT_ADR)
243#define NETXEN_HW_CRB_HUB_AGT_ADR_QMS \
244 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_QMS_CRB_AGT_ADR)
245#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS0 \
246 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS0_CRB_AGT_ADR)
247#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS1 \
248 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS1_CRB_AGT_ADR)
249#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS2 \
250 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS2_CRB_AGT_ADR)
251#define NETXEN_HW_CRB_HUB_AGT_ADR_SQS3 \
252 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SQGS3_CRB_AGT_ADR)
253#define NETXEN_HW_CRB_HUB_AGT_ADR_C2C0 \
254 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_C2C0_CRB_AGT_ADR)
255#define NETXEN_HW_CRB_HUB_AGT_ADR_C2C1 \
256 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_C2C1_CRB_AGT_ADR)
257#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX2 \
258 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX2_CRB_AGT_ADR)
259#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX4 \
260 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX4_CRB_AGT_ADR)
261#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX7 \
262 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX7_CRB_AGT_ADR)
263#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX9 \
264 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_RPMX9_CRB_AGT_ADR)
265#define NETXEN_HW_CRB_HUB_AGT_ADR_SMB \
266 ((NETXEN_HW_H1_CH_HUB_ADR << 7) | NETXEN_HW_SMB_CRB_AGT_ADR)
267
268#define NETXEN_HW_CRB_HUB_AGT_ADR_NIU \
269 ((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_NIU_CRB_AGT_ADR)
270#define NETXEN_HW_CRB_HUB_AGT_ADR_I2C0 \
271 ((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_I2C0_CRB_AGT_ADR)
272#define NETXEN_HW_CRB_HUB_AGT_ADR_I2C1 \
273 ((NETXEN_HW_H2_CH_HUB_ADR << 7) | NETXEN_HW_I2C1_CRB_AGT_ADR)
274
275#define NETXEN_HW_CRB_HUB_AGT_ADR_SRE \
276 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SRE_CRB_AGT_ADR)
277#define NETXEN_HW_CRB_HUB_AGT_ADR_EG \
278 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_EG_CRB_AGT_ADR)
279#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX0 \
280 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX0_CRB_AGT_ADR)
281#define NETXEN_HW_CRB_HUB_AGT_ADR_QMN \
282 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_QM_CRB_AGT_ADR)
283#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN0 \
284 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG0_CRB_AGT_ADR)
285#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN1 \
286 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG1_CRB_AGT_ADR)
287#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN2 \
288 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG2_CRB_AGT_ADR)
289#define NETXEN_HW_CRB_HUB_AGT_ADR_SQN3 \
290 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_SQG3_CRB_AGT_ADR)
291#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX1 \
292 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX1_CRB_AGT_ADR)
293#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX5 \
294 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX5_CRB_AGT_ADR)
295#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX6 \
296 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX6_CRB_AGT_ADR)
297#define NETXEN_HW_CRB_HUB_AGT_ADR_RPMX8 \
298 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_RPMX8_CRB_AGT_ADR)
299#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS0 \
300 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS0_CRB_AGT_ADR)
301#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS1 \
302 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS1_CRB_AGT_ADR)
303#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS2 \
304 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS2_CRB_AGT_ADR)
305#define NETXEN_HW_CRB_HUB_AGT_ADR_CAS3 \
306 ((NETXEN_HW_H3_CH_HUB_ADR << 7) | NETXEN_HW_CAS3_CRB_AGT_ADR)
307
308#define NETXEN_HW_CRB_HUB_AGT_ADR_PGNI \
309 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGNI_CRB_AGT_ADR)
310#define NETXEN_HW_CRB_HUB_AGT_ADR_PGND \
311 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGND_CRB_AGT_ADR)
312#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN0 \
313 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN0_CRB_AGT_ADR)
314#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN1 \
315 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN1_CRB_AGT_ADR)
316#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN2 \
317 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN2_CRB_AGT_ADR)
318#define NETXEN_HW_CRB_HUB_AGT_ADR_PGN3 \
319 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGN3_CRB_AGT_ADR)
320#define NETXEN_HW_CRB_HUB_AGT_ADR_PGNC \
321 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGNC_CRB_AGT_ADR)
322#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR0 \
323 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR0_CRB_AGT_ADR)
324#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR1 \
325 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR1_CRB_AGT_ADR)
326#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR2 \
327 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR2_CRB_AGT_ADR)
328#define NETXEN_HW_CRB_HUB_AGT_ADR_PGR3 \
329 ((NETXEN_HW_H4_CH_HUB_ADR << 7) | NETXEN_HW_PEGR3_CRB_AGT_ADR)
330
331#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSI \
332 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSI_CRB_AGT_ADR)
333#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSD \
334 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSD_CRB_AGT_ADR)
335#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS0 \
336 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS0_CRB_AGT_ADR)
337#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS1 \
338 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS1_CRB_AGT_ADR)
339#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS2 \
340 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS2_CRB_AGT_ADR)
341#define NETXEN_HW_CRB_HUB_AGT_ADR_PGS3 \
342 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGS3_CRB_AGT_ADR)
343#define NETXEN_HW_CRB_HUB_AGT_ADR_PGSC \
344 ((NETXEN_HW_H5_CH_HUB_ADR << 7) | NETXEN_HW_PEGSC_CRB_AGT_ADR)
345
346#define NETXEN_HW_CRB_HUB_AGT_ADR_CAM \
347 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_NCM_CRB_AGT_ADR)
348#define NETXEN_HW_CRB_HUB_AGT_ADR_TIMR \
349 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_TMR_CRB_AGT_ADR)
350#define NETXEN_HW_CRB_HUB_AGT_ADR_XDMA \
351 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_XDMA_CRB_AGT_ADR)
352#define NETXEN_HW_CRB_HUB_AGT_ADR_SN \
353 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_SN_CRB_AGT_ADR)
354#define NETXEN_HW_CRB_HUB_AGT_ADR_I2Q \
355 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_I2Q_CRB_AGT_ADR)
356#define NETXEN_HW_CRB_HUB_AGT_ADR_ROMUSB \
357 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_ROMUSB_CRB_AGT_ADR)
358#define NETXEN_HW_CRB_HUB_AGT_ADR_OCM0 \
359 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_OCM0_CRB_AGT_ADR)
360#define NETXEN_HW_CRB_HUB_AGT_ADR_OCM1 \
361 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_OCM1_CRB_AGT_ADR)
362#define NETXEN_HW_CRB_HUB_AGT_ADR_LPC \
363 ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_LPC_CRB_AGT_ADR)
364
365/*
366 * MAX_RCV_CTX : The number of receive contexts that are available on
367 * the phantom.
368 */
369#define MAX_RCV_CTX 1
370
371#define NETXEN_SRE_INT_STATUS (NETXEN_CRB_SRE + 0x00034)
372#define NETXEN_SRE_PBI_ACTIVE_STATUS (NETXEN_CRB_SRE + 0x01014)
373#define NETXEN_SRE_L1RE_CTL (NETXEN_CRB_SRE + 0x03000)
374#define NETXEN_SRE_L2RE_CTL (NETXEN_CRB_SRE + 0x05000)
375#define NETXEN_SRE_BUF_CTL (NETXEN_CRB_SRE + 0x01000)
376
377#define NETXEN_DMA_BASE(U) (NETXEN_CRB_PCIX_MD + 0x20000 + ((U)<<16))
378#define NETXEN_DMA_COMMAND(U) (NETXEN_DMA_BASE(U) + 0x00008)
379
380#define NETXEN_I2Q_CLR_PCI_HI (NETXEN_CRB_I2Q + 0x00034)
381
382#define PEG_NETWORK_BASE(N) (NETXEN_CRB_PEG_NET_0 + (((N)&3) << 20))
383#define CRB_REG_EX_PC 0x3c
384
385#define ROMUSB_GLB (NETXEN_CRB_ROMUSB + 0x00000)
386#define ROMUSB_ROM (NETXEN_CRB_ROMUSB + 0x10000)
387
388#define NETXEN_ROMUSB_GLB_STATUS (ROMUSB_GLB + 0x0004)
389#define NETXEN_ROMUSB_GLB_SW_RESET (ROMUSB_GLB + 0x0008)
390#define NETXEN_ROMUSB_GLB_PAD_GPIO_I (ROMUSB_GLB + 0x000c)
391#define NETXEN_ROMUSB_GLB_CAS_RST (ROMUSB_GLB + 0x0038)
392#define NETXEN_ROMUSB_GLB_TEST_MUX_SEL (ROMUSB_GLB + 0x0044)
393#define NETXEN_ROMUSB_GLB_PEGTUNE_DONE (ROMUSB_GLB + 0x005c)
394#define NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL (ROMUSB_GLB + 0x00A8)
395
396#define NETXEN_ROMUSB_GPIO(n) (ROMUSB_GLB + 0x60 + (4 * (n)))
397
398#define NETXEN_ROMUSB_ROM_INSTR_OPCODE (ROMUSB_ROM + 0x0004)
399#define NETXEN_ROMUSB_ROM_ADDRESS (ROMUSB_ROM + 0x0008)
400#define NETXEN_ROMUSB_ROM_WDATA (ROMUSB_ROM + 0x000c)
401#define NETXEN_ROMUSB_ROM_ABYTE_CNT (ROMUSB_ROM + 0x0010)
402#define NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT (ROMUSB_ROM + 0x0014)
403#define NETXEN_ROMUSB_ROM_RDATA (ROMUSB_ROM + 0x0018)
404
405/* Lock IDs for ROM lock */
406#define ROM_LOCK_DRIVER 0x0d417340
407
408/******************************************************************************
409*
410* Definitions specific to M25P flash
411*
412*******************************************************************************
413* Instructions
414*/
415#define M25P_INSTR_WREN 0x06
416#define M25P_INSTR_WRDI 0x04
417#define M25P_INSTR_RDID 0x9f
418#define M25P_INSTR_RDSR 0x05
419#define M25P_INSTR_WRSR 0x01
420#define M25P_INSTR_READ 0x03
421#define M25P_INSTR_FAST_READ 0x0b
422#define M25P_INSTR_PP 0x02
423#define M25P_INSTR_SE 0xd8
424#define M25P_INSTR_BE 0xc7
425#define M25P_INSTR_DP 0xb9
426#define M25P_INSTR_RES 0xab
427
428/* all are 1MB windows */
429
430#define NETXEN_PCI_CRB_WINDOWSIZE 0x00100000
431#define NETXEN_PCI_CRB_WINDOW(A) \
432 (NETXEN_PCI_CRBSPACE + (A)*NETXEN_PCI_CRB_WINDOWSIZE)
433
434#define NETXEN_CRB_NIU NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_NIU)
435#define NETXEN_CRB_SRE NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_SRE)
436#define NETXEN_CRB_ROMUSB \
437 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_ROMUSB)
438#define NETXEN_CRB_I2Q NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_I2Q)
439#define NETXEN_CRB_MAX NETXEN_PCI_CRB_WINDOW(64)
440
441#define NETXEN_CRB_PCIX_HOST NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PH)
442#define NETXEN_CRB_PCIX_HOST2 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PH2)
443#define NETXEN_CRB_PEG_NET_0 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN0)
444#define NETXEN_CRB_PEG_NET_1 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN1)
445#define NETXEN_CRB_PEG_NET_2 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN2)
446#define NETXEN_CRB_PEG_NET_3 NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGN3)
447#define NETXEN_CRB_PEG_NET_D NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGND)
448#define NETXEN_CRB_PEG_NET_I NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PGNI)
449#define NETXEN_CRB_DDR_NET NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_MN)
450
451#define NETXEN_CRB_PCIX_MD NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_PS)
452#define NETXEN_CRB_PCIE NETXEN_CRB_PCIX_MD
453
454#define ISR_INT_VECTOR (NETXEN_PCIX_PS_REG(PCIX_INT_VECTOR))
455#define ISR_INT_MASK (NETXEN_PCIX_PS_REG(PCIX_INT_MASK))
456#define ISR_INT_MASK_SLOW (NETXEN_PCIX_PS_REG(PCIX_INT_MASK))
457#define ISR_INT_TARGET_STATUS (NETXEN_PCIX_PS_REG(PCIX_TARGET_STATUS))
458#define ISR_INT_TARGET_MASK (NETXEN_PCIX_PS_REG(PCIX_TARGET_MASK))
459
460#define NETXEN_PCI_MAPSIZE 128
461#define NETXEN_PCI_DDR_NET (0x00000000UL)
462#define NETXEN_PCI_QDR_NET (0x04000000UL)
463#define NETXEN_PCI_DIRECT_CRB (0x04400000UL)
464#define NETXEN_PCI_CAMQM_MAX (0x04ffffffUL)
465#define NETXEN_PCI_OCM0 (0x05000000UL)
466#define NETXEN_PCI_OCM0_MAX (0x050fffffUL)
467#define NETXEN_PCI_OCM1 (0x05100000UL)
468#define NETXEN_PCI_OCM1_MAX (0x051fffffUL)
469#define NETXEN_PCI_CRBSPACE (0x06000000UL)
470
471#define NETXEN_CRB_CAM NETXEN_PCI_CRB_WINDOW(NETXEN_HW_PX_MAP_CRB_CAM)
472
473#define NETXEN_ADDR_DDR_NET (0x0000000000000000ULL)
474#define NETXEN_ADDR_DDR_NET_MAX (0x000000000fffffffULL)
475#define NETXEN_ADDR_OCM0 (0x0000000200000000ULL)
476#define NETXEN_ADDR_OCM0_MAX (0x00000002000fffffULL)
477#define NETXEN_ADDR_OCM1 (0x0000000200400000ULL)
478#define NETXEN_ADDR_OCM1_MAX (0x00000002004fffffULL)
479#define NETXEN_ADDR_QDR_NET (0x0000000300000000ULL)
480#define NETXEN_ADDR_QDR_NET_MAX (0x00000003003fffffULL)
481
482 /* 200ms delay in each loop */
483#define NETXEN_NIU_PHY_WAITLEN 200000
484 /* 10 seconds before we give up */
485#define NETXEN_NIU_PHY_WAITMAX 50
486#define NETXEN_NIU_MAX_GBE_PORTS 4
487
488#define NETXEN_NIU_MODE (NETXEN_CRB_NIU + 0x00000)
489
490#define NETXEN_NIU_XG_SINGLE_TERM (NETXEN_CRB_NIU + 0x00004)
491#define NETXEN_NIU_XG_DRIVE_HI (NETXEN_CRB_NIU + 0x00008)
492#define NETXEN_NIU_XG_DRIVE_LO (NETXEN_CRB_NIU + 0x0000c)
493#define NETXEN_NIU_XG_DTX (NETXEN_CRB_NIU + 0x00010)
494#define NETXEN_NIU_XG_DEQ (NETXEN_CRB_NIU + 0x00014)
495#define NETXEN_NIU_XG_WORD_ALIGN (NETXEN_CRB_NIU + 0x00018)
496#define NETXEN_NIU_XG_RESET (NETXEN_CRB_NIU + 0x0001c)
497#define NETXEN_NIU_XG_POWER_DOWN (NETXEN_CRB_NIU + 0x00020)
498#define NETXEN_NIU_XG_RESET_PLL (NETXEN_CRB_NIU + 0x00024)
499#define NETXEN_NIU_XG_SERDES_LOOPBACK (NETXEN_CRB_NIU + 0x00028)
500#define NETXEN_NIU_XG_DO_BYTE_ALIGN (NETXEN_CRB_NIU + 0x0002c)
501#define NETXEN_NIU_XG_TX_ENABLE (NETXEN_CRB_NIU + 0x00030)
502#define NETXEN_NIU_XG_RX_ENABLE (NETXEN_CRB_NIU + 0x00034)
503#define NETXEN_NIU_XG_STATUS (NETXEN_CRB_NIU + 0x00038)
504#define NETXEN_NIU_XG_PAUSE_THRESHOLD (NETXEN_CRB_NIU + 0x0003c)
505#define NETXEN_NIU_INT_MASK (NETXEN_CRB_NIU + 0x00040)
506#define NETXEN_NIU_ACTIVE_INT (NETXEN_CRB_NIU + 0x00044)
507#define NETXEN_NIU_MASKABLE_INT (NETXEN_CRB_NIU + 0x00048)
508
509#define NETXEN_NIU_STRAP_VALUE_SAVE_HIGHER (NETXEN_CRB_NIU + 0x0004c)
510
511#define NETXEN_NIU_GB_SERDES_RESET (NETXEN_CRB_NIU + 0x00050)
512#define NETXEN_NIU_GB0_GMII_MODE (NETXEN_CRB_NIU + 0x00054)
513#define NETXEN_NIU_GB0_MII_MODE (NETXEN_CRB_NIU + 0x00058)
514#define NETXEN_NIU_GB1_GMII_MODE (NETXEN_CRB_NIU + 0x0005c)
515#define NETXEN_NIU_GB1_MII_MODE (NETXEN_CRB_NIU + 0x00060)
516#define NETXEN_NIU_GB2_GMII_MODE (NETXEN_CRB_NIU + 0x00064)
517#define NETXEN_NIU_GB2_MII_MODE (NETXEN_CRB_NIU + 0x00068)
518#define NETXEN_NIU_GB3_GMII_MODE (NETXEN_CRB_NIU + 0x0006c)
519#define NETXEN_NIU_GB3_MII_MODE (NETXEN_CRB_NIU + 0x00070)
520#define NETXEN_NIU_REMOTE_LOOPBACK (NETXEN_CRB_NIU + 0x00074)
521#define NETXEN_NIU_GB0_HALF_DUPLEX (NETXEN_CRB_NIU + 0x00078)
522#define NETXEN_NIU_GB1_HALF_DUPLEX (NETXEN_CRB_NIU + 0x0007c)
523#define NETXEN_NIU_RESET_SYS_FIFOS (NETXEN_CRB_NIU + 0x00088)
524#define NETXEN_NIU_GB_CRC_DROP (NETXEN_CRB_NIU + 0x0008c)
525#define NETXEN_NIU_GB_DROP_WRONGADDR (NETXEN_CRB_NIU + 0x00090)
526#define NETXEN_NIU_TEST_MUX_CTL (NETXEN_CRB_NIU + 0x00094)
527#define NETXEN_NIU_XG_PAUSE_CTL (NETXEN_CRB_NIU + 0x00098)
528#define NETXEN_NIU_XG_PAUSE_LEVEL (NETXEN_CRB_NIU + 0x000dc)
529#define NETXEN_NIU_XG_SEL (NETXEN_CRB_NIU + 0x00128)
530
531#define NETXEN_NIU_FULL_LEVEL_XG (NETXEN_CRB_NIU + 0x00450)
532
533#define NETXEN_NIU_XG1_RESET (NETXEN_CRB_NIU + 0x0011c)
534#define NETXEN_NIU_XG1_POWER_DOWN (NETXEN_CRB_NIU + 0x00120)
535#define NETXEN_NIU_XG1_RESET_PLL (NETXEN_CRB_NIU + 0x00124)
536
537#define NETXEN_MAC_ADDR_CNTL_REG (NETXEN_CRB_NIU + 0x1000)
538
539#define NETXEN_MULTICAST_ADDR_HI_0 (NETXEN_CRB_NIU + 0x1010)
540#define NETXEN_MULTICAST_ADDR_HI_1 (NETXEN_CRB_NIU + 0x1014)
541#define NETXEN_MULTICAST_ADDR_HI_2 (NETXEN_CRB_NIU + 0x1018)
542#define NETXEN_MULTICAST_ADDR_HI_3 (NETXEN_CRB_NIU + 0x101c)
543
544#define NETXEN_NIU_GB_MAC_CONFIG_0(I) \
545 (NETXEN_CRB_NIU + 0x30000 + (I)*0x10000)
546#define NETXEN_NIU_GB_MAC_CONFIG_1(I) \
547 (NETXEN_CRB_NIU + 0x30004 + (I)*0x10000)
548#define NETXEN_NIU_GB_MAC_IPG_IFG(I) \
549 (NETXEN_CRB_NIU + 0x30008 + (I)*0x10000)
550#define NETXEN_NIU_GB_HALF_DUPLEX_CTRL(I) \
551 (NETXEN_CRB_NIU + 0x3000c + (I)*0x10000)
552#define NETXEN_NIU_GB_MAX_FRAME_SIZE(I) \
553 (NETXEN_CRB_NIU + 0x30010 + (I)*0x10000)
554#define NETXEN_NIU_GB_TEST_REG(I) \
555 (NETXEN_CRB_NIU + 0x3001c + (I)*0x10000)
556#define NETXEN_NIU_GB_MII_MGMT_CONFIG(I) \
557 (NETXEN_CRB_NIU + 0x30020 + (I)*0x10000)
558#define NETXEN_NIU_GB_MII_MGMT_COMMAND(I) \
559 (NETXEN_CRB_NIU + 0x30024 + (I)*0x10000)
560#define NETXEN_NIU_GB_MII_MGMT_ADDR(I) \
561 (NETXEN_CRB_NIU + 0x30028 + (I)*0x10000)
562#define NETXEN_NIU_GB_MII_MGMT_CTRL(I) \
563 (NETXEN_CRB_NIU + 0x3002c + (I)*0x10000)
564#define NETXEN_NIU_GB_MII_MGMT_STATUS(I) \
565 (NETXEN_CRB_NIU + 0x30030 + (I)*0x10000)
566#define NETXEN_NIU_GB_MII_MGMT_INDICATE(I) \
567 (NETXEN_CRB_NIU + 0x30034 + (I)*0x10000)
568#define NETXEN_NIU_GB_INTERFACE_CTRL(I) \
569 (NETXEN_CRB_NIU + 0x30038 + (I)*0x10000)
570#define NETXEN_NIU_GB_INTERFACE_STATUS(I) \
571 (NETXEN_CRB_NIU + 0x3003c + (I)*0x10000)
572#define NETXEN_NIU_GB_STATION_ADDR_0(I) \
573 (NETXEN_CRB_NIU + 0x30040 + (I)*0x10000)
574#define NETXEN_NIU_GB_STATION_ADDR_1(I) \
575 (NETXEN_CRB_NIU + 0x30044 + (I)*0x10000)
576
577#define NETXEN_NIU_XGE_CONFIG_0 (NETXEN_CRB_NIU + 0x70000)
578#define NETXEN_NIU_XGE_CONFIG_1 (NETXEN_CRB_NIU + 0x70004)
579#define NETXEN_NIU_XGE_IPG (NETXEN_CRB_NIU + 0x70008)
580#define NETXEN_NIU_XGE_STATION_ADDR_0_HI (NETXEN_CRB_NIU + 0x7000c)
581#define NETXEN_NIU_XGE_STATION_ADDR_0_1 (NETXEN_CRB_NIU + 0x70010)
582#define NETXEN_NIU_XGE_STATION_ADDR_1_LO (NETXEN_CRB_NIU + 0x70014)
583#define NETXEN_NIU_XGE_STATUS (NETXEN_CRB_NIU + 0x70018)
584#define NETXEN_NIU_XGE_MAX_FRAME_SIZE (NETXEN_CRB_NIU + 0x7001c)
585#define NETXEN_NIU_XGE_PAUSE_FRAME_VALUE (NETXEN_CRB_NIU + 0x70020)
586#define NETXEN_NIU_XGE_TX_BYTE_CNT (NETXEN_CRB_NIU + 0x70024)
587#define NETXEN_NIU_XGE_TX_FRAME_CNT (NETXEN_CRB_NIU + 0x70028)
588#define NETXEN_NIU_XGE_RX_BYTE_CNT (NETXEN_CRB_NIU + 0x7002c)
589#define NETXEN_NIU_XGE_RX_FRAME_CNT (NETXEN_CRB_NIU + 0x70030)
590#define NETXEN_NIU_XGE_AGGR_ERROR_CNT (NETXEN_CRB_NIU + 0x70034)
591#define NETXEN_NIU_XGE_MULTICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x70038)
592#define NETXEN_NIU_XGE_UNICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x7003c)
593#define NETXEN_NIU_XGE_CRC_ERROR_CNT (NETXEN_CRB_NIU + 0x70040)
594#define NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x70044)
595#define NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x70048)
596#define NETXEN_NIU_XGE_LOCAL_ERROR_CNT (NETXEN_CRB_NIU + 0x7004c)
597#define NETXEN_NIU_XGE_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x70050)
598#define NETXEN_NIU_XGE_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x70054)
599#define NETXEN_NIU_XGE_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x70058)
600#define NETXEN_NIU_XG1_CONFIG_0 (NETXEN_CRB_NIU + 0x80000)
601#define NETXEN_NIU_XG1_CONFIG_1 (NETXEN_CRB_NIU + 0x80004)
602#define NETXEN_NIU_XG1_IPG (NETXEN_CRB_NIU + 0x80008)
603#define NETXEN_NIU_XG1_STATION_ADDR_0_HI (NETXEN_CRB_NIU + 0x8000c)
604#define NETXEN_NIU_XG1_STATION_ADDR_0_1 (NETXEN_CRB_NIU + 0x80010)
605#define NETXEN_NIU_XG1_STATION_ADDR_1_LO (NETXEN_CRB_NIU + 0x80014)
606#define NETXEN_NIU_XG1_STATUS (NETXEN_CRB_NIU + 0x80018)
607#define NETXEN_NIU_XG1_MAX_FRAME_SIZE (NETXEN_CRB_NIU + 0x8001c)
608#define NETXEN_NIU_XG1_PAUSE_FRAME_VALUE (NETXEN_CRB_NIU + 0x80020)
609#define NETXEN_NIU_XG1_TX_BYTE_CNT (NETXEN_CRB_NIU + 0x80024)
610#define NETXEN_NIU_XG1_TX_FRAME_CNT (NETXEN_CRB_NIU + 0x80028)
611#define NETXEN_NIU_XG1_RX_BYTE_CNT (NETXEN_CRB_NIU + 0x8002c)
612#define NETXEN_NIU_XG1_RX_FRAME_CNT (NETXEN_CRB_NIU + 0x80030)
613#define NETXEN_NIU_XG1_AGGR_ERROR_CNT (NETXEN_CRB_NIU + 0x80034)
614#define NETXEN_NIU_XG1_MULTICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x80038)
615#define NETXEN_NIU_XG1_UNICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x8003c)
616#define NETXEN_NIU_XG1_CRC_ERROR_CNT (NETXEN_CRB_NIU + 0x80040)
617#define NETXEN_NIU_XG1_OVERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x80044)
618#define NETXEN_NIU_XG1_UNDERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x80048)
619#define NETXEN_NIU_XG1_LOCAL_ERROR_CNT (NETXEN_CRB_NIU + 0x8004c)
620#define NETXEN_NIU_XG1_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x80050)
621#define NETXEN_NIU_XG1_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x80054)
622#define NETXEN_NIU_XG1_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x80058)
623
624/* XG Link status */
625#define XG_LINK_UP 0x10
626#define XG_LINK_DOWN 0x20
627
628#define NETXEN_CAM_RAM_BASE (NETXEN_CRB_CAM + 0x02000)
629#define NETXEN_CAM_RAM(reg) (NETXEN_CAM_RAM_BASE + (reg))
630#define NETXEN_FW_VERSION_MAJOR (NETXEN_CAM_RAM(0x150))
631#define NETXEN_FW_VERSION_MINOR (NETXEN_CAM_RAM(0x154))
632#define NETXEN_FW_VERSION_SUB (NETXEN_CAM_RAM(0x158))
633#define NETXEN_ROM_LOCK_ID (NETXEN_CAM_RAM(0x100))
634
635#define NETXEN_PHY_LOCK_ID (NETXEN_CAM_RAM(0x120))
636
637/* Lock IDs for PHY lock */
638#define PHY_LOCK_DRIVER 0x44524956
639
640/* Used for PS PCI Memory access */
641#define PCIX_PS_OP_ADDR_LO (0x10000)
642/* via CRB (PS side only) */
643#define PCIX_PS_OP_ADDR_HI (0x10004)
644
645#define PCIX_INT_VECTOR (0x10100)
646#define PCIX_INT_MASK (0x10104)
647
648#define PCIX_MN_WINDOW (0x10200)
649#define PCIX_MS_WINDOW (0x10204)
650#define PCIX_SN_WINDOW (0x10208)
651#define PCIX_CRB_WINDOW (0x10210)
652
653#define PCIX_TARGET_STATUS (0x10118)
654#define PCIX_TARGET_MASK (0x10128)
655
656#define PCIX_MSI_F0 (0x13000)
657
658#define PCIX_PS_MEM_SPACE (0x90000)
659
660#define NETXEN_PCIX_PH_REG(reg) (NETXEN_CRB_PCIE + (reg))
661#define NETXEN_PCIX_PS_REG(reg) (NETXEN_CRB_PCIX_MD + (reg))
662
663#define NETXEN_PCIE_REG(reg) (NETXEN_CRB_PCIE + (reg))
664
665#define PCIE_MAX_DMA_XFER_SIZE (0x1404c)
666
667#define PCIE_DCR 0x00d8
668
669#define PCIE_SEM2_LOCK (0x1c010) /* Flash lock */
670#define PCIE_SEM2_UNLOCK (0x1c014) /* Flash unlock */
671#define PCIE_SEM3_LOCK (0x1c018) /* Phy lock */
672#define PCIE_SEM3_UNLOCK (0x1c01c) /* Phy unlock */
673
674#define PCIE_TGT_SPLIT_CHICKEN (0x12080)
675
676#define PCIE_MAX_MASTER_SPLIT (0x14048)
677
678#endif /* __NETXEN_NIC_HDR_H_ */
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
new file mode 100644
index 000000000000..105c24f0ad4c
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -0,0 +1,1010 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Source file for NIC routines to access the Phantom hardware
31 *
32 */
33
34#include "netxen_nic.h"
35#include "netxen_nic_hw.h"
36#include "netxen_nic_phan_reg.h"
37
38/* PCI Windowing for DDR regions. */
39
40#define ADDR_IN_RANGE(addr, low, high) \
41 (((addr) <= (high)) && ((addr) >= (low)))
42
43#define NETXEN_FLASH_BASE (BOOTLD_START)
44#define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE)
45#define NETXEN_MAX_MTU 8000
46#define NETXEN_MIN_MTU 64
47#define NETXEN_ETH_FCS_SIZE 4
48#define NETXEN_ENET_HEADER_SIZE 14
49#define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */
50#define NETXEN_FIRMWARE_LEN ((16 * 1024) / 4)
51#define NETXEN_NIU_HDRSIZE (0x1 << 6)
52#define NETXEN_NIU_TLRSIZE (0x1 << 5)
53
54#define lower32(x) ((u32)((x) & 0xffffffff))
55#define upper32(x) \
56 ((u32)(((unsigned long long)(x) >> 32) & 0xffffffff))
57
58#define NETXEN_NIC_ZERO_PAUSE_ADDR 0ULL
59#define NETXEN_NIC_UNIT_PAUSE_ADDR 0x200ULL
60#define NETXEN_NIC_EPG_PAUSE_ADDR1 0x2200010000c28001ULL
61#define NETXEN_NIC_EPG_PAUSE_ADDR2 0x0100088866554433ULL
62
63#define NETXEN_NIC_WINDOW_MARGIN 0x100000
64
65unsigned long netxen_nic_pci_set_window(struct netxen_adapter *adapter,
66 unsigned long long addr);
67void netxen_free_hw_resources(struct netxen_adapter *adapter);
68
69int netxen_nic_set_mac(struct net_device *netdev, void *p)
70{
71 struct netxen_port *port = netdev_priv(netdev);
72 struct netxen_adapter *adapter = port->adapter;
73 struct sockaddr *addr = p;
74
75 if (netif_running(netdev))
76 return -EBUSY;
77
78 if (!is_valid_ether_addr(addr->sa_data))
79 return -EADDRNOTAVAIL;
80
81 DPRINTK(INFO, "valid ether addr\n");
82 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
83
84 if (adapter->ops->macaddr_set)
85 adapter->ops->macaddr_set(port, addr->sa_data);
86
87 return 0;
88}
89
90/*
91 * netxen_nic_set_multi - Multicast
92 */
93void netxen_nic_set_multi(struct net_device *netdev)
94{
95 struct netxen_port *port = netdev_priv(netdev);
96 struct netxen_adapter *adapter = port->adapter;
97 struct dev_mc_list *mc_ptr;
98 __le32 netxen_mac_addr_cntl_data = 0;
99
100 mc_ptr = netdev->mc_list;
101 if (netdev->flags & IFF_PROMISC) {
102 if (adapter->ops->set_promisc)
103 adapter->ops->set_promisc(adapter,
104 port->portnum,
105 NETXEN_NIU_PROMISC_MODE);
106 } else {
107 if (adapter->ops->unset_promisc &&
108 adapter->ahw.boardcfg.board_type
109 != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ)
110 adapter->ops->unset_promisc(adapter,
111 port->portnum,
112 NETXEN_NIU_NON_PROMISC_MODE);
113 }
114 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
115 netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03);
116 netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00);
117 netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x00);
118 netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cntl_data, 0x00);
119 netxen_nic_mcr_set_id_pool3(netxen_mac_addr_cntl_data, 0x00);
120 netxen_nic_mcr_set_enable_xtnd0(netxen_mac_addr_cntl_data);
121 netxen_nic_mcr_set_enable_xtnd1(netxen_mac_addr_cntl_data);
122 netxen_nic_mcr_set_enable_xtnd2(netxen_mac_addr_cntl_data);
123 netxen_nic_mcr_set_enable_xtnd3(netxen_mac_addr_cntl_data);
124 } else {
125 netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x00);
126 netxen_nic_mcr_set_id_pool0(netxen_mac_addr_cntl_data, 0x00);
127 netxen_nic_mcr_set_id_pool1(netxen_mac_addr_cntl_data, 0x01);
128 netxen_nic_mcr_set_id_pool2(netxen_mac_addr_cntl_data, 0x02);
129 netxen_nic_mcr_set_id_pool3(netxen_mac_addr_cntl_data, 0x03);
130 }
131 writel(netxen_mac_addr_cntl_data,
132 NETXEN_CRB_NORMALIZE(adapter, NETXEN_MAC_ADDR_CNTL_REG));
133 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
134 writel(netxen_mac_addr_cntl_data,
135 NETXEN_CRB_NORMALIZE(adapter,
136 NETXEN_MULTICAST_ADDR_HI_0));
137 } else {
138 writel(netxen_mac_addr_cntl_data,
139 NETXEN_CRB_NORMALIZE(adapter,
140 NETXEN_MULTICAST_ADDR_HI_1));
141 }
142 netxen_mac_addr_cntl_data = 0;
143 writel(netxen_mac_addr_cntl_data,
144 NETXEN_CRB_NORMALIZE(adapter, NETXEN_NIU_GB_DROP_WRONGADDR));
145}
146
147/*
148 * netxen_nic_change_mtu - Change the Maximum Transfer Unit
149 * @returns 0 on success, negative on failure
150 */
151int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
152{
153 struct netxen_port *port = netdev_priv(netdev);
154 struct netxen_adapter *adapter = port->adapter;
155 int eff_mtu = mtu + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE;
156
157 if ((eff_mtu > NETXEN_MAX_MTU) || (eff_mtu < NETXEN_MIN_MTU)) {
158 printk(KERN_ERR "%s: %s %d is not supported.\n",
159 netxen_nic_driver_name, netdev->name, mtu);
160 return -EINVAL;
161 }
162
163 if (adapter->ops->set_mtu)
164 adapter->ops->set_mtu(port, mtu);
165 netdev->mtu = mtu;
166
167 return 0;
168}
169
170/*
171 * check if the firmware has been downloaded and ready to run and
172 * setup the address for the descriptors in the adapter
173 */
174int netxen_nic_hw_resources(struct netxen_adapter *adapter)
175{
176 struct netxen_hardware_context *hw = &adapter->ahw;
177 u32 state = 0;
178 void *addr;
179 void *pause_addr;
180 int loops = 0, err = 0;
181 int ctx, ring;
182 u32 card_cmdring = 0;
183 struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
184 struct netxen_recv_context *recv_ctx;
185 struct netxen_rcv_desc_ctx *rcv_desc;
186
187 DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE,
188 PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE));
189 DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM,
190 pci_base_offset(adapter, NETXEN_CRB_CAM));
191 DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE,
192 pci_base_offset(adapter, NETXEN_CAM_RAM_BASE));
193 DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1,
194 pci_base_offset(adapter, NIC_CRB_BASE_PORT1));
195
196 /* Window 1 call */
197 card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING));
198
199 DPRINTK(INFO, "Command Peg sends 0x%x for cmdring base\n",
200 card_cmdring);
201
202 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
203 DPRINTK(INFO, "Command Peg ready..waiting for rcv peg\n");
204 loops = 0;
205 state = 0;
206 /* Window 1 call */
207 state = readl(NETXEN_CRB_NORMALIZE(adapter,
208 recv_crb_registers[ctx].
209 crb_rcvpeg_state));
210 while (state != PHAN_PEG_RCV_INITIALIZED && loops < 20) {
211 udelay(100);
212 /* Window 1 call */
213 state = readl(NETXEN_CRB_NORMALIZE(adapter,
214 recv_crb_registers
215 [ctx].
216 crb_rcvpeg_state));
217 loops++;
218 }
219 if (loops >= 20) {
220 printk(KERN_ERR "Rcv Peg initialization not complete:"
221 "%x.\n", state);
222 err = -EIO;
223 return err;
224 }
225 }
226 DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n");
227
228 addr = netxen_alloc(adapter->ahw.pdev,
229 sizeof(struct cmd_desc_type0) *
230 adapter->max_tx_desc_count,
231 &hw->cmd_desc_phys_addr, &hw->cmd_desc_pdev);
232
233 if (addr == NULL) {
234 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
235 return -ENOMEM;
236 }
237
238 pause_addr = netxen_alloc(adapter->ahw.pdev, 512,
239 (dma_addr_t *) & hw->pause_physaddr,
240 &hw->pause_pdev);
241 if (pause_addr == NULL) {
242 DPRINTK(1, ERR, "bad return from pci_alloc_consistent\n");
243 return -ENOMEM;
244 }
245
246 hw->pauseaddr = (char *)pause_addr;
247 {
248 u64 *ptr = (u64 *) pause_addr;
249 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
250 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
251 *ptr++ = NETXEN_NIC_UNIT_PAUSE_ADDR;
252 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
253 *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR1;
254 *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR2;
255 }
256
257 hw->cmd_desc_head = (struct cmd_desc_type0 *)addr;
258
259 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
260 recv_ctx = &adapter->recv_ctx[ctx];
261
262 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
263 rcv_desc = &recv_ctx->rcv_desc[ring];
264 addr = netxen_alloc(adapter->ahw.pdev,
265 RCV_DESC_RINGSIZE,
266 &rcv_desc->phys_addr,
267 &rcv_desc->phys_pdev);
268 if (addr == NULL) {
269 DPRINTK(ERR, "bad return from "
270 "pci_alloc_consistent\n");
271 netxen_free_hw_resources(adapter);
272 err = -ENOMEM;
273 return err;
274 }
275 rcv_desc->desc_head = (struct rcv_desc *)addr;
276 }
277
278 addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE,
279 &recv_ctx->rcv_status_desc_phys_addr,
280 &recv_ctx->rcv_status_desc_pdev);
281 if (addr == NULL) {
282 DPRINTK(ERR, "bad return from"
283 " pci_alloc_consistent\n");
284 netxen_free_hw_resources(adapter);
285 err = -ENOMEM;
286 return err;
287 }
288 recv_ctx->rcv_status_desc_head = (struct status_desc *)addr;
289 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
290 rcv_desc = &recv_ctx->rcv_desc[ring];
291 rcv_desc_crb =
292 &recv_crb_registers[ctx].rcv_desc_crb[ring];
293 DPRINTK(INFO, "ring #%d crb global ring reg 0x%x\n",
294 ring, rcv_desc_crb->crb_globalrcv_ring);
295 /* Window = 1 */
296 writel(lower32(rcv_desc->phys_addr),
297 NETXEN_CRB_NORMALIZE(adapter,
298 rcv_desc_crb->
299 crb_globalrcv_ring));
300 DPRINTK(INFO, "GLOBAL_RCV_RING ctx %d, addr 0x%x"
301 " val 0x%llx,"
302 " virt %p\n", ctx,
303 rcv_desc_crb->crb_globalrcv_ring,
304 (unsigned long long)rcv_desc->phys_addr,
305 +rcv_desc->desc_head);
306 }
307
308 /* Window = 1 */
309 writel(lower32(recv_ctx->rcv_status_desc_phys_addr),
310 NETXEN_CRB_NORMALIZE(adapter,
311 recv_crb_registers[ctx].
312 crb_rcvstatus_ring));
313 DPRINTK(INFO, "RCVSTATUS_RING, ctx %d, addr 0x%x,"
314 " val 0x%x,virt%p\n",
315 ctx,
316 recv_crb_registers[ctx].crb_rcvstatus_ring,
317 (unsigned long long)recv_ctx->rcv_status_desc_phys_addr,
318 recv_ctx->rcv_status_desc_head);
319 }
320 /* Window = 1 */
321 writel(lower32(hw->pause_physaddr),
322 NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_LO));
323 writel(upper32(hw->pause_physaddr),
324 NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_HI));
325
326 writel(lower32(hw->cmd_desc_phys_addr),
327 NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
328 writel(upper32(hw->cmd_desc_phys_addr),
329 NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_HI));
330 return err;
331}
332
333void netxen_free_hw_resources(struct netxen_adapter *adapter)
334{
335 struct netxen_recv_context *recv_ctx;
336 struct netxen_rcv_desc_ctx *rcv_desc;
337 int ctx, ring;
338
339 if (adapter->ahw.cmd_desc_head != NULL) {
340 pci_free_consistent(adapter->ahw.cmd_desc_pdev,
341 sizeof(struct cmd_desc_type0) *
342 adapter->max_tx_desc_count,
343 adapter->ahw.cmd_desc_head,
344 adapter->ahw.cmd_desc_phys_addr);
345 adapter->ahw.cmd_desc_head = NULL;
346 }
347 if (adapter->ahw.pauseaddr != NULL) {
348 pci_free_consistent(adapter->ahw.pause_pdev, 512,
349 adapter->ahw.pauseaddr,
350 adapter->ahw.pause_physaddr);
351 adapter->ahw.pauseaddr = NULL;
352 }
353
354 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
355 recv_ctx = &adapter->recv_ctx[ctx];
356 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
357 rcv_desc = &recv_ctx->rcv_desc[ring];
358
359 if (rcv_desc->desc_head != NULL) {
360 pci_free_consistent(rcv_desc->phys_pdev,
361 RCV_DESC_RINGSIZE,
362 rcv_desc->desc_head,
363 rcv_desc->phys_addr);
364 rcv_desc->desc_head = NULL;
365 }
366 }
367
368 if (recv_ctx->rcv_status_desc_head != NULL) {
369 pci_free_consistent(recv_ctx->rcv_status_desc_pdev,
370 STATUS_DESC_RINGSIZE,
371 recv_ctx->rcv_status_desc_head,
372 recv_ctx->
373 rcv_status_desc_phys_addr);
374 recv_ctx->rcv_status_desc_head = NULL;
375 }
376 }
377}
378
379void netxen_tso_check(struct netxen_adapter *adapter,
380 struct cmd_desc_type0 *desc, struct sk_buff *skb)
381{
382 if (desc->mss) {
383 desc->total_hdr_length = sizeof(struct ethhdr) +
384 ((skb->nh.iph)->ihl * sizeof(u32)) +
385 ((skb->h.th)->doff * sizeof(u32));
386 desc->opcode = TX_TCP_LSO;
387 } else if (skb->ip_summed == CHECKSUM_COMPLETE) {
388 if (skb->nh.iph->protocol == IPPROTO_TCP) {
389 desc->opcode = TX_TCP_PKT;
390 } else if (skb->nh.iph->protocol == IPPROTO_UDP) {
391 desc->opcode = TX_UDP_PKT;
392 } else {
393 return;
394 }
395 }
396 adapter->stats.xmitcsummed++;
397 CMD_DESC_TCP_HDR_OFFSET_WRT(desc, skb->h.raw - skb->data);
398 desc->length_tcp_hdr = cpu_to_le32(desc->length_tcp_hdr);
399 desc->ip_hdr_offset = skb->nh.raw - skb->data;
400}
401
402int netxen_is_flash_supported(struct netxen_adapter *adapter)
403{
404 const int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 };
405 int addr, val01, val02, i, j;
406
407 /* if the flash size less than 4Mb, make huge war cry and die */
408 for (j = 1; j < 4; j++) {
409 addr = j * NETXEN_NIC_WINDOW_MARGIN;
410 for (i = 0; i < (sizeof(locs) / sizeof(locs[0])); i++) {
411 if (netxen_rom_fast_read(adapter, locs[i], &val01) == 0
412 && netxen_rom_fast_read(adapter, (addr + locs[i]),
413 &val02) == 0) {
414 if (val01 == val02)
415 return -1;
416 } else
417 return -1;
418 }
419 }
420
421 return 0;
422}
423
424static int netxen_get_flash_block(struct netxen_adapter *adapter, int base,
425 int size, u32 * buf)
426{
427 int i, addr;
428 u32 *ptr32;
429
430 addr = base;
431 ptr32 = buf;
432 for (i = 0; i < size / sizeof(u32); i++) {
433 if (netxen_rom_fast_read(adapter, addr, ptr32) == -1)
434 return -1;
435 ptr32++;
436 addr += sizeof(u32);
437 }
438 if ((char *)buf + size > (char *)ptr32) {
439 u32 local;
440
441 if (netxen_rom_fast_read(adapter, addr, &local) == -1)
442 return -1;
443 memcpy(ptr32, &local, (char *)buf + size - (char *)ptr32);
444 }
445
446 return 0;
447}
448
449int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[])
450{
451 u32 *pmac = (u32 *) & mac[0];
452
453 if (netxen_get_flash_block(adapter,
454 USER_START +
455 offsetof(struct netxen_new_user_info,
456 mac_addr),
457 FLASH_NUM_PORTS * sizeof(u64), pmac) == -1) {
458 return -1;
459 }
460 if (*mac == ~0ULL) {
461 if (netxen_get_flash_block(adapter,
462 USER_START_OLD +
463 offsetof(struct netxen_user_old_info,
464 mac_addr),
465 FLASH_NUM_PORTS * sizeof(u64),
466 pmac) == -1)
467 return -1;
468 if (*mac == ~0ULL)
469 return -1;
470 }
471 return 0;
472}
473
474/*
475 * Changes the CRB window to the specified window.
476 */
477void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw)
478{
479 void __iomem *offset;
480 u32 tmp;
481 int count = 0;
482
483 if (adapter->curr_window == wndw)
484 return;
485
486 /*
487 * Move the CRB window.
488 * We need to write to the "direct access" region of PCI
489 * to avoid a race condition where the window register has
490 * not been successfully written across CRB before the target
491 * register address is received by PCI. The direct region bypasses
492 * the CRB bus.
493 */
494 offset =
495 PCI_OFFSET_SECOND_RANGE(adapter,
496 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW));
497
498 if (wndw & 0x1)
499 wndw = NETXEN_WINDOW_ONE;
500
501 writel(wndw, offset);
502
503 /* MUST make sure window is set before we forge on... */
504 while ((tmp = readl(offset)) != wndw) {
505 printk(KERN_WARNING "%s: %s WARNING: CRB window value not "
506 "registered properly: 0x%08x.\n",
507 netxen_nic_driver_name, __FUNCTION__, tmp);
508 mdelay(1);
509 if (count >= 10)
510 break;
511 count++;
512 }
513
514 adapter->curr_window = wndw;
515}
516
517void netxen_load_firmware(struct netxen_adapter *adapter)
518{
519 int i;
520 long data, size = 0;
521 long flashaddr = NETXEN_FLASH_BASE, memaddr = NETXEN_PHANTOM_MEM_BASE;
522 u64 off;
523 void __iomem *addr;
524
525 size = NETXEN_FIRMWARE_LEN;
526 writel(1, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
527
528 for (i = 0; i < size; i++) {
529 if (netxen_rom_fast_read(adapter, flashaddr, (int *)&data) != 0) {
530 DPRINTK(ERR,
531 "Error in netxen_rom_fast_read(). Will skip"
532 "loading flash image\n");
533 return;
534 }
535 off = netxen_nic_pci_set_window(adapter, memaddr);
536 addr = pci_base_offset(adapter, off);
537 writel(data, addr);
538 flashaddr += 4;
539 memaddr += 4;
540 }
541 udelay(100);
542 /* make sure Casper is powered on */
543 writel(0x3fff,
544 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CHIP_CLK_CTRL));
545 writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_CAS_RST));
546
547 udelay(100);
548}
549
550int
551netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
552 int len)
553{
554 void __iomem *addr;
555
556 if (ADDR_IN_WINDOW1(off)) {
557 addr = NETXEN_CRB_NORMALIZE(adapter, off);
558 } else { /* Window 0 */
559 addr = pci_base_offset(adapter, off);
560 netxen_nic_pci_change_crbwindow(adapter, 0);
561 }
562
563 DPRINTK(INFO, "writing to base %lx offset %llx addr %p"
564 " data %llx len %d\n",
565 pci_base(adapter, off), off, addr,
566 *(unsigned long long *)data, len);
567 if (!addr) {
568 netxen_nic_pci_change_crbwindow(adapter, 1);
569 return 1;
570 }
571
572 switch (len) {
573 case 1:
574 writeb(*(u8 *) data, addr);
575 break;
576 case 2:
577 writew(*(u16 *) data, addr);
578 break;
579 case 4:
580 writel(*(u32 *) data, addr);
581 break;
582 case 8:
583 writeq(*(u64 *) data, addr);
584 break;
585 default:
586 DPRINTK(INFO,
587 "writing data %lx to offset %llx, num words=%d\n",
588 *(unsigned long *)data, off, (len >> 3));
589
590 netxen_nic_hw_block_write64((u64 __iomem *) data, addr,
591 (len >> 3));
592 break;
593 }
594 if (!ADDR_IN_WINDOW1(off))
595 netxen_nic_pci_change_crbwindow(adapter, 1);
596
597 return 0;
598}
599
600int
601netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
602 int len)
603{
604 void __iomem *addr;
605
606 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
607 addr = NETXEN_CRB_NORMALIZE(adapter, off);
608 } else { /* Window 0 */
609 addr = pci_base_offset(adapter, off);
610 netxen_nic_pci_change_crbwindow(adapter, 0);
611 }
612
613 DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n",
614 pci_base(adapter, off), off, addr);
615 if (!addr) {
616 netxen_nic_pci_change_crbwindow(adapter, 1);
617 return 1;
618 }
619 switch (len) {
620 case 1:
621 *(u8 *) data = readb(addr);
622 break;
623 case 2:
624 *(u16 *) data = readw(addr);
625 break;
626 case 4:
627 *(u32 *) data = readl(addr);
628 break;
629 case 8:
630 *(u64 *) data = readq(addr);
631 break;
632 default:
633 netxen_nic_hw_block_read64((u64 __iomem *) data, addr,
634 (len >> 3));
635 break;
636 }
637 DPRINTK(INFO, "read %lx\n", *(unsigned long *)data);
638
639 if (!ADDR_IN_WINDOW1(off))
640 netxen_nic_pci_change_crbwindow(adapter, 1);
641
642 return 0;
643}
644
645void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val)
646{ /* Only for window 1 */
647 void __iomem *addr;
648
649 addr = NETXEN_CRB_NORMALIZE(adapter, off);
650 DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n",
651 pci_base(adapter, off), off, addr);
652 writel(val, addr);
653
654}
655
656int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off)
657{ /* Only for window 1 */
658 void __iomem *addr;
659 int val;
660
661 addr = NETXEN_CRB_NORMALIZE(adapter, off);
662 DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n",
663 adapter->ahw.pci_base, off, addr);
664 val = readl(addr);
665 writel(val, addr);
666
667 return val;
668}
669
670/* Change the window to 0, write and change back to window 1. */
671void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value)
672{
673 void __iomem *addr;
674
675 netxen_nic_pci_change_crbwindow(adapter, 0);
676 addr = pci_base_offset(adapter, index);
677 writel(value, addr);
678 netxen_nic_pci_change_crbwindow(adapter, 1);
679}
680
681/* Change the window to 0, read and change back to window 1. */
682void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 * value)
683{
684 void __iomem *addr;
685
686 addr = pci_base_offset(adapter, index);
687
688 netxen_nic_pci_change_crbwindow(adapter, 0);
689 *value = readl(addr);
690 netxen_nic_pci_change_crbwindow(adapter, 1);
691}
692
693int netxen_pci_set_window_warning_count = 0;
694
695unsigned long
696netxen_nic_pci_set_window(struct netxen_adapter *adapter,
697 unsigned long long addr)
698{
699 static int ddr_mn_window = -1;
700 static int qdr_sn_window = -1;
701 int window;
702
703 if (ADDR_IN_RANGE(addr, NETXEN_ADDR_DDR_NET, NETXEN_ADDR_DDR_NET_MAX)) {
704 /* DDR network side */
705 addr -= NETXEN_ADDR_DDR_NET;
706 window = (addr >> 25) & 0x3ff;
707 if (ddr_mn_window != window) {
708 ddr_mn_window = window;
709 writel(window, PCI_OFFSET_SECOND_RANGE(adapter,
710 NETXEN_PCIX_PH_REG
711 (PCIX_MN_WINDOW)));
712 /* MUST make sure window is set before we forge on... */
713 readl(PCI_OFFSET_SECOND_RANGE(adapter,
714 NETXEN_PCIX_PH_REG
715 (PCIX_MN_WINDOW)));
716 }
717 addr -= (window * NETXEN_WINDOW_ONE);
718 addr += NETXEN_PCI_DDR_NET;
719 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) {
720 addr -= NETXEN_ADDR_OCM0;
721 addr += NETXEN_PCI_OCM0;
722 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM1, NETXEN_ADDR_OCM1_MAX)) {
723 addr -= NETXEN_ADDR_OCM1;
724 addr += NETXEN_PCI_OCM1;
725 } else
726 if (ADDR_IN_RANGE
727 (addr, NETXEN_ADDR_QDR_NET, NETXEN_ADDR_QDR_NET_MAX)) {
728 /* QDR network side */
729 addr -= NETXEN_ADDR_QDR_NET;
730 window = (addr >> 22) & 0x3f;
731 if (qdr_sn_window != window) {
732 qdr_sn_window = window;
733 writel((window << 22),
734 PCI_OFFSET_SECOND_RANGE(adapter,
735 NETXEN_PCIX_PH_REG
736 (PCIX_SN_WINDOW)));
737 /* MUST make sure window is set before we forge on... */
738 readl(PCI_OFFSET_SECOND_RANGE(adapter,
739 NETXEN_PCIX_PH_REG
740 (PCIX_SN_WINDOW)));
741 }
742 addr -= (window * 0x400000);
743 addr += NETXEN_PCI_QDR_NET;
744 } else {
745 /*
746 * peg gdb frequently accesses memory that doesn't exist,
747 * this limits the chit chat so debugging isn't slowed down.
748 */
749 if ((netxen_pci_set_window_warning_count++ < 8)
750 || (netxen_pci_set_window_warning_count % 64 == 0))
751 printk("%s: Warning:netxen_nic_pci_set_window()"
752 " Unknown address range!\n",
753 netxen_nic_driver_name);
754
755 }
756 return addr;
757}
758
759int netxen_nic_get_board_info(struct netxen_adapter *adapter)
760{
761 int rv = 0;
762 int addr = BRDCFG_START;
763 struct netxen_board_info *boardinfo;
764 int index;
765 u32 *ptr32;
766
767 boardinfo = &adapter->ahw.boardcfg;
768 ptr32 = (u32 *) boardinfo;
769
770 for (index = 0; index < sizeof(struct netxen_board_info) / sizeof(u32);
771 index++) {
772 if (netxen_rom_fast_read(adapter, addr, ptr32) == -1) {
773 return -EIO;
774 }
775 ptr32++;
776 addr += sizeof(u32);
777 }
778 if (boardinfo->magic != NETXEN_BDINFO_MAGIC) {
779 printk("%s: ERROR reading %s board config."
780 " Read %x, expected %x\n", netxen_nic_driver_name,
781 netxen_nic_driver_name,
782 boardinfo->magic, NETXEN_BDINFO_MAGIC);
783 rv = -1;
784 }
785 if (boardinfo->header_version != NETXEN_BDINFO_VERSION) {
786 printk("%s: Unknown board config version."
787 " Read %x, expected %x\n", netxen_nic_driver_name,
788 boardinfo->header_version, NETXEN_BDINFO_VERSION);
789 rv = -1;
790 }
791
792 DPRINTK(INFO, "Discovered board type:0x%x ", boardinfo->board_type);
793 switch ((netxen_brdtype_t) boardinfo->board_type) {
794 case NETXEN_BRDTYPE_P2_SB35_4G:
795 adapter->ahw.board_type = NETXEN_NIC_GBE;
796 break;
797 case NETXEN_BRDTYPE_P2_SB31_10G:
798 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
799 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
800 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
801 adapter->ahw.board_type = NETXEN_NIC_XGBE;
802 break;
803 case NETXEN_BRDTYPE_P1_BD:
804 case NETXEN_BRDTYPE_P1_SB:
805 case NETXEN_BRDTYPE_P1_SMAX:
806 case NETXEN_BRDTYPE_P1_SOCK:
807 adapter->ahw.board_type = NETXEN_NIC_GBE;
808 break;
809 default:
810 printk("%s: Unknown(%x)\n", netxen_nic_driver_name,
811 boardinfo->board_type);
812 break;
813 }
814
815 return rv;
816}
817
818/* NIU access sections */
819
820int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu)
821{
822 struct netxen_adapter *adapter = port->adapter;
823 netxen_nic_write_w0(adapter,
824 NETXEN_NIU_GB_MAX_FRAME_SIZE(port->portnum),
825 new_mtu);
826 return 0;
827}
828
829int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu)
830{
831 struct netxen_adapter *adapter = port->adapter;
832 new_mtu += NETXEN_NIU_HDRSIZE + NETXEN_NIU_TLRSIZE;
833 netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu);
834 return 0;
835}
836
837void netxen_nic_init_niu_gb(struct netxen_adapter *adapter)
838{
839 int portno;
840 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++)
841 netxen_niu_gbe_init_port(adapter, portno);
842}
843
844void netxen_nic_stop_all_ports(struct netxen_adapter *adapter)
845{
846 int port_nr;
847 struct netxen_port *port;
848
849 for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) {
850 port = adapter->port[port_nr];
851 if (adapter->ops->stop_port)
852 adapter->ops->stop_port(adapter, port->portnum);
853 }
854}
855
856void
857netxen_crb_writelit_adapter(struct netxen_adapter *adapter, unsigned long off,
858 int data)
859{
860 void __iomem *addr;
861
862 if (ADDR_IN_WINDOW1(off)) {
863 writel(data, NETXEN_CRB_NORMALIZE(adapter, off));
864 } else {
865 netxen_nic_pci_change_crbwindow(adapter, 0);
866 addr = pci_base_offset(adapter, off);
867 writel(data, addr);
868 netxen_nic_pci_change_crbwindow(adapter, 1);
869 }
870}
871
872void netxen_nic_set_link_parameters(struct netxen_port *port)
873{
874 struct netxen_adapter *adapter = port->adapter;
875 __le32 status;
876 u16 autoneg;
877 __le32 mode;
878
879 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode);
880 if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */
881 if (adapter->ops->phy_read
882 && adapter->ops->
883 phy_read(adapter, port->portnum,
884 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
885 &status) == 0) {
886 if (netxen_get_phy_link(status)) {
887 switch (netxen_get_phy_speed(status)) {
888 case 0:
889 port->link_speed = SPEED_10;
890 break;
891 case 1:
892 port->link_speed = SPEED_100;
893 break;
894 case 2:
895 port->link_speed = SPEED_1000;
896 break;
897 default:
898 port->link_speed = -1;
899 break;
900 }
901 switch (netxen_get_phy_duplex(status)) {
902 case 0:
903 port->link_duplex = DUPLEX_HALF;
904 break;
905 case 1:
906 port->link_duplex = DUPLEX_FULL;
907 break;
908 default:
909 port->link_duplex = -1;
910 break;
911 }
912 if (adapter->ops->phy_read
913 && adapter->ops->
914 phy_read(adapter, port->portnum,
915 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
916 (__le32 *) & autoneg) != 0)
917 port->link_autoneg = autoneg;
918 } else
919 goto link_down;
920 } else {
921 link_down:
922 port->link_speed = -1;
923 port->link_duplex = -1;
924 }
925 }
926}
927
928void netxen_nic_flash_print(struct netxen_adapter *adapter)
929{
930 int valid = 1;
931 u32 fw_major = 0;
932 u32 fw_minor = 0;
933 u32 fw_build = 0;
934 char brd_name[NETXEN_MAX_SHORT_NAME];
935 struct netxen_new_user_info user_info;
936 int i, addr = USER_START;
937 u32 *ptr32;
938
939 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg);
940 if (board_info->magic != NETXEN_BDINFO_MAGIC) {
941 printk
942 ("NetXen Unknown board config, Read 0x%x expected as 0x%x\n",
943 board_info->magic, NETXEN_BDINFO_MAGIC);
944 valid = 0;
945 }
946 if (board_info->header_version != NETXEN_BDINFO_VERSION) {
947 printk("NetXen Unknown board config version."
948 " Read %x, expected %x\n",
949 board_info->header_version, NETXEN_BDINFO_VERSION);
950 valid = 0;
951 }
952 if (valid) {
953 ptr32 = (u32 *) & user_info;
954 for (i = 0;
955 i < sizeof(struct netxen_new_user_info) / sizeof(u32);
956 i++) {
957 if (netxen_rom_fast_read(adapter, addr, ptr32) == -1) {
958 printk("%s: ERROR reading %s board userarea.\n",
959 netxen_nic_driver_name,
960 netxen_nic_driver_name);
961 return;
962 }
963 ptr32++;
964 addr += sizeof(u32);
965 }
966 get_brd_name_by_type(board_info->board_type, brd_name);
967
968 printk("NetXen %s Board S/N %s Chip id 0x%x\n",
969 brd_name, user_info.serial_num, board_info->chip_id);
970
971 printk("NetXen %s Board #%d, Chip id 0x%x\n",
972 board_info->board_type == 0x0b ? "XGB" : "GBE",
973 board_info->board_num, board_info->chip_id);
974 fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
975 NETXEN_FW_VERSION_MAJOR));
976 fw_minor = readl(NETXEN_CRB_NORMALIZE(adapter,
977 NETXEN_FW_VERSION_MINOR));
978 fw_build =
979 readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
980
981 printk("NetXen Firmware version %d.%d.%d\n", fw_major, fw_minor,
982 fw_build);
983 }
984 if (fw_major != _NETXEN_NIC_LINUX_MAJOR) {
985 printk(KERN_ERR "The mismatch in driver version and firmware "
986 "version major number\n"
987 "Driver version major number = %d \t"
988 "Firmware version major number = %d \n",
989 _NETXEN_NIC_LINUX_MAJOR, fw_major);
990 adapter->driver_mismatch = 1;
991 }
992 if (fw_minor != _NETXEN_NIC_LINUX_MINOR) {
993 printk(KERN_ERR "The mismatch in driver version and firmware "
994 "version minor number\n"
995 "Driver version minor number = %d \t"
996 "Firmware version minor number = %d \n",
997 _NETXEN_NIC_LINUX_MINOR, fw_minor);
998 adapter->driver_mismatch = 1;
999 }
1000 if (adapter->driver_mismatch)
1001 printk(KERN_INFO "Use the driver with version no %d.%d.xxx\n",
1002 fw_major, fw_minor);
1003}
1004
1005int netxen_crb_read_val(struct netxen_adapter *adapter, unsigned long off)
1006{
1007 int data;
1008 netxen_nic_hw_read_wx(adapter, off, &data, 4);
1009 return data;
1010}
diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h
new file mode 100644
index 000000000000..201a636b7ab8
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_hw.h
@@ -0,0 +1,482 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Structures, enums, and macros for the MAC
31 *
32 */
33
34#ifndef __NETXEN_NIC_HW_H_
35#define __NETXEN_NIC_HW_H_
36
37#include "netxen_nic_hdr.h"
38
39/* Hardware memory size of 128 meg */
40#define NETXEN_MEMADDR_MAX (128 * 1024 * 1024)
41
42#ifndef readq
43static inline u64 readq(void __iomem * addr)
44{
45 return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
46}
47#endif
48
49#ifndef writeq
50static inline void writeq(u64 val, void __iomem * addr)
51{
52 writel(((u32) (val)), (addr));
53 writel(((u32) (val >> 32)), (addr + 4));
54}
55#endif
56
57static inline void netxen_nic_hw_block_write64(u64 __iomem * data_ptr,
58 u64 __iomem * addr,
59 int num_words)
60{
61 int num;
62 for (num = 0; num < num_words; num++) {
63 writeq(readq((void __iomem *)data_ptr), addr);
64 addr++;
65 data_ptr++;
66 }
67}
68
69static inline void netxen_nic_hw_block_read64(u64 __iomem * data_ptr,
70 u64 __iomem * addr, int num_words)
71{
72 int num;
73 for (num = 0; num < num_words; num++) {
74 writeq(readq((void __iomem *)addr), data_ptr);
75 addr++;
76 data_ptr++;
77 }
78
79}
80
81struct netxen_adapter;
82
83#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
84
85#define NETXEN_NIC_LOCKED_READ_REG(X, Y) \
86 addr = pci_base_offset(adapter, (X)); \
87 *(u32 *)Y = readl(addr);
88
89struct netxen_port;
90void netxen_nic_set_link_parameters(struct netxen_port *port);
91void netxen_nic_flash_print(struct netxen_adapter *adapter);
92int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off,
93 void *data, int len);
94void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
95 unsigned long off, int data);
96int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off,
97 void *data, int len);
98
99typedef u8 netxen_ethernet_macaddr_t[6];
100
101/* Nibble or Byte mode for phy interface (GbE mode only) */
102typedef enum {
103 NETXEN_NIU_10_100_MB = 0,
104 NETXEN_NIU_1000_MB
105} netxen_niu_gbe_ifmode_t;
106
107#define _netxen_crb_get_bit(var, bit) ((var >> bit) & 0x1)
108
109/*
110 * NIU GB MAC Config Register 0 (applies to GB0, GB1, GB2, GB3)
111 *
112 * Bit 0 : enable_tx => 1:enable frame xmit, 0:disable
113 * Bit 1 : tx_synced => R/O: xmit enable synched to xmit stream
114 * Bit 2 : enable_rx => 1:enable frame recv, 0:disable
115 * Bit 3 : rx_synced => R/O: recv enable synched to recv stream
116 * Bit 4 : tx_flowctl => 1:enable pause frame generation, 0:disable
117 * Bit 5 : rx_flowctl => 1:act on recv'd pause frames, 0:ignore
118 * Bit 8 : loopback => 1:loop MAC xmits to MAC recvs, 0:normal
119 * Bit 16: tx_reset_pb => 1:reset frame xmit protocol blk, 0:no-op
120 * Bit 17: rx_reset_pb => 1:reset frame recv protocol blk, 0:no-op
121 * Bit 18: tx_reset_mac => 1:reset data/ctl multiplexer blk, 0:no-op
122 * Bit 19: rx_reset_mac => 1:reset ctl frames & timers blk, 0:no-op
123 * Bit 31: soft_reset => 1:reset the MAC and the SERDES, 0:no-op
124 */
125
126#define netxen_gb_enable_tx(config_word) \
127 set_bit(0, (unsigned long*)(&config_word))
128#define netxen_gb_enable_rx(config_word) \
129 set_bit(2, (unsigned long*)(&config_word))
130#define netxen_gb_tx_flowctl(config_word) \
131 set_bit(4, (unsigned long*)(&config_word))
132#define netxen_gb_rx_flowctl(config_word) \
133 set_bit(5, (unsigned long*)(&config_word))
134#define netxen_gb_tx_reset_pb(config_word) \
135 set_bit(16, (unsigned long*)(&config_word))
136#define netxen_gb_rx_reset_pb(config_word) \
137 set_bit(17, (unsigned long*)(&config_word))
138#define netxen_gb_tx_reset_mac(config_word) \
139 set_bit(18, (unsigned long*)(&config_word))
140#define netxen_gb_rx_reset_mac(config_word) \
141 set_bit(19, (unsigned long*)(&config_word))
142#define netxen_gb_soft_reset(config_word) \
143 set_bit(31, (unsigned long*)(&config_word))
144
145#define netxen_gb_unset_tx_flowctl(config_word) \
146 clear_bit(4, (unsigned long *)(&config_word))
147#define netxen_gb_unset_rx_flowctl(config_word) \
148 clear_bit(5, (unsigned long*)(&config_word))
149
150#define netxen_gb_get_tx_synced(config_word) \
151 _netxen_crb_get_bit((config_word), 1)
152#define netxen_gb_get_rx_synced(config_word) \
153 _netxen_crb_get_bit((config_word), 3)
154#define netxen_gb_get_tx_flowctl(config_word) \
155 _netxen_crb_get_bit((config_word), 4)
156#define netxen_gb_get_rx_flowctl(config_word) \
157 _netxen_crb_get_bit((config_word), 5)
158#define netxen_gb_get_soft_reset(config_word) \
159 _netxen_crb_get_bit((config_word), 31)
160
161/*
162 * NIU GB MAC Config Register 1 (applies to GB0, GB1, GB2, GB3)
163 *
164 * Bit 0 : duplex => 1:full duplex mode, 0:half duplex
165 * Bit 1 : crc_enable => 1:append CRC to xmit frames, 0:dont append
166 * Bit 2 : padshort => 1:pad short frames and add CRC, 0:dont pad
167 * Bit 4 : checklength => 1:check framelen with actual,0:dont check
168 * Bit 5 : hugeframes => 1:allow oversize xmit frames, 0:dont allow
169 * Bits 8-9 : intfmode => 01:nibble (10/100), 10:byte (1000)
170 * Bits 12-15 : preamblelen => preamble field length in bytes, default 7
171 */
172
173#define netxen_gb_set_duplex(config_word) \
174 set_bit(0, (unsigned long*)&config_word)
175#define netxen_gb_set_crc_enable(config_word) \
176 set_bit(1, (unsigned long*)&config_word)
177#define netxen_gb_set_padshort(config_word) \
178 set_bit(2, (unsigned long*)&config_word)
179#define netxen_gb_set_checklength(config_word) \
180 set_bit(4, (unsigned long*)&config_word)
181#define netxen_gb_set_hugeframes(config_word) \
182 set_bit(5, (unsigned long*)&config_word)
183#define netxen_gb_set_preamblelen(config_word, val) \
184 ((config_word) |= ((val) << 12) & 0xF000)
185#define netxen_gb_set_intfmode(config_word, val) \
186 ((config_word) |= ((val) << 8) & 0x300)
187
188#define netxen_gb_get_stationaddress_low(config_word) ((config_word) >> 16)
189
190#define netxen_gb_set_mii_mgmt_clockselect(config_word, val) \
191 ((config_word) |= ((val) & 0x07))
192#define netxen_gb_mii_mgmt_reset(config_word) \
193 set_bit(31, (unsigned long*)&config_word)
194#define netxen_gb_mii_mgmt_unset(config_word) \
195 clear_bit(31, (unsigned long*)&config_word)
196
197/*
198 * NIU GB MII Mgmt Command Register (applies to GB0, GB1, GB2, GB3)
199 * Bit 0 : read_cycle => 1:perform single read cycle, 0:no-op
200 * Bit 1 : scan_cycle => 1:perform continuous read cycles, 0:no-op
201 */
202
203#define netxen_gb_mii_mgmt_set_read_cycle(config_word) \
204 set_bit(0, (unsigned long*)&config_word)
205#define netxen_gb_mii_mgmt_reg_addr(config_word, val) \
206 ((config_word) |= ((val) & 0x1F))
207#define netxen_gb_mii_mgmt_phy_addr(config_word, val) \
208 ((config_word) |= (((val) & 0x1F) << 8))
209
210/*
211 * NIU GB MII Mgmt Indicators Register (applies to GB0, GB1, GB2, GB3)
212 * Read-only register.
213 * Bit 0 : busy => 1:performing an MII mgmt cycle, 0:idle
214 * Bit 1 : scanning => 1:scan operation in progress, 0:idle
215 * Bit 2 : notvalid => :mgmt result data not yet valid, 0:idle
216 */
217#define netxen_get_gb_mii_mgmt_busy(config_word) \
218 _netxen_crb_get_bit(config_word, 0)
219#define netxen_get_gb_mii_mgmt_scanning(config_word) \
220 _netxen_crb_get_bit(config_word, 1)
221#define netxen_get_gb_mii_mgmt_notvalid(config_word) \
222 _netxen_crb_get_bit(config_word, 2)
223
224/*
225 * PHY-Specific MII control/status registers.
226 */
227typedef enum {
228 NETXEN_NIU_GB_MII_MGMT_ADDR_CONTROL = 0,
229 NETXEN_NIU_GB_MII_MGMT_ADDR_STATUS = 1,
230 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_0 = 2,
231 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_ID_1 = 3,
232 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG = 4,
233 NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART = 5,
234 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG_MORE = 6,
235 NETXEN_NIU_GB_MII_MGMT_ADDR_NEXTPAGE_XMIT = 7,
236 NETXEN_NIU_GB_MII_MGMT_ADDR_LNKPART_NEXTPAGE = 8,
237 NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_CONTROL = 9,
238 NETXEN_NIU_GB_MII_MGMT_ADDR_1000BT_STATUS = 10,
239 NETXEN_NIU_GB_MII_MGMT_ADDR_EXTENDED_STATUS = 15,
240 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL = 16,
241 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS = 17,
242 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE = 18,
243 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS = 19,
244 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE = 20,
245 NETXEN_NIU_GB_MII_MGMT_ADDR_RECV_ERROR_COUNT = 21,
246 NETXEN_NIU_GB_MII_MGMT_ADDR_LED_CONTROL = 24,
247 NETXEN_NIU_GB_MII_MGMT_ADDR_LED_OVERRIDE = 25,
248 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_CONTROL_MORE_YET = 26,
249 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS_MORE = 27
250} netxen_niu_phy_register_t;
251
252/*
253 * PHY-Specific Status Register (reg 17).
254 *
255 * Bit 0 : jabber => 1:jabber detected, 0:not
256 * Bit 1 : polarity => 1:polarity reversed, 0:normal
257 * Bit 2 : recvpause => 1:receive pause enabled, 0:disabled
258 * Bit 3 : xmitpause => 1:transmit pause enabled, 0:disabled
259 * Bit 4 : energydetect => 1:sleep, 0:active
260 * Bit 5 : downshift => 1:downshift, 0:no downshift
261 * Bit 6 : crossover => 1:MDIX (crossover), 0:MDI (no crossover)
262 * Bits 7-9 : cablelen => not valid in 10Mb/s mode
263 * 0:<50m, 1:50-80m, 2:80-110m, 3:110-140m, 4:>140m
264 * Bit 10 : link => 1:link up, 0:link down
265 * Bit 11 : resolved => 1:speed and duplex resolved, 0:not yet
266 * Bit 12 : pagercvd => 1:page received, 0:page not received
267 * Bit 13 : duplex => 1:full duplex, 0:half duplex
268 * Bits 14-15 : speed => 0:10Mb/s, 1:100Mb/s, 2:1000Mb/s, 3:rsvd
269 */
270
271#define netxen_get_phy_cablelen(config_word) (((config_word) >> 7) & 0x07)
272#define netxen_get_phy_speed(config_word) (((config_word) >> 14) & 0x03)
273
274#define netxen_set_phy_speed(config_word, val) \
275 ((config_word) |= ((val & 0x03) << 14))
276#define netxen_set_phy_duplex(config_word) \
277 set_bit(13, (unsigned long*)&config_word)
278#define netxen_clear_phy_duplex(config_word) \
279 clear_bit(13, (unsigned long*)&config_word)
280
281#define netxen_get_phy_jabber(config_word) \
282 _netxen_crb_get_bit(config_word, 0)
283#define netxen_get_phy_polarity(config_word) \
284 _netxen_crb_get_bit(config_word, 1)
285#define netxen_get_phy_recvpause(config_word) \
286 _netxen_crb_get_bit(config_word, 2)
287#define netxen_get_phy_xmitpause(config_word) \
288 _netxen_crb_get_bit(config_word, 3)
289#define netxen_get_phy_energydetect(config_word) \
290 _netxen_crb_get_bit(config_word, 4)
291#define netxen_get_phy_downshift(config_word) \
292 _netxen_crb_get_bit(config_word, 5)
293#define netxen_get_phy_crossover(config_word) \
294 _netxen_crb_get_bit(config_word, 6)
295#define netxen_get_phy_link(config_word) \
296 _netxen_crb_get_bit(config_word, 10)
297#define netxen_get_phy_resolved(config_word) \
298 _netxen_crb_get_bit(config_word, 11)
299#define netxen_get_phy_pagercvd(config_word) \
300 _netxen_crb_get_bit(config_word, 12)
301#define netxen_get_phy_duplex(config_word) \
302 _netxen_crb_get_bit(config_word, 13)
303
304/*
305 * Interrupt Register definition
306 * This definition applies to registers 18 and 19 (int enable and int status).
307 * Bit 0 : jabber
308 * Bit 1 : polarity_changed
309 * Bit 4 : energy_detect
310 * Bit 5 : downshift
311 * Bit 6 : mdi_xover_changed
312 * Bit 7 : fifo_over_underflow
313 * Bit 8 : false_carrier
314 * Bit 9 : symbol_error
315 * Bit 10: link_status_changed
316 * Bit 11: autoneg_completed
317 * Bit 12: page_received
318 * Bit 13: duplex_changed
319 * Bit 14: speed_changed
320 * Bit 15: autoneg_error
321 */
322
323#define netxen_get_phy_int_jabber(config_word) \
324 _netxen_crb_get_bit(config_word, 0)
325#define netxen_get_phy_int_polarity_changed(config_word) \
326 _netxen_crb_get_bit(config_word, 1)
327#define netxen_get_phy_int_energy_detect(config_word) \
328 _netxen_crb_get_bit(config_word, 4)
329#define netxen_get_phy_int_downshift(config_word) \
330 _netxen_crb_get_bit(config_word, 5)
331#define netxen_get_phy_int_mdi_xover_changed(config_word) \
332 _netxen_crb_get_bit(config_word, 6)
333#define netxen_get_phy_int_fifo_over_underflow(config_word) \
334 _netxen_crb_get_bit(config_word, 7)
335#define netxen_get_phy_int_false_carrier(config_word) \
336 _netxen_crb_get_bit(config_word, 8)
337#define netxen_get_phy_int_symbol_error(config_word) \
338 _netxen_crb_get_bit(config_word, 9)
339#define netxen_get_phy_int_link_status_changed(config_word) \
340 _netxen_crb_get_bit(config_word, 10)
341#define netxen_get_phy_int_autoneg_completed(config_word) \
342 _netxen_crb_get_bit(config_word, 11)
343#define netxen_get_phy_int_page_received(config_word) \
344 _netxen_crb_get_bit(config_word, 12)
345#define netxen_get_phy_int_duplex_changed(config_word) \
346 _netxen_crb_get_bit(config_word, 13)
347#define netxen_get_phy_int_speed_changed(config_word) \
348 _netxen_crb_get_bit(config_word, 14)
349#define netxen_get_phy_int_autoneg_error(config_word) \
350 _netxen_crb_get_bit(config_word, 15)
351
352#define netxen_set_phy_int_link_status_changed(config_word) \
353 set_bit(10, (unsigned long*)&config_word)
354#define netxen_set_phy_int_autoneg_completed(config_word) \
355 set_bit(11, (unsigned long*)&config_word)
356#define netxen_set_phy_int_speed_changed(config_word) \
357 set_bit(14, (unsigned long*)&config_word)
358
359/*
360 * NIU Mode Register.
361 * Bit 0 : enable FibreChannel
362 * Bit 1 : enable 10/100/1000 Ethernet
363 * Bit 2 : enable 10Gb Ethernet
364 */
365
366#define netxen_get_niu_enable_ge(config_word) \
367 _netxen_crb_get_bit(config_word, 1)
368
369/* Promiscous mode options (GbE mode only) */
370typedef enum {
371 NETXEN_NIU_PROMISC_MODE = 0,
372 NETXEN_NIU_NON_PROMISC_MODE
373} netxen_niu_prom_mode_t;
374
375/*
376 * NIU GB Drop CRC Register
377 *
378 * Bit 0 : drop_gb0 => 1:drop pkts with bad CRCs, 0:pass them on
379 * Bit 1 : drop_gb1 => 1:drop pkts with bad CRCs, 0:pass them on
380 * Bit 2 : drop_gb2 => 1:drop pkts with bad CRCs, 0:pass them on
381 * Bit 3 : drop_gb3 => 1:drop pkts with bad CRCs, 0:pass them on
382 */
383
384#define netxen_set_gb_drop_gb0(config_word) \
385 set_bit(0, (unsigned long*)&config_word)
386#define netxen_set_gb_drop_gb1(config_word) \
387 set_bit(1, (unsigned long*)&config_word)
388#define netxen_set_gb_drop_gb2(config_word) \
389 set_bit(2, (unsigned long*)&config_word)
390#define netxen_set_gb_drop_gb3(config_word) \
391 set_bit(3, (unsigned long*)&config_word)
392
393#define netxen_clear_gb_drop_gb0(config_word) \
394 clear_bit(0, (unsigned long*)&config_word)
395#define netxen_clear_gb_drop_gb1(config_word) \
396 clear_bit(1, (unsigned long*)&config_word)
397#define netxen_clear_gb_drop_gb2(config_word) \
398 clear_bit(2, (unsigned long*)&config_word)
399#define netxen_clear_gb_drop_gb3(config_word) \
400 clear_bit(3, (unsigned long*)&config_word)
401
402/*
403 * NIU XG MAC Config Register
404 *
405 * Bit 0 : tx_enable => 1:enable frame xmit, 0:disable
406 * Bit 2 : rx_enable => 1:enable frame recv, 0:disable
407 * Bit 4 : soft_reset => 1:reset the MAC , 0:no-op
408 * Bit 27: xaui_framer_reset
409 * Bit 28: xaui_rx_reset
410 * Bit 29: xaui_tx_reset
411 * Bit 30: xg_ingress_afifo_reset
412 * Bit 31: xg_egress_afifo_reset
413 */
414
415#define netxen_xg_soft_reset(config_word) \
416 set_bit(4, (unsigned long*)&config_word)
417
418/*
419 * MAC Control Register
420 *
421 * Bit 0-1 : id_pool0
422 * Bit 2 : enable_xtnd0
423 * Bit 4-5 : id_pool1
424 * Bit 6 : enable_xtnd1
425 * Bit 8-9 : id_pool2
426 * Bit 10 : enable_xtnd2
427 * Bit 12-13 : id_pool3
428 * Bit 14 : enable_xtnd3
429 * Bit 24-25 : mode_select
430 * Bit 28-31 : enable_pool
431 */
432
433#define netxen_nic_mcr_set_id_pool0(config, val) \
434 ((config) |= ((val) &0x03))
435#define netxen_nic_mcr_set_enable_xtnd0(config) \
436 (set_bit(3, (unsigned long *)&(config)))
437#define netxen_nic_mcr_set_id_pool1(config, val) \
438 ((config) |= (((val) & 0x03) << 4))
439#define netxen_nic_mcr_set_enable_xtnd1(config) \
440 (set_bit(6, (unsigned long *)&(config)))
441#define netxen_nic_mcr_set_id_pool2(config, val) \
442 ((config) |= (((val) & 0x03) << 8))
443#define netxen_nic_mcr_set_enable_xtnd2(config) \
444 (set_bit(10, (unsigned long *)&(config)))
445#define netxen_nic_mcr_set_id_pool3(config, val) \
446 ((config) |= (((val) & 0x03) << 12))
447#define netxen_nic_mcr_set_enable_xtnd3(config) \
448 (set_bit(14, (unsigned long *)&(config)))
449#define netxen_nic_mcr_set_mode_select(config, val) \
450 ((config) |= (((val) & 0x03) << 24))
451#define netxen_nic_mcr_set_enable_pool(config, val) \
452 ((config) |= (((val) & 0x0f) << 28))
453
454/* Set promiscuous mode for a GbE interface */
455int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port,
456 netxen_niu_prom_mode_t mode);
457int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
458 int port, netxen_niu_prom_mode_t mode);
459
460/* get/set the MAC address for a given MAC */
461int netxen_niu_macaddr_get(struct netxen_adapter *adapter, int port,
462 netxen_ethernet_macaddr_t * addr);
463int netxen_niu_macaddr_set(struct netxen_port *port,
464 netxen_ethernet_macaddr_t addr);
465
466/* XG versons */
467int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int port,
468 netxen_ethernet_macaddr_t * addr);
469int netxen_niu_xg_macaddr_set(struct netxen_port *port,
470 netxen_ethernet_macaddr_t addr);
471
472/* Generic enable for GbE ports. Will detect the speed of the link. */
473int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port);
474
475int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port);
476
477/* Disable a GbE interface */
478int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port);
479
480int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port);
481
482#endif /* __NETXEN_NIC_HW_H_ */
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
new file mode 100644
index 000000000000..0dca029bc3e5
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -0,0 +1,1304 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Source file for NIC routines to initialize the Phantom Hardware
31 *
32 */
33
34#include <linux/netdevice.h>
35#include <linux/delay.h>
36#include "netxen_nic.h"
37#include "netxen_nic_hw.h"
38#include "netxen_nic_ioctl.h"
39#include "netxen_nic_phan_reg.h"
40
41struct crb_addr_pair {
42 long addr;
43 long data;
44};
45
46#define NETXEN_MAX_CRB_XFORM 60
47static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
48#define NETXEN_ADDR_ERROR ((unsigned long ) 0xffffffff )
49
50#define crb_addr_transform(name) \
51 crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \
52 NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20
53
54#define NETXEN_NIC_XDMA_RESET 0x8000ff
55
56static inline void
57netxen_nic_locked_write_reg(struct netxen_adapter *adapter,
58 unsigned long off, int *data)
59{
60 void __iomem *addr = pci_base_offset(adapter, off);
61 writel(*data, addr);
62}
63
64static void crb_addr_transform_setup(void)
65{
66 crb_addr_transform(XDMA);
67 crb_addr_transform(TIMR);
68 crb_addr_transform(SRE);
69 crb_addr_transform(SQN3);
70 crb_addr_transform(SQN2);
71 crb_addr_transform(SQN1);
72 crb_addr_transform(SQN0);
73 crb_addr_transform(SQS3);
74 crb_addr_transform(SQS2);
75 crb_addr_transform(SQS1);
76 crb_addr_transform(SQS0);
77 crb_addr_transform(RPMX7);
78 crb_addr_transform(RPMX6);
79 crb_addr_transform(RPMX5);
80 crb_addr_transform(RPMX4);
81 crb_addr_transform(RPMX3);
82 crb_addr_transform(RPMX2);
83 crb_addr_transform(RPMX1);
84 crb_addr_transform(RPMX0);
85 crb_addr_transform(ROMUSB);
86 crb_addr_transform(SN);
87 crb_addr_transform(QMN);
88 crb_addr_transform(QMS);
89 crb_addr_transform(PGNI);
90 crb_addr_transform(PGND);
91 crb_addr_transform(PGN3);
92 crb_addr_transform(PGN2);
93 crb_addr_transform(PGN1);
94 crb_addr_transform(PGN0);
95 crb_addr_transform(PGSI);
96 crb_addr_transform(PGSD);
97 crb_addr_transform(PGS3);
98 crb_addr_transform(PGS2);
99 crb_addr_transform(PGS1);
100 crb_addr_transform(PGS0);
101 crb_addr_transform(PS);
102 crb_addr_transform(PH);
103 crb_addr_transform(NIU);
104 crb_addr_transform(I2Q);
105 crb_addr_transform(EG);
106 crb_addr_transform(MN);
107 crb_addr_transform(MS);
108 crb_addr_transform(CAS2);
109 crb_addr_transform(CAS1);
110 crb_addr_transform(CAS0);
111 crb_addr_transform(CAM);
112 crb_addr_transform(C2C1);
113 crb_addr_transform(C2C0);
114}
115
116int netxen_init_firmware(struct netxen_adapter *adapter)
117{
118 u32 state = 0, loops = 0, err = 0;
119
120 /* Window 1 call */
121 state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
122
123 if (state == PHAN_INITIALIZE_ACK)
124 return 0;
125
126 while (state != PHAN_INITIALIZE_COMPLETE && loops < 2000) {
127 udelay(100);
128 /* Window 1 call */
129 state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
130
131 loops++;
132 }
133 if (loops >= 2000) {
134 printk(KERN_ERR "Cmd Peg initialization not complete:%x.\n",
135 state);
136 err = -EIO;
137 return err;
138 }
139 /* Window 1 call */
140 writel(PHAN_INITIALIZE_ACK,
141 NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
142
143 return err;
144}
145
146#define NETXEN_ADDR_LIMIT 0xffffffffULL
147
148void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
149 struct pci_dev **used_dev)
150{
151 void *addr;
152
153 addr = pci_alloc_consistent(pdev, sz, ptr);
154 if ((unsigned long long)(*ptr) < NETXEN_ADDR_LIMIT) {
155 *used_dev = pdev;
156 return addr;
157 }
158 pci_free_consistent(pdev, sz, addr, *ptr);
159 addr = pci_alloc_consistent(NULL, sz, ptr);
160 *used_dev = NULL;
161 return addr;
162}
163
164void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
165{
166 int ctxid, ring;
167 u32 i;
168 u32 num_rx_bufs = 0;
169 struct netxen_rcv_desc_ctx *rcv_desc;
170
171 DPRINTK(INFO, "initializing some queues: %p\n", adapter);
172 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
173 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
174 struct netxen_rx_buffer *rx_buf;
175 rcv_desc = &adapter->recv_ctx[ctxid].rcv_desc[ring];
176 rcv_desc->rcv_free = rcv_desc->max_rx_desc_count;
177 rcv_desc->begin_alloc = 0;
178 rx_buf = rcv_desc->rx_buf_arr;
179 num_rx_bufs = rcv_desc->max_rx_desc_count;
180 /*
181 * Now go through all of them, set reference handles
182 * and put them in the queues.
183 */
184 for (i = 0; i < num_rx_bufs; i++) {
185 rx_buf->ref_handle = i;
186 rx_buf->state = NETXEN_BUFFER_FREE;
187
188 DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:"
189 "%p\n", ctxid, i, rx_buf);
190 rx_buf++;
191 }
192 }
193 }
194 DPRINTK(INFO, "initialized buffers for %s and %s\n",
195 "adapter->free_cmd_buf_list", "adapter->free_rxbuf");
196}
197
198void netxen_initialize_adapter_hw(struct netxen_adapter *adapter)
199{
200 int ports = 0;
201 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg);
202
203 if (netxen_nic_get_board_info(adapter) != 0)
204 printk("%s: Error getting board config info.\n",
205 netxen_nic_driver_name);
206 get_brd_port_by_type(board_info->board_type, &ports);
207 if (ports == 0)
208 printk(KERN_ERR "%s: Unknown board type\n",
209 netxen_nic_driver_name);
210 adapter->ahw.max_ports = ports;
211}
212
213void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
214{
215 struct netxen_drvops *ops = adapter->ops;
216 switch (adapter->ahw.board_type) {
217 case NETXEN_NIC_GBE:
218 ops->enable_phy_interrupts =
219 netxen_niu_gbe_enable_phy_interrupts;
220 ops->disable_phy_interrupts =
221 netxen_niu_gbe_disable_phy_interrupts;
222 ops->handle_phy_intr = netxen_nic_gbe_handle_phy_intr;
223 ops->macaddr_set = netxen_niu_macaddr_set;
224 ops->set_mtu = netxen_nic_set_mtu_gb;
225 ops->set_promisc = netxen_niu_set_promiscuous_mode;
226 ops->unset_promisc = netxen_niu_set_promiscuous_mode;
227 ops->phy_read = netxen_niu_gbe_phy_read;
228 ops->phy_write = netxen_niu_gbe_phy_write;
229 ops->init_port = netxen_niu_gbe_init_port;
230 ops->init_niu = netxen_nic_init_niu_gb;
231 ops->stop_port = netxen_niu_disable_gbe_port;
232 break;
233
234 case NETXEN_NIC_XGBE:
235 ops->enable_phy_interrupts =
236 netxen_niu_xgbe_enable_phy_interrupts;
237 ops->disable_phy_interrupts =
238 netxen_niu_xgbe_disable_phy_interrupts;
239 ops->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr;
240 ops->macaddr_set = netxen_niu_xg_macaddr_set;
241 ops->set_mtu = netxen_nic_set_mtu_xgb;
242 ops->init_port = netxen_niu_xg_init_port;
243 ops->set_promisc = netxen_niu_xg_set_promiscuous_mode;
244 ops->unset_promisc = netxen_niu_xg_set_promiscuous_mode;
245 ops->stop_port = netxen_niu_disable_xg_port;
246 break;
247
248 default:
249 break;
250 }
251}
252
253/*
254 * netxen_decode_crb_addr(0 - utility to translate from internal Phantom CRB
255 * address to external PCI CRB address.
256 */
257unsigned long netxen_decode_crb_addr(unsigned long addr)
258{
259 int i;
260 unsigned long base_addr, offset, pci_base;
261
262 crb_addr_transform_setup();
263
264 pci_base = NETXEN_ADDR_ERROR;
265 base_addr = addr & 0xfff00000;
266 offset = addr & 0x000fffff;
267
268 for (i = 0; i < NETXEN_MAX_CRB_XFORM; i++) {
269 if (crb_addr_xform[i] == base_addr) {
270 pci_base = i << 20;
271 break;
272 }
273 }
274 if (pci_base == NETXEN_ADDR_ERROR)
275 return pci_base;
276 else
277 return (pci_base + offset);
278}
279
280static long rom_max_timeout = 10000;
281static long rom_lock_timeout = 1000000;
282
283static inline int rom_lock(struct netxen_adapter *adapter)
284{
285 int iter;
286 u32 done = 0;
287 int timeout = 0;
288
289 while (!done) {
290 /* acquire semaphore2 from PCI HW block */
291 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_LOCK),
292 &done);
293 if (done == 1)
294 break;
295 if (timeout >= rom_lock_timeout)
296 return -EIO;
297
298 timeout++;
299 /*
300 * Yield CPU
301 */
302 if (!in_atomic())
303 schedule();
304 else {
305 for (iter = 0; iter < 20; iter++)
306 cpu_relax(); /*This a nop instr on i386 */
307 }
308 }
309 netxen_nic_reg_write(adapter, NETXEN_ROM_LOCK_ID, ROM_LOCK_DRIVER);
310 return 0;
311}
312
313int netxen_wait_rom_done(struct netxen_adapter *adapter)
314{
315 long timeout = 0;
316 long done = 0;
317
318 while (done == 0) {
319 done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS);
320 done &= 2;
321 timeout++;
322 if (timeout >= rom_max_timeout) {
323 printk("Timeout reached waiting for rom done");
324 return -EIO;
325 }
326 }
327 return 0;
328}
329
330static inline int netxen_rom_wren(struct netxen_adapter *adapter)
331{
332 /* Set write enable latch in ROM status register */
333 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
334 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
335 M25P_INSTR_WREN);
336 if (netxen_wait_rom_done(adapter)) {
337 return -1;
338 }
339 return 0;
340}
341
342static inline unsigned int netxen_rdcrbreg(struct netxen_adapter *adapter,
343 unsigned int addr)
344{
345 unsigned int data = 0xdeaddead;
346 data = netxen_nic_reg_read(adapter, addr);
347 return data;
348}
349
350static inline int netxen_do_rom_rdsr(struct netxen_adapter *adapter)
351{
352 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
353 M25P_INSTR_RDSR);
354 if (netxen_wait_rom_done(adapter)) {
355 return -1;
356 }
357 return netxen_rdcrbreg(adapter, NETXEN_ROMUSB_ROM_RDATA);
358}
359
360static inline void netxen_rom_unlock(struct netxen_adapter *adapter)
361{
362 u32 val;
363
364 /* release semaphore2 */
365 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_UNLOCK), &val);
366
367}
368
369int netxen_rom_wip_poll(struct netxen_adapter *adapter)
370{
371 long timeout = 0;
372 long wip = 1;
373 int val;
374 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
375 while (wip != 0) {
376 val = netxen_do_rom_rdsr(adapter);
377 wip = val & 1;
378 timeout++;
379 if (timeout > rom_max_timeout) {
380 return -1;
381 }
382 }
383 return 0;
384}
385
386static inline int do_rom_fast_write(struct netxen_adapter *adapter,
387 int addr, int data)
388{
389 if (netxen_rom_wren(adapter)) {
390 return -1;
391 }
392 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_WDATA, data);
393 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
394 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
395 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
396 M25P_INSTR_PP);
397 if (netxen_wait_rom_done(adapter)) {
398 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
399 return -1;
400 }
401
402 return netxen_rom_wip_poll(adapter);
403}
404
405static inline int
406do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
407{
408 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
409 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
410 udelay(100); /* prevent bursting on CRB */
411 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
412 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb);
413 if (netxen_wait_rom_done(adapter)) {
414 printk("Error waiting for rom done\n");
415 return -EIO;
416 }
417 /* reset abyte_cnt and dummy_byte_cnt */
418 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
419 udelay(100); /* prevent bursting on CRB */
420 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
421
422 *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA);
423 return 0;
424}
425
426int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
427{
428 int ret;
429
430 if (rom_lock(adapter) != 0)
431 return -EIO;
432
433 ret = do_rom_fast_read(adapter, addr, valp);
434 netxen_rom_unlock(adapter);
435 return ret;
436}
437
438int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data)
439{
440 int ret = 0;
441
442 if (rom_lock(adapter) != 0) {
443 return -1;
444 }
445 ret = do_rom_fast_write(adapter, addr, data);
446 netxen_rom_unlock(adapter);
447 return ret;
448}
449int netxen_do_rom_se(struct netxen_adapter *adapter, int addr)
450{
451 netxen_rom_wren(adapter);
452 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
453 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
454 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
455 M25P_INSTR_SE);
456 if (netxen_wait_rom_done(adapter)) {
457 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
458 return -1;
459 }
460 return netxen_rom_wip_poll(adapter);
461}
462
463int netxen_rom_se(struct netxen_adapter *adapter, int addr)
464{
465 int ret = 0;
466 if (rom_lock(adapter) != 0) {
467 return -1;
468 }
469 ret = netxen_do_rom_se(adapter, addr);
470 netxen_rom_unlock(adapter);
471 return ret;
472}
473
474#define NETXEN_BOARDTYPE 0x4008
475#define NETXEN_BOARDNUM 0x400c
476#define NETXEN_CHIPNUM 0x4010
477#define NETXEN_ROMBUS_RESET 0xFFFFFFFF
478#define NETXEN_ROM_FIRST_BARRIER 0x800000000ULL
479#define NETXEN_ROM_FOUND_INIT 0x400
480
481int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
482{
483 int addr, val, status;
484 int n, i;
485 int init_delay = 0;
486 struct crb_addr_pair *buf;
487 unsigned long off;
488
489 /* resetall */
490 status = netxen_nic_get_board_info(adapter);
491 if (status)
492 printk("%s: netxen_pinit_from_rom: Error getting board info\n",
493 netxen_nic_driver_name);
494
495 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
496 NETXEN_ROMBUS_RESET);
497
498 if (verbose) {
499 int val;
500 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0)
501 printk("P2 ROM board type: 0x%08x\n", val);
502 else
503 printk("Could not read board type\n");
504 if (netxen_rom_fast_read(adapter, NETXEN_BOARDNUM, &val) == 0)
505 printk("P2 ROM board num: 0x%08x\n", val);
506 else
507 printk("Could not read board number\n");
508 if (netxen_rom_fast_read(adapter, NETXEN_CHIPNUM, &val) == 0)
509 printk("P2 ROM chip num: 0x%08x\n", val);
510 else
511 printk("Could not read chip number\n");
512 }
513
514 if (netxen_rom_fast_read(adapter, 0, &n) == 0
515 && (n & NETXEN_ROM_FIRST_BARRIER)) {
516 n &= ~NETXEN_ROM_ROUNDUP;
517 if (n < NETXEN_ROM_FOUND_INIT) {
518 if (verbose)
519 printk("%s: %d CRB init values found"
520 " in ROM.\n", netxen_nic_driver_name, n);
521 } else {
522 printk("%s:n=0x%x Error! NetXen card flash not"
523 " initialized.\n", __FUNCTION__, n);
524 return -EIO;
525 }
526 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
527 if (buf == NULL) {
528 printk("%s: netxen_pinit_from_rom: Unable to calloc "
529 "memory.\n", netxen_nic_driver_name);
530 return -ENOMEM;
531 }
532 for (i = 0; i < n; i++) {
533 if (netxen_rom_fast_read(adapter, 8 * i + 4, &val) != 0
534 || netxen_rom_fast_read(adapter, 8 * i + 8,
535 &addr) != 0)
536 return -EIO;
537
538 buf[i].addr = addr;
539 buf[i].data = val;
540
541 if (verbose)
542 printk("%s: PCI: 0x%08x == 0x%08x\n",
543 netxen_nic_driver_name, (unsigned int)
544 netxen_decode_crb_addr((unsigned long)
545 addr), val);
546 }
547 for (i = 0; i < n; i++) {
548
549 off =
550 netxen_decode_crb_addr((unsigned long)buf[i].addr) +
551 NETXEN_PCI_CRBSPACE;
552 /* skipping cold reboot MAGIC */
553 if (off == NETXEN_CAM_RAM(0x1fc))
554 continue;
555
556 /* After writing this register, HW needs time for CRB */
557 /* to quiet down (else crb_window returns 0xffffffff) */
558 if (off == NETXEN_ROMUSB_GLB_SW_RESET) {
559 init_delay = 1;
560 /* hold xdma in reset also */
561 buf[i].data = NETXEN_NIC_XDMA_RESET;
562 }
563
564 if (ADDR_IN_WINDOW1(off)) {
565 writel(buf[i].data,
566 NETXEN_CRB_NORMALIZE(adapter, off));
567 } else {
568 netxen_nic_pci_change_crbwindow(adapter, 0);
569 writel(buf[i].data,
570 pci_base_offset(adapter, off));
571
572 netxen_nic_pci_change_crbwindow(adapter, 1);
573 }
574 if (init_delay == 1) {
575 ssleep(1);
576 init_delay = 0;
577 }
578 msleep(1);
579 }
580 kfree(buf);
581
582 /* disable_peg_cache_all */
583
584 /* unreset_net_cache */
585 netxen_nic_hw_read_wx(adapter, NETXEN_ROMUSB_GLB_SW_RESET, &val,
586 4);
587 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
588 (val & 0xffffff0f));
589 /* p2dn replyCount */
590 netxen_crb_writelit_adapter(adapter,
591 NETXEN_CRB_PEG_NET_D + 0xec, 0x1e);
592 /* disable_peg_cache 0 */
593 netxen_crb_writelit_adapter(adapter,
594 NETXEN_CRB_PEG_NET_D + 0x4c, 8);
595 /* disable_peg_cache 1 */
596 netxen_crb_writelit_adapter(adapter,
597 NETXEN_CRB_PEG_NET_I + 0x4c, 8);
598
599 /* peg_clr_all */
600
601 /* peg_clr 0 */
602 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0x8,
603 0);
604 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_0 + 0xc,
605 0);
606 /* peg_clr 1 */
607 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0x8,
608 0);
609 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_1 + 0xc,
610 0);
611 /* peg_clr 2 */
612 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0x8,
613 0);
614 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_2 + 0xc,
615 0);
616 /* peg_clr 3 */
617 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0x8,
618 0);
619 netxen_crb_writelit_adapter(adapter, NETXEN_CRB_PEG_NET_3 + 0xc,
620 0);
621 }
622 return 0;
623}
624
625void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
626{
627 u32 val = 0;
628 int loops = 0;
629
630 if (!pegtune_val) {
631 while (val != PHAN_INITIALIZE_COMPLETE && loops < 200000) {
632 udelay(100);
633 schedule();
634 val =
635 readl(NETXEN_CRB_NORMALIZE
636 (adapter, CRB_CMDPEG_STATE));
637 loops++;
638 }
639 if (val != PHAN_INITIALIZE_COMPLETE)
640 printk("WARNING: Initial boot wait loop failed...\n");
641 }
642}
643
644int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
645{
646 int ctx;
647
648 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
649 struct netxen_recv_context *recv_ctx =
650 &(adapter->recv_ctx[ctx]);
651 u32 consumer;
652 struct status_desc *desc_head;
653 struct status_desc *desc;
654
655 consumer = recv_ctx->status_rx_consumer;
656 desc_head = recv_ctx->rcv_status_desc_head;
657 desc = &desc_head[consumer];
658
659 if (((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST))
660 return 1;
661 }
662
663 return 0;
664}
665
666static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
667{
668 int port_num;
669 struct netxen_port *port;
670 struct net_device *netdev;
671 uint32_t temp, temp_state, temp_val;
672 int rv = 0;
673
674 temp = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_TEMP_STATE));
675
676 temp_state = nx_get_temp_state(temp);
677 temp_val = nx_get_temp_val(temp);
678
679 if (temp_state == NX_TEMP_PANIC) {
680 printk(KERN_ALERT
681 "%s: Device temperature %d degrees C exceeds"
682 " maximum allowed. Hardware has been shut down.\n",
683 netxen_nic_driver_name, temp_val);
684 for (port_num = 0; port_num < adapter->ahw.max_ports;
685 port_num++) {
686 port = adapter->port[port_num];
687 netdev = port->netdev;
688
689 netif_carrier_off(netdev);
690 netif_stop_queue(netdev);
691 }
692 rv = 1;
693 } else if (temp_state == NX_TEMP_WARN) {
694 if (adapter->temp == NX_TEMP_NORMAL) {
695 printk(KERN_ALERT
696 "%s: Device temperature %d degrees C "
697 "exceeds operating range."
698 " Immediate action needed.\n",
699 netxen_nic_driver_name, temp_val);
700 }
701 } else {
702 if (adapter->temp == NX_TEMP_WARN) {
703 printk(KERN_INFO
704 "%s: Device temperature is now %d degrees C"
705 " in normal range.\n", netxen_nic_driver_name,
706 temp_val);
707 }
708 }
709 adapter->temp = temp_state;
710 return rv;
711}
712
713void netxen_watchdog_task(unsigned long v)
714{
715 int port_num;
716 struct netxen_port *port;
717 struct net_device *netdev;
718 struct netxen_adapter *adapter = (struct netxen_adapter *)v;
719
720 if (netxen_nic_check_temp(adapter))
721 return;
722
723 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) {
724 port = adapter->port[port_num];
725 netdev = port->netdev;
726
727 if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) {
728 printk(KERN_INFO "%s port %d, %s carrier is now ok\n",
729 netxen_nic_driver_name, port_num, netdev->name);
730 netif_carrier_on(netdev);
731 }
732
733 if (netif_queue_stopped(netdev))
734 netif_wake_queue(netdev);
735 }
736
737 if (adapter->ops->handle_phy_intr)
738 adapter->ops->handle_phy_intr(adapter);
739 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
740}
741
742/*
743 * netxen_process_rcv() send the received packet to the protocol stack.
744 * and if the number of receives exceeds RX_BUFFERS_REFILL, then we
745 * invoke the routine to send more rx buffers to the Phantom...
746 */
747void
748netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
749 struct status_desc *desc)
750{
751 struct netxen_port *port = adapter->port[STATUS_DESC_PORT(desc)];
752 struct pci_dev *pdev = port->pdev;
753 struct net_device *netdev = port->netdev;
754 int index = le16_to_cpu(desc->reference_handle);
755 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
756 struct netxen_rx_buffer *buffer;
757 struct sk_buff *skb;
758 u32 length = le16_to_cpu(desc->total_length);
759 u32 desc_ctx;
760 struct netxen_rcv_desc_ctx *rcv_desc;
761 int ret;
762
763 desc_ctx = STATUS_DESC_TYPE(desc);
764 if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) {
765 printk("%s: %s Bad Rcv descriptor ring\n",
766 netxen_nic_driver_name, netdev->name);
767 return;
768 }
769
770 rcv_desc = &recv_ctx->rcv_desc[desc_ctx];
771 buffer = &rcv_desc->rx_buf_arr[index];
772
773 pci_unmap_single(pdev, buffer->dma, rcv_desc->dma_size,
774 PCI_DMA_FROMDEVICE);
775
776 skb = (struct sk_buff *)buffer->skb;
777
778 if (likely(STATUS_DESC_STATUS(desc) == STATUS_CKSUM_OK)) {
779 port->stats.csummed++;
780 skb->ip_summed = CHECKSUM_UNNECESSARY;
781 } else
782 skb->ip_summed = CHECKSUM_NONE;
783 skb->dev = netdev;
784 skb_put(skb, length);
785 skb->protocol = eth_type_trans(skb, netdev);
786
787 ret = netif_receive_skb(skb);
788
789 /*
790 * RH: Do we need these stats on a regular basis. Can we get it from
791 * Linux stats.
792 */
793 switch (ret) {
794 case NET_RX_SUCCESS:
795 port->stats.uphappy++;
796 break;
797
798 case NET_RX_CN_LOW:
799 port->stats.uplcong++;
800 break;
801
802 case NET_RX_CN_MOD:
803 port->stats.upmcong++;
804 break;
805
806 case NET_RX_CN_HIGH:
807 port->stats.uphcong++;
808 break;
809
810 case NET_RX_DROP:
811 port->stats.updropped++;
812 break;
813
814 default:
815 port->stats.updunno++;
816 break;
817 }
818
819 netdev->last_rx = jiffies;
820
821 rcv_desc->rcv_free++;
822 rcv_desc->rcv_pending--;
823
824 /*
825 * We just consumed one buffer so post a buffer.
826 */
827 adapter->stats.post_called++;
828 buffer->skb = NULL;
829 buffer->state = NETXEN_BUFFER_FREE;
830
831 port->stats.no_rcv++;
832 port->stats.rxbytes += length;
833}
834
835/* Process Receive status ring */
836u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
837{
838 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
839 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head;
840 struct status_desc *desc; /* used to read status desc here */
841 u32 consumer = recv_ctx->status_rx_consumer;
842 int count = 0, ring;
843
844 DPRINTK(INFO, "procesing receive\n");
845 /*
846 * we assume in this case that there is only one port and that is
847 * port #1...changes need to be done in firmware to indicate port
848 * number as part of the descriptor. This way we will be able to get
849 * the netdev which is associated with that device.
850 */
851 while (count < max) {
852 desc = &desc_head[consumer];
853 if (!((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST)) {
854 DPRINTK(ERR, "desc %p ownedby %x\n", desc, desc->owner);
855 break;
856 }
857 netxen_process_rcv(adapter, ctxid, desc);
858 desc->owner = STATUS_OWNER_PHANTOM;
859 consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1);
860 count++;
861 }
862 if (count) {
863 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
864 netxen_post_rx_buffers(adapter, ctxid, ring);
865 }
866 }
867
868 /* update the consumer index in phantom */
869 if (count) {
870 adapter->stats.process_rcv++;
871 recv_ctx->status_rx_consumer = consumer;
872
873 /* Window = 1 */
874 writel(consumer,
875 NETXEN_CRB_NORMALIZE(adapter,
876 recv_crb_registers[ctxid].
877 crb_rcv_status_consumer));
878 }
879
880 return count;
881}
882
883/* Process Command status ring */
884void netxen_process_cmd_ring(unsigned long data)
885{
886 u32 last_consumer;
887 u32 consumer;
888 struct netxen_adapter *adapter = (struct netxen_adapter *)data;
889 int count = 0;
890 struct netxen_cmd_buffer *buffer;
891 struct netxen_port *port; /* port #1 */
892 struct netxen_port *nport;
893 struct pci_dev *pdev;
894 struct netxen_skb_frag *frag;
895 u32 i;
896 struct sk_buff *skb = NULL;
897 int p;
898
899 spin_lock(&adapter->tx_lock);
900 last_consumer = adapter->last_cmd_consumer;
901 DPRINTK(INFO, "procesing xmit complete\n");
902 /* we assume in this case that there is only one port and that is
903 * port #1...changes need to be done in firmware to indicate port
904 * number as part of the descriptor. This way we will be able to get
905 * the netdev which is associated with that device.
906 */
907 consumer =
908 readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
909
910 if (last_consumer == consumer) { /* Ring is empty */
911 DPRINTK(INFO, "last_consumer %d == consumer %d\n",
912 last_consumer, consumer);
913 spin_unlock(&adapter->tx_lock);
914 return;
915 }
916
917 adapter->proc_cmd_buf_counter++;
918 adapter->stats.process_xmit++;
919 /*
920 * Not needed - does not seem to be used anywhere.
921 * adapter->cmd_consumer = consumer;
922 */
923 spin_unlock(&adapter->tx_lock);
924
925 while ((last_consumer != consumer) && (count < MAX_STATUS_HANDLE)) {
926 buffer = &adapter->cmd_buf_arr[last_consumer];
927 port = adapter->port[buffer->port];
928 pdev = port->pdev;
929 frag = &buffer->frag_array[0];
930 skb = buffer->skb;
931 if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) {
932 pci_unmap_single(pdev, frag->dma, frag->length,
933 PCI_DMA_TODEVICE);
934 for (i = 1; i < buffer->frag_count; i++) {
935 DPRINTK(INFO, "getting fragment no %d\n", i);
936 frag++; /* Get the next frag */
937 pci_unmap_page(pdev, frag->dma, frag->length,
938 PCI_DMA_TODEVICE);
939 }
940
941 port->stats.skbfreed++;
942 dev_kfree_skb_any(skb);
943 skb = NULL;
944 } else if (adapter->proc_cmd_buf_counter == 1) {
945 port->stats.txnullskb++;
946 }
947 if (unlikely(netif_queue_stopped(port->netdev)
948 && netif_carrier_ok(port->netdev))
949 && ((jiffies - port->netdev->trans_start) >
950 port->netdev->watchdog_timeo)) {
951 schedule_work(&port->adapter->tx_timeout_task);
952 }
953
954 last_consumer = get_next_index(last_consumer,
955 adapter->max_tx_desc_count);
956 count++;
957 }
958 adapter->stats.noxmitdone += count;
959
960 count = 0;
961 spin_lock(&adapter->tx_lock);
962 if ((--adapter->proc_cmd_buf_counter) == 0) {
963 adapter->last_cmd_consumer = last_consumer;
964 while ((adapter->last_cmd_consumer != consumer)
965 && (count < MAX_STATUS_HANDLE)) {
966 buffer =
967 &adapter->cmd_buf_arr[adapter->last_cmd_consumer];
968 count++;
969 if (buffer->skb)
970 break;
971 else
972 adapter->last_cmd_consumer =
973 get_next_index(adapter->last_cmd_consumer,
974 adapter->max_tx_desc_count);
975 }
976 }
977 if (count) {
978 for (p = 0; p < adapter->ahw.max_ports; p++) {
979 nport = adapter->port[p];
980 if (netif_queue_stopped(nport->netdev)
981 && (nport->flags & NETXEN_NETDEV_STATUS)) {
982 netif_wake_queue(nport->netdev);
983 nport->flags &= ~NETXEN_NETDEV_STATUS;
984 }
985 }
986 }
987
988 spin_unlock(&adapter->tx_lock);
989 DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer,
990 __FUNCTION__);
991}
992
993/*
994 * netxen_post_rx_buffers puts buffer in the Phantom memory
995 */
996void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
997{
998 struct pci_dev *pdev = adapter->ahw.pdev;
999 struct sk_buff *skb;
1000 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
1001 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
1002 struct netxen_recv_crb *crbarea = &recv_crb_registers[ctx];
1003 struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
1004 u32 producer;
1005 struct rcv_desc *pdesc;
1006 struct netxen_rx_buffer *buffer;
1007 int count = 0;
1008 int index = 0;
1009
1010 adapter->stats.post_called++;
1011 rcv_desc = &recv_ctx->rcv_desc[ringid];
1012 rcv_desc_crb = &crbarea->rcv_desc_crb[ringid];
1013
1014 producer = rcv_desc->producer;
1015 index = rcv_desc->begin_alloc;
1016 buffer = &rcv_desc->rx_buf_arr[index];
1017 /* We can start writing rx descriptors into the phantom memory. */
1018 while (buffer->state == NETXEN_BUFFER_FREE) {
1019 skb = dev_alloc_skb(rcv_desc->skb_size);
1020 if (unlikely(!skb)) {
1021 /*
1022 * We need to schedule the posting of buffers to the pegs.
1023 */
1024 rcv_desc->begin_alloc = index;
1025 DPRINTK(ERR, "netxen_post_rx_buffers: "
1026 " allocated only %d buffers\n", count);
1027 break;
1028 }
1029 count++; /* now there should be no failure */
1030 pdesc = &rcv_desc->desc_head[producer];
1031 skb_reserve(skb, NET_IP_ALIGN);
1032 /*
1033 * This will be setup when we receive the
1034 * buffer after it has been filled
1035 * skb->dev = netdev;
1036 */
1037 buffer->skb = skb;
1038 buffer->state = NETXEN_BUFFER_BUSY;
1039 buffer->dma = pci_map_single(pdev, skb->data,
1040 rcv_desc->dma_size,
1041 PCI_DMA_FROMDEVICE);
1042 /* make a rcv descriptor */
1043 pdesc->reference_handle = le16_to_cpu(buffer->ref_handle);
1044 pdesc->buffer_length = le16_to_cpu(rcv_desc->dma_size);
1045 pdesc->addr_buffer = cpu_to_le64(buffer->dma);
1046 DPRINTK(INFO, "done writing descripter\n");
1047 producer =
1048 get_next_index(producer, rcv_desc->max_rx_desc_count);
1049 index = get_next_index(index, rcv_desc->max_rx_desc_count);
1050 buffer = &rcv_desc->rx_buf_arr[index];
1051 }
1052
1053 /* if we did allocate buffers, then write the count to Phantom */
1054 if (count) {
1055 rcv_desc->begin_alloc = index;
1056 rcv_desc->rcv_pending += count;
1057 adapter->stats.lastposted = count;
1058 adapter->stats.posted += count;
1059 rcv_desc->producer = producer;
1060 if (rcv_desc->rcv_free >= 32) {
1061 rcv_desc->rcv_free = 0;
1062 /* Window = 1 */
1063 writel((producer - 1) &
1064 (rcv_desc->max_rx_desc_count - 1),
1065 NETXEN_CRB_NORMALIZE(adapter,
1066 rcv_desc_crb->
1067 crb_rcv_producer_offset));
1068 wmb();
1069 }
1070 }
1071}
1072
1073int netxen_nic_tx_has_work(struct netxen_adapter *adapter)
1074{
1075 if (find_diff_among(adapter->last_cmd_consumer,
1076 adapter->cmd_producer,
1077 adapter->max_tx_desc_count) > 0)
1078 return 1;
1079
1080 return 0;
1081}
1082
1083int
1084netxen_nic_fill_statistics(struct netxen_adapter *adapter,
1085 struct netxen_port *port,
1086 struct netxen_statistics *netxen_stats)
1087{
1088 void __iomem *addr;
1089
1090 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
1091 netxen_nic_pci_change_crbwindow(adapter, 0);
1092 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_TX_BYTE_CNT,
1093 &(netxen_stats->tx_bytes));
1094 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_TX_FRAME_CNT,
1095 &(netxen_stats->tx_packets));
1096 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_RX_BYTE_CNT,
1097 &(netxen_stats->rx_bytes));
1098 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_RX_FRAME_CNT,
1099 &(netxen_stats->rx_packets));
1100 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_AGGR_ERROR_CNT,
1101 &(netxen_stats->rx_errors));
1102 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_CRC_ERROR_CNT,
1103 &(netxen_stats->rx_crc_errors));
1104 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
1105 &(netxen_stats->
1106 rx_long_length_error));
1107 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
1108 &(netxen_stats->
1109 rx_short_length_error));
1110
1111 netxen_nic_pci_change_crbwindow(adapter, 1);
1112 } else {
1113 spin_lock_bh(&adapter->tx_lock);
1114 netxen_stats->tx_bytes = port->stats.txbytes;
1115 netxen_stats->tx_packets = port->stats.xmitedframes +
1116 port->stats.xmitfinished;
1117 netxen_stats->rx_bytes = port->stats.rxbytes;
1118 netxen_stats->rx_packets = port->stats.no_rcv;
1119 netxen_stats->rx_errors = port->stats.rcvdbadskb;
1120 netxen_stats->tx_errors = port->stats.nocmddescriptor;
1121 netxen_stats->rx_short_length_error = port->stats.uplcong;
1122 netxen_stats->rx_long_length_error = port->stats.uphcong;
1123 netxen_stats->rx_crc_errors = 0;
1124 netxen_stats->rx_mac_errors = 0;
1125 spin_unlock_bh(&adapter->tx_lock);
1126 }
1127 return 0;
1128}
1129
1130void netxen_nic_clear_stats(struct netxen_adapter *adapter)
1131{
1132 struct netxen_port *port;
1133 int port_num;
1134
1135 memset(&adapter->stats, 0, sizeof(adapter->stats));
1136 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) {
1137 port = adapter->port[port_num];
1138 memset(&port->stats, 0, sizeof(port->stats));
1139 }
1140}
1141
1142int
1143netxen_nic_clear_statistics(struct netxen_adapter *adapter,
1144 struct netxen_port *port)
1145{
1146 int data = 0;
1147
1148 netxen_nic_pci_change_crbwindow(adapter, 0);
1149
1150 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_TX_BYTE_CNT, &data);
1151 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_TX_FRAME_CNT,
1152 &data);
1153 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_RX_BYTE_CNT, &data);
1154 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_RX_FRAME_CNT,
1155 &data);
1156 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_AGGR_ERROR_CNT,
1157 &data);
1158 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_CRC_ERROR_CNT,
1159 &data);
1160 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR,
1161 &data);
1162 netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR,
1163 &data);
1164
1165 netxen_nic_pci_change_crbwindow(adapter, 1);
1166 netxen_nic_clear_stats(adapter);
1167 return 0;
1168}
1169
1170int
1171netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
1172 struct netxen_port *port)
1173{
1174 struct netxen_nic_ioctl_data data;
1175 struct netxen_nic_ioctl_data *up_data;
1176 int retval = 0;
1177 struct netxen_statistics netxen_stats;
1178
1179 up_data = (void *)u_data;
1180
1181 DPRINTK(INFO, "doing ioctl for %p\n", adapter);
1182 if (copy_from_user(&data, (void __user *)up_data, sizeof(data))) {
1183 /* evil user tried to crash the kernel */
1184 DPRINTK(ERR, "bad copy from userland: %d\n", (int)sizeof(data));
1185 retval = -EFAULT;
1186 goto error_out;
1187 }
1188
1189 /* Shouldn't access beyond legal limits of "char u[64];" member */
1190 if (!data.ptr && (data.size > sizeof(data.u))) {
1191 /* evil user tried to crash the kernel */
1192 DPRINTK(ERR, "bad size: %d\n", data.size);
1193 retval = -EFAULT;
1194 goto error_out;
1195 }
1196
1197 switch (data.cmd) {
1198 case netxen_nic_cmd_pci_read:
1199 if ((retval = netxen_nic_hw_read_wx(adapter, data.off,
1200 &(data.u), data.size)))
1201 goto error_out;
1202 if (copy_to_user
1203 ((void __user *)&(up_data->u), &(data.u), data.size)) {
1204 DPRINTK(ERR, "bad copy to userland: %d\n",
1205 (int)sizeof(data));
1206 retval = -EFAULT;
1207 goto error_out;
1208 }
1209 data.rv = 0;
1210 break;
1211
1212 case netxen_nic_cmd_pci_write:
1213 data.rv = netxen_nic_hw_write_wx(adapter, data.off, &(data.u),
1214 data.size);
1215 break;
1216
1217 case netxen_nic_cmd_pci_config_read:
1218 switch (data.size) {
1219 case 1:
1220 data.rv = pci_read_config_byte(adapter->ahw.pdev,
1221 data.off,
1222 (char *)&(data.u));
1223 break;
1224 case 2:
1225 data.rv = pci_read_config_word(adapter->ahw.pdev,
1226 data.off,
1227 (short *)&(data.u));
1228 break;
1229 case 4:
1230 data.rv = pci_read_config_dword(adapter->ahw.pdev,
1231 data.off,
1232 (u32 *) & (data.u));
1233 break;
1234 }
1235 if (copy_to_user
1236 ((void __user *)&(up_data->u), &(data.u), data.size)) {
1237 DPRINTK(ERR, "bad copy to userland: %d\n",
1238 (int)sizeof(data));
1239 retval = -EFAULT;
1240 goto error_out;
1241 }
1242 break;
1243
1244 case netxen_nic_cmd_pci_config_write:
1245 switch (data.size) {
1246 case 1:
1247 data.rv = pci_write_config_byte(adapter->ahw.pdev,
1248 data.off,
1249 *(char *)&(data.u));
1250 break;
1251 case 2:
1252 data.rv = pci_write_config_word(adapter->ahw.pdev,
1253 data.off,
1254 *(short *)&(data.u));
1255 break;
1256 case 4:
1257 data.rv = pci_write_config_dword(adapter->ahw.pdev,
1258 data.off,
1259 *(u32 *) & (data.u));
1260 break;
1261 }
1262 break;
1263
1264 case netxen_nic_cmd_get_stats:
1265 data.rv =
1266 netxen_nic_fill_statistics(adapter, port, &netxen_stats);
1267 if (copy_to_user
1268 ((void __user *)(up_data->ptr), (void *)&netxen_stats,
1269 sizeof(struct netxen_statistics))) {
1270 DPRINTK(ERR, "bad copy to userland: %d\n",
1271 (int)sizeof(netxen_stats));
1272 retval = -EFAULT;
1273 goto error_out;
1274 }
1275 up_data->rv = data.rv;
1276 break;
1277
1278 case netxen_nic_cmd_clear_stats:
1279 data.rv = netxen_nic_clear_statistics(adapter, port);
1280 up_data->rv = data.rv;
1281 break;
1282
1283 case netxen_nic_cmd_get_version:
1284 if (copy_to_user
1285 ((void __user *)&(up_data->u), NETXEN_NIC_LINUX_VERSIONID,
1286 sizeof(NETXEN_NIC_LINUX_VERSIONID))) {
1287 DPRINTK(ERR, "bad copy to userland: %d\n",
1288 (int)sizeof(data));
1289 retval = -EFAULT;
1290 goto error_out;
1291 }
1292 break;
1293
1294 default:
1295 DPRINTK(INFO, "bad command %d for %p\n", data.cmd, adapter);
1296 retval = -EOPNOTSUPP;
1297 goto error_out;
1298 }
1299 put_user(data.rv, (u16 __user *) (&(up_data->rv)));
1300 DPRINTK(INFO, "done ioctl for %p well.\n", adapter);
1301
1302 error_out:
1303 return retval;
1304}
diff --git a/drivers/net/netxen/netxen_nic_ioctl.h b/drivers/net/netxen/netxen_nic_ioctl.h
new file mode 100644
index 000000000000..23e53adbf123
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_ioctl.h
@@ -0,0 +1,77 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef __NETXEN_NIC_IOCTL_H__
31#define __NETXEN_NIC_IOCTL_H__
32
33#include <linux/sockios.h>
34
35#define NETXEN_CMD_START SIOCDEVPRIVATE
36#define NETXEN_NIC_CMD (NETXEN_CMD_START + 1)
37#define NETXEN_NIC_NAME (NETXEN_CMD_START + 2)
38#define NETXEN_NIC_NAME_LEN 16
39#define NETXEN_NIC_NAME_RSP "NETXEN"
40
41typedef enum {
42 netxen_nic_cmd_none = 0,
43 netxen_nic_cmd_pci_read,
44 netxen_nic_cmd_pci_write,
45 netxen_nic_cmd_pci_mem_read,
46 netxen_nic_cmd_pci_mem_write,
47 netxen_nic_cmd_pci_config_read,
48 netxen_nic_cmd_pci_config_write,
49 netxen_nic_cmd_get_stats,
50 netxen_nic_cmd_clear_stats,
51 netxen_nic_cmd_get_version
52} netxen_nic_ioctl_cmd_t;
53
54struct netxen_nic_ioctl_data {
55 u32 cmd;
56 u32 unused1;
57 u64 off;
58 u32 size;
59 u32 rv;
60 char u[64];
61 void *ptr;
62};
63
64struct netxen_statistics {
65 u64 rx_packets;
66 u64 tx_packets;
67 u64 rx_bytes;
68 u64 rx_errors;
69 u64 tx_bytes;
70 u64 tx_errors;
71 u64 rx_crc_errors;
72 u64 rx_short_length_error;
73 u64 rx_long_length_error;
74 u64 rx_mac_errors;
75};
76
77#endif /* __NETXEN_NIC_IOCTL_H_ */
diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c
new file mode 100644
index 000000000000..ae180fee8008
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_isr.c
@@ -0,0 +1,215 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#include <linux/netdevice.h>
31#include <linux/delay.h>
32
33#include "netxen_nic.h"
34#include "netxen_nic_hw.h"
35#include "netxen_nic_phan_reg.h"
36
37/*
38 * netxen_nic_get_stats - Get System Network Statistics
39 * @netdev: network interface device structure
40 */
41struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
42{
43 struct netxen_port *port = netdev_priv(netdev);
44 struct net_device_stats *stats = &port->net_stats;
45
46 memset(stats, 0, sizeof(*stats));
47
48 /* total packets received */
49 stats->rx_packets = port->stats.no_rcv;
50 /* total packets transmitted */
51 stats->tx_packets = port->stats.xmitedframes + port->stats.xmitfinished;
52 /* total bytes received */
53 stats->rx_bytes = port->stats.rxbytes;
54 /* total bytes transmitted */
55 stats->tx_bytes = port->stats.txbytes;
56 /* bad packets received */
57 stats->rx_errors = port->stats.rcvdbadskb;
58 /* packet transmit problems */
59 stats->tx_errors = port->stats.nocmddescriptor;
60 /* no space in linux buffers */
61 stats->rx_dropped = port->stats.updropped;
62 /* no space available in linux */
63 stats->tx_dropped = port->stats.txdropped;
64
65 return stats;
66}
67
68void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
69 u32 link)
70{
71 struct netxen_port *pport = adapter->port[portno];
72 struct net_device *netdev = pport->netdev;
73
74 if (link)
75 netif_carrier_on(netdev);
76 else
77 netif_carrier_off(netdev);
78}
79
80void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
81 u32 enable)
82{
83 __le32 int_src;
84 struct netxen_port *port;
85
86 /* This should clear the interrupt source */
87 if (adapter->ops->phy_read)
88 adapter->ops->phy_read(adapter, portno,
89 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
90 &int_src);
91 if (int_src == 0) {
92 DPRINTK(INFO, "No phy interrupts for port #%d\n", portno);
93 return;
94 }
95 if (adapter->ops->disable_phy_interrupts)
96 adapter->ops->disable_phy_interrupts(adapter, portno);
97
98 port = adapter->port[portno];
99
100 if (netxen_get_phy_int_jabber(int_src))
101 DPRINTK(INFO, "NetXen: %s Jabber interrupt \n",
102 port->netdev->name);
103
104 if (netxen_get_phy_int_polarity_changed(int_src))
105 DPRINTK(INFO, "NetXen: %s POLARITY CHANGED int \n",
106 port->netdev->name);
107
108 if (netxen_get_phy_int_energy_detect(int_src))
109 DPRINTK(INFO, "NetXen: %s ENERGY DETECT INT \n",
110 port->netdev->name);
111
112 if (netxen_get_phy_int_downshift(int_src))
113 DPRINTK(INFO, "NetXen: %s DOWNSHIFT INT \n",
114 port->netdev->name);
115 /* write it down later.. */
116 if ((netxen_get_phy_int_speed_changed(int_src))
117 || (netxen_get_phy_int_link_status_changed(int_src))) {
118 __le32 status;
119
120 DPRINTK(INFO, "NetXen: %s SPEED CHANGED OR"
121 " LINK STATUS CHANGED \n", port->netdev->name);
122
123 if (adapter->ops->phy_read
124 && adapter->ops->phy_read(adapter, portno,
125 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
126 &status) == 0) {
127 if (netxen_get_phy_int_link_status_changed(int_src)) {
128 if (netxen_get_phy_link(status)) {
129 netxen_niu_gbe_init_port(adapter,
130 portno);
131 printk("%s: %s Link UP\n",
132 netxen_nic_driver_name,
133 port->netdev->name);
134
135 } else {
136 printk("%s: %s Link DOWN\n",
137 netxen_nic_driver_name,
138 port->netdev->name);
139 }
140 netxen_indicate_link_status(adapter, portno,
141 netxen_get_phy_link
142 (status));
143 }
144 }
145 }
146 if (adapter->ops->enable_phy_interrupts)
147 adapter->ops->enable_phy_interrupts(adapter, portno);
148}
149
150void netxen_nic_isr_other(struct netxen_adapter *adapter)
151{
152 u32 portno;
153 u32 val, linkup, qg_linksup;
154
155 /* verify the offset */
156 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
157 if (val == adapter->ahw.qg_linksup)
158 return;
159
160 qg_linksup = adapter->ahw.qg_linksup;
161 adapter->ahw.qg_linksup = val;
162 DPRINTK(1, INFO, "%s: link update 0x%08x\n", netxen_nic_driver_name,
163 val);
164 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) {
165 linkup = val & 1;
166 if (linkup != (qg_linksup & 1)) {
167 printk(KERN_INFO "%s: PORT %d link %s\n",
168 netxen_nic_driver_name, portno,
169 ((linkup == 0) ? "down" : "up"));
170 netxen_indicate_link_status(adapter, portno, linkup);
171 if (linkup)
172 netxen_nic_set_link_parameters(adapter->
173 port[portno]);
174
175 }
176 val = val >> 1;
177 qg_linksup = qg_linksup >> 1;
178 }
179
180 adapter->stats.otherints++;
181
182}
183
184void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter)
185{
186 netxen_nic_isr_other(adapter);
187}
188
189void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter)
190{
191 struct net_device *netdev = adapter->port[0]->netdev;
192 u32 val;
193
194 /* WINDOW = 1 */
195 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
196
197 if (adapter->ahw.xg_linkup == 1 && val != XG_LINK_UP) {
198 printk(KERN_INFO "%s: %s NIC Link is down\n",
199 netxen_nic_driver_name, netdev->name);
200 adapter->ahw.xg_linkup = 0;
201 /* read twice to clear sticky bits */
202 /* WINDOW = 0 */
203 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val);
204 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val);
205
206 if ((val & 0xffb) != 0xffb) {
207 printk(KERN_INFO "%s ISR: Sync/Align BAD: 0x%08x\n",
208 netxen_nic_driver_name, val);
209 }
210 } else if (adapter->ahw.xg_linkup == 0 && val == XG_LINK_UP) {
211 printk(KERN_INFO "%s: %s NIC Link is up\n",
212 netxen_nic_driver_name, netdev->name);
213 adapter->ahw.xg_linkup = 1;
214 }
215}
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
new file mode 100644
index 000000000000..1cb662d5bd76
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -0,0 +1,1161 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Main source file for NetXen NIC Driver on Linux
31 *
32 */
33
34#include <linux/vmalloc.h>
35#include "netxen_nic_hw.h"
36
37#include "netxen_nic.h"
38#define DEFINE_GLOBAL_RECV_CRB
39#include "netxen_nic_phan_reg.h"
40#include "netxen_nic_ioctl.h"
41
42#include <linux/dma-mapping.h>
43#include <linux/vmalloc.h>
44
45#define PHAN_VENDOR_ID 0x4040
46
47MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
48MODULE_LICENSE("GPL");
49MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
50
51char netxen_nic_driver_name[] = "netxen";
52static char netxen_nic_driver_string[] = "NetXen Network Driver version "
53 NETXEN_NIC_LINUX_VERSIONID;
54
55#define NETXEN_NETDEV_WEIGHT 120
56#define NETXEN_ADAPTER_UP_MAGIC 777
57#define NETXEN_NIC_PEG_TUNE 0
58
59/* Local functions to NetXen NIC driver */
60static int __devinit netxen_nic_probe(struct pci_dev *pdev,
61 const struct pci_device_id *ent);
62static void __devexit netxen_nic_remove(struct pci_dev *pdev);
63static int netxen_nic_open(struct net_device *netdev);
64static int netxen_nic_close(struct net_device *netdev);
65static int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *);
66static void netxen_tx_timeout(struct net_device *netdev);
67static void netxen_tx_timeout_task(struct net_device *netdev);
68static void netxen_watchdog(unsigned long);
69static int netxen_handle_int(struct netxen_adapter *, struct net_device *);
70static int netxen_nic_ioctl(struct net_device *netdev,
71 struct ifreq *ifr, int cmd);
72static int netxen_nic_poll(struct net_device *dev, int *budget);
73#ifdef CONFIG_NET_POLL_CONTROLLER
74static void netxen_nic_poll_controller(struct net_device *netdev);
75#endif
76static irqreturn_t netxen_intr(int irq, void *data);
77
78/* PCI Device ID Table */
79static struct pci_device_id netxen_pci_tbl[] __devinitdata = {
80 {PCI_DEVICE(0x4040, 0x0001)},
81 {PCI_DEVICE(0x4040, 0x0002)},
82 {PCI_DEVICE(0x4040, 0x0003)},
83 {PCI_DEVICE(0x4040, 0x0004)},
84 {PCI_DEVICE(0x4040, 0x0005)},
85 {0,}
86};
87
88MODULE_DEVICE_TABLE(pci, netxen_pci_tbl);
89
90/*
91 * netxen_nic_probe()
92 *
93 * The Linux system will invoke this after identifying the vendor ID and
94 * device Id in the pci_tbl supported by this module.
95 *
96 * A quad port card has one operational PCI config space, (function 0),
97 * which is used to access all four ports.
98 *
99 * This routine will initialize the adapter, and setup the global parameters
100 * along with the port's specific structure.
101 */
102static int __devinit
103netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
104{
105 struct net_device *netdev = NULL;
106 struct netxen_adapter *adapter = NULL;
107 struct netxen_port *port = NULL;
108 u8 *mem_ptr0 = NULL;
109 u8 *mem_ptr1 = NULL;
110 u8 *mem_ptr2 = NULL;
111
112 unsigned long mem_base, mem_len;
113 int pci_using_dac, i, err;
114 int ring;
115 struct netxen_recv_context *recv_ctx = NULL;
116 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
117 struct netxen_cmd_buffer *cmd_buf_arr = NULL;
118 u64 mac_addr[FLASH_NUM_PORTS + 1];
119 int valid_mac;
120
121 printk(KERN_INFO "%s \n", netxen_nic_driver_string);
122 if ((err = pci_enable_device(pdev)))
123 return err;
124 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
125 err = -ENODEV;
126 goto err_out_disable_pdev;
127 }
128
129 if ((err = pci_request_regions(pdev, netxen_nic_driver_name)))
130 goto err_out_disable_pdev;
131
132 pci_set_master(pdev);
133 if ((pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) &&
134 (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) == 0))
135 pci_using_dac = 1;
136 else {
137 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) ||
138 (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)))
139 goto err_out_free_res;
140
141 pci_using_dac = 0;
142 }
143
144 /* remap phys address */
145 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
146 mem_len = pci_resource_len(pdev, 0);
147
148 /* 128 Meg of memory */
149 mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
150 mem_ptr1 =
151 ioremap(mem_base + SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_SIZE);
152 mem_ptr2 =
153 ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
154
155 if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) {
156 DPRINTK(1, ERR,
157 "Cannot remap adapter memory aborting.:"
158 "0 -> %p, 1 -> %p, 2 -> %p\n",
159 mem_ptr0, mem_ptr1, mem_ptr2);
160
161 err = -EIO;
162 if (mem_ptr0)
163 iounmap(mem_ptr0);
164 if (mem_ptr1)
165 iounmap(mem_ptr1);
166 if (mem_ptr2)
167 iounmap(mem_ptr2);
168
169 goto err_out_free_res;
170 }
171
172/*
173 * Allocate a adapter structure which will manage all the initialization
174 * as well as the common resources for all ports...
175 * all the ports will have pointer to this adapter as well as Adapter
176 * will have pointers of all the ports structures.
177 */
178
179 /* One adapter structure for all 4 ports.... */
180 adapter = kzalloc(sizeof(struct netxen_adapter), GFP_KERNEL);
181 if (adapter == NULL) {
182 printk(KERN_ERR "%s: Could not allocate adapter memory:%d\n",
183 netxen_nic_driver_name,
184 (int)sizeof(struct netxen_adapter));
185 err = -ENOMEM;
186 goto err_out_iounmap;
187 }
188
189 adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS;
190 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS;
191 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS;
192
193 pci_set_drvdata(pdev, adapter);
194
195 cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE);
196 if (cmd_buf_arr == NULL) {
197 err = -ENOMEM;
198 goto err_out_free_adapter;
199 }
200 memset(cmd_buf_arr, 0, TX_RINGSIZE);
201
202 for (i = 0; i < MAX_RCV_CTX; ++i) {
203 recv_ctx = &adapter->recv_ctx[i];
204 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
205 rcv_desc = &recv_ctx->rcv_desc[ring];
206 switch (RCV_DESC_TYPE(ring)) {
207 case RCV_DESC_NORMAL:
208 rcv_desc->max_rx_desc_count =
209 adapter->max_rx_desc_count;
210 rcv_desc->flags = RCV_DESC_NORMAL;
211 rcv_desc->dma_size = RX_DMA_MAP_LEN;
212 rcv_desc->skb_size = MAX_RX_BUFFER_LENGTH;
213 break;
214
215 case RCV_DESC_JUMBO:
216 rcv_desc->max_rx_desc_count =
217 adapter->max_jumbo_rx_desc_count;
218 rcv_desc->flags = RCV_DESC_JUMBO;
219 rcv_desc->dma_size = RX_JUMBO_DMA_MAP_LEN;
220 rcv_desc->skb_size = MAX_RX_JUMBO_BUFFER_LENGTH;
221 break;
222
223 }
224 rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *)
225 vmalloc(RCV_BUFFSIZE);
226
227 if (rcv_desc->rx_buf_arr == NULL) {
228 err = -ENOMEM;
229 goto err_out_free_rx_buffer;
230 }
231 memset(rcv_desc->rx_buf_arr, 0, RCV_BUFFSIZE);
232 }
233
234 }
235
236 adapter->ops = kzalloc(sizeof(struct netxen_drvops), GFP_KERNEL);
237 if (adapter->ops == NULL) {
238 printk(KERN_ERR
239 "%s: Could not allocate memory for adapter->ops:%d\n",
240 netxen_nic_driver_name,
241 (int)sizeof(struct netxen_adapter));
242 err = -ENOMEM;
243 goto err_out_free_rx_buffer;
244 }
245
246 adapter->cmd_buf_arr = cmd_buf_arr;
247 adapter->ahw.pci_base0 = mem_ptr0;
248 adapter->ahw.pci_base1 = mem_ptr1;
249 adapter->ahw.pci_base2 = mem_ptr2;
250 spin_lock_init(&adapter->tx_lock);
251 spin_lock_init(&adapter->lock);
252#ifdef CONFIG_IA64
253 netxen_pinit_from_rom(adapter, 0);
254 udelay(500);
255 netxen_load_firmware(adapter);
256#endif
257
258 /* initialize the buffers in adapter */
259 netxen_initialize_adapter_sw(adapter);
260 /*
261 * Set the CRB window to invalid. If any register in window 0 is
262 * accessed it should set the window to 0 and then reset it to 1.
263 */
264 adapter->curr_window = 255;
265 /*
266 * Adapter in our case is quad port so initialize it before
267 * initializing the ports
268 */
269 netxen_initialize_adapter_hw(adapter); /* initialize the adapter */
270
271 netxen_initialize_adapter_ops(adapter);
272
273 init_timer(&adapter->watchdog_timer);
274 adapter->ahw.xg_linkup = 0;
275 adapter->watchdog_timer.function = &netxen_watchdog;
276 adapter->watchdog_timer.data = (unsigned long)adapter;
277 INIT_WORK(&adapter->watchdog_task,
278 (void (*)(void *))netxen_watchdog_task, adapter);
279 adapter->ahw.pdev = pdev;
280 adapter->proc_cmd_buf_counter = 0;
281 pci_read_config_byte(pdev, PCI_REVISION_ID, &adapter->ahw.revision_id);
282
283 if (pci_enable_msi(pdev)) {
284 adapter->flags &= ~NETXEN_NIC_MSI_ENABLED;
285 printk(KERN_WARNING "%s: unable to allocate MSI interrupt"
286 " error\n", netxen_nic_driver_name);
287 } else
288 adapter->flags |= NETXEN_NIC_MSI_ENABLED;
289
290 if (netxen_is_flash_supported(adapter) == 0 &&
291 netxen_get_flash_mac_addr(adapter, mac_addr) == 0)
292 valid_mac = 1;
293 else
294 valid_mac = 0;
295
296 /*
297 * Initialize all the CRB registers here.
298 */
299 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
300 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
301 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
302
303 /* Unlock the HW, prompting the boot sequence */
304 writel(1,
305 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
306
307 /* Handshake with the card before we register the devices. */
308 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
309
310 /* initialize the all the ports */
311
312 for (i = 0; i < adapter->ahw.max_ports; i++) {
313 netdev = alloc_etherdev(sizeof(struct netxen_port));
314 if (!netdev) {
315 printk(KERN_ERR "%s: could not allocate netdev for port"
316 " %d\n", netxen_nic_driver_name, i + 1);
317 goto err_out_free_dev;
318 }
319
320 SET_MODULE_OWNER(netdev);
321 SET_NETDEV_DEV(netdev, &pdev->dev);
322
323 port = netdev_priv(netdev);
324 port->netdev = netdev;
325 port->pdev = pdev;
326 port->adapter = adapter;
327 port->portnum = i; /* Gigabit port number from 0-3 */
328
329 netdev->open = netxen_nic_open;
330 netdev->stop = netxen_nic_close;
331 netdev->hard_start_xmit = netxen_nic_xmit_frame;
332 netdev->get_stats = netxen_nic_get_stats;
333 netdev->set_multicast_list = netxen_nic_set_multi;
334 netdev->set_mac_address = netxen_nic_set_mac;
335 netdev->change_mtu = netxen_nic_change_mtu;
336 netdev->do_ioctl = netxen_nic_ioctl;
337 netdev->tx_timeout = netxen_tx_timeout;
338 netdev->watchdog_timeo = HZ;
339
340 SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
341 netdev->poll = netxen_nic_poll;
342 netdev->weight = NETXEN_NETDEV_WEIGHT;
343#ifdef CONFIG_NET_POLL_CONTROLLER
344 netdev->poll_controller = netxen_nic_poll_controller;
345#endif
346 /* ScatterGather support */
347 netdev->features = NETIF_F_SG;
348 netdev->features |= NETIF_F_IP_CSUM;
349 netdev->features |= NETIF_F_TSO;
350
351 if (pci_using_dac)
352 netdev->features |= NETIF_F_HIGHDMA;
353
354 if (valid_mac) {
355 unsigned char *p = (unsigned char *)&mac_addr[i];
356 netdev->dev_addr[0] = *(p + 5);
357 netdev->dev_addr[1] = *(p + 4);
358 netdev->dev_addr[2] = *(p + 3);
359 netdev->dev_addr[3] = *(p + 2);
360 netdev->dev_addr[4] = *(p + 1);
361 netdev->dev_addr[5] = *(p + 0);
362
363 memcpy(netdev->perm_addr, netdev->dev_addr,
364 netdev->addr_len);
365 if (!is_valid_ether_addr(netdev->perm_addr)) {
366 printk(KERN_ERR "%s: Bad MAC address "
367 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
368 netxen_nic_driver_name,
369 netdev->dev_addr[0],
370 netdev->dev_addr[1],
371 netdev->dev_addr[2],
372 netdev->dev_addr[3],
373 netdev->dev_addr[4],
374 netdev->dev_addr[5]);
375 } else {
376 if (adapter->ops->macaddr_set)
377 adapter->ops->macaddr_set(port,
378 netdev->
379 dev_addr);
380 }
381 }
382 INIT_WORK(&adapter->tx_timeout_task,
383 (void (*)(void *))netxen_tx_timeout_task, netdev);
384 netif_carrier_off(netdev);
385 netif_stop_queue(netdev);
386
387 if ((err = register_netdev(netdev))) {
388 printk(KERN_ERR "%s: register_netdev failed port #%d"
389 " aborting\n", netxen_nic_driver_name, i + 1);
390 err = -EIO;
391 free_netdev(netdev);
392 goto err_out_free_dev;
393 }
394 adapter->port_count++;
395 adapter->active_ports = 0;
396 adapter->port[i] = port;
397 }
398
399 /*
400 * delay a while to ensure that the Pegs are up & running.
401 * Otherwise, we might see some flaky behaviour.
402 */
403 udelay(100);
404
405 switch (adapter->ahw.board_type) {
406 case NETXEN_NIC_GBE:
407 printk("%s: QUAD GbE board initialized\n",
408 netxen_nic_driver_name);
409 break;
410
411 case NETXEN_NIC_XGBE:
412 printk("%s: XGbE board initialized\n", netxen_nic_driver_name);
413 break;
414 }
415
416 adapter->driver_mismatch = 0;
417
418 return 0;
419
420 err_out_free_dev:
421 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
422 pci_disable_msi(pdev);
423 for (i = 0; i < adapter->port_count; i++) {
424 port = adapter->port[i];
425 if ((port) && (port->netdev)) {
426 unregister_netdev(port->netdev);
427 free_netdev(port->netdev);
428 }
429 }
430 kfree(adapter->ops);
431
432 err_out_free_rx_buffer:
433 for (i = 0; i < MAX_RCV_CTX; ++i) {
434 recv_ctx = &adapter->recv_ctx[i];
435 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
436 rcv_desc = &recv_ctx->rcv_desc[ring];
437 if (rcv_desc->rx_buf_arr != NULL) {
438 vfree(rcv_desc->rx_buf_arr);
439 rcv_desc->rx_buf_arr = NULL;
440 }
441 }
442 }
443
444 vfree(cmd_buf_arr);
445
446 kfree(adapter->port);
447
448 err_out_free_adapter:
449 pci_set_drvdata(pdev, NULL);
450 kfree(adapter);
451
452 err_out_iounmap:
453 iounmap(mem_ptr0);
454 iounmap(mem_ptr1);
455 iounmap(mem_ptr2);
456
457 err_out_free_res:
458 pci_release_regions(pdev);
459 err_out_disable_pdev:
460 pci_disable_device(pdev);
461 return err;
462}
463
464static void __devexit netxen_nic_remove(struct pci_dev *pdev)
465{
466 struct netxen_adapter *adapter;
467 struct netxen_port *port;
468 struct netxen_rx_buffer *buffer;
469 struct netxen_recv_context *recv_ctx;
470 struct netxen_rcv_desc_ctx *rcv_desc;
471 int i;
472 int ctxid, ring;
473
474 adapter = pci_get_drvdata(pdev);
475 if (adapter == NULL)
476 return;
477
478 netxen_nic_stop_all_ports(adapter);
479 /* leave the hw in the same state as reboot */
480 netxen_pinit_from_rom(adapter, 0);
481 udelay(500);
482 netxen_load_firmware(adapter);
483
484 if ((adapter->flags & NETXEN_NIC_MSI_ENABLED))
485 netxen_nic_disable_int(adapter);
486
487 udelay(500); /* Delay for a while to drain the DMA engines */
488 for (i = 0; i < adapter->port_count; i++) {
489 port = adapter->port[i];
490 if ((port) && (port->netdev)) {
491 unregister_netdev(port->netdev);
492 free_netdev(port->netdev);
493 }
494 }
495
496 if ((adapter->flags & NETXEN_NIC_MSI_ENABLED))
497 pci_disable_msi(pdev);
498 pci_set_drvdata(pdev, NULL);
499 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC)
500 netxen_free_hw_resources(adapter);
501
502 iounmap(adapter->ahw.pci_base0);
503 iounmap(adapter->ahw.pci_base1);
504 iounmap(adapter->ahw.pci_base2);
505
506 pci_release_regions(pdev);
507 pci_disable_device(pdev);
508
509 for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) {
510 recv_ctx = &adapter->recv_ctx[ctxid];
511 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
512 rcv_desc = &recv_ctx->rcv_desc[ring];
513 for (i = 0; i < rcv_desc->max_rx_desc_count; ++i) {
514 buffer = &(rcv_desc->rx_buf_arr[i]);
515 if (buffer->state == NETXEN_BUFFER_FREE)
516 continue;
517 pci_unmap_single(pdev, buffer->dma,
518 rcv_desc->dma_size,
519 PCI_DMA_FROMDEVICE);
520 if (buffer->skb != NULL)
521 dev_kfree_skb_any(buffer->skb);
522 }
523 vfree(rcv_desc->rx_buf_arr);
524 }
525 }
526
527 vfree(adapter->cmd_buf_arr);
528 kfree(adapter->ops);
529 kfree(adapter);
530}
531
532/*
533 * Called when a network interface is made active
534 * @returns 0 on success, negative value on failure
535 */
536static int netxen_nic_open(struct net_device *netdev)
537{
538 struct netxen_port *port = netdev_priv(netdev);
539 struct netxen_adapter *adapter = port->adapter;
540 int err = 0;
541 int ctx, ring;
542
543 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) {
544 err = netxen_init_firmware(adapter);
545 if (err != 0) {
546 printk(KERN_ERR "Failed to init firmware\n");
547 return -EIO;
548 }
549 netxen_nic_flash_print(adapter);
550
551 /* setup all the resources for the Phantom... */
552 /* this include the descriptors for rcv, tx, and status */
553 netxen_nic_clear_stats(adapter);
554 err = netxen_nic_hw_resources(adapter);
555 if (err) {
556 printk(KERN_ERR "Error in setting hw resources:%d\n",
557 err);
558 return err;
559 }
560 if (adapter->ops->init_port
561 && adapter->ops->init_port(adapter, port->portnum) != 0) {
562 printk(KERN_ERR "%s: Failed to initialize port %d\n",
563 netxen_nic_driver_name, port->portnum);
564 netxen_free_hw_resources(adapter);
565 return -EIO;
566 }
567 if (adapter->ops->init_niu)
568 adapter->ops->init_niu(adapter);
569 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
570 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
571 netxen_post_rx_buffers(adapter, ctx, ring);
572 }
573 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
574 }
575 adapter->active_ports++;
576 if (adapter->active_ports == 1) {
577 err = request_irq(adapter->ahw.pdev->irq, &netxen_intr,
578 SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name,
579 adapter);
580 if (err) {
581 printk(KERN_ERR "request_irq failed with: %d\n", err);
582 adapter->active_ports--;
583 return err;
584 }
585 adapter->irq = adapter->ahw.pdev->irq;
586 if (!adapter->driver_mismatch)
587 mod_timer(&adapter->watchdog_timer, jiffies);
588
589 netxen_nic_enable_int(adapter);
590 }
591
592 /* Done here again so that even if phantom sw overwrote it,
593 * we set it */
594 if (adapter->ops->macaddr_set)
595 adapter->ops->macaddr_set(port, netdev->dev_addr);
596 netxen_nic_set_link_parameters(port);
597
598 netxen_nic_set_multi(netdev);
599 if (!adapter->driver_mismatch)
600 netif_start_queue(netdev);
601
602 return 0;
603}
604
605/*
606 * netxen_nic_close - Disables a network interface entry point
607 */
608static int netxen_nic_close(struct net_device *netdev)
609{
610 struct netxen_port *port = netdev_priv(netdev);
611 struct netxen_adapter *adapter = port->adapter;
612 int i, j;
613 struct netxen_cmd_buffer *cmd_buff;
614 struct netxen_skb_frag *buffrag;
615
616 netif_carrier_off(netdev);
617 netif_stop_queue(netdev);
618
619 adapter->active_ports--;
620
621 if (!adapter->active_ports) {
622 netxen_nic_disable_int(adapter);
623 if (adapter->irq)
624 free_irq(adapter->irq, adapter);
625 cmd_buff = adapter->cmd_buf_arr;
626 for (i = 0; i < adapter->max_tx_desc_count; i++) {
627 buffrag = cmd_buff->frag_array;
628 if (buffrag->dma) {
629 pci_unmap_single(port->pdev, buffrag->dma,
630 buffrag->length,
631 PCI_DMA_TODEVICE);
632 buffrag->dma = (u64) NULL;
633 }
634 for (j = 0; j < cmd_buff->frag_count; j++) {
635 buffrag++;
636 if (buffrag->dma) {
637 pci_unmap_page(port->pdev,
638 buffrag->dma,
639 buffrag->length,
640 PCI_DMA_TODEVICE);
641 buffrag->dma = (u64) NULL;
642 }
643 }
644 /* Free the skb we received in netxen_nic_xmit_frame */
645 if (cmd_buff->skb) {
646 dev_kfree_skb_any(cmd_buff->skb);
647 cmd_buff->skb = NULL;
648 }
649 cmd_buff++;
650 }
651 del_timer_sync(&adapter->watchdog_timer);
652 }
653
654 return 0;
655}
656
657static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
658{
659 struct netxen_port *port = netdev_priv(netdev);
660 struct netxen_adapter *adapter = port->adapter;
661 struct netxen_hardware_context *hw = &adapter->ahw;
662 unsigned int first_seg_len = skb->len - skb->data_len;
663 struct netxen_skb_frag *buffrag;
664 unsigned int i;
665
666 u32 producer = 0;
667 u32 saved_producer = 0;
668 struct cmd_desc_type0 *hwdesc;
669 int k;
670 struct netxen_cmd_buffer *pbuf = NULL;
671 unsigned int tries = 0;
672 static int dropped_packet = 0;
673 int frag_count;
674 u32 local_producer = 0;
675 u32 max_tx_desc_count = 0;
676 u32 last_cmd_consumer = 0;
677 int no_of_desc;
678
679 port->stats.xmitcalled++;
680 frag_count = skb_shinfo(skb)->nr_frags + 1;
681
682 if (unlikely(skb->len <= 0)) {
683 dev_kfree_skb_any(skb);
684 port->stats.badskblen++;
685 return NETDEV_TX_OK;
686 }
687
688 if (frag_count > MAX_BUFFERS_PER_CMD) {
689 printk("%s: %s netxen_nic_xmit_frame: frag_count (%d)"
690 "too large, can handle only %d frags\n",
691 netxen_nic_driver_name, netdev->name,
692 frag_count, MAX_BUFFERS_PER_CMD);
693 port->stats.txdropped++;
694 if ((++dropped_packet & 0xff) == 0xff)
695 printk("%s: %s droppped packets = %d\n",
696 netxen_nic_driver_name, netdev->name,
697 dropped_packet);
698
699 return NETDEV_TX_OK;
700 }
701
702 /*
703 * Everything is set up. Now, we just need to transmit it out.
704 * Note that we have to copy the contents of buffer over to
705 * right place. Later on, this can be optimized out by de-coupling the
706 * producer index from the buffer index.
707 */
708 retry_getting_window:
709 spin_lock_bh(&adapter->tx_lock);
710 if (adapter->total_threads == MAX_XMIT_PRODUCERS) {
711 spin_unlock_bh(&adapter->tx_lock);
712 /*
713 * Yield CPU
714 */
715 if (!in_atomic())
716 schedule();
717 else {
718 for (i = 0; i < 20; i++)
719 cpu_relax(); /*This a nop instr on i386 */
720 }
721 goto retry_getting_window;
722 }
723 local_producer = adapter->cmd_producer;
724 /* There 4 fragments per descriptor */
725 no_of_desc = (frag_count + 3) >> 2;
726 if (netdev->features & NETIF_F_TSO) {
727 if (skb_shinfo(skb)->gso_size > 0) {
728
729 no_of_desc++;
730 if (((skb->nh.iph)->ihl * sizeof(u32)) +
731 ((skb->h.th)->doff * sizeof(u32)) +
732 sizeof(struct ethhdr) >
733 (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) {
734 no_of_desc++;
735 }
736 }
737 }
738 k = adapter->cmd_producer;
739 max_tx_desc_count = adapter->max_tx_desc_count;
740 last_cmd_consumer = adapter->last_cmd_consumer;
741 if ((k + no_of_desc) >=
742 ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count :
743 last_cmd_consumer)) {
744 spin_unlock_bh(&adapter->tx_lock);
745 if (tries == 0) {
746 local_bh_disable();
747 netxen_process_cmd_ring((unsigned long)adapter);
748 local_bh_enable();
749 ++tries;
750 goto retry_getting_window;
751 } else {
752 port->stats.nocmddescriptor++;
753 DPRINTK(ERR, "No command descriptors available,"
754 " producer = %d, consumer = %d count=%llu,"
755 " dropping packet\n", producer,
756 adapter->last_cmd_consumer,
757 port->stats.nocmddescriptor);
758
759 spin_lock_bh(&adapter->tx_lock);
760 netif_stop_queue(netdev);
761 port->flags |= NETXEN_NETDEV_STATUS;
762 spin_unlock_bh(&adapter->tx_lock);
763 return NETDEV_TX_BUSY;
764 }
765 }
766 k = get_index_range(k, max_tx_desc_count, no_of_desc);
767 adapter->cmd_producer = k;
768 adapter->total_threads++;
769 adapter->num_threads++;
770
771 spin_unlock_bh(&adapter->tx_lock);
772 /* Copy the descriptors into the hardware */
773 producer = local_producer;
774 saved_producer = producer;
775 hwdesc = &hw->cmd_desc_head[producer];
776 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
777 /* Take skb->data itself */
778 pbuf = &adapter->cmd_buf_arr[producer];
779 if ((netdev->features & NETIF_F_TSO) && skb_shinfo(skb)->gso_size > 0) {
780 pbuf->mss = skb_shinfo(skb)->gso_size;
781 hwdesc->mss = skb_shinfo(skb)->gso_size;
782 } else {
783 pbuf->mss = 0;
784 hwdesc->mss = 0;
785 }
786 pbuf->no_of_descriptors = no_of_desc;
787 pbuf->total_length = skb->len;
788 pbuf->skb = skb;
789 pbuf->cmd = TX_ETHER_PKT;
790 pbuf->frag_count = frag_count;
791 pbuf->port = port->portnum;
792 buffrag = &pbuf->frag_array[0];
793 buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len,
794 PCI_DMA_TODEVICE);
795 buffrag->length = first_seg_len;
796 CMD_DESC_TOTAL_LENGTH_WRT(hwdesc, skb->len);
797 hwdesc->num_of_buffers = frag_count;
798 hwdesc->opcode = TX_ETHER_PKT;
799
800 CMD_DESC_PORT_WRT(hwdesc, port->portnum);
801 hwdesc->buffer1_length = cpu_to_le16(first_seg_len);
802 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
803
804 for (i = 1, k = 1; i < frag_count; i++, k++) {
805 struct skb_frag_struct *frag;
806 int len, temp_len;
807 unsigned long offset;
808 dma_addr_t temp_dma;
809
810 /* move to next desc. if there is a need */
811 if ((i & 0x3) == 0) {
812 k = 0;
813 producer = get_next_index(producer,
814 adapter->max_tx_desc_count);
815 hwdesc = &hw->cmd_desc_head[producer];
816 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
817 }
818 frag = &skb_shinfo(skb)->frags[i - 1];
819 len = frag->size;
820 offset = frag->page_offset;
821
822 temp_len = len;
823 temp_dma = pci_map_page(port->pdev, frag->page, offset,
824 len, PCI_DMA_TODEVICE);
825
826 buffrag++;
827 buffrag->dma = temp_dma;
828 buffrag->length = temp_len;
829
830 DPRINTK(INFO, "for loop. i=%d k=%d\n", i, k);
831 switch (k) {
832 case 0:
833 hwdesc->buffer1_length = cpu_to_le16(temp_len);
834 hwdesc->addr_buffer1 = cpu_to_le64(temp_dma);
835 break;
836 case 1:
837 hwdesc->buffer2_length = cpu_to_le16(temp_len);
838 hwdesc->addr_buffer2 = cpu_to_le64(temp_dma);
839 break;
840 case 2:
841 hwdesc->buffer3_length = cpu_to_le16(temp_len);
842 hwdesc->addr_buffer3 = cpu_to_le64(temp_dma);
843 break;
844 case 3:
845 hwdesc->buffer4_length = temp_len;
846 hwdesc->addr_buffer4 = cpu_to_le64(temp_dma);
847 break;
848 }
849 frag++;
850 }
851 producer = get_next_index(producer, adapter->max_tx_desc_count);
852
853 /* might change opcode to TX_TCP_LSO */
854 netxen_tso_check(adapter, &hw->cmd_desc_head[saved_producer], skb);
855
856 /* For LSO, we need to copy the MAC/IP/TCP headers into
857 * the descriptor ring
858 */
859 if (hw->cmd_desc_head[saved_producer].opcode == TX_TCP_LSO) {
860 int hdr_len, first_hdr_len, more_hdr;
861 hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length;
862 if (hdr_len > (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) {
863 first_hdr_len =
864 sizeof(struct cmd_desc_type0) - NET_IP_ALIGN;
865 more_hdr = 1;
866 } else {
867 first_hdr_len = hdr_len;
868 more_hdr = 0;
869 }
870 /* copy the MAC/IP/TCP headers to the cmd descriptor list */
871 hwdesc = &hw->cmd_desc_head[producer];
872
873 /* copy the first 64 bytes */
874 memcpy(((void *)hwdesc) + NET_IP_ALIGN,
875 (void *)(skb->data), first_hdr_len);
876 producer = get_next_index(producer, max_tx_desc_count);
877
878 if (more_hdr) {
879 hwdesc = &hw->cmd_desc_head[producer];
880 /* copy the next 64 bytes - should be enough except
881 * for pathological case
882 */
883 memcpy((void *)hwdesc, (void *)(skb->data) +
884 first_hdr_len, hdr_len - first_hdr_len);
885 producer = get_next_index(producer, max_tx_desc_count);
886 }
887 }
888 spin_lock_bh(&adapter->tx_lock);
889 port->stats.txbytes +=
890 CMD_DESC_TOTAL_LENGTH(&hw->cmd_desc_head[saved_producer]);
891 /* Code to update the adapter considering how many producer threads
892 are currently working */
893 if ((--adapter->num_threads) == 0) {
894 /* This is the last thread */
895 u32 crb_producer = adapter->cmd_producer;
896 writel(crb_producer,
897 NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
898 wmb();
899 adapter->total_threads = 0;
900 } else {
901 u32 crb_producer = 0;
902 crb_producer =
903 readl(NETXEN_CRB_NORMALIZE
904 (adapter, CRB_CMD_PRODUCER_OFFSET));
905 if (crb_producer == local_producer) {
906 crb_producer = get_index_range(crb_producer,
907 max_tx_desc_count,
908 no_of_desc);
909 writel(crb_producer,
910 NETXEN_CRB_NORMALIZE(adapter,
911 CRB_CMD_PRODUCER_OFFSET));
912 wmb();
913 }
914 }
915
916 port->stats.xmitfinished++;
917 spin_unlock_bh(&adapter->tx_lock);
918
919 netdev->trans_start = jiffies;
920
921 DPRINTK(INFO, "wrote CMD producer %x to phantom\n", producer);
922
923 DPRINTK(INFO, "Done. Send\n");
924 return NETDEV_TX_OK;
925}
926
927static void netxen_watchdog(unsigned long v)
928{
929 struct netxen_adapter *adapter = (struct netxen_adapter *)v;
930 schedule_work(&adapter->watchdog_task);
931}
932
933static void netxen_tx_timeout(struct net_device *netdev)
934{
935 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev);
936 struct netxen_adapter *adapter = port->adapter;
937
938 schedule_work(&adapter->tx_timeout_task);
939}
940
941static void netxen_tx_timeout_task(struct net_device *netdev)
942{
943 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev);
944 unsigned long flags;
945
946 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
947 netxen_nic_driver_name, netdev->name);
948
949 spin_lock_irqsave(&port->adapter->lock, flags);
950 netxen_nic_close(netdev);
951 netxen_nic_open(netdev);
952 spin_unlock_irqrestore(&port->adapter->lock, flags);
953 netdev->trans_start = jiffies;
954 netif_wake_queue(netdev);
955}
956
957static int
958netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
959{
960 u32 ret = 0;
961
962 DPRINTK(INFO, "Entered handle ISR\n");
963
964 adapter->stats.ints++;
965
966 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
967 int count = 0;
968 u32 mask;
969 netxen_nic_disable_int(adapter);
970 /* Window = 0 or 1 */
971 do {
972 writel(0xffffffff, PCI_OFFSET_SECOND_RANGE(adapter,
973 ISR_INT_TARGET_STATUS));
974 mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR));
975 } while (((mask & 0x80) != 0) && (++count < 32));
976 if ((mask & 0x80) != 0)
977 printk("Could not disable interrupt completely\n");
978
979 }
980 adapter->stats.hostints++;
981
982 if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) {
983 if (netif_rx_schedule_prep(netdev)) {
984 /*
985 * Interrupts are already disabled.
986 */
987 __netif_rx_schedule(netdev);
988 } else {
989 static unsigned int intcount = 0;
990 if ((++intcount & 0xfff) == 0xfff)
991 printk(KERN_ERR
992 "%s: %s interrupt %d while in poll\n",
993 netxen_nic_driver_name, netdev->name,
994 intcount);
995 }
996 ret = 1;
997 }
998
999 if (ret == 0) {
1000 netxen_nic_enable_int(adapter);
1001 }
1002
1003 return ret;
1004}
1005
1006/*
1007 * netxen_intr - Interrupt Handler
1008 * @irq: interrupt number
1009 * data points to adapter stucture (which may be handling more than 1 port
1010 */
1011irqreturn_t netxen_intr(int irq, void *data)
1012{
1013 struct netxen_adapter *adapter;
1014 struct netxen_port *port;
1015 struct net_device *netdev;
1016 int i;
1017
1018 if (unlikely(!irq)) {
1019 return IRQ_NONE; /* Not our interrupt */
1020 }
1021
1022 adapter = (struct netxen_adapter *)data;
1023 for (i = 0; i < adapter->ahw.max_ports; i++) {
1024 port = adapter->port[i];
1025 netdev = port->netdev;
1026
1027 /* process our status queue (for all 4 ports) */
1028 netxen_handle_int(adapter, netdev);
1029 }
1030
1031 return IRQ_HANDLED;
1032}
1033
1034static int netxen_nic_poll(struct net_device *netdev, int *budget)
1035{
1036 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev);
1037 struct netxen_adapter *adapter = port->adapter;
1038 int work_to_do = min(*budget, netdev->quota);
1039 int done = 1;
1040 int ctx;
1041 int this_work_done;
1042
1043 DPRINTK(INFO, "polling for %d descriptors\n", *budget);
1044 port->stats.polled++;
1045
1046 adapter->work_done = 0;
1047 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
1048 /*
1049 * Fairness issue. This will give undue weight to the
1050 * receive context 0.
1051 */
1052
1053 /*
1054 * To avoid starvation, we give each of our receivers,
1055 * a fraction of the quota. Sometimes, it might happen that we
1056 * have enough quota to process every packet, but since all the
1057 * packets are on one context, it gets only half of the quota,
1058 * and ends up not processing it.
1059 */
1060 this_work_done = netxen_process_rcv_ring(adapter, ctx,
1061 work_to_do /
1062 MAX_RCV_CTX);
1063 adapter->work_done += this_work_done;
1064 }
1065
1066 netdev->quota -= adapter->work_done;
1067 *budget -= adapter->work_done;
1068
1069 if (adapter->work_done >= work_to_do
1070 && netxen_nic_rx_has_work(adapter) != 0)
1071 done = 0;
1072
1073 netxen_process_cmd_ring((unsigned long)adapter);
1074
1075 DPRINTK(INFO, "new work_done: %d work_to_do: %d\n",
1076 adapter->work_done, work_to_do);
1077 if (done) {
1078 netif_rx_complete(netdev);
1079 netxen_nic_enable_int(adapter);
1080 }
1081
1082 return !done;
1083}
1084
1085#ifdef CONFIG_NET_POLL_CONTROLLER
1086static void netxen_nic_poll_controller(struct net_device *netdev)
1087{
1088 struct netxen_port *port = netdev_priv(netdev);
1089 struct netxen_adapter *adapter = port->adapter;
1090 disable_irq(adapter->irq);
1091 netxen_intr(adapter->irq, adapter);
1092 enable_irq(adapter->irq);
1093}
1094#endif
1095/*
1096 * netxen_nic_ioctl () We provide the tcl/phanmon support through these
1097 * ioctls.
1098 */
1099static int
1100netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1101{
1102 int err = 0;
1103 unsigned long nr_bytes = 0;
1104 struct netxen_port *port = netdev_priv(netdev);
1105 struct netxen_adapter *adapter = port->adapter;
1106 char dev_name[NETXEN_NIC_NAME_LEN];
1107
1108 DPRINTK(INFO, "doing ioctl for %s\n", netdev->name);
1109 switch (cmd) {
1110 case NETXEN_NIC_CMD:
1111 err = netxen_nic_do_ioctl(adapter, (void *)ifr->ifr_data, port);
1112 break;
1113
1114 case NETXEN_NIC_NAME:
1115 DPRINTK(INFO, "ioctl cmd for NetXen\n");
1116 if (ifr->ifr_data) {
1117 sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP,
1118 port->portnum);
1119 nr_bytes = copy_to_user((char *)ifr->ifr_data, dev_name,
1120 NETXEN_NIC_NAME_LEN);
1121 if (nr_bytes)
1122 err = -EIO;
1123
1124 }
1125 break;
1126
1127 default:
1128 DPRINTK(INFO, "ioctl cmd %x not supported\n", cmd);
1129 err = -EOPNOTSUPP;
1130 break;
1131 }
1132
1133 return err;
1134}
1135
1136static struct pci_driver netxen_driver = {
1137 .name = netxen_nic_driver_name,
1138 .id_table = netxen_pci_tbl,
1139 .probe = netxen_nic_probe,
1140 .remove = __devexit_p(netxen_nic_remove)
1141};
1142
1143/* Driver Registration on NetXen card */
1144
1145static int __init netxen_init_module(void)
1146{
1147 return pci_module_init(&netxen_driver);
1148}
1149
1150module_init(netxen_init_module);
1151
1152static void __exit netxen_exit_module(void)
1153{
1154 /*
1155 * Wait for some time to allow the dma to drain, if any.
1156 */
1157 mdelay(5);
1158 pci_unregister_driver(&netxen_driver);
1159}
1160
1161module_exit(netxen_exit_module);
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
new file mode 100644
index 000000000000..7950a04532e6
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -0,0 +1,894 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 *
29 *
30 * Provides access to the Network Interface Unit h/w block.
31 *
32 */
33
34#include "netxen_nic.h"
35
36#define NETXEN_GB_MAC_SOFT_RESET 0x80000000
37#define NETXEN_GB_MAC_RESET_PROT_BLK 0x000F0000
38#define NETXEN_GB_MAC_ENABLE_TX_RX 0x00000005
39#define NETXEN_GB_MAC_PAUSED_FRMS 0x00000020
40
41static long phy_lock_timeout = 100000000;
42
43static inline int phy_lock(void)
44{
45 int i;
46 int done = 0, timeout = 0;
47
48 while (!done) {
49 done = readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_LOCK));
50 if (done == 1)
51 break;
52 if (timeout >= phy_lock_timeout) {
53 return -1;
54 }
55 timeout++;
56 if (!in_atomic())
57 schedule();
58 else {
59 for (i = 0; i < 20; i++)
60 cpu_relax();
61 }
62 }
63
64 writel(NETXEN_PHY_LOCK_ID, (void __iomem *)PHY_LOCK_DRIVER);
65 return 0;
66}
67
68static inline int phy_unlock(void)
69{
70 readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK));
71 return 0;
72}
73
74/*
75 * netxen_niu_gbe_phy_read - read a register from the GbE PHY via
76 * mii management interface.
77 *
78 * Note: The MII management interface goes through port 0.
79 * Individual phys are addressed as follows:
80 * @param phy [15:8] phy id
81 * @param reg [7:0] register number
82 *
83 * @returns 0 on success
84 * -1 on error
85 *
86 */
87int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
88 long reg, __le32 * readval)
89{
90 long timeout = 0;
91 long result = 0;
92 long restore = 0;
93 __le32 address;
94 __le32 command;
95 __le32 status;
96 __le32 mac_cfg0;
97
98 if (phy_lock() != 0) {
99 return -1;
100 }
101
102 /*
103 * MII mgmt all goes through port 0 MAC interface,
104 * so it cannot be in reset
105 */
106
107 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
108 &mac_cfg0, 4))
109 return -EIO;
110 if (netxen_gb_get_soft_reset(mac_cfg0)) {
111 __le32 temp;
112 temp = 0;
113 netxen_gb_tx_reset_pb(temp);
114 netxen_gb_rx_reset_pb(temp);
115 netxen_gb_tx_reset_mac(temp);
116 netxen_gb_rx_reset_mac(temp);
117 if (netxen_nic_hw_write_wx(adapter,
118 NETXEN_NIU_GB_MAC_CONFIG_0(0),
119 &temp, 4))
120 return -EIO;
121 restore = 1;
122 }
123
124 address = 0;
125 netxen_gb_mii_mgmt_reg_addr(address, reg);
126 netxen_gb_mii_mgmt_phy_addr(address, phy);
127 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
128 &address, 4))
129 return -EIO;
130 command = 0; /* turn off any prior activity */
131 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
132 &command, 4))
133 return -EIO;
134 /* send read command */
135 netxen_gb_mii_mgmt_set_read_cycle(command);
136 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
137 &command, 4))
138 return -EIO;
139
140 status = 0;
141 do {
142 if (netxen_nic_hw_read_wx(adapter,
143 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
144 &status, 4))
145 return -EIO;
146 timeout++;
147 } while ((netxen_get_gb_mii_mgmt_busy(status)
148 || netxen_get_gb_mii_mgmt_notvalid(status))
149 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
150
151 if (timeout < NETXEN_NIU_PHY_WAITMAX) {
152 if (netxen_nic_hw_read_wx(adapter,
153 NETXEN_NIU_GB_MII_MGMT_STATUS(0),
154 readval, 4))
155 return -EIO;
156 result = 0;
157 } else
158 result = -1;
159
160 if (restore)
161 if (netxen_nic_hw_write_wx(adapter,
162 NETXEN_NIU_GB_MAC_CONFIG_0(0),
163 &mac_cfg0, 4))
164 return -EIO;
165 phy_unlock();
166 return result;
167}
168
169/*
170 * netxen_niu_gbe_phy_write - write a register to the GbE PHY via
171 * mii management interface.
172 *
173 * Note: The MII management interface goes through port 0.
174 * Individual phys are addressed as follows:
175 * @param phy [15:8] phy id
176 * @param reg [7:0] register number
177 *
178 * @returns 0 on success
179 * -1 on error
180 *
181 */
182int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
183 long phy, long reg, __le32 val)
184{
185 long timeout = 0;
186 long result = 0;
187 long restore = 0;
188 __le32 address;
189 __le32 command;
190 __le32 status;
191 __le32 mac_cfg0;
192
193 /*
194 * MII mgmt all goes through port 0 MAC interface, so it
195 * cannot be in reset
196 */
197
198 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
199 &mac_cfg0, 4))
200 return -EIO;
201 if (netxen_gb_get_soft_reset(mac_cfg0)) {
202 __le32 temp;
203 temp = 0;
204 netxen_gb_tx_reset_pb(temp);
205 netxen_gb_rx_reset_pb(temp);
206 netxen_gb_tx_reset_mac(temp);
207 netxen_gb_rx_reset_mac(temp);
208
209 if (netxen_nic_hw_write_wx(adapter,
210 NETXEN_NIU_GB_MAC_CONFIG_0(0),
211 &temp, 4))
212 return -EIO;
213 restore = 1;
214 }
215
216 command = 0; /* turn off any prior activity */
217 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_COMMAND(0),
218 &command, 4))
219 return -EIO;
220
221 address = 0;
222 netxen_gb_mii_mgmt_reg_addr(address, reg);
223 netxen_gb_mii_mgmt_phy_addr(address, phy);
224 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR(0),
225 &address, 4))
226 return -EIO;
227
228 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CTRL(0),
229 &val, 4))
230 return -EIO;
231
232 status = 0;
233 do {
234 if (netxen_nic_hw_read_wx(adapter,
235 NETXEN_NIU_GB_MII_MGMT_INDICATE(0),
236 &status, 4))
237 return -EIO;
238 timeout++;
239 } while ((netxen_get_gb_mii_mgmt_busy(status))
240 && (timeout++ < NETXEN_NIU_PHY_WAITMAX));
241
242 if (timeout < NETXEN_NIU_PHY_WAITMAX)
243 result = 0;
244 else
245 result = -EIO;
246
247 /* restore the state of port 0 MAC in case we tampered with it */
248 if (restore)
249 if (netxen_nic_hw_write_wx(adapter,
250 NETXEN_NIU_GB_MAC_CONFIG_0(0),
251 &mac_cfg0, 4))
252 return -EIO;
253
254 return result;
255}
256
257int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter,
258 int port)
259{
260 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x3f);
261 return 0;
262}
263
264int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter,
265 int port)
266{
267 int result = 0;
268 __le32 enable = 0;
269 netxen_set_phy_int_link_status_changed(enable);
270 netxen_set_phy_int_autoneg_completed(enable);
271 netxen_set_phy_int_speed_changed(enable);
272
273 if (0 !=
274 netxen_niu_gbe_phy_write(adapter, port,
275 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE,
276 enable))
277 result = -EIO;
278
279 return result;
280}
281
282int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter,
283 int port)
284{
285 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_INT_MASK, 0x7f);
286 return 0;
287}
288
289int netxen_niu_gbe_disable_phy_interrupts(struct netxen_adapter *adapter,
290 int port)
291{
292 int result = 0;
293 if (0 !=
294 netxen_niu_gbe_phy_write(adapter, port,
295 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_ENABLE, 0))
296 result = -EIO;
297
298 return result;
299}
300
301int netxen_niu_xgbe_clear_phy_interrupts(struct netxen_adapter *adapter,
302 int port)
303{
304 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_ACTIVE_INT, -1);
305 return 0;
306}
307
308int netxen_niu_gbe_clear_phy_interrupts(struct netxen_adapter *adapter,
309 int port)
310{
311 int result = 0;
312 if (0 !=
313 netxen_niu_gbe_phy_write(adapter, port,
314 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
315 -EIO))
316 result = -EIO;
317
318 return result;
319}
320
321/*
322 * netxen_niu_gbe_set_mii_mode- Set 10/100 Mbit Mode for GbE MAC
323 *
324 */
325void netxen_niu_gbe_set_mii_mode(struct netxen_adapter *adapter,
326 int port, long enable)
327{
328 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
329 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
330 0x80000000);
331 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
332 0x0000f0025);
333 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
334 0xf1ff);
335 netxen_crb_writelit_adapter(adapter,
336 NETXEN_NIU_GB0_GMII_MODE + (port << 3), 0);
337 netxen_crb_writelit_adapter(adapter,
338 NETXEN_NIU_GB0_MII_MODE + (port << 3), 1);
339 netxen_crb_writelit_adapter(adapter,
340 (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
341 netxen_crb_writelit_adapter(adapter,
342 NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
343
344 if (enable) {
345 /*
346 * Do NOT enable flow control until a suitable solution for
347 * shutting down pause frames is found.
348 */
349 netxen_crb_writelit_adapter(adapter,
350 NETXEN_NIU_GB_MAC_CONFIG_0(port),
351 0x5);
352 }
353
354 if (netxen_niu_gbe_enable_phy_interrupts(adapter, port))
355 printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
356 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
357 printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
358}
359
360/*
361 * netxen_niu_gbe_set_gmii_mode- Set GbE Mode for GbE MAC
362 */
363void netxen_niu_gbe_set_gmii_mode(struct netxen_adapter *adapter,
364 int port, long enable)
365{
366 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_MODE, 0x2);
367 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
368 0x80000000);
369 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
370 0x0000f0025);
371 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB_MAC_CONFIG_1(port),
372 0xf2ff);
373 netxen_crb_writelit_adapter(adapter,
374 NETXEN_NIU_GB0_MII_MODE + (port << 3), 0);
375 netxen_crb_writelit_adapter(adapter,
376 NETXEN_NIU_GB0_GMII_MODE + (port << 3), 1);
377 netxen_crb_writelit_adapter(adapter,
378 (NETXEN_NIU_GB0_HALF_DUPLEX + port * 4), 0);
379 netxen_crb_writelit_adapter(adapter,
380 NETXEN_NIU_GB_MII_MGMT_CONFIG(port), 0x7);
381
382 if (enable) {
383 /*
384 * Do NOT enable flow control until a suitable solution for
385 * shutting down pause frames is found.
386 */
387 netxen_crb_writelit_adapter(adapter,
388 NETXEN_NIU_GB_MAC_CONFIG_0(port),
389 0x5);
390 }
391
392 if (netxen_niu_gbe_enable_phy_interrupts(adapter, port))
393 printk(KERN_ERR PFX "ERROR enabling PHY interrupts\n");
394 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
395 printk(KERN_ERR PFX "ERROR clearing PHY interrupts\n");
396}
397
398int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
399{
400 int result = 0;
401 __le32 status;
402 if (adapter->ops->disable_phy_interrupts)
403 adapter->ops->disable_phy_interrupts(adapter, port);
404 mdelay(2);
405
406 if (0 ==
407 netxen_niu_gbe_phy_read(adapter, port,
408 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
409 (__le32 *) & status)) {
410 if (netxen_get_phy_link(status)) {
411 if (netxen_get_phy_speed(status) == 2) {
412 netxen_niu_gbe_set_gmii_mode(adapter, port, 1);
413 } else if ((netxen_get_phy_speed(status) == 1)
414 || (netxen_get_phy_speed(status) == 0)) {
415 netxen_niu_gbe_set_mii_mode(adapter, port, 1);
416 } else {
417 result = -1;
418 }
419
420 } else {
421 /*
422 * We don't have link. Cable must be unconnected.
423 * Enable phy interrupts so we take action when
424 * plugged in.
425 */
426
427 netxen_crb_writelit_adapter(adapter,
428 NETXEN_NIU_GB_MAC_CONFIG_0
429 (port),
430 NETXEN_GB_MAC_SOFT_RESET);
431 netxen_crb_writelit_adapter(adapter,
432 NETXEN_NIU_GB_MAC_CONFIG_0
433 (port),
434 NETXEN_GB_MAC_RESET_PROT_BLK
435 | NETXEN_GB_MAC_ENABLE_TX_RX
436 |
437 NETXEN_GB_MAC_PAUSED_FRMS);
438 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
439 printk(KERN_ERR PFX
440 "ERROR clearing PHY interrupts\n");
441 if (netxen_niu_gbe_enable_phy_interrupts(adapter, port))
442 printk(KERN_ERR PFX
443 "ERROR enabling PHY interrupts\n");
444 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
445 printk(KERN_ERR PFX
446 "ERROR clearing PHY interrupts\n");
447 result = -1;
448 }
449 } else {
450 result = -EIO;
451 }
452 return result;
453}
454
455int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
456{
457 long reg = 0, ret = 0;
458
459 if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) {
460 netxen_crb_writelit_adapter(adapter,
461 NETXEN_NIU_XG1_CONFIG_0, 0x5);
462 /* XXX hack for Mez cards: both ports in promisc mode */
463 netxen_nic_hw_read_wx(adapter,
464 NETXEN_NIU_XGE_CONFIG_1, &reg, 4);
465 reg = (reg | 0x2000UL);
466 netxen_crb_writelit_adapter(adapter,
467 NETXEN_NIU_XGE_CONFIG_1, reg);
468 reg = 0;
469 netxen_nic_hw_read_wx(adapter,
470 NETXEN_NIU_XG1_CONFIG_1, &reg, 4);
471 reg = (reg | 0x2000UL);
472 netxen_crb_writelit_adapter(adapter,
473 NETXEN_NIU_XG1_CONFIG_1, reg);
474 }
475
476 return ret;
477}
478
479/*
480 * netxen_niu_gbe_handle_phy_interrupt - Handles GbE PHY interrupts
481 * @param enable 0 means don't enable the port
482 * 1 means enable (or re-enable) the port
483 */
484int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter,
485 int port, long enable)
486{
487 int result = 0;
488 __le32 int_src;
489
490 printk(KERN_INFO PFX "NETXEN: Handling PHY interrupt on port %d"
491 " (device enable = %d)\n", (int)port, (int)enable);
492
493 /*
494 * The read of the PHY INT status will clear the pending
495 * interrupt status
496 */
497 if (netxen_niu_gbe_phy_read(adapter, port,
498 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
499 &int_src) != 0)
500 result = -EINVAL;
501 else {
502 printk(KERN_INFO PFX "PHY Interrupt source = 0x%x \n", int_src);
503 if (netxen_get_phy_int_jabber(int_src))
504 printk(KERN_INFO PFX "jabber Interrupt ");
505 if (netxen_get_phy_int_polarity_changed(int_src))
506 printk(KERN_INFO PFX "polarity changed ");
507 if (netxen_get_phy_int_energy_detect(int_src))
508 printk(KERN_INFO PFX "energy detect \n");
509 if (netxen_get_phy_int_downshift(int_src))
510 printk(KERN_INFO PFX "downshift \n");
511 if (netxen_get_phy_int_mdi_xover_changed(int_src))
512 printk(KERN_INFO PFX "mdi_xover_changed ");
513 if (netxen_get_phy_int_fifo_over_underflow(int_src))
514 printk(KERN_INFO PFX "fifo_over_underflow ");
515 if (netxen_get_phy_int_false_carrier(int_src))
516 printk(KERN_INFO PFX "false_carrier ");
517 if (netxen_get_phy_int_symbol_error(int_src))
518 printk(KERN_INFO PFX "symbol_error ");
519 if (netxen_get_phy_int_autoneg_completed(int_src))
520 printk(KERN_INFO PFX "autoneg_completed ");
521 if (netxen_get_phy_int_page_received(int_src))
522 printk(KERN_INFO PFX "page_received ");
523 if (netxen_get_phy_int_duplex_changed(int_src))
524 printk(KERN_INFO PFX "duplex_changed ");
525 if (netxen_get_phy_int_autoneg_error(int_src))
526 printk(KERN_INFO PFX "autoneg_error ");
527 if ((netxen_get_phy_int_speed_changed(int_src))
528 || (netxen_get_phy_int_link_status_changed(int_src))) {
529 __le32 status;
530
531 printk(KERN_INFO PFX
532 "speed_changed or link status changed");
533 if (netxen_niu_gbe_phy_read
534 (adapter, port,
535 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
536 &status) == 0) {
537 if (netxen_get_phy_speed(status) == 2) {
538 printk
539 (KERN_INFO PFX "Link speed changed"
540 " to 1000 Mbps\n");
541 netxen_niu_gbe_set_gmii_mode(adapter,
542 port,
543 enable);
544 } else if (netxen_get_phy_speed(status) == 1) {
545 printk
546 (KERN_INFO PFX "Link speed changed"
547 " to 100 Mbps\n");
548 netxen_niu_gbe_set_mii_mode(adapter,
549 port,
550 enable);
551 } else if (netxen_get_phy_speed(status) == 0) {
552 printk
553 (KERN_INFO PFX "Link speed changed"
554 " to 10 Mbps\n");
555 netxen_niu_gbe_set_mii_mode(adapter,
556 port,
557 enable);
558 } else {
559 printk(KERN_ERR PFX "ERROR reading"
560 "PHY status. Illegal speed.\n");
561 result = -1;
562 }
563 } else {
564 printk(KERN_ERR PFX
565 "ERROR reading PHY status.\n");
566 result = -1;
567 }
568
569 }
570 printk(KERN_INFO "\n");
571 }
572 return result;
573}
574
575/*
576 * Return the current station MAC address.
577 * Note that the passed-in value must already be in network byte order.
578 */
579int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
580 int phy, netxen_ethernet_macaddr_t * addr)
581{
582 u64 result = 0;
583 __le32 stationhigh;
584 __le32 stationlow;
585
586 if (addr == NULL)
587 return -EINVAL;
588 if ((phy < 0) || (phy > 3))
589 return -EINVAL;
590
591 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy),
592 &stationhigh, 4))
593 return -EIO;
594 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy),
595 &stationlow, 4))
596 return -EIO;
597
598 result = (u64) netxen_gb_get_stationaddress_low(stationlow);
599 result |= (u64) stationhigh << 16;
600 memcpy(*addr, &result, sizeof(netxen_ethernet_macaddr_t));
601
602 return 0;
603}
604
605/*
606 * Set the station MAC address.
607 * Note that the passed-in value must already be in network byte order.
608 */
609int netxen_niu_macaddr_set(struct netxen_port *port,
610 netxen_ethernet_macaddr_t addr)
611{
612 __le32 temp = 0;
613 struct netxen_adapter *adapter = port->adapter;
614 int phy = port->portnum;
615 unsigned char mac_addr[MAX_ADDR_LEN];
616 int i;
617
618 for (i = 0; i < 10; i++) {
619 memcpy(&temp, addr, 2);
620 temp <<= 16;
621 if (netxen_nic_hw_write_wx
622 (adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &temp, 4))
623 return -EIO;
624
625 temp = 0;
626
627 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
628 if (netxen_nic_hw_write_wx
629 (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &temp, 4))
630 return -2;
631
632 netxen_niu_macaddr_get(adapter, phy,
633 (netxen_ethernet_macaddr_t *) mac_addr);
634 if (memcmp(mac_addr, addr, MAX_ADDR_LEN == 0))
635 break;
636 }
637
638 if (i == 10) {
639 printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
640 netxen_nic_driver_name, port->netdev->name);
641 printk(KERN_ERR "MAC address set: "
642 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
643 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
644
645 printk(KERN_ERR "MAC address get: "
646 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
647 mac_addr[0],
648 mac_addr[1],
649 mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
650 }
651 return 0;
652}
653
654/* Enable a GbE interface */
655int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter,
656 int port, netxen_niu_gbe_ifmode_t mode)
657{
658 __le32 mac_cfg0;
659 __le32 mac_cfg1;
660 __le32 mii_cfg;
661
662 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
663 return -EINVAL;
664
665 mac_cfg0 = 0;
666 netxen_gb_soft_reset(mac_cfg0);
667 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
668 &mac_cfg0, 4))
669 return -EIO;
670 mac_cfg0 = 0;
671 netxen_gb_enable_tx(mac_cfg0);
672 netxen_gb_enable_rx(mac_cfg0);
673 netxen_gb_unset_rx_flowctl(mac_cfg0);
674 netxen_gb_tx_reset_pb(mac_cfg0);
675 netxen_gb_rx_reset_pb(mac_cfg0);
676 netxen_gb_tx_reset_mac(mac_cfg0);
677 netxen_gb_rx_reset_mac(mac_cfg0);
678
679 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
680 &mac_cfg0, 4))
681 return -EIO;
682 mac_cfg1 = 0;
683 netxen_gb_set_preamblelen(mac_cfg1, 0xf);
684 netxen_gb_set_duplex(mac_cfg1);
685 netxen_gb_set_crc_enable(mac_cfg1);
686 netxen_gb_set_padshort(mac_cfg1);
687 netxen_gb_set_checklength(mac_cfg1);
688 netxen_gb_set_hugeframes(mac_cfg1);
689
690 if (mode == NETXEN_NIU_10_100_MB) {
691 netxen_gb_set_intfmode(mac_cfg1, 1);
692 if (netxen_nic_hw_write_wx(adapter,
693 NETXEN_NIU_GB_MAC_CONFIG_1(port),
694 &mac_cfg1, 4))
695 return -EIO;
696
697 /* set mii mode */
698 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_GMII_MODE +
699 (port << 3), 0);
700 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_MII_MODE +
701 (port << 3), 1);
702
703 } else if (mode == NETXEN_NIU_1000_MB) {
704 netxen_gb_set_intfmode(mac_cfg1, 2);
705 if (netxen_nic_hw_write_wx(adapter,
706 NETXEN_NIU_GB_MAC_CONFIG_1(port),
707 &mac_cfg1, 4))
708 return -EIO;
709 /* set gmii mode */
710 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_MII_MODE +
711 (port << 3), 0);
712 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_GB0_GMII_MODE +
713 (port << 3), 1);
714 }
715 mii_cfg = 0;
716 netxen_gb_set_mii_mgmt_clockselect(mii_cfg, 7);
717 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(port),
718 &mii_cfg, 4))
719 return -EIO;
720 mac_cfg0 = 0;
721 netxen_gb_enable_tx(mac_cfg0);
722 netxen_gb_enable_rx(mac_cfg0);
723 netxen_gb_unset_rx_flowctl(mac_cfg0);
724 netxen_gb_unset_tx_flowctl(mac_cfg0);
725
726 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
727 &mac_cfg0, 4))
728 return -EIO;
729 return 0;
730}
731
732/* Disable a GbE interface */
733int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port)
734{
735 __le32 mac_cfg0;
736
737 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
738 return -EINVAL;
739
740 mac_cfg0 = 0;
741 netxen_gb_soft_reset(mac_cfg0);
742 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(port),
743 &mac_cfg0, 4))
744 return -EIO;
745 return 0;
746}
747
748/* Disable an XG interface */
749int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port)
750{
751 __le32 mac_cfg;
752
753 if (port != 0)
754 return -EINVAL;
755
756 mac_cfg = 0;
757 netxen_xg_soft_reset(mac_cfg);
758 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_CONFIG_0,
759 &mac_cfg, 4))
760 return -EIO;
761 return 0;
762}
763
764/* Set promiscuous mode for a GbE interface */
765int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port,
766 netxen_niu_prom_mode_t mode)
767{
768 __le32 reg;
769
770 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
771 return -EINVAL;
772
773 /* save previous contents */
774 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
775 &reg, 4))
776 return -EIO;
777 if (mode == NETXEN_NIU_PROMISC_MODE) {
778 switch (port) {
779 case 0:
780 netxen_clear_gb_drop_gb0(reg);
781 break;
782 case 1:
783 netxen_clear_gb_drop_gb1(reg);
784 break;
785 case 2:
786 netxen_clear_gb_drop_gb2(reg);
787 break;
788 case 3:
789 netxen_clear_gb_drop_gb3(reg);
790 break;
791 default:
792 return -EIO;
793 }
794 } else {
795 switch (port) {
796 case 0:
797 netxen_set_gb_drop_gb0(reg);
798 break;
799 case 1:
800 netxen_set_gb_drop_gb1(reg);
801 break;
802 case 2:
803 netxen_set_gb_drop_gb2(reg);
804 break;
805 case 3:
806 netxen_set_gb_drop_gb3(reg);
807 break;
808 default:
809 return -EIO;
810 }
811 }
812 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_DROP_WRONGADDR,
813 &reg, 4))
814 return -EIO;
815 return 0;
816}
817
818/*
819 * Set the MAC address for an XG port
820 * Note that the passed-in value must already be in network byte order.
821 */
822int netxen_niu_xg_macaddr_set(struct netxen_port *port,
823 netxen_ethernet_macaddr_t addr)
824{
825 __le32 temp = 0;
826 struct netxen_adapter *adapter = port->adapter;
827
828 memcpy(&temp, addr, 2);
829 temp = cpu_to_le32(temp);
830 temp <<= 16;
831 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
832 &temp, 4))
833 return -EIO;
834
835 temp = 0;
836
837 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
838 temp = cpu_to_le32(temp);
839 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
840 &temp, 4))
841 return -EIO;
842
843 return 0;
844}
845
846/*
847 * Return the current station MAC address.
848 * Note that the passed-in value must already be in network byte order.
849 */
850int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy,
851 netxen_ethernet_macaddr_t * addr)
852{
853 __le32 stationhigh;
854 __le32 stationlow;
855 u64 result;
856
857 if (addr == NULL)
858 return -EINVAL;
859 if (phy != 0)
860 return -EINVAL;
861
862 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_HI,
863 &stationhigh, 4))
864 return -EIO;
865 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_STATION_ADDR_0_1,
866 &stationlow, 4))
867 return -EIO;
868
869 result = ((u64) stationlow) >> 16;
870 result |= (u64) stationhigh << 16;
871 memcpy(*addr, &result, sizeof(netxen_ethernet_macaddr_t));
872
873 return 0;
874}
875
876int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
877 int port, netxen_niu_prom_mode_t mode)
878{
879 __le32 reg;
880
881 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
882 return -EINVAL;
883
884 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_XGE_CONFIG_1, &reg, 4))
885 return -EIO;
886 if (mode == NETXEN_NIU_PROMISC_MODE)
887 reg = (reg | 0x2000UL);
888 else
889 reg = (reg & ~0x2000UL);
890
891 netxen_crb_writelit_adapter(adapter, NETXEN_NIU_XGE_CONFIG_1, reg);
892
893 return 0;
894}
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
new file mode 100644
index 000000000000..8181d436783f
--- /dev/null
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -0,0 +1,215 @@
1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * 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,
18 * MA 02111-1307, USA.
19 *
20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE.
22 *
23 * Contact Information:
24 * info@netxen.com
25 * NetXen,
26 * 3965 Freedom Circle, Fourth floor,
27 * Santa Clara, CA 95054
28 */
29
30#ifndef __NIC_PHAN_REG_H_
31#define __NIC_PHAN_REG_H_
32
33/*
34 * CRB Registers or queue message done only at initialization time.
35 */
36
37/*
38 * The following 2 are the base adresses for the CRB registers and their
39 * offsets will be added to get addresses for the index addresses.
40 */
41#define NIC_CRB_BASE_PORT1 NETXEN_CAM_RAM(0x200)
42#define NIC_CRB_BASE_PORT2 NETXEN_CAM_RAM(0x250)
43
44#define NETXEN_NIC_REG(X) (NIC_CRB_BASE_PORT1+(X))
45
46/*
47 * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
48 * which can be read by the Phantom host to get producer/consumer indexes from
49 * Phantom/Casper. If it is not HOST_SHARED_MEMORY, then the following
50 * registers will be used for the addresses of the ring's shared memory
51 * on the Phantom.
52 */
53
54#define CRB_PHAN_CNTRL_LO_OFFSET NETXEN_NIC_REG(0x00)
55#define CRB_PHAN_CNTRL_HI_OFFSET NETXEN_NIC_REG(0x04)
56
57/* point to the indexes */
58#define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08)
59#define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c)
60
61#define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10)
62#define CRB_PAUSE_ADDR_HI NETXEN_NIC_REG(0x14)
63
64/* address of command descriptors in the host memory */
65#define CRB_HOST_CMD_ADDR_HI NETXEN_NIC_REG(0x30)
66#define CRB_HOST_CMD_ADDR_LO NETXEN_NIC_REG(0x34)
67
68/* The following 4 CRB registers are for doing performance coal */
69#define CRB_CMD_INTR_LOOP NETXEN_NIC_REG(0x38)
70#define CRB_CMD_DMA_LOOP NETXEN_NIC_REG(0x3c)
71#define CRB_RCV_INTR_LOOP NETXEN_NIC_REG(0x40)
72#define CRB_RCV_DMA_LOOP NETXEN_NIC_REG(0x44)
73
74/* Needed by the host to find out the state of Phantom's initialization */
75#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x4c)
76#define CRB_CMDPEG_STATE NETXEN_NIC_REG(0x50)
77#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x54)
78
79/* Interrupt coalescing parameters */
80#define CRB_GLOBAL_INT_COAL NETXEN_NIC_REG(0x80)
81#define CRB_INT_COAL_MODE NETXEN_NIC_REG(0x84)
82#define CRB_MAX_RCV_BUFS NETXEN_NIC_REG(0x88)
83#define CRB_TX_INT_THRESHOLD NETXEN_NIC_REG(0x8c)
84#define CRB_RX_PKT_TIMER NETXEN_NIC_REG(0x90)
85#define CRB_TX_PKT_TIMER NETXEN_NIC_REG(0x94)
86#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98)
87#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c)
88#define CRB_INT_THRESH NETXEN_NIC_REG(0xa4)
89
90/* Register for communicating XG link status */
91#define CRB_XG_STATE NETXEN_NIC_REG(0xa0)
92
93/* Register for communicating card temperature */
94/* Upper 16 bits are temperature value. Lower 16 bits are the state */
95#define CRB_TEMP_STATE NETXEN_NIC_REG(0xa8)
96#define nx_get_temp_val(x) ((x) >> 16)
97#define nx_get_temp_state(x) ((x) & 0xffff)
98#define nx_encode_temp(val, state) (((val) << 16) | (state))
99
100/* Debug registers for controlling NIC pkt gen agent */
101#define CRB_AGENT_GO NETXEN_NIC_REG(0xb0)
102#define CRB_AGENT_TX_SIZE NETXEN_NIC_REG(0xb4)
103#define CRB_AGENT_TX_TYPE NETXEN_NIC_REG(0xb8)
104#define CRB_AGENT_TX_ADDR NETXEN_NIC_REG(0xbc)
105#define CRB_AGENT_TX_MSS NETXEN_NIC_REG(0xc0)
106
107/* Debug registers for observing NIC performance */
108#define CRB_TX_STATE NETXEN_NIC_REG(0xd0)
109#define CRB_TX_COUNT NETXEN_NIC_REG(0xd4)
110#define CRB_RX_STATE NETXEN_NIC_REG(0xd8)
111
112/* CRB registers per Rcv Descriptor ring */
113struct netxen_rcv_desc_crb {
114 u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
115 u32 crb_rcv_consumer_offset;
116 u32 crb_globalrcv_ring;
117};
118
119/*
120 * CRB registers used by the receive peg logic. One instance of these
121 * needs to be instantiated per instance of the receive peg.
122 */
123
124struct netxen_recv_crb {
125 struct netxen_rcv_desc_crb rcv_desc_crb[NUM_RCV_DESC_RINGS];
126 u32 crb_rcvstatus_ring;
127 u32 crb_rcv_status_producer;
128 u32 crb_rcv_status_consumer;
129 u32 crb_rcvpeg_state;
130};
131
132#if defined(DEFINE_GLOBAL_RECV_CRB)
133struct netxen_recv_crb recv_crb_registers[] = {
134 /*
135 * Instance 0.
136 */
137 {
138 /* rcv_desc_crb: */
139 {
140 {
141 /* crb_rcv_producer_offset: */
142 NETXEN_NIC_REG(0x18),
143 /* crb_rcv_consumer_offset: */
144 NETXEN_NIC_REG(0x1c),
145 /* crb_gloablrcv_ring: */
146 NETXEN_NIC_REG(0x20),
147 },
148 /* Jumbo frames */
149 {
150 /* crb_rcv_producer_offset: */
151 NETXEN_NIC_REG(0x100),
152 /* crb_rcv_consumer_offset: */
153 NETXEN_NIC_REG(0x104),
154 /* crb_gloablrcv_ring: */
155 NETXEN_NIC_REG(0x108),
156 }
157 },
158 /* crb_rcvstatus_ring: */
159 NETXEN_NIC_REG(0x24),
160 /* crb_rcv_status_producer: */
161 NETXEN_NIC_REG(0x28),
162 /* crb_rcv_status_consumer: */
163 NETXEN_NIC_REG(0x2c),
164 /* crb_rcvpeg_state: */
165 NETXEN_NIC_REG(0x48),
166
167 },
168 /*
169 * Instance 1,
170 */
171 {
172 /* rcv_desc_crb: */
173 {
174 {
175 /* crb_rcv_producer_offset: */
176 NETXEN_NIC_REG(0x80),
177 /* crb_rcv_consumer_offset: */
178 NETXEN_NIC_REG(0x84),
179 /* crb_globalrcv_ring: */
180 NETXEN_NIC_REG(0x88),
181 },
182 /* Jumbo frames */
183 {
184 /* crb_rcv_producer_offset: */
185 NETXEN_NIC_REG(0x10C),
186 /* crb_rcv_consumer_offset: */
187 NETXEN_NIC_REG(0x110),
188 /* crb_globalrcv_ring: */
189 NETXEN_NIC_REG(0x114),
190 }
191 },
192 /* crb_rcvstatus_ring: */
193 NETXEN_NIC_REG(0x8c),
194 /* crb_rcv_status_producer: */
195 NETXEN_NIC_REG(0x90),
196 /* crb_rcv_status_consumer: */
197 NETXEN_NIC_REG(0x94),
198 /* crb_rcvpeg_state: */
199 NETXEN_NIC_REG(0x98),
200 },
201};
202#else
203extern struct netxen_recv_crb recv_crb_registers[];
204#endif /* DEFINE_GLOBAL_RECEIVE_CRB */
205
206/*
207 * Temperature control.
208 */
209enum {
210 NX_TEMP_NORMAL = 0x1, /* Normal operating range */
211 NX_TEMP_WARN, /* Sound alert, temperature getting high */
212 NX_TEMP_PANIC /* Fatal error, hardware has shut down. */
213};
214
215#endif /* __NIC_PHAN_REG_H_ */
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 0c00d182e7fd..c51cc5d8789a 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -1096,7 +1096,6 @@ static void ei_watchdog(u_long arg)
1096 1096
1097 /* Check for pending interrupt with expired latency timer: with 1097 /* Check for pending interrupt with expired latency timer: with
1098 this, we can limp along even if the interrupt is blocked */ 1098 this, we can limp along even if the interrupt is blocked */
1099 outb_p(E8390_NODMA+E8390_PAGE0, nic_base + E8390_CMD);
1100 if (info->stale++ && (inb_p(nic_base + EN0_ISR) & ENISR_ALL)) { 1099 if (info->stale++ && (inb_p(nic_base + EN0_ISR) & ENISR_ALL)) {
1101 if (!info->fast_poll) 1100 if (!info->fast_poll)
1102 printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name); 1101 printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index b79ec0d7480f..f994f129f3d8 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -56,13 +56,19 @@ config SMSC_PHY
56 ---help--- 56 ---help---
57 Currently supports the LAN83C185 PHY 57 Currently supports the LAN83C185 PHY
58 58
59config BROADCOM_PHY
60 tristate "Drivers for Broadcom PHYs"
61 depends on PHYLIB
62 ---help---
63 Currently supports the BCM5411, BCM5421 and BCM5461 PHYs.
64
59config FIXED_PHY 65config FIXED_PHY
60 tristate "Drivers for PHY emulation on fixed speed/link" 66 tristate "Drivers for PHY emulation on fixed speed/link"
61 depends on PHYLIB 67 depends on PHYLIB
62 ---help--- 68 ---help---
63 Adds the driver to PHY layer to cover the boards that do not have any PHY bound, 69 Adds the driver to PHY layer to cover the boards that do not have any PHY bound,
64 but with the ability to manipulate with speed/link in software. The relavant MII 70 but with the ability to manipulate the speed/link in software. The relevant MII
65 speed/duplex parameters could be effectively handled in user-specified fuction. 71 speed/duplex parameters could be effectively handled in a user-specified function.
66 Currently tested with mpc866ads. 72 Currently tested with mpc866ads.
67 73
68config FIXED_MII_10_FDX 74config FIXED_MII_10_FDX
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 320f8323123f..bcd1efbd2a18 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -10,4 +10,5 @@ obj-$(CONFIG_LXT_PHY) += lxt.o
10obj-$(CONFIG_QSEMI_PHY) += qsemi.o 10obj-$(CONFIG_QSEMI_PHY) += qsemi.o
11obj-$(CONFIG_SMSC_PHY) += smsc.o 11obj-$(CONFIG_SMSC_PHY) += smsc.o
12obj-$(CONFIG_VITESSE_PHY) += vitesse.o 12obj-$(CONFIG_VITESSE_PHY) += vitesse.o
13obj-$(CONFIG_BROADCOM_PHY) += broadcom.o
13obj-$(CONFIG_FIXED_PHY) += fixed.o 14obj-$(CONFIG_FIXED_PHY) += fixed.o
diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
new file mode 100644
index 000000000000..29666c85ed55
--- /dev/null
+++ b/drivers/net/phy/broadcom.c
@@ -0,0 +1,175 @@
1/*
2 * drivers/net/phy/broadcom.c
3 *
4 * Broadcom BCM5411, BCM5421 and BCM5461 Gigabit Ethernet
5 * transceivers.
6 *
7 * Copyright (c) 2006 Maciej W. Rozycki
8 *
9 * Inspired by code written by Amy Fong.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16
17#include <linux/module.h>
18#include <linux/phy.h>
19
20#define MII_BCM54XX_ECR 0x10 /* BCM54xx extended control register */
21#define MII_BCM54XX_ECR_IM 0x1000 /* Interrupt mask */
22#define MII_BCM54XX_ECR_IF 0x0800 /* Interrupt force */
23
24#define MII_BCM54XX_ESR 0x11 /* BCM54xx extended status register */
25#define MII_BCM54XX_ESR_IS 0x1000 /* Interrupt status */
26
27#define MII_BCM54XX_ISR 0x1a /* BCM54xx interrupt status register */
28#define MII_BCM54XX_IMR 0x1b /* BCM54xx interrupt mask register */
29#define MII_BCM54XX_INT_CRCERR 0x0001 /* CRC error */
30#define MII_BCM54XX_INT_LINK 0x0002 /* Link status changed */
31#define MII_BCM54XX_INT_SPEED 0x0004 /* Link speed change */
32#define MII_BCM54XX_INT_DUPLEX 0x0008 /* Duplex mode changed */
33#define MII_BCM54XX_INT_LRS 0x0010 /* Local receiver status changed */
34#define MII_BCM54XX_INT_RRS 0x0020 /* Remote receiver status changed */
35#define MII_BCM54XX_INT_SSERR 0x0040 /* Scrambler synchronization error */
36#define MII_BCM54XX_INT_UHCD 0x0080 /* Unsupported HCD negotiated */
37#define MII_BCM54XX_INT_NHCD 0x0100 /* No HCD */
38#define MII_BCM54XX_INT_NHCDL 0x0200 /* No HCD link */
39#define MII_BCM54XX_INT_ANPR 0x0400 /* Auto-negotiation page received */
40#define MII_BCM54XX_INT_LC 0x0800 /* All counters below 128 */
41#define MII_BCM54XX_INT_HC 0x1000 /* Counter above 32768 */
42#define MII_BCM54XX_INT_MDIX 0x2000 /* MDIX status change */
43#define MII_BCM54XX_INT_PSERR 0x4000 /* Pair swap error */
44
45MODULE_DESCRIPTION("Broadcom PHY driver");
46MODULE_AUTHOR("Maciej W. Rozycki");
47MODULE_LICENSE("GPL");
48
49static int bcm54xx_config_init(struct phy_device *phydev)
50{
51 int reg, err;
52
53 reg = phy_read(phydev, MII_BCM54XX_ECR);
54 if (reg < 0)
55 return reg;
56
57 /* Mask interrupts globally. */
58 reg |= MII_BCM54XX_ECR_IM;
59 err = phy_write(phydev, MII_BCM54XX_ECR, reg);
60 if (err < 0)
61 return err;
62
63 /* Unmask events we are interested in. */
64 reg = ~(MII_BCM54XX_INT_DUPLEX |
65 MII_BCM54XX_INT_SPEED |
66 MII_BCM54XX_INT_LINK);
67 err = phy_write(phydev, MII_BCM54XX_IMR, reg);
68 if (err < 0)
69 return err;
70 return 0;
71}
72
73static int bcm54xx_ack_interrupt(struct phy_device *phydev)
74{
75 int reg;
76
77 /* Clear pending interrupts. */
78 reg = phy_read(phydev, MII_BCM54XX_ISR);
79 if (reg < 0)
80 return reg;
81
82 return 0;
83}
84
85static int bcm54xx_config_intr(struct phy_device *phydev)
86{
87 int reg, err;
88
89 reg = phy_read(phydev, MII_BCM54XX_ECR);
90 if (reg < 0)
91 return reg;
92
93 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
94 reg &= ~MII_BCM54XX_ECR_IM;
95 else
96 reg |= MII_BCM54XX_ECR_IM;
97
98 err = phy_write(phydev, MII_BCM54XX_ECR, reg);
99 return err;
100}
101
102static struct phy_driver bcm5411_driver = {
103 .phy_id = 0x00206070,
104 .phy_id_mask = 0xfffffff0,
105 .name = "Broadcom BCM5411",
106 .features = PHY_GBIT_FEATURES,
107 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
108 .config_init = bcm54xx_config_init,
109 .config_aneg = genphy_config_aneg,
110 .read_status = genphy_read_status,
111 .ack_interrupt = bcm54xx_ack_interrupt,
112 .config_intr = bcm54xx_config_intr,
113 .driver = { .owner = THIS_MODULE },
114};
115
116static struct phy_driver bcm5421_driver = {
117 .phy_id = 0x002060e0,
118 .phy_id_mask = 0xfffffff0,
119 .name = "Broadcom BCM5421",
120 .features = PHY_GBIT_FEATURES,
121 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
122 .config_init = bcm54xx_config_init,
123 .config_aneg = genphy_config_aneg,
124 .read_status = genphy_read_status,
125 .ack_interrupt = bcm54xx_ack_interrupt,
126 .config_intr = bcm54xx_config_intr,
127 .driver = { .owner = THIS_MODULE },
128};
129
130static struct phy_driver bcm5461_driver = {
131 .phy_id = 0x002060c0,
132 .phy_id_mask = 0xfffffff0,
133 .name = "Broadcom BCM5461",
134 .features = PHY_GBIT_FEATURES,
135 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
136 .config_init = bcm54xx_config_init,
137 .config_aneg = genphy_config_aneg,
138 .read_status = genphy_read_status,
139 .ack_interrupt = bcm54xx_ack_interrupt,
140 .config_intr = bcm54xx_config_intr,
141 .driver = { .owner = THIS_MODULE },
142};
143
144static int __init broadcom_init(void)
145{
146 int ret;
147
148 ret = phy_driver_register(&bcm5411_driver);
149 if (ret)
150 goto out_5411;
151 ret = phy_driver_register(&bcm5421_driver);
152 if (ret)
153 goto out_5421;
154 ret = phy_driver_register(&bcm5461_driver);
155 if (ret)
156 goto out_5461;
157 return ret;
158
159out_5461:
160 phy_driver_unregister(&bcm5421_driver);
161out_5421:
162 phy_driver_unregister(&bcm5411_driver);
163out_5411:
164 return ret;
165}
166
167static void __exit broadcom_exit(void)
168{
169 phy_driver_unregister(&bcm5461_driver);
170 phy_driver_unregister(&bcm5421_driver);
171 phy_driver_unregister(&bcm5411_driver);
172}
173
174module_init(broadcom_init);
175module_exit(broadcom_exit);
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index a443976d5dcf..4044bb1ada86 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -7,6 +7,7 @@
7 * Author: Andy Fleming 7 * Author: Andy Fleming
8 * 8 *
9 * Copyright (c) 2004 Freescale Semiconductor, Inc. 9 * Copyright (c) 2004 Freescale Semiconductor, Inc.
10 * Copyright (c) 2006 Maciej W. Rozycki
10 * 11 *
11 * This program is free software; you can redistribute it and/or modify it 12 * 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 * under the terms of the GNU General Public License as published by the
@@ -32,6 +33,8 @@
32#include <linux/mii.h> 33#include <linux/mii.h>
33#include <linux/ethtool.h> 34#include <linux/ethtool.h>
34#include <linux/phy.h> 35#include <linux/phy.h>
36#include <linux/timer.h>
37#include <linux/workqueue.h>
35 38
36#include <asm/io.h> 39#include <asm/io.h>
37#include <asm/irq.h> 40#include <asm/irq.h>
@@ -484,6 +487,9 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
484{ 487{
485 struct phy_device *phydev = phy_dat; 488 struct phy_device *phydev = phy_dat;
486 489
490 if (PHY_HALTED == phydev->state)
491 return IRQ_NONE; /* It can't be ours. */
492
487 /* The MDIO bus is not allowed to be written in interrupt 493 /* The MDIO bus is not allowed to be written in interrupt
488 * context, so we need to disable the irq here. A work 494 * context, so we need to disable the irq here. A work
489 * queue will write the PHY to disable and clear the 495 * queue will write the PHY to disable and clear the
@@ -577,6 +583,13 @@ int phy_stop_interrupts(struct phy_device *phydev)
577 if (err) 583 if (err)
578 phy_error(phydev); 584 phy_error(phydev);
579 585
586 /*
587 * Finish any pending work; we might have been scheduled
588 * to be called from keventd ourselves, though.
589 */
590 if (!current_is_keventd())
591 flush_scheduled_work();
592
580 free_irq(phydev->irq, phydev); 593 free_irq(phydev->irq, phydev);
581 594
582 return err; 595 return err;
@@ -604,7 +617,8 @@ static void phy_change(struct work_struct *work)
604 enable_irq(phydev->irq); 617 enable_irq(phydev->irq);
605 618
606 /* Reenable interrupts */ 619 /* Reenable interrupts */
607 err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED); 620 if (PHY_HALTED != phydev->state)
621 err = phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED);
608 622
609 if (err) 623 if (err)
610 goto irq_enable_err; 624 goto irq_enable_err;
@@ -625,18 +639,24 @@ void phy_stop(struct phy_device *phydev)
625 if (PHY_HALTED == phydev->state) 639 if (PHY_HALTED == phydev->state)
626 goto out_unlock; 640 goto out_unlock;
627 641
628 if (phydev->irq != PHY_POLL) { 642 phydev->state = PHY_HALTED;
629 /* Clear any pending interrupts */
630 phy_clear_interrupt(phydev);
631 643
644 if (phydev->irq != PHY_POLL) {
632 /* Disable PHY Interrupts */ 645 /* Disable PHY Interrupts */
633 phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED); 646 phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED);
634 }
635 647
636 phydev->state = PHY_HALTED; 648 /* Clear any pending interrupts */
649 phy_clear_interrupt(phydev);
650 }
637 651
638out_unlock: 652out_unlock:
639 spin_unlock(&phydev->lock); 653 spin_unlock(&phydev->lock);
654
655 /*
656 * Cannot call flush_scheduled_work() here as desired because
657 * of rtnl_lock(), but PHY_HALTED shall guarantee phy_change()
658 * will not reenable interrupts.
659 */
640} 660}
641 661
642 662
@@ -694,60 +714,57 @@ static void phy_timer(unsigned long data)
694 714
695 break; 715 break;
696 case PHY_AN: 716 case PHY_AN:
717 err = phy_read_status(phydev);
718
719 if (err < 0)
720 break;
721
722 /* If the link is down, give up on
723 * negotiation for now */
724 if (!phydev->link) {
725 phydev->state = PHY_NOLINK;
726 netif_carrier_off(phydev->attached_dev);
727 phydev->adjust_link(phydev->attached_dev);
728 break;
729 }
730
697 /* Check if negotiation is done. Break 731 /* Check if negotiation is done. Break
698 * if there's an error */ 732 * if there's an error */
699 err = phy_aneg_done(phydev); 733 err = phy_aneg_done(phydev);
700 if (err < 0) 734 if (err < 0)
701 break; 735 break;
702 736
703 /* If auto-negotiation is done, we change to 737 /* If AN is done, we're running */
704 * either RUNNING, or NOLINK */
705 if (err > 0) { 738 if (err > 0) {
706 err = phy_read_status(phydev); 739 phydev->state = PHY_RUNNING;
740 netif_carrier_on(phydev->attached_dev);
741 phydev->adjust_link(phydev->attached_dev);
742
743 } else if (0 == phydev->link_timeout--) {
744 int idx;
707 745
708 if (err) 746 needs_aneg = 1;
747 /* If we have the magic_aneg bit,
748 * we try again */
749 if (phydev->drv->flags & PHY_HAS_MAGICANEG)
709 break; 750 break;
710 751
711 if (phydev->link) { 752 /* The timer expired, and we still
712 phydev->state = PHY_RUNNING; 753 * don't have a setting, so we try
713 netif_carrier_on(phydev->attached_dev); 754 * forcing it until we find one that
714 } else { 755 * works, starting from the fastest speed,
715 phydev->state = PHY_NOLINK; 756 * and working our way down */
716 netif_carrier_off(phydev->attached_dev); 757 idx = phy_find_valid(0, phydev->supported);
717 }
718 758
719 phydev->adjust_link(phydev->attached_dev); 759 phydev->speed = settings[idx].speed;
760 phydev->duplex = settings[idx].duplex;
720 761
721 } else if (0 == phydev->link_timeout--) { 762 phydev->autoneg = AUTONEG_DISABLE;
722 /* The counter expired, so either we
723 * switch to forced mode, or the
724 * magic_aneg bit exists, and we try aneg
725 * again */
726 if (!(phydev->drv->flags & PHY_HAS_MAGICANEG)) {
727 int idx;
728
729 /* We'll start from the
730 * fastest speed, and work
731 * our way down */
732 idx = phy_find_valid(0,
733 phydev->supported);
734
735 phydev->speed = settings[idx].speed;
736 phydev->duplex = settings[idx].duplex;
737
738 phydev->autoneg = AUTONEG_DISABLE;
739 phydev->state = PHY_FORCING;
740 phydev->link_timeout =
741 PHY_FORCE_TIMEOUT;
742
743 pr_info("Trying %d/%s\n",
744 phydev->speed,
745 DUPLEX_FULL ==
746 phydev->duplex ?
747 "FULL" : "HALF");
748 }
749 763
750 needs_aneg = 1; 764 pr_info("Trying %d/%s\n", phydev->speed,
765 DUPLEX_FULL ==
766 phydev->duplex ?
767 "FULL" : "HALF");
751 } 768 }
752 break; 769 break;
753 case PHY_NOLINK: 770 case PHY_NOLINK:
@@ -763,7 +780,7 @@ static void phy_timer(unsigned long data)
763 } 780 }
764 break; 781 break;
765 case PHY_FORCING: 782 case PHY_FORCING:
766 err = phy_read_status(phydev); 783 err = genphy_update_link(phydev);
767 784
768 if (err) 785 if (err)
769 break; 786 break;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 3bbd5e70c209..b01fc70a57db 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -59,6 +59,7 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id)
59 dev->duplex = -1; 59 dev->duplex = -1;
60 dev->pause = dev->asym_pause = 0; 60 dev->pause = dev->asym_pause = 0;
61 dev->link = 1; 61 dev->link = 1;
62 dev->interface = PHY_INTERFACE_MODE_GMII;
62 63
63 dev->autoneg = AUTONEG_ENABLE; 64 dev->autoneg = AUTONEG_ENABLE;
64 65
@@ -137,11 +138,12 @@ void phy_prepare_link(struct phy_device *phydev,
137 * the desired functionality. 138 * the desired functionality.
138 */ 139 */
139struct phy_device * phy_connect(struct net_device *dev, const char *phy_id, 140struct phy_device * phy_connect(struct net_device *dev, const char *phy_id,
140 void (*handler)(struct net_device *), u32 flags) 141 void (*handler)(struct net_device *), u32 flags,
142 u32 interface)
141{ 143{
142 struct phy_device *phydev; 144 struct phy_device *phydev;
143 145
144 phydev = phy_attach(dev, phy_id, flags); 146 phydev = phy_attach(dev, phy_id, flags, interface);
145 147
146 if (IS_ERR(phydev)) 148 if (IS_ERR(phydev))
147 return phydev; 149 return phydev;
@@ -186,7 +188,7 @@ static int phy_compare_id(struct device *dev, void *data)
186} 188}
187 189
188struct phy_device *phy_attach(struct net_device *dev, 190struct phy_device *phy_attach(struct net_device *dev,
189 const char *phy_id, u32 flags) 191 const char *phy_id, u32 flags, u32 interface)
190{ 192{
191 struct bus_type *bus = &mdio_bus_type; 193 struct bus_type *bus = &mdio_bus_type;
192 struct phy_device *phydev; 194 struct phy_device *phydev;
@@ -231,6 +233,20 @@ struct phy_device *phy_attach(struct net_device *dev,
231 233
232 phydev->dev_flags = flags; 234 phydev->dev_flags = flags;
233 235
236 phydev->interface = interface;
237
238 /* Do initial configuration here, now that
239 * we have certain key parameters
240 * (dev_flags and interface) */
241 if (phydev->drv->config_init) {
242 int err;
243
244 err = phydev->drv->config_init(phydev);
245
246 if (err < 0)
247 return ERR_PTR(err);
248 }
249
234 return phydev; 250 return phydev;
235} 251}
236EXPORT_SYMBOL(phy_attach); 252EXPORT_SYMBOL(phy_attach);
@@ -427,6 +443,7 @@ int genphy_update_link(struct phy_device *phydev)
427 443
428 return 0; 444 return 0;
429} 445}
446EXPORT_SYMBOL(genphy_update_link);
430 447
431/* genphy_read_status 448/* genphy_read_status
432 * 449 *
@@ -611,13 +628,8 @@ static int phy_probe(struct device *dev)
611 628
612 spin_unlock(&phydev->lock); 629 spin_unlock(&phydev->lock);
613 630
614 if (err < 0)
615 return err;
616
617 if (phydev->drv->config_init)
618 err = phydev->drv->config_init(phydev);
619
620 return err; 631 return err;
632
621} 633}
622 634
623static int phy_remove(struct device *dev) 635static int phy_remove(struct device *dev)
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index f5802e7b08e9..c6de566188e4 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -860,7 +860,7 @@ static int __init ppp_init(void)
860 err = PTR_ERR(ppp_class); 860 err = PTR_ERR(ppp_class);
861 goto out_chrdev; 861 goto out_chrdev;
862 } 862 }
863 class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp"); 863 device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), "ppp");
864 } 864 }
865 865
866out: 866out:
@@ -2675,7 +2675,7 @@ static void __exit ppp_cleanup(void)
2675 cardmap_destroy(&all_ppp_units); 2675 cardmap_destroy(&all_ppp_units);
2676 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0) 2676 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0)
2677 printk(KERN_ERR "PPP: failed to unregister PPP device\n"); 2677 printk(KERN_ERR "PPP: failed to unregister PPP device\n");
2678 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0)); 2678 device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0));
2679 class_destroy(ppp_class); 2679 class_destroy(ppp_class);
2680} 2680}
2681 2681
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 0adee733b761..315d5c3fc66a 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -393,7 +393,7 @@ static int pppoe_rcv(struct sk_buff *skb,
393 393
394 po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source); 394 po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source);
395 if (po != NULL) 395 if (po != NULL)
396 return sk_receive_skb(sk_pppox(po), skb); 396 return sk_receive_skb(sk_pppox(po), skb, 0);
397drop: 397drop:
398 kfree_skb(skb); 398 kfree_skb(skb);
399out: 399out:
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 1f9663a70823..85a392fab5cc 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -572,8 +572,8 @@ static void rtl8169_xmii_reset_enable(void __iomem *ioaddr)
572{ 572{
573 unsigned int val; 573 unsigned int val;
574 574
575 val = (mdio_read(ioaddr, MII_BMCR) | BMCR_RESET) & 0xffff; 575 mdio_write(ioaddr, MII_BMCR, BMCR_RESET);
576 mdio_write(ioaddr, MII_BMCR, val); 576 val = mdio_read(ioaddr, MII_BMCR);
577} 577}
578 578
579static void rtl8169_check_link_status(struct net_device *dev, 579static void rtl8169_check_link_status(struct net_device *dev,
@@ -1407,6 +1407,22 @@ static void rtl8169_release_board(struct pci_dev *pdev, struct net_device *dev,
1407 free_netdev(dev); 1407 free_netdev(dev);
1408} 1408}
1409 1409
1410static void rtl8169_phy_reset(struct net_device *dev,
1411 struct rtl8169_private *tp)
1412{
1413 void __iomem *ioaddr = tp->mmio_addr;
1414 int i;
1415
1416 tp->phy_reset_enable(ioaddr);
1417 for (i = 0; i < 100; i++) {
1418 if (!tp->phy_reset_pending(ioaddr))
1419 return;
1420 msleep(1);
1421 }
1422 if (netif_msg_link(tp))
1423 printk(KERN_ERR "%s: PHY reset failed.\n", dev->name);
1424}
1425
1410static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp) 1426static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
1411{ 1427{
1412 void __iomem *ioaddr = tp->mmio_addr; 1428 void __iomem *ioaddr = tp->mmio_addr;
@@ -1435,6 +1451,8 @@ static void rtl8169_init_phy(struct net_device *dev, struct rtl8169_private *tp)
1435 1451
1436 rtl8169_link_option(board_idx, &autoneg, &speed, &duplex); 1452 rtl8169_link_option(board_idx, &autoneg, &speed, &duplex);
1437 1453
1454 rtl8169_phy_reset(dev, tp);
1455
1438 rtl8169_set_speed(dev, autoneg, speed, duplex); 1456 rtl8169_set_speed(dev, autoneg, speed, duplex);
1439 1457
1440 if ((RTL_R8(PHYstatus) & TBI_Enable) && netif_msg_link(tp)) 1458 if ((RTL_R8(PHYstatus) & TBI_Enable) && netif_msg_link(tp))
@@ -1474,8 +1492,8 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1474 struct rtl8169_private *tp; 1492 struct rtl8169_private *tp;
1475 struct net_device *dev; 1493 struct net_device *dev;
1476 void __iomem *ioaddr; 1494 void __iomem *ioaddr;
1477 unsigned int i, pm_cap; 1495 unsigned int pm_cap;
1478 int rc; 1496 int i, rc;
1479 1497
1480 if (netif_msg_drv(&debug)) { 1498 if (netif_msg_drv(&debug)) {
1481 printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n", 1499 printk(KERN_INFO "%s Gigabit Ethernet driver %s loaded\n",
diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
index 778d9e618ebd..3fa67171e832 100644
--- a/drivers/net/sk98lin/h/skdrv2nd.h
+++ b/drivers/net/sk98lin/h/skdrv2nd.h
@@ -160,7 +160,7 @@ struct s_IOCTL {
160 160
161/* 161/*
162** Interim definition of SK_DRV_TIMER placed in this file until 162** Interim definition of SK_DRV_TIMER placed in this file until
163** common modules have boon finallized 163** common modules have been finalized
164*/ 164*/
165#define SK_DRV_TIMER 11 165#define SK_DRV_TIMER 11
166#define SK_DRV_MODERATION_TIMER 1 166#define SK_DRV_MODERATION_TIMER 1
diff --git a/drivers/net/sk98lin/skdim.c b/drivers/net/sk98lin/skdim.c
index 07c1b4c8699d..37ce03fb8de3 100644
--- a/drivers/net/sk98lin/skdim.c
+++ b/drivers/net/sk98lin/skdim.c
@@ -252,7 +252,7 @@ SkDimEnableModerationIfNeeded(SK_AC *pAC) {
252 252
253/******************************************************************************* 253/*******************************************************************************
254** Function : SkDimDisplayModerationSettings 254** Function : SkDimDisplayModerationSettings
255** Description : Displays the current settings regaring interrupt moderation 255** Description : Displays the current settings regarding interrupt moderation
256** Programmer : Ralph Roesler 256** Programmer : Ralph Roesler
257** Last Modified: 22-mar-03 257** Last Modified: 22-mar-03
258** Returns : void (!) 258** Returns : void (!)
@@ -510,7 +510,7 @@ EnableIntMod(SK_AC *pAC) {
510 510
511/******************************************************************************* 511/*******************************************************************************
512** Function : DisableIntMod() 512** Function : DisableIntMod()
513** Description : Disbles the interrupt moderation independent of what inter- 513** Description : Disables the interrupt moderation independent of what inter-
514** rupts are running or not 514** rupts are running or not
515** Programmer : Ralph Roesler 515** Programmer : Ralph Roesler
516** Last Modified: 23-mar-03 516** Last Modified: 23-mar-03
diff --git a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
index e5cb5b548b88..36460694eb82 100644
--- a/drivers/net/sk98lin/skethtool.c
+++ b/drivers/net/sk98lin/skethtool.c
@@ -581,6 +581,30 @@ static int setRxCsum(struct net_device *dev, u32 data)
581 return 0; 581 return 0;
582} 582}
583 583
584static int getRegsLen(struct net_device *dev)
585{
586 return 0x4000;
587}
588
589/*
590 * Returns copy of whole control register region
591 * Note: skip RAM address register because accessing it will
592 * cause bus hangs!
593 */
594static void getRegs(struct net_device *dev, struct ethtool_regs *regs,
595 void *p)
596{
597 DEV_NET *pNet = netdev_priv(dev);
598 const void __iomem *io = pNet->pAC->IoBase;
599
600 regs->version = 1;
601 memset(p, 0, regs->len);
602 memcpy_fromio(p, io, B3_RAM_ADDR);
603
604 memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1,
605 regs->len - B3_RI_WTO_R1);
606}
607
584const struct ethtool_ops SkGeEthtoolOps = { 608const struct ethtool_ops SkGeEthtoolOps = {
585 .get_settings = getSettings, 609 .get_settings = getSettings,
586 .set_settings = setSettings, 610 .set_settings = setSettings,
@@ -599,4 +623,6 @@ const struct ethtool_ops SkGeEthtoolOps = {
599 .set_tx_csum = setTxCsum, 623 .set_tx_csum = setTxCsum,
600 .get_rx_csum = getRxCsum, 624 .get_rx_csum = getRxCsum,
601 .set_rx_csum = setRxCsum, 625 .set_rx_csum = setRxCsum,
626 .get_regs = getRegs,
627 .get_regs_len = getRegsLen,
602}; 628};
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index d4913c3de2a1..12cbfd190dd7 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -113,6 +113,7 @@
113#include <linux/init.h> 113#include <linux/init.h>
114#include <linux/dma-mapping.h> 114#include <linux/dma-mapping.h>
115#include <linux/ip.h> 115#include <linux/ip.h>
116#include <linux/mii.h>
116 117
117#include "h/skdrv1st.h" 118#include "h/skdrv1st.h"
118#include "h/skdrv2nd.h" 119#include "h/skdrv2nd.h"
@@ -1561,7 +1562,7 @@ struct sk_buff *pMessage) /* pointer to send-message */
1561 1562
1562 if (pMessage->ip_summed == CHECKSUM_PARTIAL) { 1563 if (pMessage->ip_summed == CHECKSUM_PARTIAL) {
1563 u16 hdrlen = pMessage->h.raw - pMessage->data; 1564 u16 hdrlen = pMessage->h.raw - pMessage->data;
1564 u16 offset = hdrlen + pMessage->csum; 1565 u16 offset = hdrlen + pMessage->csum_offset;
1565 1566
1566 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) && 1567 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1567 (pAC->GIni.GIChipRev == 0) && 1568 (pAC->GIni.GIChipRev == 0) &&
@@ -1680,7 +1681,7 @@ struct sk_buff *pMessage) /* pointer to send-message */
1680 */ 1681 */
1681 if (pMessage->ip_summed == CHECKSUM_PARTIAL) { 1682 if (pMessage->ip_summed == CHECKSUM_PARTIAL) {
1682 u16 hdrlen = pMessage->h.raw - pMessage->data; 1683 u16 hdrlen = pMessage->h.raw - pMessage->data;
1683 u16 offset = hdrlen + pMessage->csum; 1684 u16 offset = hdrlen + pMessage->csum_offset;
1684 1685
1685 Control = BMU_STFWD; 1686 Control = BMU_STFWD;
1686 1687
@@ -2843,6 +2844,56 @@ unsigned long Flags; /* for spin lock */
2843 return(&pAC->stats); 2844 return(&pAC->stats);
2844} /* SkGeStats */ 2845} /* SkGeStats */
2845 2846
2847/*
2848 * Basic MII register access
2849 */
2850static int SkGeMiiIoctl(struct net_device *dev,
2851 struct mii_ioctl_data *data, int cmd)
2852{
2853 DEV_NET *pNet = netdev_priv(dev);
2854 SK_AC *pAC = pNet->pAC;
2855 SK_IOC IoC = pAC->IoBase;
2856 int Port = pNet->PortNr;
2857 SK_GEPORT *pPrt = &pAC->GIni.GP[Port];
2858 unsigned long Flags;
2859 int err = 0;
2860 int reg = data->reg_num & 0x1f;
2861 SK_U16 val = data->val_in;
2862
2863 if (!netif_running(dev))
2864 return -ENODEV; /* Phy still in reset */
2865
2866 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
2867 switch(cmd) {
2868 case SIOCGMIIPHY:
2869 data->phy_id = pPrt->PhyAddr;
2870
2871 /* fallthru */
2872 case SIOCGMIIREG:
2873 if (pAC->GIni.GIGenesis)
2874 SkXmPhyRead(pAC, IoC, Port, reg, &val);
2875 else
2876 SkGmPhyRead(pAC, IoC, Port, reg, &val);
2877
2878 data->val_out = val;
2879 break;
2880
2881 case SIOCSMIIREG:
2882 if (!capable(CAP_NET_ADMIN))
2883 err = -EPERM;
2884
2885 else if (pAC->GIni.GIGenesis)
2886 SkXmPhyWrite(pAC, IoC, Port, reg, val);
2887 else
2888 SkGmPhyWrite(pAC, IoC, Port, reg, val);
2889 break;
2890 default:
2891 err = -EOPNOTSUPP;
2892 }
2893 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2894 return err;
2895}
2896
2846 2897
2847/***************************************************************************** 2898/*****************************************************************************
2848 * 2899 *
@@ -2876,6 +2927,9 @@ int HeaderLength = sizeof(SK_U32) + sizeof(SK_U32);
2876 pNet = netdev_priv(dev); 2927 pNet = netdev_priv(dev);
2877 pAC = pNet->pAC; 2928 pAC = pNet->pAC;
2878 2929
2930 if (cmd == SIOCGMIIPHY || cmd == SIOCSMIIREG || cmd == SIOCGMIIREG)
2931 return SkGeMiiIoctl(dev, if_mii(rq), cmd);
2932
2879 if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) { 2933 if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) {
2880 return -EFAULT; 2934 return -EFAULT;
2881 } 2935 }
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 3b67614372a7..b60f0451f6cd 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -2155,8 +2155,6 @@ static void yukon_link_down(struct skge_port *skge)
2155 int port = skge->port; 2155 int port = skge->port;
2156 u16 ctrl; 2156 u16 ctrl;
2157 2157
2158 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
2159
2160 ctrl = gma_read16(hw, port, GM_GP_CTRL); 2158 ctrl = gma_read16(hw, port, GM_GP_CTRL);
2161 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); 2159 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
2162 gma_write16(hw, port, GM_GP_CTRL, ctrl); 2160 gma_write16(hw, port, GM_GP_CTRL, ctrl);
@@ -2168,7 +2166,6 @@ static void yukon_link_down(struct skge_port *skge)
2168 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, ctrl); 2166 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, ctrl);
2169 } 2167 }
2170 2168
2171 yukon_reset(hw, port);
2172 skge_link_down(skge); 2169 skge_link_down(skge);
2173 2170
2174 yukon_init(hw, port); 2171 yukon_init(hw, port);
@@ -2256,6 +2253,7 @@ static void skge_phy_reset(struct skge_port *skge)
2256{ 2253{
2257 struct skge_hw *hw = skge->hw; 2254 struct skge_hw *hw = skge->hw;
2258 int port = skge->port; 2255 int port = skge->port;
2256 struct net_device *dev = hw->dev[port];
2259 2257
2260 netif_stop_queue(skge->netdev); 2258 netif_stop_queue(skge->netdev);
2261 netif_carrier_off(skge->netdev); 2259 netif_carrier_off(skge->netdev);
@@ -2269,6 +2267,8 @@ static void skge_phy_reset(struct skge_port *skge)
2269 yukon_init(hw, port); 2267 yukon_init(hw, port);
2270 } 2268 }
2271 mutex_unlock(&hw->phy_mutex); 2269 mutex_unlock(&hw->phy_mutex);
2270
2271 dev->set_multicast_list(dev);
2272} 2272}
2273 2273
2274/* Basic MII support */ 2274/* Basic MII support */
@@ -2566,7 +2566,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2566 2566
2567 td->csum_offs = 0; 2567 td->csum_offs = 0;
2568 td->csum_start = offset; 2568 td->csum_start = offset;
2569 td->csum_write = offset + skb->csum; 2569 td->csum_write = offset + skb->csum_offset;
2570 } else 2570 } else
2571 control = BMU_CHECK; 2571 control = BMU_CHECK;
2572 2572
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 16616f5440d0..842abd9396c6 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -104,6 +104,7 @@ static const struct pci_device_id sky2_id_table[] = {
104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, 104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
105 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */ 105 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */
106 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, /* DGE-550SX */ 106 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, /* DGE-550SX */
107 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B02) }, /* DGE-560SX */
107 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, 108 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) },
108 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, 109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) },
109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, 110 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) },
@@ -676,17 +677,15 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
676 /* Flush Rx MAC FIFO on any flow control or error */ 677 /* Flush Rx MAC FIFO on any flow control or error */
677 sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR); 678 sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR);
678 679
679 /* Set threshold to 0xa (64 bytes) 680 /* Set threshold to 0xa (64 bytes) + 1 to workaround pause bug */
680 * ASF disabled so no need to do WA dev #4.30 681 sky2_write16(hw, SK_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF+1);
681 */
682 sky2_write16(hw, SK_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF);
683 682
684 /* Configure Tx MAC FIFO */ 683 /* Configure Tx MAC FIFO */
685 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR); 684 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR);
686 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON); 685 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON);
687 686
688 if (hw->chip_id == CHIP_ID_YUKON_EC_U) { 687 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
689 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 512/8); 688 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8);
690 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8); 689 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
691 if (hw->dev[port]->mtu > ETH_DATA_LEN) { 690 if (hw->dev[port]->mtu > ETH_DATA_LEN) {
692 /* set Tx GMAC FIFO Almost Empty Threshold */ 691 /* set Tx GMAC FIFO Almost Empty Threshold */
@@ -1060,7 +1059,8 @@ static int sky2_rx_start(struct sky2_port *sky2)
1060 sky2->rx_put = sky2->rx_next = 0; 1059 sky2->rx_put = sky2->rx_next = 0;
1061 sky2_qset(hw, rxq); 1060 sky2_qset(hw, rxq);
1062 1061
1063 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev >= 2) { 1062 if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
1063 (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0)) {
1064 /* MAC Rx RAM Read is controlled by hardware */ 1064 /* MAC Rx RAM Read is controlled by hardware */
1065 sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS); 1065 sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS);
1066 } 1066 }
@@ -1350,7 +1350,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1350 u32 tcpsum; 1350 u32 tcpsum;
1351 1351
1352 tcpsum = offset << 16; /* sum start */ 1352 tcpsum = offset << 16; /* sum start */
1353 tcpsum |= offset + skb->csum; /* sum write */ 1353 tcpsum |= offset + skb->csum_offset; /* sum write */
1354 1354
1355 ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM; 1355 ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
1356 if (skb->nh.iph->protocol == IPPROTO_UDP) 1356 if (skb->nh.iph->protocol == IPPROTO_UDP)
@@ -1453,7 +1453,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1453 if (unlikely(netif_msg_tx_done(sky2))) 1453 if (unlikely(netif_msg_tx_done(sky2)))
1454 printk(KERN_DEBUG "%s: tx done %u\n", 1454 printk(KERN_DEBUG "%s: tx done %u\n",
1455 dev->name, idx); 1455 dev->name, idx);
1456 dev_kfree_skb(re->skb); 1456 dev_kfree_skb_any(re->skb);
1457 } 1457 }
1458 1458
1459 le->opcode = 0; /* paranoia */ 1459 le->opcode = 0; /* paranoia */
@@ -1509,7 +1509,7 @@ static int sky2_down(struct net_device *dev)
1509 1509
1510 /* WA for dev. #4.209 */ 1510 /* WA for dev. #4.209 */
1511 if (hw->chip_id == CHIP_ID_YUKON_EC_U 1511 if (hw->chip_id == CHIP_ID_YUKON_EC_U
1512 && hw->chip_rev == CHIP_REV_YU_EC_U_A1) 1512 && (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1513 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), 1513 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1514 sky2->speed != SPEED_1000 ? 1514 sky2->speed != SPEED_1000 ?
1515 TX_STFW_ENA : TX_STFW_DIS); 1515 TX_STFW_ENA : TX_STFW_DIS);
@@ -2065,7 +2065,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
2065 case OP_RXSTAT: 2065 case OP_RXSTAT:
2066 skb = sky2_receive(dev, length, status); 2066 skb = sky2_receive(dev, length, status);
2067 if (!skb) 2067 if (!skb)
2068 break; 2068 goto force_update;
2069 2069
2070 skb->protocol = eth_type_trans(skb, dev); 2070 skb->protocol = eth_type_trans(skb, dev);
2071 dev->last_rx = jiffies; 2071 dev->last_rx = jiffies;
@@ -2081,8 +2081,8 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
2081 2081
2082 /* Update receiver after 16 frames */ 2082 /* Update receiver after 16 frames */
2083 if (++buf_write[le->link] == RX_BUF_WRITE) { 2083 if (++buf_write[le->link] == RX_BUF_WRITE) {
2084 sky2_put_idx(hw, rxqaddr[le->link], 2084force_update:
2085 sky2->rx_put); 2085 sky2_put_idx(hw, rxqaddr[le->link], sky2->rx_put);
2086 buf_write[le->link] = 0; 2086 buf_write[le->link] = 0;
2087 } 2087 }
2088 2088
@@ -3311,7 +3311,7 @@ static irqreturn_t __devinit sky2_test_intr(int irq, void *dev_id)
3311 return IRQ_NONE; 3311 return IRQ_NONE;
3312 3312
3313 if (status & Y2_IS_IRQ_SW) { 3313 if (status & Y2_IS_IRQ_SW) {
3314 hw->msi_detected = 1; 3314 hw->msi = 1;
3315 wake_up(&hw->msi_wait); 3315 wake_up(&hw->msi_wait);
3316 sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ); 3316 sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
3317 } 3317 }
@@ -3330,7 +3330,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3330 3330
3331 sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW); 3331 sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW);
3332 3332
3333 err = request_irq(pdev->irq, sky2_test_intr, IRQF_SHARED, DRV_NAME, hw); 3333 err = request_irq(pdev->irq, sky2_test_intr, 0, DRV_NAME, hw);
3334 if (err) { 3334 if (err) {
3335 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3335 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3336 pci_name(pdev), pdev->irq); 3336 pci_name(pdev), pdev->irq);
@@ -3340,9 +3340,9 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3340 sky2_write8(hw, B0_CTST, CS_ST_SW_IRQ); 3340 sky2_write8(hw, B0_CTST, CS_ST_SW_IRQ);
3341 sky2_read8(hw, B0_CTST); 3341 sky2_read8(hw, B0_CTST);
3342 3342
3343 wait_event_timeout(hw->msi_wait, hw->msi_detected, HZ/10); 3343 wait_event_timeout(hw->msi_wait, hw->msi, HZ/10);
3344 3344
3345 if (!hw->msi_detected) { 3345 if (!hw->msi) {
3346 /* MSI test failed, go back to INTx mode */ 3346 /* MSI test failed, go back to INTx mode */
3347 printk(KERN_INFO PFX "%s: No interrupt generated using MSI, " 3347 printk(KERN_INFO PFX "%s: No interrupt generated using MSI, "
3348 "switching to INTx mode.\n", 3348 "switching to INTx mode.\n",
@@ -3475,7 +3475,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3475 goto err_out_free_netdev; 3475 goto err_out_free_netdev;
3476 } 3476 }
3477 3477
3478 err = request_irq(pdev->irq, sky2_intr, IRQF_SHARED, dev->name, hw); 3478 err = request_irq(pdev->irq, sky2_intr, hw->msi ? 0 : IRQF_SHARED,
3479 dev->name, hw);
3479 if (err) { 3480 if (err) {
3480 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3481 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3481 pci_name(pdev), pdev->irq); 3482 pci_name(pdev), pdev->irq);
@@ -3505,7 +3506,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3505 return 0; 3506 return 0;
3506 3507
3507err_out_unregister: 3508err_out_unregister:
3508 pci_disable_msi(pdev); 3509 if (hw->msi)
3510 pci_disable_msi(pdev);
3509 unregister_netdev(dev); 3511 unregister_netdev(dev);
3510err_out_free_netdev: 3512err_out_free_netdev:
3511 free_netdev(dev); 3513 free_netdev(dev);
@@ -3548,7 +3550,8 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
3548 sky2_read8(hw, B0_CTST); 3550 sky2_read8(hw, B0_CTST);
3549 3551
3550 free_irq(pdev->irq, hw); 3552 free_irq(pdev->irq, hw);
3551 pci_disable_msi(pdev); 3553 if (hw->msi)
3554 pci_disable_msi(pdev);
3552 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma); 3555 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
3553 pci_release_regions(pdev); 3556 pci_release_regions(pdev);
3554 pci_disable_device(pdev); 3557 pci_disable_device(pdev);
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 6d2a23f66c9a..7760545edbf2 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -383,8 +383,13 @@ enum {
383 CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */ 383 CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */
384 CHIP_REV_YU_EC_A3 = 2, /* Chip Rev. for Yukon-EC A3 */ 384 CHIP_REV_YU_EC_A3 = 2, /* Chip Rev. for Yukon-EC A3 */
385 385
386 CHIP_REV_YU_EC_U_A0 = 0, 386 CHIP_REV_YU_EC_U_A0 = 1,
387 CHIP_REV_YU_EC_U_A1 = 1, 387 CHIP_REV_YU_EC_U_A1 = 2,
388 CHIP_REV_YU_EC_U_B0 = 3,
389
390 CHIP_REV_YU_FE_A1 = 1,
391 CHIP_REV_YU_FE_A2 = 2,
392
388}; 393};
389 394
390/* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ 395/* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */
@@ -1895,7 +1900,7 @@ struct sky2_hw {
1895 dma_addr_t st_dma; 1900 dma_addr_t st_dma;
1896 1901
1897 struct timer_list idle_timer; 1902 struct timer_list idle_timer;
1898 int msi_detected; 1903 int msi;
1899 wait_queue_head_t msi_wait; 1904 wait_queue_head_t msi_wait;
1900}; 1905};
1901 1906
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index f88fcac0e46a..f16f696c1ff2 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -644,20 +644,12 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
644 struct spider_net_descr *descr; 644 struct spider_net_descr *descr;
645 dma_addr_t buf; 645 dma_addr_t buf;
646 unsigned long flags; 646 unsigned long flags;
647 int length;
648 647
649 length = skb->len; 648 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE);
650 if (length < ETH_ZLEN) {
651 if (skb_pad(skb, ETH_ZLEN-length))
652 return 0;
653 length = ETH_ZLEN;
654 }
655
656 buf = pci_map_single(card->pdev, skb->data, length, PCI_DMA_TODEVICE);
657 if (pci_dma_mapping_error(buf)) { 649 if (pci_dma_mapping_error(buf)) {
658 if (netif_msg_tx_err(card) && net_ratelimit()) 650 if (netif_msg_tx_err(card) && net_ratelimit())
659 pr_err("could not iommu-map packet (%p, %i). " 651 pr_err("could not iommu-map packet (%p, %i). "
660 "Dropping packet\n", skb->data, length); 652 "Dropping packet\n", skb->data, skb->len);
661 card->spider_stats.tx_iommu_map_error++; 653 card->spider_stats.tx_iommu_map_error++;
662 return -ENOMEM; 654 return -ENOMEM;
663 } 655 }
@@ -667,7 +659,7 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
667 card->tx_chain.head = descr->next; 659 card->tx_chain.head = descr->next;
668 660
669 descr->buf_addr = buf; 661 descr->buf_addr = buf;
670 descr->buf_size = length; 662 descr->buf_size = skb->len;
671 descr->next_descr_addr = 0; 663 descr->next_descr_addr = 0;
672 descr->skb = skb; 664 descr->skb = skb;
673 descr->data_status = 0; 665 descr->data_status = 0;
@@ -802,8 +794,8 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
802 794
803 /* unmap the skb */ 795 /* unmap the skb */
804 if (skb) { 796 if (skb) {
805 int len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; 797 pci_unmap_single(card->pdev, buf_addr, skb->len,
806 pci_unmap_single(card->pdev, buf_addr, len, PCI_DMA_TODEVICE); 798 PCI_DMA_TODEVICE);
807 dev_kfree_skb(skb); 799 dev_kfree_skb(skb);
808 } 800 }
809 } 801 }
@@ -1641,7 +1633,7 @@ spider_net_enable_card(struct spider_net_card *card)
1641 SPIDER_NET_INT2_MASK_VALUE); 1633 SPIDER_NET_INT2_MASK_VALUE);
1642 1634
1643 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, 1635 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
1644 SPIDER_NET_GDTBSTA | SPIDER_NET_GDTDCEIDIS); 1636 SPIDER_NET_GDTBSTA);
1645} 1637}
1646 1638
1647/** 1639/**
diff --git a/drivers/net/spider_net.h b/drivers/net/spider_net.h
index b3b46119b424..3e196df29790 100644
--- a/drivers/net/spider_net.h
+++ b/drivers/net/spider_net.h
@@ -24,7 +24,7 @@
24#ifndef _SPIDER_NET_H 24#ifndef _SPIDER_NET_H
25#define _SPIDER_NET_H 25#define _SPIDER_NET_H
26 26
27#define VERSION "1.1 A" 27#define VERSION "1.6 A"
28 28
29#include "sungem_phy.h" 29#include "sungem_phy.h"
30 30
@@ -217,8 +217,7 @@ extern char spider_net_driver_name[];
217#define SPIDER_NET_GDTBSTA 0x00000300 217#define SPIDER_NET_GDTBSTA 0x00000300
218#define SPIDER_NET_GDTDCEIDIS 0x00000002 218#define SPIDER_NET_GDTDCEIDIS 0x00000002
219#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \ 219#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \
220 SPIDER_NET_GDTBSTA | \ 220 SPIDER_NET_GDTBSTA
221 SPIDER_NET_GDTDCEIDIS
222 221
223#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003 222#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003
224 223
@@ -328,7 +327,8 @@ enum spider_net_int2_status {
328 SPIDER_NET_GRISPDNGINT 327 SPIDER_NET_GRISPDNGINT
329}; 328};
330 329
331#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GDTFDCINT) ) 330#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GDTFDCINT) | \
331 (1 << SPIDER_NET_GDTDCEINT) )
332 332
333/* We rely on flagged descriptor interrupts */ 333/* We rely on flagged descriptor interrupts */
334#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) ) 334#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) )
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 41c503d8bac4..c06ecc8002b9 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -264,8 +264,6 @@ enum alta_offsets {
264 ASICCtrl = 0x30, 264 ASICCtrl = 0x30,
265 EEData = 0x34, 265 EEData = 0x34,
266 EECtrl = 0x36, 266 EECtrl = 0x36,
267 TxStartThresh = 0x3c,
268 RxEarlyThresh = 0x3e,
269 FlashAddr = 0x40, 267 FlashAddr = 0x40,
270 FlashData = 0x44, 268 FlashData = 0x44,
271 TxStatus = 0x46, 269 TxStatus = 0x46,
@@ -790,6 +788,7 @@ static int netdev_open(struct net_device *dev)
790{ 788{
791 struct netdev_private *np = netdev_priv(dev); 789 struct netdev_private *np = netdev_priv(dev);
792 void __iomem *ioaddr = np->base; 790 void __iomem *ioaddr = np->base;
791 unsigned long flags;
793 int i; 792 int i;
794 793
795 /* Do we need to reset the chip??? */ 794 /* Do we need to reset the chip??? */
@@ -834,6 +833,10 @@ static int netdev_open(struct net_device *dev)
834 iowrite8(0x01, ioaddr + DebugCtrl1); 833 iowrite8(0x01, ioaddr + DebugCtrl1);
835 netif_start_queue(dev); 834 netif_start_queue(dev);
836 835
836 spin_lock_irqsave(&np->lock, flags);
837 reset_tx(dev);
838 spin_unlock_irqrestore(&np->lock, flags);
839
837 iowrite16 (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1); 840 iowrite16 (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
838 841
839 if (netif_msg_ifup(np)) 842 if (netif_msg_ifup(np))
@@ -1081,6 +1084,8 @@ reset_tx (struct net_device *dev)
1081 1084
1082 /* free all tx skbuff */ 1085 /* free all tx skbuff */
1083 for (i = 0; i < TX_RING_SIZE; i++) { 1086 for (i = 0; i < TX_RING_SIZE; i++) {
1087 np->tx_ring[i].next_desc = 0;
1088
1084 skb = np->tx_skbuff[i]; 1089 skb = np->tx_skbuff[i];
1085 if (skb) { 1090 if (skb) {
1086 pci_unmap_single(np->pci_dev, 1091 pci_unmap_single(np->pci_dev,
@@ -1096,6 +1101,10 @@ reset_tx (struct net_device *dev)
1096 } 1101 }
1097 np->cur_tx = np->dirty_tx = 0; 1102 np->cur_tx = np->dirty_tx = 0;
1098 np->cur_task = 0; 1103 np->cur_task = 0;
1104
1105 np->last_tx = NULL;
1106 iowrite8(127, ioaddr + TxDMAPollPeriod);
1107
1099 iowrite16 (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1); 1108 iowrite16 (StatsEnable | RxEnable | TxEnable, ioaddr + MACCtrl1);
1100 return 0; 1109 return 0;
1101} 1110}
@@ -1111,6 +1120,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
1111 int tx_cnt; 1120 int tx_cnt;
1112 int tx_status; 1121 int tx_status;
1113 int handled = 0; 1122 int handled = 0;
1123 int i;
1114 1124
1115 1125
1116 do { 1126 do {
@@ -1153,21 +1163,24 @@ static irqreturn_t intr_handler(int irq, void *dev_instance)
1153 np->stats.tx_fifo_errors++; 1163 np->stats.tx_fifo_errors++;
1154 if (tx_status & 0x02) 1164 if (tx_status & 0x02)
1155 np->stats.tx_window_errors++; 1165 np->stats.tx_window_errors++;
1166
1156 /* 1167 /*
1157 ** This reset has been verified on 1168 ** This reset has been verified on
1158 ** DFE-580TX boards ! phdm@macqel.be. 1169 ** DFE-580TX boards ! phdm@macqel.be.
1159 */ 1170 */
1160 if (tx_status & 0x10) { /* TxUnderrun */ 1171 if (tx_status & 0x10) { /* TxUnderrun */
1161 unsigned short txthreshold;
1162
1163 txthreshold = ioread16 (ioaddr + TxStartThresh);
1164 /* Restart Tx FIFO and transmitter */ 1172 /* Restart Tx FIFO and transmitter */
1165 sundance_reset(dev, (NetworkReset|FIFOReset|TxReset) << 16); 1173 sundance_reset(dev, (NetworkReset|FIFOReset|TxReset) << 16);
1166 iowrite16 (txthreshold, ioaddr + TxStartThresh);
1167 /* No need to reset the Tx pointer here */ 1174 /* No need to reset the Tx pointer here */
1168 } 1175 }
1169 /* Restart the Tx. */ 1176 /* Restart the Tx. Need to make sure tx enabled */
1170 iowrite16 (TxEnable, ioaddr + MACCtrl1); 1177 i = 10;
1178 do {
1179 iowrite16(ioread16(ioaddr + MACCtrl1) | TxEnable, ioaddr + MACCtrl1);
1180 if (ioread16(ioaddr + MACCtrl1) & TxEnabled)
1181 break;
1182 mdelay(1);
1183 } while (--i);
1171 } 1184 }
1172 /* Yup, this is a documentation bug. It cost me *hours*. */ 1185 /* Yup, this is a documentation bug. It cost me *hours*. */
1173 iowrite16 (0, ioaddr + TxStatus); 1186 iowrite16 (0, ioaddr + TxStatus);
@@ -1629,6 +1642,14 @@ static int netdev_close(struct net_device *dev)
1629 struct sk_buff *skb; 1642 struct sk_buff *skb;
1630 int i; 1643 int i;
1631 1644
1645 /* Wait and kill tasklet */
1646 tasklet_kill(&np->rx_tasklet);
1647 tasklet_kill(&np->tx_tasklet);
1648 np->cur_tx = 0;
1649 np->dirty_tx = 0;
1650 np->cur_task = 0;
1651 np->last_tx = NULL;
1652
1632 netif_stop_queue(dev); 1653 netif_stop_queue(dev);
1633 1654
1634 if (netif_msg_ifdown(np)) { 1655 if (netif_msg_ifdown(np)) {
@@ -1643,12 +1664,26 @@ static int netdev_close(struct net_device *dev)
1643 /* Disable interrupts by clearing the interrupt mask. */ 1664 /* Disable interrupts by clearing the interrupt mask. */
1644 iowrite16(0x0000, ioaddr + IntrEnable); 1665 iowrite16(0x0000, ioaddr + IntrEnable);
1645 1666
1667 /* Disable Rx and Tx DMA for safely release resource */
1668 iowrite32(0x500, ioaddr + DMACtrl);
1669
1646 /* Stop the chip's Tx and Rx processes. */ 1670 /* Stop the chip's Tx and Rx processes. */
1647 iowrite16(TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl1); 1671 iowrite16(TxDisable | RxDisable | StatsDisable, ioaddr + MACCtrl1);
1648 1672
1649 /* Wait and kill tasklet */ 1673 for (i = 2000; i > 0; i--) {
1650 tasklet_kill(&np->rx_tasklet); 1674 if ((ioread32(ioaddr + DMACtrl) & 0xc000) == 0)
1651 tasklet_kill(&np->tx_tasklet); 1675 break;
1676 mdelay(1);
1677 }
1678
1679 iowrite16(GlobalReset | DMAReset | FIFOReset | NetworkReset,
1680 ioaddr +ASICCtrl + 2);
1681
1682 for (i = 2000; i > 0; i--) {
1683 if ((ioread16(ioaddr + ASICCtrl +2) & ResetBusy) == 0)
1684 break;
1685 mdelay(1);
1686 }
1652 1687
1653#ifdef __i386__ 1688#ifdef __i386__
1654 if (netif_msg_hw(np)) { 1689 if (netif_msg_hw(np)) {
@@ -1686,6 +1721,7 @@ static int netdev_close(struct net_device *dev)
1686 } 1721 }
1687 } 1722 }
1688 for (i = 0; i < TX_RING_SIZE; i++) { 1723 for (i = 0; i < TX_RING_SIZE; i++) {
1724 np->tx_ring[i].next_desc = 0;
1689 skb = np->tx_skbuff[i]; 1725 skb = np->tx_skbuff[i];
1690 if (skb) { 1726 if (skb) {
1691 pci_unmap_single(np->pci_dev, 1727 pci_unmap_single(np->pci_dev,
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 004d651681ad..d03a9a849c06 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -1030,7 +1030,7 @@ static int gem_start_xmit(struct sk_buff *skb, struct net_device *dev)
1030 u64 csum_start_off, csum_stuff_off; 1030 u64 csum_start_off, csum_stuff_off;
1031 1031
1032 csum_start_off = (u64) (skb->h.raw - skb->data); 1032 csum_start_off = (u64) (skb->h.raw - skb->data);
1033 csum_stuff_off = (u64) ((skb->h.raw + skb->csum) - skb->data); 1033 csum_stuff_off = csum_start_off + skb->csum_offset;
1034 1034
1035 ctrl = (TXDCTRL_CENAB | 1035 ctrl = (TXDCTRL_CENAB |
1036 (csum_start_off << 15) | 1036 (csum_start_off << 15) |
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index 9d7cd130c19d..ec432ea879fb 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -2272,7 +2272,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev)
2272 u32 csum_start_off, csum_stuff_off; 2272 u32 csum_start_off, csum_stuff_off;
2273 2273
2274 csum_start_off = (u32) (skb->h.raw - skb->data); 2274 csum_start_off = (u32) (skb->h.raw - skb->data);
2275 csum_stuff_off = (u32) ((skb->h.raw + skb->csum) - skb->data); 2275 csum_stuff_off = csum_start_off + skb->csum_offset;
2276 2276
2277 tx_flags = (TXFLAG_OWN | TXFLAG_CSENABLE | 2277 tx_flags = (TXFLAG_OWN | TXFLAG_CSENABLE |
2278 ((csum_start_off << 14) & TXFLAG_CSBUFBEGIN) | 2278 ((csum_start_off << 14) & TXFLAG_CSBUFBEGIN) |
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index cd142d0302bc..8f4ecc1109cb 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -1771,7 +1771,7 @@ static struct pci_driver olympic_driver = {
1771 1771
1772static int __init olympic_pci_init(void) 1772static int __init olympic_pci_init(void)
1773{ 1773{
1774 return pci_module_init (&olympic_driver) ; 1774 return pci_register_driver(&olympic_driver) ;
1775} 1775}
1776 1776
1777static void __exit olympic_pci_cleanup(void) 1777static void __exit olympic_pci_cleanup(void)
diff --git a/drivers/net/tsi108_eth.c b/drivers/net/tsi108_eth.c
new file mode 100644
index 000000000000..893808ab3742
--- /dev/null
+++ b/drivers/net/tsi108_eth.c
@@ -0,0 +1,1708 @@
1/*******************************************************************************
2
3 Copyright(c) 2006 Tundra Semiconductor Corporation.
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*******************************************************************************/
20
21/* This driver is based on the driver code originally developed
22 * for the Intel IOC80314 (ForestLake) Gigabit Ethernet by
23 * scott.wood@timesys.com * Copyright (C) 2003 TimeSys Corporation
24 *
25 * Currently changes from original version are:
26 * - porting to Tsi108-based platform and kernel 2.6 (kong.lai@tundra.com)
27 * - modifications to handle two ports independently and support for
28 * additional PHY devices (alexandre.bounine@tundra.com)
29 * - Get hardware information from platform device. (tie-fei.zang@freescale.com)
30 *
31 */
32
33#include <linux/module.h>
34#include <linux/types.h>
35#include <linux/init.h>
36#include <linux/net.h>
37#include <linux/netdevice.h>
38#include <linux/etherdevice.h>
39#include <linux/skbuff.h>
40#include <linux/slab.h>
41#include <linux/sched.h>
42#include <linux/spinlock.h>
43#include <linux/delay.h>
44#include <linux/crc32.h>
45#include <linux/mii.h>
46#include <linux/device.h>
47#include <linux/pci.h>
48#include <linux/rtnetlink.h>
49#include <linux/timer.h>
50#include <linux/platform_device.h>
51#include <linux/etherdevice.h>
52
53#include <asm/system.h>
54#include <asm/io.h>
55#include <asm/tsi108.h>
56
57#include "tsi108_eth.h"
58
59#define MII_READ_DELAY 10000 /* max link wait time in msec */
60
61#define TSI108_RXRING_LEN 256
62
63/* NOTE: The driver currently does not support receiving packets
64 * larger than the buffer size, so don't decrease this (unless you
65 * want to add such support).
66 */
67#define TSI108_RXBUF_SIZE 1536
68
69#define TSI108_TXRING_LEN 256
70
71#define TSI108_TX_INT_FREQ 64
72
73/* Check the phy status every half a second. */
74#define CHECK_PHY_INTERVAL (HZ/2)
75
76static int tsi108_init_one(struct platform_device *pdev);
77static int tsi108_ether_remove(struct platform_device *pdev);
78
79struct tsi108_prv_data {
80 void __iomem *regs; /* Base of normal regs */
81 void __iomem *phyregs; /* Base of register bank used for PHY access */
82
83 unsigned int phy; /* Index of PHY for this interface */
84 unsigned int irq_num;
85 unsigned int id;
86
87 struct timer_list timer;/* Timer that triggers the check phy function */
88 unsigned int rxtail; /* Next entry in rxring to read */
89 unsigned int rxhead; /* Next entry in rxring to give a new buffer */
90 unsigned int rxfree; /* Number of free, allocated RX buffers */
91
92 unsigned int rxpending; /* Non-zero if there are still descriptors
93 * to be processed from a previous descriptor
94 * interrupt condition that has been cleared */
95
96 unsigned int txtail; /* Next TX descriptor to check status on */
97 unsigned int txhead; /* Next TX descriptor to use */
98
99 /* Number of free TX descriptors. This could be calculated from
100 * rxhead and rxtail if one descriptor were left unused to disambiguate
101 * full and empty conditions, but it's simpler to just keep track
102 * explicitly. */
103
104 unsigned int txfree;
105
106 unsigned int phy_ok; /* The PHY is currently powered on. */
107
108 /* PHY status (duplex is 1 for half, 2 for full,
109 * so that the default 0 indicates that neither has
110 * yet been configured). */
111
112 unsigned int link_up;
113 unsigned int speed;
114 unsigned int duplex;
115
116 tx_desc *txring;
117 rx_desc *rxring;
118 struct sk_buff *txskbs[TSI108_TXRING_LEN];
119 struct sk_buff *rxskbs[TSI108_RXRING_LEN];
120
121 dma_addr_t txdma, rxdma;
122
123 /* txlock nests in misclock and phy_lock */
124
125 spinlock_t txlock, misclock;
126
127 /* stats is used to hold the upper bits of each hardware counter,
128 * and tmpstats is used to hold the full values for returning
129 * to the caller of get_stats(). They must be separate in case
130 * an overflow interrupt occurs before the stats are consumed.
131 */
132
133 struct net_device_stats stats;
134 struct net_device_stats tmpstats;
135
136 /* These stats are kept separate in hardware, thus require individual
137 * fields for handling carry. They are combined in get_stats.
138 */
139
140 unsigned long rx_fcs; /* Add to rx_frame_errors */
141 unsigned long rx_short_fcs; /* Add to rx_frame_errors */
142 unsigned long rx_long_fcs; /* Add to rx_frame_errors */
143 unsigned long rx_underruns; /* Add to rx_length_errors */
144 unsigned long rx_overruns; /* Add to rx_length_errors */
145
146 unsigned long tx_coll_abort; /* Add to tx_aborted_errors/collisions */
147 unsigned long tx_pause_drop; /* Add to tx_aborted_errors */
148
149 unsigned long mc_hash[16];
150 u32 msg_enable; /* debug message level */
151 struct mii_if_info mii_if;
152 unsigned int init_media;
153};
154
155/* Structure for a device driver */
156
157static struct platform_driver tsi_eth_driver = {
158 .probe = tsi108_init_one,
159 .remove = tsi108_ether_remove,
160 .driver = {
161 .name = "tsi-ethernet",
162 },
163};
164
165static void tsi108_timed_checker(unsigned long dev_ptr);
166
167static void dump_eth_one(struct net_device *dev)
168{
169 struct tsi108_prv_data *data = netdev_priv(dev);
170
171 printk("Dumping %s...\n", dev->name);
172 printk("intstat %x intmask %x phy_ok %d"
173 " link %d speed %d duplex %d\n",
174 TSI_READ(TSI108_EC_INTSTAT),
175 TSI_READ(TSI108_EC_INTMASK), data->phy_ok,
176 data->link_up, data->speed, data->duplex);
177
178 printk("TX: head %d, tail %d, free %d, stat %x, estat %x, err %x\n",
179 data->txhead, data->txtail, data->txfree,
180 TSI_READ(TSI108_EC_TXSTAT),
181 TSI_READ(TSI108_EC_TXESTAT),
182 TSI_READ(TSI108_EC_TXERR));
183
184 printk("RX: head %d, tail %d, free %d, stat %x,"
185 " estat %x, err %x, pending %d\n\n",
186 data->rxhead, data->rxtail, data->rxfree,
187 TSI_READ(TSI108_EC_RXSTAT),
188 TSI_READ(TSI108_EC_RXESTAT),
189 TSI_READ(TSI108_EC_RXERR), data->rxpending);
190}
191
192/* Synchronization is needed between the thread and up/down events.
193 * Note that the PHY is accessed through the same registers for both
194 * interfaces, so this can't be made interface-specific.
195 */
196
197static DEFINE_SPINLOCK(phy_lock);
198
199static int tsi108_read_mii(struct tsi108_prv_data *data, int reg)
200{
201 unsigned i;
202
203 TSI_WRITE_PHY(TSI108_MAC_MII_ADDR,
204 (data->phy << TSI108_MAC_MII_ADDR_PHY) |
205 (reg << TSI108_MAC_MII_ADDR_REG));
206 TSI_WRITE_PHY(TSI108_MAC_MII_CMD, 0);
207 TSI_WRITE_PHY(TSI108_MAC_MII_CMD, TSI108_MAC_MII_CMD_READ);
208 for (i = 0; i < 100; i++) {
209 if (!(TSI_READ_PHY(TSI108_MAC_MII_IND) &
210 (TSI108_MAC_MII_IND_NOTVALID | TSI108_MAC_MII_IND_BUSY)))
211 break;
212 udelay(10);
213 }
214
215 if (i == 100)
216 return 0xffff;
217 else
218 return (TSI_READ_PHY(TSI108_MAC_MII_DATAIN));
219}
220
221static void tsi108_write_mii(struct tsi108_prv_data *data,
222 int reg, u16 val)
223{
224 unsigned i = 100;
225 TSI_WRITE_PHY(TSI108_MAC_MII_ADDR,
226 (data->phy << TSI108_MAC_MII_ADDR_PHY) |
227 (reg << TSI108_MAC_MII_ADDR_REG));
228 TSI_WRITE_PHY(TSI108_MAC_MII_DATAOUT, val);
229 while (i--) {
230 if(!(TSI_READ_PHY(TSI108_MAC_MII_IND) &
231 TSI108_MAC_MII_IND_BUSY))
232 break;
233 udelay(10);
234 }
235}
236
237static int tsi108_mdio_read(struct net_device *dev, int addr, int reg)
238{
239 struct tsi108_prv_data *data = netdev_priv(dev);
240 return tsi108_read_mii(data, reg);
241}
242
243static void tsi108_mdio_write(struct net_device *dev, int addr, int reg, int val)
244{
245 struct tsi108_prv_data *data = netdev_priv(dev);
246 tsi108_write_mii(data, reg, val);
247}
248
249static inline void tsi108_write_tbi(struct tsi108_prv_data *data,
250 int reg, u16 val)
251{
252 unsigned i = 1000;
253 TSI_WRITE(TSI108_MAC_MII_ADDR,
254 (0x1e << TSI108_MAC_MII_ADDR_PHY)
255 | (reg << TSI108_MAC_MII_ADDR_REG));
256 TSI_WRITE(TSI108_MAC_MII_DATAOUT, val);
257 while(i--) {
258 if(!(TSI_READ(TSI108_MAC_MII_IND) & TSI108_MAC_MII_IND_BUSY))
259 return;
260 udelay(10);
261 }
262 printk(KERN_ERR "%s function time out \n", __FUNCTION__);
263}
264
265static int mii_speed(struct mii_if_info *mii)
266{
267 int advert, lpa, val, media;
268 int lpa2 = 0;
269 int speed;
270
271 if (!mii_link_ok(mii))
272 return 0;
273
274 val = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_BMSR);
275 if ((val & BMSR_ANEGCOMPLETE) == 0)
276 return 0;
277
278 advert = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_ADVERTISE);
279 lpa = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_LPA);
280 media = mii_nway_result(advert & lpa);
281
282 if (mii->supports_gmii)
283 lpa2 = mii->mdio_read(mii->dev, mii->phy_id, MII_STAT1000);
284
285 speed = lpa2 & (LPA_1000FULL | LPA_1000HALF) ? 1000 :
286 (media & (ADVERTISE_100FULL | ADVERTISE_100HALF) ? 100 : 10);
287 return speed;
288}
289
290static void tsi108_check_phy(struct net_device *dev)
291{
292 struct tsi108_prv_data *data = netdev_priv(dev);
293 u32 mac_cfg2_reg, portctrl_reg;
294 u32 duplex;
295 u32 speed;
296 unsigned long flags;
297
298 /* Do a dummy read, as for some reason the first read
299 * after a link becomes up returns link down, even if
300 * it's been a while since the link came up.
301 */
302
303 spin_lock_irqsave(&phy_lock, flags);
304
305 if (!data->phy_ok)
306 goto out;
307
308 tsi108_read_mii(data, MII_BMSR);
309
310 duplex = mii_check_media(&data->mii_if, netif_msg_link(data), data->init_media);
311 data->init_media = 0;
312
313 if (netif_carrier_ok(dev)) {
314
315 speed = mii_speed(&data->mii_if);
316
317 if ((speed != data->speed) || duplex) {
318
319 mac_cfg2_reg = TSI_READ(TSI108_MAC_CFG2);
320 portctrl_reg = TSI_READ(TSI108_EC_PORTCTRL);
321
322 mac_cfg2_reg &= ~TSI108_MAC_CFG2_IFACE_MASK;
323
324 if (speed == 1000) {
325 mac_cfg2_reg |= TSI108_MAC_CFG2_GIG;
326 portctrl_reg &= ~TSI108_EC_PORTCTRL_NOGIG;
327 } else {
328 mac_cfg2_reg |= TSI108_MAC_CFG2_NOGIG;
329 portctrl_reg |= TSI108_EC_PORTCTRL_NOGIG;
330 }
331
332 data->speed = speed;
333
334 if (data->mii_if.full_duplex) {
335 mac_cfg2_reg |= TSI108_MAC_CFG2_FULLDUPLEX;
336 portctrl_reg &= ~TSI108_EC_PORTCTRL_HALFDUPLEX;
337 data->duplex = 2;
338 } else {
339 mac_cfg2_reg &= ~TSI108_MAC_CFG2_FULLDUPLEX;
340 portctrl_reg |= TSI108_EC_PORTCTRL_HALFDUPLEX;
341 data->duplex = 1;
342 }
343
344 TSI_WRITE(TSI108_MAC_CFG2, mac_cfg2_reg);
345 TSI_WRITE(TSI108_EC_PORTCTRL, portctrl_reg);
346
347 if (data->link_up == 0) {
348 /* The manual says it can take 3-4 usecs for the speed change
349 * to take effect.
350 */
351 udelay(5);
352
353 spin_lock(&data->txlock);
354 if (is_valid_ether_addr(dev->dev_addr) && data->txfree)
355 netif_wake_queue(dev);
356
357 data->link_up = 1;
358 spin_unlock(&data->txlock);
359 }
360 }
361
362 } else {
363 if (data->link_up == 1) {
364 netif_stop_queue(dev);
365 data->link_up = 0;
366 printk(KERN_NOTICE "%s : link is down\n", dev->name);
367 }
368
369 goto out;
370 }
371
372
373out:
374 spin_unlock_irqrestore(&phy_lock, flags);
375}
376
377static inline void
378tsi108_stat_carry_one(int carry, int carry_bit, int carry_shift,
379 unsigned long *upper)
380{
381 if (carry & carry_bit)
382 *upper += carry_shift;
383}
384
385static void tsi108_stat_carry(struct net_device *dev)
386{
387 struct tsi108_prv_data *data = netdev_priv(dev);
388 u32 carry1, carry2;
389
390 spin_lock_irq(&data->misclock);
391
392 carry1 = TSI_READ(TSI108_STAT_CARRY1);
393 carry2 = TSI_READ(TSI108_STAT_CARRY2);
394
395 TSI_WRITE(TSI108_STAT_CARRY1, carry1);
396 TSI_WRITE(TSI108_STAT_CARRY2, carry2);
397
398 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXBYTES,
399 TSI108_STAT_RXBYTES_CARRY, &data->stats.rx_bytes);
400
401 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXPKTS,
402 TSI108_STAT_RXPKTS_CARRY,
403 &data->stats.rx_packets);
404
405 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXFCS,
406 TSI108_STAT_RXFCS_CARRY, &data->rx_fcs);
407
408 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXMCAST,
409 TSI108_STAT_RXMCAST_CARRY,
410 &data->stats.multicast);
411
412 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXALIGN,
413 TSI108_STAT_RXALIGN_CARRY,
414 &data->stats.rx_frame_errors);
415
416 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXLENGTH,
417 TSI108_STAT_RXLENGTH_CARRY,
418 &data->stats.rx_length_errors);
419
420 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXRUNT,
421 TSI108_STAT_RXRUNT_CARRY, &data->rx_underruns);
422
423 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXJUMBO,
424 TSI108_STAT_RXJUMBO_CARRY, &data->rx_overruns);
425
426 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXFRAG,
427 TSI108_STAT_RXFRAG_CARRY, &data->rx_short_fcs);
428
429 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXJABBER,
430 TSI108_STAT_RXJABBER_CARRY, &data->rx_long_fcs);
431
432 tsi108_stat_carry_one(carry1, TSI108_STAT_CARRY1_RXDROP,
433 TSI108_STAT_RXDROP_CARRY,
434 &data->stats.rx_missed_errors);
435
436 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXBYTES,
437 TSI108_STAT_TXBYTES_CARRY, &data->stats.tx_bytes);
438
439 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXPKTS,
440 TSI108_STAT_TXPKTS_CARRY,
441 &data->stats.tx_packets);
442
443 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXEXDEF,
444 TSI108_STAT_TXEXDEF_CARRY,
445 &data->stats.tx_aborted_errors);
446
447 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXEXCOL,
448 TSI108_STAT_TXEXCOL_CARRY, &data->tx_coll_abort);
449
450 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXTCOL,
451 TSI108_STAT_TXTCOL_CARRY,
452 &data->stats.collisions);
453
454 tsi108_stat_carry_one(carry2, TSI108_STAT_CARRY2_TXPAUSE,
455 TSI108_STAT_TXPAUSEDROP_CARRY,
456 &data->tx_pause_drop);
457
458 spin_unlock_irq(&data->misclock);
459}
460
461/* Read a stat counter atomically with respect to carries.
462 * data->misclock must be held.
463 */
464static inline unsigned long
465tsi108_read_stat(struct tsi108_prv_data * data, int reg, int carry_bit,
466 int carry_shift, unsigned long *upper)
467{
468 int carryreg;
469 unsigned long val;
470
471 if (reg < 0xb0)
472 carryreg = TSI108_STAT_CARRY1;
473 else
474 carryreg = TSI108_STAT_CARRY2;
475
476 again:
477 val = TSI_READ(reg) | *upper;
478
479 /* Check to see if it overflowed, but the interrupt hasn't
480 * been serviced yet. If so, handle the carry here, and
481 * try again.
482 */
483
484 if (unlikely(TSI_READ(carryreg) & carry_bit)) {
485 *upper += carry_shift;
486 TSI_WRITE(carryreg, carry_bit);
487 goto again;
488 }
489
490 return val;
491}
492
493static struct net_device_stats *tsi108_get_stats(struct net_device *dev)
494{
495 unsigned long excol;
496
497 struct tsi108_prv_data *data = netdev_priv(dev);
498 spin_lock_irq(&data->misclock);
499
500 data->tmpstats.rx_packets =
501 tsi108_read_stat(data, TSI108_STAT_RXPKTS,
502 TSI108_STAT_CARRY1_RXPKTS,
503 TSI108_STAT_RXPKTS_CARRY, &data->stats.rx_packets);
504
505 data->tmpstats.tx_packets =
506 tsi108_read_stat(data, TSI108_STAT_TXPKTS,
507 TSI108_STAT_CARRY2_TXPKTS,
508 TSI108_STAT_TXPKTS_CARRY, &data->stats.tx_packets);
509
510 data->tmpstats.rx_bytes =
511 tsi108_read_stat(data, TSI108_STAT_RXBYTES,
512 TSI108_STAT_CARRY1_RXBYTES,
513 TSI108_STAT_RXBYTES_CARRY, &data->stats.rx_bytes);
514
515 data->tmpstats.tx_bytes =
516 tsi108_read_stat(data, TSI108_STAT_TXBYTES,
517 TSI108_STAT_CARRY2_TXBYTES,
518 TSI108_STAT_TXBYTES_CARRY, &data->stats.tx_bytes);
519
520 data->tmpstats.multicast =
521 tsi108_read_stat(data, TSI108_STAT_RXMCAST,
522 TSI108_STAT_CARRY1_RXMCAST,
523 TSI108_STAT_RXMCAST_CARRY, &data->stats.multicast);
524
525 excol = tsi108_read_stat(data, TSI108_STAT_TXEXCOL,
526 TSI108_STAT_CARRY2_TXEXCOL,
527 TSI108_STAT_TXEXCOL_CARRY,
528 &data->tx_coll_abort);
529
530 data->tmpstats.collisions =
531 tsi108_read_stat(data, TSI108_STAT_TXTCOL,
532 TSI108_STAT_CARRY2_TXTCOL,
533 TSI108_STAT_TXTCOL_CARRY, &data->stats.collisions);
534
535 data->tmpstats.collisions += excol;
536
537 data->tmpstats.rx_length_errors =
538 tsi108_read_stat(data, TSI108_STAT_RXLENGTH,
539 TSI108_STAT_CARRY1_RXLENGTH,
540 TSI108_STAT_RXLENGTH_CARRY,
541 &data->stats.rx_length_errors);
542
543 data->tmpstats.rx_length_errors +=
544 tsi108_read_stat(data, TSI108_STAT_RXRUNT,
545 TSI108_STAT_CARRY1_RXRUNT,
546 TSI108_STAT_RXRUNT_CARRY, &data->rx_underruns);
547
548 data->tmpstats.rx_length_errors +=
549 tsi108_read_stat(data, TSI108_STAT_RXJUMBO,
550 TSI108_STAT_CARRY1_RXJUMBO,
551 TSI108_STAT_RXJUMBO_CARRY, &data->rx_overruns);
552
553 data->tmpstats.rx_frame_errors =
554 tsi108_read_stat(data, TSI108_STAT_RXALIGN,
555 TSI108_STAT_CARRY1_RXALIGN,
556 TSI108_STAT_RXALIGN_CARRY,
557 &data->stats.rx_frame_errors);
558
559 data->tmpstats.rx_frame_errors +=
560 tsi108_read_stat(data, TSI108_STAT_RXFCS,
561 TSI108_STAT_CARRY1_RXFCS, TSI108_STAT_RXFCS_CARRY,
562 &data->rx_fcs);
563
564 data->tmpstats.rx_frame_errors +=
565 tsi108_read_stat(data, TSI108_STAT_RXFRAG,
566 TSI108_STAT_CARRY1_RXFRAG,
567 TSI108_STAT_RXFRAG_CARRY, &data->rx_short_fcs);
568
569 data->tmpstats.rx_missed_errors =
570 tsi108_read_stat(data, TSI108_STAT_RXDROP,
571 TSI108_STAT_CARRY1_RXDROP,
572 TSI108_STAT_RXDROP_CARRY,
573 &data->stats.rx_missed_errors);
574
575 /* These three are maintained by software. */
576 data->tmpstats.rx_fifo_errors = data->stats.rx_fifo_errors;
577 data->tmpstats.rx_crc_errors = data->stats.rx_crc_errors;
578
579 data->tmpstats.tx_aborted_errors =
580 tsi108_read_stat(data, TSI108_STAT_TXEXDEF,
581 TSI108_STAT_CARRY2_TXEXDEF,
582 TSI108_STAT_TXEXDEF_CARRY,
583 &data->stats.tx_aborted_errors);
584
585 data->tmpstats.tx_aborted_errors +=
586 tsi108_read_stat(data, TSI108_STAT_TXPAUSEDROP,
587 TSI108_STAT_CARRY2_TXPAUSE,
588 TSI108_STAT_TXPAUSEDROP_CARRY,
589 &data->tx_pause_drop);
590
591 data->tmpstats.tx_aborted_errors += excol;
592
593 data->tmpstats.tx_errors = data->tmpstats.tx_aborted_errors;
594 data->tmpstats.rx_errors = data->tmpstats.rx_length_errors +
595 data->tmpstats.rx_crc_errors +
596 data->tmpstats.rx_frame_errors +
597 data->tmpstats.rx_fifo_errors + data->tmpstats.rx_missed_errors;
598
599 spin_unlock_irq(&data->misclock);
600 return &data->tmpstats;
601}
602
603static void tsi108_restart_rx(struct tsi108_prv_data * data, struct net_device *dev)
604{
605 TSI_WRITE(TSI108_EC_RXQ_PTRHIGH,
606 TSI108_EC_RXQ_PTRHIGH_VALID);
607
608 TSI_WRITE(TSI108_EC_RXCTRL, TSI108_EC_RXCTRL_GO
609 | TSI108_EC_RXCTRL_QUEUE0);
610}
611
612static void tsi108_restart_tx(struct tsi108_prv_data * data)
613{
614 TSI_WRITE(TSI108_EC_TXQ_PTRHIGH,
615 TSI108_EC_TXQ_PTRHIGH_VALID);
616
617 TSI_WRITE(TSI108_EC_TXCTRL, TSI108_EC_TXCTRL_IDLEINT |
618 TSI108_EC_TXCTRL_GO | TSI108_EC_TXCTRL_QUEUE0);
619}
620
621/* txlock must be held by caller, with IRQs disabled, and
622 * with permission to re-enable them when the lock is dropped.
623 */
624static void tsi108_complete_tx(struct net_device *dev)
625{
626 struct tsi108_prv_data *data = netdev_priv(dev);
627 int tx;
628 struct sk_buff *skb;
629 int release = 0;
630
631 while (!data->txfree || data->txhead != data->txtail) {
632 tx = data->txtail;
633
634 if (data->txring[tx].misc & TSI108_TX_OWN)
635 break;
636
637 skb = data->txskbs[tx];
638
639 if (!(data->txring[tx].misc & TSI108_TX_OK))
640 printk("%s: bad tx packet, misc %x\n",
641 dev->name, data->txring[tx].misc);
642
643 data->txtail = (data->txtail + 1) % TSI108_TXRING_LEN;
644 data->txfree++;
645
646 if (data->txring[tx].misc & TSI108_TX_EOF) {
647 dev_kfree_skb_any(skb);
648 release++;
649 }
650 }
651
652 if (release) {
653 if (is_valid_ether_addr(dev->dev_addr) && data->link_up)
654 netif_wake_queue(dev);
655 }
656}
657
658static int tsi108_send_packet(struct sk_buff * skb, struct net_device *dev)
659{
660 struct tsi108_prv_data *data = netdev_priv(dev);
661 int frags = skb_shinfo(skb)->nr_frags + 1;
662 int i;
663
664 if (!data->phy_ok && net_ratelimit())
665 printk(KERN_ERR "%s: Transmit while PHY is down!\n", dev->name);
666
667 if (!data->link_up) {
668 printk(KERN_ERR "%s: Transmit while link is down!\n",
669 dev->name);
670 netif_stop_queue(dev);
671 return NETDEV_TX_BUSY;
672 }
673
674 if (data->txfree < MAX_SKB_FRAGS + 1) {
675 netif_stop_queue(dev);
676
677 if (net_ratelimit())
678 printk(KERN_ERR "%s: Transmit with full tx ring!\n",
679 dev->name);
680 return NETDEV_TX_BUSY;
681 }
682
683 if (data->txfree - frags < MAX_SKB_FRAGS + 1) {
684 netif_stop_queue(dev);
685 }
686
687 spin_lock_irq(&data->txlock);
688
689 for (i = 0; i < frags; i++) {
690 int misc = 0;
691 int tx = data->txhead;
692
693 /* This is done to mark every TSI108_TX_INT_FREQ tx buffers with
694 * the interrupt bit. TX descriptor-complete interrupts are
695 * enabled when the queue fills up, and masked when there is
696 * still free space. This way, when saturating the outbound
697 * link, the tx interrupts are kept to a reasonable level.
698 * When the queue is not full, reclamation of skbs still occurs
699 * as new packets are transmitted, or on a queue-empty
700 * interrupt.
701 */
702
703 if ((tx % TSI108_TX_INT_FREQ == 0) &&
704 ((TSI108_TXRING_LEN - data->txfree) >= TSI108_TX_INT_FREQ))
705 misc = TSI108_TX_INT;
706
707 data->txskbs[tx] = skb;
708
709 if (i == 0) {
710 data->txring[tx].buf0 = dma_map_single(NULL, skb->data,
711 skb->len - skb->data_len, DMA_TO_DEVICE);
712 data->txring[tx].len = skb->len - skb->data_len;
713 misc |= TSI108_TX_SOF;
714 } else {
715 skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
716
717 data->txring[tx].buf0 =
718 dma_map_page(NULL, frag->page, frag->page_offset,
719 frag->size, DMA_TO_DEVICE);
720 data->txring[tx].len = frag->size;
721 }
722
723 if (i == frags - 1)
724 misc |= TSI108_TX_EOF;
725
726 if (netif_msg_pktdata(data)) {
727 int i;
728 printk("%s: Tx Frame contents (%d)\n", dev->name,
729 skb->len);
730 for (i = 0; i < skb->len; i++)
731 printk(" %2.2x", skb->data[i]);
732 printk(".\n");
733 }
734 data->txring[tx].misc = misc | TSI108_TX_OWN;
735
736 data->txhead = (data->txhead + 1) % TSI108_TXRING_LEN;
737 data->txfree--;
738 }
739
740 tsi108_complete_tx(dev);
741
742 /* This must be done after the check for completed tx descriptors,
743 * so that the tail pointer is correct.
744 */
745
746 if (!(TSI_READ(TSI108_EC_TXSTAT) & TSI108_EC_TXSTAT_QUEUE0))
747 tsi108_restart_tx(data);
748
749 spin_unlock_irq(&data->txlock);
750 return NETDEV_TX_OK;
751}
752
753static int tsi108_complete_rx(struct net_device *dev, int budget)
754{
755 struct tsi108_prv_data *data = netdev_priv(dev);
756 int done = 0;
757
758 while (data->rxfree && done != budget) {
759 int rx = data->rxtail;
760 struct sk_buff *skb;
761
762 if (data->rxring[rx].misc & TSI108_RX_OWN)
763 break;
764
765 skb = data->rxskbs[rx];
766 data->rxtail = (data->rxtail + 1) % TSI108_RXRING_LEN;
767 data->rxfree--;
768 done++;
769
770 if (data->rxring[rx].misc & TSI108_RX_BAD) {
771 spin_lock_irq(&data->misclock);
772
773 if (data->rxring[rx].misc & TSI108_RX_CRC)
774 data->stats.rx_crc_errors++;
775 if (data->rxring[rx].misc & TSI108_RX_OVER)
776 data->stats.rx_fifo_errors++;
777
778 spin_unlock_irq(&data->misclock);
779
780 dev_kfree_skb_any(skb);
781 continue;
782 }
783 if (netif_msg_pktdata(data)) {
784 int i;
785 printk("%s: Rx Frame contents (%d)\n",
786 dev->name, data->rxring[rx].len);
787 for (i = 0; i < data->rxring[rx].len; i++)
788 printk(" %2.2x", skb->data[i]);
789 printk(".\n");
790 }
791
792 skb->dev = dev;
793 skb_put(skb, data->rxring[rx].len);
794 skb->protocol = eth_type_trans(skb, dev);
795 netif_receive_skb(skb);
796 dev->last_rx = jiffies;
797 }
798
799 return done;
800}
801
802static int tsi108_refill_rx(struct net_device *dev, int budget)
803{
804 struct tsi108_prv_data *data = netdev_priv(dev);
805 int done = 0;
806
807 while (data->rxfree != TSI108_RXRING_LEN && done != budget) {
808 int rx = data->rxhead;
809 struct sk_buff *skb;
810
811 data->rxskbs[rx] = skb = dev_alloc_skb(TSI108_RXBUF_SIZE + 2);
812 if (!skb)
813 break;
814
815 skb_reserve(skb, 2); /* Align the data on a 4-byte boundary. */
816
817 data->rxring[rx].buf0 = dma_map_single(NULL, skb->data,
818 TSI108_RX_SKB_SIZE,
819 DMA_FROM_DEVICE);
820
821 /* Sometimes the hardware sets blen to zero after packet
822 * reception, even though the manual says that it's only ever
823 * modified by the driver.
824 */
825
826 data->rxring[rx].blen = TSI108_RX_SKB_SIZE;
827 data->rxring[rx].misc = TSI108_RX_OWN | TSI108_RX_INT;
828
829 data->rxhead = (data->rxhead + 1) % TSI108_RXRING_LEN;
830 data->rxfree++;
831 done++;
832 }
833
834 if (done != 0 && !(TSI_READ(TSI108_EC_RXSTAT) &
835 TSI108_EC_RXSTAT_QUEUE0))
836 tsi108_restart_rx(data, dev);
837
838 return done;
839}
840
841static int tsi108_poll(struct net_device *dev, int *budget)
842{
843 struct tsi108_prv_data *data = netdev_priv(dev);
844 u32 estat = TSI_READ(TSI108_EC_RXESTAT);
845 u32 intstat = TSI_READ(TSI108_EC_INTSTAT);
846 int total_budget = min(*budget, dev->quota);
847 int num_received = 0, num_filled = 0, budget_used;
848
849 intstat &= TSI108_INT_RXQUEUE0 | TSI108_INT_RXTHRESH |
850 TSI108_INT_RXOVERRUN | TSI108_INT_RXERROR | TSI108_INT_RXWAIT;
851
852 TSI_WRITE(TSI108_EC_RXESTAT, estat);
853 TSI_WRITE(TSI108_EC_INTSTAT, intstat);
854
855 if (data->rxpending || (estat & TSI108_EC_RXESTAT_Q0_DESCINT))
856 num_received = tsi108_complete_rx(dev, total_budget);
857
858 /* This should normally fill no more slots than the number of
859 * packets received in tsi108_complete_rx(). The exception
860 * is when we previously ran out of memory for RX SKBs. In that
861 * case, it's helpful to obey the budget, not only so that the
862 * CPU isn't hogged, but so that memory (which may still be low)
863 * is not hogged by one device.
864 *
865 * A work unit is considered to be two SKBs to allow us to catch
866 * up when the ring has shrunk due to out-of-memory but we're
867 * still removing the full budget's worth of packets each time.
868 */
869
870 if (data->rxfree < TSI108_RXRING_LEN)
871 num_filled = tsi108_refill_rx(dev, total_budget * 2);
872
873 if (intstat & TSI108_INT_RXERROR) {
874 u32 err = TSI_READ(TSI108_EC_RXERR);
875 TSI_WRITE(TSI108_EC_RXERR, err);
876
877 if (err) {
878 if (net_ratelimit())
879 printk(KERN_DEBUG "%s: RX error %x\n",
880 dev->name, err);
881
882 if (!(TSI_READ(TSI108_EC_RXSTAT) &
883 TSI108_EC_RXSTAT_QUEUE0))
884 tsi108_restart_rx(data, dev);
885 }
886 }
887
888 if (intstat & TSI108_INT_RXOVERRUN) {
889 spin_lock_irq(&data->misclock);
890 data->stats.rx_fifo_errors++;
891 spin_unlock_irq(&data->misclock);
892 }
893
894 budget_used = max(num_received, num_filled / 2);
895
896 *budget -= budget_used;
897 dev->quota -= budget_used;
898
899 if (budget_used != total_budget) {
900 data->rxpending = 0;
901 netif_rx_complete(dev);
902
903 TSI_WRITE(TSI108_EC_INTMASK,
904 TSI_READ(TSI108_EC_INTMASK)
905 & ~(TSI108_INT_RXQUEUE0
906 | TSI108_INT_RXTHRESH |
907 TSI108_INT_RXOVERRUN |
908 TSI108_INT_RXERROR |
909 TSI108_INT_RXWAIT));
910
911 /* IRQs are level-triggered, so no need to re-check */
912 return 0;
913 } else {
914 data->rxpending = 1;
915 }
916
917 return 1;
918}
919
920static void tsi108_rx_int(struct net_device *dev)
921{
922 struct tsi108_prv_data *data = netdev_priv(dev);
923
924 /* A race could cause dev to already be scheduled, so it's not an
925 * error if that happens (and interrupts shouldn't be re-masked,
926 * because that can cause harmful races, if poll has already
927 * unmasked them but not cleared LINK_STATE_SCHED).
928 *
929 * This can happen if this code races with tsi108_poll(), which masks
930 * the interrupts after tsi108_irq_one() read the mask, but before
931 * netif_rx_schedule is called. It could also happen due to calls
932 * from tsi108_check_rxring().
933 */
934
935 if (netif_rx_schedule_prep(dev)) {
936 /* Mask, rather than ack, the receive interrupts. The ack
937 * will happen in tsi108_poll().
938 */
939
940 TSI_WRITE(TSI108_EC_INTMASK,
941 TSI_READ(TSI108_EC_INTMASK) |
942 TSI108_INT_RXQUEUE0
943 | TSI108_INT_RXTHRESH |
944 TSI108_INT_RXOVERRUN | TSI108_INT_RXERROR |
945 TSI108_INT_RXWAIT);
946 __netif_rx_schedule(dev);
947 } else {
948 if (!netif_running(dev)) {
949 /* This can happen if an interrupt occurs while the
950 * interface is being brought down, as the START
951 * bit is cleared before the stop function is called.
952 *
953 * In this case, the interrupts must be masked, or
954 * they will continue indefinitely.
955 *
956 * There's a race here if the interface is brought down
957 * and then up in rapid succession, as the device could
958 * be made running after the above check and before
959 * the masking below. This will only happen if the IRQ
960 * thread has a lower priority than the task brining
961 * up the interface. Fixing this race would likely
962 * require changes in generic code.
963 */
964
965 TSI_WRITE(TSI108_EC_INTMASK,
966 TSI_READ
967 (TSI108_EC_INTMASK) |
968 TSI108_INT_RXQUEUE0 |
969 TSI108_INT_RXTHRESH |
970 TSI108_INT_RXOVERRUN |
971 TSI108_INT_RXERROR |
972 TSI108_INT_RXWAIT);
973 }
974 }
975}
976
977/* If the RX ring has run out of memory, try periodically
978 * to allocate some more, as otherwise poll would never
979 * get called (apart from the initial end-of-queue condition).
980 *
981 * This is called once per second (by default) from the thread.
982 */
983
984static void tsi108_check_rxring(struct net_device *dev)
985{
986 struct tsi108_prv_data *data = netdev_priv(dev);
987
988 /* A poll is scheduled, as opposed to caling tsi108_refill_rx
989 * directly, so as to keep the receive path single-threaded
990 * (and thus not needing a lock).
991 */
992
993 if (netif_running(dev) && data->rxfree < TSI108_RXRING_LEN / 4)
994 tsi108_rx_int(dev);
995}
996
997static void tsi108_tx_int(struct net_device *dev)
998{
999 struct tsi108_prv_data *data = netdev_priv(dev);
1000 u32 estat = TSI_READ(TSI108_EC_TXESTAT);
1001
1002 TSI_WRITE(TSI108_EC_TXESTAT, estat);
1003 TSI_WRITE(TSI108_EC_INTSTAT, TSI108_INT_TXQUEUE0 |
1004 TSI108_INT_TXIDLE | TSI108_INT_TXERROR);
1005 if (estat & TSI108_EC_TXESTAT_Q0_ERR) {
1006 u32 err = TSI_READ(TSI108_EC_TXERR);
1007 TSI_WRITE(TSI108_EC_TXERR, err);
1008
1009 if (err && net_ratelimit())
1010 printk(KERN_ERR "%s: TX error %x\n", dev->name, err);
1011 }
1012
1013 if (estat & (TSI108_EC_TXESTAT_Q0_DESCINT | TSI108_EC_TXESTAT_Q0_EOQ)) {
1014 spin_lock(&data->txlock);
1015 tsi108_complete_tx(dev);
1016 spin_unlock(&data->txlock);
1017 }
1018}
1019
1020
1021static irqreturn_t tsi108_irq(int irq, void *dev_id)
1022{
1023 struct net_device *dev = dev_id;
1024 struct tsi108_prv_data *data = netdev_priv(dev);
1025 u32 stat = TSI_READ(TSI108_EC_INTSTAT);
1026
1027 if (!(stat & TSI108_INT_ANY))
1028 return IRQ_NONE; /* Not our interrupt */
1029
1030 stat &= ~TSI_READ(TSI108_EC_INTMASK);
1031
1032 if (stat & (TSI108_INT_TXQUEUE0 | TSI108_INT_TXIDLE |
1033 TSI108_INT_TXERROR))
1034 tsi108_tx_int(dev);
1035 if (stat & (TSI108_INT_RXQUEUE0 | TSI108_INT_RXTHRESH |
1036 TSI108_INT_RXWAIT | TSI108_INT_RXOVERRUN |
1037 TSI108_INT_RXERROR))
1038 tsi108_rx_int(dev);
1039
1040 if (stat & TSI108_INT_SFN) {
1041 if (net_ratelimit())
1042 printk(KERN_DEBUG "%s: SFN error\n", dev->name);
1043 TSI_WRITE(TSI108_EC_INTSTAT, TSI108_INT_SFN);
1044 }
1045
1046 if (stat & TSI108_INT_STATCARRY) {
1047 tsi108_stat_carry(dev);
1048 TSI_WRITE(TSI108_EC_INTSTAT, TSI108_INT_STATCARRY);
1049 }
1050
1051 return IRQ_HANDLED;
1052}
1053
1054static void tsi108_stop_ethernet(struct net_device *dev)
1055{
1056 struct tsi108_prv_data *data = netdev_priv(dev);
1057 int i = 1000;
1058 /* Disable all TX and RX queues ... */
1059 TSI_WRITE(TSI108_EC_TXCTRL, 0);
1060 TSI_WRITE(TSI108_EC_RXCTRL, 0);
1061
1062 /* ...and wait for them to become idle */
1063 while(i--) {
1064 if(!(TSI_READ(TSI108_EC_TXSTAT) & TSI108_EC_TXSTAT_ACTIVE))
1065 break;
1066 udelay(10);
1067 }
1068 i = 1000;
1069 while(i--){
1070 if(!(TSI_READ(TSI108_EC_RXSTAT) & TSI108_EC_RXSTAT_ACTIVE))
1071 return;
1072 udelay(10);
1073 }
1074 printk(KERN_ERR "%s function time out \n", __FUNCTION__);
1075}
1076
1077static void tsi108_reset_ether(struct tsi108_prv_data * data)
1078{
1079 TSI_WRITE(TSI108_MAC_CFG1, TSI108_MAC_CFG1_SOFTRST);
1080 udelay(100);
1081 TSI_WRITE(TSI108_MAC_CFG1, 0);
1082
1083 TSI_WRITE(TSI108_EC_PORTCTRL, TSI108_EC_PORTCTRL_STATRST);
1084 udelay(100);
1085 TSI_WRITE(TSI108_EC_PORTCTRL,
1086 TSI_READ(TSI108_EC_PORTCTRL) &
1087 ~TSI108_EC_PORTCTRL_STATRST);
1088
1089 TSI_WRITE(TSI108_EC_TXCFG, TSI108_EC_TXCFG_RST);
1090 udelay(100);
1091 TSI_WRITE(TSI108_EC_TXCFG,
1092 TSI_READ(TSI108_EC_TXCFG) &
1093 ~TSI108_EC_TXCFG_RST);
1094
1095 TSI_WRITE(TSI108_EC_RXCFG, TSI108_EC_RXCFG_RST);
1096 udelay(100);
1097 TSI_WRITE(TSI108_EC_RXCFG,
1098 TSI_READ(TSI108_EC_RXCFG) &
1099 ~TSI108_EC_RXCFG_RST);
1100
1101 TSI_WRITE(TSI108_MAC_MII_MGMT_CFG,
1102 TSI_READ(TSI108_MAC_MII_MGMT_CFG) |
1103 TSI108_MAC_MII_MGMT_RST);
1104 udelay(100);
1105 TSI_WRITE(TSI108_MAC_MII_MGMT_CFG,
1106 (TSI_READ(TSI108_MAC_MII_MGMT_CFG) &
1107 ~(TSI108_MAC_MII_MGMT_RST |
1108 TSI108_MAC_MII_MGMT_CLK)) | 0x07);
1109}
1110
1111static int tsi108_get_mac(struct net_device *dev)
1112{
1113 struct tsi108_prv_data *data = netdev_priv(dev);
1114 u32 word1 = TSI_READ(TSI108_MAC_ADDR1);
1115 u32 word2 = TSI_READ(TSI108_MAC_ADDR2);
1116
1117 /* Note that the octets are reversed from what the manual says,
1118 * producing an even weirder ordering...
1119 */
1120 if (word2 == 0 && word1 == 0) {
1121 dev->dev_addr[0] = 0x00;
1122 dev->dev_addr[1] = 0x06;
1123 dev->dev_addr[2] = 0xd2;
1124 dev->dev_addr[3] = 0x00;
1125 dev->dev_addr[4] = 0x00;
1126 if (0x8 == data->phy)
1127 dev->dev_addr[5] = 0x01;
1128 else
1129 dev->dev_addr[5] = 0x02;
1130
1131 word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);
1132
1133 word1 = (dev->dev_addr[2] << 0) | (dev->dev_addr[3] << 8) |
1134 (dev->dev_addr[4] << 16) | (dev->dev_addr[5] << 24);
1135
1136 TSI_WRITE(TSI108_MAC_ADDR1, word1);
1137 TSI_WRITE(TSI108_MAC_ADDR2, word2);
1138 } else {
1139 dev->dev_addr[0] = (word2 >> 16) & 0xff;
1140 dev->dev_addr[1] = (word2 >> 24) & 0xff;
1141 dev->dev_addr[2] = (word1 >> 0) & 0xff;
1142 dev->dev_addr[3] = (word1 >> 8) & 0xff;
1143 dev->dev_addr[4] = (word1 >> 16) & 0xff;
1144 dev->dev_addr[5] = (word1 >> 24) & 0xff;
1145 }
1146
1147 if (!is_valid_ether_addr(dev->dev_addr)) {
1148 printk("KERN_ERR: word1: %08x, word2: %08x\n", word1, word2);
1149 return -EINVAL;
1150 }
1151
1152 return 0;
1153}
1154
1155static int tsi108_set_mac(struct net_device *dev, void *addr)
1156{
1157 struct tsi108_prv_data *data = netdev_priv(dev);
1158 u32 word1, word2;
1159 int i;
1160
1161 if (!is_valid_ether_addr(addr))
1162 return -EINVAL;
1163
1164 for (i = 0; i < 6; i++)
1165 /* +2 is for the offset of the HW addr type */
1166 dev->dev_addr[i] = ((unsigned char *)addr)[i + 2];
1167
1168 word2 = (dev->dev_addr[0] << 16) | (dev->dev_addr[1] << 24);
1169
1170 word1 = (dev->dev_addr[2] << 0) | (dev->dev_addr[3] << 8) |
1171 (dev->dev_addr[4] << 16) | (dev->dev_addr[5] << 24);
1172
1173 spin_lock_irq(&data->misclock);
1174 TSI_WRITE(TSI108_MAC_ADDR1, word1);
1175 TSI_WRITE(TSI108_MAC_ADDR2, word2);
1176 spin_lock(&data->txlock);
1177
1178 if (data->txfree && data->link_up)
1179 netif_wake_queue(dev);
1180
1181 spin_unlock(&data->txlock);
1182 spin_unlock_irq(&data->misclock);
1183 return 0;
1184}
1185
1186/* Protected by dev->xmit_lock. */
1187static void tsi108_set_rx_mode(struct net_device *dev)
1188{
1189 struct tsi108_prv_data *data = netdev_priv(dev);
1190 u32 rxcfg = TSI_READ(TSI108_EC_RXCFG);
1191
1192 if (dev->flags & IFF_PROMISC) {
1193 rxcfg &= ~(TSI108_EC_RXCFG_UC_HASH | TSI108_EC_RXCFG_MC_HASH);
1194 rxcfg |= TSI108_EC_RXCFG_UFE | TSI108_EC_RXCFG_MFE;
1195 goto out;
1196 }
1197
1198 rxcfg &= ~(TSI108_EC_RXCFG_UFE | TSI108_EC_RXCFG_MFE);
1199
1200 if (dev->flags & IFF_ALLMULTI || dev->mc_count) {
1201 int i;
1202 struct dev_mc_list *mc = dev->mc_list;
1203 rxcfg |= TSI108_EC_RXCFG_MFE | TSI108_EC_RXCFG_MC_HASH;
1204
1205 memset(data->mc_hash, 0, sizeof(data->mc_hash));
1206
1207 while (mc) {
1208 u32 hash, crc;
1209
1210 if (mc->dmi_addrlen == 6) {
1211 crc = ether_crc(6, mc->dmi_addr);
1212 hash = crc >> 23;
1213
1214 __set_bit(hash, &data->mc_hash[0]);
1215 } else {
1216 printk(KERN_ERR
1217 "%s: got multicast address of length %d "
1218 "instead of 6.\n", dev->name,
1219 mc->dmi_addrlen);
1220 }
1221
1222 mc = mc->next;
1223 }
1224
1225 TSI_WRITE(TSI108_EC_HASHADDR,
1226 TSI108_EC_HASHADDR_AUTOINC |
1227 TSI108_EC_HASHADDR_MCAST);
1228
1229 for (i = 0; i < 16; i++) {
1230 /* The manual says that the hardware may drop
1231 * back-to-back writes to the data register.
1232 */
1233 udelay(1);
1234 TSI_WRITE(TSI108_EC_HASHDATA,
1235 data->mc_hash[i]);
1236 }
1237 }
1238
1239 out:
1240 TSI_WRITE(TSI108_EC_RXCFG, rxcfg);
1241}
1242
1243static void tsi108_init_phy(struct net_device *dev)
1244{
1245 struct tsi108_prv_data *data = netdev_priv(dev);
1246 u32 i = 0;
1247 u16 phyval = 0;
1248 unsigned long flags;
1249
1250 spin_lock_irqsave(&phy_lock, flags);
1251
1252 tsi108_write_mii(data, MII_BMCR, BMCR_RESET);
1253 while (i--){
1254 if(!(tsi108_read_mii(data, MII_BMCR) & BMCR_RESET))
1255 break;
1256 udelay(10);
1257 }
1258 if (i == 0)
1259 printk(KERN_ERR "%s function time out \n", __FUNCTION__);
1260
1261#if (TSI108_PHY_TYPE == PHY_BCM54XX) /* Broadcom BCM54xx PHY */
1262 tsi108_write_mii(data, 0x09, 0x0300);
1263 tsi108_write_mii(data, 0x10, 0x1020);
1264 tsi108_write_mii(data, 0x1c, 0x8c00);
1265#endif
1266
1267 tsi108_write_mii(data,
1268 MII_BMCR,
1269 BMCR_ANENABLE | BMCR_ANRESTART);
1270 while (tsi108_read_mii(data, MII_BMCR) & BMCR_ANRESTART)
1271 cpu_relax();
1272
1273 /* Set G/MII mode and receive clock select in TBI control #2. The
1274 * second port won't work if this isn't done, even though we don't
1275 * use TBI mode.
1276 */
1277
1278 tsi108_write_tbi(data, 0x11, 0x30);
1279
1280 /* FIXME: It seems to take more than 2 back-to-back reads to the
1281 * PHY_STAT register before the link up status bit is set.
1282 */
1283
1284 data->link_up = 1;
1285
1286 while (!((phyval = tsi108_read_mii(data, MII_BMSR)) &
1287 BMSR_LSTATUS)) {
1288 if (i++ > (MII_READ_DELAY / 10)) {
1289 data->link_up = 0;
1290 break;
1291 }
1292 spin_unlock_irqrestore(&phy_lock, flags);
1293 msleep(10);
1294 spin_lock_irqsave(&phy_lock, flags);
1295 }
1296
1297 printk(KERN_DEBUG "PHY_STAT reg contains %08x\n", phyval);
1298 data->phy_ok = 1;
1299 data->init_media = 1;
1300 spin_unlock_irqrestore(&phy_lock, flags);
1301}
1302
1303static void tsi108_kill_phy(struct net_device *dev)
1304{
1305 struct tsi108_prv_data *data = netdev_priv(dev);
1306 unsigned long flags;
1307
1308 spin_lock_irqsave(&phy_lock, flags);
1309 tsi108_write_mii(data, MII_BMCR, BMCR_PDOWN);
1310 data->phy_ok = 0;
1311 spin_unlock_irqrestore(&phy_lock, flags);
1312}
1313
1314static int tsi108_open(struct net_device *dev)
1315{
1316 int i;
1317 struct tsi108_prv_data *data = netdev_priv(dev);
1318 unsigned int rxring_size = TSI108_RXRING_LEN * sizeof(rx_desc);
1319 unsigned int txring_size = TSI108_TXRING_LEN * sizeof(tx_desc);
1320
1321 i = request_irq(data->irq_num, tsi108_irq, 0, dev->name, dev);
1322 if (i != 0) {
1323 printk(KERN_ERR "tsi108_eth%d: Could not allocate IRQ%d.\n",
1324 data->id, data->irq_num);
1325 return i;
1326 } else {
1327 dev->irq = data->irq_num;
1328 printk(KERN_NOTICE
1329 "tsi108_open : Port %d Assigned IRQ %d to %s\n",
1330 data->id, dev->irq, dev->name);
1331 }
1332
1333 data->rxring = dma_alloc_coherent(NULL, rxring_size,
1334 &data->rxdma, GFP_KERNEL);
1335
1336 if (!data->rxring) {
1337 printk(KERN_DEBUG
1338 "TSI108_ETH: failed to allocate memory for rxring!\n");
1339 return -ENOMEM;
1340 } else {
1341 memset(data->rxring, 0, rxring_size);
1342 }
1343
1344 data->txring = dma_alloc_coherent(NULL, txring_size,
1345 &data->txdma, GFP_KERNEL);
1346
1347 if (!data->txring) {
1348 printk(KERN_DEBUG
1349 "TSI108_ETH: failed to allocate memory for txring!\n");
1350 pci_free_consistent(0, rxring_size, data->rxring, data->rxdma);
1351 return -ENOMEM;
1352 } else {
1353 memset(data->txring, 0, txring_size);
1354 }
1355
1356 for (i = 0; i < TSI108_RXRING_LEN; i++) {
1357 data->rxring[i].next0 = data->rxdma + (i + 1) * sizeof(rx_desc);
1358 data->rxring[i].blen = TSI108_RXBUF_SIZE;
1359 data->rxring[i].vlan = 0;
1360 }
1361
1362 data->rxring[TSI108_RXRING_LEN - 1].next0 = data->rxdma;
1363
1364 data->rxtail = 0;
1365 data->rxhead = 0;
1366
1367 for (i = 0; i < TSI108_RXRING_LEN; i++) {
1368 struct sk_buff *skb = dev_alloc_skb(TSI108_RXBUF_SIZE + NET_IP_ALIGN);
1369
1370 if (!skb) {
1371 /* Bah. No memory for now, but maybe we'll get
1372 * some more later.
1373 * For now, we'll live with the smaller ring.
1374 */
1375 printk(KERN_WARNING
1376 "%s: Could only allocate %d receive skb(s).\n",
1377 dev->name, i);
1378 data->rxhead = i;
1379 break;
1380 }
1381
1382 data->rxskbs[i] = skb;
1383 /* Align the payload on a 4-byte boundary */
1384 skb_reserve(skb, 2);
1385 data->rxskbs[i] = skb;
1386 data->rxring[i].buf0 = virt_to_phys(data->rxskbs[i]->data);
1387 data->rxring[i].misc = TSI108_RX_OWN | TSI108_RX_INT;
1388 }
1389
1390 data->rxfree = i;
1391 TSI_WRITE(TSI108_EC_RXQ_PTRLOW, data->rxdma);
1392
1393 for (i = 0; i < TSI108_TXRING_LEN; i++) {
1394 data->txring[i].next0 = data->txdma + (i + 1) * sizeof(tx_desc);
1395 data->txring[i].misc = 0;
1396 }
1397
1398 data->txring[TSI108_TXRING_LEN - 1].next0 = data->txdma;
1399 data->txtail = 0;
1400 data->txhead = 0;
1401 data->txfree = TSI108_TXRING_LEN;
1402 TSI_WRITE(TSI108_EC_TXQ_PTRLOW, data->txdma);
1403 tsi108_init_phy(dev);
1404
1405 setup_timer(&data->timer, tsi108_timed_checker, (unsigned long)dev);
1406 mod_timer(&data->timer, jiffies + 1);
1407
1408 tsi108_restart_rx(data, dev);
1409
1410 TSI_WRITE(TSI108_EC_INTSTAT, ~0);
1411
1412 TSI_WRITE(TSI108_EC_INTMASK,
1413 ~(TSI108_INT_TXQUEUE0 | TSI108_INT_RXERROR |
1414 TSI108_INT_RXTHRESH | TSI108_INT_RXQUEUE0 |
1415 TSI108_INT_RXOVERRUN | TSI108_INT_RXWAIT |
1416 TSI108_INT_SFN | TSI108_INT_STATCARRY));
1417
1418 TSI_WRITE(TSI108_MAC_CFG1,
1419 TSI108_MAC_CFG1_RXEN | TSI108_MAC_CFG1_TXEN);
1420 netif_start_queue(dev);
1421 return 0;
1422}
1423
1424static int tsi108_close(struct net_device *dev)
1425{
1426 struct tsi108_prv_data *data = netdev_priv(dev);
1427
1428 netif_stop_queue(dev);
1429
1430 del_timer_sync(&data->timer);
1431
1432 tsi108_stop_ethernet(dev);
1433 tsi108_kill_phy(dev);
1434 TSI_WRITE(TSI108_EC_INTMASK, ~0);
1435 TSI_WRITE(TSI108_MAC_CFG1, 0);
1436
1437 /* Check for any pending TX packets, and drop them. */
1438
1439 while (!data->txfree || data->txhead != data->txtail) {
1440 int tx = data->txtail;
1441 struct sk_buff *skb;
1442 skb = data->txskbs[tx];
1443 data->txtail = (data->txtail + 1) % TSI108_TXRING_LEN;
1444 data->txfree++;
1445 dev_kfree_skb(skb);
1446 }
1447
1448 synchronize_irq(data->irq_num);
1449 free_irq(data->irq_num, dev);
1450
1451 /* Discard the RX ring. */
1452
1453 while (data->rxfree) {
1454 int rx = data->rxtail;
1455 struct sk_buff *skb;
1456
1457 skb = data->rxskbs[rx];
1458 data->rxtail = (data->rxtail + 1) % TSI108_RXRING_LEN;
1459 data->rxfree--;
1460 dev_kfree_skb(skb);
1461 }
1462
1463 dma_free_coherent(0,
1464 TSI108_RXRING_LEN * sizeof(rx_desc),
1465 data->rxring, data->rxdma);
1466 dma_free_coherent(0,
1467 TSI108_TXRING_LEN * sizeof(tx_desc),
1468 data->txring, data->txdma);
1469
1470 return 0;
1471}
1472
1473static void tsi108_init_mac(struct net_device *dev)
1474{
1475 struct tsi108_prv_data *data = netdev_priv(dev);
1476
1477 TSI_WRITE(TSI108_MAC_CFG2, TSI108_MAC_CFG2_DFLT_PREAMBLE |
1478 TSI108_MAC_CFG2_PADCRC);
1479
1480 TSI_WRITE(TSI108_EC_TXTHRESH,
1481 (192 << TSI108_EC_TXTHRESH_STARTFILL) |
1482 (192 << TSI108_EC_TXTHRESH_STOPFILL));
1483
1484 TSI_WRITE(TSI108_STAT_CARRYMASK1,
1485 ~(TSI108_STAT_CARRY1_RXBYTES |
1486 TSI108_STAT_CARRY1_RXPKTS |
1487 TSI108_STAT_CARRY1_RXFCS |
1488 TSI108_STAT_CARRY1_RXMCAST |
1489 TSI108_STAT_CARRY1_RXALIGN |
1490 TSI108_STAT_CARRY1_RXLENGTH |
1491 TSI108_STAT_CARRY1_RXRUNT |
1492 TSI108_STAT_CARRY1_RXJUMBO |
1493 TSI108_STAT_CARRY1_RXFRAG |
1494 TSI108_STAT_CARRY1_RXJABBER |
1495 TSI108_STAT_CARRY1_RXDROP));
1496
1497 TSI_WRITE(TSI108_STAT_CARRYMASK2,
1498 ~(TSI108_STAT_CARRY2_TXBYTES |
1499 TSI108_STAT_CARRY2_TXPKTS |
1500 TSI108_STAT_CARRY2_TXEXDEF |
1501 TSI108_STAT_CARRY2_TXEXCOL |
1502 TSI108_STAT_CARRY2_TXTCOL |
1503 TSI108_STAT_CARRY2_TXPAUSE));
1504
1505 TSI_WRITE(TSI108_EC_PORTCTRL, TSI108_EC_PORTCTRL_STATEN);
1506 TSI_WRITE(TSI108_MAC_CFG1, 0);
1507
1508 TSI_WRITE(TSI108_EC_RXCFG,
1509 TSI108_EC_RXCFG_SE | TSI108_EC_RXCFG_BFE);
1510
1511 TSI_WRITE(TSI108_EC_TXQ_CFG, TSI108_EC_TXQ_CFG_DESC_INT |
1512 TSI108_EC_TXQ_CFG_EOQ_OWN_INT |
1513 TSI108_EC_TXQ_CFG_WSWP | (TSI108_PBM_PORT <<
1514 TSI108_EC_TXQ_CFG_SFNPORT));
1515
1516 TSI_WRITE(TSI108_EC_RXQ_CFG, TSI108_EC_RXQ_CFG_DESC_INT |
1517 TSI108_EC_RXQ_CFG_EOQ_OWN_INT |
1518 TSI108_EC_RXQ_CFG_WSWP | (TSI108_PBM_PORT <<
1519 TSI108_EC_RXQ_CFG_SFNPORT));
1520
1521 TSI_WRITE(TSI108_EC_TXQ_BUFCFG,
1522 TSI108_EC_TXQ_BUFCFG_BURST256 |
1523 TSI108_EC_TXQ_BUFCFG_BSWP | (TSI108_PBM_PORT <<
1524 TSI108_EC_TXQ_BUFCFG_SFNPORT));
1525
1526 TSI_WRITE(TSI108_EC_RXQ_BUFCFG,
1527 TSI108_EC_RXQ_BUFCFG_BURST256 |
1528 TSI108_EC_RXQ_BUFCFG_BSWP | (TSI108_PBM_PORT <<
1529 TSI108_EC_RXQ_BUFCFG_SFNPORT));
1530
1531 TSI_WRITE(TSI108_EC_INTMASK, ~0);
1532}
1533
1534static int tsi108_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1535{
1536 struct tsi108_prv_data *data = netdev_priv(dev);
1537 return generic_mii_ioctl(&data->mii_if, if_mii(rq), cmd, NULL);
1538}
1539
1540static int
1541tsi108_init_one(struct platform_device *pdev)
1542{
1543 struct net_device *dev = NULL;
1544 struct tsi108_prv_data *data = NULL;
1545 hw_info *einfo;
1546 int err = 0;
1547
1548 einfo = pdev->dev.platform_data;
1549
1550 if (NULL == einfo) {
1551 printk(KERN_ERR "tsi-eth %d: Missing additional data!\n",
1552 pdev->id);
1553 return -ENODEV;
1554 }
1555
1556 /* Create an ethernet device instance */
1557
1558 dev = alloc_etherdev(sizeof(struct tsi108_prv_data));
1559 if (!dev) {
1560 printk("tsi108_eth: Could not allocate a device structure\n");
1561 return -ENOMEM;
1562 }
1563
1564 printk("tsi108_eth%d: probe...\n", pdev->id);
1565 data = netdev_priv(dev);
1566
1567 pr_debug("tsi108_eth%d:regs:phyresgs:phy:irq_num=0x%x:0x%x:0x%x:0x%x\n",
1568 pdev->id, einfo->regs, einfo->phyregs,
1569 einfo->phy, einfo->irq_num);
1570
1571 data->regs = ioremap(einfo->regs, 0x400);
1572 if (NULL == data->regs) {
1573 err = -ENOMEM;
1574 goto regs_fail;
1575 }
1576
1577 data->phyregs = ioremap(einfo->phyregs, 0x400);
1578 if (NULL == data->phyregs) {
1579 err = -ENOMEM;
1580 goto regs_fail;
1581 }
1582/* MII setup */
1583 data->mii_if.dev = dev;
1584 data->mii_if.mdio_read = tsi108_mdio_read;
1585 data->mii_if.mdio_write = tsi108_mdio_write;
1586 data->mii_if.phy_id = einfo->phy;
1587 data->mii_if.phy_id_mask = 0x1f;
1588 data->mii_if.reg_num_mask = 0x1f;
1589 data->mii_if.supports_gmii = mii_check_gmii_support(&data->mii_if);
1590
1591 data->phy = einfo->phy;
1592 data->irq_num = einfo->irq_num;
1593 data->id = pdev->id;
1594 dev->open = tsi108_open;
1595 dev->stop = tsi108_close;
1596 dev->hard_start_xmit = tsi108_send_packet;
1597 dev->set_mac_address = tsi108_set_mac;
1598 dev->set_multicast_list = tsi108_set_rx_mode;
1599 dev->get_stats = tsi108_get_stats;
1600 dev->poll = tsi108_poll;
1601 dev->do_ioctl = tsi108_do_ioctl;
1602 dev->weight = 64; /* 64 is more suitable for GigE interface - klai */
1603
1604 /* Apparently, the Linux networking code won't use scatter-gather
1605 * if the hardware doesn't do checksums. However, it's faster
1606 * to checksum in place and use SG, as (among other reasons)
1607 * the cache won't be dirtied (which then has to be flushed
1608 * before DMA). The checksumming is done by the driver (via
1609 * a new function skb_csum_dev() in net/core/skbuff.c).
1610 */
1611
1612 dev->features = NETIF_F_HIGHDMA;
1613 SET_MODULE_OWNER(dev);
1614
1615 spin_lock_init(&data->txlock);
1616 spin_lock_init(&data->misclock);
1617
1618 tsi108_reset_ether(data);
1619 tsi108_kill_phy(dev);
1620
1621 if ((err = tsi108_get_mac(dev)) != 0) {
1622 printk(KERN_ERR "%s: Invalid MAC address. Please correct.\n",
1623 dev->name);
1624 goto register_fail;
1625 }
1626
1627 tsi108_init_mac(dev);
1628 err = register_netdev(dev);
1629 if (err) {
1630 printk(KERN_ERR "%s: Cannot register net device, aborting.\n",
1631 dev->name);
1632 goto register_fail;
1633 }
1634
1635 printk(KERN_INFO "%s: Tsi108 Gigabit Ethernet, MAC: "
1636 "%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name,
1637 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1638 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
1639#ifdef DEBUG
1640 data->msg_enable = DEBUG;
1641 dump_eth_one(dev);
1642#endif
1643
1644 return 0;
1645
1646register_fail:
1647 iounmap(data->regs);
1648 iounmap(data->phyregs);
1649
1650regs_fail:
1651 free_netdev(dev);
1652 return err;
1653}
1654
1655/* There's no way to either get interrupts from the PHY when
1656 * something changes, or to have the Tsi108 automatically communicate
1657 * with the PHY to reconfigure itself.
1658 *
1659 * Thus, we have to do it using a timer.
1660 */
1661
1662static void tsi108_timed_checker(unsigned long dev_ptr)
1663{
1664 struct net_device *dev = (struct net_device *)dev_ptr;
1665 struct tsi108_prv_data *data = netdev_priv(dev);
1666
1667 tsi108_check_phy(dev);
1668 tsi108_check_rxring(dev);
1669 mod_timer(&data->timer, jiffies + CHECK_PHY_INTERVAL);
1670}
1671
1672static int tsi108_ether_init(void)
1673{
1674 int ret;
1675 ret = platform_driver_register (&tsi_eth_driver);
1676 if (ret < 0){
1677 printk("tsi108_ether_init: error initializing ethernet "
1678 "device\n");
1679 return ret;
1680 }
1681 return 0;
1682}
1683
1684static int tsi108_ether_remove(struct platform_device *pdev)
1685{
1686 struct net_device *dev = platform_get_drvdata(pdev);
1687 struct tsi108_prv_data *priv = netdev_priv(dev);
1688
1689 unregister_netdev(dev);
1690 tsi108_stop_ethernet(dev);
1691 platform_set_drvdata(pdev, NULL);
1692 iounmap(priv->regs);
1693 iounmap(priv->phyregs);
1694 free_netdev(dev);
1695
1696 return 0;
1697}
1698static void tsi108_ether_exit(void)
1699{
1700 platform_driver_unregister(&tsi_eth_driver);
1701}
1702
1703module_init(tsi108_ether_init);
1704module_exit(tsi108_ether_exit);
1705
1706MODULE_AUTHOR("Tundra Semiconductor Corporation");
1707MODULE_DESCRIPTION("Tsi108 Gigabit Ethernet driver");
1708MODULE_LICENSE("GPL");
diff --git a/drivers/net/tsi108_eth.h b/drivers/net/tsi108_eth.h
new file mode 100644
index 000000000000..77a769df228a
--- /dev/null
+++ b/drivers/net/tsi108_eth.h
@@ -0,0 +1,365 @@
1/*
2 * (C) Copyright 2005 Tundra Semiconductor Corp.
3 * Kong Lai, <kong.lai@tundra.com).
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24/*
25 * net/tsi108_eth.h - definitions for Tsi108 GIGE network controller.
26 */
27
28#ifndef __TSI108_ETH_H
29#define __TSI108_ETH_H
30
31#include <linux/types.h>
32
33#define TSI_WRITE(offset, val) \
34 out_be32((data->regs + (offset)), val)
35
36#define TSI_READ(offset) \
37 in_be32((data->regs + (offset)))
38
39#define TSI_WRITE_PHY(offset, val) \
40 out_be32((data->phyregs + (offset)), val)
41
42#define TSI_READ_PHY(offset) \
43 in_be32((data->phyregs + (offset)))
44
45/*
46 * PHY Configuration Options
47 *
48 * NOTE: Enable set of definitions corresponding to your board type
49 */
50#define PHY_MV88E 1 /* Marvel 88Exxxx PHY */
51#define PHY_BCM54XX 2 /* Broardcom BCM54xx PHY */
52#define TSI108_PHY_TYPE PHY_MV88E
53
54/*
55 * TSI108 GIGE port registers
56 */
57
58#define TSI108_ETH_PORT_NUM 2
59#define TSI108_PBM_PORT 2
60#define TSI108_SDRAM_PORT 4
61
62#define TSI108_MAC_CFG1 (0x000)
63#define TSI108_MAC_CFG1_SOFTRST (1 << 31)
64#define TSI108_MAC_CFG1_LOOPBACK (1 << 8)
65#define TSI108_MAC_CFG1_RXEN (1 << 2)
66#define TSI108_MAC_CFG1_TXEN (1 << 0)
67
68#define TSI108_MAC_CFG2 (0x004)
69#define TSI108_MAC_CFG2_DFLT_PREAMBLE (7 << 12)
70#define TSI108_MAC_CFG2_IFACE_MASK (3 << 8)
71#define TSI108_MAC_CFG2_NOGIG (1 << 8)
72#define TSI108_MAC_CFG2_GIG (2 << 8)
73#define TSI108_MAC_CFG2_PADCRC (1 << 2)
74#define TSI108_MAC_CFG2_FULLDUPLEX (1 << 0)
75
76#define TSI108_MAC_MII_MGMT_CFG (0x020)
77#define TSI108_MAC_MII_MGMT_CLK (7 << 0)
78#define TSI108_MAC_MII_MGMT_RST (1 << 31)
79
80#define TSI108_MAC_MII_CMD (0x024)
81#define TSI108_MAC_MII_CMD_READ (1 << 0)
82
83#define TSI108_MAC_MII_ADDR (0x028)
84#define TSI108_MAC_MII_ADDR_REG 0
85#define TSI108_MAC_MII_ADDR_PHY 8
86
87#define TSI108_MAC_MII_DATAOUT (0x02c)
88#define TSI108_MAC_MII_DATAIN (0x030)
89
90#define TSI108_MAC_MII_IND (0x034)
91#define TSI108_MAC_MII_IND_NOTVALID (1 << 2)
92#define TSI108_MAC_MII_IND_SCANNING (1 << 1)
93#define TSI108_MAC_MII_IND_BUSY (1 << 0)
94
95#define TSI108_MAC_IFCTRL (0x038)
96#define TSI108_MAC_IFCTRL_PHYMODE (1 << 24)
97
98#define TSI108_MAC_ADDR1 (0x040)
99#define TSI108_MAC_ADDR2 (0x044)
100
101#define TSI108_STAT_RXBYTES (0x06c)
102#define TSI108_STAT_RXBYTES_CARRY (1 << 24)
103
104#define TSI108_STAT_RXPKTS (0x070)
105#define TSI108_STAT_RXPKTS_CARRY (1 << 18)
106
107#define TSI108_STAT_RXFCS (0x074)
108#define TSI108_STAT_RXFCS_CARRY (1 << 12)
109
110#define TSI108_STAT_RXMCAST (0x078)
111#define TSI108_STAT_RXMCAST_CARRY (1 << 18)
112
113#define TSI108_STAT_RXALIGN (0x08c)
114#define TSI108_STAT_RXALIGN_CARRY (1 << 12)
115
116#define TSI108_STAT_RXLENGTH (0x090)
117#define TSI108_STAT_RXLENGTH_CARRY (1 << 12)
118
119#define TSI108_STAT_RXRUNT (0x09c)
120#define TSI108_STAT_RXRUNT_CARRY (1 << 12)
121
122#define TSI108_STAT_RXJUMBO (0x0a0)
123#define TSI108_STAT_RXJUMBO_CARRY (1 << 12)
124
125#define TSI108_STAT_RXFRAG (0x0a4)
126#define TSI108_STAT_RXFRAG_CARRY (1 << 12)
127
128#define TSI108_STAT_RXJABBER (0x0a8)
129#define TSI108_STAT_RXJABBER_CARRY (1 << 12)
130
131#define TSI108_STAT_RXDROP (0x0ac)
132#define TSI108_STAT_RXDROP_CARRY (1 << 12)
133
134#define TSI108_STAT_TXBYTES (0x0b0)
135#define TSI108_STAT_TXBYTES_CARRY (1 << 24)
136
137#define TSI108_STAT_TXPKTS (0x0b4)
138#define TSI108_STAT_TXPKTS_CARRY (1 << 18)
139
140#define TSI108_STAT_TXEXDEF (0x0c8)
141#define TSI108_STAT_TXEXDEF_CARRY (1 << 12)
142
143#define TSI108_STAT_TXEXCOL (0x0d8)
144#define TSI108_STAT_TXEXCOL_CARRY (1 << 12)
145
146#define TSI108_STAT_TXTCOL (0x0dc)
147#define TSI108_STAT_TXTCOL_CARRY (1 << 13)
148
149#define TSI108_STAT_TXPAUSEDROP (0x0e4)
150#define TSI108_STAT_TXPAUSEDROP_CARRY (1 << 12)
151
152#define TSI108_STAT_CARRY1 (0x100)
153#define TSI108_STAT_CARRY1_RXBYTES (1 << 16)
154#define TSI108_STAT_CARRY1_RXPKTS (1 << 15)
155#define TSI108_STAT_CARRY1_RXFCS (1 << 14)
156#define TSI108_STAT_CARRY1_RXMCAST (1 << 13)
157#define TSI108_STAT_CARRY1_RXALIGN (1 << 8)
158#define TSI108_STAT_CARRY1_RXLENGTH (1 << 7)
159#define TSI108_STAT_CARRY1_RXRUNT (1 << 4)
160#define TSI108_STAT_CARRY1_RXJUMBO (1 << 3)
161#define TSI108_STAT_CARRY1_RXFRAG (1 << 2)
162#define TSI108_STAT_CARRY1_RXJABBER (1 << 1)
163#define TSI108_STAT_CARRY1_RXDROP (1 << 0)
164
165#define TSI108_STAT_CARRY2 (0x104)
166#define TSI108_STAT_CARRY2_TXBYTES (1 << 13)
167#define TSI108_STAT_CARRY2_TXPKTS (1 << 12)
168#define TSI108_STAT_CARRY2_TXEXDEF (1 << 7)
169#define TSI108_STAT_CARRY2_TXEXCOL (1 << 3)
170#define TSI108_STAT_CARRY2_TXTCOL (1 << 2)
171#define TSI108_STAT_CARRY2_TXPAUSE (1 << 0)
172
173#define TSI108_STAT_CARRYMASK1 (0x108)
174#define TSI108_STAT_CARRYMASK2 (0x10c)
175
176#define TSI108_EC_PORTCTRL (0x200)
177#define TSI108_EC_PORTCTRL_STATRST (1 << 31)
178#define TSI108_EC_PORTCTRL_STATEN (1 << 28)
179#define TSI108_EC_PORTCTRL_NOGIG (1 << 18)
180#define TSI108_EC_PORTCTRL_HALFDUPLEX (1 << 16)
181
182#define TSI108_EC_INTSTAT (0x204)
183#define TSI108_EC_INTMASK (0x208)
184
185#define TSI108_INT_ANY (1 << 31)
186#define TSI108_INT_SFN (1 << 30)
187#define TSI108_INT_RXIDLE (1 << 29)
188#define TSI108_INT_RXABORT (1 << 28)
189#define TSI108_INT_RXERROR (1 << 27)
190#define TSI108_INT_RXOVERRUN (1 << 26)
191#define TSI108_INT_RXTHRESH (1 << 25)
192#define TSI108_INT_RXWAIT (1 << 24)
193#define TSI108_INT_RXQUEUE0 (1 << 16)
194#define TSI108_INT_STATCARRY (1 << 15)
195#define TSI108_INT_TXIDLE (1 << 13)
196#define TSI108_INT_TXABORT (1 << 12)
197#define TSI108_INT_TXERROR (1 << 11)
198#define TSI108_INT_TXUNDERRUN (1 << 10)
199#define TSI108_INT_TXTHRESH (1 << 9)
200#define TSI108_INT_TXWAIT (1 << 8)
201#define TSI108_INT_TXQUEUE0 (1 << 0)
202
203#define TSI108_EC_TXCFG (0x220)
204#define TSI108_EC_TXCFG_RST (1 << 31)
205
206#define TSI108_EC_TXCTRL (0x224)
207#define TSI108_EC_TXCTRL_IDLEINT (1 << 31)
208#define TSI108_EC_TXCTRL_ABORT (1 << 30)
209#define TSI108_EC_TXCTRL_GO (1 << 15)
210#define TSI108_EC_TXCTRL_QUEUE0 (1 << 0)
211
212#define TSI108_EC_TXSTAT (0x228)
213#define TSI108_EC_TXSTAT_ACTIVE (1 << 15)
214#define TSI108_EC_TXSTAT_QUEUE0 (1 << 0)
215
216#define TSI108_EC_TXESTAT (0x22c)
217#define TSI108_EC_TXESTAT_Q0_ERR (1 << 24)
218#define TSI108_EC_TXESTAT_Q0_DESCINT (1 << 16)
219#define TSI108_EC_TXESTAT_Q0_EOF (1 << 8)
220#define TSI108_EC_TXESTAT_Q0_EOQ (1 << 0)
221
222#define TSI108_EC_TXERR (0x278)
223
224#define TSI108_EC_TXQ_CFG (0x280)
225#define TSI108_EC_TXQ_CFG_DESC_INT (1 << 20)
226#define TSI108_EC_TXQ_CFG_EOQ_OWN_INT (1 << 19)
227#define TSI108_EC_TXQ_CFG_WSWP (1 << 11)
228#define TSI108_EC_TXQ_CFG_BSWP (1 << 10)
229#define TSI108_EC_TXQ_CFG_SFNPORT 0
230
231#define TSI108_EC_TXQ_BUFCFG (0x284)
232#define TSI108_EC_TXQ_BUFCFG_BURST8 (0 << 8)
233#define TSI108_EC_TXQ_BUFCFG_BURST32 (1 << 8)
234#define TSI108_EC_TXQ_BUFCFG_BURST128 (2 << 8)
235#define TSI108_EC_TXQ_BUFCFG_BURST256 (3 << 8)
236#define TSI108_EC_TXQ_BUFCFG_WSWP (1 << 11)
237#define TSI108_EC_TXQ_BUFCFG_BSWP (1 << 10)
238#define TSI108_EC_TXQ_BUFCFG_SFNPORT 0
239
240#define TSI108_EC_TXQ_PTRLOW (0x288)
241
242#define TSI108_EC_TXQ_PTRHIGH (0x28c)
243#define TSI108_EC_TXQ_PTRHIGH_VALID (1 << 31)
244
245#define TSI108_EC_TXTHRESH (0x230)
246#define TSI108_EC_TXTHRESH_STARTFILL 0
247#define TSI108_EC_TXTHRESH_STOPFILL 16
248
249#define TSI108_EC_RXCFG (0x320)
250#define TSI108_EC_RXCFG_RST (1 << 31)
251
252#define TSI108_EC_RXSTAT (0x328)
253#define TSI108_EC_RXSTAT_ACTIVE (1 << 15)
254#define TSI108_EC_RXSTAT_QUEUE0 (1 << 0)
255
256#define TSI108_EC_RXESTAT (0x32c)
257#define TSI108_EC_RXESTAT_Q0_ERR (1 << 24)
258#define TSI108_EC_RXESTAT_Q0_DESCINT (1 << 16)
259#define TSI108_EC_RXESTAT_Q0_EOF (1 << 8)
260#define TSI108_EC_RXESTAT_Q0_EOQ (1 << 0)
261
262#define TSI108_EC_HASHADDR (0x360)
263#define TSI108_EC_HASHADDR_AUTOINC (1 << 31)
264#define TSI108_EC_HASHADDR_DO1STREAD (1 << 30)
265#define TSI108_EC_HASHADDR_UNICAST (0 << 4)
266#define TSI108_EC_HASHADDR_MCAST (1 << 4)
267
268#define TSI108_EC_HASHDATA (0x364)
269
270#define TSI108_EC_RXQ_PTRLOW (0x388)
271
272#define TSI108_EC_RXQ_PTRHIGH (0x38c)
273#define TSI108_EC_RXQ_PTRHIGH_VALID (1 << 31)
274
275/* Station Enable -- accept packets destined for us */
276#define TSI108_EC_RXCFG_SE (1 << 13)
277/* Unicast Frame Enable -- for packets not destined for us */
278#define TSI108_EC_RXCFG_UFE (1 << 12)
279/* Multicast Frame Enable */
280#define TSI108_EC_RXCFG_MFE (1 << 11)
281/* Broadcast Frame Enable */
282#define TSI108_EC_RXCFG_BFE (1 << 10)
283#define TSI108_EC_RXCFG_UC_HASH (1 << 9)
284#define TSI108_EC_RXCFG_MC_HASH (1 << 8)
285
286#define TSI108_EC_RXQ_CFG (0x380)
287#define TSI108_EC_RXQ_CFG_DESC_INT (1 << 20)
288#define TSI108_EC_RXQ_CFG_EOQ_OWN_INT (1 << 19)
289#define TSI108_EC_RXQ_CFG_WSWP (1 << 11)
290#define TSI108_EC_RXQ_CFG_BSWP (1 << 10)
291#define TSI108_EC_RXQ_CFG_SFNPORT 0
292
293#define TSI108_EC_RXQ_BUFCFG (0x384)
294#define TSI108_EC_RXQ_BUFCFG_BURST8 (0 << 8)
295#define TSI108_EC_RXQ_BUFCFG_BURST32 (1 << 8)
296#define TSI108_EC_RXQ_BUFCFG_BURST128 (2 << 8)
297#define TSI108_EC_RXQ_BUFCFG_BURST256 (3 << 8)
298#define TSI108_EC_RXQ_BUFCFG_WSWP (1 << 11)
299#define TSI108_EC_RXQ_BUFCFG_BSWP (1 << 10)
300#define TSI108_EC_RXQ_BUFCFG_SFNPORT 0
301
302#define TSI108_EC_RXCTRL (0x324)
303#define TSI108_EC_RXCTRL_ABORT (1 << 30)
304#define TSI108_EC_RXCTRL_GO (1 << 15)
305#define TSI108_EC_RXCTRL_QUEUE0 (1 << 0)
306
307#define TSI108_EC_RXERR (0x378)
308
309#define TSI108_TX_EOF (1 << 0) /* End of frame; last fragment of packet */
310#define TSI108_TX_SOF (1 << 1) /* Start of frame; first frag. of packet */
311#define TSI108_TX_VLAN (1 << 2) /* Per-frame VLAN: enables VLAN override */
312#define TSI108_TX_HUGE (1 << 3) /* Huge frame enable */
313#define TSI108_TX_PAD (1 << 4) /* Pad the packet if too short */
314#define TSI108_TX_CRC (1 << 5) /* Generate CRC for this packet */
315#define TSI108_TX_INT (1 << 14) /* Generate an IRQ after frag. processed */
316#define TSI108_TX_RETRY (0xf << 16) /* 4 bit field indicating num. of retries */
317#define TSI108_TX_COL (1 << 20) /* Set if a collision occured */
318#define TSI108_TX_LCOL (1 << 24) /* Set if a late collision occured */
319#define TSI108_TX_UNDER (1 << 25) /* Set if a FIFO underrun occured */
320#define TSI108_TX_RLIM (1 << 26) /* Set if the retry limit was reached */
321#define TSI108_TX_OK (1 << 30) /* Set if the frame TX was successful */
322#define TSI108_TX_OWN (1 << 31) /* Set if the device owns the descriptor */
323
324/* Note: the descriptor layouts assume big-endian byte order. */
325typedef struct {
326 u32 buf0;
327 u32 buf1; /* Base address of buffer */
328 u32 next0; /* Address of next descriptor, if any */
329 u32 next1;
330 u16 vlan; /* VLAN, if override enabled for this packet */
331 u16 len; /* Length of buffer in bytes */
332 u32 misc; /* See TSI108_TX_* above */
333 u32 reserved0; /*reserved0 and reserved1 are added to make the desc */
334 u32 reserved1; /* 32-byte aligned */
335} __attribute__ ((aligned(32))) tx_desc;
336
337#define TSI108_RX_EOF (1 << 0) /* End of frame; last fragment of packet */
338#define TSI108_RX_SOF (1 << 1) /* Start of frame; first frag. of packet */
339#define TSI108_RX_VLAN (1 << 2) /* Set on SOF if packet has a VLAN */
340#define TSI108_RX_FTYPE (1 << 3) /* Length/Type field is type, not length */
341#define TSI108_RX_RUNT (1 << 4)/* Packet is less than minimum size */
342#define TSI108_RX_HASH (1 << 7)/* Hash table match */
343#define TSI108_RX_BAD (1 << 8) /* Bad frame */
344#define TSI108_RX_OVER (1 << 9) /* FIFO overrun occured */
345#define TSI108_RX_TRUNC (1 << 11) /* Packet truncated due to excess length */
346#define TSI108_RX_CRC (1 << 12) /* Packet had a CRC error */
347#define TSI108_RX_INT (1 << 13) /* Generate an IRQ after frag. processed */
348#define TSI108_RX_OWN (1 << 15) /* Set if the device owns the descriptor */
349
350#define TSI108_RX_SKB_SIZE 1536 /* The RX skb length */
351
352typedef struct {
353 u32 buf0; /* Base address of buffer */
354 u32 buf1; /* Base address of buffer */
355 u32 next0; /* Address of next descriptor, if any */
356 u32 next1; /* Address of next descriptor, if any */
357 u16 vlan; /* VLAN of received packet, first frag only */
358 u16 len; /* Length of received fragment in bytes */
359 u16 blen; /* Length of buffer in bytes */
360 u16 misc; /* See TSI108_RX_* above */
361 u32 reserved0; /* reserved0 and reserved1 are added to make the desc */
362 u32 reserved1; /* 32-byte aligned */
363} __attribute__ ((aligned(32))) rx_desc;
364
365#endif /* __TSI108_ETH_H */
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index f6b3a94e97bf..9d67f11422ec 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1906,9 +1906,7 @@ fill_defaults:
1906 de->media[i].csr15 = t21041_csr15[i]; 1906 de->media[i].csr15 = t21041_csr15[i];
1907 } 1907 }
1908 1908
1909 de->ee_data = kmalloc(DE_EEPROM_SIZE, GFP_KERNEL); 1909 de->ee_data = kmemdup(&ee_data[0], DE_EEPROM_SIZE, GFP_KERNEL);
1910 if (de->ee_data)
1911 memcpy(de->ee_data, &ee_data[0], DE_EEPROM_SIZE);
1912 1910
1913 return; 1911 return;
1914 1912
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 4dd8a0bae860..7f59a3d4fda2 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -187,7 +187,7 @@ struct rx_desc {
187struct dmfe_board_info { 187struct dmfe_board_info {
188 u32 chip_id; /* Chip vendor/Device ID */ 188 u32 chip_id; /* Chip vendor/Device ID */
189 u32 chip_revision; /* Chip revision */ 189 u32 chip_revision; /* Chip revision */
190 struct DEVICE *next_dev; /* next device */ 190 struct DEVICE *dev; /* net device */
191 struct pci_dev *pdev; /* PCI device */ 191 struct pci_dev *pdev; /* PCI device */
192 spinlock_t lock; 192 spinlock_t lock;
193 193
@@ -399,6 +399,8 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
399 /* Init system & device */ 399 /* Init system & device */
400 db = netdev_priv(dev); 400 db = netdev_priv(dev);
401 401
402 db->dev = dev;
403
402 /* Allocate Tx/Rx descriptor memory */ 404 /* Allocate Tx/Rx descriptor memory */
403 db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr); 405 db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr);
404 db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr); 406 db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, &db->buf_pool_dma_ptr);
@@ -426,6 +428,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
426 dev->poll_controller = &poll_dmfe; 428 dev->poll_controller = &poll_dmfe;
427#endif 429#endif
428 dev->ethtool_ops = &netdev_ethtool_ops; 430 dev->ethtool_ops = &netdev_ethtool_ops;
431 netif_carrier_off(db->dev);
429 spin_lock_init(&db->lock); 432 spin_lock_init(&db->lock);
430 433
431 pci_read_config_dword(pdev, 0x50, &pci_pmr); 434 pci_read_config_dword(pdev, 0x50, &pci_pmr);
@@ -1050,6 +1053,7 @@ static void netdev_get_drvinfo(struct net_device *dev,
1050 1053
1051static const struct ethtool_ops netdev_ethtool_ops = { 1054static const struct ethtool_ops netdev_ethtool_ops = {
1052 .get_drvinfo = netdev_get_drvinfo, 1055 .get_drvinfo = netdev_get_drvinfo,
1056 .get_link = ethtool_op_get_link,
1053}; 1057};
1054 1058
1055/* 1059/*
@@ -1144,6 +1148,7 @@ static void dmfe_timer(unsigned long data)
1144 /* Link Failed */ 1148 /* Link Failed */
1145 DMFE_DBUG(0, "Link Failed", tmp_cr12); 1149 DMFE_DBUG(0, "Link Failed", tmp_cr12);
1146 db->link_failed = 1; 1150 db->link_failed = 1;
1151 netif_carrier_off(db->dev);
1147 1152
1148 /* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */ 1153 /* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */
1149 /* AUTO or force 1M Homerun/Longrun don't need */ 1154 /* AUTO or force 1M Homerun/Longrun don't need */
@@ -1166,6 +1171,8 @@ static void dmfe_timer(unsigned long data)
1166 if ( (db->media_mode & DMFE_AUTO) && 1171 if ( (db->media_mode & DMFE_AUTO) &&
1167 dmfe_sense_speed(db) ) 1172 dmfe_sense_speed(db) )
1168 db->link_failed = 1; 1173 db->link_failed = 1;
1174 else
1175 netif_carrier_on(db->dev);
1169 dmfe_process_mode(db); 1176 dmfe_process_mode(db);
1170 /* SHOW_MEDIA_TYPE(db->op_mode); */ 1177 /* SHOW_MEDIA_TYPE(db->op_mode); */
1171 } 1178 }
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 3bf9e630404f..8ddea1da7c05 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -127,7 +127,6 @@ static const int multicast_filter_limit = 32;
127#include <asm/io.h> 127#include <asm/io.h>
128#include <asm/uaccess.h> 128#include <asm/uaccess.h>
129#include <linux/in6.h> 129#include <linux/in6.h>
130#include <asm/checksum.h>
131#include <linux/version.h> 130#include <linux/version.h>
132#include <linux/dma-mapping.h> 131#include <linux/dma-mapping.h>
133 132
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index b37888011067..1f05511fa390 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -30,7 +30,7 @@
30#include <linux/ethtool.h> 30#include <linux/ethtool.h>
31#include <linux/mii.h> 31#include <linux/mii.h>
32 32
33#include <asm/of_device.h> 33#include <asm/of_platform.h>
34#include <asm/uaccess.h> 34#include <asm/uaccess.h>
35#include <asm/irq.h> 35#include <asm/irq.h>
36#include <asm/io.h> 36#include <asm/io.h>
@@ -4301,12 +4301,12 @@ static int __init ucc_geth_init(void)
4301 memcpy(&(ugeth_info[i]), &ugeth_primary_info, 4301 memcpy(&(ugeth_info[i]), &ugeth_primary_info,
4302 sizeof(ugeth_primary_info)); 4302 sizeof(ugeth_primary_info));
4303 4303
4304 return of_register_driver(&ucc_geth_driver); 4304 return of_register_platform_driver(&ucc_geth_driver);
4305} 4305}
4306 4306
4307static void __exit ucc_geth_exit(void) 4307static void __exit ucc_geth_exit(void)
4308{ 4308{
4309 of_unregister_driver(&ucc_geth_driver); 4309 of_unregister_platform_driver(&ucc_geth_driver);
4310} 4310}
4311 4311
4312module_init(ucc_geth_init); 4312module_init(ucc_geth_init);
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index b5d0d7fb647a..d5ab9cf13257 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -57,44 +57,6 @@ config COSA
57 The driver will be compiled as a module: the 57 The driver will be compiled as a module: the
58 module will be called cosa. 58 module will be called cosa.
59 59
60config DSCC4
61 tristate "Etinc PCISYNC serial board support"
62 depends on WAN && PCI && m
63 help
64 Driver for Etinc PCISYNC boards based on the Infineon (ex. Siemens)
65 DSCC4 chipset.
66
67 This is supposed to work with the four port card. Take a look at
68 <http://www.cogenit.fr/dscc4/> for further information about the
69 driver.
70
71 To compile this driver as a module, choose M here: the
72 module will be called dscc4.
73
74config DSCC4_PCISYNC
75 bool "Etinc PCISYNC features"
76 depends on DSCC4
77 help
78 Due to Etinc's design choice for its PCISYNC cards, some operations
79 are only allowed on specific ports of the DSCC4. This option is the
80 only way for the driver to know that it shouldn't return a success
81 code for these operations.
82
83 Please say Y if your card is an Etinc's PCISYNC.
84
85config DSCC4_PCI_RST
86 bool "Hard reset support"
87 depends on DSCC4
88 help
89 Various DSCC4 bugs forbid any reliable software reset of the ASIC.
90 As a replacement, some vendors provide a way to assert the PCI #RST
91 pin of DSCC4 through the GPIO port of the card. If you choose Y,
92 the driver will make use of this feature before module removal
93 (i.e. rmmod). The feature is known to be available on Commtech's
94 cards. Contact your manufacturer for details.
95
96 Say Y if your card supports this feature.
97
98# 60#
99# Lan Media's board. Currently 1000, 1200, 5200, 5245 61# Lan Media's board. Currently 1000, 1200, 5200, 5245
100# 62#
@@ -323,6 +285,44 @@ config FARSYNC
323 To compile this driver as a module, choose M here: the 285 To compile this driver as a module, choose M here: the
324 module will be called farsync. 286 module will be called farsync.
325 287
288config DSCC4
289 tristate "Etinc PCISYNC serial board support"
290 depends on HDLC && PCI && m
291 help
292 Driver for Etinc PCISYNC boards based on the Infineon (ex. Siemens)
293 DSCC4 chipset.
294
295 This is supposed to work with the four port card. Take a look at
296 <http://www.cogenit.fr/dscc4/> for further information about the
297 driver.
298
299 To compile this driver as a module, choose M here: the
300 module will be called dscc4.
301
302config DSCC4_PCISYNC
303 bool "Etinc PCISYNC features"
304 depends on DSCC4
305 help
306 Due to Etinc's design choice for its PCISYNC cards, some operations
307 are only allowed on specific ports of the DSCC4. This option is the
308 only way for the driver to know that it shouldn't return a success
309 code for these operations.
310
311 Please say Y if your card is an Etinc's PCISYNC.
312
313config DSCC4_PCI_RST
314 bool "Hard reset support"
315 depends on DSCC4
316 help
317 Various DSCC4 bugs forbid any reliable software reset of the ASIC.
318 As a replacement, some vendors provide a way to assert the PCI #RST
319 pin of DSCC4 through the GPIO port of the card. If you choose Y,
320 the driver will make use of this feature before module removal
321 (i.e. rmmod). The feature is known to be available on Commtech's
322 cards. Contact your manufacturer for details.
323
324 Say Y if your card supports this feature.
325
326config DLCI 326config DLCI
327 tristate "Frame Relay DLCI support" 327 tristate "Frame Relay DLCI support"
328 depends on WAN 328 depends on WAN
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 0c07b8b7250d..10bcb48e80d0 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -595,7 +595,7 @@ static void atmel_join_bss(struct atmel_private *priv, int bss_index);
595static void atmel_smooth_qual(struct atmel_private *priv); 595static void atmel_smooth_qual(struct atmel_private *priv);
596static void atmel_writeAR(struct net_device *dev, u16 data); 596static void atmel_writeAR(struct net_device *dev, u16 data);
597static int probe_atmel_card(struct net_device *dev); 597static int probe_atmel_card(struct net_device *dev);
598static int reset_atmel_card(struct net_device *dev ); 598static int reset_atmel_card(struct net_device *dev);
599static void atmel_enter_state(struct atmel_private *priv, int new_state); 599static void atmel_enter_state(struct atmel_private *priv, int new_state);
600int atmel_open (struct net_device *dev); 600int atmel_open (struct net_device *dev);
601 601
@@ -784,11 +784,11 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast,
784 784
785static int start_tx(struct sk_buff *skb, struct net_device *dev) 785static int start_tx(struct sk_buff *skb, struct net_device *dev)
786{ 786{
787 static const u8 SNAP_RFC1024[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
787 struct atmel_private *priv = netdev_priv(dev); 788 struct atmel_private *priv = netdev_priv(dev);
788 struct ieee80211_hdr_4addr header; 789 struct ieee80211_hdr_4addr header;
789 unsigned long flags; 790 unsigned long flags;
790 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; 791 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
791 u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
792 792
793 if (priv->card && priv->present_callback && 793 if (priv->card && priv->present_callback &&
794 !(*priv->present_callback)(priv->card)) { 794 !(*priv->present_callback)(priv->card)) {
@@ -1193,7 +1193,7 @@ static irqreturn_t service_interrupt(int irq, void *dev_id)
1193 1193
1194 atmel_set_gcr(dev, GCR_ACKINT); /* acknowledge interrupt */ 1194 atmel_set_gcr(dev, GCR_ACKINT); /* acknowledge interrupt */
1195 1195
1196 for (i = 0; i < sizeof(irq_order)/sizeof(u8); i++) 1196 for (i = 0; i < ARRAY_SIZE(irq_order); i++)
1197 if (isr & irq_order[i]) 1197 if (isr & irq_order[i])
1198 break; 1198 break;
1199 1199
@@ -1345,10 +1345,10 @@ int atmel_open(struct net_device *dev)
1345 atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS, priv->reg_domain); 1345 atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS, priv->reg_domain);
1346 } else { 1346 } else {
1347 priv->reg_domain = atmel_get_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS); 1347 priv->reg_domain = atmel_get_mib8(priv, Phy_Mib_Type, PHY_MIB_REG_DOMAIN_POS);
1348 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) 1348 for (i = 0; i < ARRAY_SIZE(channel_table); i++)
1349 if (priv->reg_domain == channel_table[i].reg_domain) 1349 if (priv->reg_domain == channel_table[i].reg_domain)
1350 break; 1350 break;
1351 if (i == sizeof(channel_table)/sizeof(channel_table[0])) { 1351 if (i == ARRAY_SIZE(channel_table)) {
1352 priv->reg_domain = REG_DOMAIN_MKK1; 1352 priv->reg_domain = REG_DOMAIN_MKK1;
1353 printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name); 1353 printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name);
1354 } 1354 }
@@ -1393,7 +1393,7 @@ static int atmel_validate_channel(struct atmel_private *priv, int channel)
1393 else return suitable default channel */ 1393 else return suitable default channel */
1394 int i; 1394 int i;
1395 1395
1396 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) 1396 for (i = 0; i < ARRAY_SIZE(channel_table); i++)
1397 if (priv->reg_domain == channel_table[i].reg_domain) { 1397 if (priv->reg_domain == channel_table[i].reg_domain) {
1398 if (channel >= channel_table[i].min && 1398 if (channel >= channel_table[i].min &&
1399 channel <= channel_table[i].max) 1399 channel <= channel_table[i].max)
@@ -1437,7 +1437,7 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv)
1437 } 1437 }
1438 1438
1439 r = "<unknown>"; 1439 r = "<unknown>";
1440 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) 1440 for (i = 0; i < ARRAY_SIZE(channel_table); i++)
1441 if (priv->reg_domain == channel_table[i].reg_domain) 1441 if (priv->reg_domain == channel_table[i].reg_domain)
1442 r = channel_table[i].name; 1442 r = channel_table[i].name;
1443 1443
@@ -1736,7 +1736,7 @@ static int atmel_set_encode(struct net_device *dev,
1736 /* Disable the key */ 1736 /* Disable the key */
1737 priv->wep_key_len[index] = 0; 1737 priv->wep_key_len[index] = 0;
1738 /* Check if the key is not marked as invalid */ 1738 /* Check if the key is not marked as invalid */
1739 if(!(dwrq->flags & IW_ENCODE_NOKEY)) { 1739 if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
1740 /* Cleanup */ 1740 /* Cleanup */
1741 memset(priv->wep_keys[index], 0, 13); 1741 memset(priv->wep_keys[index], 0, 13);
1742 /* Copy the key in the driver */ 1742 /* Copy the key in the driver */
@@ -1907,7 +1907,7 @@ static int atmel_get_encodeext(struct net_device *dev,
1907 1907
1908 encoding->flags = idx + 1; 1908 encoding->flags = idx + 1;
1909 memset(ext, 0, sizeof(*ext)); 1909 memset(ext, 0, sizeof(*ext));
1910 1910
1911 if (!priv->wep_is_on) { 1911 if (!priv->wep_is_on) {
1912 ext->alg = IW_ENCODE_ALG_NONE; 1912 ext->alg = IW_ENCODE_ALG_NONE;
1913 ext->key_len = 0; 1913 ext->key_len = 0;
@@ -2343,6 +2343,14 @@ static int atmel_get_scan(struct net_device *dev,
2343 iwe.u.freq.e = 0; 2343 iwe.u.freq.e = 0;
2344 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN); 2344 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN);
2345 2345
2346 /* Add quality statistics */
2347 iwe.cmd = IWEVQUAL;
2348 iwe.u.qual.level = priv->BSSinfo[i].RSSI;
2349 iwe.u.qual.qual = iwe.u.qual.level;
2350 /* iwe.u.qual.noise = SOMETHING */
2351 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA , &iwe, IW_EV_QUAL_LEN);
2352
2353
2346 iwe.cmd = SIOCGIWENCODE; 2354 iwe.cmd = SIOCGIWENCODE;
2347 if (priv->BSSinfo[i].UsingWEP) 2355 if (priv->BSSinfo[i].UsingWEP)
2348 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 2356 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
@@ -2373,7 +2381,7 @@ static int atmel_get_range(struct net_device *dev,
2373 range->min_nwid = 0x0000; 2381 range->min_nwid = 0x0000;
2374 range->max_nwid = 0x0000; 2382 range->max_nwid = 0x0000;
2375 range->num_channels = 0; 2383 range->num_channels = 0;
2376 for (j = 0; j < sizeof(channel_table)/sizeof(channel_table[0]); j++) 2384 for (j = 0; j < ARRAY_SIZE(channel_table); j++)
2377 if (priv->reg_domain == channel_table[j].reg_domain) { 2385 if (priv->reg_domain == channel_table[j].reg_domain) {
2378 range->num_channels = channel_table[j].max - channel_table[j].min + 1; 2386 range->num_channels = channel_table[j].max - channel_table[j].min + 1;
2379 break; 2387 break;
@@ -2579,9 +2587,9 @@ static const struct iw_priv_args atmel_private_args[] = {
2579 2587
2580static const struct iw_handler_def atmel_handler_def = 2588static const struct iw_handler_def atmel_handler_def =
2581{ 2589{
2582 .num_standard = sizeof(atmel_handler)/sizeof(iw_handler), 2590 .num_standard = ARRAY_SIZE(atmel_handler),
2583 .num_private = sizeof(atmel_private_handler)/sizeof(iw_handler), 2591 .num_private = ARRAY_SIZE(atmel_private_handler),
2584 .num_private_args = sizeof(atmel_private_args)/sizeof(struct iw_priv_args), 2592 .num_private_args = ARRAY_SIZE(atmel_private_args),
2585 .standard = (iw_handler *) atmel_handler, 2593 .standard = (iw_handler *) atmel_handler,
2586 .private = (iw_handler *) atmel_private_handler, 2594 .private = (iw_handler *) atmel_private_handler,
2587 .private_args = (struct iw_priv_args *) atmel_private_args, 2595 .private_args = (struct iw_priv_args *) atmel_private_args,
@@ -2645,7 +2653,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2645 2653
2646 domain[REGDOMAINSZ] = 0; 2654 domain[REGDOMAINSZ] = 0;
2647 rc = -EINVAL; 2655 rc = -EINVAL;
2648 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) { 2656 for (i = 0; i < ARRAY_SIZE(channel_table); i++) {
2649 /* strcasecmp doesn't exist in the library */ 2657 /* strcasecmp doesn't exist in the library */
2650 char *a = channel_table[i].name; 2658 char *a = channel_table[i].name;
2651 char *b = domain; 2659 char *b = domain;
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 785664090bb4..5c410989c4d7 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -5,12 +5,12 @@
5 Copyright 2000-2001 ATMEL Corporation. 5 Copyright 2000-2001 ATMEL Corporation.
6 Copyright 2003 Simon Kelley. 6 Copyright 2003 Simon Kelley.
7 7
8 This code was developed from version 2.1.1 of the Atmel drivers, 8 This code was developed from version 2.1.1 of the Atmel drivers,
9 released by Atmel corp. under the GPL in December 2002. It also 9 released by Atmel corp. under the GPL in December 2002. It also
10 includes code from the Linux aironet drivers (C) Benjamin Reed, 10 includes code from the Linux aironet drivers (C) Benjamin Reed,
11 and the Linux PCMCIA package, (C) David Hinds. 11 and the Linux PCMCIA package, (C) David Hinds.
12 12
13 For all queries about this code, please contact the current author, 13 For all queries about this code, please contact the current author,
14 Simon Kelley <simon@thekelleys.org.uk> and not Atmel Corporation. 14 Simon Kelley <simon@thekelleys.org.uk> and not Atmel Corporation.
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
@@ -87,7 +87,7 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
87 event is received. The config() and release() entry points are 87 event is received. The config() and release() entry points are
88 used to configure or release a socket, in response to card 88 used to configure or release a socket, in response to card
89 insertion and ejection events. They are invoked from the atmel_cs 89 insertion and ejection events. They are invoked from the atmel_cs
90 event handler. 90 event handler.
91*/ 91*/
92 92
93static int atmel_config(struct pcmcia_device *link); 93static int atmel_config(struct pcmcia_device *link);
@@ -133,22 +133,22 @@ static void atmel_detach(struct pcmcia_device *p_dev);
133 device IO routines can use a flag like this to throttle IO to a 133 device IO routines can use a flag like this to throttle IO to a
134 card that is not ready to accept it. 134 card that is not ready to accept it.
135*/ 135*/
136 136
137typedef struct local_info_t { 137typedef struct local_info_t {
138 dev_node_t node; 138 dev_node_t node;
139 struct net_device *eth_dev; 139 struct net_device *eth_dev;
140} local_info_t; 140} local_info_t;
141 141
142/*====================================================================== 142/*======================================================================
143 143
144 atmel_attach() creates an "instance" of the driver, allocating 144 atmel_attach() creates an "instance" of the driver, allocating
145 local data structures for one device. The device is registered 145 local data structures for one device. The device is registered
146 with Card Services. 146 with Card Services.
147 147
148 The dev_link structure is initialized, but we don't actually 148 The dev_link structure is initialized, but we don't actually
149 configure the card at this point -- we wait until we receive a 149 configure the card at this point -- we wait until we receive a
150 card insertion event. 150 card insertion event.
151 151
152 ======================================================================*/ 152 ======================================================================*/
153 153
154static int atmel_probe(struct pcmcia_device *p_dev) 154static int atmel_probe(struct pcmcia_device *p_dev)
@@ -184,12 +184,12 @@ static int atmel_probe(struct pcmcia_device *p_dev)
184} /* atmel_attach */ 184} /* atmel_attach */
185 185
186/*====================================================================== 186/*======================================================================
187 187
188 This deletes a driver "instance". The device is de-registered 188 This deletes a driver "instance". The device is de-registered
189 with Card Services. If it has been released, all local data 189 with Card Services. If it has been released, all local data
190 structures are freed. Otherwise, the structures will be freed 190 structures are freed. Otherwise, the structures will be freed
191 when the device is released. 191 when the device is released.
192 192
193 ======================================================================*/ 193 ======================================================================*/
194 194
195static void atmel_detach(struct pcmcia_device *link) 195static void atmel_detach(struct pcmcia_device *link)
@@ -202,11 +202,11 @@ static void atmel_detach(struct pcmcia_device *link)
202} 202}
203 203
204/*====================================================================== 204/*======================================================================
205 205
206 atmel_config() is scheduled to run after a CARD_INSERTION event 206 atmel_config() is scheduled to run after a CARD_INSERTION event
207 is received, to configure the PCMCIA socket, and to make the 207 is received, to configure the PCMCIA socket, and to make the
208 device available to the system. 208 device available to the system.
209 209
210 ======================================================================*/ 210 ======================================================================*/
211 211
212#define CS_CHECK(fn, ret) \ 212#define CS_CHECK(fn, ret) \
@@ -237,12 +237,12 @@ static int atmel_config(struct pcmcia_device *link)
237 did = handle_to_dev(link).driver_data; 237 did = handle_to_dev(link).driver_data;
238 238
239 DEBUG(0, "atmel_config(0x%p)\n", link); 239 DEBUG(0, "atmel_config(0x%p)\n", link);
240 240
241 tuple.Attributes = 0; 241 tuple.Attributes = 0;
242 tuple.TupleData = buf; 242 tuple.TupleData = buf;
243 tuple.TupleDataMax = sizeof(buf); 243 tuple.TupleDataMax = sizeof(buf);
244 tuple.TupleOffset = 0; 244 tuple.TupleOffset = 0;
245 245
246 /* 246 /*
247 This reads the card's CONFIG tuple to find its configuration 247 This reads the card's CONFIG tuple to find its configuration
248 registers. 248 registers.
@@ -258,7 +258,7 @@ static int atmel_config(struct pcmcia_device *link)
258 In this loop, we scan the CIS for configuration table entries, 258 In this loop, we scan the CIS for configuration table entries,
259 each of which describes a valid card configuration, including 259 each of which describes a valid card configuration, including
260 voltage, IO window, memory window, and interrupt settings. 260 voltage, IO window, memory window, and interrupt settings.
261 261
262 We make no assumptions about the card to be configured: we use 262 We make no assumptions about the card to be configured: we use
263 just the information available in the CIS. In an ideal world, 263 just the information available in the CIS. In an ideal world,
264 this would work for any PCMCIA card, but it requires a complete 264 this would work for any PCMCIA card, but it requires a complete
@@ -274,17 +274,17 @@ static int atmel_config(struct pcmcia_device *link)
274 if (pcmcia_get_tuple_data(link, &tuple) != 0 || 274 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
275 pcmcia_parse_tuple(link, &tuple, &parse) != 0) 275 pcmcia_parse_tuple(link, &tuple, &parse) != 0)
276 goto next_entry; 276 goto next_entry;
277 277
278 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 278 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
279 if (cfg->index == 0) goto next_entry; 279 if (cfg->index == 0) goto next_entry;
280 link->conf.ConfigIndex = cfg->index; 280 link->conf.ConfigIndex = cfg->index;
281 281
282 /* Does this card need audio output? */ 282 /* Does this card need audio output? */
283 if (cfg->flags & CISTPL_CFTABLE_AUDIO) { 283 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
284 link->conf.Attributes |= CONF_ENABLE_SPKR; 284 link->conf.Attributes |= CONF_ENABLE_SPKR;
285 link->conf.Status = CCSR_AUDIO_ENA; 285 link->conf.Status = CCSR_AUDIO_ENA;
286 } 286 }
287 287
288 /* Use power settings for Vcc and Vpp if present */ 288 /* Use power settings for Vcc and Vpp if present */
289 /* Note that the CIS values need to be rescaled */ 289 /* Note that the CIS values need to be rescaled */
290 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 290 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
@@ -293,11 +293,11 @@ static int atmel_config(struct pcmcia_device *link)
293 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 293 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
294 link->conf.Vpp = 294 link->conf.Vpp =
295 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 295 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
296 296
297 /* Do we need to allocate an interrupt? */ 297 /* Do we need to allocate an interrupt? */
298 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) 298 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
299 link->conf.Attributes |= CONF_ENABLE_IRQ; 299 link->conf.Attributes |= CONF_ENABLE_IRQ;
300 300
301 /* IO window settings */ 301 /* IO window settings */
302 link->io.NumPorts1 = link->io.NumPorts2 = 0; 302 link->io.NumPorts1 = link->io.NumPorts2 = 0;
303 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 303 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
@@ -315,18 +315,18 @@ static int atmel_config(struct pcmcia_device *link)
315 link->io.NumPorts2 = io->win[1].len; 315 link->io.NumPorts2 = io->win[1].len;
316 } 316 }
317 } 317 }
318 318
319 /* This reserves IO space but doesn't actually enable it */ 319 /* This reserves IO space but doesn't actually enable it */
320 if (pcmcia_request_io(link, &link->io) != 0) 320 if (pcmcia_request_io(link, &link->io) != 0)
321 goto next_entry; 321 goto next_entry;
322 322
323 /* If we got this far, we're cool! */ 323 /* If we got this far, we're cool! */
324 break; 324 break;
325 325
326 next_entry: 326 next_entry:
327 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 327 CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple));
328 } 328 }
329 329
330 /* 330 /*
331 Allocate an interrupt line. Note that this does not assign a 331 Allocate an interrupt line. Note that this does not assign a
332 handler to the interrupt, unless the 'Handler' member of the 332 handler to the interrupt, unless the 'Handler' member of the
@@ -334,31 +334,31 @@ static int atmel_config(struct pcmcia_device *link)
334 */ 334 */
335 if (link->conf.Attributes & CONF_ENABLE_IRQ) 335 if (link->conf.Attributes & CONF_ENABLE_IRQ)
336 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 336 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
337 337
338 /* 338 /*
339 This actually configures the PCMCIA socket -- setting up 339 This actually configures the PCMCIA socket -- setting up
340 the I/O windows and the interrupt mapping, and putting the 340 the I/O windows and the interrupt mapping, and putting the
341 card and host interface into "Memory and IO" mode. 341 card and host interface into "Memory and IO" mode.
342 */ 342 */
343 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 343 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
344 344
345 if (link->irq.AssignedIRQ == 0) { 345 if (link->irq.AssignedIRQ == 0) {
346 printk(KERN_ALERT 346 printk(KERN_ALERT
347 "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config."); 347 "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config.");
348 goto cs_failed; 348 goto cs_failed;
349 } 349 }
350 350
351 ((local_info_t*)link->priv)->eth_dev = 351 ((local_info_t*)link->priv)->eth_dev =
352 init_atmel_card(link->irq.AssignedIRQ, 352 init_atmel_card(link->irq.AssignedIRQ,
353 link->io.BasePort1, 353 link->io.BasePort1,
354 did ? did->driver_info : ATMEL_FW_TYPE_NONE, 354 did ? did->driver_info : ATMEL_FW_TYPE_NONE,
355 &handle_to_dev(link), 355 &handle_to_dev(link),
356 card_present, 356 card_present,
357 link); 357 link);
358 if (!((local_info_t*)link->priv)->eth_dev) 358 if (!((local_info_t*)link->priv)->eth_dev)
359 goto cs_failed; 359 goto cs_failed;
360 360
361 361
362 /* 362 /*
363 At this point, the dev_node_t structure(s) need to be 363 At this point, the dev_node_t structure(s) need to be
364 initialized and arranged in a linked list at link->dev_node. 364 initialized and arranged in a linked list at link->dev_node.
@@ -376,11 +376,11 @@ static int atmel_config(struct pcmcia_device *link)
376} 376}
377 377
378/*====================================================================== 378/*======================================================================
379 379
380 After a card is removed, atmel_release() will unregister the 380 After a card is removed, atmel_release() will unregister the
381 device, and release the PCMCIA configuration. If the device is 381 device, and release the PCMCIA configuration. If the device is
382 still open, this will be postponed until it is closed. 382 still open, this will be postponed until it is closed.
383 383
384 ======================================================================*/ 384 ======================================================================*/
385 385
386static void atmel_release(struct pcmcia_device *link) 386static void atmel_release(struct pcmcia_device *link)
@@ -517,7 +517,7 @@ static void atmel_cs_cleanup(void)
517 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 517 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
518 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 518 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
519 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 519 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
520 POSSIBILITY OF SUCH DAMAGE. 520 POSSIBILITY OF SUCH DAMAGE.
521*/ 521*/
522 522
523module_init(atmel_cs_init); 523module_init(atmel_cs_init);
diff --git a/drivers/net/wireless/atmel_pci.c b/drivers/net/wireless/atmel_pci.c
index 3bfa791c323d..92f87fbe750f 100644
--- a/drivers/net/wireless/atmel_pci.c
+++ b/drivers/net/wireless/atmel_pci.c
@@ -53,18 +53,18 @@ static int __devinit atmel_pci_probe(struct pci_dev *pdev,
53 const struct pci_device_id *pent) 53 const struct pci_device_id *pent)
54{ 54{
55 struct net_device *dev; 55 struct net_device *dev;
56 56
57 if (pci_enable_device(pdev)) 57 if (pci_enable_device(pdev))
58 return -ENODEV; 58 return -ENODEV;
59 59
60 pci_set_master(pdev); 60 pci_set_master(pdev);
61 61
62 dev = init_atmel_card(pdev->irq, pdev->resource[1].start, 62 dev = init_atmel_card(pdev->irq, pdev->resource[1].start,
63 ATMEL_FW_TYPE_506, 63 ATMEL_FW_TYPE_506,
64 &pdev->dev, NULL, NULL); 64 &pdev->dev, NULL, NULL);
65 if (!dev) 65 if (!dev)
66 return -ENODEV; 66 return -ENODEV;
67 67
68 pci_set_drvdata(pdev, dev); 68 pci_set_drvdata(pdev, dev);
69 return 0; 69 return 0;
70} 70}
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index fbc0c087f53c..8286678513b9 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -159,6 +159,7 @@
159 159
160/* Chipcommon registers. */ 160/* Chipcommon registers. */
161#define BCM43xx_CHIPCOMMON_CAPABILITIES 0x04 161#define BCM43xx_CHIPCOMMON_CAPABILITIES 0x04
162#define BCM43xx_CHIPCOMMON_CTL 0x28
162#define BCM43xx_CHIPCOMMON_PLLONDELAY 0xB0 163#define BCM43xx_CHIPCOMMON_PLLONDELAY 0xB0
163#define BCM43xx_CHIPCOMMON_FREFSELDELAY 0xB4 164#define BCM43xx_CHIPCOMMON_FREFSELDELAY 0xB4
164#define BCM43xx_CHIPCOMMON_SLOWCLKCTL 0xB8 165#define BCM43xx_CHIPCOMMON_SLOWCLKCTL 0xB8
@@ -172,6 +173,33 @@
172/* SBTOPCI2 values. */ 173/* SBTOPCI2 values. */
173#define BCM43xx_SBTOPCI2_PREFETCH 0x4 174#define BCM43xx_SBTOPCI2_PREFETCH 0x4
174#define BCM43xx_SBTOPCI2_BURST 0x8 175#define BCM43xx_SBTOPCI2_BURST 0x8
176#define BCM43xx_SBTOPCI2_MEMREAD_MULTI 0x20
177
178/* PCI-E core registers. */
179#define BCM43xx_PCIECORE_REG_ADDR 0x0130
180#define BCM43xx_PCIECORE_REG_DATA 0x0134
181#define BCM43xx_PCIECORE_MDIO_CTL 0x0128
182#define BCM43xx_PCIECORE_MDIO_DATA 0x012C
183
184/* PCI-E registers. */
185#define BCM43xx_PCIE_TLP_WORKAROUND 0x0004
186#define BCM43xx_PCIE_DLLP_LINKCTL 0x0100
187
188/* PCI-E MDIO bits. */
189#define BCM43xx_PCIE_MDIO_ST 0x40000000
190#define BCM43xx_PCIE_MDIO_WT 0x10000000
191#define BCM43xx_PCIE_MDIO_DEV 22
192#define BCM43xx_PCIE_MDIO_REG 18
193#define BCM43xx_PCIE_MDIO_TA 0x00020000
194#define BCM43xx_PCIE_MDIO_TC 0x0100
195
196/* MDIO devices. */
197#define BCM43xx_MDIO_SERDES_RX 0x1F
198
199/* SERDES RX registers. */
200#define BCM43xx_SERDES_RXTIMER 0x2
201#define BCM43xx_SERDES_CDR 0x6
202#define BCM43xx_SERDES_CDR_BW 0x7
175 203
176/* Chipcommon capabilities. */ 204/* Chipcommon capabilities. */
177#define BCM43xx_CAPABILITIES_PCTL 0x00040000 205#define BCM43xx_CAPABILITIES_PCTL 0x00040000
@@ -221,6 +249,7 @@
221#define BCM43xx_COREID_USB20_HOST 0x819 249#define BCM43xx_COREID_USB20_HOST 0x819
222#define BCM43xx_COREID_USB20_DEV 0x81a 250#define BCM43xx_COREID_USB20_DEV 0x81a
223#define BCM43xx_COREID_SDIO_HOST 0x81b 251#define BCM43xx_COREID_SDIO_HOST 0x81b
252#define BCM43xx_COREID_PCIE 0x820
224 253
225/* Core Information Registers */ 254/* Core Information Registers */
226#define BCM43xx_CIR_BASE 0xf00 255#define BCM43xx_CIR_BASE 0xf00
@@ -365,6 +394,9 @@
365#define BCM43xx_DEFAULT_SHORT_RETRY_LIMIT 7 394#define BCM43xx_DEFAULT_SHORT_RETRY_LIMIT 7
366#define BCM43xx_DEFAULT_LONG_RETRY_LIMIT 4 395#define BCM43xx_DEFAULT_LONG_RETRY_LIMIT 4
367 396
397/* FIXME: the next line is a guess as to what the maximum RSSI value might be */
398#define RX_RSSI_MAX 60
399
368/* Max size of a security key */ 400/* Max size of a security key */
369#define BCM43xx_SEC_KEYSIZE 16 401#define BCM43xx_SEC_KEYSIZE 16
370/* Security algorithms. */ 402/* Security algorithms. */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 728a9b789fdf..2ec2e5afce67 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -130,6 +130,10 @@ MODULE_PARM_DESC(fwpostfix, "Postfix for .fw files. Useful for debugging.");
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 4311 802.11(a)/b/g */
134 { PCI_VENDOR_ID_BROADCOM, 0x4311, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
135 /* Broadcom 4312 802.11a/b/g */
136 { PCI_VENDOR_ID_BROADCOM, 0x4312, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
133 /* Broadcom 4318 802.11b/g */ 137 /* Broadcom 4318 802.11b/g */
134 { PCI_VENDOR_ID_BROADCOM, 0x4318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 138 { PCI_VENDOR_ID_BROADCOM, 0x4318, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
135 /* Broadcom 4319 802.11a/b/g */ 139 /* Broadcom 4319 802.11a/b/g */
@@ -2600,8 +2604,9 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2600 /* fetch sb_id_hi from core information registers */ 2604 /* fetch sb_id_hi from core information registers */
2601 sb_id_hi = bcm43xx_read32(bcm, BCM43xx_CIR_SB_ID_HI); 2605 sb_id_hi = bcm43xx_read32(bcm, BCM43xx_CIR_SB_ID_HI);
2602 2606
2603 core_id = (sb_id_hi & 0xFFF0) >> 4; 2607 core_id = (sb_id_hi & 0x8FF0) >> 4;
2604 core_rev = (sb_id_hi & 0xF); 2608 core_rev = (sb_id_hi & 0x7000) >> 8;
2609 core_rev |= (sb_id_hi & 0xF);
2605 core_vendor = (sb_id_hi & 0xFFFF0000) >> 16; 2610 core_vendor = (sb_id_hi & 0xFFFF0000) >> 16;
2606 2611
2607 /* if present, chipcommon is always core 0; read the chipid from it */ 2612 /* if present, chipcommon is always core 0; read the chipid from it */
@@ -2679,14 +2684,10 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2679 bcm->chip_id, bcm->chip_rev); 2684 bcm->chip_id, bcm->chip_rev);
2680 dprintk(KERN_INFO PFX "Number of cores: %d\n", core_count); 2685 dprintk(KERN_INFO PFX "Number of cores: %d\n", core_count);
2681 if (bcm->core_chipcommon.available) { 2686 if (bcm->core_chipcommon.available) {
2682 dprintk(KERN_INFO PFX "Core 0: ID 0x%x, rev 0x%x, vendor 0x%x, %s\n", 2687 dprintk(KERN_INFO PFX "Core 0: ID 0x%x, rev 0x%x, vendor 0x%x\n",
2683 core_id, core_rev, core_vendor, 2688 core_id, core_rev, core_vendor);
2684 bcm43xx_core_enabled(bcm) ? "enabled" : "disabled");
2685 }
2686
2687 if (bcm->core_chipcommon.available)
2688 current_core = 1; 2689 current_core = 1;
2689 else 2690 } else
2690 current_core = 0; 2691 current_core = 0;
2691 for ( ; current_core < core_count; current_core++) { 2692 for ( ; current_core < core_count; current_core++) {
2692 struct bcm43xx_coreinfo *core; 2693 struct bcm43xx_coreinfo *core;
@@ -2704,13 +2705,13 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2704 core_rev = (sb_id_hi & 0xF); 2705 core_rev = (sb_id_hi & 0xF);
2705 core_vendor = (sb_id_hi & 0xFFFF0000) >> 16; 2706 core_vendor = (sb_id_hi & 0xFFFF0000) >> 16;
2706 2707
2707 dprintk(KERN_INFO PFX "Core %d: ID 0x%x, rev 0x%x, vendor 0x%x, %s\n", 2708 dprintk(KERN_INFO PFX "Core %d: ID 0x%x, rev 0x%x, vendor 0x%x\n",
2708 current_core, core_id, core_rev, core_vendor, 2709 current_core, core_id, core_rev, core_vendor);
2709 bcm43xx_core_enabled(bcm) ? "enabled" : "disabled" );
2710 2710
2711 core = NULL; 2711 core = NULL;
2712 switch (core_id) { 2712 switch (core_id) {
2713 case BCM43xx_COREID_PCI: 2713 case BCM43xx_COREID_PCI:
2714 case BCM43xx_COREID_PCIE:
2714 core = &bcm->core_pci; 2715 core = &bcm->core_pci;
2715 if (core->available) { 2716 if (core->available) {
2716 printk(KERN_WARNING PFX "Multiple PCI cores found.\n"); 2717 printk(KERN_WARNING PFX "Multiple PCI cores found.\n");
@@ -2749,12 +2750,12 @@ static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
2749 case 6: 2750 case 6:
2750 case 7: 2751 case 7:
2751 case 9: 2752 case 9:
2753 case 10:
2752 break; 2754 break;
2753 default: 2755 default:
2754 printk(KERN_ERR PFX "Error: Unsupported 80211 core revision %u\n", 2756 printk(KERN_WARNING PFX
2757 "Unsupported 80211 core revision %u\n",
2755 core_rev); 2758 core_rev);
2756 err = -ENODEV;
2757 goto out;
2758 } 2759 }
2759 bcm->nr_80211_available++; 2760 bcm->nr_80211_available++;
2760 core->priv = ext_80211; 2761 core->priv = ext_80211;
@@ -2868,16 +2869,11 @@ static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm,
2868 u32 sbimconfiglow; 2869 u32 sbimconfiglow;
2869 u8 limit; 2870 u8 limit;
2870 2871
2871 if (bcm->chip_rev < 5) { 2872 if (bcm->core_pci.rev <= 5 && bcm->core_pci.id != BCM43xx_COREID_PCIE) {
2872 sbimconfiglow = bcm43xx_read32(bcm, BCM43xx_CIR_SBIMCONFIGLOW); 2873 sbimconfiglow = bcm43xx_read32(bcm, BCM43xx_CIR_SBIMCONFIGLOW);
2873 sbimconfiglow &= ~ BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK; 2874 sbimconfiglow &= ~ BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK;
2874 sbimconfiglow &= ~ BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK; 2875 sbimconfiglow &= ~ BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK;
2875 if (bcm->bustype == BCM43xx_BUSTYPE_PCI) 2876 sbimconfiglow |= 0x32;
2876 sbimconfiglow |= 0x32;
2877 else if (bcm->bustype == BCM43xx_BUSTYPE_SB)
2878 sbimconfiglow |= 0x53;
2879 else
2880 assert(0);
2881 bcm43xx_write32(bcm, BCM43xx_CIR_SBIMCONFIGLOW, sbimconfiglow); 2877 bcm43xx_write32(bcm, BCM43xx_CIR_SBIMCONFIGLOW, sbimconfiglow);
2882 } 2878 }
2883 2879
@@ -3004,22 +3000,64 @@ static void bcm43xx_pcicore_broadcast_value(struct bcm43xx_private *bcm,
3004 3000
3005static int bcm43xx_pcicore_commit_settings(struct bcm43xx_private *bcm) 3001static int bcm43xx_pcicore_commit_settings(struct bcm43xx_private *bcm)
3006{ 3002{
3007 int err; 3003 int err = 0;
3008 struct bcm43xx_coreinfo *old_core;
3009 3004
3010 old_core = bcm->current_core; 3005 bcm->irq_savedstate = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
3011 err = bcm43xx_switch_core(bcm, &bcm->core_pci);
3012 if (err)
3013 goto out;
3014 3006
3015 bcm43xx_pcicore_broadcast_value(bcm, 0xfd8, 0x00000000); 3007 if (bcm->core_chipcommon.available) {
3008 err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
3009 if (err)
3010 goto out;
3011
3012 bcm43xx_pcicore_broadcast_value(bcm, 0xfd8, 0x00000000);
3013
3014 /* this function is always called when a PCI core is mapped */
3015 err = bcm43xx_switch_core(bcm, &bcm->core_pci);
3016 if (err)
3017 goto out;
3018 } else
3019 bcm43xx_pcicore_broadcast_value(bcm, 0xfd8, 0x00000000);
3020
3021 bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
3016 3022
3017 bcm43xx_switch_core(bcm, old_core);
3018 assert(err == 0);
3019out: 3023out:
3020 return err; 3024 return err;
3021} 3025}
3022 3026
3027static u32 bcm43xx_pcie_reg_read(struct bcm43xx_private *bcm, u32 address)
3028{
3029 bcm43xx_write32(bcm, BCM43xx_PCIECORE_REG_ADDR, address);
3030 return bcm43xx_read32(bcm, BCM43xx_PCIECORE_REG_DATA);
3031}
3032
3033static void bcm43xx_pcie_reg_write(struct bcm43xx_private *bcm, u32 address,
3034 u32 data)
3035{
3036 bcm43xx_write32(bcm, BCM43xx_PCIECORE_REG_ADDR, address);
3037 bcm43xx_write32(bcm, BCM43xx_PCIECORE_REG_DATA, data);
3038}
3039
3040static void bcm43xx_pcie_mdio_write(struct bcm43xx_private *bcm, u8 dev, u8 reg,
3041 u16 data)
3042{
3043 int i;
3044
3045 bcm43xx_write32(bcm, BCM43xx_PCIECORE_MDIO_CTL, 0x0082);
3046 bcm43xx_write32(bcm, BCM43xx_PCIECORE_MDIO_DATA, BCM43xx_PCIE_MDIO_ST |
3047 BCM43xx_PCIE_MDIO_WT | (dev << BCM43xx_PCIE_MDIO_DEV) |
3048 (reg << BCM43xx_PCIE_MDIO_REG) | BCM43xx_PCIE_MDIO_TA |
3049 data);
3050 udelay(10);
3051
3052 for (i = 0; i < 10; i++) {
3053 if (bcm43xx_read32(bcm, BCM43xx_PCIECORE_MDIO_CTL) &
3054 BCM43xx_PCIE_MDIO_TC)
3055 break;
3056 msleep(1);
3057 }
3058 bcm43xx_write32(bcm, BCM43xx_PCIECORE_MDIO_CTL, 0);
3059}
3060
3023/* Make an I/O Core usable. "core_mask" is the bitmask of the cores to enable. 3061/* Make an I/O Core usable. "core_mask" is the bitmask of the cores to enable.
3024 * To enable core 0, pass a core_mask of 1<<0 3062 * To enable core 0, pass a core_mask of 1<<0
3025 */ 3063 */
@@ -3039,7 +3077,8 @@ static int bcm43xx_setup_backplane_pci_connection(struct bcm43xx_private *bcm,
3039 if (err) 3077 if (err)
3040 goto out; 3078 goto out;
3041 3079
3042 if (bcm->core_pci.rev < 6) { 3080 if (bcm->current_core->rev < 6 ||
3081 bcm->current_core->id == BCM43xx_COREID_PCI) {
3043 value = bcm43xx_read32(bcm, BCM43xx_CIR_SBINTVEC); 3082 value = bcm43xx_read32(bcm, BCM43xx_CIR_SBINTVEC);
3044 value |= (1 << backplane_flag_nr); 3083 value |= (1 << backplane_flag_nr);
3045 bcm43xx_write32(bcm, BCM43xx_CIR_SBINTVEC, value); 3084 bcm43xx_write32(bcm, BCM43xx_CIR_SBINTVEC, value);
@@ -3057,21 +3096,46 @@ static int bcm43xx_setup_backplane_pci_connection(struct bcm43xx_private *bcm,
3057 } 3096 }
3058 } 3097 }
3059 3098
3060 value = bcm43xx_read32(bcm, BCM43xx_PCICORE_SBTOPCI2); 3099 if (bcm->current_core->id == BCM43xx_COREID_PCI) {
3061 value |= BCM43xx_SBTOPCI2_PREFETCH | BCM43xx_SBTOPCI2_BURST; 3100 value = bcm43xx_read32(bcm, BCM43xx_PCICORE_SBTOPCI2);
3062 bcm43xx_write32(bcm, BCM43xx_PCICORE_SBTOPCI2, value); 3101 value |= BCM43xx_SBTOPCI2_PREFETCH | BCM43xx_SBTOPCI2_BURST;
3063 3102 bcm43xx_write32(bcm, BCM43xx_PCICORE_SBTOPCI2, value);
3064 if (bcm->core_pci.rev < 5) { 3103
3065 value = bcm43xx_read32(bcm, BCM43xx_CIR_SBIMCONFIGLOW); 3104 if (bcm->current_core->rev < 5) {
3066 value |= (2 << BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_SHIFT) 3105 value = bcm43xx_read32(bcm, BCM43xx_CIR_SBIMCONFIGLOW);
3067 & BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK; 3106 value |= (2 << BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_SHIFT)
3068 value |= (3 << BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_SHIFT) 3107 & BCM43xx_SBIMCONFIGLOW_SERVICE_TOUT_MASK;
3069 & BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK; 3108 value |= (3 << BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_SHIFT)
3070 bcm43xx_write32(bcm, BCM43xx_CIR_SBIMCONFIGLOW, value); 3109 & BCM43xx_SBIMCONFIGLOW_REQUEST_TOUT_MASK;
3071 err = bcm43xx_pcicore_commit_settings(bcm); 3110 bcm43xx_write32(bcm, BCM43xx_CIR_SBIMCONFIGLOW, value);
3072 assert(err == 0); 3111 err = bcm43xx_pcicore_commit_settings(bcm);
3112 assert(err == 0);
3113 } else if (bcm->current_core->rev >= 11) {
3114 value = bcm43xx_read32(bcm, BCM43xx_PCICORE_SBTOPCI2);
3115 value |= BCM43xx_SBTOPCI2_MEMREAD_MULTI;
3116 bcm43xx_write32(bcm, BCM43xx_PCICORE_SBTOPCI2, value);
3117 }
3118 } else {
3119 if (bcm->current_core->rev == 0 || bcm->current_core->rev == 1) {
3120 value = bcm43xx_pcie_reg_read(bcm, BCM43xx_PCIE_TLP_WORKAROUND);
3121 value |= 0x8;
3122 bcm43xx_pcie_reg_write(bcm, BCM43xx_PCIE_TLP_WORKAROUND,
3123 value);
3124 }
3125 if (bcm->current_core->rev == 0) {
3126 bcm43xx_pcie_mdio_write(bcm, BCM43xx_MDIO_SERDES_RX,
3127 BCM43xx_SERDES_RXTIMER, 0x8128);
3128 bcm43xx_pcie_mdio_write(bcm, BCM43xx_MDIO_SERDES_RX,
3129 BCM43xx_SERDES_CDR, 0x0100);
3130 bcm43xx_pcie_mdio_write(bcm, BCM43xx_MDIO_SERDES_RX,
3131 BCM43xx_SERDES_CDR_BW, 0x1466);
3132 } else if (bcm->current_core->rev == 1) {
3133 value = bcm43xx_pcie_reg_read(bcm, BCM43xx_PCIE_DLLP_LINKCTL);
3134 value |= 0x40;
3135 bcm43xx_pcie_reg_write(bcm, BCM43xx_PCIE_DLLP_LINKCTL,
3136 value);
3137 }
3073 } 3138 }
3074
3075out_switch_back: 3139out_switch_back:
3076 err = bcm43xx_switch_core(bcm, old_core); 3140 err = bcm43xx_switch_core(bcm, old_core);
3077out: 3141out:
@@ -3140,43 +3204,17 @@ static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm)
3140 3204
3141static void do_periodic_work(struct bcm43xx_private *bcm) 3205static void do_periodic_work(struct bcm43xx_private *bcm)
3142{ 3206{
3143 unsigned int state; 3207 if (bcm->periodic_state % 8 == 0)
3144
3145 state = bcm->periodic_state;
3146 if (state % 8 == 0)
3147 bcm43xx_periodic_every120sec(bcm); 3208 bcm43xx_periodic_every120sec(bcm);
3148 if (state % 4 == 0) 3209 if (bcm->periodic_state % 4 == 0)
3149 bcm43xx_periodic_every60sec(bcm); 3210 bcm43xx_periodic_every60sec(bcm);
3150 if (state % 2 == 0) 3211 if (bcm->periodic_state % 2 == 0)
3151 bcm43xx_periodic_every30sec(bcm); 3212 bcm43xx_periodic_every30sec(bcm);
3152 if (state % 1 == 0) 3213 bcm43xx_periodic_every15sec(bcm);
3153 bcm43xx_periodic_every15sec(bcm);
3154 bcm->periodic_state = state + 1;
3155 3214
3156 schedule_delayed_work(&bcm->periodic_work, HZ * 15); 3215 schedule_delayed_work(&bcm->periodic_work, HZ * 15);
3157} 3216}
3158 3217
3159/* Estimate a "Badness" value based on the periodic work
3160 * state-machine state. "Badness" is worse (bigger), if the
3161 * periodic work will take longer.
3162 */
3163static int estimate_periodic_work_badness(unsigned int state)
3164{
3165 int badness = 0;
3166
3167 if (state % 8 == 0) /* every 120 sec */
3168 badness += 10;
3169 if (state % 4 == 0) /* every 60 sec */
3170 badness += 5;
3171 if (state % 2 == 0) /* every 30 sec */
3172 badness += 1;
3173 if (state % 1 == 0) /* every 15 sec */
3174 badness += 1;
3175
3176#define BADNESS_LIMIT 4
3177 return badness;
3178}
3179
3180static void bcm43xx_periodic_work_handler(struct work_struct *work) 3218static void bcm43xx_periodic_work_handler(struct work_struct *work)
3181{ 3219{
3182 struct bcm43xx_private *bcm = 3220 struct bcm43xx_private *bcm =
@@ -3184,12 +3222,10 @@ static void bcm43xx_periodic_work_handler(struct work_struct *work)
3184 struct net_device *net_dev = bcm->net_dev; 3222 struct net_device *net_dev = bcm->net_dev;
3185 unsigned long flags; 3223 unsigned long flags;
3186 u32 savedirqs = 0; 3224 u32 savedirqs = 0;
3187 int badness;
3188 unsigned long orig_trans_start = 0; 3225 unsigned long orig_trans_start = 0;
3189 3226
3190 mutex_lock(&bcm->mutex); 3227 mutex_lock(&bcm->mutex);
3191 badness = estimate_periodic_work_badness(bcm->periodic_state); 3228 if (unlikely(bcm->periodic_state % 4 == 0)) {
3192 if (badness > BADNESS_LIMIT) {
3193 /* Periodic work will take a long time, so we want it to 3229 /* Periodic work will take a long time, so we want it to
3194 * be preemtible. 3230 * be preemtible.
3195 */ 3231 */
@@ -3221,7 +3257,7 @@ static void bcm43xx_periodic_work_handler(struct work_struct *work)
3221 3257
3222 do_periodic_work(bcm); 3258 do_periodic_work(bcm);
3223 3259
3224 if (badness > BADNESS_LIMIT) { 3260 if (unlikely(bcm->periodic_state % 4 == 0)) {
3225 spin_lock_irqsave(&bcm->irq_lock, flags); 3261 spin_lock_irqsave(&bcm->irq_lock, flags);
3226 tasklet_enable(&bcm->isr_tasklet); 3262 tasklet_enable(&bcm->isr_tasklet);
3227 bcm43xx_interrupt_enable(bcm, savedirqs); 3263 bcm43xx_interrupt_enable(bcm, savedirqs);
@@ -3232,6 +3268,7 @@ static void bcm43xx_periodic_work_handler(struct work_struct *work)
3232 net_dev->trans_start = orig_trans_start; 3268 net_dev->trans_start = orig_trans_start;
3233 } 3269 }
3234 mmiowb(); 3270 mmiowb();
3271 bcm->periodic_state++;
3235 spin_unlock_irqrestore(&bcm->irq_lock, flags); 3272 spin_unlock_irqrestore(&bcm->irq_lock, flags);
3236 mutex_unlock(&bcm->mutex); 3273 mutex_unlock(&bcm->mutex);
3237} 3274}
@@ -3677,7 +3714,7 @@ static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm)
3677 bcm->ieee->freq_band = IEEE80211_24GHZ_BAND; 3714 bcm->ieee->freq_band = IEEE80211_24GHZ_BAND;
3678 break; 3715 break;
3679 case BCM43xx_PHYTYPE_G: 3716 case BCM43xx_PHYTYPE_G:
3680 if (phy_rev > 7) 3717 if (phy_rev > 8)
3681 phy_rev_ok = 0; 3718 phy_rev_ok = 0;
3682 bcm->ieee->modulation = IEEE80211_OFDM_MODULATION | 3719 bcm->ieee->modulation = IEEE80211_OFDM_MODULATION |
3683 IEEE80211_CCK_MODULATION; 3720 IEEE80211_CCK_MODULATION;
@@ -3689,6 +3726,8 @@ static int bcm43xx_read_phyinfo(struct bcm43xx_private *bcm)
3689 phy_type); 3726 phy_type);
3690 return -ENODEV; 3727 return -ENODEV;
3691 }; 3728 };
3729 bcm->ieee->perfect_rssi = RX_RSSI_MAX;
3730 bcm->ieee->worst_rssi = 0;
3692 if (!phy_rev_ok) { 3731 if (!phy_rev_ok) {
3693 printk(KERN_WARNING PFX "Invalid PHY Revision %x\n", 3732 printk(KERN_WARNING PFX "Invalid PHY Revision %x\n",
3694 phy_rev); 3733 phy_rev);
@@ -3975,11 +4014,6 @@ static int bcm43xx_ieee80211_hard_start_xmit(struct ieee80211_txb *txb,
3975 return NETDEV_TX_OK; 4014 return NETDEV_TX_OK;
3976} 4015}
3977 4016
3978static struct net_device_stats * bcm43xx_net_get_stats(struct net_device *net_dev)
3979{
3980 return &(bcm43xx_priv(net_dev)->ieee->stats);
3981}
3982
3983static void bcm43xx_net_tx_timeout(struct net_device *net_dev) 4017static void bcm43xx_net_tx_timeout(struct net_device *net_dev)
3984{ 4018{
3985 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev); 4019 struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
@@ -4093,7 +4127,6 @@ static int __devinit bcm43xx_init_one(struct pci_dev *pdev,
4093 4127
4094 net_dev->open = bcm43xx_net_open; 4128 net_dev->open = bcm43xx_net_open;
4095 net_dev->stop = bcm43xx_net_stop; 4129 net_dev->stop = bcm43xx_net_stop;
4096 net_dev->get_stats = bcm43xx_net_get_stats;
4097 net_dev->tx_timeout = bcm43xx_net_tx_timeout; 4130 net_dev->tx_timeout = bcm43xx_net_tx_timeout;
4098#ifdef CONFIG_NET_POLL_CONTROLLER 4131#ifdef CONFIG_NET_POLL_CONTROLLER
4099 net_dev->poll_controller = bcm43xx_net_poll_controller; 4132 net_dev->poll_controller = bcm43xx_net_poll_controller;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_power.c b/drivers/net/wireless/bcm43xx/bcm43xx_power.c
index 6569da3a7a39..7e774f410953 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_power.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_power.c
@@ -153,8 +153,6 @@ int bcm43xx_pctl_init(struct bcm43xx_private *bcm)
153 int err, maxfreq; 153 int err, maxfreq;
154 struct bcm43xx_coreinfo *old_core; 154 struct bcm43xx_coreinfo *old_core;
155 155
156 if (!(bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL))
157 return 0;
158 old_core = bcm->current_core; 156 old_core = bcm->current_core;
159 err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon); 157 err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon);
160 if (err == -ENODEV) 158 if (err == -ENODEV)
@@ -162,11 +160,27 @@ int bcm43xx_pctl_init(struct bcm43xx_private *bcm)
162 if (err) 160 if (err)
163 goto out; 161 goto out;
164 162
165 maxfreq = bcm43xx_pctl_clockfreqlimit(bcm, 1); 163 if (bcm->chip_id == 0x4321) {
166 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_PLLONDELAY, 164 if (bcm->chip_rev == 0)
167 (maxfreq * 150 + 999999) / 1000000); 165 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_CTL, 0x03A4);
168 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_FREFSELDELAY, 166 if (bcm->chip_rev == 1)
169 (maxfreq * 15 + 999999) / 1000000); 167 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_CTL, 0x00A4);
168 }
169
170 if (bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL) {
171 if (bcm->current_core->rev >= 10) {
172 /* Set Idle Power clock rate to 1Mhz */
173 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_SYSCLKCTL,
174 (bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SYSCLKCTL)
175 & 0x0000FFFF) | 0x40000);
176 } else {
177 maxfreq = bcm43xx_pctl_clockfreqlimit(bcm, 1);
178 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_PLLONDELAY,
179 (maxfreq * 150 + 999999) / 1000000);
180 bcm43xx_write32(bcm, BCM43xx_CHIPCOMMON_FREFSELDELAY,
181 (maxfreq * 15 + 999999) / 1000000);
182 }
183 }
170 184
171 err = bcm43xx_switch_core(bcm, old_core); 185 err = bcm43xx_switch_core(bcm, old_core);
172 assert(err == 0); 186 assert(err == 0);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index d27016f8c736..a659442b9c15 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -47,9 +47,6 @@
47#define BCM43xx_WX_VERSION 18 47#define BCM43xx_WX_VERSION 18
48 48
49#define MAX_WX_STRING 80 49#define MAX_WX_STRING 80
50/* FIXME: the next line is a guess as to what the maximum RSSI value might be */
51#define RX_RSSI_MAX 60
52
53 50
54static int bcm43xx_wx_get_name(struct net_device *net_dev, 51static int bcm43xx_wx_get_name(struct net_device *net_dev,
55 struct iw_request_info *info, 52 struct iw_request_info *info,
@@ -693,6 +690,7 @@ static int bcm43xx_wx_set_swencryption(struct net_device *net_dev,
693 bcm->ieee->host_encrypt = !!on; 690 bcm->ieee->host_encrypt = !!on;
694 bcm->ieee->host_decrypt = !!on; 691 bcm->ieee->host_decrypt = !!on;
695 bcm->ieee->host_build_iv = !on; 692 bcm->ieee->host_build_iv = !on;
693 bcm->ieee->host_strip_iv_icv = !on;
696 spin_unlock_irqrestore(&bcm->irq_lock, flags); 694 spin_unlock_irqrestore(&bcm->irq_lock, flags);
697 mutex_unlock(&bcm->mutex); 695 mutex_unlock(&bcm->mutex);
698 696
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
index 0159e4e93201..3e2462671690 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
@@ -544,24 +544,6 @@ int bcm43xx_rx(struct bcm43xx_private *bcm,
544 } 544 }
545 545
546 frame_ctl = le16_to_cpu(wlhdr->frame_ctl); 546 frame_ctl = le16_to_cpu(wlhdr->frame_ctl);
547 if ((frame_ctl & IEEE80211_FCTL_PROTECTED) && !bcm->ieee->host_decrypt) {
548 frame_ctl &= ~IEEE80211_FCTL_PROTECTED;
549 wlhdr->frame_ctl = cpu_to_le16(frame_ctl);
550 /* trim IV and ICV */
551 /* FIXME: this must be done only for WEP encrypted packets */
552 if (skb->len < 32) {
553 dprintkl(KERN_ERR PFX "RX packet dropped (PROTECTED flag "
554 "set and length < 32)\n");
555 return -EINVAL;
556 } else {
557 memmove(skb->data + 4, skb->data, 24);
558 skb_pull(skb, 4);
559 skb_trim(skb, skb->len - 4);
560 stats.len -= 8;
561 }
562 wlhdr = (struct ieee80211_hdr_4addr *)(skb->data);
563 }
564
565 switch (WLAN_FC_GET_TYPE(frame_ctl)) { 547 switch (WLAN_FC_GET_TYPE(frame_ctl)) {
566 case IEEE80211_FTYPE_MGMT: 548 case IEEE80211_FTYPE_MGMT:
567 ieee80211_rx_mgt(bcm->ieee, wlhdr, &stats); 549 ieee80211_rx_mgt(bcm->ieee, wlhdr, &stats);
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index c2fa011be291..d1de9766c831 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -425,8 +425,14 @@ static int prism2_pci_suspend(struct pci_dev *pdev, pm_message_t state)
425static int prism2_pci_resume(struct pci_dev *pdev) 425static int prism2_pci_resume(struct pci_dev *pdev)
426{ 426{
427 struct net_device *dev = pci_get_drvdata(pdev); 427 struct net_device *dev = pci_get_drvdata(pdev);
428 int err;
428 429
429 pci_enable_device(pdev); 430 err = pci_enable_device(pdev);
431 if (err) {
432 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
433 dev->name);
434 return err;
435 }
430 pci_restore_state(pdev); 436 pci_restore_state(pdev);
431 prism2_hw_config(dev, 0); 437 prism2_hw_config(dev, 0);
432 if (netif_running(dev)) { 438 if (netif_running(dev)) {
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 0f554373a60d..1bcd352a813b 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -5833,19 +5833,6 @@ static void ipw2100_tx_timeout(struct net_device *dev)
5833 schedule_reset(priv); 5833 schedule_reset(priv);
5834} 5834}
5835 5835
5836/*
5837 * TODO: reimplement it so that it reads statistics
5838 * from the adapter using ordinal tables
5839 * instead of/in addition to collecting them
5840 * in the driver
5841 */
5842static struct net_device_stats *ipw2100_stats(struct net_device *dev)
5843{
5844 struct ipw2100_priv *priv = ieee80211_priv(dev);
5845
5846 return &priv->ieee->stats;
5847}
5848
5849static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value) 5836static int ipw2100_wpa_enable(struct ipw2100_priv *priv, int value)
5850{ 5837{
5851 /* This is called when wpa_supplicant loads and closes the driver 5838 /* This is called when wpa_supplicant loads and closes the driver
@@ -6030,7 +6017,6 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6030 dev->open = ipw2100_open; 6017 dev->open = ipw2100_open;
6031 dev->stop = ipw2100_close; 6018 dev->stop = ipw2100_close;
6032 dev->init = ipw2100_net_init; 6019 dev->init = ipw2100_net_init;
6033 dev->get_stats = ipw2100_stats;
6034 dev->ethtool_ops = &ipw2100_ethtool_ops; 6020 dev->ethtool_ops = &ipw2100_ethtool_ops;
6035 dev->tx_timeout = ipw2100_tx_timeout; 6021 dev->tx_timeout = ipw2100_tx_timeout;
6036 dev->wireless_handlers = &ipw2100_wx_handler_def; 6022 dev->wireless_handlers = &ipw2100_wx_handler_def;
@@ -6428,6 +6414,7 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6428{ 6414{
6429 struct ipw2100_priv *priv = pci_get_drvdata(pci_dev); 6415 struct ipw2100_priv *priv = pci_get_drvdata(pci_dev);
6430 struct net_device *dev = priv->net_dev; 6416 struct net_device *dev = priv->net_dev;
6417 int err;
6431 u32 val; 6418 u32 val;
6432 6419
6433 if (IPW2100_PM_DISABLED) 6420 if (IPW2100_PM_DISABLED)
@@ -6438,7 +6425,12 @@ static int ipw2100_resume(struct pci_dev *pci_dev)
6438 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name); 6425 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name);
6439 6426
6440 pci_set_power_state(pci_dev, PCI_D0); 6427 pci_set_power_state(pci_dev, PCI_D0);
6441 pci_enable_device(pci_dev); 6428 err = pci_enable_device(pci_dev);
6429 if (err) {
6430 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
6431 dev->name);
6432 return err;
6433 }
6442 pci_restore_state(pci_dev); 6434 pci_restore_state(pci_dev);
6443 6435
6444 /* 6436 /*
@@ -7573,11 +7565,10 @@ static int ipw2100_wx_set_genie(struct net_device *dev,
7573 return -EINVAL; 7565 return -EINVAL;
7574 7566
7575 if (wrqu->data.length) { 7567 if (wrqu->data.length) {
7576 buf = kmalloc(wrqu->data.length, GFP_KERNEL); 7568 buf = kmemdup(extra, wrqu->data.length, GFP_KERNEL);
7577 if (buf == NULL) 7569 if (buf == NULL)
7578 return -ENOMEM; 7570 return -ENOMEM;
7579 7571
7580 memcpy(buf, extra, wrqu->data.length);
7581 kfree(ieee->wpa_ie); 7572 kfree(ieee->wpa_ie);
7582 ieee->wpa_ie = buf; 7573 ieee->wpa_ie = buf;
7583 ieee->wpa_ie_len = wrqu->data.length; 7574 ieee->wpa_ie_len = wrqu->data.length;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 587a0918fa52..e82e56bb85e1 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -6938,8 +6938,8 @@ static int ipw_qos_association(struct ipw_priv *priv,
6938} 6938}
6939 6939
6940/* 6940/*
6941* handling the beaconing responces. if we get different QoS setting 6941* handling the beaconing responses. if we get different QoS setting
6942* of the network from the the associated setting adjust the QoS 6942* off the network from the associated setting, adjust the QoS
6943* setting 6943* setting
6944*/ 6944*/
6945static int ipw_qos_association_resp(struct ipw_priv *priv, 6945static int ipw_qos_association_resp(struct ipw_priv *priv,
@@ -11746,12 +11746,18 @@ static int ipw_pci_resume(struct pci_dev *pdev)
11746{ 11746{
11747 struct ipw_priv *priv = pci_get_drvdata(pdev); 11747 struct ipw_priv *priv = pci_get_drvdata(pdev);
11748 struct net_device *dev = priv->net_dev; 11748 struct net_device *dev = priv->net_dev;
11749 int err;
11749 u32 val; 11750 u32 val;
11750 11751
11751 printk(KERN_INFO "%s: Coming out of suspend...\n", dev->name); 11752 printk(KERN_INFO "%s: Coming out of suspend...\n", dev->name);
11752 11753
11753 pci_set_power_state(pdev, PCI_D0); 11754 pci_set_power_state(pdev, PCI_D0);
11754 pci_enable_device(pdev); 11755 err = pci_enable_device(pdev);
11756 if (err) {
11757 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
11758 dev->name);
11759 return err;
11760 }
11755 pci_restore_state(pdev); 11761 pci_restore_state(pdev);
11756 11762
11757 /* 11763 /*
diff --git a/drivers/net/wireless/orinoco_pci.h b/drivers/net/wireless/orinoco_pci.h
index be1abea4b64f..f4e5e06760c1 100644
--- a/drivers/net/wireless/orinoco_pci.h
+++ b/drivers/net/wireless/orinoco_pci.h
@@ -60,7 +60,12 @@ static int orinoco_pci_resume(struct pci_dev *pdev)
60 int err; 60 int err;
61 61
62 pci_set_power_state(pdev, 0); 62 pci_set_power_state(pdev, 0);
63 pci_enable_device(pdev); 63 err = pci_enable_device(pdev);
64 if (err) {
65 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
66 dev->name);
67 return err;
68 }
64 pci_restore_state(pdev); 69 pci_restore_state(pdev);
65 70
66 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, 71 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
diff --git a/drivers/net/wireless/prism54/isl_38xx.c b/drivers/net/wireless/prism54/isl_38xx.c
index 23deee69974b..02fc67bccbd0 100644
--- a/drivers/net/wireless/prism54/isl_38xx.c
+++ b/drivers/net/wireless/prism54/isl_38xx.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003-2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>_ 3 * Copyright (C) 2003-2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>_
5 * 4 *
@@ -38,7 +37,7 @@
38 * isl38xx_disable_interrupts - disable all interrupts 37 * isl38xx_disable_interrupts - disable all interrupts
39 * @device: pci memory base address 38 * @device: pci memory base address
40 * 39 *
41 * Instructs the device to disable all interrupt reporting by asserting 40 * Instructs the device to disable all interrupt reporting by asserting
42 * the IRQ line. New events may still show up in the interrupt identification 41 * the IRQ line. New events may still show up in the interrupt identification
43 * register located at offset %ISL38XX_INT_IDENT_REG. 42 * register located at offset %ISL38XX_INT_IDENT_REG.
44 */ 43 */
@@ -204,17 +203,19 @@ isl38xx_interface_reset(void __iomem *device_base, dma_addr_t host_address)
204 /* enable the interrupt for detecting initialization */ 203 /* enable the interrupt for detecting initialization */
205 204
206 /* Note: Do not enable other interrupts here. We want the 205 /* Note: Do not enable other interrupts here. We want the
207 * device to have come up first 100% before allowing any other 206 * device to have come up first 100% before allowing any other
208 * interrupts. */ 207 * interrupts. */
209 isl38xx_w32_flush(device_base, ISL38XX_INT_IDENT_INIT, ISL38XX_INT_EN_REG); 208 isl38xx_w32_flush(device_base, ISL38XX_INT_IDENT_INIT, ISL38XX_INT_EN_REG);
210 udelay(ISL38XX_WRITEIO_DELAY); /* allow complete full reset */ 209 udelay(ISL38XX_WRITEIO_DELAY); /* allow complete full reset */
211} 210}
212 211
213void 212void
214isl38xx_enable_common_interrupts(void __iomem *device_base) { 213isl38xx_enable_common_interrupts(void __iomem *device_base)
214{
215 u32 reg; 215 u32 reg;
216 reg = ( ISL38XX_INT_IDENT_UPDATE | 216
217 ISL38XX_INT_IDENT_SLEEP | ISL38XX_INT_IDENT_WAKEUP); 217 reg = ISL38XX_INT_IDENT_UPDATE | ISL38XX_INT_IDENT_SLEEP |
218 ISL38XX_INT_IDENT_WAKEUP;
218 isl38xx_w32_flush(device_base, reg, ISL38XX_INT_EN_REG); 219 isl38xx_w32_flush(device_base, reg, ISL38XX_INT_EN_REG);
219 udelay(ISL38XX_WRITEIO_DELAY); 220 udelay(ISL38XX_WRITEIO_DELAY);
220} 221}
@@ -234,23 +235,21 @@ isl38xx_in_queue(isl38xx_control_block *cb, int queue)
234 /* send queues */ 235 /* send queues */
235 case ISL38XX_CB_TX_MGMTQ: 236 case ISL38XX_CB_TX_MGMTQ:
236 BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE); 237 BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE);
238
237 case ISL38XX_CB_TX_DATA_LQ: 239 case ISL38XX_CB_TX_DATA_LQ:
238 case ISL38XX_CB_TX_DATA_HQ: 240 case ISL38XX_CB_TX_DATA_HQ:
239 BUG_ON(delta > ISL38XX_CB_TX_QSIZE); 241 BUG_ON(delta > ISL38XX_CB_TX_QSIZE);
240 return delta; 242 return delta;
241 break;
242 243
243 /* receive queues */ 244 /* receive queues */
244 case ISL38XX_CB_RX_MGMTQ: 245 case ISL38XX_CB_RX_MGMTQ:
245 BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE); 246 BUG_ON(delta > ISL38XX_CB_MGMT_QSIZE);
246 return ISL38XX_CB_MGMT_QSIZE - delta; 247 return ISL38XX_CB_MGMT_QSIZE - delta;
247 break;
248 248
249 case ISL38XX_CB_RX_DATA_LQ: 249 case ISL38XX_CB_RX_DATA_LQ:
250 case ISL38XX_CB_RX_DATA_HQ: 250 case ISL38XX_CB_RX_DATA_HQ:
251 BUG_ON(delta > ISL38XX_CB_RX_QSIZE); 251 BUG_ON(delta > ISL38XX_CB_RX_QSIZE);
252 return ISL38XX_CB_RX_QSIZE - delta; 252 return ISL38XX_CB_RX_QSIZE - delta;
253 break;
254 } 253 }
255 BUG(); 254 BUG();
256 return 0; 255 return 0;
diff --git a/drivers/net/wireless/prism54/isl_38xx.h b/drivers/net/wireless/prism54/isl_38xx.h
index 8af20980af8d..3fadcb6f5297 100644
--- a/drivers/net/wireless/prism54/isl_38xx.h
+++ b/drivers/net/wireless/prism54/isl_38xx.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * 3 *
5 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -67,10 +66,10 @@
67 * @base: (host) memory base address of the device 66 * @base: (host) memory base address of the device
68 * @val: 32bit value (host order) to write 67 * @val: 32bit value (host order) to write
69 * @offset: byte offset into @base to write value to 68 * @offset: byte offset into @base to write value to
70 * 69 *
71 * This helper takes care of writing a 32bit datum to the 70 * This helper takes care of writing a 32bit datum to the
72 * specified offset into the device's pci memory space, and making sure 71 * specified offset into the device's pci memory space, and making sure
73 * the pci memory buffers get flushed by performing one harmless read 72 * the pci memory buffers get flushed by performing one harmless read
74 * from the %ISL38XX_PCI_POSTING_FLUSH offset. 73 * from the %ISL38XX_PCI_POSTING_FLUSH offset.
75 */ 74 */
76static inline void 75static inline void
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index e7700b4257eb..a87eb51886c8 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * (C) 2003,2004 Aurelien Alleaume <slts@free.fr> 3 * (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
5 * (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 4 * (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
@@ -55,12 +54,12 @@ static const unsigned char scan_rate_list[] = { 2, 4, 11, 22,
55 * prism54_mib_mode_helper - MIB change mode helper function 54 * prism54_mib_mode_helper - MIB change mode helper function
56 * @mib: the &struct islpci_mib object to modify 55 * @mib: the &struct islpci_mib object to modify
57 * @iw_mode: new mode (%IW_MODE_*) 56 * @iw_mode: new mode (%IW_MODE_*)
58 * 57 *
59 * This is a helper function, hence it does not lock. Make sure 58 * This is a helper function, hence it does not lock. Make sure
60 * caller deals with locking *if* necessary. This function sets the 59 * caller deals with locking *if* necessary. This function sets the
61 * mode-dependent mib values and does the mapping of the Linux 60 * mode-dependent mib values and does the mapping of the Linux
62 * Wireless API modes to Device firmware modes. It also checks for 61 * Wireless API modes to Device firmware modes. It also checks for
63 * correct valid Linux wireless modes. 62 * correct valid Linux wireless modes.
64 */ 63 */
65static int 64static int
66prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode) 65prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
@@ -118,7 +117,7 @@ prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
118 * 117 *
119 * this function initializes the struct given as @mib with defaults, 118 * this function initializes the struct given as @mib with defaults,
120 * of which many are retrieved from the global module parameter 119 * of which many are retrieved from the global module parameter
121 * variables. 120 * variables.
122 */ 121 */
123 122
124void 123void
@@ -134,7 +133,7 @@ prism54_mib_init(islpci_private *priv)
134 authen = CARD_DEFAULT_AUTHEN; 133 authen = CARD_DEFAULT_AUTHEN;
135 wep = CARD_DEFAULT_WEP; 134 wep = CARD_DEFAULT_WEP;
136 filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */ 135 filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */
137 dot1x = CARD_DEFAULT_DOT1X; 136 dot1x = CARD_DEFAULT_DOT1X;
138 mlme = CARD_DEFAULT_MLME_MODE; 137 mlme = CARD_DEFAULT_MLME_MODE;
139 conformance = CARD_DEFAULT_CONFORMANCE; 138 conformance = CARD_DEFAULT_CONFORMANCE;
140 power = 127; 139 power = 127;
@@ -229,7 +228,7 @@ prism54_get_wireless_stats(struct net_device *ndev)
229 } else 228 } else
230 priv->iwstatistics.qual.updated = 0; 229 priv->iwstatistics.qual.updated = 0;
231 230
232 /* Update our wireless stats, but do not schedule to often 231 /* Update our wireless stats, but do not schedule to often
233 * (max 1 HZ) */ 232 * (max 1 HZ) */
234 if ((priv->stats_timestamp == 0) || 233 if ((priv->stats_timestamp == 0) ||
235 time_after(jiffies, priv->stats_timestamp + 1 * HZ)) { 234 time_after(jiffies, priv->stats_timestamp + 1 * HZ)) {
@@ -706,7 +705,7 @@ prism54_get_scan(struct net_device *ndev, struct iw_request_info *info,
706 * Starting with WE-17, the buffer can be as big as needed. 705 * Starting with WE-17, the buffer can be as big as needed.
707 * But the device won't repport anything if you change the value 706 * But the device won't repport anything if you change the value
708 * of IWMAX_BSS=24. */ 707 * of IWMAX_BSS=24. */
709 708
710 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r); 709 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
711 bsslist = r.ptr; 710 bsslist = r.ptr;
712 711
@@ -786,7 +785,7 @@ prism54_get_essid(struct net_device *ndev, struct iw_request_info *info,
786 return rvalue; 785 return rvalue;
787} 786}
788 787
789/* Provides no functionality, just completes the ioctl. In essence this is a 788/* Provides no functionality, just completes the ioctl. In essence this is a
790 * just a cosmetic ioctl. 789 * just a cosmetic ioctl.
791 */ 790 */
792static int 791static int
@@ -1105,7 +1104,7 @@ prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
1105 &key); 1104 &key);
1106 } 1105 }
1107 /* 1106 /*
1108 * If a valid key is set, encryption should be enabled 1107 * If a valid key is set, encryption should be enabled
1109 * (user may turn it off later). 1108 * (user may turn it off later).
1110 * This is also how "iwconfig ethX key on" works 1109 * This is also how "iwconfig ethX key on" works
1111 */ 1110 */
@@ -1127,7 +1126,7 @@ prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
1127 } 1126 }
1128 /* now read the flags */ 1127 /* now read the flags */
1129 if (dwrq->flags & IW_ENCODE_DISABLED) { 1128 if (dwrq->flags & IW_ENCODE_DISABLED) {
1130 /* Encoding disabled, 1129 /* Encoding disabled,
1131 * authen = DOT11_AUTH_OS; 1130 * authen = DOT11_AUTH_OS;
1132 * invoke = 0; 1131 * invoke = 0;
1133 * exunencrypt = 0; */ 1132 * exunencrypt = 0; */
@@ -1215,7 +1214,7 @@ prism54_get_txpower(struct net_device *ndev, struct iw_request_info *info,
1215 vwrq->value = (s32) r.u / 4; 1214 vwrq->value = (s32) r.u / 4;
1216 vwrq->fixed = 1; 1215 vwrq->fixed = 1;
1217 /* radio is not turned of 1216 /* radio is not turned of
1218 * btw: how is possible to turn off only the radio 1217 * btw: how is possible to turn off only the radio
1219 */ 1218 */
1220 vwrq->disabled = 0; 1219 vwrq->disabled = 0;
1221 1220
@@ -2355,17 +2354,17 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2355 handle_request(priv, mlme, oid); 2354 handle_request(priv, mlme, oid);
2356 send_formatted_event(priv, "Authenticate request (ex)", mlme, 1); 2355 send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
2357 2356
2358 if (priv->iw_mode != IW_MODE_MASTER 2357 if (priv->iw_mode != IW_MODE_MASTER
2359 && mlmeex->state != DOT11_STATE_AUTHING) 2358 && mlmeex->state != DOT11_STATE_AUTHING)
2360 break; 2359 break;
2361 2360
2362 confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC); 2361 confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
2363 2362
2364 if (!confirm) 2363 if (!confirm)
2365 break; 2364 break;
2366 2365
2367 memcpy(&confirm->address, mlmeex->address, ETH_ALEN); 2366 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2368 printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 2367 printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2369 mlmeex->address[0], 2368 mlmeex->address[0],
2370 mlmeex->address[1], 2369 mlmeex->address[1],
2371 mlmeex->address[2], 2370 mlmeex->address[2],
@@ -2399,10 +2398,10 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2399 handle_request(priv, mlme, oid); 2398 handle_request(priv, mlme, oid);
2400 send_formatted_event(priv, "Associate request (ex)", mlme, 1); 2399 send_formatted_event(priv, "Associate request (ex)", mlme, 1);
2401 2400
2402 if (priv->iw_mode != IW_MODE_MASTER 2401 if (priv->iw_mode != IW_MODE_MASTER
2403 && mlmeex->state != DOT11_STATE_ASSOCING) 2402 && mlmeex->state != DOT11_STATE_ASSOCING)
2404 break; 2403 break;
2405 2404
2406 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC); 2405 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
2407 2406
2408 if (!confirm) 2407 if (!confirm)
@@ -2418,7 +2417,7 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2418 2417
2419 if (!wpa_ie_len) { 2418 if (!wpa_ie_len) {
2420 printk(KERN_DEBUG "No WPA IE found from " 2419 printk(KERN_DEBUG "No WPA IE found from "
2421 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 2420 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2422 mlmeex->address[0], 2421 mlmeex->address[0],
2423 mlmeex->address[1], 2422 mlmeex->address[1],
2424 mlmeex->address[2], 2423 mlmeex->address[2],
@@ -2436,14 +2435,14 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2436 mgt_set_varlen(priv, oid, confirm, wpa_ie_len); 2435 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2437 2436
2438 kfree(confirm); 2437 kfree(confirm);
2439 2438
2440 break; 2439 break;
2441 2440
2442 case DOT11_OID_REASSOCIATEEX: 2441 case DOT11_OID_REASSOCIATEEX:
2443 handle_request(priv, mlme, oid); 2442 handle_request(priv, mlme, oid);
2444 send_formatted_event(priv, "Reassociate request (ex)", mlme, 1); 2443 send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
2445 2444
2446 if (priv->iw_mode != IW_MODE_MASTER 2445 if (priv->iw_mode != IW_MODE_MASTER
2447 && mlmeex->state != DOT11_STATE_ASSOCING) 2446 && mlmeex->state != DOT11_STATE_ASSOCING)
2448 break; 2447 break;
2449 2448
@@ -2462,7 +2461,7 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2462 2461
2463 if (!wpa_ie_len) { 2462 if (!wpa_ie_len) {
2464 printk(KERN_DEBUG "No WPA IE found from " 2463 printk(KERN_DEBUG "No WPA IE found from "
2465 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n", 2464 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2466 mlmeex->address[0], 2465 mlmeex->address[0],
2467 mlmeex->address[1], 2466 mlmeex->address[1],
2468 mlmeex->address[2], 2467 mlmeex->address[2],
@@ -2474,13 +2473,13 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2474 break; 2473 break;
2475 } 2474 }
2476 2475
2477 confirm->size = wpa_ie_len; 2476 confirm->size = wpa_ie_len;
2478 memcpy(&confirm->data, wpa_ie, wpa_ie_len); 2477 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
2479 2478
2480 mgt_set_varlen(priv, oid, confirm, wpa_ie_len); 2479 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2481 2480
2482 kfree(confirm); 2481 kfree(confirm);
2483 2482
2484 break; 2483 break;
2485 2484
2486 default: 2485 default:
@@ -2547,10 +2546,10 @@ enum {
2547#define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ 2546#define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
2548((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data)) 2547((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
2549 2548
2550/* Maximum length for algorithm names (-1 for nul termination) 2549/* Maximum length for algorithm names (-1 for nul termination)
2551 * used in ioctl() */ 2550 * used in ioctl() */
2552#define HOSTAP_CRYPT_ALG_NAME_LEN 16 2551#define HOSTAP_CRYPT_ALG_NAME_LEN 16
2553 2552
2554struct prism2_hostapd_param { 2553struct prism2_hostapd_param {
2555 u32 cmd; 2554 u32 cmd;
2556 u8 sta_addr[ETH_ALEN]; 2555 u8 sta_addr[ETH_ALEN];
@@ -2623,7 +2622,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,
2623 &key); 2622 &key);
2624 } 2623 }
2625 /* 2624 /*
2626 * If a valid key is set, encryption should be enabled 2625 * If a valid key is set, encryption should be enabled
2627 * (user may turn it off later). 2626 * (user may turn it off later).
2628 * This is also how "iwconfig ethX key on" works 2627 * This is also how "iwconfig ethX key on" works
2629 */ 2628 */
@@ -2645,7 +2644,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,
2645 } 2644 }
2646 /* now read the flags */ 2645 /* now read the flags */
2647 if (param->u.crypt.flags & IW_ENCODE_DISABLED) { 2646 if (param->u.crypt.flags & IW_ENCODE_DISABLED) {
2648 /* Encoding disabled, 2647 /* Encoding disabled,
2649 * authen = DOT11_AUTH_OS; 2648 * authen = DOT11_AUTH_OS;
2650 * invoke = 0; 2649 * invoke = 0;
2651 * exunencrypt = 0; */ 2650 * exunencrypt = 0; */
@@ -2712,7 +2711,7 @@ prism2_ioctl_set_generic_element(struct net_device *ndev,
2712 2711
2713 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len); 2712 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2714 2713
2715 if (ret == 0) 2714 if (ret == 0)
2716 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n", 2715 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
2717 ndev->name); 2716 ndev->name);
2718 } 2717 }
@@ -2872,7 +2871,7 @@ prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
2872 mlme = DOT11_MLME_AUTO; 2871 mlme = DOT11_MLME_AUTO;
2873 printk("%s: Disabling WPA\n", ndev->name); 2872 printk("%s: Disabling WPA\n", ndev->name);
2874 break; 2873 break;
2875 case 2: 2874 case 2:
2876 case 1: /* WPA */ 2875 case 1: /* WPA */
2877 printk("%s: Enabling WPA\n", ndev->name); 2876 printk("%s: Enabling WPA\n", ndev->name);
2878 break; 2877 break;
diff --git a/drivers/net/wireless/prism54/isl_ioctl.h b/drivers/net/wireless/prism54/isl_ioctl.h
index 0802fa64996f..bcfbfb9281d2 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.h
+++ b/drivers/net/wireless/prism54/isl_ioctl.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * (C) 2003 Aurelien Alleaume <slts@free.fr> 3 * (C) 2003 Aurelien Alleaume <slts@free.fr>
5 * (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 4 * (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
diff --git a/drivers/net/wireless/prism54/isl_oid.h b/drivers/net/wireless/prism54/isl_oid.h
index 419edf7ccf1a..b7534c2869c8 100644
--- a/drivers/net/wireless/prism54/isl_oid.h
+++ b/drivers/net/wireless/prism54/isl_oid.h
@@ -1,6 +1,4 @@
1/* 1/*
2 *
3 *
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 2 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 3 * Copyright (C) 2004 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr> 4 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
@@ -23,7 +21,7 @@
23#if !defined(_ISL_OID_H) 21#if !defined(_ISL_OID_H)
24#define _ISL_OID_H 22#define _ISL_OID_H
25 23
26/* 24/*
27 * MIB related constant and structure definitions for communicating 25 * MIB related constant and structure definitions for communicating
28 * with the device firmware 26 * with the device firmware
29 */ 27 */
@@ -99,21 +97,21 @@ struct obj_attachment {
99 char data[0]; 97 char data[0];
100} __attribute__((packed)); 98} __attribute__((packed));
101 99
102/* 100/*
103 * in case everything's ok, the inlined function below will be 101 * in case everything's ok, the inlined function below will be
104 * optimized away by the compiler... 102 * optimized away by the compiler...
105 */ 103 */
106static inline void 104static inline void
107__bug_on_wrong_struct_sizes(void) 105__bug_on_wrong_struct_sizes(void)
108{ 106{
109 BUG_ON(sizeof (struct obj_ssid) != 34); 107 BUILD_BUG_ON(sizeof (struct obj_ssid) != 34);
110 BUG_ON(sizeof (struct obj_key) != 34); 108 BUILD_BUG_ON(sizeof (struct obj_key) != 34);
111 BUG_ON(sizeof (struct obj_mlme) != 12); 109 BUILD_BUG_ON(sizeof (struct obj_mlme) != 12);
112 BUG_ON(sizeof (struct obj_mlmeex) != 14); 110 BUILD_BUG_ON(sizeof (struct obj_mlmeex) != 14);
113 BUG_ON(sizeof (struct obj_buffer) != 8); 111 BUILD_BUG_ON(sizeof (struct obj_buffer) != 8);
114 BUG_ON(sizeof (struct obj_bss) != 60); 112 BUILD_BUG_ON(sizeof (struct obj_bss) != 60);
115 BUG_ON(sizeof (struct obj_bsslist) != 4); 113 BUILD_BUG_ON(sizeof (struct obj_bsslist) != 4);
116 BUG_ON(sizeof (struct obj_frequencies) != 2); 114 BUILD_BUG_ON(sizeof (struct obj_frequencies) != 2);
117} 115}
118 116
119enum dot11_state_t { 117enum dot11_state_t {
@@ -154,13 +152,13 @@ enum dot11_priv_t {
154 152
155/* Prism "Nitro" / Frameburst / "Packet Frame Grouping" 153/* Prism "Nitro" / Frameburst / "Packet Frame Grouping"
156 * Value is in microseconds. Represents the # microseconds 154 * Value is in microseconds. Represents the # microseconds
157 * the firmware will take to group frames before sending out then out 155 * the firmware will take to group frames before sending out then out
158 * together with a CSMA contention. Without this all frames are 156 * together with a CSMA contention. Without this all frames are
159 * sent with a CSMA contention. 157 * sent with a CSMA contention.
160 * Bibliography: 158 * Bibliography:
161 * http://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html 159 * http://www.hpl.hp.com/personal/Jean_Tourrilhes/Papers/Packet.Frame.Grouping.html
162 */ 160 */
163enum dot11_maxframeburst_t { 161enum dot11_maxframeburst_t {
164 /* Values for DOT11_OID_MAXFRAMEBURST */ 162 /* Values for DOT11_OID_MAXFRAMEBURST */
165 DOT11_MAXFRAMEBURST_OFF = 0, /* Card firmware default */ 163 DOT11_MAXFRAMEBURST_OFF = 0, /* Card firmware default */
166 DOT11_MAXFRAMEBURST_MIXED_SAFE = 650, /* 802.11 a,b,g safe */ 164 DOT11_MAXFRAMEBURST_MIXED_SAFE = 650, /* 802.11 a,b,g safe */
@@ -176,9 +174,9 @@ enum dot11_maxframeburst_t {
176/* Support for 802.11 long and short frame preambles. 174/* Support for 802.11 long and short frame preambles.
177 * Long preamble uses 128-bit sync field, 8-bit CRC 175 * Long preamble uses 128-bit sync field, 8-bit CRC
178 * Short preamble uses 56-bit sync field, 16-bit CRC 176 * Short preamble uses 56-bit sync field, 16-bit CRC
179 * 177 *
180 * 802.11a -- not sure, both optionally ? 178 * 802.11a -- not sure, both optionally ?
181 * 802.11b supports long and optionally short 179 * 802.11b supports long and optionally short
182 * 802.11g supports both */ 180 * 802.11g supports both */
183enum dot11_preamblesettings_t { 181enum dot11_preamblesettings_t {
184 DOT11_PREAMBLESETTING_LONG = 0, 182 DOT11_PREAMBLESETTING_LONG = 0,
@@ -194,7 +192,7 @@ enum dot11_preamblesettings_t {
194 * Long uses 802.11a slot timing (9 usec ?) 192 * Long uses 802.11a slot timing (9 usec ?)
195 * Short uses 802.11b slot timing (20 use ?) */ 193 * Short uses 802.11b slot timing (20 use ?) */
196enum dot11_slotsettings_t { 194enum dot11_slotsettings_t {
197 DOT11_SLOTSETTINGS_LONG = 0, 195 DOT11_SLOTSETTINGS_LONG = 0,
198 /* Allows *only* long 802.11b slot timing */ 196 /* Allows *only* long 802.11b slot timing */
199 DOT11_SLOTSETTINGS_SHORT = 1, 197 DOT11_SLOTSETTINGS_SHORT = 1,
200 /* Allows *only* long 802.11a slot timing */ 198 /* Allows *only* long 802.11a slot timing */
@@ -203,7 +201,7 @@ enum dot11_slotsettings_t {
203}; 201};
204 202
205/* All you need to know, ERP is "Extended Rate PHY". 203/* All you need to know, ERP is "Extended Rate PHY".
206 * An Extended Rate PHY (ERP) STA or AP shall support three different 204 * An Extended Rate PHY (ERP) STA or AP shall support three different
207 * preamble and header formats: 205 * preamble and header formats:
208 * Long preamble (refer to above) 206 * Long preamble (refer to above)
209 * Short preamble (refer to above) 207 * Short preamble (refer to above)
@@ -221,7 +219,7 @@ enum do11_nonerpstatus_t {
221/* (ERP is "Extended Rate PHY") Way to read NONERP is NON-ERP-* 219/* (ERP is "Extended Rate PHY") Way to read NONERP is NON-ERP-*
222 * The key here is DOT11 NON ERP NEVER protects against 220 * The key here is DOT11 NON ERP NEVER protects against
223 * NON ERP STA's. You *don't* want this unless 221 * NON ERP STA's. You *don't* want this unless
224 * you know what you are doing. It means you will only 222 * you know what you are doing. It means you will only
225 * get Extended Rate capabilities */ 223 * get Extended Rate capabilities */
226enum dot11_nonerpprotection_t { 224enum dot11_nonerpprotection_t {
227 DOT11_NONERP_NEVER = 0, 225 DOT11_NONERP_NEVER = 0,
@@ -229,13 +227,13 @@ enum dot11_nonerpprotection_t {
229 DOT11_NONERP_DYNAMIC = 2 227 DOT11_NONERP_DYNAMIC = 2
230}; 228};
231 229
232/* Preset OID configuration for 802.11 modes 230/* Preset OID configuration for 802.11 modes
233 * Note: DOT11_OID_CW[MIN|MAX] hold the values of the 231 * Note: DOT11_OID_CW[MIN|MAX] hold the values of the
234 * DCS MIN|MAX backoff used */ 232 * DCS MIN|MAX backoff used */
235enum dot11_profile_t { /* And set/allowed values */ 233enum dot11_profile_t { /* And set/allowed values */
236 /* Allowed values for DOT11_OID_PROFILES */ 234 /* Allowed values for DOT11_OID_PROFILES */
237 DOT11_PROFILE_B_ONLY = 0, 235 DOT11_PROFILE_B_ONLY = 0,
238 /* DOT11_OID_RATES: 1, 2, 5.5, 11Mbps 236 /* DOT11_OID_RATES: 1, 2, 5.5, 11Mbps
239 * DOT11_OID_PREAMBLESETTINGS: DOT11_PREAMBLESETTING_DYNAMIC 237 * DOT11_OID_PREAMBLESETTINGS: DOT11_PREAMBLESETTING_DYNAMIC
240 * DOT11_OID_CWMIN: 31 238 * DOT11_OID_CWMIN: 31
241 * DOT11_OID_NONEPROTECTION: DOT11_NOERP_DYNAMIC 239 * DOT11_OID_NONEPROTECTION: DOT11_NOERP_DYNAMIC
@@ -275,7 +273,7 @@ enum oid_inl_conformance_t {
275 OID_INL_CONFORMANCE_NONE = 0, /* Perform active scanning */ 273 OID_INL_CONFORMANCE_NONE = 0, /* Perform active scanning */
276 OID_INL_CONFORMANCE_STRICT = 1, /* Strictly adhere to 802.11d */ 274 OID_INL_CONFORMANCE_STRICT = 1, /* Strictly adhere to 802.11d */
277 OID_INL_CONFORMANCE_FLEXIBLE = 2, /* Use passed 802.11d info to 275 OID_INL_CONFORMANCE_FLEXIBLE = 2, /* Use passed 802.11d info to
278 * determine channel AND/OR just make assumption that active 276 * determine channel AND/OR just make assumption that active
279 * channels are valid channels */ 277 * channels are valid channels */
280}; 278};
281 279
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index e35fcb2543c4..f057fd9fcd79 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 3 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 4 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
@@ -413,7 +412,7 @@ prism54_bring_down(islpci_private *priv)
413 islpci_set_state(priv, PRV_STATE_PREBOOT); 412 islpci_set_state(priv, PRV_STATE_PREBOOT);
414 413
415 /* disable all device interrupts in case they weren't */ 414 /* disable all device interrupts in case they weren't */
416 isl38xx_disable_interrupts(priv->device_base); 415 isl38xx_disable_interrupts(priv->device_base);
417 416
418 /* For safety reasons, we may want to ensure that no DMA transfer is 417 /* For safety reasons, we may want to ensure that no DMA transfer is
419 * currently in progress by emptying the TX and RX queues. */ 418 * currently in progress by emptying the TX and RX queues. */
@@ -480,7 +479,7 @@ islpci_reset_if(islpci_private *priv)
480 479
481 DEFINE_WAIT(wait); 480 DEFINE_WAIT(wait);
482 prepare_to_wait(&priv->reset_done, &wait, TASK_UNINTERRUPTIBLE); 481 prepare_to_wait(&priv->reset_done, &wait, TASK_UNINTERRUPTIBLE);
483 482
484 /* now the last step is to reset the interface */ 483 /* now the last step is to reset the interface */
485 isl38xx_interface_reset(priv->device_base, priv->device_host_address); 484 isl38xx_interface_reset(priv->device_base, priv->device_host_address);
486 islpci_set_state(priv, PRV_STATE_PREINIT); 485 islpci_set_state(priv, PRV_STATE_PREINIT);
@@ -488,7 +487,7 @@ islpci_reset_if(islpci_private *priv)
488 for(count = 0; count < 2 && result; count++) { 487 for(count = 0; count < 2 && result; count++) {
489 /* The software reset acknowledge needs about 220 msec here. 488 /* The software reset acknowledge needs about 220 msec here.
490 * Be conservative and wait for up to one second. */ 489 * Be conservative and wait for up to one second. */
491 490
492 remaining = schedule_timeout_uninterruptible(HZ); 491 remaining = schedule_timeout_uninterruptible(HZ);
493 492
494 if(remaining > 0) { 493 if(remaining > 0) {
@@ -496,7 +495,7 @@ islpci_reset_if(islpci_private *priv)
496 break; 495 break;
497 } 496 }
498 497
499 /* If we're here it's because our IRQ hasn't yet gone through. 498 /* If we're here it's because our IRQ hasn't yet gone through.
500 * Retry a bit more... 499 * Retry a bit more...
501 */ 500 */
502 printk(KERN_ERR "%s: no 'reset complete' IRQ seen - retrying\n", 501 printk(KERN_ERR "%s: no 'reset complete' IRQ seen - retrying\n",
@@ -514,7 +513,7 @@ islpci_reset_if(islpci_private *priv)
514 513
515 /* Now that the device is 100% up, let's allow 514 /* Now that the device is 100% up, let's allow
516 * for the other interrupts -- 515 * for the other interrupts --
517 * NOTE: this is not *yet* true since we've only allowed the 516 * NOTE: this is not *yet* true since we've only allowed the
518 * INIT interrupt on the IRQ line. We can perhaps poll 517 * INIT interrupt on the IRQ line. We can perhaps poll
519 * the IRQ line until we know for sure the reset went through */ 518 * the IRQ line until we know for sure the reset went through */
520 isl38xx_enable_common_interrupts(priv->device_base); 519 isl38xx_enable_common_interrupts(priv->device_base);
@@ -716,7 +715,7 @@ islpci_alloc_memory(islpci_private *priv)
716 715
717 prism54_acl_init(&priv->acl); 716 prism54_acl_init(&priv->acl);
718 prism54_wpa_bss_ie_init(priv); 717 prism54_wpa_bss_ie_init(priv);
719 if (mgt_init(priv)) 718 if (mgt_init(priv))
720 goto out_free; 719 goto out_free;
721 720
722 return 0; 721 return 0;
diff --git a/drivers/net/wireless/prism54/islpci_dev.h b/drivers/net/wireless/prism54/islpci_dev.h
index 2f7e525d0cf6..a9aa1662eaa4 100644
--- a/drivers/net/wireless/prism54/islpci_dev.h
+++ b/drivers/net/wireless/prism54/islpci_dev.h
@@ -1,6 +1,5 @@
1/* 1/*
2 * 2 * Copyright (C) 2002 Intersil Americas Inc.
3 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 3 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 4 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
6 * Copyright (C) 2003 Aurelien Alleaume <slts@free.fr> 5 * Copyright (C) 2003 Aurelien Alleaume <slts@free.fr>
@@ -72,12 +71,12 @@ struct islpci_bss_wpa_ie {
72 u8 bssid[ETH_ALEN]; 71 u8 bssid[ETH_ALEN];
73 u8 wpa_ie[MAX_WPA_IE_LEN]; 72 u8 wpa_ie[MAX_WPA_IE_LEN];
74 size_t wpa_ie_len; 73 size_t wpa_ie_len;
75 74
76}; 75};
77 76
78typedef struct { 77typedef struct {
79 spinlock_t slock; /* generic spinlock; */ 78 spinlock_t slock; /* generic spinlock; */
80 79
81 u32 priv_oid; 80 u32 priv_oid;
82 81
83 /* our mib cache */ 82 /* our mib cache */
@@ -85,7 +84,7 @@ typedef struct {
85 struct rw_semaphore mib_sem; 84 struct rw_semaphore mib_sem;
86 void **mib; 85 void **mib;
87 char nickname[IW_ESSID_MAX_SIZE+1]; 86 char nickname[IW_ESSID_MAX_SIZE+1];
88 87
89 /* Take care of the wireless stats */ 88 /* Take care of the wireless stats */
90 struct work_struct stats_work; 89 struct work_struct stats_work;
91 struct semaphore stats_sem; 90 struct semaphore stats_sem;
@@ -120,7 +119,7 @@ typedef struct {
120 struct net_device *ndev; 119 struct net_device *ndev;
121 120
122 /* device queue interface members */ 121 /* device queue interface members */
123 struct isl38xx_cb *control_block; /* device control block 122 struct isl38xx_cb *control_block; /* device control block
124 (== driver_mem_address!) */ 123 (== driver_mem_address!) */
125 124
126 /* Each queue has three indexes: 125 /* Each queue has three indexes:
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index 103a37877733..b1122912ee2d 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr> 3 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
5 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -48,7 +47,7 @@ islpci_eth_cleanup_transmit(islpci_private *priv,
48 /* read the index of the first fragment to be freed */ 47 /* read the index of the first fragment to be freed */
49 index = priv->free_data_tx % ISL38XX_CB_TX_QSIZE; 48 index = priv->free_data_tx % ISL38XX_CB_TX_QSIZE;
50 49
51 /* check for holes in the arrays caused by multi fragment frames 50 /* check for holes in the arrays caused by multi fragment frames
52 * searching for the last fragment of a frame */ 51 * searching for the last fragment of a frame */
53 if (priv->pci_map_tx_address[index] != (dma_addr_t) NULL) { 52 if (priv->pci_map_tx_address[index] != (dma_addr_t) NULL) {
54 /* entry is the last fragment of a frame 53 /* entry is the last fragment of a frame
@@ -253,6 +252,7 @@ islpci_monitor_rx(islpci_private *priv, struct sk_buff **skb)
253 * header and without the FCS. But there a is a bit that 252 * header and without the FCS. But there a is a bit that
254 * indicates if the packet is corrupted :-) */ 253 * indicates if the packet is corrupted :-) */
255 struct rfmon_header *hdr = (struct rfmon_header *) (*skb)->data; 254 struct rfmon_header *hdr = (struct rfmon_header *) (*skb)->data;
255
256 if (hdr->flags & 0x01) 256 if (hdr->flags & 0x01)
257 /* This one is bad. Drop it ! */ 257 /* This one is bad. Drop it ! */
258 return -1; 258 return -1;
@@ -284,7 +284,7 @@ islpci_monitor_rx(islpci_private *priv, struct sk_buff **skb)
284 (struct avs_80211_1_header *) skb_push(*skb, 284 (struct avs_80211_1_header *) skb_push(*skb,
285 sizeof (struct 285 sizeof (struct
286 avs_80211_1_header)); 286 avs_80211_1_header));
287 287
288 avs->version = cpu_to_be32(P80211CAPTURE_VERSION); 288 avs->version = cpu_to_be32(P80211CAPTURE_VERSION);
289 avs->length = cpu_to_be32(sizeof (struct avs_80211_1_header)); 289 avs->length = cpu_to_be32(sizeof (struct avs_80211_1_header));
290 avs->mactime = cpu_to_be64(le64_to_cpu(clock)); 290 avs->mactime = cpu_to_be64(le64_to_cpu(clock));
@@ -390,7 +390,7 @@ islpci_eth_receive(islpci_private *priv)
390 struct rx_annex_header *annex = 390 struct rx_annex_header *annex =
391 (struct rx_annex_header *) skb->data; 391 (struct rx_annex_header *) skb->data;
392 wstats.level = annex->rfmon.rssi; 392 wstats.level = annex->rfmon.rssi;
393 /* The noise value can be a bit outdated if nobody's 393 /* The noise value can be a bit outdated if nobody's
394 * reading wireless stats... */ 394 * reading wireless stats... */
395 wstats.noise = priv->local_iwstatistics.qual.noise; 395 wstats.noise = priv->local_iwstatistics.qual.noise;
396 wstats.qual = wstats.level - wstats.noise; 396 wstats.qual = wstats.level - wstats.noise;
@@ -464,10 +464,8 @@ islpci_eth_receive(islpci_private *priv)
464 break; 464 break;
465 } 465 }
466 /* update the fragment address */ 466 /* update the fragment address */
467 control_block->rx_data_low[index].address = cpu_to_le32((u32) 467 control_block->rx_data_low[index].address =
468 priv-> 468 cpu_to_le32((u32)priv->pci_map_rx_address[index]);
469 pci_map_rx_address
470 [index]);
471 wmb(); 469 wmb();
472 470
473 /* increment the driver read pointer */ 471 /* increment the driver read pointer */
@@ -485,9 +483,11 @@ void
485islpci_do_reset_and_wake(struct work_struct *work) 483islpci_do_reset_and_wake(struct work_struct *work)
486{ 484{
487 islpci_private *priv = container_of(work, islpci_private, reset_task); 485 islpci_private *priv = container_of(work, islpci_private, reset_task);
486
488 islpci_reset(priv, 1); 487 islpci_reset(priv, 1);
489 netif_wake_queue(priv->ndev);
490 priv->reset_task_pending = 0; 488 priv->reset_task_pending = 0;
489 smp_wmb();
490 netif_wake_queue(priv->ndev);
491} 491}
492 492
493void 493void
@@ -499,12 +499,14 @@ islpci_eth_tx_timeout(struct net_device *ndev)
499 /* increment the transmit error counter */ 499 /* increment the transmit error counter */
500 statistics->tx_errors++; 500 statistics->tx_errors++;
501 501
502 printk(KERN_WARNING "%s: tx_timeout", ndev->name);
503 if (!priv->reset_task_pending) { 502 if (!priv->reset_task_pending) {
504 priv->reset_task_pending = 1; 503 printk(KERN_WARNING
505 printk(", scheduling a reset"); 504 "%s: tx_timeout, scheduling reset", ndev->name);
506 netif_stop_queue(ndev); 505 netif_stop_queue(ndev);
506 priv->reset_task_pending = 1;
507 schedule_work(&priv->reset_task); 507 schedule_work(&priv->reset_task);
508 } else {
509 printk(KERN_WARNING
510 "%s: tx_timeout, waiting for reset", ndev->name);
508 } 511 }
509 printk("\n");
510} 512}
diff --git a/drivers/net/wireless/prism54/islpci_eth.h b/drivers/net/wireless/prism54/islpci_eth.h
index 99d37eda9f01..5bf820defbd0 100644
--- a/drivers/net/wireless/prism54/islpci_eth.h
+++ b/drivers/net/wireless/prism54/islpci_eth.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * 3 *
5 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c
index f692dccf0d07..58257b40c043 100644
--- a/drivers/net/wireless/prism54/islpci_hotplug.c
+++ b/drivers/net/wireless/prism54/islpci_hotplug.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org> 3 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * 4 *
@@ -40,8 +39,8 @@ static int init_pcitm = 0;
40module_param(init_pcitm, int, 0); 39module_param(init_pcitm, int, 0);
41 40
42/* In this order: vendor, device, subvendor, subdevice, class, class_mask, 41/* In this order: vendor, device, subvendor, subdevice, class, class_mask,
43 * driver_data 42 * driver_data
44 * If you have an update for this please contact prism54-devel@prism54.org 43 * If you have an update for this please contact prism54-devel@prism54.org
45 * The latest list can be found at http://prism54.org/supported_cards.php */ 44 * The latest list can be found at http://prism54.org/supported_cards.php */
46static const struct pci_device_id prism54_id_tbl[] = { 45static const struct pci_device_id prism54_id_tbl[] = {
47 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */ 46 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
@@ -132,15 +131,15 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
132 131
133 /* 0x40 is the programmable timer to configure the response timeout (TRDY_TIMEOUT) 132 /* 0x40 is the programmable timer to configure the response timeout (TRDY_TIMEOUT)
134 * 0x41 is the programmable timer to configure the retry timeout (RETRY_TIMEOUT) 133 * 0x41 is the programmable timer to configure the retry timeout (RETRY_TIMEOUT)
135 * The RETRY_TIMEOUT is used to set the number of retries that the core, as a 134 * The RETRY_TIMEOUT is used to set the number of retries that the core, as a
136 * Master, will perform before abandoning a cycle. The default value for 135 * Master, will perform before abandoning a cycle. The default value for
137 * RETRY_TIMEOUT is 0x80, which far exceeds the PCI 2.1 requirement for new 136 * RETRY_TIMEOUT is 0x80, which far exceeds the PCI 2.1 requirement for new
138 * devices. A write of zero to the RETRY_TIMEOUT register disables this 137 * devices. A write of zero to the RETRY_TIMEOUT register disables this
139 * function to allow use with any non-compliant legacy devices that may 138 * function to allow use with any non-compliant legacy devices that may
140 * execute more retries. 139 * execute more retries.
141 * 140 *
142 * Writing zero to both these two registers will disable both timeouts and 141 * Writing zero to both these two registers will disable both timeouts and
143 * *can* solve problems caused by devices that are slow to respond. 142 * *can* solve problems caused by devices that are slow to respond.
144 * Make this configurable - MSW 143 * Make this configurable - MSW
145 */ 144 */
146 if ( init_pcitm >= 0 ) { 145 if ( init_pcitm >= 0 ) {
@@ -171,14 +170,15 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
171 pci_set_master(pdev); 170 pci_set_master(pdev);
172 171
173 /* enable MWI */ 172 /* enable MWI */
174 pci_set_mwi(pdev); 173 if (!pci_set_mwi(pdev))
174 printk(KERN_INFO "%s: pci_set_mwi(pdev) succeeded\n", DRV_NAME);
175 175
176 /* setup the network device interface and its structure */ 176 /* setup the network device interface and its structure */
177 if (!(ndev = islpci_setup(pdev))) { 177 if (!(ndev = islpci_setup(pdev))) {
178 /* error configuring the driver as a network device */ 178 /* error configuring the driver as a network device */
179 printk(KERN_ERR "%s: could not configure network device\n", 179 printk(KERN_ERR "%s: could not configure network device\n",
180 DRV_NAME); 180 DRV_NAME);
181 goto do_pci_release_regions; 181 goto do_pci_clear_mwi;
182 } 182 }
183 183
184 priv = netdev_priv(ndev); 184 priv = netdev_priv(ndev);
@@ -208,6 +208,8 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
208 pci_set_drvdata(pdev, NULL); 208 pci_set_drvdata(pdev, NULL);
209 free_netdev(ndev); 209 free_netdev(ndev);
210 priv = NULL; 210 priv = NULL;
211 do_pci_clear_mwi:
212 pci_clear_mwi(pdev);
211 do_pci_release_regions: 213 do_pci_release_regions:
212 pci_release_regions(pdev); 214 pci_release_regions(pdev);
213 do_pci_disable_device: 215 do_pci_disable_device:
@@ -241,7 +243,7 @@ prism54_remove(struct pci_dev *pdev)
241 isl38xx_disable_interrupts(priv->device_base); 243 isl38xx_disable_interrupts(priv->device_base);
242 islpci_set_state(priv, PRV_STATE_OFF); 244 islpci_set_state(priv, PRV_STATE_OFF);
243 /* This bellow causes a lockup at rmmod time. It might be 245 /* This bellow causes a lockup at rmmod time. It might be
244 * because some interrupts still linger after rmmod time, 246 * because some interrupts still linger after rmmod time,
245 * see bug #17 */ 247 * see bug #17 */
246 /* pci_set_power_state(pdev, 3);*/ /* try to power-off */ 248 /* pci_set_power_state(pdev, 3);*/ /* try to power-off */
247 } 249 }
@@ -255,6 +257,8 @@ prism54_remove(struct pci_dev *pdev)
255 free_netdev(ndev); 257 free_netdev(ndev);
256 priv = NULL; 258 priv = NULL;
257 259
260 pci_clear_mwi(pdev);
261
258 pci_release_regions(pdev); 262 pci_release_regions(pdev);
259 263
260 pci_disable_device(pdev); 264 pci_disable_device(pdev);
@@ -288,12 +292,19 @@ prism54_resume(struct pci_dev *pdev)
288{ 292{
289 struct net_device *ndev = pci_get_drvdata(pdev); 293 struct net_device *ndev = pci_get_drvdata(pdev);
290 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL; 294 islpci_private *priv = ndev ? netdev_priv(ndev) : NULL;
291 BUG_ON(!priv); 295 int err;
292 296
293 pci_enable_device(pdev); 297 BUG_ON(!priv);
294 298
295 printk(KERN_NOTICE "%s: got resume request\n", ndev->name); 299 printk(KERN_NOTICE "%s: got resume request\n", ndev->name);
296 300
301 err = pci_enable_device(pdev);
302 if (err) {
303 printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
304 ndev->name);
305 return err;
306 }
307
297 pci_restore_state(pdev); 308 pci_restore_state(pdev);
298 309
299 /* alright let's go into the PREBOOT state */ 310 /* alright let's go into the PREBOOT state */
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
index 656ec9fa7128..2246f7930b4e 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.c
+++ b/drivers/net/wireless/prism54/islpci_mgt.c
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright 2004 Jens Maurer <Jens.Maurer@gmx.net> 3 * Copyright 2004 Jens Maurer <Jens.Maurer@gmx.net>
5 * 4 *
@@ -502,7 +501,7 @@ islpci_mgt_transaction(struct net_device *ndev,
502 printk(KERN_WARNING "%s: timeout waiting for mgmt response\n", 501 printk(KERN_WARNING "%s: timeout waiting for mgmt response\n",
503 ndev->name); 502 ndev->name);
504 503
505 /* TODO: we should reset the device here */ 504 /* TODO: we should reset the device here */
506 out: 505 out:
507 finish_wait(&priv->mgmt_wqueue, &wait); 506 finish_wait(&priv->mgmt_wqueue, &wait);
508 up(&priv->mgmt_sem); 507 up(&priv->mgmt_sem);
diff --git a/drivers/net/wireless/prism54/islpci_mgt.h b/drivers/net/wireless/prism54/islpci_mgt.h
index 2982be3363ef..fc53b587b722 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.h
+++ b/drivers/net/wireless/prism54/islpci_mgt.h
@@ -1,5 +1,4 @@
1/* 1/*
2 *
3 * Copyright (C) 2002 Intersil Americas Inc. 2 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu> 3 * Copyright (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
5 * 4 *
@@ -36,8 +35,8 @@ extern int pc_debug;
36 35
37 36
38/* General driver definitions */ 37/* General driver definitions */
39#define PCIDEVICE_LATENCY_TIMER_MIN 0x40 38#define PCIDEVICE_LATENCY_TIMER_MIN 0x40
40#define PCIDEVICE_LATENCY_TIMER_VAL 0x50 39#define PCIDEVICE_LATENCY_TIMER_VAL 0x50
41 40
42/* Debugging verbose definitions */ 41/* Debugging verbose definitions */
43#define SHOW_NOTHING 0x00 /* overrules everything */ 42#define SHOW_NOTHING 0x00 /* overrules everything */
diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c
index ebb238785839..fbc52b6a3024 100644
--- a/drivers/net/wireless/prism54/oid_mgt.c
+++ b/drivers/net/wireless/prism54/oid_mgt.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2003,2004 Aurelien Alleaume <slts@free.fr> 2 * Copyright (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -503,7 +503,7 @@ mgt_set_varlen(islpci_private *priv, enum oid_num_t n, void *data, int extra_len
503 } 503 }
504 if (ret || response_op == PIMFOR_OP_ERROR) 504 if (ret || response_op == PIMFOR_OP_ERROR)
505 ret = -EIO; 505 ret = -EIO;
506 } else 506 } else
507 ret = -EIO; 507 ret = -EIO;
508 508
509 /* re-set given data to what it was */ 509 /* re-set given data to what it was */
@@ -727,7 +727,7 @@ mgt_commit(islpci_private *priv)
727 * MEDIUMLIMIT,BEACONPERIOD,DTIMPERIOD,ATIMWINDOW,LISTENINTERVAL 727 * MEDIUMLIMIT,BEACONPERIOD,DTIMPERIOD,ATIMWINDOW,LISTENINTERVAL
728 * FREQUENCY,EXTENDEDRATES. 728 * FREQUENCY,EXTENDEDRATES.
729 * 729 *
730 * The way to do this is to set ESSID. Note though that they may get 730 * The way to do this is to set ESSID. Note though that they may get
731 * unlatch before though by setting another OID. */ 731 * unlatch before though by setting another OID. */
732#if 0 732#if 0
733void 733void
diff --git a/drivers/net/wireless/prism54/prismcompat.h b/drivers/net/wireless/prism54/prismcompat.h
index d71eca55a302..aa1d1747784f 100644
--- a/drivers/net/wireless/prism54/prismcompat.h
+++ b/drivers/net/wireless/prism54/prismcompat.h
@@ -1,4 +1,4 @@
1/* 1/*
2 * (C) 2004 Margit Schubert-While <margitsw@t-online.de> 2 * (C) 2004 Margit Schubert-While <margitsw@t-online.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
@@ -16,7 +16,7 @@
16 * 16 *
17 */ 17 */
18 18
19/* 19/*
20 * Compatibility header file to aid support of different kernel versions 20 * Compatibility header file to aid support of different kernel versions
21 */ 21 */
22 22
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 36b29ff05814..6cb66a356c96 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -1828,10 +1828,8 @@ err_start:
1828 /* Leave the device in reset state */ 1828 /* Leave the device in reset state */
1829 zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0); 1829 zd1201_docmd(zd, ZD1201_CMDCODE_INIT, 0, 0, 0);
1830err_zd: 1830err_zd:
1831 if (zd->tx_urb) 1831 usb_free_urb(zd->tx_urb);
1832 usb_free_urb(zd->tx_urb); 1832 usb_free_urb(zd->rx_urb);
1833 if (zd->rx_urb)
1834 usb_free_urb(zd->rx_urb);
1835 kfree(zd); 1833 kfree(zd);
1836 return err; 1834 return err;
1837} 1835}
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index aa661b2b76c7..8be99ebbe1cd 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -1076,6 +1076,31 @@ static int set_mandatory_rates(struct zd_chip *chip, enum ieee80211_std std)
1076 return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL); 1076 return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL);
1077} 1077}
1078 1078
1079int zd_chip_set_rts_cts_rate_locked(struct zd_chip *chip,
1080 u8 rts_rate, int preamble)
1081{
1082 int rts_mod = ZD_RX_CCK;
1083 u32 value = 0;
1084
1085 /* Modulation bit */
1086 if (ZD_CS_TYPE(rts_rate) == ZD_CS_OFDM)
1087 rts_mod = ZD_RX_OFDM;
1088
1089 dev_dbg_f(zd_chip_dev(chip), "rts_rate=%x preamble=%x\n",
1090 rts_rate, preamble);
1091
1092 value |= rts_rate << RTSCTS_SH_RTS_RATE;
1093 value |= rts_mod << RTSCTS_SH_RTS_MOD_TYPE;
1094 value |= preamble << RTSCTS_SH_RTS_PMB_TYPE;
1095 value |= preamble << RTSCTS_SH_CTS_PMB_TYPE;
1096
1097 /* We always send 11M self-CTS messages, like the vendor driver. */
1098 value |= ZD_CCK_RATE_11M << RTSCTS_SH_CTS_RATE;
1099 value |= ZD_RX_CCK << RTSCTS_SH_CTS_MOD_TYPE;
1100
1101 return zd_iowrite32_locked(chip, value, CR_RTS_CTS_RATE);
1102}
1103
1079int zd_chip_enable_hwint(struct zd_chip *chip) 1104int zd_chip_enable_hwint(struct zd_chip *chip)
1080{ 1105{
1081 int r; 1106 int r;
@@ -1355,17 +1380,12 @@ out:
1355 return r; 1380 return r;
1356} 1381}
1357 1382
1358int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates) 1383int zd_chip_set_basic_rates_locked(struct zd_chip *chip, u16 cr_rates)
1359{ 1384{
1360 int r; 1385 ZD_ASSERT((cr_rates & ~(CR_RATES_80211B | CR_RATES_80211G)) == 0);
1361 1386 dev_dbg_f(zd_chip_dev(chip), "%x\n", cr_rates);
1362 if (cr_rates & ~(CR_RATES_80211B|CR_RATES_80211G))
1363 return -EINVAL;
1364 1387
1365 mutex_lock(&chip->mutex); 1388 return zd_iowrite32_locked(chip, cr_rates, CR_BASIC_RATE_TBL);
1366 r = zd_iowrite32_locked(chip, cr_rates, CR_BASIC_RATE_TBL);
1367 mutex_unlock(&chip->mutex);
1368 return r;
1369} 1389}
1370 1390
1371static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size) 1391static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size)
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index ae59597ce4e1..ca892b9a6448 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -337,24 +337,24 @@
337#define CR_MAC_PS_STATE CTL_REG(0x050C) 337#define CR_MAC_PS_STATE CTL_REG(0x050C)
338 338
339#define CR_INTERRUPT CTL_REG(0x0510) 339#define CR_INTERRUPT CTL_REG(0x0510)
340#define INT_TX_COMPLETE 0x00000001 340#define INT_TX_COMPLETE (1 << 0)
341#define INT_RX_COMPLETE 0x00000002 341#define INT_RX_COMPLETE (1 << 1)
342#define INT_RETRY_FAIL 0x00000004 342#define INT_RETRY_FAIL (1 << 2)
343#define INT_WAKEUP 0x00000008 343#define INT_WAKEUP (1 << 3)
344#define INT_DTIM_NOTIFY 0x00000020 344#define INT_DTIM_NOTIFY (1 << 5)
345#define INT_CFG_NEXT_BCN 0x00000040 345#define INT_CFG_NEXT_BCN (1 << 6)
346#define INT_BUS_ABORT 0x00000080 346#define INT_BUS_ABORT (1 << 7)
347#define INT_TX_FIFO_READY 0x00000100 347#define INT_TX_FIFO_READY (1 << 8)
348#define INT_UART 0x00000200 348#define INT_UART (1 << 9)
349#define INT_TX_COMPLETE_EN 0x00010000 349#define INT_TX_COMPLETE_EN (1 << 16)
350#define INT_RX_COMPLETE_EN 0x00020000 350#define INT_RX_COMPLETE_EN (1 << 17)
351#define INT_RETRY_FAIL_EN 0x00040000 351#define INT_RETRY_FAIL_EN (1 << 18)
352#define INT_WAKEUP_EN 0x00080000 352#define INT_WAKEUP_EN (1 << 19)
353#define INT_DTIM_NOTIFY_EN 0x00200000 353#define INT_DTIM_NOTIFY_EN (1 << 21)
354#define INT_CFG_NEXT_BCN_EN 0x00400000 354#define INT_CFG_NEXT_BCN_EN (1 << 22)
355#define INT_BUS_ABORT_EN 0x00800000 355#define INT_BUS_ABORT_EN (1 << 23)
356#define INT_TX_FIFO_READY_EN 0x01000000 356#define INT_TX_FIFO_READY_EN (1 << 24)
357#define INT_UART_EN 0x02000000 357#define INT_UART_EN (1 << 25)
358 358
359#define CR_TSF_LOW_PART CTL_REG(0x0514) 359#define CR_TSF_LOW_PART CTL_REG(0x0514)
360#define CR_TSF_HIGH_PART CTL_REG(0x0518) 360#define CR_TSF_HIGH_PART CTL_REG(0x0518)
@@ -398,18 +398,18 @@
398 * device will use a rate in this table that is less than or equal to the rate 398 * device will use a rate in this table that is less than or equal to the rate
399 * of the incoming frame which prompted the response */ 399 * of the incoming frame which prompted the response */
400#define CR_BASIC_RATE_TBL CTL_REG(0x0630) 400#define CR_BASIC_RATE_TBL CTL_REG(0x0630)
401#define CR_RATE_1M 0x0001 /* 802.11b */ 401#define CR_RATE_1M (1 << 0) /* 802.11b */
402#define CR_RATE_2M 0x0002 /* 802.11b */ 402#define CR_RATE_2M (1 << 1) /* 802.11b */
403#define CR_RATE_5_5M 0x0004 /* 802.11b */ 403#define CR_RATE_5_5M (1 << 2) /* 802.11b */
404#define CR_RATE_11M 0x0008 /* 802.11b */ 404#define CR_RATE_11M (1 << 3) /* 802.11b */
405#define CR_RATE_6M 0x0100 /* 802.11g */ 405#define CR_RATE_6M (1 << 8) /* 802.11g */
406#define CR_RATE_9M 0x0200 /* 802.11g */ 406#define CR_RATE_9M (1 << 9) /* 802.11g */
407#define CR_RATE_12M 0x0400 /* 802.11g */ 407#define CR_RATE_12M (1 << 10) /* 802.11g */
408#define CR_RATE_18M 0x0800 /* 802.11g */ 408#define CR_RATE_18M (1 << 11) /* 802.11g */
409#define CR_RATE_24M 0x1000 /* 802.11g */ 409#define CR_RATE_24M (1 << 12) /* 802.11g */
410#define CR_RATE_36M 0x2000 /* 802.11g */ 410#define CR_RATE_36M (1 << 13) /* 802.11g */
411#define CR_RATE_48M 0x4000 /* 802.11g */ 411#define CR_RATE_48M (1 << 14) /* 802.11g */
412#define CR_RATE_54M 0x8000 /* 802.11g */ 412#define CR_RATE_54M (1 << 15) /* 802.11g */
413#define CR_RATES_80211G 0xff00 413#define CR_RATES_80211G 0xff00
414#define CR_RATES_80211B 0x000f 414#define CR_RATES_80211B 0x000f
415 415
@@ -420,15 +420,24 @@
420#define CR_MANDATORY_RATE_TBL CTL_REG(0x0634) 420#define CR_MANDATORY_RATE_TBL CTL_REG(0x0634)
421#define CR_RTS_CTS_RATE CTL_REG(0x0638) 421#define CR_RTS_CTS_RATE CTL_REG(0x0638)
422 422
423/* These are all bit indexes in CR_RTS_CTS_RATE, so remember to shift. */
424#define RTSCTS_SH_RTS_RATE 0
425#define RTSCTS_SH_EXP_CTS_RATE 4
426#define RTSCTS_SH_RTS_MOD_TYPE 8
427#define RTSCTS_SH_RTS_PMB_TYPE 9
428#define RTSCTS_SH_CTS_RATE 16
429#define RTSCTS_SH_CTS_MOD_TYPE 24
430#define RTSCTS_SH_CTS_PMB_TYPE 25
431
423#define CR_WEP_PROTECT CTL_REG(0x063C) 432#define CR_WEP_PROTECT CTL_REG(0x063C)
424#define CR_RX_THRESHOLD CTL_REG(0x0640) 433#define CR_RX_THRESHOLD CTL_REG(0x0640)
425 434
426/* register for controlling the LEDS */ 435/* register for controlling the LEDS */
427#define CR_LED CTL_REG(0x0644) 436#define CR_LED CTL_REG(0x0644)
428/* masks for controlling LEDs */ 437/* masks for controlling LEDs */
429#define LED1 0x0100 438#define LED1 (1 << 8)
430#define LED2 0x0200 439#define LED2 (1 << 9)
431#define LED_SW 0x0400 440#define LED_SW (1 << 10)
432 441
433/* Seems to indicate that the configuration is over. 442/* Seems to indicate that the configuration is over.
434 */ 443 */
@@ -455,18 +464,18 @@
455 * registers, so one could argue it is a LOCK bit. But calling it 464 * registers, so one could argue it is a LOCK bit. But calling it
456 * LOCK_PHY_REGS makes it confusing. 465 * LOCK_PHY_REGS makes it confusing.
457 */ 466 */
458#define UNLOCK_PHY_REGS 0x0080 467#define UNLOCK_PHY_REGS (1 << 7)
459 468
460#define CR_DEVICE_STATE CTL_REG(0x0684) 469#define CR_DEVICE_STATE CTL_REG(0x0684)
461#define CR_UNDERRUN_CNT CTL_REG(0x0688) 470#define CR_UNDERRUN_CNT CTL_REG(0x0688)
462 471
463#define CR_RX_FILTER CTL_REG(0x068c) 472#define CR_RX_FILTER CTL_REG(0x068c)
464#define RX_FILTER_ASSOC_RESPONSE 0x0002 473#define RX_FILTER_ASSOC_RESPONSE (1 << 1)
465#define RX_FILTER_REASSOC_RESPONSE 0x0008 474#define RX_FILTER_REASSOC_RESPONSE (1 << 3)
466#define RX_FILTER_PROBE_RESPONSE 0x0020 475#define RX_FILTER_PROBE_RESPONSE (1 << 5)
467#define RX_FILTER_BEACON 0x0100 476#define RX_FILTER_BEACON (1 << 8)
468#define RX_FILTER_DISASSOC 0x0400 477#define RX_FILTER_DISASSOC (1 << 10)
469#define RX_FILTER_AUTH 0x0800 478#define RX_FILTER_AUTH (1 << 11)
470#define AP_RX_FILTER 0x0400feff 479#define AP_RX_FILTER 0x0400feff
471#define STA_RX_FILTER 0x0000ffff 480#define STA_RX_FILTER 0x0000ffff
472 481
@@ -794,6 +803,9 @@ void zd_chip_disable_rx(struct zd_chip *chip);
794int zd_chip_enable_hwint(struct zd_chip *chip); 803int zd_chip_enable_hwint(struct zd_chip *chip);
795int zd_chip_disable_hwint(struct zd_chip *chip); 804int zd_chip_disable_hwint(struct zd_chip *chip);
796 805
806int zd_chip_set_rts_cts_rate_locked(struct zd_chip *chip,
807 u8 rts_rate, int preamble);
808
797static inline int zd_get_encryption_type(struct zd_chip *chip, u32 *type) 809static inline int zd_get_encryption_type(struct zd_chip *chip, u32 *type)
798{ 810{
799 return zd_ioread32(chip, CR_ENCRYPTION_TYPE, type); 811 return zd_ioread32(chip, CR_ENCRYPTION_TYPE, type);
@@ -809,7 +821,17 @@ static inline int zd_chip_get_basic_rates(struct zd_chip *chip, u16 *cr_rates)
809 return zd_ioread16(chip, CR_BASIC_RATE_TBL, cr_rates); 821 return zd_ioread16(chip, CR_BASIC_RATE_TBL, cr_rates);
810} 822}
811 823
812int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates); 824int zd_chip_set_basic_rates_locked(struct zd_chip *chip, u16 cr_rates);
825
826static inline int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates)
827{
828 int r;
829
830 mutex_lock(&chip->mutex);
831 r = zd_chip_set_basic_rates_locked(chip, cr_rates);
832 mutex_unlock(&chip->mutex);
833 return r;
834}
813 835
814static inline int zd_chip_set_rx_filter(struct zd_chip *chip, u32 filter) 836static inline int zd_chip_set_rx_filter(struct zd_chip *chip, u32 filter)
815{ 837{
diff --git a/drivers/net/wireless/zd1211rw/zd_def.h b/drivers/net/wireless/zd1211rw/zd_def.h
index a13ec72eb304..fb22f62cf1f3 100644
--- a/drivers/net/wireless/zd1211rw/zd_def.h
+++ b/drivers/net/wireless/zd1211rw/zd_def.h
@@ -39,6 +39,7 @@ do { \
39 if (!(x)) { \ 39 if (!(x)) { \
40 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \ 40 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \
41 __FILE__, __LINE__, __stringify(x)); \ 41 __FILE__, __LINE__, __stringify(x)); \
42 dump_stack(); \
42 } \ 43 } \
43} while (0) 44} while (0)
44#else 45#else
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.c b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
index 66905f7b61ff..189160efd2ae 100644
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.c
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
@@ -37,7 +37,12 @@ static const struct channel_range channel_ranges[] = {
37 [ZD_REGDOMAIN_JAPAN] = { 1, 14}, 37 [ZD_REGDOMAIN_JAPAN] = { 1, 14},
38 [ZD_REGDOMAIN_SPAIN] = { 1, 14}, 38 [ZD_REGDOMAIN_SPAIN] = { 1, 14},
39 [ZD_REGDOMAIN_FRANCE] = { 1, 14}, 39 [ZD_REGDOMAIN_FRANCE] = { 1, 14},
40 [ZD_REGDOMAIN_JAPAN_ADD] = {14, 15}, 40
41 /* Japan originally only had channel 14 available (see CHNL_ID 0x40 in
42 * 802.11). However, in 2001 the range was extended to include channels
43 * 1-13. The ZyDAS devices still use the old region code but are
44 * designed to allow the extra channel access in Japan. */
45 [ZD_REGDOMAIN_JAPAN_ADD] = { 1, 15},
41}; 46};
42 47
43const struct channel_range *zd_channel_range(u8 regdomain) 48const struct channel_range *zd_channel_range(u8 regdomain)
@@ -133,9 +138,6 @@ int zd_find_channel(u8 *channel, const struct iw_freq *freq)
133 int i, r; 138 int i, r;
134 u32 mhz; 139 u32 mhz;
135 140
136 if (!(freq->flags & IW_FREQ_FIXED))
137 return 0;
138
139 if (freq->m < 1000) { 141 if (freq->m < 1000) {
140 if (freq->m > NUM_CHANNELS || freq->m == 0) 142 if (freq->m > NUM_CHANNELS || freq->m == 0)
141 return -EINVAL; 143 return -EINVAL;
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.h b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
index f63245b0d966..26b8298dff8c 100644
--- a/drivers/net/wireless/zd1211rw/zd_ieee80211.h
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
@@ -50,6 +50,7 @@ static inline u8 zd_ofdm_plcp_header_rate(
50 return header->prefix[0] & 0xf; 50 return header->prefix[0] & 0xf;
51} 51}
52 52
53/* These are referred to as zd_rates */
53#define ZD_OFDM_RATE_6M 0xb 54#define ZD_OFDM_RATE_6M 0xb
54#define ZD_OFDM_RATE_9M 0xf 55#define ZD_OFDM_RATE_9M 0xf
55#define ZD_OFDM_RATE_12M 0xa 56#define ZD_OFDM_RATE_12M 0xa
@@ -64,7 +65,7 @@ struct cck_plcp_header {
64 u8 service; 65 u8 service;
65 __le16 length; 66 __le16 length;
66 __le16 crc16; 67 __le16 crc16;
67}; 68} __attribute__((packed));
68 69
69static inline u8 zd_cck_plcp_header_rate(const struct cck_plcp_header *header) 70static inline u8 zd_cck_plcp_header_rate(const struct cck_plcp_header *header)
70{ 71{
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 5e4f4b707375..44f3cfd4cc1d 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -32,6 +32,8 @@
32 32
33static void ieee_init(struct ieee80211_device *ieee); 33static void ieee_init(struct ieee80211_device *ieee);
34static void softmac_init(struct ieee80211softmac_device *sm); 34static void softmac_init(struct ieee80211softmac_device *sm);
35static void set_rts_cts_work(void *d);
36static void set_basic_rates_work(void *d);
35 37
36static void housekeeping_init(struct zd_mac *mac); 38static void housekeeping_init(struct zd_mac *mac);
37static void housekeeping_enable(struct zd_mac *mac); 39static void housekeeping_enable(struct zd_mac *mac);
@@ -46,6 +48,8 @@ int zd_mac_init(struct zd_mac *mac,
46 memset(mac, 0, sizeof(*mac)); 48 memset(mac, 0, sizeof(*mac));
47 spin_lock_init(&mac->lock); 49 spin_lock_init(&mac->lock);
48 mac->netdev = netdev; 50 mac->netdev = netdev;
51 INIT_WORK(&mac->set_rts_cts_work, set_rts_cts_work, mac);
52 INIT_WORK(&mac->set_basic_rates_work, set_basic_rates_work, mac);
49 53
50 ieee_init(ieee); 54 ieee_init(ieee);
51 softmac_init(ieee80211_priv(netdev)); 55 softmac_init(ieee80211_priv(netdev));
@@ -213,6 +217,13 @@ int zd_mac_stop(struct net_device *netdev)
213 housekeeping_disable(mac); 217 housekeeping_disable(mac);
214 ieee80211softmac_stop(netdev); 218 ieee80211softmac_stop(netdev);
215 219
220 /* Ensure no work items are running or queued from this point */
221 cancel_delayed_work(&mac->set_rts_cts_work);
222 cancel_delayed_work(&mac->set_basic_rates_work);
223 flush_workqueue(zd_workqueue);
224 mac->updating_rts_rate = 0;
225 mac->updating_basic_rates = 0;
226
216 zd_chip_disable_hwint(chip); 227 zd_chip_disable_hwint(chip);
217 zd_chip_switch_radio_off(chip); 228 zd_chip_switch_radio_off(chip);
218 zd_chip_disable_int(chip); 229 zd_chip_disable_int(chip);
@@ -286,6 +297,186 @@ u8 zd_mac_get_regdomain(struct zd_mac *mac)
286 return regdomain; 297 return regdomain;
287} 298}
288 299
300/* Fallback to lowest rate, if rate is unknown. */
301static u8 rate_to_zd_rate(u8 rate)
302{
303 switch (rate) {
304 case IEEE80211_CCK_RATE_2MB:
305 return ZD_CCK_RATE_2M;
306 case IEEE80211_CCK_RATE_5MB:
307 return ZD_CCK_RATE_5_5M;
308 case IEEE80211_CCK_RATE_11MB:
309 return ZD_CCK_RATE_11M;
310 case IEEE80211_OFDM_RATE_6MB:
311 return ZD_OFDM_RATE_6M;
312 case IEEE80211_OFDM_RATE_9MB:
313 return ZD_OFDM_RATE_9M;
314 case IEEE80211_OFDM_RATE_12MB:
315 return ZD_OFDM_RATE_12M;
316 case IEEE80211_OFDM_RATE_18MB:
317 return ZD_OFDM_RATE_18M;
318 case IEEE80211_OFDM_RATE_24MB:
319 return ZD_OFDM_RATE_24M;
320 case IEEE80211_OFDM_RATE_36MB:
321 return ZD_OFDM_RATE_36M;
322 case IEEE80211_OFDM_RATE_48MB:
323 return ZD_OFDM_RATE_48M;
324 case IEEE80211_OFDM_RATE_54MB:
325 return ZD_OFDM_RATE_54M;
326 }
327 return ZD_CCK_RATE_1M;
328}
329
330static u16 rate_to_cr_rate(u8 rate)
331{
332 switch (rate) {
333 case IEEE80211_CCK_RATE_2MB:
334 return CR_RATE_1M;
335 case IEEE80211_CCK_RATE_5MB:
336 return CR_RATE_5_5M;
337 case IEEE80211_CCK_RATE_11MB:
338 return CR_RATE_11M;
339 case IEEE80211_OFDM_RATE_6MB:
340 return CR_RATE_6M;
341 case IEEE80211_OFDM_RATE_9MB:
342 return CR_RATE_9M;
343 case IEEE80211_OFDM_RATE_12MB:
344 return CR_RATE_12M;
345 case IEEE80211_OFDM_RATE_18MB:
346 return CR_RATE_18M;
347 case IEEE80211_OFDM_RATE_24MB:
348 return CR_RATE_24M;
349 case IEEE80211_OFDM_RATE_36MB:
350 return CR_RATE_36M;
351 case IEEE80211_OFDM_RATE_48MB:
352 return CR_RATE_48M;
353 case IEEE80211_OFDM_RATE_54MB:
354 return CR_RATE_54M;
355 }
356 return CR_RATE_1M;
357}
358
359static void try_enable_tx(struct zd_mac *mac)
360{
361 unsigned long flags;
362
363 spin_lock_irqsave(&mac->lock, flags);
364 if (mac->updating_rts_rate == 0 && mac->updating_basic_rates == 0)
365 netif_wake_queue(mac->netdev);
366 spin_unlock_irqrestore(&mac->lock, flags);
367}
368
369static void set_rts_cts_work(void *d)
370{
371 struct zd_mac *mac = d;
372 unsigned long flags;
373 u8 rts_rate;
374 unsigned int short_preamble;
375
376 mutex_lock(&mac->chip.mutex);
377
378 spin_lock_irqsave(&mac->lock, flags);
379 mac->updating_rts_rate = 0;
380 rts_rate = mac->rts_rate;
381 short_preamble = mac->short_preamble;
382 spin_unlock_irqrestore(&mac->lock, flags);
383
384 zd_chip_set_rts_cts_rate_locked(&mac->chip, rts_rate, short_preamble);
385 mutex_unlock(&mac->chip.mutex);
386
387 try_enable_tx(mac);
388}
389
390static void set_basic_rates_work(void *d)
391{
392 struct zd_mac *mac = d;
393 unsigned long flags;
394 u16 basic_rates;
395
396 mutex_lock(&mac->chip.mutex);
397
398 spin_lock_irqsave(&mac->lock, flags);
399 mac->updating_basic_rates = 0;
400 basic_rates = mac->basic_rates;
401 spin_unlock_irqrestore(&mac->lock, flags);
402
403 zd_chip_set_basic_rates_locked(&mac->chip, basic_rates);
404 mutex_unlock(&mac->chip.mutex);
405
406 try_enable_tx(mac);
407}
408
409static void bssinfo_change(struct net_device *netdev, u32 changes)
410{
411 struct zd_mac *mac = zd_netdev_mac(netdev);
412 struct ieee80211softmac_device *softmac = ieee80211_priv(netdev);
413 struct ieee80211softmac_bss_info *bssinfo = &softmac->bssinfo;
414 int need_set_rts_cts = 0;
415 int need_set_rates = 0;
416 u16 basic_rates;
417 unsigned long flags;
418
419 dev_dbg_f(zd_mac_dev(mac), "changes: %x\n", changes);
420
421 if (changes & IEEE80211SOFTMAC_BSSINFOCHG_SHORT_PREAMBLE) {
422 spin_lock_irqsave(&mac->lock, flags);
423 mac->short_preamble = bssinfo->short_preamble;
424 spin_unlock_irqrestore(&mac->lock, flags);
425 need_set_rts_cts = 1;
426 }
427
428 if (changes & IEEE80211SOFTMAC_BSSINFOCHG_RATES) {
429 /* Set RTS rate to highest available basic rate */
430 u8 rate = ieee80211softmac_highest_supported_rate(softmac,
431 &bssinfo->supported_rates, 1);
432 rate = rate_to_zd_rate(rate);
433
434 spin_lock_irqsave(&mac->lock, flags);
435 if (rate != mac->rts_rate) {
436 mac->rts_rate = rate;
437 need_set_rts_cts = 1;
438 }
439 spin_unlock_irqrestore(&mac->lock, flags);
440
441 /* Set basic rates */
442 need_set_rates = 1;
443 if (bssinfo->supported_rates.count == 0) {
444 /* Allow the device to be flexible */
445 basic_rates = CR_RATES_80211B | CR_RATES_80211G;
446 } else {
447 int i = 0;
448 basic_rates = 0;
449
450 for (i = 0; i < bssinfo->supported_rates.count; i++) {
451 u16 rate = bssinfo->supported_rates.rates[i];
452 if ((rate & IEEE80211_BASIC_RATE_MASK) == 0)
453 continue;
454
455 rate &= ~IEEE80211_BASIC_RATE_MASK;
456 basic_rates |= rate_to_cr_rate(rate);
457 }
458 }
459 spin_lock_irqsave(&mac->lock, flags);
460 mac->basic_rates = basic_rates;
461 spin_unlock_irqrestore(&mac->lock, flags);
462 }
463
464 /* Schedule any changes we made above */
465
466 spin_lock_irqsave(&mac->lock, flags);
467 if (need_set_rts_cts && !mac->updating_rts_rate) {
468 mac->updating_rts_rate = 1;
469 netif_stop_queue(mac->netdev);
470 queue_work(zd_workqueue, &mac->set_rts_cts_work);
471 }
472 if (need_set_rates && !mac->updating_basic_rates) {
473 mac->updating_basic_rates = 1;
474 netif_stop_queue(mac->netdev);
475 queue_work(zd_workqueue, &mac->set_basic_rates_work);
476 }
477 spin_unlock_irqrestore(&mac->lock, flags);
478}
479
289static void set_channel(struct net_device *netdev, u8 channel) 480static void set_channel(struct net_device *netdev, u8 channel)
290{ 481{
291 struct zd_mac *mac = zd_netdev_mac(netdev); 482 struct zd_mac *mac = zd_netdev_mac(netdev);
@@ -295,7 +486,6 @@ static void set_channel(struct net_device *netdev, u8 channel)
295 zd_chip_set_channel(&mac->chip, channel); 486 zd_chip_set_channel(&mac->chip, channel);
296} 487}
297 488
298/* TODO: Should not work in Managed mode. */
299int zd_mac_request_channel(struct zd_mac *mac, u8 channel) 489int zd_mac_request_channel(struct zd_mac *mac, u8 channel)
300{ 490{
301 unsigned long lock_flags; 491 unsigned long lock_flags;
@@ -317,31 +507,22 @@ int zd_mac_request_channel(struct zd_mac *mac, u8 channel)
317 return 0; 507 return 0;
318} 508}
319 509
320int zd_mac_get_channel(struct zd_mac *mac, u8 *channel, u8 *flags) 510u8 zd_mac_get_channel(struct zd_mac *mac)
321{ 511{
322 struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac); 512 u8 channel = zd_chip_get_channel(&mac->chip);
323 513
324 *channel = zd_chip_get_channel(&mac->chip); 514 dev_dbg_f(zd_mac_dev(mac), "channel %u\n", channel);
325 if (ieee->iw_mode != IW_MODE_INFRA) { 515 return channel;
326 spin_lock_irq(&mac->lock);
327 *flags = *channel == mac->requested_channel ?
328 MAC_FIXED_CHANNEL : 0;
329 spin_unlock(&mac->lock);
330 } else {
331 *flags = 0;
332 }
333 dev_dbg_f(zd_mac_dev(mac), "channel %u flags %u\n", *channel, *flags);
334 return 0;
335} 516}
336 517
337/* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */ 518/* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */
338static u8 cs_typed_rate(u8 cs_rate) 519static u8 zd_rate_typed(u8 zd_rate)
339{ 520{
340 static const u8 typed_rates[16] = { 521 static const u8 typed_rates[16] = {
341 [ZD_CS_CCK_RATE_1M] = ZD_CS_CCK|ZD_CS_CCK_RATE_1M, 522 [ZD_CCK_RATE_1M] = ZD_CS_CCK|ZD_CCK_RATE_1M,
342 [ZD_CS_CCK_RATE_2M] = ZD_CS_CCK|ZD_CS_CCK_RATE_2M, 523 [ZD_CCK_RATE_2M] = ZD_CS_CCK|ZD_CCK_RATE_2M,
343 [ZD_CS_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CS_CCK_RATE_5_5M, 524 [ZD_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CCK_RATE_5_5M,
344 [ZD_CS_CCK_RATE_11M] = ZD_CS_CCK|ZD_CS_CCK_RATE_11M, 525 [ZD_CCK_RATE_11M] = ZD_CS_CCK|ZD_CCK_RATE_11M,
345 [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M, 526 [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M,
346 [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M, 527 [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M,
347 [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M, 528 [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M,
@@ -353,37 +534,7 @@ static u8 cs_typed_rate(u8 cs_rate)
353 }; 534 };
354 535
355 ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f); 536 ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f);
356 return typed_rates[cs_rate & ZD_CS_RATE_MASK]; 537 return typed_rates[zd_rate & ZD_CS_RATE_MASK];
357}
358
359/* Fallback to lowest rate, if rate is unknown. */
360static u8 rate_to_cs_rate(u8 rate)
361{
362 switch (rate) {
363 case IEEE80211_CCK_RATE_2MB:
364 return ZD_CS_CCK_RATE_2M;
365 case IEEE80211_CCK_RATE_5MB:
366 return ZD_CS_CCK_RATE_5_5M;
367 case IEEE80211_CCK_RATE_11MB:
368 return ZD_CS_CCK_RATE_11M;
369 case IEEE80211_OFDM_RATE_6MB:
370 return ZD_OFDM_RATE_6M;
371 case IEEE80211_OFDM_RATE_9MB:
372 return ZD_OFDM_RATE_9M;
373 case IEEE80211_OFDM_RATE_12MB:
374 return ZD_OFDM_RATE_12M;
375 case IEEE80211_OFDM_RATE_18MB:
376 return ZD_OFDM_RATE_18M;
377 case IEEE80211_OFDM_RATE_24MB:
378 return ZD_OFDM_RATE_24M;
379 case IEEE80211_OFDM_RATE_36MB:
380 return ZD_OFDM_RATE_36M;
381 case IEEE80211_OFDM_RATE_48MB:
382 return ZD_OFDM_RATE_48M;
383 case IEEE80211_OFDM_RATE_54MB:
384 return ZD_OFDM_RATE_54M;
385 }
386 return ZD_CS_CCK_RATE_1M;
387} 538}
388 539
389int zd_mac_set_mode(struct zd_mac *mac, u32 mode) 540int zd_mac_set_mode(struct zd_mac *mac, u32 mode)
@@ -484,13 +635,13 @@ int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range)
484 return 0; 635 return 0;
485} 636}
486 637
487static int zd_calc_tx_length_us(u8 *service, u8 cs_rate, u16 tx_length) 638static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length)
488{ 639{
489 static const u8 rate_divisor[] = { 640 static const u8 rate_divisor[] = {
490 [ZD_CS_CCK_RATE_1M] = 1, 641 [ZD_CCK_RATE_1M] = 1,
491 [ZD_CS_CCK_RATE_2M] = 2, 642 [ZD_CCK_RATE_2M] = 2,
492 [ZD_CS_CCK_RATE_5_5M] = 11, /* bits must be doubled */ 643 [ZD_CCK_RATE_5_5M] = 11, /* bits must be doubled */
493 [ZD_CS_CCK_RATE_11M] = 11, 644 [ZD_CCK_RATE_11M] = 11,
494 [ZD_OFDM_RATE_6M] = 6, 645 [ZD_OFDM_RATE_6M] = 6,
495 [ZD_OFDM_RATE_9M] = 9, 646 [ZD_OFDM_RATE_9M] = 9,
496 [ZD_OFDM_RATE_12M] = 12, 647 [ZD_OFDM_RATE_12M] = 12,
@@ -504,15 +655,15 @@ static int zd_calc_tx_length_us(u8 *service, u8 cs_rate, u16 tx_length)
504 u32 bits = (u32)tx_length * 8; 655 u32 bits = (u32)tx_length * 8;
505 u32 divisor; 656 u32 divisor;
506 657
507 divisor = rate_divisor[cs_rate]; 658 divisor = rate_divisor[zd_rate];
508 if (divisor == 0) 659 if (divisor == 0)
509 return -EINVAL; 660 return -EINVAL;
510 661
511 switch (cs_rate) { 662 switch (zd_rate) {
512 case ZD_CS_CCK_RATE_5_5M: 663 case ZD_CCK_RATE_5_5M:
513 bits = (2*bits) + 10; /* round up to the next integer */ 664 bits = (2*bits) + 10; /* round up to the next integer */
514 break; 665 break;
515 case ZD_CS_CCK_RATE_11M: 666 case ZD_CCK_RATE_11M:
516 if (service) { 667 if (service) {
517 u32 t = bits % 11; 668 u32 t = bits % 11;
518 *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION; 669 *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION;
@@ -532,16 +683,16 @@ enum {
532 R2M_11A = 0x02, 683 R2M_11A = 0x02,
533}; 684};
534 685
535static u8 cs_rate_to_modulation(u8 cs_rate, int flags) 686static u8 zd_rate_to_modulation(u8 zd_rate, int flags)
536{ 687{
537 u8 modulation; 688 u8 modulation;
538 689
539 modulation = cs_typed_rate(cs_rate); 690 modulation = zd_rate_typed(zd_rate);
540 if (flags & R2M_SHORT_PREAMBLE) { 691 if (flags & R2M_SHORT_PREAMBLE) {
541 switch (ZD_CS_RATE(modulation)) { 692 switch (ZD_CS_RATE(modulation)) {
542 case ZD_CS_CCK_RATE_2M: 693 case ZD_CCK_RATE_2M:
543 case ZD_CS_CCK_RATE_5_5M: 694 case ZD_CCK_RATE_5_5M:
544 case ZD_CS_CCK_RATE_11M: 695 case ZD_CCK_RATE_11M:
545 modulation |= ZD_CS_CCK_PREA_SHORT; 696 modulation |= ZD_CS_CCK_PREA_SHORT;
546 return modulation; 697 return modulation;
547 } 698 }
@@ -558,39 +709,36 @@ static void cs_set_modulation(struct zd_mac *mac, struct zd_ctrlset *cs,
558{ 709{
559 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev); 710 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev);
560 u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl)); 711 u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl));
561 u8 rate, cs_rate; 712 u8 rate, zd_rate;
562 int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0; 713 int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0;
714 int is_multicast = is_multicast_ether_addr(hdr->addr1);
715 int short_preamble = ieee80211softmac_short_preamble_ok(softmac,
716 is_multicast, is_mgt);
717 int flags = 0;
718
719 /* FIXME: 802.11a? */
720 rate = ieee80211softmac_suggest_txrate(softmac, is_multicast, is_mgt);
563 721
564 /* FIXME: 802.11a? short preamble? */ 722 if (short_preamble)
565 rate = ieee80211softmac_suggest_txrate(softmac, 723 flags |= R2M_SHORT_PREAMBLE;
566 is_multicast_ether_addr(hdr->addr1), is_mgt);
567 724
568 cs_rate = rate_to_cs_rate(rate); 725 zd_rate = rate_to_zd_rate(rate);
569 cs->modulation = cs_rate_to_modulation(cs_rate, 0); 726 cs->modulation = zd_rate_to_modulation(zd_rate, flags);
570} 727}
571 728
572static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, 729static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
573 struct ieee80211_hdr_4addr *header) 730 struct ieee80211_hdr_4addr *header)
574{ 731{
732 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev);
575 unsigned int tx_length = le16_to_cpu(cs->tx_length); 733 unsigned int tx_length = le16_to_cpu(cs->tx_length);
576 u16 fctl = le16_to_cpu(header->frame_ctl); 734 u16 fctl = le16_to_cpu(header->frame_ctl);
577 u16 ftype = WLAN_FC_GET_TYPE(fctl); 735 u16 ftype = WLAN_FC_GET_TYPE(fctl);
578 u16 stype = WLAN_FC_GET_STYPE(fctl); 736 u16 stype = WLAN_FC_GET_STYPE(fctl);
579 737
580 /* 738 /*
581 * CONTROL: 739 * CONTROL TODO:
582 * - start at 0x00
583 * - if fragment 0, enable bit 0
584 * - if backoff needed, enable bit 0 740 * - if backoff needed, enable bit 0
585 * - if burst (backoff not needed) disable bit 0 741 * - if burst (backoff not needed) disable bit 0
586 * - if multicast, enable bit 1
587 * - if PS-POLL frame, enable bit 2
588 * - if in INDEPENDENT_BSS mode and zd1205_DestPowerSave, then enable
589 * bit 4 (FIXME: wtf)
590 * - if frag_len > RTS threshold, set bit 5 as long if it isnt
591 * multicast or mgt
592 * - if bit 5 is set, and we are in OFDM mode, unset bit 5 and set bit
593 * 7
594 */ 742 */
595 743
596 cs->control = 0; 744 cs->control = 0;
@@ -607,17 +755,18 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
607 if (stype == IEEE80211_STYPE_PSPOLL) 755 if (stype == IEEE80211_STYPE_PSPOLL)
608 cs->control |= ZD_CS_PS_POLL_FRAME; 756 cs->control |= ZD_CS_PS_POLL_FRAME;
609 757
758 /* Unicast data frames over the threshold should have RTS */
610 if (!is_multicast_ether_addr(header->addr1) && 759 if (!is_multicast_ether_addr(header->addr1) &&
611 ftype != IEEE80211_FTYPE_MGMT && 760 ftype != IEEE80211_FTYPE_MGMT &&
612 tx_length > zd_netdev_ieee80211(mac->netdev)->rts) 761 tx_length > zd_netdev_ieee80211(mac->netdev)->rts)
613 { 762 cs->control |= ZD_CS_RTS;
614 /* FIXME: check the logic */ 763
615 if (ZD_CS_TYPE(cs->modulation) == ZD_CS_OFDM) { 764 /* Use CTS-to-self protection if required */
616 /* 802.11g */ 765 if (ZD_CS_TYPE(cs->modulation) == ZD_CS_OFDM &&
617 cs->control |= ZD_CS_SELF_CTS; 766 ieee80211softmac_protection_needed(softmac)) {
618 } else { /* 802.11b */ 767 /* FIXME: avoid sending RTS *and* self-CTS, is that correct? */
619 cs->control |= ZD_CS_RTS; 768 cs->control &= ~ZD_CS_RTS;
620 } 769 cs->control |= ZD_CS_SELF_CTS;
621 } 770 }
622 771
623 /* FIXME: Management frame? */ 772 /* FIXME: Management frame? */
@@ -721,7 +870,7 @@ struct zd_rt_hdr {
721 u8 rt_rate; 870 u8 rt_rate;
722 u16 rt_channel; 871 u16 rt_channel;
723 u16 rt_chbitmask; 872 u16 rt_chbitmask;
724}; 873} __attribute__((packed));
725 874
726static void fill_rt_header(void *buffer, struct zd_mac *mac, 875static void fill_rt_header(void *buffer, struct zd_mac *mac,
727 const struct ieee80211_rx_stats *stats, 876 const struct ieee80211_rx_stats *stats,
@@ -782,9 +931,11 @@ static int is_data_packet_for_us(struct ieee80211_device *ieee,
782 (netdev->flags & IFF_PROMISC); 931 (netdev->flags & IFF_PROMISC);
783} 932}
784 933
785/* Filters receiving packets. If it returns 1 send it to ieee80211_rx, if 0 934/* Filters received packets. The function returns 1 if the packet should be
786 * return. If an error is detected -EINVAL is returned. ieee80211_rx_mgt() is 935 * forwarded to ieee80211_rx(). If the packet should be ignored the function
787 * called here. 936 * returns 0. If an invalid packet is found the function returns -EINVAL.
937 *
938 * The function calls ieee80211_rx_mgt() directly.
788 * 939 *
789 * It has been based on ieee80211_rx_any. 940 * It has been based on ieee80211_rx_any.
790 */ 941 */
@@ -810,9 +961,9 @@ static int filter_rx(struct ieee80211_device *ieee,
810 ieee80211_rx_mgt(ieee, hdr, stats); 961 ieee80211_rx_mgt(ieee, hdr, stats);
811 return 0; 962 return 0;
812 case IEEE80211_FTYPE_CTL: 963 case IEEE80211_FTYPE_CTL:
813 /* Ignore invalid short buffers */
814 return 0; 964 return 0;
815 case IEEE80211_FTYPE_DATA: 965 case IEEE80211_FTYPE_DATA:
966 /* Ignore invalid short buffers */
816 if (length < sizeof(struct ieee80211_hdr_3addr)) 967 if (length < sizeof(struct ieee80211_hdr_3addr))
817 return -EINVAL; 968 return -EINVAL;
818 return is_data_packet_for_us(ieee, hdr); 969 return is_data_packet_for_us(ieee, hdr);
@@ -993,6 +1144,7 @@ static void ieee_init(struct ieee80211_device *ieee)
993static void softmac_init(struct ieee80211softmac_device *sm) 1144static void softmac_init(struct ieee80211softmac_device *sm)
994{ 1145{
995 sm->set_channel = set_channel; 1146 sm->set_channel = set_channel;
1147 sm->bssinfo_change = bssinfo_change;
996} 1148}
997 1149
998struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev) 1150struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev)
@@ -1028,66 +1180,6 @@ struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev)
1028 return iw_stats; 1180 return iw_stats;
1029} 1181}
1030 1182
1031#ifdef DEBUG
1032static const char* decryption_types[] = {
1033 [ZD_RX_NO_WEP] = "none",
1034 [ZD_RX_WEP64] = "WEP64",
1035 [ZD_RX_TKIP] = "TKIP",
1036 [ZD_RX_AES] = "AES",
1037 [ZD_RX_WEP128] = "WEP128",
1038 [ZD_RX_WEP256] = "WEP256",
1039};
1040
1041static const char *decryption_type_string(u8 type)
1042{
1043 const char *s;
1044
1045 if (type < ARRAY_SIZE(decryption_types)) {
1046 s = decryption_types[type];
1047 } else {
1048 s = NULL;
1049 }
1050 return s ? s : "unknown";
1051}
1052
1053static int is_ofdm(u8 frame_status)
1054{
1055 return (frame_status & ZD_RX_OFDM);
1056}
1057
1058void zd_dump_rx_status(const struct rx_status *status)
1059{
1060 const char* modulation;
1061 u8 quality;
1062
1063 if (is_ofdm(status->frame_status)) {
1064 modulation = "ofdm";
1065 quality = status->signal_quality_ofdm;
1066 } else {
1067 modulation = "cck";
1068 quality = status->signal_quality_cck;
1069 }
1070 pr_debug("rx status %s strength %#04x qual %#04x decryption %s\n",
1071 modulation, status->signal_strength, quality,
1072 decryption_type_string(status->decryption_type));
1073 if (status->frame_status & ZD_RX_ERROR) {
1074 pr_debug("rx error %s%s%s%s%s%s\n",
1075 (status->frame_status & ZD_RX_TIMEOUT_ERROR) ?
1076 "timeout " : "",
1077 (status->frame_status & ZD_RX_FIFO_OVERRUN_ERROR) ?
1078 "fifo " : "",
1079 (status->frame_status & ZD_RX_DECRYPTION_ERROR) ?
1080 "decryption " : "",
1081 (status->frame_status & ZD_RX_CRC32_ERROR) ?
1082 "crc32 " : "",
1083 (status->frame_status & ZD_RX_NO_ADDR1_MATCH_ERROR) ?
1084 "addr1 " : "",
1085 (status->frame_status & ZD_RX_CRC16_ERROR) ?
1086 "crc16" : "");
1087 }
1088}
1089#endif /* DEBUG */
1090
1091#define LINK_LED_WORK_DELAY HZ 1183#define LINK_LED_WORK_DELAY HZ
1092 1184
1093static void link_led_handler(struct work_struct *work) 1185static void link_led_handler(struct work_struct *work)
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 7957cac3de25..08d6b8c08e75 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -20,6 +20,7 @@
20 20
21#include <linux/wireless.h> 21#include <linux/wireless.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/workqueue.h>
23#include <net/ieee80211.h> 24#include <net/ieee80211.h>
24#include <net/ieee80211softmac.h> 25#include <net/ieee80211softmac.h>
25 26
@@ -48,10 +49,11 @@ struct zd_ctrlset {
48#define ZD_CS_CCK 0x00 49#define ZD_CS_CCK 0x00
49#define ZD_CS_OFDM 0x10 50#define ZD_CS_OFDM 0x10
50 51
51#define ZD_CS_CCK_RATE_1M 0x00 52/* These are referred to as zd_rates */
52#define ZD_CS_CCK_RATE_2M 0x01 53#define ZD_CCK_RATE_1M 0x00
53#define ZD_CS_CCK_RATE_5_5M 0x02 54#define ZD_CCK_RATE_2M 0x01
54#define ZD_CS_CCK_RATE_11M 0x03 55#define ZD_CCK_RATE_5_5M 0x02
56#define ZD_CCK_RATE_11M 0x03
55/* The rates for OFDM are encoded as in the PLCP header. Use ZD_OFDM_RATE_*. 57/* The rates for OFDM are encoded as in the PLCP header. Use ZD_OFDM_RATE_*.
56 */ 58 */
57 59
@@ -82,7 +84,7 @@ struct zd_ctrlset {
82struct rx_length_info { 84struct rx_length_info {
83 __le16 length[3]; 85 __le16 length[3];
84 __le16 tag; 86 __le16 tag;
85}; 87} __attribute__((packed));
86 88
87#define RX_LENGTH_INFO_TAG 0x697e 89#define RX_LENGTH_INFO_TAG 0x697e
88 90
@@ -93,7 +95,7 @@ struct rx_status {
93 u8 signal_quality_ofdm; 95 u8 signal_quality_ofdm;
94 u8 decryption_type; 96 u8 decryption_type;
95 u8 frame_status; 97 u8 frame_status;
96}; 98} __attribute__((packed));
97 99
98/* rx_status field decryption_type */ 100/* rx_status field decryption_type */
99#define ZD_RX_NO_WEP 0 101#define ZD_RX_NO_WEP 0
@@ -116,10 +118,6 @@ struct rx_status {
116#define ZD_RX_CRC16_ERROR 0x40 118#define ZD_RX_CRC16_ERROR 0x40
117#define ZD_RX_ERROR 0x80 119#define ZD_RX_ERROR 0x80
118 120
119enum mac_flags {
120 MAC_FIXED_CHANNEL = 0x01,
121};
122
123struct housekeeping { 121struct housekeeping {
124 struct delayed_work link_led_work; 122 struct delayed_work link_led_work;
125}; 123};
@@ -130,15 +128,33 @@ struct zd_mac {
130 struct zd_chip chip; 128 struct zd_chip chip;
131 spinlock_t lock; 129 spinlock_t lock;
132 struct net_device *netdev; 130 struct net_device *netdev;
131
133 /* Unlocked reading possible */ 132 /* Unlocked reading possible */
134 struct iw_statistics iw_stats; 133 struct iw_statistics iw_stats;
134
135 struct housekeeping housekeeping; 135 struct housekeeping housekeeping;
136 struct work_struct set_rts_cts_work;
137 struct work_struct set_basic_rates_work;
138
136 unsigned int stats_count; 139 unsigned int stats_count;
137 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 140 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE];
138 u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 141 u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE];
139 u8 regdomain; 142 u8 regdomain;
140 u8 default_regdomain; 143 u8 default_regdomain;
141 u8 requested_channel; 144 u8 requested_channel;
145
146 /* A bitpattern of cr_rates */
147 u16 basic_rates;
148
149 /* A zd_rate */
150 u8 rts_rate;
151
152 /* Short preamble (used for RTS/CTS) */
153 unsigned int short_preamble:1;
154
155 /* flags to indicate update in progress */
156 unsigned int updating_rts_rate:1;
157 unsigned int updating_basic_rates:1;
142}; 158};
143 159
144static inline struct ieee80211_device *zd_mac_to_ieee80211(struct zd_mac *mac) 160static inline struct ieee80211_device *zd_mac_to_ieee80211(struct zd_mac *mac)
@@ -180,7 +196,7 @@ int zd_mac_set_regdomain(struct zd_mac *zd_mac, u8 regdomain);
180u8 zd_mac_get_regdomain(struct zd_mac *zd_mac); 196u8 zd_mac_get_regdomain(struct zd_mac *zd_mac);
181 197
182int zd_mac_request_channel(struct zd_mac *mac, u8 channel); 198int zd_mac_request_channel(struct zd_mac *mac, u8 channel);
183int zd_mac_get_channel(struct zd_mac *mac, u8 *channel, u8 *flags); 199u8 zd_mac_get_channel(struct zd_mac *mac);
184 200
185int zd_mac_set_mode(struct zd_mac *mac, u32 mode); 201int zd_mac_set_mode(struct zd_mac *mac, u32 mode);
186int zd_mac_get_mode(struct zd_mac *mac, u32 *mode); 202int zd_mac_get_mode(struct zd_mac *mac, u32 *mode);
diff --git a/drivers/net/wireless/zd1211rw/zd_netdev.c b/drivers/net/wireless/zd1211rw/zd_netdev.c
index af3a7b36d078..60f1b0f6d45b 100644
--- a/drivers/net/wireless/zd1211rw/zd_netdev.c
+++ b/drivers/net/wireless/zd1211rw/zd_netdev.c
@@ -107,21 +107,10 @@ static int iw_get_freq(struct net_device *netdev,
107 struct iw_request_info *info, 107 struct iw_request_info *info,
108 union iwreq_data *req, char *extra) 108 union iwreq_data *req, char *extra)
109{ 109{
110 int r;
111 struct zd_mac *mac = zd_netdev_mac(netdev); 110 struct zd_mac *mac = zd_netdev_mac(netdev);
112 struct iw_freq *freq = &req->freq; 111 struct iw_freq *freq = &req->freq;
113 u8 channel;
114 u8 flags;
115
116 r = zd_mac_get_channel(mac, &channel, &flags);
117 if (r)
118 return r;
119 112
120 freq->flags = (flags & MAC_FIXED_CHANNEL) ? 113 return zd_channel_to_freq(freq, zd_mac_get_channel(mac));
121 IW_FREQ_FIXED : IW_FREQ_AUTO;
122 dev_dbg_f(zd_mac_dev(mac), "channel %s\n",
123 (flags & MAC_FIXED_CHANNEL) ? "fixed" : "auto");
124 return zd_channel_to_freq(freq, channel);
125} 114}
126 115
127static int iw_set_mode(struct net_device *netdev, 116static int iw_set_mode(struct net_device *netdev,
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 3faaeb2b7c89..aa782e88754b 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -47,11 +47,17 @@ static struct usb_device_id usb_ids[] = {
47 { USB_DEVICE(0x0586, 0x3402), .driver_info = DEVICE_ZD1211 }, 47 { USB_DEVICE(0x0586, 0x3402), .driver_info = DEVICE_ZD1211 },
48 { USB_DEVICE(0x0b3b, 0x5630), .driver_info = DEVICE_ZD1211 }, 48 { USB_DEVICE(0x0b3b, 0x5630), .driver_info = DEVICE_ZD1211 },
49 { USB_DEVICE(0x0b05, 0x170c), .driver_info = DEVICE_ZD1211 }, 49 { USB_DEVICE(0x0b05, 0x170c), .driver_info = DEVICE_ZD1211 },
50 { USB_DEVICE(0x1435, 0x0711), .driver_info = DEVICE_ZD1211 },
51 { USB_DEVICE(0x0586, 0x3409), .driver_info = DEVICE_ZD1211 },
52 { USB_DEVICE(0x0b3b, 0x1630), .driver_info = DEVICE_ZD1211 },
53 { USB_DEVICE(0x0586, 0x3401), .driver_info = DEVICE_ZD1211 },
54 { USB_DEVICE(0x14ea, 0xab13), .driver_info = DEVICE_ZD1211 },
50 /* ZD1211B */ 55 /* ZD1211B */
51 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B }, 56 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B },
52 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B }, 57 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B },
53 { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B }, 58 { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B },
54 { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B }, 59 { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B },
60 { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B },
55 /* "Driverless" devices that need ejecting */ 61 /* "Driverless" devices that need ejecting */
56 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, 62 { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER },
57 {} 63 {}
@@ -366,15 +372,6 @@ error:
366 return r; 372 return r;
367} 373}
368 374
369static void disable_read_regs_int(struct zd_usb *usb)
370{
371 struct zd_usb_interrupt *intr = &usb->intr;
372
373 spin_lock(&intr->lock);
374 intr->read_regs_enabled = 0;
375 spin_unlock(&intr->lock);
376}
377
378#define urb_dev(urb) (&(urb)->dev->dev) 375#define urb_dev(urb) (&(urb)->dev->dev)
379 376
380static inline void handle_regs_int(struct urb *urb) 377static inline void handle_regs_int(struct urb *urb)
@@ -596,6 +593,8 @@ static void handle_rx_packet(struct zd_usb *usb, const u8 *buffer,
596 unsigned int l, k, n; 593 unsigned int l, k, n;
597 for (i = 0, l = 0;; i++) { 594 for (i = 0, l = 0;; i++) {
598 k = le16_to_cpu(get_unaligned(&length_info->length[i])); 595 k = le16_to_cpu(get_unaligned(&length_info->length[i]));
596 if (k == 0)
597 return;
599 n = l+k; 598 n = l+k;
600 if (n > length) 599 if (n > length)
601 return; 600 return;
@@ -1119,27 +1118,28 @@ static int __init usb_init(void)
1119{ 1118{
1120 int r; 1119 int r;
1121 1120
1122 pr_debug("usb_init()\n"); 1121 pr_debug("%s usb_init()\n", driver.name);
1123 1122
1124 zd_workqueue = create_singlethread_workqueue(driver.name); 1123 zd_workqueue = create_singlethread_workqueue(driver.name);
1125 if (zd_workqueue == NULL) { 1124 if (zd_workqueue == NULL) {
1126 printk(KERN_ERR "%s: couldn't create workqueue\n", driver.name); 1125 printk(KERN_ERR "%s couldn't create workqueue\n", driver.name);
1127 return -ENOMEM; 1126 return -ENOMEM;
1128 } 1127 }
1129 1128
1130 r = usb_register(&driver); 1129 r = usb_register(&driver);
1131 if (r) { 1130 if (r) {
1132 printk(KERN_ERR "usb_register() failed. Error number %d\n", r); 1131 printk(KERN_ERR "%s usb_register() failed. Error number %d\n",
1132 driver.name, r);
1133 return r; 1133 return r;
1134 } 1134 }
1135 1135
1136 pr_debug("zd1211rw initialized\n"); 1136 pr_debug("%s initialized\n", driver.name);
1137 return 0; 1137 return 0;
1138} 1138}
1139 1139
1140static void __exit usb_exit(void) 1140static void __exit usb_exit(void)
1141{ 1141{
1142 pr_debug("usb_exit()\n"); 1142 pr_debug("%s usb_exit()\n", driver.name);
1143 usb_deregister(&driver); 1143 usb_deregister(&driver);
1144 destroy_workqueue(zd_workqueue); 1144 destroy_workqueue(zd_workqueue);
1145} 1145}
@@ -1156,10 +1156,19 @@ static void prepare_read_regs_int(struct zd_usb *usb)
1156{ 1156{
1157 struct zd_usb_interrupt *intr = &usb->intr; 1157 struct zd_usb_interrupt *intr = &usb->intr;
1158 1158
1159 spin_lock(&intr->lock); 1159 spin_lock_irq(&intr->lock);
1160 intr->read_regs_enabled = 1; 1160 intr->read_regs_enabled = 1;
1161 INIT_COMPLETION(intr->read_regs.completion); 1161 INIT_COMPLETION(intr->read_regs.completion);
1162 spin_unlock(&intr->lock); 1162 spin_unlock_irq(&intr->lock);
1163}
1164
1165static void disable_read_regs_int(struct zd_usb *usb)
1166{
1167 struct zd_usb_interrupt *intr = &usb->intr;
1168
1169 spin_lock_irq(&intr->lock);
1170 intr->read_regs_enabled = 0;
1171 spin_unlock_irq(&intr->lock);
1163} 1172}
1164 1173
1165static int get_results(struct zd_usb *usb, u16 *values, 1174static int get_results(struct zd_usb *usb, u16 *values,
@@ -1171,7 +1180,7 @@ static int get_results(struct zd_usb *usb, u16 *values,
1171 struct read_regs_int *rr = &intr->read_regs; 1180 struct read_regs_int *rr = &intr->read_regs;
1172 struct usb_int_regs *regs = (struct usb_int_regs *)rr->buffer; 1181 struct usb_int_regs *regs = (struct usb_int_regs *)rr->buffer;
1173 1182
1174 spin_lock(&intr->lock); 1183 spin_lock_irq(&intr->lock);
1175 1184
1176 r = -EIO; 1185 r = -EIO;
1177 /* The created block size seems to be larger than expected. 1186 /* The created block size seems to be larger than expected.
@@ -1204,7 +1213,7 @@ static int get_results(struct zd_usb *usb, u16 *values,
1204 1213
1205 r = 0; 1214 r = 0;
1206error_unlock: 1215error_unlock:
1207 spin_unlock(&intr->lock); 1216 spin_unlock_irq(&intr->lock);
1208 return r; 1217 return r;
1209} 1218}
1210 1219
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.h b/drivers/net/wireless/zd1211rw/zd_usb.h
index e81a2d3cfffd..317d37c36679 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.h
+++ b/drivers/net/wireless/zd1211rw/zd_usb.h
@@ -74,17 +74,17 @@ enum control_requests {
74struct usb_req_read_regs { 74struct usb_req_read_regs {
75 __le16 id; 75 __le16 id;
76 __le16 addr[0]; 76 __le16 addr[0];
77}; 77} __attribute__((packed));
78 78
79struct reg_data { 79struct reg_data {
80 __le16 addr; 80 __le16 addr;
81 __le16 value; 81 __le16 value;
82}; 82} __attribute__((packed));
83 83
84struct usb_req_write_regs { 84struct usb_req_write_regs {
85 __le16 id; 85 __le16 id;
86 struct reg_data reg_writes[0]; 86 struct reg_data reg_writes[0];
87}; 87} __attribute__((packed));
88 88
89enum { 89enum {
90 RF_IF_LE = 0x02, 90 RF_IF_LE = 0x02,
@@ -101,7 +101,7 @@ struct usb_req_rfwrite {
101 /* RF2595: 24 */ 101 /* RF2595: 24 */
102 __le16 bit_values[0]; 102 __le16 bit_values[0];
103 /* (CR203 & ~(RF_IF_LE | RF_CLK | RF_DATA)) | (bit ? RF_DATA : 0) */ 103 /* (CR203 & ~(RF_IF_LE | RF_CLK | RF_DATA)) | (bit ? RF_DATA : 0) */
104}; 104} __attribute__((packed));
105 105
106/* USB interrupt */ 106/* USB interrupt */
107 107
@@ -118,12 +118,12 @@ enum usb_int_flags {
118struct usb_int_header { 118struct usb_int_header {
119 u8 type; /* must always be 1 */ 119 u8 type; /* must always be 1 */
120 u8 id; 120 u8 id;
121}; 121} __attribute__((packed));
122 122
123struct usb_int_regs { 123struct usb_int_regs {
124 struct usb_int_header hdr; 124 struct usb_int_header hdr;
125 struct reg_data regs[0]; 125 struct reg_data regs[0];
126}; 126} __attribute__((packed));
127 127
128struct usb_int_retry_fail { 128struct usb_int_retry_fail {
129 struct usb_int_header hdr; 129 struct usb_int_header hdr;
@@ -131,7 +131,7 @@ struct usb_int_retry_fail {
131 u8 _dummy; 131 u8 _dummy;
132 u8 addr[ETH_ALEN]; 132 u8 addr[ETH_ALEN];
133 u8 ibss_wakeup_dest; 133 u8 ibss_wakeup_dest;
134}; 134} __attribute__((packed));
135 135
136struct read_regs_int { 136struct read_regs_int {
137 struct completion completion; 137 struct completion completion;
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index df04e050c647..d85e2ea0b6af 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -34,8 +34,16 @@
34#include <asm/amigaints.h> 34#include <asm/amigaints.h>
35#include <asm/amigahw.h> 35#include <asm/amigahw.h>
36 36
37#include "8390.h" 37#define EI_SHIFT(x) (ei_local->reg_offset[x])
38#define ei_inb(port) in_8(port)
39#define ei_outb(val,port) out_8(port,val)
40#define ei_inb_p(port) in_8(port)
41#define ei_outb_p(val,port) out_8(port,val)
38 42
43static const char version[] =
44 "8390.c:v1.10cvs 9/23/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
45
46#include "lib8390.c"
39 47
40#define DRV_NAME "zorro8390" 48#define DRV_NAME "zorro8390"
41 49
@@ -114,7 +122,7 @@ static int __devinit zorro8390_init_one(struct zorro_dev *z,
114 break; 122 break;
115 board = z->resource.start; 123 board = z->resource.start;
116 ioaddr = board+cards[i].offset; 124 ioaddr = board+cards[i].offset;
117 dev = alloc_ei_netdev(); 125 dev = ____alloc_ei_netdev(0);
118 if (!dev) 126 if (!dev)
119 return -ENOMEM; 127 return -ENOMEM;
120 SET_MODULE_OWNER(dev); 128 SET_MODULE_OWNER(dev);
@@ -201,7 +209,7 @@ static int __devinit zorro8390_init(struct net_device *dev,
201 dev->irq = IRQ_AMIGA_PORTS; 209 dev->irq = IRQ_AMIGA_PORTS;
202 210
203 /* Install the Interrupt handler */ 211 /* Install the Interrupt handler */
204 i = request_irq(IRQ_AMIGA_PORTS, ei_interrupt, IRQF_SHARED, DRV_NAME, dev); 212 i = request_irq(IRQ_AMIGA_PORTS, __ei_interrupt, IRQF_SHARED, DRV_NAME, dev);
205 if (i) return i; 213 if (i) return i;
206 214
207 for(i = 0; i < ETHER_ADDR_LEN; i++) { 215 for(i = 0; i < ETHER_ADDR_LEN; i++) {
@@ -226,10 +234,10 @@ static int __devinit zorro8390_init(struct net_device *dev,
226 dev->open = &zorro8390_open; 234 dev->open = &zorro8390_open;
227 dev->stop = &zorro8390_close; 235 dev->stop = &zorro8390_close;
228#ifdef CONFIG_NET_POLL_CONTROLLER 236#ifdef CONFIG_NET_POLL_CONTROLLER
229 dev->poll_controller = ei_poll; 237 dev->poll_controller = __ei_poll;
230#endif 238#endif
231 239
232 NS8390_init(dev, 0); 240 __NS8390_init(dev, 0);
233 err = register_netdev(dev); 241 err = register_netdev(dev);
234 if (err) { 242 if (err) {
235 free_irq(IRQ_AMIGA_PORTS, dev); 243 free_irq(IRQ_AMIGA_PORTS, dev);
@@ -246,7 +254,7 @@ static int __devinit zorro8390_init(struct net_device *dev,
246 254
247static int zorro8390_open(struct net_device *dev) 255static int zorro8390_open(struct net_device *dev)
248{ 256{
249 ei_open(dev); 257 __ei_open(dev);
250 return 0; 258 return 0;
251} 259}
252 260
@@ -254,7 +262,7 @@ static int zorro8390_close(struct net_device *dev)
254{ 262{
255 if (ei_debug > 1) 263 if (ei_debug > 1)
256 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name); 264 printk(KERN_DEBUG "%s: Shutting down ethercard.\n", dev->name);
257 ei_close(dev); 265 __ei_close(dev);
258 return 0; 266 return 0;
259} 267}
260 268
@@ -405,7 +413,7 @@ static void zorro8390_block_output(struct net_device *dev, int count,
405 printk(KERN_ERR "%s: timeout waiting for Tx RDC.\n", 413 printk(KERN_ERR "%s: timeout waiting for Tx RDC.\n",
406 dev->name); 414 dev->name);
407 zorro8390_reset_8390(dev); 415 zorro8390_reset_8390(dev);
408 NS8390_init(dev,1); 416 __NS8390_init(dev,1);
409 break; 417 break;
410 } 418 }
411 419
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 68cb3a080050..fe3f5f5365c5 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -486,7 +486,7 @@ typedef unsigned long space_t;
486** This bit tells U2 to do R/M/W for partial cachelines. "Streaming" 486** This bit tells U2 to do R/M/W for partial cachelines. "Streaming"
487** data can avoid this if the mapping covers full cache lines. 487** data can avoid this if the mapping covers full cache lines.
488** o STOP_MOST is needed for atomicity across cachelines. 488** o STOP_MOST is needed for atomicity across cachelines.
489** Apperently only "some EISA devices" need this. 489** Apparently only "some EISA devices" need this.
490** Using CONFIG_ISA is hack. Only the IOA with EISA under it needs 490** Using CONFIG_ISA is hack. Only the IOA with EISA under it needs
491** to use this hint iff the EISA devices needs this feature. 491** to use this hint iff the EISA devices needs this feature.
492** According to the U2 ERS, STOP_MOST enabled pages hurt performance. 492** According to the U2 ERS, STOP_MOST enabled pages hurt performance.
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index c2949b4367e5..12bab64a62a1 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -50,12 +50,12 @@
50** 50**
51** PA Firmware 51** PA Firmware
52** ----------- 52** -----------
53** PA-RISC platforms have two fundementally different types of firmware. 53** PA-RISC platforms have two fundamentally different types of firmware.
54** For PCI devices, "Legacy" PDC initializes the "INTERRUPT_LINE" register 54** For PCI devices, "Legacy" PDC initializes the "INTERRUPT_LINE" register
55** and BARs similar to a traditional PC BIOS. 55** and BARs similar to a traditional PC BIOS.
56** The newer "PAT" firmware supports PDC calls which return tables. 56** The newer "PAT" firmware supports PDC calls which return tables.
57** PAT firmware only initializes PCI Console and Boot interface. 57** PAT firmware only initializes the PCI Console and Boot interface.
58** With these tables, the OS can progam all other PCI devices. 58** With these tables, the OS can program all other PCI devices.
59** 59**
60** One such PAT PDC call returns the "Interrupt Routing Table" (IRT). 60** One such PAT PDC call returns the "Interrupt Routing Table" (IRT).
61** The IRT maps each PCI slot's INTA-D "output" line to an I/O SAPIC 61** The IRT maps each PCI slot's INTA-D "output" line to an I/O SAPIC
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 5f1b9f58070e..f1dd81a1d592 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -19,7 +19,7 @@ config PCI_MSI
19 19
20config PCI_MULTITHREAD_PROBE 20config PCI_MULTITHREAD_PROBE
21 bool "PCI Multi-threaded probe (EXPERIMENTAL)" 21 bool "PCI Multi-threaded probe (EXPERIMENTAL)"
22 depends on PCI && EXPERIMENTAL && BROKEN 22 depends on PCI && EXPERIMENTAL
23 help 23 help
24 Say Y here if you want the PCI core to spawn a new thread for 24 Say Y here if you want the PCI core to spawn a new thread for
25 every PCI device that is probed. This can cause a huge 25 every PCI device that is probed. This can cause a huge
@@ -27,14 +27,14 @@ config PCI_MULTITHREAD_PROBE
27 smaller speedup on single processor machines. 27 smaller speedup on single processor machines.
28 28
29 But it can also cause lots of bad things to happen. A number 29 But it can also cause lots of bad things to happen. A number
30 of PCI drivers can not properly handle running in this way, 30 of PCI drivers cannot properly handle running in this way,
31 some will just not work properly at all, while others might 31 some will just not work properly at all, while others might
32 decide to blow up power supplies with a huge load all at once, 32 decide to blow up power supplies with a huge load all at once,
33 so use this option at your own risk. 33 so use this option at your own risk.
34 34
35 It is very unwise to use this option if you are not using a 35 It is very unwise to use this option if you are not using a
36 boot process that can handle devices being created in any 36 boot process that can handle devices being created in any
37 order. A program that can create persistant block and network 37 order. A program that can create persistent block and network
38 device names (like udev) is a good idea if you wish to use 38 device names (like udev) is a good idea if you wish to use
39 this option. 39 this option.
40 40
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index ea16805a153c..73a58c73d526 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -1,6 +1,7 @@
1#include <linux/pci.h> 1#include <linux/pci.h>
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/ioport.h> 3#include <linux/ioport.h>
4#include <linux/wait.h>
4 5
5#include "pci.h" 6#include "pci.h"
6 7
@@ -63,30 +64,42 @@ EXPORT_SYMBOL(pci_bus_write_config_byte);
63EXPORT_SYMBOL(pci_bus_write_config_word); 64EXPORT_SYMBOL(pci_bus_write_config_word);
64EXPORT_SYMBOL(pci_bus_write_config_dword); 65EXPORT_SYMBOL(pci_bus_write_config_dword);
65 66
66static u32 pci_user_cached_config(struct pci_dev *dev, int pos) 67/*
67{ 68 * The following routines are to prevent the user from accessing PCI config
68 u32 data; 69 * space when it's unsafe to do so. Some devices require this during BIST and
70 * we're required to prevent it during D-state transitions.
71 *
72 * We have a bit per device to indicate it's blocked and a global wait queue
73 * for callers to sleep on until devices are unblocked.
74 */
75static DECLARE_WAIT_QUEUE_HEAD(pci_ucfg_wait);
69 76
70 data = dev->saved_config_space[pos/sizeof(dev->saved_config_space[0])]; 77static noinline void pci_wait_ucfg(struct pci_dev *dev)
71 data >>= (pos % sizeof(dev->saved_config_space[0])) * 8; 78{
72 return data; 79 DECLARE_WAITQUEUE(wait, current);
80
81 __add_wait_queue(&pci_ucfg_wait, &wait);
82 do {
83 set_current_state(TASK_UNINTERRUPTIBLE);
84 spin_unlock_irq(&pci_lock);
85 schedule();
86 spin_lock_irq(&pci_lock);
87 } while (dev->block_ucfg_access);
88 __remove_wait_queue(&pci_ucfg_wait, &wait);
73} 89}
74 90
75#define PCI_USER_READ_CONFIG(size,type) \ 91#define PCI_USER_READ_CONFIG(size,type) \
76int pci_user_read_config_##size \ 92int pci_user_read_config_##size \
77 (struct pci_dev *dev, int pos, type *val) \ 93 (struct pci_dev *dev, int pos, type *val) \
78{ \ 94{ \
79 unsigned long flags; \
80 int ret = 0; \ 95 int ret = 0; \
81 u32 data = -1; \ 96 u32 data = -1; \
82 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ 97 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
83 spin_lock_irqsave(&pci_lock, flags); \ 98 spin_lock_irq(&pci_lock); \
84 if (likely(!dev->block_ucfg_access)) \ 99 if (unlikely(dev->block_ucfg_access)) pci_wait_ucfg(dev); \
85 ret = dev->bus->ops->read(dev->bus, dev->devfn, \ 100 ret = dev->bus->ops->read(dev->bus, dev->devfn, \
86 pos, sizeof(type), &data); \ 101 pos, sizeof(type), &data); \
87 else if (pos < sizeof(dev->saved_config_space)) \ 102 spin_unlock_irq(&pci_lock); \
88 data = pci_user_cached_config(dev, pos); \
89 spin_unlock_irqrestore(&pci_lock, flags); \
90 *val = (type)data; \ 103 *val = (type)data; \
91 return ret; \ 104 return ret; \
92} 105}
@@ -95,14 +108,13 @@ int pci_user_read_config_##size \
95int pci_user_write_config_##size \ 108int pci_user_write_config_##size \
96 (struct pci_dev *dev, int pos, type val) \ 109 (struct pci_dev *dev, int pos, type val) \
97{ \ 110{ \
98 unsigned long flags; \
99 int ret = -EIO; \ 111 int ret = -EIO; \
100 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ 112 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
101 spin_lock_irqsave(&pci_lock, flags); \ 113 spin_lock_irq(&pci_lock); \
102 if (likely(!dev->block_ucfg_access)) \ 114 if (unlikely(dev->block_ucfg_access)) pci_wait_ucfg(dev); \
103 ret = dev->bus->ops->write(dev->bus, dev->devfn, \ 115 ret = dev->bus->ops->write(dev->bus, dev->devfn, \
104 pos, sizeof(type), val); \ 116 pos, sizeof(type), val); \
105 spin_unlock_irqrestore(&pci_lock, flags); \ 117 spin_unlock_irq(&pci_lock); \
106 return ret; \ 118 return ret; \
107} 119}
108 120
@@ -117,21 +129,23 @@ PCI_USER_WRITE_CONFIG(dword, u32)
117 * pci_block_user_cfg_access - Block userspace PCI config reads/writes 129 * pci_block_user_cfg_access - Block userspace PCI config reads/writes
118 * @dev: pci device struct 130 * @dev: pci device struct
119 * 131 *
120 * This function blocks any userspace PCI config accesses from occurring. 132 * When user access is blocked, any reads or writes to config space will
121 * When blocked, any writes will be bit bucketed and reads will return the 133 * sleep until access is unblocked again. We don't allow nesting of
122 * data saved using pci_save_state for the first 64 bytes of config 134 * block/unblock calls.
123 * space and return 0xff for all other config reads. 135 */
124 **/
125void pci_block_user_cfg_access(struct pci_dev *dev) 136void pci_block_user_cfg_access(struct pci_dev *dev)
126{ 137{
127 unsigned long flags; 138 unsigned long flags;
139 int was_blocked;
128 140
129 pci_save_state(dev);
130
131 /* spinlock to synchronize with anyone reading config space now */
132 spin_lock_irqsave(&pci_lock, flags); 141 spin_lock_irqsave(&pci_lock, flags);
142 was_blocked = dev->block_ucfg_access;
133 dev->block_ucfg_access = 1; 143 dev->block_ucfg_access = 1;
134 spin_unlock_irqrestore(&pci_lock, flags); 144 spin_unlock_irqrestore(&pci_lock, flags);
145
146 /* If we BUG() inside the pci_lock, we're guaranteed to hose
147 * the machine */
148 BUG_ON(was_blocked);
135} 149}
136EXPORT_SYMBOL_GPL(pci_block_user_cfg_access); 150EXPORT_SYMBOL_GPL(pci_block_user_cfg_access);
137 151
@@ -140,14 +154,19 @@ EXPORT_SYMBOL_GPL(pci_block_user_cfg_access);
140 * @dev: pci device struct 154 * @dev: pci device struct
141 * 155 *
142 * This function allows userspace PCI config accesses to resume. 156 * This function allows userspace PCI config accesses to resume.
143 **/ 157 */
144void pci_unblock_user_cfg_access(struct pci_dev *dev) 158void pci_unblock_user_cfg_access(struct pci_dev *dev)
145{ 159{
146 unsigned long flags; 160 unsigned long flags;
147 161
148 /* spinlock to synchronize with anyone reading saved config space */
149 spin_lock_irqsave(&pci_lock, flags); 162 spin_lock_irqsave(&pci_lock, flags);
163
164 /* This indicates a problem in the caller, but we don't need
165 * to kill them, unlike a double-block above. */
166 WARN_ON(!dev->block_ucfg_access);
167
150 dev->block_ucfg_access = 0; 168 dev->block_ucfg_access = 0;
169 wake_up_all(&pci_ucfg_wait);
151 spin_unlock_irqrestore(&pci_lock, flags); 170 spin_unlock_irqrestore(&pci_lock, flags);
152} 171}
153EXPORT_SYMBOL_GPL(pci_unblock_user_cfg_access); 172EXPORT_SYMBOL_GPL(pci_unblock_user_cfg_access);
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 59c5b242d86d..ddbadd95387e 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -62,10 +62,10 @@ struct acpiphp_slot;
62struct slot { 62struct slot {
63 struct hotplug_slot *hotplug_slot; 63 struct hotplug_slot *hotplug_slot;
64 struct acpiphp_slot *acpi_slot; 64 struct acpiphp_slot *acpi_slot;
65 struct hotplug_slot_info info;
66 char name[SLOT_NAME_SIZE];
65}; 67};
66 68
67
68
69/** 69/**
70 * struct acpiphp_bridge - PCI bridge information 70 * struct acpiphp_bridge - PCI bridge information
71 * 71 *
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index c57d9d5ce84e..40c79b03c7ef 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -303,25 +303,15 @@ static int __init init_acpi(void)
303 /* read initial number of slots */ 303 /* read initial number of slots */
304 if (!retval) { 304 if (!retval) {
305 num_slots = acpiphp_get_num_slots(); 305 num_slots = acpiphp_get_num_slots();
306 if (num_slots == 0) 306 if (num_slots == 0) {
307 acpiphp_glue_exit();
307 retval = -ENODEV; 308 retval = -ENODEV;
309 }
308 } 310 }
309 311
310 return retval; 312 return retval;
311} 313}
312 314
313
314/**
315 * make_slot_name - make a slot name that appears in pcihpfs
316 * @slot: slot to name
317 *
318 */
319static void make_slot_name(struct slot *slot)
320{
321 snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%u",
322 slot->acpi_slot->sun);
323}
324
325/** 315/**
326 * release_slot - free up the memory used by a slot 316 * release_slot - free up the memory used by a slot
327 * @hotplug_slot: slot to free 317 * @hotplug_slot: slot to free
@@ -332,8 +322,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
332 322
333 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 323 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
334 324
335 kfree(slot->hotplug_slot->info);
336 kfree(slot->hotplug_slot->name);
337 kfree(slot->hotplug_slot); 325 kfree(slot->hotplug_slot);
338 kfree(slot); 326 kfree(slot);
339} 327}
@@ -342,26 +330,19 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
342int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) 330int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
343{ 331{
344 struct slot *slot; 332 struct slot *slot;
345 struct hotplug_slot *hotplug_slot;
346 struct hotplug_slot_info *hotplug_slot_info;
347 int retval = -ENOMEM; 333 int retval = -ENOMEM;
348 334
349 slot = kzalloc(sizeof(*slot), GFP_KERNEL); 335 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
350 if (!slot) 336 if (!slot)
351 goto error; 337 goto error;
352 338
353 slot->hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL); 339 slot->hotplug_slot = kzalloc(sizeof(*slot->hotplug_slot), GFP_KERNEL);
354 if (!slot->hotplug_slot) 340 if (!slot->hotplug_slot)
355 goto error_slot; 341 goto error_slot;
356 342
357 slot->hotplug_slot->info = kzalloc(sizeof(*hotplug_slot_info), 343 slot->hotplug_slot->info = &slot->info;
358 GFP_KERNEL);
359 if (!slot->hotplug_slot->info)
360 goto error_hpslot;
361 344
362 slot->hotplug_slot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL); 345 slot->hotplug_slot->name = slot->name;
363 if (!slot->hotplug_slot->name)
364 goto error_info;
365 346
366 slot->hotplug_slot->private = slot; 347 slot->hotplug_slot->private = slot;
367 slot->hotplug_slot->release = &release_slot; 348 slot->hotplug_slot->release = &release_slot;
@@ -376,21 +357,17 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
376 slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN; 357 slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
377 358
378 acpiphp_slot->slot = slot; 359 acpiphp_slot->slot = slot;
379 make_slot_name(slot); 360 snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
380 361
381 retval = pci_hp_register(slot->hotplug_slot); 362 retval = pci_hp_register(slot->hotplug_slot);
382 if (retval) { 363 if (retval) {
383 err("pci_hp_register failed with error %d\n", retval); 364 err("pci_hp_register failed with error %d\n", retval);
384 goto error_name; 365 goto error_hpslot;
385 } 366 }
386 367
387 info("Slot [%s] registered\n", slot->hotplug_slot->name); 368 info("Slot [%s] registered\n", slot->hotplug_slot->name);
388 369
389 return 0; 370 return 0;
390error_name:
391 kfree(slot->hotplug_slot->name);
392error_info:
393 kfree(slot->hotplug_slot->info);
394error_hpslot: 371error_hpslot:
395 kfree(slot->hotplug_slot); 372 kfree(slot->hotplug_slot);
396error_slot: 373error_slot:
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 16167b016266..0b9d0db1590a 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1693,14 +1693,10 @@ void __exit acpiphp_glue_exit(void)
1693 */ 1693 */
1694int __init acpiphp_get_num_slots(void) 1694int __init acpiphp_get_num_slots(void)
1695{ 1695{
1696 struct list_head *node;
1697 struct acpiphp_bridge *bridge; 1696 struct acpiphp_bridge *bridge;
1698 int num_slots; 1697 int num_slots = 0;
1699
1700 num_slots = 0;
1701 1698
1702 list_for_each (node, &bridge_list) { 1699 list_for_each_entry (bridge, &bridge_list, list) {
1703 bridge = (struct acpiphp_bridge *)node;
1704 dbg("Bus %04x:%02x has %d slot%s\n", 1700 dbg("Bus %04x:%02x has %d slot%s\n",
1705 pci_domain_nr(bridge->pci_bus), 1701 pci_domain_nr(bridge->pci_bus),
1706 bridge->pci_bus->number, bridge->nr_slots, 1702 bridge->pci_bus->number, bridge->nr_slots,
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index c3ac98a0a6a6..f55ac3885cb3 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -531,7 +531,7 @@ static u8 hpc_readcmdtoindex (u8 cmd, u8 index)
531* 531*
532* Action: issue a READ command to HPC 532* Action: issue a READ command to HPC
533* 533*
534* Input: pslot - can not be NULL for READ_ALLSTAT 534* Input: pslot - cannot be NULL for READ_ALLSTAT
535* pstatus - can be NULL for READ_ALLSTAT 535* pstatus - can be NULL for READ_ALLSTAT
536* 536*
537* Return 0 or error codes 537* Return 0 or error codes
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index d87a9e3eaeeb..d8f05d7a3c72 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -1371,12 +1371,12 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1371 } 1371 }
1372 1372
1373 bus = ibmphp_find_res_bus (sec_number); 1373 bus = ibmphp_find_res_bus (sec_number);
1374 debug ("bus->busno is %x\n", bus->busno);
1375 debug ("sec_number is %x\n", sec_number);
1376 if (!bus) { 1374 if (!bus) {
1377 err ("cannot find Bus structure for the bridged device\n"); 1375 err ("cannot find Bus structure for the bridged device\n");
1378 return -EINVAL; 1376 return -EINVAL;
1379 } 1377 }
1378 debug("bus->busno is %x\n", bus->busno);
1379 debug("sec_number is %x\n", sec_number);
1380 1380
1381 ibmphp_remove_bus (bus, busno); 1381 ibmphp_remove_bus (bus, busno);
1382 1382
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index f93e81e2d2c7..f13f31323e85 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -521,14 +521,9 @@ static void __exit unload_pciehpd(void)
521 521
522} 522}
523 523
524static int hpdriver_context = 0;
525
526static void pciehp_remove (struct pcie_device *device) 524static void pciehp_remove (struct pcie_device *device)
527{ 525{
528 printk("%s ENTRY\n", __FUNCTION__); 526 /* XXX - Needs to be adapted to device driver model */
529 printk("%s -> Call free_irq for irq = %d\n",
530 __FUNCTION__, device->irq);
531 free_irq(device->irq, &hpdriver_context);
532} 527}
533 528
534#ifdef CONFIG_PM 529#ifdef CONFIG_PM
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 1c551c697c35..6d3f580f2666 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -718,8 +718,6 @@ static void hpc_release_ctlr(struct controller *ctrl)
718 if (php_ctlr->irq) { 718 if (php_ctlr->irq) {
719 free_irq(php_ctlr->irq, ctrl); 719 free_irq(php_ctlr->irq, ctrl);
720 php_ctlr->irq = 0; 720 php_ctlr->irq = 0;
721 if (!pcie_mch_quirk)
722 pci_disable_msi(php_ctlr->pci_dev);
723 } 721 }
724 } 722 }
725 if (php_ctlr->pci_dev) 723 if (php_ctlr->pci_dev)
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index 46825fee3ae4..72383467a0d5 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -63,7 +63,7 @@ static struct device_node *find_php_slot_pci_node(char *drc_name,
63 char *type; 63 char *type;
64 int rc; 64 int rc;
65 65
66 while ((np = of_find_node_by_type(np, "pci"))) { 66 while ((np = of_find_node_by_name(np, "pci"))) {
67 rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL); 67 rc = rpaphp_get_drc_props(np, NULL, &name, &type, NULL);
68 if (rc == 0) 68 if (rc == 0)
69 if (!strcmp(drc_name, name) && !strcmp(drc_type, type)) 69 if (!strcmp(drc_name, name) && !strcmp(drc_type, type))
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 141486df235b..71a2cb8baa4a 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -356,7 +356,7 @@ static int __init rpaphp_init(void)
356 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 356 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
357 init_MUTEX(&rpaphp_sem); 357 init_MUTEX(&rpaphp_sem);
358 358
359 while ((dn = of_find_node_by_type(dn, "pci"))) 359 while ((dn = of_find_node_by_name(dn, "pci")))
360 rpaphp_add_slot(dn); 360 rpaphp_add_slot(dn);
361 361
362 return 0; 362 return 0;
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index b62ad31a9739..5d188c558386 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -205,21 +205,6 @@ static struct hotplug_slot * sn_hp_destroy(void)
205 return bss_hotplug_slot; 205 return bss_hotplug_slot;
206} 206}
207 207
208static void sn_bus_alloc_data(struct pci_dev *dev)
209{
210 struct pci_bus *subordinate_bus;
211 struct pci_dev *child;
212
213 sn_pci_fixup_slot(dev);
214
215 /* Recursively sets up the sn_irq_info structs */
216 if (dev->subordinate) {
217 subordinate_bus = dev->subordinate;
218 list_for_each_entry(child, &subordinate_bus->devices, bus_list)
219 sn_bus_alloc_data(child);
220 }
221}
222
223static void sn_bus_free_data(struct pci_dev *dev) 208static void sn_bus_free_data(struct pci_dev *dev)
224{ 209{
225 struct pci_bus *subordinate_bus; 210 struct pci_bus *subordinate_bus;
@@ -337,6 +322,11 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
337 return rc; 322 return rc;
338} 323}
339 324
325/*
326 * Power up and configure the slot via a SAL call to PROM.
327 * Scan slot (and any children), do any platform specific fixup,
328 * and find device driver.
329 */
340static int enable_slot(struct hotplug_slot *bss_hotplug_slot) 330static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
341{ 331{
342 struct slot *slot = bss_hotplug_slot->private; 332 struct slot *slot = bss_hotplug_slot->private;
@@ -345,6 +335,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
345 int func, num_funcs; 335 int func, num_funcs;
346 int new_ppb = 0; 336 int new_ppb = 0;
347 int rc; 337 int rc;
338 void pcibios_fixup_device_resources(struct pci_dev *);
348 339
349 /* Serialize the Linux PCI infrastructure */ 340 /* Serialize the Linux PCI infrastructure */
350 mutex_lock(&sn_hotplug_mutex); 341 mutex_lock(&sn_hotplug_mutex);
@@ -367,9 +358,6 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
367 return -ENODEV; 358 return -ENODEV;
368 } 359 }
369 360
370 sn_pci_controller_fixup(pci_domain_nr(slot->pci_bus),
371 slot->pci_bus->number,
372 slot->pci_bus);
373 /* 361 /*
374 * Map SN resources for all functions on the card 362 * Map SN resources for all functions on the card
375 * to the Linux PCI interface and tell the drivers 363 * to the Linux PCI interface and tell the drivers
@@ -380,6 +368,13 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
380 PCI_DEVFN(slot->device_num + 1, 368 PCI_DEVFN(slot->device_num + 1,
381 PCI_FUNC(func))); 369 PCI_FUNC(func)));
382 if (dev) { 370 if (dev) {
371 /* Need to do slot fixup on PPB before fixup of children
372 * (PPB's pcidev_info needs to be in pcidev_info list
373 * before child's SN_PCIDEV_INFO() call to setup
374 * pdi_host_pcidev_info).
375 */
376 pcibios_fixup_device_resources(dev);
377 sn_pci_fixup_slot(dev);
383 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 378 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
384 unsigned char sec_bus; 379 unsigned char sec_bus;
385 pci_read_config_byte(dev, PCI_SECONDARY_BUS, 380 pci_read_config_byte(dev, PCI_SECONDARY_BUS,
@@ -387,12 +382,8 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
387 new_bus = pci_add_new_bus(dev->bus, dev, 382 new_bus = pci_add_new_bus(dev->bus, dev,
388 sec_bus); 383 sec_bus);
389 pci_scan_child_bus(new_bus); 384 pci_scan_child_bus(new_bus);
390 sn_pci_controller_fixup(pci_domain_nr(new_bus),
391 new_bus->number,
392 new_bus);
393 new_ppb = 1; 385 new_ppb = 1;
394 } 386 }
395 sn_bus_alloc_data(dev);
396 pci_dev_put(dev); 387 pci_dev_put(dev);
397 } 388 }
398 } 389 }
diff --git a/drivers/pci/msi.h b/drivers/pci/msi.h
index f0cca1772f9c..3898f5237144 100644
--- a/drivers/pci/msi.h
+++ b/drivers/pci/msi.h
@@ -6,14 +6,6 @@
6#ifndef MSI_H 6#ifndef MSI_H
7#define MSI_H 7#define MSI_H
8 8
9/*
10 * MSI-X Address Register
11 */
12#define PCI_MSIX_FLAGS_QSIZE 0x7FF
13#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
14#define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
15#define PCI_MSIX_FLAGS_BITMASK (1 << 0)
16
17#define PCI_MSIX_ENTRY_SIZE 16 9#define PCI_MSIX_ENTRY_SIZE 16
18#define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0 10#define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0
19#define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4 11#define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index bb7456c1dbac..a064f36a0805 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -36,6 +36,7 @@ acpi_query_osc (
36 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; 36 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
37 union acpi_object *out_obj; 37 union acpi_object *out_obj;
38 u32 osc_dw0; 38 u32 osc_dw0;
39 acpi_status *ret_status = (acpi_status *)retval;
39 40
40 41
41 /* Setting up input parameters */ 42 /* Setting up input parameters */
@@ -56,6 +57,7 @@ acpi_query_osc (
56 if (ACPI_FAILURE (status)) { 57 if (ACPI_FAILURE (status)) {
57 printk(KERN_DEBUG 58 printk(KERN_DEBUG
58 "Evaluate _OSC Set fails. Status = 0x%04x\n", status); 59 "Evaluate _OSC Set fails. Status = 0x%04x\n", status);
60 *ret_status = status;
59 return status; 61 return status;
60 } 62 }
61 out_obj = output.pointer; 63 out_obj = output.pointer;
@@ -90,6 +92,7 @@ acpi_query_osc (
90 92
91query_osc_out: 93query_osc_out:
92 kfree(output.pointer); 94 kfree(output.pointer);
95 *ret_status = status;
93 return status; 96 return status;
94} 97}
95 98
@@ -166,6 +169,7 @@ run_osc_out:
166acpi_status pci_osc_support_set(u32 flags) 169acpi_status pci_osc_support_set(u32 flags)
167{ 170{
168 u32 temp; 171 u32 temp;
172 acpi_status retval;
169 173
170 if (!(flags & OSC_SUPPORT_MASKS)) { 174 if (!(flags & OSC_SUPPORT_MASKS)) {
171 return AE_TYPE; 175 return AE_TYPE;
@@ -179,9 +183,13 @@ acpi_status pci_osc_support_set(u32 flags)
179 acpi_get_devices ( PCI_ROOT_HID_STRING, 183 acpi_get_devices ( PCI_ROOT_HID_STRING,
180 acpi_query_osc, 184 acpi_query_osc,
181 ctrlset_buf, 185 ctrlset_buf,
182 NULL ); 186 (void **) &retval );
183 ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE; 187 ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE;
184 ctrlset_buf[OSC_CONTROL_TYPE] = temp; 188 ctrlset_buf[OSC_CONTROL_TYPE] = temp;
189 if (ACPI_FAILURE(retval)) {
190 /* no osc support at all */
191 ctrlset_buf[OSC_SUPPORT_TYPE] = 0;
192 }
185 return AE_OK; 193 return AE_OK;
186} 194}
187EXPORT_SYMBOL(pci_osc_support_set); 195EXPORT_SYMBOL(pci_osc_support_set);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 194f1d21d3d7..e5ae3a0c13bb 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -329,8 +329,8 @@ static int pci_default_resume(struct pci_dev *pci_dev)
329 /* restore the PCI config space */ 329 /* restore the PCI config space */
330 pci_restore_state(pci_dev); 330 pci_restore_state(pci_dev);
331 /* if the device was enabled before suspend, reenable */ 331 /* if the device was enabled before suspend, reenable */
332 if (pci_dev->is_enabled) 332 if (atomic_read(&pci_dev->enable_cnt))
333 retval = pci_enable_device(pci_dev); 333 retval = __pci_enable_device(pci_dev);
334 /* if the device was busmaster before the suspend, make it busmaster again */ 334 /* if the device was busmaster before the suspend, make it busmaster again */
335 if (pci_dev->is_busmaster) 335 if (pci_dev->is_busmaster)
336 pci_set_master(pci_dev); 336 pci_set_master(pci_dev);
@@ -445,9 +445,12 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner)
445 445
446 /* register with core */ 446 /* register with core */
447 error = driver_register(&drv->driver); 447 error = driver_register(&drv->driver);
448 if (error)
449 return error;
448 450
449 if (!error) 451 error = pci_create_newid_file(drv);
450 error = pci_create_newid_file(drv); 452 if (error)
453 driver_unregister(&drv->driver);
451 454
452 return error; 455 return error;
453} 456}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index f952bfea48a6..7a94076752d0 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -42,7 +42,6 @@ pci_config_attr(subsystem_vendor, "0x%04x\n");
42pci_config_attr(subsystem_device, "0x%04x\n"); 42pci_config_attr(subsystem_device, "0x%04x\n");
43pci_config_attr(class, "0x%06x\n"); 43pci_config_attr(class, "0x%06x\n");
44pci_config_attr(irq, "%u\n"); 44pci_config_attr(irq, "%u\n");
45pci_config_attr(is_enabled, "%u\n");
46 45
47static ssize_t broken_parity_status_show(struct device *dev, 46static ssize_t broken_parity_status_show(struct device *dev,
48 struct device_attribute *attr, 47 struct device_attribute *attr,
@@ -112,26 +111,36 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
112 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8), 111 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
113 (u8)(pci_dev->class)); 112 (u8)(pci_dev->class));
114} 113}
115static ssize_t 114
116is_enabled_store(struct device *dev, struct device_attribute *attr, 115static ssize_t is_enabled_store(struct device *dev,
117 const char *buf, size_t count) 116 struct device_attribute *attr, const char *buf,
117 size_t count)
118{ 118{
119 ssize_t result = -EINVAL;
119 struct pci_dev *pdev = to_pci_dev(dev); 120 struct pci_dev *pdev = to_pci_dev(dev);
120 int retval = 0;
121 121
122 /* this can crash the machine when done on the "wrong" device */ 122 /* this can crash the machine when done on the "wrong" device */
123 if (!capable(CAP_SYS_ADMIN)) 123 if (!capable(CAP_SYS_ADMIN))
124 return count; 124 return count;
125 125
126 if (*buf == '0') 126 if (*buf == '0') {
127 pci_disable_device(pdev); 127 if (atomic_read(&pdev->enable_cnt) != 0)
128 pci_disable_device(pdev);
129 else
130 result = -EIO;
131 } else if (*buf == '1')
132 result = pci_enable_device(pdev);
133
134 return result < 0 ? result : count;
135}
128 136
129 if (*buf == '1') 137static ssize_t is_enabled_show(struct device *dev,
130 retval = pci_enable_device(pdev); 138 struct device_attribute *attr, char *buf)
139{
140 struct pci_dev *pdev;
131 141
132 if (retval) 142 pdev = to_pci_dev (dev);
133 return retval; 143 return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt));
134 return count;
135} 144}
136 145
137static ssize_t 146static ssize_t
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index a544997399b3..5a14b73cf3a1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -490,6 +490,47 @@ static void pci_restore_pcie_state(struct pci_dev *dev)
490 kfree(save_state); 490 kfree(save_state);
491} 491}
492 492
493
494static int pci_save_pcix_state(struct pci_dev *dev)
495{
496 int pos, i = 0;
497 struct pci_cap_saved_state *save_state;
498 u16 *cap;
499
500 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
501 if (pos <= 0)
502 return 0;
503
504 save_state = kzalloc(sizeof(*save_state) + sizeof(u16), GFP_KERNEL);
505 if (!save_state) {
506 dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n");
507 return -ENOMEM;
508 }
509 cap = (u16 *)&save_state->data[0];
510
511 pci_read_config_word(dev, pos + PCI_X_CMD, &cap[i++]);
512 pci_add_saved_cap(dev, save_state);
513 return 0;
514}
515
516static void pci_restore_pcix_state(struct pci_dev *dev)
517{
518 int i = 0, pos;
519 struct pci_cap_saved_state *save_state;
520 u16 *cap;
521
522 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
523 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
524 if (!save_state || pos <= 0)
525 return;
526 cap = (u16 *)&save_state->data[0];
527
528 pci_write_config_word(dev, pos + PCI_X_CMD, cap[i++]);
529 pci_remove_saved_cap(save_state);
530 kfree(save_state);
531}
532
533
493/** 534/**
494 * pci_save_state - save the PCI configuration space of a device before suspending 535 * pci_save_state - save the PCI configuration space of a device before suspending
495 * @dev: - PCI device that we're dealing with 536 * @dev: - PCI device that we're dealing with
@@ -507,6 +548,8 @@ pci_save_state(struct pci_dev *dev)
507 return i; 548 return i;
508 if ((i = pci_save_pcie_state(dev)) != 0) 549 if ((i = pci_save_pcie_state(dev)) != 0)
509 return i; 550 return i;
551 if ((i = pci_save_pcix_state(dev)) != 0)
552 return i;
510 return 0; 553 return 0;
511} 554}
512 555
@@ -538,6 +581,7 @@ pci_restore_state(struct pci_dev *dev)
538 dev->saved_config_space[i]); 581 dev->saved_config_space[i]);
539 } 582 }
540 } 583 }
584 pci_restore_pcix_state(dev);
541 pci_restore_msi_state(dev); 585 pci_restore_msi_state(dev);
542 pci_restore_msix_state(dev); 586 pci_restore_msix_state(dev);
543 return 0; 587 return 0;
@@ -568,30 +612,51 @@ pci_enable_device_bars(struct pci_dev *dev, int bars)
568} 612}
569 613
570/** 614/**
571 * pci_enable_device - Initialize device before it's used by a driver. 615 * __pci_enable_device - Initialize device before it's used by a driver.
572 * @dev: PCI device to be initialized 616 * @dev: PCI device to be initialized
573 * 617 *
574 * Initialize device before it's used by a driver. Ask low-level code 618 * Initialize device before it's used by a driver. Ask low-level code
575 * to enable I/O and memory. Wake up the device if it was suspended. 619 * to enable I/O and memory. Wake up the device if it was suspended.
576 * Beware, this function can fail. 620 * Beware, this function can fail.
621 *
622 * Note this function is a backend and is not supposed to be called by
623 * normal code, use pci_enable_device() instead.
577 */ 624 */
578int 625int
579pci_enable_device(struct pci_dev *dev) 626__pci_enable_device(struct pci_dev *dev)
580{ 627{
581 int err; 628 int err;
582 629
583 if (dev->is_enabled)
584 return 0;
585
586 err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1); 630 err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
587 if (err) 631 if (err)
588 return err; 632 return err;
589 pci_fixup_device(pci_fixup_enable, dev); 633 pci_fixup_device(pci_fixup_enable, dev);
590 dev->is_enabled = 1;
591 return 0; 634 return 0;
592} 635}
593 636
594/** 637/**
638 * pci_enable_device - Initialize device before it's used by a driver.
639 * @dev: PCI device to be initialized
640 *
641 * Initialize device before it's used by a driver. Ask low-level code
642 * to enable I/O and memory. Wake up the device if it was suspended.
643 * Beware, this function can fail.
644 *
645 * Note we don't actually enable the device many times if we call
646 * this function repeatedly (we just increment the count).
647 */
648int pci_enable_device(struct pci_dev *dev)
649{
650 int result;
651 if (atomic_add_return(1, &dev->enable_cnt) > 1)
652 return 0; /* already enabled */
653 result = __pci_enable_device(dev);
654 if (result < 0)
655 atomic_dec(&dev->enable_cnt);
656 return result;
657}
658
659/**
595 * pcibios_disable_device - disable arch specific PCI resources for device dev 660 * pcibios_disable_device - disable arch specific PCI resources for device dev
596 * @dev: the PCI device to disable 661 * @dev: the PCI device to disable
597 * 662 *
@@ -607,12 +672,18 @@ void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {}
607 * 672 *
608 * Signal to the system that the PCI device is not in use by the system 673 * Signal to the system that the PCI device is not in use by the system
609 * anymore. This only involves disabling PCI bus-mastering, if active. 674 * anymore. This only involves disabling PCI bus-mastering, if active.
675 *
676 * Note we don't actually disable the device until all callers of
677 * pci_device_enable() have called pci_device_disable().
610 */ 678 */
611void 679void
612pci_disable_device(struct pci_dev *dev) 680pci_disable_device(struct pci_dev *dev)
613{ 681{
614 u16 pci_command; 682 u16 pci_command;
615 683
684 if (atomic_sub_return(1, &dev->enable_cnt) != 0)
685 return;
686
616 if (dev->msi_enabled) 687 if (dev->msi_enabled)
617 disable_msi_mode(dev, pci_find_capability(dev, PCI_CAP_ID_MSI), 688 disable_msi_mode(dev, pci_find_capability(dev, PCI_CAP_ID_MSI),
618 PCI_CAP_ID_MSI); 689 PCI_CAP_ID_MSI);
@@ -628,7 +699,6 @@ pci_disable_device(struct pci_dev *dev)
628 dev->is_busmaster = 0; 699 dev->is_busmaster = 0;
629 700
630 pcibios_disable_device(dev); 701 pcibios_disable_device(dev);
631 dev->is_enabled = 0;
632} 702}
633 703
634/** 704/**
@@ -831,22 +901,38 @@ pci_set_master(struct pci_dev *dev)
831 pcibios_set_master(dev); 901 pcibios_set_master(dev);
832} 902}
833 903
834#ifndef HAVE_ARCH_PCI_MWI 904#ifdef PCI_DISABLE_MWI
905int pci_set_mwi(struct pci_dev *dev)
906{
907 return 0;
908}
909
910void pci_clear_mwi(struct pci_dev *dev)
911{
912}
913
914#else
915
916#ifndef PCI_CACHE_LINE_BYTES
917#define PCI_CACHE_LINE_BYTES L1_CACHE_BYTES
918#endif
919
835/* This can be overridden by arch code. */ 920/* This can be overridden by arch code. */
836u8 pci_cache_line_size = L1_CACHE_BYTES >> 2; 921/* Don't forget this is measured in 32-bit words, not bytes */
922u8 pci_cache_line_size = PCI_CACHE_LINE_BYTES / 4;
837 923
838/** 924/**
839 * pci_generic_prep_mwi - helper function for pci_set_mwi 925 * pci_set_cacheline_size - ensure the CACHE_LINE_SIZE register is programmed
840 * @dev: the PCI device for which MWI is enabled 926 * @dev: the PCI device for which MWI is to be enabled
841 * 927 *
842 * Helper function for generic implementation of pcibios_prep_mwi 928 * Helper function for pci_set_mwi.
843 * function. Originally copied from drivers/net/acenic.c. 929 * Originally copied from drivers/net/acenic.c.
844 * Copyright 1998-2001 by Jes Sorensen, <jes@trained-monkey.org>. 930 * Copyright 1998-2001 by Jes Sorensen, <jes@trained-monkey.org>.
845 * 931 *
846 * RETURNS: An appropriate -ERRNO error value on error, or zero for success. 932 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
847 */ 933 */
848static int 934static int
849pci_generic_prep_mwi(struct pci_dev *dev) 935pci_set_cacheline_size(struct pci_dev *dev)
850{ 936{
851 u8 cacheline_size; 937 u8 cacheline_size;
852 938
@@ -872,7 +958,6 @@ pci_generic_prep_mwi(struct pci_dev *dev)
872 958
873 return -EINVAL; 959 return -EINVAL;
874} 960}
875#endif /* !HAVE_ARCH_PCI_MWI */
876 961
877/** 962/**
878 * pci_set_mwi - enables memory-write-invalidate PCI transaction 963 * pci_set_mwi - enables memory-write-invalidate PCI transaction
@@ -890,12 +975,7 @@ pci_set_mwi(struct pci_dev *dev)
890 int rc; 975 int rc;
891 u16 cmd; 976 u16 cmd;
892 977
893#ifdef HAVE_ARCH_PCI_MWI 978 rc = pci_set_cacheline_size(dev);
894 rc = pcibios_prep_mwi(dev);
895#else
896 rc = pci_generic_prep_mwi(dev);
897#endif
898
899 if (rc) 979 if (rc)
900 return rc; 980 return rc;
901 981
@@ -926,6 +1006,7 @@ pci_clear_mwi(struct pci_dev *dev)
926 pci_write_config_word(dev, PCI_COMMAND, cmd); 1006 pci_write_config_word(dev, PCI_COMMAND, cmd);
927 } 1007 }
928} 1008}
1009#endif /* ! PCI_DISABLE_MWI */
929 1010
930/** 1011/**
931 * pci_intx - enables/disables PCI INTx for device dev 1012 * pci_intx - enables/disables PCI INTx for device dev
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 6bf327db5c5e..398852f526a6 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -1,5 +1,6 @@
1/* Functions internal to the PCI core code */ 1/* Functions internal to the PCI core code */
2 2
3extern int __must_check __pci_enable_device(struct pci_dev *);
3extern int pci_uevent(struct device *dev, char **envp, int num_envp, 4extern int pci_uevent(struct device *dev, char **envp, int num_envp,
4 char *buffer, int buffer_size); 5 char *buffer, int buffer_size);
5extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); 6extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index e159d6604494..0eeac60042b3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -679,6 +679,33 @@ static int pci_setup_device(struct pci_dev * dev)
679 pci_read_bases(dev, 6, PCI_ROM_ADDRESS); 679 pci_read_bases(dev, 6, PCI_ROM_ADDRESS);
680 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor); 680 pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &dev->subsystem_vendor);
681 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device); 681 pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &dev->subsystem_device);
682
683 /*
684 * Do the ugly legacy mode stuff here rather than broken chip
685 * quirk code. Legacy mode ATA controllers have fixed
686 * addresses. These are not always echoed in BAR0-3, and
687 * BAR0-3 in a few cases contain junk!
688 */
689 if (class == PCI_CLASS_STORAGE_IDE) {
690 u8 progif;
691 pci_read_config_byte(dev, PCI_CLASS_PROG, &progif);
692 if ((progif & 1) == 0) {
693 dev->resource[0].start = 0x1F0;
694 dev->resource[0].end = 0x1F7;
695 dev->resource[0].flags = IORESOURCE_IO;
696 dev->resource[1].start = 0x3F6;
697 dev->resource[1].end = 0x3F6;
698 dev->resource[1].flags = IORESOURCE_IO;
699 }
700 if ((progif & 4) == 0) {
701 dev->resource[2].start = 0x170;
702 dev->resource[2].end = 0x177;
703 dev->resource[2].flags = IORESOURCE_IO;
704 dev->resource[3].start = 0x376;
705 dev->resource[3].end = 0x376;
706 dev->resource[3].flags = IORESOURCE_IO;
707 }
708 }
682 break; 709 break;
683 710
684 case PCI_HEADER_TYPE_BRIDGE: /* bridge header */ 711 case PCI_HEADER_TYPE_BRIDGE: /* bridge header */
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 5b4483811691..9ca9b9bf6160 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -797,56 +797,6 @@ static void __init quirk_mediagx_master(struct pci_dev *dev)
797DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_PCI_MASTER, quirk_mediagx_master ); 797DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_PCI_MASTER, quirk_mediagx_master );
798 798
799/* 799/*
800 * As per PCI spec, ignore base address registers 0-3 of the IDE controllers
801 * running in Compatible mode (bits 0 and 2 in the ProgIf for primary and
802 * secondary channels respectively). If the device reports Compatible mode
803 * but does use BAR0-3 for address decoding, we assume that firmware has
804 * programmed these BARs with standard values (0x1f0,0x3f4 and 0x170,0x374).
805 * Exceptions (if they exist) must be handled in chip/architecture specific
806 * fixups.
807 *
808 * Note: for non x86 people. You may need an arch specific quirk to handle
809 * moving IDE devices to native mode as well. Some plug in card devices power
810 * up in compatible mode and assume the BIOS will adjust them.
811 *
812 * Q: should we load the 0x1f0,0x3f4 into the registers or zap them as
813 * we do now ? We don't want is pci_enable_device to come along
814 * and assign new resources. Both approaches work for that.
815 */
816static void __devinit quirk_ide_bases(struct pci_dev *dev)
817{
818 struct resource *res;
819 int first_bar = 2, last_bar = 0;
820
821 if ((dev->class >> 8) != PCI_CLASS_STORAGE_IDE)
822 return;
823
824 res = &dev->resource[0];
825
826 /* primary channel: ProgIf bit 0, BAR0, BAR1 */
827 if (!(dev->class & 1) && (res[0].flags || res[1].flags)) {
828 res[0].start = res[0].end = res[0].flags = 0;
829 res[1].start = res[1].end = res[1].flags = 0;
830 first_bar = 0;
831 last_bar = 1;
832 }
833
834 /* secondary channel: ProgIf bit 2, BAR2, BAR3 */
835 if (!(dev->class & 4) && (res[2].flags || res[3].flags)) {
836 res[2].start = res[2].end = res[2].flags = 0;
837 res[3].start = res[3].end = res[3].flags = 0;
838 last_bar = 3;
839 }
840
841 if (!last_bar)
842 return;
843
844 printk(KERN_INFO "PCI: Ignoring BAR%d-%d of IDE controller %s\n",
845 first_bar, last_bar, pci_name(dev));
846}
847DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, quirk_ide_bases);
848
849/*
850 * Ensure C0 rev restreaming is off. This is normally done by 800 * Ensure C0 rev restreaming is off. This is normally done by
851 * the BIOS but in the odd case it is not the results are corruption 801 * the BIOS but in the odd case it is not the results are corruption
852 * hence the presence of a Linux check 802 * hence the presence of a Linux check
@@ -880,11 +830,10 @@ static void __devinit quirk_svwks_csb5ide(struct pci_dev *pdev)
880 prog &= ~5; 830 prog &= ~5;
881 pdev->class &= ~5; 831 pdev->class &= ~5;
882 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); 832 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog);
883 /* need to re-assign BARs for compat mode */ 833 /* PCI layer will sort out resources */
884 quirk_ide_bases(pdev);
885 } 834 }
886} 835}
887DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, quirk_svwks_csb5ide ); 836DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, quirk_svwks_csb5ide );
888 837
889/* 838/*
890 * Intel 82801CAM ICH3-M datasheet says IDE modes must be the same 839 * Intel 82801CAM ICH3-M datasheet says IDE modes must be the same
@@ -900,11 +849,9 @@ static void __init quirk_ide_samemode(struct pci_dev *pdev)
900 prog &= ~5; 849 prog &= ~5;
901 pdev->class &= ~5; 850 pdev->class &= ~5;
902 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); 851 pci_write_config_byte(pdev, PCI_CLASS_PROG, prog);
903 /* need to re-assign BARs for compat mode */
904 quirk_ide_bases(pdev);
905 } 852 }
906} 853}
907DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode); 854DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode);
908 855
909/* This was originally an Alpha specific thing, but it really fits here. 856/* This was originally an Alpha specific thing, but it really fits here.
910 * The i82375 PCI/EISA bridge appears as non-classified. Fix that. 857 * The i82375 PCI/EISA bridge appears as non-classified. Fix that.
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index e1dcefc69bb4..d087e0817715 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -81,7 +81,8 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
81 start = (loff_t)0xC0000; 81 start = (loff_t)0xC0000;
82 *size = 0x20000; /* cover C000:0 through E000:0 */ 82 *size = 0x20000; /* cover C000:0 through E000:0 */
83 } else { 83 } else {
84 if (res->flags & IORESOURCE_ROM_COPY) { 84 if (res->flags &
85 (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) {
85 *size = pci_resource_len(pdev, PCI_ROM_RESOURCE); 86 *size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
86 return (void __iomem *)(unsigned long) 87 return (void __iomem *)(unsigned long)
87 pci_resource_start(pdev, PCI_ROM_RESOURCE); 88 pci_resource_start(pdev, PCI_ROM_RESOURCE);
@@ -165,7 +166,8 @@ void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size)
165 if (!rom) 166 if (!rom)
166 return NULL; 167 return NULL;
167 168
168 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_SHADOW)) 169 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_SHADOW |
170 IORESOURCE_ROM_BIOS_COPY))
169 return rom; 171 return rom;
170 172
171 res->start = (unsigned long)kmalloc(*size, GFP_KERNEL); 173 res->start = (unsigned long)kmalloc(*size, GFP_KERNEL);
@@ -191,7 +193,7 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
191{ 193{
192 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE]; 194 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
193 195
194 if (res->flags & IORESOURCE_ROM_COPY) 196 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY))
195 return; 197 return;
196 198
197 iounmap(rom); 199 iounmap(rom);
@@ -215,6 +217,7 @@ void pci_remove_rom(struct pci_dev *pdev)
215 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); 217 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
216 if (!(res->flags & (IORESOURCE_ROM_ENABLE | 218 if (!(res->flags & (IORESOURCE_ROM_ENABLE |
217 IORESOURCE_ROM_SHADOW | 219 IORESOURCE_ROM_SHADOW |
220 IORESOURCE_ROM_BIOS_COPY |
218 IORESOURCE_ROM_COPY))) 221 IORESOURCE_ROM_COPY)))
219 pci_disable_rom(pdev); 222 pci_disable_rom(pdev);
220} 223}
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index e469a46a388b..ff14fd8f0cd1 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -1273,7 +1273,9 @@ static void pcmcia_bus_remove_socket(struct class_device *class_dev,
1273 pccard_register_pcmcia(socket, NULL); 1273 pccard_register_pcmcia(socket, NULL);
1274 1274
1275 /* unregister any unbound devices */ 1275 /* unregister any unbound devices */
1276 mutex_lock(&socket->skt_mutex);
1276 pcmcia_card_remove(socket, NULL); 1277 pcmcia_card_remove(socket, NULL);
1278 mutex_unlock(&socket->skt_mutex);
1277 1279
1278 pcmcia_put_socket(socket); 1280 pcmcia_put_socket(socket);
1279 1281
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index 579cd667b16f..6f11f6dfdd9d 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -145,6 +145,13 @@ int rtc_set_alarm(struct class_device *class_dev, struct rtc_wkalrm *alarm)
145} 145}
146EXPORT_SYMBOL_GPL(rtc_set_alarm); 146EXPORT_SYMBOL_GPL(rtc_set_alarm);
147 147
148/**
149 * rtc_update_irq - report RTC periodic, alarm, and/or update irqs
150 * @class_dev: the rtc's class device
151 * @num: how many irqs are being reported (usually one)
152 * @events: mask of RTC_IRQF with one or more of RTC_PF, RTC_AF, RTC_UF
153 * Context: in_interrupt(), irqs blocked
154 */
148void rtc_update_irq(struct class_device *class_dev, 155void rtc_update_irq(struct class_device *class_dev,
149 unsigned long num, unsigned long events) 156 unsigned long num, unsigned long events)
150{ 157{
@@ -201,12 +208,12 @@ int rtc_irq_register(struct class_device *class_dev, struct rtc_task *task)
201 if (task == NULL || task->func == NULL) 208 if (task == NULL || task->func == NULL)
202 return -EINVAL; 209 return -EINVAL;
203 210
204 spin_lock(&rtc->irq_task_lock); 211 spin_lock_irq(&rtc->irq_task_lock);
205 if (rtc->irq_task == NULL) { 212 if (rtc->irq_task == NULL) {
206 rtc->irq_task = task; 213 rtc->irq_task = task;
207 retval = 0; 214 retval = 0;
208 } 215 }
209 spin_unlock(&rtc->irq_task_lock); 216 spin_unlock_irq(&rtc->irq_task_lock);
210 217
211 return retval; 218 return retval;
212} 219}
@@ -216,10 +223,10 @@ void rtc_irq_unregister(struct class_device *class_dev, struct rtc_task *task)
216{ 223{
217 struct rtc_device *rtc = to_rtc_device(class_dev); 224 struct rtc_device *rtc = to_rtc_device(class_dev);
218 225
219 spin_lock(&rtc->irq_task_lock); 226 spin_lock_irq(&rtc->irq_task_lock);
220 if (rtc->irq_task == task) 227 if (rtc->irq_task == task)
221 rtc->irq_task = NULL; 228 rtc->irq_task = NULL;
222 spin_unlock(&rtc->irq_task_lock); 229 spin_unlock_irq(&rtc->irq_task_lock);
223} 230}
224EXPORT_SYMBOL_GPL(rtc_irq_unregister); 231EXPORT_SYMBOL_GPL(rtc_irq_unregister);
225 232
@@ -265,3 +272,4 @@ int rtc_irq_set_freq(struct class_device *class_dev, struct rtc_task *task, int
265 } 272 }
266 return err; 273 return err;
267} 274}
275EXPORT_SYMBOL_GPL(rtc_irq_set_freq);
diff --git a/drivers/rtc/rtc-at91.c b/drivers/rtc/rtc-at91.c
index bd61e99540a3..5c8addcaf1fb 100644
--- a/drivers/rtc/rtc-at91.c
+++ b/drivers/rtc/rtc-at91.c
@@ -292,7 +292,8 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
292 AT91_RTC_CALEV); 292 AT91_RTC_CALEV);
293 293
294 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, 294 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt,
295 IRQF_SHARED, "at91_rtc", pdev); 295 IRQF_DISABLED | IRQF_SHARED,
296 "at91_rtc", pdev);
296 if (ret) { 297 if (ret) {
297 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n", 298 printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n",
298 AT91_ID_SYS); 299 AT91_ID_SYS);
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index dcf5f86461f7..828b329e08e0 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -62,7 +62,9 @@ static void rtc_uie_task(struct work_struct *work)
62 int err; 62 int err;
63 63
64 err = rtc_read_time(&rtc->class_dev, &tm); 64 err = rtc_read_time(&rtc->class_dev, &tm);
65 spin_lock_irq(&rtc->irq_lock); 65
66 local_irq_disable();
67 spin_lock(&rtc->irq_lock);
66 if (rtc->stop_uie_polling || err) { 68 if (rtc->stop_uie_polling || err) {
67 rtc->uie_task_active = 0; 69 rtc->uie_task_active = 0;
68 } else if (rtc->oldsecs != tm.tm_sec) { 70 } else if (rtc->oldsecs != tm.tm_sec) {
@@ -75,11 +77,11 @@ static void rtc_uie_task(struct work_struct *work)
75 } else if (schedule_work(&rtc->uie_task) == 0) { 77 } else if (schedule_work(&rtc->uie_task) == 0) {
76 rtc->uie_task_active = 0; 78 rtc->uie_task_active = 0;
77 } 79 }
78 spin_unlock_irq(&rtc->irq_lock); 80 spin_unlock(&rtc->irq_lock);
79 if (num) 81 if (num)
80 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF); 82 rtc_update_irq(&rtc->class_dev, num, RTC_UF | RTC_IRQF);
83 local_irq_enable();
81} 84}
82
83static void rtc_uie_timer(unsigned long data) 85static void rtc_uie_timer(unsigned long data)
84{ 86{
85 struct rtc_device *rtc = (struct rtc_device *)data; 87 struct rtc_device *rtc = (struct rtc_device *)data;
@@ -215,7 +217,7 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
215 struct rtc_wkalrm alarm; 217 struct rtc_wkalrm alarm;
216 void __user *uarg = (void __user *) arg; 218 void __user *uarg = (void __user *) arg;
217 219
218 /* check that the calles has appropriate permissions 220 /* check that the calling task has appropriate permissions
219 * for certain ioctls. doing this check here is useful 221 * for certain ioctls. doing this check here is useful
220 * to avoid duplicate code in each driver. 222 * to avoid duplicate code in each driver.
221 */ 223 */
@@ -239,10 +241,10 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
239 241
240 /* avoid conflicting IRQ users */ 242 /* avoid conflicting IRQ users */
241 if (cmd == RTC_PIE_ON || cmd == RTC_PIE_OFF || cmd == RTC_IRQP_SET) { 243 if (cmd == RTC_PIE_ON || cmd == RTC_PIE_OFF || cmd == RTC_IRQP_SET) {
242 spin_lock(&rtc->irq_task_lock); 244 spin_lock_irq(&rtc->irq_task_lock);
243 if (rtc->irq_task) 245 if (rtc->irq_task)
244 err = -EBUSY; 246 err = -EBUSY;
245 spin_unlock(&rtc->irq_task_lock); 247 spin_unlock_irq(&rtc->irq_task_lock);
246 248
247 if (err < 0) 249 if (err < 0)
248 return err; 250 return err;
@@ -300,6 +302,17 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
300 302
301 err = rtc_set_time(class_dev, &tm); 303 err = rtc_set_time(class_dev, &tm);
302 break; 304 break;
305
306 case RTC_IRQP_READ:
307 if (ops->irq_set_freq)
308 err = put_user(rtc->irq_freq, (unsigned long *) arg);
309 break;
310
311 case RTC_IRQP_SET:
312 if (ops->irq_set_freq)
313 err = rtc_irq_set_freq(class_dev, rtc->irq_task, arg);
314 break;
315
303#if 0 316#if 0
304 case RTC_EPOCH_SET: 317 case RTC_EPOCH_SET:
305#ifndef rtc_epoch 318#ifndef rtc_epoch
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index 78552e6e76aa..001eb1123a65 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -340,7 +340,8 @@ static int __init ds1553_rtc_probe(struct platform_device *pdev)
340 340
341 if (pdata->irq >= 0) { 341 if (pdata->irq >= 0) {
342 writeb(0, ioaddr + RTC_INTERRUPTS); 342 writeb(0, ioaddr + RTC_INTERRUPTS);
343 if (request_irq(pdata->irq, ds1553_rtc_interrupt, IRQF_SHARED, 343 if (request_irq(pdata->irq, ds1553_rtc_interrupt,
344 IRQF_DISABLED | IRQF_SHARED,
344 pdev->name, pdev) < 0) { 345 pdev->name, pdev) < 0) {
345 dev_warn(&pdev->dev, "interrupt not available.\n"); 346 dev_warn(&pdev->dev, "interrupt not available.\n");
346 pdata->irq = -1; 347 pdata->irq = -1;
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 2a86632580f1..a44fe4efa216 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -126,13 +126,13 @@ static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
126 return -EIO; 126 return -EIO;
127 } 127 }
128 128
129 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
130
131 if (osc) 129 if (osc)
132 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768; 130 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768;
133 131
134 if (trim) 132 if (trim) {
135 *trim = buf & RS5C372_TRIM_MASK; 133 *trim = buf & RS5C372_TRIM_MASK;
134 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
135 }
136 136
137 return 0; 137 return 0;
138} 138}
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index bc4bd24508a2..6ef9c62d5032 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -99,6 +99,7 @@ static ssize_t test_irq_store(struct device *dev,
99 struct rtc_device *rtc = platform_get_drvdata(plat_dev); 99 struct rtc_device *rtc = platform_get_drvdata(plat_dev);
100 100
101 retval = count; 101 retval = count;
102 local_irq_disable();
102 if (strncmp(buf, "tick", 4) == 0) 103 if (strncmp(buf, "tick", 4) == 0)
103 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF); 104 rtc_update_irq(&rtc->class_dev, 1, RTC_PF | RTC_IRQF);
104 else if (strncmp(buf, "alarm", 5) == 0) 105 else if (strncmp(buf, "alarm", 5) == 0)
@@ -107,6 +108,7 @@ static ssize_t test_irq_store(struct device *dev,
107 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF); 108 rtc_update_irq(&rtc->class_dev, 1, RTC_UF | RTC_IRQF);
108 else 109 else
109 retval = -EINVAL; 110 retval = -EINVAL;
111 local_irq_enable();
110 112
111 return retval; 113 return retval;
112} 114}
diff --git a/drivers/s390/net/claw.h b/drivers/s390/net/claw.h
index 969be465309c..1ee9a6f06541 100644
--- a/drivers/s390/net/claw.h
+++ b/drivers/s390/net/claw.h
@@ -29,7 +29,7 @@
29#define CLAW_COMPLETE 0xff /* flag to indicate i/o completed */ 29#define CLAW_COMPLETE 0xff /* flag to indicate i/o completed */
30 30
31/*-----------------------------------------------------* 31/*-----------------------------------------------------*
32* CLAW control comand code * 32* CLAW control command code *
33*------------------------------------------------------*/ 33*------------------------------------------------------*/
34 34
35#define SYSTEM_VALIDATE_REQUEST 0x01 /* System Validate request */ 35#define SYSTEM_VALIDATE_REQUEST 0x01 /* System Validate request */
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 16ac68c27a27..66a8aec6efa6 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -1147,7 +1147,7 @@ list_modified:
1147 * get mac address for the relevant Multicast address 1147 * get mac address for the relevant Multicast address
1148 */ 1148 */
1149static void 1149static void
1150lcs_get_mac_for_ipm(__u32 ipm, char *mac, struct net_device *dev) 1150lcs_get_mac_for_ipm(__be32 ipm, char *mac, struct net_device *dev)
1151{ 1151{
1152 LCS_DBF_TEXT(4,trace, "getmac"); 1152 LCS_DBF_TEXT(4,trace, "getmac");
1153 if (dev->type == ARPHRD_IEEE802_TR) 1153 if (dev->type == ARPHRD_IEEE802_TR)
diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
index 93143932983b..b5247dc08b57 100644
--- a/drivers/s390/net/lcs.h
+++ b/drivers/s390/net/lcs.h
@@ -169,7 +169,7 @@ struct lcs_header {
169} __attribute__ ((packed)); 169} __attribute__ ((packed));
170 170
171struct lcs_ip_mac_pair { 171struct lcs_ip_mac_pair {
172 __u32 ip_addr; 172 __be32 ip_addr;
173 __u8 mac_addr[LCS_MAC_LENGTH]; 173 __u8 mac_addr[LCS_MAC_LENGTH];
174 __u8 reserved[2]; 174 __u8 reserved[2];
175} __attribute__ ((packed)); 175} __attribute__ ((packed));
@@ -287,7 +287,7 @@ struct lcs_card {
287 enum lcs_dev_states state; 287 enum lcs_dev_states state;
288 struct net_device *dev; 288 struct net_device *dev;
289 struct net_device_stats stats; 289 struct net_device_stats stats;
290 unsigned short (*lan_type_trans)(struct sk_buff *skb, 290 __be16 (*lan_type_trans)(struct sk_buff *skb,
291 struct net_device *dev); 291 struct net_device *dev);
292 struct ccwgroup_device *gdev; 292 struct ccwgroup_device *gdev;
293 struct lcs_channel read; 293 struct lcs_channel read;
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index a363721cf28d..6bb558a9a032 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -258,7 +258,7 @@ qeth_eddp_create_segment_hdrs(struct qeth_eddp_context *ctx,
258 258
259static inline void 259static inline void
260qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len, 260qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
261 u32 *hcsum) 261 __wsum *hcsum)
262{ 262{
263 struct skb_frag_struct *frag; 263 struct skb_frag_struct *frag;
264 int left_in_frag; 264 int left_in_frag;
@@ -305,7 +305,7 @@ qeth_eddp_copy_data_tcp(char *dst, struct qeth_eddp_data *eddp, int len,
305static inline void 305static inline void
306qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx, 306qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx,
307 struct qeth_eddp_data *eddp, int data_len, 307 struct qeth_eddp_data *eddp, int data_len,
308 u32 hcsum) 308 __wsum hcsum)
309{ 309{
310 u8 *page; 310 u8 *page;
311 int page_remainder; 311 int page_remainder;
@@ -349,10 +349,10 @@ qeth_eddp_create_segment_data_tcp(struct qeth_eddp_context *ctx,
349 ((struct tcphdr *)eddp->th_in_ctx)->check = csum_fold(hcsum); 349 ((struct tcphdr *)eddp->th_in_ctx)->check = csum_fold(hcsum);
350} 350}
351 351
352static inline u32 352static inline __wsum
353qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len) 353qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len)
354{ 354{
355 u32 phcsum; /* pseudo header checksum */ 355 __wsum phcsum; /* pseudo header checksum */
356 356
357 QETH_DBF_TEXT(trace, 5, "eddpckt4"); 357 QETH_DBF_TEXT(trace, 5, "eddpckt4");
358 eddp->th.tcp.h.check = 0; 358 eddp->th.tcp.h.check = 0;
@@ -363,11 +363,11 @@ qeth_eddp_check_tcp4_hdr(struct qeth_eddp_data *eddp, int data_len)
363 return csum_partial((u8 *)&eddp->th, eddp->thl, phcsum); 363 return csum_partial((u8 *)&eddp->th, eddp->thl, phcsum);
364} 364}
365 365
366static inline u32 366static inline __wsum
367qeth_eddp_check_tcp6_hdr(struct qeth_eddp_data *eddp, int data_len) 367qeth_eddp_check_tcp6_hdr(struct qeth_eddp_data *eddp, int data_len)
368{ 368{
369 u32 proto; 369 __be32 proto;
370 u32 phcsum; /* pseudo header checksum */ 370 __wsum phcsum; /* pseudo header checksum */
371 371
372 QETH_DBF_TEXT(trace, 5, "eddpckt6"); 372 QETH_DBF_TEXT(trace, 5, "eddpckt6");
373 eddp->th.tcp.h.check = 0; 373 eddp->th.tcp.h.check = 0;
@@ -405,7 +405,7 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
405{ 405{
406 struct tcphdr *tcph; 406 struct tcphdr *tcph;
407 int data_len; 407 int data_len;
408 u32 hcsum; 408 __wsum hcsum;
409 409
410 QETH_DBF_TEXT(trace, 5, "eddpftcp"); 410 QETH_DBF_TEXT(trace, 5, "eddpftcp");
411 eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl; 411 eddp->skb_offset = sizeof(struct qeth_hdr) + eddp->nhl + eddp->thl;
@@ -433,22 +433,22 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
433 eddp->qh.hdr.l3.length = data_len + eddp->nhl + 433 eddp->qh.hdr.l3.length = data_len + eddp->nhl +
434 eddp->thl; 434 eddp->thl;
435 /* prepare ip hdr */ 435 /* prepare ip hdr */
436 if (eddp->skb->protocol == ETH_P_IP){ 436 if (eddp->skb->protocol == htons(ETH_P_IP)){
437 eddp->nh.ip4.h.tot_len = data_len + eddp->nhl + 437 eddp->nh.ip4.h.tot_len = htons(data_len + eddp->nhl +
438 eddp->thl; 438 eddp->thl);
439 eddp->nh.ip4.h.check = 0; 439 eddp->nh.ip4.h.check = 0;
440 eddp->nh.ip4.h.check = 440 eddp->nh.ip4.h.check =
441 ip_fast_csum((u8 *)&eddp->nh.ip4.h, 441 ip_fast_csum((u8 *)&eddp->nh.ip4.h,
442 eddp->nh.ip4.h.ihl); 442 eddp->nh.ip4.h.ihl);
443 } else 443 } else
444 eddp->nh.ip6.h.payload_len = data_len + eddp->thl; 444 eddp->nh.ip6.h.payload_len = htons(data_len + eddp->thl);
445 /* prepare tcp hdr */ 445 /* prepare tcp hdr */
446 if (data_len == (eddp->skb->len - eddp->skb_offset)){ 446 if (data_len == (eddp->skb->len - eddp->skb_offset)){
447 /* last segment -> set FIN and PSH flags */ 447 /* last segment -> set FIN and PSH flags */
448 eddp->th.tcp.h.fin = tcph->fin; 448 eddp->th.tcp.h.fin = tcph->fin;
449 eddp->th.tcp.h.psh = tcph->psh; 449 eddp->th.tcp.h.psh = tcph->psh;
450 } 450 }
451 if (eddp->skb->protocol == ETH_P_IP) 451 if (eddp->skb->protocol == htons(ETH_P_IP))
452 hcsum = qeth_eddp_check_tcp4_hdr(eddp, data_len); 452 hcsum = qeth_eddp_check_tcp4_hdr(eddp, data_len);
453 else 453 else
454 hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len); 454 hcsum = qeth_eddp_check_tcp6_hdr(eddp, data_len);
@@ -458,9 +458,9 @@ __qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
458 if (eddp->skb_offset >= eddp->skb->len) 458 if (eddp->skb_offset >= eddp->skb->len)
459 break; 459 break;
460 /* prepare headers for next round */ 460 /* prepare headers for next round */
461 if (eddp->skb->protocol == ETH_P_IP) 461 if (eddp->skb->protocol == htons(ETH_P_IP))
462 eddp->nh.ip4.h.id++; 462 eddp->nh.ip4.h.id = htons(ntohs(eddp->nh.ip4.h.id) + 1);
463 eddp->th.tcp.h.seq += data_len; 463 eddp->th.tcp.h.seq = htonl(ntohl(eddp->th.tcp.h.seq) + data_len);
464 } 464 }
465} 465}
466 466
@@ -472,7 +472,7 @@ qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
472 472
473 QETH_DBF_TEXT(trace, 5, "eddpficx"); 473 QETH_DBF_TEXT(trace, 5, "eddpficx");
474 /* create our segmentation headers and copy original headers */ 474 /* create our segmentation headers and copy original headers */
475 if (skb->protocol == ETH_P_IP) 475 if (skb->protocol == htons(ETH_P_IP))
476 eddp = qeth_eddp_create_eddp_data(qhdr, (u8 *)skb->nh.iph, 476 eddp = qeth_eddp_create_eddp_data(qhdr, (u8 *)skb->nh.iph,
477 skb->nh.iph->ihl*4, 477 skb->nh.iph->ihl*4,
478 (u8 *)skb->h.th, skb->h.th->doff*4); 478 (u8 *)skb->h.th, skb->h.th->doff*4);
@@ -490,7 +490,7 @@ qeth_eddp_fill_context_tcp(struct qeth_eddp_context *ctx,
490 memcpy(&eddp->mac, eth_hdr(skb), ETH_HLEN); 490 memcpy(&eddp->mac, eth_hdr(skb), ETH_HLEN);
491#ifdef CONFIG_QETH_VLAN 491#ifdef CONFIG_QETH_VLAN
492 if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) { 492 if (eddp->mac.h_proto == __constant_htons(ETH_P_8021Q)) {
493 eddp->vlan[0] = __constant_htons(skb->protocol); 493 eddp->vlan[0] = skb->protocol;
494 eddp->vlan[1] = htons(vlan_tx_tag_get(skb)); 494 eddp->vlan[1] = htons(vlan_tx_tag_get(skb));
495 } 495 }
496#endif /* CONFIG_QETH_VLAN */ 496#endif /* CONFIG_QETH_VLAN */
@@ -588,11 +588,11 @@ qeth_eddp_create_context_tcp(struct qeth_card *card, struct sk_buff *skb,
588 struct qeth_eddp_context *ctx = NULL; 588 struct qeth_eddp_context *ctx = NULL;
589 589
590 QETH_DBF_TEXT(trace, 5, "creddpct"); 590 QETH_DBF_TEXT(trace, 5, "creddpct");
591 if (skb->protocol == ETH_P_IP) 591 if (skb->protocol == htons(ETH_P_IP))
592 ctx = qeth_eddp_create_context_generic(card, skb, 592 ctx = qeth_eddp_create_context_generic(card, skb,
593 sizeof(struct qeth_hdr) + skb->nh.iph->ihl*4 + 593 sizeof(struct qeth_hdr) + skb->nh.iph->ihl*4 +
594 skb->h.th->doff*4); 594 skb->h.th->doff*4);
595 else if (skb->protocol == ETH_P_IPV6) 595 else if (skb->protocol == htons(ETH_P_IPV6))
596 ctx = qeth_eddp_create_context_generic(card, skb, 596 ctx = qeth_eddp_create_context_generic(card, skb,
597 sizeof(struct qeth_hdr) + sizeof(struct ipv6hdr) + 597 sizeof(struct qeth_hdr) + sizeof(struct ipv6hdr) +
598 skb->h.th->doff*4); 598 skb->h.th->doff*4);
diff --git a/drivers/s390/net/qeth_eddp.h b/drivers/s390/net/qeth_eddp.h
index cae9ba265056..103768d3bab2 100644
--- a/drivers/s390/net/qeth_eddp.h
+++ b/drivers/s390/net/qeth_eddp.h
@@ -54,7 +54,7 @@ qeth_eddp_check_buffers_for_context(struct qeth_qdio_out_q *,
54struct qeth_eddp_data { 54struct qeth_eddp_data {
55 struct qeth_hdr qh; 55 struct qeth_hdr qh;
56 struct ethhdr mac; 56 struct ethhdr mac;
57 u16 vlan[2]; 57 __be16 vlan[2];
58 union { 58 union {
59 struct { 59 struct {
60 struct iphdr h; 60 struct iphdr h;
diff --git a/drivers/scsi/aic94xx/aic94xx_reg_def.h b/drivers/scsi/aic94xx/aic94xx_reg_def.h
index b79f45f3ad47..a11f4e6d8bd9 100644
--- a/drivers/scsi/aic94xx/aic94xx_reg_def.h
+++ b/drivers/scsi/aic94xx/aic94xx_reg_def.h
@@ -2000,7 +2000,7 @@
2000 * The host accesses this scratch in a different manner from the 2000 * The host accesses this scratch in a different manner from the
2001 * central sequencer. The sequencer has to use CSEQ registers CSCRPAGE 2001 * central sequencer. The sequencer has to use CSEQ registers CSCRPAGE
2002 * and CMnSCRPAGE to access the scratch memory. A flat mapping of the 2002 * and CMnSCRPAGE to access the scratch memory. A flat mapping of the
2003 * scratch memory is avaliable for software convenience and to prevent 2003 * scratch memory is available for software convenience and to prevent
2004 * corruption while the sequencer is running. This memory is mapped 2004 * corruption while the sequencer is running. This memory is mapped
2005 * onto addresses 800h - BFFh, total of 400h bytes. 2005 * onto addresses 800h - BFFh, total of 400h bytes.
2006 * 2006 *
diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c
index de7c04d4254d..e5a0ec37e954 100644
--- a/drivers/scsi/aic94xx/aic94xx_sds.c
+++ b/drivers/scsi/aic94xx/aic94xx_sds.c
@@ -64,7 +64,7 @@ struct asd_ocm_dir {
64 64
65#define OCM_INIT_DIR_ENTRIES 5 65#define OCM_INIT_DIR_ENTRIES 5
66/*************************************************************************** 66/***************************************************************************
67* OCM dircetory default 67* OCM directory default
68***************************************************************************/ 68***************************************************************************/
69static struct asd_ocm_dir OCMDirInit = 69static struct asd_ocm_dir OCMDirInit =
70{ 70{
@@ -73,7 +73,7 @@ static struct asd_ocm_dir OCMDirInit =
73}; 73};
74 74
75/*************************************************************************** 75/***************************************************************************
76* OCM dircetory Entries default 76* OCM directory Entries default
77***************************************************************************/ 77***************************************************************************/
78static struct asd_ocm_dir_ent OCMDirEntriesInit[OCM_INIT_DIR_ENTRIES] = 78static struct asd_ocm_dir_ent OCMDirEntriesInit[OCM_INIT_DIR_ENTRIES] =
79{ 79{
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 6cc2bc2f62be..adb8eb4f5fd1 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -185,7 +185,7 @@ static inline struct list_head *ncr_list_pop(struct list_head *head)
185** power of 2 cache line size. 185** power of 2 cache line size.
186** Enhanced in linux-2.3.44 to provide a memory pool 186** Enhanced in linux-2.3.44 to provide a memory pool
187** per pcidev to support dynamic dma mapping. (I would 187** per pcidev to support dynamic dma mapping. (I would
188** have preferred a real bus astraction, btw). 188** have preferred a real bus abstraction, btw).
189** 189**
190**========================================================== 190**==========================================================
191*/ 191*/
@@ -1438,7 +1438,7 @@ struct head {
1438** The first four bytes (scr_st[4]) are used inside the script by 1438** The first four bytes (scr_st[4]) are used inside the script by
1439** "COPY" commands. 1439** "COPY" commands.
1440** Because source and destination must have the same alignment 1440** Because source and destination must have the same alignment
1441** in a DWORD, the fields HAVE to be at the choosen offsets. 1441** in a DWORD, the fields HAVE to be at the chosen offsets.
1442** xerr_st 0 (0x34) scratcha 1442** xerr_st 0 (0x34) scratcha
1443** sync_st 1 (0x05) sxfer 1443** sync_st 1 (0x05) sxfer
1444** wide_st 3 (0x03) scntl3 1444** wide_st 3 (0x03) scntl3
@@ -1498,7 +1498,7 @@ struct head {
1498** the DSA (data structure address) register points 1498** the DSA (data structure address) register points
1499** to this substructure of the ccb. 1499** to this substructure of the ccb.
1500** This substructure contains the header with 1500** This substructure contains the header with
1501** the script-processor-changable data and 1501** the script-processor-changeable data and
1502** data blocks for the indirect move commands. 1502** data blocks for the indirect move commands.
1503** 1503**
1504**---------------------------------------------------------- 1504**----------------------------------------------------------
@@ -5107,7 +5107,7 @@ void ncr_complete (struct ncb *np, struct ccb *cp)
5107 5107
5108/* 5108/*
5109** This CCB has been skipped by the NCR. 5109** This CCB has been skipped by the NCR.
5110** Queue it in the correponding unit queue. 5110** Queue it in the corresponding unit queue.
5111*/ 5111*/
5112static void ncr_ccb_skipped(struct ncb *np, struct ccb *cp) 5112static void ncr_ccb_skipped(struct ncb *np, struct ccb *cp)
5113{ 5113{
@@ -5896,8 +5896,8 @@ static void ncr_log_hard_error(struct ncb *np, u16 sist, u_char dstat)
5896** 5896**
5897** In normal cases, interrupt conditions occur one at a 5897** In normal cases, interrupt conditions occur one at a
5898** time. The ncr is able to stack in some extra registers 5898** time. The ncr is able to stack in some extra registers
5899** other interrupts that will occurs after the first one. 5899** other interrupts that will occur after the first one.
5900** But severall interrupts may occur at the same time. 5900** But, several interrupts may occur at the same time.
5901** 5901**
5902** We probably should only try to deal with the normal 5902** We probably should only try to deal with the normal
5903** case, but it seems that multiple interrupts occur in 5903** case, but it seems that multiple interrupts occur in
@@ -6796,7 +6796,7 @@ void ncr_int_sir (struct ncb *np)
6796** The host status field is set to HS_NEGOTIATE to mark this 6796** The host status field is set to HS_NEGOTIATE to mark this
6797** situation. 6797** situation.
6798** 6798**
6799** If the target doesn't answer this message immidiately 6799** If the target doesn't answer this message immediately
6800** (as required by the standard), the SIR_NEGO_FAIL interrupt 6800** (as required by the standard), the SIR_NEGO_FAIL interrupt
6801** will be raised eventually. 6801** will be raised eventually.
6802** The handler removes the HS_NEGOTIATE status, and sets the 6802** The handler removes the HS_NEGOTIATE status, and sets the
diff --git a/drivers/scsi/ncr53c8xx.h b/drivers/scsi/ncr53c8xx.h
index cb8b7701431e..b39357d9af8d 100644
--- a/drivers/scsi/ncr53c8xx.h
+++ b/drivers/scsi/ncr53c8xx.h
@@ -218,7 +218,7 @@
218** Same as option 1, but also deal with 218** Same as option 1, but also deal with
219** misconfigured interrupts. 219** misconfigured interrupts.
220** 220**
221** - Edge triggerred instead of level sensitive. 221** - Edge triggered instead of level sensitive.
222** - No interrupt line connected. 222** - No interrupt line connected.
223** - IRQ number misconfigured. 223** - IRQ number misconfigured.
224** 224**
@@ -549,7 +549,7 @@ struct ncr_driver_setup {
549 549
550/* 550/*
551** Initial setup. 551** Initial setup.
552** Can be overriden at startup by a command line. 552** Can be overridden at startup by a command line.
553*/ 553*/
554#define SCSI_NCR_DRIVER_SETUP \ 554#define SCSI_NCR_DRIVER_SETUP \
555{ \ 555{ \
@@ -1093,7 +1093,7 @@ struct scr_tblsel {
1093**----------------------------------------------------------- 1093**-----------------------------------------------------------
1094** On 810A, 860, 825A, 875, 895 and 896 chips the content 1094** On 810A, 860, 825A, 875, 895 and 896 chips the content
1095** of SFBR register can be used as data (SCR_SFBR_DATA). 1095** of SFBR register can be used as data (SCR_SFBR_DATA).
1096** The 896 has additionnal IO registers starting at 1096** The 896 has additional IO registers starting at
1097** offset 0x80. Bit 7 of register offset is stored in 1097** offset 0x80. Bit 7 of register offset is stored in
1098** bit 7 of the SCRIPTS instruction first DWORD. 1098** bit 7 of the SCRIPTS instruction first DWORD.
1099**----------------------------------------------------------- 1099**-----------------------------------------------------------
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 23334c8bc4c7..d895a1adb428 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -16,7 +16,7 @@ config SPI
16 controller and a chipselect. Most SPI slaves don't support 16 controller and a chipselect. Most SPI slaves don't support
17 dynamic device discovery; some are even write-only or read-only. 17 dynamic device discovery; some are even write-only or read-only.
18 18
19 SPI is widely used by microcontollers to talk with sensors, 19 SPI is widely used by microcontrollers to talk with sensors,
20 eeprom and flash memory, codecs and various other controller 20 eeprom and flash memory, codecs and various other controller
21 chips, analog to digital (and d-to-a) converters, and more. 21 chips, analog to digital (and d-to-a) converters, and more.
22 MMC and SD cards can be accessed using SPI protocol; and for 22 MMC and SD cards can be accessed using SPI protocol; and for
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 7ed34bb1c50f..8ed6c75adf0f 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -837,8 +837,8 @@ static int speedtch_bind(struct usbatm_data *usbatm,
837 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc; 837 const struct usb_endpoint_descriptor *endpoint_desc = &desc->endpoint[i].desc;
838 838
839 if ((endpoint_desc->bEndpointAddress == target_address)) { 839 if ((endpoint_desc->bEndpointAddress == target_address)) {
840 use_isoc = (endpoint_desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 840 use_isoc =
841 USB_ENDPOINT_XFER_ISOC; 841 usb_endpoint_xfer_isoc(endpoint_desc);
842 break; 842 break;
843 } 843 }
844 } 844 }
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index e39bb09f5af9..f2d196fa1e8b 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -401,9 +401,8 @@ static int uea_send_modem_cmd(struct usb_device *usb,
401 int ret = -ENOMEM; 401 int ret = -ENOMEM;
402 u8 *xfer_buff; 402 u8 *xfer_buff;
403 403
404 xfer_buff = kmalloc(size, GFP_KERNEL); 404 xfer_buff = kmemdup(buff, size, GFP_KERNEL);
405 if (xfer_buff) { 405 if (xfer_buff) {
406 memcpy(xfer_buff, buff, size);
407 ret = usb_control_msg(usb, 406 ret = usb_control_msg(usb,
408 usb_sndctrlpipe(usb, 0), 407 usb_sndctrlpipe(usb, 0),
409 LOAD_INTERNAL, 408 LOAD_INTERNAL,
@@ -595,14 +594,12 @@ static int uea_idma_write(struct uea_softc *sc, void *data, u32 size)
595 u8 *xfer_buff; 594 u8 *xfer_buff;
596 int bytes_read; 595 int bytes_read;
597 596
598 xfer_buff = kmalloc(size, GFP_KERNEL); 597 xfer_buff = kmemdup(data, size, GFP_KERNEL);
599 if (!xfer_buff) { 598 if (!xfer_buff) {
600 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); 599 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
601 return ret; 600 return ret;
602 } 601 }
603 602
604 memcpy(xfer_buff, data, size);
605
606 ret = usb_bulk_msg(sc->usb_dev, 603 ret = usb_bulk_msg(sc->usb_dev,
607 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE), 604 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
608 xfer_buff, size, &bytes_read, BULK_TIMEOUT); 605 xfer_buff, size, &bytes_read, BULK_TIMEOUT);
@@ -765,12 +762,11 @@ static int uea_request(struct uea_softc *sc,
765 u8 *xfer_buff; 762 u8 *xfer_buff;
766 int ret = -ENOMEM; 763 int ret = -ENOMEM;
767 764
768 xfer_buff = kmalloc(size, GFP_KERNEL); 765 xfer_buff = kmemdup(data, size, GFP_KERNEL);
769 if (!xfer_buff) { 766 if (!xfer_buff) {
770 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); 767 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
771 return ret; 768 return ret;
772 } 769 }
773 memcpy(xfer_buff, data, size);
774 770
775 ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0), 771 ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
776 UCDC_SEND_ENCAPSULATED_COMMAND, 772 UCDC_SEND_ENCAPSULATED_COMMAND,
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 6408e10fdbf8..7f1fa956dcdb 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -892,7 +892,7 @@ skip_normal_probe:
892 892
893 893
894 /* workaround for switched endpoints */ 894 /* workaround for switched endpoints */
895 if ((epread->bEndpointAddress & USB_DIR_IN) != USB_DIR_IN) { 895 if (!usb_endpoint_dir_in(epread)) {
896 /* descriptors are swapped */ 896 /* descriptors are swapped */
897 struct usb_endpoint_descriptor *t; 897 struct usb_endpoint_descriptor *t;
898 dev_dbg(&intf->dev,"The data interface has switched endpoints"); 898 dev_dbg(&intf->dev,"The data interface has switched endpoints");
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 6e3b5358a760..f8324d8d06ac 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -72,6 +72,21 @@ config USB_SUSPEND
72 72
73 If you are unsure about this, say N here. 73 If you are unsure about this, say N here.
74 74
75config USB_MULTITHREAD_PROBE
76 bool "USB Multi-threaded probe (EXPERIMENTAL)"
77 depends on USB && EXPERIMENTAL
78 default n
79 help
80 Say Y here if you want the USB core to spawn a new thread for
81 every USB device that is probed. This can cause a small speedup
82 in boot times on systems with a lot of different USB devices.
83
84 This option should be safe to enable, but if any odd probing
85 problems are found, please disable it, or dynamically turn it
86 off in the /sys/module/usbcore/parameters/multithread_probe
87 file
88
89 When in doubt, say N.
75 90
76config USB_OTG 91config USB_OTG
77 bool 92 bool
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 3538c2fdadfe..ea398e5d50af 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -175,12 +175,13 @@ static char *usb_dump_endpoint_descriptor (
175) 175)
176{ 176{
177 char dir, unit, *type; 177 char dir, unit, *type;
178 unsigned interval, in, bandwidth = 1; 178 unsigned interval, bandwidth = 1;
179 179
180 if (start > end) 180 if (start > end)
181 return start; 181 return start;
182 in = (desc->bEndpointAddress & USB_DIR_IN); 182
183 dir = in ? 'I' : 'O'; 183 dir = usb_endpoint_dir_in(desc) ? 'I' : 'O';
184
184 if (speed == USB_SPEED_HIGH) { 185 if (speed == USB_SPEED_HIGH) {
185 switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) { 186 switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) {
186 case 1 << 11: bandwidth = 2; break; 187 case 1 << 11: bandwidth = 2; break;
@@ -204,7 +205,7 @@ static char *usb_dump_endpoint_descriptor (
204 break; 205 break;
205 case USB_ENDPOINT_XFER_BULK: 206 case USB_ENDPOINT_XFER_BULK:
206 type = "Bulk"; 207 type = "Bulk";
207 if (speed == USB_SPEED_HIGH && !in) /* uframes per NAK */ 208 if (speed == USB_SPEED_HIGH && dir == 'O') /* uframes per NAK */
208 interval = desc->bInterval; 209 interval = desc->bInterval;
209 else 210 else
210 interval = 0; 211 interval = 0;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index fed92be63b5e..3ed4cb2d56d9 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -561,7 +561,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
561 dev = inode->i_private; 561 dev = inode->i_private;
562 if (!dev) 562 if (!dev)
563 goto out; 563 goto out;
564 ret = usb_autoresume_device(dev, 1); 564 ret = usb_autoresume_device(dev);
565 if (ret) 565 if (ret)
566 goto out; 566 goto out;
567 567
@@ -609,7 +609,7 @@ static int usbdev_release(struct inode *inode, struct file *file)
609 releaseintf(ps, ifnum); 609 releaseintf(ps, ifnum);
610 } 610 }
611 destroy_all_async(ps); 611 destroy_all_async(ps);
612 usb_autosuspend_device(dev, 1); 612 usb_autosuspend_device(dev);
613 usb_unlock_device(dev); 613 usb_unlock_device(dev);
614 usb_put_dev(dev); 614 usb_put_dev(dev);
615 put_pid(ps->disc_pid); 615 put_pid(ps->disc_pid);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 113e484c763e..d6eb5ce1dd1d 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -205,7 +205,7 @@ static int usb_probe_interface(struct device *dev)
205 if (id) { 205 if (id) {
206 dev_dbg(dev, "%s - got id\n", __FUNCTION__); 206 dev_dbg(dev, "%s - got id\n", __FUNCTION__);
207 207
208 error = usb_autoresume_device(udev, 1); 208 error = usb_autoresume_device(udev);
209 if (error) 209 if (error)
210 return error; 210 return error;
211 211
@@ -229,7 +229,7 @@ static int usb_probe_interface(struct device *dev)
229 } else 229 } else
230 intf->condition = USB_INTERFACE_BOUND; 230 intf->condition = USB_INTERFACE_BOUND;
231 231
232 usb_autosuspend_device(udev, 1); 232 usb_autosuspend_device(udev);
233 } 233 }
234 234
235 return error; 235 return error;
@@ -247,7 +247,7 @@ static int usb_unbind_interface(struct device *dev)
247 247
248 /* Autoresume for set_interface call below */ 248 /* Autoresume for set_interface call below */
249 udev = interface_to_usbdev(intf); 249 udev = interface_to_usbdev(intf);
250 error = usb_autoresume_device(udev, 1); 250 error = usb_autoresume_device(udev);
251 251
252 /* release all urbs for this interface */ 252 /* release all urbs for this interface */
253 usb_disable_interface(interface_to_usbdev(intf), intf); 253 usb_disable_interface(interface_to_usbdev(intf), intf);
@@ -265,7 +265,7 @@ static int usb_unbind_interface(struct device *dev)
265 intf->needs_remote_wakeup = 0; 265 intf->needs_remote_wakeup = 0;
266 266
267 if (!error) 267 if (!error)
268 usb_autosuspend_device(udev, 1); 268 usb_autosuspend_device(udev);
269 269
270 return 0; 270 return 0;
271} 271}
@@ -408,6 +408,16 @@ static int usb_match_one_id(struct usb_interface *interface,
408 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) 408 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
409 return 0; 409 return 0;
410 410
411 /* The interface class, subclass, and protocol should never be
412 * checked for a match if the device class is Vendor Specific,
413 * unless the match record specifies the Vendor ID. */
414 if (dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC &&
415 !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
416 (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS |
417 USB_DEVICE_ID_MATCH_INT_SUBCLASS |
418 USB_DEVICE_ID_MATCH_INT_PROTOCOL)))
419 return 0;
420
411 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && 421 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
412 (id->bInterfaceClass != intf->desc.bInterfaceClass)) 422 (id->bInterfaceClass != intf->desc.bInterfaceClass))
413 return 0; 423 return 0;
@@ -476,7 +486,17 @@ static int usb_match_one_id(struct usb_interface *interface,
476 * most general; they let drivers bind to any interface on a 486 * most general; they let drivers bind to any interface on a
477 * multiple-function device. Use the USB_INTERFACE_INFO 487 * multiple-function device. Use the USB_INTERFACE_INFO
478 * macro, or its siblings, to match class-per-interface style 488 * macro, or its siblings, to match class-per-interface style
479 * devices (as recorded in bDeviceClass). 489 * devices (as recorded in bInterfaceClass).
490 *
491 * Note that an entry created by USB_INTERFACE_INFO won't match
492 * any interface if the device class is set to Vendor-Specific.
493 * This is deliberate; according to the USB spec the meanings of
494 * the interface class/subclass/protocol for these devices are also
495 * vendor-specific, and hence matching against a standard product
496 * class wouldn't work anyway. If you really want to use an
497 * interface-based match for such a device, create a match record
498 * that also specifies the vendor ID. (Unforunately there isn't a
499 * standard macro for creating records like this.)
480 * 500 *
481 * Within those groups, remember that not all combinations are 501 * Within those groups, remember that not all combinations are
482 * meaningful. For example, don't give a product version range 502 * meaningful. For example, don't give a product version range
@@ -505,7 +525,7 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
505} 525}
506EXPORT_SYMBOL_GPL_FUTURE(usb_match_id); 526EXPORT_SYMBOL_GPL_FUTURE(usb_match_id);
507 527
508int usb_device_match(struct device *dev, struct device_driver *drv) 528static int usb_device_match(struct device *dev, struct device_driver *drv)
509{ 529{
510 /* devices and interfaces are handled separately */ 530 /* devices and interfaces are handled separately */
511 if (is_usb_device(dev)) { 531 if (is_usb_device(dev)) {
@@ -790,7 +810,7 @@ EXPORT_SYMBOL_GPL_FUTURE(usb_deregister);
790#ifdef CONFIG_PM 810#ifdef CONFIG_PM
791 811
792/* Caller has locked udev's pm_mutex */ 812/* Caller has locked udev's pm_mutex */
793static int suspend_device(struct usb_device *udev, pm_message_t msg) 813static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
794{ 814{
795 struct usb_device_driver *udriver; 815 struct usb_device_driver *udriver;
796 int status = 0; 816 int status = 0;
@@ -817,7 +837,7 @@ done:
817} 837}
818 838
819/* Caller has locked udev's pm_mutex */ 839/* Caller has locked udev's pm_mutex */
820static int resume_device(struct usb_device *udev) 840static int usb_resume_device(struct usb_device *udev)
821{ 841{
822 struct usb_device_driver *udriver; 842 struct usb_device_driver *udriver;
823 int status = 0; 843 int status = 0;
@@ -843,7 +863,7 @@ done:
843} 863}
844 864
845/* Caller has locked intf's usb_device's pm mutex */ 865/* Caller has locked intf's usb_device's pm mutex */
846static int suspend_interface(struct usb_interface *intf, pm_message_t msg) 866static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg)
847{ 867{
848 struct usb_driver *driver; 868 struct usb_driver *driver;
849 int status = 0; 869 int status = 0;
@@ -880,7 +900,7 @@ done:
880} 900}
881 901
882/* Caller has locked intf's usb_device's pm_mutex */ 902/* Caller has locked intf's usb_device's pm_mutex */
883static int resume_interface(struct usb_interface *intf) 903static int usb_resume_interface(struct usb_interface *intf)
884{ 904{
885 struct usb_driver *driver; 905 struct usb_driver *driver;
886 int status = 0; 906 int status = 0;
@@ -920,6 +940,44 @@ done:
920 return status; 940 return status;
921} 941}
922 942
943#ifdef CONFIG_USB_SUSPEND
944
945/* Internal routine to check whether we may autosuspend a device. */
946static int autosuspend_check(struct usb_device *udev)
947{
948 int i;
949 struct usb_interface *intf;
950
951 /* For autosuspend, fail fast if anything is in use.
952 * Also fail if any interfaces require remote wakeup but it
953 * isn't available. */
954 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
955 if (udev->pm_usage_cnt > 0)
956 return -EBUSY;
957 if (udev->actconfig) {
958 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
959 intf = udev->actconfig->interface[i];
960 if (!is_active(intf))
961 continue;
962 if (intf->pm_usage_cnt > 0)
963 return -EBUSY;
964 if (intf->needs_remote_wakeup &&
965 !udev->do_remote_wakeup) {
966 dev_dbg(&udev->dev, "remote wakeup needed "
967 "for autosuspend\n");
968 return -EOPNOTSUPP;
969 }
970 }
971 }
972 return 0;
973}
974
975#else
976
977#define autosuspend_check(udev) 0
978
979#endif
980
923/** 981/**
924 * usb_suspend_both - suspend a USB device and its interfaces 982 * usb_suspend_both - suspend a USB device and its interfaces
925 * @udev: the usb_device to suspend 983 * @udev: the usb_device to suspend
@@ -971,52 +1029,34 @@ int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
971 1029
972 udev->do_remote_wakeup = device_may_wakeup(&udev->dev); 1030 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
973 1031
974 /* For autosuspend, fail fast if anything is in use.
975 * Also fail if any interfaces require remote wakeup but it
976 * isn't available. */
977 if (udev->auto_pm) { 1032 if (udev->auto_pm) {
978 if (udev->pm_usage_cnt > 0) 1033 status = autosuspend_check(udev);
979 return -EBUSY; 1034 if (status < 0)
980 if (udev->actconfig) { 1035 return status;
981 for (; i < udev->actconfig->desc.bNumInterfaces; i++) {
982 intf = udev->actconfig->interface[i];
983 if (!is_active(intf))
984 continue;
985 if (intf->pm_usage_cnt > 0)
986 return -EBUSY;
987 if (intf->needs_remote_wakeup &&
988 !udev->do_remote_wakeup) {
989 dev_dbg(&udev->dev,
990 "remote wakeup needed for autosuspend\n");
991 return -EOPNOTSUPP;
992 }
993 }
994 i = 0;
995 }
996 } 1036 }
997 1037
998 /* Suspend all the interfaces and then udev itself */ 1038 /* Suspend all the interfaces and then udev itself */
999 if (udev->actconfig) { 1039 if (udev->actconfig) {
1000 for (; i < udev->actconfig->desc.bNumInterfaces; i++) { 1040 for (; i < udev->actconfig->desc.bNumInterfaces; i++) {
1001 intf = udev->actconfig->interface[i]; 1041 intf = udev->actconfig->interface[i];
1002 status = suspend_interface(intf, msg); 1042 status = usb_suspend_interface(intf, msg);
1003 if (status != 0) 1043 if (status != 0)
1004 break; 1044 break;
1005 } 1045 }
1006 } 1046 }
1007 if (status == 0) 1047 if (status == 0)
1008 status = suspend_device(udev, msg); 1048 status = usb_suspend_device(udev, msg);
1009 1049
1010 /* If the suspend failed, resume interfaces that did get suspended */ 1050 /* If the suspend failed, resume interfaces that did get suspended */
1011 if (status != 0) { 1051 if (status != 0) {
1012 while (--i >= 0) { 1052 while (--i >= 0) {
1013 intf = udev->actconfig->interface[i]; 1053 intf = udev->actconfig->interface[i];
1014 resume_interface(intf); 1054 usb_resume_interface(intf);
1015 } 1055 }
1016 1056
1017 /* If the suspend succeeded, propagate it up the tree */ 1057 /* If the suspend succeeded, propagate it up the tree */
1018 } else if (parent) 1058 } else if (parent)
1019 usb_autosuspend_device(parent, 0); 1059 usb_autosuspend_device(parent);
1020 1060
1021 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); 1061 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
1022 return status; 1062 return status;
@@ -1064,9 +1104,25 @@ int usb_resume_both(struct usb_device *udev)
1064 /* Propagate the resume up the tree, if necessary */ 1104 /* Propagate the resume up the tree, if necessary */
1065 if (udev->state == USB_STATE_SUSPENDED) { 1105 if (udev->state == USB_STATE_SUSPENDED) {
1066 if (parent) { 1106 if (parent) {
1067 usb_pm_lock(parent); 1107 status = usb_autoresume_device(parent);
1068 parent->auto_pm = 1; 1108 if (status == 0) {
1069 status = usb_resume_both(parent); 1109 status = usb_resume_device(udev);
1110 if (status) {
1111 usb_autosuspend_device(parent);
1112
1113 /* It's possible usb_resume_device()
1114 * failed after the port was
1115 * unsuspended, causing udev to be
1116 * logically disconnected. We don't
1117 * want usb_disconnect() to autosuspend
1118 * the parent again, so tell it that
1119 * udev disconnected while still
1120 * suspended. */
1121 if (udev->state ==
1122 USB_STATE_NOTATTACHED)
1123 udev->discon_suspended = 1;
1124 }
1125 }
1070 } else { 1126 } else {
1071 1127
1072 /* We can't progagate beyond the USB subsystem, 1128 /* We can't progagate beyond the USB subsystem,
@@ -1075,24 +1131,20 @@ int usb_resume_both(struct usb_device *udev)
1075 if (udev->dev.parent->power.power_state.event != 1131 if (udev->dev.parent->power.power_state.event !=
1076 PM_EVENT_ON) 1132 PM_EVENT_ON)
1077 status = -EHOSTUNREACH; 1133 status = -EHOSTUNREACH;
1078 } 1134 else
1079 if (status == 0) 1135 status = usb_resume_device(udev);
1080 status = resume_device(udev); 1136 }
1081 if (parent)
1082 usb_pm_unlock(parent);
1083 } else { 1137 } else {
1084 1138
1085 /* Needed only for setting udev->dev.power.power_state.event 1139 /* Needed only for setting udev->dev.power.power_state.event
1086 * and for possible debugging message. */ 1140 * and for possible debugging message. */
1087 status = resume_device(udev); 1141 status = usb_resume_device(udev);
1088 } 1142 }
1089 1143
1090 /* Now the parent won't suspend until we are finished */
1091
1092 if (status == 0 && udev->actconfig) { 1144 if (status == 0 && udev->actconfig) {
1093 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1145 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1094 intf = udev->actconfig->interface[i]; 1146 intf = udev->actconfig->interface[i];
1095 resume_interface(intf); 1147 usb_resume_interface(intf);
1096 } 1148 }
1097 } 1149 }
1098 1150
@@ -1102,39 +1154,53 @@ int usb_resume_both(struct usb_device *udev)
1102 1154
1103#ifdef CONFIG_USB_SUSPEND 1155#ifdef CONFIG_USB_SUSPEND
1104 1156
1157/* Internal routine to adjust a device's usage counter and change
1158 * its autosuspend state.
1159 */
1160static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
1161{
1162 int status = 0;
1163
1164 usb_pm_lock(udev);
1165 udev->pm_usage_cnt += inc_usage_cnt;
1166 WARN_ON(udev->pm_usage_cnt < 0);
1167 if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) {
1168 udev->auto_pm = 1;
1169 status = usb_resume_both(udev);
1170 if (status != 0)
1171 udev->pm_usage_cnt -= inc_usage_cnt;
1172 } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0)
1173 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1174 USB_AUTOSUSPEND_DELAY);
1175 usb_pm_unlock(udev);
1176 return status;
1177}
1178
1105/** 1179/**
1106 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces 1180 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces
1107 * @udev: the usb_device to autosuspend 1181 * @udev: the usb_device to autosuspend
1108 * @dec_usage_cnt: flag to decrement @udev's PM-usage counter
1109 * 1182 *
1110 * This routine should be called when a core subsystem is finished using 1183 * This routine should be called when a core subsystem is finished using
1111 * @udev and wants to allow it to autosuspend. Examples would be when 1184 * @udev and wants to allow it to autosuspend. Examples would be when
1112 * @udev's device file in usbfs is closed or after a configuration change. 1185 * @udev's device file in usbfs is closed or after a configuration change.
1113 * 1186 *
1114 * @dec_usage_cnt should be 1 if the subsystem previously incremented 1187 * @udev's usage counter is decremented. If it or any of the usage counters
1115 * @udev's usage counter (such as by passing 1 to usb_autoresume_device); 1188 * for an active interface is greater than 0, no autosuspend request will be
1116 * otherwise it should be 0. 1189 * queued. (If an interface driver does not support autosuspend then its
1117 * 1190 * usage counter is permanently positive.) Furthermore, if an interface
1118 * If the usage counter for @udev or any of its active interfaces is greater 1191 * driver requires remote-wakeup capability during autosuspend but remote
1119 * than 0, the autosuspend request will not be queued. (If an interface 1192 * wakeup is disabled, the autosuspend will fail.
1120 * driver does not support autosuspend then its usage counter is permanently
1121 * positive.) Likewise, if an interface driver requires remote-wakeup
1122 * capability during autosuspend but remote wakeup is disabled, the
1123 * autosuspend will fail.
1124 * 1193 *
1125 * Often the caller will hold @udev's device lock, but this is not 1194 * Often the caller will hold @udev's device lock, but this is not
1126 * necessary. 1195 * necessary.
1127 * 1196 *
1128 * This routine can run only in process context. 1197 * This routine can run only in process context.
1129 */ 1198 */
1130void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt) 1199void usb_autosuspend_device(struct usb_device *udev)
1131{ 1200{
1132 usb_pm_lock(udev); 1201 int status;
1133 udev->pm_usage_cnt -= dec_usage_cnt; 1202
1134 if (udev->pm_usage_cnt <= 0) 1203 status = usb_autopm_do_device(udev, -1);
1135 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1136 USB_AUTOSUSPEND_DELAY);
1137 usb_pm_unlock(udev);
1138 // dev_dbg(&udev->dev, "%s: cnt %d\n", 1204 // dev_dbg(&udev->dev, "%s: cnt %d\n",
1139 // __FUNCTION__, udev->pm_usage_cnt); 1205 // __FUNCTION__, udev->pm_usage_cnt);
1140} 1206}
@@ -1142,44 +1208,59 @@ void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt)
1142/** 1208/**
1143 * usb_autoresume_device - immediately autoresume a USB device and its interfaces 1209 * usb_autoresume_device - immediately autoresume a USB device and its interfaces
1144 * @udev: the usb_device to autoresume 1210 * @udev: the usb_device to autoresume
1145 * @inc_usage_cnt: flag to increment @udev's PM-usage counter
1146 * 1211 *
1147 * This routine should be called when a core subsystem wants to use @udev 1212 * This routine should be called when a core subsystem wants to use @udev
1148 * and needs to guarantee that it is not suspended. In addition, the 1213 * and needs to guarantee that it is not suspended. No autosuspend will
1149 * caller can prevent @udev from being autosuspended subsequently. (Note 1214 * occur until usb_autosuspend_device is called. (Note that this will not
1150 * that this will not prevent suspend events originating in the PM core.) 1215 * prevent suspend events originating in the PM core.) Examples would be
1151 * Examples would be when @udev's device file in usbfs is opened (autosuspend 1216 * when @udev's device file in usbfs is opened or when a remote-wakeup
1152 * should be prevented until the file is closed) or when a remote-wakeup 1217 * request is received.
1153 * request is received (later autosuspends should not be prevented).
1154 * 1218 *
1155 * @inc_usage_cnt should be 1 to increment @udev's usage counter and prevent 1219 * @udev's usage counter is incremented to prevent subsequent autosuspends.
1156 * autosuspends. This prevention will persist until the usage counter is 1220 * However if the autoresume fails then the usage counter is re-decremented.
1157 * decremented again (such as by passing 1 to usb_autosuspend_device).
1158 * Otherwise @inc_usage_cnt should be 0 to leave the usage counter unchanged.
1159 * Regardless, if the autoresume fails then the usage counter is not
1160 * incremented.
1161 * 1221 *
1162 * Often the caller will hold @udev's device lock, but this is not 1222 * Often the caller will hold @udev's device lock, but this is not
1163 * necessary (and attempting it might cause deadlock). 1223 * necessary (and attempting it might cause deadlock).
1164 * 1224 *
1165 * This routine can run only in process context. 1225 * This routine can run only in process context.
1166 */ 1226 */
1167int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt) 1227int usb_autoresume_device(struct usb_device *udev)
1168{ 1228{
1169 int status; 1229 int status;
1170 1230
1171 usb_pm_lock(udev); 1231 status = usb_autopm_do_device(udev, 1);
1172 udev->pm_usage_cnt += inc_usage_cnt;
1173 udev->auto_pm = 1;
1174 status = usb_resume_both(udev);
1175 if (status != 0)
1176 udev->pm_usage_cnt -= inc_usage_cnt;
1177 usb_pm_unlock(udev);
1178 // dev_dbg(&udev->dev, "%s: status %d cnt %d\n", 1232 // dev_dbg(&udev->dev, "%s: status %d cnt %d\n",
1179 // __FUNCTION__, status, udev->pm_usage_cnt); 1233 // __FUNCTION__, status, udev->pm_usage_cnt);
1180 return status; 1234 return status;
1181} 1235}
1182 1236
1237/* Internal routine to adjust an interface's usage counter and change
1238 * its device's autosuspend state.
1239 */
1240static int usb_autopm_do_interface(struct usb_interface *intf,
1241 int inc_usage_cnt)
1242{
1243 struct usb_device *udev = interface_to_usbdev(intf);
1244 int status = 0;
1245
1246 usb_pm_lock(udev);
1247 if (intf->condition == USB_INTERFACE_UNBOUND)
1248 status = -ENODEV;
1249 else {
1250 intf->pm_usage_cnt += inc_usage_cnt;
1251 if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) {
1252 udev->auto_pm = 1;
1253 status = usb_resume_both(udev);
1254 if (status != 0)
1255 intf->pm_usage_cnt -= inc_usage_cnt;
1256 } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0)
1257 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1258 USB_AUTOSUSPEND_DELAY);
1259 }
1260 usb_pm_unlock(udev);
1261 return status;
1262}
1263
1183/** 1264/**
1184 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter 1265 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter
1185 * @intf: the usb_interface whose counter should be decremented 1266 * @intf: the usb_interface whose counter should be decremented
@@ -1213,17 +1294,11 @@ int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt)
1213 */ 1294 */
1214void usb_autopm_put_interface(struct usb_interface *intf) 1295void usb_autopm_put_interface(struct usb_interface *intf)
1215{ 1296{
1216 struct usb_device *udev = interface_to_usbdev(intf); 1297 int status;
1217 1298
1218 usb_pm_lock(udev); 1299 status = usb_autopm_do_interface(intf, -1);
1219 if (intf->condition != USB_INTERFACE_UNBOUND && 1300 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1220 --intf->pm_usage_cnt <= 0) { 1301 // __FUNCTION__, status, intf->pm_usage_cnt);
1221 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1222 USB_AUTOSUSPEND_DELAY);
1223 }
1224 usb_pm_unlock(udev);
1225 // dev_dbg(&intf->dev, "%s: cnt %d\n",
1226 // __FUNCTION__, intf->pm_usage_cnt);
1227} 1302}
1228EXPORT_SYMBOL_GPL(usb_autopm_put_interface); 1303EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1229 1304
@@ -1260,26 +1335,37 @@ EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1260 */ 1335 */
1261int usb_autopm_get_interface(struct usb_interface *intf) 1336int usb_autopm_get_interface(struct usb_interface *intf)
1262{ 1337{
1263 struct usb_device *udev = interface_to_usbdev(intf); 1338 int status;
1264 int status;
1265 1339
1266 usb_pm_lock(udev); 1340 status = usb_autopm_do_interface(intf, 1);
1267 if (intf->condition == USB_INTERFACE_UNBOUND)
1268 status = -ENODEV;
1269 else {
1270 ++intf->pm_usage_cnt;
1271 udev->auto_pm = 1;
1272 status = usb_resume_both(udev);
1273 if (status != 0)
1274 --intf->pm_usage_cnt;
1275 }
1276 usb_pm_unlock(udev);
1277 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n", 1341 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1278 // __FUNCTION__, status, intf->pm_usage_cnt); 1342 // __FUNCTION__, status, intf->pm_usage_cnt);
1279 return status; 1343 return status;
1280} 1344}
1281EXPORT_SYMBOL_GPL(usb_autopm_get_interface); 1345EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
1282 1346
1347/**
1348 * usb_autopm_set_interface - set a USB interface's autosuspend state
1349 * @intf: the usb_interface whose state should be set
1350 *
1351 * This routine sets the autosuspend state of @intf's device according
1352 * to @intf's usage counter, which the caller must have set previously.
1353 * If the counter is <= 0, the device is autosuspended (if it isn't
1354 * already suspended and if nothing else prevents the autosuspend). If
1355 * the counter is > 0, the device is autoresumed (if it isn't already
1356 * awake).
1357 */
1358int usb_autopm_set_interface(struct usb_interface *intf)
1359{
1360 int status;
1361
1362 status = usb_autopm_do_interface(intf, 0);
1363 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1364 // __FUNCTION__, status, intf->pm_usage_cnt);
1365 return status;
1366}
1367EXPORT_SYMBOL_GPL(usb_autopm_set_interface);
1368
1283#endif /* CONFIG_USB_SUSPEND */ 1369#endif /* CONFIG_USB_SUSPEND */
1284 1370
1285static int usb_suspend(struct device *dev, pm_message_t message) 1371static int usb_suspend(struct device *dev, pm_message_t message)
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3b2d137912be..c505b767cee1 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -10,15 +10,20 @@
10 */ 10 */
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/spinlock.h>
14#include <linux/idr.h>
13#include <linux/usb.h> 15#include <linux/usb.h>
14#include "usb.h" 16#include "usb.h"
15 17
16/* endpoint stuff */ 18#define MAX_ENDPOINT_MINORS (64*128*32)
19static int usb_endpoint_major;
20static DEFINE_IDR(endpoint_idr);
17 21
18struct ep_device { 22struct ep_device {
19 struct usb_endpoint_descriptor *desc; 23 struct usb_endpoint_descriptor *desc;
20 struct usb_device *udev; 24 struct usb_device *udev;
21 struct device dev; 25 struct device dev;
26 int minor;
22}; 27};
23#define to_ep_device(_dev) \ 28#define to_ep_device(_dev) \
24 container_of(_dev, struct ep_device, dev) 29 container_of(_dev, struct ep_device, dev)
@@ -152,6 +157,55 @@ static struct attribute_group ep_dev_attr_grp = {
152 .attrs = ep_dev_attrs, 157 .attrs = ep_dev_attrs,
153}; 158};
154 159
160static int usb_endpoint_major_init(void)
161{
162 dev_t dev;
163 int error;
164
165 error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS,
166 "usb_endpoint");
167 if (error) {
168 err("unable to get a dynamic major for usb endpoints");
169 return error;
170 }
171 usb_endpoint_major = MAJOR(dev);
172
173 return error;
174}
175
176static void usb_endpoint_major_cleanup(void)
177{
178 unregister_chrdev_region(MKDEV(usb_endpoint_major, 0),
179 MAX_ENDPOINT_MINORS);
180}
181
182static int endpoint_get_minor(struct ep_device *ep_dev)
183{
184 static DEFINE_MUTEX(minor_lock);
185 int retval = -ENOMEM;
186 int id;
187
188 mutex_lock(&minor_lock);
189 if (idr_pre_get(&endpoint_idr, GFP_KERNEL) == 0)
190 goto exit;
191
192 retval = idr_get_new(&endpoint_idr, ep_dev, &id);
193 if (retval < 0) {
194 if (retval == -EAGAIN)
195 retval = -ENOMEM;
196 goto exit;
197 }
198 ep_dev->minor = id & MAX_ID_MASK;
199exit:
200 mutex_unlock(&minor_lock);
201 return retval;
202}
203
204static void endpoint_free_minor(struct ep_device *ep_dev)
205{
206 idr_remove(&endpoint_idr, ep_dev->minor);
207}
208
155static struct endpoint_class { 209static struct endpoint_class {
156 struct kref kref; 210 struct kref kref;
157 struct class *class; 211 struct class *class;
@@ -176,11 +230,20 @@ static int init_endpoint_class(void)
176 ep_class->class = class_create(THIS_MODULE, "usb_endpoint"); 230 ep_class->class = class_create(THIS_MODULE, "usb_endpoint");
177 if (IS_ERR(ep_class->class)) { 231 if (IS_ERR(ep_class->class)) {
178 result = IS_ERR(ep_class->class); 232 result = IS_ERR(ep_class->class);
179 kfree(ep_class); 233 goto class_create_error;
180 ep_class = NULL;
181 goto exit;
182 } 234 }
183 235
236 result = usb_endpoint_major_init();
237 if (result)
238 goto endpoint_major_error;
239
240 goto exit;
241
242endpoint_major_error:
243 class_destroy(ep_class->class);
244class_create_error:
245 kfree(ep_class);
246 ep_class = NULL;
184exit: 247exit:
185 return result; 248 return result;
186} 249}
@@ -191,6 +254,7 @@ static void release_endpoint_class(struct kref *kref)
191 class_destroy(ep_class->class); 254 class_destroy(ep_class->class);
192 kfree(ep_class); 255 kfree(ep_class);
193 ep_class = NULL; 256 ep_class = NULL;
257 usb_endpoint_major_cleanup();
194} 258}
195 259
196static void destroy_endpoint_class(void) 260static void destroy_endpoint_class(void)
@@ -213,7 +277,6 @@ int usb_create_ep_files(struct device *parent,
213{ 277{
214 char name[8]; 278 char name[8];
215 struct ep_device *ep_dev; 279 struct ep_device *ep_dev;
216 int minor;
217 int retval; 280 int retval;
218 281
219 retval = init_endpoint_class(); 282 retval = init_endpoint_class();
@@ -226,12 +289,16 @@ int usb_create_ep_files(struct device *parent,
226 goto error_alloc; 289 goto error_alloc;
227 } 290 }
228 291
229 /* fun calculation to determine the minor of this endpoint */ 292 retval = endpoint_get_minor(ep_dev);
230 minor = (((udev->bus->busnum - 1) * 128) * 16) + (udev->devnum - 1); 293 if (retval) {
294 dev_err(parent, "can not allocate minor number for %s",
295 ep_dev->dev.bus_id);
296 goto error_register;
297 }
231 298
232 ep_dev->desc = &endpoint->desc; 299 ep_dev->desc = &endpoint->desc;
233 ep_dev->udev = udev; 300 ep_dev->udev = udev;
234 ep_dev->dev.devt = MKDEV(442, minor); // FIXME fake number... 301 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor);
235 ep_dev->dev.class = ep_class->class; 302 ep_dev->dev.class = ep_class->class;
236 ep_dev->dev.parent = parent; 303 ep_dev->dev.parent = parent;
237 ep_dev->dev.release = ep_device_release; 304 ep_dev->dev.release = ep_device_release;
@@ -241,7 +308,7 @@ int usb_create_ep_files(struct device *parent,
241 308
242 retval = device_register(&ep_dev->dev); 309 retval = device_register(&ep_dev->dev);
243 if (retval) 310 if (retval)
244 goto error_register; 311 goto error_chrdev;
245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 312 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
246 if (retval) 313 if (retval)
247 goto error_group; 314 goto error_group;
@@ -261,6 +328,9 @@ error_group:
261 destroy_endpoint_class(); 328 destroy_endpoint_class();
262 return retval; 329 return retval;
263 330
331error_chrdev:
332 endpoint_free_minor(ep_dev);
333
264error_register: 334error_register:
265 kfree(ep_dev); 335 kfree(ep_dev);
266error_alloc: 336error_alloc:
@@ -271,14 +341,16 @@ exit:
271 341
272void usb_remove_ep_files(struct usb_host_endpoint *endpoint) 342void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
273{ 343{
344 struct ep_device *ep_dev = endpoint->ep_dev;
274 345
275 if (endpoint->ep_dev) { 346 if (ep_dev) {
276 char name[8]; 347 char name[8];
277 348
278 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
279 sysfs_remove_link(&endpoint->ep_dev->dev.parent->kobj, name); 350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name);
280 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp); 351 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
281 device_unregister(&endpoint->ep_dev->dev); 352 endpoint_free_minor(ep_dev);
353 device_unregister(&ep_dev->dev);
282 endpoint->ep_dev = NULL; 354 endpoint->ep_dev = NULL;
283 destroy_endpoint_class(); 355 destroy_endpoint_class();
284 } 356 }
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index afa2dd203329..10064af65d17 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -256,7 +256,9 @@ static const u8 hs_rh_config_descriptor [] = {
256 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 256 0x05, /* __u8 ep_bDescriptorType; Endpoint */
257 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 257 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */
258 0x03, /* __u8 ep_bmAttributes; Interrupt */ 258 0x03, /* __u8 ep_bmAttributes; Interrupt */
259 0x02, 0x00, /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ 259 /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8)
260 * see hub.c:hub_configure() for details. */
261 (USB_MAXCHILDREN + 1 + 7) / 8, 0x00,
260 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */ 262 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */
261}; 263};
262 264
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index ad0ffbe8f7d7..39186db1015f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -31,6 +31,47 @@
31#include "hcd.h" 31#include "hcd.h"
32#include "hub.h" 32#include "hub.h"
33 33
34struct usb_hub {
35 struct device *intfdev; /* the "interface" device */
36 struct usb_device *hdev;
37 struct urb *urb; /* for interrupt polling pipe */
38
39 /* buffer for urb ... with extra space in case of babble */
40 char (*buffer)[8];
41 dma_addr_t buffer_dma; /* DMA address for buffer */
42 union {
43 struct usb_hub_status hub;
44 struct usb_port_status port;
45 } *status; /* buffer for status reports */
46
47 int error; /* last reported error */
48 int nerrors; /* track consecutive errors */
49
50 struct list_head event_list; /* hubs w/data or errs ready */
51 unsigned long event_bits[1]; /* status change bitmask */
52 unsigned long change_bits[1]; /* ports with logical connect
53 status change */
54 unsigned long busy_bits[1]; /* ports being reset or
55 resumed */
56#if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */
57#error event_bits[] is too short!
58#endif
59
60 struct usb_hub_descriptor *descriptor; /* class descriptor */
61 struct usb_tt tt; /* Transaction Translator */
62
63 unsigned mA_per_port; /* current for each child */
64
65 unsigned limited_power:1;
66 unsigned quiescing:1;
67 unsigned activating:1;
68
69 unsigned has_indicators:1;
70 u8 indicator[USB_MAXCHILDREN];
71 struct work_struct leds;
72};
73
74
34/* Protect struct usb_device->state and ->children members 75/* Protect struct usb_device->state and ->children members
35 * Note: Both are also protected by ->dev.sem, except that ->state can 76 * Note: Both are also protected by ->dev.sem, except that ->state can
36 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ 77 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
@@ -45,6 +86,16 @@ static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
45 86
46static struct task_struct *khubd_task; 87static struct task_struct *khubd_task;
47 88
89/* multithreaded probe logic */
90static int multithread_probe =
91#ifdef CONFIG_USB_MULTITHREAD_PROBE
92 1;
93#else
94 0;
95#endif
96module_param(multithread_probe, bool, S_IRUGO);
97MODULE_PARM_DESC(multithread_probe, "Run each USB device probe in a new thread");
98
48/* cycle leds on hubs that aren't blinking for attention */ 99/* cycle leds on hubs that aren't blinking for attention */
49static int blinkenlights = 0; 100static int blinkenlights = 0;
50module_param (blinkenlights, bool, S_IRUGO); 101module_param (blinkenlights, bool, S_IRUGO);
@@ -277,6 +328,9 @@ static void kick_khubd(struct usb_hub *hub)
277{ 328{
278 unsigned long flags; 329 unsigned long flags;
279 330
331 /* Suppress autosuspend until khubd runs */
332 to_usb_interface(hub->intfdev)->pm_usage_cnt = 1;
333
280 spin_lock_irqsave(&hub_event_lock, flags); 334 spin_lock_irqsave(&hub_event_lock, flags);
281 if (list_empty(&hub->event_list)) { 335 if (list_empty(&hub->event_list)) {
282 list_add_tail(&hub->event_list, &hub_event_list); 336 list_add_tail(&hub->event_list, &hub_event_list);
@@ -459,7 +513,6 @@ static void hub_quiesce(struct usb_hub *hub)
459 /* (nonblocking) khubd and related activity won't re-trigger */ 513 /* (nonblocking) khubd and related activity won't re-trigger */
460 hub->quiescing = 1; 514 hub->quiescing = 1;
461 hub->activating = 0; 515 hub->activating = 0;
462 hub->resume_root_hub = 0;
463 516
464 /* (blocking) stop khubd and related activity */ 517 /* (blocking) stop khubd and related activity */
465 usb_kill_urb(hub->urb); 518 usb_kill_urb(hub->urb);
@@ -475,7 +528,7 @@ static void hub_activate(struct usb_hub *hub)
475 528
476 hub->quiescing = 0; 529 hub->quiescing = 0;
477 hub->activating = 1; 530 hub->activating = 1;
478 hub->resume_root_hub = 0; 531
479 status = usb_submit_urb(hub->urb, GFP_NOIO); 532 status = usb_submit_urb(hub->urb, GFP_NOIO);
480 if (status < 0) 533 if (status < 0)
481 dev_err(hub->intfdev, "activate --> %d\n", status); 534 dev_err(hub->intfdev, "activate --> %d\n", status);
@@ -761,7 +814,12 @@ static int hub_configure(struct usb_hub *hub,
761 dev_dbg(hub_dev, "%sover-current condition exists\n", 814 dev_dbg(hub_dev, "%sover-current condition exists\n",
762 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); 815 (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no ");
763 816
764 /* set up the interrupt endpoint */ 817 /* set up the interrupt endpoint
818 * We use the EP's maxpacket size instead of (PORTS+1+7)/8
819 * bytes as USB2.0[11.12.3] says because some hubs are known
820 * to send more data (and thus cause overflow). For root hubs,
821 * maxpktsize is defined in hcd.c's fake endpoint descriptors
822 * to be big enough for at least USB_MAXCHILDREN ports. */
765 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 823 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress);
766 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 824 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe));
767 825
@@ -885,6 +943,7 @@ descriptor_error:
885 INIT_DELAYED_WORK(&hub->leds, led_work); 943 INIT_DELAYED_WORK(&hub->leds, led_work);
886 944
887 usb_set_intfdata (intf, hub); 945 usb_set_intfdata (intf, hub);
946 intf->needs_remote_wakeup = 1;
888 947
889 if (hdev->speed == USB_SPEED_HIGH) 948 if (hdev->speed == USB_SPEED_HIGH)
890 highspeed_hubs++; 949 highspeed_hubs++;
@@ -982,6 +1041,8 @@ static void recursively_mark_NOTATTACHED(struct usb_device *udev)
982 if (udev->children[i]) 1041 if (udev->children[i])
983 recursively_mark_NOTATTACHED(udev->children[i]); 1042 recursively_mark_NOTATTACHED(udev->children[i]);
984 } 1043 }
1044 if (udev->state == USB_STATE_SUSPENDED)
1045 udev->discon_suspended = 1;
985 udev->state = USB_STATE_NOTATTACHED; 1046 udev->state = USB_STATE_NOTATTACHED;
986} 1047}
987 1048
@@ -1171,6 +1232,14 @@ void usb_disconnect(struct usb_device **pdev)
1171 *pdev = NULL; 1232 *pdev = NULL;
1172 spin_unlock_irq(&device_state_lock); 1233 spin_unlock_irq(&device_state_lock);
1173 1234
1235 /* Decrement the parent's count of unsuspended children */
1236 if (udev->parent) {
1237 usb_pm_lock(udev);
1238 if (!udev->discon_suspended)
1239 usb_autosuspend_device(udev->parent);
1240 usb_pm_unlock(udev);
1241 }
1242
1174 put_device(&udev->dev); 1243 put_device(&udev->dev);
1175} 1244}
1176 1245
@@ -1193,29 +1262,17 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1193static int __usb_port_suspend(struct usb_device *, int port1); 1262static int __usb_port_suspend(struct usb_device *, int port1);
1194#endif 1263#endif
1195 1264
1196/** 1265static int __usb_new_device(void *void_data)
1197 * usb_new_device - perform initial device setup (usbcore-internal)
1198 * @udev: newly addressed device (in ADDRESS state)
1199 *
1200 * This is called with devices which have been enumerated, but not yet
1201 * configured. The device descriptor is available, but not descriptors
1202 * for any device configuration. The caller must have locked either
1203 * the parent hub (if udev is a normal device) or else the
1204 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1205 * udev has already been installed, but udev is not yet visible through
1206 * sysfs or other filesystem code.
1207 *
1208 * Returns 0 for success (device is configured and listed, with its
1209 * interfaces, in sysfs); else a negative errno value.
1210 *
1211 * This call is synchronous, and may not be used in an interrupt context.
1212 *
1213 * Only the hub driver or root-hub registrar should ever call this.
1214 */
1215int usb_new_device(struct usb_device *udev)
1216{ 1266{
1267 struct usb_device *udev = void_data;
1217 int err; 1268 int err;
1218 1269
1270 /* Lock ourself into memory in order to keep a probe sequence
1271 * sleeping in a new thread from allowing us to be unloaded.
1272 */
1273 if (!try_module_get(THIS_MODULE))
1274 return -EINVAL;
1275
1219 err = usb_get_configuration(udev); 1276 err = usb_get_configuration(udev);
1220 if (err < 0) { 1277 if (err < 0) {
1221 dev_err(&udev->dev, "can't read configurations, error %d\n", 1278 dev_err(&udev->dev, "can't read configurations, error %d\n",
@@ -1311,13 +1368,56 @@ int usb_new_device(struct usb_device *udev)
1311 goto fail; 1368 goto fail;
1312 } 1369 }
1313 1370
1314 return 0; 1371 /* Increment the parent's count of unsuspended children */
1372 if (udev->parent)
1373 usb_autoresume_device(udev->parent);
1374
1375exit:
1376 module_put(THIS_MODULE);
1377 return err;
1315 1378
1316fail: 1379fail:
1317 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1380 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
1318 return err; 1381 goto exit;
1319} 1382}
1320 1383
1384/**
1385 * usb_new_device - perform initial device setup (usbcore-internal)
1386 * @udev: newly addressed device (in ADDRESS state)
1387 *
1388 * This is called with devices which have been enumerated, but not yet
1389 * configured. The device descriptor is available, but not descriptors
1390 * for any device configuration. The caller must have locked either
1391 * the parent hub (if udev is a normal device) or else the
1392 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1393 * udev has already been installed, but udev is not yet visible through
1394 * sysfs or other filesystem code.
1395 *
1396 * The return value for this function depends on if the
1397 * multithread_probe variable is set or not. If it's set, it will
1398 * return a if the probe thread was successfully created or not. If the
1399 * variable is not set, it will return if the device is configured
1400 * properly or not. interfaces, in sysfs); else a negative errno value.
1401 *
1402 * This call is synchronous, and may not be used in an interrupt context.
1403 *
1404 * Only the hub driver or root-hub registrar should ever call this.
1405 */
1406int usb_new_device(struct usb_device *udev)
1407{
1408 struct task_struct *probe_task;
1409 int ret = 0;
1410
1411 if (multithread_probe) {
1412 probe_task = kthread_run(__usb_new_device, udev,
1413 "usb-probe-%s", udev->devnum);
1414 if (IS_ERR(probe_task))
1415 ret = PTR_ERR(probe_task);
1416 } else
1417 ret = __usb_new_device(udev);
1418
1419 return ret;
1420}
1321 1421
1322static int hub_port_status(struct usb_hub *hub, int port1, 1422static int hub_port_status(struct usb_hub *hub, int port1,
1323 u16 *status, u16 *change) 1423 u16 *status, u16 *change)
@@ -1325,10 +1425,12 @@ static int hub_port_status(struct usb_hub *hub, int port1,
1325 int ret; 1425 int ret;
1326 1426
1327 ret = get_port_status(hub->hdev, port1, &hub->status->port); 1427 ret = get_port_status(hub->hdev, port1, &hub->status->port);
1328 if (ret < 0) 1428 if (ret < 4) {
1329 dev_err (hub->intfdev, 1429 dev_err (hub->intfdev,
1330 "%s failed (err = %d)\n", __FUNCTION__, ret); 1430 "%s failed (err = %d)\n", __FUNCTION__, ret);
1331 else { 1431 if (ret >= 0)
1432 ret = -EIO;
1433 } else {
1332 *status = le16_to_cpu(hub->status->port.wPortStatus); 1434 *status = le16_to_cpu(hub->status->port.wPortStatus);
1333 *change = le16_to_cpu(hub->status->port.wPortChange); 1435 *change = le16_to_cpu(hub->status->port.wPortChange);
1334 ret = 0; 1436 ret = 0;
@@ -1676,6 +1778,12 @@ static int
1676hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) 1778hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1677{ 1779{
1678 int status; 1780 int status;
1781 u16 portchange, portstatus;
1782
1783 /* Skip the initial Clear-Suspend step for a remote wakeup */
1784 status = hub_port_status(hub, port1, &portstatus, &portchange);
1785 if (status == 0 && !(portstatus & USB_PORT_STAT_SUSPEND))
1786 goto SuspendCleared;
1679 1787
1680 // dev_dbg(hub->intfdev, "resume port %d\n", port1); 1788 // dev_dbg(hub->intfdev, "resume port %d\n", port1);
1681 1789
@@ -1689,9 +1797,6 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1689 "can't resume port %d, status %d\n", 1797 "can't resume port %d, status %d\n",
1690 port1, status); 1798 port1, status);
1691 } else { 1799 } else {
1692 u16 devstatus;
1693 u16 portchange;
1694
1695 /* drive resume for at least 20 msec */ 1800 /* drive resume for at least 20 msec */
1696 if (udev) 1801 if (udev)
1697 dev_dbg(&udev->dev, "usb %sresume\n", 1802 dev_dbg(&udev->dev, "usb %sresume\n",
@@ -1706,16 +1811,15 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1706 * stop resume signaling. Then finish the resume 1811 * stop resume signaling. Then finish the resume
1707 * sequence. 1812 * sequence.
1708 */ 1813 */
1709 devstatus = portchange = 0; 1814 status = hub_port_status(hub, port1, &portstatus, &portchange);
1710 status = hub_port_status(hub, port1, 1815SuspendCleared:
1711 &devstatus, &portchange);
1712 if (status < 0 1816 if (status < 0
1713 || (devstatus & LIVE_FLAGS) != LIVE_FLAGS 1817 || (portstatus & LIVE_FLAGS) != LIVE_FLAGS
1714 || (devstatus & USB_PORT_STAT_SUSPEND) != 0 1818 || (portstatus & USB_PORT_STAT_SUSPEND) != 0
1715 ) { 1819 ) {
1716 dev_dbg(hub->intfdev, 1820 dev_dbg(hub->intfdev,
1717 "port %d status %04x.%04x after resume, %d\n", 1821 "port %d status %04x.%04x after resume, %d\n",
1718 port1, portchange, devstatus, status); 1822 port1, portchange, portstatus, status);
1719 if (status >= 0) 1823 if (status >= 0)
1720 status = -ENODEV; 1824 status = -ENODEV;
1721 } else { 1825 } else {
@@ -1776,23 +1880,16 @@ static int remote_wakeup(struct usb_device *udev)
1776{ 1880{
1777 int status = 0; 1881 int status = 0;
1778 1882
1779 /* All this just to avoid sending a port-resume message
1780 * to the parent hub! */
1781
1782 usb_lock_device(udev); 1883 usb_lock_device(udev);
1783 usb_pm_lock(udev);
1784 if (udev->state == USB_STATE_SUSPENDED) { 1884 if (udev->state == USB_STATE_SUSPENDED) {
1785 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); 1885 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-");
1786 /* TRSMRCY = 10 msec */ 1886 status = usb_autoresume_device(udev);
1787 msleep(10); 1887
1788 status = finish_port_resume(udev); 1888 /* Give the interface drivers a chance to do something,
1889 * then autosuspend the device again. */
1789 if (status == 0) 1890 if (status == 0)
1790 udev->dev.power.power_state.event = PM_EVENT_ON; 1891 usb_autosuspend_device(udev);
1791 } 1892 }
1792 usb_pm_unlock(udev);
1793
1794 if (status == 0)
1795 usb_autoresume_device(udev, 0);
1796 usb_unlock_device(udev); 1893 usb_unlock_device(udev);
1797 return status; 1894 return status;
1798} 1895}
@@ -1856,6 +1953,8 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1856 } 1953 }
1857 } 1954 }
1858 1955
1956 dev_dbg(&intf->dev, "%s\n", __FUNCTION__);
1957
1859 /* "global suspend" of the downstream HC-to-USB interface */ 1958 /* "global suspend" of the downstream HC-to-USB interface */
1860 if (!hdev->parent) { 1959 if (!hdev->parent) {
1861 struct usb_bus *bus = hdev->bus; 1960 struct usb_bus *bus = hdev->bus;
@@ -1878,10 +1977,12 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1878 1977
1879static int hub_resume(struct usb_interface *intf) 1978static int hub_resume(struct usb_interface *intf)
1880{ 1979{
1881 struct usb_device *hdev = interface_to_usbdev(intf);
1882 struct usb_hub *hub = usb_get_intfdata (intf); 1980 struct usb_hub *hub = usb_get_intfdata (intf);
1981 struct usb_device *hdev = hub->hdev;
1883 int status; 1982 int status;
1884 1983
1984 dev_dbg(&intf->dev, "%s\n", __FUNCTION__);
1985
1885 /* "global resume" of the downstream HC-to-USB interface */ 1986 /* "global resume" of the downstream HC-to-USB interface */
1886 if (!hdev->parent) { 1987 if (!hdev->parent) {
1887 struct usb_bus *bus = hdev->bus; 1988 struct usb_bus *bus = hdev->bus;
@@ -1920,7 +2021,6 @@ void usb_resume_root_hub(struct usb_device *hdev)
1920{ 2021{
1921 struct usb_hub *hub = hdev_to_hub(hdev); 2022 struct usb_hub *hub = hdev_to_hub(hdev);
1922 2023
1923 hub->resume_root_hub = 1;
1924 kick_khubd(hub); 2024 kick_khubd(hub);
1925} 2025}
1926 2026
@@ -2557,16 +2657,13 @@ static void hub_events(void)
2557 intf = to_usb_interface(hub->intfdev); 2657 intf = to_usb_interface(hub->intfdev);
2558 hub_dev = &intf->dev; 2658 hub_dev = &intf->dev;
2559 2659
2560 i = hub->resume_root_hub; 2660 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n",
2561
2562 dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x%s\n",
2563 hdev->state, hub->descriptor 2661 hdev->state, hub->descriptor
2564 ? hub->descriptor->bNbrPorts 2662 ? hub->descriptor->bNbrPorts
2565 : 0, 2663 : 0,
2566 /* NOTE: expects max 15 ports... */ 2664 /* NOTE: expects max 15 ports... */
2567 (u16) hub->change_bits[0], 2665 (u16) hub->change_bits[0],
2568 (u16) hub->event_bits[0], 2666 (u16) hub->event_bits[0]);
2569 i ? ", resume root" : "");
2570 2667
2571 usb_get_intf(intf); 2668 usb_get_intf(intf);
2572 spin_unlock_irq(&hub_event_lock); 2669 spin_unlock_irq(&hub_event_lock);
@@ -2587,16 +2684,16 @@ static void hub_events(void)
2587 goto loop; 2684 goto loop;
2588 } 2685 }
2589 2686
2590 /* Is this is a root hub wanting to reactivate the downstream 2687 /* Autoresume */
2591 * ports? If so, be sure the interface resumes even if its 2688 ret = usb_autopm_get_interface(intf);
2592 * stub "device" node was never suspended. 2689 if (ret) {
2593 */ 2690 dev_dbg(hub_dev, "Can't autoresume: %d\n", ret);
2594 if (i) 2691 goto loop;
2595 usb_autoresume_device(hdev, 0); 2692 }
2596 2693
2597 /* If this is an inactive or suspended hub, do nothing */ 2694 /* If this is an inactive hub, do nothing */
2598 if (hub->quiescing) 2695 if (hub->quiescing)
2599 goto loop; 2696 goto loop_autopm;
2600 2697
2601 if (hub->error) { 2698 if (hub->error) {
2602 dev_dbg (hub_dev, "resetting for error %d\n", 2699 dev_dbg (hub_dev, "resetting for error %d\n",
@@ -2606,7 +2703,7 @@ static void hub_events(void)
2606 if (ret) { 2703 if (ret) {
2607 dev_dbg (hub_dev, 2704 dev_dbg (hub_dev,
2608 "error resetting hub: %d\n", ret); 2705 "error resetting hub: %d\n", ret);
2609 goto loop; 2706 goto loop_autopm;
2610 } 2707 }
2611 2708
2612 hub->nerrors = 0; 2709 hub->nerrors = 0;
@@ -2734,6 +2831,10 @@ static void hub_events(void)
2734 if (!hdev->parent && !hub->busy_bits[0]) 2831 if (!hdev->parent && !hub->busy_bits[0])
2735 usb_enable_root_hub_irq(hdev->bus); 2832 usb_enable_root_hub_irq(hdev->bus);
2736 2833
2834loop_autopm:
2835 /* Allow autosuspend if we're not going to run again */
2836 if (list_empty(&hub->event_list))
2837 usb_autopm_enable(intf);
2737loop: 2838loop:
2738 usb_unlock_device(hdev); 2839 usb_unlock_device(hdev);
2739 usb_put_intf(intf); 2840 usb_put_intf(intf);
@@ -2775,6 +2876,7 @@ static struct usb_driver hub_driver = {
2775 .post_reset = hub_post_reset, 2876 .post_reset = hub_post_reset,
2776 .ioctl = hub_ioctl, 2877 .ioctl = hub_ioctl,
2777 .id_table = hub_id_table, 2878 .id_table = hub_id_table,
2879 .supports_autosuspend = 1,
2778}; 2880};
2779 2881
2780int usb_hub_init(void) 2882int usb_hub_init(void)
@@ -2999,7 +3101,7 @@ int usb_reset_composite_device(struct usb_device *udev,
2999 } 3101 }
3000 3102
3001 /* Prevent autosuspend during the reset */ 3103 /* Prevent autosuspend during the reset */
3002 usb_autoresume_device(udev, 1); 3104 usb_autoresume_device(udev);
3003 3105
3004 if (iface && iface->condition != USB_INTERFACE_BINDING) 3106 if (iface && iface->condition != USB_INTERFACE_BINDING)
3005 iface = NULL; 3107 iface = NULL;
@@ -3042,7 +3144,7 @@ int usb_reset_composite_device(struct usb_device *udev,
3042 } 3144 }
3043 } 3145 }
3044 3146
3045 usb_autosuspend_device(udev, 1); 3147 usb_autosuspend_device(udev);
3046 return ret; 3148 return ret;
3047} 3149}
3048EXPORT_SYMBOL(usb_reset_composite_device); 3150EXPORT_SYMBOL(usb_reset_composite_device);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 035d3ef35888..cf9559c6c9b6 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -192,45 +192,4 @@ struct usb_tt_clear {
192 192
193extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe); 193extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe);
194 194
195struct usb_hub {
196 struct device *intfdev; /* the "interface" device */
197 struct usb_device *hdev;
198 struct urb *urb; /* for interrupt polling pipe */
199
200 /* buffer for urb ... with extra space in case of babble */
201 char (*buffer)[8];
202 dma_addr_t buffer_dma; /* DMA address for buffer */
203 union {
204 struct usb_hub_status hub;
205 struct usb_port_status port;
206 } *status; /* buffer for status reports */
207
208 int error; /* last reported error */
209 int nerrors; /* track consecutive errors */
210
211 struct list_head event_list; /* hubs w/data or errs ready */
212 unsigned long event_bits[1]; /* status change bitmask */
213 unsigned long change_bits[1]; /* ports with logical connect
214 status change */
215 unsigned long busy_bits[1]; /* ports being reset or
216 resumed */
217#if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */
218#error event_bits[] is too short!
219#endif
220
221 struct usb_hub_descriptor *descriptor; /* class descriptor */
222 struct usb_tt tt; /* Transaction Translator */
223
224 unsigned mA_per_port; /* current for each child */
225
226 unsigned limited_power:1;
227 unsigned quiescing:1;
228 unsigned activating:1;
229 unsigned resume_root_hub:1;
230
231 unsigned has_indicators:1;
232 enum hub_led_mode indicator[USB_MAXCHILDREN];
233 struct delayed_work leds;
234};
235
236#endif /* __LINUX_HUB_H */ 195#endif /* __LINUX_HUB_H */
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 89572bc021b1..7390b67c609d 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -764,7 +764,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
764 err = -EINVAL; 764 err = -EINVAL;
765 goto errout; 765 goto errout;
766 } else { 766 } else {
767 dev->have_langid = -1; 767 dev->have_langid = 1;
768 dev->string_langid = tbuf[2] | (tbuf[3]<< 8); 768 dev->string_langid = tbuf[2] | (tbuf[3]<< 8);
769 /* always use the first langid listed */ 769 /* always use the first langid listed */
770 dev_dbg (&dev->dev, "default language 0x%04x\n", 770 dev_dbg (&dev->dev, "default language 0x%04x\n",
@@ -1398,7 +1398,7 @@ free_interfaces:
1398 } 1398 }
1399 1399
1400 /* Wake up the device so we can send it the Set-Config request */ 1400 /* Wake up the device so we can send it the Set-Config request */
1401 ret = usb_autoresume_device(dev, 1); 1401 ret = usb_autoresume_device(dev);
1402 if (ret) 1402 if (ret)
1403 goto free_interfaces; 1403 goto free_interfaces;
1404 1404
@@ -1421,7 +1421,7 @@ free_interfaces:
1421 dev->actconfig = cp; 1421 dev->actconfig = cp;
1422 if (!cp) { 1422 if (!cp) {
1423 usb_set_device_state(dev, USB_STATE_ADDRESS); 1423 usb_set_device_state(dev, USB_STATE_ADDRESS);
1424 usb_autosuspend_device(dev, 1); 1424 usb_autosuspend_device(dev);
1425 goto free_interfaces; 1425 goto free_interfaces;
1426 } 1426 }
1427 usb_set_device_state(dev, USB_STATE_CONFIGURED); 1427 usb_set_device_state(dev, USB_STATE_CONFIGURED);
@@ -1490,7 +1490,7 @@ free_interfaces:
1490 usb_create_sysfs_intf_files (intf); 1490 usb_create_sysfs_intf_files (intf);
1491 } 1491 }
1492 1492
1493 usb_autosuspend_device(dev, 1); 1493 usb_autosuspend_device(dev);
1494 return 0; 1494 return 0;
1495} 1495}
1496 1496
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index ab2f68fc7d2d..02426d0b9a34 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -200,13 +200,6 @@ static void ksuspend_usb_cleanup(void)
200 destroy_workqueue(ksuspend_usb_wq); 200 destroy_workqueue(ksuspend_usb_wq);
201} 201}
202 202
203#else
204
205#define ksuspend_usb_init() 0
206#define ksuspend_usb_cleanup() do {} while (0)
207
208#endif
209
210#ifdef CONFIG_USB_SUSPEND 203#ifdef CONFIG_USB_SUSPEND
211 204
212/* usb_autosuspend_work - callback routine to autosuspend a USB device */ 205/* usb_autosuspend_work - callback routine to autosuspend a USB device */
@@ -226,7 +219,14 @@ static void usb_autosuspend_work(struct work_struct *work)
226static void usb_autosuspend_work(struct work_struct *work) 219static void usb_autosuspend_work(struct work_struct *work)
227{} 220{}
228 221
229#endif 222#endif /* CONFIG_USB_SUSPEND */
223
224#else
225
226#define ksuspend_usb_init() 0
227#define ksuspend_usb_cleanup() do {} while (0)
228
229#endif /* CONFIG_PM */
230 230
231/** 231/**
232 * usb_alloc_dev - usb device constructor (usbcore-internal) 232 * usb_alloc_dev - usb device constructor (usbcore-internal)
@@ -538,138 +538,6 @@ int usb_get_current_frame_number(struct usb_device *dev)
538 return usb_hcd_get_frame_number (dev); 538 return usb_hcd_get_frame_number (dev);
539} 539}
540 540
541/**
542 * usb_endpoint_dir_in - check if the endpoint has IN direction
543 * @epd: endpoint to be checked
544 *
545 * Returns true if the endpoint is of type IN, otherwise it returns false.
546 */
547int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
548{
549 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
550}
551
552/**
553 * usb_endpoint_dir_out - check if the endpoint has OUT direction
554 * @epd: endpoint to be checked
555 *
556 * Returns true if the endpoint is of type OUT, otherwise it returns false.
557 */
558int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
559{
560 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
561}
562
563/**
564 * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
565 * @epd: endpoint to be checked
566 *
567 * Returns true if the endpoint is of type bulk, otherwise it returns false.
568 */
569int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
570{
571 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
572 USB_ENDPOINT_XFER_BULK);
573}
574
575/**
576 * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
577 * @epd: endpoint to be checked
578 *
579 * Returns true if the endpoint is of type interrupt, otherwise it returns
580 * false.
581 */
582int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
583{
584 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
585 USB_ENDPOINT_XFER_INT);
586}
587
588/**
589 * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
590 * @epd: endpoint to be checked
591 *
592 * Returns true if the endpoint is of type isochronous, otherwise it returns
593 * false.
594 */
595int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
596{
597 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
598 USB_ENDPOINT_XFER_ISOC);
599}
600
601/**
602 * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
603 * @epd: endpoint to be checked
604 *
605 * Returns true if the endpoint has bulk transfer type and IN direction,
606 * otherwise it returns false.
607 */
608int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
609{
610 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
611}
612
613/**
614 * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
615 * @epd: endpoint to be checked
616 *
617 * Returns true if the endpoint has bulk transfer type and OUT direction,
618 * otherwise it returns false.
619 */
620int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
621{
622 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
623}
624
625/**
626 * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
627 * @epd: endpoint to be checked
628 *
629 * Returns true if the endpoint has interrupt transfer type and IN direction,
630 * otherwise it returns false.
631 */
632int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
633{
634 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
635}
636
637/**
638 * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
639 * @epd: endpoint to be checked
640 *
641 * Returns true if the endpoint has interrupt transfer type and OUT direction,
642 * otherwise it returns false.
643 */
644int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
645{
646 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
647}
648
649/**
650 * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
651 * @epd: endpoint to be checked
652 *
653 * Returns true if the endpoint has isochronous transfer type and IN direction,
654 * otherwise it returns false.
655 */
656int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
657{
658 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
659}
660
661/**
662 * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
663 * @epd: endpoint to be checked
664 *
665 * Returns true if the endpoint has isochronous transfer type and OUT direction,
666 * otherwise it returns false.
667 */
668int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
669{
670 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
671}
672
673/*-------------------------------------------------------------------*/ 541/*-------------------------------------------------------------------*/
674/* 542/*
675 * __usb_get_extra_descriptor() finds a descriptor of specific type in the 543 * __usb_get_extra_descriptor() finds a descriptor of specific type in the
@@ -1103,18 +971,6 @@ EXPORT_SYMBOL(__usb_get_extra_descriptor);
1103EXPORT_SYMBOL(usb_find_device); 971EXPORT_SYMBOL(usb_find_device);
1104EXPORT_SYMBOL(usb_get_current_frame_number); 972EXPORT_SYMBOL(usb_get_current_frame_number);
1105 973
1106EXPORT_SYMBOL_GPL(usb_endpoint_dir_in);
1107EXPORT_SYMBOL_GPL(usb_endpoint_dir_out);
1108EXPORT_SYMBOL_GPL(usb_endpoint_xfer_bulk);
1109EXPORT_SYMBOL_GPL(usb_endpoint_xfer_int);
1110EXPORT_SYMBOL_GPL(usb_endpoint_xfer_isoc);
1111EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_in);
1112EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_out);
1113EXPORT_SYMBOL_GPL(usb_endpoint_is_int_in);
1114EXPORT_SYMBOL_GPL(usb_endpoint_is_int_out);
1115EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_in);
1116EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_out);
1117
1118EXPORT_SYMBOL (usb_buffer_alloc); 974EXPORT_SYMBOL (usb_buffer_alloc);
1119EXPORT_SYMBOL (usb_buffer_free); 975EXPORT_SYMBOL (usb_buffer_free);
1120 976
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 13322e33f912..17830a81be14 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -64,14 +64,13 @@ static inline void usb_pm_unlock(struct usb_device *udev) {}
64 64
65#define USB_AUTOSUSPEND_DELAY (HZ*2) 65#define USB_AUTOSUSPEND_DELAY (HZ*2)
66 66
67extern void usb_autosuspend_device(struct usb_device *udev, int dec_busy_cnt); 67extern void usb_autosuspend_device(struct usb_device *udev);
68extern int usb_autoresume_device(struct usb_device *udev, int inc_busy_cnt); 68extern int usb_autoresume_device(struct usb_device *udev);
69 69
70#else 70#else
71 71
72#define usb_autosuspend_device(udev, dec_busy_cnt) do {} while (0) 72#define usb_autosuspend_device(udev) do {} while (0)
73static inline int usb_autoresume_device(struct usb_device *udev, 73static inline int usb_autoresume_device(struct usb_device *udev)
74 int inc_busy_cnt)
75{ 74{
76 return 0; 75 return 0;
77} 76}
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 107119c54301..d15bf22b9a03 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1894,13 +1894,13 @@ static int eth_start_xmit (struct sk_buff *skb, struct net_device *net)
1894 if (!eth_is_promisc (dev)) { 1894 if (!eth_is_promisc (dev)) {
1895 u8 *dest = skb->data; 1895 u8 *dest = skb->data;
1896 1896
1897 if (dest [0] & 0x01) { 1897 if (is_multicast_ether_addr(dest)) {
1898 u16 type; 1898 u16 type;
1899 1899
1900 /* ignores USB_CDC_PACKET_TYPE_MULTICAST and host 1900 /* ignores USB_CDC_PACKET_TYPE_MULTICAST and host
1901 * SET_ETHERNET_MULTICAST_FILTERS requests 1901 * SET_ETHERNET_MULTICAST_FILTERS requests
1902 */ 1902 */
1903 if (memcmp (dest, net->broadcast, ETH_ALEN) == 0) 1903 if (is_broadcast_ether_addr(dest))
1904 type = USB_CDC_PACKET_TYPE_BROADCAST; 1904 type = USB_CDC_PACKET_TYPE_BROADCAST;
1905 else 1905 else
1906 type = USB_CDC_PACKET_TYPE_ALL_MULTICAST; 1906 type = USB_CDC_PACKET_TYPE_ALL_MULTICAST;
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 179259664c18..4a991564a03e 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -83,7 +83,6 @@ static int lh7a40x_queue(struct usb_ep *ep, struct usb_request *, gfp_t);
83static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *); 83static int lh7a40x_dequeue(struct usb_ep *ep, struct usb_request *);
84static int lh7a40x_set_halt(struct usb_ep *ep, int); 84static int lh7a40x_set_halt(struct usb_ep *ep, int);
85static int lh7a40x_fifo_status(struct usb_ep *ep); 85static int lh7a40x_fifo_status(struct usb_ep *ep);
86static int lh7a40x_fifo_status(struct usb_ep *ep);
87static void lh7a40x_fifo_flush(struct usb_ep *ep); 86static void lh7a40x_fifo_flush(struct usb_ep *ep);
88static void lh7a40x_ep0_kick(struct lh7a40x_udc *dev, struct lh7a40x_ep *ep); 87static void lh7a40x_ep0_kick(struct lh7a40x_udc *dev, struct lh7a40x_ep *ep);
89static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr); 88static void lh7a40x_handle_ep0(struct lh7a40x_udc *dev, u32 intr);
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 3acc896a5d4c..0b590831582c 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1040,6 +1040,7 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1040 1040
1041 } /* else the irq handler advances the queue. */ 1041 } /* else the irq handler advances the queue. */
1042 1042
1043 ep->responded = 1;
1043 if (req) 1044 if (req)
1044 list_add_tail (&req->queue, &ep->queue); 1045 list_add_tail (&req->queue, &ep->queue);
1045done: 1046done:
@@ -2188,7 +2189,8 @@ static void handle_ep_small (struct net2280_ep *ep)
2188 ep->stopped = 1; 2189 ep->stopped = 1;
2189 set_halt (ep); 2190 set_halt (ep);
2190 mode = 2; 2191 mode = 2;
2191 } else if (!req && !ep->stopped) 2192 } else if (ep->responded &&
2193 !req && !ep->stopped)
2192 write_fifo (ep, NULL); 2194 write_fifo (ep, NULL);
2193 } 2195 }
2194 } else { 2196 } else {
@@ -2203,7 +2205,7 @@ static void handle_ep_small (struct net2280_ep *ep)
2203 } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT)) 2205 } else if (((t & (1 << DATA_OUT_PING_TOKEN_INTERRUPT))
2204 && req 2206 && req
2205 && req->req.actual == req->req.length) 2207 && req->req.actual == req->req.length)
2206 || !req) { 2208 || (ep->responded && !req)) {
2207 ep->dev->protocol_stall = 1; 2209 ep->dev->protocol_stall = 1;
2208 set_halt (ep); 2210 set_halt (ep);
2209 ep->stopped = 1; 2211 ep->stopped = 1;
@@ -2469,6 +2471,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
2469 /* we made the hardware handle most lowlevel requests; 2471 /* we made the hardware handle most lowlevel requests;
2470 * everything else goes uplevel to the gadget code. 2472 * everything else goes uplevel to the gadget code.
2471 */ 2473 */
2474 ep->responded = 1;
2472 switch (u.r.bRequest) { 2475 switch (u.r.bRequest) {
2473 case USB_REQ_GET_STATUS: { 2476 case USB_REQ_GET_STATUS: {
2474 struct net2280_ep *e; 2477 struct net2280_ep *e;
@@ -2537,6 +2540,7 @@ delegate:
2537 u.r.bRequestType, u.r.bRequest, 2540 u.r.bRequestType, u.r.bRequest,
2538 w_value, w_index, w_length, 2541 w_value, w_index, w_length,
2539 readl (&ep->regs->ep_cfg)); 2542 readl (&ep->regs->ep_cfg));
2543 ep->responded = 0;
2540 spin_unlock (&dev->lock); 2544 spin_unlock (&dev->lock);
2541 tmp = dev->driver->setup (&dev->gadget, &u.r); 2545 tmp = dev->driver->setup (&dev->gadget, &u.r);
2542 spin_lock (&dev->lock); 2546 spin_lock (&dev->lock);
diff --git a/drivers/usb/gadget/net2280.h b/drivers/usb/gadget/net2280.h
index 957d6df34015..44ca139983d8 100644
--- a/drivers/usb/gadget/net2280.h
+++ b/drivers/usb/gadget/net2280.h
@@ -110,7 +110,8 @@ struct net2280_ep {
110 out_overflow : 1, 110 out_overflow : 1,
111 stopped : 1, 111 stopped : 1,
112 is_in : 1, 112 is_in : 1,
113 is_iso : 1; 113 is_iso : 1,
114 responded : 1;
114}; 115};
115 116
116static inline void allow_status (struct net2280_ep *ep) 117static inline void allow_status (struct net2280_ep *ep)
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 671c24bc6d75..1ed506e95985 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -2472,6 +2472,7 @@ static struct pxa2xx_udc memory = {
2472#define PXA210_B1 0x00000123 2472#define PXA210_B1 0x00000123
2473#define PXA210_B0 0x00000122 2473#define PXA210_B0 0x00000122
2474#define IXP425_A0 0x000001c1 2474#define IXP425_A0 0x000001c1
2475#define IXP425_B0 0x000001f1
2475#define IXP465_AD 0x00000200 2476#define IXP465_AD 0x00000200
2476 2477
2477/* 2478/*
@@ -2509,6 +2510,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2509 break; 2510 break;
2510#elif defined(CONFIG_ARCH_IXP4XX) 2511#elif defined(CONFIG_ARCH_IXP4XX)
2511 case IXP425_A0: 2512 case IXP425_A0:
2513 case IXP425_B0:
2512 case IXP465_AD: 2514 case IXP465_AD:
2513 dev->has_cfr = 1; 2515 dev->has_cfr = 1;
2514 out_dma = 0; 2516 out_dma = 0;
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index cf10cbc98f80..cc60759083bf 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -153,7 +153,7 @@ config USB_U132_HCD
153 adapter will *NOT* work with PC cards that do not contain an OHCI 153 adapter will *NOT* work with PC cards that do not contain an OHCI
154 controller. 154 controller.
155 155
156 For those PC cards that contain multiple OHCI controllers only ther 156 For those PC cards that contain multiple OHCI controllers only the
157 first one is used. 157 first one is used.
158 158
159 The driver consists of two modules, the "ftdi-elan" module is a 159 The driver consists of two modules, the "ftdi-elan" module is a
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 9030994aba98..025d33313681 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -126,6 +126,11 @@ static unsigned park = 0;
126module_param (park, uint, S_IRUGO); 126module_param (park, uint, S_IRUGO);
127MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets"); 127MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets");
128 128
129/* for flakey hardware, ignore overcurrent indicators */
130static int ignore_oc = 0;
131module_param (ignore_oc, bool, S_IRUGO);
132MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications");
133
129#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) 134#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
130 135
131/*-------------------------------------------------------------------------*/ 136/*-------------------------------------------------------------------------*/
@@ -541,9 +546,10 @@ static int ehci_run (struct usb_hcd *hcd)
541 546
542 temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); 547 temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
543 ehci_info (ehci, 548 ehci_info (ehci,
544 "USB %x.%x started, EHCI %x.%02x, driver %s\n", 549 "USB %x.%x started, EHCI %x.%02x, driver %s%s\n",
545 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), 550 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
546 temp >> 8, temp & 0xff, DRIVER_VERSION); 551 temp >> 8, temp & 0xff, DRIVER_VERSION,
552 ignore_oc ? ", overcurrent ignored" : "");
547 553
548 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ 554 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */
549 555
@@ -613,9 +619,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
613 unsigned i = HCS_N_PORTS (ehci->hcs_params); 619 unsigned i = HCS_N_PORTS (ehci->hcs_params);
614 620
615 /* resume root hub? */ 621 /* resume root hub? */
616 status = readl (&ehci->regs->command); 622 if (!(readl(&ehci->regs->command) & CMD_RUN))
617 if (!(status & CMD_RUN)) 623 usb_hcd_resume_root_hub(hcd);
618 writel (status | CMD_RUN, &ehci->regs->command);
619 624
620 while (i--) { 625 while (i--) {
621 int pstatus = readl (&ehci->regs->port_status [i]); 626 int pstatus = readl (&ehci->regs->port_status [i]);
@@ -632,7 +637,6 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
632 */ 637 */
633 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 638 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
634 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 639 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
635 usb_hcd_resume_root_hub(hcd);
636 } 640 }
637 } 641 }
638 642
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 1b20722c102b..bfe5f307cba6 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -34,6 +34,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
34{ 34{
35 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 35 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
36 int port; 36 int port;
37 int mask;
37 38
38 if (time_before (jiffies, ehci->next_statechange)) 39 if (time_before (jiffies, ehci->next_statechange))
39 msleep(5); 40 msleep(5);
@@ -51,14 +52,25 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
51 ehci->reclaim_ready = 1; 52 ehci->reclaim_ready = 1;
52 ehci_work(ehci); 53 ehci_work(ehci);
53 54
54 /* suspend any active/unsuspended ports, maybe allow wakeup */ 55 /* Unlike other USB host controller types, EHCI doesn't have
56 * any notion of "global" or bus-wide suspend. The driver has
57 * to manually suspend all the active unsuspended ports, and
58 * then manually resume them in the bus_resume() routine.
59 */
60 ehci->bus_suspended = 0;
55 while (port--) { 61 while (port--) {
56 u32 __iomem *reg = &ehci->regs->port_status [port]; 62 u32 __iomem *reg = &ehci->regs->port_status [port];
57 u32 t1 = readl (reg) & ~PORT_RWC_BITS; 63 u32 t1 = readl (reg) & ~PORT_RWC_BITS;
58 u32 t2 = t1; 64 u32 t2 = t1;
59 65
60 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER)) 66 /* keep track of which ports we suspend */
67 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER) &&
68 !(t1 & PORT_SUSPEND)) {
61 t2 |= PORT_SUSPEND; 69 t2 |= PORT_SUSPEND;
70 set_bit(port, &ehci->bus_suspended);
71 }
72
73 /* enable remote wakeup on all ports */
62 if (device_may_wakeup(&hcd->self.root_hub->dev)) 74 if (device_may_wakeup(&hcd->self.root_hub->dev))
63 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; 75 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
64 else 76 else
@@ -76,6 +88,13 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
76 ehci_halt (ehci); 88 ehci_halt (ehci);
77 hcd->state = HC_STATE_SUSPENDED; 89 hcd->state = HC_STATE_SUSPENDED;
78 90
91 /* allow remote wakeup */
92 mask = INTR_MASK;
93 if (!device_may_wakeup(&hcd->self.root_hub->dev))
94 mask &= ~STS_PCD;
95 writel(mask, &ehci->regs->intr_enable);
96 readl(&ehci->regs->intr_enable);
97
79 ehci->next_statechange = jiffies + msecs_to_jiffies(10); 98 ehci->next_statechange = jiffies + msecs_to_jiffies(10);
80 spin_unlock_irq (&ehci->lock); 99 spin_unlock_irq (&ehci->lock);
81 return 0; 100 return 0;
@@ -88,7 +107,6 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
88 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 107 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
89 u32 temp; 108 u32 temp;
90 int i; 109 int i;
91 int intr_enable;
92 110
93 if (time_before (jiffies, ehci->next_statechange)) 111 if (time_before (jiffies, ehci->next_statechange))
94 msleep(5); 112 msleep(5);
@@ -100,31 +118,30 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
100 * the last user of the controller, not reset/pm hardware keeping 118 * the last user of the controller, not reset/pm hardware keeping
101 * state we gave to it. 119 * state we gave to it.
102 */ 120 */
121 temp = readl(&ehci->regs->intr_enable);
122 ehci_dbg(ehci, "resume root hub%s\n", temp ? "" : " after power loss");
103 123
104 /* re-init operational registers in case we lost power */ 124 /* at least some APM implementations will try to deliver
105 if (readl (&ehci->regs->intr_enable) == 0) { 125 * IRQs right away, so delay them until we're ready.
106 /* at least some APM implementations will try to deliver 126 */
107 * IRQs right away, so delay them until we're ready. 127 writel(0, &ehci->regs->intr_enable);
108 */ 128
109 intr_enable = 1; 129 /* re-init operational registers */
110 writel (0, &ehci->regs->segment); 130 writel(0, &ehci->regs->segment);
111 writel (ehci->periodic_dma, &ehci->regs->frame_list); 131 writel(ehci->periodic_dma, &ehci->regs->frame_list);
112 writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next); 132 writel((u32) ehci->async->qh_dma, &ehci->regs->async_next);
113 } else
114 intr_enable = 0;
115 ehci_dbg(ehci, "resume root hub%s\n",
116 intr_enable ? " after power loss" : "");
117 133
118 /* restore CMD_RUN, framelist size, and irq threshold */ 134 /* restore CMD_RUN, framelist size, and irq threshold */
119 writel (ehci->command, &ehci->regs->command); 135 writel (ehci->command, &ehci->regs->command);
120 136
121 /* take ports out of suspend */ 137 /* manually resume the ports we suspended during bus_suspend() */
122 i = HCS_N_PORTS (ehci->hcs_params); 138 i = HCS_N_PORTS (ehci->hcs_params);
123 while (i--) { 139 while (i--) {
124 temp = readl (&ehci->regs->port_status [i]); 140 temp = readl (&ehci->regs->port_status [i]);
125 temp &= ~(PORT_RWC_BITS 141 temp &= ~(PORT_RWC_BITS
126 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E); 142 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
127 if (temp & PORT_SUSPEND) { 143 if (test_bit(i, &ehci->bus_suspended) &&
144 (temp & PORT_SUSPEND)) {
128 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 145 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
129 temp |= PORT_RESUME; 146 temp |= PORT_RESUME;
130 } 147 }
@@ -134,11 +151,12 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
134 mdelay (20); 151 mdelay (20);
135 while (i--) { 152 while (i--) {
136 temp = readl (&ehci->regs->port_status [i]); 153 temp = readl (&ehci->regs->port_status [i]);
137 if ((temp & PORT_SUSPEND) == 0) 154 if (test_bit(i, &ehci->bus_suspended) &&
138 continue; 155 (temp & PORT_SUSPEND)) {
139 temp &= ~(PORT_RWC_BITS | PORT_RESUME); 156 temp &= ~(PORT_RWC_BITS | PORT_RESUME);
140 writel (temp, &ehci->regs->port_status [i]); 157 writel (temp, &ehci->regs->port_status [i]);
141 ehci_vdbg (ehci, "resumed port %d\n", i + 1); 158 ehci_vdbg (ehci, "resumed port %d\n", i + 1);
159 }
142 } 160 }
143 (void) readl (&ehci->regs->command); 161 (void) readl (&ehci->regs->command);
144 162
@@ -157,8 +175,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
157 hcd->state = HC_STATE_RUNNING; 175 hcd->state = HC_STATE_RUNNING;
158 176
159 /* Now we can safely re-enable irqs */ 177 /* Now we can safely re-enable irqs */
160 if (intr_enable) 178 writel(INTR_MASK, &ehci->regs->intr_enable);
161 writel (INTR_MASK, &ehci->regs->intr_enable);
162 179
163 spin_unlock_irq (&ehci->lock); 180 spin_unlock_irq (&ehci->lock);
164 return 0; 181 return 0;
@@ -218,6 +235,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
218{ 235{
219 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 236 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
220 u32 temp, status = 0; 237 u32 temp, status = 0;
238 u32 mask;
221 int ports, i, retval = 1; 239 int ports, i, retval = 1;
222 unsigned long flags; 240 unsigned long flags;
223 241
@@ -233,6 +251,18 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
233 retval++; 251 retval++;
234 } 252 }
235 253
254 /* Some boards (mostly VIA?) report bogus overcurrent indications,
255 * causing massive log spam unless we completely ignore them. It
256 * may be relevant that VIA VT8235 controlers, where PORT_POWER is
257 * always set, seem to clear PORT_OCC and PORT_CSC when writing to
258 * PORT_POWER; that's surprising, but maybe within-spec.
259 */
260 if (!ignore_oc)
261 mask = PORT_CSC | PORT_PEC | PORT_OCC;
262 else
263 mask = PORT_CSC | PORT_PEC;
264 // PORT_RESUME from hardware ~= PORT_STAT_C_SUSPEND
265
236 /* no hub change reports (bit 0) for now (power, ...) */ 266 /* no hub change reports (bit 0) for now (power, ...) */
237 267
238 /* port N changes (bit N)? */ 268 /* port N changes (bit N)? */
@@ -250,8 +280,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
250 } 280 }
251 if (!(temp & PORT_CONNECT)) 281 if (!(temp & PORT_CONNECT))
252 ehci->reset_done [i] = 0; 282 ehci->reset_done [i] = 0;
253 if ((temp & (PORT_CSC | PORT_PEC | PORT_OCC)) != 0 283 if ((temp & mask) != 0
254 // PORT_STAT_C_SUSPEND?
255 || ((temp & PORT_RESUME) != 0 284 || ((temp & PORT_RESUME) != 0
256 && time_after (jiffies, 285 && time_after (jiffies,
257 ehci->reset_done [i]))) { 286 ehci->reset_done [i]))) {
@@ -319,6 +348,7 @@ static int ehci_hub_control (
319 u32 temp, status; 348 u32 temp, status;
320 unsigned long flags; 349 unsigned long flags;
321 int retval = 0; 350 int retval = 0;
351 unsigned selector;
322 352
323 /* 353 /*
324 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. 354 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
@@ -417,7 +447,7 @@ static int ehci_hub_control (
417 status |= 1 << USB_PORT_FEAT_C_CONNECTION; 447 status |= 1 << USB_PORT_FEAT_C_CONNECTION;
418 if (temp & PORT_PEC) 448 if (temp & PORT_PEC)
419 status |= 1 << USB_PORT_FEAT_C_ENABLE; 449 status |= 1 << USB_PORT_FEAT_C_ENABLE;
420 if (temp & PORT_OCC) 450 if ((temp & PORT_OCC) && !ignore_oc)
421 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; 451 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
422 452
423 /* whoever resumes must GetPortStatus to complete it!! */ 453 /* whoever resumes must GetPortStatus to complete it!! */
@@ -506,6 +536,8 @@ static int ehci_hub_control (
506 } 536 }
507 break; 537 break;
508 case SetPortFeature: 538 case SetPortFeature:
539 selector = wIndex >> 8;
540 wIndex &= 0xff;
509 if (!wIndex || wIndex > ports) 541 if (!wIndex || wIndex > ports)
510 goto error; 542 goto error;
511 wIndex--; 543 wIndex--;
@@ -559,6 +591,22 @@ static int ehci_hub_control (
559 } 591 }
560 writel (temp, &ehci->regs->port_status [wIndex]); 592 writel (temp, &ehci->regs->port_status [wIndex]);
561 break; 593 break;
594
595 /* For downstream facing ports (these): one hub port is put
596 * into test mode according to USB2 11.24.2.13, then the hub
597 * must be reset (which for root hub now means rmmod+modprobe,
598 * or else system reboot). See EHCI 2.3.9 and 4.14 for info
599 * about the EHCI-specific stuff.
600 */
601 case USB_PORT_FEAT_TEST:
602 if (!selector || selector > 5)
603 goto error;
604 ehci_quiesce(ehci);
605 ehci_halt(ehci);
606 temp |= selector << 16;
607 writel (temp, &ehci->regs->port_status [wIndex]);
608 break;
609
562 default: 610 default:
563 goto error; 611 goto error;
564 } 612 }
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index e51c1ed81ac4..4bc7970ba3ef 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -257,9 +257,7 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
257static int ehci_pci_resume(struct usb_hcd *hcd) 257static int ehci_pci_resume(struct usb_hcd *hcd)
258{ 258{
259 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 259 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
260 unsigned port;
261 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 260 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
262 int retval = -EINVAL;
263 261
264 // maybe restore FLADJ 262 // maybe restore FLADJ
265 263
@@ -269,27 +267,19 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
269 /* Mark hardware accessible again as we are out of D3 state by now */ 267 /* Mark hardware accessible again as we are out of D3 state by now */
270 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 268 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
271 269
272 /* If CF is clear, we lost PCI Vaux power and need to restart. */ 270 /* If CF is still set, we maintained PCI Vaux power.
273 if (readl(&ehci->regs->configured_flag) != FLAG_CF) 271 * Just undo the effect of ehci_pci_suspend().
274 goto restart;
275
276 /* If any port is suspended (or owned by the companion),
277 * we know we can/must resume the HC (and mustn't reset it).
278 * We just defer that to the root hub code.
279 */ 272 */
280 for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { 273 if (readl(&ehci->regs->configured_flag) == FLAG_CF) {
281 u32 status; 274 int mask = INTR_MASK;
282 port--; 275
283 status = readl(&ehci->regs->port_status [port]); 276 if (!device_may_wakeup(&hcd->self.root_hub->dev))
284 if (!(status & PORT_POWER)) 277 mask &= ~STS_PCD;
285 continue; 278 writel(mask, &ehci->regs->intr_enable);
286 if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) { 279 readl(&ehci->regs->intr_enable);
287 usb_hcd_resume_root_hub(hcd); 280 return 0;
288 return 0;
289 }
290 } 281 }
291 282
292restart:
293 ehci_dbg(ehci, "lost power, restarting\n"); 283 ehci_dbg(ehci, "lost power, restarting\n");
294 usb_root_hub_lost_power(hcd->self.root_hub); 284 usb_root_hub_lost_power(hcd->self.root_hub);
295 285
@@ -307,13 +297,15 @@ restart:
307 ehci_work(ehci); 297 ehci_work(ehci);
308 spin_unlock_irq(&ehci->lock); 298 spin_unlock_irq(&ehci->lock);
309 299
310 /* restart; khubd will disconnect devices */
311 retval = ehci_run(hcd);
312
313 /* here we "know" root ports should always stay powered */ 300 /* here we "know" root ports should always stay powered */
314 ehci_port_power(ehci, 1); 301 ehci_port_power(ehci, 1);
315 302
316 return retval; 303 writel(ehci->command, &ehci->regs->command);
304 writel(FLAG_CF, &ehci->regs->configured_flag);
305 readl(&ehci->regs->command); /* unblock posted writes */
306
307 hcd->state = HC_STATE_SUSPENDED;
308 return 0;
317} 309}
318#endif 310#endif
319 311
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index bbc3082a73d7..74dbc6c8228f 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -74,6 +74,7 @@ struct ehci_hcd { /* one per controller */
74 74
75 /* per root hub port */ 75 /* per root hub port */
76 unsigned long reset_done [EHCI_MAX_ROOT_PORTS]; 76 unsigned long reset_done [EHCI_MAX_ROOT_PORTS];
77 unsigned long bus_suspended;
77 78
78 /* per-HC memory pools (could be per-bus, but ...) */ 79 /* per-HC memory pools (could be per-bus, but ...) */
79 struct dma_pool *qh_pool; /* qh per active urb */ 80 struct dma_pool *qh_pool; /* qh per active urb */
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index ea4714e557e4..a95275a401b1 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -729,6 +729,16 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
729 ohci->next_statechange = jiffies + STATECHANGE_DELAY; 729 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
730 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC, 730 ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC,
731 &regs->intrstatus); 731 &regs->intrstatus);
732
733 /* NOTE: Vendors didn't always make the same implementation
734 * choices for RHSC. Many followed the spec; RHSC triggers
735 * on an edge, like setting and maybe clearing a port status
736 * change bit. With others it's level-triggered, active
737 * until khubd clears all the port status change bits. We'll
738 * always disable it here and rely on polling until khubd
739 * re-enables it.
740 */
741 ohci_writel(ohci, OHCI_INTR_RHSC, &regs->intrdisable);
732 usb_hcd_poll_rh_status(hcd); 742 usb_hcd_poll_rh_status(hcd);
733 } 743 }
734 744
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 6995ea36f2e8..2441642cb7b4 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -41,7 +41,11 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd)
41{ 41{
42 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 42 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
43 43
44 ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); 44 spin_lock_irq(&ohci->lock);
45 if (!ohci->autostop)
46 del_timer(&hcd->rh_timer); /* Prevent next poll */
47 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable);
48 spin_unlock_irq(&ohci->lock);
45} 49}
46 50
47#define OHCI_SCHED_ENABLES \ 51#define OHCI_SCHED_ENABLES \
@@ -50,6 +54,9 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd)
50static void dl_done_list (struct ohci_hcd *); 54static void dl_done_list (struct ohci_hcd *);
51static void finish_unlinks (struct ohci_hcd *, u16); 55static void finish_unlinks (struct ohci_hcd *, u16);
52 56
57#ifdef CONFIG_PM
58static int ohci_restart(struct ohci_hcd *ohci);
59
53static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop) 60static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop)
54__releases(ohci->lock) 61__releases(ohci->lock)
55__acquires(ohci->lock) 62__acquires(ohci->lock)
@@ -132,8 +139,6 @@ static inline struct ed *find_head (struct ed *ed)
132 return ed; 139 return ed;
133} 140}
134 141
135static int ohci_restart (struct ohci_hcd *ohci);
136
137/* caller has locked the root hub */ 142/* caller has locked the root hub */
138static int ohci_rh_resume (struct ohci_hcd *ohci) 143static int ohci_rh_resume (struct ohci_hcd *ohci)
139__releases(ohci->lock) 144__releases(ohci->lock)
@@ -169,7 +174,7 @@ __acquires(ohci->lock)
169 break; 174 break;
170 case OHCI_USB_RESUME: 175 case OHCI_USB_RESUME:
171 /* HCFS changes sometime after INTR_RD */ 176 /* HCFS changes sometime after INTR_RD */
172 ohci_info(ohci, "%swakeup\n", 177 ohci_dbg(ohci, "%swakeup root hub\n",
173 autostopped ? "auto-" : ""); 178 autostopped ? "auto-" : "");
174 break; 179 break;
175 case OHCI_USB_OPER: 180 case OHCI_USB_OPER:
@@ -181,7 +186,6 @@ __acquires(ohci->lock)
181 ohci_dbg (ohci, "lost power\n"); 186 ohci_dbg (ohci, "lost power\n");
182 status = -EBUSY; 187 status = -EBUSY;
183 } 188 }
184#ifdef CONFIG_PM
185 if (status == -EBUSY) { 189 if (status == -EBUSY) {
186 if (!autostopped) { 190 if (!autostopped) {
187 spin_unlock_irq (&ohci->lock); 191 spin_unlock_irq (&ohci->lock);
@@ -191,25 +195,12 @@ __acquires(ohci->lock)
191 } 195 }
192 return status; 196 return status;
193 } 197 }
194#endif
195 if (status != -EINPROGRESS) 198 if (status != -EINPROGRESS)
196 return status; 199 return status;
197 if (autostopped) 200 if (autostopped)
198 goto skip_resume; 201 goto skip_resume;
199 spin_unlock_irq (&ohci->lock); 202 spin_unlock_irq (&ohci->lock);
200 203
201 temp = ohci->num_ports;
202 while (temp--) {
203 u32 stat = ohci_readl (ohci,
204 &ohci->regs->roothub.portstatus [temp]);
205
206 /* force global, not selective, resume */
207 if (!(stat & RH_PS_PSS))
208 continue;
209 ohci_writel (ohci, RH_PS_POCI,
210 &ohci->regs->roothub.portstatus [temp]);
211 }
212
213 /* Some controllers (lucent erratum) need extra-long delays */ 204 /* Some controllers (lucent erratum) need extra-long delays */
214 msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1); 205 msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1);
215 206
@@ -217,6 +208,7 @@ __acquires(ohci->lock)
217 temp &= OHCI_CTRL_HCFS; 208 temp &= OHCI_CTRL_HCFS;
218 if (temp != OHCI_USB_RESUME) { 209 if (temp != OHCI_USB_RESUME) {
219 ohci_err (ohci, "controller won't resume\n"); 210 ohci_err (ohci, "controller won't resume\n");
211 spin_lock_irq(&ohci->lock);
220 return -EBUSY; 212 return -EBUSY;
221 } 213 }
222 214
@@ -296,8 +288,6 @@ skip_resume:
296 return 0; 288 return 0;
297} 289}
298 290
299#ifdef CONFIG_PM
300
301static int ohci_bus_suspend (struct usb_hcd *hcd) 291static int ohci_bus_suspend (struct usb_hcd *hcd)
302{ 292{
303 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 293 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
@@ -335,6 +325,83 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
335 return rc; 325 return rc;
336} 326}
337 327
328/* Carry out polling-, autostop-, and autoresume-related state changes */
329static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
330 int any_connected)
331{
332 int poll_rh = 1;
333
334 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
335
336 case OHCI_USB_OPER:
337 /* keep on polling until we know a device is connected
338 * and RHSC is enabled */
339 if (!ohci->autostop) {
340 if (any_connected ||
341 !device_may_wakeup(&ohci_to_hcd(ohci)
342 ->self.root_hub->dev)) {
343 if (ohci_readl(ohci, &ohci->regs->intrenable) &
344 OHCI_INTR_RHSC)
345 poll_rh = 0;
346 } else {
347 ohci->autostop = 1;
348 ohci->next_statechange = jiffies + HZ;
349 }
350
351 /* if no devices have been attached for one second, autostop */
352 } else {
353 if (changed || any_connected) {
354 ohci->autostop = 0;
355 ohci->next_statechange = jiffies +
356 STATECHANGE_DELAY;
357 } else if (time_after_eq(jiffies,
358 ohci->next_statechange)
359 && !ohci->ed_rm_list
360 && !(ohci->hc_control &
361 OHCI_SCHED_ENABLES)) {
362 ohci_rh_suspend(ohci, 1);
363 }
364 }
365 break;
366
367 /* if there is a port change, autostart or ask to be resumed */
368 case OHCI_USB_SUSPEND:
369 case OHCI_USB_RESUME:
370 if (changed) {
371 if (ohci->autostop)
372 ohci_rh_resume(ohci);
373 else
374 usb_hcd_resume_root_hub(ohci_to_hcd(ohci));
375 } else {
376 /* everything is idle, no need for polling */
377 poll_rh = 0;
378 }
379 break;
380 }
381 return poll_rh;
382}
383
384#else /* CONFIG_PM */
385
386static inline int ohci_rh_resume(struct ohci_hcd *ohci)
387{
388 return 0;
389}
390
391/* Carry out polling-related state changes.
392 * autostop isn't used when CONFIG_PM is turned off.
393 */
394static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
395 int any_connected)
396{
397 int poll_rh = 1;
398
399 /* keep on polling until RHSC is enabled */
400 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC)
401 poll_rh = 0;
402 return poll_rh;
403}
404
338#endif /* CONFIG_PM */ 405#endif /* CONFIG_PM */
339 406
340/*-------------------------------------------------------------------------*/ 407/*-------------------------------------------------------------------------*/
@@ -346,7 +413,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
346{ 413{
347 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 414 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
348 int i, changed = 0, length = 1; 415 int i, changed = 0, length = 1;
349 int any_connected = 0, rhsc_enabled = 1; 416 int any_connected = 0;
350 unsigned long flags; 417 unsigned long flags;
351 418
352 spin_lock_irqsave (&ohci->lock, flags); 419 spin_lock_irqsave (&ohci->lock, flags);
@@ -387,67 +454,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
387 } 454 }
388 } 455 }
389 456
390 /* NOTE: vendors didn't always make the same implementation 457 hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed,
391 * choices for RHSC. Sometimes it triggers on an edge (like 458 any_connected);
392 * setting and maybe clearing a port status change bit); and
393 * it's level-triggered on other silicon, active until khubd
394 * clears all active port status change bits. If it's still
395 * set (level-triggered) we must disable it and rely on
396 * polling until khubd re-enables it.
397 */
398 if (ohci_readl (ohci, &ohci->regs->intrstatus) & OHCI_INTR_RHSC) {
399 ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrdisable);
400 (void) ohci_readl (ohci, &ohci->regs->intrdisable);
401 rhsc_enabled = 0;
402 }
403 hcd->poll_rh = 1;
404
405 /* carry out appropriate state changes */
406 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
407
408 case OHCI_USB_OPER:
409 /* keep on polling until we know a device is connected
410 * and RHSC is enabled */
411 if (!ohci->autostop) {
412 if (any_connected) {
413 if (rhsc_enabled)
414 hcd->poll_rh = 0;
415 } else {
416 ohci->autostop = 1;
417 ohci->next_statechange = jiffies + HZ;
418 }
419
420 /* if no devices have been attached for one second, autostop */
421 } else {
422 if (changed || any_connected) {
423 ohci->autostop = 0;
424 ohci->next_statechange = jiffies +
425 STATECHANGE_DELAY;
426 } else if (device_may_wakeup(&hcd->self.root_hub->dev)
427 && time_after_eq(jiffies,
428 ohci->next_statechange)
429 && !ohci->ed_rm_list
430 && !(ohci->hc_control &
431 OHCI_SCHED_ENABLES)) {
432 ohci_rh_suspend (ohci, 1);
433 }
434 }
435 break;
436
437 /* if there is a port change, autostart or ask to be resumed */
438 case OHCI_USB_SUSPEND:
439 case OHCI_USB_RESUME:
440 if (changed) {
441 if (ohci->autostop)
442 ohci_rh_resume (ohci);
443 else
444 usb_hcd_resume_root_hub (hcd);
445 } else {
446 /* everything is idle, no need for polling */
447 hcd->poll_rh = 0;
448 }
449 break;
450 }
451 459
452done: 460done:
453 spin_unlock_irqrestore (&ohci->lock, flags); 461 spin_unlock_irqrestore (&ohci->lock, flags);
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 4f95a249c913..a9d7119e3176 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -71,7 +71,7 @@ static int distrust_firmware = 1;
71module_param(distrust_firmware, bool, 0); 71module_param(distrust_firmware, bool, 0);
72MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" 72MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren"
73 "t setup"); 73 "t setup");
74DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); 74static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
75/* 75/*
76* u132_module_lock exists to protect access to global variables 76* u132_module_lock exists to protect access to global variables
77* 77*
@@ -205,13 +205,9 @@ struct u132 {
205 struct u132_port port[MAX_U132_PORTS]; 205 struct u132_port port[MAX_U132_PORTS];
206 struct u132_endp *endp[MAX_U132_ENDPS]; 206 struct u132_endp *endp[MAX_U132_ENDPS];
207}; 207};
208int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data); 208
209int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, u8 addressofs,
210 u8 width, u32 *data);
211int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, u8 addressofs,
212 u8 width, u32 data);
213/* 209/*
214* these can not be inlines because we need the structure offset!! 210* these cannot be inlines because we need the structure offset!!
215* Does anyone have a better way????? 211* Does anyone have a better way?????
216*/ 212*/
217#define u132_read_pcimem(u132, member, data) \ 213#define u132_read_pcimem(u132, member, data) \
@@ -3031,7 +3027,7 @@ static struct hc_driver u132_hc_driver = {
3031* This function may be called by the USB core whilst the "usb_all_devices_rwsem" 3027* This function may be called by the USB core whilst the "usb_all_devices_rwsem"
3032* is held for writing, thus this module must not call usb_remove_hcd() 3028* is held for writing, thus this module must not call usb_remove_hcd()
3033* synchronously - but instead should immediately stop activity to the 3029* synchronously - but instead should immediately stop activity to the
3034* device and ansynchronously call usb_remove_hcd() 3030* device and asynchronously call usb_remove_hcd()
3035*/ 3031*/
3036static int __devexit u132_remove(struct platform_device *pdev) 3032static int __devexit u132_remove(struct platform_device *pdev)
3037{ 3033{
@@ -3227,7 +3223,7 @@ static int u132_resume(struct platform_device *pdev)
3227#define u132_resume NULL 3223#define u132_resume NULL
3228#endif 3224#endif
3229/* 3225/*
3230* this driver is loaded explicitely by ftdi_u132 3226* this driver is loaded explicitly by ftdi_u132
3231* 3227*
3232* the platform_driver struct is static because it is per type of module 3228* the platform_driver struct is static because it is per type of module
3233*/ 3229*/
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 3038ed0700d3..8ccddf74534a 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -796,7 +796,7 @@ static int mts_usb_probe(struct usb_interface *intf,
796 796
797 new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL); 797 new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL);
798 if (!new_desc->context.scsi_status) 798 if (!new_desc->context.scsi_status)
799 goto out_kfree2; 799 goto out_free_urb;
800 800
801 new_desc->usb_dev = dev; 801 new_desc->usb_dev = dev;
802 new_desc->usb_intf = intf; 802 new_desc->usb_intf = intf;
@@ -822,18 +822,20 @@ static int mts_usb_probe(struct usb_interface *intf,
822 new_desc->host = scsi_host_alloc(&mts_scsi_host_template, 822 new_desc->host = scsi_host_alloc(&mts_scsi_host_template,
823 sizeof(new_desc)); 823 sizeof(new_desc));
824 if (!new_desc->host) 824 if (!new_desc->host)
825 goto out_free_urb; 825 goto out_kfree2;
826 826
827 new_desc->host->hostdata[0] = (unsigned long)new_desc; 827 new_desc->host->hostdata[0] = (unsigned long)new_desc;
828 if (scsi_add_host(new_desc->host, NULL)) { 828 if (scsi_add_host(new_desc->host, NULL)) {
829 err_retval = -EIO; 829 err_retval = -EIO;
830 goto out_free_urb; 830 goto out_host_put;
831 } 831 }
832 scsi_scan_host(new_desc->host); 832 scsi_scan_host(new_desc->host);
833 833
834 usb_set_intfdata(intf, new_desc); 834 usb_set_intfdata(intf, new_desc);
835 return 0; 835 return 0;
836 836
837 out_host_put:
838 scsi_host_put(new_desc->host);
837 out_kfree2: 839 out_kfree2:
838 kfree(new_desc->context.scsi_status); 840 kfree(new_desc->context.scsi_status);
839 out_free_urb: 841 out_free_urb:
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 20db36448ab3..661af7aa6236 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -221,6 +221,7 @@ config USB_TOUCHSCREEN
221 - ITM 221 - ITM
222 - some other eTurboTouch 222 - some other eTurboTouch
223 - Gunze AHL61 223 - Gunze AHL61
224 - DMC TSC-10/25
224 225
225 Have a look at <http://linux.chapter7.ch/touchkit/> for 226 Have a look at <http://linux.chapter7.ch/touchkit/> for
226 a usage description and the required user-space stuff. 227 a usage description and the required user-space stuff.
@@ -258,6 +259,11 @@ config USB_TOUCHSCREEN_GUNZE
258 bool "Gunze AHL61 device support" if EMBEDDED 259 bool "Gunze AHL61 device support" if EMBEDDED
259 depends on USB_TOUCHSCREEN 260 depends on USB_TOUCHSCREEN
260 261
262config USB_TOUCHSCREEN_DMC_TSC10
263 default y
264 bool "DMC TSC-10/25 device support" if EMBEDDED
265 depends on USB_TOUCHSCREEN
266
261config USB_YEALINK 267config USB_YEALINK
262 tristate "Yealink usb-p1k voip phone" 268 tristate "Yealink usb-p1k voip phone"
263 depends on USB && INPUT && EXPERIMENTAL 269 depends on USB && INPUT && EXPERIMENTAL
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index f659f3028ad2..ff23318dc301 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -630,19 +630,14 @@ static int ati_remote_alloc_buffers(struct usb_device *udev,
630 */ 630 */
631static void ati_remote_free_buffers(struct ati_remote *ati_remote) 631static void ati_remote_free_buffers(struct ati_remote *ati_remote)
632{ 632{
633 if (ati_remote->irq_urb) 633 usb_free_urb(ati_remote->irq_urb);
634 usb_free_urb(ati_remote->irq_urb); 634 usb_free_urb(ati_remote->out_urb);
635 635
636 if (ati_remote->out_urb) 636 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
637 usb_free_urb(ati_remote->out_urb); 637 ati_remote->inbuf, ati_remote->inbuf_dma);
638 638
639 if (ati_remote->inbuf) 639 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
640 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 640 ati_remote->outbuf, ati_remote->outbuf_dma);
641 ati_remote->inbuf, ati_remote->inbuf_dma);
642
643 if (ati_remote->outbuf)
644 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
645 ati_remote->inbuf, ati_remote->outbuf_dma);
646} 641}
647 642
648static void ati_remote_input_init(struct ati_remote *ati_remote) 643static void ati_remote_input_init(struct ati_remote *ati_remote)
diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c
index f982a2b4a7f9..83f1f79db7c7 100644
--- a/drivers/usb/input/ati_remote2.c
+++ b/drivers/usb/input/ati_remote2.c
@@ -372,8 +372,7 @@ static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2)
372 int i; 372 int i;
373 373
374 for (i = 0; i < 2; i++) { 374 for (i = 0; i < 2; i++) {
375 if (ar2->urb[i]) 375 usb_free_urb(ar2->urb[i]);
376 usb_free_urb(ar2->urb[i]);
377 376
378 if (ar2->buf[i]) 377 if (ar2->buf[i])
379 usb_buffer_free(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]); 378 usb_buffer_free(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]);
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index ebc9e823a46e..4295bab4f1e2 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -968,21 +968,30 @@ static void hid_retry_timeout(unsigned long _hid)
968 hid_io_error(hid); 968 hid_io_error(hid);
969} 969}
970 970
971/* Workqueue routine to reset the device */ 971/* Workqueue routine to reset the device or clear a halt */
972static void hid_reset(struct work_struct *work) 972static void hid_reset(struct work_struct *work)
973{ 973{
974 struct hid_device *hid = 974 struct hid_device *hid =
975 container_of(work, struct hid_device, reset_work); 975 container_of(work, struct hid_device, reset_work);
976 int rc_lock, rc; 976 int rc_lock, rc = 0;
977 977
978 dev_dbg(&hid->intf->dev, "resetting device\n"); 978 if (test_bit(HID_CLEAR_HALT, &hid->iofl)) {
979 rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf); 979 dev_dbg(&hid->intf->dev, "clear halt\n");
980 if (rc_lock >= 0) { 980 rc = usb_clear_halt(hid->dev, hid->urbin->pipe);
981 rc = usb_reset_composite_device(hid->dev, hid->intf); 981 clear_bit(HID_CLEAR_HALT, &hid->iofl);
982 if (rc_lock) 982 hid_start_in(hid);
983 usb_unlock_device(hid->dev); 983 }
984
985 else if (test_bit(HID_RESET_PENDING, &hid->iofl)) {
986 dev_dbg(&hid->intf->dev, "resetting device\n");
987 rc = rc_lock = usb_lock_device_for_reset(hid->dev, hid->intf);
988 if (rc_lock >= 0) {
989 rc = usb_reset_composite_device(hid->dev, hid->intf);
990 if (rc_lock)
991 usb_unlock_device(hid->dev);
992 }
993 clear_bit(HID_RESET_PENDING, &hid->iofl);
984 } 994 }
985 clear_bit(HID_RESET_PENDING, &hid->iofl);
986 995
987 switch (rc) { 996 switch (rc) {
988 case 0: 997 case 0:
@@ -1024,9 +1033,8 @@ static void hid_io_error(struct hid_device *hid)
1024 1033
1025 /* Retries failed, so do a port reset */ 1034 /* Retries failed, so do a port reset */
1026 if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) { 1035 if (!test_and_set_bit(HID_RESET_PENDING, &hid->iofl)) {
1027 if (schedule_work(&hid->reset_work)) 1036 schedule_work(&hid->reset_work);
1028 goto done; 1037 goto done;
1029 clear_bit(HID_RESET_PENDING, &hid->iofl);
1030 } 1038 }
1031 } 1039 }
1032 1040
@@ -1050,6 +1058,11 @@ static void hid_irq_in(struct urb *urb)
1050 hid->retry_delay = 0; 1058 hid->retry_delay = 0;
1051 hid_input_report(HID_INPUT_REPORT, urb, 1); 1059 hid_input_report(HID_INPUT_REPORT, urb, 1);
1052 break; 1060 break;
1061 case -EPIPE: /* stall */
1062 clear_bit(HID_IN_RUNNING, &hid->iofl);
1063 set_bit(HID_CLEAR_HALT, &hid->iofl);
1064 schedule_work(&hid->reset_work);
1065 return;
1053 case -ECONNRESET: /* unlink */ 1066 case -ECONNRESET: /* unlink */
1054 case -ENOENT: 1067 case -ENOENT:
1055 case -ESHUTDOWN: /* unplug */ 1068 case -ESHUTDOWN: /* unplug */
@@ -1628,6 +1641,19 @@ void hid_init_reports(struct hid_device *hid)
1628 1641
1629#define USB_VENDOR_ID_APPLE 0x05ac 1642#define USB_VENDOR_ID_APPLE 0x05ac
1630#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 1643#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304
1644#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e
1645#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f
1646#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
1647#define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
1648#define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
1649#define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
1650#define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
1651#define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219
1652#define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a
1653#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b
1654#define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c
1655#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
1656#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
1631 1657
1632#define USB_VENDOR_ID_CHERRY 0x046a 1658#define USB_VENDOR_ID_CHERRY 0x046a
1633#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 1659#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
@@ -1795,17 +1821,19 @@ static const struct hid_blacklist {
1795 1821
1796 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION }, 1822 { USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION, HID_QUIRK_CYMOTION },
1797 1823
1798 { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN }, 1824 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1799 { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN }, 1825 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO, HID_QUIRK_POWERBOOK_HAS_FN },
1800 { USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN }, 1826 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1801 { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, 1827 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1802 { USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN }, 1828 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1803 { USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN }, 1829 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1804 { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD}, 1830 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
1805 { USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN }, 1831 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1806 { USB_VENDOR_ID_APPLE, 0x021B, HID_QUIRK_POWERBOOK_HAS_FN }, 1832 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI, HID_QUIRK_POWERBOOK_HAS_FN },
1807 { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN }, 1833 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO, HID_QUIRK_POWERBOOK_HAS_FN },
1808 { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN }, 1834 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_POWERBOOK_HAS_FN },
1835 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN },
1836 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_POWERBOOK_HAS_FN },
1809 1837
1810 { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE }, 1838 { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE },
1811 { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE }, 1839 { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE },
@@ -1986,7 +2014,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
1986 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0) 2014 if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0)
1987 interval = hid_mousepoll_interval; 2015 interval = hid_mousepoll_interval;
1988 2016
1989 if (endpoint->bEndpointAddress & USB_DIR_IN) { 2017 if (usb_endpoint_dir_in(endpoint)) {
1990 if (hid->urbin) 2018 if (hid->urbin)
1991 continue; 2019 continue;
1992 if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) 2020 if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL)))
@@ -2068,13 +2096,9 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
2068 return hid; 2096 return hid;
2069 2097
2070fail: 2098fail:
2071 2099 usb_free_urb(hid->urbin);
2072 if (hid->urbin) 2100 usb_free_urb(hid->urbout);
2073 usb_free_urb(hid->urbin); 2101 usb_free_urb(hid->urbctrl);
2074 if (hid->urbout)
2075 usb_free_urb(hid->urbout);
2076 if (hid->urbctrl)
2077 usb_free_urb(hid->urbctrl);
2078 hid_free_buffers(dev, hid); 2102 hid_free_buffers(dev, hid);
2079 hid_free_device(hid); 2103 hid_free_device(hid);
2080 2104
@@ -2105,8 +2129,7 @@ static void hid_disconnect(struct usb_interface *intf)
2105 2129
2106 usb_free_urb(hid->urbin); 2130 usb_free_urb(hid->urbin);
2107 usb_free_urb(hid->urbctrl); 2131 usb_free_urb(hid->urbctrl);
2108 if (hid->urbout) 2132 usb_free_urb(hid->urbout);
2109 usb_free_urb(hid->urbout);
2110 2133
2111 hid_free_buffers(hid->dev, hid); 2134 hid_free_buffers(hid->dev, hid);
2112 hid_free_device(hid); 2135 hid_free_device(hid);
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index 0e76e6dcac37..2a9bf07944c0 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -385,6 +385,7 @@ struct hid_control_fifo {
385#define HID_IN_RUNNING 3 385#define HID_IN_RUNNING 3
386#define HID_RESET_PENDING 4 386#define HID_RESET_PENDING 4
387#define HID_SUSPENDED 5 387#define HID_SUSPENDED 5
388#define HID_CLEAR_HALT 6
388 389
389struct hid_input { 390struct hid_input {
390 struct list_head list; 391 struct list_head list;
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index c73285cf8558..dac88640eab6 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -208,10 +208,8 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
208 208
209static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd) 209static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
210{ 210{
211 if (kbd->irq) 211 usb_free_urb(kbd->irq);
212 usb_free_urb(kbd->irq); 212 usb_free_urb(kbd->led);
213 if (kbd->led)
214 usb_free_urb(kbd->led);
215 if (kbd->new) 213 if (kbd->new)
216 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma); 214 usb_buffer_free(dev, 8, kbd->new, kbd->new_dma);
217 if (kbd->cr) 215 if (kbd->cr)
@@ -236,9 +234,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
236 return -ENODEV; 234 return -ENODEV;
237 235
238 endpoint = &interface->endpoint[0].desc; 236 endpoint = &interface->endpoint[0].desc;
239 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 237 if (!usb_endpoint_is_int_in(endpoint))
240 return -ENODEV;
241 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
242 return -ENODEV; 238 return -ENODEV;
243 239
244 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 240 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index cbbbea332ed7..68a55642c082 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -126,9 +126,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
126 return -ENODEV; 126 return -ENODEV;
127 127
128 endpoint = &interface->endpoint[0].desc; 128 endpoint = &interface->endpoint[0].desc;
129 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 129 if (!usb_endpoint_is_int_in(endpoint))
130 return -ENODEV;
131 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
132 return -ENODEV; 130 return -ENODEV;
133 131
134 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 132 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 933ceddf3dee..49704d4ed0e2 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -8,6 +8,7 @@
8 * - PanJit TouchSet 8 * - PanJit TouchSet
9 * - eTurboTouch 9 * - eTurboTouch
10 * - Gunze AHL61 10 * - Gunze AHL61
11 * - DMC TSC-10/25
11 * 12 *
12 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch> 13 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch>
13 * Copyright (C) by Todd E. Johnson (mtouchusb.c) 14 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
@@ -30,6 +31,8 @@
30 * - ITM parts are from itmtouch.c 31 * - ITM parts are from itmtouch.c
31 * - 3M parts are from mtouchusb.c 32 * - 3M parts are from mtouchusb.c
32 * - PanJit parts are from an unmerged driver by Lanslott Gish 33 * - PanJit parts are from an unmerged driver by Lanslott Gish
34 * - DMC TSC 10/25 are from Holger Schurig, with ideas from an unmerged
35 * driver from Marius Vollmer
33 * 36 *
34 *****************************************************************************/ 37 *****************************************************************************/
35 38
@@ -44,7 +47,7 @@
44#include <linux/usb/input.h> 47#include <linux/usb/input.h>
45 48
46 49
47#define DRIVER_VERSION "v0.4" 50#define DRIVER_VERSION "v0.5"
48#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>" 51#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
49#define DRIVER_DESC "USB Touchscreen Driver" 52#define DRIVER_DESC "USB Touchscreen Driver"
50 53
@@ -103,6 +106,7 @@ enum {
103 DEVTYPE_ITM, 106 DEVTYPE_ITM,
104 DEVTYPE_ETURBO, 107 DEVTYPE_ETURBO,
105 DEVTYPE_GUNZE, 108 DEVTYPE_GUNZE,
109 DEVTYPE_DMC_TSC10,
106}; 110};
107 111
108static struct usb_device_id usbtouch_devices[] = { 112static struct usb_device_id usbtouch_devices[] = {
@@ -139,6 +143,10 @@ static struct usb_device_id usbtouch_devices[] = {
139 {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE}, 143 {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE},
140#endif 144#endif
141 145
146#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
147 {USB_DEVICE(0x0afa, 0x03e8), .driver_info = DEVTYPE_DMC_TSC10},
148#endif
149
142 {} 150 {}
143}; 151};
144 152
@@ -313,6 +321,80 @@ static int gunze_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *
313#endif 321#endif
314 322
315/***************************************************************************** 323/*****************************************************************************
324 * DMC TSC-10/25 Part
325 *
326 * Documentation about the controller and it's protocol can be found at
327 * http://www.dmccoltd.com/files/controler/tsc10usb_pi_e.pdf
328 * http://www.dmccoltd.com/files/controler/tsc25_usb_e.pdf
329 */
330#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
331
332/* supported data rates. currently using 130 */
333#define TSC10_RATE_POINT 0x50
334#define TSC10_RATE_30 0x40
335#define TSC10_RATE_50 0x41
336#define TSC10_RATE_80 0x42
337#define TSC10_RATE_100 0x43
338#define TSC10_RATE_130 0x44
339#define TSC10_RATE_150 0x45
340
341/* commands */
342#define TSC10_CMD_RESET 0x55
343#define TSC10_CMD_RATE 0x05
344#define TSC10_CMD_DATA1 0x01
345
346static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
347{
348 struct usb_device *dev = usbtouch->udev;
349 int ret;
350 unsigned char buf[2];
351
352 /* reset */
353 buf[0] = buf[1] = 0xFF;
354 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
355 TSC10_CMD_RESET,
356 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
357 0, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
358 if (ret < 0)
359 return ret;
360 if (buf[0] != 0x06 || buf[1] != 0x00)
361 return -ENODEV;
362
363 /* set coordinate output rate */
364 buf[0] = buf[1] = 0xFF;
365 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
366 TSC10_CMD_RATE,
367 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
368 TSC10_RATE_150, 0, buf, 2, USB_CTRL_SET_TIMEOUT);
369 if (ret < 0)
370 return ret;
371 if (buf[0] != 0x06 || buf[1] != 0x00)
372 return -ENODEV;
373
374 /* start sending data */
375 ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
376 TSC10_CMD_DATA1,
377 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
378 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
379 if (ret < 0)
380 return ret;
381
382 return 0;
383}
384
385
386static int dmc_tsc10_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
387{
388 *x = ((pkt[2] & 0x03) << 8) | pkt[1];
389 *y = ((pkt[4] & 0x03) << 8) | pkt[3];
390 *touch = pkt[0] & 0x01;
391
392 return 1;
393}
394#endif
395
396
397/*****************************************************************************
316 * the different device descriptors 398 * the different device descriptors
317 */ 399 */
318static struct usbtouch_device_info usbtouch_dev_info[] = { 400static struct usbtouch_device_info usbtouch_dev_info[] = {
@@ -389,6 +471,18 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
389 .read_data = gunze_read_data, 471 .read_data = gunze_read_data,
390 }, 472 },
391#endif 473#endif
474
475#ifdef CONFIG_USB_TOUCHSCREEN_DMC_TSC10
476 [DEVTYPE_DMC_TSC10] = {
477 .min_xc = 0x0,
478 .max_xc = 0x03ff,
479 .min_yc = 0x0,
480 .max_yc = 0x03ff,
481 .rept_size = 5,
482 .init = dmc_tsc10_init,
483 .read_data = dmc_tsc10_read_data,
484 },
485#endif
392}; 486};
393 487
394 488
diff --git a/drivers/usb/input/wacom.h b/drivers/usb/input/wacom.h
index 1cf08f02c50e..d85abfc5ab58 100644
--- a/drivers/usb/input/wacom.h
+++ b/drivers/usb/input/wacom.h
@@ -110,7 +110,6 @@ struct wacom_combo {
110}; 110};
111 111
112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo); 112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
113extern void wacom_sys_irq(struct urb *urb);
114extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data); 113extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data);
115extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data); 114extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data);
116extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data); 115extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data);
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
index 3498b893b53b..e7cc20ab8155 100644
--- a/drivers/usb/input/wacom_sys.c
+++ b/drivers/usb/input/wacom_sys.c
@@ -42,7 +42,7 @@ static struct input_dev * get_input_dev(struct wacom_combo *wcombo)
42 return wcombo->wacom->dev; 42 return wcombo->wacom->dev;
43} 43}
44 44
45void wacom_sys_irq(struct urb *urb) 45static void wacom_sys_irq(struct urb *urb)
46{ 46{
47 struct wacom *wacom = urb->context; 47 struct wacom *wacom = urb->context;
48 struct wacom_combo wcombo; 48 struct wacom_combo wcombo;
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 905bf6398257..2268ca311ade 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -859,10 +859,8 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
859 859
860 interface = intf->cur_altsetting; 860 interface = intf->cur_altsetting;
861 endpoint = &interface->endpoint[0].desc; 861 endpoint = &interface->endpoint[0].desc;
862 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 862 if (!usb_endpoint_is_int_in(endpoint))
863 return -EIO; 863 return -ENODEV;
864 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT)
865 return -EIO;
866 864
867 yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL); 865 yld = kzalloc(sizeof(struct yealink_dev), GFP_KERNEL);
868 if (!yld) 866 if (!yld)
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 11dc59540cda..2cba07d31971 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -4,6 +4,7 @@
4# 4#
5 5
6obj-$(CONFIG_USB_ADUTUX) += adutux.o 6obj-$(CONFIG_USB_ADUTUX) += adutux.o
7obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o
7obj-$(CONFIG_USB_AUERSWALD) += auerswald.o 8obj-$(CONFIG_USB_AUERSWALD) += auerswald.o
8obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o 9obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
9obj-$(CONFIG_USB_CYTHERM) += cytherm.o 10obj-$(CONFIG_USB_CYTHERM) += cytherm.o
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index 6b23a1def9fe..ba30ca6a14aa 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -216,10 +216,7 @@ static int appledisplay_probe(struct usb_interface *iface,
216 iface_desc = iface->cur_altsetting; 216 iface_desc = iface->cur_altsetting;
217 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 217 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
218 endpoint = &iface_desc->endpoint[i].desc; 218 endpoint = &iface_desc->endpoint[i].desc;
219 if (!int_in_endpointAddr && 219 if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) {
220 (endpoint->bEndpointAddress & USB_DIR_IN) &&
221 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
222 USB_ENDPOINT_XFER_INT)) {
223 /* we found an interrupt in endpoint */ 220 /* we found an interrupt in endpoint */
224 int_in_endpointAddr = endpoint->bEndpointAddress; 221 int_in_endpointAddr = endpoint->bEndpointAddress;
225 break; 222 break;
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index e4971d6aaafb..c703f73e1655 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -704,9 +704,7 @@ static void auerbuf_free (pauerbuf_t bp)
704{ 704{
705 kfree(bp->bufp); 705 kfree(bp->bufp);
706 kfree(bp->dr); 706 kfree(bp->dr);
707 if (bp->urbp) { 707 usb_free_urb(bp->urbp);
708 usb_free_urb(bp->urbp);
709 }
710 kfree(bp); 708 kfree(bp);
711} 709}
712 710
@@ -1155,8 +1153,7 @@ static void auerswald_int_release (pauerswald_t cp)
1155 dbg ("auerswald_int_release"); 1153 dbg ("auerswald_int_release");
1156 1154
1157 /* stop the int endpoint */ 1155 /* stop the int endpoint */
1158 if (cp->inturbp) 1156 usb_kill_urb (cp->inturbp);
1159 usb_kill_urb (cp->inturbp);
1160 1157
1161 /* deallocate memory */ 1158 /* deallocate memory */
1162 auerswald_int_free (cp); 1159 auerswald_int_free (cp);
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index 1fd9cb85f4ca..5c0a26cbd128 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -53,13 +53,12 @@ static void __exit emi26_exit (void);
53static int emi26_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request) 53static int emi26_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request)
54{ 54{
55 int result; 55 int result;
56 unsigned char *buffer = kmalloc (length, GFP_KERNEL); 56 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL);
57 57
58 if (!buffer) { 58 if (!buffer) {
59 err("emi26: kmalloc(%d) failed.", length); 59 err("emi26: kmalloc(%d) failed.", length);
60 return -ENOMEM; 60 return -ENOMEM;
61 } 61 }
62 memcpy (buffer, data, length);
63 /* Note: usb_control_msg returns negative value on error or length of the 62 /* Note: usb_control_msg returns negative value on error or length of the
64 * data that was written! */ 63 * data that was written! */
65 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300); 64 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300);
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index fe351371f274..23153eac0dfa 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -61,13 +61,12 @@ static void __exit emi62_exit (void);
61static int emi62_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request) 61static int emi62_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request)
62{ 62{
63 int result; 63 int result;
64 unsigned char *buffer = kmalloc (length, GFP_KERNEL); 64 unsigned char *buffer = kmemdup(data, length, GFP_KERNEL);
65 65
66 if (!buffer) { 66 if (!buffer) {
67 err("emi62: kmalloc(%d) failed.", length); 67 err("emi62: kmalloc(%d) failed.", length);
68 return -ENOMEM; 68 return -ENOMEM;
69 } 69 }
70 memcpy (buffer, data, length);
71 /* Note: usb_control_msg returns negative value on error or length of the 70 /* Note: usb_control_msg returns negative value on error or length of the
72 * data that was written! */ 71 * data that was written! */
73 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300); 72 result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300);
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index e4e2cf2ba915..18b1925032a8 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -272,7 +272,7 @@ void ftdi_elan_gone_away(struct platform_device *pdev)
272 272
273 273
274EXPORT_SYMBOL_GPL(ftdi_elan_gone_away); 274EXPORT_SYMBOL_GPL(ftdi_elan_gone_away);
275void ftdi_release_platform_dev(struct device *dev) 275static void ftdi_release_platform_dev(struct device *dev)
276{ 276{
277 dev->parent = NULL; 277 dev->parent = NULL;
278} 278}
@@ -1399,14 +1399,6 @@ static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data)
1399 } 1399 }
1400} 1400}
1401 1401
1402int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data)
1403{
1404 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1405 return ftdi_elan_read_reg(ftdi, data);
1406}
1407
1408
1409EXPORT_SYMBOL_GPL(usb_ftdi_elan_read_reg);
1410static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset, 1402static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset,
1411 u8 width, u32 *data) 1403 u8 width, u32 *data)
1412{ 1404{
@@ -2606,10 +2598,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2606 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 2598 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
2607 endpoint = &iface_desc->endpoint[i].desc; 2599 endpoint = &iface_desc->endpoint[i].desc;
2608 if (!ftdi->bulk_in_endpointAddr && 2600 if (!ftdi->bulk_in_endpointAddr &&
2609 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 2601 usb_endpoint_is_bulk_in(endpoint)) {
2610 == USB_DIR_IN) && ((endpoint->bmAttributes &
2611 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
2612 {
2613 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 2602 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
2614 ftdi->bulk_in_size = buffer_size; 2603 ftdi->bulk_in_size = buffer_size;
2615 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress; 2604 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress;
@@ -2622,10 +2611,7 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2622 } 2611 }
2623 } 2612 }
2624 if (!ftdi->bulk_out_endpointAddr && 2613 if (!ftdi->bulk_out_endpointAddr &&
2625 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 2614 usb_endpoint_is_bulk_out(endpoint)) {
2626 == USB_DIR_OUT) && ((endpoint->bmAttributes &
2627 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
2628 {
2629 ftdi->bulk_out_endpointAddr = 2615 ftdi->bulk_out_endpointAddr =
2630 endpoint->bEndpointAddress; 2616 endpoint->bEndpointAddress;
2631 } 2617 }
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index 8e6e195a22ba..c9418535bef8 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -125,12 +125,12 @@ static DEFINE_MUTEX(disconnect_mutex);
125 125
126static int idmouse_create_image(struct usb_idmouse *dev) 126static int idmouse_create_image(struct usb_idmouse *dev)
127{ 127{
128 int bytes_read = 0; 128 int bytes_read;
129 int bulk_read = 0; 129 int bulk_read;
130 int result = 0; 130 int result;
131 131
132 memcpy(dev->bulk_in_buffer, HEADER, sizeof(HEADER)-1); 132 memcpy(dev->bulk_in_buffer, HEADER, sizeof(HEADER)-1);
133 bytes_read += sizeof(HEADER)-1; 133 bytes_read = sizeof(HEADER)-1;
134 134
135 /* reset the device and set a fast blink rate */ 135 /* reset the device and set a fast blink rate */
136 result = ftip_command(dev, FTIP_RELEASE, 0, 0); 136 result = ftip_command(dev, FTIP_RELEASE, 0, 0);
@@ -208,9 +208,9 @@ static inline void idmouse_delete(struct usb_idmouse *dev)
208 208
209static int idmouse_open(struct inode *inode, struct file *file) 209static int idmouse_open(struct inode *inode, struct file *file)
210{ 210{
211 struct usb_idmouse *dev = NULL; 211 struct usb_idmouse *dev;
212 struct usb_interface *interface; 212 struct usb_interface *interface;
213 int result = 0; 213 int result;
214 214
215 /* prevent disconnects */ 215 /* prevent disconnects */
216 mutex_lock(&disconnect_mutex); 216 mutex_lock(&disconnect_mutex);
@@ -305,7 +305,7 @@ static ssize_t idmouse_read(struct file *file, char __user *buffer, size_t count
305 loff_t * ppos) 305 loff_t * ppos)
306{ 306{
307 struct usb_idmouse *dev; 307 struct usb_idmouse *dev;
308 int result = 0; 308 int result;
309 309
310 dev = (struct usb_idmouse *) file->private_data; 310 dev = (struct usb_idmouse *) file->private_data;
311 311
@@ -329,7 +329,7 @@ static int idmouse_probe(struct usb_interface *interface,
329 const struct usb_device_id *id) 329 const struct usb_device_id *id)
330{ 330{
331 struct usb_device *udev = interface_to_usbdev(interface); 331 struct usb_device *udev = interface_to_usbdev(interface);
332 struct usb_idmouse *dev = NULL; 332 struct usb_idmouse *dev;
333 struct usb_host_interface *iface_desc; 333 struct usb_host_interface *iface_desc;
334 struct usb_endpoint_descriptor *endpoint; 334 struct usb_endpoint_descriptor *endpoint;
335 int result; 335 int result;
@@ -350,11 +350,7 @@ static int idmouse_probe(struct usb_interface *interface,
350 350
351 /* set up the endpoint information - use only the first bulk-in endpoint */ 351 /* set up the endpoint information - use only the first bulk-in endpoint */
352 endpoint = &iface_desc->endpoint[0].desc; 352 endpoint = &iface_desc->endpoint[0].desc;
353 if (!dev->bulk_in_endpointAddr 353 if (!dev->bulk_in_endpointAddr && usb_endpoint_is_bulk_in(endpoint)) {
354 && (endpoint->bEndpointAddress & USB_DIR_IN)
355 && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
356 USB_ENDPOINT_XFER_BULK)) {
357
358 /* we found a bulk in endpoint */ 354 /* we found a bulk in endpoint */
359 dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize); 355 dev->orig_bi_size = le16_to_cpu(endpoint->wMaxPacketSize);
360 dev->bulk_in_size = 0x200; /* works _much_ faster */ 356 dev->bulk_in_size = 0x200; /* works _much_ faster */
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 27089497e717..5dce797bddb7 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -317,12 +317,8 @@ static inline void tower_delete (struct lego_usb_tower *dev)
317 tower_abort_transfers (dev); 317 tower_abort_transfers (dev);
318 318
319 /* free data structures */ 319 /* free data structures */
320 if (dev->interrupt_in_urb != NULL) { 320 usb_free_urb(dev->interrupt_in_urb);
321 usb_free_urb (dev->interrupt_in_urb); 321 usb_free_urb(dev->interrupt_out_urb);
322 }
323 if (dev->interrupt_out_urb != NULL) {
324 usb_free_urb (dev->interrupt_out_urb);
325 }
326 kfree (dev->read_buffer); 322 kfree (dev->read_buffer);
327 kfree (dev->interrupt_in_buffer); 323 kfree (dev->interrupt_in_buffer);
328 kfree (dev->interrupt_out_buffer); 324 kfree (dev->interrupt_out_buffer);
@@ -502,15 +498,11 @@ static void tower_abort_transfers (struct lego_usb_tower *dev)
502 if (dev->interrupt_in_running) { 498 if (dev->interrupt_in_running) {
503 dev->interrupt_in_running = 0; 499 dev->interrupt_in_running = 0;
504 mb(); 500 mb();
505 if (dev->interrupt_in_urb != NULL && dev->udev) { 501 if (dev->udev)
506 usb_kill_urb (dev->interrupt_in_urb); 502 usb_kill_urb (dev->interrupt_in_urb);
507 }
508 }
509 if (dev->interrupt_out_busy) {
510 if (dev->interrupt_out_urb != NULL && dev->udev) {
511 usb_kill_urb (dev->interrupt_out_urb);
512 }
513 } 503 }
504 if (dev->interrupt_out_busy && dev->udev)
505 usb_kill_urb(dev->interrupt_out_urb);
514 506
515exit: 507exit:
516 dbg(2, "%s: leave", __FUNCTION__); 508 dbg(2, "%s: leave", __FUNCTION__);
@@ -898,14 +890,11 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
898 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 890 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
899 endpoint = &iface_desc->endpoint[i].desc; 891 endpoint = &iface_desc->endpoint[i].desc;
900 892
901 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) && 893 if (usb_endpoint_xfer_int(endpoint)) {
902 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) { 894 if (usb_endpoint_dir_in(endpoint))
903 dev->interrupt_in_endpoint = endpoint; 895 dev->interrupt_in_endpoint = endpoint;
904 } 896 else
905 897 dev->interrupt_out_endpoint = endpoint;
906 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) &&
907 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
908 dev->interrupt_out_endpoint = endpoint;
909 } 898 }
910 } 899 }
911 if(dev->interrupt_in_endpoint == NULL) { 900 if(dev->interrupt_in_endpoint == NULL) {
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 33e716c6a79b..9659c79e187e 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -554,7 +554,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
554 return -ENODEV; 554 return -ENODEV;
555 555
556 endpoint = &interface->endpoint[0].desc; 556 endpoint = &interface->endpoint[0].desc;
557 if (!(endpoint->bEndpointAddress & 0x80)) 557 if (!usb_endpoint_dir_in(endpoint))
558 return -ENODEV; 558 return -ENODEV;
559 /* 559 /*
560 * bmAttributes 560 * bmAttributes
@@ -653,8 +653,7 @@ out2:
653 device_remove_file(kit->dev, &dev_output_attrs[i]); 653 device_remove_file(kit->dev, &dev_output_attrs[i]);
654out: 654out:
655 if (kit) { 655 if (kit) {
656 if (kit->irq) 656 usb_free_urb(kit->irq);
657 usb_free_urb(kit->irq);
658 if (kit->data) 657 if (kit->data)
659 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma); 658 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma);
660 if (kit->dev) 659 if (kit->dev)
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index 0385ffcc7419..2bb4fa572bb7 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -324,7 +324,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
324 return -ENODEV; 324 return -ENODEV;
325 325
326 endpoint = &interface->endpoint[0].desc; 326 endpoint = &interface->endpoint[0].desc;
327 if (!(endpoint->bEndpointAddress & 0x80)) 327 if (!usb_endpoint_dir_in(endpoint))
328 return -ENODEV; 328 return -ENODEV;
329 329
330 /* 330 /*
@@ -393,8 +393,7 @@ out2:
393 device_remove_file(mc->dev, &dev_attrs[i]); 393 device_remove_file(mc->dev, &dev_attrs[i]);
394out: 394out:
395 if (mc) { 395 if (mc) {
396 if (mc->irq) 396 usb_free_urb(mc->irq);
397 usb_free_urb(mc->irq);
398 if (mc->data) 397 if (mc->data)
399 usb_buffer_free(dev, URB_INT_SIZE, mc->data, mc->data_dma); 398 usb_buffer_free(dev, URB_INT_SIZE, mc->data, mc->data_dma);
400 if (mc->dev) 399 if (mc->dev)
diff --git a/drivers/usb/misc/usb_u132.h b/drivers/usb/misc/usb_u132.h
index 551ba8906d62..dc2e5a31caec 100644
--- a/drivers/usb/misc/usb_u132.h
+++ b/drivers/usb/misc/usb_u132.h
@@ -52,7 +52,7 @@
52* the kernel to load the "u132-hcd" module. 52* the kernel to load the "u132-hcd" module.
53* 53*
54* The "ftdi-u132" module provides the interface to the inserted 54* The "ftdi-u132" module provides the interface to the inserted
55* PC card and the "u132-hcd" module uses the API to send and recieve 55* PC card and the "u132-hcd" module uses the API to send and receive
56* data. The API features call-backs, so that part of the "u132-hcd" 56* data. The API features call-backs, so that part of the "u132-hcd"
57* module code will run in the context of one of the kernel threads 57* module code will run in the context of one of the kernel threads
58* of the "ftdi-u132" module. 58* of the "ftdi-u132" module.
@@ -95,3 +95,7 @@ int usb_ftdi_elan_edset_setup(struct platform_device *pdev, u8 ed_number,
95 int halted, int skipped, int actual, int non_null)); 95 int halted, int skipped, int actual, int non_null));
96int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number, 96int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number,
97 void *endp); 97 void *endp);
98int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, int mem_offset,
99 u8 width, u32 *data);
100int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, int mem_offset,
101 u8 width, u32 data);
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 7c2cbdf81d20..194065dbb51f 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -138,7 +138,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
138 default: 138 default:
139 continue; 139 continue;
140 } 140 }
141 if (e->desc.bEndpointAddress & USB_DIR_IN) { 141 if (usb_endpoint_dir_in(&e->desc)) {
142 if (!in) 142 if (!in)
143 in = e; 143 in = e;
144 } else { 144 } else {
@@ -147,7 +147,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
147 } 147 }
148 continue; 148 continue;
149try_iso: 149try_iso:
150 if (e->desc.bEndpointAddress & USB_DIR_IN) { 150 if (usb_endpoint_dir_in(&e->desc)) {
151 if (!iso_in) 151 if (!iso_in)
152 iso_in = e; 152 iso_in = e;
153 } else { 153 } else {
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 881841e600de..95e682e2c9d6 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -249,9 +249,9 @@ asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
249 249
250 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; 250 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
251 req->bRequest = cmd; 251 req->bRequest = cmd;
252 req->wValue = value; 252 req->wValue = cpu_to_le16(value);
253 req->wIndex = index; 253 req->wIndex = cpu_to_le16(index);
254 req->wLength = size; 254 req->wLength = cpu_to_le16(size);
255 255
256 usb_fill_control_urb(urb, dev->udev, 256 usb_fill_control_urb(urb, dev->udev,
257 usb_sndctrlpipe(dev->udev, 0), 257 usb_sndctrlpipe(dev->udev, 0),
diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
index f740325abac4..907b820a5faf 100644
--- a/drivers/usb/net/catc.c
+++ b/drivers/usb/net/catc.c
@@ -786,14 +786,10 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
786 if ((!catc->ctrl_urb) || (!catc->tx_urb) || 786 if ((!catc->ctrl_urb) || (!catc->tx_urb) ||
787 (!catc->rx_urb) || (!catc->irq_urb)) { 787 (!catc->rx_urb) || (!catc->irq_urb)) {
788 err("No free urbs available."); 788 err("No free urbs available.");
789 if (catc->ctrl_urb) 789 usb_free_urb(catc->ctrl_urb);
790 usb_free_urb(catc->ctrl_urb); 790 usb_free_urb(catc->tx_urb);
791 if (catc->tx_urb) 791 usb_free_urb(catc->rx_urb);
792 usb_free_urb(catc->tx_urb); 792 usb_free_urb(catc->irq_urb);
793 if (catc->rx_urb)
794 usb_free_urb(catc->rx_urb);
795 if (catc->irq_urb)
796 usb_free_urb(catc->irq_urb);
797 free_netdev(netdev); 793 free_netdev(netdev);
798 return -ENOMEM; 794 return -ENOMEM;
799 } 795 }
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c
index f6971b88349d..44a91547146e 100644
--- a/drivers/usb/net/cdc_ether.c
+++ b/drivers/usb/net/cdc_ether.c
@@ -200,8 +200,7 @@ next_desc:
200 200
201 dev->status = &info->control->cur_altsetting->endpoint [0]; 201 dev->status = &info->control->cur_altsetting->endpoint [0];
202 desc = &dev->status->desc; 202 desc = &dev->status->desc;
203 if (desc->bmAttributes != USB_ENDPOINT_XFER_INT 203 if (!usb_endpoint_is_int_in(desc)
204 || !(desc->bEndpointAddress & USB_DIR_IN)
205 || (le16_to_cpu(desc->wMaxPacketSize) 204 || (le16_to_cpu(desc->wMaxPacketSize)
206 < sizeof(struct usb_cdc_notification)) 205 < sizeof(struct usb_cdc_notification))
207 || !desc->bInterval) { 206 || !desc->bInterval) {
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index ce00de8f13a1..a77410562e12 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -237,12 +237,12 @@ static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl)
237#define STATUS_CONN_OTHER (1 << 14) 237#define STATUS_CONN_OTHER (1 << 14)
238#define STATUS_SUSPEND_OTHER (1 << 13) 238#define STATUS_SUSPEND_OTHER (1 << 13)
239#define STATUS_MAILBOX_OTHER (1 << 12) 239#define STATUS_MAILBOX_OTHER (1 << 12)
240#define STATUS_PACKETS_OTHER(n) (((n) >> 8) && 0x03) 240#define STATUS_PACKETS_OTHER(n) (((n) >> 8) & 0x03)
241 241
242#define STATUS_CONN_THIS (1 << 6) 242#define STATUS_CONN_THIS (1 << 6)
243#define STATUS_SUSPEND_THIS (1 << 5) 243#define STATUS_SUSPEND_THIS (1 << 5)
244#define STATUS_MAILBOX_THIS (1 << 4) 244#define STATUS_MAILBOX_THIS (1 << 4)
245#define STATUS_PACKETS_THIS(n) (((n) >> 0) && 0x03) 245#define STATUS_PACKETS_THIS(n) (((n) >> 0) & 0x03)
246 246
247#define STATUS_UNSPEC_MASK 0x0c8c 247#define STATUS_UNSPEC_MASK 0x0c8c
248#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) 248#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK))
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 78cf6f091285..b5690b3834e3 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -163,6 +163,7 @@ static int get_registers(pegasus_t * pegasus, __u16 indx, __u16 size,
163 163
164 /* using ATOMIC, we'd never wake up if we slept */ 164 /* using ATOMIC, we'd never wake up if we slept */
165 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) { 165 if ((ret = usb_submit_urb(pegasus->ctrl_urb, GFP_ATOMIC))) {
166 set_current_state(TASK_RUNNING);
166 if (ret == -ENODEV) 167 if (ret == -ENODEV)
167 netif_device_detach(pegasus->net); 168 netif_device_detach(pegasus->net);
168 if (netif_msg_drv(pegasus)) 169 if (netif_msg_drv(pegasus))
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 79b5474fe234..327f97555679 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -116,7 +116,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
116 e = alt->endpoint + ep; 116 e = alt->endpoint + ep;
117 switch (e->desc.bmAttributes) { 117 switch (e->desc.bmAttributes) {
118 case USB_ENDPOINT_XFER_INT: 118 case USB_ENDPOINT_XFER_INT:
119 if (!(e->desc.bEndpointAddress & USB_DIR_IN)) 119 if (!usb_endpoint_dir_in(&e->desc))
120 continue; 120 continue;
121 intr = 1; 121 intr = 1;
122 /* FALLTHROUGH */ 122 /* FALLTHROUGH */
@@ -125,7 +125,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
125 default: 125 default:
126 continue; 126 continue;
127 } 127 }
128 if (e->desc.bEndpointAddress & USB_DIR_IN) { 128 if (usb_endpoint_dir_in(&e->desc)) {
129 if (!intr && !in) 129 if (!intr && !in)
130 in = e; 130 in = e;
131 else if (intr && !status) 131 else if (intr && !status)
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 2a8dd4cc943d..2f4d303ee36f 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -554,6 +554,17 @@ config USB_SERIAL_OMNINET
554 To compile this driver as a module, choose M here: the 554 To compile this driver as a module, choose M here: the
555 module will be called omninet. 555 module will be called omninet.
556 556
557config USB_SERIAL_DEBUG
558 tristate "USB Debugging Device"
559 depends on USB_SERIAL
560 help
561 Say Y here if you have a USB debugging device used to recieve
562 debugging data from another machine. The most common of these
563 devices is the NetChip TurboCONNECT device.
564
565 To compile this driver as a module, choose M here: the
566 module will be called usb-debug.
567
557config USB_EZUSB 568config USB_EZUSB
558 bool 569 bool
559 depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT 570 depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index a5047dc599bb..61166ad450e6 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
18obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 18obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o
19obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o 19obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
20obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o 20obj-$(CONFIG_USB_SERIAL_CYPRESS_M8) += cypress_m8.o
21obj-$(CONFIG_USB_SERIAL_DEBUG) += usb_debug.o
21obj-$(CONFIG_USB_SERIAL_DIGI_ACCELEPORT) += digi_acceleport.o 22obj-$(CONFIG_USB_SERIAL_DIGI_ACCELEPORT) += digi_acceleport.o
22obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o 23obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o
23obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o 24obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 2a4ac9bd6a3a..86bcf63b6ba5 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -272,8 +272,11 @@ static void aircable_read(struct work_struct *work)
272 */ 272 */
273 tty = port->tty; 273 tty = port->tty;
274 274
275 if (!tty) 275 if (!tty) {
276 schedule_work(&priv->rx_work); 276 schedule_work(&priv->rx_work);
277 err("%s - No tty available", __FUNCTION__);
278 return ;
279 }
277 280
278 count = min(64, serial_buf_data_avail(priv->rx_buf)); 281 count = min(64, serial_buf_data_avail(priv->rx_buf));
279 282
@@ -307,9 +310,7 @@ static int aircable_probe(struct usb_serial *serial,
307 310
308 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 311 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
309 endpoint = &iface_desc->endpoint[i].desc; 312 endpoint = &iface_desc->endpoint[i].desc;
310 if (((endpoint->bEndpointAddress & 0x80) == 0x00) && 313 if (usb_endpoint_is_bulk_out(endpoint)) {
311 ((endpoint->bmAttributes & 3) == 0x02)) {
312 /* we found our bulk out endpoint */
313 dbg("found bulk out on endpoint %d", i); 314 dbg("found bulk out on endpoint %d", i);
314 ++num_bulk_out; 315 ++num_bulk_out;
315 } 316 }
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 7f5d546da39a..96c73726d74a 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -19,6 +19,7 @@
19static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ 21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
22 { USB_DEVICE(0x1410, 0x1430) }, /* Novatel Merlin XU870 HSDPA/3G */
22 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */ 23 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */
23 { }, 24 { },
24}; 25};
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index ca52f12f0e24..863966c1c5ac 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -85,10 +85,9 @@ static int ark3116_attach(struct usb_serial *serial)
85 int i; 85 int i;
86 86
87 for (i = 0; i < serial->num_ports; ++i) { 87 for (i = 0; i < serial->num_ports; ++i) {
88 priv = kmalloc(sizeof (struct ark3116_private), GFP_KERNEL); 88 priv = kzalloc(sizeof(struct ark3116_private), GFP_KERNEL);
89 if (!priv) 89 if (!priv)
90 goto cleanup; 90 goto cleanup;
91 memset(priv, 0x00, sizeof (struct ark3116_private));
92 spin_lock_init(&priv->lock); 91 spin_lock_init(&priv->lock);
93 92
94 usb_set_serial_port_data(serial->port[i], priv); 93 usb_set_serial_port_data(serial->port[i], priv);
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 3a9073dbfe6a..7167728d764c 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -166,19 +166,17 @@ static int usb_console_setup(struct console *co, char *options)
166 if (serial->type->set_termios) { 166 if (serial->type->set_termios) {
167 /* build up a fake tty structure so that the open call has something 167 /* build up a fake tty structure so that the open call has something
168 * to look at to get the cflag value */ 168 * to look at to get the cflag value */
169 tty = kmalloc (sizeof (*tty), GFP_KERNEL); 169 tty = kzalloc(sizeof(*tty), GFP_KERNEL);
170 if (!tty) { 170 if (!tty) {
171 err ("no more memory"); 171 err ("no more memory");
172 return -ENOMEM; 172 return -ENOMEM;
173 } 173 }
174 termios = kmalloc (sizeof (*termios), GFP_KERNEL); 174 termios = kzalloc(sizeof(*termios), GFP_KERNEL);
175 if (!termios) { 175 if (!termios) {
176 err ("no more memory"); 176 err ("no more memory");
177 kfree (tty); 177 kfree (tty);
178 return -ENOMEM; 178 return -ENOMEM;
179 } 179 }
180 memset (tty, 0x00, sizeof(*tty));
181 memset (termios, 0x00, sizeof(*termios));
182 termios->c_cflag = cflag; 180 termios->c_cflag = cflag;
183 tty->termios = termios; 181 tty->termios = termios;
184 port->tty = tty; 182 port->tty = tty;
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index f2e89a083659..093f303b3189 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -1684,15 +1684,14 @@ static int __init cypress_init(void)
1684 1684
1685 info(DRIVER_DESC " " DRIVER_VERSION); 1685 info(DRIVER_DESC " " DRIVER_VERSION);
1686 return 0; 1686 return 0;
1687
1687failed_usb_register: 1688failed_usb_register:
1688 usb_deregister(&cypress_driver);
1689failed_ca42v2_register:
1690 usb_serial_deregister(&cypress_ca42v2_device); 1689 usb_serial_deregister(&cypress_ca42v2_device);
1691failed_hidcom_register: 1690failed_ca42v2_register:
1692 usb_serial_deregister(&cypress_hidcom_device); 1691 usb_serial_deregister(&cypress_hidcom_device);
1693failed_em_register: 1692failed_hidcom_register:
1694 usb_serial_deregister(&cypress_earthmate_device); 1693 usb_serial_deregister(&cypress_earthmate_device);
1695 1694failed_em_register:
1696 return retval; 1695 return retval;
1697} 1696}
1698 1697
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index fd159b040bfb..83d0e21145b0 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -157,7 +157,7 @@
157* to TASK_RUNNING will be lost and write_chan's subsequent call to 157* to TASK_RUNNING will be lost and write_chan's subsequent call to
158* schedule() will never return (unless it catches a signal). 158* schedule() will never return (unless it catches a signal).
159* This race condition occurs because write_bulk_callback() (and thus 159* This race condition occurs because write_bulk_callback() (and thus
160* the wakeup) are called asynchonously from an interrupt, rather than 160* the wakeup) are called asynchronously from an interrupt, rather than
161* from the scheduler. We can avoid the race by calling the wakeup 161* from the scheduler. We can avoid the race by calling the wakeup
162* from the scheduler queue and that's our fix: Now, at the end of 162* from the scheduler queue and that's our fix: Now, at the end of
163* write_bulk_callback() we queue up a wakeup call on the scheduler 163* write_bulk_callback() we queue up a wakeup call on the scheduler
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index 5169c2d154ab..97ee718b1da2 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -31,12 +31,11 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
31 return -ENODEV; 31 return -ENODEV;
32 } 32 }
33 33
34 transfer_buffer = kmalloc (length, GFP_KERNEL); 34 transfer_buffer = kmemdup(data, length, GFP_KERNEL);
35 if (!transfer_buffer) { 35 if (!transfer_buffer) {
36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length); 36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length);
37 return -ENOMEM; 37 return -ENOMEM;
38 } 38 }
39 memcpy (transfer_buffer, data, length);
40 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000); 39 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000);
41 kfree (transfer_buffer); 40 kfree (transfer_buffer);
42 return result; 41 return result;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 88ed5c1d236c..72e4d48f51e9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1390,8 +1390,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1390 flush_scheduled_work(); 1390 flush_scheduled_work();
1391 1391
1392 /* shutdown our bulk read */ 1392 /* shutdown our bulk read */
1393 if (port->read_urb) 1393 usb_kill_urb(port->read_urb);
1394 usb_kill_urb(port->read_urb);
1395} /* ftdi_close */ 1394} /* ftdi_close */
1396 1395
1397 1396
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 4543152a9966..6530d391ebed 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1523,12 +1523,11 @@ static int garmin_attach (struct usb_serial *serial)
1523 1523
1524 dbg("%s", __FUNCTION__); 1524 dbg("%s", __FUNCTION__);
1525 1525
1526 garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL); 1526 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
1527 if (garmin_data_p == NULL) { 1527 if (garmin_data_p == NULL) {
1528 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__); 1528 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
1529 return -ENOMEM; 1529 return -ENOMEM;
1530 } 1530 }
1531 memset (garmin_data_p, 0, sizeof(struct garmin_data));
1532 init_timer(&garmin_data_p->timer); 1531 init_timer(&garmin_data_p->timer);
1533 spin_lock_init(&garmin_data_p->lock); 1532 spin_lock_init(&garmin_data_p->lock);
1534 INIT_LIST_HEAD(&garmin_data_p->pktlist); 1533 INIT_LIST_HEAD(&garmin_data_p->pktlist);
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 91bd3014ef1e..d06547a13f28 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -1038,9 +1038,7 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
1038 edge_port->open = FALSE; 1038 edge_port->open = FALSE;
1039 edge_port->openPending = FALSE; 1039 edge_port->openPending = FALSE;
1040 1040
1041 if (edge_port->write_urb) { 1041 usb_kill_urb(edge_port->write_urb);
1042 usb_kill_urb(edge_port->write_urb);
1043 }
1044 1042
1045 if (edge_port->write_urb) { 1043 if (edge_port->write_urb) {
1046 /* if this urb had a transfer buffer already (old transfer) free it */ 1044 /* if this urb had a transfer buffer already (old transfer) free it */
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 2a4bb66691ad..d3b9a351cef8 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -206,10 +206,9 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
206 206
207 dbg("%s", __FUNCTION__); 207 dbg("%s", __FUNCTION__);
208 208
209 buf_flow_init = kmalloc(16, GFP_KERNEL); 209 buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL);
210 if (!buf_flow_init) 210 if (!buf_flow_init)
211 return -ENOMEM; 211 return -ENOMEM;
212 memcpy(buf_flow_init, buf_flow_static, 16);
213 212
214 if (port->tty) 213 if (port->tty)
215 port->tty->low_latency = 1; 214 port->tty->low_latency = 1;
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 53be824eb1bf..7639652cec42 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -2306,22 +2306,16 @@ static void keyspan_shutdown (struct usb_serial *serial)
2306 } 2306 }
2307 2307
2308 /* Now free them */ 2308 /* Now free them */
2309 if (s_priv->instat_urb) 2309 usb_free_urb(s_priv->instat_urb);
2310 usb_free_urb(s_priv->instat_urb); 2310 usb_free_urb(s_priv->glocont_urb);
2311 if (s_priv->glocont_urb)
2312 usb_free_urb(s_priv->glocont_urb);
2313 for (i = 0; i < serial->num_ports; ++i) { 2311 for (i = 0; i < serial->num_ports; ++i) {
2314 port = serial->port[i]; 2312 port = serial->port[i];
2315 p_priv = usb_get_serial_port_data(port); 2313 p_priv = usb_get_serial_port_data(port);
2316 if (p_priv->inack_urb) 2314 usb_free_urb(p_priv->inack_urb);
2317 usb_free_urb(p_priv->inack_urb); 2315 usb_free_urb(p_priv->outcont_urb);
2318 if (p_priv->outcont_urb)
2319 usb_free_urb(p_priv->outcont_urb);
2320 for (j = 0; j < 2; j++) { 2316 for (j = 0; j < 2; j++) {
2321 if (p_priv->in_urbs[j]) 2317 usb_free_urb(p_priv->in_urbs[j]);
2322 usb_free_urb(p_priv->in_urbs[j]); 2318 usb_free_urb(p_priv->out_urbs[j]);
2323 if (p_priv->out_urbs[j])
2324 usb_free_urb(p_priv->out_urbs[j]);
2325 } 2319 }
2326 } 2320 }
2327 2321
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index ff03331e0bcf..237289920f03 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -185,13 +185,11 @@ static int kobil_startup (struct usb_serial *serial)
185 185
186 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { 186 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
187 endpoint = &altsetting->endpoint[i]; 187 endpoint = &altsetting->endpoint[i];
188 if (((endpoint->desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) && 188 if (usb_endpoint_is_int_out(&endpoint->desc)) {
189 ((endpoint->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
190 dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); 189 dbg("%s Found interrupt out endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress);
191 priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress; 190 priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress;
192 } 191 }
193 if (((endpoint->desc.bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) && 192 if (usb_endpoint_is_int_in(&endpoint->desc)) {
194 ((endpoint->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
195 dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress); 193 dbg("%s Found interrupt in endpoint. Address: %d", __FUNCTION__, endpoint->desc.bEndpointAddress);
196 priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress; 194 priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress;
197 } 195 }
@@ -355,8 +353,7 @@ static void kobil_close (struct usb_serial_port *port, struct file *filp)
355 usb_free_urb( port->write_urb ); 353 usb_free_urb( port->write_urb );
356 port->write_urb = NULL; 354 port->write_urb = NULL;
357 } 355 }
358 if (port->interrupt_in_urb) 356 usb_kill_urb(port->interrupt_in_urb);
359 usb_kill_urb(port->interrupt_in_urb);
360} 357}
361 358
362 359
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index b7582cc496dc..a906e500a02b 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -358,10 +358,8 @@ static int mct_u232_startup (struct usb_serial *serial)
358 /* Puh, that's dirty */ 358 /* Puh, that's dirty */
359 port = serial->port[0]; 359 port = serial->port[0];
360 rport = serial->port[1]; 360 rport = serial->port[1];
361 if (port->read_urb) { 361 /* No unlinking, it wasn't submitted yet. */
362 /* No unlinking, it wasn't submitted yet. */ 362 usb_free_urb(port->read_urb);
363 usb_free_urb(port->read_urb);
364 }
365 port->read_urb = rport->interrupt_in_urb; 363 port->read_urb = rport->interrupt_in_urb;
366 rport->interrupt_in_urb = NULL; 364 rport->interrupt_in_urb = NULL;
367 port->read_urb->context = port; 365 port->read_urb->context = port;
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 5b71962d0351..02c89e10b2cf 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2596,12 +2596,11 @@ static int mos7840_startup(struct usb_serial *serial)
2596 2596
2597 /* set up port private structures */ 2597 /* set up port private structures */
2598 for (i = 0; i < serial->num_ports; ++i) { 2598 for (i = 0; i < serial->num_ports; ++i) {
2599 mos7840_port = kmalloc(sizeof(struct moschip_port), GFP_KERNEL); 2599 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2600 if (mos7840_port == NULL) { 2600 if (mos7840_port == NULL) {
2601 err("%s - Out of memory", __FUNCTION__); 2601 err("%s - Out of memory", __FUNCTION__);
2602 return -ENOMEM; 2602 return -ENOMEM;
2603 } 2603 }
2604 memset(mos7840_port, 0, sizeof(struct moschip_port));
2605 2604
2606 /* Initialize all port interrupt end point to port 0 int endpoint * 2605 /* Initialize all port interrupt end point to port 0 int endpoint *
2607 * Our device has only one interrupt end point comman to all port */ 2606 * Our device has only one interrupt end point comman to all port */
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index 0610409a6568..054abee81652 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -95,8 +95,7 @@ static void navman_close(struct usb_serial_port *port, struct file *filp)
95{ 95{
96 dbg("%s - port %d", __FUNCTION__, port->number); 96 dbg("%s - port %d", __FUNCTION__, port->number);
97 97
98 if (port->interrupt_in_urb) 98 usb_kill_urb(port->interrupt_in_urb);
99 usb_kill_urb(port->interrupt_in_urb);
100} 99}
101 100
102static int navman_write(struct usb_serial_port *port, 101static int navman_write(struct usb_serial_port *port,
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 07400c0c8a8c..ae98d8cbdbb8 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -228,6 +228,7 @@ static int product_5052_count;
228/* null entry */ 228/* null entry */
229static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = { 229static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = {
230 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 230 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
231 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
231}; 232};
232 233
233static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 234static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -239,6 +240,7 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
239 240
240static struct usb_device_id ti_id_table_combined[] = { 241static struct usb_device_id ti_id_table_combined[] = {
241 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 242 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
243 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
242 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 244 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
243 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 245 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
244 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 246 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -459,13 +461,12 @@ static int ti_startup(struct usb_serial *serial)
459 461
460 /* set up port structures */ 462 /* set up port structures */
461 for (i = 0; i < serial->num_ports; ++i) { 463 for (i = 0; i < serial->num_ports; ++i) {
462 tport = kmalloc(sizeof(struct ti_port), GFP_KERNEL); 464 tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL);
463 if (tport == NULL) { 465 if (tport == NULL) {
464 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__); 466 dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
465 status = -ENOMEM; 467 status = -ENOMEM;
466 goto free_tports; 468 goto free_tports;
467 } 469 }
468 memset(tport, 0, sizeof(struct ti_port));
469 spin_lock_init(&tport->tp_lock); 470 spin_lock_init(&tport->tp_lock);
470 tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR); 471 tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
471 tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0; 472 tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index 02c1aeb9e1b8..b5541bf991ba 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -28,6 +28,7 @@
28/* Vendor and product ids */ 28/* Vendor and product ids */
29#define TI_VENDOR_ID 0x0451 29#define TI_VENDOR_ID 0x0451
30#define TI_3410_PRODUCT_ID 0x3410 30#define TI_3410_PRODUCT_ID 0x3410
31#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */
31#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */ 32#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */
32#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */ 33#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */
33#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */ 34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 2cfba8488a93..3d5072f14b8d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -953,32 +953,28 @@ probe_error:
953 port = serial->port[i]; 953 port = serial->port[i];
954 if (!port) 954 if (!port)
955 continue; 955 continue;
956 if (port->read_urb) 956 usb_free_urb(port->read_urb);
957 usb_free_urb (port->read_urb);
958 kfree(port->bulk_in_buffer); 957 kfree(port->bulk_in_buffer);
959 } 958 }
960 for (i = 0; i < num_bulk_out; ++i) { 959 for (i = 0; i < num_bulk_out; ++i) {
961 port = serial->port[i]; 960 port = serial->port[i];
962 if (!port) 961 if (!port)
963 continue; 962 continue;
964 if (port->write_urb) 963 usb_free_urb(port->write_urb);
965 usb_free_urb (port->write_urb);
966 kfree(port->bulk_out_buffer); 964 kfree(port->bulk_out_buffer);
967 } 965 }
968 for (i = 0; i < num_interrupt_in; ++i) { 966 for (i = 0; i < num_interrupt_in; ++i) {
969 port = serial->port[i]; 967 port = serial->port[i];
970 if (!port) 968 if (!port)
971 continue; 969 continue;
972 if (port->interrupt_in_urb) 970 usb_free_urb(port->interrupt_in_urb);
973 usb_free_urb (port->interrupt_in_urb);
974 kfree(port->interrupt_in_buffer); 971 kfree(port->interrupt_in_buffer);
975 } 972 }
976 for (i = 0; i < num_interrupt_out; ++i) { 973 for (i = 0; i < num_interrupt_out; ++i) {
977 port = serial->port[i]; 974 port = serial->port[i];
978 if (!port) 975 if (!port)
979 continue; 976 continue;
980 if (port->interrupt_out_urb) 977 usb_free_urb(port->interrupt_out_urb);
981 usb_free_urb (port->interrupt_out_urb);
982 kfree(port->interrupt_out_buffer); 978 kfree(port->interrupt_out_buffer);
983 } 979 }
984 980
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
new file mode 100644
index 000000000000..257a5e436873
--- /dev/null
+++ b/drivers/usb/serial/usb_debug.c
@@ -0,0 +1,65 @@
1/*
2 * USB Debug cable driver
3 *
4 * Copyright (C) 2006 Greg Kroah-Hartman <greg@kroah.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/tty.h>
14#include <linux/module.h>
15#include <linux/usb.h>
16#include <linux/usb/serial.h>
17
18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x0525, 0x127a) },
20 { },
21};
22MODULE_DEVICE_TABLE(usb, id_table);
23
24static struct usb_driver debug_driver = {
25 .name = "debug",
26 .probe = usb_serial_probe,
27 .disconnect = usb_serial_disconnect,
28 .id_table = id_table,
29 .no_dynamic_id = 1,
30};
31
32static struct usb_serial_driver debug_device = {
33 .driver = {
34 .owner = THIS_MODULE,
35 .name = "debug",
36 },
37 .id_table = id_table,
38 .num_interrupt_in = NUM_DONT_CARE,
39 .num_bulk_in = NUM_DONT_CARE,
40 .num_bulk_out = NUM_DONT_CARE,
41 .num_ports = 1,
42};
43
44static int __init debug_init(void)
45{
46 int retval;
47
48 retval = usb_serial_register(&debug_device);
49 if (retval)
50 return retval;
51 retval = usb_register(&debug_driver);
52 if (retval)
53 usb_serial_deregister(&debug_device);
54 return retval;
55}
56
57static void __exit debug_exit(void)
58{
59 usb_deregister(&debug_driver);
60 usb_serial_deregister(&debug_device);
61}
62
63module_init(debug_init);
64module_exit(debug_exit);
65MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index befe2e11a041..eef5eaa5fa0b 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -348,8 +348,7 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
348 348
349 /* shutdown our urbs */ 349 /* shutdown our urbs */
350 usb_kill_urb(port->read_urb); 350 usb_kill_urb(port->read_urb);
351 if (port->interrupt_in_urb) 351 usb_kill_urb(port->interrupt_in_urb);
352 usb_kill_urb(port->interrupt_in_urb);
353 352
354 /* Try to send shutdown message, if the device is gone, this will just fail. */ 353 /* Try to send shutdown message, if the device is gone, this will just fail. */
355 transfer_buffer = kmalloc (0x12, GFP_KERNEL); 354 transfer_buffer = kmalloc (0x12, GFP_KERNEL);
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 3baf448e300d..3a158d58441f 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -142,10 +142,7 @@ int onetouch_connect_input(struct us_data *ss)
142 return -ENODEV; 142 return -ENODEV;
143 143
144 endpoint = &interface->endpoint[2].desc; 144 endpoint = &interface->endpoint[2].desc;
145 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 145 if (!usb_endpoint_is_int_in(endpoint))
146 return -ENODEV;
147 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
148 != USB_ENDPOINT_XFER_INT)
149 return -ENODEV; 146 return -ENODEV;
150 147
151 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress); 148 pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index efb047f431e8..db8b26012c75 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1318,6 +1318,16 @@ UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
1318 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1318 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
1319 0 ), 1319 0 ),
1320 1320
1321/* Reported by Jaco Kroon <jaco@kroon.co.za>
1322 * The usb-storage module found on the Digitech GNX4 (and supposedly other
1323 * devices) misbehaves and causes a bunch of invalid I/O errors.
1324 */
1325UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100,
1326 "Digitech HMG",
1327 "DigiTech Mass Storage",
1328 US_SC_DEVICE, US_PR_DEVICE, NULL,
1329 US_FL_IGNORE_RESIDUE ),
1330
1321/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */ 1331/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
1322UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001, 1332UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
1323 "Minolta", 1333 "Minolta",
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index b8d6031b0975..b401084b3d22 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -740,18 +740,16 @@ static int get_pipes(struct us_data *us)
740 ep = &altsetting->endpoint[i].desc; 740 ep = &altsetting->endpoint[i].desc;
741 741
742 /* Is it a BULK endpoint? */ 742 /* Is it a BULK endpoint? */
743 if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 743 if (usb_endpoint_xfer_bulk(ep)) {
744 == USB_ENDPOINT_XFER_BULK) {
745 /* BULK in or out? */ 744 /* BULK in or out? */
746 if (ep->bEndpointAddress & USB_DIR_IN) 745 if (usb_endpoint_dir_in(ep))
747 ep_in = ep; 746 ep_in = ep;
748 else 747 else
749 ep_out = ep; 748 ep_out = ep;
750 } 749 }
751 750
752 /* Is it an interrupt endpoint? */ 751 /* Is it an interrupt endpoint? */
753 else if ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 752 else if (usb_endpoint_xfer_int(ep)) {
754 == USB_ENDPOINT_XFER_INT) {
755 ep_int = ep; 753 ep_int = ep;
756 } 754 }
757 } 755 }
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 93ffcdd95f50..e973a87fbb01 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1296,14 +1296,14 @@ register_framebuffer(struct fb_info *fb_info)
1296 break; 1296 break;
1297 fb_info->node = i; 1297 fb_info->node = i;
1298 1298
1299 fb_info->class_device = class_device_create(fb_class, NULL, MKDEV(FB_MAJOR, i), 1299 fb_info->dev = device_create(fb_class, fb_info->device,
1300 fb_info->device, "fb%d", i); 1300 MKDEV(FB_MAJOR, i), "fb%d", i);
1301 if (IS_ERR(fb_info->class_device)) { 1301 if (IS_ERR(fb_info->dev)) {
1302 /* Not fatal */ 1302 /* Not fatal */
1303 printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->class_device)); 1303 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
1304 fb_info->class_device = NULL; 1304 fb_info->dev = NULL;
1305 } else 1305 } else
1306 fb_init_class_device(fb_info); 1306 fb_init_device(fb_info);
1307 1307
1308 if (fb_info->pixmap.addr == NULL) { 1308 if (fb_info->pixmap.addr == NULL) {
1309 fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL); 1309 fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
@@ -1356,8 +1356,8 @@ unregister_framebuffer(struct fb_info *fb_info)
1356 fb_destroy_modelist(&fb_info->modelist); 1356 fb_destroy_modelist(&fb_info->modelist);
1357 registered_fb[i]=NULL; 1357 registered_fb[i]=NULL;
1358 num_registered_fb--; 1358 num_registered_fb--;
1359 fb_cleanup_class_device(fb_info); 1359 fb_cleanup_device(fb_info);
1360 class_device_destroy(fb_class, MKDEV(FB_MAJOR, i)); 1360 device_destroy(fb_class, MKDEV(FB_MAJOR, i));
1361 event.info = fb_info; 1361 event.info = fb_info;
1362 fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event); 1362 fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event);
1363 return 0; 1363 return 0;
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index d3a50417ed9a..323bdf6fc7d5 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL(framebuffer_alloc);
73 * 73 *
74 * @info: frame buffer info structure 74 * @info: frame buffer info structure
75 * 75 *
76 * Drop the reference count of the class_device embedded in the 76 * Drop the reference count of the device embedded in the
77 * framebuffer info structure. 77 * framebuffer info structure.
78 * 78 *
79 */ 79 */
@@ -120,10 +120,10 @@ static int mode_string(char *buf, unsigned int offset,
120 m, mode->xres, mode->yres, v, mode->refresh); 120 m, mode->xres, mode->yres, v, mode->refresh);
121} 121}
122 122
123static ssize_t store_mode(struct class_device *class_device, const char * buf, 123static ssize_t store_mode(struct device *device, struct device_attribute *attr,
124 size_t count) 124 const char *buf, size_t count)
125{ 125{
126 struct fb_info *fb_info = class_get_devdata(class_device); 126 struct fb_info *fb_info = dev_get_drvdata(device);
127 char mstr[100]; 127 char mstr[100];
128 struct fb_var_screeninfo var; 128 struct fb_var_screeninfo var;
129 struct fb_modelist *modelist; 129 struct fb_modelist *modelist;
@@ -151,9 +151,10 @@ static ssize_t store_mode(struct class_device *class_device, const char * buf,
151 return -EINVAL; 151 return -EINVAL;
152} 152}
153 153
154static ssize_t show_mode(struct class_device *class_device, char *buf) 154static ssize_t show_mode(struct device *device, struct device_attribute *attr,
155 char *buf)
155{ 156{
156 struct fb_info *fb_info = class_get_devdata(class_device); 157 struct fb_info *fb_info = dev_get_drvdata(device);
157 158
158 if (!fb_info->mode) 159 if (!fb_info->mode)
159 return 0; 160 return 0;
@@ -161,10 +162,11 @@ static ssize_t show_mode(struct class_device *class_device, char *buf)
161 return mode_string(buf, 0, fb_info->mode); 162 return mode_string(buf, 0, fb_info->mode);
162} 163}
163 164
164static ssize_t store_modes(struct class_device *class_device, const char * buf, 165static ssize_t store_modes(struct device *device,
165 size_t count) 166 struct device_attribute *attr,
167 const char *buf, size_t count)
166{ 168{
167 struct fb_info *fb_info = class_get_devdata(class_device); 169 struct fb_info *fb_info = dev_get_drvdata(device);
168 LIST_HEAD(old_list); 170 LIST_HEAD(old_list);
169 int i = count / sizeof(struct fb_videomode); 171 int i = count / sizeof(struct fb_videomode);
170 172
@@ -186,9 +188,10 @@ static ssize_t store_modes(struct class_device *class_device, const char * buf,
186 return 0; 188 return 0;
187} 189}
188 190
189static ssize_t show_modes(struct class_device *class_device, char *buf) 191static ssize_t show_modes(struct device *device, struct device_attribute *attr,
192 char *buf)
190{ 193{
191 struct fb_info *fb_info = class_get_devdata(class_device); 194 struct fb_info *fb_info = dev_get_drvdata(device);
192 unsigned int i; 195 unsigned int i;
193 struct list_head *pos; 196 struct list_head *pos;
194 struct fb_modelist *modelist; 197 struct fb_modelist *modelist;
@@ -203,10 +206,10 @@ static ssize_t show_modes(struct class_device *class_device, char *buf)
203 return i; 206 return i;
204} 207}
205 208
206static ssize_t store_bpp(struct class_device *class_device, const char * buf, 209static ssize_t store_bpp(struct device *device, struct device_attribute *attr,
207 size_t count) 210 const char *buf, size_t count)
208{ 211{
209 struct fb_info *fb_info = class_get_devdata(class_device); 212 struct fb_info *fb_info = dev_get_drvdata(device);
210 struct fb_var_screeninfo var; 213 struct fb_var_screeninfo var;
211 char ** last = NULL; 214 char ** last = NULL;
212 int err; 215 int err;
@@ -218,16 +221,18 @@ static ssize_t store_bpp(struct class_device *class_device, const char * buf,
218 return count; 221 return count;
219} 222}
220 223
221static ssize_t show_bpp(struct class_device *class_device, char *buf) 224static ssize_t show_bpp(struct device *device, struct device_attribute *attr,
225 char *buf)
222{ 226{
223 struct fb_info *fb_info = class_get_devdata(class_device); 227 struct fb_info *fb_info = dev_get_drvdata(device);
224 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel); 228 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.bits_per_pixel);
225} 229}
226 230
227static ssize_t store_rotate(struct class_device *class_device, const char *buf, 231static ssize_t store_rotate(struct device *device,
228 size_t count) 232 struct device_attribute *attr,
233 const char *buf, size_t count)
229{ 234{
230 struct fb_info *fb_info = class_get_devdata(class_device); 235 struct fb_info *fb_info = dev_get_drvdata(device);
231 struct fb_var_screeninfo var; 236 struct fb_var_screeninfo var;
232 char **last = NULL; 237 char **last = NULL;
233 int err; 238 int err;
@@ -242,17 +247,19 @@ static ssize_t store_rotate(struct class_device *class_device, const char *buf,
242} 247}
243 248
244 249
245static ssize_t show_rotate(struct class_device *class_device, char *buf) 250static ssize_t show_rotate(struct device *device,
251 struct device_attribute *attr, char *buf)
246{ 252{
247 struct fb_info *fb_info = class_get_devdata(class_device); 253 struct fb_info *fb_info = dev_get_drvdata(device);
248 254
249 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate); 255 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->var.rotate);
250} 256}
251 257
252static ssize_t store_virtual(struct class_device *class_device, 258static ssize_t store_virtual(struct device *device,
253 const char * buf, size_t count) 259 struct device_attribute *attr,
260 const char *buf, size_t count)
254{ 261{
255 struct fb_info *fb_info = class_get_devdata(class_device); 262 struct fb_info *fb_info = dev_get_drvdata(device);
256 struct fb_var_screeninfo var; 263 struct fb_var_screeninfo var;
257 char *last = NULL; 264 char *last = NULL;
258 int err; 265 int err;
@@ -269,23 +276,26 @@ static ssize_t store_virtual(struct class_device *class_device,
269 return count; 276 return count;
270} 277}
271 278
272static ssize_t show_virtual(struct class_device *class_device, char *buf) 279static ssize_t show_virtual(struct device *device,
280 struct device_attribute *attr, char *buf)
273{ 281{
274 struct fb_info *fb_info = class_get_devdata(class_device); 282 struct fb_info *fb_info = dev_get_drvdata(device);
275 return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual, 283 return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xres_virtual,
276 fb_info->var.yres_virtual); 284 fb_info->var.yres_virtual);
277} 285}
278 286
279static ssize_t show_stride(struct class_device *class_device, char *buf) 287static ssize_t show_stride(struct device *device,
288 struct device_attribute *attr, char *buf)
280{ 289{
281 struct fb_info *fb_info = class_get_devdata(class_device); 290 struct fb_info *fb_info = dev_get_drvdata(device);
282 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length); 291 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length);
283} 292}
284 293
285static ssize_t store_blank(struct class_device *class_device, const char * buf, 294static ssize_t store_blank(struct device *device,
286 size_t count) 295 struct device_attribute *attr,
296 const char *buf, size_t count)
287{ 297{
288 struct fb_info *fb_info = class_get_devdata(class_device); 298 struct fb_info *fb_info = dev_get_drvdata(device);
289 char *last = NULL; 299 char *last = NULL;
290 int err; 300 int err;
291 301
@@ -299,42 +309,48 @@ static ssize_t store_blank(struct class_device *class_device, const char * buf,
299 return count; 309 return count;
300} 310}
301 311
302static ssize_t show_blank(struct class_device *class_device, char *buf) 312static ssize_t show_blank(struct device *device,
313 struct device_attribute *attr, char *buf)
303{ 314{
304// struct fb_info *fb_info = class_get_devdata(class_device); 315// struct fb_info *fb_info = dev_get_drvdata(device);
305 return 0; 316 return 0;
306} 317}
307 318
308static ssize_t store_console(struct class_device *class_device, 319static ssize_t store_console(struct device *device,
309 const char * buf, size_t count) 320 struct device_attribute *attr,
321 const char *buf, size_t count)
310{ 322{
311// struct fb_info *fb_info = class_get_devdata(class_device); 323// struct fb_info *fb_info = dev_get_drvdata(device);
312 return 0; 324 return 0;
313} 325}
314 326
315static ssize_t show_console(struct class_device *class_device, char *buf) 327static ssize_t show_console(struct device *device,
328 struct device_attribute *attr, char *buf)
316{ 329{
317// struct fb_info *fb_info = class_get_devdata(class_device); 330// struct fb_info *fb_info = dev_get_drvdata(device);
318 return 0; 331 return 0;
319} 332}
320 333
321static ssize_t store_cursor(struct class_device *class_device, 334static ssize_t store_cursor(struct device *device,
322 const char * buf, size_t count) 335 struct device_attribute *attr,
336 const char *buf, size_t count)
323{ 337{
324// struct fb_info *fb_info = class_get_devdata(class_device); 338// struct fb_info *fb_info = dev_get_drvdata(device);
325 return 0; 339 return 0;
326} 340}
327 341
328static ssize_t show_cursor(struct class_device *class_device, char *buf) 342static ssize_t show_cursor(struct device *device,
343 struct device_attribute *attr, char *buf)
329{ 344{
330// struct fb_info *fb_info = class_get_devdata(class_device); 345// struct fb_info *fb_info = dev_get_drvdata(device);
331 return 0; 346 return 0;
332} 347}
333 348
334static ssize_t store_pan(struct class_device *class_device, const char * buf, 349static ssize_t store_pan(struct device *device,
335 size_t count) 350 struct device_attribute *attr,
351 const char *buf, size_t count)
336{ 352{
337 struct fb_info *fb_info = class_get_devdata(class_device); 353 struct fb_info *fb_info = dev_get_drvdata(device);
338 struct fb_var_screeninfo var; 354 struct fb_var_screeninfo var;
339 char *last = NULL; 355 char *last = NULL;
340 int err; 356 int err;
@@ -355,24 +371,27 @@ static ssize_t store_pan(struct class_device *class_device, const char * buf,
355 return count; 371 return count;
356} 372}
357 373
358static ssize_t show_pan(struct class_device *class_device, char *buf) 374static ssize_t show_pan(struct device *device,
375 struct device_attribute *attr, char *buf)
359{ 376{
360 struct fb_info *fb_info = class_get_devdata(class_device); 377 struct fb_info *fb_info = dev_get_drvdata(device);
361 return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset, 378 return snprintf(buf, PAGE_SIZE, "%d,%d\n", fb_info->var.xoffset,
362 fb_info->var.xoffset); 379 fb_info->var.xoffset);
363} 380}
364 381
365static ssize_t show_name(struct class_device *class_device, char *buf) 382static ssize_t show_name(struct device *device,
383 struct device_attribute *attr, char *buf)
366{ 384{
367 struct fb_info *fb_info = class_get_devdata(class_device); 385 struct fb_info *fb_info = dev_get_drvdata(device);
368 386
369 return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id); 387 return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id);
370} 388}
371 389
372static ssize_t store_fbstate(struct class_device *class_device, 390static ssize_t store_fbstate(struct device *device,
373 const char *buf, size_t count) 391 struct device_attribute *attr,
392 const char *buf, size_t count)
374{ 393{
375 struct fb_info *fb_info = class_get_devdata(class_device); 394 struct fb_info *fb_info = dev_get_drvdata(device);
376 u32 state; 395 u32 state;
377 char *last = NULL; 396 char *last = NULL;
378 397
@@ -385,17 +404,19 @@ static ssize_t store_fbstate(struct class_device *class_device,
385 return count; 404 return count;
386} 405}
387 406
388static ssize_t show_fbstate(struct class_device *class_device, char *buf) 407static ssize_t show_fbstate(struct device *device,
408 struct device_attribute *attr, char *buf)
389{ 409{
390 struct fb_info *fb_info = class_get_devdata(class_device); 410 struct fb_info *fb_info = dev_get_drvdata(device);
391 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); 411 return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state);
392} 412}
393 413
394#ifdef CONFIG_FB_BACKLIGHT 414#ifdef CONFIG_FB_BACKLIGHT
395static ssize_t store_bl_curve(struct class_device *class_device, 415static ssize_t store_bl_curve(struct device *device,
396 const char *buf, size_t count) 416 struct device_attribute *attr,
417 const char *buf, size_t count)
397{ 418{
398 struct fb_info *fb_info = class_get_devdata(class_device); 419 struct fb_info *fb_info = dev_get_drvdata(device);
399 u8 tmp_curve[FB_BACKLIGHT_LEVELS]; 420 u8 tmp_curve[FB_BACKLIGHT_LEVELS];
400 unsigned int i; 421 unsigned int i;
401 422
@@ -432,9 +453,10 @@ static ssize_t store_bl_curve(struct class_device *class_device,
432 return count; 453 return count;
433} 454}
434 455
435static ssize_t show_bl_curve(struct class_device *class_device, char *buf) 456static ssize_t show_bl_curve(struct device *device,
457 struct device_attribute *attr, char *buf)
436{ 458{
437 struct fb_info *fb_info = class_get_devdata(class_device); 459 struct fb_info *fb_info = dev_get_drvdata(device);
438 ssize_t len = 0; 460 ssize_t len = 0;
439 unsigned int i; 461 unsigned int i;
440 462
@@ -465,7 +487,7 @@ static ssize_t show_bl_curve(struct class_device *class_device, char *buf)
465/* When cmap is added back in it should be a binary attribute 487/* When cmap is added back in it should be a binary attribute
466 * not a text one. Consideration should also be given to converting 488 * not a text one. Consideration should also be given to converting
467 * fbdev to use configfs instead of sysfs */ 489 * fbdev to use configfs instead of sysfs */
468static struct class_device_attribute class_device_attrs[] = { 490static struct device_attribute device_attrs[] = {
469 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp), 491 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp),
470 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank), 492 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank),
471 __ATTR(console, S_IRUGO|S_IWUSR, show_console, store_console), 493 __ATTR(console, S_IRUGO|S_IWUSR, show_console, store_console),
@@ -483,17 +505,16 @@ static struct class_device_attribute class_device_attrs[] = {
483#endif 505#endif
484}; 506};
485 507
486int fb_init_class_device(struct fb_info *fb_info) 508int fb_init_device(struct fb_info *fb_info)
487{ 509{
488 int i, error = 0; 510 int i, error = 0;
489 511
490 class_set_devdata(fb_info->class_device, fb_info); 512 dev_set_drvdata(fb_info->dev, fb_info);
491 513
492 fb_info->class_flag |= FB_SYSFS_FLAG_ATTR; 514 fb_info->class_flag |= FB_SYSFS_FLAG_ATTR;
493 515
494 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) { 516 for (i = 0; i < ARRAY_SIZE(device_attrs); i++) {
495 error = class_device_create_file(fb_info->class_device, 517 error = device_create_file(fb_info->dev, &device_attrs[i]);
496 &class_device_attrs[i]);
497 518
498 if (error) 519 if (error)
499 break; 520 break;
@@ -501,22 +522,20 @@ int fb_init_class_device(struct fb_info *fb_info)
501 522
502 if (error) { 523 if (error) {
503 while (--i >= 0) 524 while (--i >= 0)
504 class_device_remove_file(fb_info->class_device, 525 device_remove_file(fb_info->dev, &device_attrs[i]);
505 &class_device_attrs[i]);
506 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; 526 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR;
507 } 527 }
508 528
509 return 0; 529 return 0;
510} 530}
511 531
512void fb_cleanup_class_device(struct fb_info *fb_info) 532void fb_cleanup_device(struct fb_info *fb_info)
513{ 533{
514 unsigned int i; 534 unsigned int i;
515 535
516 if (fb_info->class_flag & FB_SYSFS_FLAG_ATTR) { 536 if (fb_info->class_flag & FB_SYSFS_FLAG_ATTR) {
517 for (i = 0; i < ARRAY_SIZE(class_device_attrs); i++) 537 for (i = 0; i < ARRAY_SIZE(device_attrs); i++)
518 class_device_remove_file(fb_info->class_device, 538 device_remove_file(fb_info->dev, &device_attrs[i]);
519 &class_device_attrs[i]);
520 539
521 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR; 540 fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR;
522 } 541 }
diff --git a/fs/Kconfig b/fs/Kconfig
index 7b1511d50b05..b3b5aa0edff9 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -972,7 +972,7 @@ config SYSFS
972 972
973 Some system agents rely on the information in sysfs to operate. 973 Some system agents rely on the information in sysfs to operate.
974 /sbin/hotplug uses device and object attributes in sysfs to assist in 974 /sbin/hotplug uses device and object attributes in sysfs to assist in
975 delegating policy decisions, like persistantly naming devices. 975 delegating policy decisions, like persistently naming devices.
976 976
977 sysfs is currently used by the block subsystem to mount the root 977 sysfs is currently used by the block subsystem to mount the root
978 partition. If sysfs is disabled you must specify the boot device on 978 partition. If sysfs is disabled you must specify the boot device on
@@ -1145,7 +1145,7 @@ config BEFS_FS
1145 help 1145 help
1146 The BeOS File System (BeFS) is the native file system of Be, Inc's 1146 The BeOS File System (BeFS) is the native file system of Be, Inc's
1147 BeOS. Notable features include support for arbitrary attributes 1147 BeOS. Notable features include support for arbitrary attributes
1148 on files and directories, and database-like indeces on selected 1148 on files and directories, and database-like indices on selected
1149 attributes. (Also note that this driver doesn't make those features 1149 attributes. (Also note that this driver doesn't make those features
1150 available at this time). It is a 64 bit filesystem, so it supports 1150 available at this time). It is a 64 bit filesystem, so it supports
1151 extremely large volumes and files. 1151 extremely large volumes and files.
diff --git a/fs/aio.c b/fs/aio.c
index ca1c5180a17f..287a1bc7a182 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -367,8 +367,7 @@ void fastcall __put_ioctx(struct kioctx *ctx)
367{ 367{
368 unsigned nr_events = ctx->max_reqs; 368 unsigned nr_events = ctx->max_reqs;
369 369
370 if (unlikely(ctx->reqs_active)) 370 BUG_ON(ctx->reqs_active);
371 BUG();
372 371
373 cancel_delayed_work(&ctx->wq); 372 cancel_delayed_work(&ctx->wq);
374 flush_workqueue(aio_wq); 373 flush_workqueue(aio_wq);
@@ -505,8 +504,7 @@ static int __aio_put_req(struct kioctx *ctx, struct kiocb *req)
505 assert_spin_locked(&ctx->ctx_lock); 504 assert_spin_locked(&ctx->ctx_lock);
506 505
507 req->ki_users --; 506 req->ki_users --;
508 if (unlikely(req->ki_users < 0)) 507 BUG_ON(req->ki_users < 0);
509 BUG();
510 if (likely(req->ki_users)) 508 if (likely(req->ki_users))
511 return 0; 509 return 0;
512 list_del(&req->ki_list); /* remove from active_reqs */ 510 list_del(&req->ki_list); /* remove from active_reqs */
diff --git a/fs/bio.c b/fs/bio.c
index c6c07ca5b5a9..50c40ce2cead 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -560,10 +560,8 @@ struct bio *bio_copy_user(request_queue_t *q, unsigned long uaddr,
560 break; 560 break;
561 } 561 }
562 562
563 if (bio_add_pc_page(q, bio, page, bytes, 0) < bytes) { 563 if (bio_add_pc_page(q, bio, page, bytes, 0) < bytes)
564 ret = -EINVAL;
565 break; 564 break;
566 }
567 565
568 len -= bytes; 566 len -= bytes;
569 } 567 }
@@ -622,10 +620,9 @@ static struct bio *__bio_map_user_iov(request_queue_t *q,
622 620
623 nr_pages += end - start; 621 nr_pages += end - start;
624 /* 622 /*
625 * transfer and buffer must be aligned to at least hardsector 623 * buffer must be aligned to at least hardsector size for now
626 * size for now, in the future we can relax this restriction
627 */ 624 */
628 if ((uaddr & queue_dma_alignment(q)) || (len & queue_dma_alignment(q))) 625 if (uaddr & queue_dma_alignment(q))
629 return ERR_PTR(-EINVAL); 626 return ERR_PTR(-EINVAL);
630 } 627 }
631 628
@@ -751,7 +748,6 @@ struct bio *bio_map_user_iov(request_queue_t *q, struct block_device *bdev,
751 int write_to_vm) 748 int write_to_vm)
752{ 749{
753 struct bio *bio; 750 struct bio *bio;
754 int len = 0, i;
755 751
756 bio = __bio_map_user_iov(q, bdev, iov, iov_count, write_to_vm); 752 bio = __bio_map_user_iov(q, bdev, iov, iov_count, write_to_vm);
757 753
@@ -766,18 +762,7 @@ struct bio *bio_map_user_iov(request_queue_t *q, struct block_device *bdev,
766 */ 762 */
767 bio_get(bio); 763 bio_get(bio);
768 764
769 for (i = 0; i < iov_count; i++) 765 return bio;
770 len += iov[i].iov_len;
771
772 if (bio->bi_size == len)
773 return bio;
774
775 /*
776 * don't support partial mappings
777 */
778 bio_endio(bio, bio->bi_size, 0);
779 bio_unmap_user(bio);
780 return ERR_PTR(-EINVAL);
781} 766}
782 767
783static void __bio_unmap_user(struct bio *bio) 768static void __bio_unmap_user(struct bio *bio)
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 1ad8c9fcc742..c4fa91b8b62f 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -318,6 +318,7 @@ int cifs_get_inode_info(struct inode **pinode,
318 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 318 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
319 char *tmp_path; 319 char *tmp_path;
320 char *buf = NULL; 320 char *buf = NULL;
321 int adjustTZ = FALSE;
321 322
322 pTcon = cifs_sb->tcon; 323 pTcon = cifs_sb->tcon;
323 cFYI(1,("Getting info on %s", search_path)); 324 cFYI(1,("Getting info on %s", search_path));
@@ -348,6 +349,7 @@ int cifs_get_inode_info(struct inode **pinode,
348 pfindData, cifs_sb->local_nls, 349 pfindData, cifs_sb->local_nls,
349 cifs_sb->mnt_cifs_flags & 350 cifs_sb->mnt_cifs_flags &
350 CIFS_MOUNT_MAP_SPECIAL_CHR); 351 CIFS_MOUNT_MAP_SPECIAL_CHR);
352 adjustTZ = TRUE;
351 } 353 }
352 354
353 } 355 }
@@ -444,6 +446,10 @@ int cifs_get_inode_info(struct inode **pinode,
444 inode->i_ctime = 446 inode->i_ctime =
445 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); 447 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
446 cFYI(0, ("Attributes came in as 0x%x", attr)); 448 cFYI(0, ("Attributes came in as 0x%x", attr));
449 if(adjustTZ && (pTcon->ses) && (pTcon->ses->server)) {
450 inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj;
451 inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj;
452 }
447 453
448 /* set default mode. will override for dirs below */ 454 /* set default mode. will override for dirs below */
449 if (atomic_read(&cifsInfo->inUse) == 0) 455 if (atomic_read(&cifsInfo->inUse) == 0)
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 0bee8b7e521a..8e259969354b 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -69,17 +69,30 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
69 rc = -EOPNOTSUPP; 69 rc = -EOPNOTSUPP;
70 } 70 }
71 71
72/* if (!rc) */ 72 d_drop(direntry); /* force new lookup from server of target */
73 { 73
74 /* renew_parental_timestamps(old_file); 74 /* if source file is cached (oplocked) revalidate will not go to server
75 inode->i_nlink++; 75 until the file is closed or oplock broken so update nlinks locally */
76 mark_inode_dirty(inode); 76 if(old_file->d_inode) {
77 d_instantiate(direntry, inode); */ 77 cifsInode = CIFS_I(old_file->d_inode);
78 /* BB add call to either mark inode dirty or refresh its data and timestamp to current time */ 78 if(rc == 0) {
79 old_file->d_inode->i_nlink++;
80 old_file->d_inode->i_ctime = CURRENT_TIME;
81 /* parent dir timestamps will update from srv
82 within a second, would it really be worth it
83 to set the parent dir cifs inode time to zero
84 to force revalidate (faster) for it too? */
85 }
86 /* if not oplocked will force revalidate to get info
87 on source file from srv */
88 cifsInode->time = 0;
89
90 /* Will update parent dir timestamps from srv within a second.
91 Would it really be worth it to set the parent dir (cifs
92 inode) time field to zero to force revalidate on parent
93 directory faster ie
94 CIFS_I(inode)->time = 0; */
79 } 95 }
80 d_drop(direntry); /* force new lookup from server */
81 cifsInode = CIFS_I(old_file->d_inode);
82 cifsInode->time = 0; /* will force revalidate to go get info when needed */
83 96
84cifs_hl_exit: 97cifs_hl_exit:
85 kfree(fromName); 98 kfree(fromName);
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index a736d44989c4..137d76c3f90a 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -21,6 +21,7 @@
21#include <linux/mount.h> 21#include <linux/mount.h>
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/kobject.h>
24#include <linux/namei.h> 25#include <linux/namei.h>
25#include <linux/debugfs.h> 26#include <linux/debugfs.h>
26 27
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 136175a69332..f63a7755fe86 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -820,7 +820,8 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
820 crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0, 820 crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0,
821 CRYPTO_ALG_ASYNC); 821 CRYPTO_ALG_ASYNC);
822 kfree(full_alg_name); 822 kfree(full_alg_name);
823 if (!crypt_stat->tfm) { 823 if (IS_ERR(crypt_stat->tfm)) {
824 rc = PTR_ERR(crypt_stat->tfm);
824 ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): " 825 ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): "
825 "Error initializing cipher [%s]\n", 826 "Error initializing cipher [%s]\n",
826 crypt_stat->cipher); 827 crypt_stat->cipher);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index cfc8f81e60d0..c71a6c092ad9 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -138,6 +138,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
138 struct fuse_entry_out outarg; 138 struct fuse_entry_out outarg;
139 struct fuse_conn *fc; 139 struct fuse_conn *fc;
140 struct fuse_req *req; 140 struct fuse_req *req;
141 struct fuse_req *forget_req;
141 struct dentry *parent; 142 struct dentry *parent;
142 143
143 /* Doesn't hurt to "reset" the validity timeout */ 144 /* Doesn't hurt to "reset" the validity timeout */
@@ -152,25 +153,33 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
152 if (IS_ERR(req)) 153 if (IS_ERR(req))
153 return 0; 154 return 0;
154 155
156 forget_req = fuse_get_req(fc);
157 if (IS_ERR(forget_req)) {
158 fuse_put_request(fc, req);
159 return 0;
160 }
161
155 parent = dget_parent(entry); 162 parent = dget_parent(entry);
156 fuse_lookup_init(req, parent->d_inode, entry, &outarg); 163 fuse_lookup_init(req, parent->d_inode, entry, &outarg);
157 request_send(fc, req); 164 request_send(fc, req);
158 dput(parent); 165 dput(parent);
159 err = req->out.h.error; 166 err = req->out.h.error;
167 fuse_put_request(fc, req);
160 /* Zero nodeid is same as -ENOENT */ 168 /* Zero nodeid is same as -ENOENT */
161 if (!err && !outarg.nodeid) 169 if (!err && !outarg.nodeid)
162 err = -ENOENT; 170 err = -ENOENT;
163 if (!err) { 171 if (!err) {
164 struct fuse_inode *fi = get_fuse_inode(inode); 172 struct fuse_inode *fi = get_fuse_inode(inode);
165 if (outarg.nodeid != get_node_id(inode)) { 173 if (outarg.nodeid != get_node_id(inode)) {
166 fuse_send_forget(fc, req, outarg.nodeid, 1); 174 fuse_send_forget(fc, forget_req,
175 outarg.nodeid, 1);
167 return 0; 176 return 0;
168 } 177 }
169 spin_lock(&fc->lock); 178 spin_lock(&fc->lock);
170 fi->nlookup ++; 179 fi->nlookup ++;
171 spin_unlock(&fc->lock); 180 spin_unlock(&fc->lock);
172 } 181 }
173 fuse_put_request(fc, req); 182 fuse_put_request(fc, forget_req);
174 if (err || (outarg.attr.mode ^ inode->i_mode) & S_IFMT) 183 if (err || (outarg.attr.mode ^ inode->i_mode) & S_IFMT)
175 return 0; 184 return 0;
176 185
@@ -221,6 +230,7 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
221 struct inode *inode = NULL; 230 struct inode *inode = NULL;
222 struct fuse_conn *fc = get_fuse_conn(dir); 231 struct fuse_conn *fc = get_fuse_conn(dir);
223 struct fuse_req *req; 232 struct fuse_req *req;
233 struct fuse_req *forget_req;
224 234
225 if (entry->d_name.len > FUSE_NAME_MAX) 235 if (entry->d_name.len > FUSE_NAME_MAX)
226 return ERR_PTR(-ENAMETOOLONG); 236 return ERR_PTR(-ENAMETOOLONG);
@@ -229,9 +239,16 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
229 if (IS_ERR(req)) 239 if (IS_ERR(req))
230 return ERR_PTR(PTR_ERR(req)); 240 return ERR_PTR(PTR_ERR(req));
231 241
242 forget_req = fuse_get_req(fc);
243 if (IS_ERR(forget_req)) {
244 fuse_put_request(fc, req);
245 return ERR_PTR(PTR_ERR(forget_req));
246 }
247
232 fuse_lookup_init(req, dir, entry, &outarg); 248 fuse_lookup_init(req, dir, entry, &outarg);
233 request_send(fc, req); 249 request_send(fc, req);
234 err = req->out.h.error; 250 err = req->out.h.error;
251 fuse_put_request(fc, req);
235 /* Zero nodeid is same as -ENOENT, but with valid timeout */ 252 /* Zero nodeid is same as -ENOENT, but with valid timeout */
236 if (!err && outarg.nodeid && 253 if (!err && outarg.nodeid &&
237 (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode))) 254 (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode)))
@@ -240,11 +257,11 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
240 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, 257 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
241 &outarg.attr); 258 &outarg.attr);
242 if (!inode) { 259 if (!inode) {
243 fuse_send_forget(fc, req, outarg.nodeid, 1); 260 fuse_send_forget(fc, forget_req, outarg.nodeid, 1);
244 return ERR_PTR(-ENOMEM); 261 return ERR_PTR(-ENOMEM);
245 } 262 }
246 } 263 }
247 fuse_put_request(fc, req); 264 fuse_put_request(fc, forget_req);
248 if (err && err != -ENOENT) 265 if (err && err != -ENOENT)
249 return ERR_PTR(err); 266 return ERR_PTR(err);
250 267
@@ -388,6 +405,13 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req,
388 struct fuse_entry_out outarg; 405 struct fuse_entry_out outarg;
389 struct inode *inode; 406 struct inode *inode;
390 int err; 407 int err;
408 struct fuse_req *forget_req;
409
410 forget_req = fuse_get_req(fc);
411 if (IS_ERR(forget_req)) {
412 fuse_put_request(fc, req);
413 return PTR_ERR(forget_req);
414 }
391 415
392 req->in.h.nodeid = get_node_id(dir); 416 req->in.h.nodeid = get_node_id(dir);
393 req->out.numargs = 1; 417 req->out.numargs = 1;
@@ -395,24 +419,24 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req,
395 req->out.args[0].value = &outarg; 419 req->out.args[0].value = &outarg;
396 request_send(fc, req); 420 request_send(fc, req);
397 err = req->out.h.error; 421 err = req->out.h.error;
398 if (err) { 422 fuse_put_request(fc, req);
399 fuse_put_request(fc, req); 423 if (err)
400 return err; 424 goto out_put_forget_req;
401 } 425
402 err = -EIO; 426 err = -EIO;
403 if (invalid_nodeid(outarg.nodeid)) 427 if (invalid_nodeid(outarg.nodeid))
404 goto out_put_request; 428 goto out_put_forget_req;
405 429
406 if ((outarg.attr.mode ^ mode) & S_IFMT) 430 if ((outarg.attr.mode ^ mode) & S_IFMT)
407 goto out_put_request; 431 goto out_put_forget_req;
408 432
409 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, 433 inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
410 &outarg.attr); 434 &outarg.attr);
411 if (!inode) { 435 if (!inode) {
412 fuse_send_forget(fc, req, outarg.nodeid, 1); 436 fuse_send_forget(fc, forget_req, outarg.nodeid, 1);
413 return -ENOMEM; 437 return -ENOMEM;
414 } 438 }
415 fuse_put_request(fc, req); 439 fuse_put_request(fc, forget_req);
416 440
417 if (S_ISDIR(inode->i_mode)) { 441 if (S_ISDIR(inode->i_mode)) {
418 struct dentry *alias; 442 struct dentry *alias;
@@ -434,8 +458,8 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req,
434 fuse_invalidate_attr(dir); 458 fuse_invalidate_attr(dir);
435 return 0; 459 return 0;
436 460
437 out_put_request: 461 out_put_forget_req:
438 fuse_put_request(fc, req); 462 fuse_put_request(fc, forget_req);
439 return err; 463 return err;
440} 464}
441 465
diff --git a/fs/jfs/jfs_filsys.h b/fs/jfs/jfs_filsys.h
index 9901928668cf..eb550b339bb8 100644
--- a/fs/jfs/jfs_filsys.h
+++ b/fs/jfs/jfs_filsys.h
@@ -81,7 +81,7 @@
81#define JFS_SWAP_BYTES 0x00100000 /* running on big endian computer */ 81#define JFS_SWAP_BYTES 0x00100000 /* running on big endian computer */
82 82
83/* Directory index */ 83/* Directory index */
84#define JFS_DIR_INDEX 0x00200000 /* Persistant index for */ 84#define JFS_DIR_INDEX 0x00200000 /* Persistent index for */
85 /* directory entries */ 85 /* directory entries */
86 86
87 87
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c
index 8dfefe41a8da..75f819dc0255 100644
--- a/fs/nfs/nfsroot.c
+++ b/fs/nfs/nfsroot.c
@@ -98,7 +98,7 @@
98static char nfs_root_name[256] __initdata = ""; 98static char nfs_root_name[256] __initdata = "";
99 99
100/* Address of NFS server */ 100/* Address of NFS server */
101static __u32 servaddr __initdata = 0; 101static __be32 servaddr __initdata = 0;
102 102
103/* Name of directory to mount */ 103/* Name of directory to mount */
104static char nfs_path[NFS_MAXPATHLEN] __initdata = { 0, }; 104static char nfs_path[NFS_MAXPATHLEN] __initdata = { 0, };
@@ -327,7 +327,7 @@ static int __init root_nfs_name(char *name)
327 */ 327 */
328static int __init root_nfs_addr(void) 328static int __init root_nfs_addr(void)
329{ 329{
330 if ((servaddr = root_server_addr) == INADDR_NONE) { 330 if ((servaddr = root_server_addr) == htonl(INADDR_NONE)) {
331 printk(KERN_ERR "Root-NFS: No NFS server available, giving up.\n"); 331 printk(KERN_ERR "Root-NFS: No NFS server available, giving up.\n");
332 return -1; 332 return -1;
333 } 333 }
@@ -411,7 +411,7 @@ __setup("nfsroot=", nfs_root_setup);
411 * Construct sockaddr_in from address and port number. 411 * Construct sockaddr_in from address and port number.
412 */ 412 */
413static inline void 413static inline void
414set_sockaddr(struct sockaddr_in *sin, __u32 addr, __u16 port) 414set_sockaddr(struct sockaddr_in *sin, __be32 addr, __be16 port)
415{ 415{
416 sin->sin_family = AF_INET; 416 sin->sin_family = AF_INET;
417 sin->sin_addr.s_addr = addr; 417 sin->sin_addr.s_addr = addr;
@@ -468,14 +468,13 @@ static int __init root_nfs_ports(void)
468 dprintk("Root-NFS: Portmapper on server returned %d " 468 dprintk("Root-NFS: Portmapper on server returned %d "
469 "as nfsd port\n", port); 469 "as nfsd port\n", port);
470 } 470 }
471 nfs_port = htons(nfs_port);
472 471
473 if ((port = root_nfs_getport(NFS_MNT_PROGRAM, mountd_ver, proto)) < 0) { 472 if ((port = root_nfs_getport(NFS_MNT_PROGRAM, mountd_ver, proto)) < 0) {
474 printk(KERN_ERR "Root-NFS: Unable to get mountd port " 473 printk(KERN_ERR "Root-NFS: Unable to get mountd port "
475 "number from server, using default\n"); 474 "number from server, using default\n");
476 port = mountd_port; 475 port = mountd_port;
477 } 476 }
478 mount_port = htons(port); 477 mount_port = port;
479 dprintk("Root-NFS: mountd port is %d\n", port); 478 dprintk("Root-NFS: mountd port is %d\n", port);
480 479
481 return 0; 480 return 0;
@@ -496,7 +495,7 @@ static int __init root_nfs_get_handle(void)
496 int version = (nfs_data.flags & NFS_MOUNT_VER3) ? 495 int version = (nfs_data.flags & NFS_MOUNT_VER3) ?
497 NFS_MNT3_VERSION : NFS_MNT_VERSION; 496 NFS_MNT3_VERSION : NFS_MNT_VERSION;
498 497
499 set_sockaddr(&sin, servaddr, mount_port); 498 set_sockaddr(&sin, servaddr, htons(mount_port));
500 status = nfsroot_mount(&sin, nfs_path, &fh, version, protocol); 499 status = nfsroot_mount(&sin, nfs_path, &fh, version, protocol);
501 if (status < 0) 500 if (status < 0)
502 printk(KERN_ERR "Root-NFS: Server returned error %d " 501 printk(KERN_ERR "Root-NFS: Server returned error %d "
@@ -519,6 +518,6 @@ void * __init nfs_root_data(void)
519 || root_nfs_ports() < 0 518 || root_nfs_ports() < 0
520 || root_nfs_get_handle() < 0) 519 || root_nfs_get_handle() < 0)
521 return NULL; 520 return NULL;
522 set_sockaddr((struct sockaddr_in *) &nfs_data.addr, servaddr, nfs_port); 521 set_sockaddr((struct sockaddr_in *) &nfs_data.addr, servaddr, htons(nfs_port));
523 return (void*)&nfs_data; 522 return (void*)&nfs_data;
524} 523}
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8df27401d292..795319c54f72 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -442,7 +442,8 @@ static int mountstats_open(struct inode *inode, struct file *file)
442 442
443 if (task) { 443 if (task) {
444 task_lock(task); 444 task_lock(task);
445 namespace = task->nsproxy->namespace; 445 if (task->nsproxy)
446 namespace = task->nsproxy->namespace;
446 if (namespace) 447 if (namespace)
447 get_namespace(namespace); 448 get_namespace(namespace);
448 task_unlock(task); 449 task_unlock(task);
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index b67ce9354048..ac14318c81ba 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -74,7 +74,8 @@ static int reiserfs_file_release(struct inode *inode, struct file *filp)
74 igrab(inode); 74 igrab(inode);
75 reiserfs_warning(inode->i_sb, 75 reiserfs_warning(inode->i_sb,
76 "pinning inode %lu because the " 76 "pinning inode %lu because the "
77 "preallocation can't be freed"); 77 "preallocation can't be freed",
78 inode->i_ino);
78 goto out; 79 goto out;
79 } 80 }
80 } 81 }
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index cd1bb75ceb24..7280a23ef344 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -1464,7 +1464,7 @@ static int flush_journal_list(struct super_block *s,
1464 } 1464 }
1465 1465
1466 /* if someone has this block in a newer transaction, just make 1466 /* if someone has this block in a newer transaction, just make
1467 ** sure they are commited, and don't try writing it to disk 1467 ** sure they are committed, and don't try writing it to disk
1468 */ 1468 */
1469 if (pjl) { 1469 if (pjl) {
1470 if (atomic_read(&pjl->j_commit_left)) 1470 if (atomic_read(&pjl->j_commit_left))
@@ -3385,7 +3385,7 @@ static int remove_from_transaction(struct super_block *p_s_sb,
3385 3385
3386/* 3386/*
3387** for any cnode in a journal list, it can only be dirtied of all the 3387** for any cnode in a journal list, it can only be dirtied of all the
3388** transactions that include it are commited to disk. 3388** transactions that include it are committed to disk.
3389** this checks through each transaction, and returns 1 if you are allowed to dirty, 3389** this checks through each transaction, and returns 1 if you are allowed to dirty,
3390** and 0 if you aren't 3390** and 0 if you aren't
3391** 3391**
@@ -3427,7 +3427,7 @@ static int can_dirty(struct reiserfs_journal_cnode *cn)
3427} 3427}
3428 3428
3429/* syncs the commit blocks, but does not force the real buffers to disk 3429/* syncs the commit blocks, but does not force the real buffers to disk
3430** will wait until the current transaction is done/commited before returning 3430** will wait until the current transaction is done/committed before returning
3431*/ 3431*/
3432int journal_end_sync(struct reiserfs_transaction_handle *th, 3432int journal_end_sync(struct reiserfs_transaction_handle *th,
3433 struct super_block *p_s_sb, unsigned long nblocks) 3433 struct super_block *p_s_sb, unsigned long nblocks)
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 7bdb0ed443e1..1e4d68590178 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -41,7 +41,7 @@
41#include <linux/reiserfs_xattr.h> 41#include <linux/reiserfs_xattr.h>
42#include <linux/reiserfs_acl.h> 42#include <linux/reiserfs_acl.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <asm/checksum.h> 44#include <net/checksum.h>
45#include <linux/smp_lock.h> 45#include <linux/smp_lock.h>
46#include <linux/stat.h> 46#include <linux/stat.h>
47#include <asm/semaphore.h> 47#include <asm/semaphore.h>
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 3aa3434621ca..a5782e8c7f07 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -372,6 +372,51 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
372 return error; 372 return error;
373} 373}
374 374
375int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent)
376{
377 struct dentry *old_parent_dentry, *new_parent_dentry, *new_dentry;
378 struct sysfs_dirent *new_parent_sd, *sd;
379 int error;
380
381 if (!new_parent)
382 return -EINVAL;
383
384 old_parent_dentry = kobj->parent ?
385 kobj->parent->dentry : sysfs_mount->mnt_sb->s_root;
386 new_parent_dentry = new_parent->dentry;
387
388again:
389 mutex_lock(&old_parent_dentry->d_inode->i_mutex);
390 if (!mutex_trylock(&new_parent_dentry->d_inode->i_mutex)) {
391 mutex_unlock(&old_parent_dentry->d_inode->i_mutex);
392 goto again;
393 }
394
395 new_parent_sd = new_parent_dentry->d_fsdata;
396 sd = kobj->dentry->d_fsdata;
397
398 new_dentry = lookup_one_len(kobj->name, new_parent_dentry,
399 strlen(kobj->name));
400 if (IS_ERR(new_dentry)) {
401 error = PTR_ERR(new_dentry);
402 goto out;
403 } else
404 error = 0;
405 d_add(new_dentry, NULL);
406 d_move(kobj->dentry, new_dentry);
407 dput(new_dentry);
408
409 /* Remove from old parent's list and insert into new parent's list. */
410 list_del_init(&sd->s_sibling);
411 list_add(&sd->s_sibling, &new_parent_sd->s_children);
412
413out:
414 mutex_unlock(&new_parent_dentry->d_inode->i_mutex);
415 mutex_unlock(&old_parent_dentry->d_inode->i_mutex);
416
417 return error;
418}
419
375static int sysfs_dir_open(struct inode *inode, struct file *file) 420static int sysfs_dir_open(struct inode *inode, struct file *file)
376{ 421{
377 struct dentry * dentry = file->f_dentry; 422 struct dentry * dentry = file->f_dentry;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 298303b5a716..95c165101c98 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -190,6 +190,9 @@ fill_write_buffer(struct sysfs_buffer * buffer, const char __user * buf, size_t
190 count = PAGE_SIZE - 1; 190 count = PAGE_SIZE - 1;
191 error = copy_from_user(buffer->page,buf,count); 191 error = copy_from_user(buffer->page,buf,count);
192 buffer->needs_read_fill = 1; 192 buffer->needs_read_fill = 1;
193 /* if buf is assumed to contain a string, terminate it by \0,
194 so e.g. sscanf() can scan the string easily */
195 buffer->page[count] = 0;
193 return error ? -EFAULT : count; 196 return error ? -EFAULT : count;
194} 197}
195 198
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index f338e40bd544..fdd10953b2b6 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -357,7 +357,7 @@ struct device *acpi_get_physical_device(acpi_handle);
357/* helper */ 357/* helper */
358acpi_handle acpi_get_child(acpi_handle, acpi_integer); 358acpi_handle acpi_get_child(acpi_handle, acpi_integer);
359acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); 359acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
360#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->firmware_data)) 360#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
361 361
362#endif /* CONFIG_ACPI */ 362#endif /* CONFIG_ACPI */
363 363
diff --git a/include/asm-alpha/checksum.h b/include/asm-alpha/checksum.h
index a5c9f08447fb..d3854bbf0a9e 100644
--- a/include/asm-alpha/checksum.h
+++ b/include/asm-alpha/checksum.h
@@ -7,21 +7,20 @@
7 * This is a version of ip_compute_csum() optimized for IP headers, 7 * This is a version of ip_compute_csum() optimized for IP headers,
8 * which always checksum on 4 octet boundaries. 8 * which always checksum on 4 octet boundaries.
9 */ 9 */
10extern unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl); 10extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
11 11
12/* 12/*
13 * computes the checksum of the TCP/UDP pseudo-header 13 * computes the checksum of the TCP/UDP pseudo-header
14 * returns a 16-bit checksum, already complemented 14 * returns a 16-bit checksum, already complemented
15 */ 15 */
16extern unsigned short int csum_tcpudp_magic(unsigned long saddr, 16extern __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
17 unsigned long daddr,
18 unsigned short len, 17 unsigned short len,
19 unsigned short proto, 18 unsigned short proto,
20 unsigned int sum); 19 __wsum sum);
21 20
22unsigned int csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, 21__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
23 unsigned short len, unsigned short proto, 22 unsigned short len, unsigned short proto,
24 unsigned int sum); 23 __wsum sum);
25 24
26/* 25/*
27 * computes the checksum of a memory block at buff, length len, 26 * computes the checksum of a memory block at buff, length len,
@@ -35,7 +34,7 @@ unsigned int csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
35 * 34 *
36 * it's best to have buff aligned on a 32-bit boundary 35 * it's best to have buff aligned on a 32-bit boundary
37 */ 36 */
38extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 37extern __wsum csum_partial(const void *buff, int len, __wsum sum);
39 38
40/* 39/*
41 * the same as csum_partial, but copies from src while it 40 * the same as csum_partial, but copies from src while it
@@ -44,9 +43,9 @@ extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned i
44 * here even more important to align src and dst on a 32-bit (or even 43 * here even more important to align src and dst on a 32-bit (or even
45 * better 64-bit) boundary 44 * better 64-bit) boundary
46 */ 45 */
47unsigned int csum_partial_copy_from_user(const char __user *src, char *dst, int len, unsigned int sum, int *errp); 46__wsum csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *errp);
48 47
49unsigned int csum_partial_copy_nocheck(const char *src, char *dst, int len, unsigned int sum); 48__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
50 49
51 50
52/* 51/*
@@ -54,24 +53,23 @@ unsigned int csum_partial_copy_nocheck(const char *src, char *dst, int len, unsi
54 * in icmp.c 53 * in icmp.c
55 */ 54 */
56 55
57extern unsigned short ip_compute_csum(unsigned char * buff, int len); 56extern __sum16 ip_compute_csum(const void *buff, int len);
58 57
59/* 58/*
60 * Fold a partial checksum without adding pseudo headers 59 * Fold a partial checksum without adding pseudo headers
61 */ 60 */
62 61
63static inline unsigned short csum_fold(unsigned int sum) 62static inline __sum16 csum_fold(__wsum csum)
64{ 63{
64 u32 sum = (__force u32)csum;
65 sum = (sum & 0xffff) + (sum >> 16); 65 sum = (sum & 0xffff) + (sum >> 16);
66 sum = (sum & 0xffff) + (sum >> 16); 66 sum = (sum & 0xffff) + (sum >> 16);
67 return ~sum; 67 return (__force __sum16)~sum;
68} 68}
69 69
70#define _HAVE_ARCH_IPV6_CSUM 70#define _HAVE_ARCH_IPV6_CSUM
71extern unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 71extern __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
72 struct in6_addr *daddr, 72 const struct in6_addr *daddr,
73 __u32 len, 73 __u32 len, unsigned short proto,
74 unsigned short proto, 74 __wsum sum);
75 unsigned int sum);
76
77#endif 75#endif
diff --git a/include/asm-alpha/device.h b/include/asm-alpha/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-alpha/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-arm/arch-ebsa110/io.h b/include/asm-arm/arch-ebsa110/io.h
index ae048441c9ed..722c5e086285 100644
--- a/include/asm-arm/arch-ebsa110/io.h
+++ b/include/asm-arm/arch-ebsa110/io.h
@@ -27,9 +27,9 @@ void __outw(u16 val, unsigned int port);
27u32 __inl(unsigned int port); 27u32 __inl(unsigned int port);
28void __outl(u32 val, unsigned int port); 28void __outl(u32 val, unsigned int port);
29 29
30u8 __readb(void __iomem *addr); 30u8 __readb(const volatile void __iomem *addr);
31u16 __readw(void __iomem *addr); 31u16 __readw(const volatile void __iomem *addr);
32u32 __readl(void __iomem *addr); 32u32 __readl(const volatile void __iomem *addr);
33 33
34void __writeb(u8 val, void __iomem *addr); 34void __writeb(u8 val, void __iomem *addr);
35void __writew(u16 val, void __iomem *addr); 35void __writew(u16 val, void __iomem *addr);
@@ -64,8 +64,14 @@ void __writel(u32 val, void __iomem *addr);
64#define writew(v,b) __writew(v,b) 64#define writew(v,b) __writew(v,b)
65#define writel(v,b) __writel(v,b) 65#define writel(v,b) __writel(v,b)
66 66
67#define __arch_ioremap(cookie,sz,c) ((void __iomem *)(cookie)) 67static inline void __iomem *__arch_ioremap(unsigned long cookie, size_t size,
68#define __arch_iounmap(cookie) do { } while (0) 68 unsigned int flags)
69{
70 return (void __iomem *)cookie;
71}
72
73#define __arch_ioremap __arch_ioremap
74#define __arch_iounmap(cookie) do { } while (0)
69 75
70extern void insb(unsigned int port, void *buf, int sz); 76extern void insb(unsigned int port, void *buf, int sz);
71extern void insw(unsigned int port, void *buf, int sz); 77extern void insw(unsigned int port, void *buf, int sz);
diff --git a/include/asm-arm/arch-pxa/udc.h b/include/asm-arm/arch-pxa/udc.h
index 121cd241115d..646480d37256 100644
--- a/include/asm-arm/arch-pxa/udc.h
+++ b/include/asm-arm/arch-pxa/udc.h
@@ -4,23 +4,8 @@
4 * This supports machine-specific differences in how the PXA2xx 4 * This supports machine-specific differences in how the PXA2xx
5 * USB Device Controller (UDC) is wired. 5 * USB Device Controller (UDC) is wired.
6 * 6 *
7 * It is set in linux/arch/arm/mach-pxa/<machine>.c and used in
8 * the probe routine of linux/drivers/usb/gadget/pxa2xx_udc.c
9 */ 7 */
10struct pxa2xx_udc_mach_info { 8#include <asm/mach/udc_pxa2xx.h>
11 int (*udc_is_connected)(void); /* do we see host? */
12 void (*udc_command)(int cmd);
13#define PXA2XX_UDC_CMD_CONNECT 0 /* let host see us */
14#define PXA2XX_UDC_CMD_DISCONNECT 1 /* so host won't see us */
15
16 /* Boards following the design guidelines in the developer's manual,
17 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane
18 * VBUS IRQ and omit the methods above. Store the GPIO number
19 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits.
20 */
21 u16 gpio_vbus; /* high == vbus present */
22 u16 gpio_pullup; /* high == pullup activated */
23};
24 9
25extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info); 10extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info);
26 11
diff --git a/include/asm-arm/checksum.h b/include/asm-arm/checksum.h
index 747bdd31a74b..8c0bb5bb14ee 100644
--- a/include/asm-arm/checksum.h
+++ b/include/asm-arm/checksum.h
@@ -23,7 +23,7 @@
23 * 23 *
24 * it's best to have buff aligned on a 32-bit boundary 24 * it's best to have buff aligned on a 32-bit boundary
25 */ 25 */
26unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 26__wsum csum_partial(const void *buff, int len, __wsum sum);
27 27
28/* 28/*
29 * the same as csum_partial, but copies from src while it 29 * the same as csum_partial, but copies from src while it
@@ -33,26 +33,18 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
33 * better 64-bit) boundary 33 * better 64-bit) boundary
34 */ 34 */
35 35
36unsigned int 36__wsum
37csum_partial_copy_nocheck(const char *src, char *dst, int len, int sum); 37csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
38 38
39unsigned int 39__wsum
40csum_partial_copy_from_user(const char __user *src, char *dst, int len, int sum, int *err_ptr); 40csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
41
42/*
43 * This is the old (and unsafe) way of doing checksums, a warning message will
44 * be printed if it is used and an exception occurs.
45 *
46 * this functions should go away after some time.
47 */
48#define csum_partial_copy(src,dst,len,sum) csum_partial_copy_nocheck(src,dst,len,sum)
49 41
50/* 42/*
51 * This is a version of ip_compute_csum() optimized for IP headers, 43 * This is a version of ip_compute_csum() optimized for IP headers,
52 * which always checksum on 4 octet boundaries. 44 * which always checksum on 4 octet boundaries.
53 */ 45 */
54static inline unsigned short 46static inline __sum16
55ip_fast_csum(unsigned char * iph, unsigned int ihl) 47ip_fast_csum(const void *iph, unsigned int ihl)
56{ 48{
57 unsigned int sum, tmp1; 49 unsigned int sum, tmp1;
58 50
@@ -78,14 +70,13 @@ ip_fast_csum(unsigned char * iph, unsigned int ihl)
78 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1) 70 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1)
79 : "1" (iph), "2" (ihl) 71 : "1" (iph), "2" (ihl)
80 : "cc", "memory"); 72 : "cc", "memory");
81 return sum; 73 return (__force __sum16)sum;
82} 74}
83 75
84/* 76/*
85 * Fold a partial checksum without adding pseudo headers 77 * Fold a partial checksum without adding pseudo headers
86 */ 78 */
87static inline unsigned int 79static inline __sum16 csum_fold(__wsum sum)
88csum_fold(unsigned int sum)
89{ 80{
90 __asm__( 81 __asm__(
91 "adds %0, %1, %1, lsl #16 @ csum_fold \n\ 82 "adds %0, %1, %1, lsl #16 @ csum_fold \n\
@@ -93,21 +84,25 @@ csum_fold(unsigned int sum)
93 : "=r" (sum) 84 : "=r" (sum)
94 : "r" (sum) 85 : "r" (sum)
95 : "cc"); 86 : "cc");
96 return (~sum) >> 16; 87 return (__force __sum16)(~(__force u32)sum >> 16);
97} 88}
98 89
99static inline unsigned int 90static inline __wsum
100csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 91csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
101 unsigned int proto, unsigned int sum) 92 unsigned short proto, __wsum sum)
102{ 93{
103 __asm__( 94 __asm__(
104 "adds %0, %1, %2 @ csum_tcpudp_nofold \n\ 95 "adds %0, %1, %2 @ csum_tcpudp_nofold \n\
105 adcs %0, %0, %3 \n\ 96 adcs %0, %0, %3 \n"
106 adcs %0, %0, %4 \n\ 97#ifdef __ARMEB__
107 adcs %0, %0, %5 \n\ 98 "adcs %0, %0, %4 \n"
99#else
100 "adcs %0, %0, %4, lsl #8 \n"
101#endif
102 "adcs %0, %0, %5 \n\
108 adc %0, %0, #0" 103 adc %0, %0, #0"
109 : "=&r"(sum) 104 : "=&r"(sum)
110 : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto)) 105 : "r" (sum), "r" (daddr), "r" (saddr), "r" (len), "Ir" (htons(proto))
111 : "cc"); 106 : "cc");
112 return sum; 107 return sum;
113} 108}
@@ -115,23 +110,27 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
115 * computes the checksum of the TCP/UDP pseudo-header 110 * computes the checksum of the TCP/UDP pseudo-header
116 * returns a 16-bit checksum, already complemented 111 * returns a 16-bit checksum, already complemented
117 */ 112 */
118static inline unsigned short int 113static inline __sum16
119csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, 114csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
120 unsigned int proto, unsigned int sum) 115 unsigned short proto, __wsum sum)
121{ 116{
122 __asm__( 117 __asm__(
123 "adds %0, %1, %2 @ csum_tcpudp_magic \n\ 118 "adds %0, %1, %2 @ csum_tcpudp_magic \n\
124 adcs %0, %0, %3 \n\ 119 adcs %0, %0, %3 \n"
125 adcs %0, %0, %4 \n\ 120#ifdef __ARMEB__
126 adcs %0, %0, %5 \n\ 121 "adcs %0, %0, %4 \n"
122#else
123 "adcs %0, %0, %4, lsl #8 \n"
124#endif
125 "adcs %0, %0, %5 \n\
127 adc %0, %0, #0 \n\ 126 adc %0, %0, #0 \n\
128 adds %0, %0, %0, lsl #16 \n\ 127 adds %0, %0, %0, lsl #16 \n\
129 addcs %0, %0, #0x10000 \n\ 128 addcs %0, %0, #0x10000 \n\
130 mvn %0, %0" 129 mvn %0, %0"
131 : "=&r"(sum) 130 : "=&r"(sum)
132 : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto)) 131 : "r" (sum), "r" (daddr), "r" (saddr), "r" (len), "Ir" (htons(proto))
133 : "cc"); 132 : "cc");
134 return sum >> 16; 133 return (__force __sum16)((__force u32)sum >> 16);
135} 134}
136 135
137 136
@@ -139,20 +138,20 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
139 * this routine is used for miscellaneous IP-like checksums, mainly 138 * this routine is used for miscellaneous IP-like checksums, mainly
140 * in icmp.c 139 * in icmp.c
141 */ 140 */
142static inline unsigned short 141static inline __sum16
143ip_compute_csum(unsigned char * buff, int len) 142ip_compute_csum(const void *buff, int len)
144{ 143{
145 return csum_fold(csum_partial(buff, len, 0)); 144 return csum_fold(csum_partial(buff, len, 0));
146} 145}
147 146
148#define _HAVE_ARCH_IPV6_CSUM 147#define _HAVE_ARCH_IPV6_CSUM
149extern unsigned long 148extern __wsum
150__csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, __u32 len, 149__csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __be32 len,
151 __u32 proto, unsigned int sum); 150 __be32 proto, __wsum sum);
152 151
153static inline unsigned short int 152static inline __sum16
154csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, __u32 len, 153csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __u32 len,
155 unsigned short proto, unsigned int sum) 154 unsigned short proto, __wsum sum)
156{ 155{
157 return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len), 156 return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len),
158 htonl(proto), sum)); 157 htonl(proto), sum));
diff --git a/include/asm-arm/device.h b/include/asm-arm/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-arm/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
index 55eb4dc3253d..666617711c81 100644
--- a/include/asm-arm/dma-mapping.h
+++ b/include/asm-arm/dma-mapping.h
@@ -12,6 +12,10 @@
12 * uncached, unwrite-buffered mapped memory space for use with DMA 12 * uncached, unwrite-buffered mapped memory space for use with DMA
13 * devices. This is the "generic" version. The PCI specific version 13 * devices. This is the "generic" version. The PCI specific version
14 * is in pci.h 14 * is in pci.h
15 *
16 * Note: Drivers should NOT use this function directly, as it will break
17 * platforms with CONFIG_DMABOUNCE.
18 * Use the driver DMA support - see dma-mapping.h (dma_sync_*)
15 */ 19 */
16extern void consistent_sync(void *kaddr, size_t size, int rw); 20extern void consistent_sync(void *kaddr, size_t size, int rw);
17 21
diff --git a/include/asm-arm/mach/udc_pxa2xx.h b/include/asm-arm/mach/udc_pxa2xx.h
new file mode 100644
index 000000000000..ff0a95715a07
--- /dev/null
+++ b/include/asm-arm/mach/udc_pxa2xx.h
@@ -0,0 +1,26 @@
1/*
2 * linux/include/asm-arm/mach/udc_pxa2xx.h
3 *
4 * This supports machine-specific differences in how the PXA2xx
5 * USB Device Controller (UDC) is wired.
6 *
7 * It is set in linux/arch/arm/mach-pxa/<machine>.c or in
8 * linux/arch/mach-ixp4xx/<machine>.c and used in
9 * the probe routine of linux/drivers/usb/gadget/pxa2xx_udc.c
10 */
11
12struct pxa2xx_udc_mach_info {
13 int (*udc_is_connected)(void); /* do we see host? */
14 void (*udc_command)(int cmd);
15#define PXA2XX_UDC_CMD_CONNECT 0 /* let host see us */
16#define PXA2XX_UDC_CMD_DISCONNECT 1 /* so host won't see us */
17
18 /* Boards following the design guidelines in the developer's manual,
19 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane
20 * VBUS IRQ and omit the methods above. Store the GPIO number
21 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits.
22 */
23 u16 gpio_vbus; /* high == vbus present */
24 u16 gpio_pullup; /* high == pullup activated */
25};
26
diff --git a/include/asm-arm26/checksum.h b/include/asm-arm26/checksum.h
index d4256d5f3a7c..f2b4b0a403bd 100644
--- a/include/asm-arm26/checksum.h
+++ b/include/asm-arm26/checksum.h
@@ -23,7 +23,7 @@
23 * 23 *
24 * it's best to have buff aligned on a 32-bit boundary 24 * it's best to have buff aligned on a 32-bit boundary
25 */ 25 */
26unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 26__wsum csum_partial(const void *buff, int len, __wsum sum);
27 27
28/* 28/*
29 * the same as csum_partial, but copies from src while it 29 * the same as csum_partial, but copies from src while it
@@ -33,26 +33,18 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
33 * better 64-bit) boundary 33 * better 64-bit) boundary
34 */ 34 */
35 35
36unsigned int 36__wsum
37csum_partial_copy_nocheck(const char *src, char *dst, int len, int sum); 37csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
38 38
39unsigned int 39__wsum
40csum_partial_copy_from_user(const char __user *src, char *dst, int len, int sum, int *err_ptr); 40csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
41
42/*
43 * This is the old (and unsafe) way of doing checksums, a warning message will
44 * be printed if it is used and an exception occurs.
45 *
46 * this functions should go away after some time.
47 */
48#define csum_partial_copy(src,dst,len,sum) csum_partial_copy_nocheck(src,dst,len,sum)
49 41
50/* 42/*
51 * This is a version of ip_compute_csum() optimized for IP headers, 43 * This is a version of ip_compute_csum() optimized for IP headers,
52 * which always checksum on 4 octet boundaries. 44 * which always checksum on 4 octet boundaries.
53 */ 45 */
54static inline unsigned short 46static inline __sum16
55ip_fast_csum(unsigned char * iph, unsigned int ihl) 47ip_fast_csum(const void *iph, unsigned int ihl)
56{ 48{
57 unsigned int sum, tmp1; 49 unsigned int sum, tmp1;
58 50
@@ -78,14 +70,13 @@ ip_fast_csum(unsigned char * iph, unsigned int ihl)
78 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1) 70 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1)
79 : "1" (iph), "2" (ihl) 71 : "1" (iph), "2" (ihl)
80 : "cc"); 72 : "cc");
81 return sum; 73 return (__force __sum16)sum;
82} 74}
83 75
84/* 76/*
85 * Fold a partial checksum without adding pseudo headers 77 * Fold a partial checksum without adding pseudo headers
86 */ 78 */
87static inline unsigned int 79static inline __sum16 csum_fold(__wsum sum)
88csum_fold(unsigned int sum)
89{ 80{
90 __asm__( 81 __asm__(
91 "adds %0, %1, %1, lsl #16 @ csum_fold \n\ 82 "adds %0, %1, %1, lsl #16 @ csum_fold \n\
@@ -93,12 +84,12 @@ csum_fold(unsigned int sum)
93 : "=r" (sum) 84 : "=r" (sum)
94 : "r" (sum) 85 : "r" (sum)
95 : "cc"); 86 : "cc");
96 return (~sum) >> 16; 87 return (__force __sum16)(~(__force u32)sum >> 16);
97} 88}
98 89
99static inline unsigned int 90static inline __wsum
100csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 91csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
101 unsigned int proto, unsigned int sum) 92 unsigned short proto, __wsum sum)
102{ 93{
103 __asm__( 94 __asm__(
104 "adds %0, %1, %2 @ csum_tcpudp_nofold \n\ 95 "adds %0, %1, %2 @ csum_tcpudp_nofold \n\
@@ -107,7 +98,7 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
107 adcs %0, %0, %5 \n\ 98 adcs %0, %0, %5 \n\
108 adc %0, %0, #0" 99 adc %0, %0, #0"
109 : "=&r"(sum) 100 : "=&r"(sum)
110 : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto)) 101 : "r" (sum), "r" (daddr), "r" (saddr), "r" (htons(len)), "Ir" (htons(proto))
111 : "cc"); 102 : "cc");
112 return sum; 103 return sum;
113} 104}
@@ -115,9 +106,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
115 * computes the checksum of the TCP/UDP pseudo-header 106 * computes the checksum of the TCP/UDP pseudo-header
116 * returns a 16-bit checksum, already complemented 107 * returns a 16-bit checksum, already complemented
117 */ 108 */
118static inline unsigned short int 109static inline __sum16
119csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, 110csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
120 unsigned int proto, unsigned int sum) 111 unsigned short proto, __wsum sum)
121{ 112{
122 __asm__( 113 __asm__(
123 "adds %0, %1, %2 @ csum_tcpudp_magic \n\ 114 "adds %0, %1, %2 @ csum_tcpudp_magic \n\
@@ -129,9 +120,9 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
129 addcs %0, %0, #0x10000 \n\ 120 addcs %0, %0, #0x10000 \n\
130 mvn %0, %0" 121 mvn %0, %0"
131 : "=&r"(sum) 122 : "=&r"(sum)
132 : "r" (sum), "r" (daddr), "r" (saddr), "r" (ntohs(len)), "Ir" (ntohs(proto)) 123 : "r" (sum), "r" (daddr), "r" (saddr), "r" (htons(len)), "Ir" (htons(proto))
133 : "cc"); 124 : "cc");
134 return sum >> 16; 125 return (__force __sum16)((__force u32)sum >> 16);
135} 126}
136 127
137 128
@@ -139,20 +130,20 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
139 * this routine is used for miscellaneous IP-like checksums, mainly 130 * this routine is used for miscellaneous IP-like checksums, mainly
140 * in icmp.c 131 * in icmp.c
141 */ 132 */
142static inline unsigned short 133static inline __sum16
143ip_compute_csum(unsigned char * buff, int len) 134ip_compute_csum(const void *buff, int len)
144{ 135{
145 return csum_fold(csum_partial(buff, len, 0)); 136 return csum_fold(csum_partial(buff, len, 0));
146} 137}
147 138
148#define _HAVE_ARCH_IPV6_CSUM 139#define _HAVE_ARCH_IPV6_CSUM
149extern unsigned long 140extern __wsum
150__csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, __u32 len, 141__csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __be32 len,
151 __u32 proto, unsigned int sum); 142 __be32 proto, __wsum sum);
152 143
153static inline unsigned short int 144static inline __sum16
154csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, __u32 len, 145csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __u32 len,
155 unsigned short proto, unsigned int sum) 146 unsigned short proto, __wsum sum)
156{ 147{
157 return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len), 148 return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len),
158 htonl(proto), sum)); 149 htonl(proto), sum));
diff --git a/include/asm-arm26/device.h b/include/asm-arm26/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-arm26/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-avr32/checksum.h b/include/asm-avr32/checksum.h
index 41b7af09edc4..af9d53f0f5d2 100644
--- a/include/asm-avr32/checksum.h
+++ b/include/asm-avr32/checksum.h
@@ -20,8 +20,7 @@
20 * 20 *
21 * it's best to have buff aligned on a 32-bit boundary 21 * it's best to have buff aligned on a 32-bit boundary
22 */ 22 */
23unsigned int csum_partial(const unsigned char * buff, int len, 23__wsum csum_partial(const void *buff, int len, __wsum sum);
24 unsigned int sum);
25 24
26/* 25/*
27 * the same as csum_partial, but copies from src while it 26 * the same as csum_partial, but copies from src while it
@@ -30,8 +29,8 @@ unsigned int csum_partial(const unsigned char * buff, int len,
30 * here even more important to align src and dst on a 32-bit (or even 29 * here even more important to align src and dst on a 32-bit (or even
31 * better 64-bit) boundary 30 * better 64-bit) boundary
32 */ 31 */
33unsigned int csum_partial_copy_generic(const char *src, char *dst, int len, 32__wsum csum_partial_copy_generic(const void *src, void *dst, int len,
34 int sum, int *src_err_ptr, 33 __wsum sum, int *src_err_ptr,
35 int *dst_err_ptr); 34 int *dst_err_ptr);
36 35
37/* 36/*
@@ -42,17 +41,17 @@ unsigned int csum_partial_copy_generic(const char *src, char *dst, int len,
42 * verify_area(). 41 * verify_area().
43 */ 42 */
44static inline 43static inline
45unsigned int csum_partial_copy_nocheck(const char *src, char *dst, 44__wsum csum_partial_copy_nocheck(const void *src, void *dst,
46 int len, int sum) 45 int len, __wsum sum)
47{ 46{
48 return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL); 47 return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL);
49} 48}
50 49
51static inline 50static inline
52unsigned int csum_partial_copy_from_user (const char __user *src, char *dst, 51__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
53 int len, int sum, int *err_ptr) 52 int len, __wsum sum, int *err_ptr)
54{ 53{
55 return csum_partial_copy_generic((const char __force *)src, dst, len, 54 return csum_partial_copy_generic((const void __force *)src, dst, len,
56 sum, err_ptr, NULL); 55 sum, err_ptr, NULL);
57} 56}
58 57
@@ -60,8 +59,7 @@ unsigned int csum_partial_copy_from_user (const char __user *src, char *dst,
60 * This is a version of ip_compute_csum() optimized for IP headers, 59 * This is a version of ip_compute_csum() optimized for IP headers,
61 * which always checksum on 4 octet boundaries. 60 * which always checksum on 4 octet boundaries.
62 */ 61 */
63static inline unsigned short ip_fast_csum(unsigned char *iph, 62static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
64 unsigned int ihl)
65{ 63{
66 unsigned int sum, tmp; 64 unsigned int sum, tmp;
67 65
@@ -90,14 +88,14 @@ static inline unsigned short ip_fast_csum(unsigned char *iph,
90 : "=r"(sum), "=r"(iph), "=r"(ihl), "=r"(tmp) 88 : "=r"(sum), "=r"(iph), "=r"(ihl), "=r"(tmp)
91 : "1"(iph), "2"(ihl) 89 : "1"(iph), "2"(ihl)
92 : "memory", "cc"); 90 : "memory", "cc");
93 return sum; 91 return (__force __sum16)sum;
94} 92}
95 93
96/* 94/*
97 * Fold a partial checksum 95 * Fold a partial checksum
98 */ 96 */
99 97
100static inline unsigned int csum_fold(unsigned int sum) 98static inline __sum16 csum_fold(__wsum sum)
101{ 99{
102 unsigned int tmp; 100 unsigned int tmp;
103 101
@@ -109,21 +107,20 @@ static inline unsigned int csum_fold(unsigned int sum)
109 : "=&r"(sum), "=&r"(tmp) 107 : "=&r"(sum), "=&r"(tmp)
110 : "0"(sum)); 108 : "0"(sum));
111 109
112 return ~sum; 110 return (__force __sum16)~sum;
113} 111}
114 112
115static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, 113static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
116 unsigned long daddr,
117 unsigned short len, 114 unsigned short len,
118 unsigned short proto, 115 unsigned short proto,
119 unsigned int sum) 116 __wsum sum)
120{ 117{
121 asm(" add %0, %1\n" 118 asm(" add %0, %1\n"
122 " adc %0, %0, %2\n" 119 " adc %0, %0, %2\n"
123 " adc %0, %0, %3\n" 120 " adc %0, %0, %3\n"
124 " acr %0" 121 " acr %0"
125 : "=r"(sum) 122 : "=r"(sum)
126 : "r"(daddr), "r"(saddr), "r"(ntohs(len) | (proto << 16)), 123 : "r"(daddr), "r"(saddr), "r"(len + proto),
127 "0"(sum) 124 "0"(sum)
128 : "cc"); 125 : "cc");
129 126
@@ -134,11 +131,10 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
134 * computes the checksum of the TCP/UDP pseudo-header 131 * computes the checksum of the TCP/UDP pseudo-header
135 * returns a 16-bit checksum, already complemented 132 * returns a 16-bit checksum, already complemented
136 */ 133 */
137static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 134static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
138 unsigned long daddr,
139 unsigned short len, 135 unsigned short len,
140 unsigned short proto, 136 unsigned short proto,
141 unsigned int sum) 137 __wsum sum)
142{ 138{
143 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 139 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
144} 140}
@@ -148,7 +144,7 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
148 * in icmp.c 144 * in icmp.c
149 */ 145 */
150 146
151static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 147static inline __sum16 ip_compute_csum(const void *buff, int len)
152{ 148{
153 return csum_fold(csum_partial(buff, len, 0)); 149 return csum_fold(csum_partial(buff, len, 0));
154} 150}
diff --git a/include/asm-avr32/device.h b/include/asm-avr32/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-avr32/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-cris/arch-v10/checksum.h b/include/asm-cris/arch-v10/checksum.h
index 633f234f336b..b8000c5d7fe1 100644
--- a/include/asm-cris/arch-v10/checksum.h
+++ b/include/asm-cris/arch-v10/checksum.h
@@ -8,11 +8,11 @@
8 * to split all of those into 16-bit components, then add. 8 * to split all of those into 16-bit components, then add.
9 */ 9 */
10 10
11static inline unsigned int 11static inline __wsum
12csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 12csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
13 unsigned short proto, unsigned int sum) 13 unsigned short proto, __wsum sum)
14{ 14{
15 int res; 15 __wsum res;
16 __asm__ ("add.d %2, %0\n\t" 16 __asm__ ("add.d %2, %0\n\t"
17 "ax\n\t" 17 "ax\n\t"
18 "add.d %3, %0\n\t" 18 "add.d %3, %0\n\t"
@@ -21,7 +21,7 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
21 "ax\n\t" 21 "ax\n\t"
22 "addq 0, %0\n" 22 "addq 0, %0\n"
23 : "=r" (res) 23 : "=r" (res)
24 : "0" (sum), "r" (daddr), "r" (saddr), "r" ((ntohs(len) << 16) + (proto << 8))); 24 : "0" (sum), "r" (daddr), "r" (saddr), "r" ((len + proto) << 8));
25 25
26 return res; 26 return res;
27} 27}
diff --git a/include/asm-cris/arch-v32/checksum.h b/include/asm-cris/arch-v32/checksum.h
index 97ef89efea62..e5dcfce6e0dc 100644
--- a/include/asm-cris/arch-v32/checksum.h
+++ b/include/asm-cris/arch-v32/checksum.h
@@ -9,11 +9,11 @@
9 * checksum. Which means it would be necessary to split all those into 9 * checksum. Which means it would be necessary to split all those into
10 * 16-bit components and then add. 10 * 16-bit components and then add.
11 */ 11 */
12static inline unsigned int 12static inline __wsum
13csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, 13csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
14 unsigned short len, unsigned short proto, unsigned int sum) 14 unsigned short len, unsigned short proto, __wsum sum)
15{ 15{
16 int res; 16 __wsum res;
17 17
18 __asm__ __volatile__ ("add.d %2, %0\n\t" 18 __asm__ __volatile__ ("add.d %2, %0\n\t"
19 "addc %3, %0\n\t" 19 "addc %3, %0\n\t"
@@ -21,7 +21,7 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
21 "addc 0, %0\n\t" 21 "addc 0, %0\n\t"
22 : "=r" (res) 22 : "=r" (res)
23 : "0" (sum), "r" (daddr), "r" (saddr), \ 23 : "0" (sum), "r" (daddr), "r" (saddr), \
24 "r" ((ntohs(len) << 16) + (proto << 8))); 24 "r" ((len + proto) << 8));
25 25
26 return res; 26 return res;
27} 27}
diff --git a/include/asm-cris/checksum.h b/include/asm-cris/checksum.h
index 26a7719bbb84..180dbf2757b0 100644
--- a/include/asm-cris/checksum.h
+++ b/include/asm-cris/checksum.h
@@ -17,7 +17,7 @@
17 * 17 *
18 * it's best to have buff aligned on a 32-bit boundary 18 * it's best to have buff aligned on a 32-bit boundary
19 */ 19 */
20unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 20__wsum csum_partial(const void *buff, int len, __wsum sum);
21 21
22/* 22/*
23 * the same as csum_partial, but copies from src while it 23 * the same as csum_partial, but copies from src while it
@@ -27,26 +27,23 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
27 * better 64-bit) boundary 27 * better 64-bit) boundary
28 */ 28 */
29 29
30unsigned int csum_partial_copy_nocheck(const char *src, char *dst, 30__wsum csum_partial_copy_nocheck(const void *src, void *dst,
31 int len, unsigned int sum); 31 int len, __wsum sum);
32 32
33/* 33/*
34 * Fold a partial checksum into a word 34 * Fold a partial checksum into a word
35 */ 35 */
36 36
37static inline unsigned int csum_fold(unsigned int sum) 37static inline __sum16 csum_fold(__wsum csum)
38{ 38{
39 /* the while loop is unnecessary really, it's always enough with two 39 u32 sum = (__force u32)csum;
40 iterations */ 40 sum = (sum & 0xffff) + (sum >> 16); /* add in end-around carry */
41 41 sum = (sum & 0xffff) + (sum >> 16); /* add in end-around carry */
42 while(sum >> 16) 42 return (__force __sum16)~sum;
43 sum = (sum & 0xffff) + (sum >> 16); /* add in end-around carry */
44
45 return ~sum;
46} 43}
47 44
48extern unsigned int csum_partial_copy_from_user(const char *src, char *dst, 45extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
49 int len, unsigned int sum, 46 int len, __wsum sum,
50 int *errptr); 47 int *errptr);
51 48
52/* 49/*
@@ -55,8 +52,7 @@ extern unsigned int csum_partial_copy_from_user(const char *src, char *dst,
55 * 52 *
56 */ 53 */
57 54
58static inline unsigned short ip_fast_csum(unsigned char * iph, 55static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
59 unsigned int ihl)
60{ 56{
61 return csum_fold(csum_partial(iph, ihl * 4, 0)); 57 return csum_fold(csum_partial(iph, ihl * 4, 0));
62} 58}
@@ -66,11 +62,10 @@ static inline unsigned short ip_fast_csum(unsigned char * iph,
66 * returns a 16-bit checksum, already complemented 62 * returns a 16-bit checksum, already complemented
67 */ 63 */
68 64
69static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 65static inline __sum16 int csum_tcpudp_magic(__be32 saddr, __be32 daddr,
70 unsigned long daddr,
71 unsigned short len, 66 unsigned short len,
72 unsigned short proto, 67 unsigned short proto,
73 unsigned int sum) 68 __wsum sum)
74{ 69{
75 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 70 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
76} 71}
@@ -80,7 +75,8 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
80 * in icmp.c 75 * in icmp.c
81 */ 76 */
82 77
83static inline unsigned short ip_compute_csum(unsigned char * buff, int len) { 78static inline __sum16 ip_compute_csum(const void *buff, int len)
79{
84 return csum_fold (csum_partial(buff, len, 0)); 80 return csum_fold (csum_partial(buff, len, 0));
85} 81}
86 82
diff --git a/include/asm-cris/device.h b/include/asm-cris/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-cris/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-frv/checksum.h b/include/asm-frv/checksum.h
index 42bf0db2287a..9b1689850187 100644
--- a/include/asm-frv/checksum.h
+++ b/include/asm-frv/checksum.h
@@ -26,7 +26,7 @@
26 * 26 *
27 * it's best to have buff aligned on a 32-bit boundary 27 * it's best to have buff aligned on a 32-bit boundary
28 */ 28 */
29unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 29__wsum csum_partial(const void *buff, int len, __wsum sum);
30 30
31/* 31/*
32 * the same as csum_partial, but copies from src while it 32 * the same as csum_partial, but copies from src while it
@@ -35,7 +35,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
35 * here even more important to align src and dst on a 32-bit (or even 35 * here even more important to align src and dst on a 32-bit (or even
36 * better 64-bit) boundary 36 * better 64-bit) boundary
37 */ 37 */
38unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum); 38__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
39 39
40/* 40/*
41 * the same as csum_partial_copy, but copies from user space. 41 * the same as csum_partial_copy, but copies from user space.
@@ -43,11 +43,8 @@ unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
43 * here even more important to align src and dst on a 32-bit (or even 43 * here even more important to align src and dst on a 32-bit (or even
44 * better 64-bit) boundary 44 * better 64-bit) boundary
45 */ 45 */
46extern unsigned int csum_partial_copy_from_user(const char __user *src, char *dst, 46extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
47 int len, int sum, int *csum_err); 47 int len, __wsum sum, int *csum_err);
48
49#define csum_partial_copy_nocheck(src, dst, len, sum) \
50 csum_partial_copy((src), (dst), (len), (sum))
51 48
52/* 49/*
53 * This is a version of ip_compute_csum() optimized for IP headers, 50 * This is a version of ip_compute_csum() optimized for IP headers,
@@ -55,7 +52,7 @@ extern unsigned int csum_partial_copy_from_user(const char __user *src, char *ds
55 * 52 *
56 */ 53 */
57static inline 54static inline
58unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) 55__sum16 ip_fast_csum(const void *iph, unsigned int ihl)
59{ 56{
60 unsigned int tmp, inc, sum = 0; 57 unsigned int tmp, inc, sum = 0;
61 58
@@ -81,13 +78,13 @@ unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
81 : "icc0", "icc1" 78 : "icc0", "icc1"
82 ); 79 );
83 80
84 return ~sum; 81 return (__force __sum16)~sum;
85} 82}
86 83
87/* 84/*
88 * Fold a partial checksum 85 * Fold a partial checksum
89 */ 86 */
90static inline unsigned int csum_fold(unsigned int sum) 87static inline __sum16 csum_fold(__wsum sum)
91{ 88{
92 unsigned int tmp; 89 unsigned int tmp;
93 90
@@ -100,16 +97,16 @@ static inline unsigned int csum_fold(unsigned int sum)
100 : "0"(sum) 97 : "0"(sum)
101 ); 98 );
102 99
103 return ~sum; 100 return (__force __sum16)~sum;
104} 101}
105 102
106/* 103/*
107 * computes the checksum of the TCP/UDP pseudo-header 104 * computes the checksum of the TCP/UDP pseudo-header
108 * returns a 16-bit checksum, already complemented 105 * returns a 16-bit checksum, already complemented
109 */ 106 */
110static inline unsigned int 107static inline __wsum
111csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 108csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
112 unsigned short proto, unsigned int sum) 109 unsigned short proto, __wsum sum)
113{ 110{
114 asm(" addcc %1,%0,%0,icc0 \n" 111 asm(" addcc %1,%0,%0,icc0 \n"
115 " addxcc %2,%0,%0,icc0 \n" 112 " addxcc %2,%0,%0,icc0 \n"
@@ -122,9 +119,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
122 return sum; 119 return sum;
123} 120}
124 121
125static inline unsigned short int 122static inline __sum16
126csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, 123csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
127 unsigned short proto, unsigned int sum) 124 unsigned short proto, __wsum sum)
128{ 125{
129 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 126 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
130} 127}
@@ -133,12 +130,12 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
133 * this routine is used for miscellaneous IP-like checksums, mainly 130 * this routine is used for miscellaneous IP-like checksums, mainly
134 * in icmp.c 131 * in icmp.c
135 */ 132 */
136extern unsigned short ip_compute_csum(const unsigned char * buff, int len); 133extern __sum16 ip_compute_csum(const void *buff, int len);
137 134
138#define _HAVE_ARCH_IPV6_CSUM 135#define _HAVE_ARCH_IPV6_CSUM
139static inline unsigned short int 136static inline __sum16
140csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, 137csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
141 __u32 len, unsigned short proto, unsigned int sum) 138 __u32 len, unsigned short proto, __wsum sum)
142{ 139{
143 unsigned long tmp, tmp2; 140 unsigned long tmp, tmp2;
144 141
@@ -177,7 +174,7 @@ csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr,
177 : "icc0" 174 : "icc0"
178 ); 175 );
179 176
180 return ~sum; 177 return (__force __sum16)~sum;
181} 178}
182 179
183#endif /* _ASM_CHECKSUM_H */ 180#endif /* _ASM_CHECKSUM_H */
diff --git a/include/asm-frv/device.h b/include/asm-frv/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-frv/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-generic/device.h b/include/asm-generic/device.h
new file mode 100644
index 000000000000..c17c9600f220
--- /dev/null
+++ b/include/asm-generic/device.h
@@ -0,0 +1,12 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#ifndef _ASM_GENERIC_DEVICE_H
7#define _ASM_GENERIC_DEVICE_H
8
9struct dev_archdata {
10};
11
12#endif /* _ASM_GENERIC_DEVICE_H */
diff --git a/include/asm-h8300/checksum.h b/include/asm-h8300/checksum.h
index 3051931dd301..98724e12508c 100644
--- a/include/asm-h8300/checksum.h
+++ b/include/asm-h8300/checksum.h
@@ -13,7 +13,7 @@
13 * 13 *
14 * it's best to have buff aligned on a 32-bit boundary 14 * it's best to have buff aligned on a 32-bit boundary
15 */ 15 */
16unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 16__wsum csum_partial(const void *buff, int len, __wsum sum);
17 17
18/* 18/*
19 * the same as csum_partial, but copies from src while it 19 * the same as csum_partial, but copies from src while it
@@ -23,7 +23,7 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
23 * better 64-bit) boundary 23 * better 64-bit) boundary
24 */ 24 */
25 25
26unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum); 26__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
27 27
28 28
29/* 29/*
@@ -33,20 +33,17 @@ unsigned int csum_partial_copy(const char *src, char *dst, int len, int sum);
33 * better 64-bit) boundary 33 * better 64-bit) boundary
34 */ 34 */
35 35
36extern unsigned int csum_partial_copy_from_user(const char *src, char *dst, 36extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
37 int len, int sum, int *csum_err); 37 int len, __wsum sum, int *csum_err);
38 38
39#define csum_partial_copy_nocheck(src, dst, len, sum) \ 39__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
40 csum_partial_copy((src), (dst), (len), (sum))
41
42unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl);
43 40
44 41
45/* 42/*
46 * Fold a partial checksum 43 * Fold a partial checksum
47 */ 44 */
48 45
49static inline unsigned int csum_fold(unsigned int sum) 46static inline __sum16 csum_fold(__wsum sum)
50{ 47{
51 __asm__("mov.l %0,er0\n\t" 48 __asm__("mov.l %0,er0\n\t"
52 "add.w e0,r0\n\t" 49 "add.w e0,r0\n\t"
@@ -58,7 +55,7 @@ static inline unsigned int csum_fold(unsigned int sum)
58 : "=r"(sum) 55 : "=r"(sum)
59 : "0"(sum) 56 : "0"(sum)
60 : "er0"); 57 : "er0");
61 return ~sum; 58 return (__force __sum16)~sum;
62} 59}
63 60
64 61
@@ -67,9 +64,9 @@ static inline unsigned int csum_fold(unsigned int sum)
67 * returns a 16-bit checksum, already complemented 64 * returns a 16-bit checksum, already complemented
68 */ 65 */
69 66
70static inline unsigned int 67static inline __wsum
71csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 68csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
72 unsigned short proto, unsigned int sum) 69 unsigned short proto, __wsum sum)
73{ 70{
74 __asm__ ("sub.l er0,er0\n\t" 71 __asm__ ("sub.l er0,er0\n\t"
75 "add.l %2,%0\n\t" 72 "add.l %2,%0\n\t"
@@ -88,9 +85,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
88 return sum; 85 return sum;
89} 86}
90 87
91static inline unsigned short int 88static inline __sum16
92csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, 89csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
93 unsigned short proto, unsigned int sum) 90 unsigned short proto, __wsum sum)
94{ 91{
95 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 92 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
96} 93}
@@ -100,6 +97,6 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
100 * in icmp.c 97 * in icmp.c
101 */ 98 */
102 99
103extern unsigned short ip_compute_csum(const unsigned char * buff, int len); 100extern __sum16 ip_compute_csum(const void *buff, int len);
104 101
105#endif /* _H8300_CHECKSUM_H */ 102#endif /* _H8300_CHECKSUM_H */
diff --git a/include/asm-h8300/device.h b/include/asm-h8300/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-h8300/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-i386/checksum.h b/include/asm-i386/checksum.h
index 67d3630c4e89..75194abbe8ee 100644
--- a/include/asm-i386/checksum.h
+++ b/include/asm-i386/checksum.h
@@ -17,7 +17,7 @@
17 * 17 *
18 * it's best to have buff aligned on a 32-bit boundary 18 * it's best to have buff aligned on a 32-bit boundary
19 */ 19 */
20asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 20asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
21 21
22/* 22/*
23 * the same as csum_partial, but copies from src while it 23 * the same as csum_partial, but copies from src while it
@@ -27,8 +27,8 @@ asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsign
27 * better 64-bit) boundary 27 * better 64-bit) boundary
28 */ 28 */
29 29
30asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsigned char *dst, 30asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
31 int len, int sum, int *src_err_ptr, int *dst_err_ptr); 31 int len, __wsum sum, int *src_err_ptr, int *dst_err_ptr);
32 32
33/* 33/*
34 * Note: when you get a NULL pointer exception here this means someone 34 * Note: when you get a NULL pointer exception here this means someone
@@ -38,18 +38,18 @@ asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsi
38 * access_ok(). 38 * access_ok().
39 */ 39 */
40static __inline__ 40static __inline__
41unsigned int csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, 41__wsum csum_partial_copy_nocheck (const void *src, void *dst,
42 int len, int sum) 42 int len, __wsum sum)
43{ 43{
44 return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); 44 return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL);
45} 45}
46 46
47static __inline__ 47static __inline__
48unsigned int csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst, 48__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
49 int len, int sum, int *err_ptr) 49 int len, __wsum sum, int *err_ptr)
50{ 50{
51 might_sleep(); 51 might_sleep();
52 return csum_partial_copy_generic((__force unsigned char *)src, dst, 52 return csum_partial_copy_generic((__force void *)src, dst,
53 len, sum, err_ptr, NULL); 53 len, sum, err_ptr, NULL);
54} 54}
55 55
@@ -60,8 +60,7 @@ unsigned int csum_partial_copy_from_user(const unsigned char __user *src, unsign
60 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by 60 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
61 * Arnt Gulbrandsen. 61 * Arnt Gulbrandsen.
62 */ 62 */
63static inline unsigned short ip_fast_csum(unsigned char * iph, 63static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
64 unsigned int ihl)
65{ 64{
66 unsigned int sum; 65 unsigned int sum;
67 66
@@ -89,29 +88,29 @@ static inline unsigned short ip_fast_csum(unsigned char * iph,
89 : "=r" (sum), "=r" (iph), "=r" (ihl) 88 : "=r" (sum), "=r" (iph), "=r" (ihl)
90 : "1" (iph), "2" (ihl) 89 : "1" (iph), "2" (ihl)
91 : "memory"); 90 : "memory");
92 return(sum); 91 return (__force __sum16)sum;
93} 92}
94 93
95/* 94/*
96 * Fold a partial checksum 95 * Fold a partial checksum
97 */ 96 */
98 97
99static inline unsigned int csum_fold(unsigned int sum) 98static inline __sum16 csum_fold(__wsum sum)
100{ 99{
101 __asm__( 100 __asm__(
102 "addl %1, %0 ;\n" 101 "addl %1, %0 ;\n"
103 "adcl $0xffff, %0 ;\n" 102 "adcl $0xffff, %0 ;\n"
104 : "=r" (sum) 103 : "=r" (sum)
105 : "r" (sum << 16), "0" (sum & 0xffff0000) 104 : "r" ((__force u32)sum << 16),
105 "0" ((__force u32)sum & 0xffff0000)
106 ); 106 );
107 return (~sum) >> 16; 107 return (__force __sum16)(~(__force u32)sum >> 16);
108} 108}
109 109
110static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, 110static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
111 unsigned long daddr, 111 unsigned short len,
112 unsigned short len, 112 unsigned short proto,
113 unsigned short proto, 113 __wsum sum)
114 unsigned int sum)
115{ 114{
116 __asm__( 115 __asm__(
117 "addl %1, %0 ;\n" 116 "addl %1, %0 ;\n"
@@ -119,7 +118,7 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
119 "adcl %3, %0 ;\n" 118 "adcl %3, %0 ;\n"
120 "adcl $0, %0 ;\n" 119 "adcl $0, %0 ;\n"
121 : "=r" (sum) 120 : "=r" (sum)
122 : "g" (daddr), "g"(saddr), "g"((ntohs(len)<<16)+proto*256), "0"(sum)); 121 : "g" (daddr), "g"(saddr), "g"((len + proto) << 8), "0"(sum));
123 return sum; 122 return sum;
124} 123}
125 124
@@ -127,11 +126,10 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
127 * computes the checksum of the TCP/UDP pseudo-header 126 * computes the checksum of the TCP/UDP pseudo-header
128 * returns a 16-bit checksum, already complemented 127 * returns a 16-bit checksum, already complemented
129 */ 128 */
130static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 129static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
131 unsigned long daddr,
132 unsigned short len, 130 unsigned short len,
133 unsigned short proto, 131 unsigned short proto,
134 unsigned int sum) 132 __wsum sum)
135{ 133{
136 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 134 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
137} 135}
@@ -141,17 +139,16 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
141 * in icmp.c 139 * in icmp.c
142 */ 140 */
143 141
144static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 142static inline __sum16 ip_compute_csum(const void *buff, int len)
145{ 143{
146 return csum_fold (csum_partial(buff, len, 0)); 144 return csum_fold (csum_partial(buff, len, 0));
147} 145}
148 146
149#define _HAVE_ARCH_IPV6_CSUM 147#define _HAVE_ARCH_IPV6_CSUM
150static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 148static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
151 struct in6_addr *daddr, 149 const struct in6_addr *daddr,
152 __u32 len, 150 __u32 len, unsigned short proto,
153 unsigned short proto, 151 __wsum sum)
154 unsigned int sum)
155{ 152{
156 __asm__( 153 __asm__(
157 "addl 0(%1), %0 ;\n" 154 "addl 0(%1), %0 ;\n"
@@ -176,19 +173,19 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
176 * Copy and checksum to user 173 * Copy and checksum to user
177 */ 174 */
178#define HAVE_CSUM_COPY_USER 175#define HAVE_CSUM_COPY_USER
179static __inline__ unsigned int csum_and_copy_to_user(const unsigned char *src, 176static __inline__ __wsum csum_and_copy_to_user(const void *src,
180 unsigned char __user *dst, 177 void __user *dst,
181 int len, int sum, 178 int len, __wsum sum,
182 int *err_ptr) 179 int *err_ptr)
183{ 180{
184 might_sleep(); 181 might_sleep();
185 if (access_ok(VERIFY_WRITE, dst, len)) 182 if (access_ok(VERIFY_WRITE, dst, len))
186 return csum_partial_copy_generic(src, (__force unsigned char *)dst, len, sum, NULL, err_ptr); 183 return csum_partial_copy_generic(src, (__force void *)dst, len, sum, NULL, err_ptr);
187 184
188 if (len) 185 if (len)
189 *err_ptr = -EFAULT; 186 *err_ptr = -EFAULT;
190 187
191 return -1; /* invalid checksum */ 188 return (__force __wsum)-1; /* invalid checksum */
192} 189}
193 190
194#endif 191#endif
diff --git a/include/asm-i386/device.h b/include/asm-i386/device.h
new file mode 100644
index 000000000000..849604c70e6b
--- /dev/null
+++ b/include/asm-i386/device.h
@@ -0,0 +1,15 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#ifndef _ASM_I386_DEVICE_H
7#define _ASM_I386_DEVICE_H
8
9struct dev_archdata {
10#ifdef CONFIG_ACPI
11 void *acpi_handle;
12#endif
13};
14
15#endif /* _ASM_I386_DEVICE_H */
diff --git a/include/asm-i386/mach-summit/mach_apic.h b/include/asm-i386/mach-summit/mach_apic.h
index ef0671e5d5c5..43e5bd8f4a19 100644
--- a/include/asm-i386/mach-summit/mach_apic.h
+++ b/include/asm-i386/mach-summit/mach_apic.h
@@ -88,7 +88,11 @@ static inline void clustered_apic_check(void)
88 88
89static inline int apicid_to_node(int logical_apicid) 89static inline int apicid_to_node(int logical_apicid)
90{ 90{
91#ifdef CONFIG_SMP
91 return apicid_2_node[hard_smp_processor_id()]; 92 return apicid_2_node[hard_smp_processor_id()];
93#else
94 return 0;
95#endif
92} 96}
93 97
94/* Mapping from cpu number to logical apicid */ 98/* Mapping from cpu number to logical apicid */
diff --git a/include/asm-ia64/checksum.h b/include/asm-ia64/checksum.h
index 1f230ff8ea81..bd40f4756ce1 100644
--- a/include/asm-ia64/checksum.h
+++ b/include/asm-ia64/checksum.h
@@ -10,23 +10,21 @@
10 * This is a version of ip_compute_csum() optimized for IP headers, 10 * This is a version of ip_compute_csum() optimized for IP headers,
11 * which always checksum on 4 octet boundaries. 11 * which always checksum on 4 octet boundaries.
12 */ 12 */
13extern unsigned short ip_fast_csum (unsigned char * iph, unsigned int ihl); 13extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
14 14
15/* 15/*
16 * Computes the checksum of the TCP/UDP pseudo-header returns a 16-bit 16 * Computes the checksum of the TCP/UDP pseudo-header returns a 16-bit
17 * checksum, already complemented 17 * checksum, already complemented
18 */ 18 */
19extern unsigned short int csum_tcpudp_magic (unsigned long saddr, 19extern __sum16 csum_tcpudp_magic (__be32 saddr, __be32 daddr,
20 unsigned long daddr,
21 unsigned short len, 20 unsigned short len,
22 unsigned short proto, 21 unsigned short proto,
23 unsigned int sum); 22 __wsum sum);
24 23
25extern unsigned int csum_tcpudp_nofold (unsigned long saddr, 24extern __wsum csum_tcpudp_nofold (__be32 saddr, __be32 daddr,
26 unsigned long daddr,
27 unsigned short len, 25 unsigned short len,
28 unsigned short proto, 26 unsigned short proto,
29 unsigned int sum); 27 __wsum sum);
30 28
31/* 29/*
32 * Computes the checksum of a memory block at buff, length len, 30 * Computes the checksum of a memory block at buff, length len,
@@ -40,8 +38,7 @@ extern unsigned int csum_tcpudp_nofold (unsigned long saddr,
40 * 38 *
41 * it's best to have buff aligned on a 32-bit boundary 39 * it's best to have buff aligned on a 32-bit boundary
42 */ 40 */
43extern unsigned int csum_partial (const unsigned char * buff, int len, 41extern __wsum csum_partial(const void *buff, int len, __wsum sum);
44 unsigned int sum);
45 42
46/* 43/*
47 * Same as csum_partial, but copies from src while it checksums. 44 * Same as csum_partial, but copies from src while it checksums.
@@ -49,28 +46,28 @@ extern unsigned int csum_partial (const unsigned char * buff, int len,
49 * Here it is even more important to align src and dst on a 32-bit (or 46 * Here it is even more important to align src and dst on a 32-bit (or
50 * even better 64-bit) boundary. 47 * even better 64-bit) boundary.
51 */ 48 */
52extern unsigned int csum_partial_copy_from_user (const char *src, char *dst, 49extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
53 int len, unsigned int sum, 50 int len, __wsum sum,
54 int *errp); 51 int *errp);
55 52
56extern unsigned int csum_partial_copy_nocheck (const char *src, char *dst, 53extern __wsum csum_partial_copy_nocheck(const void *src, void *dst,
57 int len, unsigned int sum); 54 int len, __wsum sum);
58 55
59/* 56/*
60 * This routine is used for miscellaneous IP-like checksums, mainly in 57 * This routine is used for miscellaneous IP-like checksums, mainly in
61 * icmp.c 58 * icmp.c
62 */ 59 */
63extern unsigned short ip_compute_csum (unsigned char *buff, int len); 60extern __sum16 ip_compute_csum(const void *buff, int len);
64 61
65/* 62/*
66 * Fold a partial checksum without adding pseudo headers. 63 * Fold a partial checksum without adding pseudo headers.
67 */ 64 */
68static inline unsigned short 65static inline __sum16 csum_fold(__wsum csum)
69csum_fold (unsigned int sum)
70{ 66{
67 u32 sum = (__force u32)csum;
71 sum = (sum & 0xffff) + (sum >> 16); 68 sum = (sum & 0xffff) + (sum >> 16);
72 sum = (sum & 0xffff) + (sum >> 16); 69 sum = (sum & 0xffff) + (sum >> 16);
73 return ~sum; 70 return (__force __sum16)~sum;
74} 71}
75 72
76#endif /* _ASM_IA64_CHECKSUM_H */ 73#endif /* _ASM_IA64_CHECKSUM_H */
diff --git a/include/asm-ia64/device.h b/include/asm-ia64/device.h
new file mode 100644
index 000000000000..3db6daf7f251
--- /dev/null
+++ b/include/asm-ia64/device.h
@@ -0,0 +1,15 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#ifndef _ASM_IA64_DEVICE_H
7#define _ASM_IA64_DEVICE_H
8
9struct dev_archdata {
10#ifdef CONFIG_ACPI
11 void *acpi_handle;
12#endif
13};
14
15#endif /* _ASM_IA64_DEVICE_H */
diff --git a/include/asm-ia64/io.h b/include/asm-ia64/io.h
index 855c30af72a9..6311e168cd34 100644
--- a/include/asm-ia64/io.h
+++ b/include/asm-ia64/io.h
@@ -32,7 +32,7 @@
32 */ 32 */
33#define IO_SPACE_LIMIT 0xffffffffffffffffUL 33#define IO_SPACE_LIMIT 0xffffffffffffffffUL
34 34
35#define MAX_IO_SPACES_BITS 4 35#define MAX_IO_SPACES_BITS 8
36#define MAX_IO_SPACES (1UL << MAX_IO_SPACES_BITS) 36#define MAX_IO_SPACES (1UL << MAX_IO_SPACES_BITS)
37#define IO_SPACE_BITS 24 37#define IO_SPACE_BITS 24
38#define IO_SPACE_SIZE (1UL << IO_SPACE_BITS) 38#define IO_SPACE_SIZE (1UL << IO_SPACE_BITS)
diff --git a/include/asm-ia64/machvec.h b/include/asm-ia64/machvec.h
index 7ffbddf5306f..8f784f8e45b0 100644
--- a/include/asm-ia64/machvec.h
+++ b/include/asm-ia64/machvec.h
@@ -36,6 +36,7 @@ typedef int ia64_mv_pci_legacy_read_t (struct pci_bus *, u16 port, u32 *val,
36typedef int ia64_mv_pci_legacy_write_t (struct pci_bus *, u16 port, u32 val, 36typedef int ia64_mv_pci_legacy_write_t (struct pci_bus *, u16 port, u32 val,
37 u8 size); 37 u8 size);
38typedef void ia64_mv_migrate_t(struct task_struct * task); 38typedef void ia64_mv_migrate_t(struct task_struct * task);
39typedef void ia64_mv_pci_fixup_bus_t (struct pci_bus *);
39 40
40/* DMA-mapping interface: */ 41/* DMA-mapping interface: */
41typedef void ia64_mv_dma_init (void); 42typedef void ia64_mv_dma_init (void);
@@ -95,6 +96,11 @@ machvec_noop_task (struct task_struct *task)
95{ 96{
96} 97}
97 98
99static inline void
100machvec_noop_bus (struct pci_bus *bus)
101{
102}
103
98extern void machvec_setup (char **); 104extern void machvec_setup (char **);
99extern void machvec_timer_interrupt (int, void *); 105extern void machvec_timer_interrupt (int, void *);
100extern void machvec_dma_sync_single (struct device *, dma_addr_t, size_t, int); 106extern void machvec_dma_sync_single (struct device *, dma_addr_t, size_t, int);
@@ -159,6 +165,7 @@ extern void machvec_tlb_migrate_finish (struct mm_struct *);
159# define platform_migrate ia64_mv.migrate 165# define platform_migrate ia64_mv.migrate
160# define platform_setup_msi_irq ia64_mv.setup_msi_irq 166# define platform_setup_msi_irq ia64_mv.setup_msi_irq
161# define platform_teardown_msi_irq ia64_mv.teardown_msi_irq 167# define platform_teardown_msi_irq ia64_mv.teardown_msi_irq
168# define platform_pci_fixup_bus ia64_mv.pci_fixup_bus
162# endif 169# endif
163 170
164/* __attribute__((__aligned__(16))) is required to make size of the 171/* __attribute__((__aligned__(16))) is required to make size of the
@@ -210,6 +217,7 @@ struct ia64_machine_vector {
210 ia64_mv_migrate_t *migrate; 217 ia64_mv_migrate_t *migrate;
211 ia64_mv_setup_msi_irq_t *setup_msi_irq; 218 ia64_mv_setup_msi_irq_t *setup_msi_irq;
212 ia64_mv_teardown_msi_irq_t *teardown_msi_irq; 219 ia64_mv_teardown_msi_irq_t *teardown_msi_irq;
220 ia64_mv_pci_fixup_bus_t *pci_fixup_bus;
213} __attribute__((__aligned__(16))); /* align attrib? see above comment */ 221} __attribute__((__aligned__(16))); /* align attrib? see above comment */
214 222
215#define MACHVEC_INIT(name) \ 223#define MACHVEC_INIT(name) \
@@ -257,6 +265,7 @@ struct ia64_machine_vector {
257 platform_migrate, \ 265 platform_migrate, \
258 platform_setup_msi_irq, \ 266 platform_setup_msi_irq, \
259 platform_teardown_msi_irq, \ 267 platform_teardown_msi_irq, \
268 platform_pci_fixup_bus, \
260} 269}
261 270
262extern struct ia64_machine_vector ia64_mv; 271extern struct ia64_machine_vector ia64_mv;
@@ -416,5 +425,8 @@ extern int ia64_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size
416#ifndef platform_teardown_msi_irq 425#ifndef platform_teardown_msi_irq
417# define platform_teardown_msi_irq ((ia64_mv_teardown_msi_irq_t*)NULL) 426# define platform_teardown_msi_irq ((ia64_mv_teardown_msi_irq_t*)NULL)
418#endif 427#endif
428#ifndef platform_pci_fixup_bus
429# define platform_pci_fixup_bus machvec_noop_bus
430#endif
419 431
420#endif /* _ASM_IA64_MACHVEC_H */ 432#endif /* _ASM_IA64_MACHVEC_H */
diff --git a/include/asm-ia64/machvec_sn2.h b/include/asm-ia64/machvec_sn2.h
index c54b165b1c17..83325f6db03e 100644
--- a/include/asm-ia64/machvec_sn2.h
+++ b/include/asm-ia64/machvec_sn2.h
@@ -69,6 +69,7 @@ extern ia64_mv_dma_supported sn_dma_supported;
69extern ia64_mv_migrate_t sn_migrate; 69extern ia64_mv_migrate_t sn_migrate;
70extern ia64_mv_setup_msi_irq_t sn_setup_msi_irq; 70extern ia64_mv_setup_msi_irq_t sn_setup_msi_irq;
71extern ia64_mv_teardown_msi_irq_t sn_teardown_msi_irq; 71extern ia64_mv_teardown_msi_irq_t sn_teardown_msi_irq;
72extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus;
72 73
73 74
74/* 75/*
@@ -127,6 +128,7 @@ extern ia64_mv_teardown_msi_irq_t sn_teardown_msi_irq;
127#define platform_setup_msi_irq ((ia64_mv_setup_msi_irq_t*)NULL) 128#define platform_setup_msi_irq ((ia64_mv_setup_msi_irq_t*)NULL)
128#define platform_teardown_msi_irq ((ia64_mv_teardown_msi_irq_t*)NULL) 129#define platform_teardown_msi_irq ((ia64_mv_teardown_msi_irq_t*)NULL)
129#endif 130#endif
131#define platform_pci_fixup_bus sn_pci_fixup_bus
130 132
131#include <asm/sn/io.h> 133#include <asm/sn/io.h>
132 134
diff --git a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
index ef616fd4cb1b..825eb7d882e6 100644
--- a/include/asm-ia64/pci.h
+++ b/include/asm-ia64/pci.h
@@ -26,16 +26,18 @@ void pcibios_config_init(void);
26struct pci_dev; 26struct pci_dev;
27 27
28/* 28/*
29 * PCI_DMA_BUS_IS_PHYS should be set to 1 if there is _necessarily_ a direct correspondence 29 * PCI_DMA_BUS_IS_PHYS should be set to 1 if there is _necessarily_ a direct
30 * between device bus addresses and CPU physical addresses. Platforms with a hardware I/O 30 * correspondence between device bus addresses and CPU physical addresses.
31 * MMU _must_ turn this off to suppress the bounce buffer handling code in the block and 31 * Platforms with a hardware I/O MMU _must_ turn this off to suppress the
32 * network device layers. Platforms with separate bus address spaces _must_ turn this off 32 * bounce buffer handling code in the block and network device layers.
33 * and provide a device DMA mapping implementation that takes care of the necessary 33 * Platforms with separate bus address spaces _must_ turn this off and provide
34 * a device DMA mapping implementation that takes care of the necessary
34 * address translation. 35 * address translation.
35 * 36 *
36 * For now, the ia64 platforms which may have separate/multiple bus address spaces all 37 * For now, the ia64 platforms which may have separate/multiple bus address
37 * have I/O MMUs which support the merging of physically discontiguous buffers, so we can 38 * spaces all have I/O MMUs which support the merging of physically
38 * use that as the sole factor to determine the setting of PCI_DMA_BUS_IS_PHYS. 39 * discontiguous buffers, so we can use that as the sole factor to determine
40 * the setting of PCI_DMA_BUS_IS_PHYS.
39 */ 41 */
40extern unsigned long ia64_max_iommu_merge_mask; 42extern unsigned long ia64_max_iommu_merge_mask;
41#define PCI_DMA_BUS_IS_PHYS (ia64_max_iommu_merge_mask == ~0UL) 43#define PCI_DMA_BUS_IS_PHYS (ia64_max_iommu_merge_mask == ~0UL)
@@ -52,9 +54,6 @@ pcibios_penalize_isa_irq (int irq, int active)
52 /* We don't do dynamic PCI IRQ allocation */ 54 /* We don't do dynamic PCI IRQ allocation */
53} 55}
54 56
55#define HAVE_ARCH_PCI_MWI 1
56extern int pcibios_prep_mwi (struct pci_dev *);
57
58#include <asm-generic/pci-dma-compat.h> 57#include <asm-generic/pci-dma-compat.h>
59 58
60/* pci_unmap_{single,page} is not a nop, thus... */ 59/* pci_unmap_{single,page} is not a nop, thus... */
diff --git a/include/asm-ia64/sn/acpi.h b/include/asm-ia64/sn/acpi.h
new file mode 100644
index 000000000000..2850a7ef5e71
--- /dev/null
+++ b/include/asm-ia64/sn/acpi.h
@@ -0,0 +1,16 @@
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) 2006 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#ifndef _ASM_IA64_SN_ACPI_H
10#define _ASM_IA64_SN_ACPI_H
11
12#include "acpi/acglobal.h"
13
14#define SN_ACPI_BASE_SUPPORT() (acpi_gbl_DSDT->oem_revision >= 0x20101)
15
16#endif /* _ASM_IA64_SN_ACPI_H */
diff --git a/include/asm-ia64/sn/pcidev.h b/include/asm-ia64/sn/pcidev.h
index eac3561574be..9fe89a93d880 100644
--- a/include/asm-ia64/sn/pcidev.h
+++ b/include/asm-ia64/sn/pcidev.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved. 6 * Copyright (C) 1992 - 1997, 2000-2006 Silicon Graphics, Inc. All rights reserved.
7 */ 7 */
8#ifndef _ASM_IA64_SN_PCI_PCIDEV_H 8#ifndef _ASM_IA64_SN_PCI_PCIDEV_H
9#define _ASM_IA64_SN_PCI_PCIDEV_H 9#define _ASM_IA64_SN_PCI_PCIDEV_H
@@ -12,31 +12,29 @@
12 12
13/* 13/*
14 * In ia64, pci_dev->sysdata must be a *pci_controller. To provide access to 14 * In ia64, pci_dev->sysdata must be a *pci_controller. To provide access to
15 * the pcidev_info structs for all devices under a controller, we extend the 15 * the pcidev_info structs for all devices under a controller, we keep a
16 * definition of pci_controller, via sn_pci_controller, to include a list 16 * list of pcidev_info under pci_controller->platform_data.
17 * of pcidev_info.
18 */ 17 */
19struct sn_pci_controller { 18struct sn_platform_data {
20 struct pci_controller pci_controller; 19 void *provider_soft;
21 struct list_head pcidev_info; 20 struct list_head pcidev_info;
22}; 21};
23 22
24#define SN_PCI_CONTROLLER(dev) ((struct sn_pci_controller *) dev->sysdata) 23#define SN_PLATFORM_DATA(busdev) \
24 ((struct sn_platform_data *)(PCI_CONTROLLER(busdev)->platform_data))
25 25
26#define SN_PCIDEV_INFO(dev) sn_pcidev_info_get(dev) 26#define SN_PCIDEV_INFO(dev) sn_pcidev_info_get(dev)
27 27
28#define SN_PCIBUS_BUSSOFT_INFO(pci_bus) \
29 (struct pcibus_info *)((struct pcibus_bussoft *)(PCI_CONTROLLER((pci_bus))->platform_data))
30/* 28/*
31 * Given a pci_bus, return the sn pcibus_bussoft struct. Note that 29 * Given a pci_bus, return the sn pcibus_bussoft struct. Note that
32 * this only works for root busses, not for busses represented by PPB's. 30 * this only works for root busses, not for busses represented by PPB's.
33 */ 31 */
34 32
35#define SN_PCIBUS_BUSSOFT(pci_bus) \ 33#define SN_PCIBUS_BUSSOFT(pci_bus) \
36 ((struct pcibus_bussoft *)(PCI_CONTROLLER((pci_bus))->platform_data)) 34 ((struct pcibus_bussoft *)(SN_PLATFORM_DATA(pci_bus)->provider_soft))
37 35
38#define SN_PCIBUS_BUSSOFT_INFO(pci_bus) \ 36#define SN_PCIBUS_BUSSOFT_INFO(pci_bus) \
39 (struct pcibus_info *)((struct pcibus_bussoft *)(PCI_CONTROLLER((pci_bus))->platform_data)) 37 ((struct pcibus_info *)(SN_PLATFORM_DATA(pci_bus)->provider_soft))
40/* 38/*
41 * Given a struct pci_dev, return the sn pcibus_bussoft struct. Note 39 * Given a struct pci_dev, return the sn pcibus_bussoft struct. Note
42 * that this is not equivalent to SN_PCIBUS_BUSSOFT(pci_dev->bus) due 40 * that this is not equivalent to SN_PCIBUS_BUSSOFT(pci_dev->bus) due
@@ -72,8 +70,6 @@ extern void sn_irq_fixup(struct pci_dev *pci_dev,
72 struct sn_irq_info *sn_irq_info); 70 struct sn_irq_info *sn_irq_info);
73extern void sn_irq_unfixup(struct pci_dev *pci_dev); 71extern void sn_irq_unfixup(struct pci_dev *pci_dev);
74extern struct pcidev_info * sn_pcidev_info_get(struct pci_dev *); 72extern struct pcidev_info * sn_pcidev_info_get(struct pci_dev *);
75extern void sn_pci_controller_fixup(int segment, int busnum,
76 struct pci_bus *bus);
77extern void sn_bus_store_sysdata(struct pci_dev *dev); 73extern void sn_bus_store_sysdata(struct pci_dev *dev);
78extern void sn_bus_free_sysdata(void); 74extern void sn_bus_free_sysdata(void);
79extern void sn_generate_path(struct pci_bus *pci_bus, char *address); 75extern void sn_generate_path(struct pci_bus *pci_bus, char *address);
diff --git a/include/asm-ia64/sn/sn_feature_sets.h b/include/asm-ia64/sn/sn_feature_sets.h
index 30dcfa442e53..bfdc36273ed4 100644
--- a/include/asm-ia64/sn/sn_feature_sets.h
+++ b/include/asm-ia64/sn/sn_feature_sets.h
@@ -44,8 +44,14 @@ extern int sn_prom_feature_available(int id);
44 * Once enabled, a feature cannot be disabled. 44 * Once enabled, a feature cannot be disabled.
45 * 45 *
46 * By default, features are disabled unless explicitly enabled. 46 * By default, features are disabled unless explicitly enabled.
47 *
48 * These defines must be kept in sync with the corresponding
49 * PROM definitions in feature_sets.h.
47 */ 50 */
48#define OSF_MCA_SLV_TO_OS_INIT_SLV 0 51#define OSF_MCA_SLV_TO_OS_INIT_SLV 0
49#define OSF_FEAT_LOG_SBES 1 52#define OSF_FEAT_LOG_SBES 1
53#define OSF_ACPI_ENABLE 2
54#define OSF_PCISEGMENT_ENABLE 3
55
50 56
51#endif /* _ASM_IA64_SN_FEATURE_SETS_H */ 57#endif /* _ASM_IA64_SN_FEATURE_SETS_H */
diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h
index ba826b3f75bb..be5d83ad7cb1 100644
--- a/include/asm-ia64/sn/sn_sal.h
+++ b/include/asm-ia64/sn/sn_sal.h
@@ -77,6 +77,7 @@
77#define SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST 0x02000058 // deprecated 77#define SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST 0x02000058 // deprecated
78#define SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST 0x0200005a 78#define SN_SAL_IOIF_GET_DEVICE_DMAFLUSH_LIST 0x0200005a
79 79
80#define SN_SAL_IOIF_INIT 0x0200005f
80#define SN_SAL_HUB_ERROR_INTERRUPT 0x02000060 81#define SN_SAL_HUB_ERROR_INTERRUPT 0x02000060
81#define SN_SAL_BTE_RECOVER 0x02000061 82#define SN_SAL_BTE_RECOVER 0x02000061
82#define SN_SAL_RESERVED_DO_NOT_USE 0x02000062 83#define SN_SAL_RESERVED_DO_NOT_USE 0x02000062
diff --git a/include/asm-m32r/checksum.h b/include/asm-m32r/checksum.h
index 877ebf46e9ff..a7a7c4f44abe 100644
--- a/include/asm-m32r/checksum.h
+++ b/include/asm-m32r/checksum.h
@@ -31,8 +31,7 @@
31 * 31 *
32 * it's best to have buff aligned on a 32-bit boundary 32 * it's best to have buff aligned on a 32-bit boundary
33 */ 33 */
34asmlinkage unsigned int csum_partial(const unsigned char *buff, 34asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
35 int len, unsigned int sum);
36 35
37/* 36/*
38 * The same as csum_partial, but copies from src while it checksums. 37 * The same as csum_partial, but copies from src while it checksums.
@@ -40,24 +39,22 @@ asmlinkage unsigned int csum_partial(const unsigned char *buff,
40 * Here even more important to align src and dst on a 32-bit (or even 39 * Here even more important to align src and dst on a 32-bit (or even
41 * better 64-bit) boundary 40 * better 64-bit) boundary
42 */ 41 */
43extern unsigned int csum_partial_copy_nocheck(const unsigned char *src, 42extern __wsum csum_partial_copy_nocheck(const void *src, void *dst,
44 unsigned char *dst, 43 int len, __wsum sum);
45 int len, unsigned int sum);
46 44
47/* 45/*
48 * This is a new version of the above that records errors it finds in *errp, 46 * This is a new version of the above that records errors it finds in *errp,
49 * but continues and zeros thre rest of the buffer. 47 * but continues and zeros thre rest of the buffer.
50 */ 48 */
51extern unsigned int csum_partial_copy_from_user(const unsigned char __user *src, 49extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
52 unsigned char *dst, 50 int len, __wsum sum,
53 int len, unsigned int sum,
54 int *err_ptr); 51 int *err_ptr);
55 52
56/* 53/*
57 * Fold a partial checksum 54 * Fold a partial checksum
58 */ 55 */
59 56
60static inline unsigned int csum_fold(unsigned int sum) 57static inline __sum16 csum_fold(__wsum sum)
61{ 58{
62 unsigned long tmpreg; 59 unsigned long tmpreg;
63 __asm__( 60 __asm__(
@@ -72,16 +69,17 @@ static inline unsigned int csum_fold(unsigned int sum)
72 : "0" (sum) 69 : "0" (sum)
73 : "cbit" 70 : "cbit"
74 ); 71 );
75 return sum; 72 return (__force __sum16)sum;
76} 73}
77 74
78/* 75/*
79 * This is a version of ip_compute_csum() optimized for IP headers, 76 * This is a version of ip_compute_csum() optimized for IP headers,
80 * which always checksum on 4 octet boundaries. 77 * which always checksum on 4 octet boundaries.
81 */ 78 */
82static inline unsigned short ip_fast_csum(unsigned char * iph, 79static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
83 unsigned int ihl) { 80{
84 unsigned long sum, tmpreg0, tmpreg1; 81 unsigned long tmpreg0, tmpreg1;
82 __wsum sum;
85 83
86 __asm__ __volatile__( 84 __asm__ __volatile__(
87 " ld %0, @%1+ \n" 85 " ld %0, @%1+ \n"
@@ -115,16 +113,15 @@ static inline unsigned short ip_fast_csum(unsigned char * iph,
115 return csum_fold(sum); 113 return csum_fold(sum);
116} 114}
117 115
118static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, 116static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
119 unsigned long daddr,
120 unsigned short len, 117 unsigned short len,
121 unsigned short proto, 118 unsigned short proto,
122 unsigned int sum) 119 __wsum sum)
123{ 120{
124#if defined(__LITTLE_ENDIAN) 121#if defined(__LITTLE_ENDIAN)
125 unsigned long len_proto = (ntohs(len)<<16)+proto*256; 122 unsigned long len_proto = (proto + len) << 8;
126#else 123#else
127 unsigned long len_proto = (proto<<16)+len; 124 unsigned long len_proto = proto + len;
128#endif 125#endif
129 unsigned long tmpreg; 126 unsigned long tmpreg;
130 127
@@ -147,11 +144,10 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
147 * computes the checksum of the TCP/UDP pseudo-header 144 * computes the checksum of the TCP/UDP pseudo-header
148 * returns a 16-bit checksum, already complemented 145 * returns a 16-bit checksum, already complemented
149 */ 146 */
150static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 147static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
151 unsigned long daddr,
152 unsigned short len, 148 unsigned short len,
153 unsigned short proto, 149 unsigned short proto,
154 unsigned int sum) 150 __wsum sum)
155{ 151{
156 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 152 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
157} 153}
@@ -161,16 +157,16 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
161 * in icmp.c 157 * in icmp.c
162 */ 158 */
163 159
164static inline unsigned short ip_compute_csum(unsigned char * buff, int len) { 160static inline __sum16 ip_compute_csum(const void *buff, int len)
161{
165 return csum_fold (csum_partial(buff, len, 0)); 162 return csum_fold (csum_partial(buff, len, 0));
166} 163}
167 164
168#define _HAVE_ARCH_IPV6_CSUM 165#define _HAVE_ARCH_IPV6_CSUM
169static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 166static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
170 struct in6_addr *daddr, 167 const struct in6_addr *daddr,
171 __u16 len, 168 __u32 len, unsigned short proto,
172 unsigned short proto, 169 __wsum sum)
173 unsigned int sum)
174{ 170{
175 unsigned long tmpreg0, tmpreg1, tmpreg2, tmpreg3; 171 unsigned long tmpreg0, tmpreg1, tmpreg2, tmpreg3;
176 __asm__( 172 __asm__(
@@ -197,7 +193,7 @@ static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
197 : "=&r" (sum), "=&r" (tmpreg0), "=&r" (tmpreg1), 193 : "=&r" (sum), "=&r" (tmpreg0), "=&r" (tmpreg1),
198 "=&r" (tmpreg2), "=&r" (tmpreg3) 194 "=&r" (tmpreg2), "=&r" (tmpreg3)
199 : "r" (saddr), "r" (daddr), 195 : "r" (saddr), "r" (daddr),
200 "r" (htonl((__u32) (len))), "r" (htonl(proto)), "0" (sum) 196 "r" (htonl(len)), "r" (htonl(proto)), "0" (sum)
201 : "cbit" 197 : "cbit"
202 ); 198 );
203 199
diff --git a/include/asm-m32r/device.h b/include/asm-m32r/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-m32r/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-m68k/checksum.h b/include/asm-m68k/checksum.h
index 17280ef719f5..494f9aec37ea 100644
--- a/include/asm-m68k/checksum.h
+++ b/include/asm-m68k/checksum.h
@@ -15,7 +15,7 @@
15 * 15 *
16 * it's best to have buff aligned on a 32-bit boundary 16 * it's best to have buff aligned on a 32-bit boundary
17 */ 17 */
18unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 18__wsum csum_partial(const void *buff, int len, __wsum sum);
19 19
20/* 20/*
21 * the same as csum_partial, but copies from src while it 21 * the same as csum_partial, but copies from src while it
@@ -25,22 +25,21 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
25 * better 64-bit) boundary 25 * better 64-bit) boundary
26 */ 26 */
27 27
28extern unsigned int csum_partial_copy_from_user(const unsigned char __user *src, 28extern __wsum csum_partial_copy_from_user(const void __user *src,
29 unsigned char *dst, 29 void *dst,
30 int len, int sum, 30 int len, __wsum sum,
31 int *csum_err); 31 int *csum_err);
32 32
33extern unsigned int csum_partial_copy_nocheck(const unsigned char *src, 33extern __wsum csum_partial_copy_nocheck(const void *src,
34 unsigned char *dst, int len, 34 void *dst, int len,
35 int sum); 35 __wsum sum);
36 36
37/* 37/*
38 * This is a version of ip_compute_csum() optimized for IP headers, 38 * This is a version of ip_compute_csum() optimized for IP headers,
39 * which always checksum on 4 octet boundaries. 39 * which always checksum on 4 octet boundaries.
40 * 40 *
41 */ 41 */
42static inline unsigned short 42static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
43ip_fast_csum(unsigned char *iph, unsigned int ihl)
44{ 43{
45 unsigned int sum = 0; 44 unsigned int sum = 0;
46 unsigned long tmp; 45 unsigned long tmp;
@@ -58,29 +57,29 @@ ip_fast_csum(unsigned char *iph, unsigned int ihl)
58 : "=d" (sum), "=&a" (iph), "=&d" (ihl), "=&d" (tmp) 57 : "=d" (sum), "=&a" (iph), "=&d" (ihl), "=&d" (tmp)
59 : "0" (sum), "1" (iph), "2" (ihl) 58 : "0" (sum), "1" (iph), "2" (ihl)
60 : "memory"); 59 : "memory");
61 return ~sum; 60 return (__force __sum16)~sum;
62} 61}
63 62
64/* 63/*
65 * Fold a partial checksum 64 * Fold a partial checksum
66 */ 65 */
67 66
68static inline unsigned int csum_fold(unsigned int sum) 67static inline __sum16 csum_fold(__wsum sum)
69{ 68{
70 unsigned int tmp = sum; 69 unsigned int tmp = (__force u32)sum;
71 __asm__("swap %1\n\t" 70 __asm__("swap %1\n\t"
72 "addw %1, %0\n\t" 71 "addw %1, %0\n\t"
73 "clrw %1\n\t" 72 "clrw %1\n\t"
74 "addxw %1, %0" 73 "addxw %1, %0"
75 : "=&d" (sum), "=&d" (tmp) 74 : "=&d" (sum), "=&d" (tmp)
76 : "0" (sum), "1" (tmp)); 75 : "0" (sum), "1" (tmp));
77 return ~sum; 76 return (__force __sum16)~sum;
78} 77}
79 78
80 79
81static inline unsigned int 80static inline __wsum
82csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 81csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
83 unsigned short proto, unsigned int sum) 82 unsigned short proto, __wsum sum)
84{ 83{
85 __asm__ ("addl %2,%0\n\t" 84 __asm__ ("addl %2,%0\n\t"
86 "addxl %3,%0\n\t" 85 "addxl %3,%0\n\t"
@@ -98,9 +97,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
98 * computes the checksum of the TCP/UDP pseudo-header 97 * computes the checksum of the TCP/UDP pseudo-header
99 * returns a 16-bit checksum, already complemented 98 * returns a 16-bit checksum, already complemented
100 */ 99 */
101static inline unsigned short int 100static inline __sum16
102csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, 101csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
103 unsigned short proto, unsigned int sum) 102 unsigned short proto, __wsum sum)
104{ 103{
105 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 104 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
106} 105}
@@ -110,16 +109,15 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
110 * in icmp.c 109 * in icmp.c
111 */ 110 */
112 111
113static inline unsigned short 112static inline __sum16 ip_compute_csum(const void *buff, int len)
114ip_compute_csum(unsigned char * buff, int len)
115{ 113{
116 return csum_fold (csum_partial(buff, len, 0)); 114 return csum_fold (csum_partial(buff, len, 0));
117} 115}
118 116
119#define _HAVE_ARCH_IPV6_CSUM 117#define _HAVE_ARCH_IPV6_CSUM
120static __inline__ unsigned short int 118static __inline__ __sum16
121csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, 119csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
122 __u32 len, unsigned short proto, unsigned int sum) 120 __u32 len, unsigned short proto, __wsum sum)
123{ 121{
124 register unsigned long tmp; 122 register unsigned long tmp;
125 __asm__("addl %2@,%0\n\t" 123 __asm__("addl %2@,%0\n\t"
diff --git a/include/asm-m68k/device.h b/include/asm-m68k/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-m68k/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-m68knommu/checksum.h b/include/asm-m68knommu/checksum.h
index 294ec7583ac9..81883482ffb1 100644
--- a/include/asm-m68knommu/checksum.h
+++ b/include/asm-m68knommu/checksum.h
@@ -15,7 +15,7 @@
15 * 15 *
16 * it's best to have buff aligned on a 32-bit boundary 16 * it's best to have buff aligned on a 32-bit boundary
17 */ 17 */
18unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 18__wsum csum_partial(const void *buff, int len, __wsum sum);
19 19
20/* 20/*
21 * the same as csum_partial, but copies from src while it 21 * the same as csum_partial, but copies from src while it
@@ -25,8 +25,8 @@ unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum)
25 * better 64-bit) boundary 25 * better 64-bit) boundary
26 */ 26 */
27 27
28unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, 28__wsum csum_partial_copy_nocheck(const void *src, void *dst,
29 int len, int sum); 29 int len, __wsum sum);
30 30
31 31
32/* 32/*
@@ -36,33 +36,31 @@ unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst,
36 * better 64-bit) boundary 36 * better 64-bit) boundary
37 */ 37 */
38 38
39extern unsigned int csum_partial_copy_from_user(const unsigned char *src, 39extern __wsum csum_partial_copy_from_user(const void __user *src,
40 unsigned char *dst, int len, int sum, int *csum_err); 40 void *dst, int len, __wsum sum, int *csum_err);
41 41
42#define csum_partial_copy_nocheck(src, dst, len, sum) \ 42__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
43 csum_partial_copy((src), (dst), (len), (sum))
44
45unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl);
46 43
47/* 44/*
48 * Fold a partial checksum 45 * Fold a partial checksum
49 */ 46 */
50 47
51static inline unsigned int csum_fold(unsigned int sum) 48static inline __sum16 csum_fold(__wsum sum)
52{ 49{
50 unsigned int tmp = (__force u32)sum;
53#ifdef CONFIG_COLDFIRE 51#ifdef CONFIG_COLDFIRE
54 sum = (sum & 0xffff) + (sum >> 16); 52 tmp = (tmp & 0xffff) + (tmp >> 16);
55 sum = (sum & 0xffff) + (sum >> 16); 53 tmp = (tmp & 0xffff) + (tmp >> 16);
54 return (__force __sum16)~tmp;
56#else 55#else
57 unsigned int tmp = sum;
58 __asm__("swap %1\n\t" 56 __asm__("swap %1\n\t"
59 "addw %1, %0\n\t" 57 "addw %1, %0\n\t"
60 "clrw %1\n\t" 58 "clrw %1\n\t"
61 "addxw %1, %0" 59 "addxw %1, %0"
62 : "=&d" (sum), "=&d" (tmp) 60 : "=&d" (sum), "=&d" (tmp)
63 : "0" (sum), "1" (sum)); 61 : "0" (sum), "1" (sum));
62 return (__force __sum16)~sum;
64#endif 63#endif
65 return ~sum;
66} 64}
67 65
68 66
@@ -71,9 +69,9 @@ static inline unsigned int csum_fold(unsigned int sum)
71 * returns a 16-bit checksum, already complemented 69 * returns a 16-bit checksum, already complemented
72 */ 70 */
73 71
74static inline unsigned int 72static inline __wsum
75csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, 73csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
76 unsigned short proto, unsigned int sum) 74 unsigned short proto, __wsum sum)
77{ 75{
78 __asm__ ("addl %1,%0\n\t" 76 __asm__ ("addl %1,%0\n\t"
79 "addxl %4,%0\n\t" 77 "addxl %4,%0\n\t"
@@ -86,9 +84,9 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len,
86 return sum; 84 return sum;
87} 85}
88 86
89static inline unsigned short int 87static inline __sum16
90csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, 88csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
91 unsigned short proto, unsigned int sum) 89 unsigned short proto, __wsum sum)
92{ 90{
93 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 91 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
94} 92}
@@ -98,12 +96,12 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len,
98 * in icmp.c 96 * in icmp.c
99 */ 97 */
100 98
101extern unsigned short ip_compute_csum(const unsigned char * buff, int len); 99extern __sum16 ip_compute_csum(const void *buff, int len);
102 100
103#define _HAVE_ARCH_IPV6_CSUM 101#define _HAVE_ARCH_IPV6_CSUM
104static __inline__ unsigned short int 102static __inline__ __sum16
105csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, 103csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
106 __u32 len, unsigned short proto, unsigned int sum) 104 __u32 len, unsigned short proto, __wsum sum)
107{ 105{
108 register unsigned long tmp; 106 register unsigned long tmp;
109 __asm__("addl %2@,%0\n\t" 107 __asm__("addl %2@,%0\n\t"
diff --git a/include/asm-m68knommu/device.h b/include/asm-m68knommu/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-m68knommu/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-m68knommu/mcfmbus.h b/include/asm-m68knommu/mcfmbus.h
index 13df9d41bd1a..319899c47a2c 100644
--- a/include/asm-m68knommu/mcfmbus.h
+++ b/include/asm-m68knommu/mcfmbus.h
@@ -37,7 +37,7 @@
37#define MCFMBUS_MFDR_MBC(a) ((a)&0x3F) /*M-Bus Clock*/ 37#define MCFMBUS_MFDR_MBC(a) ((a)&0x3F) /*M-Bus Clock*/
38 38
39/* 39/*
40* Define bit flags in Controll Register 40* Define bit flags in Control Register
41*/ 41*/
42 42
43#define MCFMBUS_MBCR_MEN (0x80) /* M-Bus Enable */ 43#define MCFMBUS_MBCR_MEN (0x80) /* M-Bus Enable */
diff --git a/include/asm-mips/addrspace.h b/include/asm-mips/addrspace.h
index 45c706e34df1..c6275088cf65 100644
--- a/include/asm-mips/addrspace.h
+++ b/include/asm-mips/addrspace.h
@@ -19,12 +19,16 @@
19#define _ATYPE_ 19#define _ATYPE_
20#define _ATYPE32_ 20#define _ATYPE32_
21#define _ATYPE64_ 21#define _ATYPE64_
22#define _LLCONST_(x) x 22#define _CONST64_(x) x
23#else 23#else
24#define _ATYPE_ __PTRDIFF_TYPE__ 24#define _ATYPE_ __PTRDIFF_TYPE__
25#define _ATYPE32_ int 25#define _ATYPE32_ int
26#define _ATYPE64_ long long 26#define _ATYPE64_ __s64
27#define _LLCONST_(x) x ## LL 27#ifdef CONFIG_64BIT
28#define _CONST64_(x) x ## L
29#else
30#define _CONST64_(x) x ## LL
31#endif
28#endif 32#endif
29 33
30/* 34/*
@@ -48,7 +52,7 @@
48 */ 52 */
49#define CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff) 53#define CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff)
50#define XPHYSADDR(a) ((_ACAST64_(a)) & \ 54#define XPHYSADDR(a) ((_ACAST64_(a)) & \
51 _LLCONST_(0x000000ffffffffff)) 55 _CONST64_(0x000000ffffffffff))
52 56
53#ifdef CONFIG_64BIT 57#ifdef CONFIG_64BIT
54 58
@@ -57,14 +61,14 @@
57 * The compatibility segments use the full 64-bit sign extended value. Note 61 * The compatibility segments use the full 64-bit sign extended value. Note
58 * the R8000 doesn't have them so don't reference these in generic MIPS code. 62 * the R8000 doesn't have them so don't reference these in generic MIPS code.
59 */ 63 */
60#define XKUSEG _LLCONST_(0x0000000000000000) 64#define XKUSEG _CONST64_(0x0000000000000000)
61#define XKSSEG _LLCONST_(0x4000000000000000) 65#define XKSSEG _CONST64_(0x4000000000000000)
62#define XKPHYS _LLCONST_(0x8000000000000000) 66#define XKPHYS _CONST64_(0x8000000000000000)
63#define XKSEG _LLCONST_(0xc000000000000000) 67#define XKSEG _CONST64_(0xc000000000000000)
64#define CKSEG0 _LLCONST_(0xffffffff80000000) 68#define CKSEG0 _CONST64_(0xffffffff80000000)
65#define CKSEG1 _LLCONST_(0xffffffffa0000000) 69#define CKSEG1 _CONST64_(0xffffffffa0000000)
66#define CKSSEG _LLCONST_(0xffffffffc0000000) 70#define CKSSEG _CONST64_(0xffffffffc0000000)
67#define CKSEG3 _LLCONST_(0xffffffffe0000000) 71#define CKSEG3 _CONST64_(0xffffffffe0000000)
68 72
69#define CKSEG0ADDR(a) (CPHYSADDR(a) | CKSEG0) 73#define CKSEG0ADDR(a) (CPHYSADDR(a) | CKSEG0)
70#define CKSEG1ADDR(a) (CPHYSADDR(a) | CKSEG1) 74#define CKSEG1ADDR(a) (CPHYSADDR(a) | CKSEG1)
@@ -122,7 +126,7 @@
122#define PHYS_TO_XKSEG_UNCACHED(p) PHYS_TO_XKPHYS(K_CALG_UNCACHED,(p)) 126#define PHYS_TO_XKSEG_UNCACHED(p) PHYS_TO_XKPHYS(K_CALG_UNCACHED,(p))
123#define PHYS_TO_XKSEG_CACHED(p) PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE,(p)) 127#define PHYS_TO_XKSEG_CACHED(p) PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE,(p))
124#define XKPHYS_TO_PHYS(p) ((p) & TO_PHYS_MASK) 128#define XKPHYS_TO_PHYS(p) ((p) & TO_PHYS_MASK)
125#define PHYS_TO_XKPHYS(cm,a) (_LLCONST_(0x8000000000000000) | \ 129#define PHYS_TO_XKPHYS(cm,a) (_CONST64_(0x8000000000000000) | \
126 ((cm)<<59) | (a)) 130 ((cm)<<59) | (a))
127 131
128#if defined (CONFIG_CPU_R4300) \ 132#if defined (CONFIG_CPU_R4300) \
@@ -132,20 +136,20 @@
132 || defined (CONFIG_CPU_NEVADA) \ 136 || defined (CONFIG_CPU_NEVADA) \
133 || defined (CONFIG_CPU_TX49XX) \ 137 || defined (CONFIG_CPU_TX49XX) \
134 || defined (CONFIG_CPU_MIPS64) 138 || defined (CONFIG_CPU_MIPS64)
135#define TO_PHYS_MASK _LLCONST_(0x0000000fffffffff) /* 2^^36 - 1 */ 139#define TO_PHYS_MASK _CONST64_(0x0000000fffffffff) /* 2^^36 - 1 */
136#endif 140#endif
137 141
138#if defined (CONFIG_CPU_R8000) 142#if defined (CONFIG_CPU_R8000)
139/* We keep KUSIZE consistent with R4000 for now (2^^40) instead of (2^^48) */ 143/* We keep KUSIZE consistent with R4000 for now (2^^40) instead of (2^^48) */
140#define TO_PHYS_MASK _LLCONST_(0x000000ffffffffff) /* 2^^40 - 1 */ 144#define TO_PHYS_MASK _CONST64_(0x000000ffffffffff) /* 2^^40 - 1 */
141#endif 145#endif
142 146
143#if defined (CONFIG_CPU_R10000) 147#if defined (CONFIG_CPU_R10000)
144#define TO_PHYS_MASK _LLCONST_(0x000000ffffffffff) /* 2^^40 - 1 */ 148#define TO_PHYS_MASK _CONST64_(0x000000ffffffffff) /* 2^^40 - 1 */
145#endif 149#endif
146 150
147#if defined(CONFIG_CPU_SB1) || defined(CONFIG_CPU_SB1A) 151#if defined(CONFIG_CPU_SB1) || defined(CONFIG_CPU_SB1A)
148#define TO_PHYS_MASK _LLCONST_(0x00000fffffffffff) /* 2^^44 - 1 */ 152#define TO_PHYS_MASK _CONST64_(0x00000fffffffffff) /* 2^^44 - 1 */
149#endif 153#endif
150 154
151#ifndef CONFIG_CPU_R8000 155#ifndef CONFIG_CPU_R8000
@@ -155,7 +159,7 @@
155 * in order to catch bugs in the source code. 159 * in order to catch bugs in the source code.
156 */ 160 */
157 161
158#define COMPAT_K1BASE32 _LLCONST_(0xffffffffa0000000) 162#define COMPAT_K1BASE32 _CONST64_(0xffffffffa0000000)
159#define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */ 163#define PHYS_TO_COMPATK1(x) ((x) | COMPAT_K1BASE32) /* 32-bit compat k1 */
160 164
161#endif 165#endif
diff --git a/include/asm-mips/atomic.h b/include/asm-mips/atomic.h
index e64abc0d8221..7978d8e11647 100644
--- a/include/asm-mips/atomic.h
+++ b/include/asm-mips/atomic.h
@@ -9,16 +9,8 @@
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details. 10 * for more details.
11 * 11 *
12 * Copyright (C) 1996, 97, 99, 2000, 03, 04 by Ralf Baechle 12 * Copyright (C) 1996, 97, 99, 2000, 03, 04, 06 by Ralf Baechle
13 */ 13 */
14
15/*
16 * As workaround for the ATOMIC_DEC_AND_LOCK / atomic_dec_and_lock mess in
17 * <linux/spinlock.h> we have to include <linux/spinlock.h> outside the
18 * main big wrapper ...
19 */
20#include <linux/spinlock.h>
21
22#ifndef _ASM_ATOMIC_H 14#ifndef _ASM_ATOMIC_H
23#define _ASM_ATOMIC_H 15#define _ASM_ATOMIC_H
24 16
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 1bb89c5a10ee..b9007411b60f 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -10,31 +10,26 @@
10#define _ASM_BITOPS_H 10#define _ASM_BITOPS_H
11 11
12#include <linux/compiler.h> 12#include <linux/compiler.h>
13#include <linux/irqflags.h>
13#include <linux/types.h> 14#include <linux/types.h>
14#include <asm/bug.h> 15#include <asm/bug.h>
15#include <asm/byteorder.h> /* sigh ... */ 16#include <asm/byteorder.h> /* sigh ... */
16#include <asm/cpu-features.h> 17#include <asm/cpu-features.h>
18#include <asm/sgidefs.h>
19#include <asm/war.h>
17 20
18#if (_MIPS_SZLONG == 32) 21#if (_MIPS_SZLONG == 32)
19#define SZLONG_LOG 5 22#define SZLONG_LOG 5
20#define SZLONG_MASK 31UL 23#define SZLONG_MASK 31UL
21#define __LL "ll " 24#define __LL "ll "
22#define __SC "sc " 25#define __SC "sc "
23#define cpu_to_lelongp(x) cpu_to_le32p((__u32 *) (x))
24#elif (_MIPS_SZLONG == 64) 26#elif (_MIPS_SZLONG == 64)
25#define SZLONG_LOG 6 27#define SZLONG_LOG 6
26#define SZLONG_MASK 63UL 28#define SZLONG_MASK 63UL
27#define __LL "lld " 29#define __LL "lld "
28#define __SC "scd " 30#define __SC "scd "
29#define cpu_to_lelongp(x) cpu_to_le64p((__u64 *) (x))
30#endif 31#endif
31 32
32#ifdef __KERNEL__
33
34#include <linux/irqflags.h>
35#include <asm/sgidefs.h>
36#include <asm/war.h>
37
38/* 33/*
39 * clear_bit() doesn't provide any barrier for the compiler. 34 * clear_bit() doesn't provide any barrier for the compiler.
40 */ 35 */
@@ -42,20 +37,6 @@
42#define smp_mb__after_clear_bit() smp_mb() 37#define smp_mb__after_clear_bit() smp_mb()
43 38
44/* 39/*
45 * Only disable interrupt for kernel mode stuff to keep usermode stuff
46 * that dares to use kernel include files alive.
47 */
48
49#define __bi_flags unsigned long flags
50#define __bi_local_irq_save(x) local_irq_save(x)
51#define __bi_local_irq_restore(x) local_irq_restore(x)
52#else
53#define __bi_flags
54#define __bi_local_irq_save(x)
55#define __bi_local_irq_restore(x)
56#endif /* __KERNEL__ */
57
58/*
59 * set_bit - Atomically set a bit in memory 40 * set_bit - Atomically set a bit in memory
60 * @nr: the bit to set 41 * @nr: the bit to set
61 * @addr: the address to start counting from 42 * @addr: the address to start counting from
@@ -93,13 +74,13 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
93 } else { 74 } else {
94 volatile unsigned long *a = addr; 75 volatile unsigned long *a = addr;
95 unsigned long mask; 76 unsigned long mask;
96 __bi_flags; 77 unsigned long flags;
97 78
98 a += nr >> SZLONG_LOG; 79 a += nr >> SZLONG_LOG;
99 mask = 1UL << (nr & SZLONG_MASK); 80 mask = 1UL << (nr & SZLONG_MASK);
100 __bi_local_irq_save(flags); 81 local_irq_save(flags);
101 *a |= mask; 82 *a |= mask;
102 __bi_local_irq_restore(flags); 83 local_irq_restore(flags);
103 } 84 }
104} 85}
105 86
@@ -141,13 +122,13 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
141 } else { 122 } else {
142 volatile unsigned long *a = addr; 123 volatile unsigned long *a = addr;
143 unsigned long mask; 124 unsigned long mask;
144 __bi_flags; 125 unsigned long flags;
145 126
146 a += nr >> SZLONG_LOG; 127 a += nr >> SZLONG_LOG;
147 mask = 1UL << (nr & SZLONG_MASK); 128 mask = 1UL << (nr & SZLONG_MASK);
148 __bi_local_irq_save(flags); 129 local_irq_save(flags);
149 *a &= ~mask; 130 *a &= ~mask;
150 __bi_local_irq_restore(flags); 131 local_irq_restore(flags);
151 } 132 }
152} 133}
153 134
@@ -191,13 +172,13 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
191 } else { 172 } else {
192 volatile unsigned long *a = addr; 173 volatile unsigned long *a = addr;
193 unsigned long mask; 174 unsigned long mask;
194 __bi_flags; 175 unsigned long flags;
195 176
196 a += nr >> SZLONG_LOG; 177 a += nr >> SZLONG_LOG;
197 mask = 1UL << (nr & SZLONG_MASK); 178 mask = 1UL << (nr & SZLONG_MASK);
198 __bi_local_irq_save(flags); 179 local_irq_save(flags);
199 *a ^= mask; 180 *a ^= mask;
200 __bi_local_irq_restore(flags); 181 local_irq_restore(flags);
201 } 182 }
202} 183}
203 184
@@ -258,14 +239,14 @@ static inline int test_and_set_bit(unsigned long nr,
258 volatile unsigned long *a = addr; 239 volatile unsigned long *a = addr;
259 unsigned long mask; 240 unsigned long mask;
260 int retval; 241 int retval;
261 __bi_flags; 242 unsigned long flags;
262 243
263 a += nr >> SZLONG_LOG; 244 a += nr >> SZLONG_LOG;
264 mask = 1UL << (nr & SZLONG_MASK); 245 mask = 1UL << (nr & SZLONG_MASK);
265 __bi_local_irq_save(flags); 246 local_irq_save(flags);
266 retval = (mask & *a) != 0; 247 retval = (mask & *a) != 0;
267 *a |= mask; 248 *a |= mask;
268 __bi_local_irq_restore(flags); 249 local_irq_restore(flags);
269 250
270 return retval; 251 return retval;
271 } 252 }
@@ -330,14 +311,14 @@ static inline int test_and_clear_bit(unsigned long nr,
330 volatile unsigned long *a = addr; 311 volatile unsigned long *a = addr;
331 unsigned long mask; 312 unsigned long mask;
332 int retval; 313 int retval;
333 __bi_flags; 314 unsigned long flags;
334 315
335 a += nr >> SZLONG_LOG; 316 a += nr >> SZLONG_LOG;
336 mask = 1UL << (nr & SZLONG_MASK); 317 mask = 1UL << (nr & SZLONG_MASK);
337 __bi_local_irq_save(flags); 318 local_irq_save(flags);
338 retval = (mask & *a) != 0; 319 retval = (mask & *a) != 0;
339 *a &= ~mask; 320 *a &= ~mask;
340 __bi_local_irq_restore(flags); 321 local_irq_restore(flags);
341 322
342 return retval; 323 return retval;
343 } 324 }
@@ -399,23 +380,19 @@ static inline int test_and_change_bit(unsigned long nr,
399 } else { 380 } else {
400 volatile unsigned long *a = addr; 381 volatile unsigned long *a = addr;
401 unsigned long mask, retval; 382 unsigned long mask, retval;
402 __bi_flags; 383 unsigned long flags;
403 384
404 a += nr >> SZLONG_LOG; 385 a += nr >> SZLONG_LOG;
405 mask = 1UL << (nr & SZLONG_MASK); 386 mask = 1UL << (nr & SZLONG_MASK);
406 __bi_local_irq_save(flags); 387 local_irq_save(flags);
407 retval = (mask & *a) != 0; 388 retval = (mask & *a) != 0;
408 *a ^= mask; 389 *a ^= mask;
409 __bi_local_irq_restore(flags); 390 local_irq_restore(flags);
410 391
411 return retval; 392 return retval;
412 } 393 }
413} 394}
414 395
415#undef __bi_flags
416#undef __bi_local_irq_save
417#undef __bi_local_irq_restore
418
419#include <asm-generic/bitops/non-atomic.h> 396#include <asm-generic/bitops/non-atomic.h>
420 397
421/* 398/*
diff --git a/include/asm-mips/bug.h b/include/asm-mips/bug.h
index 7b4739dc8f3f..4d560a533940 100644
--- a/include/asm-mips/bug.h
+++ b/include/asm-mips/bug.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_BUG_H 1#ifndef __ASM_BUG_H
2#define __ASM_BUG_H 2#define __ASM_BUG_H
3 3
4#include <asm/sgidefs.h>
4 5
5#ifdef CONFIG_BUG 6#ifdef CONFIG_BUG
6 7
@@ -13,6 +14,17 @@ do { \
13 14
14#define HAVE_ARCH_BUG 15#define HAVE_ARCH_BUG
15 16
17#if (_MIPS_ISA > _MIPS_ISA_MIPS1)
18
19#define BUG_ON(condition) \
20do { \
21 __asm__ __volatile__("tne $0, %0" : : "r" (condition)); \
22} while (0)
23
24#define HAVE_ARCH_BUG_ON
25
26#endif /* _MIPS_ISA > _MIPS_ISA_MIPS1 */
27
16#endif 28#endif
17 29
18#include <asm-generic/bug.h> 30#include <asm-generic/bug.h>
diff --git a/include/asm-mips/checksum.h b/include/asm-mips/checksum.h
index a5e6050ec0f3..9b768c3b96b3 100644
--- a/include/asm-mips/checksum.h
+++ b/include/asm-mips/checksum.h
@@ -27,23 +27,22 @@
27 * 27 *
28 * it's best to have buff aligned on a 32-bit boundary 28 * it's best to have buff aligned on a 32-bit boundary
29 */ 29 */
30unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum); 30__wsum csum_partial(const void *buff, int len, __wsum sum);
31 31
32/* 32/*
33 * this is a new version of the above that records errors it finds in *errp, 33 * this is a new version of the above that records errors it finds in *errp,
34 * but continues and zeros the rest of the buffer. 34 * but continues and zeros the rest of the buffer.
35 */ 35 */
36unsigned int csum_partial_copy_from_user(const unsigned char __user *src, 36__wsum csum_partial_copy_from_user(const void __user *src,
37 unsigned char *dst, int len, 37 void *dst, int len,
38 unsigned int sum, int *errp); 38 __wsum sum, int *errp);
39 39
40/* 40/*
41 * Copy and checksum to user 41 * Copy and checksum to user
42 */ 42 */
43#define HAVE_CSUM_COPY_USER 43#define HAVE_CSUM_COPY_USER
44static inline unsigned int csum_and_copy_to_user (const unsigned char *src, 44static inline __wsum csum_and_copy_to_user (const void *src, void __user *dst,
45 unsigned char __user *dst, 45 int len, __wsum sum,
46 int len, int sum,
47 int *err_ptr) 46 int *err_ptr)
48{ 47{
49 might_sleep(); 48 might_sleep();
@@ -51,7 +50,7 @@ static inline unsigned int csum_and_copy_to_user (const unsigned char *src,
51 50
52 if (copy_to_user(dst, src, len)) { 51 if (copy_to_user(dst, src, len)) {
53 *err_ptr = -EFAULT; 52 *err_ptr = -EFAULT;
54 return -1; 53 return (__force __wsum)-1;
55 } 54 }
56 55
57 return sum; 56 return sum;
@@ -61,13 +60,13 @@ static inline unsigned int csum_and_copy_to_user (const unsigned char *src,
61 * the same as csum_partial, but copies from user space (but on MIPS 60 * the same as csum_partial, but copies from user space (but on MIPS
62 * we have just one address space, so this is identical to the above) 61 * we have just one address space, so this is identical to the above)
63 */ 62 */
64unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, 63__wsum csum_partial_copy_nocheck(const void *src, void *dst,
65 int len, unsigned int sum); 64 int len, __wsum sum);
66 65
67/* 66/*
68 * Fold a partial checksum without adding pseudo headers 67 * Fold a partial checksum without adding pseudo headers
69 */ 68 */
70static inline unsigned short int csum_fold(unsigned int sum) 69static inline __sum16 csum_fold(__wsum sum)
71{ 70{
72 __asm__( 71 __asm__(
73 " .set push # csum_fold\n" 72 " .set push # csum_fold\n"
@@ -82,7 +81,7 @@ static inline unsigned short int csum_fold(unsigned int sum)
82 : "=r" (sum) 81 : "=r" (sum)
83 : "0" (sum)); 82 : "0" (sum));
84 83
85 return sum; 84 return (__force __sum16)sum;
86} 85}
87 86
88/* 87/*
@@ -92,10 +91,10 @@ static inline unsigned short int csum_fold(unsigned int sum)
92 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by 91 * By Jorge Cwik <jorge@laser.satlink.net>, adapted for linux by
93 * Arnt Gulbrandsen. 92 * Arnt Gulbrandsen.
94 */ 93 */
95static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) 94static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
96{ 95{
97 unsigned int *word = (unsigned int *) iph; 96 const unsigned int *word = iph;
98 unsigned int *stop = word + ihl; 97 const unsigned int *stop = word + ihl;
99 unsigned int csum; 98 unsigned int csum;
100 int carry; 99 int carry;
101 100
@@ -123,9 +122,9 @@ static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
123 return csum_fold(csum); 122 return csum_fold(csum);
124} 123}
125 124
126static inline unsigned int csum_tcpudp_nofold(unsigned long saddr, 125static inline __wsum csum_tcpudp_nofold(__be32 saddr,
127 unsigned long daddr, unsigned short len, unsigned short proto, 126 __be32 daddr, unsigned short len, unsigned short proto,
128 unsigned int sum) 127 __wsum sum)
129{ 128{
130 __asm__( 129 __asm__(
131 " .set push # csum_tcpudp_nofold\n" 130 " .set push # csum_tcpudp_nofold\n"
@@ -155,9 +154,9 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
155 : "=r" (sum) 154 : "=r" (sum)
156 : "0" (daddr), "r"(saddr), 155 : "0" (daddr), "r"(saddr),
157#ifdef __MIPSEL__ 156#ifdef __MIPSEL__
158 "r" (((unsigned long)htons(len)<<16) + proto*256), 157 "r" ((proto + len) << 8),
159#else 158#else
160 "r" (((unsigned long)(proto)<<16) + len), 159 "r" (proto + len),
161#endif 160#endif
162 "r" (sum)); 161 "r" (sum));
163 162
@@ -168,11 +167,10 @@ static inline unsigned int csum_tcpudp_nofold(unsigned long saddr,
168 * computes the checksum of the TCP/UDP pseudo-header 167 * computes the checksum of the TCP/UDP pseudo-header
169 * returns a 16-bit checksum, already complemented 168 * returns a 16-bit checksum, already complemented
170 */ 169 */
171static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 170static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
172 unsigned long daddr,
173 unsigned short len, 171 unsigned short len,
174 unsigned short proto, 172 unsigned short proto,
175 unsigned int sum) 173 __wsum sum)
176{ 174{
177 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum)); 175 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
178} 176}
@@ -181,17 +179,16 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
181 * this routine is used for miscellaneous IP-like checksums, mainly 179 * this routine is used for miscellaneous IP-like checksums, mainly
182 * in icmp.c 180 * in icmp.c
183 */ 181 */
184static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 182static inline __sum16 ip_compute_csum(const void *buff, int len)
185{ 183{
186 return csum_fold(csum_partial(buff, len, 0)); 184 return csum_fold(csum_partial(buff, len, 0));
187} 185}
188 186
189#define _HAVE_ARCH_IPV6_CSUM 187#define _HAVE_ARCH_IPV6_CSUM
190static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 188static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
191 struct in6_addr *daddr, 189 const struct in6_addr *daddr,
192 __u32 len, 190 __u32 len, unsigned short proto,
193 unsigned short proto, 191 __wsum sum)
194 unsigned int sum)
195{ 192{
196 __asm__( 193 __asm__(
197 " .set push # csum_ipv6_magic\n" 194 " .set push # csum_ipv6_magic\n"
diff --git a/include/asm-mips/cpu-info.h b/include/asm-mips/cpu-info.h
index a2f0c8ea9160..610d0cdeaa9e 100644
--- a/include/asm-mips/cpu-info.h
+++ b/include/asm-mips/cpu-info.h
@@ -22,12 +22,12 @@
22 * Descriptor for a cache 22 * Descriptor for a cache
23 */ 23 */
24struct cache_desc { 24struct cache_desc {
25 unsigned short linesz; /* Size of line in bytes */
26 unsigned short ways; /* Number of ways */
27 unsigned short sets; /* Number of lines per set */
28 unsigned int waysize; /* Bytes per way */ 25 unsigned int waysize; /* Bytes per way */
29 unsigned int waybit; /* Bits to select in a cache set */ 26 unsigned short sets; /* Number of lines per set */
30 unsigned int flags; /* Flags describing cache properties */ 27 unsigned char ways; /* Number of ways */
28 unsigned char linesz; /* Size of line in bytes */
29 unsigned char waybit; /* Bits to select in a cache set */
30 unsigned char flags; /* Flags describing cache properties */
31}; 31};
32 32
33/* 33/*
diff --git a/include/asm-mips/dec/kn02.h b/include/asm-mips/dec/kn02.h
index 8319ad77b250..93430b5f4724 100644
--- a/include/asm-mips/dec/kn02.h
+++ b/include/asm-mips/dec/kn02.h
@@ -82,11 +82,9 @@
82 82
83#ifndef __ASSEMBLY__ 83#ifndef __ASSEMBLY__
84 84
85#include <linux/spinlock.h>
86#include <linux/types.h> 85#include <linux/types.h>
87 86
88extern u32 cached_kn02_csr; 87extern u32 cached_kn02_csr;
89extern spinlock_t kn02_lock;
90extern void init_kn02_irqs(int base); 88extern void init_kn02_irqs(int base);
91#endif 89#endif
92 90
diff --git a/include/asm-mips/device.h b/include/asm-mips/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-mips/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-mips/dma.h b/include/asm-mips/dma.h
index e85849ac165f..23f789c80845 100644
--- a/include/asm-mips/dma.h
+++ b/include/asm-mips/dma.h
@@ -74,7 +74,9 @@
74 * 74 *
75 */ 75 */
76 76
77#ifndef GENERIC_ISA_DMA_SUPPORT_BROKEN
77#define MAX_DMA_CHANNELS 8 78#define MAX_DMA_CHANNELS 8
79#endif
78 80
79/* 81/*
80 * The maximum address in KSEG0 that we can perform a DMA transfer to on this 82 * The maximum address in KSEG0 that we can perform a DMA transfer to on this
diff --git a/include/asm-mips/gt64120.h b/include/asm-mips/gt64120.h
index 2edd171bb6cd..4bf8e28f8850 100644
--- a/include/asm-mips/gt64120.h
+++ b/include/asm-mips/gt64120.h
@@ -451,6 +451,13 @@
451#define GT_SDRAM_OPMODE_OP_MODE 3 451#define GT_SDRAM_OPMODE_OP_MODE 3
452#define GT_SDRAM_OPMODE_OP_CBR 4 452#define GT_SDRAM_OPMODE_OP_CBR 4
453 453
454#define GT_TC_CONTROL_ENTC0_SHF 0
455#define GT_TC_CONTROL_ENTC0_MSK (MSK(1) << GT_TC_CONTROL_ENTC0_SHF)
456#define GT_TC_CONTROL_ENTC0_BIT GT_TC_CONTROL_ENTC0_MSK
457#define GT_TC_CONTROL_SELTC0_SHF 1
458#define GT_TC_CONTROL_SELTC0_MSK (MSK(1) << GT_TC_CONTROL_SELTC0_SHF)
459#define GT_TC_CONTROL_SELTC0_BIT GT_TC_CONTROL_SELTC0_MSK
460
454 461
455#define GT_PCI0_BARE_SWSCS3BOOTDIS_SHF 0 462#define GT_PCI0_BARE_SWSCS3BOOTDIS_SHF 0
456#define GT_PCI0_BARE_SWSCS3BOOTDIS_MSK (MSK(1) << GT_PCI0_BARE_SWSCS3BOOTDIS_SHF) 463#define GT_PCI0_BARE_SWSCS3BOOTDIS_MSK (MSK(1) << GT_PCI0_BARE_SWSCS3BOOTDIS_SHF)
@@ -523,6 +530,13 @@
523#define GT_PCI0_CMD_SWORDSWAP_MSK (MSK(1) << GT_PCI0_CMD_SWORDSWAP_SHF) 530#define GT_PCI0_CMD_SWORDSWAP_MSK (MSK(1) << GT_PCI0_CMD_SWORDSWAP_SHF)
524#define GT_PCI0_CMD_SWORDSWAP_BIT GT_PCI0_CMD_SWORDSWAP_MSK 531#define GT_PCI0_CMD_SWORDSWAP_BIT GT_PCI0_CMD_SWORDSWAP_MSK
525 532
533#define GT_INTR_T0EXP_SHF 8
534#define GT_INTR_T0EXP_MSK (MSK(1) << GT_INTR_T0EXP_SHF)
535#define GT_INTR_T0EXP_BIT GT_INTR_T0EXP_MSK
536#define GT_INTR_RETRYCTR0_SHF 20
537#define GT_INTR_RETRYCTR0_MSK (MSK(1) << GT_INTR_RETRYCTR0_SHF)
538#define GT_INTR_RETRYCTR0_BIT GT_INTR_RETRYCTR0_MSK
539
526/* 540/*
527 * Misc 541 * Misc
528 */ 542 */
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index bc5f3c53155f..d77b657c09c7 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -113,7 +113,7 @@ static inline void set_io_port_base(unsigned long base)
113 * almost all conceivable cases a device driver should not be using 113 * almost all conceivable cases a device driver should not be using
114 * this function 114 * this function
115 */ 115 */
116static inline unsigned long virt_to_phys(volatile void * address) 116static inline unsigned long virt_to_phys(volatile const void *address)
117{ 117{
118 return (unsigned long)address - PAGE_OFFSET; 118 return (unsigned long)address - PAGE_OFFSET;
119} 119}
diff --git a/include/asm-mips/irq.h b/include/asm-mips/irq.h
index 35a05ca5560c..67657089efa7 100644
--- a/include/asm-mips/irq.h
+++ b/include/asm-mips/irq.h
@@ -24,8 +24,6 @@ static inline int irq_canonicalize(int irq)
24#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */ 24#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */
25#endif 25#endif
26 26
27extern asmlinkage unsigned int do_IRQ(unsigned int irq);
28
29#ifdef CONFIG_MIPS_MT_SMTC 27#ifdef CONFIG_MIPS_MT_SMTC
30/* 28/*
31 * Clear interrupt mask handling "backstop" if irq_hwmask 29 * Clear interrupt mask handling "backstop" if irq_hwmask
@@ -43,8 +41,6 @@ do { \
43#define __DO_IRQ_SMTC_HOOK() do { } while (0) 41#define __DO_IRQ_SMTC_HOOK() do { } while (0)
44#endif 42#endif
45 43
46#ifdef CONFIG_PREEMPT
47
48/* 44/*
49 * do_IRQ handles all normal device IRQ's (the special 45 * do_IRQ handles all normal device IRQ's (the special
50 * SMP cross-CPU interrupts have their own specific 46 * SMP cross-CPU interrupts have their own specific
@@ -57,12 +53,10 @@ do { \
57do { \ 53do { \
58 irq_enter(); \ 54 irq_enter(); \
59 __DO_IRQ_SMTC_HOOK(); \ 55 __DO_IRQ_SMTC_HOOK(); \
60 __do_IRQ((irq)); \ 56 generic_handle_irq(irq); \
61 irq_exit(); \ 57 irq_exit(); \
62} while (0) 58} while (0)
63 59
64#endif
65
66extern void arch_init_irq(void); 60extern void arch_init_irq(void);
67extern void spurious_interrupt(void); 61extern void spurious_interrupt(void);
68 62
diff --git a/include/asm-mips/kexec.h b/include/asm-mips/kexec.h
new file mode 100644
index 000000000000..b25267ebcb09
--- /dev/null
+++ b/include/asm-mips/kexec.h
@@ -0,0 +1,32 @@
1/*
2 * kexec.h for kexec
3 * Created by <nschichan@corp.free.fr> on Thu Oct 12 14:59:34 2006
4 *
5 * This source code is licensed under the GNU General Public License,
6 * Version 2. See the file COPYING for more details.
7 */
8
9#ifndef _MIPS_KEXEC
10# define _MIPS_KEXEC
11
12/* Maximum physical address we can use pages from */
13#define KEXEC_SOURCE_MEMORY_LIMIT (0x20000000)
14/* Maximum address we can reach in physical address mode */
15#define KEXEC_DESTINATION_MEMORY_LIMIT (0x20000000)
16 /* Maximum address we can use for the control code buffer */
17#define KEXEC_CONTROL_MEMORY_LIMIT (0x20000000)
18
19#define KEXEC_CONTROL_CODE_SIZE 4096
20
21/* The native architecture */
22#define KEXEC_ARCH KEXEC_ARCH_MIPS
23
24#define MAX_NOTE_BYTES 1024
25
26static inline void crash_setup_regs(struct pt_regs *newregs,
27 struct pt_regs *oldregs)
28{
29 /* Dummy implementation for now */
30}
31
32#endif /* !_MIPS_KEXEC */
diff --git a/include/asm-mips/mach-au1x00/au1xxx_ide.h b/include/asm-mips/mach-au1x00/au1xxx_ide.h
index 301e71300779..e9fa252f8a3f 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_ide.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_ide.h
@@ -170,10 +170,8 @@ int __init auide_probe(void);
170 static int auide_dma_host_on(ide_drive_t *drive); 170 static int auide_dma_host_on(ide_drive_t *drive);
171 static int auide_dma_lostirq(ide_drive_t *drive); 171 static int auide_dma_lostirq(ide_drive_t *drive);
172 static int auide_dma_on(ide_drive_t *drive); 172 static int auide_dma_on(ide_drive_t *drive);
173 static void auide_ddma_tx_callback(int irq, void *param, 173 static void auide_ddma_tx_callback(int irq, void *param);
174 struct pt_regs *regs); 174 static void auide_ddma_rx_callback(int irq, void *param);
175 static void auide_ddma_rx_callback(int irq, void *param,
176 struct pt_regs *regs);
177 static int auide_dma_off_quietly(ide_drive_t *drive); 175 static int auide_dma_off_quietly(ide_drive_t *drive);
178#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */ 176#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
179 177
diff --git a/include/asm-mips/mach-cobalt/cobalt.h b/include/asm-mips/mach-cobalt/cobalt.h
index b3c5ecbec03c..00b0fc68d5cb 100644
--- a/include/asm-mips/mach-cobalt/cobalt.h
+++ b/include/asm-mips/mach-cobalt/cobalt.h
@@ -67,34 +67,9 @@
67#define COBALT_BRD_ID_QUBE2 0x5 67#define COBALT_BRD_ID_QUBE2 0x5
68#define COBALT_BRD_ID_RAQ2 0x6 68#define COBALT_BRD_ID_RAQ2 0x6
69 69
70/*
71 * Galileo chipset access macros for the Cobalt. The base address for
72 * the GT64111 chip is 0x14000000
73 *
74 * Most of this really should go into a separate GT64111 header file.
75 */
76#define GT64111_IO_BASE 0x10000000UL
77#define GT64111_IO_END 0x11ffffffUL
78#define GT64111_MEM_BASE 0x12000000UL
79#define GT64111_MEM_END 0x13ffffffUL
80#define GT64111_BASE 0x14000000UL
81#define GALILEO_REG(ofs) CKSEG1ADDR(GT64111_BASE + (unsigned long)(ofs))
82
83#define GALILEO_INL(port) (*(volatile unsigned int *) GALILEO_REG(port))
84#define GALILEO_OUTL(val, port) \
85do { \
86 *(volatile unsigned int *) GALILEO_REG(port) = (val); \
87} while (0)
88
89#define GALILEO_INTR_T0EXP (1 << 8)
90#define GALILEO_INTR_RETRY_CTR (1 << 20)
91
92#define GALILEO_ENTC0 0x01
93#define GALILEO_SELTC0 0x02
94
95#define PCI_CFG_SET(devfn,where) \ 70#define PCI_CFG_SET(devfn,where) \
96 GALILEO_OUTL((0x80000000 | (PCI_SLOT (devfn) << 11) | \ 71 GT_WRITE(GT_PCI0_CFGADDR_OFS, (0x80000000 | (PCI_SLOT (devfn) << 11) | \
97 (PCI_FUNC (devfn) << 8) | (where)), GT_PCI0_CFGADDR_OFS) 72 (PCI_FUNC (devfn) << 8) | (where)))
98 73
99#define COBALT_LED_PORT (*(volatile unsigned char *) CKSEG1ADDR(0x1c000000)) 74#define COBALT_LED_PORT (*(volatile unsigned char *) CKSEG1ADDR(0x1c000000))
100# define COBALT_LED_BAR_LEFT (1 << 0) /* Qube */ 75# define COBALT_LED_BAR_LEFT (1 << 0) /* Qube */
diff --git a/include/asm-mips/mach-cobalt/mach-gt64120.h b/include/asm-mips/mach-cobalt/mach-gt64120.h
index 587fc4378f44..ae9c5523c7ef 100644
--- a/include/asm-mips/mach-cobalt/mach-gt64120.h
+++ b/include/asm-mips/mach-cobalt/mach-gt64120.h
@@ -1 +1,27 @@
1/* there's something here ... in the dark */ 1/*
2 * Copyright (C) 2006 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
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 as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18#ifndef _COBALT_MACH_GT64120_H
19#define _COBALT_MACH_GT64120_H
20
21/*
22 * Cobalt uses GT64111. GT64111 is almost the same as GT64120.
23 */
24
25#define GT64120_BASE CKSEG1ADDR(GT_DEF_BASE)
26
27#endif /* _COBALT_MACH_GT64120_H */
diff --git a/include/asm-mips/mipsregs.h b/include/asm-mips/mipsregs.h
index 1f318d707998..9985cb7c16e7 100644
--- a/include/asm-mips/mipsregs.h
+++ b/include/asm-mips/mipsregs.h
@@ -545,62 +545,6 @@
545#define MIPS_FPIR_L (_ULCAST_(1) << 21) 545#define MIPS_FPIR_L (_ULCAST_(1) << 21)
546#define MIPS_FPIR_F64 (_ULCAST_(1) << 22) 546#define MIPS_FPIR_F64 (_ULCAST_(1) << 22)
547 547
548/*
549 * R10000 performance counter definitions.
550 *
551 * FIXME: The R10000 performance counter opens a nice way to implement CPU
552 * time accounting with a precission of one cycle. I don't have
553 * R10000 silicon but just a manual, so ...
554 */
555
556/*
557 * Events counted by counter #0
558 */
559#define CE0_CYCLES 0
560#define CE0_INSN_ISSUED 1
561#define CE0_LPSC_ISSUED 2
562#define CE0_S_ISSUED 3
563#define CE0_SC_ISSUED 4
564#define CE0_SC_FAILED 5
565#define CE0_BRANCH_DECODED 6
566#define CE0_QW_WB_SECONDARY 7
567#define CE0_CORRECTED_ECC_ERRORS 8
568#define CE0_ICACHE_MISSES 9
569#define CE0_SCACHE_I_MISSES 10
570#define CE0_SCACHE_I_WAY_MISSPREDICTED 11
571#define CE0_EXT_INTERVENTIONS_REQ 12
572#define CE0_EXT_INVALIDATE_REQ 13
573#define CE0_VIRTUAL_COHERENCY_COND 14
574#define CE0_INSN_GRADUATED 15
575
576/*
577 * Events counted by counter #1
578 */
579#define CE1_CYCLES 0
580#define CE1_INSN_GRADUATED 1
581#define CE1_LPSC_GRADUATED 2
582#define CE1_S_GRADUATED 3
583#define CE1_SC_GRADUATED 4
584#define CE1_FP_INSN_GRADUATED 5
585#define CE1_QW_WB_PRIMARY 6
586#define CE1_TLB_REFILL 7
587#define CE1_BRANCH_MISSPREDICTED 8
588#define CE1_DCACHE_MISS 9
589#define CE1_SCACHE_D_MISSES 10
590#define CE1_SCACHE_D_WAY_MISSPREDICTED 11
591#define CE1_EXT_INTERVENTION_HITS 12
592#define CE1_EXT_INVALIDATE_REQ 13
593#define CE1_SP_HINT_TO_CEXCL_SC_BLOCKS 14
594#define CE1_SP_HINT_TO_SHARED_SC_BLOCKS 15
595
596/*
597 * These flags define in which privilege mode the counters count events
598 */
599#define CEB_USER 8 /* Count events in user mode, EXL = ERL = 0 */
600#define CEB_SUPERVISOR 4 /* Count events in supvervisor mode EXL = ERL = 0 */
601#define CEB_KERNEL 2 /* Count events in kernel mode EXL = ERL = 0 */
602#define CEB_EXL 1 /* Count events with EXL = 1, ERL = 0 */
603
604#ifndef __ASSEMBLY__ 548#ifndef __ASSEMBLY__
605 549
606/* 550/*
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index 85b258ee7090..0dc1a45c27ed 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -34,7 +34,9 @@
34 34
35#ifndef __ASSEMBLY__ 35#ifndef __ASSEMBLY__
36 36
37#include <linux/pfn.h>
37#include <asm/cpu-features.h> 38#include <asm/cpu-features.h>
39#include <asm/io.h>
38 40
39extern void clear_page(void * page); 41extern void clear_page(void * page);
40extern void copy_page(void * to, void * from); 42extern void copy_page(void * to, void * from);
@@ -134,8 +136,14 @@ typedef struct { unsigned long pgprot; } pgprot_t;
134/* to align the pointer to the (next) page boundary */ 136/* to align the pointer to the (next) page boundary */
135#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK) 137#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
136 138
137#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET) 139#if defined(CONFIG_64BIT) && !defined(CONFIG_BUILD_ELF64)
138#define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET)) 140#define __pa_page_offset(x) ((unsigned long)(x) < CKSEG0 ? PAGE_OFFSET : CKSEG0)
141#else
142#define __pa_page_offset(x) PAGE_OFFSET
143#endif
144#define __pa(x) ((unsigned long)(x) - __pa_page_offset(x))
145#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))
146#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
139 147
140#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 148#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
141 149
@@ -160,8 +168,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
160 168
161#endif 169#endif
162 170
163#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 171#define virt_to_page(kaddr) pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
164#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 172#define virt_addr_valid(kaddr) pfn_valid(PFN_DOWN(virt_to_phys(kaddr)))
165 173
166#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ 174#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
167 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 175 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h
index 7e7320300aa3..b9b1e86493ee 100644
--- a/include/asm-mips/pgtable-64.h
+++ b/include/asm-mips/pgtable-64.h
@@ -14,6 +14,7 @@
14#include <asm/addrspace.h> 14#include <asm/addrspace.h>
15#include <asm/page.h> 15#include <asm/page.h>
16#include <asm/cachectl.h> 16#include <asm/cachectl.h>
17#include <asm/fixmap.h>
17 18
18#include <asm-generic/pgtable-nopud.h> 19#include <asm-generic/pgtable-nopud.h>
19 20
@@ -103,6 +104,13 @@
103#define VMALLOC_START MAP_BASE 104#define VMALLOC_START MAP_BASE
104#define VMALLOC_END \ 105#define VMALLOC_END \
105 (VMALLOC_START + PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE) 106 (VMALLOC_START + PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE)
107#if defined(CONFIG_MODULES) && !defined(CONFIG_BUILD_ELF64) && \
108 VMALLOC_START != CKSSEG
109/* Load modules into 32bit-compatible segment. */
110#define MODULE_START CKSSEG
111#define MODULE_END (FIXADDR_START-2*PAGE_SIZE)
112extern pgd_t module_pg_dir[PTRS_PER_PGD];
113#endif
106 114
107#define pte_ERROR(e) \ 115#define pte_ERROR(e) \
108 printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e)) 116 printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
@@ -174,7 +182,12 @@ static inline void pud_clear(pud_t *pudp)
174#define __pmd_offset(address) pmd_index(address) 182#define __pmd_offset(address) pmd_index(address)
175 183
176/* to find an entry in a kernel page-table-directory */ 184/* to find an entry in a kernel page-table-directory */
185#ifdef MODULE_START
186#define pgd_offset_k(address) \
187 ((address) >= MODULE_START ? module_pg_dir : pgd_offset(&init_mm, 0UL))
188#else
177#define pgd_offset_k(address) pgd_offset(&init_mm, 0UL) 189#define pgd_offset_k(address) pgd_offset(&init_mm, 0UL)
190#endif
178 191
179#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 192#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
180#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) 193#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h
index 1ca4d1e185c7..f2e1325fec6c 100644
--- a/include/asm-mips/pgtable.h
+++ b/include/asm-mips/pgtable.h
@@ -67,7 +67,7 @@ extern unsigned long empty_zero_page;
67extern unsigned long zero_page_mask; 67extern unsigned long zero_page_mask;
68 68
69#define ZERO_PAGE(vaddr) \ 69#define ZERO_PAGE(vaddr) \
70 (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))) 70 (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
71 71
72#define __HAVE_ARCH_MOVE_PTE 72#define __HAVE_ARCH_MOVE_PTE
73#define move_pte(pte, prot, old_addr, new_addr) \ 73#define move_pte(pte, prot, old_addr, new_addr) \
diff --git a/include/asm-mips/ptrace.h b/include/asm-mips/ptrace.h
index 5f3a9075cd28..30bf555faeaa 100644
--- a/include/asm-mips/ptrace.h
+++ b/include/asm-mips/ptrace.h
@@ -80,8 +80,6 @@ struct pt_regs {
80#define instruction_pointer(regs) ((regs)->cp0_epc) 80#define instruction_pointer(regs) ((regs)->cp0_epc)
81#define profile_pc(regs) instruction_pointer(regs) 81#define profile_pc(regs) instruction_pointer(regs)
82 82
83extern void show_regs(struct pt_regs *);
84
85extern asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit); 83extern asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit);
86 84
87#endif 85#endif
diff --git a/include/asm-mips/time.h b/include/asm-mips/time.h
index 625acd337bc3..a632cef830a2 100644
--- a/include/asm-mips/time.h
+++ b/include/asm-mips/time.h
@@ -21,6 +21,7 @@
21#include <linux/ptrace.h> 21#include <linux/ptrace.h>
22#include <linux/rtc.h> 22#include <linux/rtc.h>
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/clocksource.h>
24 25
25extern spinlock_t rtc_lock; 26extern spinlock_t rtc_lock;
26 27
@@ -44,12 +45,10 @@ extern int (*mips_timer_state)(void);
44extern void (*mips_timer_ack)(void); 45extern void (*mips_timer_ack)(void);
45 46
46/* 47/*
47 * High precision timer functions. 48 * High precision timer clocksource.
48 * If mips_hpt_read is NULL, an R4k-compatible timer setup is attempted. 49 * If .read is NULL, an R4k-compatible timer setup is attempted.
49 */ 50 */
50extern unsigned int (*mips_hpt_read)(void); 51extern struct clocksource clocksource_mips;
51extern void (*mips_hpt_init)(void);
52extern unsigned int mips_hpt_mask;
53 52
54/* 53/*
55 * to_tm() converts system time back to (year, mon, day, hour, min, sec). 54 * to_tm() converts system time back to (year, mon, day, hour, min, sec).
diff --git a/include/asm-parisc/checksum.h b/include/asm-parisc/checksum.h
index 229cb56fdb7a..cc3ec1bd8919 100644
--- a/include/asm-parisc/checksum.h
+++ b/include/asm-parisc/checksum.h
@@ -15,7 +15,7 @@
15 * 15 *
16 * it's best to have buff aligned on a 32-bit boundary 16 * it's best to have buff aligned on a 32-bit boundary
17 */ 17 */
18extern unsigned int csum_partial(const unsigned char *, int, unsigned int); 18extern __wsum csum_partial(const void *, int, __wsum);
19 19
20/* 20/*
21 * The same as csum_partial, but copies from src while it checksums. 21 * The same as csum_partial, but copies from src while it checksums.
@@ -23,15 +23,14 @@ extern unsigned int csum_partial(const unsigned char *, int, unsigned int);
23 * Here even more important to align src and dst on a 32-bit (or even 23 * Here even more important to align src and dst on a 32-bit (or even
24 * better 64-bit) boundary 24 * better 64-bit) boundary
25 */ 25 */
26extern unsigned int csum_partial_copy_nocheck(const unsigned char *, unsigned char *, 26extern __wsum csum_partial_copy_nocheck(const void *, void *, int, __wsum);
27 int, unsigned int);
28 27
29/* 28/*
30 * this is a new version of the above that records errors it finds in *errp, 29 * this is a new version of the above that records errors it finds in *errp,
31 * but continues and zeros the rest of the buffer. 30 * but continues and zeros the rest of the buffer.
32 */ 31 */
33extern unsigned int csum_partial_copy_from_user(const unsigned char __user *src, 32extern __wsum csum_partial_copy_from_user(const void __user *src,
34 unsigned char *dst, int len, unsigned int sum, int *errp); 33 void *dst, int len, __wsum sum, int *errp);
35 34
36/* 35/*
37 * Optimized for IP headers, which always checksum on 4 octet boundaries. 36 * Optimized for IP headers, which always checksum on 4 octet boundaries.
@@ -39,11 +38,10 @@ extern unsigned int csum_partial_copy_from_user(const unsigned char __user *src,
39 * Written by Randolph Chung <tausq@debian.org>, and then mucked with by 38 * Written by Randolph Chung <tausq@debian.org>, and then mucked with by
40 * LaMont Jones <lamont@debian.org> 39 * LaMont Jones <lamont@debian.org>
41 */ 40 */
42static inline unsigned short ip_fast_csum(unsigned char * iph, 41static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
43 unsigned int ihl) { 42{
44 unsigned int sum; 43 unsigned int sum;
45 44
46
47 __asm__ __volatile__ ( 45 __asm__ __volatile__ (
48" ldws,ma 4(%1), %0\n" 46" ldws,ma 4(%1), %0\n"
49" addib,<= -4, %2, 2f\n" 47" addib,<= -4, %2, 2f\n"
@@ -69,27 +67,27 @@ static inline unsigned short ip_fast_csum(unsigned char * iph,
69 : "1" (iph), "2" (ihl) 67 : "1" (iph), "2" (ihl)
70 : "r19", "r20", "r21" ); 68 : "r19", "r20", "r21" );
71 69
72 return(sum); 70 return (__force __sum16)sum;
73} 71}
74 72
75/* 73/*
76 * Fold a partial checksum 74 * Fold a partial checksum
77 */ 75 */
78static inline unsigned int csum_fold(unsigned int sum) 76static inline __sum16 csum_fold(__wsum csum)
79{ 77{
78 u32 sum = (__force u32)csum;
80 /* add the swapped two 16-bit halves of sum, 79 /* add the swapped two 16-bit halves of sum,
81 a possible carry from adding the two 16-bit halves, 80 a possible carry from adding the two 16-bit halves,
82 will carry from the lower half into the upper half, 81 will carry from the lower half into the upper half,
83 giving us the correct sum in the upper half. */ 82 giving us the correct sum in the upper half. */
84 sum += (sum << 16) + (sum >> 16); 83 sum += (sum << 16) + (sum >> 16);
85 return (~sum) >> 16; 84 return (__force __sum16)(~sum >> 16);
86} 85}
87 86
88static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, 87static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
89 unsigned long daddr,
90 unsigned short len, 88 unsigned short len,
91 unsigned short proto, 89 unsigned short proto,
92 unsigned int sum) 90 __wsum sum)
93{ 91{
94 __asm__( 92 __asm__(
95 " add %1, %0, %0\n" 93 " add %1, %0, %0\n"
@@ -97,19 +95,18 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
97 " addc %3, %0, %0\n" 95 " addc %3, %0, %0\n"
98 " addc %%r0, %0, %0\n" 96 " addc %%r0, %0, %0\n"
99 : "=r" (sum) 97 : "=r" (sum)
100 : "r" (daddr), "r"(saddr), "r"((proto<<16)+len), "0"(sum)); 98 : "r" (daddr), "r"(saddr), "r"(proto+len), "0"(sum));
101 return sum; 99 return sum;
102} 100}
103 101
104/* 102/*
105 * computes the checksum of the TCP/UDP pseudo-header 103 * computes the checksum of the TCP/UDP pseudo-header
106 * returns a 16-bit checksum, already complemented 104 * returns a 16-bit checksum, already complemented
107 */ 105 */
108static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 106static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
109 unsigned long daddr,
110 unsigned short len, 107 unsigned short len,
111 unsigned short proto, 108 unsigned short proto,
112 unsigned int sum) 109 __wsum sum)
113{ 110{
114 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 111 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
115} 112}
@@ -118,17 +115,17 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
118 * this routine is used for miscellaneous IP-like checksums, mainly 115 * this routine is used for miscellaneous IP-like checksums, mainly
119 * in icmp.c 116 * in icmp.c
120 */ 117 */
121static inline unsigned short ip_compute_csum(unsigned char * buf, int len) { 118static inline __sum16 ip_compute_csum(const void *buf, int len)
119{
122 return csum_fold (csum_partial(buf, len, 0)); 120 return csum_fold (csum_partial(buf, len, 0));
123} 121}
124 122
125 123
126#define _HAVE_ARCH_IPV6_CSUM 124#define _HAVE_ARCH_IPV6_CSUM
127static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 125static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
128 struct in6_addr *daddr, 126 const struct in6_addr *daddr,
129 __u16 len, 127 __u32 len, unsigned short proto,
130 unsigned short proto, 128 __wsum sum)
131 unsigned int sum)
132{ 129{
133 __asm__ __volatile__ ( 130 __asm__ __volatile__ (
134 131
@@ -193,9 +190,9 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
193 * Copy and checksum to user 190 * Copy and checksum to user
194 */ 191 */
195#define HAVE_CSUM_COPY_USER 192#define HAVE_CSUM_COPY_USER
196static __inline__ unsigned int csum_and_copy_to_user (const unsigned char *src, 193static __inline__ __wsum csum_and_copy_to_user(const void *src,
197 unsigned char __user *dst, 194 void __user *dst,
198 int len, int sum, 195 int len, __wsum sum,
199 int *err_ptr) 196 int *err_ptr)
200{ 197{
201 /* code stolen from include/asm-mips64 */ 198 /* code stolen from include/asm-mips64 */
@@ -203,7 +200,7 @@ static __inline__ unsigned int csum_and_copy_to_user (const unsigned char *src,
203 200
204 if (copy_to_user(dst, src, len)) { 201 if (copy_to_user(dst, src, len)) {
205 *err_ptr = -EFAULT; 202 *err_ptr = -EFAULT;
206 return -1; 203 return (__force __wsum)-1;
207 } 204 }
208 205
209 return sum; 206 return sum;
diff --git a/include/asm-parisc/device.h b/include/asm-parisc/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-parisc/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-parisc/dma.h b/include/asm-parisc/dma.h
index da2cf373e31c..31ad0f05af3d 100644
--- a/include/asm-parisc/dma.h
+++ b/include/asm-parisc/dma.h
@@ -17,10 +17,10 @@
17 17
18/* 18/*
19** DMA_CHUNK_SIZE is used by the SCSI mid-layer to break up 19** DMA_CHUNK_SIZE is used by the SCSI mid-layer to break up
20** (or rather not merge) DMA's into managable chunks. 20** (or rather not merge) DMAs into manageable chunks.
21** On parisc, this is more of the software/tuning constraint 21** On parisc, this is more of the software/tuning constraint
22** rather than the HW. I/O MMU allocation alogorithms can be 22** rather than the HW. I/O MMU allocation algorithms can be
23** faster with smaller size is (to some degree). 23** faster with smaller sizes (to some degree).
24*/ 24*/
25#define DMA_CHUNK_SIZE (BITS_PER_LONG*PAGE_SIZE) 25#define DMA_CHUNK_SIZE (BITS_PER_LONG*PAGE_SIZE)
26 26
diff --git a/include/asm-parisc/pci.h b/include/asm-parisc/pci.h
index 7b8ad118d2fe..7b3be9ac0dda 100644
--- a/include/asm-parisc/pci.h
+++ b/include/asm-parisc/pci.h
@@ -149,7 +149,7 @@ extern int parisc_bus_is_phys; /* in arch/parisc/kernel/setup.c */
149/* 149/*
150** Most PCI devices (eg Tulip, NCR720) also export the same registers 150** Most PCI devices (eg Tulip, NCR720) also export the same registers
151** to both MMIO and I/O port space. Due to poor performance of I/O Port 151** to both MMIO and I/O port space. Due to poor performance of I/O Port
152** access under HP PCI bus adapters, strongly reccomend use of MMIO 152** access under HP PCI bus adapters, strongly recommend the use of MMIO
153** address space. 153** address space.
154** 154**
155** While I'm at it more PA programming notes: 155** While I'm at it more PA programming notes:
diff --git a/include/asm-parisc/ropes.h b/include/asm-parisc/ropes.h
index 5542dd00472b..007a880615eb 100644
--- a/include/asm-parisc/ropes.h
+++ b/include/asm-parisc/ropes.h
@@ -14,7 +14,7 @@
14#endif 14#endif
15 15
16/* 16/*
17** The number of pdir entries to "free" before issueing 17** The number of pdir entries to "free" before issuing
18** a read to PCOM register to flush out PCOM writes. 18** a read to PCOM register to flush out PCOM writes.
19** Interacts with allocation granularity (ie 4 or 8 entries 19** Interacts with allocation granularity (ie 4 or 8 entries
20** allocated and free'd/purged at a time might make this 20** allocated and free'd/purged at a time might make this
diff --git a/include/asm-parisc/semaphore.h b/include/asm-parisc/semaphore.h
index c9ee41cd0707..d45827a21f94 100644
--- a/include/asm-parisc/semaphore.h
+++ b/include/asm-parisc/semaphore.h
@@ -115,7 +115,8 @@ extern __inline__ int down_interruptible(struct semaphore * sem)
115 */ 115 */
116extern __inline__ int down_trylock(struct semaphore * sem) 116extern __inline__ int down_trylock(struct semaphore * sem)
117{ 117{
118 int flags, count; 118 unsigned long flags;
119 int count;
119 120
120 spin_lock_irqsave(&sem->sentry, flags); 121 spin_lock_irqsave(&sem->sentry, flags);
121 count = sem->count - 1; 122 count = sem->count - 1;
@@ -131,7 +132,8 @@ extern __inline__ int down_trylock(struct semaphore * sem)
131 */ 132 */
132extern __inline__ void up(struct semaphore * sem) 133extern __inline__ void up(struct semaphore * sem)
133{ 134{
134 int flags; 135 unsigned long flags;
136
135 spin_lock_irqsave(&sem->sentry, flags); 137 spin_lock_irqsave(&sem->sentry, flags);
136 if (sem->count < 0) { 138 if (sem->count < 0) {
137 __up(sem); 139 __up(sem);
diff --git a/include/asm-powerpc/checksum.h b/include/asm-powerpc/checksum.h
index 609ecbbd7210..7cdf358337cf 100644
--- a/include/asm-powerpc/checksum.h
+++ b/include/asm-powerpc/checksum.h
@@ -14,17 +14,16 @@
14 * which always checksum on 4 octet boundaries. ihl is the number 14 * which always checksum on 4 octet boundaries. ihl is the number
15 * of 32-bit words and is always >= 5. 15 * of 32-bit words and is always >= 5.
16 */ 16 */
17extern unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl); 17extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
18 18
19/* 19/*
20 * computes the checksum of the TCP/UDP pseudo-header 20 * computes the checksum of the TCP/UDP pseudo-header
21 * returns a 16-bit checksum, already complemented 21 * returns a 16-bit checksum, already complemented
22 */ 22 */
23extern unsigned short csum_tcpudp_magic(unsigned long saddr, 23extern __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
24 unsigned long daddr,
25 unsigned short len, 24 unsigned short len,
26 unsigned short proto, 25 unsigned short proto,
27 unsigned int sum); 26 __wsum sum);
28 27
29/* 28/*
30 * computes the checksum of a memory block at buff, length len, 29 * computes the checksum of a memory block at buff, length len,
@@ -38,8 +37,7 @@ extern unsigned short csum_tcpudp_magic(unsigned long saddr,
38 * 37 *
39 * it's best to have buff aligned on a 32-bit boundary 38 * it's best to have buff aligned on a 32-bit boundary
40 */ 39 */
41extern unsigned int csum_partial(const unsigned char * buff, int len, 40extern __wsum csum_partial(const void *buff, int len, __wsum sum);
42 unsigned int sum);
43 41
44/* 42/*
45 * Computes the checksum of a memory block at src, length len, 43 * Computes the checksum of a memory block at src, length len,
@@ -51,20 +49,15 @@ extern unsigned int csum_partial(const unsigned char * buff, int len,
51 * Like csum_partial, this must be called with even lengths, 49 * Like csum_partial, this must be called with even lengths,
52 * except for the last fragment. 50 * except for the last fragment.
53 */ 51 */
54extern unsigned int csum_partial_copy_generic(const char *src, char *dst, 52extern __wsum csum_partial_copy_generic(const void *src, void *dst,
55 int len, unsigned int sum, 53 int len, __wsum sum,
56 int *src_err, int *dst_err); 54 int *src_err, int *dst_err);
57/* 55/*
58 * the same as csum_partial, but copies from src to dst while it 56 * the same as csum_partial, but copies from src to dst while it
59 * checksums. 57 * checksums.
60 */ 58 */
61unsigned int csum_partial_copy_nocheck(const char *src,
62 char *dst,
63 int len,
64 unsigned int sum);
65
66#define csum_partial_copy_from_user(src, dst, len, sum, errp) \ 59#define csum_partial_copy_from_user(src, dst, len, sum, errp) \
67 csum_partial_copy_generic((src), (dst), (len), (sum), (errp), NULL) 60 csum_partial_copy_generic((__force const void *)(src), (dst), (len), (sum), (errp), NULL)
68 61
69#define csum_partial_copy_nocheck(src, dst, len, sum) \ 62#define csum_partial_copy_nocheck(src, dst, len, sum) \
70 csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL) 63 csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL)
@@ -74,7 +67,7 @@ unsigned int csum_partial_copy_nocheck(const char *src,
74 * turns a 32-bit partial checksum (e.g. from csum_partial) into a 67 * turns a 32-bit partial checksum (e.g. from csum_partial) into a
75 * 1's complement 16-bit checksum. 68 * 1's complement 16-bit checksum.
76 */ 69 */
77static inline unsigned int csum_fold(unsigned int sum) 70static inline __sum16 csum_fold(__wsum sum)
78{ 71{
79 unsigned int tmp; 72 unsigned int tmp;
80 73
@@ -83,41 +76,32 @@ static inline unsigned int csum_fold(unsigned int sum)
83 /* if there is a carry from adding the two 16-bit halves, 76 /* if there is a carry from adding the two 16-bit halves,
84 it will carry from the lower half into the upper half, 77 it will carry from the lower half into the upper half,
85 giving us the correct sum in the upper half. */ 78 giving us the correct sum in the upper half. */
86 sum = ~(sum + tmp) >> 16; 79 return (__force __sum16)(~((__force u32)sum + tmp) >> 16);
87 return sum;
88} 80}
89 81
90/* 82/*
91 * this routine is used for miscellaneous IP-like checksums, mainly 83 * this routine is used for miscellaneous IP-like checksums, mainly
92 * in icmp.c 84 * in icmp.c
93 */ 85 */
94static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 86static inline __sum16 ip_compute_csum(const void *buff, int len)
95{ 87{
96 return csum_fold(csum_partial(buff, len, 0)); 88 return csum_fold(csum_partial(buff, len, 0));
97} 89}
98 90
99#ifdef __powerpc64__ 91static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
100static inline u32 csum_tcpudp_nofold(u32 saddr,
101 u32 daddr,
102 unsigned short len, 92 unsigned short len,
103 unsigned short proto, 93 unsigned short proto,
104 unsigned int sum) 94 __wsum sum)
105{ 95{
106 unsigned long s = sum; 96#ifdef __powerpc64__
97 unsigned long s = (__force u32)sum;
107 98
108 s += saddr; 99 s += (__force u32)saddr;
109 s += daddr; 100 s += (__force u32)daddr;
110 s += (proto << 16) + len; 101 s += proto + len;
111 s += (s >> 32); 102 s += (s >> 32);
112 return (u32) s; 103 return (__force __wsum) s;
113}
114#else 104#else
115static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
116 unsigned long daddr,
117 unsigned short len,
118 unsigned short proto,
119 unsigned int sum)
120{
121 __asm__("\n\ 105 __asm__("\n\
122 addc %0,%0,%1 \n\ 106 addc %0,%0,%1 \n\
123 adde %0,%0,%2 \n\ 107 adde %0,%0,%2 \n\
@@ -125,10 +109,9 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
125 addze %0,%0 \n\ 109 addze %0,%0 \n\
126 " 110 "
127 : "=r" (sum) 111 : "=r" (sum)
128 : "r" (daddr), "r"(saddr), "r"((proto<<16)+len), "0"(sum)); 112 : "r" (daddr), "r"(saddr), "r"(proto + len), "0"(sum));
129 return sum; 113 return sum;
130}
131
132#endif 114#endif
115}
133#endif /* __KERNEL__ */ 116#endif /* __KERNEL__ */
134#endif 117#endif
diff --git a/include/asm-powerpc/device.h b/include/asm-powerpc/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-powerpc/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-powerpc/pci.h b/include/asm-powerpc/pci.h
index 46afd29b904e..721c97f09b20 100644
--- a/include/asm-powerpc/pci.h
+++ b/include/asm-powerpc/pci.h
@@ -62,19 +62,13 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
62} 62}
63 63
64#ifdef CONFIG_PPC64 64#ifdef CONFIG_PPC64
65#define HAVE_ARCH_PCI_MWI 1 65
66static inline int pcibios_prep_mwi(struct pci_dev *dev) 66/*
67{ 67 * We want to avoid touching the cacheline size or MWI bit.
68 /* 68 * pSeries firmware sets the cacheline size (which is not the cpu cacheline
69 * We would like to avoid touching the cacheline size or MWI bit 69 * size in all cases) and hardware treats MWI the same as memory write.
70 * but we cant do that with the current pcibios_prep_mwi 70 */
71 * interface. pSeries firmware sets the cacheline size (which is not 71#define PCI_DISABLE_MWI
72 * the cpu cacheline size in all cases) and hardware treats MWI
73 * the same as memory write. So we dont touch the cacheline size
74 * here and allow the generic code to set the MWI bit.
75 */
76 return 0;
77}
78 72
79extern struct dma_mapping_ops pci_dma_ops; 73extern struct dma_mapping_ops pci_dma_ops;
80 74
diff --git a/include/asm-ppc/device.h b/include/asm-ppc/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-ppc/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-s390/checksum.h b/include/asm-s390/checksum.h
index 37c362d89fad..0a3cd7ec8451 100644
--- a/include/asm-s390/checksum.h
+++ b/include/asm-s390/checksum.h
@@ -27,8 +27,8 @@
27 * 27 *
28 * it's best to have buff aligned on a 32-bit boundary 28 * it's best to have buff aligned on a 32-bit boundary
29 */ 29 */
30static inline unsigned int 30static inline __wsum
31csum_partial(const unsigned char * buff, int len, unsigned int sum) 31csum_partial(const void *buff, int len, __wsum sum)
32{ 32{
33 register unsigned long reg2 asm("2") = (unsigned long) buff; 33 register unsigned long reg2 asm("2") = (unsigned long) buff;
34 register unsigned long reg3 asm("3") = (unsigned long) len; 34 register unsigned long reg3 asm("3") = (unsigned long) len;
@@ -49,9 +49,9 @@ csum_partial(const unsigned char * buff, int len, unsigned int sum)
49 * Copy from userspace and compute checksum. If we catch an exception 49 * Copy from userspace and compute checksum. If we catch an exception
50 * then zero the rest of the buffer. 50 * then zero the rest of the buffer.
51 */ 51 */
52static inline unsigned int 52static inline __wsum
53csum_partial_copy_from_user(const char __user *src, char *dst, 53csum_partial_copy_from_user(const void __user *src, void *dst,
54 int len, unsigned int sum, 54 int len, __wsum sum,
55 int *err_ptr) 55 int *err_ptr)
56{ 56{
57 int missing; 57 int missing;
@@ -66,8 +66,8 @@ csum_partial_copy_from_user(const char __user *src, char *dst,
66} 66}
67 67
68 68
69static inline unsigned int 69static inline __wsum
70csum_partial_copy_nocheck (const char *src, char *dst, int len, unsigned int sum) 70csum_partial_copy_nocheck (const void *src, void *dst, int len, __wsum sum)
71{ 71{
72 memcpy(dst,src,len); 72 memcpy(dst,src,len);
73 return csum_partial(dst, len, sum); 73 return csum_partial(dst, len, sum);
@@ -76,8 +76,7 @@ csum_partial_copy_nocheck (const char *src, char *dst, int len, unsigned int sum
76/* 76/*
77 * Fold a partial checksum without adding pseudo headers 77 * Fold a partial checksum without adding pseudo headers
78 */ 78 */
79static inline unsigned short 79static inline __sum16 csum_fold(__wsum sum)
80csum_fold(unsigned int sum)
81{ 80{
82#ifndef __s390x__ 81#ifndef __s390x__
83 register_pair rp; 82 register_pair rp;
@@ -100,7 +99,7 @@ csum_fold(unsigned int sum)
100 " srl %0,16\n" /* %0 = H+L+C */ 99 " srl %0,16\n" /* %0 = H+L+C */
101 : "+&d" (sum) : : "cc", "2", "3"); 100 : "+&d" (sum) : : "cc", "2", "3");
102#endif /* __s390x__ */ 101#endif /* __s390x__ */
103 return ((unsigned short) ~sum); 102 return (__force __sum16) ~sum;
104} 103}
105 104
106/* 105/*
@@ -108,8 +107,7 @@ csum_fold(unsigned int sum)
108 * which always checksum on 4 octet boundaries. 107 * which always checksum on 4 octet boundaries.
109 * 108 *
110 */ 109 */
111static inline unsigned short 110static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
112ip_fast_csum(unsigned char *iph, unsigned int ihl)
113{ 111{
114 return csum_fold(csum_partial(iph, ihl*4, 0)); 112 return csum_fold(csum_partial(iph, ihl*4, 0));
115} 113}
@@ -118,10 +116,10 @@ ip_fast_csum(unsigned char *iph, unsigned int ihl)
118 * computes the checksum of the TCP/UDP pseudo-header 116 * computes the checksum of the TCP/UDP pseudo-header
119 * returns a 32-bit checksum 117 * returns a 32-bit checksum
120 */ 118 */
121static inline unsigned int 119static inline __wsum
122csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, 120csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
123 unsigned short len, unsigned short proto, 121 unsigned short len, unsigned short proto,
124 unsigned int sum) 122 __wsum sum)
125{ 123{
126#ifndef __s390x__ 124#ifndef __s390x__
127 asm volatile( 125 asm volatile(
@@ -137,12 +135,12 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
137 "1:" 135 "1:"
138 : "+&d" (sum) : "d" (daddr) : "cc"); 136 : "+&d" (sum) : "d" (daddr) : "cc");
139 asm volatile( 137 asm volatile(
140 " alr %0,%1\n" /* sum += (len<<16) + (proto<<8) */ 138 " alr %0,%1\n" /* sum += len + proto */
141 " brc 12,2f\n" 139 " brc 12,2f\n"
142 " ahi %0,1\n" /* add carry */ 140 " ahi %0,1\n" /* add carry */
143 "2:" 141 "2:"
144 : "+&d" (sum) 142 : "+&d" (sum)
145 : "d" (((unsigned int) len<<16) + (unsigned int) proto) 143 : "d" (len + proto)
146 : "cc"); 144 : "cc");
147#else /* __s390x__ */ 145#else /* __s390x__ */
148 asm volatile( 146 asm volatile(
@@ -153,7 +151,7 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
153 "0: algr %0,%2\n" /* sum += daddr */ 151 "0: algr %0,%2\n" /* sum += daddr */
154 " brc 12,1f\n" 152 " brc 12,1f\n"
155 " aghi %0,1\n" /* add carry */ 153 " aghi %0,1\n" /* add carry */
156 "1: algfr %0,%3\n" /* sum += (len<<16) + proto */ 154 "1: algfr %0,%3\n" /* sum += len + proto */
157 " brc 12,2f\n" 155 " brc 12,2f\n"
158 " aghi %0,1\n" /* add carry */ 156 " aghi %0,1\n" /* add carry */
159 "2: srlg 0,%0,32\n" 157 "2: srlg 0,%0,32\n"
@@ -163,7 +161,7 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
163 "3: llgfr %0,%0" 161 "3: llgfr %0,%0"
164 : "+&d" (sum) 162 : "+&d" (sum)
165 : "d" (saddr), "d" (daddr), 163 : "d" (saddr), "d" (daddr),
166 "d" (((unsigned int) len<<16) + (unsigned int) proto) 164 "d" (len + proto)
167 : "cc", "0"); 165 : "cc", "0");
168#endif /* __s390x__ */ 166#endif /* __s390x__ */
169 return sum; 167 return sum;
@@ -174,10 +172,10 @@ csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr,
174 * returns a 16-bit checksum, already complemented 172 * returns a 16-bit checksum, already complemented
175 */ 173 */
176 174
177static inline unsigned short int 175static inline __sum16
178csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, 176csum_tcpudp_magic(__be32 saddr, __be32 daddr,
179 unsigned short len, unsigned short proto, 177 unsigned short len, unsigned short proto,
180 unsigned int sum) 178 __wsum sum)
181{ 179{
182 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 180 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
183} 181}
@@ -187,8 +185,7 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr,
187 * in icmp.c 185 * in icmp.c
188 */ 186 */
189 187
190static inline unsigned short 188static inline __sum16 ip_compute_csum(const void *buff, int len)
191ip_compute_csum(unsigned char * buff, int len)
192{ 189{
193 return csum_fold(csum_partial(buff, len, 0)); 190 return csum_fold(csum_partial(buff, len, 0));
194} 191}
diff --git a/include/asm-s390/device.h b/include/asm-s390/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-s390/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-sh/checksum.h b/include/asm-sh/checksum.h
index 08168afe6746..d44344c88e73 100644
--- a/include/asm-sh/checksum.h
+++ b/include/asm-sh/checksum.h
@@ -23,7 +23,7 @@
23 * 23 *
24 * it's best to have buff aligned on a 32-bit boundary 24 * it's best to have buff aligned on a 32-bit boundary
25 */ 25 */
26asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 26asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
27 27
28/* 28/*
29 * the same as csum_partial, but copies from src while it 29 * the same as csum_partial, but copies from src while it
@@ -33,8 +33,8 @@ asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsign
33 * better 64-bit) boundary 33 * better 64-bit) boundary
34 */ 34 */
35 35
36asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsigned char *dst, 36asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
37 int len, int sum, int *src_err_ptr, int *dst_err_ptr); 37 int len, __wsum sum, int *src_err_ptr, int *dst_err_ptr);
38 38
39/* 39/*
40 * Note: when you get a NULL pointer exception here this means someone 40 * Note: when you get a NULL pointer exception here this means someone
@@ -44,24 +44,25 @@ asmlinkage unsigned int csum_partial_copy_generic(const unsigned char *src, unsi
44 * access_ok(). 44 * access_ok().
45 */ 45 */
46static __inline__ 46static __inline__
47unsigned int csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, 47__wsum csum_partial_copy_nocheck(const void *src, void *dst,
48 int len, int sum) 48 int len, __wsum sum)
49{ 49{
50 return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); 50 return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL);
51} 51}
52 52
53static __inline__ 53static __inline__
54unsigned int csum_partial_copy_from_user (const unsigned char *src, unsigned char *dst, 54__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
55 int len, int sum, int *err_ptr) 55 int len, __wsum sum, int *err_ptr)
56{ 56{
57 return csum_partial_copy_generic ( src, dst, len, sum, err_ptr, NULL); 57 return csum_partial_copy_generic((__force const void *)src, dst,
58 len, sum, err_ptr, NULL);
58} 59}
59 60
60/* 61/*
61 * Fold a partial checksum 62 * Fold a partial checksum
62 */ 63 */
63 64
64static __inline__ unsigned int csum_fold(unsigned int sum) 65static __inline__ __sum16 csum_fold(__wsum sum)
65{ 66{
66 unsigned int __dummy; 67 unsigned int __dummy;
67 __asm__("swap.w %0, %1\n\t" 68 __asm__("swap.w %0, %1\n\t"
@@ -74,7 +75,7 @@ static __inline__ unsigned int csum_fold(unsigned int sum)
74 : "=r" (sum), "=&r" (__dummy) 75 : "=r" (sum), "=&r" (__dummy)
75 : "0" (sum) 76 : "0" (sum)
76 : "t"); 77 : "t");
77 return sum; 78 return (__force __sum16)sum;
78} 79}
79 80
80/* 81/*
@@ -84,7 +85,7 @@ static __inline__ unsigned int csum_fold(unsigned int sum)
84 * i386 version by Jorge Cwik <jorge@laser.satlink.net>, adapted 85 * i386 version by Jorge Cwik <jorge@laser.satlink.net>, adapted
85 * for linux by * Arnt Gulbrandsen. 86 * for linux by * Arnt Gulbrandsen.
86 */ 87 */
87static __inline__ unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) 88static __inline__ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
88{ 89{
89 unsigned int sum, __dummy0, __dummy1; 90 unsigned int sum, __dummy0, __dummy1;
90 91
@@ -112,16 +113,15 @@ static __inline__ unsigned short ip_fast_csum(unsigned char * iph, unsigned int
112 return csum_fold(sum); 113 return csum_fold(sum);
113} 114}
114 115
115static __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr, 116static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
116 unsigned long daddr,
117 unsigned short len, 117 unsigned short len,
118 unsigned short proto, 118 unsigned short proto,
119 unsigned int sum) 119 __wsum sum)
120{ 120{
121#ifdef __LITTLE_ENDIAN__ 121#ifdef __LITTLE_ENDIAN__
122 unsigned long len_proto = (ntohs(len)<<16)+proto*256; 122 unsigned long len_proto = (proto + len) << 8;
123#else 123#else
124 unsigned long len_proto = (proto<<16)+len; 124 unsigned long len_proto = proto + len;
125#endif 125#endif
126 __asm__("clrt\n\t" 126 __asm__("clrt\n\t"
127 "addc %0, %1\n\t" 127 "addc %0, %1\n\t"
@@ -139,11 +139,10 @@ static __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
139 * computes the checksum of the TCP/UDP pseudo-header 139 * computes the checksum of the TCP/UDP pseudo-header
140 * returns a 16-bit checksum, already complemented 140 * returns a 16-bit checksum, already complemented
141 */ 141 */
142static __inline__ unsigned short int csum_tcpudp_magic(unsigned long saddr, 142static __inline__ __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
143 unsigned long daddr,
144 unsigned short len, 143 unsigned short len,
145 unsigned short proto, 144 unsigned short proto,
146 unsigned int sum) 145 __wsum sum)
147{ 146{
148 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 147 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
149} 148}
@@ -153,18 +152,17 @@ static __inline__ unsigned short int csum_tcpudp_magic(unsigned long saddr,
153 * in icmp.c 152 * in icmp.c
154 */ 153 */
155 154
156static __inline__ unsigned short ip_compute_csum(unsigned char * buff, int len) 155static __inline__ __sum16 ip_compute_csum(const void *buff, int len)
157{ 156{
158 return csum_fold (csum_partial(buff, len, 0)); 157 return csum_fold (csum_partial(buff, len, 0));
159} 158}
160 159
161#define _HAVE_ARCH_IPV6_CSUM 160#define _HAVE_ARCH_IPV6_CSUM
162#ifdef CONFIG_IPV6 161#ifdef CONFIG_IPV6
163static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 162static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
164 struct in6_addr *daddr, 163 const struct in6_addr *daddr,
165 __u32 len, 164 __u32 len, unsigned short proto,
166 unsigned short proto, 165 __wsum sum)
167 unsigned int sum)
168{ 166{
169 unsigned int __dummy; 167 unsigned int __dummy;
170 __asm__("clrt\n\t" 168 __asm__("clrt\n\t"
@@ -201,17 +199,18 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
201 * Copy and checksum to user 199 * Copy and checksum to user
202 */ 200 */
203#define HAVE_CSUM_COPY_USER 201#define HAVE_CSUM_COPY_USER
204static __inline__ unsigned int csum_and_copy_to_user (const unsigned char *src, 202static __inline__ __wsum csum_and_copy_to_user (const void *src,
205 unsigned char __user *dst, 203 void __user *dst,
206 int len, int sum, 204 int len, __wsum sum,
207 int *err_ptr) 205 int *err_ptr)
208{ 206{
209 if (access_ok(VERIFY_WRITE, dst, len)) 207 if (access_ok(VERIFY_WRITE, dst, len))
210 return csum_partial_copy_generic(src, dst, len, sum, NULL, err_ptr); 208 return csum_partial_copy_generic((__force const void *)src,
209 dst, len, sum, NULL, err_ptr);
211 210
212 if (len) 211 if (len)
213 *err_ptr = -EFAULT; 212 *err_ptr = -EFAULT;
214 213
215 return -1; /* invalid checksum */ 214 return (__force __wsum)-1; /* invalid checksum */
216} 215}
217#endif /* __ASM_SH_CHECKSUM_H */ 216#endif /* __ASM_SH_CHECKSUM_H */
diff --git a/include/asm-sh/device.h b/include/asm-sh/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-sh/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-sh64/checksum.h b/include/asm-sh64/checksum.h
index fd034e9ae6e3..ba594ccb42e5 100644
--- a/include/asm-sh64/checksum.h
+++ b/include/asm-sh64/checksum.h
@@ -26,8 +26,7 @@
26 * 26 *
27 * it's best to have buff aligned on a 32-bit boundary 27 * it's best to have buff aligned on a 32-bit boundary
28 */ 28 */
29asmlinkage unsigned int csum_partial(const unsigned char *buff, int len, 29asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
30 unsigned int sum);
31 30
32/* 31/*
33 * Note: when you get a NULL pointer exception here this means someone 32 * Note: when you get a NULL pointer exception here this means someone
@@ -38,46 +37,34 @@ asmlinkage unsigned int csum_partial(const unsigned char *buff, int len,
38 */ 37 */
39 38
40 39
41unsigned int csum_partial_copy_nocheck(const char *src, char *dst, int len, 40__wsum csum_partial_copy_nocheck(const void *src, void *dst, int len,
42 unsigned int sum); 41 __wsum sum);
43 42
44unsigned int csum_partial_copy_from_user(const char *src, char *dst, 43__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
45 int len, int sum, int *err_ptr); 44 int len, __wsum sum, int *err_ptr);
46 45
47/* 46static inline __sum16 csum_fold(__wsum csum)
48 * These are the old (and unsafe) way of doing checksums, a warning message will be
49 * printed if they are used and an exeption occurs.
50 *
51 * these functions should go away after some time.
52 */
53
54#define csum_partial_copy_fromuser csum_partial_copy
55
56unsigned int csum_partial_copy(const char *src, char *dst, int len,
57 unsigned int sum);
58
59static inline unsigned short csum_fold(unsigned int sum)
60{ 47{
48 u32 sum = (__force u32)csum;
61 sum = (sum & 0xffff) + (sum >> 16); 49 sum = (sum & 0xffff) + (sum >> 16);
62 sum = (sum & 0xffff) + (sum >> 16); 50 sum = (sum & 0xffff) + (sum >> 16);
63 return ~(sum); 51 return (__force __sum16)~sum;
64} 52}
65 53
66unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl); 54__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
67 55
68unsigned long csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, 56__wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
69 unsigned short len, unsigned short proto, 57 unsigned short len, unsigned short proto,
70 unsigned int sum); 58 __wsum sum);
71 59
72/* 60/*
73 * computes the checksum of the TCP/UDP pseudo-header 61 * computes the checksum of the TCP/UDP pseudo-header
74 * returns a 16-bit checksum, already complemented 62 * returns a 16-bit checksum, already complemented
75 */ 63 */
76static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 64static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
77 unsigned long daddr,
78 unsigned short len, 65 unsigned short len,
79 unsigned short proto, 66 unsigned short proto,
80 unsigned int sum) 67 __wsum sum)
81{ 68{
82 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 69 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
83} 70}
@@ -86,7 +73,7 @@ static inline unsigned short int csum_tcpudp_magic(unsigned long saddr,
86 * this routine is used for miscellaneous IP-like checksums, mainly 73 * this routine is used for miscellaneous IP-like checksums, mainly
87 * in icmp.c 74 * in icmp.c
88 */ 75 */
89static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 76static inline __sum16 ip_compute_csum(const void *buff, int len)
90{ 77{
91 return csum_fold(csum_partial(buff, len, 0)); 78 return csum_fold(csum_partial(buff, len, 0));
92} 79}
diff --git a/include/asm-sh64/device.h b/include/asm-sh64/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-sh64/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-sparc/checksum.h b/include/asm-sparc/checksum.h
index 286158108974..267e631e9bbc 100644
--- a/include/asm-sparc/checksum.h
+++ b/include/asm-sparc/checksum.h
@@ -30,7 +30,7 @@
30 * 30 *
31 * it's best to have buff aligned on a 32-bit boundary 31 * it's best to have buff aligned on a 32-bit boundary
32 */ 32 */
33extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 33extern __wsum csum_partial(const void *buff, int len, __wsum sum);
34 34
35/* the same as csum_partial, but copies from fs:src while it 35/* the same as csum_partial, but copies from fs:src while it
36 * checksums 36 * checksums
@@ -41,9 +41,8 @@ extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned i
41 41
42extern unsigned int __csum_partial_copy_sparc_generic (const unsigned char *, unsigned char *); 42extern unsigned int __csum_partial_copy_sparc_generic (const unsigned char *, unsigned char *);
43 43
44static inline unsigned int 44static inline __wsum
45csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, int len, 45csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
46 unsigned int sum)
47{ 46{
48 register unsigned int ret asm("o0") = (unsigned int)src; 47 register unsigned int ret asm("o0") = (unsigned int)src;
49 register char *d asm("o1") = dst; 48 register char *d asm("o1") = dst;
@@ -57,42 +56,36 @@ csum_partial_copy_nocheck (const unsigned char *src, unsigned char *dst, int len
57 : "o2", "o3", "o4", "o5", "o7", 56 : "o2", "o3", "o4", "o5", "o7",
58 "g2", "g3", "g4", "g5", "g7", 57 "g2", "g3", "g4", "g5", "g7",
59 "memory", "cc"); 58 "memory", "cc");
60 return ret; 59 return (__force __wsum)ret;
61} 60}
62 61
63static inline unsigned int 62static inline __wsum
64csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst, int len, 63csum_partial_copy_from_user(const void __user *src, void *dst, int len,
65 unsigned int sum, int *err) 64 __wsum sum, int *err)
66 { 65 {
67 if (!access_ok (VERIFY_READ, src, len)) { 66 register unsigned long ret asm("o0") = (unsigned long)src;
68 *err = -EFAULT; 67 register char *d asm("o1") = dst;
69 memset (dst, 0, len); 68 register int l asm("g1") = len;
70 return sum; 69 register __wsum s asm("g7") = sum;
71 } else {
72 register unsigned long ret asm("o0") = (unsigned long)src;
73 register char *d asm("o1") = dst;
74 register int l asm("g1") = len;
75 register unsigned int s asm("g7") = sum;
76 70
77 __asm__ __volatile__ ( 71 __asm__ __volatile__ (
78 ".section __ex_table,#alloc\n\t" 72 ".section __ex_table,#alloc\n\t"
79 ".align 4\n\t" 73 ".align 4\n\t"
80 ".word 1f,2\n\t" 74 ".word 1f,2\n\t"
81 ".previous\n" 75 ".previous\n"
82 "1:\n\t" 76 "1:\n\t"
83 "call __csum_partial_copy_sparc_generic\n\t" 77 "call __csum_partial_copy_sparc_generic\n\t"
84 " st %8, [%%sp + 64]\n" 78 " st %8, [%%sp + 64]\n"
85 : "=&r" (ret), "=&r" (d), "=&r" (l), "=&r" (s) 79 : "=&r" (ret), "=&r" (d), "=&r" (l), "=&r" (s)
86 : "0" (ret), "1" (d), "2" (l), "3" (s), "r" (err) 80 : "0" (ret), "1" (d), "2" (l), "3" (s), "r" (err)
87 : "o2", "o3", "o4", "o5", "o7", "g2", "g3", "g4", "g5", 81 : "o2", "o3", "o4", "o5", "o7", "g2", "g3", "g4", "g5",
88 "cc", "memory"); 82 "cc", "memory");
89 return ret; 83 return (__force __wsum)ret;
90 } 84}
91 }
92 85
93static inline unsigned int 86static inline __wsum
94csum_partial_copy_to_user(const unsigned char *src, unsigned char __user *dst, int len, 87csum_partial_copy_to_user(const void *src, void __user *dst, int len,
95 unsigned int sum, int *err) 88 __wsum sum, int *err)
96{ 89{
97 if (!access_ok (VERIFY_WRITE, dst, len)) { 90 if (!access_ok (VERIFY_WRITE, dst, len)) {
98 *err = -EFAULT; 91 *err = -EFAULT;
@@ -101,7 +94,7 @@ csum_partial_copy_to_user(const unsigned char *src, unsigned char __user *dst, i
101 register unsigned long ret asm("o0") = (unsigned long)src; 94 register unsigned long ret asm("o0") = (unsigned long)src;
102 register char __user *d asm("o1") = dst; 95 register char __user *d asm("o1") = dst;
103 register int l asm("g1") = len; 96 register int l asm("g1") = len;
104 register unsigned int s asm("g7") = sum; 97 register __wsum s asm("g7") = sum;
105 98
106 __asm__ __volatile__ ( 99 __asm__ __volatile__ (
107 ".section __ex_table,#alloc\n\t" 100 ".section __ex_table,#alloc\n\t"
@@ -116,7 +109,7 @@ csum_partial_copy_to_user(const unsigned char *src, unsigned char __user *dst, i
116 : "o2", "o3", "o4", "o5", "o7", 109 : "o2", "o3", "o4", "o5", "o7",
117 "g2", "g3", "g4", "g5", 110 "g2", "g3", "g4", "g5",
118 "cc", "memory"); 111 "cc", "memory");
119 return ret; 112 return (__force __wsum)ret;
120 } 113 }
121} 114}
122 115
@@ -126,10 +119,9 @@ csum_partial_copy_to_user(const unsigned char *src, unsigned char __user *dst, i
126/* ihl is always 5 or greater, almost always is 5, and iph is word aligned 119/* ihl is always 5 or greater, almost always is 5, and iph is word aligned
127 * the majority of the time. 120 * the majority of the time.
128 */ 121 */
129static inline unsigned short ip_fast_csum(const unsigned char *iph, 122static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
130 unsigned int ihl)
131{ 123{
132 unsigned short sum; 124 __sum16 sum;
133 125
134 /* Note: We must read %2 before we touch %0 for the first time, 126 /* Note: We must read %2 before we touch %0 for the first time,
135 * because GCC can legitimately use the same register for 127 * because GCC can legitimately use the same register for
@@ -164,7 +156,7 @@ static inline unsigned short ip_fast_csum(const unsigned char *iph,
164} 156}
165 157
166/* Fold a partial checksum without adding pseudo headers. */ 158/* Fold a partial checksum without adding pseudo headers. */
167static inline unsigned int csum_fold(unsigned int sum) 159static inline __sum16 csum_fold(__wsum sum)
168{ 160{
169 unsigned int tmp; 161 unsigned int tmp;
170 162
@@ -173,23 +165,22 @@ static inline unsigned int csum_fold(unsigned int sum)
173 "addx\t%1, %%g0, %1\n\t" 165 "addx\t%1, %%g0, %1\n\t"
174 "xnor\t%%g0, %1, %0" 166 "xnor\t%%g0, %1, %0"
175 : "=&r" (sum), "=r" (tmp) 167 : "=&r" (sum), "=r" (tmp)
176 : "0" (sum), "1" (sum<<16) 168 : "0" (sum), "1" ((__force u32)sum<<16)
177 : "cc"); 169 : "cc");
178 return sum; 170 return (__force __sum16)sum;
179} 171}
180 172
181static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, 173static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
182 unsigned long daddr, 174 unsigned short len,
183 unsigned int len,
184 unsigned short proto, 175 unsigned short proto,
185 unsigned int sum) 176 __wsum sum)
186{ 177{
187 __asm__ __volatile__("addcc\t%1, %0, %0\n\t" 178 __asm__ __volatile__("addcc\t%1, %0, %0\n\t"
188 "addxcc\t%2, %0, %0\n\t" 179 "addxcc\t%2, %0, %0\n\t"
189 "addxcc\t%3, %0, %0\n\t" 180 "addxcc\t%3, %0, %0\n\t"
190 "addx\t%0, %%g0, %0\n\t" 181 "addx\t%0, %%g0, %0\n\t"
191 : "=r" (sum), "=r" (saddr) 182 : "=r" (sum), "=r" (saddr)
192 : "r" (daddr), "r" ((proto<<16)+len), "0" (sum), 183 : "r" (daddr), "r" (proto + len), "0" (sum),
193 "1" (saddr) 184 "1" (saddr)
194 : "cc"); 185 : "cc");
195 return sum; 186 return sum;
@@ -199,22 +190,20 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
199 * computes the checksum of the TCP/UDP pseudo-header 190 * computes the checksum of the TCP/UDP pseudo-header
200 * returns a 16-bit checksum, already complemented 191 * returns a 16-bit checksum, already complemented
201 */ 192 */
202static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 193static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
203 unsigned long daddr,
204 unsigned short len, 194 unsigned short len,
205 unsigned short proto, 195 unsigned short proto,
206 unsigned int sum) 196 __wsum sum)
207{ 197{
208 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 198 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
209} 199}
210 200
211#define _HAVE_ARCH_IPV6_CSUM 201#define _HAVE_ARCH_IPV6_CSUM
212 202
213static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 203static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
214 struct in6_addr *daddr, 204 const struct in6_addr *daddr,
215 __u32 len, 205 __u32 len, unsigned short proto,
216 unsigned short proto, 206 __wsum sum)
217 unsigned int sum)
218{ 207{
219 __asm__ __volatile__ ( 208 __asm__ __volatile__ (
220 "addcc %3, %4, %%g4\n\t" 209 "addcc %3, %4, %%g4\n\t"
@@ -245,7 +234,7 @@ static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
245} 234}
246 235
247/* this routine is used for miscellaneous IP-like checksums, mainly in icmp.c */ 236/* this routine is used for miscellaneous IP-like checksums, mainly in icmp.c */
248static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 237static inline __sum16 ip_compute_csum(const void *buff, int len)
249{ 238{
250 return csum_fold(csum_partial(buff, len, 0)); 239 return csum_fold(csum_partial(buff, len, 0));
251} 240}
diff --git a/include/asm-sparc/device.h b/include/asm-sparc/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-sparc/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-sparc64/checksum.h b/include/asm-sparc64/checksum.h
index dc8bed246fc9..70a006da7634 100644
--- a/include/asm-sparc64/checksum.h
+++ b/include/asm-sparc64/checksum.h
@@ -30,7 +30,7 @@
30 * 30 *
31 * it's best to have buff aligned on a 32-bit boundary 31 * it's best to have buff aligned on a 32-bit boundary
32 */ 32 */
33extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 33extern __wsum csum_partial(const void * buff, int len, __wsum sum);
34 34
35/* the same as csum_partial, but copies from user space while it 35/* the same as csum_partial, but copies from user space while it
36 * checksums 36 * checksums
@@ -38,52 +38,50 @@ extern unsigned int csum_partial(const unsigned char * buff, int len, unsigned i
38 * here even more important to align src and dst on a 32-bit (or even 38 * here even more important to align src and dst on a 32-bit (or even
39 * better 64-bit) boundary 39 * better 64-bit) boundary
40 */ 40 */
41extern unsigned int csum_partial_copy_nocheck(const unsigned char *src, 41extern __wsum csum_partial_copy_nocheck(const void *src, void *dst,
42 unsigned char *dst, 42 int len, __wsum sum);
43 int len, unsigned int sum); 43
44 44extern long __csum_partial_copy_from_user(const void __user *src,
45extern long __csum_partial_copy_from_user(const unsigned char __user *src, 45 void *dst, int len,
46 unsigned char *dst, int len, 46 __wsum sum);
47 unsigned int sum); 47
48 48static inline __wsum
49static inline unsigned int 49csum_partial_copy_from_user(const void __user *src,
50csum_partial_copy_from_user(const unsigned char __user *src, 50 void *dst, int len,
51 unsigned char *dst, int len, 51 __wsum sum, int *err)
52 unsigned int sum, int *err)
53{ 52{
54 long ret = __csum_partial_copy_from_user(src, dst, len, sum); 53 long ret = __csum_partial_copy_from_user(src, dst, len, sum);
55 if (ret < 0) 54 if (ret < 0)
56 *err = -EFAULT; 55 *err = -EFAULT;
57 return (unsigned int) ret; 56 return (__force __wsum) ret;
58} 57}
59 58
60/* 59/*
61 * Copy and checksum to user 60 * Copy and checksum to user
62 */ 61 */
63#define HAVE_CSUM_COPY_USER 62#define HAVE_CSUM_COPY_USER
64extern long __csum_partial_copy_to_user(const unsigned char *src, 63extern long __csum_partial_copy_to_user(const void *src,
65 unsigned char __user *dst, int len, 64 void __user *dst, int len,
66 unsigned int sum); 65 __wsum sum);
67 66
68static inline unsigned int 67static inline __wsum
69csum_and_copy_to_user(const unsigned char *src, 68csum_and_copy_to_user(const void *src,
70 unsigned char __user *dst, int len, 69 void __user *dst, int len,
71 unsigned int sum, int *err) 70 __wsum sum, int *err)
72{ 71{
73 long ret = __csum_partial_copy_to_user(src, dst, len, sum); 72 long ret = __csum_partial_copy_to_user(src, dst, len, sum);
74 if (ret < 0) 73 if (ret < 0)
75 *err = -EFAULT; 74 *err = -EFAULT;
76 return (unsigned int) ret; 75 return (__force __wsum) ret;
77} 76}
78 77
79/* ihl is always 5 or greater, almost always is 5, and iph is word aligned 78/* ihl is always 5 or greater, almost always is 5, and iph is word aligned
80 * the majority of the time. 79 * the majority of the time.
81 */ 80 */
82extern unsigned short ip_fast_csum(__const__ unsigned char *iph, 81extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
83 unsigned int ihl);
84 82
85/* Fold a partial checksum without adding pseudo headers. */ 83/* Fold a partial checksum without adding pseudo headers. */
86static inline unsigned short csum_fold(unsigned int sum) 84static inline __sum16 csum_fold(__wsum sum)
87{ 85{
88 unsigned int tmp; 86 unsigned int tmp;
89 87
@@ -93,16 +91,15 @@ static inline unsigned short csum_fold(unsigned int sum)
93" addc %1, %%g0, %1\n" 91" addc %1, %%g0, %1\n"
94" xnor %%g0, %1, %0\n" 92" xnor %%g0, %1, %0\n"
95 : "=&r" (sum), "=r" (tmp) 93 : "=&r" (sum), "=r" (tmp)
96 : "0" (sum), "1" (sum<<16) 94 : "0" (sum), "1" ((__force u32)sum<<16)
97 : "cc"); 95 : "cc");
98 return (sum & 0xffff); 96 return (__force __sum16)sum;
99} 97}
100 98
101static inline unsigned long csum_tcpudp_nofold(unsigned long saddr, 99static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
102 unsigned long daddr,
103 unsigned int len, 100 unsigned int len,
104 unsigned short proto, 101 unsigned short proto,
105 unsigned int sum) 102 __wsum sum)
106{ 103{
107 __asm__ __volatile__( 104 __asm__ __volatile__(
108" addcc %1, %0, %0\n" 105" addcc %1, %0, %0\n"
@@ -110,7 +107,7 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
110" addccc %3, %0, %0\n" 107" addccc %3, %0, %0\n"
111" addc %0, %%g0, %0\n" 108" addc %0, %%g0, %0\n"
112 : "=r" (sum), "=r" (saddr) 109 : "=r" (sum), "=r" (saddr)
113 : "r" (daddr), "r" ((proto<<16)+len), "0" (sum), "1" (saddr) 110 : "r" (daddr), "r" (proto + len), "0" (sum), "1" (saddr)
114 : "cc"); 111 : "cc");
115 return sum; 112 return sum;
116} 113}
@@ -119,22 +116,20 @@ static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
119 * computes the checksum of the TCP/UDP pseudo-header 116 * computes the checksum of the TCP/UDP pseudo-header
120 * returns a 16-bit checksum, already complemented 117 * returns a 16-bit checksum, already complemented
121 */ 118 */
122static inline unsigned short int csum_tcpudp_magic(unsigned long saddr, 119static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
123 unsigned long daddr,
124 unsigned short len, 120 unsigned short len,
125 unsigned short proto, 121 unsigned short proto,
126 unsigned int sum) 122 __wsum sum)
127{ 123{
128 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 124 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
129} 125}
130 126
131#define _HAVE_ARCH_IPV6_CSUM 127#define _HAVE_ARCH_IPV6_CSUM
132 128
133static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 129static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
134 struct in6_addr *daddr, 130 const struct in6_addr *daddr,
135 __u32 len, 131 __u32 len, unsigned short proto,
136 unsigned short proto, 132 __wsum sum)
137 unsigned int sum)
138{ 133{
139 __asm__ __volatile__ ( 134 __asm__ __volatile__ (
140" addcc %3, %4, %%g7\n" 135" addcc %3, %4, %%g7\n"
@@ -165,7 +160,7 @@ static inline unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
165} 160}
166 161
167/* this routine is used for miscellaneous IP-like checksums, mainly in icmp.c */ 162/* this routine is used for miscellaneous IP-like checksums, mainly in icmp.c */
168static inline unsigned short ip_compute_csum(unsigned char * buff, int len) 163static inline __sum16 ip_compute_csum(const void *buff, int len)
169{ 164{
170 return csum_fold(csum_partial(buff, len, 0)); 165 return csum_fold(csum_partial(buff, len, 0));
171} 166}
diff --git a/include/asm-sparc64/device.h b/include/asm-sparc64/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-sparc64/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
index e1ea67bc32f2..ca6560288ae8 100644
--- a/include/asm-sparc64/pci.h
+++ b/include/asm-sparc64/pci.h
@@ -18,6 +18,8 @@
18 18
19#define PCI_IRQ_NONE 0xffffffff 19#define PCI_IRQ_NONE 0xffffffff
20 20
21#define PCI_CACHE_LINE_BYTES 64
22
21static inline void pcibios_set_master(struct pci_dev *dev) 23static inline void pcibios_set_master(struct pci_dev *dev)
22{ 24{
23 /* No special bus mastering setup handling */ 25 /* No special bus mastering setup handling */
@@ -291,10 +293,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
291 enum pci_mmap_state mmap_state, 293 enum pci_mmap_state mmap_state,
292 int write_combine); 294 int write_combine);
293 295
294/* Platform specific MWI support. */
295#define HAVE_ARCH_PCI_MWI
296extern int pcibios_prep_mwi(struct pci_dev *dev);
297
298extern void 296extern void
299pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region, 297pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
300 struct resource *res); 298 struct resource *res);
diff --git a/include/asm-um/device.h b/include/asm-um/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-um/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-v850/checksum.h b/include/asm-v850/checksum.h
index 4df5e71098f9..d1dddd938262 100644
--- a/include/asm-v850/checksum.h
+++ b/include/asm-v850/checksum.h
@@ -26,8 +26,7 @@
26 * 26 *
27 * it's best to have buff aligned on a 32-bit boundary 27 * it's best to have buff aligned on a 32-bit boundary
28 */ 28 */
29extern unsigned int csum_partial (const unsigned char * buff, int len, 29extern __wsum csum_partial(const void *buff, int len, __wsum sum);
30 unsigned int sum);
31 30
32/* 31/*
33 * the same as csum_partial, but copies from src while it 32 * the same as csum_partial, but copies from src while it
@@ -36,8 +35,8 @@ extern unsigned int csum_partial (const unsigned char * buff, int len,
36 * here even more important to align src and dst on a 32-bit (or even 35 * here even more important to align src and dst on a 32-bit (or even
37 * better 64-bit) boundary 36 * better 64-bit) boundary
38 */ 37 */
39extern unsigned csum_partial_copy (const unsigned char *src, 38extern __wsum csum_partial_copy_nocheck(const void *src,
40 unsigned char *dst, int len, unsigned sum); 39 void *dst, int len, __wsum sum);
41 40
42 41
43/* 42/*
@@ -46,20 +45,17 @@ extern unsigned csum_partial_copy (const unsigned char *src,
46 * here even more important to align src and dst on a 32-bit (or even 45 * here even more important to align src and dst on a 32-bit (or even
47 * better 64-bit) boundary 46 * better 64-bit) boundary
48 */ 47 */
49extern unsigned csum_partial_copy_from_user (const unsigned char *src, 48extern __wsum csum_partial_copy_from_user (const void *src,
50 unsigned char *dst, 49 void *dst,
51 int len, unsigned sum, 50 int len, __wsum sum,
52 int *csum_err); 51 int *csum_err);
53 52
54#define csum_partial_copy_nocheck(src, dst, len, sum) \ 53__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
55 csum_partial_copy ((src), (dst), (len), (sum))
56
57unsigned short ip_fast_csum (unsigned char *iph, unsigned int ihl);
58 54
59/* 55/*
60 * Fold a partial checksum 56 * Fold a partial checksum
61 */ 57 */
62static inline unsigned int csum_fold (unsigned long sum) 58static inline __sum16 csum_fold (__wsum sum)
63{ 59{
64 unsigned int result; 60 unsigned int result;
65 /* 61 /*
@@ -68,7 +64,7 @@ static inline unsigned int csum_fold (unsigned long sum)
68 add %1, %0 H L H+L+C H+L 64 add %1, %0 H L H+L+C H+L
69 */ 65 */
70 asm ("hsw %1, %0; add %1, %0" : "=&r" (result) : "r" (sum)); 66 asm ("hsw %1, %0; add %1, %0" : "=&r" (result) : "r" (sum));
71 return (~result) >> 16; 67 return (__force __sum16)(~result >> 16);
72} 68}
73 69
74 70
@@ -76,10 +72,10 @@ static inline unsigned int csum_fold (unsigned long sum)
76 * computes the checksum of the TCP/UDP pseudo-header 72 * computes the checksum of the TCP/UDP pseudo-header
77 * returns a 16-bit checksum, already complemented 73 * returns a 16-bit checksum, already complemented
78 */ 74 */
79static inline unsigned int 75static inline __wsum
80csum_tcpudp_nofold (unsigned long saddr, unsigned long daddr, 76csum_tcpudp_nofold (__be32 saddr, __be32 daddr,
81 unsigned short len, 77 unsigned short len,
82 unsigned short proto, unsigned int sum) 78 unsigned short proto, __wsum sum)
83{ 79{
84 int __carry; 80 int __carry;
85 __asm__ ("add %2, %0;" 81 __asm__ ("add %2, %0;"
@@ -93,15 +89,15 @@ csum_tcpudp_nofold (unsigned long saddr, unsigned long daddr,
93 "add %1, %0" 89 "add %1, %0"
94 : "=&r" (sum), "=&r" (__carry) 90 : "=&r" (sum), "=&r" (__carry)
95 : "r" (daddr), "r" (saddr), 91 : "r" (daddr), "r" (saddr),
96 "r" (ntohs (len) + (proto << 8)), 92 "r" ((len + proto) << 8),
97 "0" (sum)); 93 "0" (sum));
98 return sum; 94 return sum;
99} 95}
100 96
101static inline unsigned short int 97static inline __sum16
102csum_tcpudp_magic (unsigned long saddr, unsigned long daddr, 98csum_tcpudp_magic (__be32 saddr, __be32 daddr,
103 unsigned short len, 99 unsigned short len,
104 unsigned short proto, unsigned int sum) 100 unsigned short proto, __wsum sum)
105{ 101{
106 return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum)); 102 return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum));
107} 103}
@@ -110,7 +106,7 @@ csum_tcpudp_magic (unsigned long saddr, unsigned long daddr,
110 * this routine is used for miscellaneous IP-like checksums, mainly 106 * this routine is used for miscellaneous IP-like checksums, mainly
111 * in icmp.c 107 * in icmp.c
112 */ 108 */
113extern unsigned short ip_compute_csum (const unsigned char * buff, int len); 109extern __sum16 ip_compute_csum(const void *buff, int len);
114 110
115 111
116#endif /* __V850_CHECKSUM_H__ */ 112#endif /* __V850_CHECKSUM_H__ */
diff --git a/include/asm-v850/device.h b/include/asm-v850/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-v850/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-x86_64/checksum.h b/include/asm-x86_64/checksum.h
index 989469e8e0b7..419fe88a0342 100644
--- a/include/asm-x86_64/checksum.h
+++ b/include/asm-x86_64/checksum.h
@@ -19,15 +19,16 @@
19 * the last step before putting a checksum into a packet. 19 * the last step before putting a checksum into a packet.
20 * Make sure not to mix with 64bit checksums. 20 * Make sure not to mix with 64bit checksums.
21 */ 21 */
22static inline unsigned int csum_fold(unsigned int sum) 22static inline __sum16 csum_fold(__wsum sum)
23{ 23{
24 __asm__( 24 __asm__(
25 " addl %1,%0\n" 25 " addl %1,%0\n"
26 " adcl $0xffff,%0" 26 " adcl $0xffff,%0"
27 : "=r" (sum) 27 : "=r" (sum)
28 : "r" (sum << 16), "0" (sum & 0xffff0000) 28 : "r" ((__force u32)sum << 16),
29 "0" ((__force u32)sum & 0xffff0000)
29 ); 30 );
30 return (~sum) >> 16; 31 return (__force __sum16)(~(__force u32)sum >> 16);
31} 32}
32 33
33/* 34/*
@@ -43,7 +44,7 @@ static inline unsigned int csum_fold(unsigned int sum)
43 * iph: ipv4 header 44 * iph: ipv4 header
44 * ihl: length of header / 4 45 * ihl: length of header / 4
45 */ 46 */
46static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) 47static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
47{ 48{
48 unsigned int sum; 49 unsigned int sum;
49 50
@@ -70,7 +71,7 @@ static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
70 : "=r" (sum), "=r" (iph), "=r" (ihl) 71 : "=r" (sum), "=r" (iph), "=r" (ihl)
71 : "1" (iph), "2" (ihl) 72 : "1" (iph), "2" (ihl)
72 : "memory"); 73 : "memory");
73 return(sum); 74 return (__force __sum16)sum;
74} 75}
75 76
76/** 77/**
@@ -84,16 +85,17 @@ static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl)
84 * Returns the pseudo header checksum the input data. Result is 85 * Returns the pseudo header checksum the input data. Result is
85 * 32bit unfolded. 86 * 32bit unfolded.
86 */ 87 */
87static inline unsigned long 88static inline __wsum
88csum_tcpudp_nofold(unsigned saddr, unsigned daddr, unsigned short len, 89csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
89 unsigned short proto, unsigned int sum) 90 unsigned short proto, __wsum sum)
90{ 91{
91 asm(" addl %1, %0\n" 92 asm(" addl %1, %0\n"
92 " adcl %2, %0\n" 93 " adcl %2, %0\n"
93 " adcl %3, %0\n" 94 " adcl %3, %0\n"
94 " adcl $0, %0\n" 95 " adcl $0, %0\n"
95 : "=r" (sum) 96 : "=r" (sum)
96 : "g" (daddr), "g" (saddr), "g" ((ntohs(len)<<16)+proto*256), "0" (sum)); 97 : "g" (daddr), "g" (saddr),
98 "g" ((len + proto)<<8), "0" (sum));
97 return sum; 99 return sum;
98} 100}
99 101
@@ -109,9 +111,9 @@ csum_tcpudp_nofold(unsigned saddr, unsigned daddr, unsigned short len,
109 * Returns the 16bit pseudo header checksum the input data already 111 * Returns the 16bit pseudo header checksum the input data already
110 * complemented and ready to be filled in. 112 * complemented and ready to be filled in.
111 */ 113 */
112static inline unsigned short int 114static inline __sum16
113csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, 115csum_tcpudp_magic(__be32 saddr, __be32 daddr,
114 unsigned short len, unsigned short proto, unsigned int sum) 116 unsigned short len, unsigned short proto, __wsum sum)
115{ 117{
116 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 118 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
117} 119}
@@ -126,25 +128,25 @@ csum_tcpudp_magic(unsigned long saddr, unsigned long daddr,
126 * Before filling it in it needs to be csum_fold()'ed. 128 * Before filling it in it needs to be csum_fold()'ed.
127 * buff should be aligned to a 64bit boundary if possible. 129 * buff should be aligned to a 64bit boundary if possible.
128 */ 130 */
129extern unsigned int csum_partial(const unsigned char *buff, unsigned len, unsigned int sum); 131extern __wsum csum_partial(const void *buff, int len, __wsum sum);
130 132
131#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1 133#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 1
132#define HAVE_CSUM_COPY_USER 1 134#define HAVE_CSUM_COPY_USER 1
133 135
134 136
135/* Do not call this directly. Use the wrappers below */ 137/* Do not call this directly. Use the wrappers below */
136extern unsigned long csum_partial_copy_generic(const unsigned char *src, const unsigned char *dst, 138extern __wsum csum_partial_copy_generic(const void *src, const void *dst,
137 unsigned len, 139 int len,
138 unsigned sum, 140 __wsum sum,
139 int *src_err_ptr, int *dst_err_ptr); 141 int *src_err_ptr, int *dst_err_ptr);
140 142
141 143
142extern unsigned int csum_partial_copy_from_user(const unsigned char __user *src, unsigned char *dst, 144extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
143 int len, unsigned int isum, int *errp); 145 int len, __wsum isum, int *errp);
144extern unsigned int csum_partial_copy_to_user(const unsigned char *src, unsigned char __user *dst, 146extern __wsum csum_partial_copy_to_user(const void *src, void __user *dst,
145 int len, unsigned int isum, int *errp); 147 int len, __wsum isum, int *errp);
146extern unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned char *dst, int len, 148extern __wsum csum_partial_copy_nocheck(const void *src, void *dst, int len,
147 unsigned int sum); 149 __wsum sum);
148 150
149/* Old names. To be removed. */ 151/* Old names. To be removed. */
150#define csum_and_copy_to_user csum_partial_copy_to_user 152#define csum_and_copy_to_user csum_partial_copy_to_user
@@ -158,7 +160,7 @@ extern unsigned int csum_partial_copy_nocheck(const unsigned char *src, unsigned
158 * Returns the 16bit folded/inverted checksum of the passed buffer. 160 * Returns the 16bit folded/inverted checksum of the passed buffer.
159 * Ready to fill in. 161 * Ready to fill in.
160 */ 162 */
161extern unsigned short ip_compute_csum(unsigned char * buff, int len); 163extern __sum16 ip_compute_csum(const void *buff, int len);
162 164
163/** 165/**
164 * csum_ipv6_magic - Compute checksum of an IPv6 pseudo header. 166 * csum_ipv6_magic - Compute checksum of an IPv6 pseudo header.
@@ -176,9 +178,9 @@ extern unsigned short ip_compute_csum(unsigned char * buff, int len);
176struct in6_addr; 178struct in6_addr;
177 179
178#define _HAVE_ARCH_IPV6_CSUM 1 180#define _HAVE_ARCH_IPV6_CSUM 1
179extern unsigned short 181extern __sum16
180csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, 182csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr,
181 __u32 len, unsigned short proto, unsigned int sum); 183 __u32 len, unsigned short proto, __wsum sum);
182 184
183static inline unsigned add32_with_carry(unsigned a, unsigned b) 185static inline unsigned add32_with_carry(unsigned a, unsigned b)
184{ 186{
diff --git a/include/asm-x86_64/device.h b/include/asm-x86_64/device.h
new file mode 100644
index 000000000000..3afa03f33a36
--- /dev/null
+++ b/include/asm-x86_64/device.h
@@ -0,0 +1,15 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#ifndef _ASM_X86_64_DEVICE_H
7#define _ASM_X86_64_DEVICE_H
8
9struct dev_archdata {
10#ifdef CONFIG_ACPI
11 void *acpi_handle;
12#endif
13};
14
15#endif /* _ASM_X86_64_DEVICE_H */
diff --git a/include/asm-xtensa/checksum.h b/include/asm-xtensa/checksum.h
index 03114f8d1e18..5435aff9a4b7 100644
--- a/include/asm-xtensa/checksum.h
+++ b/include/asm-xtensa/checksum.h
@@ -26,7 +26,7 @@
26 * 26 *
27 * it's best to have buff aligned on a 32-bit boundary 27 * it's best to have buff aligned on a 32-bit boundary
28 */ 28 */
29asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); 29asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
30 30
31/* 31/*
32 * the same as csum_partial, but copies from src while it 32 * the same as csum_partial, but copies from src while it
@@ -36,7 +36,7 @@ asmlinkage unsigned int csum_partial(const unsigned char * buff, int len, unsign
36 * better 64-bit) boundary 36 * better 64-bit) boundary
37 */ 37 */
38 38
39asmlinkage unsigned int csum_partial_copy_generic( const char *src, char *dst, int len, int sum, 39asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst, int len, __wsum sum,
40 int *src_err_ptr, int *dst_err_ptr); 40 int *src_err_ptr, int *dst_err_ptr);
41 41
42/* 42/*
@@ -46,34 +46,25 @@ asmlinkage unsigned int csum_partial_copy_generic( const char *src, char *dst, i
46 * If you use these functions directly please don't forget the access_ok(). 46 * If you use these functions directly please don't forget the access_ok().
47 */ 47 */
48static inline 48static inline
49unsigned int csum_partial_copy_nocheck ( const char *src, char *dst, 49__wsum csum_partial_copy_nocheck(const void *src, void *dst,
50 int len, int sum) 50 int len, __wsum sum)
51{ 51{
52 return csum_partial_copy_generic ( src, dst, len, sum, NULL, NULL); 52 return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL);
53} 53}
54 54
55static inline 55static inline
56unsigned int csum_partial_copy_from_user ( const char *src, char *dst, 56__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
57 int len, int sum, int *err_ptr) 57 int len, __wsum sum, int *err_ptr)
58{ 58{
59 return csum_partial_copy_generic ( src, dst, len, sum, err_ptr, NULL); 59 return csum_partial_copy_generic((__force const void *)src, dst,
60 len, sum, err_ptr, NULL);
60} 61}
61 62
62/* 63/*
63 * These are the old (and unsafe) way of doing checksums, a warning message will be
64 * printed if they are used and an exeption occurs.
65 *
66 * these functions should go away after some time.
67 */
68
69#define csum_partial_copy_fromuser csum_partial_copy
70unsigned int csum_partial_copy( const char *src, char *dst, int len, int sum);
71
72/*
73 * Fold a partial checksum 64 * Fold a partial checksum
74 */ 65 */
75 66
76static __inline__ unsigned int csum_fold(unsigned int sum) 67static __inline__ __sum16 csum_fold(__wsum sum)
77{ 68{
78 unsigned int __dummy; 69 unsigned int __dummy;
79 __asm__("extui %1, %0, 16, 16\n\t" 70 __asm__("extui %1, %0, 16, 16\n\t"
@@ -87,14 +78,14 @@ static __inline__ unsigned int csum_fold(unsigned int sum)
87 "extui %0, %0, 0, 16\n\t" 78 "extui %0, %0, 0, 16\n\t"
88 : "=r" (sum), "=&r" (__dummy) 79 : "=r" (sum), "=&r" (__dummy)
89 : "0" (sum)); 80 : "0" (sum));
90 return sum; 81 return (__force __sum16)sum;
91} 82}
92 83
93/* 84/*
94 * This is a version of ip_compute_csum() optimized for IP headers, 85 * This is a version of ip_compute_csum() optimized for IP headers,
95 * which always checksum on 4 octet boundaries. 86 * which always checksum on 4 octet boundaries.
96 */ 87 */
97static __inline__ unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) 88static __inline__ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
98{ 89{
99 unsigned int sum, tmp, endaddr; 90 unsigned int sum, tmp, endaddr;
100 91
@@ -127,17 +118,16 @@ static __inline__ unsigned short ip_fast_csum(unsigned char * iph, unsigned int
127 return csum_fold(sum); 118 return csum_fold(sum);
128} 119}
129 120
130static __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr, 121static __inline__ __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
131 unsigned long daddr,
132 unsigned short len, 122 unsigned short len,
133 unsigned short proto, 123 unsigned short proto,
134 unsigned int sum) 124 __wsum sum)
135{ 125{
136 126
137#ifdef __XTENSA_EL__ 127#ifdef __XTENSA_EL__
138 unsigned long len_proto = (ntohs(len)<<16)+proto*256; 128 unsigned long len_proto = (len + proto) << 8;
139#elif defined(__XTENSA_EB__) 129#elif defined(__XTENSA_EB__)
140 unsigned long len_proto = (proto<<16)+len; 130 unsigned long len_proto = len + proto;
141#else 131#else
142# error processor byte order undefined! 132# error processor byte order undefined!
143#endif 133#endif
@@ -162,11 +152,10 @@ static __inline__ unsigned long csum_tcpudp_nofold(unsigned long saddr,
162 * computes the checksum of the TCP/UDP pseudo-header 152 * computes the checksum of the TCP/UDP pseudo-header
163 * returns a 16-bit checksum, already complemented 153 * returns a 16-bit checksum, already complemented
164 */ 154 */
165static __inline__ unsigned short int csum_tcpudp_magic(unsigned long saddr, 155static __inline__ __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
166 unsigned long daddr,
167 unsigned short len, 156 unsigned short len,
168 unsigned short proto, 157 unsigned short proto,
169 unsigned int sum) 158 __wsum sum)
170{ 159{
171 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum)); 160 return csum_fold(csum_tcpudp_nofold(saddr,daddr,len,proto,sum));
172} 161}
@@ -176,17 +165,16 @@ static __inline__ unsigned short int csum_tcpudp_magic(unsigned long saddr,
176 * in icmp.c 165 * in icmp.c
177 */ 166 */
178 167
179static __inline__ unsigned short ip_compute_csum(unsigned char * buff, int len) 168static __inline__ __sum16 ip_compute_csum(const void *buff, int len)
180{ 169{
181 return csum_fold (csum_partial(buff, len, 0)); 170 return csum_fold (csum_partial(buff, len, 0));
182} 171}
183 172
184#define _HAVE_ARCH_IPV6_CSUM 173#define _HAVE_ARCH_IPV6_CSUM
185static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 174static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
186 struct in6_addr *daddr, 175 const struct in6_addr *daddr,
187 __u32 len, 176 __u32 len, unsigned short proto,
188 unsigned short proto, 177 __wsum sum)
189 unsigned int sum)
190{ 178{
191 unsigned int __dummy; 179 unsigned int __dummy;
192 __asm__("l32i %1, %2, 0\n\t" 180 __asm__("l32i %1, %2, 0\n\t"
@@ -248,8 +236,8 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
248 * Copy and checksum to user 236 * Copy and checksum to user
249 */ 237 */
250#define HAVE_CSUM_COPY_USER 238#define HAVE_CSUM_COPY_USER
251static __inline__ unsigned int csum_and_copy_to_user (const char *src, char *dst, 239static __inline__ __wsum csum_and_copy_to_user(const void *src, void __user *dst,
252 int len, int sum, int *err_ptr) 240 int len, __wsum sum, int *err_ptr)
253{ 241{
254 if (access_ok(VERIFY_WRITE, dst, len)) 242 if (access_ok(VERIFY_WRITE, dst, len))
255 return csum_partial_copy_generic(src, dst, len, sum, NULL, err_ptr); 243 return csum_partial_copy_generic(src, dst, len, sum, NULL, err_ptr);
@@ -257,6 +245,6 @@ static __inline__ unsigned int csum_and_copy_to_user (const char *src, char *dst
257 if (len) 245 if (len)
258 *err_ptr = -EFAULT; 246 *err_ptr = -EFAULT;
259 247
260 return -1; /* invalid checksum */ 248 return (__force __wsum)-1; /* invalid checksum */
261} 249}
262#endif 250#endif
diff --git a/include/asm-xtensa/device.h b/include/asm-xtensa/device.h
new file mode 100644
index 000000000000..d8f9872b0e2d
--- /dev/null
+++ b/include/asm-xtensa/device.h
@@ -0,0 +1,7 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index a1155a2beb32..ff433126361f 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -60,8 +60,6 @@ header-y += fadvise.h
60header-y += fd.h 60header-y += fd.h
61header-y += fdreg.h 61header-y += fdreg.h
62header-y += fib_rules.h 62header-y += fib_rules.h
63header-y += ftape-header-segment.h
64header-y += ftape-vendors.h
65header-y += fuse.h 63header-y += fuse.h
66header-y += futex.h 64header-y += futex.h
67header-y += genetlink.h 65header-y += genetlink.h
@@ -193,7 +191,6 @@ unifdef-y += cuda.h
193unifdef-y += cyclades.h 191unifdef-y += cyclades.h
194unifdef-y += dccp.h 192unifdef-y += dccp.h
195unifdef-y += dirent.h 193unifdef-y += dirent.h
196unifdef-y += divert.h
197unifdef-y += dlm.h 194unifdef-y += dlm.h
198unifdef-y += elfcore.h 195unifdef-y += elfcore.h
199unifdef-y += errno.h 196unifdef-y += errno.h
@@ -207,7 +204,6 @@ unifdef-y += fcntl.h
207unifdef-y += filter.h 204unifdef-y += filter.h
208unifdef-y += flat.h 205unifdef-y += flat.h
209unifdef-y += fs.h 206unifdef-y += fs.h
210unifdef-y += ftape.h
211unifdef-y += gameport.h 207unifdef-y += gameport.h
212unifdef-y += generic_serial.h 208unifdef-y += generic_serial.h
213unifdef-y += genhd.h 209unifdef-y += genhd.h
@@ -342,6 +338,5 @@ unifdef-y += wait.h
342unifdef-y += wanrouter.h 338unifdef-y += wanrouter.h
343unifdef-y += watchdog.h 339unifdef-y += watchdog.h
344unifdef-y += xfrm.h 340unifdef-y += xfrm.h
345unifdef-y += zftape.h
346 341
347objhdr-y += version.h 342objhdr-y += version.h
diff --git a/include/linux/atmarp.h b/include/linux/atmarp.h
index 24f82338f59a..ee108f9e9cb7 100644
--- a/include/linux/atmarp.h
+++ b/include/linux/atmarp.h
@@ -37,7 +37,7 @@ enum atmarp_ctrl_type {
37struct atmarp_ctrl { 37struct atmarp_ctrl {
38 enum atmarp_ctrl_type type; /* message type */ 38 enum atmarp_ctrl_type type; /* message type */
39 int itf_num;/* interface number (if present) */ 39 int itf_num;/* interface number (if present) */
40 uint32_t ip; /* IP address (act_need only) */ 40 __be32 ip; /* IP address (act_need only) */
41}; 41};
42 42
43#endif 43#endif
diff --git a/include/linux/atmbr2684.h b/include/linux/atmbr2684.h
index 7981b733f1ef..969fb6c9e1cc 100644
--- a/include/linux/atmbr2684.h
+++ b/include/linux/atmbr2684.h
@@ -86,8 +86,8 @@ struct atm_backend_br2684 {
86 * efficient per-if in/out filters, this support will be removed 86 * efficient per-if in/out filters, this support will be removed
87 */ 87 */
88struct br2684_filter { 88struct br2684_filter {
89 __u32 prefix; /* network byte order */ 89 __be32 prefix; /* network byte order */
90 __u32 netmask; /* 0 = disable filter */ 90 __be32 netmask; /* 0 = disable filter */
91}; 91};
92 92
93struct br2684_filter_set { 93struct br2684_filter_set {
diff --git a/include/linux/atmmpc.h b/include/linux/atmmpc.h
index 5fbfa68136d3..ea1650425a12 100644
--- a/include/linux/atmmpc.h
+++ b/include/linux/atmmpc.h
@@ -13,7 +13,7 @@
13 13
14struct atmmpc_ioc { 14struct atmmpc_ioc {
15 int dev_num; 15 int dev_num;
16 uint32_t ipaddr; /* the IP address of the shortcut */ 16 __be32 ipaddr; /* the IP address of the shortcut */
17 int type; /* ingress or egress */ 17 int type; /* ingress or egress */
18}; 18};
19 19
@@ -21,8 +21,8 @@ typedef struct in_ctrl_info {
21 uint8_t Last_NHRP_CIE_code; 21 uint8_t Last_NHRP_CIE_code;
22 uint8_t Last_Q2931_cause_value; 22 uint8_t Last_Q2931_cause_value;
23 uint8_t eg_MPC_ATM_addr[ATM_ESA_LEN]; 23 uint8_t eg_MPC_ATM_addr[ATM_ESA_LEN];
24 uint32_t tag; 24 __be32 tag;
25 uint32_t in_dst_ip; /* IP address this ingress MPC sends packets to */ 25 __be32 in_dst_ip; /* IP address this ingress MPC sends packets to */
26 uint16_t holding_time; 26 uint16_t holding_time;
27 uint32_t request_id; 27 uint32_t request_id;
28} in_ctrl_info; 28} in_ctrl_info;
@@ -30,10 +30,10 @@ typedef struct in_ctrl_info {
30typedef struct eg_ctrl_info { 30typedef struct eg_ctrl_info {
31 uint8_t DLL_header[256]; 31 uint8_t DLL_header[256];
32 uint8_t DH_length; 32 uint8_t DH_length;
33 uint32_t cache_id; 33 __be32 cache_id;
34 uint32_t tag; 34 __be32 tag;
35 uint32_t mps_ip; 35 __be32 mps_ip;
36 uint32_t eg_dst_ip; /* IP address to which ingress MPC sends packets */ 36 __be32 eg_dst_ip; /* IP address to which ingress MPC sends packets */
37 uint8_t in_MPC_data_ATM_addr[ATM_ESA_LEN]; 37 uint8_t in_MPC_data_ATM_addr[ATM_ESA_LEN];
38 uint16_t holding_time; 38 uint16_t holding_time;
39} eg_ctrl_info; 39} eg_ctrl_info;
@@ -49,7 +49,7 @@ struct mpc_parameters {
49 49
50struct k_message { 50struct k_message {
51 uint16_t type; 51 uint16_t type;
52 uint32_t ip_mask; 52 __be32 ip_mask;
53 uint8_t MPS_ctrl[ATM_ESA_LEN]; 53 uint8_t MPS_ctrl[ATM_ESA_LEN];
54 union { 54 union {
55 in_ctrl_info in_info; 55 in_ctrl_info in_info;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 7bfcde2d5578..e1c7286165ff 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -678,10 +678,11 @@ extern void __blk_stop_queue(request_queue_t *q);
678extern void blk_run_queue(request_queue_t *); 678extern void blk_run_queue(request_queue_t *);
679extern void blk_start_queueing(request_queue_t *); 679extern void blk_start_queueing(request_queue_t *);
680extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *); 680extern void blk_queue_activity_fn(request_queue_t *, activity_fn *, void *);
681extern int blk_rq_map_user(request_queue_t *, struct request *, void __user *, unsigned int); 681extern int blk_rq_map_user(request_queue_t *, struct request *, void __user *, unsigned long);
682extern int blk_rq_unmap_user(struct bio *, unsigned int); 682extern int blk_rq_unmap_user(struct request *);
683extern int blk_rq_map_kern(request_queue_t *, struct request *, void *, unsigned int, gfp_t); 683extern int blk_rq_map_kern(request_queue_t *, struct request *, void *, unsigned int, gfp_t);
684extern int blk_rq_map_user_iov(request_queue_t *, struct request *, struct sg_iovec *, int); 684extern int blk_rq_map_user_iov(request_queue_t *, struct request *,
685 struct sg_iovec *, int, unsigned int);
685extern int blk_execute_rq(request_queue_t *, struct gendisk *, 686extern int blk_execute_rq(request_queue_t *, struct gendisk *,
686 struct request *, int); 687 struct request *, int);
687extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *, 688extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *,
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index b99a714fcac6..3680ff9a30ed 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -50,6 +50,15 @@ enum blktrace_act {
50}; 50};
51 51
52/* 52/*
53 * Notify events.
54 */
55enum blktrace_notify {
56 __BLK_TN_PROCESS = 0, /* establish pid/name mapping */
57 __BLK_TN_TIMESTAMP, /* include system clock */
58};
59
60
61/*
53 * Trace actions in full. Additionally, read or write is masked 62 * Trace actions in full. Additionally, read or write is masked
54 */ 63 */
55#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE)) 64#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE))
@@ -68,6 +77,9 @@ enum blktrace_act {
68#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) 77#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
69#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) 78#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
70 79
80#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
81#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
82
71#define BLK_IO_TRACE_MAGIC 0x65617400 83#define BLK_IO_TRACE_MAGIC 0x65617400
72#define BLK_IO_TRACE_VERSION 0x07 84#define BLK_IO_TRACE_VERSION 0x07
73 85
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 53553c99cad6..ed6cc8962d87 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -30,7 +30,7 @@ struct dccp_hdr {
30#else 30#else
31#error "Adjust your <asm/byteorder.h> defines" 31#error "Adjust your <asm/byteorder.h> defines"
32#endif 32#endif
33 __u16 dccph_checksum; 33 __sum16 dccph_checksum;
34#if defined(__LITTLE_ENDIAN_BITFIELD) 34#if defined(__LITTLE_ENDIAN_BITFIELD)
35 __u8 dccph_x:1, 35 __u8 dccph_x:1,
36 dccph_type:4, 36 dccph_type:4,
@@ -175,17 +175,21 @@ enum {
175 DCCPC_CCID3 = 3, 175 DCCPC_CCID3 = 3,
176}; 176};
177 177
178/* DCCP features */ 178/* DCCP features (RFC 4340 section 6.4) */
179enum { 179 enum {
180 DCCPF_RESERVED = 0, 180 DCCPF_RESERVED = 0,
181 DCCPF_CCID = 1, 181 DCCPF_CCID = 1,
182 DCCPF_SEQUENCE_WINDOW = 3, 182 DCCPF_SHORT_SEQNOS = 2, /* XXX: not yet implemented */
183 DCCPF_ACK_RATIO = 5, 183 DCCPF_SEQUENCE_WINDOW = 3,
184 DCCPF_SEND_ACK_VECTOR = 6, 184 DCCPF_ECN_INCAPABLE = 4, /* XXX: not yet implemented */
185 DCCPF_SEND_NDP_COUNT = 7, 185 DCCPF_ACK_RATIO = 5,
186 /* 10-127 reserved */ 186 DCCPF_SEND_ACK_VECTOR = 6,
187 DCCPF_MIN_CCID_SPECIFIC = 128, 187 DCCPF_SEND_NDP_COUNT = 7,
188 DCCPF_MAX_CCID_SPECIFIC = 255, 188 DCCPF_MIN_CSUM_COVER = 8,
189 DCCPF_DATA_CHECKSUM = 9, /* XXX: not yet implemented */
190 /* 10-127 reserved */
191 DCCPF_MIN_CCID_SPECIFIC = 128,
192 DCCPF_MAX_CCID_SPECIFIC = 255,
189}; 193};
190 194
191/* this structure is argument to DCCP_SOCKOPT_CHANGE_X */ 195/* this structure is argument to DCCP_SOCKOPT_CHANGE_X */
@@ -196,13 +200,16 @@ struct dccp_so_feat {
196}; 200};
197 201
198/* DCCP socket options */ 202/* DCCP socket options */
199#define DCCP_SOCKOPT_PACKET_SIZE 1 203#define DCCP_SOCKOPT_PACKET_SIZE 1 /* XXX deprecated, without effect */
200#define DCCP_SOCKOPT_SERVICE 2 204#define DCCP_SOCKOPT_SERVICE 2
201#define DCCP_SOCKOPT_CHANGE_L 3 205#define DCCP_SOCKOPT_CHANGE_L 3
202#define DCCP_SOCKOPT_CHANGE_R 4 206#define DCCP_SOCKOPT_CHANGE_R 4
207#define DCCP_SOCKOPT_SEND_CSCOV 10
208#define DCCP_SOCKOPT_RECV_CSCOV 11
203#define DCCP_SOCKOPT_CCID_RX_INFO 128 209#define DCCP_SOCKOPT_CCID_RX_INFO 128
204#define DCCP_SOCKOPT_CCID_TX_INFO 192 210#define DCCP_SOCKOPT_CCID_TX_INFO 192
205 211
212/* maximum number of services provided on the same listening port */
206#define DCCP_SERVICE_LIST_MAX_LEN 32 213#define DCCP_SERVICE_LIST_MAX_LEN 32
207 214
208#ifdef __KERNEL__ 215#ifdef __KERNEL__
@@ -256,6 +263,13 @@ static inline struct dccp_hdr *dccp_hdr(const struct sk_buff *skb)
256 return (struct dccp_hdr *)skb->h.raw; 263 return (struct dccp_hdr *)skb->h.raw;
257} 264}
258 265
266static inline struct dccp_hdr *dccp_zeroed_hdr(struct sk_buff *skb, int headlen)
267{
268 skb->h.raw = skb_push(skb, headlen);
269 memset(skb->h.raw, 0, headlen);
270 return dccp_hdr(skb);
271}
272
259static inline struct dccp_hdr_ext *dccp_hdrx(const struct sk_buff *skb) 273static inline struct dccp_hdr_ext *dccp_hdrx(const struct sk_buff *skb)
260{ 274{
261 return (struct dccp_hdr_ext *)(skb->h.raw + sizeof(struct dccp_hdr)); 275 return (struct dccp_hdr_ext *)(skb->h.raw + sizeof(struct dccp_hdr));
@@ -342,6 +356,9 @@ static inline unsigned int dccp_hdr_len(const struct sk_buff *skb)
342 * @dccpms_ccid - Congestion Control Id (CCID) (section 10) 356 * @dccpms_ccid - Congestion Control Id (CCID) (section 10)
343 * @dccpms_send_ack_vector - Send Ack Vector Feature (section 11.5) 357 * @dccpms_send_ack_vector - Send Ack Vector Feature (section 11.5)
344 * @dccpms_send_ndp_count - Send NDP Count Feature (7.7.2) 358 * @dccpms_send_ndp_count - Send NDP Count Feature (7.7.2)
359 * @dccpms_ack_ratio - Ack Ratio Feature (section 11.3)
360 * @dccpms_pending - List of features being negotiated
361 * @dccpms_conf -
345 */ 362 */
346struct dccp_minisock { 363struct dccp_minisock {
347 __u64 dccpms_sequence_window; 364 __u64 dccpms_sequence_window;
@@ -439,12 +456,25 @@ struct dccp_ackvec;
439 * @dccps_gss - greatest sequence number sent 456 * @dccps_gss - greatest sequence number sent
440 * @dccps_gsr - greatest valid sequence number received 457 * @dccps_gsr - greatest valid sequence number received
441 * @dccps_gar - greatest valid ack number received on a non-Sync; initialized to %dccps_iss 458 * @dccps_gar - greatest valid ack number received on a non-Sync; initialized to %dccps_iss
459 * @dccps_service - first (passive sock) or unique (active sock) service code
460 * @dccps_service_list - second .. last service code on passive socket
442 * @dccps_timestamp_time - time of latest TIMESTAMP option 461 * @dccps_timestamp_time - time of latest TIMESTAMP option
443 * @dccps_timestamp_echo - latest timestamp received on a TIMESTAMP option 462 * @dccps_timestamp_echo - latest timestamp received on a TIMESTAMP option
444 * @dccps_packet_size - Set thru setsockopt 463 * @dccps_l_ack_ratio -
445 * @dccps_role - Role of this sock, one of %dccp_role 464 * @dccps_r_ack_ratio -
465 * @dccps_pcslen - sender partial checksum coverage (via sockopt)
466 * @dccps_pcrlen - receiver partial checksum coverage (via sockopt)
446 * @dccps_ndp_count - number of Non Data Packets since last data packet 467 * @dccps_ndp_count - number of Non Data Packets since last data packet
468 * @dccps_mss_cache -
469 * @dccps_minisock -
447 * @dccps_hc_rx_ackvec - rx half connection ack vector 470 * @dccps_hc_rx_ackvec - rx half connection ack vector
471 * @dccps_hc_rx_ccid -
472 * @dccps_hc_tx_ccid -
473 * @dccps_options_received -
474 * @dccps_epoch -
475 * @dccps_role - Role of this sock, one of %dccp_role
476 * @dccps_hc_rx_insert_options -
477 * @dccps_hc_tx_insert_options -
448 * @dccps_xmit_timer - timer for when CCID is not ready to send 478 * @dccps_xmit_timer - timer for when CCID is not ready to send
449 */ 479 */
450struct dccp_sock { 480struct dccp_sock {
@@ -464,9 +494,10 @@ struct dccp_sock {
464 struct dccp_service_list *dccps_service_list; 494 struct dccp_service_list *dccps_service_list;
465 struct timeval dccps_timestamp_time; 495 struct timeval dccps_timestamp_time;
466 __u32 dccps_timestamp_echo; 496 __u32 dccps_timestamp_echo;
467 __u32 dccps_packet_size;
468 __u16 dccps_l_ack_ratio; 497 __u16 dccps_l_ack_ratio;
469 __u16 dccps_r_ack_ratio; 498 __u16 dccps_r_ack_ratio;
499 __u16 dccps_pcslen;
500 __u16 dccps_pcrlen;
470 unsigned long dccps_ndp_count; 501 unsigned long dccps_ndp_count;
471 __u32 dccps_mss_cache; 502 __u32 dccps_mss_cache;
472 struct dccp_minisock dccps_minisock; 503 struct dccp_minisock dccps_minisock;
diff --git a/include/linux/device.h b/include/linux/device.h
index 9d4f6a963936..583a341e016c 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -21,6 +21,7 @@
21#include <linux/pm.h> 21#include <linux/pm.h>
22#include <asm/semaphore.h> 22#include <asm/semaphore.h>
23#include <asm/atomic.h> 23#include <asm/atomic.h>
24#include <asm/device.h>
24 25
25#define DEVICE_NAME_SIZE 50 26#define DEVICE_NAME_SIZE 50
26#define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */ 27#define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */
@@ -42,6 +43,8 @@ struct bus_type {
42 struct klist klist_devices; 43 struct klist klist_devices;
43 struct klist klist_drivers; 44 struct klist klist_drivers;
44 45
46 struct blocking_notifier_head bus_notifier;
47
45 struct bus_attribute * bus_attrs; 48 struct bus_attribute * bus_attrs;
46 struct device_attribute * dev_attrs; 49 struct device_attribute * dev_attrs;
47 struct driver_attribute * drv_attrs; 50 struct driver_attribute * drv_attrs;
@@ -75,6 +78,29 @@ int __must_check bus_for_each_drv(struct bus_type *bus,
75 struct device_driver *start, void *data, 78 struct device_driver *start, void *data,
76 int (*fn)(struct device_driver *, void *)); 79 int (*fn)(struct device_driver *, void *));
77 80
81/*
82 * Bus notifiers: Get notified of addition/removal of devices
83 * and binding/unbinding of drivers to devices.
84 * In the long run, it should be a replacement for the platform
85 * notify hooks.
86 */
87struct notifier_block;
88
89extern int bus_register_notifier(struct bus_type *bus,
90 struct notifier_block *nb);
91extern int bus_unregister_notifier(struct bus_type *bus,
92 struct notifier_block *nb);
93
94/* All 4 notifers below get called with the target struct device *
95 * as an argument. Note that those functions are likely to be called
96 * with the device semaphore held in the core, so be careful.
97 */
98#define BUS_NOTIFY_ADD_DEVICE 0x00000001 /* device added */
99#define BUS_NOTIFY_DEL_DEVICE 0x00000002 /* device removed */
100#define BUS_NOTIFY_BOUND_DRIVER 0x00000003 /* driver bound to device */
101#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be
102 unbound */
103
78/* driverfs interface for exporting bus attributes */ 104/* driverfs interface for exporting bus attributes */
79 105
80struct bus_attribute { 106struct bus_attribute {
@@ -343,8 +369,6 @@ struct device {
343 void *driver_data; /* data private to the driver */ 369 void *driver_data; /* data private to the driver */
344 void *platform_data; /* Platform specific data, device 370 void *platform_data; /* Platform specific data, device
345 core doesn't touch it */ 371 core doesn't touch it */
346 void *firmware_data; /* Firmware specific data (e.g. ACPI,
347 BIOS data),reserved for device core*/
348 struct dev_pm_info power; 372 struct dev_pm_info power;
349 373
350 u64 *dma_mask; /* dma mask (if dma'able device) */ 374 u64 *dma_mask; /* dma mask (if dma'able device) */
@@ -358,6 +382,8 @@ struct device {
358 382
359 struct dma_coherent_mem *dma_mem; /* internal for coherent mem 383 struct dma_coherent_mem *dma_mem; /* internal for coherent mem
360 override */ 384 override */
385 /* arch specific additions */
386 struct dev_archdata archdata;
361 387
362 /* class_device migration path */ 388 /* class_device migration path */
363 struct list_head node; 389 struct list_head node;
@@ -395,7 +421,10 @@ extern int __must_check device_add(struct device * dev);
395extern void device_del(struct device * dev); 421extern void device_del(struct device * dev);
396extern int device_for_each_child(struct device *, void *, 422extern int device_for_each_child(struct device *, void *,
397 int (*fn)(struct device *, void *)); 423 int (*fn)(struct device *, void *));
424extern struct device *device_find_child(struct device *, void *data,
425 int (*match)(struct device *, void *));
398extern int device_rename(struct device *dev, char *new_name); 426extern int device_rename(struct device *dev, char *new_name);
427extern int device_move(struct device *dev, struct device *new_parent);
399 428
400/* 429/*
401 * Manual binding of a device to driver. See drivers/base/bus.c 430 * Manual binding of a device to driver. See drivers/base/bus.c
@@ -415,8 +444,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
415 __attribute__((format(printf,4,5))); 444 __attribute__((format(printf,4,5)));
416extern void device_destroy(struct class *cls, dev_t devt); 445extern void device_destroy(struct class *cls, dev_t devt);
417 446
418extern int virtual_device_parent(struct device *dev);
419
420/* 447/*
421 * Platform "fixup" functions - allow the platform to have their say 448 * Platform "fixup" functions - allow the platform to have their say
422 * about devices and actions that the general device layer doesn't 449 * about devices and actions that the general device layer doesn't
diff --git a/include/linux/divert.h b/include/linux/divert.h
deleted file mode 100644
index 8fb4e9de6843..000000000000
--- a/include/linux/divert.h
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * Frame Diversion, Benoit Locher <Benoit.Locher@skf.com>
3 *
4 * Changes:
5 * 06/09/2000 BL: initial version
6 *
7 */
8
9#ifndef _LINUX_DIVERT_H
10#define _LINUX_DIVERT_H
11
12#include <asm/types.h>
13
14#define MAX_DIVERT_PORTS 8 /* Max number of ports to divert (tcp, udp) */
15
16/* Divertable protocols */
17#define DIVERT_PROTO_NONE 0x0000
18#define DIVERT_PROTO_IP 0x0001
19#define DIVERT_PROTO_ICMP 0x0002
20#define DIVERT_PROTO_TCP 0x0004
21#define DIVERT_PROTO_UDP 0x0008
22
23/*
24 * This is an Ethernet Frame Diverter option block
25 */
26struct divert_blk
27{
28 int divert; /* are we active */
29 unsigned int protos; /* protocols */
30 __u16 tcp_dst[MAX_DIVERT_PORTS]; /* specific tcp dst ports to divert */
31 __u16 tcp_src[MAX_DIVERT_PORTS]; /* specific tcp src ports to divert */
32 __u16 udp_dst[MAX_DIVERT_PORTS]; /* specific udp dst ports to divert */
33 __u16 udp_src[MAX_DIVERT_PORTS]; /* specific udp src ports to divert */
34};
35
36/*
37 * Diversion control block, for configuration with the userspace tool
38 * divert
39 */
40
41typedef union _divert_cf_arg
42{
43 __s16 int16;
44 __u16 uint16;
45 __s32 int32;
46 __u32 uint32;
47 __s64 int64;
48 __u64 uint64;
49 void __user *ptr;
50} divert_cf_arg;
51
52
53struct divert_cf
54{
55 int cmd; /* Command */
56 divert_cf_arg arg1,
57 arg2,
58 arg3;
59 int dev_index; /* device index (eth0=0, etc...) */
60};
61
62
63/* Diversion commands */
64#define DIVCMD_DIVERT 1 /* ENABLE/DISABLE diversion */
65#define DIVCMD_IP 2 /* ENABLE/DISABLE whold IP diversion */
66#define DIVCMD_TCP 3 /* ENABLE/DISABLE whold TCP diversion */
67#define DIVCMD_TCPDST 4 /* ADD/REMOVE TCP DST port for diversion */
68#define DIVCMD_TCPSRC 5 /* ADD/REMOVE TCP SRC port for diversion */
69#define DIVCMD_UDP 6 /* ENABLE/DISABLE whole UDP diversion */
70#define DIVCMD_UDPDST 7 /* ADD/REMOVE UDP DST port for diversion */
71#define DIVCMD_UDPSRC 8 /* ADD/REMOVE UDP SRC port for diversion */
72#define DIVCMD_ICMP 9 /* ENABLE/DISABLE whole ICMP diversion */
73#define DIVCMD_GETSTATUS 10 /* GET the status of the diverter */
74#define DIVCMD_RESET 11 /* Reset the diverter on the specified dev */
75#define DIVCMD_GETVERSION 12 /* Retrieve the diverter code version (char[32]) */
76
77/* General syntax of the commands:
78 *
79 * DIVCMD_xxxxxx(arg1, arg2, arg3, dev_index)
80 *
81 * SIOCSIFDIVERT:
82 * DIVCMD_DIVERT(DIVARG1_ENABLE|DIVARG1_DISABLE, , ,ifindex)
83 * DIVCMD_IP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
84 * DIVCMD_TCP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
85 * DIVCMD_TCPDST(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
86 * DIVCMD_TCPSRC(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
87 * DIVCMD_UDP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
88 * DIVCMD_UDPDST(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
89 * DIVCMD_UDPSRC(DIVARG1_ADD|DIVARG1_REMOVE, port, , ifindex)
90 * DIVCMD_ICMP(DIVARG1_ENABLE|DIVARG1_DISABLE, , , ifindex)
91 * DIVCMD_RESET(, , , ifindex)
92 *
93 * SIOGIFDIVERT:
94 * DIVCMD_GETSTATUS(divert_blk, , , ifindex)
95 * DIVCMD_GETVERSION(string[3])
96 */
97
98
99/* Possible values for arg1 */
100#define DIVARG1_ENABLE 0 /* ENABLE something */
101#define DIVARG1_DISABLE 1 /* DISABLE something */
102#define DIVARG1_ADD 2 /* ADD something */
103#define DIVARG1_REMOVE 3 /* REMOVE something */
104
105
106#ifdef __KERNEL__
107
108/* diverter functions */
109#include <linux/skbuff.h>
110
111#ifdef CONFIG_NET_DIVERT
112#include <linux/netdevice.h>
113
114int alloc_divert_blk(struct net_device *);
115void free_divert_blk(struct net_device *);
116int divert_ioctl(unsigned int cmd, struct divert_cf __user *arg);
117void divert_frame(struct sk_buff *skb);
118static inline void handle_diverter(struct sk_buff *skb)
119{
120 /* if diversion is supported on device, then divert */
121 if (skb->dev->divert && skb->dev->divert->divert)
122 divert_frame(skb);
123}
124
125#else
126# define alloc_divert_blk(dev) (0)
127# define free_divert_blk(dev) do {} while (0)
128# define divert_ioctl(cmd, arg) (-ENOPKG)
129# define handle_diverter(skb) do {} while (0)
130#endif
131#endif
132#endif /* _LINUX_DIVERT_H */
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index 2fa9f1144228..a24931d24404 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -21,11 +21,11 @@ typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *);
21typedef int (elevator_may_queue_fn) (request_queue_t *, int); 21typedef int (elevator_may_queue_fn) (request_queue_t *, int);
22 22
23typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, gfp_t); 23typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, gfp_t);
24typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); 24typedef void (elevator_put_req_fn) (struct request *);
25typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *); 25typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *);
26typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *); 26typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *);
27 27
28typedef void *(elevator_init_fn) (request_queue_t *, elevator_t *); 28typedef void *(elevator_init_fn) (request_queue_t *);
29typedef void (elevator_exit_fn) (elevator_t *); 29typedef void (elevator_exit_fn) (elevator_t *);
30 30
31struct elevator_ops 31struct elevator_ops
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 3e69241e6a81..fa23e0671bb3 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -774,8 +774,8 @@ struct fb_info {
774#endif 774#endif
775 775
776 struct fb_ops *fbops; 776 struct fb_ops *fbops;
777 struct device *device; 777 struct device *device; /* This is the parent */
778 struct class_device *class_device; /* sysfs per device attrs */ 778 struct device *dev; /* This is this fb device */
779 int class_flag; /* private sysfs flags */ 779 int class_flag; /* private sysfs flags */
780#ifdef CONFIG_FB_TILEBLITTING 780#ifdef CONFIG_FB_TILEBLITTING
781 struct fb_tile_ops *tileops; /* Tile Blitting */ 781 struct fb_tile_ops *tileops; /* Tile Blitting */
@@ -910,8 +910,8 @@ static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
910/* drivers/video/fbsysfs.c */ 910/* drivers/video/fbsysfs.c */
911extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev); 911extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
912extern void framebuffer_release(struct fb_info *info); 912extern void framebuffer_release(struct fb_info *info);
913extern int fb_init_class_device(struct fb_info *fb_info); 913extern int fb_init_device(struct fb_info *fb_info);
914extern void fb_cleanup_class_device(struct fb_info *head); 914extern void fb_cleanup_device(struct fb_info *head);
915extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max); 915extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max);
916 916
917/* drivers/video/fbmon.c */ 917/* drivers/video/fbmon.c */
diff --git a/include/linux/fib_rules.h b/include/linux/fib_rules.h
index 4418c8d9d479..8270aac2aa5d 100644
--- a/include/linux/fib_rules.h
+++ b/include/linux/fib_rules.h
@@ -6,6 +6,7 @@
6 6
7/* rule is permanent, and cannot be deleted */ 7/* rule is permanent, and cannot be deleted */
8#define FIB_RULE_PERMANENT 1 8#define FIB_RULE_PERMANENT 1
9#define FIB_RULE_INVERT 2
9 10
10struct fib_rule_hdr 11struct fib_rule_hdr
11{ 12{
@@ -34,7 +35,7 @@ enum
34 FRA_UNUSED3, 35 FRA_UNUSED3,
35 FRA_UNUSED4, 36 FRA_UNUSED4,
36 FRA_UNUSED5, 37 FRA_UNUSED5,
37 FRA_FWMARK, /* netfilter mark */ 38 FRA_FWMARK, /* mark */
38 FRA_FLOW, /* flow/class id */ 39 FRA_FLOW, /* flow/class id */
39 FRA_UNUSED6, 40 FRA_UNUSED6,
40 FRA_UNUSED7, 41 FRA_UNUSED7,
diff --git a/include/linux/ftape-header-segment.h b/include/linux/ftape-header-segment.h
deleted file mode 100644
index 4732218f0708..000000000000
--- a/include/linux/ftape-header-segment.h
+++ /dev/null
@@ -1,122 +0,0 @@
1#ifndef _FTAPE_HEADER_SEGMENT_H
2#define _FTAPE_HEADER_SEGMENT_H
3
4/*
5 * Copyright (C) 1996-1997 Claus-Justus Heine.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/include/linux/ftape-header-segment.h,v $
23 * $Revision: 1.2 $
24 * $Date: 1997/10/05 19:19:28 $
25 *
26 * This file defines some offsets into the header segment of a
27 * floppy tape cartridge. For use with the QIC-40/80/3010/3020
28 * floppy-tape driver "ftape" for Linux.
29 */
30
31#define FT_SIGNATURE 0 /* must be 0xaa55aa55 */
32#define FT_FMT_CODE 4
33#define FT_REV_LEVEL 5 /* only for QIC-80 since. Rev. L (== 0x0c) */
34#define FT_HSEG_1 6 /* first header segment, except for format code 6 */
35#define FT_HSEG_2 8 /* second header segment, except for format code 6 */
36#define FT_FRST_SEG 10 /* first data segment, except for format code 6 */
37#define FT_LAST_SEG 12 /* last data segment, except for format code 6 */
38#define FT_FMT_DATE 14 /* date and time of most recent format, see below */
39#define FT_WR_DATE 18 /* date and time of most recent write or format */
40#define FT_SPT 24 /* segments per track */
41#define FT_TPC 26 /* tracks per cartridge */
42#define FT_FHM 27 /* floppy drive head (maximum of it) */
43#define FT_FTM 28 /* floppy track max. */
44#define FT_FSM 29 /* floppy sector max. (128) */
45#define FT_LABEL 30 /* floppy tape label */
46#define FT_LABEL_DATE 74 /* date and time the tape label was written */
47#define FT_LABEL_SZ (FT_LABEL_DATE - FT_LABEL)
48#define FT_CMAP_START 78 /* starting segment of compression map */
49#define FT_FMT_ERROR 128 /* must be set to 0xff if remainder gets lost during
50 * tape format
51 */
52#define FT_SEG_CNT 130 /* number of seg. written, formatted or verified
53 * through lifetime of tape (why not read?)
54 */
55#define FT_INIT_DATE 138 /* date and time of initial tape format */
56#define FT_FMT_CNT 142 /* number of times tape has been formatted */
57#define FT_FSL_CNT 144 /* number of segments in failed sector log */
58#define FT_MK_CODE 146 /* id string of tape manufacturer */
59#define FT_LOT_CODE 190 /* tape manufacturer lot code */
60#define FT_6_HSEG_1 234 /* first header segment for format code 6 */
61#define FT_6_HSEG_2 238 /* second header segment for format code 6 */
62#define FT_6_FRST_SEG 242 /* first data segment for format code 6 */
63#define FT_6_LAST_SEG 246 /* last data segment for format code 6 */
64
65#define FT_FSL 256
66#define FT_HEADER_END 256 /* space beyond this point:
67 * format codes 2, 3 and 5:
68 * - failed sector log until byte 2047
69 * - bad sector map in the reamining part of segment
70 * format codes 4 and 6:
71 * - bad sector map starts hear
72 */
73
74
75/* value to be stored at the FT_SIGNATURE offset
76 */
77#define FT_HSEG_MAGIC 0xaa55aa55
78#define FT_D2G_MAGIC 0x82288228 /* Ditto 2GB */
79
80/* data and time encoding: */
81#define FT_YEAR_SHIFT 25
82#define FT_YEAR_MASK 0xfe000000
83#define FT_YEAR_0 1970
84#define FT_YEAR_MAX 127
85#define FT_YEAR(year) ((((year)-FT_YEAR_0)<<FT_YEAR_SHIFT)&FT_YEAR_MASK)
86
87#define FT_TIME_SHIFT 0
88#define FT_TIME_MASK 0x01FFFFFF
89#define FT_TIME_MAX 0x01ea6dff /* last second of a year */
90#define FT_TIME(mo,d,h,m,s) \
91 ((((s)+60*((m)+60*((h)+24*((d)+31*(mo))))) & FT_TIME_MASK))
92
93#define FT_TIME_STAMP(y,mo,d,h,m,s) (FT_YEAR(y) | FT_TIME(mo,d,h,m,s))
94
95/* values for the format code field */
96typedef enum {
97 fmt_normal = 2, /* QIC-80 post Rev. B 205Ft or 307Ft tape */
98 fmt_1100ft = 3, /* QIC-80 post Rev. B 1100Ft tape */
99 fmt_var = 4, /* QIC-80 post Rev. B variabel length format */
100 fmt_425ft = 5, /* QIC-80 post Rev. B 425Ft tape */
101 fmt_big = 6 /* QIC-3010/3020 variable length tape with more
102 * than 2^16 segments per tape
103 */
104} ft_format_type;
105
106/* definitions for the failed sector log */
107#define FT_FSL_SIZE (2 * FT_SECTOR_SIZE - FT_HEADER_END)
108#define FT_FSL_MAX_ENTRIES (FT_FSL_SIZE/sizeof(__u32))
109
110typedef struct ft_fsl_entry {
111 __u16 segment;
112 __u16 date;
113} __attribute__ ((packed)) ft_fsl_entry;
114
115
116/* date encoding for the failed sector log
117 * month: 1..12, day: 1..31, year: 1970..2097
118 */
119#define FT_FSL_TIME_STAMP(y,m,d) \
120 (((((y) - FT_YEAR_0)<<9)&0xfe00) | (((m)<<5)&0x01e0) | ((d)&0x001f))
121
122#endif /* _FTAPE_HEADER_SEGMENT_H */
diff --git a/include/linux/ftape-vendors.h b/include/linux/ftape-vendors.h
deleted file mode 100644
index ec1a81f059e5..000000000000
--- a/include/linux/ftape-vendors.h
+++ /dev/null
@@ -1,137 +0,0 @@
1#ifndef _FTAPE_VENDORS_H
2#define _FTAPE_VENDORS_H
3
4/*
5 * Copyright (C) 1993-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/include/linux/ftape-vendors.h,v $
24 * $Revision: 1.6 $
25 * $Date: 1997/10/09 15:38:11 $
26 *
27 * This file contains the supported drive types with their
28 * QIC-117 spec. vendor code and drive dependent configuration
29 * information.
30 */
31
32typedef enum {
33 unknown_wake_up = 0,
34 no_wake_up,
35 wake_up_colorado,
36 wake_up_mountain,
37 wake_up_insight,
38} wake_up_types;
39
40typedef struct {
41 wake_up_types wake_up; /* see wake_up_types */
42 char *name; /* Text describing the drive */
43} wakeup_method;
44
45/* Note: order of entries in WAKEUP_METHODS must be so that a variable
46 * of type wake_up_types can be used as an index in the array.
47 */
48#define WAKEUP_METHODS { \
49 { unknown_wake_up, "Unknown" }, \
50 { no_wake_up, "None" }, \
51 { wake_up_colorado, "Colorado" }, \
52 { wake_up_mountain, "Mountain" }, \
53 { wake_up_insight, "Motor-on" }, \
54}
55
56typedef struct {
57 unsigned int vendor_id; /* vendor id from drive */
58 int speed; /* maximum tape transport speed (ips) */
59 wake_up_types wake_up; /* see wake_up_types */
60 char *name; /* Text describing the drive */
61} vendor_struct;
62
63#define UNKNOWN_VENDOR (-1)
64
65#define QIC117_VENDORS { \
66/* see _vendor_struct */ \
67 { 0x00000, 82, wake_up_colorado, "Colorado DJ-10 (old)" }, \
68 { 0x00047, 90, wake_up_colorado, "Colorado DJ-10/DJ-20" }, \
69 { 0x011c2, 84, wake_up_colorado, "Colorado 700" }, \
70 { 0x011c3, 90, wake_up_colorado, "Colorado 1400" }, \
71 { 0x011c4, 84, wake_up_colorado, "Colorado DJ-10/DJ-20 (new)" }, \
72 { 0x011c5, 84, wake_up_colorado, "HP Colorado T1000" }, \
73 { 0x011c6, 90, wake_up_colorado, "HP Colorado T3000" }, \
74 { 0x00005, 45, wake_up_mountain, "Archive 5580i" }, \
75 { 0x10005, 50, wake_up_insight, "Insight 80Mb, Irwin 80SX" }, \
76 { 0x00140, 74, wake_up_mountain, "Archive S.Hornet [Identity/Escom]" }, \
77 { 0x00146, 72, wake_up_mountain, "Archive 31250Q [Escom]" }, \
78 { 0x0014a, 100, wake_up_mountain, "Archive XL9250i [Conner/Escom]" }, \
79 { 0x0014c, 98, wake_up_mountain, "Conner C250MQT" }, \
80 { 0x0014e, 80, wake_up_mountain, "Conner C250MQ" }, \
81 { 0x00150, 80, wake_up_mountain, "Conner TSM420R/TST800R" }, \
82 { 0x00152, 80, wake_up_mountain, "Conner TSM850R" }, \
83 { 0x00156, 80, wake_up_mountain, "Conner TSM850R/1700R/TST3200R" }, \
84 { 0x00180, 0, wake_up_mountain, "Summit SE 150" }, \
85 { 0x00181, 85, wake_up_mountain, "Summit SE 250, Mountain FS8000" }, \
86 { 0x001c1, 82, no_wake_up, "Wangtek 3040F" }, \
87 { 0x001c8, 64, no_wake_up, "Wangtek 3080F" }, \
88 { 0x001c8, 64, wake_up_colorado, "Wangtek 3080F" }, \
89 { 0x001ca, 67, no_wake_up, "Wangtek 3080F (new)" }, \
90 { 0x001cc, 77, wake_up_colorado, "Wangtek 3200 / Teac 700" }, \
91 { 0x001cd, 75, wake_up_colorado, "Reveal TB1400" }, \
92 { 0x00380, 85, wake_up_colorado, "Exabyte Eagle-96" }, \
93 { 0x00381, 85, wake_up_colorado, "Exabyte Eagle TR-3" }, \
94 { 0x00382, 85, wake_up_colorado, "Exabyte Eagle TR-3" }, \
95 { 0x003ce, 77, wake_up_colorado, "Teac 800" }, \
96 { 0x003cf, 0, wake_up_colorado, "Teac FT3010TR" }, \
97 { 0x08880, 64, no_wake_up, "Iomega 250, Ditto 800" }, \
98 { 0x08880, 64, wake_up_colorado, "Iomega 250, Ditto 800" }, \
99 { 0x08880, 64, wake_up_insight, "Iomega 250, Ditto 800" }, \
100 { 0x08881, 80, wake_up_colorado, "Iomega 700" }, \
101 { 0x08882, 80, wake_up_colorado, "Iomega 3200" }, \
102 { 0x08883, 80, wake_up_colorado, "Iomega DITTO 2GB" }, \
103 { 0x00021, 70, no_wake_up, "AIWA CT-803" }, \
104 { 0x004c0, 80, no_wake_up, "AIWA TD-S1600" }, \
105 { 0x00021, 0, wake_up_mountain, "COREtape QIC80" }, \
106 { 0x00441, 0, wake_up_mountain, "ComByte DoublePlay" }, \
107 { 0x00481, 127, wake_up_mountain, "PERTEC MyTape 800" }, \
108 { 0x00483, 130, wake_up_mountain, "PERTEC MyTape 3200" }, \
109 { UNKNOWN_VENDOR, 0, no_wake_up, "unknown" } \
110}
111
112#define QIC117_MAKE_CODES { \
113 { 0, "Unassigned" }, \
114 { 1, "Alloy Computer Products" }, \
115 { 2, "3M" }, \
116 { 3, "Tandberg Data" }, \
117 { 4, "Colorado" }, \
118 { 5, "Archive/Conner" }, \
119 { 6, "Mountain/Summit Memory Systems" }, \
120 { 7, "Wangtek/Rexon/Tecmar" }, \
121 { 8, "Sony" }, \
122 { 9, "Cipher Data Products" }, \
123 { 10, "Irwin Magnetic Systems" }, \
124 { 11, "Braemar" }, \
125 { 12, "Verbatim" }, \
126 { 13, "Core International" }, \
127 { 14, "Exabyte" }, \
128 { 15, "Teac" }, \
129 { 16, "Gigatek" }, \
130 { 17, "ComByte" }, \
131 { 18, "PERTEC Memories" }, \
132 { 19, "Aiwa" }, \
133 { 71, "Colorado" }, \
134 { 546, "Iomega Inc" }, \
135}
136
137#endif /* _FTAPE_VENDORS_H */
diff --git a/include/linux/ftape.h b/include/linux/ftape.h
deleted file mode 100644
index 7e7038cba86a..000000000000
--- a/include/linux/ftape.h
+++ /dev/null
@@ -1,201 +0,0 @@
1#ifndef _FTAPE_H
2#define _FTAPE_H
3
4/*
5 * Copyright (C) 1994-1996 Bas Laarhoven,
6 * (C) 1996-1997 Claus-Justus Heine.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 *
23 * $Source: /homes/cvs/ftape-stacked/include/linux/ftape.h,v $
24 * $Revision: 1.17.6.4 $
25 * $Date: 1997/11/25 01:52:54 $
26 *
27 * This file contains global definitions, typedefs and macro's
28 * for the QIC-40/80/3010/3020 floppy-tape driver for Linux.
29 */
30
31#define FTAPE_VERSION "ftape v3.04d 25/11/97"
32
33#ifdef __KERNEL__
34#include <linux/interrupt.h>
35#include <linux/mm.h>
36#endif
37#include <linux/types.h>
38#include <linux/mtio.h>
39
40#define FT_SECTOR(x) (x+1) /* sector offset into real sector */
41#define FT_SECTOR_SIZE 1024
42#define FT_SECTORS_PER_SEGMENT 32
43#define FT_ECC_SECTORS 3
44#define FT_SEGMENT_SIZE ((FT_SECTORS_PER_SEGMENT - FT_ECC_SECTORS) * FT_SECTOR_SIZE)
45#define FT_BUFF_SIZE (FT_SECTORS_PER_SEGMENT * FT_SECTOR_SIZE)
46
47/*
48 * bits of the minor device number that define drive selection
49 * methods. Could be used one day to access multiple tape
50 * drives on the same controller.
51 */
52#define FTAPE_SEL_A 0
53#define FTAPE_SEL_B 1
54#define FTAPE_SEL_C 2
55#define FTAPE_SEL_D 3
56#define FTAPE_SEL_MASK 3
57#define FTAPE_SEL(unit) ((unit) & FTAPE_SEL_MASK)
58#define FTAPE_NO_REWIND 4 /* mask for minor nr */
59
60/* the following two may be reported when MTIOCGET is requested ... */
61typedef union {
62 struct {
63 __u8 error;
64 __u8 command;
65 } error;
66 long space;
67} ft_drive_error;
68typedef union {
69 struct {
70 __u8 drive_status;
71 __u8 drive_config;
72 __u8 tape_status;
73 } status;
74 long space;
75} ft_drive_status;
76
77#ifdef __KERNEL__
78
79#define FT_RQM_DELAY 12
80#define FT_MILLISECOND 1
81#define FT_SECOND 1000
82#define FT_FOREVER -1
83#ifndef HZ
84#error "HZ undefined."
85#endif
86#define FT_USPT (1000000/HZ) /* microseconds per tick */
87
88/* This defines the number of retries that the driver will allow
89 * before giving up (and letting a higher level handle the error).
90 */
91#ifdef TESTING
92#define FT_SOFT_RETRIES 1 /* number of low level retries */
93#define FT_RETRIES_ON_ECC_ERROR 3 /* ecc error when correcting segment */
94#else
95#define FT_SOFT_RETRIES 6 /* number of low level retries (triple) */
96#define FT_RETRIES_ON_ECC_ERROR 3 /* ecc error when correcting segment */
97#endif
98
99#ifndef THE_FTAPE_MAINTAINER
100#define THE_FTAPE_MAINTAINER "the ftape maintainer"
101#endif
102
103/* Initialize missing configuration parameters.
104 */
105#ifndef CONFIG_FT_NR_BUFFERS
106# define CONFIG_FT_NR_BUFFERS 3
107#endif
108#ifndef CONFIG_FT_FDC_THR
109# define CONFIG_FT_FDC_THR 8
110#endif
111#ifndef CONFIG_FT_FDC_MAX_RATE
112# define CONFIG_FT_FDC_MAX_RATE 2000
113#endif
114#ifndef CONFIG_FT_FDC_BASE
115# define CONFIG_FT_FDC_BASE 0
116#endif
117#ifndef CONFIG_FT_FDC_IRQ
118# define CONFIG_FT_FDC_IRQ 0
119#endif
120#ifndef CONFIG_FT_FDC_DMA
121# define CONFIG_FT_FDC_DMA 0
122#endif
123
124/* Turn some booleans into numbers.
125 */
126#ifdef CONFIG_FT_PROBE_FC10
127# undef CONFIG_FT_PROBE_FC10
128# define CONFIG_FT_PROBE_FC10 1
129#else
130# define CONFIG_FT_PROBE_FC10 0
131#endif
132#ifdef CONFIG_FT_MACH2
133# undef CONFIG_FT_MACH2
134# define CONFIG_FT_MACH2 1
135#else
136# define CONFIG_FT_MACH2 0
137#endif
138
139/* Insert default settings
140 */
141#if CONFIG_FT_PROBE_FC10 == 1
142# if CONFIG_FT_FDC_BASE == 0
143# undef CONFIG_FT_FDC_BASE
144# define CONFIG_FT_FDC_BASE 0x180
145# endif
146# if CONFIG_FT_FDC_IRQ == 0
147# undef CONFIG_FT_FDC_IRQ
148# define CONFIG_FT_FDC_IRQ 9
149# endif
150# if CONFIG_FT_FDC_DMA == 0
151# undef CONFIG_FT_FDC_DMA
152# define CONFIG_FT_FDC_DMA 3
153# endif
154#elif CONFIG_FT_MACH2 == 1 /* CONFIG_FT_PROBE_FC10 == 1 */
155# if CONFIG_FT_FDC_BASE == 0
156# undef CONFIG_FT_FDC_BASE
157# define CONFIG_FT_FDC_BASE 0x1E0
158# endif
159# if CONFIG_FT_FDC_IRQ == 0
160# undef CONFIG_FT_FDC_IRQ
161# define CONFIG_FT_FDC_IRQ 6
162# endif
163# if CONFIG_FT_FDC_DMA == 0
164# undef CONFIG_FT_FDC_DMA
165# define CONFIG_FT_FDC_DMA 2
166# endif
167#elif defined(CONFIG_FT_ALT_FDC) /* CONFIG_FT_MACH2 */
168# if CONFIG_FT_FDC_BASE == 0
169# undef CONFIG_FT_FDC_BASE
170# define CONFIG_FT_FDC_BASE 0x370
171# endif
172# if CONFIG_FT_FDC_IRQ == 0
173# undef CONFIG_FT_FDC_IRQ
174# define CONFIG_FT_FDC_IRQ 6
175# endif
176# if CONFIG_FT_FDC_DMA == 0
177# undef CONFIG_FT_FDC_DMA
178# define CONFIG_FT_FDC_DMA 2
179# endif
180#else /* CONFIG_FT_ALT_FDC */
181# if CONFIG_FT_FDC_BASE == 0
182# undef CONFIG_FT_FDC_BASE
183# define CONFIG_FT_FDC_BASE 0x3f0
184# endif
185# if CONFIG_FT_FDC_IRQ == 0
186# undef CONFIG_FT_FDC_IRQ
187# define CONFIG_FT_FDC_IRQ 6
188# endif
189# if CONFIG_FT_FDC_DMA == 0
190# undef CONFIG_FT_FDC_DMA
191# define CONFIG_FT_FDC_DMA 2
192# endif
193#endif /* standard FDC */
194
195/* some useful macro's
196 */
197#define NR_ITEMS(x) (int)(sizeof(x)/ sizeof(*x))
198
199#endif /* __KERNEL__ */
200
201#endif
diff --git a/include/linux/icmp.h b/include/linux/icmp.h
index 878cfe4e587f..24da4fbc1a2f 100644
--- a/include/linux/icmp.h
+++ b/include/linux/icmp.h
@@ -68,7 +68,7 @@
68struct icmphdr { 68struct icmphdr {
69 __u8 type; 69 __u8 type;
70 __u8 code; 70 __u8 code;
71 __be16 checksum; 71 __sum16 checksum;
72 union { 72 union {
73 struct { 73 struct {
74 __be16 id; 74 __be16 id;
diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
index c771a7db9871..68d3526c3a05 100644
--- a/include/linux/icmpv6.h
+++ b/include/linux/icmpv6.h
@@ -7,17 +7,17 @@ struct icmp6hdr {
7 7
8 __u8 icmp6_type; 8 __u8 icmp6_type;
9 __u8 icmp6_code; 9 __u8 icmp6_code;
10 __u16 icmp6_cksum; 10 __sum16 icmp6_cksum;
11 11
12 12
13 union { 13 union {
14 __u32 un_data32[1]; 14 __be32 un_data32[1];
15 __u16 un_data16[2]; 15 __be16 un_data16[2];
16 __u8 un_data8[4]; 16 __u8 un_data8[4];
17 17
18 struct icmpv6_echo { 18 struct icmpv6_echo {
19 __u16 identifier; 19 __be16 identifier;
20 __u16 sequence; 20 __be16 sequence;
21 } u_echo; 21 } u_echo;
22 22
23 struct icmpv6_nd_advt { 23 struct icmpv6_nd_advt {
@@ -53,7 +53,7 @@ struct icmp6hdr {
53#else 53#else
54#error "Please fix <asm/byteorder.h>" 54#error "Please fix <asm/byteorder.h>"
55#endif 55#endif
56 __u16 rt_lifetime; 56 __be16 rt_lifetime;
57 } u_nd_ra; 57 } u_nd_ra;
58 58
59 } icmp6_dataun; 59 } icmp6_dataun;
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h
index b92558549d27..99393ef3af39 100644
--- a/include/linux/if_packet.h
+++ b/include/linux/if_packet.h
@@ -1,17 +1,19 @@
1#ifndef __LINUX_IF_PACKET_H 1#ifndef __LINUX_IF_PACKET_H
2#define __LINUX_IF_PACKET_H 2#define __LINUX_IF_PACKET_H
3 3
4#include <linux/types.h>
5
4struct sockaddr_pkt 6struct sockaddr_pkt
5{ 7{
6 unsigned short spkt_family; 8 unsigned short spkt_family;
7 unsigned char spkt_device[14]; 9 unsigned char spkt_device[14];
8 unsigned short spkt_protocol; 10 __be16 spkt_protocol;
9}; 11};
10 12
11struct sockaddr_ll 13struct sockaddr_ll
12{ 14{
13 unsigned short sll_family; 15 unsigned short sll_family;
14 unsigned short sll_protocol; 16 __be16 sll_protocol;
15 int sll_ifindex; 17 int sll_ifindex;
16 unsigned short sll_hatype; 18 unsigned short sll_hatype;
17 unsigned char sll_pkttype; 19 unsigned char sll_pkttype;
diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h
index bef9f8fd93b3..8de079ba1107 100644
--- a/include/linux/if_tunnel.h
+++ b/include/linux/if_tunnel.h
@@ -19,10 +19,10 @@ struct ip_tunnel_parm
19{ 19{
20 char name[IFNAMSIZ]; 20 char name[IFNAMSIZ];
21 int link; 21 int link;
22 __u16 i_flags; 22 __be16 i_flags;
23 __u16 o_flags; 23 __be16 o_flags;
24 __u32 i_key; 24 __be32 i_key;
25 __u32 o_key; 25 __be32 o_key;
26 struct iphdr iph; 26 struct iphdr iph;
27}; 27};
28 28
diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index 21dd56905271..6e7ea2f0a57c 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -30,7 +30,7 @@ struct igmphdr
30{ 30{
31 __u8 type; 31 __u8 type;
32 __u8 code; /* For newer IGMP */ 32 __u8 code; /* For newer IGMP */
33 __be16 csum; 33 __sum16 csum;
34 __be32 group; 34 __be32 group;
35}; 35};
36 36
diff --git a/include/linux/in.h b/include/linux/in.h
index 2619859f6e1b..1912e7c0bc26 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -45,6 +45,7 @@ enum {
45 45
46 IPPROTO_COMP = 108, /* Compression Header protocol */ 46 IPPROTO_COMP = 108, /* Compression Header protocol */
47 IPPROTO_SCTP = 132, /* Stream Control Transport Protocol */ 47 IPPROTO_SCTP = 132, /* Stream Control Transport Protocol */
48 IPPROTO_UDPLITE = 136, /* UDP-Lite (RFC 3828) */
48 49
49 IPPROTO_RAW = 255, /* Raw IP packets */ 50 IPPROTO_RAW = 255, /* Raw IP packets */
50 IPPROTO_MAX 51 IPPROTO_MAX
diff --git a/include/linux/in6.h b/include/linux/in6.h
index f28621f638e0..4e8350ae8869 100644
--- a/include/linux/in6.h
+++ b/include/linux/in6.h
@@ -54,7 +54,7 @@ extern const struct in6_addr in6addr_loopback;
54struct sockaddr_in6 { 54struct sockaddr_in6 {
55 unsigned short int sin6_family; /* AF_INET6 */ 55 unsigned short int sin6_family; /* AF_INET6 */
56 __be16 sin6_port; /* Transport layer port # */ 56 __be16 sin6_port; /* Transport layer port # */
57 __u32 sin6_flowinfo; /* IPv6 flow information */ 57 __be32 sin6_flowinfo; /* IPv6 flow information */
58 struct in6_addr sin6_addr; /* IPv6 address */ 58 struct in6_addr sin6_addr; /* IPv6 address */
59 __u32 sin6_scope_id; /* scope id (new in RFC2553) */ 59 __u32 sin6_scope_id; /* scope id (new in RFC2553) */
60}; 60};
@@ -72,7 +72,7 @@ struct ipv6_mreq {
72struct in6_flowlabel_req 72struct in6_flowlabel_req
73{ 73{
74 struct in6_addr flr_dst; 74 struct in6_addr flr_dst;
75 __u32 flr_label; 75 __be32 flr_label;
76 __u8 flr_action; 76 __u8 flr_action;
77 __u8 flr_share; 77 __u8 flr_share;
78 __u16 flr_flags; 78 __u16 flr_flags;
diff --git a/include/linux/inet.h b/include/linux/inet.h
index b7c6da7d6d32..675a7dbe86f8 100644
--- a/include/linux/inet.h
+++ b/include/linux/inet.h
@@ -46,7 +46,7 @@
46#include <linux/types.h> 46#include <linux/types.h>
47 47
48extern __be32 in_aton(const char *str); 48extern __be32 in_aton(const char *str);
49extern int in4_pton(const char *src, int srclen, u8 *dst, char delim, const char **end); 49extern int in4_pton(const char *src, int srclen, u8 *dst, int delim, const char **end);
50extern int in6_pton(const char *src, int srclen, u8 *dst, char delim, const char **end); 50extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char **end);
51#endif 51#endif
52#endif /* _LINUX_INET_H */ 52#endif /* _LINUX_INET_H */
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index 5a0ab04627bc..c0f7aec331c2 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -124,12 +124,13 @@ static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa)
124 * Check if a mask is acceptable. 124 * Check if a mask is acceptable.
125 */ 125 */
126 126
127static __inline__ int bad_mask(u32 mask, u32 addr) 127static __inline__ int bad_mask(__be32 mask, __be32 addr)
128{ 128{
129 __u32 hmask;
129 if (addr & (mask = ~mask)) 130 if (addr & (mask = ~mask))
130 return 1; 131 return 1;
131 mask = ntohl(mask); 132 hmask = ntohl(mask);
132 if (mask & (mask+1)) 133 if (hmask & (hmask+1))
133 return 1; 134 return 1;
134 return 0; 135 return 0;
135} 136}
@@ -190,11 +191,12 @@ static __inline__ __be32 inet_make_mask(int logmask)
190 return 0; 191 return 0;
191} 192}
192 193
193static __inline__ int inet_mask_len(__u32 mask) 194static __inline__ int inet_mask_len(__be32 mask)
194{ 195{
195 if (!(mask = ntohl(mask))) 196 __u32 hmask = ntohl(mask);
197 if (!hmask)
196 return 0; 198 return 0;
197 return 32 - ffz(~mask); 199 return 32 - ffz(~hmask);
198} 200}
199 201
200 202
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index d42c83399071..cf8696d4a138 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -89,6 +89,7 @@ struct resource_list {
89#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */ 89#define IORESOURCE_ROM_ENABLE (1<<0) /* ROM is enabled, same as PCI_ROM_ADDRESS_ENABLE */
90#define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */ 90#define IORESOURCE_ROM_SHADOW (1<<1) /* ROM is copy at C000:0 */
91#define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */ 91#define IORESOURCE_ROM_COPY (1<<2) /* ROM is alloc'd copy, resource field overlaid */
92#define IORESOURCE_ROM_BIOS_COPY (1<<3) /* ROM is BIOS copy, resource field overlaid */
92 93
93/* PC/ISA/whatever - the normal PC address spaces: IO and memory */ 94/* PC/ISA/whatever - the normal PC address spaces: IO and memory */
94extern struct resource ioport_resource; 95extern struct resource ioport_resource;
diff --git a/include/linux/ip.h b/include/linux/ip.h
index ecee9bb27d0e..1d36b971a8b5 100644
--- a/include/linux/ip.h
+++ b/include/linux/ip.h
@@ -98,7 +98,7 @@ struct iphdr {
98 __be16 frag_off; 98 __be16 frag_off;
99 __u8 ttl; 99 __u8 ttl;
100 __u8 protocol; 100 __u8 protocol;
101 __be16 check; 101 __sum16 check;
102 __be32 saddr; 102 __be32 saddr;
103 __be32 daddr; 103 __be32 daddr;
104 /*The options start here. */ 104 /*The options start here. */
diff --git a/include/linux/ip6_tunnel.h b/include/linux/ip6_tunnel.h
index 5c23aeb104ca..af3f4a70f3df 100644
--- a/include/linux/ip6_tunnel.h
+++ b/include/linux/ip6_tunnel.h
@@ -25,7 +25,7 @@ struct ip6_tnl_parm {
25 __u8 proto; /* tunnel protocol */ 25 __u8 proto; /* tunnel protocol */
26 __u8 encap_limit; /* encapsulation limit for tunnel */ 26 __u8 encap_limit; /* encapsulation limit for tunnel */
27 __u8 hop_limit; /* hop limit for tunnel */ 27 __u8 hop_limit; /* hop limit for tunnel */
28 __u32 flowinfo; /* traffic class and flowlabel for tunnel */ 28 __be32 flowinfo; /* traffic class and flowlabel for tunnel */
29 __u32 flags; /* tunnel flags */ 29 __u32 flags; /* tunnel flags */
30 struct in6_addr laddr; /* local tunnel end-point address */ 30 struct in6_addr laddr; /* local tunnel end-point address */
31 struct in6_addr raddr; /* remote tunnel end-point address */ 31 struct in6_addr raddr; /* remote tunnel end-point address */
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 4f435c59de06..f8241130f5ea 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -274,7 +274,7 @@ struct ipv6_pinfo {
274 struct in6_addr *saddr_cache; 274 struct in6_addr *saddr_cache;
275#endif 275#endif
276 276
277 __u32 flow_label; 277 __be32 flow_label;
278 __u32 frag_size; 278 __u32 frag_size;
279 __s16 hop_limit; 279 __s16 hop_limit;
280 __s16 mcast_hops; 280 __s16 mcast_hops;
diff --git a/include/linux/ixjuser.h b/include/linux/ixjuser.h
index fd1756d3a47e..88b45895746d 100644
--- a/include/linux/ixjuser.h
+++ b/include/linux/ixjuser.h
@@ -315,7 +315,7 @@ typedef struct {
315* structures. If the freq0 variable is non-zero, the tone table contents 315* structures. If the freq0 variable is non-zero, the tone table contents
316* for the tone_index are updated to the frequencies and gains defined. It 316* for the tone_index are updated to the frequencies and gains defined. It
317* should be noted that DTMF tones cannot be reassigned, so if DTMF tone 317* should be noted that DTMF tones cannot be reassigned, so if DTMF tone
318* table indexs are used in a cadence the frequency and gain variables will 318* table indexes are used in a cadence the frequency and gain variables will
319* be ignored. 319* be ignored.
320* 320*
321* If the array elements contain frequency parameters the driver will 321* If the array elements contain frequency parameters the driver will
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index c8d5f207c3d4..0ec6e28bccd2 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -74,7 +74,7 @@
74#define __jiffy_data __attribute__((section(".data"))) 74#define __jiffy_data __attribute__((section(".data")))
75 75
76/* 76/*
77 * The 64-bit value is not volatile - you MUST NOT read it 77 * The 64-bit value is not atomic - you MUST NOT read it
78 * without sampling the sequence number in xtime_lock. 78 * without sampling the sequence number in xtime_lock.
79 * get_jiffies_64() will do this for you as appropriate. 79 * get_jiffies_64() will do this for you as appropriate.
80 */ 80 */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 24b611147adb..6738283ac385 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -30,8 +30,10 @@ extern const char linux_banner[];
30 30
31#define STACK_MAGIC 0xdeadbeef 31#define STACK_MAGIC 0xdeadbeef
32 32
33#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
34#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
35
33#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
34#define ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL))
35#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) 37#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
36#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) 38#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
37#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) 39#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
@@ -63,7 +65,7 @@ struct user;
63 * context (spinlock, irq-handler, ...). 65 * context (spinlock, irq-handler, ...).
64 * 66 *
65 * This is a useful debugging help to be able to catch problems early and not 67 * This is a useful debugging help to be able to catch problems early and not
66 * be biten later when the calling function happens to sleep when it is not 68 * be bitten later when the calling function happens to sleep when it is not
67 * supposed to. 69 * supposed to.
68 */ 70 */
69#ifdef CONFIG_PREEMPT_VOLUNTARY 71#ifdef CONFIG_PREEMPT_VOLUNTARY
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 6427949ddf99..a4ede62b339d 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -122,6 +122,8 @@ extern struct kimage *kexec_crash_image;
122#define KEXEC_ARCH_IA_64 (50 << 16) 122#define KEXEC_ARCH_IA_64 (50 << 16)
123#define KEXEC_ARCH_S390 (22 << 16) 123#define KEXEC_ARCH_S390 (22 << 16)
124#define KEXEC_ARCH_SH (42 << 16) 124#define KEXEC_ARCH_SH (42 << 16)
125#define KEXEC_ARCH_MIPS_LE (10 << 16)
126#define KEXEC_ARCH_MIPS ( 8 << 16)
125 127
126#define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */ 128#define KEXEC_FLAGS (KEXEC_ON_CRASH) /* List of defined/legal kexec flags */
127 129
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index bcd9cd173c2c..d1c8d28fa92e 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -47,6 +47,7 @@ enum kobject_action {
47 KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices (broken) */ 47 KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices (broken) */
48 KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* device offline */ 48 KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* device offline */
49 KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* device online */ 49 KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* device online */
50 KOBJ_MOVE = (__force kobject_action_t) 0x08, /* device move */
50}; 51};
51 52
52struct kobject { 53struct kobject {
@@ -76,6 +77,7 @@ extern int __must_check kobject_add(struct kobject *);
76extern void kobject_del(struct kobject *); 77extern void kobject_del(struct kobject *);
77 78
78extern int __must_check kobject_rename(struct kobject *, const char *new_name); 79extern int __must_check kobject_rename(struct kobject *, const char *new_name);
80extern int __must_check kobject_move(struct kobject *, struct kobject *);
79 81
80extern int __must_check kobject_register(struct kobject *); 82extern int __must_check kobject_register(struct kobject *);
81extern void kobject_unregister(struct kobject *); 83extern void kobject_unregister(struct kobject *);
@@ -264,6 +266,8 @@ extern int __must_check subsys_create_file(struct subsystem * ,
264 266
265#if defined(CONFIG_HOTPLUG) 267#if defined(CONFIG_HOTPLUG)
266void kobject_uevent(struct kobject *kobj, enum kobject_action action); 268void kobject_uevent(struct kobject *kobj, enum kobject_action action);
269void kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
270 char *envp[]);
267 271
268int add_uevent_var(char **envp, int num_envp, int *cur_index, 272int add_uevent_var(char **envp, int num_envp, int *cur_index,
269 char *buffer, int buffer_size, int *cur_len, 273 char *buffer, int buffer_size, int *cur_len,
@@ -271,6 +275,10 @@ int add_uevent_var(char **envp, int num_envp, int *cur_index,
271 __attribute__((format (printf, 7, 8))); 275 __attribute__((format (printf, 7, 8)));
272#else 276#else
273static inline void kobject_uevent(struct kobject *kobj, enum kobject_action action) { } 277static inline void kobject_uevent(struct kobject *kobj, enum kobject_action action) { }
278static inline void kobject_uevent_env(struct kobject *kobj,
279 enum kobject_action action,
280 char *envp[])
281{ }
274 282
275static inline int add_uevent_var(char **envp, int num_envp, int *cur_index, 283static inline int add_uevent_var(char **envp, int num_envp, int *cur_index,
276 char *buffer, int buffer_size, int *cur_len, 284 char *buffer, int buffer_size, int *cur_len,
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h
index b03cfb91e228..326da7d500c7 100644
--- a/include/linux/miscdevice.h
+++ b/include/linux/miscdevice.h
@@ -31,15 +31,14 @@
31#define HPET_MINOR 228 31#define HPET_MINOR 228
32 32
33struct device; 33struct device;
34struct class_device;
35 34
36struct miscdevice { 35struct miscdevice {
37 int minor; 36 int minor;
38 const char *name; 37 const char *name;
39 const struct file_operations *fops; 38 const struct file_operations *fops;
40 struct list_head list; 39 struct list_head list;
41 struct device *dev; 40 struct device *parent;
42 struct class_device *class; 41 struct device *this_device;
43}; 42};
44 43
45extern int misc_register(struct miscdevice * misc); 44extern int misc_register(struct miscdevice * misc);
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 991a37382a22..d0e6a5497614 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -39,6 +39,10 @@ struct mmc_csd {
39 write_misalign:1; 39 write_misalign:1;
40}; 40};
41 41
42struct mmc_ext_csd {
43 unsigned int hs_max_dtr;
44};
45
42struct sd_scr { 46struct sd_scr {
43 unsigned char sda_vsn; 47 unsigned char sda_vsn;
44 unsigned char bus_widths; 48 unsigned char bus_widths;
@@ -46,6 +50,10 @@ struct sd_scr {
46#define SD_SCR_BUS_WIDTH_4 (1<<2) 50#define SD_SCR_BUS_WIDTH_4 (1<<2)
47}; 51};
48 52
53struct sd_switch_caps {
54 unsigned int hs_max_dtr;
55};
56
49struct mmc_host; 57struct mmc_host;
50 58
51/* 59/*
@@ -62,12 +70,15 @@ struct mmc_card {
62#define MMC_STATE_BAD (1<<2) /* unrecognised device */ 70#define MMC_STATE_BAD (1<<2) /* unrecognised device */
63#define MMC_STATE_SDCARD (1<<3) /* is an SD card */ 71#define MMC_STATE_SDCARD (1<<3) /* is an SD card */
64#define MMC_STATE_READONLY (1<<4) /* card is read-only */ 72#define MMC_STATE_READONLY (1<<4) /* card is read-only */
73#define MMC_STATE_HIGHSPEED (1<<5) /* card is in high speed mode */
65 u32 raw_cid[4]; /* raw card CID */ 74 u32 raw_cid[4]; /* raw card CID */
66 u32 raw_csd[4]; /* raw card CSD */ 75 u32 raw_csd[4]; /* raw card CSD */
67 u32 raw_scr[2]; /* raw card SCR */ 76 u32 raw_scr[2]; /* raw card SCR */
68 struct mmc_cid cid; /* card identification */ 77 struct mmc_cid cid; /* card identification */
69 struct mmc_csd csd; /* card specific */ 78 struct mmc_csd csd; /* card specific */
79 struct mmc_ext_csd ext_csd; /* mmc v4 extended card specific */
70 struct sd_scr scr; /* extra SD information */ 80 struct sd_scr scr; /* extra SD information */
81 struct sd_switch_caps sw_caps; /* switch (CMD6) caps */
71}; 82};
72 83
73#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) 84#define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT)
@@ -75,12 +86,14 @@ struct mmc_card {
75#define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD) 86#define mmc_card_bad(c) ((c)->state & MMC_STATE_BAD)
76#define mmc_card_sd(c) ((c)->state & MMC_STATE_SDCARD) 87#define mmc_card_sd(c) ((c)->state & MMC_STATE_SDCARD)
77#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) 88#define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY)
89#define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED)
78 90
79#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) 91#define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT)
80#define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD) 92#define mmc_card_set_dead(c) ((c)->state |= MMC_STATE_DEAD)
81#define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD) 93#define mmc_card_set_bad(c) ((c)->state |= MMC_STATE_BAD)
82#define mmc_card_set_sd(c) ((c)->state |= MMC_STATE_SDCARD) 94#define mmc_card_set_sd(c) ((c)->state |= MMC_STATE_SDCARD)
83#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) 95#define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY)
96#define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED)
84 97
85#define mmc_card_name(c) ((c)->cid.prod_name) 98#define mmc_card_name(c) ((c)->cid.prod_name)
86#define mmc_card_id(c) ((c)->dev.bus_id) 99#define mmc_card_id(c) ((c)->dev.bus_id)
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 8b08ef3820f2..c15ae1986b98 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -74,8 +74,8 @@ struct mmc_card;
74struct device; 74struct device;
75 75
76struct mmc_host { 76struct mmc_host {
77 struct device *dev; 77 struct device *parent;
78 struct class_device class_dev; 78 struct device class_dev;
79 int index; 79 int index;
80 const struct mmc_host_ops *ops; 80 const struct mmc_host_ops *ops;
81 unsigned int f_min; 81 unsigned int f_min;
@@ -125,8 +125,8 @@ static inline void *mmc_priv(struct mmc_host *host)
125 return (void *)host->private; 125 return (void *)host->private;
126} 126}
127 127
128#define mmc_dev(x) ((x)->dev) 128#define mmc_dev(x) ((x)->parent)
129#define mmc_hostname(x) ((x)->class_dev.class_id) 129#define mmc_hostname(x) ((x)->class_dev.bus_id)
130 130
131extern int mmc_suspend_host(struct mmc_host *, pm_message_t); 131extern int mmc_suspend_host(struct mmc_host *, pm_message_t);
132extern int mmc_resume_host(struct mmc_host *); 132extern int mmc_resume_host(struct mmc_host *);
diff --git a/include/linux/mmc/protocol.h b/include/linux/mmc/protocol.h
index 08dec8d9e703..2dce60c43f4b 100644
--- a/include/linux/mmc/protocol.h
+++ b/include/linux/mmc/protocol.h
@@ -25,14 +25,16 @@
25#ifndef MMC_MMC_PROTOCOL_H 25#ifndef MMC_MMC_PROTOCOL_H
26#define MMC_MMC_PROTOCOL_H 26#define MMC_MMC_PROTOCOL_H
27 27
28/* Standard MMC commands (3.1) type argument response */ 28/* Standard MMC commands (4.1) type argument response */
29 /* class 1 */ 29 /* class 1 */
30#define MMC_GO_IDLE_STATE 0 /* bc */ 30#define MMC_GO_IDLE_STATE 0 /* bc */
31#define MMC_SEND_OP_COND 1 /* bcr [31:0] OCR R3 */ 31#define MMC_SEND_OP_COND 1 /* bcr [31:0] OCR R3 */
32#define MMC_ALL_SEND_CID 2 /* bcr R2 */ 32#define MMC_ALL_SEND_CID 2 /* bcr R2 */
33#define MMC_SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */ 33#define MMC_SET_RELATIVE_ADDR 3 /* ac [31:16] RCA R1 */
34#define MMC_SET_DSR 4 /* bc [31:16] RCA */ 34#define MMC_SET_DSR 4 /* bc [31:16] RCA */
35#define MMC_SWITCH 6 /* ac [31:0] See below R1b */
35#define MMC_SELECT_CARD 7 /* ac [31:16] RCA R1 */ 36#define MMC_SELECT_CARD 7 /* ac [31:16] RCA R1 */
37#define MMC_SEND_EXT_CSD 8 /* adtc R1 */
36#define MMC_SEND_CSD 9 /* ac [31:16] RCA R2 */ 38#define MMC_SEND_CSD 9 /* ac [31:16] RCA R2 */
37#define MMC_SEND_CID 10 /* ac [31:16] RCA R2 */ 39#define MMC_SEND_CID 10 /* ac [31:16] RCA R2 */
38#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */ 40#define MMC_READ_DAT_UNTIL_STOP 11 /* adtc [31:0] dadr R1 */
@@ -80,6 +82,7 @@
80 /* class 8 */ 82 /* class 8 */
81/* This is basically the same command as for MMC with some quirks. */ 83/* This is basically the same command as for MMC with some quirks. */
82#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */ 84#define SD_SEND_RELATIVE_ADDR 3 /* bcr R6 */
85#define SD_SWITCH 6 /* adtc [31:0] See below R1 */
83 86
84 /* Application commands */ 87 /* Application commands */
85#define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */ 88#define SD_APP_SET_BUS_WIDTH 6 /* ac [1:0] bus width R1 */
@@ -88,6 +91,30 @@
88#define SD_APP_SEND_SCR 51 /* adtc R1 */ 91#define SD_APP_SEND_SCR 51 /* adtc R1 */
89 92
90/* 93/*
94 * MMC_SWITCH argument format:
95 *
96 * [31:26] Always 0
97 * [25:24] Access Mode
98 * [23:16] Location of target Byte in EXT_CSD
99 * [15:08] Value Byte
100 * [07:03] Always 0
101 * [02:00] Command Set
102 */
103
104/*
105 * SD_SWITCH argument format:
106 *
107 * [31] Check (0) or switch (1)
108 * [30:24] Reserved (0)
109 * [23:20] Function group 6
110 * [19:16] Function group 5
111 * [15:12] Function group 4
112 * [11:8] Function group 3
113 * [7:4] Function group 2
114 * [3:0] Function group 1
115 */
116
117/*
91 MMC status in R1 118 MMC status in R1
92 Type 119 Type
93 e : error bit 120 e : error bit
@@ -230,13 +257,54 @@ struct _mmc_csd {
230 257
231#define CSD_STRUCT_VER_1_0 0 /* Valid for system specification 1.0 - 1.2 */ 258#define CSD_STRUCT_VER_1_0 0 /* Valid for system specification 1.0 - 1.2 */
232#define CSD_STRUCT_VER_1_1 1 /* Valid for system specification 1.4 - 2.2 */ 259#define CSD_STRUCT_VER_1_1 1 /* Valid for system specification 1.4 - 2.2 */
233#define CSD_STRUCT_VER_1_2 2 /* Valid for system specification 3.1 */ 260#define CSD_STRUCT_VER_1_2 2 /* Valid for system specification 3.1 - 3.2 - 3.31 - 4.0 - 4.1 */
261#define CSD_STRUCT_EXT_CSD 3 /* Version is coded in CSD_STRUCTURE in EXT_CSD */
234 262
235#define CSD_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.2 */ 263#define CSD_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.2 */
236#define CSD_SPEC_VER_1 1 /* Implements system specification 1.4 */ 264#define CSD_SPEC_VER_1 1 /* Implements system specification 1.4 */
237#define CSD_SPEC_VER_2 2 /* Implements system specification 2.0 - 2.2 */ 265#define CSD_SPEC_VER_2 2 /* Implements system specification 2.0 - 2.2 */
238#define CSD_SPEC_VER_3 3 /* Implements system specification 3.1 */ 266#define CSD_SPEC_VER_3 3 /* Implements system specification 3.1 - 3.2 - 3.31 */
267#define CSD_SPEC_VER_4 4 /* Implements system specification 4.0 - 4.1 */
268
269/*
270 * EXT_CSD fields
271 */
272
273#define EXT_CSD_BUS_WIDTH 183 /* R/W */
274#define EXT_CSD_HS_TIMING 185 /* R/W */
275#define EXT_CSD_CARD_TYPE 196 /* RO */
276
277/*
278 * EXT_CSD field definitions
279 */
280
281#define EXT_CSD_CMD_SET_NORMAL (1<<0)
282#define EXT_CSD_CMD_SET_SECURE (1<<1)
283#define EXT_CSD_CMD_SET_CPSECURE (1<<2)
284
285#define EXT_CSD_CARD_TYPE_26 (1<<0) /* Card can run at 26MHz */
286#define EXT_CSD_CARD_TYPE_52 (1<<1) /* Card can run at 52MHz */
287
288#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */
289#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */
290#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */
291
292/*
293 * MMC_SWITCH access modes
294 */
295
296#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */
297#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */
298#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */
299#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */
300
301/*
302 * SCR field definitions
303 */
239 304
305#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */
306#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */
307#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */
240 308
241/* 309/*
242 * SD bus widths 310 * SD bus widths
diff --git a/include/linux/module.h b/include/linux/module.h
index d1d00ce8f4ed..9258ffd8a7f0 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -264,6 +264,7 @@ struct module
264 struct module_attribute *modinfo_attrs; 264 struct module_attribute *modinfo_attrs;
265 const char *version; 265 const char *version;
266 const char *srcversion; 266 const char *srcversion;
267 struct kobject *drivers_dir;
267 268
268 /* Exported symbols */ 269 /* Exported symbols */
269 const struct kernel_symbol *syms; 270 const struct kernel_symbol *syms;
diff --git a/include/linux/mqueue.h b/include/linux/mqueue.h
index 8db9d75541a6..8b5a79615fbf 100644
--- a/include/linux/mqueue.h
+++ b/include/linux/mqueue.h
@@ -18,8 +18,6 @@
18#ifndef _LINUX_MQUEUE_H 18#ifndef _LINUX_MQUEUE_H
19#define _LINUX_MQUEUE_H 19#define _LINUX_MQUEUE_H
20 20
21#include <linux/types.h>
22
23#define MQ_PRIO_MAX 32768 21#define MQ_PRIO_MAX 32768
24/* per-uid limit of kernel memory used by mqueue, in bytes */ 22/* per-uid limit of kernel memory used by mqueue, in bytes */
25#define MQ_BYTES_MAX 819200 23#define MQ_BYTES_MAX 819200
diff --git a/include/linux/mv643xx.h b/include/linux/mv643xx.h
index edfa012fad3a..aff25c000abf 100644
--- a/include/linux/mv643xx.h
+++ b/include/linux/mv643xx.h
@@ -724,7 +724,7 @@
724#define MV643XX_ETH_RX_FIFO_URGENT_THRESHOLD_REG(port) (0x2470 + (port<<10)) 724#define MV643XX_ETH_RX_FIFO_URGENT_THRESHOLD_REG(port) (0x2470 + (port<<10))
725#define MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(port) (0x2474 + (port<<10)) 725#define MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(port) (0x2474 + (port<<10))
726#define MV643XX_ETH_RX_MINIMAL_FRAME_SIZE_REG(port) (0x247c + (port<<10)) 726#define MV643XX_ETH_RX_MINIMAL_FRAME_SIZE_REG(port) (0x247c + (port<<10))
727#define MV643XX_ETH_RX_DISCARDED_FRAMES_COUNTER(port) (0x2484 + (port<<10) 727#define MV643XX_ETH_RX_DISCARDED_FRAMES_COUNTER(port) (0x2484 + (port<<10))
728#define MV643XX_ETH_PORT_DEBUG_0_REG(port) (0x248c + (port<<10)) 728#define MV643XX_ETH_PORT_DEBUG_0_REG(port) (0x248c + (port<<10))
729#define MV643XX_ETH_PORT_DEBUG_1_REG(port) (0x2490 + (port<<10)) 729#define MV643XX_ETH_PORT_DEBUG_1_REG(port) (0x2490 + (port<<10))
730#define MV643XX_ETH_PORT_INTERNAL_ADDR_ERROR_REG(port) (0x2494 + (port<<10)) 730#define MV643XX_ETH_PORT_INTERNAL_ADDR_ERROR_REG(port) (0x2494 + (port<<10))
@@ -1135,7 +1135,7 @@ struct mv64xxx_i2c_pdata {
1135#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_1 (1<<19) 1135#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_1 (1<<19)
1136#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_2 (1<<20) 1136#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_2 (1<<20)
1137#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_3 ((1<<20) | (1<<19)) 1137#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_3 ((1<<20) | (1<<19))
1138#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4 ((1<<21) 1138#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4 (1<<21)
1139#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_5 ((1<<21) | (1<<19)) 1139#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_5 ((1<<21) | (1<<19))
1140#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_6 ((1<<21) | (1<<20)) 1140#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_6 ((1<<21) | (1<<20))
1141#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_7 ((1<<21) | (1<<20) | (1<<19)) 1141#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_7 ((1<<21) | (1<<20) | (1<<19))
diff --git a/include/linux/net.h b/include/linux/net.h
index 15c733b816f0..6f0dfeba509a 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -196,7 +196,7 @@ extern struct socket *sockfd_lookup(int fd, int *err);
196extern int net_ratelimit(void); 196extern int net_ratelimit(void);
197 197
198#define net_random() random32() 198#define net_random() random32()
199#define net_srandom(seed) srandom32(seed) 199#define net_srandom(seed) srandom32((__force u32)seed)
200 200
201extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg, 201extern int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
202 struct kvec *vec, size_t num, size_t len); 202 struct kvec *vec, size_t num, size_t len);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9264139bd8df..949eada46ce1 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -38,7 +38,6 @@
38#include <linux/percpu.h> 38#include <linux/percpu.h>
39#include <linux/dmaengine.h> 39#include <linux/dmaengine.h>
40 40
41struct divert_blk;
42struct vlan_group; 41struct vlan_group;
43struct ethtool_ops; 42struct ethtool_ops;
44struct netpoll_info; 43struct netpoll_info;
@@ -67,6 +66,10 @@ struct netpoll_info;
67#define NET_RX_CN_HIGH 4 /* The storm is here */ 66#define NET_RX_CN_HIGH 4 /* The storm is here */
68#define NET_RX_BAD 5 /* packet dropped due to kernel error */ 67#define NET_RX_BAD 5 /* packet dropped due to kernel error */
69 68
69/* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It
70 * indicates that the device will soon be dropping packets, or already drops
71 * some packets of the same priority; prompting us to send less aggressively. */
72#define net_xmit_eval(e) ((e) == NET_XMIT_CN? 0 : (e))
70#define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0) 73#define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0)
71 74
72#endif 75#endif
@@ -93,8 +96,10 @@ struct netpoll_info;
93#endif 96#endif
94#endif 97#endif
95 98
96#if !defined(CONFIG_NET_IPIP) && \ 99#if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \
97 !defined(CONFIG_IPV6) && !defined(CONFIG_IPV6_MODULE) 100 !defined(CONFIG_NET_IPGRE) && !defined(CONFIG_NET_IPGRE_MODULE) && \
101 !defined(CONFIG_IPV6_SIT) && !defined(CONFIG_IPV6_SIT_MODULE) && \
102 !defined(CONFIG_IPV6_TUNNEL) && !defined(CONFIG_IPV6_TUNNEL_MODULE)
98#define MAX_HEADER LL_MAX_HEADER 103#define MAX_HEADER LL_MAX_HEADER
99#else 104#else
100#define MAX_HEADER (LL_MAX_HEADER + 48) 105#define MAX_HEADER (LL_MAX_HEADER + 48)
@@ -191,7 +196,7 @@ struct hh_cache
191 * NOTE: For VLANs, this will be the 196 * NOTE: For VLANs, this will be the
192 * encapuslated type. --BLG 197 * encapuslated type. --BLG
193 */ 198 */
194 int hh_len; /* length of header */ 199 u16 hh_len; /* length of header */
195 int (*hh_output)(struct sk_buff *skb); 200 int (*hh_output)(struct sk_buff *skb);
196 rwlock_t hh_lock; 201 rwlock_t hh_lock;
197 202
@@ -515,11 +520,6 @@ struct net_device
515 /* bridge stuff */ 520 /* bridge stuff */
516 struct net_bridge_port *br_port; 521 struct net_bridge_port *br_port;
517 522
518#ifdef CONFIG_NET_DIVERT
519 /* this will get initialized at each interface type init routine */
520 struct divert_blk *divert;
521#endif /* CONFIG_NET_DIVERT */
522
523 /* class/net/name entry */ 523 /* class/net/name entry */
524 struct class_device class_dev; 524 struct class_device class_dev;
525 /* space for optional statistics and wireless sysfs groups */ 525 /* space for optional statistics and wireless sysfs groups */
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index b7e67d1d4382..d4c4c5120bc0 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -117,6 +117,16 @@ void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n);
117int nf_register_sockopt(struct nf_sockopt_ops *reg); 117int nf_register_sockopt(struct nf_sockopt_ops *reg);
118void nf_unregister_sockopt(struct nf_sockopt_ops *reg); 118void nf_unregister_sockopt(struct nf_sockopt_ops *reg);
119 119
120#ifdef CONFIG_SYSCTL
121/* Sysctl registration */
122struct ctl_table_header *nf_register_sysctl_table(struct ctl_table *path,
123 struct ctl_table *table);
124void nf_unregister_sysctl_table(struct ctl_table_header *header,
125 struct ctl_table *table);
126extern struct ctl_table nf_net_netfilter_sysctl_path[];
127extern struct ctl_table nf_net_ipv4_netfilter_sysctl_path[];
128#endif /* CONFIG_SYSCTL */
129
120extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS]; 130extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS];
121 131
122/* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will 132/* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will
@@ -282,15 +292,31 @@ extern void nf_invalidate_cache(int pf);
282 Returns true or false. */ 292 Returns true or false. */
283extern int skb_make_writable(struct sk_buff **pskb, unsigned int writable_len); 293extern int skb_make_writable(struct sk_buff **pskb, unsigned int writable_len);
284 294
285extern u_int16_t nf_csum_update(u_int32_t oldval, u_int32_t newval, 295static inline void nf_csum_replace4(__sum16 *sum, __be32 from, __be32 to)
286 u_int32_t csum); 296{
287extern u_int16_t nf_proto_csum_update(struct sk_buff *skb, 297 __be32 diff[] = { ~from, to };
288 u_int32_t oldval, u_int32_t newval, 298
289 u_int16_t csum, int pseudohdr); 299 *sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum)));
300}
301
302static inline void nf_csum_replace2(__sum16 *sum, __be16 from, __be16 to)
303{
304 nf_csum_replace4(sum, (__force __be32)from, (__force __be32)to);
305}
306
307extern void nf_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
308 __be32 from, __be32 to, int pseudohdr);
309
310static inline void nf_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb,
311 __be16 from, __be16 to, int pseudohdr)
312{
313 nf_proto_csum_replace4(sum, skb, (__force __be32)from,
314 (__force __be32)to, pseudohdr);
315}
290 316
291struct nf_afinfo { 317struct nf_afinfo {
292 unsigned short family; 318 unsigned short family;
293 unsigned int (*checksum)(struct sk_buff *skb, unsigned int hook, 319 __sum16 (*checksum)(struct sk_buff *skb, unsigned int hook,
294 unsigned int dataoff, u_int8_t protocol); 320 unsigned int dataoff, u_int8_t protocol);
295 void (*saveroute)(const struct sk_buff *skb, 321 void (*saveroute)(const struct sk_buff *skb,
296 struct nf_info *info); 322 struct nf_info *info);
@@ -305,12 +331,12 @@ static inline struct nf_afinfo *nf_get_afinfo(unsigned short family)
305 return rcu_dereference(nf_afinfo[family]); 331 return rcu_dereference(nf_afinfo[family]);
306} 332}
307 333
308static inline unsigned int 334static inline __sum16
309nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff, 335nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
310 u_int8_t protocol, unsigned short family) 336 u_int8_t protocol, unsigned short family)
311{ 337{
312 struct nf_afinfo *afinfo; 338 struct nf_afinfo *afinfo;
313 unsigned int csum = 0; 339 __sum16 csum = 0;
314 340
315 rcu_read_lock(); 341 rcu_read_lock();
316 afinfo = nf_get_afinfo(family); 342 afinfo = nf_get_afinfo(family);
@@ -331,7 +357,7 @@ extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *);
331static inline void 357static inline void
332nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family) 358nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family)
333{ 359{
334#ifdef CONFIG_IP_NF_NAT_NEEDED 360#if defined(CONFIG_IP_NF_NAT_NEEDED) || defined(CONFIG_NF_NAT_NEEDED)
335 void (*decodefn)(struct sk_buff *, struct flowi *); 361 void (*decodefn)(struct sk_buff *, struct flowi *);
336 362
337 if (family == AF_INET && (decodefn = ip_nat_decode_session) != NULL) 363 if (family == AF_INET && (decodefn = ip_nat_decode_session) != NULL)
diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild
index 312bd2ffee33..6328175a1c3a 100644
--- a/include/linux/netfilter/Kbuild
+++ b/include/linux/netfilter/Kbuild
@@ -14,6 +14,7 @@ header-y += xt_dscp.h
14header-y += xt_DSCP.h 14header-y += xt_DSCP.h
15header-y += xt_esp.h 15header-y += xt_esp.h
16header-y += xt_helper.h 16header-y += xt_helper.h
17header-y += xt_hashlimit.h
17header-y += xt_length.h 18header-y += xt_length.h
18header-y += xt_limit.h 19header-y += xt_limit.h
19header-y += xt_mac.h 20header-y += xt_mac.h
@@ -21,6 +22,7 @@ header-y += xt_mark.h
21header-y += xt_MARK.h 22header-y += xt_MARK.h
22header-y += xt_multiport.h 23header-y += xt_multiport.h
23header-y += xt_NFQUEUE.h 24header-y += xt_NFQUEUE.h
25header-y += xt_NFLOG.h
24header-y += xt_pkttype.h 26header-y += xt_pkttype.h
25header-y += xt_policy.h 27header-y += xt_policy.h
26header-y += xt_realm.h 28header-y += xt_realm.h
diff --git a/include/linux/netfilter/nf_conntrack_amanda.h b/include/linux/netfilter/nf_conntrack_amanda.h
new file mode 100644
index 000000000000..26c223544ae8
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_amanda.h
@@ -0,0 +1,10 @@
1#ifndef _NF_CONNTRACK_AMANDA_H
2#define _NF_CONNTRACK_AMANDA_H
3/* AMANDA tracking. */
4
5extern unsigned int (*nf_nat_amanda_hook)(struct sk_buff **pskb,
6 enum ip_conntrack_info ctinfo,
7 unsigned int matchoff,
8 unsigned int matchlen,
9 struct nf_conntrack_expect *exp);
10#endif /* _NF_CONNTRACK_AMANDA_H */
diff --git a/include/linux/netfilter/nf_conntrack_ftp.h b/include/linux/netfilter/nf_conntrack_ftp.h
index ad4a41c9ce93..81453ea7e4c2 100644
--- a/include/linux/netfilter/nf_conntrack_ftp.h
+++ b/include/linux/netfilter/nf_conntrack_ftp.h
@@ -3,16 +3,16 @@
3/* FTP tracking. */ 3/* FTP tracking. */
4 4
5/* This enum is exposed to userspace */ 5/* This enum is exposed to userspace */
6enum ip_ct_ftp_type 6enum nf_ct_ftp_type
7{ 7{
8 /* PORT command from client */ 8 /* PORT command from client */
9 IP_CT_FTP_PORT, 9 NF_CT_FTP_PORT,
10 /* PASV response from server */ 10 /* PASV response from server */
11 IP_CT_FTP_PASV, 11 NF_CT_FTP_PASV,
12 /* EPRT command from client */ 12 /* EPRT command from client */
13 IP_CT_FTP_EPRT, 13 NF_CT_FTP_EPRT,
14 /* EPSV response from server */ 14 /* EPSV response from server */
15 IP_CT_FTP_EPSV, 15 NF_CT_FTP_EPSV,
16}; 16};
17 17
18#ifdef __KERNEL__ 18#ifdef __KERNEL__
@@ -21,23 +21,23 @@ enum ip_ct_ftp_type
21 21
22#define NUM_SEQ_TO_REMEMBER 2 22#define NUM_SEQ_TO_REMEMBER 2
23/* This structure exists only once per master */ 23/* This structure exists only once per master */
24struct ip_ct_ftp_master { 24struct nf_ct_ftp_master {
25 /* Valid seq positions for cmd matching after newline */ 25 /* Valid seq positions for cmd matching after newline */
26 u_int32_t seq_aft_nl[IP_CT_DIR_MAX][NUM_SEQ_TO_REMEMBER]; 26 u_int32_t seq_aft_nl[IP_CT_DIR_MAX][NUM_SEQ_TO_REMEMBER];
27 /* 0 means seq_match_aft_nl not set */ 27 /* 0 means seq_match_aft_nl not set */
28 int seq_aft_nl_num[IP_CT_DIR_MAX]; 28 int seq_aft_nl_num[IP_CT_DIR_MAX];
29}; 29};
30 30
31struct ip_conntrack_expect; 31struct nf_conntrack_expect;
32 32
33/* For NAT to hook in when we find a packet which describes what other 33/* For NAT to hook in when we find a packet which describes what other
34 * connection we should expect. */ 34 * connection we should expect. */
35extern unsigned int (*ip_nat_ftp_hook)(struct sk_buff **pskb, 35extern unsigned int (*nf_nat_ftp_hook)(struct sk_buff **pskb,
36 enum ip_conntrack_info ctinfo, 36 enum ip_conntrack_info ctinfo,
37 enum ip_ct_ftp_type type, 37 enum nf_ct_ftp_type type,
38 unsigned int matchoff, 38 unsigned int matchoff,
39 unsigned int matchlen, 39 unsigned int matchlen,
40 struct ip_conntrack_expect *exp, 40 struct nf_conntrack_expect *exp,
41 u32 *seq); 41 u32 *seq);
42#endif /* __KERNEL__ */ 42#endif /* __KERNEL__ */
43 43
diff --git a/include/linux/netfilter/nf_conntrack_h323.h b/include/linux/netfilter/nf_conntrack_h323.h
new file mode 100644
index 000000000000..08e2f4977c2e
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_h323.h
@@ -0,0 +1,92 @@
1#ifndef _NF_CONNTRACK_H323_H
2#define _NF_CONNTRACK_H323_H
3
4#ifdef __KERNEL__
5
6#include <linux/netfilter/nf_conntrack_h323_asn1.h>
7
8#define RAS_PORT 1719
9#define Q931_PORT 1720
10#define H323_RTP_CHANNEL_MAX 4 /* Audio, video, FAX and other */
11
12/* This structure exists only once per master */
13struct nf_ct_h323_master {
14
15 /* Original and NATed Q.931 or H.245 signal ports */
16 __be16 sig_port[IP_CT_DIR_MAX];
17
18 /* Original and NATed RTP ports */
19 __be16 rtp_port[H323_RTP_CHANNEL_MAX][IP_CT_DIR_MAX];
20
21 union {
22 /* RAS connection timeout */
23 u_int32_t timeout;
24
25 /* Next TPKT length (for separate TPKT header and data) */
26 u_int16_t tpkt_len[IP_CT_DIR_MAX];
27 };
28};
29
30struct nf_conn;
31
32extern int get_h225_addr(struct nf_conn *ct, unsigned char *data,
33 TransportAddress *taddr,
34 union nf_conntrack_address *addr, __be16 *port);
35extern void nf_conntrack_h245_expect(struct nf_conn *new,
36 struct nf_conntrack_expect *this);
37extern void nf_conntrack_q931_expect(struct nf_conn *new,
38 struct nf_conntrack_expect *this);
39extern int (*set_h245_addr_hook) (struct sk_buff **pskb,
40 unsigned char **data, int dataoff,
41 H245_TransportAddress *taddr,
42 union nf_conntrack_address *addr,
43 __be16 port);
44extern int (*set_h225_addr_hook) (struct sk_buff **pskb,
45 unsigned char **data, int dataoff,
46 TransportAddress *taddr,
47 union nf_conntrack_address *addr,
48 __be16 port);
49extern int (*set_sig_addr_hook) (struct sk_buff **pskb,
50 struct nf_conn *ct,
51 enum ip_conntrack_info ctinfo,
52 unsigned char **data,
53 TransportAddress *taddr, int count);
54extern int (*set_ras_addr_hook) (struct sk_buff **pskb,
55 struct nf_conn *ct,
56 enum ip_conntrack_info ctinfo,
57 unsigned char **data,
58 TransportAddress *taddr, int count);
59extern int (*nat_rtp_rtcp_hook) (struct sk_buff **pskb,
60 struct nf_conn *ct,
61 enum ip_conntrack_info ctinfo,
62 unsigned char **data, int dataoff,
63 H245_TransportAddress *taddr,
64 __be16 port, __be16 rtp_port,
65 struct nf_conntrack_expect *rtp_exp,
66 struct nf_conntrack_expect *rtcp_exp);
67extern int (*nat_t120_hook) (struct sk_buff **pskb, struct nf_conn *ct,
68 enum ip_conntrack_info ctinfo,
69 unsigned char **data, int dataoff,
70 H245_TransportAddress *taddr, __be16 port,
71 struct nf_conntrack_expect *exp);
72extern int (*nat_h245_hook) (struct sk_buff **pskb, struct nf_conn *ct,
73 enum ip_conntrack_info ctinfo,
74 unsigned char **data, int dataoff,
75 TransportAddress *taddr, __be16 port,
76 struct nf_conntrack_expect *exp);
77extern int (*nat_callforwarding_hook) (struct sk_buff **pskb,
78 struct nf_conn *ct,
79 enum ip_conntrack_info ctinfo,
80 unsigned char **data, int dataoff,
81 TransportAddress *taddr,
82 __be16 port,
83 struct nf_conntrack_expect *exp);
84extern int (*nat_q931_hook) (struct sk_buff **pskb, struct nf_conn *ct,
85 enum ip_conntrack_info ctinfo,
86 unsigned char **data, TransportAddress *taddr,
87 int idx, __be16 port,
88 struct nf_conntrack_expect *exp);
89
90#endif
91
92#endif
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h b/include/linux/netfilter/nf_conntrack_h323_asn1.h
index c6e9a0b6d30b..8dab5968fc7e 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h
+++ b/include/linux/netfilter/nf_conntrack_h323_asn1.h
@@ -1,6 +1,6 @@
1/**************************************************************************** 1/****************************************************************************
2 * ip_conntrack_helper_h323_asn1.h - BER and PER decoding library for H.323 2 * ip_conntrack_h323_asn1.h - BER and PER decoding library for H.323
3 * conntrack/NAT module. 3 * conntrack/NAT module.
4 * 4 *
5 * Copyright (c) 2006 by Jing Min Zhao <zhaojingmin@users.sourceforge.net> 5 * Copyright (c) 2006 by Jing Min Zhao <zhaojingmin@users.sourceforge.net>
6 * 6 *
@@ -34,13 +34,13 @@
34 * 34 *
35 ****************************************************************************/ 35 ****************************************************************************/
36 36
37#ifndef _IP_CONNTRACK_HELPER_H323_ASN1_H_ 37#ifndef _NF_CONNTRACK_HELPER_H323_ASN1_H_
38#define _IP_CONNTRACK_HELPER_H323_ASN1_H_ 38#define _NF_CONNTRACK_HELPER_H323_ASN1_H_
39 39
40/***************************************************************************** 40/*****************************************************************************
41 * H.323 Types 41 * H.323 Types
42 ****************************************************************************/ 42 ****************************************************************************/
43#include "ip_conntrack_helper_h323_types.h" 43#include "nf_conntrack_h323_types.h"
44 44
45typedef struct { 45typedef struct {
46 enum { 46 enum {
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h b/include/linux/netfilter/nf_conntrack_h323_types.h
index 3d4a773799fc..38d74d5c9700 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_helper_h323_types.h
+++ b/include/linux/netfilter/nf_conntrack_h323_types.h
@@ -10,6 +10,11 @@ typedef struct TransportAddress_ipAddress { /* SEQUENCE */
10 unsigned ip; 10 unsigned ip;
11} TransportAddress_ipAddress; 11} TransportAddress_ipAddress;
12 12
13typedef struct TransportAddress_ip6Address { /* SEQUENCE */
14 int options; /* No use */
15 unsigned ip6;
16} TransportAddress_ip6Address;
17
13typedef struct TransportAddress { /* CHOICE */ 18typedef struct TransportAddress { /* CHOICE */
14 enum { 19 enum {
15 eTransportAddress_ipAddress, 20 eTransportAddress_ipAddress,
@@ -22,6 +27,7 @@ typedef struct TransportAddress { /* CHOICE */
22 } choice; 27 } choice;
23 union { 28 union {
24 TransportAddress_ipAddress ipAddress; 29 TransportAddress_ipAddress ipAddress;
30 TransportAddress_ip6Address ip6Address;
25 }; 31 };
26} TransportAddress; 32} TransportAddress;
27 33
@@ -93,6 +99,11 @@ typedef struct UnicastAddress_iPAddress { /* SEQUENCE */
93 unsigned network; 99 unsigned network;
94} UnicastAddress_iPAddress; 100} UnicastAddress_iPAddress;
95 101
102typedef struct UnicastAddress_iP6Address { /* SEQUENCE */
103 int options; /* No use */
104 unsigned network;
105} UnicastAddress_iP6Address;
106
96typedef struct UnicastAddress { /* CHOICE */ 107typedef struct UnicastAddress { /* CHOICE */
97 enum { 108 enum {
98 eUnicastAddress_iPAddress, 109 eUnicastAddress_iPAddress,
@@ -105,6 +116,7 @@ typedef struct UnicastAddress { /* CHOICE */
105 } choice; 116 } choice;
106 union { 117 union {
107 UnicastAddress_iPAddress iPAddress; 118 UnicastAddress_iPAddress iPAddress;
119 UnicastAddress_iP6Address iP6Address;
108 }; 120 };
109} UnicastAddress; 121} UnicastAddress;
110 122
diff --git a/include/linux/netfilter/nf_conntrack_irc.h b/include/linux/netfilter/nf_conntrack_irc.h
new file mode 100644
index 000000000000..2ab6b8255911
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_irc.h
@@ -0,0 +1,15 @@
1#ifndef _NF_CONNTRACK_IRC_H
2#define _NF_CONNTRACK_IRC_H
3
4#ifdef __KERNEL__
5
6#define IRC_PORT 6667
7
8extern unsigned int (*nf_nat_irc_hook)(struct sk_buff **pskb,
9 enum ip_conntrack_info ctinfo,
10 unsigned int matchoff,
11 unsigned int matchlen,
12 struct nf_conntrack_expect *exp);
13
14#endif /* __KERNEL__ */
15#endif /* _NF_CONNTRACK_IRC_H */
diff --git a/include/linux/netfilter/nf_conntrack_pptp.h b/include/linux/netfilter/nf_conntrack_pptp.h
new file mode 100644
index 000000000000..fb049ec11ff2
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_pptp.h
@@ -0,0 +1,321 @@
1/* PPTP constants and structs */
2#ifndef _NF_CONNTRACK_PPTP_H
3#define _NF_CONNTRACK_PPTP_H
4
5/* state of the control session */
6enum pptp_ctrlsess_state {
7 PPTP_SESSION_NONE, /* no session present */
8 PPTP_SESSION_ERROR, /* some session error */
9 PPTP_SESSION_STOPREQ, /* stop_sess request seen */
10 PPTP_SESSION_REQUESTED, /* start_sess request seen */
11 PPTP_SESSION_CONFIRMED, /* session established */
12};
13
14/* state of the call inside the control session */
15enum pptp_ctrlcall_state {
16 PPTP_CALL_NONE,
17 PPTP_CALL_ERROR,
18 PPTP_CALL_OUT_REQ,
19 PPTP_CALL_OUT_CONF,
20 PPTP_CALL_IN_REQ,
21 PPTP_CALL_IN_REP,
22 PPTP_CALL_IN_CONF,
23 PPTP_CALL_CLEAR_REQ,
24};
25
26/* conntrack private data */
27struct nf_ct_pptp_master {
28 enum pptp_ctrlsess_state sstate; /* session state */
29 enum pptp_ctrlcall_state cstate; /* call state */
30 __be16 pac_call_id; /* call id of PAC */
31 __be16 pns_call_id; /* call id of PNS */
32
33 /* in pre-2.6.11 this used to be per-expect. Now it is per-conntrack
34 * and therefore imposes a fixed limit on the number of maps */
35 struct nf_ct_gre_keymap *keymap[IP_CT_DIR_MAX];
36};
37
38struct nf_nat_pptp {
39 __be16 pns_call_id; /* NAT'ed PNS call id */
40 __be16 pac_call_id; /* NAT'ed PAC call id */
41};
42
43#ifdef __KERNEL__
44
45#define PPTP_CONTROL_PORT 1723
46
47#define PPTP_PACKET_CONTROL 1
48#define PPTP_PACKET_MGMT 2
49
50#define PPTP_MAGIC_COOKIE 0x1a2b3c4d
51
52struct pptp_pkt_hdr {
53 __u16 packetLength;
54 __be16 packetType;
55 __be32 magicCookie;
56};
57
58/* PptpControlMessageType values */
59#define PPTP_START_SESSION_REQUEST 1
60#define PPTP_START_SESSION_REPLY 2
61#define PPTP_STOP_SESSION_REQUEST 3
62#define PPTP_STOP_SESSION_REPLY 4
63#define PPTP_ECHO_REQUEST 5
64#define PPTP_ECHO_REPLY 6
65#define PPTP_OUT_CALL_REQUEST 7
66#define PPTP_OUT_CALL_REPLY 8
67#define PPTP_IN_CALL_REQUEST 9
68#define PPTP_IN_CALL_REPLY 10
69#define PPTP_IN_CALL_CONNECT 11
70#define PPTP_CALL_CLEAR_REQUEST 12
71#define PPTP_CALL_DISCONNECT_NOTIFY 13
72#define PPTP_WAN_ERROR_NOTIFY 14
73#define PPTP_SET_LINK_INFO 15
74
75#define PPTP_MSG_MAX 15
76
77/* PptpGeneralError values */
78#define PPTP_ERROR_CODE_NONE 0
79#define PPTP_NOT_CONNECTED 1
80#define PPTP_BAD_FORMAT 2
81#define PPTP_BAD_VALUE 3
82#define PPTP_NO_RESOURCE 4
83#define PPTP_BAD_CALLID 5
84#define PPTP_REMOVE_DEVICE_ERROR 6
85
86struct PptpControlHeader {
87 __be16 messageType;
88 __u16 reserved;
89};
90
91/* FramingCapability Bitmap Values */
92#define PPTP_FRAME_CAP_ASYNC 0x1
93#define PPTP_FRAME_CAP_SYNC 0x2
94
95/* BearerCapability Bitmap Values */
96#define PPTP_BEARER_CAP_ANALOG 0x1
97#define PPTP_BEARER_CAP_DIGITAL 0x2
98
99struct PptpStartSessionRequest {
100 __be16 protocolVersion;
101 __u16 reserved1;
102 __be32 framingCapability;
103 __be32 bearerCapability;
104 __be16 maxChannels;
105 __be16 firmwareRevision;
106 __u8 hostName[64];
107 __u8 vendorString[64];
108};
109
110/* PptpStartSessionResultCode Values */
111#define PPTP_START_OK 1
112#define PPTP_START_GENERAL_ERROR 2
113#define PPTP_START_ALREADY_CONNECTED 3
114#define PPTP_START_NOT_AUTHORIZED 4
115#define PPTP_START_UNKNOWN_PROTOCOL 5
116
117struct PptpStartSessionReply {
118 __be16 protocolVersion;
119 __u8 resultCode;
120 __u8 generalErrorCode;
121 __be32 framingCapability;
122 __be32 bearerCapability;
123 __be16 maxChannels;
124 __be16 firmwareRevision;
125 __u8 hostName[64];
126 __u8 vendorString[64];
127};
128
129/* PptpStopReasons */
130#define PPTP_STOP_NONE 1
131#define PPTP_STOP_PROTOCOL 2
132#define PPTP_STOP_LOCAL_SHUTDOWN 3
133
134struct PptpStopSessionRequest {
135 __u8 reason;
136 __u8 reserved1;
137 __u16 reserved2;
138};
139
140/* PptpStopSessionResultCode */
141#define PPTP_STOP_OK 1
142#define PPTP_STOP_GENERAL_ERROR 2
143
144struct PptpStopSessionReply {
145 __u8 resultCode;
146 __u8 generalErrorCode;
147 __u16 reserved1;
148};
149
150struct PptpEchoRequest {
151 __be32 identNumber;
152};
153
154/* PptpEchoReplyResultCode */
155#define PPTP_ECHO_OK 1
156#define PPTP_ECHO_GENERAL_ERROR 2
157
158struct PptpEchoReply {
159 __be32 identNumber;
160 __u8 resultCode;
161 __u8 generalErrorCode;
162 __u16 reserved;
163};
164
165/* PptpFramingType */
166#define PPTP_ASYNC_FRAMING 1
167#define PPTP_SYNC_FRAMING 2
168#define PPTP_DONT_CARE_FRAMING 3
169
170/* PptpCallBearerType */
171#define PPTP_ANALOG_TYPE 1
172#define PPTP_DIGITAL_TYPE 2
173#define PPTP_DONT_CARE_BEARER_TYPE 3
174
175struct PptpOutCallRequest {
176 __be16 callID;
177 __be16 callSerialNumber;
178 __be32 minBPS;
179 __be32 maxBPS;
180 __be32 bearerType;
181 __be32 framingType;
182 __be16 packetWindow;
183 __be16 packetProcDelay;
184 __be16 phoneNumberLength;
185 __u16 reserved1;
186 __u8 phoneNumber[64];
187 __u8 subAddress[64];
188};
189
190/* PptpCallResultCode */
191#define PPTP_OUTCALL_CONNECT 1
192#define PPTP_OUTCALL_GENERAL_ERROR 2
193#define PPTP_OUTCALL_NO_CARRIER 3
194#define PPTP_OUTCALL_BUSY 4
195#define PPTP_OUTCALL_NO_DIAL_TONE 5
196#define PPTP_OUTCALL_TIMEOUT 6
197#define PPTP_OUTCALL_DONT_ACCEPT 7
198
199struct PptpOutCallReply {
200 __be16 callID;
201 __be16 peersCallID;
202 __u8 resultCode;
203 __u8 generalErrorCode;
204 __be16 causeCode;
205 __be32 connectSpeed;
206 __be16 packetWindow;
207 __be16 packetProcDelay;
208 __be32 physChannelID;
209};
210
211struct PptpInCallRequest {
212 __be16 callID;
213 __be16 callSerialNumber;
214 __be32 callBearerType;
215 __be32 physChannelID;
216 __be16 dialedNumberLength;
217 __be16 dialingNumberLength;
218 __u8 dialedNumber[64];
219 __u8 dialingNumber[64];
220 __u8 subAddress[64];
221};
222
223/* PptpInCallResultCode */
224#define PPTP_INCALL_ACCEPT 1
225#define PPTP_INCALL_GENERAL_ERROR 2
226#define PPTP_INCALL_DONT_ACCEPT 3
227
228struct PptpInCallReply {
229 __be16 callID;
230 __be16 peersCallID;
231 __u8 resultCode;
232 __u8 generalErrorCode;
233 __be16 packetWindow;
234 __be16 packetProcDelay;
235 __u16 reserved;
236};
237
238struct PptpInCallConnected {
239 __be16 peersCallID;
240 __u16 reserved;
241 __be32 connectSpeed;
242 __be16 packetWindow;
243 __be16 packetProcDelay;
244 __be32 callFramingType;
245};
246
247struct PptpClearCallRequest {
248 __be16 callID;
249 __u16 reserved;
250};
251
252struct PptpCallDisconnectNotify {
253 __be16 callID;
254 __u8 resultCode;
255 __u8 generalErrorCode;
256 __be16 causeCode;
257 __u16 reserved;
258 __u8 callStatistics[128];
259};
260
261struct PptpWanErrorNotify {
262 __be16 peersCallID;
263 __u16 reserved;
264 __be32 crcErrors;
265 __be32 framingErrors;
266 __be32 hardwareOverRuns;
267 __be32 bufferOverRuns;
268 __be32 timeoutErrors;
269 __be32 alignmentErrors;
270};
271
272struct PptpSetLinkInfo {
273 __be16 peersCallID;
274 __u16 reserved;
275 __be32 sendAccm;
276 __be32 recvAccm;
277};
278
279union pptp_ctrl_union {
280 struct PptpStartSessionRequest sreq;
281 struct PptpStartSessionReply srep;
282 struct PptpStopSessionRequest streq;
283 struct PptpStopSessionReply strep;
284 struct PptpOutCallRequest ocreq;
285 struct PptpOutCallReply ocack;
286 struct PptpInCallRequest icreq;
287 struct PptpInCallReply icack;
288 struct PptpInCallConnected iccon;
289 struct PptpClearCallRequest clrreq;
290 struct PptpCallDisconnectNotify disc;
291 struct PptpWanErrorNotify wanerr;
292 struct PptpSetLinkInfo setlink;
293};
294
295/* crap needed for nf_conntrack_compat.h */
296struct nf_conn;
297struct nf_conntrack_expect;
298enum ip_conntrack_info;
299
300extern int
301(*nf_nat_pptp_hook_outbound)(struct sk_buff **pskb,
302 struct nf_conn *ct, enum ip_conntrack_info ctinfo,
303 struct PptpControlHeader *ctlh,
304 union pptp_ctrl_union *pptpReq);
305
306extern int
307(*nf_nat_pptp_hook_inbound)(struct sk_buff **pskb,
308 struct nf_conn *ct, enum ip_conntrack_info ctinfo,
309 struct PptpControlHeader *ctlh,
310 union pptp_ctrl_union *pptpReq);
311
312extern void
313(*nf_nat_pptp_hook_exp_gre)(struct nf_conntrack_expect *exp_orig,
314 struct nf_conntrack_expect *exp_reply);
315
316extern void
317(*nf_nat_pptp_hook_expectfn)(struct nf_conn *ct,
318 struct nf_conntrack_expect *exp);
319
320#endif /* __KERNEL__ */
321#endif /* _NF_CONNTRACK_PPTP_H */
diff --git a/include/linux/netfilter/nf_conntrack_proto_gre.h b/include/linux/netfilter/nf_conntrack_proto_gre.h
new file mode 100644
index 000000000000..4e6bbce04ff8
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_proto_gre.h
@@ -0,0 +1,112 @@
1#ifndef _CONNTRACK_PROTO_GRE_H
2#define _CONNTRACK_PROTO_GRE_H
3#include <asm/byteorder.h>
4
5/* GRE PROTOCOL HEADER */
6
7/* GRE Version field */
8#define GRE_VERSION_1701 0x0
9#define GRE_VERSION_PPTP 0x1
10
11/* GRE Protocol field */
12#define GRE_PROTOCOL_PPTP 0x880B
13
14/* GRE Flags */
15#define GRE_FLAG_C 0x80
16#define GRE_FLAG_R 0x40
17#define GRE_FLAG_K 0x20
18#define GRE_FLAG_S 0x10
19#define GRE_FLAG_A 0x80
20
21#define GRE_IS_C(f) ((f)&GRE_FLAG_C)
22#define GRE_IS_R(f) ((f)&GRE_FLAG_R)
23#define GRE_IS_K(f) ((f)&GRE_FLAG_K)
24#define GRE_IS_S(f) ((f)&GRE_FLAG_S)
25#define GRE_IS_A(f) ((f)&GRE_FLAG_A)
26
27/* GRE is a mess: Four different standards */
28struct gre_hdr {
29#if defined(__LITTLE_ENDIAN_BITFIELD)
30 __u16 rec:3,
31 srr:1,
32 seq:1,
33 key:1,
34 routing:1,
35 csum:1,
36 version:3,
37 reserved:4,
38 ack:1;
39#elif defined(__BIG_ENDIAN_BITFIELD)
40 __u16 csum:1,
41 routing:1,
42 key:1,
43 seq:1,
44 srr:1,
45 rec:3,
46 ack:1,
47 reserved:4,
48 version:3;
49#else
50#error "Adjust your <asm/byteorder.h> defines"
51#endif
52 __be16 protocol;
53};
54
55/* modified GRE header for PPTP */
56struct gre_hdr_pptp {
57 __u8 flags; /* bitfield */
58 __u8 version; /* should be GRE_VERSION_PPTP */
59 __be16 protocol; /* should be GRE_PROTOCOL_PPTP */
60 __be16 payload_len; /* size of ppp payload, not inc. gre header */
61 __be16 call_id; /* peer's call_id for this session */
62 __be32 seq; /* sequence number. Present if S==1 */
63 __be32 ack; /* seq number of highest packet recieved by */
64 /* sender in this session */
65};
66
67struct nf_ct_gre {
68 unsigned int stream_timeout;
69 unsigned int timeout;
70};
71
72#ifdef __KERNEL__
73#include <net/netfilter/nf_conntrack_tuple.h>
74
75struct nf_conn;
76
77/* structure for original <-> reply keymap */
78struct nf_ct_gre_keymap {
79 struct list_head list;
80 struct nf_conntrack_tuple tuple;
81};
82
83/* add new tuple->key_reply pair to keymap */
84int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,
85 struct nf_conntrack_tuple *t);
86
87/* delete keymap entries */
88void nf_ct_gre_keymap_destroy(struct nf_conn *ct);
89
90/* get pointer to gre key, if present */
91static inline __be32 *gre_key(struct gre_hdr *greh)
92{
93 if (!greh->key)
94 return NULL;
95 if (greh->csum || greh->routing)
96 return (__be32 *)(greh+sizeof(*greh)+4);
97 return (__be32 *)(greh+sizeof(*greh));
98}
99
100/* get pointer ot gre csum, if present */
101static inline __sum16 *gre_csum(struct gre_hdr *greh)
102{
103 if (!greh->csum)
104 return NULL;
105 return (__sum16 *)(greh+sizeof(*greh));
106}
107
108extern void nf_ct_gre_keymap_flush(void);
109extern void nf_nat_need_gre(void);
110
111#endif /* __KERNEL__ */
112#endif /* _CONNTRACK_PROTO_GRE_H */
diff --git a/include/linux/netfilter/nf_conntrack_sctp.h b/include/linux/netfilter/nf_conntrack_sctp.h
index b8994d9fd1a9..5cf2c115cce4 100644
--- a/include/linux/netfilter/nf_conntrack_sctp.h
+++ b/include/linux/netfilter/nf_conntrack_sctp.h
@@ -20,7 +20,7 @@ struct ip_ct_sctp
20{ 20{
21 enum sctp_conntrack state; 21 enum sctp_conntrack state;
22 22
23 u_int32_t vtag[IP_CT_DIR_MAX]; 23 __be32 vtag[IP_CT_DIR_MAX];
24 u_int32_t ttag[IP_CT_DIR_MAX]; 24 u_int32_t ttag[IP_CT_DIR_MAX];
25}; 25};
26 26
diff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h
new file mode 100644
index 000000000000..bb7f2041db74
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_sip.h
@@ -0,0 +1,41 @@
1#ifndef __NF_CONNTRACK_SIP_H__
2#define __NF_CONNTRACK_SIP_H__
3#ifdef __KERNEL__
4
5#define SIP_PORT 5060
6#define SIP_TIMEOUT 3600
7
8enum sip_header_pos {
9 POS_REG_REQ_URI,
10 POS_REQ_URI,
11 POS_FROM,
12 POS_TO,
13 POS_VIA,
14 POS_CONTACT,
15 POS_CONTENT,
16 POS_MEDIA,
17 POS_OWNER_IP4,
18 POS_CONNECTION_IP4,
19 POS_OWNER_IP6,
20 POS_CONNECTION_IP6,
21 POS_SDP_HEADER,
22};
23
24extern unsigned int (*nf_nat_sip_hook)(struct sk_buff **pskb,
25 enum ip_conntrack_info ctinfo,
26 struct nf_conn *ct,
27 const char **dptr);
28extern unsigned int (*nf_nat_sdp_hook)(struct sk_buff **pskb,
29 enum ip_conntrack_info ctinfo,
30 struct nf_conntrack_expect *exp,
31 const char *dptr);
32
33extern int ct_sip_get_info(struct nf_conn *ct, const char *dptr, size_t dlen,
34 unsigned int *matchoff, unsigned int *matchlen,
35 enum sip_header_pos pos);
36extern int ct_sip_lnlen(const char *line, const char *limit);
37extern const char *ct_sip_search(const char *needle, const char *haystack,
38 size_t needle_len, size_t haystack_len,
39 int case_sensitive);
40#endif /* __KERNEL__ */
41#endif /* __NF_CONNTRACK_SIP_H__ */
diff --git a/include/linux/netfilter/nf_conntrack_tftp.h b/include/linux/netfilter/nf_conntrack_tftp.h
new file mode 100644
index 000000000000..0d79b7ae051f
--- /dev/null
+++ b/include/linux/netfilter/nf_conntrack_tftp.h
@@ -0,0 +1,20 @@
1#ifndef _NF_CONNTRACK_TFTP_H
2#define _NF_CONNTRACK_TFTP_H
3
4#define TFTP_PORT 69
5
6struct tftphdr {
7 __be16 opcode;
8};
9
10#define TFTP_OPCODE_READ 1
11#define TFTP_OPCODE_WRITE 2
12#define TFTP_OPCODE_DATA 3
13#define TFTP_OPCODE_ACK 4
14#define TFTP_OPCODE_ERROR 5
15
16extern unsigned int (*nf_nat_tftp_hook)(struct sk_buff **pskb,
17 enum ip_conntrack_info ctinfo,
18 struct nf_conntrack_expect *exp);
19
20#endif /* _NF_CONNTRACK_TFTP_H */
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index 6d8e3e5a80e9..1e9c821f152d 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -78,7 +78,7 @@ struct nfattr
78struct nfgenmsg { 78struct nfgenmsg {
79 u_int8_t nfgen_family; /* AF_xxx */ 79 u_int8_t nfgen_family; /* AF_xxx */
80 u_int8_t version; /* nfnetlink version */ 80 u_int8_t version; /* nfnetlink version */
81 u_int16_t res_id; /* resource id */ 81 __be16 res_id; /* resource id */
82}; 82};
83 83
84#define NFNETLINK_V0 0 84#define NFNETLINK_V0 0
diff --git a/include/linux/netfilter/nfnetlink_log.h b/include/linux/netfilter/nfnetlink_log.h
index 87b92f8b988f..5966afa026e9 100644
--- a/include/linux/netfilter/nfnetlink_log.h
+++ b/include/linux/netfilter/nfnetlink_log.h
@@ -16,24 +16,22 @@ enum nfulnl_msg_types {
16}; 16};
17 17
18struct nfulnl_msg_packet_hdr { 18struct nfulnl_msg_packet_hdr {
19 u_int16_t hw_protocol; /* hw protocol (network order) */ 19 __be16 hw_protocol; /* hw protocol (network order) */
20 u_int8_t hook; /* netfilter hook */ 20 u_int8_t hook; /* netfilter hook */
21 u_int8_t _pad; 21 u_int8_t _pad;
22}; 22};
23 23
24struct nfulnl_msg_packet_hw { 24struct nfulnl_msg_packet_hw {
25 u_int16_t hw_addrlen; 25 __be16 hw_addrlen;
26 u_int16_t _pad; 26 u_int16_t _pad;
27 u_int8_t hw_addr[8]; 27 u_int8_t hw_addr[8];
28}; 28};
29 29
30struct nfulnl_msg_packet_timestamp { 30struct nfulnl_msg_packet_timestamp {
31 aligned_u64 sec; 31 aligned_be64 sec;
32 aligned_u64 usec; 32 aligned_be64 usec;
33}; 33};
34 34
35#define NFULNL_PREFIXLEN 30 /* just like old log target */
36
37enum nfulnl_attr_type { 35enum nfulnl_attr_type {
38 NFULA_UNSPEC, 36 NFULA_UNSPEC,
39 NFULA_PACKET_HDR, 37 NFULA_PACKET_HDR,
@@ -67,7 +65,7 @@ struct nfulnl_msg_config_cmd {
67} __attribute__ ((packed)); 65} __attribute__ ((packed));
68 66
69struct nfulnl_msg_config_mode { 67struct nfulnl_msg_config_mode {
70 u_int32_t copy_range; 68 __be32 copy_range;
71 u_int8_t copy_mode; 69 u_int8_t copy_mode;
72 u_int8_t _pad; 70 u_int8_t _pad;
73} __attribute__ ((packed)); 71} __attribute__ ((packed));
diff --git a/include/linux/netfilter/nfnetlink_queue.h b/include/linux/netfilter/nfnetlink_queue.h
index 36af0360b56d..83e789633e35 100644
--- a/include/linux/netfilter/nfnetlink_queue.h
+++ b/include/linux/netfilter/nfnetlink_queue.h
@@ -13,20 +13,20 @@ enum nfqnl_msg_types {
13}; 13};
14 14
15struct nfqnl_msg_packet_hdr { 15struct nfqnl_msg_packet_hdr {
16 u_int32_t packet_id; /* unique ID of packet in queue */ 16 __be32 packet_id; /* unique ID of packet in queue */
17 u_int16_t hw_protocol; /* hw protocol (network order) */ 17 __be16 hw_protocol; /* hw protocol (network order) */
18 u_int8_t hook; /* netfilter hook */ 18 u_int8_t hook; /* netfilter hook */
19} __attribute__ ((packed)); 19} __attribute__ ((packed));
20 20
21struct nfqnl_msg_packet_hw { 21struct nfqnl_msg_packet_hw {
22 u_int16_t hw_addrlen; 22 __be16 hw_addrlen;
23 u_int16_t _pad; 23 u_int16_t _pad;
24 u_int8_t hw_addr[8]; 24 u_int8_t hw_addr[8];
25}; 25};
26 26
27struct nfqnl_msg_packet_timestamp { 27struct nfqnl_msg_packet_timestamp {
28 aligned_u64 sec; 28 aligned_be64 sec;
29 aligned_u64 usec; 29 aligned_be64 usec;
30}; 30};
31 31
32enum nfqnl_attr_type { 32enum nfqnl_attr_type {
@@ -47,8 +47,8 @@ enum nfqnl_attr_type {
47#define NFQA_MAX (__NFQA_MAX - 1) 47#define NFQA_MAX (__NFQA_MAX - 1)
48 48
49struct nfqnl_msg_verdict_hdr { 49struct nfqnl_msg_verdict_hdr {
50 u_int32_t verdict; 50 __be32 verdict;
51 u_int32_t id; 51 __be32 id;
52}; 52};
53 53
54 54
@@ -63,7 +63,7 @@ enum nfqnl_msg_config_cmds {
63struct nfqnl_msg_config_cmd { 63struct nfqnl_msg_config_cmd {
64 u_int8_t command; /* nfqnl_msg_config_cmds */ 64 u_int8_t command; /* nfqnl_msg_config_cmds */
65 u_int8_t _pad; 65 u_int8_t _pad;
66 u_int16_t pf; /* AF_xxx for PF_[UN]BIND */ 66 __be16 pf; /* AF_xxx for PF_[UN]BIND */
67}; 67};
68 68
69enum nfqnl_config_mode { 69enum nfqnl_config_mode {
@@ -73,7 +73,7 @@ enum nfqnl_config_mode {
73}; 73};
74 74
75struct nfqnl_msg_config_params { 75struct nfqnl_msg_config_params {
76 u_int32_t copy_range; 76 __be32 copy_range;
77 u_int8_t copy_mode; /* enum nfqnl_config_mode */ 77 u_int8_t copy_mode; /* enum nfqnl_config_mode */
78} __attribute__ ((packed)); 78} __attribute__ ((packed));
79 79
@@ -82,6 +82,7 @@ enum nfqnl_attr_config {
82 NFQA_CFG_UNSPEC, 82 NFQA_CFG_UNSPEC,
83 NFQA_CFG_CMD, /* nfqnl_msg_config_cmd */ 83 NFQA_CFG_CMD, /* nfqnl_msg_config_cmd */
84 NFQA_CFG_PARAMS, /* nfqnl_msg_config_params */ 84 NFQA_CFG_PARAMS, /* nfqnl_msg_config_params */
85 NFQA_CFG_QUEUE_MAXLEN, /* u_int32_t */
85 __NFQA_CFG_MAX 86 __NFQA_CFG_MAX
86}; 87};
87#define NFQA_CFG_MAX (__NFQA_CFG_MAX-1) 88#define NFQA_CFG_MAX (__NFQA_CFG_MAX-1)
diff --git a/include/linux/netfilter/xt_NFLOG.h b/include/linux/netfilter/xt_NFLOG.h
new file mode 100644
index 000000000000..cdcd0ed58f7a
--- /dev/null
+++ b/include/linux/netfilter/xt_NFLOG.h
@@ -0,0 +1,18 @@
1#ifndef _XT_NFLOG_TARGET
2#define _XT_NFLOG_TARGET
3
4#define XT_NFLOG_DEFAULT_GROUP 0x1
5#define XT_NFLOG_DEFAULT_THRESHOLD 1
6
7#define XT_NFLOG_MASK 0x0
8
9struct xt_nflog_info {
10 u_int32_t len;
11 u_int16_t group;
12 u_int16_t threshold;
13 u_int16_t flags;
14 u_int16_t pad;
15 char prefix[64];
16};
17
18#endif /* _XT_NFLOG_TARGET */
diff --git a/include/linux/netfilter/xt_conntrack.h b/include/linux/netfilter/xt_conntrack.h
index 4c2d9945ca54..70b6f718cf4c 100644
--- a/include/linux/netfilter/xt_conntrack.h
+++ b/include/linux/netfilter/xt_conntrack.h
@@ -29,14 +29,14 @@
29struct ip_conntrack_old_tuple 29struct ip_conntrack_old_tuple
30{ 30{
31 struct { 31 struct {
32 __u32 ip; 32 __be32 ip;
33 union { 33 union {
34 __u16 all; 34 __u16 all;
35 } u; 35 } u;
36 } src; 36 } src;
37 37
38 struct { 38 struct {
39 __u32 ip; 39 __be32 ip;
40 union { 40 union {
41 __u16 all; 41 __u16 all;
42 } u; 42 } u;
diff --git a/include/linux/netfilter/xt_hashlimit.h b/include/linux/netfilter/xt_hashlimit.h
new file mode 100644
index 000000000000..b4556b8edbfd
--- /dev/null
+++ b/include/linux/netfilter/xt_hashlimit.h
@@ -0,0 +1,40 @@
1#ifndef _XT_HASHLIMIT_H
2#define _XT_HASHLIMIT_H
3
4/* timings are in milliseconds. */
5#define XT_HASHLIMIT_SCALE 10000
6/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
7 seconds, or one every 59 hours. */
8
9/* details of this structure hidden by the implementation */
10struct xt_hashlimit_htable;
11
12#define XT_HASHLIMIT_HASH_DIP 0x0001
13#define XT_HASHLIMIT_HASH_DPT 0x0002
14#define XT_HASHLIMIT_HASH_SIP 0x0004
15#define XT_HASHLIMIT_HASH_SPT 0x0008
16
17struct hashlimit_cfg {
18 u_int32_t mode; /* bitmask of IPT_HASHLIMIT_HASH_* */
19 u_int32_t avg; /* Average secs between packets * scale */
20 u_int32_t burst; /* Period multiplier for upper limit. */
21
22 /* user specified */
23 u_int32_t size; /* how many buckets */
24 u_int32_t max; /* max number of entries */
25 u_int32_t gc_interval; /* gc interval */
26 u_int32_t expire; /* when do entries expire? */
27};
28
29struct xt_hashlimit_info {
30 char name [IFNAMSIZ]; /* name */
31 struct hashlimit_cfg cfg;
32 struct xt_hashlimit_htable *hinfo;
33
34 /* Used internally by the kernel */
35 union {
36 void *ptr;
37 struct xt_hashlimit_info *master;
38 } u;
39};
40#endif /*_XT_HASHLIMIT_H*/
diff --git a/include/linux/netfilter/xt_policy.h b/include/linux/netfilter/xt_policy.h
index a8132ec076fb..45654d359a68 100644
--- a/include/linux/netfilter/xt_policy.h
+++ b/include/linux/netfilter/xt_policy.h
@@ -39,7 +39,7 @@ struct xt_policy_elem
39 union xt_policy_addr smask; 39 union xt_policy_addr smask;
40 union xt_policy_addr daddr; 40 union xt_policy_addr daddr;
41 union xt_policy_addr dmask; 41 union xt_policy_addr dmask;
42 u_int32_t spi; 42 __be32 spi;
43 u_int32_t reqid; 43 u_int32_t reqid;
44 u_int8_t proto; 44 u_int8_t proto;
45 u_int8_t mode; 45 u_int8_t mode;
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index 9a4dd11af86e..6c4613f8ad75 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -64,7 +64,7 @@ static inline int nf_bridge_pad(const struct sk_buff *skb)
64 64
65struct bridge_skb_cb { 65struct bridge_skb_cb {
66 union { 66 union {
67 __u32 ipv4; 67 __be32 ipv4;
68 } daddr; 68 } daddr;
69}; 69};
70 70
diff --git a/include/linux/netfilter_bridge/ebt_802_3.h b/include/linux/netfilter_bridge/ebt_802_3.h
index b9f712c14a0a..07f044ff1a6b 100644
--- a/include/linux/netfilter_bridge/ebt_802_3.h
+++ b/include/linux/netfilter_bridge/ebt_802_3.h
@@ -28,21 +28,21 @@ struct hdr_ui {
28 uint8_t ssap; 28 uint8_t ssap;
29 uint8_t ctrl; 29 uint8_t ctrl;
30 uint8_t orig[3]; 30 uint8_t orig[3];
31 uint16_t type; 31 __be16 type;
32}; 32};
33 33
34struct hdr_ni { 34struct hdr_ni {
35 uint8_t dsap; 35 uint8_t dsap;
36 uint8_t ssap; 36 uint8_t ssap;
37 uint16_t ctrl; 37 __be16 ctrl;
38 uint8_t orig[3]; 38 uint8_t orig[3];
39 uint16_t type; 39 __be16 type;
40}; 40};
41 41
42struct ebt_802_3_hdr { 42struct ebt_802_3_hdr {
43 uint8_t daddr[6]; 43 uint8_t daddr[6];
44 uint8_t saddr[6]; 44 uint8_t saddr[6];
45 uint16_t len; 45 __be16 len;
46 union { 46 union {
47 struct hdr_ui ui; 47 struct hdr_ui ui;
48 struct hdr_ni ni; 48 struct hdr_ni ni;
@@ -61,7 +61,7 @@ static inline struct ebt_802_3_hdr *ebt_802_3_hdr(const struct sk_buff *skb)
61struct ebt_802_3_info 61struct ebt_802_3_info
62{ 62{
63 uint8_t sap; 63 uint8_t sap;
64 uint16_t type; 64 __be16 type;
65 uint8_t bitmask; 65 uint8_t bitmask;
66 uint8_t invflags; 66 uint8_t invflags;
67}; 67};
diff --git a/include/linux/netfilter_bridge/ebt_among.h b/include/linux/netfilter_bridge/ebt_among.h
index 307c1fed8511..7654069233ca 100644
--- a/include/linux/netfilter_bridge/ebt_among.h
+++ b/include/linux/netfilter_bridge/ebt_among.h
@@ -32,7 +32,7 @@
32struct ebt_mac_wormhash_tuple 32struct ebt_mac_wormhash_tuple
33{ 33{
34 uint32_t cmp[2]; 34 uint32_t cmp[2];
35 uint32_t ip; 35 __be32 ip;
36}; 36};
37 37
38struct ebt_mac_wormhash 38struct ebt_mac_wormhash
diff --git a/include/linux/netfilter_bridge/ebt_arp.h b/include/linux/netfilter_bridge/ebt_arp.h
index 537ec6b487a2..97e4dbde1f89 100644
--- a/include/linux/netfilter_bridge/ebt_arp.h
+++ b/include/linux/netfilter_bridge/ebt_arp.h
@@ -14,13 +14,13 @@
14 14
15struct ebt_arp_info 15struct ebt_arp_info
16{ 16{
17 uint16_t htype; 17 __be16 htype;
18 uint16_t ptype; 18 __be16 ptype;
19 uint16_t opcode; 19 __be16 opcode;
20 uint32_t saddr; 20 __be32 saddr;
21 uint32_t smsk; 21 __be32 smsk;
22 uint32_t daddr; 22 __be32 daddr;
23 uint32_t dmsk; 23 __be32 dmsk;
24 unsigned char smaddr[ETH_ALEN]; 24 unsigned char smaddr[ETH_ALEN];
25 unsigned char smmsk[ETH_ALEN]; 25 unsigned char smmsk[ETH_ALEN];
26 unsigned char dmaddr[ETH_ALEN]; 26 unsigned char dmaddr[ETH_ALEN];
diff --git a/include/linux/netfilter_bridge/ebt_ip.h b/include/linux/netfilter_bridge/ebt_ip.h
index 7247385cdcb1..d6847475bf2e 100644
--- a/include/linux/netfilter_bridge/ebt_ip.h
+++ b/include/linux/netfilter_bridge/ebt_ip.h
@@ -28,10 +28,10 @@
28/* the same values are used for the invflags */ 28/* the same values are used for the invflags */
29struct ebt_ip_info 29struct ebt_ip_info
30{ 30{
31 uint32_t saddr; 31 __be32 saddr;
32 uint32_t daddr; 32 __be32 daddr;
33 uint32_t smsk; 33 __be32 smsk;
34 uint32_t dmsk; 34 __be32 dmsk;
35 uint8_t tos; 35 uint8_t tos;
36 uint8_t protocol; 36 uint8_t protocol;
37 uint8_t bitmask; 37 uint8_t bitmask;
diff --git a/include/linux/netfilter_bridge/ebt_nat.h b/include/linux/netfilter_bridge/ebt_nat.h
index 26fd90da4cd6..435b886a51aa 100644
--- a/include/linux/netfilter_bridge/ebt_nat.h
+++ b/include/linux/netfilter_bridge/ebt_nat.h
@@ -1,6 +1,7 @@
1#ifndef __LINUX_BRIDGE_EBT_NAT_H 1#ifndef __LINUX_BRIDGE_EBT_NAT_H
2#define __LINUX_BRIDGE_EBT_NAT_H 2#define __LINUX_BRIDGE_EBT_NAT_H
3 3
4#define NAT_ARP_BIT (0x00000010)
4struct ebt_nat_info 5struct ebt_nat_info
5{ 6{
6 unsigned char mac[ETH_ALEN]; 7 unsigned char mac[ETH_ALEN];
diff --git a/include/linux/netfilter_bridge/ebt_vlan.h b/include/linux/netfilter_bridge/ebt_vlan.h
index cb1fcc41565f..1d98be4031e7 100644
--- a/include/linux/netfilter_bridge/ebt_vlan.h
+++ b/include/linux/netfilter_bridge/ebt_vlan.h
@@ -10,7 +10,7 @@
10struct ebt_vlan_info { 10struct ebt_vlan_info {
11 uint16_t id; /* VLAN ID {1-4095} */ 11 uint16_t id; /* VLAN ID {1-4095} */
12 uint8_t prio; /* VLAN User Priority {0-7} */ 12 uint8_t prio; /* VLAN User Priority {0-7} */
13 uint16_t encap; /* VLAN Encapsulated frame code {0-65535} */ 13 __be16 encap; /* VLAN Encapsulated frame code {0-65535} */
14 uint8_t bitmask; /* Args bitmask bit 1=1 - ID arg, 14 uint8_t bitmask; /* Args bitmask bit 1=1 - ID arg,
15 bit 2=1 User-Priority arg, bit 3=1 encap*/ 15 bit 2=1 User-Priority arg, bit 3=1 encap*/
16 uint8_t invflags; /* Inverse bitmask bit 1=1 - inversed ID arg, 16 uint8_t invflags; /* Inverse bitmask bit 1=1 - inversed ID arg,
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index b1a7cc90877b..94e0a7dc0cb2 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -26,6 +26,10 @@
26#define EBT_CONTINUE -3 26#define EBT_CONTINUE -3
27#define EBT_RETURN -4 27#define EBT_RETURN -4
28#define NUM_STANDARD_TARGETS 4 28#define NUM_STANDARD_TARGETS 4
29/* ebtables target modules store the verdict inside an int. We can
30 * reclaim a part of this int for backwards compatible extensions.
31 * The 4 lsb are more than enough to store the verdict. */
32#define EBT_VERDICT_BITS 0x0000000F
29 33
30struct ebt_counter 34struct ebt_counter
31{ 35{
@@ -42,6 +46,23 @@ struct ebt_replace
42 /* total size of the entries */ 46 /* total size of the entries */
43 unsigned int entries_size; 47 unsigned int entries_size;
44 /* start of the chains */ 48 /* start of the chains */
49 struct ebt_entries __user *hook_entry[NF_BR_NUMHOOKS];
50 /* nr of counters userspace expects back */
51 unsigned int num_counters;
52 /* where the kernel will put the old counters */
53 struct ebt_counter __user *counters;
54 char __user *entries;
55};
56
57struct ebt_replace_kernel
58{
59 char name[EBT_TABLE_MAXNAMELEN];
60 unsigned int valid_hooks;
61 /* nr of rules in the table */
62 unsigned int nentries;
63 /* total size of the entries */
64 unsigned int entries_size;
65 /* start of the chains */
45 struct ebt_entries *hook_entry[NF_BR_NUMHOOKS]; 66 struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
46 /* nr of counters userspace expects back */ 67 /* nr of counters userspace expects back */
47 unsigned int num_counters; 68 unsigned int num_counters;
@@ -141,7 +162,7 @@ struct ebt_entry {
141 /* this needs to be the first field */ 162 /* this needs to be the first field */
142 unsigned int bitmask; 163 unsigned int bitmask;
143 unsigned int invflags; 164 unsigned int invflags;
144 uint16_t ethproto; 165 __be16 ethproto;
145 /* the physical in-dev */ 166 /* the physical in-dev */
146 char in[IFNAMSIZ]; 167 char in[IFNAMSIZ];
147 /* the logical in-dev */ 168 /* the logical in-dev */
@@ -251,7 +272,7 @@ struct ebt_table
251{ 272{
252 struct list_head list; 273 struct list_head list;
253 char name[EBT_TABLE_MAXNAMELEN]; 274 char name[EBT_TABLE_MAXNAMELEN];
254 struct ebt_replace *table; 275 struct ebt_replace_kernel *table;
255 unsigned int valid_hooks; 276 unsigned int valid_hooks;
256 rwlock_t lock; 277 rwlock_t lock;
257 /* e.g. could be the table explicitly only allows certain 278 /* e.g. could be the table explicitly only allows certain
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
index 5b63a231a76b..5821eb5a0a3e 100644
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -79,7 +79,7 @@ enum nf_ip_hook_priorities {
79#ifdef __KERNEL__ 79#ifdef __KERNEL__
80extern int ip_route_me_harder(struct sk_buff **pskb, unsigned addr_type); 80extern int ip_route_me_harder(struct sk_buff **pskb, unsigned addr_type);
81extern int ip_xfrm_me_harder(struct sk_buff **pskb); 81extern int ip_xfrm_me_harder(struct sk_buff **pskb);
82extern unsigned int nf_ip_checksum(struct sk_buff *skb, unsigned int hook, 82extern __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
83 unsigned int dataoff, u_int8_t protocol); 83 unsigned int dataoff, u_int8_t protocol);
84#endif /*__KERNEL__*/ 84#endif /*__KERNEL__*/
85 85
diff --git a/include/linux/netfilter_ipv4/Kbuild b/include/linux/netfilter_ipv4/Kbuild
index 591c1a809c00..180337801a86 100644
--- a/include/linux/netfilter_ipv4/Kbuild
+++ b/include/linux/netfilter_ipv4/Kbuild
@@ -1,6 +1,4 @@
1header-y += ip_conntrack_helper.h 1header-y += ip_conntrack_helper.h
2header-y += ip_conntrack_helper_h323_asn1.h
3header-y += ip_conntrack_helper_h323_types.h
4header-y += ip_conntrack_protocol.h 2header-y += ip_conntrack_protocol.h
5header-y += ip_conntrack_sctp.h 3header-y += ip_conntrack_sctp.h
6header-y += ip_conntrack_tcp.h 4header-y += ip_conntrack_tcp.h
diff --git a/include/linux/netfilter_ipv4/ip_conntrack.h b/include/linux/netfilter_ipv4/ip_conntrack.h
index 64e868034c4a..61da56941dce 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack.h
@@ -277,7 +277,7 @@ extern struct ip_conntrack_expect *
277__ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple); 277__ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple);
278 278
279extern struct ip_conntrack_expect * 279extern struct ip_conntrack_expect *
280ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple); 280ip_conntrack_expect_find_get(const struct ip_conntrack_tuple *tuple);
281 281
282extern struct ip_conntrack_tuple_hash * 282extern struct ip_conntrack_tuple_hash *
283__ip_conntrack_find(const struct ip_conntrack_tuple *tuple, 283__ip_conntrack_find(const struct ip_conntrack_tuple *tuple,
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_ftp.h b/include/linux/netfilter_ipv4/ip_conntrack_ftp.h
index 63811934de4d..2129fc3972ac 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_ftp.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_ftp.h
@@ -1,6 +1,44 @@
1#ifndef _IP_CONNTRACK_FTP_H 1#ifndef _IP_CONNTRACK_FTP_H
2#define _IP_CONNTRACK_FTP_H 2#define _IP_CONNTRACK_FTP_H
3/* FTP tracking. */
3 4
4#include <linux/netfilter/nf_conntrack_ftp.h> 5/* This enum is exposed to userspace */
6enum ip_ct_ftp_type
7{
8 /* PORT command from client */
9 IP_CT_FTP_PORT,
10 /* PASV response from server */
11 IP_CT_FTP_PASV,
12 /* EPRT command from client */
13 IP_CT_FTP_EPRT,
14 /* EPSV response from server */
15 IP_CT_FTP_EPSV,
16};
17
18#ifdef __KERNEL__
19
20#define FTP_PORT 21
21
22#define NUM_SEQ_TO_REMEMBER 2
23/* This structure exists only once per master */
24struct ip_ct_ftp_master {
25 /* Valid seq positions for cmd matching after newline */
26 u_int32_t seq_aft_nl[IP_CT_DIR_MAX][NUM_SEQ_TO_REMEMBER];
27 /* 0 means seq_match_aft_nl not set */
28 int seq_aft_nl_num[IP_CT_DIR_MAX];
29};
30
31struct ip_conntrack_expect;
32
33/* For NAT to hook in when we find a packet which describes what other
34 * connection we should expect. */
35extern unsigned int (*ip_nat_ftp_hook)(struct sk_buff **pskb,
36 enum ip_conntrack_info ctinfo,
37 enum ip_ct_ftp_type type,
38 unsigned int matchoff,
39 unsigned int matchlen,
40 struct ip_conntrack_expect *exp,
41 u32 *seq);
42#endif /* __KERNEL__ */
5 43
6#endif /* _IP_CONNTRACK_FTP_H */ 44#endif /* _IP_CONNTRACK_FTP_H */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_h323.h b/include/linux/netfilter_ipv4/ip_conntrack_h323.h
index 943cc6a4871d..18f769818f4e 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_h323.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_h323.h
@@ -3,7 +3,7 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h> 6#include <linux/netfilter/nf_conntrack_h323_asn1.h>
7 7
8#define RAS_PORT 1719 8#define RAS_PORT 1719
9#define Q931_PORT 1720 9#define Q931_PORT 1720
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h b/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h
index 1d853aa873eb..e371e0fc1672 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h
@@ -102,11 +102,11 @@ static inline __be32 *gre_key(struct gre_hdr *greh)
102} 102}
103 103
104/* get pointer ot gre csum, if present */ 104/* get pointer ot gre csum, if present */
105static inline u_int16_t *gre_csum(struct gre_hdr *greh) 105static inline __sum16 *gre_csum(struct gre_hdr *greh)
106{ 106{
107 if (!greh->csum) 107 if (!greh->csum)
108 return NULL; 108 return NULL;
109 return (u_int16_t *) (greh+sizeof(*greh)); 109 return (__sum16 *) (greh+sizeof(*greh));
110} 110}
111 111
112#endif /* __KERNEL__ */ 112#endif /* __KERNEL__ */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_sip.h b/include/linux/netfilter_ipv4/ip_conntrack_sip.h
index 913dad66c0fb..bef6c646defa 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_sip.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_sip.h
@@ -5,23 +5,18 @@
5#define SIP_PORT 5060 5#define SIP_PORT 5060
6#define SIP_TIMEOUT 3600 6#define SIP_TIMEOUT 3600
7 7
8#define POS_VIA 0 8enum sip_header_pos {
9#define POS_CONTACT 1 9 POS_REG_REQ_URI,
10#define POS_CONTENT 2 10 POS_REQ_URI,
11#define POS_MEDIA 3 11 POS_FROM,
12#define POS_OWNER 4 12 POS_TO,
13#define POS_CONNECTION 5 13 POS_VIA,
14#define POS_REQ_HEADER 6 14 POS_CONTACT,
15#define POS_SDP_HEADER 7 15 POS_CONTENT,
16 16 POS_MEDIA,
17struct sip_header_nfo { 17 POS_OWNER,
18 const char *lname; 18 POS_CONNECTION,
19 const char *sname; 19 POS_SDP_HEADER,
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}; 20};
26 21
27extern unsigned int (*ip_nat_sip_hook)(struct sk_buff **pskb, 22extern unsigned int (*ip_nat_sip_hook)(struct sk_buff **pskb,
@@ -36,9 +31,10 @@ extern unsigned int (*ip_nat_sdp_hook)(struct sk_buff **pskb,
36extern int ct_sip_get_info(const char *dptr, size_t dlen, 31extern int ct_sip_get_info(const char *dptr, size_t dlen,
37 unsigned int *matchoff, 32 unsigned int *matchoff,
38 unsigned int *matchlen, 33 unsigned int *matchlen,
39 struct sip_header_nfo *hnfo); 34 enum sip_header_pos pos);
40extern int ct_sip_lnlen(const char *line, const char *limit); 35extern int ct_sip_lnlen(const char *line, const char *limit);
41extern const char *ct_sip_search(const char *needle, const char *haystack, 36extern const char *ct_sip_search(const char *needle, const char *haystack,
42 size_t needle_len, size_t haystack_len); 37 size_t needle_len, size_t haystack_len,
38 int case_sensitive);
43#endif /* __KERNEL__ */ 39#endif /* __KERNEL__ */
44#endif /* __IP_CONNTRACK_SIP_H__ */ 40#endif /* __IP_CONNTRACK_SIP_H__ */
diff --git a/include/linux/netfilter_ipv4/ip_conntrack_tftp.h b/include/linux/netfilter_ipv4/ip_conntrack_tftp.h
index cde9729aa173..a404fc0abf0e 100644
--- a/include/linux/netfilter_ipv4/ip_conntrack_tftp.h
+++ b/include/linux/netfilter_ipv4/ip_conntrack_tftp.h
@@ -4,7 +4,7 @@
4#define TFTP_PORT 69 4#define TFTP_PORT 69
5 5
6struct tftphdr { 6struct tftphdr {
7 u_int16_t opcode; 7 __be16 opcode;
8}; 8};
9 9
10#define TFTP_OPCODE_READ 1 10#define TFTP_OPCODE_READ 1
diff --git a/include/linux/netfilter_ipv4/ipt_LOG.h b/include/linux/netfilter_ipv4/ipt_LOG.h
index 892f9a33fea8..90fa6525ef9c 100644
--- a/include/linux/netfilter_ipv4/ipt_LOG.h
+++ b/include/linux/netfilter_ipv4/ipt_LOG.h
@@ -6,7 +6,7 @@
6#define IPT_LOG_TCPOPT 0x02 /* Log TCP options */ 6#define IPT_LOG_TCPOPT 0x02 /* Log TCP options */
7#define IPT_LOG_IPOPT 0x04 /* Log IP options */ 7#define IPT_LOG_IPOPT 0x04 /* Log IP options */
8#define IPT_LOG_UID 0x08 /* Log UID owning local socket */ 8#define IPT_LOG_UID 0x08 /* Log UID owning local socket */
9#define IPT_LOG_NFLOG 0x10 /* Log using nf_log backend */ 9#define IPT_LOG_NFLOG 0x10 /* Unsupported, don't reuse */
10#define IPT_LOG_MASK 0x1f 10#define IPT_LOG_MASK 0x1f
11 11
12struct ipt_log_info { 12struct ipt_log_info {
diff --git a/include/linux/netfilter_ipv4/ipt_hashlimit.h b/include/linux/netfilter_ipv4/ipt_hashlimit.h
index ac2cb64ecd76..5662120a3d7b 100644
--- a/include/linux/netfilter_ipv4/ipt_hashlimit.h
+++ b/include/linux/netfilter_ipv4/ipt_hashlimit.h
@@ -1,40 +1,14 @@
1#ifndef _IPT_HASHLIMIT_H 1#ifndef _IPT_HASHLIMIT_H
2#define _IPT_HASHLIMIT_H 2#define _IPT_HASHLIMIT_H
3 3
4/* timings are in milliseconds. */ 4#include <linux/netfilter/xt_hashlimit.h>
5#define IPT_HASHLIMIT_SCALE 10000
6/* 1/10,000 sec period => max of 10,000/sec. Min rate is then 429490
7 seconds, or one every 59 hours. */
8 5
9/* details of this structure hidden by the implementation */ 6#define IPT_HASHLIMIT_SCALE XT_HASHLIMIT_SCALE
10struct ipt_hashlimit_htable; 7#define IPT_HASHLIMIT_HASH_DIP XT_HASHLIMIT_HASH_DIP
8#define IPT_HASHLIMIT_HASH_DPT XT_HASHLIMIT_HASH_DPT
9#define IPT_HASHLIMIT_HASH_SIP XT_HASHLIMIT_HASH_SIP
10#define IPT_HASHLIMIT_HASH_SPT XT_HASHLIMIT_HASH_SPT
11 11
12#define IPT_HASHLIMIT_HASH_DIP 0x0001 12#define ipt_hashlimit_info xt_hashlimit_info
13#define IPT_HASHLIMIT_HASH_DPT 0x0002
14#define IPT_HASHLIMIT_HASH_SIP 0x0004
15#define IPT_HASHLIMIT_HASH_SPT 0x0008
16 13
17struct hashlimit_cfg { 14#endif /* _IPT_HASHLIMIT_H */
18 u_int32_t mode; /* bitmask of IPT_HASHLIMIT_HASH_* */
19 u_int32_t avg; /* Average secs between packets * scale */
20 u_int32_t burst; /* Period multiplier for upper limit. */
21
22 /* user specified */
23 u_int32_t size; /* how many buckets */
24 u_int32_t max; /* max number of entries */
25 u_int32_t gc_interval; /* gc interval */
26 u_int32_t expire; /* when do entries expire? */
27};
28
29struct ipt_hashlimit_info {
30 char name [IFNAMSIZ]; /* name */
31 struct hashlimit_cfg cfg;
32 struct ipt_hashlimit_htable *hinfo;
33
34 /* Used internally by the kernel */
35 union {
36 void *ptr;
37 struct ipt_hashlimit_info *master;
38 } u;
39};
40#endif /*_IPT_HASHLIMIT_H*/
diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h
index d97e268cdfe5..ab81a6dc94ea 100644
--- a/include/linux/netfilter_ipv6.h
+++ b/include/linux/netfilter_ipv6.h
@@ -74,7 +74,7 @@ enum nf_ip6_hook_priorities {
74 74
75#ifdef CONFIG_NETFILTER 75#ifdef CONFIG_NETFILTER
76extern int ip6_route_me_harder(struct sk_buff *skb); 76extern int ip6_route_me_harder(struct sk_buff *skb);
77extern unsigned int nf_ip6_checksum(struct sk_buff *skb, unsigned int hook, 77extern __sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
78 unsigned int dataoff, u_int8_t protocol); 78 unsigned int dataoff, u_int8_t protocol);
79 79
80extern int ipv6_netfilter_init(void); 80extern int ipv6_netfilter_init(void);
diff --git a/include/linux/netfilter_ipv6/ip6t_LOG.h b/include/linux/netfilter_ipv6/ip6t_LOG.h
index 060c1a1c6c60..0d0119b0458c 100644
--- a/include/linux/netfilter_ipv6/ip6t_LOG.h
+++ b/include/linux/netfilter_ipv6/ip6t_LOG.h
@@ -6,7 +6,7 @@
6#define IP6T_LOG_TCPOPT 0x02 /* Log TCP options */ 6#define IP6T_LOG_TCPOPT 0x02 /* Log TCP options */
7#define IP6T_LOG_IPOPT 0x04 /* Log IP options */ 7#define IP6T_LOG_IPOPT 0x04 /* Log IP options */
8#define IP6T_LOG_UID 0x08 /* Log UID owning local socket */ 8#define IP6T_LOG_UID 0x08 /* Log UID owning local socket */
9#define IP6T_LOG_NFLOG 0x10 /* Log using nf_log backend */ 9#define IP6T_LOG_NFLOG 0x10 /* Unsupported, don't use */
10#define IP6T_LOG_MASK 0x1f 10#define IP6T_LOG_MASK 0x1f
11 11
12struct ip6t_log_info { 12struct ip6t_log_info {
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 66411622e06e..b3b9b609ee89 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -141,7 +141,6 @@ struct netlink_skb_parms
141{ 141{
142 struct ucred creds; /* Skb credentials */ 142 struct ucred creds; /* Skb credentials */
143 __u32 pid; 143 __u32 pid;
144 __u32 dst_pid;
145 __u32 dst_group; 144 __u32 dst_group;
146 kernel_cap_t eff_cap; 145 kernel_cap_t eff_cap;
147 __u32 loginuid; /* Login (audit) uid */ 146 __u32 loginuid; /* Login (audit) uid */
@@ -174,6 +173,7 @@ int netlink_sendskb(struct sock *sk, struct sk_buff *skb, int protocol);
174 */ 173 */
175#define NLMSG_GOODORDER 0 174#define NLMSG_GOODORDER 0
176#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER)) 175#define NLMSG_GOODSIZE (SKB_MAX_ORDER(0, NLMSG_GOODORDER))
176#define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
177 177
178 178
179struct netlink_callback 179struct netlink_callback
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 1efe60c5c00c..2cc9867b1626 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -12,26 +12,27 @@
12#include <linux/rcupdate.h> 12#include <linux/rcupdate.h>
13#include <linux/list.h> 13#include <linux/list.h>
14 14
15struct netpoll;
16
17struct netpoll { 15struct netpoll {
18 struct net_device *dev; 16 struct net_device *dev;
19 char dev_name[16], *name; 17 char dev_name[IFNAMSIZ];
18 const char *name;
20 void (*rx_hook)(struct netpoll *, int, char *, int); 19 void (*rx_hook)(struct netpoll *, int, char *, int);
21 void (*drop)(struct sk_buff *skb); 20
22 u32 local_ip, remote_ip; 21 u32 local_ip, remote_ip;
23 u16 local_port, remote_port; 22 u16 local_port, remote_port;
24 unsigned char local_mac[6], remote_mac[6]; 23 u8 local_mac[ETH_ALEN], remote_mac[ETH_ALEN];
25}; 24};
26 25
27struct netpoll_info { 26struct netpoll_info {
27 atomic_t refcnt;
28 spinlock_t poll_lock; 28 spinlock_t poll_lock;
29 int poll_owner; 29 int poll_owner;
30 int tries;
31 int rx_flags; 30 int rx_flags;
32 spinlock_t rx_lock; 31 spinlock_t rx_lock;
33 struct netpoll *rx_np; /* netpoll that registered an rx_hook */ 32 struct netpoll *rx_np; /* netpoll that registered an rx_hook */
34 struct sk_buff_head arp_tx; /* list of arp requests to reply to */ 33 struct sk_buff_head arp_tx; /* list of arp requests to reply to */
34 struct sk_buff_head txq;
35 struct work_struct tx_work;
35}; 36};
36 37
37void netpoll_poll(struct netpoll *np); 38void netpoll_poll(struct netpoll *np);
@@ -42,7 +43,7 @@ int netpoll_trap(void);
42void netpoll_set_trap(int trap); 43void netpoll_set_trap(int trap);
43void netpoll_cleanup(struct netpoll *np); 44void netpoll_cleanup(struct netpoll *np);
44int __netpoll_rx(struct sk_buff *skb); 45int __netpoll_rx(struct sk_buff *skb);
45void netpoll_queue(struct sk_buff *skb); 46
46 47
47#ifdef CONFIG_NETPOLL 48#ifdef CONFIG_NETPOLL
48static inline int netpoll_rx(struct sk_buff *skb) 49static inline int netpoll_rx(struct sk_buff *skb)
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 45228c1a1195..625ffea98561 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -318,7 +318,7 @@ extern void put_nfs_open_context(struct nfs_open_context *ctx);
318extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode); 318extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode);
319 319
320/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */ 320/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
321extern u32 root_nfs_parse_addr(char *name); /*__init*/ 321extern __be32 root_nfs_parse_addr(char *name); /*__init*/
322 322
323static inline void nfs_fattr_init(struct nfs_fattr *fattr) 323static inline void nfs_fattr_init(struct nfs_fattr *fattr)
324{ 324{
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h
index f6baecdeecd6..971d1c6dfc4b 100644
--- a/include/linux/nsproxy.h
+++ b/include/linux/nsproxy.h
@@ -45,8 +45,10 @@ static inline void exit_task_namespaces(struct task_struct *p)
45{ 45{
46 struct nsproxy *ns = p->nsproxy; 46 struct nsproxy *ns = p->nsproxy;
47 if (ns) { 47 if (ns) {
48 put_nsproxy(ns); 48 task_lock(p);
49 p->nsproxy = NULL; 49 p->nsproxy = NULL;
50 task_unlock(p);
51 put_nsproxy(ns);
50 } 52 }
51} 53}
52#endif 54#endif
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 09be0f81b27b..01c707261f9c 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -51,6 +51,7 @@
51#include <linux/list.h> 51#include <linux/list.h>
52#include <linux/compiler.h> 52#include <linux/compiler.h>
53#include <linux/errno.h> 53#include <linux/errno.h>
54#include <asm/atomic.h>
54#include <linux/device.h> 55#include <linux/device.h>
55 56
56/* File state for mmap()s on /proc/bus/pci/X/Y */ 57/* File state for mmap()s on /proc/bus/pci/X/Y */
@@ -159,7 +160,6 @@ struct pci_dev {
159 unsigned int transparent:1; /* Transparent PCI bridge */ 160 unsigned int transparent:1; /* Transparent PCI bridge */
160 unsigned int multifunction:1;/* Part of multi-function device */ 161 unsigned int multifunction:1;/* Part of multi-function device */
161 /* keep track of device state */ 162 /* keep track of device state */
162 unsigned int is_enabled:1; /* pci_enable_device has been called */
163 unsigned int is_busmaster:1; /* device is busmaster */ 163 unsigned int is_busmaster:1; /* device is busmaster */
164 unsigned int no_msi:1; /* device may not use msi */ 164 unsigned int no_msi:1; /* device may not use msi */
165 unsigned int no_d1d2:1; /* only allow d0 or d3 */ 165 unsigned int no_d1d2:1; /* only allow d0 or d3 */
@@ -167,6 +167,7 @@ struct pci_dev {
167 unsigned int broken_parity_status:1; /* Device generates false positive parity */ 167 unsigned int broken_parity_status:1; /* Device generates false positive parity */
168 unsigned int msi_enabled:1; 168 unsigned int msi_enabled:1;
169 unsigned int msix_enabled:1; 169 unsigned int msix_enabled:1;
170 atomic_t enable_cnt; /* pci_enable_device has been called */
170 171
171 u32 saved_config_space[16]; /* config space saved at suspend time */ 172 u32 saved_config_space[16]; /* config space saved at suspend time */
172 struct hlist_head saved_cap_space; 173 struct hlist_head saved_cap_space;
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index fa4e1d799782..c09da1e30c54 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1213,6 +1213,10 @@
1213#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451 1213#define PCI_DEVICE_ID_NVIDIA_NVENET_21 0x0451
1214#define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452 1214#define PCI_DEVICE_ID_NVIDIA_NVENET_22 0x0452
1215#define PCI_DEVICE_ID_NVIDIA_NVENET_23 0x0453 1215#define PCI_DEVICE_ID_NVIDIA_NVENET_23 0x0453
1216#define PCI_DEVICE_ID_NVIDIA_NVENET_24 0x054C
1217#define PCI_DEVICE_ID_NVIDIA_NVENET_25 0x054D
1218#define PCI_DEVICE_ID_NVIDIA_NVENET_26 0x054E
1219#define PCI_DEVICE_ID_NVIDIA_NVENET_27 0x054F
1216#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE 0x0560 1220#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE 0x0560
1217 1221
1218#define PCI_VENDOR_ID_IMS 0x10e0 1222#define PCI_VENDOR_ID_IMS 0x10e0
@@ -1893,6 +1897,7 @@
1893#define PCI_VENDOR_ID_BROADCOM 0x14e4 1897#define PCI_VENDOR_ID_BROADCOM 0x14e4
1894#define PCI_DEVICE_ID_TIGON3_5752 0x1600 1898#define PCI_DEVICE_ID_TIGON3_5752 0x1600
1895#define PCI_DEVICE_ID_TIGON3_5752M 0x1601 1899#define PCI_DEVICE_ID_TIGON3_5752M 0x1601
1900#define PCI_DEVICE_ID_NX2_5709 0x1639
1896#define PCI_DEVICE_ID_TIGON3_5700 0x1644 1901#define PCI_DEVICE_ID_TIGON3_5700 0x1644
1897#define PCI_DEVICE_ID_TIGON3_5701 0x1645 1902#define PCI_DEVICE_ID_TIGON3_5701 0x1645
1898#define PCI_DEVICE_ID_TIGON3_5702 0x1646 1903#define PCI_DEVICE_ID_TIGON3_5702 0x1646
@@ -2211,6 +2216,13 @@
2211#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815 2216#define PCI_DEVICE_ID_INTEL_ICH8_4 0x2815
2212#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e 2217#define PCI_DEVICE_ID_INTEL_ICH8_5 0x283e
2213#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850 2218#define PCI_DEVICE_ID_INTEL_ICH8_6 0x2850
2219#define PCI_DEVICE_ID_INTEL_ICH9_0 0x2910
2220#define PCI_DEVICE_ID_INTEL_ICH9_1 0x2911
2221#define PCI_DEVICE_ID_INTEL_ICH9_2 0x2912
2222#define PCI_DEVICE_ID_INTEL_ICH9_3 0x2913
2223#define PCI_DEVICE_ID_INTEL_ICH9_4 0x2914
2224#define PCI_DEVICE_ID_INTEL_ICH9_5 0x2915
2225#define PCI_DEVICE_ID_INTEL_ICH9_6 0x2930
2214#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 2226#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340
2215#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 2227#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575
2216#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 2228#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index c321316f1bc7..064b1dc71c22 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -292,6 +292,12 @@
292#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */ 292#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
293#define PCI_MSI_MASK_BIT 16 /* Mask bits register */ 293#define PCI_MSI_MASK_BIT 16 /* Mask bits register */
294 294
295/* MSI-X registers (these are at offset PCI_MSI_FLAGS) */
296#define PCI_MSIX_FLAGS_QSIZE 0x7FF
297#define PCI_MSIX_FLAGS_ENABLE (1 << 15)
298#define PCI_MSIX_FLAGS_BIRMASK (7 << 0)
299#define PCI_MSIX_FLAGS_BITMASK (1 << 0)
300
295/* CompactPCI Hotswap Register */ 301/* CompactPCI Hotswap Register */
296 302
297#define PCI_CHSWP_CSR 2 /* Control and Status Register */ 303#define PCI_CHSWP_CSR 2 /* Control and Status Register */
diff --git a/include/linux/pfkeyv2.h b/include/linux/pfkeyv2.h
index d5dd471da225..0f0b880c4280 100644
--- a/include/linux/pfkeyv2.h
+++ b/include/linux/pfkeyv2.h
@@ -32,7 +32,7 @@ struct sadb_ext {
32struct sadb_sa { 32struct sadb_sa {
33 uint16_t sadb_sa_len; 33 uint16_t sadb_sa_len;
34 uint16_t sadb_sa_exttype; 34 uint16_t sadb_sa_exttype;
35 uint32_t sadb_sa_spi; 35 __be32 sadb_sa_spi;
36 uint8_t sadb_sa_replay; 36 uint8_t sadb_sa_replay;
37 uint8_t sadb_sa_state; 37 uint8_t sadb_sa_state;
38 uint8_t sadb_sa_auth; 38 uint8_t sadb_sa_auth;
@@ -211,7 +211,7 @@ struct sadb_x_nat_t_type {
211struct sadb_x_nat_t_port { 211struct sadb_x_nat_t_port {
212 uint16_t sadb_x_nat_t_port_len; 212 uint16_t sadb_x_nat_t_port_len;
213 uint16_t sadb_x_nat_t_port_exttype; 213 uint16_t sadb_x_nat_t_port_exttype;
214 uint16_t sadb_x_nat_t_port_port; 214 __be16 sadb_x_nat_t_port_port;
215 uint16_t sadb_x_nat_t_port_reserved; 215 uint16_t sadb_x_nat_t_port_reserved;
216} __attribute__((packed)); 216} __attribute__((packed));
217/* sizeof(struct sadb_x_nat_t_port) == 8 */ 217/* sizeof(struct sadb_x_nat_t_port) == 8 */
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 9447a57ee8a9..edd4c88ca7d8 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -20,6 +20,10 @@
20 20
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/ethtool.h>
24#include <linux/mii.h>
25#include <linux/timer.h>
26#include <linux/workqueue.h>
23 27
24#define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \ 28#define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \
25 SUPPORTED_10baseT_Full | \ 29 SUPPORTED_10baseT_Full | \
@@ -43,15 +47,26 @@
43#define PHY_HAS_INTERRUPT 0x00000001 47#define PHY_HAS_INTERRUPT 0x00000001
44#define PHY_HAS_MAGICANEG 0x00000002 48#define PHY_HAS_MAGICANEG 0x00000002
45 49
50/* Interface Mode definitions */
51typedef enum {
52 PHY_INTERFACE_MODE_MII,
53 PHY_INTERFACE_MODE_GMII,
54 PHY_INTERFACE_MODE_SGMII,
55 PHY_INTERFACE_MODE_TBI,
56 PHY_INTERFACE_MODE_RMII,
57 PHY_INTERFACE_MODE_RGMII,
58 PHY_INTERFACE_MODE_RTBI
59} phy_interface_t;
60
46#define MII_BUS_MAX 4 61#define MII_BUS_MAX 4
47 62
48 63
49#define PHY_INIT_TIMEOUT 100000 64#define PHY_INIT_TIMEOUT 100000
50#define PHY_STATE_TIME 1 65#define PHY_STATE_TIME 1
51#define PHY_FORCE_TIMEOUT 10 66#define PHY_FORCE_TIMEOUT 10
52#define PHY_AN_TIMEOUT 10 67#define PHY_AN_TIMEOUT 10
53 68
54#define PHY_MAX_ADDR 32 69#define PHY_MAX_ADDR 32
55 70
56/* Used when trying to connect to a specific phy (mii bus id:phy device id) */ 71/* Used when trying to connect to a specific phy (mii bus id:phy device id) */
57#define PHY_ID_FMT "%x:%02x" 72#define PHY_ID_FMT "%x:%02x"
@@ -83,8 +98,8 @@ struct mii_bus {
83 int *irq; 98 int *irq;
84}; 99};
85 100
86#define PHY_INTERRUPT_DISABLED 0x0 101#define PHY_INTERRUPT_DISABLED 0x0
87#define PHY_INTERRUPT_ENABLED 0x80000000 102#define PHY_INTERRUPT_ENABLED 0x80000000
88 103
89/* PHY state machine states: 104/* PHY state machine states:
90 * 105 *
@@ -226,6 +241,8 @@ struct phy_device {
226 241
227 u32 dev_flags; 242 u32 dev_flags;
228 243
244 phy_interface_t interface;
245
229 /* Bus address of the PHY (0-32) */ 246 /* Bus address of the PHY (0-32) */
230 int addr; 247 int addr;
231 248
@@ -341,9 +358,10 @@ struct phy_device* get_phy_device(struct mii_bus *bus, int addr);
341int phy_clear_interrupt(struct phy_device *phydev); 358int phy_clear_interrupt(struct phy_device *phydev);
342int phy_config_interrupt(struct phy_device *phydev, u32 interrupts); 359int phy_config_interrupt(struct phy_device *phydev, u32 interrupts);
343struct phy_device * phy_attach(struct net_device *dev, 360struct phy_device * phy_attach(struct net_device *dev,
344 const char *phy_id, u32 flags); 361 const char *phy_id, u32 flags, phy_interface_t interface);
345struct phy_device * phy_connect(struct net_device *dev, const char *phy_id, 362struct phy_device * phy_connect(struct net_device *dev, const char *phy_id,
346 void (*handler)(struct net_device *), u32 flags); 363 void (*handler)(struct net_device *), u32 flags,
364 phy_interface_t interface);
347void phy_disconnect(struct phy_device *phydev); 365void phy_disconnect(struct phy_device *phydev);
348void phy_detach(struct phy_device *phydev); 366void phy_detach(struct phy_device *phydev);
349void phy_start(struct phy_device *phydev); 367void phy_start(struct phy_device *phydev);
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 29cd6dee13db..20f47b81d3fa 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -58,6 +58,12 @@ struct platform_driver {
58extern int platform_driver_register(struct platform_driver *); 58extern int platform_driver_register(struct platform_driver *);
59extern void platform_driver_unregister(struct platform_driver *); 59extern void platform_driver_unregister(struct platform_driver *);
60 60
61/* non-hotpluggable platform devices may use this so that probe() and
62 * its support may live in __init sections, conserving runtime memory.
63 */
64extern int platform_driver_probe(struct platform_driver *driver,
65 int (*probe)(struct platform_device *));
66
61#define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev) 67#define platform_get_drvdata(_dev) dev_get_drvdata(&(_dev)->dev)
62#define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) 68#define platform_set_drvdata(_dev,data) dev_set_drvdata(&(_dev)->dev, (data))
63 69
diff --git a/include/linux/random.h b/include/linux/random.h
index 0248b30e306d..01ad71033d65 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -51,16 +51,16 @@ extern void add_interrupt_randomness(int irq);
51extern void get_random_bytes(void *buf, int nbytes); 51extern void get_random_bytes(void *buf, int nbytes);
52void generate_random_uuid(unsigned char uuid_out[16]); 52void generate_random_uuid(unsigned char uuid_out[16]);
53 53
54extern __u32 secure_ip_id(__u32 daddr); 54extern __u32 secure_ip_id(__be32 daddr);
55extern u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport); 55extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
56extern u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, 56extern u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr,
57 __u16 dport); 57 __be16 dport);
58extern __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr, 58extern __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
59 __u16 sport, __u16 dport); 59 __be16 sport, __be16 dport);
60extern __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr, 60extern __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
61 __u16 sport, __u16 dport); 61 __be16 sport, __be16 dport);
62extern u64 secure_dccp_sequence_number(__u32 saddr, __u32 daddr, 62extern u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
63 __u16 sport, __u16 dport); 63 __be16 sport, __be16 dport);
64 64
65#ifndef MODULE 65#ifndef MODULE
66extern struct file_operations random_fops, urandom_fops; 66extern struct file_operations random_fops, urandom_fops;
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index 6610103f23e1..3a28742d86f9 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -430,7 +430,7 @@ enum reiserfs_mount_options {
430/* -o hash={tea, rupasov, r5, detect} is meant for properly mounting 430/* -o hash={tea, rupasov, r5, detect} is meant for properly mounting
431** reiserfs disks from 3.5.19 or earlier. 99% of the time, this option 431** reiserfs disks from 3.5.19 or earlier. 99% of the time, this option
432** is not required. If the normal autodection code can't determine which 432** is not required. If the normal autodection code can't determine which
433** hash to use (because both hases had the same value for a file) 433** hash to use (because both hashes had the same value for a file)
434** use this option to force a specific hash. It won't allow you to override 434** use this option to force a specific hash. It won't allow you to override
435** the existing hash on the FS, so if you have a tea hash disk, and mount 435** the existing hash on the FS, so if you have a tea hash disk, and mount
436** with -o hash=rupasov, the mount will fail. 436** with -o hash=rupasov, the mount will fail.
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 3a18addaed4c..493297acdae8 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -81,8 +81,6 @@ enum {
81 81
82 RTM_NEWPREFIX = 52, 82 RTM_NEWPREFIX = 52,
83#define RTM_NEWPREFIX RTM_NEWPREFIX 83#define RTM_NEWPREFIX RTM_NEWPREFIX
84 RTM_GETPREFIX = 54,
85#define RTM_GETPREFIX RTM_GETPREFIX
86 84
87 RTM_GETMULTICAST = 58, 85 RTM_GETMULTICAST = 58,
88#define RTM_GETMULTICAST RTM_GETMULTICAST 86#define RTM_GETMULTICAST RTM_GETMULTICAST
@@ -587,6 +585,9 @@ extern int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group,
587 struct nlmsghdr *nlh, gfp_t flags); 585 struct nlmsghdr *nlh, gfp_t flags);
588extern void rtnl_set_sk_err(u32 group, int error); 586extern void rtnl_set_sk_err(u32 group, int error);
589extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); 587extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
588extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
589 u32 id, u32 ts, u32 tsage, long expires,
590 u32 error);
590 591
591extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data); 592extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
592 593
diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index 6ec66dec29f7..35108fe7a686 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -57,17 +57,17 @@
57 57
58/* Section 3.1. SCTP Common Header Format */ 58/* Section 3.1. SCTP Common Header Format */
59typedef struct sctphdr { 59typedef struct sctphdr {
60 __u16 source; 60 __be16 source;
61 __u16 dest; 61 __be16 dest;
62 __u32 vtag; 62 __be32 vtag;
63 __u32 checksum; 63 __be32 checksum;
64} __attribute__((packed)) sctp_sctphdr_t; 64} __attribute__((packed)) sctp_sctphdr_t;
65 65
66/* Section 3.2. Chunk Field Descriptions. */ 66/* Section 3.2. Chunk Field Descriptions. */
67typedef struct sctp_chunkhdr { 67typedef struct sctp_chunkhdr {
68 __u8 type; 68 __u8 type;
69 __u8 flags; 69 __u8 flags;
70 __u16 length; 70 __be16 length;
71} __attribute__((packed)) sctp_chunkhdr_t; 71} __attribute__((packed)) sctp_chunkhdr_t;
72 72
73 73
@@ -153,8 +153,8 @@ enum { SCTP_CHUNK_FLAG_T = 0x01 };
153 */ 153 */
154 154
155typedef struct sctp_paramhdr { 155typedef struct sctp_paramhdr {
156 __u16 type; 156 __be16 type;
157 __u16 length; 157 __be16 length;
158} __attribute__((packed)) sctp_paramhdr_t; 158} __attribute__((packed)) sctp_paramhdr_t;
159 159
160typedef enum { 160typedef enum {
@@ -203,10 +203,10 @@ enum { SCTP_PARAM_ACTION_MASK = __constant_htons(0xc000), };
203/* RFC 2960 Section 3.3.1 Payload Data (DATA) (0) */ 203/* RFC 2960 Section 3.3.1 Payload Data (DATA) (0) */
204 204
205typedef struct sctp_datahdr { 205typedef struct sctp_datahdr {
206 __u32 tsn; 206 __be32 tsn;
207 __u16 stream; 207 __be16 stream;
208 __u16 ssn; 208 __be16 ssn;
209 __u32 ppid; 209 __be32 ppid;
210 __u8 payload[0]; 210 __u8 payload[0];
211} __attribute__((packed)) sctp_datahdr_t; 211} __attribute__((packed)) sctp_datahdr_t;
212 212
@@ -232,11 +232,11 @@ enum { SCTP_DATA_FRAG_MASK = 0x03, };
232 * endpoints. 232 * endpoints.
233 */ 233 */
234typedef struct sctp_inithdr { 234typedef struct sctp_inithdr {
235 __u32 init_tag; 235 __be32 init_tag;
236 __u32 a_rwnd; 236 __be32 a_rwnd;
237 __u16 num_outbound_streams; 237 __be16 num_outbound_streams;
238 __u16 num_inbound_streams; 238 __be16 num_inbound_streams;
239 __u32 initial_tsn; 239 __be32 initial_tsn;
240 __u8 params[0]; 240 __u8 params[0];
241} __attribute__((packed)) sctp_inithdr_t; 241} __attribute__((packed)) sctp_inithdr_t;
242 242
@@ -261,7 +261,7 @@ typedef struct sctp_ipv6addr_param {
261/* Section 3.3.2.1 Cookie Preservative (9) */ 261/* Section 3.3.2.1 Cookie Preservative (9) */
262typedef struct sctp_cookie_preserve_param { 262typedef struct sctp_cookie_preserve_param {
263 sctp_paramhdr_t param_hdr; 263 sctp_paramhdr_t param_hdr;
264 uint32_t lifespan_increment; 264 __be32 lifespan_increment;
265} __attribute__((packed)) sctp_cookie_preserve_param_t; 265} __attribute__((packed)) sctp_cookie_preserve_param_t;
266 266
267/* Section 3.3.2.1 Host Name Address (11) */ 267/* Section 3.3.2.1 Host Name Address (11) */
@@ -273,7 +273,7 @@ typedef struct sctp_hostname_param {
273/* Section 3.3.2.1 Supported Address Types (12) */ 273/* Section 3.3.2.1 Supported Address Types (12) */
274typedef struct sctp_supported_addrs_param { 274typedef struct sctp_supported_addrs_param {
275 sctp_paramhdr_t param_hdr; 275 sctp_paramhdr_t param_hdr;
276 uint16_t types[0]; 276 __be16 types[0];
277} __attribute__((packed)) sctp_supported_addrs_param_t; 277} __attribute__((packed)) sctp_supported_addrs_param_t;
278 278
279/* Appendix A. ECN Capable (32768) */ 279/* Appendix A. ECN Capable (32768) */
@@ -284,7 +284,7 @@ typedef struct sctp_ecn_capable_param {
284/* ADDIP Section 3.2.6 Adaption Layer Indication */ 284/* ADDIP Section 3.2.6 Adaption Layer Indication */
285typedef struct sctp_adaption_ind_param { 285typedef struct sctp_adaption_ind_param {
286 struct sctp_paramhdr param_hdr; 286 struct sctp_paramhdr param_hdr;
287 __u32 adaption_ind; 287 __be32 adaption_ind;
288} __attribute__((packed)) sctp_adaption_ind_param_t; 288} __attribute__((packed)) sctp_adaption_ind_param_t;
289 289
290/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2): 290/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
@@ -316,11 +316,11 @@ typedef struct sctp_unrecognized_param {
316 */ 316 */
317 317
318typedef struct sctp_gap_ack_block { 318typedef struct sctp_gap_ack_block {
319 __u16 start; 319 __be16 start;
320 __u16 end; 320 __be16 end;
321} __attribute__((packed)) sctp_gap_ack_block_t; 321} __attribute__((packed)) sctp_gap_ack_block_t;
322 322
323typedef uint32_t sctp_dup_tsn_t; 323typedef __be32 sctp_dup_tsn_t;
324 324
325typedef union { 325typedef union {
326 sctp_gap_ack_block_t gab; 326 sctp_gap_ack_block_t gab;
@@ -328,10 +328,10 @@ typedef union {
328} sctp_sack_variable_t; 328} sctp_sack_variable_t;
329 329
330typedef struct sctp_sackhdr { 330typedef struct sctp_sackhdr {
331 __u32 cum_tsn_ack; 331 __be32 cum_tsn_ack;
332 __u32 a_rwnd; 332 __be32 a_rwnd;
333 __u16 num_gap_ack_blocks; 333 __be16 num_gap_ack_blocks;
334 __u16 num_dup_tsns; 334 __be16 num_dup_tsns;
335 sctp_sack_variable_t variable[0]; 335 sctp_sack_variable_t variable[0];
336} __attribute__((packed)) sctp_sackhdr_t; 336} __attribute__((packed)) sctp_sackhdr_t;
337 337
@@ -371,7 +371,7 @@ typedef struct sctp_abort_chunk {
371 * and the highest consecutive acking value. 371 * and the highest consecutive acking value.
372 */ 372 */
373typedef struct sctp_shutdownhdr { 373typedef struct sctp_shutdownhdr {
374 __u32 cum_tsn_ack; 374 __be32 cum_tsn_ack;
375} __attribute__((packed)) sctp_shutdownhdr_t; 375} __attribute__((packed)) sctp_shutdownhdr_t;
376 376
377struct sctp_shutdown_chunk_t { 377struct sctp_shutdown_chunk_t {
@@ -382,8 +382,8 @@ struct sctp_shutdown_chunk_t {
382/* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */ 382/* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */
383 383
384typedef struct sctp_errhdr { 384typedef struct sctp_errhdr {
385 __u16 cause; 385 __be16 cause;
386 __u16 length; 386 __be16 length;
387 __u8 variable[0]; 387 __u8 variable[0];
388} __attribute__((packed)) sctp_errhdr_t; 388} __attribute__((packed)) sctp_errhdr_t;
389 389
@@ -462,7 +462,7 @@ typedef enum {
462 * Explicit Congestion Notification Echo (ECNE) (12) 462 * Explicit Congestion Notification Echo (ECNE) (12)
463 */ 463 */
464typedef struct sctp_ecnehdr { 464typedef struct sctp_ecnehdr {
465 __u32 lowest_tsn; 465 __be32 lowest_tsn;
466} sctp_ecnehdr_t; 466} sctp_ecnehdr_t;
467 467
468typedef struct sctp_ecne_chunk { 468typedef struct sctp_ecne_chunk {
@@ -474,7 +474,7 @@ typedef struct sctp_ecne_chunk {
474 * Congestion Window Reduced (CWR) (13) 474 * Congestion Window Reduced (CWR) (13)
475 */ 475 */
476typedef struct sctp_cwrhdr { 476typedef struct sctp_cwrhdr {
477 __u32 lowest_tsn; 477 __be32 lowest_tsn;
478} sctp_cwrhdr_t; 478} sctp_cwrhdr_t;
479 479
480typedef struct sctp_cwr_chunk { 480typedef struct sctp_cwr_chunk {
@@ -529,12 +529,12 @@ typedef struct sctp_cwr_chunk {
529 * chunks this field MUST be filled in. 529 * chunks this field MUST be filled in.
530 */ 530 */
531struct sctp_fwdtsn_skip { 531struct sctp_fwdtsn_skip {
532 __u16 stream; 532 __be16 stream;
533 __u16 ssn; 533 __be16 ssn;
534} __attribute__((packed)); 534} __attribute__((packed));
535 535
536struct sctp_fwdtsn_hdr { 536struct sctp_fwdtsn_hdr {
537 __u32 new_cum_tsn; 537 __be32 new_cum_tsn;
538 struct sctp_fwdtsn_skip skip[0]; 538 struct sctp_fwdtsn_skip skip[0];
539} __attribute((packed)); 539} __attribute((packed));
540 540
@@ -578,11 +578,11 @@ struct sctp_fwdtsn_chunk {
578 */ 578 */
579typedef struct sctp_addip_param { 579typedef struct sctp_addip_param {
580 sctp_paramhdr_t param_hdr; 580 sctp_paramhdr_t param_hdr;
581 __u32 crr_id; 581 __be32 crr_id;
582} __attribute__((packed)) sctp_addip_param_t; 582} __attribute__((packed)) sctp_addip_param_t;
583 583
584typedef struct sctp_addiphdr { 584typedef struct sctp_addiphdr {
585 __u32 serial; 585 __be32 serial;
586 __u8 params[0]; 586 __u8 params[0];
587} __attribute__((packed)) sctp_addiphdr_t; 587} __attribute__((packed)) sctp_addiphdr_t;
588 588
diff --git a/include/linux/security.h b/include/linux/security.h
index b200b9856f32..83cdefae9931 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -826,6 +826,8 @@ struct request_sock;
826 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid. 826 * Sets the openreq's sid to socket's sid with MLS portion taken from peer sid.
827 * @inet_csk_clone: 827 * @inet_csk_clone:
828 * Sets the new child socket's sid to the openreq sid. 828 * Sets the new child socket's sid to the openreq sid.
829 * @inet_conn_established:
830 * Sets the connection's peersid to the secmark on skb.
829 * @req_classify_flow: 831 * @req_classify_flow:
830 * Sets the flow's sid to the openreq sid. 832 * Sets the flow's sid to the openreq sid.
831 * 833 *
@@ -836,10 +838,8 @@ struct request_sock;
836 * used by the XFRM system. 838 * used by the XFRM system.
837 * @sec_ctx contains the security context information being provided by 839 * @sec_ctx contains the security context information being provided by
838 * the user-level policy update program (e.g., setkey). 840 * the user-level policy update program (e.g., setkey).
839 * @sk refers to the sock from which to derive the security context.
840 * Allocate a security structure to the xp->security field; the security 841 * Allocate a security structure to the xp->security field; the security
841 * field is initialized to NULL when the xfrm_policy is allocated. Only 842 * field is initialized to NULL when the xfrm_policy is allocated.
842 * one of sec_ctx or sock can be specified.
843 * Return 0 if operation was successful (memory to allocate, legal context) 843 * Return 0 if operation was successful (memory to allocate, legal context)
844 * @xfrm_policy_clone_security: 844 * @xfrm_policy_clone_security:
845 * @old contains an existing xfrm_policy in the SPD. 845 * @old contains an existing xfrm_policy in the SPD.
@@ -858,9 +858,6 @@ struct request_sock;
858 * Database by the XFRM system. 858 * Database by the XFRM system.
859 * @sec_ctx contains the security context information being provided by 859 * @sec_ctx contains the security context information being provided by
860 * the user-level SA generation program (e.g., setkey or racoon). 860 * the user-level SA generation program (e.g., setkey or racoon).
861 * @polsec contains the security context information associated with a xfrm
862 * policy rule from which to take the base context. polsec must be NULL
863 * when sec_ctx is specified.
864 * @secid contains the secid from which to take the mls portion of the context. 861 * @secid contains the secid from which to take the mls portion of the context.
865 * Allocate a security structure to the x->security field; the security 862 * Allocate a security structure to the x->security field; the security
866 * field is initialized to NULL when the xfrm_state is allocated. Set the 863 * field is initialized to NULL when the xfrm_state is allocated. Set the
@@ -889,11 +886,6 @@ struct request_sock;
889 * @xp contains the policy to check for a match. 886 * @xp contains the policy to check for a match.
890 * @fl contains the flow to check for a match. 887 * @fl contains the flow to check for a match.
891 * Return 1 if there is a match. 888 * Return 1 if there is a match.
892 * @xfrm_flow_state_match:
893 * @fl contains the flow key to match.
894 * @xfrm points to the xfrm_state to match.
895 * @xp points to the xfrm_policy to match.
896 * Return 1 if there is a match.
897 * @xfrm_decode_session: 889 * @xfrm_decode_session:
898 * @skb points to skb to decode. 890 * @skb points to skb to decode.
899 * @secid points to the flow key secid to set. 891 * @secid points to the flow key secid to set.
@@ -1373,25 +1365,24 @@ struct security_operations {
1373 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb, 1365 int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
1374 struct request_sock *req); 1366 struct request_sock *req);
1375 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req); 1367 void (*inet_csk_clone)(struct sock *newsk, const struct request_sock *req);
1368 void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
1376 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl); 1369 void (*req_classify_flow)(const struct request_sock *req, struct flowi *fl);
1377#endif /* CONFIG_SECURITY_NETWORK */ 1370#endif /* CONFIG_SECURITY_NETWORK */
1378 1371
1379#ifdef CONFIG_SECURITY_NETWORK_XFRM 1372#ifdef CONFIG_SECURITY_NETWORK_XFRM
1380 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, 1373 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp,
1381 struct xfrm_user_sec_ctx *sec_ctx, struct sock *sk); 1374 struct xfrm_user_sec_ctx *sec_ctx);
1382 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new); 1375 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1383 void (*xfrm_policy_free_security) (struct xfrm_policy *xp); 1376 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
1384 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp); 1377 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
1385 int (*xfrm_state_alloc_security) (struct xfrm_state *x, 1378 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1386 struct xfrm_user_sec_ctx *sec_ctx, struct xfrm_sec_ctx *polsec, 1379 struct xfrm_user_sec_ctx *sec_ctx,
1387 u32 secid); 1380 u32 secid);
1388 void (*xfrm_state_free_security) (struct xfrm_state *x); 1381 void (*xfrm_state_free_security) (struct xfrm_state *x);
1389 int (*xfrm_state_delete_security) (struct xfrm_state *x); 1382 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1390 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir); 1383 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
1391 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x, 1384 int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
1392 struct xfrm_policy *xp, struct flowi *fl); 1385 struct xfrm_policy *xp, struct flowi *fl);
1393 int (*xfrm_flow_state_match)(struct flowi *fl, struct xfrm_state *xfrm,
1394 struct xfrm_policy *xp);
1395 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall); 1386 int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
1396#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1387#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1397 1388
@@ -2966,9 +2957,15 @@ static inline void security_inet_csk_clone(struct sock *newsk,
2966{ 2957{
2967 security_ops->inet_csk_clone(newsk, req); 2958 security_ops->inet_csk_clone(newsk, req);
2968} 2959}
2960
2961static inline void security_inet_conn_established(struct sock *sk,
2962 struct sk_buff *skb)
2963{
2964 security_ops->inet_conn_established(sk, skb);
2965}
2969#else /* CONFIG_SECURITY_NETWORK */ 2966#else /* CONFIG_SECURITY_NETWORK */
2970static inline int security_unix_stream_connect(struct socket * sock, 2967static inline int security_unix_stream_connect(struct socket * sock,
2971 struct socket * other, 2968 struct socket * other,
2972 struct sock * newsk) 2969 struct sock * newsk)
2973{ 2970{
2974 return 0; 2971 return 0;
@@ -3115,12 +3112,17 @@ static inline void security_inet_csk_clone(struct sock *newsk,
3115 const struct request_sock *req) 3112 const struct request_sock *req)
3116{ 3113{
3117} 3114}
3115
3116static inline void security_inet_conn_established(struct sock *sk,
3117 struct sk_buff *skb)
3118{
3119}
3118#endif /* CONFIG_SECURITY_NETWORK */ 3120#endif /* CONFIG_SECURITY_NETWORK */
3119 3121
3120#ifdef CONFIG_SECURITY_NETWORK_XFRM 3122#ifdef CONFIG_SECURITY_NETWORK_XFRM
3121static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) 3123static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3122{ 3124{
3123 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx, NULL); 3125 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
3124} 3126}
3125 3127
3126static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) 3128static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
@@ -3141,7 +3143,7 @@ static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3141static inline int security_xfrm_state_alloc(struct xfrm_state *x, 3143static inline int security_xfrm_state_alloc(struct xfrm_state *x,
3142 struct xfrm_user_sec_ctx *sec_ctx) 3144 struct xfrm_user_sec_ctx *sec_ctx)
3143{ 3145{
3144 return security_ops->xfrm_state_alloc_security(x, sec_ctx, NULL, 0); 3146 return security_ops->xfrm_state_alloc_security(x, sec_ctx, 0);
3145} 3147}
3146 3148
3147static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x, 3149static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
@@ -3149,7 +3151,11 @@ static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
3149{ 3151{
3150 if (!polsec) 3152 if (!polsec)
3151 return 0; 3153 return 0;
3152 return security_ops->xfrm_state_alloc_security(x, NULL, polsec, secid); 3154 /*
3155 * We want the context to be taken from secid which is usually
3156 * from the sock.
3157 */
3158 return security_ops->xfrm_state_alloc_security(x, NULL, secid);
3153} 3159}
3154 3160
3155static inline int security_xfrm_state_delete(struct xfrm_state *x) 3161static inline int security_xfrm_state_delete(struct xfrm_state *x)
@@ -3173,12 +3179,6 @@ static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3173 return security_ops->xfrm_state_pol_flow_match(x, xp, fl); 3179 return security_ops->xfrm_state_pol_flow_match(x, xp, fl);
3174} 3180}
3175 3181
3176static inline int security_xfrm_flow_state_match(struct flowi *fl,
3177 struct xfrm_state *xfrm, struct xfrm_policy *xp)
3178{
3179 return security_ops->xfrm_flow_state_match(fl, xfrm, xp);
3180}
3181
3182static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) 3182static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3183{ 3183{
3184 return security_ops->xfrm_decode_session(skb, secid, 1); 3184 return security_ops->xfrm_decode_session(skb, secid, 1);
@@ -3242,12 +3242,6 @@ static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
3242 return 1; 3242 return 1;
3243} 3243}
3244 3244
3245static inline int security_xfrm_flow_state_match(struct flowi *fl,
3246 struct xfrm_state *xfrm, struct xfrm_policy *xp)
3247{
3248 return 1;
3249}
3250
3251static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid) 3245static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
3252{ 3246{
3253 return 0; 3247 return 0;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 85577a4ffa61..14ec16d2d9ba 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -139,7 +139,7 @@ struct skb_shared_info {
139 /* Warning: this field is not always filled in (UFO)! */ 139 /* Warning: this field is not always filled in (UFO)! */
140 unsigned short gso_segs; 140 unsigned short gso_segs;
141 unsigned short gso_type; 141 unsigned short gso_type;
142 unsigned int ip6_frag_id; 142 __be32 ip6_frag_id;
143 struct sk_buff *frag_list; 143 struct sk_buff *frag_list;
144 skb_frag_t frags[MAX_SKB_FRAGS]; 144 skb_frag_t frags[MAX_SKB_FRAGS];
145}; 145};
@@ -216,7 +216,7 @@ enum {
216 * @tail: Tail pointer 216 * @tail: Tail pointer
217 * @end: End pointer 217 * @end: End pointer
218 * @destructor: Destruct function 218 * @destructor: Destruct function
219 * @nfmark: Can be used for communication between hooks 219 * @mark: Generic packet mark
220 * @nfct: Associated connection, if any 220 * @nfct: Associated connection, if any
221 * @ipvs_property: skbuff is owned by ipvs 221 * @ipvs_property: skbuff is owned by ipvs
222 * @nfctinfo: Relationship of this skb to the connection 222 * @nfctinfo: Relationship of this skb to the connection
@@ -273,8 +273,11 @@ struct sk_buff {
273 273
274 unsigned int len, 274 unsigned int len,
275 data_len, 275 data_len,
276 mac_len, 276 mac_len;
277 csum; 277 union {
278 __wsum csum;
279 __u32 csum_offset;
280 };
278 __u32 priority; 281 __u32 priority;
279 __u8 local_df:1, 282 __u8 local_df:1,
280 cloned:1, 283 cloned:1,
@@ -295,7 +298,6 @@ struct sk_buff {
295#ifdef CONFIG_BRIDGE_NETFILTER 298#ifdef CONFIG_BRIDGE_NETFILTER
296 struct nf_bridge_info *nf_bridge; 299 struct nf_bridge_info *nf_bridge;
297#endif 300#endif
298 __u32 nfmark;
299#endif /* CONFIG_NETFILTER */ 301#endif /* CONFIG_NETFILTER */
300#ifdef CONFIG_NET_SCHED 302#ifdef CONFIG_NET_SCHED
301 __u16 tc_index; /* traffic control index */ 303 __u16 tc_index; /* traffic control index */
@@ -310,6 +312,7 @@ struct sk_buff {
310 __u32 secmark; 312 __u32 secmark;
311#endif 313#endif
312 314
315 __u32 mark;
313 316
314 /* These elements must be at the end, see alloc_skb() for details. */ 317 /* These elements must be at the end, see alloc_skb() for details. */
315 unsigned int truesize; 318 unsigned int truesize;
@@ -1199,8 +1202,7 @@ static inline int skb_add_data(struct sk_buff *skb,
1199 1202
1200 if (skb->ip_summed == CHECKSUM_NONE) { 1203 if (skb->ip_summed == CHECKSUM_NONE) {
1201 int err = 0; 1204 int err = 0;
1202 unsigned int csum = csum_and_copy_from_user(from, 1205 __wsum csum = csum_and_copy_from_user(from, skb_put(skb, copy),
1203 skb_put(skb, copy),
1204 copy, 0, &err); 1206 copy, 0, &err);
1205 if (!err) { 1207 if (!err) {
1206 skb->csum = csum_block_add(skb->csum, csum, off); 1208 skb->csum = csum_block_add(skb->csum, csum, off);
@@ -1335,15 +1337,15 @@ extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
1335extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb); 1337extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
1336extern void skb_kill_datagram(struct sock *sk, struct sk_buff *skb, 1338extern void skb_kill_datagram(struct sock *sk, struct sk_buff *skb,
1337 unsigned int flags); 1339 unsigned int flags);
1338extern unsigned int skb_checksum(const struct sk_buff *skb, int offset, 1340extern __wsum skb_checksum(const struct sk_buff *skb, int offset,
1339 int len, unsigned int csum); 1341 int len, __wsum csum);
1340extern int skb_copy_bits(const struct sk_buff *skb, int offset, 1342extern int skb_copy_bits(const struct sk_buff *skb, int offset,
1341 void *to, int len); 1343 void *to, int len);
1342extern int skb_store_bits(const struct sk_buff *skb, int offset, 1344extern int skb_store_bits(const struct sk_buff *skb, int offset,
1343 void *from, int len); 1345 void *from, int len);
1344extern unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, 1346extern __wsum skb_copy_and_csum_bits(const struct sk_buff *skb,
1345 int offset, u8 *to, int len, 1347 int offset, u8 *to, int len,
1346 unsigned int csum); 1348 __wsum csum);
1347extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to); 1349extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
1348extern void skb_split(struct sk_buff *skb, 1350extern void skb_split(struct sk_buff *skb,
1349 struct sk_buff *skb1, const u32 len); 1351 struct sk_buff *skb1, const u32 len);
@@ -1399,7 +1401,7 @@ static inline void skb_set_timestamp(struct sk_buff *skb, const struct timeval *
1399 1401
1400extern void __net_timestamp(struct sk_buff *skb); 1402extern void __net_timestamp(struct sk_buff *skb);
1401 1403
1402extern unsigned int __skb_checksum_complete(struct sk_buff *skb); 1404extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
1403 1405
1404/** 1406/**
1405 * skb_checksum_complete - Calculate checksum of an entire packet 1407 * skb_checksum_complete - Calculate checksum of an entire packet
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 361409094649..92cd38efad7f 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -264,6 +264,7 @@ struct ucred {
264#define SOL_IPV6 41 264#define SOL_IPV6 41
265#define SOL_ICMPV6 58 265#define SOL_ICMPV6 58
266#define SOL_SCTP 132 266#define SOL_SCTP 132
267#define SOL_UDPLITE 136 /* UDP-Lite (RFC 3828) */
267#define SOL_RAW 255 268#define SOL_RAW 255
268#define SOL_IPX 256 269#define SOL_IPX 256
269#define SOL_AX25 257 270#define SOL_AX25 257
@@ -292,7 +293,7 @@ extern int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov,
292extern int csum_partial_copy_fromiovecend(unsigned char *kdata, 293extern int csum_partial_copy_fromiovecend(unsigned char *kdata,
293 struct iovec *iov, 294 struct iovec *iov,
294 int offset, 295 int offset,
295 unsigned int len, int *csump); 296 unsigned int len, __wsum *csump);
296 297
297extern int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode); 298extern int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode);
298extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len); 299extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
diff --git a/include/linux/sockios.h b/include/linux/sockios.h
index e6b9d1d36ea2..abef7596655a 100644
--- a/include/linux/sockios.h
+++ b/include/linux/sockios.h
@@ -72,8 +72,8 @@
72#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ 72#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
73#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ 73#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
74 74
75#define SIOCGIFDIVERT 0x8944 /* Frame diversion support */ 75/* SIOCGIFDIVERT was: 0x8944 Frame diversion support */
76#define SIOCSIFDIVERT 0x8945 /* Set frame diversion options */ 76/* SIOCSIFDIVERT was: 0x8945 Set frame diversion options */
77 77
78#define SIOCETHTOOL 0x8946 /* Ethtool interface */ 78#define SIOCETHTOOL 0x8946 /* Ethtool interface */
79 79
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index b800d2d68b32..8451052ca66f 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -183,13 +183,27 @@ do { \
183#define read_lock(lock) _read_lock(lock) 183#define read_lock(lock) _read_lock(lock)
184 184
185#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) 185#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
186
186#define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock) 187#define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock)
187#define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock) 188#define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock)
188#define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock) 189#define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock)
190
191#ifdef CONFIG_DEBUG_LOCK_ALLOC
192#define spin_lock_irqsave_nested(lock, flags, subclass) \
193 flags = _spin_lock_irqsave_nested(lock, subclass)
194#else
195#define spin_lock_irqsave_nested(lock, flags, subclass) \
196 flags = _spin_lock_irqsave(lock)
197#endif
198
189#else 199#else
200
190#define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags) 201#define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags)
191#define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags) 202#define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags)
192#define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags) 203#define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags)
204#define spin_lock_irqsave_nested(lock, flags, subclass) \
205 spin_lock_irqsave(lock, flags)
206
193#endif 207#endif
194 208
195#define spin_lock_irq(lock) _spin_lock_irq(lock) 209#define spin_lock_irq(lock) _spin_lock_irq(lock)
diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h
index 8828b8155e9c..8a2307ce7296 100644
--- a/include/linux/spinlock_api_smp.h
+++ b/include/linux/spinlock_api_smp.h
@@ -32,6 +32,8 @@ void __lockfunc _read_lock_irq(rwlock_t *lock) __acquires(lock);
32void __lockfunc _write_lock_irq(rwlock_t *lock) __acquires(lock); 32void __lockfunc _write_lock_irq(rwlock_t *lock) __acquires(lock);
33unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock) 33unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock)
34 __acquires(lock); 34 __acquires(lock);
35unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, int subclass)
36 __acquires(lock);
35unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock) 37unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock)
36 __acquires(lock); 38 __acquires(lock);
37unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock) 39unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock)
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index ac69e5511606..9a527c364394 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -151,7 +151,7 @@ typedef struct {
151 struct sk_buff *skb; 151 struct sk_buff *skb;
152 unsigned int offset; 152 unsigned int offset;
153 size_t count; 153 size_t count;
154 unsigned int csum; 154 __wsum csum;
155} skb_reader_t; 155} skb_reader_t;
156 156
157typedef size_t (*skb_read_actor_t)(skb_reader_t *desc, void *to, size_t len); 157typedef size_t (*skb_read_actor_t)(skb_reader_t *desc, void *to, size_t len);
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index d98562f1df76..94316a98e0d0 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -426,6 +426,8 @@ enum
426 NET_CIPSOV4_CACHE_BUCKET_SIZE=119, 426 NET_CIPSOV4_CACHE_BUCKET_SIZE=119,
427 NET_CIPSOV4_RBM_OPTFMT=120, 427 NET_CIPSOV4_RBM_OPTFMT=120,
428 NET_CIPSOV4_RBM_STRICTVALID=121, 428 NET_CIPSOV4_RBM_STRICTVALID=121,
429 NET_TCP_AVAIL_CONG_CONTROL=122,
430 NET_TCP_ALLOWED_CONG_CONTROL=123,
429}; 431};
430 432
431enum { 433enum {
@@ -604,16 +606,6 @@ enum {
604 NET_DCCP_DEFAULT=1, 606 NET_DCCP_DEFAULT=1,
605}; 607};
606 608
607/* /proc/sys/net/dccp/default */
608enum {
609 NET_DCCP_DEFAULT_SEQ_WINDOW = 1,
610 NET_DCCP_DEFAULT_RX_CCID = 2,
611 NET_DCCP_DEFAULT_TX_CCID = 3,
612 NET_DCCP_DEFAULT_ACK_RATIO = 4,
613 NET_DCCP_DEFAULT_SEND_ACKVEC = 5,
614 NET_DCCP_DEFAULT_SEND_NDP = 6,
615};
616
617/* /proc/sys/net/ipx */ 609/* /proc/sys/net/ipx */
618enum { 610enum {
619 NET_IPX_PPROP_BROADCASTING=1, 611 NET_IPX_PPROP_BROADCASTING=1,
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 6d5c43d31dec..2129d1b6c874 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -97,6 +97,9 @@ extern int __must_check
97sysfs_rename_dir(struct kobject *, const char *new_name); 97sysfs_rename_dir(struct kobject *, const char *new_name);
98 98
99extern int __must_check 99extern int __must_check
100sysfs_move_dir(struct kobject *, struct kobject *);
101
102extern int __must_check
100sysfs_create_file(struct kobject *, const struct attribute *); 103sysfs_create_file(struct kobject *, const struct attribute *);
101 104
102extern int __must_check 105extern int __must_check
@@ -142,6 +145,11 @@ static inline int sysfs_rename_dir(struct kobject * k, const char *new_name)
142 return 0; 145 return 0;
143} 146}
144 147
148static inline int sysfs_move_dir(struct kobject * k, struct kobject * new_parent)
149{
150 return 0;
151}
152
145static inline int sysfs_create_file(struct kobject * k, const struct attribute * a) 153static inline int sysfs_create_file(struct kobject * k, const struct attribute * a)
146{ 154{
147 return 0; 155 return 0;
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 2d36f6db3706..3cc70d1a3504 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -19,6 +19,7 @@
19 19
20#include <linux/types.h> 20#include <linux/types.h>
21#include <asm/byteorder.h> 21#include <asm/byteorder.h>
22#include <linux/socket.h>
22 23
23struct tcphdr { 24struct tcphdr {
24 __be16 source; 25 __be16 source;
@@ -51,7 +52,7 @@ struct tcphdr {
51#error "Adjust your <asm/byteorder.h> defines" 52#error "Adjust your <asm/byteorder.h> defines"
52#endif 53#endif
53 __be16 window; 54 __be16 window;
54 __be16 check; 55 __sum16 check;
55 __be16 urg_ptr; 56 __be16 urg_ptr;
56}; 57};
57 58
@@ -94,6 +95,7 @@ enum {
94#define TCP_INFO 11 /* Information about this connection. */ 95#define TCP_INFO 11 /* Information about this connection. */
95#define TCP_QUICKACK 12 /* Block/reenable quick acks */ 96#define TCP_QUICKACK 12 /* Block/reenable quick acks */
96#define TCP_CONGESTION 13 /* Congestion control algorithm */ 97#define TCP_CONGESTION 13 /* Congestion control algorithm */
98#define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */
97 99
98#define TCPI_OPT_TIMESTAMPS 1 100#define TCPI_OPT_TIMESTAMPS 1
99#define TCPI_OPT_SACK 2 101#define TCPI_OPT_SACK 2
@@ -157,6 +159,17 @@ struct tcp_info
157 __u32 tcpi_total_retrans; 159 __u32 tcpi_total_retrans;
158}; 160};
159 161
162/* for TCP_MD5SIG socket option */
163#define TCP_MD5SIG_MAXKEYLEN 80
164
165struct tcp_md5sig {
166 struct __kernel_sockaddr_storage tcpm_addr; /* address associated */
167 __u16 __tcpm_pad1; /* zero */
168 __u16 tcpm_keylen; /* key length */
169 __u32 __tcpm_pad2; /* zero */
170 __u8 tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* key (binary) */
171};
172
160#ifdef __KERNEL__ 173#ifdef __KERNEL__
161 174
162#include <linux/skbuff.h> 175#include <linux/skbuff.h>
@@ -172,17 +185,17 @@ struct tcp_sack_block_wire {
172}; 185};
173 186
174struct tcp_sack_block { 187struct tcp_sack_block {
175 __u32 start_seq; 188 u32 start_seq;
176 __u32 end_seq; 189 u32 end_seq;
177}; 190};
178 191
179struct tcp_options_received { 192struct tcp_options_received {
180/* PAWS/RTTM data */ 193/* PAWS/RTTM data */
181 long ts_recent_stamp;/* Time we stored ts_recent (for aging) */ 194 long ts_recent_stamp;/* Time we stored ts_recent (for aging) */
182 __u32 ts_recent; /* Time stamp to echo next */ 195 u32 ts_recent; /* Time stamp to echo next */
183 __u32 rcv_tsval; /* Time stamp value */ 196 u32 rcv_tsval; /* Time stamp value */
184 __u32 rcv_tsecr; /* Time stamp echo reply */ 197 u32 rcv_tsecr; /* Time stamp echo reply */
185 __u16 saw_tstamp : 1, /* Saw TIMESTAMP on last packet */ 198 u16 saw_tstamp : 1, /* Saw TIMESTAMP on last packet */
186 tstamp_ok : 1, /* TIMESTAMP seen on SYN packet */ 199 tstamp_ok : 1, /* TIMESTAMP seen on SYN packet */
187 dsack : 1, /* D-SACK is scheduled */ 200 dsack : 1, /* D-SACK is scheduled */
188 wscale_ok : 1, /* Wscale seen on SYN packet */ 201 wscale_ok : 1, /* Wscale seen on SYN packet */
@@ -190,16 +203,20 @@ struct tcp_options_received {
190 snd_wscale : 4, /* Window scaling received from sender */ 203 snd_wscale : 4, /* Window scaling received from sender */
191 rcv_wscale : 4; /* Window scaling to send to receiver */ 204 rcv_wscale : 4; /* Window scaling to send to receiver */
192/* SACKs data */ 205/* SACKs data */
193 __u8 eff_sacks; /* Size of SACK array to send with next packet */ 206 u8 eff_sacks; /* Size of SACK array to send with next packet */
194 __u8 num_sacks; /* Number of SACK blocks */ 207 u8 num_sacks; /* Number of SACK blocks */
195 __u16 user_mss; /* mss requested by user in ioctl */ 208 u16 user_mss; /* mss requested by user in ioctl */
196 __u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ 209 u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
197}; 210};
198 211
199struct tcp_request_sock { 212struct tcp_request_sock {
200 struct inet_request_sock req; 213 struct inet_request_sock req;
201 __u32 rcv_isn; 214#ifdef CONFIG_TCP_MD5SIG
202 __u32 snt_isn; 215 /* Only used by TCP MD5 Signature so far. */
216 struct tcp_request_sock_ops *af_specific;
217#endif
218 u32 rcv_isn;
219 u32 snt_isn;
203}; 220};
204 221
205static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req) 222static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)
@@ -210,7 +227,8 @@ static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)
210struct tcp_sock { 227struct tcp_sock {
211 /* inet_connection_sock has to be the first member of tcp_sock */ 228 /* inet_connection_sock has to be the first member of tcp_sock */
212 struct inet_connection_sock inet_conn; 229 struct inet_connection_sock inet_conn;
213 int tcp_header_len; /* Bytes of tcp header to send */ 230 u16 tcp_header_len; /* Bytes of tcp header to send */
231 u16 xmit_size_goal; /* Goal for segmenting output packets */
214 232
215/* 233/*
216 * Header prediction flags 234 * Header prediction flags
@@ -223,13 +241,13 @@ struct tcp_sock {
223 * read the code and the spec side by side (and laugh ...) 241 * read the code and the spec side by side (and laugh ...)
224 * See RFC793 and RFC1122. The RFC writes these in capitals. 242 * See RFC793 and RFC1122. The RFC writes these in capitals.
225 */ 243 */
226 __u32 rcv_nxt; /* What we want to receive next */ 244 u32 rcv_nxt; /* What we want to receive next */
227 __u32 snd_nxt; /* Next sequence we send */ 245 u32 snd_nxt; /* Next sequence we send */
228 246
229 __u32 snd_una; /* First byte we want an ack for */ 247 u32 snd_una; /* First byte we want an ack for */
230 __u32 snd_sml; /* Last byte of the most recently transmitted small packet */ 248 u32 snd_sml; /* Last byte of the most recently transmitted small packet */
231 __u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ 249 u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
232 __u32 lsndtime; /* timestamp of last sent data packet (for restart window) */ 250 u32 lsndtime; /* timestamp of last sent data packet (for restart window) */
233 251
234 /* Data for direct copy to user */ 252 /* Data for direct copy to user */
235 struct { 253 struct {
@@ -247,32 +265,30 @@ struct tcp_sock {
247#endif 265#endif
248 } ucopy; 266 } ucopy;
249 267
250 __u32 snd_wl1; /* Sequence for window update */ 268 u32 snd_wl1; /* Sequence for window update */
251 __u32 snd_wnd; /* The window we expect to receive */ 269 u32 snd_wnd; /* The window we expect to receive */
252 __u32 max_window; /* Maximal window ever seen from peer */ 270 u32 max_window; /* Maximal window ever seen from peer */
253 __u32 mss_cache; /* Cached effective mss, not including SACKS */ 271 u32 mss_cache; /* Cached effective mss, not including SACKS */
254 __u16 xmit_size_goal; /* Goal for segmenting output packets */
255 /* XXX Two bytes hole, try to pack */
256 272
257 __u32 window_clamp; /* Maximal window to advertise */ 273 u32 window_clamp; /* Maximal window to advertise */
258 __u32 rcv_ssthresh; /* Current window clamp */ 274 u32 rcv_ssthresh; /* Current window clamp */
259 275
260 __u32 frto_highmark; /* snd_nxt when RTO occurred */ 276 u32 frto_highmark; /* snd_nxt when RTO occurred */
261 __u8 reordering; /* Packet reordering metric. */ 277 u8 reordering; /* Packet reordering metric. */
262 __u8 frto_counter; /* Number of new acks after RTO */ 278 u8 frto_counter; /* Number of new acks after RTO */
263 __u8 nonagle; /* Disable Nagle algorithm? */ 279 u8 nonagle; /* Disable Nagle algorithm? */
264 __u8 keepalive_probes; /* num of allowed keep alive probes */ 280 u8 keepalive_probes; /* num of allowed keep alive probes */
265 281
266/* RTT measurement */ 282/* RTT measurement */
267 __u32 srtt; /* smoothed round trip time << 3 */ 283 u32 srtt; /* smoothed round trip time << 3 */
268 __u32 mdev; /* medium deviation */ 284 u32 mdev; /* medium deviation */
269 __u32 mdev_max; /* maximal mdev for the last rtt period */ 285 u32 mdev_max; /* maximal mdev for the last rtt period */
270 __u32 rttvar; /* smoothed mdev_max */ 286 u32 rttvar; /* smoothed mdev_max */
271 __u32 rtt_seq; /* sequence number to update rttvar */ 287 u32 rtt_seq; /* sequence number to update rttvar */
272 288
273 __u32 packets_out; /* Packets which are "in flight" */ 289 u32 packets_out; /* Packets which are "in flight" */
274 __u32 left_out; /* Packets which leaved network */ 290 u32 left_out; /* Packets which leaved network */
275 __u32 retrans_out; /* Retransmitted packets out */ 291 u32 retrans_out; /* Retransmitted packets out */
276/* 292/*
277 * Options received (usually on last packet, some only on SYN packets). 293 * Options received (usually on last packet, some only on SYN packets).
278 */ 294 */
@@ -281,20 +297,20 @@ struct tcp_sock {
281/* 297/*
282 * Slow start and congestion control (see also Nagle, and Karn & Partridge) 298 * Slow start and congestion control (see also Nagle, and Karn & Partridge)
283 */ 299 */
284 __u32 snd_ssthresh; /* Slow start size threshold */ 300 u32 snd_ssthresh; /* Slow start size threshold */
285 __u32 snd_cwnd; /* Sending congestion window */ 301 u32 snd_cwnd; /* Sending congestion window */
286 __u16 snd_cwnd_cnt; /* Linear increase counter */ 302 u16 snd_cwnd_cnt; /* Linear increase counter */
287 __u16 snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */ 303 u16 snd_cwnd_clamp; /* Do not allow snd_cwnd to grow above this */
288 __u32 snd_cwnd_used; 304 u32 snd_cwnd_used;
289 __u32 snd_cwnd_stamp; 305 u32 snd_cwnd_stamp;
290 306
291 struct sk_buff_head out_of_order_queue; /* Out of order segments go here */ 307 struct sk_buff_head out_of_order_queue; /* Out of order segments go here */
292 308
293 __u32 rcv_wnd; /* Current receiver window */ 309 u32 rcv_wnd; /* Current receiver window */
294 __u32 rcv_wup; /* rcv_nxt on last window update sent */ 310 u32 rcv_wup; /* rcv_nxt on last window update sent */
295 __u32 write_seq; /* Tail(+1) of data held in tcp send buffer */ 311 u32 write_seq; /* Tail(+1) of data held in tcp send buffer */
296 __u32 pushed_seq; /* Last pushed seq, required to talk to windows */ 312 u32 pushed_seq; /* Last pushed seq, required to talk to windows */
297 __u32 copied_seq; /* Head of yet unread data */ 313 u32 copied_seq; /* Head of yet unread data */
298 314
299/* SACKs data */ 315/* SACKs data */
300 struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */ 316 struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
@@ -315,26 +331,26 @@ struct tcp_sock {
315 int retransmit_cnt_hint; 331 int retransmit_cnt_hint;
316 int forward_cnt_hint; 332 int forward_cnt_hint;
317 333
318 __u16 advmss; /* Advertised MSS */ 334 u16 advmss; /* Advertised MSS */
319 __u16 prior_ssthresh; /* ssthresh saved at recovery start */ 335 u16 prior_ssthresh; /* ssthresh saved at recovery start */
320 __u32 lost_out; /* Lost packets */ 336 u32 lost_out; /* Lost packets */
321 __u32 sacked_out; /* SACK'd packets */ 337 u32 sacked_out; /* SACK'd packets */
322 __u32 fackets_out; /* FACK'd packets */ 338 u32 fackets_out; /* FACK'd packets */
323 __u32 high_seq; /* snd_nxt at onset of congestion */ 339 u32 high_seq; /* snd_nxt at onset of congestion */
324 340
325 __u32 retrans_stamp; /* Timestamp of the last retransmit, 341 u32 retrans_stamp; /* Timestamp of the last retransmit,
326 * also used in SYN-SENT to remember stamp of 342 * also used in SYN-SENT to remember stamp of
327 * the first SYN. */ 343 * the first SYN. */
328 __u32 undo_marker; /* tracking retrans started here. */ 344 u32 undo_marker; /* tracking retrans started here. */
329 int undo_retrans; /* number of undoable retransmissions. */ 345 int undo_retrans; /* number of undoable retransmissions. */
330 __u32 urg_seq; /* Seq of received urgent pointer */ 346 u32 urg_seq; /* Seq of received urgent pointer */
331 __u16 urg_data; /* Saved octet of OOB data and control flags */ 347 u16 urg_data; /* Saved octet of OOB data and control flags */
332 __u8 urg_mode; /* In urgent mode */ 348 u8 urg_mode; /* In urgent mode */
333 __u8 ecn_flags; /* ECN status bits. */ 349 u8 ecn_flags; /* ECN status bits. */
334 __u32 snd_up; /* Urgent pointer */ 350 u32 snd_up; /* Urgent pointer */
335 351
336 __u32 total_retrans; /* Total retransmits for entire connection */ 352 u32 total_retrans; /* Total retransmits for entire connection */
337 __u32 bytes_acked; /* Appropriate Byte Counting - RFC3465 */ 353 u32 bytes_acked; /* Appropriate Byte Counting - RFC3465 */
338 354
339 unsigned int keepalive_time; /* time before keep alive takes place */ 355 unsigned int keepalive_time; /* time before keep alive takes place */
340 unsigned int keepalive_intvl; /* time interval between keep alive probes */ 356 unsigned int keepalive_intvl; /* time interval between keep alive probes */
@@ -342,27 +358,35 @@ struct tcp_sock {
342 358
343 unsigned long last_synq_overflow; 359 unsigned long last_synq_overflow;
344 360
345 __u32 tso_deferred; 361 u32 tso_deferred;
346 362
347/* Receiver side RTT estimation */ 363/* Receiver side RTT estimation */
348 struct { 364 struct {
349 __u32 rtt; 365 u32 rtt;
350 __u32 seq; 366 u32 seq;
351 __u32 time; 367 u32 time;
352 } rcv_rtt_est; 368 } rcv_rtt_est;
353 369
354/* Receiver queue space */ 370/* Receiver queue space */
355 struct { 371 struct {
356 int space; 372 int space;
357 __u32 seq; 373 u32 seq;
358 __u32 time; 374 u32 time;
359 } rcvq_space; 375 } rcvq_space;
360 376
361/* TCP-specific MTU probe information. */ 377/* TCP-specific MTU probe information. */
362 struct { 378 struct {
363 __u32 probe_seq_start; 379 u32 probe_seq_start;
364 __u32 probe_seq_end; 380 u32 probe_seq_end;
365 } mtu_probe; 381 } mtu_probe;
382
383#ifdef CONFIG_TCP_MD5SIG
384/* TCP AF-Specific parts; only used by MD5 Signature support so far */
385 struct tcp_sock_af_ops *af_specific;
386
387/* TCP MD5 Signagure Option information */
388 struct tcp_md5sig_info *md5sig_info;
389#endif
366}; 390};
367 391
368static inline struct tcp_sock *tcp_sk(const struct sock *sk) 392static inline struct tcp_sock *tcp_sk(const struct sock *sk)
@@ -372,11 +396,15 @@ static inline struct tcp_sock *tcp_sk(const struct sock *sk)
372 396
373struct tcp_timewait_sock { 397struct tcp_timewait_sock {
374 struct inet_timewait_sock tw_sk; 398 struct inet_timewait_sock tw_sk;
375 __u32 tw_rcv_nxt; 399 u32 tw_rcv_nxt;
376 __u32 tw_snd_nxt; 400 u32 tw_snd_nxt;
377 __u32 tw_rcv_wnd; 401 u32 tw_rcv_wnd;
378 __u32 tw_ts_recent; 402 u32 tw_ts_recent;
379 long tw_ts_recent_stamp; 403 long tw_ts_recent_stamp;
404#ifdef CONFIG_TCP_MD5SIG
405 u16 tw_md5_keylen;
406 u8 tw_md5_key[TCP_MD5SIG_MAXKEYLEN];
407#endif
380}; 408};
381 409
382static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk) 410static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h
index 7dac8f04d28e..004808a6df1d 100644
--- a/include/linux/textsearch.h
+++ b/include/linux/textsearch.h
@@ -20,7 +20,7 @@ struct ts_config;
20/** 20/**
21 * struct ts_state - search state 21 * struct ts_state - search state
22 * @offset: offset for next match 22 * @offset: offset for next match
23 * @cb: control buffer, for persistant variables of get_next_block() 23 * @cb: control buffer, for persistent variables of get_next_block()
24 */ 24 */
25struct ts_state 25struct ts_state
26{ 26{
@@ -71,7 +71,7 @@ struct ts_config
71 * Called repeatedly until 0 is returned. Must assign the 71 * Called repeatedly until 0 is returned. Must assign the
72 * head of the next block of data to &*dst and return the length 72 * head of the next block of data to &*dst and return the length
73 * of the block or 0 if at the end. consumed == 0 indicates 73 * of the block or 0 if at the end. consumed == 0 indicates
74 * a new search. May store/read persistant values in state->cb. 74 * a new search. May store/read persistent values in state->cb.
75 */ 75 */
76 unsigned int (*get_next_block)(unsigned int consumed, 76 unsigned int (*get_next_block)(unsigned int consumed,
77 const u8 **dst, 77 const u8 **dst,
diff --git a/include/linux/tfrc.h b/include/linux/tfrc.h
index 7dab7831c3cb..31a9b25276fe 100644
--- a/include/linux/tfrc.h
+++ b/include/linux/tfrc.h
@@ -1,7 +1,8 @@
1#ifndef _LINUX_TFRC_H_ 1#ifndef _LINUX_TFRC_H_
2#define _LINUX_TFRC_H_ 2#define _LINUX_TFRC_H_
3/* 3/*
4 * include/linux/tfrc.h 4 * TFRC - Data Structures for the TCP-Friendly Rate Control congestion
5 * control mechanism as specified in RFC 3448.
5 * 6 *
6 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. 7 * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand.
7 * Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz> 8 * Copyright (c) 2005 Ian McDonald <iam4@cs.waikato.ac.nz>
@@ -13,15 +14,30 @@
13 * the Free Software Foundation; either version 2 of the License, or 14 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version. 15 * (at your option) any later version.
15 */ 16 */
16
17#include <linux/types.h> 17#include <linux/types.h>
18 18
19/** tfrc_rx_info - TFRC Receiver Data Structure
20 *
21 * @tfrcrx_x_recv: receiver estimate of sending rate (3.2.2)
22 * @tfrcrx_rtt: round-trip-time (communicated by sender)
23 * @tfrcrx_p: current estimate of loss event rate (3.2.2)
24 */
19struct tfrc_rx_info { 25struct tfrc_rx_info {
20 __u32 tfrcrx_x_recv; 26 __u32 tfrcrx_x_recv;
21 __u32 tfrcrx_rtt; 27 __u32 tfrcrx_rtt;
22 __u32 tfrcrx_p; 28 __u32 tfrcrx_p;
23}; 29};
24 30
31/** tfrc_tx_info - TFRC Sender Data Structure
32 *
33 * @tfrctx_x: computed transmit rate (4.3 (4))
34 * @tfrctx_x_recv: receiver estimate of send rate (4.3)
35 * @tfrctx_x_calc: return value of throughput equation (3.1)
36 * @tfrctx_rtt: (moving average) estimate of RTT (4.3)
37 * @tfrctx_p: current loss event rate (5.4)
38 * @tfrctx_rto: estimate of RTO, equals 4*RTT (4.3)
39 * @tfrctx_ipi: inter-packet interval (4.6)
40 */
25struct tfrc_tx_info { 41struct tfrc_tx_info {
26 __u32 tfrctx_x; 42 __u32 tfrctx_x;
27 __u32 tfrctx_x_recv; 43 __u32 tfrctx_x_recv;
diff --git a/include/linux/tipc_config.h b/include/linux/tipc_config.h
index 33a653913d94..b0c916d1f375 100644
--- a/include/linux/tipc_config.h
+++ b/include/linux/tipc_config.h
@@ -194,34 +194,34 @@
194 194
195 195
196struct tipc_node_info { 196struct tipc_node_info {
197 __u32 addr; /* network address of node */ 197 __be32 addr; /* network address of node */
198 __u32 up; /* 0=down, 1= up */ 198 __be32 up; /* 0=down, 1= up */
199}; 199};
200 200
201struct tipc_link_info { 201struct tipc_link_info {
202 __u32 dest; /* network address of peer node */ 202 __be32 dest; /* network address of peer node */
203 __u32 up; /* 0=down, 1=up */ 203 __be32 up; /* 0=down, 1=up */
204 char str[TIPC_MAX_LINK_NAME]; /* link name */ 204 char str[TIPC_MAX_LINK_NAME]; /* link name */
205}; 205};
206 206
207struct tipc_bearer_config { 207struct tipc_bearer_config {
208 __u32 priority; /* Range [1,31]. Override per link */ 208 __be32 priority; /* Range [1,31]. Override per link */
209 __u32 detect_scope; 209 __be32 detect_scope;
210 char name[TIPC_MAX_BEARER_NAME]; 210 char name[TIPC_MAX_BEARER_NAME];
211}; 211};
212 212
213struct tipc_link_config { 213struct tipc_link_config {
214 __u32 value; 214 __be32 value;
215 char name[TIPC_MAX_LINK_NAME]; 215 char name[TIPC_MAX_LINK_NAME];
216}; 216};
217 217
218#define TIPC_NTQ_ALLTYPES 0x80000000 218#define TIPC_NTQ_ALLTYPES 0x80000000
219 219
220struct tipc_name_table_query { 220struct tipc_name_table_query {
221 __u32 depth; /* 1:type, 2:+name info, 3:+port info, 4+:+debug info */ 221 __be32 depth; /* 1:type, 2:+name info, 3:+port info, 4+:+debug info */
222 __u32 type; /* {t,l,u} info ignored if high bit of "depth" is set */ 222 __be32 type; /* {t,l,u} info ignored if high bit of "depth" is set */
223 __u32 lowbound; /* (i.e. displays all entries of name table) */ 223 __be32 lowbound; /* (i.e. displays all entries of name table) */
224 __u32 upbound; 224 __be32 upbound;
225}; 225};
226 226
227/* 227/*
@@ -262,8 +262,8 @@ struct tipc_route_info {
262 */ 262 */
263 263
264struct tlv_desc { 264struct tlv_desc {
265 __u16 tlv_len; /* TLV length (descriptor + value) */ 265 __be16 tlv_len; /* TLV length (descriptor + value) */
266 __u16 tlv_type; /* TLV identifier */ 266 __be16 tlv_type; /* TLV identifier */
267}; 267};
268 268
269#define TLV_ALIGNTO 4 269#define TLV_ALIGNTO 4
@@ -377,9 +377,9 @@ struct tipc_genlmsghdr {
377 377
378struct tipc_cfg_msg_hdr 378struct tipc_cfg_msg_hdr
379{ 379{
380 __u32 tcm_len; /* Message length (including header) */ 380 __be32 tcm_len; /* Message length (including header) */
381 __u16 tcm_type; /* Command type */ 381 __be16 tcm_type; /* Command type */
382 __u16 tcm_flags; /* Additional flags */ 382 __be16 tcm_flags; /* Additional flags */
383 char tcm_reserved[8]; /* Unused */ 383 char tcm_reserved[8]; /* Unused */
384}; 384};
385 385
diff --git a/include/linux/tty.h b/include/linux/tty.h
index c1f716446161..f717f0898238 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -276,9 +276,8 @@ extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc);
276extern int tty_unregister_ldisc(int disc); 276extern int tty_unregister_ldisc(int disc);
277extern int tty_register_driver(struct tty_driver *driver); 277extern int tty_register_driver(struct tty_driver *driver);
278extern int tty_unregister_driver(struct tty_driver *driver); 278extern int tty_unregister_driver(struct tty_driver *driver);
279extern struct class_device *tty_register_device(struct tty_driver *driver, 279extern struct device *tty_register_device(struct tty_driver *driver,
280 unsigned index, 280 unsigned index, struct device *dev);
281 struct device *dev);
282extern void tty_unregister_device(struct tty_driver *driver, unsigned index); 281extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
283extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, 282extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
284 int buflen); 283 int buflen);
diff --git a/include/linux/types.h b/include/linux/types.h
index 750f085fa564..745c409ebbb5 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -128,6 +128,8 @@ typedef __s64 int64_t;
128 128
129/* this is a special 64bit data type that is 8-byte aligned */ 129/* this is a special 64bit data type that is 8-byte aligned */
130#define aligned_u64 unsigned long long __attribute__((aligned(8))) 130#define aligned_u64 unsigned long long __attribute__((aligned(8)))
131#define aligned_be64 __be64 __attribute__((aligned(8)))
132#define aligned_le64 __le64 __attribute__((aligned(8)))
131 133
132/** 134/**
133 * The type used for indexing onto a disc or disc partition. 135 * The type used for indexing onto a disc or disc partition.
@@ -180,6 +182,8 @@ typedef __u32 __bitwise __be32;
180typedef __u64 __bitwise __le64; 182typedef __u64 __bitwise __le64;
181typedef __u64 __bitwise __be64; 183typedef __u64 __bitwise __be64;
182#endif 184#endif
185typedef __u16 __bitwise __sum16;
186typedef __u32 __bitwise __wsum;
183 187
184#ifdef __KERNEL__ 188#ifdef __KERNEL__
185typedef unsigned __bitwise__ gfp_t; 189typedef unsigned __bitwise__ gfp_t;
diff --git a/include/linux/udp.h b/include/linux/udp.h
index 014b41d1e308..7e08c07efe0f 100644
--- a/include/linux/udp.h
+++ b/include/linux/udp.h
@@ -23,7 +23,7 @@ struct udphdr {
23 __be16 source; 23 __be16 source;
24 __be16 dest; 24 __be16 dest;
25 __be16 len; 25 __be16 len;
26 __be16 check; 26 __sum16 check;
27}; 27};
28 28
29/* UDP socket options */ 29/* UDP socket options */
@@ -38,6 +38,7 @@ struct udphdr {
38#include <linux/types.h> 38#include <linux/types.h>
39 39
40#include <net/inet_sock.h> 40#include <net/inet_sock.h>
41#define UDP_HTABLE_SIZE 128
41 42
42struct udp_sock { 43struct udp_sock {
43 /* inet_sock has to be the first member */ 44 /* inet_sock has to be the first member */
@@ -50,12 +51,23 @@ struct udp_sock {
50 * when the socket is uncorked. 51 * when the socket is uncorked.
51 */ 52 */
52 __u16 len; /* total length of pending frames */ 53 __u16 len; /* total length of pending frames */
54 /*
55 * Fields specific to UDP-Lite.
56 */
57 __u16 pcslen;
58 __u16 pcrlen;
59/* indicator bits used by pcflag: */
60#define UDPLITE_BIT 0x1 /* set by udplite proto init function */
61#define UDPLITE_SEND_CC 0x2 /* set via udplite setsockopt */
62#define UDPLITE_RECV_CC 0x4 /* set via udplite setsocktopt */
63 __u8 pcflag; /* marks socket as UDP-Lite if > 0 */
53}; 64};
54 65
55static inline struct udp_sock *udp_sk(const struct sock *sk) 66static inline struct udp_sock *udp_sk(const struct sock *sk)
56{ 67{
57 return (struct udp_sock *)sk; 68 return (struct udp_sock *)sk;
58} 69}
70#define IS_UDPLITE(__sk) (udp_sk(__sk)->pcflag)
59 71
60#endif 72#endif
61 73
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 06ce7a626040..aab5b1b72021 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -313,8 +313,13 @@ struct usb_bus {
313/* This is arbitrary. 313/* This is arbitrary.
314 * From USB 2.0 spec Table 11-13, offset 7, a hub can 314 * From USB 2.0 spec Table 11-13, offset 7, a hub can
315 * have up to 255 ports. The most yet reported is 10. 315 * have up to 255 ports. The most yet reported is 10.
316 *
317 * Current Wireless USB host hardware (Intel i1480 for example) allows
318 * up to 22 devices to connect. Upcoming hardware might raise that
319 * limit. Because the arrays need to add a bit for hub status data, we
320 * do 31, so plus one evens out to four bytes.
316 */ 321 */
317#define USB_MAXCHILDREN (16) 322#define USB_MAXCHILDREN (31)
318 323
319struct usb_tt; 324struct usb_tt;
320 325
@@ -357,7 +362,8 @@ struct usb_device {
357 u8 portnum; /* Parent port number (origin 1) */ 362 u8 portnum; /* Parent port number (origin 1) */
358 u8 level; /* Number of USB hub ancestors */ 363 u8 level; /* Number of USB hub ancestors */
359 364
360 int have_langid; /* whether string_langid is valid */ 365 unsigned discon_suspended:1; /* Disconnected while suspended */
366 unsigned have_langid:1; /* whether string_langid is valid */
361 int string_langid; /* language ID for strings */ 367 int string_langid; /* language ID for strings */
362 368
363 /* static strings from the device */ 369 /* static strings from the device */
@@ -410,14 +416,37 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
410 416
411/* USB autosuspend and autoresume */ 417/* USB autosuspend and autoresume */
412#ifdef CONFIG_USB_SUSPEND 418#ifdef CONFIG_USB_SUSPEND
419extern int usb_autopm_set_interface(struct usb_interface *intf);
413extern int usb_autopm_get_interface(struct usb_interface *intf); 420extern int usb_autopm_get_interface(struct usb_interface *intf);
414extern void usb_autopm_put_interface(struct usb_interface *intf); 421extern void usb_autopm_put_interface(struct usb_interface *intf);
415 422
423static inline void usb_autopm_enable(struct usb_interface *intf)
424{
425 intf->pm_usage_cnt = 0;
426 usb_autopm_set_interface(intf);
427}
428
429static inline void usb_autopm_disable(struct usb_interface *intf)
430{
431 intf->pm_usage_cnt = 1;
432 usb_autopm_set_interface(intf);
433}
434
416#else 435#else
417#define usb_autopm_get_interface(intf) 0
418#define usb_autopm_put_interface(intf) do {} while (0)
419#endif
420 436
437static inline int usb_autopm_set_interface(struct usb_interface *intf)
438{ return 0; }
439
440static inline int usb_autopm_get_interface(struct usb_interface *intf)
441{ return 0; }
442
443static inline void usb_autopm_put_interface(struct usb_interface *intf)
444{ }
445static inline void usb_autopm_enable(struct usb_interface *intf)
446{ }
447static inline void usb_autopm_disable(struct usb_interface *intf)
448{ }
449#endif
421 450
422/*-------------------------------------------------------------------------*/ 451/*-------------------------------------------------------------------------*/
423 452
@@ -490,17 +519,137 @@ static inline int usb_make_path (struct usb_device *dev, char *buf,
490 519
491/*-------------------------------------------------------------------------*/ 520/*-------------------------------------------------------------------------*/
492 521
493extern int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd); 522/**
494extern int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd); 523 * usb_endpoint_dir_in - check if the endpoint has IN direction
495extern int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd); 524 * @epd: endpoint to be checked
496extern int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd); 525 *
497extern int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd); 526 * Returns true if the endpoint is of type IN, otherwise it returns false.
498extern int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd); 527 */
499extern int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd); 528static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
500extern int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd); 529{
501extern int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd); 530 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
502extern int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd); 531}
503extern int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd); 532
533/**
534 * usb_endpoint_dir_out - check if the endpoint has OUT direction
535 * @epd: endpoint to be checked
536 *
537 * Returns true if the endpoint is of type OUT, otherwise it returns false.
538 */
539static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
540{
541 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
542}
543
544/**
545 * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
546 * @epd: endpoint to be checked
547 *
548 * Returns true if the endpoint is of type bulk, otherwise it returns false.
549 */
550static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
551{
552 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
553 USB_ENDPOINT_XFER_BULK);
554}
555
556/**
557 * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
558 * @epd: endpoint to be checked
559 *
560 * Returns true if the endpoint is of type interrupt, otherwise it returns
561 * false.
562 */
563static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
564{
565 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
566 USB_ENDPOINT_XFER_INT);
567}
568
569/**
570 * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
571 * @epd: endpoint to be checked
572 *
573 * Returns true if the endpoint is of type isochronous, otherwise it returns
574 * false.
575 */
576static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
577{
578 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
579 USB_ENDPOINT_XFER_ISOC);
580}
581
582/**
583 * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
584 * @epd: endpoint to be checked
585 *
586 * Returns true if the endpoint has bulk transfer type and IN direction,
587 * otherwise it returns false.
588 */
589static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
590{
591 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
592}
593
594/**
595 * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
596 * @epd: endpoint to be checked
597 *
598 * Returns true if the endpoint has bulk transfer type and OUT direction,
599 * otherwise it returns false.
600 */
601static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
602{
603 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
604}
605
606/**
607 * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
608 * @epd: endpoint to be checked
609 *
610 * Returns true if the endpoint has interrupt transfer type and IN direction,
611 * otherwise it returns false.
612 */
613static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
614{
615 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
616}
617
618/**
619 * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
620 * @epd: endpoint to be checked
621 *
622 * Returns true if the endpoint has interrupt transfer type and OUT direction,
623 * otherwise it returns false.
624 */
625static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
626{
627 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
628}
629
630/**
631 * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
632 * @epd: endpoint to be checked
633 *
634 * Returns true if the endpoint has isochronous transfer type and IN direction,
635 * otherwise it returns false.
636 */
637static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
638{
639 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
640}
641
642/**
643 * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
644 * @epd: endpoint to be checked
645 *
646 * Returns true if the endpoint has isochronous transfer type and OUT direction,
647 * otherwise it returns false.
648 */
649static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
650{
651 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
652}
504 653
505/*-------------------------------------------------------------------------*/ 654/*-------------------------------------------------------------------------*/
506 655
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index a50a0130fd9e..7c269f4992eb 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -546,6 +546,8 @@
546/* MLME requests (SIOCSIWMLME / struct iw_mlme) */ 546/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
547#define IW_MLME_DEAUTH 0 547#define IW_MLME_DEAUTH 0
548#define IW_MLME_DISASSOC 1 548#define IW_MLME_DISASSOC 1
549#define IW_MLME_AUTH 2
550#define IW_MLME_ASSOC 3
549 551
550/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */ 552/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
551#define IW_AUTH_INDEX 0x0FFF 553#define IW_AUTH_INDEX 0x0FFF
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index 8ae7f744917b..088ba8113f7e 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -211,8 +211,8 @@ struct xfrm_user_tmpl {
211 211
212struct xfrm_encap_tmpl { 212struct xfrm_encap_tmpl {
213 __u16 encap_type; 213 __u16 encap_type;
214 __u16 encap_sport; 214 __be16 encap_sport;
215 __u16 encap_dport; 215 __be16 encap_dport;
216 xfrm_address_t encap_oa; 216 xfrm_address_t encap_oa;
217}; 217};
218 218
@@ -289,7 +289,9 @@ struct xfrm_usersa_id {
289 289
290struct xfrm_aevent_id { 290struct xfrm_aevent_id {
291 struct xfrm_usersa_id sa_id; 291 struct xfrm_usersa_id sa_id;
292 xfrm_address_t saddr;
292 __u32 flags; 293 __u32 flags;
294 __u32 reqid;
293}; 295};
294 296
295struct xfrm_userspi_info { 297struct xfrm_userspi_info {
diff --git a/include/linux/zftape.h b/include/linux/zftape.h
deleted file mode 100644
index b057c65366c6..000000000000
--- a/include/linux/zftape.h
+++ /dev/null
@@ -1,87 +0,0 @@
1#ifndef _ZFTAPE_H
2#define _ZFTAPE_H
3
4/*
5 * Copyright (C) 1996, 1997 Claus-Justus Heine.
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; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 *
22 * $Source: /homes/cvs/ftape-stacked/include/linux/zftape.h,v $
23 * $Revision: 1.12 $
24 * $Date: 1997/10/21 11:02:37 $
25 *
26 * Special ioctl and other global info for the zftape VFS
27 * interface for the QIC-40/80/3010/3020 floppy-tape driver for
28 * Linux.
29 */
30
31#define ZFTAPE_VERSION "zftape for " FTAPE_VERSION
32
33#include <linux/ftape.h>
34
35#define ZFTAPE_LABEL "Ftape - The Linux Floppy Tape Project!"
36
37/* Bits of the minor device number that control the operation mode */
38#define ZFT_Q80_MODE (1 << 3)
39#define ZFT_ZIP_MODE (1 << 4)
40#define ZFT_RAW_MODE (1 << 5)
41#define ZFT_MINOR_OP_MASK (ZFT_Q80_MODE | \
42 ZFT_ZIP_MODE | \
43 ZFT_RAW_MODE)
44#define ZFT_MINOR_MASK (FTAPE_SEL_MASK | \
45 ZFT_MINOR_OP_MASK | \
46 FTAPE_NO_REWIND)
47
48#ifdef ZFT_OBSOLETE
49struct mtblksz {
50 unsigned int mt_blksz;
51};
52#define MTIOC_ZFTAPE_GETBLKSZ _IOR('m', 104, struct mtblksz)
53#endif
54
55#ifdef __KERNEL__
56
57extern int zft_init(void);
58
59static inline __s64 zft_div_blksz(__s64 value, __u32 blk_sz)
60{
61 if (blk_sz == 1) {
62 return value;
63 } else {
64 return (__s64)(((__u32)(value >> 10) + (blk_sz >> 10) - 1)
65 / (blk_sz >> 10));
66 }
67}
68
69static inline __s64 zft_mul_blksz(__s64 value, __u32 blk_sz)
70{
71 if (blk_sz == 1) {
72 return value;
73 } else {
74 /* if blk_sz != 1, then it is a multiple of 1024. In
75 * this case, `value' will also fit into 32 bits.
76 *
77 * Actually, this limits the capacity to 42
78 * bits. This is (2^32)*1024, roughly a thousand
79 * times 2GB, or 3 Terabytes. Hopefully this is enough
80 */
81 return(__s64)(((__u32)(value)*(blk_sz>>10))<<10);
82 }
83}
84
85#endif
86
87#endif
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 44f1b673f916..88df8fc814e4 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -35,9 +35,9 @@ struct prefix_info {
35#else 35#else
36#error "Please fix <asm/byteorder.h>" 36#error "Please fix <asm/byteorder.h>"
37#endif 37#endif
38 __u32 valid; 38 __be32 valid;
39 __u32 prefered; 39 __be32 prefered;
40 __u32 reserved2; 40 __be32 reserved2;
41 41
42 struct in6_addr prefix; 42 struct in6_addr prefix;
43}; 43};
@@ -183,7 +183,7 @@ static __inline__ u8 ipv6_addr_hash(const struct in6_addr *addr)
183 * This will include the IEEE address token on links that support it. 183 * This will include the IEEE address token on links that support it.
184 */ 184 */
185 185
186 word = addr->s6_addr32[2] ^ addr->s6_addr32[3]; 186 word = (__force u32)(addr->s6_addr32[2] ^ addr->s6_addr32[3]);
187 word ^= (word >> 16); 187 word ^= (word >> 16);
188 word ^= (word >> 8); 188 word ^= (word >> 8);
189 189
diff --git a/include/net/arp.h b/include/net/arp.h
index 6a3d9a7d302b..f02664568600 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -16,7 +16,7 @@ extern void arp_send(int type, int ptype, __be32 dest_ip,
16 struct net_device *dev, __be32 src_ip, 16 struct net_device *dev, __be32 src_ip,
17 unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th); 17 unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th);
18extern int arp_bind_neighbour(struct dst_entry *dst); 18extern int arp_bind_neighbour(struct dst_entry *dst);
19extern int arp_mc_map(u32 addr, u8 *haddr, struct net_device *dev, int dir); 19extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir);
20extern void arp_ifdown(struct net_device *dev); 20extern void arp_ifdown(struct net_device *dev);
21 21
22extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, 22extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
diff --git a/include/net/atmclip.h b/include/net/atmclip.h
index 90fcc98e676f..b5a51a7bb364 100644
--- a/include/net/atmclip.h
+++ b/include/net/atmclip.h
@@ -36,7 +36,7 @@ struct clip_vcc {
36 36
37 37
38struct atmarp_entry { 38struct atmarp_entry {
39 u32 ip; /* IP address */ 39 __be32 ip; /* IP address */
40 struct clip_vcc *vccs; /* active VCCs; NULL if resolution is 40 struct clip_vcc *vccs; /* active VCCs; NULL if resolution is
41 pending */ 41 pending */
42 unsigned long expires; /* entry expiration time */ 42 unsigned long expires; /* entry expiration time */
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index 89d743cfdfdf..3c563f02907c 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -124,7 +124,7 @@ struct rfcomm_pn {
124 u8 flow_ctrl; 124 u8 flow_ctrl;
125 u8 priority; 125 u8 priority;
126 u8 ack_timer; 126 u8 ack_timer;
127 u16 mtu; 127 __le16 mtu;
128 u8 max_retrans; 128 u8 max_retrans;
129 u8 credits; 129 u8 credits;
130} __attribute__ ((packed)); 130} __attribute__ ((packed));
@@ -136,7 +136,7 @@ struct rfcomm_rpn {
136 u8 flow_ctrl; 136 u8 flow_ctrl;
137 u8 xon_char; 137 u8 xon_char;
138 u8 xoff_char; 138 u8 xoff_char;
139 u16 param_mask; 139 __le16 param_mask;
140} __attribute__ ((packed)); 140} __attribute__ ((packed));
141 141
142struct rfcomm_rls { 142struct rfcomm_rls {
diff --git a/include/net/checksum.h b/include/net/checksum.h
index e3ea7cc2c728..124246172a88 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -27,8 +27,8 @@
27 27
28#ifndef _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 28#ifndef _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
29static inline 29static inline
30unsigned int csum_and_copy_from_user (const unsigned char __user *src, unsigned char *dst, 30__wsum csum_and_copy_from_user (const void __user *src, void *dst,
31 int len, int sum, int *err_ptr) 31 int len, __wsum sum, int *err_ptr)
32{ 32{
33 if (access_ok(VERIFY_READ, src, len)) 33 if (access_ok(VERIFY_READ, src, len))
34 return csum_partial_copy_from_user(src, dst, len, sum, err_ptr); 34 return csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
@@ -41,8 +41,8 @@ unsigned int csum_and_copy_from_user (const unsigned char __user *src, unsigned
41#endif 41#endif
42 42
43#ifndef HAVE_CSUM_COPY_USER 43#ifndef HAVE_CSUM_COPY_USER
44static __inline__ unsigned int csum_and_copy_to_user 44static __inline__ __wsum csum_and_copy_to_user
45(const unsigned char *src, unsigned char __user *dst, int len, unsigned int sum, int *err_ptr) 45(const void *src, void __user *dst, int len, __wsum sum, int *err_ptr)
46{ 46{
47 sum = csum_partial(src, len, sum); 47 sum = csum_partial(src, len, sum);
48 48
@@ -53,35 +53,44 @@ static __inline__ unsigned int csum_and_copy_to_user
53 if (len) 53 if (len)
54 *err_ptr = -EFAULT; 54 *err_ptr = -EFAULT;
55 55
56 return -1; /* invalid checksum */ 56 return (__force __wsum)-1; /* invalid checksum */
57} 57}
58#endif 58#endif
59 59
60static inline unsigned int csum_add(unsigned int csum, unsigned int addend) 60static inline __wsum csum_add(__wsum csum, __wsum addend)
61{ 61{
62 csum += addend; 62 u32 res = (__force u32)csum;
63 return csum + (csum < addend); 63 res += (__force u32)addend;
64 return (__force __wsum)(res + (res < (__force u32)addend));
64} 65}
65 66
66static inline unsigned int csum_sub(unsigned int csum, unsigned int addend) 67static inline __wsum csum_sub(__wsum csum, __wsum addend)
67{ 68{
68 return csum_add(csum, ~addend); 69 return csum_add(csum, ~addend);
69} 70}
70 71
71static inline unsigned int 72static inline __wsum
72csum_block_add(unsigned int csum, unsigned int csum2, int offset) 73csum_block_add(__wsum csum, __wsum csum2, int offset)
73{ 74{
75 u32 sum = (__force u32)csum2;
74 if (offset&1) 76 if (offset&1)
75 csum2 = ((csum2&0xFF00FF)<<8)+((csum2>>8)&0xFF00FF); 77 sum = ((sum&0xFF00FF)<<8)+((sum>>8)&0xFF00FF);
76 return csum_add(csum, csum2); 78 return csum_add(csum, (__force __wsum)sum);
77} 79}
78 80
79static inline unsigned int 81static inline __wsum
80csum_block_sub(unsigned int csum, unsigned int csum2, int offset) 82csum_block_sub(__wsum csum, __wsum csum2, int offset)
81{ 83{
84 u32 sum = (__force u32)csum2;
82 if (offset&1) 85 if (offset&1)
83 csum2 = ((csum2&0xFF00FF)<<8)+((csum2>>8)&0xFF00FF); 86 sum = ((sum&0xFF00FF)<<8)+((sum>>8)&0xFF00FF);
84 return csum_sub(csum, csum2); 87 return csum_sub(csum, (__force __wsum)sum);
85} 88}
86 89
90static inline __wsum csum_unfold(__sum16 n)
91{
92 return (__force __wsum)n;
93}
94
95#define CSUM_MANGLED_0 ((__force __sum16)0xffff)
87#endif 96#endif
diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index 718b4d9c891f..4c9522c5178f 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -58,10 +58,10 @@
58#define CIPSO_V4_MAP_PASS 2 58#define CIPSO_V4_MAP_PASS 2
59 59
60/* limits */ 60/* limits */
61#define CIPSO_V4_MAX_REM_LVLS 256 61#define CIPSO_V4_MAX_REM_LVLS 255
62#define CIPSO_V4_INV_LVL 0x80000000 62#define CIPSO_V4_INV_LVL 0x80000000
63#define CIPSO_V4_MAX_LOC_LVLS (CIPSO_V4_INV_LVL - 1) 63#define CIPSO_V4_MAX_LOC_LVLS (CIPSO_V4_INV_LVL - 1)
64#define CIPSO_V4_MAX_REM_CATS 65536 64#define CIPSO_V4_MAX_REM_CATS 65534
65#define CIPSO_V4_INV_CAT 0x80000000 65#define CIPSO_V4_INV_CAT 0x80000000
66#define CIPSO_V4_MAX_LOC_CATS (CIPSO_V4_INV_CAT - 1) 66#define CIPSO_V4_MAX_LOC_CATS (CIPSO_V4_INV_CAT - 1)
67 67
diff --git a/include/net/dsfield.h b/include/net/dsfield.h
index a79c9e075f7f..eb65bf2e2502 100644
--- a/include/net/dsfield.h
+++ b/include/net/dsfield.h
@@ -20,14 +20,14 @@ static inline __u8 ipv4_get_dsfield(struct iphdr *iph)
20 20
21static inline __u8 ipv6_get_dsfield(struct ipv6hdr *ipv6h) 21static inline __u8 ipv6_get_dsfield(struct ipv6hdr *ipv6h)
22{ 22{
23 return ntohs(*(__u16 *) ipv6h) >> 4; 23 return ntohs(*(__be16 *) ipv6h) >> 4;
24} 24}
25 25
26 26
27static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask, 27static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask,
28 __u8 value) 28 __u8 value)
29{ 29{
30 __u32 check = ntohs(iph->check); 30 __u32 check = ntohs((__force __be16)iph->check);
31 __u8 dsfield; 31 __u8 dsfield;
32 32
33 dsfield = (iph->tos & mask) | value; 33 dsfield = (iph->tos & mask) | value;
@@ -35,7 +35,7 @@ static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask,
35 if ((check+1) >> 16) check = (check+1) & 0xffff; 35 if ((check+1) >> 16) check = (check+1) & 0xffff;
36 check -= dsfield; 36 check -= dsfield;
37 check += check >> 16; /* adjust carry */ 37 check += check >> 16; /* adjust carry */
38 iph->check = htons(check); 38 iph->check = (__force __sum16)htons(check);
39 iph->tos = dsfield; 39 iph->tos = dsfield;
40} 40}
41 41
@@ -45,9 +45,9 @@ static inline void ipv6_change_dsfield(struct ipv6hdr *ipv6h,__u8 mask,
45{ 45{
46 __u16 tmp; 46 __u16 tmp;
47 47
48 tmp = ntohs(*(__u16 *) ipv6h); 48 tmp = ntohs(*(__be16 *) ipv6h);
49 tmp = (tmp & ((mask << 4) | 0xf00f)) | (value << 4); 49 tmp = (tmp & ((mask << 4) | 0xf00f)) | (value << 4);
50 *(__u16 *) ipv6h = htons(tmp); 50 *(__be16 *) ipv6h = htons(tmp);
51} 51}
52 52
53 53
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 8e2f473d3e82..bc3c26494c3d 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -13,6 +13,8 @@ struct fib_rule
13 atomic_t refcnt; 13 atomic_t refcnt;
14 int ifindex; 14 int ifindex;
15 char ifname[IFNAMSIZ]; 15 char ifname[IFNAMSIZ];
16 u32 mark;
17 u32 mark_mask;
16 u32 pref; 18 u32 pref;
17 u32 flags; 19 u32 flags;
18 u32 table; 20 u32 table;
@@ -50,6 +52,7 @@ struct fib_rules_ops
50 struct nlmsghdr *, 52 struct nlmsghdr *,
51 struct fib_rule_hdr *); 53 struct fib_rule_hdr *);
52 u32 (*default_pref)(void); 54 u32 (*default_pref)(void);
55 size_t (*nlmsg_payload)(struct fib_rule *);
53 56
54 int nlgroup; 57 int nlgroup;
55 struct nla_policy *policy; 58 struct nla_policy *policy;
@@ -57,6 +60,13 @@ struct fib_rules_ops
57 struct module *owner; 60 struct module *owner;
58}; 61};
59 62
63#define FRA_GENERIC_POLICY \
64 [FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, \
65 [FRA_PRIORITY] = { .type = NLA_U32 }, \
66 [FRA_FWMARK] = { .type = NLA_U32 }, \
67 [FRA_FWMASK] = { .type = NLA_U32 }, \
68 [FRA_TABLE] = { .type = NLA_U32 }
69
60static inline void fib_rule_get(struct fib_rule *rule) 70static inline void fib_rule_get(struct fib_rule *rule)
61{ 71{
62 atomic_inc(&rule->refcnt); 72 atomic_inc(&rule->refcnt);
diff --git a/include/net/flow.h b/include/net/flow.h
index 5cda27cd9deb..ce4b10d8b412 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -13,12 +13,12 @@
13struct flowi { 13struct flowi {
14 int oif; 14 int oif;
15 int iif; 15 int iif;
16 __u32 mark;
16 17
17 union { 18 union {
18 struct { 19 struct {
19 __be32 daddr; 20 __be32 daddr;
20 __be32 saddr; 21 __be32 saddr;
21 __u32 fwmark;
22 __u8 tos; 22 __u8 tos;
23 __u8 scope; 23 __u8 scope;
24 } ip4_u; 24 } ip4_u;
@@ -26,28 +26,23 @@ struct flowi {
26 struct { 26 struct {
27 struct in6_addr daddr; 27 struct in6_addr daddr;
28 struct in6_addr saddr; 28 struct in6_addr saddr;
29 __u32 fwmark; 29 __be32 flowlabel;
30 __u32 flowlabel;
31 } ip6_u; 30 } ip6_u;
32 31
33 struct { 32 struct {
34 __le16 daddr; 33 __le16 daddr;
35 __le16 saddr; 34 __le16 saddr;
36 __u32 fwmark;
37 __u8 scope; 35 __u8 scope;
38 } dn_u; 36 } dn_u;
39 } nl_u; 37 } nl_u;
40#define fld_dst nl_u.dn_u.daddr 38#define fld_dst nl_u.dn_u.daddr
41#define fld_src nl_u.dn_u.saddr 39#define fld_src nl_u.dn_u.saddr
42#define fld_fwmark nl_u.dn_u.fwmark
43#define fld_scope nl_u.dn_u.scope 40#define fld_scope nl_u.dn_u.scope
44#define fl6_dst nl_u.ip6_u.daddr 41#define fl6_dst nl_u.ip6_u.daddr
45#define fl6_src nl_u.ip6_u.saddr 42#define fl6_src nl_u.ip6_u.saddr
46#define fl6_fwmark nl_u.ip6_u.fwmark
47#define fl6_flowlabel nl_u.ip6_u.flowlabel 43#define fl6_flowlabel nl_u.ip6_u.flowlabel
48#define fl4_dst nl_u.ip4_u.daddr 44#define fl4_dst nl_u.ip4_u.daddr
49#define fl4_src nl_u.ip4_u.saddr 45#define fl4_src nl_u.ip4_u.saddr
50#define fl4_fwmark nl_u.ip4_u.fwmark
51#define fl4_tos nl_u.ip4_u.tos 46#define fl4_tos nl_u.ip4_u.tos
52#define fl4_scope nl_u.ip4_u.scope 47#define fl4_scope nl_u.ip4_u.scope
53 48
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index b619314218a6..adff4c898d50 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -53,6 +53,7 @@ struct genl_info
53 * @policy: attribute validation policy 53 * @policy: attribute validation policy
54 * @doit: standard command callback 54 * @doit: standard command callback
55 * @dumpit: callback for dumpers 55 * @dumpit: callback for dumpers
56 * @done: completion callback for dumps
56 * @ops_list: operations list 57 * @ops_list: operations list
57 */ 58 */
58struct genl_ops 59struct genl_ops
@@ -64,6 +65,7 @@ struct genl_ops
64 struct genl_info *info); 65 struct genl_info *info);
65 int (*dumpit)(struct sk_buff *skb, 66 int (*dumpit)(struct sk_buff *skb,
66 struct netlink_callback *cb); 67 struct netlink_callback *cb);
68 int (*done)(struct netlink_callback *cb);
67 struct list_head ops_list; 69 struct list_head ops_list;
68}; 70};
69 71
@@ -79,34 +81,51 @@ extern struct sock *genl_sock;
79 * @skb: socket buffer holding the message 81 * @skb: socket buffer holding the message
80 * @pid: netlink pid the message is addressed to 82 * @pid: netlink pid the message is addressed to
81 * @seq: sequence number (usually the one of the sender) 83 * @seq: sequence number (usually the one of the sender)
82 * @type: netlink message type 84 * @family: generic netlink family
83 * @hdrlen: length of the user specific header
84 * @flags netlink message flags 85 * @flags netlink message flags
85 * @cmd: generic netlink command 86 * @cmd: generic netlink command
86 * @version: version
87 * 87 *
88 * Returns pointer to user specific header 88 * Returns pointer to user specific header
89 */ 89 */
90static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, 90static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
91 int type, int hdrlen, int flags, 91 struct genl_family *family, int flags, u8 cmd)
92 u8 cmd, u8 version)
93{ 92{
94 struct nlmsghdr *nlh; 93 struct nlmsghdr *nlh;
95 struct genlmsghdr *hdr; 94 struct genlmsghdr *hdr;
96 95
97 nlh = nlmsg_put(skb, pid, seq, type, GENL_HDRLEN + hdrlen, flags); 96 nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN +
97 family->hdrsize, flags);
98 if (nlh == NULL) 98 if (nlh == NULL)
99 return NULL; 99 return NULL;
100 100
101 hdr = nlmsg_data(nlh); 101 hdr = nlmsg_data(nlh);
102 hdr->cmd = cmd; 102 hdr->cmd = cmd;
103 hdr->version = version; 103 hdr->version = family->version;
104 hdr->reserved = 0; 104 hdr->reserved = 0;
105 105
106 return (char *) hdr + GENL_HDRLEN; 106 return (char *) hdr + GENL_HDRLEN;
107} 107}
108 108
109/** 109/**
110 * genlmsg_put_reply - Add generic netlink header to a reply message
111 * @skb: socket buffer holding the message
112 * @info: receiver info
113 * @family: generic netlink family
114 * @flags: netlink message flags
115 * @cmd: generic netlink command
116 *
117 * Returns pointer to user specific header
118 */
119static inline void *genlmsg_put_reply(struct sk_buff *skb,
120 struct genl_info *info,
121 struct genl_family *family,
122 int flags, u8 cmd)
123{
124 return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
125 flags, cmd);
126}
127
128/**
110 * genlmsg_end - Finalize a generic netlink message 129 * genlmsg_end - Finalize a generic netlink message
111 * @skb: socket buffer the message is stored in 130 * @skb: socket buffer the message is stored in
112 * @hdr: user specific header 131 * @hdr: user specific header
@@ -150,6 +169,16 @@ static inline int genlmsg_unicast(struct sk_buff *skb, u32 pid)
150} 169}
151 170
152/** 171/**
172 * genlmsg_reply - reply to a request
173 * @skb: netlink message to be sent back
174 * @info: receiver information
175 */
176static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
177{
178 return genlmsg_unicast(skb, info->snd_pid);
179}
180
181/**
153 * gennlmsg_data - head of message payload 182 * gennlmsg_data - head of message payload
154 * @gnlh: genetlink messsage header 183 * @gnlh: genetlink messsage header
155 */ 184 */
@@ -187,4 +216,15 @@ static inline int genlmsg_total_size(int payload)
187 return NLMSG_ALIGN(genlmsg_msg_size(payload)); 216 return NLMSG_ALIGN(genlmsg_msg_size(payload));
188} 217}
189 218
219/**
220 * genlmsg_new - Allocate a new generic netlink message
221 * @payload: size of the message payload
222 * @flags: the type of memory to allocate.
223 */
224static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
225{
226 return nlmsg_new(genlmsg_total_size(payload), flags);
227}
228
229
190#endif /* __NET_GENERIC_NETLINK_H */ 230#endif /* __NET_GENERIC_NETLINK_H */
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index b174ebb277a9..e6af381e206d 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -1037,6 +1037,10 @@ struct ieee80211_device {
1037 /* host performs multicast decryption */ 1037 /* host performs multicast decryption */
1038 int host_mc_decrypt; 1038 int host_mc_decrypt;
1039 1039
1040 /* host should strip IV and ICV from protected frames */
1041 /* meaningful only when hardware decryption is being used */
1042 int host_strip_iv_icv;
1043
1040 int host_open_frag; 1044 int host_open_frag;
1041 int host_build_iv; 1045 int host_build_iv;
1042 int ieee802_1x; /* is IEEE 802.1X used */ 1046 int ieee802_1x; /* is IEEE 802.1X used */
@@ -1076,6 +1080,8 @@ struct ieee80211_device {
1076 int perfect_rssi; 1080 int perfect_rssi;
1077 int worst_rssi; 1081 int worst_rssi;
1078 1082
1083 u16 prev_seq_ctl; /* used to drop duplicate frames */
1084
1079 /* Callback functions */ 1085 /* Callback functions */
1080 void (*set_security) (struct net_device * dev, 1086 void (*set_security) (struct net_device * dev,
1081 struct ieee80211_security * sec); 1087 struct ieee80211_security * sec);
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index 34489c13c119..3ec7d07346d6 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -152,6 +152,7 @@ struct ifacaddr6
152 152
153struct ipv6_devstat { 153struct ipv6_devstat {
154 struct proc_dir_entry *proc_dir_entry; 154 struct proc_dir_entry *proc_dir_entry;
155 DEFINE_SNMP_STAT(struct ipstats_mib, ipv6);
155 DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6); 156 DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6);
156}; 157};
157 158
diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h
index b33b438bffcc..16aa96a6a53b 100644
--- a/include/net/inet6_connection_sock.h
+++ b/include/net/inet6_connection_sock.h
@@ -27,7 +27,7 @@ extern int inet6_csk_bind_conflict(const struct sock *sk,
27 27
28extern struct request_sock *inet6_csk_search_req(const struct sock *sk, 28extern struct request_sock *inet6_csk_search_req(const struct sock *sk,
29 struct request_sock ***prevp, 29 struct request_sock ***prevp,
30 const __u16 rport, 30 const __be16 rport,
31 const struct in6_addr *raddr, 31 const struct in6_addr *raddr,
32 const struct in6_addr *laddr, 32 const struct in6_addr *laddr,
33 const int iif); 33 const int iif);
@@ -38,5 +38,5 @@ extern void inet6_csk_reqsk_queue_hash_add(struct sock *sk,
38 38
39extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); 39extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr);
40 40
41extern int inet6_csk_xmit(struct sk_buff *skb, int ipfragok); 41extern int inet6_csk_xmit(struct sk_buff *skb, struct sock *sk, int ipfragok);
42#endif /* _INET6_CONNECTION_SOCK_H */ 42#endif /* _INET6_CONNECTION_SOCK_H */
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index bc6a71dce984..c28e424f53d9 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -26,11 +26,11 @@ struct inet_hashinfo;
26 26
27/* I have no idea if this is a good hash for v6 or not. -DaveM */ 27/* I have no idea if this is a good hash for v6 or not. -DaveM */
28static inline unsigned int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport, 28static inline unsigned int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport,
29 const struct in6_addr *faddr, const u16 fport) 29 const struct in6_addr *faddr, const __be16 fport)
30{ 30{
31 unsigned int hashent = (lport ^ fport); 31 unsigned int hashent = (lport ^ (__force u16)fport);
32 32
33 hashent ^= (laddr->s6_addr32[3] ^ faddr->s6_addr32[3]); 33 hashent ^= (__force u32)(laddr->s6_addr32[3] ^ faddr->s6_addr32[3]);
34 hashent ^= hashent >> 16; 34 hashent ^= hashent >> 16;
35 hashent ^= hashent >> 8; 35 hashent ^= hashent >> 8;
36 return hashent; 36 return hashent;
@@ -43,7 +43,7 @@ static inline int inet6_sk_ehashfn(const struct sock *sk)
43 const struct in6_addr *laddr = &np->rcv_saddr; 43 const struct in6_addr *laddr = &np->rcv_saddr;
44 const struct in6_addr *faddr = &np->daddr; 44 const struct in6_addr *faddr = &np->daddr;
45 const __u16 lport = inet->num; 45 const __u16 lport = inet->num;
46 const __u16 fport = inet->dport; 46 const __be16 fport = inet->dport;
47 return inet6_ehashfn(laddr, lport, faddr, fport); 47 return inet6_ehashfn(laddr, lport, faddr, fport);
48} 48}
49 49
@@ -57,7 +57,7 @@ extern void __inet6_hash(struct inet_hashinfo *hashinfo, struct sock *sk);
57 */ 57 */
58extern struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, 58extern struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
59 const struct in6_addr *saddr, 59 const struct in6_addr *saddr,
60 const u16 sport, 60 const __be16 sport,
61 const struct in6_addr *daddr, 61 const struct in6_addr *daddr,
62 const u16 hnum, 62 const u16 hnum,
63 const int dif); 63 const int dif);
@@ -69,7 +69,7 @@ extern struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo,
69 69
70static inline struct sock *__inet6_lookup(struct inet_hashinfo *hashinfo, 70static inline struct sock *__inet6_lookup(struct inet_hashinfo *hashinfo,
71 const struct in6_addr *saddr, 71 const struct in6_addr *saddr,
72 const u16 sport, 72 const __be16 sport,
73 const struct in6_addr *daddr, 73 const struct in6_addr *daddr,
74 const u16 hnum, 74 const u16 hnum,
75 const int dif) 75 const int dif)
@@ -83,8 +83,8 @@ static inline struct sock *__inet6_lookup(struct inet_hashinfo *hashinfo,
83} 83}
84 84
85extern struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, 85extern struct sock *inet6_lookup(struct inet_hashinfo *hashinfo,
86 const struct in6_addr *saddr, const u16 sport, 86 const struct in6_addr *saddr, const __be16 sport,
87 const struct in6_addr *daddr, const u16 dport, 87 const struct in6_addr *daddr, const __be16 dport,
88 const int dif); 88 const int dif);
89#endif /* defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) */ 89#endif /* defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) */
90#endif /* _INET6_HASHTABLES_H */ 90#endif /* _INET6_HASHTABLES_H */
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 0bcf9f237e1f..cccea051e922 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -36,7 +36,8 @@ struct tcp_congestion_ops;
36 * (i.e. things that depend on the address family) 36 * (i.e. things that depend on the address family)
37 */ 37 */
38struct inet_connection_sock_af_ops { 38struct inet_connection_sock_af_ops {
39 int (*queue_xmit)(struct sk_buff *skb, int ipfragok); 39 int (*queue_xmit)(struct sk_buff *skb, struct sock *sk,
40 int ipfragok);
40 void (*send_check)(struct sock *sk, int len, 41 void (*send_check)(struct sock *sk, int len,
41 struct sk_buff *skb); 42 struct sk_buff *skb);
42 int (*rebuild_header)(struct sock *sk); 43 int (*rebuild_header)(struct sock *sk);
@@ -45,7 +46,8 @@ struct inet_connection_sock_af_ops {
45 struct request_sock *req, 46 struct request_sock *req,
46 struct dst_entry *dst); 47 struct dst_entry *dst);
47 int (*remember_stamp)(struct sock *sk); 48 int (*remember_stamp)(struct sock *sk);
48 __u16 net_header_len; 49 u16 net_header_len;
50 u16 sockaddr_len;
49 int (*setsockopt)(struct sock *sk, int level, int optname, 51 int (*setsockopt)(struct sock *sk, int level, int optname,
50 char __user *optval, int optlen); 52 char __user *optval, int optlen);
51 int (*getsockopt)(struct sock *sk, int level, int optname, 53 int (*getsockopt)(struct sock *sk, int level, int optname,
@@ -57,7 +59,6 @@ struct inet_connection_sock_af_ops {
57 int level, int optname, 59 int level, int optname,
58 char __user *optval, int __user *optlen); 60 char __user *optval, int __user *optlen);
59 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); 61 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
60 int sockaddr_len;
61}; 62};
62 63
63/** inet_connection_sock - INET connection oriented sock 64/** inet_connection_sock - INET connection oriented sock
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index 7849844a4911..10117c8503e8 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -53,7 +53,7 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
53 53
54static inline int IP_ECN_set_ce(struct iphdr *iph) 54static inline int IP_ECN_set_ce(struct iphdr *iph)
55{ 55{
56 u32 check = iph->check; 56 u32 check = (__force u32)iph->check;
57 u32 ecn = (iph->tos + 1) & INET_ECN_MASK; 57 u32 ecn = (iph->tos + 1) & INET_ECN_MASK;
58 58
59 /* 59 /*
@@ -71,9 +71,9 @@ static inline int IP_ECN_set_ce(struct iphdr *iph)
71 * INET_ECN_ECT_1 => check += htons(0xFFFD) 71 * INET_ECN_ECT_1 => check += htons(0xFFFD)
72 * INET_ECN_ECT_0 => check += htons(0xFFFE) 72 * INET_ECN_ECT_0 => check += htons(0xFFFE)
73 */ 73 */
74 check += htons(0xFFFB) + htons(ecn); 74 check += (__force u16)htons(0xFFFB) + (__force u16)htons(ecn);
75 75
76 iph->check = check + (check>=0xFFFF); 76 iph->check = (__force __sum16)(check + (check>=0xFFFF));
77 iph->tos |= INET_ECN_CE; 77 iph->tos |= INET_ECN_CE;
78 return 1; 78 return 1;
79} 79}
@@ -95,13 +95,13 @@ static inline int IP6_ECN_set_ce(struct ipv6hdr *iph)
95{ 95{
96 if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph))) 96 if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph)))
97 return 0; 97 return 0;
98 *(u32*)iph |= htonl(INET_ECN_CE << 20); 98 *(__be32*)iph |= htonl(INET_ECN_CE << 20);
99 return 1; 99 return 1;
100} 100}
101 101
102static inline void IP6_ECN_clear(struct ipv6hdr *iph) 102static inline void IP6_ECN_clear(struct ipv6hdr *iph)
103{ 103{
104 *(u32*)iph &= ~htonl(INET_ECN_MASK << 20); 104 *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20);
105} 105}
106 106
107static inline void ipv6_copy_dscp(struct ipv6hdr *outer, struct ipv6hdr *inner) 107static inline void ipv6_copy_dscp(struct ipv6hdr *outer, struct ipv6hdr *inner)
diff --git a/include/net/ip.h b/include/net/ip.h
index b6d95e553401..83cb9ac5554e 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -97,7 +97,7 @@ extern int ip_mc_output(struct sk_buff *skb);
97extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); 97extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
98extern int ip_do_nat(struct sk_buff *skb); 98extern int ip_do_nat(struct sk_buff *skb);
99extern void ip_send_check(struct iphdr *ip); 99extern void ip_send_check(struct iphdr *ip);
100extern int ip_queue_xmit(struct sk_buff *skb, int ipfragok); 100extern int ip_queue_xmit(struct sk_buff *skb, struct sock *sk, int ipfragok);
101extern void ip_init(void); 101extern void ip_init(void);
102extern int ip_append_data(struct sock *sk, 102extern int ip_append_data(struct sock *sk,
103 int getfrag(void *from, char *to, int offset, int len, 103 int getfrag(void *from, char *to, int offset, int len,
@@ -123,7 +123,7 @@ extern int ip4_datagram_connect(struct sock *sk,
123 * multicast packets. 123 * multicast packets.
124 */ 124 */
125 125
126static inline void ip_tr_mc_map(u32 addr, char *buf) 126static inline void ip_tr_mc_map(__be32 addr, char *buf)
127{ 127{
128 buf[0]=0xC0; 128 buf[0]=0xC0;
129 buf[1]=0x00; 129 buf[1]=0x00;
@@ -135,7 +135,7 @@ static inline void ip_tr_mc_map(u32 addr, char *buf)
135 135
136struct ip_reply_arg { 136struct ip_reply_arg {
137 struct kvec iov[1]; 137 struct kvec iov[1];
138 u32 csum; 138 __wsum csum;
139 int csumoffset; /* u16 offset of csum in iov[0].iov_base */ 139 int csumoffset; /* u16 offset of csum in iov[0].iov_base */
140 /* -1 if not needed */ 140 /* -1 if not needed */
141}; 141};
@@ -192,9 +192,9 @@ extern void ipfrag_init(void);
192static inline 192static inline
193int ip_decrease_ttl(struct iphdr *iph) 193int ip_decrease_ttl(struct iphdr *iph)
194{ 194{
195 u32 check = iph->check; 195 u32 check = (__force u32)iph->check;
196 check += htons(0x0100); 196 check += (__force u32)htons(0x0100);
197 iph->check = check + (check>=0xFFFF); 197 iph->check = (__force __sum16)(check + (check>=0xFFFF));
198 return --iph->ttl; 198 return --iph->ttl;
199} 199}
200 200
@@ -238,9 +238,9 @@ static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst
238 * Map a multicast IP onto multicast MAC for type ethernet. 238 * Map a multicast IP onto multicast MAC for type ethernet.
239 */ 239 */
240 240
241static inline void ip_eth_mc_map(u32 addr, char *buf) 241static inline void ip_eth_mc_map(__be32 naddr, char *buf)
242{ 242{
243 addr=ntohl(addr); 243 __u32 addr=ntohl(naddr);
244 buf[0]=0x01; 244 buf[0]=0x01;
245 buf[1]=0x00; 245 buf[1]=0x00;
246 buf[2]=0x5e; 246 buf[2]=0x5e;
@@ -256,13 +256,14 @@ static inline void ip_eth_mc_map(u32 addr, char *buf)
256 * Leave P_Key as 0 to be filled in by driver. 256 * Leave P_Key as 0 to be filled in by driver.
257 */ 257 */
258 258
259static inline void ip_ib_mc_map(u32 addr, char *buf) 259static inline void ip_ib_mc_map(__be32 naddr, char *buf)
260{ 260{
261 __u32 addr;
261 buf[0] = 0; /* Reserved */ 262 buf[0] = 0; /* Reserved */
262 buf[1] = 0xff; /* Multicast QPN */ 263 buf[1] = 0xff; /* Multicast QPN */
263 buf[2] = 0xff; 264 buf[2] = 0xff;
264 buf[3] = 0xff; 265 buf[3] = 0xff;
265 addr = ntohl(addr); 266 addr = ntohl(naddr);
266 buf[4] = 0xff; 267 buf[4] = 0xff;
267 buf[5] = 0x12; /* link local scope */ 268 buf[5] = 0x12; /* link local scope */
268 buf[6] = 0x40; /* IPv4 signature */ 269 buf[6] = 0x40; /* IPv4 signature */
diff --git a/include/net/ip6_checksum.h b/include/net/ip6_checksum.h
index 3dfc885bdf25..68e2b32cf1d6 100644
--- a/include/net/ip6_checksum.h
+++ b/include/net/ip6_checksum.h
@@ -34,60 +34,60 @@
34 34
35#ifndef _HAVE_ARCH_IPV6_CSUM 35#ifndef _HAVE_ARCH_IPV6_CSUM
36 36
37static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 37static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
38 struct in6_addr *daddr, 38 const struct in6_addr *daddr,
39 __u16 len, 39 __u32 len, unsigned short proto,
40 unsigned short proto, 40 __wsum csum)
41 unsigned int csum)
42{ 41{
43 42
44 int carry; 43 int carry;
45 __u32 ulen; 44 __u32 ulen;
46 __u32 uproto; 45 __u32 uproto;
46 __u32 sum = (__force u32)csum;
47 47
48 csum += saddr->s6_addr32[0]; 48 sum += (__force u32)saddr->s6_addr32[0];
49 carry = (csum < saddr->s6_addr32[0]); 49 carry = (sum < (__force u32)saddr->s6_addr32[0]);
50 csum += carry; 50 sum += carry;
51 51
52 csum += saddr->s6_addr32[1]; 52 sum += (__force u32)saddr->s6_addr32[1];
53 carry = (csum < saddr->s6_addr32[1]); 53 carry = (sum < (__force u32)saddr->s6_addr32[1]);
54 csum += carry; 54 sum += carry;
55 55
56 csum += saddr->s6_addr32[2]; 56 sum += (__force u32)saddr->s6_addr32[2];
57 carry = (csum < saddr->s6_addr32[2]); 57 carry = (sum < (__force u32)saddr->s6_addr32[2]);
58 csum += carry; 58 sum += carry;
59 59
60 csum += saddr->s6_addr32[3]; 60 sum += (__force u32)saddr->s6_addr32[3];
61 carry = (csum < saddr->s6_addr32[3]); 61 carry = (sum < (__force u32)saddr->s6_addr32[3]);
62 csum += carry; 62 sum += carry;
63 63
64 csum += daddr->s6_addr32[0]; 64 sum += (__force u32)daddr->s6_addr32[0];
65 carry = (csum < daddr->s6_addr32[0]); 65 carry = (sum < (__force u32)daddr->s6_addr32[0]);
66 csum += carry; 66 sum += carry;
67 67
68 csum += daddr->s6_addr32[1]; 68 sum += (__force u32)daddr->s6_addr32[1];
69 carry = (csum < daddr->s6_addr32[1]); 69 carry = (sum < (__force u32)daddr->s6_addr32[1]);
70 csum += carry; 70 sum += carry;
71 71
72 csum += daddr->s6_addr32[2]; 72 sum += (__force u32)daddr->s6_addr32[2];
73 carry = (csum < daddr->s6_addr32[2]); 73 carry = (sum < (__force u32)daddr->s6_addr32[2]);
74 csum += carry; 74 sum += carry;
75 75
76 csum += daddr->s6_addr32[3]; 76 sum += (__force u32)daddr->s6_addr32[3];
77 carry = (csum < daddr->s6_addr32[3]); 77 carry = (sum < (__force u32)daddr->s6_addr32[3]);
78 csum += carry; 78 sum += carry;
79 79
80 ulen = htonl((__u32) len); 80 ulen = (__force u32)htonl((__u32) len);
81 csum += ulen; 81 sum += ulen;
82 carry = (csum < ulen); 82 carry = (sum < ulen);
83 csum += carry; 83 sum += carry;
84 84
85 uproto = htonl(proto); 85 uproto = (__force u32)htonl(proto);
86 csum += uproto; 86 sum += uproto;
87 carry = (csum < uproto); 87 carry = (sum < uproto);
88 csum += carry; 88 sum += carry;
89 89
90 return csum_fold(csum); 90 return csum_fold((__force __wsum)csum);
91} 91}
92 92
93#endif 93#endif
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index e4438de3bd6b..f9cde44f93b4 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -107,6 +107,11 @@ struct rt6_info
107 u8 rt6i_protocol; 107 u8 rt6i_protocol;
108}; 108};
109 109
110static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
111{
112 return ((struct rt6_info *)dst)->rt6i_idev;
113}
114
110struct fib6_walker_t 115struct fib6_walker_t
111{ 116{
112 struct fib6_walker_t *prev, *next; 117 struct fib6_walker_t *prev, *next;
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index c14b70ed4c57..4e927ebd1cb3 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -20,7 +20,7 @@ struct route_info {
20 route_pref:2, 20 route_pref:2,
21 reserved_h:3; 21 reserved_h:3;
22#endif 22#endif
23 __u32 lifetime; 23 __be32 lifetime;
24 __u8 prefix[0]; /* 0,8 or 16 */ 24 __u8 prefix[0]; /* 0,8 or 16 */
25}; 25};
26 26
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 949b932d2f08..36c635ca1aa6 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -115,7 +115,7 @@ struct fib_result {
115 115
116struct fib_result_nl { 116struct fib_result_nl {
117 __be32 fl_addr; /* To be looked up*/ 117 __be32 fl_addr; /* To be looked up*/
118 u32 fl_fwmark; 118 u32 fl_mark;
119 unsigned char fl_tos; 119 unsigned char fl_tos;
120 unsigned char fl_scope; 120 unsigned char fl_scope;
121 unsigned char tb_id_in; 121 unsigned char tb_id_in;
diff --git a/include/net/ip_mp_alg.h b/include/net/ip_mp_alg.h
index beffdd66ad74..25b56571e54b 100644
--- a/include/net/ip_mp_alg.h
+++ b/include/net/ip_mp_alg.h
@@ -88,9 +88,7 @@ static inline int multipath_comparekeys(const struct flowi *flp1,
88 return flp1->fl4_dst == flp2->fl4_dst && 88 return flp1->fl4_dst == flp2->fl4_dst &&
89 flp1->fl4_src == flp2->fl4_src && 89 flp1->fl4_src == flp2->fl4_src &&
90 flp1->oif == flp2->oif && 90 flp1->oif == flp2->oif &&
91#ifdef CONFIG_IP_ROUTE_FWMARK 91 flp1->mark == flp2->mark &&
92 flp1->fl4_fwmark == flp2->fl4_fwmark &&
93#endif
94 !((flp1->fl4_tos ^ flp2->fl4_tos) & 92 !((flp1->fl4_tos ^ flp2->fl4_tos) &
95 (IPTOS_RT_MASK | RTO_ONLINK)); 93 (IPTOS_RT_MASK | RTO_ONLINK));
96} 94}
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 903108e583f8..672564e5a81d 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -988,14 +988,20 @@ extern int ip_vs_make_skb_writable(struct sk_buff **pskb, int len);
988extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp, 988extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
989 struct ip_vs_conn *cp, int dir); 989 struct ip_vs_conn *cp, int dir);
990 990
991extern u16 ip_vs_checksum_complete(struct sk_buff *skb, int offset); 991extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset);
992 992
993static inline u16 ip_vs_check_diff(u32 old, u32 new, u16 oldsum) 993static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum)
994{ 994{
995 u32 diff[2] = { old, new }; 995 __be32 diff[2] = { ~old, new };
996 996
997 return csum_fold(csum_partial((char *) diff, sizeof(diff), 997 return csum_partial((char *) diff, sizeof(diff), oldsum);
998 oldsum ^ 0xFFFF)); 998}
999
1000static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum)
1001{
1002 __be16 diff[2] = { ~old, new };
1003
1004 return csum_partial((char *) diff, sizeof(diff), oldsum);
999} 1005}
1000 1006
1001#endif /* __KERNEL__ */ 1007#endif /* __KERNEL__ */
diff --git a/include/net/ipconfig.h b/include/net/ipconfig.h
index 2a1fe996fbc6..3924d7d2cb11 100644
--- a/include/net/ipconfig.h
+++ b/include/net/ipconfig.h
@@ -11,12 +11,12 @@
11extern int ic_proto_enabled; /* Protocols enabled (see IC_xxx) */ 11extern int ic_proto_enabled; /* Protocols enabled (see IC_xxx) */
12extern int ic_set_manually; /* IPconfig parameters set manually */ 12extern int ic_set_manually; /* IPconfig parameters set manually */
13 13
14extern u32 ic_myaddr; /* My IP address */ 14extern __be32 ic_myaddr; /* My IP address */
15extern u32 ic_gateway; /* Gateway IP address */ 15extern __be32 ic_gateway; /* Gateway IP address */
16 16
17extern u32 ic_servaddr; /* Boot server IP address */ 17extern __be32 ic_servaddr; /* Boot server IP address */
18 18
19extern u32 root_server_addr; /* Address of NFS server */ 19extern __be32 root_server_addr; /* Address of NFS server */
20extern u8 root_server_path[]; /* Path to mount as root */ 20extern u8 root_server_path[]; /* Path to mount as root */
21 21
22 22
diff --git a/include/net/ipip.h b/include/net/ipip.h
index f490c3cbe377..7cdc914322f0 100644
--- a/include/net/ipip.h
+++ b/include/net/ipip.h
@@ -35,7 +35,7 @@ struct ip_tunnel
35 ip_send_check(iph); \ 35 ip_send_check(iph); \
36 \ 36 \
37 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, dst_output);\ 37 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, dst_output);\
38 if (err == NET_XMIT_SUCCESS || err == NET_XMIT_CN) { \ 38 if (net_xmit_eval(err) == 0) { \
39 stats->tx_bytes += pkt_len; \ 39 stats->tx_bytes += pkt_len; \
40 stats->tx_packets++; \ 40 stats->tx_packets++; \
41 } else { \ 41 } else { \
@@ -44,8 +44,4 @@ struct ip_tunnel
44 } \ 44 } \
45} while (0) 45} while (0)
46 46
47
48extern int sit_init(void);
49extern void sit_cleanup(void);
50
51#endif 47#endif
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 8223c4410b4b..00328b71a08c 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -95,10 +95,10 @@
95 */ 95 */
96 96
97struct frag_hdr { 97struct frag_hdr {
98 unsigned char nexthdr; 98 __u8 nexthdr;
99 unsigned char reserved; 99 __u8 reserved;
100 unsigned short frag_off; 100 __be16 frag_off;
101 __u32 identification; 101 __be32 identification;
102}; 102};
103 103
104#define IP6_MF 0x0001 104#define IP6_MF 0x0001
@@ -113,9 +113,24 @@ extern int sysctl_mld_max_msf;
113 113
114/* MIBs */ 114/* MIBs */
115DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); 115DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
116#define IP6_INC_STATS(field) SNMP_INC_STATS(ipv6_statistics, field) 116#define IP6_INC_STATS(idev,field) ({ \
117#define IP6_INC_STATS_BH(field) SNMP_INC_STATS_BH(ipv6_statistics, field) 117 struct inet6_dev *_idev = (idev); \
118#define IP6_INC_STATS_USER(field) SNMP_INC_STATS_USER(ipv6_statistics, field) 118 if (likely(_idev != NULL)) \
119 SNMP_INC_STATS(_idev->stats.ipv6, field); \
120 SNMP_INC_STATS(ipv6_statistics, field); \
121})
122#define IP6_INC_STATS_BH(idev,field) ({ \
123 struct inet6_dev *_idev = (idev); \
124 if (likely(_idev != NULL)) \
125 SNMP_INC_STATS_BH(_idev->stats.ipv6, field); \
126 SNMP_INC_STATS_BH(ipv6_statistics, field); \
127})
128#define IP6_INC_STATS_USER(idev,field) ({ \
129 struct inet6_dev *_idev = (idev); \
130 if (likely(_idev != NULL)) \
131 SNMP_INC_STATS_USER(_idev->stats.ipv6, field); \
132 SNMP_INC_STATS_USER(ipv6_statistics, field); \
133})
119DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); 134DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
120#define ICMP6_INC_STATS(idev, field) ({ \ 135#define ICMP6_INC_STATS(idev, field) ({ \
121 struct inet6_dev *_idev = (idev); \ 136 struct inet6_dev *_idev = (idev); \
@@ -143,9 +158,13 @@ DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
143 SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \ 158 SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \
144}) 159})
145DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6); 160DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
146#define UDP6_INC_STATS(field) SNMP_INC_STATS(udp_stats_in6, field) 161DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
147#define UDP6_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_stats_in6, field) 162#define UDP6_INC_STATS_BH(field, is_udplite) do { \
148#define UDP6_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_stats_in6, field) 163 if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
164 else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
165#define UDP6_INC_STATS_USER(field, is_udplite) do { \
166 if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
167 else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
149 168
150int snmp6_register_dev(struct inet6_dev *idev); 169int snmp6_register_dev(struct inet6_dev *idev);
151int snmp6_unregister_dev(struct inet6_dev *idev); 170int snmp6_unregister_dev(struct inet6_dev *idev);
@@ -191,7 +210,7 @@ struct ipv6_txoptions
191struct ip6_flowlabel 210struct ip6_flowlabel
192{ 211{
193 struct ip6_flowlabel *next; 212 struct ip6_flowlabel *next;
194 u32 label; 213 __be32 label;
195 struct in6_addr dst; 214 struct in6_addr dst;
196 struct ipv6_txoptions *opt; 215 struct ipv6_txoptions *opt;
197 atomic_t users; 216 atomic_t users;
@@ -211,7 +230,7 @@ struct ipv6_fl_socklist
211 struct ip6_flowlabel *fl; 230 struct ip6_flowlabel *fl;
212}; 231};
213 232
214extern struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, u32 label); 233extern struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, __be32 label);
215extern struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space, 234extern struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_space,
216 struct ip6_flowlabel * fl, 235 struct ip6_flowlabel * fl,
217 struct ipv6_txoptions * fopt); 236 struct ipv6_txoptions * fopt);
@@ -375,22 +394,15 @@ static inline int ipv6_addr_any(const struct in6_addr *a)
375 */ 394 */
376static inline int __ipv6_addr_diff(const void *token1, const void *token2, int addrlen) 395static inline int __ipv6_addr_diff(const void *token1, const void *token2, int addrlen)
377{ 396{
378 const __u32 *a1 = token1, *a2 = token2; 397 const __be32 *a1 = token1, *a2 = token2;
379 int i; 398 int i;
380 399
381 addrlen >>= 2; 400 addrlen >>= 2;
382 401
383 for (i = 0; i < addrlen; i++) { 402 for (i = 0; i < addrlen; i++) {
384 __u32 xb = a1[i] ^ a2[i]; 403 __be32 xb = a1[i] ^ a2[i];
385 if (xb) { 404 if (xb)
386 int j = 31; 405 return i * 32 + 32 - fls(ntohl(xb));
387
388 xb = ntohl(xb);
389 while ((xb & (1 << j)) == 0)
390 j--;
391
392 return (i * 32 + 31 - j);
393 }
394 } 406 }
395 407
396 /* 408 /*
@@ -544,7 +556,7 @@ extern int ip6_datagram_connect(struct sock *sk,
544 struct sockaddr *addr, int addr_len); 556 struct sockaddr *addr, int addr_len);
545 557
546extern int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len); 558extern int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len);
547extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16 port, 559extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port,
548 u32 info, u8 *payload); 560 u32 info, u8 *payload);
549extern void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info); 561extern void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info);
550 562
@@ -589,6 +601,8 @@ extern int tcp6_proc_init(void);
589extern void tcp6_proc_exit(void); 601extern void tcp6_proc_exit(void);
590extern int udp6_proc_init(void); 602extern int udp6_proc_init(void);
591extern void udp6_proc_exit(void); 603extern void udp6_proc_exit(void);
604extern int udplite6_proc_init(void);
605extern void udplite6_proc_exit(void);
592extern int ipv6_misc_proc_init(void); 606extern int ipv6_misc_proc_init(void);
593extern void ipv6_misc_proc_exit(void); 607extern void ipv6_misc_proc_exit(void);
594 608
diff --git a/include/net/irda/irlap_frame.h b/include/net/irda/irlap_frame.h
index 9dd54a5002b2..641f88e848bd 100644
--- a/include/net/irda/irlap_frame.h
+++ b/include/net/irda/irlap_frame.h
@@ -91,8 +91,8 @@ struct xid_frame {
91 __u8 caddr; /* Connection address */ 91 __u8 caddr; /* Connection address */
92 __u8 control; 92 __u8 control;
93 __u8 ident; /* Should always be XID_FORMAT */ 93 __u8 ident; /* Should always be XID_FORMAT */
94 __u32 saddr; /* Source device address */ 94 __le32 saddr; /* Source device address */
95 __u32 daddr; /* Destination device address */ 95 __le32 daddr; /* Destination device address */
96 __u8 flags; /* Discovery flags */ 96 __u8 flags; /* Discovery flags */
97 __u8 slotnr; 97 __u8 slotnr;
98 __u8 version; 98 __u8 version;
@@ -101,15 +101,15 @@ struct xid_frame {
101struct test_frame { 101struct test_frame {
102 __u8 caddr; /* Connection address */ 102 __u8 caddr; /* Connection address */
103 __u8 control; 103 __u8 control;
104 __u32 saddr; /* Source device address */ 104 __le32 saddr; /* Source device address */
105 __u32 daddr; /* Destination device address */ 105 __le32 daddr; /* Destination device address */
106} IRDA_PACK; 106} IRDA_PACK;
107 107
108struct ua_frame { 108struct ua_frame {
109 __u8 caddr; 109 __u8 caddr;
110 __u8 control; 110 __u8 control;
111 __u32 saddr; /* Source device address */ 111 __le32 saddr; /* Source device address */
112 __u32 daddr; /* Dest device address */ 112 __le32 daddr; /* Dest device address */
113} IRDA_PACK; 113} IRDA_PACK;
114 114
115struct dm_frame { 115struct dm_frame {
@@ -135,8 +135,8 @@ struct i_frame {
135struct snrm_frame { 135struct snrm_frame {
136 __u8 caddr; 136 __u8 caddr;
137 __u8 control; 137 __u8 control;
138 __u32 saddr; 138 __le32 saddr;
139 __u32 daddr; 139 __le32 daddr;
140 __u8 ncaddr; 140 __u8 ncaddr;
141} IRDA_PACK; 141} IRDA_PACK;
142 142
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h
index 8f6306581fa7..aa33a477c3fb 100644
--- a/include/net/llc_pdu.h
+++ b/include/net/llc_pdu.h
@@ -252,9 +252,9 @@ static inline void llc_pdu_header_init(struct sk_buff *skb, u8 type,
252 */ 252 */
253static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa) 253static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa)
254{ 254{
255 if (skb->protocol == ntohs(ETH_P_802_2)) 255 if (skb->protocol == htons(ETH_P_802_2))
256 memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN); 256 memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN);
257 else if (skb->protocol == ntohs(ETH_P_TR_802_2)) { 257 else if (skb->protocol == htons(ETH_P_TR_802_2)) {
258 memcpy(sa, tr_hdr(skb)->saddr, ETH_ALEN); 258 memcpy(sa, tr_hdr(skb)->saddr, ETH_ALEN);
259 *sa &= 0x7F; 259 *sa &= 0x7F;
260 } 260 }
@@ -269,9 +269,9 @@ static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa)
269 */ 269 */
270static inline void llc_pdu_decode_da(struct sk_buff *skb, u8 *da) 270static inline void llc_pdu_decode_da(struct sk_buff *skb, u8 *da)
271{ 271{
272 if (skb->protocol == ntohs(ETH_P_802_2)) 272 if (skb->protocol == htons(ETH_P_802_2))
273 memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN); 273 memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN);
274 else if (skb->protocol == ntohs(ETH_P_TR_802_2)) 274 else if (skb->protocol == htons(ETH_P_TR_802_2))
275 memcpy(da, tr_hdr(skb)->daddr, ETH_ALEN); 275 memcpy(da, tr_hdr(skb)->daddr, ETH_ALEN);
276} 276}
277 277
@@ -345,7 +345,7 @@ static inline void llc_pdu_init_as_test_rsp(struct sk_buff *skb,
345 pdu->ctrl_1 = LLC_PDU_TYPE_U; 345 pdu->ctrl_1 = LLC_PDU_TYPE_U;
346 pdu->ctrl_1 |= LLC_1_PDU_CMD_TEST; 346 pdu->ctrl_1 |= LLC_1_PDU_CMD_TEST;
347 pdu->ctrl_1 |= LLC_U_PF_BIT_MASK; 347 pdu->ctrl_1 |= LLC_U_PF_BIT_MASK;
348 if (ev_skb->protocol == ntohs(ETH_P_802_2)) { 348 if (ev_skb->protocol == htons(ETH_P_802_2)) {
349 struct llc_pdu_un *ev_pdu = llc_pdu_un_hdr(ev_skb); 349 struct llc_pdu_un *ev_pdu = llc_pdu_un_hdr(ev_skb);
350 int dsize; 350 int dsize;
351 351
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index d3915dabe6de..475b10c575b3 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -66,8 +66,8 @@ struct rs_msg {
66 66
67struct ra_msg { 67struct ra_msg {
68 struct icmp6hdr icmph; 68 struct icmp6hdr icmph;
69 __u32 reachable_time; 69 __be32 reachable_time;
70 __u32 retrans_timer; 70 __be32 retrans_timer;
71}; 71};
72 72
73struct nd_opt_hdr { 73struct nd_opt_hdr {
diff --git a/include/net/netfilter/ipv4/nf_conntrack_ipv4.h b/include/net/netfilter/ipv4/nf_conntrack_ipv4.h
index 91684436af8e..1401ccc051c4 100644
--- a/include/net/netfilter/ipv4/nf_conntrack_ipv4.h
+++ b/include/net/netfilter/ipv4/nf_conntrack_ipv4.h
@@ -9,32 +9,35 @@
9#ifndef _NF_CONNTRACK_IPV4_H 9#ifndef _NF_CONNTRACK_IPV4_H
10#define _NF_CONNTRACK_IPV4_H 10#define _NF_CONNTRACK_IPV4_H
11 11
12#ifdef CONFIG_IP_NF_NAT_NEEDED 12#ifdef CONFIG_NF_NAT_NEEDED
13#include <linux/netfilter_ipv4/ip_nat.h> 13#include <net/netfilter/nf_nat.h>
14#include <linux/netfilter/nf_conntrack_pptp.h>
14 15
15/* per conntrack: nat application helper private data */ 16/* per conntrack: nat application helper private data */
16union ip_conntrack_nat_help { 17union nf_conntrack_nat_help {
17 /* insert nat helper private data here */ 18 /* insert nat helper private data here */
19 struct nf_nat_pptp nat_pptp_info;
18}; 20};
19 21
20struct nf_conntrack_ipv4_nat { 22struct nf_conn_nat {
21 struct ip_nat_info info; 23 struct nf_nat_info info;
22 union ip_conntrack_nat_help help; 24 union nf_conntrack_nat_help help;
23#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ 25#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
24 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) 26 defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE)
25 int masq_index; 27 int masq_index;
26#endif 28#endif
27}; 29};
28#endif /* CONFIG_IP_NF_NAT_NEEDED */ 30#endif /* CONFIG_NF_NAT_NEEDED */
29
30struct nf_conntrack_ipv4 {
31#ifdef CONFIG_IP_NF_NAT_NEEDED
32 struct nf_conntrack_ipv4_nat *nat;
33#endif
34};
35 31
36/* Returns new sk_buff, or NULL */ 32/* Returns new sk_buff, or NULL */
37struct sk_buff * 33struct sk_buff *
38nf_ct_ipv4_ct_gather_frags(struct sk_buff *skb); 34nf_ct_ipv4_ct_gather_frags(struct sk_buff *skb);
39 35
36extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4;
37extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4;
38extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp;
39
40extern int nf_conntrack_ipv4_compat_init(void);
41extern void nf_conntrack_ipv4_compat_fini(void);
42
40#endif /*_NF_CONNTRACK_IPV4_H*/ 43#endif /*_NF_CONNTRACK_IPV4_H*/
diff --git a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
new file mode 100644
index 000000000000..b4b6049e01fa
--- /dev/null
+++ b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
@@ -0,0 +1,25 @@
1#ifndef _NF_CONNTRACK_IPV6_H
2#define _NF_CONNTRACK_IPV6_H
3
4extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
5
6extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6;
7extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6;
8extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6;
9
10extern int nf_ct_ipv6_skip_exthdr(struct sk_buff *skb, int start,
11 u8 *nexthdrp, int len);
12
13extern int nf_ct_frag6_init(void);
14extern void nf_ct_frag6_cleanup(void);
15extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb);
16extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
17 struct net_device *in,
18 struct net_device *out,
19 int (*okfn)(struct sk_buff *));
20
21extern unsigned int nf_ct_frag6_timeout;
22extern unsigned int nf_ct_frag6_low_thresh;
23extern unsigned int nf_ct_frag6_high_thresh;
24
25#endif /* _NF_CONNTRACK_IPV6_H*/
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 1fbd8193d5f1..032b36a0e378 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -21,6 +21,7 @@
21 21
22#include <linux/netfilter/nf_conntrack_tcp.h> 22#include <linux/netfilter/nf_conntrack_tcp.h>
23#include <linux/netfilter/nf_conntrack_sctp.h> 23#include <linux/netfilter/nf_conntrack_sctp.h>
24#include <linux/netfilter/nf_conntrack_proto_gre.h>
24#include <net/netfilter/ipv4/nf_conntrack_icmp.h> 25#include <net/netfilter/ipv4/nf_conntrack_icmp.h>
25#include <net/netfilter/ipv6/nf_conntrack_icmpv6.h> 26#include <net/netfilter/ipv6/nf_conntrack_icmpv6.h>
26 27
@@ -33,6 +34,7 @@ union nf_conntrack_proto {
33 struct ip_ct_tcp tcp; 34 struct ip_ct_tcp tcp;
34 struct ip_ct_icmp icmp; 35 struct ip_ct_icmp icmp;
35 struct nf_ct_icmpv6 icmpv6; 36 struct nf_ct_icmpv6 icmpv6;
37 struct nf_ct_gre gre;
36}; 38};
37 39
38union nf_conntrack_expect_proto { 40union nf_conntrack_expect_proto {
@@ -41,11 +43,15 @@ union nf_conntrack_expect_proto {
41 43
42/* Add protocol helper include file here */ 44/* Add protocol helper include file here */
43#include <linux/netfilter/nf_conntrack_ftp.h> 45#include <linux/netfilter/nf_conntrack_ftp.h>
46#include <linux/netfilter/nf_conntrack_pptp.h>
47#include <linux/netfilter/nf_conntrack_h323.h>
44 48
45/* per conntrack: application helper private data */ 49/* per conntrack: application helper private data */
46union nf_conntrack_help { 50union nf_conntrack_help {
47 /* insert conntrack helper private data (master) here */ 51 /* insert conntrack helper private data (master) here */
48 struct ip_ct_ftp_master ct_ftp_info; 52 struct nf_ct_ftp_master ct_ftp_info;
53 struct nf_ct_pptp_master ct_pptp_info;
54 struct nf_ct_h323_master ct_h323_info;
49}; 55};
50 56
51#include <linux/types.h> 57#include <linux/types.h>
@@ -79,6 +85,8 @@ struct nf_conn_help {
79 85
80 86
81#include <net/netfilter/ipv4/nf_conntrack_ipv4.h> 87#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
88#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
89
82struct nf_conn 90struct nf_conn
83{ 91{
84 /* Usage count in here is 1 for hash table/destruct timer, 1 per skb, 92 /* Usage count in here is 1 for hash table/destruct timer, 1 per skb,
@@ -124,44 +132,6 @@ struct nf_conn
124 char data[0]; 132 char data[0];
125}; 133};
126 134
127struct nf_conntrack_expect
128{
129 /* Internal linked list (global expectation list) */
130 struct list_head list;
131
132 /* We expect this tuple, with the following mask */
133 struct nf_conntrack_tuple tuple, mask;
134
135 /* Function to call after setup and insertion */
136 void (*expectfn)(struct nf_conn *new,
137 struct nf_conntrack_expect *this);
138
139 /* The conntrack of the master connection */
140 struct nf_conn *master;
141
142 /* Timer function; deletes the expectation. */
143 struct timer_list timeout;
144
145 /* Usage count. */
146 atomic_t use;
147
148 /* Unique ID */
149 unsigned int id;
150
151 /* Flags */
152 unsigned int flags;
153
154#ifdef CONFIG_NF_NAT_NEEDED
155 /* This is the original per-proto part, used to map the
156 * expected connection the way the recipient expects. */
157 union nf_conntrack_manip_proto saved_proto;
158 /* Direction relative to the master connection. */
159 enum ip_conntrack_dir dir;
160#endif
161};
162
163#define NF_CT_EXPECT_PERMANENT 0x1
164
165static inline struct nf_conn * 135static inline struct nf_conn *
166nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash) 136nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash)
167{ 137{
@@ -208,16 +178,6 @@ __nf_conntrack_find(const struct nf_conntrack_tuple *tuple,
208 178
209extern void nf_conntrack_hash_insert(struct nf_conn *ct); 179extern void nf_conntrack_hash_insert(struct nf_conn *ct);
210 180
211extern struct nf_conntrack_expect *
212__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);
213
214extern struct nf_conntrack_expect *
215nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);
216
217extern void nf_ct_unlink_expect(struct nf_conntrack_expect *exp);
218
219extern void nf_ct_remove_expectations(struct nf_conn *ct);
220
221extern void nf_conntrack_flush(void); 181extern void nf_conntrack_flush(void);
222 182
223extern struct nf_conntrack_helper * 183extern struct nf_conntrack_helper *
@@ -289,89 +249,12 @@ static inline int nf_ct_is_dying(struct nf_conn *ct)
289 249
290extern unsigned int nf_conntrack_htable_size; 250extern unsigned int nf_conntrack_htable_size;
291extern int nf_conntrack_checksum; 251extern int nf_conntrack_checksum;
252extern atomic_t nf_conntrack_count;
253extern int nf_conntrack_max;
292 254
255DECLARE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat);
293#define NF_CT_STAT_INC(count) (__get_cpu_var(nf_conntrack_stat).count++) 256#define NF_CT_STAT_INC(count) (__get_cpu_var(nf_conntrack_stat).count++)
294 257
295#ifdef CONFIG_NF_CONNTRACK_EVENTS
296#include <linux/notifier.h>
297#include <linux/interrupt.h>
298
299struct nf_conntrack_ecache {
300 struct nf_conn *ct;
301 unsigned int events;
302};
303DECLARE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache);
304
305#define CONNTRACK_ECACHE(x) (__get_cpu_var(nf_conntrack_ecache).x)
306
307extern struct atomic_notifier_head nf_conntrack_chain;
308extern struct atomic_notifier_head nf_conntrack_expect_chain;
309
310static inline int nf_conntrack_register_notifier(struct notifier_block *nb)
311{
312 return atomic_notifier_chain_register(&nf_conntrack_chain, nb);
313}
314
315static inline int nf_conntrack_unregister_notifier(struct notifier_block *nb)
316{
317 return atomic_notifier_chain_unregister(&nf_conntrack_chain, nb);
318}
319
320static inline int
321nf_conntrack_expect_register_notifier(struct notifier_block *nb)
322{
323 return atomic_notifier_chain_register(&nf_conntrack_expect_chain, nb);
324}
325
326static inline int
327nf_conntrack_expect_unregister_notifier(struct notifier_block *nb)
328{
329 return atomic_notifier_chain_unregister(&nf_conntrack_expect_chain,
330 nb);
331}
332
333extern void nf_ct_deliver_cached_events(const struct nf_conn *ct);
334extern void __nf_ct_event_cache_init(struct nf_conn *ct);
335
336static inline void
337nf_conntrack_event_cache(enum ip_conntrack_events event,
338 const struct sk_buff *skb)
339{
340 struct nf_conn *ct = (struct nf_conn *)skb->nfct;
341 struct nf_conntrack_ecache *ecache;
342
343 local_bh_disable();
344 ecache = &__get_cpu_var(nf_conntrack_ecache);
345 if (ct != ecache->ct)
346 __nf_ct_event_cache_init(ct);
347 ecache->events |= event;
348 local_bh_enable();
349}
350
351static inline void nf_conntrack_event(enum ip_conntrack_events event,
352 struct nf_conn *ct)
353{
354 if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct))
355 atomic_notifier_call_chain(&nf_conntrack_chain, event, ct);
356}
357
358static inline void
359nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
360 struct nf_conntrack_expect *exp)
361{
362 atomic_notifier_call_chain(&nf_conntrack_expect_chain, event, exp);
363}
364#else /* CONFIG_NF_CONNTRACK_EVENTS */
365static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
366 const struct sk_buff *skb) {}
367static inline void nf_conntrack_event(enum ip_conntrack_events event,
368 struct nf_conn *ct) {}
369static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
370static inline void
371nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
372 struct nf_conntrack_expect *exp) {}
373#endif /* CONFIG_NF_CONNTRACK_EVENTS */
374
375/* no helper, no nat */ 258/* no helper, no nat */
376#define NF_CT_F_BASIC 0 259#define NF_CT_F_BASIC 0
377/* for helper */ 260/* for helper */
@@ -387,17 +270,45 @@ nf_conntrack_unregister_cache(u_int32_t features);
387 270
388/* valid combinations: 271/* valid combinations:
389 * basic: nf_conn, nf_conn .. nf_conn_help 272 * basic: nf_conn, nf_conn .. nf_conn_help
390 * nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat, nf_conn help 273 * nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat .. nf_conn help
391 */ 274 */
275#ifdef CONFIG_NF_NAT_NEEDED
276static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
277{
278 unsigned int offset = sizeof(struct nf_conn);
279
280 if (!(ct->features & NF_CT_F_NAT))
281 return NULL;
282
283 offset = ALIGN(offset, __alignof__(struct nf_conn_nat));
284 return (struct nf_conn_nat *) ((void *)ct + offset);
285}
286
392static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct) 287static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
393{ 288{
394 unsigned int offset = sizeof(struct nf_conn); 289 unsigned int offset = sizeof(struct nf_conn);
395 290
396 if (!(ct->features & NF_CT_F_HELP)) 291 if (!(ct->features & NF_CT_F_HELP))
397 return NULL; 292 return NULL;
293 if (ct->features & NF_CT_F_NAT) {
294 offset = ALIGN(offset, __alignof__(struct nf_conn_nat));
295 offset += sizeof(struct nf_conn_nat);
296 }
398 297
298 offset = ALIGN(offset, __alignof__(struct nf_conn_help));
399 return (struct nf_conn_help *) ((void *)ct + offset); 299 return (struct nf_conn_help *) ((void *)ct + offset);
400} 300}
301#else /* No NAT */
302static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
303{
304 unsigned int offset = sizeof(struct nf_conn);
305
306 if (!(ct->features & NF_CT_F_HELP))
307 return NULL;
401 308
309 offset = ALIGN(offset, __alignof__(struct nf_conn_help));
310 return (struct nf_conn_help *) ((void *)ct + offset);
311}
312#endif /* CONFIG_NF_NAT_NEEDED */
402#endif /* __KERNEL__ */ 313#endif /* __KERNEL__ */
403#endif /* _NF_CONNTRACK_H */ 314#endif /* _NF_CONNTRACK_H */
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index da254525a4ce..7fdc72c01356 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -13,6 +13,9 @@
13#define _NF_CONNTRACK_CORE_H 13#define _NF_CONNTRACK_CORE_H
14 14
15#include <linux/netfilter.h> 15#include <linux/netfilter.h>
16#include <net/netfilter/nf_conntrack_l3proto.h>
17#include <net/netfilter/nf_conntrack_l4proto.h>
18#include <net/netfilter/nf_conntrack_ecache.h>
16 19
17/* This header is used to share core functionality between the 20/* This header is used to share core functionality between the
18 standalone connection tracking module, and the compatibility layer's use 21 standalone connection tracking module, and the compatibility layer's use
@@ -29,7 +32,7 @@ extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf);
29/* Like above, but you already have conntrack read lock. */ 32/* Like above, but you already have conntrack read lock. */
30extern struct nf_conntrack_l3proto *__nf_ct_find_l3proto(u_int16_t l3proto); 33extern struct nf_conntrack_l3proto *__nf_ct_find_l3proto(u_int16_t l3proto);
31 34
32struct nf_conntrack_protocol; 35struct nf_conntrack_l4proto;
33 36
34extern int 37extern int
35nf_ct_get_tuple(const struct sk_buff *skb, 38nf_ct_get_tuple(const struct sk_buff *skb,
@@ -39,13 +42,13 @@ nf_ct_get_tuple(const struct sk_buff *skb,
39 u_int8_t protonum, 42 u_int8_t protonum,
40 struct nf_conntrack_tuple *tuple, 43 struct nf_conntrack_tuple *tuple,
41 const struct nf_conntrack_l3proto *l3proto, 44 const struct nf_conntrack_l3proto *l3proto,
42 const struct nf_conntrack_protocol *protocol); 45 const struct nf_conntrack_l4proto *l4proto);
43 46
44extern int 47extern int
45nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, 48nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
46 const struct nf_conntrack_tuple *orig, 49 const struct nf_conntrack_tuple *orig,
47 const struct nf_conntrack_l3proto *l3proto, 50 const struct nf_conntrack_l3proto *l3proto,
48 const struct nf_conntrack_protocol *protocol); 51 const struct nf_conntrack_l4proto *l4proto);
49 52
50/* Find a connection corresponding to a tuple. */ 53/* Find a connection corresponding to a tuple. */
51extern struct nf_conntrack_tuple_hash * 54extern struct nf_conntrack_tuple_hash *
@@ -70,7 +73,14 @@ static inline int nf_conntrack_confirm(struct sk_buff **pskb)
70 73
71extern void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb); 74extern void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb);
72 75
76int
77print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
78 struct nf_conntrack_l3proto *l3proto,
79 struct nf_conntrack_l4proto *proto);
80
73extern struct list_head *nf_conntrack_hash; 81extern struct list_head *nf_conntrack_hash;
74extern struct list_head nf_conntrack_expect_list; 82extern struct list_head nf_conntrack_expect_list;
75extern rwlock_t nf_conntrack_lock ; 83extern rwlock_t nf_conntrack_lock ;
84extern struct list_head unconfirmed;
85
76#endif /* _NF_CONNTRACK_CORE_H */ 86#endif /* _NF_CONNTRACK_CORE_H */
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
new file mode 100644
index 000000000000..b62a8a9ec9d8
--- /dev/null
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -0,0 +1,95 @@
1/*
2 * connection tracking event cache.
3 */
4
5#ifndef _NF_CONNTRACK_ECACHE_H
6#define _NF_CONNTRACK_ECACHE_H
7#include <net/netfilter/nf_conntrack.h>
8
9#include <linux/notifier.h>
10#include <linux/interrupt.h>
11#include <net/netfilter/nf_conntrack_expect.h>
12
13#ifdef CONFIG_NF_CONNTRACK_EVENTS
14struct nf_conntrack_ecache {
15 struct nf_conn *ct;
16 unsigned int events;
17};
18DECLARE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache);
19
20#define CONNTRACK_ECACHE(x) (__get_cpu_var(nf_conntrack_ecache).x)
21
22extern struct atomic_notifier_head nf_conntrack_chain;
23extern struct atomic_notifier_head nf_conntrack_expect_chain;
24
25static inline int nf_conntrack_register_notifier(struct notifier_block *nb)
26{
27 return atomic_notifier_chain_register(&nf_conntrack_chain, nb);
28}
29
30static inline int nf_conntrack_unregister_notifier(struct notifier_block *nb)
31{
32 return atomic_notifier_chain_unregister(&nf_conntrack_chain, nb);
33}
34
35static inline int
36nf_conntrack_expect_register_notifier(struct notifier_block *nb)
37{
38 return atomic_notifier_chain_register(&nf_conntrack_expect_chain, nb);
39}
40
41static inline int
42nf_conntrack_expect_unregister_notifier(struct notifier_block *nb)
43{
44 return atomic_notifier_chain_unregister(&nf_conntrack_expect_chain,
45 nb);
46}
47
48extern void nf_ct_deliver_cached_events(const struct nf_conn *ct);
49extern void __nf_ct_event_cache_init(struct nf_conn *ct);
50extern void nf_ct_event_cache_flush(void);
51
52static inline void
53nf_conntrack_event_cache(enum ip_conntrack_events event,
54 const struct sk_buff *skb)
55{
56 struct nf_conn *ct = (struct nf_conn *)skb->nfct;
57 struct nf_conntrack_ecache *ecache;
58
59 local_bh_disable();
60 ecache = &__get_cpu_var(nf_conntrack_ecache);
61 if (ct != ecache->ct)
62 __nf_ct_event_cache_init(ct);
63 ecache->events |= event;
64 local_bh_enable();
65}
66
67static inline void nf_conntrack_event(enum ip_conntrack_events event,
68 struct nf_conn *ct)
69{
70 if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct))
71 atomic_notifier_call_chain(&nf_conntrack_chain, event, ct);
72}
73
74static inline void
75nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
76 struct nf_conntrack_expect *exp)
77{
78 atomic_notifier_call_chain(&nf_conntrack_expect_chain, event, exp);
79}
80
81#else /* CONFIG_NF_CONNTRACK_EVENTS */
82
83static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
84 const struct sk_buff *skb) {}
85static inline void nf_conntrack_event(enum ip_conntrack_events event,
86 struct nf_conn *ct) {}
87static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
88static inline void
89nf_conntrack_expect_event(enum ip_conntrack_expect_events event,
90 struct nf_conntrack_expect *exp) {}
91static inline void nf_ct_event_cache_flush(void) {}
92#endif /* CONFIG_NF_CONNTRACK_EVENTS */
93
94#endif /*_NF_CONNTRACK_ECACHE_H*/
95
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
new file mode 100644
index 000000000000..cef3136e22a3
--- /dev/null
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -0,0 +1,80 @@
1/*
2 * connection tracking expectations.
3 */
4
5#ifndef _NF_CONNTRACK_EXPECT_H
6#define _NF_CONNTRACK_EXPECT_H
7#include <net/netfilter/nf_conntrack.h>
8
9extern struct list_head nf_conntrack_expect_list;
10extern kmem_cache_t *nf_conntrack_expect_cachep;
11extern struct file_operations exp_file_ops;
12
13struct nf_conntrack_expect
14{
15 /* Internal linked list (global expectation list) */
16 struct list_head list;
17
18 /* We expect this tuple, with the following mask */
19 struct nf_conntrack_tuple tuple, mask;
20
21 /* Function to call after setup and insertion */
22 void (*expectfn)(struct nf_conn *new,
23 struct nf_conntrack_expect *this);
24
25 /* Helper to assign to new connection */
26 struct nf_conntrack_helper *helper;
27
28 /* The conntrack of the master connection */
29 struct nf_conn *master;
30
31 /* Timer function; deletes the expectation. */
32 struct timer_list timeout;
33
34 /* Usage count. */
35 atomic_t use;
36
37 /* Unique ID */
38 unsigned int id;
39
40 /* Flags */
41 unsigned int flags;
42
43#ifdef CONFIG_NF_NAT_NEEDED
44 __be32 saved_ip;
45 /* This is the original per-proto part, used to map the
46 * expected connection the way the recipient expects. */
47 union nf_conntrack_man_proto saved_proto;
48 /* Direction relative to the master connection. */
49 enum ip_conntrack_dir dir;
50#endif
51};
52
53#define NF_CT_EXPECT_PERMANENT 0x1
54
55
56struct nf_conntrack_expect *
57__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);
58
59struct nf_conntrack_expect *
60nf_conntrack_expect_find_get(const struct nf_conntrack_tuple *tuple);
61
62struct nf_conntrack_expect *
63find_expectation(const struct nf_conntrack_tuple *tuple);
64
65void nf_ct_unlink_expect(struct nf_conntrack_expect *exp);
66void nf_ct_remove_expectations(struct nf_conn *ct);
67void nf_conntrack_unexpect_related(struct nf_conntrack_expect *exp);
68
69/* Allocate space for an expectation: this is mandatory before calling
70 nf_conntrack_expect_related. You will have to call put afterwards. */
71struct nf_conntrack_expect *nf_conntrack_expect_alloc(struct nf_conn *me);
72void nf_conntrack_expect_init(struct nf_conntrack_expect *, int,
73 union nf_conntrack_address *,
74 union nf_conntrack_address *,
75 u_int8_t, __be16 *, __be16 *);
76void nf_conntrack_expect_put(struct nf_conntrack_expect *exp);
77int nf_conntrack_expect_related(struct nf_conntrack_expect *expect);
78
79#endif /*_NF_CONNTRACK_EXPECT_H*/
80
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
index 86ec8174ad02..8c72ac9f0ab8 100644
--- a/include/net/netfilter/nf_conntrack_helper.h
+++ b/include/net/netfilter/nf_conntrack_helper.h
@@ -34,20 +34,22 @@ struct nf_conntrack_helper
34 struct nf_conn *ct, 34 struct nf_conn *ct,
35 enum ip_conntrack_info conntrackinfo); 35 enum ip_conntrack_info conntrackinfo);
36 36
37 void (*destroy)(struct nf_conn *ct);
38
37 int (*to_nfattr)(struct sk_buff *skb, const struct nf_conn *ct); 39 int (*to_nfattr)(struct sk_buff *skb, const struct nf_conn *ct);
38}; 40};
39 41
40extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); 42extern struct nf_conntrack_helper *
41extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *); 43__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple);
42 44
43/* Allocate space for an expectation: this is mandatory before calling 45extern struct nf_conntrack_helper *
44 nf_conntrack_expect_related. You will have to call put afterwards. */ 46nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple);
45extern struct nf_conntrack_expect *
46nf_conntrack_expect_alloc(struct nf_conn *master);
47extern void nf_conntrack_expect_put(struct nf_conntrack_expect *exp);
48 47
49/* Add an expected connection: can have more than one per connection */ 48extern struct nf_conntrack_helper *
50extern int nf_conntrack_expect_related(struct nf_conntrack_expect *exp); 49__nf_conntrack_helper_find_byname(const char *name);
51extern void nf_conntrack_unexpect_related(struct nf_conntrack_expect *exp); 50
51extern void nf_ct_helper_put(struct nf_conntrack_helper *helper);
52extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
53extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
52 54
53#endif /*_NF_CONNTRACK_HELPER_H*/ 55#endif /*_NF_CONNTRACK_HELPER_H*/
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index dac43b15a5b0..664ddcffe00d 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -18,9 +18,6 @@ struct nfattr;
18 18
19struct nf_conntrack_l3proto 19struct nf_conntrack_l3proto
20{ 20{
21 /* Next pointer. */
22 struct list_head list;
23
24 /* L3 Protocol Family number. ex) PF_INET */ 21 /* L3 Protocol Family number. ex) PF_INET */
25 u_int16_t l3proto; 22 u_int16_t l3proto;
26 23
@@ -78,6 +75,12 @@ struct nf_conntrack_l3proto
78 int (*nfattr_to_tuple)(struct nfattr *tb[], 75 int (*nfattr_to_tuple)(struct nfattr *tb[],
79 struct nf_conntrack_tuple *t); 76 struct nf_conntrack_tuple *t);
80 77
78#ifdef CONFIG_SYSCTL
79 struct ctl_table_header *ctl_table_header;
80 struct ctl_table *ctl_table_path;
81 struct ctl_table *ctl_table;
82#endif /* CONFIG_SYSCTL */
83
81 /* Module (if any) which this is connected to. */ 84 /* Module (if any) which this is connected to. */
82 struct module *me; 85 struct module *me;
83}; 86};
@@ -86,7 +89,7 @@ extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX];
86 89
87/* Protocol registration. */ 90/* Protocol registration. */
88extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); 91extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
89extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto); 92extern int nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);
90 93
91extern struct nf_conntrack_l3proto * 94extern struct nf_conntrack_l3proto *
92nf_ct_l3proto_find_get(u_int16_t l3proto); 95nf_ct_l3proto_find_get(u_int16_t l3proto);
@@ -96,13 +99,13 @@ extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p);
96/* Existing built-in protocols */ 99/* Existing built-in protocols */
97extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4; 100extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
98extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6; 101extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
99extern struct nf_conntrack_l3proto nf_conntrack_generic_l3proto; 102extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic;
100 103
101static inline struct nf_conntrack_l3proto * 104static inline struct nf_conntrack_l3proto *
102__nf_ct_l3proto_find(u_int16_t l3proto) 105__nf_ct_l3proto_find(u_int16_t l3proto)
103{ 106{
104 if (unlikely(l3proto >= AF_MAX)) 107 if (unlikely(l3proto >= AF_MAX))
105 return &nf_conntrack_generic_l3proto; 108 return &nf_conntrack_l3proto_generic;
106 return nf_ct_l3protos[l3proto]; 109 return nf_ct_l3protos[l3proto];
107} 110}
108 111
diff --git a/include/net/netfilter/nf_conntrack_protocol.h b/include/net/netfilter/nf_conntrack_l4proto.h
index 1f33737fcea5..fc8af08ff542 100644
--- a/include/net/netfilter/nf_conntrack_protocol.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Header for use in defining a given protocol for connection tracking. 2 * Header for use in defining a given L4 protocol for connection tracking.
3 * 3 *
4 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> 4 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
5 * - generalized L3 protocol dependent part. 5 * - generalized L3 protocol dependent part.
@@ -7,23 +7,20 @@
7 * Derived from include/linux/netfiter_ipv4/ip_conntrack_protcol.h 7 * Derived from include/linux/netfiter_ipv4/ip_conntrack_protcol.h
8 */ 8 */
9 9
10#ifndef _NF_CONNTRACK_PROTOCOL_H 10#ifndef _NF_CONNTRACK_L4PROTO_H
11#define _NF_CONNTRACK_PROTOCOL_H 11#define _NF_CONNTRACK_L4PROTO_H
12#include <net/netfilter/nf_conntrack.h> 12#include <net/netfilter/nf_conntrack.h>
13 13
14struct seq_file; 14struct seq_file;
15struct nfattr; 15struct nfattr;
16 16
17struct nf_conntrack_protocol 17struct nf_conntrack_l4proto
18{ 18{
19 /* Next pointer. */
20 struct list_head list;
21
22 /* L3 Protocol number. */ 19 /* L3 Protocol number. */
23 u_int16_t l3proto; 20 u_int16_t l3proto;
24 21
25 /* Protocol number. */ 22 /* L4 Protocol number. */
26 u_int8_t proto; 23 u_int8_t l4proto;
27 24
28 /* Protocol name */ 25 /* Protocol name */
29 const char *name; 26 const char *name;
@@ -79,30 +76,40 @@ struct nf_conntrack_protocol
79 int (*nfattr_to_tuple)(struct nfattr *tb[], 76 int (*nfattr_to_tuple)(struct nfattr *tb[],
80 struct nf_conntrack_tuple *t); 77 struct nf_conntrack_tuple *t);
81 78
79#ifdef CONFIG_SYSCTL
80 struct ctl_table_header **ctl_table_header;
81 struct ctl_table *ctl_table;
82 unsigned int *ctl_table_users;
83#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
84 struct ctl_table_header *ctl_compat_table_header;
85 struct ctl_table *ctl_compat_table;
86#endif
87#endif
88
82 /* Module (if any) which this is connected to. */ 89 /* Module (if any) which this is connected to. */
83 struct module *me; 90 struct module *me;
84}; 91};
85 92
86/* Existing built-in protocols */ 93/* Existing built-in protocols */
87extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp6; 94extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6;
88extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4; 95extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4;
89extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6; 96extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6;
90extern struct nf_conntrack_protocol nf_conntrack_generic_protocol; 97extern struct nf_conntrack_l4proto nf_conntrack_l4proto_generic;
91 98
92#define MAX_NF_CT_PROTO 256 99#define MAX_NF_CT_PROTO 256
93extern struct nf_conntrack_protocol **nf_ct_protos[PF_MAX]; 100extern struct nf_conntrack_l4proto **nf_ct_protos[PF_MAX];
94 101
95extern struct nf_conntrack_protocol * 102extern struct nf_conntrack_l4proto *
96__nf_ct_proto_find(u_int16_t l3proto, u_int8_t protocol); 103__nf_ct_l4proto_find(u_int16_t l3proto, u_int8_t l4proto);
97 104
98extern struct nf_conntrack_protocol * 105extern struct nf_conntrack_l4proto *
99nf_ct_proto_find_get(u_int16_t l3proto, u_int8_t protocol); 106nf_ct_l4proto_find_get(u_int16_t l3proto, u_int8_t protocol);
100 107
101extern void nf_ct_proto_put(struct nf_conntrack_protocol *p); 108extern void nf_ct_l4proto_put(struct nf_conntrack_l4proto *p);
102 109
103/* Protocol registration. */ 110/* Protocol registration. */
104extern int nf_conntrack_protocol_register(struct nf_conntrack_protocol *proto); 111extern int nf_conntrack_l4proto_register(struct nf_conntrack_l4proto *proto);
105extern void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol *proto); 112extern int nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *proto);
106 113
107/* Generic netlink helpers */ 114/* Generic netlink helpers */
108extern int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb, 115extern int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb,
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h
index 530ef1f75283..5d72b16e876f 100644
--- a/include/net/netfilter/nf_conntrack_tuple.h
+++ b/include/net/netfilter/nf_conntrack_tuple.h
@@ -24,10 +24,10 @@
24 24
25/* The l3 protocol-specific manipulable parts of the tuple: always in 25/* The l3 protocol-specific manipulable parts of the tuple: always in
26 network order! */ 26 network order! */
27union nf_conntrack_man_l3proto { 27union nf_conntrack_address {
28 u_int32_t all[NF_CT_TUPLE_L3SIZE]; 28 u_int32_t all[NF_CT_TUPLE_L3SIZE];
29 u_int32_t ip; 29 __be32 ip;
30 u_int32_t ip6[4]; 30 __be32 ip6[4];
31}; 31};
32 32
33/* The protocol-specific manipulable parts of the tuple: always in 33/* The protocol-specific manipulable parts of the tuple: always in
@@ -38,23 +38,26 @@ union nf_conntrack_man_proto
38 u_int16_t all; 38 u_int16_t all;
39 39
40 struct { 40 struct {
41 u_int16_t port; 41 __be16 port;
42 } tcp; 42 } tcp;
43 struct { 43 struct {
44 u_int16_t port; 44 __be16 port;
45 } udp; 45 } udp;
46 struct { 46 struct {
47 u_int16_t id; 47 __be16 id;
48 } icmp; 48 } icmp;
49 struct { 49 struct {
50 u_int16_t port; 50 __be16 port;
51 } sctp; 51 } sctp;
52 struct {
53 __be16 key; /* GRE key is 32bit, PPtP only uses 16bit */
54 } gre;
52}; 55};
53 56
54/* The manipulable part of the tuple. */ 57/* The manipulable part of the tuple. */
55struct nf_conntrack_man 58struct nf_conntrack_man
56{ 59{
57 union nf_conntrack_man_l3proto u3; 60 union nf_conntrack_address u3;
58 union nf_conntrack_man_proto u; 61 union nf_conntrack_man_proto u;
59 /* Layer 3 protocol */ 62 /* Layer 3 protocol */
60 u_int16_t l3num; 63 u_int16_t l3num;
@@ -67,27 +70,26 @@ struct nf_conntrack_tuple
67 70
68 /* These are the parts of the tuple which are fixed. */ 71 /* These are the parts of the tuple which are fixed. */
69 struct { 72 struct {
70 union { 73 union nf_conntrack_address u3;
71 u_int32_t all[NF_CT_TUPLE_L3SIZE];
72 u_int32_t ip;
73 u_int32_t ip6[4];
74 } u3;
75 union { 74 union {
76 /* Add other protocols here. */ 75 /* Add other protocols here. */
77 u_int16_t all; 76 u_int16_t all;
78 77
79 struct { 78 struct {
80 u_int16_t port; 79 __be16 port;
81 } tcp; 80 } tcp;
82 struct { 81 struct {
83 u_int16_t port; 82 __be16 port;
84 } udp; 83 } udp;
85 struct { 84 struct {
86 u_int8_t type, code; 85 u_int8_t type, code;
87 } icmp; 86 } icmp;
88 struct { 87 struct {
89 u_int16_t port; 88 __be16 port;
90 } sctp; 89 } sctp;
90 struct {
91 __be16 key;
92 } gre;
91 } u; 93 } u;
92 94
93 /* The protocol. */ 95 /* The protocol. */
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h
new file mode 100644
index 000000000000..61c62068ca6b
--- /dev/null
+++ b/include/net/netfilter/nf_nat.h
@@ -0,0 +1,77 @@
1#ifndef _NF_NAT_H
2#define _NF_NAT_H
3#include <linux/netfilter_ipv4.h>
4#include <net/netfilter/nf_conntrack_tuple.h>
5
6#define NF_NAT_MAPPING_TYPE_MAX_NAMELEN 16
7
8enum nf_nat_manip_type
9{
10 IP_NAT_MANIP_SRC,
11 IP_NAT_MANIP_DST
12};
13
14/* SRC manip occurs POST_ROUTING or LOCAL_IN */
15#define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING && (hooknum) != NF_IP_LOCAL_IN)
16
17#define IP_NAT_RANGE_MAP_IPS 1
18#define IP_NAT_RANGE_PROTO_SPECIFIED 2
19
20/* NAT sequence number modifications */
21struct nf_nat_seq {
22 /* position of the last TCP sequence number modification (if any) */
23 u_int32_t correction_pos;
24
25 /* sequence number offset before and after last modification */
26 int16_t offset_before, offset_after;
27};
28
29/* Single range specification. */
30struct nf_nat_range
31{
32 /* Set to OR of flags above. */
33 unsigned int flags;
34
35 /* Inclusive: network order. */
36 __be32 min_ip, max_ip;
37
38 /* Inclusive: network order */
39 union nf_conntrack_man_proto min, max;
40};
41
42/* For backwards compat: don't use in modern code. */
43struct nf_nat_multi_range_compat
44{
45 unsigned int rangesize; /* Must be 1. */
46
47 /* hangs off end. */
48 struct nf_nat_range range[1];
49};
50
51#ifdef __KERNEL__
52#include <linux/list.h>
53
54/* The structure embedded in the conntrack structure. */
55struct nf_nat_info
56{
57 struct list_head bysource;
58 struct nf_nat_seq seq[IP_CT_DIR_MAX];
59};
60
61struct nf_conn;
62
63/* Set up the info structure to map into this range. */
64extern unsigned int nf_nat_setup_info(struct nf_conn *ct,
65 const struct nf_nat_range *range,
66 unsigned int hooknum);
67
68/* Is this tuple already taken? (not by us)*/
69extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
70 const struct nf_conn *ignored_conntrack);
71
72extern int nf_nat_module_is_loaded;
73
74#else /* !__KERNEL__: iptables wants this to compile. */
75#define nf_nat_multi_range nf_nat_multi_range_compat
76#endif /*__KERNEL__*/
77#endif
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h
new file mode 100644
index 000000000000..9778ffa93440
--- /dev/null
+++ b/include/net/netfilter/nf_nat_core.h
@@ -0,0 +1,27 @@
1#ifndef _NF_NAT_CORE_H
2#define _NF_NAT_CORE_H
3#include <linux/list.h>
4#include <net/netfilter/nf_conntrack.h>
5
6/* This header used to share core functionality between the standalone
7 NAT module, and the compatibility layer's use of NAT for masquerading. */
8
9extern unsigned int nf_nat_packet(struct nf_conn *ct,
10 enum ip_conntrack_info ctinfo,
11 unsigned int hooknum,
12 struct sk_buff **pskb);
13
14extern int nf_nat_icmp_reply_translation(struct nf_conn *ct,
15 enum ip_conntrack_info ctinfo,
16 unsigned int hooknum,
17 struct sk_buff **pskb);
18
19static inline int nf_nat_initialized(struct nf_conn *ct,
20 enum nf_nat_manip_type manip)
21{
22 if (manip == IP_NAT_MANIP_SRC)
23 return test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
24 else
25 return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status);
26}
27#endif /* _NF_NAT_CORE_H */
diff --git a/include/net/netfilter/nf_nat_helper.h b/include/net/netfilter/nf_nat_helper.h
new file mode 100644
index 000000000000..ec98ecf95fc8
--- /dev/null
+++ b/include/net/netfilter/nf_nat_helper.h
@@ -0,0 +1,32 @@
1#ifndef _NF_NAT_HELPER_H
2#define _NF_NAT_HELPER_H
3/* NAT protocol helper routines. */
4
5#include <net/netfilter/nf_conntrack.h>
6
7struct sk_buff;
8
9/* These return true or false. */
10extern int nf_nat_mangle_tcp_packet(struct sk_buff **skb,
11 struct nf_conn *ct,
12 enum ip_conntrack_info ctinfo,
13 unsigned int match_offset,
14 unsigned int match_len,
15 const char *rep_buffer,
16 unsigned int rep_len);
17extern int nf_nat_mangle_udp_packet(struct sk_buff **skb,
18 struct nf_conn *ct,
19 enum ip_conntrack_info ctinfo,
20 unsigned int match_offset,
21 unsigned int match_len,
22 const char *rep_buffer,
23 unsigned int rep_len);
24extern int nf_nat_seq_adjust(struct sk_buff **pskb,
25 struct nf_conn *ct,
26 enum ip_conntrack_info ctinfo);
27
28/* Setup NAT on this expected conntrack so it follows master, but goes
29 * to port ct->master->saved_proto. */
30extern void nf_nat_follow_master(struct nf_conn *ct,
31 struct nf_conntrack_expect *this);
32#endif
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h
new file mode 100644
index 000000000000..a9ec5ef61468
--- /dev/null
+++ b/include/net/netfilter/nf_nat_protocol.h
@@ -0,0 +1,70 @@
1/* Header for use in defining a given protocol. */
2#ifndef _NF_NAT_PROTOCOL_H
3#define _NF_NAT_PROTOCOL_H
4#include <net/netfilter/nf_nat.h>
5#include <linux/netfilter/nfnetlink_conntrack.h>
6
7struct nf_nat_range;
8
9struct nf_nat_protocol
10{
11 /* Protocol name */
12 const char *name;
13
14 /* Protocol number. */
15 unsigned int protonum;
16
17 struct module *me;
18
19 /* Translate a packet to the target according to manip type.
20 Return true if succeeded. */
21 int (*manip_pkt)(struct sk_buff **pskb,
22 unsigned int iphdroff,
23 const struct nf_conntrack_tuple *tuple,
24 enum nf_nat_manip_type maniptype);
25
26 /* Is the manipable part of the tuple between min and max incl? */
27 int (*in_range)(const struct nf_conntrack_tuple *tuple,
28 enum nf_nat_manip_type maniptype,
29 const union nf_conntrack_man_proto *min,
30 const union nf_conntrack_man_proto *max);
31
32 /* Alter the per-proto part of the tuple (depending on
33 maniptype), to give a unique tuple in the given range if
34 possible; return false if not. Per-protocol part of tuple
35 is initialized to the incoming packet. */
36 int (*unique_tuple)(struct nf_conntrack_tuple *tuple,
37 const struct nf_nat_range *range,
38 enum nf_nat_manip_type maniptype,
39 const struct nf_conn *ct);
40
41 int (*range_to_nfattr)(struct sk_buff *skb,
42 const struct nf_nat_range *range);
43
44 int (*nfattr_to_range)(struct nfattr *tb[],
45 struct nf_nat_range *range);
46};
47
48/* Protocol registration. */
49extern int nf_nat_protocol_register(struct nf_nat_protocol *proto);
50extern void nf_nat_protocol_unregister(struct nf_nat_protocol *proto);
51
52extern struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol);
53extern void nf_nat_proto_put(struct nf_nat_protocol *proto);
54
55/* Built-in protocols. */
56extern struct nf_nat_protocol nf_nat_protocol_tcp;
57extern struct nf_nat_protocol nf_nat_protocol_udp;
58extern struct nf_nat_protocol nf_nat_protocol_icmp;
59extern struct nf_nat_protocol nf_nat_unknown_protocol;
60
61extern int init_protocols(void) __init;
62extern void cleanup_protocols(void);
63extern struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
64
65extern int nf_nat_port_range_to_nfattr(struct sk_buff *skb,
66 const struct nf_nat_range *range);
67extern int nf_nat_port_nfattr_to_range(struct nfattr *tb[],
68 struct nf_nat_range *range);
69
70#endif /*_NF_NAT_PROTO_H*/
diff --git a/include/net/netfilter/nf_nat_rule.h b/include/net/netfilter/nf_nat_rule.h
new file mode 100644
index 000000000000..f191c672bcc6
--- /dev/null
+++ b/include/net/netfilter/nf_nat_rule.h
@@ -0,0 +1,35 @@
1#ifndef _NF_NAT_RULE_H
2#define _NF_NAT_RULE_H
3#include <net/netfilter/nf_conntrack.h>
4#include <net/netfilter/nf_nat.h>
5#include <linux/netfilter_ipv4/ip_tables.h>
6
7/* Compatibility definitions for ipt_FOO modules */
8#define ip_nat_range nf_nat_range
9#define ip_conntrack_tuple nf_conntrack_tuple
10#define ip_conntrack_get nf_ct_get
11#define ip_conntrack nf_conn
12#define ip_nat_setup_info nf_nat_setup_info
13#define ip_nat_multi_range_compat nf_nat_multi_range_compat
14#define ip_ct_iterate_cleanup nf_ct_iterate_cleanup
15#define IP_NF_ASSERT NF_CT_ASSERT
16
17extern int nf_nat_rule_init(void) __init;
18extern void nf_nat_rule_cleanup(void);
19extern int nf_nat_rule_find(struct sk_buff **pskb,
20 unsigned int hooknum,
21 const struct net_device *in,
22 const struct net_device *out,
23 struct nf_conn *ct,
24 struct nf_nat_info *info);
25
26extern unsigned int
27alloc_null_binding(struct nf_conn *ct,
28 struct nf_nat_info *info,
29 unsigned int hooknum);
30
31extern unsigned int
32alloc_null_binding_confirmed(struct nf_conn *ct,
33 struct nf_nat_info *info,
34 unsigned int hooknum);
35#endif /* _NF_NAT_RULE_H */
diff --git a/include/net/netlabel.h b/include/net/netlabel.h
index 12c214b9eadf..83da7e1f0d3d 100644
--- a/include/net/netlabel.h
+++ b/include/net/netlabel.h
@@ -111,13 +111,34 @@ struct netlbl_lsm_cache {
111 void (*free) (const void *data); 111 void (*free) (const void *data);
112 void *data; 112 void *data;
113}; 113};
114/* The catmap bitmap field MUST be a power of two in length and large
115 * enough to hold at least 240 bits. Special care (i.e. check the code!)
116 * should be used when changing these values as the LSM implementation
117 * probably has functions which rely on the sizes of these types to speed
118 * processing. */
119#define NETLBL_CATMAP_MAPTYPE u64
120#define NETLBL_CATMAP_MAPCNT 4
121#define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8)
122#define NETLBL_CATMAP_SIZE (NETLBL_CATMAP_MAPSIZE * \
123 NETLBL_CATMAP_MAPCNT)
124#define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01
125struct netlbl_lsm_secattr_catmap {
126 u32 startbit;
127 NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT];
128 struct netlbl_lsm_secattr_catmap *next;
129};
130#define NETLBL_SECATTR_NONE 0x00000000
131#define NETLBL_SECATTR_DOMAIN 0x00000001
132#define NETLBL_SECATTR_CACHE 0x00000002
133#define NETLBL_SECATTR_MLS_LVL 0x00000004
134#define NETLBL_SECATTR_MLS_CAT 0x00000008
114struct netlbl_lsm_secattr { 135struct netlbl_lsm_secattr {
136 u32 flags;
137
115 char *domain; 138 char *domain;
116 139
117 u32 mls_lvl; 140 u32 mls_lvl;
118 u32 mls_lvl_vld; 141 struct netlbl_lsm_secattr_catmap *mls_cat;
119 unsigned char *mls_cat;
120 size_t mls_cat_len;
121 142
122 struct netlbl_lsm_cache *cache; 143 struct netlbl_lsm_cache *cache;
123}; 144};
@@ -165,18 +186,54 @@ static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache)
165} 186}
166 187
167/** 188/**
189 * netlbl_secattr_catmap_alloc - Allocate a LSM secattr catmap
190 * @flags: memory allocation flags
191 *
192 * Description:
193 * Allocate memory for a LSM secattr catmap, returns a pointer on success, NULL
194 * on failure.
195 *
196 */
197static inline struct netlbl_lsm_secattr_catmap *netlbl_secattr_catmap_alloc(
198 gfp_t flags)
199{
200 return kzalloc(sizeof(struct netlbl_lsm_secattr_catmap), flags);
201}
202
203/**
204 * netlbl_secattr_catmap_free - Free a LSM secattr catmap
205 * @catmap: the category bitmap
206 *
207 * Description:
208 * Free a LSM secattr catmap.
209 *
210 */
211static inline void netlbl_secattr_catmap_free(
212 struct netlbl_lsm_secattr_catmap *catmap)
213{
214 struct netlbl_lsm_secattr_catmap *iter;
215
216 do {
217 iter = catmap;
218 catmap = catmap->next;
219 kfree(iter);
220 } while (catmap);
221}
222
223/**
168 * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct 224 * netlbl_secattr_init - Initialize a netlbl_lsm_secattr struct
169 * @secattr: the struct to initialize 225 * @secattr: the struct to initialize
170 * 226 *
171 * Description: 227 * Description:
172 * Initialize an already allocated netlbl_lsm_secattr struct. Returns zero on 228 * Initialize an already allocated netlbl_lsm_secattr struct.
173 * success, negative values on error.
174 * 229 *
175 */ 230 */
176static inline int netlbl_secattr_init(struct netlbl_lsm_secattr *secattr) 231static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
177{ 232{
178 memset(secattr, 0, sizeof(*secattr)); 233 secattr->flags = 0;
179 return 0; 234 secattr->domain = NULL;
235 secattr->mls_cat = NULL;
236 secattr->cache = NULL;
180} 237}
181 238
182/** 239/**
@@ -193,7 +250,8 @@ static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
193 if (secattr->cache) 250 if (secattr->cache)
194 netlbl_secattr_cache_free(secattr->cache); 251 netlbl_secattr_cache_free(secattr->cache);
195 kfree(secattr->domain); 252 kfree(secattr->domain);
196 kfree(secattr->mls_cat); 253 if (secattr->mls_cat)
254 netlbl_secattr_catmap_free(secattr->mls_cat);
197} 255}
198 256
199/** 257/**
@@ -205,7 +263,7 @@ static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
205 * pointer on success, or NULL on failure. 263 * pointer on success, or NULL on failure.
206 * 264 *
207 */ 265 */
208static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc(int flags) 266static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc(gfp_t flags)
209{ 267{
210 return kzalloc(sizeof(struct netlbl_lsm_secattr), flags); 268 return kzalloc(sizeof(struct netlbl_lsm_secattr), flags);
211} 269}
@@ -224,6 +282,51 @@ static inline void netlbl_secattr_free(struct netlbl_lsm_secattr *secattr)
224 kfree(secattr); 282 kfree(secattr);
225} 283}
226 284
285#ifdef CONFIG_NETLABEL
286int netlbl_secattr_catmap_walk(struct netlbl_lsm_secattr_catmap *catmap,
287 u32 offset);
288int netlbl_secattr_catmap_walk_rng(struct netlbl_lsm_secattr_catmap *catmap,
289 u32 offset);
290int netlbl_secattr_catmap_setbit(struct netlbl_lsm_secattr_catmap *catmap,
291 u32 bit,
292 gfp_t flags);
293int netlbl_secattr_catmap_setrng(struct netlbl_lsm_secattr_catmap *catmap,
294 u32 start,
295 u32 end,
296 gfp_t flags);
297#else
298static inline int netlbl_secattr_catmap_walk(
299 struct netlbl_lsm_secattr_catmap *catmap,
300 u32 offset)
301{
302 return -ENOENT;
303}
304
305static inline int netlbl_secattr_catmap_walk_rng(
306 struct netlbl_lsm_secattr_catmap *catmap,
307 u32 offset)
308{
309 return -ENOENT;
310}
311
312static inline int netlbl_secattr_catmap_setbit(
313 struct netlbl_lsm_secattr_catmap *catmap,
314 u32 bit,
315 gfp_t flags)
316{
317 return 0;
318}
319
320static inline int netlbl_secattr_catmap_setrng(
321 struct netlbl_lsm_secattr_catmap *catmap,
322 u32 start,
323 u32 end,
324 gfp_t flags)
325{
326 return 0;
327}
328#endif
329
227/* 330/*
228 * LSM protocol operations 331 * LSM protocol operations
229 */ 332 */
diff --git a/include/net/netlink.h b/include/net/netlink.h
index ce5cba19c393..fd75fd65d59e 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -500,14 +500,15 @@ static inline struct nlmsghdr *nlmsg_put_answer(struct sk_buff *skb,
500 500
501/** 501/**
502 * nlmsg_new - Allocate a new netlink message 502 * nlmsg_new - Allocate a new netlink message
503 * @size: maximum size of message 503 * @payload: size of the message payload
504 * @flags: the type of memory to allocate. 504 * @flags: the type of memory to allocate.
505 * 505 *
506 * Use NLMSG_GOODSIZE if size isn't know and you need a good default size. 506 * Use NLMSG_DEFAULT_SIZE if the size of the payload isn't known
507 * and a good default is needed.
507 */ 508 */
508static inline struct sk_buff *nlmsg_new(int size, gfp_t flags) 509static inline struct sk_buff *nlmsg_new(size_t payload, gfp_t flags)
509{ 510{
510 return alloc_skb(size, flags); 511 return alloc_skb(nlmsg_total_size(payload), flags);
511} 512}
512 513
513/** 514/**
@@ -828,6 +829,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
828#define NLA_PUT_U16(skb, attrtype, value) \ 829#define NLA_PUT_U16(skb, attrtype, value) \
829 NLA_PUT_TYPE(skb, u16, attrtype, value) 830 NLA_PUT_TYPE(skb, u16, attrtype, value)
830 831
832#define NLA_PUT_LE16(skb, attrtype, value) \
833 NLA_PUT_TYPE(skb, __le16, attrtype, value)
834
831#define NLA_PUT_U32(skb, attrtype, value) \ 835#define NLA_PUT_U32(skb, attrtype, value) \
832 NLA_PUT_TYPE(skb, u32, attrtype, value) 836 NLA_PUT_TYPE(skb, u32, attrtype, value)
833 837
@@ -874,6 +878,15 @@ static inline u16 nla_get_u16(struct nlattr *nla)
874} 878}
875 879
876/** 880/**
881 * nla_get_le16 - return payload of __le16 attribute
882 * @nla: __le16 netlink attribute
883 */
884static inline __le16 nla_get_le16(struct nlattr *nla)
885{
886 return *(__le16 *) nla_data(nla);
887}
888
889/**
877 * nla_get_u8 - return payload of u8 attribute 890 * nla_get_u8 - return payload of u8 attribute
878 * @nla: u8 netlink attribute 891 * @nla: u8 netlink attribute
879 */ 892 */
diff --git a/include/net/protocol.h b/include/net/protocol.h
index c643bce64e55..105bf12b0c79 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -50,7 +50,7 @@ struct inet6_protocol
50 void (*err_handler)(struct sk_buff *skb, 50 void (*err_handler)(struct sk_buff *skb,
51 struct inet6_skb_parm *opt, 51 struct inet6_skb_parm *opt,
52 int type, int code, int offset, 52 int type, int code, int offset,
53 __u32 info); 53 __be32 info);
54 54
55 int (*gso_send_check)(struct sk_buff *skb); 55 int (*gso_send_check)(struct sk_buff *skb);
56 struct sk_buff *(*gso_segment)(struct sk_buff *skb, 56 struct sk_buff *(*gso_segment)(struct sk_buff *skb,
@@ -71,7 +71,7 @@ struct inet_protosw {
71 71
72 /* These two fields form the lookup key. */ 72 /* These two fields form the lookup key. */
73 unsigned short type; /* This is the 2nd argument to socket(2). */ 73 unsigned short type; /* This is the 2nd argument to socket(2). */
74 int protocol; /* This is the L4 protocol number. */ 74 unsigned short protocol; /* This is the L4 protocol number. */
75 75
76 struct proto *prot; 76 struct proto *prot;
77 const struct proto_ops *ops; 77 const struct proto_ops *ops;
diff --git a/include/net/rawv6.h b/include/net/rawv6.h
index 14476a71725e..af8960878ef4 100644
--- a/include/net/rawv6.h
+++ b/include/net/rawv6.h
@@ -21,7 +21,7 @@ extern void rawv6_err(struct sock *sk,
21 struct sk_buff *skb, 21 struct sk_buff *skb,
22 struct inet6_skb_parm *opt, 22 struct inet6_skb_parm *opt,
23 int type, int code, 23 int type, int code,
24 int offset, u32 info); 24 int offset, __be32 info);
25 25
26#endif 26#endif
27 27
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 8e165ca16bd8..e37baaf2080b 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -28,14 +28,15 @@ struct proto;
28 28
29struct request_sock_ops { 29struct request_sock_ops {
30 int family; 30 int family;
31 kmem_cache_t *slab;
32 int obj_size; 31 int obj_size;
32 kmem_cache_t *slab;
33 int (*rtx_syn_ack)(struct sock *sk, 33 int (*rtx_syn_ack)(struct sock *sk,
34 struct request_sock *req, 34 struct request_sock *req,
35 struct dst_entry *dst); 35 struct dst_entry *dst);
36 void (*send_ack)(struct sk_buff *skb, 36 void (*send_ack)(struct sk_buff *skb,
37 struct request_sock *req); 37 struct request_sock *req);
38 void (*send_reset)(struct sk_buff *skb); 38 void (*send_reset)(struct sock *sk,
39 struct sk_buff *skb);
39 void (*destructor)(struct request_sock *req); 40 void (*destructor)(struct request_sock *req);
40}; 41};
41 42
@@ -51,12 +52,13 @@ struct request_sock {
51 u32 rcv_wnd; /* rcv_wnd offered first time */ 52 u32 rcv_wnd; /* rcv_wnd offered first time */
52 u32 ts_recent; 53 u32 ts_recent;
53 unsigned long expires; 54 unsigned long expires;
54 struct request_sock_ops *rsk_ops; 55 const struct request_sock_ops *rsk_ops;
55 struct sock *sk; 56 struct sock *sk;
56 u32 secid; 57 u32 secid;
58 u32 peer_secid;
57}; 59};
58 60
59static inline struct request_sock *reqsk_alloc(struct request_sock_ops *ops) 61static inline struct request_sock *reqsk_alloc(const struct request_sock_ops *ops)
60{ 62{
61 struct request_sock *req = kmem_cache_alloc(ops->slab, SLAB_ATOMIC); 63 struct request_sock *req = kmem_cache_alloc(ops->slab, SLAB_ATOMIC);
62 64
@@ -120,7 +122,7 @@ struct request_sock_queue {
120}; 122};
121 123
122extern int reqsk_queue_alloc(struct request_sock_queue *queue, 124extern int reqsk_queue_alloc(struct request_sock_queue *queue,
123 const int nr_table_entries); 125 unsigned int nr_table_entries);
124 126
125static inline struct listen_sock *reqsk_queue_yank_listen_sk(struct request_sock_queue *queue) 127static inline struct listen_sock *reqsk_queue_yank_listen_sk(struct request_sock_queue *queue)
126{ 128{
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index b0e9108a4e18..82086392735a 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -60,6 +60,7 @@ struct Qdisc_class_ops
60 int (*graft)(struct Qdisc *, unsigned long cl, 60 int (*graft)(struct Qdisc *, unsigned long cl,
61 struct Qdisc *, struct Qdisc **); 61 struct Qdisc *, struct Qdisc **);
62 struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl); 62 struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl);
63 void (*qlen_notify)(struct Qdisc *, unsigned long);
63 64
64 /* Class manipulation routines */ 65 /* Class manipulation routines */
65 unsigned long (*get)(struct Qdisc *, u32 classid); 66 unsigned long (*get)(struct Qdisc *, u32 classid);
@@ -144,7 +145,7 @@ struct tcf_proto
144 void *root; 145 void *root;
145 int (*classify)(struct sk_buff*, struct tcf_proto*, 146 int (*classify)(struct sk_buff*, struct tcf_proto*,
146 struct tcf_result *); 147 struct tcf_result *);
147 u32 protocol; 148 __be16 protocol;
148 149
149 /* All the rest */ 150 /* All the rest */
150 u32 prio; 151 u32 prio;
@@ -172,9 +173,10 @@ extern void dev_activate(struct net_device *dev);
172extern void dev_deactivate(struct net_device *dev); 173extern void dev_deactivate(struct net_device *dev);
173extern void qdisc_reset(struct Qdisc *qdisc); 174extern void qdisc_reset(struct Qdisc *qdisc);
174extern void qdisc_destroy(struct Qdisc *qdisc); 175extern void qdisc_destroy(struct Qdisc *qdisc);
176extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n);
175extern struct Qdisc *qdisc_alloc(struct net_device *dev, struct Qdisc_ops *ops); 177extern struct Qdisc *qdisc_alloc(struct net_device *dev, struct Qdisc_ops *ops);
176extern struct Qdisc *qdisc_create_dflt(struct net_device *dev, 178extern struct Qdisc *qdisc_create_dflt(struct net_device *dev,
177 struct Qdisc_ops *ops); 179 struct Qdisc_ops *ops, u32 parentid);
178 180
179static inline void 181static inline void
180tcf_destroy(struct tcf_proto *tp) 182tcf_destroy(struct tcf_proto *tp)
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index 807d6f1ef4b5..6114c4f54b0a 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -116,9 +116,11 @@ typedef enum {
116typedef union { 116typedef union {
117 __s32 i32; 117 __s32 i32;
118 __u32 u32; 118 __u32 u32;
119 __be32 be32;
119 __u16 u16; 120 __u16 u16;
120 __u8 u8; 121 __u8 u8;
121 int error; 122 int error;
123 __be16 err;
122 sctp_state_t state; 124 sctp_state_t state;
123 sctp_event_timeout_t to; 125 sctp_event_timeout_t to;
124 unsigned long zero; 126 unsigned long zero;
@@ -164,9 +166,11 @@ SCTP_## name (type arg) \
164 166
165SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) 167SCTP_ARG_CONSTRUCTOR(I32, __s32, i32)
166SCTP_ARG_CONSTRUCTOR(U32, __u32, u32) 168SCTP_ARG_CONSTRUCTOR(U32, __u32, u32)
169SCTP_ARG_CONSTRUCTOR(BE32, __be32, be32)
167SCTP_ARG_CONSTRUCTOR(U16, __u16, u16) 170SCTP_ARG_CONSTRUCTOR(U16, __u16, u16)
168SCTP_ARG_CONSTRUCTOR(U8, __u8, u8) 171SCTP_ARG_CONSTRUCTOR(U8, __u8, u8)
169SCTP_ARG_CONSTRUCTOR(ERROR, int, error) 172SCTP_ARG_CONSTRUCTOR(ERROR, int, error)
173SCTP_ARG_CONSTRUCTOR(PERR, __be16, err) /* protocol error */
170SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state) 174SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state)
171SCTP_ARG_CONSTRUCTOR(TO, sctp_event_timeout_t, to) 175SCTP_ARG_CONSTRUCTOR(TO, sctp_event_timeout_t, to)
172SCTP_ARG_CONSTRUCTOR(PTR, void *, ptr) 176SCTP_ARG_CONSTRUCTOR(PTR, void *, ptr)
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index 6c632e26f72d..5ddb85599863 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -356,7 +356,7 @@ typedef enum {
356 * addresses. 356 * addresses.
357 */ 357 */
358#define IS_IPV4_UNUSABLE_ADDRESS(a) \ 358#define IS_IPV4_UNUSABLE_ADDRESS(a) \
359 ((INADDR_BROADCAST == *a) || \ 359 ((htonl(INADDR_BROADCAST) == *a) || \
360 (MULTICAST(*a)) || \ 360 (MULTICAST(*a)) || \
361 (((unsigned char *)(a))[0] == 0) || \ 361 (((unsigned char *)(a))[0] == 0) || \
362 ((((unsigned char *)(a))[0] == 198) && \ 362 ((((unsigned char *)(a))[0] == 198) && \
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 764e3af5be93..215461f18db1 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -585,7 +585,7 @@ static inline int ipver2af(__u8 ipver)
585} 585}
586 586
587/* Convert from an address parameter type to an address family. */ 587/* Convert from an address parameter type to an address family. */
588static inline int param_type2af(__u16 type) 588static inline int param_type2af(__be16 type)
589{ 589{
590 switch (type) { 590 switch (type) {
591 case SCTP_PARAM_IPV4_ADDRESS: 591 case SCTP_PARAM_IPV4_ADDRESS:
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index de313de4fefe..3269ed1cc222 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -213,7 +213,7 @@ struct sctp_chunk *sctp_make_shutdown_ack(const struct sctp_association *asoc,
213 const struct sctp_chunk *); 213 const struct sctp_chunk *);
214struct sctp_chunk *sctp_make_shutdown_complete(const struct sctp_association *, 214struct sctp_chunk *sctp_make_shutdown_complete(const struct sctp_association *,
215 const struct sctp_chunk *); 215 const struct sctp_chunk *);
216void sctp_init_cause(struct sctp_chunk *, __u16 cause, const void *, size_t); 216void sctp_init_cause(struct sctp_chunk *, __be16 cause, const void *, size_t);
217struct sctp_chunk *sctp_make_abort(const struct sctp_association *, 217struct sctp_chunk *sctp_make_abort(const struct sctp_association *,
218 const struct sctp_chunk *, 218 const struct sctp_chunk *,
219 const size_t hint); 219 const size_t hint);
@@ -236,14 +236,14 @@ struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *,
236 const size_t paylen); 236 const size_t paylen);
237struct sctp_chunk *sctp_make_op_error(const struct sctp_association *, 237struct sctp_chunk *sctp_make_op_error(const struct sctp_association *,
238 const struct sctp_chunk *chunk, 238 const struct sctp_chunk *chunk,
239 __u16 cause_code, 239 __be16 cause_code,
240 const void *payload, 240 const void *payload,
241 size_t paylen); 241 size_t paylen);
242 242
243struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *, 243struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *,
244 union sctp_addr *, 244 union sctp_addr *,
245 struct sockaddr *, 245 struct sockaddr *,
246 int, __u16); 246 int, __be16);
247struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc, 247struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
248 union sctp_addr *addr); 248 union sctp_addr *addr);
249struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc, 249struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 60b684470db8..c089f93ba591 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -537,7 +537,7 @@ struct sctp_af {
537 struct net_device *); 537 struct net_device *);
538 void (*dst_saddr) (union sctp_addr *saddr, 538 void (*dst_saddr) (union sctp_addr *saddr,
539 struct dst_entry *dst, 539 struct dst_entry *dst,
540 unsigned short port); 540 __be16 port);
541 int (*cmp_addr) (const union sctp_addr *addr1, 541 int (*cmp_addr) (const union sctp_addr *addr1,
542 const union sctp_addr *addr2); 542 const union sctp_addr *addr2);
543 void (*addr_copy) (union sctp_addr *dst, 543 void (*addr_copy) (union sctp_addr *dst,
@@ -553,14 +553,14 @@ struct sctp_af {
553 struct sock *sk); 553 struct sock *sk);
554 void (*from_addr_param) (union sctp_addr *, 554 void (*from_addr_param) (union sctp_addr *,
555 union sctp_addr_param *, 555 union sctp_addr_param *,
556 __u16 port, int iif); 556 __be16 port, int iif);
557 int (*to_addr_param) (const union sctp_addr *, 557 int (*to_addr_param) (const union sctp_addr *,
558 union sctp_addr_param *); 558 union sctp_addr_param *);
559 int (*addr_valid) (union sctp_addr *, 559 int (*addr_valid) (union sctp_addr *,
560 struct sctp_sock *, 560 struct sctp_sock *,
561 const struct sk_buff *); 561 const struct sk_buff *);
562 sctp_scope_t (*scope) (union sctp_addr *); 562 sctp_scope_t (*scope) (union sctp_addr *);
563 void (*inaddr_any) (union sctp_addr *, unsigned short); 563 void (*inaddr_any) (union sctp_addr *, __be16);
564 int (*is_any) (const union sctp_addr *); 564 int (*is_any) (const union sctp_addr *);
565 int (*available) (union sctp_addr *, 565 int (*available) (union sctp_addr *,
566 struct sctp_sock *); 566 struct sctp_sock *);
@@ -587,7 +587,7 @@ struct sctp_pf {
587 struct sctp_sock *); 587 struct sctp_sock *);
588 int (*bind_verify) (struct sctp_sock *, union sctp_addr *); 588 int (*bind_verify) (struct sctp_sock *, union sctp_addr *);
589 int (*send_verify) (struct sctp_sock *, union sctp_addr *); 589 int (*send_verify) (struct sctp_sock *, union sctp_addr *);
590 int (*supported_addrs)(const struct sctp_sock *, __u16 *); 590 int (*supported_addrs)(const struct sctp_sock *, __be16 *);
591 struct sock *(*create_accept_sk) (struct sock *sk, 591 struct sock *(*create_accept_sk) (struct sock *sk,
592 struct sctp_association *asoc); 592 struct sctp_association *asoc);
593 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *); 593 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
@@ -1270,7 +1270,7 @@ struct sctp_endpoint {
1270 * this here so we pre-allocate this once and can re-use 1270 * this here so we pre-allocate this once and can re-use
1271 * on every receive. 1271 * on every receive.
1272 */ 1272 */
1273 __u8 digest[SCTP_SIGNATURE_SIZE]; 1273 __u8 *digest;
1274 1274
1275 /* sendbuf acct. policy. */ 1275 /* sendbuf acct. policy. */
1276 __u32 sndbuf_policy; 1276 __u32 sndbuf_policy;
@@ -1314,6 +1314,13 @@ int sctp_process_init(struct sctp_association *, sctp_cid_t cid,
1314__u32 sctp_generate_tag(const struct sctp_endpoint *); 1314__u32 sctp_generate_tag(const struct sctp_endpoint *);
1315__u32 sctp_generate_tsn(const struct sctp_endpoint *); 1315__u32 sctp_generate_tsn(const struct sctp_endpoint *);
1316 1316
1317struct sctp_inithdr_host {
1318 __u32 init_tag;
1319 __u32 a_rwnd;
1320 __u16 num_outbound_streams;
1321 __u16 num_inbound_streams;
1322 __u32 initial_tsn;
1323};
1317 1324
1318/* RFC2960 1325/* RFC2960
1319 * 1326 *
@@ -1482,9 +1489,9 @@ struct sctp_association {
1482 /* This mask is used to disable sending the ASCONF chunk 1489 /* This mask is used to disable sending the ASCONF chunk
1483 * with specified parameter to peer. 1490 * with specified parameter to peer.
1484 */ 1491 */
1485 __u16 addip_disabled_mask; 1492 __be16 addip_disabled_mask;
1486 1493
1487 struct sctp_inithdr i; 1494 struct sctp_inithdr_host i;
1488 int cookie_len; 1495 int cookie_len;
1489 void *cookie; 1496 void *cookie;
1490 1497
diff --git a/include/net/sctp/tsnmap.h b/include/net/sctp/tsnmap.h
index 021947da70ea..70a824df6f60 100644
--- a/include/net/sctp/tsnmap.h
+++ b/include/net/sctp/tsnmap.h
@@ -105,7 +105,7 @@ struct sctp_tsnmap {
105 * every SACK. Store up to SCTP_MAX_DUP_TSNS worth of 105 * every SACK. Store up to SCTP_MAX_DUP_TSNS worth of
106 * information. 106 * information.
107 */ 107 */
108 __u32 dup_tsns[SCTP_MAX_DUP_TSNS]; 108 __be32 dup_tsns[SCTP_MAX_DUP_TSNS];
109 __u16 num_dup_tsns; 109 __u16 num_dup_tsns;
110 110
111 /* Record gap ack block information here. */ 111 /* Record gap ack block information here. */
@@ -162,7 +162,7 @@ static inline __u16 sctp_tsnmap_num_dups(struct sctp_tsnmap *map)
162} 162}
163 163
164/* Return pointer to duplicate tsn array as needed by SACK. */ 164/* Return pointer to duplicate tsn array as needed by SACK. */
165static inline __u32 *sctp_tsnmap_get_dups(struct sctp_tsnmap *map) 165static inline __be32 *sctp_tsnmap_get_dups(struct sctp_tsnmap *map)
166{ 166{
167 map->num_dup_tsns = 0; 167 map->num_dup_tsns = 0;
168 return map->dup_tsns; 168 return map->dup_tsns;
diff --git a/include/net/sock.h b/include/net/sock.h
index ac286a353032..26fc0b16bc0c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -745,7 +745,13 @@ static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
745 */ 745 */
746#define sock_owned_by_user(sk) ((sk)->sk_lock.owner) 746#define sock_owned_by_user(sk) ((sk)->sk_lock.owner)
747 747
748extern void FASTCALL(lock_sock(struct sock *sk)); 748extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass));
749
750static inline void lock_sock(struct sock *sk)
751{
752 lock_sock_nested(sk, 0);
753}
754
749extern void FASTCALL(release_sock(struct sock *sk)); 755extern void FASTCALL(release_sock(struct sock *sk));
750 756
751/* BH context may only use the following locking interface. */ 757/* BH context may only use the following locking interface. */
@@ -883,18 +889,23 @@ static inline int sk_filter(struct sock *sk, struct sk_buff *skb)
883} 889}
884 890
885/** 891/**
886 * sk_filter_release: Release a socket filter 892 * sk_filter_rcu_free: Free a socket filter
887 * @rcu: rcu_head that contains the sk_filter info to remove 893 * @rcu: rcu_head that contains the sk_filter to free
888 *
889 * Remove a filter from a socket and release its resources.
890 */ 894 */
891
892static inline void sk_filter_rcu_free(struct rcu_head *rcu) 895static inline void sk_filter_rcu_free(struct rcu_head *rcu)
893{ 896{
894 struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu); 897 struct sk_filter *fp = container_of(rcu, struct sk_filter, rcu);
895 kfree(fp); 898 kfree(fp);
896} 899}
897 900
901/**
902 * sk_filter_release: Release a socket filter
903 * @sk: socket
904 * @fp: filter to remove
905 *
906 * Remove a filter from a socket and release its resources.
907 */
908
898static inline void sk_filter_release(struct sock *sk, struct sk_filter *fp) 909static inline void sk_filter_release(struct sock *sk, struct sk_filter *fp)
899{ 910{
900 unsigned int size = sk_filter_len(fp); 911 unsigned int size = sk_filter_len(fp);
@@ -943,7 +954,8 @@ static inline void sock_put(struct sock *sk)
943 sk_free(sk); 954 sk_free(sk);
944} 955}
945 956
946extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb); 957extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
958 const int nested);
947 959
948/* Detach socket from process context. 960/* Detach socket from process context.
949 * Announce socket dead, detach it from wait queue and inode. 961 * Announce socket dead, detach it from wait queue and inode.
@@ -1077,7 +1089,7 @@ static inline int skb_copy_to_page(struct sock *sk, char __user *from,
1077{ 1089{
1078 if (skb->ip_summed == CHECKSUM_NONE) { 1090 if (skb->ip_summed == CHECKSUM_NONE) {
1079 int err = 0; 1091 int err = 0;
1080 unsigned int csum = csum_and_copy_from_user(from, 1092 __wsum csum = csum_and_copy_from_user(from,
1081 page_address(page) + off, 1093 page_address(page) + off,
1082 copy, 0, &err); 1094 copy, 0, &err);
1083 if (err) 1095 if (err)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 7a093d0aa0fe..c99774f15eba 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -28,6 +28,7 @@
28#include <linux/percpu.h> 28#include <linux/percpu.h>
29#include <linux/skbuff.h> 29#include <linux/skbuff.h>
30#include <linux/dmaengine.h> 30#include <linux/dmaengine.h>
31#include <linux/crypto.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>
@@ -138,7 +139,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
138#define MAX_TCP_SYNCNT 127 139#define MAX_TCP_SYNCNT 127
139 140
140#define TCP_SYNQ_INTERVAL (HZ/5) /* Period of SYNACK timer */ 141#define TCP_SYNQ_INTERVAL (HZ/5) /* Period of SYNACK timer */
141#define TCP_SYNQ_HSIZE 512 /* Size of SYNACK hash table */
142 142
143#define TCP_PAWS_24DAYS (60 * 60 * 24 * 24) 143#define TCP_PAWS_24DAYS (60 * 60 * 24 * 24)
144#define TCP_PAWS_MSL 60 /* Per-host timestamps are invalidated 144#define TCP_PAWS_MSL 60 /* Per-host timestamps are invalidated
@@ -162,6 +162,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
162#define TCPOPT_SACK_PERM 4 /* SACK Permitted */ 162#define TCPOPT_SACK_PERM 4 /* SACK Permitted */
163#define TCPOPT_SACK 5 /* SACK Block */ 163#define TCPOPT_SACK 5 /* SACK Block */
164#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ 164#define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */
165#define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */
165 166
166/* 167/*
167 * TCP option lengths 168 * TCP option lengths
@@ -171,6 +172,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
171#define TCPOLEN_WINDOW 3 172#define TCPOLEN_WINDOW 3
172#define TCPOLEN_SACK_PERM 2 173#define TCPOLEN_SACK_PERM 2
173#define TCPOLEN_TIMESTAMP 10 174#define TCPOLEN_TIMESTAMP 10
175#define TCPOLEN_MD5SIG 18
174 176
175/* But this is what stacks really send out. */ 177/* But this is what stacks really send out. */
176#define TCPOLEN_TSTAMP_ALIGNED 12 178#define TCPOLEN_TSTAMP_ALIGNED 12
@@ -179,6 +181,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo);
179#define TCPOLEN_SACK_BASE 2 181#define TCPOLEN_SACK_BASE 2
180#define TCPOLEN_SACK_BASE_ALIGNED 4 182#define TCPOLEN_SACK_BASE_ALIGNED 4
181#define TCPOLEN_SACK_PERBLOCK 8 183#define TCPOLEN_SACK_PERBLOCK 8
184#define TCPOLEN_MD5SIG_ALIGNED 20
182 185
183/* Flags in tp->nonagle */ 186/* Flags in tp->nonagle */
184#define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ 187#define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */
@@ -300,6 +303,8 @@ extern void tcp_cleanup_rbuf(struct sock *sk, int copied);
300extern int tcp_twsk_unique(struct sock *sk, 303extern int tcp_twsk_unique(struct sock *sk,
301 struct sock *sktw, void *twp); 304 struct sock *sktw, void *twp);
302 305
306extern void tcp_twsk_destructor(struct sock *sk);
307
303static inline void tcp_dec_quickack_mode(struct sock *sk, 308static inline void tcp_dec_quickack_mode(struct sock *sk,
304 const unsigned int pkts) 309 const unsigned int pkts)
305{ 310{
@@ -621,8 +626,12 @@ enum tcp_ca_event {
621 * Interface for adding new TCP congestion control handlers 626 * Interface for adding new TCP congestion control handlers
622 */ 627 */
623#define TCP_CA_NAME_MAX 16 628#define TCP_CA_NAME_MAX 16
629#define TCP_CA_MAX 128
630#define TCP_CA_BUF_MAX (TCP_CA_NAME_MAX*TCP_CA_MAX)
631
624struct tcp_congestion_ops { 632struct tcp_congestion_ops {
625 struct list_head list; 633 struct list_head list;
634 int non_restricted;
626 635
627 /* initialize private data (optional) */ 636 /* initialize private data (optional) */
628 void (*init)(struct sock *sk); 637 void (*init)(struct sock *sk);
@@ -660,6 +669,9 @@ extern void tcp_init_congestion_control(struct sock *sk);
660extern void tcp_cleanup_congestion_control(struct sock *sk); 669extern void tcp_cleanup_congestion_control(struct sock *sk);
661extern int tcp_set_default_congestion_control(const char *name); 670extern int tcp_set_default_congestion_control(const char *name);
662extern void tcp_get_default_congestion_control(char *name); 671extern void tcp_get_default_congestion_control(char *name);
672extern void tcp_get_available_congestion_control(char *buf, size_t len);
673extern void tcp_get_allowed_congestion_control(char *buf, size_t len);
674extern int tcp_set_allowed_congestion_control(char *allowed);
663extern int tcp_set_congestion_control(struct sock *sk, const char *name); 675extern int tcp_set_congestion_control(struct sock *sk, const char *name);
664extern void tcp_slow_start(struct tcp_sock *tp); 676extern void tcp_slow_start(struct tcp_sock *tp);
665 677
@@ -795,14 +807,14 @@ static inline void tcp_update_wl(struct tcp_sock *tp, u32 ack, u32 seq)
795/* 807/*
796 * Calculate(/check) TCP checksum 808 * Calculate(/check) TCP checksum
797 */ 809 */
798static inline u16 tcp_v4_check(struct tcphdr *th, int len, 810static inline __sum16 tcp_v4_check(struct tcphdr *th, int len,
799 unsigned long saddr, unsigned long daddr, 811 __be32 saddr, __be32 daddr,
800 unsigned long base) 812 __wsum base)
801{ 813{
802 return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base); 814 return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base);
803} 815}
804 816
805static inline int __tcp_checksum_complete(struct sk_buff *skb) 817static inline __sum16 __tcp_checksum_complete(struct sk_buff *skb)
806{ 818{
807 return __skb_checksum_complete(skb); 819 return __skb_checksum_complete(skb);
808} 820}
@@ -1058,6 +1070,114 @@ static inline void clear_all_retrans_hints(struct tcp_sock *tp){
1058 tp->fastpath_skb_hint = NULL; 1070 tp->fastpath_skb_hint = NULL;
1059} 1071}
1060 1072
1073/* MD5 Signature */
1074struct crypto_hash;
1075
1076/* - key database */
1077struct tcp_md5sig_key {
1078 u8 *key;
1079 u8 keylen;
1080};
1081
1082struct tcp4_md5sig_key {
1083 u8 *key;
1084 u16 keylen;
1085 __be32 addr;
1086};
1087
1088struct tcp6_md5sig_key {
1089 u8 *key;
1090 u16 keylen;
1091#if 0
1092 u32 scope_id; /* XXX */
1093#endif
1094 struct in6_addr addr;
1095};
1096
1097/* - sock block */
1098struct tcp_md5sig_info {
1099 struct tcp4_md5sig_key *keys4;
1100#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1101 struct tcp6_md5sig_key *keys6;
1102 u32 entries6;
1103 u32 alloced6;
1104#endif
1105 u32 entries4;
1106 u32 alloced4;
1107};
1108
1109/* - pseudo header */
1110struct tcp4_pseudohdr {
1111 __be32 saddr;
1112 __be32 daddr;
1113 __u8 pad;
1114 __u8 protocol;
1115 __be16 len;
1116};
1117
1118struct tcp6_pseudohdr {
1119 struct in6_addr saddr;
1120 struct in6_addr daddr;
1121 __be32 len;
1122 __be32 protocol; /* including padding */
1123};
1124
1125union tcp_md5sum_block {
1126 struct tcp4_pseudohdr ip4;
1127#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1128 struct tcp6_pseudohdr ip6;
1129#endif
1130};
1131
1132/* - pool: digest algorithm, hash description and scratch buffer */
1133struct tcp_md5sig_pool {
1134 struct hash_desc md5_desc;
1135 union tcp_md5sum_block md5_blk;
1136};
1137
1138#define TCP_MD5SIG_MAXKEYS (~(u32)0) /* really?! */
1139
1140/* - functions */
1141extern int tcp_v4_calc_md5_hash(char *md5_hash,
1142 struct tcp_md5sig_key *key,
1143 struct sock *sk,
1144 struct dst_entry *dst,
1145 struct request_sock *req,
1146 struct tcphdr *th,
1147 int protocol, int tcplen);
1148extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
1149 struct sock *addr_sk);
1150
1151extern int tcp_v4_md5_do_add(struct sock *sk,
1152 __be32 addr,
1153 u8 *newkey,
1154 u8 newkeylen);
1155
1156extern int tcp_v4_md5_do_del(struct sock *sk,
1157 __be32 addr);
1158
1159extern struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(void);
1160extern void tcp_free_md5sig_pool(void);
1161
1162extern struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu);
1163extern void __tcp_put_md5sig_pool(void);
1164
1165static inline
1166struct tcp_md5sig_pool *tcp_get_md5sig_pool(void)
1167{
1168 int cpu = get_cpu();
1169 struct tcp_md5sig_pool *ret = __tcp_get_md5sig_pool(cpu);
1170 if (!ret)
1171 put_cpu();
1172 return ret;
1173}
1174
1175static inline void tcp_put_md5sig_pool(void)
1176{
1177 __tcp_put_md5sig_pool();
1178 put_cpu();
1179}
1180
1061/* /proc */ 1181/* /proc */
1062enum tcp_seq_states { 1182enum tcp_seq_states {
1063 TCP_SEQ_STATE_LISTENING, 1183 TCP_SEQ_STATE_LISTENING,
@@ -1097,6 +1217,35 @@ extern int tcp4_proc_init(void);
1097extern void tcp4_proc_exit(void); 1217extern void tcp4_proc_exit(void);
1098#endif 1218#endif
1099 1219
1220/* TCP af-specific functions */
1221struct tcp_sock_af_ops {
1222#ifdef CONFIG_TCP_MD5SIG
1223 struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk,
1224 struct sock *addr_sk);
1225 int (*calc_md5_hash) (char *location,
1226 struct tcp_md5sig_key *md5,
1227 struct sock *sk,
1228 struct dst_entry *dst,
1229 struct request_sock *req,
1230 struct tcphdr *th,
1231 int protocol, int len);
1232 int (*md5_add) (struct sock *sk,
1233 struct sock *addr_sk,
1234 u8 *newkey,
1235 u8 len);
1236 int (*md5_parse) (struct sock *sk,
1237 char __user *optval,
1238 int optlen);
1239#endif
1240};
1241
1242struct tcp_request_sock_ops {
1243#ifdef CONFIG_TCP_MD5SIG
1244 struct tcp_md5sig_key *(*md5_lookup) (struct sock *sk,
1245 struct request_sock *req);
1246#endif
1247};
1248
1100extern void tcp_v4_init(struct net_proto_family *ops); 1249extern void tcp_v4_init(struct net_proto_family *ops);
1101extern void tcp_init(void); 1250extern void tcp_init(void);
1102 1251
diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h
index be293d795e38..d7a306ea560d 100644
--- a/include/net/timewait_sock.h
+++ b/include/net/timewait_sock.h
@@ -31,6 +31,9 @@ static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
31 31
32static inline void twsk_destructor(struct sock *sk) 32static inline void twsk_destructor(struct sock *sk)
33{ 33{
34 BUG_ON(sk == NULL);
35 BUG_ON(sk->sk_prot == NULL);
36 BUG_ON(sk->sk_prot->twsk_prot == NULL);
34 if (sk->sk_prot->twsk_prot->twsk_destructor != NULL) 37 if (sk->sk_prot->twsk_prot->twsk_destructor != NULL)
35 sk->sk_prot->twsk_prot->twsk_destructor(sk); 38 sk->sk_prot->twsk_prot->twsk_destructor(sk);
36} 39}
diff --git a/include/net/tipc/tipc_bearer.h b/include/net/tipc/tipc_bearer.h
index e07136d74c2f..2151a80cdf30 100644
--- a/include/net/tipc/tipc_bearer.h
+++ b/include/net/tipc/tipc_bearer.h
@@ -58,7 +58,7 @@
58 */ 58 */
59 59
60struct tipc_media_addr { 60struct tipc_media_addr {
61 __u32 type; /* bearer type (network byte order) */ 61 __be32 type; /* bearer type (network byte order) */
62 union { 62 union {
63 __u8 eth_addr[6]; /* 48 bit Ethernet addr (byte array) */ 63 __u8 eth_addr[6]; /* 48 bit Ethernet addr (byte array) */
64#if 0 64#if 0
diff --git a/include/net/tipc/tipc_msg.h b/include/net/tipc/tipc_msg.h
index 4d096eebc93f..fb42eb7a86a5 100644
--- a/include/net/tipc/tipc_msg.h
+++ b/include/net/tipc/tipc_msg.h
@@ -40,7 +40,7 @@
40#ifdef __KERNEL__ 40#ifdef __KERNEL__
41 41
42struct tipc_msg { 42struct tipc_msg {
43 u32 hdr[15]; 43 __be32 hdr[15];
44}; 44};
45 45
46 46
diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h
index 61f724c1036f..409da3a9a455 100644
--- a/include/net/transp_v6.h
+++ b/include/net/transp_v6.h
@@ -11,6 +11,7 @@
11 11
12extern struct proto rawv6_prot; 12extern struct proto rawv6_prot;
13extern struct proto udpv6_prot; 13extern struct proto udpv6_prot;
14extern struct proto udplitev6_prot;
14extern struct proto tcpv6_prot; 15extern struct proto tcpv6_prot;
15 16
16struct flowi; 17struct flowi;
@@ -24,6 +25,7 @@ extern void ipv6_destopt_init(void);
24/* transport protocols */ 25/* transport protocols */
25extern void rawv6_init(void); 26extern void rawv6_init(void);
26extern void udpv6_init(void); 27extern void udpv6_init(void);
28extern void udplitev6_init(void);
27extern void tcpv6_init(void); 29extern void tcpv6_init(void);
28 30
29extern int udpv6_connect(struct sock *sk, 31extern int udpv6_connect(struct sock *sk,
diff --git a/include/net/udp.h b/include/net/udp.h
index db0c05f67546..1548d68d45da 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -26,9 +26,28 @@
26#include <net/inet_sock.h> 26#include <net/inet_sock.h>
27#include <net/sock.h> 27#include <net/sock.h>
28#include <net/snmp.h> 28#include <net/snmp.h>
29#include <net/ip.h>
30#include <linux/ipv6.h>
29#include <linux/seq_file.h> 31#include <linux/seq_file.h>
30 32
31#define UDP_HTABLE_SIZE 128 33/**
34 * struct udp_skb_cb - UDP(-Lite) private variables
35 *
36 * @header: private variables used by IPv4/IPv6
37 * @cscov: checksum coverage length (UDP-Lite only)
38 * @partial_cov: if set indicates partial csum coverage
39 */
40struct udp_skb_cb {
41 union {
42 struct inet_skb_parm h4;
43#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
44 struct inet6_skb_parm h6;
45#endif
46 } header;
47 __u16 cscov;
48 __u8 partial_cov;
49};
50#define UDP_SKB_CB(__skb) ((struct udp_skb_cb *)((__skb)->cb))
32 51
33extern struct hlist_head udp_hash[UDP_HTABLE_SIZE]; 52extern struct hlist_head udp_hash[UDP_HTABLE_SIZE];
34extern rwlock_t udp_hash_lock; 53extern rwlock_t udp_hash_lock;
@@ -47,6 +66,62 @@ extern struct proto udp_prot;
47 66
48struct sk_buff; 67struct sk_buff;
49 68
69/*
70 * Generic checksumming routines for UDP(-Lite) v4 and v6
71 */
72static inline __sum16 __udp_lib_checksum_complete(struct sk_buff *skb)
73{
74 if (! UDP_SKB_CB(skb)->partial_cov)
75 return __skb_checksum_complete(skb);
76 return csum_fold(skb_checksum(skb, 0, UDP_SKB_CB(skb)->cscov,
77 skb->csum));
78}
79
80static inline int udp_lib_checksum_complete(struct sk_buff *skb)
81{
82 return skb->ip_summed != CHECKSUM_UNNECESSARY &&
83 __udp_lib_checksum_complete(skb);
84}
85
86/**
87 * udp_csum_outgoing - compute UDPv4/v6 checksum over fragments
88 * @sk: socket we are writing to
89 * @skb: sk_buff containing the filled-in UDP header
90 * (checksum field must be zeroed out)
91 */
92static inline __wsum udp_csum_outgoing(struct sock *sk, struct sk_buff *skb)
93{
94 __wsum csum = csum_partial(skb->h.raw, sizeof(struct udphdr), 0);
95
96 skb_queue_walk(&sk->sk_write_queue, skb) {
97 csum = csum_add(csum, skb->csum);
98 }
99 return csum;
100}
101
102/* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
103static inline void udp_lib_hash(struct sock *sk)
104{
105 BUG();
106}
107
108static inline void udp_lib_unhash(struct sock *sk)
109{
110 write_lock_bh(&udp_hash_lock);
111 if (sk_del_node_init(sk)) {
112 inet_sk(sk)->num = 0;
113 sock_prot_dec_use(sk->sk_prot);
114 }
115 write_unlock_bh(&udp_hash_lock);
116}
117
118static inline void udp_lib_close(struct sock *sk, long timeout)
119{
120 sk_common_release(sk);
121}
122
123
124/* net/ipv4/udp.c */
50extern int udp_get_port(struct sock *sk, unsigned short snum, 125extern int udp_get_port(struct sock *sk, unsigned short snum,
51 int (*saddr_cmp)(const struct sock *, const struct sock *)); 126 int (*saddr_cmp)(const struct sock *, const struct sock *));
52extern void udp_err(struct sk_buff *, u32); 127extern void udp_err(struct sk_buff *, u32);
@@ -59,23 +134,36 @@ extern int udp_ioctl(struct sock *sk, int cmd, unsigned long arg);
59extern int udp_disconnect(struct sock *sk, int flags); 134extern int udp_disconnect(struct sock *sk, int flags);
60extern unsigned int udp_poll(struct file *file, struct socket *sock, 135extern unsigned int udp_poll(struct file *file, struct socket *sock,
61 poll_table *wait); 136 poll_table *wait);
137extern int udp_lib_getsockopt(struct sock *sk, int level, int optname,
138 char __user *optval, int __user *optlen);
139extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
140 char __user *optval, int optlen,
141 int (*push_pending_frames)(struct sock *));
62 142
63DECLARE_SNMP_STAT(struct udp_mib, udp_statistics); 143DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
64#define UDP_INC_STATS(field) SNMP_INC_STATS(udp_statistics, field) 144/*
65#define UDP_INC_STATS_BH(field) SNMP_INC_STATS_BH(udp_statistics, field) 145 * SNMP statistics for UDP and UDP-Lite
66#define UDP_INC_STATS_USER(field) SNMP_INC_STATS_USER(udp_statistics, field) 146 */
147#define UDP_INC_STATS_USER(field, is_udplite) do { \
148 if (is_udplite) SNMP_INC_STATS_USER(udplite_statistics, field); \
149 else SNMP_INC_STATS_USER(udp_statistics, field); } while(0)
150#define UDP_INC_STATS_BH(field, is_udplite) do { \
151 if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \
152 else SNMP_INC_STATS_BH(udp_statistics, field); } while(0)
67 153
68/* /proc */ 154/* /proc */
69struct udp_seq_afinfo { 155struct udp_seq_afinfo {
70 struct module *owner; 156 struct module *owner;
71 char *name; 157 char *name;
72 sa_family_t family; 158 sa_family_t family;
159 struct hlist_head *hashtable;
73 int (*seq_show) (struct seq_file *m, void *v); 160 int (*seq_show) (struct seq_file *m, void *v);
74 struct file_operations *seq_fops; 161 struct file_operations *seq_fops;
75}; 162};
76 163
77struct udp_iter_state { 164struct udp_iter_state {
78 sa_family_t family; 165 sa_family_t family;
166 struct hlist_head *hashtable;
79 int bucket; 167 int bucket;
80 struct seq_operations seq_ops; 168 struct seq_operations seq_ops;
81}; 169};
diff --git a/include/net/udplite.h b/include/net/udplite.h
new file mode 100644
index 000000000000..67ac51424307
--- /dev/null
+++ b/include/net/udplite.h
@@ -0,0 +1,151 @@
1/*
2 * Definitions for the UDP-Lite (RFC 3828) code.
3 */
4#ifndef _UDPLITE_H
5#define _UDPLITE_H
6
7#include <net/ip6_checksum.h>
8
9/* UDP-Lite socket options */
10#define UDPLITE_SEND_CSCOV 10 /* sender partial coverage (as sent) */
11#define UDPLITE_RECV_CSCOV 11 /* receiver partial coverage (threshold ) */
12
13extern struct proto udplite_prot;
14extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
15
16/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
17DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
18
19/*
20 * Checksum computation is all in software, hence simpler getfrag.
21 */
22static __inline__ int udplite_getfrag(void *from, char *to, int offset,
23 int len, int odd, struct sk_buff *skb)
24{
25 return memcpy_fromiovecend(to, (struct iovec *) from, offset, len);
26}
27
28/* Designate sk as UDP-Lite socket */
29static inline int udplite_sk_init(struct sock *sk)
30{
31 udp_sk(sk)->pcflag = UDPLITE_BIT;
32 return 0;
33}
34
35/*
36 * Checksumming routines
37 */
38static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh)
39{
40 u16 cscov;
41
42 /* In UDPv4 a zero checksum means that the transmitter generated no
43 * checksum. UDP-Lite (like IPv6) mandates checksums, hence packets
44 * with a zero checksum field are illegal. */
45 if (uh->check == 0) {
46 LIMIT_NETDEBUG(KERN_DEBUG "UDPLITE: zeroed checksum field\n");
47 return 1;
48 }
49
50 UDP_SKB_CB(skb)->partial_cov = 0;
51 cscov = ntohs(uh->len);
52
53 if (cscov == 0) /* Indicates that full coverage is required. */
54 cscov = skb->len;
55 else if (cscov < 8 || cscov > skb->len) {
56 /*
57 * Coverage length violates RFC 3828: log and discard silently.
58 */
59 LIMIT_NETDEBUG(KERN_DEBUG "UDPLITE: bad csum coverage %d/%d\n",
60 cscov, skb->len);
61 return 1;
62
63 } else if (cscov < skb->len)
64 UDP_SKB_CB(skb)->partial_cov = 1;
65
66 UDP_SKB_CB(skb)->cscov = cscov;
67
68 /*
69 * There is no known NIC manufacturer supporting UDP-Lite yet,
70 * hence ip_summed is always (re-)set to CHECKSUM_NONE.
71 */
72 skb->ip_summed = CHECKSUM_NONE;
73
74 return 0;
75}
76
77static __inline__ int udplite4_csum_init(struct sk_buff *skb, struct udphdr *uh)
78{
79 int rc = udplite_checksum_init(skb, uh);
80
81 if (!rc)
82 skb->csum = csum_tcpudp_nofold(skb->nh.iph->saddr,
83 skb->nh.iph->daddr,
84 skb->len, IPPROTO_UDPLITE, 0);
85 return rc;
86}
87
88static __inline__ int udplite6_csum_init(struct sk_buff *skb, struct udphdr *uh)
89{
90 int rc = udplite_checksum_init(skb, uh);
91
92 if (!rc)
93 skb->csum = ~csum_unfold(csum_ipv6_magic(&skb->nh.ipv6h->saddr,
94 &skb->nh.ipv6h->daddr,
95 skb->len, IPPROTO_UDPLITE, 0));
96 return rc;
97}
98
99static inline int udplite_sender_cscov(struct udp_sock *up, struct udphdr *uh)
100{
101 int cscov = up->len;
102
103 /*
104 * Sender has set `partial coverage' option on UDP-Lite socket
105 */
106 if (up->pcflag & UDPLITE_SEND_CC) {
107 if (up->pcslen < up->len) {
108 /* up->pcslen == 0 means that full coverage is required,
109 * partial coverage only if 0 < up->pcslen < up->len */
110 if (0 < up->pcslen) {
111 cscov = up->pcslen;
112 }
113 uh->len = htons(up->pcslen);
114 }
115 /*
116 * NOTE: Causes for the error case `up->pcslen > up->len':
117 * (i) Application error (will not be penalized).
118 * (ii) Payload too big for send buffer: data is split
119 * into several packets, each with its own header.
120 * In this case (e.g. last segment), coverage may
121 * exceed packet length.
122 * Since packets with coverage length > packet length are
123 * illegal, we fall back to the defaults here.
124 */
125 }
126 return cscov;
127}
128
129static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb)
130{
131 int off, len, cscov = udplite_sender_cscov(udp_sk(sk), skb->h.uh);
132 __wsum csum = 0;
133
134 skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */
135
136 skb_queue_walk(&sk->sk_write_queue, skb) {
137 off = skb->h.raw - skb->data;
138 len = skb->len - off;
139
140 csum = skb_checksum(skb, off, (cscov > len)? len : cscov, csum);
141
142 if ((cscov -= len) <= 0)
143 break;
144 }
145 return csum;
146}
147
148extern void udplite4_register(void);
149extern int udplite_get_port(struct sock *sk, unsigned short snum,
150 int (*scmp)(const struct sock *, const struct sock *));
151#endif /* _UDPLITE_H */
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 737fdb2ee8a4..15ec19dcf9c8 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -310,6 +310,8 @@ struct xfrm_tmpl
310/* Source address of tunnel. Ignored, if it is not a tunnel. */ 310/* Source address of tunnel. Ignored, if it is not a tunnel. */
311 xfrm_address_t saddr; 311 xfrm_address_t saddr;
312 312
313 unsigned short encap_family;
314
313 __u32 reqid; 315 __u32 reqid;
314 316
315/* Mode: transport, tunnel etc. */ 317/* Mode: transport, tunnel etc. */
@@ -340,18 +342,19 @@ struct xfrm_policy
340 atomic_t refcnt; 342 atomic_t refcnt;
341 struct timer_list timer; 343 struct timer_list timer;
342 344
343 u8 type;
344 u32 priority; 345 u32 priority;
345 u32 index; 346 u32 index;
346 struct xfrm_selector selector; 347 struct xfrm_selector selector;
347 struct xfrm_lifetime_cfg lft; 348 struct xfrm_lifetime_cfg lft;
348 struct xfrm_lifetime_cur curlft; 349 struct xfrm_lifetime_cur curlft;
349 struct dst_entry *bundles; 350 struct dst_entry *bundles;
350 __u16 family; 351 u16 family;
351 __u8 action; 352 u8 type;
352 __u8 flags; 353 u8 action;
353 __u8 dead; 354 u8 flags;
354 __u8 xfrm_nr; 355 u8 dead;
356 u8 xfrm_nr;
357 /* XXX 1 byte hole, try to pack */
355 struct xfrm_sec_ctx *security; 358 struct xfrm_sec_ctx *security;
356 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; 359 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
357}; 360};
@@ -379,7 +382,7 @@ struct xfrm_mgr
379 int (*notify)(struct xfrm_state *x, struct km_event *c); 382 int (*notify)(struct xfrm_state *x, struct km_event *c);
380 int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); 383 int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir);
381 struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir); 384 struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir);
382 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, u16 sport); 385 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
383 int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c); 386 int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c);
384 int (*report)(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); 387 int (*report)(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr);
385}; 388};
@@ -468,6 +471,7 @@ __be16 xfrm_flowi_sport(struct flowi *fl)
468 switch(fl->proto) { 471 switch(fl->proto) {
469 case IPPROTO_TCP: 472 case IPPROTO_TCP:
470 case IPPROTO_UDP: 473 case IPPROTO_UDP:
474 case IPPROTO_UDPLITE:
471 case IPPROTO_SCTP: 475 case IPPROTO_SCTP:
472 port = fl->fl_ip_sport; 476 port = fl->fl_ip_sport;
473 break; 477 break;
@@ -493,6 +497,7 @@ __be16 xfrm_flowi_dport(struct flowi *fl)
493 switch(fl->proto) { 497 switch(fl->proto) {
494 case IPPROTO_TCP: 498 case IPPROTO_TCP:
495 case IPPROTO_UDP: 499 case IPPROTO_UDP:
500 case IPPROTO_UDPLITE:
496 case IPPROTO_SCTP: 501 case IPPROTO_SCTP:
497 port = fl->fl_ip_dport; 502 port = fl->fl_ip_dport;
498 break; 503 break;
@@ -506,40 +511,8 @@ __be16 xfrm_flowi_dport(struct flowi *fl)
506 return port; 511 return port;
507} 512}
508 513
509static inline int 514extern int xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl,
510__xfrm4_selector_match(struct xfrm_selector *sel, struct flowi *fl) 515 unsigned short family);
511{
512 return addr_match(&fl->fl4_dst, &sel->daddr, sel->prefixlen_d) &&
513 addr_match(&fl->fl4_src, &sel->saddr, sel->prefixlen_s) &&
514 !((xfrm_flowi_dport(fl) ^ sel->dport) & sel->dport_mask) &&
515 !((xfrm_flowi_sport(fl) ^ sel->sport) & sel->sport_mask) &&
516 (fl->proto == sel->proto || !sel->proto) &&
517 (fl->oif == sel->ifindex || !sel->ifindex);
518}
519
520static inline int
521__xfrm6_selector_match(struct xfrm_selector *sel, struct flowi *fl)
522{
523 return addr_match(&fl->fl6_dst, &sel->daddr, sel->prefixlen_d) &&
524 addr_match(&fl->fl6_src, &sel->saddr, sel->prefixlen_s) &&
525 !((xfrm_flowi_dport(fl) ^ sel->dport) & sel->dport_mask) &&
526 !((xfrm_flowi_sport(fl) ^ sel->sport) & sel->sport_mask) &&
527 (fl->proto == sel->proto || !sel->proto) &&
528 (fl->oif == sel->ifindex || !sel->ifindex);
529}
530
531static inline int
532xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl,
533 unsigned short family)
534{
535 switch (family) {
536 case AF_INET:
537 return __xfrm4_selector_match(sel, fl);
538 case AF_INET6:
539 return __xfrm6_selector_match(sel, fl);
540 }
541 return 0;
542}
543 516
544#ifdef CONFIG_SECURITY_NETWORK_XFRM 517#ifdef CONFIG_SECURITY_NETWORK_XFRM
545/* If neither has a context --> match 518/* If neither has a context --> match
@@ -887,8 +860,7 @@ struct xfrm_tunnel {
887struct xfrm6_tunnel { 860struct xfrm6_tunnel {
888 int (*handler)(struct sk_buff *skb); 861 int (*handler)(struct sk_buff *skb);
889 int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt, 862 int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt,
890 int type, int code, int offset, __u32 info); 863 int type, int code, int offset, __be32 info);
891
892 struct xfrm6_tunnel *next; 864 struct xfrm6_tunnel *next;
893 int priority; 865 int priority;
894}; 866};
@@ -951,9 +923,9 @@ extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
951 xfrm_address_t *saddr, u8 proto); 923 xfrm_address_t *saddr, u8 proto);
952extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler); 924extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler);
953extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler); 925extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler);
954extern u32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr); 926extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr);
955extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr); 927extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr);
956extern u32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr); 928extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr);
957extern int xfrm6_output(struct sk_buff *skb); 929extern int xfrm6_output(struct sk_buff *skb);
958extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, 930extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
959 u8 **prevhdr); 931 u8 **prevhdr);
@@ -1000,7 +972,7 @@ extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
1000extern void xfrm_init_pmtu(struct dst_entry *dst); 972extern void xfrm_init_pmtu(struct dst_entry *dst);
1001 973
1002extern wait_queue_head_t km_waitq; 974extern wait_queue_head_t km_waitq;
1003extern int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, u16 sport); 975extern int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
1004extern void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 pid); 976extern void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 pid);
1005extern int km_report(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); 977extern int km_report(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr);
1006 978
@@ -1033,7 +1005,7 @@ static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b,
1033 switch (family) { 1005 switch (family) {
1034 default: 1006 default:
1035 case AF_INET: 1007 case AF_INET:
1036 return a->a4 - b->a4; 1008 return (__force __u32)a->a4 - (__force __u32)b->a4;
1037 case AF_INET6: 1009 case AF_INET6:
1038 return ipv6_addr_cmp((struct in6_addr *)a, 1010 return ipv6_addr_cmp((struct in6_addr *)a,
1039 (struct in6_addr *)b); 1011 (struct in6_addr *)b);
diff --git a/include/rdma/ib_cm.h b/include/rdma/ib_cm.h
index c9b4738be9d6..5c070176d9ab 100644
--- a/include/rdma/ib_cm.h
+++ b/include/rdma/ib_cm.h
@@ -60,6 +60,7 @@ enum ib_cm_state {
60}; 60};
61 61
62enum ib_cm_lap_state { 62enum ib_cm_lap_state {
63 IB_CM_LAP_UNINIT,
63 IB_CM_LAP_IDLE, 64 IB_CM_LAP_IDLE,
64 IB_CM_LAP_SENT, 65 IB_CM_LAP_SENT,
65 IB_CM_LAP_RCVD, 66 IB_CM_LAP_RCVD,
@@ -443,13 +444,20 @@ int ib_send_cm_drep(struct ib_cm_id *cm_id,
443 u8 private_data_len); 444 u8 private_data_len);
444 445
445/** 446/**
446 * ib_cm_establish - Forces a connection state to established. 447 * ib_cm_notify - Notifies the CM of an event reported to the consumer.
447 * @cm_id: Connection identifier to transition to established. 448 * @cm_id: Connection identifier to transition to established.
449 * @event: Type of event.
448 * 450 *
449 * This routine should be invoked by users who receive messages on a 451 * This routine should be invoked by users to notify the CM of relevant
450 * connected QP before an RTU has been received. 452 * communication events. Events that should be reported to the CM and
453 * when to report them are:
454 *
455 * IB_EVENT_COMM_EST - Used when a message is received on a connected
456 * QP before an RTU has been received.
457 * IB_EVENT_PATH_MIG - Notifies the CM that the connection has failed over
458 * to the alternate path.
451 */ 459 */
452int ib_cm_establish(struct ib_cm_id *cm_id); 460int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event);
453 461
454/** 462/**
455 * ib_send_cm_rej - Sends a connection rejection message to the 463 * ib_send_cm_rej - Sends a connection rejection message to the
diff --git a/include/rdma/ib_user_cm.h b/include/rdma/ib_user_cm.h
index 066c20b7cdfb..37650afb982c 100644
--- a/include/rdma/ib_user_cm.h
+++ b/include/rdma/ib_user_cm.h
@@ -38,7 +38,7 @@
38 38
39#include <rdma/ib_user_sa.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 5
42 42
43enum { 43enum {
44 IB_USER_CM_CMD_CREATE_ID, 44 IB_USER_CM_CMD_CREATE_ID,
@@ -46,7 +46,7 @@ enum {
46 IB_USER_CM_CMD_ATTR_ID, 46 IB_USER_CM_CMD_ATTR_ID,
47 47
48 IB_USER_CM_CMD_LISTEN, 48 IB_USER_CM_CMD_LISTEN,
49 IB_USER_CM_CMD_ESTABLISH, 49 IB_USER_CM_CMD_NOTIFY,
50 50
51 IB_USER_CM_CMD_SEND_REQ, 51 IB_USER_CM_CMD_SEND_REQ,
52 IB_USER_CM_CMD_SEND_REP, 52 IB_USER_CM_CMD_SEND_REP,
@@ -117,8 +117,9 @@ struct ib_ucm_listen {
117 __u32 reserved; 117 __u32 reserved;
118}; 118};
119 119
120struct ib_ucm_establish { 120struct ib_ucm_notify {
121 __u32 id; 121 __u32 id;
122 __u32 event;
122}; 123};
123 124
124struct ib_ucm_private_data { 125struct ib_ucm_private_data {
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 9ccc0365aa89..1f989fb42c70 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -35,6 +35,7 @@
35#include <scsi/scsi_device.h> 35#include <scsi/scsi_device.h>
36#include <scsi/scsi_cmnd.h> 36#include <scsi/scsi_cmnd.h>
37#include <scsi/scsi_transport_sas.h> 37#include <scsi/scsi_transport_sas.h>
38#include <asm/scatterlist.h>
38 39
39struct block_device; 40struct block_device;
40 41
diff --git a/include/sound/core.h b/include/sound/core.h
index fa1ca0127bab..a994bea09cd6 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -132,6 +132,7 @@ struct snd_card {
132 int shutdown; /* this card is going down */ 132 int shutdown; /* this card is going down */
133 int free_on_last_close; /* free in context of file_release */ 133 int free_on_last_close; /* free in context of file_release */
134 wait_queue_head_t shutdown_sleep; 134 wait_queue_head_t shutdown_sleep;
135 struct device *parent;
135 struct device *dev; 136 struct device *dev;
136 137
137#ifdef CONFIG_PM 138#ifdef CONFIG_PM
@@ -187,13 +188,14 @@ struct snd_minor {
187 int device; /* device number */ 188 int device; /* device number */
188 const struct file_operations *f_ops; /* file operations */ 189 const struct file_operations *f_ops; /* file operations */
189 void *private_data; /* private data for f_ops->open */ 190 void *private_data; /* private data for f_ops->open */
190 struct class_device *class_dev; /* class device for sysfs */ 191 struct device *dev; /* device for sysfs */
191}; 192};
192 193
193/* sound.c */ 194/* sound.c */
194 195
195extern int snd_major; 196extern int snd_major;
196extern int snd_ecards_limit; 197extern int snd_ecards_limit;
198extern struct class *sound_class;
197 199
198void snd_request_card(int card); 200void snd_request_card(int card);
199 201
@@ -203,7 +205,7 @@ int snd_register_device(int type, struct snd_card *card, int dev,
203int snd_unregister_device(int type, struct snd_card *card, int dev); 205int snd_unregister_device(int type, struct snd_card *card, int dev);
204void *snd_lookup_minor_data(unsigned int minor, int type); 206void *snd_lookup_minor_data(unsigned int minor, int type);
205int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev, 207int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
206 const struct class_device_attribute *attr); 208 struct device_attribute *attr);
207 209
208#ifdef CONFIG_SND_OSSEMUL 210#ifdef CONFIG_SND_OSSEMUL
209int snd_register_oss_device(int type, struct snd_card *card, int dev, 211int snd_register_oss_device(int type, struct snd_card *card, int dev,
@@ -255,7 +257,7 @@ int snd_card_file_add(struct snd_card *card, struct file *file);
255int snd_card_file_remove(struct snd_card *card, struct file *file); 257int snd_card_file_remove(struct snd_card *card, struct file *file);
256 258
257#ifndef snd_card_set_dev 259#ifndef snd_card_set_dev
258#define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) 260#define snd_card_set_dev(card,devptr) ((card)->parent = (devptr))
259#endif 261#endif
260 262
261/* device.c */ 263/* device.c */
diff --git a/include/sound/version.h b/include/sound/version.h
index 52fd6879b86e..17137f3a3b6f 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h. Generated by alsa/ksync script. */ 1/* include/version.h. Generated by alsa/ksync script. */
2#define CONFIG_SND_VERSION "1.0.13" 2#define CONFIG_SND_VERSION "1.0.13"
3#define CONFIG_SND_DATE " (Sun Oct 22 08:56:16 2006 UTC)" 3#define CONFIG_SND_DATE " (Tue Nov 28 14:07:24 2006 UTC)"
diff --git a/init/Kconfig b/init/Kconfig
index 176f7e5136c7..14d484606fab 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -249,6 +249,26 @@ config CPUSETS
249 249
250 Say N if unsure. 250 Say N if unsure.
251 251
252config SYSFS_DEPRECATED
253 bool "Create deprecated sysfs files"
254 default y
255 help
256 This option creates deprecated symlinks such as the
257 "device"-link, the <subsystem>:<name>-link, and the
258 "bus"-link. It may also add deprecated key in the
259 uevent environment.
260 None of these features or values should be used today, as
261 they export driver core implementation details to userspace
262 or export properties which can't be kept stable across kernel
263 releases.
264
265 If enabled, this option will also move any device structures
266 that belong to a class, back into the /sys/class heirachy, in
267 order to support older versions of udev.
268
269 If you are using a distro that was released in 2006 or later,
270 it should be safe to say N here.
271
252config RELAY 272config RELAY
253 bool "Kernel->user space relay support (formerly relayfs)" 273 bool "Kernel->user space relay support (formerly relayfs)"
254 help 274 help
diff --git a/kernel/fork.c b/kernel/fork.c
index 3da978eec791..8cdd3e72ba55 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1315,9 +1315,8 @@ struct task_struct * __devinit fork_idle(int cpu)
1315 struct pt_regs regs; 1315 struct pt_regs regs;
1316 1316
1317 task = copy_process(CLONE_VM, 0, idle_regs(&regs), 0, NULL, NULL, 0); 1317 task = copy_process(CLONE_VM, 0, idle_regs(&regs), 0, NULL, NULL, 0);
1318 if (!task) 1318 if (!IS_ERR(task))
1319 return ERR_PTR(-ENOMEM); 1319 init_idle(task, cpu);
1320 init_idle(task, cpu);
1321 1320
1322 return task; 1321 return task;
1323} 1322}
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 42aa6f1a3f0f..a681912bc89a 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -231,10 +231,10 @@ fastcall unsigned int __do_IRQ(unsigned int irq)
231 spin_unlock(&desc->lock); 231 spin_unlock(&desc->lock);
232 232
233 action_ret = handle_IRQ_event(irq, action); 233 action_ret = handle_IRQ_event(irq, action);
234
235 spin_lock(&desc->lock);
236 if (!noirqdebug) 234 if (!noirqdebug)
237 note_interrupt(irq, desc, action_ret); 235 note_interrupt(irq, desc, action_ret);
236
237 spin_lock(&desc->lock);
238 if (likely(!(desc->status & IRQ_PENDING))) 238 if (likely(!(desc->status & IRQ_PENDING)))
239 break; 239 break;
240 desc->status &= ~IRQ_PENDING; 240 desc->status &= ~IRQ_PENDING;
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 9c7e2e4c1fe7..543ea2e5ad93 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -147,11 +147,7 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
147 if (unlikely(irqfixup)) { 147 if (unlikely(irqfixup)) {
148 /* Don't punish working computers */ 148 /* Don't punish working computers */
149 if ((irqfixup == 2 && irq == 0) || action_ret == IRQ_NONE) { 149 if ((irqfixup == 2 && irq == 0) || action_ret == IRQ_NONE) {
150 int ok; 150 int ok = misrouted_irq(irq);
151
152 spin_unlock(&desc->lock);
153 ok = misrouted_irq(irq);
154 spin_lock(&desc->lock);
155 if (action_ret == IRQ_NONE) 151 if (action_ret == IRQ_NONE)
156 desc->irqs_unhandled -= ok; 152 desc->irqs_unhandled -= ok;
157 } 153 }
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 7dc7a9dad6ac..8d2bea09a4ec 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -311,14 +311,14 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp,
311 return 0; 311 return 0;
312 312
313 f = create_write_pipe(); 313 f = create_write_pipe();
314 if (!f) 314 if (IS_ERR(f))
315 return -ENOMEM; 315 return PTR_ERR(f);
316 *filp = f; 316 *filp = f;
317 317
318 f = create_read_pipe(f); 318 f = create_read_pipe(f);
319 if (!f) { 319 if (IS_ERR(f)) {
320 free_write_pipe(*filp); 320 free_write_pipe(*filp);
321 return -ENOMEM; 321 return PTR_ERR(f);
322 } 322 }
323 sub_info.stdin = f; 323 sub_info.stdin = f;
324 324
diff --git a/kernel/module.c b/kernel/module.c
index f0166563c602..45e01cb60101 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1086,22 +1086,35 @@ static int mod_sysfs_setup(struct module *mod,
1086 goto out; 1086 goto out;
1087 kobj_set_kset_s(&mod->mkobj, module_subsys); 1087 kobj_set_kset_s(&mod->mkobj, module_subsys);
1088 mod->mkobj.mod = mod; 1088 mod->mkobj.mod = mod;
1089 err = kobject_register(&mod->mkobj.kobj); 1089
1090 /* delay uevent until full sysfs population */
1091 kobject_init(&mod->mkobj.kobj);
1092 err = kobject_add(&mod->mkobj.kobj);
1090 if (err) 1093 if (err)
1091 goto out; 1094 goto out;
1092 1095
1096 mod->drivers_dir = kobject_add_dir(&mod->mkobj.kobj, "drivers");
1097 if (!mod->drivers_dir)
1098 goto out_unreg;
1099
1093 err = module_param_sysfs_setup(mod, kparam, num_params); 1100 err = module_param_sysfs_setup(mod, kparam, num_params);
1094 if (err) 1101 if (err)
1095 goto out_unreg; 1102 goto out_unreg_drivers;
1096 1103
1097 err = module_add_modinfo_attrs(mod); 1104 err = module_add_modinfo_attrs(mod);
1098 if (err) 1105 if (err)
1099 goto out_unreg; 1106 goto out_unreg_param;
1100 1107
1108 kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD);
1101 return 0; 1109 return 0;
1102 1110
1111out_unreg_drivers:
1112 kobject_unregister(mod->drivers_dir);
1113out_unreg_param:
1114 module_param_sysfs_remove(mod);
1103out_unreg: 1115out_unreg:
1104 kobject_unregister(&mod->mkobj.kobj); 1116 kobject_del(&mod->mkobj.kobj);
1117 kobject_put(&mod->mkobj.kobj);
1105out: 1118out:
1106 return err; 1119 return err;
1107} 1120}
@@ -1110,6 +1123,7 @@ static void mod_kobject_remove(struct module *mod)
1110{ 1123{
1111 module_remove_modinfo_attrs(mod); 1124 module_remove_modinfo_attrs(mod);
1112 module_param_sysfs_remove(mod); 1125 module_param_sysfs_remove(mod);
1126 kobject_unregister(mod->drivers_dir);
1113 1127
1114 kobject_unregister(&mod->mkobj.kobj); 1128 kobject_unregister(&mod->mkobj.kobj);
1115} 1129}
@@ -2275,11 +2289,14 @@ void print_modules(void)
2275 2289
2276void module_add_driver(struct module *mod, struct device_driver *drv) 2290void module_add_driver(struct module *mod, struct device_driver *drv)
2277{ 2291{
2292 int no_warn;
2293
2278 if (!mod || !drv) 2294 if (!mod || !drv)
2279 return; 2295 return;
2280 2296
2281 /* Don't check return code; this call is idempotent */ 2297 /* Don't check return codes; these calls are idempotent */
2282 sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); 2298 no_warn = sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module");
2299 no_warn = sysfs_create_link(mod->drivers_dir, &drv->kobj, drv->name);
2283} 2300}
2284EXPORT_SYMBOL(module_add_driver); 2301EXPORT_SYMBOL(module_add_driver);
2285 2302
@@ -2288,6 +2305,8 @@ void module_remove_driver(struct device_driver *drv)
2288 if (!drv) 2305 if (!drv)
2289 return; 2306 return;
2290 sysfs_remove_link(&drv->kobj, "module"); 2307 sysfs_remove_link(&drv->kobj, "module");
2308 if (drv->owner && drv->owner->drivers_dir)
2309 sysfs_remove_link(drv->owner->drivers_dir, drv->name);
2291} 2310}
2292EXPORT_SYMBOL(module_remove_driver); 2311EXPORT_SYMBOL(module_remove_driver);
2293 2312
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index 476c3741511b..2c6c2bf85514 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -293,6 +293,27 @@ void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass)
293} 293}
294 294
295EXPORT_SYMBOL(_spin_lock_nested); 295EXPORT_SYMBOL(_spin_lock_nested);
296unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, int subclass)
297{
298 unsigned long flags;
299
300 local_irq_save(flags);
301 preempt_disable();
302 spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
303 /*
304 * On lockdep we dont want the hand-coded irq-enable of
305 * _raw_spin_lock_flags() code, because lockdep assumes
306 * that interrupts are not re-enabled during lock-acquire:
307 */
308#ifdef CONFIG_PROVE_SPIN_LOCKING
309 _raw_spin_lock(lock);
310#else
311 _raw_spin_lock_flags(lock, &flags);
312#endif
313 return flags;
314}
315
316EXPORT_SYMBOL(_spin_lock_irqsave_nested);
296 317
297#endif 318#endif
298 319
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index f45c5e70773c..d3d28919d4b4 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -77,8 +77,7 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
77 /* 77 /*
78 * If new attributes are added, please revisit this allocation 78 * If new attributes are added, please revisit this allocation
79 */ 79 */
80 size = nlmsg_total_size(genlmsg_total_size(size)); 80 skb = genlmsg_new(size, GFP_KERNEL);
81 skb = nlmsg_new(size, GFP_KERNEL);
82 if (!skb) 81 if (!skb)
83 return -ENOMEM; 82 return -ENOMEM;
84 83
@@ -86,13 +85,9 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
86 int seq = get_cpu_var(taskstats_seqnum)++; 85 int seq = get_cpu_var(taskstats_seqnum)++;
87 put_cpu_var(taskstats_seqnum); 86 put_cpu_var(taskstats_seqnum);
88 87
89 reply = genlmsg_put(skb, 0, seq, 88 reply = genlmsg_put(skb, 0, seq, &family, 0, cmd);
90 family.id, 0, 0,
91 cmd, family.version);
92 } else 89 } else
93 reply = genlmsg_put(skb, info->snd_pid, info->snd_seq, 90 reply = genlmsg_put_reply(skb, info, &family, 0, cmd);
94 family.id, 0, 0,
95 cmd, family.version);
96 if (reply == NULL) { 91 if (reply == NULL) {
97 nlmsg_free(skb); 92 nlmsg_free(skb);
98 return -EINVAL; 93 return -EINVAL;
diff --git a/kernel/unwind.c b/kernel/unwind.c
index f7e50d16dbf6..ed0a21d4a902 100644
--- a/kernel/unwind.c
+++ b/kernel/unwind.c
@@ -938,8 +938,11 @@ int unwind(struct unwind_frame_info *frame)
938 else { 938 else {
939 retAddrReg = state.version <= 1 ? *ptr++ : get_uleb128(&ptr, end); 939 retAddrReg = state.version <= 1 ? *ptr++ : get_uleb128(&ptr, end);
940 /* skip augmentation */ 940 /* skip augmentation */
941 if (((const char *)(cie + 2))[1] == 'z') 941 if (((const char *)(cie + 2))[1] == 'z') {
942 ptr += get_uleb128(&ptr, end); 942 uleb128_t augSize = get_uleb128(&ptr, end);
943
944 ptr += augSize;
945 }
943 if (ptr > end 946 if (ptr > end
944 || retAddrReg >= ARRAY_SIZE(reg_info) 947 || retAddrReg >= ARRAY_SIZE(reg_info)
945 || REG_INVALID(retAddrReg) 948 || REG_INVALID(retAddrReg)
@@ -963,9 +966,7 @@ int unwind(struct unwind_frame_info *frame)
963 if (cie == NULL || fde == NULL) { 966 if (cie == NULL || fde == NULL) {
964#ifdef CONFIG_FRAME_POINTER 967#ifdef CONFIG_FRAME_POINTER
965 unsigned long top, bottom; 968 unsigned long top, bottom;
966#endif
967 969
968#ifdef CONFIG_FRAME_POINTER
969 top = STACK_TOP(frame->task); 970 top = STACK_TOP(frame->task);
970 bottom = STACK_BOTTOM(frame->task); 971 bottom = STACK_BOTTOM(frame->task);
971# if FRAME_RETADDR_OFFSET < 0 972# if FRAME_RETADDR_OFFSET < 0
diff --git a/lib/kobject.c b/lib/kobject.c
index 7dd5c0e9d996..744a4b102c7f 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -311,6 +311,56 @@ int kobject_rename(struct kobject * kobj, const char *new_name)
311} 311}
312 312
313/** 313/**
314 * kobject_move - move object to another parent
315 * @kobj: object in question.
316 * @new_parent: object's new parent
317 */
318
319int kobject_move(struct kobject *kobj, struct kobject *new_parent)
320{
321 int error;
322 struct kobject *old_parent;
323 const char *devpath = NULL;
324 char *devpath_string = NULL;
325 char *envp[2];
326
327 kobj = kobject_get(kobj);
328 if (!kobj)
329 return -EINVAL;
330 new_parent = kobject_get(new_parent);
331 if (!new_parent) {
332 error = -EINVAL;
333 goto out;
334 }
335 /* old object path */
336 devpath = kobject_get_path(kobj, GFP_KERNEL);
337 if (!devpath) {
338 error = -ENOMEM;
339 goto out;
340 }
341 devpath_string = kmalloc(strlen(devpath) + 15, GFP_KERNEL);
342 if (!devpath_string) {
343 error = -ENOMEM;
344 goto out;
345 }
346 sprintf(devpath_string, "DEVPATH_OLD=%s", devpath);
347 envp[0] = devpath_string;
348 envp[1] = NULL;
349 error = sysfs_move_dir(kobj, new_parent);
350 if (error)
351 goto out;
352 old_parent = kobj->parent;
353 kobj->parent = new_parent;
354 kobject_put(old_parent);
355 kobject_uevent_env(kobj, KOBJ_MOVE, envp);
356out:
357 kobject_put(kobj);
358 kfree(devpath_string);
359 kfree(devpath);
360 return error;
361}
362
363/**
314 * kobject_del - unlink kobject from hierarchy. 364 * kobject_del - unlink kobject from hierarchy.
315 * @kobj: object. 365 * @kobj: object.
316 */ 366 */
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 7f20e7b857cb..a1922765ff31 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -50,18 +50,22 @@ static char *action_to_string(enum kobject_action action)
50 return "offline"; 50 return "offline";
51 case KOBJ_ONLINE: 51 case KOBJ_ONLINE:
52 return "online"; 52 return "online";
53 case KOBJ_MOVE:
54 return "move";
53 default: 55 default:
54 return NULL; 56 return NULL;
55 } 57 }
56} 58}
57 59
58/** 60/**
59 * kobject_uevent - notify userspace by ending an uevent 61 * kobject_uevent_env - send an uevent with environmental data
60 * 62 *
61 * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE) 63 * @action: action that is happening (usually KOBJ_MOVE)
62 * @kobj: struct kobject that the action is happening to 64 * @kobj: struct kobject that the action is happening to
65 * @envp_ext: pointer to environmental data
63 */ 66 */
64void kobject_uevent(struct kobject *kobj, enum kobject_action action) 67void kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
68 char *envp_ext[])
65{ 69{
66 char **envp; 70 char **envp;
67 char *buffer; 71 char *buffer;
@@ -76,6 +80,7 @@ void kobject_uevent(struct kobject *kobj, enum kobject_action action)
76 char *seq_buff; 80 char *seq_buff;
77 int i = 0; 81 int i = 0;
78 int retval; 82 int retval;
83 int j;
79 84
80 pr_debug("%s\n", __FUNCTION__); 85 pr_debug("%s\n", __FUNCTION__);
81 86
@@ -134,7 +139,8 @@ void kobject_uevent(struct kobject *kobj, enum kobject_action action)
134 scratch += sprintf (scratch, "DEVPATH=%s", devpath) + 1; 139 scratch += sprintf (scratch, "DEVPATH=%s", devpath) + 1;
135 envp [i++] = scratch; 140 envp [i++] = scratch;
136 scratch += sprintf(scratch, "SUBSYSTEM=%s", subsystem) + 1; 141 scratch += sprintf(scratch, "SUBSYSTEM=%s", subsystem) + 1;
137 142 for (j = 0; envp_ext && envp_ext[j]; j++)
143 envp[i++] = envp_ext[j];
138 /* just reserve the space, overwrite it after kset call has returned */ 144 /* just reserve the space, overwrite it after kset call has returned */
139 envp[i++] = seq_buff = scratch; 145 envp[i++] = seq_buff = scratch;
140 scratch += strlen("SEQNUM=18446744073709551616") + 1; 146 scratch += strlen("SEQNUM=18446744073709551616") + 1;
@@ -200,6 +206,20 @@ exit:
200 kfree(envp); 206 kfree(envp);
201 return; 207 return;
202} 208}
209
210EXPORT_SYMBOL_GPL(kobject_uevent_env);
211
212/**
213 * kobject_uevent - notify userspace by ending an uevent
214 *
215 * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE)
216 * @kobj: struct kobject that the action is happening to
217 */
218void kobject_uevent(struct kobject *kobj, enum kobject_action action)
219{
220 kobject_uevent_env(kobj, action, NULL);
221}
222
203EXPORT_SYMBOL_GPL(kobject_uevent); 223EXPORT_SYMBOL_GPL(kobject_uevent);
204 224
205/** 225/**
diff --git a/lib/textsearch.c b/lib/textsearch.c
index 2cb4a437942e..98bcadc01185 100644
--- a/lib/textsearch.c
+++ b/lib/textsearch.c
@@ -40,7 +40,7 @@
40 * configuration according to the specified parameters. 40 * configuration according to the specified parameters.
41 * (3) User starts the search(es) by calling _find() or _next() to 41 * (3) User starts the search(es) by calling _find() or _next() to
42 * fetch subsequent occurrences. A state variable is provided 42 * fetch subsequent occurrences. A state variable is provided
43 * to the algorihtm to store persistant variables. 43 * to the algorihtm to store persistent variables.
44 * (4) Core eventually resets the search offset and forwards the find() 44 * (4) Core eventually resets the search offset and forwards the find()
45 * request to the algorithm. 45 * request to the algorithm.
46 * (5) Algorithm calls get_next_block() provided by the user continously 46 * (5) Algorithm calls get_next_block() provided by the user continously
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bf2f6cff1d6a..aa6fcc7ca66f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2612,6 +2612,9 @@ unsigned long __init find_min_pfn_for_node(unsigned long nid)
2612{ 2612{
2613 int i; 2613 int i;
2614 2614
2615 /* Regions in the early_node_map can be in any order */
2616 sort_node_map();
2617
2615 /* Assuming a sorted map, the first range found has the starting pfn */ 2618 /* Assuming a sorted map, the first range found has the starting pfn */
2616 for_each_active_range_index_in_nid(i, nid) 2619 for_each_active_range_index_in_nid(i, nid)
2617 return early_node_map[i].start_pfn; 2620 return early_node_map[i].start_pfn;
@@ -2680,9 +2683,6 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
2680 max(max_zone_pfn[i], arch_zone_lowest_possible_pfn[i]); 2683 max(max_zone_pfn[i], arch_zone_lowest_possible_pfn[i]);
2681 } 2684 }
2682 2685
2683 /* Regions in the early_node_map can be in any order */
2684 sort_node_map();
2685
2686 /* Print out the zone ranges */ 2686 /* Print out the zone ranges */
2687 printk("Zone PFN ranges:\n"); 2687 printk("Zone PFN ranges:\n");
2688 for (i = 0; i < MAX_NR_ZONES; i++) 2688 for (i = 0; i < MAX_NR_ZONES; i++)
diff --git a/net/802/hippi.c b/net/802/hippi.c
index 6d7fed3dd99a..579e2ddf5ebe 100644
--- a/net/802/hippi.c
+++ b/net/802/hippi.c
@@ -36,7 +36,6 @@
36#include <net/arp.h> 36#include <net/arp.h>
37#include <net/sock.h> 37#include <net/sock.h>
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
39#include <asm/checksum.h>
40#include <asm/system.h> 39#include <asm/system.h>
41 40
42/* 41/*
diff --git a/net/Kconfig b/net/Kconfig
index 67e39ad8b8b6..7dfc94920697 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -75,7 +75,7 @@ config NETWORK_SECMARK
75 If you are unsure how to answer this question, answer N. 75 If you are unsure how to answer this question, answer N.
76 76
77menuconfig NETFILTER 77menuconfig NETFILTER
78 bool "Network packet filtering (replaces ipchains)" 78 bool "Network packet filtering framework (Netfilter)"
79 ---help--- 79 ---help---
80 Netfilter is a framework for filtering and mangling network packets 80 Netfilter is a framework for filtering and mangling network packets
81 that pass through your Linux box. 81 that pass through your Linux box.
@@ -175,33 +175,6 @@ source "net/ipx/Kconfig"
175source "drivers/net/appletalk/Kconfig" 175source "drivers/net/appletalk/Kconfig"
176source "net/x25/Kconfig" 176source "net/x25/Kconfig"
177source "net/lapb/Kconfig" 177source "net/lapb/Kconfig"
178
179config NET_DIVERT
180 bool "Frame Diverter (EXPERIMENTAL)"
181 depends on EXPERIMENTAL && BROKEN
182 ---help---
183 The Frame Diverter allows you to divert packets from the
184 network, that are not aimed at the interface receiving it (in
185 promisc. mode). Typically, a Linux box setup as an Ethernet bridge
186 with the Frames Diverter on, can do some *really* transparent www
187 caching using a Squid proxy for example.
188
189 This is very useful when you don't want to change your router's
190 config (or if you simply don't have access to it).
191
192 The other possible usages of diverting Ethernet Frames are
193 numberous:
194 - reroute smtp traffic to another interface
195 - traffic-shape certain network streams
196 - transparently proxy smtp connections
197 - etc...
198
199 For more informations, please refer to:
200 <http://diverter.sourceforge.net/>
201 <http://perso.wanadoo.fr/magpie/EtherDivert.html>
202
203 If unsure, say N.
204
205source "net/econet/Kconfig" 178source "net/econet/Kconfig"
206source "net/wanrouter/Kconfig" 179source "net/wanrouter/Kconfig"
207source "net/sched/Kconfig" 180source "net/sched/Kconfig"
diff --git a/net/atm/Makefile b/net/atm/Makefile
index 89656d6c0b90..cc50bd1ff1de 100644
--- a/net/atm/Makefile
+++ b/net/atm/Makefile
@@ -7,10 +7,7 @@ mpoa-objs := mpc.o mpoa_caches.o mpoa_proc.o
7 7
8obj-$(CONFIG_ATM) += atm.o 8obj-$(CONFIG_ATM) += atm.o
9obj-$(CONFIG_ATM_CLIP) += clip.o 9obj-$(CONFIG_ATM_CLIP) += clip.o
10atm-$(subst m,y,$(CONFIG_ATM_CLIP)) += ipcommon.o
11obj-$(CONFIG_ATM_BR2684) += br2684.o 10obj-$(CONFIG_ATM_BR2684) += br2684.o
12atm-$(subst m,y,$(CONFIG_ATM_BR2684)) += ipcommon.o
13atm-$(subst m,y,$(CONFIG_NET_SCH_ATM)) += ipcommon.o
14atm-$(CONFIG_PROC_FS) += proc.o 11atm-$(CONFIG_PROC_FS) += proc.o
15 12
16obj-$(CONFIG_ATM_LANE) += lec.o 13obj-$(CONFIG_ATM_LANE) += lec.o
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index d00cca97eb33..83a1c1b1d6cd 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -23,7 +23,6 @@ Author: Marcell GAL, 2000, XDSL Ltd, Hungary
23#include <linux/atmbr2684.h> 23#include <linux/atmbr2684.h>
24 24
25#include "common.h" 25#include "common.h"
26#include "ipcommon.h"
27 26
28/* 27/*
29 * Define this to use a version of the code which interacts with the higher 28 * Define this to use a version of the code which interacts with the higher
@@ -372,7 +371,7 @@ static int br2684_setfilt(struct atm_vcc *atmvcc, void __user *arg)
372 371
373/* Returns 1 if packet should be dropped */ 372/* Returns 1 if packet should be dropped */
374static inline int 373static inline int
375packet_fails_filter(u16 type, struct br2684_vcc *brvcc, struct sk_buff *skb) 374packet_fails_filter(__be16 type, struct br2684_vcc *brvcc, struct sk_buff *skb)
376{ 375{
377 if (brvcc->filter.netmask == 0) 376 if (brvcc->filter.netmask == 0)
378 return 0; /* no filter in place */ 377 return 0; /* no filter in place */
@@ -500,11 +499,12 @@ Note: we do not have explicit unassign, but look at _push()
500*/ 499*/
501 int err; 500 int err;
502 struct br2684_vcc *brvcc; 501 struct br2684_vcc *brvcc;
503 struct sk_buff_head copy;
504 struct sk_buff *skb; 502 struct sk_buff *skb;
503 struct sk_buff_head *rq;
505 struct br2684_dev *brdev; 504 struct br2684_dev *brdev;
506 struct net_device *net_dev; 505 struct net_device *net_dev;
507 struct atm_backend_br2684 be; 506 struct atm_backend_br2684 be;
507 unsigned long flags;
508 508
509 if (copy_from_user(&be, arg, sizeof be)) 509 if (copy_from_user(&be, arg, sizeof be))
510 return -EFAULT; 510 return -EFAULT;
@@ -554,12 +554,30 @@ Note: we do not have explicit unassign, but look at _push()
554 brvcc->old_push = atmvcc->push; 554 brvcc->old_push = atmvcc->push;
555 barrier(); 555 barrier();
556 atmvcc->push = br2684_push; 556 atmvcc->push = br2684_push;
557 skb_queue_head_init(&copy); 557
558 skb_migrate(&sk_atm(atmvcc)->sk_receive_queue, &copy); 558 rq = &sk_atm(atmvcc)->sk_receive_queue;
559 while ((skb = skb_dequeue(&copy)) != NULL) { 559
560 spin_lock_irqsave(&rq->lock, flags);
561 if (skb_queue_empty(rq)) {
562 skb = NULL;
563 } else {
564 /* NULL terminate the list. */
565 rq->prev->next = NULL;
566 skb = rq->next;
567 }
568 rq->prev = rq->next = (struct sk_buff *)rq;
569 rq->qlen = 0;
570 spin_unlock_irqrestore(&rq->lock, flags);
571
572 while (skb) {
573 struct sk_buff *next = skb->next;
574
575 skb->next = skb->prev = NULL;
560 BRPRIV(skb->dev)->stats.rx_bytes -= skb->len; 576 BRPRIV(skb->dev)->stats.rx_bytes -= skb->len;
561 BRPRIV(skb->dev)->stats.rx_packets--; 577 BRPRIV(skb->dev)->stats.rx_packets--;
562 br2684_push(atmvcc, skb); 578 br2684_push(atmvcc, skb);
579
580 skb = next;
563 } 581 }
564 __module_get(THIS_MODULE); 582 __module_get(THIS_MODULE);
565 return 0; 583 return 0;
diff --git a/net/atm/clip.c b/net/atm/clip.c
index 7af2c411da82..5f8a1d222720 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -38,7 +38,6 @@
38 38
39#include "common.h" 39#include "common.h"
40#include "resources.h" 40#include "resources.h"
41#include "ipcommon.h"
42#include <net/atmclip.h> 41#include <net/atmclip.h>
43 42
44 43
@@ -54,7 +53,7 @@ static struct atm_vcc *atmarpd;
54static struct neigh_table clip_tbl; 53static struct neigh_table clip_tbl;
55static struct timer_list idle_timer; 54static struct timer_list idle_timer;
56 55
57static int to_atmarpd(enum atmarp_ctrl_type type, int itf, unsigned long ip) 56static int to_atmarpd(enum atmarp_ctrl_type type, int itf, __be32 ip)
58{ 57{
59 struct sock *sk; 58 struct sock *sk;
60 struct atmarp_ctrl *ctrl; 59 struct atmarp_ctrl *ctrl;
@@ -220,7 +219,7 @@ static void clip_push(struct atm_vcc *vcc, struct sk_buff *skb)
220 || memcmp(skb->data, llc_oui, sizeof (llc_oui))) 219 || memcmp(skb->data, llc_oui, sizeof (llc_oui)))
221 skb->protocol = htons(ETH_P_IP); 220 skb->protocol = htons(ETH_P_IP);
222 else { 221 else {
223 skb->protocol = ((u16 *) skb->data)[3]; 222 skb->protocol = ((__be16 *) skb->data)[3];
224 skb_pull(skb, RFC1483LLC_LEN); 223 skb_pull(skb, RFC1483LLC_LEN);
225 if (skb->protocol == htons(ETH_P_ARP)) { 224 if (skb->protocol == htons(ETH_P_ARP)) {
226 PRIV(skb->dev)->stats.rx_packets++; 225 PRIV(skb->dev)->stats.rx_packets++;
@@ -430,7 +429,7 @@ static int clip_start_xmit(struct sk_buff *skb, struct net_device *dev)
430 429
431 here = skb_push(skb, RFC1483LLC_LEN); 430 here = skb_push(skb, RFC1483LLC_LEN);
432 memcpy(here, llc_oui, sizeof(llc_oui)); 431 memcpy(here, llc_oui, sizeof(llc_oui));
433 ((u16 *) here)[3] = skb->protocol; 432 ((__be16 *) here)[3] = skb->protocol;
434 } 433 }
435 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); 434 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
436 ATM_SKB(skb)->atm_options = vcc->atm_options; 435 ATM_SKB(skb)->atm_options = vcc->atm_options;
@@ -469,8 +468,9 @@ static struct net_device_stats *clip_get_stats(struct net_device *dev)
469static int clip_mkip(struct atm_vcc *vcc, int timeout) 468static int clip_mkip(struct atm_vcc *vcc, int timeout)
470{ 469{
471 struct clip_vcc *clip_vcc; 470 struct clip_vcc *clip_vcc;
472 struct sk_buff_head copy;
473 struct sk_buff *skb; 471 struct sk_buff *skb;
472 struct sk_buff_head *rq;
473 unsigned long flags;
474 474
475 if (!vcc->push) 475 if (!vcc->push)
476 return -EBADFD; 476 return -EBADFD;
@@ -490,10 +490,26 @@ static int clip_mkip(struct atm_vcc *vcc, int timeout)
490 clip_vcc->old_pop = vcc->pop; 490 clip_vcc->old_pop = vcc->pop;
491 vcc->push = clip_push; 491 vcc->push = clip_push;
492 vcc->pop = clip_pop; 492 vcc->pop = clip_pop;
493 skb_queue_head_init(&copy); 493
494 skb_migrate(&sk_atm(vcc)->sk_receive_queue, &copy); 494 rq = &sk_atm(vcc)->sk_receive_queue;
495
496 spin_lock_irqsave(&rq->lock, flags);
497 if (skb_queue_empty(rq)) {
498 skb = NULL;
499 } else {
500 /* NULL terminate the list. */
501 rq->prev->next = NULL;
502 skb = rq->next;
503 }
504 rq->prev = rq->next = (struct sk_buff *)rq;
505 rq->qlen = 0;
506 spin_unlock_irqrestore(&rq->lock, flags);
507
495 /* re-process everything received between connection setup and MKIP */ 508 /* re-process everything received between connection setup and MKIP */
496 while ((skb = skb_dequeue(&copy)) != NULL) 509 while (skb) {
510 struct sk_buff *next = skb->next;
511
512 skb->next = skb->prev = NULL;
497 if (!clip_devs) { 513 if (!clip_devs) {
498 atm_return(vcc, skb->truesize); 514 atm_return(vcc, skb->truesize);
499 kfree_skb(skb); 515 kfree_skb(skb);
@@ -506,10 +522,13 @@ static int clip_mkip(struct atm_vcc *vcc, int timeout)
506 PRIV(skb->dev)->stats.rx_bytes -= len; 522 PRIV(skb->dev)->stats.rx_bytes -= len;
507 kfree_skb(skb); 523 kfree_skb(skb);
508 } 524 }
525
526 skb = next;
527 }
509 return 0; 528 return 0;
510} 529}
511 530
512static int clip_setentry(struct atm_vcc *vcc, u32 ip) 531static int clip_setentry(struct atm_vcc *vcc, __be32 ip)
513{ 532{
514 struct neighbour *neigh; 533 struct neighbour *neigh;
515 struct atmarp_entry *entry; 534 struct atmarp_entry *entry;
@@ -752,7 +771,7 @@ static int clip_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
752 err = clip_mkip(vcc, arg); 771 err = clip_mkip(vcc, arg);
753 break; 772 break;
754 case ATMARP_SETENTRY: 773 case ATMARP_SETENTRY:
755 err = clip_setentry(vcc, arg); 774 err = clip_setentry(vcc, (__force __be32)arg);
756 break; 775 break;
757 case ATMARP_ENCAP: 776 case ATMARP_ENCAP:
758 err = clip_encap(vcc, arg); 777 err = clip_encap(vcc, arg);
diff --git a/net/atm/ipcommon.c b/net/atm/ipcommon.c
deleted file mode 100644
index 1d3de42fada0..000000000000
--- a/net/atm/ipcommon.c
+++ /dev/null
@@ -1,63 +0,0 @@
1/* net/atm/ipcommon.c - Common items for all ways of doing IP over ATM */
2
3/* Written 1996-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#include <linux/module.h>
7#include <linux/string.h>
8#include <linux/skbuff.h>
9#include <linux/netdevice.h>
10#include <linux/in.h>
11#include <linux/atmdev.h>
12#include <linux/atmclip.h>
13
14#include "common.h"
15#include "ipcommon.h"
16
17
18#if 0
19#define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
20#else
21#define DPRINTK(format,args...)
22#endif
23
24
25/*
26 * skb_migrate appends the list at "from" to "to", emptying "from" in the
27 * process. skb_migrate is atomic with respect to all other skb operations on
28 * "from" and "to". Note that it locks both lists at the same time, so to deal
29 * with the lock ordering, the locks are taken in address order.
30 *
31 * This function should live in skbuff.c or skbuff.h.
32 */
33
34
35void skb_migrate(struct sk_buff_head *from, struct sk_buff_head *to)
36{
37 unsigned long flags;
38 struct sk_buff *skb_from = (struct sk_buff *) from;
39 struct sk_buff *skb_to = (struct sk_buff *) to;
40 struct sk_buff *prev;
41
42 if ((unsigned long) from < (unsigned long) to) {
43 spin_lock_irqsave(&from->lock, flags);
44 spin_lock_nested(&to->lock, SINGLE_DEPTH_NESTING);
45 } else {
46 spin_lock_irqsave(&to->lock, flags);
47 spin_lock_nested(&from->lock, SINGLE_DEPTH_NESTING);
48 }
49 prev = from->prev;
50 from->next->prev = to->prev;
51 prev->next = skb_to;
52 to->prev->next = from->next;
53 to->prev = from->prev;
54 to->qlen += from->qlen;
55 spin_unlock(&to->lock);
56 from->prev = skb_from;
57 from->next = skb_from;
58 from->qlen = 0;
59 spin_unlock_irqrestore(&from->lock, flags);
60}
61
62
63EXPORT_SYMBOL(skb_migrate);
diff --git a/net/atm/ipcommon.h b/net/atm/ipcommon.h
deleted file mode 100644
index d72165f60939..000000000000
--- a/net/atm/ipcommon.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/* net/atm/ipcommon.h - Common items for all ways of doing IP over ATM */
2
3/* Written 1996-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#ifndef NET_ATM_IPCOMMON_H
7#define NET_ATM_IPCOMMON_H
8
9
10#include <linux/string.h>
11#include <linux/skbuff.h>
12#include <linux/netdevice.h>
13#include <linux/atmdev.h>
14
15/*
16 * Appends all skbs from "from" to "to". The operation is atomic with respect
17 * to all other skb operations on "from" or "to".
18 */
19
20void skb_migrate(struct sk_buff_head *from,struct sk_buff_head *to);
21
22#endif
diff --git a/net/atm/lec.c b/net/atm/lec.c
index e801fff69dc0..3fc0abeeaf34 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -204,9 +204,9 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
204 memset(rdesc, 0, ETH_ALEN); 204 memset(rdesc, 0, ETH_ALEN);
205 /* offset 4 comes from LAN destination field in LE control frames */ 205 /* offset 4 comes from LAN destination field in LE control frames */
206 if (trh->rcf & htons((uint16_t) TR_RCF_DIR_BIT)) 206 if (trh->rcf & htons((uint16_t) TR_RCF_DIR_BIT))
207 memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(uint16_t)); 207 memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(__be16));
208 else { 208 else {
209 memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t)); 209 memcpy(&rdesc[4], &trh->rseg[1], sizeof(__be16));
210 rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0)); 210 rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0));
211 } 211 }
212 212
@@ -775,7 +775,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
775 unsigned char *src, *dst; 775 unsigned char *src, *dst;
776 776
777 atm_return(vcc, skb->truesize); 777 atm_return(vcc, skb->truesize);
778 if (*(uint16_t *) skb->data == htons(priv->lecid) || 778 if (*(__be16 *) skb->data == htons(priv->lecid) ||
779 !priv->lecd || !(dev->flags & IFF_UP)) { 779 !priv->lecd || !(dev->flags & IFF_UP)) {
780 /* 780 /*
781 * Probably looping back, or if lecd is missing, 781 * Probably looping back, or if lecd is missing,
@@ -1321,11 +1321,10 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
1321 if (table == NULL) 1321 if (table == NULL)
1322 return -1; 1322 return -1;
1323 1323
1324 *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC); 1324 *tlvs = kmemdup(table->tlvs, table->sizeoftlvs, GFP_ATOMIC);
1325 if (*tlvs == NULL) 1325 if (*tlvs == NULL)
1326 return -1; 1326 return -1;
1327 1327
1328 memcpy(*tlvs, table->tlvs, table->sizeoftlvs);
1329 *sizeoftlvs = table->sizeoftlvs; 1328 *sizeoftlvs = table->sizeoftlvs;
1330 1329
1331 return 0; 1330 return 0;
@@ -1364,11 +1363,10 @@ static int lane2_associate_req(struct net_device *dev, u8 *lan_dst,
1364 1363
1365 kfree(priv->tlvs); /* NULL if there was no previous association */ 1364 kfree(priv->tlvs); /* NULL if there was no previous association */
1366 1365
1367 priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); 1366 priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
1368 if (priv->tlvs == NULL) 1367 if (priv->tlvs == NULL)
1369 return (0); 1368 return (0);
1370 priv->sizeoftlvs = sizeoftlvs; 1369 priv->sizeoftlvs = sizeoftlvs;
1371 memcpy(priv->tlvs, tlvs, sizeoftlvs);
1372 1370
1373 skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); 1371 skb = alloc_skb(sizeoftlvs, GFP_ATOMIC);
1374 if (skb == NULL) 1372 if (skb == NULL)
@@ -1409,12 +1407,10 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
1409 1407
1410 kfree(entry->tlvs); 1408 kfree(entry->tlvs);
1411 1409
1412 entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); 1410 entry->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
1413 if (entry->tlvs == NULL) 1411 if (entry->tlvs == NULL)
1414 return; 1412 return;
1415
1416 entry->sizeoftlvs = sizeoftlvs; 1413 entry->sizeoftlvs = sizeoftlvs;
1417 memcpy(entry->tlvs, tlvs, sizeoftlvs);
1418#endif 1414#endif
1419#if 0 1415#if 0
1420 printk("lec.c: lane2_associate_ind()\n"); 1416 printk("lec.c: lane2_associate_ind()\n");
diff --git a/net/atm/lec.h b/net/atm/lec.h
index 984e8e6e083a..99136babd535 100644
--- a/net/atm/lec.h
+++ b/net/atm/lec.h
@@ -14,14 +14,14 @@
14#define LEC_HEADER_LEN 16 14#define LEC_HEADER_LEN 16
15 15
16struct lecdatahdr_8023 { 16struct lecdatahdr_8023 {
17 unsigned short le_header; 17 __be16 le_header;
18 unsigned char h_dest[ETH_ALEN]; 18 unsigned char h_dest[ETH_ALEN];
19 unsigned char h_source[ETH_ALEN]; 19 unsigned char h_source[ETH_ALEN];
20 unsigned short h_type; 20 __be16 h_type;
21}; 21};
22 22
23struct lecdatahdr_8025 { 23struct lecdatahdr_8025 {
24 unsigned short le_header; 24 __be16 le_header;
25 unsigned char ac_pad; 25 unsigned char ac_pad;
26 unsigned char fc; 26 unsigned char fc;
27 unsigned char h_dest[ETH_ALEN]; 27 unsigned char h_dest[ETH_ALEN];
diff --git a/net/atm/mpc.c b/net/atm/mpc.c
index 0d2b994af511..c18f73715ef9 100644
--- a/net/atm/mpc.c
+++ b/net/atm/mpc.c
@@ -152,7 +152,7 @@ static struct mpoa_client *find_mpc_by_lec(struct net_device *dev)
152/* 152/*
153 * Overwrites the old entry or makes a new one. 153 * Overwrites the old entry or makes a new one.
154 */ 154 */
155struct atm_mpoa_qos *atm_mpoa_add_qos(uint32_t dst_ip, struct atm_qos *qos) 155struct atm_mpoa_qos *atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos)
156{ 156{
157 struct atm_mpoa_qos *entry; 157 struct atm_mpoa_qos *entry;
158 158
@@ -177,7 +177,7 @@ struct atm_mpoa_qos *atm_mpoa_add_qos(uint32_t dst_ip, struct atm_qos *qos)
177 return entry; 177 return entry;
178} 178}
179 179
180struct atm_mpoa_qos *atm_mpoa_search_qos(uint32_t dst_ip) 180struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip)
181{ 181{
182 struct atm_mpoa_qos *qos; 182 struct atm_mpoa_qos *qos;
183 183
@@ -460,11 +460,11 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc)
460 in_cache_entry *entry; 460 in_cache_entry *entry;
461 struct iphdr *iph; 461 struct iphdr *iph;
462 char *buff; 462 char *buff;
463 uint32_t ipaddr = 0; 463 __be32 ipaddr = 0;
464 464
465 static struct { 465 static struct {
466 struct llc_snap_hdr hdr; 466 struct llc_snap_hdr hdr;
467 uint32_t tag; 467 __be32 tag;
468 } tagged_llc_snap_hdr = { 468 } tagged_llc_snap_hdr = {
469 {0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}, {0x88, 0x4c}}, 469 {0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}, {0x88, 0x4c}},
470 0 470 0
@@ -559,7 +559,7 @@ static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg)
559 struct mpoa_client *mpc; 559 struct mpoa_client *mpc;
560 struct atmmpc_ioc ioc_data; 560 struct atmmpc_ioc ioc_data;
561 in_cache_entry *in_entry; 561 in_cache_entry *in_entry;
562 uint32_t ipaddr; 562 __be32 ipaddr;
563 563
564 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc)); 564 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc));
565 if (bytes_left != 0) { 565 if (bytes_left != 0) {
@@ -638,7 +638,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)
638 struct sk_buff *new_skb; 638 struct sk_buff *new_skb;
639 eg_cache_entry *eg; 639 eg_cache_entry *eg;
640 struct mpoa_client *mpc; 640 struct mpoa_client *mpc;
641 uint32_t tag; 641 __be32 tag;
642 char *tmp; 642 char *tmp;
643 643
644 ddprintk("mpoa: (%s) mpc_push:\n", dev->name); 644 ddprintk("mpoa: (%s) mpc_push:\n", dev->name);
@@ -683,7 +683,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb)
683 } 683 }
684 684
685 tmp = skb->data + sizeof(struct llc_snap_hdr); 685 tmp = skb->data + sizeof(struct llc_snap_hdr);
686 tag = *(uint32_t *)tmp; 686 tag = *(__be32 *)tmp;
687 687
688 eg = mpc->eg_ops->get_by_tag(tag, mpc); 688 eg = mpc->eg_ops->get_by_tag(tag, mpc);
689 if (eg == NULL) { 689 if (eg == NULL) {
@@ -1029,7 +1029,7 @@ static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned lo
1029 1029
1030static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) 1030static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1031{ 1031{
1032 uint32_t dst_ip = msg->content.in_info.in_dst_ip; 1032 __be32 dst_ip = msg->content.in_info.in_dst_ip;
1033 in_cache_entry *entry; 1033 in_cache_entry *entry;
1034 1034
1035 entry = mpc->in_ops->get(dst_ip, mpc); 1035 entry = mpc->in_ops->get(dst_ip, mpc);
@@ -1066,7 +1066,7 @@ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1066 */ 1066 */
1067static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_client *client, in_cache_entry *entry) 1067static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_client *client, in_cache_entry *entry)
1068{ 1068{
1069 uint32_t dst_ip = msg->content.in_info.in_dst_ip; 1069 __be32 dst_ip = msg->content.in_info.in_dst_ip;
1070 struct atm_mpoa_qos *qos = atm_mpoa_search_qos(dst_ip); 1070 struct atm_mpoa_qos *qos = atm_mpoa_search_qos(dst_ip);
1071 eg_cache_entry *eg_entry = client->eg_ops->get_by_src_ip(dst_ip, client); 1071 eg_cache_entry *eg_entry = client->eg_ops->get_by_src_ip(dst_ip, client);
1072 1072
@@ -1102,7 +1102,7 @@ static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_clien
1102 1102
1103static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc) 1103static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1104{ 1104{
1105 uint32_t dst_ip = msg->content.in_info.in_dst_ip; 1105 __be32 dst_ip = msg->content.in_info.in_dst_ip;
1106 in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc); 1106 in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc);
1107 1107
1108 dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %u.%u.%u.%u\n", mpc->dev->name, NIPQUAD(dst_ip)); 1108 dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %u.%u.%u.%u\n", mpc->dev->name, NIPQUAD(dst_ip));
@@ -1148,8 +1148,8 @@ static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1148 1148
1149static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) 1149static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1150{ 1150{
1151 uint32_t dst_ip = msg->content.in_info.in_dst_ip; 1151 __be32 dst_ip = msg->content.in_info.in_dst_ip;
1152 uint32_t mask = msg->ip_mask; 1152 __be32 mask = msg->ip_mask;
1153 in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); 1153 in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask);
1154 1154
1155 if(entry == NULL){ 1155 if(entry == NULL){
@@ -1173,7 +1173,7 @@ static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1173 1173
1174static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) 1174static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc)
1175{ 1175{
1176 uint32_t cache_id = msg->content.eg_info.cache_id; 1176 __be32 cache_id = msg->content.eg_info.cache_id;
1177 eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(cache_id, mpc); 1177 eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(cache_id, mpc);
1178 1178
1179 if (entry == NULL) { 1179 if (entry == NULL) {
@@ -1322,13 +1322,12 @@ static void set_mps_mac_addr_rcvd(struct k_message *msg, struct mpoa_client *cli
1322 if(client->number_of_mps_macs) 1322 if(client->number_of_mps_macs)
1323 kfree(client->mps_macs); 1323 kfree(client->mps_macs);
1324 client->number_of_mps_macs = 0; 1324 client->number_of_mps_macs = 0;
1325 client->mps_macs = kmalloc(ETH_ALEN,GFP_KERNEL); 1325 client->mps_macs = kmemdup(msg->MPS_ctrl, ETH_ALEN, GFP_KERNEL);
1326 if (client->mps_macs == NULL) { 1326 if (client->mps_macs == NULL) {
1327 printk("mpoa: set_mps_mac_addr_rcvd: out of memory\n"); 1327 printk("mpoa: set_mps_mac_addr_rcvd: out of memory\n");
1328 return; 1328 return;
1329 } 1329 }
1330 client->number_of_mps_macs = 1; 1330 client->number_of_mps_macs = 1;
1331 memcpy(client->mps_macs, msg->MPS_ctrl, ETH_ALEN);
1332 1331
1333 return; 1332 return;
1334} 1333}
diff --git a/net/atm/mpc.h b/net/atm/mpc.h
index 3c7981a229e8..51f460d005c3 100644
--- a/net/atm/mpc.h
+++ b/net/atm/mpc.h
@@ -36,14 +36,14 @@ struct mpoa_client {
36 36
37struct atm_mpoa_qos { 37struct atm_mpoa_qos {
38 struct atm_mpoa_qos *next; 38 struct atm_mpoa_qos *next;
39 uint32_t ipaddr; 39 __be32 ipaddr;
40 struct atm_qos qos; 40 struct atm_qos qos;
41}; 41};
42 42
43 43
44/* MPOA QoS operations */ 44/* MPOA QoS operations */
45struct atm_mpoa_qos *atm_mpoa_add_qos(uint32_t dst_ip, struct atm_qos *qos); 45struct atm_mpoa_qos *atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos);
46struct atm_mpoa_qos *atm_mpoa_search_qos(uint32_t dst_ip); 46struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip);
47int atm_mpoa_delete_qos(struct atm_mpoa_qos *qos); 47int atm_mpoa_delete_qos(struct atm_mpoa_qos *qos);
48 48
49/* Display QoS entries. This is for the procfs */ 49/* Display QoS entries. This is for the procfs */
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c
index fbf13cdcf46e..697a081533b5 100644
--- a/net/atm/mpoa_caches.c
+++ b/net/atm/mpoa_caches.c
@@ -22,7 +22,7 @@
22#define ddprintk(format,args...) 22#define ddprintk(format,args...)
23#endif 23#endif
24 24
25static in_cache_entry *in_cache_get(uint32_t dst_ip, 25static in_cache_entry *in_cache_get(__be32 dst_ip,
26 struct mpoa_client *client) 26 struct mpoa_client *client)
27{ 27{
28 in_cache_entry *entry; 28 in_cache_entry *entry;
@@ -42,9 +42,9 @@ static in_cache_entry *in_cache_get(uint32_t dst_ip,
42 return NULL; 42 return NULL;
43} 43}
44 44
45static in_cache_entry *in_cache_get_with_mask(uint32_t dst_ip, 45static in_cache_entry *in_cache_get_with_mask(__be32 dst_ip,
46 struct mpoa_client *client, 46 struct mpoa_client *client,
47 uint32_t mask) 47 __be32 mask)
48{ 48{
49 in_cache_entry *entry; 49 in_cache_entry *entry;
50 50
@@ -84,10 +84,10 @@ static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc,
84 return NULL; 84 return NULL;
85} 85}
86 86
87static in_cache_entry *in_cache_add_entry(uint32_t dst_ip, 87static in_cache_entry *in_cache_add_entry(__be32 dst_ip,
88 struct mpoa_client *client) 88 struct mpoa_client *client)
89{ 89{
90 in_cache_entry* entry = kmalloc(sizeof(in_cache_entry), GFP_KERNEL); 90 in_cache_entry *entry = kzalloc(sizeof(in_cache_entry), GFP_KERNEL);
91 91
92 if (entry == NULL) { 92 if (entry == NULL) {
93 printk("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n"); 93 printk("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n");
@@ -95,7 +95,6 @@ static in_cache_entry *in_cache_add_entry(uint32_t dst_ip,
95 } 95 }
96 96
97 dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip)); 97 dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip));
98 memset(entry,0,sizeof(in_cache_entry));
99 98
100 atomic_set(&entry->use, 1); 99 atomic_set(&entry->use, 1);
101 dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n"); 100 dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n");
@@ -319,7 +318,7 @@ static void in_destroy_cache(struct mpoa_client *mpc)
319 return; 318 return;
320} 319}
321 320
322static eg_cache_entry *eg_cache_get_by_cache_id(uint32_t cache_id, struct mpoa_client *mpc) 321static eg_cache_entry *eg_cache_get_by_cache_id(__be32 cache_id, struct mpoa_client *mpc)
323{ 322{
324 eg_cache_entry *entry; 323 eg_cache_entry *entry;
325 324
@@ -339,7 +338,7 @@ static eg_cache_entry *eg_cache_get_by_cache_id(uint32_t cache_id, struct mpoa_c
339} 338}
340 339
341/* This can be called from any context since it saves CPU flags */ 340/* This can be called from any context since it saves CPU flags */
342static eg_cache_entry *eg_cache_get_by_tag(uint32_t tag, struct mpoa_client *mpc) 341static eg_cache_entry *eg_cache_get_by_tag(__be32 tag, struct mpoa_client *mpc)
343{ 342{
344 unsigned long flags; 343 unsigned long flags;
345 eg_cache_entry *entry; 344 eg_cache_entry *entry;
@@ -380,7 +379,7 @@ static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, struct mpoa_clie
380 return NULL; 379 return NULL;
381} 380}
382 381
383static eg_cache_entry *eg_cache_get_by_src_ip(uint32_t ipaddr, struct mpoa_client *mpc) 382static eg_cache_entry *eg_cache_get_by_src_ip(__be32 ipaddr, struct mpoa_client *mpc)
384{ 383{
385 eg_cache_entry *entry; 384 eg_cache_entry *entry;
386 385
@@ -447,7 +446,7 @@ static void eg_cache_remove_entry(eg_cache_entry *entry,
447 446
448static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_client *client) 447static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_client *client)
449{ 448{
450 eg_cache_entry *entry = kmalloc(sizeof(eg_cache_entry), GFP_KERNEL); 449 eg_cache_entry *entry = kzalloc(sizeof(eg_cache_entry), GFP_KERNEL);
451 450
452 if (entry == NULL) { 451 if (entry == NULL) {
453 printk("mpoa: mpoa_caches.c: new_eg_cache_entry: out of memory\n"); 452 printk("mpoa: mpoa_caches.c: new_eg_cache_entry: out of memory\n");
@@ -455,7 +454,6 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_cli
455 } 454 }
456 455
457 dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %u.%u.%u.%u, this should be our IP\n", NIPQUAD(msg->content.eg_info.eg_dst_ip)); 456 dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %u.%u.%u.%u, this should be our IP\n", NIPQUAD(msg->content.eg_info.eg_dst_ip));
458 memset(entry, 0, sizeof(eg_cache_entry));
459 457
460 atomic_set(&entry->use, 1); 458 atomic_set(&entry->use, 1);
461 dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n"); 459 dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n");
diff --git a/net/atm/mpoa_caches.h b/net/atm/mpoa_caches.h
index 6c9886a03d0b..84de977def2e 100644
--- a/net/atm/mpoa_caches.h
+++ b/net/atm/mpoa_caches.h
@@ -29,12 +29,12 @@ typedef struct in_cache_entry {
29} in_cache_entry; 29} in_cache_entry;
30 30
31struct in_cache_ops{ 31struct in_cache_ops{
32 in_cache_entry *(*add_entry)(uint32_t dst_ip, 32 in_cache_entry *(*add_entry)(__be32 dst_ip,
33 struct mpoa_client *client); 33 struct mpoa_client *client);
34 in_cache_entry *(*get)(uint32_t dst_ip, struct mpoa_client *client); 34 in_cache_entry *(*get)(__be32 dst_ip, struct mpoa_client *client);
35 in_cache_entry *(*get_with_mask)(uint32_t dst_ip, 35 in_cache_entry *(*get_with_mask)(__be32 dst_ip,
36 struct mpoa_client *client, 36 struct mpoa_client *client,
37 uint32_t mask); 37 __be32 mask);
38 in_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, 38 in_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc,
39 struct mpoa_client *client); 39 struct mpoa_client *client);
40 void (*put)(in_cache_entry *entry); 40 void (*put)(in_cache_entry *entry);
@@ -56,17 +56,17 @@ typedef struct eg_cache_entry{
56 struct atm_vcc *shortcut; 56 struct atm_vcc *shortcut;
57 uint32_t packets_rcvd; 57 uint32_t packets_rcvd;
58 uint16_t entry_state; 58 uint16_t entry_state;
59 uint32_t latest_ip_addr; /* The src IP address of the last packet */ 59 __be32 latest_ip_addr; /* The src IP address of the last packet */
60 struct eg_ctrl_info ctrl_info; 60 struct eg_ctrl_info ctrl_info;
61 atomic_t use; 61 atomic_t use;
62} eg_cache_entry; 62} eg_cache_entry;
63 63
64struct eg_cache_ops{ 64struct eg_cache_ops{
65 eg_cache_entry *(*add_entry)(struct k_message *msg, struct mpoa_client *client); 65 eg_cache_entry *(*add_entry)(struct k_message *msg, struct mpoa_client *client);
66 eg_cache_entry *(*get_by_cache_id)(uint32_t cache_id, struct mpoa_client *client); 66 eg_cache_entry *(*get_by_cache_id)(__be32 cache_id, struct mpoa_client *client);
67 eg_cache_entry *(*get_by_tag)(uint32_t cache_id, struct mpoa_client *client); 67 eg_cache_entry *(*get_by_tag)(__be32 cache_id, struct mpoa_client *client);
68 eg_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, struct mpoa_client *client); 68 eg_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, struct mpoa_client *client);
69 eg_cache_entry *(*get_by_src_ip)(uint32_t ipaddr, struct mpoa_client *client); 69 eg_cache_entry *(*get_by_src_ip)(__be32 ipaddr, struct mpoa_client *client);
70 void (*put)(eg_cache_entry *entry); 70 void (*put)(eg_cache_entry *entry);
71 void (*remove_entry)(eg_cache_entry *entry, struct mpoa_client *client); 71 void (*remove_entry)(eg_cache_entry *entry, struct mpoa_client *client);
72 void (*update)(eg_cache_entry *entry, uint16_t holding_time); 72 void (*update)(eg_cache_entry *entry, uint16_t holding_time);
diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index d37b8911b3ab..3844c85d602f 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -231,14 +231,14 @@ static int parse_qos(const char *buff)
231 */ 231 */
232 unsigned char ip[4]; 232 unsigned char ip[4];
233 int tx_pcr, tx_sdu, rx_pcr, rx_sdu; 233 int tx_pcr, tx_sdu, rx_pcr, rx_sdu;
234 uint32_t ipaddr; 234 __be32 ipaddr;
235 struct atm_qos qos; 235 struct atm_qos qos;
236 236
237 memset(&qos, 0, sizeof(struct atm_qos)); 237 memset(&qos, 0, sizeof(struct atm_qos));
238 238
239 if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu", 239 if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu",
240 ip, ip+1, ip+2, ip+3) == 4) { 240 ip, ip+1, ip+2, ip+3) == 4) {
241 ipaddr = *(uint32_t *)ip; 241 ipaddr = *(__be32 *)ip;
242 return atm_mpoa_delete_qos(atm_mpoa_search_qos(ipaddr)); 242 return atm_mpoa_delete_qos(atm_mpoa_search_qos(ipaddr));
243 } 243 }
244 244
@@ -250,7 +250,7 @@ static int parse_qos(const char *buff)
250 ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8) 250 ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
251 return 0; 251 return 0;
252 252
253 ipaddr = *(uint32_t *)ip; 253 ipaddr = *(__be32 *)ip;
254 qos.txtp.traffic_class = ATM_CBR; 254 qos.txtp.traffic_class = ATM_CBR;
255 qos.txtp.max_pcr = tx_pcr; 255 qos.txtp.max_pcr = tx_pcr;
256 qos.txtp.max_sdu = tx_sdu; 256 qos.txtp.max_sdu = tx_sdu;
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 000695c48583..6cabf6d8a751 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -906,13 +906,13 @@ struct sock *ax25_make_new(struct sock *osk, struct ax25_dev *ax25_dev)
906 ax25->source_addr = oax25->source_addr; 906 ax25->source_addr = oax25->source_addr;
907 907
908 if (oax25->digipeat != NULL) { 908 if (oax25->digipeat != NULL) {
909 if ((ax25->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { 909 ax25->digipeat = kmemdup(oax25->digipeat, sizeof(ax25_digi),
910 GFP_ATOMIC);
911 if (ax25->digipeat == NULL) {
910 sk_free(sk); 912 sk_free(sk);
911 ax25_cb_put(ax25); 913 ax25_cb_put(ax25);
912 return NULL; 914 return NULL;
913 } 915 }
914
915 memcpy(ax25->digipeat, oax25->digipeat, sizeof(ax25_digi));
916 } 916 }
917 917
918 sk->sk_protinfo = ax25; 918 sk->sk_protinfo = ax25;
diff --git a/net/ax25/ax25_out.c b/net/ax25/ax25_out.c
index d7736e585336..f84047d1e8ce 100644
--- a/net/ax25/ax25_out.c
+++ b/net/ax25/ax25_out.c
@@ -70,11 +70,11 @@ ax25_cb *ax25_send_frame(struct sk_buff *skb, int paclen, ax25_address *src, ax2
70 ax25->dest_addr = *dest; 70 ax25->dest_addr = *dest;
71 71
72 if (digi != NULL) { 72 if (digi != NULL) {
73 if ((ax25->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { 73 ax25->digipeat = kmemdup(digi, sizeof(*digi), GFP_ATOMIC);
74 if (ax25->digipeat == NULL) {
74 ax25_cb_put(ax25); 75 ax25_cb_put(ax25);
75 return NULL; 76 return NULL;
76 } 77 }
77 memcpy(ax25->digipeat, digi, sizeof(ax25_digi));
78 } 78 }
79 79
80 switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) { 80 switch (ax25->ax25_dev->values[AX25_VALUES_PROTOCOL]) {
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
index 51b7bdaf27eb..8580356ace5c 100644
--- a/net/ax25/ax25_route.c
+++ b/net/ax25/ax25_route.c
@@ -432,11 +432,12 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr)
432 } 432 }
433 433
434 if (ax25_rt->digipeat != NULL) { 434 if (ax25_rt->digipeat != NULL) {
435 if ((ax25->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { 435 ax25->digipeat = kmemdup(ax25_rt->digipeat, sizeof(ax25_digi),
436 GFP_ATOMIC);
437 if (ax25->digipeat == NULL) {
436 err = -ENOMEM; 438 err = -ENOMEM;
437 goto put; 439 goto put;
438 } 440 }
439 memcpy(ax25->digipeat, ax25_rt->digipeat, sizeof(ax25_digi));
440 ax25_adjust_path(addr, ax25->digipeat); 441 ax25_adjust_path(addr, ax25->digipeat);
441 } 442 }
442 443
diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
index 867d42537979..d23a27f25d2f 100644
--- a/net/ax25/sysctl_net_ax25.c
+++ b/net/ax25/sysctl_net_ax25.c
@@ -209,7 +209,9 @@ void ax25_register_sysctl(void)
209 } 209 }
210 210
211 for (n = 0, ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next) { 211 for (n = 0, ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next) {
212 ctl_table *child = kmalloc(sizeof(ax25_param_table), GFP_ATOMIC); 212 struct ctl_table *child = kmemdup(ax25_param_table,
213 sizeof(ax25_param_table),
214 GFP_ATOMIC);
213 if (!child) { 215 if (!child) {
214 while (n--) 216 while (n--)
215 kfree(ax25_table[n].child); 217 kfree(ax25_table[n].child);
@@ -217,7 +219,6 @@ void ax25_register_sysctl(void)
217 spin_unlock_bh(&ax25_dev_lock); 219 spin_unlock_bh(&ax25_dev_lock);
218 return; 220 return;
219 } 221 }
220 memcpy(child, ax25_param_table, sizeof(ax25_param_table));
221 ax25_table[n].child = ax25_dev->systable = child; 222 ax25_table[n].child = ax25_dev->systable = child;
222 ax25_table[n].ctl_name = n + 1; 223 ax25_table[n].ctl_name = n + 1;
223 ax25_table[n].procname = ax25_dev->dev->name; 224 ax25_table[n].procname = ax25_dev->dev->name;
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h
index bbb1ed7097a9..0b6cd0e2528d 100644
--- a/net/bluetooth/bnep/bnep.h
+++ b/net/bluetooth/bnep/bnep.h
@@ -95,14 +95,14 @@ struct bnep_setup_conn_req {
95struct bnep_set_filter_req { 95struct bnep_set_filter_req {
96 __u8 type; 96 __u8 type;
97 __u8 ctrl; 97 __u8 ctrl;
98 __u16 len; 98 __be16 len;
99 __u8 list[0]; 99 __u8 list[0];
100} __attribute__((packed)); 100} __attribute__((packed));
101 101
102struct bnep_control_rsp { 102struct bnep_control_rsp {
103 __u8 type; 103 __u8 type;
104 __u8 ctrl; 104 __u8 ctrl;
105 __u16 resp; 105 __be16 resp;
106} __attribute__((packed)); 106} __attribute__((packed));
107 107
108struct bnep_ext_hdr { 108struct bnep_ext_hdr {
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 4d3424c2421c..7ba6470dc507 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -117,18 +117,18 @@ static int bnep_send_rsp(struct bnep_session *s, u8 ctrl, u16 resp)
117static inline void bnep_set_default_proto_filter(struct bnep_session *s) 117static inline void bnep_set_default_proto_filter(struct bnep_session *s)
118{ 118{
119 /* (IPv4, ARP) */ 119 /* (IPv4, ARP) */
120 s->proto_filter[0].start = htons(0x0800); 120 s->proto_filter[0].start = ETH_P_IP;
121 s->proto_filter[0].end = htons(0x0806); 121 s->proto_filter[0].end = ETH_P_ARP;
122 /* (RARP, AppleTalk) */ 122 /* (RARP, AppleTalk) */
123 s->proto_filter[1].start = htons(0x8035); 123 s->proto_filter[1].start = ETH_P_RARP;
124 s->proto_filter[1].end = htons(0x80F3); 124 s->proto_filter[1].end = ETH_P_AARP;
125 /* (IPX, IPv6) */ 125 /* (IPX, IPv6) */
126 s->proto_filter[2].start = htons(0x8137); 126 s->proto_filter[2].start = ETH_P_IPX;
127 s->proto_filter[2].end = htons(0x86DD); 127 s->proto_filter[2].end = ETH_P_IPV6;
128} 128}
129#endif 129#endif
130 130
131static int bnep_ctrl_set_netfilter(struct bnep_session *s, u16 *data, int len) 131static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len)
132{ 132{
133 int n; 133 int n;
134 134
@@ -150,8 +150,8 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, u16 *data, int len)
150 int i; 150 int i;
151 151
152 for (i = 0; i < n; i++) { 152 for (i = 0; i < n; i++) {
153 f[i].start = get_unaligned(data++); 153 f[i].start = ntohs(get_unaligned(data++));
154 f[i].end = get_unaligned(data++); 154 f[i].end = ntohs(get_unaligned(data++));
155 155
156 BT_DBG("proto filter start %d end %d", 156 BT_DBG("proto filter start %d end %d",
157 f[i].start, f[i].end); 157 f[i].start, f[i].end);
@@ -180,7 +180,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
180 if (len < 2) 180 if (len < 2)
181 return -EILSEQ; 181 return -EILSEQ;
182 182
183 n = ntohs(get_unaligned((u16 *) data)); 183 n = ntohs(get_unaligned((__be16 *) data));
184 data += 2; len -= 2; 184 data += 2; len -= 2;
185 185
186 if (len < n) 186 if (len < n)
@@ -332,7 +332,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
332 if (!skb_pull(skb, __bnep_rx_hlen[type & BNEP_TYPE_MASK])) 332 if (!skb_pull(skb, __bnep_rx_hlen[type & BNEP_TYPE_MASK]))
333 goto badframe; 333 goto badframe;
334 334
335 s->eh.h_proto = get_unaligned((u16 *) (skb->data - 2)); 335 s->eh.h_proto = get_unaligned((__be16 *) (skb->data - 2));
336 336
337 if (type & BNEP_EXT_HEADER) { 337 if (type & BNEP_EXT_HEADER) {
338 if (bnep_rx_extension(s, skb) < 0) 338 if (bnep_rx_extension(s, skb) < 0)
@@ -343,7 +343,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
343 if (ntohs(s->eh.h_proto) == 0x8100) { 343 if (ntohs(s->eh.h_proto) == 0x8100) {
344 if (!skb_pull(skb, 4)) 344 if (!skb_pull(skb, 4))
345 goto badframe; 345 goto badframe;
346 s->eh.h_proto = get_unaligned((u16 *) (skb->data - 2)); 346 s->eh.h_proto = get_unaligned((__be16 *) (skb->data - 2));
347 } 347 }
348 348
349 /* We have to alloc new skb and copy data here :(. Because original skb 349 /* We have to alloc new skb and copy data here :(. Because original skb
@@ -365,7 +365,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
365 case BNEP_COMPRESSED_SRC_ONLY: 365 case BNEP_COMPRESSED_SRC_ONLY:
366 memcpy(__skb_put(nskb, ETH_ALEN), s->eh.h_dest, ETH_ALEN); 366 memcpy(__skb_put(nskb, ETH_ALEN), s->eh.h_dest, ETH_ALEN);
367 memcpy(__skb_put(nskb, ETH_ALEN), skb->mac.raw, ETH_ALEN); 367 memcpy(__skb_put(nskb, ETH_ALEN), skb->mac.raw, ETH_ALEN);
368 put_unaligned(s->eh.h_proto, (u16 *) __skb_put(nskb, 2)); 368 put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2));
369 break; 369 break;
370 370
371 case BNEP_COMPRESSED_DST_ONLY: 371 case BNEP_COMPRESSED_DST_ONLY:
@@ -375,7 +375,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
375 375
376 case BNEP_GENERAL: 376 case BNEP_GENERAL:
377 memcpy(__skb_put(nskb, ETH_ALEN * 2), skb->mac.raw, ETH_ALEN * 2); 377 memcpy(__skb_put(nskb, ETH_ALEN * 2), skb->mac.raw, ETH_ALEN * 2);
378 put_unaligned(s->eh.h_proto, (u16 *) __skb_put(nskb, 2)); 378 put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2));
379 break; 379 break;
380 } 380 }
381 381
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c
index 7f7b27db6a8f..67a002a9751a 100644
--- a/net/bluetooth/bnep/netdev.c
+++ b/net/bluetooth/bnep/netdev.c
@@ -158,14 +158,15 @@ static inline int bnep_net_mc_filter(struct sk_buff *skb, struct bnep_session *s
158static inline u16 bnep_net_eth_proto(struct sk_buff *skb) 158static inline u16 bnep_net_eth_proto(struct sk_buff *skb)
159{ 159{
160 struct ethhdr *eh = (void *) skb->data; 160 struct ethhdr *eh = (void *) skb->data;
161 u16 proto = ntohs(eh->h_proto);
161 162
162 if (ntohs(eh->h_proto) >= 1536) 163 if (proto >= 1536)
163 return eh->h_proto; 164 return proto;
164 165
165 if (get_unaligned((u16 *) skb->data) == 0xFFFF) 166 if (get_unaligned((__be16 *) skb->data) == htons(0xFFFF))
166 return htons(ETH_P_802_3); 167 return ETH_P_802_3;
167 168
168 return htons(ETH_P_802_2); 169 return ETH_P_802_2;
169} 170}
170 171
171static inline int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session *s) 172static inline int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session *s)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index bbf78e6a7bc3..29a8fa4d3728 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -770,7 +770,7 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl
770 long timeo; 770 long timeo;
771 int err = 0; 771 int err = 0;
772 772
773 lock_sock(sk); 773 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
774 774
775 if (sk->sk_state != BT_LISTEN) { 775 if (sk->sk_state != BT_LISTEN) {
776 err = -EBADFD; 776 err = -EBADFD;
@@ -792,7 +792,7 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl
792 792
793 release_sock(sk); 793 release_sock(sk);
794 timeo = schedule_timeout(timeo); 794 timeo = schedule_timeout(timeo);
795 lock_sock(sk); 795 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
796 796
797 if (sk->sk_state != BT_LISTEN) { 797 if (sk->sk_state != BT_LISTEN) {
798 err = -EBADFD; 798 err = -EBADFD;
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index ddc4e9d5963e..278c8676906a 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -854,7 +854,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
854 rpn->flow_ctrl = flow_ctrl_settings; 854 rpn->flow_ctrl = flow_ctrl_settings;
855 rpn->xon_char = xon_char; 855 rpn->xon_char = xon_char;
856 rpn->xoff_char = xoff_char; 856 rpn->xoff_char = xoff_char;
857 rpn->param_mask = param_mask; 857 rpn->param_mask = cpu_to_le16(param_mask);
858 858
859 *ptr = __fcs(buf); ptr++; 859 *ptr = __fcs(buf); ptr++;
860 860
@@ -1018,7 +1018,7 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr)
1018 1018
1019 if (len > 127) { 1019 if (len > 127) {
1020 hdr = (void *) skb_push(skb, 4); 1020 hdr = (void *) skb_push(skb, 4);
1021 put_unaligned(htobs(__len16(len)), (u16 *) &hdr->len); 1021 put_unaligned(htobs(__len16(len)), (__le16 *) &hdr->len);
1022 } else { 1022 } else {
1023 hdr = (void *) skb_push(skb, 3); 1023 hdr = (void *) skb_push(skb, 3);
1024 hdr->len = __len8(len); 1024 hdr->len = __len8(len);
@@ -1343,7 +1343,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1343 /* Check for sane values, ignore/accept bit_rate, 8 bits, 1 stop bit, 1343 /* Check for sane values, ignore/accept bit_rate, 8 bits, 1 stop bit,
1344 * no parity, no flow control lines, normal XON/XOFF chars */ 1344 * no parity, no flow control lines, normal XON/XOFF chars */
1345 1345
1346 if (rpn->param_mask & RFCOMM_RPN_PM_BITRATE) { 1346 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_BITRATE)) {
1347 bit_rate = rpn->bit_rate; 1347 bit_rate = rpn->bit_rate;
1348 if (bit_rate != RFCOMM_RPN_BR_115200) { 1348 if (bit_rate != RFCOMM_RPN_BR_115200) {
1349 BT_DBG("RPN bit rate mismatch 0x%x", bit_rate); 1349 BT_DBG("RPN bit rate mismatch 0x%x", bit_rate);
@@ -1352,7 +1352,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1352 } 1352 }
1353 } 1353 }
1354 1354
1355 if (rpn->param_mask & RFCOMM_RPN_PM_DATA) { 1355 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_DATA)) {
1356 data_bits = __get_rpn_data_bits(rpn->line_settings); 1356 data_bits = __get_rpn_data_bits(rpn->line_settings);
1357 if (data_bits != RFCOMM_RPN_DATA_8) { 1357 if (data_bits != RFCOMM_RPN_DATA_8) {
1358 BT_DBG("RPN data bits mismatch 0x%x", data_bits); 1358 BT_DBG("RPN data bits mismatch 0x%x", data_bits);
@@ -1361,7 +1361,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1361 } 1361 }
1362 } 1362 }
1363 1363
1364 if (rpn->param_mask & RFCOMM_RPN_PM_STOP) { 1364 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_STOP)) {
1365 stop_bits = __get_rpn_stop_bits(rpn->line_settings); 1365 stop_bits = __get_rpn_stop_bits(rpn->line_settings);
1366 if (stop_bits != RFCOMM_RPN_STOP_1) { 1366 if (stop_bits != RFCOMM_RPN_STOP_1) {
1367 BT_DBG("RPN stop bits mismatch 0x%x", stop_bits); 1367 BT_DBG("RPN stop bits mismatch 0x%x", stop_bits);
@@ -1370,7 +1370,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1370 } 1370 }
1371 } 1371 }
1372 1372
1373 if (rpn->param_mask & RFCOMM_RPN_PM_PARITY) { 1373 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_PARITY)) {
1374 parity = __get_rpn_parity(rpn->line_settings); 1374 parity = __get_rpn_parity(rpn->line_settings);
1375 if (parity != RFCOMM_RPN_PARITY_NONE) { 1375 if (parity != RFCOMM_RPN_PARITY_NONE) {
1376 BT_DBG("RPN parity mismatch 0x%x", parity); 1376 BT_DBG("RPN parity mismatch 0x%x", parity);
@@ -1379,7 +1379,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1379 } 1379 }
1380 } 1380 }
1381 1381
1382 if (rpn->param_mask & RFCOMM_RPN_PM_FLOW) { 1382 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_FLOW)) {
1383 flow_ctrl = rpn->flow_ctrl; 1383 flow_ctrl = rpn->flow_ctrl;
1384 if (flow_ctrl != RFCOMM_RPN_FLOW_NONE) { 1384 if (flow_ctrl != RFCOMM_RPN_FLOW_NONE) {
1385 BT_DBG("RPN flow ctrl mismatch 0x%x", flow_ctrl); 1385 BT_DBG("RPN flow ctrl mismatch 0x%x", flow_ctrl);
@@ -1388,7 +1388,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1388 } 1388 }
1389 } 1389 }
1390 1390
1391 if (rpn->param_mask & RFCOMM_RPN_PM_XON) { 1391 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_XON)) {
1392 xon_char = rpn->xon_char; 1392 xon_char = rpn->xon_char;
1393 if (xon_char != RFCOMM_RPN_XON_CHAR) { 1393 if (xon_char != RFCOMM_RPN_XON_CHAR) {
1394 BT_DBG("RPN XON char mismatch 0x%x", xon_char); 1394 BT_DBG("RPN XON char mismatch 0x%x", xon_char);
@@ -1397,7 +1397,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1397 } 1397 }
1398 } 1398 }
1399 1399
1400 if (rpn->param_mask & RFCOMM_RPN_PM_XOFF) { 1400 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_XOFF)) {
1401 xoff_char = rpn->xoff_char; 1401 xoff_char = rpn->xoff_char;
1402 if (xoff_char != RFCOMM_RPN_XOFF_CHAR) { 1402 if (xoff_char != RFCOMM_RPN_XOFF_CHAR) {
1403 BT_DBG("RPN XOFF char mismatch 0x%x", xoff_char); 1403 BT_DBG("RPN XOFF char mismatch 0x%x", xoff_char);
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index 4e4119a12139..4c61a7e0a86e 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -58,12 +58,13 @@ static int get_fdb_entries(struct net_bridge *br, void __user *userbuf,
58{ 58{
59 int num; 59 int num;
60 void *buf; 60 void *buf;
61 size_t size = maxnum * sizeof(struct __fdb_entry); 61 size_t size;
62 62
63 if (size > PAGE_SIZE) { 63 /* Clamp size to PAGE_SIZE, test maxnum to avoid overflow */
64 size = PAGE_SIZE; 64 if (maxnum > PAGE_SIZE/sizeof(struct __fdb_entry))
65 maxnum = PAGE_SIZE/sizeof(struct __fdb_entry); 65 maxnum = PAGE_SIZE/sizeof(struct __fdb_entry);
66 } 66
67 size = maxnum * sizeof(struct __fdb_entry);
67 68
68 buf = kmalloc(size, GFP_USER); 69 buf = kmalloc(size, GFP_USER);
69 if (!buf) 70 if (!buf)
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index ac181be13d83..ac47ba2ba028 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -40,7 +40,6 @@
40#include <net/route.h> 40#include <net/route.h>
41 41
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
43#include <asm/checksum.h>
44#include "br_private.h" 43#include "br_private.h"
45#ifdef CONFIG_SYSCTL 44#ifdef CONFIG_SYSCTL
46#include <linux/sysctl.h> 45#include <linux/sysctl.h>
@@ -381,7 +380,7 @@ static int check_hbh_len(struct sk_buff *skb)
381 case IPV6_TLV_JUMBO: 380 case IPV6_TLV_JUMBO:
382 if (skb->nh.raw[off + 1] != 4 || (off & 3) != 2) 381 if (skb->nh.raw[off + 1] != 4 || (off & 3) != 2)
383 goto bad; 382 goto bad;
384 pkt_len = ntohl(*(u32 *) (skb->nh.raw + off + 2)); 383 pkt_len = ntohl(*(__be32 *) (skb->nh.raw + off + 2));
385 if (pkt_len <= IPV6_MAXPLEN || 384 if (pkt_len <= IPV6_MAXPLEN ||
386 skb->nh.ipv6h->payload_len) 385 skb->nh.ipv6h->payload_len)
387 goto bad; 386 goto bad;
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 8f661195d09d..a9139682c49b 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -15,6 +15,18 @@
15#include <net/netlink.h> 15#include <net/netlink.h>
16#include "br_private.h" 16#include "br_private.h"
17 17
18static inline size_t br_nlmsg_size(void)
19{
20 return NLMSG_ALIGN(sizeof(struct ifinfomsg))
21 + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */
22 + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */
23 + nla_total_size(4) /* IFLA_MASTER */
24 + nla_total_size(4) /* IFLA_MTU */
25 + nla_total_size(4) /* IFLA_LINK */
26 + nla_total_size(1) /* IFLA_OPERSTATE */
27 + nla_total_size(1); /* IFLA_PROTINFO */
28}
29
18/* 30/*
19 * Create one netlink message for one interface 31 * Create one netlink message for one interface
20 * Contains port and master info as well as carrier and bridge state. 32 * Contains port and master info as well as carrier and bridge state.
@@ -24,51 +36,43 @@ static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *por
24{ 36{
25 const struct net_bridge *br = port->br; 37 const struct net_bridge *br = port->br;
26 const struct net_device *dev = port->dev; 38 const struct net_device *dev = port->dev;
27 struct ifinfomsg *r; 39 struct ifinfomsg *hdr;
28 struct nlmsghdr *nlh; 40 struct nlmsghdr *nlh;
29 unsigned char *b = skb->tail;
30 u32 mtu = dev->mtu;
31 u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN; 41 u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
32 u8 portstate = port->state;
33 42
34 pr_debug("br_fill_info event %d port %s master %s\n", 43 pr_debug("br_fill_info event %d port %s master %s\n",
35 event, dev->name, br->dev->name); 44 event, dev->name, br->dev->name);
36 45
37 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*r), flags); 46 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
38 r = NLMSG_DATA(nlh); 47 if (nlh == NULL)
39 r->ifi_family = AF_BRIDGE; 48 return -ENOBUFS;
40 r->__ifi_pad = 0;
41 r->ifi_type = dev->type;
42 r->ifi_index = dev->ifindex;
43 r->ifi_flags = dev_get_flags(dev);
44 r->ifi_change = 0;
45 49
46 RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name); 50 hdr = nlmsg_data(nlh);
51 hdr->ifi_family = AF_BRIDGE;
52 hdr->__ifi_pad = 0;
53 hdr->ifi_type = dev->type;
54 hdr->ifi_index = dev->ifindex;
55 hdr->ifi_flags = dev_get_flags(dev);
56 hdr->ifi_change = 0;
47 57
48 RTA_PUT(skb, IFLA_MASTER, sizeof(int), &br->dev->ifindex); 58 NLA_PUT_STRING(skb, IFLA_IFNAME, dev->name);
59 NLA_PUT_U32(skb, IFLA_MASTER, br->dev->ifindex);
60 NLA_PUT_U32(skb, IFLA_MTU, dev->mtu);
61 NLA_PUT_U8(skb, IFLA_OPERSTATE, operstate);
49 62
50 if (dev->addr_len) 63 if (dev->addr_len)
51 RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr); 64 NLA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
52 65
53 RTA_PUT(skb, IFLA_MTU, sizeof(mtu), &mtu);
54 if (dev->ifindex != dev->iflink) 66 if (dev->ifindex != dev->iflink)
55 RTA_PUT(skb, IFLA_LINK, sizeof(int), &dev->iflink); 67 NLA_PUT_U32(skb, IFLA_LINK, dev->iflink);
56
57
58 RTA_PUT(skb, IFLA_OPERSTATE, sizeof(operstate), &operstate);
59 68
60 if (event == RTM_NEWLINK) 69 if (event == RTM_NEWLINK)
61 RTA_PUT(skb, IFLA_PROTINFO, sizeof(portstate), &portstate); 70 NLA_PUT_U8(skb, IFLA_PROTINFO, port->state);
62
63 nlh->nlmsg_len = skb->tail - b;
64
65 return skb->len;
66 71
67nlmsg_failure: 72 return nlmsg_end(skb, nlh);
68rtattr_failure:
69 73
70 skb_trim(skb, b - skb->data); 74nla_put_failure:
71 return -EINVAL; 75 return nlmsg_cancel(skb, nlh);
72} 76}
73 77
74/* 78/*
@@ -77,19 +81,16 @@ rtattr_failure:
77void br_ifinfo_notify(int event, struct net_bridge_port *port) 81void br_ifinfo_notify(int event, struct net_bridge_port *port)
78{ 82{
79 struct sk_buff *skb; 83 struct sk_buff *skb;
80 int payload = sizeof(struct ifinfomsg) + 128;
81 int err = -ENOBUFS; 84 int err = -ENOBUFS;
82 85
83 pr_debug("bridge notify event=%d\n", event); 86 pr_debug("bridge notify event=%d\n", event);
84 skb = nlmsg_new(nlmsg_total_size(payload), GFP_ATOMIC); 87 skb = nlmsg_new(br_nlmsg_size(), GFP_ATOMIC);
85 if (skb == NULL) 88 if (skb == NULL)
86 goto errout; 89 goto errout;
87 90
88 err = br_fill_ifinfo(skb, port, 0, 0, event, 0); 91 err = br_fill_ifinfo(skb, port, 0, 0, event, 0);
89 if (err < 0) { 92 /* failure implies BUG in br_nlmsg_size() */
90 kfree_skb(skb); 93 BUG_ON(err < 0);
91 goto errout;
92 }
93 94
94 err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); 95 err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
95errout: 96errout:
@@ -104,25 +105,18 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
104{ 105{
105 struct net_device *dev; 106 struct net_device *dev;
106 int idx; 107 int idx;
107 int s_idx = cb->args[0];
108 int err = 0;
109 108
110 read_lock(&dev_base_lock); 109 read_lock(&dev_base_lock);
111 for (dev = dev_base, idx = 0; dev; dev = dev->next) { 110 for (dev = dev_base, idx = 0; dev; dev = dev->next) {
112 struct net_bridge_port *p = dev->br_port;
113
114 /* not a bridge port */ 111 /* not a bridge port */
115 if (!p) 112 if (dev->br_port == NULL || idx < cb->args[0])
116 continue; 113 goto skip;
117
118 if (idx < s_idx)
119 goto cont;
120 114
121 err = br_fill_ifinfo(skb, p, NETLINK_CB(cb->skb).pid, 115 if (br_fill_ifinfo(skb, dev->br_port, NETLINK_CB(cb->skb).pid,
122 cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI); 116 cb->nlh->nlmsg_seq, RTM_NEWLINK,
123 if (err <= 0) 117 NLM_F_MULTI) < 0)
124 break; 118 break;
125cont: 119skip:
126 ++idx; 120 ++idx;
127 } 121 }
128 read_unlock(&dev_base_lock); 122 read_unlock(&dev_base_lock);
@@ -138,26 +132,27 @@ cont:
138 */ 132 */
139static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 133static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
140{ 134{
141 struct rtattr **rta = arg; 135 struct ifinfomsg *ifm;
142 struct ifinfomsg *ifm = NLMSG_DATA(nlh); 136 struct nlattr *protinfo;
143 struct net_device *dev; 137 struct net_device *dev;
144 struct net_bridge_port *p; 138 struct net_bridge_port *p;
145 u8 new_state; 139 u8 new_state;
146 140
141 if (nlmsg_len(nlh) < sizeof(*ifm))
142 return -EINVAL;
143
144 ifm = nlmsg_data(nlh);
147 if (ifm->ifi_family != AF_BRIDGE) 145 if (ifm->ifi_family != AF_BRIDGE)
148 return -EPFNOSUPPORT; 146 return -EPFNOSUPPORT;
149 147
150 /* Must pass valid state as PROTINFO */ 148 protinfo = nlmsg_find_attr(nlh, sizeof(*ifm), IFLA_PROTINFO);
151 if (rta[IFLA_PROTINFO-1]) { 149 if (!protinfo || nla_len(protinfo) < sizeof(u8))
152 u8 *pstate = RTA_DATA(rta[IFLA_PROTINFO-1]);
153 new_state = *pstate;
154 } else
155 return -EINVAL; 150 return -EINVAL;
156 151
152 new_state = nla_get_u8(protinfo);
157 if (new_state > BR_STATE_BLOCKING) 153 if (new_state > BR_STATE_BLOCKING)
158 return -EINVAL; 154 return -EINVAL;
159 155
160 /* Find bridge port */
161 dev = __dev_get_by_index(ifm->ifi_index); 156 dev = __dev_get_by_index(ifm->ifi_index);
162 if (!dev) 157 if (!dev)
163 return -ENODEV; 158 return -ENODEV;
@@ -170,10 +165,8 @@ static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
170 if (p->br->stp_enabled) 165 if (p->br->stp_enabled)
171 return -EBUSY; 166 return -EBUSY;
172 167
173 if (!netif_running(dev)) 168 if (!netif_running(dev) ||
174 return -ENETDOWN; 169 (!netif_carrier_ok(dev) && new_state != BR_STATE_DISABLED))
175
176 if (!netif_carrier_ok(dev) && new_state != BR_STATE_DISABLED)
177 return -ENETDOWN; 170 return -ENETDOWN;
178 171
179 p->state = new_state; 172 p->state = new_state;
diff --git a/net/bridge/netfilter/ebt_802_3.c b/net/bridge/netfilter/ebt_802_3.c
index d42f63f5e9f8..9abbc09ccdc3 100644
--- a/net/bridge/netfilter/ebt_802_3.c
+++ b/net/bridge/netfilter/ebt_802_3.c
@@ -17,7 +17,7 @@ static int ebt_filter_802_3(const struct sk_buff *skb, const struct net_device *
17{ 17{
18 struct ebt_802_3_info *info = (struct ebt_802_3_info *)data; 18 struct ebt_802_3_info *info = (struct ebt_802_3_info *)data;
19 struct ebt_802_3_hdr *hdr = ebt_802_3_hdr(skb); 19 struct ebt_802_3_hdr *hdr = ebt_802_3_hdr(skb);
20 uint16_t type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type; 20 __be16 type = hdr->llc.ui.ctrl & IS_UI ? hdr->llc.ui.type : hdr->llc.ni.type;
21 21
22 if (info->bitmask & EBT_802_3_SAP) { 22 if (info->bitmask & EBT_802_3_SAP) {
23 if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP)) 23 if (FWINV(info->sap != hdr->llc.ui.ssap, EBT_802_3_SAP))
diff --git a/net/bridge/netfilter/ebt_among.c b/net/bridge/netfilter/ebt_among.c
index a614485828af..ce97c4285f9a 100644
--- a/net/bridge/netfilter/ebt_among.c
+++ b/net/bridge/netfilter/ebt_among.c
@@ -15,7 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16 16
17static int ebt_mac_wormhash_contains(const struct ebt_mac_wormhash *wh, 17static int ebt_mac_wormhash_contains(const struct ebt_mac_wormhash *wh,
18 const char *mac, uint32_t ip) 18 const char *mac, __be32 ip)
19{ 19{
20 /* You may be puzzled as to how this code works. 20 /* You may be puzzled as to how this code works.
21 * Some tricks were used, refer to 21 * Some tricks were used, refer to
@@ -70,7 +70,7 @@ static int ebt_mac_wormhash_check_integrity(const struct ebt_mac_wormhash
70 return 0; 70 return 0;
71} 71}
72 72
73static int get_ip_dst(const struct sk_buff *skb, uint32_t *addr) 73static int get_ip_dst(const struct sk_buff *skb, __be32 *addr)
74{ 74{
75 if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) { 75 if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) {
76 struct iphdr _iph, *ih; 76 struct iphdr _iph, *ih;
@@ -81,16 +81,16 @@ static int get_ip_dst(const struct sk_buff *skb, uint32_t *addr)
81 *addr = ih->daddr; 81 *addr = ih->daddr;
82 } else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) { 82 } else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) {
83 struct arphdr _arph, *ah; 83 struct arphdr _arph, *ah;
84 uint32_t buf, *bp; 84 __be32 buf, *bp;
85 85
86 ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph); 86 ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
87 if (ah == NULL || 87 if (ah == NULL ||
88 ah->ar_pln != sizeof(uint32_t) || 88 ah->ar_pln != sizeof(__be32) ||
89 ah->ar_hln != ETH_ALEN) 89 ah->ar_hln != ETH_ALEN)
90 return -1; 90 return -1;
91 bp = skb_header_pointer(skb, sizeof(struct arphdr) + 91 bp = skb_header_pointer(skb, sizeof(struct arphdr) +
92 2 * ETH_ALEN + sizeof(uint32_t), 92 2 * ETH_ALEN + sizeof(__be32),
93 sizeof(uint32_t), &buf); 93 sizeof(__be32), &buf);
94 if (bp == NULL) 94 if (bp == NULL)
95 return -1; 95 return -1;
96 *addr = *bp; 96 *addr = *bp;
@@ -98,7 +98,7 @@ static int get_ip_dst(const struct sk_buff *skb, uint32_t *addr)
98 return 0; 98 return 0;
99} 99}
100 100
101static int get_ip_src(const struct sk_buff *skb, uint32_t *addr) 101static int get_ip_src(const struct sk_buff *skb, __be32 *addr)
102{ 102{
103 if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) { 103 if (eth_hdr(skb)->h_proto == htons(ETH_P_IP)) {
104 struct iphdr _iph, *ih; 104 struct iphdr _iph, *ih;
@@ -109,15 +109,15 @@ static int get_ip_src(const struct sk_buff *skb, uint32_t *addr)
109 *addr = ih->saddr; 109 *addr = ih->saddr;
110 } else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) { 110 } else if (eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) {
111 struct arphdr _arph, *ah; 111 struct arphdr _arph, *ah;
112 uint32_t buf, *bp; 112 __be32 buf, *bp;
113 113
114 ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph); 114 ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph);
115 if (ah == NULL || 115 if (ah == NULL ||
116 ah->ar_pln != sizeof(uint32_t) || 116 ah->ar_pln != sizeof(__be32) ||
117 ah->ar_hln != ETH_ALEN) 117 ah->ar_hln != ETH_ALEN)
118 return -1; 118 return -1;
119 bp = skb_header_pointer(skb, sizeof(struct arphdr) + 119 bp = skb_header_pointer(skb, sizeof(struct arphdr) +
120 ETH_ALEN, sizeof(uint32_t), &buf); 120 ETH_ALEN, sizeof(__be32), &buf);
121 if (bp == NULL) 121 if (bp == NULL)
122 return -1; 122 return -1;
123 *addr = *bp; 123 *addr = *bp;
@@ -133,7 +133,7 @@ static int ebt_filter_among(const struct sk_buff *skb,
133 struct ebt_among_info *info = (struct ebt_among_info *) data; 133 struct ebt_among_info *info = (struct ebt_among_info *) data;
134 const char *dmac, *smac; 134 const char *dmac, *smac;
135 const struct ebt_mac_wormhash *wh_dst, *wh_src; 135 const struct ebt_mac_wormhash *wh_dst, *wh_src;
136 uint32_t dip = 0, sip = 0; 136 __be32 dip = 0, sip = 0;
137 137
138 wh_dst = ebt_among_wh_dst(info); 138 wh_dst = ebt_among_wh_dst(info);
139 wh_src = ebt_among_wh_src(info); 139 wh_src = ebt_among_wh_src(info);
diff --git a/net/bridge/netfilter/ebt_arp.c b/net/bridge/netfilter/ebt_arp.c
index a6c81d9f73b8..9c599800a900 100644
--- a/net/bridge/netfilter/ebt_arp.c
+++ b/net/bridge/netfilter/ebt_arp.c
@@ -35,10 +35,10 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in
35 return EBT_NOMATCH; 35 return EBT_NOMATCH;
36 36
37 if (info->bitmask & (EBT_ARP_SRC_IP | EBT_ARP_DST_IP)) { 37 if (info->bitmask & (EBT_ARP_SRC_IP | EBT_ARP_DST_IP)) {
38 uint32_t _addr, *ap; 38 __be32 _addr, *ap;
39 39
40 /* IPv4 addresses are always 4 bytes */ 40 /* IPv4 addresses are always 4 bytes */
41 if (ah->ar_pln != sizeof(uint32_t)) 41 if (ah->ar_pln != sizeof(__be32))
42 return EBT_NOMATCH; 42 return EBT_NOMATCH;
43 if (info->bitmask & EBT_ARP_SRC_IP) { 43 if (info->bitmask & EBT_ARP_SRC_IP) {
44 ap = skb_header_pointer(skb, sizeof(struct arphdr) + 44 ap = skb_header_pointer(skb, sizeof(struct arphdr) +
@@ -53,7 +53,7 @@ static int ebt_filter_arp(const struct sk_buff *skb, const struct net_device *in
53 53
54 if (info->bitmask & EBT_ARP_DST_IP) { 54 if (info->bitmask & EBT_ARP_DST_IP) {
55 ap = skb_header_pointer(skb, sizeof(struct arphdr) + 55 ap = skb_header_pointer(skb, sizeof(struct arphdr) +
56 2*ah->ar_hln+sizeof(uint32_t), 56 2*ah->ar_hln+sizeof(__be32),
57 sizeof(_addr), &_addr); 57 sizeof(_addr), &_addr);
58 if (ap == NULL) 58 if (ap == NULL)
59 return EBT_NOMATCH; 59 return EBT_NOMATCH;
diff --git a/net/bridge/netfilter/ebt_ip.c b/net/bridge/netfilter/ebt_ip.c
index 65b665ce57b5..e4c642448e1b 100644
--- a/net/bridge/netfilter/ebt_ip.c
+++ b/net/bridge/netfilter/ebt_ip.c
@@ -20,8 +20,8 @@
20#include <linux/module.h> 20#include <linux/module.h>
21 21
22struct tcpudphdr { 22struct tcpudphdr {
23 uint16_t src; 23 __be16 src;
24 uint16_t dst; 24 __be16 dst;
25}; 25};
26 26
27static int ebt_filter_ip(const struct sk_buff *skb, const struct net_device *in, 27static int ebt_filter_ip(const struct sk_buff *skb, const struct net_device *in,
diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c
index 466ed3440b74..a184f879f253 100644
--- a/net/bridge/netfilter/ebt_log.c
+++ b/net/bridge/netfilter/ebt_log.c
@@ -38,8 +38,8 @@ static int ebt_log_check(const char *tablename, unsigned int hookmask,
38 38
39struct tcpudphdr 39struct tcpudphdr
40{ 40{
41 uint16_t src; 41 __be16 src;
42 uint16_t dst; 42 __be16 dst;
43}; 43};
44 44
45struct arppayload 45struct arppayload
@@ -130,7 +130,7 @@ ebt_log_packet(unsigned int pf, unsigned int hooknum,
130 * then log the ARP payload */ 130 * then log the ARP payload */
131 if (ah->ar_hrd == htons(1) && 131 if (ah->ar_hrd == htons(1) &&
132 ah->ar_hln == ETH_ALEN && 132 ah->ar_hln == ETH_ALEN &&
133 ah->ar_pln == sizeof(uint32_t)) { 133 ah->ar_pln == sizeof(__be32)) {
134 struct arppayload _arpp, *ap; 134 struct arppayload _arpp, *ap;
135 135
136 ap = skb_header_pointer(skb, sizeof(_arph), 136 ap = skb_header_pointer(skb, sizeof(_arph),
diff --git a/net/bridge/netfilter/ebt_mark.c b/net/bridge/netfilter/ebt_mark.c
index b54306a934e5..62d23c7b25e6 100644
--- a/net/bridge/netfilter/ebt_mark.c
+++ b/net/bridge/netfilter/ebt_mark.c
@@ -25,15 +25,15 @@ static int ebt_target_mark(struct sk_buff **pskb, unsigned int hooknr,
25 int action = info->target & -16; 25 int action = info->target & -16;
26 26
27 if (action == MARK_SET_VALUE) 27 if (action == MARK_SET_VALUE)
28 (*pskb)->nfmark = info->mark; 28 (*pskb)->mark = info->mark;
29 else if (action == MARK_OR_VALUE) 29 else if (action == MARK_OR_VALUE)
30 (*pskb)->nfmark |= info->mark; 30 (*pskb)->mark |= info->mark;
31 else if (action == MARK_AND_VALUE) 31 else if (action == MARK_AND_VALUE)
32 (*pskb)->nfmark &= info->mark; 32 (*pskb)->mark &= info->mark;
33 else 33 else
34 (*pskb)->nfmark ^= info->mark; 34 (*pskb)->mark ^= info->mark;
35 35
36 return info->target | -16; 36 return info->target | ~EBT_VERDICT_BITS;
37} 37}
38 38
39static int ebt_target_mark_check(const char *tablename, unsigned int hookmask, 39static int ebt_target_mark_check(const char *tablename, unsigned int hookmask,
@@ -44,13 +44,13 @@ static int ebt_target_mark_check(const char *tablename, unsigned int hookmask,
44 44
45 if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info))) 45 if (datalen != EBT_ALIGN(sizeof(struct ebt_mark_t_info)))
46 return -EINVAL; 46 return -EINVAL;
47 tmp = info->target | -16; 47 tmp = info->target | ~EBT_VERDICT_BITS;
48 if (BASE_CHAIN && tmp == EBT_RETURN) 48 if (BASE_CHAIN && tmp == EBT_RETURN)
49 return -EINVAL; 49 return -EINVAL;
50 CLEAR_BASE_CHAIN_BIT; 50 CLEAR_BASE_CHAIN_BIT;
51 if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0) 51 if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
52 return -EINVAL; 52 return -EINVAL;
53 tmp = info->target & -16; 53 tmp = info->target & ~EBT_VERDICT_BITS;
54 if (tmp != MARK_SET_VALUE && tmp != MARK_OR_VALUE && 54 if (tmp != MARK_SET_VALUE && tmp != MARK_OR_VALUE &&
55 tmp != MARK_AND_VALUE && tmp != MARK_XOR_VALUE) 55 tmp != MARK_AND_VALUE && tmp != MARK_XOR_VALUE)
56 return -EINVAL; 56 return -EINVAL;
diff --git a/net/bridge/netfilter/ebt_mark_m.c b/net/bridge/netfilter/ebt_mark_m.c
index a6413e4b4982..025869ee0b68 100644
--- a/net/bridge/netfilter/ebt_mark_m.c
+++ b/net/bridge/netfilter/ebt_mark_m.c
@@ -19,8 +19,8 @@ static int ebt_filter_mark(const struct sk_buff *skb,
19 struct ebt_mark_m_info *info = (struct ebt_mark_m_info *) data; 19 struct ebt_mark_m_info *info = (struct ebt_mark_m_info *) data;
20 20
21 if (info->bitmask & EBT_MARK_OR) 21 if (info->bitmask & EBT_MARK_OR)
22 return !(!!(skb->nfmark & info->mask) ^ info->invert); 22 return !(!!(skb->mark & info->mask) ^ info->invert);
23 return !(((skb->nfmark & info->mask) == info->mark) ^ info->invert); 23 return !(((skb->mark & info->mask) == info->mark) ^ info->invert);
24} 24}
25 25
26static int ebt_mark_check(const char *tablename, unsigned int hookmask, 26static int ebt_mark_check(const char *tablename, unsigned int hookmask,
diff --git a/net/bridge/netfilter/ebt_snat.c b/net/bridge/netfilter/ebt_snat.c
index cbb33e24ca8a..a50722182bfe 100644
--- a/net/bridge/netfilter/ebt_snat.c
+++ b/net/bridge/netfilter/ebt_snat.c
@@ -12,6 +12,8 @@
12#include <linux/netfilter_bridge/ebt_nat.h> 12#include <linux/netfilter_bridge/ebt_nat.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <net/sock.h> 14#include <net/sock.h>
15#include <linux/if_arp.h>
16#include <net/arp.h>
15 17
16static int ebt_target_snat(struct sk_buff **pskb, unsigned int hooknr, 18static int ebt_target_snat(struct sk_buff **pskb, unsigned int hooknr,
17 const struct net_device *in, const struct net_device *out, 19 const struct net_device *in, const struct net_device *out,
@@ -31,24 +33,43 @@ static int ebt_target_snat(struct sk_buff **pskb, unsigned int hooknr,
31 *pskb = nskb; 33 *pskb = nskb;
32 } 34 }
33 memcpy(eth_hdr(*pskb)->h_source, info->mac, ETH_ALEN); 35 memcpy(eth_hdr(*pskb)->h_source, info->mac, ETH_ALEN);
34 return info->target; 36 if (!(info->target & NAT_ARP_BIT) &&
37 eth_hdr(*pskb)->h_proto == htons(ETH_P_ARP)) {
38 struct arphdr _ah, *ap;
39
40 ap = skb_header_pointer(*pskb, 0, sizeof(_ah), &_ah);
41 if (ap == NULL)
42 return EBT_DROP;
43 if (ap->ar_hln != ETH_ALEN)
44 goto out;
45 if (skb_store_bits(*pskb, sizeof(_ah), info->mac,ETH_ALEN))
46 return EBT_DROP;
47 }
48out:
49 return info->target | ~EBT_VERDICT_BITS;
35} 50}
36 51
37static int ebt_target_snat_check(const char *tablename, unsigned int hookmask, 52static int ebt_target_snat_check(const char *tablename, unsigned int hookmask,
38 const struct ebt_entry *e, void *data, unsigned int datalen) 53 const struct ebt_entry *e, void *data, unsigned int datalen)
39{ 54{
40 struct ebt_nat_info *info = (struct ebt_nat_info *) data; 55 struct ebt_nat_info *info = (struct ebt_nat_info *) data;
56 int tmp;
41 57
42 if (datalen != EBT_ALIGN(sizeof(struct ebt_nat_info))) 58 if (datalen != EBT_ALIGN(sizeof(struct ebt_nat_info)))
43 return -EINVAL; 59 return -EINVAL;
44 if (BASE_CHAIN && info->target == EBT_RETURN) 60 tmp = info->target | ~EBT_VERDICT_BITS;
61 if (BASE_CHAIN && tmp == EBT_RETURN)
45 return -EINVAL; 62 return -EINVAL;
46 CLEAR_BASE_CHAIN_BIT; 63 CLEAR_BASE_CHAIN_BIT;
47 if (strcmp(tablename, "nat")) 64 if (strcmp(tablename, "nat"))
48 return -EINVAL; 65 return -EINVAL;
49 if (hookmask & ~(1 << NF_BR_POST_ROUTING)) 66 if (hookmask & ~(1 << NF_BR_POST_ROUTING))
50 return -EINVAL; 67 return -EINVAL;
51 if (INVALID_TARGET) 68
69 if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
70 return -EINVAL;
71 tmp = info->target | EBT_VERDICT_BITS;
72 if ((tmp & ~NAT_ARP_BIT) != ~NAT_ARP_BIT)
52 return -EINVAL; 73 return -EINVAL;
53 return 0; 74 return 0;
54} 75}
diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index 9f950db3b76f..c1af68b5a29c 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -168,7 +168,7 @@ static void ebt_ulog_packet(unsigned int hooknr, const struct sk_buff *skb,
168 if (ub->qlen == 1) 168 if (ub->qlen == 1)
169 skb_set_timestamp(ub->skb, &pm->stamp); 169 skb_set_timestamp(ub->skb, &pm->stamp);
170 pm->data_len = copy_len; 170 pm->data_len = copy_len;
171 pm->mark = skb->nfmark; 171 pm->mark = skb->mark;
172 pm->hook = hooknr; 172 pm->hook = hooknr;
173 if (uloginfo->prefix != NULL) 173 if (uloginfo->prefix != NULL)
174 strcpy(pm->prefix, uloginfo->prefix); 174 strcpy(pm->prefix, uloginfo->prefix);
diff --git a/net/bridge/netfilter/ebt_vlan.c b/net/bridge/netfilter/ebt_vlan.c
index a2b452862b73..7ee377622964 100644
--- a/net/bridge/netfilter/ebt_vlan.c
+++ b/net/bridge/netfilter/ebt_vlan.c
@@ -55,7 +55,7 @@ ebt_filter_vlan(const struct sk_buff *skb,
55 unsigned short id; /* VLAN ID, given from frame TCI */ 55 unsigned short id; /* VLAN ID, given from frame TCI */
56 unsigned char prio; /* user_priority, given from frame TCI */ 56 unsigned char prio; /* user_priority, given from frame TCI */
57 /* VLAN encapsulated Type/Length field, given from orig frame */ 57 /* VLAN encapsulated Type/Length field, given from orig frame */
58 unsigned short encap; 58 __be16 encap;
59 59
60 fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame); 60 fp = skb_header_pointer(skb, 0, sizeof(_frame), &_frame);
61 if (fp == NULL) 61 if (fp == NULL)
diff --git a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c
index 9a6e548e148b..d37ce0478938 100644
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -23,7 +23,7 @@ static struct ebt_entries initial_chain = {
23 .policy = EBT_ACCEPT, 23 .policy = EBT_ACCEPT,
24}; 24};
25 25
26static struct ebt_replace initial_table = 26static struct ebt_replace_kernel initial_table =
27{ 27{
28 .name = "broute", 28 .name = "broute",
29 .valid_hooks = 1 << NF_BR_BROUTING, 29 .valid_hooks = 1 << NF_BR_BROUTING,
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index 3d5bd44f2395..127135ead2d5 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -30,7 +30,7 @@ static struct ebt_entries initial_chains[] =
30 }, 30 },
31}; 31};
32 32
33static struct ebt_replace initial_table = 33static struct ebt_replace_kernel initial_table =
34{ 34{
35 .name = "filter", 35 .name = "filter",
36 .valid_hooks = FILTER_VALID_HOOKS, 36 .valid_hooks = FILTER_VALID_HOOKS,
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index 04dd42efda1d..9c50488b62eb 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -30,7 +30,7 @@ static struct ebt_entries initial_chains[] =
30 } 30 }
31}; 31};
32 32
33static struct ebt_replace initial_table = 33static struct ebt_replace_kernel initial_table =
34{ 34{
35 .name = "nat", 35 .name = "nat",
36 .valid_hooks = NAT_VALID_HOOKS, 36 .valid_hooks = NAT_VALID_HOOKS,
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 9f85666f29f7..bee558a41800 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -338,10 +338,11 @@ ebt_check_match(struct ebt_entry_match *m, struct ebt_entry *e,
338 const char *name, unsigned int hookmask, unsigned int *cnt) 338 const char *name, unsigned int hookmask, unsigned int *cnt)
339{ 339{
340 struct ebt_match *match; 340 struct ebt_match *match;
341 size_t left = ((char *)e + e->watchers_offset) - (char *)m;
341 int ret; 342 int ret;
342 343
343 if (((char *)m) + m->match_size + sizeof(struct ebt_entry_match) > 344 if (left < sizeof(struct ebt_entry_match) ||
344 ((char *)e) + e->watchers_offset) 345 left - sizeof(struct ebt_entry_match) < m->match_size)
345 return -EINVAL; 346 return -EINVAL;
346 match = find_match_lock(m->u.name, &ret, &ebt_mutex); 347 match = find_match_lock(m->u.name, &ret, &ebt_mutex);
347 if (!match) 348 if (!match)
@@ -367,10 +368,11 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct ebt_entry *e,
367 const char *name, unsigned int hookmask, unsigned int *cnt) 368 const char *name, unsigned int hookmask, unsigned int *cnt)
368{ 369{
369 struct ebt_watcher *watcher; 370 struct ebt_watcher *watcher;
371 size_t left = ((char *)e + e->target_offset) - (char *)w;
370 int ret; 372 int ret;
371 373
372 if (((char *)w) + w->watcher_size + sizeof(struct ebt_entry_watcher) > 374 if (left < sizeof(struct ebt_entry_watcher) ||
373 ((char *)e) + e->target_offset) 375 left - sizeof(struct ebt_entry_watcher) < w->watcher_size)
374 return -EINVAL; 376 return -EINVAL;
375 watcher = find_watcher_lock(w->u.name, &ret, &ebt_mutex); 377 watcher = find_watcher_lock(w->u.name, &ret, &ebt_mutex);
376 if (!watcher) 378 if (!watcher)
@@ -391,35 +393,91 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct ebt_entry *e,
391 return 0; 393 return 0;
392} 394}
393 395
396static int ebt_verify_pointers(struct ebt_replace *repl,
397 struct ebt_table_info *newinfo)
398{
399 unsigned int limit = repl->entries_size;
400 unsigned int valid_hooks = repl->valid_hooks;
401 unsigned int offset = 0;
402 int i;
403
404 for (i = 0; i < NF_BR_NUMHOOKS; i++)
405 newinfo->hook_entry[i] = NULL;
406
407 newinfo->entries_size = repl->entries_size;
408 newinfo->nentries = repl->nentries;
409
410 while (offset < limit) {
411 size_t left = limit - offset;
412 struct ebt_entry *e = (void *)newinfo->entries + offset;
413
414 if (left < sizeof(unsigned int))
415 break;
416
417 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
418 if ((valid_hooks & (1 << i)) == 0)
419 continue;
420 if ((char __user *)repl->hook_entry[i] ==
421 repl->entries + offset)
422 break;
423 }
424
425 if (i != NF_BR_NUMHOOKS || !(e->bitmask & EBT_ENTRY_OR_ENTRIES)) {
426 if (e->bitmask != 0) {
427 /* we make userspace set this right,
428 so there is no misunderstanding */
429 BUGPRINT("EBT_ENTRY_OR_ENTRIES shouldn't be set "
430 "in distinguisher\n");
431 return -EINVAL;
432 }
433 if (i != NF_BR_NUMHOOKS)
434 newinfo->hook_entry[i] = (struct ebt_entries *)e;
435 if (left < sizeof(struct ebt_entries))
436 break;
437 offset += sizeof(struct ebt_entries);
438 } else {
439 if (left < sizeof(struct ebt_entry))
440 break;
441 if (left < e->next_offset)
442 break;
443 offset += e->next_offset;
444 }
445 }
446 if (offset != limit) {
447 BUGPRINT("entries_size too small\n");
448 return -EINVAL;
449 }
450
451 /* check if all valid hooks have a chain */
452 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
453 if (!newinfo->hook_entry[i] &&
454 (valid_hooks & (1 << i))) {
455 BUGPRINT("Valid hook without chain\n");
456 return -EINVAL;
457 }
458 }
459 return 0;
460}
461
394/* 462/*
395 * this one is very careful, as it is the first function 463 * this one is very careful, as it is the first function
396 * to parse the userspace data 464 * to parse the userspace data
397 */ 465 */
398static inline int 466static inline int
399ebt_check_entry_size_and_hooks(struct ebt_entry *e, 467ebt_check_entry_size_and_hooks(struct ebt_entry *e,
400 struct ebt_table_info *newinfo, char *base, char *limit, 468 struct ebt_table_info *newinfo,
401 struct ebt_entries **hook_entries, unsigned int *n, unsigned int *cnt, 469 unsigned int *n, unsigned int *cnt,
402 unsigned int *totalcnt, unsigned int *udc_cnt, unsigned int valid_hooks) 470 unsigned int *totalcnt, unsigned int *udc_cnt)
403{ 471{
404 int i; 472 int i;
405 473
406 for (i = 0; i < NF_BR_NUMHOOKS; i++) { 474 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
407 if ((valid_hooks & (1 << i)) == 0) 475 if ((void *)e == (void *)newinfo->hook_entry[i])
408 continue;
409 if ( (char *)hook_entries[i] - base ==
410 (char *)e - newinfo->entries)
411 break; 476 break;
412 } 477 }
413 /* beginning of a new chain 478 /* beginning of a new chain
414 if i == NF_BR_NUMHOOKS it must be a user defined chain */ 479 if i == NF_BR_NUMHOOKS it must be a user defined chain */
415 if (i != NF_BR_NUMHOOKS || !(e->bitmask & EBT_ENTRY_OR_ENTRIES)) { 480 if (i != NF_BR_NUMHOOKS || !e->bitmask) {
416 if ((e->bitmask & EBT_ENTRY_OR_ENTRIES) != 0) {
417 /* we make userspace set this right,
418 so there is no misunderstanding */
419 BUGPRINT("EBT_ENTRY_OR_ENTRIES shouldn't be set "
420 "in distinguisher\n");
421 return -EINVAL;
422 }
423 /* this checks if the previous chain has as many entries 481 /* this checks if the previous chain has as many entries
424 as it said it has */ 482 as it said it has */
425 if (*n != *cnt) { 483 if (*n != *cnt) {
@@ -427,12 +485,6 @@ ebt_check_entry_size_and_hooks(struct ebt_entry *e,
427 "in the chain\n"); 485 "in the chain\n");
428 return -EINVAL; 486 return -EINVAL;
429 } 487 }
430 /* before we look at the struct, be sure it is not too big */
431 if ((char *)hook_entries[i] + sizeof(struct ebt_entries)
432 > limit) {
433 BUGPRINT("entries_size too small\n");
434 return -EINVAL;
435 }
436 if (((struct ebt_entries *)e)->policy != EBT_DROP && 488 if (((struct ebt_entries *)e)->policy != EBT_DROP &&
437 ((struct ebt_entries *)e)->policy != EBT_ACCEPT) { 489 ((struct ebt_entries *)e)->policy != EBT_ACCEPT) {
438 /* only RETURN from udc */ 490 /* only RETURN from udc */
@@ -444,8 +496,6 @@ ebt_check_entry_size_and_hooks(struct ebt_entry *e,
444 } 496 }
445 if (i == NF_BR_NUMHOOKS) /* it's a user defined chain */ 497 if (i == NF_BR_NUMHOOKS) /* it's a user defined chain */
446 (*udc_cnt)++; 498 (*udc_cnt)++;
447 else
448 newinfo->hook_entry[i] = (struct ebt_entries *)e;
449 if (((struct ebt_entries *)e)->counter_offset != *totalcnt) { 499 if (((struct ebt_entries *)e)->counter_offset != *totalcnt) {
450 BUGPRINT("counter_offset != totalcnt"); 500 BUGPRINT("counter_offset != totalcnt");
451 return -EINVAL; 501 return -EINVAL;
@@ -466,7 +516,6 @@ ebt_check_entry_size_and_hooks(struct ebt_entry *e,
466 BUGPRINT("target size too small\n"); 516 BUGPRINT("target size too small\n");
467 return -EINVAL; 517 return -EINVAL;
468 } 518 }
469
470 (*cnt)++; 519 (*cnt)++;
471 (*totalcnt)++; 520 (*totalcnt)++;
472 return 0; 521 return 0;
@@ -485,17 +534,14 @@ struct ebt_cl_stack
485 */ 534 */
486static inline int 535static inline int
487ebt_get_udc_positions(struct ebt_entry *e, struct ebt_table_info *newinfo, 536ebt_get_udc_positions(struct ebt_entry *e, struct ebt_table_info *newinfo,
488 struct ebt_entries **hook_entries, unsigned int *n, unsigned int valid_hooks, 537 unsigned int *n, struct ebt_cl_stack *udc)
489 struct ebt_cl_stack *udc)
490{ 538{
491 int i; 539 int i;
492 540
493 /* we're only interested in chain starts */ 541 /* we're only interested in chain starts */
494 if (e->bitmask & EBT_ENTRY_OR_ENTRIES) 542 if (e->bitmask)
495 return 0; 543 return 0;
496 for (i = 0; i < NF_BR_NUMHOOKS; i++) { 544 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
497 if ((valid_hooks & (1 << i)) == 0)
498 continue;
499 if (newinfo->hook_entry[i] == (struct ebt_entries *)e) 545 if (newinfo->hook_entry[i] == (struct ebt_entries *)e)
500 break; 546 break;
501 } 547 }
@@ -541,7 +587,7 @@ ebt_cleanup_entry(struct ebt_entry *e, unsigned int *cnt)
541{ 587{
542 struct ebt_entry_target *t; 588 struct ebt_entry_target *t;
543 589
544 if ((e->bitmask & EBT_ENTRY_OR_ENTRIES) == 0) 590 if (e->bitmask == 0)
545 return 0; 591 return 0;
546 /* we're done */ 592 /* we're done */
547 if (cnt && (*cnt)-- == 0) 593 if (cnt && (*cnt)-- == 0)
@@ -558,16 +604,17 @@ ebt_cleanup_entry(struct ebt_entry *e, unsigned int *cnt)
558 604
559static inline int 605static inline int
560ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo, 606ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
561 const char *name, unsigned int *cnt, unsigned int valid_hooks, 607 const char *name, unsigned int *cnt,
562 struct ebt_cl_stack *cl_s, unsigned int udc_cnt) 608 struct ebt_cl_stack *cl_s, unsigned int udc_cnt)
563{ 609{
564 struct ebt_entry_target *t; 610 struct ebt_entry_target *t;
565 struct ebt_target *target; 611 struct ebt_target *target;
566 unsigned int i, j, hook = 0, hookmask = 0; 612 unsigned int i, j, hook = 0, hookmask = 0;
613 size_t gap = e->next_offset - e->target_offset;
567 int ret; 614 int ret;
568 615
569 /* don't mess with the struct ebt_entries */ 616 /* don't mess with the struct ebt_entries */
570 if ((e->bitmask & EBT_ENTRY_OR_ENTRIES) == 0) 617 if (e->bitmask == 0)
571 return 0; 618 return 0;
572 619
573 if (e->bitmask & ~EBT_F_MASK) { 620 if (e->bitmask & ~EBT_F_MASK) {
@@ -584,7 +631,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
584 } 631 }
585 /* what hook do we belong to? */ 632 /* what hook do we belong to? */
586 for (i = 0; i < NF_BR_NUMHOOKS; i++) { 633 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
587 if ((valid_hooks & (1 << i)) == 0) 634 if (!newinfo->hook_entry[i])
588 continue; 635 continue;
589 if ((char *)newinfo->hook_entry[i] < (char *)e) 636 if ((char *)newinfo->hook_entry[i] < (char *)e)
590 hook = i; 637 hook = i;
@@ -625,8 +672,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
625 672
626 t->u.target = target; 673 t->u.target = target;
627 if (t->u.target == &ebt_standard_target) { 674 if (t->u.target == &ebt_standard_target) {
628 if (e->target_offset + sizeof(struct ebt_standard_target) > 675 if (gap < sizeof(struct ebt_standard_target)) {
629 e->next_offset) {
630 BUGPRINT("Standard target size too big\n"); 676 BUGPRINT("Standard target size too big\n");
631 ret = -EFAULT; 677 ret = -EFAULT;
632 goto cleanup_watchers; 678 goto cleanup_watchers;
@@ -637,8 +683,7 @@ ebt_check_entry(struct ebt_entry *e, struct ebt_table_info *newinfo,
637 ret = -EFAULT; 683 ret = -EFAULT;
638 goto cleanup_watchers; 684 goto cleanup_watchers;
639 } 685 }
640 } else if ((e->target_offset + t->target_size + 686 } else if (t->target_size > gap - sizeof(struct ebt_entry_target) ||
641 sizeof(struct ebt_entry_target) > e->next_offset) ||
642 (t->u.target->check && 687 (t->u.target->check &&
643 t->u.target->check(name, hookmask, e, t->data, t->target_size) != 0)){ 688 t->u.target->check(name, hookmask, e, t->data, t->target_size) != 0)){
644 module_put(t->u.target->me); 689 module_put(t->u.target->me);
@@ -708,7 +753,9 @@ static int check_chainloops(struct ebt_entries *chain, struct ebt_cl_stack *cl_s
708 BUGPRINT("loop\n"); 753 BUGPRINT("loop\n");
709 return -1; 754 return -1;
710 } 755 }
711 /* this can't be 0, so the above test is correct */ 756 if (cl_s[i].hookmask & (1 << hooknr))
757 goto letscontinue;
758 /* this can't be 0, so the loop test is correct */
712 cl_s[i].cs.n = pos + 1; 759 cl_s[i].cs.n = pos + 1;
713 pos = 0; 760 pos = 0;
714 cl_s[i].cs.e = ((void *)e + e->next_offset); 761 cl_s[i].cs.e = ((void *)e + e->next_offset);
@@ -728,42 +775,35 @@ letscontinue:
728} 775}
729 776
730/* do the parsing of the table/chains/entries/matches/watchers/targets, heh */ 777/* do the parsing of the table/chains/entries/matches/watchers/targets, heh */
731static int translate_table(struct ebt_replace *repl, 778static int translate_table(char *name, struct ebt_table_info *newinfo)
732 struct ebt_table_info *newinfo)
733{ 779{
734 unsigned int i, j, k, udc_cnt; 780 unsigned int i, j, k, udc_cnt;
735 int ret; 781 int ret;
736 struct ebt_cl_stack *cl_s = NULL; /* used in the checking for chain loops */ 782 struct ebt_cl_stack *cl_s = NULL; /* used in the checking for chain loops */
737 783
738 i = 0; 784 i = 0;
739 while (i < NF_BR_NUMHOOKS && !(repl->valid_hooks & (1 << i))) 785 while (i < NF_BR_NUMHOOKS && !newinfo->hook_entry[i])
740 i++; 786 i++;
741 if (i == NF_BR_NUMHOOKS) { 787 if (i == NF_BR_NUMHOOKS) {
742 BUGPRINT("No valid hooks specified\n"); 788 BUGPRINT("No valid hooks specified\n");
743 return -EINVAL; 789 return -EINVAL;
744 } 790 }
745 if (repl->hook_entry[i] != (struct ebt_entries *)repl->entries) { 791 if (newinfo->hook_entry[i] != (struct ebt_entries *)newinfo->entries) {
746 BUGPRINT("Chains don't start at beginning\n"); 792 BUGPRINT("Chains don't start at beginning\n");
747 return -EINVAL; 793 return -EINVAL;
748 } 794 }
749 /* make sure chains are ordered after each other in same order 795 /* make sure chains are ordered after each other in same order
750 as their corresponding hooks */ 796 as their corresponding hooks */
751 for (j = i + 1; j < NF_BR_NUMHOOKS; j++) { 797 for (j = i + 1; j < NF_BR_NUMHOOKS; j++) {
752 if (!(repl->valid_hooks & (1 << j))) 798 if (!newinfo->hook_entry[j])
753 continue; 799 continue;
754 if ( repl->hook_entry[j] <= repl->hook_entry[i] ) { 800 if (newinfo->hook_entry[j] <= newinfo->hook_entry[i]) {
755 BUGPRINT("Hook order must be followed\n"); 801 BUGPRINT("Hook order must be followed\n");
756 return -EINVAL; 802 return -EINVAL;
757 } 803 }
758 i = j; 804 i = j;
759 } 805 }
760 806
761 for (i = 0; i < NF_BR_NUMHOOKS; i++)
762 newinfo->hook_entry[i] = NULL;
763
764 newinfo->entries_size = repl->entries_size;
765 newinfo->nentries = repl->nentries;
766
767 /* do some early checkings and initialize some things */ 807 /* do some early checkings and initialize some things */
768 i = 0; /* holds the expected nr. of entries for the chain */ 808 i = 0; /* holds the expected nr. of entries for the chain */
769 j = 0; /* holds the up to now counted entries for the chain */ 809 j = 0; /* holds the up to now counted entries for the chain */
@@ -771,9 +811,8 @@ static int translate_table(struct ebt_replace *repl,
771 newinfo->nentries afterwards */ 811 newinfo->nentries afterwards */
772 udc_cnt = 0; /* will hold the nr. of user defined chains (udc) */ 812 udc_cnt = 0; /* will hold the nr. of user defined chains (udc) */
773 ret = EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 813 ret = EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
774 ebt_check_entry_size_and_hooks, newinfo, repl->entries, 814 ebt_check_entry_size_and_hooks, newinfo,
775 repl->entries + repl->entries_size, repl->hook_entry, &i, &j, &k, 815 &i, &j, &k, &udc_cnt);
776 &udc_cnt, repl->valid_hooks);
777 816
778 if (ret != 0) 817 if (ret != 0)
779 return ret; 818 return ret;
@@ -788,15 +827,6 @@ static int translate_table(struct ebt_replace *repl,
788 return -EINVAL; 827 return -EINVAL;
789 } 828 }
790 829
791 /* check if all valid hooks have a chain */
792 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
793 if (newinfo->hook_entry[i] == NULL &&
794 (repl->valid_hooks & (1 << i))) {
795 BUGPRINT("Valid hook without chain\n");
796 return -EINVAL;
797 }
798 }
799
800 /* get the location of the udc, put them in an array 830 /* get the location of the udc, put them in an array
801 while we're at it, allocate the chainstack */ 831 while we're at it, allocate the chainstack */
802 if (udc_cnt) { 832 if (udc_cnt) {
@@ -824,8 +854,7 @@ static int translate_table(struct ebt_replace *repl,
824 return -ENOMEM; 854 return -ENOMEM;
825 i = 0; /* the i'th udc */ 855 i = 0; /* the i'th udc */
826 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 856 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
827 ebt_get_udc_positions, newinfo, repl->hook_entry, &i, 857 ebt_get_udc_positions, newinfo, &i, cl_s);
828 repl->valid_hooks, cl_s);
829 /* sanity check */ 858 /* sanity check */
830 if (i != udc_cnt) { 859 if (i != udc_cnt) {
831 BUGPRINT("i != udc_cnt\n"); 860 BUGPRINT("i != udc_cnt\n");
@@ -836,7 +865,7 @@ static int translate_table(struct ebt_replace *repl,
836 865
837 /* Check for loops */ 866 /* Check for loops */
838 for (i = 0; i < NF_BR_NUMHOOKS; i++) 867 for (i = 0; i < NF_BR_NUMHOOKS; i++)
839 if (repl->valid_hooks & (1 << i)) 868 if (newinfo->hook_entry[i])
840 if (check_chainloops(newinfo->hook_entry[i], 869 if (check_chainloops(newinfo->hook_entry[i],
841 cl_s, udc_cnt, i, newinfo->entries)) { 870 cl_s, udc_cnt, i, newinfo->entries)) {
842 vfree(cl_s); 871 vfree(cl_s);
@@ -856,8 +885,7 @@ static int translate_table(struct ebt_replace *repl,
856 /* used to know what we need to clean up if something goes wrong */ 885 /* used to know what we need to clean up if something goes wrong */
857 i = 0; 886 i = 0;
858 ret = EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 887 ret = EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
859 ebt_check_entry, newinfo, repl->name, &i, repl->valid_hooks, 888 ebt_check_entry, newinfo, name, &i, cl_s, udc_cnt);
860 cl_s, udc_cnt);
861 if (ret != 0) { 889 if (ret != 0) {
862 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size, 890 EBT_ENTRY_ITERATE(newinfo->entries, newinfo->entries_size,
863 ebt_cleanup_entry, &i); 891 ebt_cleanup_entry, &i);
@@ -954,7 +982,11 @@ static int do_replace(void __user *user, unsigned int len)
954 982
955 /* this can get initialized by translate_table() */ 983 /* this can get initialized by translate_table() */
956 newinfo->chainstack = NULL; 984 newinfo->chainstack = NULL;
957 ret = translate_table(&tmp, newinfo); 985 ret = ebt_verify_pointers(&tmp, newinfo);
986 if (ret != 0)
987 goto free_counterstmp;
988
989 ret = translate_table(tmp.name, newinfo);
958 990
959 if (ret != 0) 991 if (ret != 0)
960 goto free_counterstmp; 992 goto free_counterstmp;
@@ -1125,35 +1157,47 @@ int ebt_register_table(struct ebt_table *table)
1125{ 1157{
1126 struct ebt_table_info *newinfo; 1158 struct ebt_table_info *newinfo;
1127 struct ebt_table *t; 1159 struct ebt_table *t;
1160 struct ebt_replace_kernel *repl;
1128 int ret, i, countersize; 1161 int ret, i, countersize;
1162 void *p;
1129 1163
1130 if (!table || !table->table ||!table->table->entries || 1164 if (!table || !(repl = table->table) || !repl->entries ||
1131 table->table->entries_size == 0 || 1165 repl->entries_size == 0 ||
1132 table->table->counters || table->private) { 1166 repl->counters || table->private) {
1133 BUGPRINT("Bad table data for ebt_register_table!!!\n"); 1167 BUGPRINT("Bad table data for ebt_register_table!!!\n");
1134 return -EINVAL; 1168 return -EINVAL;
1135 } 1169 }
1136 1170
1137 countersize = COUNTER_OFFSET(table->table->nentries) * 1171 countersize = COUNTER_OFFSET(repl->nentries) *
1138 (highest_possible_processor_id()+1); 1172 (highest_possible_processor_id()+1);
1139 newinfo = vmalloc(sizeof(*newinfo) + countersize); 1173 newinfo = vmalloc(sizeof(*newinfo) + countersize);
1140 ret = -ENOMEM; 1174 ret = -ENOMEM;
1141 if (!newinfo) 1175 if (!newinfo)
1142 return -ENOMEM; 1176 return -ENOMEM;
1143 1177
1144 newinfo->entries = vmalloc(table->table->entries_size); 1178 p = vmalloc(repl->entries_size);
1145 if (!(newinfo->entries)) 1179 if (!p)
1146 goto free_newinfo; 1180 goto free_newinfo;
1147 1181
1148 memcpy(newinfo->entries, table->table->entries, 1182 memcpy(p, repl->entries, repl->entries_size);
1149 table->table->entries_size); 1183 newinfo->entries = p;
1184
1185 newinfo->entries_size = repl->entries_size;
1186 newinfo->nentries = repl->nentries;
1150 1187
1151 if (countersize) 1188 if (countersize)
1152 memset(newinfo->counters, 0, countersize); 1189 memset(newinfo->counters, 0, countersize);
1153 1190
1154 /* fill in newinfo and parse the entries */ 1191 /* fill in newinfo and parse the entries */
1155 newinfo->chainstack = NULL; 1192 newinfo->chainstack = NULL;
1156 ret = translate_table(table->table, newinfo); 1193 for (i = 0; i < NF_BR_NUMHOOKS; i++) {
1194 if ((repl->valid_hooks & (1 << i)) == 0)
1195 newinfo->hook_entry[i] = NULL;
1196 else
1197 newinfo->hook_entry[i] = p +
1198 ((char *)repl->hook_entry[i] - repl->entries);
1199 }
1200 ret = translate_table(repl->name, newinfo);
1157 if (ret != 0) { 1201 if (ret != 0) {
1158 BUGPRINT("Translate_table failed\n"); 1202 BUGPRINT("Translate_table failed\n");
1159 goto free_chainstack; 1203 goto free_chainstack;
@@ -1277,33 +1321,33 @@ free_tmp:
1277} 1321}
1278 1322
1279static inline int ebt_make_matchname(struct ebt_entry_match *m, 1323static inline int ebt_make_matchname(struct ebt_entry_match *m,
1280 char *base, char *ubase) 1324 char *base, char __user *ubase)
1281{ 1325{
1282 char *hlp = ubase - base + (char *)m; 1326 char __user *hlp = ubase + ((char *)m - base);
1283 if (copy_to_user(hlp, m->u.match->name, EBT_FUNCTION_MAXNAMELEN)) 1327 if (copy_to_user(hlp, m->u.match->name, EBT_FUNCTION_MAXNAMELEN))
1284 return -EFAULT; 1328 return -EFAULT;
1285 return 0; 1329 return 0;
1286} 1330}
1287 1331
1288static inline int ebt_make_watchername(struct ebt_entry_watcher *w, 1332static inline int ebt_make_watchername(struct ebt_entry_watcher *w,
1289 char *base, char *ubase) 1333 char *base, char __user *ubase)
1290{ 1334{
1291 char *hlp = ubase - base + (char *)w; 1335 char __user *hlp = ubase + ((char *)w - base);
1292 if (copy_to_user(hlp , w->u.watcher->name, EBT_FUNCTION_MAXNAMELEN)) 1336 if (copy_to_user(hlp , w->u.watcher->name, EBT_FUNCTION_MAXNAMELEN))
1293 return -EFAULT; 1337 return -EFAULT;
1294 return 0; 1338 return 0;
1295} 1339}
1296 1340
1297static inline int ebt_make_names(struct ebt_entry *e, char *base, char *ubase) 1341static inline int ebt_make_names(struct ebt_entry *e, char *base, char __user *ubase)
1298{ 1342{
1299 int ret; 1343 int ret;
1300 char *hlp; 1344 char __user *hlp;
1301 struct ebt_entry_target *t; 1345 struct ebt_entry_target *t;
1302 1346
1303 if ((e->bitmask & EBT_ENTRY_OR_ENTRIES) == 0) 1347 if (e->bitmask == 0)
1304 return 0; 1348 return 0;
1305 1349
1306 hlp = ubase - base + (char *)e + e->target_offset; 1350 hlp = ubase + (((char *)e + e->target_offset) - base);
1307 t = (struct ebt_entry_target *)(((char *)e) + e->target_offset); 1351 t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);
1308 1352
1309 ret = EBT_MATCH_ITERATE(e, ebt_make_matchname, base, ubase); 1353 ret = EBT_MATCH_ITERATE(e, ebt_make_matchname, base, ubase);
diff --git a/net/core/Makefile b/net/core/Makefile
index 119568077dab..73272d506e93 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -12,7 +12,6 @@ obj-y += dev.o ethtool.o dev_mcast.o dst.o netevent.o \
12 12
13obj-$(CONFIG_XFRM) += flow.o 13obj-$(CONFIG_XFRM) += flow.o
14obj-$(CONFIG_SYSFS) += net-sysfs.o 14obj-$(CONFIG_SYSFS) += net-sysfs.o
15obj-$(CONFIG_NET_DIVERT) += dv.o
16obj-$(CONFIG_NET_PKTGEN) += pktgen.o 15obj-$(CONFIG_NET_PKTGEN) += pktgen.o
17obj-$(CONFIG_WIRELESS_EXT) += wireless.o 16obj-$(CONFIG_WIRELESS_EXT) += wireless.o
18obj-$(CONFIG_NETPOLL) += netpoll.o 17obj-$(CONFIG_NETPOLL) += netpoll.o
diff --git a/net/core/datagram.c b/net/core/datagram.c
index f558c61aecc7..797fdd4352ce 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -321,7 +321,7 @@ fault:
321 321
322static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, 322static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
323 u8 __user *to, int len, 323 u8 __user *to, int len,
324 unsigned int *csump) 324 __wsum *csump)
325{ 325{
326 int start = skb_headlen(skb); 326 int start = skb_headlen(skb);
327 int pos = 0; 327 int pos = 0;
@@ -350,7 +350,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
350 350
351 end = start + skb_shinfo(skb)->frags[i].size; 351 end = start + skb_shinfo(skb)->frags[i].size;
352 if ((copy = end - offset) > 0) { 352 if ((copy = end - offset) > 0) {
353 unsigned int csum2; 353 __wsum csum2;
354 int err = 0; 354 int err = 0;
355 u8 *vaddr; 355 u8 *vaddr;
356 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 356 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
@@ -386,7 +386,7 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset,
386 386
387 end = start + list->len; 387 end = start + list->len;
388 if ((copy = end - offset) > 0) { 388 if ((copy = end - offset) > 0) {
389 unsigned int csum2 = 0; 389 __wsum csum2 = 0;
390 if (copy > len) 390 if (copy > len)
391 copy = len; 391 copy = len;
392 if (skb_copy_and_csum_datagram(list, 392 if (skb_copy_and_csum_datagram(list,
@@ -411,11 +411,11 @@ fault:
411 return -EFAULT; 411 return -EFAULT;
412} 412}
413 413
414unsigned int __skb_checksum_complete(struct sk_buff *skb) 414__sum16 __skb_checksum_complete(struct sk_buff *skb)
415{ 415{
416 unsigned int sum; 416 __sum16 sum;
417 417
418 sum = (u16)csum_fold(skb_checksum(skb, 0, skb->len, skb->csum)); 418 sum = csum_fold(skb_checksum(skb, 0, skb->len, skb->csum));
419 if (likely(!sum)) { 419 if (likely(!sum)) {
420 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) 420 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
421 netdev_rx_csum_fault(skb->dev); 421 netdev_rx_csum_fault(skb->dev);
@@ -441,7 +441,7 @@ EXPORT_SYMBOL(__skb_checksum_complete);
441int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, 441int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
442 int hlen, struct iovec *iov) 442 int hlen, struct iovec *iov)
443{ 443{
444 unsigned int csum; 444 __wsum csum;
445 int chunk = skb->len - hlen; 445 int chunk = skb->len - hlen;
446 446
447 /* Skip filled elements. 447 /* Skip filled elements.
@@ -460,7 +460,7 @@ int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
460 if (skb_copy_and_csum_datagram(skb, hlen, iov->iov_base, 460 if (skb_copy_and_csum_datagram(skb, hlen, iov->iov_base,
461 chunk, &csum)) 461 chunk, &csum))
462 goto fault; 462 goto fault;
463 if ((unsigned short)csum_fold(csum)) 463 if (csum_fold(csum))
464 goto csum_error; 464 goto csum_error;
465 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) 465 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
466 netdev_rx_csum_fault(skb->dev); 466 netdev_rx_csum_fault(skb->dev);
diff --git a/net/core/dev.c b/net/core/dev.c
index 81c426adcd1e..59d058a3b504 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -98,7 +98,6 @@
98#include <linux/seq_file.h> 98#include <linux/seq_file.h>
99#include <linux/stat.h> 99#include <linux/stat.h>
100#include <linux/if_bridge.h> 100#include <linux/if_bridge.h>
101#include <linux/divert.h>
102#include <net/dst.h> 101#include <net/dst.h>
103#include <net/pkt_sched.h> 102#include <net/pkt_sched.h>
104#include <net/checksum.h> 103#include <net/checksum.h>
@@ -1170,7 +1169,7 @@ EXPORT_SYMBOL(netif_device_attach);
1170 */ 1169 */
1171int skb_checksum_help(struct sk_buff *skb) 1170int skb_checksum_help(struct sk_buff *skb)
1172{ 1171{
1173 unsigned int csum; 1172 __wsum csum;
1174 int ret = 0, offset = skb->h.raw - skb->data; 1173 int ret = 0, offset = skb->h.raw - skb->data;
1175 1174
1176 if (skb->ip_summed == CHECKSUM_COMPLETE) 1175 if (skb->ip_summed == CHECKSUM_COMPLETE)
@@ -1192,9 +1191,9 @@ int skb_checksum_help(struct sk_buff *skb)
1192 1191
1193 offset = skb->tail - skb->h.raw; 1192 offset = skb->tail - skb->h.raw;
1194 BUG_ON(offset <= 0); 1193 BUG_ON(offset <= 0);
1195 BUG_ON(skb->csum + 2 > offset); 1194 BUG_ON(skb->csum_offset + 2 > offset);
1196 1195
1197 *(u16*)(skb->h.raw + skb->csum) = csum_fold(csum); 1196 *(__sum16*)(skb->h.raw + skb->csum_offset) = csum_fold(csum);
1198 1197
1199out_set_summed: 1198out_set_summed:
1200 skb->ip_summed = CHECKSUM_NONE; 1199 skb->ip_summed = CHECKSUM_NONE;
@@ -1216,7 +1215,7 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features)
1216{ 1215{
1217 struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT); 1216 struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT);
1218 struct packet_type *ptype; 1217 struct packet_type *ptype;
1219 int type = skb->protocol; 1218 __be16 type = skb->protocol;
1220 int err; 1219 int err;
1221 1220
1222 BUG_ON(skb_shinfo(skb)->frag_list); 1221 BUG_ON(skb_shinfo(skb)->frag_list);
@@ -1767,7 +1766,7 @@ int netif_receive_skb(struct sk_buff *skb)
1767 struct packet_type *ptype, *pt_prev; 1766 struct packet_type *ptype, *pt_prev;
1768 struct net_device *orig_dev; 1767 struct net_device *orig_dev;
1769 int ret = NET_RX_DROP; 1768 int ret = NET_RX_DROP;
1770 unsigned short type; 1769 __be16 type;
1771 1770
1772 /* if we've gotten here through NAPI, check netpoll */ 1771 /* if we've gotten here through NAPI, check netpoll */
1773 if (skb->dev->poll && netpoll_rx(skb)) 1772 if (skb->dev->poll && netpoll_rx(skb))
@@ -1827,8 +1826,6 @@ int netif_receive_skb(struct sk_buff *skb)
1827ncls: 1826ncls:
1828#endif 1827#endif
1829 1828
1830 handle_diverter(skb);
1831
1832 if (handle_bridge(&skb, &pt_prev, &ret, orig_dev)) 1829 if (handle_bridge(&skb, &pt_prev, &ret, orig_dev))
1833 goto out; 1830 goto out;
1834 1831
@@ -2898,10 +2895,6 @@ int register_netdevice(struct net_device *dev)
2898 spin_lock_init(&dev->ingress_lock); 2895 spin_lock_init(&dev->ingress_lock);
2899#endif 2896#endif
2900 2897
2901 ret = alloc_divert_blk(dev);
2902 if (ret)
2903 goto out;
2904
2905 dev->iflink = -1; 2898 dev->iflink = -1;
2906 2899
2907 /* Init, if this function is available */ 2900 /* Init, if this function is available */
@@ -2910,13 +2903,13 @@ int register_netdevice(struct net_device *dev)
2910 if (ret) { 2903 if (ret) {
2911 if (ret > 0) 2904 if (ret > 0)
2912 ret = -EIO; 2905 ret = -EIO;
2913 goto out_err; 2906 goto out;
2914 } 2907 }
2915 } 2908 }
2916 2909
2917 if (!dev_valid_name(dev->name)) { 2910 if (!dev_valid_name(dev->name)) {
2918 ret = -EINVAL; 2911 ret = -EINVAL;
2919 goto out_err; 2912 goto out;
2920 } 2913 }
2921 2914
2922 dev->ifindex = dev_new_index(); 2915 dev->ifindex = dev_new_index();
@@ -2930,7 +2923,7 @@ int register_netdevice(struct net_device *dev)
2930 = hlist_entry(p, struct net_device, name_hlist); 2923 = hlist_entry(p, struct net_device, name_hlist);
2931 if (!strncmp(d->name, dev->name, IFNAMSIZ)) { 2924 if (!strncmp(d->name, dev->name, IFNAMSIZ)) {
2932 ret = -EEXIST; 2925 ret = -EEXIST;
2933 goto out_err; 2926 goto out;
2934 } 2927 }
2935 } 2928 }
2936 2929
@@ -2974,7 +2967,7 @@ int register_netdevice(struct net_device *dev)
2974 2967
2975 ret = netdev_register_sysfs(dev); 2968 ret = netdev_register_sysfs(dev);
2976 if (ret) 2969 if (ret)
2977 goto out_err; 2970 goto out;
2978 dev->reg_state = NETREG_REGISTERED; 2971 dev->reg_state = NETREG_REGISTERED;
2979 2972
2980 /* 2973 /*
@@ -3001,9 +2994,6 @@ int register_netdevice(struct net_device *dev)
3001 2994
3002out: 2995out:
3003 return ret; 2996 return ret;
3004out_err:
3005 free_divert_blk(dev);
3006 goto out;
3007} 2997}
3008 2998
3009/** 2999/**
@@ -3035,15 +3025,6 @@ int register_netdev(struct net_device *dev)
3035 goto out; 3025 goto out;
3036 } 3026 }
3037 3027
3038 /*
3039 * Back compatibility hook. Kill this one in 2.5
3040 */
3041 if (dev->name[0] == 0 || dev->name[0] == ' ') {
3042 err = dev_alloc_name(dev, "eth%d");
3043 if (err < 0)
3044 goto out;
3045 }
3046
3047 err = register_netdevice(dev); 3028 err = register_netdevice(dev);
3048out: 3029out:
3049 rtnl_unlock(); 3030 rtnl_unlock();
@@ -3329,8 +3310,6 @@ int unregister_netdevice(struct net_device *dev)
3329 /* Notifier chain MUST detach us from master device. */ 3310 /* Notifier chain MUST detach us from master device. */
3330 BUG_TRAP(!dev->master); 3311 BUG_TRAP(!dev->master);
3331 3312
3332 free_divert_blk(dev);
3333
3334 /* Finish processing unregister after unlock */ 3313 /* Finish processing unregister after unlock */
3335 net_set_todo(dev); 3314 net_set_todo(dev);
3336 3315
diff --git a/net/core/dv.c b/net/core/dv.c
deleted file mode 100644
index 29ee77f15932..000000000000
--- a/net/core/dv.c
+++ /dev/null
@@ -1,546 +0,0 @@
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Generic frame diversion
7 *
8 * Authors:
9 * Benoit LOCHER: initial integration within the kernel with support for ethernet
10 * Dave Miller: improvement on the code (correctness, performance and source files)
11 *
12 */
13#include <linux/module.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16#include <linux/sched.h>
17#include <linux/string.h>
18#include <linux/mm.h>
19#include <linux/socket.h>
20#include <linux/in.h>
21#include <linux/inet.h>
22#include <linux/ip.h>
23#include <linux/udp.h>
24#include <linux/netdevice.h>
25#include <linux/etherdevice.h>
26#include <linux/skbuff.h>
27#include <linux/capability.h>
28#include <linux/errno.h>
29#include <linux/init.h>
30#include <net/dst.h>
31#include <net/arp.h>
32#include <net/sock.h>
33#include <net/ipv6.h>
34#include <net/ip.h>
35#include <asm/uaccess.h>
36#include <asm/system.h>
37#include <asm/checksum.h>
38#include <linux/divert.h>
39#include <linux/sockios.h>
40
41const char sysctl_divert_version[32]="0.46"; /* Current version */
42
43static int __init dv_init(void)
44{
45 return 0;
46}
47module_init(dv_init);
48
49/*
50 * Allocate a divert_blk for a device. This must be an ethernet nic.
51 */
52int alloc_divert_blk(struct net_device *dev)
53{
54 int alloc_size = (sizeof(struct divert_blk) + 3) & ~3;
55
56 dev->divert = NULL;
57 if (dev->type == ARPHRD_ETHER) {
58 dev->divert = kzalloc(alloc_size, GFP_KERNEL);
59 if (dev->divert == NULL) {
60 printk(KERN_INFO "divert: unable to allocate divert_blk for %s\n",
61 dev->name);
62 return -ENOMEM;
63 }
64 dev_hold(dev);
65 }
66
67 return 0;
68}
69
70/*
71 * Free a divert_blk allocated by the above function, if it was
72 * allocated on that device.
73 */
74void free_divert_blk(struct net_device *dev)
75{
76 if (dev->divert) {
77 kfree(dev->divert);
78 dev->divert=NULL;
79 dev_put(dev);
80 }
81}
82
83/*
84 * Adds a tcp/udp (source or dest) port to an array
85 */
86static int add_port(u16 ports[], u16 port)
87{
88 int i;
89
90 if (port == 0)
91 return -EINVAL;
92
93 /* Storing directly in network format for performance,
94 * thanks Dave :)
95 */
96 port = htons(port);
97
98 for (i = 0; i < MAX_DIVERT_PORTS; i++) {
99 if (ports[i] == port)
100 return -EALREADY;
101 }
102
103 for (i = 0; i < MAX_DIVERT_PORTS; i++) {
104 if (ports[i] == 0) {
105 ports[i] = port;
106 return 0;
107 }
108 }
109
110 return -ENOBUFS;
111}
112
113/*
114 * Removes a port from an array tcp/udp (source or dest)
115 */
116static int remove_port(u16 ports[], u16 port)
117{
118 int i;
119
120 if (port == 0)
121 return -EINVAL;
122
123 /* Storing directly in network format for performance,
124 * thanks Dave !
125 */
126 port = htons(port);
127
128 for (i = 0; i < MAX_DIVERT_PORTS; i++) {
129 if (ports[i] == port) {
130 ports[i] = 0;
131 return 0;
132 }
133 }
134
135 return -EINVAL;
136}
137
138/* Some basic sanity checks on the arguments passed to divert_ioctl() */
139static int check_args(struct divert_cf *div_cf, struct net_device **dev)
140{
141 char devname[32];
142 int ret;
143
144 if (dev == NULL)
145 return -EFAULT;
146
147 /* GETVERSION: all other args are unused */
148 if (div_cf->cmd == DIVCMD_GETVERSION)
149 return 0;
150
151 /* Network device index should reasonably be between 0 and 1000 :) */
152 if (div_cf->dev_index < 0 || div_cf->dev_index > 1000)
153 return -EINVAL;
154
155 /* Let's try to find the ifname */
156 sprintf(devname, "eth%d", div_cf->dev_index);
157 *dev = dev_get_by_name(devname);
158
159 /* dev should NOT be null */
160 if (*dev == NULL)
161 return -EINVAL;
162
163 ret = 0;
164
165 /* user issuing the ioctl must be a super one :) */
166 if (!capable(CAP_SYS_ADMIN)) {
167 ret = -EPERM;
168 goto out;
169 }
170
171 /* Device must have a divert_blk member NOT null */
172 if ((*dev)->divert == NULL)
173 ret = -EINVAL;
174out:
175 dev_put(*dev);
176 return ret;
177}
178
179/*
180 * control function of the diverter
181 */
182#if 0
183#define DVDBG(a) \
184 printk(KERN_DEBUG "divert_ioctl() line %d %s\n", __LINE__, (a))
185#else
186#define DVDBG(a)
187#endif
188
189int divert_ioctl(unsigned int cmd, struct divert_cf __user *arg)
190{
191 struct divert_cf div_cf;
192 struct divert_blk *div_blk;
193 struct net_device *dev;
194 int ret;
195
196 switch (cmd) {
197 case SIOCGIFDIVERT:
198 DVDBG("SIOCGIFDIVERT, copy_from_user");
199 if (copy_from_user(&div_cf, arg, sizeof(struct divert_cf)))
200 return -EFAULT;
201 DVDBG("before check_args");
202 ret = check_args(&div_cf, &dev);
203 if (ret)
204 return ret;
205 DVDBG("after checkargs");
206 div_blk = dev->divert;
207
208 DVDBG("befre switch()");
209 switch (div_cf.cmd) {
210 case DIVCMD_GETSTATUS:
211 /* Now, just give the user the raw divert block
212 * for him to play with :)
213 */
214 if (copy_to_user(div_cf.arg1.ptr, dev->divert,
215 sizeof(struct divert_blk)))
216 return -EFAULT;
217 break;
218
219 case DIVCMD_GETVERSION:
220 DVDBG("GETVERSION: checking ptr");
221 if (div_cf.arg1.ptr == NULL)
222 return -EINVAL;
223 DVDBG("GETVERSION: copying data to userland");
224 if (copy_to_user(div_cf.arg1.ptr,
225 sysctl_divert_version, 32))
226 return -EFAULT;
227 DVDBG("GETVERSION: data copied");
228 break;
229
230 default:
231 return -EINVAL;
232 }
233
234 break;
235
236 case SIOCSIFDIVERT:
237 if (copy_from_user(&div_cf, arg, sizeof(struct divert_cf)))
238 return -EFAULT;
239
240 ret = check_args(&div_cf, &dev);
241 if (ret)
242 return ret;
243
244 div_blk = dev->divert;
245
246 switch(div_cf.cmd) {
247 case DIVCMD_RESET:
248 div_blk->divert = 0;
249 div_blk->protos = DIVERT_PROTO_NONE;
250 memset(div_blk->tcp_dst, 0,
251 MAX_DIVERT_PORTS * sizeof(u16));
252 memset(div_blk->tcp_src, 0,
253 MAX_DIVERT_PORTS * sizeof(u16));
254 memset(div_blk->udp_dst, 0,
255 MAX_DIVERT_PORTS * sizeof(u16));
256 memset(div_blk->udp_src, 0,
257 MAX_DIVERT_PORTS * sizeof(u16));
258 return 0;
259
260 case DIVCMD_DIVERT:
261 switch(div_cf.arg1.int32) {
262 case DIVARG1_ENABLE:
263 if (div_blk->divert)
264 return -EALREADY;
265 div_blk->divert = 1;
266 break;
267
268 case DIVARG1_DISABLE:
269 if (!div_blk->divert)
270 return -EALREADY;
271 div_blk->divert = 0;
272 break;
273
274 default:
275 return -EINVAL;
276 }
277
278 break;
279
280 case DIVCMD_IP:
281 switch(div_cf.arg1.int32) {
282 case DIVARG1_ENABLE:
283 if (div_blk->protos & DIVERT_PROTO_IP)
284 return -EALREADY;
285 div_blk->protos |= DIVERT_PROTO_IP;
286 break;
287
288 case DIVARG1_DISABLE:
289 if (!(div_blk->protos & DIVERT_PROTO_IP))
290 return -EALREADY;
291 div_blk->protos &= ~DIVERT_PROTO_IP;
292 break;
293
294 default:
295 return -EINVAL;
296 }
297
298 break;
299
300 case DIVCMD_TCP:
301 switch(div_cf.arg1.int32) {
302 case DIVARG1_ENABLE:
303 if (div_blk->protos & DIVERT_PROTO_TCP)
304 return -EALREADY;
305 div_blk->protos |= DIVERT_PROTO_TCP;
306 break;
307
308 case DIVARG1_DISABLE:
309 if (!(div_blk->protos & DIVERT_PROTO_TCP))
310 return -EALREADY;
311 div_blk->protos &= ~DIVERT_PROTO_TCP;
312 break;
313
314 default:
315 return -EINVAL;
316 }
317
318 break;
319
320 case DIVCMD_TCPDST:
321 switch(div_cf.arg1.int32) {
322 case DIVARG1_ADD:
323 return add_port(div_blk->tcp_dst,
324 div_cf.arg2.uint16);
325
326 case DIVARG1_REMOVE:
327 return remove_port(div_blk->tcp_dst,
328 div_cf.arg2.uint16);
329
330 default:
331 return -EINVAL;
332 }
333
334 break;
335
336 case DIVCMD_TCPSRC:
337 switch(div_cf.arg1.int32) {
338 case DIVARG1_ADD:
339 return add_port(div_blk->tcp_src,
340 div_cf.arg2.uint16);
341
342 case DIVARG1_REMOVE:
343 return remove_port(div_blk->tcp_src,
344 div_cf.arg2.uint16);
345
346 default:
347 return -EINVAL;
348 }
349
350 break;
351
352 case DIVCMD_UDP:
353 switch(div_cf.arg1.int32) {
354 case DIVARG1_ENABLE:
355 if (div_blk->protos & DIVERT_PROTO_UDP)
356 return -EALREADY;
357 div_blk->protos |= DIVERT_PROTO_UDP;
358 break;
359
360 case DIVARG1_DISABLE:
361 if (!(div_blk->protos & DIVERT_PROTO_UDP))
362 return -EALREADY;
363 div_blk->protos &= ~DIVERT_PROTO_UDP;
364 break;
365
366 default:
367 return -EINVAL;
368 }
369
370 break;
371
372 case DIVCMD_UDPDST:
373 switch(div_cf.arg1.int32) {
374 case DIVARG1_ADD:
375 return add_port(div_blk->udp_dst,
376 div_cf.arg2.uint16);
377
378 case DIVARG1_REMOVE:
379 return remove_port(div_blk->udp_dst,
380 div_cf.arg2.uint16);
381
382 default:
383 return -EINVAL;
384 }
385
386 break;
387
388 case DIVCMD_UDPSRC:
389 switch(div_cf.arg1.int32) {
390 case DIVARG1_ADD:
391 return add_port(div_blk->udp_src,
392 div_cf.arg2.uint16);
393
394 case DIVARG1_REMOVE:
395 return remove_port(div_blk->udp_src,
396 div_cf.arg2.uint16);
397
398 default:
399 return -EINVAL;
400 }
401
402 break;
403
404 case DIVCMD_ICMP:
405 switch(div_cf.arg1.int32) {
406 case DIVARG1_ENABLE:
407 if (div_blk->protos & DIVERT_PROTO_ICMP)
408 return -EALREADY;
409 div_blk->protos |= DIVERT_PROTO_ICMP;
410 break;
411
412 case DIVARG1_DISABLE:
413 if (!(div_blk->protos & DIVERT_PROTO_ICMP))
414 return -EALREADY;
415 div_blk->protos &= ~DIVERT_PROTO_ICMP;
416 break;
417
418 default:
419 return -EINVAL;
420 }
421
422 break;
423
424 default:
425 return -EINVAL;
426 }
427
428 break;
429
430 default:
431 return -EINVAL;
432 }
433
434 return 0;
435}
436
437
438/*
439 * Check if packet should have its dest mac address set to the box itself
440 * for diversion
441 */
442
443#define ETH_DIVERT_FRAME(skb) \
444 memcpy(eth_hdr(skb), skb->dev->dev_addr, ETH_ALEN); \
445 skb->pkt_type=PACKET_HOST
446
447void divert_frame(struct sk_buff *skb)
448{
449 struct ethhdr *eth = eth_hdr(skb);
450 struct iphdr *iph;
451 struct tcphdr *tcph;
452 struct udphdr *udph;
453 struct divert_blk *divert = skb->dev->divert;
454 int i, src, dst;
455 unsigned char *skb_data_end = skb->data + skb->len;
456
457 /* Packet is already aimed at us, return */
458 if (!compare_ether_addr(eth->h_dest, skb->dev->dev_addr))
459 return;
460
461 /* proto is not IP, do nothing */
462 if (eth->h_proto != htons(ETH_P_IP))
463 return;
464
465 /* Divert all IP frames ? */
466 if (divert->protos & DIVERT_PROTO_IP) {
467 ETH_DIVERT_FRAME(skb);
468 return;
469 }
470
471 /* Check for possible (maliciously) malformed IP frame (thanks Dave) */
472 iph = (struct iphdr *) skb->data;
473 if (((iph->ihl<<2)+(unsigned char*)(iph)) >= skb_data_end) {
474 printk(KERN_INFO "divert: malformed IP packet !\n");
475 return;
476 }
477
478 switch (iph->protocol) {
479 /* Divert all ICMP frames ? */
480 case IPPROTO_ICMP:
481 if (divert->protos & DIVERT_PROTO_ICMP) {
482 ETH_DIVERT_FRAME(skb);
483 return;
484 }
485 break;
486
487 /* Divert all TCP frames ? */
488 case IPPROTO_TCP:
489 if (divert->protos & DIVERT_PROTO_TCP) {
490 ETH_DIVERT_FRAME(skb);
491 return;
492 }
493
494 /* Check for possible (maliciously) malformed IP
495 * frame (thanx Dave)
496 */
497 tcph = (struct tcphdr *)
498 (((unsigned char *)iph) + (iph->ihl<<2));
499 if (((unsigned char *)(tcph+1)) >= skb_data_end) {
500 printk(KERN_INFO "divert: malformed TCP packet !\n");
501 return;
502 }
503
504 /* Divert some tcp dst/src ports only ?*/
505 for (i = 0; i < MAX_DIVERT_PORTS; i++) {
506 dst = divert->tcp_dst[i];
507 src = divert->tcp_src[i];
508 if ((dst && dst == tcph->dest) ||
509 (src && src == tcph->source)) {
510 ETH_DIVERT_FRAME(skb);
511 return;
512 }
513 }
514 break;
515
516 /* Divert all UDP frames ? */
517 case IPPROTO_UDP:
518 if (divert->protos & DIVERT_PROTO_UDP) {
519 ETH_DIVERT_FRAME(skb);
520 return;
521 }
522
523 /* Check for possible (maliciously) malformed IP
524 * packet (thanks Dave)
525 */
526 udph = (struct udphdr *)
527 (((unsigned char *)iph) + (iph->ihl<<2));
528 if (((unsigned char *)(udph+1)) >= skb_data_end) {
529 printk(KERN_INFO
530 "divert: malformed UDP packet !\n");
531 return;
532 }
533
534 /* Divert some udp dst/src ports only ? */
535 for (i = 0; i < MAX_DIVERT_PORTS; i++) {
536 dst = divert->udp_dst[i];
537 src = divert->udp_src[i];
538 if ((dst && dst == udph->dest) ||
539 (src && src == udph->source)) {
540 ETH_DIVERT_FRAME(skb);
541 return;
542 }
543 }
544 break;
545 }
546}
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 6b0e63cacd93..1df6cd4568d3 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -107,6 +107,22 @@ out:
107 107
108EXPORT_SYMBOL_GPL(fib_rules_unregister); 108EXPORT_SYMBOL_GPL(fib_rules_unregister);
109 109
110static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
111 struct flowi *fl, int flags)
112{
113 int ret = 0;
114
115 if (rule->ifindex && (rule->ifindex != fl->iif))
116 goto out;
117
118 if ((rule->mark ^ fl->mark) & rule->mark_mask)
119 goto out;
120
121 ret = ops->match(rule, fl, flags);
122out:
123 return (rule->flags & FIB_RULE_INVERT) ? !ret : ret;
124}
125
110int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl, 126int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,
111 int flags, struct fib_lookup_arg *arg) 127 int flags, struct fib_lookup_arg *arg)
112{ 128{
@@ -116,10 +132,7 @@ int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,
116 rcu_read_lock(); 132 rcu_read_lock();
117 133
118 list_for_each_entry_rcu(rule, ops->rules_list, list) { 134 list_for_each_entry_rcu(rule, ops->rules_list, list) {
119 if (rule->ifindex && (rule->ifindex != fl->iif)) 135 if (!fib_rule_match(rule, ops, fl, flags))
120 continue;
121
122 if (!ops->match(rule, fl, flags))
123 continue; 136 continue;
124 137
125 err = ops->action(rule, fl, flags, arg); 138 err = ops->action(rule, fl, flags, arg);
@@ -179,6 +192,18 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
179 rule->ifindex = dev->ifindex; 192 rule->ifindex = dev->ifindex;
180 } 193 }
181 194
195 if (tb[FRA_FWMARK]) {
196 rule->mark = nla_get_u32(tb[FRA_FWMARK]);
197 if (rule->mark)
198 /* compatibility: if the mark value is non-zero all bits
199 * are compared unless a mask is explicitly specified.
200 */
201 rule->mark_mask = 0xFFFFFFFF;
202 }
203
204 if (tb[FRA_FWMASK])
205 rule->mark_mask = nla_get_u32(tb[FRA_FWMASK]);
206
182 rule->action = frh->action; 207 rule->action = frh->action;
183 rule->flags = frh->flags; 208 rule->flags = frh->flags;
184 rule->table = frh_get_table(frh, tb); 209 rule->table = frh_get_table(frh, tb);
@@ -250,6 +275,14 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
250 nla_strcmp(tb[FRA_IFNAME], rule->ifname)) 275 nla_strcmp(tb[FRA_IFNAME], rule->ifname))
251 continue; 276 continue;
252 277
278 if (tb[FRA_FWMARK] &&
279 (rule->mark != nla_get_u32(tb[FRA_FWMARK])))
280 continue;
281
282 if (tb[FRA_FWMASK] &&
283 (rule->mark_mask != nla_get_u32(tb[FRA_FWMASK])))
284 continue;
285
253 if (!ops->compare(rule, frh, tb)) 286 if (!ops->compare(rule, frh, tb))
254 continue; 287 continue;
255 288
@@ -273,6 +306,22 @@ errout:
273 return err; 306 return err;
274} 307}
275 308
309static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops,
310 struct fib_rule *rule)
311{
312 size_t payload = NLMSG_ALIGN(sizeof(struct fib_rule_hdr))
313 + nla_total_size(IFNAMSIZ) /* FRA_IFNAME */
314 + nla_total_size(4) /* FRA_PRIORITY */
315 + nla_total_size(4) /* FRA_TABLE */
316 + nla_total_size(4) /* FRA_FWMARK */
317 + nla_total_size(4); /* FRA_FWMASK */
318
319 if (ops->nlmsg_payload)
320 payload += ops->nlmsg_payload(rule);
321
322 return payload;
323}
324
276static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule, 325static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
277 u32 pid, u32 seq, int type, int flags, 326 u32 pid, u32 seq, int type, int flags,
278 struct fib_rules_ops *ops) 327 struct fib_rules_ops *ops)
@@ -298,6 +347,12 @@ static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
298 if (rule->pref) 347 if (rule->pref)
299 NLA_PUT_U32(skb, FRA_PRIORITY, rule->pref); 348 NLA_PUT_U32(skb, FRA_PRIORITY, rule->pref);
300 349
350 if (rule->mark)
351 NLA_PUT_U32(skb, FRA_FWMARK, rule->mark);
352
353 if (rule->mark_mask || rule->mark)
354 NLA_PUT_U32(skb, FRA_FWMASK, rule->mark_mask);
355
301 if (ops->fill(rule, skb, nlh, frh) < 0) 356 if (ops->fill(rule, skb, nlh, frh) < 0)
302 goto nla_put_failure; 357 goto nla_put_failure;
303 358
@@ -345,15 +400,13 @@ static void notify_rule_change(int event, struct fib_rule *rule,
345 struct sk_buff *skb; 400 struct sk_buff *skb;
346 int err = -ENOBUFS; 401 int err = -ENOBUFS;
347 402
348 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 403 skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL);
349 if (skb == NULL) 404 if (skb == NULL)
350 goto errout; 405 goto errout;
351 406
352 err = fib_nl_fill_rule(skb, rule, pid, nlh->nlmsg_seq, event, 0, ops); 407 err = fib_nl_fill_rule(skb, rule, pid, nlh->nlmsg_seq, event, 0, ops);
353 if (err < 0) { 408 /* failure implies BUG in fib_rule_nlmsg_size() */
354 kfree_skb(skb); 409 BUG_ON(err < 0);
355 goto errout;
356 }
357 410
358 err = rtnl_notify(skb, pid, ops->nlgroup, nlh, GFP_KERNEL); 411 err = rtnl_notify(skb, pid, ops->nlgroup, nlh, GFP_KERNEL);
359errout: 412errout:
diff --git a/net/core/filter.c b/net/core/filter.c
index 6732782a5a40..0df843b667f4 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -178,7 +178,7 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int
178load_w: 178load_w:
179 ptr = load_pointer(skb, k, 4, &tmp); 179 ptr = load_pointer(skb, k, 4, &tmp);
180 if (ptr != NULL) { 180 if (ptr != NULL) {
181 A = ntohl(get_unaligned((u32 *)ptr)); 181 A = ntohl(get_unaligned((__be32 *)ptr));
182 continue; 182 continue;
183 } 183 }
184 break; 184 break;
@@ -187,7 +187,7 @@ load_w:
187load_h: 187load_h:
188 ptr = load_pointer(skb, k, 2, &tmp); 188 ptr = load_pointer(skb, k, 2, &tmp);
189 if (ptr != NULL) { 189 if (ptr != NULL) {
190 A = ntohs(get_unaligned((u16 *)ptr)); 190 A = ntohs(get_unaligned((__be16 *)ptr));
191 continue; 191 continue;
192 } 192 }
193 break; 193 break;
@@ -261,7 +261,7 @@ load_b:
261 */ 261 */
262 switch (k-SKF_AD_OFF) { 262 switch (k-SKF_AD_OFF) {
263 case SKF_AD_PROTOCOL: 263 case SKF_AD_PROTOCOL:
264 A = htons(skb->protocol); 264 A = ntohs(skb->protocol);
265 continue; 265 continue;
266 case SKF_AD_PKTTYPE: 266 case SKF_AD_PKTTYPE:
267 A = skb->pkt_type; 267 A = skb->pkt_type;
diff --git a/net/core/iovec.c b/net/core/iovec.c
index 65e4b56fbc77..04b249c40b5b 100644
--- a/net/core/iovec.c
+++ b/net/core/iovec.c
@@ -158,9 +158,9 @@ int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov, int offset,
158 * call to this function will be unaligned also. 158 * call to this function will be unaligned also.
159 */ 159 */
160int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov, 160int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
161 int offset, unsigned int len, int *csump) 161 int offset, unsigned int len, __wsum *csump)
162{ 162{
163 int csum = *csump; 163 __wsum csum = *csump;
164 int partial_cnt = 0, err = 0; 164 int partial_cnt = 0, err = 0;
165 165
166 /* Skip over the finished iovecs */ 166 /* Skip over the finished iovecs */
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index b4b478353b27..ba509a4a8e92 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1266,10 +1266,9 @@ void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
1266struct neigh_parms *neigh_parms_alloc(struct net_device *dev, 1266struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
1267 struct neigh_table *tbl) 1267 struct neigh_table *tbl)
1268{ 1268{
1269 struct neigh_parms *p = kmalloc(sizeof(*p), GFP_KERNEL); 1269 struct neigh_parms *p = kmemdup(&tbl->parms, sizeof(*p), GFP_KERNEL);
1270 1270
1271 if (p) { 1271 if (p) {
1272 memcpy(p, &tbl->parms, sizeof(*p));
1273 p->tbl = tbl; 1272 p->tbl = tbl;
1274 atomic_set(&p->refcnt, 1); 1273 atomic_set(&p->refcnt, 1);
1275 INIT_RCU_HEAD(&p->rcu_head); 1274 INIT_RCU_HEAD(&p->rcu_head);
@@ -2410,20 +2409,27 @@ static struct file_operations neigh_stat_seq_fops = {
2410#endif /* CONFIG_PROC_FS */ 2409#endif /* CONFIG_PROC_FS */
2411 2410
2412#ifdef CONFIG_ARPD 2411#ifdef CONFIG_ARPD
2412static inline size_t neigh_nlmsg_size(void)
2413{
2414 return NLMSG_ALIGN(sizeof(struct ndmsg))
2415 + nla_total_size(MAX_ADDR_LEN) /* NDA_DST */
2416 + nla_total_size(MAX_ADDR_LEN) /* NDA_LLADDR */
2417 + nla_total_size(sizeof(struct nda_cacheinfo))
2418 + nla_total_size(4); /* NDA_PROBES */
2419}
2420
2413static void __neigh_notify(struct neighbour *n, int type, int flags) 2421static void __neigh_notify(struct neighbour *n, int type, int flags)
2414{ 2422{
2415 struct sk_buff *skb; 2423 struct sk_buff *skb;
2416 int err = -ENOBUFS; 2424 int err = -ENOBUFS;
2417 2425
2418 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); 2426 skb = nlmsg_new(neigh_nlmsg_size(), GFP_ATOMIC);
2419 if (skb == NULL) 2427 if (skb == NULL)
2420 goto errout; 2428 goto errout;
2421 2429
2422 err = neigh_fill_info(skb, n, 0, 0, type, flags); 2430 err = neigh_fill_info(skb, n, 0, 0, type, flags);
2423 if (err < 0) { 2431 /* failure implies BUG in neigh_nlmsg_size() */
2424 kfree_skb(skb); 2432 BUG_ON(err < 0);
2425 goto errout;
2426 }
2427 2433
2428 err = rtnl_notify(skb, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC); 2434 err = rtnl_notify(skb, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
2429errout: 2435errout:
@@ -2618,14 +2624,14 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
2618 int p_id, int pdev_id, char *p_name, 2624 int p_id, int pdev_id, char *p_name,
2619 proc_handler *handler, ctl_handler *strategy) 2625 proc_handler *handler, ctl_handler *strategy)
2620{ 2626{
2621 struct neigh_sysctl_table *t = kmalloc(sizeof(*t), GFP_KERNEL); 2627 struct neigh_sysctl_table *t = kmemdup(&neigh_sysctl_template,
2628 sizeof(*t), GFP_KERNEL);
2622 const char *dev_name_source = NULL; 2629 const char *dev_name_source = NULL;
2623 char *dev_name = NULL; 2630 char *dev_name = NULL;
2624 int err = 0; 2631 int err = 0;
2625 2632
2626 if (!t) 2633 if (!t)
2627 return -ENOBUFS; 2634 return -ENOBUFS;
2628 memcpy(t, &neigh_sysctl_template, sizeof(*t));
2629 t->neigh_vars[0].data = &p->mcast_probes; 2635 t->neigh_vars[0].data = &p->mcast_probes;
2630 t->neigh_vars[1].data = &p->ucast_probes; 2636 t->neigh_vars[1].data = &p->ucast_probes;
2631 t->neigh_vars[2].data = &p->app_probes; 2637 t->neigh_vars[2].data = &p->app_probes;
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 63f24c914ddb..b3c559b9ac35 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -34,18 +34,12 @@
34#define MAX_UDP_CHUNK 1460 34#define MAX_UDP_CHUNK 1460
35#define MAX_SKBS 32 35#define MAX_SKBS 32
36#define MAX_QUEUE_DEPTH (MAX_SKBS / 2) 36#define MAX_QUEUE_DEPTH (MAX_SKBS / 2)
37#define MAX_RETRIES 20000
38 37
39static DEFINE_SPINLOCK(skb_list_lock); 38static struct sk_buff_head skb_pool;
40static int nr_skbs;
41static struct sk_buff *skbs;
42
43static DEFINE_SPINLOCK(queue_lock);
44static int queue_depth;
45static struct sk_buff *queue_head, *queue_tail;
46 39
47static atomic_t trapped; 40static atomic_t trapped;
48 41
42#define USEC_PER_POLL 50
49#define NETPOLL_RX_ENABLED 1 43#define NETPOLL_RX_ENABLED 1
50#define NETPOLL_RX_DROP 2 44#define NETPOLL_RX_DROP 2
51 45
@@ -58,52 +52,34 @@ static void arp_reply(struct sk_buff *skb);
58 52
59static void queue_process(struct work_struct *work) 53static void queue_process(struct work_struct *work)
60{ 54{
61 unsigned long flags; 55 struct netpoll_info *npinfo =
56 container_of(work, struct netpoll_info, tx_work.work);
62 struct sk_buff *skb; 57 struct sk_buff *skb;
63 58
64 while (queue_head) { 59 while ((skb = skb_dequeue(&npinfo->txq))) {
65 spin_lock_irqsave(&queue_lock, flags); 60 struct net_device *dev = skb->dev;
66
67 skb = queue_head;
68 queue_head = skb->next;
69 if (skb == queue_tail)
70 queue_head = NULL;
71
72 queue_depth--;
73
74 spin_unlock_irqrestore(&queue_lock, flags);
75
76 dev_queue_xmit(skb);
77 }
78}
79 61
80static DECLARE_WORK(send_queue, queue_process); 62 if (!netif_device_present(dev) || !netif_running(dev)) {
63 __kfree_skb(skb);
64 continue;
65 }
81 66
82void netpoll_queue(struct sk_buff *skb) 67 netif_tx_lock_bh(dev);
83{ 68 if (netif_queue_stopped(dev) ||
84 unsigned long flags; 69 dev->hard_start_xmit(skb, dev) != NETDEV_TX_OK) {
70 skb_queue_head(&npinfo->txq, skb);
71 netif_tx_unlock_bh(dev);
85 72
86 if (queue_depth == MAX_QUEUE_DEPTH) { 73 schedule_delayed_work(&npinfo->tx_work, HZ/10);
87 __kfree_skb(skb); 74 return;
88 return; 75 }
89 } 76 }
90
91 spin_lock_irqsave(&queue_lock, flags);
92 if (!queue_head)
93 queue_head = skb;
94 else
95 queue_tail->next = skb;
96 queue_tail = skb;
97 queue_depth++;
98 spin_unlock_irqrestore(&queue_lock, flags);
99
100 schedule_work(&send_queue);
101} 77}
102 78
103static int checksum_udp(struct sk_buff *skb, struct udphdr *uh, 79static __sum16 checksum_udp(struct sk_buff *skb, struct udphdr *uh,
104 unsigned short ulen, u32 saddr, u32 daddr) 80 unsigned short ulen, __be32 saddr, __be32 daddr)
105{ 81{
106 unsigned int psum; 82 __wsum psum;
107 83
108 if (uh->check == 0 || skb->ip_summed == CHECKSUM_UNNECESSARY) 84 if (uh->check == 0 || skb->ip_summed == CHECKSUM_UNNECESSARY)
109 return 0; 85 return 0;
@@ -111,7 +87,7 @@ static int checksum_udp(struct sk_buff *skb, struct udphdr *uh,
111 psum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0); 87 psum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0);
112 88
113 if (skb->ip_summed == CHECKSUM_COMPLETE && 89 if (skb->ip_summed == CHECKSUM_COMPLETE &&
114 !(u16)csum_fold(csum_add(psum, skb->csum))) 90 !csum_fold(csum_add(psum, skb->csum)))
115 return 0; 91 return 0;
116 92
117 skb->csum = psum; 93 skb->csum = psum;
@@ -167,12 +143,11 @@ static void service_arp_queue(struct netpoll_info *npi)
167 arp_reply(skb); 143 arp_reply(skb);
168 skb = skb_dequeue(&npi->arp_tx); 144 skb = skb_dequeue(&npi->arp_tx);
169 } 145 }
170 return;
171} 146}
172 147
173void netpoll_poll(struct netpoll *np) 148void netpoll_poll(struct netpoll *np)
174{ 149{
175 if(!np->dev || !netif_running(np->dev) || !np->dev->poll_controller) 150 if (!np->dev || !netif_running(np->dev) || !np->dev->poll_controller)
176 return; 151 return;
177 152
178 /* Process pending work on NIC */ 153 /* Process pending work on NIC */
@@ -190,17 +165,15 @@ static void refill_skbs(void)
190 struct sk_buff *skb; 165 struct sk_buff *skb;
191 unsigned long flags; 166 unsigned long flags;
192 167
193 spin_lock_irqsave(&skb_list_lock, flags); 168 spin_lock_irqsave(&skb_pool.lock, flags);
194 while (nr_skbs < MAX_SKBS) { 169 while (skb_pool.qlen < MAX_SKBS) {
195 skb = alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC); 170 skb = alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC);
196 if (!skb) 171 if (!skb)
197 break; 172 break;
198 173
199 skb->next = skbs; 174 __skb_queue_tail(&skb_pool, skb);
200 skbs = skb;
201 nr_skbs++;
202 } 175 }
203 spin_unlock_irqrestore(&skb_list_lock, flags); 176 spin_unlock_irqrestore(&skb_pool.lock, flags);
204} 177}
205 178
206static void zap_completion_queue(void) 179static void zap_completion_queue(void)
@@ -219,7 +192,7 @@ static void zap_completion_queue(void)
219 while (clist != NULL) { 192 while (clist != NULL) {
220 struct sk_buff *skb = clist; 193 struct sk_buff *skb = clist;
221 clist = clist->next; 194 clist = clist->next;
222 if(skb->destructor) 195 if (skb->destructor)
223 dev_kfree_skb_any(skb); /* put this one back */ 196 dev_kfree_skb_any(skb); /* put this one back */
224 else 197 else
225 __kfree_skb(skb); 198 __kfree_skb(skb);
@@ -229,38 +202,25 @@ static void zap_completion_queue(void)
229 put_cpu_var(softnet_data); 202 put_cpu_var(softnet_data);
230} 203}
231 204
232static struct sk_buff * find_skb(struct netpoll *np, int len, int reserve) 205static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
233{ 206{
234 int once = 1, count = 0; 207 int count = 0;
235 unsigned long flags; 208 struct sk_buff *skb;
236 struct sk_buff *skb = NULL;
237 209
238 zap_completion_queue(); 210 zap_completion_queue();
211 refill_skbs();
239repeat: 212repeat:
240 if (nr_skbs < MAX_SKBS)
241 refill_skbs();
242 213
243 skb = alloc_skb(len, GFP_ATOMIC); 214 skb = alloc_skb(len, GFP_ATOMIC);
215 if (!skb)
216 skb = skb_dequeue(&skb_pool);
244 217
245 if (!skb) { 218 if (!skb) {
246 spin_lock_irqsave(&skb_list_lock, flags); 219 if (++count < 10) {
247 skb = skbs; 220 netpoll_poll(np);
248 if (skb) { 221 goto repeat;
249 skbs = skb->next;
250 skb->next = NULL;
251 nr_skbs--;
252 } 222 }
253 spin_unlock_irqrestore(&skb_list_lock, flags); 223 return NULL;
254 }
255
256 if(!skb) {
257 count++;
258 if (once && (count == 1000000)) {
259 printk("out of netpoll skbs!\n");
260 once = 0;
261 }
262 netpoll_poll(np);
263 goto repeat;
264 } 224 }
265 225
266 atomic_set(&skb->users, 1); 226 atomic_set(&skb->users, 1);
@@ -270,50 +230,40 @@ repeat:
270 230
271static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) 231static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
272{ 232{
273 int status; 233 int status = NETDEV_TX_BUSY;
274 struct netpoll_info *npinfo; 234 unsigned long tries;
275 235 struct net_device *dev = np->dev;
276 if (!np || !np->dev || !netif_running(np->dev)) { 236 struct netpoll_info *npinfo = np->dev->npinfo;
277 __kfree_skb(skb); 237
278 return; 238 if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) {
279 } 239 __kfree_skb(skb);
280 240 return;
281 npinfo = np->dev->npinfo; 241 }
282 242
283 /* avoid recursion */ 243 /* don't get messages out of order, and no recursion */
284 if (npinfo->poll_owner == smp_processor_id() || 244 if (skb_queue_len(&npinfo->txq) == 0 &&
285 np->dev->xmit_lock_owner == smp_processor_id()) { 245 npinfo->poll_owner != smp_processor_id() &&
286 if (np->drop) 246 netif_tx_trylock(dev)) {
287 np->drop(skb); 247 /* try until next clock tick */
288 else 248 for (tries = jiffies_to_usecs(1)/USEC_PER_POLL; tries > 0; --tries) {
289 __kfree_skb(skb); 249 if (!netif_queue_stopped(dev))
290 return; 250 status = dev->hard_start_xmit(skb, dev);
291 }
292
293 do {
294 npinfo->tries--;
295 netif_tx_lock(np->dev);
296 251
297 /* 252 if (status == NETDEV_TX_OK)
298 * network drivers do not expect to be called if the queue is 253 break;
299 * stopped.
300 */
301 status = NETDEV_TX_BUSY;
302 if (!netif_queue_stopped(np->dev))
303 status = np->dev->hard_start_xmit(skb, np->dev);
304 254
305 netif_tx_unlock(np->dev); 255 /* tickle device maybe there is some cleanup */
256 netpoll_poll(np);
306 257
307 /* success */ 258 udelay(USEC_PER_POLL);
308 if(!status) {
309 npinfo->tries = MAX_RETRIES; /* reset */
310 return;
311 } 259 }
260 netif_tx_unlock(dev);
261 }
312 262
313 /* transmit busy */ 263 if (status != NETDEV_TX_OK) {
314 netpoll_poll(np); 264 skb_queue_tail(&npinfo->txq, skb);
315 udelay(50); 265 schedule_delayed_work(&npinfo->tx_work,0);
316 } while (npinfo->tries > 0); 266 }
317} 267}
318 268
319void netpoll_send_udp(struct netpoll *np, const char *msg, int len) 269void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
@@ -345,7 +295,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
345 udp_len, IPPROTO_UDP, 295 udp_len, IPPROTO_UDP,
346 csum_partial((unsigned char *)udph, udp_len, 0)); 296 csum_partial((unsigned char *)udph, udp_len, 0));
347 if (udph->check == 0) 297 if (udph->check == 0)
348 udph->check = -1; 298 udph->check = CSUM_MANGLED_0;
349 299
350 skb->nh.iph = iph = (struct iphdr *)skb_push(skb, sizeof(*iph)); 300 skb->nh.iph = iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
351 301
@@ -379,7 +329,7 @@ static void arp_reply(struct sk_buff *skb)
379 struct arphdr *arp; 329 struct arphdr *arp;
380 unsigned char *arp_ptr; 330 unsigned char *arp_ptr;
381 int size, type = ARPOP_REPLY, ptype = ETH_P_ARP; 331 int size, type = ARPOP_REPLY, ptype = ETH_P_ARP;
382 u32 sip, tip; 332 __be32 sip, tip;
383 struct sk_buff *send_skb; 333 struct sk_buff *send_skb;
384 struct netpoll *np = NULL; 334 struct netpoll *np = NULL;
385 335
@@ -431,8 +381,8 @@ static void arp_reply(struct sk_buff *skb)
431 381
432 if (np->dev->hard_header && 382 if (np->dev->hard_header &&
433 np->dev->hard_header(send_skb, skb->dev, ptype, 383 np->dev->hard_header(send_skb, skb->dev, ptype,
434 np->remote_mac, np->local_mac, 384 np->remote_mac, np->local_mac,
435 send_skb->len) < 0) { 385 send_skb->len) < 0) {
436 kfree_skb(send_skb); 386 kfree_skb(send_skb);
437 return; 387 return;
438 } 388 }
@@ -470,7 +420,6 @@ int __netpoll_rx(struct sk_buff *skb)
470 struct netpoll_info *npi = skb->dev->npinfo; 420 struct netpoll_info *npi = skb->dev->npinfo;
471 struct netpoll *np = npi->rx_np; 421 struct netpoll *np = npi->rx_np;
472 422
473
474 if (!np) 423 if (!np)
475 goto out; 424 goto out;
476 if (skb->dev->type != ARPHRD_ETHER) 425 if (skb->dev->type != ARPHRD_ETHER)
@@ -543,47 +492,47 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
543{ 492{
544 char *cur=opt, *delim; 493 char *cur=opt, *delim;
545 494
546 if(*cur != '@') { 495 if (*cur != '@') {
547 if ((delim = strchr(cur, '@')) == NULL) 496 if ((delim = strchr(cur, '@')) == NULL)
548 goto parse_failed; 497 goto parse_failed;
549 *delim=0; 498 *delim = 0;
550 np->local_port=simple_strtol(cur, NULL, 10); 499 np->local_port = simple_strtol(cur, NULL, 10);
551 cur=delim; 500 cur = delim;
552 } 501 }
553 cur++; 502 cur++;
554 printk(KERN_INFO "%s: local port %d\n", np->name, np->local_port); 503 printk(KERN_INFO "%s: local port %d\n", np->name, np->local_port);
555 504
556 if(*cur != '/') { 505 if (*cur != '/') {
557 if ((delim = strchr(cur, '/')) == NULL) 506 if ((delim = strchr(cur, '/')) == NULL)
558 goto parse_failed; 507 goto parse_failed;
559 *delim=0; 508 *delim = 0;
560 np->local_ip=ntohl(in_aton(cur)); 509 np->local_ip = ntohl(in_aton(cur));
561 cur=delim; 510 cur = delim;
562 511
563 printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n", 512 printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n",
564 np->name, HIPQUAD(np->local_ip)); 513 np->name, HIPQUAD(np->local_ip));
565 } 514 }
566 cur++; 515 cur++;
567 516
568 if ( *cur != ',') { 517 if (*cur != ',') {
569 /* parse out dev name */ 518 /* parse out dev name */
570 if ((delim = strchr(cur, ',')) == NULL) 519 if ((delim = strchr(cur, ',')) == NULL)
571 goto parse_failed; 520 goto parse_failed;
572 *delim=0; 521 *delim = 0;
573 strlcpy(np->dev_name, cur, sizeof(np->dev_name)); 522 strlcpy(np->dev_name, cur, sizeof(np->dev_name));
574 cur=delim; 523 cur = delim;
575 } 524 }
576 cur++; 525 cur++;
577 526
578 printk(KERN_INFO "%s: interface %s\n", np->name, np->dev_name); 527 printk(KERN_INFO "%s: interface %s\n", np->name, np->dev_name);
579 528
580 if ( *cur != '@' ) { 529 if (*cur != '@') {
581 /* dst port */ 530 /* dst port */
582 if ((delim = strchr(cur, '@')) == NULL) 531 if ((delim = strchr(cur, '@')) == NULL)
583 goto parse_failed; 532 goto parse_failed;
584 *delim=0; 533 *delim = 0;
585 np->remote_port=simple_strtol(cur, NULL, 10); 534 np->remote_port = simple_strtol(cur, NULL, 10);
586 cur=delim; 535 cur = delim;
587 } 536 }
588 cur++; 537 cur++;
589 printk(KERN_INFO "%s: remote port %d\n", np->name, np->remote_port); 538 printk(KERN_INFO "%s: remote port %d\n", np->name, np->remote_port);
@@ -591,42 +540,41 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
591 /* dst ip */ 540 /* dst ip */
592 if ((delim = strchr(cur, '/')) == NULL) 541 if ((delim = strchr(cur, '/')) == NULL)
593 goto parse_failed; 542 goto parse_failed;
594 *delim=0; 543 *delim = 0;
595 np->remote_ip=ntohl(in_aton(cur)); 544 np->remote_ip = ntohl(in_aton(cur));
596 cur=delim+1; 545 cur = delim + 1;
597 546
598 printk(KERN_INFO "%s: remote IP %d.%d.%d.%d\n", 547 printk(KERN_INFO "%s: remote IP %d.%d.%d.%d\n",
599 np->name, HIPQUAD(np->remote_ip)); 548 np->name, HIPQUAD(np->remote_ip));
600 549
601 if( *cur != 0 ) 550 if (*cur != 0) {
602 {
603 /* MAC address */ 551 /* MAC address */
604 if ((delim = strchr(cur, ':')) == NULL) 552 if ((delim = strchr(cur, ':')) == NULL)
605 goto parse_failed; 553 goto parse_failed;
606 *delim=0; 554 *delim = 0;
607 np->remote_mac[0]=simple_strtol(cur, NULL, 16); 555 np->remote_mac[0] = simple_strtol(cur, NULL, 16);
608 cur=delim+1; 556 cur = delim + 1;
609 if ((delim = strchr(cur, ':')) == NULL) 557 if ((delim = strchr(cur, ':')) == NULL)
610 goto parse_failed; 558 goto parse_failed;
611 *delim=0; 559 *delim = 0;
612 np->remote_mac[1]=simple_strtol(cur, NULL, 16); 560 np->remote_mac[1] = simple_strtol(cur, NULL, 16);
613 cur=delim+1; 561 cur = delim + 1;
614 if ((delim = strchr(cur, ':')) == NULL) 562 if ((delim = strchr(cur, ':')) == NULL)
615 goto parse_failed; 563 goto parse_failed;
616 *delim=0; 564 *delim = 0;
617 np->remote_mac[2]=simple_strtol(cur, NULL, 16); 565 np->remote_mac[2] = simple_strtol(cur, NULL, 16);
618 cur=delim+1; 566 cur = delim + 1;
619 if ((delim = strchr(cur, ':')) == NULL) 567 if ((delim = strchr(cur, ':')) == NULL)
620 goto parse_failed; 568 goto parse_failed;
621 *delim=0; 569 *delim = 0;
622 np->remote_mac[3]=simple_strtol(cur, NULL, 16); 570 np->remote_mac[3] = simple_strtol(cur, NULL, 16);
623 cur=delim+1; 571 cur = delim + 1;
624 if ((delim = strchr(cur, ':')) == NULL) 572 if ((delim = strchr(cur, ':')) == NULL)
625 goto parse_failed; 573 goto parse_failed;
626 *delim=0; 574 *delim = 0;
627 np->remote_mac[4]=simple_strtol(cur, NULL, 16); 575 np->remote_mac[4] = simple_strtol(cur, NULL, 16);
628 cur=delim+1; 576 cur = delim + 1;
629 np->remote_mac[5]=simple_strtol(cur, NULL, 16); 577 np->remote_mac[5] = simple_strtol(cur, NULL, 16);
630 } 578 }
631 579
632 printk(KERN_INFO "%s: remote ethernet address " 580 printk(KERN_INFO "%s: remote ethernet address "
@@ -653,34 +601,44 @@ int netpoll_setup(struct netpoll *np)
653 struct in_device *in_dev; 601 struct in_device *in_dev;
654 struct netpoll_info *npinfo; 602 struct netpoll_info *npinfo;
655 unsigned long flags; 603 unsigned long flags;
604 int err;
656 605
657 if (np->dev_name) 606 if (np->dev_name)
658 ndev = dev_get_by_name(np->dev_name); 607 ndev = dev_get_by_name(np->dev_name);
659 if (!ndev) { 608 if (!ndev) {
660 printk(KERN_ERR "%s: %s doesn't exist, aborting.\n", 609 printk(KERN_ERR "%s: %s doesn't exist, aborting.\n",
661 np->name, np->dev_name); 610 np->name, np->dev_name);
662 return -1; 611 return -ENODEV;
663 } 612 }
664 613
665 np->dev = ndev; 614 np->dev = ndev;
666 if (!ndev->npinfo) { 615 if (!ndev->npinfo) {
667 npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL); 616 npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
668 if (!npinfo) 617 if (!npinfo) {
618 err = -ENOMEM;
669 goto release; 619 goto release;
620 }
670 621
671 npinfo->rx_flags = 0; 622 npinfo->rx_flags = 0;
672 npinfo->rx_np = NULL; 623 npinfo->rx_np = NULL;
673 spin_lock_init(&npinfo->poll_lock); 624 spin_lock_init(&npinfo->poll_lock);
674 npinfo->poll_owner = -1; 625 npinfo->poll_owner = -1;
675 npinfo->tries = MAX_RETRIES; 626
676 spin_lock_init(&npinfo->rx_lock); 627 spin_lock_init(&npinfo->rx_lock);
677 skb_queue_head_init(&npinfo->arp_tx); 628 skb_queue_head_init(&npinfo->arp_tx);
678 } else 629 skb_queue_head_init(&npinfo->txq);
630 INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
631
632 atomic_set(&npinfo->refcnt, 1);
633 } else {
679 npinfo = ndev->npinfo; 634 npinfo = ndev->npinfo;
635 atomic_inc(&npinfo->refcnt);
636 }
680 637
681 if (!ndev->poll_controller) { 638 if (!ndev->poll_controller) {
682 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n", 639 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
683 np->name, np->dev_name); 640 np->name, np->dev_name);
641 err = -ENOTSUPP;
684 goto release; 642 goto release;
685 } 643 }
686 644
@@ -691,13 +649,14 @@ int netpoll_setup(struct netpoll *np)
691 np->name, np->dev_name); 649 np->name, np->dev_name);
692 650
693 rtnl_lock(); 651 rtnl_lock();
694 if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) { 652 err = dev_open(ndev);
653 rtnl_unlock();
654
655 if (err) {
695 printk(KERN_ERR "%s: failed to open %s\n", 656 printk(KERN_ERR "%s: failed to open %s\n",
696 np->name, np->dev_name); 657 np->name, ndev->name);
697 rtnl_unlock();
698 goto release; 658 goto release;
699 } 659 }
700 rtnl_unlock();
701 660
702 atleast = jiffies + HZ/10; 661 atleast = jiffies + HZ/10;
703 atmost = jiffies + 4*HZ; 662 atmost = jiffies + 4*HZ;
@@ -735,6 +694,7 @@ int netpoll_setup(struct netpoll *np)
735 rcu_read_unlock(); 694 rcu_read_unlock();
736 printk(KERN_ERR "%s: no IP address for %s, aborting\n", 695 printk(KERN_ERR "%s: no IP address for %s, aborting\n",
737 np->name, np->dev_name); 696 np->name, np->dev_name);
697 err = -EDESTADDRREQ;
738 goto release; 698 goto release;
739 } 699 }
740 700
@@ -767,9 +727,16 @@ int netpoll_setup(struct netpoll *np)
767 kfree(npinfo); 727 kfree(npinfo);
768 np->dev = NULL; 728 np->dev = NULL;
769 dev_put(ndev); 729 dev_put(ndev);
770 return -1; 730 return err;
771} 731}
772 732
733static int __init netpoll_init(void)
734{
735 skb_queue_head_init(&skb_pool);
736 return 0;
737}
738core_initcall(netpoll_init);
739
773void netpoll_cleanup(struct netpoll *np) 740void netpoll_cleanup(struct netpoll *np)
774{ 741{
775 struct netpoll_info *npinfo; 742 struct netpoll_info *npinfo;
@@ -777,12 +744,25 @@ void netpoll_cleanup(struct netpoll *np)
777 744
778 if (np->dev) { 745 if (np->dev) {
779 npinfo = np->dev->npinfo; 746 npinfo = np->dev->npinfo;
780 if (npinfo && npinfo->rx_np == np) { 747 if (npinfo) {
781 spin_lock_irqsave(&npinfo->rx_lock, flags); 748 if (npinfo->rx_np == np) {
782 npinfo->rx_np = NULL; 749 spin_lock_irqsave(&npinfo->rx_lock, flags);
783 npinfo->rx_flags &= ~NETPOLL_RX_ENABLED; 750 npinfo->rx_np = NULL;
784 spin_unlock_irqrestore(&npinfo->rx_lock, flags); 751 npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
752 spin_unlock_irqrestore(&npinfo->rx_lock, flags);
753 }
754
755 np->dev->npinfo = NULL;
756 if (atomic_dec_and_test(&npinfo->refcnt)) {
757 skb_queue_purge(&npinfo->arp_tx);
758 skb_queue_purge(&npinfo->txq);
759 cancel_rearming_delayed_work(&npinfo->tx_work);
760 flush_scheduled_work();
761
762 kfree(npinfo);
763 }
785 } 764 }
765
786 dev_put(np->dev); 766 dev_put(np->dev);
787 } 767 }
788 768
@@ -809,4 +789,3 @@ EXPORT_SYMBOL(netpoll_setup);
809EXPORT_SYMBOL(netpoll_cleanup); 789EXPORT_SYMBOL(netpoll_cleanup);
810EXPORT_SYMBOL(netpoll_send_udp); 790EXPORT_SYMBOL(netpoll_send_udp);
811EXPORT_SYMBOL(netpoll_poll); 791EXPORT_SYMBOL(netpoll_poll);
812EXPORT_SYMBOL(netpoll_queue);
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 733d86d0a4fb..1897a3a385d8 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -207,7 +207,7 @@ static struct proc_dir_entry *pg_proc_dir = NULL;
207#define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4) 207#define SVLAN_TAG_SIZE(x) ((x)->svlan_id == 0xffff ? 0 : 4)
208 208
209struct flow_state { 209struct flow_state {
210 __u32 cur_daddr; 210 __be32 cur_daddr;
211 int count; 211 int count;
212}; 212};
213 213
@@ -282,10 +282,10 @@ struct pktgen_dev {
282 /* If we're doing ranges, random or incremental, then this 282 /* If we're doing ranges, random or incremental, then this
283 * defines the min/max for those ranges. 283 * defines the min/max for those ranges.
284 */ 284 */
285 __u32 saddr_min; /* inclusive, source IP address */ 285 __be32 saddr_min; /* inclusive, source IP address */
286 __u32 saddr_max; /* exclusive, source IP address */ 286 __be32 saddr_max; /* exclusive, source IP address */
287 __u32 daddr_min; /* inclusive, dest IP address */ 287 __be32 daddr_min; /* inclusive, dest IP address */
288 __u32 daddr_max; /* exclusive, dest IP address */ 288 __be32 daddr_max; /* exclusive, dest IP address */
289 289
290 __u16 udp_src_min; /* inclusive, source UDP port */ 290 __u16 udp_src_min; /* inclusive, source UDP port */
291 __u16 udp_src_max; /* exclusive, source UDP port */ 291 __u16 udp_src_max; /* exclusive, source UDP port */
@@ -317,8 +317,8 @@ struct pktgen_dev {
317 317
318 __u32 cur_dst_mac_offset; 318 __u32 cur_dst_mac_offset;
319 __u32 cur_src_mac_offset; 319 __u32 cur_src_mac_offset;
320 __u32 cur_saddr; 320 __be32 cur_saddr;
321 __u32 cur_daddr; 321 __be32 cur_daddr;
322 __u16 cur_udp_dst; 322 __u16 cur_udp_dst;
323 __u16 cur_udp_src; 323 __u16 cur_udp_src;
324 __u32 cur_pkt_size; 324 __u32 cur_pkt_size;
@@ -350,10 +350,10 @@ struct pktgen_dev {
350}; 350};
351 351
352struct pktgen_hdr { 352struct pktgen_hdr {
353 __u32 pgh_magic; 353 __be32 pgh_magic;
354 __u32 seq_num; 354 __be32 seq_num;
355 __u32 tv_sec; 355 __be32 tv_sec;
356 __u32 tv_usec; 356 __be32 tv_usec;
357}; 357};
358 358
359struct pktgen_thread { 359struct pktgen_thread {
@@ -2160,7 +2160,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
2160 for(i = 0; i < pkt_dev->nr_labels; i++) 2160 for(i = 0; i < pkt_dev->nr_labels; i++)
2161 if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) 2161 if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
2162 pkt_dev->labels[i] = MPLS_STACK_BOTTOM | 2162 pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
2163 (pktgen_random() & 2163 ((__force __be32)pktgen_random() &
2164 htonl(0x000fffff)); 2164 htonl(0x000fffff));
2165 } 2165 }
2166 2166
@@ -2220,29 +2220,25 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
2220 if (pkt_dev->cflows && pkt_dev->flows[flow].count != 0) { 2220 if (pkt_dev->cflows && pkt_dev->flows[flow].count != 0) {
2221 pkt_dev->cur_daddr = pkt_dev->flows[flow].cur_daddr; 2221 pkt_dev->cur_daddr = pkt_dev->flows[flow].cur_daddr;
2222 } else { 2222 } else {
2223 2223 imn = ntohl(pkt_dev->daddr_min);
2224 if ((imn = ntohl(pkt_dev->daddr_min)) < (imx = 2224 imx = ntohl(pkt_dev->daddr_max);
2225 ntohl(pkt_dev-> 2225 if (imn < imx) {
2226 daddr_max)))
2227 {
2228 __u32 t; 2226 __u32 t;
2227 __be32 s;
2229 if (pkt_dev->flags & F_IPDST_RND) { 2228 if (pkt_dev->flags & F_IPDST_RND) {
2230 2229
2231 t = ((pktgen_random() % (imx - imn)) + 2230 t = pktgen_random() % (imx - imn) + imn;
2232 imn); 2231 s = htonl(t);
2233 t = htonl(t);
2234 2232
2235 while (LOOPBACK(t) || MULTICAST(t) 2233 while (LOOPBACK(s) || MULTICAST(s)
2236 || BADCLASS(t) || ZERONET(t) 2234 || BADCLASS(s) || ZERONET(s)
2237 || LOCAL_MCAST(t)) { 2235 || LOCAL_MCAST(s)) {
2238 t = ((pktgen_random() % 2236 t = (pktgen_random() %
2239 (imx - imn)) + imn); 2237 (imx - imn)) + imn;
2240 t = htonl(t); 2238 s = htonl(t);
2241 } 2239 }
2242 pkt_dev->cur_daddr = t; 2240 pkt_dev->cur_daddr = s;
2243 } 2241 } else {
2244
2245 else {
2246 t = ntohl(pkt_dev->cur_daddr); 2242 t = ntohl(pkt_dev->cur_daddr);
2247 t++; 2243 t++;
2248 if (t > imx) { 2244 if (t > imx) {
@@ -2270,7 +2266,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
2270 2266
2271 for (i = 0; i < 4; i++) { 2267 for (i = 0; i < 4; i++) {
2272 pkt_dev->cur_in6_daddr.s6_addr32[i] = 2268 pkt_dev->cur_in6_daddr.s6_addr32[i] =
2273 ((pktgen_random() | 2269 (((__force __be32)pktgen_random() |
2274 pkt_dev->min_in6_daddr.s6_addr32[i]) & 2270 pkt_dev->min_in6_daddr.s6_addr32[i]) &
2275 pkt_dev->max_in6_daddr.s6_addr32[i]); 2271 pkt_dev->max_in6_daddr.s6_addr32[i]);
2276 } 2272 }
@@ -2377,7 +2373,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
2377 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); 2373 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
2378 2374
2379 memcpy(eth, pkt_dev->hh, 12); 2375 memcpy(eth, pkt_dev->hh, 12);
2380 *(u16 *) & eth[12] = protocol; 2376 *(__be16 *) & eth[12] = protocol;
2381 2377
2382 /* Eth + IPh + UDPh + mpls */ 2378 /* Eth + IPh + UDPh + mpls */
2383 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 - 2379 datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 -
@@ -2497,7 +2493,7 @@ static unsigned int scan_ip6(const char *s, char ip[16])
2497 char suffix[16]; 2493 char suffix[16];
2498 unsigned int prefixlen = 0; 2494 unsigned int prefixlen = 0;
2499 unsigned int suffixlen = 0; 2495 unsigned int suffixlen = 0;
2500 __u32 tmp; 2496 __be32 tmp;
2501 2497
2502 for (i = 0; i < 16; i++) 2498 for (i = 0; i < 16; i++)
2503 ip[i] = 0; 2499 ip[i] = 0;
@@ -2713,7 +2709,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2713 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); 2709 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
2714 2710
2715 memcpy(eth, pkt_dev->hh, 12); 2711 memcpy(eth, pkt_dev->hh, 12);
2716 *(u16 *) & eth[12] = protocol; 2712 *(__be16 *) & eth[12] = protocol;
2717 2713
2718 /* Eth + IPh + UDPh + mpls */ 2714 /* Eth + IPh + UDPh + mpls */
2719 datalen = pkt_dev->cur_pkt_size - 14 - 2715 datalen = pkt_dev->cur_pkt_size - 14 -
@@ -2732,11 +2728,11 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
2732 udph->len = htons(datalen + sizeof(struct udphdr)); 2728 udph->len = htons(datalen + sizeof(struct udphdr));
2733 udph->check = 0; /* No checksum */ 2729 udph->check = 0; /* No checksum */
2734 2730
2735 *(u32 *) iph = __constant_htonl(0x60000000); /* Version + flow */ 2731 *(__be32 *) iph = __constant_htonl(0x60000000); /* Version + flow */
2736 2732
2737 if (pkt_dev->traffic_class) { 2733 if (pkt_dev->traffic_class) {
2738 /* Version + traffic class + flow (0) */ 2734 /* Version + traffic class + flow (0) */
2739 *(u32 *)iph |= htonl(0x60000000 | (pkt_dev->traffic_class << 20)); 2735 *(__be32 *)iph |= htonl(0x60000000 | (pkt_dev->traffic_class << 20));
2740 } 2736 }
2741 2737
2742 iph->hop_limit = 32; 2738 iph->hop_limit = 32;
diff --git a/net/core/request_sock.c b/net/core/request_sock.c
index 79ebd75fbe4d..5f0818d815e6 100644
--- a/net/core/request_sock.c
+++ b/net/core/request_sock.c
@@ -15,6 +15,7 @@
15#include <linux/random.h> 15#include <linux/random.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/string.h> 17#include <linux/string.h>
18#include <linux/vmalloc.h>
18 19
19#include <net/request_sock.h> 20#include <net/request_sock.h>
20 21
@@ -29,22 +30,31 @@
29 * it is absolutely not enough even at 100conn/sec. 256 cures most 30 * it is absolutely not enough even at 100conn/sec. 256 cures most
30 * of problems. This value is adjusted to 128 for very small machines 31 * of problems. This value is adjusted to 128 for very small machines
31 * (<=32Mb of memory) and to 1024 on normal or better ones (>=256Mb). 32 * (<=32Mb of memory) and to 1024 on normal or better ones (>=256Mb).
32 * Further increasing requires to change hash table size. 33 * Note : Dont forget somaxconn that may limit backlog too.
33 */ 34 */
34int sysctl_max_syn_backlog = 256; 35int sysctl_max_syn_backlog = 256;
35 36
36int reqsk_queue_alloc(struct request_sock_queue *queue, 37int reqsk_queue_alloc(struct request_sock_queue *queue,
37 const int nr_table_entries) 38 unsigned int nr_table_entries)
38{ 39{
39 const int lopt_size = sizeof(struct listen_sock) + 40 size_t lopt_size = sizeof(struct listen_sock);
40 nr_table_entries * sizeof(struct request_sock *); 41 struct listen_sock *lopt;
41 struct listen_sock *lopt = kzalloc(lopt_size, GFP_KERNEL); 42
42 43 nr_table_entries = min_t(u32, nr_table_entries, sysctl_max_syn_backlog);
44 nr_table_entries = max_t(u32, nr_table_entries, 8);
45 nr_table_entries = roundup_pow_of_two(nr_table_entries + 1);
46 lopt_size += nr_table_entries * sizeof(struct request_sock *);
47 if (lopt_size > PAGE_SIZE)
48 lopt = __vmalloc(lopt_size,
49 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
50 PAGE_KERNEL);
51 else
52 lopt = kzalloc(lopt_size, GFP_KERNEL);
43 if (lopt == NULL) 53 if (lopt == NULL)
44 return -ENOMEM; 54 return -ENOMEM;
45 55
46 for (lopt->max_qlen_log = 6; 56 for (lopt->max_qlen_log = 3;
47 (1 << lopt->max_qlen_log) < sysctl_max_syn_backlog; 57 (1 << lopt->max_qlen_log) < nr_table_entries;
48 lopt->max_qlen_log++); 58 lopt->max_qlen_log++);
49 59
50 get_random_bytes(&lopt->hash_rnd, sizeof(lopt->hash_rnd)); 60 get_random_bytes(&lopt->hash_rnd, sizeof(lopt->hash_rnd));
@@ -65,9 +75,11 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
65{ 75{
66 /* make all the listen_opt local to us */ 76 /* make all the listen_opt local to us */
67 struct listen_sock *lopt = reqsk_queue_yank_listen_sk(queue); 77 struct listen_sock *lopt = reqsk_queue_yank_listen_sk(queue);
78 size_t lopt_size = sizeof(struct listen_sock) +
79 lopt->nr_table_entries * sizeof(struct request_sock *);
68 80
69 if (lopt->qlen != 0) { 81 if (lopt->qlen != 0) {
70 int i; 82 unsigned int i;
71 83
72 for (i = 0; i < lopt->nr_table_entries; i++) { 84 for (i = 0; i < lopt->nr_table_entries; i++) {
73 struct request_sock *req; 85 struct request_sock *req;
@@ -81,7 +93,10 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
81 } 93 }
82 94
83 BUG_TRAP(lopt->qlen == 0); 95 BUG_TRAP(lopt->qlen == 0);
84 kfree(lopt); 96 if (lopt_size > PAGE_SIZE)
97 vfree(lopt);
98 else
99 kfree(lopt);
85} 100}
86 101
87EXPORT_SYMBOL(reqsk_queue_destroy); 102EXPORT_SYMBOL(reqsk_queue_destroy);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 02f3c7947898..e76539a5eb5e 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -108,7 +108,6 @@ static const int rtm_min[RTM_NR_FAMILIES] =
108 [RTM_FAM(RTM_NEWTCLASS)] = NLMSG_LENGTH(sizeof(struct tcmsg)), 108 [RTM_FAM(RTM_NEWTCLASS)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
109 [RTM_FAM(RTM_NEWTFILTER)] = NLMSG_LENGTH(sizeof(struct tcmsg)), 109 [RTM_FAM(RTM_NEWTFILTER)] = NLMSG_LENGTH(sizeof(struct tcmsg)),
110 [RTM_FAM(RTM_NEWACTION)] = NLMSG_LENGTH(sizeof(struct tcamsg)), 110 [RTM_FAM(RTM_NEWACTION)] = NLMSG_LENGTH(sizeof(struct tcamsg)),
111 [RTM_FAM(RTM_NEWPREFIX)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
112 [RTM_FAM(RTM_GETMULTICAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)), 111 [RTM_FAM(RTM_GETMULTICAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
113 [RTM_FAM(RTM_GETANYCAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)), 112 [RTM_FAM(RTM_GETANYCAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
114}; 113};
@@ -213,6 +212,26 @@ nla_put_failure:
213 return nla_nest_cancel(skb, mx); 212 return nla_nest_cancel(skb, mx);
214} 213}
215 214
215int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id,
216 u32 ts, u32 tsage, long expires, u32 error)
217{
218 struct rta_cacheinfo ci = {
219 .rta_lastuse = jiffies_to_clock_t(jiffies - dst->lastuse),
220 .rta_used = dst->__use,
221 .rta_clntref = atomic_read(&(dst->__refcnt)),
222 .rta_error = error,
223 .rta_id = id,
224 .rta_ts = ts,
225 .rta_tsage = tsage,
226 };
227
228 if (expires)
229 ci.rta_expires = jiffies_to_clock_t(expires);
230
231 return nla_put(skb, RTA_CACHEINFO, sizeof(ci), &ci);
232}
233
234EXPORT_SYMBOL_GPL(rtnl_put_cacheinfo);
216 235
217static void set_operstate(struct net_device *dev, unsigned char transition) 236static void set_operstate(struct net_device *dev, unsigned char transition)
218{ 237{
@@ -273,6 +292,25 @@ static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
273 a->tx_compressed = b->tx_compressed; 292 a->tx_compressed = b->tx_compressed;
274}; 293};
275 294
295static inline size_t if_nlmsg_size(int iwbuflen)
296{
297 return NLMSG_ALIGN(sizeof(struct ifinfomsg))
298 + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */
299 + nla_total_size(IFNAMSIZ) /* IFLA_QDISC */
300 + nla_total_size(sizeof(struct rtnl_link_ifmap))
301 + nla_total_size(sizeof(struct rtnl_link_stats))
302 + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */
303 + nla_total_size(MAX_ADDR_LEN) /* IFLA_BROADCAST */
304 + nla_total_size(4) /* IFLA_TXQLEN */
305 + nla_total_size(4) /* IFLA_WEIGHT */
306 + nla_total_size(4) /* IFLA_MTU */
307 + nla_total_size(4) /* IFLA_LINK */
308 + nla_total_size(4) /* IFLA_MASTER */
309 + nla_total_size(1) /* IFLA_OPERSTATE */
310 + nla_total_size(1) /* IFLA_LINKMODE */
311 + nla_total_size(iwbuflen);
312}
313
276static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, 314static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
277 void *iwbuf, int iwbuflen, int type, u32 pid, 315 void *iwbuf, int iwbuflen, int type, u32 pid,
278 u32 seq, u32 change, unsigned int flags) 316 u32 seq, u32 change, unsigned int flags)
@@ -558,7 +596,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
558 struct sk_buff *nskb; 596 struct sk_buff *nskb;
559 char *iw_buf = NULL, *iw = NULL; 597 char *iw_buf = NULL, *iw = NULL;
560 int iw_buf_len = 0; 598 int iw_buf_len = 0;
561 int err, payload; 599 int err;
562 600
563 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); 601 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
564 if (err < 0) 602 if (err < 0)
@@ -587,9 +625,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
587 } 625 }
588#endif /* CONFIG_NET_WIRELESS_RTNETLINK */ 626#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
589 627
590 payload = NLMSG_ALIGN(sizeof(struct ifinfomsg) + 628 nskb = nlmsg_new(if_nlmsg_size(iw_buf_len), GFP_KERNEL);
591 nla_total_size(iw_buf_len));
592 nskb = nlmsg_new(nlmsg_total_size(payload), GFP_KERNEL);
593 if (nskb == NULL) { 629 if (nskb == NULL) {
594 err = -ENOBUFS; 630 err = -ENOBUFS;
595 goto errout; 631 goto errout;
@@ -597,10 +633,8 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
597 633
598 err = rtnl_fill_ifinfo(nskb, dev, iw, iw_buf_len, RTM_NEWLINK, 634 err = rtnl_fill_ifinfo(nskb, dev, iw, iw_buf_len, RTM_NEWLINK,
599 NETLINK_CB(skb).pid, nlh->nlmsg_seq, 0, 0); 635 NETLINK_CB(skb).pid, nlh->nlmsg_seq, 0, 0);
600 if (err <= 0) { 636 /* failure impilies BUG in if_nlmsg_size or wireless_rtnetlink_get */
601 kfree_skb(nskb); 637 BUG_ON(err < 0);
602 goto errout;
603 }
604 638
605 err = rtnl_unicast(nskb, NETLINK_CB(skb).pid); 639 err = rtnl_unicast(nskb, NETLINK_CB(skb).pid);
606errout: 640errout:
@@ -639,15 +673,13 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
639 struct sk_buff *skb; 673 struct sk_buff *skb;
640 int err = -ENOBUFS; 674 int err = -ENOBUFS;
641 675
642 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 676 skb = nlmsg_new(if_nlmsg_size(0), GFP_KERNEL);
643 if (skb == NULL) 677 if (skb == NULL)
644 goto errout; 678 goto errout;
645 679
646 err = rtnl_fill_ifinfo(skb, dev, NULL, 0, type, 0, 0, change, 0); 680 err = rtnl_fill_ifinfo(skb, dev, NULL, 0, type, 0, 0, change, 0);
647 if (err < 0) { 681 /* failure implies BUG in if_nlmsg_size() */
648 kfree_skb(skb); 682 BUG_ON(err < 0);
649 goto errout;
650 }
651 683
652 err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_KERNEL); 684 err = rtnl_notify(skb, 0, RTNLGRP_LINK, NULL, GFP_KERNEL);
653errout: 685errout:
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b8b106358040..a90bc439488e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -473,8 +473,8 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
473#endif 473#endif
474 C(protocol); 474 C(protocol);
475 n->destructor = NULL; 475 n->destructor = NULL;
476 C(mark);
476#ifdef CONFIG_NETFILTER 477#ifdef CONFIG_NETFILTER
477 C(nfmark);
478 C(nfct); 478 C(nfct);
479 nf_conntrack_get(skb->nfct); 479 nf_conntrack_get(skb->nfct);
480 C(nfctinfo); 480 C(nfctinfo);
@@ -534,8 +534,8 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
534 new->pkt_type = old->pkt_type; 534 new->pkt_type = old->pkt_type;
535 new->tstamp = old->tstamp; 535 new->tstamp = old->tstamp;
536 new->destructor = NULL; 536 new->destructor = NULL;
537 new->mark = old->mark;
537#ifdef CONFIG_NETFILTER 538#ifdef CONFIG_NETFILTER
538 new->nfmark = old->nfmark;
539 new->nfct = old->nfct; 539 new->nfct = old->nfct;
540 nf_conntrack_get(old->nfct); 540 nf_conntrack_get(old->nfct);
541 new->nfctinfo = old->nfctinfo; 541 new->nfctinfo = old->nfctinfo;
@@ -1240,8 +1240,8 @@ EXPORT_SYMBOL(skb_store_bits);
1240 1240
1241/* Checksum skb data. */ 1241/* Checksum skb data. */
1242 1242
1243unsigned int skb_checksum(const struct sk_buff *skb, int offset, 1243__wsum skb_checksum(const struct sk_buff *skb, int offset,
1244 int len, unsigned int csum) 1244 int len, __wsum csum)
1245{ 1245{
1246 int start = skb_headlen(skb); 1246 int start = skb_headlen(skb);
1247 int i, copy = start - offset; 1247 int i, copy = start - offset;
@@ -1265,7 +1265,7 @@ unsigned int skb_checksum(const struct sk_buff *skb, int offset,
1265 1265
1266 end = start + skb_shinfo(skb)->frags[i].size; 1266 end = start + skb_shinfo(skb)->frags[i].size;
1267 if ((copy = end - offset) > 0) { 1267 if ((copy = end - offset) > 0) {
1268 unsigned int csum2; 1268 __wsum csum2;
1269 u8 *vaddr; 1269 u8 *vaddr;
1270 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 1270 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1271 1271
@@ -1294,7 +1294,7 @@ unsigned int skb_checksum(const struct sk_buff *skb, int offset,
1294 1294
1295 end = start + list->len; 1295 end = start + list->len;
1296 if ((copy = end - offset) > 0) { 1296 if ((copy = end - offset) > 0) {
1297 unsigned int csum2; 1297 __wsum csum2;
1298 if (copy > len) 1298 if (copy > len)
1299 copy = len; 1299 copy = len;
1300 csum2 = skb_checksum(list, offset - start, 1300 csum2 = skb_checksum(list, offset - start,
@@ -1315,8 +1315,8 @@ unsigned int skb_checksum(const struct sk_buff *skb, int offset,
1315 1315
1316/* Both of above in one bottle. */ 1316/* Both of above in one bottle. */
1317 1317
1318unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, 1318__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
1319 u8 *to, int len, unsigned int csum) 1319 u8 *to, int len, __wsum csum)
1320{ 1320{
1321 int start = skb_headlen(skb); 1321 int start = skb_headlen(skb);
1322 int i, copy = start - offset; 1322 int i, copy = start - offset;
@@ -1342,7 +1342,7 @@ unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
1342 1342
1343 end = start + skb_shinfo(skb)->frags[i].size; 1343 end = start + skb_shinfo(skb)->frags[i].size;
1344 if ((copy = end - offset) > 0) { 1344 if ((copy = end - offset) > 0) {
1345 unsigned int csum2; 1345 __wsum csum2;
1346 u8 *vaddr; 1346 u8 *vaddr;
1347 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 1347 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1348 1348
@@ -1368,7 +1368,7 @@ unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
1368 struct sk_buff *list = skb_shinfo(skb)->frag_list; 1368 struct sk_buff *list = skb_shinfo(skb)->frag_list;
1369 1369
1370 for (; list; list = list->next) { 1370 for (; list; list = list->next) {
1371 unsigned int csum2; 1371 __wsum csum2;
1372 int end; 1372 int end;
1373 1373
1374 BUG_TRAP(start <= offset + len); 1374 BUG_TRAP(start <= offset + len);
@@ -1396,7 +1396,7 @@ unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
1396 1396
1397void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to) 1397void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
1398{ 1398{
1399 unsigned int csum; 1399 __wsum csum;
1400 long csstart; 1400 long csstart;
1401 1401
1402 if (skb->ip_summed == CHECKSUM_PARTIAL) 1402 if (skb->ip_summed == CHECKSUM_PARTIAL)
@@ -1414,9 +1414,9 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
1414 skb->len - csstart, 0); 1414 skb->len - csstart, 0);
1415 1415
1416 if (skb->ip_summed == CHECKSUM_PARTIAL) { 1416 if (skb->ip_summed == CHECKSUM_PARTIAL) {
1417 long csstuff = csstart + skb->csum; 1417 long csstuff = csstart + skb->csum_offset;
1418 1418
1419 *((unsigned short *)(to + csstuff)) = csum_fold(csum); 1419 *((__sum16 *)(to + csstuff)) = csum_fold(csum);
1420 } 1420 }
1421} 1421}
1422 1422
diff --git a/net/core/sock.c b/net/core/sock.c
index ee6cd2541d35..ab8fafadb4ba 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -270,7 +270,7 @@ out:
270} 270}
271EXPORT_SYMBOL(sock_queue_rcv_skb); 271EXPORT_SYMBOL(sock_queue_rcv_skb);
272 272
273int sk_receive_skb(struct sock *sk, struct sk_buff *skb) 273int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
274{ 274{
275 int rc = NET_RX_SUCCESS; 275 int rc = NET_RX_SUCCESS;
276 276
@@ -279,7 +279,10 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb)
279 279
280 skb->dev = NULL; 280 skb->dev = NULL;
281 281
282 bh_lock_sock(sk); 282 if (nested)
283 bh_lock_sock_nested(sk);
284 else
285 bh_lock_sock(sk);
283 if (!sock_owned_by_user(sk)) { 286 if (!sock_owned_by_user(sk)) {
284 /* 287 /*
285 * trylock + unlock semantics: 288 * trylock + unlock semantics:
@@ -1527,7 +1530,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
1527 atomic_set(&sk->sk_refcnt, 1); 1530 atomic_set(&sk->sk_refcnt, 1);
1528} 1531}
1529 1532
1530void fastcall lock_sock(struct sock *sk) 1533void fastcall lock_sock_nested(struct sock *sk, int subclass)
1531{ 1534{
1532 might_sleep(); 1535 might_sleep();
1533 spin_lock_bh(&sk->sk_lock.slock); 1536 spin_lock_bh(&sk->sk_lock.slock);
@@ -1538,11 +1541,11 @@ void fastcall lock_sock(struct sock *sk)
1538 /* 1541 /*
1539 * The sk_lock has mutex_lock() semantics here: 1542 * The sk_lock has mutex_lock() semantics here:
1540 */ 1543 */
1541 mutex_acquire(&sk->sk_lock.dep_map, 0, 0, _RET_IP_); 1544 mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_);
1542 local_bh_enable(); 1545 local_bh_enable();
1543} 1546}
1544 1547
1545EXPORT_SYMBOL(lock_sock); 1548EXPORT_SYMBOL(lock_sock_nested);
1546 1549
1547void fastcall release_sock(struct sock *sk) 1550void fastcall release_sock(struct sock *sk)
1548{ 1551{
diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 02534131d88e..1e75b1585460 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -21,10 +21,6 @@ extern __u32 sysctl_rmem_max;
21 21
22extern int sysctl_core_destroy_delay; 22extern int sysctl_core_destroy_delay;
23 23
24#ifdef CONFIG_NET_DIVERT
25extern char sysctl_divert_version[];
26#endif /* CONFIG_NET_DIVERT */
27
28#ifdef CONFIG_XFRM 24#ifdef CONFIG_XFRM
29extern u32 sysctl_xfrm_aevent_etime; 25extern u32 sysctl_xfrm_aevent_etime;
30extern u32 sysctl_xfrm_aevent_rseqth; 26extern u32 sysctl_xfrm_aevent_rseqth;
@@ -105,16 +101,6 @@ ctl_table core_table[] = {
105 .mode = 0644, 101 .mode = 0644,
106 .proc_handler = &proc_dointvec 102 .proc_handler = &proc_dointvec
107 }, 103 },
108#ifdef CONFIG_NET_DIVERT
109 {
110 .ctl_name = NET_CORE_DIVERT_VERSION,
111 .procname = "divert_version",
112 .data = (void *)sysctl_divert_version,
113 .maxlen = 32,
114 .mode = 0444,
115 .proc_handler = &proc_dostring
116 },
117#endif /* CONFIG_NET_DIVERT */
118#ifdef CONFIG_XFRM 104#ifdef CONFIG_XFRM
119 { 105 {
120 .ctl_name = NET_CORE_AEVENT_ETIME, 106 .ctl_name = NET_CORE_AEVENT_ETIME,
diff --git a/net/core/utils.c b/net/core/utils.c
index d93fe64f6693..61556065f07e 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -88,7 +88,7 @@ EXPORT_SYMBOL(in_aton);
88#define IN6PTON_NULL 0x20000000 /* first/tail */ 88#define IN6PTON_NULL 0x20000000 /* first/tail */
89#define IN6PTON_UNKNOWN 0x40000000 89#define IN6PTON_UNKNOWN 0x40000000
90 90
91static inline int digit2bin(char c, char delim) 91static inline int digit2bin(char c, int delim)
92{ 92{
93 if (c == delim || c == '\0') 93 if (c == delim || c == '\0')
94 return IN6PTON_DELIM; 94 return IN6PTON_DELIM;
@@ -99,7 +99,7 @@ static inline int digit2bin(char c, char delim)
99 return IN6PTON_UNKNOWN; 99 return IN6PTON_UNKNOWN;
100} 100}
101 101
102static inline int xdigit2bin(char c, char delim) 102static inline int xdigit2bin(char c, int delim)
103{ 103{
104 if (c == delim || c == '\0') 104 if (c == delim || c == '\0')
105 return IN6PTON_DELIM; 105 return IN6PTON_DELIM;
@@ -113,12 +113,14 @@ static inline int xdigit2bin(char c, char delim)
113 return (IN6PTON_XDIGIT | (c - 'a' + 10)); 113 return (IN6PTON_XDIGIT | (c - 'a' + 10));
114 if (c >= 'A' && c <= 'F') 114 if (c >= 'A' && c <= 'F')
115 return (IN6PTON_XDIGIT | (c - 'A' + 10)); 115 return (IN6PTON_XDIGIT | (c - 'A' + 10));
116 if (delim == -1)
117 return IN6PTON_DELIM;
116 return IN6PTON_UNKNOWN; 118 return IN6PTON_UNKNOWN;
117} 119}
118 120
119int in4_pton(const char *src, int srclen, 121int in4_pton(const char *src, int srclen,
120 u8 *dst, 122 u8 *dst,
121 char delim, const char **end) 123 int delim, const char **end)
122{ 124{
123 const char *s; 125 const char *s;
124 u8 *d; 126 u8 *d;
@@ -173,7 +175,7 @@ EXPORT_SYMBOL(in4_pton);
173 175
174int in6_pton(const char *src, int srclen, 176int in6_pton(const char *src, int srclen,
175 u8 *dst, 177 u8 *dst,
176 char delim, const char **end) 178 int delim, const char **end)
177{ 179{
178 const char *s, *tok = NULL; 180 const char *s, *tok = NULL;
179 u8 *d, *dc = NULL; 181 u8 *d, *dc = NULL;
diff --git a/net/dccp/Kconfig b/net/dccp/Kconfig
index ef8919cca74b..b8a68dd41000 100644
--- a/net/dccp/Kconfig
+++ b/net/dccp/Kconfig
@@ -38,6 +38,9 @@ config IP_DCCP_DEBUG
38 ---help--- 38 ---help---
39 Only use this if you're hacking DCCP. 39 Only use this if you're hacking DCCP.
40 40
41 When compiling DCCP as a module, this debugging output can be toggled
42 by setting the parameter dccp_debug of the `dccp' module to 0 or 1.
43
41 Just say N. 44 Just say N.
42 45
43config NET_DCCPPROBE 46config NET_DCCPPROBE
@@ -49,7 +52,7 @@ config NET_DCCPPROBE
49 DCCP congestion avoidance modules. If you don't understand 52 DCCP congestion avoidance modules. If you don't understand
50 what was just said, you don't need it: say N. 53 what was just said, you don't need it: say N.
51 54
52 Documentation on how to use the packet generator can be found 55 Documentation on how to use DCCP connection probing can be found
53 at http://linux-net.osdl.org/index.php/DccpProbe 56 at http://linux-net.osdl.org/index.php/DccpProbe
54 57
55 To compile this code as a module, choose M here: the 58 To compile this code as a module, choose M here: the
diff --git a/net/dccp/Makefile b/net/dccp/Makefile
index 17ed99c46617..f4f8793aafff 100644
--- a/net/dccp/Makefile
+++ b/net/dccp/Makefile
@@ -1,13 +1,13 @@
1obj-$(CONFIG_IPV6) += dccp_ipv6.o
2
3dccp_ipv6-y := ipv6.o
4
5obj-$(CONFIG_IP_DCCP) += dccp.o dccp_ipv4.o 1obj-$(CONFIG_IP_DCCP) += dccp.o dccp_ipv4.o
6 2
7dccp-y := ccid.o feat.o input.o minisocks.o options.o output.o proto.o timer.o 3dccp-y := ccid.o feat.o input.o minisocks.o options.o output.o proto.o timer.o
8 4
9dccp_ipv4-y := ipv4.o 5dccp_ipv4-y := ipv4.o
10 6
7# build dccp_ipv6 as module whenever either IPv6 or DCCP is a module
8obj-$(subst y,$(CONFIG_IP_DCCP),$(CONFIG_IPV6)) += dccp_ipv6.o
9dccp_ipv6-y := ipv6.o
10
11dccp-$(CONFIG_IP_DCCP_ACKVEC) += ackvec.o 11dccp-$(CONFIG_IP_DCCP_ACKVEC) += ackvec.o
12 12
13obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o 13obj-$(CONFIG_INET_DCCP_DIAG) += dccp_diag.o
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index f8208874ac7d..bdf1bb7a82c0 100644
--- a/net/dccp/ackvec.c
+++ b/net/dccp/ackvec.c
@@ -67,15 +67,16 @@ static void dccp_ackvec_insert_avr(struct dccp_ackvec *av,
67int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb) 67int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
68{ 68{
69 struct dccp_sock *dp = dccp_sk(sk); 69 struct dccp_sock *dp = dccp_sk(sk);
70#ifdef CONFIG_IP_DCCP_DEBUG
71 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
72 "CLIENT tx: " : "server tx: ";
73#endif
74 struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec; 70 struct dccp_ackvec *av = dp->dccps_hc_rx_ackvec;
75 int len = av->dccpav_vec_len + 2; 71 /* Figure out how many options do we need to represent the ackvec */
72 const u16 nr_opts = (av->dccpav_vec_len +
73 DCCP_MAX_ACKVEC_OPT_LEN - 1) /
74 DCCP_MAX_ACKVEC_OPT_LEN;
75 u16 len = av->dccpav_vec_len + 2 * nr_opts, i;
76 struct timeval now; 76 struct timeval now;
77 u32 elapsed_time; 77 u32 elapsed_time;
78 unsigned char *to, *from; 78 const unsigned char *tail, *from;
79 unsigned char *to;
79 struct dccp_ackvec_record *avr; 80 struct dccp_ackvec_record *avr;
80 81
81 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) 82 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN)
@@ -94,24 +95,37 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
94 95
95 DCCP_SKB_CB(skb)->dccpd_opt_len += len; 96 DCCP_SKB_CB(skb)->dccpd_opt_len += len;
96 97
97 to = skb_push(skb, len); 98 to = skb_push(skb, len);
98 *to++ = DCCPO_ACK_VECTOR_0;
99 *to++ = len;
100
101 len = av->dccpav_vec_len; 99 len = av->dccpav_vec_len;
102 from = av->dccpav_buf + av->dccpav_buf_head; 100 from = av->dccpav_buf + av->dccpav_buf_head;
101 tail = av->dccpav_buf + DCCP_MAX_ACKVEC_LEN;
102
103 for (i = 0; i < nr_opts; ++i) {
104 int copylen = len;
103 105
104 /* Check if buf_head wraps */ 106 if (len > DCCP_MAX_ACKVEC_OPT_LEN)
105 if ((int)av->dccpav_buf_head + len > DCCP_MAX_ACKVEC_LEN) { 107 copylen = DCCP_MAX_ACKVEC_OPT_LEN;
106 const u32 tailsize = DCCP_MAX_ACKVEC_LEN - av->dccpav_buf_head; 108
109 *to++ = DCCPO_ACK_VECTOR_0;
110 *to++ = copylen + 2;
111
112 /* Check if buf_head wraps */
113 if (from + copylen > tail) {
114 const u16 tailsize = tail - from;
115
116 memcpy(to, from, tailsize);
117 to += tailsize;
118 len -= tailsize;
119 copylen -= tailsize;
120 from = av->dccpav_buf;
121 }
107 122
108 memcpy(to, from, tailsize); 123 memcpy(to, from, copylen);
109 to += tailsize; 124 from += copylen;
110 len -= tailsize; 125 to += copylen;
111 from = av->dccpav_buf; 126 len -= copylen;
112 } 127 }
113 128
114 memcpy(to, from, len);
115 /* 129 /*
116 * From RFC 4340, A.2: 130 * From RFC 4340, A.2:
117 * 131 *
@@ -129,9 +143,9 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb)
129 143
130 dccp_ackvec_insert_avr(av, avr); 144 dccp_ackvec_insert_avr(av, avr);
131 145
132 dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, " 146 dccp_pr_debug("%s ACK Vector 0, len=%d, ack_seqno=%llu, "
133 "ack_ackno=%llu\n", 147 "ack_ackno=%llu\n",
134 debug_prefix, avr->dccpavr_sent_len, 148 dccp_role(sk), avr->dccpavr_sent_len,
135 (unsigned long long)avr->dccpavr_ack_seqno, 149 (unsigned long long)avr->dccpavr_ack_seqno,
136 (unsigned long long)avr->dccpavr_ack_ackno); 150 (unsigned long long)avr->dccpavr_ack_ackno);
137 return 0; 151 return 0;
@@ -145,7 +159,6 @@ struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority)
145 av->dccpav_buf_head = DCCP_MAX_ACKVEC_LEN - 1; 159 av->dccpav_buf_head = DCCP_MAX_ACKVEC_LEN - 1;
146 av->dccpav_buf_ackno = DCCP_MAX_SEQNO + 1; 160 av->dccpav_buf_ackno = DCCP_MAX_SEQNO + 1;
147 av->dccpav_buf_nonce = av->dccpav_buf_nonce = 0; 161 av->dccpav_buf_nonce = av->dccpav_buf_nonce = 0;
148 av->dccpav_ack_ptr = 0;
149 av->dccpav_time.tv_sec = 0; 162 av->dccpav_time.tv_sec = 0;
150 av->dccpav_time.tv_usec = 0; 163 av->dccpav_time.tv_usec = 0;
151 av->dccpav_vec_len = 0; 164 av->dccpav_vec_len = 0;
@@ -174,13 +187,13 @@ void dccp_ackvec_free(struct dccp_ackvec *av)
174} 187}
175 188
176static inline u8 dccp_ackvec_state(const struct dccp_ackvec *av, 189static inline u8 dccp_ackvec_state(const struct dccp_ackvec *av,
177 const u8 index) 190 const u32 index)
178{ 191{
179 return av->dccpav_buf[index] & DCCP_ACKVEC_STATE_MASK; 192 return av->dccpav_buf[index] & DCCP_ACKVEC_STATE_MASK;
180} 193}
181 194
182static inline u8 dccp_ackvec_len(const struct dccp_ackvec *av, 195static inline u8 dccp_ackvec_len(const struct dccp_ackvec *av,
183 const u8 index) 196 const u32 index)
184{ 197{
185 return av->dccpav_buf[index] & DCCP_ACKVEC_LEN_MASK; 198 return av->dccpav_buf[index] & DCCP_ACKVEC_LEN_MASK;
186} 199}
@@ -280,7 +293,7 @@ int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
280 * could reduce the complexity of this scan.) 293 * could reduce the complexity of this scan.)
281 */ 294 */
282 u64 delta = dccp_delta_seqno(ackno, av->dccpav_buf_ackno); 295 u64 delta = dccp_delta_seqno(ackno, av->dccpav_buf_ackno);
283 u8 index = av->dccpav_buf_head; 296 u32 index = av->dccpav_buf_head;
284 297
285 while (1) { 298 while (1) {
286 const u8 len = dccp_ackvec_len(av, index); 299 const u8 len = dccp_ackvec_len(av, index);
@@ -322,21 +335,18 @@ out_duplicate:
322#ifdef CONFIG_IP_DCCP_DEBUG 335#ifdef CONFIG_IP_DCCP_DEBUG
323void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len) 336void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len)
324{ 337{
325 if (!dccp_debug) 338 dccp_pr_debug_cat("ACK vector len=%d, ackno=%llu |", len,
326 return; 339 (unsigned long long)ackno);
327
328 printk("ACK vector len=%d, ackno=%llu |", len,
329 (unsigned long long)ackno);
330 340
331 while (len--) { 341 while (len--) {
332 const u8 state = (*vector & DCCP_ACKVEC_STATE_MASK) >> 6; 342 const u8 state = (*vector & DCCP_ACKVEC_STATE_MASK) >> 6;
333 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK; 343 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
334 344
335 printk("%d,%d|", state, rl); 345 dccp_pr_debug_cat("%d,%d|", state, rl);
336 ++vector; 346 ++vector;
337 } 347 }
338 348
339 printk("\n"); 349 dccp_pr_debug_cat("\n");
340} 350}
341 351
342void dccp_ackvec_print(const struct dccp_ackvec *av) 352void dccp_ackvec_print(const struct dccp_ackvec *av)
@@ -380,24 +390,20 @@ void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, struct sock *sk,
380 */ 390 */
381 list_for_each_entry_reverse(avr, &av->dccpav_records, dccpavr_node) { 391 list_for_each_entry_reverse(avr, &av->dccpav_records, dccpavr_node) {
382 if (ackno == avr->dccpavr_ack_seqno) { 392 if (ackno == avr->dccpavr_ack_seqno) {
383#ifdef CONFIG_IP_DCCP_DEBUG 393 dccp_pr_debug("%s ACK packet 0, len=%d, ack_seqno=%llu, "
384 struct dccp_sock *dp = dccp_sk(sk);
385 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
386 "CLIENT rx ack: " : "server rx ack: ";
387#endif
388 dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, "
389 "ack_ackno=%llu, ACKED!\n", 394 "ack_ackno=%llu, ACKED!\n",
390 debug_prefix, 1, 395 dccp_role(sk), 1,
391 (unsigned long long)avr->dccpavr_ack_seqno, 396 (unsigned long long)avr->dccpavr_ack_seqno,
392 (unsigned long long)avr->dccpavr_ack_ackno); 397 (unsigned long long)avr->dccpavr_ack_ackno);
393 dccp_ackvec_throw_record(av, avr); 398 dccp_ackvec_throw_record(av, avr);
394 break; 399 break;
395 } 400 } else if (avr->dccpavr_ack_seqno > ackno)
401 break; /* old news */
396 } 402 }
397} 403}
398 404
399static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av, 405static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av,
400 struct sock *sk, u64 ackno, 406 struct sock *sk, u64 *ackno,
401 const unsigned char len, 407 const unsigned char len,
402 const unsigned char *vector) 408 const unsigned char *vector)
403{ 409{
@@ -420,7 +426,7 @@ static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av,
420 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK; 426 const u8 rl = *vector & DCCP_ACKVEC_LEN_MASK;
421 u64 ackno_end_rl; 427 u64 ackno_end_rl;
422 428
423 dccp_set_seqno(&ackno_end_rl, ackno - rl); 429 dccp_set_seqno(&ackno_end_rl, *ackno - rl);
424 430
425 /* 431 /*
426 * If our AVR sequence number is greater than the ack, go 432 * If our AVR sequence number is greater than the ack, go
@@ -428,25 +434,19 @@ static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av,
428 */ 434 */
429 list_for_each_entry_from(avr, &av->dccpav_records, 435 list_for_each_entry_from(avr, &av->dccpav_records,
430 dccpavr_node) { 436 dccpavr_node) {
431 if (!after48(avr->dccpavr_ack_seqno, ackno)) 437 if (!after48(avr->dccpavr_ack_seqno, *ackno))
432 goto found; 438 goto found;
433 } 439 }
434 /* End of the dccpav_records list, not found, exit */ 440 /* End of the dccpav_records list, not found, exit */
435 break; 441 break;
436found: 442found:
437 if (between48(avr->dccpavr_ack_seqno, ackno_end_rl, ackno)) { 443 if (between48(avr->dccpavr_ack_seqno, ackno_end_rl, *ackno)) {
438 const u8 state = *vector & DCCP_ACKVEC_STATE_MASK; 444 const u8 state = *vector & DCCP_ACKVEC_STATE_MASK;
439 if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED) { 445 if (state != DCCP_ACKVEC_STATE_NOT_RECEIVED) {
440#ifdef CONFIG_IP_DCCP_DEBUG 446 dccp_pr_debug("%s ACK vector 0, len=%d, "
441 struct dccp_sock *dp = dccp_sk(sk);
442 const char *debug_prefix =
443 dp->dccps_role == DCCP_ROLE_CLIENT ?
444 "CLIENT rx ack: " : "server rx ack: ";
445#endif
446 dccp_pr_debug("%sACK vector 0, len=%d, "
447 "ack_seqno=%llu, ack_ackno=%llu, " 447 "ack_seqno=%llu, ack_ackno=%llu, "
448 "ACKED!\n", 448 "ACKED!\n",
449 debug_prefix, len, 449 dccp_role(sk), len,
450 (unsigned long long) 450 (unsigned long long)
451 avr->dccpavr_ack_seqno, 451 avr->dccpavr_ack_seqno,
452 (unsigned long long) 452 (unsigned long long)
@@ -460,27 +460,23 @@ found:
460 */ 460 */
461 } 461 }
462 462
463 dccp_set_seqno(&ackno, ackno_end_rl - 1); 463 dccp_set_seqno(ackno, ackno_end_rl - 1);
464 ++vector; 464 ++vector;
465 } 465 }
466} 466}
467 467
468int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, 468int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
469 const u8 opt, const u8 *value, const u8 len) 469 u64 *ackno, const u8 opt, const u8 *value, const u8 len)
470{ 470{
471 if (len > DCCP_MAX_ACKVEC_LEN) 471 if (len > DCCP_MAX_ACKVEC_OPT_LEN)
472 return -1; 472 return -1;
473 473
474 /* dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, value, len); */ 474 /* dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, value, len); */
475 dccp_ackvec_check_rcv_ackvector(dccp_sk(sk)->dccps_hc_rx_ackvec, sk, 475 dccp_ackvec_check_rcv_ackvector(dccp_sk(sk)->dccps_hc_rx_ackvec, sk,
476 DCCP_SKB_CB(skb)->dccpd_ack_seq, 476 ackno, len, value);
477 len, value);
478 return 0; 477 return 0;
479} 478}
480 479
481static char dccp_ackvec_slab_msg[] __initdata =
482 KERN_CRIT "DCCP: Unable to create ack vectors slab caches\n";
483
484int __init dccp_ackvec_init(void) 480int __init dccp_ackvec_init(void)
485{ 481{
486 dccp_ackvec_slab = kmem_cache_create("dccp_ackvec", 482 dccp_ackvec_slab = kmem_cache_create("dccp_ackvec",
@@ -502,7 +498,7 @@ out_destroy_slab:
502 kmem_cache_destroy(dccp_ackvec_slab); 498 kmem_cache_destroy(dccp_ackvec_slab);
503 dccp_ackvec_slab = NULL; 499 dccp_ackvec_slab = NULL;
504out_err: 500out_err:
505 printk(dccp_ackvec_slab_msg); 501 DCCP_CRIT("Unable to create Ack Vector slab cache");
506 return -ENOBUFS; 502 return -ENOBUFS;
507} 503}
508 504
diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h
index cf8f20ce23a9..96504a3b16e4 100644
--- a/net/dccp/ackvec.h
+++ b/net/dccp/ackvec.h
@@ -17,7 +17,9 @@
17#include <linux/types.h> 17#include <linux/types.h>
18 18
19/* Read about the ECN nonce to see why it is 253 */ 19/* Read about the ECN nonce to see why it is 253 */
20#define DCCP_MAX_ACKVEC_LEN 253 20#define DCCP_MAX_ACKVEC_OPT_LEN 253
21/* We can spread an ack vector across multiple options */
22#define DCCP_MAX_ACKVEC_LEN (DCCP_MAX_ACKVEC_OPT_LEN * 2)
21 23
22#define DCCP_ACKVEC_STATE_RECEIVED 0 24#define DCCP_ACKVEC_STATE_RECEIVED 0
23#define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6) 25#define DCCP_ACKVEC_STATE_ECN_MARKED (1 << 6)
@@ -41,7 +43,6 @@
41 * Ack Vectors it has recently sent. For each packet sent carrying an 43 * Ack Vectors it has recently sent. For each packet sent carrying an
42 * Ack Vector, it remembers four variables: 44 * Ack Vector, it remembers four variables:
43 * 45 *
44 * @dccpav_ack_ptr - the value of buf_head at the time of acknowledgement.
45 * @dccpav_records - list of dccp_ackvec_record 46 * @dccpav_records - list of dccp_ackvec_record
46 * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. 47 * @dccpav_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
47 * 48 *
@@ -52,9 +53,8 @@ struct dccp_ackvec {
52 u64 dccpav_buf_ackno; 53 u64 dccpav_buf_ackno;
53 struct list_head dccpav_records; 54 struct list_head dccpav_records;
54 struct timeval dccpav_time; 55 struct timeval dccpav_time;
55 u8 dccpav_buf_head; 56 u16 dccpav_buf_head;
56 u8 dccpav_ack_ptr; 57 u16 dccpav_vec_len;
57 u8 dccpav_vec_len;
58 u8 dccpav_buf_nonce; 58 u8 dccpav_buf_nonce;
59 u8 dccpav_ack_nonce; 59 u8 dccpav_ack_nonce;
60 u8 dccpav_buf[DCCP_MAX_ACKVEC_LEN]; 60 u8 dccpav_buf[DCCP_MAX_ACKVEC_LEN];
@@ -77,9 +77,9 @@ struct dccp_ackvec_record {
77 struct list_head dccpavr_node; 77 struct list_head dccpavr_node;
78 u64 dccpavr_ack_seqno; 78 u64 dccpavr_ack_seqno;
79 u64 dccpavr_ack_ackno; 79 u64 dccpavr_ack_ackno;
80 u8 dccpavr_ack_ptr; 80 u16 dccpavr_ack_ptr;
81 u16 dccpavr_sent_len;
81 u8 dccpavr_ack_nonce; 82 u8 dccpavr_ack_nonce;
82 u8 dccpavr_sent_len;
83}; 83};
84 84
85struct sock; 85struct sock;
@@ -98,7 +98,8 @@ extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk,
98extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, 98extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
99 struct sock *sk, const u64 ackno); 99 struct sock *sk, const u64 ackno);
100extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, 100extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
101 const u8 opt, const u8 *value, const u8 len); 101 u64 *ackno, const u8 opt,
102 const u8 *value, const u8 len);
102 103
103extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb); 104extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb);
104 105
@@ -137,7 +138,8 @@ static inline void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av,
137} 138}
138 139
139static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, 140static inline int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb,
140 const u8 opt, const u8 *value, const u8 len) 141 const u64 *ackno, const u8 opt,
142 const u8 *value, const u8 len)
141{ 143{
142 return -1; 144 return -1;
143} 145}
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index f7eb6c613414..c7c29514dce8 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -52,9 +52,9 @@ struct ccid_operations {
52 unsigned char len, u16 idx, 52 unsigned char len, u16 idx,
53 unsigned char* value); 53 unsigned char* value);
54 int (*ccid_hc_tx_send_packet)(struct sock *sk, 54 int (*ccid_hc_tx_send_packet)(struct sock *sk,
55 struct sk_buff *skb, int len); 55 struct sk_buff *skb);
56 void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more, 56 void (*ccid_hc_tx_packet_sent)(struct sock *sk,
57 int len); 57 int more, unsigned int len);
58 void (*ccid_hc_rx_get_info)(struct sock *sk, 58 void (*ccid_hc_rx_get_info)(struct sock *sk,
59 struct tcp_info *info); 59 struct tcp_info *info);
60 void (*ccid_hc_tx_get_info)(struct sock *sk, 60 void (*ccid_hc_tx_get_info)(struct sock *sk,
@@ -94,16 +94,16 @@ extern void ccid_hc_rx_delete(struct ccid *ccid, struct sock *sk);
94extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk); 94extern void ccid_hc_tx_delete(struct ccid *ccid, struct sock *sk);
95 95
96static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk, 96static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
97 struct sk_buff *skb, int len) 97 struct sk_buff *skb)
98{ 98{
99 int rc = 0; 99 int rc = 0;
100 if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL) 100 if (ccid->ccid_ops->ccid_hc_tx_send_packet != NULL)
101 rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb, len); 101 rc = ccid->ccid_ops->ccid_hc_tx_send_packet(sk, skb);
102 return rc; 102 return rc;
103} 103}
104 104
105static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk, 105static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
106 int more, int len) 106 int more, unsigned int len)
107{ 107{
108 if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL) 108 if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
109 ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len); 109 ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len);
diff --git a/net/dccp/ccids/Kconfig b/net/dccp/ccids/Kconfig
index 8533dabfb9f8..dac89166eb18 100644
--- a/net/dccp/ccids/Kconfig
+++ b/net/dccp/ccids/Kconfig
@@ -28,13 +28,20 @@ config IP_DCCP_CCID2
28 This text was extracted from RFC 4340 (sec. 10.1), 28 This text was extracted from RFC 4340 (sec. 10.1),
29 http://www.ietf.org/rfc/rfc4340.txt 29 http://www.ietf.org/rfc/rfc4340.txt
30 30
31 To compile this CCID as a module, choose M here: the module will be
32 called dccp_ccid2.
33
31 If in doubt, say M. 34 If in doubt, say M.
32 35
33config IP_DCCP_CCID2_DEBUG 36config IP_DCCP_CCID2_DEBUG
34 bool "CCID2 debug" 37 bool "CCID2 debugging messages"
35 depends on IP_DCCP_CCID2 38 depends on IP_DCCP_CCID2
36 ---help--- 39 ---help---
37 Enable CCID2 debug messages. 40 Enable CCID2-specific debugging messages.
41
42 When compiling CCID2 as a module, this debugging output can
43 additionally be toggled by setting the ccid2_debug module
44 parameter to 0 or 1.
38 45
39 If in doubt, say N. 46 If in doubt, say N.
40 47
@@ -62,10 +69,24 @@ config IP_DCCP_CCID3
62 This text was extracted from RFC 4340 (sec. 10.2), 69 This text was extracted from RFC 4340 (sec. 10.2),
63 http://www.ietf.org/rfc/rfc4340.txt 70 http://www.ietf.org/rfc/rfc4340.txt
64 71
72 To compile this CCID as a module, choose M here: the module will be
73 called dccp_ccid3.
74
65 If in doubt, say M. 75 If in doubt, say M.
66 76
67config IP_DCCP_TFRC_LIB 77config IP_DCCP_TFRC_LIB
68 depends on IP_DCCP_CCID3 78 depends on IP_DCCP_CCID3
69 def_tristate IP_DCCP_CCID3 79 def_tristate IP_DCCP_CCID3
70 80
81config IP_DCCP_CCID3_DEBUG
82 bool "CCID3 debugging messages"
83 depends on IP_DCCP_CCID3
84 ---help---
85 Enable CCID3-specific debugging messages.
86
87 When compiling CCID3 as a module, this debugging output can
88 additionally be toggled by setting the ccid3_debug module
89 parameter to 0 or 1.
90
91 If in doubt, say N.
71endmenu 92endmenu
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index 162032baeac0..2555be8f4790 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -33,18 +33,11 @@
33#include "../dccp.h" 33#include "../dccp.h"
34#include "ccid2.h" 34#include "ccid2.h"
35 35
36static int ccid2_debug;
37 36
38#ifdef CONFIG_IP_DCCP_CCID2_DEBUG 37#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
39#define ccid2_pr_debug(format, a...) \ 38static int ccid2_debug;
40 do { if (ccid2_debug) \ 39#define ccid2_pr_debug(format, a...) DCCP_PR_DEBUG(ccid2_debug, format, ##a)
41 printk(KERN_DEBUG "%s: " format, __FUNCTION__, ##a); \
42 } while (0)
43#else
44#define ccid2_pr_debug(format, a...)
45#endif
46 40
47#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
48static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) 41static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
49{ 42{
50 int len = 0; 43 int len = 0;
@@ -86,7 +79,8 @@ static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx)
86 BUG_ON(len != hctx->ccid2hctx_seqbufc * CCID2_SEQBUF_LEN); 79 BUG_ON(len != hctx->ccid2hctx_seqbufc * CCID2_SEQBUF_LEN);
87} 80}
88#else 81#else
89#define ccid2_hc_tx_check_sanity(hctx) do {} while (0) 82#define ccid2_pr_debug(format, a...)
83#define ccid2_hc_tx_check_sanity(hctx)
90#endif 84#endif
91 85
92static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx, int num, 86static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx, int num,
@@ -131,8 +125,7 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hctx, int num,
131 return 0; 125 return 0;
132} 126}
133 127
134static int ccid2_hc_tx_send_packet(struct sock *sk, 128static int ccid2_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
135 struct sk_buff *skb, int len)
136{ 129{
137 struct ccid2_hc_tx_sock *hctx; 130 struct ccid2_hc_tx_sock *hctx;
138 131
@@ -274,7 +267,7 @@ static void ccid2_start_rto_timer(struct sock *sk)
274 jiffies + hctx->ccid2hctx_rto); 267 jiffies + hctx->ccid2hctx_rto);
275} 268}
276 269
277static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len) 270static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
278{ 271{
279 struct dccp_sock *dp = dccp_sk(sk); 272 struct dccp_sock *dp = dccp_sk(sk);
280 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); 273 struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk);
@@ -426,7 +419,7 @@ static int ccid2_ackvector(struct sock *sk, struct sk_buff *skb, int offset,
426 return -1; 419 return -1;
427 420
428out_invalid_option: 421out_invalid_option:
429 BUG_ON(1); /* should never happen... options were previously parsed ! */ 422 DCCP_BUG("Invalid option - this should not happen (previous parsing)!");
430 return -1; 423 return -1;
431} 424}
432 425
@@ -619,7 +612,17 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
619 } 612 }
620 613
621 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq; 614 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
622 seqp = hctx->ccid2hctx_seqh->ccid2s_prev; 615 if (after48(ackno, hctx->ccid2hctx_high_ack))
616 hctx->ccid2hctx_high_ack = ackno;
617
618 seqp = hctx->ccid2hctx_seqt;
619 while (before48(seqp->ccid2s_seq, ackno)) {
620 seqp = seqp->ccid2s_next;
621 if (seqp == hctx->ccid2hctx_seqh) {
622 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
623 break;
624 }
625 }
623 626
624 /* If in slow-start, cwnd can increase at most Ack Ratio / 2 packets for 627 /* If in slow-start, cwnd can increase at most Ack Ratio / 2 packets for
625 * this single ack. I round up. 628 * this single ack. I round up.
@@ -697,7 +700,14 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
697 /* The state about what is acked should be correct now 700 /* The state about what is acked should be correct now
698 * Check for NUMDUPACK 701 * Check for NUMDUPACK
699 */ 702 */
700 seqp = hctx->ccid2hctx_seqh->ccid2s_prev; 703 seqp = hctx->ccid2hctx_seqt;
704 while (before48(seqp->ccid2s_seq, hctx->ccid2hctx_high_ack)) {
705 seqp = seqp->ccid2s_next;
706 if (seqp == hctx->ccid2hctx_seqh) {
707 seqp = hctx->ccid2hctx_seqh->ccid2s_prev;
708 break;
709 }
710 }
701 done = 0; 711 done = 0;
702 while (1) { 712 while (1) {
703 if (seqp->ccid2s_acked) { 713 if (seqp->ccid2s_acked) {
@@ -771,6 +781,7 @@ static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk)
771 hctx->ccid2hctx_lastrtt = 0; 781 hctx->ccid2hctx_lastrtt = 0;
772 hctx->ccid2hctx_rpdupack = -1; 782 hctx->ccid2hctx_rpdupack = -1;
773 hctx->ccid2hctx_last_cong = jiffies; 783 hctx->ccid2hctx_last_cong = jiffies;
784 hctx->ccid2hctx_high_ack = 0;
774 785
775 hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire; 786 hctx->ccid2hctx_rtotimer.function = &ccid2_hc_tx_rto_expire;
776 hctx->ccid2hctx_rtotimer.data = (unsigned long)sk; 787 hctx->ccid2hctx_rtotimer.data = (unsigned long)sk;
@@ -823,8 +834,10 @@ static struct ccid_operations ccid2 = {
823 .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv, 834 .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv,
824}; 835};
825 836
837#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
826module_param(ccid2_debug, int, 0444); 838module_param(ccid2_debug, int, 0444);
827MODULE_PARM_DESC(ccid2_debug, "Enable debug messages"); 839MODULE_PARM_DESC(ccid2_debug, "Enable debug messages");
840#endif
828 841
829static __init int ccid2_module_init(void) 842static __init int ccid2_module_init(void)
830{ 843{
diff --git a/net/dccp/ccids/ccid2.h b/net/dccp/ccids/ccid2.h
index 5b2ef4acb300..ebd79499c85a 100644
--- a/net/dccp/ccids/ccid2.h
+++ b/net/dccp/ccids/ccid2.h
@@ -35,7 +35,7 @@ struct ccid2_seq {
35 struct ccid2_seq *ccid2s_next; 35 struct ccid2_seq *ccid2s_next;
36}; 36};
37 37
38#define CCID2_SEQBUF_LEN 256 38#define CCID2_SEQBUF_LEN 1024
39#define CCID2_SEQBUF_MAX 128 39#define CCID2_SEQBUF_MAX 128
40 40
41/** struct ccid2_hc_tx_sock - CCID2 TX half connection 41/** struct ccid2_hc_tx_sock - CCID2 TX half connection
@@ -72,6 +72,7 @@ struct ccid2_hc_tx_sock {
72 int ccid2hctx_rpdupack; 72 int ccid2hctx_rpdupack;
73 int ccid2hctx_sendwait; 73 int ccid2hctx_sendwait;
74 unsigned long ccid2hctx_last_cong; 74 unsigned long ccid2hctx_last_cong;
75 u64 ccid2hctx_high_ack;
75}; 76};
76 77
77struct ccid2_hc_rx_sock { 78struct ccid2_hc_rx_sock {
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index cec23ad286de..70ebe705eb75 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -60,13 +60,11 @@ static u32 usecs_div(const u32 a, const u32 b)
60 return (b >= 2 * div) ? tmp / (b / div) : tmp; 60 return (b >= 2 * div) ? tmp / (b / div) : tmp;
61} 61}
62 62
63static int ccid3_debug;
64 63
65#ifdef CCID3_DEBUG 64
66#define ccid3_pr_debug(format, a...) \ 65#ifdef CONFIG_IP_DCCP_CCID3_DEBUG
67 do { if (ccid3_debug) \ 66static int ccid3_debug;
68 printk(KERN_DEBUG "%s: " format, __FUNCTION__, ##a); \ 67#define ccid3_pr_debug(format, a...) DCCP_PR_DEBUG(ccid3_debug, format, ##a)
69 } while (0)
70#else 68#else
71#define ccid3_pr_debug(format, a...) 69#define ccid3_pr_debug(format, a...)
72#endif 70#endif
@@ -75,15 +73,7 @@ static struct dccp_tx_hist *ccid3_tx_hist;
75static struct dccp_rx_hist *ccid3_rx_hist; 73static struct dccp_rx_hist *ccid3_rx_hist;
76static struct dccp_li_hist *ccid3_li_hist; 74static struct dccp_li_hist *ccid3_li_hist;
77 75
78/* TFRC sender states */ 76#ifdef CONFIG_IP_DCCP_CCID3_DEBUG
79enum ccid3_hc_tx_states {
80 TFRC_SSTATE_NO_SENT = 1,
81 TFRC_SSTATE_NO_FBACK,
82 TFRC_SSTATE_FBACK,
83 TFRC_SSTATE_TERM,
84};
85
86#ifdef CCID3_DEBUG
87static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) 77static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state)
88{ 78{
89 static char *ccid3_state_names[] = { 79 static char *ccid3_state_names[] = {
@@ -110,25 +100,24 @@ static void ccid3_hc_tx_set_state(struct sock *sk,
110 hctx->ccid3hctx_state = state; 100 hctx->ccid3hctx_state = state;
111} 101}
112 102
113/* Calculate new t_ipi (inter packet interval) by t_ipi = s / X_inst */ 103/*
114static inline void ccid3_calc_new_t_ipi(struct ccid3_hc_tx_sock *hctx) 104 * Recalculate scheduled nominal send time t_nom, inter-packet interval
105 * t_ipi, and delta value. Should be called after each change to X.
106 */
107static inline void ccid3_update_send_time(struct ccid3_hc_tx_sock *hctx)
115{ 108{
116 /* 109 timeval_sub_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi);
117 * If no feedback spec says t_ipi is 1 second (set elsewhere and then
118 * doubles after every no feedback timer (separate function)
119 */
120 if (hctx->ccid3hctx_state != TFRC_SSTATE_NO_FBACK)
121 hctx->ccid3hctx_t_ipi = usecs_div(hctx->ccid3hctx_s,
122 hctx->ccid3hctx_x);
123}
124 110
125/* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */ 111 /* Calculate new t_ipi (inter packet interval) by t_ipi = s / X_inst */
126static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx) 112 hctx->ccid3hctx_t_ipi = usecs_div(hctx->ccid3hctx_s, hctx->ccid3hctx_x);
127{ 113
114 /* Update nominal send time with regard to the new t_ipi */
115 timeval_add_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi);
116
117 /* Calculate new delta by delta = min(t_ipi / 2, t_gran / 2) */
128 hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2, 118 hctx->ccid3hctx_delta = min_t(u32, hctx->ccid3hctx_t_ipi / 2,
129 TFRC_OPSYS_HALF_TIME_GRAN); 119 TFRC_OPSYS_HALF_TIME_GRAN);
130} 120}
131
132/* 121/*
133 * Update X by 122 * Update X by
134 * If (p > 0) 123 * If (p > 0)
@@ -139,76 +128,85 @@ static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx)
139 * X = max(min(2 * X, 2 * X_recv), s / R); 128 * X = max(min(2 * X, 2 * X_recv), s / R);
140 * tld = now; 129 * tld = now;
141 */ 130 */
142static void ccid3_hc_tx_update_x(struct sock *sk) 131static void ccid3_hc_tx_update_x(struct sock *sk, struct timeval *now)
132
143{ 133{
144 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 134 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
135 const __u32 old_x = hctx->ccid3hctx_x;
145 136
146 /* To avoid large error in calcX */ 137 /* To avoid large error in calcX */
147 if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { 138 if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) {
148 hctx->ccid3hctx_x_calc = tfrc_calc_x(hctx->ccid3hctx_s, 139 hctx->ccid3hctx_x_calc = tfrc_calc_x(hctx->ccid3hctx_s,
149 hctx->ccid3hctx_rtt, 140 hctx->ccid3hctx_rtt,
150 hctx->ccid3hctx_p); 141 hctx->ccid3hctx_p);
151 hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_calc, 142 hctx->ccid3hctx_x = max_t(u32, min(hctx->ccid3hctx_x_calc,
152 2 * hctx->ccid3hctx_x_recv), 143 hctx->ccid3hctx_x_recv * 2),
153 (hctx->ccid3hctx_s / 144 hctx->ccid3hctx_s / TFRC_T_MBI);
154 TFRC_MAX_BACK_OFF_TIME)); 145
155 } else { 146 } else if (timeval_delta(now, &hctx->ccid3hctx_t_ld) >=
156 struct timeval now; 147 hctx->ccid3hctx_rtt) {
148 hctx->ccid3hctx_x = max(min(hctx->ccid3hctx_x_recv,
149 hctx->ccid3hctx_x ) * 2,
150 usecs_div(hctx->ccid3hctx_s,
151 hctx->ccid3hctx_rtt) );
152 hctx->ccid3hctx_t_ld = *now;
153 } else
154 ccid3_pr_debug("Not changing X\n");
157 155
158 dccp_timestamp(sk, &now); 156 if (hctx->ccid3hctx_x != old_x)
159 if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= 157 ccid3_update_send_time(hctx);
160 hctx->ccid3hctx_rtt) { 158}
161 hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, 159
162 hctx->ccid3hctx_x) * 2, 160/*
163 usecs_div(hctx->ccid3hctx_s, 161 * Track the mean packet size `s' (cf. RFC 4342, 5.3 and RFC 3448, 4.1)
164 hctx->ccid3hctx_rtt)); 162 * @len: DCCP packet payload size in bytes
165 hctx->ccid3hctx_t_ld = now; 163 */
166 } 164static inline void ccid3_hc_tx_update_s(struct ccid3_hc_tx_sock *hctx, int len)
167 } 165{
166 if (unlikely(len == 0))
167 ccid3_pr_debug("Packet payload length is 0 - not updating\n");
168 else
169 hctx->ccid3hctx_s = hctx->ccid3hctx_s == 0 ? len :
170 (9 * hctx->ccid3hctx_s + len) / 10;
171 /*
172 * Note: We could do a potential optimisation here - when `s' changes,
173 * recalculate sending rate and consequently t_ipi, t_delta, and
174 * t_now. This is however non-standard, and the benefits are not
175 * clear, so it is currently left out.
176 */
168} 177}
169 178
170static void ccid3_hc_tx_no_feedback_timer(unsigned long data) 179static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
171{ 180{
172 struct sock *sk = (struct sock *)data; 181 struct sock *sk = (struct sock *)data;
173 unsigned long next_tmout = 0;
174 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 182 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
183 unsigned long t_nfb = USEC_PER_SEC / 5;
175 184
176 bh_lock_sock(sk); 185 bh_lock_sock(sk);
177 if (sock_owned_by_user(sk)) { 186 if (sock_owned_by_user(sk)) {
178 /* Try again later. */ 187 /* Try again later. */
179 /* XXX: set some sensible MIB */ 188 /* XXX: set some sensible MIB */
180 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, 189 goto restart_timer;
181 jiffies + HZ / 5);
182 goto out;
183 } 190 }
184 191
185 ccid3_pr_debug("%s, sk=%p, state=%s\n", dccp_role(sk), sk, 192 ccid3_pr_debug("%s, sk=%p, state=%s\n", dccp_role(sk), sk,
186 ccid3_tx_state_name(hctx->ccid3hctx_state)); 193 ccid3_tx_state_name(hctx->ccid3hctx_state));
187 194
188 switch (hctx->ccid3hctx_state) { 195 switch (hctx->ccid3hctx_state) {
189 case TFRC_SSTATE_TERM:
190 goto out;
191 case TFRC_SSTATE_NO_FBACK: 196 case TFRC_SSTATE_NO_FBACK:
192 /* Halve send rate */ 197 /* RFC 3448, 4.4: Halve send rate directly */
193 hctx->ccid3hctx_x /= 2; 198 hctx->ccid3hctx_x = min_t(u32, hctx->ccid3hctx_x / 2,
194 if (hctx->ccid3hctx_x < (hctx->ccid3hctx_s / 199 hctx->ccid3hctx_s / TFRC_T_MBI);
195 TFRC_MAX_BACK_OFF_TIME))
196 hctx->ccid3hctx_x = (hctx->ccid3hctx_s /
197 TFRC_MAX_BACK_OFF_TIME);
198 200
199 ccid3_pr_debug("%s, sk=%p, state=%s, updated tx rate to %d " 201 ccid3_pr_debug("%s, sk=%p, state=%s, updated tx rate to %d "
200 "bytes/s\n", 202 "bytes/s\n",
201 dccp_role(sk), sk, 203 dccp_role(sk), sk,
202 ccid3_tx_state_name(hctx->ccid3hctx_state), 204 ccid3_tx_state_name(hctx->ccid3hctx_state),
203 hctx->ccid3hctx_x); 205 hctx->ccid3hctx_x);
204 next_tmout = max_t(u32, 2 * usecs_div(hctx->ccid3hctx_s, 206 /* The value of R is still undefined and so we can not recompute
205 hctx->ccid3hctx_x), 207 * the timout value. Keep initial value as per [RFC 4342, 5]. */
206 TFRC_INITIAL_TIMEOUT); 208 t_nfb = TFRC_INITIAL_TIMEOUT;
207 /* 209 ccid3_update_send_time(hctx);
208 * FIXME - not sure above calculation is correct. See section
209 * 5 of CCID3 11 should adjust tx_t_ipi and double that to
210 * achieve it really
211 */
212 break; 210 break;
213 case TFRC_SSTATE_FBACK: 211 case TFRC_SSTATE_FBACK:
214 /* 212 /*
@@ -218,6 +216,8 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
218 if (!hctx->ccid3hctx_idle || 216 if (!hctx->ccid3hctx_idle ||
219 (hctx->ccid3hctx_x_recv >= 217 (hctx->ccid3hctx_x_recv >=
220 4 * usecs_div(hctx->ccid3hctx_s, hctx->ccid3hctx_rtt))) { 218 4 * usecs_div(hctx->ccid3hctx_s, hctx->ccid3hctx_rtt))) {
219 struct timeval now;
220
221 ccid3_pr_debug("%s, sk=%p, state=%s, not idle\n", 221 ccid3_pr_debug("%s, sk=%p, state=%s, not idle\n",
222 dccp_role(sk), sk, 222 dccp_role(sk), sk,
223 ccid3_tx_state_name(hctx->ccid3hctx_state)); 223 ccid3_tx_state_name(hctx->ccid3hctx_state));
@@ -235,55 +235,60 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
235 if (hctx->ccid3hctx_p < TFRC_SMALLEST_P || 235 if (hctx->ccid3hctx_p < TFRC_SMALLEST_P ||
236 hctx->ccid3hctx_x_calc > 2 * hctx->ccid3hctx_x_recv) 236 hctx->ccid3hctx_x_calc > 2 * hctx->ccid3hctx_x_recv)
237 hctx->ccid3hctx_x_recv = max_t(u32, hctx->ccid3hctx_x_recv / 2, 237 hctx->ccid3hctx_x_recv = max_t(u32, hctx->ccid3hctx_x_recv / 2,
238 hctx->ccid3hctx_s / (2 * TFRC_MAX_BACK_OFF_TIME)); 238 hctx->ccid3hctx_s / (2 * TFRC_T_MBI));
239 else 239 else
240 hctx->ccid3hctx_x_recv = hctx->ccid3hctx_x_calc / 4; 240 hctx->ccid3hctx_x_recv = hctx->ccid3hctx_x_calc / 4;
241 241
242 /* Update sending rate */ 242 /* Update sending rate */
243 ccid3_hc_tx_update_x(sk); 243 dccp_timestamp(sk, &now);
244 ccid3_hc_tx_update_x(sk, &now);
244 } 245 }
245 /* 246 /*
246 * Schedule no feedback timer to expire in 247 * Schedule no feedback timer to expire in
247 * max(4 * R, 2 * s / X) 248 * max(4 * R, 2 * s/X) = max(4 * R, 2 * t_ipi)
248 */ 249 */
249 next_tmout = max_t(u32, hctx->ccid3hctx_t_rto, 250 t_nfb = max(4 * hctx->ccid3hctx_rtt, 2 * hctx->ccid3hctx_t_ipi);
250 2 * usecs_div(hctx->ccid3hctx_s,
251 hctx->ccid3hctx_x));
252 break; 251 break;
253 default: 252 case TFRC_SSTATE_NO_SENT:
254 printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", 253 DCCP_BUG("Illegal %s state NO_SENT, sk=%p", dccp_role(sk), sk);
255 __FUNCTION__, dccp_role(sk), sk, hctx->ccid3hctx_state); 254 /* fall through */
256 dump_stack(); 255 case TFRC_SSTATE_TERM:
257 goto out; 256 goto out;
258 } 257 }
259 258
260 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
261 jiffies + max_t(u32, 1, usecs_to_jiffies(next_tmout)));
262 hctx->ccid3hctx_idle = 1; 259 hctx->ccid3hctx_idle = 1;
260
261restart_timer:
262 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
263 jiffies + usecs_to_jiffies(t_nfb));
263out: 264out:
264 bh_unlock_sock(sk); 265 bh_unlock_sock(sk);
265 sock_put(sk); 266 sock_put(sk);
266} 267}
267 268
268static int ccid3_hc_tx_send_packet(struct sock *sk, 269/*
269 struct sk_buff *skb, int len) 270 * returns
271 * > 0: delay (in msecs) that should pass before actually sending
272 * = 0: can send immediately
273 * < 0: error condition; do not send packet
274 */
275static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
270{ 276{
271 struct dccp_sock *dp = dccp_sk(sk); 277 struct dccp_sock *dp = dccp_sk(sk);
272 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 278 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
273 struct dccp_tx_hist_entry *new_packet; 279 struct dccp_tx_hist_entry *new_packet;
274 struct timeval now; 280 struct timeval now;
275 long delay; 281 long delay;
276 int rc = -ENOTCONN;
277 282
278 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); 283 BUG_ON(hctx == NULL);
279 284
280 /* Check if pure ACK or Terminating*/
281 /* 285 /*
282 * XXX: We only call this function for DATA and DATAACK, on, these 286 * This function is called only for Data and DataAck packets. Sending
283 * packets can have zero length, but why the comment about "pure ACK"? 287 * zero-sized Data(Ack)s is theoretically possible, but for congestion
288 * control this case is pathological - ignore it.
284 */ 289 */
285 if (unlikely(len == 0)) 290 if (unlikely(skb->len == 0))
286 goto out; 291 return -EBADMSG;
287 292
288 /* See if last packet allocated was not sent */ 293 /* See if last packet allocated was not sent */
289 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); 294 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
@@ -291,12 +296,10 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
291 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist, 296 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist,
292 SLAB_ATOMIC); 297 SLAB_ATOMIC);
293 298
294 rc = -ENOBUFS;
295 if (unlikely(new_packet == NULL)) { 299 if (unlikely(new_packet == NULL)) {
296 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, not enough " 300 DCCP_WARN("%s, sk=%p, not enough mem to add to history,"
297 "mem to add to history, send refused\n", 301 "send refused\n", dccp_role(sk), sk);
298 __FUNCTION__, dccp_role(sk), sk); 302 return -ENOBUFS;
299 goto out;
300 } 303 }
301 304
302 dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); 305 dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet);
@@ -311,123 +314,94 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
311 hctx->ccid3hctx_last_win_count = 0; 314 hctx->ccid3hctx_last_win_count = 0;
312 hctx->ccid3hctx_t_last_win_count = now; 315 hctx->ccid3hctx_t_last_win_count = now;
313 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK); 316 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
314 hctx->ccid3hctx_t_ipi = TFRC_INITIAL_IPI;
315 317
316 /* Set nominal send time for initial packet */ 318 /* Set initial sending rate to 1 packet per second */
319 ccid3_hc_tx_update_s(hctx, skb->len);
320 hctx->ccid3hctx_x = hctx->ccid3hctx_s;
321
322 /* First timeout, according to [RFC 3448, 4.2], is 1 second */
323 hctx->ccid3hctx_t_ipi = USEC_PER_SEC;
324 /* Initial delta: minimum of 0.5 sec and t_gran/2 */
325 hctx->ccid3hctx_delta = TFRC_OPSYS_HALF_TIME_GRAN;
326
327 /* Set t_0 for initial packet */
317 hctx->ccid3hctx_t_nom = now; 328 hctx->ccid3hctx_t_nom = now;
318 timeval_add_usecs(&hctx->ccid3hctx_t_nom,
319 hctx->ccid3hctx_t_ipi);
320 ccid3_calc_new_delta(hctx);
321 rc = 0;
322 break; 329 break;
323 case TFRC_SSTATE_NO_FBACK: 330 case TFRC_SSTATE_NO_FBACK:
324 case TFRC_SSTATE_FBACK: 331 case TFRC_SSTATE_FBACK:
325 delay = (timeval_delta(&now, &hctx->ccid3hctx_t_nom) - 332 delay = timeval_delta(&hctx->ccid3hctx_t_nom, &now);
326 hctx->ccid3hctx_delta); 333 /*
327 delay /= -1000; 334 * Scheduling of packet transmissions [RFC 3448, 4.6]
328 /* divide by -1000 is to convert to ms and get sign right */ 335 *
329 rc = delay > 0 ? delay : 0; 336 * if (t_now > t_nom - delta)
330 break; 337 * // send the packet now
331 default: 338 * else
332 printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", 339 * // send the packet in (t_nom - t_now) milliseconds.
333 __FUNCTION__, dccp_role(sk), sk, hctx->ccid3hctx_state); 340 */
334 dump_stack(); 341 if (delay >= hctx->ccid3hctx_delta)
335 rc = -EINVAL; 342 return delay / 1000L;
336 break; 343 break;
344 case TFRC_SSTATE_TERM:
345 DCCP_BUG("Illegal %s state TERM, sk=%p", dccp_role(sk), sk);
346 return -EINVAL;
337 } 347 }
338 348
339 /* Can we send? if so add options and add to packet history */ 349 /* prepare to send now (add options etc.) */
340 if (rc == 0) { 350 dp->dccps_hc_tx_insert_options = 1;
341 dp->dccps_hc_tx_insert_options = 1; 351 new_packet->dccphtx_ccval = DCCP_SKB_CB(skb)->dccpd_ccval =
342 new_packet->dccphtx_ccval = 352 hctx->ccid3hctx_last_win_count;
343 DCCP_SKB_CB(skb)->dccpd_ccval = 353 timeval_add_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi);
344 hctx->ccid3hctx_last_win_count; 354
345 timeval_add_usecs(&hctx->ccid3hctx_t_nom, 355 return 0;
346 hctx->ccid3hctx_t_ipi);
347 }
348out:
349 return rc;
350} 356}
351 357
352static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) 358static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
353{ 359{
354 const struct dccp_sock *dp = dccp_sk(sk); 360 const struct dccp_sock *dp = dccp_sk(sk);
355 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 361 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
356 struct timeval now; 362 struct timeval now;
363 unsigned long quarter_rtt;
364 struct dccp_tx_hist_entry *packet;
357 365
358 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); 366 BUG_ON(hctx == NULL);
359 367
360 dccp_timestamp(sk, &now); 368 dccp_timestamp(sk, &now);
361 369
362 /* check if we have sent a data packet */ 370 ccid3_hc_tx_update_s(hctx, len);
363 if (len > 0) {
364 unsigned long quarter_rtt;
365 struct dccp_tx_hist_entry *packet;
366 371
367 packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); 372 packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
368 if (unlikely(packet == NULL)) { 373 if (unlikely(packet == NULL)) {
369 LIMIT_NETDEBUG(KERN_WARNING "%s: packet doesn't " 374 DCCP_WARN("packet doesn't exist in history!\n");
370 "exists in history!\n", __FUNCTION__);
371 return;
372 }
373 if (unlikely(packet->dccphtx_sent)) {
374 LIMIT_NETDEBUG(KERN_WARNING "%s: no unsent packet in "
375 "history!\n", __FUNCTION__);
376 return;
377 }
378 packet->dccphtx_tstamp = now;
379 packet->dccphtx_seqno = dp->dccps_gss;
380 /*
381 * Check if win_count have changed
382 * Algorithm in "8.1. Window Counter Value" in RFC 4342.
383 */
384 quarter_rtt = timeval_delta(&now, &hctx->ccid3hctx_t_last_win_count);
385 if (likely(hctx->ccid3hctx_rtt > 8))
386 quarter_rtt /= hctx->ccid3hctx_rtt / 4;
387
388 if (quarter_rtt > 0) {
389 hctx->ccid3hctx_t_last_win_count = now;
390 hctx->ccid3hctx_last_win_count = (hctx->ccid3hctx_last_win_count +
391 min_t(unsigned long, quarter_rtt, 5)) % 16;
392 ccid3_pr_debug("%s, sk=%p, window changed from "
393 "%u to %u!\n",
394 dccp_role(sk), sk,
395 packet->dccphtx_ccval,
396 hctx->ccid3hctx_last_win_count);
397 }
398
399 hctx->ccid3hctx_idle = 0;
400 packet->dccphtx_rtt = hctx->ccid3hctx_rtt;
401 packet->dccphtx_sent = 1;
402 } else
403 ccid3_pr_debug("%s, sk=%p, seqno=%llu NOT inserted!\n",
404 dccp_role(sk), sk, dp->dccps_gss);
405
406 switch (hctx->ccid3hctx_state) {
407 case TFRC_SSTATE_NO_SENT:
408 /* if first wasn't pure ack */
409 if (len != 0)
410 printk(KERN_CRIT "%s: %s, First packet sent is noted "
411 "as a data packet\n",
412 __FUNCTION__, dccp_role(sk));
413 return; 375 return;
414 case TFRC_SSTATE_NO_FBACK:
415 case TFRC_SSTATE_FBACK:
416 if (len > 0) {
417 timeval_sub_usecs(&hctx->ccid3hctx_t_nom,
418 hctx->ccid3hctx_t_ipi);
419 ccid3_calc_new_t_ipi(hctx);
420 ccid3_calc_new_delta(hctx);
421 timeval_add_usecs(&hctx->ccid3hctx_t_nom,
422 hctx->ccid3hctx_t_ipi);
423 }
424 break;
425 default:
426 printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n",
427 __FUNCTION__, dccp_role(sk), sk, hctx->ccid3hctx_state);
428 dump_stack();
429 break;
430 } 376 }
377 if (unlikely(packet->dccphtx_sent)) {
378 DCCP_WARN("no unsent packet in history!\n");
379 return;
380 }
381 packet->dccphtx_tstamp = now;
382 packet->dccphtx_seqno = dp->dccps_gss;
383 /*
384 * Check if win_count have changed
385 * Algorithm in "8.1. Window Counter Value" in RFC 4342.
386 */
387 quarter_rtt = timeval_delta(&now, &hctx->ccid3hctx_t_last_win_count);
388 if (likely(hctx->ccid3hctx_rtt > 8))
389 quarter_rtt /= hctx->ccid3hctx_rtt / 4;
390
391 if (quarter_rtt > 0) {
392 hctx->ccid3hctx_t_last_win_count = now;
393 hctx->ccid3hctx_last_win_count = (hctx->ccid3hctx_last_win_count +
394 min_t(unsigned long, quarter_rtt, 5)) % 16;
395 ccid3_pr_debug("%s, sk=%p, window changed from "
396 "%u to %u!\n",
397 dccp_role(sk), sk,
398 packet->dccphtx_ccval,
399 hctx->ccid3hctx_last_win_count);
400 }
401
402 hctx->ccid3hctx_idle = 0;
403 packet->dccphtx_rtt = hctx->ccid3hctx_rtt;
404 packet->dccphtx_sent = 1;
431} 405}
432 406
433static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) 407static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
@@ -437,13 +411,13 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
437 struct ccid3_options_received *opt_recv; 411 struct ccid3_options_received *opt_recv;
438 struct dccp_tx_hist_entry *packet; 412 struct dccp_tx_hist_entry *packet;
439 struct timeval now; 413 struct timeval now;
440 unsigned long next_tmout; 414 unsigned long t_nfb;
441 u32 t_elapsed; 415 u32 t_elapsed;
442 u32 pinv; 416 u32 pinv;
443 u32 x_recv; 417 u32 x_recv;
444 u32 r_sample; 418 u32 r_sample;
445 419
446 BUG_ON(hctx == NULL || hctx->ccid3hctx_state == TFRC_SSTATE_TERM); 420 BUG_ON(hctx == NULL);
447 421
448 /* we are only interested in ACKs */ 422 /* we are only interested in ACKs */
449 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK || 423 if (!(DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK ||
@@ -457,9 +431,6 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
457 pinv = opt_recv->ccid3or_loss_event_rate; 431 pinv = opt_recv->ccid3or_loss_event_rate;
458 432
459 switch (hctx->ccid3hctx_state) { 433 switch (hctx->ccid3hctx_state) {
460 case TFRC_SSTATE_NO_SENT:
461 /* FIXME: what to do here? */
462 return;
463 case TFRC_SSTATE_NO_FBACK: 434 case TFRC_SSTATE_NO_FBACK:
464 case TFRC_SSTATE_FBACK: 435 case TFRC_SSTATE_FBACK:
465 /* Calculate new round trip sample by 436 /* Calculate new round trip sample by
@@ -468,11 +439,10 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
468 packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist, 439 packet = dccp_tx_hist_find_entry(&hctx->ccid3hctx_hist,
469 DCCP_SKB_CB(skb)->dccpd_ack_seq); 440 DCCP_SKB_CB(skb)->dccpd_ack_seq);
470 if (unlikely(packet == NULL)) { 441 if (unlikely(packet == NULL)) {
471 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, seqno " 442 DCCP_WARN("%s, sk=%p, seqno %llu(%s) does't exist "
472 "%llu(%s) does't exist in history!\n", 443 "in history!\n", dccp_role(sk), sk,
473 __FUNCTION__, dccp_role(sk), sk,
474 (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq, 444 (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq,
475 dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type)); 445 dccp_packet_name(DCCP_SKB_CB(skb)->dccpd_type));
476 return; 446 return;
477 } 447 }
478 448
@@ -480,9 +450,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
480 dccp_timestamp(sk, &now); 450 dccp_timestamp(sk, &now);
481 r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); 451 r_sample = timeval_delta(&now, &packet->dccphtx_tstamp);
482 if (unlikely(r_sample <= t_elapsed)) 452 if (unlikely(r_sample <= t_elapsed))
483 LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, " 453 DCCP_WARN("r_sample=%uus,t_elapsed=%uus\n",
484 "t_elapsed=%uus\n", 454 r_sample, t_elapsed);
485 __FUNCTION__, r_sample, t_elapsed);
486 else 455 else
487 r_sample -= t_elapsed; 456 r_sample -= t_elapsed;
488 457
@@ -495,20 +464,26 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
495 * q is a constant, RFC 3448 recomments 0.9 464 * q is a constant, RFC 3448 recomments 0.9
496 */ 465 */
497 if (hctx->ccid3hctx_state == TFRC_SSTATE_NO_FBACK) { 466 if (hctx->ccid3hctx_state == TFRC_SSTATE_NO_FBACK) {
467 /* Use Larger Initial Windows [RFC 4342, sec. 5]
468 * We deviate in that we use `s' instead of `MSS'. */
469 u16 w_init = max( 4 * hctx->ccid3hctx_s,
470 max(2 * hctx->ccid3hctx_s, 4380));
471 hctx->ccid3hctx_rtt = r_sample;
472 hctx->ccid3hctx_x = usecs_div(w_init, r_sample);
473 hctx->ccid3hctx_t_ld = now;
474
475 ccid3_update_send_time(hctx);
498 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK); 476 ccid3_hc_tx_set_state(sk, TFRC_SSTATE_FBACK);
499 hctx->ccid3hctx_rtt = r_sample; 477 } else {
500 } else
501 hctx->ccid3hctx_rtt = (hctx->ccid3hctx_rtt * 9) / 10 + 478 hctx->ccid3hctx_rtt = (hctx->ccid3hctx_rtt * 9) / 10 +
502 r_sample / 10; 479 r_sample / 10;
480 ccid3_hc_tx_update_x(sk, &now);
481 }
503 482
504 ccid3_pr_debug("%s, sk=%p, New RTT estimate=%uus, " 483 ccid3_pr_debug("%s, sk=%p, New RTT estimate=%uus, "
505 "r_sample=%us\n", dccp_role(sk), sk, 484 "r_sample=%us\n", dccp_role(sk), sk,
506 hctx->ccid3hctx_rtt, r_sample); 485 hctx->ccid3hctx_rtt, r_sample);
507 486
508 /* Update timeout interval */
509 hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt,
510 USEC_PER_SEC);
511
512 /* Update receive rate */ 487 /* Update receive rate */
513 hctx->ccid3hctx_x_recv = x_recv;/* X_recv in bytes per sec */ 488 hctx->ccid3hctx_x_recv = x_recv;/* X_recv in bytes per sec */
514 489
@@ -528,49 +503,41 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
528 /* unschedule no feedback timer */ 503 /* unschedule no feedback timer */
529 sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer); 504 sk_stop_timer(sk, &hctx->ccid3hctx_no_feedback_timer);
530 505
531 /* Update sending rate */
532 ccid3_hc_tx_update_x(sk);
533
534 /* Update next send time */
535 timeval_sub_usecs(&hctx->ccid3hctx_t_nom,
536 hctx->ccid3hctx_t_ipi);
537 ccid3_calc_new_t_ipi(hctx);
538 timeval_add_usecs(&hctx->ccid3hctx_t_nom,
539 hctx->ccid3hctx_t_ipi);
540 ccid3_calc_new_delta(hctx);
541
542 /* remove all packets older than the one acked from history */ 506 /* remove all packets older than the one acked from history */
543 dccp_tx_hist_purge_older(ccid3_tx_hist, 507 dccp_tx_hist_purge_older(ccid3_tx_hist,
544 &hctx->ccid3hctx_hist, packet); 508 &hctx->ccid3hctx_hist, packet);
545 /* 509 /*
546 * As we have calculated new ipi, delta, t_nom it is possible that 510 * As we have calculated new ipi, delta, t_nom it is possible that
547 * we now can send a packet, so wake up dccp_wait_for_ccids. 511 * we now can send a packet, so wake up dccp_wait_for_ccid
548 */ 512 */
549 sk->sk_write_space(sk); 513 sk->sk_write_space(sk);
550 514
515 /* Update timeout interval. We use the alternative variant of
516 * [RFC 3448, 3.1] which sets the upper bound of t_rto to one
517 * second, as it is suggested for TCP (see RFC 2988, 2.4). */
518 hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt,
519 USEC_PER_SEC );
551 /* 520 /*
552 * Schedule no feedback timer to expire in 521 * Schedule no feedback timer to expire in
553 * max(4 * R, 2 * s / X) 522 * max(4 * R, 2 * s/X) = max(4 * R, 2 * t_ipi)
554 */ 523 */
555 next_tmout = max(hctx->ccid3hctx_t_rto, 524 t_nfb = max(4 * hctx->ccid3hctx_rtt, 2 * hctx->ccid3hctx_t_ipi);
556 2 * usecs_div(hctx->ccid3hctx_s,
557 hctx->ccid3hctx_x));
558 525
559 ccid3_pr_debug("%s, sk=%p, Scheduled no feedback timer to " 526 ccid3_pr_debug("%s, sk=%p, Scheduled no feedback timer to "
560 "expire in %lu jiffies (%luus)\n", 527 "expire in %lu jiffies (%luus)\n",
561 dccp_role(sk), sk, 528 dccp_role(sk), sk,
562 usecs_to_jiffies(next_tmout), next_tmout); 529 usecs_to_jiffies(t_nfb), t_nfb);
563 530
564 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer, 531 sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
565 jiffies + max_t(u32, 1, usecs_to_jiffies(next_tmout))); 532 jiffies + usecs_to_jiffies(t_nfb));
566 533
567 /* set idle flag */ 534 /* set idle flag */
568 hctx->ccid3hctx_idle = 1; 535 hctx->ccid3hctx_idle = 1;
569 break; 536 break;
570 default: 537 case TFRC_SSTATE_NO_SENT:
571 printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", 538 DCCP_WARN("Illegal ACK received - no packet has been sent\n");
572 __FUNCTION__, dccp_role(sk), sk, hctx->ccid3hctx_state); 539 /* fall through */
573 dump_stack(); 540 case TFRC_SSTATE_TERM: /* ignore feedback when closing */
574 break; 541 break;
575 } 542 }
576} 543}
@@ -610,9 +577,9 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
610 switch (option) { 577 switch (option) {
611 case TFRC_OPT_LOSS_EVENT_RATE: 578 case TFRC_OPT_LOSS_EVENT_RATE:
612 if (unlikely(len != 4)) { 579 if (unlikely(len != 4)) {
613 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid " 580 DCCP_WARN("%s, sk=%p, invalid len %d "
614 "len for TFRC_OPT_LOSS_EVENT_RATE\n", 581 "for TFRC_OPT_LOSS_EVENT_RATE\n",
615 __FUNCTION__, dccp_role(sk), sk); 582 dccp_role(sk), sk, len);
616 rc = -EINVAL; 583 rc = -EINVAL;
617 } else { 584 } else {
618 opt_recv->ccid3or_loss_event_rate = ntohl(*(__be32 *)value); 585 opt_recv->ccid3or_loss_event_rate = ntohl(*(__be32 *)value);
@@ -631,9 +598,9 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
631 break; 598 break;
632 case TFRC_OPT_RECEIVE_RATE: 599 case TFRC_OPT_RECEIVE_RATE:
633 if (unlikely(len != 4)) { 600 if (unlikely(len != 4)) {
634 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, invalid " 601 DCCP_WARN("%s, sk=%p, invalid len %d "
635 "len for TFRC_OPT_RECEIVE_RATE\n", 602 "for TFRC_OPT_RECEIVE_RATE\n",
636 __FUNCTION__, dccp_role(sk), sk); 603 dccp_role(sk), sk, len);
637 rc = -EINVAL; 604 rc = -EINVAL;
638 } else { 605 } else {
639 opt_recv->ccid3or_receive_rate = ntohl(*(__be32 *)value); 606 opt_recv->ccid3or_receive_rate = ntohl(*(__be32 *)value);
@@ -649,18 +616,9 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
649 616
650static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk) 617static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
651{ 618{
652 struct dccp_sock *dp = dccp_sk(sk);
653 struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid); 619 struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid);
654 620
655 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && 621 hctx->ccid3hctx_s = 0;
656 dp->dccps_packet_size <= TFRC_MAX_PACKET_SIZE)
657 hctx->ccid3hctx_s = dp->dccps_packet_size;
658 else
659 hctx->ccid3hctx_s = TFRC_STD_PACKET_SIZE;
660
661 /* Set transmission rate to 1 packet per second */
662 hctx->ccid3hctx_x = hctx->ccid3hctx_s;
663 hctx->ccid3hctx_t_rto = USEC_PER_SEC;
664 hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT; 622 hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT;
665 INIT_LIST_HEAD(&hctx->ccid3hctx_hist); 623 INIT_LIST_HEAD(&hctx->ccid3hctx_hist);
666 624
@@ -688,14 +646,7 @@ static void ccid3_hc_tx_exit(struct sock *sk)
688 * RX Half Connection methods 646 * RX Half Connection methods
689 */ 647 */
690 648
691/* TFRC receiver states */ 649#ifdef CONFIG_IP_DCCP_CCID3_DEBUG
692enum ccid3_hc_rx_states {
693 TFRC_RSTATE_NO_DATA = 1,
694 TFRC_RSTATE_DATA,
695 TFRC_RSTATE_TERM = 127,
696};
697
698#ifdef CCID3_DEBUG
699static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) 650static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state)
700{ 651{
701 static char *ccid3_rx_state_names[] = { 652 static char *ccid3_rx_state_names[] = {
@@ -721,6 +672,15 @@ static void ccid3_hc_rx_set_state(struct sock *sk,
721 hcrx->ccid3hcrx_state = state; 672 hcrx->ccid3hcrx_state = state;
722} 673}
723 674
675static inline void ccid3_hc_rx_update_s(struct ccid3_hc_rx_sock *hcrx, int len)
676{
677 if (unlikely(len == 0)) /* don't update on empty packets (e.g. ACKs) */
678 ccid3_pr_debug("Packet payload length is 0 - not updating\n");
679 else
680 hcrx->ccid3hcrx_s = hcrx->ccid3hcrx_s == 0 ? len :
681 (9 * hcrx->ccid3hcrx_s + len) / 10;
682}
683
724static void ccid3_hc_rx_send_feedback(struct sock *sk) 684static void ccid3_hc_rx_send_feedback(struct sock *sk)
725{ 685{
726 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); 686 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
@@ -743,18 +703,15 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
743 delta); 703 delta);
744 } 704 }
745 break; 705 break;
746 default: 706 case TFRC_RSTATE_TERM:
747 printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", 707 DCCP_BUG("Illegal %s state TERM, sk=%p", dccp_role(sk), sk);
748 __FUNCTION__, dccp_role(sk), sk, hcrx->ccid3hcrx_state);
749 dump_stack();
750 return; 708 return;
751 } 709 }
752 710
753 packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist); 711 packet = dccp_rx_hist_find_data_packet(&hcrx->ccid3hcrx_hist);
754 if (unlikely(packet == NULL)) { 712 if (unlikely(packet == NULL)) {
755 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, no data packet " 713 DCCP_WARN("%s, sk=%p, no data packet in history!\n",
756 "in history!\n", 714 dccp_role(sk), sk);
757 __FUNCTION__, dccp_role(sk), sk);
758 return; 715 return;
759 } 716 }
760 717
@@ -842,29 +799,29 @@ static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
842 } 799 }
843 800
844 if (unlikely(step == 0)) { 801 if (unlikely(step == 0)) {
845 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, packet history " 802 DCCP_WARN("%s, sk=%p, packet history has no data packets!\n",
846 "contains no data packets!\n", 803 dccp_role(sk), sk);
847 __FUNCTION__, dccp_role(sk), sk);
848 return ~0; 804 return ~0;
849 } 805 }
850 806
851 if (unlikely(interval == 0)) { 807 if (unlikely(interval == 0)) {
852 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Could not find a " 808 DCCP_WARN("%s, sk=%p, Could not find a win_count interval > 0."
853 "win_count interval > 0. Defaulting to 1\n", 809 "Defaulting to 1\n", dccp_role(sk), sk);
854 __FUNCTION__, dccp_role(sk), sk);
855 interval = 1; 810 interval = 1;
856 } 811 }
857found: 812found:
858 if (!tail) { 813 if (!tail) {
859 LIMIT_NETDEBUG(KERN_WARNING "%s: tail is null\n", 814 DCCP_CRIT("tail is null\n");
860 __FUNCTION__);
861 return ~0; 815 return ~0;
862 } 816 }
863 rtt = timeval_delta(&tstamp, &tail->dccphrx_tstamp) * 4 / interval; 817 rtt = timeval_delta(&tstamp, &tail->dccphrx_tstamp) * 4 / interval;
864 ccid3_pr_debug("%s, sk=%p, approximated RTT to %uus\n", 818 ccid3_pr_debug("%s, sk=%p, approximated RTT to %uus\n",
865 dccp_role(sk), sk, rtt); 819 dccp_role(sk), sk, rtt);
866 if (rtt == 0) 820
867 rtt = 1; 821 if (rtt == 0) {
822 DCCP_WARN("RTT==0, setting to 1\n");
823 rtt = 1;
824 }
868 825
869 dccp_timestamp(sk, &tstamp); 826 dccp_timestamp(sk, &tstamp);
870 delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback); 827 delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback);
@@ -878,9 +835,7 @@ found:
878 tmp2 = (u32)tmp1; 835 tmp2 = (u32)tmp1;
879 836
880 if (!tmp2) { 837 if (!tmp2) {
881 LIMIT_NETDEBUG(KERN_WARNING "tmp2 = 0 " 838 DCCP_CRIT("tmp2 = 0, x_recv = %u, rtt =%u\n", x_recv, rtt);
882 "%s: x_recv = %u, rtt =%u\n",
883 __FUNCTION__, x_recv, rtt);
884 return ~0; 839 return ~0;
885 } 840 }
886 841
@@ -926,8 +881,7 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
926 entry = dccp_li_hist_entry_new(ccid3_li_hist, SLAB_ATOMIC); 881 entry = dccp_li_hist_entry_new(ccid3_li_hist, SLAB_ATOMIC);
927 882
928 if (entry == NULL) { 883 if (entry == NULL) {
929 printk(KERN_CRIT "%s: out of memory\n",__FUNCTION__); 884 DCCP_BUG("out of memory - can not allocate entry");
930 dump_stack();
931 return; 885 return;
932 } 886 }
933 887
@@ -1002,13 +956,10 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1002 const struct dccp_options_received *opt_recv; 956 const struct dccp_options_received *opt_recv;
1003 struct dccp_rx_hist_entry *packet; 957 struct dccp_rx_hist_entry *packet;
1004 struct timeval now; 958 struct timeval now;
1005 u8 win_count;
1006 u32 p_prev, rtt_prev, r_sample, t_elapsed; 959 u32 p_prev, rtt_prev, r_sample, t_elapsed;
1007 int loss; 960 int loss, payload_size;
1008 961
1009 BUG_ON(hcrx == NULL || 962 BUG_ON(hcrx == NULL);
1010 !(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA ||
1011 hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA));
1012 963
1013 opt_recv = &dccp_sk(sk)->dccps_options_received; 964 opt_recv = &dccp_sk(sk)->dccps_options_received;
1014 965
@@ -1026,9 +977,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1026 t_elapsed = opt_recv->dccpor_elapsed_time * 10; 977 t_elapsed = opt_recv->dccpor_elapsed_time * 10;
1027 978
1028 if (unlikely(r_sample <= t_elapsed)) 979 if (unlikely(r_sample <= t_elapsed))
1029 LIMIT_NETDEBUG(KERN_WARNING "%s: r_sample=%uus, " 980 DCCP_WARN("r_sample=%uus, t_elapsed=%uus\n",
1030 "t_elapsed=%uus\n", 981 r_sample, t_elapsed);
1031 __FUNCTION__, r_sample, t_elapsed);
1032 else 982 else
1033 r_sample -= t_elapsed; 983 r_sample -= t_elapsed;
1034 984
@@ -1052,19 +1002,19 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1052 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, 1002 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,
1053 skb, SLAB_ATOMIC); 1003 skb, SLAB_ATOMIC);
1054 if (unlikely(packet == NULL)) { 1004 if (unlikely(packet == NULL)) {
1055 LIMIT_NETDEBUG(KERN_WARNING "%s: %s, sk=%p, Not enough mem to " 1005 DCCP_WARN("%s, sk=%p, Not enough mem to add rx packet "
1056 "add rx packet to history, consider it lost!\n", 1006 "to history, consider it lost!\n", dccp_role(sk), sk);
1057 __FUNCTION__, dccp_role(sk), sk);
1058 return; 1007 return;
1059 } 1008 }
1060 1009
1061 win_count = packet->dccphrx_ccval;
1062
1063 loss = ccid3_hc_rx_detect_loss(sk, packet); 1010 loss = ccid3_hc_rx_detect_loss(sk, packet);
1064 1011
1065 if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK) 1012 if (DCCP_SKB_CB(skb)->dccpd_type == DCCP_PKT_ACK)
1066 return; 1013 return;
1067 1014
1015 payload_size = skb->len - dccp_hdr(skb)->dccph_doff * 4;
1016 ccid3_hc_rx_update_s(hcrx, payload_size);
1017
1068 switch (hcrx->ccid3hcrx_state) { 1018 switch (hcrx->ccid3hcrx_state) {
1069 case TFRC_RSTATE_NO_DATA: 1019 case TFRC_RSTATE_NO_DATA:
1070 ccid3_pr_debug("%s, sk=%p(%s), skb=%p, sending initial " 1020 ccid3_pr_debug("%s, sk=%p(%s), skb=%p, sending initial "
@@ -1075,8 +1025,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1075 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA); 1025 ccid3_hc_rx_set_state(sk, TFRC_RSTATE_DATA);
1076 return; 1026 return;
1077 case TFRC_RSTATE_DATA: 1027 case TFRC_RSTATE_DATA:
1078 hcrx->ccid3hcrx_bytes_recv += skb->len - 1028 hcrx->ccid3hcrx_bytes_recv += payload_size;
1079 dccp_hdr(skb)->dccph_doff * 4;
1080 if (loss) 1029 if (loss)
1081 break; 1030 break;
1082 1031
@@ -1087,10 +1036,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1087 ccid3_hc_rx_send_feedback(sk); 1036 ccid3_hc_rx_send_feedback(sk);
1088 } 1037 }
1089 return; 1038 return;
1090 default: 1039 case TFRC_RSTATE_TERM:
1091 printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", 1040 DCCP_BUG("Illegal %s state TERM, sk=%p", dccp_role(sk), sk);
1092 __FUNCTION__, dccp_role(sk), sk, hcrx->ccid3hcrx_state);
1093 dump_stack();
1094 return; 1041 return;
1095 } 1042 }
1096 1043
@@ -1107,10 +1054,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1107 /* Scaling up by 1000000 as fixed decimal */ 1054 /* Scaling up by 1000000 as fixed decimal */
1108 if (i_mean != 0) 1055 if (i_mean != 0)
1109 hcrx->ccid3hcrx_p = 1000000 / i_mean; 1056 hcrx->ccid3hcrx_p = 1000000 / i_mean;
1110 } else { 1057 } else
1111 printk(KERN_CRIT "%s: empty loss hist\n",__FUNCTION__); 1058 DCCP_BUG("empty loss history");
1112 dump_stack();
1113 }
1114 1059
1115 if (hcrx->ccid3hcrx_p > p_prev) { 1060 if (hcrx->ccid3hcrx_p > p_prev) {
1116 ccid3_hc_rx_send_feedback(sk); 1061 ccid3_hc_rx_send_feedback(sk);
@@ -1120,22 +1065,16 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1120 1065
1121static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk) 1066static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
1122{ 1067{
1123 struct dccp_sock *dp = dccp_sk(sk);
1124 struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid); 1068 struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid);
1125 1069
1126 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 1070 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
1127 1071
1128 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
1129 dp->dccps_packet_size <= TFRC_MAX_PACKET_SIZE)
1130 hcrx->ccid3hcrx_s = dp->dccps_packet_size;
1131 else
1132 hcrx->ccid3hcrx_s = TFRC_STD_PACKET_SIZE;
1133
1134 hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; 1072 hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA;
1135 INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); 1073 INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist);
1136 INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); 1074 INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist);
1137 dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack); 1075 dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack);
1138 hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; 1076 hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack;
1077 hcrx->ccid3hcrx_s = 0;
1139 hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ 1078 hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */
1140 return 0; 1079 return 0;
1141} 1080}
@@ -1261,8 +1200,10 @@ static struct ccid_operations ccid3 = {
1261 .ccid_hc_tx_getsockopt = ccid3_hc_tx_getsockopt, 1200 .ccid_hc_tx_getsockopt = ccid3_hc_tx_getsockopt,
1262}; 1201};
1263 1202
1203#ifdef CONFIG_IP_DCCP_CCID3_DEBUG
1264module_param(ccid3_debug, int, 0444); 1204module_param(ccid3_debug, int, 0444);
1265MODULE_PARM_DESC(ccid3_debug, "Enable debug messages"); 1205MODULE_PARM_DESC(ccid3_debug, "Enable debug messages");
1206#endif
1266 1207
1267static __init int ccid3_module_init(void) 1208static __init int ccid3_module_init(void)
1268{ 1209{
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index 0a2cb7536d26..27cb20ae1da8 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -42,20 +42,14 @@
42#include <linux/tfrc.h> 42#include <linux/tfrc.h>
43#include "../ccid.h" 43#include "../ccid.h"
44 44
45#define TFRC_MIN_PACKET_SIZE 16 45/* Two seconds as per RFC 3448 4.2 */
46#define TFRC_STD_PACKET_SIZE 256
47#define TFRC_MAX_PACKET_SIZE 65535
48
49/* Two seconds as per CCID3 spec */
50#define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC) 46#define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC)
51 47
52#define TFRC_INITIAL_IPI (USEC_PER_SEC / 4)
53
54/* In usecs - half the scheduling granularity as per RFC3448 4.6 */ 48/* In usecs - half the scheduling granularity as per RFC3448 4.6 */
55#define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ)) 49#define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ))
56 50
57/* In seconds */ 51/* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */
58#define TFRC_MAX_BACK_OFF_TIME 64 52#define TFRC_T_MBI 64
59 53
60#define TFRC_SMALLEST_P 40 54#define TFRC_SMALLEST_P 40
61 55
@@ -73,26 +67,36 @@ struct ccid3_options_received {
73 u32 ccid3or_receive_rate; 67 u32 ccid3or_receive_rate;
74}; 68};
75 69
76/** struct ccid3_hc_tx_sock - CCID3 sender half connection sock 70/* TFRC sender states */
71enum ccid3_hc_tx_states {
72 TFRC_SSTATE_NO_SENT = 1,
73 TFRC_SSTATE_NO_FBACK,
74 TFRC_SSTATE_FBACK,
75 TFRC_SSTATE_TERM,
76};
77
78/** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket
77 * 79 *
78 * @ccid3hctx_state - Sender state 80 * @ccid3hctx_x - Current sending rate
79 * @ccid3hctx_x - Current sending rate 81 * @ccid3hctx_x_recv - Receive rate
80 * @ccid3hctx_x_recv - Receive rate 82 * @ccid3hctx_x_calc - Calculated send rate (RFC 3448, 3.1)
81 * @ccid3hctx_x_calc - Calculated send (?) rate 83 * @ccid3hctx_rtt - Estimate of current round trip time in usecs
82 * @ccid3hctx_s - Packet size 84 * @ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000
83 * @ccid3hctx_rtt - Estimate of current round trip time in usecs 85 * @ccid3hctx_s - Packet size
84 * @@ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000 86 * @ccid3hctx_t_rto - Retransmission Timeout (RFC 3448, 3.1)
85 * @ccid3hctx_last_win_count - Last window counter sent 87 * @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6)
86 * @ccid3hctx_t_last_win_count - Timestamp of earliest packet 88 * @ccid3hctx_state - Sender state, one of %ccid3_hc_tx_states
87 * with last_win_count value sent 89 * @ccid3hctx_last_win_count - Last window counter sent
88 * @ccid3hctx_no_feedback_timer - Handle to no feedback timer 90 * @ccid3hctx_t_last_win_count - Timestamp of earliest packet
89 * @ccid3hctx_idle - FIXME 91 * with last_win_count value sent
90 * @ccid3hctx_t_ld - Time last doubled during slow start 92 * @ccid3hctx_no_feedback_timer - Handle to no feedback timer
91 * @ccid3hctx_t_nom - Nominal send time of next packet 93 * @ccid3hctx_idle - Flag indicating that sender is idling
92 * @ccid3hctx_t_ipi - Interpacket (send) interval 94 * @ccid3hctx_t_ld - Time last doubled during slow start
93 * @ccid3hctx_delta - Send timer delta 95 * @ccid3hctx_t_nom - Nominal send time of next packet
94 * @ccid3hctx_hist - Packet history 96 * @ccid3hctx_delta - Send timer delta
95 */ 97 * @ccid3hctx_hist - Packet history
98 * @ccid3hctx_options_received - Parsed set of retrieved options
99 */
96struct ccid3_hc_tx_sock { 100struct ccid3_hc_tx_sock {
97 struct tfrc_tx_info ccid3hctx_tfrc; 101 struct tfrc_tx_info ccid3hctx_tfrc;
98#define ccid3hctx_x ccid3hctx_tfrc.tfrctx_x 102#define ccid3hctx_x ccid3hctx_tfrc.tfrctx_x
@@ -103,7 +107,7 @@ struct ccid3_hc_tx_sock {
103#define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto 107#define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto
104#define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi 108#define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi
105 u16 ccid3hctx_s; 109 u16 ccid3hctx_s;
106 u8 ccid3hctx_state; 110 enum ccid3_hc_tx_states ccid3hctx_state:8;
107 u8 ccid3hctx_last_win_count; 111 u8 ccid3hctx_last_win_count;
108 u8 ccid3hctx_idle; 112 u8 ccid3hctx_idle;
109 struct timeval ccid3hctx_t_last_win_count; 113 struct timeval ccid3hctx_t_last_win_count;
@@ -115,23 +119,48 @@ struct ccid3_hc_tx_sock {
115 struct ccid3_options_received ccid3hctx_options_received; 119 struct ccid3_options_received ccid3hctx_options_received;
116}; 120};
117 121
122/* TFRC receiver states */
123enum ccid3_hc_rx_states {
124 TFRC_RSTATE_NO_DATA = 1,
125 TFRC_RSTATE_DATA,
126 TFRC_RSTATE_TERM = 127,
127};
128
129/** struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket
130 *
131 * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3)
132 * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard)
133 * @ccid3hcrx_p - current loss event rate (RFC 3448 5.4)
134 * @ccid3hcrx_seqno_nonloss - Last received non-loss sequence number
135 * @ccid3hcrx_ccval_nonloss - Last received non-loss Window CCVal
136 * @ccid3hcrx_ccval_last_counter - Tracks window counter (RFC 4342, 8.1)
137 * @ccid3hcrx_state - receiver state, one of %ccid3_hc_rx_states
138 * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes
139 * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent
140 * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent
141 * @ccid3hcrx_hist - Packet history
142 * @ccid3hcrx_li_hist - Loss Interval History
143 * @ccid3hcrx_s - Received packet size in bytes
144 * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5)
145 * @ccid3hcrx_elapsed_time - Time since packet reception
146 */
118struct ccid3_hc_rx_sock { 147struct ccid3_hc_rx_sock {
119 struct tfrc_rx_info ccid3hcrx_tfrc; 148 struct tfrc_rx_info ccid3hcrx_tfrc;
120#define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv 149#define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv
121#define ccid3hcrx_rtt ccid3hcrx_tfrc.tfrcrx_rtt 150#define ccid3hcrx_rtt ccid3hcrx_tfrc.tfrcrx_rtt
122#define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p 151#define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p
123 u64 ccid3hcrx_seqno_nonloss:48, 152 u64 ccid3hcrx_seqno_nonloss:48,
124 ccid3hcrx_ccval_nonloss:4, 153 ccid3hcrx_ccval_nonloss:4,
125 ccid3hcrx_state:8, 154 ccid3hcrx_ccval_last_counter:4;
126 ccid3hcrx_ccval_last_counter:4; 155 enum ccid3_hc_rx_states ccid3hcrx_state:8;
127 u32 ccid3hcrx_bytes_recv; 156 u32 ccid3hcrx_bytes_recv;
128 struct timeval ccid3hcrx_tstamp_last_feedback; 157 struct timeval ccid3hcrx_tstamp_last_feedback;
129 struct timeval ccid3hcrx_tstamp_last_ack; 158 struct timeval ccid3hcrx_tstamp_last_ack;
130 struct list_head ccid3hcrx_hist; 159 struct list_head ccid3hcrx_hist;
131 struct list_head ccid3hcrx_li_hist; 160 struct list_head ccid3hcrx_li_hist;
132 u16 ccid3hcrx_s; 161 u16 ccid3hcrx_s;
133 u32 ccid3hcrx_pinv; 162 u32 ccid3hcrx_pinv;
134 u32 ccid3hcrx_elapsed_time; 163 u32 ccid3hcrx_elapsed_time;
135}; 164};
136 165
137static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) 166static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c
index 906c81ab9d4f..48b9b93f8acb 100644
--- a/net/dccp/ccids/lib/loss_interval.c
+++ b/net/dccp/ccids/lib/loss_interval.c
@@ -13,7 +13,7 @@
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <net/sock.h> 15#include <net/sock.h>
16 16#include "../../dccp.h"
17#include "loss_interval.h" 17#include "loss_interval.h"
18 18
19struct dccp_li_hist *dccp_li_hist_new(const char *name) 19struct dccp_li_hist *dccp_li_hist_new(const char *name)
@@ -109,7 +109,7 @@ u32 dccp_li_hist_calc_i_mean(struct list_head *list)
109 i_tot = max(i_tot0, i_tot1); 109 i_tot = max(i_tot0, i_tot1);
110 110
111 if (!w_tot) { 111 if (!w_tot) {
112 LIMIT_NETDEBUG(KERN_WARNING "%s: w_tot = 0\n", __FUNCTION__); 112 DCCP_WARN("w_tot = 0\n");
113 return 1; 113 return 1;
114 } 114 }
115 115
@@ -128,7 +128,7 @@ int dccp_li_hist_interval_new(struct dccp_li_hist *hist,
128 entry = dccp_li_hist_entry_new(hist, SLAB_ATOMIC); 128 entry = dccp_li_hist_entry_new(hist, SLAB_ATOMIC);
129 if (entry == NULL) { 129 if (entry == NULL) {
130 dccp_li_hist_purge(hist, list); 130 dccp_li_hist_purge(hist, list);
131 dump_stack(); 131 DCCP_BUG("loss interval list entry is NULL");
132 return 0; 132 return 0;
133 } 133 }
134 entry->dccplih_interval = ~0; 134 entry->dccplih_interval = ~0;
diff --git a/net/dccp/ccids/lib/tfrc_equation.c b/net/dccp/ccids/lib/tfrc_equation.c
index 44076e0c6591..2601012383fb 100644
--- a/net/dccp/ccids/lib/tfrc_equation.c
+++ b/net/dccp/ccids/lib/tfrc_equation.c
@@ -13,9 +13,8 @@
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16
17#include <asm/div64.h> 16#include <asm/div64.h>
18 17#include "../../dccp.h"
19#include "tfrc.h" 18#include "tfrc.h"
20 19
21#define TFRC_CALC_X_ARRSIZE 500 20#define TFRC_CALC_X_ARRSIZE 500
@@ -588,8 +587,10 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p)
588 /* p should be 0 unless there is a bug in my code */ 587 /* p should be 0 unless there is a bug in my code */
589 index = 0; 588 index = 0;
590 589
591 if (R == 0) 590 if (R == 0) {
591 DCCP_WARN("RTT==0, setting to 1\n");
592 R = 1; /* RTT can't be zero or else divide by zero */ 592 R = 1; /* RTT can't be zero or else divide by zero */
593 }
593 594
594 BUG_ON(index >= TFRC_CALC_X_ARRSIZE); 595 BUG_ON(index >= TFRC_CALC_X_ARRSIZE);
595 596
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 272e8584564e..68886986c8e4 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -18,15 +18,33 @@
18#include <net/tcp.h> 18#include <net/tcp.h>
19#include "ackvec.h" 19#include "ackvec.h"
20 20
21/*
22 * DCCP - specific warning and debugging macros.
23 */
24#define DCCP_WARN(fmt, a...) LIMIT_NETDEBUG(KERN_WARNING "%s: " fmt, \
25 __FUNCTION__, ##a)
26#define DCCP_CRIT(fmt, a...) printk(KERN_CRIT fmt " at %s:%d/%s()\n", ##a, \
27 __FILE__, __LINE__, __FUNCTION__)
28#define DCCP_BUG(a...) do { DCCP_CRIT("BUG: " a); dump_stack(); } while(0)
29#define DCCP_BUG_ON(cond) do { if (unlikely((cond) != 0)) \
30 DCCP_BUG("\"%s\" holds (exception!)", \
31 __stringify(cond)); \
32 } while (0)
33
34#ifdef MODULE
35#define DCCP_PRINTK(enable, fmt, args...) do { if (enable) \
36 printk(fmt, ##args); \
37 } while(0)
38#else
39#define DCCP_PRINTK(enable, fmt, args...) printk(fmt, ##args)
40#endif
41#define DCCP_PR_DEBUG(enable, fmt, a...) DCCP_PRINTK(enable, KERN_DEBUG \
42 "%s: " fmt, __FUNCTION__, ##a)
43
21#ifdef CONFIG_IP_DCCP_DEBUG 44#ifdef CONFIG_IP_DCCP_DEBUG
22extern int dccp_debug; 45extern int dccp_debug;
23 46#define dccp_pr_debug(format, a...) DCCP_PR_DEBUG(dccp_debug, format, ##a)
24#define dccp_pr_debug(format, a...) \ 47#define dccp_pr_debug_cat(format, a...) DCCP_PRINTK(dccp_debug, format, ##a)
25 do { if (dccp_debug) \
26 printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \
27 } while (0)
28#define dccp_pr_debug_cat(format, a...) do { if (dccp_debug) \
29 printk(format, ##a); } while (0)
30#else 48#else
31#define dccp_pr_debug(format, a...) 49#define dccp_pr_debug(format, a...)
32#define dccp_pr_debug_cat(format, a...) 50#define dccp_pr_debug_cat(format, a...)
@@ -35,17 +53,21 @@ extern int dccp_debug;
35extern struct inet_hashinfo dccp_hashinfo; 53extern struct inet_hashinfo dccp_hashinfo;
36 54
37extern atomic_t dccp_orphan_count; 55extern atomic_t dccp_orphan_count;
38extern int dccp_tw_count;
39extern void dccp_tw_deschedule(struct inet_timewait_sock *tw);
40 56
41extern void dccp_time_wait(struct sock *sk, int state, int timeo); 57extern void dccp_time_wait(struct sock *sk, int state, int timeo);
42 58
43/* FIXME: Right size this */ 59/*
44#define DCCP_MAX_OPT_LEN 128 60 * Set safe upper bounds for header and option length. Since Data Offset is 8
45 61 * bits (RFC 4340, sec. 5.1), the total header length can never be more than
46#define DCCP_MAX_PACKET_HDR 32 62 * 4 * 255 = 1020 bytes. The largest possible header length is 28 bytes (X=1):
47 63 * - DCCP-Response with ACK Subheader and 4 bytes of Service code OR
48#define MAX_DCCP_HEADER (DCCP_MAX_PACKET_HDR + DCCP_MAX_OPT_LEN + MAX_HEADER) 64 * - DCCP-Reset with ACK Subheader and 4 bytes of Reset Code fields
65 * Hence a safe upper bound for the maximum option length is 1020-28 = 992
66 */
67#define MAX_DCCP_SPECIFIC_HEADER (255 * sizeof(int))
68#define DCCP_MAX_PACKET_HDR 28
69#define DCCP_MAX_OPT_LEN (MAX_DCCP_SPECIFIC_HEADER - DCCP_MAX_PACKET_HDR)
70#define MAX_DCCP_HEADER (MAX_DCCP_SPECIFIC_HEADER + MAX_HEADER)
49 71
50#define DCCP_TIMEWAIT_LEN (60 * HZ) /* how long to wait to destroy TIME-WAIT 72#define DCCP_TIMEWAIT_LEN (60 * HZ) /* how long to wait to destroy TIME-WAIT
51 * state, about 60 seconds */ 73 * state, about 60 seconds */
@@ -58,6 +80,20 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo);
58 80
59#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ 81#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */
60 82
83#define DCCP_XMIT_TIMEO 30000 /* Time/msecs for blocking transmit per packet */
84
85/* sysctl variables for DCCP */
86extern int sysctl_dccp_request_retries;
87extern int sysctl_dccp_retries1;
88extern int sysctl_dccp_retries2;
89extern int sysctl_dccp_feat_sequence_window;
90extern int sysctl_dccp_feat_rx_ccid;
91extern int sysctl_dccp_feat_tx_ccid;
92extern int sysctl_dccp_feat_ack_ratio;
93extern int sysctl_dccp_feat_send_ack_vector;
94extern int sysctl_dccp_feat_send_ndp_count;
95extern int sysctl_dccp_tx_qlen;
96
61/* is seq1 < seq2 ? */ 97/* is seq1 < seq2 ? */
62static inline int before48(const u64 seq1, const u64 seq2) 98static inline int before48(const u64 seq1, const u64 seq2)
63{ 99{
@@ -123,10 +159,36 @@ DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics);
123#define DCCP_ADD_STATS_USER(field, val) \ 159#define DCCP_ADD_STATS_USER(field, val) \
124 SNMP_ADD_STATS_USER(dccp_statistics, field, val) 160 SNMP_ADD_STATS_USER(dccp_statistics, field, val)
125 161
162/*
163 * Checksumming routines
164 */
165static inline int dccp_csum_coverage(const struct sk_buff *skb)
166{
167 const struct dccp_hdr* dh = dccp_hdr(skb);
168
169 if (dh->dccph_cscov == 0)
170 return skb->len;
171 return (dh->dccph_doff + dh->dccph_cscov - 1) * sizeof(u32);
172}
173
174static inline void dccp_csum_outgoing(struct sk_buff *skb)
175{
176 int cov = dccp_csum_coverage(skb);
177
178 if (cov >= skb->len)
179 dccp_hdr(skb)->dccph_cscov = 0;
180
181 skb->csum = skb_checksum(skb, 0, (cov > skb->len)? skb->len : cov, 0);
182}
183
184extern void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb);
185
126extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); 186extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb);
127 187
128extern void dccp_send_ack(struct sock *sk); 188extern void dccp_send_ack(struct sock *sk);
129extern void dccp_send_delayed_ack(struct sock *sk); 189extern void dccp_send_delayed_ack(struct sock *sk);
190extern void dccp_reqsk_send_ack(struct sk_buff *sk, struct request_sock *rsk);
191
130extern void dccp_send_sync(struct sock *sk, const u64 seq, 192extern void dccp_send_sync(struct sock *sk, const u64 seq,
131 const enum dccp_pkt_type pkt_type); 193 const enum dccp_pkt_type pkt_type);
132 194
@@ -147,18 +209,7 @@ extern const char *dccp_state_name(const int state);
147extern void dccp_set_state(struct sock *sk, const int state); 209extern void dccp_set_state(struct sock *sk, const int state);
148extern void dccp_done(struct sock *sk); 210extern void dccp_done(struct sock *sk);
149 211
150static inline void dccp_openreq_init(struct request_sock *req, 212extern void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb);
151 struct dccp_sock *dp,
152 struct sk_buff *skb)
153{
154 /*
155 * FIXME: fill in the other req fields from the DCCP options
156 * received
157 */
158 inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport;
159 inet_rsk(req)->acked = 0;
160 req->rcv_wnd = 0;
161}
162 213
163extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb); 214extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
164 215
@@ -217,14 +268,9 @@ extern void dccp_shutdown(struct sock *sk, int how);
217extern int inet_dccp_listen(struct socket *sock, int backlog); 268extern int inet_dccp_listen(struct socket *sock, int backlog);
218extern unsigned int dccp_poll(struct file *file, struct socket *sock, 269extern unsigned int dccp_poll(struct file *file, struct socket *sock,
219 poll_table *wait); 270 poll_table *wait);
220extern void dccp_v4_send_check(struct sock *sk, int len,
221 struct sk_buff *skb);
222extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, 271extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
223 int addr_len); 272 int addr_len);
224 273
225extern int dccp_v4_checksum(const struct sk_buff *skb,
226 const __be32 saddr, const __be32 daddr);
227
228extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); 274extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
229extern void dccp_send_close(struct sock *sk, const int active); 275extern void dccp_send_close(struct sock *sk, const int active);
230extern int dccp_invalid_packet(struct sk_buff *skb); 276extern int dccp_invalid_packet(struct sk_buff *skb);
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index a1b0682ee77c..4dc487f27a1f 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -12,7 +12,6 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14 14
15#include "dccp.h"
16#include "ccid.h" 15#include "ccid.h"
17#include "feat.h" 16#include "feat.h"
18 17
@@ -23,9 +22,17 @@ int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature,
23{ 22{
24 struct dccp_opt_pend *opt; 23 struct dccp_opt_pend *opt;
25 24
26 dccp_pr_debug("feat change type=%d feat=%d\n", type, feature); 25 dccp_feat_debug(type, feature, *val);
27 26
28 /* XXX sanity check feat change request */ 27 if (!dccp_feat_is_valid_type(type)) {
28 DCCP_WARN("option type %d invalid in negotiation\n", type);
29 return 1;
30 }
31 if (!dccp_feat_is_valid_length(type, feature, len)) {
32 DCCP_WARN("invalid length %d\n", len);
33 return 1;
34 }
35 /* XXX add further sanity checks */
29 36
30 /* check if that feature is already being negotiated */ 37 /* check if that feature is already being negotiated */
31 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) { 38 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
@@ -95,14 +102,14 @@ static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr)
95/* XXX taking only u8 vals */ 102/* XXX taking only u8 vals */
96static int dccp_feat_update(struct sock *sk, u8 type, u8 feat, u8 val) 103static int dccp_feat_update(struct sock *sk, u8 type, u8 feat, u8 val)
97{ 104{
98 dccp_pr_debug("changing [%d] feat %d to %d\n", type, feat, val); 105 dccp_feat_debug(type, feat, val);
99 106
100 switch (feat) { 107 switch (feat) {
101 case DCCPF_CCID: 108 case DCCPF_CCID:
102 return dccp_feat_update_ccid(sk, type, val); 109 return dccp_feat_update_ccid(sk, type, val);
103 default: 110 default:
104 dccp_pr_debug("IMPLEMENT changing [%d] feat %d to %d\n", 111 dccp_pr_debug("UNIMPLEMENTED: %s(%d, ...)\n",
105 type, feat, val); 112 dccp_feat_typename(type), feat);
106 break; 113 break;
107 } 114 }
108 return 0; 115 return 0;
@@ -162,7 +169,8 @@ static int dccp_feat_reconcile(struct sock *sk, struct dccp_opt_pend *opt,
162 break; 169 break;
163 170
164 default: 171 default:
165 WARN_ON(1); /* XXX implement res */ 172 DCCP_BUG("Fell through, feat=%d", opt->dccpop_feat);
173 /* XXX implement res */
166 return -EFAULT; 174 return -EFAULT;
167 } 175 }
168 176
@@ -265,10 +273,10 @@ static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
265 u8 *copy; 273 u8 *copy;
266 int rc; 274 int rc;
267 275
268 /* NN features must be change L */ 276 /* NN features must be Change L (sec. 6.3.2) */
269 if (type == DCCPO_CHANGE_R) { 277 if (type != DCCPO_CHANGE_L) {
270 dccp_pr_debug("received CHANGE_R %d for NN feat %d\n", 278 dccp_pr_debug("received %s for NN feature %d\n",
271 type, feature); 279 dccp_feat_typename(type), feature);
272 return -EFAULT; 280 return -EFAULT;
273 } 281 }
274 282
@@ -279,12 +287,11 @@ static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
279 if (opt == NULL) 287 if (opt == NULL)
280 return -ENOMEM; 288 return -ENOMEM;
281 289
282 copy = kmalloc(len, GFP_ATOMIC); 290 copy = kmemdup(val, len, GFP_ATOMIC);
283 if (copy == NULL) { 291 if (copy == NULL) {
284 kfree(opt); 292 kfree(opt);
285 return -ENOMEM; 293 return -ENOMEM;
286 } 294 }
287 memcpy(copy, val, len);
288 295
289 opt->dccpop_type = DCCPO_CONFIRM_R; /* NN can only confirm R */ 296 opt->dccpop_type = DCCPO_CONFIRM_R; /* NN can only confirm R */
290 opt->dccpop_feat = feature; 297 opt->dccpop_feat = feature;
@@ -299,7 +306,8 @@ static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
299 return rc; 306 return rc;
300 } 307 }
301 308
302 dccp_pr_debug("Confirming NN feature %d (val=%d)\n", feature, *copy); 309 dccp_feat_debug(type, feature, *copy);
310
303 list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf); 311 list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf);
304 312
305 return 0; 313 return 0;
@@ -318,14 +326,19 @@ static void dccp_feat_empty_confirm(struct dccp_minisock *dmsk,
318 return; 326 return;
319 } 327 }
320 328
321 opt->dccpop_type = type == DCCPO_CHANGE_L ? DCCPO_CONFIRM_R : 329 switch (type) {
322 DCCPO_CONFIRM_L; 330 case DCCPO_CHANGE_L: opt->dccpop_type = DCCPO_CONFIRM_R; break;
331 case DCCPO_CHANGE_R: opt->dccpop_type = DCCPO_CONFIRM_L; break;
332 default: DCCP_WARN("invalid type %d\n", type); return;
333
334 }
323 opt->dccpop_feat = feature; 335 opt->dccpop_feat = feature;
324 opt->dccpop_val = NULL; 336 opt->dccpop_val = NULL;
325 opt->dccpop_len = 0; 337 opt->dccpop_len = 0;
326 338
327 /* change feature */ 339 /* change feature */
328 dccp_pr_debug("Empty confirm feature %d type %d\n", feature, type); 340 dccp_pr_debug("Empty %s(%d)\n", dccp_feat_typename(type), feature);
341
329 list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf); 342 list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf);
330} 343}
331 344
@@ -359,7 +372,7 @@ int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
359{ 372{
360 int rc; 373 int rc;
361 374
362 dccp_pr_debug("got feat change type=%d feat=%d\n", type, feature); 375 dccp_feat_debug(type, feature, *val);
363 376
364 /* figure out if it's SP or NN feature */ 377 /* figure out if it's SP or NN feature */
365 switch (feature) { 378 switch (feature) {
@@ -375,6 +388,8 @@ int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
375 388
376 /* XXX implement other features */ 389 /* XXX implement other features */
377 default: 390 default:
391 dccp_pr_debug("UNIMPLEMENTED: not handling %s(%d, ...)\n",
392 dccp_feat_typename(type), feature);
378 rc = -EFAULT; 393 rc = -EFAULT;
379 break; 394 break;
380 } 395 }
@@ -403,20 +418,27 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
403 u8 t; 418 u8 t;
404 struct dccp_opt_pend *opt; 419 struct dccp_opt_pend *opt;
405 struct dccp_minisock *dmsk = dccp_msk(sk); 420 struct dccp_minisock *dmsk = dccp_msk(sk);
406 int rc = 1; 421 int found = 0;
407 int all_confirmed = 1; 422 int all_confirmed = 1;
408 423
409 dccp_pr_debug("got feat confirm type=%d feat=%d\n", type, feature); 424 dccp_feat_debug(type, feature, *val);
410
411 /* XXX sanity check type & feat */
412 425
413 /* locate our change request */ 426 /* locate our change request */
414 t = type == DCCPO_CONFIRM_L ? DCCPO_CHANGE_R : DCCPO_CHANGE_L; 427 switch (type) {
428 case DCCPO_CONFIRM_L: t = DCCPO_CHANGE_R; break;
429 case DCCPO_CONFIRM_R: t = DCCPO_CHANGE_L; break;
430 default: DCCP_WARN("invalid type %d\n", type);
431 return 1;
432
433 }
434 /* XXX sanity check feature value */
415 435
416 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) { 436 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
417 if (!opt->dccpop_conf && opt->dccpop_type == t && 437 if (!opt->dccpop_conf && opt->dccpop_type == t &&
418 opt->dccpop_feat == feature) { 438 opt->dccpop_feat == feature) {
419 /* we found it */ 439 found = 1;
440 dccp_pr_debug("feature %d found\n", opt->dccpop_feat);
441
420 /* XXX do sanity check */ 442 /* XXX do sanity check */
421 443
422 opt->dccpop_conf = 1; 444 opt->dccpop_conf = 1;
@@ -425,9 +447,7 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
425 dccp_feat_update(sk, opt->dccpop_type, 447 dccp_feat_update(sk, opt->dccpop_type,
426 opt->dccpop_feat, *val); 448 opt->dccpop_feat, *val);
427 449
428 dccp_pr_debug("feat %d type %d confirmed %d\n", 450 /* XXX check the return value of dccp_feat_update */
429 feature, type, *val);
430 rc = 0;
431 break; 451 break;
432 } 452 }
433 453
@@ -446,9 +466,9 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
446 inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); 466 inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS);
447 } 467 }
448 468
449 if (rc) 469 if (!found)
450 dccp_pr_debug("feat %d type %d never requested\n", 470 dccp_pr_debug("%s(%d, ...) never requested\n",
451 feature, type); 471 dccp_feat_typename(type), feature);
452 return 0; 472 return 0;
453} 473}
454 474
@@ -501,20 +521,18 @@ int dccp_feat_clone(struct sock *oldsk, struct sock *newsk)
501 list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) { 521 list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) {
502 struct dccp_opt_pend *newopt; 522 struct dccp_opt_pend *newopt;
503 /* copy the value of the option */ 523 /* copy the value of the option */
504 u8 *val = kmalloc(opt->dccpop_len, GFP_ATOMIC); 524 u8 *val = kmemdup(opt->dccpop_val, opt->dccpop_len, GFP_ATOMIC);
505 525
506 if (val == NULL) 526 if (val == NULL)
507 goto out_clean; 527 goto out_clean;
508 memcpy(val, opt->dccpop_val, opt->dccpop_len);
509 528
510 newopt = kmalloc(sizeof(*newopt), GFP_ATOMIC); 529 newopt = kmemdup(opt, sizeof(*newopt), GFP_ATOMIC);
511 if (newopt == NULL) { 530 if (newopt == NULL) {
512 kfree(val); 531 kfree(val);
513 goto out_clean; 532 goto out_clean;
514 } 533 }
515 534
516 /* insert the option */ 535 /* insert the option */
517 memcpy(newopt, opt, sizeof(*newopt));
518 newopt->dccpop_val = val; 536 newopt->dccpop_val = val;
519 list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending); 537 list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending);
520 538
@@ -545,10 +563,9 @@ static int __dccp_feat_init(struct dccp_minisock *dmsk, u8 type, u8 feat,
545 u8 *val, u8 len) 563 u8 *val, u8 len)
546{ 564{
547 int rc = -ENOMEM; 565 int rc = -ENOMEM;
548 u8 *copy = kmalloc(len, GFP_KERNEL); 566 u8 *copy = kmemdup(val, len, GFP_KERNEL);
549 567
550 if (copy != NULL) { 568 if (copy != NULL) {
551 memcpy(copy, val, len);
552 rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL); 569 rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL);
553 if (rc) 570 if (rc)
554 kfree(copy); 571 kfree(copy);
@@ -583,3 +600,45 @@ out:
583} 600}
584 601
585EXPORT_SYMBOL_GPL(dccp_feat_init); 602EXPORT_SYMBOL_GPL(dccp_feat_init);
603
604#ifdef CONFIG_IP_DCCP_DEBUG
605const char *dccp_feat_typename(const u8 type)
606{
607 switch(type) {
608 case DCCPO_CHANGE_L: return("ChangeL");
609 case DCCPO_CONFIRM_L: return("ConfirmL");
610 case DCCPO_CHANGE_R: return("ChangeR");
611 case DCCPO_CONFIRM_R: return("ConfirmR");
612 /* the following case must not appear in feature negotation */
613 default: dccp_pr_debug("unknown type %d [BUG!]\n", type);
614 }
615 return NULL;
616}
617
618EXPORT_SYMBOL_GPL(dccp_feat_typename);
619
620const char *dccp_feat_name(const u8 feat)
621{
622 static const char *feature_names[] = {
623 [DCCPF_RESERVED] = "Reserved",
624 [DCCPF_CCID] = "CCID",
625 [DCCPF_SHORT_SEQNOS] = "Allow Short Seqnos",
626 [DCCPF_SEQUENCE_WINDOW] = "Sequence Window",
627 [DCCPF_ECN_INCAPABLE] = "ECN Incapable",
628 [DCCPF_ACK_RATIO] = "Ack Ratio",
629 [DCCPF_SEND_ACK_VECTOR] = "Send ACK Vector",
630 [DCCPF_SEND_NDP_COUNT] = "Send NDP Count",
631 [DCCPF_MIN_CSUM_COVER] = "Min. Csum Coverage",
632 [DCCPF_DATA_CHECKSUM] = "Send Data Checksum",
633 };
634 if (feat >= DCCPF_MIN_CCID_SPECIFIC)
635 return "CCID-specific";
636
637 if (dccp_feat_is_reserved(feat))
638 return feature_names[DCCPF_RESERVED];
639
640 return feature_names[feat];
641}
642
643EXPORT_SYMBOL_GPL(dccp_feat_name);
644#endif /* CONFIG_IP_DCCP_DEBUG */
diff --git a/net/dccp/feat.h b/net/dccp/feat.h
index cee553d416ca..2c373ad7edcf 100644
--- a/net/dccp/feat.h
+++ b/net/dccp/feat.h
@@ -12,9 +12,46 @@
12 */ 12 */
13 13
14#include <linux/types.h> 14#include <linux/types.h>
15#include "dccp.h"
15 16
16struct sock; 17static inline int dccp_feat_is_valid_length(u8 type, u8 feature, u8 len)
17struct dccp_minisock; 18{
19 /* sec. 6.1: Confirm has at least length 3,
20 * sec. 6.2: Change has at least length 4 */
21 if (len < 3)
22 return 1;
23 if (len < 4 && (type == DCCPO_CHANGE_L || type == DCCPO_CHANGE_R))
24 return 1;
25 /* XXX: add per-feature length validation (sec. 6.6.8) */
26 return 0;
27}
28
29static inline int dccp_feat_is_reserved(const u8 feat)
30{
31 return (feat > DCCPF_DATA_CHECKSUM &&
32 feat < DCCPF_MIN_CCID_SPECIFIC) ||
33 feat == DCCPF_RESERVED;
34}
35
36/* feature negotiation knows only these four option types (RFC 4340, sec. 6) */
37static inline int dccp_feat_is_valid_type(const u8 optnum)
38{
39 return optnum >= DCCPO_CHANGE_L && optnum <= DCCPO_CONFIRM_R;
40
41}
42
43#ifdef CONFIG_IP_DCCP_DEBUG
44extern const char *dccp_feat_typename(const u8 type);
45extern const char *dccp_feat_name(const u8 feat);
46
47static inline void dccp_feat_debug(const u8 type, const u8 feat, const u8 val)
48{
49 dccp_pr_debug("%s(%s (%d), %d)\n", dccp_feat_typename(type),
50 dccp_feat_name(feat), feat, val);
51}
52#else
53#define dccp_feat_debug(type, feat, val)
54#endif /* CONFIG_IP_DCCP_DEBUG */
18 55
19extern int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, 56extern int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature,
20 u8 *val, u8 len, gfp_t gfp); 57 u8 *val, u8 len, gfp_t gfp);
@@ -26,11 +63,4 @@ extern void dccp_feat_clean(struct dccp_minisock *dmsk);
26extern int dccp_feat_clone(struct sock *oldsk, struct sock *newsk); 63extern int dccp_feat_clone(struct sock *oldsk, struct sock *newsk);
27extern int dccp_feat_init(struct dccp_minisock *dmsk); 64extern int dccp_feat_init(struct dccp_minisock *dmsk);
28 65
29extern int dccp_feat_default_sequence_window;
30extern int dccp_feat_default_rx_ccid;
31extern int dccp_feat_default_tx_ccid;
32extern int dccp_feat_default_ack_ratio;
33extern int dccp_feat_default_send_ack_vector;
34extern int dccp_feat_default_send_ndp_count;
35
36#endif /* _DCCP_FEAT_H */ 66#endif /* _DCCP_FEAT_H */
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 1d24881ac0ab..7371a2f3acf4 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -128,21 +128,18 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
128 DCCP_PKT_WITHOUT_ACK_SEQ)) 128 DCCP_PKT_WITHOUT_ACK_SEQ))
129 dp->dccps_gar = DCCP_SKB_CB(skb)->dccpd_ack_seq; 129 dp->dccps_gar = DCCP_SKB_CB(skb)->dccpd_ack_seq;
130 } else { 130 } else {
131 LIMIT_NETDEBUG(KERN_WARNING "DCCP: Step 6 failed for %s packet, " 131 DCCP_WARN("DCCP: Step 6 failed for %s packet, "
132 "(LSWL(%llu) <= P.seqno(%llu) <= S.SWH(%llu)) and " 132 "(LSWL(%llu) <= P.seqno(%llu) <= S.SWH(%llu)) and "
133 "(P.ackno %s or LAWL(%llu) <= P.ackno(%llu) <= S.AWH(%llu), " 133 "(P.ackno %s or LAWL(%llu) <= P.ackno(%llu) <= S.AWH(%llu), "
134 "sending SYNC...\n", 134 "sending SYNC...\n", dccp_packet_name(dh->dccph_type),
135 dccp_packet_name(dh->dccph_type), 135 (unsigned long long) lswl,
136 (unsigned long long) lswl, 136 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq,
137 (unsigned long long) 137 (unsigned long long) dp->dccps_swh,
138 DCCP_SKB_CB(skb)->dccpd_seq, 138 (DCCP_SKB_CB(skb)->dccpd_ack_seq ==
139 (unsigned long long) dp->dccps_swh,
140 (DCCP_SKB_CB(skb)->dccpd_ack_seq ==
141 DCCP_PKT_WITHOUT_ACK_SEQ) ? "doesn't exist" : "exists", 139 DCCP_PKT_WITHOUT_ACK_SEQ) ? "doesn't exist" : "exists",
142 (unsigned long long) lawl, 140 (unsigned long long) lawl,
143 (unsigned long long) 141 (unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq,
144 DCCP_SKB_CB(skb)->dccpd_ack_seq, 142 (unsigned long long) dp->dccps_awh);
145 (unsigned long long) dp->dccps_awh);
146 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_PKT_SYNC); 143 dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_PKT_SYNC);
147 return -1; 144 return -1;
148 } 145 }
@@ -431,29 +428,25 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
431 428
432 /* 429 /*
433 * Step 3: Process LISTEN state 430 * Step 3: Process LISTEN state
434 * (Continuing from dccp_v4_do_rcv and dccp_v6_do_rcv)
435 * 431 *
436 * If S.state == LISTEN, 432 * If S.state == LISTEN,
437 * If P.type == Request or P contains a valid Init Cookie 433 * If P.type == Request or P contains a valid Init Cookie option,
438 * option, 434 * (* Must scan the packet's options to check for Init
439 * * Must scan the packet's options to check for an Init 435 * Cookies. Only Init Cookies are processed here,
440 * Cookie. Only the Init Cookie is processed here, 436 * however; other options are processed in Step 8. This
441 * however; other options are processed in Step 8. This 437 * scan need only be performed if the endpoint uses Init
442 * scan need only be performed if the endpoint uses Init 438 * Cookies *)
443 * Cookies * 439 * (* Generate a new socket and switch to that socket *)
444 * * Generate a new socket and switch to that socket * 440 * Set S := new socket for this port pair
445 * Set S := new socket for this port pair 441 * S.state = RESPOND
446 * S.state = RESPOND 442 * Choose S.ISS (initial seqno) or set from Init Cookies
447 * Choose S.ISS (initial seqno) or set from Init Cookie 443 * Initialize S.GAR := S.ISS
448 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie 444 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init
449 * Continue with S.state == RESPOND 445 * Cookies Continue with S.state == RESPOND
450 * * A Response packet will be generated in Step 11 * 446 * (* A Response packet will be generated in Step 11 *)
451 * Otherwise, 447 * Otherwise,
452 * Generate Reset(No Connection) unless P.type == Reset 448 * Generate Reset(No Connection) unless P.type == Reset
453 * Drop packet and return 449 * Drop packet and return
454 *
455 * NOTE: the check for the packet types is done in
456 * dccp_rcv_state_process
457 */ 450 */
458 if (sk->sk_state == DCCP_LISTEN) { 451 if (sk->sk_state == DCCP_LISTEN) {
459 if (dh->dccph_type == DCCP_PKT_REQUEST) { 452 if (dh->dccph_type == DCCP_PKT_REQUEST) {
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index e08e7688a263..ff81679c9f17 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -113,13 +113,8 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
113 /* OK, now commit destination to socket. */ 113 /* OK, now commit destination to socket. */
114 sk_setup_caps(sk, &rt->u.dst); 114 sk_setup_caps(sk, &rt->u.dst);
115 115
116 dp->dccps_gar = 116 dp->dccps_iss = secure_dccp_sequence_number(inet->saddr, inet->daddr,
117 dp->dccps_iss = secure_dccp_sequence_number(inet->saddr, 117 inet->sport, inet->dport);
118 inet->daddr,
119 inet->sport,
120 usin->sin_port);
121 dccp_update_gss(sk, dp->dccps_iss);
122
123 inet->id = dp->dccps_iss ^ jiffies; 118 inet->id = dp->dccps_iss ^ jiffies;
124 119
125 err = dccp_connect(sk); 120 err = dccp_connect(sk);
@@ -193,86 +188,6 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
193 } /* else let the usual retransmit timer handle it */ 188 } /* else let the usual retransmit timer handle it */
194} 189}
195 190
196static void dccp_v4_reqsk_send_ack(struct sk_buff *rxskb,
197 struct request_sock *req)
198{
199 int err;
200 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
201 const u32 dccp_hdr_ack_len = sizeof(struct dccp_hdr) +
202 sizeof(struct dccp_hdr_ext) +
203 sizeof(struct dccp_hdr_ack_bits);
204 struct sk_buff *skb;
205
206 if (((struct rtable *)rxskb->dst)->rt_type != RTN_LOCAL)
207 return;
208
209 skb = alloc_skb(dccp_v4_ctl_socket->sk->sk_prot->max_header, GFP_ATOMIC);
210 if (skb == NULL)
211 return;
212
213 /* Reserve space for headers. */
214 skb_reserve(skb, dccp_v4_ctl_socket->sk->sk_prot->max_header);
215
216 skb->dst = dst_clone(rxskb->dst);
217
218 skb->h.raw = skb_push(skb, dccp_hdr_ack_len);
219 dh = dccp_hdr(skb);
220 memset(dh, 0, dccp_hdr_ack_len);
221
222 /* Build DCCP header and checksum it. */
223 dh->dccph_type = DCCP_PKT_ACK;
224 dh->dccph_sport = rxdh->dccph_dport;
225 dh->dccph_dport = rxdh->dccph_sport;
226 dh->dccph_doff = dccp_hdr_ack_len / 4;
227 dh->dccph_x = 1;
228
229 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
230 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
231 DCCP_SKB_CB(rxskb)->dccpd_seq);
232
233 bh_lock_sock(dccp_v4_ctl_socket->sk);
234 err = ip_build_and_send_pkt(skb, dccp_v4_ctl_socket->sk,
235 rxskb->nh.iph->daddr,
236 rxskb->nh.iph->saddr, NULL);
237 bh_unlock_sock(dccp_v4_ctl_socket->sk);
238
239 if (err == NET_XMIT_CN || err == 0) {
240 DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
241 DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS);
242 }
243}
244
245static int dccp_v4_send_response(struct sock *sk, struct request_sock *req,
246 struct dst_entry *dst)
247{
248 int err = -1;
249 struct sk_buff *skb;
250
251 /* First, grab a route. */
252
253 if (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL)
254 goto out;
255
256 skb = dccp_make_response(sk, dst, req);
257 if (skb != NULL) {
258 const struct inet_request_sock *ireq = inet_rsk(req);
259 struct dccp_hdr *dh = dccp_hdr(skb);
260
261 dh->dccph_checksum = dccp_v4_checksum(skb, ireq->loc_addr,
262 ireq->rmt_addr);
263 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
264 err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr,
265 ireq->rmt_addr,
266 ireq->opt);
267 if (err == NET_XMIT_CN)
268 err = 0;
269 }
270
271out:
272 dst_release(dst);
273 return err;
274}
275
276/* 191/*
277 * This routine is called by the ICMP module when it gets some sort of error 192 * This routine is called by the ICMP module when it gets some sort of error
278 * condition. If err < 0 then the socket should be closed and the error 193 * condition. If err < 0 then the socket should be closed and the error
@@ -329,7 +244,7 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
329 seq = dccp_hdr_seq(skb); 244 seq = dccp_hdr_seq(skb);
330 if (sk->sk_state != DCCP_LISTEN && 245 if (sk->sk_state != DCCP_LISTEN &&
331 !between48(seq, dp->dccps_swl, dp->dccps_swh)) { 246 !between48(seq, dp->dccps_swl, dp->dccps_swh)) {
332 NET_INC_STATS(LINUX_MIB_OUTOFWINDOWICMPS); 247 NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS);
333 goto out; 248 goto out;
334 } 249 }
335 250
@@ -429,19 +344,24 @@ out:
429 sock_put(sk); 344 sock_put(sk);
430} 345}
431 346
432/* This routine computes an IPv4 DCCP checksum. */ 347static inline __sum16 dccp_v4_csum_finish(struct sk_buff *skb,
433void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) 348 __be32 src, __be32 dst)
349{
350 return csum_tcpudp_magic(src, dst, skb->len, IPPROTO_DCCP, skb->csum);
351}
352
353void dccp_v4_send_check(struct sock *sk, int unused, struct sk_buff *skb)
434{ 354{
435 const struct inet_sock *inet = inet_sk(sk); 355 const struct inet_sock *inet = inet_sk(sk);
436 struct dccp_hdr *dh = dccp_hdr(skb); 356 struct dccp_hdr *dh = dccp_hdr(skb);
437 357
438 dh->dccph_checksum = dccp_v4_checksum(skb, inet->saddr, inet->daddr); 358 dccp_csum_outgoing(skb);
359 dh->dccph_checksum = dccp_v4_csum_finish(skb, inet->saddr, inet->daddr);
439} 360}
440 361
441EXPORT_SYMBOL_GPL(dccp_v4_send_check); 362EXPORT_SYMBOL_GPL(dccp_v4_send_check);
442 363
443static inline u64 dccp_v4_init_sequence(const struct sock *sk, 364static inline u64 dccp_v4_init_sequence(const struct sk_buff *skb)
444 const struct sk_buff *skb)
445{ 365{
446 return secure_dccp_sequence_number(skb->nh.iph->daddr, 366 return secure_dccp_sequence_number(skb->nh.iph->daddr,
447 skb->nh.iph->saddr, 367 skb->nh.iph->saddr,
@@ -449,95 +369,6 @@ static inline u64 dccp_v4_init_sequence(const struct sock *sk,
449 dccp_hdr(skb)->dccph_sport); 369 dccp_hdr(skb)->dccph_sport);
450} 370}
451 371
452static struct request_sock_ops dccp_request_sock_ops;
453
454int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
455{
456 struct inet_request_sock *ireq;
457 struct dccp_sock dp;
458 struct request_sock *req;
459 struct dccp_request_sock *dreq;
460 const __be32 saddr = skb->nh.iph->saddr;
461 const __be32 daddr = skb->nh.iph->daddr;
462 const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
463 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
464 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
465
466 /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
467 if (((struct rtable *)skb->dst)->rt_flags &
468 (RTCF_BROADCAST | RTCF_MULTICAST)) {
469 reset_code = DCCP_RESET_CODE_NO_CONNECTION;
470 goto drop;
471 }
472
473 if (dccp_bad_service_code(sk, service)) {
474 reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
475 goto drop;
476 }
477 /*
478 * TW buckets are converted to open requests without
479 * limitations, they conserve resources and peer is
480 * evidently real one.
481 */
482 if (inet_csk_reqsk_queue_is_full(sk))
483 goto drop;
484
485 /*
486 * Accept backlog is full. If we have already queued enough
487 * of warm entries in syn queue, drop request. It is better than
488 * clogging syn queue with openreqs with exponentially increasing
489 * timeout.
490 */
491 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
492 goto drop;
493
494 req = reqsk_alloc(&dccp_request_sock_ops);
495 if (req == NULL)
496 goto drop;
497
498 if (dccp_parse_options(sk, skb))
499 goto drop_and_free;
500
501 dccp_openreq_init(req, &dp, skb);
502
503 if (security_inet_conn_request(sk, skb, req))
504 goto drop_and_free;
505
506 ireq = inet_rsk(req);
507 ireq->loc_addr = daddr;
508 ireq->rmt_addr = saddr;
509 req->rcv_wnd = dccp_feat_default_sequence_window;
510 ireq->opt = NULL;
511
512 /*
513 * Step 3: Process LISTEN state
514 *
515 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
516 *
517 * In fact we defer setting S.GSR, S.SWL, S.SWH to
518 * dccp_create_openreq_child.
519 */
520 dreq = dccp_rsk(req);
521 dreq->dreq_isr = dcb->dccpd_seq;
522 dreq->dreq_iss = dccp_v4_init_sequence(sk, skb);
523 dreq->dreq_service = service;
524
525 if (dccp_v4_send_response(sk, req, NULL))
526 goto drop_and_free;
527
528 inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
529 return 0;
530
531drop_and_free:
532 reqsk_free(req);
533drop:
534 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
535 dcb->dccpd_reset_code = reset_code;
536 return -1;
537}
538
539EXPORT_SYMBOL_GPL(dccp_v4_conn_request);
540
541/* 372/*
542 * The three way handshake has completed - we got a valid ACK or DATAACK - 373 * The three way handshake has completed - we got a valid ACK or DATAACK -
543 * now create the new socket. 374 * now create the new socket.
@@ -623,47 +454,6 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
623 return sk; 454 return sk;
624} 455}
625 456
626int dccp_v4_checksum(const struct sk_buff *skb, const __be32 saddr,
627 const __be32 daddr)
628{
629 const struct dccp_hdr* dh = dccp_hdr(skb);
630 int checksum_len;
631 u32 tmp;
632
633 if (dh->dccph_cscov == 0)
634 checksum_len = skb->len;
635 else {
636 checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
637 checksum_len = checksum_len < skb->len ? checksum_len :
638 skb->len;
639 }
640
641 tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
642 return csum_tcpudp_magic(saddr, daddr, checksum_len,
643 IPPROTO_DCCP, tmp);
644}
645
646EXPORT_SYMBOL_GPL(dccp_v4_checksum);
647
648static int dccp_v4_verify_checksum(struct sk_buff *skb,
649 const __be32 saddr, const __be32 daddr)
650{
651 struct dccp_hdr *dh = dccp_hdr(skb);
652 int checksum_len;
653 u32 tmp;
654
655 if (dh->dccph_cscov == 0)
656 checksum_len = skb->len;
657 else {
658 checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
659 checksum_len = checksum_len < skb->len ? checksum_len :
660 skb->len;
661 }
662 tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
663 return csum_tcpudp_magic(saddr, daddr, checksum_len,
664 IPPROTO_DCCP, tmp) == 0 ? 0 : -1;
665}
666
667static struct dst_entry* dccp_v4_route_skb(struct sock *sk, 457static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
668 struct sk_buff *skb) 458 struct sk_buff *skb)
669{ 459{
@@ -689,7 +479,37 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
689 return &rt->u.dst; 479 return &rt->u.dst;
690} 480}
691 481
692static void dccp_v4_ctl_send_reset(struct sk_buff *rxskb) 482static int dccp_v4_send_response(struct sock *sk, struct request_sock *req,
483 struct dst_entry *dst)
484{
485 int err = -1;
486 struct sk_buff *skb;
487
488 /* First, grab a route. */
489
490 if (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL)
491 goto out;
492
493 skb = dccp_make_response(sk, dst, req);
494 if (skb != NULL) {
495 const struct inet_request_sock *ireq = inet_rsk(req);
496 struct dccp_hdr *dh = dccp_hdr(skb);
497
498 dh->dccph_checksum = dccp_v4_csum_finish(skb, ireq->loc_addr,
499 ireq->rmt_addr);
500 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
501 err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr,
502 ireq->rmt_addr,
503 ireq->opt);
504 err = net_xmit_eval(err);
505 }
506
507out:
508 dst_release(dst);
509 return err;
510}
511
512static void dccp_v4_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
693{ 513{
694 int err; 514 int err;
695 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh; 515 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
@@ -698,7 +518,7 @@ static void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
698 sizeof(struct dccp_hdr_reset); 518 sizeof(struct dccp_hdr_reset);
699 struct sk_buff *skb; 519 struct sk_buff *skb;
700 struct dst_entry *dst; 520 struct dst_entry *dst;
701 u64 seqno; 521 u64 seqno = 0;
702 522
703 /* Never send a reset in response to a reset. */ 523 /* Never send a reset in response to a reset. */
704 if (rxdh->dccph_type == DCCP_PKT_RESET) 524 if (rxdh->dccph_type == DCCP_PKT_RESET)
@@ -720,9 +540,7 @@ static void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
720 skb_reserve(skb, dccp_v4_ctl_socket->sk->sk_prot->max_header); 540 skb_reserve(skb, dccp_v4_ctl_socket->sk->sk_prot->max_header);
721 skb->dst = dst_clone(dst); 541 skb->dst = dst_clone(dst);
722 542
723 skb->h.raw = skb_push(skb, dccp_hdr_reset_len); 543 dh = dccp_zeroed_hdr(skb, dccp_hdr_reset_len);
724 dh = dccp_hdr(skb);
725 memset(dh, 0, dccp_hdr_reset_len);
726 544
727 /* Build DCCP header and checksum it. */ 545 /* Build DCCP header and checksum it. */
728 dh->dccph_type = DCCP_PKT_RESET; 546 dh->dccph_type = DCCP_PKT_RESET;
@@ -734,16 +552,15 @@ static void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
734 DCCP_SKB_CB(rxskb)->dccpd_reset_code; 552 DCCP_SKB_CB(rxskb)->dccpd_reset_code;
735 553
736 /* See "8.3.1. Abnormal Termination" in RFC 4340 */ 554 /* See "8.3.1. Abnormal Termination" in RFC 4340 */
737 seqno = 0;
738 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) 555 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
739 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1); 556 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1);
740 557
741 dccp_hdr_set_seq(dh, seqno); 558 dccp_hdr_set_seq(dh, seqno);
742 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), 559 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq);
743 DCCP_SKB_CB(rxskb)->dccpd_seq);
744 560
745 dh->dccph_checksum = dccp_v4_checksum(skb, rxskb->nh.iph->saddr, 561 dccp_csum_outgoing(skb);
746 rxskb->nh.iph->daddr); 562 dh->dccph_checksum = dccp_v4_csum_finish(skb, rxskb->nh.iph->saddr,
563 rxskb->nh.iph->daddr);
747 564
748 bh_lock_sock(dccp_v4_ctl_socket->sk); 565 bh_lock_sock(dccp_v4_ctl_socket->sk);
749 err = ip_build_and_send_pkt(skb, dccp_v4_ctl_socket->sk, 566 err = ip_build_and_send_pkt(skb, dccp_v4_ctl_socket->sk,
@@ -751,7 +568,7 @@ static void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
751 rxskb->nh.iph->saddr, NULL); 568 rxskb->nh.iph->saddr, NULL);
752 bh_unlock_sock(dccp_v4_ctl_socket->sk); 569 bh_unlock_sock(dccp_v4_ctl_socket->sk);
753 570
754 if (err == NET_XMIT_CN || err == 0) { 571 if (net_xmit_eval(err) == 0) {
755 DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS); 572 DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
756 DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS); 573 DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS);
757 } 574 }
@@ -759,6 +576,103 @@ out:
759 dst_release(dst); 576 dst_release(dst);
760} 577}
761 578
579static void dccp_v4_reqsk_destructor(struct request_sock *req)
580{
581 kfree(inet_rsk(req)->opt);
582}
583
584static struct request_sock_ops dccp_request_sock_ops __read_mostly = {
585 .family = PF_INET,
586 .obj_size = sizeof(struct dccp_request_sock),
587 .rtx_syn_ack = dccp_v4_send_response,
588 .send_ack = dccp_reqsk_send_ack,
589 .destructor = dccp_v4_reqsk_destructor,
590 .send_reset = dccp_v4_ctl_send_reset,
591};
592
593int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
594{
595 struct inet_request_sock *ireq;
596 struct request_sock *req;
597 struct dccp_request_sock *dreq;
598 const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
599 struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
600 __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY;
601
602 /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
603 if (((struct rtable *)skb->dst)->rt_flags &
604 (RTCF_BROADCAST | RTCF_MULTICAST)) {
605 reset_code = DCCP_RESET_CODE_NO_CONNECTION;
606 goto drop;
607 }
608
609 if (dccp_bad_service_code(sk, service)) {
610 reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
611 goto drop;
612 }
613 /*
614 * TW buckets are converted to open requests without
615 * limitations, they conserve resources and peer is
616 * evidently real one.
617 */
618 if (inet_csk_reqsk_queue_is_full(sk))
619 goto drop;
620
621 /*
622 * Accept backlog is full. If we have already queued enough
623 * of warm entries in syn queue, drop request. It is better than
624 * clogging syn queue with openreqs with exponentially increasing
625 * timeout.
626 */
627 if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1)
628 goto drop;
629
630 req = reqsk_alloc(&dccp_request_sock_ops);
631 if (req == NULL)
632 goto drop;
633
634 if (dccp_parse_options(sk, skb))
635 goto drop_and_free;
636
637 dccp_reqsk_init(req, skb);
638
639 if (security_inet_conn_request(sk, skb, req))
640 goto drop_and_free;
641
642 ireq = inet_rsk(req);
643 ireq->loc_addr = skb->nh.iph->daddr;
644 ireq->rmt_addr = skb->nh.iph->saddr;
645 ireq->opt = NULL;
646
647 /*
648 * Step 3: Process LISTEN state
649 *
650 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
651 *
652 * In fact we defer setting S.GSR, S.SWL, S.SWH to
653 * dccp_create_openreq_child.
654 */
655 dreq = dccp_rsk(req);
656 dreq->dreq_isr = dcb->dccpd_seq;
657 dreq->dreq_iss = dccp_v4_init_sequence(skb);
658 dreq->dreq_service = service;
659
660 if (dccp_v4_send_response(sk, req, NULL))
661 goto drop_and_free;
662
663 inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
664 return 0;
665
666drop_and_free:
667 reqsk_free(req);
668drop:
669 DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS);
670 dcb->dccpd_reset_code = reset_code;
671 return -1;
672}
673
674EXPORT_SYMBOL_GPL(dccp_v4_conn_request);
675
762int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) 676int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
763{ 677{
764 struct dccp_hdr *dh = dccp_hdr(skb); 678 struct dccp_hdr *dh = dccp_hdr(skb);
@@ -771,24 +685,23 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
771 685
772 /* 686 /*
773 * Step 3: Process LISTEN state 687 * Step 3: Process LISTEN state
774 * If S.state == LISTEN, 688 * If P.type == Request or P contains a valid Init Cookie option,
775 * If P.type == Request or P contains a valid Init Cookie 689 * (* Must scan the packet's options to check for Init
776 * option, 690 * Cookies. Only Init Cookies are processed here,
777 * * Must scan the packet's options to check for an Init 691 * however; other options are processed in Step 8. This
778 * Cookie. Only the Init Cookie is processed here, 692 * scan need only be performed if the endpoint uses Init
779 * however; other options are processed in Step 8. This 693 * Cookies *)
780 * scan need only be performed if the endpoint uses Init 694 * (* Generate a new socket and switch to that socket *)
781 * Cookies * 695 * Set S := new socket for this port pair
782 * * Generate a new socket and switch to that socket * 696 * S.state = RESPOND
783 * Set S := new socket for this port pair 697 * Choose S.ISS (initial seqno) or set from Init Cookies
784 * S.state = RESPOND 698 * Initialize S.GAR := S.ISS
785 * Choose S.ISS (initial seqno) or set from Init Cookie 699 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies
786 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie 700 * Continue with S.state == RESPOND
787 * Continue with S.state == RESPOND 701 * (* A Response packet will be generated in Step 11 *)
788 * * A Response packet will be generated in Step 11 * 702 * Otherwise,
789 * Otherwise, 703 * Generate Reset(No Connection) unless P.type == Reset
790 * Generate Reset(No Connection) unless P.type == Reset 704 * Drop packet and return
791 * Drop packet and return
792 * 705 *
793 * NOTE: the check for the packet types is done in 706 * NOTE: the check for the packet types is done in
794 * dccp_rcv_state_process 707 * dccp_rcv_state_process
@@ -811,7 +724,7 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
811 return 0; 724 return 0;
812 725
813reset: 726reset:
814 dccp_v4_ctl_send_reset(skb); 727 dccp_v4_ctl_send_reset(sk, skb);
815discard: 728discard:
816 kfree_skb(skb); 729 kfree_skb(skb);
817 return 0; 730 return 0;
@@ -819,60 +732,74 @@ discard:
819 732
820EXPORT_SYMBOL_GPL(dccp_v4_do_rcv); 733EXPORT_SYMBOL_GPL(dccp_v4_do_rcv);
821 734
735/**
736 * dccp_invalid_packet - check for malformed packets
737 * Implements RFC 4340, 8.5: Step 1: Check header basics
738 * Packets that fail these checks are ignored and do not receive Resets.
739 */
822int dccp_invalid_packet(struct sk_buff *skb) 740int dccp_invalid_packet(struct sk_buff *skb)
823{ 741{
824 const struct dccp_hdr *dh; 742 const struct dccp_hdr *dh;
743 unsigned int cscov;
825 744
826 if (skb->pkt_type != PACKET_HOST) 745 if (skb->pkt_type != PACKET_HOST)
827 return 1; 746 return 1;
828 747
748 /* If the packet is shorter than 12 bytes, drop packet and return */
829 if (!pskb_may_pull(skb, sizeof(struct dccp_hdr))) { 749 if (!pskb_may_pull(skb, sizeof(struct dccp_hdr))) {
830 LIMIT_NETDEBUG(KERN_WARNING "DCCP: pskb_may_pull failed\n"); 750 DCCP_WARN("pskb_may_pull failed\n");
831 return 1; 751 return 1;
832 } 752 }
833 753
834 dh = dccp_hdr(skb); 754 dh = dccp_hdr(skb);
835 755
836 /* If the packet type is not understood, drop packet and return */ 756 /* If P.type is not understood, drop packet and return */
837 if (dh->dccph_type >= DCCP_PKT_INVALID) { 757 if (dh->dccph_type >= DCCP_PKT_INVALID) {
838 LIMIT_NETDEBUG(KERN_WARNING "DCCP: invalid packet type\n"); 758 DCCP_WARN("invalid packet type\n");
839 return 1; 759 return 1;
840 } 760 }
841 761
842 /* 762 /*
843 * If P.Data Offset is too small for packet type, or too large for 763 * If P.Data Offset is too small for packet type, drop packet and return
844 * packet, drop packet and return
845 */ 764 */
846 if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) { 765 if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
847 LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.Data Offset(%u) " 766 DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff);
848 "too small 1\n",
849 dh->dccph_doff);
850 return 1; 767 return 1;
851 } 768 }
852 769 /*
770 * If P.Data Offset is too too large for packet, drop packet and return
771 */
853 if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) { 772 if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) {
854 LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.Data Offset(%u) " 773 DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff);
855 "too small 2\n",
856 dh->dccph_doff);
857 return 1; 774 return 1;
858 } 775 }
859 776
860 dh = dccp_hdr(skb);
861
862 /* 777 /*
863 * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet 778 * If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet
864 * has short sequence numbers), drop packet and return 779 * has short sequence numbers), drop packet and return
865 */ 780 */
866 if (dh->dccph_x == 0 && 781 if (dh->dccph_type >= DCCP_PKT_DATA &&
867 dh->dccph_type != DCCP_PKT_DATA && 782 dh->dccph_type <= DCCP_PKT_DATAACK && dh->dccph_x == 0) {
868 dh->dccph_type != DCCP_PKT_ACK && 783 DCCP_WARN("P.type (%s) not Data || [Data]Ack, while P.X == 0\n",
869 dh->dccph_type != DCCP_PKT_DATAACK) { 784 dccp_packet_name(dh->dccph_type));
870 LIMIT_NETDEBUG(KERN_WARNING "DCCP: P.type (%s) not Data, Ack "
871 "nor DataAck and P.X == 0\n",
872 dccp_packet_name(dh->dccph_type));
873 return 1; 785 return 1;
874 } 786 }
875 787
788 /*
789 * If P.CsCov is too large for the packet size, drop packet and return.
790 * This must come _before_ checksumming (not as RFC 4340 suggests).
791 */
792 cscov = dccp_csum_coverage(skb);
793 if (cscov > skb->len) {
794 DCCP_WARN("P.CsCov %u exceeds packet length %d\n",
795 dh->dccph_cscov, skb->len);
796 return 1;
797 }
798
799 /* If header checksum is incorrect, drop packet and return.
800 * (This step is completed in the AF-dependent functions.) */
801 skb->csum = skb_checksum(skb, 0, cscov, 0);
802
876 return 0; 803 return 0;
877} 804}
878 805
@@ -883,17 +810,16 @@ static int dccp_v4_rcv(struct sk_buff *skb)
883{ 810{
884 const struct dccp_hdr *dh; 811 const struct dccp_hdr *dh;
885 struct sock *sk; 812 struct sock *sk;
813 int min_cov;
886 814
887 /* Step 1: Check header basics: */ 815 /* Step 1: Check header basics */
888 816
889 if (dccp_invalid_packet(skb)) 817 if (dccp_invalid_packet(skb))
890 goto discard_it; 818 goto discard_it;
891 819
892 /* If the header checksum is incorrect, drop packet and return */ 820 /* Step 1: If header checksum is incorrect, drop packet and return */
893 if (dccp_v4_verify_checksum(skb, skb->nh.iph->saddr, 821 if (dccp_v4_csum_finish(skb, skb->nh.iph->saddr, skb->nh.iph->daddr)) {
894 skb->nh.iph->daddr) < 0) { 822 DCCP_WARN("dropped packet with invalid checksum\n");
895 LIMIT_NETDEBUG(KERN_WARNING "%s: incorrect header checksum\n",
896 __FUNCTION__);
897 goto discard_it; 823 goto discard_it;
898 } 824 }
899 825
@@ -915,8 +841,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)
915 dccp_pr_debug_cat("\n"); 841 dccp_pr_debug_cat("\n");
916 } else { 842 } else {
917 DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb); 843 DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
918 dccp_pr_debug_cat(", ack=%llu\n", 844 dccp_pr_debug_cat(", ack=%llu\n", (unsigned long long)
919 (unsigned long long)
920 DCCP_SKB_CB(skb)->dccpd_ack_seq); 845 DCCP_SKB_CB(skb)->dccpd_ack_seq);
921 } 846 }
922 847
@@ -930,8 +855,6 @@ static int dccp_v4_rcv(struct sk_buff *skb)
930 /* 855 /*
931 * Step 2: 856 * Step 2:
932 * If no socket ... 857 * If no socket ...
933 * Generate Reset(No Connection) unless P.type == Reset
934 * Drop packet and return
935 */ 858 */
936 if (sk == NULL) { 859 if (sk == NULL) {
937 dccp_pr_debug("failed to look up flow ID in table and " 860 dccp_pr_debug("failed to look up flow ID in table and "
@@ -945,45 +868,55 @@ static int dccp_v4_rcv(struct sk_buff *skb)
945 * Generate Reset(No Connection) unless P.type == Reset 868 * Generate Reset(No Connection) unless P.type == Reset
946 * Drop packet and return 869 * Drop packet and return
947 */ 870 */
948
949 if (sk->sk_state == DCCP_TIME_WAIT) { 871 if (sk->sk_state == DCCP_TIME_WAIT) {
950 dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: " 872 dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n");
951 "do_time_wait\n"); 873 inet_twsk_put(inet_twsk(sk));
952 goto do_time_wait; 874 goto no_dccp_socket;
875 }
876
877 /*
878 * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
879 * o if MinCsCov = 0, only packets with CsCov = 0 are accepted
880 * o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
881 */
882 min_cov = dccp_sk(sk)->dccps_pcrlen;
883 if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
884 dccp_pr_debug("Packet CsCov %d does not satisfy MinCsCov %d\n",
885 dh->dccph_cscov, min_cov);
886 /* FIXME: "Such packets SHOULD be reported using Data Dropped
887 * options (Section 11.7) with Drop Code 0, Protocol
888 * Constraints." */
889 goto discard_and_relse;
953 } 890 }
954 891
955 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) 892 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
956 goto discard_and_relse; 893 goto discard_and_relse;
957 nf_reset(skb); 894 nf_reset(skb);
958 895
959 return sk_receive_skb(sk, skb); 896 return sk_receive_skb(sk, skb, 1);
960 897
961no_dccp_socket: 898no_dccp_socket:
962 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) 899 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
963 goto discard_it; 900 goto discard_it;
964 /* 901 /*
965 * Step 2: 902 * Step 2:
903 * If no socket ...
966 * Generate Reset(No Connection) unless P.type == Reset 904 * Generate Reset(No Connection) unless P.type == Reset
967 * Drop packet and return 905 * Drop packet and return
968 */ 906 */
969 if (dh->dccph_type != DCCP_PKT_RESET) { 907 if (dh->dccph_type != DCCP_PKT_RESET) {
970 DCCP_SKB_CB(skb)->dccpd_reset_code = 908 DCCP_SKB_CB(skb)->dccpd_reset_code =
971 DCCP_RESET_CODE_NO_CONNECTION; 909 DCCP_RESET_CODE_NO_CONNECTION;
972 dccp_v4_ctl_send_reset(skb); 910 dccp_v4_ctl_send_reset(sk, skb);
973 } 911 }
974 912
975discard_it: 913discard_it:
976 /* Discard frame. */
977 kfree_skb(skb); 914 kfree_skb(skb);
978 return 0; 915 return 0;
979 916
980discard_and_relse: 917discard_and_relse:
981 sock_put(sk); 918 sock_put(sk);
982 goto discard_it; 919 goto discard_it;
983
984do_time_wait:
985 inet_twsk_put(inet_twsk(sk));
986 goto no_dccp_socket;
987} 920}
988 921
989static struct inet_connection_sock_af_ops dccp_ipv4_af_ops = { 922static struct inet_connection_sock_af_ops dccp_ipv4_af_ops = {
@@ -1017,20 +950,6 @@ static int dccp_v4_init_sock(struct sock *sk)
1017 return err; 950 return err;
1018} 951}
1019 952
1020static void dccp_v4_reqsk_destructor(struct request_sock *req)
1021{
1022 kfree(inet_rsk(req)->opt);
1023}
1024
1025static struct request_sock_ops dccp_request_sock_ops = {
1026 .family = PF_INET,
1027 .obj_size = sizeof(struct dccp_request_sock),
1028 .rtx_syn_ack = dccp_v4_send_response,
1029 .send_ack = dccp_v4_reqsk_send_ack,
1030 .destructor = dccp_v4_reqsk_destructor,
1031 .send_reset = dccp_v4_ctl_send_reset,
1032};
1033
1034static struct timewait_sock_ops dccp_timewait_sock_ops = { 953static struct timewait_sock_ops dccp_timewait_sock_ops = {
1035 .twsk_obj_size = sizeof(struct inet_timewait_sock), 954 .twsk_obj_size = sizeof(struct inet_timewait_sock),
1036}; 955};
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index fc4242c0767c..c7aaa2574f52 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -36,13 +36,6 @@
36/* Socket used for sending RSTs and ACKs */ 36/* Socket used for sending RSTs and ACKs */
37static struct socket *dccp_v6_ctl_socket; 37static struct socket *dccp_v6_ctl_socket;
38 38
39static void dccp_v6_ctl_send_reset(struct sk_buff *skb);
40static void dccp_v6_reqsk_send_ack(struct sk_buff *skb,
41 struct request_sock *req);
42static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb);
43
44static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb);
45
46static struct inet_connection_sock_af_ops dccp_ipv6_mapped; 39static struct inet_connection_sock_af_ops dccp_ipv6_mapped;
47static struct inet_connection_sock_af_ops dccp_ipv6_af_ops; 40static struct inet_connection_sock_af_ops dccp_ipv6_af_ops;
48 41
@@ -65,205 +58,37 @@ static void dccp_v6_hash(struct sock *sk)
65 } 58 }
66} 59}
67 60
68static inline u16 dccp_v6_check(struct dccp_hdr *dh, int len, 61/* add pseudo-header to DCCP checksum stored in skb->csum */
69 struct in6_addr *saddr, 62static inline __sum16 dccp_v6_csum_finish(struct sk_buff *skb,
70 struct in6_addr *daddr, 63 struct in6_addr *saddr,
71 unsigned long base) 64 struct in6_addr *daddr)
72{ 65{
73 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_DCCP, base); 66 return csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_DCCP, skb->csum);
74} 67}
75 68
76static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb) 69static inline void dccp_v6_send_check(struct sock *sk, int unused_value,
70 struct sk_buff *skb)
77{ 71{
78 const struct dccp_hdr *dh = dccp_hdr(skb); 72 struct ipv6_pinfo *np = inet6_sk(sk);
79 73 struct dccp_hdr *dh = dccp_hdr(skb);
80 if (skb->protocol == htons(ETH_P_IPV6))
81 return secure_tcpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32,
82 skb->nh.ipv6h->saddr.s6_addr32,
83 dh->dccph_dport,
84 dh->dccph_sport);
85 74
86 return secure_dccp_sequence_number(skb->nh.iph->daddr, 75 dccp_csum_outgoing(skb);
87 skb->nh.iph->saddr, 76 dh->dccph_checksum = dccp_v6_csum_finish(skb, &np->saddr, &np->daddr);
88 dh->dccph_dport,
89 dh->dccph_sport);
90} 77}
91 78
92static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, 79static inline __u32 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
93 int addr_len) 80 __be16 sport, __be16 dport )
94{ 81{
95 struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr; 82 return secure_tcpv6_sequence_number(saddr, daddr, sport, dport);
96 struct inet_connection_sock *icsk = inet_csk(sk); 83}
97 struct inet_sock *inet = inet_sk(sk);
98 struct ipv6_pinfo *np = inet6_sk(sk);
99 struct dccp_sock *dp = dccp_sk(sk);
100 struct in6_addr *saddr = NULL, *final_p = NULL, final;
101 struct flowi fl;
102 struct dst_entry *dst;
103 int addr_type;
104 int err;
105
106 dp->dccps_role = DCCP_ROLE_CLIENT;
107
108 if (addr_len < SIN6_LEN_RFC2133)
109 return -EINVAL;
110
111 if (usin->sin6_family != AF_INET6)
112 return -EAFNOSUPPORT;
113
114 memset(&fl, 0, sizeof(fl));
115
116 if (np->sndflow) {
117 fl.fl6_flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;
118 IP6_ECN_flow_init(fl.fl6_flowlabel);
119 if (fl.fl6_flowlabel & IPV6_FLOWLABEL_MASK) {
120 struct ip6_flowlabel *flowlabel;
121 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel);
122 if (flowlabel == NULL)
123 return -EINVAL;
124 ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst);
125 fl6_sock_release(flowlabel);
126 }
127 }
128 /*
129 * connect() to INADDR_ANY means loopback (BSD'ism).
130 */
131 if (ipv6_addr_any(&usin->sin6_addr))
132 usin->sin6_addr.s6_addr[15] = 1;
133
134 addr_type = ipv6_addr_type(&usin->sin6_addr);
135
136 if (addr_type & IPV6_ADDR_MULTICAST)
137 return -ENETUNREACH;
138
139 if (addr_type & IPV6_ADDR_LINKLOCAL) {
140 if (addr_len >= sizeof(struct sockaddr_in6) &&
141 usin->sin6_scope_id) {
142 /* If interface is set while binding, indices
143 * must coincide.
144 */
145 if (sk->sk_bound_dev_if &&
146 sk->sk_bound_dev_if != usin->sin6_scope_id)
147 return -EINVAL;
148
149 sk->sk_bound_dev_if = usin->sin6_scope_id;
150 }
151
152 /* Connect to link-local address requires an interface */
153 if (!sk->sk_bound_dev_if)
154 return -EINVAL;
155 }
156
157 ipv6_addr_copy(&np->daddr, &usin->sin6_addr);
158 np->flow_label = fl.fl6_flowlabel;
159
160 /*
161 * DCCP over IPv4
162 */
163 if (addr_type == IPV6_ADDR_MAPPED) {
164 u32 exthdrlen = icsk->icsk_ext_hdr_len;
165 struct sockaddr_in sin;
166
167 SOCK_DEBUG(sk, "connect: ipv4 mapped\n");
168
169 if (__ipv6_only_sock(sk))
170 return -ENETUNREACH;
171
172 sin.sin_family = AF_INET;
173 sin.sin_port = usin->sin6_port;
174 sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
175
176 icsk->icsk_af_ops = &dccp_ipv6_mapped;
177 sk->sk_backlog_rcv = dccp_v4_do_rcv;
178
179 err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
180 if (err) {
181 icsk->icsk_ext_hdr_len = exthdrlen;
182 icsk->icsk_af_ops = &dccp_ipv6_af_ops;
183 sk->sk_backlog_rcv = dccp_v6_do_rcv;
184 goto failure;
185 } else {
186 ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000FFFF),
187 inet->saddr);
188 ipv6_addr_set(&np->rcv_saddr, 0, 0, htonl(0x0000FFFF),
189 inet->rcv_saddr);
190 }
191
192 return err;
193 }
194
195 if (!ipv6_addr_any(&np->rcv_saddr))
196 saddr = &np->rcv_saddr;
197
198 fl.proto = IPPROTO_DCCP;
199 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
200 ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr);
201 fl.oif = sk->sk_bound_dev_if;
202 fl.fl_ip_dport = usin->sin6_port;
203 fl.fl_ip_sport = inet->sport;
204 security_sk_classify_flow(sk, &fl);
205
206 if (np->opt != NULL && np->opt->srcrt != NULL) {
207 const struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
208
209 ipv6_addr_copy(&final, &fl.fl6_dst);
210 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
211 final_p = &final;
212 }
213
214 err = ip6_dst_lookup(sk, &dst, &fl);
215 if (err)
216 goto failure;
217
218 if (final_p)
219 ipv6_addr_copy(&fl.fl6_dst, final_p);
220
221 err = xfrm_lookup(&dst, &fl, sk, 0);
222 if (err < 0)
223 goto failure;
224
225 if (saddr == NULL) {
226 saddr = &fl.fl6_src;
227 ipv6_addr_copy(&np->rcv_saddr, saddr);
228 }
229
230 /* set the source address */
231 ipv6_addr_copy(&np->saddr, saddr);
232 inet->rcv_saddr = LOOPBACK4_IPV6;
233
234 __ip6_dst_store(sk, dst, NULL, NULL);
235
236 icsk->icsk_ext_hdr_len = 0;
237 if (np->opt != NULL)
238 icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
239 np->opt->opt_nflen);
240
241 inet->dport = usin->sin6_port;
242
243 dccp_set_state(sk, DCCP_REQUESTING);
244 err = inet6_hash_connect(&dccp_death_row, sk);
245 if (err)
246 goto late_failure;
247 /* FIXME */
248#if 0
249 dp->dccps_gar = secure_dccp_v6_sequence_number(np->saddr.s6_addr32,
250 np->daddr.s6_addr32,
251 inet->sport,
252 inet->dport);
253#endif
254 err = dccp_connect(sk);
255 if (err)
256 goto late_failure;
257 84
258 return 0; 85static inline __u32 dccp_v6_init_sequence(struct sk_buff *skb)
86{
87 return secure_dccpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32,
88 skb->nh.ipv6h->saddr.s6_addr32,
89 dccp_hdr(skb)->dccph_dport,
90 dccp_hdr(skb)->dccph_sport );
259 91
260late_failure:
261 dccp_set_state(sk, DCCP_CLOSED);
262 __sk_dst_reset(sk);
263failure:
264 inet->dport = 0;
265 sk->sk_route_caps = 0;
266 return err;
267} 92}
268 93
269static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 94static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
@@ -464,16 +289,12 @@ static int dccp_v6_send_response(struct sock *sk, struct request_sock *req,
464 if (skb != NULL) { 289 if (skb != NULL) {
465 struct dccp_hdr *dh = dccp_hdr(skb); 290 struct dccp_hdr *dh = dccp_hdr(skb);
466 291
467 dh->dccph_checksum = dccp_v6_check(dh, skb->len, 292 dh->dccph_checksum = dccp_v6_csum_finish(skb,
468 &ireq6->loc_addr, 293 &ireq6->loc_addr,
469 &ireq6->rmt_addr, 294 &ireq6->rmt_addr);
470 csum_partial((char *)dh,
471 skb->len,
472 skb->csum));
473 ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr); 295 ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr);
474 err = ip6_xmit(sk, skb, &fl, opt, 0); 296 err = ip6_xmit(sk, skb, &fl, opt, 0);
475 if (err == NET_XMIT_CN) 297 err = net_xmit_eval(err);
476 err = 0;
477 } 298 }
478 299
479done: 300done:
@@ -489,32 +310,7 @@ static void dccp_v6_reqsk_destructor(struct request_sock *req)
489 kfree_skb(inet6_rsk(req)->pktopts); 310 kfree_skb(inet6_rsk(req)->pktopts);
490} 311}
491 312
492static struct request_sock_ops dccp6_request_sock_ops = { 313static void dccp_v6_ctl_send_reset(struct sock *sk, struct sk_buff *rxskb)
493 .family = AF_INET6,
494 .obj_size = sizeof(struct dccp6_request_sock),
495 .rtx_syn_ack = dccp_v6_send_response,
496 .send_ack = dccp_v6_reqsk_send_ack,
497 .destructor = dccp_v6_reqsk_destructor,
498 .send_reset = dccp_v6_ctl_send_reset,
499};
500
501static struct timewait_sock_ops dccp6_timewait_sock_ops = {
502 .twsk_obj_size = sizeof(struct dccp6_timewait_sock),
503};
504
505static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
506{
507 struct ipv6_pinfo *np = inet6_sk(sk);
508 struct dccp_hdr *dh = dccp_hdr(skb);
509
510 dh->dccph_checksum = csum_ipv6_magic(&np->saddr, &np->daddr,
511 len, IPPROTO_DCCP,
512 csum_partial((char *)dh,
513 dh->dccph_doff << 2,
514 skb->csum));
515}
516
517static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
518{ 314{
519 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh; 315 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
520 const u32 dccp_hdr_reset_len = sizeof(struct dccp_hdr) + 316 const u32 dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
@@ -522,7 +318,7 @@ static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
522 sizeof(struct dccp_hdr_reset); 318 sizeof(struct dccp_hdr_reset);
523 struct sk_buff *skb; 319 struct sk_buff *skb;
524 struct flowi fl; 320 struct flowi fl;
525 u64 seqno; 321 u64 seqno = 0;
526 322
527 if (rxdh->dccph_type == DCCP_PKT_RESET) 323 if (rxdh->dccph_type == DCCP_PKT_RESET)
528 return; 324 return;
@@ -537,9 +333,7 @@ static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
537 333
538 skb_reserve(skb, dccp_v6_ctl_socket->sk->sk_prot->max_header); 334 skb_reserve(skb, dccp_v6_ctl_socket->sk->sk_prot->max_header);
539 335
540 skb->h.raw = skb_push(skb, dccp_hdr_reset_len); 336 dh = dccp_zeroed_hdr(skb, dccp_hdr_reset_len);
541 dh = dccp_hdr(skb);
542 memset(dh, 0, dccp_hdr_reset_len);
543 337
544 /* Swap the send and the receive. */ 338 /* Swap the send and the receive. */
545 dh->dccph_type = DCCP_PKT_RESET; 339 dh->dccph_type = DCCP_PKT_RESET;
@@ -551,20 +345,20 @@ static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
551 DCCP_SKB_CB(rxskb)->dccpd_reset_code; 345 DCCP_SKB_CB(rxskb)->dccpd_reset_code;
552 346
553 /* See "8.3.1. Abnormal Termination" in RFC 4340 */ 347 /* See "8.3.1. Abnormal Termination" in RFC 4340 */
554 seqno = 0;
555 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) 348 if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
556 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1); 349 dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1);
557 350
558 dccp_hdr_set_seq(dh, seqno); 351 dccp_hdr_set_seq(dh, seqno);
559 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), 352 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq);
560 DCCP_SKB_CB(rxskb)->dccpd_seq); 353
354 dccp_csum_outgoing(skb);
355 dh->dccph_checksum = dccp_v6_csum_finish(skb, &rxskb->nh.ipv6h->saddr,
356 &rxskb->nh.ipv6h->daddr);
561 357
562 memset(&fl, 0, sizeof(fl)); 358 memset(&fl, 0, sizeof(fl));
563 ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr); 359 ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr);
564 ipv6_addr_copy(&fl.fl6_src, &rxskb->nh.ipv6h->daddr); 360 ipv6_addr_copy(&fl.fl6_src, &rxskb->nh.ipv6h->daddr);
565 dh->dccph_checksum = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst, 361
566 sizeof(*dh), IPPROTO_DCCP,
567 skb->csum);
568 fl.proto = IPPROTO_DCCP; 362 fl.proto = IPPROTO_DCCP;
569 fl.oif = inet6_iif(rxskb); 363 fl.oif = inet6_iif(rxskb);
570 fl.fl_ip_dport = dh->dccph_dport; 364 fl.fl_ip_dport = dh->dccph_dport;
@@ -584,60 +378,14 @@ static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb)
584 kfree_skb(skb); 378 kfree_skb(skb);
585} 379}
586 380
587static void dccp_v6_reqsk_send_ack(struct sk_buff *rxskb, 381static struct request_sock_ops dccp6_request_sock_ops = {
588 struct request_sock *req) 382 .family = AF_INET6,
589{ 383 .obj_size = sizeof(struct dccp6_request_sock),
590 struct flowi fl; 384 .rtx_syn_ack = dccp_v6_send_response,
591 struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh; 385 .send_ack = dccp_reqsk_send_ack,
592 const u32 dccp_hdr_ack_len = sizeof(struct dccp_hdr) + 386 .destructor = dccp_v6_reqsk_destructor,
593 sizeof(struct dccp_hdr_ext) + 387 .send_reset = dccp_v6_ctl_send_reset,
594 sizeof(struct dccp_hdr_ack_bits); 388};
595 struct sk_buff *skb;
596
597 skb = alloc_skb(dccp_v6_ctl_socket->sk->sk_prot->max_header,
598 GFP_ATOMIC);
599 if (skb == NULL)
600 return;
601
602 skb_reserve(skb, dccp_v6_ctl_socket->sk->sk_prot->max_header);
603
604 skb->h.raw = skb_push(skb, dccp_hdr_ack_len);
605 dh = dccp_hdr(skb);
606 memset(dh, 0, dccp_hdr_ack_len);
607
608 /* Build DCCP header and checksum it. */
609 dh->dccph_type = DCCP_PKT_ACK;
610 dh->dccph_sport = rxdh->dccph_dport;
611 dh->dccph_dport = rxdh->dccph_sport;
612 dh->dccph_doff = dccp_hdr_ack_len / 4;
613 dh->dccph_x = 1;
614
615 dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
616 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
617 DCCP_SKB_CB(rxskb)->dccpd_seq);
618
619 memset(&fl, 0, sizeof(fl));
620 ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr);
621 ipv6_addr_copy(&fl.fl6_src, &rxskb->nh.ipv6h->daddr);
622
623 /* FIXME: calculate checksum, IPv4 also should... */
624
625 fl.proto = IPPROTO_DCCP;
626 fl.oif = inet6_iif(rxskb);
627 fl.fl_ip_dport = dh->dccph_dport;
628 fl.fl_ip_sport = dh->dccph_sport;
629 security_req_classify_flow(req, &fl);
630
631 if (!ip6_dst_lookup(NULL, &skb->dst, &fl)) {
632 if (xfrm_lookup(&skb->dst, &fl, NULL, 0) >= 0) {
633 ip6_xmit(dccp_v6_ctl_socket->sk, skb, &fl, NULL, 0);
634 DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
635 return;
636 }
637 }
638
639 kfree_skb(skb);
640}
641 389
642static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) 390static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
643{ 391{
@@ -672,7 +420,6 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb)
672 420
673static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) 421static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
674{ 422{
675 struct dccp_sock dp;
676 struct request_sock *req; 423 struct request_sock *req;
677 struct dccp_request_sock *dreq; 424 struct dccp_request_sock *dreq;
678 struct inet6_request_sock *ireq6; 425 struct inet6_request_sock *ireq6;
@@ -704,9 +451,10 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
704 if (req == NULL) 451 if (req == NULL)
705 goto drop; 452 goto drop;
706 453
707 /* FIXME: process options */ 454 if (dccp_parse_options(sk, skb))
455 goto drop_and_free;
708 456
709 dccp_openreq_init(req, &dp, skb); 457 dccp_reqsk_init(req, skb);
710 458
711 if (security_inet_conn_request(sk, skb, req)) 459 if (security_inet_conn_request(sk, skb, req))
712 goto drop_and_free; 460 goto drop_and_free;
@@ -714,7 +462,6 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
714 ireq6 = inet6_rsk(req); 462 ireq6 = inet6_rsk(req);
715 ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr); 463 ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr);
716 ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr); 464 ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr);
717 req->rcv_wnd = dccp_feat_default_sequence_window;
718 ireq6->pktopts = NULL; 465 ireq6->pktopts = NULL;
719 466
720 if (ipv6_opt_accepted(sk, skb) || 467 if (ipv6_opt_accepted(sk, skb) ||
@@ -733,14 +480,14 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
733 /* 480 /*
734 * Step 3: Process LISTEN state 481 * Step 3: Process LISTEN state
735 * 482 *
736 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie 483 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
737 * 484 *
738 * In fact we defer setting S.GSR, S.SWL, S.SWH to 485 * In fact we defer setting S.GSR, S.SWL, S.SWH to
739 * dccp_create_openreq_child. 486 * dccp_create_openreq_child.
740 */ 487 */
741 dreq = dccp_rsk(req); 488 dreq = dccp_rsk(req);
742 dreq->dreq_isr = dcb->dccpd_seq; 489 dreq->dreq_isr = dcb->dccpd_seq;
743 dreq->dreq_iss = dccp_v6_init_sequence(sk, skb); 490 dreq->dreq_iss = dccp_v6_init_sequence(skb);
744 dreq->dreq_service = service; 491 dreq->dreq_service = service;
745 492
746 if (dccp_v6_send_response(sk, req, NULL)) 493 if (dccp_v6_send_response(sk, req, NULL))
@@ -990,18 +737,46 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
990 --ANK (980728) 737 --ANK (980728)
991 */ 738 */
992 if (np->rxopt.all) 739 if (np->rxopt.all)
740 /*
741 * FIXME: Add handling of IPV6_PKTOPTIONS skb. See the comments below
742 * (wrt ipv6_pktopions) and net/ipv6/tcp_ipv6.c for an example.
743 */
993 opt_skb = skb_clone(skb, GFP_ATOMIC); 744 opt_skb = skb_clone(skb, GFP_ATOMIC);
994 745
995 if (sk->sk_state == DCCP_OPEN) { /* Fast path */ 746 if (sk->sk_state == DCCP_OPEN) { /* Fast path */
996 if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len)) 747 if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len))
997 goto reset; 748 goto reset;
998 if (opt_skb) { 749 if (opt_skb) {
999 /* This is where we would goto ipv6_pktoptions. */ 750 /* XXX This is where we would goto ipv6_pktoptions. */
1000 __kfree_skb(opt_skb); 751 __kfree_skb(opt_skb);
1001 } 752 }
1002 return 0; 753 return 0;
1003 } 754 }
1004 755
756 /*
757 * Step 3: Process LISTEN state
758 * If S.state == LISTEN,
759 * If P.type == Request or P contains a valid Init Cookie option,
760 * (* Must scan the packet's options to check for Init
761 * Cookies. Only Init Cookies are processed here,
762 * however; other options are processed in Step 8. This
763 * scan need only be performed if the endpoint uses Init
764 * Cookies *)
765 * (* Generate a new socket and switch to that socket *)
766 * Set S := new socket for this port pair
767 * S.state = RESPOND
768 * Choose S.ISS (initial seqno) or set from Init Cookies
769 * Initialize S.GAR := S.ISS
770 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies
771 * Continue with S.state == RESPOND
772 * (* A Response packet will be generated in Step 11 *)
773 * Otherwise,
774 * Generate Reset(No Connection) unless P.type == Reset
775 * Drop packet and return
776 *
777 * NOTE: the check for the packet types is done in
778 * dccp_rcv_state_process
779 */
1005 if (sk->sk_state == DCCP_LISTEN) { 780 if (sk->sk_state == DCCP_LISTEN) {
1006 struct sock *nsk = dccp_v6_hnd_req(sk, skb); 781 struct sock *nsk = dccp_v6_hnd_req(sk, skb);
1007 782
@@ -1024,13 +799,13 @@ static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1024 if (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len)) 799 if (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len))
1025 goto reset; 800 goto reset;
1026 if (opt_skb) { 801 if (opt_skb) {
1027 /* This is where we would goto ipv6_pktoptions. */ 802 /* XXX This is where we would goto ipv6_pktoptions. */
1028 __kfree_skb(opt_skb); 803 __kfree_skb(opt_skb);
1029 } 804 }
1030 return 0; 805 return 0;
1031 806
1032reset: 807reset:
1033 dccp_v6_ctl_send_reset(skb); 808 dccp_v6_ctl_send_reset(sk, skb);
1034discard: 809discard:
1035 if (opt_skb != NULL) 810 if (opt_skb != NULL)
1036 __kfree_skb(opt_skb); 811 __kfree_skb(opt_skb);
@@ -1043,12 +818,20 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
1043 const struct dccp_hdr *dh; 818 const struct dccp_hdr *dh;
1044 struct sk_buff *skb = *pskb; 819 struct sk_buff *skb = *pskb;
1045 struct sock *sk; 820 struct sock *sk;
821 int min_cov;
1046 822
1047 /* Step 1: Check header basics: */ 823 /* Step 1: Check header basics */
1048 824
1049 if (dccp_invalid_packet(skb)) 825 if (dccp_invalid_packet(skb))
1050 goto discard_it; 826 goto discard_it;
1051 827
828 /* Step 1: If header checksum is incorrect, drop packet and return. */
829 if (dccp_v6_csum_finish(skb, &skb->nh.ipv6h->saddr,
830 &skb->nh.ipv6h->daddr)) {
831 DCCP_WARN("dropped packet with invalid checksum\n");
832 goto discard_it;
833 }
834
1052 dh = dccp_hdr(skb); 835 dh = dccp_hdr(skb);
1053 836
1054 DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb); 837 DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb);
@@ -1068,11 +851,12 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
1068 /* 851 /*
1069 * Step 2: 852 * Step 2:
1070 * If no socket ... 853 * If no socket ...
1071 * Generate Reset(No Connection) unless P.type == Reset
1072 * Drop packet and return
1073 */ 854 */
1074 if (sk == NULL) 855 if (sk == NULL) {
856 dccp_pr_debug("failed to look up flow ID in table and "
857 "get corresponding socket\n");
1075 goto no_dccp_socket; 858 goto no_dccp_socket;
859 }
1076 860
1077 /* 861 /*
1078 * Step 2: 862 * Step 2:
@@ -1080,43 +864,226 @@ static int dccp_v6_rcv(struct sk_buff **pskb)
1080 * Generate Reset(No Connection) unless P.type == Reset 864 * Generate Reset(No Connection) unless P.type == Reset
1081 * Drop packet and return 865 * Drop packet and return
1082 */ 866 */
1083 if (sk->sk_state == DCCP_TIME_WAIT) 867 if (sk->sk_state == DCCP_TIME_WAIT) {
1084 goto do_time_wait; 868 dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n");
869 inet_twsk_put(inet_twsk(sk));
870 goto no_dccp_socket;
871 }
872
873 /*
874 * RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
875 * o if MinCsCov = 0, only packets with CsCov = 0 are accepted
876 * o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
877 */
878 min_cov = dccp_sk(sk)->dccps_pcrlen;
879 if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
880 dccp_pr_debug("Packet CsCov %d does not satisfy MinCsCov %d\n",
881 dh->dccph_cscov, min_cov);
882 /* FIXME: send Data Dropped option (see also dccp_v4_rcv) */
883 goto discard_and_relse;
884 }
1085 885
1086 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) 886 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
1087 goto discard_and_relse; 887 goto discard_and_relse;
1088 888
1089 return sk_receive_skb(sk, skb) ? -1 : 0; 889 return sk_receive_skb(sk, skb, 1) ? -1 : 0;
1090 890
1091no_dccp_socket: 891no_dccp_socket:
1092 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 892 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
1093 goto discard_it; 893 goto discard_it;
1094 /* 894 /*
1095 * Step 2: 895 * Step 2:
896 * If no socket ...
1096 * Generate Reset(No Connection) unless P.type == Reset 897 * Generate Reset(No Connection) unless P.type == Reset
1097 * Drop packet and return 898 * Drop packet and return
1098 */ 899 */
1099 if (dh->dccph_type != DCCP_PKT_RESET) { 900 if (dh->dccph_type != DCCP_PKT_RESET) {
1100 DCCP_SKB_CB(skb)->dccpd_reset_code = 901 DCCP_SKB_CB(skb)->dccpd_reset_code =
1101 DCCP_RESET_CODE_NO_CONNECTION; 902 DCCP_RESET_CODE_NO_CONNECTION;
1102 dccp_v6_ctl_send_reset(skb); 903 dccp_v6_ctl_send_reset(sk, skb);
1103 } 904 }
1104discard_it:
1105
1106 /*
1107 * Discard frame
1108 */
1109 905
906discard_it:
1110 kfree_skb(skb); 907 kfree_skb(skb);
1111 return 0; 908 return 0;
1112 909
1113discard_and_relse: 910discard_and_relse:
1114 sock_put(sk); 911 sock_put(sk);
1115 goto discard_it; 912 goto discard_it;
913}
1116 914
1117do_time_wait: 915static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
1118 inet_twsk_put(inet_twsk(sk)); 916 int addr_len)
1119 goto no_dccp_socket; 917{
918 struct sockaddr_in6 *usin = (struct sockaddr_in6 *)uaddr;
919 struct inet_connection_sock *icsk = inet_csk(sk);
920 struct inet_sock *inet = inet_sk(sk);
921 struct ipv6_pinfo *np = inet6_sk(sk);
922 struct dccp_sock *dp = dccp_sk(sk);
923 struct in6_addr *saddr = NULL, *final_p = NULL, final;
924 struct flowi fl;
925 struct dst_entry *dst;
926 int addr_type;
927 int err;
928
929 dp->dccps_role = DCCP_ROLE_CLIENT;
930
931 if (addr_len < SIN6_LEN_RFC2133)
932 return -EINVAL;
933
934 if (usin->sin6_family != AF_INET6)
935 return -EAFNOSUPPORT;
936
937 memset(&fl, 0, sizeof(fl));
938
939 if (np->sndflow) {
940 fl.fl6_flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK;
941 IP6_ECN_flow_init(fl.fl6_flowlabel);
942 if (fl.fl6_flowlabel & IPV6_FLOWLABEL_MASK) {
943 struct ip6_flowlabel *flowlabel;
944 flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel);
945 if (flowlabel == NULL)
946 return -EINVAL;
947 ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst);
948 fl6_sock_release(flowlabel);
949 }
950 }
951 /*
952 * connect() to INADDR_ANY means loopback (BSD'ism).
953 */
954 if (ipv6_addr_any(&usin->sin6_addr))
955 usin->sin6_addr.s6_addr[15] = 1;
956
957 addr_type = ipv6_addr_type(&usin->sin6_addr);
958
959 if (addr_type & IPV6_ADDR_MULTICAST)
960 return -ENETUNREACH;
961
962 if (addr_type & IPV6_ADDR_LINKLOCAL) {
963 if (addr_len >= sizeof(struct sockaddr_in6) &&
964 usin->sin6_scope_id) {
965 /* If interface is set while binding, indices
966 * must coincide.
967 */
968 if (sk->sk_bound_dev_if &&
969 sk->sk_bound_dev_if != usin->sin6_scope_id)
970 return -EINVAL;
971
972 sk->sk_bound_dev_if = usin->sin6_scope_id;
973 }
974
975 /* Connect to link-local address requires an interface */
976 if (!sk->sk_bound_dev_if)
977 return -EINVAL;
978 }
979
980 ipv6_addr_copy(&np->daddr, &usin->sin6_addr);
981 np->flow_label = fl.fl6_flowlabel;
982
983 /*
984 * DCCP over IPv4
985 */
986 if (addr_type == IPV6_ADDR_MAPPED) {
987 u32 exthdrlen = icsk->icsk_ext_hdr_len;
988 struct sockaddr_in sin;
989
990 SOCK_DEBUG(sk, "connect: ipv4 mapped\n");
991
992 if (__ipv6_only_sock(sk))
993 return -ENETUNREACH;
994
995 sin.sin_family = AF_INET;
996 sin.sin_port = usin->sin6_port;
997 sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
998
999 icsk->icsk_af_ops = &dccp_ipv6_mapped;
1000 sk->sk_backlog_rcv = dccp_v4_do_rcv;
1001
1002 err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
1003 if (err) {
1004 icsk->icsk_ext_hdr_len = exthdrlen;
1005 icsk->icsk_af_ops = &dccp_ipv6_af_ops;
1006 sk->sk_backlog_rcv = dccp_v6_do_rcv;
1007 goto failure;
1008 } else {
1009 ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000FFFF),
1010 inet->saddr);
1011 ipv6_addr_set(&np->rcv_saddr, 0, 0, htonl(0x0000FFFF),
1012 inet->rcv_saddr);
1013 }
1014
1015 return err;
1016 }
1017
1018 if (!ipv6_addr_any(&np->rcv_saddr))
1019 saddr = &np->rcv_saddr;
1020
1021 fl.proto = IPPROTO_DCCP;
1022 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
1023 ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr);
1024 fl.oif = sk->sk_bound_dev_if;
1025 fl.fl_ip_dport = usin->sin6_port;
1026 fl.fl_ip_sport = inet->sport;
1027 security_sk_classify_flow(sk, &fl);
1028
1029 if (np->opt != NULL && np->opt->srcrt != NULL) {
1030 const struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt;
1031
1032 ipv6_addr_copy(&final, &fl.fl6_dst);
1033 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
1034 final_p = &final;
1035 }
1036
1037 err = ip6_dst_lookup(sk, &dst, &fl);
1038 if (err)
1039 goto failure;
1040
1041 if (final_p)
1042 ipv6_addr_copy(&fl.fl6_dst, final_p);
1043
1044 err = xfrm_lookup(&dst, &fl, sk, 0);
1045 if (err < 0)
1046 goto failure;
1047
1048 if (saddr == NULL) {
1049 saddr = &fl.fl6_src;
1050 ipv6_addr_copy(&np->rcv_saddr, saddr);
1051 }
1052
1053 /* set the source address */
1054 ipv6_addr_copy(&np->saddr, saddr);
1055 inet->rcv_saddr = LOOPBACK4_IPV6;
1056
1057 __ip6_dst_store(sk, dst, NULL, NULL);
1058
1059 icsk->icsk_ext_hdr_len = 0;
1060 if (np->opt != NULL)
1061 icsk->icsk_ext_hdr_len = (np->opt->opt_flen +
1062 np->opt->opt_nflen);
1063
1064 inet->dport = usin->sin6_port;
1065
1066 dccp_set_state(sk, DCCP_REQUESTING);
1067 err = inet6_hash_connect(&dccp_death_row, sk);
1068 if (err)
1069 goto late_failure;
1070
1071 dp->dccps_iss = secure_dccpv6_sequence_number(np->saddr.s6_addr32,
1072 np->daddr.s6_addr32,
1073 inet->sport, inet->dport);
1074 err = dccp_connect(sk);
1075 if (err)
1076 goto late_failure;
1077
1078 return 0;
1079
1080late_failure:
1081 dccp_set_state(sk, DCCP_CLOSED);
1082 __sk_dst_reset(sk);
1083failure:
1084 inet->dport = 0;
1085 sk->sk_route_caps = 0;
1086 return err;
1120} 1087}
1121 1088
1122static struct inet_connection_sock_af_ops dccp_ipv6_af_ops = { 1089static struct inet_connection_sock_af_ops dccp_ipv6_af_ops = {
@@ -1179,6 +1146,10 @@ static int dccp_v6_destroy_sock(struct sock *sk)
1179 return inet6_destroy_sock(sk); 1146 return inet6_destroy_sock(sk);
1180} 1147}
1181 1148
1149static struct timewait_sock_ops dccp6_timewait_sock_ops = {
1150 .twsk_obj_size = sizeof(struct dccp6_timewait_sock),
1151};
1152
1182static struct proto dccp_v6_prot = { 1153static struct proto dccp_v6_prot = {
1183 .name = "DCCPv6", 1154 .name = "DCCPv6",
1184 .owner = THIS_MODULE, 1155 .owner = THIS_MODULE,
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index 36db5be2a9e9..4c9e26775f72 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/dccp.h> 13#include <linux/dccp.h>
14#include <linux/kernel.h>
14#include <linux/skbuff.h> 15#include <linux/skbuff.h>
15#include <linux/timer.h> 16#include <linux/timer.h>
16 17
@@ -82,8 +83,7 @@ void dccp_time_wait(struct sock *sk, int state, int timeo)
82 * socket up. We've got bigger problems than 83 * socket up. We've got bigger problems than
83 * non-graceful socket closings. 84 * non-graceful socket closings.
84 */ 85 */
85 LIMIT_NETDEBUG(KERN_INFO "DCCP: time wait bucket " 86 DCCP_WARN("time wait bucket table overflow\n");
86 "table overflow\n");
87 } 87 }
88 88
89 dccp_done(sk); 89 dccp_done(sk);
@@ -96,8 +96,8 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
96 /* 96 /*
97 * Step 3: Process LISTEN state 97 * Step 3: Process LISTEN state
98 * 98 *
99 * // Generate a new socket and switch to that socket 99 * (* Generate a new socket and switch to that socket *)
100 * Set S := new socket for this port pair 100 * Set S := new socket for this port pair
101 */ 101 */
102 struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC); 102 struct sock *newsk = inet_csk_clone(sk, req, GFP_ATOMIC);
103 103
@@ -146,9 +146,9 @@ out_free:
146 /* 146 /*
147 * Step 3: Process LISTEN state 147 * Step 3: Process LISTEN state
148 * 148 *
149 * Choose S.ISS (initial seqno) or set from Init Cookie 149 * Choose S.ISS (initial seqno) or set from Init Cookies
150 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init 150 * Initialize S.GAR := S.ISS
151 * Cookie 151 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies
152 */ 152 */
153 153
154 /* See dccp_v4_conn_request */ 154 /* See dccp_v4_conn_request */
@@ -194,15 +194,17 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb,
194 194
195 /* Check for retransmitted REQUEST */ 195 /* Check for retransmitted REQUEST */
196 if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) { 196 if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) {
197 if (after48(DCCP_SKB_CB(skb)->dccpd_seq, 197 struct dccp_request_sock *dreq = dccp_rsk(req);
198 dccp_rsk(req)->dreq_isr)) {
199 struct dccp_request_sock *dreq = dccp_rsk(req);
200 198
199 if (after48(DCCP_SKB_CB(skb)->dccpd_seq, dreq->dreq_isr)) {
201 dccp_pr_debug("Retransmitted REQUEST\n"); 200 dccp_pr_debug("Retransmitted REQUEST\n");
202 /* Send another RESPONSE packet */ 201 dreq->dreq_isr = DCCP_SKB_CB(skb)->dccpd_seq;
203 dccp_set_seqno(&dreq->dreq_iss, dreq->dreq_iss + 1); 202 /*
204 dccp_set_seqno(&dreq->dreq_isr, 203 * Send another RESPONSE packet
205 DCCP_SKB_CB(skb)->dccpd_seq); 204 * To protect against Request floods, increment retrans
205 * counter (backoff, monitored by dccp_response_timer).
206 */
207 req->retrans++;
206 req->rsk_ops->rtx_syn_ack(sk, req, NULL); 208 req->rsk_ops->rtx_syn_ack(sk, req, NULL);
207 } 209 }
208 /* Network Duplicate, discard packet */ 210 /* Network Duplicate, discard packet */
@@ -242,7 +244,7 @@ listen_overflow:
242 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY; 244 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY;
243drop: 245drop:
244 if (dccp_hdr(skb)->dccph_type != DCCP_PKT_RESET) 246 if (dccp_hdr(skb)->dccph_type != DCCP_PKT_RESET)
245 req->rsk_ops->send_reset(skb); 247 req->rsk_ops->send_reset(sk, skb);
246 248
247 inet_csk_reqsk_queue_drop(sk, req, prev); 249 inet_csk_reqsk_queue_drop(sk, req, prev);
248 goto out; 250 goto out;
@@ -282,3 +284,19 @@ int dccp_child_process(struct sock *parent, struct sock *child,
282} 284}
283 285
284EXPORT_SYMBOL_GPL(dccp_child_process); 286EXPORT_SYMBOL_GPL(dccp_child_process);
287
288void dccp_reqsk_send_ack(struct sk_buff *skb, struct request_sock *rsk)
289{
290 DCCP_BUG("DCCP-ACK packets are never sent in LISTEN/RESPOND state");
291}
292
293EXPORT_SYMBOL_GPL(dccp_reqsk_send_ack);
294
295void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb)
296{
297 inet_rsk(req)->rmt_port = dccp_hdr(skb)->dccph_sport;
298 inet_rsk(req)->acked = 0;
299 req->rcv_wnd = sysctl_dccp_feat_sequence_window;
300}
301
302EXPORT_SYMBOL_GPL(dccp_reqsk_init);
diff --git a/net/dccp/options.c b/net/dccp/options.c
index fb0db1f7cd7b..f398b43bc055 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -22,23 +22,23 @@
22#include "dccp.h" 22#include "dccp.h"
23#include "feat.h" 23#include "feat.h"
24 24
25int dccp_feat_default_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW; 25int sysctl_dccp_feat_sequence_window = DCCPF_INITIAL_SEQUENCE_WINDOW;
26int dccp_feat_default_rx_ccid = DCCPF_INITIAL_CCID; 26int sysctl_dccp_feat_rx_ccid = DCCPF_INITIAL_CCID;
27int dccp_feat_default_tx_ccid = DCCPF_INITIAL_CCID; 27int sysctl_dccp_feat_tx_ccid = DCCPF_INITIAL_CCID;
28int dccp_feat_default_ack_ratio = DCCPF_INITIAL_ACK_RATIO; 28int sysctl_dccp_feat_ack_ratio = DCCPF_INITIAL_ACK_RATIO;
29int dccp_feat_default_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR; 29int sysctl_dccp_feat_send_ack_vector = DCCPF_INITIAL_SEND_ACK_VECTOR;
30int dccp_feat_default_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT; 30int sysctl_dccp_feat_send_ndp_count = DCCPF_INITIAL_SEND_NDP_COUNT;
31 31
32EXPORT_SYMBOL_GPL(dccp_feat_default_sequence_window); 32EXPORT_SYMBOL_GPL(sysctl_dccp_feat_sequence_window);
33 33
34void dccp_minisock_init(struct dccp_minisock *dmsk) 34void dccp_minisock_init(struct dccp_minisock *dmsk)
35{ 35{
36 dmsk->dccpms_sequence_window = dccp_feat_default_sequence_window; 36 dmsk->dccpms_sequence_window = sysctl_dccp_feat_sequence_window;
37 dmsk->dccpms_rx_ccid = dccp_feat_default_rx_ccid; 37 dmsk->dccpms_rx_ccid = sysctl_dccp_feat_rx_ccid;
38 dmsk->dccpms_tx_ccid = dccp_feat_default_tx_ccid; 38 dmsk->dccpms_tx_ccid = sysctl_dccp_feat_tx_ccid;
39 dmsk->dccpms_ack_ratio = dccp_feat_default_ack_ratio; 39 dmsk->dccpms_ack_ratio = sysctl_dccp_feat_ack_ratio;
40 dmsk->dccpms_send_ack_vector = dccp_feat_default_send_ack_vector; 40 dmsk->dccpms_send_ack_vector = sysctl_dccp_feat_send_ack_vector;
41 dmsk->dccpms_send_ndp_count = dccp_feat_default_send_ndp_count; 41 dmsk->dccpms_send_ndp_count = sysctl_dccp_feat_send_ndp_count;
42} 42}
43 43
44static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len) 44static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len)
@@ -60,12 +60,9 @@ static u32 dccp_decode_value_var(const unsigned char *bf, const u8 len)
60int dccp_parse_options(struct sock *sk, struct sk_buff *skb) 60int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
61{ 61{
62 struct dccp_sock *dp = dccp_sk(sk); 62 struct dccp_sock *dp = dccp_sk(sk);
63#ifdef CONFIG_IP_DCCP_DEBUG
64 const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
65 "CLIENT rx opt: " : "server rx opt: ";
66#endif
67 const struct dccp_hdr *dh = dccp_hdr(skb); 63 const struct dccp_hdr *dh = dccp_hdr(skb);
68 const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type; 64 const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
65 u64 ackno = DCCP_SKB_CB(skb)->dccpd_ack_seq;
69 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb); 66 unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
70 unsigned char *opt_ptr = options; 67 unsigned char *opt_ptr = options;
71 const unsigned char *opt_end = (unsigned char *)dh + 68 const unsigned char *opt_end = (unsigned char *)dh +
@@ -119,7 +116,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
119 goto out_invalid_option; 116 goto out_invalid_option;
120 117
121 opt_recv->dccpor_ndp = dccp_decode_value_var(value, len); 118 opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
122 dccp_pr_debug("%sNDP count=%d\n", debug_prefix, 119 dccp_pr_debug("%s rx opt: NDP count=%d\n", dccp_role(sk),
123 opt_recv->dccpor_ndp); 120 opt_recv->dccpor_ndp);
124 break; 121 break;
125 case DCCPO_CHANGE_L: 122 case DCCPO_CHANGE_L:
@@ -153,7 +150,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
153 break; 150 break;
154 151
155 if (dccp_msk(sk)->dccpms_send_ack_vector && 152 if (dccp_msk(sk)->dccpms_send_ack_vector &&
156 dccp_ackvec_parse(sk, skb, opt, value, len)) 153 dccp_ackvec_parse(sk, skb, &ackno, opt, value, len))
157 goto out_invalid_option; 154 goto out_invalid_option;
158 break; 155 break;
159 case DCCPO_TIMESTAMP: 156 case DCCPO_TIMESTAMP:
@@ -165,8 +162,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
165 dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; 162 dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp;
166 dccp_timestamp(sk, &dp->dccps_timestamp_time); 163 dccp_timestamp(sk, &dp->dccps_timestamp_time);
167 164
168 dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n", 165 dccp_pr_debug("%s rx opt: TIMESTAMP=%u, ackno=%llu\n",
169 debug_prefix, opt_recv->dccpor_timestamp, 166 dccp_role(sk), opt_recv->dccpor_timestamp,
170 (unsigned long long) 167 (unsigned long long)
171 DCCP_SKB_CB(skb)->dccpd_ack_seq); 168 DCCP_SKB_CB(skb)->dccpd_ack_seq);
172 break; 169 break;
@@ -176,8 +173,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
176 173
177 opt_recv->dccpor_timestamp_echo = ntohl(*(__be32 *)value); 174 opt_recv->dccpor_timestamp_echo = ntohl(*(__be32 *)value);
178 175
179 dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, ", 176 dccp_pr_debug("%s rx opt: TIMESTAMP_ECHO=%u, len=%d, "
180 debug_prefix, 177 "ackno=%llu, ", dccp_role(sk),
181 opt_recv->dccpor_timestamp_echo, 178 opt_recv->dccpor_timestamp_echo,
182 len + 2, 179 len + 2,
183 (unsigned long long) 180 (unsigned long long)
@@ -211,8 +208,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
211 if (elapsed_time > opt_recv->dccpor_elapsed_time) 208 if (elapsed_time > opt_recv->dccpor_elapsed_time)
212 opt_recv->dccpor_elapsed_time = elapsed_time; 209 opt_recv->dccpor_elapsed_time = elapsed_time;
213 210
214 dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, 211 dccp_pr_debug("%s rx opt: ELAPSED_TIME=%d\n",
215 elapsed_time); 212 dccp_role(sk), elapsed_time);
216 break; 213 break;
217 /* 214 /*
218 * From RFC 4340, sec. 10.3: 215 * From RFC 4340, sec. 10.3:
@@ -242,9 +239,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
242 } 239 }
243 break; 240 break;
244 default: 241 default:
245 pr_info("DCCP(%p): option %d(len=%d) not " 242 DCCP_CRIT("DCCP(%p): option %d(len=%d) not "
246 "implemented, ignoring\n", 243 "implemented, ignoring", sk, opt, len);
247 sk, opt, len);
248 break; 244 break;
249 } 245 }
250 246
@@ -261,7 +257,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
261out_invalid_option: 257out_invalid_option:
262 DCCP_INC_STATS_BH(DCCP_MIB_INVALIDOPT); 258 DCCP_INC_STATS_BH(DCCP_MIB_INVALIDOPT);
263 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_OPTION_ERROR; 259 DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_OPTION_ERROR;
264 pr_info("DCCP(%p): invalid option %d, len=%d\n", sk, opt, len); 260 DCCP_WARN("DCCP(%p): invalid option %d, len=%d", sk, opt, len);
265 return -1; 261 return -1;
266} 262}
267 263
@@ -451,8 +447,7 @@ static int dccp_insert_feat_opt(struct sk_buff *skb, u8 type, u8 feat,
451 u8 *to; 447 u8 *to;
452 448
453 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 3 > DCCP_MAX_OPT_LEN) { 449 if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 3 > DCCP_MAX_OPT_LEN) {
454 LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small" 450 DCCP_WARN("packet too small for feature %d option!\n", feat);
455 " to insert feature %d option!\n", feat);
456 return -1; 451 return -1;
457 } 452 }
458 453
@@ -465,8 +460,10 @@ static int dccp_insert_feat_opt(struct sk_buff *skb, u8 type, u8 feat,
465 460
466 if (len) 461 if (len)
467 memcpy(to, val, len); 462 memcpy(to, val, len);
468 dccp_pr_debug("option %d feat %d len %d\n", type, feat, len);
469 463
464 dccp_pr_debug("%s(%s (%d), ...), length %d\n",
465 dccp_feat_typename(type),
466 dccp_feat_name(feat), feat, len);
470 return 0; 467 return 0;
471} 468}
472 469
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 7102e3aed4ca..400c30b6fcae 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -88,16 +88,15 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
88 return -EPROTO; 88 return -EPROTO;
89 } 89 }
90 90
91 skb->h.raw = skb_push(skb, dccp_header_size);
92 dh = dccp_hdr(skb);
93 91
94 /* Build DCCP header and checksum it. */ 92 /* Build DCCP header and checksum it. */
95 memset(dh, 0, dccp_header_size); 93 dh = dccp_zeroed_hdr(skb, dccp_header_size);
96 dh->dccph_type = dcb->dccpd_type; 94 dh->dccph_type = dcb->dccpd_type;
97 dh->dccph_sport = inet->sport; 95 dh->dccph_sport = inet->sport;
98 dh->dccph_dport = inet->dport; 96 dh->dccph_dport = inet->dport;
99 dh->dccph_doff = (dccp_header_size + dcb->dccpd_opt_len) / 4; 97 dh->dccph_doff = (dccp_header_size + dcb->dccpd_opt_len) / 4;
100 dh->dccph_ccval = dcb->dccpd_ccval; 98 dh->dccph_ccval = dcb->dccpd_ccval;
99 dh->dccph_cscov = dp->dccps_pcslen;
101 /* XXX For now we're using only 48 bits sequence numbers */ 100 /* XXX For now we're using only 48 bits sequence numbers */
102 dh->dccph_x = 1; 101 dh->dccph_x = 1;
103 102
@@ -117,7 +116,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
117 break; 116 break;
118 } 117 }
119 118
120 icsk->icsk_af_ops->send_check(sk, skb->len, skb); 119 icsk->icsk_af_ops->send_check(sk, 0, skb);
121 120
122 if (set_ack) 121 if (set_ack)
123 dccp_event_ack_sent(sk); 122 dccp_event_ack_sent(sk);
@@ -125,17 +124,8 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
125 DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 124 DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
126 125
127 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); 126 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
128 err = icsk->icsk_af_ops->queue_xmit(skb, 0); 127 err = icsk->icsk_af_ops->queue_xmit(skb, sk, 0);
129 if (err <= 0) 128 return net_xmit_eval(err);
130 return err;
131
132 /* NET_XMIT_CN is special. It does not guarantee,
133 * that this packet is lost. It tells that device
134 * is about to start to drop packets or already
135 * drops some packets of the same priority and
136 * invokes us to send less aggressively.
137 */
138 return err == NET_XMIT_CN ? 0 : err;
139 } 129 }
140 return -ENOBUFS; 130 return -ENOBUFS;
141} 131}
@@ -205,8 +195,7 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
205 if (signal_pending(current)) 195 if (signal_pending(current))
206 goto do_interrupted; 196 goto do_interrupted;
207 197
208 rc = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb, 198 rc = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb);
209 skb->len);
210 if (rc <= 0) 199 if (rc <= 0)
211 break; 200 break;
212 delay = msecs_to_jiffies(rc); 201 delay = msecs_to_jiffies(rc);
@@ -251,25 +240,23 @@ void dccp_write_xmit(struct sock *sk, int block)
251{ 240{
252 struct dccp_sock *dp = dccp_sk(sk); 241 struct dccp_sock *dp = dccp_sk(sk);
253 struct sk_buff *skb; 242 struct sk_buff *skb;
254 long timeo = 30000; /* If a packet is taking longer than 2 secs 243 long timeo = DCCP_XMIT_TIMEO; /* If a packet is taking longer than
255 we have other issues */ 244 this we have other issues */
256 245
257 while ((skb = skb_peek(&sk->sk_write_queue))) { 246 while ((skb = skb_peek(&sk->sk_write_queue))) {
258 int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb, 247 int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb);
259 skb->len);
260 248
261 if (err > 0) { 249 if (err > 0) {
262 if (!block) { 250 if (!block) {
263 sk_reset_timer(sk, &dp->dccps_xmit_timer, 251 sk_reset_timer(sk, &dp->dccps_xmit_timer,
264 msecs_to_jiffies(err)+jiffies); 252 msecs_to_jiffies(err)+jiffies);
265 break; 253 break;
266 } else 254 } else {
267 err = dccp_wait_for_ccid(sk, skb, &timeo); 255 err = dccp_wait_for_ccid(sk, skb, &timeo);
268 if (err) { 256 timeo = DCCP_XMIT_TIMEO;
269 printk(KERN_CRIT "%s:err at dccp_wait_for_ccid"
270 " %d\n", __FUNCTION__, err);
271 dump_stack();
272 } 257 }
258 if (err)
259 DCCP_BUG("err=%d after dccp_wait_for_ccid", err);
273 } 260 }
274 261
275 skb_dequeue(&sk->sk_write_queue); 262 skb_dequeue(&sk->sk_write_queue);
@@ -291,12 +278,9 @@ void dccp_write_xmit(struct sock *sk, int block)
291 278
292 err = dccp_transmit_skb(sk, skb); 279 err = dccp_transmit_skb(sk, skb);
293 ccid_hc_tx_packet_sent(dp->dccps_hc_tx_ccid, sk, 0, len); 280 ccid_hc_tx_packet_sent(dp->dccps_hc_tx_ccid, sk, 0, len);
294 if (err) { 281 if (err)
295 printk(KERN_CRIT "%s:err from " 282 DCCP_BUG("err=%d after ccid_hc_tx_packet_sent",
296 "ccid_hc_tx_packet_sent %d\n", 283 err);
297 __FUNCTION__, err);
298 dump_stack();
299 }
300 } else 284 } else
301 kfree(skb); 285 kfree(skb);
302 } 286 }
@@ -329,9 +313,10 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
329 skb_reserve(skb, sk->sk_prot->max_header); 313 skb_reserve(skb, sk->sk_prot->max_header);
330 314
331 skb->dst = dst_clone(dst); 315 skb->dst = dst_clone(dst);
332 skb->csum = 0;
333 316
334 dreq = dccp_rsk(req); 317 dreq = dccp_rsk(req);
318 if (inet_rsk(req)->acked) /* increase ISS upon retransmission */
319 dccp_inc_seqno(&dreq->dreq_iss);
335 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE; 320 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_RESPONSE;
336 DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss; 321 DCCP_SKB_CB(skb)->dccpd_seq = dreq->dreq_iss;
337 322
@@ -340,10 +325,8 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
340 return NULL; 325 return NULL;
341 } 326 }
342 327
343 skb->h.raw = skb_push(skb, dccp_header_size); 328 /* Build and checksum header */
344 329 dh = dccp_zeroed_hdr(skb, dccp_header_size);
345 dh = dccp_hdr(skb);
346 memset(dh, 0, dccp_header_size);
347 330
348 dh->dccph_sport = inet_sk(sk)->sport; 331 dh->dccph_sport = inet_sk(sk)->sport;
349 dh->dccph_dport = inet_rsk(req)->rmt_port; 332 dh->dccph_dport = inet_rsk(req)->rmt_port;
@@ -355,6 +338,10 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
355 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dreq->dreq_isr); 338 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dreq->dreq_isr);
356 dccp_hdr_response(skb)->dccph_resp_service = dreq->dreq_service; 339 dccp_hdr_response(skb)->dccph_resp_service = dreq->dreq_service;
357 340
341 dccp_csum_outgoing(skb);
342
343 /* We use `acked' to remember that a Response was already sent. */
344 inet_rsk(req)->acked = 1;
358 DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 345 DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
359 return skb; 346 return skb;
360} 347}
@@ -379,7 +366,6 @@ static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
379 skb_reserve(skb, sk->sk_prot->max_header); 366 skb_reserve(skb, sk->sk_prot->max_header);
380 367
381 skb->dst = dst_clone(dst); 368 skb->dst = dst_clone(dst);
382 skb->csum = 0;
383 369
384 dccp_inc_seqno(&dp->dccps_gss); 370 dccp_inc_seqno(&dp->dccps_gss);
385 371
@@ -392,10 +378,7 @@ static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
392 return NULL; 378 return NULL;
393 } 379 }
394 380
395 skb->h.raw = skb_push(skb, dccp_header_size); 381 dh = dccp_zeroed_hdr(skb, dccp_header_size);
396
397 dh = dccp_hdr(skb);
398 memset(dh, 0, dccp_header_size);
399 382
400 dh->dccph_sport = inet_sk(sk)->sport; 383 dh->dccph_sport = inet_sk(sk)->sport;
401 dh->dccph_dport = inet_sk(sk)->dport; 384 dh->dccph_dport = inet_sk(sk)->dport;
@@ -407,7 +390,7 @@ static struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
407 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dp->dccps_gsr); 390 dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), dp->dccps_gsr);
408 391
409 dccp_hdr_reset(skb)->dccph_reset_code = code; 392 dccp_hdr_reset(skb)->dccph_reset_code = code;
410 inet_csk(sk)->icsk_af_ops->send_check(sk, skb->len, skb); 393 inet_csk(sk)->icsk_af_ops->send_check(sk, 0, skb);
411 394
412 DCCP_INC_STATS(DCCP_MIB_OUTSEGS); 395 DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
413 return skb; 396 return skb;
@@ -426,9 +409,8 @@ int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code)
426 code); 409 code);
427 if (skb != NULL) { 410 if (skb != NULL) {
428 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); 411 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
429 err = inet_csk(sk)->icsk_af_ops->queue_xmit(skb, 0); 412 err = inet_csk(sk)->icsk_af_ops->queue_xmit(skb, sk, 0);
430 if (err == NET_XMIT_CN) 413 return net_xmit_eval(err);
431 err = 0;
432 } 414 }
433 } 415 }
434 416
@@ -449,7 +431,6 @@ static inline void dccp_connect_init(struct sock *sk)
449 431
450 dccp_sync_mss(sk, dst_mtu(dst)); 432 dccp_sync_mss(sk, dst_mtu(dst));
451 433
452 dccp_update_gss(sk, dp->dccps_iss);
453 /* 434 /*
454 * SWL and AWL are initially adjusted so that they are not less than 435 * SWL and AWL are initially adjusted so that they are not less than
455 * the initial Sequence Numbers received and sent, respectively: 436 * the initial Sequence Numbers received and sent, respectively:
@@ -458,8 +439,13 @@ static inline void dccp_connect_init(struct sock *sk)
458 * These adjustments MUST be applied only at the beginning of the 439 * These adjustments MUST be applied only at the beginning of the
459 * connection. 440 * connection.
460 */ 441 */
442 dccp_update_gss(sk, dp->dccps_iss);
461 dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss)); 443 dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss));
462 444
445 /* S.GAR - greatest valid acknowledgement number received on a non-Sync;
446 * initialized to S.ISS (sec. 8.5) */
447 dp->dccps_gar = dp->dccps_iss;
448
463 icsk->icsk_retransmits = 0; 449 icsk->icsk_retransmits = 0;
464 init_timer(&dp->dccps_xmit_timer); 450 init_timer(&dp->dccps_xmit_timer);
465 dp->dccps_xmit_timer.data = (unsigned long)sk; 451 dp->dccps_xmit_timer.data = (unsigned long)sk;
@@ -481,7 +467,6 @@ int dccp_connect(struct sock *sk)
481 skb_reserve(skb, sk->sk_prot->max_header); 467 skb_reserve(skb, sk->sk_prot->max_header);
482 468
483 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST; 469 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_REQUEST;
484 skb->csum = 0;
485 470
486 dccp_skb_entail(sk, skb); 471 dccp_skb_entail(sk, skb);
487 dccp_transmit_skb(sk, skb_clone(skb, GFP_KERNEL)); 472 dccp_transmit_skb(sk, skb_clone(skb, GFP_KERNEL));
@@ -513,7 +498,6 @@ void dccp_send_ack(struct sock *sk)
513 498
514 /* Reserve space for headers */ 499 /* Reserve space for headers */
515 skb_reserve(skb, sk->sk_prot->max_header); 500 skb_reserve(skb, sk->sk_prot->max_header);
516 skb->csum = 0;
517 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_ACK; 501 DCCP_SKB_CB(skb)->dccpd_type = DCCP_PKT_ACK;
518 dccp_transmit_skb(sk, skb); 502 dccp_transmit_skb(sk, skb);
519 } 503 }
@@ -567,7 +551,6 @@ void dccp_send_sync(struct sock *sk, const u64 seq,
567 551
568 /* Reserve space for headers and prepare control bits. */ 552 /* Reserve space for headers and prepare control bits. */
569 skb_reserve(skb, sk->sk_prot->max_header); 553 skb_reserve(skb, sk->sk_prot->max_header);
570 skb->csum = 0;
571 DCCP_SKB_CB(skb)->dccpd_type = pkt_type; 554 DCCP_SKB_CB(skb)->dccpd_type = pkt_type;
572 DCCP_SKB_CB(skb)->dccpd_seq = seq; 555 DCCP_SKB_CB(skb)->dccpd_seq = seq;
573 556
@@ -593,7 +576,6 @@ void dccp_send_close(struct sock *sk, const int active)
593 576
594 /* Reserve space for headers and prepare control bits. */ 577 /* Reserve space for headers and prepare control bits. */
595 skb_reserve(skb, sk->sk_prot->max_header); 578 skb_reserve(skb, sk->sk_prot->max_header);
596 skb->csum = 0;
597 DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ? 579 DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ?
598 DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ; 580 DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ;
599 581
diff --git a/net/dccp/probe.c b/net/dccp/probe.c
index 146496fce2e2..f81e37de35d5 100644
--- a/net/dccp/probe.c
+++ b/net/dccp/probe.c
@@ -106,8 +106,10 @@ static int jdccp_sendmsg(struct kiocb *iocb, struct sock *sk,
106} 106}
107 107
108static struct jprobe dccp_send_probe = { 108static struct jprobe dccp_send_probe = {
109 .kp = { .addr = (kprobe_opcode_t *)&dccp_sendmsg, }, 109 .kp = {
110 .entry = (kprobe_opcode_t *)&jdccp_sendmsg, 110 .symbol_name = "dccp_sendmsg",
111 },
112 .entry = JPROBE_ENTRY(jdccp_sendmsg),
111}; 113};
112 114
113static int dccpprobe_open(struct inode *inode, struct file *file) 115static int dccpprobe_open(struct inode *inode, struct file *file)
@@ -160,6 +162,8 @@ static __init int dccpprobe_init(void)
160 init_waitqueue_head(&dccpw.wait); 162 init_waitqueue_head(&dccpw.wait);
161 spin_lock_init(&dccpw.lock); 163 spin_lock_init(&dccpw.lock);
162 dccpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &dccpw.lock); 164 dccpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &dccpw.lock);
165 if (IS_ERR(dccpw.fifo))
166 return PTR_ERR(dccpw.fifo);
163 167
164 if (!proc_net_fops_create(procname, S_IRUSR, &dccpprobe_fops)) 168 if (!proc_net_fops_create(procname, S_IRUSR, &dccpprobe_fops))
165 goto err0; 169 goto err0;
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 72cbdcfc2c65..5ec47d9ee447 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -52,6 +52,9 @@ struct inet_hashinfo __cacheline_aligned dccp_hashinfo = {
52 52
53EXPORT_SYMBOL_GPL(dccp_hashinfo); 53EXPORT_SYMBOL_GPL(dccp_hashinfo);
54 54
55/* the maximum queue length for tx in packets. 0 is no limit */
56int sysctl_dccp_tx_qlen __read_mostly = 5;
57
55void dccp_set_state(struct sock *sk, const int state) 58void dccp_set_state(struct sock *sk, const int state)
56{ 59{
57 const int oldstate = sk->sk_state; 60 const int oldstate = sk->sk_state;
@@ -212,6 +215,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
212 215
213 dccp_init_xmit_timers(sk); 216 dccp_init_xmit_timers(sk);
214 icsk->icsk_rto = DCCP_TIMEOUT_INIT; 217 icsk->icsk_rto = DCCP_TIMEOUT_INIT;
218 icsk->icsk_syn_retries = sysctl_dccp_request_retries;
215 sk->sk_state = DCCP_CLOSED; 219 sk->sk_state = DCCP_CLOSED;
216 sk->sk_write_space = dccp_write_space; 220 sk->sk_write_space = dccp_write_space;
217 icsk->icsk_sync_mss = dccp_sync_mss; 221 icsk->icsk_sync_mss = dccp_sync_mss;
@@ -262,12 +266,12 @@ int dccp_destroy_sock(struct sock *sk)
262 266
263EXPORT_SYMBOL_GPL(dccp_destroy_sock); 267EXPORT_SYMBOL_GPL(dccp_destroy_sock);
264 268
265static inline int dccp_listen_start(struct sock *sk) 269static inline int dccp_listen_start(struct sock *sk, int backlog)
266{ 270{
267 struct dccp_sock *dp = dccp_sk(sk); 271 struct dccp_sock *dp = dccp_sk(sk);
268 272
269 dp->dccps_role = DCCP_ROLE_LISTEN; 273 dp->dccps_role = DCCP_ROLE_LISTEN;
270 return inet_csk_listen_start(sk, TCP_SYNQ_HSIZE); 274 return inet_csk_listen_start(sk, backlog);
271} 275}
272 276
273int dccp_disconnect(struct sock *sk, int flags) 277int dccp_disconnect(struct sock *sk, int flags)
@@ -451,9 +455,8 @@ out_free_val:
451static int do_dccp_setsockopt(struct sock *sk, int level, int optname, 455static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
452 char __user *optval, int optlen) 456 char __user *optval, int optlen)
453{ 457{
454 struct dccp_sock *dp; 458 struct dccp_sock *dp = dccp_sk(sk);
455 int err; 459 int val, err = 0;
456 int val;
457 460
458 if (optlen < sizeof(int)) 461 if (optlen < sizeof(int))
459 return -EINVAL; 462 return -EINVAL;
@@ -465,14 +468,11 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
465 return dccp_setsockopt_service(sk, val, optval, optlen); 468 return dccp_setsockopt_service(sk, val, optval, optlen);
466 469
467 lock_sock(sk); 470 lock_sock(sk);
468 dp = dccp_sk(sk);
469 err = 0;
470
471 switch (optname) { 471 switch (optname) {
472 case DCCP_SOCKOPT_PACKET_SIZE: 472 case DCCP_SOCKOPT_PACKET_SIZE:
473 dp->dccps_packet_size = val; 473 DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
474 err = 0;
474 break; 475 break;
475
476 case DCCP_SOCKOPT_CHANGE_L: 476 case DCCP_SOCKOPT_CHANGE_L:
477 if (optlen != sizeof(struct dccp_so_feat)) 477 if (optlen != sizeof(struct dccp_so_feat))
478 err = -EINVAL; 478 err = -EINVAL;
@@ -481,7 +481,6 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
481 (struct dccp_so_feat __user *) 481 (struct dccp_so_feat __user *)
482 optval); 482 optval);
483 break; 483 break;
484
485 case DCCP_SOCKOPT_CHANGE_R: 484 case DCCP_SOCKOPT_CHANGE_R:
486 if (optlen != sizeof(struct dccp_so_feat)) 485 if (optlen != sizeof(struct dccp_so_feat))
487 err = -EINVAL; 486 err = -EINVAL;
@@ -490,12 +489,26 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
490 (struct dccp_so_feat __user *) 489 (struct dccp_so_feat __user *)
491 optval); 490 optval);
492 break; 491 break;
493 492 case DCCP_SOCKOPT_SEND_CSCOV: /* sender side, RFC 4340, sec. 9.2 */
493 if (val < 0 || val > 15)
494 err = -EINVAL;
495 else
496 dp->dccps_pcslen = val;
497 break;
498 case DCCP_SOCKOPT_RECV_CSCOV: /* receiver side, RFC 4340 sec. 9.2.1 */
499 if (val < 0 || val > 15)
500 err = -EINVAL;
501 else {
502 dp->dccps_pcrlen = val;
503 /* FIXME: add feature negotiation,
504 * ChangeL(MinimumChecksumCoverage, val) */
505 }
506 break;
494 default: 507 default:
495 err = -ENOPROTOOPT; 508 err = -ENOPROTOOPT;
496 break; 509 break;
497 } 510 }
498 511
499 release_sock(sk); 512 release_sock(sk);
500 return err; 513 return err;
501} 514}
@@ -569,12 +582,17 @@ static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
569 582
570 switch (optname) { 583 switch (optname) {
571 case DCCP_SOCKOPT_PACKET_SIZE: 584 case DCCP_SOCKOPT_PACKET_SIZE:
572 val = dp->dccps_packet_size; 585 DCCP_WARN("sockopt(PACKET_SIZE) is deprecated: fix your app\n");
573 len = sizeof(dp->dccps_packet_size); 586 return 0;
574 break;
575 case DCCP_SOCKOPT_SERVICE: 587 case DCCP_SOCKOPT_SERVICE:
576 return dccp_getsockopt_service(sk, len, 588 return dccp_getsockopt_service(sk, len,
577 (__be32 __user *)optval, optlen); 589 (__be32 __user *)optval, optlen);
590 case DCCP_SOCKOPT_SEND_CSCOV:
591 val = dp->dccps_pcslen;
592 break;
593 case DCCP_SOCKOPT_RECV_CSCOV:
594 val = dp->dccps_pcrlen;
595 break;
578 case 128 ... 191: 596 case 128 ... 191:
579 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname, 597 return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname,
580 len, (u32 __user *)optval, optlen); 598 len, (u32 __user *)optval, optlen);
@@ -630,6 +648,13 @@ int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
630 return -EMSGSIZE; 648 return -EMSGSIZE;
631 649
632 lock_sock(sk); 650 lock_sock(sk);
651
652 if (sysctl_dccp_tx_qlen &&
653 (sk->sk_write_queue.qlen >= sysctl_dccp_tx_qlen)) {
654 rc = -EAGAIN;
655 goto out_release;
656 }
657
633 timeo = sock_sndtimeo(sk, noblock); 658 timeo = sock_sndtimeo(sk, noblock);
634 659
635 /* 660 /*
@@ -788,7 +813,7 @@ int inet_dccp_listen(struct socket *sock, int backlog)
788 * FIXME: here it probably should be sk->sk_prot->listen_start 813 * FIXME: here it probably should be sk->sk_prot->listen_start
789 * see tcp_listen_start 814 * see tcp_listen_start
790 */ 815 */
791 err = dccp_listen_start(sk); 816 err = dccp_listen_start(sk, backlog);
792 if (err) 817 if (err)
793 goto out; 818 goto out;
794 } 819 }
@@ -1008,8 +1033,7 @@ static int __init dccp_init(void)
1008 } while (!dccp_hashinfo.ehash && --ehash_order > 0); 1033 } while (!dccp_hashinfo.ehash && --ehash_order > 0);
1009 1034
1010 if (!dccp_hashinfo.ehash) { 1035 if (!dccp_hashinfo.ehash) {
1011 printk(KERN_CRIT "Failed to allocate DCCP " 1036 DCCP_CRIT("Failed to allocate DCCP established hash table");
1012 "established hash table\n");
1013 goto out_free_bind_bucket_cachep; 1037 goto out_free_bind_bucket_cachep;
1014 } 1038 }
1015 1039
@@ -1031,7 +1055,7 @@ static int __init dccp_init(void)
1031 } while (!dccp_hashinfo.bhash && --bhash_order >= 0); 1055 } while (!dccp_hashinfo.bhash && --bhash_order >= 0);
1032 1056
1033 if (!dccp_hashinfo.bhash) { 1057 if (!dccp_hashinfo.bhash) {
1034 printk(KERN_CRIT "Failed to allocate DCCP bind hash table\n"); 1058 DCCP_CRIT("Failed to allocate DCCP bind hash table");
1035 goto out_free_dccp_ehash; 1059 goto out_free_dccp_ehash;
1036 } 1060 }
1037 1061
diff --git a/net/dccp/sysctl.c b/net/dccp/sysctl.c
index 38bc157876f3..fdcfca3e9208 100644
--- a/net/dccp/sysctl.c
+++ b/net/dccp/sysctl.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/sysctl.h> 13#include <linux/sysctl.h>
14#include "dccp.h"
14#include "feat.h" 15#include "feat.h"
15 16
16#ifndef CONFIG_SYSCTL 17#ifndef CONFIG_SYSCTL
@@ -19,53 +20,76 @@
19 20
20static struct ctl_table dccp_default_table[] = { 21static struct ctl_table dccp_default_table[] = {
21 { 22 {
22 .ctl_name = NET_DCCP_DEFAULT_SEQ_WINDOW,
23 .procname = "seq_window", 23 .procname = "seq_window",
24 .data = &dccp_feat_default_sequence_window, 24 .data = &sysctl_dccp_feat_sequence_window,
25 .maxlen = sizeof(dccp_feat_default_sequence_window), 25 .maxlen = sizeof(sysctl_dccp_feat_sequence_window),
26 .mode = 0644, 26 .mode = 0644,
27 .proc_handler = proc_dointvec, 27 .proc_handler = proc_dointvec,
28 }, 28 },
29 { 29 {
30 .ctl_name = NET_DCCP_DEFAULT_RX_CCID,
31 .procname = "rx_ccid", 30 .procname = "rx_ccid",
32 .data = &dccp_feat_default_rx_ccid, 31 .data = &sysctl_dccp_feat_rx_ccid,
33 .maxlen = sizeof(dccp_feat_default_rx_ccid), 32 .maxlen = sizeof(sysctl_dccp_feat_rx_ccid),
34 .mode = 0644, 33 .mode = 0644,
35 .proc_handler = proc_dointvec, 34 .proc_handler = proc_dointvec,
36 }, 35 },
37 { 36 {
38 .ctl_name = NET_DCCP_DEFAULT_TX_CCID,
39 .procname = "tx_ccid", 37 .procname = "tx_ccid",
40 .data = &dccp_feat_default_tx_ccid, 38 .data = &sysctl_dccp_feat_tx_ccid,
41 .maxlen = sizeof(dccp_feat_default_tx_ccid), 39 .maxlen = sizeof(sysctl_dccp_feat_tx_ccid),
42 .mode = 0644, 40 .mode = 0644,
43 .proc_handler = proc_dointvec, 41 .proc_handler = proc_dointvec,
44 }, 42 },
45 { 43 {
46 .ctl_name = NET_DCCP_DEFAULT_ACK_RATIO,
47 .procname = "ack_ratio", 44 .procname = "ack_ratio",
48 .data = &dccp_feat_default_ack_ratio, 45 .data = &sysctl_dccp_feat_ack_ratio,
49 .maxlen = sizeof(dccp_feat_default_ack_ratio), 46 .maxlen = sizeof(sysctl_dccp_feat_ack_ratio),
50 .mode = 0644, 47 .mode = 0644,
51 .proc_handler = proc_dointvec, 48 .proc_handler = proc_dointvec,
52 }, 49 },
53 { 50 {
54 .ctl_name = NET_DCCP_DEFAULT_SEND_ACKVEC,
55 .procname = "send_ackvec", 51 .procname = "send_ackvec",
56 .data = &dccp_feat_default_send_ack_vector, 52 .data = &sysctl_dccp_feat_send_ack_vector,
57 .maxlen = sizeof(dccp_feat_default_send_ack_vector), 53 .maxlen = sizeof(sysctl_dccp_feat_send_ack_vector),
58 .mode = 0644, 54 .mode = 0644,
59 .proc_handler = proc_dointvec, 55 .proc_handler = proc_dointvec,
60 }, 56 },
61 { 57 {
62 .ctl_name = NET_DCCP_DEFAULT_SEND_NDP,
63 .procname = "send_ndp", 58 .procname = "send_ndp",
64 .data = &dccp_feat_default_send_ndp_count, 59 .data = &sysctl_dccp_feat_send_ndp_count,
65 .maxlen = sizeof(dccp_feat_default_send_ndp_count), 60 .maxlen = sizeof(sysctl_dccp_feat_send_ndp_count),
66 .mode = 0644, 61 .mode = 0644,
67 .proc_handler = proc_dointvec, 62 .proc_handler = proc_dointvec,
68 }, 63 },
64 {
65 .procname = "request_retries",
66 .data = &sysctl_dccp_request_retries,
67 .maxlen = sizeof(sysctl_dccp_request_retries),
68 .mode = 0644,
69 .proc_handler = proc_dointvec,
70 },
71 {
72 .procname = "retries1",
73 .data = &sysctl_dccp_retries1,
74 .maxlen = sizeof(sysctl_dccp_retries1),
75 .mode = 0644,
76 .proc_handler = proc_dointvec,
77 },
78 {
79 .procname = "retries2",
80 .data = &sysctl_dccp_retries2,
81 .maxlen = sizeof(sysctl_dccp_retries2),
82 .mode = 0644,
83 .proc_handler = proc_dointvec,
84 },
85 {
86 .procname = "tx_qlen",
87 .data = &sysctl_dccp_tx_qlen,
88 .maxlen = sizeof(sysctl_dccp_tx_qlen),
89 .mode = 0644,
90 .proc_handler = proc_dointvec,
91 },
92
69 { .ctl_name = 0, } 93 { .ctl_name = 0, }
70}; 94};
71 95
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 8447742f5615..e8f519e7f481 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -15,15 +15,10 @@
15 15
16#include "dccp.h" 16#include "dccp.h"
17 17
18static void dccp_write_timer(unsigned long data); 18/* sysctl variables governing numbers of retransmission attempts */
19static void dccp_keepalive_timer(unsigned long data); 19int sysctl_dccp_request_retries __read_mostly = TCP_SYN_RETRIES;
20static void dccp_delack_timer(unsigned long data); 20int sysctl_dccp_retries1 __read_mostly = TCP_RETR1;
21 21int sysctl_dccp_retries2 __read_mostly = TCP_RETR2;
22void dccp_init_xmit_timers(struct sock *sk)
23{
24 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer,
25 &dccp_keepalive_timer);
26}
27 22
28static void dccp_write_err(struct sock *sk) 23static void dccp_write_err(struct sock *sk)
29{ 24{
@@ -44,11 +39,10 @@ static int dccp_write_timeout(struct sock *sk)
44 if (sk->sk_state == DCCP_REQUESTING || sk->sk_state == DCCP_PARTOPEN) { 39 if (sk->sk_state == DCCP_REQUESTING || sk->sk_state == DCCP_PARTOPEN) {
45 if (icsk->icsk_retransmits != 0) 40 if (icsk->icsk_retransmits != 0)
46 dst_negative_advice(&sk->sk_dst_cache); 41 dst_negative_advice(&sk->sk_dst_cache);
47 retry_until = icsk->icsk_syn_retries ? : 42 retry_until = icsk->icsk_syn_retries ?
48 /* FIXME! */ 3 /* FIXME! sysctl_tcp_syn_retries */; 43 : sysctl_dccp_request_retries;
49 } else { 44 } else {
50 if (icsk->icsk_retransmits >= 45 if (icsk->icsk_retransmits >= sysctl_dccp_retries1) {
51 /* FIXME! sysctl_tcp_retries1 */ 5 /* FIXME! */) {
52 /* NOTE. draft-ietf-tcpimpl-pmtud-01.txt requires pmtu 46 /* NOTE. draft-ietf-tcpimpl-pmtud-01.txt requires pmtu
53 black hole detection. :-( 47 black hole detection. :-(
54 48
@@ -72,7 +66,7 @@ static int dccp_write_timeout(struct sock *sk)
72 dst_negative_advice(&sk->sk_dst_cache); 66 dst_negative_advice(&sk->sk_dst_cache);
73 } 67 }
74 68
75 retry_until = /* FIXME! */ 15 /* FIXME! sysctl_tcp_retries2 */; 69 retry_until = sysctl_dccp_retries2;
76 /* 70 /*
77 * FIXME: see tcp_write_timout and tcp_out_of_resources 71 * FIXME: see tcp_write_timout and tcp_out_of_resources
78 */ 72 */
@@ -86,53 +80,6 @@ static int dccp_write_timeout(struct sock *sk)
86 return 0; 80 return 0;
87} 81}
88 82
89/* This is the same as tcp_delack_timer, sans prequeue & mem_reclaim stuff */
90static void dccp_delack_timer(unsigned long data)
91{
92 struct sock *sk = (struct sock *)data;
93 struct inet_connection_sock *icsk = inet_csk(sk);
94
95 bh_lock_sock(sk);
96 if (sock_owned_by_user(sk)) {
97 /* Try again later. */
98 icsk->icsk_ack.blocked = 1;
99 NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKLOCKED);
100 sk_reset_timer(sk, &icsk->icsk_delack_timer,
101 jiffies + TCP_DELACK_MIN);
102 goto out;
103 }
104
105 if (sk->sk_state == DCCP_CLOSED ||
106 !(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
107 goto out;
108 if (time_after(icsk->icsk_ack.timeout, jiffies)) {
109 sk_reset_timer(sk, &icsk->icsk_delack_timer,
110 icsk->icsk_ack.timeout);
111 goto out;
112 }
113
114 icsk->icsk_ack.pending &= ~ICSK_ACK_TIMER;
115
116 if (inet_csk_ack_scheduled(sk)) {
117 if (!icsk->icsk_ack.pingpong) {
118 /* Delayed ACK missed: inflate ATO. */
119 icsk->icsk_ack.ato = min(icsk->icsk_ack.ato << 1,
120 icsk->icsk_rto);
121 } else {
122 /* Delayed ACK missed: leave pingpong mode and
123 * deflate ATO.
124 */
125 icsk->icsk_ack.pingpong = 0;
126 icsk->icsk_ack.ato = TCP_ATO_MIN;
127 }
128 dccp_send_ack(sk);
129 NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKS);
130 }
131out:
132 bh_unlock_sock(sk);
133 sock_put(sk);
134}
135
136/* 83/*
137 * The DCCP retransmit timer. 84 * The DCCP retransmit timer.
138 */ 85 */
@@ -142,7 +89,7 @@ static void dccp_retransmit_timer(struct sock *sk)
142 89
143 /* retransmit timer is used for feature negotiation throughout 90 /* retransmit timer is used for feature negotiation throughout
144 * connection. In this case, no packet is re-transmitted, but rather an 91 * connection. In this case, no packet is re-transmitted, but rather an
145 * ack is generated and pending changes are splaced into its options. 92 * ack is generated and pending changes are placed into its options.
146 */ 93 */
147 if (sk->sk_send_head == NULL) { 94 if (sk->sk_send_head == NULL) {
148 dccp_pr_debug("feat negotiation retransmit timeout %p\n", sk); 95 dccp_pr_debug("feat negotiation retransmit timeout %p\n", sk);
@@ -154,9 +101,11 @@ static void dccp_retransmit_timer(struct sock *sk)
154 /* 101 /*
155 * sk->sk_send_head has to have one skb with 102 * sk->sk_send_head has to have one skb with
156 * DCCP_SKB_CB(skb)->dccpd_type set to one of the retransmittable DCCP 103 * DCCP_SKB_CB(skb)->dccpd_type set to one of the retransmittable DCCP
157 * packet types (REQUEST, RESPONSE, the ACK in the 3way handshake 104 * packet types. The only packets eligible for retransmission are:
158 * (PARTOPEN timer), etc). 105 * -- Requests in client-REQUEST state (sec. 8.1.1)
159 */ 106 * -- Acks in client-PARTOPEN state (sec. 8.1.5)
107 * -- CloseReq in server-CLOSEREQ state (sec. 8.3)
108 * -- Close in node-CLOSING state (sec. 8.3) */
160 BUG_TRAP(sk->sk_send_head != NULL); 109 BUG_TRAP(sk->sk_send_head != NULL);
161 110
162 /* 111 /*
@@ -194,7 +143,7 @@ backoff:
194 icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX); 143 icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX);
195 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, 144 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto,
196 DCCP_RTO_MAX); 145 DCCP_RTO_MAX);
197 if (icsk->icsk_retransmits > 3 /* FIXME: sysctl_dccp_retries1 */) 146 if (icsk->icsk_retransmits > sysctl_dccp_retries1)
198 __sk_dst_reset(sk); 147 __sk_dst_reset(sk);
199out:; 148out:;
200} 149}
@@ -264,3 +213,56 @@ out:
264 bh_unlock_sock(sk); 213 bh_unlock_sock(sk);
265 sock_put(sk); 214 sock_put(sk);
266} 215}
216
217/* This is the same as tcp_delack_timer, sans prequeue & mem_reclaim stuff */
218static void dccp_delack_timer(unsigned long data)
219{
220 struct sock *sk = (struct sock *)data;
221 struct inet_connection_sock *icsk = inet_csk(sk);
222
223 bh_lock_sock(sk);
224 if (sock_owned_by_user(sk)) {
225 /* Try again later. */
226 icsk->icsk_ack.blocked = 1;
227 NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKLOCKED);
228 sk_reset_timer(sk, &icsk->icsk_delack_timer,
229 jiffies + TCP_DELACK_MIN);
230 goto out;
231 }
232
233 if (sk->sk_state == DCCP_CLOSED ||
234 !(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
235 goto out;
236 if (time_after(icsk->icsk_ack.timeout, jiffies)) {
237 sk_reset_timer(sk, &icsk->icsk_delack_timer,
238 icsk->icsk_ack.timeout);
239 goto out;
240 }
241
242 icsk->icsk_ack.pending &= ~ICSK_ACK_TIMER;
243
244 if (inet_csk_ack_scheduled(sk)) {
245 if (!icsk->icsk_ack.pingpong) {
246 /* Delayed ACK missed: inflate ATO. */
247 icsk->icsk_ack.ato = min(icsk->icsk_ack.ato << 1,
248 icsk->icsk_rto);
249 } else {
250 /* Delayed ACK missed: leave pingpong mode and
251 * deflate ATO.
252 */
253 icsk->icsk_ack.pingpong = 0;
254 icsk->icsk_ack.ato = TCP_ATO_MIN;
255 }
256 dccp_send_ack(sk);
257 NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKS);
258 }
259out:
260 bh_unlock_sock(sk);
261 sock_put(sk);
262}
263
264void dccp_init_xmit_timers(struct sock *sk)
265{
266 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer,
267 &dccp_keepalive_timer);
268}
diff --git a/net/decnet/Kconfig b/net/decnet/Kconfig
index 36e72cb145b0..7914fd619c5c 100644
--- a/net/decnet/Kconfig
+++ b/net/decnet/Kconfig
@@ -41,11 +41,3 @@ config DECNET_ROUTER
41 41
42 See <file:Documentation/networking/decnet.txt> for more information. 42 See <file:Documentation/networking/decnet.txt> for more information.
43 43
44config DECNET_ROUTE_FWMARK
45 bool "DECnet: use FWMARK value as routing key (EXPERIMENTAL)"
46 depends on DECNET_ROUTER && NETFILTER
47 help
48 If you say Y here, you will be able to specify different routes for
49 packets with different FWMARK ("firewalling mark") values
50 (see ipchains(8), "-m" argument).
51
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 01861feb608d..0b9d4c955154 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -38,7 +38,6 @@
38#include <linux/if_arp.h> 38#include <linux/if_arp.h>
39#include <linux/if_ether.h> 39#include <linux/if_ether.h>
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/rtnetlink.h>
42#include <linux/sysctl.h> 41#include <linux/sysctl.h>
43#include <linux/notifier.h> 42#include <linux/notifier.h>
44#include <asm/uaccess.h> 43#include <asm/uaccess.h>
@@ -47,6 +46,7 @@
47#include <net/dst.h> 46#include <net/dst.h>
48#include <net/flow.h> 47#include <net/flow.h>
49#include <net/fib_rules.h> 48#include <net/fib_rules.h>
49#include <net/netlink.h>
50#include <net/dn.h> 50#include <net/dn.h>
51#include <net/dn_dev.h> 51#include <net/dn_dev.h>
52#include <net/dn_route.h> 52#include <net/dn_route.h>
@@ -73,7 +73,7 @@ static BLOCKING_NOTIFIER_HEAD(dnaddr_chain);
73 73
74static struct dn_dev *dn_dev_create(struct net_device *dev, int *err); 74static struct dn_dev *dn_dev_create(struct net_device *dev, int *err);
75static void dn_dev_delete(struct net_device *dev); 75static void dn_dev_delete(struct net_device *dev);
76static void rtmsg_ifa(int event, struct dn_ifaddr *ifa); 76static void dn_ifaddr_notify(int event, struct dn_ifaddr *ifa);
77 77
78static int dn_eth_up(struct net_device *); 78static int dn_eth_up(struct net_device *);
79static void dn_eth_down(struct net_device *); 79static void dn_eth_down(struct net_device *);
@@ -255,12 +255,10 @@ static void dn_dev_sysctl_register(struct net_device *dev, struct dn_dev_parms *
255 struct dn_dev_sysctl_table *t; 255 struct dn_dev_sysctl_table *t;
256 int i; 256 int i;
257 257
258 t = kmalloc(sizeof(*t), GFP_KERNEL); 258 t = kmemdup(&dn_dev_sysctl, sizeof(*t), GFP_KERNEL);
259 if (t == NULL) 259 if (t == NULL)
260 return; 260 return;
261 261
262 memcpy(t, &dn_dev_sysctl, sizeof(*t));
263
264 for(i = 0; i < ARRAY_SIZE(t->dn_dev_vars) - 1; i++) { 262 for(i = 0; i < ARRAY_SIZE(t->dn_dev_vars) - 1; i++) {
265 long offset = (long)t->dn_dev_vars[i].data; 263 long offset = (long)t->dn_dev_vars[i].data;
266 t->dn_dev_vars[i].data = ((char *)parms) + offset; 264 t->dn_dev_vars[i].data = ((char *)parms) + offset;
@@ -442,7 +440,7 @@ static void dn_dev_del_ifa(struct dn_dev *dn_db, struct dn_ifaddr **ifap, int de
442 } 440 }
443 } 441 }
444 442
445 rtmsg_ifa(RTM_DELADDR, ifa1); 443 dn_ifaddr_notify(RTM_DELADDR, ifa1);
446 blocking_notifier_call_chain(&dnaddr_chain, NETDEV_DOWN, ifa1); 444 blocking_notifier_call_chain(&dnaddr_chain, NETDEV_DOWN, ifa1);
447 if (destroy) { 445 if (destroy) {
448 dn_dev_free_ifa(ifa1); 446 dn_dev_free_ifa(ifa1);
@@ -477,7 +475,7 @@ static int dn_dev_insert_ifa(struct dn_dev *dn_db, struct dn_ifaddr *ifa)
477 ifa->ifa_next = dn_db->ifa_list; 475 ifa->ifa_next = dn_db->ifa_list;
478 dn_db->ifa_list = ifa; 476 dn_db->ifa_list = ifa;
479 477
480 rtmsg_ifa(RTM_NEWADDR, ifa); 478 dn_ifaddr_notify(RTM_NEWADDR, ifa);
481 blocking_notifier_call_chain(&dnaddr_chain, NETDEV_UP, ifa); 479 blocking_notifier_call_chain(&dnaddr_chain, NETDEV_UP, ifa);
482 480
483 return 0; 481 return 0;
@@ -647,41 +645,62 @@ static struct dn_dev *dn_dev_by_index(int ifindex)
647 return dn_dev; 645 return dn_dev;
648} 646}
649 647
650static int dn_dev_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 648static struct nla_policy dn_ifa_policy[IFA_MAX+1] __read_mostly = {
649 [IFA_ADDRESS] = { .type = NLA_U16 },
650 [IFA_LOCAL] = { .type = NLA_U16 },
651 [IFA_LABEL] = { .type = NLA_STRING,
652 .len = IFNAMSIZ - 1 },
653};
654
655static int dn_nl_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
651{ 656{
652 struct rtattr **rta = arg; 657 struct nlattr *tb[IFA_MAX+1];
653 struct dn_dev *dn_db; 658 struct dn_dev *dn_db;
654 struct ifaddrmsg *ifm = NLMSG_DATA(nlh); 659 struct ifaddrmsg *ifm;
655 struct dn_ifaddr *ifa, **ifap; 660 struct dn_ifaddr *ifa, **ifap;
661 int err = -EADDRNOTAVAIL;
662
663 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
664 if (err < 0)
665 goto errout;
656 666
667 ifm = nlmsg_data(nlh);
657 if ((dn_db = dn_dev_by_index(ifm->ifa_index)) == NULL) 668 if ((dn_db = dn_dev_by_index(ifm->ifa_index)) == NULL)
658 return -EADDRNOTAVAIL; 669 goto errout;
670
671 for (ifap = &dn_db->ifa_list; (ifa = *ifap); ifap = &ifa->ifa_next) {
672 if (tb[IFA_LOCAL] &&
673 nla_memcmp(tb[IFA_LOCAL], &ifa->ifa_local, 2))
674 continue;
659 675
660 for(ifap = &dn_db->ifa_list; (ifa=*ifap) != NULL; ifap = &ifa->ifa_next) { 676 if (tb[IFA_LABEL] && nla_strcmp(tb[IFA_LABEL], ifa->ifa_label))
661 void *tmp = rta[IFA_LOCAL-1];
662 if ((tmp && memcmp(RTA_DATA(tmp), &ifa->ifa_local, 2)) ||
663 (rta[IFA_LABEL-1] && rtattr_strcmp(rta[IFA_LABEL-1], ifa->ifa_label)))
664 continue; 677 continue;
665 678
666 dn_dev_del_ifa(dn_db, ifap, 1); 679 dn_dev_del_ifa(dn_db, ifap, 1);
667 return 0; 680 return 0;
668 } 681 }
669 682
670 return -EADDRNOTAVAIL; 683errout:
684 return err;
671} 685}
672 686
673static int dn_dev_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 687static int dn_nl_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
674{ 688{
675 struct rtattr **rta = arg; 689 struct nlattr *tb[IFA_MAX+1];
676 struct net_device *dev; 690 struct net_device *dev;
677 struct dn_dev *dn_db; 691 struct dn_dev *dn_db;
678 struct ifaddrmsg *ifm = NLMSG_DATA(nlh); 692 struct ifaddrmsg *ifm;
679 struct dn_ifaddr *ifa; 693 struct dn_ifaddr *ifa;
680 int rv; 694 int err;
681 695
682 if (rta[IFA_LOCAL-1] == NULL) 696 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, dn_ifa_policy);
697 if (err < 0)
698 return err;
699
700 if (tb[IFA_LOCAL] == NULL)
683 return -EINVAL; 701 return -EINVAL;
684 702
703 ifm = nlmsg_data(nlh);
685 if ((dev = __dev_get_by_index(ifm->ifa_index)) == NULL) 704 if ((dev = __dev_get_by_index(ifm->ifa_index)) == NULL)
686 return -ENODEV; 705 return -ENODEV;
687 706
@@ -695,69 +714,77 @@ static int dn_dev_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *a
695 if ((ifa = dn_dev_alloc_ifa()) == NULL) 714 if ((ifa = dn_dev_alloc_ifa()) == NULL)
696 return -ENOBUFS; 715 return -ENOBUFS;
697 716
698 if (!rta[IFA_ADDRESS - 1]) 717 if (tb[IFA_ADDRESS] == NULL)
699 rta[IFA_ADDRESS - 1] = rta[IFA_LOCAL - 1]; 718 tb[IFA_ADDRESS] = tb[IFA_LOCAL];
700 memcpy(&ifa->ifa_local, RTA_DATA(rta[IFA_LOCAL-1]), 2); 719
701 memcpy(&ifa->ifa_address, RTA_DATA(rta[IFA_ADDRESS-1]), 2); 720 ifa->ifa_local = nla_get_le16(tb[IFA_LOCAL]);
721 ifa->ifa_address = nla_get_le16(tb[IFA_ADDRESS]);
702 ifa->ifa_flags = ifm->ifa_flags; 722 ifa->ifa_flags = ifm->ifa_flags;
703 ifa->ifa_scope = ifm->ifa_scope; 723 ifa->ifa_scope = ifm->ifa_scope;
704 ifa->ifa_dev = dn_db; 724 ifa->ifa_dev = dn_db;
705 if (rta[IFA_LABEL-1]) 725
706 rtattr_strlcpy(ifa->ifa_label, rta[IFA_LABEL-1], IFNAMSIZ); 726 if (tb[IFA_LABEL])
727 nla_strlcpy(ifa->ifa_label, tb[IFA_LABEL], IFNAMSIZ);
707 else 728 else
708 memcpy(ifa->ifa_label, dev->name, IFNAMSIZ); 729 memcpy(ifa->ifa_label, dev->name, IFNAMSIZ);
709 730
710 rv = dn_dev_insert_ifa(dn_db, ifa); 731 err = dn_dev_insert_ifa(dn_db, ifa);
711 if (rv) 732 if (err)
712 dn_dev_free_ifa(ifa); 733 dn_dev_free_ifa(ifa);
713 return rv; 734
735 return err;
714} 736}
715 737
716static int dn_dev_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa, 738static inline size_t dn_ifaddr_nlmsg_size(void)
717 u32 pid, u32 seq, int event, unsigned int flags) 739{
740 return NLMSG_ALIGN(sizeof(struct ifaddrmsg))
741 + nla_total_size(IFNAMSIZ) /* IFA_LABEL */
742 + nla_total_size(2) /* IFA_ADDRESS */
743 + nla_total_size(2); /* IFA_LOCAL */
744}
745
746static int dn_nl_fill_ifaddr(struct sk_buff *skb, struct dn_ifaddr *ifa,
747 u32 pid, u32 seq, int event, unsigned int flags)
718{ 748{
719 struct ifaddrmsg *ifm; 749 struct ifaddrmsg *ifm;
720 struct nlmsghdr *nlh; 750 struct nlmsghdr *nlh;
721 unsigned char *b = skb->tail;
722 751
723 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*ifm), flags); 752 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*ifm), flags);
724 ifm = NLMSG_DATA(nlh); 753 if (nlh == NULL)
754 return -ENOBUFS;
725 755
756 ifm = nlmsg_data(nlh);
726 ifm->ifa_family = AF_DECnet; 757 ifm->ifa_family = AF_DECnet;
727 ifm->ifa_prefixlen = 16; 758 ifm->ifa_prefixlen = 16;
728 ifm->ifa_flags = ifa->ifa_flags | IFA_F_PERMANENT; 759 ifm->ifa_flags = ifa->ifa_flags | IFA_F_PERMANENT;
729 ifm->ifa_scope = ifa->ifa_scope; 760 ifm->ifa_scope = ifa->ifa_scope;
730 ifm->ifa_index = ifa->ifa_dev->dev->ifindex; 761 ifm->ifa_index = ifa->ifa_dev->dev->ifindex;
762
731 if (ifa->ifa_address) 763 if (ifa->ifa_address)
732 RTA_PUT(skb, IFA_ADDRESS, 2, &ifa->ifa_address); 764 NLA_PUT_LE16(skb, IFA_ADDRESS, ifa->ifa_address);
733 if (ifa->ifa_local) 765 if (ifa->ifa_local)
734 RTA_PUT(skb, IFA_LOCAL, 2, &ifa->ifa_local); 766 NLA_PUT_LE16(skb, IFA_LOCAL, ifa->ifa_local);
735 if (ifa->ifa_label[0]) 767 if (ifa->ifa_label[0])
736 RTA_PUT(skb, IFA_LABEL, IFNAMSIZ, &ifa->ifa_label); 768 NLA_PUT_STRING(skb, IFA_LABEL, ifa->ifa_label);
737 nlh->nlmsg_len = skb->tail - b; 769
738 return skb->len; 770 return nlmsg_end(skb, nlh);
739 771
740nlmsg_failure: 772nla_put_failure:
741rtattr_failure: 773 return nlmsg_cancel(skb, nlh);
742 skb_trim(skb, b - skb->data);
743 return -1;
744} 774}
745 775
746static void rtmsg_ifa(int event, struct dn_ifaddr *ifa) 776static void dn_ifaddr_notify(int event, struct dn_ifaddr *ifa)
747{ 777{
748 struct sk_buff *skb; 778 struct sk_buff *skb;
749 int payload = sizeof(struct ifaddrmsg) + 128;
750 int err = -ENOBUFS; 779 int err = -ENOBUFS;
751 780
752 skb = alloc_skb(nlmsg_total_size(payload), GFP_KERNEL); 781 skb = alloc_skb(dn_ifaddr_nlmsg_size(), GFP_KERNEL);
753 if (skb == NULL) 782 if (skb == NULL)
754 goto errout; 783 goto errout;
755 784
756 err = dn_dev_fill_ifaddr(skb, ifa, 0, 0, event, 0); 785 err = dn_nl_fill_ifaddr(skb, ifa, 0, 0, event, 0);
757 if (err < 0) { 786 /* failure implies BUG in dn_ifaddr_nlmsg_size() */
758 kfree_skb(skb); 787 BUG_ON(err < 0);
759 goto errout;
760 }
761 788
762 err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL); 789 err = rtnl_notify(skb, 0, RTNLGRP_DECnet_IFADDR, NULL, GFP_KERNEL);
763errout: 790errout:
@@ -765,39 +792,43 @@ errout:
765 rtnl_set_sk_err(RTNLGRP_DECnet_IFADDR, err); 792 rtnl_set_sk_err(RTNLGRP_DECnet_IFADDR, err);
766} 793}
767 794
768static int dn_dev_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) 795static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
769{ 796{
770 int idx, dn_idx; 797 int idx, dn_idx = 0, skip_ndevs, skip_naddr;
771 int s_idx, s_dn_idx;
772 struct net_device *dev; 798 struct net_device *dev;
773 struct dn_dev *dn_db; 799 struct dn_dev *dn_db;
774 struct dn_ifaddr *ifa; 800 struct dn_ifaddr *ifa;
775 801
776 s_idx = cb->args[0]; 802 skip_ndevs = cb->args[0];
777 s_dn_idx = dn_idx = cb->args[1]; 803 skip_naddr = cb->args[1];
804
778 read_lock(&dev_base_lock); 805 read_lock(&dev_base_lock);
779 for(dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { 806 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
780 if (idx < s_idx) 807 if (idx < skip_ndevs)
781 continue; 808 continue;
782 if (idx > s_idx) 809 else if (idx > skip_ndevs) {
783 s_dn_idx = 0; 810 /* Only skip over addresses for first dev dumped
811 * in this iteration (idx == skip_ndevs) */
812 skip_naddr = 0;
813 }
814
784 if ((dn_db = dev->dn_ptr) == NULL) 815 if ((dn_db = dev->dn_ptr) == NULL)
785 continue; 816 continue;
786 817
787 for(ifa = dn_db->ifa_list, dn_idx = 0; ifa; ifa = ifa->ifa_next, dn_idx++) { 818 for (ifa = dn_db->ifa_list, dn_idx = 0; ifa;
788 if (dn_idx < s_dn_idx) 819 ifa = ifa->ifa_next, dn_idx++) {
820 if (dn_idx < skip_naddr)
789 continue; 821 continue;
790 822
791 if (dn_dev_fill_ifaddr(skb, ifa, 823 if (dn_nl_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
792 NETLINK_CB(cb->skb).pid, 824 cb->nlh->nlmsg_seq, RTM_NEWADDR,
793 cb->nlh->nlmsg_seq, 825 NLM_F_MULTI) < 0)
794 RTM_NEWADDR,
795 NLM_F_MULTI) <= 0)
796 goto done; 826 goto done;
797 } 827 }
798 } 828 }
799done: 829done:
800 read_unlock(&dev_base_lock); 830 read_unlock(&dev_base_lock);
831
801 cb->args[0] = idx; 832 cb->args[0] = idx;
802 cb->args[1] = dn_idx; 833 cb->args[1] = dn_idx;
803 834
@@ -1414,9 +1445,9 @@ static struct file_operations dn_dev_seq_fops = {
1414 1445
1415static struct rtnetlink_link dnet_rtnetlink_table[RTM_NR_MSGTYPES] = 1446static struct rtnetlink_link dnet_rtnetlink_table[RTM_NR_MSGTYPES] =
1416{ 1447{
1417 [RTM_NEWADDR - RTM_BASE] = { .doit = dn_dev_rtm_newaddr, }, 1448 [RTM_NEWADDR - RTM_BASE] = { .doit = dn_nl_newaddr, },
1418 [RTM_DELADDR - RTM_BASE] = { .doit = dn_dev_rtm_deladdr, }, 1449 [RTM_DELADDR - RTM_BASE] = { .doit = dn_nl_deladdr, },
1419 [RTM_GETADDR - RTM_BASE] = { .dumpit = dn_dev_dump_ifaddr, }, 1450 [RTM_GETADDR - RTM_BASE] = { .dumpit = dn_nl_dump_ifaddr, },
1420#ifdef CONFIG_DECNET_ROUTER 1451#ifdef CONFIG_DECNET_ROUTER
1421 [RTM_NEWROUTE - RTM_BASE] = { .doit = dn_fib_rtm_newroute, }, 1452 [RTM_NEWROUTE - RTM_BASE] = { .doit = dn_fib_rtm_newroute, },
1422 [RTM_DELROUTE - RTM_BASE] = { .doit = dn_fib_rtm_delroute, }, 1453 [RTM_DELROUTE - RTM_BASE] = { .doit = dn_fib_rtm_delroute, },
diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c
index ff0ebe99137d..7322bb36e825 100644
--- a/net/decnet/dn_neigh.c
+++ b/net/decnet/dn_neigh.c
@@ -591,7 +591,6 @@ static int dn_neigh_seq_open(struct inode *inode, struct file *file)
591 591
592 seq = file->private_data; 592 seq = file->private_data;
593 seq->private = s; 593 seq->private = s;
594 memset(s, 0, sizeof(*s));
595out: 594out:
596 return rc; 595 return rc;
597out_kfree: 596out_kfree:
diff --git a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c
index 7683d4f754d2..39a6cf7fb566 100644
--- a/net/decnet/dn_nsp_in.c
+++ b/net/decnet/dn_nsp_in.c
@@ -804,7 +804,7 @@ got_it:
804 goto free_out; 804 goto free_out;
805 } 805 }
806 806
807 return sk_receive_skb(sk, skb); 807 return sk_receive_skb(sk, skb, 0);
808 } 808 }
809 809
810 return dn_nsp_no_socket(skb, reason); 810 return dn_nsp_no_socket(skb, reason);
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 23489f7232d2..9881933167bd 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -269,9 +269,7 @@ static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
269{ 269{
270 return ((fl1->nl_u.dn_u.daddr ^ fl2->nl_u.dn_u.daddr) | 270 return ((fl1->nl_u.dn_u.daddr ^ fl2->nl_u.dn_u.daddr) |
271 (fl1->nl_u.dn_u.saddr ^ fl2->nl_u.dn_u.saddr) | 271 (fl1->nl_u.dn_u.saddr ^ fl2->nl_u.dn_u.saddr) |
272#ifdef CONFIG_DECNET_ROUTE_FWMARK 272 (fl1->mark ^ fl2->mark) |
273 (fl1->nl_u.dn_u.fwmark ^ fl2->nl_u.dn_u.fwmark) |
274#endif
275 (fl1->nl_u.dn_u.scope ^ fl2->nl_u.dn_u.scope) | 273 (fl1->nl_u.dn_u.scope ^ fl2->nl_u.dn_u.scope) |
276 (fl1->oif ^ fl2->oif) | 274 (fl1->oif ^ fl2->oif) |
277 (fl1->iif ^ fl2->iif)) == 0; 275 (fl1->iif ^ fl2->iif)) == 0;
@@ -882,10 +880,8 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
882 { .daddr = oldflp->fld_dst, 880 { .daddr = oldflp->fld_dst,
883 .saddr = oldflp->fld_src, 881 .saddr = oldflp->fld_src,
884 .scope = RT_SCOPE_UNIVERSE, 882 .scope = RT_SCOPE_UNIVERSE,
885#ifdef CONFIG_DECNET_ROUTE_FWMARK
886 .fwmark = oldflp->fld_fwmark
887#endif
888 } }, 883 } },
884 .mark = oldflp->mark,
889 .iif = loopback_dev.ifindex, 885 .iif = loopback_dev.ifindex,
890 .oif = oldflp->oif }; 886 .oif = oldflp->oif };
891 struct dn_route *rt = NULL; 887 struct dn_route *rt = NULL;
@@ -903,7 +899,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
903 "dn_route_output_slow: dst=%04x src=%04x mark=%d" 899 "dn_route_output_slow: dst=%04x src=%04x mark=%d"
904 " iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst), 900 " iif=%d oif=%d\n", dn_ntohs(oldflp->fld_dst),
905 dn_ntohs(oldflp->fld_src), 901 dn_ntohs(oldflp->fld_src),
906 oldflp->fld_fwmark, loopback_dev.ifindex, oldflp->oif); 902 oldflp->mark, loopback_dev.ifindex, oldflp->oif);
907 903
908 /* If we have an output interface, verify its a DECnet device */ 904 /* If we have an output interface, verify its a DECnet device */
909 if (oldflp->oif) { 905 if (oldflp->oif) {
@@ -1108,9 +1104,7 @@ make_route:
1108 rt->fl.fld_dst = oldflp->fld_dst; 1104 rt->fl.fld_dst = oldflp->fld_dst;
1109 rt->fl.oif = oldflp->oif; 1105 rt->fl.oif = oldflp->oif;
1110 rt->fl.iif = 0; 1106 rt->fl.iif = 0;
1111#ifdef CONFIG_DECNET_ROUTE_FWMARK 1107 rt->fl.mark = oldflp->mark;
1112 rt->fl.fld_fwmark = oldflp->fld_fwmark;
1113#endif
1114 1108
1115 rt->rt_saddr = fl.fld_src; 1109 rt->rt_saddr = fl.fld_src;
1116 rt->rt_daddr = fl.fld_dst; 1110 rt->rt_daddr = fl.fld_dst;
@@ -1178,9 +1172,7 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *fl
1178 rt = rcu_dereference(rt->u.rt_next)) { 1172 rt = rcu_dereference(rt->u.rt_next)) {
1179 if ((flp->fld_dst == rt->fl.fld_dst) && 1173 if ((flp->fld_dst == rt->fl.fld_dst) &&
1180 (flp->fld_src == rt->fl.fld_src) && 1174 (flp->fld_src == rt->fl.fld_src) &&
1181#ifdef CONFIG_DECNET_ROUTE_FWMARK 1175 (flp->mark == rt->fl.mark) &&
1182 (flp->fld_fwmark == rt->fl.fld_fwmark) &&
1183#endif
1184 (rt->fl.iif == 0) && 1176 (rt->fl.iif == 0) &&
1185 (rt->fl.oif == flp->oif)) { 1177 (rt->fl.oif == flp->oif)) {
1186 rt->u.dst.lastuse = jiffies; 1178 rt->u.dst.lastuse = jiffies;
@@ -1235,10 +1227,8 @@ static int dn_route_input_slow(struct sk_buff *skb)
1235 { .daddr = cb->dst, 1227 { .daddr = cb->dst,
1236 .saddr = cb->src, 1228 .saddr = cb->src,
1237 .scope = RT_SCOPE_UNIVERSE, 1229 .scope = RT_SCOPE_UNIVERSE,
1238#ifdef CONFIG_DECNET_ROUTE_FWMARK
1239 .fwmark = skb->nfmark
1240#endif
1241 } }, 1230 } },
1231 .mark = skb->mark,
1242 .iif = skb->dev->ifindex }; 1232 .iif = skb->dev->ifindex };
1243 struct dn_fib_res res = { .fi = NULL, .type = RTN_UNREACHABLE }; 1233 struct dn_fib_res res = { .fi = NULL, .type = RTN_UNREACHABLE };
1244 int err = -EINVAL; 1234 int err = -EINVAL;
@@ -1385,7 +1375,7 @@ make_route:
1385 rt->fl.fld_dst = cb->dst; 1375 rt->fl.fld_dst = cb->dst;
1386 rt->fl.oif = 0; 1376 rt->fl.oif = 0;
1387 rt->fl.iif = in_dev->ifindex; 1377 rt->fl.iif = in_dev->ifindex;
1388 rt->fl.fld_fwmark = fl.fld_fwmark; 1378 rt->fl.mark = fl.mark;
1389 1379
1390 rt->u.dst.flags = DST_HOST; 1380 rt->u.dst.flags = DST_HOST;
1391 rt->u.dst.neighbour = neigh; 1381 rt->u.dst.neighbour = neigh;
@@ -1457,9 +1447,7 @@ int dn_route_input(struct sk_buff *skb)
1457 if ((rt->fl.fld_src == cb->src) && 1447 if ((rt->fl.fld_src == cb->src) &&
1458 (rt->fl.fld_dst == cb->dst) && 1448 (rt->fl.fld_dst == cb->dst) &&
1459 (rt->fl.oif == 0) && 1449 (rt->fl.oif == 0) &&
1460#ifdef CONFIG_DECNET_ROUTE_FWMARK 1450 (rt->fl.mark == skb->mark) &&
1461 (rt->fl.fld_fwmark == skb->nfmark) &&
1462#endif
1463 (rt->fl.iif == cb->iif)) { 1451 (rt->fl.iif == cb->iif)) {
1464 rt->u.dst.lastuse = jiffies; 1452 rt->u.dst.lastuse = jiffies;
1465 dst_hold(&rt->u.dst); 1453 dst_hold(&rt->u.dst);
@@ -1481,7 +1469,7 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
1481 struct rtmsg *r; 1469 struct rtmsg *r;
1482 struct nlmsghdr *nlh; 1470 struct nlmsghdr *nlh;
1483 unsigned char *b = skb->tail; 1471 unsigned char *b = skb->tail;
1484 struct rta_cacheinfo ci; 1472 long expires;
1485 1473
1486 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*r), flags); 1474 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*r), flags);
1487 r = NLMSG_DATA(nlh); 1475 r = NLMSG_DATA(nlh);
@@ -1514,16 +1502,10 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
1514 RTA_PUT(skb, RTA_GATEWAY, 2, &rt->rt_gateway); 1502 RTA_PUT(skb, RTA_GATEWAY, 2, &rt->rt_gateway);
1515 if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0) 1503 if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0)
1516 goto rtattr_failure; 1504 goto rtattr_failure;
1517 ci.rta_lastuse = jiffies_to_clock_t(jiffies - rt->u.dst.lastuse); 1505 expires = rt->u.dst.expires ? rt->u.dst.expires - jiffies : 0;
1518 ci.rta_used = rt->u.dst.__use; 1506 if (rtnl_put_cacheinfo(skb, &rt->u.dst, 0, 0, 0, expires,
1519 ci.rta_clntref = atomic_read(&rt->u.dst.__refcnt); 1507 rt->u.dst.error) < 0)
1520 if (rt->u.dst.expires) 1508 goto rtattr_failure;
1521 ci.rta_expires = jiffies_to_clock_t(rt->u.dst.expires - jiffies);
1522 else
1523 ci.rta_expires = 0;
1524 ci.rta_error = rt->u.dst.error;
1525 ci.rta_id = ci.rta_ts = ci.rta_tsage = 0;
1526 RTA_PUT(skb, RTA_CACHEINFO, sizeof(ci), &ci);
1527 if (rt->fl.iif) 1509 if (rt->fl.iif)
1528 RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->fl.iif); 1510 RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->fl.iif);
1529 1511
@@ -1604,8 +1586,6 @@ int dn_cache_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void *arg)
1604 if (rtm->rtm_flags & RTM_F_NOTIFY) 1586 if (rtm->rtm_flags & RTM_F_NOTIFY)
1605 rt->rt_flags |= RTCF_NOTIFY; 1587 rt->rt_flags |= RTCF_NOTIFY;
1606 1588
1607 NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid;
1608
1609 err = dn_rt_fill_info(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq, RTM_NEWROUTE, 0, 0); 1589 err = dn_rt_fill_info(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq, RTM_NEWROUTE, 0, 0);
1610 1590
1611 if (err == 0) 1591 if (err == 0)
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index 590e0a72495c..e32d0c3d5a96 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -45,10 +45,6 @@ struct dn_fib_rule
45 __le16 dstmask; 45 __le16 dstmask;
46 __le16 srcmap; 46 __le16 srcmap;
47 u8 flags; 47 u8 flags;
48#ifdef CONFIG_DECNET_ROUTE_FWMARK
49 u32 fwmark;
50 u32 fwmask;
51#endif
52}; 48};
53 49
54static struct dn_fib_rule default_rule = { 50static struct dn_fib_rule default_rule = {
@@ -112,13 +108,9 @@ errout:
112} 108}
113 109
114static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = { 110static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = {
115 [FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, 111 FRA_GENERIC_POLICY,
116 [FRA_PRIORITY] = { .type = NLA_U32 },
117 [FRA_SRC] = { .type = NLA_U16 }, 112 [FRA_SRC] = { .type = NLA_U16 },
118 [FRA_DST] = { .type = NLA_U16 }, 113 [FRA_DST] = { .type = NLA_U16 },
119 [FRA_FWMARK] = { .type = NLA_U32 },
120 [FRA_FWMASK] = { .type = NLA_U32 },
121 [FRA_TABLE] = { .type = NLA_U32 },
122}; 114};
123 115
124static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) 116static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
@@ -131,11 +123,6 @@ static int dn_fib_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
131 ((daddr ^ r->dst) & r->dstmask)) 123 ((daddr ^ r->dst) & r->dstmask))
132 return 0; 124 return 0;
133 125
134#ifdef CONFIG_DECNET_ROUTE_FWMARK
135 if ((r->fwmark ^ fl->fld_fwmark) & r->fwmask)
136 return 0;
137#endif
138
139 return 1; 126 return 1;
140} 127}
141 128
@@ -169,20 +156,6 @@ static int dn_fib_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
169 if (tb[FRA_DST]) 156 if (tb[FRA_DST])
170 r->dst = nla_get_u16(tb[FRA_DST]); 157 r->dst = nla_get_u16(tb[FRA_DST]);
171 158
172#ifdef CONFIG_DECNET_ROUTE_FWMARK
173 if (tb[FRA_FWMARK]) {
174 r->fwmark = nla_get_u32(tb[FRA_FWMARK]);
175 if (r->fwmark)
176 /* compatibility: if the mark value is non-zero all bits
177 * are compared unless a mask is explicitly specified.
178 */
179 r->fwmask = 0xFFFFFFFF;
180 }
181
182 if (tb[FRA_FWMASK])
183 r->fwmask = nla_get_u32(tb[FRA_FWMASK]);
184#endif
185
186 r->src_len = frh->src_len; 159 r->src_len = frh->src_len;
187 r->srcmask = dnet_make_mask(r->src_len); 160 r->srcmask = dnet_make_mask(r->src_len);
188 r->dst_len = frh->dst_len; 161 r->dst_len = frh->dst_len;
@@ -203,14 +176,6 @@ static int dn_fib_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
203 if (frh->dst_len && (r->dst_len != frh->dst_len)) 176 if (frh->dst_len && (r->dst_len != frh->dst_len))
204 return 0; 177 return 0;
205 178
206#ifdef CONFIG_DECNET_ROUTE_FWMARK
207 if (tb[FRA_FWMARK] && (r->fwmark != nla_get_u32(tb[FRA_FWMARK])))
208 return 0;
209
210 if (tb[FRA_FWMASK] && (r->fwmask != nla_get_u32(tb[FRA_FWMASK])))
211 return 0;
212#endif
213
214 if (tb[FRA_SRC] && (r->src != nla_get_u16(tb[FRA_SRC]))) 179 if (tb[FRA_SRC] && (r->src != nla_get_u16(tb[FRA_SRC])))
215 return 0; 180 return 0;
216 181
@@ -248,12 +213,6 @@ static int dn_fib_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
248 frh->src_len = r->src_len; 213 frh->src_len = r->src_len;
249 frh->tos = 0; 214 frh->tos = 0;
250 215
251#ifdef CONFIG_DECNET_ROUTE_FWMARK
252 if (r->fwmark)
253 NLA_PUT_U32(skb, FRA_FWMARK, r->fwmark);
254 if (r->fwmask || r->fwmark)
255 NLA_PUT_U32(skb, FRA_FWMASK, r->fwmask);
256#endif
257 if (r->dst_len) 216 if (r->dst_len)
258 NLA_PUT_U16(skb, FRA_DST, r->dst); 217 NLA_PUT_U16(skb, FRA_DST, r->dst);
259 if (r->src_len) 218 if (r->src_len)
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index 317904bb5896..bdbc3f431668 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -263,6 +263,32 @@ static int dn_fib_nh_match(struct rtmsg *r, struct nlmsghdr *nlh, struct dn_kern
263 return 0; 263 return 0;
264} 264}
265 265
266static inline size_t dn_fib_nlmsg_size(struct dn_fib_info *fi)
267{
268 size_t payload = NLMSG_ALIGN(sizeof(struct rtmsg))
269 + nla_total_size(4) /* RTA_TABLE */
270 + nla_total_size(2) /* RTA_DST */
271 + nla_total_size(4); /* RTA_PRIORITY */
272
273 /* space for nested metrics */
274 payload += nla_total_size((RTAX_MAX * nla_total_size(4)));
275
276 if (fi->fib_nhs) {
277 /* Also handles the special case fib_nhs == 1 */
278
279 /* each nexthop is packed in an attribute */
280 size_t nhsize = nla_total_size(sizeof(struct rtnexthop));
281
282 /* may contain a gateway attribute */
283 nhsize += nla_total_size(4);
284
285 /* all nexthops are packed in a nested attribute */
286 payload += nla_total_size(fi->fib_nhs * nhsize);
287 }
288
289 return payload;
290}
291
266static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event, 292static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
267 u32 tb_id, u8 type, u8 scope, void *dst, int dst_len, 293 u32 tb_id, u8 type, u8 scope, void *dst, int dst_len,
268 struct dn_fib_info *fi, unsigned int flags) 294 struct dn_fib_info *fi, unsigned int flags)
@@ -335,17 +361,15 @@ static void dn_rtmsg_fib(int event, struct dn_fib_node *f, int z, u32 tb_id,
335 u32 pid = req ? req->pid : 0; 361 u32 pid = req ? req->pid : 0;
336 int err = -ENOBUFS; 362 int err = -ENOBUFS;
337 363
338 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 364 skb = nlmsg_new(dn_fib_nlmsg_size(DN_FIB_INFO(f)), GFP_KERNEL);
339 if (skb == NULL) 365 if (skb == NULL)
340 goto errout; 366 goto errout;
341 367
342 err = dn_fib_dump_info(skb, pid, nlh->nlmsg_seq, event, tb_id, 368 err = dn_fib_dump_info(skb, pid, nlh->nlmsg_seq, event, tb_id,
343 f->fn_type, f->fn_scope, &f->fn_key, z, 369 f->fn_type, f->fn_scope, &f->fn_key, z,
344 DN_FIB_INFO(f), 0); 370 DN_FIB_INFO(f), 0);
345 if (err < 0) { 371 /* failure implies BUG in dn_fib_nlmsg_size() */
346 kfree_skb(skb); 372 BUG_ON(err < 0);
347 goto errout;
348 }
349 373
350 err = rtnl_notify(skb, pid, RTNLGRP_DECnet_ROUTE, nlh, GFP_KERNEL); 374 err = rtnl_notify(skb, pid, RTNLGRP_DECnet_ROUTE, nlh, GFP_KERNEL);
351errout: 375errout:
@@ -807,10 +831,11 @@ struct dn_fib_table *dn_fib_get_table(u32 n, int create)
807 printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n"); 831 printk(KERN_DEBUG "DECnet: BUG! Attempt to create routing table from interrupt\n");
808 return NULL; 832 return NULL;
809 } 833 }
810 if ((t = kmalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash), GFP_KERNEL)) == NULL)
811 return NULL;
812 834
813 memset(t, 0, sizeof(struct dn_fib_table)); 835 t = kzalloc(sizeof(struct dn_fib_table) + sizeof(struct dn_hash),
836 GFP_KERNEL);
837 if (t == NULL)
838 return NULL;
814 839
815 t->n = n; 840 t->n = n;
816 t->insert = dn_fib_table_insert; 841 t->insert = dn_fib_table_insert;
@@ -818,7 +843,6 @@ struct dn_fib_table *dn_fib_get_table(u32 n, int create)
818 t->lookup = dn_fib_table_lookup; 843 t->lookup = dn_fib_table_lookup;
819 t->flush = dn_fib_table_flush; 844 t->flush = dn_fib_table_flush;
820 t->dump = dn_fib_table_dump; 845 t->dump = dn_fib_table_dump;
821 memset(t->data, 0, sizeof(struct dn_hash));
822 hlist_add_head_rcu(&t->hlist, &dn_fib_table_hash[h]); 846 hlist_add_head_rcu(&t->hlist, &dn_fib_table_hash[h]);
823 847
824 return t; 848 return t;
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 4bd78c8cfb26..2d31bf3f05c5 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -60,7 +60,6 @@
60#include <net/ip.h> 60#include <net/ip.h>
61#include <asm/uaccess.h> 61#include <asm/uaccess.h>
62#include <asm/system.h> 62#include <asm/system.h>
63#include <asm/checksum.h>
64 63
65__setup("ether=", netdev_boot_setup); 64__setup("ether=", netdev_boot_setup);
66 65
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c
index 13b1e5fff7e4..b1c6d1f717d9 100644
--- a/net/ieee80211/ieee80211_module.c
+++ b/net/ieee80211/ieee80211_module.c
@@ -67,7 +67,7 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee)
67 return 0; 67 return 0;
68 68
69 ieee->networks = 69 ieee->networks =
70 kmalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network), 70 kzalloc(MAX_NETWORK_COUNT * sizeof(struct ieee80211_network),
71 GFP_KERNEL); 71 GFP_KERNEL);
72 if (!ieee->networks) { 72 if (!ieee->networks) {
73 printk(KERN_WARNING "%s: Out of memory allocating beacons\n", 73 printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
@@ -75,9 +75,6 @@ static int ieee80211_networks_allocate(struct ieee80211_device *ieee)
75 return -ENOMEM; 75 return -ENOMEM;
76 } 76 }
77 77
78 memset(ieee->networks, 0,
79 MAX_NETWORK_COUNT * sizeof(struct ieee80211_network));
80
81 return 0; 78 return 0;
82} 79}
83 80
@@ -118,6 +115,21 @@ static void ieee80211_networks_initialize(struct ieee80211_device *ieee)
118 &ieee->network_free_list); 115 &ieee->network_free_list);
119} 116}
120 117
118static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
119{
120 if ((new_mtu < 68) || (new_mtu > IEEE80211_DATA_LEN))
121 return -EINVAL;
122 dev->mtu = new_mtu;
123 return 0;
124}
125
126static struct net_device_stats *ieee80211_generic_get_stats(
127 struct net_device *dev)
128{
129 struct ieee80211_device *ieee = netdev_priv(dev);
130 return &ieee->stats;
131}
132
121struct net_device *alloc_ieee80211(int sizeof_priv) 133struct net_device *alloc_ieee80211(int sizeof_priv)
122{ 134{
123 struct ieee80211_device *ieee; 135 struct ieee80211_device *ieee;
@@ -133,6 +145,11 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
133 } 145 }
134 ieee = netdev_priv(dev); 146 ieee = netdev_priv(dev);
135 dev->hard_start_xmit = ieee80211_xmit; 147 dev->hard_start_xmit = ieee80211_xmit;
148 dev->change_mtu = ieee80211_change_mtu;
149
150 /* Drivers are free to override this if the generic implementation
151 * does not meet their needs. */
152 dev->get_stats = ieee80211_generic_get_stats;
136 153
137 ieee->dev = dev; 154 ieee->dev = dev;
138 155
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index 2759312a4204..d97e5412e31b 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -415,17 +415,16 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
415 ieee->host_mc_decrypt : ieee->host_decrypt; 415 ieee->host_mc_decrypt : ieee->host_decrypt;
416 416
417 if (can_be_decrypted) { 417 if (can_be_decrypted) {
418 int idx = 0;
419 if (skb->len >= hdrlen + 3) { 418 if (skb->len >= hdrlen + 3) {
420 /* Top two-bits of byte 3 are the key index */ 419 /* Top two-bits of byte 3 are the key index */
421 idx = skb->data[hdrlen + 3] >> 6; 420 keyidx = skb->data[hdrlen + 3] >> 6;
422 } 421 }
423 422
424 /* ieee->crypt[] is WEP_KEY (4) in length. Given that idx 423 /* ieee->crypt[] is WEP_KEY (4) in length. Given that keyidx
425 * is only allowed 2-bits of storage, no value of idx can 424 * is only allowed 2-bits of storage, no value of keyidx can
426 * be provided via above code that would result in idx 425 * be provided via above code that would result in keyidx
427 * being out of range */ 426 * being out of range */
428 crypt = ieee->crypt[idx]; 427 crypt = ieee->crypt[keyidx];
429 428
430#ifdef NOT_YET 429#ifdef NOT_YET
431 sta = NULL; 430 sta = NULL;
@@ -479,6 +478,11 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
479 goto rx_exit; 478 goto rx_exit;
480 } 479 }
481#endif 480#endif
481 /* drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.29) */
482 if (sc == ieee->prev_seq_ctl)
483 goto rx_dropped;
484 else
485 ieee->prev_seq_ctl = sc;
482 486
483 /* Data frame - extract src/dst addresses */ 487 /* Data frame - extract src/dst addresses */
484 if (skb->len < IEEE80211_3ADDR_LEN) 488 if (skb->len < IEEE80211_3ADDR_LEN)
@@ -655,6 +659,51 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
655 goto rx_dropped; 659 goto rx_dropped;
656 } 660 }
657 661
662 /* If the frame was decrypted in hardware, we may need to strip off
663 * any security data (IV, ICV, etc) that was left behind */
664 if (!can_be_decrypted && (fc & IEEE80211_FCTL_PROTECTED) &&
665 ieee->host_strip_iv_icv) {
666 int trimlen = 0;
667
668 /* Top two-bits of byte 3 are the key index */
669 if (skb->len >= hdrlen + 3)
670 keyidx = skb->data[hdrlen + 3] >> 6;
671
672 /* To strip off any security data which appears before the
673 * payload, we simply increase hdrlen (as the header gets
674 * chopped off immediately below). For the security data which
675 * appears after the payload, we use skb_trim. */
676
677 switch (ieee->sec.encode_alg[keyidx]) {
678 case SEC_ALG_WEP:
679 /* 4 byte IV */
680 hdrlen += 4;
681 /* 4 byte ICV */
682 trimlen = 4;
683 break;
684 case SEC_ALG_TKIP:
685 /* 4 byte IV, 4 byte ExtIV */
686 hdrlen += 8;
687 /* 8 byte MIC, 4 byte ICV */
688 trimlen = 12;
689 break;
690 case SEC_ALG_CCMP:
691 /* 8 byte CCMP header */
692 hdrlen += 8;
693 /* 8 byte MIC */
694 trimlen = 8;
695 break;
696 }
697
698 if (skb->len < trimlen)
699 goto rx_dropped;
700
701 __skb_trim(skb, skb->len - trimlen);
702
703 if (skb->len < hdrlen)
704 goto rx_dropped;
705 }
706
658 /* skb: hdr + (possible reassembled) full plaintext payload */ 707 /* skb: hdr + (possible reassembled) full plaintext payload */
659 708
660 payload = skb->data + hdrlen; 709 payload = skb->data + hdrlen;
@@ -1255,12 +1304,11 @@ static int ieee80211_parse_info_param(struct ieee80211_info_element
1255 case MFIE_TYPE_IBSS_DFS: 1304 case MFIE_TYPE_IBSS_DFS:
1256 if (network->ibss_dfs) 1305 if (network->ibss_dfs)
1257 break; 1306 break;
1258 network->ibss_dfs = 1307 network->ibss_dfs = kmemdup(info_element->data,
1259 kmalloc(info_element->len, GFP_ATOMIC); 1308 info_element->len,
1309 GFP_ATOMIC);
1260 if (!network->ibss_dfs) 1310 if (!network->ibss_dfs)
1261 return 1; 1311 return 1;
1262 memcpy(network->ibss_dfs, info_element->data,
1263 info_element->len);
1264 network->flags |= NETWORK_HAS_IBSS_DFS; 1312 network->flags |= NETWORK_HAS_IBSS_DFS;
1265 break; 1313 break;
1266 1314
diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c
index ae254497ba3d..854fc13cd78d 100644
--- a/net/ieee80211/ieee80211_tx.c
+++ b/net/ieee80211/ieee80211_tx.c
@@ -390,7 +390,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
390 * this stack is providing the full 802.11 header, one will 390 * this stack is providing the full 802.11 header, one will
391 * eventually be affixed to this fragment -- so we must account 391 * eventually be affixed to this fragment -- so we must account
392 * for it when determining the amount of payload space. */ 392 * for it when determining the amount of payload space. */
393 bytes_per_frag = frag_size - IEEE80211_3ADDR_LEN; 393 bytes_per_frag = frag_size - hdr_len;
394 if (ieee->config & 394 if (ieee->config &
395 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS)) 395 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
396 bytes_per_frag -= IEEE80211_FCS_LEN; 396 bytes_per_frag -= IEEE80211_FCS_LEN;
@@ -412,7 +412,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
412 } else { 412 } else {
413 nr_frags = 1; 413 nr_frags = 1;
414 bytes_per_frag = bytes_last_frag = bytes; 414 bytes_per_frag = bytes_last_frag = bytes;
415 frag_size = bytes + IEEE80211_3ADDR_LEN; 415 frag_size = bytes + hdr_len;
416 } 416 }
417 417
418 rts_required = (frag_size > ieee->rts 418 rts_required = (frag_size > ieee->rts
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c
index 2ae1833b657a..6012705aa4f8 100644
--- a/net/ieee80211/softmac/ieee80211softmac_auth.c
+++ b/net/ieee80211/softmac/ieee80211softmac_auth.c
@@ -161,7 +161,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
161 /* Make sure that we've got an auth queue item for this request */ 161 /* Make sure that we've got an auth queue item for this request */
162 if(aq == NULL) 162 if(aq == NULL)
163 { 163 {
164 printkl(KERN_DEBUG PFX "Authentication response received from "MAC_FMT" but no queue item exists.\n", MAC_ARG(auth->header.addr2)); 164 dprintkl(KERN_DEBUG PFX "Authentication response received from "MAC_FMT" but no queue item exists.\n", MAC_ARG(auth->header.addr2));
165 /* Error #? */ 165 /* Error #? */
166 return -1; 166 return -1;
167 } 167 }
@@ -169,7 +169,7 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
169 /* Check for out of order authentication */ 169 /* Check for out of order authentication */
170 if(!net->authenticating) 170 if(!net->authenticating)
171 { 171 {
172 printkl(KERN_DEBUG PFX "Authentication response received from "MAC_FMT" but did not request authentication.\n",MAC_ARG(auth->header.addr2)); 172 dprintkl(KERN_DEBUG PFX "Authentication response received from "MAC_FMT" but did not request authentication.\n",MAC_ARG(auth->header.addr2));
173 return -1; 173 return -1;
174 } 174 }
175 175
@@ -219,10 +219,16 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
219 net->challenge_len = *data++; 219 net->challenge_len = *data++;
220 if (net->challenge_len > WLAN_AUTH_CHALLENGE_LEN) 220 if (net->challenge_len > WLAN_AUTH_CHALLENGE_LEN)
221 net->challenge_len = WLAN_AUTH_CHALLENGE_LEN; 221 net->challenge_len = WLAN_AUTH_CHALLENGE_LEN;
222 if (net->challenge != NULL) 222 kfree(net->challenge);
223 kfree(net->challenge); 223 net->challenge = kmemdup(data, net->challenge_len,
224 net->challenge = kmalloc(net->challenge_len, GFP_ATOMIC); 224 GFP_ATOMIC);
225 memcpy(net->challenge, data, net->challenge_len); 225 if (net->challenge == NULL) {
226 printkl(KERN_NOTICE PFX "Shared Key "
227 "Authentication failed due to "
228 "memory shortage.\n");
229 spin_unlock_irqrestore(&mac->lock, flags);
230 break;
231 }
226 aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE; 232 aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE;
227 233
228 /* We reuse the work struct from the auth request here. 234 /* We reuse the work struct from the auth request here.
@@ -345,7 +351,7 @@ ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac,
345 /* Make sure the network is authenticated */ 351 /* Make sure the network is authenticated */
346 if (!net->authenticated) 352 if (!net->authenticated)
347 { 353 {
348 printkl(KERN_DEBUG PFX "Can't send deauthentication packet, network is not authenticated.\n"); 354 dprintkl(KERN_DEBUG PFX "Can't send deauthentication packet, network is not authenticated.\n");
349 /* Error okay? */ 355 /* Error okay? */
350 return -EPERM; 356 return -EPERM;
351 } 357 }
@@ -379,7 +385,7 @@ ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *de
379 net = ieee80211softmac_get_network_by_bssid(mac, deauth->header.addr2); 385 net = ieee80211softmac_get_network_by_bssid(mac, deauth->header.addr2);
380 386
381 if (net == NULL) { 387 if (net == NULL) {
382 printkl(KERN_DEBUG PFX "Received deauthentication packet from "MAC_FMT", but that network is unknown.\n", 388 dprintkl(KERN_DEBUG PFX "Received deauthentication packet from "MAC_FMT", but that network is unknown.\n",
383 MAC_ARG(deauth->header.addr2)); 389 MAC_ARG(deauth->header.addr2));
384 return 0; 390 return 0;
385 } 391 }
@@ -387,7 +393,7 @@ ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *de
387 /* Make sure the network is authenticated */ 393 /* Make sure the network is authenticated */
388 if(!net->authenticated) 394 if(!net->authenticated)
389 { 395 {
390 printkl(KERN_DEBUG PFX "Can't perform deauthentication, network is not authenticated.\n"); 396 dprintkl(KERN_DEBUG PFX "Can't perform deauthentication, network is not authenticated.\n");
391 /* Error okay? */ 397 /* Error okay? */
392 return -EPERM; 398 return -EPERM;
393 } 399 }
diff --git a/net/ieee80211/softmac/ieee80211softmac_scan.c b/net/ieee80211/softmac/ieee80211softmac_scan.c
index a8326076581a..0c85d6c24cdb 100644
--- a/net/ieee80211/softmac/ieee80211softmac_scan.c
+++ b/net/ieee80211/softmac/ieee80211softmac_scan.c
@@ -47,7 +47,6 @@ ieee80211softmac_start_scan(struct ieee80211softmac_device *sm)
47 sm->scanning = 1; 47 sm->scanning = 1;
48 spin_unlock_irqrestore(&sm->lock, flags); 48 spin_unlock_irqrestore(&sm->lock, flags);
49 49
50 netif_tx_disable(sm->ieee->dev);
51 ret = sm->start_scan(sm->dev); 50 ret = sm->start_scan(sm->dev);
52 if (ret) { 51 if (ret) {
53 spin_lock_irqsave(&sm->lock, flags); 52 spin_lock_irqsave(&sm->lock, flags);
@@ -137,7 +136,8 @@ void ieee80211softmac_scan(struct work_struct *work)
137 si->started = 0; 136 si->started = 0;
138 spin_unlock_irqrestore(&sm->lock, flags); 137 spin_unlock_irqrestore(&sm->lock, flags);
139 138
140 dprintk(PFX "Scanning finished\n"); 139 dprintk(PFX "Scanning finished: scanned %d channels starting with channel %d\n",
140 sm->scaninfo->number_channels, sm->scaninfo->channels[0].channel);
141 ieee80211softmac_scan_finished(sm); 141 ieee80211softmac_scan_finished(sm);
142 complete_all(&sm->scaninfo->finished); 142 complete_all(&sm->scaninfo->finished);
143} 143}
@@ -186,8 +186,6 @@ int ieee80211softmac_start_scan_implementation(struct net_device *dev)
186 sm->scaninfo->channels = sm->ieee->geo.bg; 186 sm->scaninfo->channels = sm->ieee->geo.bg;
187 sm->scaninfo->number_channels = sm->ieee->geo.bg_channels; 187 sm->scaninfo->number_channels = sm->ieee->geo.bg_channels;
188 } 188 }
189 dprintk(PFX "Start scanning with channel: %d\n", sm->scaninfo->channels[0].channel);
190 dprintk(PFX "Scanning %d channels\n", sm->scaninfo->number_channels);
191 sm->scaninfo->current_channel_idx = 0; 189 sm->scaninfo->current_channel_idx = 0;
192 sm->scaninfo->started = 1; 190 sm->scaninfo->started = 1;
193 sm->scaninfo->stop = 0; 191 sm->scaninfo->stop = 0;
@@ -251,7 +249,6 @@ void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm)
251 if (net) 249 if (net)
252 sm->set_channel(sm->dev, net->channel); 250 sm->set_channel(sm->dev, net->channel);
253 } 251 }
254 netif_wake_queue(sm->ieee->dev);
255 ieee80211softmac_call_events(sm, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, NULL); 252 ieee80211softmac_call_events(sm, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, NULL);
256} 253}
257EXPORT_SYMBOL_GPL(ieee80211softmac_scan_finished); 254EXPORT_SYMBOL_GPL(ieee80211softmac_scan_finished);
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 5572071af735..503e7059e312 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -104,13 +104,6 @@ config IP_MULTIPLE_TABLES
104 104
105 If unsure, say N. 105 If unsure, say N.
106 106
107config IP_ROUTE_FWMARK
108 bool "IP: use netfilter MARK value as routing key"
109 depends on IP_MULTIPLE_TABLES && NETFILTER
110 help
111 If you say Y here, you will be able to specify different routes for
112 packets with different mark values (see iptables(8), MARK target).
113
114config IP_ROUTE_MULTIPATH 107config IP_ROUTE_MULTIPATH
115 bool "IP: equal cost multipath" 108 bool "IP: equal cost multipath"
116 depends on IP_ADVANCED_ROUTER 109 depends on IP_ADVANCED_ROUTER
@@ -625,5 +618,17 @@ config DEFAULT_TCP_CONG
625 default "reno" if DEFAULT_RENO 618 default "reno" if DEFAULT_RENO
626 default "cubic" 619 default "cubic"
627 620
621config TCP_MD5SIG
622 bool "TCP: MD5 Signature Option support (RFC2385) (EXPERIMENTAL)"
623 depends on EXPERIMENTAL
624 select CRYPTO
625 select CRYPTO_MD5
626 ---help---
627 RFC2385 specifices a method of giving MD5 protection to TCP sessions.
628 Its main (only?) use is to protect BGP sessions between core routers
629 on the Internet.
630
631 If unsure, say N.
632
628source "net/ipv4/ipvs/Kconfig" 633source "net/ipv4/ipvs/Kconfig"
629 634
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index 15645c51520c..7a068626feea 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -8,7 +8,8 @@ obj-y := route.o inetpeer.o protocol.o \
8 inet_timewait_sock.o inet_connection_sock.o \ 8 inet_timewait_sock.o inet_connection_sock.o \
9 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \ 9 tcp.o tcp_input.o tcp_output.o tcp_timer.o tcp_ipv4.o \
10 tcp_minisocks.o tcp_cong.o \ 10 tcp_minisocks.o tcp_cong.o \
11 datagram.o raw.o udp.o arp.o icmp.o devinet.o af_inet.o igmp.o \ 11 datagram.o raw.o udp.o udplite.o \
12 arp.o icmp.o devinet.o af_inet.o igmp.o \
12 sysctl_net_ipv4.o fib_frontend.o fib_semantics.o 13 sysctl_net_ipv4.o fib_frontend.o fib_semantics.o
13 14
14obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o 15obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index edcf0932ac6d..1144900d37f6 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -104,6 +104,7 @@
104#include <net/inet_connection_sock.h> 104#include <net/inet_connection_sock.h>
105#include <net/tcp.h> 105#include <net/tcp.h>
106#include <net/udp.h> 106#include <net/udp.h>
107#include <net/udplite.h>
107#include <linux/skbuff.h> 108#include <linux/skbuff.h>
108#include <net/sock.h> 109#include <net/sock.h>
109#include <net/raw.h> 110#include <net/raw.h>
@@ -204,7 +205,7 @@ int inet_listen(struct socket *sock, int backlog)
204 * we can only allow the backlog to be adjusted. 205 * we can only allow the backlog to be adjusted.
205 */ 206 */
206 if (old_state != TCP_LISTEN) { 207 if (old_state != TCP_LISTEN) {
207 err = inet_csk_listen_start(sk, TCP_SYNQ_HSIZE); 208 err = inet_csk_listen_start(sk, backlog);
208 if (err) 209 if (err)
209 goto out; 210 goto out;
210 } 211 }
@@ -643,7 +644,7 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
643 sin->sin_port = inet->dport; 644 sin->sin_port = inet->dport;
644 sin->sin_addr.s_addr = inet->daddr; 645 sin->sin_addr.s_addr = inet->daddr;
645 } else { 646 } else {
646 __u32 addr = inet->rcv_saddr; 647 __be32 addr = inet->rcv_saddr;
647 if (!addr) 648 if (!addr)
648 addr = inet->saddr; 649 addr = inet->saddr;
649 sin->sin_port = inet->sport; 650 sin->sin_port = inet->sport;
@@ -994,8 +995,8 @@ static int inet_sk_reselect_saddr(struct sock *sk)
994 struct inet_sock *inet = inet_sk(sk); 995 struct inet_sock *inet = inet_sk(sk);
995 int err; 996 int err;
996 struct rtable *rt; 997 struct rtable *rt;
997 __u32 old_saddr = inet->saddr; 998 __be32 old_saddr = inet->saddr;
998 __u32 new_saddr; 999 __be32 new_saddr;
999 __be32 daddr = inet->daddr; 1000 __be32 daddr = inet->daddr;
1000 1001
1001 if (inet->opt && inet->opt->srr) 1002 if (inet->opt && inet->opt->srr)
@@ -1223,10 +1224,13 @@ static int __init init_ipv4_mibs(void)
1223 tcp_statistics[1] = alloc_percpu(struct tcp_mib); 1224 tcp_statistics[1] = alloc_percpu(struct tcp_mib);
1224 udp_statistics[0] = alloc_percpu(struct udp_mib); 1225 udp_statistics[0] = alloc_percpu(struct udp_mib);
1225 udp_statistics[1] = alloc_percpu(struct udp_mib); 1226 udp_statistics[1] = alloc_percpu(struct udp_mib);
1227 udplite_statistics[0] = alloc_percpu(struct udp_mib);
1228 udplite_statistics[1] = alloc_percpu(struct udp_mib);
1226 if (! 1229 if (!
1227 (net_statistics[0] && net_statistics[1] && ip_statistics[0] 1230 (net_statistics[0] && net_statistics[1] && ip_statistics[0]
1228 && ip_statistics[1] && tcp_statistics[0] && tcp_statistics[1] 1231 && ip_statistics[1] && tcp_statistics[0] && tcp_statistics[1]
1229 && udp_statistics[0] && udp_statistics[1])) 1232 && udp_statistics[0] && udp_statistics[1]
1233 && udplite_statistics[0] && udplite_statistics[1] ) )
1230 return -ENOMEM; 1234 return -ENOMEM;
1231 1235
1232 (void) tcp_mib_init(); 1236 (void) tcp_mib_init();
@@ -1313,6 +1317,8 @@ static int __init inet_init(void)
1313 /* Setup TCP slab cache for open requests. */ 1317 /* Setup TCP slab cache for open requests. */
1314 tcp_init(); 1318 tcp_init();
1315 1319
1320 /* Add UDP-Lite (RFC 3828) */
1321 udplite4_register();
1316 1322
1317 /* 1323 /*
1318 * Set the ICMP layer up 1324 * Set the ICMP layer up
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 99542977e47e..67a5509e26fc 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -14,7 +14,7 @@
14 * into IP header for icv calculation. Options are already checked 14 * into IP header for icv calculation. Options are already checked
15 * for validity, so paranoia is not required. */ 15 * for validity, so paranoia is not required. */
16 16
17static int ip_clear_mutable_options(struct iphdr *iph, u32 *daddr) 17static int ip_clear_mutable_options(struct iphdr *iph, __be32 *daddr)
18{ 18{
19 unsigned char * optptr = (unsigned char*)(iph+1); 19 unsigned char * optptr = (unsigned char*)(iph+1);
20 int l = iph->ihl*4 - sizeof(struct iphdr); 20 int l = iph->ihl*4 - sizeof(struct iphdr);
@@ -162,7 +162,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
162 iph->frag_off = 0; 162 iph->frag_off = 0;
163 iph->check = 0; 163 iph->check = 0;
164 if (ihl > sizeof(*iph)) { 164 if (ihl > sizeof(*iph)) {
165 u32 dummy; 165 __be32 dummy;
166 if (ip_clear_mutable_options(iph, &dummy)) 166 if (ip_clear_mutable_options(iph, &dummy))
167 goto out; 167 goto out;
168 } 168 }
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index cfb5d3de9c84..3981e8be9ab8 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -203,7 +203,7 @@ struct neigh_table arp_tbl = {
203 .gc_thresh3 = 1024, 203 .gc_thresh3 = 1024,
204}; 204};
205 205
206int arp_mc_map(u32 addr, u8 *haddr, struct net_device *dev, int dir) 206int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir)
207{ 207{
208 switch (dev->type) { 208 switch (dev->type) {
209 case ARPHRD_ETHER: 209 case ARPHRD_ETHER:
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 6460233407c7..60aafb4a8adf 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -319,6 +319,7 @@ static int cipso_v4_cache_check(const unsigned char *key,
319 entry->activity += 1; 319 entry->activity += 1;
320 atomic_inc(&entry->lsm_data->refcount); 320 atomic_inc(&entry->lsm_data->refcount);
321 secattr->cache = entry->lsm_data; 321 secattr->cache = entry->lsm_data;
322 secattr->flags |= NETLBL_SECATTR_CACHE;
322 if (prev_entry == NULL) { 323 if (prev_entry == NULL) {
323 spin_unlock_bh(&cipso_v4_cache[bkt].lock); 324 spin_unlock_bh(&cipso_v4_cache[bkt].lock);
324 return 0; 325 return 0;
@@ -377,12 +378,11 @@ int cipso_v4_cache_add(const struct sk_buff *skb,
377 entry = kzalloc(sizeof(*entry), GFP_ATOMIC); 378 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
378 if (entry == NULL) 379 if (entry == NULL)
379 return -ENOMEM; 380 return -ENOMEM;
380 entry->key = kmalloc(cipso_ptr_len, GFP_ATOMIC); 381 entry->key = kmemdup(cipso_ptr, cipso_ptr_len, GFP_ATOMIC);
381 if (entry->key == NULL) { 382 if (entry->key == NULL) {
382 ret_val = -ENOMEM; 383 ret_val = -ENOMEM;
383 goto cache_add_failure; 384 goto cache_add_failure;
384 } 385 }
385 memcpy(entry->key, cipso_ptr, cipso_ptr_len);
386 entry->key_len = cipso_ptr_len; 386 entry->key_len = cipso_ptr_len;
387 entry->hash = cipso_v4_map_cache_hash(cipso_ptr, cipso_ptr_len); 387 entry->hash = cipso_v4_map_cache_hash(cipso_ptr, cipso_ptr_len);
388 atomic_inc(&secattr->cache->refcount); 388 atomic_inc(&secattr->cache->refcount);
@@ -447,8 +447,30 @@ static struct cipso_v4_doi *cipso_v4_doi_search(u32 doi)
447 */ 447 */
448int cipso_v4_doi_add(struct cipso_v4_doi *doi_def) 448int cipso_v4_doi_add(struct cipso_v4_doi *doi_def)
449{ 449{
450 u32 iter;
451
450 if (doi_def == NULL || doi_def->doi == CIPSO_V4_DOI_UNKNOWN) 452 if (doi_def == NULL || doi_def->doi == CIPSO_V4_DOI_UNKNOWN)
451 return -EINVAL; 453 return -EINVAL;
454 for (iter = 0; iter < CIPSO_V4_TAG_MAXCNT; iter++) {
455 switch (doi_def->tags[iter]) {
456 case CIPSO_V4_TAG_RBITMAP:
457 break;
458 case CIPSO_V4_TAG_RANGE:
459 if (doi_def->type != CIPSO_V4_MAP_PASS)
460 return -EINVAL;
461 break;
462 case CIPSO_V4_TAG_INVALID:
463 if (iter == 0)
464 return -EINVAL;
465 break;
466 case CIPSO_V4_TAG_ENUM:
467 if (doi_def->type != CIPSO_V4_MAP_PASS)
468 return -EINVAL;
469 break;
470 default:
471 return -EINVAL;
472 }
473 }
452 474
453 doi_def->valid = 1; 475 doi_def->valid = 1;
454 INIT_RCU_HEAD(&doi_def->rcu); 476 INIT_RCU_HEAD(&doi_def->rcu);
@@ -805,8 +827,7 @@ static int cipso_v4_map_cat_rbm_valid(const struct cipso_v4_doi *doi_def,
805/** 827/**
806 * cipso_v4_map_cat_rbm_hton - Perform a category mapping from host to network 828 * cipso_v4_map_cat_rbm_hton - Perform a category mapping from host to network
807 * @doi_def: the DOI definition 829 * @doi_def: the DOI definition
808 * @host_cat: the category bitmap in host format 830 * @secattr: the security attributes
809 * @host_cat_len: the length of the host's category bitmap in bytes
810 * @net_cat: the zero'd out category bitmap in network/CIPSO format 831 * @net_cat: the zero'd out category bitmap in network/CIPSO format
811 * @net_cat_len: the length of the CIPSO bitmap in bytes 832 * @net_cat_len: the length of the CIPSO bitmap in bytes
812 * 833 *
@@ -817,59 +838,51 @@ static int cipso_v4_map_cat_rbm_valid(const struct cipso_v4_doi *doi_def,
817 * 838 *
818 */ 839 */
819static int cipso_v4_map_cat_rbm_hton(const struct cipso_v4_doi *doi_def, 840static int cipso_v4_map_cat_rbm_hton(const struct cipso_v4_doi *doi_def,
820 const unsigned char *host_cat, 841 const struct netlbl_lsm_secattr *secattr,
821 u32 host_cat_len,
822 unsigned char *net_cat, 842 unsigned char *net_cat,
823 u32 net_cat_len) 843 u32 net_cat_len)
824{ 844{
825 int host_spot = -1; 845 int host_spot = -1;
826 u32 net_spot; 846 u32 net_spot = CIPSO_V4_INV_CAT;
827 u32 net_spot_max = 0; 847 u32 net_spot_max = 0;
828 u32 host_clen_bits = host_cat_len * 8;
829 u32 net_clen_bits = net_cat_len * 8; 848 u32 net_clen_bits = net_cat_len * 8;
830 u32 host_cat_size; 849 u32 host_cat_size = 0;
831 u32 *host_cat_array; 850 u32 *host_cat_array = NULL;
832 851
833 switch (doi_def->type) { 852 if (doi_def->type == CIPSO_V4_MAP_STD) {
834 case CIPSO_V4_MAP_PASS:
835 net_spot_max = host_cat_len;
836 while (net_spot_max > 0 && host_cat[net_spot_max - 1] == 0)
837 net_spot_max--;
838 if (net_spot_max > net_cat_len)
839 return -EINVAL;
840 memcpy(net_cat, host_cat, net_spot_max);
841 return net_spot_max;
842 case CIPSO_V4_MAP_STD:
843 host_cat_size = doi_def->map.std->cat.local_size; 853 host_cat_size = doi_def->map.std->cat.local_size;
844 host_cat_array = doi_def->map.std->cat.local; 854 host_cat_array = doi_def->map.std->cat.local;
845 for (;;) { 855 }
846 host_spot = cipso_v4_bitmap_walk(host_cat, 856
847 host_clen_bits, 857 for (;;) {
848 host_spot + 1, 858 host_spot = netlbl_secattr_catmap_walk(secattr->mls_cat,
849 1); 859 host_spot + 1);
850 if (host_spot < 0) 860 if (host_spot < 0)
851 break; 861 break;
862
863 switch (doi_def->type) {
864 case CIPSO_V4_MAP_PASS:
865 net_spot = host_spot;
866 break;
867 case CIPSO_V4_MAP_STD:
852 if (host_spot >= host_cat_size) 868 if (host_spot >= host_cat_size)
853 return -EPERM; 869 return -EPERM;
854
855 net_spot = host_cat_array[host_spot]; 870 net_spot = host_cat_array[host_spot];
856 if (net_spot >= net_clen_bits) 871 if (net_spot >= CIPSO_V4_INV_CAT)
857 return -ENOSPC; 872 return -EPERM;
858 cipso_v4_bitmap_setbit(net_cat, net_spot, 1); 873 break;
859
860 if (net_spot > net_spot_max)
861 net_spot_max = net_spot;
862 } 874 }
875 if (net_spot >= net_clen_bits)
876 return -ENOSPC;
877 cipso_v4_bitmap_setbit(net_cat, net_spot, 1);
863 878
864 if (host_spot == -2) 879 if (net_spot > net_spot_max)
865 return -EFAULT; 880 net_spot_max = net_spot;
866
867 if (++net_spot_max % 8)
868 return net_spot_max / 8 + 1;
869 return net_spot_max / 8;
870 } 881 }
871 882
872 return -EINVAL; 883 if (++net_spot_max % 8)
884 return net_spot_max / 8 + 1;
885 return net_spot_max / 8;
873} 886}
874 887
875/** 888/**
@@ -877,102 +890,333 @@ static int cipso_v4_map_cat_rbm_hton(const struct cipso_v4_doi *doi_def,
877 * @doi_def: the DOI definition 890 * @doi_def: the DOI definition
878 * @net_cat: the category bitmap in network/CIPSO format 891 * @net_cat: the category bitmap in network/CIPSO format
879 * @net_cat_len: the length of the CIPSO bitmap in bytes 892 * @net_cat_len: the length of the CIPSO bitmap in bytes
880 * @host_cat: the zero'd out category bitmap in host format 893 * @secattr: the security attributes
881 * @host_cat_len: the length of the host's category bitmap in bytes
882 * 894 *
883 * Description: 895 * Description:
884 * Perform a label mapping to translate a CIPSO bitmap to the correct local 896 * Perform a label mapping to translate a CIPSO bitmap to the correct local
885 * MLS category bitmap using the given DOI definition. Returns the minimum 897 * MLS category bitmap using the given DOI definition. Returns zero on
886 * size in bytes of the host bitmap on success, negative values otherwise. 898 * success, negative values on failure.
887 * 899 *
888 */ 900 */
889static int cipso_v4_map_cat_rbm_ntoh(const struct cipso_v4_doi *doi_def, 901static int cipso_v4_map_cat_rbm_ntoh(const struct cipso_v4_doi *doi_def,
890 const unsigned char *net_cat, 902 const unsigned char *net_cat,
891 u32 net_cat_len, 903 u32 net_cat_len,
892 unsigned char *host_cat, 904 struct netlbl_lsm_secattr *secattr)
893 u32 host_cat_len)
894{ 905{
895 u32 host_spot; 906 int ret_val;
896 u32 host_spot_max = 0;
897 int net_spot = -1; 907 int net_spot = -1;
908 u32 host_spot = CIPSO_V4_INV_CAT;
898 u32 net_clen_bits = net_cat_len * 8; 909 u32 net_clen_bits = net_cat_len * 8;
899 u32 host_clen_bits = host_cat_len * 8; 910 u32 net_cat_size = 0;
900 u32 net_cat_size; 911 u32 *net_cat_array = NULL;
901 u32 *net_cat_array;
902 912
903 switch (doi_def->type) { 913 if (doi_def->type == CIPSO_V4_MAP_STD) {
904 case CIPSO_V4_MAP_PASS:
905 if (net_cat_len > host_cat_len)
906 return -EINVAL;
907 memcpy(host_cat, net_cat, net_cat_len);
908 return net_cat_len;
909 case CIPSO_V4_MAP_STD:
910 net_cat_size = doi_def->map.std->cat.cipso_size; 914 net_cat_size = doi_def->map.std->cat.cipso_size;
911 net_cat_array = doi_def->map.std->cat.cipso; 915 net_cat_array = doi_def->map.std->cat.cipso;
912 for (;;) { 916 }
913 net_spot = cipso_v4_bitmap_walk(net_cat,
914 net_clen_bits,
915 net_spot + 1,
916 1);
917 if (net_spot < 0)
918 break;
919 if (net_spot >= net_cat_size ||
920 net_cat_array[net_spot] >= CIPSO_V4_INV_CAT)
921 return -EPERM;
922 917
923 host_spot = net_cat_array[net_spot]; 918 for (;;) {
924 if (host_spot >= host_clen_bits) 919 net_spot = cipso_v4_bitmap_walk(net_cat,
925 return -ENOSPC; 920 net_clen_bits,
926 cipso_v4_bitmap_setbit(host_cat, host_spot, 1); 921 net_spot + 1,
922 1);
923 if (net_spot < 0) {
924 if (net_spot == -2)
925 return -EFAULT;
926 return 0;
927 }
927 928
928 if (host_spot > host_spot_max) 929 switch (doi_def->type) {
929 host_spot_max = host_spot; 930 case CIPSO_V4_MAP_PASS:
931 host_spot = net_spot;
932 break;
933 case CIPSO_V4_MAP_STD:
934 if (net_spot >= net_cat_size)
935 return -EPERM;
936 host_spot = net_cat_array[net_spot];
937 if (host_spot >= CIPSO_V4_INV_CAT)
938 return -EPERM;
939 break;
930 } 940 }
941 ret_val = netlbl_secattr_catmap_setbit(secattr->mls_cat,
942 host_spot,
943 GFP_ATOMIC);
944 if (ret_val != 0)
945 return ret_val;
946 }
947
948 return -EINVAL;
949}
950
951/**
952 * cipso_v4_map_cat_enum_valid - Checks to see if the categories are valid
953 * @doi_def: the DOI definition
954 * @enumcat: category list
955 * @enumcat_len: length of the category list in bytes
956 *
957 * Description:
958 * Checks the given categories against the given DOI definition and returns a
959 * negative value if any of the categories do not have a valid mapping and a
960 * zero value if all of the categories are valid.
961 *
962 */
963static int cipso_v4_map_cat_enum_valid(const struct cipso_v4_doi *doi_def,
964 const unsigned char *enumcat,
965 u32 enumcat_len)
966{
967 u16 cat;
968 int cat_prev = -1;
969 u32 iter;
970
971 if (doi_def->type != CIPSO_V4_MAP_PASS || enumcat_len & 0x01)
972 return -EFAULT;
973
974 for (iter = 0; iter < enumcat_len; iter += 2) {
975 cat = ntohs(*((__be16 *)&enumcat[iter]));
976 if (cat <= cat_prev)
977 return -EFAULT;
978 cat_prev = cat;
979 }
980
981 return 0;
982}
983
984/**
985 * cipso_v4_map_cat_enum_hton - Perform a category mapping from host to network
986 * @doi_def: the DOI definition
987 * @secattr: the security attributes
988 * @net_cat: the zero'd out category list in network/CIPSO format
989 * @net_cat_len: the length of the CIPSO category list in bytes
990 *
991 * Description:
992 * Perform a label mapping to translate a local MLS category bitmap to the
993 * correct CIPSO category list using the given DOI definition. Returns the
994 * size in bytes of the network category bitmap on success, negative values
995 * otherwise.
996 *
997 */
998static int cipso_v4_map_cat_enum_hton(const struct cipso_v4_doi *doi_def,
999 const struct netlbl_lsm_secattr *secattr,
1000 unsigned char *net_cat,
1001 u32 net_cat_len)
1002{
1003 int cat = -1;
1004 u32 cat_iter = 0;
1005
1006 for (;;) {
1007 cat = netlbl_secattr_catmap_walk(secattr->mls_cat, cat + 1);
1008 if (cat < 0)
1009 break;
1010 if ((cat_iter + 2) > net_cat_len)
1011 return -ENOSPC;
1012
1013 *((__be16 *)&net_cat[cat_iter]) = htons(cat);
1014 cat_iter += 2;
1015 }
1016
1017 return cat_iter;
1018}
1019
1020/**
1021 * cipso_v4_map_cat_enum_ntoh - Perform a category mapping from network to host
1022 * @doi_def: the DOI definition
1023 * @net_cat: the category list in network/CIPSO format
1024 * @net_cat_len: the length of the CIPSO bitmap in bytes
1025 * @secattr: the security attributes
1026 *
1027 * Description:
1028 * Perform a label mapping to translate a CIPSO category list to the correct
1029 * local MLS category bitmap using the given DOI definition. Returns zero on
1030 * success, negative values on failure.
1031 *
1032 */
1033static int cipso_v4_map_cat_enum_ntoh(const struct cipso_v4_doi *doi_def,
1034 const unsigned char *net_cat,
1035 u32 net_cat_len,
1036 struct netlbl_lsm_secattr *secattr)
1037{
1038 int ret_val;
1039 u32 iter;
1040
1041 for (iter = 0; iter < net_cat_len; iter += 2) {
1042 ret_val = netlbl_secattr_catmap_setbit(secattr->mls_cat,
1043 ntohs(*((__be16 *)&net_cat[iter])),
1044 GFP_ATOMIC);
1045 if (ret_val != 0)
1046 return ret_val;
1047 }
1048
1049 return 0;
1050}
1051
1052/**
1053 * cipso_v4_map_cat_rng_valid - Checks to see if the categories are valid
1054 * @doi_def: the DOI definition
1055 * @rngcat: category list
1056 * @rngcat_len: length of the category list in bytes
1057 *
1058 * Description:
1059 * Checks the given categories against the given DOI definition and returns a
1060 * negative value if any of the categories do not have a valid mapping and a
1061 * zero value if all of the categories are valid.
1062 *
1063 */
1064static int cipso_v4_map_cat_rng_valid(const struct cipso_v4_doi *doi_def,
1065 const unsigned char *rngcat,
1066 u32 rngcat_len)
1067{
1068 u16 cat_high;
1069 u16 cat_low;
1070 u32 cat_prev = CIPSO_V4_MAX_REM_CATS + 1;
1071 u32 iter;
931 1072
932 if (net_spot == -2) 1073 if (doi_def->type != CIPSO_V4_MAP_PASS || rngcat_len & 0x01)
1074 return -EFAULT;
1075
1076 for (iter = 0; iter < rngcat_len; iter += 4) {
1077 cat_high = ntohs(*((__be16 *)&rngcat[iter]));
1078 if ((iter + 4) <= rngcat_len)
1079 cat_low = ntohs(*((__be16 *)&rngcat[iter + 2]));
1080 else
1081 cat_low = 0;
1082
1083 if (cat_high > cat_prev)
933 return -EFAULT; 1084 return -EFAULT;
934 1085
935 if (++host_spot_max % 8) 1086 cat_prev = cat_low;
936 return host_spot_max / 8 + 1;
937 return host_spot_max / 8;
938 } 1087 }
939 1088
940 return -EINVAL; 1089 return 0;
1090}
1091
1092/**
1093 * cipso_v4_map_cat_rng_hton - Perform a category mapping from host to network
1094 * @doi_def: the DOI definition
1095 * @secattr: the security attributes
1096 * @net_cat: the zero'd out category list in network/CIPSO format
1097 * @net_cat_len: the length of the CIPSO category list in bytes
1098 *
1099 * Description:
1100 * Perform a label mapping to translate a local MLS category bitmap to the
1101 * correct CIPSO category list using the given DOI definition. Returns the
1102 * size in bytes of the network category bitmap on success, negative values
1103 * otherwise.
1104 *
1105 */
1106static int cipso_v4_map_cat_rng_hton(const struct cipso_v4_doi *doi_def,
1107 const struct netlbl_lsm_secattr *secattr,
1108 unsigned char *net_cat,
1109 u32 net_cat_len)
1110{
1111 /* The constant '16' is not random, it is the maximum number of
1112 * high/low category range pairs as permitted by the CIPSO draft based
1113 * on a maximum IPv4 header length of 60 bytes - the BUG_ON() assertion
1114 * does a sanity check to make sure we don't overflow the array. */
1115 int iter = -1;
1116 u16 array[16];
1117 u32 array_cnt = 0;
1118 u32 cat_size = 0;
1119
1120 BUG_ON(net_cat_len > 30);
1121
1122 for (;;) {
1123 iter = netlbl_secattr_catmap_walk(secattr->mls_cat, iter + 1);
1124 if (iter < 0)
1125 break;
1126 cat_size += (iter == 0 ? 0 : sizeof(u16));
1127 if (cat_size > net_cat_len)
1128 return -ENOSPC;
1129 array[array_cnt++] = iter;
1130
1131 iter = netlbl_secattr_catmap_walk_rng(secattr->mls_cat, iter);
1132 if (iter < 0)
1133 return -EFAULT;
1134 cat_size += sizeof(u16);
1135 if (cat_size > net_cat_len)
1136 return -ENOSPC;
1137 array[array_cnt++] = iter;
1138 }
1139
1140 for (iter = 0; array_cnt > 0;) {
1141 *((__be16 *)&net_cat[iter]) = htons(array[--array_cnt]);
1142 iter += 2;
1143 array_cnt--;
1144 if (array[array_cnt] != 0) {
1145 *((__be16 *)&net_cat[iter]) = htons(array[array_cnt]);
1146 iter += 2;
1147 }
1148 }
1149
1150 return cat_size;
1151}
1152
1153/**
1154 * cipso_v4_map_cat_rng_ntoh - Perform a category mapping from network to host
1155 * @doi_def: the DOI definition
1156 * @net_cat: the category list in network/CIPSO format
1157 * @net_cat_len: the length of the CIPSO bitmap in bytes
1158 * @secattr: the security attributes
1159 *
1160 * Description:
1161 * Perform a label mapping to translate a CIPSO category list to the correct
1162 * local MLS category bitmap using the given DOI definition. Returns zero on
1163 * success, negative values on failure.
1164 *
1165 */
1166static int cipso_v4_map_cat_rng_ntoh(const struct cipso_v4_doi *doi_def,
1167 const unsigned char *net_cat,
1168 u32 net_cat_len,
1169 struct netlbl_lsm_secattr *secattr)
1170{
1171 int ret_val;
1172 u32 net_iter;
1173 u16 cat_low;
1174 u16 cat_high;
1175
1176 for(net_iter = 0; net_iter < net_cat_len; net_iter += 4) {
1177 cat_high = ntohs(*((__be16 *)&net_cat[net_iter]));
1178 if ((net_iter + 4) <= net_cat_len)
1179 cat_low = ntohs(*((__be16 *)&net_cat[net_iter + 2]));
1180 else
1181 cat_low = 0;
1182
1183 ret_val = netlbl_secattr_catmap_setrng(secattr->mls_cat,
1184 cat_low,
1185 cat_high,
1186 GFP_ATOMIC);
1187 if (ret_val != 0)
1188 return ret_val;
1189 }
1190
1191 return 0;
941} 1192}
942 1193
943/* 1194/*
944 * Protocol Handling Functions 1195 * Protocol Handling Functions
945 */ 1196 */
946 1197
1198#define CIPSO_V4_OPT_LEN_MAX 40
947#define CIPSO_V4_HDR_LEN 6 1199#define CIPSO_V4_HDR_LEN 6
948 1200
949/** 1201/**
950 * cipso_v4_gentag_hdr - Generate a CIPSO option header 1202 * cipso_v4_gentag_hdr - Generate a CIPSO option header
951 * @doi_def: the DOI definition 1203 * @doi_def: the DOI definition
952 * @len: the total tag length in bytes 1204 * @len: the total tag length in bytes, not including this header
953 * @buf: the CIPSO option buffer 1205 * @buf: the CIPSO option buffer
954 * 1206 *
955 * Description: 1207 * Description:
956 * Write a CIPSO header into the beginning of @buffer. Return zero on success, 1208 * Write a CIPSO header into the beginning of @buffer.
957 * negative values on failure.
958 * 1209 *
959 */ 1210 */
960static int cipso_v4_gentag_hdr(const struct cipso_v4_doi *doi_def, 1211static void cipso_v4_gentag_hdr(const struct cipso_v4_doi *doi_def,
961 u32 len, 1212 unsigned char *buf,
962 unsigned char *buf) 1213 u32 len)
963{ 1214{
964 if (CIPSO_V4_HDR_LEN + len > 40)
965 return -ENOSPC;
966
967 buf[0] = IPOPT_CIPSO; 1215 buf[0] = IPOPT_CIPSO;
968 buf[1] = CIPSO_V4_HDR_LEN + len; 1216 buf[1] = CIPSO_V4_HDR_LEN + len;
969 *(u32 *)&buf[2] = htonl(doi_def->doi); 1217 *(__be32 *)&buf[2] = htonl(doi_def->doi);
970
971 return 0;
972} 1218}
973 1219
974#define CIPSO_V4_TAG1_CAT_LEN 30
975
976/** 1220/**
977 * cipso_v4_gentag_rbm - Generate a CIPSO restricted bitmap tag (type #1) 1221 * cipso_v4_gentag_rbm - Generate a CIPSO restricted bitmap tag (type #1)
978 * @doi_def: the DOI definition 1222 * @doi_def: the DOI definition
@@ -983,83 +1227,249 @@ static int cipso_v4_gentag_hdr(const struct cipso_v4_doi *doi_def,
983 * Description: 1227 * Description:
984 * Generate a CIPSO option using the restricted bitmap tag, tag type #1. The 1228 * Generate a CIPSO option using the restricted bitmap tag, tag type #1. The
985 * actual buffer length may be larger than the indicated size due to 1229 * actual buffer length may be larger than the indicated size due to
986 * translation between host and network category bitmaps. Returns zero on 1230 * translation between host and network category bitmaps. Returns the size of
987 * success, negative values on failure. 1231 * the tag on success, negative values on failure.
988 * 1232 *
989 */ 1233 */
990static int cipso_v4_gentag_rbm(const struct cipso_v4_doi *doi_def, 1234static int cipso_v4_gentag_rbm(const struct cipso_v4_doi *doi_def,
991 const struct netlbl_lsm_secattr *secattr, 1235 const struct netlbl_lsm_secattr *secattr,
992 unsigned char **buffer, 1236 unsigned char *buffer,
993 u32 *buffer_len) 1237 u32 buffer_len)
994{ 1238{
995 int ret_val = -EPERM; 1239 int ret_val;
996 unsigned char *buf = NULL; 1240 u32 tag_len;
997 u32 buf_len;
998 u32 level; 1241 u32 level;
999 1242
1000 if (secattr->mls_cat) { 1243 if ((secattr->flags & NETLBL_SECATTR_MLS_LVL) == 0)
1001 buf = kzalloc(CIPSO_V4_HDR_LEN + 4 + CIPSO_V4_TAG1_CAT_LEN, 1244 return -EPERM;
1002 GFP_ATOMIC); 1245
1003 if (buf == NULL) 1246 ret_val = cipso_v4_map_lvl_hton(doi_def, secattr->mls_lvl, &level);
1004 return -ENOMEM; 1247 if (ret_val != 0)
1248 return ret_val;
1005 1249
1250 if (secattr->flags & NETLBL_SECATTR_MLS_CAT) {
1006 ret_val = cipso_v4_map_cat_rbm_hton(doi_def, 1251 ret_val = cipso_v4_map_cat_rbm_hton(doi_def,
1007 secattr->mls_cat, 1252 secattr,
1008 secattr->mls_cat_len, 1253 &buffer[4],
1009 &buf[CIPSO_V4_HDR_LEN + 4], 1254 buffer_len - 4);
1010 CIPSO_V4_TAG1_CAT_LEN);
1011 if (ret_val < 0) 1255 if (ret_val < 0)
1012 goto gentag_failure; 1256 return ret_val;
1013 1257
1014 /* This will send packets using the "optimized" format when 1258 /* This will send packets using the "optimized" format when
1015 * possibile as specified in section 3.4.2.6 of the 1259 * possibile as specified in section 3.4.2.6 of the
1016 * CIPSO draft. */ 1260 * CIPSO draft. */
1017 if (cipso_v4_rbm_optfmt && (ret_val > 0 && ret_val < 10)) 1261 if (cipso_v4_rbm_optfmt && ret_val > 0 && ret_val <= 10)
1018 ret_val = 10; 1262 tag_len = 14;
1263 else
1264 tag_len = 4 + ret_val;
1265 } else
1266 tag_len = 4;
1267
1268 buffer[0] = 0x01;
1269 buffer[1] = tag_len;
1270 buffer[3] = level;
1271
1272 return tag_len;
1273}
1019 1274
1020 buf_len = 4 + ret_val; 1275/**
1021 } else { 1276 * cipso_v4_parsetag_rbm - Parse a CIPSO restricted bitmap tag
1022 buf = kzalloc(CIPSO_V4_HDR_LEN + 4, GFP_ATOMIC); 1277 * @doi_def: the DOI definition
1023 if (buf == NULL) 1278 * @tag: the CIPSO tag
1279 * @secattr: the security attributes
1280 *
1281 * Description:
1282 * Parse a CIPSO restricted bitmap tag (tag type #1) and return the security
1283 * attributes in @secattr. Return zero on success, negatives values on
1284 * failure.
1285 *
1286 */
1287static int cipso_v4_parsetag_rbm(const struct cipso_v4_doi *doi_def,
1288 const unsigned char *tag,
1289 struct netlbl_lsm_secattr *secattr)
1290{
1291 int ret_val;
1292 u8 tag_len = tag[1];
1293 u32 level;
1294
1295 ret_val = cipso_v4_map_lvl_ntoh(doi_def, tag[3], &level);
1296 if (ret_val != 0)
1297 return ret_val;
1298 secattr->mls_lvl = level;
1299 secattr->flags |= NETLBL_SECATTR_MLS_LVL;
1300
1301 if (tag_len > 4) {
1302 secattr->mls_cat = netlbl_secattr_catmap_alloc(GFP_ATOMIC);
1303 if (secattr->mls_cat == NULL)
1024 return -ENOMEM; 1304 return -ENOMEM;
1025 buf_len = 4; 1305
1306 ret_val = cipso_v4_map_cat_rbm_ntoh(doi_def,
1307 &tag[4],
1308 tag_len - 4,
1309 secattr);
1310 if (ret_val != 0) {
1311 netlbl_secattr_catmap_free(secattr->mls_cat);
1312 return ret_val;
1313 }
1314
1315 secattr->flags |= NETLBL_SECATTR_MLS_CAT;
1026 } 1316 }
1027 1317
1318 return 0;
1319}
1320
1321/**
1322 * cipso_v4_gentag_enum - Generate a CIPSO enumerated tag (type #2)
1323 * @doi_def: the DOI definition
1324 * @secattr: the security attributes
1325 * @buffer: the option buffer
1326 * @buffer_len: length of buffer in bytes
1327 *
1328 * Description:
1329 * Generate a CIPSO option using the enumerated tag, tag type #2. Returns the
1330 * size of the tag on success, negative values on failure.
1331 *
1332 */
1333static int cipso_v4_gentag_enum(const struct cipso_v4_doi *doi_def,
1334 const struct netlbl_lsm_secattr *secattr,
1335 unsigned char *buffer,
1336 u32 buffer_len)
1337{
1338 int ret_val;
1339 u32 tag_len;
1340 u32 level;
1341
1342 if (!(secattr->flags & NETLBL_SECATTR_MLS_LVL))
1343 return -EPERM;
1344
1028 ret_val = cipso_v4_map_lvl_hton(doi_def, secattr->mls_lvl, &level); 1345 ret_val = cipso_v4_map_lvl_hton(doi_def, secattr->mls_lvl, &level);
1029 if (ret_val != 0) 1346 if (ret_val != 0)
1030 goto gentag_failure; 1347 return ret_val;
1348
1349 if (secattr->flags & NETLBL_SECATTR_MLS_CAT) {
1350 ret_val = cipso_v4_map_cat_enum_hton(doi_def,
1351 secattr,
1352 &buffer[4],
1353 buffer_len - 4);
1354 if (ret_val < 0)
1355 return ret_val;
1356
1357 tag_len = 4 + ret_val;
1358 } else
1359 tag_len = 4;
1360
1361 buffer[0] = 0x02;
1362 buffer[1] = tag_len;
1363 buffer[3] = level;
1031 1364
1032 ret_val = cipso_v4_gentag_hdr(doi_def, buf_len, buf); 1365 return tag_len;
1366}
1367
1368/**
1369 * cipso_v4_parsetag_enum - Parse a CIPSO enumerated tag
1370 * @doi_def: the DOI definition
1371 * @tag: the CIPSO tag
1372 * @secattr: the security attributes
1373 *
1374 * Description:
1375 * Parse a CIPSO enumerated tag (tag type #2) and return the security
1376 * attributes in @secattr. Return zero on success, negatives values on
1377 * failure.
1378 *
1379 */
1380static int cipso_v4_parsetag_enum(const struct cipso_v4_doi *doi_def,
1381 const unsigned char *tag,
1382 struct netlbl_lsm_secattr *secattr)
1383{
1384 int ret_val;
1385 u8 tag_len = tag[1];
1386 u32 level;
1387
1388 ret_val = cipso_v4_map_lvl_ntoh(doi_def, tag[3], &level);
1033 if (ret_val != 0) 1389 if (ret_val != 0)
1034 goto gentag_failure; 1390 return ret_val;
1391 secattr->mls_lvl = level;
1392 secattr->flags |= NETLBL_SECATTR_MLS_LVL;
1393
1394 if (tag_len > 4) {
1395 secattr->mls_cat = netlbl_secattr_catmap_alloc(GFP_ATOMIC);
1396 if (secattr->mls_cat == NULL)
1397 return -ENOMEM;
1035 1398
1036 buf[CIPSO_V4_HDR_LEN] = 0x01; 1399 ret_val = cipso_v4_map_cat_enum_ntoh(doi_def,
1037 buf[CIPSO_V4_HDR_LEN + 1] = buf_len; 1400 &tag[4],
1038 buf[CIPSO_V4_HDR_LEN + 3] = level; 1401 tag_len - 4,
1402 secattr);
1403 if (ret_val != 0) {
1404 netlbl_secattr_catmap_free(secattr->mls_cat);
1405 return ret_val;
1406 }
1039 1407
1040 *buffer = buf; 1408 secattr->flags |= NETLBL_SECATTR_MLS_CAT;
1041 *buffer_len = CIPSO_V4_HDR_LEN + buf_len; 1409 }
1042 1410
1043 return 0; 1411 return 0;
1412}
1044 1413
1045gentag_failure: 1414/**
1046 kfree(buf); 1415 * cipso_v4_gentag_rng - Generate a CIPSO ranged tag (type #5)
1047 return ret_val; 1416 * @doi_def: the DOI definition
1417 * @secattr: the security attributes
1418 * @buffer: the option buffer
1419 * @buffer_len: length of buffer in bytes
1420 *
1421 * Description:
1422 * Generate a CIPSO option using the ranged tag, tag type #5. Returns the
1423 * size of the tag on success, negative values on failure.
1424 *
1425 */
1426static int cipso_v4_gentag_rng(const struct cipso_v4_doi *doi_def,
1427 const struct netlbl_lsm_secattr *secattr,
1428 unsigned char *buffer,
1429 u32 buffer_len)
1430{
1431 int ret_val;
1432 u32 tag_len;
1433 u32 level;
1434
1435 if (!(secattr->flags & NETLBL_SECATTR_MLS_LVL))
1436 return -EPERM;
1437
1438 ret_val = cipso_v4_map_lvl_hton(doi_def, secattr->mls_lvl, &level);
1439 if (ret_val != 0)
1440 return ret_val;
1441
1442 if (secattr->flags & NETLBL_SECATTR_MLS_CAT) {
1443 ret_val = cipso_v4_map_cat_rng_hton(doi_def,
1444 secattr,
1445 &buffer[4],
1446 buffer_len - 4);
1447 if (ret_val < 0)
1448 return ret_val;
1449
1450 tag_len = 4 + ret_val;
1451 } else
1452 tag_len = 4;
1453
1454 buffer[0] = 0x05;
1455 buffer[1] = tag_len;
1456 buffer[3] = level;
1457
1458 return tag_len;
1048} 1459}
1049 1460
1050/** 1461/**
1051 * cipso_v4_parsetag_rbm - Parse a CIPSO restricted bitmap tag 1462 * cipso_v4_parsetag_rng - Parse a CIPSO ranged tag
1052 * @doi_def: the DOI definition 1463 * @doi_def: the DOI definition
1053 * @tag: the CIPSO tag 1464 * @tag: the CIPSO tag
1054 * @secattr: the security attributes 1465 * @secattr: the security attributes
1055 * 1466 *
1056 * Description: 1467 * Description:
1057 * Parse a CIPSO restricted bitmap tag (tag type #1) and return the security 1468 * Parse a CIPSO ranged tag (tag type #5) and return the security attributes
1058 * attributes in @secattr. Return zero on success, negatives values on 1469 * in @secattr. Return zero on success, negatives values on failure.
1059 * failure.
1060 * 1470 *
1061 */ 1471 */
1062static int cipso_v4_parsetag_rbm(const struct cipso_v4_doi *doi_def, 1472static int cipso_v4_parsetag_rng(const struct cipso_v4_doi *doi_def,
1063 const unsigned char *tag, 1473 const unsigned char *tag,
1064 struct netlbl_lsm_secattr *secattr) 1474 struct netlbl_lsm_secattr *secattr)
1065{ 1475{
@@ -1071,32 +1481,23 @@ static int cipso_v4_parsetag_rbm(const struct cipso_v4_doi *doi_def,
1071 if (ret_val != 0) 1481 if (ret_val != 0)
1072 return ret_val; 1482 return ret_val;
1073 secattr->mls_lvl = level; 1483 secattr->mls_lvl = level;
1074 secattr->mls_lvl_vld = 1; 1484 secattr->flags |= NETLBL_SECATTR_MLS_LVL;
1075 1485
1076 if (tag_len > 4) { 1486 if (tag_len > 4) {
1077 switch (doi_def->type) { 1487 secattr->mls_cat = netlbl_secattr_catmap_alloc(GFP_ATOMIC);
1078 case CIPSO_V4_MAP_PASS:
1079 secattr->mls_cat_len = tag_len - 4;
1080 break;
1081 case CIPSO_V4_MAP_STD:
1082 secattr->mls_cat_len =
1083 doi_def->map.std->cat.local_size;
1084 break;
1085 }
1086 secattr->mls_cat = kzalloc(secattr->mls_cat_len, GFP_ATOMIC);
1087 if (secattr->mls_cat == NULL) 1488 if (secattr->mls_cat == NULL)
1088 return -ENOMEM; 1489 return -ENOMEM;
1089 1490
1090 ret_val = cipso_v4_map_cat_rbm_ntoh(doi_def, 1491 ret_val = cipso_v4_map_cat_rng_ntoh(doi_def,
1091 &tag[4], 1492 &tag[4],
1092 tag_len - 4, 1493 tag_len - 4,
1093 secattr->mls_cat, 1494 secattr);
1094 secattr->mls_cat_len); 1495 if (ret_val != 0) {
1095 if (ret_val < 0) { 1496 netlbl_secattr_catmap_free(secattr->mls_cat);
1096 kfree(secattr->mls_cat);
1097 return ret_val; 1497 return ret_val;
1098 } 1498 }
1099 secattr->mls_cat_len = ret_val; 1499
1500 secattr->flags |= NETLBL_SECATTR_MLS_CAT;
1100 } 1501 }
1101 1502
1102 return 0; 1503 return 0;
@@ -1140,7 +1541,7 @@ int cipso_v4_validate(unsigned char **option)
1140 } 1541 }
1141 1542
1142 rcu_read_lock(); 1543 rcu_read_lock();
1143 doi_def = cipso_v4_doi_getdef(ntohl(*((u32 *)&opt[2]))); 1544 doi_def = cipso_v4_doi_search(ntohl(*((__be32 *)&opt[2])));
1144 if (doi_def == NULL) { 1545 if (doi_def == NULL) {
1145 err_offset = 2; 1546 err_offset = 2;
1146 goto validate_return_locked; 1547 goto validate_return_locked;
@@ -1191,6 +1592,44 @@ int cipso_v4_validate(unsigned char **option)
1191 } 1592 }
1192 } 1593 }
1193 break; 1594 break;
1595 case CIPSO_V4_TAG_ENUM:
1596 if (tag_len < 4) {
1597 err_offset = opt_iter + 1;
1598 goto validate_return_locked;
1599 }
1600
1601 if (cipso_v4_map_lvl_valid(doi_def,
1602 tag[3]) < 0) {
1603 err_offset = opt_iter + 3;
1604 goto validate_return_locked;
1605 }
1606 if (tag_len > 4 &&
1607 cipso_v4_map_cat_enum_valid(doi_def,
1608 &tag[4],
1609 tag_len - 4) < 0) {
1610 err_offset = opt_iter + 4;
1611 goto validate_return_locked;
1612 }
1613 break;
1614 case CIPSO_V4_TAG_RANGE:
1615 if (tag_len < 4) {
1616 err_offset = opt_iter + 1;
1617 goto validate_return_locked;
1618 }
1619
1620 if (cipso_v4_map_lvl_valid(doi_def,
1621 tag[3]) < 0) {
1622 err_offset = opt_iter + 3;
1623 goto validate_return_locked;
1624 }
1625 if (tag_len > 4 &&
1626 cipso_v4_map_cat_rng_valid(doi_def,
1627 &tag[4],
1628 tag_len - 4) < 0) {
1629 err_offset = opt_iter + 4;
1630 goto validate_return_locked;
1631 }
1632 break;
1194 default: 1633 default:
1195 err_offset = opt_iter; 1634 err_offset = opt_iter;
1196 goto validate_return_locked; 1635 goto validate_return_locked;
@@ -1265,7 +1704,7 @@ int cipso_v4_socket_setattr(const struct socket *sock,
1265{ 1704{
1266 int ret_val = -EPERM; 1705 int ret_val = -EPERM;
1267 u32 iter; 1706 u32 iter;
1268 unsigned char *buf = NULL; 1707 unsigned char *buf;
1269 u32 buf_len = 0; 1708 u32 buf_len = 0;
1270 u32 opt_len; 1709 u32 opt_len;
1271 struct ip_options *opt = NULL; 1710 struct ip_options *opt = NULL;
@@ -1281,17 +1720,40 @@ int cipso_v4_socket_setattr(const struct socket *sock,
1281 if (sk == NULL) 1720 if (sk == NULL)
1282 return 0; 1721 return 0;
1283 1722
1723 /* We allocate the maximum CIPSO option size here so we are probably
1724 * being a little wasteful, but it makes our life _much_ easier later
1725 * on and after all we are only talking about 40 bytes. */
1726 buf_len = CIPSO_V4_OPT_LEN_MAX;
1727 buf = kmalloc(buf_len, GFP_ATOMIC);
1728 if (buf == NULL) {
1729 ret_val = -ENOMEM;
1730 goto socket_setattr_failure;
1731 }
1732
1284 /* XXX - This code assumes only one tag per CIPSO option which isn't 1733 /* XXX - This code assumes only one tag per CIPSO option which isn't
1285 * really a good assumption to make but since we only support the MAC 1734 * really a good assumption to make but since we only support the MAC
1286 * tags right now it is a safe assumption. */ 1735 * tags right now it is a safe assumption. */
1287 iter = 0; 1736 iter = 0;
1288 do { 1737 do {
1738 memset(buf, 0, buf_len);
1289 switch (doi_def->tags[iter]) { 1739 switch (doi_def->tags[iter]) {
1290 case CIPSO_V4_TAG_RBITMAP: 1740 case CIPSO_V4_TAG_RBITMAP:
1291 ret_val = cipso_v4_gentag_rbm(doi_def, 1741 ret_val = cipso_v4_gentag_rbm(doi_def,
1292 secattr, 1742 secattr,
1293 &buf, 1743 &buf[CIPSO_V4_HDR_LEN],
1294 &buf_len); 1744 buf_len - CIPSO_V4_HDR_LEN);
1745 break;
1746 case CIPSO_V4_TAG_ENUM:
1747 ret_val = cipso_v4_gentag_enum(doi_def,
1748 secattr,
1749 &buf[CIPSO_V4_HDR_LEN],
1750 buf_len - CIPSO_V4_HDR_LEN);
1751 break;
1752 case CIPSO_V4_TAG_RANGE:
1753 ret_val = cipso_v4_gentag_rng(doi_def,
1754 secattr,
1755 &buf[CIPSO_V4_HDR_LEN],
1756 buf_len - CIPSO_V4_HDR_LEN);
1295 break; 1757 break;
1296 default: 1758 default:
1297 ret_val = -EPERM; 1759 ret_val = -EPERM;
@@ -1299,11 +1761,13 @@ int cipso_v4_socket_setattr(const struct socket *sock,
1299 } 1761 }
1300 1762
1301 iter++; 1763 iter++;
1302 } while (ret_val != 0 && 1764 } while (ret_val < 0 &&
1303 iter < CIPSO_V4_TAG_MAXCNT && 1765 iter < CIPSO_V4_TAG_MAXCNT &&
1304 doi_def->tags[iter] != CIPSO_V4_TAG_INVALID); 1766 doi_def->tags[iter] != CIPSO_V4_TAG_INVALID);
1305 if (ret_val != 0) 1767 if (ret_val < 0)
1306 goto socket_setattr_failure; 1768 goto socket_setattr_failure;
1769 cipso_v4_gentag_hdr(doi_def, buf, ret_val);
1770 buf_len = CIPSO_V4_HDR_LEN + ret_val;
1307 1771
1308 /* We can't use ip_options_get() directly because it makes a call to 1772 /* We can't use ip_options_get() directly because it makes a call to
1309 * ip_options_get_alloc() which allocates memory with GFP_KERNEL and 1773 * ip_options_get_alloc() which allocates memory with GFP_KERNEL and
@@ -1370,19 +1834,33 @@ int cipso_v4_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)
1370 if (ret_val == 0) 1834 if (ret_val == 0)
1371 return ret_val; 1835 return ret_val;
1372 1836
1373 doi = ntohl(*(u32 *)&cipso_ptr[2]); 1837 doi = ntohl(*(__be32 *)&cipso_ptr[2]);
1374 rcu_read_lock(); 1838 rcu_read_lock();
1375 doi_def = cipso_v4_doi_getdef(doi); 1839 doi_def = cipso_v4_doi_search(doi);
1376 if (doi_def == NULL) { 1840 if (doi_def == NULL) {
1377 rcu_read_unlock(); 1841 rcu_read_unlock();
1378 return -ENOMSG; 1842 return -ENOMSG;
1379 } 1843 }
1844
1845 /* XXX - This code assumes only one tag per CIPSO option which isn't
1846 * really a good assumption to make but since we only support the MAC
1847 * tags right now it is a safe assumption. */
1380 switch (cipso_ptr[6]) { 1848 switch (cipso_ptr[6]) {
1381 case CIPSO_V4_TAG_RBITMAP: 1849 case CIPSO_V4_TAG_RBITMAP:
1382 ret_val = cipso_v4_parsetag_rbm(doi_def, 1850 ret_val = cipso_v4_parsetag_rbm(doi_def,
1383 &cipso_ptr[6], 1851 &cipso_ptr[6],
1384 secattr); 1852 secattr);
1385 break; 1853 break;
1854 case CIPSO_V4_TAG_ENUM:
1855 ret_val = cipso_v4_parsetag_enum(doi_def,
1856 &cipso_ptr[6],
1857 secattr);
1858 break;
1859 case CIPSO_V4_TAG_RANGE:
1860 ret_val = cipso_v4_parsetag_rng(doi_def,
1861 &cipso_ptr[6],
1862 secattr);
1863 break;
1386 } 1864 }
1387 rcu_read_unlock(); 1865 rcu_read_unlock();
1388 1866
@@ -1430,23 +1908,30 @@ int cipso_v4_skbuff_getattr(const struct sk_buff *skb,
1430 u32 doi; 1908 u32 doi;
1431 struct cipso_v4_doi *doi_def; 1909 struct cipso_v4_doi *doi_def;
1432 1910
1433 if (!CIPSO_V4_OPTEXIST(skb))
1434 return -ENOMSG;
1435 cipso_ptr = CIPSO_V4_OPTPTR(skb); 1911 cipso_ptr = CIPSO_V4_OPTPTR(skb);
1436 if (cipso_v4_cache_check(cipso_ptr, cipso_ptr[1], secattr) == 0) 1912 if (cipso_v4_cache_check(cipso_ptr, cipso_ptr[1], secattr) == 0)
1437 return 0; 1913 return 0;
1438 1914
1439 doi = ntohl(*(u32 *)&cipso_ptr[2]); 1915 doi = ntohl(*(__be32 *)&cipso_ptr[2]);
1440 rcu_read_lock(); 1916 rcu_read_lock();
1441 doi_def = cipso_v4_doi_getdef(doi); 1917 doi_def = cipso_v4_doi_search(doi);
1442 if (doi_def == NULL) 1918 if (doi_def == NULL)
1443 goto skbuff_getattr_return; 1919 goto skbuff_getattr_return;
1920
1921 /* XXX - This code assumes only one tag per CIPSO option which isn't
1922 * really a good assumption to make but since we only support the MAC
1923 * tags right now it is a safe assumption. */
1444 switch (cipso_ptr[6]) { 1924 switch (cipso_ptr[6]) {
1445 case CIPSO_V4_TAG_RBITMAP: 1925 case CIPSO_V4_TAG_RBITMAP:
1446 ret_val = cipso_v4_parsetag_rbm(doi_def, 1926 ret_val = cipso_v4_parsetag_rbm(doi_def,
1447 &cipso_ptr[6], 1927 &cipso_ptr[6],
1448 secattr); 1928 secattr);
1449 break; 1929 break;
1930 case CIPSO_V4_TAG_ENUM:
1931 ret_val = cipso_v4_parsetag_enum(doi_def,
1932 &cipso_ptr[6],
1933 secattr);
1934 break;
1450 } 1935 }
1451 1936
1452skbuff_getattr_return: 1937skbuff_getattr_return:
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 7602c79a389b..2fd899160f85 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -577,20 +577,20 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
577 * Determine a default network mask, based on the IP address. 577 * Determine a default network mask, based on the IP address.
578 */ 578 */
579 579
580static __inline__ int inet_abc_len(u32 addr) 580static __inline__ int inet_abc_len(__be32 addr)
581{ 581{
582 int rc = -1; /* Something else, probably a multicast. */ 582 int rc = -1; /* Something else, probably a multicast. */
583 583
584 if (ZERONET(addr)) 584 if (ZERONET(addr))
585 rc = 0; 585 rc = 0;
586 else { 586 else {
587 addr = ntohl(addr); 587 __u32 haddr = ntohl(addr);
588 588
589 if (IN_CLASSA(addr)) 589 if (IN_CLASSA(haddr))
590 rc = 8; 590 rc = 8;
591 else if (IN_CLASSB(addr)) 591 else if (IN_CLASSB(haddr))
592 rc = 16; 592 rc = 16;
593 else if (IN_CLASSC(addr)) 593 else if (IN_CLASSC(haddr))
594 rc = 24; 594 rc = 24;
595 } 595 }
596 596
@@ -1120,6 +1120,16 @@ static struct notifier_block ip_netdev_notifier = {
1120 .notifier_call =inetdev_event, 1120 .notifier_call =inetdev_event,
1121}; 1121};
1122 1122
1123static inline size_t inet_nlmsg_size(void)
1124{
1125 return NLMSG_ALIGN(sizeof(struct ifaddrmsg))
1126 + nla_total_size(4) /* IFA_ADDRESS */
1127 + nla_total_size(4) /* IFA_LOCAL */
1128 + nla_total_size(4) /* IFA_BROADCAST */
1129 + nla_total_size(4) /* IFA_ANYCAST */
1130 + nla_total_size(IFNAMSIZ); /* IFA_LABEL */
1131}
1132
1123static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa, 1133static int inet_fill_ifaddr(struct sk_buff *skb, struct in_ifaddr *ifa,
1124 u32 pid, u32 seq, int event, unsigned int flags) 1134 u32 pid, u32 seq, int event, unsigned int flags)
1125{ 1135{
@@ -1208,15 +1218,13 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa, struct nlmsghdr *nlh,
1208 u32 seq = nlh ? nlh->nlmsg_seq : 0; 1218 u32 seq = nlh ? nlh->nlmsg_seq : 0;
1209 int err = -ENOBUFS; 1219 int err = -ENOBUFS;
1210 1220
1211 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 1221 skb = nlmsg_new(inet_nlmsg_size(), GFP_KERNEL);
1212 if (skb == NULL) 1222 if (skb == NULL)
1213 goto errout; 1223 goto errout;
1214 1224
1215 err = inet_fill_ifaddr(skb, ifa, pid, seq, event, 0); 1225 err = inet_fill_ifaddr(skb, ifa, pid, seq, event, 0);
1216 if (err < 0) { 1226 /* failure implies BUG in inet_nlmsg_size() */
1217 kfree_skb(skb); 1227 BUG_ON(err < 0);
1218 goto errout;
1219 }
1220 1228
1221 err = rtnl_notify(skb, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL); 1229 err = rtnl_notify(skb, pid, RTNLGRP_IPV4_IFADDR, nlh, GFP_KERNEL);
1222errout: 1230errout:
@@ -1556,12 +1564,12 @@ static void devinet_sysctl_register(struct in_device *in_dev,
1556{ 1564{
1557 int i; 1565 int i;
1558 struct net_device *dev = in_dev ? in_dev->dev : NULL; 1566 struct net_device *dev = in_dev ? in_dev->dev : NULL;
1559 struct devinet_sysctl_table *t = kmalloc(sizeof(*t), GFP_KERNEL); 1567 struct devinet_sysctl_table *t = kmemdup(&devinet_sysctl, sizeof(*t),
1568 GFP_KERNEL);
1560 char *dev_name = NULL; 1569 char *dev_name = NULL;
1561 1570
1562 if (!t) 1571 if (!t)
1563 return; 1572 return;
1564 memcpy(t, &devinet_sysctl, sizeof(*t));
1565 for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) { 1573 for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) {
1566 t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf; 1574 t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf;
1567 t->devinet_vars[i].de = NULL; 1575 t->devinet_vars[i].de = NULL;
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index b5c205b57669..f2c6776ea0e6 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -67,7 +67,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
67 if (x->encap) { 67 if (x->encap) {
68 struct xfrm_encap_tmpl *encap = x->encap; 68 struct xfrm_encap_tmpl *encap = x->encap;
69 struct udphdr *uh; 69 struct udphdr *uh;
70 u32 *udpdata32; 70 __be32 *udpdata32;
71 71
72 uh = (struct udphdr *)esph; 72 uh = (struct udphdr *)esph;
73 uh->source = encap->encap_sport; 73 uh->source = encap->encap_sport;
@@ -81,7 +81,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
81 esph = (struct ip_esp_hdr *)(uh + 1); 81 esph = (struct ip_esp_hdr *)(uh + 1);
82 break; 82 break;
83 case UDP_ENCAP_ESPINUDP_NON_IKE: 83 case UDP_ENCAP_ESPINUDP_NON_IKE:
84 udpdata32 = (u32 *)(uh + 1); 84 udpdata32 = (__be32 *)(uh + 1);
85 udpdata32[0] = udpdata32[1] = 0; 85 udpdata32[0] = udpdata32[1] = 0;
86 esph = (struct ip_esp_hdr *)(udpdata32 + 2); 86 esph = (struct ip_esp_hdr *)(udpdata32 + 2);
87 break; 87 break;
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index af0190d8b6c0..d47b72af89ed 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -768,8 +768,8 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb )
768{ 768{
769 769
770 struct fib_result res; 770 struct fib_result res;
771 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = frn->fl_addr, 771 struct flowi fl = { .mark = frn->fl_mark,
772 .fwmark = frn->fl_fwmark, 772 .nl_u = { .ip4_u = { .daddr = frn->fl_addr,
773 .tos = frn->fl_tos, 773 .tos = frn->fl_tos,
774 .scope = frn->fl_scope } } }; 774 .scope = frn->fl_scope } } };
775 if (tb) { 775 if (tb) {
@@ -811,7 +811,6 @@ static void nl_fib_input(struct sock *sk, int len)
811 811
812 pid = nlh->nlmsg_pid; /*pid of sending process */ 812 pid = nlh->nlmsg_pid; /*pid of sending process */
813 NETLINK_CB(skb).pid = 0; /* from kernel */ 813 NETLINK_CB(skb).pid = 0; /* from kernel */
814 NETLINK_CB(skb).dst_pid = pid;
815 NETLINK_CB(skb).dst_group = 0; /* unicast */ 814 NETLINK_CB(skb).dst_group = 0; /* unicast */
816 netlink_unicast(sk, skb, pid, MSG_DONTWAIT); 815 netlink_unicast(sk, skb, pid, MSG_DONTWAIT);
817} 816}
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 0852b9cd065a..b837c33e0404 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -44,10 +44,6 @@ struct fib4_rule
44 __be32 srcmask; 44 __be32 srcmask;
45 __be32 dst; 45 __be32 dst;
46 __be32 dstmask; 46 __be32 dstmask;
47#ifdef CONFIG_IP_ROUTE_FWMARK
48 u32 fwmark;
49 u32 fwmask;
50#endif
51#ifdef CONFIG_NET_CLS_ROUTE 47#ifdef CONFIG_NET_CLS_ROUTE
52 u32 tclassid; 48 u32 tclassid;
53#endif 49#endif
@@ -160,11 +156,6 @@ static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
160 if (r->tos && (r->tos != fl->fl4_tos)) 156 if (r->tos && (r->tos != fl->fl4_tos))
161 return 0; 157 return 0;
162 158
163#ifdef CONFIG_IP_ROUTE_FWMARK
164 if ((r->fwmark ^ fl->fl4_fwmark) & r->fwmask)
165 return 0;
166#endif
167
168 return 1; 159 return 1;
169} 160}
170 161
@@ -179,14 +170,10 @@ static struct fib_table *fib_empty_table(void)
179} 170}
180 171
181static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = { 172static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = {
182 [FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, 173 FRA_GENERIC_POLICY,
183 [FRA_PRIORITY] = { .type = NLA_U32 },
184 [FRA_SRC] = { .type = NLA_U32 }, 174 [FRA_SRC] = { .type = NLA_U32 },
185 [FRA_DST] = { .type = NLA_U32 }, 175 [FRA_DST] = { .type = NLA_U32 },
186 [FRA_FWMARK] = { .type = NLA_U32 },
187 [FRA_FWMASK] = { .type = NLA_U32 },
188 [FRA_FLOW] = { .type = NLA_U32 }, 176 [FRA_FLOW] = { .type = NLA_U32 },
189 [FRA_TABLE] = { .type = NLA_U32 },
190}; 177};
191 178
192static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb, 179static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
@@ -220,20 +207,6 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
220 if (tb[FRA_DST]) 207 if (tb[FRA_DST])
221 rule4->dst = nla_get_be32(tb[FRA_DST]); 208 rule4->dst = nla_get_be32(tb[FRA_DST]);
222 209
223#ifdef CONFIG_IP_ROUTE_FWMARK
224 if (tb[FRA_FWMARK]) {
225 rule4->fwmark = nla_get_u32(tb[FRA_FWMARK]);
226 if (rule4->fwmark)
227 /* compatibility: if the mark value is non-zero all bits
228 * are compared unless a mask is explicitly specified.
229 */
230 rule4->fwmask = 0xFFFFFFFF;
231 }
232
233 if (tb[FRA_FWMASK])
234 rule4->fwmask = nla_get_u32(tb[FRA_FWMASK]);
235#endif
236
237#ifdef CONFIG_NET_CLS_ROUTE 210#ifdef CONFIG_NET_CLS_ROUTE
238 if (tb[FRA_FLOW]) 211 if (tb[FRA_FLOW])
239 rule4->tclassid = nla_get_u32(tb[FRA_FLOW]); 212 rule4->tclassid = nla_get_u32(tb[FRA_FLOW]);
@@ -264,14 +237,6 @@ static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
264 if (frh->tos && (rule4->tos != frh->tos)) 237 if (frh->tos && (rule4->tos != frh->tos))
265 return 0; 238 return 0;
266 239
267#ifdef CONFIG_IP_ROUTE_FWMARK
268 if (tb[FRA_FWMARK] && (rule4->fwmark != nla_get_u32(tb[FRA_FWMARK])))
269 return 0;
270
271 if (tb[FRA_FWMASK] && (rule4->fwmask != nla_get_u32(tb[FRA_FWMASK])))
272 return 0;
273#endif
274
275#ifdef CONFIG_NET_CLS_ROUTE 240#ifdef CONFIG_NET_CLS_ROUTE
276 if (tb[FRA_FLOW] && (rule4->tclassid != nla_get_u32(tb[FRA_FLOW]))) 241 if (tb[FRA_FLOW] && (rule4->tclassid != nla_get_u32(tb[FRA_FLOW])))
277 return 0; 242 return 0;
@@ -296,14 +261,6 @@ static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
296 frh->src_len = rule4->src_len; 261 frh->src_len = rule4->src_len;
297 frh->tos = rule4->tos; 262 frh->tos = rule4->tos;
298 263
299#ifdef CONFIG_IP_ROUTE_FWMARK
300 if (rule4->fwmark)
301 NLA_PUT_U32(skb, FRA_FWMARK, rule4->fwmark);
302
303 if (rule4->fwmask || rule4->fwmark)
304 NLA_PUT_U32(skb, FRA_FWMASK, rule4->fwmask);
305#endif
306
307 if (rule4->dst_len) 264 if (rule4->dst_len)
308 NLA_PUT_BE32(skb, FRA_DST, rule4->dst); 265 NLA_PUT_BE32(skb, FRA_DST, rule4->dst);
309 266
@@ -342,6 +299,13 @@ static u32 fib4_rule_default_pref(void)
342 return 0; 299 return 0;
343} 300}
344 301
302static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule)
303{
304 return nla_total_size(4) /* dst */
305 + nla_total_size(4) /* src */
306 + nla_total_size(4); /* flow */
307}
308
345static struct fib_rules_ops fib4_rules_ops = { 309static struct fib_rules_ops fib4_rules_ops = {
346 .family = AF_INET, 310 .family = AF_INET,
347 .rule_size = sizeof(struct fib4_rule), 311 .rule_size = sizeof(struct fib4_rule),
@@ -351,6 +315,7 @@ static struct fib_rules_ops fib4_rules_ops = {
351 .compare = fib4_rule_compare, 315 .compare = fib4_rule_compare,
352 .fill = fib4_rule_fill, 316 .fill = fib4_rule_fill,
353 .default_pref = fib4_rule_default_pref, 317 .default_pref = fib4_rule_default_pref,
318 .nlmsg_payload = fib4_rule_nlmsg_payload,
354 .nlgroup = RTNLGRP_IPV4_RULE, 319 .nlgroup = RTNLGRP_IPV4_RULE,
355 .policy = fib4_rule_policy, 320 .policy = fib4_rule_policy,
356 .rules_list = &fib4_rules, 321 .rules_list = &fib4_rules,
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 884d176e0082..e63b8a98fb4d 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -273,25 +273,49 @@ int ip_fib_check_default(__be32 gw, struct net_device *dev)
273 return -1; 273 return -1;
274} 274}
275 275
276static inline size_t fib_nlmsg_size(struct fib_info *fi)
277{
278 size_t payload = NLMSG_ALIGN(sizeof(struct rtmsg))
279 + nla_total_size(4) /* RTA_TABLE */
280 + nla_total_size(4) /* RTA_DST */
281 + nla_total_size(4) /* RTA_PRIORITY */
282 + nla_total_size(4); /* RTA_PREFSRC */
283
284 /* space for nested metrics */
285 payload += nla_total_size((RTAX_MAX * nla_total_size(4)));
286
287 if (fi->fib_nhs) {
288 /* Also handles the special case fib_nhs == 1 */
289
290 /* each nexthop is packed in an attribute */
291 size_t nhsize = nla_total_size(sizeof(struct rtnexthop));
292
293 /* may contain flow and gateway attribute */
294 nhsize += 2 * nla_total_size(4);
295
296 /* all nexthops are packed in a nested attribute */
297 payload += nla_total_size(fi->fib_nhs * nhsize);
298 }
299
300 return payload;
301}
302
276void rtmsg_fib(int event, __be32 key, struct fib_alias *fa, 303void rtmsg_fib(int event, __be32 key, struct fib_alias *fa,
277 int dst_len, u32 tb_id, struct nl_info *info) 304 int dst_len, u32 tb_id, struct nl_info *info)
278{ 305{
279 struct sk_buff *skb; 306 struct sk_buff *skb;
280 int payload = sizeof(struct rtmsg) + 256;
281 u32 seq = info->nlh ? info->nlh->nlmsg_seq : 0; 307 u32 seq = info->nlh ? info->nlh->nlmsg_seq : 0;
282 int err = -ENOBUFS; 308 int err = -ENOBUFS;
283 309
284 skb = nlmsg_new(nlmsg_total_size(payload), GFP_KERNEL); 310 skb = nlmsg_new(fib_nlmsg_size(fa->fa_info), GFP_KERNEL);
285 if (skb == NULL) 311 if (skb == NULL)
286 goto errout; 312 goto errout;
287 313
288 err = fib_dump_info(skb, info->pid, seq, event, tb_id, 314 err = fib_dump_info(skb, info->pid, seq, event, tb_id,
289 fa->fa_type, fa->fa_scope, key, dst_len, 315 fa->fa_type, fa->fa_scope, key, dst_len,
290 fa->fa_tos, fa->fa_info, 0); 316 fa->fa_tos, fa->fa_info, 0);
291 if (err < 0) { 317 /* failure implies BUG in fib_nlmsg_size() */
292 kfree_skb(skb); 318 BUG_ON(err < 0);
293 goto errout;
294 }
295 319
296 err = rtnl_notify(skb, info->pid, RTNLGRP_IPV4_ROUTE, 320 err = rtnl_notify(skb, info->pid, RTNLGRP_IPV4_ROUTE,
297 info->nlh, GFP_KERNEL); 321 info->nlh, GFP_KERNEL);
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index b39a37a47545..40cf0d0e1b83 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -332,7 +332,7 @@ static int icmp_glue_bits(void *from, char *to, int offset, int len, int odd,
332 struct sk_buff *skb) 332 struct sk_buff *skb)
333{ 333{
334 struct icmp_bxm *icmp_param = (struct icmp_bxm *)from; 334 struct icmp_bxm *icmp_param = (struct icmp_bxm *)from;
335 unsigned int csum; 335 __wsum csum;
336 336
337 csum = skb_copy_and_csum_bits(icmp_param->skb, 337 csum = skb_copy_and_csum_bits(icmp_param->skb,
338 icmp_param->offset + offset, 338 icmp_param->offset + offset,
@@ -356,7 +356,7 @@ static void icmp_push_reply(struct icmp_bxm *icmp_param,
356 ip_flush_pending_frames(icmp_socket->sk); 356 ip_flush_pending_frames(icmp_socket->sk);
357 else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) { 357 else if ((skb = skb_peek(&icmp_socket->sk->sk_write_queue)) != NULL) {
358 struct icmphdr *icmph = skb->h.icmph; 358 struct icmphdr *icmph = skb->h.icmph;
359 unsigned int csum = 0; 359 __wsum csum = 0;
360 struct sk_buff *skb1; 360 struct sk_buff *skb1;
361 361
362 skb_queue_walk(&icmp_socket->sk->sk_write_queue, skb1) { 362 skb_queue_walk(&icmp_socket->sk->sk_write_queue, skb1) {
@@ -931,7 +931,7 @@ int icmp_rcv(struct sk_buff *skb)
931 931
932 switch (skb->ip_summed) { 932 switch (skb->ip_summed) {
933 case CHECKSUM_COMPLETE: 933 case CHECKSUM_COMPLETE:
934 if (!(u16)csum_fold(skb->csum)) 934 if (!csum_fold(skb->csum))
935 break; 935 break;
936 /* fall through */ 936 /* fall through */
937 case CHECKSUM_NONE: 937 case CHECKSUM_NONE:
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 6eee71647b7c..0017ccb01d6d 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -932,7 +932,7 @@ int igmp_rcv(struct sk_buff *skb)
932 932
933 switch (skb->ip_summed) { 933 switch (skb->ip_summed) {
934 case CHECKSUM_COMPLETE: 934 case CHECKSUM_COMPLETE:
935 if (!(u16)csum_fold(skb->csum)) 935 if (!csum_fold(skb->csum))
936 break; 936 break;
937 /* fall through */ 937 /* fall through */
938 case CHECKSUM_NONE: 938 case CHECKSUM_NONE:
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 96bbe2a0aa1b..9d68837888d3 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -343,7 +343,7 @@ struct dst_entry* inet_csk_route_req(struct sock *sk,
343EXPORT_SYMBOL_GPL(inet_csk_route_req); 343EXPORT_SYMBOL_GPL(inet_csk_route_req);
344 344
345static inline u32 inet_synq_hash(const __be32 raddr, const __be16 rport, 345static inline u32 inet_synq_hash(const __be32 raddr, const __be16 rport,
346 const u32 rnd, const u16 synq_hsize) 346 const u32 rnd, const u32 synq_hsize)
347{ 347{
348 return jhash_2words((__force u32)raddr, (__force u32)rport, rnd) & (synq_hsize - 1); 348 return jhash_2words((__force u32)raddr, (__force u32)rport, rnd) & (synq_hsize - 1);
349} 349}
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index d5b5dec075b8..476cb6084c75 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -144,7 +144,7 @@ static struct net_device *ipgre_fb_tunnel_dev;
144 */ 144 */
145 145
146#define HASH_SIZE 16 146#define HASH_SIZE 16
147#define HASH(addr) ((addr^(addr>>4))&0xF) 147#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)
148 148
149static struct ip_tunnel *tunnels[4][HASH_SIZE]; 149static struct ip_tunnel *tunnels[4][HASH_SIZE];
150 150
@@ -157,7 +157,7 @@ static DEFINE_RWLOCK(ipgre_lock);
157 157
158/* Given src, dst and key, find appropriate for input tunnel. */ 158/* Given src, dst and key, find appropriate for input tunnel. */
159 159
160static struct ip_tunnel * ipgre_tunnel_lookup(u32 remote, u32 local, u32 key) 160static struct ip_tunnel * ipgre_tunnel_lookup(__be32 remote, __be32 local, __be32 key)
161{ 161{
162 unsigned h0 = HASH(remote); 162 unsigned h0 = HASH(remote);
163 unsigned h1 = HASH(key); 163 unsigned h1 = HASH(key);
@@ -194,9 +194,9 @@ static struct ip_tunnel * ipgre_tunnel_lookup(u32 remote, u32 local, u32 key)
194 194
195static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t) 195static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t)
196{ 196{
197 u32 remote = t->parms.iph.daddr; 197 __be32 remote = t->parms.iph.daddr;
198 u32 local = t->parms.iph.saddr; 198 __be32 local = t->parms.iph.saddr;
199 u32 key = t->parms.i_key; 199 __be32 key = t->parms.i_key;
200 unsigned h = HASH(key); 200 unsigned h = HASH(key);
201 int prio = 0; 201 int prio = 0;
202 202
@@ -236,9 +236,9 @@ static void ipgre_tunnel_unlink(struct ip_tunnel *t)
236 236
237static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int create) 237static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int create)
238{ 238{
239 u32 remote = parms->iph.daddr; 239 __be32 remote = parms->iph.daddr;
240 u32 local = parms->iph.saddr; 240 __be32 local = parms->iph.saddr;
241 u32 key = parms->i_key; 241 __be32 key = parms->i_key;
242 struct ip_tunnel *t, **tp, *nt; 242 struct ip_tunnel *t, **tp, *nt;
243 struct net_device *dev; 243 struct net_device *dev;
244 unsigned h = HASH(key); 244 unsigned h = HASH(key);
@@ -319,12 +319,12 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
319 */ 319 */
320 320
321 struct iphdr *iph = (struct iphdr*)skb->data; 321 struct iphdr *iph = (struct iphdr*)skb->data;
322 u16 *p = (u16*)(skb->data+(iph->ihl<<2)); 322 __be16 *p = (__be16*)(skb->data+(iph->ihl<<2));
323 int grehlen = (iph->ihl<<2) + 4; 323 int grehlen = (iph->ihl<<2) + 4;
324 int type = skb->h.icmph->type; 324 int type = skb->h.icmph->type;
325 int code = skb->h.icmph->code; 325 int code = skb->h.icmph->code;
326 struct ip_tunnel *t; 326 struct ip_tunnel *t;
327 u16 flags; 327 __be16 flags;
328 328
329 flags = p[0]; 329 flags = p[0];
330 if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) { 330 if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) {
@@ -370,7 +370,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
370 } 370 }
371 371
372 read_lock(&ipgre_lock); 372 read_lock(&ipgre_lock);
373 t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((u32*)p) + (grehlen>>2) - 1) : 0); 373 t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((__be32*)p) + (grehlen>>2) - 1) : 0);
374 if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr)) 374 if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr))
375 goto out; 375 goto out;
376 376
@@ -388,14 +388,14 @@ out:
388#else 388#else
389 struct iphdr *iph = (struct iphdr*)dp; 389 struct iphdr *iph = (struct iphdr*)dp;
390 struct iphdr *eiph; 390 struct iphdr *eiph;
391 u16 *p = (u16*)(dp+(iph->ihl<<2)); 391 __be16 *p = (__be16*)(dp+(iph->ihl<<2));
392 int type = skb->h.icmph->type; 392 int type = skb->h.icmph->type;
393 int code = skb->h.icmph->code; 393 int code = skb->h.icmph->code;
394 int rel_type = 0; 394 int rel_type = 0;
395 int rel_code = 0; 395 int rel_code = 0;
396 __be32 rel_info = 0; 396 __be32 rel_info = 0;
397 __u32 n = 0; 397 __u32 n = 0;
398 u16 flags; 398 __be16 flags;
399 int grehlen = (iph->ihl<<2) + 4; 399 int grehlen = (iph->ihl<<2) + 4;
400 struct sk_buff *skb2; 400 struct sk_buff *skb2;
401 struct flowi fl; 401 struct flowi fl;
@@ -556,9 +556,9 @@ static int ipgre_rcv(struct sk_buff *skb)
556{ 556{
557 struct iphdr *iph; 557 struct iphdr *iph;
558 u8 *h; 558 u8 *h;
559 u16 flags; 559 __be16 flags;
560 u16 csum = 0; 560 __sum16 csum = 0;
561 u32 key = 0; 561 __be32 key = 0;
562 u32 seqno = 0; 562 u32 seqno = 0;
563 struct ip_tunnel *tunnel; 563 struct ip_tunnel *tunnel;
564 int offset = 4; 564 int offset = 4;
@@ -568,7 +568,7 @@ static int ipgre_rcv(struct sk_buff *skb)
568 568
569 iph = skb->nh.iph; 569 iph = skb->nh.iph;
570 h = skb->data; 570 h = skb->data;
571 flags = *(u16*)h; 571 flags = *(__be16*)h;
572 572
573 if (flags&(GRE_CSUM|GRE_KEY|GRE_ROUTING|GRE_SEQ|GRE_VERSION)) { 573 if (flags&(GRE_CSUM|GRE_KEY|GRE_ROUTING|GRE_SEQ|GRE_VERSION)) {
574 /* - Version must be 0. 574 /* - Version must be 0.
@@ -580,7 +580,7 @@ static int ipgre_rcv(struct sk_buff *skb)
580 if (flags&GRE_CSUM) { 580 if (flags&GRE_CSUM) {
581 switch (skb->ip_summed) { 581 switch (skb->ip_summed) {
582 case CHECKSUM_COMPLETE: 582 case CHECKSUM_COMPLETE:
583 csum = (u16)csum_fold(skb->csum); 583 csum = csum_fold(skb->csum);
584 if (!csum) 584 if (!csum)
585 break; 585 break;
586 /* fall through */ 586 /* fall through */
@@ -592,11 +592,11 @@ static int ipgre_rcv(struct sk_buff *skb)
592 offset += 4; 592 offset += 4;
593 } 593 }
594 if (flags&GRE_KEY) { 594 if (flags&GRE_KEY) {
595 key = *(u32*)(h + offset); 595 key = *(__be32*)(h + offset);
596 offset += 4; 596 offset += 4;
597 } 597 }
598 if (flags&GRE_SEQ) { 598 if (flags&GRE_SEQ) {
599 seqno = ntohl(*(u32*)(h + offset)); 599 seqno = ntohl(*(__be32*)(h + offset));
600 offset += 4; 600 offset += 4;
601 } 601 }
602 } 602 }
@@ -605,7 +605,7 @@ static int ipgre_rcv(struct sk_buff *skb)
605 if ((tunnel = ipgre_tunnel_lookup(iph->saddr, iph->daddr, key)) != NULL) { 605 if ((tunnel = ipgre_tunnel_lookup(iph->saddr, iph->daddr, key)) != NULL) {
606 secpath_reset(skb); 606 secpath_reset(skb);
607 607
608 skb->protocol = *(u16*)(h + 2); 608 skb->protocol = *(__be16*)(h + 2);
609 /* WCCP version 1 and 2 protocol decoding. 609 /* WCCP version 1 and 2 protocol decoding.
610 * - Change protocol to IP 610 * - Change protocol to IP
611 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header 611 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
@@ -673,13 +673,13 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
673 struct iphdr *old_iph = skb->nh.iph; 673 struct iphdr *old_iph = skb->nh.iph;
674 struct iphdr *tiph; 674 struct iphdr *tiph;
675 u8 tos; 675 u8 tos;
676 u16 df; 676 __be16 df;
677 struct rtable *rt; /* Route to the other host */ 677 struct rtable *rt; /* Route to the other host */
678 struct net_device *tdev; /* Device to other host */ 678 struct net_device *tdev; /* Device to other host */
679 struct iphdr *iph; /* Our new IP header */ 679 struct iphdr *iph; /* Our new IP header */
680 int max_headroom; /* The extra header space needed */ 680 int max_headroom; /* The extra header space needed */
681 int gre_hlen; 681 int gre_hlen;
682 u32 dst; 682 __be32 dst;
683 int mtu; 683 int mtu;
684 684
685 if (tunnel->recursion++) { 685 if (tunnel->recursion++) {
@@ -860,11 +860,11 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
860 iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT); 860 iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT);
861 } 861 }
862 862
863 ((u16*)(iph+1))[0] = tunnel->parms.o_flags; 863 ((__be16*)(iph+1))[0] = tunnel->parms.o_flags;
864 ((u16*)(iph+1))[1] = skb->protocol; 864 ((__be16*)(iph+1))[1] = skb->protocol;
865 865
866 if (tunnel->parms.o_flags&(GRE_KEY|GRE_CSUM|GRE_SEQ)) { 866 if (tunnel->parms.o_flags&(GRE_KEY|GRE_CSUM|GRE_SEQ)) {
867 u32 *ptr = (u32*)(((u8*)iph) + tunnel->hlen - 4); 867 __be32 *ptr = (__be32*)(((u8*)iph) + tunnel->hlen - 4);
868 868
869 if (tunnel->parms.o_flags&GRE_SEQ) { 869 if (tunnel->parms.o_flags&GRE_SEQ) {
870 ++tunnel->o_seqno; 870 ++tunnel->o_seqno;
@@ -877,7 +877,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
877 } 877 }
878 if (tunnel->parms.o_flags&GRE_CSUM) { 878 if (tunnel->parms.o_flags&GRE_CSUM) {
879 *ptr = 0; 879 *ptr = 0;
880 *(__u16*)ptr = ip_compute_csum((void*)(iph+1), skb->len - sizeof(struct iphdr)); 880 *(__sum16*)ptr = ip_compute_csum((void*)(iph+1), skb->len - sizeof(struct iphdr));
881 } 881 }
882 } 882 }
883 883
@@ -1068,7 +1068,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev, unsigned sh
1068{ 1068{
1069 struct ip_tunnel *t = netdev_priv(dev); 1069 struct ip_tunnel *t = netdev_priv(dev);
1070 struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen); 1070 struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen);
1071 u16 *p = (u16*)(iph+1); 1071 __be16 *p = (__be16*)(iph+1);
1072 1072
1073 memcpy(iph, &t->parms.iph, sizeof(struct iphdr)); 1073 memcpy(iph, &t->parms.iph, sizeof(struct iphdr));
1074 p[0] = t->parms.o_flags; 1074 p[0] = t->parms.o_flags;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index fc195a44fc2e..1da3d32f8289 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -288,9 +288,8 @@ int ip_output(struct sk_buff *skb)
288 !(IPCB(skb)->flags & IPSKB_REROUTED)); 288 !(IPCB(skb)->flags & IPSKB_REROUTED));
289} 289}
290 290
291int ip_queue_xmit(struct sk_buff *skb, int ipfragok) 291int ip_queue_xmit(struct sk_buff *skb, struct sock *sk, int ipfragok)
292{ 292{
293 struct sock *sk = skb->sk;
294 struct inet_sock *inet = inet_sk(sk); 293 struct inet_sock *inet = inet_sk(sk);
295 struct ip_options *opt = inet->opt; 294 struct ip_options *opt = inet->opt;
296 struct rtable *rt; 295 struct rtable *rt;
@@ -342,7 +341,7 @@ packet_routed:
342 341
343 /* OK, we know where to send it, allocate and build IP header. */ 342 /* OK, we know where to send it, allocate and build IP header. */
344 iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0)); 343 iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0));
345 *((__u16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); 344 *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff));
346 iph->tot_len = htons(skb->len); 345 iph->tot_len = htons(skb->len);
347 if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok) 346 if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok)
348 iph->frag_off = htons(IP_DF); 347 iph->frag_off = htons(IP_DF);
@@ -386,6 +385,7 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
386 dst_release(to->dst); 385 dst_release(to->dst);
387 to->dst = dst_clone(from->dst); 386 to->dst = dst_clone(from->dst);
388 to->dev = from->dev; 387 to->dev = from->dev;
388 to->mark = from->mark;
389 389
390 /* Copy the flags to each fragment. */ 390 /* Copy the flags to each fragment. */
391 IPCB(to)->flags = IPCB(from)->flags; 391 IPCB(to)->flags = IPCB(from)->flags;
@@ -394,7 +394,6 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
394 to->tc_index = from->tc_index; 394 to->tc_index = from->tc_index;
395#endif 395#endif
396#ifdef CONFIG_NETFILTER 396#ifdef CONFIG_NETFILTER
397 to->nfmark = from->nfmark;
398 /* Connection association is same as pre-frag packet */ 397 /* Connection association is same as pre-frag packet */
399 nf_conntrack_put(to->nfct); 398 nf_conntrack_put(to->nfct);
400 to->nfct = from->nfct; 399 to->nfct = from->nfct;
@@ -683,7 +682,7 @@ ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk
683 if (memcpy_fromiovecend(to, iov, offset, len) < 0) 682 if (memcpy_fromiovecend(to, iov, offset, len) < 0)
684 return -EFAULT; 683 return -EFAULT;
685 } else { 684 } else {
686 unsigned int csum = 0; 685 __wsum csum = 0;
687 if (csum_partial_copy_fromiovecend(to, iov, offset, len, &csum) < 0) 686 if (csum_partial_copy_fromiovecend(to, iov, offset, len, &csum) < 0)
688 return -EFAULT; 687 return -EFAULT;
689 skb->csum = csum_block_add(skb->csum, csum, odd); 688 skb->csum = csum_block_add(skb->csum, csum, odd);
@@ -691,11 +690,11 @@ ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk
691 return 0; 690 return 0;
692} 691}
693 692
694static inline unsigned int 693static inline __wsum
695csum_page(struct page *page, int offset, int copy) 694csum_page(struct page *page, int offset, int copy)
696{ 695{
697 char *kaddr; 696 char *kaddr;
698 unsigned int csum; 697 __wsum csum;
699 kaddr = kmap(page); 698 kaddr = kmap(page);
700 csum = csum_partial(kaddr + offset, copy, 0); 699 csum = csum_partial(kaddr + offset, copy, 0);
701 kunmap(page); 700 kunmap(page);
@@ -1167,7 +1166,7 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
1167 } 1166 }
1168 1167
1169 if (skb->ip_summed == CHECKSUM_NONE) { 1168 if (skb->ip_summed == CHECKSUM_NONE) {
1170 unsigned int csum; 1169 __wsum csum;
1171 csum = csum_page(page, offset, len); 1170 csum = csum_page(page, offset, len);
1172 skb->csum = csum_block_add(skb->csum, csum, skb->len); 1171 skb->csum = csum_block_add(skb->csum, csum, skb->len);
1173 } 1172 }
@@ -1315,7 +1314,7 @@ void ip_flush_pending_frames(struct sock *sk)
1315static int ip_reply_glue_bits(void *dptr, char *to, int offset, 1314static int ip_reply_glue_bits(void *dptr, char *to, int offset,
1316 int len, int odd, struct sk_buff *skb) 1315 int len, int odd, struct sk_buff *skb)
1317{ 1316{
1318 unsigned int csum; 1317 __wsum csum;
1319 1318
1320 csum = csum_partial_copy_nocheck(dptr+offset, to, len, 0); 1319 csum = csum_partial_copy_nocheck(dptr+offset, to, len, 0);
1321 skb->csum = csum_block_add(skb->csum, csum, odd); 1320 skb->csum = csum_block_add(skb->csum, csum, odd);
@@ -1385,7 +1384,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *ar
1385 &ipc, rt, MSG_DONTWAIT); 1384 &ipc, rt, MSG_DONTWAIT);
1386 if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) { 1385 if ((skb = skb_peek(&sk->sk_write_queue)) != NULL) {
1387 if (arg->csumoffset >= 0) 1386 if (arg->csumoffset >= 0)
1388 *((u16 *)skb->h.raw + arg->csumoffset) = csum_fold(csum_add(skb->csum, arg->csum)); 1387 *((__sum16 *)skb->h.raw + arg->csumoffset) = csum_fold(csum_add(skb->csum, arg->csum));
1389 skb->ip_summed = CHECKSUM_NONE; 1388 skb->ip_summed = CHECKSUM_NONE;
1390 ip_push_pending_frames(sk); 1389 ip_push_pending_frames(sk);
1391 } 1390 }
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 4b132953bcc2..57d4bae6f080 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -355,7 +355,7 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len)
355 sin = (struct sockaddr_in *)msg->msg_name; 355 sin = (struct sockaddr_in *)msg->msg_name;
356 if (sin) { 356 if (sin) {
357 sin->sin_family = AF_INET; 357 sin->sin_family = AF_INET;
358 sin->sin_addr.s_addr = *(u32*)(skb->nh.raw + serr->addr_offset); 358 sin->sin_addr.s_addr = *(__be32*)(skb->nh.raw + serr->addr_offset);
359 sin->sin_port = serr->port; 359 sin->sin_port = serr->port;
360 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); 360 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
361 } 361 }
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 955a07abb91d..afa60b9a003f 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -101,6 +101,7 @@
101#define CONF_NAMESERVERS_MAX 3 /* Maximum number of nameservers 101#define CONF_NAMESERVERS_MAX 3 /* Maximum number of nameservers
102 - '3' from resolv.h */ 102 - '3' from resolv.h */
103 103
104#define NONE __constant_htonl(INADDR_NONE)
104 105
105/* 106/*
106 * Public IP configuration 107 * Public IP configuration
@@ -129,19 +130,19 @@ int ic_proto_enabled __initdata = 0
129 130
130static int ic_host_name_set __initdata = 0; /* Host name set by us? */ 131static int ic_host_name_set __initdata = 0; /* Host name set by us? */
131 132
132u32 ic_myaddr = INADDR_NONE; /* My IP address */ 133__be32 ic_myaddr = NONE; /* My IP address */
133static u32 ic_netmask = INADDR_NONE; /* Netmask for local subnet */ 134static __be32 ic_netmask = NONE; /* Netmask for local subnet */
134u32 ic_gateway = INADDR_NONE; /* Gateway IP address */ 135__be32 ic_gateway = NONE; /* Gateway IP address */
135 136
136u32 ic_servaddr = INADDR_NONE; /* Boot server IP address */ 137__be32 ic_servaddr = NONE; /* Boot server IP address */
137 138
138u32 root_server_addr = INADDR_NONE; /* Address of NFS server */ 139__be32 root_server_addr = NONE; /* Address of NFS server */
139u8 root_server_path[256] = { 0, }; /* Path to mount as root */ 140u8 root_server_path[256] = { 0, }; /* Path to mount as root */
140 141
141/* Persistent data: */ 142/* Persistent data: */
142 143
143static int ic_proto_used; /* Protocol used, if any */ 144static int ic_proto_used; /* Protocol used, if any */
144static u32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */ 145static __be32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
145static u8 ic_domain[64]; /* DNS (not NIS) domain name */ 146static u8 ic_domain[64]; /* DNS (not NIS) domain name */
146 147
147/* 148/*
@@ -172,7 +173,7 @@ struct ic_device {
172 struct net_device *dev; 173 struct net_device *dev;
173 unsigned short flags; 174 unsigned short flags;
174 short able; 175 short able;
175 u32 xid; 176 __be32 xid;
176}; 177};
177 178
178static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */ 179static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */
@@ -223,7 +224,7 @@ static int __init ic_open_devs(void)
223 d->flags = oflags; 224 d->flags = oflags;
224 d->able = able; 225 d->able = able;
225 if (able & IC_BOOTP) 226 if (able & IC_BOOTP)
226 get_random_bytes(&d->xid, sizeof(u32)); 227 get_random_bytes(&d->xid, sizeof(__be32));
227 else 228 else
228 d->xid = 0; 229 d->xid = 0;
229 ic_proto_have_if |= able; 230 ic_proto_have_if |= able;
@@ -269,7 +270,7 @@ static void __init ic_close_devs(void)
269 */ 270 */
270 271
271static inline void 272static inline void
272set_sockaddr(struct sockaddr_in *sin, u32 addr, u16 port) 273set_sockaddr(struct sockaddr_in *sin, __be32 addr, __be16 port)
273{ 274{
274 sin->sin_family = AF_INET; 275 sin->sin_family = AF_INET;
275 sin->sin_addr.s_addr = addr; 276 sin->sin_addr.s_addr = addr;
@@ -332,7 +333,7 @@ static int __init ic_setup_routes(void)
332{ 333{
333 /* No need to setup device routes, only the default route... */ 334 /* No need to setup device routes, only the default route... */
334 335
335 if (ic_gateway != INADDR_NONE) { 336 if (ic_gateway != NONE) {
336 struct rtentry rm; 337 struct rtentry rm;
337 int err; 338 int err;
338 339
@@ -368,10 +369,10 @@ static int __init ic_defaults(void)
368 if (!ic_host_name_set) 369 if (!ic_host_name_set)
369 sprintf(init_utsname()->nodename, "%u.%u.%u.%u", NIPQUAD(ic_myaddr)); 370 sprintf(init_utsname()->nodename, "%u.%u.%u.%u", NIPQUAD(ic_myaddr));
370 371
371 if (root_server_addr == INADDR_NONE) 372 if (root_server_addr == NONE)
372 root_server_addr = ic_servaddr; 373 root_server_addr = ic_servaddr;
373 374
374 if (ic_netmask == INADDR_NONE) { 375 if (ic_netmask == NONE) {
375 if (IN_CLASSA(ntohl(ic_myaddr))) 376 if (IN_CLASSA(ntohl(ic_myaddr)))
376 ic_netmask = htonl(IN_CLASSA_NET); 377 ic_netmask = htonl(IN_CLASSA_NET);
377 else if (IN_CLASSB(ntohl(ic_myaddr))) 378 else if (IN_CLASSB(ntohl(ic_myaddr)))
@@ -420,7 +421,7 @@ ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
420{ 421{
421 struct arphdr *rarp; 422 struct arphdr *rarp;
422 unsigned char *rarp_ptr; 423 unsigned char *rarp_ptr;
423 u32 sip, tip; 424 __be32 sip, tip;
424 unsigned char *sha, *tha; /* s for "source", t for "target" */ 425 unsigned char *sha, *tha; /* s for "source", t for "target" */
425 struct ic_device *d; 426 struct ic_device *d;
426 427
@@ -485,12 +486,12 @@ ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
485 goto drop_unlock; 486 goto drop_unlock;
486 487
487 /* Discard packets which are not from specified server. */ 488 /* Discard packets which are not from specified server. */
488 if (ic_servaddr != INADDR_NONE && ic_servaddr != sip) 489 if (ic_servaddr != NONE && ic_servaddr != sip)
489 goto drop_unlock; 490 goto drop_unlock;
490 491
491 /* We have a winner! */ 492 /* We have a winner! */
492 ic_dev = dev; 493 ic_dev = dev;
493 if (ic_myaddr == INADDR_NONE) 494 if (ic_myaddr == NONE)
494 ic_myaddr = tip; 495 ic_myaddr = tip;
495 ic_servaddr = sip; 496 ic_servaddr = sip;
496 ic_got_reply = IC_RARP; 497 ic_got_reply = IC_RARP;
@@ -530,13 +531,13 @@ struct bootp_pkt { /* BOOTP packet format */
530 u8 htype; /* HW address type */ 531 u8 htype; /* HW address type */
531 u8 hlen; /* HW address length */ 532 u8 hlen; /* HW address length */
532 u8 hops; /* Used only by gateways */ 533 u8 hops; /* Used only by gateways */
533 u32 xid; /* Transaction ID */ 534 __be32 xid; /* Transaction ID */
534 u16 secs; /* Seconds since we started */ 535 __be16 secs; /* Seconds since we started */
535 u16 flags; /* Just what it says */ 536 __be16 flags; /* Just what it says */
536 u32 client_ip; /* Client's IP address if known */ 537 __be32 client_ip; /* Client's IP address if known */
537 u32 your_ip; /* Assigned IP address */ 538 __be32 your_ip; /* Assigned IP address */
538 u32 server_ip; /* (Next, e.g. NFS) Server's IP address */ 539 __be32 server_ip; /* (Next, e.g. NFS) Server's IP address */
539 u32 relay_ip; /* IP address of BOOTP relay */ 540 __be32 relay_ip; /* IP address of BOOTP relay */
540 u8 hw_addr[16]; /* Client's HW address */ 541 u8 hw_addr[16]; /* Client's HW address */
541 u8 serv_name[64]; /* Server host name */ 542 u8 serv_name[64]; /* Server host name */
542 u8 boot_file[128]; /* Name of boot file */ 543 u8 boot_file[128]; /* Name of boot file */
@@ -576,7 +577,7 @@ static const u8 ic_bootp_cookie[4] = { 99, 130, 83, 99 };
576static void __init 577static void __init
577ic_dhcp_init_options(u8 *options) 578ic_dhcp_init_options(u8 *options)
578{ 579{
579 u8 mt = ((ic_servaddr == INADDR_NONE) 580 u8 mt = ((ic_servaddr == NONE)
580 ? DHCPDISCOVER : DHCPREQUEST); 581 ? DHCPDISCOVER : DHCPREQUEST);
581 u8 *e = options; 582 u8 *e = options;
582 583
@@ -666,7 +667,7 @@ static inline void ic_bootp_init(void)
666 int i; 667 int i;
667 668
668 for (i = 0; i < CONF_NAMESERVERS_MAX; i++) 669 for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
669 ic_nameservers[i] = INADDR_NONE; 670 ic_nameservers[i] = NONE;
670 671
671 dev_add_pack(&bootp_packet_type); 672 dev_add_pack(&bootp_packet_type);
672} 673}
@@ -708,7 +709,7 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
708 h->frag_off = htons(IP_DF); 709 h->frag_off = htons(IP_DF);
709 h->ttl = 64; 710 h->ttl = 64;
710 h->protocol = IPPROTO_UDP; 711 h->protocol = IPPROTO_UDP;
711 h->daddr = INADDR_BROADCAST; 712 h->daddr = htonl(INADDR_BROADCAST);
712 h->check = ip_fast_csum((unsigned char *) h, h->ihl); 713 h->check = ip_fast_csum((unsigned char *) h, h->ihl);
713 714
714 /* Construct UDP header */ 715 /* Construct UDP header */
@@ -730,8 +731,8 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
730 b->htype = dev->type; /* can cause undefined behavior */ 731 b->htype = dev->type; /* can cause undefined behavior */
731 } 732 }
732 b->hlen = dev->addr_len; 733 b->hlen = dev->addr_len;
733 b->your_ip = INADDR_NONE; 734 b->your_ip = NONE;
734 b->server_ip = INADDR_NONE; 735 b->server_ip = NONE;
735 memcpy(b->hw_addr, dev->dev_addr, dev->addr_len); 736 memcpy(b->hw_addr, dev->dev_addr, dev->addr_len);
736 b->secs = htons(jiffies_diff / HZ); 737 b->secs = htons(jiffies_diff / HZ);
737 b->xid = d->xid; 738 b->xid = d->xid;
@@ -788,11 +789,11 @@ static void __init ic_do_bootp_ext(u8 *ext)
788 789
789 switch (*ext++) { 790 switch (*ext++) {
790 case 1: /* Subnet mask */ 791 case 1: /* Subnet mask */
791 if (ic_netmask == INADDR_NONE) 792 if (ic_netmask == NONE)
792 memcpy(&ic_netmask, ext+1, 4); 793 memcpy(&ic_netmask, ext+1, 4);
793 break; 794 break;
794 case 3: /* Default gateway */ 795 case 3: /* Default gateway */
795 if (ic_gateway == INADDR_NONE) 796 if (ic_gateway == NONE)
796 memcpy(&ic_gateway, ext+1, 4); 797 memcpy(&ic_gateway, ext+1, 4);
797 break; 798 break;
798 case 6: /* DNS server */ 799 case 6: /* DNS server */
@@ -800,7 +801,7 @@ static void __init ic_do_bootp_ext(u8 *ext)
800 if (servers > CONF_NAMESERVERS_MAX) 801 if (servers > CONF_NAMESERVERS_MAX)
801 servers = CONF_NAMESERVERS_MAX; 802 servers = CONF_NAMESERVERS_MAX;
802 for (i = 0; i < servers; i++) { 803 for (i = 0; i < servers; i++) {
803 if (ic_nameservers[i] == INADDR_NONE) 804 if (ic_nameservers[i] == NONE)
804 memcpy(&ic_nameservers[i], ext+1+4*i, 4); 805 memcpy(&ic_nameservers[i], ext+1+4*i, 4);
805 } 806 }
806 break; 807 break;
@@ -917,7 +918,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
917 918
918#ifdef IPCONFIG_DHCP 919#ifdef IPCONFIG_DHCP
919 if (ic_proto_enabled & IC_USE_DHCP) { 920 if (ic_proto_enabled & IC_USE_DHCP) {
920 u32 server_id = INADDR_NONE; 921 __be32 server_id = NONE;
921 int mt = 0; 922 int mt = 0;
922 923
923 ext = &b->exten[4]; 924 ext = &b->exten[4];
@@ -949,7 +950,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
949 /* While in the process of accepting one offer, 950 /* While in the process of accepting one offer,
950 * ignore all others. 951 * ignore all others.
951 */ 952 */
952 if (ic_myaddr != INADDR_NONE) 953 if (ic_myaddr != NONE)
953 goto drop_unlock; 954 goto drop_unlock;
954 955
955 /* Let's accept that offer. */ 956 /* Let's accept that offer. */
@@ -965,7 +966,7 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
965 * precedence over the bootp header one if 966 * precedence over the bootp header one if
966 * they are different. 967 * they are different.
967 */ 968 */
968 if ((server_id != INADDR_NONE) && 969 if ((server_id != NONE) &&
969 (b->server_ip != server_id)) 970 (b->server_ip != server_id))
970 b->server_ip = ic_servaddr; 971 b->server_ip = ic_servaddr;
971 break; 972 break;
@@ -979,8 +980,8 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
979 980
980 default: 981 default:
981 /* Urque. Forget it*/ 982 /* Urque. Forget it*/
982 ic_myaddr = INADDR_NONE; 983 ic_myaddr = NONE;
983 ic_servaddr = INADDR_NONE; 984 ic_servaddr = NONE;
984 goto drop_unlock; 985 goto drop_unlock;
985 }; 986 };
986 987
@@ -1004,9 +1005,9 @@ static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, str
1004 ic_dev = dev; 1005 ic_dev = dev;
1005 ic_myaddr = b->your_ip; 1006 ic_myaddr = b->your_ip;
1006 ic_servaddr = b->server_ip; 1007 ic_servaddr = b->server_ip;
1007 if (ic_gateway == INADDR_NONE && b->relay_ip) 1008 if (ic_gateway == NONE && b->relay_ip)
1008 ic_gateway = b->relay_ip; 1009 ic_gateway = b->relay_ip;
1009 if (ic_nameservers[0] == INADDR_NONE) 1010 if (ic_nameservers[0] == NONE)
1010 ic_nameservers[0] = ic_servaddr; 1011 ic_nameservers[0] = ic_servaddr;
1011 ic_got_reply = IC_BOOTP; 1012 ic_got_reply = IC_BOOTP;
1012 1013
@@ -1150,7 +1151,7 @@ static int __init ic_dynamic(void)
1150#endif 1151#endif
1151 1152
1152 if (!ic_got_reply) { 1153 if (!ic_got_reply) {
1153 ic_myaddr = INADDR_NONE; 1154 ic_myaddr = NONE;
1154 return -1; 1155 return -1;
1155 } 1156 }
1156 1157
@@ -1182,12 +1183,12 @@ static int pnp_seq_show(struct seq_file *seq, void *v)
1182 seq_printf(seq, 1183 seq_printf(seq,
1183 "domain %s\n", ic_domain); 1184 "domain %s\n", ic_domain);
1184 for (i = 0; i < CONF_NAMESERVERS_MAX; i++) { 1185 for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
1185 if (ic_nameservers[i] != INADDR_NONE) 1186 if (ic_nameservers[i] != NONE)
1186 seq_printf(seq, 1187 seq_printf(seq,
1187 "nameserver %u.%u.%u.%u\n", 1188 "nameserver %u.%u.%u.%u\n",
1188 NIPQUAD(ic_nameservers[i])); 1189 NIPQUAD(ic_nameservers[i]));
1189 } 1190 }
1190 if (ic_servaddr != INADDR_NONE) 1191 if (ic_servaddr != NONE)
1191 seq_printf(seq, 1192 seq_printf(seq,
1192 "bootserver %u.%u.%u.%u\n", 1193 "bootserver %u.%u.%u.%u\n",
1193 NIPQUAD(ic_servaddr)); 1194 NIPQUAD(ic_servaddr));
@@ -1213,9 +1214,9 @@ static struct file_operations pnp_seq_fops = {
1213 * need to have root_server_addr set _before_ IPConfig gets called as it 1214 * need to have root_server_addr set _before_ IPConfig gets called as it
1214 * can override it. 1215 * can override it.
1215 */ 1216 */
1216u32 __init root_nfs_parse_addr(char *name) 1217__be32 __init root_nfs_parse_addr(char *name)
1217{ 1218{
1218 u32 addr; 1219 __be32 addr;
1219 int octets = 0; 1220 int octets = 0;
1220 char *cp, *cq; 1221 char *cp, *cq;
1221 1222
@@ -1237,7 +1238,7 @@ u32 __init root_nfs_parse_addr(char *name)
1237 addr = in_aton(name); 1238 addr = in_aton(name);
1238 memmove(name, cp, strlen(cp) + 1); 1239 memmove(name, cp, strlen(cp) + 1);
1239 } else 1240 } else
1240 addr = INADDR_NONE; 1241 addr = NONE;
1241 1242
1242 return addr; 1243 return addr;
1243} 1244}
@@ -1248,7 +1249,7 @@ u32 __init root_nfs_parse_addr(char *name)
1248 1249
1249static int __init ip_auto_config(void) 1250static int __init ip_auto_config(void)
1250{ 1251{
1251 u32 addr; 1252 __be32 addr;
1252 1253
1253#ifdef CONFIG_PROC_FS 1254#ifdef CONFIG_PROC_FS
1254 proc_net_fops_create("pnp", S_IRUGO, &pnp_seq_fops); 1255 proc_net_fops_create("pnp", S_IRUGO, &pnp_seq_fops);
@@ -1277,11 +1278,11 @@ static int __init ip_auto_config(void)
1277 * interfaces and no default was set), use BOOTP or RARP to get the 1278 * interfaces and no default was set), use BOOTP or RARP to get the
1278 * missing values. 1279 * missing values.
1279 */ 1280 */
1280 if (ic_myaddr == INADDR_NONE || 1281 if (ic_myaddr == NONE ||
1281#ifdef CONFIG_ROOT_NFS 1282#ifdef CONFIG_ROOT_NFS
1282 (MAJOR(ROOT_DEV) == UNNAMED_MAJOR 1283 (MAJOR(ROOT_DEV) == UNNAMED_MAJOR
1283 && root_server_addr == INADDR_NONE 1284 && root_server_addr == NONE
1284 && ic_servaddr == INADDR_NONE) || 1285 && ic_servaddr == NONE) ||
1285#endif 1286#endif
1286 ic_first_dev->next) { 1287 ic_first_dev->next) {
1287#ifdef IPCONFIG_DYNAMIC 1288#ifdef IPCONFIG_DYNAMIC
@@ -1334,7 +1335,7 @@ static int __init ip_auto_config(void)
1334 } 1335 }
1335 1336
1336 addr = root_nfs_parse_addr(root_server_path); 1337 addr = root_nfs_parse_addr(root_server_path);
1337 if (root_server_addr == INADDR_NONE) 1338 if (root_server_addr == NONE)
1338 root_server_addr = addr; 1339 root_server_addr = addr;
1339 1340
1340 /* 1341 /*
@@ -1461,19 +1462,19 @@ static int __init ip_auto_config_setup(char *addrs)
1461 switch (num) { 1462 switch (num) {
1462 case 0: 1463 case 0:
1463 if ((ic_myaddr = in_aton(ip)) == INADDR_ANY) 1464 if ((ic_myaddr = in_aton(ip)) == INADDR_ANY)
1464 ic_myaddr = INADDR_NONE; 1465 ic_myaddr = NONE;
1465 break; 1466 break;
1466 case 1: 1467 case 1:
1467 if ((ic_servaddr = in_aton(ip)) == INADDR_ANY) 1468 if ((ic_servaddr = in_aton(ip)) == INADDR_ANY)
1468 ic_servaddr = INADDR_NONE; 1469 ic_servaddr = NONE;
1469 break; 1470 break;
1470 case 2: 1471 case 2:
1471 if ((ic_gateway = in_aton(ip)) == INADDR_ANY) 1472 if ((ic_gateway = in_aton(ip)) == INADDR_ANY)
1472 ic_gateway = INADDR_NONE; 1473 ic_gateway = NONE;
1473 break; 1474 break;
1474 case 3: 1475 case 3:
1475 if ((ic_netmask = in_aton(ip)) == INADDR_ANY) 1476 if ((ic_netmask = in_aton(ip)) == INADDR_ANY)
1476 ic_netmask = INADDR_NONE; 1477 ic_netmask = NONE;
1477 break; 1478 break;
1478 case 4: 1479 case 4:
1479 if ((dp = strchr(ip, '.'))) { 1480 if ((dp = strchr(ip, '.'))) {
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 0c4556529228..9d719d664e5b 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -118,7 +118,7 @@
118#include <net/xfrm.h> 118#include <net/xfrm.h>
119 119
120#define HASH_SIZE 16 120#define HASH_SIZE 16
121#define HASH(addr) ((addr^(addr>>4))&0xF) 121#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)
122 122
123static int ipip_fb_tunnel_init(struct net_device *dev); 123static int ipip_fb_tunnel_init(struct net_device *dev);
124static int ipip_tunnel_init(struct net_device *dev); 124static int ipip_tunnel_init(struct net_device *dev);
@@ -134,7 +134,7 @@ static struct ip_tunnel **tunnels[4] = { tunnels_wc, tunnels_l, tunnels_r, tunne
134 134
135static DEFINE_RWLOCK(ipip_lock); 135static DEFINE_RWLOCK(ipip_lock);
136 136
137static struct ip_tunnel * ipip_tunnel_lookup(u32 remote, u32 local) 137static struct ip_tunnel * ipip_tunnel_lookup(__be32 remote, __be32 local)
138{ 138{
139 unsigned h0 = HASH(remote); 139 unsigned h0 = HASH(remote);
140 unsigned h1 = HASH(local); 140 unsigned h1 = HASH(local);
@@ -160,8 +160,8 @@ static struct ip_tunnel * ipip_tunnel_lookup(u32 remote, u32 local)
160 160
161static struct ip_tunnel **ipip_bucket(struct ip_tunnel *t) 161static struct ip_tunnel **ipip_bucket(struct ip_tunnel *t)
162{ 162{
163 u32 remote = t->parms.iph.daddr; 163 __be32 remote = t->parms.iph.daddr;
164 u32 local = t->parms.iph.saddr; 164 __be32 local = t->parms.iph.saddr;
165 unsigned h = 0; 165 unsigned h = 0;
166 int prio = 0; 166 int prio = 0;
167 167
@@ -203,8 +203,8 @@ static void ipip_tunnel_link(struct ip_tunnel *t)
203 203
204static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int create) 204static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int create)
205{ 205{
206 u32 remote = parms->iph.daddr; 206 __be32 remote = parms->iph.daddr;
207 u32 local = parms->iph.saddr; 207 __be32 local = parms->iph.saddr;
208 struct ip_tunnel *t, **tp, *nt; 208 struct ip_tunnel *t, **tp, *nt;
209 struct net_device *dev; 209 struct net_device *dev;
210 unsigned h = 0; 210 unsigned h = 0;
@@ -519,13 +519,13 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
519 struct net_device_stats *stats = &tunnel->stat; 519 struct net_device_stats *stats = &tunnel->stat;
520 struct iphdr *tiph = &tunnel->parms.iph; 520 struct iphdr *tiph = &tunnel->parms.iph;
521 u8 tos = tunnel->parms.iph.tos; 521 u8 tos = tunnel->parms.iph.tos;
522 u16 df = tiph->frag_off; 522 __be16 df = tiph->frag_off;
523 struct rtable *rt; /* Route to the other host */ 523 struct rtable *rt; /* Route to the other host */
524 struct net_device *tdev; /* Device to other host */ 524 struct net_device *tdev; /* Device to other host */
525 struct iphdr *old_iph = skb->nh.iph; 525 struct iphdr *old_iph = skb->nh.iph;
526 struct iphdr *iph; /* Our new IP header */ 526 struct iphdr *iph; /* Our new IP header */
527 int max_headroom; /* The extra header space needed */ 527 int max_headroom; /* The extra header space needed */
528 u32 dst = tiph->daddr; 528 __be32 dst = tiph->daddr;
529 int mtu; 529 int mtu;
530 530
531 if (tunnel->recursion++) { 531 if (tunnel->recursion++) {
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 97cfa97c8abb..efcf45ecc818 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1493,7 +1493,7 @@ static int pim_rcv(struct sk_buff * skb)
1493 if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) || 1493 if (pim->type != ((PIM_VERSION<<4)|(PIM_REGISTER)) ||
1494 (pim->flags&PIM_NULL_REGISTER) || 1494 (pim->flags&PIM_NULL_REGISTER) ||
1495 (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 && 1495 (ip_compute_csum((void *)pim, sizeof(*pim)) != 0 &&
1496 (u16)csum_fold(skb_checksum(skb, 0, skb->len, 0)))) 1496 csum_fold(skb_checksum(skb, 0, skb->len, 0))))
1497 goto drop; 1497 goto drop;
1498 1498
1499 /* check if the inner packet is destined to mcast group */ 1499 /* check if the inner packet is destined to mcast group */
diff --git a/net/ipv4/ipvs/ip_vs_app.c b/net/ipv4/ipvs/ip_vs_app.c
index e7752334d296..6c40899aa161 100644
--- a/net/ipv4/ipvs/ip_vs_app.c
+++ b/net/ipv4/ipvs/ip_vs_app.c
@@ -80,10 +80,9 @@ ip_vs_app_inc_new(struct ip_vs_app *app, __u16 proto, __u16 port)
80 if (!pp->unregister_app) 80 if (!pp->unregister_app)
81 return -EOPNOTSUPP; 81 return -EOPNOTSUPP;
82 82
83 inc = kmalloc(sizeof(struct ip_vs_app), GFP_KERNEL); 83 inc = kmemdup(app, sizeof(*inc), GFP_KERNEL);
84 if (!inc) 84 if (!inc)
85 return -ENOMEM; 85 return -ENOMEM;
86 memcpy(inc, app, sizeof(*inc));
87 INIT_LIST_HEAD(&inc->p_list); 86 INIT_LIST_HEAD(&inc->p_list);
88 INIT_LIST_HEAD(&inc->incs_list); 87 INIT_LIST_HEAD(&inc->incs_list);
89 inc->app = app; 88 inc->app = app;
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c
index 1445bb47fea4..34257520a3a6 100644
--- a/net/ipv4/ipvs/ip_vs_core.c
+++ b/net/ipv4/ipvs/ip_vs_core.c
@@ -536,9 +536,9 @@ static unsigned int ip_vs_post_routing(unsigned int hooknum,
536 return NF_STOP; 536 return NF_STOP;
537} 537}
538 538
539u16 ip_vs_checksum_complete(struct sk_buff *skb, int offset) 539__sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset)
540{ 540{
541 return (u16) csum_fold(skb_checksum(skb, offset, skb->len - offset, 0)); 541 return csum_fold(skb_checksum(skb, offset, skb->len - offset, 0));
542} 542}
543 543
544static inline struct sk_buff * 544static inline struct sk_buff *
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c
index c4528b5c800d..e844ddb82b9a 100644
--- a/net/ipv4/ipvs/ip_vs_proto.c
+++ b/net/ipv4/ipvs/ip_vs_proto.c
@@ -118,13 +118,7 @@ void ip_vs_protocol_timeout_change(int flags)
118int * 118int *
119ip_vs_create_timeout_table(int *table, int size) 119ip_vs_create_timeout_table(int *table, int size)
120{ 120{
121 int *t; 121 return kmemdup(table, size, GFP_ATOMIC);
122
123 t = kmalloc(size, GFP_ATOMIC);
124 if (t == NULL)
125 return NULL;
126 memcpy(t, table, size);
127 return t;
128} 122}
129 123
130 124
diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c
index 6ff05c3a32e6..16a9ebee2fe6 100644
--- a/net/ipv4/ipvs/ip_vs_proto_tcp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c
@@ -84,7 +84,7 @@ tcp_conn_schedule(struct sk_buff *skb,
84 } 84 }
85 85
86 if (th->syn && 86 if (th->syn &&
87 (svc = ip_vs_service_get(skb->nfmark, skb->nh.iph->protocol, 87 (svc = ip_vs_service_get(skb->mark, skb->nh.iph->protocol,
88 skb->nh.iph->daddr, th->dest))) { 88 skb->nh.iph->daddr, th->dest))) {
89 if (ip_vs_todrop()) { 89 if (ip_vs_todrop()) {
90 /* 90 /*
@@ -116,9 +116,9 @@ tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip,
116 __be16 oldport, __be16 newport) 116 __be16 oldport, __be16 newport)
117{ 117{
118 tcph->check = 118 tcph->check =
119 ip_vs_check_diff(~oldip, newip, 119 csum_fold(ip_vs_check_diff4(oldip, newip,
120 ip_vs_check_diff(oldport ^ htons(0xFFFF), 120 ip_vs_check_diff2(oldport, newport,
121 newport, tcph->check)); 121 ~csum_unfold(tcph->check))));
122} 122}
123 123
124 124
@@ -490,16 +490,18 @@ tcp_state_transition(struct ip_vs_conn *cp, int direction,
490static struct list_head tcp_apps[TCP_APP_TAB_SIZE]; 490static struct list_head tcp_apps[TCP_APP_TAB_SIZE];
491static DEFINE_SPINLOCK(tcp_app_lock); 491static DEFINE_SPINLOCK(tcp_app_lock);
492 492
493static inline __u16 tcp_app_hashkey(__u16 port) 493static inline __u16 tcp_app_hashkey(__be16 port)
494{ 494{
495 return ((port >> TCP_APP_TAB_BITS) ^ port) & TCP_APP_TAB_MASK; 495 return (((__force u16)port >> TCP_APP_TAB_BITS) ^ (__force u16)port)
496 & TCP_APP_TAB_MASK;
496} 497}
497 498
498 499
499static int tcp_register_app(struct ip_vs_app *inc) 500static int tcp_register_app(struct ip_vs_app *inc)
500{ 501{
501 struct ip_vs_app *i; 502 struct ip_vs_app *i;
502 __u16 hash, port = inc->port; 503 __u16 hash;
504 __be16 port = inc->port;
503 int ret = 0; 505 int ret = 0;
504 506
505 hash = tcp_app_hashkey(port); 507 hash = tcp_app_hashkey(port);
diff --git a/net/ipv4/ipvs/ip_vs_proto_udp.c b/net/ipv4/ipvs/ip_vs_proto_udp.c
index 691c8b637b29..03f0a414cfa4 100644
--- a/net/ipv4/ipvs/ip_vs_proto_udp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_udp.c
@@ -89,7 +89,7 @@ udp_conn_schedule(struct sk_buff *skb, struct ip_vs_protocol *pp,
89 return 0; 89 return 0;
90 } 90 }
91 91
92 if ((svc = ip_vs_service_get(skb->nfmark, skb->nh.iph->protocol, 92 if ((svc = ip_vs_service_get(skb->mark, skb->nh.iph->protocol,
93 skb->nh.iph->daddr, uh->dest))) { 93 skb->nh.iph->daddr, uh->dest))) {
94 if (ip_vs_todrop()) { 94 if (ip_vs_todrop()) {
95 /* 95 /*
@@ -121,11 +121,11 @@ udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
121 __be16 oldport, __be16 newport) 121 __be16 oldport, __be16 newport)
122{ 122{
123 uhdr->check = 123 uhdr->check =
124 ip_vs_check_diff(~oldip, newip, 124 csum_fold(ip_vs_check_diff4(oldip, newip,
125 ip_vs_check_diff(oldport ^ htons(0xFFFF), 125 ip_vs_check_diff2(oldport, newport,
126 newport, uhdr->check)); 126 ~csum_unfold(uhdr->check))));
127 if (!uhdr->check) 127 if (!uhdr->check)
128 uhdr->check = -1; 128 uhdr->check = CSUM_MANGLED_0;
129} 129}
130 130
131static int 131static int
@@ -173,7 +173,7 @@ udp_snat_handler(struct sk_buff **pskb,
173 cp->protocol, 173 cp->protocol,
174 (*pskb)->csum); 174 (*pskb)->csum);
175 if (udph->check == 0) 175 if (udph->check == 0)
176 udph->check = -1; 176 udph->check = CSUM_MANGLED_0;
177 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n", 177 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n",
178 pp->name, udph->check, 178 pp->name, udph->check,
179 (char*)&(udph->check) - (char*)udph); 179 (char*)&(udph->check) - (char*)udph);
@@ -228,7 +228,7 @@ udp_dnat_handler(struct sk_buff **pskb,
228 cp->protocol, 228 cp->protocol,
229 (*pskb)->csum); 229 (*pskb)->csum);
230 if (udph->check == 0) 230 if (udph->check == 0)
231 udph->check = -1; 231 udph->check = CSUM_MANGLED_0;
232 (*pskb)->ip_summed = CHECKSUM_UNNECESSARY; 232 (*pskb)->ip_summed = CHECKSUM_UNNECESSARY;
233 } 233 }
234 return 1; 234 return 1;
@@ -282,16 +282,18 @@ udp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
282static struct list_head udp_apps[UDP_APP_TAB_SIZE]; 282static struct list_head udp_apps[UDP_APP_TAB_SIZE];
283static DEFINE_SPINLOCK(udp_app_lock); 283static DEFINE_SPINLOCK(udp_app_lock);
284 284
285static inline __u16 udp_app_hashkey(__u16 port) 285static inline __u16 udp_app_hashkey(__be16 port)
286{ 286{
287 return ((port >> UDP_APP_TAB_BITS) ^ port) & UDP_APP_TAB_MASK; 287 return (((__force u16)port >> UDP_APP_TAB_BITS) ^ (__force u16)port)
288 & UDP_APP_TAB_MASK;
288} 289}
289 290
290 291
291static int udp_register_app(struct ip_vs_app *inc) 292static int udp_register_app(struct ip_vs_app *inc)
292{ 293{
293 struct ip_vs_app *i; 294 struct ip_vs_app *i;
294 __u16 hash, port = inc->port; 295 __u16 hash;
296 __be16 port = inc->port;
295 int ret = 0; 297 int ret = 0;
296 298
297 hash = udp_app_hashkey(port); 299 hash = udp_app_hashkey(port);
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
index e2005c6810a4..a68966059b50 100644
--- a/net/ipv4/netfilter.c
+++ b/net/ipv4/netfilter.c
@@ -27,9 +27,7 @@ int ip_route_me_harder(struct sk_buff **pskb, unsigned addr_type)
27 fl.nl_u.ip4_u.saddr = iph->saddr; 27 fl.nl_u.ip4_u.saddr = iph->saddr;
28 fl.nl_u.ip4_u.tos = RT_TOS(iph->tos); 28 fl.nl_u.ip4_u.tos = RT_TOS(iph->tos);
29 fl.oif = (*pskb)->sk ? (*pskb)->sk->sk_bound_dev_if : 0; 29 fl.oif = (*pskb)->sk ? (*pskb)->sk->sk_bound_dev_if : 0;
30#ifdef CONFIG_IP_ROUTE_FWMARK 30 fl.mark = (*pskb)->mark;
31 fl.nl_u.ip4_u.fwmark = (*pskb)->nfmark;
32#endif
33 if (ip_route_output_key(&rt, &fl) != 0) 31 if (ip_route_output_key(&rt, &fl) != 0)
34 return -1; 32 return -1;
35 33
@@ -164,17 +162,17 @@ static int nf_ip_reroute(struct sk_buff **pskb, const struct nf_info *info)
164 return 0; 162 return 0;
165} 163}
166 164
167unsigned int nf_ip_checksum(struct sk_buff *skb, unsigned int hook, 165__sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
168 unsigned int dataoff, u_int8_t protocol) 166 unsigned int dataoff, u_int8_t protocol)
169{ 167{
170 struct iphdr *iph = skb->nh.iph; 168 struct iphdr *iph = skb->nh.iph;
171 unsigned int csum = 0; 169 __sum16 csum = 0;
172 170
173 switch (skb->ip_summed) { 171 switch (skb->ip_summed) {
174 case CHECKSUM_COMPLETE: 172 case CHECKSUM_COMPLETE:
175 if (hook != NF_IP_PRE_ROUTING && hook != NF_IP_LOCAL_IN) 173 if (hook != NF_IP_PRE_ROUTING && hook != NF_IP_LOCAL_IN)
176 break; 174 break;
177 if ((protocol == 0 && !(u16)csum_fold(skb->csum)) || 175 if ((protocol == 0 && !csum_fold(skb->csum)) ||
178 !csum_tcpudp_magic(iph->saddr, iph->daddr, 176 !csum_tcpudp_magic(iph->saddr, iph->daddr,
179 skb->len - dataoff, protocol, 177 skb->len - dataoff, protocol,
180 skb->csum)) { 178 skb->csum)) {
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index d88c292f118c..363df9976c9d 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -6,7 +6,7 @@ menu "IP: Netfilter Configuration"
6 depends on INET && NETFILTER 6 depends on INET && NETFILTER
7 7
8config NF_CONNTRACK_IPV4 8config NF_CONNTRACK_IPV4
9 tristate "IPv4 support for new connection tracking (EXPERIMENTAL)" 9 tristate "IPv4 connection tracking support (required for NAT) (EXPERIMENTAL)"
10 depends on EXPERIMENTAL && NF_CONNTRACK 10 depends on EXPERIMENTAL && NF_CONNTRACK
11 ---help--- 11 ---help---
12 Connection tracking keeps a record of what packets have passed 12 Connection tracking keeps a record of what packets have passed
@@ -19,21 +19,18 @@ config NF_CONNTRACK_IPV4
19 19
20 To compile it as a module, choose M here. If unsure, say N. 20 To compile it as a module, choose M here. If unsure, say N.
21 21
22# connection tracking, helpers and protocols 22config NF_CONNTRACK_PROC_COMPAT
23config IP_NF_CONNTRACK 23 bool "proc/sysctl compatibility with old connection tracking"
24 tristate "Connection tracking (required for masq/NAT)" 24 depends on NF_CONNTRACK_IPV4
25 ---help--- 25 default y
26 Connection tracking keeps a record of what packets have passed 26 help
27 through your machine, in order to figure out how they are related 27 This option enables /proc and sysctl compatibility with the old
28 into connections. 28 layer 3 dependant connection tracking. This is needed to keep
29 29 old programs that have not been adapted to the new names working.
30 This is required to do Masquerading or other kinds of Network
31 Address Translation (except for Fast NAT). It can also be used to
32 enhance packet filtering (see `Connection state match support'
33 below).
34 30
35 To compile it as a module, choose M here. If unsure, say N. 31 If unsure, say Y.
36 32
33# connection tracking, helpers and protocols
37config IP_NF_CT_ACCT 34config IP_NF_CT_ACCT
38 bool "Connection tracking flow accounting" 35 bool "Connection tracking flow accounting"
39 depends on IP_NF_CONNTRACK 36 depends on IP_NF_CONNTRACK
@@ -315,20 +312,6 @@ config IP_NF_MATCH_ADDRTYPE
315 If you want to compile it as a module, say M here and read 312 If you want to compile it as a module, say M here and read
316 <file:Documentation/modules.txt>. If unsure, say `N'. 313 <file:Documentation/modules.txt>. If unsure, say `N'.
317 314
318config IP_NF_MATCH_HASHLIMIT
319 tristate 'hashlimit match support'
320 depends on IP_NF_IPTABLES
321 help
322 This option adds a new iptables `hashlimit' match.
323
324 As opposed to `limit', this match dynamically creates a hash table
325 of limit buckets, based on your selection of source/destination
326 ip addresses and/or ports.
327
328 It enables you to express policies like `10kpps for any given
329 destination IP' or `500pps from any given source IP' with a single
330 IPtables rule.
331
332# `filter', generic and specific targets 315# `filter', generic and specific targets
333config IP_NF_FILTER 316config IP_NF_FILTER
334 tristate "Packet filtering" 317 tristate "Packet filtering"
@@ -404,7 +387,7 @@ config IP_NF_TARGET_TCPMSS
404 387
405 To compile it as a module, choose M here. If unsure, say N. 388 To compile it as a module, choose M here. If unsure, say N.
406 389
407# NAT + specific targets 390# NAT + specific targets: ip_conntrack
408config IP_NF_NAT 391config IP_NF_NAT
409 tristate "Full NAT" 392 tristate "Full NAT"
410 depends on IP_NF_IPTABLES && IP_NF_CONNTRACK 393 depends on IP_NF_IPTABLES && IP_NF_CONNTRACK
@@ -415,14 +398,30 @@ config IP_NF_NAT
415 398
416 To compile it as a module, choose M here. If unsure, say N. 399 To compile it as a module, choose M here. If unsure, say N.
417 400
401# NAT + specific targets: nf_conntrack
402config NF_NAT
403 tristate "Full NAT"
404 depends on IP_NF_IPTABLES && NF_CONNTRACK
405 help
406 The Full NAT option allows masquerading, port forwarding and other
407 forms of full Network Address Port Translation. It is controlled by
408 the `nat' table in iptables: see the man page for iptables(8).
409
410 To compile it as a module, choose M here. If unsure, say N.
411
418config IP_NF_NAT_NEEDED 412config IP_NF_NAT_NEEDED
419 bool 413 bool
420 depends on IP_NF_NAT != n 414 depends on IP_NF_NAT
415 default y
416
417config NF_NAT_NEEDED
418 bool
419 depends on NF_NAT
421 default y 420 default y
422 421
423config IP_NF_TARGET_MASQUERADE 422config IP_NF_TARGET_MASQUERADE
424 tristate "MASQUERADE target support" 423 tristate "MASQUERADE target support"
425 depends on IP_NF_NAT 424 depends on (NF_NAT || IP_NF_NAT)
426 help 425 help
427 Masquerading is a special case of NAT: all outgoing connections are 426 Masquerading is a special case of NAT: all outgoing connections are
428 changed to seem to come from a particular interface's address, and 427 changed to seem to come from a particular interface's address, and
@@ -434,7 +433,7 @@ config IP_NF_TARGET_MASQUERADE
434 433
435config IP_NF_TARGET_REDIRECT 434config IP_NF_TARGET_REDIRECT
436 tristate "REDIRECT target support" 435 tristate "REDIRECT target support"
437 depends on IP_NF_NAT 436 depends on (NF_NAT || IP_NF_NAT)
438 help 437 help
439 REDIRECT is a special case of NAT: all incoming connections are 438 REDIRECT is a special case of NAT: all incoming connections are
440 mapped onto the incoming interface's address, causing the packets to 439 mapped onto the incoming interface's address, causing the packets to
@@ -445,7 +444,7 @@ config IP_NF_TARGET_REDIRECT
445 444
446config IP_NF_TARGET_NETMAP 445config IP_NF_TARGET_NETMAP
447 tristate "NETMAP target support" 446 tristate "NETMAP target support"
448 depends on IP_NF_NAT 447 depends on (NF_NAT || IP_NF_NAT)
449 help 448 help
450 NETMAP is an implementation of static 1:1 NAT mapping of network 449 NETMAP is an implementation of static 1:1 NAT mapping of network
451 addresses. It maps the network address part, while keeping the host 450 addresses. It maps the network address part, while keeping the host
@@ -456,7 +455,7 @@ config IP_NF_TARGET_NETMAP
456 455
457config IP_NF_TARGET_SAME 456config IP_NF_TARGET_SAME
458 tristate "SAME target support" 457 tristate "SAME target support"
459 depends on IP_NF_NAT 458 depends on (NF_NAT || IP_NF_NAT)
460 help 459 help
461 This option adds a `SAME' target, which works like the standard SNAT 460 This option adds a `SAME' target, which works like the standard SNAT
462 target, but attempts to give clients the same IP for all connections. 461 target, but attempts to give clients the same IP for all connections.
@@ -478,19 +477,52 @@ config IP_NF_NAT_SNMP_BASIC
478 477
479 To compile it as a module, choose M here. If unsure, say N. 478 To compile it as a module, choose M here. If unsure, say N.
480 479
480config NF_NAT_SNMP_BASIC
481 tristate "Basic SNMP-ALG support (EXPERIMENTAL)"
482 depends on EXPERIMENTAL && NF_NAT
483 ---help---
484
485 This module implements an Application Layer Gateway (ALG) for
486 SNMP payloads. In conjunction with NAT, it allows a network
487 management system to access multiple private networks with
488 conflicting addresses. It works by modifying IP addresses
489 inside SNMP payloads to match IP-layer NAT mapping.
490
491 This is the "basic" form of SNMP-ALG, as described in RFC 2962
492
493 To compile it as a module, choose M here. If unsure, say N.
494
495# If they want FTP, set to $CONFIG_IP_NF_NAT (m or y),
496# or $CONFIG_IP_NF_FTP (m or y), whichever is weaker.
497# From kconfig-language.txt:
498#
499# <expr> '&&' <expr> (6)
500#
501# (6) Returns the result of min(/expr/, /expr/).
502config NF_NAT_PROTO_GRE
503 tristate
504 depends on NF_NAT && NF_CT_PROTO_GRE
505
506config IP_NF_NAT_FTP
507 tristate
508 depends on IP_NF_IPTABLES && IP_NF_CONNTRACK && IP_NF_NAT
509 default IP_NF_NAT && IP_NF_FTP
510
511config NF_NAT_FTP
512 tristate
513 depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
514 default NF_NAT && NF_CONNTRACK_FTP
515
481config IP_NF_NAT_IRC 516config IP_NF_NAT_IRC
482 tristate 517 tristate
483 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n 518 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
484 default IP_NF_NAT if IP_NF_IRC=y 519 default IP_NF_NAT if IP_NF_IRC=y
485 default m if IP_NF_IRC=m 520 default m if IP_NF_IRC=m
486 521
487# If they want FTP, set to $CONFIG_IP_NF_NAT (m or y), 522config NF_NAT_IRC
488# or $CONFIG_IP_NF_FTP (m or y), whichever is weaker. Argh.
489config IP_NF_NAT_FTP
490 tristate 523 tristate
491 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n 524 depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
492 default IP_NF_NAT if IP_NF_FTP=y 525 default NF_NAT && NF_CONNTRACK_IRC
493 default m if IP_NF_FTP=m
494 526
495config IP_NF_NAT_TFTP 527config IP_NF_NAT_TFTP
496 tristate 528 tristate
@@ -498,30 +530,56 @@ config IP_NF_NAT_TFTP
498 default IP_NF_NAT if IP_NF_TFTP=y 530 default IP_NF_NAT if IP_NF_TFTP=y
499 default m if IP_NF_TFTP=m 531 default m if IP_NF_TFTP=m
500 532
533config NF_NAT_TFTP
534 tristate
535 depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
536 default NF_NAT && NF_CONNTRACK_TFTP
537
501config IP_NF_NAT_AMANDA 538config IP_NF_NAT_AMANDA
502 tristate 539 tristate
503 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n 540 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
504 default IP_NF_NAT if IP_NF_AMANDA=y 541 default IP_NF_NAT if IP_NF_AMANDA=y
505 default m if IP_NF_AMANDA=m 542 default m if IP_NF_AMANDA=m
506 543
544config NF_NAT_AMANDA
545 tristate
546 depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
547 default NF_NAT && NF_CONNTRACK_AMANDA
548
507config IP_NF_NAT_PPTP 549config IP_NF_NAT_PPTP
508 tristate 550 tristate
509 depends on IP_NF_NAT!=n && IP_NF_PPTP!=n 551 depends on IP_NF_NAT!=n && IP_NF_PPTP!=n
510 default IP_NF_NAT if IP_NF_PPTP=y 552 default IP_NF_NAT if IP_NF_PPTP=y
511 default m if IP_NF_PPTP=m 553 default m if IP_NF_PPTP=m
512 554
555config NF_NAT_PPTP
556 tristate
557 depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
558 default NF_NAT && NF_CONNTRACK_PPTP
559 select NF_NAT_PROTO_GRE
560
513config IP_NF_NAT_H323 561config IP_NF_NAT_H323
514 tristate 562 tristate
515 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n 563 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
516 default IP_NF_NAT if IP_NF_H323=y 564 default IP_NF_NAT if IP_NF_H323=y
517 default m if IP_NF_H323=m 565 default m if IP_NF_H323=m
518 566
567config NF_NAT_H323
568 tristate
569 depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
570 default NF_NAT && NF_CONNTRACK_H323
571
519config IP_NF_NAT_SIP 572config IP_NF_NAT_SIP
520 tristate 573 tristate
521 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n 574 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
522 default IP_NF_NAT if IP_NF_SIP=y 575 default IP_NF_NAT if IP_NF_SIP=y
523 default m if IP_NF_SIP=m 576 default m if IP_NF_SIP=m
524 577
578config NF_NAT_SIP
579 tristate
580 depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
581 default NF_NAT && NF_CONNTRACK_SIP
582
525# mangle + specific targets 583# mangle + specific targets
526config IP_NF_MANGLE 584config IP_NF_MANGLE
527 tristate "Packet mangling" 585 tristate "Packet mangling"
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
index 09aaed1a8063..15e741aeb291 100644
--- a/net/ipv4/netfilter/Makefile
+++ b/net/ipv4/netfilter/Makefile
@@ -5,17 +5,23 @@
5# objects for the standalone - connection tracking / NAT 5# objects for the standalone - connection tracking / NAT
6ip_conntrack-objs := ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o 6ip_conntrack-objs := ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o
7ip_nat-objs := ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o 7ip_nat-objs := ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o
8nf_nat-objs := nf_nat_core.o nf_nat_helper.o nf_nat_proto_unknown.o nf_nat_proto_tcp.o nf_nat_proto_udp.o nf_nat_proto_icmp.o
9ifneq ($(CONFIG_NF_NAT),)
10iptable_nat-objs := nf_nat_rule.o nf_nat_standalone.o
11else
8iptable_nat-objs := ip_nat_rule.o ip_nat_standalone.o 12iptable_nat-objs := ip_nat_rule.o ip_nat_standalone.o
13endif
9 14
10ip_conntrack_pptp-objs := ip_conntrack_helper_pptp.o ip_conntrack_proto_gre.o 15ip_conntrack_pptp-objs := ip_conntrack_helper_pptp.o ip_conntrack_proto_gre.o
11ip_nat_pptp-objs := ip_nat_helper_pptp.o ip_nat_proto_gre.o 16ip_nat_pptp-objs := ip_nat_helper_pptp.o ip_nat_proto_gre.o
12 17
13ip_conntrack_h323-objs := ip_conntrack_helper_h323.o ip_conntrack_helper_h323_asn1.o 18ip_conntrack_h323-objs := ip_conntrack_helper_h323.o ../../netfilter/nf_conntrack_h323_asn1.o
14ip_nat_h323-objs := ip_nat_helper_h323.o 19ip_nat_h323-objs := ip_nat_helper_h323.o
15 20
16# connection tracking 21# connection tracking
17obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o 22obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o
18obj-$(CONFIG_IP_NF_NAT) += ip_nat.o 23obj-$(CONFIG_IP_NF_NAT) += ip_nat.o
24obj-$(CONFIG_NF_NAT) += nf_nat.o
19 25
20# conntrack netlink interface 26# conntrack netlink interface
21obj-$(CONFIG_IP_NF_CONNTRACK_NETLINK) += ip_conntrack_netlink.o 27obj-$(CONFIG_IP_NF_CONNTRACK_NETLINK) += ip_conntrack_netlink.o
@@ -34,7 +40,7 @@ obj-$(CONFIG_IP_NF_IRC) += ip_conntrack_irc.o
34obj-$(CONFIG_IP_NF_SIP) += ip_conntrack_sip.o 40obj-$(CONFIG_IP_NF_SIP) += ip_conntrack_sip.o
35obj-$(CONFIG_IP_NF_NETBIOS_NS) += ip_conntrack_netbios_ns.o 41obj-$(CONFIG_IP_NF_NETBIOS_NS) += ip_conntrack_netbios_ns.o
36 42
37# NAT helpers 43# NAT helpers (ip_conntrack)
38obj-$(CONFIG_IP_NF_NAT_H323) += ip_nat_h323.o 44obj-$(CONFIG_IP_NF_NAT_H323) += ip_nat_h323.o
39obj-$(CONFIG_IP_NF_NAT_PPTP) += ip_nat_pptp.o 45obj-$(CONFIG_IP_NF_NAT_PPTP) += ip_nat_pptp.o
40obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o 46obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o
@@ -43,6 +49,19 @@ obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o
43obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o 49obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o
44obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_sip.o 50obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_sip.o
45 51
52# NAT helpers (nf_conntrack)
53obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_amanda.o
54obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o
55obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o
56obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o
57obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o
58obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o
59obj-$(CONFIG_NF_NAT_SNMP_BASIC) += nf_nat_snmp_basic.o
60obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o
61
62# NAT protocols (nf_nat)
63obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o
64
46# generic IP tables 65# generic IP tables
47obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o 66obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o
48 67
@@ -50,10 +69,10 @@ obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o
50obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o 69obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o
51obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o 70obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o
52obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o 71obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o
72obj-$(CONFIG_NF_NAT) += iptable_nat.o
53obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o 73obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o
54 74
55# matches 75# matches
56obj-$(CONFIG_IP_NF_MATCH_HASHLIMIT) += ipt_hashlimit.o
57obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o 76obj-$(CONFIG_IP_NF_MATCH_IPRANGE) += ipt_iprange.o
58obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o 77obj-$(CONFIG_IP_NF_MATCH_OWNER) += ipt_owner.o
59obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o 78obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o
@@ -89,6 +108,11 @@ obj-$(CONFIG_IP_NF_QUEUE) += ip_queue.o
89 108
90# objects for l3 independent conntrack 109# objects for l3 independent conntrack
91nf_conntrack_ipv4-objs := nf_conntrack_l3proto_ipv4.o nf_conntrack_proto_icmp.o 110nf_conntrack_ipv4-objs := nf_conntrack_l3proto_ipv4.o nf_conntrack_proto_icmp.o
111ifeq ($(CONFIG_NF_CONNTRACK_PROC_COMPAT),y)
112ifeq ($(CONFIG_PROC_FS),y)
113nf_conntrack_ipv4-objs += nf_conntrack_l3proto_ipv4_compat.o
114endif
115endif
92 116
93# l3 independent conntrack 117# l3 independent conntrack
94obj-$(CONFIG_NF_CONNTRACK_IPV4) += nf_conntrack_ipv4.o 118obj-$(CONFIG_NF_CONNTRACK_IPV4) += nf_conntrack_ipv4.o
diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c
index 6c7383a8e42b..ad246ba7790b 100644
--- a/net/ipv4/netfilter/ip_conntrack_amanda.c
+++ b/net/ipv4/netfilter/ip_conntrack_amanda.c
@@ -92,6 +92,7 @@ static int help(struct sk_buff **pskb,
92 char pbuf[sizeof("65535")], *tmp; 92 char pbuf[sizeof("65535")], *tmp;
93 u_int16_t port, len; 93 u_int16_t port, len;
94 int ret = NF_ACCEPT; 94 int ret = NF_ACCEPT;
95 typeof(ip_nat_amanda_hook) ip_nat_amanda;
95 96
96 /* Only look at packets from the Amanda server */ 97 /* Only look at packets from the Amanda server */
97 if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) 98 if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL)
@@ -161,9 +162,11 @@ static int help(struct sk_buff **pskb,
161 exp->mask.dst.protonum = 0xFF; 162 exp->mask.dst.protonum = 0xFF;
162 exp->mask.dst.u.tcp.port = htons(0xFFFF); 163 exp->mask.dst.u.tcp.port = htons(0xFFFF);
163 164
164 if (ip_nat_amanda_hook) 165 /* RCU read locked by nf_hook_slow */
165 ret = ip_nat_amanda_hook(pskb, ctinfo, off - dataoff, 166 ip_nat_amanda = rcu_dereference(ip_nat_amanda_hook);
166 len, exp); 167 if (ip_nat_amanda)
168 ret = ip_nat_amanda(pskb, ctinfo, off - dataoff,
169 len, exp);
167 else if (ip_conntrack_expect_related(exp) != 0) 170 else if (ip_conntrack_expect_related(exp) != 0)
168 ret = NF_DROP; 171 ret = NF_DROP;
169 ip_conntrack_expect_put(exp); 172 ip_conntrack_expect_put(exp);
@@ -180,7 +183,7 @@ static struct ip_conntrack_helper amanda_helper = {
180 .help = help, 183 .help = help,
181 .name = "amanda", 184 .name = "amanda",
182 185
183 .tuple = { .src = { .u = { __constant_htons(10080) } }, 186 .tuple = { .src = { .u = { .udp = {.port = __constant_htons(10080) } } },
184 .dst = { .protonum = IPPROTO_UDP }, 187 .dst = { .protonum = IPPROTO_UDP },
185 }, 188 },
186 .mask = { .src = { .u = { 0xFFFF } }, 189 .mask = { .src = { .u = { 0xFFFF } },
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 143c4668538b..f4b0e68a16d2 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -40,9 +40,6 @@
40 40
41/* ip_conntrack_lock protects the main hash table, protocol/helper/expected 41/* ip_conntrack_lock protects the main hash table, protocol/helper/expected
42 registrations, conntrack timers*/ 42 registrations, conntrack timers*/
43#define ASSERT_READ_LOCK(x)
44#define ASSERT_WRITE_LOCK(x)
45
46#include <linux/netfilter_ipv4/ip_conntrack.h> 43#include <linux/netfilter_ipv4/ip_conntrack.h>
47#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 44#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
48#include <linux/netfilter_ipv4/ip_conntrack_helper.h> 45#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
@@ -201,7 +198,6 @@ ip_ct_invert_tuple(struct ip_conntrack_tuple *inverse,
201/* ip_conntrack_expect helper functions */ 198/* ip_conntrack_expect helper functions */
202void ip_ct_unlink_expect(struct ip_conntrack_expect *exp) 199void ip_ct_unlink_expect(struct ip_conntrack_expect *exp)
203{ 200{
204 ASSERT_WRITE_LOCK(&ip_conntrack_lock);
205 IP_NF_ASSERT(!timer_pending(&exp->timeout)); 201 IP_NF_ASSERT(!timer_pending(&exp->timeout));
206 list_del(&exp->list); 202 list_del(&exp->list);
207 CONNTRACK_STAT_INC(expect_delete); 203 CONNTRACK_STAT_INC(expect_delete);
@@ -225,22 +221,22 @@ __ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple)
225 struct ip_conntrack_expect *i; 221 struct ip_conntrack_expect *i;
226 222
227 list_for_each_entry(i, &ip_conntrack_expect_list, list) { 223 list_for_each_entry(i, &ip_conntrack_expect_list, list) {
228 if (ip_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask)) { 224 if (ip_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask))
229 atomic_inc(&i->use);
230 return i; 225 return i;
231 }
232 } 226 }
233 return NULL; 227 return NULL;
234} 228}
235 229
236/* Just find a expectation corresponding to a tuple. */ 230/* Just find a expectation corresponding to a tuple. */
237struct ip_conntrack_expect * 231struct ip_conntrack_expect *
238ip_conntrack_expect_find(const struct ip_conntrack_tuple *tuple) 232ip_conntrack_expect_find_get(const struct ip_conntrack_tuple *tuple)
239{ 233{
240 struct ip_conntrack_expect *i; 234 struct ip_conntrack_expect *i;
241 235
242 read_lock_bh(&ip_conntrack_lock); 236 read_lock_bh(&ip_conntrack_lock);
243 i = __ip_conntrack_expect_find(tuple); 237 i = __ip_conntrack_expect_find(tuple);
238 if (i)
239 atomic_inc(&i->use);
244 read_unlock_bh(&ip_conntrack_lock); 240 read_unlock_bh(&ip_conntrack_lock);
245 241
246 return i; 242 return i;
@@ -294,7 +290,6 @@ static void
294clean_from_lists(struct ip_conntrack *ct) 290clean_from_lists(struct ip_conntrack *ct)
295{ 291{
296 DEBUGP("clean_from_lists(%p)\n", ct); 292 DEBUGP("clean_from_lists(%p)\n", ct);
297 ASSERT_WRITE_LOCK(&ip_conntrack_lock);
298 list_del(&ct->tuplehash[IP_CT_DIR_ORIGINAL].list); 293 list_del(&ct->tuplehash[IP_CT_DIR_ORIGINAL].list);
299 list_del(&ct->tuplehash[IP_CT_DIR_REPLY].list); 294 list_del(&ct->tuplehash[IP_CT_DIR_REPLY].list);
300 295
@@ -373,7 +368,6 @@ __ip_conntrack_find(const struct ip_conntrack_tuple *tuple,
373 struct ip_conntrack_tuple_hash *h; 368 struct ip_conntrack_tuple_hash *h;
374 unsigned int hash = hash_conntrack(tuple); 369 unsigned int hash = hash_conntrack(tuple);
375 370
376 ASSERT_READ_LOCK(&ip_conntrack_lock);
377 list_for_each_entry(h, &ip_conntrack_hash[hash], list) { 371 list_for_each_entry(h, &ip_conntrack_hash[hash], list) {
378 if (tuplehash_to_ctrack(h) != ignored_conntrack && 372 if (tuplehash_to_ctrack(h) != ignored_conntrack &&
379 ip_ct_tuple_equal(tuple, &h->tuple)) { 373 ip_ct_tuple_equal(tuple, &h->tuple)) {
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
index 93dcf960662f..0410c99cacae 100644
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -310,6 +310,7 @@ static int help(struct sk_buff **pskb,
310 struct ip_conntrack_expect *exp; 310 struct ip_conntrack_expect *exp;
311 unsigned int i; 311 unsigned int i;
312 int found = 0, ends_in_nl; 312 int found = 0, ends_in_nl;
313 typeof(ip_nat_ftp_hook) ip_nat_ftp;
313 314
314 /* Until there's been traffic both ways, don't look in packets. */ 315 /* Until there's been traffic both ways, don't look in packets. */
315 if (ctinfo != IP_CT_ESTABLISHED 316 if (ctinfo != IP_CT_ESTABLISHED
@@ -433,9 +434,10 @@ static int help(struct sk_buff **pskb,
433 434
434 /* Now, NAT might want to mangle the packet, and register the 435 /* Now, NAT might want to mangle the packet, and register the
435 * (possibly changed) expectation itself. */ 436 * (possibly changed) expectation itself. */
436 if (ip_nat_ftp_hook) 437 ip_nat_ftp = rcu_dereference(ip_nat_ftp_hook);
437 ret = ip_nat_ftp_hook(pskb, ctinfo, search[dir][i].ftptype, 438 if (ip_nat_ftp)
438 matchoff, matchlen, exp, &seq); 439 ret = ip_nat_ftp(pskb, ctinfo, search[dir][i].ftptype,
440 matchoff, matchlen, exp, &seq);
439 else { 441 else {
440 /* Can't expect this? Best to drop packet now. */ 442 /* Can't expect this? Best to drop packet now. */
441 if (ip_conntrack_expect_related(exp) != 0) 443 if (ip_conntrack_expect_related(exp) != 0)
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323.c b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
index 7b7441202bfd..aabfe1c06905 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
@@ -237,6 +237,7 @@ static int expect_rtp_rtcp(struct sk_buff **pskb, struct ip_conntrack *ct,
237 u_int16_t rtp_port; 237 u_int16_t rtp_port;
238 struct ip_conntrack_expect *rtp_exp; 238 struct ip_conntrack_expect *rtp_exp;
239 struct ip_conntrack_expect *rtcp_exp; 239 struct ip_conntrack_expect *rtcp_exp;
240 typeof(nat_rtp_rtcp_hook) nat_rtp_rtcp;
240 241
241 /* Read RTP or RTCP address */ 242 /* Read RTP or RTCP address */
242 if (!get_h245_addr(*data, addr, &ip, &port) || 243 if (!get_h245_addr(*data, addr, &ip, &port) ||
@@ -279,11 +280,11 @@ static int expect_rtp_rtcp(struct sk_buff **pskb, struct ip_conntrack *ct,
279 rtcp_exp->flags = 0; 280 rtcp_exp->flags = 0;
280 281
281 if (ct->tuplehash[dir].tuple.src.ip != 282 if (ct->tuplehash[dir].tuple.src.ip !=
282 ct->tuplehash[!dir].tuple.dst.ip && nat_rtp_rtcp_hook) { 283 ct->tuplehash[!dir].tuple.dst.ip &&
284 (nat_rtp_rtcp = rcu_dereference(nat_rtp_rtcp_hook))) {
283 /* NAT needed */ 285 /* NAT needed */
284 ret = nat_rtp_rtcp_hook(pskb, ct, ctinfo, data, dataoff, 286 ret = nat_rtp_rtcp(pskb, ct, ctinfo, data, dataoff,
285 addr, port, rtp_port, rtp_exp, 287 addr, port, rtp_port, rtp_exp, rtcp_exp);
286 rtcp_exp);
287 } else { /* Conntrack only */ 288 } else { /* Conntrack only */
288 rtp_exp->expectfn = NULL; 289 rtp_exp->expectfn = NULL;
289 rtcp_exp->expectfn = NULL; 290 rtcp_exp->expectfn = NULL;
@@ -328,6 +329,7 @@ static int expect_t120(struct sk_buff **pskb,
328 __be32 ip; 329 __be32 ip;
329 u_int16_t port; 330 u_int16_t port;
330 struct ip_conntrack_expect *exp = NULL; 331 struct ip_conntrack_expect *exp = NULL;
332 typeof(nat_t120_hook) nat_t120;
331 333
332 /* Read T.120 address */ 334 /* Read T.120 address */
333 if (!get_h245_addr(*data, addr, &ip, &port) || 335 if (!get_h245_addr(*data, addr, &ip, &port) ||
@@ -350,10 +352,11 @@ static int expect_t120(struct sk_buff **pskb,
350 exp->flags = IP_CT_EXPECT_PERMANENT; /* Accept multiple channels */ 352 exp->flags = IP_CT_EXPECT_PERMANENT; /* Accept multiple channels */
351 353
352 if (ct->tuplehash[dir].tuple.src.ip != 354 if (ct->tuplehash[dir].tuple.src.ip !=
353 ct->tuplehash[!dir].tuple.dst.ip && nat_t120_hook) { 355 ct->tuplehash[!dir].tuple.dst.ip &&
356 (nat_t120 = rcu_dereference(nat_t120_hook))) {
354 /* NAT needed */ 357 /* NAT needed */
355 ret = nat_t120_hook(pskb, ct, ctinfo, data, dataoff, addr, 358 ret = nat_t120(pskb, ct, ctinfo, data, dataoff, addr,
356 port, exp); 359 port, exp);
357 } else { /* Conntrack only */ 360 } else { /* Conntrack only */
358 exp->expectfn = NULL; 361 exp->expectfn = NULL;
359 if (ip_conntrack_expect_related(exp) == 0) { 362 if (ip_conntrack_expect_related(exp) == 0) {
@@ -651,6 +654,7 @@ static int expect_h245(struct sk_buff **pskb, struct ip_conntrack *ct,
651 __be32 ip; 654 __be32 ip;
652 u_int16_t port; 655 u_int16_t port;
653 struct ip_conntrack_expect *exp = NULL; 656 struct ip_conntrack_expect *exp = NULL;
657 typeof(nat_h245_hook) nat_h245;
654 658
655 /* Read h245Address */ 659 /* Read h245Address */
656 if (!get_h225_addr(*data, addr, &ip, &port) || 660 if (!get_h225_addr(*data, addr, &ip, &port) ||
@@ -673,10 +677,11 @@ static int expect_h245(struct sk_buff **pskb, struct ip_conntrack *ct,
673 exp->flags = 0; 677 exp->flags = 0;
674 678
675 if (ct->tuplehash[dir].tuple.src.ip != 679 if (ct->tuplehash[dir].tuple.src.ip !=
676 ct->tuplehash[!dir].tuple.dst.ip && nat_h245_hook) { 680 ct->tuplehash[!dir].tuple.dst.ip &&
681 (nat_h245 = rcu_dereference(nat_h245_hook))) {
677 /* NAT needed */ 682 /* NAT needed */
678 ret = nat_h245_hook(pskb, ct, ctinfo, data, dataoff, addr, 683 ret = nat_h245(pskb, ct, ctinfo, data, dataoff, addr,
679 port, exp); 684 port, exp);
680 } else { /* Conntrack only */ 685 } else { /* Conntrack only */
681 exp->expectfn = ip_conntrack_h245_expect; 686 exp->expectfn = ip_conntrack_h245_expect;
682 687
@@ -712,6 +717,7 @@ static int expect_callforwarding(struct sk_buff **pskb,
712 __be32 ip; 717 __be32 ip;
713 u_int16_t port; 718 u_int16_t port;
714 struct ip_conntrack_expect *exp = NULL; 719 struct ip_conntrack_expect *exp = NULL;
720 typeof(nat_callforwarding_hook) nat_callforwarding;
715 721
716 /* Read alternativeAddress */ 722 /* Read alternativeAddress */
717 if (!get_h225_addr(*data, addr, &ip, &port) || port == 0) 723 if (!get_h225_addr(*data, addr, &ip, &port) || port == 0)
@@ -759,10 +765,11 @@ static int expect_callforwarding(struct sk_buff **pskb,
759 exp->flags = 0; 765 exp->flags = 0;
760 766
761 if (ct->tuplehash[dir].tuple.src.ip != 767 if (ct->tuplehash[dir].tuple.src.ip !=
762 ct->tuplehash[!dir].tuple.dst.ip && nat_callforwarding_hook) { 768 ct->tuplehash[!dir].tuple.dst.ip &&
769 (nat_callforwarding = rcu_dereference(nat_callforwarding_hook))) {
763 /* Need NAT */ 770 /* Need NAT */
764 ret = nat_callforwarding_hook(pskb, ct, ctinfo, data, dataoff, 771 ret = nat_callforwarding(pskb, ct, ctinfo, data, dataoff,
765 addr, port, exp); 772 addr, port, exp);
766 } else { /* Conntrack only */ 773 } else { /* Conntrack only */
767 exp->expectfn = ip_conntrack_q931_expect; 774 exp->expectfn = ip_conntrack_q931_expect;
768 775
@@ -793,6 +800,7 @@ static int process_setup(struct sk_buff **pskb, struct ip_conntrack *ct,
793 int i; 800 int i;
794 __be32 ip; 801 __be32 ip;
795 u_int16_t port; 802 u_int16_t port;
803 typeof(set_h225_addr_hook) set_h225_addr;
796 804
797 DEBUGP("ip_ct_q931: Setup\n"); 805 DEBUGP("ip_ct_q931: Setup\n");
798 806
@@ -803,8 +811,10 @@ static int process_setup(struct sk_buff **pskb, struct ip_conntrack *ct,
803 return -1; 811 return -1;
804 } 812 }
805 813
814 set_h225_addr = rcu_dereference(set_h225_addr_hook);
815
806 if ((setup->options & eSetup_UUIE_destCallSignalAddress) && 816 if ((setup->options & eSetup_UUIE_destCallSignalAddress) &&
807 (set_h225_addr_hook) && 817 (set_h225_addr) &&
808 get_h225_addr(*data, &setup->destCallSignalAddress, &ip, &port) && 818 get_h225_addr(*data, &setup->destCallSignalAddress, &ip, &port) &&
809 ip != ct->tuplehash[!dir].tuple.src.ip) { 819 ip != ct->tuplehash[!dir].tuple.src.ip) {
810 DEBUGP("ip_ct_q931: set destCallSignalAddress " 820 DEBUGP("ip_ct_q931: set destCallSignalAddress "
@@ -812,17 +822,17 @@ static int process_setup(struct sk_buff **pskb, struct ip_conntrack *ct,
812 NIPQUAD(ip), port, 822 NIPQUAD(ip), port,
813 NIPQUAD(ct->tuplehash[!dir].tuple.src.ip), 823 NIPQUAD(ct->tuplehash[!dir].tuple.src.ip),
814 ntohs(ct->tuplehash[!dir].tuple.src.u.tcp.port)); 824 ntohs(ct->tuplehash[!dir].tuple.src.u.tcp.port));
815 ret = set_h225_addr_hook(pskb, data, dataoff, 825 ret = set_h225_addr(pskb, data, dataoff,
816 &setup->destCallSignalAddress, 826 &setup->destCallSignalAddress,
817 ct->tuplehash[!dir].tuple.src.ip, 827 ct->tuplehash[!dir].tuple.src.ip,
818 ntohs(ct->tuplehash[!dir].tuple.src. 828 ntohs(ct->tuplehash[!dir].tuple.src.
819 u.tcp.port)); 829 u.tcp.port));
820 if (ret < 0) 830 if (ret < 0)
821 return -1; 831 return -1;
822 } 832 }
823 833
824 if ((setup->options & eSetup_UUIE_sourceCallSignalAddress) && 834 if ((setup->options & eSetup_UUIE_sourceCallSignalAddress) &&
825 (set_h225_addr_hook) && 835 (set_h225_addr) &&
826 get_h225_addr(*data, &setup->sourceCallSignalAddress, &ip, &port) 836 get_h225_addr(*data, &setup->sourceCallSignalAddress, &ip, &port)
827 && ip != ct->tuplehash[!dir].tuple.dst.ip) { 837 && ip != ct->tuplehash[!dir].tuple.dst.ip) {
828 DEBUGP("ip_ct_q931: set sourceCallSignalAddress " 838 DEBUGP("ip_ct_q931: set sourceCallSignalAddress "
@@ -830,11 +840,11 @@ static int process_setup(struct sk_buff **pskb, struct ip_conntrack *ct,
830 NIPQUAD(ip), port, 840 NIPQUAD(ip), port,
831 NIPQUAD(ct->tuplehash[!dir].tuple.dst.ip), 841 NIPQUAD(ct->tuplehash[!dir].tuple.dst.ip),
832 ntohs(ct->tuplehash[!dir].tuple.dst.u.tcp.port)); 842 ntohs(ct->tuplehash[!dir].tuple.dst.u.tcp.port));
833 ret = set_h225_addr_hook(pskb, data, dataoff, 843 ret = set_h225_addr(pskb, data, dataoff,
834 &setup->sourceCallSignalAddress, 844 &setup->sourceCallSignalAddress,
835 ct->tuplehash[!dir].tuple.dst.ip, 845 ct->tuplehash[!dir].tuple.dst.ip,
836 ntohs(ct->tuplehash[!dir].tuple.dst. 846 ntohs(ct->tuplehash[!dir].tuple.dst.
837 u.tcp.port)); 847 u.tcp.port));
838 if (ret < 0) 848 if (ret < 0)
839 return -1; 849 return -1;
840 } 850 }
@@ -1153,7 +1163,7 @@ static struct ip_conntrack_helper ip_conntrack_helper_q931 = {
1153 .me = THIS_MODULE, 1163 .me = THIS_MODULE,
1154 .max_expected = H323_RTP_CHANNEL_MAX * 4 + 4 /* T.120 and H.245 */ , 1164 .max_expected = H323_RTP_CHANNEL_MAX * 4 + 4 /* T.120 and H.245 */ ,
1155 .timeout = 240, 1165 .timeout = 240,
1156 .tuple = {.src = {.u = {__constant_htons(Q931_PORT)}}, 1166 .tuple = {.src = {.u = {.tcp = {.port = __constant_htons(Q931_PORT)}}},
1157 .dst = {.protonum = IPPROTO_TCP}}, 1167 .dst = {.protonum = IPPROTO_TCP}},
1158 .mask = {.src = {.u = {0xFFFF}}, 1168 .mask = {.src = {.u = {0xFFFF}},
1159 .dst = {.protonum = 0xFF}}, 1169 .dst = {.protonum = 0xFF}},
@@ -1231,6 +1241,7 @@ static int expect_q931(struct sk_buff **pskb, struct ip_conntrack *ct,
1231 __be32 ip; 1241 __be32 ip;
1232 u_int16_t port; 1242 u_int16_t port;
1233 struct ip_conntrack_expect *exp; 1243 struct ip_conntrack_expect *exp;
1244 typeof(nat_q931_hook) nat_q931;
1234 1245
1235 /* Look for the first related address */ 1246 /* Look for the first related address */
1236 for (i = 0; i < count; i++) { 1247 for (i = 0; i < count; i++) {
@@ -1258,9 +1269,9 @@ static int expect_q931(struct sk_buff **pskb, struct ip_conntrack *ct,
1258 exp->mask.dst.protonum = 0xFF; 1269 exp->mask.dst.protonum = 0xFF;
1259 exp->flags = IP_CT_EXPECT_PERMANENT; /* Accept multiple calls */ 1270 exp->flags = IP_CT_EXPECT_PERMANENT; /* Accept multiple calls */
1260 1271
1261 if (nat_q931_hook) { /* Need NAT */ 1272 nat_q931 = rcu_dereference(nat_q931_hook);
1262 ret = nat_q931_hook(pskb, ct, ctinfo, data, addr, i, 1273 if (nat_q931) { /* Need NAT */
1263 port, exp); 1274 ret = nat_q931(pskb, ct, ctinfo, data, addr, i, port, exp);
1264 } else { /* Conntrack only */ 1275 } else { /* Conntrack only */
1265 exp->expectfn = ip_conntrack_q931_expect; 1276 exp->expectfn = ip_conntrack_q931_expect;
1266 1277
@@ -1288,11 +1299,14 @@ static int process_grq(struct sk_buff **pskb, struct ip_conntrack *ct,
1288 enum ip_conntrack_info ctinfo, 1299 enum ip_conntrack_info ctinfo,
1289 unsigned char **data, GatekeeperRequest * grq) 1300 unsigned char **data, GatekeeperRequest * grq)
1290{ 1301{
1302 typeof(set_ras_addr_hook) set_ras_addr;
1303
1291 DEBUGP("ip_ct_ras: GRQ\n"); 1304 DEBUGP("ip_ct_ras: GRQ\n");
1292 1305
1293 if (set_ras_addr_hook) /* NATed */ 1306 set_ras_addr = rcu_dereference(set_ras_addr_hook);
1294 return set_ras_addr_hook(pskb, ct, ctinfo, data, 1307 if (set_ras_addr) /* NATed */
1295 &grq->rasAddress, 1); 1308 return set_ras_addr(pskb, ct, ctinfo, data,
1309 &grq->rasAddress, 1);
1296 return 0; 1310 return 0;
1297} 1311}
1298 1312
@@ -1362,6 +1376,7 @@ static int process_rrq(struct sk_buff **pskb, struct ip_conntrack *ct,
1362{ 1376{
1363 struct ip_ct_h323_master *info = &ct->help.ct_h323_info; 1377 struct ip_ct_h323_master *info = &ct->help.ct_h323_info;
1364 int ret; 1378 int ret;
1379 typeof(set_ras_addr_hook) set_ras_addr;
1365 1380
1366 DEBUGP("ip_ct_ras: RRQ\n"); 1381 DEBUGP("ip_ct_ras: RRQ\n");
1367 1382
@@ -1371,10 +1386,11 @@ static int process_rrq(struct sk_buff **pskb, struct ip_conntrack *ct,
1371 if (ret < 0) 1386 if (ret < 0)
1372 return -1; 1387 return -1;
1373 1388
1374 if (set_ras_addr_hook) { 1389 set_ras_addr = rcu_dereference(set_ras_addr_hook);
1375 ret = set_ras_addr_hook(pskb, ct, ctinfo, data, 1390 if (set_ras_addr) {
1376 rrq->rasAddress.item, 1391 ret = set_ras_addr(pskb, ct, ctinfo, data,
1377 rrq->rasAddress.count); 1392 rrq->rasAddress.item,
1393 rrq->rasAddress.count);
1378 if (ret < 0) 1394 if (ret < 0)
1379 return -1; 1395 return -1;
1380 } 1396 }
@@ -1397,13 +1413,15 @@ static int process_rcf(struct sk_buff **pskb, struct ip_conntrack *ct,
1397 int dir = CTINFO2DIR(ctinfo); 1413 int dir = CTINFO2DIR(ctinfo);
1398 int ret; 1414 int ret;
1399 struct ip_conntrack_expect *exp; 1415 struct ip_conntrack_expect *exp;
1416 typeof(set_sig_addr_hook) set_sig_addr;
1400 1417
1401 DEBUGP("ip_ct_ras: RCF\n"); 1418 DEBUGP("ip_ct_ras: RCF\n");
1402 1419
1403 if (set_sig_addr_hook) { 1420 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1404 ret = set_sig_addr_hook(pskb, ct, ctinfo, data, 1421 if (set_sig_addr) {
1405 rcf->callSignalAddress.item, 1422 ret = set_sig_addr(pskb, ct, ctinfo, data,
1406 rcf->callSignalAddress.count); 1423 rcf->callSignalAddress.item,
1424 rcf->callSignalAddress.count);
1407 if (ret < 0) 1425 if (ret < 0)
1408 return -1; 1426 return -1;
1409 } 1427 }
@@ -1417,7 +1435,7 @@ static int process_rcf(struct sk_buff **pskb, struct ip_conntrack *ct,
1417 DEBUGP 1435 DEBUGP
1418 ("ip_ct_ras: set RAS connection timeout to %u seconds\n", 1436 ("ip_ct_ras: set RAS connection timeout to %u seconds\n",
1419 info->timeout); 1437 info->timeout);
1420 ip_ct_refresh_acct(ct, ctinfo, NULL, info->timeout * HZ); 1438 ip_ct_refresh(ct, *pskb, info->timeout * HZ);
1421 1439
1422 /* Set expect timeout */ 1440 /* Set expect timeout */
1423 read_lock_bh(&ip_conntrack_lock); 1441 read_lock_bh(&ip_conntrack_lock);
@@ -1448,13 +1466,15 @@ static int process_urq(struct sk_buff **pskb, struct ip_conntrack *ct,
1448 struct ip_ct_h323_master *info = &ct->help.ct_h323_info; 1466 struct ip_ct_h323_master *info = &ct->help.ct_h323_info;
1449 int dir = CTINFO2DIR(ctinfo); 1467 int dir = CTINFO2DIR(ctinfo);
1450 int ret; 1468 int ret;
1469 typeof(set_sig_addr_hook) set_sig_addr;
1451 1470
1452 DEBUGP("ip_ct_ras: URQ\n"); 1471 DEBUGP("ip_ct_ras: URQ\n");
1453 1472
1454 if (set_sig_addr_hook) { 1473 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1455 ret = set_sig_addr_hook(pskb, ct, ctinfo, data, 1474 if (set_sig_addr) {
1456 urq->callSignalAddress.item, 1475 ret = set_sig_addr(pskb, ct, ctinfo, data,
1457 urq->callSignalAddress.count); 1476 urq->callSignalAddress.item,
1477 urq->callSignalAddress.count);
1458 if (ret < 0) 1478 if (ret < 0)
1459 return -1; 1479 return -1;
1460 } 1480 }
@@ -1465,7 +1485,7 @@ static int process_urq(struct sk_buff **pskb, struct ip_conntrack *ct,
1465 info->sig_port[!dir] = 0; 1485 info->sig_port[!dir] = 0;
1466 1486
1467 /* Give it 30 seconds for UCF or URJ */ 1487 /* Give it 30 seconds for UCF or URJ */
1468 ip_ct_refresh_acct(ct, ctinfo, NULL, 30 * HZ); 1488 ip_ct_refresh(ct, *pskb, 30 * HZ);
1469 1489
1470 return 0; 1490 return 0;
1471} 1491}
@@ -1479,28 +1499,30 @@ static int process_arq(struct sk_buff **pskb, struct ip_conntrack *ct,
1479 int dir = CTINFO2DIR(ctinfo); 1499 int dir = CTINFO2DIR(ctinfo);
1480 __be32 ip; 1500 __be32 ip;
1481 u_int16_t port; 1501 u_int16_t port;
1502 typeof(set_h225_addr_hook) set_h225_addr;
1482 1503
1483 DEBUGP("ip_ct_ras: ARQ\n"); 1504 DEBUGP("ip_ct_ras: ARQ\n");
1484 1505
1506 set_h225_addr = rcu_dereference(set_h225_addr_hook);
1485 if ((arq->options & eAdmissionRequest_destCallSignalAddress) && 1507 if ((arq->options & eAdmissionRequest_destCallSignalAddress) &&
1486 get_h225_addr(*data, &arq->destCallSignalAddress, &ip, &port) && 1508 get_h225_addr(*data, &arq->destCallSignalAddress, &ip, &port) &&
1487 ip == ct->tuplehash[dir].tuple.src.ip && 1509 ip == ct->tuplehash[dir].tuple.src.ip &&
1488 port == info->sig_port[dir] && set_h225_addr_hook) { 1510 port == info->sig_port[dir] && set_h225_addr) {
1489 /* Answering ARQ */ 1511 /* Answering ARQ */
1490 return set_h225_addr_hook(pskb, data, 0, 1512 return set_h225_addr(pskb, data, 0,
1491 &arq->destCallSignalAddress, 1513 &arq->destCallSignalAddress,
1492 ct->tuplehash[!dir].tuple.dst.ip, 1514 ct->tuplehash[!dir].tuple.dst.ip,
1493 info->sig_port[!dir]); 1515 info->sig_port[!dir]);
1494 } 1516 }
1495 1517
1496 if ((arq->options & eAdmissionRequest_srcCallSignalAddress) && 1518 if ((arq->options & eAdmissionRequest_srcCallSignalAddress) &&
1497 get_h225_addr(*data, &arq->srcCallSignalAddress, &ip, &port) && 1519 get_h225_addr(*data, &arq->srcCallSignalAddress, &ip, &port) &&
1498 ip == ct->tuplehash[dir].tuple.src.ip && set_h225_addr_hook) { 1520 ip == ct->tuplehash[dir].tuple.src.ip && set_h225_addr) {
1499 /* Calling ARQ */ 1521 /* Calling ARQ */
1500 return set_h225_addr_hook(pskb, data, 0, 1522 return set_h225_addr(pskb, data, 0,
1501 &arq->srcCallSignalAddress, 1523 &arq->srcCallSignalAddress,
1502 ct->tuplehash[!dir].tuple.dst.ip, 1524 ct->tuplehash[!dir].tuple.dst.ip,
1503 port); 1525 port);
1504 } 1526 }
1505 1527
1506 return 0; 1528 return 0;
@@ -1516,6 +1538,7 @@ static int process_acf(struct sk_buff **pskb, struct ip_conntrack *ct,
1516 __be32 ip; 1538 __be32 ip;
1517 u_int16_t port; 1539 u_int16_t port;
1518 struct ip_conntrack_expect *exp; 1540 struct ip_conntrack_expect *exp;
1541 typeof(set_sig_addr_hook) set_sig_addr;
1519 1542
1520 DEBUGP("ip_ct_ras: ACF\n"); 1543 DEBUGP("ip_ct_ras: ACF\n");
1521 1544
@@ -1523,10 +1546,10 @@ static int process_acf(struct sk_buff **pskb, struct ip_conntrack *ct,
1523 return 0; 1546 return 0;
1524 1547
1525 if (ip == ct->tuplehash[dir].tuple.dst.ip) { /* Answering ACF */ 1548 if (ip == ct->tuplehash[dir].tuple.dst.ip) { /* Answering ACF */
1526 if (set_sig_addr_hook) 1549 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1527 return set_sig_addr_hook(pskb, ct, ctinfo, data, 1550 if (set_sig_addr)
1528 &acf->destCallSignalAddress, 1551 return set_sig_addr(pskb, ct, ctinfo, data,
1529 1); 1552 &acf->destCallSignalAddress, 1);
1530 return 0; 1553 return 0;
1531 } 1554 }
1532 1555
@@ -1566,11 +1589,14 @@ static int process_lrq(struct sk_buff **pskb, struct ip_conntrack *ct,
1566 enum ip_conntrack_info ctinfo, 1589 enum ip_conntrack_info ctinfo,
1567 unsigned char **data, LocationRequest * lrq) 1590 unsigned char **data, LocationRequest * lrq)
1568{ 1591{
1592 typeof(set_ras_addr_hook) set_ras_addr;
1593
1569 DEBUGP("ip_ct_ras: LRQ\n"); 1594 DEBUGP("ip_ct_ras: LRQ\n");
1570 1595
1571 if (set_ras_addr_hook) 1596 set_ras_addr = rcu_dereference(set_ras_addr_hook);
1572 return set_ras_addr_hook(pskb, ct, ctinfo, data, 1597 if (set_ras_addr)
1573 &lrq->replyAddress, 1); 1598 return set_ras_addr(pskb, ct, ctinfo, data,
1599 &lrq->replyAddress, 1);
1574 return 0; 1600 return 0;
1575} 1601}
1576 1602
@@ -1629,20 +1655,24 @@ static int process_irr(struct sk_buff **pskb, struct ip_conntrack *ct,
1629 unsigned char **data, InfoRequestResponse * irr) 1655 unsigned char **data, InfoRequestResponse * irr)
1630{ 1656{
1631 int ret; 1657 int ret;
1658 typeof(set_ras_addr_hook) set_ras_addr;
1659 typeof(set_sig_addr_hook) set_sig_addr;
1632 1660
1633 DEBUGP("ip_ct_ras: IRR\n"); 1661 DEBUGP("ip_ct_ras: IRR\n");
1634 1662
1635 if (set_ras_addr_hook) { 1663 set_ras_addr = rcu_dereference(set_ras_addr_hook);
1636 ret = set_ras_addr_hook(pskb, ct, ctinfo, data, 1664 if (set_ras_addr) {
1637 &irr->rasAddress, 1); 1665 ret = set_ras_addr(pskb, ct, ctinfo, data,
1666 &irr->rasAddress, 1);
1638 if (ret < 0) 1667 if (ret < 0)
1639 return -1; 1668 return -1;
1640 } 1669 }
1641 1670
1642 if (set_sig_addr_hook) { 1671 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1643 ret = set_sig_addr_hook(pskb, ct, ctinfo, data, 1672 if (set_sig_addr) {
1644 irr->callSignalAddress.item, 1673 ret = set_sig_addr(pskb, ct, ctinfo, data,
1645 irr->callSignalAddress.count); 1674 irr->callSignalAddress.item,
1675 irr->callSignalAddress.count);
1646 if (ret < 0) 1676 if (ret < 0)
1647 return -1; 1677 return -1;
1648 } 1678 }
@@ -1746,7 +1776,7 @@ static struct ip_conntrack_helper ip_conntrack_helper_ras = {
1746 .me = THIS_MODULE, 1776 .me = THIS_MODULE,
1747 .max_expected = 32, 1777 .max_expected = 32,
1748 .timeout = 240, 1778 .timeout = 240,
1749 .tuple = {.src = {.u = {__constant_htons(RAS_PORT)}}, 1779 .tuple = {.src = {.u = {.tcp = {.port = __constant_htons(RAS_PORT)}}},
1750 .dst = {.protonum = IPPROTO_UDP}}, 1780 .dst = {.protonum = IPPROTO_UDP}},
1751 .mask = {.src = {.u = {0xFFFE}}, 1781 .mask = {.src = {.u = {0xFFFE}},
1752 .dst = {.protonum = 0xFF}}, 1782 .dst = {.protonum = 0xFF}},
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
index a2af5e0c7f99..4d19373bbf0d 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c
@@ -124,6 +124,8 @@ EXPORT_SYMBOL(pptp_msg_name);
124static void pptp_expectfn(struct ip_conntrack *ct, 124static void pptp_expectfn(struct ip_conntrack *ct,
125 struct ip_conntrack_expect *exp) 125 struct ip_conntrack_expect *exp)
126{ 126{
127 typeof(ip_nat_pptp_hook_expectfn) ip_nat_pptp_expectfn;
128
127 DEBUGP("increasing timeouts\n"); 129 DEBUGP("increasing timeouts\n");
128 130
129 /* increase timeout of GRE data channel conntrack entry */ 131 /* increase timeout of GRE data channel conntrack entry */
@@ -133,7 +135,9 @@ static void pptp_expectfn(struct ip_conntrack *ct,
133 /* Can you see how rusty this code is, compared with the pre-2.6.11 135 /* Can you see how rusty this code is, compared with the pre-2.6.11
134 * one? That's what happened to my shiny newnat of 2002 ;( -HW */ 136 * one? That's what happened to my shiny newnat of 2002 ;( -HW */
135 137
136 if (!ip_nat_pptp_hook_expectfn) { 138 rcu_read_lock();
139 ip_nat_pptp_expectfn = rcu_dereference(ip_nat_pptp_hook_expectfn);
140 if (!ip_nat_pptp_expectfn) {
137 struct ip_conntrack_tuple inv_t; 141 struct ip_conntrack_tuple inv_t;
138 struct ip_conntrack_expect *exp_other; 142 struct ip_conntrack_expect *exp_other;
139 143
@@ -142,7 +146,7 @@ static void pptp_expectfn(struct ip_conntrack *ct,
142 DEBUGP("trying to unexpect other dir: "); 146 DEBUGP("trying to unexpect other dir: ");
143 DUMP_TUPLE(&inv_t); 147 DUMP_TUPLE(&inv_t);
144 148
145 exp_other = ip_conntrack_expect_find(&inv_t); 149 exp_other = ip_conntrack_expect_find_get(&inv_t);
146 if (exp_other) { 150 if (exp_other) {
147 /* delete other expectation. */ 151 /* delete other expectation. */
148 DEBUGP("found\n"); 152 DEBUGP("found\n");
@@ -153,8 +157,9 @@ static void pptp_expectfn(struct ip_conntrack *ct,
153 } 157 }
154 } else { 158 } else {
155 /* we need more than simple inversion */ 159 /* we need more than simple inversion */
156 ip_nat_pptp_hook_expectfn(ct, exp); 160 ip_nat_pptp_expectfn(ct, exp);
157 } 161 }
162 rcu_read_unlock();
158} 163}
159 164
160static int destroy_sibling_or_exp(const struct ip_conntrack_tuple *t) 165static int destroy_sibling_or_exp(const struct ip_conntrack_tuple *t)
@@ -176,7 +181,7 @@ static int destroy_sibling_or_exp(const struct ip_conntrack_tuple *t)
176 ip_conntrack_put(sibling); 181 ip_conntrack_put(sibling);
177 return 1; 182 return 1;
178 } else { 183 } else {
179 exp = ip_conntrack_expect_find(t); 184 exp = ip_conntrack_expect_find_get(t);
180 if (exp) { 185 if (exp) {
181 DEBUGP("unexpect_related of expect %p\n", exp); 186 DEBUGP("unexpect_related of expect %p\n", exp);
182 ip_conntrack_unexpect_related(exp); 187 ip_conntrack_unexpect_related(exp);
@@ -226,6 +231,7 @@ exp_gre(struct ip_conntrack *ct,
226{ 231{
227 struct ip_conntrack_expect *exp_orig, *exp_reply; 232 struct ip_conntrack_expect *exp_orig, *exp_reply;
228 int ret = 1; 233 int ret = 1;
234 typeof(ip_nat_pptp_hook_exp_gre) ip_nat_pptp_exp_gre;
229 235
230 exp_orig = ip_conntrack_expect_alloc(ct); 236 exp_orig = ip_conntrack_expect_alloc(ct);
231 if (exp_orig == NULL) 237 if (exp_orig == NULL)
@@ -262,8 +268,9 @@ exp_gre(struct ip_conntrack *ct,
262 exp_reply->tuple.dst.u.gre.key = peer_callid; 268 exp_reply->tuple.dst.u.gre.key = peer_callid;
263 exp_reply->tuple.dst.protonum = IPPROTO_GRE; 269 exp_reply->tuple.dst.protonum = IPPROTO_GRE;
264 270
265 if (ip_nat_pptp_hook_exp_gre) 271 ip_nat_pptp_exp_gre = rcu_dereference(ip_nat_pptp_hook_exp_gre);
266 ip_nat_pptp_hook_exp_gre(exp_orig, exp_reply); 272 if (ip_nat_pptp_exp_gre)
273 ip_nat_pptp_exp_gre(exp_orig, exp_reply);
267 if (ip_conntrack_expect_related(exp_orig) != 0) 274 if (ip_conntrack_expect_related(exp_orig) != 0)
268 goto out_put_both; 275 goto out_put_both;
269 if (ip_conntrack_expect_related(exp_reply) != 0) 276 if (ip_conntrack_expect_related(exp_reply) != 0)
@@ -303,6 +310,7 @@ pptp_inbound_pkt(struct sk_buff **pskb,
303 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info; 310 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info;
304 u_int16_t msg; 311 u_int16_t msg;
305 __be16 cid = 0, pcid = 0; 312 __be16 cid = 0, pcid = 0;
313 typeof(ip_nat_pptp_hook_inbound) ip_nat_pptp_inbound;
306 314
307 msg = ntohs(ctlh->messageType); 315 msg = ntohs(ctlh->messageType);
308 DEBUGP("inbound control message %s\n", pptp_msg_name[msg]); 316 DEBUGP("inbound control message %s\n", pptp_msg_name[msg]);
@@ -402,9 +410,9 @@ pptp_inbound_pkt(struct sk_buff **pskb,
402 goto invalid; 410 goto invalid;
403 } 411 }
404 412
405 if (ip_nat_pptp_hook_inbound) 413 ip_nat_pptp_inbound = rcu_dereference(ip_nat_pptp_hook_inbound);
406 return ip_nat_pptp_hook_inbound(pskb, ct, ctinfo, ctlh, 414 if (ip_nat_pptp_inbound)
407 pptpReq); 415 return ip_nat_pptp_inbound(pskb, ct, ctinfo, ctlh, pptpReq);
408 return NF_ACCEPT; 416 return NF_ACCEPT;
409 417
410invalid: 418invalid:
@@ -427,6 +435,7 @@ pptp_outbound_pkt(struct sk_buff **pskb,
427 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info; 435 struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info;
428 u_int16_t msg; 436 u_int16_t msg;
429 __be16 cid = 0, pcid = 0; 437 __be16 cid = 0, pcid = 0;
438 typeof(ip_nat_pptp_hook_outbound) ip_nat_pptp_outbound;
430 439
431 msg = ntohs(ctlh->messageType); 440 msg = ntohs(ctlh->messageType);
432 DEBUGP("outbound control message %s\n", pptp_msg_name[msg]); 441 DEBUGP("outbound control message %s\n", pptp_msg_name[msg]);
@@ -492,9 +501,9 @@ pptp_outbound_pkt(struct sk_buff **pskb,
492 goto invalid; 501 goto invalid;
493 } 502 }
494 503
495 if (ip_nat_pptp_hook_outbound) 504 ip_nat_pptp_outbound = rcu_dereference(ip_nat_pptp_hook_outbound);
496 return ip_nat_pptp_hook_outbound(pskb, ct, ctinfo, ctlh, 505 if (ip_nat_pptp_outbound)
497 pptpReq); 506 return ip_nat_pptp_outbound(pskb, ct, ctinfo, ctlh, pptpReq);
498 return NF_ACCEPT; 507 return NF_ACCEPT;
499 508
500invalid: 509invalid:
diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
index 75f7c3db1619..91832eca4106 100644
--- a/net/ipv4/netfilter/ip_conntrack_irc.c
+++ b/net/ipv4/netfilter/ip_conntrack_irc.c
@@ -114,6 +114,7 @@ static int help(struct sk_buff **pskb,
114 u_int16_t dcc_port; 114 u_int16_t dcc_port;
115 int i, ret = NF_ACCEPT; 115 int i, ret = NF_ACCEPT;
116 char *addr_beg_p, *addr_end_p; 116 char *addr_beg_p, *addr_end_p;
117 typeof(ip_nat_irc_hook) ip_nat_irc;
117 118
118 DEBUGP("entered\n"); 119 DEBUGP("entered\n");
119 120
@@ -222,11 +223,12 @@ static int help(struct sk_buff **pskb,
222 { .tcp = { htons(0xFFFF) } }, 0xFF }}); 223 { .tcp = { htons(0xFFFF) } }, 0xFF }});
223 exp->expectfn = NULL; 224 exp->expectfn = NULL;
224 exp->flags = 0; 225 exp->flags = 0;
225 if (ip_nat_irc_hook) 226 ip_nat_irc = rcu_dereference(ip_nat_irc_hook);
226 ret = ip_nat_irc_hook(pskb, ctinfo, 227 if (ip_nat_irc)
227 addr_beg_p - ib_ptr, 228 ret = ip_nat_irc(pskb, ctinfo,
228 addr_end_p - addr_beg_p, 229 addr_beg_p - ib_ptr,
229 exp); 230 addr_end_p - addr_beg_p,
231 exp);
230 else if (ip_conntrack_expect_related(exp) != 0) 232 else if (ip_conntrack_expect_related(exp) != 0)
231 ret = NF_DROP; 233 ret = NF_DROP;
232 ip_conntrack_expect_put(exp); 234 ip_conntrack_expect_put(exp);
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 262d0d44ec1b..5fcf91d617cd 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -153,6 +153,7 @@ ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct ip_conntrack *ct)
153 return ret; 153 return ret;
154 154
155nfattr_failure: 155nfattr_failure:
156 ip_conntrack_proto_put(proto);
156 return -1; 157 return -1;
157} 158}
158 159
@@ -319,8 +320,6 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
319 } else if (events & (IPCT_NEW | IPCT_RELATED)) { 320 } else if (events & (IPCT_NEW | IPCT_RELATED)) {
320 type = IPCTNL_MSG_CT_NEW; 321 type = IPCTNL_MSG_CT_NEW;
321 flags = NLM_F_CREATE|NLM_F_EXCL; 322 flags = NLM_F_CREATE|NLM_F_EXCL;
322 /* dump everything */
323 events = ~0UL;
324 group = NFNLGRP_CONNTRACK_NEW; 323 group = NFNLGRP_CONNTRACK_NEW;
325 } else if (events & (IPCT_STATUS | IPCT_PROTOINFO)) { 324 } else if (events & (IPCT_STATUS | IPCT_PROTOINFO)) {
326 type = IPCTNL_MSG_CT_NEW; 325 type = IPCTNL_MSG_CT_NEW;
@@ -355,28 +354,35 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
355 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0) 354 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0)
356 goto nfattr_failure; 355 goto nfattr_failure;
357 NFA_NEST_END(skb, nest_parms); 356 NFA_NEST_END(skb, nest_parms);
358
359 /* NAT stuff is now a status flag */
360 if ((events & IPCT_STATUS || events & IPCT_NATINFO)
361 && ctnetlink_dump_status(skb, ct) < 0)
362 goto nfattr_failure;
363 if (events & IPCT_REFRESH
364 && ctnetlink_dump_timeout(skb, ct) < 0)
365 goto nfattr_failure;
366 if (events & IPCT_PROTOINFO
367 && ctnetlink_dump_protoinfo(skb, ct) < 0)
368 goto nfattr_failure;
369 if (events & IPCT_HELPINFO
370 && ctnetlink_dump_helpinfo(skb, ct) < 0)
371 goto nfattr_failure;
372 357
373 if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || 358 if (events & IPCT_DESTROY) {
374 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0) 359 if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
375 goto nfattr_failure; 360 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0)
361 goto nfattr_failure;
362 } else {
363 if (ctnetlink_dump_status(skb, ct) < 0)
364 goto nfattr_failure;
376 365
377 if (events & IPCT_MARK 366 if (ctnetlink_dump_timeout(skb, ct) < 0)
378 && ctnetlink_dump_mark(skb, ct) < 0) 367 goto nfattr_failure;
379 goto nfattr_failure; 368
369 if (events & IPCT_PROTOINFO
370 && ctnetlink_dump_protoinfo(skb, ct) < 0)
371 goto nfattr_failure;
372
373 if ((events & IPCT_HELPER || ct->helper)
374 && ctnetlink_dump_helpinfo(skb, ct) < 0)
375 goto nfattr_failure;
376
377 if ((events & IPCT_MARK || ct->mark)
378 && ctnetlink_dump_mark(skb, ct) < 0)
379 goto nfattr_failure;
380
381 if (events & IPCT_COUNTER_FILLING &&
382 (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
383 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0))
384 goto nfattr_failure;
385 }
380 386
381 nlh->nlmsg_len = skb->tail - b; 387 nlh->nlmsg_len = skb->tail - b;
382 nfnetlink_send(skb, 0, group, 0); 388 nfnetlink_send(skb, 0, group, 0);
@@ -742,7 +748,6 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
742 ip_conntrack_put(ct); 748 ip_conntrack_put(ct);
743 return -ENOMEM; 749 return -ENOMEM;
744 } 750 }
745 NETLINK_CB(skb2).dst_pid = NETLINK_CB(skb).pid;
746 751
747 err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, 752 err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq,
748 IPCTNL_MSG_CT_NEW, 1, ct); 753 IPCTNL_MSG_CT_NEW, 1, ct);
@@ -945,9 +950,11 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
945 ct->timeout.expires = jiffies + ct->timeout.expires * HZ; 950 ct->timeout.expires = jiffies + ct->timeout.expires * HZ;
946 ct->status |= IPS_CONFIRMED; 951 ct->status |= IPS_CONFIRMED;
947 952
948 err = ctnetlink_change_status(ct, cda); 953 if (cda[CTA_STATUS-1]) {
949 if (err < 0) 954 err = ctnetlink_change_status(ct, cda);
950 goto err; 955 if (err < 0)
956 goto err;
957 }
951 958
952 if (cda[CTA_PROTOINFO-1]) { 959 if (cda[CTA_PROTOINFO-1]) {
953 err = ctnetlink_change_protoinfo(ct, cda); 960 err = ctnetlink_change_protoinfo(ct, cda);
@@ -1256,7 +1263,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1256 if (err < 0) 1263 if (err < 0)
1257 return err; 1264 return err;
1258 1265
1259 exp = ip_conntrack_expect_find(&tuple); 1266 exp = ip_conntrack_expect_find_get(&tuple);
1260 if (!exp) 1267 if (!exp)
1261 return -ENOENT; 1268 return -ENOENT;
1262 1269
@@ -1272,8 +1279,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1272 skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); 1279 skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
1273 if (!skb2) 1280 if (!skb2)
1274 goto out; 1281 goto out;
1275 NETLINK_CB(skb2).dst_pid = NETLINK_CB(skb).pid; 1282
1276
1277 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, 1283 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
1278 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, 1284 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW,
1279 1, exp); 1285 1, exp);
@@ -1310,7 +1316,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
1310 return err; 1316 return err;
1311 1317
1312 /* bump usage count to 2 */ 1318 /* bump usage count to 2 */
1313 exp = ip_conntrack_expect_find(&tuple); 1319 exp = ip_conntrack_expect_find_get(&tuple);
1314 if (!exp) 1320 if (!exp)
1315 return -ENOENT; 1321 return -ENOENT;
1316 1322
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_gre.c b/net/ipv4/netfilter/ip_conntrack_proto_gre.c
index 5fe026f467d3..ac1c49ef36a9 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_gre.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_gre.c
@@ -34,8 +34,6 @@
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35 35
36static DEFINE_RWLOCK(ip_ct_gre_lock); 36static DEFINE_RWLOCK(ip_ct_gre_lock);
37#define ASSERT_READ_LOCK(x)
38#define ASSERT_WRITE_LOCK(x)
39 37
40#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 38#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
41#include <linux/netfilter_ipv4/ip_conntrack_helper.h> 39#include <linux/netfilter_ipv4/ip_conntrack_helper.h>
diff --git a/net/ipv4/netfilter/ip_conntrack_sip.c b/net/ipv4/netfilter/ip_conntrack_sip.c
index f4f75995a9e4..3a26d63eed88 100644
--- a/net/ipv4/netfilter/ip_conntrack_sip.c
+++ b/net/ipv4/netfilter/ip_conntrack_sip.c
@@ -52,20 +52,56 @@ unsigned int (*ip_nat_sdp_hook)(struct sk_buff **pskb,
52 const char *dptr); 52 const char *dptr);
53EXPORT_SYMBOL_GPL(ip_nat_sdp_hook); 53EXPORT_SYMBOL_GPL(ip_nat_sdp_hook);
54 54
55int ct_sip_get_info(const char *dptr, size_t dlen,
56 unsigned int *matchoff,
57 unsigned int *matchlen,
58 struct sip_header_nfo *hnfo);
59EXPORT_SYMBOL_GPL(ct_sip_get_info);
60
61
62static int digits_len(const char *dptr, const char *limit, int *shift); 55static int digits_len(const char *dptr, const char *limit, int *shift);
63static int epaddr_len(const char *dptr, const char *limit, int *shift); 56static int epaddr_len(const char *dptr, const char *limit, int *shift);
64static int skp_digits_len(const char *dptr, const char *limit, int *shift); 57static int skp_digits_len(const char *dptr, const char *limit, int *shift);
65static int skp_epaddr_len(const char *dptr, const char *limit, int *shift); 58static int skp_epaddr_len(const char *dptr, const char *limit, int *shift);
66 59
67struct sip_header_nfo ct_sip_hdrs[] = { 60struct sip_header_nfo {
68 { /* Via header */ 61 const char *lname;
62 const char *sname;
63 const char *ln_str;
64 size_t lnlen;
65 size_t snlen;
66 size_t ln_strlen;
67 int case_sensitive;
68 int (*match_len)(const char *, const char *, int *);
69};
70
71static struct sip_header_nfo ct_sip_hdrs[] = {
72 [POS_REG_REQ_URI] = { /* SIP REGISTER request URI */
73 .lname = "sip:",
74 .lnlen = sizeof("sip:") - 1,
75 .ln_str = ":",
76 .ln_strlen = sizeof(":") - 1,
77 .match_len = epaddr_len
78 },
79 [POS_REQ_URI] = { /* SIP request URI */
80 .lname = "sip:",
81 .lnlen = sizeof("sip:") - 1,
82 .ln_str = "@",
83 .ln_strlen = sizeof("@") - 1,
84 .match_len = epaddr_len
85 },
86 [POS_FROM] = { /* SIP From header */
87 .lname = "From:",
88 .lnlen = sizeof("From:") - 1,
89 .sname = "\r\nf:",
90 .snlen = sizeof("\r\nf:") - 1,
91 .ln_str = "sip:",
92 .ln_strlen = sizeof("sip:") - 1,
93 .match_len = skp_epaddr_len,
94 },
95 [POS_TO] = { /* SIP To header */
96 .lname = "To:",
97 .lnlen = sizeof("To:") - 1,
98 .sname = "\r\nt:",
99 .snlen = sizeof("\r\nt:") - 1,
100 .ln_str = "sip:",
101 .ln_strlen = sizeof("sip:") - 1,
102 .match_len = skp_epaddr_len,
103 },
104 [POS_VIA] = { /* SIP Via header */
69 .lname = "Via:", 105 .lname = "Via:",
70 .lnlen = sizeof("Via:") - 1, 106 .lnlen = sizeof("Via:") - 1,
71 .sname = "\r\nv:", 107 .sname = "\r\nv:",
@@ -74,7 +110,7 @@ struct sip_header_nfo ct_sip_hdrs[] = {
74 .ln_strlen = sizeof("UDP ") - 1, 110 .ln_strlen = sizeof("UDP ") - 1,
75 .match_len = epaddr_len, 111 .match_len = epaddr_len,
76 }, 112 },
77 { /* Contact header */ 113 [POS_CONTACT] = { /* SIP Contact header */
78 .lname = "Contact:", 114 .lname = "Contact:",
79 .lnlen = sizeof("Contact:") - 1, 115 .lnlen = sizeof("Contact:") - 1,
80 .sname = "\r\nm:", 116 .sname = "\r\nm:",
@@ -83,7 +119,7 @@ struct sip_header_nfo ct_sip_hdrs[] = {
83 .ln_strlen = sizeof("sip:") - 1, 119 .ln_strlen = sizeof("sip:") - 1,
84 .match_len = skp_epaddr_len 120 .match_len = skp_epaddr_len
85 }, 121 },
86 { /* Content length header */ 122 [POS_CONTENT] = { /* SIP Content length header */
87 .lname = "Content-Length:", 123 .lname = "Content-Length:",
88 .lnlen = sizeof("Content-Length:") - 1, 124 .lnlen = sizeof("Content-Length:") - 1,
89 .sname = "\r\nl:", 125 .sname = "\r\nl:",
@@ -92,7 +128,8 @@ struct sip_header_nfo ct_sip_hdrs[] = {
92 .ln_strlen = sizeof(":") - 1, 128 .ln_strlen = sizeof(":") - 1,
93 .match_len = skp_digits_len 129 .match_len = skp_digits_len
94 }, 130 },
95 { /* SDP media info */ 131 [POS_MEDIA] = { /* SDP media info */
132 .case_sensitive = 1,
96 .lname = "\nm=", 133 .lname = "\nm=",
97 .lnlen = sizeof("\nm=") - 1, 134 .lnlen = sizeof("\nm=") - 1,
98 .sname = "\rm=", 135 .sname = "\rm=",
@@ -101,7 +138,8 @@ struct sip_header_nfo ct_sip_hdrs[] = {
101 .ln_strlen = sizeof("audio ") - 1, 138 .ln_strlen = sizeof("audio ") - 1,
102 .match_len = digits_len 139 .match_len = digits_len
103 }, 140 },
104 { /* SDP owner address*/ 141 [POS_OWNER] = { /* SDP owner address*/
142 .case_sensitive = 1,
105 .lname = "\no=", 143 .lname = "\no=",
106 .lnlen = sizeof("\no=") - 1, 144 .lnlen = sizeof("\no=") - 1,
107 .sname = "\ro=", 145 .sname = "\ro=",
@@ -110,7 +148,8 @@ struct sip_header_nfo ct_sip_hdrs[] = {
110 .ln_strlen = sizeof("IN IP4 ") - 1, 148 .ln_strlen = sizeof("IN IP4 ") - 1,
111 .match_len = epaddr_len 149 .match_len = epaddr_len
112 }, 150 },
113 { /* SDP connection info */ 151 [POS_CONNECTION] = { /* SDP connection info */
152 .case_sensitive = 1,
114 .lname = "\nc=", 153 .lname = "\nc=",
115 .lnlen = sizeof("\nc=") - 1, 154 .lnlen = sizeof("\nc=") - 1,
116 .sname = "\rc=", 155 .sname = "\rc=",
@@ -119,16 +158,8 @@ struct sip_header_nfo ct_sip_hdrs[] = {
119 .ln_strlen = sizeof("IN IP4 ") - 1, 158 .ln_strlen = sizeof("IN IP4 ") - 1,
120 .match_len = epaddr_len 159 .match_len = epaddr_len
121 }, 160 },
122 { /* Requests headers */ 161 [POS_SDP_HEADER] = { /* SDP version header */
123 .lname = "sip:", 162 .case_sensitive = 1,
124 .lnlen = sizeof("sip:") - 1,
125 .sname = "sip:",
126 .snlen = sizeof("sip:") - 1, /* yes, i know.. ;) */
127 .ln_str = "@",
128 .ln_strlen = sizeof("@") - 1,
129 .match_len = epaddr_len
130 },
131 { /* SDP version header */
132 .lname = "\nv=", 163 .lname = "\nv=",
133 .lnlen = sizeof("\nv=") - 1, 164 .lnlen = sizeof("\nv=") - 1,
134 .sname = "\rv=", 165 .sname = "\rv=",
@@ -138,7 +169,6 @@ struct sip_header_nfo ct_sip_hdrs[] = {
138 .match_len = digits_len 169 .match_len = digits_len
139 } 170 }
140}; 171};
141EXPORT_SYMBOL_GPL(ct_sip_hdrs);
142 172
143/* get line lenght until first CR or LF seen. */ 173/* get line lenght until first CR or LF seen. */
144int ct_sip_lnlen(const char *line, const char *limit) 174int ct_sip_lnlen(const char *line, const char *limit)
@@ -159,13 +189,19 @@ EXPORT_SYMBOL_GPL(ct_sip_lnlen);
159 189
160/* Linear string search, case sensitive. */ 190/* Linear string search, case sensitive. */
161const char *ct_sip_search(const char *needle, const char *haystack, 191const char *ct_sip_search(const char *needle, const char *haystack,
162 size_t needle_len, size_t haystack_len) 192 size_t needle_len, size_t haystack_len,
193 int case_sensitive)
163{ 194{
164 const char *limit = haystack + (haystack_len - needle_len); 195 const char *limit = haystack + (haystack_len - needle_len);
165 196
166 while (haystack <= limit) { 197 while (haystack <= limit) {
167 if (memcmp(haystack, needle, needle_len) == 0) 198 if (case_sensitive) {
168 return haystack; 199 if (strncmp(haystack, needle, needle_len) == 0)
200 return haystack;
201 } else {
202 if (strnicmp(haystack, needle, needle_len) == 0)
203 return haystack;
204 }
169 haystack++; 205 haystack++;
170 } 206 }
171 return NULL; 207 return NULL;
@@ -263,8 +299,9 @@ static int skp_epaddr_len(const char *dptr, const char *limit, int *shift)
263int ct_sip_get_info(const char *dptr, size_t dlen, 299int ct_sip_get_info(const char *dptr, size_t dlen,
264 unsigned int *matchoff, 300 unsigned int *matchoff,
265 unsigned int *matchlen, 301 unsigned int *matchlen,
266 struct sip_header_nfo *hnfo) 302 enum sip_header_pos pos)
267{ 303{
304 struct sip_header_nfo *hnfo = &ct_sip_hdrs[pos];
268 const char *limit, *aux, *k = dptr; 305 const char *limit, *aux, *k = dptr;
269 int shift = 0; 306 int shift = 0;
270 307
@@ -272,12 +309,14 @@ int ct_sip_get_info(const char *dptr, size_t dlen,
272 309
273 while (dptr <= limit) { 310 while (dptr <= limit) {
274 if ((strncmp(dptr, hnfo->lname, hnfo->lnlen) != 0) && 311 if ((strncmp(dptr, hnfo->lname, hnfo->lnlen) != 0) &&
275 (strncmp(dptr, hnfo->sname, hnfo->snlen) != 0)) { 312 (hnfo->sname == NULL ||
313 strncmp(dptr, hnfo->sname, hnfo->snlen) != 0)) {
276 dptr++; 314 dptr++;
277 continue; 315 continue;
278 } 316 }
279 aux = ct_sip_search(hnfo->ln_str, dptr, hnfo->ln_strlen, 317 aux = ct_sip_search(hnfo->ln_str, dptr, hnfo->ln_strlen,
280 ct_sip_lnlen(dptr, limit)); 318 ct_sip_lnlen(dptr, limit),
319 hnfo->case_sensitive);
281 if (!aux) { 320 if (!aux) {
282 DEBUGP("'%s' not found in '%s'.\n", hnfo->ln_str, 321 DEBUGP("'%s' not found in '%s'.\n", hnfo->ln_str,
283 hnfo->lname); 322 hnfo->lname);
@@ -298,6 +337,7 @@ int ct_sip_get_info(const char *dptr, size_t dlen,
298 DEBUGP("%s header not found.\n", hnfo->lname); 337 DEBUGP("%s header not found.\n", hnfo->lname);
299 return 0; 338 return 0;
300} 339}
340EXPORT_SYMBOL_GPL(ct_sip_get_info);
301 341
302static int set_expected_rtp(struct sk_buff **pskb, 342static int set_expected_rtp(struct sk_buff **pskb,
303 struct ip_conntrack *ct, 343 struct ip_conntrack *ct,
@@ -308,6 +348,7 @@ static int set_expected_rtp(struct sk_buff **pskb,
308 struct ip_conntrack_expect *exp; 348 struct ip_conntrack_expect *exp;
309 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); 349 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
310 int ret; 350 int ret;
351 typeof(ip_nat_sdp_hook) ip_nat_sdp;
311 352
312 exp = ip_conntrack_expect_alloc(ct); 353 exp = ip_conntrack_expect_alloc(ct);
313 if (exp == NULL) 354 if (exp == NULL)
@@ -328,8 +369,9 @@ static int set_expected_rtp(struct sk_buff **pskb,
328 exp->expectfn = NULL; 369 exp->expectfn = NULL;
329 exp->flags = 0; 370 exp->flags = 0;
330 371
331 if (ip_nat_sdp_hook) 372 ip_nat_sdp = rcu_dereference(ip_nat_sdp_hook);
332 ret = ip_nat_sdp_hook(pskb, ctinfo, exp, dptr); 373 if (ip_nat_sdp)
374 ret = ip_nat_sdp(pskb, ctinfo, exp, dptr);
333 else { 375 else {
334 if (ip_conntrack_expect_related(exp) != 0) 376 if (ip_conntrack_expect_related(exp) != 0)
335 ret = NF_DROP; 377 ret = NF_DROP;
@@ -351,6 +393,7 @@ static int sip_help(struct sk_buff **pskb,
351 int matchoff, matchlen; 393 int matchoff, matchlen;
352 __be32 ipaddr; 394 __be32 ipaddr;
353 u_int16_t port; 395 u_int16_t port;
396 typeof(ip_nat_sip_hook) ip_nat_sip;
354 397
355 /* No Data ? */ 398 /* No Data ? */
356 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr); 399 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
@@ -368,8 +411,9 @@ static int sip_help(struct sk_buff **pskb,
368 goto out; 411 goto out;
369 } 412 }
370 413
371 if (ip_nat_sip_hook) { 414 ip_nat_sip = rcu_dereference(ip_nat_sip_hook);
372 if (!ip_nat_sip_hook(pskb, ctinfo, ct, &dptr)) { 415 if (ip_nat_sip) {
416 if (!ip_nat_sip(pskb, ctinfo, ct, &dptr)) {
373 ret = NF_DROP; 417 ret = NF_DROP;
374 goto out; 418 goto out;
375 } 419 }
@@ -389,7 +433,7 @@ static int sip_help(struct sk_buff **pskb,
389 } 433 }
390 /* Get ip and port address from SDP packet. */ 434 /* Get ip and port address from SDP packet. */
391 if (ct_sip_get_info(dptr, datalen, &matchoff, &matchlen, 435 if (ct_sip_get_info(dptr, datalen, &matchoff, &matchlen,
392 &ct_sip_hdrs[POS_CONNECTION]) > 0) { 436 POS_CONNECTION) > 0) {
393 437
394 /* We'll drop only if there are parse problems. */ 438 /* We'll drop only if there are parse problems. */
395 if (parse_ipaddr(dptr + matchoff, NULL, &ipaddr, 439 if (parse_ipaddr(dptr + matchoff, NULL, &ipaddr,
@@ -398,7 +442,7 @@ static int sip_help(struct sk_buff **pskb,
398 goto out; 442 goto out;
399 } 443 }
400 if (ct_sip_get_info(dptr, datalen, &matchoff, &matchlen, 444 if (ct_sip_get_info(dptr, datalen, &matchoff, &matchlen,
401 &ct_sip_hdrs[POS_MEDIA]) > 0) { 445 POS_MEDIA) > 0) {
402 446
403 port = simple_strtoul(dptr + matchoff, NULL, 10); 447 port = simple_strtoul(dptr + matchoff, NULL, 10);
404 if (port < 1024) { 448 if (port < 1024) {
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
index 02135756562e..86efb5449676 100644
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c
@@ -28,9 +28,6 @@
28#include <net/ip.h> 28#include <net/ip.h>
29#include <net/route.h> 29#include <net/route.h>
30 30
31#define ASSERT_READ_LOCK(x)
32#define ASSERT_WRITE_LOCK(x)
33
34#include <linux/netfilter_ipv4/ip_conntrack.h> 31#include <linux/netfilter_ipv4/ip_conntrack.h>
35#include <linux/netfilter_ipv4/ip_conntrack_protocol.h> 32#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
36#include <linux/netfilter_ipv4/ip_conntrack_core.h> 33#include <linux/netfilter_ipv4/ip_conntrack_core.h>
@@ -139,7 +136,6 @@ static int ct_seq_show(struct seq_file *s, void *v)
139 const struct ip_conntrack *conntrack = tuplehash_to_ctrack(hash); 136 const struct ip_conntrack *conntrack = tuplehash_to_ctrack(hash);
140 struct ip_conntrack_protocol *proto; 137 struct ip_conntrack_protocol *proto;
141 138
142 ASSERT_READ_LOCK(&ip_conntrack_lock);
143 IP_NF_ASSERT(conntrack); 139 IP_NF_ASSERT(conntrack);
144 140
145 /* we only want to print DIR_ORIGINAL */ 141 /* we only want to print DIR_ORIGINAL */
@@ -926,7 +922,7 @@ EXPORT_SYMBOL(__ip_ct_refresh_acct);
926EXPORT_SYMBOL(ip_conntrack_expect_alloc); 922EXPORT_SYMBOL(ip_conntrack_expect_alloc);
927EXPORT_SYMBOL(ip_conntrack_expect_put); 923EXPORT_SYMBOL(ip_conntrack_expect_put);
928EXPORT_SYMBOL_GPL(__ip_conntrack_expect_find); 924EXPORT_SYMBOL_GPL(__ip_conntrack_expect_find);
929EXPORT_SYMBOL_GPL(ip_conntrack_expect_find); 925EXPORT_SYMBOL_GPL(ip_conntrack_expect_find_get);
930EXPORT_SYMBOL(ip_conntrack_expect_related); 926EXPORT_SYMBOL(ip_conntrack_expect_related);
931EXPORT_SYMBOL(ip_conntrack_unexpect_related); 927EXPORT_SYMBOL(ip_conntrack_unexpect_related);
932EXPORT_SYMBOL_GPL(ip_conntrack_expect_list); 928EXPORT_SYMBOL_GPL(ip_conntrack_expect_list);
diff --git a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
index fe0b634dd377..ef56de2eff0c 100644
--- a/net/ipv4/netfilter/ip_conntrack_tftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_tftp.c
@@ -50,6 +50,7 @@ static int tftp_help(struct sk_buff **pskb,
50 struct tftphdr _tftph, *tfh; 50 struct tftphdr _tftph, *tfh;
51 struct ip_conntrack_expect *exp; 51 struct ip_conntrack_expect *exp;
52 unsigned int ret = NF_ACCEPT; 52 unsigned int ret = NF_ACCEPT;
53 typeof(ip_nat_tftp_hook) ip_nat_tftp;
53 54
54 tfh = skb_header_pointer(*pskb, 55 tfh = skb_header_pointer(*pskb,
55 (*pskb)->nh.iph->ihl*4+sizeof(struct udphdr), 56 (*pskb)->nh.iph->ihl*4+sizeof(struct udphdr),
@@ -81,8 +82,9 @@ static int tftp_help(struct sk_buff **pskb,
81 DEBUGP("expect: "); 82 DEBUGP("expect: ");
82 DUMP_TUPLE(&exp->tuple); 83 DUMP_TUPLE(&exp->tuple);
83 DUMP_TUPLE(&exp->mask); 84 DUMP_TUPLE(&exp->mask);
84 if (ip_nat_tftp_hook) 85 ip_nat_tftp = rcu_dereference(ip_nat_tftp_hook);
85 ret = ip_nat_tftp_hook(pskb, ctinfo, exp); 86 if (ip_nat_tftp)
87 ret = ip_nat_tftp(pskb, ctinfo, exp);
86 else if (ip_conntrack_expect_related(exp) != 0) 88 else if (ip_conntrack_expect_related(exp) != 0)
87 ret = NF_DROP; 89 ret = NF_DROP;
88 ip_conntrack_expect_put(exp); 90 ip_conntrack_expect_put(exp);
diff --git a/net/ipv4/netfilter/ip_nat_amanda.c b/net/ipv4/netfilter/ip_nat_amanda.c
index 3a888715bbf3..85df1a9aed33 100644
--- a/net/ipv4/netfilter/ip_nat_amanda.c
+++ b/net/ipv4/netfilter/ip_nat_amanda.c
@@ -70,15 +70,14 @@ static unsigned int help(struct sk_buff **pskb,
70 70
71static void __exit ip_nat_amanda_fini(void) 71static void __exit ip_nat_amanda_fini(void)
72{ 72{
73 ip_nat_amanda_hook = NULL; 73 rcu_assign_pointer(ip_nat_amanda_hook, NULL);
74 /* Make sure noone calls it, meanwhile. */ 74 synchronize_rcu();
75 synchronize_net();
76} 75}
77 76
78static int __init ip_nat_amanda_init(void) 77static int __init ip_nat_amanda_init(void)
79{ 78{
80 BUG_ON(ip_nat_amanda_hook); 79 BUG_ON(rcu_dereference(ip_nat_amanda_hook));
81 ip_nat_amanda_hook = help; 80 rcu_assign_pointer(ip_nat_amanda_hook, help);
82 return 0; 81 return 0;
83} 82}
84 83
diff --git a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
index 4b6260a97408..9d1a5175dcd4 100644
--- a/net/ipv4/netfilter/ip_nat_core.c
+++ b/net/ipv4/netfilter/ip_nat_core.c
@@ -362,12 +362,10 @@ manip_pkt(u_int16_t proto,
362 iph = (void *)(*pskb)->data + iphdroff; 362 iph = (void *)(*pskb)->data + iphdroff;
363 363
364 if (maniptype == IP_NAT_MANIP_SRC) { 364 if (maniptype == IP_NAT_MANIP_SRC) {
365 iph->check = nf_csum_update(~iph->saddr, target->src.ip, 365 nf_csum_replace4(&iph->check, iph->saddr, target->src.ip);
366 iph->check);
367 iph->saddr = target->src.ip; 366 iph->saddr = target->src.ip;
368 } else { 367 } else {
369 iph->check = nf_csum_update(~iph->daddr, target->dst.ip, 368 nf_csum_replace4(&iph->check, iph->daddr, target->dst.ip);
370 iph->check);
371 iph->daddr = target->dst.ip; 369 iph->daddr = target->dst.ip;
372 } 370 }
373 return 1; 371 return 1;
diff --git a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c
index a71c233d8112..913960e1380f 100644
--- a/net/ipv4/netfilter/ip_nat_ftp.c
+++ b/net/ipv4/netfilter/ip_nat_ftp.c
@@ -156,15 +156,14 @@ static unsigned int ip_nat_ftp(struct sk_buff **pskb,
156 156
157static void __exit ip_nat_ftp_fini(void) 157static void __exit ip_nat_ftp_fini(void)
158{ 158{
159 ip_nat_ftp_hook = NULL; 159 rcu_assign_pointer(ip_nat_ftp_hook, NULL);
160 /* Make sure noone calls it, meanwhile. */ 160 synchronize_rcu();
161 synchronize_net();
162} 161}
163 162
164static int __init ip_nat_ftp_init(void) 163static int __init ip_nat_ftp_init(void)
165{ 164{
166 BUG_ON(ip_nat_ftp_hook); 165 BUG_ON(rcu_dereference(ip_nat_ftp_hook));
167 ip_nat_ftp_hook = ip_nat_ftp; 166 rcu_assign_pointer(ip_nat_ftp_hook, ip_nat_ftp);
168 return 0; 167 return 0;
169} 168}
170 169
diff --git a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c
index 3bf858480558..ee80feb4b2a9 100644
--- a/net/ipv4/netfilter/ip_nat_helper.c
+++ b/net/ipv4/netfilter/ip_nat_helper.c
@@ -188,10 +188,8 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb,
188 csum_partial((char *)tcph, 188 csum_partial((char *)tcph,
189 datalen, 0)); 189 datalen, 0));
190 } else 190 } else
191 tcph->check = nf_proto_csum_update(*pskb, 191 nf_proto_csum_replace2(&tcph->check, *pskb,
192 htons(oldlen) ^ htons(0xFFFF), 192 htons(oldlen), htons(datalen), 1);
193 htons(datalen),
194 tcph->check, 1);
195 193
196 if (rep_len != match_len) { 194 if (rep_len != match_len) {
197 set_bit(IPS_SEQ_ADJUST_BIT, &ct->status); 195 set_bit(IPS_SEQ_ADJUST_BIT, &ct->status);
@@ -264,12 +262,10 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb,
264 csum_partial((char *)udph, 262 csum_partial((char *)udph,
265 datalen, 0)); 263 datalen, 0));
266 if (!udph->check) 264 if (!udph->check)
267 udph->check = -1; 265 udph->check = CSUM_MANGLED_0;
268 } else 266 } else
269 udph->check = nf_proto_csum_update(*pskb, 267 nf_proto_csum_replace2(&udph->check, *pskb,
270 htons(oldlen) ^ htons(0xFFFF), 268 htons(oldlen), htons(datalen), 1);
271 htons(datalen),
272 udph->check, 1);
273 return 1; 269 return 1;
274} 270}
275EXPORT_SYMBOL(ip_nat_mangle_udp_packet); 271EXPORT_SYMBOL(ip_nat_mangle_udp_packet);
@@ -307,14 +303,10 @@ sack_adjust(struct sk_buff *skb,
307 ntohl(sack->start_seq), new_start_seq, 303 ntohl(sack->start_seq), new_start_seq,
308 ntohl(sack->end_seq), new_end_seq); 304 ntohl(sack->end_seq), new_end_seq);
309 305
310 tcph->check = nf_proto_csum_update(skb, 306 nf_proto_csum_replace4(&tcph->check, skb,
311 ~sack->start_seq, 307 sack->start_seq, new_start_seq, 0);
312 new_start_seq, 308 nf_proto_csum_replace4(&tcph->check, skb,
313 tcph->check, 0); 309 sack->end_seq, new_end_seq, 0);
314 tcph->check = nf_proto_csum_update(skb,
315 ~sack->end_seq,
316 new_end_seq,
317 tcph->check, 0);
318 sack->start_seq = new_start_seq; 310 sack->start_seq = new_start_seq;
319 sack->end_seq = new_end_seq; 311 sack->end_seq = new_end_seq;
320 sackoff += sizeof(*sack); 312 sackoff += sizeof(*sack);
@@ -397,10 +389,8 @@ ip_nat_seq_adjust(struct sk_buff **pskb,
397 else 389 else
398 newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_before); 390 newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_before);
399 391
400 tcph->check = nf_proto_csum_update(*pskb, ~tcph->seq, newseq, 392 nf_proto_csum_replace4(&tcph->check, *pskb, tcph->seq, newseq, 0);
401 tcph->check, 0); 393 nf_proto_csum_replace4(&tcph->check, *pskb, tcph->ack_seq, newack, 0);
402 tcph->check = nf_proto_csum_update(*pskb, ~tcph->ack_seq, newack,
403 tcph->check, 0);
404 394
405 DEBUGP("Adjusting sequence number from %u->%u, ack from %u->%u\n", 395 DEBUGP("Adjusting sequence number from %u->%u, ack from %u->%u\n",
406 ntohl(tcph->seq), ntohl(newseq), ntohl(tcph->ack_seq), 396 ntohl(tcph->seq), ntohl(newseq), ntohl(tcph->ack_seq),
diff --git a/net/ipv4/netfilter/ip_nat_helper_h323.c b/net/ipv4/netfilter/ip_nat_helper_h323.c
index 4a7d34466ee2..bdc99ef6159e 100644
--- a/net/ipv4/netfilter/ip_nat_helper_h323.c
+++ b/net/ipv4/netfilter/ip_nat_helper_h323.c
@@ -563,25 +563,25 @@ static int nat_callforwarding(struct sk_buff **pskb, struct ip_conntrack *ct,
563/****************************************************************************/ 563/****************************************************************************/
564static int __init init(void) 564static int __init init(void)
565{ 565{
566 BUG_ON(set_h245_addr_hook != NULL); 566 BUG_ON(rcu_dereference(set_h245_addr_hook) != NULL);
567 BUG_ON(set_h225_addr_hook != NULL); 567 BUG_ON(rcu_dereference(set_h225_addr_hook) != NULL);
568 BUG_ON(set_sig_addr_hook != NULL); 568 BUG_ON(rcu_dereference(set_sig_addr_hook) != NULL);
569 BUG_ON(set_ras_addr_hook != NULL); 569 BUG_ON(rcu_dereference(set_ras_addr_hook) != NULL);
570 BUG_ON(nat_rtp_rtcp_hook != NULL); 570 BUG_ON(rcu_dereference(nat_rtp_rtcp_hook) != NULL);
571 BUG_ON(nat_t120_hook != NULL); 571 BUG_ON(rcu_dereference(nat_t120_hook) != NULL);
572 BUG_ON(nat_h245_hook != NULL); 572 BUG_ON(rcu_dereference(nat_h245_hook) != NULL);
573 BUG_ON(nat_callforwarding_hook != NULL); 573 BUG_ON(rcu_dereference(nat_callforwarding_hook) != NULL);
574 BUG_ON(nat_q931_hook != NULL); 574 BUG_ON(rcu_dereference(nat_q931_hook) != NULL);
575 575
576 set_h245_addr_hook = set_h245_addr; 576 rcu_assign_pointer(set_h245_addr_hook, set_h245_addr);
577 set_h225_addr_hook = set_h225_addr; 577 rcu_assign_pointer(set_h225_addr_hook, set_h225_addr);
578 set_sig_addr_hook = set_sig_addr; 578 rcu_assign_pointer(set_sig_addr_hook, set_sig_addr);
579 set_ras_addr_hook = set_ras_addr; 579 rcu_assign_pointer(set_ras_addr_hook, set_ras_addr);
580 nat_rtp_rtcp_hook = nat_rtp_rtcp; 580 rcu_assign_pointer(nat_rtp_rtcp_hook, nat_rtp_rtcp);
581 nat_t120_hook = nat_t120; 581 rcu_assign_pointer(nat_t120_hook, nat_t120);
582 nat_h245_hook = nat_h245; 582 rcu_assign_pointer(nat_h245_hook, nat_h245);
583 nat_callforwarding_hook = nat_callforwarding; 583 rcu_assign_pointer(nat_callforwarding_hook, nat_callforwarding);
584 nat_q931_hook = nat_q931; 584 rcu_assign_pointer(nat_q931_hook, nat_q931);
585 585
586 DEBUGP("ip_nat_h323: init success\n"); 586 DEBUGP("ip_nat_h323: init success\n");
587 return 0; 587 return 0;
@@ -590,16 +590,16 @@ static int __init init(void)
590/****************************************************************************/ 590/****************************************************************************/
591static void __exit fini(void) 591static void __exit fini(void)
592{ 592{
593 set_h245_addr_hook = NULL; 593 rcu_assign_pointer(set_h245_addr_hook, NULL);
594 set_h225_addr_hook = NULL; 594 rcu_assign_pointer(set_h225_addr_hook, NULL);
595 set_sig_addr_hook = NULL; 595 rcu_assign_pointer(set_sig_addr_hook, NULL);
596 set_ras_addr_hook = NULL; 596 rcu_assign_pointer(set_ras_addr_hook, NULL);
597 nat_rtp_rtcp_hook = NULL; 597 rcu_assign_pointer(nat_rtp_rtcp_hook, NULL);
598 nat_t120_hook = NULL; 598 rcu_assign_pointer(nat_t120_hook, NULL);
599 nat_h245_hook = NULL; 599 rcu_assign_pointer(nat_h245_hook, NULL);
600 nat_callforwarding_hook = NULL; 600 rcu_assign_pointer(nat_callforwarding_hook, NULL);
601 nat_q931_hook = NULL; 601 rcu_assign_pointer(nat_q931_hook, NULL);
602 synchronize_net(); 602 synchronize_rcu();
603} 603}
604 604
605/****************************************************************************/ 605/****************************************************************************/
diff --git a/net/ipv4/netfilter/ip_nat_helper_pptp.c b/net/ipv4/netfilter/ip_nat_helper_pptp.c
index 329fdcd7d702..ec957bbb5366 100644
--- a/net/ipv4/netfilter/ip_nat_helper_pptp.c
+++ b/net/ipv4/netfilter/ip_nat_helper_pptp.c
@@ -101,7 +101,7 @@ static void pptp_nat_expected(struct ip_conntrack *ct,
101 101
102 DEBUGP("trying to unexpect other dir: "); 102 DEBUGP("trying to unexpect other dir: ");
103 DUMP_TUPLE(&t); 103 DUMP_TUPLE(&t);
104 other_exp = ip_conntrack_expect_find(&t); 104 other_exp = ip_conntrack_expect_find_get(&t);
105 if (other_exp) { 105 if (other_exp) {
106 ip_conntrack_unexpect_related(other_exp); 106 ip_conntrack_unexpect_related(other_exp);
107 ip_conntrack_expect_put(other_exp); 107 ip_conntrack_expect_put(other_exp);
@@ -315,17 +315,17 @@ static int __init ip_nat_helper_pptp_init(void)
315 if (ret < 0) 315 if (ret < 0)
316 return ret; 316 return ret;
317 317
318 BUG_ON(ip_nat_pptp_hook_outbound); 318 BUG_ON(rcu_dereference(ip_nat_pptp_hook_outbound));
319 ip_nat_pptp_hook_outbound = &pptp_outbound_pkt; 319 rcu_assign_pointer(ip_nat_pptp_hook_outbound, pptp_outbound_pkt);
320 320
321 BUG_ON(ip_nat_pptp_hook_inbound); 321 BUG_ON(rcu_dereference(ip_nat_pptp_hook_inbound));
322 ip_nat_pptp_hook_inbound = &pptp_inbound_pkt; 322 rcu_assign_pointer(ip_nat_pptp_hook_inbound, pptp_inbound_pkt);
323 323
324 BUG_ON(ip_nat_pptp_hook_exp_gre); 324 BUG_ON(rcu_dereference(ip_nat_pptp_hook_exp_gre));
325 ip_nat_pptp_hook_exp_gre = &pptp_exp_gre; 325 rcu_assign_pointer(ip_nat_pptp_hook_exp_gre, pptp_exp_gre);
326 326
327 BUG_ON(ip_nat_pptp_hook_expectfn); 327 BUG_ON(rcu_dereference(ip_nat_pptp_hook_expectfn));
328 ip_nat_pptp_hook_expectfn = &pptp_nat_expected; 328 rcu_assign_pointer(ip_nat_pptp_hook_expectfn, pptp_nat_expected);
329 329
330 printk("ip_nat_pptp version %s loaded\n", IP_NAT_PPTP_VERSION); 330 printk("ip_nat_pptp version %s loaded\n", IP_NAT_PPTP_VERSION);
331 return 0; 331 return 0;
@@ -335,14 +335,13 @@ static void __exit ip_nat_helper_pptp_fini(void)
335{ 335{
336 DEBUGP("cleanup_module\n" ); 336 DEBUGP("cleanup_module\n" );
337 337
338 ip_nat_pptp_hook_expectfn = NULL; 338 rcu_assign_pointer(ip_nat_pptp_hook_expectfn, NULL);
339 ip_nat_pptp_hook_exp_gre = NULL; 339 rcu_assign_pointer(ip_nat_pptp_hook_exp_gre, NULL);
340 ip_nat_pptp_hook_inbound = NULL; 340 rcu_assign_pointer(ip_nat_pptp_hook_inbound, NULL);
341 ip_nat_pptp_hook_outbound = NULL; 341 rcu_assign_pointer(ip_nat_pptp_hook_outbound, NULL);
342 synchronize_rcu();
342 343
343 ip_nat_proto_gre_fini(); 344 ip_nat_proto_gre_fini();
344 /* Make sure noone calls it, meanwhile */
345 synchronize_net();
346 345
347 printk("ip_nat_pptp version %s unloaded\n", IP_NAT_PPTP_VERSION); 346 printk("ip_nat_pptp version %s unloaded\n", IP_NAT_PPTP_VERSION);
348} 347}
diff --git a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc.c
index a767123e082c..feb26b48f1d5 100644
--- a/net/ipv4/netfilter/ip_nat_irc.c
+++ b/net/ipv4/netfilter/ip_nat_irc.c
@@ -98,15 +98,14 @@ static unsigned int help(struct sk_buff **pskb,
98 98
99static void __exit ip_nat_irc_fini(void) 99static void __exit ip_nat_irc_fini(void)
100{ 100{
101 ip_nat_irc_hook = NULL; 101 rcu_assign_pointer(ip_nat_irc_hook, NULL);
102 /* Make sure noone calls it, meanwhile. */ 102 synchronize_rcu();
103 synchronize_net();
104} 103}
105 104
106static int __init ip_nat_irc_init(void) 105static int __init ip_nat_irc_init(void)
107{ 106{
108 BUG_ON(ip_nat_irc_hook); 107 BUG_ON(rcu_dereference(ip_nat_irc_hook));
109 ip_nat_irc_hook = help; 108 rcu_assign_pointer(ip_nat_irc_hook, help);
110 return 0; 109 return 0;
111} 110}
112 111
diff --git a/net/ipv4/netfilter/ip_nat_proto_gre.c b/net/ipv4/netfilter/ip_nat_proto_gre.c
index bf91f9312b3c..95810202d849 100644
--- a/net/ipv4/netfilter/ip_nat_proto_gre.c
+++ b/net/ipv4/netfilter/ip_nat_proto_gre.c
@@ -129,11 +129,9 @@ gre_manip_pkt(struct sk_buff **pskb,
129 } 129 }
130 if (greh->csum) { 130 if (greh->csum) {
131 /* FIXME: Never tested this code... */ 131 /* FIXME: Never tested this code... */
132 *(gre_csum(greh)) = 132 nf_proto_csum_replace4(gre_csum(greh), *pskb,
133 nf_proto_csum_update(*pskb, 133 *(gre_key(greh)),
134 ~*(gre_key(greh)), 134 tuple->dst.u.gre.key, 0);
135 tuple->dst.u.gre.key,
136 *(gre_csum(greh)), 0);
137 } 135 }
138 *(gre_key(greh)) = tuple->dst.u.gre.key; 136 *(gre_key(greh)) = tuple->dst.u.gre.key;
139 break; 137 break;
diff --git a/net/ipv4/netfilter/ip_nat_proto_icmp.c b/net/ipv4/netfilter/ip_nat_proto_icmp.c
index 3f6efc13ac74..fb716edd5bc6 100644
--- a/net/ipv4/netfilter/ip_nat_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_icmp.c
@@ -24,8 +24,8 @@ icmp_in_range(const struct ip_conntrack_tuple *tuple,
24 const union ip_conntrack_manip_proto *min, 24 const union ip_conntrack_manip_proto *min,
25 const union ip_conntrack_manip_proto *max) 25 const union ip_conntrack_manip_proto *max)
26{ 26{
27 return (tuple->src.u.icmp.id >= min->icmp.id 27 return ntohs(tuple->src.u.icmp.id) >= ntohs(min->icmp.id) &&
28 && tuple->src.u.icmp.id <= max->icmp.id); 28 ntohs(tuple->src.u.icmp.id) <= ntohs(max->icmp.id);
29} 29}
30 30
31static int 31static int
@@ -66,10 +66,8 @@ icmp_manip_pkt(struct sk_buff **pskb,
66 return 0; 66 return 0;
67 67
68 hdr = (struct icmphdr *)((*pskb)->data + hdroff); 68 hdr = (struct icmphdr *)((*pskb)->data + hdroff);
69 hdr->checksum = nf_proto_csum_update(*pskb, 69 nf_proto_csum_replace2(&hdr->checksum, *pskb,
70 hdr->un.echo.id ^ htons(0xFFFF), 70 hdr->un.echo.id, tuple->src.u.icmp.id, 0);
71 tuple->src.u.icmp.id,
72 hdr->checksum, 0);
73 hdr->un.echo.id = tuple->src.u.icmp.id; 71 hdr->un.echo.id = tuple->src.u.icmp.id;
74 return 1; 72 return 1;
75} 73}
diff --git a/net/ipv4/netfilter/ip_nat_proto_tcp.c b/net/ipv4/netfilter/ip_nat_proto_tcp.c
index 12deb13b93b1..b586d18b3fb3 100644
--- a/net/ipv4/netfilter/ip_nat_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_tcp.c
@@ -129,9 +129,8 @@ tcp_manip_pkt(struct sk_buff **pskb,
129 if (hdrsize < sizeof(*hdr)) 129 if (hdrsize < sizeof(*hdr))
130 return 1; 130 return 1;
131 131
132 hdr->check = nf_proto_csum_update(*pskb, ~oldip, newip, hdr->check, 1); 132 nf_proto_csum_replace4(&hdr->check, *pskb, oldip, newip, 1);
133 hdr->check = nf_proto_csum_update(*pskb, oldport ^ htons(0xFFFF), newport, 133 nf_proto_csum_replace2(&hdr->check, *pskb, oldport, newport, 0);
134 hdr->check, 0);
135 return 1; 134 return 1;
136} 135}
137 136
diff --git a/net/ipv4/netfilter/ip_nat_proto_udp.c b/net/ipv4/netfilter/ip_nat_proto_udp.c
index 4bbec7730d18..5ced0877b32f 100644
--- a/net/ipv4/netfilter/ip_nat_proto_udp.c
+++ b/net/ipv4/netfilter/ip_nat_proto_udp.c
@@ -115,13 +115,10 @@ udp_manip_pkt(struct sk_buff **pskb,
115 } 115 }
116 116
117 if (hdr->check || (*pskb)->ip_summed == CHECKSUM_PARTIAL) { 117 if (hdr->check || (*pskb)->ip_summed == CHECKSUM_PARTIAL) {
118 hdr->check = nf_proto_csum_update(*pskb, ~oldip, newip, 118 nf_proto_csum_replace4(&hdr->check, *pskb, oldip, newip, 1);
119 hdr->check, 1); 119 nf_proto_csum_replace2(&hdr->check, *pskb, *portptr, newport, 0);
120 hdr->check = nf_proto_csum_update(*pskb,
121 *portptr ^ htons(0xFFFF), newport,
122 hdr->check, 0);
123 if (!hdr->check) 120 if (!hdr->check)
124 hdr->check = -1; 121 hdr->check = CSUM_MANGLED_0;
125 } 122 }
126 *portptr = newport; 123 *portptr = newport;
127 return 1; 124 return 1;
diff --git a/net/ipv4/netfilter/ip_nat_sip.c b/net/ipv4/netfilter/ip_nat_sip.c
index 71fc2730a007..6223abc924ff 100644
--- a/net/ipv4/netfilter/ip_nat_sip.c
+++ b/net/ipv4/netfilter/ip_nat_sip.c
@@ -29,27 +29,70 @@ MODULE_DESCRIPTION("SIP NAT helper");
29#define DEBUGP(format, args...) 29#define DEBUGP(format, args...)
30#endif 30#endif
31 31
32extern struct sip_header_nfo ct_sip_hdrs[]; 32struct addr_map {
33 struct {
34 char src[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
35 char dst[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
36 unsigned int srclen, srciplen;
37 unsigned int dstlen, dstiplen;
38 } addr[IP_CT_DIR_MAX];
39};
40
41static void addr_map_init(struct ip_conntrack *ct, struct addr_map *map)
42{
43 struct ip_conntrack_tuple *t;
44 enum ip_conntrack_dir dir;
45 unsigned int n;
46
47 for (dir = 0; dir < IP_CT_DIR_MAX; dir++) {
48 t = &ct->tuplehash[dir].tuple;
49
50 n = sprintf(map->addr[dir].src, "%u.%u.%u.%u",
51 NIPQUAD(t->src.ip));
52 map->addr[dir].srciplen = n;
53 n += sprintf(map->addr[dir].src + n, ":%u",
54 ntohs(t->src.u.udp.port));
55 map->addr[dir].srclen = n;
56
57 n = sprintf(map->addr[dir].dst, "%u.%u.%u.%u",
58 NIPQUAD(t->dst.ip));
59 map->addr[dir].dstiplen = n;
60 n += sprintf(map->addr[dir].dst + n, ":%u",
61 ntohs(t->dst.u.udp.port));
62 map->addr[dir].dstlen = n;
63 }
64}
33 65
34static unsigned int mangle_sip_packet(struct sk_buff **pskb, 66static int map_sip_addr(struct sk_buff **pskb, enum ip_conntrack_info ctinfo,
35 enum ip_conntrack_info ctinfo, 67 struct ip_conntrack *ct, const char **dptr, size_t dlen,
36 struct ip_conntrack *ct, 68 enum sip_header_pos pos, struct addr_map *map)
37 const char **dptr, size_t dlen,
38 char *buffer, int bufflen,
39 struct sip_header_nfo *hnfo)
40{ 69{
41 unsigned int matchlen, matchoff; 70 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
71 unsigned int matchlen, matchoff, addrlen;
72 char *addr;
42 73
43 if (ct_sip_get_info(*dptr, dlen, &matchoff, &matchlen, hnfo) <= 0) 74 if (ct_sip_get_info(*dptr, dlen, &matchoff, &matchlen, pos) <= 0)
44 return 0; 75 return 1;
76
77 if ((matchlen == map->addr[dir].srciplen ||
78 matchlen == map->addr[dir].srclen) &&
79 memcmp(*dptr + matchoff, map->addr[dir].src, matchlen) == 0) {
80 addr = map->addr[!dir].dst;
81 addrlen = map->addr[!dir].dstlen;
82 } else if ((matchlen == map->addr[dir].dstiplen ||
83 matchlen == map->addr[dir].dstlen) &&
84 memcmp(*dptr + matchoff, map->addr[dir].dst, matchlen) == 0) {
85 addr = map->addr[!dir].src;
86 addrlen = map->addr[!dir].srclen;
87 } else
88 return 1;
45 89
46 if (!ip_nat_mangle_udp_packet(pskb, ct, ctinfo, 90 if (!ip_nat_mangle_udp_packet(pskb, ct, ctinfo,
47 matchoff, matchlen, buffer, bufflen)) 91 matchoff, matchlen, addr, addrlen))
48 return 0; 92 return 0;
49
50 /* We need to reload this. Thanks Patrick. */
51 *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr); 93 *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
52 return 1; 94 return 1;
95
53} 96}
54 97
55static unsigned int ip_nat_sip(struct sk_buff **pskb, 98static unsigned int ip_nat_sip(struct sk_buff **pskb,
@@ -57,70 +100,61 @@ static unsigned int ip_nat_sip(struct sk_buff **pskb,
57 struct ip_conntrack *ct, 100 struct ip_conntrack *ct,
58 const char **dptr) 101 const char **dptr)
59{ 102{
60 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); 103 enum sip_header_pos pos;
61 char buffer[sizeof("nnn.nnn.nnn.nnn:nnnnn")]; 104 struct addr_map map;
62 unsigned int bufflen, dataoff; 105 int dataoff, datalen;
63 __be32 ip;
64 __be16 port;
65 106
66 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr); 107 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
108 datalen = (*pskb)->len - dataoff;
109 if (datalen < sizeof("SIP/2.0") - 1)
110 return NF_DROP;
111
112 addr_map_init(ct, &map);
113
114 /* Basic rules: requests and responses. */
115 if (strncmp(*dptr, "SIP/2.0", sizeof("SIP/2.0") - 1) != 0) {
116 /* 10.2: Constructing the REGISTER Request:
117 *
118 * The "userinfo" and "@" components of the SIP URI MUST NOT
119 * be present.
120 */
121 if (datalen >= sizeof("REGISTER") - 1 &&
122 strncmp(*dptr, "REGISTER", sizeof("REGISTER") - 1) == 0)
123 pos = POS_REG_REQ_URI;
124 else
125 pos = POS_REQ_URI;
126
127 if (!map_sip_addr(pskb, ctinfo, ct, dptr, datalen, pos, &map))
128 return NF_DROP;
129 }
130
131 if (!map_sip_addr(pskb, ctinfo, ct, dptr, datalen, POS_FROM, &map) ||
132 !map_sip_addr(pskb, ctinfo, ct, dptr, datalen, POS_TO, &map) ||
133 !map_sip_addr(pskb, ctinfo, ct, dptr, datalen, POS_VIA, &map) ||
134 !map_sip_addr(pskb, ctinfo, ct, dptr, datalen, POS_CONTACT, &map))
135 return NF_DROP;
136 return NF_ACCEPT;
137}
67 138
68 ip = ct->tuplehash[!dir].tuple.dst.ip; 139static unsigned int mangle_sip_packet(struct sk_buff **pskb,
69 port = ct->tuplehash[!dir].tuple.dst.u.udp.port; 140 enum ip_conntrack_info ctinfo,
70 bufflen = sprintf(buffer, "%u.%u.%u.%u:%u", NIPQUAD(ip), ntohs(port)); 141 struct ip_conntrack *ct,
142 const char **dptr, size_t dlen,
143 char *buffer, int bufflen,
144 enum sip_header_pos pos)
145{
146 unsigned int matchlen, matchoff;
71 147
72 /* short packet ? */ 148 if (ct_sip_get_info(*dptr, dlen, &matchoff, &matchlen, pos) <= 0)
73 if (((*pskb)->len - dataoff) < (sizeof("SIP/2.0") - 1))
74 return 0; 149 return 0;
75 150
76 /* Basic rules: requests and responses. */ 151 if (!ip_nat_mangle_udp_packet(pskb, ct, ctinfo,
77 if (memcmp(*dptr, "SIP/2.0", sizeof("SIP/2.0") - 1) == 0) { 152 matchoff, matchlen, buffer, bufflen))
78 const char *aux; 153 return 0;
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 154
88 if (!mangle_sip_packet(pskb, ctinfo, ct, dptr, 155 /* We need to reload this. Thanks Patrick. */
89 (*pskb)->len - dataoff, 156 *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
90 buffer, bufflen, &ct_sip_hdrs[POS_VIA])) 157 return 1;
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} 158}
125 159
126static int mangle_content_len(struct sk_buff **pskb, 160static int mangle_content_len(struct sk_buff **pskb,
@@ -136,7 +170,7 @@ static int mangle_content_len(struct sk_buff **pskb,
136 170
137 /* Get actual SDP lenght */ 171 /* Get actual SDP lenght */
138 if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff, 172 if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff,
139 &matchlen, &ct_sip_hdrs[POS_SDP_HEADER]) > 0) { 173 &matchlen, POS_SDP_HEADER) > 0) {
140 174
141 /* since ct_sip_get_info() give us a pointer passing 'v=' 175 /* since ct_sip_get_info() give us a pointer passing 'v='
142 we need to add 2 bytes in this count. */ 176 we need to add 2 bytes in this count. */
@@ -144,7 +178,7 @@ static int mangle_content_len(struct sk_buff **pskb,
144 178
145 /* Now, update SDP lenght */ 179 /* Now, update SDP lenght */
146 if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff, 180 if (ct_sip_get_info(dptr, (*pskb)->len - dataoff, &matchoff,
147 &matchlen, &ct_sip_hdrs[POS_CONTENT]) > 0) { 181 &matchlen, POS_CONTENT) > 0) {
148 182
149 bufflen = sprintf(buffer, "%u", c_len); 183 bufflen = sprintf(buffer, "%u", c_len);
150 184
@@ -170,17 +204,17 @@ static unsigned int mangle_sdp(struct sk_buff **pskb,
170 /* Mangle owner and contact info. */ 204 /* Mangle owner and contact info. */
171 bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip)); 205 bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip));
172 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff, 206 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
173 buffer, bufflen, &ct_sip_hdrs[POS_OWNER])) 207 buffer, bufflen, POS_OWNER))
174 return 0; 208 return 0;
175 209
176 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff, 210 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
177 buffer, bufflen, &ct_sip_hdrs[POS_CONNECTION])) 211 buffer, bufflen, POS_CONNECTION))
178 return 0; 212 return 0;
179 213
180 /* Mangle media port. */ 214 /* Mangle media port. */
181 bufflen = sprintf(buffer, "%u", port); 215 bufflen = sprintf(buffer, "%u", port);
182 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff, 216 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
183 buffer, bufflen, &ct_sip_hdrs[POS_MEDIA])) 217 buffer, bufflen, POS_MEDIA))
184 return 0; 218 return 0;
185 219
186 return mangle_content_len(pskb, ctinfo, ct, dptr); 220 return mangle_content_len(pskb, ctinfo, ct, dptr);
@@ -230,18 +264,17 @@ static unsigned int ip_nat_sdp(struct sk_buff **pskb,
230 264
231static void __exit fini(void) 265static void __exit fini(void)
232{ 266{
233 ip_nat_sip_hook = NULL; 267 rcu_assign_pointer(ip_nat_sip_hook, NULL);
234 ip_nat_sdp_hook = NULL; 268 rcu_assign_pointer(ip_nat_sdp_hook, NULL);
235 /* Make sure noone calls it, meanwhile. */ 269 synchronize_rcu();
236 synchronize_net();
237} 270}
238 271
239static int __init init(void) 272static int __init init(void)
240{ 273{
241 BUG_ON(ip_nat_sip_hook); 274 BUG_ON(rcu_dereference(ip_nat_sip_hook));
242 BUG_ON(ip_nat_sdp_hook); 275 BUG_ON(rcu_dereference(ip_nat_sdp_hook));
243 ip_nat_sip_hook = ip_nat_sip; 276 rcu_assign_pointer(ip_nat_sip_hook, ip_nat_sip);
244 ip_nat_sdp_hook = ip_nat_sdp; 277 rcu_assign_pointer(ip_nat_sdp_hook, ip_nat_sdp);
245 return 0; 278 return 0;
246} 279}
247 280
diff --git a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c
index 168f45fa1898..c3d9f3b090c4 100644
--- a/net/ipv4/netfilter/ip_nat_snmp_basic.c
+++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c
@@ -64,7 +64,7 @@ MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
64 64
65#define SNMP_PORT 161 65#define SNMP_PORT 161
66#define SNMP_TRAP_PORT 162 66#define SNMP_TRAP_PORT 162
67#define NOCT1(n) (u_int8_t )((n) & 0xff) 67#define NOCT1(n) (*(u8 *)n)
68 68
69static int debug; 69static int debug;
70static DEFINE_SPINLOCK(snmp_lock); 70static DEFINE_SPINLOCK(snmp_lock);
@@ -613,7 +613,7 @@ struct snmp_v1_trap
613static inline void mangle_address(unsigned char *begin, 613static inline void mangle_address(unsigned char *begin,
614 unsigned char *addr, 614 unsigned char *addr,
615 const struct oct1_map *map, 615 const struct oct1_map *map,
616 u_int16_t *check); 616 __sum16 *check);
617struct snmp_cnv 617struct snmp_cnv
618{ 618{
619 unsigned int class; 619 unsigned int class;
@@ -873,38 +873,24 @@ static unsigned char snmp_request_decode(struct asn1_ctx *ctx,
873 * Fast checksum update for possibly oddly-aligned UDP byte, from the 873 * Fast checksum update for possibly oddly-aligned UDP byte, from the
874 * code example in the draft. 874 * code example in the draft.
875 */ 875 */
876static void fast_csum(unsigned char *csum, 876static void fast_csum(__sum16 *csum,
877 const unsigned char *optr, 877 const unsigned char *optr,
878 const unsigned char *nptr, 878 const unsigned char *nptr,
879 int odd) 879 int offset)
880{ 880{
881 long x, old, new; 881 unsigned char s[4];
882 882
883 x = csum[0] * 256 + csum[1]; 883 if (offset & 1) {
884 884 s[0] = s[2] = 0;
885 x =~ x & 0xFFFF; 885 s[1] = ~*optr;
886 886 s[3] = *nptr;
887 if (odd) old = optr[0] * 256; 887 } else {
888 else old = optr[0]; 888 s[1] = s[3] = 0;
889 889 s[0] = ~*optr;
890 x -= old & 0xFFFF; 890 s[2] = *nptr;
891 if (x <= 0) {
892 x--;
893 x &= 0xFFFF;
894 }
895
896 if (odd) new = nptr[0] * 256;
897 else new = nptr[0];
898
899 x += new & 0xFFFF;
900 if (x & 0x10000) {
901 x++;
902 x &= 0xFFFF;
903 } 891 }
904 892
905 x =~ x & 0xFFFF; 893 *csum = csum_fold(csum_partial(s, 4, ~csum_unfold(*csum)));
906 csum[0] = x / 256;
907 csum[1] = x & 0xFF;
908} 894}
909 895
910/* 896/*
@@ -915,9 +901,9 @@ static void fast_csum(unsigned char *csum,
915static inline void mangle_address(unsigned char *begin, 901static inline void mangle_address(unsigned char *begin,
916 unsigned char *addr, 902 unsigned char *addr,
917 const struct oct1_map *map, 903 const struct oct1_map *map,
918 u_int16_t *check) 904 __sum16 *check)
919{ 905{
920 if (map->from == NOCT1(*addr)) { 906 if (map->from == NOCT1(addr)) {
921 u_int32_t old; 907 u_int32_t old;
922 908
923 if (debug) 909 if (debug)
@@ -927,11 +913,8 @@ static inline void mangle_address(unsigned char *begin,
927 913
928 /* Update UDP checksum if being used */ 914 /* Update UDP checksum if being used */
929 if (*check) { 915 if (*check) {
930 unsigned char odd = !((addr - begin) % 2); 916 fast_csum(check,
931 917 &map->from, &map->to, addr - begin);
932 fast_csum((unsigned char *)check,
933 &map->from, &map->to, odd);
934
935 } 918 }
936 919
937 if (debug) 920 if (debug)
@@ -943,7 +926,7 @@ static inline void mangle_address(unsigned char *begin,
943static unsigned char snmp_trap_decode(struct asn1_ctx *ctx, 926static unsigned char snmp_trap_decode(struct asn1_ctx *ctx,
944 struct snmp_v1_trap *trap, 927 struct snmp_v1_trap *trap,
945 const struct oct1_map *map, 928 const struct oct1_map *map,
946 u_int16_t *check) 929 __sum16 *check)
947{ 930{
948 unsigned int cls, con, tag, len; 931 unsigned int cls, con, tag, len;
949 unsigned char *end; 932 unsigned char *end;
@@ -1037,7 +1020,7 @@ static void hex_dump(unsigned char *buf, size_t len)
1037static int snmp_parse_mangle(unsigned char *msg, 1020static int snmp_parse_mangle(unsigned char *msg,
1038 u_int16_t len, 1021 u_int16_t len,
1039 const struct oct1_map *map, 1022 const struct oct1_map *map,
1040 u_int16_t *check) 1023 __sum16 *check)
1041{ 1024{
1042 unsigned char *eoc, *end; 1025 unsigned char *eoc, *end;
1043 unsigned int cls, con, tag, vers, pdutype; 1026 unsigned int cls, con, tag, vers, pdutype;
@@ -1223,12 +1206,12 @@ static int snmp_translate(struct ip_conntrack *ct,
1223 */ 1206 */
1224 if (dir == IP_CT_DIR_ORIGINAL) { 1207 if (dir == IP_CT_DIR_ORIGINAL) {
1225 /* SNAT traps */ 1208 /* SNAT traps */
1226 map.from = NOCT1(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip); 1209 map.from = NOCT1(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip);
1227 map.to = NOCT1(ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip); 1210 map.to = NOCT1(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip);
1228 } else { 1211 } else {
1229 /* DNAT replies */ 1212 /* DNAT replies */
1230 map.from = NOCT1(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip); 1213 map.from = NOCT1(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip);
1231 map.to = NOCT1(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip); 1214 map.to = NOCT1(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.ip);
1232 } 1215 }
1233 1216
1234 if (map.from == map.to) 1217 if (map.from == map.to)
@@ -1294,11 +1277,11 @@ static struct ip_conntrack_helper snmp_helper = {
1294 .help = help, 1277 .help = help,
1295 .name = "snmp", 1278 .name = "snmp",
1296 1279
1297 .tuple = { .src = { .u = { __constant_htons(SNMP_PORT) } }, 1280 .tuple = {.src = {.u = {.udp = {.port = __constant_htons(SNMP_PORT)}}},
1298 .dst = { .protonum = IPPROTO_UDP }, 1281 .dst = {.protonum = IPPROTO_UDP},
1299 }, 1282 },
1300 .mask = { .src = { .u = { 0xFFFF } }, 1283 .mask = {.src = {.u = {0xFFFF}},
1301 .dst = { .protonum = 0xFF }, 1284 .dst = {.protonum = 0xFF},
1302 }, 1285 },
1303}; 1286};
1304 1287
@@ -1309,11 +1292,11 @@ static struct ip_conntrack_helper snmp_trap_helper = {
1309 .help = help, 1292 .help = help,
1310 .name = "snmp_trap", 1293 .name = "snmp_trap",
1311 1294
1312 .tuple = { .src = { .u = { __constant_htons(SNMP_TRAP_PORT) } }, 1295 .tuple = {.src = {.u = {.udp = {.port = __constant_htons(SNMP_TRAP_PORT)}}},
1313 .dst = { .protonum = IPPROTO_UDP }, 1296 .dst = {.protonum = IPPROTO_UDP},
1314 }, 1297 },
1315 .mask = { .src = { .u = { 0xFFFF } }, 1298 .mask = {.src = {.u = {0xFFFF}},
1316 .dst = { .protonum = 0xFF }, 1299 .dst = {.protonum = 0xFF},
1317 }, 1300 },
1318}; 1301};
1319 1302
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index d85d2de50449..ad66328baa5d 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -44,12 +44,6 @@
44#define DEBUGP(format, args...) 44#define DEBUGP(format, args...)
45#endif 45#endif
46 46
47#define HOOKNAME(hooknum) ((hooknum) == NF_IP_POST_ROUTING ? "POST_ROUTING" \
48 : ((hooknum) == NF_IP_PRE_ROUTING ? "PRE_ROUTING" \
49 : ((hooknum) == NF_IP_LOCAL_OUT ? "LOCAL_OUT" \
50 : ((hooknum) == NF_IP_LOCAL_IN ? "LOCAL_IN" \
51 : "*ERROR*")))
52
53#ifdef CONFIG_XFRM 47#ifdef CONFIG_XFRM
54static void nat_decode_session(struct sk_buff *skb, struct flowi *fl) 48static void nat_decode_session(struct sk_buff *skb, struct flowi *fl)
55{ 49{
diff --git a/net/ipv4/netfilter/ip_nat_tftp.c b/net/ipv4/netfilter/ip_nat_tftp.c
index 94a78015451c..604793536fc1 100644
--- a/net/ipv4/netfilter/ip_nat_tftp.c
+++ b/net/ipv4/netfilter/ip_nat_tftp.c
@@ -55,15 +55,14 @@ static unsigned int help(struct sk_buff **pskb,
55 55
56static void __exit ip_nat_tftp_fini(void) 56static void __exit ip_nat_tftp_fini(void)
57{ 57{
58 ip_nat_tftp_hook = NULL; 58 rcu_assign_pointer(ip_nat_tftp_hook, NULL);
59 /* Make sure noone calls it, meanwhile. */ 59 synchronize_rcu();
60 synchronize_net();
61} 60}
62 61
63static int __init ip_nat_tftp_init(void) 62static int __init ip_nat_tftp_init(void)
64{ 63{
65 BUG_ON(ip_nat_tftp_hook); 64 BUG_ON(rcu_dereference(ip_nat_tftp_hook));
66 ip_nat_tftp_hook = help; 65 rcu_assign_pointer(ip_nat_tftp_hook, help);
67 return 0; 66 return 0;
68} 67}
69 68
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 97556cc2e4e0..cd520df4dcf4 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -243,7 +243,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
243 pmsg->data_len = data_len; 243 pmsg->data_len = data_len;
244 pmsg->timestamp_sec = entry->skb->tstamp.off_sec; 244 pmsg->timestamp_sec = entry->skb->tstamp.off_sec;
245 pmsg->timestamp_usec = entry->skb->tstamp.off_usec; 245 pmsg->timestamp_usec = entry->skb->tstamp.off_usec;
246 pmsg->mark = entry->skb->nfmark; 246 pmsg->mark = entry->skb->mark;
247 pmsg->hook = entry->info->hook; 247 pmsg->hook = entry->info->hook;
248 pmsg->hw_protocol = entry->skb->protocol; 248 pmsg->hw_protocol = entry->skb->protocol;
249 249
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 7a29d6e7baa7..098365062234 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -40,8 +40,6 @@
40#define DEBUGP 40#define DEBUGP
41#endif 41#endif
42 42
43#define ASSERT_READ_LOCK(x)
44
45MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
46MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 44MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
47MODULE_DESCRIPTION("iptables target for CLUSTERIP"); 45MODULE_DESCRIPTION("iptables target for CLUSTERIP");
@@ -123,7 +121,6 @@ __clusterip_config_find(__be32 clusterip)
123{ 121{
124 struct list_head *pos; 122 struct list_head *pos;
125 123
126 ASSERT_READ_LOCK(&clusterip_lock);
127 list_for_each(pos, &clusterip_configs) { 124 list_for_each(pos, &clusterip_configs) {
128 struct clusterip_config *c = list_entry(pos, 125 struct clusterip_config *c = list_entry(pos,
129 struct clusterip_config, list); 126 struct clusterip_config, list);
@@ -170,7 +167,6 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, __be32 ip,
170 struct net_device *dev) 167 struct net_device *dev)
171{ 168{
172 struct clusterip_config *c; 169 struct clusterip_config *c;
173 char buffer[16];
174 170
175 c = kzalloc(sizeof(*c), GFP_ATOMIC); 171 c = kzalloc(sizeof(*c), GFP_ATOMIC);
176 if (!c) 172 if (!c)
@@ -187,12 +183,17 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, __be32 ip,
187 atomic_set(&c->entries, 1); 183 atomic_set(&c->entries, 1);
188 184
189#ifdef CONFIG_PROC_FS 185#ifdef CONFIG_PROC_FS
190 /* create proc dir entry */ 186 {
191 sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip)); 187 char buffer[16];
192 c->pde = create_proc_entry(buffer, S_IWUSR|S_IRUSR, clusterip_procdir); 188
193 if (!c->pde) { 189 /* create proc dir entry */
194 kfree(c); 190 sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip));
195 return NULL; 191 c->pde = create_proc_entry(buffer, S_IWUSR|S_IRUSR,
192 clusterip_procdir);
193 if (!c->pde) {
194 kfree(c);
195 return NULL;
196 }
196 } 197 }
197 c->pde->proc_fops = &clusterip_proc_fops; 198 c->pde->proc_fops = &clusterip_proc_fops;
198 c->pde->data = c; 199 c->pde->data = c;
@@ -205,6 +206,7 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, __be32 ip,
205 return c; 206 return c;
206} 207}
207 208
209#ifdef CONFIG_PROC_FS
208static int 210static int
209clusterip_add_node(struct clusterip_config *c, u_int16_t nodenum) 211clusterip_add_node(struct clusterip_config *c, u_int16_t nodenum)
210{ 212{
@@ -232,6 +234,7 @@ clusterip_del_node(struct clusterip_config *c, u_int16_t nodenum)
232 234
233 return 1; 235 return 1;
234} 236}
237#endif
235 238
236static inline u_int32_t 239static inline u_int32_t
237clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config) 240clusterip_hashfn(struct sk_buff *skb, struct clusterip_config *config)
@@ -737,8 +740,10 @@ static int __init ipt_clusterip_init(void)
737 CLUSTERIP_VERSION); 740 CLUSTERIP_VERSION);
738 return 0; 741 return 0;
739 742
743#ifdef CONFIG_PROC_FS
740cleanup_hook: 744cleanup_hook:
741 nf_unregister_hook(&cip_arp_ops); 745 nf_unregister_hook(&cip_arp_ops);
746#endif /* CONFIG_PROC_FS */
742cleanup_target: 747cleanup_target:
743 ipt_unregister_target(&clusterip_tgt); 748 ipt_unregister_target(&clusterip_tgt);
744 return ret; 749 return ret;
diff --git a/net/ipv4/netfilter/ipt_ECN.c b/net/ipv4/netfilter/ipt_ECN.c
index 1aa4517fbcdb..b55d670a24df 100644
--- a/net/ipv4/netfilter/ipt_ECN.c
+++ b/net/ipv4/netfilter/ipt_ECN.c
@@ -28,17 +28,16 @@ static inline int
28set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo) 28set_ect_ip(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
29{ 29{
30 struct iphdr *iph = (*pskb)->nh.iph; 30 struct iphdr *iph = (*pskb)->nh.iph;
31 u_int16_t oldtos;
32 31
33 if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) { 32 if ((iph->tos & IPT_ECN_IP_MASK) != (einfo->ip_ect & IPT_ECN_IP_MASK)) {
33 __u8 oldtos;
34 if (!skb_make_writable(pskb, sizeof(struct iphdr))) 34 if (!skb_make_writable(pskb, sizeof(struct iphdr)))
35 return 0; 35 return 0;
36 iph = (*pskb)->nh.iph; 36 iph = (*pskb)->nh.iph;
37 oldtos = iph->tos; 37 oldtos = iph->tos;
38 iph->tos &= ~IPT_ECN_IP_MASK; 38 iph->tos &= ~IPT_ECN_IP_MASK;
39 iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK); 39 iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK);
40 iph->check = nf_csum_update(htons(oldtos) ^ htons(0xFFFF), 40 nf_csum_replace2(&iph->check, htons(oldtos), htons(iph->tos));
41 htons(iph->tos), iph->check);
42 } 41 }
43 return 1; 42 return 1;
44} 43}
@@ -72,10 +71,8 @@ set_ect_tcp(struct sk_buff **pskb, const struct ipt_ECN_info *einfo)
72 if (einfo->operation & IPT_ECN_OP_SET_CWR) 71 if (einfo->operation & IPT_ECN_OP_SET_CWR)
73 tcph->cwr = einfo->proto.tcp.cwr; 72 tcph->cwr = einfo->proto.tcp.cwr;
74 73
75 tcph->check = nf_proto_csum_update((*pskb), 74 nf_proto_csum_replace2(&tcph->check, *pskb,
76 oldval ^ htons(0xFFFF), 75 oldval, ((__be16 *)tcph)[6], 0);
77 ((__be16 *)tcph)[6],
78 tcph->check, 0);
79 return 1; 76 return 1;
80} 77}
81 78
diff --git a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
index 7dc820df8bc5..c96de16fefae 100644
--- a/net/ipv4/netfilter/ipt_LOG.c
+++ b/net/ipv4/netfilter/ipt_LOG.c
@@ -171,11 +171,15 @@ static void dump_packet(const struct nf_loginfo *info,
171 } 171 }
172 break; 172 break;
173 } 173 }
174 case IPPROTO_UDP: { 174 case IPPROTO_UDP:
175 case IPPROTO_UDPLITE: {
175 struct udphdr _udph, *uh; 176 struct udphdr _udph, *uh;
176 177
177 /* Max length: 10 "PROTO=UDP " */ 178 if (ih->protocol == IPPROTO_UDP)
178 printk("PROTO=UDP "); 179 /* Max length: 10 "PROTO=UDP " */
180 printk("PROTO=UDP " );
181 else /* Max length: 14 "PROTO=UDPLITE " */
182 printk("PROTO=UDPLITE ");
179 183
180 if (ntohs(ih->frag_off) & IP_OFFSET) 184 if (ntohs(ih->frag_off) & IP_OFFSET)
181 break; 185 break;
@@ -341,6 +345,7 @@ static void dump_packet(const struct nf_loginfo *info,
341 /* IP: 40+46+6+11+127 = 230 */ 345 /* IP: 40+46+6+11+127 = 230 */
342 /* TCP: 10+max(25,20+30+13+9+32+11+127) = 252 */ 346 /* TCP: 10+max(25,20+30+13+9+32+11+127) = 252 */
343 /* UDP: 10+max(25,20) = 35 */ 347 /* UDP: 10+max(25,20) = 35 */
348 /* UDPLITE: 14+max(25,20) = 39 */
344 /* ICMP: 11+max(25, 18+25+max(19,14,24+3+n+10,3+n+10)) = 91+n */ 349 /* ICMP: 11+max(25, 18+25+max(19,14,24+3+n+10,3+n+10)) = 91+n */
345 /* ESP: 10+max(25)+15 = 50 */ 350 /* ESP: 10+max(25)+15 = 50 */
346 /* AH: 9+max(25)+15 = 49 */ 351 /* AH: 9+max(25)+15 = 49 */
@@ -425,13 +430,8 @@ ipt_log_target(struct sk_buff **pskb,
425 li.u.log.level = loginfo->level; 430 li.u.log.level = loginfo->level;
426 li.u.log.logflags = loginfo->logflags; 431 li.u.log.logflags = loginfo->logflags;
427 432
428 if (loginfo->logflags & IPT_LOG_NFLOG) 433 ipt_log_packet(PF_INET, hooknum, *pskb, in, out, &li,
429 nf_log_packet(PF_INET, hooknum, *pskb, in, out, &li, 434 loginfo->prefix);
430 "%s", loginfo->prefix);
431 else
432 ipt_log_packet(PF_INET, hooknum, *pskb, in, out, &li,
433 loginfo->prefix);
434
435 return IPT_CONTINUE; 435 return IPT_CONTINUE;
436} 436}
437 437
diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c
index 3dbfcfac8a84..28b9233956b5 100644
--- a/net/ipv4/netfilter/ipt_MASQUERADE.c
+++ b/net/ipv4/netfilter/ipt_MASQUERADE.c
@@ -2,7 +2,7 @@
2 (depending on route). */ 2 (depending on route). */
3 3
4/* (C) 1999-2001 Paul `Rusty' Russell 4/* (C) 1999-2001 Paul `Rusty' Russell
5 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> 5 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -20,7 +20,11 @@
20#include <net/checksum.h> 20#include <net/checksum.h>
21#include <net/route.h> 21#include <net/route.h>
22#include <linux/netfilter_ipv4.h> 22#include <linux/netfilter_ipv4.h>
23#ifdef CONFIG_NF_NAT_NEEDED
24#include <net/netfilter/nf_nat_rule.h>
25#else
23#include <linux/netfilter_ipv4/ip_nat_rule.h> 26#include <linux/netfilter_ipv4/ip_nat_rule.h>
27#endif
24#include <linux/netfilter_ipv4/ip_tables.h> 28#include <linux/netfilter_ipv4/ip_tables.h>
25 29
26MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
@@ -65,23 +69,33 @@ masquerade_target(struct sk_buff **pskb,
65 const struct xt_target *target, 69 const struct xt_target *target,
66 const void *targinfo) 70 const void *targinfo)
67{ 71{
72#ifdef CONFIG_NF_NAT_NEEDED
73 struct nf_conn_nat *nat;
74#endif
68 struct ip_conntrack *ct; 75 struct ip_conntrack *ct;
69 enum ip_conntrack_info ctinfo; 76 enum ip_conntrack_info ctinfo;
70 const struct ip_nat_multi_range_compat *mr;
71 struct ip_nat_range newrange; 77 struct ip_nat_range newrange;
78 const struct ip_nat_multi_range_compat *mr;
72 struct rtable *rt; 79 struct rtable *rt;
73 __be32 newsrc; 80 __be32 newsrc;
74 81
75 IP_NF_ASSERT(hooknum == NF_IP_POST_ROUTING); 82 IP_NF_ASSERT(hooknum == NF_IP_POST_ROUTING);
76 83
77 ct = ip_conntrack_get(*pskb, &ctinfo); 84 ct = ip_conntrack_get(*pskb, &ctinfo);
85#ifdef CONFIG_NF_NAT_NEEDED
86 nat = nfct_nat(ct);
87#endif
78 IP_NF_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED 88 IP_NF_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED
79 || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY)); 89 || ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
80 90
81 /* Source address is 0.0.0.0 - locally generated packet that is 91 /* Source address is 0.0.0.0 - locally generated packet that is
82 * probably not supposed to be masqueraded. 92 * probably not supposed to be masqueraded.
83 */ 93 */
94#ifdef CONFIG_NF_NAT_NEEDED
95 if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3.ip == 0)
96#else
84 if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip == 0) 97 if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip == 0)
98#endif
85 return NF_ACCEPT; 99 return NF_ACCEPT;
86 100
87 mr = targinfo; 101 mr = targinfo;
@@ -93,7 +107,11 @@ masquerade_target(struct sk_buff **pskb,
93 } 107 }
94 108
95 write_lock_bh(&masq_lock); 109 write_lock_bh(&masq_lock);
110#ifdef CONFIG_NF_NAT_NEEDED
111 nat->masq_index = out->ifindex;
112#else
96 ct->nat.masq_index = out->ifindex; 113 ct->nat.masq_index = out->ifindex;
114#endif
97 write_unlock_bh(&masq_lock); 115 write_unlock_bh(&masq_lock);
98 116
99 /* Transfer from original range. */ 117 /* Transfer from original range. */
@@ -109,10 +127,17 @@ masquerade_target(struct sk_buff **pskb,
109static inline int 127static inline int
110device_cmp(struct ip_conntrack *i, void *ifindex) 128device_cmp(struct ip_conntrack *i, void *ifindex)
111{ 129{
130#ifdef CONFIG_NF_NAT_NEEDED
131 struct nf_conn_nat *nat = nfct_nat(i);
132#endif
112 int ret; 133 int ret;
113 134
114 read_lock_bh(&masq_lock); 135 read_lock_bh(&masq_lock);
136#ifdef CONFIG_NF_NAT_NEEDED
137 ret = (nat->masq_index == (int)(long)ifindex);
138#else
115 ret = (i->nat.masq_index == (int)(long)ifindex); 139 ret = (i->nat.masq_index == (int)(long)ifindex);
140#endif
116 read_unlock_bh(&masq_lock); 141 read_unlock_bh(&masq_lock);
117 142
118 return ret; 143 return ret;
diff --git a/net/ipv4/netfilter/ipt_NETMAP.c b/net/ipv4/netfilter/ipt_NETMAP.c
index 58a88f227108..9390e90f2b25 100644
--- a/net/ipv4/netfilter/ipt_NETMAP.c
+++ b/net/ipv4/netfilter/ipt_NETMAP.c
@@ -15,7 +15,11 @@
15#include <linux/netdevice.h> 15#include <linux/netdevice.h>
16#include <linux/netfilter.h> 16#include <linux/netfilter.h>
17#include <linux/netfilter_ipv4.h> 17#include <linux/netfilter_ipv4.h>
18#ifdef CONFIG_NF_NAT_NEEDED
19#include <net/netfilter/nf_nat_rule.h>
20#else
18#include <linux/netfilter_ipv4/ip_nat_rule.h> 21#include <linux/netfilter_ipv4/ip_nat_rule.h>
22#endif
19 23
20#define MODULENAME "NETMAP" 24#define MODULENAME "NETMAP"
21MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
index c0dcfe9d610c..462eceb3a1b1 100644
--- a/net/ipv4/netfilter/ipt_REDIRECT.c
+++ b/net/ipv4/netfilter/ipt_REDIRECT.c
@@ -1,6 +1,6 @@
1/* Redirect. Simple mapping which alters dst to a local IP address. */ 1/* Redirect. Simple mapping which alters dst to a local IP address. */
2/* (C) 1999-2001 Paul `Rusty' Russell 2/* (C) 1999-2001 Paul `Rusty' Russell
3 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> 3 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as 6 * it under the terms of the GNU General Public License version 2 as
@@ -18,7 +18,11 @@
18#include <net/protocol.h> 18#include <net/protocol.h>
19#include <net/checksum.h> 19#include <net/checksum.h>
20#include <linux/netfilter_ipv4.h> 20#include <linux/netfilter_ipv4.h>
21#ifdef CONFIG_NF_NAT_NEEDED
22#include <net/netfilter/nf_nat_rule.h>
23#else
21#include <linux/netfilter_ipv4/ip_nat_rule.h> 24#include <linux/netfilter_ipv4/ip_nat_rule.h>
25#endif
22 26
23MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
24MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>"); 28MODULE_AUTHOR("Netfilter Core Team <coreteam@netfilter.org>");
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c
index ad0312d0e4fd..f0319e5ee437 100644
--- a/net/ipv4/netfilter/ipt_REJECT.c
+++ b/net/ipv4/netfilter/ipt_REJECT.c
@@ -76,7 +76,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
76 76
77 /* This packet will not be the same as the other: clear nf fields */ 77 /* This packet will not be the same as the other: clear nf fields */
78 nf_reset(nskb); 78 nf_reset(nskb);
79 nskb->nfmark = 0; 79 nskb->mark = 0;
80 skb_init_secmark(nskb); 80 skb_init_secmark(nskb);
81 81
82 tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl); 82 tcph = (struct tcphdr *)((u_int32_t*)nskb->nh.iph + nskb->nh.iph->ihl);
@@ -114,6 +114,14 @@ static void send_reset(struct sk_buff *oldskb, int hook)
114 tcph->window = 0; 114 tcph->window = 0;
115 tcph->urg_ptr = 0; 115 tcph->urg_ptr = 0;
116 116
117 /* Adjust TCP checksum */
118 tcph->check = 0;
119 tcph->check = tcp_v4_check(tcph, sizeof(struct tcphdr),
120 nskb->nh.iph->saddr,
121 nskb->nh.iph->daddr,
122 csum_partial((char *)tcph,
123 sizeof(struct tcphdr), 0));
124
117 /* Set DF, id = 0 */ 125 /* Set DF, id = 0 */
118 nskb->nh.iph->frag_off = htons(IP_DF); 126 nskb->nh.iph->frag_off = htons(IP_DF);
119 nskb->nh.iph->id = 0; 127 nskb->nh.iph->id = 0;
@@ -129,14 +137,8 @@ static void send_reset(struct sk_buff *oldskb, int hook)
129 if (ip_route_me_harder(&nskb, addr_type)) 137 if (ip_route_me_harder(&nskb, addr_type))
130 goto free_nskb; 138 goto free_nskb;
131 139
132 /* Adjust TCP checksum */
133 nskb->ip_summed = CHECKSUM_NONE; 140 nskb->ip_summed = CHECKSUM_NONE;
134 tcph->check = 0; 141
135 tcph->check = tcp_v4_check(tcph, sizeof(struct tcphdr),
136 nskb->nh.iph->saddr,
137 nskb->nh.iph->daddr,
138 csum_partial((char *)tcph,
139 sizeof(struct tcphdr), 0));
140 /* Adjust IP TTL */ 142 /* Adjust IP TTL */
141 nskb->nh.iph->ttl = dst_metric(nskb->dst, RTAX_HOPLIMIT); 143 nskb->nh.iph->ttl = dst_metric(nskb->dst, RTAX_HOPLIMIT);
142 144
diff --git a/net/ipv4/netfilter/ipt_SAME.c b/net/ipv4/netfilter/ipt_SAME.c
index b38b13328d73..3dcf29411337 100644
--- a/net/ipv4/netfilter/ipt_SAME.c
+++ b/net/ipv4/netfilter/ipt_SAME.c
@@ -34,7 +34,11 @@
34#include <net/protocol.h> 34#include <net/protocol.h>
35#include <net/checksum.h> 35#include <net/checksum.h>
36#include <linux/netfilter_ipv4.h> 36#include <linux/netfilter_ipv4.h>
37#ifdef CONFIG_NF_NAT_NEEDED
38#include <net/netfilter/nf_nat_rule.h>
39#else
37#include <linux/netfilter_ipv4/ip_nat_rule.h> 40#include <linux/netfilter_ipv4/ip_nat_rule.h>
41#endif
38#include <linux/netfilter_ipv4/ipt_SAME.h> 42#include <linux/netfilter_ipv4/ipt_SAME.h>
39 43
40MODULE_LICENSE("GPL"); 44MODULE_LICENSE("GPL");
@@ -152,11 +156,17 @@ same_target(struct sk_buff **pskb,
152 Here we calculate the index in same->iparray which 156 Here we calculate the index in same->iparray which
153 holds the ipaddress we should use */ 157 holds the ipaddress we should use */
154 158
159#ifdef CONFIG_NF_NAT_NEEDED
160 tmpip = ntohl(t->src.u3.ip);
161
162 if (!(same->info & IPT_SAME_NODST))
163 tmpip += ntohl(t->dst.u3.ip);
164#else
155 tmpip = ntohl(t->src.ip); 165 tmpip = ntohl(t->src.ip);
156 166
157 if (!(same->info & IPT_SAME_NODST)) 167 if (!(same->info & IPT_SAME_NODST))
158 tmpip += ntohl(t->dst.ip); 168 tmpip += ntohl(t->dst.ip);
159 169#endif
160 aindex = tmpip % same->ipnum; 170 aindex = tmpip % same->ipnum;
161 171
162 new_ip = htonl(same->iparray[aindex]); 172 new_ip = htonl(same->iparray[aindex]);
diff --git a/net/ipv4/netfilter/ipt_TCPMSS.c b/net/ipv4/netfilter/ipt_TCPMSS.c
index 108b6b76311f..93eb5c3c1884 100644
--- a/net/ipv4/netfilter/ipt_TCPMSS.c
+++ b/net/ipv4/netfilter/ipt_TCPMSS.c
@@ -97,10 +97,8 @@ ipt_tcpmss_target(struct sk_buff **pskb,
97 opt[i+2] = (newmss & 0xff00) >> 8; 97 opt[i+2] = (newmss & 0xff00) >> 8;
98 opt[i+3] = (newmss & 0x00ff); 98 opt[i+3] = (newmss & 0x00ff);
99 99
100 tcph->check = nf_proto_csum_update(*pskb, 100 nf_proto_csum_replace2(&tcph->check, *pskb,
101 htons(oldmss)^htons(0xFFFF), 101 htons(oldmss), htons(newmss), 0);
102 htons(newmss),
103 tcph->check, 0);
104 return IPT_CONTINUE; 102 return IPT_CONTINUE;
105 } 103 }
106 } 104 }
@@ -126,28 +124,22 @@ ipt_tcpmss_target(struct sk_buff **pskb,
126 opt = (u_int8_t *)tcph + sizeof(struct tcphdr); 124 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
127 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr)); 125 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
128 126
129 tcph->check = nf_proto_csum_update(*pskb, 127 nf_proto_csum_replace2(&tcph->check, *pskb,
130 htons(tcplen) ^ htons(0xFFFF), 128 htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
131 htons(tcplen + TCPOLEN_MSS),
132 tcph->check, 1);
133 opt[0] = TCPOPT_MSS; 129 opt[0] = TCPOPT_MSS;
134 opt[1] = TCPOLEN_MSS; 130 opt[1] = TCPOLEN_MSS;
135 opt[2] = (newmss & 0xff00) >> 8; 131 opt[2] = (newmss & 0xff00) >> 8;
136 opt[3] = (newmss & 0x00ff); 132 opt[3] = (newmss & 0x00ff);
137 133
138 tcph->check = nf_proto_csum_update(*pskb, htonl(~0), *((__be32 *)opt), 134 nf_proto_csum_replace4(&tcph->check, *pskb, 0, *((__be32 *)opt), 0);
139 tcph->check, 0);
140 135
141 oldval = ((__be16 *)tcph)[6]; 136 oldval = ((__be16 *)tcph)[6];
142 tcph->doff += TCPOLEN_MSS/4; 137 tcph->doff += TCPOLEN_MSS/4;
143 tcph->check = nf_proto_csum_update(*pskb, 138 nf_proto_csum_replace2(&tcph->check, *pskb,
144 oldval ^ htons(0xFFFF), 139 oldval, ((__be16 *)tcph)[6], 0);
145 ((__be16 *)tcph)[6],
146 tcph->check, 0);
147 140
148 newtotlen = htons(ntohs(iph->tot_len) + TCPOLEN_MSS); 141 newtotlen = htons(ntohs(iph->tot_len) + TCPOLEN_MSS);
149 iph->check = nf_csum_update(iph->tot_len ^ htons(0xFFFF), 142 nf_csum_replace2(&iph->check, iph->tot_len, newtotlen);
150 newtotlen, iph->check);
151 iph->tot_len = newtotlen; 143 iph->tot_len = newtotlen;
152 return IPT_CONTINUE; 144 return IPT_CONTINUE;
153} 145}
diff --git a/net/ipv4/netfilter/ipt_TOS.c b/net/ipv4/netfilter/ipt_TOS.c
index 83b80b3a5d2f..18e74ac4d425 100644
--- a/net/ipv4/netfilter/ipt_TOS.c
+++ b/net/ipv4/netfilter/ipt_TOS.c
@@ -30,16 +30,15 @@ target(struct sk_buff **pskb,
30{ 30{
31 const struct ipt_tos_target_info *tosinfo = targinfo; 31 const struct ipt_tos_target_info *tosinfo = targinfo;
32 struct iphdr *iph = (*pskb)->nh.iph; 32 struct iphdr *iph = (*pskb)->nh.iph;
33 u_int16_t oldtos;
34 33
35 if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) { 34 if ((iph->tos & IPTOS_TOS_MASK) != tosinfo->tos) {
35 __u8 oldtos;
36 if (!skb_make_writable(pskb, sizeof(struct iphdr))) 36 if (!skb_make_writable(pskb, sizeof(struct iphdr)))
37 return NF_DROP; 37 return NF_DROP;
38 iph = (*pskb)->nh.iph; 38 iph = (*pskb)->nh.iph;
39 oldtos = iph->tos; 39 oldtos = iph->tos;
40 iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos; 40 iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos;
41 iph->check = nf_csum_update(htons(oldtos) ^ htons(0xFFFF), 41 nf_csum_replace2(&iph->check, htons(oldtos), htons(iph->tos));
42 htons(iph->tos), iph->check);
43 } 42 }
44 return IPT_CONTINUE; 43 return IPT_CONTINUE;
45} 44}
diff --git a/net/ipv4/netfilter/ipt_TTL.c b/net/ipv4/netfilter/ipt_TTL.c
index ac9517d62af0..fffe5ca82e91 100644
--- a/net/ipv4/netfilter/ipt_TTL.c
+++ b/net/ipv4/netfilter/ipt_TTL.c
@@ -54,9 +54,8 @@ ipt_ttl_target(struct sk_buff **pskb,
54 } 54 }
55 55
56 if (new_ttl != iph->ttl) { 56 if (new_ttl != iph->ttl) {
57 iph->check = nf_csum_update(htons((iph->ttl << 8)) ^ htons(0xFFFF), 57 nf_csum_replace2(&iph->check, htons(iph->ttl << 8),
58 htons(new_ttl << 8), 58 htons(new_ttl << 8));
59 iph->check);
60 iph->ttl = new_ttl; 59 iph->ttl = new_ttl;
61 } 60 }
62 61
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index 2b104ea54f48..dbd34783a64d 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -239,7 +239,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
239 pm->data_len = copy_len; 239 pm->data_len = copy_len;
240 pm->timestamp_sec = skb->tstamp.off_sec; 240 pm->timestamp_sec = skb->tstamp.off_sec;
241 pm->timestamp_usec = skb->tstamp.off_usec; 241 pm->timestamp_usec = skb->tstamp.off_usec;
242 pm->mark = skb->nfmark; 242 pm->mark = skb->mark;
243 pm->hook = hooknum; 243 pm->hook = hooknum;
244 if (prefix != NULL) 244 if (prefix != NULL)
245 strncpy(pm->prefix, prefix, sizeof(pm->prefix)); 245 strncpy(pm->prefix, prefix, sizeof(pm->prefix));
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c
index b91f3582359b..af2939889444 100644
--- a/net/ipv4/netfilter/iptable_mangle.c
+++ b/net/ipv4/netfilter/iptable_mangle.c
@@ -132,7 +132,7 @@ ipt_local_hook(unsigned int hook,
132 unsigned int ret; 132 unsigned int ret;
133 u_int8_t tos; 133 u_int8_t tos;
134 __be32 saddr, daddr; 134 __be32 saddr, daddr;
135 unsigned long nfmark; 135 u_int32_t mark;
136 136
137 /* root is playing with raw sockets. */ 137 /* root is playing with raw sockets. */
138 if ((*pskb)->len < sizeof(struct iphdr) 138 if ((*pskb)->len < sizeof(struct iphdr)
@@ -143,7 +143,7 @@ ipt_local_hook(unsigned int hook,
143 } 143 }
144 144
145 /* Save things which could affect route */ 145 /* Save things which could affect route */
146 nfmark = (*pskb)->nfmark; 146 mark = (*pskb)->mark;
147 saddr = (*pskb)->nh.iph->saddr; 147 saddr = (*pskb)->nh.iph->saddr;
148 daddr = (*pskb)->nh.iph->daddr; 148 daddr = (*pskb)->nh.iph->daddr;
149 tos = (*pskb)->nh.iph->tos; 149 tos = (*pskb)->nh.iph->tos;
@@ -153,9 +153,7 @@ ipt_local_hook(unsigned int hook,
153 if (ret != NF_DROP && ret != NF_STOLEN && ret != NF_QUEUE 153 if (ret != NF_DROP && ret != NF_STOLEN && ret != NF_QUEUE
154 && ((*pskb)->nh.iph->saddr != saddr 154 && ((*pskb)->nh.iph->saddr != saddr
155 || (*pskb)->nh.iph->daddr != daddr 155 || (*pskb)->nh.iph->daddr != daddr
156#ifdef CONFIG_IP_ROUTE_FWMARK 156 || (*pskb)->mark != mark
157 || (*pskb)->nfmark != nfmark
158#endif
159 || (*pskb)->nh.iph->tos != tos)) 157 || (*pskb)->nh.iph->tos != tos))
160 if (ip_route_me_harder(pskb, RTN_UNSPEC)) 158 if (ip_route_me_harder(pskb, RTN_UNSPEC))
161 ret = NF_DROP; 159 ret = NF_DROP;
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 0af803df82b0..471b638cedec 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -27,7 +27,7 @@
27#include <linux/netfilter_ipv4.h> 27#include <linux/netfilter_ipv4.h>
28#include <net/netfilter/nf_conntrack.h> 28#include <net/netfilter/nf_conntrack.h>
29#include <net/netfilter/nf_conntrack_helper.h> 29#include <net/netfilter/nf_conntrack_helper.h>
30#include <net/netfilter/nf_conntrack_protocol.h> 30#include <net/netfilter/nf_conntrack_l4proto.h>
31#include <net/netfilter/nf_conntrack_l3proto.h> 31#include <net/netfilter/nf_conntrack_l3proto.h>
32#include <net/netfilter/nf_conntrack_core.h> 32#include <net/netfilter/nf_conntrack_core.h>
33#include <net/netfilter/ipv4/nf_conntrack_ipv4.h> 33#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
@@ -38,12 +38,10 @@
38#define DEBUGP(format, args...) 38#define DEBUGP(format, args...)
39#endif 39#endif
40 40
41DECLARE_PER_CPU(struct nf_conntrack_stat, nf_conntrack_stat);
42
43static int ipv4_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff, 41static int ipv4_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff,
44 struct nf_conntrack_tuple *tuple) 42 struct nf_conntrack_tuple *tuple)
45{ 43{
46 u_int32_t _addrs[2], *ap; 44 __be32 _addrs[2], *ap;
47 ap = skb_header_pointer(skb, nhoff + offsetof(struct iphdr, saddr), 45 ap = skb_header_pointer(skb, nhoff + offsetof(struct iphdr, saddr),
48 sizeof(u_int32_t) * 2, _addrs); 46 sizeof(u_int32_t) * 2, _addrs);
49 if (ap == NULL) 47 if (ap == NULL)
@@ -113,10 +111,12 @@ ipv4_prepare(struct sk_buff **pskb, unsigned int hooknum, unsigned int *dataoff,
113 return NF_ACCEPT; 111 return NF_ACCEPT;
114} 112}
115 113
116int nat_module_is_loaded = 0; 114int nf_nat_module_is_loaded = 0;
115EXPORT_SYMBOL_GPL(nf_nat_module_is_loaded);
116
117static u_int32_t ipv4_get_features(const struct nf_conntrack_tuple *tuple) 117static u_int32_t ipv4_get_features(const struct nf_conntrack_tuple *tuple)
118{ 118{
119 if (nat_module_is_loaded) 119 if (nf_nat_module_is_loaded)
120 return NF_CT_F_NAT; 120 return NF_CT_F_NAT;
121 121
122 return NF_CT_F_BASIC; 122 return NF_CT_F_BASIC;
@@ -268,43 +268,59 @@ static struct nf_hook_ops ipv4_conntrack_ops[] = {
268 }, 268 },
269}; 269};
270 270
271#ifdef CONFIG_SYSCTL 271#if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
272/* From nf_conntrack_proto_icmp.c */ 272static int log_invalid_proto_min = 0;
273extern unsigned int nf_ct_icmp_timeout; 273static int log_invalid_proto_max = 255;
274static struct ctl_table_header *nf_ct_ipv4_sysctl_header;
275 274
276static ctl_table nf_ct_sysctl_table[] = { 275static ctl_table ip_ct_sysctl_table[] = {
277 { 276 {
278 .ctl_name = NET_NF_CONNTRACK_ICMP_TIMEOUT, 277 .ctl_name = NET_IPV4_NF_CONNTRACK_MAX,
279 .procname = "nf_conntrack_icmp_timeout", 278 .procname = "ip_conntrack_max",
280 .data = &nf_ct_icmp_timeout, 279 .data = &nf_conntrack_max,
281 .maxlen = sizeof(unsigned int), 280 .maxlen = sizeof(int),
282 .mode = 0644, 281 .mode = 0644,
283 .proc_handler = &proc_dointvec_jiffies, 282 .proc_handler = &proc_dointvec,
284 }, 283 },
285 { .ctl_name = 0 }
286};
287
288static ctl_table nf_ct_netfilter_table[] = {
289 { 284 {
290 .ctl_name = NET_NETFILTER, 285 .ctl_name = NET_IPV4_NF_CONNTRACK_COUNT,
291 .procname = "netfilter", 286 .procname = "ip_conntrack_count",
292 .mode = 0555, 287 .data = &nf_conntrack_count,
293 .child = nf_ct_sysctl_table, 288 .maxlen = sizeof(int),
289 .mode = 0444,
290 .proc_handler = &proc_dointvec,
291 },
292 {
293 .ctl_name = NET_IPV4_NF_CONNTRACK_BUCKETS,
294 .procname = "ip_conntrack_buckets",
295 .data = &nf_conntrack_htable_size,
296 .maxlen = sizeof(unsigned int),
297 .mode = 0444,
298 .proc_handler = &proc_dointvec,
299 },
300 {
301 .ctl_name = NET_IPV4_NF_CONNTRACK_CHECKSUM,
302 .procname = "ip_conntrack_checksum",
303 .data = &nf_conntrack_checksum,
304 .maxlen = sizeof(int),
305 .mode = 0644,
306 .proc_handler = &proc_dointvec,
294 }, 307 },
295 { .ctl_name = 0 }
296};
297
298static ctl_table nf_ct_net_table[] = {
299 { 308 {
300 .ctl_name = CTL_NET, 309 .ctl_name = NET_IPV4_NF_CONNTRACK_LOG_INVALID,
301 .procname = "net", 310 .procname = "ip_conntrack_log_invalid",
302 .mode = 0555, 311 .data = &nf_ct_log_invalid,
303 .child = nf_ct_netfilter_table, 312 .maxlen = sizeof(unsigned int),
313 .mode = 0644,
314 .proc_handler = &proc_dointvec_minmax,
315 .strategy = &sysctl_intvec,
316 .extra1 = &log_invalid_proto_min,
317 .extra2 = &log_invalid_proto_max,
304 }, 318 },
305 { .ctl_name = 0 } 319 {
320 .ctl_name = 0
321 }
306}; 322};
307#endif 323#endif /* CONFIG_SYSCTL && CONFIG_NF_CONNTRACK_PROC_COMPAT */
308 324
309/* Fast function for those who don't want to parse /proc (and I don't 325/* Fast function for those who don't want to parse /proc (and I don't
310 blame them). */ 326 blame them). */
@@ -396,10 +412,8 @@ static int ipv4_nfattr_to_tuple(struct nfattr *tb[],
396 if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) 412 if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip))
397 return -EINVAL; 413 return -EINVAL;
398 414
399 t->src.u3.ip = 415 t->src.u3.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_SRC-1]);
400 *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_SRC-1]); 416 t->dst.u3.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_DST-1]);
401 t->dst.u3.ip =
402 *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_DST-1]);
403 417
404 return 0; 418 return 0;
405} 419}
@@ -426,14 +440,15 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 = {
426 .tuple_to_nfattr = ipv4_tuple_to_nfattr, 440 .tuple_to_nfattr = ipv4_tuple_to_nfattr,
427 .nfattr_to_tuple = ipv4_nfattr_to_tuple, 441 .nfattr_to_tuple = ipv4_nfattr_to_tuple,
428#endif 442#endif
443#if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
444 .ctl_table_path = nf_net_ipv4_netfilter_sysctl_path,
445 .ctl_table = ip_ct_sysctl_table,
446#endif
429 .me = THIS_MODULE, 447 .me = THIS_MODULE,
430}; 448};
431 449
432extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp4;
433extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4;
434extern struct nf_conntrack_protocol nf_conntrack_protocol_icmp;
435
436MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET)); 450MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
451MODULE_ALIAS("ip_conntrack");
437MODULE_LICENSE("GPL"); 452MODULE_LICENSE("GPL");
438 453
439static int __init nf_conntrack_l3proto_ipv4_init(void) 454static int __init nf_conntrack_l3proto_ipv4_init(void)
@@ -448,19 +463,19 @@ static int __init nf_conntrack_l3proto_ipv4_init(void)
448 return ret; 463 return ret;
449 } 464 }
450 465
451 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_tcp4); 466 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_tcp4);
452 if (ret < 0) { 467 if (ret < 0) {
453 printk("nf_conntrack_ipv4: can't register tcp.\n"); 468 printk("nf_conntrack_ipv4: can't register tcp.\n");
454 goto cleanup_sockopt; 469 goto cleanup_sockopt;
455 } 470 }
456 471
457 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_udp4); 472 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_udp4);
458 if (ret < 0) { 473 if (ret < 0) {
459 printk("nf_conntrack_ipv4: can't register udp.\n"); 474 printk("nf_conntrack_ipv4: can't register udp.\n");
460 goto cleanup_tcp; 475 goto cleanup_tcp;
461 } 476 }
462 477
463 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_icmp); 478 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_icmp);
464 if (ret < 0) { 479 if (ret < 0) {
465 printk("nf_conntrack_ipv4: can't register icmp.\n"); 480 printk("nf_conntrack_ipv4: can't register icmp.\n");
466 goto cleanup_udp; 481 goto cleanup_udp;
@@ -478,28 +493,24 @@ static int __init nf_conntrack_l3proto_ipv4_init(void)
478 printk("nf_conntrack_ipv4: can't register hooks.\n"); 493 printk("nf_conntrack_ipv4: can't register hooks.\n");
479 goto cleanup_ipv4; 494 goto cleanup_ipv4;
480 } 495 }
481#ifdef CONFIG_SYSCTL 496#if defined(CONFIG_PROC_FS) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
482 nf_ct_ipv4_sysctl_header = register_sysctl_table(nf_ct_net_table, 0); 497 ret = nf_conntrack_ipv4_compat_init();
483 if (nf_ct_ipv4_sysctl_header == NULL) { 498 if (ret < 0)
484 printk("nf_conntrack: can't register to sysctl.\n");
485 ret = -ENOMEM;
486 goto cleanup_hooks; 499 goto cleanup_hooks;
487 }
488#endif 500#endif
489 return ret; 501 return ret;
490 502#if defined(CONFIG_PROC_FS) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
491#ifdef CONFIG_SYSCTL
492 cleanup_hooks: 503 cleanup_hooks:
493 nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops)); 504 nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
494#endif 505#endif
495 cleanup_ipv4: 506 cleanup_ipv4:
496 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4); 507 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
497 cleanup_icmp: 508 cleanup_icmp:
498 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmp); 509 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_icmp);
499 cleanup_udp: 510 cleanup_udp:
500 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp4); 511 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udp4);
501 cleanup_tcp: 512 cleanup_tcp:
502 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4); 513 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_tcp4);
503 cleanup_sockopt: 514 cleanup_sockopt:
504 nf_unregister_sockopt(&so_getorigdst); 515 nf_unregister_sockopt(&so_getorigdst);
505 return ret; 516 return ret;
@@ -508,18 +519,16 @@ static int __init nf_conntrack_l3proto_ipv4_init(void)
508static void __exit nf_conntrack_l3proto_ipv4_fini(void) 519static void __exit nf_conntrack_l3proto_ipv4_fini(void)
509{ 520{
510 synchronize_net(); 521 synchronize_net();
511#ifdef CONFIG_SYSCTL 522#if defined(CONFIG_PROC_FS) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
512 unregister_sysctl_table(nf_ct_ipv4_sysctl_header); 523 nf_conntrack_ipv4_compat_fini();
513#endif 524#endif
514 nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops)); 525 nf_unregister_hooks(ipv4_conntrack_ops, ARRAY_SIZE(ipv4_conntrack_ops));
515 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4); 526 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv4);
516 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmp); 527 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_icmp);
517 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp4); 528 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udp4);
518 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp4); 529 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_tcp4);
519 nf_unregister_sockopt(&so_getorigdst); 530 nf_unregister_sockopt(&so_getorigdst);
520} 531}
521 532
522module_init(nf_conntrack_l3proto_ipv4_init); 533module_init(nf_conntrack_l3proto_ipv4_init);
523module_exit(nf_conntrack_l3proto_ipv4_fini); 534module_exit(nf_conntrack_l3proto_ipv4_fini);
524
525EXPORT_SYMBOL(nf_ct_ipv4_gather_frags);
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
new file mode 100644
index 000000000000..3b31bc649608
--- /dev/null
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
@@ -0,0 +1,412 @@
1/* ip_conntrack proc compat - based on ip_conntrack_standalone.c
2 *
3 * (C) 1999-2001 Paul `Rusty' Russell
4 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
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#include <linux/types.h>
11#include <linux/proc_fs.h>
12#include <linux/seq_file.h>
13#include <linux/percpu.h>
14
15#include <linux/netfilter.h>
16#include <net/netfilter/nf_conntrack_core.h>
17#include <net/netfilter/nf_conntrack_l3proto.h>
18#include <net/netfilter/nf_conntrack_l4proto.h>
19#include <net/netfilter/nf_conntrack_expect.h>
20
21#if 0
22#define DEBUGP printk
23#else
24#define DEBUGP(format, args...)
25#endif
26
27#ifdef CONFIG_NF_CT_ACCT
28static unsigned int
29seq_print_counters(struct seq_file *s,
30 const struct ip_conntrack_counter *counter)
31{
32 return seq_printf(s, "packets=%llu bytes=%llu ",
33 (unsigned long long)counter->packets,
34 (unsigned long long)counter->bytes);
35}
36#else
37#define seq_print_counters(x, y) 0
38#endif
39
40struct ct_iter_state {
41 unsigned int bucket;
42};
43
44static struct list_head *ct_get_first(struct seq_file *seq)
45{
46 struct ct_iter_state *st = seq->private;
47
48 for (st->bucket = 0;
49 st->bucket < nf_conntrack_htable_size;
50 st->bucket++) {
51 if (!list_empty(&nf_conntrack_hash[st->bucket]))
52 return nf_conntrack_hash[st->bucket].next;
53 }
54 return NULL;
55}
56
57static struct list_head *ct_get_next(struct seq_file *seq, struct list_head *head)
58{
59 struct ct_iter_state *st = seq->private;
60
61 head = head->next;
62 while (head == &nf_conntrack_hash[st->bucket]) {
63 if (++st->bucket >= nf_conntrack_htable_size)
64 return NULL;
65 head = nf_conntrack_hash[st->bucket].next;
66 }
67 return head;
68}
69
70static struct list_head *ct_get_idx(struct seq_file *seq, loff_t pos)
71{
72 struct list_head *head = ct_get_first(seq);
73
74 if (head)
75 while (pos && (head = ct_get_next(seq, head)))
76 pos--;
77 return pos ? NULL : head;
78}
79
80static void *ct_seq_start(struct seq_file *seq, loff_t *pos)
81{
82 read_lock_bh(&nf_conntrack_lock);
83 return ct_get_idx(seq, *pos);
84}
85
86static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
87{
88 (*pos)++;
89 return ct_get_next(s, v);
90}
91
92static void ct_seq_stop(struct seq_file *s, void *v)
93{
94 read_unlock_bh(&nf_conntrack_lock);
95}
96
97static int ct_seq_show(struct seq_file *s, void *v)
98{
99 const struct nf_conntrack_tuple_hash *hash = v;
100 const struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(hash);
101 struct nf_conntrack_l3proto *l3proto;
102 struct nf_conntrack_l4proto *l4proto;
103
104 NF_CT_ASSERT(ct);
105
106 /* we only want to print DIR_ORIGINAL */
107 if (NF_CT_DIRECTION(hash))
108 return 0;
109 if (ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num != AF_INET)
110 return 0;
111
112 l3proto = __nf_ct_l3proto_find(ct->tuplehash[IP_CT_DIR_ORIGINAL]
113 .tuple.src.l3num);
114 NF_CT_ASSERT(l3proto);
115 l4proto = __nf_ct_l4proto_find(ct->tuplehash[IP_CT_DIR_ORIGINAL]
116 .tuple.src.l3num,
117 ct->tuplehash[IP_CT_DIR_ORIGINAL]
118 .tuple.dst.protonum);
119 NF_CT_ASSERT(l4proto);
120
121 if (seq_printf(s, "%-8s %u %ld ",
122 l4proto->name,
123 ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum,
124 timer_pending(&ct->timeout)
125 ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
126 return -ENOSPC;
127
128 if (l3proto->print_conntrack(s, ct))
129 return -ENOSPC;
130
131 if (l4proto->print_conntrack(s, ct))
132 return -ENOSPC;
133
134 if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
135 l3proto, l4proto))
136 return -ENOSPC;
137
138 if (seq_print_counters(s, &ct->counters[IP_CT_DIR_ORIGINAL]))
139 return -ENOSPC;
140
141 if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
142 if (seq_printf(s, "[UNREPLIED] "))
143 return -ENOSPC;
144
145 if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
146 l3proto, l4proto))
147 return -ENOSPC;
148
149 if (seq_print_counters(s, &ct->counters[IP_CT_DIR_REPLY]))
150 return -ENOSPC;
151
152 if (test_bit(IPS_ASSURED_BIT, &ct->status))
153 if (seq_printf(s, "[ASSURED] "))
154 return -ENOSPC;
155
156#ifdef CONFIG_NF_CONNTRACK_MARK
157 if (seq_printf(s, "mark=%u ", ct->mark))
158 return -ENOSPC;
159#endif
160
161#ifdef CONFIG_NF_CONNTRACK_SECMARK
162 if (seq_printf(s, "secmark=%u ", ct->secmark))
163 return -ENOSPC;
164#endif
165
166 if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)))
167 return -ENOSPC;
168
169 return 0;
170}
171
172static struct seq_operations ct_seq_ops = {
173 .start = ct_seq_start,
174 .next = ct_seq_next,
175 .stop = ct_seq_stop,
176 .show = ct_seq_show
177};
178
179static int ct_open(struct inode *inode, struct file *file)
180{
181 struct seq_file *seq;
182 struct ct_iter_state *st;
183 int ret;
184
185 st = kmalloc(sizeof(struct ct_iter_state), GFP_KERNEL);
186 if (st == NULL)
187 return -ENOMEM;
188 ret = seq_open(file, &ct_seq_ops);
189 if (ret)
190 goto out_free;
191 seq = file->private_data;
192 seq->private = st;
193 memset(st, 0, sizeof(struct ct_iter_state));
194 return ret;
195out_free:
196 kfree(st);
197 return ret;
198}
199
200static struct file_operations ct_file_ops = {
201 .owner = THIS_MODULE,
202 .open = ct_open,
203 .read = seq_read,
204 .llseek = seq_lseek,
205 .release = seq_release_private,
206};
207
208/* expects */
209static void *exp_seq_start(struct seq_file *s, loff_t *pos)
210{
211 struct list_head *e = &nf_conntrack_expect_list;
212 loff_t i;
213
214 /* strange seq_file api calls stop even if we fail,
215 * thus we need to grab lock since stop unlocks */
216 read_lock_bh(&nf_conntrack_lock);
217
218 if (list_empty(e))
219 return NULL;
220
221 for (i = 0; i <= *pos; i++) {
222 e = e->next;
223 if (e == &nf_conntrack_expect_list)
224 return NULL;
225 }
226 return e;
227}
228
229static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
230{
231 struct list_head *e = v;
232
233 ++*pos;
234 e = e->next;
235
236 if (e == &nf_conntrack_expect_list)
237 return NULL;
238
239 return e;
240}
241
242static void exp_seq_stop(struct seq_file *s, void *v)
243{
244 read_unlock_bh(&nf_conntrack_lock);
245}
246
247static int exp_seq_show(struct seq_file *s, void *v)
248{
249 struct nf_conntrack_expect *exp = v;
250
251 if (exp->tuple.src.l3num != AF_INET)
252 return 0;
253
254 if (exp->timeout.function)
255 seq_printf(s, "%ld ", timer_pending(&exp->timeout)
256 ? (long)(exp->timeout.expires - jiffies)/HZ : 0);
257 else
258 seq_printf(s, "- ");
259
260 seq_printf(s, "proto=%u ", exp->tuple.dst.protonum);
261
262 print_tuple(s, &exp->tuple,
263 __nf_ct_l3proto_find(exp->tuple.src.l3num),
264 __nf_ct_l4proto_find(exp->tuple.src.l3num,
265 exp->tuple.dst.protonum));
266 return seq_putc(s, '\n');
267}
268
269static struct seq_operations exp_seq_ops = {
270 .start = exp_seq_start,
271 .next = exp_seq_next,
272 .stop = exp_seq_stop,
273 .show = exp_seq_show
274};
275
276static int exp_open(struct inode *inode, struct file *file)
277{
278 return seq_open(file, &exp_seq_ops);
279}
280
281static struct file_operations ip_exp_file_ops = {
282 .owner = THIS_MODULE,
283 .open = exp_open,
284 .read = seq_read,
285 .llseek = seq_lseek,
286 .release = seq_release
287};
288
289static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
290{
291 int cpu;
292
293 if (*pos == 0)
294 return SEQ_START_TOKEN;
295
296 for (cpu = *pos-1; cpu < NR_CPUS; ++cpu) {
297 if (!cpu_possible(cpu))
298 continue;
299 *pos = cpu+1;
300 return &per_cpu(nf_conntrack_stat, cpu);
301 }
302
303 return NULL;
304}
305
306static void *ct_cpu_seq_next(struct seq_file *seq, void *v, loff_t *pos)
307{
308 int cpu;
309
310 for (cpu = *pos; cpu < NR_CPUS; ++cpu) {
311 if (!cpu_possible(cpu))
312 continue;
313 *pos = cpu+1;
314 return &per_cpu(nf_conntrack_stat, cpu);
315 }
316
317 return NULL;
318}
319
320static void ct_cpu_seq_stop(struct seq_file *seq, void *v)
321{
322}
323
324static int ct_cpu_seq_show(struct seq_file *seq, void *v)
325{
326 unsigned int nr_conntracks = atomic_read(&nf_conntrack_count);
327 struct ip_conntrack_stat *st = v;
328
329 if (v == SEQ_START_TOKEN) {
330 seq_printf(seq, "entries searched found new invalid ignore delete delete_list insert insert_failed drop early_drop icmp_error expect_new expect_create expect_delete\n");
331 return 0;
332 }
333
334 seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x "
335 "%08x %08x %08x %08x %08x %08x %08x %08x \n",
336 nr_conntracks,
337 st->searched,
338 st->found,
339 st->new,
340 st->invalid,
341 st->ignore,
342 st->delete,
343 st->delete_list,
344 st->insert,
345 st->insert_failed,
346 st->drop,
347 st->early_drop,
348 st->error,
349
350 st->expect_new,
351 st->expect_create,
352 st->expect_delete
353 );
354 return 0;
355}
356
357static struct seq_operations ct_cpu_seq_ops = {
358 .start = ct_cpu_seq_start,
359 .next = ct_cpu_seq_next,
360 .stop = ct_cpu_seq_stop,
361 .show = ct_cpu_seq_show,
362};
363
364static int ct_cpu_seq_open(struct inode *inode, struct file *file)
365{
366 return seq_open(file, &ct_cpu_seq_ops);
367}
368
369static struct file_operations ct_cpu_seq_fops = {
370 .owner = THIS_MODULE,
371 .open = ct_cpu_seq_open,
372 .read = seq_read,
373 .llseek = seq_lseek,
374 .release = seq_release_private,
375};
376
377int __init nf_conntrack_ipv4_compat_init(void)
378{
379 struct proc_dir_entry *proc, *proc_exp, *proc_stat;
380
381 proc = proc_net_fops_create("ip_conntrack", 0440, &ct_file_ops);
382 if (!proc)
383 goto err1;
384
385 proc_exp = proc_net_fops_create("ip_conntrack_expect", 0440,
386 &ip_exp_file_ops);
387 if (!proc_exp)
388 goto err2;
389
390 proc_stat = create_proc_entry("ip_conntrack", S_IRUGO, proc_net_stat);
391 if (!proc_stat)
392 goto err3;
393
394 proc_stat->proc_fops = &ct_cpu_seq_fops;
395 proc_stat->owner = THIS_MODULE;
396
397 return 0;
398
399err3:
400 proc_net_remove("ip_conntrack_expect");
401err2:
402 proc_net_remove("ip_conntrack");
403err1:
404 return -ENOMEM;
405}
406
407void __exit nf_conntrack_ipv4_compat_fini(void)
408{
409 remove_proc_entry("ip_conntrack", proc_net_stat);
410 proc_net_remove("ip_conntrack_expect");
411 proc_net_remove("ip_conntrack");
412}
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index 790f00d500c3..db9e7c45d3b4 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -22,10 +22,10 @@
22#include <net/checksum.h> 22#include <net/checksum.h>
23#include <linux/netfilter_ipv4.h> 23#include <linux/netfilter_ipv4.h>
24#include <net/netfilter/nf_conntrack_tuple.h> 24#include <net/netfilter/nf_conntrack_tuple.h>
25#include <net/netfilter/nf_conntrack_protocol.h> 25#include <net/netfilter/nf_conntrack_l4proto.h>
26#include <net/netfilter/nf_conntrack_core.h> 26#include <net/netfilter/nf_conntrack_core.h>
27 27
28unsigned long nf_ct_icmp_timeout __read_mostly = 30*HZ; 28static unsigned long nf_ct_icmp_timeout __read_mostly = 30*HZ;
29 29
30#if 0 30#if 0
31#define DEBUGP printk 31#define DEBUGP printk
@@ -152,7 +152,7 @@ icmp_error_message(struct sk_buff *skb,
152 struct icmphdr icmp; 152 struct icmphdr icmp;
153 struct iphdr ip; 153 struct iphdr ip;
154 } _in, *inside; 154 } _in, *inside;
155 struct nf_conntrack_protocol *innerproto; 155 struct nf_conntrack_l4proto *innerproto;
156 struct nf_conntrack_tuple_hash *h; 156 struct nf_conntrack_tuple_hash *h;
157 int dataoff; 157 int dataoff;
158 158
@@ -170,7 +170,7 @@ icmp_error_message(struct sk_buff *skb,
170 return -NF_ACCEPT; 170 return -NF_ACCEPT;
171 } 171 }
172 172
173 innerproto = __nf_ct_proto_find(PF_INET, inside->ip.protocol); 173 innerproto = __nf_ct_l4proto_find(PF_INET, inside->ip.protocol);
174 dataoff = skb->nh.iph->ihl*4 + sizeof(inside->icmp); 174 dataoff = skb->nh.iph->ihl*4 + sizeof(inside->icmp);
175 /* Are they talking about one of our connections? */ 175 /* Are they talking about one of our connections? */
176 if (!nf_ct_get_tuple(skb, dataoff, dataoff + inside->ip.ihl*4, PF_INET, 176 if (!nf_ct_get_tuple(skb, dataoff, dataoff + inside->ip.ihl*4, PF_INET,
@@ -311,7 +311,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[],
311 tuple->dst.u.icmp.code = 311 tuple->dst.u.icmp.code =
312 *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]); 312 *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]);
313 tuple->src.u.icmp.id = 313 tuple->src.u.icmp.id =
314 *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]); 314 *(__be16 *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]);
315 315
316 if (tuple->dst.u.icmp.type >= sizeof(invmap) 316 if (tuple->dst.u.icmp.type >= sizeof(invmap)
317 || !invmap[tuple->dst.u.icmp.type]) 317 || !invmap[tuple->dst.u.icmp.type])
@@ -321,11 +321,42 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[],
321} 321}
322#endif 322#endif
323 323
324struct nf_conntrack_protocol nf_conntrack_protocol_icmp = 324#ifdef CONFIG_SYSCTL
325static struct ctl_table_header *icmp_sysctl_header;
326static struct ctl_table icmp_sysctl_table[] = {
327 {
328 .ctl_name = NET_NF_CONNTRACK_ICMP_TIMEOUT,
329 .procname = "nf_conntrack_icmp_timeout",
330 .data = &nf_ct_icmp_timeout,
331 .maxlen = sizeof(unsigned int),
332 .mode = 0644,
333 .proc_handler = &proc_dointvec_jiffies,
334 },
335 {
336 .ctl_name = 0
337 }
338};
339#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
340static struct ctl_table icmp_compat_sysctl_table[] = {
341 {
342 .ctl_name = NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT,
343 .procname = "ip_conntrack_icmp_timeout",
344 .data = &nf_ct_icmp_timeout,
345 .maxlen = sizeof(unsigned int),
346 .mode = 0644,
347 .proc_handler = &proc_dointvec_jiffies,
348 },
349 {
350 .ctl_name = 0
351 }
352};
353#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
354#endif /* CONFIG_SYSCTL */
355
356struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp =
325{ 357{
326 .list = { NULL, NULL },
327 .l3proto = PF_INET, 358 .l3proto = PF_INET,
328 .proto = IPPROTO_ICMP, 359 .l4proto = IPPROTO_ICMP,
329 .name = "icmp", 360 .name = "icmp",
330 .pkt_to_tuple = icmp_pkt_to_tuple, 361 .pkt_to_tuple = icmp_pkt_to_tuple,
331 .invert_tuple = icmp_invert_tuple, 362 .invert_tuple = icmp_invert_tuple,
@@ -341,6 +372,12 @@ struct nf_conntrack_protocol nf_conntrack_protocol_icmp =
341 .tuple_to_nfattr = icmp_tuple_to_nfattr, 372 .tuple_to_nfattr = icmp_tuple_to_nfattr,
342 .nfattr_to_tuple = icmp_nfattr_to_tuple, 373 .nfattr_to_tuple = icmp_nfattr_to_tuple,
343#endif 374#endif
375#ifdef CONFIG_SYSCTL
376 .ctl_table_header = &icmp_sysctl_header,
377 .ctl_table = icmp_sysctl_table,
378#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
379 .ctl_compat_table = icmp_compat_sysctl_table,
380#endif
381#endif
344}; 382};
345 383EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_icmp);
346EXPORT_SYMBOL(nf_conntrack_protocol_icmp);
diff --git a/net/ipv4/netfilter/nf_nat_amanda.c b/net/ipv4/netfilter/nf_nat_amanda.c
new file mode 100644
index 000000000000..0f17098917bc
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_amanda.c
@@ -0,0 +1,78 @@
1/* Amanda extension for TCP NAT alteration.
2 * (C) 2002 by Brian J. Murrell <netfilter@interlinx.bc.ca>
3 * based on a copy of HW's ip_nat_irc.c as well as other modules
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/skbuff.h>
14#include <linux/udp.h>
15
16#include <net/netfilter/nf_nat_helper.h>
17#include <net/netfilter/nf_nat_rule.h>
18#include <net/netfilter/nf_conntrack_helper.h>
19#include <net/netfilter/nf_conntrack_expect.h>
20#include <linux/netfilter/nf_conntrack_amanda.h>
21
22MODULE_AUTHOR("Brian J. Murrell <netfilter@interlinx.bc.ca>");
23MODULE_DESCRIPTION("Amanda NAT helper");
24MODULE_LICENSE("GPL");
25MODULE_ALIAS("ip_nat_amanda");
26
27static unsigned int help(struct sk_buff **pskb,
28 enum ip_conntrack_info ctinfo,
29 unsigned int matchoff,
30 unsigned int matchlen,
31 struct nf_conntrack_expect *exp)
32{
33 char buffer[sizeof("65535")];
34 u_int16_t port;
35 unsigned int ret;
36
37 /* Connection comes from client. */
38 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
39 exp->dir = IP_CT_DIR_ORIGINAL;
40
41 /* When you see the packet, we need to NAT it the same as the
42 * this one (ie. same IP: it will be TCP and master is UDP). */
43 exp->expectfn = nf_nat_follow_master;
44
45 /* Try to get same port: if not, try to change it. */
46 for (port = ntohs(exp->saved_proto.tcp.port); port != 0; port++) {
47 exp->tuple.dst.u.tcp.port = htons(port);
48 if (nf_conntrack_expect_related(exp) == 0)
49 break;
50 }
51
52 if (port == 0)
53 return NF_DROP;
54
55 sprintf(buffer, "%u", port);
56 ret = nf_nat_mangle_udp_packet(pskb, exp->master, ctinfo,
57 matchoff, matchlen,
58 buffer, strlen(buffer));
59 if (ret != NF_ACCEPT)
60 nf_conntrack_unexpect_related(exp);
61 return ret;
62}
63
64static void __exit nf_nat_amanda_fini(void)
65{
66 rcu_assign_pointer(nf_nat_amanda_hook, NULL);
67 synchronize_rcu();
68}
69
70static int __init nf_nat_amanda_init(void)
71{
72 BUG_ON(rcu_dereference(nf_nat_amanda_hook));
73 rcu_assign_pointer(nf_nat_amanda_hook, help);
74 return 0;
75}
76
77module_init(nf_nat_amanda_init);
78module_exit(nf_nat_amanda_fini);
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
new file mode 100644
index 000000000000..86a92272b053
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -0,0 +1,647 @@
1/* NAT for netfilter; shared with compatibility layer. */
2
3/* (C) 1999-2001 Paul `Rusty' Russell
4 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
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/types.h>
13#include <linux/timer.h>
14#include <linux/skbuff.h>
15#include <linux/vmalloc.h>
16#include <net/checksum.h>
17#include <net/icmp.h>
18#include <net/ip.h>
19#include <net/tcp.h> /* For tcp_prot in getorigdst */
20#include <linux/icmp.h>
21#include <linux/udp.h>
22#include <linux/jhash.h>
23
24#include <linux/netfilter_ipv4.h>
25#include <net/netfilter/nf_conntrack.h>
26#include <net/netfilter/nf_conntrack_core.h>
27#include <net/netfilter/nf_nat.h>
28#include <net/netfilter/nf_nat_protocol.h>
29#include <net/netfilter/nf_nat_core.h>
30#include <net/netfilter/nf_nat_helper.h>
31#include <net/netfilter/nf_conntrack_helper.h>
32#include <net/netfilter/nf_conntrack_l3proto.h>
33#include <net/netfilter/nf_conntrack_l4proto.h>
34
35#if 0
36#define DEBUGP printk
37#else
38#define DEBUGP(format, args...)
39#endif
40
41static DEFINE_RWLOCK(nf_nat_lock);
42
43static struct nf_conntrack_l3proto *l3proto = NULL;
44
45/* Calculated at init based on memory size */
46static unsigned int nf_nat_htable_size;
47
48static struct list_head *bysource;
49
50#define MAX_IP_NAT_PROTO 256
51static struct nf_nat_protocol *nf_nat_protos[MAX_IP_NAT_PROTO];
52
53static inline struct nf_nat_protocol *
54__nf_nat_proto_find(u_int8_t protonum)
55{
56 return nf_nat_protos[protonum];
57}
58
59struct nf_nat_protocol *
60nf_nat_proto_find_get(u_int8_t protonum)
61{
62 struct nf_nat_protocol *p;
63
64 /* we need to disable preemption to make sure 'p' doesn't get
65 * removed until we've grabbed the reference */
66 preempt_disable();
67 p = __nf_nat_proto_find(protonum);
68 if (!try_module_get(p->me))
69 p = &nf_nat_unknown_protocol;
70 preempt_enable();
71
72 return p;
73}
74EXPORT_SYMBOL_GPL(nf_nat_proto_find_get);
75
76void
77nf_nat_proto_put(struct nf_nat_protocol *p)
78{
79 module_put(p->me);
80}
81EXPORT_SYMBOL_GPL(nf_nat_proto_put);
82
83/* We keep an extra hash for each conntrack, for fast searching. */
84static inline unsigned int
85hash_by_src(const struct nf_conntrack_tuple *tuple)
86{
87 /* Original src, to ensure we map it consistently if poss. */
88 return jhash_3words((__force u32)tuple->src.u3.ip, tuple->src.u.all,
89 tuple->dst.protonum, 0) % nf_nat_htable_size;
90}
91
92/* Noone using conntrack by the time this called. */
93static void nf_nat_cleanup_conntrack(struct nf_conn *conn)
94{
95 struct nf_conn_nat *nat;
96 if (!(conn->status & IPS_NAT_DONE_MASK))
97 return;
98
99 nat = nfct_nat(conn);
100 write_lock_bh(&nf_nat_lock);
101 list_del(&nat->info.bysource);
102 write_unlock_bh(&nf_nat_lock);
103}
104
105/* Is this tuple already taken? (not by us) */
106int
107nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
108 const struct nf_conn *ignored_conntrack)
109{
110 /* Conntrack tracking doesn't keep track of outgoing tuples; only
111 incoming ones. NAT means they don't have a fixed mapping,
112 so we invert the tuple and look for the incoming reply.
113
114 We could keep a separate hash if this proves too slow. */
115 struct nf_conntrack_tuple reply;
116
117 nf_ct_invert_tuplepr(&reply, tuple);
118 return nf_conntrack_tuple_taken(&reply, ignored_conntrack);
119}
120EXPORT_SYMBOL(nf_nat_used_tuple);
121
122/* If we source map this tuple so reply looks like reply_tuple, will
123 * that meet the constraints of range. */
124static int
125in_range(const struct nf_conntrack_tuple *tuple,
126 const struct nf_nat_range *range)
127{
128 struct nf_nat_protocol *proto;
129
130 proto = __nf_nat_proto_find(tuple->dst.protonum);
131 /* If we are supposed to map IPs, then we must be in the
132 range specified, otherwise let this drag us onto a new src IP. */
133 if (range->flags & IP_NAT_RANGE_MAP_IPS) {
134 if (ntohl(tuple->src.u3.ip) < ntohl(range->min_ip) ||
135 ntohl(tuple->src.u3.ip) > ntohl(range->max_ip))
136 return 0;
137 }
138
139 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) ||
140 proto->in_range(tuple, IP_NAT_MANIP_SRC,
141 &range->min, &range->max))
142 return 1;
143
144 return 0;
145}
146
147static inline int
148same_src(const struct nf_conn *ct,
149 const struct nf_conntrack_tuple *tuple)
150{
151 const struct nf_conntrack_tuple *t;
152
153 t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
154 return (t->dst.protonum == tuple->dst.protonum &&
155 t->src.u3.ip == tuple->src.u3.ip &&
156 t->src.u.all == tuple->src.u.all);
157}
158
159/* Only called for SRC manip */
160static int
161find_appropriate_src(const struct nf_conntrack_tuple *tuple,
162 struct nf_conntrack_tuple *result,
163 const struct nf_nat_range *range)
164{
165 unsigned int h = hash_by_src(tuple);
166 struct nf_conn_nat *nat;
167 struct nf_conn *ct;
168
169 read_lock_bh(&nf_nat_lock);
170 list_for_each_entry(nat, &bysource[h], info.bysource) {
171 ct = (struct nf_conn *)((char *)nat - offsetof(struct nf_conn, data));
172 if (same_src(ct, tuple)) {
173 /* Copy source part from reply tuple. */
174 nf_ct_invert_tuplepr(result,
175 &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
176 result->dst = tuple->dst;
177
178 if (in_range(result, range)) {
179 read_unlock_bh(&nf_nat_lock);
180 return 1;
181 }
182 }
183 }
184 read_unlock_bh(&nf_nat_lock);
185 return 0;
186}
187
188/* For [FUTURE] fragmentation handling, we want the least-used
189 src-ip/dst-ip/proto triple. Fairness doesn't come into it. Thus
190 if the range specifies 1.2.3.4 ports 10000-10005 and 1.2.3.5 ports
191 1-65535, we don't do pro-rata allocation based on ports; we choose
192 the ip with the lowest src-ip/dst-ip/proto usage.
193*/
194static void
195find_best_ips_proto(struct nf_conntrack_tuple *tuple,
196 const struct nf_nat_range *range,
197 const struct nf_conn *ct,
198 enum nf_nat_manip_type maniptype)
199{
200 __be32 *var_ipp;
201 /* Host order */
202 u_int32_t minip, maxip, j;
203
204 /* No IP mapping? Do nothing. */
205 if (!(range->flags & IP_NAT_RANGE_MAP_IPS))
206 return;
207
208 if (maniptype == IP_NAT_MANIP_SRC)
209 var_ipp = &tuple->src.u3.ip;
210 else
211 var_ipp = &tuple->dst.u3.ip;
212
213 /* Fast path: only one choice. */
214 if (range->min_ip == range->max_ip) {
215 *var_ipp = range->min_ip;
216 return;
217 }
218
219 /* Hashing source and destination IPs gives a fairly even
220 * spread in practice (if there are a small number of IPs
221 * involved, there usually aren't that many connections
222 * anyway). The consistency means that servers see the same
223 * client coming from the same IP (some Internet Banking sites
224 * like this), even across reboots. */
225 minip = ntohl(range->min_ip);
226 maxip = ntohl(range->max_ip);
227 j = jhash_2words((__force u32)tuple->src.u3.ip,
228 (__force u32)tuple->dst.u3.ip, 0);
229 *var_ipp = htonl(minip + j % (maxip - minip + 1));
230}
231
232/* Manipulate the tuple into the range given. For NF_IP_POST_ROUTING,
233 * we change the source to map into the range. For NF_IP_PRE_ROUTING
234 * and NF_IP_LOCAL_OUT, we change the destination to map into the
235 * range. It might not be possible to get a unique tuple, but we try.
236 * At worst (or if we race), we will end up with a final duplicate in
237 * __ip_conntrack_confirm and drop the packet. */
238static void
239get_unique_tuple(struct nf_conntrack_tuple *tuple,
240 const struct nf_conntrack_tuple *orig_tuple,
241 const struct nf_nat_range *range,
242 struct nf_conn *ct,
243 enum nf_nat_manip_type maniptype)
244{
245 struct nf_nat_protocol *proto;
246
247 /* 1) If this srcip/proto/src-proto-part is currently mapped,
248 and that same mapping gives a unique tuple within the given
249 range, use that.
250
251 This is only required for source (ie. NAT/masq) mappings.
252 So far, we don't do local source mappings, so multiple
253 manips not an issue. */
254 if (maniptype == IP_NAT_MANIP_SRC) {
255 if (find_appropriate_src(orig_tuple, tuple, range)) {
256 DEBUGP("get_unique_tuple: Found current src map\n");
257 if (!nf_nat_used_tuple(tuple, ct))
258 return;
259 }
260 }
261
262 /* 2) Select the least-used IP/proto combination in the given
263 range. */
264 *tuple = *orig_tuple;
265 find_best_ips_proto(tuple, range, ct, maniptype);
266
267 /* 3) The per-protocol part of the manip is made to map into
268 the range to make a unique tuple. */
269
270 proto = nf_nat_proto_find_get(orig_tuple->dst.protonum);
271
272 /* Only bother mapping if it's not already in range and unique */
273 if ((!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) ||
274 proto->in_range(tuple, maniptype, &range->min, &range->max)) &&
275 !nf_nat_used_tuple(tuple, ct)) {
276 nf_nat_proto_put(proto);
277 return;
278 }
279
280 /* Last change: get protocol to try to obtain unique tuple. */
281 proto->unique_tuple(tuple, range, maniptype, ct);
282
283 nf_nat_proto_put(proto);
284}
285
286unsigned int
287nf_nat_setup_info(struct nf_conn *ct,
288 const struct nf_nat_range *range,
289 unsigned int hooknum)
290{
291 struct nf_conntrack_tuple curr_tuple, new_tuple;
292 struct nf_conn_nat *nat = nfct_nat(ct);
293 struct nf_nat_info *info = &nat->info;
294 int have_to_hash = !(ct->status & IPS_NAT_DONE_MASK);
295 enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum);
296
297 NF_CT_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
298 hooknum == NF_IP_POST_ROUTING ||
299 hooknum == NF_IP_LOCAL_IN ||
300 hooknum == NF_IP_LOCAL_OUT);
301 BUG_ON(nf_nat_initialized(ct, maniptype));
302
303 /* What we've got will look like inverse of reply. Normally
304 this is what is in the conntrack, except for prior
305 manipulations (future optimization: if num_manips == 0,
306 orig_tp =
307 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple) */
308 nf_ct_invert_tuplepr(&curr_tuple,
309 &ct->tuplehash[IP_CT_DIR_REPLY].tuple);
310
311 get_unique_tuple(&new_tuple, &curr_tuple, range, ct, maniptype);
312
313 if (!nf_ct_tuple_equal(&new_tuple, &curr_tuple)) {
314 struct nf_conntrack_tuple reply;
315
316 /* Alter conntrack table so will recognize replies. */
317 nf_ct_invert_tuplepr(&reply, &new_tuple);
318 nf_conntrack_alter_reply(ct, &reply);
319
320 /* Non-atomic: we own this at the moment. */
321 if (maniptype == IP_NAT_MANIP_SRC)
322 ct->status |= IPS_SRC_NAT;
323 else
324 ct->status |= IPS_DST_NAT;
325 }
326
327 /* Place in source hash if this is the first time. */
328 if (have_to_hash) {
329 unsigned int srchash;
330
331 srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
332 write_lock_bh(&nf_nat_lock);
333 list_add(&info->bysource, &bysource[srchash]);
334 write_unlock_bh(&nf_nat_lock);
335 }
336
337 /* It's done. */
338 if (maniptype == IP_NAT_MANIP_DST)
339 set_bit(IPS_DST_NAT_DONE_BIT, &ct->status);
340 else
341 set_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
342
343 return NF_ACCEPT;
344}
345EXPORT_SYMBOL(nf_nat_setup_info);
346
347/* Returns true if succeeded. */
348static int
349manip_pkt(u_int16_t proto,
350 struct sk_buff **pskb,
351 unsigned int iphdroff,
352 const struct nf_conntrack_tuple *target,
353 enum nf_nat_manip_type maniptype)
354{
355 struct iphdr *iph;
356 struct nf_nat_protocol *p;
357
358 if (!skb_make_writable(pskb, iphdroff + sizeof(*iph)))
359 return 0;
360
361 iph = (void *)(*pskb)->data + iphdroff;
362
363 /* Manipulate protcol part. */
364 p = nf_nat_proto_find_get(proto);
365 if (!p->manip_pkt(pskb, iphdroff, target, maniptype)) {
366 nf_nat_proto_put(p);
367 return 0;
368 }
369 nf_nat_proto_put(p);
370
371 iph = (void *)(*pskb)->data + iphdroff;
372
373 if (maniptype == IP_NAT_MANIP_SRC) {
374 nf_csum_replace4(&iph->check, iph->saddr, target->src.u3.ip);
375 iph->saddr = target->src.u3.ip;
376 } else {
377 nf_csum_replace4(&iph->check, iph->daddr, target->dst.u3.ip);
378 iph->daddr = target->dst.u3.ip;
379 }
380 return 1;
381}
382
383/* Do packet manipulations according to nf_nat_setup_info. */
384unsigned int nf_nat_packet(struct nf_conn *ct,
385 enum ip_conntrack_info ctinfo,
386 unsigned int hooknum,
387 struct sk_buff **pskb)
388{
389 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
390 unsigned long statusbit;
391 enum nf_nat_manip_type mtype = HOOK2MANIP(hooknum);
392
393 if (mtype == IP_NAT_MANIP_SRC)
394 statusbit = IPS_SRC_NAT;
395 else
396 statusbit = IPS_DST_NAT;
397
398 /* Invert if this is reply dir. */
399 if (dir == IP_CT_DIR_REPLY)
400 statusbit ^= IPS_NAT_MASK;
401
402 /* Non-atomic: these bits don't change. */
403 if (ct->status & statusbit) {
404 struct nf_conntrack_tuple target;
405
406 /* We are aiming to look like inverse of other direction. */
407 nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
408
409 if (!manip_pkt(target.dst.protonum, pskb, 0, &target, mtype))
410 return NF_DROP;
411 }
412 return NF_ACCEPT;
413}
414EXPORT_SYMBOL_GPL(nf_nat_packet);
415
416/* Dir is direction ICMP is coming from (opposite to packet it contains) */
417int nf_nat_icmp_reply_translation(struct nf_conn *ct,
418 enum ip_conntrack_info ctinfo,
419 unsigned int hooknum,
420 struct sk_buff **pskb)
421{
422 struct {
423 struct icmphdr icmp;
424 struct iphdr ip;
425 } *inside;
426 struct nf_conntrack_tuple inner, target;
427 int hdrlen = (*pskb)->nh.iph->ihl * 4;
428 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
429 unsigned long statusbit;
430 enum nf_nat_manip_type manip = HOOK2MANIP(hooknum);
431
432 if (!skb_make_writable(pskb, hdrlen + sizeof(*inside)))
433 return 0;
434
435 inside = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
436
437 /* We're actually going to mangle it beyond trivial checksum
438 adjustment, so make sure the current checksum is correct. */
439 if (nf_ip_checksum(*pskb, hooknum, hdrlen, 0))
440 return 0;
441
442 /* Must be RELATED */
443 NF_CT_ASSERT((*pskb)->nfctinfo == IP_CT_RELATED ||
444 (*pskb)->nfctinfo == IP_CT_RELATED+IP_CT_IS_REPLY);
445
446 /* Redirects on non-null nats must be dropped, else they'll
447 start talking to each other without our translation, and be
448 confused... --RR */
449 if (inside->icmp.type == ICMP_REDIRECT) {
450 /* If NAT isn't finished, assume it and drop. */
451 if ((ct->status & IPS_NAT_DONE_MASK) != IPS_NAT_DONE_MASK)
452 return 0;
453
454 if (ct->status & IPS_NAT_MASK)
455 return 0;
456 }
457
458 DEBUGP("icmp_reply_translation: translating error %p manp %u dir %s\n",
459 *pskb, manip, dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY");
460
461 if (!nf_ct_get_tuple(*pskb,
462 (*pskb)->nh.iph->ihl*4 + sizeof(struct icmphdr),
463 (*pskb)->nh.iph->ihl*4 +
464 sizeof(struct icmphdr) + inside->ip.ihl*4,
465 (u_int16_t)AF_INET,
466 inside->ip.protocol,
467 &inner,
468 l3proto,
469 __nf_ct_l4proto_find((u_int16_t)PF_INET,
470 inside->ip.protocol)))
471 return 0;
472
473 /* Change inner back to look like incoming packet. We do the
474 opposite manip on this hook to normal, because it might not
475 pass all hooks (locally-generated ICMP). Consider incoming
476 packet: PREROUTING (DST manip), routing produces ICMP, goes
477 through POSTROUTING (which must correct the DST manip). */
478 if (!manip_pkt(inside->ip.protocol, pskb,
479 (*pskb)->nh.iph->ihl*4 + sizeof(inside->icmp),
480 &ct->tuplehash[!dir].tuple,
481 !manip))
482 return 0;
483
484 if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
485 /* Reloading "inside" here since manip_pkt inner. */
486 inside = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
487 inside->icmp.checksum = 0;
488 inside->icmp.checksum =
489 csum_fold(skb_checksum(*pskb, hdrlen,
490 (*pskb)->len - hdrlen, 0));
491 }
492
493 /* Change outer to look the reply to an incoming packet
494 * (proto 0 means don't invert per-proto part). */
495 if (manip == IP_NAT_MANIP_SRC)
496 statusbit = IPS_SRC_NAT;
497 else
498 statusbit = IPS_DST_NAT;
499
500 /* Invert if this is reply dir. */
501 if (dir == IP_CT_DIR_REPLY)
502 statusbit ^= IPS_NAT_MASK;
503
504 if (ct->status & statusbit) {
505 nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
506 if (!manip_pkt(0, pskb, 0, &target, manip))
507 return 0;
508 }
509
510 return 1;
511}
512EXPORT_SYMBOL_GPL(nf_nat_icmp_reply_translation);
513
514/* Protocol registration. */
515int nf_nat_protocol_register(struct nf_nat_protocol *proto)
516{
517 int ret = 0;
518
519 write_lock_bh(&nf_nat_lock);
520 if (nf_nat_protos[proto->protonum] != &nf_nat_unknown_protocol) {
521 ret = -EBUSY;
522 goto out;
523 }
524 nf_nat_protos[proto->protonum] = proto;
525 out:
526 write_unlock_bh(&nf_nat_lock);
527 return ret;
528}
529EXPORT_SYMBOL(nf_nat_protocol_register);
530
531/* Noone stores the protocol anywhere; simply delete it. */
532void nf_nat_protocol_unregister(struct nf_nat_protocol *proto)
533{
534 write_lock_bh(&nf_nat_lock);
535 nf_nat_protos[proto->protonum] = &nf_nat_unknown_protocol;
536 write_unlock_bh(&nf_nat_lock);
537
538 /* Someone could be still looking at the proto in a bh. */
539 synchronize_net();
540}
541EXPORT_SYMBOL(nf_nat_protocol_unregister);
542
543#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
544 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
545int
546nf_nat_port_range_to_nfattr(struct sk_buff *skb,
547 const struct nf_nat_range *range)
548{
549 NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16),
550 &range->min.tcp.port);
551 NFA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16),
552 &range->max.tcp.port);
553
554 return 0;
555
556nfattr_failure:
557 return -1;
558}
559EXPORT_SYMBOL_GPL(nf_nat_port_nfattr_to_range);
560
561int
562nf_nat_port_nfattr_to_range(struct nfattr *tb[], struct nf_nat_range *range)
563{
564 int ret = 0;
565
566 /* we have to return whether we actually parsed something or not */
567
568 if (tb[CTA_PROTONAT_PORT_MIN-1]) {
569 ret = 1;
570 range->min.tcp.port =
571 *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]);
572 }
573
574 if (!tb[CTA_PROTONAT_PORT_MAX-1]) {
575 if (ret)
576 range->max.tcp.port = range->min.tcp.port;
577 } else {
578 ret = 1;
579 range->max.tcp.port =
580 *(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]);
581 }
582
583 return ret;
584}
585EXPORT_SYMBOL_GPL(nf_nat_port_range_to_nfattr);
586#endif
587
588static int __init nf_nat_init(void)
589{
590 size_t i;
591
592 /* Leave them the same for the moment. */
593 nf_nat_htable_size = nf_conntrack_htable_size;
594
595 /* One vmalloc for both hash tables */
596 bysource = vmalloc(sizeof(struct list_head) * nf_nat_htable_size);
597 if (!bysource)
598 return -ENOMEM;
599
600 /* Sew in builtin protocols. */
601 write_lock_bh(&nf_nat_lock);
602 for (i = 0; i < MAX_IP_NAT_PROTO; i++)
603 nf_nat_protos[i] = &nf_nat_unknown_protocol;
604 nf_nat_protos[IPPROTO_TCP] = &nf_nat_protocol_tcp;
605 nf_nat_protos[IPPROTO_UDP] = &nf_nat_protocol_udp;
606 nf_nat_protos[IPPROTO_ICMP] = &nf_nat_protocol_icmp;
607 write_unlock_bh(&nf_nat_lock);
608
609 for (i = 0; i < nf_nat_htable_size; i++) {
610 INIT_LIST_HEAD(&bysource[i]);
611 }
612
613 /* FIXME: Man, this is a hack. <SIGH> */
614 NF_CT_ASSERT(nf_conntrack_destroyed == NULL);
615 nf_conntrack_destroyed = &nf_nat_cleanup_conntrack;
616
617 /* Initialize fake conntrack so that NAT will skip it */
618 nf_conntrack_untracked.status |= IPS_NAT_DONE_MASK;
619
620 l3proto = nf_ct_l3proto_find_get((u_int16_t)AF_INET);
621 return 0;
622}
623
624/* Clear NAT section of all conntracks, in case we're loaded again. */
625static int clean_nat(struct nf_conn *i, void *data)
626{
627 struct nf_conn_nat *nat = nfct_nat(i);
628
629 if (!nat)
630 return 0;
631 memset(nat, 0, sizeof(nat));
632 i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK | IPS_SEQ_ADJUST);
633 return 0;
634}
635
636static void __exit nf_nat_cleanup(void)
637{
638 nf_ct_iterate_cleanup(&clean_nat, NULL);
639 nf_conntrack_destroyed = NULL;
640 vfree(bysource);
641 nf_ct_l3proto_put(l3proto);
642}
643
644MODULE_LICENSE("GPL");
645
646module_init(nf_nat_init);
647module_exit(nf_nat_cleanup);
diff --git a/net/ipv4/netfilter/nf_nat_ftp.c b/net/ipv4/netfilter/nf_nat_ftp.c
new file mode 100644
index 000000000000..751b59801755
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_ftp.c
@@ -0,0 +1,179 @@
1/* FTP extension for TCP NAT alteration. */
2
3/* (C) 1999-2001 Paul `Rusty' Russell
4 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
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/moduleparam.h>
13#include <linux/ip.h>
14#include <linux/tcp.h>
15#include <linux/netfilter_ipv4.h>
16#include <net/netfilter/nf_nat.h>
17#include <net/netfilter/nf_nat_helper.h>
18#include <net/netfilter/nf_nat_rule.h>
19#include <net/netfilter/nf_conntrack_helper.h>
20#include <net/netfilter/nf_conntrack_expect.h>
21#include <linux/netfilter/nf_conntrack_ftp.h>
22
23MODULE_LICENSE("GPL");
24MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
25MODULE_DESCRIPTION("ftp NAT helper");
26MODULE_ALIAS("ip_nat_ftp");
27
28#if 0
29#define DEBUGP printk
30#else
31#define DEBUGP(format, args...)
32#endif
33
34/* FIXME: Time out? --RR */
35
36static int
37mangle_rfc959_packet(struct sk_buff **pskb,
38 __be32 newip,
39 u_int16_t port,
40 unsigned int matchoff,
41 unsigned int matchlen,
42 struct nf_conn *ct,
43 enum ip_conntrack_info ctinfo,
44 u32 *seq)
45{
46 char buffer[sizeof("nnn,nnn,nnn,nnn,nnn,nnn")];
47
48 sprintf(buffer, "%u,%u,%u,%u,%u,%u",
49 NIPQUAD(newip), port>>8, port&0xFF);
50
51 DEBUGP("calling nf_nat_mangle_tcp_packet\n");
52
53 *seq += strlen(buffer) - matchlen;
54 return nf_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff,
55 matchlen, buffer, strlen(buffer));
56}
57
58/* |1|132.235.1.2|6275| */
59static int
60mangle_eprt_packet(struct sk_buff **pskb,
61 __be32 newip,
62 u_int16_t port,
63 unsigned int matchoff,
64 unsigned int matchlen,
65 struct nf_conn *ct,
66 enum ip_conntrack_info ctinfo,
67 u32 *seq)
68{
69 char buffer[sizeof("|1|255.255.255.255|65535|")];
70
71 sprintf(buffer, "|1|%u.%u.%u.%u|%u|", NIPQUAD(newip), port);
72
73 DEBUGP("calling nf_nat_mangle_tcp_packet\n");
74
75 *seq += strlen(buffer) - matchlen;
76 return nf_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff,
77 matchlen, buffer, strlen(buffer));
78}
79
80/* |1|132.235.1.2|6275| */
81static int
82mangle_epsv_packet(struct sk_buff **pskb,
83 __be32 newip,
84 u_int16_t port,
85 unsigned int matchoff,
86 unsigned int matchlen,
87 struct nf_conn *ct,
88 enum ip_conntrack_info ctinfo,
89 u32 *seq)
90{
91 char buffer[sizeof("|||65535|")];
92
93 sprintf(buffer, "|||%u|", port);
94
95 DEBUGP("calling nf_nat_mangle_tcp_packet\n");
96
97 *seq += strlen(buffer) - matchlen;
98 return nf_nat_mangle_tcp_packet(pskb, ct, ctinfo, matchoff,
99 matchlen, buffer, strlen(buffer));
100}
101
102static int (*mangle[])(struct sk_buff **, __be32, u_int16_t,
103 unsigned int, unsigned int, struct nf_conn *,
104 enum ip_conntrack_info, u32 *seq)
105= {
106 [NF_CT_FTP_PORT] = mangle_rfc959_packet,
107 [NF_CT_FTP_PASV] = mangle_rfc959_packet,
108 [NF_CT_FTP_EPRT] = mangle_eprt_packet,
109 [NF_CT_FTP_EPSV] = mangle_epsv_packet
110};
111
112/* So, this packet has hit the connection tracking matching code.
113 Mangle it, and change the expectation to match the new version. */
114static unsigned int nf_nat_ftp(struct sk_buff **pskb,
115 enum ip_conntrack_info ctinfo,
116 enum nf_ct_ftp_type type,
117 unsigned int matchoff,
118 unsigned int matchlen,
119 struct nf_conntrack_expect *exp,
120 u32 *seq)
121{
122 __be32 newip;
123 u_int16_t port;
124 int dir = CTINFO2DIR(ctinfo);
125 struct nf_conn *ct = exp->master;
126
127 DEBUGP("FTP_NAT: type %i, off %u len %u\n", type, matchoff, matchlen);
128
129 /* Connection will come from wherever this packet goes, hence !dir */
130 newip = ct->tuplehash[!dir].tuple.dst.u3.ip;
131 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
132 exp->dir = !dir;
133
134 /* When you see the packet, we need to NAT it the same as the
135 * this one. */
136 exp->expectfn = nf_nat_follow_master;
137
138 /* Try to get same port: if not, try to change it. */
139 for (port = ntohs(exp->saved_proto.tcp.port); port != 0; port++) {
140 exp->tuple.dst.u.tcp.port = htons(port);
141 if (nf_conntrack_expect_related(exp) == 0)
142 break;
143 }
144
145 if (port == 0)
146 return NF_DROP;
147
148 if (!mangle[type](pskb, newip, port, matchoff, matchlen, ct, ctinfo,
149 seq)) {
150 nf_conntrack_unexpect_related(exp);
151 return NF_DROP;
152 }
153 return NF_ACCEPT;
154}
155
156static void __exit nf_nat_ftp_fini(void)
157{
158 rcu_assign_pointer(nf_nat_ftp_hook, NULL);
159 synchronize_rcu();
160}
161
162static int __init nf_nat_ftp_init(void)
163{
164 BUG_ON(rcu_dereference(nf_nat_ftp_hook));
165 rcu_assign_pointer(nf_nat_ftp_hook, nf_nat_ftp);
166 return 0;
167}
168
169/* Prior to 2.6.11, we had a ports param. No longer, but don't break users. */
170static int warn_set(const char *val, struct kernel_param *kp)
171{
172 printk(KERN_INFO KBUILD_MODNAME
173 ": kernel >= 2.6.10 only uses 'ports' for conntrack modules\n");
174 return 0;
175}
176module_param_call(ports, warn_set, NULL, NULL, 0);
177
178module_init(nf_nat_ftp_init);
179module_exit(nf_nat_ftp_fini);
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c
new file mode 100644
index 000000000000..fb9ab0114c23
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_h323.c
@@ -0,0 +1,596 @@
1/*
2 * H.323 extension for NAT alteration.
3 *
4 * Copyright (c) 2006 Jing Min Zhao <zhaojingmin@users.sourceforge.net>
5 *
6 * This source code is licensed under General Public License version 2.
7 *
8 * Based on the 'brute force' H.323 NAT module by
9 * Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 */
11
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/tcp.h>
15#include <net/tcp.h>
16
17#include <net/netfilter/nf_nat.h>
18#include <net/netfilter/nf_nat_helper.h>
19#include <net/netfilter/nf_nat_rule.h>
20#include <net/netfilter/nf_conntrack_helper.h>
21#include <net/netfilter/nf_conntrack_expect.h>
22#include <linux/netfilter/nf_conntrack_h323.h>
23
24#if 0
25#define DEBUGP printk
26#else
27#define DEBUGP(format, args...)
28#endif
29
30/****************************************************************************/
31static int set_addr(struct sk_buff **pskb,
32 unsigned char **data, int dataoff,
33 unsigned int addroff, __be32 ip, __be16 port)
34{
35 enum ip_conntrack_info ctinfo;
36 struct nf_conn *ct = ip_conntrack_get(*pskb, &ctinfo);
37 struct {
38 __be32 ip;
39 __be16 port;
40 } __attribute__ ((__packed__)) buf;
41 struct tcphdr _tcph, *th;
42
43 buf.ip = ip;
44 buf.port = port;
45 addroff += dataoff;
46
47 if ((*pskb)->nh.iph->protocol == IPPROTO_TCP) {
48 if (!nf_nat_mangle_tcp_packet(pskb, ct, ctinfo,
49 addroff, sizeof(buf),
50 (char *) &buf, sizeof(buf))) {
51 if (net_ratelimit())
52 printk("nf_nat_h323: nf_nat_mangle_tcp_packet"
53 " error\n");
54 return -1;
55 }
56
57 /* Relocate data pointer */
58 th = skb_header_pointer(*pskb, (*pskb)->nh.iph->ihl * 4,
59 sizeof(_tcph), &_tcph);
60 if (th == NULL)
61 return -1;
62 *data = (*pskb)->data + (*pskb)->nh.iph->ihl * 4 +
63 th->doff * 4 + dataoff;
64 } else {
65 if (!nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
66 addroff, sizeof(buf),
67 (char *) &buf, sizeof(buf))) {
68 if (net_ratelimit())
69 printk("nf_nat_h323: nf_nat_mangle_udp_packet"
70 " error\n");
71 return -1;
72 }
73 /* nf_nat_mangle_udp_packet uses skb_make_writable() to copy
74 * or pull everything in a linear buffer, so we can safely
75 * use the skb pointers now */
76 *data = (*pskb)->data + (*pskb)->nh.iph->ihl * 4 +
77 sizeof(struct udphdr);
78 }
79
80 return 0;
81}
82
83/****************************************************************************/
84static int set_h225_addr(struct sk_buff **pskb,
85 unsigned char **data, int dataoff,
86 TransportAddress *taddr,
87 union nf_conntrack_address *addr, __be16 port)
88{
89 return set_addr(pskb, data, dataoff, taddr->ipAddress.ip,
90 addr->ip, port);
91}
92
93/****************************************************************************/
94static int set_h245_addr(struct sk_buff **pskb,
95 unsigned char **data, int dataoff,
96 H245_TransportAddress *taddr,
97 union nf_conntrack_address *addr, __be16 port)
98{
99 return set_addr(pskb, data, dataoff,
100 taddr->unicastAddress.iPAddress.network,
101 addr->ip, port);
102}
103
104/****************************************************************************/
105static int set_sig_addr(struct sk_buff **pskb, struct nf_conn *ct,
106 enum ip_conntrack_info ctinfo,
107 unsigned char **data,
108 TransportAddress *taddr, int count)
109{
110 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
111 int dir = CTINFO2DIR(ctinfo);
112 int i;
113 __be16 port;
114 union nf_conntrack_address addr;
115
116 for (i = 0; i < count; i++) {
117 if (get_h225_addr(ct, *data, &taddr[i], &addr, &port)) {
118 if (addr.ip == ct->tuplehash[dir].tuple.src.u3.ip &&
119 port == info->sig_port[dir]) {
120 /* GW->GK */
121
122 /* Fix for Gnomemeeting */
123 if (i > 0 &&
124 get_h225_addr(ct, *data, &taddr[0],
125 &addr, &port) &&
126 (ntohl(addr.ip) & 0xff000000) == 0x7f000000)
127 i = 0;
128
129 DEBUGP
130 ("nf_nat_ras: set signal address "
131 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
132 NIPQUAD(ip), port,
133 NIPQUAD(ct->tuplehash[!dir].tuple.dst.
134 ip), info->sig_port[!dir]);
135 return set_h225_addr(pskb, data, 0, &taddr[i],
136 &ct->tuplehash[!dir].
137 tuple.dst.u3,
138 info->sig_port[!dir]);
139 } else if (addr.ip == ct->tuplehash[dir].tuple.dst.u3.ip &&
140 port == info->sig_port[dir]) {
141 /* GK->GW */
142 DEBUGP
143 ("nf_nat_ras: set signal address "
144 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
145 NIPQUAD(ip), port,
146 NIPQUAD(ct->tuplehash[!dir].tuple.src.
147 ip), info->sig_port[!dir]);
148 return set_h225_addr(pskb, data, 0, &taddr[i],
149 &ct->tuplehash[!dir].
150 tuple.src.u3,
151 info->sig_port[!dir]);
152 }
153 }
154 }
155
156 return 0;
157}
158
159/****************************************************************************/
160static int set_ras_addr(struct sk_buff **pskb, struct nf_conn *ct,
161 enum ip_conntrack_info ctinfo,
162 unsigned char **data,
163 TransportAddress *taddr, int count)
164{
165 int dir = CTINFO2DIR(ctinfo);
166 int i;
167 __be16 port;
168 union nf_conntrack_address addr;
169
170 for (i = 0; i < count; i++) {
171 if (get_h225_addr(ct, *data, &taddr[i], &addr, &port) &&
172 addr.ip == ct->tuplehash[dir].tuple.src.u3.ip &&
173 port == ct->tuplehash[dir].tuple.src.u.udp.port) {
174 DEBUGP("nf_nat_ras: set rasAddress "
175 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
176 NIPQUAD(ip), ntohs(port),
177 NIPQUAD(ct->tuplehash[!dir].tuple.dst.u3.ip),
178 ntohs(ct->tuplehash[!dir].tuple.dst.u.udp.
179 port));
180 return set_h225_addr(pskb, data, 0, &taddr[i],
181 &ct->tuplehash[!dir].tuple.dst.u3,
182 ct->tuplehash[!dir].tuple.
183 dst.u.udp.port);
184 }
185 }
186
187 return 0;
188}
189
190/****************************************************************************/
191static int nat_rtp_rtcp(struct sk_buff **pskb, struct nf_conn *ct,
192 enum ip_conntrack_info ctinfo,
193 unsigned char **data, int dataoff,
194 H245_TransportAddress *taddr,
195 __be16 port, __be16 rtp_port,
196 struct nf_conntrack_expect *rtp_exp,
197 struct nf_conntrack_expect *rtcp_exp)
198{
199 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
200 int dir = CTINFO2DIR(ctinfo);
201 int i;
202 u_int16_t nated_port;
203
204 /* Set expectations for NAT */
205 rtp_exp->saved_proto.udp.port = rtp_exp->tuple.dst.u.udp.port;
206 rtp_exp->expectfn = nf_nat_follow_master;
207 rtp_exp->dir = !dir;
208 rtcp_exp->saved_proto.udp.port = rtcp_exp->tuple.dst.u.udp.port;
209 rtcp_exp->expectfn = nf_nat_follow_master;
210 rtcp_exp->dir = !dir;
211
212 /* Lookup existing expects */
213 for (i = 0; i < H323_RTP_CHANNEL_MAX; i++) {
214 if (info->rtp_port[i][dir] == rtp_port) {
215 /* Expected */
216
217 /* Use allocated ports first. This will refresh
218 * the expects */
219 rtp_exp->tuple.dst.u.udp.port = info->rtp_port[i][dir];
220 rtcp_exp->tuple.dst.u.udp.port =
221 htons(ntohs(info->rtp_port[i][dir]) + 1);
222 break;
223 } else if (info->rtp_port[i][dir] == 0) {
224 /* Not expected */
225 break;
226 }
227 }
228
229 /* Run out of expectations */
230 if (i >= H323_RTP_CHANNEL_MAX) {
231 if (net_ratelimit())
232 printk("nf_nat_h323: out of expectations\n");
233 return 0;
234 }
235
236 /* Try to get a pair of ports. */
237 for (nated_port = ntohs(rtp_exp->tuple.dst.u.udp.port);
238 nated_port != 0; nated_port += 2) {
239 rtp_exp->tuple.dst.u.udp.port = htons(nated_port);
240 if (nf_conntrack_expect_related(rtp_exp) == 0) {
241 rtcp_exp->tuple.dst.u.udp.port =
242 htons(nated_port + 1);
243 if (nf_conntrack_expect_related(rtcp_exp) == 0)
244 break;
245 nf_conntrack_unexpect_related(rtp_exp);
246 }
247 }
248
249 if (nated_port == 0) { /* No port available */
250 if (net_ratelimit())
251 printk("nf_nat_h323: out of RTP ports\n");
252 return 0;
253 }
254
255 /* Modify signal */
256 if (set_h245_addr(pskb, data, dataoff, taddr,
257 &ct->tuplehash[!dir].tuple.dst.u3,
258 htons((port & htons(1)) ? nated_port + 1 :
259 nated_port)) == 0) {
260 /* Save ports */
261 info->rtp_port[i][dir] = rtp_port;
262 info->rtp_port[i][!dir] = htons(nated_port);
263 } else {
264 nf_conntrack_unexpect_related(rtp_exp);
265 nf_conntrack_unexpect_related(rtcp_exp);
266 return -1;
267 }
268
269 /* Success */
270 DEBUGP("nf_nat_h323: expect RTP %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
271 NIPQUAD(rtp_exp->tuple.src.ip),
272 ntohs(rtp_exp->tuple.src.u.udp.port),
273 NIPQUAD(rtp_exp->tuple.dst.ip),
274 ntohs(rtp_exp->tuple.dst.u.udp.port));
275 DEBUGP("nf_nat_h323: expect RTCP %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
276 NIPQUAD(rtcp_exp->tuple.src.ip),
277 ntohs(rtcp_exp->tuple.src.u.udp.port),
278 NIPQUAD(rtcp_exp->tuple.dst.ip),
279 ntohs(rtcp_exp->tuple.dst.u.udp.port));
280
281 return 0;
282}
283
284/****************************************************************************/
285static int nat_t120(struct sk_buff **pskb, struct nf_conn *ct,
286 enum ip_conntrack_info ctinfo,
287 unsigned char **data, int dataoff,
288 H245_TransportAddress *taddr, __be16 port,
289 struct nf_conntrack_expect *exp)
290{
291 int dir = CTINFO2DIR(ctinfo);
292 u_int16_t nated_port = ntohs(port);
293
294 /* Set expectations for NAT */
295 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
296 exp->expectfn = nf_nat_follow_master;
297 exp->dir = !dir;
298
299 /* Try to get same port: if not, try to change it. */
300 for (; nated_port != 0; nated_port++) {
301 exp->tuple.dst.u.tcp.port = htons(nated_port);
302 if (nf_conntrack_expect_related(exp) == 0)
303 break;
304 }
305
306 if (nated_port == 0) { /* No port available */
307 if (net_ratelimit())
308 printk("nf_nat_h323: out of TCP ports\n");
309 return 0;
310 }
311
312 /* Modify signal */
313 if (set_h245_addr(pskb, data, dataoff, taddr,
314 &ct->tuplehash[!dir].tuple.dst.u3,
315 htons(nated_port)) < 0) {
316 nf_conntrack_unexpect_related(exp);
317 return -1;
318 }
319
320 DEBUGP("nf_nat_h323: expect T.120 %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
321 NIPQUAD(exp->tuple.src.ip), ntohs(exp->tuple.src.u.tcp.port),
322 NIPQUAD(exp->tuple.dst.ip), ntohs(exp->tuple.dst.u.tcp.port));
323
324 return 0;
325}
326
327/****************************************************************************/
328static int nat_h245(struct sk_buff **pskb, struct nf_conn *ct,
329 enum ip_conntrack_info ctinfo,
330 unsigned char **data, int dataoff,
331 TransportAddress *taddr, __be16 port,
332 struct nf_conntrack_expect *exp)
333{
334 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
335 int dir = CTINFO2DIR(ctinfo);
336 u_int16_t nated_port = ntohs(port);
337
338 /* Set expectations for NAT */
339 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
340 exp->expectfn = nf_nat_follow_master;
341 exp->dir = !dir;
342
343 /* Check existing expects */
344 if (info->sig_port[dir] == port)
345 nated_port = ntohs(info->sig_port[!dir]);
346
347 /* Try to get same port: if not, try to change it. */
348 for (; nated_port != 0; nated_port++) {
349 exp->tuple.dst.u.tcp.port = htons(nated_port);
350 if (nf_conntrack_expect_related(exp) == 0)
351 break;
352 }
353
354 if (nated_port == 0) { /* No port available */
355 if (net_ratelimit())
356 printk("nf_nat_q931: out of TCP ports\n");
357 return 0;
358 }
359
360 /* Modify signal */
361 if (set_h225_addr(pskb, data, dataoff, taddr,
362 &ct->tuplehash[!dir].tuple.dst.u3,
363 htons(nated_port)) == 0) {
364 /* Save ports */
365 info->sig_port[dir] = port;
366 info->sig_port[!dir] = htons(nated_port);
367 } else {
368 nf_conntrack_unexpect_related(exp);
369 return -1;
370 }
371
372 DEBUGP("nf_nat_q931: expect H.245 %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
373 NIPQUAD(exp->tuple.src.ip), ntohs(exp->tuple.src.u.tcp.port),
374 NIPQUAD(exp->tuple.dst.ip), ntohs(exp->tuple.dst.u.tcp.port));
375
376 return 0;
377}
378
379/****************************************************************************
380 * This conntrack expect function replaces nf_conntrack_q931_expect()
381 * which was set by nf_conntrack_h323.c.
382 ****************************************************************************/
383static void ip_nat_q931_expect(struct nf_conn *new,
384 struct nf_conntrack_expect *this)
385{
386 struct ip_nat_range range;
387
388 if (this->tuple.src.u3.ip != 0) { /* Only accept calls from GK */
389 nf_nat_follow_master(new, this);
390 return;
391 }
392
393 /* This must be a fresh one. */
394 BUG_ON(new->status & IPS_NAT_DONE_MASK);
395
396 /* Change src to where master sends to */
397 range.flags = IP_NAT_RANGE_MAP_IPS;
398 range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.u3.ip;
399
400 /* hook doesn't matter, but it has to do source manip */
401 nf_nat_setup_info(new, &range, NF_IP_POST_ROUTING);
402
403 /* For DST manip, map port here to where it's expected. */
404 range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED);
405 range.min = range.max = this->saved_proto;
406 range.min_ip = range.max_ip =
407 new->master->tuplehash[!this->dir].tuple.src.u3.ip;
408
409 /* hook doesn't matter, but it has to do destination manip */
410 nf_nat_setup_info(new, &range, NF_IP_PRE_ROUTING);
411}
412
413/****************************************************************************/
414static int nat_q931(struct sk_buff **pskb, struct nf_conn *ct,
415 enum ip_conntrack_info ctinfo,
416 unsigned char **data, TransportAddress *taddr, int idx,
417 __be16 port, struct nf_conntrack_expect *exp)
418{
419 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
420 int dir = CTINFO2DIR(ctinfo);
421 u_int16_t nated_port = ntohs(port);
422 union nf_conntrack_address addr;
423
424 /* Set expectations for NAT */
425 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
426 exp->expectfn = ip_nat_q931_expect;
427 exp->dir = !dir;
428
429 /* Check existing expects */
430 if (info->sig_port[dir] == port)
431 nated_port = ntohs(info->sig_port[!dir]);
432
433 /* Try to get same port: if not, try to change it. */
434 for (; nated_port != 0; nated_port++) {
435 exp->tuple.dst.u.tcp.port = htons(nated_port);
436 if (nf_conntrack_expect_related(exp) == 0)
437 break;
438 }
439
440 if (nated_port == 0) { /* No port available */
441 if (net_ratelimit())
442 printk("nf_nat_ras: out of TCP ports\n");
443 return 0;
444 }
445
446 /* Modify signal */
447 if (set_h225_addr(pskb, data, 0, &taddr[idx],
448 &ct->tuplehash[!dir].tuple.dst.u3,
449 htons(nated_port)) == 0) {
450 /* Save ports */
451 info->sig_port[dir] = port;
452 info->sig_port[!dir] = htons(nated_port);
453
454 /* Fix for Gnomemeeting */
455 if (idx > 0 &&
456 get_h225_addr(ct, *data, &taddr[0], &addr, &port) &&
457 (ntohl(addr.ip) & 0xff000000) == 0x7f000000) {
458 set_h225_addr_hook(pskb, data, 0, &taddr[0],
459 &ct->tuplehash[!dir].tuple.dst.u3,
460 info->sig_port[!dir]);
461 }
462 } else {
463 nf_conntrack_unexpect_related(exp);
464 return -1;
465 }
466
467 /* Success */
468 DEBUGP("nf_nat_ras: expect Q.931 %u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
469 NIPQUAD(exp->tuple.src.ip), ntohs(exp->tuple.src.u.tcp.port),
470 NIPQUAD(exp->tuple.dst.ip), ntohs(exp->tuple.dst.u.tcp.port));
471
472 return 0;
473}
474
475/****************************************************************************/
476static void ip_nat_callforwarding_expect(struct nf_conn *new,
477 struct nf_conntrack_expect *this)
478{
479 struct nf_nat_range range;
480
481 /* This must be a fresh one. */
482 BUG_ON(new->status & IPS_NAT_DONE_MASK);
483
484 /* Change src to where master sends to */
485 range.flags = IP_NAT_RANGE_MAP_IPS;
486 range.min_ip = range.max_ip = new->tuplehash[!this->dir].tuple.src.u3.ip;
487
488 /* hook doesn't matter, but it has to do source manip */
489 nf_nat_setup_info(new, &range, NF_IP_POST_ROUTING);
490
491 /* For DST manip, map port here to where it's expected. */
492 range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED);
493 range.min = range.max = this->saved_proto;
494 range.min_ip = range.max_ip = this->saved_ip;
495
496 /* hook doesn't matter, but it has to do destination manip */
497 nf_nat_setup_info(new, &range, NF_IP_PRE_ROUTING);
498}
499
500/****************************************************************************/
501static int nat_callforwarding(struct sk_buff **pskb, struct nf_conn *ct,
502 enum ip_conntrack_info ctinfo,
503 unsigned char **data, int dataoff,
504 TransportAddress *taddr, __be16 port,
505 struct nf_conntrack_expect *exp)
506{
507 int dir = CTINFO2DIR(ctinfo);
508 u_int16_t nated_port;
509
510 /* Set expectations for NAT */
511 exp->saved_ip = exp->tuple.dst.u3.ip;
512 exp->tuple.dst.u3.ip = ct->tuplehash[!dir].tuple.dst.u3.ip;
513 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
514 exp->expectfn = ip_nat_callforwarding_expect;
515 exp->dir = !dir;
516
517 /* Try to get same port: if not, try to change it. */
518 for (nated_port = ntohs(port); nated_port != 0; nated_port++) {
519 exp->tuple.dst.u.tcp.port = htons(nated_port);
520 if (nf_conntrack_expect_related(exp) == 0)
521 break;
522 }
523
524 if (nated_port == 0) { /* No port available */
525 if (net_ratelimit())
526 printk("nf_nat_q931: out of TCP ports\n");
527 return 0;
528 }
529
530 /* Modify signal */
531 if (!set_h225_addr(pskb, data, dataoff, taddr,
532 &ct->tuplehash[!dir].tuple.dst.u3,
533 htons(nated_port)) == 0) {
534 nf_conntrack_unexpect_related(exp);
535 return -1;
536 }
537
538 /* Success */
539 DEBUGP("nf_nat_q931: expect Call Forwarding "
540 "%u.%u.%u.%u:%hu->%u.%u.%u.%u:%hu\n",
541 NIPQUAD(exp->tuple.src.ip), ntohs(exp->tuple.src.u.tcp.port),
542 NIPQUAD(exp->tuple.dst.ip), ntohs(exp->tuple.dst.u.tcp.port));
543
544 return 0;
545}
546
547/****************************************************************************/
548static int __init init(void)
549{
550 BUG_ON(rcu_dereference(set_h245_addr_hook) != NULL);
551 BUG_ON(rcu_dereference(set_h225_addr_hook) != NULL);
552 BUG_ON(rcu_dereference(set_sig_addr_hook) != NULL);
553 BUG_ON(rcu_dereference(set_ras_addr_hook) != NULL);
554 BUG_ON(rcu_dereference(nat_rtp_rtcp_hook) != NULL);
555 BUG_ON(rcu_dereference(nat_t120_hook) != NULL);
556 BUG_ON(rcu_dereference(nat_h245_hook) != NULL);
557 BUG_ON(rcu_dereference(nat_callforwarding_hook) != NULL);
558 BUG_ON(rcu_dereference(nat_q931_hook) != NULL);
559
560 rcu_assign_pointer(set_h245_addr_hook, set_h245_addr);
561 rcu_assign_pointer(set_h225_addr_hook, set_h225_addr);
562 rcu_assign_pointer(set_sig_addr_hook, set_sig_addr);
563 rcu_assign_pointer(set_ras_addr_hook, set_ras_addr);
564 rcu_assign_pointer(nat_rtp_rtcp_hook, nat_rtp_rtcp);
565 rcu_assign_pointer(nat_t120_hook, nat_t120);
566 rcu_assign_pointer(nat_h245_hook, nat_h245);
567 rcu_assign_pointer(nat_callforwarding_hook, nat_callforwarding);
568 rcu_assign_pointer(nat_q931_hook, nat_q931);
569
570 DEBUGP("nf_nat_h323: init success\n");
571 return 0;
572}
573
574/****************************************************************************/
575static void __exit fini(void)
576{
577 rcu_assign_pointer(set_h245_addr_hook, NULL);
578 rcu_assign_pointer(set_h225_addr_hook, NULL);
579 rcu_assign_pointer(set_sig_addr_hook, NULL);
580 rcu_assign_pointer(set_ras_addr_hook, NULL);
581 rcu_assign_pointer(nat_rtp_rtcp_hook, NULL);
582 rcu_assign_pointer(nat_t120_hook, NULL);
583 rcu_assign_pointer(nat_h245_hook, NULL);
584 rcu_assign_pointer(nat_callforwarding_hook, NULL);
585 rcu_assign_pointer(nat_q931_hook, NULL);
586 synchronize_rcu();
587}
588
589/****************************************************************************/
590module_init(init);
591module_exit(fini);
592
593MODULE_AUTHOR("Jing Min Zhao <zhaojingmin@users.sourceforge.net>");
594MODULE_DESCRIPTION("H.323 NAT helper");
595MODULE_LICENSE("GPL");
596MODULE_ALIAS("ip_nat_h323");
diff --git a/net/ipv4/netfilter/nf_nat_helper.c b/net/ipv4/netfilter/nf_nat_helper.c
new file mode 100644
index 000000000000..98fbfc84d183
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_helper.c
@@ -0,0 +1,433 @@
1/* ip_nat_helper.c - generic support functions for NAT helpers
2 *
3 * (C) 2000-2002 Harald Welte <laforge@netfilter.org>
4 * (C) 2003-2006 Netfilter Core Team <coreteam@netfilter.org>
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#include <linux/module.h>
11#include <linux/kmod.h>
12#include <linux/types.h>
13#include <linux/timer.h>
14#include <linux/skbuff.h>
15#include <linux/tcp.h>
16#include <linux/udp.h>
17#include <net/checksum.h>
18#include <net/tcp.h>
19
20#include <linux/netfilter_ipv4.h>
21#include <net/netfilter/nf_conntrack.h>
22#include <net/netfilter/nf_conntrack_helper.h>
23#include <net/netfilter/nf_conntrack_expect.h>
24#include <net/netfilter/nf_nat.h>
25#include <net/netfilter/nf_nat_protocol.h>
26#include <net/netfilter/nf_nat_core.h>
27#include <net/netfilter/nf_nat_helper.h>
28
29#if 0
30#define DEBUGP printk
31#define DUMP_OFFSET(x) printk("offset_before=%d, offset_after=%d, correction_pos=%u\n", x->offset_before, x->offset_after, x->correction_pos);
32#else
33#define DEBUGP(format, args...)
34#define DUMP_OFFSET(x)
35#endif
36
37static DEFINE_SPINLOCK(nf_nat_seqofs_lock);
38
39/* Setup TCP sequence correction given this change at this sequence */
40static inline void
41adjust_tcp_sequence(u32 seq,
42 int sizediff,
43 struct nf_conn *ct,
44 enum ip_conntrack_info ctinfo)
45{
46 int dir;
47 struct nf_nat_seq *this_way, *other_way;
48 struct nf_conn_nat *nat = nfct_nat(ct);
49
50 DEBUGP("nf_nat_resize_packet: old_size = %u, new_size = %u\n",
51 (*skb)->len, new_size);
52
53 dir = CTINFO2DIR(ctinfo);
54
55 this_way = &nat->info.seq[dir];
56 other_way = &nat->info.seq[!dir];
57
58 DEBUGP("nf_nat_resize_packet: Seq_offset before: ");
59 DUMP_OFFSET(this_way);
60
61 spin_lock_bh(&nf_nat_seqofs_lock);
62
63 /* SYN adjust. If it's uninitialized, or this is after last
64 * correction, record it: we don't handle more than one
65 * adjustment in the window, but do deal with common case of a
66 * retransmit */
67 if (this_way->offset_before == this_way->offset_after ||
68 before(this_way->correction_pos, seq)) {
69 this_way->correction_pos = seq;
70 this_way->offset_before = this_way->offset_after;
71 this_way->offset_after += sizediff;
72 }
73 spin_unlock_bh(&nf_nat_seqofs_lock);
74
75 DEBUGP("nf_nat_resize_packet: Seq_offset after: ");
76 DUMP_OFFSET(this_way);
77}
78
79/* Frobs data inside this packet, which is linear. */
80static void mangle_contents(struct sk_buff *skb,
81 unsigned int dataoff,
82 unsigned int match_offset,
83 unsigned int match_len,
84 const char *rep_buffer,
85 unsigned int rep_len)
86{
87 unsigned char *data;
88
89 BUG_ON(skb_is_nonlinear(skb));
90 data = (unsigned char *)skb->nh.iph + dataoff;
91
92 /* move post-replacement */
93 memmove(data + match_offset + rep_len,
94 data + match_offset + match_len,
95 skb->tail - (data + match_offset + match_len));
96
97 /* insert data from buffer */
98 memcpy(data + match_offset, rep_buffer, rep_len);
99
100 /* update skb info */
101 if (rep_len > match_len) {
102 DEBUGP("nf_nat_mangle_packet: Extending packet by "
103 "%u from %u bytes\n", rep_len - match_len,
104 skb->len);
105 skb_put(skb, rep_len - match_len);
106 } else {
107 DEBUGP("nf_nat_mangle_packet: Shrinking packet from "
108 "%u from %u bytes\n", match_len - rep_len,
109 skb->len);
110 __skb_trim(skb, skb->len + rep_len - match_len);
111 }
112
113 /* fix IP hdr checksum information */
114 skb->nh.iph->tot_len = htons(skb->len);
115 ip_send_check(skb->nh.iph);
116}
117
118/* Unusual, but possible case. */
119static int enlarge_skb(struct sk_buff **pskb, unsigned int extra)
120{
121 struct sk_buff *nskb;
122
123 if ((*pskb)->len + extra > 65535)
124 return 0;
125
126 nskb = skb_copy_expand(*pskb, skb_headroom(*pskb), extra, GFP_ATOMIC);
127 if (!nskb)
128 return 0;
129
130 /* Transfer socket to new skb. */
131 if ((*pskb)->sk)
132 skb_set_owner_w(nskb, (*pskb)->sk);
133 kfree_skb(*pskb);
134 *pskb = nskb;
135 return 1;
136}
137
138/* Generic function for mangling variable-length address changes inside
139 * NATed TCP connections (like the PORT XXX,XXX,XXX,XXX,XXX,XXX
140 * command in FTP).
141 *
142 * Takes care about all the nasty sequence number changes, checksumming,
143 * skb enlargement, ...
144 *
145 * */
146int
147nf_nat_mangle_tcp_packet(struct sk_buff **pskb,
148 struct nf_conn *ct,
149 enum ip_conntrack_info ctinfo,
150 unsigned int match_offset,
151 unsigned int match_len,
152 const char *rep_buffer,
153 unsigned int rep_len)
154{
155 struct iphdr *iph;
156 struct tcphdr *tcph;
157 int oldlen, datalen;
158
159 if (!skb_make_writable(pskb, (*pskb)->len))
160 return 0;
161
162 if (rep_len > match_len &&
163 rep_len - match_len > skb_tailroom(*pskb) &&
164 !enlarge_skb(pskb, rep_len - match_len))
165 return 0;
166
167 SKB_LINEAR_ASSERT(*pskb);
168
169 iph = (*pskb)->nh.iph;
170 tcph = (void *)iph + iph->ihl*4;
171
172 oldlen = (*pskb)->len - iph->ihl*4;
173 mangle_contents(*pskb, iph->ihl*4 + tcph->doff*4,
174 match_offset, match_len, rep_buffer, rep_len);
175
176 datalen = (*pskb)->len - iph->ihl*4;
177 if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
178 tcph->check = 0;
179 tcph->check = tcp_v4_check(tcph, datalen,
180 iph->saddr, iph->daddr,
181 csum_partial((char *)tcph,
182 datalen, 0));
183 } else
184 nf_proto_csum_replace2(&tcph->check, *pskb,
185 htons(oldlen), htons(datalen), 1);
186
187 if (rep_len != match_len) {
188 set_bit(IPS_SEQ_ADJUST_BIT, &ct->status);
189 adjust_tcp_sequence(ntohl(tcph->seq),
190 (int)rep_len - (int)match_len,
191 ct, ctinfo);
192 /* Tell TCP window tracking about seq change */
193 nf_conntrack_tcp_update(*pskb, (*pskb)->nh.iph->ihl*4,
194 ct, CTINFO2DIR(ctinfo));
195 }
196 return 1;
197}
198EXPORT_SYMBOL(nf_nat_mangle_tcp_packet);
199
200/* Generic function for mangling variable-length address changes inside
201 * NATed UDP connections (like the CONNECT DATA XXXXX MESG XXXXX INDEX XXXXX
202 * command in the Amanda protocol)
203 *
204 * Takes care about all the nasty sequence number changes, checksumming,
205 * skb enlargement, ...
206 *
207 * XXX - This function could be merged with nf_nat_mangle_tcp_packet which
208 * should be fairly easy to do.
209 */
210int
211nf_nat_mangle_udp_packet(struct sk_buff **pskb,
212 struct nf_conn *ct,
213 enum ip_conntrack_info ctinfo,
214 unsigned int match_offset,
215 unsigned int match_len,
216 const char *rep_buffer,
217 unsigned int rep_len)
218{
219 struct iphdr *iph;
220 struct udphdr *udph;
221 int datalen, oldlen;
222
223 /* UDP helpers might accidentally mangle the wrong packet */
224 iph = (*pskb)->nh.iph;
225 if ((*pskb)->len < iph->ihl*4 + sizeof(*udph) +
226 match_offset + match_len)
227 return 0;
228
229 if (!skb_make_writable(pskb, (*pskb)->len))
230 return 0;
231
232 if (rep_len > match_len &&
233 rep_len - match_len > skb_tailroom(*pskb) &&
234 !enlarge_skb(pskb, rep_len - match_len))
235 return 0;
236
237 iph = (*pskb)->nh.iph;
238 udph = (void *)iph + iph->ihl*4;
239
240 oldlen = (*pskb)->len - iph->ihl*4;
241 mangle_contents(*pskb, iph->ihl*4 + sizeof(*udph),
242 match_offset, match_len, rep_buffer, rep_len);
243
244 /* update the length of the UDP packet */
245 datalen = (*pskb)->len - iph->ihl*4;
246 udph->len = htons(datalen);
247
248 /* fix udp checksum if udp checksum was previously calculated */
249 if (!udph->check && (*pskb)->ip_summed != CHECKSUM_PARTIAL)
250 return 1;
251
252 if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
253 udph->check = 0;
254 udph->check = csum_tcpudp_magic(iph->saddr, iph->daddr,
255 datalen, IPPROTO_UDP,
256 csum_partial((char *)udph,
257 datalen, 0));
258 if (!udph->check)
259 udph->check = CSUM_MANGLED_0;
260 } else
261 nf_proto_csum_replace2(&udph->check, *pskb,
262 htons(oldlen), htons(datalen), 1);
263
264 return 1;
265}
266EXPORT_SYMBOL(nf_nat_mangle_udp_packet);
267
268/* Adjust one found SACK option including checksum correction */
269static void
270sack_adjust(struct sk_buff *skb,
271 struct tcphdr *tcph,
272 unsigned int sackoff,
273 unsigned int sackend,
274 struct nf_nat_seq *natseq)
275{
276 while (sackoff < sackend) {
277 struct tcp_sack_block_wire *sack;
278 __be32 new_start_seq, new_end_seq;
279
280 sack = (void *)skb->data + sackoff;
281 if (after(ntohl(sack->start_seq) - natseq->offset_before,
282 natseq->correction_pos))
283 new_start_seq = htonl(ntohl(sack->start_seq)
284 - natseq->offset_after);
285 else
286 new_start_seq = htonl(ntohl(sack->start_seq)
287 - natseq->offset_before);
288
289 if (after(ntohl(sack->end_seq) - natseq->offset_before,
290 natseq->correction_pos))
291 new_end_seq = htonl(ntohl(sack->end_seq)
292 - natseq->offset_after);
293 else
294 new_end_seq = htonl(ntohl(sack->end_seq)
295 - natseq->offset_before);
296
297 DEBUGP("sack_adjust: start_seq: %d->%d, end_seq: %d->%d\n",
298 ntohl(sack->start_seq), new_start_seq,
299 ntohl(sack->end_seq), new_end_seq);
300
301 nf_proto_csum_replace4(&tcph->check, skb,
302 sack->start_seq, new_start_seq, 0);
303 nf_proto_csum_replace4(&tcph->check, skb,
304 sack->end_seq, new_end_seq, 0);
305 sack->start_seq = new_start_seq;
306 sack->end_seq = new_end_seq;
307 sackoff += sizeof(*sack);
308 }
309}
310
311/* TCP SACK sequence number adjustment */
312static inline unsigned int
313nf_nat_sack_adjust(struct sk_buff **pskb,
314 struct tcphdr *tcph,
315 struct nf_conn *ct,
316 enum ip_conntrack_info ctinfo)
317{
318 unsigned int dir, optoff, optend;
319 struct nf_conn_nat *nat = nfct_nat(ct);
320
321 optoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct tcphdr);
322 optend = (*pskb)->nh.iph->ihl*4 + tcph->doff*4;
323
324 if (!skb_make_writable(pskb, optend))
325 return 0;
326
327 dir = CTINFO2DIR(ctinfo);
328
329 while (optoff < optend) {
330 /* Usually: option, length. */
331 unsigned char *op = (*pskb)->data + optoff;
332
333 switch (op[0]) {
334 case TCPOPT_EOL:
335 return 1;
336 case TCPOPT_NOP:
337 optoff++;
338 continue;
339 default:
340 /* no partial options */
341 if (optoff + 1 == optend ||
342 optoff + op[1] > optend ||
343 op[1] < 2)
344 return 0;
345 if (op[0] == TCPOPT_SACK &&
346 op[1] >= 2+TCPOLEN_SACK_PERBLOCK &&
347 ((op[1] - 2) % TCPOLEN_SACK_PERBLOCK) == 0)
348 sack_adjust(*pskb, tcph, optoff+2,
349 optoff+op[1],
350 &nat->info.seq[!dir]);
351 optoff += op[1];
352 }
353 }
354 return 1;
355}
356
357/* TCP sequence number adjustment. Returns 1 on success, 0 on failure */
358int
359nf_nat_seq_adjust(struct sk_buff **pskb,
360 struct nf_conn *ct,
361 enum ip_conntrack_info ctinfo)
362{
363 struct tcphdr *tcph;
364 int dir;
365 __be32 newseq, newack;
366 struct nf_conn_nat *nat = nfct_nat(ct);
367 struct nf_nat_seq *this_way, *other_way;
368
369 dir = CTINFO2DIR(ctinfo);
370
371 this_way = &nat->info.seq[dir];
372 other_way = &nat->info.seq[!dir];
373
374 if (!skb_make_writable(pskb, (*pskb)->nh.iph->ihl*4+sizeof(*tcph)))
375 return 0;
376
377 tcph = (void *)(*pskb)->data + (*pskb)->nh.iph->ihl*4;
378 if (after(ntohl(tcph->seq), this_way->correction_pos))
379 newseq = htonl(ntohl(tcph->seq) + this_way->offset_after);
380 else
381 newseq = htonl(ntohl(tcph->seq) + this_way->offset_before);
382
383 if (after(ntohl(tcph->ack_seq) - other_way->offset_before,
384 other_way->correction_pos))
385 newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_after);
386 else
387 newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_before);
388
389 nf_proto_csum_replace4(&tcph->check, *pskb, tcph->seq, newseq, 0);
390 nf_proto_csum_replace4(&tcph->check, *pskb, tcph->ack_seq, newack, 0);
391
392 DEBUGP("Adjusting sequence number from %u->%u, ack from %u->%u\n",
393 ntohl(tcph->seq), ntohl(newseq), ntohl(tcph->ack_seq),
394 ntohl(newack));
395
396 tcph->seq = newseq;
397 tcph->ack_seq = newack;
398
399 if (!nf_nat_sack_adjust(pskb, tcph, ct, ctinfo))
400 return 0;
401
402 nf_conntrack_tcp_update(*pskb, (*pskb)->nh.iph->ihl*4, ct, dir);
403
404 return 1;
405}
406EXPORT_SYMBOL(nf_nat_seq_adjust);
407
408/* Setup NAT on this expected conntrack so it follows master. */
409/* If we fail to get a free NAT slot, we'll get dropped on confirm */
410void nf_nat_follow_master(struct nf_conn *ct,
411 struct nf_conntrack_expect *exp)
412{
413 struct nf_nat_range range;
414
415 /* This must be a fresh one. */
416 BUG_ON(ct->status & IPS_NAT_DONE_MASK);
417
418 /* Change src to where master sends to */
419 range.flags = IP_NAT_RANGE_MAP_IPS;
420 range.min_ip = range.max_ip
421 = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip;
422 /* hook doesn't matter, but it has to do source manip */
423 nf_nat_setup_info(ct, &range, NF_IP_POST_ROUTING);
424
425 /* For DST manip, map port here to where it's expected. */
426 range.flags = (IP_NAT_RANGE_MAP_IPS | IP_NAT_RANGE_PROTO_SPECIFIED);
427 range.min = range.max = exp->saved_proto;
428 range.min_ip = range.max_ip
429 = ct->master->tuplehash[!exp->dir].tuple.src.u3.ip;
430 /* hook doesn't matter, but it has to do destination manip */
431 nf_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING);
432}
433EXPORT_SYMBOL(nf_nat_follow_master);
diff --git a/net/ipv4/netfilter/nf_nat_irc.c b/net/ipv4/netfilter/nf_nat_irc.c
new file mode 100644
index 000000000000..9b8c0daea744
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_irc.c
@@ -0,0 +1,101 @@
1/* IRC extension for TCP NAT alteration.
2 *
3 * (C) 2000-2001 by Harald Welte <laforge@gnumonks.org>
4 * (C) 2004 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
5 * based on a copy of RR's ip_nat_ftp.c
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/module.h>
14#include <linux/moduleparam.h>
15#include <linux/tcp.h>
16#include <linux/kernel.h>
17
18#include <net/netfilter/nf_nat.h>
19#include <net/netfilter/nf_nat_helper.h>
20#include <net/netfilter/nf_nat_rule.h>
21#include <net/netfilter/nf_conntrack_helper.h>
22#include <net/netfilter/nf_conntrack_expect.h>
23#include <linux/netfilter/nf_conntrack_irc.h>
24
25#if 0
26#define DEBUGP printk
27#else
28#define DEBUGP(format, args...)
29#endif
30
31MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
32MODULE_DESCRIPTION("IRC (DCC) NAT helper");
33MODULE_LICENSE("GPL");
34MODULE_ALIAS("ip_nat_irc");
35
36static unsigned int help(struct sk_buff **pskb,
37 enum ip_conntrack_info ctinfo,
38 unsigned int matchoff,
39 unsigned int matchlen,
40 struct nf_conntrack_expect *exp)
41{
42 char buffer[sizeof("4294967296 65635")];
43 u_int32_t ip;
44 u_int16_t port;
45 unsigned int ret;
46
47 DEBUGP("IRC_NAT: info (seq %u + %u) in %u\n",
48 expect->seq, exp_irc_info->len, ntohl(tcph->seq));
49
50 /* Reply comes from server. */
51 exp->saved_proto.tcp.port = exp->tuple.dst.u.tcp.port;
52 exp->dir = IP_CT_DIR_REPLY;
53 exp->expectfn = nf_nat_follow_master;
54
55 /* Try to get same port: if not, try to change it. */
56 for (port = ntohs(exp->saved_proto.tcp.port); port != 0; port++) {
57 exp->tuple.dst.u.tcp.port = htons(port);
58 if (nf_conntrack_expect_related(exp) == 0)
59 break;
60 }
61
62 if (port == 0)
63 return NF_DROP;
64
65 ip = ntohl(exp->master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip);
66 sprintf(buffer, "%u %u", ip, port);
67 DEBUGP("nf_nat_irc: inserting '%s' == %u.%u.%u.%u, port %u\n",
68 buffer, NIPQUAD(ip), port);
69
70 ret = nf_nat_mangle_tcp_packet(pskb, exp->master, ctinfo,
71 matchoff, matchlen, buffer,
72 strlen(buffer));
73 if (ret != NF_ACCEPT)
74 nf_conntrack_unexpect_related(exp);
75 return ret;
76}
77
78static void __exit nf_nat_irc_fini(void)
79{
80 rcu_assign_pointer(nf_nat_irc_hook, NULL);
81 synchronize_rcu();
82}
83
84static int __init nf_nat_irc_init(void)
85{
86 BUG_ON(rcu_dereference(nf_nat_irc_hook));
87 rcu_assign_pointer(nf_nat_irc_hook, help);
88 return 0;
89}
90
91/* Prior to 2.6.11, we had a ports param. No longer, but don't break users. */
92static int warn_set(const char *val, struct kernel_param *kp)
93{
94 printk(KERN_INFO KBUILD_MODNAME
95 ": kernel >= 2.6.10 only uses 'ports' for conntrack modules\n");
96 return 0;
97}
98module_param_call(ports, warn_set, NULL, NULL, 0);
99
100module_init(nf_nat_irc_init);
101module_exit(nf_nat_irc_fini);
diff --git a/net/ipv4/netfilter/nf_nat_pptp.c b/net/ipv4/netfilter/nf_nat_pptp.c
new file mode 100644
index 000000000000..0ae45b79a4eb
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_pptp.c
@@ -0,0 +1,315 @@
1/*
2 * nf_nat_pptp.c
3 *
4 * NAT support for PPTP (Point to Point Tunneling Protocol).
5 * PPTP is a a protocol for creating virtual private networks.
6 * It is a specification defined by Microsoft and some vendors
7 * working with Microsoft. PPTP is built on top of a modified
8 * version of the Internet Generic Routing Encapsulation Protocol.
9 * GRE is defined in RFC 1701 and RFC 1702. Documentation of
10 * PPTP can be found in RFC 2637
11 *
12 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
13 *
14 * Development of this code funded by Astaro AG (http://www.astaro.com/)
15 *
16 * TODO: - NAT to a unique tuple, not to TCP source port
17 * (needs netfilter tuple reservation)
18 */
19
20#include <linux/module.h>
21#include <linux/tcp.h>
22
23#include <net/netfilter/nf_nat.h>
24#include <net/netfilter/nf_nat_helper.h>
25#include <net/netfilter/nf_nat_rule.h>
26#include <net/netfilter/nf_conntrack_helper.h>
27#include <net/netfilter/nf_conntrack_expect.h>
28#include <linux/netfilter/nf_conntrack_proto_gre.h>
29#include <linux/netfilter/nf_conntrack_pptp.h>
30
31#define NF_NAT_PPTP_VERSION "3.0"
32
33#define REQ_CID(req, off) (*(__be16 *)((char *)(req) + (off)))
34
35MODULE_LICENSE("GPL");
36MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
37MODULE_DESCRIPTION("Netfilter NAT helper module for PPTP");
38MODULE_ALIAS("ip_nat_pptp");
39
40#if 0
41extern const char *pptp_msg_name[];
42#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, \
43 __FUNCTION__, ## args)
44#else
45#define DEBUGP(format, args...)
46#endif
47
48static void pptp_nat_expected(struct nf_conn *ct,
49 struct nf_conntrack_expect *exp)
50{
51 struct nf_conn *master = ct->master;
52 struct nf_conntrack_expect *other_exp;
53 struct nf_conntrack_tuple t;
54 struct nf_ct_pptp_master *ct_pptp_info;
55 struct nf_nat_pptp *nat_pptp_info;
56 struct ip_nat_range range;
57
58 ct_pptp_info = &nfct_help(master)->help.ct_pptp_info;
59 nat_pptp_info = &nfct_nat(master)->help.nat_pptp_info;
60
61 /* And here goes the grand finale of corrosion... */
62 if (exp->dir == IP_CT_DIR_ORIGINAL) {
63 DEBUGP("we are PNS->PAC\n");
64 /* therefore, build tuple for PAC->PNS */
65 t.src.l3num = AF_INET;
66 t.src.u3.ip = master->tuplehash[!exp->dir].tuple.src.u3.ip;
67 t.src.u.gre.key = ct_pptp_info->pac_call_id;
68 t.dst.u3.ip = master->tuplehash[!exp->dir].tuple.dst.u3.ip;
69 t.dst.u.gre.key = ct_pptp_info->pns_call_id;
70 t.dst.protonum = IPPROTO_GRE;
71 } else {
72 DEBUGP("we are PAC->PNS\n");
73 /* build tuple for PNS->PAC */
74 t.src.l3num = AF_INET;
75 t.src.u3.ip = master->tuplehash[exp->dir].tuple.src.u3.ip;
76 t.src.u.gre.key = nat_pptp_info->pns_call_id;
77 t.dst.u3.ip = master->tuplehash[exp->dir].tuple.dst.u3.ip;
78 t.dst.u.gre.key = nat_pptp_info->pac_call_id;
79 t.dst.protonum = IPPROTO_GRE;
80 }
81
82 DEBUGP("trying to unexpect other dir: ");
83 NF_CT_DUMP_TUPLE(&t);
84 other_exp = nf_conntrack_expect_find_get(&t);
85 if (other_exp) {
86 nf_conntrack_unexpect_related(other_exp);
87 nf_conntrack_expect_put(other_exp);
88 DEBUGP("success\n");
89 } else {
90 DEBUGP("not found!\n");
91 }
92
93 /* This must be a fresh one. */
94 BUG_ON(ct->status & IPS_NAT_DONE_MASK);
95
96 /* Change src to where master sends to */
97 range.flags = IP_NAT_RANGE_MAP_IPS;
98 range.min_ip = range.max_ip
99 = ct->master->tuplehash[!exp->dir].tuple.dst.u3.ip;
100 if (exp->dir == IP_CT_DIR_ORIGINAL) {
101 range.flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
102 range.min = range.max = exp->saved_proto;
103 }
104 /* hook doesn't matter, but it has to do source manip */
105 nf_nat_setup_info(ct, &range, NF_IP_POST_ROUTING);
106
107 /* For DST manip, map port here to where it's expected. */
108 range.flags = IP_NAT_RANGE_MAP_IPS;
109 range.min_ip = range.max_ip
110 = ct->master->tuplehash[!exp->dir].tuple.src.u3.ip;
111 if (exp->dir == IP_CT_DIR_REPLY) {
112 range.flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
113 range.min = range.max = exp->saved_proto;
114 }
115 /* hook doesn't matter, but it has to do destination manip */
116 nf_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING);
117}
118
119/* outbound packets == from PNS to PAC */
120static int
121pptp_outbound_pkt(struct sk_buff **pskb,
122 struct nf_conn *ct,
123 enum ip_conntrack_info ctinfo,
124 struct PptpControlHeader *ctlh,
125 union pptp_ctrl_union *pptpReq)
126
127{
128 struct nf_ct_pptp_master *ct_pptp_info;
129 struct nf_nat_pptp *nat_pptp_info;
130 u_int16_t msg;
131 __be16 new_callid;
132 unsigned int cid_off;
133
134 ct_pptp_info = &nfct_help(ct)->help.ct_pptp_info;
135 nat_pptp_info = &nfct_nat(ct)->help.nat_pptp_info;
136
137 new_callid = ct_pptp_info->pns_call_id;
138
139 switch (msg = ntohs(ctlh->messageType)) {
140 case PPTP_OUT_CALL_REQUEST:
141 cid_off = offsetof(union pptp_ctrl_union, ocreq.callID);
142 /* FIXME: ideally we would want to reserve a call ID
143 * here. current netfilter NAT core is not able to do
144 * this :( For now we use TCP source port. This breaks
145 * multiple calls within one control session */
146
147 /* save original call ID in nat_info */
148 nat_pptp_info->pns_call_id = ct_pptp_info->pns_call_id;
149
150 /* don't use tcph->source since we are at a DSTmanip
151 * hook (e.g. PREROUTING) and pkt is not mangled yet */
152 new_callid = ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.tcp.port;
153
154 /* save new call ID in ct info */
155 ct_pptp_info->pns_call_id = new_callid;
156 break;
157 case PPTP_IN_CALL_REPLY:
158 cid_off = offsetof(union pptp_ctrl_union, icack.callID);
159 break;
160 case PPTP_CALL_CLEAR_REQUEST:
161 cid_off = offsetof(union pptp_ctrl_union, clrreq.callID);
162 break;
163 default:
164 DEBUGP("unknown outbound packet 0x%04x:%s\n", msg,
165 (msg <= PPTP_MSG_MAX)?
166 pptp_msg_name[msg]:pptp_msg_name[0]);
167 /* fall through */
168 case PPTP_SET_LINK_INFO:
169 /* only need to NAT in case PAC is behind NAT box */
170 case PPTP_START_SESSION_REQUEST:
171 case PPTP_START_SESSION_REPLY:
172 case PPTP_STOP_SESSION_REQUEST:
173 case PPTP_STOP_SESSION_REPLY:
174 case PPTP_ECHO_REQUEST:
175 case PPTP_ECHO_REPLY:
176 /* no need to alter packet */
177 return NF_ACCEPT;
178 }
179
180 /* only OUT_CALL_REQUEST, IN_CALL_REPLY, CALL_CLEAR_REQUEST pass
181 * down to here */
182 DEBUGP("altering call id from 0x%04x to 0x%04x\n",
183 ntohs(REQ_CID(pptpReq, cid_off)), ntohs(new_callid));
184
185 /* mangle packet */
186 if (nf_nat_mangle_tcp_packet(pskb, ct, ctinfo,
187 cid_off + sizeof(struct pptp_pkt_hdr) +
188 sizeof(struct PptpControlHeader),
189 sizeof(new_callid), (char *)&new_callid,
190 sizeof(new_callid)) == 0)
191 return NF_DROP;
192 return NF_ACCEPT;
193}
194
195static void
196pptp_exp_gre(struct nf_conntrack_expect *expect_orig,
197 struct nf_conntrack_expect *expect_reply)
198{
199 struct nf_conn *ct = expect_orig->master;
200 struct nf_ct_pptp_master *ct_pptp_info;
201 struct nf_nat_pptp *nat_pptp_info;
202
203 ct_pptp_info = &nfct_help(ct)->help.ct_pptp_info;
204 nat_pptp_info = &nfct_nat(ct)->help.nat_pptp_info;
205
206 /* save original PAC call ID in nat_info */
207 nat_pptp_info->pac_call_id = ct_pptp_info->pac_call_id;
208
209 /* alter expectation for PNS->PAC direction */
210 expect_orig->saved_proto.gre.key = ct_pptp_info->pns_call_id;
211 expect_orig->tuple.src.u.gre.key = nat_pptp_info->pns_call_id;
212 expect_orig->tuple.dst.u.gre.key = ct_pptp_info->pac_call_id;
213 expect_orig->dir = IP_CT_DIR_ORIGINAL;
214
215 /* alter expectation for PAC->PNS direction */
216 expect_reply->saved_proto.gre.key = nat_pptp_info->pns_call_id;
217 expect_reply->tuple.src.u.gre.key = nat_pptp_info->pac_call_id;
218 expect_reply->tuple.dst.u.gre.key = ct_pptp_info->pns_call_id;
219 expect_reply->dir = IP_CT_DIR_REPLY;
220}
221
222/* inbound packets == from PAC to PNS */
223static int
224pptp_inbound_pkt(struct sk_buff **pskb,
225 struct nf_conn *ct,
226 enum ip_conntrack_info ctinfo,
227 struct PptpControlHeader *ctlh,
228 union pptp_ctrl_union *pptpReq)
229{
230 struct nf_nat_pptp *nat_pptp_info;
231 u_int16_t msg;
232 __be16 new_pcid;
233 unsigned int pcid_off;
234
235 nat_pptp_info = &nfct_nat(ct)->help.nat_pptp_info;
236 new_pcid = nat_pptp_info->pns_call_id;
237
238 switch (msg = ntohs(ctlh->messageType)) {
239 case PPTP_OUT_CALL_REPLY:
240 pcid_off = offsetof(union pptp_ctrl_union, ocack.peersCallID);
241 break;
242 case PPTP_IN_CALL_CONNECT:
243 pcid_off = offsetof(union pptp_ctrl_union, iccon.peersCallID);
244 break;
245 case PPTP_IN_CALL_REQUEST:
246 /* only need to nat in case PAC is behind NAT box */
247 return NF_ACCEPT;
248 case PPTP_WAN_ERROR_NOTIFY:
249 pcid_off = offsetof(union pptp_ctrl_union, wanerr.peersCallID);
250 break;
251 case PPTP_CALL_DISCONNECT_NOTIFY:
252 pcid_off = offsetof(union pptp_ctrl_union, disc.callID);
253 break;
254 case PPTP_SET_LINK_INFO:
255 pcid_off = offsetof(union pptp_ctrl_union, setlink.peersCallID);
256 break;
257 default:
258 DEBUGP("unknown inbound packet %s\n", (msg <= PPTP_MSG_MAX)?
259 pptp_msg_name[msg]:pptp_msg_name[0]);
260 /* fall through */
261 case PPTP_START_SESSION_REQUEST:
262 case PPTP_START_SESSION_REPLY:
263 case PPTP_STOP_SESSION_REQUEST:
264 case PPTP_STOP_SESSION_REPLY:
265 case PPTP_ECHO_REQUEST:
266 case PPTP_ECHO_REPLY:
267 /* no need to alter packet */
268 return NF_ACCEPT;
269 }
270
271 /* only OUT_CALL_REPLY, IN_CALL_CONNECT, IN_CALL_REQUEST,
272 * WAN_ERROR_NOTIFY, CALL_DISCONNECT_NOTIFY pass down here */
273
274 /* mangle packet */
275 DEBUGP("altering peer call id from 0x%04x to 0x%04x\n",
276 ntohs(REQ_CID(pptpReq, pcid_off)), ntohs(new_pcid));
277
278 if (nf_nat_mangle_tcp_packet(pskb, ct, ctinfo,
279 pcid_off + sizeof(struct pptp_pkt_hdr) +
280 sizeof(struct PptpControlHeader),
281 sizeof(new_pcid), (char *)&new_pcid,
282 sizeof(new_pcid)) == 0)
283 return NF_DROP;
284 return NF_ACCEPT;
285}
286
287static int __init nf_nat_helper_pptp_init(void)
288{
289 nf_nat_need_gre();
290
291 BUG_ON(rcu_dereference(nf_nat_pptp_hook_outbound));
292 rcu_assign_pointer(nf_nat_pptp_hook_outbound, pptp_outbound_pkt);
293
294 BUG_ON(rcu_dereference(nf_nat_pptp_hook_inbound));
295 rcu_assign_pointer(nf_nat_pptp_hook_inbound, pptp_inbound_pkt);
296
297 BUG_ON(rcu_dereference(nf_nat_pptp_hook_exp_gre));
298 rcu_assign_pointer(nf_nat_pptp_hook_exp_gre, pptp_exp_gre);
299
300 BUG_ON(rcu_dereference(nf_nat_pptp_hook_expectfn));
301 rcu_assign_pointer(nf_nat_pptp_hook_expectfn, pptp_nat_expected);
302 return 0;
303}
304
305static void __exit nf_nat_helper_pptp_fini(void)
306{
307 rcu_assign_pointer(nf_nat_pptp_hook_expectfn, NULL);
308 rcu_assign_pointer(nf_nat_pptp_hook_exp_gre, NULL);
309 rcu_assign_pointer(nf_nat_pptp_hook_inbound, NULL);
310 rcu_assign_pointer(nf_nat_pptp_hook_outbound, NULL);
311 synchronize_rcu();
312}
313
314module_init(nf_nat_helper_pptp_init);
315module_exit(nf_nat_helper_pptp_fini);
diff --git a/net/ipv4/netfilter/nf_nat_proto_gre.c b/net/ipv4/netfilter/nf_nat_proto_gre.c
new file mode 100644
index 000000000000..d3de579e09d2
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_proto_gre.c
@@ -0,0 +1,179 @@
1/*
2 * nf_nat_proto_gre.c
3 *
4 * NAT protocol helper module for GRE.
5 *
6 * GRE is a generic encapsulation protocol, which is generally not very
7 * suited for NAT, as it has no protocol-specific part as port numbers.
8 *
9 * It has an optional key field, which may help us distinguishing two
10 * connections between the same two hosts.
11 *
12 * GRE is defined in RFC 1701 and RFC 1702, as well as RFC 2784
13 *
14 * PPTP is built on top of a modified version of GRE, and has a mandatory
15 * field called "CallID", which serves us for the same purpose as the key
16 * field in plain GRE.
17 *
18 * Documentation about PPTP can be found in RFC 2637
19 *
20 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
21 *
22 * Development of this code funded by Astaro AG (http://www.astaro.com/)
23 *
24 */
25
26#include <linux/module.h>
27#include <linux/skbuff.h>
28#include <linux/ip.h>
29
30#include <net/netfilter/nf_nat.h>
31#include <net/netfilter/nf_nat_rule.h>
32#include <net/netfilter/nf_nat_protocol.h>
33#include <linux/netfilter/nf_conntrack_proto_gre.h>
34
35MODULE_LICENSE("GPL");
36MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
37MODULE_DESCRIPTION("Netfilter NAT protocol helper module for GRE");
38
39#if 0
40#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, \
41 __FUNCTION__, ## args)
42#else
43#define DEBUGP(x, args...)
44#endif
45
46/* is key in given range between min and max */
47static int
48gre_in_range(const struct nf_conntrack_tuple *tuple,
49 enum nf_nat_manip_type maniptype,
50 const union nf_conntrack_man_proto *min,
51 const union nf_conntrack_man_proto *max)
52{
53 __be16 key;
54
55 if (maniptype == IP_NAT_MANIP_SRC)
56 key = tuple->src.u.gre.key;
57 else
58 key = tuple->dst.u.gre.key;
59
60 return ntohs(key) >= ntohs(min->gre.key) &&
61 ntohs(key) <= ntohs(max->gre.key);
62}
63
64/* generate unique tuple ... */
65static int
66gre_unique_tuple(struct nf_conntrack_tuple *tuple,
67 const struct nf_nat_range *range,
68 enum nf_nat_manip_type maniptype,
69 const struct nf_conn *conntrack)
70{
71 static u_int16_t key;
72 __be16 *keyptr;
73 unsigned int min, i, range_size;
74
75 if (maniptype == IP_NAT_MANIP_SRC)
76 keyptr = &tuple->src.u.gre.key;
77 else
78 keyptr = &tuple->dst.u.gre.key;
79
80 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) {
81 DEBUGP("%p: NATing GRE PPTP\n", conntrack);
82 min = 1;
83 range_size = 0xffff;
84 } else {
85 min = ntohs(range->min.gre.key);
86 range_size = ntohs(range->max.gre.key) - min + 1;
87 }
88
89 DEBUGP("min = %u, range_size = %u\n", min, range_size);
90
91 for (i = 0; i < range_size; i++, key++) {
92 *keyptr = htons(min + key % range_size);
93 if (!nf_nat_used_tuple(tuple, conntrack))
94 return 1;
95 }
96
97 DEBUGP("%p: no NAT mapping\n", conntrack);
98 return 0;
99}
100
101/* manipulate a GRE packet according to maniptype */
102static int
103gre_manip_pkt(struct sk_buff **pskb, unsigned int iphdroff,
104 const struct nf_conntrack_tuple *tuple,
105 enum nf_nat_manip_type maniptype)
106{
107 struct gre_hdr *greh;
108 struct gre_hdr_pptp *pgreh;
109 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
110 unsigned int hdroff = iphdroff + iph->ihl * 4;
111
112 /* pgreh includes two optional 32bit fields which are not required
113 * to be there. That's where the magic '8' comes from */
114 if (!skb_make_writable(pskb, hdroff + sizeof(*pgreh) - 8))
115 return 0;
116
117 greh = (void *)(*pskb)->data + hdroff;
118 pgreh = (struct gre_hdr_pptp *)greh;
119
120 /* we only have destination manip of a packet, since 'source key'
121 * is not present in the packet itself */
122 if (maniptype != IP_NAT_MANIP_DST)
123 return 1;
124 switch (greh->version) {
125 case 0:
126 if (!greh->key) {
127 DEBUGP("can't nat GRE w/o key\n");
128 break;
129 }
130 if (greh->csum) {
131 /* FIXME: Never tested this code... */
132 nf_proto_csum_replace4(gre_csum(greh), *pskb,
133 *(gre_key(greh)),
134 tuple->dst.u.gre.key, 0);
135 }
136 *(gre_key(greh)) = tuple->dst.u.gre.key;
137 break;
138 case GRE_VERSION_PPTP:
139 DEBUGP("call_id -> 0x%04x\n", ntohs(tuple->dst.u.gre.key));
140 pgreh->call_id = tuple->dst.u.gre.key;
141 break;
142 default:
143 DEBUGP("can't nat unknown GRE version\n");
144 return 0;
145 }
146 return 1;
147}
148
149static struct nf_nat_protocol gre __read_mostly = {
150 .name = "GRE",
151 .protonum = IPPROTO_GRE,
152 .manip_pkt = gre_manip_pkt,
153 .in_range = gre_in_range,
154 .unique_tuple = gre_unique_tuple,
155#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
156 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
157 .range_to_nfattr = nf_nat_port_range_to_nfattr,
158 .nfattr_to_range = nf_nat_port_nfattr_to_range,
159#endif
160};
161
162int __init nf_nat_proto_gre_init(void)
163{
164 return nf_nat_protocol_register(&gre);
165}
166
167void __exit nf_nat_proto_gre_fini(void)
168{
169 nf_nat_protocol_unregister(&gre);
170}
171
172module_init(nf_nat_proto_gre_init);
173module_exit(nf_nat_proto_gre_fini);
174
175void nf_nat_need_gre(void)
176{
177 return;
178}
179EXPORT_SYMBOL_GPL(nf_nat_need_gre);
diff --git a/net/ipv4/netfilter/nf_nat_proto_icmp.c b/net/ipv4/netfilter/nf_nat_proto_icmp.c
new file mode 100644
index 000000000000..dcfd772972d7
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_proto_icmp.c
@@ -0,0 +1,86 @@
1/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
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
9#include <linux/types.h>
10#include <linux/init.h>
11#include <linux/ip.h>
12#include <linux/icmp.h>
13
14#include <linux/netfilter.h>
15#include <net/netfilter/nf_nat.h>
16#include <net/netfilter/nf_nat_core.h>
17#include <net/netfilter/nf_nat_rule.h>
18#include <net/netfilter/nf_nat_protocol.h>
19
20static int
21icmp_in_range(const struct nf_conntrack_tuple *tuple,
22 enum nf_nat_manip_type maniptype,
23 const union nf_conntrack_man_proto *min,
24 const union nf_conntrack_man_proto *max)
25{
26 return ntohs(tuple->src.u.icmp.id) >= ntohs(min->icmp.id) &&
27 ntohs(tuple->src.u.icmp.id) <= ntohs(max->icmp.id);
28}
29
30static int
31icmp_unique_tuple(struct nf_conntrack_tuple *tuple,
32 const struct nf_nat_range *range,
33 enum nf_nat_manip_type maniptype,
34 const struct nf_conn *ct)
35{
36 static u_int16_t id;
37 unsigned int range_size;
38 unsigned int i;
39
40 range_size = ntohs(range->max.icmp.id) - ntohs(range->min.icmp.id) + 1;
41 /* If no range specified... */
42 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED))
43 range_size = 0xFFFF;
44
45 for (i = 0; i < range_size; i++, id++) {
46 tuple->src.u.icmp.id = htons(ntohs(range->min.icmp.id) +
47 (id % range_size));
48 if (!nf_nat_used_tuple(tuple, ct))
49 return 1;
50 }
51 return 0;
52}
53
54static int
55icmp_manip_pkt(struct sk_buff **pskb,
56 unsigned int iphdroff,
57 const struct nf_conntrack_tuple *tuple,
58 enum nf_nat_manip_type maniptype)
59{
60 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
61 struct icmphdr *hdr;
62 unsigned int hdroff = iphdroff + iph->ihl*4;
63
64 if (!skb_make_writable(pskb, hdroff + sizeof(*hdr)))
65 return 0;
66
67 hdr = (struct icmphdr *)((*pskb)->data + hdroff);
68 nf_proto_csum_replace2(&hdr->checksum, *pskb,
69 hdr->un.echo.id, tuple->src.u.icmp.id, 0);
70 hdr->un.echo.id = tuple->src.u.icmp.id;
71 return 1;
72}
73
74struct nf_nat_protocol nf_nat_protocol_icmp = {
75 .name = "ICMP",
76 .protonum = IPPROTO_ICMP,
77 .me = THIS_MODULE,
78 .manip_pkt = icmp_manip_pkt,
79 .in_range = icmp_in_range,
80 .unique_tuple = icmp_unique_tuple,
81#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
82 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
83 .range_to_nfattr = nf_nat_port_range_to_nfattr,
84 .nfattr_to_range = nf_nat_port_nfattr_to_range,
85#endif
86};
diff --git a/net/ipv4/netfilter/nf_nat_proto_tcp.c b/net/ipv4/netfilter/nf_nat_proto_tcp.c
new file mode 100644
index 000000000000..7e26a7e9bee1
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_proto_tcp.c
@@ -0,0 +1,148 @@
1/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
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
9#include <linux/types.h>
10#include <linux/init.h>
11#include <linux/ip.h>
12#include <linux/tcp.h>
13
14#include <linux/netfilter.h>
15#include <linux/netfilter/nfnetlink_conntrack.h>
16#include <net/netfilter/nf_nat.h>
17#include <net/netfilter/nf_nat_rule.h>
18#include <net/netfilter/nf_nat_protocol.h>
19#include <net/netfilter/nf_nat_core.h>
20
21static int
22tcp_in_range(const struct nf_conntrack_tuple *tuple,
23 enum nf_nat_manip_type maniptype,
24 const union nf_conntrack_man_proto *min,
25 const union nf_conntrack_man_proto *max)
26{
27 __be16 port;
28
29 if (maniptype == IP_NAT_MANIP_SRC)
30 port = tuple->src.u.tcp.port;
31 else
32 port = tuple->dst.u.tcp.port;
33
34 return ntohs(port) >= ntohs(min->tcp.port) &&
35 ntohs(port) <= ntohs(max->tcp.port);
36}
37
38static int
39tcp_unique_tuple(struct nf_conntrack_tuple *tuple,
40 const struct nf_nat_range *range,
41 enum nf_nat_manip_type maniptype,
42 const struct nf_conn *ct)
43{
44 static u_int16_t port;
45 __be16 *portptr;
46 unsigned int range_size, min, i;
47
48 if (maniptype == IP_NAT_MANIP_SRC)
49 portptr = &tuple->src.u.tcp.port;
50 else
51 portptr = &tuple->dst.u.tcp.port;
52
53 /* If no range specified... */
54 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) {
55 /* If it's dst rewrite, can't change port */
56 if (maniptype == IP_NAT_MANIP_DST)
57 return 0;
58
59 /* Map privileged onto privileged. */
60 if (ntohs(*portptr) < 1024) {
61 /* Loose convention: >> 512 is credential passing */
62 if (ntohs(*portptr)<512) {
63 min = 1;
64 range_size = 511 - min + 1;
65 } else {
66 min = 600;
67 range_size = 1023 - min + 1;
68 }
69 } else {
70 min = 1024;
71 range_size = 65535 - 1024 + 1;
72 }
73 } else {
74 min = ntohs(range->min.tcp.port);
75 range_size = ntohs(range->max.tcp.port) - min + 1;
76 }
77
78 for (i = 0; i < range_size; i++, port++) {
79 *portptr = htons(min + port % range_size);
80 if (!nf_nat_used_tuple(tuple, ct))
81 return 1;
82 }
83 return 0;
84}
85
86static int
87tcp_manip_pkt(struct sk_buff **pskb,
88 unsigned int iphdroff,
89 const struct nf_conntrack_tuple *tuple,
90 enum nf_nat_manip_type maniptype)
91{
92 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
93 struct tcphdr *hdr;
94 unsigned int hdroff = iphdroff + iph->ihl*4;
95 __be32 oldip, newip;
96 __be16 *portptr, newport, oldport;
97 int hdrsize = 8; /* TCP connection tracking guarantees this much */
98
99 /* this could be a inner header returned in icmp packet; in such
100 cases we cannot update the checksum field since it is outside of
101 the 8 bytes of transport layer headers we are guaranteed */
102 if ((*pskb)->len >= hdroff + sizeof(struct tcphdr))
103 hdrsize = sizeof(struct tcphdr);
104
105 if (!skb_make_writable(pskb, hdroff + hdrsize))
106 return 0;
107
108 iph = (struct iphdr *)((*pskb)->data + iphdroff);
109 hdr = (struct tcphdr *)((*pskb)->data + hdroff);
110
111 if (maniptype == IP_NAT_MANIP_SRC) {
112 /* Get rid of src ip and src pt */
113 oldip = iph->saddr;
114 newip = tuple->src.u3.ip;
115 newport = tuple->src.u.tcp.port;
116 portptr = &hdr->source;
117 } else {
118 /* Get rid of dst ip and dst pt */
119 oldip = iph->daddr;
120 newip = tuple->dst.u3.ip;
121 newport = tuple->dst.u.tcp.port;
122 portptr = &hdr->dest;
123 }
124
125 oldport = *portptr;
126 *portptr = newport;
127
128 if (hdrsize < sizeof(*hdr))
129 return 1;
130
131 nf_proto_csum_replace4(&hdr->check, *pskb, oldip, newip, 1);
132 nf_proto_csum_replace2(&hdr->check, *pskb, oldport, newport, 0);
133 return 1;
134}
135
136struct nf_nat_protocol nf_nat_protocol_tcp = {
137 .name = "TCP",
138 .protonum = IPPROTO_TCP,
139 .me = THIS_MODULE,
140 .manip_pkt = tcp_manip_pkt,
141 .in_range = tcp_in_range,
142 .unique_tuple = tcp_unique_tuple,
143#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
144 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
145 .range_to_nfattr = nf_nat_port_range_to_nfattr,
146 .nfattr_to_range = nf_nat_port_nfattr_to_range,
147#endif
148};
diff --git a/net/ipv4/netfilter/nf_nat_proto_udp.c b/net/ipv4/netfilter/nf_nat_proto_udp.c
new file mode 100644
index 000000000000..ab0ce4c8699f
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_proto_udp.c
@@ -0,0 +1,138 @@
1/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
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
9#include <linux/types.h>
10#include <linux/init.h>
11#include <linux/ip.h>
12#include <linux/udp.h>
13
14#include <linux/netfilter.h>
15#include <net/netfilter/nf_nat.h>
16#include <net/netfilter/nf_nat_core.h>
17#include <net/netfilter/nf_nat_rule.h>
18#include <net/netfilter/nf_nat_protocol.h>
19
20static int
21udp_in_range(const struct nf_conntrack_tuple *tuple,
22 enum nf_nat_manip_type maniptype,
23 const union nf_conntrack_man_proto *min,
24 const union nf_conntrack_man_proto *max)
25{
26 __be16 port;
27
28 if (maniptype == IP_NAT_MANIP_SRC)
29 port = tuple->src.u.udp.port;
30 else
31 port = tuple->dst.u.udp.port;
32
33 return ntohs(port) >= ntohs(min->udp.port) &&
34 ntohs(port) <= ntohs(max->udp.port);
35}
36
37static int
38udp_unique_tuple(struct nf_conntrack_tuple *tuple,
39 const struct nf_nat_range *range,
40 enum nf_nat_manip_type maniptype,
41 const struct nf_conn *ct)
42{
43 static u_int16_t port;
44 __be16 *portptr;
45 unsigned int range_size, min, i;
46
47 if (maniptype == IP_NAT_MANIP_SRC)
48 portptr = &tuple->src.u.udp.port;
49 else
50 portptr = &tuple->dst.u.udp.port;
51
52 /* If no range specified... */
53 if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED)) {
54 /* If it's dst rewrite, can't change port */
55 if (maniptype == IP_NAT_MANIP_DST)
56 return 0;
57
58 if (ntohs(*portptr) < 1024) {
59 /* Loose convention: >> 512 is credential passing */
60 if (ntohs(*portptr)<512) {
61 min = 1;
62 range_size = 511 - min + 1;
63 } else {
64 min = 600;
65 range_size = 1023 - min + 1;
66 }
67 } else {
68 min = 1024;
69 range_size = 65535 - 1024 + 1;
70 }
71 } else {
72 min = ntohs(range->min.udp.port);
73 range_size = ntohs(range->max.udp.port) - min + 1;
74 }
75
76 for (i = 0; i < range_size; i++, port++) {
77 *portptr = htons(min + port % range_size);
78 if (!nf_nat_used_tuple(tuple, ct))
79 return 1;
80 }
81 return 0;
82}
83
84static int
85udp_manip_pkt(struct sk_buff **pskb,
86 unsigned int iphdroff,
87 const struct nf_conntrack_tuple *tuple,
88 enum nf_nat_manip_type maniptype)
89{
90 struct iphdr *iph = (struct iphdr *)((*pskb)->data + iphdroff);
91 struct udphdr *hdr;
92 unsigned int hdroff = iphdroff + iph->ihl*4;
93 __be32 oldip, newip;
94 __be16 *portptr, newport;
95
96 if (!skb_make_writable(pskb, hdroff + sizeof(*hdr)))
97 return 0;
98
99 iph = (struct iphdr *)((*pskb)->data + iphdroff);
100 hdr = (struct udphdr *)((*pskb)->data + hdroff);
101
102 if (maniptype == IP_NAT_MANIP_SRC) {
103 /* Get rid of src ip and src pt */
104 oldip = iph->saddr;
105 newip = tuple->src.u3.ip;
106 newport = tuple->src.u.udp.port;
107 portptr = &hdr->source;
108 } else {
109 /* Get rid of dst ip and dst pt */
110 oldip = iph->daddr;
111 newip = tuple->dst.u3.ip;
112 newport = tuple->dst.u.udp.port;
113 portptr = &hdr->dest;
114 }
115 if (hdr->check || (*pskb)->ip_summed == CHECKSUM_PARTIAL) {
116 nf_proto_csum_replace4(&hdr->check, *pskb, oldip, newip, 1);
117 nf_proto_csum_replace2(&hdr->check, *pskb, *portptr, newport,
118 0);
119 if (!hdr->check)
120 hdr->check = CSUM_MANGLED_0;
121 }
122 *portptr = newport;
123 return 1;
124}
125
126struct nf_nat_protocol nf_nat_protocol_udp = {
127 .name = "UDP",
128 .protonum = IPPROTO_UDP,
129 .me = THIS_MODULE,
130 .manip_pkt = udp_manip_pkt,
131 .in_range = udp_in_range,
132 .unique_tuple = udp_unique_tuple,
133#if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \
134 defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE)
135 .range_to_nfattr = nf_nat_port_range_to_nfattr,
136 .nfattr_to_range = nf_nat_port_nfattr_to_range,
137#endif
138};
diff --git a/net/ipv4/netfilter/nf_nat_proto_unknown.c b/net/ipv4/netfilter/nf_nat_proto_unknown.c
new file mode 100644
index 000000000000..f50d0203f9c0
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_proto_unknown.c
@@ -0,0 +1,54 @@
1/* The "unknown" protocol. This is what is used for protocols we
2 * don't understand. It's returned by ip_ct_find_proto().
3 */
4
5/* (C) 1999-2001 Paul `Rusty' Russell
6 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/types.h>
14#include <linux/init.h>
15
16#include <linux/netfilter.h>
17#include <net/netfilter/nf_nat.h>
18#include <net/netfilter/nf_nat_rule.h>
19#include <net/netfilter/nf_nat_protocol.h>
20
21static int unknown_in_range(const struct nf_conntrack_tuple *tuple,
22 enum nf_nat_manip_type manip_type,
23 const union nf_conntrack_man_proto *min,
24 const union nf_conntrack_man_proto *max)
25{
26 return 1;
27}
28
29static int unknown_unique_tuple(struct nf_conntrack_tuple *tuple,
30 const struct nf_nat_range *range,
31 enum nf_nat_manip_type maniptype,
32 const struct nf_conn *ct)
33{
34 /* Sorry: we can't help you; if it's not unique, we can't frob
35 anything. */
36 return 0;
37}
38
39static int
40unknown_manip_pkt(struct sk_buff **pskb,
41 unsigned int iphdroff,
42 const struct nf_conntrack_tuple *tuple,
43 enum nf_nat_manip_type maniptype)
44{
45 return 1;
46}
47
48struct nf_nat_protocol nf_nat_unknown_protocol = {
49 .name = "unknown",
50 /* .me isn't set: getting a ref to this cannot fail. */
51 .manip_pkt = unknown_manip_pkt,
52 .in_range = unknown_in_range,
53 .unique_tuple = unknown_unique_tuple,
54};
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c
new file mode 100644
index 000000000000..b868ee0195d4
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_rule.c
@@ -0,0 +1,343 @@
1/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
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
9/* Everything about the rules for NAT. */
10#include <linux/types.h>
11#include <linux/ip.h>
12#include <linux/netfilter.h>
13#include <linux/netfilter_ipv4.h>
14#include <linux/module.h>
15#include <linux/kmod.h>
16#include <linux/skbuff.h>
17#include <linux/proc_fs.h>
18#include <net/checksum.h>
19#include <net/route.h>
20#include <linux/bitops.h>
21
22#include <linux/netfilter_ipv4/ip_tables.h>
23#include <net/netfilter/nf_nat.h>
24#include <net/netfilter/nf_nat_core.h>
25#include <net/netfilter/nf_nat_rule.h>
26
27#if 0
28#define DEBUGP printk
29#else
30#define DEBUGP(format, args...)
31#endif
32
33#define NAT_VALID_HOOKS ((1<<NF_IP_PRE_ROUTING) | (1<<NF_IP_POST_ROUTING) | (1<<NF_IP_LOCAL_OUT))
34
35static struct
36{
37 struct ipt_replace repl;
38 struct ipt_standard entries[3];
39 struct ipt_error term;
40} nat_initial_table __initdata = {
41 .repl = {
42 .name = "nat",
43 .valid_hooks = NAT_VALID_HOOKS,
44 .num_entries = 4,
45 .size = sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error),
46 .hook_entry = {
47 [NF_IP_PRE_ROUTING] = 0,
48 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard),
49 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 },
50 .underflow = {
51 [NF_IP_PRE_ROUTING] = 0,
52 [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard),
53 [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 },
54 },
55 .entries = {
56 /* PRE_ROUTING */
57 {
58 .entry = {
59 .target_offset = sizeof(struct ipt_entry),
60 .next_offset = sizeof(struct ipt_standard),
61 },
62 .target = {
63 .target = {
64 .u = {
65 .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
66 },
67 },
68 .verdict = -NF_ACCEPT - 1,
69 },
70 },
71 /* POST_ROUTING */
72 {
73 .entry = {
74 .target_offset = sizeof(struct ipt_entry),
75 .next_offset = sizeof(struct ipt_standard),
76 },
77 .target = {
78 .target = {
79 .u = {
80 .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
81 },
82 },
83 .verdict = -NF_ACCEPT - 1,
84 },
85 },
86 /* LOCAL_OUT */
87 {
88 .entry = {
89 .target_offset = sizeof(struct ipt_entry),
90 .next_offset = sizeof(struct ipt_standard),
91 },
92 .target = {
93 .target = {
94 .u = {
95 .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)),
96 },
97 },
98 .verdict = -NF_ACCEPT - 1,
99 },
100 },
101 },
102 /* ERROR */
103 .term = {
104 .entry = {
105 .target_offset = sizeof(struct ipt_entry),
106 .next_offset = sizeof(struct ipt_error),
107 },
108 .target = {
109 .target = {
110 .u = {
111 .user = {
112 .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)),
113 .name = IPT_ERROR_TARGET,
114 },
115 },
116 },
117 .errorname = "ERROR",
118 },
119 }
120};
121
122static struct ipt_table nat_table = {
123 .name = "nat",
124 .valid_hooks = NAT_VALID_HOOKS,
125 .lock = RW_LOCK_UNLOCKED,
126 .me = THIS_MODULE,
127 .af = AF_INET,
128};
129
130/* Source NAT */
131static unsigned int ipt_snat_target(struct sk_buff **pskb,
132 const struct net_device *in,
133 const struct net_device *out,
134 unsigned int hooknum,
135 const struct xt_target *target,
136 const void *targinfo)
137{
138 struct nf_conn *ct;
139 enum ip_conntrack_info ctinfo;
140 const struct nf_nat_multi_range_compat *mr = targinfo;
141
142 NF_CT_ASSERT(hooknum == NF_IP_POST_ROUTING);
143
144 ct = nf_ct_get(*pskb, &ctinfo);
145
146 /* Connection must be valid and new. */
147 NF_CT_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED ||
148 ctinfo == IP_CT_RELATED + IP_CT_IS_REPLY));
149 NF_CT_ASSERT(out);
150
151 return nf_nat_setup_info(ct, &mr->range[0], hooknum);
152}
153
154/* Before 2.6.11 we did implicit source NAT if required. Warn about change. */
155static void warn_if_extra_mangle(__be32 dstip, __be32 srcip)
156{
157 static int warned = 0;
158 struct flowi fl = { .nl_u = { .ip4_u = { .daddr = dstip } } };
159 struct rtable *rt;
160
161 if (ip_route_output_key(&rt, &fl) != 0)
162 return;
163
164 if (rt->rt_src != srcip && !warned) {
165 printk("NAT: no longer support implicit source local NAT\n");
166 printk("NAT: packet src %u.%u.%u.%u -> dst %u.%u.%u.%u\n",
167 NIPQUAD(srcip), NIPQUAD(dstip));
168 warned = 1;
169 }
170 ip_rt_put(rt);
171}
172
173static unsigned int ipt_dnat_target(struct sk_buff **pskb,
174 const struct net_device *in,
175 const struct net_device *out,
176 unsigned int hooknum,
177 const struct xt_target *target,
178 const void *targinfo)
179{
180 struct nf_conn *ct;
181 enum ip_conntrack_info ctinfo;
182 const struct nf_nat_multi_range_compat *mr = targinfo;
183
184 NF_CT_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
185 hooknum == NF_IP_LOCAL_OUT);
186
187 ct = nf_ct_get(*pskb, &ctinfo);
188
189 /* Connection must be valid and new. */
190 NF_CT_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED));
191
192 if (hooknum == NF_IP_LOCAL_OUT &&
193 mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)
194 warn_if_extra_mangle((*pskb)->nh.iph->daddr,
195 mr->range[0].min_ip);
196
197 return nf_nat_setup_info(ct, &mr->range[0], hooknum);
198}
199
200static int ipt_snat_checkentry(const char *tablename,
201 const void *entry,
202 const struct xt_target *target,
203 void *targinfo,
204 unsigned int hook_mask)
205{
206 struct nf_nat_multi_range_compat *mr = targinfo;
207
208 /* Must be a valid range */
209 if (mr->rangesize != 1) {
210 printk("SNAT: multiple ranges no longer supported\n");
211 return 0;
212 }
213 return 1;
214}
215
216static int ipt_dnat_checkentry(const char *tablename,
217 const void *entry,
218 const struct xt_target *target,
219 void *targinfo,
220 unsigned int hook_mask)
221{
222 struct nf_nat_multi_range_compat *mr = targinfo;
223
224 /* Must be a valid range */
225 if (mr->rangesize != 1) {
226 printk("DNAT: multiple ranges no longer supported\n");
227 return 0;
228 }
229 return 1;
230}
231
232inline unsigned int
233alloc_null_binding(struct nf_conn *ct,
234 struct nf_nat_info *info,
235 unsigned int hooknum)
236{
237 /* Force range to this IP; let proto decide mapping for
238 per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED).
239 Use reply in case it's already been mangled (eg local packet).
240 */
241 __be32 ip
242 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
243 ? ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip
244 : ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip);
245 struct nf_nat_range range
246 = { IP_NAT_RANGE_MAP_IPS, ip, ip, { 0 }, { 0 } };
247
248 DEBUGP("Allocating NULL binding for %p (%u.%u.%u.%u)\n",
249 ct, NIPQUAD(ip));
250 return nf_nat_setup_info(ct, &range, hooknum);
251}
252
253unsigned int
254alloc_null_binding_confirmed(struct nf_conn *ct,
255 struct nf_nat_info *info,
256 unsigned int hooknum)
257{
258 __be32 ip
259 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
260 ? ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip
261 : ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip);
262 u_int16_t all
263 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
264 ? ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all
265 : ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
266 struct nf_nat_range range
267 = { IP_NAT_RANGE_MAP_IPS, ip, ip, { all }, { all } };
268
269 DEBUGP("Allocating NULL binding for confirmed %p (%u.%u.%u.%u)\n",
270 ct, NIPQUAD(ip));
271 return nf_nat_setup_info(ct, &range, hooknum);
272}
273
274int nf_nat_rule_find(struct sk_buff **pskb,
275 unsigned int hooknum,
276 const struct net_device *in,
277 const struct net_device *out,
278 struct nf_conn *ct,
279 struct nf_nat_info *info)
280{
281 int ret;
282
283 ret = ipt_do_table(pskb, hooknum, in, out, &nat_table);
284
285 if (ret == NF_ACCEPT) {
286 if (!nf_nat_initialized(ct, HOOK2MANIP(hooknum)))
287 /* NUL mapping */
288 ret = alloc_null_binding(ct, info, hooknum);
289 }
290 return ret;
291}
292
293static struct ipt_target ipt_snat_reg = {
294 .name = "SNAT",
295 .target = ipt_snat_target,
296 .targetsize = sizeof(struct nf_nat_multi_range_compat),
297 .table = "nat",
298 .hooks = 1 << NF_IP_POST_ROUTING,
299 .checkentry = ipt_snat_checkentry,
300 .family = AF_INET,
301};
302
303static struct xt_target ipt_dnat_reg = {
304 .name = "DNAT",
305 .target = ipt_dnat_target,
306 .targetsize = sizeof(struct nf_nat_multi_range_compat),
307 .table = "nat",
308 .hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT),
309 .checkentry = ipt_dnat_checkentry,
310 .family = AF_INET,
311};
312
313int __init nf_nat_rule_init(void)
314{
315 int ret;
316
317 ret = ipt_register_table(&nat_table, &nat_initial_table.repl);
318 if (ret != 0)
319 return ret;
320 ret = xt_register_target(&ipt_snat_reg);
321 if (ret != 0)
322 goto unregister_table;
323
324 ret = xt_register_target(&ipt_dnat_reg);
325 if (ret != 0)
326 goto unregister_snat;
327
328 return ret;
329
330 unregister_snat:
331 xt_unregister_target(&ipt_snat_reg);
332 unregister_table:
333 ipt_unregister_table(&nat_table);
334
335 return ret;
336}
337
338void nf_nat_rule_cleanup(void)
339{
340 xt_unregister_target(&ipt_dnat_reg);
341 xt_unregister_target(&ipt_snat_reg);
342 ipt_unregister_table(&nat_table);
343}
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c
new file mode 100644
index 000000000000..3d524b957310
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_sip.c
@@ -0,0 +1,283 @@
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 <net/netfilter/nf_nat.h>
17#include <net/netfilter/nf_nat_helper.h>
18#include <net/netfilter/nf_nat_rule.h>
19#include <net/netfilter/nf_conntrack_helper.h>
20#include <net/netfilter/nf_conntrack_expect.h>
21#include <linux/netfilter/nf_conntrack_sip.h>
22
23MODULE_LICENSE("GPL");
24MODULE_AUTHOR("Christian Hentschel <chentschel@arnet.com.ar>");
25MODULE_DESCRIPTION("SIP NAT helper");
26MODULE_ALIAS("ip_nat_sip");
27
28#if 0
29#define DEBUGP printk
30#else
31#define DEBUGP(format, args...)
32#endif
33
34struct addr_map {
35 struct {
36 char src[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
37 char dst[sizeof("nnn.nnn.nnn.nnn:nnnnn")];
38 unsigned int srclen, srciplen;
39 unsigned int dstlen, dstiplen;
40 } addr[IP_CT_DIR_MAX];
41};
42
43static void addr_map_init(struct nf_conn *ct, struct addr_map *map)
44{
45 struct nf_conntrack_tuple *t;
46 enum ip_conntrack_dir dir;
47 unsigned int n;
48
49 for (dir = 0; dir < IP_CT_DIR_MAX; dir++) {
50 t = &ct->tuplehash[dir].tuple;
51
52 n = sprintf(map->addr[dir].src, "%u.%u.%u.%u",
53 NIPQUAD(t->src.u3.ip));
54 map->addr[dir].srciplen = n;
55 n += sprintf(map->addr[dir].src + n, ":%u",
56 ntohs(t->src.u.udp.port));
57 map->addr[dir].srclen = n;
58
59 n = sprintf(map->addr[dir].dst, "%u.%u.%u.%u",
60 NIPQUAD(t->dst.u3.ip));
61 map->addr[dir].dstiplen = n;
62 n += sprintf(map->addr[dir].dst + n, ":%u",
63 ntohs(t->dst.u.udp.port));
64 map->addr[dir].dstlen = n;
65 }
66}
67
68static int map_sip_addr(struct sk_buff **pskb, enum ip_conntrack_info ctinfo,
69 struct nf_conn *ct, const char **dptr, size_t dlen,
70 enum sip_header_pos pos, struct addr_map *map)
71{
72 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
73 unsigned int matchlen, matchoff, addrlen;
74 char *addr;
75
76 if (ct_sip_get_info(ct, *dptr, dlen, &matchoff, &matchlen, pos) <= 0)
77 return 1;
78
79 if ((matchlen == map->addr[dir].srciplen ||
80 matchlen == map->addr[dir].srclen) &&
81 memcmp(*dptr + matchoff, map->addr[dir].src, matchlen) == 0) {
82 addr = map->addr[!dir].dst;
83 addrlen = map->addr[!dir].dstlen;
84 } else if ((matchlen == map->addr[dir].dstiplen ||
85 matchlen == map->addr[dir].dstlen) &&
86 memcmp(*dptr + matchoff, map->addr[dir].dst, matchlen) == 0) {
87 addr = map->addr[!dir].src;
88 addrlen = map->addr[!dir].srclen;
89 } else
90 return 1;
91
92 if (!nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
93 matchoff, matchlen, addr, addrlen))
94 return 0;
95 *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
96 return 1;
97
98}
99
100static unsigned int ip_nat_sip(struct sk_buff **pskb,
101 enum ip_conntrack_info ctinfo,
102 struct nf_conn *ct,
103 const char **dptr)
104{
105 enum sip_header_pos pos;
106 struct addr_map map;
107 int dataoff, datalen;
108
109 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
110 datalen = (*pskb)->len - dataoff;
111 if (datalen < sizeof("SIP/2.0") - 1)
112 return NF_DROP;
113
114 addr_map_init(ct, &map);
115
116 /* Basic rules: requests and responses. */
117 if (strncmp(*dptr, "SIP/2.0", sizeof("SIP/2.0") - 1) != 0) {
118 /* 10.2: Constructing the REGISTER Request:
119 *
120 * The "userinfo" and "@" components of the SIP URI MUST NOT
121 * be present.
122 */
123 if (datalen >= sizeof("REGISTER") - 1 &&
124 strncmp(*dptr, "REGISTER", sizeof("REGISTER") - 1) == 0)
125 pos = POS_REG_REQ_URI;
126 else
127 pos = POS_REQ_URI;
128
129 if (!map_sip_addr(pskb, ctinfo, ct, dptr, datalen, pos, &map))
130 return NF_DROP;
131 }
132
133 if (!map_sip_addr(pskb, ctinfo, ct, dptr, datalen, POS_FROM, &map) ||
134 !map_sip_addr(pskb, ctinfo, ct, dptr, datalen, POS_TO, &map) ||
135 !map_sip_addr(pskb, ctinfo, ct, dptr, datalen, POS_VIA, &map) ||
136 !map_sip_addr(pskb, ctinfo, ct, dptr, datalen, POS_CONTACT, &map))
137 return NF_DROP;
138 return NF_ACCEPT;
139}
140
141static unsigned int mangle_sip_packet(struct sk_buff **pskb,
142 enum ip_conntrack_info ctinfo,
143 struct nf_conn *ct,
144 const char **dptr, size_t dlen,
145 char *buffer, int bufflen,
146 enum sip_header_pos pos)
147{
148 unsigned int matchlen, matchoff;
149
150 if (ct_sip_get_info(ct, *dptr, dlen, &matchoff, &matchlen, pos) <= 0)
151 return 0;
152
153 if (!nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
154 matchoff, matchlen, buffer, bufflen))
155 return 0;
156
157 /* We need to reload this. Thanks Patrick. */
158 *dptr = (*pskb)->data + (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
159 return 1;
160}
161
162static int mangle_content_len(struct sk_buff **pskb,
163 enum ip_conntrack_info ctinfo,
164 struct nf_conn *ct,
165 const char *dptr)
166{
167 unsigned int dataoff, matchoff, matchlen;
168 char buffer[sizeof("65536")];
169 int bufflen;
170
171 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
172
173 /* Get actual SDP lenght */
174 if (ct_sip_get_info(ct, dptr, (*pskb)->len - dataoff, &matchoff,
175 &matchlen, POS_SDP_HEADER) > 0) {
176
177 /* since ct_sip_get_info() give us a pointer passing 'v='
178 we need to add 2 bytes in this count. */
179 int c_len = (*pskb)->len - dataoff - matchoff + 2;
180
181 /* Now, update SDP length */
182 if (ct_sip_get_info(ct, dptr, (*pskb)->len - dataoff, &matchoff,
183 &matchlen, POS_CONTENT) > 0) {
184
185 bufflen = sprintf(buffer, "%u", c_len);
186 return nf_nat_mangle_udp_packet(pskb, ct, ctinfo,
187 matchoff, matchlen,
188 buffer, bufflen);
189 }
190 }
191 return 0;
192}
193
194static unsigned int mangle_sdp(struct sk_buff **pskb,
195 enum ip_conntrack_info ctinfo,
196 struct nf_conn *ct,
197 __be32 newip, u_int16_t port,
198 const char *dptr)
199{
200 char buffer[sizeof("nnn.nnn.nnn.nnn")];
201 unsigned int dataoff, bufflen;
202
203 dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr);
204
205 /* Mangle owner and contact info. */
206 bufflen = sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(newip));
207 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
208 buffer, bufflen, POS_OWNER_IP4))
209 return 0;
210
211 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
212 buffer, bufflen, POS_CONNECTION_IP4))
213 return 0;
214
215 /* Mangle media port. */
216 bufflen = sprintf(buffer, "%u", port);
217 if (!mangle_sip_packet(pskb, ctinfo, ct, &dptr, (*pskb)->len - dataoff,
218 buffer, bufflen, POS_MEDIA))
219 return 0;
220
221 return mangle_content_len(pskb, ctinfo, ct, dptr);
222}
223
224/* So, this packet has hit the connection tracking matching code.
225 Mangle it, and change the expectation to match the new version. */
226static unsigned int ip_nat_sdp(struct sk_buff **pskb,
227 enum ip_conntrack_info ctinfo,
228 struct nf_conntrack_expect *exp,
229 const char *dptr)
230{
231 struct nf_conn *ct = exp->master;
232 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
233 __be32 newip;
234 u_int16_t port;
235
236 DEBUGP("ip_nat_sdp():\n");
237
238 /* Connection will come from reply */
239 newip = ct->tuplehash[!dir].tuple.dst.u3.ip;
240
241 exp->tuple.dst.u3.ip = newip;
242 exp->saved_proto.udp.port = exp->tuple.dst.u.udp.port;
243 exp->dir = !dir;
244
245 /* When you see the packet, we need to NAT it the same as the
246 this one. */
247 exp->expectfn = nf_nat_follow_master;
248
249 /* Try to get same port: if not, try to change it. */
250 for (port = ntohs(exp->saved_proto.udp.port); port != 0; port++) {
251 exp->tuple.dst.u.udp.port = htons(port);
252 if (nf_conntrack_expect_related(exp) == 0)
253 break;
254 }
255
256 if (port == 0)
257 return NF_DROP;
258
259 if (!mangle_sdp(pskb, ctinfo, ct, newip, port, dptr)) {
260 nf_conntrack_unexpect_related(exp);
261 return NF_DROP;
262 }
263 return NF_ACCEPT;
264}
265
266static void __exit nf_nat_sip_fini(void)
267{
268 rcu_assign_pointer(nf_nat_sip_hook, NULL);
269 rcu_assign_pointer(nf_nat_sdp_hook, NULL);
270 synchronize_rcu();
271}
272
273static int __init nf_nat_sip_init(void)
274{
275 BUG_ON(rcu_dereference(nf_nat_sip_hook));
276 BUG_ON(rcu_dereference(nf_nat_sdp_hook));
277 rcu_assign_pointer(nf_nat_sip_hook, ip_nat_sip);
278 rcu_assign_pointer(nf_nat_sdp_hook, ip_nat_sdp);
279 return 0;
280}
281
282module_init(nf_nat_sip_init);
283module_exit(nf_nat_sip_fini);
diff --git a/net/ipv4/netfilter/nf_nat_snmp_basic.c b/net/ipv4/netfilter/nf_nat_snmp_basic.c
new file mode 100644
index 000000000000..f12528fe1bf9
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c
@@ -0,0 +1,1332 @@
1/*
2 * nf_nat_snmp_basic.c
3 *
4 * Basic SNMP Application Layer Gateway
5 *
6 * This IP NAT module is intended for use with SNMP network
7 * discovery and monitoring applications where target networks use
8 * conflicting private address realms.
9 *
10 * Static NAT is used to remap the networks from the view of the network
11 * management system at the IP layer, and this module remaps some application
12 * layer addresses to match.
13 *
14 * The simplest form of ALG is performed, where only tagged IP addresses
15 * are modified. The module does not need to be MIB aware and only scans
16 * messages at the ASN.1/BER level.
17 *
18 * Currently, only SNMPv1 and SNMPv2 are supported.
19 *
20 * More information on ALG and associated issues can be found in
21 * RFC 2962
22 *
23 * The ASB.1/BER parsing code is derived from the gxsnmp package by Gregory
24 * McLean & Jochen Friedrich, stripped down for use in the kernel.
25 *
26 * Copyright (c) 2000 RP Internet (www.rpi.net.au).
27 *
28 * This program is free software; you can redistribute it and/or modify
29 * it under the terms of the GNU General Public License as published by
30 * the Free Software Foundation; either version 2 of the License, or
31 * (at your option) any later version.
32 * This program is distributed in the hope that it will be useful,
33 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public License
37 * along with this program; if not, write to the Free Software
38 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 *
40 * Author: James Morris <jmorris@intercode.com.au>
41 *
42 * Updates:
43 * 2000-08-06: Convert to new helper API (Harald Welte).
44 *
45 */
46#include <linux/module.h>
47#include <linux/moduleparam.h>
48#include <linux/types.h>
49#include <linux/kernel.h>
50#include <linux/in.h>
51#include <linux/ip.h>
52#include <linux/udp.h>
53#include <net/checksum.h>
54#include <net/udp.h>
55
56#include <net/netfilter/nf_nat.h>
57#include <net/netfilter/nf_conntrack_helper.h>
58#include <net/netfilter/nf_nat_helper.h>
59
60MODULE_LICENSE("GPL");
61MODULE_AUTHOR("James Morris <jmorris@intercode.com.au>");
62MODULE_DESCRIPTION("Basic SNMP Application Layer Gateway");
63MODULE_ALIAS("ip_nat_snmp_basic");
64
65#define SNMP_PORT 161
66#define SNMP_TRAP_PORT 162
67#define NOCT1(n) (*(u8 *)n)
68
69static int debug;
70static DEFINE_SPINLOCK(snmp_lock);
71
72/*
73 * Application layer address mapping mimics the NAT mapping, but
74 * only for the first octet in this case (a more flexible system
75 * can be implemented if needed).
76 */
77struct oct1_map
78{
79 u_int8_t from;
80 u_int8_t to;
81};
82
83
84/*****************************************************************************
85 *
86 * Basic ASN.1 decoding routines (gxsnmp author Dirk Wisse)
87 *
88 *****************************************************************************/
89
90/* Class */
91#define ASN1_UNI 0 /* Universal */
92#define ASN1_APL 1 /* Application */
93#define ASN1_CTX 2 /* Context */
94#define ASN1_PRV 3 /* Private */
95
96/* Tag */
97#define ASN1_EOC 0 /* End Of Contents */
98#define ASN1_BOL 1 /* Boolean */
99#define ASN1_INT 2 /* Integer */
100#define ASN1_BTS 3 /* Bit String */
101#define ASN1_OTS 4 /* Octet String */
102#define ASN1_NUL 5 /* Null */
103#define ASN1_OJI 6 /* Object Identifier */
104#define ASN1_OJD 7 /* Object Description */
105#define ASN1_EXT 8 /* External */
106#define ASN1_SEQ 16 /* Sequence */
107#define ASN1_SET 17 /* Set */
108#define ASN1_NUMSTR 18 /* Numerical String */
109#define ASN1_PRNSTR 19 /* Printable String */
110#define ASN1_TEXSTR 20 /* Teletext String */
111#define ASN1_VIDSTR 21 /* Video String */
112#define ASN1_IA5STR 22 /* IA5 String */
113#define ASN1_UNITIM 23 /* Universal Time */
114#define ASN1_GENTIM 24 /* General Time */
115#define ASN1_GRASTR 25 /* Graphical String */
116#define ASN1_VISSTR 26 /* Visible String */
117#define ASN1_GENSTR 27 /* General String */
118
119/* Primitive / Constructed methods*/
120#define ASN1_PRI 0 /* Primitive */
121#define ASN1_CON 1 /* Constructed */
122
123/*
124 * Error codes.
125 */
126#define ASN1_ERR_NOERROR 0
127#define ASN1_ERR_DEC_EMPTY 2
128#define ASN1_ERR_DEC_EOC_MISMATCH 3
129#define ASN1_ERR_DEC_LENGTH_MISMATCH 4
130#define ASN1_ERR_DEC_BADVALUE 5
131
132/*
133 * ASN.1 context.
134 */
135struct asn1_ctx
136{
137 int error; /* Error condition */
138 unsigned char *pointer; /* Octet just to be decoded */
139 unsigned char *begin; /* First octet */
140 unsigned char *end; /* Octet after last octet */
141};
142
143/*
144 * Octet string (not null terminated)
145 */
146struct asn1_octstr
147{
148 unsigned char *data;
149 unsigned int len;
150};
151
152static void asn1_open(struct asn1_ctx *ctx,
153 unsigned char *buf,
154 unsigned int len)
155{
156 ctx->begin = buf;
157 ctx->end = buf + len;
158 ctx->pointer = buf;
159 ctx->error = ASN1_ERR_NOERROR;
160}
161
162static unsigned char asn1_octet_decode(struct asn1_ctx *ctx, unsigned char *ch)
163{
164 if (ctx->pointer >= ctx->end) {
165 ctx->error = ASN1_ERR_DEC_EMPTY;
166 return 0;
167 }
168 *ch = *(ctx->pointer)++;
169 return 1;
170}
171
172static unsigned char asn1_tag_decode(struct asn1_ctx *ctx, unsigned int *tag)
173{
174 unsigned char ch;
175
176 *tag = 0;
177
178 do
179 {
180 if (!asn1_octet_decode(ctx, &ch))
181 return 0;
182 *tag <<= 7;
183 *tag |= ch & 0x7F;
184 } while ((ch & 0x80) == 0x80);
185 return 1;
186}
187
188static unsigned char asn1_id_decode(struct asn1_ctx *ctx,
189 unsigned int *cls,
190 unsigned int *con,
191 unsigned int *tag)
192{
193 unsigned char ch;
194
195 if (!asn1_octet_decode(ctx, &ch))
196 return 0;
197
198 *cls = (ch & 0xC0) >> 6;
199 *con = (ch & 0x20) >> 5;
200 *tag = (ch & 0x1F);
201
202 if (*tag == 0x1F) {
203 if (!asn1_tag_decode(ctx, tag))
204 return 0;
205 }
206 return 1;
207}
208
209static unsigned char asn1_length_decode(struct asn1_ctx *ctx,
210 unsigned int *def,
211 unsigned int *len)
212{
213 unsigned char ch, cnt;
214
215 if (!asn1_octet_decode(ctx, &ch))
216 return 0;
217
218 if (ch == 0x80)
219 *def = 0;
220 else {
221 *def = 1;
222
223 if (ch < 0x80)
224 *len = ch;
225 else {
226 cnt = (unsigned char) (ch & 0x7F);
227 *len = 0;
228
229 while (cnt > 0) {
230 if (!asn1_octet_decode(ctx, &ch))
231 return 0;
232 *len <<= 8;
233 *len |= ch;
234 cnt--;
235 }
236 }
237 }
238 return 1;
239}
240
241static unsigned char asn1_header_decode(struct asn1_ctx *ctx,
242 unsigned char **eoc,
243 unsigned int *cls,
244 unsigned int *con,
245 unsigned int *tag)
246{
247 unsigned int def, len;
248
249 if (!asn1_id_decode(ctx, cls, con, tag))
250 return 0;
251
252 def = len = 0;
253 if (!asn1_length_decode(ctx, &def, &len))
254 return 0;
255
256 if (def)
257 *eoc = ctx->pointer + len;
258 else
259 *eoc = NULL;
260 return 1;
261}
262
263static unsigned char asn1_eoc_decode(struct asn1_ctx *ctx, unsigned char *eoc)
264{
265 unsigned char ch;
266
267 if (eoc == 0) {
268 if (!asn1_octet_decode(ctx, &ch))
269 return 0;
270
271 if (ch != 0x00) {
272 ctx->error = ASN1_ERR_DEC_EOC_MISMATCH;
273 return 0;
274 }
275
276 if (!asn1_octet_decode(ctx, &ch))
277 return 0;
278
279 if (ch != 0x00) {
280 ctx->error = ASN1_ERR_DEC_EOC_MISMATCH;
281 return 0;
282 }
283 return 1;
284 } else {
285 if (ctx->pointer != eoc) {
286 ctx->error = ASN1_ERR_DEC_LENGTH_MISMATCH;
287 return 0;
288 }
289 return 1;
290 }
291}
292
293static unsigned char asn1_null_decode(struct asn1_ctx *ctx, unsigned char *eoc)
294{
295 ctx->pointer = eoc;
296 return 1;
297}
298
299static unsigned char asn1_long_decode(struct asn1_ctx *ctx,
300 unsigned char *eoc,
301 long *integer)
302{
303 unsigned char ch;
304 unsigned int len;
305
306 if (!asn1_octet_decode(ctx, &ch))
307 return 0;
308
309 *integer = (signed char) ch;
310 len = 1;
311
312 while (ctx->pointer < eoc) {
313 if (++len > sizeof (long)) {
314 ctx->error = ASN1_ERR_DEC_BADVALUE;
315 return 0;
316 }
317
318 if (!asn1_octet_decode(ctx, &ch))
319 return 0;
320
321 *integer <<= 8;
322 *integer |= ch;
323 }
324 return 1;
325}
326
327static unsigned char asn1_uint_decode(struct asn1_ctx *ctx,
328 unsigned char *eoc,
329 unsigned int *integer)
330{
331 unsigned char ch;
332 unsigned int len;
333
334 if (!asn1_octet_decode(ctx, &ch))
335 return 0;
336
337 *integer = ch;
338 if (ch == 0) len = 0;
339 else len = 1;
340
341 while (ctx->pointer < eoc) {
342 if (++len > sizeof (unsigned int)) {
343 ctx->error = ASN1_ERR_DEC_BADVALUE;
344 return 0;
345 }
346
347 if (!asn1_octet_decode(ctx, &ch))
348 return 0;
349
350 *integer <<= 8;
351 *integer |= ch;
352 }
353 return 1;
354}
355
356static unsigned char asn1_ulong_decode(struct asn1_ctx *ctx,
357 unsigned char *eoc,
358 unsigned long *integer)
359{
360 unsigned char ch;
361 unsigned int len;
362
363 if (!asn1_octet_decode(ctx, &ch))
364 return 0;
365
366 *integer = ch;
367 if (ch == 0) len = 0;
368 else len = 1;
369
370 while (ctx->pointer < eoc) {
371 if (++len > sizeof (unsigned long)) {
372 ctx->error = ASN1_ERR_DEC_BADVALUE;
373 return 0;
374 }
375
376 if (!asn1_octet_decode(ctx, &ch))
377 return 0;
378
379 *integer <<= 8;
380 *integer |= ch;
381 }
382 return 1;
383}
384
385static unsigned char asn1_octets_decode(struct asn1_ctx *ctx,
386 unsigned char *eoc,
387 unsigned char **octets,
388 unsigned int *len)
389{
390 unsigned char *ptr;
391
392 *len = 0;
393
394 *octets = kmalloc(eoc - ctx->pointer, GFP_ATOMIC);
395 if (*octets == NULL) {
396 if (net_ratelimit())
397 printk("OOM in bsalg (%d)\n", __LINE__);
398 return 0;
399 }
400
401 ptr = *octets;
402 while (ctx->pointer < eoc) {
403 if (!asn1_octet_decode(ctx, (unsigned char *)ptr++)) {
404 kfree(*octets);
405 *octets = NULL;
406 return 0;
407 }
408 (*len)++;
409 }
410 return 1;
411}
412
413static unsigned char asn1_subid_decode(struct asn1_ctx *ctx,
414 unsigned long *subid)
415{
416 unsigned char ch;
417
418 *subid = 0;
419
420 do {
421 if (!asn1_octet_decode(ctx, &ch))
422 return 0;
423
424 *subid <<= 7;
425 *subid |= ch & 0x7F;
426 } while ((ch & 0x80) == 0x80);
427 return 1;
428}
429
430static unsigned char asn1_oid_decode(struct asn1_ctx *ctx,
431 unsigned char *eoc,
432 unsigned long **oid,
433 unsigned int *len)
434{
435 unsigned long subid;
436 unsigned int size;
437 unsigned long *optr;
438
439 size = eoc - ctx->pointer + 1;
440 *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
441 if (*oid == NULL) {
442 if (net_ratelimit())
443 printk("OOM in bsalg (%d)\n", __LINE__);
444 return 0;
445 }
446
447 optr = *oid;
448
449 if (!asn1_subid_decode(ctx, &subid)) {
450 kfree(*oid);
451 *oid = NULL;
452 return 0;
453 }
454
455 if (subid < 40) {
456 optr [0] = 0;
457 optr [1] = subid;
458 } else if (subid < 80) {
459 optr [0] = 1;
460 optr [1] = subid - 40;
461 } else {
462 optr [0] = 2;
463 optr [1] = subid - 80;
464 }
465
466 *len = 2;
467 optr += 2;
468
469 while (ctx->pointer < eoc) {
470 if (++(*len) > size) {
471 ctx->error = ASN1_ERR_DEC_BADVALUE;
472 kfree(*oid);
473 *oid = NULL;
474 return 0;
475 }
476
477 if (!asn1_subid_decode(ctx, optr++)) {
478 kfree(*oid);
479 *oid = NULL;
480 return 0;
481 }
482 }
483 return 1;
484}
485
486/*****************************************************************************
487 *
488 * SNMP decoding routines (gxsnmp author Dirk Wisse)
489 *
490 *****************************************************************************/
491
492/* SNMP Versions */
493#define SNMP_V1 0
494#define SNMP_V2C 1
495#define SNMP_V2 2
496#define SNMP_V3 3
497
498/* Default Sizes */
499#define SNMP_SIZE_COMM 256
500#define SNMP_SIZE_OBJECTID 128
501#define SNMP_SIZE_BUFCHR 256
502#define SNMP_SIZE_BUFINT 128
503#define SNMP_SIZE_SMALLOBJECTID 16
504
505/* Requests */
506#define SNMP_PDU_GET 0
507#define SNMP_PDU_NEXT 1
508#define SNMP_PDU_RESPONSE 2
509#define SNMP_PDU_SET 3
510#define SNMP_PDU_TRAP1 4
511#define SNMP_PDU_BULK 5
512#define SNMP_PDU_INFORM 6
513#define SNMP_PDU_TRAP2 7
514
515/* Errors */
516#define SNMP_NOERROR 0
517#define SNMP_TOOBIG 1
518#define SNMP_NOSUCHNAME 2
519#define SNMP_BADVALUE 3
520#define SNMP_READONLY 4
521#define SNMP_GENERROR 5
522#define SNMP_NOACCESS 6
523#define SNMP_WRONGTYPE 7
524#define SNMP_WRONGLENGTH 8
525#define SNMP_WRONGENCODING 9
526#define SNMP_WRONGVALUE 10
527#define SNMP_NOCREATION 11
528#define SNMP_INCONSISTENTVALUE 12
529#define SNMP_RESOURCEUNAVAILABLE 13
530#define SNMP_COMMITFAILED 14
531#define SNMP_UNDOFAILED 15
532#define SNMP_AUTHORIZATIONERROR 16
533#define SNMP_NOTWRITABLE 17
534#define SNMP_INCONSISTENTNAME 18
535
536/* General SNMP V1 Traps */
537#define SNMP_TRAP_COLDSTART 0
538#define SNMP_TRAP_WARMSTART 1
539#define SNMP_TRAP_LINKDOWN 2
540#define SNMP_TRAP_LINKUP 3
541#define SNMP_TRAP_AUTFAILURE 4
542#define SNMP_TRAP_EQPNEIGHBORLOSS 5
543#define SNMP_TRAP_ENTSPECIFIC 6
544
545/* SNMPv1 Types */
546#define SNMP_NULL 0
547#define SNMP_INTEGER 1 /* l */
548#define SNMP_OCTETSTR 2 /* c */
549#define SNMP_DISPLAYSTR 2 /* c */
550#define SNMP_OBJECTID 3 /* ul */
551#define SNMP_IPADDR 4 /* uc */
552#define SNMP_COUNTER 5 /* ul */
553#define SNMP_GAUGE 6 /* ul */
554#define SNMP_TIMETICKS 7 /* ul */
555#define SNMP_OPAQUE 8 /* c */
556
557/* Additional SNMPv2 Types */
558#define SNMP_UINTEGER 5 /* ul */
559#define SNMP_BITSTR 9 /* uc */
560#define SNMP_NSAP 10 /* uc */
561#define SNMP_COUNTER64 11 /* ul */
562#define SNMP_NOSUCHOBJECT 12
563#define SNMP_NOSUCHINSTANCE 13
564#define SNMP_ENDOFMIBVIEW 14
565
566union snmp_syntax
567{
568 unsigned char uc[0]; /* 8 bit unsigned */
569 char c[0]; /* 8 bit signed */
570 unsigned long ul[0]; /* 32 bit unsigned */
571 long l[0]; /* 32 bit signed */
572};
573
574struct snmp_object
575{
576 unsigned long *id;
577 unsigned int id_len;
578 unsigned short type;
579 unsigned int syntax_len;
580 union snmp_syntax syntax;
581};
582
583struct snmp_request
584{
585 unsigned long id;
586 unsigned int error_status;
587 unsigned int error_index;
588};
589
590struct snmp_v1_trap
591{
592 unsigned long *id;
593 unsigned int id_len;
594 unsigned long ip_address; /* pointer */
595 unsigned int general;
596 unsigned int specific;
597 unsigned long time;
598};
599
600/* SNMP types */
601#define SNMP_IPA 0
602#define SNMP_CNT 1
603#define SNMP_GGE 2
604#define SNMP_TIT 3
605#define SNMP_OPQ 4
606#define SNMP_C64 6
607
608/* SNMP errors */
609#define SERR_NSO 0
610#define SERR_NSI 1
611#define SERR_EOM 2
612
613static inline void mangle_address(unsigned char *begin,
614 unsigned char *addr,
615 const struct oct1_map *map,
616 __sum16 *check);
617struct snmp_cnv
618{
619 unsigned int class;
620 unsigned int tag;
621 int syntax;
622};
623
624static struct snmp_cnv snmp_conv [] =
625{
626 {ASN1_UNI, ASN1_NUL, SNMP_NULL},
627 {ASN1_UNI, ASN1_INT, SNMP_INTEGER},
628 {ASN1_UNI, ASN1_OTS, SNMP_OCTETSTR},
629 {ASN1_UNI, ASN1_OTS, SNMP_DISPLAYSTR},
630 {ASN1_UNI, ASN1_OJI, SNMP_OBJECTID},
631 {ASN1_APL, SNMP_IPA, SNMP_IPADDR},
632 {ASN1_APL, SNMP_CNT, SNMP_COUNTER}, /* Counter32 */
633 {ASN1_APL, SNMP_GGE, SNMP_GAUGE}, /* Gauge32 == Unsigned32 */
634 {ASN1_APL, SNMP_TIT, SNMP_TIMETICKS},
635 {ASN1_APL, SNMP_OPQ, SNMP_OPAQUE},
636
637 /* SNMPv2 data types and errors */
638 {ASN1_UNI, ASN1_BTS, SNMP_BITSTR},
639 {ASN1_APL, SNMP_C64, SNMP_COUNTER64},
640 {ASN1_CTX, SERR_NSO, SNMP_NOSUCHOBJECT},
641 {ASN1_CTX, SERR_NSI, SNMP_NOSUCHINSTANCE},
642 {ASN1_CTX, SERR_EOM, SNMP_ENDOFMIBVIEW},
643 {0, 0, -1}
644};
645
646static unsigned char snmp_tag_cls2syntax(unsigned int tag,
647 unsigned int cls,
648 unsigned short *syntax)
649{
650 struct snmp_cnv *cnv;
651
652 cnv = snmp_conv;
653
654 while (cnv->syntax != -1) {
655 if (cnv->tag == tag && cnv->class == cls) {
656 *syntax = cnv->syntax;
657 return 1;
658 }
659 cnv++;
660 }
661 return 0;
662}
663
664static unsigned char snmp_object_decode(struct asn1_ctx *ctx,
665 struct snmp_object **obj)
666{
667 unsigned int cls, con, tag, len, idlen;
668 unsigned short type;
669 unsigned char *eoc, *end, *p;
670 unsigned long *lp, *id;
671 unsigned long ul;
672 long l;
673
674 *obj = NULL;
675 id = NULL;
676
677 if (!asn1_header_decode(ctx, &eoc, &cls, &con, &tag))
678 return 0;
679
680 if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
681 return 0;
682
683 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
684 return 0;
685
686 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OJI)
687 return 0;
688
689 if (!asn1_oid_decode(ctx, end, &id, &idlen))
690 return 0;
691
692 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag)) {
693 kfree(id);
694 return 0;
695 }
696
697 if (con != ASN1_PRI) {
698 kfree(id);
699 return 0;
700 }
701
702 type = 0;
703 if (!snmp_tag_cls2syntax(tag, cls, &type)) {
704 kfree(id);
705 return 0;
706 }
707
708 l = 0;
709 switch (type) {
710 case SNMP_INTEGER:
711 len = sizeof(long);
712 if (!asn1_long_decode(ctx, end, &l)) {
713 kfree(id);
714 return 0;
715 }
716 *obj = kmalloc(sizeof(struct snmp_object) + len,
717 GFP_ATOMIC);
718 if (*obj == NULL) {
719 kfree(id);
720 if (net_ratelimit())
721 printk("OOM in bsalg (%d)\n", __LINE__);
722 return 0;
723 }
724 (*obj)->syntax.l[0] = l;
725 break;
726 case SNMP_OCTETSTR:
727 case SNMP_OPAQUE:
728 if (!asn1_octets_decode(ctx, end, &p, &len)) {
729 kfree(id);
730 return 0;
731 }
732 *obj = kmalloc(sizeof(struct snmp_object) + len,
733 GFP_ATOMIC);
734 if (*obj == NULL) {
735 kfree(id);
736 if (net_ratelimit())
737 printk("OOM in bsalg (%d)\n", __LINE__);
738 return 0;
739 }
740 memcpy((*obj)->syntax.c, p, len);
741 kfree(p);
742 break;
743 case SNMP_NULL:
744 case SNMP_NOSUCHOBJECT:
745 case SNMP_NOSUCHINSTANCE:
746 case SNMP_ENDOFMIBVIEW:
747 len = 0;
748 *obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC);
749 if (*obj == NULL) {
750 kfree(id);
751 if (net_ratelimit())
752 printk("OOM in bsalg (%d)\n", __LINE__);
753 return 0;
754 }
755 if (!asn1_null_decode(ctx, end)) {
756 kfree(id);
757 kfree(*obj);
758 *obj = NULL;
759 return 0;
760 }
761 break;
762 case SNMP_OBJECTID:
763 if (!asn1_oid_decode(ctx, end, (unsigned long **)&lp, &len)) {
764 kfree(id);
765 return 0;
766 }
767 len *= sizeof(unsigned long);
768 *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC);
769 if (*obj == NULL) {
770 kfree(lp);
771 kfree(id);
772 if (net_ratelimit())
773 printk("OOM in bsalg (%d)\n", __LINE__);
774 return 0;
775 }
776 memcpy((*obj)->syntax.ul, lp, len);
777 kfree(lp);
778 break;
779 case SNMP_IPADDR:
780 if (!asn1_octets_decode(ctx, end, &p, &len)) {
781 kfree(id);
782 return 0;
783 }
784 if (len != 4) {
785 kfree(p);
786 kfree(id);
787 return 0;
788 }
789 *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC);
790 if (*obj == NULL) {
791 kfree(p);
792 kfree(id);
793 if (net_ratelimit())
794 printk("OOM in bsalg (%d)\n", __LINE__);
795 return 0;
796 }
797 memcpy((*obj)->syntax.uc, p, len);
798 kfree(p);
799 break;
800 case SNMP_COUNTER:
801 case SNMP_GAUGE:
802 case SNMP_TIMETICKS:
803 len = sizeof(unsigned long);
804 if (!asn1_ulong_decode(ctx, end, &ul)) {
805 kfree(id);
806 return 0;
807 }
808 *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC);
809 if (*obj == NULL) {
810 kfree(id);
811 if (net_ratelimit())
812 printk("OOM in bsalg (%d)\n", __LINE__);
813 return 0;
814 }
815 (*obj)->syntax.ul[0] = ul;
816 break;
817 default:
818 kfree(id);
819 return 0;
820 }
821
822 (*obj)->syntax_len = len;
823 (*obj)->type = type;
824 (*obj)->id = id;
825 (*obj)->id_len = idlen;
826
827 if (!asn1_eoc_decode(ctx, eoc)) {
828 kfree(id);
829 kfree(*obj);
830 *obj = NULL;
831 return 0;
832 }
833 return 1;
834}
835
836static unsigned char snmp_request_decode(struct asn1_ctx *ctx,
837 struct snmp_request *request)
838{
839 unsigned int cls, con, tag;
840 unsigned char *end;
841
842 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
843 return 0;
844
845 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
846 return 0;
847
848 if (!asn1_ulong_decode(ctx, end, &request->id))
849 return 0;
850
851 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
852 return 0;
853
854 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
855 return 0;
856
857 if (!asn1_uint_decode(ctx, end, &request->error_status))
858 return 0;
859
860 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
861 return 0;
862
863 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
864 return 0;
865
866 if (!asn1_uint_decode(ctx, end, &request->error_index))
867 return 0;
868
869 return 1;
870}
871
872/*
873 * Fast checksum update for possibly oddly-aligned UDP byte, from the
874 * code example in the draft.
875 */
876static void fast_csum(__sum16 *csum,
877 const unsigned char *optr,
878 const unsigned char *nptr,
879 int offset)
880{
881 unsigned char s[4];
882
883 if (offset & 1) {
884 s[0] = s[2] = 0;
885 s[1] = ~*optr;
886 s[3] = *nptr;
887 } else {
888 s[1] = s[3] = 0;
889 s[0] = ~*optr;
890 s[2] = *nptr;
891 }
892
893 *csum = csum_fold(csum_partial(s, 4, ~csum_unfold(*csum)));
894}
895
896/*
897 * Mangle IP address.
898 * - begin points to the start of the snmp messgae
899 * - addr points to the start of the address
900 */
901static inline void mangle_address(unsigned char *begin,
902 unsigned char *addr,
903 const struct oct1_map *map,
904 __sum16 *check)
905{
906 if (map->from == NOCT1(addr)) {
907 u_int32_t old;
908
909 if (debug)
910 memcpy(&old, (unsigned char *)addr, sizeof(old));
911
912 *addr = map->to;
913
914 /* Update UDP checksum if being used */
915 if (*check) {
916 fast_csum(check,
917 &map->from, &map->to, addr - begin);
918
919 }
920
921 if (debug)
922 printk(KERN_DEBUG "bsalg: mapped %u.%u.%u.%u to "
923 "%u.%u.%u.%u\n", NIPQUAD(old), NIPQUAD(*addr));
924 }
925}
926
927static unsigned char snmp_trap_decode(struct asn1_ctx *ctx,
928 struct snmp_v1_trap *trap,
929 const struct oct1_map *map,
930 __sum16 *check)
931{
932 unsigned int cls, con, tag, len;
933 unsigned char *end;
934
935 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
936 return 0;
937
938 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OJI)
939 return 0;
940
941 if (!asn1_oid_decode(ctx, end, &trap->id, &trap->id_len))
942 return 0;
943
944 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
945 goto err_id_free;
946
947 if (!((cls == ASN1_APL && con == ASN1_PRI && tag == SNMP_IPA) ||
948 (cls == ASN1_UNI && con == ASN1_PRI && tag == ASN1_OTS)))
949 goto err_id_free;
950
951 if (!asn1_octets_decode(ctx, end, (unsigned char **)&trap->ip_address, &len))
952 goto err_id_free;
953
954 /* IPv4 only */
955 if (len != 4)
956 goto err_addr_free;
957
958 mangle_address(ctx->begin, ctx->pointer - 4, map, check);
959
960 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
961 goto err_addr_free;
962
963 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
964 goto err_addr_free;
965
966 if (!asn1_uint_decode(ctx, end, &trap->general))
967 goto err_addr_free;
968
969 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
970 goto err_addr_free;
971
972 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
973 goto err_addr_free;
974
975 if (!asn1_uint_decode(ctx, end, &trap->specific))
976 goto err_addr_free;
977
978 if (!asn1_header_decode(ctx, &end, &cls, &con, &tag))
979 goto err_addr_free;
980
981 if (!((cls == ASN1_APL && con == ASN1_PRI && tag == SNMP_TIT) ||
982 (cls == ASN1_UNI && con == ASN1_PRI && tag == ASN1_INT)))
983 goto err_addr_free;
984
985 if (!asn1_ulong_decode(ctx, end, &trap->time))
986 goto err_addr_free;
987
988 return 1;
989
990err_addr_free:
991 kfree((unsigned long *)trap->ip_address);
992
993err_id_free:
994 kfree(trap->id);
995
996 return 0;
997}
998
999/*****************************************************************************
1000 *
1001 * Misc. routines
1002 *
1003 *****************************************************************************/
1004
1005static void hex_dump(unsigned char *buf, size_t len)
1006{
1007 size_t i;
1008
1009 for (i = 0; i < len; i++) {
1010 if (i && !(i % 16))
1011 printk("\n");
1012 printk("%02x ", *(buf + i));
1013 }
1014 printk("\n");
1015}
1016
1017/*
1018 * Parse and mangle SNMP message according to mapping.
1019 * (And this is the fucking 'basic' method).
1020 */
1021static int snmp_parse_mangle(unsigned char *msg,
1022 u_int16_t len,
1023 const struct oct1_map *map,
1024 __sum16 *check)
1025{
1026 unsigned char *eoc, *end;
1027 unsigned int cls, con, tag, vers, pdutype;
1028 struct asn1_ctx ctx;
1029 struct asn1_octstr comm;
1030 struct snmp_object **obj;
1031
1032 if (debug > 1)
1033 hex_dump(msg, len);
1034
1035 asn1_open(&ctx, msg, len);
1036
1037 /*
1038 * Start of SNMP message.
1039 */
1040 if (!asn1_header_decode(&ctx, &eoc, &cls, &con, &tag))
1041 return 0;
1042 if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
1043 return 0;
1044
1045 /*
1046 * Version 1 or 2 handled.
1047 */
1048 if (!asn1_header_decode(&ctx, &end, &cls, &con, &tag))
1049 return 0;
1050 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_INT)
1051 return 0;
1052 if (!asn1_uint_decode (&ctx, end, &vers))
1053 return 0;
1054 if (debug > 1)
1055 printk(KERN_DEBUG "bsalg: snmp version: %u\n", vers + 1);
1056 if (vers > 1)
1057 return 1;
1058
1059 /*
1060 * Community.
1061 */
1062 if (!asn1_header_decode (&ctx, &end, &cls, &con, &tag))
1063 return 0;
1064 if (cls != ASN1_UNI || con != ASN1_PRI || tag != ASN1_OTS)
1065 return 0;
1066 if (!asn1_octets_decode(&ctx, end, &comm.data, &comm.len))
1067 return 0;
1068 if (debug > 1) {
1069 unsigned int i;
1070
1071 printk(KERN_DEBUG "bsalg: community: ");
1072 for (i = 0; i < comm.len; i++)
1073 printk("%c", comm.data[i]);
1074 printk("\n");
1075 }
1076 kfree(comm.data);
1077
1078 /*
1079 * PDU type
1080 */
1081 if (!asn1_header_decode(&ctx, &eoc, &cls, &con, &pdutype))
1082 return 0;
1083 if (cls != ASN1_CTX || con != ASN1_CON)
1084 return 0;
1085 if (debug > 1) {
1086 unsigned char *pdus[] = {
1087 [SNMP_PDU_GET] = "get",
1088 [SNMP_PDU_NEXT] = "get-next",
1089 [SNMP_PDU_RESPONSE] = "response",
1090 [SNMP_PDU_SET] = "set",
1091 [SNMP_PDU_TRAP1] = "trapv1",
1092 [SNMP_PDU_BULK] = "bulk",
1093 [SNMP_PDU_INFORM] = "inform",
1094 [SNMP_PDU_TRAP2] = "trapv2"
1095 };
1096
1097 if (pdutype > SNMP_PDU_TRAP2)
1098 printk(KERN_DEBUG "bsalg: bad pdu type %u\n", pdutype);
1099 else
1100 printk(KERN_DEBUG "bsalg: pdu: %s\n", pdus[pdutype]);
1101 }
1102 if (pdutype != SNMP_PDU_RESPONSE &&
1103 pdutype != SNMP_PDU_TRAP1 && pdutype != SNMP_PDU_TRAP2)
1104 return 1;
1105
1106 /*
1107 * Request header or v1 trap
1108 */
1109 if (pdutype == SNMP_PDU_TRAP1) {
1110 struct snmp_v1_trap trap;
1111 unsigned char ret = snmp_trap_decode(&ctx, &trap, map, check);
1112
1113 if (ret) {
1114 kfree(trap.id);
1115 kfree((unsigned long *)trap.ip_address);
1116 } else
1117 return ret;
1118
1119 } else {
1120 struct snmp_request req;
1121
1122 if (!snmp_request_decode(&ctx, &req))
1123 return 0;
1124
1125 if (debug > 1)
1126 printk(KERN_DEBUG "bsalg: request: id=0x%lx error_status=%u "
1127 "error_index=%u\n", req.id, req.error_status,
1128 req.error_index);
1129 }
1130
1131 /*
1132 * Loop through objects, look for IP addresses to mangle.
1133 */
1134 if (!asn1_header_decode(&ctx, &eoc, &cls, &con, &tag))
1135 return 0;
1136
1137 if (cls != ASN1_UNI || con != ASN1_CON || tag != ASN1_SEQ)
1138 return 0;
1139
1140 obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC);
1141 if (obj == NULL) {
1142 if (net_ratelimit())
1143 printk(KERN_WARNING "OOM in bsalg(%d)\n", __LINE__);
1144 return 0;
1145 }
1146
1147 while (!asn1_eoc_decode(&ctx, eoc)) {
1148 unsigned int i;
1149
1150 if (!snmp_object_decode(&ctx, obj)) {
1151 if (*obj) {
1152 kfree((*obj)->id);
1153 kfree(*obj);
1154 }
1155 kfree(obj);
1156 return 0;
1157 }
1158
1159 if (debug > 1) {
1160 printk(KERN_DEBUG "bsalg: object: ");
1161 for (i = 0; i < (*obj)->id_len; i++) {
1162 if (i > 0)
1163 printk(".");
1164 printk("%lu", (*obj)->id[i]);
1165 }
1166 printk(": type=%u\n", (*obj)->type);
1167
1168 }
1169
1170 if ((*obj)->type == SNMP_IPADDR)
1171 mangle_address(ctx.begin, ctx.pointer - 4 , map, check);
1172
1173 kfree((*obj)->id);
1174 kfree(*obj);
1175 }
1176 kfree(obj);
1177
1178 if (!asn1_eoc_decode(&ctx, eoc))
1179 return 0;
1180
1181 return 1;
1182}
1183
1184/*****************************************************************************
1185 *
1186 * NAT routines.
1187 *
1188 *****************************************************************************/
1189
1190/*
1191 * SNMP translation routine.
1192 */
1193static int snmp_translate(struct nf_conn *ct,
1194 enum ip_conntrack_info ctinfo,
1195 struct sk_buff **pskb)
1196{
1197 struct iphdr *iph = (*pskb)->nh.iph;
1198 struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl);
1199 u_int16_t udplen = ntohs(udph->len);
1200 u_int16_t paylen = udplen - sizeof(struct udphdr);
1201 int dir = CTINFO2DIR(ctinfo);
1202 struct oct1_map map;
1203
1204 /*
1205 * Determine mappping for application layer addresses based
1206 * on NAT manipulations for the packet.
1207 */
1208 if (dir == IP_CT_DIR_ORIGINAL) {
1209 /* SNAT traps */
1210 map.from = NOCT1(&ct->tuplehash[dir].tuple.src.u3.ip);
1211 map.to = NOCT1(&ct->tuplehash[!dir].tuple.dst.u3.ip);
1212 } else {
1213 /* DNAT replies */
1214 map.from = NOCT1(&ct->tuplehash[dir].tuple.src.u3.ip);
1215 map.to = NOCT1(&ct->tuplehash[!dir].tuple.dst.u3.ip);
1216 }
1217
1218 if (map.from == map.to)
1219 return NF_ACCEPT;
1220
1221 if (!snmp_parse_mangle((unsigned char *)udph + sizeof(struct udphdr),
1222 paylen, &map, &udph->check)) {
1223 if (net_ratelimit())
1224 printk(KERN_WARNING "bsalg: parser failed\n");
1225 return NF_DROP;
1226 }
1227 return NF_ACCEPT;
1228}
1229
1230/* We don't actually set up expectations, just adjust internal IP
1231 * addresses if this is being NATted */
1232static int help(struct sk_buff **pskb, unsigned int protoff,
1233 struct nf_conn *ct,
1234 enum ip_conntrack_info ctinfo)
1235{
1236 int dir = CTINFO2DIR(ctinfo);
1237 unsigned int ret;
1238 struct iphdr *iph = (*pskb)->nh.iph;
1239 struct udphdr *udph = (struct udphdr *)((u_int32_t *)iph + iph->ihl);
1240
1241 /* SNMP replies and originating SNMP traps get mangled */
1242 if (udph->source == htons(SNMP_PORT) && dir != IP_CT_DIR_REPLY)
1243 return NF_ACCEPT;
1244 if (udph->dest == htons(SNMP_TRAP_PORT) && dir != IP_CT_DIR_ORIGINAL)
1245 return NF_ACCEPT;
1246
1247 /* No NAT? */
1248 if (!(ct->status & IPS_NAT_MASK))
1249 return NF_ACCEPT;
1250
1251 /*
1252 * Make sure the packet length is ok. So far, we were only guaranteed
1253 * to have a valid length IP header plus 8 bytes, which means we have
1254 * enough room for a UDP header. Just verify the UDP length field so we
1255 * can mess around with the payload.
1256 */
1257 if (ntohs(udph->len) != (*pskb)->len - (iph->ihl << 2)) {
1258 if (net_ratelimit())
1259 printk(KERN_WARNING "SNMP: dropping malformed packet "
1260 "src=%u.%u.%u.%u dst=%u.%u.%u.%u\n",
1261 NIPQUAD(iph->saddr), NIPQUAD(iph->daddr));
1262 return NF_DROP;
1263 }
1264
1265 if (!skb_make_writable(pskb, (*pskb)->len))
1266 return NF_DROP;
1267
1268 spin_lock_bh(&snmp_lock);
1269 ret = snmp_translate(ct, ctinfo, pskb);
1270 spin_unlock_bh(&snmp_lock);
1271 return ret;
1272}
1273
1274static struct nf_conntrack_helper snmp_helper __read_mostly = {
1275 .max_expected = 0,
1276 .timeout = 180,
1277 .me = THIS_MODULE,
1278 .help = help,
1279 .name = "snmp",
1280 .tuple.src.l3num = AF_INET,
1281 .tuple.src.u.udp.port = __constant_htons(SNMP_PORT),
1282 .tuple.dst.protonum = IPPROTO_UDP,
1283 .mask.src.l3num = 0xFFFF,
1284 .mask.src.u.udp.port = __constant_htons(0xFFFF),
1285 .mask.dst.protonum = 0xFF,
1286};
1287
1288static struct nf_conntrack_helper snmp_trap_helper __read_mostly = {
1289 .max_expected = 0,
1290 .timeout = 180,
1291 .me = THIS_MODULE,
1292 .help = help,
1293 .name = "snmp_trap",
1294 .tuple.src.l3num = AF_INET,
1295 .tuple.src.u.udp.port = __constant_htons(SNMP_TRAP_PORT),
1296 .tuple.dst.protonum = IPPROTO_UDP,
1297 .mask.src.l3num = 0xFFFF,
1298 .mask.src.u.udp.port = __constant_htons(0xFFFF),
1299 .mask.dst.protonum = 0xFF,
1300};
1301
1302/*****************************************************************************
1303 *
1304 * Module stuff.
1305 *
1306 *****************************************************************************/
1307
1308static int __init nf_nat_snmp_basic_init(void)
1309{
1310 int ret = 0;
1311
1312 ret = nf_conntrack_helper_register(&snmp_helper);
1313 if (ret < 0)
1314 return ret;
1315 ret = nf_conntrack_helper_register(&snmp_trap_helper);
1316 if (ret < 0) {
1317 nf_conntrack_helper_unregister(&snmp_helper);
1318 return ret;
1319 }
1320 return ret;
1321}
1322
1323static void __exit nf_nat_snmp_basic_fini(void)
1324{
1325 nf_conntrack_helper_unregister(&snmp_helper);
1326 nf_conntrack_helper_unregister(&snmp_trap_helper);
1327}
1328
1329module_init(nf_nat_snmp_basic_init);
1330module_exit(nf_nat_snmp_basic_fini);
1331
1332module_param(debug, int, 0600);
diff --git a/net/ipv4/netfilter/nf_nat_standalone.c b/net/ipv4/netfilter/nf_nat_standalone.c
new file mode 100644
index 000000000000..730a7a44c883
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_standalone.c
@@ -0,0 +1,406 @@
1/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
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#include <linux/types.h>
9#include <linux/icmp.h>
10#include <linux/ip.h>
11#include <linux/netfilter.h>
12#include <linux/netfilter_ipv4.h>
13#include <linux/module.h>
14#include <linux/skbuff.h>
15#include <linux/proc_fs.h>
16#include <net/ip.h>
17#include <net/checksum.h>
18#include <linux/spinlock.h>
19
20#include <net/netfilter/nf_conntrack.h>
21#include <net/netfilter/nf_conntrack_core.h>
22#include <net/netfilter/nf_nat.h>
23#include <net/netfilter/nf_nat_rule.h>
24#include <net/netfilter/nf_nat_protocol.h>
25#include <net/netfilter/nf_nat_core.h>
26#include <net/netfilter/nf_nat_helper.h>
27#include <linux/netfilter_ipv4/ip_tables.h>
28
29#if 0
30#define DEBUGP printk
31#else
32#define DEBUGP(format, args...)
33#endif
34
35#define HOOKNAME(hooknum) ((hooknum) == NF_IP_POST_ROUTING ? "POST_ROUTING" \
36 : ((hooknum) == NF_IP_PRE_ROUTING ? "PRE_ROUTING" \
37 : ((hooknum) == NF_IP_LOCAL_OUT ? "LOCAL_OUT" \
38 : ((hooknum) == NF_IP_LOCAL_IN ? "LOCAL_IN" \
39 : "*ERROR*")))
40
41#ifdef CONFIG_XFRM
42static void nat_decode_session(struct sk_buff *skb, struct flowi *fl)
43{
44 struct nf_conn *ct;
45 struct nf_conntrack_tuple *t;
46 enum ip_conntrack_info ctinfo;
47 enum ip_conntrack_dir dir;
48 unsigned long statusbit;
49
50 ct = nf_ct_get(skb, &ctinfo);
51 if (ct == NULL)
52 return;
53 dir = CTINFO2DIR(ctinfo);
54 t = &ct->tuplehash[dir].tuple;
55
56 if (dir == IP_CT_DIR_ORIGINAL)
57 statusbit = IPS_DST_NAT;
58 else
59 statusbit = IPS_SRC_NAT;
60
61 if (ct->status & statusbit) {
62 fl->fl4_dst = t->dst.u3.ip;
63 if (t->dst.protonum == IPPROTO_TCP ||
64 t->dst.protonum == IPPROTO_UDP)
65 fl->fl_ip_dport = t->dst.u.tcp.port;
66 }
67
68 statusbit ^= IPS_NAT_MASK;
69
70 if (ct->status & statusbit) {
71 fl->fl4_src = t->src.u3.ip;
72 if (t->dst.protonum == IPPROTO_TCP ||
73 t->dst.protonum == IPPROTO_UDP)
74 fl->fl_ip_sport = t->src.u.tcp.port;
75 }
76}
77#endif
78
79static unsigned int
80nf_nat_fn(unsigned int hooknum,
81 struct sk_buff **pskb,
82 const struct net_device *in,
83 const struct net_device *out,
84 int (*okfn)(struct sk_buff *))
85{
86 struct nf_conn *ct;
87 enum ip_conntrack_info ctinfo;
88 struct nf_conn_nat *nat;
89 struct nf_nat_info *info;
90 /* maniptype == SRC for postrouting. */
91 enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum);
92
93 /* We never see fragments: conntrack defrags on pre-routing
94 and local-out, and nf_nat_out protects post-routing. */
95 NF_CT_ASSERT(!((*pskb)->nh.iph->frag_off
96 & htons(IP_MF|IP_OFFSET)));
97
98 ct = nf_ct_get(*pskb, &ctinfo);
99 /* Can't track? It's not due to stress, or conntrack would
100 have dropped it. Hence it's the user's responsibilty to
101 packet filter it out, or implement conntrack/NAT for that
102 protocol. 8) --RR */
103 if (!ct) {
104 /* Exception: ICMP redirect to new connection (not in
105 hash table yet). We must not let this through, in
106 case we're doing NAT to the same network. */
107 if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
108 struct icmphdr _hdr, *hp;
109
110 hp = skb_header_pointer(*pskb,
111 (*pskb)->nh.iph->ihl*4,
112 sizeof(_hdr), &_hdr);
113 if (hp != NULL &&
114 hp->type == ICMP_REDIRECT)
115 return NF_DROP;
116 }
117 return NF_ACCEPT;
118 }
119
120 /* Don't try to NAT if this packet is not conntracked */
121 if (ct == &nf_conntrack_untracked)
122 return NF_ACCEPT;
123
124 nat = nfct_nat(ct);
125 if (!nat)
126 return NF_DROP;
127
128 switch (ctinfo) {
129 case IP_CT_RELATED:
130 case IP_CT_RELATED+IP_CT_IS_REPLY:
131 if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) {
132 if (!nf_nat_icmp_reply_translation(ct, ctinfo,
133 hooknum, pskb))
134 return NF_DROP;
135 else
136 return NF_ACCEPT;
137 }
138 /* Fall thru... (Only ICMPs can be IP_CT_IS_REPLY) */
139 case IP_CT_NEW:
140 info = &nat->info;
141
142 /* Seen it before? This can happen for loopback, retrans,
143 or local packets.. */
144 if (!nf_nat_initialized(ct, maniptype)) {
145 unsigned int ret;
146
147 if (unlikely(nf_ct_is_confirmed(ct)))
148 /* NAT module was loaded late */
149 ret = alloc_null_binding_confirmed(ct, info,
150 hooknum);
151 else if (hooknum == NF_IP_LOCAL_IN)
152 /* LOCAL_IN hook doesn't have a chain! */
153 ret = alloc_null_binding(ct, info, hooknum);
154 else
155 ret = nf_nat_rule_find(pskb, hooknum, in, out,
156 ct, info);
157
158 if (ret != NF_ACCEPT) {
159 return ret;
160 }
161 } else
162 DEBUGP("Already setup manip %s for ct %p\n",
163 maniptype == IP_NAT_MANIP_SRC ? "SRC" : "DST",
164 ct);
165 break;
166
167 default:
168 /* ESTABLISHED */
169 NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED ||
170 ctinfo == (IP_CT_ESTABLISHED+IP_CT_IS_REPLY));
171 info = &nat->info;
172 }
173
174 NF_CT_ASSERT(info);
175 return nf_nat_packet(ct, ctinfo, hooknum, pskb);
176}
177
178static unsigned int
179nf_nat_in(unsigned int hooknum,
180 struct sk_buff **pskb,
181 const struct net_device *in,
182 const struct net_device *out,
183 int (*okfn)(struct sk_buff *))
184{
185 unsigned int ret;
186 __be32 daddr = (*pskb)->nh.iph->daddr;
187
188 ret = nf_nat_fn(hooknum, pskb, in, out, okfn);
189 if (ret != NF_DROP && ret != NF_STOLEN &&
190 daddr != (*pskb)->nh.iph->daddr) {
191 dst_release((*pskb)->dst);
192 (*pskb)->dst = NULL;
193 }
194 return ret;
195}
196
197static unsigned int
198nf_nat_out(unsigned int hooknum,
199 struct sk_buff **pskb,
200 const struct net_device *in,
201 const struct net_device *out,
202 int (*okfn)(struct sk_buff *))
203{
204#ifdef CONFIG_XFRM
205 struct nf_conn *ct;
206 enum ip_conntrack_info ctinfo;
207#endif
208 unsigned int ret;
209
210 /* root is playing with raw sockets. */
211 if ((*pskb)->len < sizeof(struct iphdr) ||
212 (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr))
213 return NF_ACCEPT;
214
215 ret = nf_nat_fn(hooknum, pskb, in, out, okfn);
216#ifdef CONFIG_XFRM
217 if (ret != NF_DROP && ret != NF_STOLEN &&
218 (ct = nf_ct_get(*pskb, &ctinfo)) != NULL) {
219 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
220
221 if (ct->tuplehash[dir].tuple.src.u3.ip !=
222 ct->tuplehash[!dir].tuple.dst.u3.ip
223 || ct->tuplehash[dir].tuple.src.u.all !=
224 ct->tuplehash[!dir].tuple.dst.u.all
225 )
226 return ip_xfrm_me_harder(pskb) == 0 ? ret : NF_DROP;
227 }
228#endif
229 return ret;
230}
231
232static unsigned int
233nf_nat_local_fn(unsigned int hooknum,
234 struct sk_buff **pskb,
235 const struct net_device *in,
236 const struct net_device *out,
237 int (*okfn)(struct sk_buff *))
238{
239 struct nf_conn *ct;
240 enum ip_conntrack_info ctinfo;
241 unsigned int ret;
242
243 /* root is playing with raw sockets. */
244 if ((*pskb)->len < sizeof(struct iphdr) ||
245 (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr))
246 return NF_ACCEPT;
247
248 ret = nf_nat_fn(hooknum, pskb, in, out, okfn);
249 if (ret != NF_DROP && ret != NF_STOLEN &&
250 (ct = nf_ct_get(*pskb, &ctinfo)) != NULL) {
251 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
252
253 if (ct->tuplehash[dir].tuple.dst.u3.ip !=
254 ct->tuplehash[!dir].tuple.src.u3.ip
255#ifdef CONFIG_XFRM
256 || ct->tuplehash[dir].tuple.dst.u.all !=
257 ct->tuplehash[!dir].tuple.src.u.all
258#endif
259 )
260 if (ip_route_me_harder(pskb, RTN_UNSPEC))
261 ret = NF_DROP;
262 }
263 return ret;
264}
265
266static unsigned int
267nf_nat_adjust(unsigned int hooknum,
268 struct sk_buff **pskb,
269 const struct net_device *in,
270 const struct net_device *out,
271 int (*okfn)(struct sk_buff *))
272{
273 struct nf_conn *ct;
274 enum ip_conntrack_info ctinfo;
275
276 ct = nf_ct_get(*pskb, &ctinfo);
277 if (ct && test_bit(IPS_SEQ_ADJUST_BIT, &ct->status)) {
278 DEBUGP("nf_nat_standalone: adjusting sequence number\n");
279 if (!nf_nat_seq_adjust(pskb, ct, ctinfo))
280 return NF_DROP;
281 }
282 return NF_ACCEPT;
283}
284
285/* We must be after connection tracking and before packet filtering. */
286
287static struct nf_hook_ops nf_nat_ops[] = {
288 /* Before packet filtering, change destination */
289 {
290 .hook = nf_nat_in,
291 .owner = THIS_MODULE,
292 .pf = PF_INET,
293 .hooknum = NF_IP_PRE_ROUTING,
294 .priority = NF_IP_PRI_NAT_DST,
295 },
296 /* After packet filtering, change source */
297 {
298 .hook = nf_nat_out,
299 .owner = THIS_MODULE,
300 .pf = PF_INET,
301 .hooknum = NF_IP_POST_ROUTING,
302 .priority = NF_IP_PRI_NAT_SRC,
303 },
304 /* After conntrack, adjust sequence number */
305 {
306 .hook = nf_nat_adjust,
307 .owner = THIS_MODULE,
308 .pf = PF_INET,
309 .hooknum = NF_IP_POST_ROUTING,
310 .priority = NF_IP_PRI_NAT_SEQ_ADJUST,
311 },
312 /* Before packet filtering, change destination */
313 {
314 .hook = nf_nat_local_fn,
315 .owner = THIS_MODULE,
316 .pf = PF_INET,
317 .hooknum = NF_IP_LOCAL_OUT,
318 .priority = NF_IP_PRI_NAT_DST,
319 },
320 /* After packet filtering, change source */
321 {
322 .hook = nf_nat_fn,
323 .owner = THIS_MODULE,
324 .pf = PF_INET,
325 .hooknum = NF_IP_LOCAL_IN,
326 .priority = NF_IP_PRI_NAT_SRC,
327 },
328 /* After conntrack, adjust sequence number */
329 {
330 .hook = nf_nat_adjust,
331 .owner = THIS_MODULE,
332 .pf = PF_INET,
333 .hooknum = NF_IP_LOCAL_IN,
334 .priority = NF_IP_PRI_NAT_SEQ_ADJUST,
335 },
336};
337
338static int __init nf_nat_standalone_init(void)
339{
340 int size, ret = 0;
341
342 need_conntrack();
343
344 size = ALIGN(sizeof(struct nf_conn), __alignof__(struct nf_conn_nat)) +
345 sizeof(struct nf_conn_nat);
346 ret = nf_conntrack_register_cache(NF_CT_F_NAT, "nf_nat:base", size);
347 if (ret < 0) {
348 printk(KERN_ERR "nf_nat_init: Unable to create slab cache\n");
349 return ret;
350 }
351
352 size = ALIGN(size, __alignof__(struct nf_conn_help)) +
353 sizeof(struct nf_conn_help);
354 ret = nf_conntrack_register_cache(NF_CT_F_NAT|NF_CT_F_HELP,
355 "nf_nat:help", size);
356 if (ret < 0) {
357 printk(KERN_ERR "nf_nat_init: Unable to create slab cache\n");
358 goto cleanup_register_cache;
359 }
360#ifdef CONFIG_XFRM
361 BUG_ON(ip_nat_decode_session != NULL);
362 ip_nat_decode_session = nat_decode_session;
363#endif
364 ret = nf_nat_rule_init();
365 if (ret < 0) {
366 printk("nf_nat_init: can't setup rules.\n");
367 goto cleanup_decode_session;
368 }
369 ret = nf_register_hooks(nf_nat_ops, ARRAY_SIZE(nf_nat_ops));
370 if (ret < 0) {
371 printk("nf_nat_init: can't register hooks.\n");
372 goto cleanup_rule_init;
373 }
374 nf_nat_module_is_loaded = 1;
375 return ret;
376
377 cleanup_rule_init:
378 nf_nat_rule_cleanup();
379 cleanup_decode_session:
380#ifdef CONFIG_XFRM
381 ip_nat_decode_session = NULL;
382 synchronize_net();
383#endif
384 nf_conntrack_unregister_cache(NF_CT_F_NAT|NF_CT_F_HELP);
385 cleanup_register_cache:
386 nf_conntrack_unregister_cache(NF_CT_F_NAT);
387 return ret;
388}
389
390static void __exit nf_nat_standalone_fini(void)
391{
392 nf_unregister_hooks(nf_nat_ops, ARRAY_SIZE(nf_nat_ops));
393 nf_nat_rule_cleanup();
394 nf_nat_module_is_loaded = 0;
395#ifdef CONFIG_XFRM
396 ip_nat_decode_session = NULL;
397 synchronize_net();
398#endif
399 /* Conntrack caches are unregistered in nf_conntrack_cleanup */
400}
401
402module_init(nf_nat_standalone_init);
403module_exit(nf_nat_standalone_fini);
404
405MODULE_LICENSE("GPL");
406MODULE_ALIAS("ip_nat");
diff --git a/net/ipv4/netfilter/nf_nat_tftp.c b/net/ipv4/netfilter/nf_nat_tftp.c
new file mode 100644
index 000000000000..2566b79de224
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_tftp.c
@@ -0,0 +1,52 @@
1/* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu>
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation.
6 */
7
8#include <linux/module.h>
9#include <linux/moduleparam.h>
10#include <linux/udp.h>
11
12#include <net/netfilter/nf_nat_helper.h>
13#include <net/netfilter/nf_nat_rule.h>
14#include <net/netfilter/nf_conntrack_helper.h>
15#include <net/netfilter/nf_conntrack_expect.h>
16#include <linux/netfilter/nf_conntrack_tftp.h>
17
18MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
19MODULE_DESCRIPTION("TFTP NAT helper");
20MODULE_LICENSE("GPL");
21MODULE_ALIAS("ip_nat_tftp");
22
23static unsigned int help(struct sk_buff **pskb,
24 enum ip_conntrack_info ctinfo,
25 struct nf_conntrack_expect *exp)
26{
27 struct nf_conn *ct = exp->master;
28
29 exp->saved_proto.udp.port
30 = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.udp.port;
31 exp->dir = IP_CT_DIR_REPLY;
32 exp->expectfn = nf_nat_follow_master;
33 if (nf_conntrack_expect_related(exp) != 0)
34 return NF_DROP;
35 return NF_ACCEPT;
36}
37
38static void __exit nf_nat_tftp_fini(void)
39{
40 rcu_assign_pointer(nf_nat_tftp_hook, NULL);
41 synchronize_rcu();
42}
43
44static int __init nf_nat_tftp_init(void)
45{
46 BUG_ON(rcu_dereference(nf_nat_tftp_hook));
47 rcu_assign_pointer(nf_nat_tftp_hook, help);
48 return 0;
49}
50
51module_init(nf_nat_tftp_init);
52module_exit(nf_nat_tftp_fini);
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 9c6cbe3d9fb8..cd873da54cbe 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -38,6 +38,7 @@
38#include <net/protocol.h> 38#include <net/protocol.h>
39#include <net/tcp.h> 39#include <net/tcp.h>
40#include <net/udp.h> 40#include <net/udp.h>
41#include <net/udplite.h>
41#include <linux/inetdevice.h> 42#include <linux/inetdevice.h>
42#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
43#include <linux/seq_file.h> 44#include <linux/seq_file.h>
@@ -66,6 +67,7 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
66 tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated), 67 tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated),
67 atomic_read(&tcp_memory_allocated)); 68 atomic_read(&tcp_memory_allocated));
68 seq_printf(seq, "UDP: inuse %d\n", fold_prot_inuse(&udp_prot)); 69 seq_printf(seq, "UDP: inuse %d\n", fold_prot_inuse(&udp_prot));
70 seq_printf(seq, "UDPLITE: inuse %d\n", fold_prot_inuse(&udplite_prot));
69 seq_printf(seq, "RAW: inuse %d\n", fold_prot_inuse(&raw_prot)); 71 seq_printf(seq, "RAW: inuse %d\n", fold_prot_inuse(&raw_prot));
70 seq_printf(seq, "FRAG: inuse %d memory %d\n", ip_frag_nqueues, 72 seq_printf(seq, "FRAG: inuse %d memory %d\n", ip_frag_nqueues,
71 atomic_read(&ip_frag_mem)); 73 atomic_read(&ip_frag_mem));
@@ -304,6 +306,17 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
304 fold_field((void **) udp_statistics, 306 fold_field((void **) udp_statistics,
305 snmp4_udp_list[i].entry)); 307 snmp4_udp_list[i].entry));
306 308
309 /* the UDP and UDP-Lite MIBs are the same */
310 seq_puts(seq, "\nUdpLite:");
311 for (i = 0; snmp4_udp_list[i].name != NULL; i++)
312 seq_printf(seq, " %s", snmp4_udp_list[i].name);
313
314 seq_puts(seq, "\nUdpLite:");
315 for (i = 0; snmp4_udp_list[i].name != NULL; i++)
316 seq_printf(seq, " %lu",
317 fold_field((void **) udplite_statistics,
318 snmp4_udp_list[i].entry) );
319
307 seq_putc(seq, '\n'); 320 seq_putc(seq, '\n');
308 return 0; 321 return 0;
309} 322}
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 5c31dead2bdc..a6c63bbd9ddb 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -854,8 +854,8 @@ static void raw_seq_stop(struct seq_file *seq, void *v)
854static __inline__ char *get_raw_sock(struct sock *sp, char *tmpbuf, int i) 854static __inline__ char *get_raw_sock(struct sock *sp, char *tmpbuf, int i)
855{ 855{
856 struct inet_sock *inet = inet_sk(sp); 856 struct inet_sock *inet = inet_sk(sp);
857 unsigned int dest = inet->daddr, 857 __be32 dest = inet->daddr,
858 src = inet->rcv_saddr; 858 src = inet->rcv_saddr;
859 __u16 destp = 0, 859 __u16 destp = 0,
860 srcp = inet->num; 860 srcp = inet->num;
861 861
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 925ee4dfc32c..9f3924c4905e 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -566,11 +566,9 @@ static inline u32 rt_score(struct rtable *rt)
566 566
567static inline int compare_keys(struct flowi *fl1, struct flowi *fl2) 567static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
568{ 568{
569 return ((fl1->nl_u.ip4_u.daddr ^ fl2->nl_u.ip4_u.daddr) | 569 return ((__force u32)((fl1->nl_u.ip4_u.daddr ^ fl2->nl_u.ip4_u.daddr) |
570 (fl1->nl_u.ip4_u.saddr ^ fl2->nl_u.ip4_u.saddr) | 570 (fl1->nl_u.ip4_u.saddr ^ fl2->nl_u.ip4_u.saddr)) |
571#ifdef CONFIG_IP_ROUTE_FWMARK 571 (fl1->mark ^ fl2->mark) |
572 (fl1->nl_u.ip4_u.fwmark ^ fl2->nl_u.ip4_u.fwmark) |
573#endif
574 (*(u16 *)&fl1->nl_u.ip4_u.tos ^ 572 (*(u16 *)&fl1->nl_u.ip4_u.tos ^
575 *(u16 *)&fl2->nl_u.ip4_u.tos) | 573 *(u16 *)&fl2->nl_u.ip4_u.tos) |
576 (fl1->oif ^ fl2->oif) | 574 (fl1->oif ^ fl2->oif) |
@@ -1643,9 +1641,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1643 rth->fl.fl4_dst = daddr; 1641 rth->fl.fl4_dst = daddr;
1644 rth->rt_dst = daddr; 1642 rth->rt_dst = daddr;
1645 rth->fl.fl4_tos = tos; 1643 rth->fl.fl4_tos = tos;
1646#ifdef CONFIG_IP_ROUTE_FWMARK 1644 rth->fl.mark = skb->mark;
1647 rth->fl.fl4_fwmark= skb->nfmark;
1648#endif
1649 rth->fl.fl4_src = saddr; 1645 rth->fl.fl4_src = saddr;
1650 rth->rt_src = saddr; 1646 rth->rt_src = saddr;
1651#ifdef CONFIG_NET_CLS_ROUTE 1647#ifdef CONFIG_NET_CLS_ROUTE
@@ -1789,9 +1785,7 @@ static inline int __mkroute_input(struct sk_buff *skb,
1789 rth->fl.fl4_dst = daddr; 1785 rth->fl.fl4_dst = daddr;
1790 rth->rt_dst = daddr; 1786 rth->rt_dst = daddr;
1791 rth->fl.fl4_tos = tos; 1787 rth->fl.fl4_tos = tos;
1792#ifdef CONFIG_IP_ROUTE_FWMARK 1788 rth->fl.mark = skb->mark;
1793 rth->fl.fl4_fwmark= skb->nfmark;
1794#endif
1795 rth->fl.fl4_src = saddr; 1789 rth->fl.fl4_src = saddr;
1796 rth->rt_src = saddr; 1790 rth->rt_src = saddr;
1797 rth->rt_gateway = daddr; 1791 rth->rt_gateway = daddr;
@@ -1920,10 +1914,8 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1920 .saddr = saddr, 1914 .saddr = saddr,
1921 .tos = tos, 1915 .tos = tos,
1922 .scope = RT_SCOPE_UNIVERSE, 1916 .scope = RT_SCOPE_UNIVERSE,
1923#ifdef CONFIG_IP_ROUTE_FWMARK
1924 .fwmark = skb->nfmark
1925#endif
1926 } }, 1917 } },
1918 .mark = skb->mark,
1927 .iif = dev->ifindex }; 1919 .iif = dev->ifindex };
1928 unsigned flags = 0; 1920 unsigned flags = 0;
1929 u32 itag = 0; 1921 u32 itag = 0;
@@ -2034,9 +2026,7 @@ local_input:
2034 rth->fl.fl4_dst = daddr; 2026 rth->fl.fl4_dst = daddr;
2035 rth->rt_dst = daddr; 2027 rth->rt_dst = daddr;
2036 rth->fl.fl4_tos = tos; 2028 rth->fl.fl4_tos = tos;
2037#ifdef CONFIG_IP_ROUTE_FWMARK 2029 rth->fl.mark = skb->mark;
2038 rth->fl.fl4_fwmark= skb->nfmark;
2039#endif
2040 rth->fl.fl4_src = saddr; 2030 rth->fl.fl4_src = saddr;
2041 rth->rt_src = saddr; 2031 rth->rt_src = saddr;
2042#ifdef CONFIG_NET_CLS_ROUTE 2032#ifdef CONFIG_NET_CLS_ROUTE
@@ -2113,9 +2103,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2113 rth->fl.fl4_src == saddr && 2103 rth->fl.fl4_src == saddr &&
2114 rth->fl.iif == iif && 2104 rth->fl.iif == iif &&
2115 rth->fl.oif == 0 && 2105 rth->fl.oif == 0 &&
2116#ifdef CONFIG_IP_ROUTE_FWMARK 2106 rth->fl.mark == skb->mark &&
2117 rth->fl.fl4_fwmark == skb->nfmark &&
2118#endif
2119 rth->fl.fl4_tos == tos) { 2107 rth->fl.fl4_tos == tos) {
2120 rth->u.dst.lastuse = jiffies; 2108 rth->u.dst.lastuse = jiffies;
2121 dst_hold(&rth->u.dst); 2109 dst_hold(&rth->u.dst);
@@ -2239,9 +2227,7 @@ static inline int __mkroute_output(struct rtable **result,
2239 rth->fl.fl4_tos = tos; 2227 rth->fl.fl4_tos = tos;
2240 rth->fl.fl4_src = oldflp->fl4_src; 2228 rth->fl.fl4_src = oldflp->fl4_src;
2241 rth->fl.oif = oldflp->oif; 2229 rth->fl.oif = oldflp->oif;
2242#ifdef CONFIG_IP_ROUTE_FWMARK 2230 rth->fl.mark = oldflp->mark;
2243 rth->fl.fl4_fwmark= oldflp->fl4_fwmark;
2244#endif
2245 rth->rt_dst = fl->fl4_dst; 2231 rth->rt_dst = fl->fl4_dst;
2246 rth->rt_src = fl->fl4_src; 2232 rth->rt_src = fl->fl4_src;
2247 rth->rt_iif = oldflp->oif ? : dev_out->ifindex; 2233 rth->rt_iif = oldflp->oif ? : dev_out->ifindex;
@@ -2385,10 +2371,8 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
2385 .scope = ((tos & RTO_ONLINK) ? 2371 .scope = ((tos & RTO_ONLINK) ?
2386 RT_SCOPE_LINK : 2372 RT_SCOPE_LINK :
2387 RT_SCOPE_UNIVERSE), 2373 RT_SCOPE_UNIVERSE),
2388#ifdef CONFIG_IP_ROUTE_FWMARK
2389 .fwmark = oldflp->fl4_fwmark
2390#endif
2391 } }, 2374 } },
2375 .mark = oldflp->mark,
2392 .iif = loopback_dev.ifindex, 2376 .iif = loopback_dev.ifindex,
2393 .oif = oldflp->oif }; 2377 .oif = oldflp->oif };
2394 struct fib_result res; 2378 struct fib_result res;
@@ -2583,9 +2567,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
2583 rth->fl.fl4_src == flp->fl4_src && 2567 rth->fl.fl4_src == flp->fl4_src &&
2584 rth->fl.iif == 0 && 2568 rth->fl.iif == 0 &&
2585 rth->fl.oif == flp->oif && 2569 rth->fl.oif == flp->oif &&
2586#ifdef CONFIG_IP_ROUTE_FWMARK 2570 rth->fl.mark == flp->mark &&
2587 rth->fl.fl4_fwmark == flp->fl4_fwmark &&
2588#endif
2589 !((rth->fl.fl4_tos ^ flp->fl4_tos) & 2571 !((rth->fl.fl4_tos ^ flp->fl4_tos) &
2590 (IPTOS_RT_MASK | RTO_ONLINK))) { 2572 (IPTOS_RT_MASK | RTO_ONLINK))) {
2591 2573
@@ -2647,7 +2629,8 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2647 struct rtable *rt = (struct rtable*)skb->dst; 2629 struct rtable *rt = (struct rtable*)skb->dst;
2648 struct rtmsg *r; 2630 struct rtmsg *r;
2649 struct nlmsghdr *nlh; 2631 struct nlmsghdr *nlh;
2650 struct rta_cacheinfo ci; 2632 long expires;
2633 u32 id = 0, ts = 0, tsage = 0, error;
2651 2634
2652 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*r), flags); 2635 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*r), flags);
2653 if (nlh == NULL) 2636 if (nlh == NULL)
@@ -2694,20 +2677,13 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2694 if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0) 2677 if (rtnetlink_put_metrics(skb, rt->u.dst.metrics) < 0)
2695 goto nla_put_failure; 2678 goto nla_put_failure;
2696 2679
2697 ci.rta_lastuse = jiffies_to_clock_t(jiffies - rt->u.dst.lastuse); 2680 error = rt->u.dst.error;
2698 ci.rta_used = rt->u.dst.__use; 2681 expires = rt->u.dst.expires ? rt->u.dst.expires - jiffies : 0;
2699 ci.rta_clntref = atomic_read(&rt->u.dst.__refcnt);
2700 if (rt->u.dst.expires)
2701 ci.rta_expires = jiffies_to_clock_t(rt->u.dst.expires - jiffies);
2702 else
2703 ci.rta_expires = 0;
2704 ci.rta_error = rt->u.dst.error;
2705 ci.rta_id = ci.rta_ts = ci.rta_tsage = 0;
2706 if (rt->peer) { 2682 if (rt->peer) {
2707 ci.rta_id = rt->peer->ip_id_count; 2683 id = rt->peer->ip_id_count;
2708 if (rt->peer->tcp_ts_stamp) { 2684 if (rt->peer->tcp_ts_stamp) {
2709 ci.rta_ts = rt->peer->tcp_ts; 2685 ts = rt->peer->tcp_ts;
2710 ci.rta_tsage = xtime.tv_sec - rt->peer->tcp_ts_stamp; 2686 tsage = xtime.tv_sec - rt->peer->tcp_ts_stamp;
2711 } 2687 }
2712 } 2688 }
2713 2689
@@ -2726,7 +2702,7 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2726 } else { 2702 } else {
2727 if (err == -EMSGSIZE) 2703 if (err == -EMSGSIZE)
2728 goto nla_put_failure; 2704 goto nla_put_failure;
2729 ci.rta_error = err; 2705 error = err;
2730 } 2706 }
2731 } 2707 }
2732 } else 2708 } else
@@ -2734,7 +2710,9 @@ static int rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
2734 NLA_PUT_U32(skb, RTA_IIF, rt->fl.iif); 2710 NLA_PUT_U32(skb, RTA_IIF, rt->fl.iif);
2735 } 2711 }
2736 2712
2737 NLA_PUT(skb, RTA_CACHEINFO, sizeof(ci), &ci); 2713 if (rtnl_put_cacheinfo(skb, &rt->u.dst, id, ts, tsage,
2714 expires, error) < 0)
2715 goto nla_put_failure;
2738 2716
2739 return nlmsg_end(skb, nlh); 2717 return nlmsg_end(skb, nlh);
2740 2718
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 661e0a4bca72..6b19530905af 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -35,23 +35,23 @@ module_init(init_syncookies);
35#define COOKIEBITS 24 /* Upper bits store count */ 35#define COOKIEBITS 24 /* Upper bits store count */
36#define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) 36#define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
37 37
38static u32 cookie_hash(u32 saddr, u32 daddr, u32 sport, u32 dport, 38static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport,
39 u32 count, int c) 39 u32 count, int c)
40{ 40{
41 __u32 tmp[16 + 5 + SHA_WORKSPACE_WORDS]; 41 __u32 tmp[16 + 5 + SHA_WORKSPACE_WORDS];
42 42
43 memcpy(tmp + 3, syncookie_secret[c], sizeof(syncookie_secret[c])); 43 memcpy(tmp + 3, syncookie_secret[c], sizeof(syncookie_secret[c]));
44 tmp[0] = saddr; 44 tmp[0] = (__force u32)saddr;
45 tmp[1] = daddr; 45 tmp[1] = (__force u32)daddr;
46 tmp[2] = (sport << 16) + dport; 46 tmp[2] = ((__force u32)sport << 16) + (__force u32)dport;
47 tmp[3] = count; 47 tmp[3] = count;
48 sha_transform(tmp + 16, (__u8 *)tmp, tmp + 16 + 5); 48 sha_transform(tmp + 16, (__u8 *)tmp, tmp + 16 + 5);
49 49
50 return tmp[17]; 50 return tmp[17];
51} 51}
52 52
53static __u32 secure_tcp_syn_cookie(__u32 saddr, __u32 daddr, __u16 sport, 53static __u32 secure_tcp_syn_cookie(__be32 saddr, __be32 daddr, __be16 sport,
54 __u16 dport, __u32 sseq, __u32 count, 54 __be16 dport, __u32 sseq, __u32 count,
55 __u32 data) 55 __u32 data)
56{ 56{
57 /* 57 /*
@@ -80,8 +80,8 @@ static __u32 secure_tcp_syn_cookie(__u32 saddr, __u32 daddr, __u16 sport,
80 * "maxdiff" if the current (passed-in) "count". The return value 80 * "maxdiff" if the current (passed-in) "count". The return value
81 * is (__u32)-1 if this test fails. 81 * is (__u32)-1 if this test fails.
82 */ 82 */
83static __u32 check_tcp_syn_cookie(__u32 cookie, __u32 saddr, __u32 daddr, 83static __u32 check_tcp_syn_cookie(__u32 cookie, __be32 saddr, __be32 daddr,
84 __u16 sport, __u16 dport, __u32 sseq, 84 __be16 sport, __be16 dport, __u32 sseq,
85 __u32 count, __u32 maxdiff) 85 __u32 count, __u32 maxdiff)
86{ 86{
87 __u32 diff; 87 __u32 diff;
@@ -220,7 +220,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
220 } 220 }
221 ireq = inet_rsk(req); 221 ireq = inet_rsk(req);
222 treq = tcp_rsk(req); 222 treq = tcp_rsk(req);
223 treq->rcv_isn = htonl(skb->h.th->seq) - 1; 223 treq->rcv_isn = ntohl(skb->h.th->seq) - 1;
224 treq->snt_isn = cookie; 224 treq->snt_isn = cookie;
225 req->mss = mss; 225 req->mss = mss;
226 ireq->rmt_port = skb->h.th->source; 226 ireq->rmt_port = skb->h.th->source;
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 15061b314411..dfcf47f10f88 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -129,6 +129,67 @@ static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
129 return ret; 129 return ret;
130} 130}
131 131
132static int proc_tcp_available_congestion_control(ctl_table *ctl,
133 int write, struct file * filp,
134 void __user *buffer, size_t *lenp,
135 loff_t *ppos)
136{
137 ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
138 int ret;
139
140 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
141 if (!tbl.data)
142 return -ENOMEM;
143 tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
144 ret = proc_dostring(&tbl, write, filp, buffer, lenp, ppos);
145 kfree(tbl.data);
146 return ret;
147}
148
149static int proc_allowed_congestion_control(ctl_table *ctl,
150 int write, struct file * filp,
151 void __user *buffer, size_t *lenp,
152 loff_t *ppos)
153{
154 ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
155 int ret;
156
157 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
158 if (!tbl.data)
159 return -ENOMEM;
160
161 tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
162 ret = proc_dostring(&tbl, write, filp, buffer, lenp, ppos);
163 if (write && ret == 0)
164 ret = tcp_set_allowed_congestion_control(tbl.data);
165 kfree(tbl.data);
166 return ret;
167}
168
169static int strategy_allowed_congestion_control(ctl_table *table, int __user *name,
170 int nlen, void __user *oldval,
171 size_t __user *oldlenp,
172 void __user *newval, size_t newlen,
173 void **context)
174{
175 ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
176 int ret;
177
178 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
179 if (!tbl.data)
180 return -ENOMEM;
181
182 tcp_get_available_congestion_control(tbl.data, tbl.maxlen);
183 ret = sysctl_string(&tbl, name, nlen, oldval, oldlenp, newval, newlen,
184 context);
185 if (ret == 0 && newval && newlen)
186 ret = tcp_set_allowed_congestion_control(tbl.data);
187 kfree(tbl.data);
188
189 return ret;
190
191}
192
132ctl_table ipv4_table[] = { 193ctl_table ipv4_table[] = {
133 { 194 {
134 .ctl_name = NET_IPV4_TCP_TIMESTAMPS, 195 .ctl_name = NET_IPV4_TCP_TIMESTAMPS,
@@ -731,6 +792,21 @@ ctl_table ipv4_table[] = {
731 .proc_handler = &proc_dointvec, 792 .proc_handler = &proc_dointvec,
732 }, 793 },
733#endif /* CONFIG_NETLABEL */ 794#endif /* CONFIG_NETLABEL */
795 {
796 .ctl_name = NET_TCP_AVAIL_CONG_CONTROL,
797 .procname = "tcp_available_congestion_control",
798 .maxlen = TCP_CA_BUF_MAX,
799 .mode = 0444,
800 .proc_handler = &proc_tcp_available_congestion_control,
801 },
802 {
803 .ctl_name = NET_TCP_ALLOWED_CONG_CONTROL,
804 .procname = "tcp_allowed_congestion_control",
805 .maxlen = TCP_CA_BUF_MAX,
806 .mode = 0644,
807 .proc_handler = &proc_allowed_congestion_control,
808 .strategy = &strategy_allowed_congestion_control,
809 },
734 { .ctl_name = 0 } 810 { .ctl_name = 0 }
735}; 811};
736 812
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index c05e8edaf544..090c690627e5 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -258,6 +258,7 @@
258#include <linux/bootmem.h> 258#include <linux/bootmem.h>
259#include <linux/cache.h> 259#include <linux/cache.h>
260#include <linux/err.h> 260#include <linux/err.h>
261#include <linux/crypto.h>
261 262
262#include <net/icmp.h> 263#include <net/icmp.h>
263#include <net/tcp.h> 264#include <net/tcp.h>
@@ -462,11 +463,12 @@ static inline int forced_push(struct tcp_sock *tp)
462static inline void skb_entail(struct sock *sk, struct tcp_sock *tp, 463static inline void skb_entail(struct sock *sk, struct tcp_sock *tp,
463 struct sk_buff *skb) 464 struct sk_buff *skb)
464{ 465{
465 skb->csum = 0; 466 struct tcp_skb_cb *tcb = TCP_SKB_CB(skb);
466 TCP_SKB_CB(skb)->seq = tp->write_seq; 467
467 TCP_SKB_CB(skb)->end_seq = tp->write_seq; 468 skb->csum = 0;
468 TCP_SKB_CB(skb)->flags = TCPCB_FLAG_ACK; 469 tcb->seq = tcb->end_seq = tp->write_seq;
469 TCP_SKB_CB(skb)->sacked = 0; 470 tcb->flags = TCPCB_FLAG_ACK;
471 tcb->sacked = 0;
470 skb_header_release(skb); 472 skb_header_release(skb);
471 __skb_queue_tail(&sk->sk_write_queue, skb); 473 __skb_queue_tail(&sk->sk_write_queue, skb);
472 sk_charge_skb(sk, skb); 474 sk_charge_skb(sk, skb);
@@ -1942,6 +1944,13 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
1942 } 1944 }
1943 break; 1945 break;
1944 1946
1947#ifdef CONFIG_TCP_MD5SIG
1948 case TCP_MD5SIG:
1949 /* Read the IP->Key mappings from userspace */
1950 err = tp->af_specific->md5_parse(sk, optval, optlen);
1951 break;
1952#endif
1953
1945 default: 1954 default:
1946 err = -ENOPROTOOPT; 1955 err = -ENOPROTOOPT;
1947 break; 1956 break;
@@ -2154,7 +2163,7 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
2154 struct tcphdr *th; 2163 struct tcphdr *th;
2155 unsigned thlen; 2164 unsigned thlen;
2156 unsigned int seq; 2165 unsigned int seq;
2157 unsigned int delta; 2166 __be32 delta;
2158 unsigned int oldlen; 2167 unsigned int oldlen;
2159 unsigned int len; 2168 unsigned int len;
2160 2169
@@ -2207,7 +2216,8 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
2207 do { 2216 do {
2208 th->fin = th->psh = 0; 2217 th->fin = th->psh = 0;
2209 2218
2210 th->check = ~csum_fold(th->check + delta); 2219 th->check = ~csum_fold((__force __wsum)((__force u32)th->check +
2220 (__force u32)delta));
2211 if (skb->ip_summed != CHECKSUM_PARTIAL) 2221 if (skb->ip_summed != CHECKSUM_PARTIAL)
2212 th->check = csum_fold(csum_partial(skb->h.raw, thlen, 2222 th->check = csum_fold(csum_partial(skb->h.raw, thlen,
2213 skb->csum)); 2223 skb->csum));
@@ -2221,7 +2231,8 @@ struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
2221 } while (skb->next); 2231 } while (skb->next);
2222 2232
2223 delta = htonl(oldlen + (skb->tail - skb->h.raw) + skb->data_len); 2233 delta = htonl(oldlen + (skb->tail - skb->h.raw) + skb->data_len);
2224 th->check = ~csum_fold(th->check + delta); 2234 th->check = ~csum_fold((__force __wsum)((__force u32)th->check +
2235 (__force u32)delta));
2225 if (skb->ip_summed != CHECKSUM_PARTIAL) 2236 if (skb->ip_summed != CHECKSUM_PARTIAL)
2226 th->check = csum_fold(csum_partial(skb->h.raw, thlen, 2237 th->check = csum_fold(csum_partial(skb->h.raw, thlen,
2227 skb->csum)); 2238 skb->csum));
@@ -2231,6 +2242,135 @@ out:
2231} 2242}
2232EXPORT_SYMBOL(tcp_tso_segment); 2243EXPORT_SYMBOL(tcp_tso_segment);
2233 2244
2245#ifdef CONFIG_TCP_MD5SIG
2246static unsigned long tcp_md5sig_users;
2247static struct tcp_md5sig_pool **tcp_md5sig_pool;
2248static DEFINE_SPINLOCK(tcp_md5sig_pool_lock);
2249
2250static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool **pool)
2251{
2252 int cpu;
2253 for_each_possible_cpu(cpu) {
2254 struct tcp_md5sig_pool *p = *per_cpu_ptr(pool, cpu);
2255 if (p) {
2256 if (p->md5_desc.tfm)
2257 crypto_free_hash(p->md5_desc.tfm);
2258 kfree(p);
2259 p = NULL;
2260 }
2261 }
2262 free_percpu(pool);
2263}
2264
2265void tcp_free_md5sig_pool(void)
2266{
2267 struct tcp_md5sig_pool **pool = NULL;
2268
2269 spin_lock(&tcp_md5sig_pool_lock);
2270 if (--tcp_md5sig_users == 0) {
2271 pool = tcp_md5sig_pool;
2272 tcp_md5sig_pool = NULL;
2273 }
2274 spin_unlock(&tcp_md5sig_pool_lock);
2275 if (pool)
2276 __tcp_free_md5sig_pool(pool);
2277}
2278
2279EXPORT_SYMBOL(tcp_free_md5sig_pool);
2280
2281static struct tcp_md5sig_pool **__tcp_alloc_md5sig_pool(void)
2282{
2283 int cpu;
2284 struct tcp_md5sig_pool **pool;
2285
2286 pool = alloc_percpu(struct tcp_md5sig_pool *);
2287 if (!pool)
2288 return NULL;
2289
2290 for_each_possible_cpu(cpu) {
2291 struct tcp_md5sig_pool *p;
2292 struct crypto_hash *hash;
2293
2294 p = kzalloc(sizeof(*p), GFP_KERNEL);
2295 if (!p)
2296 goto out_free;
2297 *per_cpu_ptr(pool, cpu) = p;
2298
2299 hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
2300 if (!hash || IS_ERR(hash))
2301 goto out_free;
2302
2303 p->md5_desc.tfm = hash;
2304 }
2305 return pool;
2306out_free:
2307 __tcp_free_md5sig_pool(pool);
2308 return NULL;
2309}
2310
2311struct tcp_md5sig_pool **tcp_alloc_md5sig_pool(void)
2312{
2313 struct tcp_md5sig_pool **pool;
2314 int alloc = 0;
2315
2316retry:
2317 spin_lock(&tcp_md5sig_pool_lock);
2318 pool = tcp_md5sig_pool;
2319 if (tcp_md5sig_users++ == 0) {
2320 alloc = 1;
2321 spin_unlock(&tcp_md5sig_pool_lock);
2322 } else if (!pool) {
2323 tcp_md5sig_users--;
2324 spin_unlock(&tcp_md5sig_pool_lock);
2325 cpu_relax();
2326 goto retry;
2327 } else
2328 spin_unlock(&tcp_md5sig_pool_lock);
2329
2330 if (alloc) {
2331 /* we cannot hold spinlock here because this may sleep. */
2332 struct tcp_md5sig_pool **p = __tcp_alloc_md5sig_pool();
2333 spin_lock(&tcp_md5sig_pool_lock);
2334 if (!p) {
2335 tcp_md5sig_users--;
2336 spin_unlock(&tcp_md5sig_pool_lock);
2337 return NULL;
2338 }
2339 pool = tcp_md5sig_pool;
2340 if (pool) {
2341 /* oops, it has already been assigned. */
2342 spin_unlock(&tcp_md5sig_pool_lock);
2343 __tcp_free_md5sig_pool(p);
2344 } else {
2345 tcp_md5sig_pool = pool = p;
2346 spin_unlock(&tcp_md5sig_pool_lock);
2347 }
2348 }
2349 return pool;
2350}
2351
2352EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
2353
2354struct tcp_md5sig_pool *__tcp_get_md5sig_pool(int cpu)
2355{
2356 struct tcp_md5sig_pool **p;
2357 spin_lock(&tcp_md5sig_pool_lock);
2358 p = tcp_md5sig_pool;
2359 if (p)
2360 tcp_md5sig_users++;
2361 spin_unlock(&tcp_md5sig_pool_lock);
2362 return (p ? *per_cpu_ptr(p, cpu) : NULL);
2363}
2364
2365EXPORT_SYMBOL(__tcp_get_md5sig_pool);
2366
2367void __tcp_put_md5sig_pool(void) {
2368 __tcp_free_md5sig_pool(tcp_md5sig_pool);
2369}
2370
2371EXPORT_SYMBOL(__tcp_put_md5sig_pool);
2372#endif
2373
2234extern void __skb_cb_too_small_for_tcp(int, int); 2374extern void __skb_cb_too_small_for_tcp(int, int);
2235extern struct tcp_congestion_ops tcp_reno; 2375extern struct tcp_congestion_ops tcp_reno;
2236 2376
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index 1e2982f4acd4..5ca7723d0798 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -113,7 +113,7 @@ int tcp_set_default_congestion_control(const char *name)
113 spin_lock(&tcp_cong_list_lock); 113 spin_lock(&tcp_cong_list_lock);
114 ca = tcp_ca_find(name); 114 ca = tcp_ca_find(name);
115#ifdef CONFIG_KMOD 115#ifdef CONFIG_KMOD
116 if (!ca) { 116 if (!ca && capable(CAP_SYS_MODULE)) {
117 spin_unlock(&tcp_cong_list_lock); 117 spin_unlock(&tcp_cong_list_lock);
118 118
119 request_module("tcp_%s", name); 119 request_module("tcp_%s", name);
@@ -123,6 +123,7 @@ int tcp_set_default_congestion_control(const char *name)
123#endif 123#endif
124 124
125 if (ca) { 125 if (ca) {
126 ca->non_restricted = 1; /* default is always allowed */
126 list_move(&ca->list, &tcp_cong_list); 127 list_move(&ca->list, &tcp_cong_list);
127 ret = 0; 128 ret = 0;
128 } 129 }
@@ -139,6 +140,22 @@ static int __init tcp_congestion_default(void)
139late_initcall(tcp_congestion_default); 140late_initcall(tcp_congestion_default);
140 141
141 142
143/* Build string with list of available congestion control values */
144void tcp_get_available_congestion_control(char *buf, size_t maxlen)
145{
146 struct tcp_congestion_ops *ca;
147 size_t offs = 0;
148
149 rcu_read_lock();
150 list_for_each_entry_rcu(ca, &tcp_cong_list, list) {
151 offs += snprintf(buf + offs, maxlen - offs,
152 "%s%s",
153 offs == 0 ? "" : " ", ca->name);
154
155 }
156 rcu_read_unlock();
157}
158
142/* Get current default congestion control */ 159/* Get current default congestion control */
143void tcp_get_default_congestion_control(char *name) 160void tcp_get_default_congestion_control(char *name)
144{ 161{
@@ -152,6 +169,64 @@ void tcp_get_default_congestion_control(char *name)
152 rcu_read_unlock(); 169 rcu_read_unlock();
153} 170}
154 171
172/* Built list of non-restricted congestion control values */
173void tcp_get_allowed_congestion_control(char *buf, size_t maxlen)
174{
175 struct tcp_congestion_ops *ca;
176 size_t offs = 0;
177
178 *buf = '\0';
179 rcu_read_lock();
180 list_for_each_entry_rcu(ca, &tcp_cong_list, list) {
181 if (!ca->non_restricted)
182 continue;
183 offs += snprintf(buf + offs, maxlen - offs,
184 "%s%s",
185 offs == 0 ? "" : " ", ca->name);
186
187 }
188 rcu_read_unlock();
189}
190
191/* Change list of non-restricted congestion control */
192int tcp_set_allowed_congestion_control(char *val)
193{
194 struct tcp_congestion_ops *ca;
195 char *clone, *name;
196 int ret = 0;
197
198 clone = kstrdup(val, GFP_USER);
199 if (!clone)
200 return -ENOMEM;
201
202 spin_lock(&tcp_cong_list_lock);
203 /* pass 1 check for bad entries */
204 while ((name = strsep(&clone, " ")) && *name) {
205 ca = tcp_ca_find(name);
206 if (!ca) {
207 ret = -ENOENT;
208 goto out;
209 }
210 }
211
212 /* pass 2 clear */
213 list_for_each_entry_rcu(ca, &tcp_cong_list, list)
214 ca->non_restricted = 0;
215
216 /* pass 3 mark as allowed */
217 while ((name = strsep(&val, " ")) && *name) {
218 ca = tcp_ca_find(name);
219 WARN_ON(!ca);
220 if (ca)
221 ca->non_restricted = 1;
222 }
223out:
224 spin_unlock(&tcp_cong_list_lock);
225
226 return ret;
227}
228
229
155/* Change congestion control for socket */ 230/* Change congestion control for socket */
156int tcp_set_congestion_control(struct sock *sk, const char *name) 231int tcp_set_congestion_control(struct sock *sk, const char *name)
157{ 232{
@@ -161,12 +236,25 @@ int tcp_set_congestion_control(struct sock *sk, const char *name)
161 236
162 rcu_read_lock(); 237 rcu_read_lock();
163 ca = tcp_ca_find(name); 238 ca = tcp_ca_find(name);
239 /* no change asking for existing value */
164 if (ca == icsk->icsk_ca_ops) 240 if (ca == icsk->icsk_ca_ops)
165 goto out; 241 goto out;
166 242
243#ifdef CONFIG_KMOD
244 /* not found attempt to autoload module */
245 if (!ca && capable(CAP_SYS_MODULE)) {
246 rcu_read_unlock();
247 request_module("tcp_%s", name);
248 rcu_read_lock();
249 ca = tcp_ca_find(name);
250 }
251#endif
167 if (!ca) 252 if (!ca)
168 err = -ENOENT; 253 err = -ENOENT;
169 254
255 else if (!(ca->non_restricted || capable(CAP_NET_ADMIN)))
256 err = -EPERM;
257
170 else if (!try_module_get(ca->owner)) 258 else if (!try_module_get(ca->owner))
171 err = -EBUSY; 259 err = -EBUSY;
172 260
@@ -268,6 +356,7 @@ EXPORT_SYMBOL_GPL(tcp_reno_min_cwnd);
268 356
269struct tcp_congestion_ops tcp_reno = { 357struct tcp_congestion_ops tcp_reno = {
270 .name = "reno", 358 .name = "reno",
359 .non_restricted = 1,
271 .owner = THIS_MODULE, 360 .owner = THIS_MODULE,
272 .ssthresh = tcp_reno_ssthresh, 361 .ssthresh = tcp_reno_ssthresh,
273 .cong_avoid = tcp_reno_cong_avoid, 362 .cong_avoid = tcp_reno_cong_avoid,
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c
index 283be3cb4667..753987a1048f 100644
--- a/net/ipv4/tcp_htcp.c
+++ b/net/ipv4/tcp_htcp.c
@@ -26,12 +26,12 @@ struct htcp {
26 u32 alpha; /* Fixed point arith, << 7 */ 26 u32 alpha; /* Fixed point arith, << 7 */
27 u8 beta; /* Fixed point arith, << 7 */ 27 u8 beta; /* Fixed point arith, << 7 */
28 u8 modeswitch; /* Delay modeswitch until we had at least one congestion event */ 28 u8 modeswitch; /* Delay modeswitch until we had at least one congestion event */
29 u32 last_cong; /* Time since last congestion event end */
30 u32 undo_last_cong;
31 u16 pkts_acked; 29 u16 pkts_acked;
32 u32 packetcount; 30 u32 packetcount;
33 u32 minRTT; 31 u32 minRTT;
34 u32 maxRTT; 32 u32 maxRTT;
33 u32 last_cong; /* Time since last congestion event end */
34 u32 undo_last_cong;
35 35
36 u32 undo_maxRTT; 36 u32 undo_maxRTT;
37 u32 undo_old_maxB; 37 u32 undo_old_maxB;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index cf06accbe687..9304034c0c47 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2677,6 +2677,14 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
2677 opt_rx->sack_ok) { 2677 opt_rx->sack_ok) {
2678 TCP_SKB_CB(skb)->sacked = (ptr - 2) - (unsigned char *)th; 2678 TCP_SKB_CB(skb)->sacked = (ptr - 2) - (unsigned char *)th;
2679 } 2679 }
2680#ifdef CONFIG_TCP_MD5SIG
2681 case TCPOPT_MD5SIG:
2682 /*
2683 * The MD5 Hash has already been
2684 * checked (see tcp_v{4,6}_do_rcv()).
2685 */
2686 break;
2687#endif
2680 }; 2688 };
2681 ptr+=opsize-2; 2689 ptr+=opsize-2;
2682 length-=opsize; 2690 length-=opsize;
@@ -3782,9 +3790,9 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
3782 return err; 3790 return err;
3783} 3791}
3784 3792
3785static int __tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb) 3793static __sum16 __tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb)
3786{ 3794{
3787 int result; 3795 __sum16 result;
3788 3796
3789 if (sock_owned_by_user(sk)) { 3797 if (sock_owned_by_user(sk)) {
3790 local_bh_enable(); 3798 local_bh_enable();
@@ -4230,6 +4238,8 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
4230 mb(); 4238 mb();
4231 tcp_set_state(sk, TCP_ESTABLISHED); 4239 tcp_set_state(sk, TCP_ESTABLISHED);
4232 4240
4241 security_inet_conn_established(sk, skb);
4242
4233 /* Make sure socket is routed, for correct metrics. */ 4243 /* Make sure socket is routed, for correct metrics. */
4234 icsk->icsk_af_ops->rebuild_header(sk); 4244 icsk->icsk_af_ops->rebuild_header(sk);
4235 4245
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 22ef8bd26620..a1222d6968c4 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -78,6 +78,9 @@
78#include <linux/proc_fs.h> 78#include <linux/proc_fs.h>
79#include <linux/seq_file.h> 79#include <linux/seq_file.h>
80 80
81#include <linux/crypto.h>
82#include <linux/scatterlist.h>
83
81int sysctl_tcp_tw_reuse __read_mostly; 84int sysctl_tcp_tw_reuse __read_mostly;
82int sysctl_tcp_low_latency __read_mostly; 85int sysctl_tcp_low_latency __read_mostly;
83 86
@@ -89,10 +92,19 @@ static struct socket *tcp_socket;
89 92
90void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb); 93void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb);
91 94
95#ifdef CONFIG_TCP_MD5SIG
96static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk,
97 __be32 addr);
98static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
99 __be32 saddr, __be32 daddr,
100 struct tcphdr *th, int protocol,
101 int tcplen);
102#endif
103
92struct inet_hashinfo __cacheline_aligned tcp_hashinfo = { 104struct inet_hashinfo __cacheline_aligned tcp_hashinfo = {
93 .lhash_lock = __RW_LOCK_UNLOCKED(tcp_hashinfo.lhash_lock), 105 .lhash_lock = __RW_LOCK_UNLOCKED(tcp_hashinfo.lhash_lock),
94 .lhash_users = ATOMIC_INIT(0), 106 .lhash_users = ATOMIC_INIT(0),
95 .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.lhash_wait), 107 .lhash_wait = __WAIT_QUEUE_HEAD_INITIALIZER(tcp_hashinfo.lhash_wait),
96}; 108};
97 109
98static int tcp_v4_get_port(struct sock *sk, unsigned short snum) 110static int tcp_v4_get_port(struct sock *sk, unsigned short snum)
@@ -111,7 +123,7 @@ void tcp_unhash(struct sock *sk)
111 inet_unhash(&tcp_hashinfo, sk); 123 inet_unhash(&tcp_hashinfo, sk);
112} 124}
113 125
114static inline __u32 tcp_v4_init_sequence(struct sock *sk, struct sk_buff *skb) 126static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb)
115{ 127{
116 return secure_tcp_sequence_number(skb->nh.iph->daddr, 128 return secure_tcp_sequence_number(skb->nh.iph->daddr,
117 skb->nh.iph->saddr, 129 skb->nh.iph->saddr,
@@ -205,13 +217,14 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
205 if (tcp_death_row.sysctl_tw_recycle && 217 if (tcp_death_row.sysctl_tw_recycle &&
206 !tp->rx_opt.ts_recent_stamp && rt->rt_dst == daddr) { 218 !tp->rx_opt.ts_recent_stamp && rt->rt_dst == daddr) {
207 struct inet_peer *peer = rt_get_peer(rt); 219 struct inet_peer *peer = rt_get_peer(rt);
208 220 /*
209 /* VJ's idea. We save last timestamp seen from 221 * VJ's idea. We save last timestamp seen from
210 * the destination in peer table, when entering state TIME-WAIT 222 * the destination in peer table, when entering state
211 * and initialize rx_opt.ts_recent from it, when trying new connection. 223 * TIME-WAIT * and initialize rx_opt.ts_recent from it,
224 * when trying new connection.
212 */ 225 */
213 226 if (peer != NULL &&
214 if (peer && peer->tcp_ts_stamp + TCP_PAWS_MSL >= xtime.tv_sec) { 227 peer->tcp_ts_stamp + TCP_PAWS_MSL >= xtime.tv_sec) {
215 tp->rx_opt.ts_recent_stamp = peer->tcp_ts_stamp; 228 tp->rx_opt.ts_recent_stamp = peer->tcp_ts_stamp;
216 tp->rx_opt.ts_recent = peer->tcp_ts; 229 tp->rx_opt.ts_recent = peer->tcp_ts;
217 } 230 }
@@ -236,7 +249,8 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
236 if (err) 249 if (err)
237 goto failure; 250 goto failure;
238 251
239 err = ip_route_newports(&rt, IPPROTO_TCP, inet->sport, inet->dport, sk); 252 err = ip_route_newports(&rt, IPPROTO_TCP,
253 inet->sport, inet->dport, sk);
240 if (err) 254 if (err)
241 goto failure; 255 goto failure;
242 256
@@ -260,7 +274,10 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
260 return 0; 274 return 0;
261 275
262failure: 276failure:
263 /* This unhashes the socket and releases the local port, if necessary. */ 277 /*
278 * This unhashes the socket and releases the local port,
279 * if necessary.
280 */
264 tcp_set_state(sk, TCP_CLOSE); 281 tcp_set_state(sk, TCP_CLOSE);
265 ip_rt_put(rt); 282 ip_rt_put(rt);
266 sk->sk_route_caps = 0; 283 sk->sk_route_caps = 0;
@@ -485,8 +502,9 @@ void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb)
485 struct tcphdr *th = skb->h.th; 502 struct tcphdr *th = skb->h.th;
486 503
487 if (skb->ip_summed == CHECKSUM_PARTIAL) { 504 if (skb->ip_summed == CHECKSUM_PARTIAL) {
488 th->check = ~tcp_v4_check(th, len, inet->saddr, inet->daddr, 0); 505 th->check = ~tcp_v4_check(th, len,
489 skb->csum = offsetof(struct tcphdr, check); 506 inet->saddr, inet->daddr, 0);
507 skb->csum_offset = offsetof(struct tcphdr, check);
490 } else { 508 } else {
491 th->check = tcp_v4_check(th, len, inet->saddr, inet->daddr, 509 th->check = tcp_v4_check(th, len, inet->saddr, inet->daddr,
492 csum_partial((char *)th, 510 csum_partial((char *)th,
@@ -508,7 +526,7 @@ int tcp_v4_gso_send_check(struct sk_buff *skb)
508 526
509 th->check = 0; 527 th->check = 0;
510 th->check = ~tcp_v4_check(th, skb->len, iph->saddr, iph->daddr, 0); 528 th->check = ~tcp_v4_check(th, skb->len, iph->saddr, iph->daddr, 0);
511 skb->csum = offsetof(struct tcphdr, check); 529 skb->csum_offset = offsetof(struct tcphdr, check);
512 skb->ip_summed = CHECKSUM_PARTIAL; 530 skb->ip_summed = CHECKSUM_PARTIAL;
513 return 0; 531 return 0;
514} 532}
@@ -526,11 +544,19 @@ int tcp_v4_gso_send_check(struct sk_buff *skb)
526 * Exception: precedence violation. We do not implement it in any case. 544 * Exception: precedence violation. We do not implement it in any case.
527 */ 545 */
528 546
529static void tcp_v4_send_reset(struct sk_buff *skb) 547static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
530{ 548{
531 struct tcphdr *th = skb->h.th; 549 struct tcphdr *th = skb->h.th;
532 struct tcphdr rth; 550 struct {
551 struct tcphdr th;
552#ifdef CONFIG_TCP_MD5SIG
553 __be32 opt[(TCPOLEN_MD5SIG_ALIGNED >> 2)];
554#endif
555 } rep;
533 struct ip_reply_arg arg; 556 struct ip_reply_arg arg;
557#ifdef CONFIG_TCP_MD5SIG
558 struct tcp_md5sig_key *key;
559#endif
534 560
535 /* Never send a reset in response to a reset. */ 561 /* Never send a reset in response to a reset. */
536 if (th->rst) 562 if (th->rst)
@@ -540,29 +566,49 @@ static void tcp_v4_send_reset(struct sk_buff *skb)
540 return; 566 return;
541 567
542 /* Swap the send and the receive. */ 568 /* Swap the send and the receive. */
543 memset(&rth, 0, sizeof(struct tcphdr)); 569 memset(&rep, 0, sizeof(rep));
544 rth.dest = th->source; 570 rep.th.dest = th->source;
545 rth.source = th->dest; 571 rep.th.source = th->dest;
546 rth.doff = sizeof(struct tcphdr) / 4; 572 rep.th.doff = sizeof(struct tcphdr) / 4;
547 rth.rst = 1; 573 rep.th.rst = 1;
548 574
549 if (th->ack) { 575 if (th->ack) {
550 rth.seq = th->ack_seq; 576 rep.th.seq = th->ack_seq;
551 } else { 577 } else {
552 rth.ack = 1; 578 rep.th.ack = 1;
553 rth.ack_seq = htonl(ntohl(th->seq) + th->syn + th->fin + 579 rep.th.ack_seq = htonl(ntohl(th->seq) + th->syn + th->fin +
554 skb->len - (th->doff << 2)); 580 skb->len - (th->doff << 2));
555 } 581 }
556 582
557 memset(&arg, 0, sizeof arg); 583 memset(&arg, 0, sizeof(arg));
558 arg.iov[0].iov_base = (unsigned char *)&rth; 584 arg.iov[0].iov_base = (unsigned char *)&rep;
559 arg.iov[0].iov_len = sizeof rth; 585 arg.iov[0].iov_len = sizeof(rep.th);
586
587#ifdef CONFIG_TCP_MD5SIG
588 key = sk ? tcp_v4_md5_do_lookup(sk, skb->nh.iph->daddr) : NULL;
589 if (key) {
590 rep.opt[0] = htonl((TCPOPT_NOP << 24) |
591 (TCPOPT_NOP << 16) |
592 (TCPOPT_MD5SIG << 8) |
593 TCPOLEN_MD5SIG);
594 /* Update length and the length the header thinks exists */
595 arg.iov[0].iov_len += TCPOLEN_MD5SIG_ALIGNED;
596 rep.th.doff = arg.iov[0].iov_len / 4;
597
598 tcp_v4_do_calc_md5_hash((__u8 *)&rep.opt[1],
599 key,
600 skb->nh.iph->daddr,
601 skb->nh.iph->saddr,
602 &rep.th, IPPROTO_TCP,
603 arg.iov[0].iov_len);
604 }
605#endif
560 arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr, 606 arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr,
561 skb->nh.iph->saddr, /*XXX*/ 607 skb->nh.iph->saddr, /* XXX */
562 sizeof(struct tcphdr), IPPROTO_TCP, 0); 608 sizeof(struct tcphdr), IPPROTO_TCP, 0);
563 arg.csumoffset = offsetof(struct tcphdr, check) / 2; 609 arg.csumoffset = offsetof(struct tcphdr, check) / 2;
564 610
565 ip_send_reply(tcp_socket->sk, skb, &arg, sizeof rth); 611 ip_send_reply(tcp_socket->sk, skb, &arg, arg.iov[0].iov_len);
566 612
567 TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); 613 TCP_INC_STATS_BH(TCP_MIB_OUTSEGS);
568 TCP_INC_STATS_BH(TCP_MIB_OUTRSTS); 614 TCP_INC_STATS_BH(TCP_MIB_OUTRSTS);
@@ -572,28 +618,37 @@ static void tcp_v4_send_reset(struct sk_buff *skb)
572 outside socket context is ugly, certainly. What can I do? 618 outside socket context is ugly, certainly. What can I do?
573 */ 619 */
574 620
575static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, 621static void tcp_v4_send_ack(struct tcp_timewait_sock *twsk,
622 struct sk_buff *skb, u32 seq, u32 ack,
576 u32 win, u32 ts) 623 u32 win, u32 ts)
577{ 624{
578 struct tcphdr *th = skb->h.th; 625 struct tcphdr *th = skb->h.th;
579 struct { 626 struct {
580 struct tcphdr th; 627 struct tcphdr th;
581 u32 tsopt[TCPOLEN_TSTAMP_ALIGNED >> 2]; 628 __be32 opt[(TCPOLEN_TSTAMP_ALIGNED >> 2)
629#ifdef CONFIG_TCP_MD5SIG
630 + (TCPOLEN_MD5SIG_ALIGNED >> 2)
631#endif
632 ];
582 } rep; 633 } rep;
583 struct ip_reply_arg arg; 634 struct ip_reply_arg arg;
635#ifdef CONFIG_TCP_MD5SIG
636 struct tcp_md5sig_key *key;
637 struct tcp_md5sig_key tw_key;
638#endif
584 639
585 memset(&rep.th, 0, sizeof(struct tcphdr)); 640 memset(&rep.th, 0, sizeof(struct tcphdr));
586 memset(&arg, 0, sizeof arg); 641 memset(&arg, 0, sizeof(arg));
587 642
588 arg.iov[0].iov_base = (unsigned char *)&rep; 643 arg.iov[0].iov_base = (unsigned char *)&rep;
589 arg.iov[0].iov_len = sizeof(rep.th); 644 arg.iov[0].iov_len = sizeof(rep.th);
590 if (ts) { 645 if (ts) {
591 rep.tsopt[0] = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | 646 rep.opt[0] = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
592 (TCPOPT_TIMESTAMP << 8) | 647 (TCPOPT_TIMESTAMP << 8) |
593 TCPOLEN_TIMESTAMP); 648 TCPOLEN_TIMESTAMP);
594 rep.tsopt[1] = htonl(tcp_time_stamp); 649 rep.opt[1] = htonl(tcp_time_stamp);
595 rep.tsopt[2] = htonl(ts); 650 rep.opt[2] = htonl(ts);
596 arg.iov[0].iov_len = sizeof(rep); 651 arg.iov[0].iov_len = TCPOLEN_TSTAMP_ALIGNED;
597 } 652 }
598 653
599 /* Swap the send and the receive. */ 654 /* Swap the send and the receive. */
@@ -605,8 +660,44 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
605 rep.th.ack = 1; 660 rep.th.ack = 1;
606 rep.th.window = htons(win); 661 rep.th.window = htons(win);
607 662
663#ifdef CONFIG_TCP_MD5SIG
664 /*
665 * The SKB holds an imcoming packet, but may not have a valid ->sk
666 * pointer. This is especially the case when we're dealing with a
667 * TIME_WAIT ack, because the sk structure is long gone, and only
668 * the tcp_timewait_sock remains. So the md5 key is stashed in that
669 * structure, and we use it in preference. I believe that (twsk ||
670 * skb->sk) holds true, but we program defensively.
671 */
672 if (!twsk && skb->sk) {
673 key = tcp_v4_md5_do_lookup(skb->sk, skb->nh.iph->daddr);
674 } else if (twsk && twsk->tw_md5_keylen) {
675 tw_key.key = twsk->tw_md5_key;
676 tw_key.keylen = twsk->tw_md5_keylen;
677 key = &tw_key;
678 } else
679 key = NULL;
680
681 if (key) {
682 int offset = (ts) ? 3 : 0;
683
684 rep.opt[offset++] = htonl((TCPOPT_NOP << 24) |
685 (TCPOPT_NOP << 16) |
686 (TCPOPT_MD5SIG << 8) |
687 TCPOLEN_MD5SIG);
688 arg.iov[0].iov_len += TCPOLEN_MD5SIG_ALIGNED;
689 rep.th.doff = arg.iov[0].iov_len/4;
690
691 tcp_v4_do_calc_md5_hash((__u8 *)&rep.opt[offset],
692 key,
693 skb->nh.iph->daddr,
694 skb->nh.iph->saddr,
695 &rep.th, IPPROTO_TCP,
696 arg.iov[0].iov_len);
697 }
698#endif
608 arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr, 699 arg.csum = csum_tcpudp_nofold(skb->nh.iph->daddr,
609 skb->nh.iph->saddr, /*XXX*/ 700 skb->nh.iph->saddr, /* XXX */
610 arg.iov[0].iov_len, IPPROTO_TCP, 0); 701 arg.iov[0].iov_len, IPPROTO_TCP, 0);
611 arg.csumoffset = offsetof(struct tcphdr, check) / 2; 702 arg.csumoffset = offsetof(struct tcphdr, check) / 2;
612 703
@@ -618,17 +709,20 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
618static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) 709static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb)
619{ 710{
620 struct inet_timewait_sock *tw = inet_twsk(sk); 711 struct inet_timewait_sock *tw = inet_twsk(sk);
621 const struct tcp_timewait_sock *tcptw = tcp_twsk(sk); 712 struct tcp_timewait_sock *tcptw = tcp_twsk(sk);
622 713
623 tcp_v4_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, 714 tcp_v4_send_ack(tcptw, skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt,
624 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, tcptw->tw_ts_recent); 715 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,
716 tcptw->tw_ts_recent);
625 717
626 inet_twsk_put(tw); 718 inet_twsk_put(tw);
627} 719}
628 720
629static void tcp_v4_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) 721static void tcp_v4_reqsk_send_ack(struct sk_buff *skb,
722 struct request_sock *req)
630{ 723{
631 tcp_v4_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, 724 tcp_v4_send_ack(NULL, skb, tcp_rsk(req)->snt_isn + 1,
725 tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd,
632 req->ts_recent); 726 req->ts_recent);
633} 727}
634 728
@@ -662,8 +756,7 @@ static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req,
662 err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr, 756 err = ip_build_and_send_pkt(skb, sk, ireq->loc_addr,
663 ireq->rmt_addr, 757 ireq->rmt_addr,
664 ireq->opt); 758 ireq->opt);
665 if (err == NET_XMIT_CN) 759 err = net_xmit_eval(err);
666 err = 0;
667 } 760 }
668 761
669out: 762out:
@@ -715,7 +808,423 @@ static struct ip_options *tcp_v4_save_options(struct sock *sk,
715 return dopt; 808 return dopt;
716} 809}
717 810
718struct request_sock_ops tcp_request_sock_ops = { 811#ifdef CONFIG_TCP_MD5SIG
812/*
813 * RFC2385 MD5 checksumming requires a mapping of
814 * IP address->MD5 Key.
815 * We need to maintain these in the sk structure.
816 */
817
818/* Find the Key structure for an address. */
819static struct tcp_md5sig_key *
820 tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr)
821{
822 struct tcp_sock *tp = tcp_sk(sk);
823 int i;
824
825 if (!tp->md5sig_info || !tp->md5sig_info->entries4)
826 return NULL;
827 for (i = 0; i < tp->md5sig_info->entries4; i++) {
828 if (tp->md5sig_info->keys4[i].addr == addr)
829 return (struct tcp_md5sig_key *)
830 &tp->md5sig_info->keys4[i];
831 }
832 return NULL;
833}
834
835struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
836 struct sock *addr_sk)
837{
838 return tcp_v4_md5_do_lookup(sk, inet_sk(addr_sk)->daddr);
839}
840
841EXPORT_SYMBOL(tcp_v4_md5_lookup);
842
843static struct tcp_md5sig_key *tcp_v4_reqsk_md5_lookup(struct sock *sk,
844 struct request_sock *req)
845{
846 return tcp_v4_md5_do_lookup(sk, inet_rsk(req)->rmt_addr);
847}
848
849/* This can be called on a newly created socket, from other files */
850int tcp_v4_md5_do_add(struct sock *sk, __be32 addr,
851 u8 *newkey, u8 newkeylen)
852{
853 /* Add Key to the list */
854 struct tcp4_md5sig_key *key;
855 struct tcp_sock *tp = tcp_sk(sk);
856 struct tcp4_md5sig_key *keys;
857
858 key = (struct tcp4_md5sig_key *)tcp_v4_md5_do_lookup(sk, addr);
859 if (key) {
860 /* Pre-existing entry - just update that one. */
861 kfree(key->key);
862 key->key = newkey;
863 key->keylen = newkeylen;
864 } else {
865 struct tcp_md5sig_info *md5sig;
866
867 if (!tp->md5sig_info) {
868 tp->md5sig_info = kzalloc(sizeof(*tp->md5sig_info),
869 GFP_ATOMIC);
870 if (!tp->md5sig_info) {
871 kfree(newkey);
872 return -ENOMEM;
873 }
874 }
875 if (tcp_alloc_md5sig_pool() == NULL) {
876 kfree(newkey);
877 return -ENOMEM;
878 }
879 md5sig = tp->md5sig_info;
880
881 if (md5sig->alloced4 == md5sig->entries4) {
882 keys = kmalloc((sizeof(*keys) *
883 (md5sig->entries4 + 1)), GFP_ATOMIC);
884 if (!keys) {
885 kfree(newkey);
886 tcp_free_md5sig_pool();
887 return -ENOMEM;
888 }
889
890 if (md5sig->entries4)
891 memcpy(keys, md5sig->keys4,
892 sizeof(*keys) * md5sig->entries4);
893
894 /* Free old key list, and reference new one */
895 if (md5sig->keys4)
896 kfree(md5sig->keys4);
897 md5sig->keys4 = keys;
898 md5sig->alloced4++;
899 }
900 md5sig->entries4++;
901 md5sig->keys4[md5sig->entries4 - 1].addr = addr;
902 md5sig->keys4[md5sig->entries4 - 1].key = newkey;
903 md5sig->keys4[md5sig->entries4 - 1].keylen = newkeylen;
904 }
905 return 0;
906}
907
908EXPORT_SYMBOL(tcp_v4_md5_do_add);
909
910static int tcp_v4_md5_add_func(struct sock *sk, struct sock *addr_sk,
911 u8 *newkey, u8 newkeylen)
912{
913 return tcp_v4_md5_do_add(sk, inet_sk(addr_sk)->daddr,
914 newkey, newkeylen);
915}
916
917int tcp_v4_md5_do_del(struct sock *sk, __be32 addr)
918{
919 struct tcp_sock *tp = tcp_sk(sk);
920 int i;
921
922 for (i = 0; i < tp->md5sig_info->entries4; i++) {
923 if (tp->md5sig_info->keys4[i].addr == addr) {
924 /* Free the key */
925 kfree(tp->md5sig_info->keys4[i].key);
926 tp->md5sig_info->entries4--;
927
928 if (tp->md5sig_info->entries4 == 0) {
929 kfree(tp->md5sig_info->keys4);
930 tp->md5sig_info->keys4 = NULL;
931 } else if (tp->md5sig_info->entries4 != i) {
932 /* Need to do some manipulation */
933 memcpy(&tp->md5sig_info->keys4[i],
934 &tp->md5sig_info->keys4[i+1],
935 (tp->md5sig_info->entries4 - i) *
936 sizeof(struct tcp4_md5sig_key));
937 }
938 tcp_free_md5sig_pool();
939 return 0;
940 }
941 }
942 return -ENOENT;
943}
944
945EXPORT_SYMBOL(tcp_v4_md5_do_del);
946
947static void tcp_v4_clear_md5_list(struct sock *sk)
948{
949 struct tcp_sock *tp = tcp_sk(sk);
950
951 /* Free each key, then the set of key keys,
952 * the crypto element, and then decrement our
953 * hold on the last resort crypto.
954 */
955 if (tp->md5sig_info->entries4) {
956 int i;
957 for (i = 0; i < tp->md5sig_info->entries4; i++)
958 kfree(tp->md5sig_info->keys4[i].key);
959 tp->md5sig_info->entries4 = 0;
960 tcp_free_md5sig_pool();
961 }
962 if (tp->md5sig_info->keys4) {
963 kfree(tp->md5sig_info->keys4);
964 tp->md5sig_info->keys4 = NULL;
965 tp->md5sig_info->alloced4 = 0;
966 }
967}
968
969static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval,
970 int optlen)
971{
972 struct tcp_md5sig cmd;
973 struct sockaddr_in *sin = (struct sockaddr_in *)&cmd.tcpm_addr;
974 u8 *newkey;
975
976 if (optlen < sizeof(cmd))
977 return -EINVAL;
978
979 if (copy_from_user(&cmd, optval, sizeof(cmd)))
980 return -EFAULT;
981
982 if (sin->sin_family != AF_INET)
983 return -EINVAL;
984
985 if (!cmd.tcpm_key || !cmd.tcpm_keylen) {
986 if (!tcp_sk(sk)->md5sig_info)
987 return -ENOENT;
988 return tcp_v4_md5_do_del(sk, sin->sin_addr.s_addr);
989 }
990
991 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
992 return -EINVAL;
993
994 if (!tcp_sk(sk)->md5sig_info) {
995 struct tcp_sock *tp = tcp_sk(sk);
996 struct tcp_md5sig_info *p = kzalloc(sizeof(*p), GFP_KERNEL);
997
998 if (!p)
999 return -EINVAL;
1000
1001 tp->md5sig_info = p;
1002
1003 }
1004
1005 newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
1006 if (!newkey)
1007 return -ENOMEM;
1008 return tcp_v4_md5_do_add(sk, sin->sin_addr.s_addr,
1009 newkey, cmd.tcpm_keylen);
1010}
1011
1012static int tcp_v4_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
1013 __be32 saddr, __be32 daddr,
1014 struct tcphdr *th, int protocol,
1015 int tcplen)
1016{
1017 struct scatterlist sg[4];
1018 __u16 data_len;
1019 int block = 0;
1020 __sum16 old_checksum;
1021 struct tcp_md5sig_pool *hp;
1022 struct tcp4_pseudohdr *bp;
1023 struct hash_desc *desc;
1024 int err;
1025 unsigned int nbytes = 0;
1026
1027 /*
1028 * Okay, so RFC2385 is turned on for this connection,
1029 * so we need to generate the MD5 hash for the packet now.
1030 */
1031
1032 hp = tcp_get_md5sig_pool();
1033 if (!hp)
1034 goto clear_hash_noput;
1035
1036 bp = &hp->md5_blk.ip4;
1037 desc = &hp->md5_desc;
1038
1039 /*
1040 * 1. the TCP pseudo-header (in the order: source IP address,
1041 * destination IP address, zero-padded protocol number, and
1042 * segment length)
1043 */
1044 bp->saddr = saddr;
1045 bp->daddr = daddr;
1046 bp->pad = 0;
1047 bp->protocol = protocol;
1048 bp->len = htons(tcplen);
1049 sg_set_buf(&sg[block++], bp, sizeof(*bp));
1050 nbytes += sizeof(*bp);
1051
1052 /* 2. the TCP header, excluding options, and assuming a
1053 * checksum of zero/
1054 */
1055 old_checksum = th->check;
1056 th->check = 0;
1057 sg_set_buf(&sg[block++], th, sizeof(struct tcphdr));
1058 nbytes += sizeof(struct tcphdr);
1059
1060 /* 3. the TCP segment data (if any) */
1061 data_len = tcplen - (th->doff << 2);
1062 if (data_len > 0) {
1063 unsigned char *data = (unsigned char *)th + (th->doff << 2);
1064 sg_set_buf(&sg[block++], data, data_len);
1065 nbytes += data_len;
1066 }
1067
1068 /* 4. an independently-specified key or password, known to both
1069 * TCPs and presumably connection-specific
1070 */
1071 sg_set_buf(&sg[block++], key->key, key->keylen);
1072 nbytes += key->keylen;
1073
1074 /* Now store the Hash into the packet */
1075 err = crypto_hash_init(desc);
1076 if (err)
1077 goto clear_hash;
1078 err = crypto_hash_update(desc, sg, nbytes);
1079 if (err)
1080 goto clear_hash;
1081 err = crypto_hash_final(desc, md5_hash);
1082 if (err)
1083 goto clear_hash;
1084
1085 /* Reset header, and free up the crypto */
1086 tcp_put_md5sig_pool();
1087 th->check = old_checksum;
1088
1089out:
1090 return 0;
1091clear_hash:
1092 tcp_put_md5sig_pool();
1093clear_hash_noput:
1094 memset(md5_hash, 0, 16);
1095 goto out;
1096}
1097
1098int tcp_v4_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
1099 struct sock *sk,
1100 struct dst_entry *dst,
1101 struct request_sock *req,
1102 struct tcphdr *th, int protocol,
1103 int tcplen)
1104{
1105 __be32 saddr, daddr;
1106
1107 if (sk) {
1108 saddr = inet_sk(sk)->saddr;
1109 daddr = inet_sk(sk)->daddr;
1110 } else {
1111 struct rtable *rt = (struct rtable *)dst;
1112 BUG_ON(!rt);
1113 saddr = rt->rt_src;
1114 daddr = rt->rt_dst;
1115 }
1116 return tcp_v4_do_calc_md5_hash(md5_hash, key,
1117 saddr, daddr,
1118 th, protocol, tcplen);
1119}
1120
1121EXPORT_SYMBOL(tcp_v4_calc_md5_hash);
1122
1123static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb)
1124{
1125 /*
1126 * This gets called for each TCP segment that arrives
1127 * so we want to be efficient.
1128 * We have 3 drop cases:
1129 * o No MD5 hash and one expected.
1130 * o MD5 hash and we're not expecting one.
1131 * o MD5 hash and its wrong.
1132 */
1133 __u8 *hash_location = NULL;
1134 struct tcp_md5sig_key *hash_expected;
1135 struct iphdr *iph = skb->nh.iph;
1136 struct tcphdr *th = skb->h.th;
1137 int length = (th->doff << 2) - sizeof(struct tcphdr);
1138 int genhash;
1139 unsigned char *ptr;
1140 unsigned char newhash[16];
1141
1142 hash_expected = tcp_v4_md5_do_lookup(sk, iph->saddr);
1143
1144 /*
1145 * If the TCP option length is less than the TCP_MD5SIG
1146 * option length, then we can shortcut
1147 */
1148 if (length < TCPOLEN_MD5SIG) {
1149 if (hash_expected)
1150 return 1;
1151 else
1152 return 0;
1153 }
1154
1155 /* Okay, we can't shortcut - we have to grub through the options */
1156 ptr = (unsigned char *)(th + 1);
1157 while (length > 0) {
1158 int opcode = *ptr++;
1159 int opsize;
1160
1161 switch (opcode) {
1162 case TCPOPT_EOL:
1163 goto done_opts;
1164 case TCPOPT_NOP:
1165 length--;
1166 continue;
1167 default:
1168 opsize = *ptr++;
1169 if (opsize < 2)
1170 goto done_opts;
1171 if (opsize > length)
1172 goto done_opts;
1173
1174 if (opcode == TCPOPT_MD5SIG) {
1175 hash_location = ptr;
1176 goto done_opts;
1177 }
1178 }
1179 ptr += opsize-2;
1180 length -= opsize;
1181 }
1182done_opts:
1183 /* We've parsed the options - do we have a hash? */
1184 if (!hash_expected && !hash_location)
1185 return 0;
1186
1187 if (hash_expected && !hash_location) {
1188 LIMIT_NETDEBUG(KERN_INFO "MD5 Hash NOT expected but found "
1189 "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)\n",
1190 NIPQUAD(iph->saddr), ntohs(th->source),
1191 NIPQUAD(iph->daddr), ntohs(th->dest));
1192 return 1;
1193 }
1194
1195 if (!hash_expected && hash_location) {
1196 LIMIT_NETDEBUG(KERN_INFO "MD5 Hash NOT expected but found "
1197 "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)\n",
1198 NIPQUAD(iph->saddr), ntohs(th->source),
1199 NIPQUAD(iph->daddr), ntohs(th->dest));
1200 return 1;
1201 }
1202
1203 /* Okay, so this is hash_expected and hash_location -
1204 * so we need to calculate the checksum.
1205 */
1206 genhash = tcp_v4_do_calc_md5_hash(newhash,
1207 hash_expected,
1208 iph->saddr, iph->daddr,
1209 th, sk->sk_protocol,
1210 skb->len);
1211
1212 if (genhash || memcmp(hash_location, newhash, 16) != 0) {
1213 if (net_ratelimit()) {
1214 printk(KERN_INFO "MD5 Hash failed for "
1215 "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)%s\n",
1216 NIPQUAD(iph->saddr), ntohs(th->source),
1217 NIPQUAD(iph->daddr), ntohs(th->dest),
1218 genhash ? " tcp_v4_calc_md5_hash failed" : "");
1219 }
1220 return 1;
1221 }
1222 return 0;
1223}
1224
1225#endif
1226
1227struct request_sock_ops tcp_request_sock_ops __read_mostly = {
719 .family = PF_INET, 1228 .family = PF_INET,
720 .obj_size = sizeof(struct tcp_request_sock), 1229 .obj_size = sizeof(struct tcp_request_sock),
721 .rtx_syn_ack = tcp_v4_send_synack, 1230 .rtx_syn_ack = tcp_v4_send_synack,
@@ -724,9 +1233,16 @@ struct request_sock_ops tcp_request_sock_ops = {
724 .send_reset = tcp_v4_send_reset, 1233 .send_reset = tcp_v4_send_reset,
725}; 1234};
726 1235
1236#ifdef CONFIG_TCP_MD5SIG
1237static struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = {
1238 .md5_lookup = tcp_v4_reqsk_md5_lookup,
1239};
1240#endif
1241
727static struct timewait_sock_ops tcp_timewait_sock_ops = { 1242static struct timewait_sock_ops tcp_timewait_sock_ops = {
728 .twsk_obj_size = sizeof(struct tcp_timewait_sock), 1243 .twsk_obj_size = sizeof(struct tcp_timewait_sock),
729 .twsk_unique = tcp_twsk_unique, 1244 .twsk_unique = tcp_twsk_unique,
1245 .twsk_destructor= tcp_twsk_destructor,
730}; 1246};
731 1247
732int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) 1248int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
@@ -774,6 +1290,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
774 if (!req) 1290 if (!req)
775 goto drop; 1291 goto drop;
776 1292
1293#ifdef CONFIG_TCP_MD5SIG
1294 tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops;
1295#endif
1296
777 tcp_clear_options(&tmp_opt); 1297 tcp_clear_options(&tmp_opt);
778 tmp_opt.mss_clamp = 536; 1298 tmp_opt.mss_clamp = 536;
779 tmp_opt.user_mss = tcp_sk(sk)->rx_opt.user_mss; 1299 tmp_opt.user_mss = tcp_sk(sk)->rx_opt.user_mss;
@@ -859,7 +1379,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
859 goto drop_and_free; 1379 goto drop_and_free;
860 } 1380 }
861 1381
862 isn = tcp_v4_init_sequence(sk, skb); 1382 isn = tcp_v4_init_sequence(skb);
863 } 1383 }
864 tcp_rsk(req)->snt_isn = isn; 1384 tcp_rsk(req)->snt_isn = isn;
865 1385
@@ -892,6 +1412,9 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
892 struct inet_sock *newinet; 1412 struct inet_sock *newinet;
893 struct tcp_sock *newtp; 1413 struct tcp_sock *newtp;
894 struct sock *newsk; 1414 struct sock *newsk;
1415#ifdef CONFIG_TCP_MD5SIG
1416 struct tcp_md5sig_key *key;
1417#endif
895 1418
896 if (sk_acceptq_is_full(sk)) 1419 if (sk_acceptq_is_full(sk))
897 goto exit_overflow; 1420 goto exit_overflow;
@@ -926,6 +1449,22 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
926 newtp->advmss = dst_metric(dst, RTAX_ADVMSS); 1449 newtp->advmss = dst_metric(dst, RTAX_ADVMSS);
927 tcp_initialize_rcv_mss(newsk); 1450 tcp_initialize_rcv_mss(newsk);
928 1451
1452#ifdef CONFIG_TCP_MD5SIG
1453 /* Copy over the MD5 key from the original socket */
1454 if ((key = tcp_v4_md5_do_lookup(sk, newinet->daddr)) != NULL) {
1455 /*
1456 * We're using one, so create a matching key
1457 * on the newsk structure. If we fail to get
1458 * memory, then we end up not copying the key
1459 * across. Shucks.
1460 */
1461 char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC);
1462 if (newkey != NULL)
1463 tcp_v4_md5_do_add(newsk, inet_sk(sk)->daddr,
1464 newkey, key->keylen);
1465 }
1466#endif
1467
929 __inet_hash(&tcp_hashinfo, newsk, 0); 1468 __inet_hash(&tcp_hashinfo, newsk, 0);
930 __inet_inherit_port(&tcp_hashinfo, sk, newsk); 1469 __inet_inherit_port(&tcp_hashinfo, sk, newsk);
931 1470
@@ -971,7 +1510,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
971 return sk; 1510 return sk;
972} 1511}
973 1512
974static int tcp_v4_checksum_init(struct sk_buff *skb) 1513static __sum16 tcp_v4_checksum_init(struct sk_buff *skb)
975{ 1514{
976 if (skb->ip_summed == CHECKSUM_COMPLETE) { 1515 if (skb->ip_summed == CHECKSUM_COMPLETE) {
977 if (!tcp_v4_check(skb->h.th, skb->len, skb->nh.iph->saddr, 1516 if (!tcp_v4_check(skb->h.th, skb->len, skb->nh.iph->saddr,
@@ -1001,10 +1540,24 @@ static int tcp_v4_checksum_init(struct sk_buff *skb)
1001 */ 1540 */
1002int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) 1541int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
1003{ 1542{
1543 struct sock *rsk;
1544#ifdef CONFIG_TCP_MD5SIG
1545 /*
1546 * We really want to reject the packet as early as possible
1547 * if:
1548 * o We're expecting an MD5'd packet and this is no MD5 tcp option
1549 * o There is an MD5 option and we're not expecting one
1550 */
1551 if (tcp_v4_inbound_md5_hash(sk, skb))
1552 goto discard;
1553#endif
1554
1004 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ 1555 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
1005 TCP_CHECK_TIMER(sk); 1556 TCP_CHECK_TIMER(sk);
1006 if (tcp_rcv_established(sk, skb, skb->h.th, skb->len)) 1557 if (tcp_rcv_established(sk, skb, skb->h.th, skb->len)) {
1558 rsk = sk;
1007 goto reset; 1559 goto reset;
1560 }
1008 TCP_CHECK_TIMER(sk); 1561 TCP_CHECK_TIMER(sk);
1009 return 0; 1562 return 0;
1010 } 1563 }
@@ -1018,20 +1571,24 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
1018 goto discard; 1571 goto discard;
1019 1572
1020 if (nsk != sk) { 1573 if (nsk != sk) {
1021 if (tcp_child_process(sk, nsk, skb)) 1574 if (tcp_child_process(sk, nsk, skb)) {
1575 rsk = nsk;
1022 goto reset; 1576 goto reset;
1577 }
1023 return 0; 1578 return 0;
1024 } 1579 }
1025 } 1580 }
1026 1581
1027 TCP_CHECK_TIMER(sk); 1582 TCP_CHECK_TIMER(sk);
1028 if (tcp_rcv_state_process(sk, skb, skb->h.th, skb->len)) 1583 if (tcp_rcv_state_process(sk, skb, skb->h.th, skb->len)) {
1584 rsk = sk;
1029 goto reset; 1585 goto reset;
1586 }
1030 TCP_CHECK_TIMER(sk); 1587 TCP_CHECK_TIMER(sk);
1031 return 0; 1588 return 0;
1032 1589
1033reset: 1590reset:
1034 tcp_v4_send_reset(skb); 1591 tcp_v4_send_reset(rsk, skb);
1035discard: 1592discard:
1036 kfree_skb(skb); 1593 kfree_skb(skb);
1037 /* Be careful here. If this function gets more complicated and 1594 /* Be careful here. If this function gets more complicated and
@@ -1140,7 +1697,7 @@ no_tcp_socket:
1140bad_packet: 1697bad_packet:
1141 TCP_INC_STATS_BH(TCP_MIB_INERRS); 1698 TCP_INC_STATS_BH(TCP_MIB_INERRS);
1142 } else { 1699 } else {
1143 tcp_v4_send_reset(skb); 1700 tcp_v4_send_reset(NULL, skb);
1144 } 1701 }
1145 1702
1146discard_it: 1703discard_it:
@@ -1263,6 +1820,15 @@ struct inet_connection_sock_af_ops ipv4_specific = {
1263#endif 1820#endif
1264}; 1821};
1265 1822
1823#ifdef CONFIG_TCP_MD5SIG
1824static struct tcp_sock_af_ops tcp_sock_ipv4_specific = {
1825 .md5_lookup = tcp_v4_md5_lookup,
1826 .calc_md5_hash = tcp_v4_calc_md5_hash,
1827 .md5_add = tcp_v4_md5_add_func,
1828 .md5_parse = tcp_v4_parse_md5_keys,
1829};
1830#endif
1831
1266/* NOTE: A lot of things set to zero explicitly by call to 1832/* NOTE: A lot of things set to zero explicitly by call to
1267 * sk_alloc() so need not be done here. 1833 * sk_alloc() so need not be done here.
1268 */ 1834 */
@@ -1302,6 +1868,9 @@ static int tcp_v4_init_sock(struct sock *sk)
1302 1868
1303 icsk->icsk_af_ops = &ipv4_specific; 1869 icsk->icsk_af_ops = &ipv4_specific;
1304 icsk->icsk_sync_mss = tcp_sync_mss; 1870 icsk->icsk_sync_mss = tcp_sync_mss;
1871#ifdef CONFIG_TCP_MD5SIG
1872 tp->af_specific = &tcp_sock_ipv4_specific;
1873#endif
1305 1874
1306 sk->sk_sndbuf = sysctl_tcp_wmem[1]; 1875 sk->sk_sndbuf = sysctl_tcp_wmem[1];
1307 sk->sk_rcvbuf = sysctl_tcp_rmem[1]; 1876 sk->sk_rcvbuf = sysctl_tcp_rmem[1];
@@ -1325,6 +1894,15 @@ int tcp_v4_destroy_sock(struct sock *sk)
1325 /* Cleans up our, hopefully empty, out_of_order_queue. */ 1894 /* Cleans up our, hopefully empty, out_of_order_queue. */
1326 __skb_queue_purge(&tp->out_of_order_queue); 1895 __skb_queue_purge(&tp->out_of_order_queue);
1327 1896
1897#ifdef CONFIG_TCP_MD5SIG
1898 /* Clean up the MD5 key list, if any */
1899 if (tp->md5sig_info) {
1900 tcp_v4_clear_md5_list(sk);
1901 kfree(tp->md5sig_info);
1902 tp->md5sig_info = NULL;
1903 }
1904#endif
1905
1328#ifdef CONFIG_NET_DMA 1906#ifdef CONFIG_NET_DMA
1329 /* Cleans up our sk_async_wait_queue */ 1907 /* Cleans up our sk_async_wait_queue */
1330 __skb_queue_purge(&sk->sk_async_wait_queue); 1908 __skb_queue_purge(&sk->sk_async_wait_queue);
@@ -1385,7 +1963,7 @@ static void *listening_get_next(struct seq_file *seq, void *cur)
1385 if (st->state == TCP_SEQ_STATE_OPENREQ) { 1963 if (st->state == TCP_SEQ_STATE_OPENREQ) {
1386 struct request_sock *req = cur; 1964 struct request_sock *req = cur;
1387 1965
1388 icsk = inet_csk(st->syn_wait_sk); 1966 icsk = inet_csk(st->syn_wait_sk);
1389 req = req->dl_next; 1967 req = req->dl_next;
1390 while (1) { 1968 while (1) {
1391 while (req) { 1969 while (req) {
@@ -1395,7 +1973,7 @@ static void *listening_get_next(struct seq_file *seq, void *cur)
1395 } 1973 }
1396 req = req->dl_next; 1974 req = req->dl_next;
1397 } 1975 }
1398 if (++st->sbucket >= TCP_SYNQ_HSIZE) 1976 if (++st->sbucket >= icsk->icsk_accept_queue.listen_opt->nr_table_entries)
1399 break; 1977 break;
1400get_req: 1978get_req:
1401 req = icsk->icsk_accept_queue.listen_opt->syn_table[st->sbucket]; 1979 req = icsk->icsk_accept_queue.listen_opt->syn_table[st->sbucket];
@@ -1543,7 +2121,7 @@ static void *established_get_idx(struct seq_file *seq, loff_t pos)
1543 while (rc && pos) { 2121 while (rc && pos) {
1544 rc = established_get_next(seq, rc); 2122 rc = established_get_next(seq, rc);
1545 --pos; 2123 --pos;
1546 } 2124 }
1547 return rc; 2125 return rc;
1548} 2126}
1549 2127
@@ -1672,7 +2250,7 @@ int tcp_proc_register(struct tcp_seq_afinfo *afinfo)
1672 afinfo->seq_fops->read = seq_read; 2250 afinfo->seq_fops->read = seq_read;
1673 afinfo->seq_fops->llseek = seq_lseek; 2251 afinfo->seq_fops->llseek = seq_lseek;
1674 afinfo->seq_fops->release = seq_release_private; 2252 afinfo->seq_fops->release = seq_release_private;
1675 2253
1676 p = proc_net_fops_create(afinfo->name, S_IRUGO, afinfo->seq_fops); 2254 p = proc_net_fops_create(afinfo->name, S_IRUGO, afinfo->seq_fops);
1677 if (p) 2255 if (p)
1678 p->data = afinfo; 2256 p->data = afinfo;
@@ -1686,7 +2264,7 @@ void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo)
1686 if (!afinfo) 2264 if (!afinfo)
1687 return; 2265 return;
1688 proc_net_remove(afinfo->name); 2266 proc_net_remove(afinfo->name);
1689 memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); 2267 memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops));
1690} 2268}
1691 2269
1692static void get_openreq4(struct sock *sk, struct request_sock *req, 2270static void get_openreq4(struct sock *sk, struct request_sock *req,
@@ -1721,8 +2299,8 @@ static void get_tcp4_sock(struct sock *sp, char *tmpbuf, int i)
1721 struct tcp_sock *tp = tcp_sk(sp); 2299 struct tcp_sock *tp = tcp_sk(sp);
1722 const struct inet_connection_sock *icsk = inet_csk(sp); 2300 const struct inet_connection_sock *icsk = inet_csk(sp);
1723 struct inet_sock *inet = inet_sk(sp); 2301 struct inet_sock *inet = inet_sk(sp);
1724 unsigned int dest = inet->daddr; 2302 __be32 dest = inet->daddr;
1725 unsigned int src = inet->rcv_saddr; 2303 __be32 src = inet->rcv_saddr;
1726 __u16 destp = ntohs(inet->dport); 2304 __u16 destp = ntohs(inet->dport);
1727 __u16 srcp = ntohs(inet->sport); 2305 __u16 srcp = ntohs(inet->sport);
1728 2306
@@ -1744,7 +2322,8 @@ static void get_tcp4_sock(struct sock *sp, char *tmpbuf, int i)
1744 "%08X %5d %8d %lu %d %p %u %u %u %u %d", 2322 "%08X %5d %8d %lu %d %p %u %u %u %u %d",
1745 i, src, srcp, dest, destp, sp->sk_state, 2323 i, src, srcp, dest, destp, sp->sk_state,
1746 tp->write_seq - tp->snd_una, 2324 tp->write_seq - tp->snd_una,
1747 (sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq), 2325 sp->sk_state == TCP_LISTEN ? sp->sk_ack_backlog :
2326 (tp->rcv_nxt - tp->copied_seq),
1748 timer_active, 2327 timer_active,
1749 jiffies_to_clock_t(timer_expires - jiffies), 2328 jiffies_to_clock_t(timer_expires - jiffies),
1750 icsk->icsk_retransmits, 2329 icsk->icsk_retransmits,
@@ -1759,7 +2338,8 @@ static void get_tcp4_sock(struct sock *sp, char *tmpbuf, int i)
1759 tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh); 2338 tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh);
1760} 2339}
1761 2340
1762static void get_timewait4_sock(struct inet_timewait_sock *tw, char *tmpbuf, int i) 2341static void get_timewait4_sock(struct inet_timewait_sock *tw,
2342 char *tmpbuf, int i)
1763{ 2343{
1764 __be32 dest, src; 2344 __be32 dest, src;
1765 __u16 destp, srcp; 2345 __u16 destp, srcp;
@@ -1872,7 +2452,8 @@ struct proto tcp_prot = {
1872 2452
1873void __init tcp_v4_init(struct net_proto_family *ops) 2453void __init tcp_v4_init(struct net_proto_family *ops)
1874{ 2454{
1875 if (inet_csk_ctl_sock_create(&tcp_socket, PF_INET, SOCK_RAW, IPPROTO_TCP) < 0) 2455 if (inet_csk_ctl_sock_create(&tcp_socket, PF_INET, SOCK_RAW,
2456 IPPROTO_TCP) < 0)
1876 panic("Failed to create the TCP control socket.\n"); 2457 panic("Failed to create the TCP control socket.\n");
1877} 2458}
1878 2459
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index af7b2c986b1f..4a3889dd1943 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -305,6 +305,28 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
305 tw->tw_ipv6only = np->ipv6only; 305 tw->tw_ipv6only = np->ipv6only;
306 } 306 }
307#endif 307#endif
308
309#ifdef CONFIG_TCP_MD5SIG
310 /*
311 * The timewait bucket does not have the key DB from the
312 * sock structure. We just make a quick copy of the
313 * md5 key being used (if indeed we are using one)
314 * so the timewait ack generating code has the key.
315 */
316 do {
317 struct tcp_md5sig_key *key;
318 memset(tcptw->tw_md5_key, 0, sizeof(tcptw->tw_md5_key));
319 tcptw->tw_md5_keylen = 0;
320 key = tp->af_specific->md5_lookup(sk, sk);
321 if (key != NULL) {
322 memcpy(&tcptw->tw_md5_key, key->key, key->keylen);
323 tcptw->tw_md5_keylen = key->keylen;
324 if (tcp_alloc_md5sig_pool() == NULL)
325 BUG();
326 }
327 } while(0);
328#endif
329
308 /* Linkage updates. */ 330 /* Linkage updates. */
309 __inet_twsk_hashdance(tw, sk, &tcp_hashinfo); 331 __inet_twsk_hashdance(tw, sk, &tcp_hashinfo);
310 332
@@ -328,14 +350,24 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
328 * socket up. We've got bigger problems than 350 * socket up. We've got bigger problems than
329 * non-graceful socket closings. 351 * non-graceful socket closings.
330 */ 352 */
331 if (net_ratelimit()) 353 LIMIT_NETDEBUG(KERN_INFO "TCP: time wait bucket table overflow\n");
332 printk(KERN_INFO "TCP: time wait bucket table overflow\n");
333 } 354 }
334 355
335 tcp_update_metrics(sk); 356 tcp_update_metrics(sk);
336 tcp_done(sk); 357 tcp_done(sk);
337} 358}
338 359
360void tcp_twsk_destructor(struct sock *sk)
361{
362#ifdef CONFIG_TCP_MD5SIG
363 struct tcp_timewait_sock *twsk = tcp_twsk(sk);
364 if (twsk->tw_md5_keylen)
365 tcp_put_md5sig_pool();
366#endif
367}
368
369EXPORT_SYMBOL_GPL(tcp_twsk_destructor);
370
339/* This is not only more efficient than what we used to do, it eliminates 371/* This is not only more efficient than what we used to do, it eliminates
340 * a lot of code duplication between IPv4/IPv6 SYN recv processing. -DaveM 372 * a lot of code duplication between IPv4/IPv6 SYN recv processing. -DaveM
341 * 373 *
@@ -434,6 +466,11 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
434 newtp->rx_opt.ts_recent_stamp = 0; 466 newtp->rx_opt.ts_recent_stamp = 0;
435 newtp->tcp_header_len = sizeof(struct tcphdr); 467 newtp->tcp_header_len = sizeof(struct tcphdr);
436 } 468 }
469#ifdef CONFIG_TCP_MD5SIG
470 newtp->md5sig_info = NULL; /*XXX*/
471 if (newtp->af_specific->md5_lookup(sk, newsk))
472 newtp->tcp_header_len += TCPOLEN_MD5SIG_ALIGNED;
473#endif
437 if (skb->len >= TCP_MIN_RCVMSS+newtp->tcp_header_len) 474 if (skb->len >= TCP_MIN_RCVMSS+newtp->tcp_header_len)
438 newicsk->icsk_ack.last_seg_size = skb->len - newtp->tcp_header_len; 475 newicsk->icsk_ack.last_seg_size = skb->len - newtp->tcp_header_len;
439 newtp->rx_opt.mss_clamp = req->mss; 476 newtp->rx_opt.mss_clamp = req->mss;
@@ -454,7 +491,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb,
454 struct request_sock **prev) 491 struct request_sock **prev)
455{ 492{
456 struct tcphdr *th = skb->h.th; 493 struct tcphdr *th = skb->h.th;
457 u32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); 494 __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK);
458 int paws_reject = 0; 495 int paws_reject = 0;
459 struct tcp_options_received tmp_opt; 496 struct tcp_options_received tmp_opt;
460 struct sock *child; 497 struct sock *child;
@@ -616,6 +653,30 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb,
616 req, NULL); 653 req, NULL);
617 if (child == NULL) 654 if (child == NULL)
618 goto listen_overflow; 655 goto listen_overflow;
656#ifdef CONFIG_TCP_MD5SIG
657 else {
658 /* Copy over the MD5 key from the original socket */
659 struct tcp_md5sig_key *key;
660 struct tcp_sock *tp = tcp_sk(sk);
661 key = tp->af_specific->md5_lookup(sk, child);
662 if (key != NULL) {
663 /*
664 * We're using one, so create a matching key on the
665 * newsk structure. If we fail to get memory then we
666 * end up not copying the key across. Shucks.
667 */
668 char *newkey = kmemdup(key->key, key->keylen,
669 GFP_ATOMIC);
670 if (newkey) {
671 if (!tcp_alloc_md5sig_pool())
672 BUG();
673 tp->af_specific->md5_add(child, child,
674 newkey,
675 key->keylen);
676 }
677 }
678 }
679#endif
619 680
620 inet_csk_reqsk_queue_unlink(sk, req, prev); 681 inet_csk_reqsk_queue_unlink(sk, req, prev);
621 inet_csk_reqsk_queue_removed(sk, req); 682 inet_csk_reqsk_queue_removed(sk, req);
@@ -632,7 +693,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb,
632 embryonic_reset: 693 embryonic_reset:
633 NET_INC_STATS_BH(LINUX_MIB_EMBRYONICRSTS); 694 NET_INC_STATS_BH(LINUX_MIB_EMBRYONICRSTS);
634 if (!(flg & TCP_FLAG_RST)) 695 if (!(flg & TCP_FLAG_RST))
635 req->rsk_ops->send_reset(skb); 696 req->rsk_ops->send_reset(sk, skb);
636 697
637 inet_csk_reqsk_queue_drop(sk, req, prev); 698 inet_csk_reqsk_queue_drop(sk, req, prev);
638 return NULL; 699 return NULL;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index ca406157724c..32c1a972fa31 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -270,7 +270,7 @@ static u16 tcp_select_window(struct sock *sk)
270} 270}
271 271
272static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp, 272static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp,
273 __u32 tstamp) 273 __u32 tstamp, __u8 **md5_hash)
274{ 274{
275 if (tp->rx_opt.tstamp_ok) { 275 if (tp->rx_opt.tstamp_ok) {
276 *ptr++ = htonl((TCPOPT_NOP << 24) | 276 *ptr++ = htonl((TCPOPT_NOP << 24) |
@@ -298,16 +298,29 @@ static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp,
298 tp->rx_opt.eff_sacks--; 298 tp->rx_opt.eff_sacks--;
299 } 299 }
300 } 300 }
301#ifdef CONFIG_TCP_MD5SIG
302 if (md5_hash) {
303 *ptr++ = htonl((TCPOPT_NOP << 24) |
304 (TCPOPT_NOP << 16) |
305 (TCPOPT_MD5SIG << 8) |
306 TCPOLEN_MD5SIG);
307 *md5_hash = (__u8 *)ptr;
308 }
309#endif
301} 310}
302 311
303/* Construct a tcp options header for a SYN or SYN_ACK packet. 312/* Construct a tcp options header for a SYN or SYN_ACK packet.
304 * If this is every changed make sure to change the definition of 313 * If this is every changed make sure to change the definition of
305 * MAX_SYN_SIZE to match the new maximum number of options that you 314 * MAX_SYN_SIZE to match the new maximum number of options that you
306 * can generate. 315 * can generate.
316 *
317 * Note - that with the RFC2385 TCP option, we make room for the
318 * 16 byte MD5 hash. This will be filled in later, so the pointer for the
319 * location to be filled is passed back up.
307 */ 320 */
308static void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack, 321static void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack,
309 int offer_wscale, int wscale, __u32 tstamp, 322 int offer_wscale, int wscale, __u32 tstamp,
310 __u32 ts_recent) 323 __u32 ts_recent, __u8 **md5_hash)
311{ 324{
312 /* We always get an MSS option. 325 /* We always get an MSS option.
313 * The option bytes which will be seen in normal data 326 * The option bytes which will be seen in normal data
@@ -346,6 +359,20 @@ static void tcp_syn_build_options(__be32 *ptr, int mss, int ts, int sack,
346 (TCPOPT_WINDOW << 16) | 359 (TCPOPT_WINDOW << 16) |
347 (TCPOLEN_WINDOW << 8) | 360 (TCPOLEN_WINDOW << 8) |
348 (wscale)); 361 (wscale));
362#ifdef CONFIG_TCP_MD5SIG
363 /*
364 * If MD5 is enabled, then we set the option, and include the size
365 * (always 18). The actual MD5 hash is added just before the
366 * packet is sent.
367 */
368 if (md5_hash) {
369 *ptr++ = htonl((TCPOPT_NOP << 24) |
370 (TCPOPT_NOP << 16) |
371 (TCPOPT_MD5SIG << 8) |
372 TCPOLEN_MD5SIG);
373 *md5_hash = (__u8 *) ptr;
374 }
375#endif
349} 376}
350 377
351/* This routine actually transmits TCP packets queued in by 378/* This routine actually transmits TCP packets queued in by
@@ -366,6 +393,10 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
366 struct tcp_sock *tp; 393 struct tcp_sock *tp;
367 struct tcp_skb_cb *tcb; 394 struct tcp_skb_cb *tcb;
368 int tcp_header_size; 395 int tcp_header_size;
396#ifdef CONFIG_TCP_MD5SIG
397 struct tcp_md5sig_key *md5;
398 __u8 *md5_hash_location;
399#endif
369 struct tcphdr *th; 400 struct tcphdr *th;
370 int sysctl_flags; 401 int sysctl_flags;
371 int err; 402 int err;
@@ -424,9 +455,18 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
424 if (tcp_packets_in_flight(tp) == 0) 455 if (tcp_packets_in_flight(tp) == 0)
425 tcp_ca_event(sk, CA_EVENT_TX_START); 456 tcp_ca_event(sk, CA_EVENT_TX_START);
426 457
458#ifdef CONFIG_TCP_MD5SIG
459 /*
460 * Are we doing MD5 on this segment? If so - make
461 * room for it.
462 */
463 md5 = tp->af_specific->md5_lookup(sk, sk);
464 if (md5)
465 tcp_header_size += TCPOLEN_MD5SIG_ALIGNED;
466#endif
467
427 th = (struct tcphdr *) skb_push(skb, tcp_header_size); 468 th = (struct tcphdr *) skb_push(skb, tcp_header_size);
428 skb->h.th = th; 469 skb->h.th = th;
429 skb_set_owner_w(skb, sk);
430 470
431 /* Build TCP header and checksum it. */ 471 /* Build TCP header and checksum it. */
432 th->source = inet->sport; 472 th->source = inet->sport;
@@ -461,13 +501,34 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
461 (sysctl_flags & SYSCTL_FLAG_WSCALE), 501 (sysctl_flags & SYSCTL_FLAG_WSCALE),
462 tp->rx_opt.rcv_wscale, 502 tp->rx_opt.rcv_wscale,
463 tcb->when, 503 tcb->when,
464 tp->rx_opt.ts_recent); 504 tp->rx_opt.ts_recent,
505
506#ifdef CONFIG_TCP_MD5SIG
507 md5 ? &md5_hash_location :
508#endif
509 NULL);
465 } else { 510 } else {
466 tcp_build_and_update_options((__be32 *)(th + 1), 511 tcp_build_and_update_options((__be32 *)(th + 1),
467 tp, tcb->when); 512 tp, tcb->when,
513#ifdef CONFIG_TCP_MD5SIG
514 md5 ? &md5_hash_location :
515#endif
516 NULL);
468 TCP_ECN_send(sk, tp, skb, tcp_header_size); 517 TCP_ECN_send(sk, tp, skb, tcp_header_size);
469 } 518 }
470 519
520#ifdef CONFIG_TCP_MD5SIG
521 /* Calculate the MD5 hash, as we have all we need now */
522 if (md5) {
523 tp->af_specific->calc_md5_hash(md5_hash_location,
524 md5,
525 sk, NULL, NULL,
526 skb->h.th,
527 sk->sk_protocol,
528 skb->len);
529 }
530#endif
531
471 icsk->icsk_af_ops->send_check(sk, skb->len, skb); 532 icsk->icsk_af_ops->send_check(sk, skb->len, skb);
472 533
473 if (likely(tcb->flags & TCPCB_FLAG_ACK)) 534 if (likely(tcb->flags & TCPCB_FLAG_ACK))
@@ -479,19 +540,13 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
479 if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq) 540 if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq)
480 TCP_INC_STATS(TCP_MIB_OUTSEGS); 541 TCP_INC_STATS(TCP_MIB_OUTSEGS);
481 542
482 err = icsk->icsk_af_ops->queue_xmit(skb, 0); 543 err = icsk->icsk_af_ops->queue_xmit(skb, sk, 0);
483 if (likely(err <= 0)) 544 if (likely(err <= 0))
484 return err; 545 return err;
485 546
486 tcp_enter_cwr(sk); 547 tcp_enter_cwr(sk);
487 548
488 /* NET_XMIT_CN is special. It does not guarantee, 549 return net_xmit_eval(err);
489 * that this packet is lost. It tells that device
490 * is about to start to drop packets or already
491 * drops some packets of the same priority and
492 * invokes us to send less aggressively.
493 */
494 return err == NET_XMIT_CN ? 0 : err;
495 550
496#undef SYSCTL_FLAG_TSTAMPS 551#undef SYSCTL_FLAG_TSTAMPS
497#undef SYSCTL_FLAG_WSCALE 552#undef SYSCTL_FLAG_WSCALE
@@ -847,6 +902,11 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed)
847 mss_now -= (TCPOLEN_SACK_BASE_ALIGNED + 902 mss_now -= (TCPOLEN_SACK_BASE_ALIGNED +
848 (tp->rx_opt.eff_sacks * TCPOLEN_SACK_PERBLOCK)); 903 (tp->rx_opt.eff_sacks * TCPOLEN_SACK_PERBLOCK));
849 904
905#ifdef CONFIG_TCP_MD5SIG
906 if (tp->af_specific->md5_lookup(sk, sk))
907 mss_now -= TCPOLEN_MD5SIG_ALIGNED;
908#endif
909
850 xmit_size_goal = mss_now; 910 xmit_size_goal = mss_now;
851 911
852 if (doing_tso) { 912 if (doing_tso) {
@@ -2040,6 +2100,10 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2040 struct tcphdr *th; 2100 struct tcphdr *th;
2041 int tcp_header_size; 2101 int tcp_header_size;
2042 struct sk_buff *skb; 2102 struct sk_buff *skb;
2103#ifdef CONFIG_TCP_MD5SIG
2104 struct tcp_md5sig_key *md5;
2105 __u8 *md5_hash_location;
2106#endif
2043 2107
2044 skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC); 2108 skb = sock_wmalloc(sk, MAX_TCP_HEADER + 15, 1, GFP_ATOMIC);
2045 if (skb == NULL) 2109 if (skb == NULL)
@@ -2055,6 +2119,13 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2055 (ireq->wscale_ok ? TCPOLEN_WSCALE_ALIGNED : 0) + 2119 (ireq->wscale_ok ? TCPOLEN_WSCALE_ALIGNED : 0) +
2056 /* SACK_PERM is in the place of NOP NOP of TS */ 2120 /* SACK_PERM is in the place of NOP NOP of TS */
2057 ((ireq->sack_ok && !ireq->tstamp_ok) ? TCPOLEN_SACKPERM_ALIGNED : 0)); 2121 ((ireq->sack_ok && !ireq->tstamp_ok) ? TCPOLEN_SACKPERM_ALIGNED : 0));
2122
2123#ifdef CONFIG_TCP_MD5SIG
2124 /* Are we doing MD5 on this segment? If so - make room for it */
2125 md5 = tcp_rsk(req)->af_specific->md5_lookup(sk, req);
2126 if (md5)
2127 tcp_header_size += TCPOLEN_MD5SIG_ALIGNED;
2128#endif
2058 skb->h.th = th = (struct tcphdr *) skb_push(skb, tcp_header_size); 2129 skb->h.th = th = (struct tcphdr *) skb_push(skb, tcp_header_size);
2059 2130
2060 memset(th, 0, sizeof(struct tcphdr)); 2131 memset(th, 0, sizeof(struct tcphdr));
@@ -2092,11 +2163,29 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
2092 tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok, 2163 tcp_syn_build_options((__be32 *)(th + 1), dst_metric(dst, RTAX_ADVMSS), ireq->tstamp_ok,
2093 ireq->sack_ok, ireq->wscale_ok, ireq->rcv_wscale, 2164 ireq->sack_ok, ireq->wscale_ok, ireq->rcv_wscale,
2094 TCP_SKB_CB(skb)->when, 2165 TCP_SKB_CB(skb)->when,
2095 req->ts_recent); 2166 req->ts_recent,
2167 (
2168#ifdef CONFIG_TCP_MD5SIG
2169 md5 ? &md5_hash_location :
2170#endif
2171 NULL)
2172 );
2096 2173
2097 skb->csum = 0; 2174 skb->csum = 0;
2098 th->doff = (tcp_header_size >> 2); 2175 th->doff = (tcp_header_size >> 2);
2099 TCP_INC_STATS(TCP_MIB_OUTSEGS); 2176 TCP_INC_STATS(TCP_MIB_OUTSEGS);
2177
2178#ifdef CONFIG_TCP_MD5SIG
2179 /* Okay, we have all we need - do the md5 hash if needed */
2180 if (md5) {
2181 tp->af_specific->calc_md5_hash(md5_hash_location,
2182 md5,
2183 NULL, dst, req,
2184 skb->h.th, sk->sk_protocol,
2185 skb->len);
2186 }
2187#endif
2188
2100 return skb; 2189 return skb;
2101} 2190}
2102 2191
@@ -2115,6 +2204,11 @@ static void tcp_connect_init(struct sock *sk)
2115 tp->tcp_header_len = sizeof(struct tcphdr) + 2204 tp->tcp_header_len = sizeof(struct tcphdr) +
2116 (sysctl_tcp_timestamps ? TCPOLEN_TSTAMP_ALIGNED : 0); 2205 (sysctl_tcp_timestamps ? TCPOLEN_TSTAMP_ALIGNED : 0);
2117 2206
2207#ifdef CONFIG_TCP_MD5SIG
2208 if (tp->af_specific->md5_lookup(sk, sk) != NULL)
2209 tp->tcp_header_len += TCPOLEN_MD5SIG_ALIGNED;
2210#endif
2211
2118 /* If user gave his TCP_MAXSEG, record it to clamp */ 2212 /* If user gave his TCP_MAXSEG, record it to clamp */
2119 if (tp->rx_opt.user_mss) 2213 if (tp->rx_opt.user_mss)
2120 tp->rx_opt.mss_clamp = tp->rx_opt.user_mss; 2214 tp->rx_opt.mss_clamp = tp->rx_opt.user_mss;
diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
index 4be336f17883..f230eeecf092 100644
--- a/net/ipv4/tcp_probe.c
+++ b/net/ipv4/tcp_probe.c
@@ -156,6 +156,8 @@ static __init int tcpprobe_init(void)
156 init_waitqueue_head(&tcpw.wait); 156 init_waitqueue_head(&tcpw.wait);
157 spin_lock_init(&tcpw.lock); 157 spin_lock_init(&tcpw.lock);
158 tcpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &tcpw.lock); 158 tcpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &tcpw.lock);
159 if (IS_ERR(tcpw.fifo))
160 return PTR_ERR(tcpw.fifo);
159 161
160 if (!proc_net_fops_create(procname, S_IRUSR, &tcpprobe_fops)) 162 if (!proc_net_fops_create(procname, S_IRUSR, &tcpprobe_fops))
161 goto err0; 163 goto err0;
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index fb09ade5897b..3355c276b611 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -297,7 +297,7 @@ static void tcp_retransmit_timer(struct sock *sk)
297 if (net_ratelimit()) { 297 if (net_ratelimit()) {
298 struct inet_sock *inet = inet_sk(sk); 298 struct inet_sock *inet = inet_sk(sk);
299 printk(KERN_DEBUG "TCP: Treason uncloaked! Peer %u.%u.%u.%u:%u/%u shrinks window %u:%u. Repaired.\n", 299 printk(KERN_DEBUG "TCP: Treason uncloaked! Peer %u.%u.%u.%u:%u/%u shrinks window %u:%u. Repaired.\n",
300 NIPQUAD(inet->daddr), htons(inet->dport), 300 NIPQUAD(inet->daddr), ntohs(inet->dport),
301 inet->num, tp->snd_una, tp->snd_nxt); 301 inet->num, tp->snd_una, tp->snd_nxt);
302 } 302 }
303#endif 303#endif
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index a3b7aa015a2f..ddc4bcc5785e 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -42,8 +42,8 @@
42 * with V_PARAM_SHIFT bits to the right of the binary point. 42 * with V_PARAM_SHIFT bits to the right of the binary point.
43 */ 43 */
44#define V_PARAM_SHIFT 1 44#define V_PARAM_SHIFT 1
45static int alpha = 1<<V_PARAM_SHIFT; 45static int alpha = 2<<V_PARAM_SHIFT;
46static int beta = 3<<V_PARAM_SHIFT; 46static int beta = 4<<V_PARAM_SHIFT;
47static int gamma = 1<<V_PARAM_SHIFT; 47static int gamma = 1<<V_PARAM_SHIFT;
48 48
49module_param(alpha, int, 0644); 49module_param(alpha, int, 0644);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 865d75214a9a..035915fc9ed3 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -92,22 +92,16 @@
92#include <linux/timer.h> 92#include <linux/timer.h>
93#include <linux/mm.h> 93#include <linux/mm.h>
94#include <linux/inet.h> 94#include <linux/inet.h>
95#include <linux/ipv6.h>
96#include <linux/netdevice.h> 95#include <linux/netdevice.h>
97#include <net/snmp.h>
98#include <net/ip.h>
99#include <net/tcp_states.h> 96#include <net/tcp_states.h>
100#include <net/protocol.h>
101#include <linux/skbuff.h> 97#include <linux/skbuff.h>
102#include <linux/proc_fs.h> 98#include <linux/proc_fs.h>
103#include <linux/seq_file.h> 99#include <linux/seq_file.h>
104#include <net/sock.h>
105#include <net/udp.h>
106#include <net/icmp.h> 100#include <net/icmp.h>
107#include <net/route.h> 101#include <net/route.h>
108#include <net/inet_common.h>
109#include <net/checksum.h> 102#include <net/checksum.h>
110#include <net/xfrm.h> 103#include <net/xfrm.h>
104#include "udp_impl.h"
111 105
112/* 106/*
113 * Snmp MIB for the UDP layer 107 * Snmp MIB for the UDP layer
@@ -120,26 +114,30 @@ DEFINE_RWLOCK(udp_hash_lock);
120 114
121static int udp_port_rover; 115static int udp_port_rover;
122 116
123static inline int udp_lport_inuse(u16 num) 117static inline int __udp_lib_lport_inuse(__u16 num, struct hlist_head udptable[])
124{ 118{
125 struct sock *sk; 119 struct sock *sk;
126 struct hlist_node *node; 120 struct hlist_node *node;
127 121
128 sk_for_each(sk, node, &udp_hash[num & (UDP_HTABLE_SIZE - 1)]) 122 sk_for_each(sk, node, &udptable[num & (UDP_HTABLE_SIZE - 1)])
129 if (inet_sk(sk)->num == num) 123 if (inet_sk(sk)->num == num)
130 return 1; 124 return 1;
131 return 0; 125 return 0;
132} 126}
133 127
134/** 128/**
135 * udp_get_port - common port lookup for IPv4 and IPv6 129 * __udp_lib_get_port - UDP/-Lite port lookup for IPv4 and IPv6
136 * 130 *
137 * @sk: socket struct in question 131 * @sk: socket struct in question
138 * @snum: port number to look up 132 * @snum: port number to look up
133 * @udptable: hash list table, must be of UDP_HTABLE_SIZE
134 * @port_rover: pointer to record of last unallocated port
139 * @saddr_comp: AF-dependent comparison of bound local IP addresses 135 * @saddr_comp: AF-dependent comparison of bound local IP addresses
140 */ 136 */
141int udp_get_port(struct sock *sk, unsigned short snum, 137int __udp_lib_get_port(struct sock *sk, unsigned short snum,
142 int (*saddr_cmp)(const struct sock *sk1, const struct sock *sk2)) 138 struct hlist_head udptable[], int *port_rover,
139 int (*saddr_comp)(const struct sock *sk1,
140 const struct sock *sk2 ) )
143{ 141{
144 struct hlist_node *node; 142 struct hlist_node *node;
145 struct hlist_head *head; 143 struct hlist_head *head;
@@ -150,15 +148,15 @@ int udp_get_port(struct sock *sk, unsigned short snum,
150 if (snum == 0) { 148 if (snum == 0) {
151 int best_size_so_far, best, result, i; 149 int best_size_so_far, best, result, i;
152 150
153 if (udp_port_rover > sysctl_local_port_range[1] || 151 if (*port_rover > sysctl_local_port_range[1] ||
154 udp_port_rover < sysctl_local_port_range[0]) 152 *port_rover < sysctl_local_port_range[0])
155 udp_port_rover = sysctl_local_port_range[0]; 153 *port_rover = sysctl_local_port_range[0];
156 best_size_so_far = 32767; 154 best_size_so_far = 32767;
157 best = result = udp_port_rover; 155 best = result = *port_rover;
158 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) { 156 for (i = 0; i < UDP_HTABLE_SIZE; i++, result++) {
159 int size; 157 int size;
160 158
161 head = &udp_hash[result & (UDP_HTABLE_SIZE - 1)]; 159 head = &udptable[result & (UDP_HTABLE_SIZE - 1)];
162 if (hlist_empty(head)) { 160 if (hlist_empty(head)) {
163 if (result > sysctl_local_port_range[1]) 161 if (result > sysctl_local_port_range[1])
164 result = sysctl_local_port_range[0] + 162 result = sysctl_local_port_range[0] +
@@ -179,15 +177,15 @@ int udp_get_port(struct sock *sk, unsigned short snum,
179 result = sysctl_local_port_range[0] 177 result = sysctl_local_port_range[0]
180 + ((result - sysctl_local_port_range[0]) & 178 + ((result - sysctl_local_port_range[0]) &
181 (UDP_HTABLE_SIZE - 1)); 179 (UDP_HTABLE_SIZE - 1));
182 if (!udp_lport_inuse(result)) 180 if (! __udp_lib_lport_inuse(result, udptable))
183 break; 181 break;
184 } 182 }
185 if (i >= (1 << 16) / UDP_HTABLE_SIZE) 183 if (i >= (1 << 16) / UDP_HTABLE_SIZE)
186 goto fail; 184 goto fail;
187gotit: 185gotit:
188 udp_port_rover = snum = result; 186 *port_rover = snum = result;
189 } else { 187 } else {
190 head = &udp_hash[snum & (UDP_HTABLE_SIZE - 1)]; 188 head = &udptable[snum & (UDP_HTABLE_SIZE - 1)];
191 189
192 sk_for_each(sk2, node, head) 190 sk_for_each(sk2, node, head)
193 if (inet_sk(sk2)->num == snum && 191 if (inet_sk(sk2)->num == snum &&
@@ -195,12 +193,12 @@ gotit:
195 (!sk2->sk_reuse || !sk->sk_reuse) && 193 (!sk2->sk_reuse || !sk->sk_reuse) &&
196 (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if 194 (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if
197 || sk2->sk_bound_dev_if == sk->sk_bound_dev_if) && 195 || sk2->sk_bound_dev_if == sk->sk_bound_dev_if) &&
198 (*saddr_cmp)(sk, sk2) ) 196 (*saddr_comp)(sk, sk2) )
199 goto fail; 197 goto fail;
200 } 198 }
201 inet_sk(sk)->num = snum; 199 inet_sk(sk)->num = snum;
202 if (sk_unhashed(sk)) { 200 if (sk_unhashed(sk)) {
203 head = &udp_hash[snum & (UDP_HTABLE_SIZE - 1)]; 201 head = &udptable[snum & (UDP_HTABLE_SIZE - 1)];
204 sk_add_node(sk, head); 202 sk_add_node(sk, head);
205 sock_prot_inc_use(sk->sk_prot); 203 sock_prot_inc_use(sk->sk_prot);
206 } 204 }
@@ -210,7 +208,13 @@ fail:
210 return error; 208 return error;
211} 209}
212 210
213static inline int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2) 211__inline__ int udp_get_port(struct sock *sk, unsigned short snum,
212 int (*scmp)(const struct sock *, const struct sock *))
213{
214 return __udp_lib_get_port(sk, snum, udp_hash, &udp_port_rover, scmp);
215}
216
217inline int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
214{ 218{
215 struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2); 219 struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
216 220
@@ -224,34 +228,20 @@ static inline int udp_v4_get_port(struct sock *sk, unsigned short snum)
224 return udp_get_port(sk, snum, ipv4_rcv_saddr_equal); 228 return udp_get_port(sk, snum, ipv4_rcv_saddr_equal);
225} 229}
226 230
227
228static void udp_v4_hash(struct sock *sk)
229{
230 BUG();
231}
232
233static void udp_v4_unhash(struct sock *sk)
234{
235 write_lock_bh(&udp_hash_lock);
236 if (sk_del_node_init(sk)) {
237 inet_sk(sk)->num = 0;
238 sock_prot_dec_use(sk->sk_prot);
239 }
240 write_unlock_bh(&udp_hash_lock);
241}
242
243/* UDP is nearly always wildcards out the wazoo, it makes no sense to try 231/* UDP is nearly always wildcards out the wazoo, it makes no sense to try
244 * harder than this. -DaveM 232 * harder than this. -DaveM
245 */ 233 */
246static struct sock *udp_v4_lookup_longway(__be32 saddr, __be16 sport, 234static struct sock *__udp4_lib_lookup(__be32 saddr, __be16 sport,
247 __be32 daddr, __be16 dport, int dif) 235 __be32 daddr, __be16 dport,
236 int dif, struct hlist_head udptable[])
248{ 237{
249 struct sock *sk, *result = NULL; 238 struct sock *sk, *result = NULL;
250 struct hlist_node *node; 239 struct hlist_node *node;
251 unsigned short hnum = ntohs(dport); 240 unsigned short hnum = ntohs(dport);
252 int badness = -1; 241 int badness = -1;
253 242
254 sk_for_each(sk, node, &udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]) { 243 read_lock(&udp_hash_lock);
244 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
255 struct inet_sock *inet = inet_sk(sk); 245 struct inet_sock *inet = inet_sk(sk);
256 246
257 if (inet->num == hnum && !ipv6_only_sock(sk)) { 247 if (inet->num == hnum && !ipv6_only_sock(sk)) {
@@ -285,20 +275,10 @@ static struct sock *udp_v4_lookup_longway(__be32 saddr, __be16 sport,
285 } 275 }
286 } 276 }
287 } 277 }
288 return result; 278 if (result)
289} 279 sock_hold(result);
290
291static __inline__ struct sock *udp_v4_lookup(__be32 saddr, __be16 sport,
292 __be32 daddr, __be16 dport, int dif)
293{
294 struct sock *sk;
295
296 read_lock(&udp_hash_lock);
297 sk = udp_v4_lookup_longway(saddr, sport, daddr, dport, dif);
298 if (sk)
299 sock_hold(sk);
300 read_unlock(&udp_hash_lock); 280 read_unlock(&udp_hash_lock);
301 return sk; 281 return result;
302} 282}
303 283
304static inline struct sock *udp_v4_mcast_next(struct sock *sk, 284static inline struct sock *udp_v4_mcast_next(struct sock *sk,
@@ -340,7 +320,7 @@ found:
340 * to find the appropriate port. 320 * to find the appropriate port.
341 */ 321 */
342 322
343void udp_err(struct sk_buff *skb, u32 info) 323void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[])
344{ 324{
345 struct inet_sock *inet; 325 struct inet_sock *inet;
346 struct iphdr *iph = (struct iphdr*)skb->data; 326 struct iphdr *iph = (struct iphdr*)skb->data;
@@ -351,7 +331,8 @@ void udp_err(struct sk_buff *skb, u32 info)
351 int harderr; 331 int harderr;
352 int err; 332 int err;
353 333
354 sk = udp_v4_lookup(iph->daddr, uh->dest, iph->saddr, uh->source, skb->dev->ifindex); 334 sk = __udp4_lib_lookup(iph->daddr, uh->dest, iph->saddr, uh->source,
335 skb->dev->ifindex, udptable );
355 if (sk == NULL) { 336 if (sk == NULL) {
356 ICMP_INC_STATS_BH(ICMP_MIB_INERRORS); 337 ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
357 return; /* No socket for error */ 338 return; /* No socket for error */
@@ -405,6 +386,11 @@ out:
405 sock_put(sk); 386 sock_put(sk);
406} 387}
407 388
389__inline__ void udp_err(struct sk_buff *skb, u32 info)
390{
391 return __udp4_lib_err(skb, info, udp_hash);
392}
393
408/* 394/*
409 * Throw away all pending data and cancel the corking. Socket is locked. 395 * Throw away all pending data and cancel the corking. Socket is locked.
410 */ 396 */
@@ -419,16 +405,58 @@ static void udp_flush_pending_frames(struct sock *sk)
419 } 405 }
420} 406}
421 407
408/**
409 * udp4_hwcsum_outgoing - handle outgoing HW checksumming
410 * @sk: socket we are sending on
411 * @skb: sk_buff containing the filled-in UDP header
412 * (checksum field must be zeroed out)
413 */
414static void udp4_hwcsum_outgoing(struct sock *sk, struct sk_buff *skb,
415 __be32 src, __be32 dst, int len )
416{
417 unsigned int offset;
418 struct udphdr *uh = skb->h.uh;
419 __wsum csum = 0;
420
421 if (skb_queue_len(&sk->sk_write_queue) == 1) {
422 /*
423 * Only one fragment on the socket.
424 */
425 skb->csum_offset = offsetof(struct udphdr, check);
426 uh->check = ~csum_tcpudp_magic(src, dst, len, IPPROTO_UDP, 0);
427 } else {
428 /*
429 * HW-checksum won't work as there are two or more
430 * fragments on the socket so that all csums of sk_buffs
431 * should be together
432 */
433 offset = skb->h.raw - skb->data;
434 skb->csum = skb_checksum(skb, offset, skb->len - offset, 0);
435
436 skb->ip_summed = CHECKSUM_NONE;
437
438 skb_queue_walk(&sk->sk_write_queue, skb) {
439 csum = csum_add(csum, skb->csum);
440 }
441
442 uh->check = csum_tcpudp_magic(src, dst, len, IPPROTO_UDP, csum);
443 if (uh->check == 0)
444 uh->check = CSUM_MANGLED_0;
445 }
446}
447
422/* 448/*
423 * Push out all pending data as one UDP datagram. Socket is locked. 449 * Push out all pending data as one UDP datagram. Socket is locked.
424 */ 450 */
425static int udp_push_pending_frames(struct sock *sk, struct udp_sock *up) 451static int udp_push_pending_frames(struct sock *sk)
426{ 452{
453 struct udp_sock *up = udp_sk(sk);
427 struct inet_sock *inet = inet_sk(sk); 454 struct inet_sock *inet = inet_sk(sk);
428 struct flowi *fl = &inet->cork.fl; 455 struct flowi *fl = &inet->cork.fl;
429 struct sk_buff *skb; 456 struct sk_buff *skb;
430 struct udphdr *uh; 457 struct udphdr *uh;
431 int err = 0; 458 int err = 0;
459 __wsum csum = 0;
432 460
433 /* Grab the skbuff where UDP header space exists. */ 461 /* Grab the skbuff where UDP header space exists. */
434 if ((skb = skb_peek(&sk->sk_write_queue)) == NULL) 462 if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
@@ -443,52 +471,28 @@ static int udp_push_pending_frames(struct sock *sk, struct udp_sock *up)
443 uh->len = htons(up->len); 471 uh->len = htons(up->len);
444 uh->check = 0; 472 uh->check = 0;
445 473
446 if (sk->sk_no_check == UDP_CSUM_NOXMIT) { 474 if (up->pcflag) /* UDP-Lite */
475 csum = udplite_csum_outgoing(sk, skb);
476
477 else if (sk->sk_no_check == UDP_CSUM_NOXMIT) { /* UDP csum disabled */
478
447 skb->ip_summed = CHECKSUM_NONE; 479 skb->ip_summed = CHECKSUM_NONE;
448 goto send; 480 goto send;
449 }
450 481
451 if (skb_queue_len(&sk->sk_write_queue) == 1) { 482 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { /* UDP hardware csum */
452 /*
453 * Only one fragment on the socket.
454 */
455 if (skb->ip_summed == CHECKSUM_PARTIAL) {
456 skb->csum = offsetof(struct udphdr, check);
457 uh->check = ~csum_tcpudp_magic(fl->fl4_src, fl->fl4_dst,
458 up->len, IPPROTO_UDP, 0);
459 } else {
460 skb->csum = csum_partial((char *)uh,
461 sizeof(struct udphdr), skb->csum);
462 uh->check = csum_tcpudp_magic(fl->fl4_src, fl->fl4_dst,
463 up->len, IPPROTO_UDP, skb->csum);
464 if (uh->check == 0)
465 uh->check = -1;
466 }
467 } else {
468 unsigned int csum = 0;
469 /*
470 * HW-checksum won't work as there are two or more
471 * fragments on the socket so that all csums of sk_buffs
472 * should be together.
473 */
474 if (skb->ip_summed == CHECKSUM_PARTIAL) {
475 int offset = (unsigned char *)uh - skb->data;
476 skb->csum = skb_checksum(skb, offset, skb->len - offset, 0);
477 483
478 skb->ip_summed = CHECKSUM_NONE; 484 udp4_hwcsum_outgoing(sk, skb, fl->fl4_src,fl->fl4_dst, up->len);
479 } else { 485 goto send;
480 skb->csum = csum_partial((char *)uh, 486
481 sizeof(struct udphdr), skb->csum); 487 } else /* `normal' UDP */
482 } 488 csum = udp_csum_outgoing(sk, skb);
489
490 /* add protocol-dependent pseudo-header */
491 uh->check = csum_tcpudp_magic(fl->fl4_src, fl->fl4_dst, up->len,
492 sk->sk_protocol, csum );
493 if (uh->check == 0)
494 uh->check = CSUM_MANGLED_0;
483 495
484 skb_queue_walk(&sk->sk_write_queue, skb) {
485 csum = csum_add(csum, skb->csum);
486 }
487 uh->check = csum_tcpudp_magic(fl->fl4_src, fl->fl4_dst,
488 up->len, IPPROTO_UDP, csum);
489 if (uh->check == 0)
490 uh->check = -1;
491 }
492send: 496send:
493 err = ip_push_pending_frames(sk); 497 err = ip_push_pending_frames(sk);
494out: 498out:
@@ -497,12 +501,6 @@ out:
497 return err; 501 return err;
498} 502}
499 503
500
501static unsigned short udp_check(struct udphdr *uh, int len, __be32 saddr, __be32 daddr, unsigned long base)
502{
503 return(csum_tcpudp_magic(saddr, daddr, len, IPPROTO_UDP, base));
504}
505
506int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 504int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
507 size_t len) 505 size_t len)
508{ 506{
@@ -516,8 +514,9 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
516 __be32 daddr, faddr, saddr; 514 __be32 daddr, faddr, saddr;
517 __be16 dport; 515 __be16 dport;
518 u8 tos; 516 u8 tos;
519 int err; 517 int err, is_udplite = up->pcflag;
520 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 518 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
519 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
521 520
522 if (len > 0xFFFF) 521 if (len > 0xFFFF)
523 return -EMSGSIZE; 522 return -EMSGSIZE;
@@ -622,7 +621,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
622 { .daddr = faddr, 621 { .daddr = faddr,
623 .saddr = saddr, 622 .saddr = saddr,
624 .tos = tos } }, 623 .tos = tos } },
625 .proto = IPPROTO_UDP, 624 .proto = sk->sk_protocol,
626 .uli_u = { .ports = 625 .uli_u = { .ports =
627 { .sport = inet->sport, 626 { .sport = inet->sport,
628 .dport = dport } } }; 627 .dport = dport } } };
@@ -668,13 +667,14 @@ back_from_confirm:
668 667
669do_append_data: 668do_append_data:
670 up->len += ulen; 669 up->len += ulen;
671 err = ip_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, 670 getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
672 sizeof(struct udphdr), &ipc, rt, 671 err = ip_append_data(sk, getfrag, msg->msg_iov, ulen,
672 sizeof(struct udphdr), &ipc, rt,
673 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); 673 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags);
674 if (err) 674 if (err)
675 udp_flush_pending_frames(sk); 675 udp_flush_pending_frames(sk);
676 else if (!corkreq) 676 else if (!corkreq)
677 err = udp_push_pending_frames(sk, up); 677 err = udp_push_pending_frames(sk);
678 else if (unlikely(skb_queue_empty(&sk->sk_write_queue))) 678 else if (unlikely(skb_queue_empty(&sk->sk_write_queue)))
679 up->pending = 0; 679 up->pending = 0;
680 release_sock(sk); 680 release_sock(sk);
@@ -684,7 +684,7 @@ out:
684 if (free) 684 if (free)
685 kfree(ipc.opt); 685 kfree(ipc.opt);
686 if (!err) { 686 if (!err) {
687 UDP_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS); 687 UDP_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS, is_udplite);
688 return len; 688 return len;
689 } 689 }
690 /* 690 /*
@@ -695,7 +695,7 @@ out:
695 * seems like overkill. 695 * seems like overkill.
696 */ 696 */
697 if (err == -ENOBUFS || test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { 697 if (err == -ENOBUFS || test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
698 UDP_INC_STATS_USER(UDP_MIB_SNDBUFERRORS); 698 UDP_INC_STATS_USER(UDP_MIB_SNDBUFERRORS, is_udplite);
699 } 699 }
700 return err; 700 return err;
701 701
@@ -707,8 +707,8 @@ do_confirm:
707 goto out; 707 goto out;
708} 708}
709 709
710static int udp_sendpage(struct sock *sk, struct page *page, int offset, 710int udp_sendpage(struct sock *sk, struct page *page, int offset,
711 size_t size, int flags) 711 size_t size, int flags)
712{ 712{
713 struct udp_sock *up = udp_sk(sk); 713 struct udp_sock *up = udp_sk(sk);
714 int ret; 714 int ret;
@@ -747,7 +747,7 @@ static int udp_sendpage(struct sock *sk, struct page *page, int offset,
747 747
748 up->len += size; 748 up->len += size;
749 if (!(up->corkflag || (flags&MSG_MORE))) 749 if (!(up->corkflag || (flags&MSG_MORE)))
750 ret = udp_push_pending_frames(sk, up); 750 ret = udp_push_pending_frames(sk);
751 if (!ret) 751 if (!ret)
752 ret = size; 752 ret = size;
753out: 753out:
@@ -795,29 +795,18 @@ int udp_ioctl(struct sock *sk, int cmd, unsigned long arg)
795 return(0); 795 return(0);
796} 796}
797 797
798static __inline__ int __udp_checksum_complete(struct sk_buff *skb)
799{
800 return __skb_checksum_complete(skb);
801}
802
803static __inline__ int udp_checksum_complete(struct sk_buff *skb)
804{
805 return skb->ip_summed != CHECKSUM_UNNECESSARY &&
806 __udp_checksum_complete(skb);
807}
808
809/* 798/*
810 * This should be easy, if there is something there we 799 * This should be easy, if there is something there we
811 * return it, otherwise we block. 800 * return it, otherwise we block.
812 */ 801 */
813 802
814static int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 803int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
815 size_t len, int noblock, int flags, int *addr_len) 804 size_t len, int noblock, int flags, int *addr_len)
816{ 805{
817 struct inet_sock *inet = inet_sk(sk); 806 struct inet_sock *inet = inet_sk(sk);
818 struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name; 807 struct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;
819 struct sk_buff *skb; 808 struct sk_buff *skb;
820 int copied, err; 809 int copied, err, copy_only, is_udplite = IS_UDPLITE(sk);
821 810
822 /* 811 /*
823 * Check any passed addresses 812 * Check any passed addresses
@@ -839,15 +828,25 @@ try_again:
839 msg->msg_flags |= MSG_TRUNC; 828 msg->msg_flags |= MSG_TRUNC;
840 } 829 }
841 830
842 if (skb->ip_summed==CHECKSUM_UNNECESSARY) { 831 /*
843 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov, 832 * Decide whether to checksum and/or copy data.
844 copied); 833 *
845 } else if (msg->msg_flags&MSG_TRUNC) { 834 * UDP: checksum may have been computed in HW,
846 if (__udp_checksum_complete(skb)) 835 * (re-)compute it if message is truncated.
836 * UDP-Lite: always needs to checksum, no HW support.
837 */
838 copy_only = (skb->ip_summed==CHECKSUM_UNNECESSARY);
839
840 if (is_udplite || (!copy_only && msg->msg_flags&MSG_TRUNC)) {
841 if (__udp_lib_checksum_complete(skb))
847 goto csum_copy_err; 842 goto csum_copy_err;
848 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov, 843 copy_only = 1;
849 copied); 844 }
850 } else { 845
846 if (copy_only)
847 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
848 msg->msg_iov, copied );
849 else {
851 err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov); 850 err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);
852 851
853 if (err == -EINVAL) 852 if (err == -EINVAL)
@@ -880,7 +879,7 @@ out:
880 return err; 879 return err;
881 880
882csum_copy_err: 881csum_copy_err:
883 UDP_INC_STATS_BH(UDP_MIB_INERRORS); 882 UDP_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
884 883
885 skb_kill_datagram(sk, skb, flags); 884 skb_kill_datagram(sk, skb, flags);
886 885
@@ -912,11 +911,6 @@ int udp_disconnect(struct sock *sk, int flags)
912 return 0; 911 return 0;
913} 912}
914 913
915static void udp_close(struct sock *sk, long timeout)
916{
917 sk_common_release(sk);
918}
919
920/* return: 914/* return:
921 * 1 if the the UDP system should process it 915 * 1 if the the UDP system should process it
922 * 0 if we should drop this packet 916 * 0 if we should drop this packet
@@ -928,23 +922,32 @@ static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
928 return 1; 922 return 1;
929#else 923#else
930 struct udp_sock *up = udp_sk(sk); 924 struct udp_sock *up = udp_sk(sk);
931 struct udphdr *uh = skb->h.uh; 925 struct udphdr *uh;
932 struct iphdr *iph; 926 struct iphdr *iph;
933 int iphlen, len; 927 int iphlen, len;
934 928
935 __u8 *udpdata = (__u8 *)uh + sizeof(struct udphdr); 929 __u8 *udpdata;
936 __be32 *udpdata32 = (__be32 *)udpdata; 930 __be32 *udpdata32;
937 __u16 encap_type = up->encap_type; 931 __u16 encap_type = up->encap_type;
938 932
939 /* if we're overly short, let UDP handle it */ 933 /* if we're overly short, let UDP handle it */
940 if (udpdata > skb->tail) 934 len = skb->len - sizeof(struct udphdr);
935 if (len <= 0)
941 return 1; 936 return 1;
942 937
943 /* if this is not encapsulated socket, then just return now */ 938 /* if this is not encapsulated socket, then just return now */
944 if (!encap_type) 939 if (!encap_type)
945 return 1; 940 return 1;
946 941
947 len = skb->tail - udpdata; 942 /* If this is a paged skb, make sure we pull up
943 * whatever data we need to look at. */
944 if (!pskb_may_pull(skb, sizeof(struct udphdr) + min(len, 8)))
945 return 1;
946
947 /* Now we can get the pointers */
948 uh = skb->h.uh;
949 udpdata = (__u8 *)uh + sizeof(struct udphdr);
950 udpdata32 = (__be32 *)udpdata;
948 951
949 switch (encap_type) { 952 switch (encap_type) {
950 default: 953 default:
@@ -1013,7 +1016,7 @@ static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
1013 * Note that in the success and error cases, the skb is assumed to 1016 * Note that in the success and error cases, the skb is assumed to
1014 * have either been requeued or freed. 1017 * have either been requeued or freed.
1015 */ 1018 */
1016static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) 1019int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
1017{ 1020{
1018 struct udp_sock *up = udp_sk(sk); 1021 struct udp_sock *up = udp_sk(sk);
1019 int rc; 1022 int rc;
@@ -1021,10 +1024,8 @@ static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
1021 /* 1024 /*
1022 * Charge it to the socket, dropping if the queue is full. 1025 * Charge it to the socket, dropping if the queue is full.
1023 */ 1026 */
1024 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) { 1027 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
1025 kfree_skb(skb); 1028 goto drop;
1026 return -1;
1027 }
1028 nf_reset(skb); 1029 nf_reset(skb);
1029 1030
1030 if (up->encap_type) { 1031 if (up->encap_type) {
@@ -1048,31 +1049,68 @@ static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
1048 if (ret < 0) { 1049 if (ret < 0) {
1049 /* process the ESP packet */ 1050 /* process the ESP packet */
1050 ret = xfrm4_rcv_encap(skb, up->encap_type); 1051 ret = xfrm4_rcv_encap(skb, up->encap_type);
1051 UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS); 1052 UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
1052 return -ret; 1053 return -ret;
1053 } 1054 }
1054 /* FALLTHROUGH -- it's a UDP Packet */ 1055 /* FALLTHROUGH -- it's a UDP Packet */
1055 } 1056 }
1056 1057
1057 if (sk->sk_filter && skb->ip_summed != CHECKSUM_UNNECESSARY) { 1058 /*
1058 if (__udp_checksum_complete(skb)) { 1059 * UDP-Lite specific tests, ignored on UDP sockets
1059 UDP_INC_STATS_BH(UDP_MIB_INERRORS); 1060 */
1060 kfree_skb(skb); 1061 if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
1061 return -1; 1062
1063 /*
1064 * MIB statistics other than incrementing the error count are
1065 * disabled for the following two types of errors: these depend
1066 * on the application settings, not on the functioning of the
1067 * protocol stack as such.
1068 *
1069 * RFC 3828 here recommends (sec 3.3): "There should also be a
1070 * way ... to ... at least let the receiving application block
1071 * delivery of packets with coverage values less than a value
1072 * provided by the application."
1073 */
1074 if (up->pcrlen == 0) { /* full coverage was set */
1075 LIMIT_NETDEBUG(KERN_WARNING "UDPLITE: partial coverage "
1076 "%d while full coverage %d requested\n",
1077 UDP_SKB_CB(skb)->cscov, skb->len);
1078 goto drop;
1062 } 1079 }
1080 /* The next case involves violating the min. coverage requested
1081 * by the receiver. This is subtle: if receiver wants x and x is
1082 * greater than the buffersize/MTU then receiver will complain
1083 * that it wants x while sender emits packets of smaller size y.
1084 * Therefore the above ...()->partial_cov statement is essential.
1085 */
1086 if (UDP_SKB_CB(skb)->cscov < up->pcrlen) {
1087 LIMIT_NETDEBUG(KERN_WARNING
1088 "UDPLITE: coverage %d too small, need min %d\n",
1089 UDP_SKB_CB(skb)->cscov, up->pcrlen);
1090 goto drop;
1091 }
1092 }
1093
1094 if (sk->sk_filter && skb->ip_summed != CHECKSUM_UNNECESSARY) {
1095 if (__udp_lib_checksum_complete(skb))
1096 goto drop;
1063 skb->ip_summed = CHECKSUM_UNNECESSARY; 1097 skb->ip_summed = CHECKSUM_UNNECESSARY;
1064 } 1098 }
1065 1099
1066 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { 1100 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) {
1067 /* Note that an ENOMEM error is charged twice */ 1101 /* Note that an ENOMEM error is charged twice */
1068 if (rc == -ENOMEM) 1102 if (rc == -ENOMEM)
1069 UDP_INC_STATS_BH(UDP_MIB_RCVBUFERRORS); 1103 UDP_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, up->pcflag);
1070 UDP_INC_STATS_BH(UDP_MIB_INERRORS); 1104 goto drop;
1071 kfree_skb(skb);
1072 return -1;
1073 } 1105 }
1074 UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS); 1106
1107 UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
1075 return 0; 1108 return 0;
1109
1110drop:
1111 UDP_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
1112 kfree_skb(skb);
1113 return -1;
1076} 1114}
1077 1115
1078/* 1116/*
@@ -1081,14 +1119,16 @@ static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
1081 * Note: called only from the BH handler context, 1119 * Note: called only from the BH handler context,
1082 * so we don't need to lock the hashes. 1120 * so we don't need to lock the hashes.
1083 */ 1121 */
1084static int udp_v4_mcast_deliver(struct sk_buff *skb, struct udphdr *uh, 1122static int __udp4_lib_mcast_deliver(struct sk_buff *skb,
1085 __be32 saddr, __be32 daddr) 1123 struct udphdr *uh,
1124 __be32 saddr, __be32 daddr,
1125 struct hlist_head udptable[])
1086{ 1126{
1087 struct sock *sk; 1127 struct sock *sk;
1088 int dif; 1128 int dif;
1089 1129
1090 read_lock(&udp_hash_lock); 1130 read_lock(&udp_hash_lock);
1091 sk = sk_head(&udp_hash[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]); 1131 sk = sk_head(&udptable[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]);
1092 dif = skb->dev->ifindex; 1132 dif = skb->dev->ifindex;
1093 sk = udp_v4_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif); 1133 sk = udp_v4_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif);
1094 if (sk) { 1134 if (sk) {
@@ -1122,65 +1162,75 @@ static int udp_v4_mcast_deliver(struct sk_buff *skb, struct udphdr *uh,
1122 * Otherwise, csum completion requires chacksumming packet body, 1162 * Otherwise, csum completion requires chacksumming packet body,
1123 * including udp header and folding it to skb->csum. 1163 * including udp header and folding it to skb->csum.
1124 */ 1164 */
1125static void udp_checksum_init(struct sk_buff *skb, struct udphdr *uh, 1165static inline void udp4_csum_init(struct sk_buff *skb, struct udphdr *uh)
1126 unsigned short ulen, __be32 saddr, __be32 daddr)
1127{ 1166{
1128 if (uh->check == 0) { 1167 if (uh->check == 0) {
1129 skb->ip_summed = CHECKSUM_UNNECESSARY; 1168 skb->ip_summed = CHECKSUM_UNNECESSARY;
1130 } else if (skb->ip_summed == CHECKSUM_COMPLETE) { 1169 } else if (skb->ip_summed == CHECKSUM_COMPLETE) {
1131 if (!udp_check(uh, ulen, saddr, daddr, skb->csum)) 1170 if (!csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr,
1171 skb->len, IPPROTO_UDP, skb->csum ))
1132 skb->ip_summed = CHECKSUM_UNNECESSARY; 1172 skb->ip_summed = CHECKSUM_UNNECESSARY;
1133 } 1173 }
1134 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 1174 if (skb->ip_summed != CHECKSUM_UNNECESSARY)
1135 skb->csum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0); 1175 skb->csum = csum_tcpudp_nofold(skb->nh.iph->saddr,
1176 skb->nh.iph->daddr,
1177 skb->len, IPPROTO_UDP, 0);
1136 /* Probably, we should checksum udp header (it should be in cache 1178 /* Probably, we should checksum udp header (it should be in cache
1137 * in any case) and data in tiny packets (< rx copybreak). 1179 * in any case) and data in tiny packets (< rx copybreak).
1138 */ 1180 */
1181
1182 /* UDP = UDP-Lite with a non-partial checksum coverage */
1183 UDP_SKB_CB(skb)->partial_cov = 0;
1139} 1184}
1140 1185
1141/* 1186/*
1142 * All we need to do is get the socket, and then do a checksum. 1187 * All we need to do is get the socket, and then do a checksum.
1143 */ 1188 */
1144 1189
1145int udp_rcv(struct sk_buff *skb) 1190int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
1191 int is_udplite)
1146{ 1192{
1147 struct sock *sk; 1193 struct sock *sk;
1148 struct udphdr *uh; 1194 struct udphdr *uh = skb->h.uh;
1149 unsigned short ulen; 1195 unsigned short ulen;
1150 struct rtable *rt = (struct rtable*)skb->dst; 1196 struct rtable *rt = (struct rtable*)skb->dst;
1151 __be32 saddr = skb->nh.iph->saddr; 1197 __be32 saddr = skb->nh.iph->saddr;
1152 __be32 daddr = skb->nh.iph->daddr; 1198 __be32 daddr = skb->nh.iph->daddr;
1153 int len = skb->len;
1154 1199
1155 /* 1200 /*
1156 * Validate the packet and the UDP length. 1201 * Validate the packet.
1157 */ 1202 */
1158 if (!pskb_may_pull(skb, sizeof(struct udphdr))) 1203 if (!pskb_may_pull(skb, sizeof(struct udphdr)))
1159 goto no_header; 1204 goto drop; /* No space for header. */
1160
1161 uh = skb->h.uh;
1162 1205
1163 ulen = ntohs(uh->len); 1206 ulen = ntohs(uh->len);
1164 1207 if (ulen > skb->len)
1165 if (ulen > len || ulen < sizeof(*uh))
1166 goto short_packet; 1208 goto short_packet;
1167 1209
1168 if (pskb_trim_rcsum(skb, ulen)) 1210 if(! is_udplite ) { /* UDP validates ulen. */
1169 goto short_packet; 1211
1212 if (ulen < sizeof(*uh) || pskb_trim_rcsum(skb, ulen))
1213 goto short_packet;
1170 1214
1171 udp_checksum_init(skb, uh, ulen, saddr, daddr); 1215 udp4_csum_init(skb, uh);
1216
1217 } else { /* UDP-Lite validates cscov. */
1218 if (udplite4_csum_init(skb, uh))
1219 goto csum_error;
1220 }
1172 1221
1173 if(rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST)) 1222 if(rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST))
1174 return udp_v4_mcast_deliver(skb, uh, saddr, daddr); 1223 return __udp4_lib_mcast_deliver(skb, uh, saddr, daddr, udptable);
1175 1224
1176 sk = udp_v4_lookup(saddr, uh->source, daddr, uh->dest, skb->dev->ifindex); 1225 sk = __udp4_lib_lookup(saddr, uh->source, daddr, uh->dest,
1226 skb->dev->ifindex, udptable );
1177 1227
1178 if (sk != NULL) { 1228 if (sk != NULL) {
1179 int ret = udp_queue_rcv_skb(sk, skb); 1229 int ret = udp_queue_rcv_skb(sk, skb);
1180 sock_put(sk); 1230 sock_put(sk);
1181 1231
1182 /* a return value > 0 means to resubmit the input, but 1232 /* a return value > 0 means to resubmit the input, but
1183 * it it wants the return to be -protocol, or 0 1233 * it wants the return to be -protocol, or 0
1184 */ 1234 */
1185 if (ret > 0) 1235 if (ret > 0)
1186 return -ret; 1236 return -ret;
@@ -1192,10 +1242,10 @@ int udp_rcv(struct sk_buff *skb)
1192 nf_reset(skb); 1242 nf_reset(skb);
1193 1243
1194 /* No socket. Drop packet silently, if checksum is wrong */ 1244 /* No socket. Drop packet silently, if checksum is wrong */
1195 if (udp_checksum_complete(skb)) 1245 if (udp_lib_checksum_complete(skb))
1196 goto csum_error; 1246 goto csum_error;
1197 1247
1198 UDP_INC_STATS_BH(UDP_MIB_NOPORTS); 1248 UDP_INC_STATS_BH(UDP_MIB_NOPORTS, is_udplite);
1199 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); 1249 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
1200 1250
1201 /* 1251 /*
@@ -1206,36 +1256,40 @@ int udp_rcv(struct sk_buff *skb)
1206 return(0); 1256 return(0);
1207 1257
1208short_packet: 1258short_packet:
1209 LIMIT_NETDEBUG(KERN_DEBUG "UDP: short packet: From %u.%u.%u.%u:%u %d/%d to %u.%u.%u.%u:%u\n", 1259 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: short packet: From %u.%u.%u.%u:%u %d/%d to %u.%u.%u.%u:%u\n",
1260 is_udplite? "-Lite" : "",
1210 NIPQUAD(saddr), 1261 NIPQUAD(saddr),
1211 ntohs(uh->source), 1262 ntohs(uh->source),
1212 ulen, 1263 ulen,
1213 len, 1264 skb->len,
1214 NIPQUAD(daddr), 1265 NIPQUAD(daddr),
1215 ntohs(uh->dest)); 1266 ntohs(uh->dest));
1216no_header: 1267 goto drop;
1217 UDP_INC_STATS_BH(UDP_MIB_INERRORS);
1218 kfree_skb(skb);
1219 return(0);
1220 1268
1221csum_error: 1269csum_error:
1222 /* 1270 /*
1223 * RFC1122: OK. Discards the bad packet silently (as far as 1271 * RFC1122: OK. Discards the bad packet silently (as far as
1224 * the network is concerned, anyway) as per 4.1.3.4 (MUST). 1272 * the network is concerned, anyway) as per 4.1.3.4 (MUST).
1225 */ 1273 */
1226 LIMIT_NETDEBUG(KERN_DEBUG "UDP: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n", 1274 LIMIT_NETDEBUG(KERN_DEBUG "UDP%s: bad checksum. From %d.%d.%d.%d:%d to %d.%d.%d.%d:%d ulen %d\n",
1275 is_udplite? "-Lite" : "",
1227 NIPQUAD(saddr), 1276 NIPQUAD(saddr),
1228 ntohs(uh->source), 1277 ntohs(uh->source),
1229 NIPQUAD(daddr), 1278 NIPQUAD(daddr),
1230 ntohs(uh->dest), 1279 ntohs(uh->dest),
1231 ulen); 1280 ulen);
1232drop: 1281drop:
1233 UDP_INC_STATS_BH(UDP_MIB_INERRORS); 1282 UDP_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
1234 kfree_skb(skb); 1283 kfree_skb(skb);
1235 return(0); 1284 return(0);
1236} 1285}
1237 1286
1238static int udp_destroy_sock(struct sock *sk) 1287__inline__ int udp_rcv(struct sk_buff *skb)
1288{
1289 return __udp4_lib_rcv(skb, udp_hash, 0);
1290}
1291
1292int udp_destroy_sock(struct sock *sk)
1239{ 1293{
1240 lock_sock(sk); 1294 lock_sock(sk);
1241 udp_flush_pending_frames(sk); 1295 udp_flush_pending_frames(sk);
@@ -1246,8 +1300,9 @@ static int udp_destroy_sock(struct sock *sk)
1246/* 1300/*
1247 * Socket option code for UDP 1301 * Socket option code for UDP
1248 */ 1302 */
1249static int do_udp_setsockopt(struct sock *sk, int level, int optname, 1303int udp_lib_setsockopt(struct sock *sk, int level, int optname,
1250 char __user *optval, int optlen) 1304 char __user *optval, int optlen,
1305 int (*push_pending_frames)(struct sock *))
1251{ 1306{
1252 struct udp_sock *up = udp_sk(sk); 1307 struct udp_sock *up = udp_sk(sk);
1253 int val; 1308 int val;
@@ -1266,7 +1321,7 @@ static int do_udp_setsockopt(struct sock *sk, int level, int optname,
1266 } else { 1321 } else {
1267 up->corkflag = 0; 1322 up->corkflag = 0;
1268 lock_sock(sk); 1323 lock_sock(sk);
1269 udp_push_pending_frames(sk, up); 1324 (*push_pending_frames)(sk);
1270 release_sock(sk); 1325 release_sock(sk);
1271 } 1326 }
1272 break; 1327 break;
@@ -1284,6 +1339,32 @@ static int do_udp_setsockopt(struct sock *sk, int level, int optname,
1284 } 1339 }
1285 break; 1340 break;
1286 1341
1342 /*
1343 * UDP-Lite's partial checksum coverage (RFC 3828).
1344 */
1345 /* The sender sets actual checksum coverage length via this option.
1346 * The case coverage > packet length is handled by send module. */
1347 case UDPLITE_SEND_CSCOV:
1348 if (!up->pcflag) /* Disable the option on UDP sockets */
1349 return -ENOPROTOOPT;
1350 if (val != 0 && val < 8) /* Illegal coverage: use default (8) */
1351 val = 8;
1352 up->pcslen = val;
1353 up->pcflag |= UDPLITE_SEND_CC;
1354 break;
1355
1356 /* The receiver specifies a minimum checksum coverage value. To make
1357 * sense, this should be set to at least 8 (as done below). If zero is
1358 * used, this again means full checksum coverage. */
1359 case UDPLITE_RECV_CSCOV:
1360 if (!up->pcflag) /* Disable the option on UDP sockets */
1361 return -ENOPROTOOPT;
1362 if (val != 0 && val < 8) /* Avoid silly minimal values. */
1363 val = 8;
1364 up->pcrlen = val;
1365 up->pcflag |= UDPLITE_RECV_CC;
1366 break;
1367
1287 default: 1368 default:
1288 err = -ENOPROTOOPT; 1369 err = -ENOPROTOOPT;
1289 break; 1370 break;
@@ -1292,26 +1373,28 @@ static int do_udp_setsockopt(struct sock *sk, int level, int optname,
1292 return err; 1373 return err;
1293} 1374}
1294 1375
1295static int udp_setsockopt(struct sock *sk, int level, int optname, 1376int udp_setsockopt(struct sock *sk, int level, int optname,
1296 char __user *optval, int optlen) 1377 char __user *optval, int optlen)
1297{ 1378{
1298 if (level != SOL_UDP) 1379 if (level == SOL_UDP || level == SOL_UDPLITE)
1299 return ip_setsockopt(sk, level, optname, optval, optlen); 1380 return udp_lib_setsockopt(sk, level, optname, optval, optlen,
1300 return do_udp_setsockopt(sk, level, optname, optval, optlen); 1381 udp_push_pending_frames);
1382 return ip_setsockopt(sk, level, optname, optval, optlen);
1301} 1383}
1302 1384
1303#ifdef CONFIG_COMPAT 1385#ifdef CONFIG_COMPAT
1304static int compat_udp_setsockopt(struct sock *sk, int level, int optname, 1386int compat_udp_setsockopt(struct sock *sk, int level, int optname,
1305 char __user *optval, int optlen) 1387 char __user *optval, int optlen)
1306{ 1388{
1307 if (level != SOL_UDP) 1389 if (level == SOL_UDP || level == SOL_UDPLITE)
1308 return compat_ip_setsockopt(sk, level, optname, optval, optlen); 1390 return udp_lib_setsockopt(sk, level, optname, optval, optlen,
1309 return do_udp_setsockopt(sk, level, optname, optval, optlen); 1391 udp_push_pending_frames);
1392 return compat_ip_setsockopt(sk, level, optname, optval, optlen);
1310} 1393}
1311#endif 1394#endif
1312 1395
1313static int do_udp_getsockopt(struct sock *sk, int level, int optname, 1396int udp_lib_getsockopt(struct sock *sk, int level, int optname,
1314 char __user *optval, int __user *optlen) 1397 char __user *optval, int __user *optlen)
1315{ 1398{
1316 struct udp_sock *up = udp_sk(sk); 1399 struct udp_sock *up = udp_sk(sk);
1317 int val, len; 1400 int val, len;
@@ -1333,6 +1416,16 @@ static int do_udp_getsockopt(struct sock *sk, int level, int optname,
1333 val = up->encap_type; 1416 val = up->encap_type;
1334 break; 1417 break;
1335 1418
1419 /* The following two cannot be changed on UDP sockets, the return is
1420 * always 0 (which corresponds to the full checksum coverage of UDP). */
1421 case UDPLITE_SEND_CSCOV:
1422 val = up->pcslen;
1423 break;
1424
1425 case UDPLITE_RECV_CSCOV:
1426 val = up->pcrlen;
1427 break;
1428
1336 default: 1429 default:
1337 return -ENOPROTOOPT; 1430 return -ENOPROTOOPT;
1338 }; 1431 };
@@ -1344,21 +1437,21 @@ static int do_udp_getsockopt(struct sock *sk, int level, int optname,
1344 return 0; 1437 return 0;
1345} 1438}
1346 1439
1347static int udp_getsockopt(struct sock *sk, int level, int optname, 1440int udp_getsockopt(struct sock *sk, int level, int optname,
1348 char __user *optval, int __user *optlen) 1441 char __user *optval, int __user *optlen)
1349{ 1442{
1350 if (level != SOL_UDP) 1443 if (level == SOL_UDP || level == SOL_UDPLITE)
1351 return ip_getsockopt(sk, level, optname, optval, optlen); 1444 return udp_lib_getsockopt(sk, level, optname, optval, optlen);
1352 return do_udp_getsockopt(sk, level, optname, optval, optlen); 1445 return ip_getsockopt(sk, level, optname, optval, optlen);
1353} 1446}
1354 1447
1355#ifdef CONFIG_COMPAT 1448#ifdef CONFIG_COMPAT
1356static int compat_udp_getsockopt(struct sock *sk, int level, int optname, 1449int compat_udp_getsockopt(struct sock *sk, int level, int optname,
1357 char __user *optval, int __user *optlen) 1450 char __user *optval, int __user *optlen)
1358{ 1451{
1359 if (level != SOL_UDP) 1452 if (level == SOL_UDP || level == SOL_UDPLITE)
1360 return compat_ip_getsockopt(sk, level, optname, optval, optlen); 1453 return udp_lib_getsockopt(sk, level, optname, optval, optlen);
1361 return do_udp_getsockopt(sk, level, optname, optval, optlen); 1454 return compat_ip_getsockopt(sk, level, optname, optval, optlen);
1362} 1455}
1363#endif 1456#endif
1364/** 1457/**
@@ -1378,7 +1471,8 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
1378{ 1471{
1379 unsigned int mask = datagram_poll(file, sock, wait); 1472 unsigned int mask = datagram_poll(file, sock, wait);
1380 struct sock *sk = sock->sk; 1473 struct sock *sk = sock->sk;
1381 1474 int is_lite = IS_UDPLITE(sk);
1475
1382 /* Check for false positives due to checksum errors */ 1476 /* Check for false positives due to checksum errors */
1383 if ( (mask & POLLRDNORM) && 1477 if ( (mask & POLLRDNORM) &&
1384 !(file->f_flags & O_NONBLOCK) && 1478 !(file->f_flags & O_NONBLOCK) &&
@@ -1388,8 +1482,8 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
1388 1482
1389 spin_lock_bh(&rcvq->lock); 1483 spin_lock_bh(&rcvq->lock);
1390 while ((skb = skb_peek(rcvq)) != NULL) { 1484 while ((skb = skb_peek(rcvq)) != NULL) {
1391 if (udp_checksum_complete(skb)) { 1485 if (udp_lib_checksum_complete(skb)) {
1392 UDP_INC_STATS_BH(UDP_MIB_INERRORS); 1486 UDP_INC_STATS_BH(UDP_MIB_INERRORS, is_lite);
1393 __skb_unlink(skb, rcvq); 1487 __skb_unlink(skb, rcvq);
1394 kfree_skb(skb); 1488 kfree_skb(skb);
1395 } else { 1489 } else {
@@ -1411,7 +1505,7 @@ unsigned int udp_poll(struct file *file, struct socket *sock, poll_table *wait)
1411struct proto udp_prot = { 1505struct proto udp_prot = {
1412 .name = "UDP", 1506 .name = "UDP",
1413 .owner = THIS_MODULE, 1507 .owner = THIS_MODULE,
1414 .close = udp_close, 1508 .close = udp_lib_close,
1415 .connect = ip4_datagram_connect, 1509 .connect = ip4_datagram_connect,
1416 .disconnect = udp_disconnect, 1510 .disconnect = udp_disconnect,
1417 .ioctl = udp_ioctl, 1511 .ioctl = udp_ioctl,
@@ -1422,8 +1516,8 @@ struct proto udp_prot = {
1422 .recvmsg = udp_recvmsg, 1516 .recvmsg = udp_recvmsg,
1423 .sendpage = udp_sendpage, 1517 .sendpage = udp_sendpage,
1424 .backlog_rcv = udp_queue_rcv_skb, 1518 .backlog_rcv = udp_queue_rcv_skb,
1425 .hash = udp_v4_hash, 1519 .hash = udp_lib_hash,
1426 .unhash = udp_v4_unhash, 1520 .unhash = udp_lib_unhash,
1427 .get_port = udp_v4_get_port, 1521 .get_port = udp_v4_get_port,
1428 .obj_size = sizeof(struct udp_sock), 1522 .obj_size = sizeof(struct udp_sock),
1429#ifdef CONFIG_COMPAT 1523#ifdef CONFIG_COMPAT
@@ -1442,7 +1536,7 @@ static struct sock *udp_get_first(struct seq_file *seq)
1442 1536
1443 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) { 1537 for (state->bucket = 0; state->bucket < UDP_HTABLE_SIZE; ++state->bucket) {
1444 struct hlist_node *node; 1538 struct hlist_node *node;
1445 sk_for_each(sk, node, &udp_hash[state->bucket]) { 1539 sk_for_each(sk, node, state->hashtable + state->bucket) {
1446 if (sk->sk_family == state->family) 1540 if (sk->sk_family == state->family)
1447 goto found; 1541 goto found;
1448 } 1542 }
@@ -1463,7 +1557,7 @@ try_again:
1463 } while (sk && sk->sk_family != state->family); 1557 } while (sk && sk->sk_family != state->family);
1464 1558
1465 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) { 1559 if (!sk && ++state->bucket < UDP_HTABLE_SIZE) {
1466 sk = sk_head(&udp_hash[state->bucket]); 1560 sk = sk_head(state->hashtable + state->bucket);
1467 goto try_again; 1561 goto try_again;
1468 } 1562 }
1469 return sk; 1563 return sk;
@@ -1513,6 +1607,7 @@ static int udp_seq_open(struct inode *inode, struct file *file)
1513 if (!s) 1607 if (!s)
1514 goto out; 1608 goto out;
1515 s->family = afinfo->family; 1609 s->family = afinfo->family;
1610 s->hashtable = afinfo->hashtable;
1516 s->seq_ops.start = udp_seq_start; 1611 s->seq_ops.start = udp_seq_start;
1517 s->seq_ops.next = udp_seq_next; 1612 s->seq_ops.next = udp_seq_next;
1518 s->seq_ops.show = afinfo->seq_show; 1613 s->seq_ops.show = afinfo->seq_show;
@@ -1579,7 +1674,7 @@ static void udp4_format_sock(struct sock *sp, char *tmpbuf, int bucket)
1579 atomic_read(&sp->sk_refcnt), sp); 1674 atomic_read(&sp->sk_refcnt), sp);
1580} 1675}
1581 1676
1582static int udp4_seq_show(struct seq_file *seq, void *v) 1677int udp4_seq_show(struct seq_file *seq, void *v)
1583{ 1678{
1584 if (v == SEQ_START_TOKEN) 1679 if (v == SEQ_START_TOKEN)
1585 seq_printf(seq, "%-127s\n", 1680 seq_printf(seq, "%-127s\n",
@@ -1602,6 +1697,7 @@ static struct udp_seq_afinfo udp4_seq_afinfo = {
1602 .owner = THIS_MODULE, 1697 .owner = THIS_MODULE,
1603 .name = "udp", 1698 .name = "udp",
1604 .family = AF_INET, 1699 .family = AF_INET,
1700 .hashtable = udp_hash,
1605 .seq_show = udp4_seq_show, 1701 .seq_show = udp4_seq_show,
1606 .seq_fops = &udp4_seq_fops, 1702 .seq_fops = &udp4_seq_fops,
1607}; 1703};
@@ -1624,6 +1720,8 @@ EXPORT_SYMBOL(udp_ioctl);
1624EXPORT_SYMBOL(udp_get_port); 1720EXPORT_SYMBOL(udp_get_port);
1625EXPORT_SYMBOL(udp_prot); 1721EXPORT_SYMBOL(udp_prot);
1626EXPORT_SYMBOL(udp_sendmsg); 1722EXPORT_SYMBOL(udp_sendmsg);
1723EXPORT_SYMBOL(udp_lib_getsockopt);
1724EXPORT_SYMBOL(udp_lib_setsockopt);
1627EXPORT_SYMBOL(udp_poll); 1725EXPORT_SYMBOL(udp_poll);
1628 1726
1629#ifdef CONFIG_PROC_FS 1727#ifdef CONFIG_PROC_FS
diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h
new file mode 100644
index 000000000000..f6f4277ba6dc
--- /dev/null
+++ b/net/ipv4/udp_impl.h
@@ -0,0 +1,38 @@
1#ifndef _UDP4_IMPL_H
2#define _UDP4_IMPL_H
3#include <net/udp.h>
4#include <net/udplite.h>
5#include <net/protocol.h>
6#include <net/inet_common.h>
7
8extern int __udp4_lib_rcv(struct sk_buff *, struct hlist_head [], int );
9extern void __udp4_lib_err(struct sk_buff *, u32, struct hlist_head []);
10
11extern int __udp_lib_get_port(struct sock *sk, unsigned short snum,
12 struct hlist_head udptable[], int *port_rover,
13 int (*)(const struct sock*,const struct sock*));
14extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
15
16
17extern int udp_setsockopt(struct sock *sk, int level, int optname,
18 char __user *optval, int optlen);
19extern int udp_getsockopt(struct sock *sk, int level, int optname,
20 char __user *optval, int __user *optlen);
21
22#ifdef CONFIG_COMPAT
23extern int compat_udp_setsockopt(struct sock *sk, int level, int optname,
24 char __user *optval, int optlen);
25extern int compat_udp_getsockopt(struct sock *sk, int level, int optname,
26 char __user *optval, int __user *optlen);
27#endif
28extern int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
29 size_t len, int noblock, int flags, int *addr_len);
30extern int udp_sendpage(struct sock *sk, struct page *page, int offset,
31 size_t size, int flags);
32extern int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb);
33extern int udp_destroy_sock(struct sock *sk);
34
35#ifdef CONFIG_PROC_FS
36extern int udp4_seq_show(struct seq_file *seq, void *v);
37#endif
38#endif /* _UDP4_IMPL_H */
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
new file mode 100644
index 000000000000..b28fe1edf98b
--- /dev/null
+++ b/net/ipv4/udplite.c
@@ -0,0 +1,119 @@
1/*
2 * UDPLITE An implementation of the UDP-Lite protocol (RFC 3828).
3 *
4 * Version: $Id: udplite.c,v 1.25 2006/10/19 07:22:36 gerrit Exp $
5 *
6 * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk>
7 *
8 * Changes:
9 * Fixes:
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15#include "udp_impl.h"
16DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics) __read_mostly;
17
18struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
19static int udplite_port_rover;
20
21int udplite_get_port(struct sock *sk, unsigned short p,
22 int (*c)(const struct sock *, const struct sock *))
23{
24 return __udp_lib_get_port(sk, p, udplite_hash, &udplite_port_rover, c);
25}
26
27static int udplite_v4_get_port(struct sock *sk, unsigned short snum)
28{
29 return udplite_get_port(sk, snum, ipv4_rcv_saddr_equal);
30}
31
32static int udplite_rcv(struct sk_buff *skb)
33{
34 return __udp4_lib_rcv(skb, udplite_hash, 1);
35}
36
37static void udplite_err(struct sk_buff *skb, u32 info)
38{
39 return __udp4_lib_err(skb, info, udplite_hash);
40}
41
42static struct net_protocol udplite_protocol = {
43 .handler = udplite_rcv,
44 .err_handler = udplite_err,
45 .no_policy = 1,
46};
47
48struct proto udplite_prot = {
49 .name = "UDP-Lite",
50 .owner = THIS_MODULE,
51 .close = udp_lib_close,
52 .connect = ip4_datagram_connect,
53 .disconnect = udp_disconnect,
54 .ioctl = udp_ioctl,
55 .init = udplite_sk_init,
56 .destroy = udp_destroy_sock,
57 .setsockopt = udp_setsockopt,
58 .getsockopt = udp_getsockopt,
59 .sendmsg = udp_sendmsg,
60 .recvmsg = udp_recvmsg,
61 .sendpage = udp_sendpage,
62 .backlog_rcv = udp_queue_rcv_skb,
63 .hash = udp_lib_hash,
64 .unhash = udp_lib_unhash,
65 .get_port = udplite_v4_get_port,
66 .obj_size = sizeof(struct udp_sock),
67#ifdef CONFIG_COMPAT
68 .compat_setsockopt = compat_udp_setsockopt,
69 .compat_getsockopt = compat_udp_getsockopt,
70#endif
71};
72
73static struct inet_protosw udplite4_protosw = {
74 .type = SOCK_DGRAM,
75 .protocol = IPPROTO_UDPLITE,
76 .prot = &udplite_prot,
77 .ops = &inet_dgram_ops,
78 .capability = -1,
79 .no_check = 0, /* must checksum (RFC 3828) */
80 .flags = INET_PROTOSW_PERMANENT,
81};
82
83#ifdef CONFIG_PROC_FS
84static struct file_operations udplite4_seq_fops;
85static struct udp_seq_afinfo udplite4_seq_afinfo = {
86 .owner = THIS_MODULE,
87 .name = "udplite",
88 .family = AF_INET,
89 .hashtable = udplite_hash,
90 .seq_show = udp4_seq_show,
91 .seq_fops = &udplite4_seq_fops,
92};
93#endif
94
95void __init udplite4_register(void)
96{
97 if (proto_register(&udplite_prot, 1))
98 goto out_register_err;
99
100 if (inet_add_protocol(&udplite_protocol, IPPROTO_UDPLITE) < 0)
101 goto out_unregister_proto;
102
103 inet_register_protosw(&udplite4_protosw);
104
105#ifdef CONFIG_PROC_FS
106 if (udp_proc_register(&udplite4_seq_afinfo)) /* udplite4_proc_init() */
107 printk(KERN_ERR "%s: Cannot register /proc!\n", __FUNCTION__);
108#endif
109 return;
110
111out_unregister_proto:
112 proto_unregister(&udplite_prot);
113out_register_err:
114 printk(KERN_CRIT "%s: Cannot add UDP-Lite protocol.\n", __FUNCTION__);
115}
116
117EXPORT_SYMBOL(udplite_hash);
118EXPORT_SYMBOL(udplite_prot);
119EXPORT_SYMBOL(udplite_get_port);
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 1bed0cdf53e3..d4107bb701b5 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -72,8 +72,8 @@ __xfrm4_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
72 struct dst_entry *dst, *dst_prev; 72 struct dst_entry *dst, *dst_prev;
73 struct rtable *rt0 = (struct rtable*)(*dst_p); 73 struct rtable *rt0 = (struct rtable*)(*dst_p);
74 struct rtable *rt = rt0; 74 struct rtable *rt = rt0;
75 u32 remote = fl->fl4_dst; 75 __be32 remote = fl->fl4_dst;
76 u32 local = fl->fl4_src; 76 __be32 local = fl->fl4_src;
77 struct flowi fl_tunnel = { 77 struct flowi fl_tunnel = {
78 .nl_u = { 78 .nl_u = {
79 .ip4_u = { 79 .ip4_u = {
@@ -199,11 +199,12 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl)
199 if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) { 199 if (!(iph->frag_off & htons(IP_MF | IP_OFFSET))) {
200 switch (iph->protocol) { 200 switch (iph->protocol) {
201 case IPPROTO_UDP: 201 case IPPROTO_UDP:
202 case IPPROTO_UDPLITE:
202 case IPPROTO_TCP: 203 case IPPROTO_TCP:
203 case IPPROTO_SCTP: 204 case IPPROTO_SCTP:
204 case IPPROTO_DCCP: 205 case IPPROTO_DCCP:
205 if (pskb_may_pull(skb, xprth + 4 - skb->data)) { 206 if (pskb_may_pull(skb, xprth + 4 - skb->data)) {
206 u16 *ports = (u16 *)xprth; 207 __be16 *ports = (__be16 *)xprth;
207 208
208 fl->fl_ip_sport = ports[0]; 209 fl->fl_ip_sport = ports[0];
209 fl->fl_ip_dport = ports[1]; 210 fl->fl_ip_dport = ports[1];
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index 6e48f52e197c..deb4101a2a81 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -196,10 +196,3 @@ config IPV6_SUBTREES
196 196
197 If unsure, say N. 197 If unsure, say N.
198 198
199config IPV6_ROUTE_FWMARK
200 bool "IPv6: use netfilter MARK value as routing key"
201 depends on IPV6_MULTIPLE_TABLES && NETFILTER
202 ---help---
203 If you say Y here, you will be able to specify different routes for
204 packets with different mark values (see iptables(8), MARK target).
205
diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile
index addcc011bc01..8bacda109b7f 100644
--- a/net/ipv6/Makefile
+++ b/net/ipv6/Makefile
@@ -5,8 +5,8 @@
5obj-$(CONFIG_IPV6) += ipv6.o 5obj-$(CONFIG_IPV6) += ipv6.o
6 6
7ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \ 7ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \
8 route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o raw.o \ 8 route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o udplite.o \
9 protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \ 9 raw.o protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \
10 exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \ 10 exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \
11 ip6_flowlabel.o ipv6_syms.o inet6_connection_sock.o 11 ip6_flowlabel.o ipv6_syms.o inet6_connection_sock.o
12 12
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index b312a5f7a759..a5e8d207a51b 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -232,7 +232,7 @@ static inline unsigned ipv6_addr_scope2type(unsigned scope)
232 232
233int __ipv6_addr_type(const struct in6_addr *addr) 233int __ipv6_addr_type(const struct in6_addr *addr)
234{ 234{
235 u32 st; 235 __be32 st;
236 236
237 st = addr->s6_addr32[0]; 237 st = addr->s6_addr32[0];
238 238
@@ -1164,7 +1164,7 @@ record_it:
1164int ipv6_get_saddr(struct dst_entry *dst, 1164int ipv6_get_saddr(struct dst_entry *dst,
1165 struct in6_addr *daddr, struct in6_addr *saddr) 1165 struct in6_addr *daddr, struct in6_addr *saddr)
1166{ 1166{
1167 return ipv6_dev_get_saddr(dst ? ((struct rt6_info *)dst)->rt6i_idev->dev : NULL, daddr, saddr); 1167 return ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, daddr, saddr);
1168} 1168}
1169 1169
1170 1170
@@ -3098,10 +3098,9 @@ static inline int rt_scope(int ifa_scope)
3098 3098
3099static inline int inet6_ifaddr_msgsize(void) 3099static inline int inet6_ifaddr_msgsize(void)
3100{ 3100{
3101 return nlmsg_total_size(sizeof(struct ifaddrmsg) + 3101 return NLMSG_ALIGN(sizeof(struct ifaddrmsg))
3102 nla_total_size(16) + 3102 + nla_total_size(16) /* IFA_ADDRESS */
3103 nla_total_size(sizeof(struct ifa_cacheinfo)) + 3103 + nla_total_size(sizeof(struct ifa_cacheinfo));
3104 128);
3105} 3104}
3106 3105
3107static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa, 3106static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
@@ -3329,10 +3328,8 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
3329 3328
3330 err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(in_skb).pid, 3329 err = inet6_fill_ifaddr(skb, ifa, NETLINK_CB(in_skb).pid,
3331 nlh->nlmsg_seq, RTM_NEWADDR, 0); 3330 nlh->nlmsg_seq, RTM_NEWADDR, 0);
3332 if (err < 0) { 3331 /* failure implies BUG in inet6_ifaddr_msgsize() */
3333 kfree_skb(skb); 3332 BUG_ON(err < 0);
3334 goto errout_ifa;
3335 }
3336 3333
3337 err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid); 3334 err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
3338errout_ifa: 3335errout_ifa:
@@ -3351,10 +3348,8 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
3351 goto errout; 3348 goto errout;
3352 3349
3353 err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0); 3350 err = inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0);
3354 if (err < 0) { 3351 /* failure implies BUG in inet6_ifaddr_msgsize() */
3355 kfree_skb(skb); 3352 BUG_ON(err < 0);
3356 goto errout;
3357 }
3358 3353
3359 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); 3354 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
3360errout: 3355errout:
@@ -3365,6 +3360,8 @@ errout:
3365static void inline ipv6_store_devconf(struct ipv6_devconf *cnf, 3360static void inline ipv6_store_devconf(struct ipv6_devconf *cnf,
3366 __s32 *array, int bytes) 3361 __s32 *array, int bytes)
3367{ 3362{
3363 BUG_ON(bytes < (DEVCONF_MAX * 4));
3364
3368 memset(array, 0, bytes); 3365 memset(array, 0, bytes);
3369 array[DEVCONF_FORWARDING] = cnf->forwarding; 3366 array[DEVCONF_FORWARDING] = cnf->forwarding;
3370 array[DEVCONF_HOPLIMIT] = cnf->hop_limit; 3367 array[DEVCONF_HOPLIMIT] = cnf->hop_limit;
@@ -3397,80 +3394,76 @@ static void inline ipv6_store_devconf(struct ipv6_devconf *cnf,
3397 array[DEVCONF_PROXY_NDP] = cnf->proxy_ndp; 3394 array[DEVCONF_PROXY_NDP] = cnf->proxy_ndp;
3398} 3395}
3399 3396
3400/* Maximum length of ifinfomsg attributes */ 3397static inline size_t inet6_if_nlmsg_size(void)
3401#define INET6_IFINFO_RTA_SPACE \ 3398{
3402 RTA_SPACE(IFNAMSIZ) /* IFNAME */ + \ 3399 return NLMSG_ALIGN(sizeof(struct ifinfomsg))
3403 RTA_SPACE(MAX_ADDR_LEN) /* ADDRESS */ + \ 3400 + nla_total_size(IFNAMSIZ) /* IFLA_IFNAME */
3404 RTA_SPACE(sizeof(u32)) /* MTU */ + \ 3401 + nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */
3405 RTA_SPACE(sizeof(int)) /* LINK */ + \ 3402 + nla_total_size(4) /* IFLA_MTU */
3406 RTA_SPACE(0) /* PROTINFO */ + \ 3403 + nla_total_size(4) /* IFLA_LINK */
3407 RTA_SPACE(sizeof(u32)) /* FLAGS */ + \ 3404 + nla_total_size( /* IFLA_PROTINFO */
3408 RTA_SPACE(sizeof(struct ifla_cacheinfo)) /* CACHEINFO */ + \ 3405 nla_total_size(4) /* IFLA_INET6_FLAGS */
3409 RTA_SPACE(sizeof(__s32[DEVCONF_MAX])) /* CONF */ 3406 + nla_total_size(sizeof(struct ifla_cacheinfo))
3407 + nla_total_size(DEVCONF_MAX * 4) /* IFLA_INET6_CONF */
3408 );
3409}
3410 3410
3411static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev, 3411static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
3412 u32 pid, u32 seq, int event, unsigned int flags) 3412 u32 pid, u32 seq, int event, unsigned int flags)
3413{ 3413{
3414 struct net_device *dev = idev->dev; 3414 struct net_device *dev = idev->dev;
3415 __s32 *array = NULL; 3415 struct nlattr *conf;
3416 struct ifinfomsg *r; 3416 struct ifinfomsg *hdr;
3417 struct nlmsghdr *nlh; 3417 struct nlmsghdr *nlh;
3418 unsigned char *b = skb->tail; 3418 void *protoinfo;
3419 struct rtattr *subattr; 3419 struct ifla_cacheinfo ci;
3420 __u32 mtu = dev->mtu; 3420
3421 struct ifla_cacheinfo ci; 3421 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
3422 3422 if (nlh == NULL)
3423 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*r), flags); 3423 return -ENOBUFS;
3424 r = NLMSG_DATA(nlh); 3424
3425 r->ifi_family = AF_INET6; 3425 hdr = nlmsg_data(nlh);
3426 r->__ifi_pad = 0; 3426 hdr->ifi_family = AF_INET6;
3427 r->ifi_type = dev->type; 3427 hdr->__ifi_pad = 0;
3428 r->ifi_index = dev->ifindex; 3428 hdr->ifi_type = dev->type;
3429 r->ifi_flags = dev_get_flags(dev); 3429 hdr->ifi_index = dev->ifindex;
3430 r->ifi_change = 0; 3430 hdr->ifi_flags = dev_get_flags(dev);
3431 3431 hdr->ifi_change = 0;
3432 RTA_PUT(skb, IFLA_IFNAME, strlen(dev->name)+1, dev->name); 3432
3433 NLA_PUT_STRING(skb, IFLA_IFNAME, dev->name);
3433 3434
3434 if (dev->addr_len) 3435 if (dev->addr_len)
3435 RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr); 3436 NLA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
3436 3437
3437 RTA_PUT(skb, IFLA_MTU, sizeof(mtu), &mtu); 3438 NLA_PUT_U32(skb, IFLA_MTU, dev->mtu);
3438 if (dev->ifindex != dev->iflink) 3439 if (dev->ifindex != dev->iflink)
3439 RTA_PUT(skb, IFLA_LINK, sizeof(int), &dev->iflink); 3440 NLA_PUT_U32(skb, IFLA_LINK, dev->iflink);
3440
3441 subattr = (struct rtattr*)skb->tail;
3442 3441
3443 RTA_PUT(skb, IFLA_PROTINFO, 0, NULL); 3442 protoinfo = nla_nest_start(skb, IFLA_PROTINFO);
3443 if (protoinfo == NULL)
3444 goto nla_put_failure;
3444 3445
3445 /* return the device flags */ 3446 NLA_PUT_U32(skb, IFLA_INET6_FLAGS, idev->if_flags);
3446 RTA_PUT(skb, IFLA_INET6_FLAGS, sizeof(__u32), &idev->if_flags);
3447 3447
3448 /* return interface cacheinfo */
3449 ci.max_reasm_len = IPV6_MAXPLEN; 3448 ci.max_reasm_len = IPV6_MAXPLEN;
3450 ci.tstamp = (__u32)(TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) / HZ * 100 3449 ci.tstamp = (__u32)(TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) / HZ * 100
3451 + TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) % HZ * 100 / HZ); 3450 + TIME_DELTA(idev->tstamp, INITIAL_JIFFIES) % HZ * 100 / HZ);
3452 ci.reachable_time = idev->nd_parms->reachable_time; 3451 ci.reachable_time = idev->nd_parms->reachable_time;
3453 ci.retrans_time = idev->nd_parms->retrans_time; 3452 ci.retrans_time = idev->nd_parms->retrans_time;
3454 RTA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci); 3453 NLA_PUT(skb, IFLA_INET6_CACHEINFO, sizeof(ci), &ci);
3455 3454
3456 /* return the device sysctl params */ 3455 conf = nla_reserve(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(s32));
3457 if ((array = kmalloc(DEVCONF_MAX * sizeof(*array), GFP_ATOMIC)) == NULL) 3456 if (conf == NULL)
3458 goto rtattr_failure; 3457 goto nla_put_failure;
3459 ipv6_store_devconf(&idev->cnf, array, DEVCONF_MAX * sizeof(*array)); 3458 ipv6_store_devconf(&idev->cnf, nla_data(conf), nla_len(conf));
3460 RTA_PUT(skb, IFLA_INET6_CONF, DEVCONF_MAX * sizeof(*array), array);
3461 3459
3462 /* XXX - Statistics/MC not implemented */ 3460 /* XXX - Statistics/MC not implemented */
3463 subattr->rta_len = skb->tail - (u8*)subattr;
3464 3461
3465 nlh->nlmsg_len = skb->tail - b; 3462 nla_nest_end(skb, protoinfo);
3466 kfree(array); 3463 return nlmsg_end(skb, nlh);
3467 return skb->len;
3468 3464
3469nlmsg_failure: 3465nla_put_failure:
3470rtattr_failure: 3466 return nlmsg_cancel(skb, nlh);
3471 kfree(array);
3472 skb_trim(skb, b - skb->data);
3473 return -1;
3474} 3467}
3475 3468
3476static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) 3469static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
@@ -3501,18 +3494,15 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
3501void inet6_ifinfo_notify(int event, struct inet6_dev *idev) 3494void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
3502{ 3495{
3503 struct sk_buff *skb; 3496 struct sk_buff *skb;
3504 int payload = sizeof(struct ifinfomsg) + INET6_IFINFO_RTA_SPACE;
3505 int err = -ENOBUFS; 3497 int err = -ENOBUFS;
3506 3498
3507 skb = nlmsg_new(nlmsg_total_size(payload), GFP_ATOMIC); 3499 skb = nlmsg_new(inet6_if_nlmsg_size(), GFP_ATOMIC);
3508 if (skb == NULL) 3500 if (skb == NULL)
3509 goto errout; 3501 goto errout;
3510 3502
3511 err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0); 3503 err = inet6_fill_ifinfo(skb, idev, 0, 0, event, 0);
3512 if (err < 0) { 3504 /* failure implies BUG in inet6_if_nlmsg_size() */
3513 kfree_skb(skb); 3505 BUG_ON(err < 0);
3514 goto errout;
3515 }
3516 3506
3517 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC); 3507 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
3518errout: 3508errout:
@@ -3520,22 +3510,26 @@ errout:
3520 rtnl_set_sk_err(RTNLGRP_IPV6_IFADDR, err); 3510 rtnl_set_sk_err(RTNLGRP_IPV6_IFADDR, err);
3521} 3511}
3522 3512
3523/* Maximum length of prefix_cacheinfo attributes */ 3513static inline size_t inet6_prefix_nlmsg_size(void)
3524#define INET6_PREFIX_RTA_SPACE \ 3514{
3525 RTA_SPACE(sizeof(((struct prefix_info *)NULL)->prefix)) /* ADDRESS */ + \ 3515 return NLMSG_ALIGN(sizeof(struct prefixmsg))
3526 RTA_SPACE(sizeof(struct prefix_cacheinfo)) /* CACHEINFO */ 3516 + nla_total_size(sizeof(struct in6_addr))
3517 + nla_total_size(sizeof(struct prefix_cacheinfo));
3518}
3527 3519
3528static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev, 3520static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
3529 struct prefix_info *pinfo, u32 pid, u32 seq, 3521 struct prefix_info *pinfo, u32 pid, u32 seq,
3530 int event, unsigned int flags) 3522 int event, unsigned int flags)
3531{ 3523{
3532 struct prefixmsg *pmsg; 3524 struct prefixmsg *pmsg;
3533 struct nlmsghdr *nlh; 3525 struct nlmsghdr *nlh;
3534 unsigned char *b = skb->tail;
3535 struct prefix_cacheinfo ci; 3526 struct prefix_cacheinfo ci;
3536 3527
3537 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*pmsg), flags); 3528 nlh = nlmsg_put(skb, pid, seq, event, sizeof(*pmsg), flags);
3538 pmsg = NLMSG_DATA(nlh); 3529 if (nlh == NULL)
3530 return -ENOBUFS;
3531
3532 pmsg = nlmsg_data(nlh);
3539 pmsg->prefix_family = AF_INET6; 3533 pmsg->prefix_family = AF_INET6;
3540 pmsg->prefix_pad1 = 0; 3534 pmsg->prefix_pad1 = 0;
3541 pmsg->prefix_pad2 = 0; 3535 pmsg->prefix_pad2 = 0;
@@ -3543,44 +3537,37 @@ static int inet6_fill_prefix(struct sk_buff *skb, struct inet6_dev *idev,
3543 pmsg->prefix_len = pinfo->prefix_len; 3537 pmsg->prefix_len = pinfo->prefix_len;
3544 pmsg->prefix_type = pinfo->type; 3538 pmsg->prefix_type = pinfo->type;
3545 pmsg->prefix_pad3 = 0; 3539 pmsg->prefix_pad3 = 0;
3546
3547 pmsg->prefix_flags = 0; 3540 pmsg->prefix_flags = 0;
3548 if (pinfo->onlink) 3541 if (pinfo->onlink)
3549 pmsg->prefix_flags |= IF_PREFIX_ONLINK; 3542 pmsg->prefix_flags |= IF_PREFIX_ONLINK;
3550 if (pinfo->autoconf) 3543 if (pinfo->autoconf)
3551 pmsg->prefix_flags |= IF_PREFIX_AUTOCONF; 3544 pmsg->prefix_flags |= IF_PREFIX_AUTOCONF;
3552 3545
3553 RTA_PUT(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix); 3546 NLA_PUT(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix);
3554 3547
3555 ci.preferred_time = ntohl(pinfo->prefered); 3548 ci.preferred_time = ntohl(pinfo->prefered);
3556 ci.valid_time = ntohl(pinfo->valid); 3549 ci.valid_time = ntohl(pinfo->valid);
3557 RTA_PUT(skb, PREFIX_CACHEINFO, sizeof(ci), &ci); 3550 NLA_PUT(skb, PREFIX_CACHEINFO, sizeof(ci), &ci);
3558 3551
3559 nlh->nlmsg_len = skb->tail - b; 3552 return nlmsg_end(skb, nlh);
3560 return skb->len;
3561 3553
3562nlmsg_failure: 3554nla_put_failure:
3563rtattr_failure: 3555 return nlmsg_cancel(skb, nlh);
3564 skb_trim(skb, b - skb->data);
3565 return -1;
3566} 3556}
3567 3557
3568static void inet6_prefix_notify(int event, struct inet6_dev *idev, 3558static void inet6_prefix_notify(int event, struct inet6_dev *idev,
3569 struct prefix_info *pinfo) 3559 struct prefix_info *pinfo)
3570{ 3560{
3571 struct sk_buff *skb; 3561 struct sk_buff *skb;
3572 int payload = sizeof(struct prefixmsg) + INET6_PREFIX_RTA_SPACE;
3573 int err = -ENOBUFS; 3562 int err = -ENOBUFS;
3574 3563
3575 skb = nlmsg_new(nlmsg_total_size(payload), GFP_ATOMIC); 3564 skb = nlmsg_new(inet6_prefix_nlmsg_size(), GFP_ATOMIC);
3576 if (skb == NULL) 3565 if (skb == NULL)
3577 goto errout; 3566 goto errout;
3578 3567
3579 err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0); 3568 err = inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0);
3580 if (err < 0) { 3569 /* failure implies BUG in inet6_prefix_nlmsg_size() */
3581 kfree_skb(skb); 3570 BUG_ON(err < 0);
3582 goto errout;
3583 }
3584 3571
3585 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC); 3572 err = rtnl_notify(skb, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC);
3586errout: 3573errout:
@@ -3982,10 +3969,9 @@ static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf
3982 struct addrconf_sysctl_table *t; 3969 struct addrconf_sysctl_table *t;
3983 char *dev_name = NULL; 3970 char *dev_name = NULL;
3984 3971
3985 t = kmalloc(sizeof(*t), GFP_KERNEL); 3972 t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL);
3986 if (t == NULL) 3973 if (t == NULL)
3987 return; 3974 return;
3988 memcpy(t, &addrconf_sysctl, sizeof(*t));
3989 for (i=0; t->addrconf_vars[i].data; i++) { 3975 for (i=0; t->addrconf_vars[i].data; i++) {
3990 t->addrconf_vars[i].data += (char*)p - (char*)&ipv6_devconf; 3976 t->addrconf_vars[i].data += (char*)p - (char*)&ipv6_devconf;
3991 t->addrconf_vars[i].de = NULL; 3977 t->addrconf_vars[i].de = NULL;
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 858cae29581c..87c8f54872b7 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -49,6 +49,7 @@
49#include <net/ip.h> 49#include <net/ip.h>
50#include <net/ipv6.h> 50#include <net/ipv6.h>
51#include <net/udp.h> 51#include <net/udp.h>
52#include <net/udplite.h>
52#include <net/tcp.h> 53#include <net/tcp.h>
53#include <net/ipip.h> 54#include <net/ipip.h>
54#include <net/protocol.h> 55#include <net/protocol.h>
@@ -221,7 +222,7 @@ lookup_protocol:
221 * the user to assign a number at socket 222 * the user to assign a number at socket
222 * creation time automatically shares. 223 * creation time automatically shares.
223 */ 224 */
224 inet->sport = ntohs(inet->num); 225 inet->sport = htons(inet->num);
225 sk->sk_prot->hash(sk); 226 sk->sk_prot->hash(sk);
226 } 227 }
227 if (sk->sk_prot->init) { 228 if (sk->sk_prot->init) {
@@ -341,7 +342,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
341 sk->sk_userlocks |= SOCK_BINDADDR_LOCK; 342 sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
342 if (snum) 343 if (snum)
343 sk->sk_userlocks |= SOCK_BINDPORT_LOCK; 344 sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
344 inet->sport = ntohs(inet->num); 345 inet->sport = htons(inet->num);
345 inet->dport = 0; 346 inet->dport = 0;
346 inet->daddr = 0; 347 inet->daddr = 0;
347out: 348out:
@@ -678,7 +679,7 @@ int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
678 if (np->rxopt.all) { 679 if (np->rxopt.all) {
679 if ((opt->hop && (np->rxopt.bits.hopopts || 680 if ((opt->hop && (np->rxopt.bits.hopopts ||
680 np->rxopt.bits.ohopopts)) || 681 np->rxopt.bits.ohopopts)) ||
681 ((IPV6_FLOWINFO_MASK & *(u32*)skb->nh.raw) && 682 ((IPV6_FLOWINFO_MASK & *(__be32*)skb->nh.raw) &&
682 np->rxopt.bits.rxflow) || 683 np->rxopt.bits.rxflow) ||
683 (opt->srcrt && (np->rxopt.bits.srcrt || 684 (opt->srcrt && (np->rxopt.bits.srcrt ||
684 np->rxopt.bits.osrcrt)) || 685 np->rxopt.bits.osrcrt)) ||
@@ -737,8 +738,13 @@ static int __init init_ipv6_mibs(void)
737 if (snmp6_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib), 738 if (snmp6_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib),
738 __alignof__(struct udp_mib)) < 0) 739 __alignof__(struct udp_mib)) < 0)
739 goto err_udp_mib; 740 goto err_udp_mib;
741 if (snmp6_mib_init((void **)udplite_stats_in6, sizeof (struct udp_mib),
742 __alignof__(struct udp_mib)) < 0)
743 goto err_udplite_mib;
740 return 0; 744 return 0;
741 745
746err_udplite_mib:
747 snmp6_mib_free((void **)udp_stats_in6);
742err_udp_mib: 748err_udp_mib:
743 snmp6_mib_free((void **)icmpv6_statistics); 749 snmp6_mib_free((void **)icmpv6_statistics);
744err_icmp_mib: 750err_icmp_mib:
@@ -753,6 +759,7 @@ static void cleanup_ipv6_mibs(void)
753 snmp6_mib_free((void **)ipv6_statistics); 759 snmp6_mib_free((void **)ipv6_statistics);
754 snmp6_mib_free((void **)icmpv6_statistics); 760 snmp6_mib_free((void **)icmpv6_statistics);
755 snmp6_mib_free((void **)udp_stats_in6); 761 snmp6_mib_free((void **)udp_stats_in6);
762 snmp6_mib_free((void **)udplite_stats_in6);
756} 763}
757 764
758static int __init inet6_init(void) 765static int __init inet6_init(void)
@@ -780,10 +787,14 @@ static int __init inet6_init(void)
780 if (err) 787 if (err)
781 goto out_unregister_tcp_proto; 788 goto out_unregister_tcp_proto;
782 789
783 err = proto_register(&rawv6_prot, 1); 790 err = proto_register(&udplitev6_prot, 1);
784 if (err) 791 if (err)
785 goto out_unregister_udp_proto; 792 goto out_unregister_udp_proto;
786 793
794 err = proto_register(&rawv6_prot, 1);
795 if (err)
796 goto out_unregister_udplite_proto;
797
787 798
788 /* Register the socket-side information for inet6_create. */ 799 /* Register the socket-side information for inet6_create. */
789 for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r) 800 for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
@@ -837,6 +848,8 @@ static int __init inet6_init(void)
837 goto proc_tcp6_fail; 848 goto proc_tcp6_fail;
838 if (udp6_proc_init()) 849 if (udp6_proc_init())
839 goto proc_udp6_fail; 850 goto proc_udp6_fail;
851 if (udplite6_proc_init())
852 goto proc_udplite6_fail;
840 if (ipv6_misc_proc_init()) 853 if (ipv6_misc_proc_init())
841 goto proc_misc6_fail; 854 goto proc_misc6_fail;
842 855
@@ -862,6 +875,7 @@ static int __init inet6_init(void)
862 875
863 /* Init v6 transport protocols. */ 876 /* Init v6 transport protocols. */
864 udpv6_init(); 877 udpv6_init();
878 udplitev6_init();
865 tcpv6_init(); 879 tcpv6_init();
866 880
867 ipv6_packet_init(); 881 ipv6_packet_init();
@@ -879,6 +893,8 @@ proc_if6_fail:
879proc_anycast6_fail: 893proc_anycast6_fail:
880 ipv6_misc_proc_exit(); 894 ipv6_misc_proc_exit();
881proc_misc6_fail: 895proc_misc6_fail:
896 udplite6_proc_exit();
897proc_udplite6_fail:
882 udp6_proc_exit(); 898 udp6_proc_exit();
883proc_udp6_fail: 899proc_udp6_fail:
884 tcp6_proc_exit(); 900 tcp6_proc_exit();
@@ -902,6 +918,8 @@ out_unregister_sock:
902 sock_unregister(PF_INET6); 918 sock_unregister(PF_INET6);
903out_unregister_raw_proto: 919out_unregister_raw_proto:
904 proto_unregister(&rawv6_prot); 920 proto_unregister(&rawv6_prot);
921out_unregister_udplite_proto:
922 proto_unregister(&udplitev6_prot);
905out_unregister_udp_proto: 923out_unregister_udp_proto:
906 proto_unregister(&udpv6_prot); 924 proto_unregister(&udpv6_prot);
907out_unregister_tcp_proto: 925out_unregister_tcp_proto:
@@ -919,6 +937,7 @@ static void __exit inet6_exit(void)
919 ac6_proc_exit(); 937 ac6_proc_exit();
920 ipv6_misc_proc_exit(); 938 ipv6_misc_proc_exit();
921 udp6_proc_exit(); 939 udp6_proc_exit();
940 udplite6_proc_exit();
922 tcp6_proc_exit(); 941 tcp6_proc_exit();
923 raw6_proc_exit(); 942 raw6_proc_exit();
924#endif 943#endif
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index b0d83e8e4252..12c5a4dec09e 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -354,10 +354,9 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
354 if (!pskb_may_pull(skb, ah_hlen)) 354 if (!pskb_may_pull(skb, ah_hlen))
355 goto out; 355 goto out;
356 356
357 tmp_hdr = kmalloc(hdr_len, GFP_ATOMIC); 357 tmp_hdr = kmemdup(skb->nh.raw, hdr_len, GFP_ATOMIC);
358 if (!tmp_hdr) 358 if (!tmp_hdr)
359 goto out; 359 goto out;
360 memcpy(tmp_hdr, skb->nh.raw, hdr_len);
361 if (ipv6_clear_mutable_options(skb->nh.ipv6h, hdr_len, XFRM_POLICY_IN)) 360 if (ipv6_clear_mutable_options(skb->nh.ipv6h, hdr_len, XFRM_POLICY_IN))
362 goto free_out; 361 goto free_out;
363 skb->nh.ipv6h->priority = 0; 362 skb->nh.ipv6h->priority = 0;
@@ -397,7 +396,7 @@ out:
397} 396}
398 397
399static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 398static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
400 int type, int code, int offset, __u32 info) 399 int type, int code, int offset, __be32 info)
401{ 400{
402 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 401 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
403 struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+offset); 402 struct ip_auth_hdr *ah = (struct ip_auth_hdr*)(skb->data+offset);
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 7206747022fc..5c94fea90e97 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -207,7 +207,7 @@ out:
207} 207}
208 208
209void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, 209void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err,
210 u16 port, u32 info, u8 *payload) 210 __be16 port, u32 info, u8 *payload)
211{ 211{
212 struct ipv6_pinfo *np = inet6_sk(sk); 212 struct ipv6_pinfo *np = inet6_sk(sk);
213 struct icmp6hdr *icmph = (struct icmp6hdr *)skb->h.raw; 213 struct icmp6hdr *icmph = (struct icmp6hdr *)skb->h.raw;
@@ -318,13 +318,13 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
318 ipv6_addr_copy(&sin->sin6_addr, 318 ipv6_addr_copy(&sin->sin6_addr,
319 (struct in6_addr *)(skb->nh.raw + serr->addr_offset)); 319 (struct in6_addr *)(skb->nh.raw + serr->addr_offset));
320 if (np->sndflow) 320 if (np->sndflow)
321 sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK; 321 sin->sin6_flowinfo = *(__be32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK;
322 if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) 322 if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
323 sin->sin6_scope_id = IP6CB(skb)->iif; 323 sin->sin6_scope_id = IP6CB(skb)->iif;
324 } else { 324 } else {
325 ipv6_addr_set(&sin->sin6_addr, 0, 0, 325 ipv6_addr_set(&sin->sin6_addr, 0, 0,
326 htonl(0xffff), 326 htonl(0xffff),
327 *(u32*)(skb->nh.raw + serr->addr_offset)); 327 *(__be32*)(skb->nh.raw + serr->addr_offset));
328 } 328 }
329 } 329 }
330 330
@@ -397,12 +397,12 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
397 } 397 }
398 398
399 if (np->rxopt.bits.rxtclass) { 399 if (np->rxopt.bits.rxtclass) {
400 int tclass = (ntohl(*(u32 *)skb->nh.ipv6h) >> 20) & 0xff; 400 int tclass = (ntohl(*(__be32 *)skb->nh.ipv6h) >> 20) & 0xff;
401 put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); 401 put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
402 } 402 }
403 403
404 if (np->rxopt.bits.rxflow && (*(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) { 404 if (np->rxopt.bits.rxflow && (*(__be32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) {
405 u32 flowinfo = *(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK; 405 __be32 flowinfo = *(__be32*)skb->nh.raw & IPV6_FLOWINFO_MASK;
406 put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); 406 put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo);
407 } 407 }
408 408
@@ -560,12 +560,12 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
560 } 560 }
561 561
562 if (fl->fl6_flowlabel&IPV6_FLOWINFO_MASK) { 562 if (fl->fl6_flowlabel&IPV6_FLOWINFO_MASK) {
563 if ((fl->fl6_flowlabel^*(u32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) { 563 if ((fl->fl6_flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
564 err = -EINVAL; 564 err = -EINVAL;
565 goto exit_f; 565 goto exit_f;
566 } 566 }
567 } 567 }
568 fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(u32 *)CMSG_DATA(cmsg); 568 fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg);
569 break; 569 break;
570 570
571 case IPV6_2292HOPOPTS: 571 case IPV6_2292HOPOPTS:
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index e78680a9985b..25dcf69cd807 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -256,7 +256,7 @@ static u32 esp6_get_max_size(struct xfrm_state *x, int mtu)
256} 256}
257 257
258static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 258static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
259 int type, int code, int offset, __u32 info) 259 int type, int code, int offset, __be32 info)
260{ 260{
261 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 261 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
262 struct ipv6_esp_hdr *esph = (struct ipv6_esp_hdr*)(skb->data+offset); 262 struct ipv6_esp_hdr *esph = (struct ipv6_esp_hdr*)(skb->data+offset);
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 88c96b10684c..0711f92d6a12 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -284,10 +284,12 @@ static int ipv6_destopt_rcv(struct sk_buff **skbp)
284#ifdef CONFIG_IPV6_MIP6 284#ifdef CONFIG_IPV6_MIP6
285 __u16 dstbuf; 285 __u16 dstbuf;
286#endif 286#endif
287 struct dst_entry *dst;
287 288
288 if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) || 289 if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) ||
289 !pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) { 290 !pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) {
290 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 291 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
292 IPSTATS_MIB_INHDRERRORS);
291 kfree_skb(skb); 293 kfree_skb(skb);
292 return -1; 294 return -1;
293 } 295 }
@@ -298,7 +300,9 @@ static int ipv6_destopt_rcv(struct sk_buff **skbp)
298 dstbuf = opt->dst1; 300 dstbuf = opt->dst1;
299#endif 301#endif
300 302
303 dst = dst_clone(skb->dst);
301 if (ip6_parse_tlv(tlvprocdestopt_lst, skbp)) { 304 if (ip6_parse_tlv(tlvprocdestopt_lst, skbp)) {
305 dst_release(dst);
302 skb = *skbp; 306 skb = *skbp;
303 skb->h.raw += ((skb->h.raw[1]+1)<<3); 307 skb->h.raw += ((skb->h.raw[1]+1)<<3);
304 opt = IP6CB(skb); 308 opt = IP6CB(skb);
@@ -310,7 +314,8 @@ static int ipv6_destopt_rcv(struct sk_buff **skbp)
310 return 1; 314 return 1;
311 } 315 }
312 316
313 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 317 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_INHDRERRORS);
318 dst_release(dst);
314 return -1; 319 return -1;
315} 320}
316 321
@@ -365,7 +370,8 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
365 370
366 if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) || 371 if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) ||
367 !pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) { 372 !pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) {
368 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 373 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
374 IPSTATS_MIB_INHDRERRORS);
369 kfree_skb(skb); 375 kfree_skb(skb);
370 return -1; 376 return -1;
371 } 377 }
@@ -374,7 +380,8 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
374 380
375 if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr) || 381 if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr) ||
376 skb->pkt_type != PACKET_HOST) { 382 skb->pkt_type != PACKET_HOST) {
377 IP6_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS); 383 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
384 IPSTATS_MIB_INADDRERRORS);
378 kfree_skb(skb); 385 kfree_skb(skb);
379 return -1; 386 return -1;
380 } 387 }
@@ -388,7 +395,8 @@ looped_back:
388 * processed by own 395 * processed by own
389 */ 396 */
390 if (!addr) { 397 if (!addr) {
391 IP6_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS); 398 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
399 IPSTATS_MIB_INADDRERRORS);
392 kfree_skb(skb); 400 kfree_skb(skb);
393 return -1; 401 return -1;
394 } 402 }
@@ -410,7 +418,8 @@ looped_back:
410 switch (hdr->type) { 418 switch (hdr->type) {
411 case IPV6_SRCRT_TYPE_0: 419 case IPV6_SRCRT_TYPE_0:
412 if (hdr->hdrlen & 0x01) { 420 if (hdr->hdrlen & 0x01) {
413 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 421 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
422 IPSTATS_MIB_INHDRERRORS);
414 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->hdrlen) - skb->nh.raw); 423 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->hdrlen) - skb->nh.raw);
415 return -1; 424 return -1;
416 } 425 }
@@ -419,14 +428,16 @@ looped_back:
419 case IPV6_SRCRT_TYPE_2: 428 case IPV6_SRCRT_TYPE_2:
420 /* Silently discard invalid RTH type 2 */ 429 /* Silently discard invalid RTH type 2 */
421 if (hdr->hdrlen != 2 || hdr->segments_left != 1) { 430 if (hdr->hdrlen != 2 || hdr->segments_left != 1) {
422 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 431 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
432 IPSTATS_MIB_INHDRERRORS);
423 kfree_skb(skb); 433 kfree_skb(skb);
424 return -1; 434 return -1;
425 } 435 }
426 break; 436 break;
427#endif 437#endif
428 default: 438 default:
429 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 439 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
440 IPSTATS_MIB_INHDRERRORS);
430 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw); 441 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw);
431 return -1; 442 return -1;
432 } 443 }
@@ -439,7 +450,8 @@ looped_back:
439 n = hdr->hdrlen >> 1; 450 n = hdr->hdrlen >> 1;
440 451
441 if (hdr->segments_left > n) { 452 if (hdr->segments_left > n) {
442 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 453 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
454 IPSTATS_MIB_INHDRERRORS);
443 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->segments_left) - skb->nh.raw); 455 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->segments_left) - skb->nh.raw);
444 return -1; 456 return -1;
445 } 457 }
@@ -449,12 +461,14 @@ looped_back:
449 */ 461 */
450 if (skb_cloned(skb)) { 462 if (skb_cloned(skb)) {
451 struct sk_buff *skb2 = skb_copy(skb, GFP_ATOMIC); 463 struct sk_buff *skb2 = skb_copy(skb, GFP_ATOMIC);
452 kfree_skb(skb);
453 /* the copy is a forwarded packet */ 464 /* the copy is a forwarded packet */
454 if (skb2 == NULL) { 465 if (skb2 == NULL) {
455 IP6_INC_STATS_BH(IPSTATS_MIB_OUTDISCARDS); 466 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
467 IPSTATS_MIB_OUTDISCARDS);
468 kfree_skb(skb);
456 return -1; 469 return -1;
457 } 470 }
471 kfree_skb(skb);
458 *skbp = skb = skb2; 472 *skbp = skb = skb2;
459 opt = IP6CB(skb2); 473 opt = IP6CB(skb2);
460 hdr = (struct ipv6_rt_hdr *) skb2->h.raw; 474 hdr = (struct ipv6_rt_hdr *) skb2->h.raw;
@@ -475,12 +489,14 @@ looped_back:
475 if (xfrm6_input_addr(skb, (xfrm_address_t *)addr, 489 if (xfrm6_input_addr(skb, (xfrm_address_t *)addr,
476 (xfrm_address_t *)&skb->nh.ipv6h->saddr, 490 (xfrm_address_t *)&skb->nh.ipv6h->saddr,
477 IPPROTO_ROUTING) < 0) { 491 IPPROTO_ROUTING) < 0) {
478 IP6_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS); 492 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
493 IPSTATS_MIB_INADDRERRORS);
479 kfree_skb(skb); 494 kfree_skb(skb);
480 return -1; 495 return -1;
481 } 496 }
482 if (!ipv6_chk_home_addr(addr)) { 497 if (!ipv6_chk_home_addr(addr)) {
483 IP6_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS); 498 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
499 IPSTATS_MIB_INADDRERRORS);
484 kfree_skb(skb); 500 kfree_skb(skb);
485 return -1; 501 return -1;
486 } 502 }
@@ -491,7 +507,8 @@ looped_back:
491 } 507 }
492 508
493 if (ipv6_addr_is_multicast(addr)) { 509 if (ipv6_addr_is_multicast(addr)) {
494 IP6_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS); 510 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
511 IPSTATS_MIB_INADDRERRORS);
495 kfree_skb(skb); 512 kfree_skb(skb);
496 return -1; 513 return -1;
497 } 514 }
@@ -510,7 +527,8 @@ looped_back:
510 527
511 if (skb->dst->dev->flags&IFF_LOOPBACK) { 528 if (skb->dst->dev->flags&IFF_LOOPBACK) {
512 if (skb->nh.ipv6h->hop_limit <= 1) { 529 if (skb->nh.ipv6h->hop_limit <= 1) {
513 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 530 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
531 IPSTATS_MIB_INHDRERRORS);
514 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT, 532 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT,
515 0, skb->dev); 533 0, skb->dev);
516 kfree_skb(skb); 534 kfree_skb(skb);
@@ -632,24 +650,25 @@ static int ipv6_hop_jumbo(struct sk_buff **skbp, int optoff)
632 if (skb->nh.raw[optoff+1] != 4 || (optoff&3) != 2) { 650 if (skb->nh.raw[optoff+1] != 4 || (optoff&3) != 2) {
633 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", 651 LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n",
634 skb->nh.raw[optoff+1]); 652 skb->nh.raw[optoff+1]);
635 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 653 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
654 IPSTATS_MIB_INHDRERRORS);
636 goto drop; 655 goto drop;
637 } 656 }
638 657
639 pkt_len = ntohl(*(u32*)(skb->nh.raw+optoff+2)); 658 pkt_len = ntohl(*(__be32*)(skb->nh.raw+optoff+2));
640 if (pkt_len <= IPV6_MAXPLEN) { 659 if (pkt_len <= IPV6_MAXPLEN) {
641 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 660 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS);
642 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2); 661 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2);
643 return 0; 662 return 0;
644 } 663 }
645 if (skb->nh.ipv6h->payload_len) { 664 if (skb->nh.ipv6h->payload_len) {
646 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 665 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS);
647 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff); 666 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff);
648 return 0; 667 return 0;
649 } 668 }
650 669
651 if (pkt_len > skb->len - sizeof(struct ipv6hdr)) { 670 if (pkt_len > skb->len - sizeof(struct ipv6hdr)) {
652 IP6_INC_STATS_BH(IPSTATS_MIB_INTRUNCATEDPKTS); 671 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INTRUNCATEDPKTS);
653 goto drop; 672 goto drop;
654 } 673 }
655 674
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 315bc1fbec3f..21cbbbddaf4d 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -77,7 +77,7 @@ int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp)
77 if (hp == NULL) 77 if (hp == NULL)
78 return -1; 78 return -1;
79 if (nexthdr == NEXTHDR_FRAGMENT) { 79 if (nexthdr == NEXTHDR_FRAGMENT) {
80 unsigned short _frag_off, *fp; 80 __be16 _frag_off, *fp;
81 fp = skb_header_pointer(skb, 81 fp = skb_header_pointer(skb,
82 start+offsetof(struct frag_hdr, 82 start+offsetof(struct frag_hdr,
83 frag_off), 83 frag_off),
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 1896ecb52899..0862809ffcf7 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -25,10 +25,6 @@ struct fib6_rule
25 struct fib_rule common; 25 struct fib_rule common;
26 struct rt6key src; 26 struct rt6key src;
27 struct rt6key dst; 27 struct rt6key dst;
28#ifdef CONFIG_IPV6_ROUTE_FWMARK
29 u32 fwmark;
30 u32 fwmask;
31#endif
32 u8 tclass; 28 u8 tclass;
33}; 29};
34 30
@@ -67,7 +63,7 @@ struct dst_entry *fib6_rule_lookup(struct flowi *fl, int flags,
67 fib_rule_put(arg.rule); 63 fib_rule_put(arg.rule);
68 64
69 if (arg.result) 65 if (arg.result)
70 return (struct dst_entry *) arg.result; 66 return arg.result;
71 67
72 dst_hold(&ip6_null_entry.u.dst); 68 dst_hold(&ip6_null_entry.u.dst);
73 return &ip6_null_entry.u.dst; 69 return &ip6_null_entry.u.dst;
@@ -130,22 +126,13 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
130 if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff)) 126 if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff))
131 return 0; 127 return 0;
132 128
133#ifdef CONFIG_IPV6_ROUTE_FWMARK
134 if ((r->fwmark ^ fl->fl6_fwmark) & r->fwmask)
135 return 0;
136#endif
137
138 return 1; 129 return 1;
139} 130}
140 131
141static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = { 132static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = {
142 [FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 }, 133 FRA_GENERIC_POLICY,
143 [FRA_PRIORITY] = { .type = NLA_U32 },
144 [FRA_SRC] = { .len = sizeof(struct in6_addr) }, 134 [FRA_SRC] = { .len = sizeof(struct in6_addr) },
145 [FRA_DST] = { .len = sizeof(struct in6_addr) }, 135 [FRA_DST] = { .len = sizeof(struct in6_addr) },
146 [FRA_FWMARK] = { .type = NLA_U32 },
147 [FRA_FWMASK] = { .type = NLA_U32 },
148 [FRA_TABLE] = { .type = NLA_U32 },
149}; 136};
150 137
151static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb, 138static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
@@ -155,8 +142,7 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
155 int err = -EINVAL; 142 int err = -EINVAL;
156 struct fib6_rule *rule6 = (struct fib6_rule *) rule; 143 struct fib6_rule *rule6 = (struct fib6_rule *) rule;
157 144
158 if (frh->src_len > 128 || frh->dst_len > 128 || 145 if (frh->src_len > 128 || frh->dst_len > 128)
159 (frh->tos & ~IPV6_FLOWINFO_MASK))
160 goto errout; 146 goto errout;
161 147
162 if (rule->action == FR_ACT_TO_TBL) { 148 if (rule->action == FR_ACT_TO_TBL) {
@@ -177,23 +163,6 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
177 nla_memcpy(&rule6->dst.addr, tb[FRA_DST], 163 nla_memcpy(&rule6->dst.addr, tb[FRA_DST],
178 sizeof(struct in6_addr)); 164 sizeof(struct in6_addr));
179 165
180#ifdef CONFIG_IPV6_ROUTE_FWMARK
181 if (tb[FRA_FWMARK]) {
182 rule6->fwmark = nla_get_u32(tb[FRA_FWMARK]);
183 if (rule6->fwmark) {
184 /*
185 * if the mark value is non-zero,
186 * all bits are compared by default
187 * unless a mask is explicitly specified.
188 */
189 rule6->fwmask = 0xFFFFFFFF;
190 }
191 }
192
193 if (tb[FRA_FWMASK])
194 rule6->fwmask = nla_get_u32(tb[FRA_FWMASK]);
195#endif
196
197 rule6->src.plen = frh->src_len; 166 rule6->src.plen = frh->src_len;
198 rule6->dst.plen = frh->dst_len; 167 rule6->dst.plen = frh->dst_len;
199 rule6->tclass = frh->tos; 168 rule6->tclass = frh->tos;
@@ -225,14 +194,6 @@ static int fib6_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
225 nla_memcmp(tb[FRA_DST], &rule6->dst.addr, sizeof(struct in6_addr))) 194 nla_memcmp(tb[FRA_DST], &rule6->dst.addr, sizeof(struct in6_addr)))
226 return 0; 195 return 0;
227 196
228#ifdef CONFIG_IPV6_ROUTE_FWMARK
229 if (tb[FRA_FWMARK] && (rule6->fwmark != nla_get_u32(tb[FRA_FWMARK])))
230 return 0;
231
232 if (tb[FRA_FWMASK] && (rule6->fwmask != nla_get_u32(tb[FRA_FWMASK])))
233 return 0;
234#endif
235
236 return 1; 197 return 1;
237} 198}
238 199
@@ -254,14 +215,6 @@ static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
254 NLA_PUT(skb, FRA_SRC, sizeof(struct in6_addr), 215 NLA_PUT(skb, FRA_SRC, sizeof(struct in6_addr),
255 &rule6->src.addr); 216 &rule6->src.addr);
256 217
257#ifdef CONFIG_IPV6_ROUTE_FWMARK
258 if (rule6->fwmark)
259 NLA_PUT_U32(skb, FRA_FWMARK, rule6->fwmark);
260
261 if (rule6->fwmask || rule6->fwmark)
262 NLA_PUT_U32(skb, FRA_FWMASK, rule6->fwmask);
263#endif
264
265 return 0; 218 return 0;
266 219
267nla_put_failure: 220nla_put_failure:
@@ -278,6 +231,12 @@ static u32 fib6_rule_default_pref(void)
278 return 0x3FFF; 231 return 0x3FFF;
279} 232}
280 233
234static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule)
235{
236 return nla_total_size(16) /* dst */
237 + nla_total_size(16); /* src */
238}
239
281static struct fib_rules_ops fib6_rules_ops = { 240static struct fib_rules_ops fib6_rules_ops = {
282 .family = AF_INET6, 241 .family = AF_INET6,
283 .rule_size = sizeof(struct fib6_rule), 242 .rule_size = sizeof(struct fib6_rule),
@@ -287,6 +246,7 @@ static struct fib_rules_ops fib6_rules_ops = {
287 .compare = fib6_rule_compare, 246 .compare = fib6_rule_compare,
288 .fill = fib6_rule_fill, 247 .fill = fib6_rule_fill,
289 .default_pref = fib6_rule_default_pref, 248 .default_pref = fib6_rule_default_pref,
249 .nlmsg_payload = fib6_rule_nlmsg_payload,
290 .nlgroup = RTNLGRP_IPV6_RULE, 250 .nlgroup = RTNLGRP_IPV6_RULE,
291 .policy = fib6_rule_policy, 251 .policy = fib6_rule_policy,
292 .rules_list = &fib6_rules, 252 .rules_list = &fib6_rules,
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 4ec876066b3f..3dcc4b7f41b4 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -177,7 +177,8 @@ static inline int icmpv6_xrlim_allow(struct sock *sk, int type,
177 */ 177 */
178 dst = ip6_route_output(sk, fl); 178 dst = ip6_route_output(sk, fl);
179 if (dst->error) { 179 if (dst->error) {
180 IP6_INC_STATS(IPSTATS_MIB_OUTNOROUTES); 180 IP6_INC_STATS(ip6_dst_idev(dst),
181 IPSTATS_MIB_OUTNOROUTES);
181 } else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) { 182 } else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) {
182 res = 1; 183 res = 1;
183 } else { 184 } else {
@@ -233,7 +234,7 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
233 len, fl->proto, 234 len, fl->proto,
234 skb->csum); 235 skb->csum);
235 } else { 236 } else {
236 u32 tmp_csum = 0; 237 __wsum tmp_csum = 0;
237 238
238 skb_queue_walk(&sk->sk_write_queue, skb) { 239 skb_queue_walk(&sk->sk_write_queue, skb) {
239 tmp_csum = csum_add(tmp_csum, skb->csum); 240 tmp_csum = csum_add(tmp_csum, skb->csum);
@@ -241,13 +242,11 @@ static int icmpv6_push_pending_frames(struct sock *sk, struct flowi *fl, struct
241 242
242 tmp_csum = csum_partial((char *)icmp6h, 243 tmp_csum = csum_partial((char *)icmp6h,
243 sizeof(struct icmp6hdr), tmp_csum); 244 sizeof(struct icmp6hdr), tmp_csum);
244 tmp_csum = csum_ipv6_magic(&fl->fl6_src, 245 icmp6h->icmp6_cksum = csum_ipv6_magic(&fl->fl6_src,
245 &fl->fl6_dst, 246 &fl->fl6_dst,
246 len, fl->proto, tmp_csum); 247 len, fl->proto,
247 icmp6h->icmp6_cksum = tmp_csum; 248 tmp_csum);
248 } 249 }
249 if (icmp6h->icmp6_cksum == 0)
250 icmp6h->icmp6_cksum = -1;
251 ip6_push_pending_frames(sk); 250 ip6_push_pending_frames(sk);
252out: 251out:
253 return err; 252 return err;
@@ -263,7 +262,7 @@ static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, st
263{ 262{
264 struct icmpv6_msg *msg = (struct icmpv6_msg *) from; 263 struct icmpv6_msg *msg = (struct icmpv6_msg *) from;
265 struct sk_buff *org_skb = msg->skb; 264 struct sk_buff *org_skb = msg->skb;
266 __u32 csum = 0; 265 __wsum csum = 0;
267 266
268 csum = skb_copy_and_csum_bits(org_skb, msg->offset + offset, 267 csum = skb_copy_and_csum_bits(org_skb, msg->offset + offset,
269 to, len, csum); 268 to, len, csum);
@@ -555,7 +554,7 @@ out:
555 icmpv6_xmit_unlock(); 554 icmpv6_xmit_unlock();
556} 555}
557 556
558static void icmpv6_notify(struct sk_buff *skb, int type, int code, u32 info) 557static void icmpv6_notify(struct sk_buff *skb, int type, int code, __be32 info)
559{ 558{
560 struct in6_addr *saddr, *daddr; 559 struct in6_addr *saddr, *daddr;
561 struct inet6_protocol *ipprot; 560 struct inet6_protocol *ipprot;
@@ -637,8 +636,8 @@ static int icmpv6_rcv(struct sk_buff **pskb)
637 break; 636 break;
638 /* fall through */ 637 /* fall through */
639 case CHECKSUM_NONE: 638 case CHECKSUM_NONE:
640 skb->csum = ~csum_ipv6_magic(saddr, daddr, skb->len, 639 skb->csum = ~csum_unfold(csum_ipv6_magic(saddr, daddr, skb->len,
641 IPPROTO_ICMPV6, 0); 640 IPPROTO_ICMPV6, 0));
642 if (__skb_checksum_complete(skb)) { 641 if (__skb_checksum_complete(skb)) {
643 LIMIT_NETDEBUG(KERN_DEBUG "ICMPv6 checksum failed [" NIP6_FMT " > " NIP6_FMT "]\n", 642 LIMIT_NETDEBUG(KERN_DEBUG "ICMPv6 checksum failed [" NIP6_FMT " > " NIP6_FMT "]\n",
644 NIP6(*saddr), NIP6(*daddr)); 643 NIP6(*saddr), NIP6(*daddr));
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index 827f41d1478b..c700302ad51a 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -52,20 +52,20 @@ EXPORT_SYMBOL_GPL(inet6_csk_bind_conflict);
52/* 52/*
53 * request_sock (formerly open request) hash tables. 53 * request_sock (formerly open request) hash tables.
54 */ 54 */
55static u32 inet6_synq_hash(const struct in6_addr *raddr, const u16 rport, 55static u32 inet6_synq_hash(const struct in6_addr *raddr, const __be16 rport,
56 const u32 rnd, const u16 synq_hsize) 56 const u32 rnd, const u16 synq_hsize)
57{ 57{
58 u32 a = raddr->s6_addr32[0]; 58 u32 a = (__force u32)raddr->s6_addr32[0];
59 u32 b = raddr->s6_addr32[1]; 59 u32 b = (__force u32)raddr->s6_addr32[1];
60 u32 c = raddr->s6_addr32[2]; 60 u32 c = (__force u32)raddr->s6_addr32[2];
61 61
62 a += JHASH_GOLDEN_RATIO; 62 a += JHASH_GOLDEN_RATIO;
63 b += JHASH_GOLDEN_RATIO; 63 b += JHASH_GOLDEN_RATIO;
64 c += rnd; 64 c += rnd;
65 __jhash_mix(a, b, c); 65 __jhash_mix(a, b, c);
66 66
67 a += raddr->s6_addr32[3]; 67 a += (__force u32)raddr->s6_addr32[3];
68 b += (u32)rport; 68 b += (__force u32)rport;
69 __jhash_mix(a, b, c); 69 __jhash_mix(a, b, c);
70 70
71 return c & (synq_hsize - 1); 71 return c & (synq_hsize - 1);
@@ -73,7 +73,7 @@ static u32 inet6_synq_hash(const struct in6_addr *raddr, const u16 rport,
73 73
74struct request_sock *inet6_csk_search_req(const struct sock *sk, 74struct request_sock *inet6_csk_search_req(const struct sock *sk,
75 struct request_sock ***prevp, 75 struct request_sock ***prevp,
76 const __u16 rport, 76 const __be16 rport,
77 const struct in6_addr *raddr, 77 const struct in6_addr *raddr,
78 const struct in6_addr *laddr, 78 const struct in6_addr *laddr,
79 const int iif) 79 const int iif)
@@ -139,9 +139,8 @@ void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr)
139 139
140EXPORT_SYMBOL_GPL(inet6_csk_addr2sockaddr); 140EXPORT_SYMBOL_GPL(inet6_csk_addr2sockaddr);
141 141
142int inet6_csk_xmit(struct sk_buff *skb, int ipfragok) 142int inet6_csk_xmit(struct sk_buff *skb, struct sock *sk, int ipfragok)
143{ 143{
144 struct sock *sk = skb->sk;
145 struct inet_sock *inet = inet_sk(sk); 144 struct inet_sock *inet = inet_sk(sk);
146 struct ipv6_pinfo *np = inet6_sk(sk); 145 struct ipv6_pinfo *np = inet6_sk(sk);
147 struct flowi fl; 146 struct flowi fl;
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 8accd1fbeeda..b7e5bae0e347 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -57,7 +57,7 @@ EXPORT_SYMBOL(__inet6_hash);
57 */ 57 */
58struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, 58struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo,
59 const struct in6_addr *saddr, 59 const struct in6_addr *saddr,
60 const u16 sport, 60 const __be16 sport,
61 const struct in6_addr *daddr, 61 const struct in6_addr *daddr,
62 const u16 hnum, 62 const u16 hnum,
63 const int dif) 63 const int dif)
@@ -146,8 +146,8 @@ struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo,
146EXPORT_SYMBOL_GPL(inet6_lookup_listener); 146EXPORT_SYMBOL_GPL(inet6_lookup_listener);
147 147
148struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, 148struct sock *inet6_lookup(struct inet_hashinfo *hashinfo,
149 const struct in6_addr *saddr, const u16 sport, 149 const struct in6_addr *saddr, const __be16 sport,
150 const struct in6_addr *daddr, const u16 dport, 150 const struct in6_addr *daddr, const __be16 dport,
151 const int dif) 151 const int dif)
152{ 152{
153 struct sock *sk; 153 struct sock *sk;
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index f98ca30d7c1f..bf526115e518 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -139,9 +139,9 @@ static __inline__ u32 fib6_new_sernum(void)
139 * test bit 139 * test bit
140 */ 140 */
141 141
142static __inline__ int addr_bit_set(void *token, int fn_bit) 142static __inline__ __be32 addr_bit_set(void *token, int fn_bit)
143{ 143{
144 __u32 *addr = token; 144 __be32 *addr = token;
145 145
146 return htonl(1 << ((~fn_bit)&0x1F)) & addr[fn_bit>>5]; 146 return htonl(1 << ((~fn_bit)&0x1F)) & addr[fn_bit>>5];
147} 147}
@@ -434,7 +434,7 @@ static struct fib6_node * fib6_add_1(struct fib6_node *root, void *addr,
434 struct fib6_node *pn = NULL; 434 struct fib6_node *pn = NULL;
435 struct rt6key *key; 435 struct rt6key *key;
436 int bit; 436 int bit;
437 int dir = 0; 437 __be32 dir = 0;
438 __u32 sernum = fib6_new_sernum(); 438 __u32 sernum = fib6_new_sernum();
439 439
440 RT6_TRACE("fib6_add_1\n"); 440 RT6_TRACE("fib6_add_1\n");
@@ -829,7 +829,7 @@ static struct fib6_node * fib6_lookup_1(struct fib6_node *root,
829 struct lookup_args *args) 829 struct lookup_args *args)
830{ 830{
831 struct fib6_node *fn; 831 struct fib6_node *fn;
832 int dir; 832 __be32 dir;
833 833
834 if (unlikely(args->offset == 0)) 834 if (unlikely(args->offset == 0))
835 return NULL; 835 return NULL;
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 6d4533b58dca..624fae251f4e 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -61,7 +61,7 @@ static DEFINE_RWLOCK(ip6_fl_lock);
61static DEFINE_RWLOCK(ip6_sk_fl_lock); 61static DEFINE_RWLOCK(ip6_sk_fl_lock);
62 62
63 63
64static __inline__ struct ip6_flowlabel * __fl_lookup(u32 label) 64static __inline__ struct ip6_flowlabel * __fl_lookup(__be32 label)
65{ 65{
66 struct ip6_flowlabel *fl; 66 struct ip6_flowlabel *fl;
67 67
@@ -72,7 +72,7 @@ static __inline__ struct ip6_flowlabel * __fl_lookup(u32 label)
72 return NULL; 72 return NULL;
73} 73}
74 74
75static struct ip6_flowlabel * fl_lookup(u32 label) 75static struct ip6_flowlabel * fl_lookup(__be32 label)
76{ 76{
77 struct ip6_flowlabel *fl; 77 struct ip6_flowlabel *fl;
78 78
@@ -153,7 +153,7 @@ static void ip6_fl_gc(unsigned long dummy)
153 write_unlock(&ip6_fl_lock); 153 write_unlock(&ip6_fl_lock);
154} 154}
155 155
156static int fl_intern(struct ip6_flowlabel *fl, __u32 label) 156static int fl_intern(struct ip6_flowlabel *fl, __be32 label)
157{ 157{
158 fl->label = label & IPV6_FLOWLABEL_MASK; 158 fl->label = label & IPV6_FLOWLABEL_MASK;
159 159
@@ -182,7 +182,7 @@ static int fl_intern(struct ip6_flowlabel *fl, __u32 label)
182 182
183/* Socket flowlabel lists */ 183/* Socket flowlabel lists */
184 184
185struct ip6_flowlabel * fl6_sock_lookup(struct sock *sk, u32 label) 185struct ip6_flowlabel * fl6_sock_lookup(struct sock *sk, __be32 label)
186{ 186{
187 struct ipv6_fl_socklist *sfl; 187 struct ipv6_fl_socklist *sfl;
188 struct ipv6_pinfo *np = inet6_sk(sk); 188 struct ipv6_pinfo *np = inet6_sk(sk);
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 6b8e6d76a58b..ad0b8abcdf4b 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -60,14 +60,22 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
60{ 60{
61 struct ipv6hdr *hdr; 61 struct ipv6hdr *hdr;
62 u32 pkt_len; 62 u32 pkt_len;
63 struct inet6_dev *idev;
63 64
64 if (skb->pkt_type == PACKET_OTHERHOST) 65 if (skb->pkt_type == PACKET_OTHERHOST) {
65 goto drop; 66 kfree_skb(skb);
67 return 0;
68 }
69
70 rcu_read_lock();
66 71
67 IP6_INC_STATS_BH(IPSTATS_MIB_INRECEIVES); 72 idev = __in6_dev_get(skb->dev);
73
74 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INRECEIVES);
68 75
69 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) { 76 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
70 IP6_INC_STATS_BH(IPSTATS_MIB_INDISCARDS); 77 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INDISCARDS);
78 rcu_read_unlock();
71 goto out; 79 goto out;
72 } 80 }
73 81
@@ -84,7 +92,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
84 * arrived via the sending interface (ethX), because of the 92 * arrived via the sending interface (ethX), because of the
85 * nature of scoping architecture. --yoshfuji 93 * nature of scoping architecture. --yoshfuji
86 */ 94 */
87 IP6CB(skb)->iif = skb->dst ? ((struct rt6_info *)skb->dst)->rt6i_idev->dev->ifindex : dev->ifindex; 95 IP6CB(skb)->iif = skb->dst ? ip6_dst_idev(skb->dst)->dev->ifindex : dev->ifindex;
88 96
89 if (unlikely(!pskb_may_pull(skb, sizeof(*hdr)))) 97 if (unlikely(!pskb_may_pull(skb, sizeof(*hdr))))
90 goto err; 98 goto err;
@@ -104,7 +112,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
104 if (pkt_len + sizeof(struct ipv6hdr) > skb->len) 112 if (pkt_len + sizeof(struct ipv6hdr) > skb->len)
105 goto truncated; 113 goto truncated;
106 if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) { 114 if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) {
107 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 115 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INHDRERRORS);
108 goto drop; 116 goto drop;
109 } 117 }
110 hdr = skb->nh.ipv6h; 118 hdr = skb->nh.ipv6h;
@@ -112,17 +120,21 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
112 120
113 if (hdr->nexthdr == NEXTHDR_HOP) { 121 if (hdr->nexthdr == NEXTHDR_HOP) {
114 if (ipv6_parse_hopopts(&skb) < 0) { 122 if (ipv6_parse_hopopts(&skb) < 0) {
115 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 123 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INHDRERRORS);
124 rcu_read_unlock();
116 return 0; 125 return 0;
117 } 126 }
118 } 127 }
119 128
129 rcu_read_unlock();
130
120 return NF_HOOK(PF_INET6,NF_IP6_PRE_ROUTING, skb, dev, NULL, ip6_rcv_finish); 131 return NF_HOOK(PF_INET6,NF_IP6_PRE_ROUTING, skb, dev, NULL, ip6_rcv_finish);
121truncated: 132truncated:
122 IP6_INC_STATS_BH(IPSTATS_MIB_INTRUNCATEDPKTS); 133 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INTRUNCATEDPKTS);
123err: 134err:
124 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 135 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INHDRERRORS);
125drop: 136drop:
137 rcu_read_unlock();
126 kfree_skb(skb); 138 kfree_skb(skb);
127out: 139out:
128 return 0; 140 return 0;
@@ -140,6 +152,7 @@ static inline int ip6_input_finish(struct sk_buff *skb)
140 unsigned int nhoff; 152 unsigned int nhoff;
141 int nexthdr; 153 int nexthdr;
142 u8 hash; 154 u8 hash;
155 struct inet6_dev *idev;
143 156
144 /* 157 /*
145 * Parse extension headers 158 * Parse extension headers
@@ -147,6 +160,7 @@ static inline int ip6_input_finish(struct sk_buff *skb)
147 160
148 rcu_read_lock(); 161 rcu_read_lock();
149resubmit: 162resubmit:
163 idev = ip6_dst_idev(skb->dst);
150 if (!pskb_pull(skb, skb->h.raw - skb->data)) 164 if (!pskb_pull(skb, skb->h.raw - skb->data))
151 goto discard; 165 goto discard;
152 nhoff = IP6CB(skb)->nhoff; 166 nhoff = IP6CB(skb)->nhoff;
@@ -185,24 +199,24 @@ resubmit:
185 if (ret > 0) 199 if (ret > 0)
186 goto resubmit; 200 goto resubmit;
187 else if (ret == 0) 201 else if (ret == 0)
188 IP6_INC_STATS_BH(IPSTATS_MIB_INDELIVERS); 202 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INDELIVERS);
189 } else { 203 } else {
190 if (!raw_sk) { 204 if (!raw_sk) {
191 if (xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { 205 if (xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
192 IP6_INC_STATS_BH(IPSTATS_MIB_INUNKNOWNPROTOS); 206 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INUNKNOWNPROTOS);
193 icmpv6_send(skb, ICMPV6_PARAMPROB, 207 icmpv6_send(skb, ICMPV6_PARAMPROB,
194 ICMPV6_UNK_NEXTHDR, nhoff, 208 ICMPV6_UNK_NEXTHDR, nhoff,
195 skb->dev); 209 skb->dev);
196 } 210 }
197 } else 211 } else
198 IP6_INC_STATS_BH(IPSTATS_MIB_INDELIVERS); 212 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INDELIVERS);
199 kfree_skb(skb); 213 kfree_skb(skb);
200 } 214 }
201 rcu_read_unlock(); 215 rcu_read_unlock();
202 return 0; 216 return 0;
203 217
204discard: 218discard:
205 IP6_INC_STATS_BH(IPSTATS_MIB_INDISCARDS); 219 IP6_INC_STATS_BH(idev, IPSTATS_MIB_INDISCARDS);
206 rcu_read_unlock(); 220 rcu_read_unlock();
207 kfree_skb(skb); 221 kfree_skb(skb);
208 return 0; 222 return 0;
@@ -219,7 +233,7 @@ int ip6_mc_input(struct sk_buff *skb)
219 struct ipv6hdr *hdr; 233 struct ipv6hdr *hdr;
220 int deliver; 234 int deliver;
221 235
222 IP6_INC_STATS_BH(IPSTATS_MIB_INMCASTPKTS); 236 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_INMCASTPKTS);
223 237
224 hdr = skb->nh.ipv6h; 238 hdr = skb->nh.ipv6h;
225 deliver = likely(!(skb->dev->flags & (IFF_PROMISC|IFF_ALLMULTI))) || 239 deliver = likely(!(skb->dev->flags & (IFF_PROMISC|IFF_ALLMULTI))) ||
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 66716911962e..e05ecbb1412d 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -88,7 +88,7 @@ static inline int ip6_output_finish(struct sk_buff *skb)
88 } else if (dst->neighbour) 88 } else if (dst->neighbour)
89 return dst->neighbour->output(skb); 89 return dst->neighbour->output(skb);
90 90
91 IP6_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 91 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
92 kfree_skb(skb); 92 kfree_skb(skb);
93 return -EINVAL; 93 return -EINVAL;
94 94
@@ -118,6 +118,7 @@ static int ip6_output2(struct sk_buff *skb)
118 118
119 if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr)) { 119 if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr)) {
120 struct ipv6_pinfo* np = skb->sk ? inet6_sk(skb->sk) : NULL; 120 struct ipv6_pinfo* np = skb->sk ? inet6_sk(skb->sk) : NULL;
121 struct inet6_dev *idev = ip6_dst_idev(skb->dst);
121 122
122 if (!(dev->flags & IFF_LOOPBACK) && (!np || np->mc_loop) && 123 if (!(dev->flags & IFF_LOOPBACK) && (!np || np->mc_loop) &&
123 ipv6_chk_mcast_addr(dev, &skb->nh.ipv6h->daddr, 124 ipv6_chk_mcast_addr(dev, &skb->nh.ipv6h->daddr,
@@ -133,13 +134,13 @@ static int ip6_output2(struct sk_buff *skb)
133 ip6_dev_loopback_xmit); 134 ip6_dev_loopback_xmit);
134 135
135 if (skb->nh.ipv6h->hop_limit == 0) { 136 if (skb->nh.ipv6h->hop_limit == 0) {
136 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 137 IP6_INC_STATS(idev, IPSTATS_MIB_OUTDISCARDS);
137 kfree_skb(skb); 138 kfree_skb(skb);
138 return 0; 139 return 0;
139 } 140 }
140 } 141 }
141 142
142 IP6_INC_STATS(IPSTATS_MIB_OUTMCASTPKTS); 143 IP6_INC_STATS(idev, IPSTATS_MIB_OUTMCASTPKTS);
143 } 144 }
144 145
145 return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb,NULL, skb->dev,ip6_output_finish); 146 return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb,NULL, skb->dev,ip6_output_finish);
@@ -182,12 +183,14 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
182 183
183 if (skb_headroom(skb) < head_room) { 184 if (skb_headroom(skb) < head_room) {
184 struct sk_buff *skb2 = skb_realloc_headroom(skb, head_room); 185 struct sk_buff *skb2 = skb_realloc_headroom(skb, head_room);
185 kfree_skb(skb); 186 if (skb2 == NULL) {
186 skb = skb2; 187 IP6_INC_STATS(ip6_dst_idev(skb->dst),
187 if (skb == NULL) { 188 IPSTATS_MIB_OUTDISCARDS);
188 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 189 kfree_skb(skb);
189 return -ENOBUFS; 190 return -ENOBUFS;
190 } 191 }
192 kfree_skb(skb);
193 skb = skb2;
191 if (sk) 194 if (sk)
192 skb_set_owner_w(skb, sk); 195 skb_set_owner_w(skb, sk);
193 } 196 }
@@ -217,7 +220,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
217 if (tclass < 0) 220 if (tclass < 0)
218 tclass = 0; 221 tclass = 0;
219 222
220 *(u32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel; 223 *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel;
221 224
222 hdr->payload_len = htons(seg_len); 225 hdr->payload_len = htons(seg_len);
223 hdr->nexthdr = proto; 226 hdr->nexthdr = proto;
@@ -230,7 +233,8 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
230 233
231 mtu = dst_mtu(dst); 234 mtu = dst_mtu(dst);
232 if ((skb->len <= mtu) || ipfragok || skb_is_gso(skb)) { 235 if ((skb->len <= mtu) || ipfragok || skb_is_gso(skb)) {
233 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 236 IP6_INC_STATS(ip6_dst_idev(skb->dst),
237 IPSTATS_MIB_OUTREQUESTS);
234 return NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, 238 return NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev,
235 dst_output); 239 dst_output);
236 } 240 }
@@ -239,7 +243,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
239 printk(KERN_DEBUG "IPv6: sending pkt_too_big to self\n"); 243 printk(KERN_DEBUG "IPv6: sending pkt_too_big to self\n");
240 skb->dev = dst->dev; 244 skb->dev = dst->dev;
241 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev); 245 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev);
242 IP6_INC_STATS(IPSTATS_MIB_FRAGFAILS); 246 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS);
243 kfree_skb(skb); 247 kfree_skb(skb);
244 return -EMSGSIZE; 248 return -EMSGSIZE;
245} 249}
@@ -267,7 +271,7 @@ int ip6_nd_hdr(struct sock *sk, struct sk_buff *skb, struct net_device *dev,
267 hdr = (struct ipv6hdr *) skb_put(skb, sizeof(struct ipv6hdr)); 271 hdr = (struct ipv6hdr *) skb_put(skb, sizeof(struct ipv6hdr));
268 skb->nh.ipv6h = hdr; 272 skb->nh.ipv6h = hdr;
269 273
270 *(u32*)hdr = htonl(0x60000000); 274 *(__be32*)hdr = htonl(0x60000000);
271 275
272 hdr->payload_len = htons(len); 276 hdr->payload_len = htons(len);
273 hdr->nexthdr = proto; 277 hdr->nexthdr = proto;
@@ -373,7 +377,7 @@ int ip6_forward(struct sk_buff *skb)
373 goto error; 377 goto error;
374 378
375 if (!xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) { 379 if (!xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) {
376 IP6_INC_STATS(IPSTATS_MIB_INDISCARDS); 380 IP6_INC_STATS(ip6_dst_idev(dst), IPSTATS_MIB_INDISCARDS);
377 goto drop; 381 goto drop;
378 } 382 }
379 383
@@ -406,7 +410,7 @@ int ip6_forward(struct sk_buff *skb)
406 skb->dev = dst->dev; 410 skb->dev = dst->dev;
407 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT, 411 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT,
408 0, skb->dev); 412 0, skb->dev);
409 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 413 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_INHDRERRORS);
410 414
411 kfree_skb(skb); 415 kfree_skb(skb);
412 return -ETIMEDOUT; 416 return -ETIMEDOUT;
@@ -419,13 +423,13 @@ int ip6_forward(struct sk_buff *skb)
419 if (proxied > 0) 423 if (proxied > 0)
420 return ip6_input(skb); 424 return ip6_input(skb);
421 else if (proxied < 0) { 425 else if (proxied < 0) {
422 IP6_INC_STATS(IPSTATS_MIB_INDISCARDS); 426 IP6_INC_STATS(ip6_dst_idev(dst), IPSTATS_MIB_INDISCARDS);
423 goto drop; 427 goto drop;
424 } 428 }
425 } 429 }
426 430
427 if (!xfrm6_route_forward(skb)) { 431 if (!xfrm6_route_forward(skb)) {
428 IP6_INC_STATS(IPSTATS_MIB_INDISCARDS); 432 IP6_INC_STATS(ip6_dst_idev(dst), IPSTATS_MIB_INDISCARDS);
429 goto drop; 433 goto drop;
430 } 434 }
431 dst = skb->dst; 435 dst = skb->dst;
@@ -464,14 +468,14 @@ int ip6_forward(struct sk_buff *skb)
464 /* Again, force OUTPUT device used as source address */ 468 /* Again, force OUTPUT device used as source address */
465 skb->dev = dst->dev; 469 skb->dev = dst->dev;
466 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, dst_mtu(dst), skb->dev); 470 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, dst_mtu(dst), skb->dev);
467 IP6_INC_STATS_BH(IPSTATS_MIB_INTOOBIGERRORS); 471 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_INTOOBIGERRORS);
468 IP6_INC_STATS_BH(IPSTATS_MIB_FRAGFAILS); 472 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_FRAGFAILS);
469 kfree_skb(skb); 473 kfree_skb(skb);
470 return -EMSGSIZE; 474 return -EMSGSIZE;
471 } 475 }
472 476
473 if (skb_cow(skb, dst->dev->hard_header_len)) { 477 if (skb_cow(skb, dst->dev->hard_header_len)) {
474 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 478 IP6_INC_STATS(ip6_dst_idev(dst), IPSTATS_MIB_OUTDISCARDS);
475 goto drop; 479 goto drop;
476 } 480 }
477 481
@@ -481,11 +485,11 @@ int ip6_forward(struct sk_buff *skb)
481 485
482 hdr->hop_limit--; 486 hdr->hop_limit--;
483 487
484 IP6_INC_STATS_BH(IPSTATS_MIB_OUTFORWDATAGRAMS); 488 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
485 return NF_HOOK(PF_INET6,NF_IP6_FORWARD, skb, skb->dev, dst->dev, ip6_forward_finish); 489 return NF_HOOK(PF_INET6,NF_IP6_FORWARD, skb, skb->dev, dst->dev, ip6_forward_finish);
486 490
487error: 491error:
488 IP6_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS); 492 IP6_INC_STATS_BH(ip6_dst_idev(dst), IPSTATS_MIB_INADDRERRORS);
489drop: 493drop:
490 kfree_skb(skb); 494 kfree_skb(skb);
491 return -EINVAL; 495 return -EINVAL;
@@ -499,12 +503,12 @@ static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
499 dst_release(to->dst); 503 dst_release(to->dst);
500 to->dst = dst_clone(from->dst); 504 to->dst = dst_clone(from->dst);
501 to->dev = from->dev; 505 to->dev = from->dev;
506 to->mark = from->mark;
502 507
503#ifdef CONFIG_NET_SCHED 508#ifdef CONFIG_NET_SCHED
504 to->tc_index = from->tc_index; 509 to->tc_index = from->tc_index;
505#endif 510#endif
506#ifdef CONFIG_NETFILTER 511#ifdef CONFIG_NETFILTER
507 to->nfmark = from->nfmark;
508 /* Connection association is same as pre-frag packet */ 512 /* Connection association is same as pre-frag packet */
509 nf_conntrack_put(to->nfct); 513 nf_conntrack_put(to->nfct);
510 to->nfct = from->nfct; 514 to->nfct = from->nfct;
@@ -571,7 +575,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
571 struct ipv6hdr *tmp_hdr; 575 struct ipv6hdr *tmp_hdr;
572 struct frag_hdr *fh; 576 struct frag_hdr *fh;
573 unsigned int mtu, hlen, left, len; 577 unsigned int mtu, hlen, left, len;
574 u32 frag_id = 0; 578 __be32 frag_id = 0;
575 int ptr, offset = 0, err=0; 579 int ptr, offset = 0, err=0;
576 u8 *prevhdr, nexthdr = 0; 580 u8 *prevhdr, nexthdr = 0;
577 581
@@ -620,14 +624,13 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
620 skb_shinfo(skb)->frag_list = NULL; 624 skb_shinfo(skb)->frag_list = NULL;
621 /* BUILD HEADER */ 625 /* BUILD HEADER */
622 626
623 tmp_hdr = kmalloc(hlen, GFP_ATOMIC); 627 tmp_hdr = kmemdup(skb->nh.raw, hlen, GFP_ATOMIC);
624 if (!tmp_hdr) { 628 if (!tmp_hdr) {
625 IP6_INC_STATS(IPSTATS_MIB_FRAGFAILS); 629 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS);
626 return -ENOMEM; 630 return -ENOMEM;
627 } 631 }
628 632
629 *prevhdr = NEXTHDR_FRAGMENT; 633 *prevhdr = NEXTHDR_FRAGMENT;
630 memcpy(tmp_hdr, skb->nh.raw, hlen);
631 __skb_pull(skb, hlen); 634 __skb_pull(skb, hlen);
632 fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr)); 635 fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr));
633 skb->nh.raw = __skb_push(skb, hlen); 636 skb->nh.raw = __skb_push(skb, hlen);
@@ -643,7 +646,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
643 skb->data_len = first_len - skb_headlen(skb); 646 skb->data_len = first_len - skb_headlen(skb);
644 skb->len = first_len; 647 skb->len = first_len;
645 skb->nh.ipv6h->payload_len = htons(first_len - sizeof(struct ipv6hdr)); 648 skb->nh.ipv6h->payload_len = htons(first_len - sizeof(struct ipv6hdr));
646 649
650 dst_hold(&rt->u.dst);
647 651
648 for (;;) { 652 for (;;) {
649 /* Prepare header of the next frame, 653 /* Prepare header of the next frame,
@@ -667,7 +671,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
667 671
668 err = output(skb); 672 err = output(skb);
669 if(!err) 673 if(!err)
670 IP6_INC_STATS(IPSTATS_MIB_FRAGCREATES); 674 IP6_INC_STATS(ip6_dst_idev(&rt->u.dst), IPSTATS_MIB_FRAGCREATES);
671 675
672 if (err || !frag) 676 if (err || !frag)
673 break; 677 break;
@@ -680,7 +684,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
680 kfree(tmp_hdr); 684 kfree(tmp_hdr);
681 685
682 if (err == 0) { 686 if (err == 0) {
683 IP6_INC_STATS(IPSTATS_MIB_FRAGOKS); 687 IP6_INC_STATS(ip6_dst_idev(&rt->u.dst), IPSTATS_MIB_FRAGOKS);
688 dst_release(&rt->u.dst);
684 return 0; 689 return 0;
685 } 690 }
686 691
@@ -690,7 +695,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
690 frag = skb; 695 frag = skb;
691 } 696 }
692 697
693 IP6_INC_STATS(IPSTATS_MIB_FRAGFAILS); 698 IP6_INC_STATS(ip6_dst_idev(&rt->u.dst), IPSTATS_MIB_FRAGFAILS);
699 dst_release(&rt->u.dst);
694 return err; 700 return err;
695 } 701 }
696 702
@@ -723,7 +729,8 @@ slow_path:
723 729
724 if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_RESERVED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) { 730 if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_RESERVED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) {
725 NETDEBUG(KERN_INFO "IPv6: frag: no memory for new fragment!\n"); 731 NETDEBUG(KERN_INFO "IPv6: frag: no memory for new fragment!\n");
726 IP6_INC_STATS(IPSTATS_MIB_FRAGFAILS); 732 IP6_INC_STATS(ip6_dst_idev(skb->dst),
733 IPSTATS_MIB_FRAGFAILS);
727 err = -ENOMEM; 734 err = -ENOMEM;
728 goto fail; 735 goto fail;
729 } 736 }
@@ -784,15 +791,17 @@ slow_path:
784 if (err) 791 if (err)
785 goto fail; 792 goto fail;
786 793
787 IP6_INC_STATS(IPSTATS_MIB_FRAGCREATES); 794 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGCREATES);
788 } 795 }
796 IP6_INC_STATS(ip6_dst_idev(skb->dst),
797 IPSTATS_MIB_FRAGOKS);
789 kfree_skb(skb); 798 kfree_skb(skb);
790 IP6_INC_STATS(IPSTATS_MIB_FRAGOKS);
791 return err; 799 return err;
792 800
793fail: 801fail:
802 IP6_INC_STATS(ip6_dst_idev(skb->dst),
803 IPSTATS_MIB_FRAGFAILS);
794 kfree_skb(skb); 804 kfree_skb(skb);
795 IP6_INC_STATS(IPSTATS_MIB_FRAGFAILS);
796 return err; 805 return err;
797} 806}
798 807
@@ -1265,7 +1274,7 @@ alloc_new_skb:
1265 return 0; 1274 return 0;
1266error: 1275error:
1267 inet->cork.length -= length; 1276 inet->cork.length -= length;
1268 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 1277 IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS);
1269 return err; 1278 return err;
1270} 1279}
1271 1280
@@ -1311,7 +1320,7 @@ int ip6_push_pending_frames(struct sock *sk)
1311 1320
1312 skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr)); 1321 skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr));
1313 1322
1314 *(u32*)hdr = fl->fl6_flowlabel | 1323 *(__be32*)hdr = fl->fl6_flowlabel |
1315 htonl(0x60000000 | ((int)np->cork.tclass << 20)); 1324 htonl(0x60000000 | ((int)np->cork.tclass << 20));
1316 1325
1317 if (skb->len <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) 1326 if (skb->len <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN)
@@ -1326,7 +1335,7 @@ int ip6_push_pending_frames(struct sock *sk)
1326 skb->priority = sk->sk_priority; 1335 skb->priority = sk->sk_priority;
1327 1336
1328 skb->dst = dst_clone(&rt->u.dst); 1337 skb->dst = dst_clone(&rt->u.dst);
1329 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 1338 IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTREQUESTS);
1330 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dst->dev, dst_output); 1339 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, skb->dst->dev, dst_output);
1331 if (err) { 1340 if (err) {
1332 if (err > 0) 1341 if (err > 0)
@@ -1357,7 +1366,8 @@ void ip6_flush_pending_frames(struct sock *sk)
1357 struct sk_buff *skb; 1366 struct sk_buff *skb;
1358 1367
1359 while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL) { 1368 while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL) {
1360 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 1369 IP6_INC_STATS(ip6_dst_idev(skb->dst),
1370 IPSTATS_MIB_OUTDISCARDS);
1361 kfree_skb(skb); 1371 kfree_skb(skb);
1362 } 1372 }
1363 1373
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index b9f40290d12a..8d918348f5bb 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -66,7 +66,7 @@ MODULE_LICENSE("GPL");
66 66
67#define HASH_SIZE 32 67#define HASH_SIZE 32
68 68
69#define HASH(addr) (((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \ 69#define HASH(addr) ((__force u32)((addr)->s6_addr32[0] ^ (addr)->s6_addr32[1] ^ \
70 (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \ 70 (addr)->s6_addr32[2] ^ (addr)->s6_addr32[3]) & \
71 (HASH_SIZE - 1)) 71 (HASH_SIZE - 1))
72 72
@@ -215,11 +215,10 @@ ip6ip6_tnl_unlink(struct ip6_tnl *t)
215 * Create tunnel matching given parameters. 215 * Create tunnel matching given parameters.
216 * 216 *
217 * Return: 217 * Return:
218 * 0 on success 218 * created tunnel or NULL
219 **/ 219 **/
220 220
221static int 221static struct ip6_tnl *ip6_tnl_create(struct ip6_tnl_parm *p)
222ip6_tnl_create(struct ip6_tnl_parm *p, struct ip6_tnl **pt)
223{ 222{
224 struct net_device *dev; 223 struct net_device *dev;
225 struct ip6_tnl *t; 224 struct ip6_tnl *t;
@@ -236,11 +235,11 @@ ip6_tnl_create(struct ip6_tnl_parm *p, struct ip6_tnl **pt)
236 break; 235 break;
237 } 236 }
238 if (i == IP6_TNL_MAX) 237 if (i == IP6_TNL_MAX)
239 return -ENOBUFS; 238 goto failed;
240 } 239 }
241 dev = alloc_netdev(sizeof (*t), name, ip6ip6_tnl_dev_setup); 240 dev = alloc_netdev(sizeof (*t), name, ip6ip6_tnl_dev_setup);
242 if (dev == NULL) 241 if (dev == NULL)
243 return -ENOMEM; 242 goto failed;
244 243
245 t = netdev_priv(dev); 244 t = netdev_priv(dev);
246 dev->init = ip6ip6_tnl_dev_init; 245 dev->init = ip6ip6_tnl_dev_init;
@@ -248,13 +247,13 @@ ip6_tnl_create(struct ip6_tnl_parm *p, struct ip6_tnl **pt)
248 247
249 if ((err = register_netdevice(dev)) < 0) { 248 if ((err = register_netdevice(dev)) < 0) {
250 free_netdev(dev); 249 free_netdev(dev);
251 return err; 250 goto failed;
252 } 251 }
253 dev_hold(dev); 252 dev_hold(dev);
254
255 ip6ip6_tnl_link(t); 253 ip6ip6_tnl_link(t);
256 *pt = t; 254 return t;
257 return 0; 255failed:
256 return NULL;
258} 257}
259 258
260/** 259/**
@@ -268,32 +267,23 @@ ip6_tnl_create(struct ip6_tnl_parm *p, struct ip6_tnl **pt)
268 * tunnel device is created and registered for use. 267 * tunnel device is created and registered for use.
269 * 268 *
270 * Return: 269 * Return:
271 * 0 if tunnel located or created, 270 * matching tunnel or NULL
272 * -EINVAL if parameters incorrect,
273 * -ENODEV if no matching tunnel available
274 **/ 271 **/
275 272
276static int 273static struct ip6_tnl *ip6ip6_tnl_locate(struct ip6_tnl_parm *p, int create)
277ip6ip6_tnl_locate(struct ip6_tnl_parm *p, struct ip6_tnl **pt, int create)
278{ 274{
279 struct in6_addr *remote = &p->raddr; 275 struct in6_addr *remote = &p->raddr;
280 struct in6_addr *local = &p->laddr; 276 struct in6_addr *local = &p->laddr;
281 struct ip6_tnl *t; 277 struct ip6_tnl *t;
282 278
283 if (p->proto != IPPROTO_IPV6)
284 return -EINVAL;
285
286 for (t = *ip6ip6_bucket(p); t; t = t->next) { 279 for (t = *ip6ip6_bucket(p); t; t = t->next) {
287 if (ipv6_addr_equal(local, &t->parms.laddr) && 280 if (ipv6_addr_equal(local, &t->parms.laddr) &&
288 ipv6_addr_equal(remote, &t->parms.raddr)) { 281 ipv6_addr_equal(remote, &t->parms.raddr))
289 *pt = t; 282 return t;
290 return (create ? -EEXIST : 0);
291 }
292 } 283 }
293 if (!create) 284 if (!create)
294 return -ENODEV; 285 return NULL;
295 286 return ip6_tnl_create(p);
296 return ip6_tnl_create(p, pt);
297} 287}
298 288
299/** 289/**
@@ -391,7 +381,7 @@ parse_tlv_tnl_enc_lim(struct sk_buff *skb, __u8 * raw)
391 381
392static int 382static int
393ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 383ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
394 int type, int code, int offset, __u32 info) 384 int type, int code, int offset, __be32 info)
395{ 385{
396 struct ipv6hdr *ipv6h = (struct ipv6hdr *) skb->data; 386 struct ipv6hdr *ipv6h = (struct ipv6hdr *) skb->data;
397 struct ip6_tnl *t; 387 struct ip6_tnl *t;
@@ -434,12 +424,9 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
434 } 424 }
435 break; 425 break;
436 case ICMPV6_PARAMPROB: 426 case ICMPV6_PARAMPROB:
437 /* ignore if parameter problem not caused by a tunnel 427 teli = 0;
438 encapsulation limit sub-option */ 428 if (code == ICMPV6_HDR_FIELD)
439 if (code != ICMPV6_HDR_FIELD) { 429 teli = parse_tlv_tnl_enc_lim(skb, skb->data);
440 break;
441 }
442 teli = parse_tlv_tnl_enc_lim(skb, skb->data);
443 430
444 if (teli && teli == ntohl(info) - 2) { 431 if (teli && teli == ntohl(info) - 2) {
445 tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli]; 432 tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
@@ -451,6 +438,10 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
451 "tunnel!\n", t->parms.name); 438 "tunnel!\n", t->parms.name);
452 rel_msg = 1; 439 rel_msg = 1;
453 } 440 }
441 } else if (net_ratelimit()) {
442 printk(KERN_WARNING
443 "%s: Recipient unable to parse tunneled "
444 "packet!\n ", t->parms.name);
454 } 445 }
455 break; 446 break;
456 case ICMPV6_PKT_TOOBIG: 447 case ICMPV6_PKT_TOOBIG:
@@ -470,6 +461,7 @@ ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
470 if (rel_msg && pskb_may_pull(skb, offset + sizeof (*ipv6h))) { 461 if (rel_msg && pskb_may_pull(skb, offset + sizeof (*ipv6h))) {
471 struct rt6_info *rt; 462 struct rt6_info *rt;
472 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); 463 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
464
473 if (!skb2) 465 if (!skb2)
474 goto out; 466 goto out;
475 467
@@ -504,6 +496,27 @@ static inline void ip6ip6_ecn_decapsulate(struct ipv6hdr *outer_iph,
504 if (INET_ECN_is_ce(ipv6_get_dsfield(outer_iph))) 496 if (INET_ECN_is_ce(ipv6_get_dsfield(outer_iph)))
505 IP6_ECN_set_ce(inner_iph); 497 IP6_ECN_set_ce(inner_iph);
506} 498}
499static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
500{
501 struct ip6_tnl_parm *p = &t->parms;
502 int ret = 0;
503
504 if (p->flags & IP6_TNL_F_CAP_RCV) {
505 struct net_device *ldev = NULL;
506
507 if (p->link)
508 ldev = dev_get_by_index(p->link);
509
510 if ((ipv6_addr_is_multicast(&p->laddr) ||
511 likely(ipv6_chk_addr(&p->laddr, ldev, 0))) &&
512 likely(!ipv6_chk_addr(&p->raddr, NULL, 0)))
513 ret = 1;
514
515 if (ldev)
516 dev_put(ldev);
517 }
518 return ret;
519}
507 520
508/** 521/**
509 * ip6ip6_rcv - decapsulate IPv6 packet and retransmit it locally 522 * ip6ip6_rcv - decapsulate IPv6 packet and retransmit it locally
@@ -528,7 +541,7 @@ ip6ip6_rcv(struct sk_buff *skb)
528 goto discard; 541 goto discard;
529 } 542 }
530 543
531 if (!(t->parms.flags & IP6_TNL_F_CAP_RCV)) { 544 if (!ip6_tnl_rcv_ctl(t)) {
532 t->stat.rx_dropped++; 545 t->stat.rx_dropped++;
533 read_unlock(&ip6ip6_lock); 546 read_unlock(&ip6ip6_lock);
534 goto discard; 547 goto discard;
@@ -560,31 +573,23 @@ discard:
560 return 0; 573 return 0;
561} 574}
562 575
563static inline struct ipv6_txoptions *create_tel(__u8 encap_limit) 576struct ipv6_tel_txoption {
564{ 577 struct ipv6_txoptions ops;
565 struct ipv6_tlv_tnl_enc_lim *tel; 578 __u8 dst_opt[8];
566 struct ipv6_txoptions *opt; 579};
567 __u8 *raw;
568
569 int opt_len = sizeof(*opt) + 8;
570
571 if (!(opt = kzalloc(opt_len, GFP_ATOMIC))) {
572 return NULL;
573 }
574 opt->tot_len = opt_len;
575 opt->dst0opt = (struct ipv6_opt_hdr *) (opt + 1);
576 opt->opt_nflen = 8;
577 580
578 tel = (struct ipv6_tlv_tnl_enc_lim *) (opt->dst0opt + 1); 581static void init_tel_txopt(struct ipv6_tel_txoption *opt, __u8 encap_limit)
579 tel->type = IPV6_TLV_TNL_ENCAP_LIMIT; 582{
580 tel->length = 1; 583 memset(opt, 0, sizeof(struct ipv6_tel_txoption));
581 tel->encap_limit = encap_limit;
582 584
583 raw = (__u8 *) opt->dst0opt; 585 opt->dst_opt[2] = IPV6_TLV_TNL_ENCAP_LIMIT;
584 raw[5] = IPV6_TLV_PADN; 586 opt->dst_opt[3] = 1;
585 raw[6] = 1; 587 opt->dst_opt[4] = encap_limit;
588 opt->dst_opt[5] = IPV6_TLV_PADN;
589 opt->dst_opt[6] = 1;
586 590
587 return opt; 591 opt->ops.dst0opt = (struct ipv6_opt_hdr *) opt->dst_opt;
592 opt->ops.opt_nflen = 8;
588} 593}
589 594
590/** 595/**
@@ -607,6 +612,34 @@ ip6ip6_tnl_addr_conflict(struct ip6_tnl *t, struct ipv6hdr *hdr)
607 return ipv6_addr_equal(&t->parms.raddr, &hdr->saddr); 612 return ipv6_addr_equal(&t->parms.raddr, &hdr->saddr);
608} 613}
609 614
615static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
616{
617 struct ip6_tnl_parm *p = &t->parms;
618 int ret = 0;
619
620 if (p->flags & IP6_TNL_F_CAP_XMIT) {
621 struct net_device *ldev = NULL;
622
623 if (p->link)
624 ldev = dev_get_by_index(p->link);
625
626 if (unlikely(!ipv6_chk_addr(&p->laddr, ldev, 0)))
627 printk(KERN_WARNING
628 "%s xmit: Local address not yet configured!\n",
629 p->name);
630 else if (!ipv6_addr_is_multicast(&p->raddr) &&
631 unlikely(ipv6_chk_addr(&p->raddr, NULL, 0)))
632 printk(KERN_WARNING
633 "%s xmit: Routing loop! "
634 "Remote address found on this node!\n",
635 p->name);
636 else
637 ret = 1;
638 if (ldev)
639 dev_put(ldev);
640 }
641 return ret;
642}
610/** 643/**
611 * ip6ip6_tnl_xmit - encapsulate packet and send 644 * ip6ip6_tnl_xmit - encapsulate packet and send
612 * @skb: the outgoing socket buffer 645 * @skb: the outgoing socket buffer
@@ -626,8 +659,8 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
626 struct ip6_tnl *t = netdev_priv(dev); 659 struct ip6_tnl *t = netdev_priv(dev);
627 struct net_device_stats *stats = &t->stat; 660 struct net_device_stats *stats = &t->stat;
628 struct ipv6hdr *ipv6h = skb->nh.ipv6h; 661 struct ipv6hdr *ipv6h = skb->nh.ipv6h;
629 struct ipv6_txoptions *opt = NULL;
630 int encap_limit = -1; 662 int encap_limit = -1;
663 struct ipv6_tel_txoption opt;
631 __u16 offset; 664 __u16 offset;
632 struct flowi fl; 665 struct flowi fl;
633 struct dst_entry *dst; 666 struct dst_entry *dst;
@@ -644,10 +677,9 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
644 goto tx_err; 677 goto tx_err;
645 } 678 }
646 if (skb->protocol != htons(ETH_P_IPV6) || 679 if (skb->protocol != htons(ETH_P_IPV6) ||
647 !(t->parms.flags & IP6_TNL_F_CAP_XMIT) || 680 !ip6_tnl_xmit_ctl(t) || ip6ip6_tnl_addr_conflict(t, ipv6h))
648 ip6ip6_tnl_addr_conflict(t, ipv6h)) {
649 goto tx_err; 681 goto tx_err;
650 } 682
651 if ((offset = parse_tlv_tnl_enc_lim(skb, skb->nh.raw)) > 0) { 683 if ((offset = parse_tlv_tnl_enc_lim(skb, skb->nh.raw)) > 0) {
652 struct ipv6_tlv_tnl_enc_lim *tel; 684 struct ipv6_tlv_tnl_enc_lim *tel;
653 tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->nh.raw[offset]; 685 tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->nh.raw[offset];
@@ -657,20 +689,17 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
657 goto tx_err; 689 goto tx_err;
658 } 690 }
659 encap_limit = tel->encap_limit - 1; 691 encap_limit = tel->encap_limit - 1;
660 } else if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT)) { 692 } else if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
661 encap_limit = t->parms.encap_limit; 693 encap_limit = t->parms.encap_limit;
662 } 694
663 memcpy(&fl, &t->fl, sizeof (fl)); 695 memcpy(&fl, &t->fl, sizeof (fl));
664 proto = fl.proto; 696 proto = fl.proto;
665 697
666 dsfield = ipv6_get_dsfield(ipv6h); 698 dsfield = ipv6_get_dsfield(ipv6h);
667 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)) 699 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
668 fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_TCLASS_MASK); 700 fl.fl6_flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
669 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)) 701 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL))
670 fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_FLOWLABEL_MASK); 702 fl.fl6_flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK);
671
672 if (encap_limit >= 0 && (opt = create_tel(encap_limit)) == NULL)
673 goto tx_err;
674 703
675 if ((dst = ip6_tnl_dst_check(t)) != NULL) 704 if ((dst = ip6_tnl_dst_check(t)) != NULL)
676 dst_hold(dst); 705 dst_hold(dst);
@@ -692,7 +721,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
692 goto tx_err_dst_release; 721 goto tx_err_dst_release;
693 } 722 }
694 mtu = dst_mtu(dst) - sizeof (*ipv6h); 723 mtu = dst_mtu(dst) - sizeof (*ipv6h);
695 if (opt) { 724 if (encap_limit >= 0) {
696 max_headroom += 8; 725 max_headroom += 8;
697 mtu -= 8; 726 mtu -= 8;
698 } 727 }
@@ -730,12 +759,13 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
730 759
731 skb->h.raw = skb->nh.raw; 760 skb->h.raw = skb->nh.raw;
732 761
733 if (opt) 762 if (encap_limit >= 0) {
734 ipv6_push_nfrag_opts(skb, opt, &proto, NULL); 763 init_tel_txopt(&opt, encap_limit);
735 764 ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);
765 }
736 skb->nh.raw = skb_push(skb, sizeof(struct ipv6hdr)); 766 skb->nh.raw = skb_push(skb, sizeof(struct ipv6hdr));
737 ipv6h = skb->nh.ipv6h; 767 ipv6h = skb->nh.ipv6h;
738 *(u32*)ipv6h = fl.fl6_flowlabel | htonl(0x60000000); 768 *(__be32*)ipv6h = fl.fl6_flowlabel | htonl(0x60000000);
739 dsfield = INET_ECN_encapsulate(0, dsfield); 769 dsfield = INET_ECN_encapsulate(0, dsfield);
740 ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield); 770 ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield);
741 ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); 771 ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
@@ -748,7 +778,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
748 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, 778 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL,
749 skb->dst->dev, dst_output); 779 skb->dst->dev, dst_output);
750 780
751 if (err == NET_XMIT_SUCCESS || err == NET_XMIT_CN) { 781 if (net_xmit_eval(err) == 0) {
752 stats->tx_bytes += pkt_len; 782 stats->tx_bytes += pkt_len;
753 stats->tx_packets++; 783 stats->tx_packets++;
754 } else { 784 } else {
@@ -756,9 +786,6 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
756 stats->tx_aborted_errors++; 786 stats->tx_aborted_errors++;
757 } 787 }
758 ip6_tnl_dst_store(t, dst); 788 ip6_tnl_dst_store(t, dst);
759
760 kfree(opt);
761
762 t->recursion--; 789 t->recursion--;
763 return 0; 790 return 0;
764tx_err_link_failure: 791tx_err_link_failure:
@@ -766,7 +793,6 @@ tx_err_link_failure:
766 dst_link_failure(skb); 793 dst_link_failure(skb);
767tx_err_dst_release: 794tx_err_dst_release:
768 dst_release(dst); 795 dst_release(dst);
769 kfree(opt);
770tx_err: 796tx_err:
771 stats->tx_errors++; 797 stats->tx_errors++;
772 stats->tx_dropped++; 798 stats->tx_dropped++;
@@ -778,39 +804,19 @@ tx_err:
778static void ip6_tnl_set_cap(struct ip6_tnl *t) 804static void ip6_tnl_set_cap(struct ip6_tnl *t)
779{ 805{
780 struct ip6_tnl_parm *p = &t->parms; 806 struct ip6_tnl_parm *p = &t->parms;
781 struct in6_addr *laddr = &p->laddr; 807 int ltype = ipv6_addr_type(&p->laddr);
782 struct in6_addr *raddr = &p->raddr; 808 int rtype = ipv6_addr_type(&p->raddr);
783 int ltype = ipv6_addr_type(laddr);
784 int rtype = ipv6_addr_type(raddr);
785 809
786 p->flags &= ~(IP6_TNL_F_CAP_XMIT|IP6_TNL_F_CAP_RCV); 810 p->flags &= ~(IP6_TNL_F_CAP_XMIT|IP6_TNL_F_CAP_RCV);
787 811
788 if (ltype != IPV6_ADDR_ANY && rtype != IPV6_ADDR_ANY && 812 if (ltype & (IPV6_ADDR_UNICAST|IPV6_ADDR_MULTICAST) &&
789 ((ltype|rtype) & 813 rtype & (IPV6_ADDR_UNICAST|IPV6_ADDR_MULTICAST) &&
790 (IPV6_ADDR_UNICAST| 814 !((ltype|rtype) & IPV6_ADDR_LOOPBACK) &&
791 IPV6_ADDR_LOOPBACK|IPV6_ADDR_LINKLOCAL| 815 (!((ltype|rtype) & IPV6_ADDR_LINKLOCAL) || p->link)) {
792 IPV6_ADDR_MAPPED|IPV6_ADDR_RESERVED)) == IPV6_ADDR_UNICAST) { 816 if (ltype&IPV6_ADDR_UNICAST)
793 struct net_device *ldev = NULL; 817 p->flags |= IP6_TNL_F_CAP_XMIT;
794 int l_ok = 1; 818 if (rtype&IPV6_ADDR_UNICAST)
795 int r_ok = 1; 819 p->flags |= IP6_TNL_F_CAP_RCV;
796
797 if (p->link)
798 ldev = dev_get_by_index(p->link);
799
800 if (ltype&IPV6_ADDR_UNICAST && !ipv6_chk_addr(laddr, ldev, 0))
801 l_ok = 0;
802
803 if (rtype&IPV6_ADDR_UNICAST && ipv6_chk_addr(raddr, NULL, 0))
804 r_ok = 0;
805
806 if (l_ok && r_ok) {
807 if (ltype&IPV6_ADDR_UNICAST)
808 p->flags |= IP6_TNL_F_CAP_XMIT;
809 if (rtype&IPV6_ADDR_UNICAST)
810 p->flags |= IP6_TNL_F_CAP_RCV;
811 }
812 if (ldev)
813 dev_put(ldev);
814 } 820 }
815} 821}
816 822
@@ -844,8 +850,11 @@ static void ip6ip6_tnl_link_config(struct ip6_tnl *t)
844 dev->iflink = p->link; 850 dev->iflink = p->link;
845 851
846 if (p->flags & IP6_TNL_F_CAP_XMIT) { 852 if (p->flags & IP6_TNL_F_CAP_XMIT) {
853 int strict = (ipv6_addr_type(&p->raddr) &
854 (IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL));
855
847 struct rt6_info *rt = rt6_lookup(&p->raddr, &p->laddr, 856 struct rt6_info *rt = rt6_lookup(&p->raddr, &p->laddr,
848 p->link, 0); 857 p->link, strict);
849 858
850 if (rt == NULL) 859 if (rt == NULL)
851 return; 860 return;
@@ -920,26 +929,20 @@ static int
920ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 929ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
921{ 930{
922 int err = 0; 931 int err = 0;
923 int create;
924 struct ip6_tnl_parm p; 932 struct ip6_tnl_parm p;
925 struct ip6_tnl *t = NULL; 933 struct ip6_tnl *t = NULL;
926 934
927 switch (cmd) { 935 switch (cmd) {
928 case SIOCGETTUNNEL: 936 case SIOCGETTUNNEL:
929 if (dev == ip6ip6_fb_tnl_dev) { 937 if (dev == ip6ip6_fb_tnl_dev) {
930 if (copy_from_user(&p, 938 if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof (p))) {
931 ifr->ifr_ifru.ifru_data,
932 sizeof (p))) {
933 err = -EFAULT; 939 err = -EFAULT;
934 break; 940 break;
935 } 941 }
936 if ((err = ip6ip6_tnl_locate(&p, &t, 0)) == -ENODEV) 942 t = ip6ip6_tnl_locate(&p, 0);
937 t = netdev_priv(dev); 943 }
938 else if (err) 944 if (t == NULL)
939 break;
940 } else
941 t = netdev_priv(dev); 945 t = netdev_priv(dev);
942
943 memcpy(&p, &t->parms, sizeof (p)); 946 memcpy(&p, &t->parms, sizeof (p));
944 if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof (p))) { 947 if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof (p))) {
945 err = -EFAULT; 948 err = -EFAULT;
@@ -948,35 +951,36 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
948 case SIOCADDTUNNEL: 951 case SIOCADDTUNNEL:
949 case SIOCCHGTUNNEL: 952 case SIOCCHGTUNNEL:
950 err = -EPERM; 953 err = -EPERM;
951 create = (cmd == SIOCADDTUNNEL);
952 if (!capable(CAP_NET_ADMIN)) 954 if (!capable(CAP_NET_ADMIN))
953 break; 955 break;
954 if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof (p))) { 956 err = -EFAULT;
955 err = -EFAULT; 957 if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof (p)))
956 break; 958 break;
957 } 959 err = -EINVAL;
958 if (!create && dev != ip6ip6_fb_tnl_dev) { 960 if (p.proto != IPPROTO_IPV6)
959 t = netdev_priv(dev);
960 }
961 if (!t && (err = ip6ip6_tnl_locate(&p, &t, create))) {
962 break; 961 break;
963 } 962 t = ip6ip6_tnl_locate(&p, cmd == SIOCADDTUNNEL);
964 if (cmd == SIOCCHGTUNNEL) { 963 if (dev != ip6ip6_fb_tnl_dev && cmd == SIOCCHGTUNNEL) {
965 if (t->dev != dev) { 964 if (t != NULL) {
966 err = -EEXIST; 965 if (t->dev != dev) {
967 break; 966 err = -EEXIST;
968 } 967 break;
968 }
969 } else
970 t = netdev_priv(dev);
971
969 ip6ip6_tnl_unlink(t); 972 ip6ip6_tnl_unlink(t);
970 err = ip6ip6_tnl_change(t, &p); 973 err = ip6ip6_tnl_change(t, &p);
971 ip6ip6_tnl_link(t); 974 ip6ip6_tnl_link(t);
972 netdev_state_change(dev); 975 netdev_state_change(dev);
973 } 976 }
974 if (copy_to_user(ifr->ifr_ifru.ifru_data, 977 if (t) {
975 &t->parms, sizeof (p))) {
976 err = -EFAULT;
977 } else {
978 err = 0; 978 err = 0;
979 } 979 if (copy_to_user(ifr->ifr_ifru.ifru_data, &t->parms, sizeof (p)))
980 err = -EFAULT;
981
982 } else
983 err = (cmd == SIOCADDTUNNEL ? -ENOBUFS : -ENOENT);
980 break; 984 break;
981 case SIOCDELTUNNEL: 985 case SIOCDELTUNNEL:
982 err = -EPERM; 986 err = -EPERM;
@@ -984,22 +988,18 @@ ip6ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
984 break; 988 break;
985 989
986 if (dev == ip6ip6_fb_tnl_dev) { 990 if (dev == ip6ip6_fb_tnl_dev) {
987 if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, 991 err = -EFAULT;
988 sizeof (p))) { 992 if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof (p)))
989 err = -EFAULT;
990 break; 993 break;
991 } 994 err = -ENOENT;
992 err = ip6ip6_tnl_locate(&p, &t, 0); 995 if ((t = ip6ip6_tnl_locate(&p, 0)) == NULL)
993 if (err)
994 break; 996 break;
995 if (t == netdev_priv(ip6ip6_fb_tnl_dev)) { 997 err = -EPERM;
996 err = -EPERM; 998 if (t->dev == ip6ip6_fb_tnl_dev)
997 break; 999 break;
998 } 1000 dev = t->dev;
999 } else {
1000 t = netdev_priv(dev);
1001 } 1001 }
1002 err = unregister_netdevice(t->dev); 1002 err = unregister_netdevice(dev);
1003 break; 1003 break;
1004 default: 1004 default:
1005 err = -EINVAL; 1005 err = -EINVAL;
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
index 71f59f18ede8..511730b67e97 100644
--- a/net/ipv6/ipcomp6.c
+++ b/net/ipv6/ipcomp6.c
@@ -176,7 +176,7 @@ out_ok:
176} 176}
177 177
178static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 178static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
179 int type, int code, int offset, __u32 info) 179 int type, int code, int offset, __be32 info)
180{ 180{
181 __be32 spi; 181 __be32 spi;
182 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; 182 struct ipv6hdr *iph = (struct ipv6hdr*)skb->data;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index de6b91981b30..1eafcfc95e81 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -51,6 +51,7 @@
51#include <net/inet_common.h> 51#include <net/inet_common.h>
52#include <net/tcp.h> 52#include <net/tcp.h>
53#include <net/udp.h> 53#include <net/udp.h>
54#include <net/udplite.h>
54#include <net/xfrm.h> 55#include <net/xfrm.h>
55 56
56#include <asm/uaccess.h> 57#include <asm/uaccess.h>
@@ -239,6 +240,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
239 struct sk_buff *pktopt; 240 struct sk_buff *pktopt;
240 241
241 if (sk->sk_protocol != IPPROTO_UDP && 242 if (sk->sk_protocol != IPPROTO_UDP &&
243 sk->sk_protocol != IPPROTO_UDPLITE &&
242 sk->sk_protocol != IPPROTO_TCP) 244 sk->sk_protocol != IPPROTO_TCP)
243 break; 245 break;
244 246
@@ -276,11 +278,15 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
276 sk->sk_family = PF_INET; 278 sk->sk_family = PF_INET;
277 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); 279 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
278 } else { 280 } else {
281 struct proto *prot = &udp_prot;
282
283 if (sk->sk_protocol == IPPROTO_UDPLITE)
284 prot = &udplite_prot;
279 local_bh_disable(); 285 local_bh_disable();
280 sock_prot_dec_use(sk->sk_prot); 286 sock_prot_dec_use(sk->sk_prot);
281 sock_prot_inc_use(&udp_prot); 287 sock_prot_inc_use(prot);
282 local_bh_enable(); 288 local_bh_enable();
283 sk->sk_prot = &udp_prot; 289 sk->sk_prot = prot;
284 sk->sk_socket->ops = &inet_dgram_ops; 290 sk->sk_socket->ops = &inet_dgram_ops;
285 sk->sk_family = PF_INET; 291 sk->sk_family = PF_INET;
286 } 292 }
@@ -813,6 +819,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
813 switch (optname) { 819 switch (optname) {
814 case IPV6_ADDRFORM: 820 case IPV6_ADDRFORM:
815 if (sk->sk_protocol != IPPROTO_UDP && 821 if (sk->sk_protocol != IPPROTO_UDP &&
822 sk->sk_protocol != IPPROTO_UDPLITE &&
816 sk->sk_protocol != IPPROTO_TCP) 823 sk->sk_protocol != IPPROTO_TCP)
817 return -EINVAL; 824 return -EINVAL;
818 if (sk->sk_state != TCP_ESTABLISHED) 825 if (sk->sk_state != TCP_ESTABLISHED)
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 3b114e3fa2f8..a1c231a04ac2 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -83,7 +83,7 @@
83struct mld2_grec { 83struct mld2_grec {
84 __u8 grec_type; 84 __u8 grec_type;
85 __u8 grec_auxwords; 85 __u8 grec_auxwords;
86 __u16 grec_nsrcs; 86 __be16 grec_nsrcs;
87 struct in6_addr grec_mca; 87 struct in6_addr grec_mca;
88 struct in6_addr grec_src[0]; 88 struct in6_addr grec_src[0];
89}; 89};
@@ -91,18 +91,18 @@ struct mld2_grec {
91struct mld2_report { 91struct mld2_report {
92 __u8 type; 92 __u8 type;
93 __u8 resv1; 93 __u8 resv1;
94 __u16 csum; 94 __sum16 csum;
95 __u16 resv2; 95 __be16 resv2;
96 __u16 ngrec; 96 __be16 ngrec;
97 struct mld2_grec grec[0]; 97 struct mld2_grec grec[0];
98}; 98};
99 99
100struct mld2_query { 100struct mld2_query {
101 __u8 type; 101 __u8 type;
102 __u8 code; 102 __u8 code;
103 __u16 csum; 103 __sum16 csum;
104 __u16 mrc; 104 __be16 mrc;
105 __u16 resv1; 105 __be16 resv1;
106 struct in6_addr mca; 106 struct in6_addr mca;
107#if defined(__LITTLE_ENDIAN_BITFIELD) 107#if defined(__LITTLE_ENDIAN_BITFIELD)
108 __u8 qrv:3, 108 __u8 qrv:3,
@@ -116,7 +116,7 @@ struct mld2_query {
116#error "Please fix <asm/byteorder.h>" 116#error "Please fix <asm/byteorder.h>"
117#endif 117#endif
118 __u8 qqic; 118 __u8 qqic;
119 __u16 nsrcs; 119 __be16 nsrcs;
120 struct in6_addr srcs[0]; 120 struct in6_addr srcs[0];
121}; 121};
122 122
@@ -1465,7 +1465,7 @@ static void mld_sendpack(struct sk_buff *skb)
1465 struct inet6_dev *idev = in6_dev_get(skb->dev); 1465 struct inet6_dev *idev = in6_dev_get(skb->dev);
1466 int err; 1466 int err;
1467 1467
1468 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 1468 IP6_INC_STATS(idev, IPSTATS_MIB_OUTREQUESTS);
1469 payload_len = skb->tail - (unsigned char *)skb->nh.ipv6h - 1469 payload_len = skb->tail - (unsigned char *)skb->nh.ipv6h -
1470 sizeof(struct ipv6hdr); 1470 sizeof(struct ipv6hdr);
1471 mldlen = skb->tail - skb->h.raw; 1471 mldlen = skb->tail - skb->h.raw;
@@ -1477,9 +1477,9 @@ static void mld_sendpack(struct sk_buff *skb)
1477 mld_dev_queue_xmit); 1477 mld_dev_queue_xmit);
1478 if (!err) { 1478 if (!err) {
1479 ICMP6_INC_STATS(idev,ICMP6_MIB_OUTMSGS); 1479 ICMP6_INC_STATS(idev,ICMP6_MIB_OUTMSGS);
1480 IP6_INC_STATS(IPSTATS_MIB_OUTMCASTPKTS); 1480 IP6_INC_STATS(idev, IPSTATS_MIB_OUTMCASTPKTS);
1481 } else 1481 } else
1482 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 1482 IP6_INC_STATS(idev, IPSTATS_MIB_OUTDISCARDS);
1483 1483
1484 if (likely(idev != NULL)) 1484 if (likely(idev != NULL))
1485 in6_dev_put(idev); 1485 in6_dev_put(idev);
@@ -1763,7 +1763,10 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1763 IPV6_TLV_ROUTERALERT, 2, 0, 0, 1763 IPV6_TLV_ROUTERALERT, 2, 0, 0,
1764 IPV6_TLV_PADN, 0 }; 1764 IPV6_TLV_PADN, 0 };
1765 1765
1766 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 1766 rcu_read_lock();
1767 IP6_INC_STATS(__in6_dev_get(dev),
1768 IPSTATS_MIB_OUTREQUESTS);
1769 rcu_read_unlock();
1767 snd_addr = addr; 1770 snd_addr = addr;
1768 if (type == ICMPV6_MGM_REDUCTION) { 1771 if (type == ICMPV6_MGM_REDUCTION) {
1769 snd_addr = &all_routers; 1772 snd_addr = &all_routers;
@@ -1777,7 +1780,10 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1777 skb = sock_alloc_send_skb(sk, LL_RESERVED_SPACE(dev) + full_len, 1, &err); 1780 skb = sock_alloc_send_skb(sk, LL_RESERVED_SPACE(dev) + full_len, 1, &err);
1778 1781
1779 if (skb == NULL) { 1782 if (skb == NULL) {
1780 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 1783 rcu_read_lock();
1784 IP6_INC_STATS(__in6_dev_get(dev),
1785 IPSTATS_MIB_OUTDISCARDS);
1786 rcu_read_unlock();
1781 return; 1787 return;
1782 } 1788 }
1783 1789
@@ -1816,9 +1822,9 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1816 else 1822 else
1817 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTGROUPMEMBRESPONSES); 1823 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTGROUPMEMBRESPONSES);
1818 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS); 1824 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTMSGS);
1819 IP6_INC_STATS(IPSTATS_MIB_OUTMCASTPKTS); 1825 IP6_INC_STATS(idev, IPSTATS_MIB_OUTMCASTPKTS);
1820 } else 1826 } else
1821 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 1827 IP6_INC_STATS(idev, IPSTATS_MIB_OUTDISCARDS);
1822 1828
1823 if (likely(idev != NULL)) 1829 if (likely(idev != NULL))
1824 in6_dev_put(idev); 1830 in6_dev_put(idev);
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index 7ccdc8fc5a31..be7dd7db65d7 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -262,10 +262,10 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb, struct
262 sel.proto = fl->proto; 262 sel.proto = fl->proto;
263 sel.dport = xfrm_flowi_dport(fl); 263 sel.dport = xfrm_flowi_dport(fl);
264 if (sel.dport) 264 if (sel.dport)
265 sel.dport_mask = ~((__u16)0); 265 sel.dport_mask = htons(~0);
266 sel.sport = xfrm_flowi_sport(fl); 266 sel.sport = xfrm_flowi_sport(fl);
267 if (sel.sport) 267 if (sel.sport)
268 sel.sport_mask = ~((__u16)0); 268 sel.sport_mask = htons(~0);
269 sel.ifindex = fl->oif; 269 sel.ifindex = fl->oif;
270 270
271 err = km_report(IPPROTO_DSTOPTS, &sel, 271 err = km_report(IPPROTO_DSTOPTS, &sel,
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 73eb8c33e9f0..56ea92837307 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -472,7 +472,9 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
472 inc_opt = 0; 472 inc_opt = 0;
473 } 473 }
474 474
475 skb = sock_alloc_send_skb(sk, MAX_HEADER + len + LL_RESERVED_SPACE(dev), 475 skb = sock_alloc_send_skb(sk,
476 (MAX_HEADER + sizeof(struct ipv6hdr) +
477 len + LL_RESERVED_SPACE(dev)),
476 1, &err); 478 1, &err);
477 479
478 if (skb == NULL) { 480 if (skb == NULL) {
@@ -513,7 +515,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh,
513 515
514 skb->dst = dst; 516 skb->dst = dst;
515 idev = in6_dev_get(dst->dev); 517 idev = in6_dev_get(dst->dev);
516 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 518 IP6_INC_STATS(idev, IPSTATS_MIB_OUTREQUESTS);
517 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output); 519 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output);
518 if (!err) { 520 if (!err) {
519 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS); 521 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTNEIGHBORADVERTISEMENTS);
@@ -561,7 +563,9 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
561 if (send_llinfo) 563 if (send_llinfo)
562 len += ndisc_opt_addr_space(dev); 564 len += ndisc_opt_addr_space(dev);
563 565
564 skb = sock_alloc_send_skb(sk, MAX_HEADER + len + LL_RESERVED_SPACE(dev), 566 skb = sock_alloc_send_skb(sk,
567 (MAX_HEADER + sizeof(struct ipv6hdr) +
568 len + LL_RESERVED_SPACE(dev)),
565 1, &err); 569 1, &err);
566 if (skb == NULL) { 570 if (skb == NULL) {
567 ND_PRINTK0(KERN_ERR 571 ND_PRINTK0(KERN_ERR
@@ -597,7 +601,7 @@ void ndisc_send_ns(struct net_device *dev, struct neighbour *neigh,
597 /* send it! */ 601 /* send it! */
598 skb->dst = dst; 602 skb->dst = dst;
599 idev = in6_dev_get(dst->dev); 603 idev = in6_dev_get(dst->dev);
600 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 604 IP6_INC_STATS(idev, IPSTATS_MIB_OUTREQUESTS);
601 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output); 605 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output);
602 if (!err) { 606 if (!err) {
603 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTNEIGHBORSOLICITS); 607 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTNEIGHBORSOLICITS);
@@ -636,7 +640,9 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
636 if (dev->addr_len) 640 if (dev->addr_len)
637 len += ndisc_opt_addr_space(dev); 641 len += ndisc_opt_addr_space(dev);
638 642
639 skb = sock_alloc_send_skb(sk, MAX_HEADER + len + LL_RESERVED_SPACE(dev), 643 skb = sock_alloc_send_skb(sk,
644 (MAX_HEADER + sizeof(struct ipv6hdr) +
645 len + LL_RESERVED_SPACE(dev)),
640 1, &err); 646 1, &err);
641 if (skb == NULL) { 647 if (skb == NULL) {
642 ND_PRINTK0(KERN_ERR 648 ND_PRINTK0(KERN_ERR
@@ -670,7 +676,7 @@ void ndisc_send_rs(struct net_device *dev, struct in6_addr *saddr,
670 /* send it! */ 676 /* send it! */
671 skb->dst = dst; 677 skb->dst = dst;
672 idev = in6_dev_get(dst->dev); 678 idev = in6_dev_get(dst->dev);
673 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 679 IP6_INC_STATS(idev, IPSTATS_MIB_OUTREQUESTS);
674 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output); 680 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, dst->dev, dst_output);
675 if (!err) { 681 if (!err) {
676 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTROUTERSOLICITS); 682 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTROUTERSOLICITS);
@@ -1261,10 +1267,11 @@ skip_defrtr:
1261 } 1267 }
1262 1268
1263 if (ndopts.nd_opts_mtu) { 1269 if (ndopts.nd_opts_mtu) {
1270 __be32 n;
1264 u32 mtu; 1271 u32 mtu;
1265 1272
1266 memcpy(&mtu, ((u8*)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu)); 1273 memcpy(&n, ((u8*)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
1267 mtu = ntohl(mtu); 1274 mtu = ntohl(n);
1268 1275
1269 if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) { 1276 if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
1270 ND_PRINTK2(KERN_WARNING 1277 ND_PRINTK2(KERN_WARNING
@@ -1446,7 +1453,9 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1446 rd_len &= ~0x7; 1453 rd_len &= ~0x7;
1447 len += rd_len; 1454 len += rd_len;
1448 1455
1449 buff = sock_alloc_send_skb(sk, MAX_HEADER + len + LL_RESERVED_SPACE(dev), 1456 buff = sock_alloc_send_skb(sk,
1457 (MAX_HEADER + sizeof(struct ipv6hdr) +
1458 len + LL_RESERVED_SPACE(dev)),
1450 1, &err); 1459 1, &err);
1451 if (buff == NULL) { 1460 if (buff == NULL) {
1452 ND_PRINTK0(KERN_ERR 1461 ND_PRINTK0(KERN_ERR
@@ -1504,7 +1513,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1504 1513
1505 buff->dst = dst; 1514 buff->dst = dst;
1506 idev = in6_dev_get(dst->dev); 1515 idev = in6_dev_get(dst->dev);
1507 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 1516 IP6_INC_STATS(idev, IPSTATS_MIB_OUTREQUESTS);
1508 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, buff, NULL, dst->dev, dst_output); 1517 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, buff, NULL, dst->dev, dst_output);
1509 if (!err) { 1518 if (!err) {
1510 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTREDIRECTS); 1519 ICMP6_INC_STATS(idev, ICMP6_MIB_OUTREDIRECTS);
diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
index 580b1aba6722..f6294e5bcb31 100644
--- a/net/ipv6/netfilter.c
+++ b/net/ipv6/netfilter.c
@@ -31,7 +31,7 @@ int ip6_route_me_harder(struct sk_buff *skb)
31#endif 31#endif
32 32
33 if (dst->error) { 33 if (dst->error) {
34 IP6_INC_STATS(IPSTATS_MIB_OUTNOROUTES); 34 IP6_INC_STATS(ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
35 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n"); 35 LIMIT_NETDEBUG(KERN_DEBUG "ip6_route_me_harder: No more route.\n");
36 dst_release(dst); 36 dst_release(dst);
37 return -EINVAL; 37 return -EINVAL;
@@ -80,11 +80,11 @@ static int nf_ip6_reroute(struct sk_buff **pskb, const struct nf_info *info)
80 return 0; 80 return 0;
81} 81}
82 82
83unsigned int nf_ip6_checksum(struct sk_buff *skb, unsigned int hook, 83__sum16 nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
84 unsigned int dataoff, u_int8_t protocol) 84 unsigned int dataoff, u_int8_t protocol)
85{ 85{
86 struct ipv6hdr *ip6h = skb->nh.ipv6h; 86 struct ipv6hdr *ip6h = skb->nh.ipv6h;
87 unsigned int csum = 0; 87 __sum16 csum = 0;
88 88
89 switch (skb->ip_summed) { 89 switch (skb->ip_summed) {
90 case CHECKSUM_COMPLETE: 90 case CHECKSUM_COMPLETE:
@@ -100,12 +100,13 @@ unsigned int nf_ip6_checksum(struct sk_buff *skb, unsigned int hook,
100 } 100 }
101 /* fall through */ 101 /* fall through */
102 case CHECKSUM_NONE: 102 case CHECKSUM_NONE:
103 skb->csum = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, 103 skb->csum = ~csum_unfold(
104 csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr,
104 skb->len - dataoff, 105 skb->len - dataoff,
105 protocol, 106 protocol,
106 csum_sub(0, 107 csum_sub(0,
107 skb_checksum(skb, 0, 108 skb_checksum(skb, 0,
108 dataoff, 0))); 109 dataoff, 0))));
109 csum = __skb_checksum_complete(skb); 110 csum = __skb_checksum_complete(skb);
110 } 111 }
111 return csum; 112 return csum;
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
index d7c45a9c15fe..fc3e5eb4bc3f 100644
--- a/net/ipv6/netfilter/Kconfig
+++ b/net/ipv6/netfilter/Kconfig
@@ -6,7 +6,7 @@ menu "IPv6: Netfilter Configuration (EXPERIMENTAL)"
6 depends on INET && IPV6 && NETFILTER && EXPERIMENTAL 6 depends on INET && IPV6 && NETFILTER && EXPERIMENTAL
7 7
8config NF_CONNTRACK_IPV6 8config NF_CONNTRACK_IPV6
9 tristate "IPv6 support for new connection tracking (EXPERIMENTAL)" 9 tristate "IPv6 connection tracking support (EXPERIMENTAL)"
10 depends on EXPERIMENTAL && NF_CONNTRACK 10 depends on EXPERIMENTAL && NF_CONNTRACK
11 ---help--- 11 ---help---
12 Connection tracking keeps a record of what packets have passed 12 Connection tracking keeps a record of what packets have passed
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index 9fec832ee08b..d4d9f182441a 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -241,7 +241,7 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
241 pmsg->data_len = data_len; 241 pmsg->data_len = data_len;
242 pmsg->timestamp_sec = entry->skb->tstamp.off_sec; 242 pmsg->timestamp_sec = entry->skb->tstamp.off_sec;
243 pmsg->timestamp_usec = entry->skb->tstamp.off_usec; 243 pmsg->timestamp_usec = entry->skb->tstamp.off_usec;
244 pmsg->mark = entry->skb->nfmark; 244 pmsg->mark = entry->skb->mark;
245 pmsg->hook = entry->info->hook; 245 pmsg->hook = entry->info->hook;
246 pmsg->hw_protocol = entry->skb->protocol; 246 pmsg->hw_protocol = entry->skb->protocol;
247 247
@@ -620,6 +620,7 @@ static ctl_table ipq_root_table[] = {
620 { .ctl_name = 0 } 620 { .ctl_name = 0 }
621}; 621};
622 622
623#ifdef CONFIG_PROC_FS
623static int 624static int
624ipq_get_info(char *buffer, char **start, off_t offset, int length) 625ipq_get_info(char *buffer, char **start, off_t offset, int length)
625{ 626{
@@ -653,6 +654,7 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
653 len = 0; 654 len = 0;
654 return len; 655 return len;
655} 656}
657#endif /* CONFIG_PROC_FS */
656 658
657static struct nf_queue_handler nfqh = { 659static struct nf_queue_handler nfqh = {
658 .name = "ip6_queue", 660 .name = "ip6_queue",
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 204e02162d49..f63fb86d7c7b 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -1481,7 +1481,8 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
1481 if (hp == NULL) 1481 if (hp == NULL)
1482 return -EBADMSG; 1482 return -EBADMSG;
1483 if (nexthdr == NEXTHDR_FRAGMENT) { 1483 if (nexthdr == NEXTHDR_FRAGMENT) {
1484 unsigned short _frag_off, *fp; 1484 unsigned short _frag_off;
1485 __be16 *fp;
1485 fp = skb_header_pointer(skb, 1486 fp = skb_header_pointer(skb,
1486 start+offsetof(struct frag_hdr, 1487 start+offsetof(struct frag_hdr,
1487 frag_off), 1488 frag_off),
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index 0cf537d30185..33b1faa90d74 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -69,9 +69,9 @@ static void dump_packet(const struct nf_loginfo *info,
69 /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */ 69 /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
70 printk("LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ", 70 printk("LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
71 ntohs(ih->payload_len) + sizeof(struct ipv6hdr), 71 ntohs(ih->payload_len) + sizeof(struct ipv6hdr),
72 (ntohl(*(u_int32_t *)ih) & 0x0ff00000) >> 20, 72 (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20,
73 ih->hop_limit, 73 ih->hop_limit,
74 (ntohl(*(u_int32_t *)ih) & 0x000fffff)); 74 (ntohl(*(__be32 *)ih) & 0x000fffff));
75 75
76 fragment = 0; 76 fragment = 0;
77 ptr = ip6hoff + sizeof(struct ipv6hdr); 77 ptr = ip6hoff + sizeof(struct ipv6hdr);
@@ -270,11 +270,15 @@ static void dump_packet(const struct nf_loginfo *info,
270 } 270 }
271 break; 271 break;
272 } 272 }
273 case IPPROTO_UDP: { 273 case IPPROTO_UDP:
274 case IPPROTO_UDPLITE: {
274 struct udphdr _udph, *uh; 275 struct udphdr _udph, *uh;
275 276
276 /* Max length: 10 "PROTO=UDP " */ 277 if (currenthdr == IPPROTO_UDP)
277 printk("PROTO=UDP "); 278 /* Max length: 10 "PROTO=UDP " */
279 printk("PROTO=UDP " );
280 else /* Max length: 14 "PROTO=UDPLITE " */
281 printk("PROTO=UDPLITE ");
278 282
279 if (fragment) 283 if (fragment)
280 break; 284 break;
@@ -436,13 +440,8 @@ ip6t_log_target(struct sk_buff **pskb,
436 li.u.log.level = loginfo->level; 440 li.u.log.level = loginfo->level;
437 li.u.log.logflags = loginfo->logflags; 441 li.u.log.logflags = loginfo->logflags;
438 442
439 if (loginfo->logflags & IP6T_LOG_NFLOG) 443 ip6t_log_packet(PF_INET6, hooknum, *pskb, in, out, &li,
440 nf_log_packet(PF_INET6, hooknum, *pskb, in, out, &li, 444 loginfo->prefix);
441 "%s", loginfo->prefix);
442 else
443 ip6t_log_packet(PF_INET6, hooknum, *pskb, in, out, &li,
444 loginfo->prefix);
445
446 return IP6T_CONTINUE; 445 return IP6T_CONTINUE;
447} 446}
448 447
diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c
index 386ea260e767..6250e86a6ddc 100644
--- a/net/ipv6/netfilter/ip6table_mangle.c
+++ b/net/ipv6/netfilter/ip6table_mangle.c
@@ -149,11 +149,10 @@ ip6t_local_hook(unsigned int hook,
149 int (*okfn)(struct sk_buff *)) 149 int (*okfn)(struct sk_buff *))
150{ 150{
151 151
152 unsigned long nfmark;
153 unsigned int ret; 152 unsigned int ret;
154 struct in6_addr saddr, daddr; 153 struct in6_addr saddr, daddr;
155 u_int8_t hop_limit; 154 u_int8_t hop_limit;
156 u_int32_t flowlabel; 155 u_int32_t flowlabel, mark;
157 156
158#if 0 157#if 0
159 /* root is playing with raw sockets. */ 158 /* root is playing with raw sockets. */
@@ -165,10 +164,10 @@ ip6t_local_hook(unsigned int hook,
165 } 164 }
166#endif 165#endif
167 166
168 /* save source/dest address, nfmark, hoplimit, flowlabel, priority, */ 167 /* save source/dest address, mark, hoplimit, flowlabel, priority, */
169 memcpy(&saddr, &(*pskb)->nh.ipv6h->saddr, sizeof(saddr)); 168 memcpy(&saddr, &(*pskb)->nh.ipv6h->saddr, sizeof(saddr));
170 memcpy(&daddr, &(*pskb)->nh.ipv6h->daddr, sizeof(daddr)); 169 memcpy(&daddr, &(*pskb)->nh.ipv6h->daddr, sizeof(daddr));
171 nfmark = (*pskb)->nfmark; 170 mark = (*pskb)->mark;
172 hop_limit = (*pskb)->nh.ipv6h->hop_limit; 171 hop_limit = (*pskb)->nh.ipv6h->hop_limit;
173 172
174 /* flowlabel and prio (includes version, which shouldn't change either */ 173 /* flowlabel and prio (includes version, which shouldn't change either */
@@ -179,7 +178,7 @@ ip6t_local_hook(unsigned int hook,
179 if (ret != NF_DROP && ret != NF_STOLEN 178 if (ret != NF_DROP && ret != NF_STOLEN
180 && (memcmp(&(*pskb)->nh.ipv6h->saddr, &saddr, sizeof(saddr)) 179 && (memcmp(&(*pskb)->nh.ipv6h->saddr, &saddr, sizeof(saddr))
181 || memcmp(&(*pskb)->nh.ipv6h->daddr, &daddr, sizeof(daddr)) 180 || memcmp(&(*pskb)->nh.ipv6h->daddr, &daddr, sizeof(daddr))
182 || (*pskb)->nfmark != nfmark 181 || (*pskb)->mark != mark
183 || (*pskb)->nh.ipv6h->hop_limit != hop_limit)) 182 || (*pskb)->nh.ipv6h->hop_limit != hop_limit))
184 return ip6_route_me_harder(*pskb) == 0 ? ret : NF_DROP; 183 return ip6_route_me_harder(*pskb) == 0 ? ret : NF_DROP;
185 184
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index e5e53fff9e38..a20615ffccff 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -33,7 +33,7 @@
33#include <linux/netfilter_ipv6.h> 33#include <linux/netfilter_ipv6.h>
34#include <net/netfilter/nf_conntrack.h> 34#include <net/netfilter/nf_conntrack.h>
35#include <net/netfilter/nf_conntrack_helper.h> 35#include <net/netfilter/nf_conntrack_helper.h>
36#include <net/netfilter/nf_conntrack_protocol.h> 36#include <net/netfilter/nf_conntrack_l4proto.h>
37#include <net/netfilter/nf_conntrack_l3proto.h> 37#include <net/netfilter/nf_conntrack_l3proto.h>
38#include <net/netfilter/nf_conntrack_core.h> 38#include <net/netfilter/nf_conntrack_core.h>
39 39
@@ -43,8 +43,6 @@
43#define DEBUGP(format, args...) 43#define DEBUGP(format, args...)
44#endif 44#endif
45 45
46DECLARE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat);
47
48static int ipv6_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff, 46static int ipv6_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff,
49 struct nf_conntrack_tuple *tuple) 47 struct nf_conntrack_tuple *tuple)
50{ 48{
@@ -211,11 +209,6 @@ out:
211 return nf_conntrack_confirm(pskb); 209 return nf_conntrack_confirm(pskb);
212} 210}
213 211
214extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb);
215extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
216 struct net_device *in,
217 struct net_device *out,
218 int (*okfn)(struct sk_buff *));
219static unsigned int ipv6_defrag(unsigned int hooknum, 212static unsigned int ipv6_defrag(unsigned int hooknum,
220 struct sk_buff **pskb, 213 struct sk_buff **pskb,
221 const struct net_device *in, 214 const struct net_device *in,
@@ -331,26 +324,7 @@ static struct nf_hook_ops ipv6_conntrack_ops[] = {
331}; 324};
332 325
333#ifdef CONFIG_SYSCTL 326#ifdef CONFIG_SYSCTL
334 327static ctl_table nf_ct_ipv6_sysctl_table[] = {
335/* From nf_conntrack_proto_icmpv6.c */
336extern unsigned int nf_ct_icmpv6_timeout;
337
338/* From nf_conntrack_reasm.c */
339extern unsigned int nf_ct_frag6_timeout;
340extern unsigned int nf_ct_frag6_low_thresh;
341extern unsigned int nf_ct_frag6_high_thresh;
342
343static struct ctl_table_header *nf_ct_ipv6_sysctl_header;
344
345static ctl_table nf_ct_sysctl_table[] = {
346 {
347 .ctl_name = NET_NF_CONNTRACK_ICMPV6_TIMEOUT,
348 .procname = "nf_conntrack_icmpv6_timeout",
349 .data = &nf_ct_icmpv6_timeout,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
352 .proc_handler = &proc_dointvec_jiffies,
353 },
354 { 328 {
355 .ctl_name = NET_NF_CONNTRACK_FRAG6_TIMEOUT, 329 .ctl_name = NET_NF_CONNTRACK_FRAG6_TIMEOUT,
356 .procname = "nf_conntrack_frag6_timeout", 330 .procname = "nf_conntrack_frag6_timeout",
@@ -377,26 +351,6 @@ static ctl_table nf_ct_sysctl_table[] = {
377 }, 351 },
378 { .ctl_name = 0 } 352 { .ctl_name = 0 }
379}; 353};
380
381static ctl_table nf_ct_netfilter_table[] = {
382 {
383 .ctl_name = NET_NETFILTER,
384 .procname = "netfilter",
385 .mode = 0555,
386 .child = nf_ct_sysctl_table,
387 },
388 { .ctl_name = 0 }
389};
390
391static ctl_table nf_ct_net_table[] = {
392 {
393 .ctl_name = CTL_NET,
394 .procname = "net",
395 .mode = 0555,
396 .child = nf_ct_netfilter_table,
397 },
398 { .ctl_name = 0 }
399};
400#endif 354#endif
401 355
402#if defined(CONFIG_NF_CT_NETLINK) || \ 356#if defined(CONFIG_NF_CT_NETLINK) || \
@@ -454,16 +408,14 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6 = {
454 .tuple_to_nfattr = ipv6_tuple_to_nfattr, 408 .tuple_to_nfattr = ipv6_tuple_to_nfattr,
455 .nfattr_to_tuple = ipv6_nfattr_to_tuple, 409 .nfattr_to_tuple = ipv6_nfattr_to_tuple,
456#endif 410#endif
411#ifdef CONFIG_SYSCTL
412 .ctl_table_path = nf_net_netfilter_sysctl_path,
413 .ctl_table = nf_ct_ipv6_sysctl_table,
414#endif
457 .get_features = ipv6_get_features, 415 .get_features = ipv6_get_features,
458 .me = THIS_MODULE, 416 .me = THIS_MODULE,
459}; 417};
460 418
461extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp6;
462extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6;
463extern struct nf_conntrack_protocol nf_conntrack_protocol_icmpv6;
464extern int nf_ct_frag6_init(void);
465extern void nf_ct_frag6_cleanup(void);
466
467MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET6)); 419MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET6));
468MODULE_LICENSE("GPL"); 420MODULE_LICENSE("GPL");
469MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>"); 421MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>");
@@ -479,19 +431,19 @@ static int __init nf_conntrack_l3proto_ipv6_init(void)
479 printk("nf_conntrack_ipv6: can't initialize frag6.\n"); 431 printk("nf_conntrack_ipv6: can't initialize frag6.\n");
480 return ret; 432 return ret;
481 } 433 }
482 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_tcp6); 434 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_tcp6);
483 if (ret < 0) { 435 if (ret < 0) {
484 printk("nf_conntrack_ipv6: can't register tcp.\n"); 436 printk("nf_conntrack_ipv6: can't register tcp.\n");
485 goto cleanup_frag6; 437 goto cleanup_frag6;
486 } 438 }
487 439
488 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_udp6); 440 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_udp6);
489 if (ret < 0) { 441 if (ret < 0) {
490 printk("nf_conntrack_ipv6: can't register udp.\n"); 442 printk("nf_conntrack_ipv6: can't register udp.\n");
491 goto cleanup_tcp; 443 goto cleanup_tcp;
492 } 444 }
493 445
494 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_icmpv6); 446 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_icmpv6);
495 if (ret < 0) { 447 if (ret < 0) {
496 printk("nf_conntrack_ipv6: can't register icmpv6.\n"); 448 printk("nf_conntrack_ipv6: can't register icmpv6.\n");
497 goto cleanup_udp; 449 goto cleanup_udp;
@@ -510,28 +462,16 @@ static int __init nf_conntrack_l3proto_ipv6_init(void)
510 "hook.\n"); 462 "hook.\n");
511 goto cleanup_ipv6; 463 goto cleanup_ipv6;
512 } 464 }
513#ifdef CONFIG_SYSCTL
514 nf_ct_ipv6_sysctl_header = register_sysctl_table(nf_ct_net_table, 0);
515 if (nf_ct_ipv6_sysctl_header == NULL) {
516 printk("nf_conntrack: can't register to sysctl.\n");
517 ret = -ENOMEM;
518 goto cleanup_hooks;
519 }
520#endif
521 return ret; 465 return ret;
522 466
523#ifdef CONFIG_SYSCTL
524 cleanup_hooks:
525 nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops));
526#endif
527 cleanup_ipv6: 467 cleanup_ipv6:
528 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv6); 468 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv6);
529 cleanup_icmpv6: 469 cleanup_icmpv6:
530 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmpv6); 470 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_icmpv6);
531 cleanup_udp: 471 cleanup_udp:
532 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp6); 472 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udp6);
533 cleanup_tcp: 473 cleanup_tcp:
534 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp6); 474 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_tcp6);
535 cleanup_frag6: 475 cleanup_frag6:
536 nf_ct_frag6_cleanup(); 476 nf_ct_frag6_cleanup();
537 return ret; 477 return ret;
@@ -540,14 +480,11 @@ static int __init nf_conntrack_l3proto_ipv6_init(void)
540static void __exit nf_conntrack_l3proto_ipv6_fini(void) 480static void __exit nf_conntrack_l3proto_ipv6_fini(void)
541{ 481{
542 synchronize_net(); 482 synchronize_net();
543#ifdef CONFIG_SYSCTL
544 unregister_sysctl_table(nf_ct_ipv6_sysctl_header);
545#endif
546 nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops)); 483 nf_unregister_hooks(ipv6_conntrack_ops, ARRAY_SIZE(ipv6_conntrack_ops));
547 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv6); 484 nf_conntrack_l3proto_unregister(&nf_conntrack_l3proto_ipv6);
548 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_icmpv6); 485 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_icmpv6);
549 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_udp6); 486 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udp6);
550 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_tcp6); 487 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_tcp6);
551 nf_ct_frag6_cleanup(); 488 nf_ct_frag6_cleanup();
552} 489}
553 490
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 34d447208ffd..3905cacc69af 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -29,11 +29,11 @@
29#include <linux/seq_file.h> 29#include <linux/seq_file.h>
30#include <linux/netfilter_ipv6.h> 30#include <linux/netfilter_ipv6.h>
31#include <net/netfilter/nf_conntrack_tuple.h> 31#include <net/netfilter/nf_conntrack_tuple.h>
32#include <net/netfilter/nf_conntrack_protocol.h> 32#include <net/netfilter/nf_conntrack_l4proto.h>
33#include <net/netfilter/nf_conntrack_core.h> 33#include <net/netfilter/nf_conntrack_core.h>
34#include <net/netfilter/ipv6/nf_conntrack_icmpv6.h> 34#include <net/netfilter/ipv6/nf_conntrack_icmpv6.h>
35 35
36unsigned long nf_ct_icmpv6_timeout __read_mostly = 30*HZ; 36static unsigned long nf_ct_icmpv6_timeout __read_mostly = 30*HZ;
37 37
38#if 0 38#if 0
39#define DEBUGP printk 39#define DEBUGP printk
@@ -142,9 +142,6 @@ static int icmpv6_new(struct nf_conn *conntrack,
142 return 1; 142 return 1;
143} 143}
144 144
145extern int
146nf_ct_ipv6_skip_exthdr(struct sk_buff *skb, int start, u8 *nexthdrp, int len);
147extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
148static int 145static int
149icmpv6_error_message(struct sk_buff *skb, 146icmpv6_error_message(struct sk_buff *skb,
150 unsigned int icmp6off, 147 unsigned int icmp6off,
@@ -155,7 +152,7 @@ icmpv6_error_message(struct sk_buff *skb,
155 struct nf_conntrack_tuple_hash *h; 152 struct nf_conntrack_tuple_hash *h;
156 struct icmp6hdr _hdr, *hp; 153 struct icmp6hdr _hdr, *hp;
157 unsigned int inip6off; 154 unsigned int inip6off;
158 struct nf_conntrack_protocol *inproto; 155 struct nf_conntrack_l4proto *inproto;
159 u_int8_t inprotonum; 156 u_int8_t inprotonum;
160 unsigned int inprotoff; 157 unsigned int inprotoff;
161 158
@@ -185,7 +182,7 @@ icmpv6_error_message(struct sk_buff *skb,
185 return -NF_ACCEPT; 182 return -NF_ACCEPT;
186 } 183 }
187 184
188 inproto = __nf_ct_proto_find(PF_INET6, inprotonum); 185 inproto = __nf_ct_l4proto_find(PF_INET6, inprotonum);
189 186
190 /* Are they talking about one of our connections? */ 187 /* Are they talking about one of our connections? */
191 if (!nf_ct_get_tuple(skb, inip6off, inprotoff, PF_INET6, inprotonum, 188 if (!nf_ct_get_tuple(skb, inip6off, inprotoff, PF_INET6, inprotonum,
@@ -290,7 +287,7 @@ static int icmpv6_nfattr_to_tuple(struct nfattr *tb[],
290 tuple->dst.u.icmp.code = 287 tuple->dst.u.icmp.code =
291 *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_CODE-1]); 288 *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_CODE-1]);
292 tuple->src.u.icmp.id = 289 tuple->src.u.icmp.id =
293 *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_ID-1]); 290 *(__be16 *)NFA_DATA(tb[CTA_PROTO_ICMPV6_ID-1]);
294 291
295 if (tuple->dst.u.icmp.type < 128 292 if (tuple->dst.u.icmp.type < 128
296 || tuple->dst.u.icmp.type - 128 >= sizeof(invmap) 293 || tuple->dst.u.icmp.type - 128 >= sizeof(invmap)
@@ -301,10 +298,27 @@ static int icmpv6_nfattr_to_tuple(struct nfattr *tb[],
301} 298}
302#endif 299#endif
303 300
304struct nf_conntrack_protocol nf_conntrack_protocol_icmpv6 = 301#ifdef CONFIG_SYSCTL
302static struct ctl_table_header *icmpv6_sysctl_header;
303static struct ctl_table icmpv6_sysctl_table[] = {
304 {
305 .ctl_name = NET_NF_CONNTRACK_ICMPV6_TIMEOUT,
306 .procname = "nf_conntrack_icmpv6_timeout",
307 .data = &nf_ct_icmpv6_timeout,
308 .maxlen = sizeof(unsigned int),
309 .mode = 0644,
310 .proc_handler = &proc_dointvec_jiffies,
311 },
312 {
313 .ctl_name = 0
314 }
315};
316#endif /* CONFIG_SYSCTL */
317
318struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 =
305{ 319{
306 .l3proto = PF_INET6, 320 .l3proto = PF_INET6,
307 .proto = IPPROTO_ICMPV6, 321 .l4proto = IPPROTO_ICMPV6,
308 .name = "icmpv6", 322 .name = "icmpv6",
309 .pkt_to_tuple = icmpv6_pkt_to_tuple, 323 .pkt_to_tuple = icmpv6_pkt_to_tuple,
310 .invert_tuple = icmpv6_invert_tuple, 324 .invert_tuple = icmpv6_invert_tuple,
@@ -318,6 +332,10 @@ struct nf_conntrack_protocol nf_conntrack_protocol_icmpv6 =
318 .tuple_to_nfattr = icmpv6_tuple_to_nfattr, 332 .tuple_to_nfattr = icmpv6_tuple_to_nfattr,
319 .nfattr_to_tuple = icmpv6_nfattr_to_tuple, 333 .nfattr_to_tuple = icmpv6_nfattr_to_tuple,
320#endif 334#endif
335#ifdef CONFIG_SYSCTL
336 .ctl_table_header = &icmpv6_sysctl_header,
337 .ctl_table = icmpv6_sysctl_table,
338#endif
321}; 339};
322 340
323EXPORT_SYMBOL(nf_conntrack_protocol_icmpv6); 341EXPORT_SYMBOL(nf_conntrack_l4proto_icmpv6);
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index bf93c1ea6be9..37e5fca923aa 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -72,7 +72,7 @@ struct nf_ct_frag6_queue
72 struct hlist_node list; 72 struct hlist_node list;
73 struct list_head lru_list; /* lru list member */ 73 struct list_head lru_list; /* lru list member */
74 74
75 __u32 id; /* fragment id */ 75 __be32 id; /* fragment id */
76 struct in6_addr saddr; 76 struct in6_addr saddr;
77 struct in6_addr daddr; 77 struct in6_addr daddr;
78 78
@@ -115,28 +115,28 @@ static __inline__ void fq_unlink(struct nf_ct_frag6_queue *fq)
115 write_unlock(&nf_ct_frag6_lock); 115 write_unlock(&nf_ct_frag6_lock);
116} 116}
117 117
118static unsigned int ip6qhashfn(u32 id, struct in6_addr *saddr, 118static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr,
119 struct in6_addr *daddr) 119 struct in6_addr *daddr)
120{ 120{
121 u32 a, b, c; 121 u32 a, b, c;
122 122
123 a = saddr->s6_addr32[0]; 123 a = (__force u32)saddr->s6_addr32[0];
124 b = saddr->s6_addr32[1]; 124 b = (__force u32)saddr->s6_addr32[1];
125 c = saddr->s6_addr32[2]; 125 c = (__force u32)saddr->s6_addr32[2];
126 126
127 a += JHASH_GOLDEN_RATIO; 127 a += JHASH_GOLDEN_RATIO;
128 b += JHASH_GOLDEN_RATIO; 128 b += JHASH_GOLDEN_RATIO;
129 c += nf_ct_frag6_hash_rnd; 129 c += nf_ct_frag6_hash_rnd;
130 __jhash_mix(a, b, c); 130 __jhash_mix(a, b, c);
131 131
132 a += saddr->s6_addr32[3]; 132 a += (__force u32)saddr->s6_addr32[3];
133 b += daddr->s6_addr32[0]; 133 b += (__force u32)daddr->s6_addr32[0];
134 c += daddr->s6_addr32[1]; 134 c += (__force u32)daddr->s6_addr32[1];
135 __jhash_mix(a, b, c); 135 __jhash_mix(a, b, c);
136 136
137 a += daddr->s6_addr32[2]; 137 a += (__force u32)daddr->s6_addr32[2];
138 b += daddr->s6_addr32[3]; 138 b += (__force u32)daddr->s6_addr32[3];
139 c += id; 139 c += (__force u32)id;
140 __jhash_mix(a, b, c); 140 __jhash_mix(a, b, c);
141 141
142 return c & (FRAG6Q_HASHSZ - 1); 142 return c & (FRAG6Q_HASHSZ - 1);
@@ -338,7 +338,7 @@ static struct nf_ct_frag6_queue *nf_ct_frag6_intern(unsigned int hash,
338 338
339 339
340static struct nf_ct_frag6_queue * 340static struct nf_ct_frag6_queue *
341nf_ct_frag6_create(unsigned int hash, u32 id, struct in6_addr *src, struct in6_addr *dst) 341nf_ct_frag6_create(unsigned int hash, __be32 id, struct in6_addr *src, struct in6_addr *dst)
342{ 342{
343 struct nf_ct_frag6_queue *fq; 343 struct nf_ct_frag6_queue *fq;
344 344
@@ -366,7 +366,7 @@ oom:
366} 366}
367 367
368static __inline__ struct nf_ct_frag6_queue * 368static __inline__ struct nf_ct_frag6_queue *
369fq_find(u32 id, struct in6_addr *src, struct in6_addr *dst) 369fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst)
370{ 370{
371 struct nf_ct_frag6_queue *fq; 371 struct nf_ct_frag6_queue *fq;
372 struct hlist_node *n; 372 struct hlist_node *n;
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index efee7a6301a8..35249d8487bb 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -49,6 +49,8 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v)
49 fold_prot_inuse(&tcpv6_prot)); 49 fold_prot_inuse(&tcpv6_prot));
50 seq_printf(seq, "UDP6: inuse %d\n", 50 seq_printf(seq, "UDP6: inuse %d\n",
51 fold_prot_inuse(&udpv6_prot)); 51 fold_prot_inuse(&udpv6_prot));
52 seq_printf(seq, "UDPLITE6: inuse %d\n",
53 fold_prot_inuse(&udplitev6_prot));
52 seq_printf(seq, "RAW6: inuse %d\n", 54 seq_printf(seq, "RAW6: inuse %d\n",
53 fold_prot_inuse(&rawv6_prot)); 55 fold_prot_inuse(&rawv6_prot));
54 seq_printf(seq, "FRAG6: inuse %d memory %d\n", 56 seq_printf(seq, "FRAG6: inuse %d memory %d\n",
@@ -133,6 +135,14 @@ static struct snmp_mib snmp6_udp6_list[] = {
133 SNMP_MIB_SENTINEL 135 SNMP_MIB_SENTINEL
134}; 136};
135 137
138static struct snmp_mib snmp6_udplite6_list[] = {
139 SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS),
140 SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS),
141 SNMP_MIB_ITEM("UdpLite6InErrors", UDP_MIB_INERRORS),
142 SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS),
143 SNMP_MIB_SENTINEL
144};
145
136static unsigned long 146static unsigned long
137fold_field(void *mib[], int offt) 147fold_field(void *mib[], int offt)
138{ 148{
@@ -161,11 +171,13 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)
161 171
162 if (idev) { 172 if (idev) {
163 seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex); 173 seq_printf(seq, "%-32s\t%u\n", "ifIndex", idev->dev->ifindex);
174 snmp6_seq_show_item(seq, (void **)idev->stats.ipv6, snmp6_ipstats_list);
164 snmp6_seq_show_item(seq, (void **)idev->stats.icmpv6, snmp6_icmp6_list); 175 snmp6_seq_show_item(seq, (void **)idev->stats.icmpv6, snmp6_icmp6_list);
165 } else { 176 } else {
166 snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list); 177 snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list);
167 snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); 178 snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list);
168 snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list); 179 snmp6_seq_show_item(seq, (void **)udp_stats_in6, snmp6_udp6_list);
180 snmp6_seq_show_item(seq, (void **)udplite_stats_in6, snmp6_udplite6_list);
169 } 181 }
170 return 0; 182 return 0;
171} 183}
@@ -281,6 +293,9 @@ int snmp6_alloc_dev(struct inet6_dev *idev)
281 if (!idev || !idev->dev) 293 if (!idev || !idev->dev)
282 return -EINVAL; 294 return -EINVAL;
283 295
296 if (snmp6_mib_init((void **)idev->stats.ipv6, sizeof(struct ipstats_mib),
297 __alignof__(struct ipstats_mib)) < 0)
298 goto err_ip;
284 if (snmp6_mib_init((void **)idev->stats.icmpv6, sizeof(struct icmpv6_mib), 299 if (snmp6_mib_init((void **)idev->stats.icmpv6, sizeof(struct icmpv6_mib),
285 __alignof__(struct icmpv6_mib)) < 0) 300 __alignof__(struct icmpv6_mib)) < 0)
286 goto err_icmp; 301 goto err_icmp;
@@ -288,12 +303,15 @@ int snmp6_alloc_dev(struct inet6_dev *idev)
288 return 0; 303 return 0;
289 304
290err_icmp: 305err_icmp:
306 snmp6_mib_free((void **)idev->stats.ipv6);
307err_ip:
291 return err; 308 return err;
292} 309}
293 310
294int snmp6_free_dev(struct inet6_dev *idev) 311int snmp6_free_dev(struct inet6_dev *idev)
295{ 312{
296 snmp6_mib_free((void **)idev->stats.icmpv6); 313 snmp6_mib_free((void **)idev->stats.icmpv6);
314 snmp6_mib_free((void **)idev->stats.ipv6);
297 return 0; 315 return 0;
298} 316}
299 317
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index d6dedc4aec77..c2e629d6aea4 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -220,7 +220,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
220 struct inet_sock *inet = inet_sk(sk); 220 struct inet_sock *inet = inet_sk(sk);
221 struct ipv6_pinfo *np = inet6_sk(sk); 221 struct ipv6_pinfo *np = inet6_sk(sk);
222 struct sockaddr_in6 *addr = (struct sockaddr_in6 *) uaddr; 222 struct sockaddr_in6 *addr = (struct sockaddr_in6 *) uaddr;
223 __u32 v4addr = 0; 223 __be32 v4addr = 0;
224 int addr_type; 224 int addr_type;
225 int err; 225 int err;
226 226
@@ -290,7 +290,7 @@ out:
290 290
291void rawv6_err(struct sock *sk, struct sk_buff *skb, 291void rawv6_err(struct sock *sk, struct sk_buff *skb,
292 struct inet6_skb_parm *opt, 292 struct inet6_skb_parm *opt,
293 int type, int code, int offset, u32 info) 293 int type, int code, int offset, __be32 info)
294{ 294{
295 struct inet_sock *inet = inet_sk(sk); 295 struct inet_sock *inet = inet_sk(sk);
296 struct ipv6_pinfo *np = inet6_sk(sk); 296 struct ipv6_pinfo *np = inet6_sk(sk);
@@ -370,9 +370,9 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
370 skb->ip_summed = CHECKSUM_UNNECESSARY; 370 skb->ip_summed = CHECKSUM_UNNECESSARY;
371 } 371 }
372 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 372 if (skb->ip_summed != CHECKSUM_UNNECESSARY)
373 skb->csum = ~csum_ipv6_magic(&skb->nh.ipv6h->saddr, 373 skb->csum = ~csum_unfold(csum_ipv6_magic(&skb->nh.ipv6h->saddr,
374 &skb->nh.ipv6h->daddr, 374 &skb->nh.ipv6h->daddr,
375 skb->len, inet->num, 0); 375 skb->len, inet->num, 0));
376 376
377 if (inet->hdrincl) { 377 if (inet->hdrincl) {
378 if (skb_checksum_complete(skb)) { 378 if (skb_checksum_complete(skb)) {
@@ -479,8 +479,8 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
479 int offset; 479 int offset;
480 int len; 480 int len;
481 int total_len; 481 int total_len;
482 u32 tmp_csum; 482 __wsum tmp_csum;
483 u16 csum; 483 __sum16 csum;
484 484
485 if (!rp->checksum) 485 if (!rp->checksum)
486 goto send; 486 goto send;
@@ -530,16 +530,15 @@ static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl,
530 530
531 /* in case cksum was not initialized */ 531 /* in case cksum was not initialized */
532 if (unlikely(csum)) 532 if (unlikely(csum))
533 tmp_csum = csum_sub(tmp_csum, csum); 533 tmp_csum = csum_sub(tmp_csum, csum_unfold(csum));
534 534
535 tmp_csum = csum_ipv6_magic(&fl->fl6_src, 535 csum = csum_ipv6_magic(&fl->fl6_src,
536 &fl->fl6_dst, 536 &fl->fl6_dst,
537 total_len, fl->proto, tmp_csum); 537 total_len, fl->proto, tmp_csum);
538 538
539 if (tmp_csum == 0) 539 if (csum == 0 && fl->proto == IPPROTO_UDP)
540 tmp_csum = -1; 540 csum = CSUM_MANGLED_0;
541 541
542 csum = tmp_csum;
543 if (skb_store_bits(skb, offset, &csum, 2)) 542 if (skb_store_bits(skb, offset, &csum, 2))
544 BUG(); 543 BUG();
545 544
@@ -586,7 +585,7 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
586 if (err) 585 if (err)
587 goto error_fault; 586 goto error_fault;
588 587
589 IP6_INC_STATS(IPSTATS_MIB_OUTREQUESTS); 588 IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTREQUESTS);
590 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, rt->u.dst.dev, 589 err = NF_HOOK(PF_INET6, NF_IP6_LOCAL_OUT, skb, NULL, rt->u.dst.dev,
591 dst_output); 590 dst_output);
592 if (err > 0) 591 if (err > 0)
@@ -600,7 +599,7 @@ error_fault:
600 err = -EFAULT; 599 err = -EFAULT;
601 kfree_skb(skb); 600 kfree_skb(skb);
602error: 601error:
603 IP6_INC_STATS(IPSTATS_MIB_OUTDISCARDS); 602 IP6_INC_STATS(rt->rt6i_idev, IPSTATS_MIB_OUTDISCARDS);
604 return err; 603 return err;
605} 604}
606 605
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index f39bbedd1327..6f9a9046510f 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -47,6 +47,7 @@
47#include <net/snmp.h> 47#include <net/snmp.h>
48 48
49#include <net/ipv6.h> 49#include <net/ipv6.h>
50#include <net/ip6_route.h>
50#include <net/protocol.h> 51#include <net/protocol.h>
51#include <net/transp_v6.h> 52#include <net/transp_v6.h>
52#include <net/rawv6.h> 53#include <net/rawv6.h>
@@ -76,7 +77,7 @@ struct frag_queue
76 struct hlist_node list; 77 struct hlist_node list;
77 struct list_head lru_list; /* lru list member */ 78 struct list_head lru_list; /* lru list member */
78 79
79 __u32 id; /* fragment id */ 80 __be32 id; /* fragment id */
80 struct in6_addr saddr; 81 struct in6_addr saddr;
81 struct in6_addr daddr; 82 struct in6_addr daddr;
82 83
@@ -124,28 +125,28 @@ static __inline__ void fq_unlink(struct frag_queue *fq)
124 * callers should be careful not to use the hash value outside the ipfrag_lock 125 * callers should be careful not to use the hash value outside the ipfrag_lock
125 * as doing so could race with ipfrag_hash_rnd being recalculated. 126 * as doing so could race with ipfrag_hash_rnd being recalculated.
126 */ 127 */
127static unsigned int ip6qhashfn(u32 id, struct in6_addr *saddr, 128static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr,
128 struct in6_addr *daddr) 129 struct in6_addr *daddr)
129{ 130{
130 u32 a, b, c; 131 u32 a, b, c;
131 132
132 a = saddr->s6_addr32[0]; 133 a = (__force u32)saddr->s6_addr32[0];
133 b = saddr->s6_addr32[1]; 134 b = (__force u32)saddr->s6_addr32[1];
134 c = saddr->s6_addr32[2]; 135 c = (__force u32)saddr->s6_addr32[2];
135 136
136 a += JHASH_GOLDEN_RATIO; 137 a += JHASH_GOLDEN_RATIO;
137 b += JHASH_GOLDEN_RATIO; 138 b += JHASH_GOLDEN_RATIO;
138 c += ip6_frag_hash_rnd; 139 c += ip6_frag_hash_rnd;
139 __jhash_mix(a, b, c); 140 __jhash_mix(a, b, c);
140 141
141 a += saddr->s6_addr32[3]; 142 a += (__force u32)saddr->s6_addr32[3];
142 b += daddr->s6_addr32[0]; 143 b += (__force u32)daddr->s6_addr32[0];
143 c += daddr->s6_addr32[1]; 144 c += (__force u32)daddr->s6_addr32[1];
144 __jhash_mix(a, b, c); 145 __jhash_mix(a, b, c);
145 146
146 a += daddr->s6_addr32[2]; 147 a += (__force u32)daddr->s6_addr32[2];
147 b += daddr->s6_addr32[3]; 148 b += (__force u32)daddr->s6_addr32[3];
148 c += id; 149 c += (__force u32)id;
149 __jhash_mix(a, b, c); 150 __jhash_mix(a, b, c);
150 151
151 return c & (IP6Q_HASHSZ - 1); 152 return c & (IP6Q_HASHSZ - 1);
@@ -257,7 +258,7 @@ static __inline__ void fq_kill(struct frag_queue *fq)
257 } 258 }
258} 259}
259 260
260static void ip6_evictor(void) 261static void ip6_evictor(struct inet6_dev *idev)
261{ 262{
262 struct frag_queue *fq; 263 struct frag_queue *fq;
263 struct list_head *tmp; 264 struct list_head *tmp;
@@ -284,14 +285,14 @@ static void ip6_evictor(void)
284 spin_unlock(&fq->lock); 285 spin_unlock(&fq->lock);
285 286
286 fq_put(fq, &work); 287 fq_put(fq, &work);
287 IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 288 IP6_INC_STATS_BH(idev, IPSTATS_MIB_REASMFAILS);
288 } 289 }
289} 290}
290 291
291static void ip6_frag_expire(unsigned long data) 292static void ip6_frag_expire(unsigned long data)
292{ 293{
293 struct frag_queue *fq = (struct frag_queue *) data; 294 struct frag_queue *fq = (struct frag_queue *) data;
294 struct net_device *dev; 295 struct net_device *dev = NULL;
295 296
296 spin_lock(&fq->lock); 297 spin_lock(&fq->lock);
297 298
@@ -300,17 +301,19 @@ static void ip6_frag_expire(unsigned long data)
300 301
301 fq_kill(fq); 302 fq_kill(fq);
302 303
303 IP6_INC_STATS_BH(IPSTATS_MIB_REASMTIMEOUT); 304 dev = dev_get_by_index(fq->iif);
304 IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 305 if (!dev)
306 goto out;
307
308 rcu_read_lock();
309 IP6_INC_STATS_BH(__in6_dev_get(dev), IPSTATS_MIB_REASMTIMEOUT);
310 IP6_INC_STATS_BH(__in6_dev_get(dev), IPSTATS_MIB_REASMFAILS);
311 rcu_read_unlock();
305 312
306 /* Don't send error if the first segment did not arrive. */ 313 /* Don't send error if the first segment did not arrive. */
307 if (!(fq->last_in&FIRST_IN) || !fq->fragments) 314 if (!(fq->last_in&FIRST_IN) || !fq->fragments)
308 goto out; 315 goto out;
309 316
310 dev = dev_get_by_index(fq->iif);
311 if (!dev)
312 goto out;
313
314 /* 317 /*
315 But use as source device on which LAST ARRIVED 318 But use as source device on which LAST ARRIVED
316 segment was received. And do not use fq->dev 319 segment was received. And do not use fq->dev
@@ -318,8 +321,9 @@ static void ip6_frag_expire(unsigned long data)
318 */ 321 */
319 fq->fragments->dev = dev; 322 fq->fragments->dev = dev;
320 icmpv6_send(fq->fragments, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0, dev); 323 icmpv6_send(fq->fragments, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0, dev);
321 dev_put(dev);
322out: 324out:
325 if (dev)
326 dev_put(dev);
323 spin_unlock(&fq->lock); 327 spin_unlock(&fq->lock);
324 fq_put(fq, NULL); 328 fq_put(fq, NULL);
325} 329}
@@ -366,7 +370,8 @@ static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in)
366 370
367 371
368static struct frag_queue * 372static struct frag_queue *
369ip6_frag_create(u32 id, struct in6_addr *src, struct in6_addr *dst) 373ip6_frag_create(__be32 id, struct in6_addr *src, struct in6_addr *dst,
374 struct inet6_dev *idev)
370{ 375{
371 struct frag_queue *fq; 376 struct frag_queue *fq;
372 377
@@ -386,12 +391,13 @@ ip6_frag_create(u32 id, struct in6_addr *src, struct in6_addr *dst)
386 return ip6_frag_intern(fq); 391 return ip6_frag_intern(fq);
387 392
388oom: 393oom:
389 IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 394 IP6_INC_STATS_BH(idev, IPSTATS_MIB_REASMFAILS);
390 return NULL; 395 return NULL;
391} 396}
392 397
393static __inline__ struct frag_queue * 398static __inline__ struct frag_queue *
394fq_find(u32 id, struct in6_addr *src, struct in6_addr *dst) 399fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst,
400 struct inet6_dev *idev)
395{ 401{
396 struct frag_queue *fq; 402 struct frag_queue *fq;
397 struct hlist_node *n; 403 struct hlist_node *n;
@@ -410,7 +416,7 @@ fq_find(u32 id, struct in6_addr *src, struct in6_addr *dst)
410 } 416 }
411 read_unlock(&ip6_frag_lock); 417 read_unlock(&ip6_frag_lock);
412 418
413 return ip6_frag_create(id, src, dst); 419 return ip6_frag_create(id, src, dst, idev);
414} 420}
415 421
416 422
@@ -428,7 +434,8 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
428 ((u8 *) (fhdr + 1) - (u8 *) (skb->nh.ipv6h + 1))); 434 ((u8 *) (fhdr + 1) - (u8 *) (skb->nh.ipv6h + 1)));
429 435
430 if ((unsigned int)end > IPV6_MAXPLEN) { 436 if ((unsigned int)end > IPV6_MAXPLEN) {
431 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 437 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
438 IPSTATS_MIB_INHDRERRORS);
432 icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw); 439 icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw);
433 return; 440 return;
434 } 441 }
@@ -455,7 +462,8 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
455 /* RFC2460 says always send parameter problem in 462 /* RFC2460 says always send parameter problem in
456 * this case. -DaveM 463 * this case. -DaveM
457 */ 464 */
458 IP6_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 465 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
466 IPSTATS_MIB_INHDRERRORS);
459 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, 467 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD,
460 offsetof(struct ipv6hdr, payload_len)); 468 offsetof(struct ipv6hdr, payload_len));
461 return; 469 return;
@@ -571,7 +579,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
571 return; 579 return;
572 580
573err: 581err:
574 IP6_INC_STATS(IPSTATS_MIB_REASMFAILS); 582 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_REASMFAILS);
575 kfree_skb(skb); 583 kfree_skb(skb);
576} 584}
577 585
@@ -665,7 +673,9 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in,
665 if (head->ip_summed == CHECKSUM_COMPLETE) 673 if (head->ip_summed == CHECKSUM_COMPLETE)
666 head->csum = csum_partial(head->nh.raw, head->h.raw-head->nh.raw, head->csum); 674 head->csum = csum_partial(head->nh.raw, head->h.raw-head->nh.raw, head->csum);
667 675
668 IP6_INC_STATS_BH(IPSTATS_MIB_REASMOKS); 676 rcu_read_lock();
677 IP6_INC_STATS_BH(__in6_dev_get(dev), IPSTATS_MIB_REASMOKS);
678 rcu_read_unlock();
669 fq->fragments = NULL; 679 fq->fragments = NULL;
670 return 1; 680 return 1;
671 681
@@ -677,7 +687,9 @@ out_oom:
677 if (net_ratelimit()) 687 if (net_ratelimit())
678 printk(KERN_DEBUG "ip6_frag_reasm: no memory for reassembly\n"); 688 printk(KERN_DEBUG "ip6_frag_reasm: no memory for reassembly\n");
679out_fail: 689out_fail:
680 IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 690 rcu_read_lock();
691 IP6_INC_STATS_BH(__in6_dev_get(dev), IPSTATS_MIB_REASMFAILS);
692 rcu_read_unlock();
681 return -1; 693 return -1;
682} 694}
683 695
@@ -691,16 +703,16 @@ static int ipv6_frag_rcv(struct sk_buff **skbp)
691 703
692 hdr = skb->nh.ipv6h; 704 hdr = skb->nh.ipv6h;
693 705
694 IP6_INC_STATS_BH(IPSTATS_MIB_REASMREQDS); 706 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_REASMREQDS);
695 707
696 /* Jumbo payload inhibits frag. header */ 708 /* Jumbo payload inhibits frag. header */
697 if (hdr->payload_len==0) { 709 if (hdr->payload_len==0) {
698 IP6_INC_STATS(IPSTATS_MIB_INHDRERRORS); 710 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS);
699 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, skb->h.raw-skb->nh.raw); 711 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, skb->h.raw-skb->nh.raw);
700 return -1; 712 return -1;
701 } 713 }
702 if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+sizeof(struct frag_hdr))) { 714 if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+sizeof(struct frag_hdr))) {
703 IP6_INC_STATS(IPSTATS_MIB_INHDRERRORS); 715 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INHDRERRORS);
704 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, skb->h.raw-skb->nh.raw); 716 icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, skb->h.raw-skb->nh.raw);
705 return -1; 717 return -1;
706 } 718 }
@@ -711,16 +723,17 @@ static int ipv6_frag_rcv(struct sk_buff **skbp)
711 if (!(fhdr->frag_off & htons(0xFFF9))) { 723 if (!(fhdr->frag_off & htons(0xFFF9))) {
712 /* It is not a fragmented frame */ 724 /* It is not a fragmented frame */
713 skb->h.raw += sizeof(struct frag_hdr); 725 skb->h.raw += sizeof(struct frag_hdr);
714 IP6_INC_STATS_BH(IPSTATS_MIB_REASMOKS); 726 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_REASMOKS);
715 727
716 IP6CB(skb)->nhoff = (u8*)fhdr - skb->nh.raw; 728 IP6CB(skb)->nhoff = (u8*)fhdr - skb->nh.raw;
717 return 1; 729 return 1;
718 } 730 }
719 731
720 if (atomic_read(&ip6_frag_mem) > sysctl_ip6frag_high_thresh) 732 if (atomic_read(&ip6_frag_mem) > sysctl_ip6frag_high_thresh)
721 ip6_evictor(); 733 ip6_evictor(ip6_dst_idev(skb->dst));
722 734
723 if ((fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr)) != NULL) { 735 if ((fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr,
736 ip6_dst_idev(skb->dst))) != NULL) {
724 int ret = -1; 737 int ret = -1;
725 738
726 spin_lock(&fq->lock); 739 spin_lock(&fq->lock);
@@ -736,7 +749,7 @@ static int ipv6_frag_rcv(struct sk_buff **skbp)
736 return ret; 749 return ret;
737 } 750 }
738 751
739 IP6_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 752 IP6_INC_STATS_BH(ip6_dst_idev(skb->dst), IPSTATS_MIB_REASMFAILS);
740 kfree_skb(skb); 753 kfree_skb(skb);
741 return -1; 754 return -1;
742} 755}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b39ae99122d5..9f80518aacbd 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -440,7 +440,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len,
440 if (pref == ICMPV6_ROUTER_PREF_INVALID) 440 if (pref == ICMPV6_ROUTER_PREF_INVALID)
441 pref = ICMPV6_ROUTER_PREF_MEDIUM; 441 pref = ICMPV6_ROUTER_PREF_MEDIUM;
442 442
443 lifetime = htonl(rinfo->lifetime); 443 lifetime = ntohl(rinfo->lifetime);
444 if (lifetime == 0xffffffff) { 444 if (lifetime == 0xffffffff) {
445 /* infinity */ 445 /* infinity */
446 } else if (lifetime > 0x7fffffff/HZ) { 446 } else if (lifetime > 0x7fffffff/HZ) {
@@ -711,12 +711,10 @@ void ip6_route_input(struct sk_buff *skb)
711 .ip6_u = { 711 .ip6_u = {
712 .daddr = iph->daddr, 712 .daddr = iph->daddr,
713 .saddr = iph->saddr, 713 .saddr = iph->saddr,
714#ifdef CONFIG_IPV6_ROUTE_FWMARK 714 .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK,
715 .fwmark = skb->nfmark,
716#endif
717 .flowlabel = (* (u32 *) iph)&IPV6_FLOWINFO_MASK,
718 }, 715 },
719 }, 716 },
717 .mark = skb->mark,
720 .proto = iph->nexthdr, 718 .proto = iph->nexthdr,
721 }; 719 };
722 720
@@ -942,7 +940,7 @@ struct dst_entry *ndisc_dst_alloc(struct net_device *dev,
942 fib6_force_start_gc(); 940 fib6_force_start_gc();
943 941
944out: 942out:
945 return (struct dst_entry *)rt; 943 return &rt->u.dst;
946} 944}
947 945
948int ndisc_dst_gc(int *more) 946int ndisc_dst_gc(int *more)
@@ -1225,7 +1223,7 @@ out:
1225 if (idev) 1223 if (idev)
1226 in6_dev_put(idev); 1224 in6_dev_put(idev);
1227 if (rt) 1225 if (rt)
1228 dst_free((struct dst_entry *) rt); 1226 dst_free(&rt->u.dst);
1229 return err; 1227 return err;
1230} 1228}
1231 1229
@@ -1751,9 +1749,9 @@ static inline int ip6_pkt_drop(struct sk_buff *skb, int code)
1751{ 1749{
1752 int type = ipv6_addr_type(&skb->nh.ipv6h->daddr); 1750 int type = ipv6_addr_type(&skb->nh.ipv6h->daddr);
1753 if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED) 1751 if (type == IPV6_ADDR_ANY || type == IPV6_ADDR_RESERVED)
1754 IP6_INC_STATS(IPSTATS_MIB_INADDRERRORS); 1752 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_INADDRERRORS);
1755 1753
1756 IP6_INC_STATS(IPSTATS_MIB_OUTNOROUTES); 1754 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_OUTNOROUTES);
1757 icmpv6_send(skb, ICMPV6_DEST_UNREACH, code, 0, skb->dev); 1755 icmpv6_send(skb, ICMPV6_DEST_UNREACH, code, 0, skb->dev);
1758 kfree_skb(skb); 1756 kfree_skb(skb);
1759 return 0; 1757 return 0;
@@ -1824,7 +1822,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
1824 rt->rt6i_flags |= RTF_LOCAL; 1822 rt->rt6i_flags |= RTF_LOCAL;
1825 rt->rt6i_nexthop = ndisc_get_neigh(rt->rt6i_dev, &rt->rt6i_gateway); 1823 rt->rt6i_nexthop = ndisc_get_neigh(rt->rt6i_dev, &rt->rt6i_gateway);
1826 if (rt->rt6i_nexthop == NULL) { 1824 if (rt->rt6i_nexthop == NULL) {
1827 dst_free((struct dst_entry *) rt); 1825 dst_free(&rt->u.dst);
1828 return ERR_PTR(-ENOMEM); 1826 return ERR_PTR(-ENOMEM);
1829 } 1827 }
1830 1828
@@ -2008,6 +2006,20 @@ int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
2008 return ip6_route_add(&cfg); 2006 return ip6_route_add(&cfg);
2009} 2007}
2010 2008
2009static inline size_t rt6_nlmsg_size(void)
2010{
2011 return NLMSG_ALIGN(sizeof(struct rtmsg))
2012 + nla_total_size(16) /* RTA_SRC */
2013 + nla_total_size(16) /* RTA_DST */
2014 + nla_total_size(16) /* RTA_GATEWAY */
2015 + nla_total_size(16) /* RTA_PREFSRC */
2016 + nla_total_size(4) /* RTA_TABLE */
2017 + nla_total_size(4) /* RTA_IIF */
2018 + nla_total_size(4) /* RTA_OIF */
2019 + nla_total_size(4) /* RTA_PRIORITY */
2020 + nla_total_size(sizeof(struct rta_cacheinfo));
2021}
2022
2011static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, 2023static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
2012 struct in6_addr *dst, struct in6_addr *src, 2024 struct in6_addr *dst, struct in6_addr *src,
2013 int iif, int type, u32 pid, u32 seq, 2025 int iif, int type, u32 pid, u32 seq,
@@ -2015,7 +2027,7 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
2015{ 2027{
2016 struct rtmsg *rtm; 2028 struct rtmsg *rtm;
2017 struct nlmsghdr *nlh; 2029 struct nlmsghdr *nlh;
2018 struct rta_cacheinfo ci; 2030 long expires;
2019 u32 table; 2031 u32 table;
2020 2032
2021 if (prefix) { /* user wants prefix routes only */ 2033 if (prefix) { /* user wants prefix routes only */
@@ -2089,18 +2101,11 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt,
2089 NLA_PUT_U32(skb, RTA_OIF, rt->rt6i_dev->ifindex); 2101 NLA_PUT_U32(skb, RTA_OIF, rt->rt6i_dev->ifindex);
2090 2102
2091 NLA_PUT_U32(skb, RTA_PRIORITY, rt->rt6i_metric); 2103 NLA_PUT_U32(skb, RTA_PRIORITY, rt->rt6i_metric);
2092 ci.rta_lastuse = jiffies_to_clock_t(jiffies - rt->u.dst.lastuse); 2104
2093 if (rt->rt6i_expires) 2105 expires = rt->rt6i_expires ? rt->rt6i_expires - jiffies : 0;
2094 ci.rta_expires = jiffies_to_clock_t(rt->rt6i_expires - jiffies); 2106 if (rtnl_put_cacheinfo(skb, &rt->u.dst, 0, 0, 0,
2095 else 2107 expires, rt->u.dst.error) < 0)
2096 ci.rta_expires = 0; 2108 goto nla_put_failure;
2097 ci.rta_used = rt->u.dst.__use;
2098 ci.rta_clntref = atomic_read(&rt->u.dst.__refcnt);
2099 ci.rta_error = rt->u.dst.error;
2100 ci.rta_id = 0;
2101 ci.rta_ts = 0;
2102 ci.rta_tsage = 0;
2103 NLA_PUT(skb, RTA_CACHEINFO, sizeof(ci), &ci);
2104 2109
2105 return nlmsg_end(skb, nlh); 2110 return nlmsg_end(skb, nlh);
2106 2111
@@ -2202,7 +2207,6 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info)
2202 struct sk_buff *skb; 2207 struct sk_buff *skb;
2203 u32 pid = 0, seq = 0; 2208 u32 pid = 0, seq = 0;
2204 struct nlmsghdr *nlh = NULL; 2209 struct nlmsghdr *nlh = NULL;
2205 int payload = sizeof(struct rtmsg) + 256;
2206 int err = -ENOBUFS; 2210 int err = -ENOBUFS;
2207 2211
2208 if (info) { 2212 if (info) {
@@ -2212,15 +2216,13 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info)
2212 seq = nlh->nlmsg_seq; 2216 seq = nlh->nlmsg_seq;
2213 } 2217 }
2214 2218
2215 skb = nlmsg_new(nlmsg_total_size(payload), gfp_any()); 2219 skb = nlmsg_new(rt6_nlmsg_size(), gfp_any());
2216 if (skb == NULL) 2220 if (skb == NULL)
2217 goto errout; 2221 goto errout;
2218 2222
2219 err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0); 2223 err = rt6_fill_node(skb, rt, NULL, NULL, 0, event, pid, seq, 0, 0);
2220 if (err < 0) { 2224 /* failure implies BUG in rt6_nlmsg_size() */
2221 kfree_skb(skb); 2225 BUG_ON(err < 0);
2222 goto errout;
2223 }
2224 2226
2225 err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any()); 2227 err = rtnl_notify(skb, pid, RTNLGRP_IPV6_ROUTE, nlh, gfp_any());
2226errout: 2228errout:
@@ -2248,7 +2250,6 @@ struct rt6_proc_arg
2248static int rt6_info_route(struct rt6_info *rt, void *p_arg) 2250static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2249{ 2251{
2250 struct rt6_proc_arg *arg = (struct rt6_proc_arg *) p_arg; 2252 struct rt6_proc_arg *arg = (struct rt6_proc_arg *) p_arg;
2251 int i;
2252 2253
2253 if (arg->skip < arg->offset / RT6_INFO_LEN) { 2254 if (arg->skip < arg->offset / RT6_INFO_LEN) {
2254 arg->skip++; 2255 arg->skip++;
@@ -2258,38 +2259,28 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2258 if (arg->len >= arg->length) 2259 if (arg->len >= arg->length)
2259 return 0; 2260 return 0;
2260 2261
2261 for (i=0; i<16; i++) { 2262 arg->len += sprintf(arg->buffer + arg->len,
2262 sprintf(arg->buffer + arg->len, "%02x", 2263 NIP6_SEQFMT " %02x ",
2263 rt->rt6i_dst.addr.s6_addr[i]); 2264 NIP6(rt->rt6i_dst.addr),
2264 arg->len += 2;
2265 }
2266 arg->len += sprintf(arg->buffer + arg->len, " %02x ",
2267 rt->rt6i_dst.plen); 2265 rt->rt6i_dst.plen);
2268 2266
2269#ifdef CONFIG_IPV6_SUBTREES 2267#ifdef CONFIG_IPV6_SUBTREES
2270 for (i=0; i<16; i++) { 2268 arg->len += sprintf(arg->buffer + arg->len,
2271 sprintf(arg->buffer + arg->len, "%02x", 2269 NIP6_SEQFMT " %02x ",
2272 rt->rt6i_src.addr.s6_addr[i]); 2270 NIP6(rt->rt6i_src.addr),
2273 arg->len += 2;
2274 }
2275 arg->len += sprintf(arg->buffer + arg->len, " %02x ",
2276 rt->rt6i_src.plen); 2271 rt->rt6i_src.plen);
2277#else 2272#else
2278 sprintf(arg->buffer + arg->len, 2273 arg->len += sprintf(arg->buffer + arg->len,
2279 "00000000000000000000000000000000 00 "); 2274 "00000000000000000000000000000000 00 ");
2280 arg->len += 36;
2281#endif 2275#endif
2282 2276
2283 if (rt->rt6i_nexthop) { 2277 if (rt->rt6i_nexthop) {
2284 for (i=0; i<16; i++) { 2278 arg->len += sprintf(arg->buffer + arg->len,
2285 sprintf(arg->buffer + arg->len, "%02x", 2279 NIP6_SEQFMT,
2286 rt->rt6i_nexthop->primary_key[i]); 2280 NIP6(*((struct in6_addr *)rt->rt6i_nexthop->primary_key)));
2287 arg->len += 2;
2288 }
2289 } else { 2281 } else {
2290 sprintf(arg->buffer + arg->len, 2282 arg->len += sprintf(arg->buffer + arg->len,
2291 "00000000000000000000000000000000"); 2283 "00000000000000000000000000000000");
2292 arg->len += 32;
2293 } 2284 }
2294 arg->len += sprintf(arg->buffer + arg->len, 2285 arg->len += sprintf(arg->buffer + arg->len,
2295 " %08x %08x %08x %08x %8s\n", 2286 " %08x %08x %08x %08x %8s\n",
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index be699f85b2c7..77b7b0911438 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -60,7 +60,7 @@
60 */ 60 */
61 61
62#define HASH_SIZE 16 62#define HASH_SIZE 16
63#define HASH(addr) ((addr^(addr>>4))&0xF) 63#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)
64 64
65static int ipip6_fb_tunnel_init(struct net_device *dev); 65static int ipip6_fb_tunnel_init(struct net_device *dev);
66static int ipip6_tunnel_init(struct net_device *dev); 66static int ipip6_tunnel_init(struct net_device *dev);
@@ -76,7 +76,7 @@ static struct ip_tunnel **tunnels[4] = { tunnels_wc, tunnels_l, tunnels_r, tunne
76 76
77static DEFINE_RWLOCK(ipip6_lock); 77static DEFINE_RWLOCK(ipip6_lock);
78 78
79static struct ip_tunnel * ipip6_tunnel_lookup(u32 remote, u32 local) 79static struct ip_tunnel * ipip6_tunnel_lookup(__be32 remote, __be32 local)
80{ 80{
81 unsigned h0 = HASH(remote); 81 unsigned h0 = HASH(remote);
82 unsigned h1 = HASH(local); 82 unsigned h1 = HASH(local);
@@ -102,8 +102,8 @@ static struct ip_tunnel * ipip6_tunnel_lookup(u32 remote, u32 local)
102 102
103static struct ip_tunnel ** ipip6_bucket(struct ip_tunnel *t) 103static struct ip_tunnel ** ipip6_bucket(struct ip_tunnel *t)
104{ 104{
105 u32 remote = t->parms.iph.daddr; 105 __be32 remote = t->parms.iph.daddr;
106 u32 local = t->parms.iph.saddr; 106 __be32 local = t->parms.iph.saddr;
107 unsigned h = 0; 107 unsigned h = 0;
108 int prio = 0; 108 int prio = 0;
109 109
@@ -144,8 +144,8 @@ static void ipip6_tunnel_link(struct ip_tunnel *t)
144 144
145static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int create) 145static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int create)
146{ 146{
147 u32 remote = parms->iph.daddr; 147 __be32 remote = parms->iph.daddr;
148 u32 local = parms->iph.saddr; 148 __be32 local = parms->iph.saddr;
149 struct ip_tunnel *t, **tp, *nt; 149 struct ip_tunnel *t, **tp, *nt;
150 struct net_device *dev; 150 struct net_device *dev;
151 unsigned h = 0; 151 unsigned h = 0;
@@ -405,9 +405,9 @@ out:
405/* Returns the embedded IPv4 address if the IPv6 address 405/* Returns the embedded IPv4 address if the IPv6 address
406 comes from 6to4 (RFC 3056) addr space */ 406 comes from 6to4 (RFC 3056) addr space */
407 407
408static inline u32 try_6to4(struct in6_addr *v6dst) 408static inline __be32 try_6to4(struct in6_addr *v6dst)
409{ 409{
410 u32 dst = 0; 410 __be32 dst = 0;
411 411
412 if (v6dst->s6_addr16[0] == htons(0x2002)) { 412 if (v6dst->s6_addr16[0] == htons(0x2002)) {
413 /* 6to4 v6 addr has 16 bits prefix, 32 v4addr, 16 SLA, ... */ 413 /* 6to4 v6 addr has 16 bits prefix, 32 v4addr, 16 SLA, ... */
@@ -432,7 +432,7 @@ static int ipip6_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
432 struct net_device *tdev; /* Device to other host */ 432 struct net_device *tdev; /* Device to other host */
433 struct iphdr *iph; /* Our new IP header */ 433 struct iphdr *iph; /* Our new IP header */
434 int max_headroom; /* The extra header space needed */ 434 int max_headroom; /* The extra header space needed */
435 u32 dst = tiph->daddr; 435 __be32 dst = tiph->daddr;
436 int mtu; 436 int mtu;
437 struct in6_addr *addr6; 437 struct in6_addr *addr6;
438 int addr_type; 438 int addr_type;
@@ -809,7 +809,7 @@ static void __exit sit_destroy_tunnels(void)
809 } 809 }
810} 810}
811 811
812void __exit sit_cleanup(void) 812static void __exit sit_cleanup(void)
813{ 813{
814 inet_del_protocol(&sit_protocol, IPPROTO_IPV6); 814 inet_del_protocol(&sit_protocol, IPPROTO_IPV6);
815 815
@@ -819,7 +819,7 @@ void __exit sit_cleanup(void)
819 rtnl_unlock(); 819 rtnl_unlock();
820} 820}
821 821
822int __init sit_init(void) 822static int __init sit_init(void)
823{ 823{
824 int err; 824 int err;
825 825
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 4c2a7c0cafef..c25e930c2c69 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -66,10 +66,13 @@
66#include <linux/proc_fs.h> 66#include <linux/proc_fs.h>
67#include <linux/seq_file.h> 67#include <linux/seq_file.h>
68 68
69#include <linux/crypto.h>
70#include <linux/scatterlist.h>
71
69/* Socket used for sending RSTs and ACKs */ 72/* Socket used for sending RSTs and ACKs */
70static struct socket *tcp6_socket; 73static struct socket *tcp6_socket;
71 74
72static void tcp_v6_send_reset(struct sk_buff *skb); 75static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
73static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); 76static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req);
74static void tcp_v6_send_check(struct sock *sk, int len, 77static void tcp_v6_send_check(struct sock *sk, int len,
75 struct sk_buff *skb); 78 struct sk_buff *skb);
@@ -78,6 +81,10 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb);
78 81
79static struct inet_connection_sock_af_ops ipv6_mapped; 82static struct inet_connection_sock_af_ops ipv6_mapped;
80static struct inet_connection_sock_af_ops ipv6_specific; 83static struct inet_connection_sock_af_ops ipv6_specific;
84#ifdef CONFIG_TCP_MD5SIG
85static struct tcp_sock_af_ops tcp_sock_ipv6_specific;
86static struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific;
87#endif
81 88
82static int tcp_v6_get_port(struct sock *sk, unsigned short snum) 89static int tcp_v6_get_port(struct sock *sk, unsigned short snum)
83{ 90{
@@ -98,27 +105,20 @@ static void tcp_v6_hash(struct sock *sk)
98 } 105 }
99} 106}
100 107
101static __inline__ u16 tcp_v6_check(struct tcphdr *th, int len, 108static __inline__ __sum16 tcp_v6_check(struct tcphdr *th, int len,
102 struct in6_addr *saddr, 109 struct in6_addr *saddr,
103 struct in6_addr *daddr, 110 struct in6_addr *daddr,
104 unsigned long base) 111 __wsum base)
105{ 112{
106 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base); 113 return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base);
107} 114}
108 115
109static __u32 tcp_v6_init_sequence(struct sock *sk, struct sk_buff *skb) 116static __u32 tcp_v6_init_sequence(struct sk_buff *skb)
110{ 117{
111 if (skb->protocol == htons(ETH_P_IPV6)) { 118 return secure_tcpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32,
112 return secure_tcpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32, 119 skb->nh.ipv6h->saddr.s6_addr32,
113 skb->nh.ipv6h->saddr.s6_addr32, 120 skb->h.th->dest,
114 skb->h.th->dest, 121 skb->h.th->source);
115 skb->h.th->source);
116 } else {
117 return secure_tcp_sequence_number(skb->nh.iph->daddr,
118 skb->nh.iph->saddr,
119 skb->h.th->dest,
120 skb->h.th->source);
121 }
122} 122}
123 123
124static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, 124static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
@@ -215,6 +215,9 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
215 215
216 icsk->icsk_af_ops = &ipv6_mapped; 216 icsk->icsk_af_ops = &ipv6_mapped;
217 sk->sk_backlog_rcv = tcp_v4_do_rcv; 217 sk->sk_backlog_rcv = tcp_v4_do_rcv;
218#ifdef CONFIG_TCP_MD5SIG
219 tp->af_specific = &tcp_sock_ipv6_mapped_specific;
220#endif
218 221
219 err = tcp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); 222 err = tcp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin));
220 223
@@ -222,6 +225,9 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
222 icsk->icsk_ext_hdr_len = exthdrlen; 225 icsk->icsk_ext_hdr_len = exthdrlen;
223 icsk->icsk_af_ops = &ipv6_specific; 226 icsk->icsk_af_ops = &ipv6_specific;
224 sk->sk_backlog_rcv = tcp_v6_do_rcv; 227 sk->sk_backlog_rcv = tcp_v6_do_rcv;
228#ifdef CONFIG_TCP_MD5SIG
229 tp->af_specific = &tcp_sock_ipv6_specific;
230#endif
225 goto failure; 231 goto failure;
226 } else { 232 } else {
227 ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000FFFF), 233 ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000FFFF),
@@ -310,7 +316,7 @@ failure:
310} 316}
311 317
312static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 318static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
313 int type, int code, int offset, __u32 info) 319 int type, int code, int offset, __be32 info)
314{ 320{
315 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data; 321 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data;
316 const struct tcphdr *th = (struct tcphdr *)(skb->data+offset); 322 const struct tcphdr *th = (struct tcphdr *)(skb->data+offset);
@@ -509,8 +515,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req,
509 515
510 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr); 516 ipv6_addr_copy(&fl.fl6_dst, &treq->rmt_addr);
511 err = ip6_xmit(sk, skb, &fl, opt, 0); 517 err = ip6_xmit(sk, skb, &fl, opt, 0);
512 if (err == NET_XMIT_CN) 518 err = net_xmit_eval(err);
513 err = 0;
514 } 519 }
515 520
516done: 521done:
@@ -526,7 +531,396 @@ static void tcp_v6_reqsk_destructor(struct request_sock *req)
526 kfree_skb(inet6_rsk(req)->pktopts); 531 kfree_skb(inet6_rsk(req)->pktopts);
527} 532}
528 533
529static struct request_sock_ops tcp6_request_sock_ops = { 534#ifdef CONFIG_TCP_MD5SIG
535static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk,
536 struct in6_addr *addr)
537{
538 struct tcp_sock *tp = tcp_sk(sk);
539 int i;
540
541 BUG_ON(tp == NULL);
542
543 if (!tp->md5sig_info || !tp->md5sig_info->entries6)
544 return NULL;
545
546 for (i = 0; i < tp->md5sig_info->entries6; i++) {
547 if (ipv6_addr_cmp(&tp->md5sig_info->keys6[i].addr, addr) == 0)
548 return (struct tcp_md5sig_key *)&tp->md5sig_info->keys6[i];
549 }
550 return NULL;
551}
552
553static struct tcp_md5sig_key *tcp_v6_md5_lookup(struct sock *sk,
554 struct sock *addr_sk)
555{
556 return tcp_v6_md5_do_lookup(sk, &inet6_sk(addr_sk)->daddr);
557}
558
559static struct tcp_md5sig_key *tcp_v6_reqsk_md5_lookup(struct sock *sk,
560 struct request_sock *req)
561{
562 return tcp_v6_md5_do_lookup(sk, &inet6_rsk(req)->rmt_addr);
563}
564
565static int tcp_v6_md5_do_add(struct sock *sk, struct in6_addr *peer,
566 char *newkey, u8 newkeylen)
567{
568 /* Add key to the list */
569 struct tcp6_md5sig_key *key;
570 struct tcp_sock *tp = tcp_sk(sk);
571 struct tcp6_md5sig_key *keys;
572
573 key = (struct tcp6_md5sig_key*) tcp_v6_md5_do_lookup(sk, peer);
574 if (key) {
575 /* modify existing entry - just update that one */
576 kfree(key->key);
577 key->key = newkey;
578 key->keylen = newkeylen;
579 } else {
580 /* reallocate new list if current one is full. */
581 if (!tp->md5sig_info) {
582 tp->md5sig_info = kzalloc(sizeof(*tp->md5sig_info), GFP_ATOMIC);
583 if (!tp->md5sig_info) {
584 kfree(newkey);
585 return -ENOMEM;
586 }
587 }
588 tcp_alloc_md5sig_pool();
589 if (tp->md5sig_info->alloced6 == tp->md5sig_info->entries6) {
590 keys = kmalloc((sizeof (tp->md5sig_info->keys6[0]) *
591 (tp->md5sig_info->entries6 + 1)), GFP_ATOMIC);
592
593 if (!keys) {
594 tcp_free_md5sig_pool();
595 kfree(newkey);
596 return -ENOMEM;
597 }
598
599 if (tp->md5sig_info->entries6)
600 memmove(keys, tp->md5sig_info->keys6,
601 (sizeof (tp->md5sig_info->keys6[0]) *
602 tp->md5sig_info->entries6));
603
604 kfree(tp->md5sig_info->keys6);
605 tp->md5sig_info->keys6 = keys;
606 tp->md5sig_info->alloced6++;
607 }
608
609 ipv6_addr_copy(&tp->md5sig_info->keys6[tp->md5sig_info->entries6].addr,
610 peer);
611 tp->md5sig_info->keys6[tp->md5sig_info->entries6].key = newkey;
612 tp->md5sig_info->keys6[tp->md5sig_info->entries6].keylen = newkeylen;
613
614 tp->md5sig_info->entries6++;
615 }
616 return 0;
617}
618
619static int tcp_v6_md5_add_func(struct sock *sk, struct sock *addr_sk,
620 u8 *newkey, __u8 newkeylen)
621{
622 return tcp_v6_md5_do_add(sk, &inet6_sk(addr_sk)->daddr,
623 newkey, newkeylen);
624}
625
626static int tcp_v6_md5_do_del(struct sock *sk, struct in6_addr *peer)
627{
628 struct tcp_sock *tp = tcp_sk(sk);
629 int i;
630
631 for (i = 0; i < tp->md5sig_info->entries6; i++) {
632 if (ipv6_addr_cmp(&tp->md5sig_info->keys6[i].addr, peer) == 0) {
633 /* Free the key */
634 kfree(tp->md5sig_info->keys6[i].key);
635 tp->md5sig_info->entries6--;
636
637 if (tp->md5sig_info->entries6 == 0) {
638 kfree(tp->md5sig_info->keys6);
639 tp->md5sig_info->keys6 = NULL;
640
641 tcp_free_md5sig_pool();
642
643 return 0;
644 } else {
645 /* shrink the database */
646 if (tp->md5sig_info->entries6 != i)
647 memmove(&tp->md5sig_info->keys6[i],
648 &tp->md5sig_info->keys6[i+1],
649 (tp->md5sig_info->entries6 - i)
650 * sizeof (tp->md5sig_info->keys6[0]));
651 }
652 }
653 }
654 return -ENOENT;
655}
656
657static void tcp_v6_clear_md5_list (struct sock *sk)
658{
659 struct tcp_sock *tp = tcp_sk(sk);
660 int i;
661
662 if (tp->md5sig_info->entries6) {
663 for (i = 0; i < tp->md5sig_info->entries6; i++)
664 kfree(tp->md5sig_info->keys6[i].key);
665 tp->md5sig_info->entries6 = 0;
666 tcp_free_md5sig_pool();
667 }
668
669 kfree(tp->md5sig_info->keys6);
670 tp->md5sig_info->keys6 = NULL;
671 tp->md5sig_info->alloced6 = 0;
672
673 if (tp->md5sig_info->entries4) {
674 for (i = 0; i < tp->md5sig_info->entries4; i++)
675 kfree(tp->md5sig_info->keys4[i].key);
676 tp->md5sig_info->entries4 = 0;
677 tcp_free_md5sig_pool();
678 }
679
680 kfree(tp->md5sig_info->keys4);
681 tp->md5sig_info->keys4 = NULL;
682 tp->md5sig_info->alloced4 = 0;
683}
684
685static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
686 int optlen)
687{
688 struct tcp_md5sig cmd;
689 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr;
690 u8 *newkey;
691
692 if (optlen < sizeof(cmd))
693 return -EINVAL;
694
695 if (copy_from_user(&cmd, optval, sizeof(cmd)))
696 return -EFAULT;
697
698 if (sin6->sin6_family != AF_INET6)
699 return -EINVAL;
700
701 if (!cmd.tcpm_keylen) {
702 if (!tcp_sk(sk)->md5sig_info)
703 return -ENOENT;
704 if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED)
705 return tcp_v4_md5_do_del(sk, sin6->sin6_addr.s6_addr32[3]);
706 return tcp_v6_md5_do_del(sk, &sin6->sin6_addr);
707 }
708
709 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
710 return -EINVAL;
711
712 if (!tcp_sk(sk)->md5sig_info) {
713 struct tcp_sock *tp = tcp_sk(sk);
714 struct tcp_md5sig_info *p;
715
716 p = kzalloc(sizeof(struct tcp_md5sig_info), GFP_KERNEL);
717 if (!p)
718 return -ENOMEM;
719
720 tp->md5sig_info = p;
721 }
722
723 newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
724 if (!newkey)
725 return -ENOMEM;
726 if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED) {
727 return tcp_v4_md5_do_add(sk, sin6->sin6_addr.s6_addr32[3],
728 newkey, cmd.tcpm_keylen);
729 }
730 return tcp_v6_md5_do_add(sk, &sin6->sin6_addr, newkey, cmd.tcpm_keylen);
731}
732
733static int tcp_v6_do_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
734 struct in6_addr *saddr,
735 struct in6_addr *daddr,
736 struct tcphdr *th, int protocol,
737 int tcplen)
738{
739 struct scatterlist sg[4];
740 __u16 data_len;
741 int block = 0;
742 __sum16 cksum;
743 struct tcp_md5sig_pool *hp;
744 struct tcp6_pseudohdr *bp;
745 struct hash_desc *desc;
746 int err;
747 unsigned int nbytes = 0;
748
749 hp = tcp_get_md5sig_pool();
750 if (!hp) {
751 printk(KERN_WARNING "%s(): hash pool not found...\n", __FUNCTION__);
752 goto clear_hash_noput;
753 }
754 bp = &hp->md5_blk.ip6;
755 desc = &hp->md5_desc;
756
757 /* 1. TCP pseudo-header (RFC2460) */
758 ipv6_addr_copy(&bp->saddr, saddr);
759 ipv6_addr_copy(&bp->daddr, daddr);
760 bp->len = htonl(tcplen);
761 bp->protocol = htonl(protocol);
762
763 sg_set_buf(&sg[block++], bp, sizeof(*bp));
764 nbytes += sizeof(*bp);
765
766 /* 2. TCP header, excluding options */
767 cksum = th->check;
768 th->check = 0;
769 sg_set_buf(&sg[block++], th, sizeof(*th));
770 nbytes += sizeof(*th);
771
772 /* 3. TCP segment data (if any) */
773 data_len = tcplen - (th->doff << 2);
774 if (data_len > 0) {
775 u8 *data = (u8 *)th + (th->doff << 2);
776 sg_set_buf(&sg[block++], data, data_len);
777 nbytes += data_len;
778 }
779
780 /* 4. shared key */
781 sg_set_buf(&sg[block++], key->key, key->keylen);
782 nbytes += key->keylen;
783
784 /* Now store the hash into the packet */
785 err = crypto_hash_init(desc);
786 if (err) {
787 printk(KERN_WARNING "%s(): hash_init failed\n", __FUNCTION__);
788 goto clear_hash;
789 }
790 err = crypto_hash_update(desc, sg, nbytes);
791 if (err) {
792 printk(KERN_WARNING "%s(): hash_update failed\n", __FUNCTION__);
793 goto clear_hash;
794 }
795 err = crypto_hash_final(desc, md5_hash);
796 if (err) {
797 printk(KERN_WARNING "%s(): hash_final failed\n", __FUNCTION__);
798 goto clear_hash;
799 }
800
801 /* Reset header, and free up the crypto */
802 tcp_put_md5sig_pool();
803 th->check = cksum;
804out:
805 return 0;
806clear_hash:
807 tcp_put_md5sig_pool();
808clear_hash_noput:
809 memset(md5_hash, 0, 16);
810 goto out;
811}
812
813static int tcp_v6_calc_md5_hash(char *md5_hash, struct tcp_md5sig_key *key,
814 struct sock *sk,
815 struct dst_entry *dst,
816 struct request_sock *req,
817 struct tcphdr *th, int protocol,
818 int tcplen)
819{
820 struct in6_addr *saddr, *daddr;
821
822 if (sk) {
823 saddr = &inet6_sk(sk)->saddr;
824 daddr = &inet6_sk(sk)->daddr;
825 } else {
826 saddr = &inet6_rsk(req)->loc_addr;
827 daddr = &inet6_rsk(req)->rmt_addr;
828 }
829 return tcp_v6_do_calc_md5_hash(md5_hash, key,
830 saddr, daddr,
831 th, protocol, tcplen);
832}
833
834static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb)
835{
836 __u8 *hash_location = NULL;
837 struct tcp_md5sig_key *hash_expected;
838 struct ipv6hdr *ip6h = skb->nh.ipv6h;
839 struct tcphdr *th = skb->h.th;
840 int length = (th->doff << 2) - sizeof (*th);
841 int genhash;
842 u8 *ptr;
843 u8 newhash[16];
844
845 hash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr);
846
847 /* If the TCP option is too short, we can short cut */
848 if (length < TCPOLEN_MD5SIG)
849 return hash_expected ? 1 : 0;
850
851 /* parse options */
852 ptr = (u8*)(th + 1);
853 while (length > 0) {
854 int opcode = *ptr++;
855 int opsize;
856
857 switch(opcode) {
858 case TCPOPT_EOL:
859 goto done_opts;
860 case TCPOPT_NOP:
861 length--;
862 continue;
863 default:
864 opsize = *ptr++;
865 if (opsize < 2 || opsize > length)
866 goto done_opts;
867 if (opcode == TCPOPT_MD5SIG) {
868 hash_location = ptr;
869 goto done_opts;
870 }
871 }
872 ptr += opsize - 2;
873 length -= opsize;
874 }
875
876done_opts:
877 /* do we have a hash as expected? */
878 if (!hash_expected) {
879 if (!hash_location)
880 return 0;
881 if (net_ratelimit()) {
882 printk(KERN_INFO "MD5 Hash NOT expected but found "
883 "(" NIP6_FMT ", %u)->"
884 "(" NIP6_FMT ", %u)\n",
885 NIP6(ip6h->saddr), ntohs(th->source),
886 NIP6(ip6h->daddr), ntohs(th->dest));
887 }
888 return 1;
889 }
890
891 if (!hash_location) {
892 if (net_ratelimit()) {
893 printk(KERN_INFO "MD5 Hash expected but NOT found "
894 "(" NIP6_FMT ", %u)->"
895 "(" NIP6_FMT ", %u)\n",
896 NIP6(ip6h->saddr), ntohs(th->source),
897 NIP6(ip6h->daddr), ntohs(th->dest));
898 }
899 return 1;
900 }
901
902 /* check the signature */
903 genhash = tcp_v6_do_calc_md5_hash(newhash,
904 hash_expected,
905 &ip6h->saddr, &ip6h->daddr,
906 th, sk->sk_protocol,
907 skb->len);
908 if (genhash || memcmp(hash_location, newhash, 16) != 0) {
909 if (net_ratelimit()) {
910 printk(KERN_INFO "MD5 Hash %s for "
911 "(" NIP6_FMT ", %u)->"
912 "(" NIP6_FMT ", %u)\n",
913 genhash ? "failed" : "mismatch",
914 NIP6(ip6h->saddr), ntohs(th->source),
915 NIP6(ip6h->daddr), ntohs(th->dest));
916 }
917 return 1;
918 }
919 return 0;
920}
921#endif
922
923static struct request_sock_ops tcp6_request_sock_ops __read_mostly = {
530 .family = AF_INET6, 924 .family = AF_INET6,
531 .obj_size = sizeof(struct tcp6_request_sock), 925 .obj_size = sizeof(struct tcp6_request_sock),
532 .rtx_syn_ack = tcp_v6_send_synack, 926 .rtx_syn_ack = tcp_v6_send_synack,
@@ -535,9 +929,16 @@ static struct request_sock_ops tcp6_request_sock_ops = {
535 .send_reset = tcp_v6_send_reset 929 .send_reset = tcp_v6_send_reset
536}; 930};
537 931
932#ifdef CONFIG_TCP_MD5SIG
933static struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = {
934 .md5_lookup = tcp_v6_reqsk_md5_lookup,
935};
936#endif
937
538static struct timewait_sock_ops tcp6_timewait_sock_ops = { 938static struct timewait_sock_ops tcp6_timewait_sock_ops = {
539 .twsk_obj_size = sizeof(struct tcp6_timewait_sock), 939 .twsk_obj_size = sizeof(struct tcp6_timewait_sock),
540 .twsk_unique = tcp_twsk_unique, 940 .twsk_unique = tcp_twsk_unique,
941 .twsk_destructor= tcp_twsk_destructor,
541}; 942};
542 943
543static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb) 944static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
@@ -547,7 +948,7 @@ static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb)
547 948
548 if (skb->ip_summed == CHECKSUM_PARTIAL) { 949 if (skb->ip_summed == CHECKSUM_PARTIAL) {
549 th->check = ~csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 0); 950 th->check = ~csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 0);
550 skb->csum = offsetof(struct tcphdr, check); 951 skb->csum_offset = offsetof(struct tcphdr, check);
551 } else { 952 } else {
552 th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 953 th->check = csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP,
553 csum_partial((char *)th, th->doff<<2, 954 csum_partial((char *)th, th->doff<<2,
@@ -569,16 +970,20 @@ static int tcp_v6_gso_send_check(struct sk_buff *skb)
569 th->check = 0; 970 th->check = 0;
570 th->check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr, skb->len, 971 th->check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr, skb->len,
571 IPPROTO_TCP, 0); 972 IPPROTO_TCP, 0);
572 skb->csum = offsetof(struct tcphdr, check); 973 skb->csum_offset = offsetof(struct tcphdr, check);
573 skb->ip_summed = CHECKSUM_PARTIAL; 974 skb->ip_summed = CHECKSUM_PARTIAL;
574 return 0; 975 return 0;
575} 976}
576 977
577static void tcp_v6_send_reset(struct sk_buff *skb) 978static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
578{ 979{
579 struct tcphdr *th = skb->h.th, *t1; 980 struct tcphdr *th = skb->h.th, *t1;
580 struct sk_buff *buff; 981 struct sk_buff *buff;
581 struct flowi fl; 982 struct flowi fl;
983 int tot_len = sizeof(*th);
984#ifdef CONFIG_TCP_MD5SIG
985 struct tcp_md5sig_key *key;
986#endif
582 987
583 if (th->rst) 988 if (th->rst)
584 return; 989 return;
@@ -586,25 +991,35 @@ static void tcp_v6_send_reset(struct sk_buff *skb)
586 if (!ipv6_unicast_destination(skb)) 991 if (!ipv6_unicast_destination(skb))
587 return; 992 return;
588 993
994#ifdef CONFIG_TCP_MD5SIG
995 if (sk)
996 key = tcp_v6_md5_do_lookup(sk, &skb->nh.ipv6h->daddr);
997 else
998 key = NULL;
999
1000 if (key)
1001 tot_len += TCPOLEN_MD5SIG_ALIGNED;
1002#endif
1003
589 /* 1004 /*
590 * We need to grab some memory, and put together an RST, 1005 * We need to grab some memory, and put together an RST,
591 * and then put it into the queue to be sent. 1006 * and then put it into the queue to be sent.
592 */ 1007 */
593 1008
594 buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + sizeof(struct tcphdr), 1009 buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len,
595 GFP_ATOMIC); 1010 GFP_ATOMIC);
596 if (buff == NULL) 1011 if (buff == NULL)
597 return; 1012 return;
598 1013
599 skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + sizeof(struct tcphdr)); 1014 skb_reserve(buff, MAX_HEADER + sizeof(struct ipv6hdr) + tot_len);
600 1015
601 t1 = (struct tcphdr *) skb_push(buff,sizeof(struct tcphdr)); 1016 t1 = (struct tcphdr *) skb_push(buff, tot_len);
602 1017
603 /* Swap the send and the receive. */ 1018 /* Swap the send and the receive. */
604 memset(t1, 0, sizeof(*t1)); 1019 memset(t1, 0, sizeof(*t1));
605 t1->dest = th->source; 1020 t1->dest = th->source;
606 t1->source = th->dest; 1021 t1->source = th->dest;
607 t1->doff = sizeof(*t1)/4; 1022 t1->doff = tot_len / 4;
608 t1->rst = 1; 1023 t1->rst = 1;
609 1024
610 if(th->ack) { 1025 if(th->ack) {
@@ -615,6 +1030,22 @@ static void tcp_v6_send_reset(struct sk_buff *skb)
615 + skb->len - (th->doff<<2)); 1030 + skb->len - (th->doff<<2));
616 } 1031 }
617 1032
1033#ifdef CONFIG_TCP_MD5SIG
1034 if (key) {
1035 __be32 *opt = (__be32*)(t1 + 1);
1036 opt[0] = htonl((TCPOPT_NOP << 24) |
1037 (TCPOPT_NOP << 16) |
1038 (TCPOPT_MD5SIG << 8) |
1039 TCPOLEN_MD5SIG);
1040 tcp_v6_do_calc_md5_hash((__u8*)&opt[1],
1041 key,
1042 &skb->nh.ipv6h->daddr,
1043 &skb->nh.ipv6h->saddr,
1044 t1, IPPROTO_TCP,
1045 tot_len);
1046 }
1047#endif
1048
618 buff->csum = csum_partial((char *)t1, sizeof(*t1), 0); 1049 buff->csum = csum_partial((char *)t1, sizeof(*t1), 0);
619 1050
620 memset(&fl, 0, sizeof(fl)); 1051 memset(&fl, 0, sizeof(fl));
@@ -645,15 +1076,37 @@ static void tcp_v6_send_reset(struct sk_buff *skb)
645 kfree_skb(buff); 1076 kfree_skb(buff);
646} 1077}
647 1078
648static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts) 1079static void tcp_v6_send_ack(struct tcp_timewait_sock *tw,
1080 struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 ts)
649{ 1081{
650 struct tcphdr *th = skb->h.th, *t1; 1082 struct tcphdr *th = skb->h.th, *t1;
651 struct sk_buff *buff; 1083 struct sk_buff *buff;
652 struct flowi fl; 1084 struct flowi fl;
653 int tot_len = sizeof(struct tcphdr); 1085 int tot_len = sizeof(struct tcphdr);
1086 __be32 *topt;
1087#ifdef CONFIG_TCP_MD5SIG
1088 struct tcp_md5sig_key *key;
1089 struct tcp_md5sig_key tw_key;
1090#endif
1091
1092#ifdef CONFIG_TCP_MD5SIG
1093 if (!tw && skb->sk) {
1094 key = tcp_v6_md5_do_lookup(skb->sk, &skb->nh.ipv6h->daddr);
1095 } else if (tw && tw->tw_md5_keylen) {
1096 tw_key.key = tw->tw_md5_key;
1097 tw_key.keylen = tw->tw_md5_keylen;
1098 key = &tw_key;
1099 } else {
1100 key = NULL;
1101 }
1102#endif
654 1103
655 if (ts) 1104 if (ts)
656 tot_len += TCPOLEN_TSTAMP_ALIGNED; 1105 tot_len += TCPOLEN_TSTAMP_ALIGNED;
1106#ifdef CONFIG_TCP_MD5SIG
1107 if (key)
1108 tot_len += TCPOLEN_MD5SIG_ALIGNED;
1109#endif
657 1110
658 buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len, 1111 buff = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + tot_len,
659 GFP_ATOMIC); 1112 GFP_ATOMIC);
@@ -673,15 +1126,29 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32
673 t1->ack_seq = htonl(ack); 1126 t1->ack_seq = htonl(ack);
674 t1->ack = 1; 1127 t1->ack = 1;
675 t1->window = htons(win); 1128 t1->window = htons(win);
1129
1130 topt = (__be32 *)(t1 + 1);
676 1131
677 if (ts) { 1132 if (ts) {
678 u32 *ptr = (u32*)(t1 + 1); 1133 *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
679 *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | 1134 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
680 (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); 1135 *topt++ = htonl(tcp_time_stamp);
681 *ptr++ = htonl(tcp_time_stamp); 1136 *topt = htonl(ts);
682 *ptr = htonl(ts);
683 } 1137 }
684 1138
1139#ifdef CONFIG_TCP_MD5SIG
1140 if (key) {
1141 *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
1142 (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG);
1143 tcp_v6_do_calc_md5_hash((__u8 *)topt,
1144 key,
1145 &skb->nh.ipv6h->daddr,
1146 &skb->nh.ipv6h->saddr,
1147 t1, IPPROTO_TCP,
1148 tot_len);
1149 }
1150#endif
1151
685 buff->csum = csum_partial((char *)t1, tot_len, 0); 1152 buff->csum = csum_partial((char *)t1, tot_len, 0);
686 1153
687 memset(&fl, 0, sizeof(fl)); 1154 memset(&fl, 0, sizeof(fl));
@@ -712,9 +1179,9 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32
712static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb) 1179static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
713{ 1180{
714 struct inet_timewait_sock *tw = inet_twsk(sk); 1181 struct inet_timewait_sock *tw = inet_twsk(sk);
715 const struct tcp_timewait_sock *tcptw = tcp_twsk(sk); 1182 struct tcp_timewait_sock *tcptw = tcp_twsk(sk);
716 1183
717 tcp_v6_send_ack(skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt, 1184 tcp_v6_send_ack(tcptw, skb, tcptw->tw_snd_nxt, tcptw->tw_rcv_nxt,
718 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale, 1185 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,
719 tcptw->tw_ts_recent); 1186 tcptw->tw_ts_recent);
720 1187
@@ -723,7 +1190,7 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
723 1190
724static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) 1191static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req)
725{ 1192{
726 tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent); 1193 tcp_v6_send_ack(NULL, skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent);
727} 1194}
728 1195
729 1196
@@ -794,6 +1261,10 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
794 if (req == NULL) 1261 if (req == NULL)
795 goto drop; 1262 goto drop;
796 1263
1264#ifdef CONFIG_TCP_MD5SIG
1265 tcp_rsk(req)->af_specific = &tcp_request_sock_ipv6_ops;
1266#endif
1267
797 tcp_clear_options(&tmp_opt); 1268 tcp_clear_options(&tmp_opt);
798 tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr); 1269 tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);
799 tmp_opt.user_mss = tp->rx_opt.user_mss; 1270 tmp_opt.user_mss = tp->rx_opt.user_mss;
@@ -822,7 +1293,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
822 treq->iif = inet6_iif(skb); 1293 treq->iif = inet6_iif(skb);
823 1294
824 if (isn == 0) 1295 if (isn == 0)
825 isn = tcp_v6_init_sequence(sk,skb); 1296 isn = tcp_v6_init_sequence(skb);
826 1297
827 tcp_rsk(req)->snt_isn = isn; 1298 tcp_rsk(req)->snt_isn = isn;
828 1299
@@ -852,6 +1323,9 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
852 struct tcp_sock *newtp; 1323 struct tcp_sock *newtp;
853 struct sock *newsk; 1324 struct sock *newsk;
854 struct ipv6_txoptions *opt; 1325 struct ipv6_txoptions *opt;
1326#ifdef CONFIG_TCP_MD5SIG
1327 struct tcp_md5sig_key *key;
1328#endif
855 1329
856 if (skb->protocol == htons(ETH_P_IP)) { 1330 if (skb->protocol == htons(ETH_P_IP)) {
857 /* 1331 /*
@@ -882,6 +1356,10 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
882 1356
883 inet_csk(newsk)->icsk_af_ops = &ipv6_mapped; 1357 inet_csk(newsk)->icsk_af_ops = &ipv6_mapped;
884 newsk->sk_backlog_rcv = tcp_v4_do_rcv; 1358 newsk->sk_backlog_rcv = tcp_v4_do_rcv;
1359#ifdef CONFIG_TCP_MD5SIG
1360 newtp->af_specific = &tcp_sock_ipv6_mapped_specific;
1361#endif
1362
885 newnp->pktoptions = NULL; 1363 newnp->pktoptions = NULL;
886 newnp->opt = NULL; 1364 newnp->opt = NULL;
887 newnp->mcast_oif = inet6_iif(skb); 1365 newnp->mcast_oif = inet6_iif(skb);
@@ -1016,6 +1494,21 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1016 1494
1017 newinet->daddr = newinet->saddr = newinet->rcv_saddr = LOOPBACK4_IPV6; 1495 newinet->daddr = newinet->saddr = newinet->rcv_saddr = LOOPBACK4_IPV6;
1018 1496
1497#ifdef CONFIG_TCP_MD5SIG
1498 /* Copy over the MD5 key from the original socket */
1499 if ((key = tcp_v6_md5_do_lookup(sk, &newnp->daddr)) != NULL) {
1500 /* We're using one, so create a matching key
1501 * on the newsk structure. If we fail to get
1502 * memory, then we end up not copying the key
1503 * across. Shucks.
1504 */
1505 char *newkey = kmemdup(key->key, key->keylen, GFP_ATOMIC);
1506 if (newkey != NULL)
1507 tcp_v6_md5_do_add(newsk, &inet6_sk(sk)->daddr,
1508 newkey, key->keylen);
1509 }
1510#endif
1511
1019 __inet6_hash(&tcp_hashinfo, newsk); 1512 __inet6_hash(&tcp_hashinfo, newsk);
1020 inet_inherit_port(&tcp_hashinfo, sk, newsk); 1513 inet_inherit_port(&tcp_hashinfo, sk, newsk);
1021 1514
@@ -1031,7 +1524,7 @@ out:
1031 return NULL; 1524 return NULL;
1032} 1525}
1033 1526
1034static int tcp_v6_checksum_init(struct sk_buff *skb) 1527static __sum16 tcp_v6_checksum_init(struct sk_buff *skb)
1035{ 1528{
1036 if (skb->ip_summed == CHECKSUM_COMPLETE) { 1529 if (skb->ip_summed == CHECKSUM_COMPLETE) {
1037 if (!tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr, 1530 if (!tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr,
@@ -1041,8 +1534,8 @@ static int tcp_v6_checksum_init(struct sk_buff *skb)
1041 } 1534 }
1042 } 1535 }
1043 1536
1044 skb->csum = ~tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr, 1537 skb->csum = ~csum_unfold(tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr,
1045 &skb->nh.ipv6h->daddr, 0); 1538 &skb->nh.ipv6h->daddr, 0));
1046 1539
1047 if (skb->len <= 76) { 1540 if (skb->len <= 76) {
1048 return __skb_checksum_complete(skb); 1541 return __skb_checksum_complete(skb);
@@ -1075,6 +1568,11 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1075 if (skb->protocol == htons(ETH_P_IP)) 1568 if (skb->protocol == htons(ETH_P_IP))
1076 return tcp_v4_do_rcv(sk, skb); 1569 return tcp_v4_do_rcv(sk, skb);
1077 1570
1571#ifdef CONFIG_TCP_MD5SIG
1572 if (tcp_v6_inbound_md5_hash (sk, skb))
1573 goto discard;
1574#endif
1575
1078 if (sk_filter(sk, skb)) 1576 if (sk_filter(sk, skb))
1079 goto discard; 1577 goto discard;
1080 1578
@@ -1140,7 +1638,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
1140 return 0; 1638 return 0;
1141 1639
1142reset: 1640reset:
1143 tcp_v6_send_reset(skb); 1641 tcp_v6_send_reset(sk, skb);
1144discard: 1642discard:
1145 if (opt_skb) 1643 if (opt_skb)
1146 __kfree_skb(opt_skb); 1644 __kfree_skb(opt_skb);
@@ -1265,7 +1763,7 @@ no_tcp_socket:
1265bad_packet: 1763bad_packet:
1266 TCP_INC_STATS_BH(TCP_MIB_INERRS); 1764 TCP_INC_STATS_BH(TCP_MIB_INERRS);
1267 } else { 1765 } else {
1268 tcp_v6_send_reset(skb); 1766 tcp_v6_send_reset(NULL, skb);
1269 } 1767 }
1270 1768
1271discard_it: 1769discard_it:
@@ -1344,6 +1842,15 @@ static struct inet_connection_sock_af_ops ipv6_specific = {
1344#endif 1842#endif
1345}; 1843};
1346 1844
1845#ifdef CONFIG_TCP_MD5SIG
1846static struct tcp_sock_af_ops tcp_sock_ipv6_specific = {
1847 .md5_lookup = tcp_v6_md5_lookup,
1848 .calc_md5_hash = tcp_v6_calc_md5_hash,
1849 .md5_add = tcp_v6_md5_add_func,
1850 .md5_parse = tcp_v6_parse_md5_keys,
1851};
1852#endif
1853
1347/* 1854/*
1348 * TCP over IPv4 via INET6 API 1855 * TCP over IPv4 via INET6 API
1349 */ 1856 */
@@ -1366,6 +1873,15 @@ static struct inet_connection_sock_af_ops ipv6_mapped = {
1366#endif 1873#endif
1367}; 1874};
1368 1875
1876#ifdef CONFIG_TCP_MD5SIG
1877static struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific = {
1878 .md5_lookup = tcp_v4_md5_lookup,
1879 .calc_md5_hash = tcp_v4_calc_md5_hash,
1880 .md5_add = tcp_v6_md5_add_func,
1881 .md5_parse = tcp_v6_parse_md5_keys,
1882};
1883#endif
1884
1369/* NOTE: A lot of things set to zero explicitly by call to 1885/* NOTE: A lot of things set to zero explicitly by call to
1370 * sk_alloc() so need not be done here. 1886 * sk_alloc() so need not be done here.
1371 */ 1887 */
@@ -1405,6 +1921,10 @@ static int tcp_v6_init_sock(struct sock *sk)
1405 sk->sk_write_space = sk_stream_write_space; 1921 sk->sk_write_space = sk_stream_write_space;
1406 sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); 1922 sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
1407 1923
1924#ifdef CONFIG_TCP_MD5SIG
1925 tp->af_specific = &tcp_sock_ipv6_specific;
1926#endif
1927
1408 sk->sk_sndbuf = sysctl_tcp_wmem[1]; 1928 sk->sk_sndbuf = sysctl_tcp_wmem[1];
1409 sk->sk_rcvbuf = sysctl_tcp_rmem[1]; 1929 sk->sk_rcvbuf = sysctl_tcp_rmem[1];
1410 1930
@@ -1415,6 +1935,11 @@ static int tcp_v6_init_sock(struct sock *sk)
1415 1935
1416static int tcp_v6_destroy_sock(struct sock *sk) 1936static int tcp_v6_destroy_sock(struct sock *sk)
1417{ 1937{
1938#ifdef CONFIG_TCP_MD5SIG
1939 /* Clean up the MD5 key list */
1940 if (tcp_sk(sk)->md5sig_info)
1941 tcp_v6_clear_md5_list(sk);
1942#endif
1418 tcp_v4_destroy_sock(sk); 1943 tcp_v4_destroy_sock(sk);
1419 return inet6_destroy_sock(sk); 1944 return inet6_destroy_sock(sk);
1420} 1945}
diff --git a/net/ipv6/tunnel6.c b/net/ipv6/tunnel6.c
index 0ef9a35798d1..918d07dd1219 100644
--- a/net/ipv6/tunnel6.c
+++ b/net/ipv6/tunnel6.c
@@ -104,7 +104,7 @@ drop:
104} 104}
105 105
106static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 106static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
107 int type, int code, int offset, __u32 info) 107 int type, int code, int offset, __be32 info)
108{ 108{
109 struct xfrm6_tunnel *handler; 109 struct xfrm6_tunnel *handler;
110 110
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index c83f23e51c46..f52a5c3cc0a3 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -38,26 +38,18 @@
38#include <linux/skbuff.h> 38#include <linux/skbuff.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40 40
41#include <net/sock.h>
42#include <net/snmp.h>
43
44#include <net/ipv6.h>
45#include <net/ndisc.h> 41#include <net/ndisc.h>
46#include <net/protocol.h> 42#include <net/protocol.h>
47#include <net/transp_v6.h> 43#include <net/transp_v6.h>
48#include <net/ip6_route.h> 44#include <net/ip6_route.h>
49#include <net/addrconf.h>
50#include <net/ip.h>
51#include <net/udp.h>
52#include <net/raw.h> 45#include <net/raw.h>
53#include <net/inet_common.h>
54#include <net/tcp_states.h> 46#include <net/tcp_states.h>
55
56#include <net/ip6_checksum.h> 47#include <net/ip6_checksum.h>
57#include <net/xfrm.h> 48#include <net/xfrm.h>
58 49
59#include <linux/proc_fs.h> 50#include <linux/proc_fs.h>
60#include <linux/seq_file.h> 51#include <linux/seq_file.h>
52#include "udp_impl.h"
61 53
62DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly; 54DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;
63 55
@@ -66,23 +58,9 @@ static inline int udp_v6_get_port(struct sock *sk, unsigned short snum)
66 return udp_get_port(sk, snum, ipv6_rcv_saddr_equal); 58 return udp_get_port(sk, snum, ipv6_rcv_saddr_equal);
67} 59}
68 60
69static void udp_v6_hash(struct sock *sk) 61static struct sock *__udp6_lib_lookup(struct in6_addr *saddr, __be16 sport,
70{ 62 struct in6_addr *daddr, __be16 dport,
71 BUG(); 63 int dif, struct hlist_head udptable[])
72}
73
74static void udp_v6_unhash(struct sock *sk)
75{
76 write_lock_bh(&udp_hash_lock);
77 if (sk_del_node_init(sk)) {
78 inet_sk(sk)->num = 0;
79 sock_prot_dec_use(sk->sk_prot);
80 }
81 write_unlock_bh(&udp_hash_lock);
82}
83
84static struct sock *udp_v6_lookup(struct in6_addr *saddr, u16 sport,
85 struct in6_addr *daddr, u16 dport, int dif)
86{ 64{
87 struct sock *sk, *result = NULL; 65 struct sock *sk, *result = NULL;
88 struct hlist_node *node; 66 struct hlist_node *node;
@@ -90,7 +68,7 @@ static struct sock *udp_v6_lookup(struct in6_addr *saddr, u16 sport,
90 int badness = -1; 68 int badness = -1;
91 69
92 read_lock(&udp_hash_lock); 70 read_lock(&udp_hash_lock);
93 sk_for_each(sk, node, &udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]) { 71 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
94 struct inet_sock *inet = inet_sk(sk); 72 struct inet_sock *inet = inet_sk(sk);
95 73
96 if (inet->num == hnum && sk->sk_family == PF_INET6) { 74 if (inet->num == hnum && sk->sk_family == PF_INET6) {
@@ -132,20 +110,11 @@ static struct sock *udp_v6_lookup(struct in6_addr *saddr, u16 sport,
132} 110}
133 111
134/* 112/*
135 *
136 */
137
138static void udpv6_close(struct sock *sk, long timeout)
139{
140 sk_common_release(sk);
141}
142
143/*
144 * This should be easy, if there is something there we 113 * This should be easy, if there is something there we
145 * return it, otherwise we block. 114 * return it, otherwise we block.
146 */ 115 */
147 116
148static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, 117int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
149 struct msghdr *msg, size_t len, 118 struct msghdr *msg, size_t len,
150 int noblock, int flags, int *addr_len) 119 int noblock, int flags, int *addr_len)
151{ 120{
@@ -153,7 +122,7 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
153 struct inet_sock *inet = inet_sk(sk); 122 struct inet_sock *inet = inet_sk(sk);
154 struct sk_buff *skb; 123 struct sk_buff *skb;
155 size_t copied; 124 size_t copied;
156 int err; 125 int err, copy_only, is_udplite = IS_UDPLITE(sk);
157 126
158 if (addr_len) 127 if (addr_len)
159 *addr_len=sizeof(struct sockaddr_in6); 128 *addr_len=sizeof(struct sockaddr_in6);
@@ -172,15 +141,21 @@ try_again:
172 msg->msg_flags |= MSG_TRUNC; 141 msg->msg_flags |= MSG_TRUNC;
173 } 142 }
174 143
175 if (skb->ip_summed==CHECKSUM_UNNECESSARY) { 144 /*
176 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov, 145 * Decide whether to checksum and/or copy data.
177 copied); 146 */
178 } else if (msg->msg_flags&MSG_TRUNC) { 147 copy_only = (skb->ip_summed==CHECKSUM_UNNECESSARY);
179 if (__skb_checksum_complete(skb)) 148
149 if (is_udplite || (!copy_only && msg->msg_flags&MSG_TRUNC)) {
150 if (__udp_lib_checksum_complete(skb))
180 goto csum_copy_err; 151 goto csum_copy_err;
181 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov, 152 copy_only = 1;
182 copied); 153 }
183 } else { 154
155 if (copy_only)
156 err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
157 msg->msg_iov, copied );
158 else {
184 err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov); 159 err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);
185 if (err == -EINVAL) 160 if (err == -EINVAL)
186 goto csum_copy_err; 161 goto csum_copy_err;
@@ -231,14 +206,15 @@ csum_copy_err:
231 skb_kill_datagram(sk, skb, flags); 206 skb_kill_datagram(sk, skb, flags);
232 207
233 if (flags & MSG_DONTWAIT) { 208 if (flags & MSG_DONTWAIT) {
234 UDP6_INC_STATS_USER(UDP_MIB_INERRORS); 209 UDP6_INC_STATS_USER(UDP_MIB_INERRORS, is_udplite);
235 return -EAGAIN; 210 return -EAGAIN;
236 } 211 }
237 goto try_again; 212 goto try_again;
238} 213}
239 214
240static void udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 215void __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
241 int type, int code, int offset, __u32 info) 216 int type, int code, int offset, __be32 info,
217 struct hlist_head udptable[] )
242{ 218{
243 struct ipv6_pinfo *np; 219 struct ipv6_pinfo *np;
244 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data; 220 struct ipv6hdr *hdr = (struct ipv6hdr*)skb->data;
@@ -248,8 +224,8 @@ static void udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
248 struct sock *sk; 224 struct sock *sk;
249 int err; 225 int err;
250 226
251 sk = udp_v6_lookup(daddr, uh->dest, saddr, uh->source, inet6_iif(skb)); 227 sk = __udp6_lib_lookup(daddr, uh->dest,
252 228 saddr, uh->source, inet6_iif(skb), udptable);
253 if (sk == NULL) 229 if (sk == NULL)
254 return; 230 return;
255 231
@@ -270,36 +246,60 @@ out:
270 sock_put(sk); 246 sock_put(sk);
271} 247}
272 248
273static inline int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) 249static __inline__ void udpv6_err(struct sk_buff *skb,
250 struct inet6_skb_parm *opt, int type,
251 int code, int offset, __be32 info )
252{
253 return __udp6_lib_err(skb, opt, type, code, offset, info, udp_hash);
254}
255
256int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
274{ 257{
258 struct udp_sock *up = udp_sk(sk);
275 int rc; 259 int rc;
276 260
277 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { 261 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
278 kfree_skb(skb); 262 goto drop;
279 return -1;
280 }
281 263
282 if (skb_checksum_complete(skb)) { 264 /*
283 UDP6_INC_STATS_BH(UDP_MIB_INERRORS); 265 * UDP-Lite specific tests, ignored on UDP sockets (see net/ipv4/udp.c).
284 kfree_skb(skb); 266 */
285 return 0; 267 if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
268
269 if (up->pcrlen == 0) { /* full coverage was set */
270 LIMIT_NETDEBUG(KERN_WARNING "UDPLITE6: partial coverage"
271 " %d while full coverage %d requested\n",
272 UDP_SKB_CB(skb)->cscov, skb->len);
273 goto drop;
274 }
275 if (UDP_SKB_CB(skb)->cscov < up->pcrlen) {
276 LIMIT_NETDEBUG(KERN_WARNING "UDPLITE6: coverage %d "
277 "too small, need min %d\n",
278 UDP_SKB_CB(skb)->cscov, up->pcrlen);
279 goto drop;
280 }
286 } 281 }
287 282
283 if (udp_lib_checksum_complete(skb))
284 goto drop;
285
288 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) { 286 if ((rc = sock_queue_rcv_skb(sk,skb)) < 0) {
289 /* Note that an ENOMEM error is charged twice */ 287 /* Note that an ENOMEM error is charged twice */
290 if (rc == -ENOMEM) 288 if (rc == -ENOMEM)
291 UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS); 289 UDP6_INC_STATS_BH(UDP_MIB_RCVBUFERRORS, up->pcflag);
292 UDP6_INC_STATS_BH(UDP_MIB_INERRORS); 290 goto drop;
293 kfree_skb(skb);
294 return 0;
295 } 291 }
296 UDP6_INC_STATS_BH(UDP_MIB_INDATAGRAMS); 292 UDP6_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
297 return 0; 293 return 0;
294drop:
295 UDP6_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
296 kfree_skb(skb);
297 return -1;
298} 298}
299 299
300static struct sock *udp_v6_mcast_next(struct sock *sk, 300static struct sock *udp_v6_mcast_next(struct sock *sk,
301 u16 loc_port, struct in6_addr *loc_addr, 301 __be16 loc_port, struct in6_addr *loc_addr,
302 u16 rmt_port, struct in6_addr *rmt_addr, 302 __be16 rmt_port, struct in6_addr *rmt_addr,
303 int dif) 303 int dif)
304{ 304{
305 struct hlist_node *node; 305 struct hlist_node *node;
@@ -338,15 +338,15 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
338 * Note: called only from the BH handler context, 338 * Note: called only from the BH handler context,
339 * so we don't need to lock the hashes. 339 * so we don't need to lock the hashes.
340 */ 340 */
341static void udpv6_mcast_deliver(struct udphdr *uh, 341static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr,
342 struct in6_addr *saddr, struct in6_addr *daddr, 342 struct in6_addr *daddr, struct hlist_head udptable[])
343 struct sk_buff *skb)
344{ 343{
345 struct sock *sk, *sk2; 344 struct sock *sk, *sk2;
345 const struct udphdr *uh = skb->h.uh;
346 int dif; 346 int dif;
347 347
348 read_lock(&udp_hash_lock); 348 read_lock(&udp_hash_lock);
349 sk = sk_head(&udp_hash[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]); 349 sk = sk_head(&udptable[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]);
350 dif = inet6_iif(skb); 350 dif = inet6_iif(skb);
351 sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif); 351 sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif);
352 if (!sk) { 352 if (!sk) {
@@ -364,9 +364,35 @@ static void udpv6_mcast_deliver(struct udphdr *uh,
364 udpv6_queue_rcv_skb(sk, skb); 364 udpv6_queue_rcv_skb(sk, skb);
365out: 365out:
366 read_unlock(&udp_hash_lock); 366 read_unlock(&udp_hash_lock);
367 return 0;
368}
369
370static inline int udp6_csum_init(struct sk_buff *skb, struct udphdr *uh)
371
372{
373 if (uh->check == 0) {
374 /* RFC 2460 section 8.1 says that we SHOULD log
375 this error. Well, it is reasonable.
376 */
377 LIMIT_NETDEBUG(KERN_INFO "IPv6: udp checksum is 0\n");
378 return 1;
379 }
380 if (skb->ip_summed == CHECKSUM_COMPLETE &&
381 !csum_ipv6_magic(&skb->nh.ipv6h->saddr, &skb->nh.ipv6h->daddr,
382 skb->len, IPPROTO_UDP, skb->csum ))
383 skb->ip_summed = CHECKSUM_UNNECESSARY;
384
385 if (skb->ip_summed != CHECKSUM_UNNECESSARY)
386 skb->csum = ~csum_unfold(csum_ipv6_magic(&skb->nh.ipv6h->saddr,
387 &skb->nh.ipv6h->daddr,
388 skb->len, IPPROTO_UDP,
389 0));
390
391 return (UDP_SKB_CB(skb)->partial_cov = 0);
367} 392}
368 393
369static int udpv6_rcv(struct sk_buff **pskb) 394int __udp6_lib_rcv(struct sk_buff **pskb, struct hlist_head udptable[],
395 int is_udplite)
370{ 396{
371 struct sk_buff *skb = *pskb; 397 struct sk_buff *skb = *pskb;
372 struct sock *sk; 398 struct sock *sk;
@@ -383,44 +409,39 @@ static int udpv6_rcv(struct sk_buff **pskb)
383 uh = skb->h.uh; 409 uh = skb->h.uh;
384 410
385 ulen = ntohs(uh->len); 411 ulen = ntohs(uh->len);
412 if (ulen > skb->len)
413 goto short_packet;
386 414
387 /* Check for jumbo payload */ 415 if(! is_udplite ) { /* UDP validates ulen. */
388 if (ulen == 0)
389 ulen = skb->len;
390 416
391 if (ulen > skb->len || ulen < sizeof(*uh)) 417 /* Check for jumbo payload */
392 goto short_packet; 418 if (ulen == 0)
419 ulen = skb->len;
393 420
394 if (uh->check == 0) { 421 if (ulen < sizeof(*uh))
395 /* RFC 2460 section 8.1 says that we SHOULD log 422 goto short_packet;
396 this error. Well, it is reasonable.
397 */
398 LIMIT_NETDEBUG(KERN_INFO "IPv6: udp checksum is 0\n");
399 goto discard;
400 }
401 423
402 if (ulen < skb->len) { 424 if (ulen < skb->len) {
403 if (pskb_trim_rcsum(skb, ulen)) 425 if (pskb_trim_rcsum(skb, ulen))
404 goto discard; 426 goto short_packet;
405 saddr = &skb->nh.ipv6h->saddr; 427 saddr = &skb->nh.ipv6h->saddr;
406 daddr = &skb->nh.ipv6h->daddr; 428 daddr = &skb->nh.ipv6h->daddr;
407 uh = skb->h.uh; 429 uh = skb->h.uh;
408 } 430 }
409 431
410 if (skb->ip_summed == CHECKSUM_COMPLETE && 432 if (udp6_csum_init(skb, uh))
411 !csum_ipv6_magic(saddr, daddr, ulen, IPPROTO_UDP, skb->csum)) 433 goto discard;
412 skb->ip_summed = CHECKSUM_UNNECESSARY;
413 434
414 if (skb->ip_summed != CHECKSUM_UNNECESSARY) 435 } else { /* UDP-Lite validates cscov. */
415 skb->csum = ~csum_ipv6_magic(saddr, daddr, ulen, IPPROTO_UDP, 0); 436 if (udplite6_csum_init(skb, uh))
437 goto discard;
438 }
416 439
417 /* 440 /*
418 * Multicast receive code 441 * Multicast receive code
419 */ 442 */
420 if (ipv6_addr_is_multicast(daddr)) { 443 if (ipv6_addr_is_multicast(daddr))
421 udpv6_mcast_deliver(uh, saddr, daddr, skb); 444 return __udp6_lib_mcast_deliver(skb, saddr, daddr, udptable);
422 return 0;
423 }
424 445
425 /* Unicast */ 446 /* Unicast */
426 447
@@ -428,15 +449,16 @@ static int udpv6_rcv(struct sk_buff **pskb)
428 * check socket cache ... must talk to Alan about his plans 449 * check socket cache ... must talk to Alan about his plans
429 * for sock caches... i'll skip this for now. 450 * for sock caches... i'll skip this for now.
430 */ 451 */
431 sk = udp_v6_lookup(saddr, uh->source, daddr, uh->dest, inet6_iif(skb)); 452 sk = __udp6_lib_lookup(saddr, uh->source,
453 daddr, uh->dest, inet6_iif(skb), udptable);
432 454
433 if (sk == NULL) { 455 if (sk == NULL) {
434 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) 456 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
435 goto discard; 457 goto discard;
436 458
437 if (skb_checksum_complete(skb)) 459 if (udp_lib_checksum_complete(skb))
438 goto discard; 460 goto discard;
439 UDP6_INC_STATS_BH(UDP_MIB_NOPORTS); 461 UDP6_INC_STATS_BH(UDP_MIB_NOPORTS, is_udplite);
440 462
441 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, dev); 463 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0, dev);
442 464
@@ -451,14 +473,20 @@ static int udpv6_rcv(struct sk_buff **pskb)
451 return(0); 473 return(0);
452 474
453short_packet: 475short_packet:
454 if (net_ratelimit()) 476 LIMIT_NETDEBUG(KERN_DEBUG "UDP%sv6: short packet: %d/%u\n",
455 printk(KERN_DEBUG "UDP: short packet: %d/%u\n", ulen, skb->len); 477 is_udplite? "-Lite" : "", ulen, skb->len);
456 478
457discard: 479discard:
458 UDP6_INC_STATS_BH(UDP_MIB_INERRORS); 480 UDP6_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
459 kfree_skb(skb); 481 kfree_skb(skb);
460 return(0); 482 return(0);
461} 483}
484
485static __inline__ int udpv6_rcv(struct sk_buff **pskb)
486{
487 return __udp6_lib_rcv(pskb, udp_hash, 0);
488}
489
462/* 490/*
463 * Throw away all pending data and cancel the corking. Socket is locked. 491 * Throw away all pending data and cancel the corking. Socket is locked.
464 */ 492 */
@@ -477,13 +505,15 @@ static void udp_v6_flush_pending_frames(struct sock *sk)
477 * Sending 505 * Sending
478 */ 506 */
479 507
480static int udp_v6_push_pending_frames(struct sock *sk, struct udp_sock *up) 508static int udp_v6_push_pending_frames(struct sock *sk)
481{ 509{
482 struct sk_buff *skb; 510 struct sk_buff *skb;
483 struct udphdr *uh; 511 struct udphdr *uh;
512 struct udp_sock *up = udp_sk(sk);
484 struct inet_sock *inet = inet_sk(sk); 513 struct inet_sock *inet = inet_sk(sk);
485 struct flowi *fl = &inet->cork.fl; 514 struct flowi *fl = &inet->cork.fl;
486 int err = 0; 515 int err = 0;
516 __wsum csum = 0;
487 517
488 /* Grab the skbuff where UDP header space exists. */ 518 /* Grab the skbuff where UDP header space exists. */
489 if ((skb = skb_peek(&sk->sk_write_queue)) == NULL) 519 if ((skb = skb_peek(&sk->sk_write_queue)) == NULL)
@@ -498,35 +528,17 @@ static int udp_v6_push_pending_frames(struct sock *sk, struct udp_sock *up)
498 uh->len = htons(up->len); 528 uh->len = htons(up->len);
499 uh->check = 0; 529 uh->check = 0;
500 530
501 if (sk->sk_no_check == UDP_CSUM_NOXMIT) { 531 if (up->pcflag)
502 skb->ip_summed = CHECKSUM_NONE; 532 csum = udplite_csum_outgoing(sk, skb);
503 goto send; 533 else
504 } 534 csum = udp_csum_outgoing(sk, skb);
505
506 if (skb_queue_len(&sk->sk_write_queue) == 1) {
507 skb->csum = csum_partial((char *)uh,
508 sizeof(struct udphdr), skb->csum);
509 uh->check = csum_ipv6_magic(&fl->fl6_src,
510 &fl->fl6_dst,
511 up->len, fl->proto, skb->csum);
512 } else {
513 u32 tmp_csum = 0;
514
515 skb_queue_walk(&sk->sk_write_queue, skb) {
516 tmp_csum = csum_add(tmp_csum, skb->csum);
517 }
518 tmp_csum = csum_partial((char *)uh,
519 sizeof(struct udphdr), tmp_csum);
520 tmp_csum = csum_ipv6_magic(&fl->fl6_src,
521 &fl->fl6_dst,
522 up->len, fl->proto, tmp_csum);
523 uh->check = tmp_csum;
524 535
525 } 536 /* add protocol-dependent pseudo-header */
537 uh->check = csum_ipv6_magic(&fl->fl6_src, &fl->fl6_dst,
538 up->len, fl->proto, csum );
526 if (uh->check == 0) 539 if (uh->check == 0)
527 uh->check = -1; 540 uh->check = CSUM_MANGLED_0;
528 541
529send:
530 err = ip6_push_pending_frames(sk); 542 err = ip6_push_pending_frames(sk);
531out: 543out:
532 up->len = 0; 544 up->len = 0;
@@ -534,7 +546,7 @@ out:
534 return err; 546 return err;
535} 547}
536 548
537static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, 549int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
538 struct msghdr *msg, size_t len) 550 struct msghdr *msg, size_t len)
539{ 551{
540 struct ipv6_txoptions opt_space; 552 struct ipv6_txoptions opt_space;
@@ -554,6 +566,8 @@ static int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
554 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE; 566 int corkreq = up->corkflag || msg->msg_flags&MSG_MORE;
555 int err; 567 int err;
556 int connected = 0; 568 int connected = 0;
569 int is_udplite = up->pcflag;
570 int (*getfrag)(void *, char *, int, int, int, struct sk_buff *);
557 571
558 /* destination address check */ 572 /* destination address check */
559 if (sin6) { 573 if (sin6) {
@@ -694,7 +708,7 @@ do_udp_sendmsg:
694 opt = fl6_merge_options(&opt_space, flowlabel, opt); 708 opt = fl6_merge_options(&opt_space, flowlabel, opt);
695 opt = ipv6_fixup_options(&opt_space, opt); 709 opt = ipv6_fixup_options(&opt_space, opt);
696 710
697 fl.proto = IPPROTO_UDP; 711 fl.proto = sk->sk_protocol;
698 ipv6_addr_copy(&fl.fl6_dst, daddr); 712 ipv6_addr_copy(&fl.fl6_dst, daddr);
699 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 713 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
700 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 714 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
@@ -761,14 +775,15 @@ back_from_confirm:
761 775
762do_append_data: 776do_append_data:
763 up->len += ulen; 777 up->len += ulen;
764 err = ip6_append_data(sk, ip_generic_getfrag, msg->msg_iov, ulen, 778 getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
779 err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,
765 sizeof(struct udphdr), hlimit, tclass, opt, &fl, 780 sizeof(struct udphdr), hlimit, tclass, opt, &fl,
766 (struct rt6_info*)dst, 781 (struct rt6_info*)dst,
767 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags); 782 corkreq ? msg->msg_flags|MSG_MORE : msg->msg_flags);
768 if (err) 783 if (err)
769 udp_v6_flush_pending_frames(sk); 784 udp_v6_flush_pending_frames(sk);
770 else if (!corkreq) 785 else if (!corkreq)
771 err = udp_v6_push_pending_frames(sk, up); 786 err = udp_v6_push_pending_frames(sk);
772 else if (unlikely(skb_queue_empty(&sk->sk_write_queue))) 787 else if (unlikely(skb_queue_empty(&sk->sk_write_queue)))
773 up->pending = 0; 788 up->pending = 0;
774 789
@@ -793,7 +808,7 @@ do_append_data:
793out: 808out:
794 fl6_sock_release(flowlabel); 809 fl6_sock_release(flowlabel);
795 if (!err) { 810 if (!err) {
796 UDP6_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS); 811 UDP6_INC_STATS_USER(UDP_MIB_OUTDATAGRAMS, is_udplite);
797 return len; 812 return len;
798 } 813 }
799 /* 814 /*
@@ -804,7 +819,7 @@ out:
804 * seems like overkill. 819 * seems like overkill.
805 */ 820 */
806 if (err == -ENOBUFS || test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) { 821 if (err == -ENOBUFS || test_bit(SOCK_NOSPACE, &sk->sk_socket->flags)) {
807 UDP6_INC_STATS_USER(UDP_MIB_SNDBUFERRORS); 822 UDP6_INC_STATS_USER(UDP_MIB_SNDBUFERRORS, is_udplite);
808 } 823 }
809 return err; 824 return err;
810 825
@@ -816,7 +831,7 @@ do_confirm:
816 goto out; 831 goto out;
817} 832}
818 833
819static int udpv6_destroy_sock(struct sock *sk) 834int udpv6_destroy_sock(struct sock *sk)
820{ 835{
821 lock_sock(sk); 836 lock_sock(sk);
822 udp_v6_flush_pending_frames(sk); 837 udp_v6_flush_pending_frames(sk);
@@ -830,119 +845,41 @@ static int udpv6_destroy_sock(struct sock *sk)
830/* 845/*
831 * Socket option code for UDP 846 * Socket option code for UDP
832 */ 847 */
833static int do_udpv6_setsockopt(struct sock *sk, int level, int optname, 848int udpv6_setsockopt(struct sock *sk, int level, int optname,
834 char __user *optval, int optlen) 849 char __user *optval, int optlen)
835{
836 struct udp_sock *up = udp_sk(sk);
837 int val;
838 int err = 0;
839
840 if(optlen<sizeof(int))
841 return -EINVAL;
842
843 if (get_user(val, (int __user *)optval))
844 return -EFAULT;
845
846 switch(optname) {
847 case UDP_CORK:
848 if (val != 0) {
849 up->corkflag = 1;
850 } else {
851 up->corkflag = 0;
852 lock_sock(sk);
853 udp_v6_push_pending_frames(sk, up);
854 release_sock(sk);
855 }
856 break;
857
858 case UDP_ENCAP:
859 switch (val) {
860 case 0:
861 up->encap_type = val;
862 break;
863 default:
864 err = -ENOPROTOOPT;
865 break;
866 }
867 break;
868
869 default:
870 err = -ENOPROTOOPT;
871 break;
872 };
873
874 return err;
875}
876
877static int udpv6_setsockopt(struct sock *sk, int level, int optname,
878 char __user *optval, int optlen)
879{ 850{
880 if (level != SOL_UDP) 851 if (level == SOL_UDP || level == SOL_UDPLITE)
881 return ipv6_setsockopt(sk, level, optname, optval, optlen); 852 return udp_lib_setsockopt(sk, level, optname, optval, optlen,
882 return do_udpv6_setsockopt(sk, level, optname, optval, optlen); 853 udp_v6_push_pending_frames);
854 return ipv6_setsockopt(sk, level, optname, optval, optlen);
883} 855}
884 856
885#ifdef CONFIG_COMPAT 857#ifdef CONFIG_COMPAT
886static int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, 858int compat_udpv6_setsockopt(struct sock *sk, int level, int optname,
887 char __user *optval, int optlen) 859 char __user *optval, int optlen)
888{ 860{
889 if (level != SOL_UDP) 861 if (level == SOL_UDP || level == SOL_UDPLITE)
890 return compat_ipv6_setsockopt(sk, level, optname, 862 return udp_lib_setsockopt(sk, level, optname, optval, optlen,
891 optval, optlen); 863 udp_v6_push_pending_frames);
892 return do_udpv6_setsockopt(sk, level, optname, optval, optlen); 864 return compat_ipv6_setsockopt(sk, level, optname, optval, optlen);
893} 865}
894#endif 866#endif
895 867
896static int do_udpv6_getsockopt(struct sock *sk, int level, int optname, 868int udpv6_getsockopt(struct sock *sk, int level, int optname,
897 char __user *optval, int __user *optlen) 869 char __user *optval, int __user *optlen)
898{
899 struct udp_sock *up = udp_sk(sk);
900 int val, len;
901
902 if(get_user(len,optlen))
903 return -EFAULT;
904
905 len = min_t(unsigned int, len, sizeof(int));
906
907 if(len < 0)
908 return -EINVAL;
909
910 switch(optname) {
911 case UDP_CORK:
912 val = up->corkflag;
913 break;
914
915 case UDP_ENCAP:
916 val = up->encap_type;
917 break;
918
919 default:
920 return -ENOPROTOOPT;
921 };
922
923 if(put_user(len, optlen))
924 return -EFAULT;
925 if(copy_to_user(optval, &val,len))
926 return -EFAULT;
927 return 0;
928}
929
930static int udpv6_getsockopt(struct sock *sk, int level, int optname,
931 char __user *optval, int __user *optlen)
932{ 870{
933 if (level != SOL_UDP) 871 if (level == SOL_UDP || level == SOL_UDPLITE)
934 return ipv6_getsockopt(sk, level, optname, optval, optlen); 872 return udp_lib_getsockopt(sk, level, optname, optval, optlen);
935 return do_udpv6_getsockopt(sk, level, optname, optval, optlen); 873 return ipv6_getsockopt(sk, level, optname, optval, optlen);
936} 874}
937 875
938#ifdef CONFIG_COMPAT 876#ifdef CONFIG_COMPAT
939static int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, 877int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
940 char __user *optval, int __user *optlen) 878 char __user *optval, int __user *optlen)
941{ 879{
942 if (level != SOL_UDP) 880 if (level == SOL_UDP || level == SOL_UDPLITE)
943 return compat_ipv6_getsockopt(sk, level, optname, 881 return udp_lib_getsockopt(sk, level, optname, optval, optlen);
944 optval, optlen); 882 return compat_ipv6_getsockopt(sk, level, optname, optval, optlen);
945 return do_udpv6_getsockopt(sk, level, optname, optval, optlen);
946} 883}
947#endif 884#endif
948 885
@@ -983,7 +920,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
983 atomic_read(&sp->sk_refcnt), sp); 920 atomic_read(&sp->sk_refcnt), sp);
984} 921}
985 922
986static int udp6_seq_show(struct seq_file *seq, void *v) 923int udp6_seq_show(struct seq_file *seq, void *v)
987{ 924{
988 if (v == SEQ_START_TOKEN) 925 if (v == SEQ_START_TOKEN)
989 seq_printf(seq, 926 seq_printf(seq,
@@ -1002,6 +939,7 @@ static struct udp_seq_afinfo udp6_seq_afinfo = {
1002 .owner = THIS_MODULE, 939 .owner = THIS_MODULE,
1003 .name = "udp6", 940 .name = "udp6",
1004 .family = AF_INET6, 941 .family = AF_INET6,
942 .hashtable = udp_hash,
1005 .seq_show = udp6_seq_show, 943 .seq_show = udp6_seq_show,
1006 .seq_fops = &udp6_seq_fops, 944 .seq_fops = &udp6_seq_fops,
1007}; 945};
@@ -1021,7 +959,7 @@ void udp6_proc_exit(void) {
1021struct proto udpv6_prot = { 959struct proto udpv6_prot = {
1022 .name = "UDPv6", 960 .name = "UDPv6",
1023 .owner = THIS_MODULE, 961 .owner = THIS_MODULE,
1024 .close = udpv6_close, 962 .close = udp_lib_close,
1025 .connect = ip6_datagram_connect, 963 .connect = ip6_datagram_connect,
1026 .disconnect = udp_disconnect, 964 .disconnect = udp_disconnect,
1027 .ioctl = udp_ioctl, 965 .ioctl = udp_ioctl,
@@ -1031,8 +969,8 @@ struct proto udpv6_prot = {
1031 .sendmsg = udpv6_sendmsg, 969 .sendmsg = udpv6_sendmsg,
1032 .recvmsg = udpv6_recvmsg, 970 .recvmsg = udpv6_recvmsg,
1033 .backlog_rcv = udpv6_queue_rcv_skb, 971 .backlog_rcv = udpv6_queue_rcv_skb,
1034 .hash = udp_v6_hash, 972 .hash = udp_lib_hash,
1035 .unhash = udp_v6_unhash, 973 .unhash = udp_lib_unhash,
1036 .get_port = udp_v6_get_port, 974 .get_port = udp_v6_get_port,
1037 .obj_size = sizeof(struct udp6_sock), 975 .obj_size = sizeof(struct udp6_sock),
1038#ifdef CONFIG_COMPAT 976#ifdef CONFIG_COMPAT
diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
new file mode 100644
index 000000000000..ec9878899128
--- /dev/null
+++ b/net/ipv6/udp_impl.h
@@ -0,0 +1,34 @@
1#ifndef _UDP6_IMPL_H
2#define _UDP6_IMPL_H
3#include <net/udp.h>
4#include <net/udplite.h>
5#include <net/protocol.h>
6#include <net/addrconf.h>
7#include <net/inet_common.h>
8
9extern int __udp6_lib_rcv(struct sk_buff **, struct hlist_head [], int );
10extern void __udp6_lib_err(struct sk_buff *, struct inet6_skb_parm *,
11 int , int , int , __be32 , struct hlist_head []);
12
13extern int udpv6_getsockopt(struct sock *sk, int level, int optname,
14 char __user *optval, int __user *optlen);
15extern int udpv6_setsockopt(struct sock *sk, int level, int optname,
16 char __user *optval, int optlen);
17#ifdef CONFIG_COMPAT
18extern int compat_udpv6_setsockopt(struct sock *sk, int level, int optname,
19 char __user *optval, int optlen);
20extern int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
21 char __user *optval, int __user *optlen);
22#endif
23extern int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
24 struct msghdr *msg, size_t len);
25extern int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
26 struct msghdr *msg, size_t len,
27 int noblock, int flags, int *addr_len);
28extern int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb);
29extern int udpv6_destroy_sock(struct sock *sk);
30
31#ifdef CONFIG_PROC_FS
32extern int udp6_seq_show(struct seq_file *seq, void *v);
33#endif
34#endif /* _UDP6_IMPL_H */
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
new file mode 100644
index 000000000000..629f97162fbc
--- /dev/null
+++ b/net/ipv6/udplite.c
@@ -0,0 +1,105 @@
1/*
2 * UDPLITEv6 An implementation of the UDP-Lite protocol over IPv6.
3 * See also net/ipv4/udplite.c
4 *
5 * Version: $Id: udplite.c,v 1.9 2006/10/19 08:28:10 gerrit Exp $
6 *
7 * Authors: Gerrit Renker <gerrit@erg.abdn.ac.uk>
8 *
9 * Changes:
10 * Fixes:
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16#include "udp_impl.h"
17
18DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6) __read_mostly;
19
20static int udplitev6_rcv(struct sk_buff **pskb)
21{
22 return __udp6_lib_rcv(pskb, udplite_hash, 1);
23}
24
25static void udplitev6_err(struct sk_buff *skb,
26 struct inet6_skb_parm *opt,
27 int type, int code, int offset, __be32 info)
28{
29 return __udp6_lib_err(skb, opt, type, code, offset, info, udplite_hash);
30}
31
32static struct inet6_protocol udplitev6_protocol = {
33 .handler = udplitev6_rcv,
34 .err_handler = udplitev6_err,
35 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
36};
37
38static int udplite_v6_get_port(struct sock *sk, unsigned short snum)
39{
40 return udplite_get_port(sk, snum, ipv6_rcv_saddr_equal);
41}
42
43struct proto udplitev6_prot = {
44 .name = "UDPLITEv6",
45 .owner = THIS_MODULE,
46 .close = udp_lib_close,
47 .connect = ip6_datagram_connect,
48 .disconnect = udp_disconnect,
49 .ioctl = udp_ioctl,
50 .init = udplite_sk_init,
51 .destroy = udpv6_destroy_sock,
52 .setsockopt = udpv6_setsockopt,
53 .getsockopt = udpv6_getsockopt,
54 .sendmsg = udpv6_sendmsg,
55 .recvmsg = udpv6_recvmsg,
56 .backlog_rcv = udpv6_queue_rcv_skb,
57 .hash = udp_lib_hash,
58 .unhash = udp_lib_unhash,
59 .get_port = udplite_v6_get_port,
60 .obj_size = sizeof(struct udp6_sock),
61#ifdef CONFIG_COMPAT
62 .compat_setsockopt = compat_udpv6_setsockopt,
63 .compat_getsockopt = compat_udpv6_getsockopt,
64#endif
65};
66
67static struct inet_protosw udplite6_protosw = {
68 .type = SOCK_DGRAM,
69 .protocol = IPPROTO_UDPLITE,
70 .prot = &udplitev6_prot,
71 .ops = &inet6_dgram_ops,
72 .capability = -1,
73 .no_check = 0,
74 .flags = INET_PROTOSW_PERMANENT,
75};
76
77void __init udplitev6_init(void)
78{
79 if (inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE) < 0)
80 printk(KERN_ERR "%s: Could not register.\n", __FUNCTION__);
81
82 inet6_register_protosw(&udplite6_protosw);
83}
84
85#ifdef CONFIG_PROC_FS
86static struct file_operations udplite6_seq_fops;
87static struct udp_seq_afinfo udplite6_seq_afinfo = {
88 .owner = THIS_MODULE,
89 .name = "udplite6",
90 .family = AF_INET6,
91 .hashtable = udplite_hash,
92 .seq_show = udp6_seq_show,
93 .seq_fops = &udplite6_seq_fops,
94};
95
96int __init udplite6_proc_init(void)
97{
98 return udp_proc_register(&udplite6_seq_afinfo);
99}
100
101void udplite6_proc_exit(void)
102{
103 udp_proc_unregister(&udplite6_seq_afinfo);
104}
105#endif
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index d400f8fae129..8dffd4daae9c 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -274,11 +274,12 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
274 break; 274 break;
275 275
276 case IPPROTO_UDP: 276 case IPPROTO_UDP:
277 case IPPROTO_UDPLITE:
277 case IPPROTO_TCP: 278 case IPPROTO_TCP:
278 case IPPROTO_SCTP: 279 case IPPROTO_SCTP:
279 case IPPROTO_DCCP: 280 case IPPROTO_DCCP:
280 if (pskb_may_pull(skb, skb->nh.raw + offset + 4 - skb->data)) { 281 if (pskb_may_pull(skb, skb->nh.raw + offset + 4 - skb->data)) {
281 u16 *ports = (u16 *)exthdr; 282 __be16 *ports = (__be16 *)exthdr;
282 283
283 fl->fl_ip_sport = ports[0]; 284 fl->fl_ip_sport = ports[0];
284 fl->fl_ip_dport = ports[1]; 285 fl->fl_ip_dport = ports[1];
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 7931e4f898d4..01a5c52a2be3 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -62,7 +62,7 @@ static unsigned inline xfrm6_tunnel_spi_hash_byaddr(xfrm_address_t *addr)
62{ 62{
63 unsigned h; 63 unsigned h;
64 64
65 h = addr->a6[0] ^ addr->a6[1] ^ addr->a6[2] ^ addr->a6[3]; 65 h = (__force u32)(addr->a6[0] ^ addr->a6[1] ^ addr->a6[2] ^ addr->a6[3]);
66 h ^= h >> 16; 66 h ^= h >> 16;
67 h ^= h >> 8; 67 h ^= h >> 8;
68 h &= XFRM6_TUNNEL_SPI_BYADDR_HSIZE - 1; 68 h &= XFRM6_TUNNEL_SPI_BYADDR_HSIZE - 1;
@@ -126,7 +126,7 @@ static struct xfrm6_tunnel_spi *__xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr)
126 return NULL; 126 return NULL;
127} 127}
128 128
129u32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr) 129__be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr)
130{ 130{
131 struct xfrm6_tunnel_spi *x6spi; 131 struct xfrm6_tunnel_spi *x6spi;
132 u32 spi; 132 u32 spi;
@@ -196,7 +196,7 @@ out:
196 return spi; 196 return spi;
197} 197}
198 198
199u32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr) 199__be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr)
200{ 200{
201 struct xfrm6_tunnel_spi *x6spi; 201 struct xfrm6_tunnel_spi *x6spi;
202 u32 spi; 202 u32 spi;
@@ -265,7 +265,7 @@ static int xfrm6_tunnel_rcv(struct sk_buff *skb)
265} 265}
266 266
267static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 267static int xfrm6_tunnel_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
268 int type, int code, int offset, __u32 info) 268 int type, int code, int offset, __be32 info)
269{ 269{
270 /* xfrm6_tunnel native err handling */ 270 /* xfrm6_tunnel native err handling */
271 switch (type) { 271 switch (type) {
diff --git a/net/irda/iriap.c b/net/irda/iriap.c
index 415cf4eec23b..8cfd076c4c12 100644
--- a/net/irda/iriap.c
+++ b/net/irda/iriap.c
@@ -172,7 +172,7 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv,
172 172
173 IRDA_DEBUG(2, "%s()\n", __FUNCTION__); 173 IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
174 174
175 self = kmalloc(sizeof(struct iriap_cb), GFP_ATOMIC); 175 self = kzalloc(sizeof(*self), GFP_ATOMIC);
176 if (!self) { 176 if (!self) {
177 IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); 177 IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
178 return NULL; 178 return NULL;
@@ -181,7 +181,6 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv,
181 /* 181 /*
182 * Initialize instance 182 * Initialize instance
183 */ 183 */
184 memset(self, 0, sizeof(struct iriap_cb));
185 184
186 self->magic = IAS_MAGIC; 185 self->magic = IAS_MAGIC;
187 self->mode = mode; 186 self->mode = mode;
@@ -451,12 +450,12 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
451 n = 2; 450 n = 2;
452 451
453 /* Get length, MSB first */ 452 /* Get length, MSB first */
454 len = be16_to_cpu(get_unaligned((__u16 *)(fp+n))); n += 2; 453 len = be16_to_cpu(get_unaligned((__be16 *)(fp+n))); n += 2;
455 454
456 IRDA_DEBUG(4, "%s(), len=%d\n", __FUNCTION__, len); 455 IRDA_DEBUG(4, "%s(), len=%d\n", __FUNCTION__, len);
457 456
458 /* Get object ID, MSB first */ 457 /* Get object ID, MSB first */
459 obj_id = be16_to_cpu(get_unaligned((__u16 *)(fp+n))); n += 2; 458 obj_id = be16_to_cpu(get_unaligned((__be16 *)(fp+n))); n += 2;
460 459
461 type = fp[n++]; 460 type = fp[n++];
462 IRDA_DEBUG(4, "%s(), Value type = %d\n", __FUNCTION__, type); 461 IRDA_DEBUG(4, "%s(), Value type = %d\n", __FUNCTION__, type);
@@ -506,7 +505,7 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
506 value = irias_new_string_value(fp+n); 505 value = irias_new_string_value(fp+n);
507 break; 506 break;
508 case IAS_OCT_SEQ: 507 case IAS_OCT_SEQ:
509 value_len = be16_to_cpu(get_unaligned((__u16 *)(fp+n))); 508 value_len = be16_to_cpu(get_unaligned((__be16 *)(fp+n)));
510 n += 2; 509 n += 2;
511 510
512 /* Will truncate to IAS_MAX_OCTET_STRING bytes */ 511 /* Will truncate to IAS_MAX_OCTET_STRING bytes */
@@ -544,7 +543,7 @@ static void iriap_getvaluebyclass_response(struct iriap_cb *self,
544{ 543{
545 struct sk_buff *tx_skb; 544 struct sk_buff *tx_skb;
546 int n; 545 int n;
547 __u32 tmp_be32; 546 __be32 tmp_be32;
548 __be16 tmp_be16; 547 __be16 tmp_be16;
549 __u8 *fp; 548 __u8 *fp;
550 549
diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c
index 56292ab7d652..b1ee99a59c0c 100644
--- a/net/irda/irias_object.c
+++ b/net/irda/irias_object.c
@@ -501,13 +501,12 @@ struct ias_value *irias_new_octseq_value(__u8 *octseq , int len)
501 len = IAS_MAX_OCTET_STRING; 501 len = IAS_MAX_OCTET_STRING;
502 value->len = len; 502 value->len = len;
503 503
504 value->t.oct_seq = kmalloc(len, GFP_ATOMIC); 504 value->t.oct_seq = kmemdup(octseq, len, GFP_ATOMIC);
505 if (value->t.oct_seq == NULL){ 505 if (value->t.oct_seq == NULL){
506 IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); 506 IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
507 kfree(value); 507 kfree(value);
508 return NULL; 508 return NULL;
509 } 509 }
510 memcpy(value->t.oct_seq, octseq , len);
511 return value; 510 return value;
512} 511}
513 512
@@ -522,7 +521,6 @@ struct ias_value *irias_new_missing_value(void)
522 } 521 }
523 522
524 value->type = IAS_MISSING; 523 value->type = IAS_MISSING;
525 value->len = 0;
526 524
527 return value; 525 return value;
528} 526}
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
index 9b962f247714..2bb04ac09329 100644
--- a/net/irda/irlan/irlan_common.c
+++ b/net/irda/irlan/irlan_common.c
@@ -995,7 +995,7 @@ static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
995{ 995{
996 __u8 *frame; 996 __u8 *frame;
997 __u8 param_len; 997 __u8 param_len;
998 __u16 tmp_le; /* Temporary value in little endian format */ 998 __le16 tmp_le; /* Temporary value in little endian format */
999 int n=0; 999 int n=0;
1000 1000
1001 if (skb == NULL) { 1001 if (skb == NULL) {
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index fede83763095..7e5d12ab3b90 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -641,15 +641,13 @@ struct lsap_cb *irlmp_dup(struct lsap_cb *orig, void *instance)
641 } 641 }
642 642
643 /* Allocate a new instance */ 643 /* Allocate a new instance */
644 new = kmalloc(sizeof(struct lsap_cb), GFP_ATOMIC); 644 new = kmemdup(orig, sizeof(*new), GFP_ATOMIC);
645 if (!new) { 645 if (!new) {
646 IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __FUNCTION__); 646 IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __FUNCTION__);
647 spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock, 647 spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock,
648 flags); 648 flags);
649 return NULL; 649 return NULL;
650 } 650 }
651 /* Dup */
652 memcpy(new, orig, sizeof(struct lsap_cb));
653 /* new->lap = orig->lap; => done in the memcpy() */ 651 /* new->lap = orig->lap; => done in the memcpy() */
654 /* new->slsap_sel = orig->slsap_sel; => done in the memcpy() */ 652 /* new->slsap_sel = orig->slsap_sel; => done in the memcpy() */
655 new->conn_skb = NULL; 653 new->conn_skb = NULL;
diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c
index 1ba8c7106639..1d26cd33ea13 100644
--- a/net/irda/irqueue.c
+++ b/net/irda/irqueue.c
@@ -356,14 +356,13 @@ hashbin_t *hashbin_new(int type)
356 /* 356 /*
357 * Allocate new hashbin 357 * Allocate new hashbin
358 */ 358 */
359 hashbin = kmalloc( sizeof(hashbin_t), GFP_ATOMIC); 359 hashbin = kzalloc(sizeof(*hashbin), GFP_ATOMIC);
360 if (!hashbin) 360 if (!hashbin)
361 return NULL; 361 return NULL;
362 362
363 /* 363 /*
364 * Initialize structure 364 * Initialize structure
365 */ 365 */
366 memset(hashbin, 0, sizeof(hashbin_t));
367 hashbin->hb_type = type; 366 hashbin->hb_type = type;
368 hashbin->magic = HB_MAGIC; 367 hashbin->magic = HB_MAGIC;
369 //hashbin->hb_current = NULL; 368 //hashbin->hb_current = NULL;
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index 3c2e70b77df1..9c446a72ff1f 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -1147,7 +1147,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
1147 frame[3] = 0x02; /* Value length */ 1147 frame[3] = 0x02; /* Value length */
1148 1148
1149 put_unaligned(cpu_to_be16((__u16) max_sdu_size), 1149 put_unaligned(cpu_to_be16((__u16) max_sdu_size),
1150 (__u16 *)(frame+4)); 1150 (__be16 *)(frame+4));
1151 } else { 1151 } else {
1152 /* Insert plain TTP header */ 1152 /* Insert plain TTP header */
1153 frame = skb_push(tx_skb, TTP_HEADER); 1153 frame = skb_push(tx_skb, TTP_HEADER);
@@ -1394,7 +1394,7 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
1394 frame[3] = 0x02; /* Value length */ 1394 frame[3] = 0x02; /* Value length */
1395 1395
1396 put_unaligned(cpu_to_be16((__u16) max_sdu_size), 1396 put_unaligned(cpu_to_be16((__u16) max_sdu_size),
1397 (__u16 *)(frame+4)); 1397 (__be16 *)(frame+4));
1398 } else { 1398 } else {
1399 /* Insert TTP header */ 1399 /* Insert TTP header */
1400 frame = skb_push(tx_skb, TTP_HEADER); 1400 frame = skb_push(tx_skb, TTP_HEADER);
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 20ff7cca1d07..0e1dbfbb9b10 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1767,11 +1767,11 @@ parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_ipsecrequest *rq)
1767 1767
1768 /* addresses present only in tunnel mode */ 1768 /* addresses present only in tunnel mode */
1769 if (t->mode == XFRM_MODE_TUNNEL) { 1769 if (t->mode == XFRM_MODE_TUNNEL) {
1770 switch (xp->family) { 1770 struct sockaddr *sa;
1771 sa = (struct sockaddr *)(rq+1);
1772 switch(sa->sa_family) {
1771 case AF_INET: 1773 case AF_INET:
1772 sin = (void*)(rq+1); 1774 sin = (struct sockaddr_in*)sa;
1773 if (sin->sin_family != AF_INET)
1774 return -EINVAL;
1775 t->saddr.a4 = sin->sin_addr.s_addr; 1775 t->saddr.a4 = sin->sin_addr.s_addr;
1776 sin++; 1776 sin++;
1777 if (sin->sin_family != AF_INET) 1777 if (sin->sin_family != AF_INET)
@@ -1780,9 +1780,7 @@ parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_ipsecrequest *rq)
1780 break; 1780 break;
1781#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1781#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1782 case AF_INET6: 1782 case AF_INET6:
1783 sin6 = (void *)(rq+1); 1783 sin6 = (struct sockaddr_in6*)sa;
1784 if (sin6->sin6_family != AF_INET6)
1785 return -EINVAL;
1786 memcpy(t->saddr.a6, &sin6->sin6_addr, sizeof(struct in6_addr)); 1784 memcpy(t->saddr.a6, &sin6->sin6_addr, sizeof(struct in6_addr));
1787 sin6++; 1785 sin6++;
1788 if (sin6->sin6_family != AF_INET6) 1786 if (sin6->sin6_family != AF_INET6)
@@ -1793,7 +1791,10 @@ parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_ipsecrequest *rq)
1793 default: 1791 default:
1794 return -EINVAL; 1792 return -EINVAL;
1795 } 1793 }
1796 } 1794 t->encap_family = sa->sa_family;
1795 } else
1796 t->encap_family = xp->family;
1797
1797 /* No way to set this via kame pfkey */ 1798 /* No way to set this via kame pfkey */
1798 t->aalgos = t->ealgos = t->calgos = ~0; 1799 t->aalgos = t->ealgos = t->calgos = ~0;
1799 xp->xfrm_nr++; 1800 xp->xfrm_nr++;
@@ -1830,18 +1831,25 @@ static inline int pfkey_xfrm_policy2sec_ctx_size(struct xfrm_policy *xp)
1830 1831
1831static int pfkey_xfrm_policy2msg_size(struct xfrm_policy *xp) 1832static int pfkey_xfrm_policy2msg_size(struct xfrm_policy *xp)
1832{ 1833{
1834 struct xfrm_tmpl *t;
1833 int sockaddr_size = pfkey_sockaddr_size(xp->family); 1835 int sockaddr_size = pfkey_sockaddr_size(xp->family);
1834 int socklen = (xp->family == AF_INET ? 1836 int socklen = 0;
1835 sizeof(struct sockaddr_in) : 1837 int i;
1836 sizeof(struct sockaddr_in6)); 1838
1839 for (i=0; i<xp->xfrm_nr; i++) {
1840 t = xp->xfrm_vec + i;
1841 socklen += (t->encap_family == AF_INET ?
1842 sizeof(struct sockaddr_in) :
1843 sizeof(struct sockaddr_in6));
1844 }
1837 1845
1838 return sizeof(struct sadb_msg) + 1846 return sizeof(struct sadb_msg) +
1839 (sizeof(struct sadb_lifetime) * 3) + 1847 (sizeof(struct sadb_lifetime) * 3) +
1840 (sizeof(struct sadb_address) * 2) + 1848 (sizeof(struct sadb_address) * 2) +
1841 (sockaddr_size * 2) + 1849 (sockaddr_size * 2) +
1842 sizeof(struct sadb_x_policy) + 1850 sizeof(struct sadb_x_policy) +
1843 (xp->xfrm_nr * (sizeof(struct sadb_x_ipsecrequest) + 1851 (xp->xfrm_nr * sizeof(struct sadb_x_ipsecrequest)) +
1844 (socklen * 2))) + 1852 (socklen * 2) +
1845 pfkey_xfrm_policy2sec_ctx_size(xp); 1853 pfkey_xfrm_policy2sec_ctx_size(xp);
1846} 1854}
1847 1855
@@ -1999,7 +2007,9 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
1999 2007
2000 req_size = sizeof(struct sadb_x_ipsecrequest); 2008 req_size = sizeof(struct sadb_x_ipsecrequest);
2001 if (t->mode == XFRM_MODE_TUNNEL) 2009 if (t->mode == XFRM_MODE_TUNNEL)
2002 req_size += 2*socklen; 2010 req_size += ((t->encap_family == AF_INET ?
2011 sizeof(struct sockaddr_in) :
2012 sizeof(struct sockaddr_in6)) * 2);
2003 else 2013 else
2004 size -= 2*socklen; 2014 size -= 2*socklen;
2005 rq = (void*)skb_put(skb, req_size); 2015 rq = (void*)skb_put(skb, req_size);
@@ -2015,7 +2025,7 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i
2015 rq->sadb_x_ipsecrequest_level = IPSEC_LEVEL_USE; 2025 rq->sadb_x_ipsecrequest_level = IPSEC_LEVEL_USE;
2016 rq->sadb_x_ipsecrequest_reqid = t->reqid; 2026 rq->sadb_x_ipsecrequest_reqid = t->reqid;
2017 if (t->mode == XFRM_MODE_TUNNEL) { 2027 if (t->mode == XFRM_MODE_TUNNEL) {
2018 switch (xp->family) { 2028 switch (t->encap_family) {
2019 case AF_INET: 2029 case AF_INET:
2020 sin = (void*)(rq+1); 2030 sin = (void*)(rq+1);
2021 sin->sin_family = AF_INET; 2031 sin->sin_family = AF_INET;
@@ -2938,7 +2948,7 @@ out:
2938 return NULL; 2948 return NULL;
2939} 2949}
2940 2950
2941static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, u16 sport) 2951static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport)
2942{ 2952{
2943 struct sk_buff *skb; 2953 struct sk_buff *skb;
2944 struct sadb_msg *hdr; 2954 struct sadb_msg *hdr;
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 2652ead96c64..190bb3e05188 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -64,7 +64,7 @@ static inline u16 llc_ui_next_link_no(int sap)
64 * 64 *
65 * Given an ARP header type return the corresponding ethernet protocol. 65 * Given an ARP header type return the corresponding ethernet protocol.
66 */ 66 */
67static inline u16 llc_proto_type(u16 arphrd) 67static inline __be16 llc_proto_type(u16 arphrd)
68{ 68{
69 return arphrd == ARPHRD_IEEE802_TR ? 69 return arphrd == ARPHRD_IEEE802_TR ?
70 htons(ETH_P_TR_802_2) : htons(ETH_P_802_2); 70 htons(ETH_P_TR_802_2) : htons(ETH_P_802_2);
diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c
index 94d2368ade92..db82aff6e40f 100644
--- a/net/llc/llc_input.c
+++ b/net/llc/llc_input.c
@@ -115,8 +115,8 @@ static inline int llc_fixup_skb(struct sk_buff *skb)
115 skb->h.raw += llc_len; 115 skb->h.raw += llc_len;
116 skb_pull(skb, llc_len); 116 skb_pull(skb, llc_len);
117 if (skb->protocol == htons(ETH_P_802_2)) { 117 if (skb->protocol == htons(ETH_P_802_2)) {
118 u16 pdulen = eth_hdr(skb)->h_proto, 118 __be16 pdulen = eth_hdr(skb)->h_proto;
119 data_size = ntohs(pdulen) - llc_len; 119 u16 data_size = ntohs(pdulen) - llc_len;
120 120
121 if (unlikely(pskb_trim_rcsum(skb, data_size))) 121 if (unlikely(pskb_trim_rcsum(skb, data_size)))
122 return 0; 122 return 0;
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index f619c6527266..3a66878a1829 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -25,19 +25,57 @@ config NETFILTER_NETLINK_LOG
25 and is also scheduled to replace the old syslog-based ipt_LOG 25 and is also scheduled to replace the old syslog-based ipt_LOG
26 and ip6t_LOG modules. 26 and ip6t_LOG modules.
27 27
28config NF_CONNTRACK 28config NF_CONNTRACK_ENABLED
29 tristate "Layer 3 Independent Connection tracking (EXPERIMENTAL)" 29 tristate "Netfilter connection tracking support"
30 depends on EXPERIMENTAL && IP_NF_CONNTRACK=n 30 help
31 default n
32 ---help---
33 Connection tracking keeps a record of what packets have passed 31 Connection tracking keeps a record of what packets have passed
34 through your machine, in order to figure out how they are related 32 through your machine, in order to figure out how they are related
35 into connections. 33 into connections.
36 34
35 This is required to do Masquerading or other kinds of Network
36 Address Translation (except for Fast NAT). It can also be used to
37 enhance packet filtering (see `Connection state match support'
38 below).
39
40 To compile it as a module, choose M here. If unsure, say N.
41
42choice
43 prompt "Netfilter connection tracking support"
44 depends on NF_CONNTRACK_ENABLED
45
46config NF_CONNTRACK_SUPPORT
47 bool "Layer 3 Independent Connection tracking (EXPERIMENTAL)"
48 depends on EXPERIMENTAL
49 help
37 Layer 3 independent connection tracking is experimental scheme 50 Layer 3 independent connection tracking is experimental scheme
38 which generalize ip_conntrack to support other layer 3 protocols. 51 which generalize ip_conntrack to support other layer 3 protocols.
39 52
40 To compile it as a module, choose M here. If unsure, say N. 53 This is required to do Masquerading or other kinds of Network
54 Address Translation (except for Fast NAT). It can also be used to
55 enhance packet filtering (see `Connection state match support'
56 below).
57
58config IP_NF_CONNTRACK_SUPPORT
59 bool "Layer 3 Dependent Connection tracking (OBSOLETE)"
60 help
61 The old, Layer 3 dependent ip_conntrack subsystem of netfilter.
62
63 This is required to do Masquerading or other kinds of Network
64 Address Translation (except for Fast NAT). It can also be used to
65 enhance packet filtering (see `Connection state match support'
66 below).
67
68endchoice
69
70config NF_CONNTRACK
71 tristate
72 default m if NF_CONNTRACK_SUPPORT && NF_CONNTRACK_ENABLED=m
73 default y if NF_CONNTRACK_SUPPORT && NF_CONNTRACK_ENABLED=y
74
75config IP_NF_CONNTRACK
76 tristate
77 default m if IP_NF_CONNTRACK_SUPPORT && NF_CONNTRACK_ENABLED=m
78 default y if IP_NF_CONNTRACK_SUPPORT && NF_CONNTRACK_ENABLED=y
41 79
42config NF_CT_ACCT 80config NF_CT_ACCT
43 bool "Connection tracking flow accounting" 81 bool "Connection tracking flow accounting"
@@ -82,8 +120,12 @@ config NF_CONNTRACK_EVENTS
82 120
83 If unsure, say `N'. 121 If unsure, say `N'.
84 122
123config NF_CT_PROTO_GRE
124 tristate
125 depends on EXPERIMENTAL && NF_CONNTRACK
126
85config NF_CT_PROTO_SCTP 127config NF_CT_PROTO_SCTP
86 tristate 'SCTP protocol on new connection tracking support (EXPERIMENTAL)' 128 tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)'
87 depends on EXPERIMENTAL && NF_CONNTRACK 129 depends on EXPERIMENTAL && NF_CONNTRACK
88 default n 130 default n
89 help 131 help
@@ -93,8 +135,23 @@ config NF_CT_PROTO_SCTP
93 If you want to compile it as a module, say M here and read 135 If you want to compile it as a module, say M here and read
94 Documentation/modules.txt. If unsure, say `N'. 136 Documentation/modules.txt. If unsure, say `N'.
95 137
138config NF_CONNTRACK_AMANDA
139 tristate "Amanda backup protocol support (EXPERIMENTAL)"
140 depends on EXPERIMENTAL && NF_CONNTRACK
141 select TEXTSEARCH
142 select TEXTSEARCH_KMP
143 help
144 If you are running the Amanda backup package <http://www.amanda.org/>
145 on this machine or machines that will be MASQUERADED through this
146 machine, then you may want to enable this feature. This allows the
147 connection tracking and natting code to allow the sub-channels that
148 Amanda requires for communication of the backup data, messages and
149 index.
150
151 To compile it as a module, choose M here. If unsure, say N.
152
96config NF_CONNTRACK_FTP 153config NF_CONNTRACK_FTP
97 tristate "FTP support on new connection tracking (EXPERIMENTAL)" 154 tristate "FTP protocol support (EXPERIMENTAL)"
98 depends on EXPERIMENTAL && NF_CONNTRACK 155 depends on EXPERIMENTAL && NF_CONNTRACK
99 help 156 help
100 Tracking FTP connections is problematic: special helpers are 157 Tracking FTP connections is problematic: special helpers are
@@ -107,6 +164,101 @@ config NF_CONNTRACK_FTP
107 164
108 To compile it as a module, choose M here. If unsure, say N. 165 To compile it as a module, choose M here. If unsure, say N.
109 166
167config NF_CONNTRACK_H323
168 tristate "H.323 protocol support (EXPERIMENTAL)"
169 depends on EXPERIMENTAL && NF_CONNTRACK
170 help
171 H.323 is a VoIP signalling protocol from ITU-T. As one of the most
172 important VoIP protocols, it is widely used by voice hardware and
173 software including voice gateways, IP phones, Netmeeting, OpenPhone,
174 Gnomemeeting, etc.
175
176 With this module you can support H.323 on a connection tracking/NAT
177 firewall.
178
179 This module supports RAS, Fast Start, H.245 Tunnelling, Call
180 Forwarding, RTP/RTCP and T.120 based audio, video, fax, chat,
181 whiteboard, file transfer, etc. For more information, please
182 visit http://nath323.sourceforge.net/.
183
184 To compile it as a module, choose M here. If unsure, say N.
185
186config NF_CONNTRACK_IRC
187 tristate "IRC protocol support (EXPERIMENTAL)"
188 depends on EXPERIMENTAL && NF_CONNTRACK
189 help
190 There is a commonly-used extension to IRC called
191 Direct Client-to-Client Protocol (DCC). This enables users to send
192 files to each other, and also chat to each other without the need
193 of a server. DCC Sending is used anywhere you send files over IRC,
194 and DCC Chat is most commonly used by Eggdrop bots. If you are
195 using NAT, this extension will enable you to send files and initiate
196 chats. Note that you do NOT need this extension to get files or
197 have others initiate chats, or everything else in IRC.
198
199 To compile it as a module, choose M here. If unsure, say N.
200
201config NF_CONNTRACK_NETBIOS_NS
202 tristate "NetBIOS name service protocol support (EXPERIMENTAL)"
203 depends on EXPERIMENTAL && NF_CONNTRACK
204 help
205 NetBIOS name service requests are sent as broadcast messages from an
206 unprivileged port and responded to with unicast messages to the
207 same port. This make them hard to firewall properly because connection
208 tracking doesn't deal with broadcasts. This helper tracks locally
209 originating NetBIOS name service requests and the corresponding
210 responses. It relies on correct IP address configuration, specifically
211 netmask and broadcast address. When properly configured, the output
212 of "ip address show" should look similar to this:
213
214 $ ip -4 address show eth0
215 4: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
216 inet 172.16.2.252/24 brd 172.16.2.255 scope global eth0
217
218 To compile it as a module, choose M here. If unsure, say N.
219
220config NF_CONNTRACK_PPTP
221 tristate "PPtP protocol support (EXPERIMENTAL)"
222 depends on EXPERIMENTAL && NF_CONNTRACK
223 select NF_CT_PROTO_GRE
224 help
225 This module adds support for PPTP (Point to Point Tunnelling
226 Protocol, RFC2637) connection tracking and NAT.
227
228 If you are running PPTP sessions over a stateful firewall or NAT
229 box, you may want to enable this feature.
230
231 Please note that not all PPTP modes of operation are supported yet.
232 Specifically these limitations exist:
233 - Blindy assumes that control connections are always established
234 in PNS->PAC direction. This is a violation of RFC2637.
235 - Only supports a single call within each session
236
237 To compile it as a module, choose M here. If unsure, say N.
238
239config NF_CONNTRACK_SIP
240 tristate "SIP protocol support (EXPERIMENTAL)"
241 depends on EXPERIMENTAL && NF_CONNTRACK
242 help
243 SIP is an application-layer control protocol that can establish,
244 modify, and terminate multimedia sessions (conferences) such as
245 Internet telephony calls. With the ip_conntrack_sip and
246 the nf_nat_sip modules you can support the protocol on a connection
247 tracking/NATing firewall.
248
249 To compile it as a module, choose M here. If unsure, say N.
250
251config NF_CONNTRACK_TFTP
252 tristate "TFTP protocol support (EXPERIMENTAL)"
253 depends on EXPERIMENTAL && NF_CONNTRACK
254 help
255 TFTP connection tracking helper, this is required depending
256 on how restrictive your ruleset is.
257 If you are using a tftp client behind -j SNAT or -j MASQUERADING
258 you will need this.
259
260 To compile it as a module, choose M here. If unsure, say N.
261
110config NF_CT_NETLINK 262config NF_CT_NETLINK
111 tristate 'Connection tracking netlink interface (EXPERIMENTAL)' 263 tristate 'Connection tracking netlink interface (EXPERIMENTAL)'
112 depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK 264 depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK
@@ -184,6 +336,17 @@ config NETFILTER_XT_TARGET_NFQUEUE
184 336
185 To compile it as a module, choose M here. If unsure, say N. 337 To compile it as a module, choose M here. If unsure, say N.
186 338
339config NETFILTER_XT_TARGET_NFLOG
340 tristate '"NFLOG" target support'
341 depends on NETFILTER_XTABLES
342 help
343 This option enables the NFLOG target, which allows to LOG
344 messages through the netfilter logging API, which can use
345 either the old LOG target, the old ULOG target or nfnetlink_log
346 as backend.
347
348 To compile it as a module, choose M here. If unsure, say N.
349
187config NETFILTER_XT_TARGET_NOTRACK 350config NETFILTER_XT_TARGET_NOTRACK
188 tristate '"NOTRACK" target support' 351 tristate '"NOTRACK" target support'
189 depends on NETFILTER_XTABLES 352 depends on NETFILTER_XTABLES
@@ -464,5 +627,19 @@ config NETFILTER_XT_MATCH_TCPMSS
464 627
465 To compile it as a module, choose M here. If unsure, say N. 628 To compile it as a module, choose M here. If unsure, say N.
466 629
630config NETFILTER_XT_MATCH_HASHLIMIT
631 tristate '"hashlimit" match support'
632 depends on NETFILTER_XTABLES
633 help
634 This option adds a `hashlimit' match.
635
636 As opposed to `limit', this match dynamically creates a hash table
637 of limit buckets, based on your selection of source/destination
638 addresses and/or ports.
639
640 It enables you to express policies like `10kpps for any given
641 destination address' or `500pps from any given source address'
642 with a single rule.
643
467endmenu 644endmenu
468 645
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
index a74be492fd0a..5dc5574f7e99 100644
--- a/net/netfilter/Makefile
+++ b/net/netfilter/Makefile
@@ -1,7 +1,10 @@
1netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o 1netfilter-objs := core.o nf_log.o nf_queue.o nf_sockopt.o
2nf_conntrack-objs := nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o 2
3nf_conntrack-y := nf_conntrack_core.o nf_conntrack_standalone.o nf_conntrack_expect.o nf_conntrack_helper.o nf_conntrack_proto.o nf_conntrack_l3proto_generic.o nf_conntrack_proto_generic.o nf_conntrack_proto_tcp.o nf_conntrack_proto_udp.o
4nf_conntrack-$(CONFIG_NF_CONNTRACK_EVENTS) += nf_conntrack_ecache.o
3 5
4obj-$(CONFIG_NETFILTER) = netfilter.o 6obj-$(CONFIG_NETFILTER) = netfilter.o
7obj-$(CONFIG_SYSCTL) += nf_sysctl.o
5 8
6obj-$(CONFIG_NETFILTER_NETLINK) += nfnetlink.o 9obj-$(CONFIG_NETFILTER_NETLINK) += nfnetlink.o
7obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += nfnetlink_queue.o 10obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += nfnetlink_queue.o
@@ -11,13 +14,23 @@ obj-$(CONFIG_NETFILTER_NETLINK_LOG) += nfnetlink_log.o
11obj-$(CONFIG_NF_CONNTRACK) += nf_conntrack.o 14obj-$(CONFIG_NF_CONNTRACK) += nf_conntrack.o
12 15
13# SCTP protocol connection tracking 16# SCTP protocol connection tracking
17obj-$(CONFIG_NF_CT_PROTO_GRE) += nf_conntrack_proto_gre.o
14obj-$(CONFIG_NF_CT_PROTO_SCTP) += nf_conntrack_proto_sctp.o 18obj-$(CONFIG_NF_CT_PROTO_SCTP) += nf_conntrack_proto_sctp.o
15 19
16# netlink interface for nf_conntrack 20# netlink interface for nf_conntrack
17obj-$(CONFIG_NF_CT_NETLINK) += nf_conntrack_netlink.o 21obj-$(CONFIG_NF_CT_NETLINK) += nf_conntrack_netlink.o
18 22
19# connection tracking helpers 23# connection tracking helpers
24nf_conntrack_h323-objs := nf_conntrack_h323_main.o nf_conntrack_h323_asn1.o
25
26obj-$(CONFIG_NF_CONNTRACK_AMANDA) += nf_conntrack_amanda.o
20obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o 27obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o
28obj-$(CONFIG_NF_CONNTRACK_H323) += nf_conntrack_h323.o
29obj-$(CONFIG_NF_CONNTRACK_IRC) += nf_conntrack_irc.o
30obj-$(CONFIG_NF_CONNTRACK_NETBIOS_NS) += nf_conntrack_netbios_ns.o
31obj-$(CONFIG_NF_CONNTRACK_PPTP) += nf_conntrack_pptp.o
32obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o
33obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_conntrack_tftp.o
21 34
22# generic X tables 35# generic X tables
23obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o 36obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
@@ -28,6 +41,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o
28obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o 41obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o
29obj-$(CONFIG_NETFILTER_XT_TARGET_MARK) += xt_MARK.o 42obj-$(CONFIG_NETFILTER_XT_TARGET_MARK) += xt_MARK.o
30obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o 43obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o
44obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG) += xt_NFLOG.o
31obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o 45obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o
32obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o 46obj-$(CONFIG_NETFILTER_XT_TARGET_SECMARK) += xt_SECMARK.o
33obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o 47obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o
@@ -56,3 +70,4 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o
56obj-$(CONFIG_NETFILTER_XT_MATCH_STRING) += xt_string.o 70obj-$(CONFIG_NETFILTER_XT_MATCH_STRING) += xt_string.o
57obj-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += xt_tcpmss.o 71obj-$(CONFIG_NETFILTER_XT_MATCH_TCPMSS) += xt_tcpmss.o
58obj-$(CONFIG_NETFILTER_XT_MATCH_PHYSDEV) += xt_physdev.o 72obj-$(CONFIG_NETFILTER_XT_MATCH_PHYSDEV) += xt_physdev.o
73obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index d80b935b3a92..291b8c6862f1 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -28,7 +28,7 @@
28 28
29static DEFINE_SPINLOCK(afinfo_lock); 29static DEFINE_SPINLOCK(afinfo_lock);
30 30
31struct nf_afinfo *nf_afinfo[NPROTO]; 31struct nf_afinfo *nf_afinfo[NPROTO] __read_mostly;
32EXPORT_SYMBOL(nf_afinfo); 32EXPORT_SYMBOL(nf_afinfo);
33 33
34int nf_register_afinfo(struct nf_afinfo *afinfo) 34int nf_register_afinfo(struct nf_afinfo *afinfo)
@@ -54,7 +54,7 @@ EXPORT_SYMBOL_GPL(nf_unregister_afinfo);
54 * of skbuffs queued for userspace, and not deregister a hook unless 54 * of skbuffs queued for userspace, and not deregister a hook unless
55 * this is zero, but that sucks. Now, we simply check when the 55 * this is zero, but that sucks. Now, we simply check when the
56 * packets come back: if the hook is gone, the packet is discarded. */ 56 * packets come back: if the hook is gone, the packet is discarded. */
57struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS]; 57struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS] __read_mostly;
58EXPORT_SYMBOL(nf_hooks); 58EXPORT_SYMBOL(nf_hooks);
59static DEFINE_SPINLOCK(nf_hook_lock); 59static DEFINE_SPINLOCK(nf_hook_lock);
60 60
@@ -222,28 +222,21 @@ copy_skb:
222} 222}
223EXPORT_SYMBOL(skb_make_writable); 223EXPORT_SYMBOL(skb_make_writable);
224 224
225u_int16_t nf_csum_update(u_int32_t oldval, u_int32_t newval, u_int32_t csum) 225void nf_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
226{ 226 __be32 from, __be32 to, int pseudohdr)
227 u_int32_t diff[] = { oldval, newval };
228
229 return csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum));
230}
231EXPORT_SYMBOL(nf_csum_update);
232
233u_int16_t nf_proto_csum_update(struct sk_buff *skb,
234 u_int32_t oldval, u_int32_t newval,
235 u_int16_t csum, int pseudohdr)
236{ 227{
228 __be32 diff[] = { ~from, to };
237 if (skb->ip_summed != CHECKSUM_PARTIAL) { 229 if (skb->ip_summed != CHECKSUM_PARTIAL) {
238 csum = nf_csum_update(oldval, newval, csum); 230 *sum = csum_fold(csum_partial((char *)diff, sizeof(diff),
231 ~csum_unfold(*sum)));
239 if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr) 232 if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr)
240 skb->csum = nf_csum_update(oldval, newval, skb->csum); 233 skb->csum = ~csum_partial((char *)diff, sizeof(diff),
234 ~skb->csum);
241 } else if (pseudohdr) 235 } else if (pseudohdr)
242 csum = ~nf_csum_update(oldval, newval, ~csum); 236 *sum = ~csum_fold(csum_partial((char *)diff, sizeof(diff),
243 237 csum_unfold(*sum)));
244 return csum;
245} 238}
246EXPORT_SYMBOL(nf_proto_csum_update); 239EXPORT_SYMBOL(nf_proto_csum_replace4);
247 240
248/* This does not belong here, but locally generated errors need it if connection 241/* This does not belong here, but locally generated errors need it if connection
249 tracking in use: without this, connection may not be in hash table, and hence 242 tracking in use: without this, connection may not be in hash table, and hence
diff --git a/net/netfilter/nf_conntrack_amanda.c b/net/netfilter/nf_conntrack_amanda.c
new file mode 100644
index 000000000000..b8869eab7650
--- /dev/null
+++ b/net/netfilter/nf_conntrack_amanda.c
@@ -0,0 +1,238 @@
1/* Amanda extension for IP connection tracking
2 *
3 * (C) 2002 by Brian J. Murrell <netfilter@interlinx.bc.ca>
4 * based on HW's ip_conntrack_irc.c as well as other modules
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/textsearch.h>
15#include <linux/skbuff.h>
16#include <linux/in.h>
17#include <linux/udp.h>
18#include <linux/netfilter.h>
19
20#include <net/netfilter/nf_conntrack.h>
21#include <net/netfilter/nf_conntrack_expect.h>
22#include <net/netfilter/nf_conntrack_ecache.h>
23#include <net/netfilter/nf_conntrack_helper.h>
24#include <linux/netfilter/nf_conntrack_amanda.h>
25
26static unsigned int master_timeout __read_mostly = 300;
27static char *ts_algo = "kmp";
28
29MODULE_AUTHOR("Brian J. Murrell <netfilter@interlinx.bc.ca>");
30MODULE_DESCRIPTION("Amanda connection tracking module");
31MODULE_LICENSE("GPL");
32MODULE_ALIAS("ip_conntrack_amanda");
33
34module_param(master_timeout, uint, 0600);
35MODULE_PARM_DESC(master_timeout, "timeout for the master connection");
36module_param(ts_algo, charp, 0400);
37MODULE_PARM_DESC(ts_algo, "textsearch algorithm to use (default kmp)");
38
39unsigned int (*nf_nat_amanda_hook)(struct sk_buff **pskb,
40 enum ip_conntrack_info ctinfo,
41 unsigned int matchoff,
42 unsigned int matchlen,
43 struct nf_conntrack_expect *exp)
44 __read_mostly;
45EXPORT_SYMBOL_GPL(nf_nat_amanda_hook);
46
47enum amanda_strings {
48 SEARCH_CONNECT,
49 SEARCH_NEWLINE,
50 SEARCH_DATA,
51 SEARCH_MESG,
52 SEARCH_INDEX,
53};
54
55static struct {
56 char *string;
57 size_t len;
58 struct ts_config *ts;
59} search[] __read_mostly = {
60 [SEARCH_CONNECT] = {
61 .string = "CONNECT ",
62 .len = 8,
63 },
64 [SEARCH_NEWLINE] = {
65 .string = "\n",
66 .len = 1,
67 },
68 [SEARCH_DATA] = {
69 .string = "DATA ",
70 .len = 5,
71 },
72 [SEARCH_MESG] = {
73 .string = "MESG ",
74 .len = 5,
75 },
76 [SEARCH_INDEX] = {
77 .string = "INDEX ",
78 .len = 6,
79 },
80};
81
82static int amanda_help(struct sk_buff **pskb,
83 unsigned int protoff,
84 struct nf_conn *ct,
85 enum ip_conntrack_info ctinfo)
86{
87 struct ts_state ts;
88 struct nf_conntrack_expect *exp;
89 struct nf_conntrack_tuple *tuple;
90 unsigned int dataoff, start, stop, off, i;
91 char pbuf[sizeof("65535")], *tmp;
92 u_int16_t len;
93 __be16 port;
94 int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
95 int ret = NF_ACCEPT;
96 typeof(nf_nat_amanda_hook) nf_nat_amanda;
97
98 /* Only look at packets from the Amanda server */
99 if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL)
100 return NF_ACCEPT;
101
102 /* increase the UDP timeout of the master connection as replies from
103 * Amanda clients to the server can be quite delayed */
104 nf_ct_refresh(ct, *pskb, master_timeout * HZ);
105
106 /* No data? */
107 dataoff = protoff + sizeof(struct udphdr);
108 if (dataoff >= (*pskb)->len) {
109 if (net_ratelimit())
110 printk("amanda_help: skblen = %u\n", (*pskb)->len);
111 return NF_ACCEPT;
112 }
113
114 memset(&ts, 0, sizeof(ts));
115 start = skb_find_text(*pskb, dataoff, (*pskb)->len,
116 search[SEARCH_CONNECT].ts, &ts);
117 if (start == UINT_MAX)
118 goto out;
119 start += dataoff + search[SEARCH_CONNECT].len;
120
121 memset(&ts, 0, sizeof(ts));
122 stop = skb_find_text(*pskb, start, (*pskb)->len,
123 search[SEARCH_NEWLINE].ts, &ts);
124 if (stop == UINT_MAX)
125 goto out;
126 stop += start;
127
128 for (i = SEARCH_DATA; i <= SEARCH_INDEX; i++) {
129 memset(&ts, 0, sizeof(ts));
130 off = skb_find_text(*pskb, start, stop, search[i].ts, &ts);
131 if (off == UINT_MAX)
132 continue;
133 off += start + search[i].len;
134
135 len = min_t(unsigned int, sizeof(pbuf) - 1, stop - off);
136 if (skb_copy_bits(*pskb, off, pbuf, len))
137 break;
138 pbuf[len] = '\0';
139
140 port = htons(simple_strtoul(pbuf, &tmp, 10));
141 len = tmp - pbuf;
142 if (port == 0 || len > 5)
143 break;
144
145 exp = nf_conntrack_expect_alloc(ct);
146 if (exp == NULL) {
147 ret = NF_DROP;
148 goto out;
149 }
150 tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
151 nf_conntrack_expect_init(exp, family,
152 &tuple->src.u3, &tuple->dst.u3,
153 IPPROTO_TCP, NULL, &port);
154
155 nf_nat_amanda = rcu_dereference(nf_nat_amanda_hook);
156 if (nf_nat_amanda && ct->status & IPS_NAT_MASK)
157 ret = nf_nat_amanda(pskb, ctinfo, off - dataoff,
158 len, exp);
159 else if (nf_conntrack_expect_related(exp) != 0)
160 ret = NF_DROP;
161 nf_conntrack_expect_put(exp);
162 }
163
164out:
165 return ret;
166}
167
168static struct nf_conntrack_helper amanda_helper[2] __read_mostly = {
169 {
170 .name = "amanda",
171 .max_expected = 3,
172 .timeout = 180,
173 .me = THIS_MODULE,
174 .help = amanda_help,
175 .tuple.src.l3num = AF_INET,
176 .tuple.src.u.udp.port = __constant_htons(10080),
177 .tuple.dst.protonum = IPPROTO_UDP,
178 .mask.src.l3num = 0xFFFF,
179 .mask.src.u.udp.port = __constant_htons(0xFFFF),
180 .mask.dst.protonum = 0xFF,
181 },
182 {
183 .name = "amanda",
184 .max_expected = 3,
185 .timeout = 180,
186 .me = THIS_MODULE,
187 .help = amanda_help,
188 .tuple.src.l3num = AF_INET6,
189 .tuple.src.u.udp.port = __constant_htons(10080),
190 .tuple.dst.protonum = IPPROTO_UDP,
191 .mask.src.l3num = 0xFFFF,
192 .mask.src.u.udp.port = __constant_htons(0xFFFF),
193 .mask.dst.protonum = 0xFF,
194 },
195};
196
197static void __exit nf_conntrack_amanda_fini(void)
198{
199 int i;
200
201 nf_conntrack_helper_unregister(&amanda_helper[0]);
202 nf_conntrack_helper_unregister(&amanda_helper[1]);
203 for (i = 0; i < ARRAY_SIZE(search); i++)
204 textsearch_destroy(search[i].ts);
205}
206
207static int __init nf_conntrack_amanda_init(void)
208{
209 int ret, i;
210
211 ret = -ENOMEM;
212 for (i = 0; i < ARRAY_SIZE(search); i++) {
213 search[i].ts = textsearch_prepare(ts_algo, search[i].string,
214 search[i].len,
215 GFP_KERNEL, TS_AUTOLOAD);
216 if (search[i].ts == NULL)
217 goto err1;
218 }
219 ret = nf_conntrack_helper_register(&amanda_helper[0]);
220 if (ret < 0)
221 goto err1;
222 ret = nf_conntrack_helper_register(&amanda_helper[1]);
223 if (ret < 0)
224 goto err2;
225 return 0;
226
227err2:
228 nf_conntrack_helper_unregister(&amanda_helper[0]);
229err1:
230 for (; i >= 0; i--) {
231 if (search[i].ts)
232 textsearch_destroy(search[i].ts);
233 }
234 return ret;
235}
236
237module_init(nf_conntrack_amanda_init);
238module_exit(nf_conntrack_amanda_fini);
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 836541e509fe..93d97d9f9da8 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -47,14 +47,10 @@
47#include <linux/netdevice.h> 47#include <linux/netdevice.h>
48#include <linux/socket.h> 48#include <linux/socket.h>
49 49
50/* This rwlock protects the main hash table, protocol/helper/expected
51 registrations, conntrack timers*/
52#define ASSERT_READ_LOCK(x)
53#define ASSERT_WRITE_LOCK(x)
54
55#include <net/netfilter/nf_conntrack.h> 50#include <net/netfilter/nf_conntrack.h>
56#include <net/netfilter/nf_conntrack_l3proto.h> 51#include <net/netfilter/nf_conntrack_l3proto.h>
57#include <net/netfilter/nf_conntrack_protocol.h> 52#include <net/netfilter/nf_conntrack_l4proto.h>
53#include <net/netfilter/nf_conntrack_expect.h>
58#include <net/netfilter/nf_conntrack_helper.h> 54#include <net/netfilter/nf_conntrack_helper.h>
59#include <net/netfilter/nf_conntrack_core.h> 55#include <net/netfilter/nf_conntrack_core.h>
60 56
@@ -67,92 +63,32 @@
67#endif 63#endif
68 64
69DEFINE_RWLOCK(nf_conntrack_lock); 65DEFINE_RWLOCK(nf_conntrack_lock);
66EXPORT_SYMBOL_GPL(nf_conntrack_lock);
70 67
71/* nf_conntrack_standalone needs this */ 68/* nf_conntrack_standalone needs this */
72atomic_t nf_conntrack_count = ATOMIC_INIT(0); 69atomic_t nf_conntrack_count = ATOMIC_INIT(0);
70EXPORT_SYMBOL_GPL(nf_conntrack_count);
73 71
74void (*nf_conntrack_destroyed)(struct nf_conn *conntrack) = NULL; 72void (*nf_conntrack_destroyed)(struct nf_conn *conntrack);
75LIST_HEAD(nf_conntrack_expect_list); 73EXPORT_SYMBOL_GPL(nf_conntrack_destroyed);
76struct nf_conntrack_protocol **nf_ct_protos[PF_MAX] __read_mostly;
77struct nf_conntrack_l3proto *nf_ct_l3protos[PF_MAX] __read_mostly;
78static LIST_HEAD(helpers);
79unsigned int nf_conntrack_htable_size __read_mostly = 0;
80int nf_conntrack_max __read_mostly;
81struct list_head *nf_conntrack_hash __read_mostly;
82static kmem_cache_t *nf_conntrack_expect_cachep __read_mostly;
83struct nf_conn nf_conntrack_untracked;
84unsigned int nf_ct_log_invalid __read_mostly;
85static LIST_HEAD(unconfirmed);
86static int nf_conntrack_vmalloc __read_mostly;
87
88static unsigned int nf_conntrack_next_id;
89static unsigned int nf_conntrack_expect_next_id;
90#ifdef CONFIG_NF_CONNTRACK_EVENTS
91ATOMIC_NOTIFIER_HEAD(nf_conntrack_chain);
92ATOMIC_NOTIFIER_HEAD(nf_conntrack_expect_chain);
93 74
94DEFINE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache); 75unsigned int nf_conntrack_htable_size __read_mostly;
76EXPORT_SYMBOL_GPL(nf_conntrack_htable_size);
95 77
96/* deliver cached events and clear cache entry - must be called with locally 78int nf_conntrack_max __read_mostly;
97 * disabled softirqs */ 79EXPORT_SYMBOL_GPL(nf_conntrack_max);
98static inline void
99__nf_ct_deliver_cached_events(struct nf_conntrack_ecache *ecache)
100{
101 DEBUGP("ecache: delivering events for %p\n", ecache->ct);
102 if (nf_ct_is_confirmed(ecache->ct) && !nf_ct_is_dying(ecache->ct)
103 && ecache->events)
104 atomic_notifier_call_chain(&nf_conntrack_chain, ecache->events,
105 ecache->ct);
106
107 ecache->events = 0;
108 nf_ct_put(ecache->ct);
109 ecache->ct = NULL;
110}
111 80
112/* Deliver all cached events for a particular conntrack. This is called 81struct list_head *nf_conntrack_hash __read_mostly;
113 * by code prior to async packet handling for freeing the skb */ 82EXPORT_SYMBOL_GPL(nf_conntrack_hash);
114void nf_ct_deliver_cached_events(const struct nf_conn *ct)
115{
116 struct nf_conntrack_ecache *ecache;
117 83
118 local_bh_disable(); 84struct nf_conn nf_conntrack_untracked __read_mostly;
119 ecache = &__get_cpu_var(nf_conntrack_ecache); 85EXPORT_SYMBOL_GPL(nf_conntrack_untracked);
120 if (ecache->ct == ct)
121 __nf_ct_deliver_cached_events(ecache);
122 local_bh_enable();
123}
124 86
125/* Deliver cached events for old pending events, if current conntrack != old */ 87unsigned int nf_ct_log_invalid __read_mostly;
126void __nf_ct_event_cache_init(struct nf_conn *ct) 88LIST_HEAD(unconfirmed);
127{ 89static int nf_conntrack_vmalloc __read_mostly;
128 struct nf_conntrack_ecache *ecache;
129
130 /* take care of delivering potentially old events */
131 ecache = &__get_cpu_var(nf_conntrack_ecache);
132 BUG_ON(ecache->ct == ct);
133 if (ecache->ct)
134 __nf_ct_deliver_cached_events(ecache);
135 /* initialize for this conntrack/packet */
136 ecache->ct = ct;
137 nf_conntrack_get(&ct->ct_general);
138}
139
140/* flush the event cache - touches other CPU's data and must not be called
141 * while packets are still passing through the code */
142static void nf_ct_event_cache_flush(void)
143{
144 struct nf_conntrack_ecache *ecache;
145 int cpu;
146 90
147 for_each_possible_cpu(cpu) { 91static unsigned int nf_conntrack_next_id;
148 ecache = &per_cpu(nf_conntrack_ecache, cpu);
149 if (ecache->ct)
150 nf_ct_put(ecache->ct);
151 }
152}
153#else
154static inline void nf_ct_event_cache_flush(void) {}
155#endif /* CONFIG_NF_CONNTRACK_EVENTS */
156 92
157DEFINE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat); 93DEFINE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat);
158EXPORT_PER_CPU_SYMBOL(nf_conntrack_stat); 94EXPORT_PER_CPU_SYMBOL(nf_conntrack_stat);
@@ -184,85 +120,6 @@ DEFINE_RWLOCK(nf_ct_cache_lock);
184/* This avoids calling kmem_cache_create() with same name simultaneously */ 120/* This avoids calling kmem_cache_create() with same name simultaneously */
185static DEFINE_MUTEX(nf_ct_cache_mutex); 121static DEFINE_MUTEX(nf_ct_cache_mutex);
186 122
187extern struct nf_conntrack_protocol nf_conntrack_generic_protocol;
188struct nf_conntrack_protocol *
189__nf_ct_proto_find(u_int16_t l3proto, u_int8_t protocol)
190{
191 if (unlikely(l3proto >= AF_MAX || nf_ct_protos[l3proto] == NULL))
192 return &nf_conntrack_generic_protocol;
193
194 return nf_ct_protos[l3proto][protocol];
195}
196
197/* this is guaranteed to always return a valid protocol helper, since
198 * it falls back to generic_protocol */
199struct nf_conntrack_protocol *
200nf_ct_proto_find_get(u_int16_t l3proto, u_int8_t protocol)
201{
202 struct nf_conntrack_protocol *p;
203
204 preempt_disable();
205 p = __nf_ct_proto_find(l3proto, protocol);
206 if (!try_module_get(p->me))
207 p = &nf_conntrack_generic_protocol;
208 preempt_enable();
209
210 return p;
211}
212
213void nf_ct_proto_put(struct nf_conntrack_protocol *p)
214{
215 module_put(p->me);
216}
217
218struct nf_conntrack_l3proto *
219nf_ct_l3proto_find_get(u_int16_t l3proto)
220{
221 struct nf_conntrack_l3proto *p;
222
223 preempt_disable();
224 p = __nf_ct_l3proto_find(l3proto);
225 if (!try_module_get(p->me))
226 p = &nf_conntrack_generic_l3proto;
227 preempt_enable();
228
229 return p;
230}
231
232void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p)
233{
234 module_put(p->me);
235}
236
237int
238nf_ct_l3proto_try_module_get(unsigned short l3proto)
239{
240 int ret;
241 struct nf_conntrack_l3proto *p;
242
243retry: p = nf_ct_l3proto_find_get(l3proto);
244 if (p == &nf_conntrack_generic_l3proto) {
245 ret = request_module("nf_conntrack-%d", l3proto);
246 if (!ret)
247 goto retry;
248
249 return -EPROTOTYPE;
250 }
251
252 return 0;
253}
254
255void nf_ct_l3proto_module_put(unsigned short l3proto)
256{
257 struct nf_conntrack_l3proto *p;
258
259 preempt_disable();
260 p = __nf_ct_l3proto_find(l3proto);
261 preempt_enable();
262
263 module_put(p->me);
264}
265
266static int nf_conntrack_hash_rnd_initted; 123static int nf_conntrack_hash_rnd_initted;
267static unsigned int nf_conntrack_hash_rnd; 124static unsigned int nf_conntrack_hash_rnd;
268 125
@@ -363,6 +220,7 @@ out_up_mutex:
363 mutex_unlock(&nf_ct_cache_mutex); 220 mutex_unlock(&nf_ct_cache_mutex);
364 return ret; 221 return ret;
365} 222}
223EXPORT_SYMBOL_GPL(nf_conntrack_register_cache);
366 224
367/* FIXME: In the current, only nf_conntrack_cleanup() can call this function. */ 225/* FIXME: In the current, only nf_conntrack_cleanup() can call this function. */
368void nf_conntrack_unregister_cache(u_int32_t features) 226void nf_conntrack_unregister_cache(u_int32_t features)
@@ -397,6 +255,7 @@ void nf_conntrack_unregister_cache(u_int32_t features)
397 255
398 mutex_unlock(&nf_ct_cache_mutex); 256 mutex_unlock(&nf_ct_cache_mutex);
399} 257}
258EXPORT_SYMBOL_GPL(nf_conntrack_unregister_cache);
400 259
401int 260int
402nf_ct_get_tuple(const struct sk_buff *skb, 261nf_ct_get_tuple(const struct sk_buff *skb,
@@ -406,7 +265,7 @@ nf_ct_get_tuple(const struct sk_buff *skb,
406 u_int8_t protonum, 265 u_int8_t protonum,
407 struct nf_conntrack_tuple *tuple, 266 struct nf_conntrack_tuple *tuple,
408 const struct nf_conntrack_l3proto *l3proto, 267 const struct nf_conntrack_l3proto *l3proto,
409 const struct nf_conntrack_protocol *protocol) 268 const struct nf_conntrack_l4proto *l4proto)
410{ 269{
411 NF_CT_TUPLE_U_BLANK(tuple); 270 NF_CT_TUPLE_U_BLANK(tuple);
412 271
@@ -417,14 +276,15 @@ nf_ct_get_tuple(const struct sk_buff *skb,
417 tuple->dst.protonum = protonum; 276 tuple->dst.protonum = protonum;
418 tuple->dst.dir = IP_CT_DIR_ORIGINAL; 277 tuple->dst.dir = IP_CT_DIR_ORIGINAL;
419 278
420 return protocol->pkt_to_tuple(skb, dataoff, tuple); 279 return l4proto->pkt_to_tuple(skb, dataoff, tuple);
421} 280}
281EXPORT_SYMBOL_GPL(nf_ct_get_tuple);
422 282
423int 283int
424nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, 284nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
425 const struct nf_conntrack_tuple *orig, 285 const struct nf_conntrack_tuple *orig,
426 const struct nf_conntrack_l3proto *l3proto, 286 const struct nf_conntrack_l3proto *l3proto,
427 const struct nf_conntrack_protocol *protocol) 287 const struct nf_conntrack_l4proto *l4proto)
428{ 288{
429 NF_CT_TUPLE_U_BLANK(inverse); 289 NF_CT_TUPLE_U_BLANK(inverse);
430 290
@@ -435,111 +295,14 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
435 inverse->dst.dir = !orig->dst.dir; 295 inverse->dst.dir = !orig->dst.dir;
436 296
437 inverse->dst.protonum = orig->dst.protonum; 297 inverse->dst.protonum = orig->dst.protonum;
438 return protocol->invert_tuple(inverse, orig); 298 return l4proto->invert_tuple(inverse, orig);
439}
440
441/* nf_conntrack_expect helper functions */
442void nf_ct_unlink_expect(struct nf_conntrack_expect *exp)
443{
444 struct nf_conn_help *master_help = nfct_help(exp->master);
445
446 NF_CT_ASSERT(master_help);
447 ASSERT_WRITE_LOCK(&nf_conntrack_lock);
448 NF_CT_ASSERT(!timer_pending(&exp->timeout));
449
450 list_del(&exp->list);
451 NF_CT_STAT_INC(expect_delete);
452 master_help->expecting--;
453 nf_conntrack_expect_put(exp);
454}
455
456static void expectation_timed_out(unsigned long ul_expect)
457{
458 struct nf_conntrack_expect *exp = (void *)ul_expect;
459
460 write_lock_bh(&nf_conntrack_lock);
461 nf_ct_unlink_expect(exp);
462 write_unlock_bh(&nf_conntrack_lock);
463 nf_conntrack_expect_put(exp);
464}
465
466struct nf_conntrack_expect *
467__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple)
468{
469 struct nf_conntrack_expect *i;
470
471 list_for_each_entry(i, &nf_conntrack_expect_list, list) {
472 if (nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask)) {
473 atomic_inc(&i->use);
474 return i;
475 }
476 }
477 return NULL;
478}
479
480/* Just find a expectation corresponding to a tuple. */
481struct nf_conntrack_expect *
482nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple)
483{
484 struct nf_conntrack_expect *i;
485
486 read_lock_bh(&nf_conntrack_lock);
487 i = __nf_conntrack_expect_find(tuple);
488 read_unlock_bh(&nf_conntrack_lock);
489
490 return i;
491}
492
493/* If an expectation for this connection is found, it gets delete from
494 * global list then returned. */
495static struct nf_conntrack_expect *
496find_expectation(const struct nf_conntrack_tuple *tuple)
497{
498 struct nf_conntrack_expect *i;
499
500 list_for_each_entry(i, &nf_conntrack_expect_list, list) {
501 /* If master is not in hash table yet (ie. packet hasn't left
502 this machine yet), how can other end know about expected?
503 Hence these are not the droids you are looking for (if
504 master ct never got confirmed, we'd hold a reference to it
505 and weird things would happen to future packets). */
506 if (nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask)
507 && nf_ct_is_confirmed(i->master)) {
508 if (i->flags & NF_CT_EXPECT_PERMANENT) {
509 atomic_inc(&i->use);
510 return i;
511 } else if (del_timer(&i->timeout)) {
512 nf_ct_unlink_expect(i);
513 return i;
514 }
515 }
516 }
517 return NULL;
518}
519
520/* delete all expectations for this conntrack */
521void nf_ct_remove_expectations(struct nf_conn *ct)
522{
523 struct nf_conntrack_expect *i, *tmp;
524 struct nf_conn_help *help = nfct_help(ct);
525
526 /* Optimization: most connection never expect any others. */
527 if (!help || help->expecting == 0)
528 return;
529
530 list_for_each_entry_safe(i, tmp, &nf_conntrack_expect_list, list) {
531 if (i->master == ct && del_timer(&i->timeout)) {
532 nf_ct_unlink_expect(i);
533 nf_conntrack_expect_put(i);
534 }
535 }
536} 299}
300EXPORT_SYMBOL_GPL(nf_ct_invert_tuple);
537 301
538static void 302static void
539clean_from_lists(struct nf_conn *ct) 303clean_from_lists(struct nf_conn *ct)
540{ 304{
541 DEBUGP("clean_from_lists(%p)\n", ct); 305 DEBUGP("clean_from_lists(%p)\n", ct);
542 ASSERT_WRITE_LOCK(&nf_conntrack_lock);
543 list_del(&ct->tuplehash[IP_CT_DIR_ORIGINAL].list); 306 list_del(&ct->tuplehash[IP_CT_DIR_ORIGINAL].list);
544 list_del(&ct->tuplehash[IP_CT_DIR_REPLY].list); 307 list_del(&ct->tuplehash[IP_CT_DIR_REPLY].list);
545 308
@@ -551,8 +314,9 @@ static void
551destroy_conntrack(struct nf_conntrack *nfct) 314destroy_conntrack(struct nf_conntrack *nfct)
552{ 315{
553 struct nf_conn *ct = (struct nf_conn *)nfct; 316 struct nf_conn *ct = (struct nf_conn *)nfct;
317 struct nf_conn_help *help = nfct_help(ct);
554 struct nf_conntrack_l3proto *l3proto; 318 struct nf_conntrack_l3proto *l3proto;
555 struct nf_conntrack_protocol *proto; 319 struct nf_conntrack_l4proto *l4proto;
556 320
557 DEBUGP("destroy_conntrack(%p)\n", ct); 321 DEBUGP("destroy_conntrack(%p)\n", ct);
558 NF_CT_ASSERT(atomic_read(&nfct->use) == 0); 322 NF_CT_ASSERT(atomic_read(&nfct->use) == 0);
@@ -561,6 +325,9 @@ destroy_conntrack(struct nf_conntrack *nfct)
561 nf_conntrack_event(IPCT_DESTROY, ct); 325 nf_conntrack_event(IPCT_DESTROY, ct);
562 set_bit(IPS_DYING_BIT, &ct->status); 326 set_bit(IPS_DYING_BIT, &ct->status);
563 327
328 if (help && help->helper && help->helper->destroy)
329 help->helper->destroy(ct);
330
564 /* To make sure we don't get any weird locking issues here: 331 /* To make sure we don't get any weird locking issues here:
565 * destroy_conntrack() MUST NOT be called with a write lock 332 * destroy_conntrack() MUST NOT be called with a write lock
566 * to nf_conntrack_lock!!! -HW */ 333 * to nf_conntrack_lock!!! -HW */
@@ -568,9 +335,9 @@ destroy_conntrack(struct nf_conntrack *nfct)
568 if (l3proto && l3proto->destroy) 335 if (l3proto && l3proto->destroy)
569 l3proto->destroy(ct); 336 l3proto->destroy(ct);
570 337
571 proto = __nf_ct_proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num, ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum); 338 l4proto = __nf_ct_l4proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num, ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum);
572 if (proto && proto->destroy) 339 if (l4proto && l4proto->destroy)
573 proto->destroy(ct); 340 l4proto->destroy(ct);
574 341
575 if (nf_conntrack_destroyed) 342 if (nf_conntrack_destroyed)
576 nf_conntrack_destroyed(ct); 343 nf_conntrack_destroyed(ct);
@@ -618,7 +385,6 @@ __nf_conntrack_find(const struct nf_conntrack_tuple *tuple,
618 struct nf_conntrack_tuple_hash *h; 385 struct nf_conntrack_tuple_hash *h;
619 unsigned int hash = hash_conntrack(tuple); 386 unsigned int hash = hash_conntrack(tuple);
620 387
621 ASSERT_READ_LOCK(&nf_conntrack_lock);
622 list_for_each_entry(h, &nf_conntrack_hash[hash], list) { 388 list_for_each_entry(h, &nf_conntrack_hash[hash], list) {
623 if (nf_ct_tuplehash_to_ctrack(h) != ignored_conntrack && 389 if (nf_ct_tuplehash_to_ctrack(h) != ignored_conntrack &&
624 nf_ct_tuple_equal(tuple, &h->tuple)) { 390 nf_ct_tuple_equal(tuple, &h->tuple)) {
@@ -630,6 +396,7 @@ __nf_conntrack_find(const struct nf_conntrack_tuple *tuple,
630 396
631 return NULL; 397 return NULL;
632} 398}
399EXPORT_SYMBOL_GPL(__nf_conntrack_find);
633 400
634/* Find a connection corresponding to a tuple. */ 401/* Find a connection corresponding to a tuple. */
635struct nf_conntrack_tuple_hash * 402struct nf_conntrack_tuple_hash *
@@ -646,6 +413,7 @@ nf_conntrack_find_get(const struct nf_conntrack_tuple *tuple,
646 413
647 return h; 414 return h;
648} 415}
416EXPORT_SYMBOL_GPL(nf_conntrack_find_get);
649 417
650static void __nf_conntrack_hash_insert(struct nf_conn *ct, 418static void __nf_conntrack_hash_insert(struct nf_conn *ct,
651 unsigned int hash, 419 unsigned int hash,
@@ -669,6 +437,7 @@ void nf_conntrack_hash_insert(struct nf_conn *ct)
669 __nf_conntrack_hash_insert(ct, hash, repl_hash); 437 __nf_conntrack_hash_insert(ct, hash, repl_hash);
670 write_unlock_bh(&nf_conntrack_lock); 438 write_unlock_bh(&nf_conntrack_lock);
671} 439}
440EXPORT_SYMBOL_GPL(nf_conntrack_hash_insert);
672 441
673/* Confirm a connection given skb; places it in hash table */ 442/* Confirm a connection given skb; places it in hash table */
674int 443int
@@ -746,6 +515,7 @@ out:
746 write_unlock_bh(&nf_conntrack_lock); 515 write_unlock_bh(&nf_conntrack_lock);
747 return NF_DROP; 516 return NF_DROP;
748} 517}
518EXPORT_SYMBOL_GPL(__nf_conntrack_confirm);
749 519
750/* Returns true if a connection correspondings to the tuple (required 520/* Returns true if a connection correspondings to the tuple (required
751 for NAT). */ 521 for NAT). */
@@ -761,6 +531,7 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
761 531
762 return h != NULL; 532 return h != NULL;
763} 533}
534EXPORT_SYMBOL_GPL(nf_conntrack_tuple_taken);
764 535
765/* There's a small race here where we may free a just-assured 536/* There's a small race here where we may free a just-assured
766 connection. Too bad: we're in trouble anyway. */ 537 connection. Too bad: we're in trouble anyway. */
@@ -794,53 +565,13 @@ static int early_drop(struct list_head *chain)
794 return dropped; 565 return dropped;
795} 566}
796 567
797static struct nf_conntrack_helper *
798__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple)
799{
800 struct nf_conntrack_helper *h;
801
802 list_for_each_entry(h, &helpers, list) {
803 if (nf_ct_tuple_mask_cmp(tuple, &h->tuple, &h->mask))
804 return h;
805 }
806 return NULL;
807}
808
809struct nf_conntrack_helper *
810nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple)
811{
812 struct nf_conntrack_helper *helper;
813
814 /* need nf_conntrack_lock to assure that helper exists until
815 * try_module_get() is called */
816 read_lock_bh(&nf_conntrack_lock);
817
818 helper = __nf_ct_helper_find(tuple);
819 if (helper) {
820 /* need to increase module usage count to assure helper will
821 * not go away while the caller is e.g. busy putting a
822 * conntrack in the hash that uses the helper */
823 if (!try_module_get(helper->me))
824 helper = NULL;
825 }
826
827 read_unlock_bh(&nf_conntrack_lock);
828
829 return helper;
830}
831
832void nf_ct_helper_put(struct nf_conntrack_helper *helper)
833{
834 module_put(helper->me);
835}
836
837static struct nf_conn * 568static struct nf_conn *
838__nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, 569__nf_conntrack_alloc(const struct nf_conntrack_tuple *orig,
839 const struct nf_conntrack_tuple *repl, 570 const struct nf_conntrack_tuple *repl,
840 const struct nf_conntrack_l3proto *l3proto) 571 const struct nf_conntrack_l3proto *l3proto,
572 u_int32_t features)
841{ 573{
842 struct nf_conn *conntrack = NULL; 574 struct nf_conn *conntrack = NULL;
843 u_int32_t features = 0;
844 struct nf_conntrack_helper *helper; 575 struct nf_conntrack_helper *helper;
845 576
846 if (unlikely(!nf_conntrack_hash_rnd_initted)) { 577 if (unlikely(!nf_conntrack_hash_rnd_initted)) {
@@ -866,12 +597,13 @@ __nf_conntrack_alloc(const struct nf_conntrack_tuple *orig,
866 } 597 }
867 598
868 /* find features needed by this conntrack. */ 599 /* find features needed by this conntrack. */
869 features = l3proto->get_features(orig); 600 features |= l3proto->get_features(orig);
870 601
871 /* FIXME: protect helper list per RCU */ 602 /* FIXME: protect helper list per RCU */
872 read_lock_bh(&nf_conntrack_lock); 603 read_lock_bh(&nf_conntrack_lock);
873 helper = __nf_ct_helper_find(repl); 604 helper = __nf_ct_helper_find(repl);
874 if (helper) 605 /* NAT might want to assign a helper later */
606 if (helper || features & NF_CT_F_NAT)
875 features |= NF_CT_F_HELP; 607 features |= NF_CT_F_HELP;
876 read_unlock_bh(&nf_conntrack_lock); 608 read_unlock_bh(&nf_conntrack_lock);
877 609
@@ -893,12 +625,6 @@ __nf_conntrack_alloc(const struct nf_conntrack_tuple *orig,
893 625
894 memset(conntrack, 0, nf_ct_cache[features].size); 626 memset(conntrack, 0, nf_ct_cache[features].size);
895 conntrack->features = features; 627 conntrack->features = features;
896 if (helper) {
897 struct nf_conn_help *help = nfct_help(conntrack);
898 NF_CT_ASSERT(help);
899 help->helper = helper;
900 }
901
902 atomic_set(&conntrack->ct_general.use, 1); 628 atomic_set(&conntrack->ct_general.use, 1);
903 conntrack->ct_general.destroy = destroy_conntrack; 629 conntrack->ct_general.destroy = destroy_conntrack;
904 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig; 630 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig;
@@ -922,8 +648,9 @@ struct nf_conn *nf_conntrack_alloc(const struct nf_conntrack_tuple *orig,
922 struct nf_conntrack_l3proto *l3proto; 648 struct nf_conntrack_l3proto *l3proto;
923 649
924 l3proto = __nf_ct_l3proto_find(orig->src.l3num); 650 l3proto = __nf_ct_l3proto_find(orig->src.l3num);
925 return __nf_conntrack_alloc(orig, repl, l3proto); 651 return __nf_conntrack_alloc(orig, repl, l3proto, 0);
926} 652}
653EXPORT_SYMBOL_GPL(nf_conntrack_alloc);
927 654
928void nf_conntrack_free(struct nf_conn *conntrack) 655void nf_conntrack_free(struct nf_conn *conntrack)
929{ 656{
@@ -934,32 +661,40 @@ void nf_conntrack_free(struct nf_conn *conntrack)
934 kmem_cache_free(nf_ct_cache[features].cachep, conntrack); 661 kmem_cache_free(nf_ct_cache[features].cachep, conntrack);
935 atomic_dec(&nf_conntrack_count); 662 atomic_dec(&nf_conntrack_count);
936} 663}
664EXPORT_SYMBOL_GPL(nf_conntrack_free);
937 665
938/* Allocate a new conntrack: we return -ENOMEM if classification 666/* Allocate a new conntrack: we return -ENOMEM if classification
939 failed due to stress. Otherwise it really is unclassifiable. */ 667 failed due to stress. Otherwise it really is unclassifiable. */
940static struct nf_conntrack_tuple_hash * 668static struct nf_conntrack_tuple_hash *
941init_conntrack(const struct nf_conntrack_tuple *tuple, 669init_conntrack(const struct nf_conntrack_tuple *tuple,
942 struct nf_conntrack_l3proto *l3proto, 670 struct nf_conntrack_l3proto *l3proto,
943 struct nf_conntrack_protocol *protocol, 671 struct nf_conntrack_l4proto *l4proto,
944 struct sk_buff *skb, 672 struct sk_buff *skb,
945 unsigned int dataoff) 673 unsigned int dataoff)
946{ 674{
947 struct nf_conn *conntrack; 675 struct nf_conn *conntrack;
948 struct nf_conntrack_tuple repl_tuple; 676 struct nf_conntrack_tuple repl_tuple;
949 struct nf_conntrack_expect *exp; 677 struct nf_conntrack_expect *exp;
678 u_int32_t features = 0;
950 679
951 if (!nf_ct_invert_tuple(&repl_tuple, tuple, l3proto, protocol)) { 680 if (!nf_ct_invert_tuple(&repl_tuple, tuple, l3proto, l4proto)) {
952 DEBUGP("Can't invert tuple.\n"); 681 DEBUGP("Can't invert tuple.\n");
953 return NULL; 682 return NULL;
954 } 683 }
955 684
956 conntrack = __nf_conntrack_alloc(tuple, &repl_tuple, l3proto); 685 read_lock_bh(&nf_conntrack_lock);
686 exp = __nf_conntrack_expect_find(tuple);
687 if (exp && exp->helper)
688 features = NF_CT_F_HELP;
689 read_unlock_bh(&nf_conntrack_lock);
690
691 conntrack = __nf_conntrack_alloc(tuple, &repl_tuple, l3proto, features);
957 if (conntrack == NULL || IS_ERR(conntrack)) { 692 if (conntrack == NULL || IS_ERR(conntrack)) {
958 DEBUGP("Can't allocate conntrack.\n"); 693 DEBUGP("Can't allocate conntrack.\n");
959 return (struct nf_conntrack_tuple_hash *)conntrack; 694 return (struct nf_conntrack_tuple_hash *)conntrack;
960 } 695 }
961 696
962 if (!protocol->new(conntrack, skb, dataoff)) { 697 if (!l4proto->new(conntrack, skb, dataoff)) {
963 nf_conntrack_free(conntrack); 698 nf_conntrack_free(conntrack);
964 DEBUGP("init conntrack: can't track with proto module\n"); 699 DEBUGP("init conntrack: can't track with proto module\n");
965 return NULL; 700 return NULL;
@@ -974,6 +709,8 @@ init_conntrack(const struct nf_conntrack_tuple *tuple,
974 /* Welcome, Mr. Bond. We've been expecting you... */ 709 /* Welcome, Mr. Bond. We've been expecting you... */
975 __set_bit(IPS_EXPECTED_BIT, &conntrack->status); 710 __set_bit(IPS_EXPECTED_BIT, &conntrack->status);
976 conntrack->master = exp->master; 711 conntrack->master = exp->master;
712 if (exp->helper)
713 nfct_help(conntrack)->helper = exp->helper;
977#ifdef CONFIG_NF_CONNTRACK_MARK 714#ifdef CONFIG_NF_CONNTRACK_MARK
978 conntrack->mark = exp->master->mark; 715 conntrack->mark = exp->master->mark;
979#endif 716#endif
@@ -982,8 +719,13 @@ init_conntrack(const struct nf_conntrack_tuple *tuple,
982#endif 719#endif
983 nf_conntrack_get(&conntrack->master->ct_general); 720 nf_conntrack_get(&conntrack->master->ct_general);
984 NF_CT_STAT_INC(expect_new); 721 NF_CT_STAT_INC(expect_new);
985 } else 722 } else {
723 struct nf_conn_help *help = nfct_help(conntrack);
724
725 if (help)
726 help->helper = __nf_ct_helper_find(&repl_tuple);
986 NF_CT_STAT_INC(new); 727 NF_CT_STAT_INC(new);
728 }
987 729
988 /* Overload tuple linked list to put us in unconfirmed list. */ 730 /* Overload tuple linked list to put us in unconfirmed list. */
989 list_add(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list, &unconfirmed); 731 list_add(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list, &unconfirmed);
@@ -1006,7 +748,7 @@ resolve_normal_ct(struct sk_buff *skb,
1006 u_int16_t l3num, 748 u_int16_t l3num,
1007 u_int8_t protonum, 749 u_int8_t protonum,
1008 struct nf_conntrack_l3proto *l3proto, 750 struct nf_conntrack_l3proto *l3proto,
1009 struct nf_conntrack_protocol *proto, 751 struct nf_conntrack_l4proto *l4proto,
1010 int *set_reply, 752 int *set_reply,
1011 enum ip_conntrack_info *ctinfo) 753 enum ip_conntrack_info *ctinfo)
1012{ 754{
@@ -1016,7 +758,7 @@ resolve_normal_ct(struct sk_buff *skb,
1016 758
1017 if (!nf_ct_get_tuple(skb, (unsigned int)(skb->nh.raw - skb->data), 759 if (!nf_ct_get_tuple(skb, (unsigned int)(skb->nh.raw - skb->data),
1018 dataoff, l3num, protonum, &tuple, l3proto, 760 dataoff, l3num, protonum, &tuple, l3proto,
1019 proto)) { 761 l4proto)) {
1020 DEBUGP("resolve_normal_ct: Can't get tuple\n"); 762 DEBUGP("resolve_normal_ct: Can't get tuple\n");
1021 return NULL; 763 return NULL;
1022 } 764 }
@@ -1024,7 +766,7 @@ resolve_normal_ct(struct sk_buff *skb,
1024 /* look for tuple match */ 766 /* look for tuple match */
1025 h = nf_conntrack_find_get(&tuple, NULL); 767 h = nf_conntrack_find_get(&tuple, NULL);
1026 if (!h) { 768 if (!h) {
1027 h = init_conntrack(&tuple, l3proto, proto, skb, dataoff); 769 h = init_conntrack(&tuple, l3proto, l4proto, skb, dataoff);
1028 if (!h) 770 if (!h)
1029 return NULL; 771 return NULL;
1030 if (IS_ERR(h)) 772 if (IS_ERR(h))
@@ -1062,7 +804,7 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
1062 struct nf_conn *ct; 804 struct nf_conn *ct;
1063 enum ip_conntrack_info ctinfo; 805 enum ip_conntrack_info ctinfo;
1064 struct nf_conntrack_l3proto *l3proto; 806 struct nf_conntrack_l3proto *l3proto;
1065 struct nf_conntrack_protocol *proto; 807 struct nf_conntrack_l4proto *l4proto;
1066 unsigned int dataoff; 808 unsigned int dataoff;
1067 u_int8_t protonum; 809 u_int8_t protonum;
1068 int set_reply = 0; 810 int set_reply = 0;
@@ -1080,19 +822,19 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
1080 return -ret; 822 return -ret;
1081 } 823 }
1082 824
1083 proto = __nf_ct_proto_find((u_int16_t)pf, protonum); 825 l4proto = __nf_ct_l4proto_find((u_int16_t)pf, protonum);
1084 826
1085 /* It may be an special packet, error, unclean... 827 /* It may be an special packet, error, unclean...
1086 * inverse of the return code tells to the netfilter 828 * inverse of the return code tells to the netfilter
1087 * core what to do with the packet. */ 829 * core what to do with the packet. */
1088 if (proto->error != NULL && 830 if (l4proto->error != NULL &&
1089 (ret = proto->error(*pskb, dataoff, &ctinfo, pf, hooknum)) <= 0) { 831 (ret = l4proto->error(*pskb, dataoff, &ctinfo, pf, hooknum)) <= 0) {
1090 NF_CT_STAT_INC(error); 832 NF_CT_STAT_INC(error);
1091 NF_CT_STAT_INC(invalid); 833 NF_CT_STAT_INC(invalid);
1092 return -ret; 834 return -ret;
1093 } 835 }
1094 836
1095 ct = resolve_normal_ct(*pskb, dataoff, pf, protonum, l3proto, proto, 837 ct = resolve_normal_ct(*pskb, dataoff, pf, protonum, l3proto, l4proto,
1096 &set_reply, &ctinfo); 838 &set_reply, &ctinfo);
1097 if (!ct) { 839 if (!ct) {
1098 /* Not valid part of a connection */ 840 /* Not valid part of a connection */
@@ -1108,7 +850,7 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
1108 850
1109 NF_CT_ASSERT((*pskb)->nfct); 851 NF_CT_ASSERT((*pskb)->nfct);
1110 852
1111 ret = proto->packet(ct, *pskb, dataoff, ctinfo, pf, hooknum); 853 ret = l4proto->packet(ct, *pskb, dataoff, ctinfo, pf, hooknum);
1112 if (ret < 0) { 854 if (ret < 0) {
1113 /* Invalid: inverse of the return code tells 855 /* Invalid: inverse of the return code tells
1114 * the netfilter core what to do */ 856 * the netfilter core what to do */
@@ -1124,255 +866,38 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
1124 866
1125 return ret; 867 return ret;
1126} 868}
869EXPORT_SYMBOL_GPL(nf_conntrack_in);
1127 870
1128int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse, 871int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
1129 const struct nf_conntrack_tuple *orig) 872 const struct nf_conntrack_tuple *orig)
1130{ 873{
1131 return nf_ct_invert_tuple(inverse, orig, 874 return nf_ct_invert_tuple(inverse, orig,
1132 __nf_ct_l3proto_find(orig->src.l3num), 875 __nf_ct_l3proto_find(orig->src.l3num),
1133 __nf_ct_proto_find(orig->src.l3num, 876 __nf_ct_l4proto_find(orig->src.l3num,
1134 orig->dst.protonum)); 877 orig->dst.protonum));
1135} 878}
879EXPORT_SYMBOL_GPL(nf_ct_invert_tuplepr);
1136 880
1137/* Would two expected things clash? */ 881/* Alter reply tuple (maybe alter helper). This is for NAT, and is
1138static inline int expect_clash(const struct nf_conntrack_expect *a, 882 implicitly racy: see __nf_conntrack_confirm */
1139 const struct nf_conntrack_expect *b) 883void nf_conntrack_alter_reply(struct nf_conn *ct,
1140{ 884 const struct nf_conntrack_tuple *newreply)
1141 /* Part covered by intersection of masks must be unequal,
1142 otherwise they clash */
1143 struct nf_conntrack_tuple intersect_mask;
1144 int count;
1145
1146 intersect_mask.src.l3num = a->mask.src.l3num & b->mask.src.l3num;
1147 intersect_mask.src.u.all = a->mask.src.u.all & b->mask.src.u.all;
1148 intersect_mask.dst.u.all = a->mask.dst.u.all & b->mask.dst.u.all;
1149 intersect_mask.dst.protonum = a->mask.dst.protonum
1150 & b->mask.dst.protonum;
1151
1152 for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++){
1153 intersect_mask.src.u3.all[count] =
1154 a->mask.src.u3.all[count] & b->mask.src.u3.all[count];
1155 }
1156
1157 for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++){
1158 intersect_mask.dst.u3.all[count] =
1159 a->mask.dst.u3.all[count] & b->mask.dst.u3.all[count];
1160 }
1161
1162 return nf_ct_tuple_mask_cmp(&a->tuple, &b->tuple, &intersect_mask);
1163}
1164
1165static inline int expect_matches(const struct nf_conntrack_expect *a,
1166 const struct nf_conntrack_expect *b)
1167{
1168 return a->master == b->master
1169 && nf_ct_tuple_equal(&a->tuple, &b->tuple)
1170 && nf_ct_tuple_equal(&a->mask, &b->mask);
1171}
1172
1173/* Generally a bad idea to call this: could have matched already. */
1174void nf_conntrack_unexpect_related(struct nf_conntrack_expect *exp)
1175{
1176 struct nf_conntrack_expect *i;
1177
1178 write_lock_bh(&nf_conntrack_lock);
1179 /* choose the the oldest expectation to evict */
1180 list_for_each_entry_reverse(i, &nf_conntrack_expect_list, list) {
1181 if (expect_matches(i, exp) && del_timer(&i->timeout)) {
1182 nf_ct_unlink_expect(i);
1183 write_unlock_bh(&nf_conntrack_lock);
1184 nf_conntrack_expect_put(i);
1185 return;
1186 }
1187 }
1188 write_unlock_bh(&nf_conntrack_lock);
1189}
1190
1191/* We don't increase the master conntrack refcount for non-fulfilled
1192 * conntracks. During the conntrack destruction, the expectations are
1193 * always killed before the conntrack itself */
1194struct nf_conntrack_expect *nf_conntrack_expect_alloc(struct nf_conn *me)
1195{
1196 struct nf_conntrack_expect *new;
1197
1198 new = kmem_cache_alloc(nf_conntrack_expect_cachep, GFP_ATOMIC);
1199 if (!new) {
1200 DEBUGP("expect_related: OOM allocating expect\n");
1201 return NULL;
1202 }
1203 new->master = me;
1204 atomic_set(&new->use, 1);
1205 return new;
1206}
1207
1208void nf_conntrack_expect_put(struct nf_conntrack_expect *exp)
1209{
1210 if (atomic_dec_and_test(&exp->use))
1211 kmem_cache_free(nf_conntrack_expect_cachep, exp);
1212}
1213
1214static void nf_conntrack_expect_insert(struct nf_conntrack_expect *exp)
1215{
1216 struct nf_conn_help *master_help = nfct_help(exp->master);
1217
1218 atomic_inc(&exp->use);
1219 master_help->expecting++;
1220 list_add(&exp->list, &nf_conntrack_expect_list);
1221
1222 init_timer(&exp->timeout);
1223 exp->timeout.data = (unsigned long)exp;
1224 exp->timeout.function = expectation_timed_out;
1225 exp->timeout.expires = jiffies + master_help->helper->timeout * HZ;
1226 add_timer(&exp->timeout);
1227
1228 exp->id = ++nf_conntrack_expect_next_id;
1229 atomic_inc(&exp->use);
1230 NF_CT_STAT_INC(expect_create);
1231}
1232
1233/* Race with expectations being used means we could have none to find; OK. */
1234static void evict_oldest_expect(struct nf_conn *master)
1235{
1236 struct nf_conntrack_expect *i;
1237
1238 list_for_each_entry_reverse(i, &nf_conntrack_expect_list, list) {
1239 if (i->master == master) {
1240 if (del_timer(&i->timeout)) {
1241 nf_ct_unlink_expect(i);
1242 nf_conntrack_expect_put(i);
1243 }
1244 break;
1245 }
1246 }
1247}
1248
1249static inline int refresh_timer(struct nf_conntrack_expect *i)
1250{
1251 struct nf_conn_help *master_help = nfct_help(i->master);
1252
1253 if (!del_timer(&i->timeout))
1254 return 0;
1255
1256 i->timeout.expires = jiffies + master_help->helper->timeout*HZ;
1257 add_timer(&i->timeout);
1258 return 1;
1259}
1260
1261int nf_conntrack_expect_related(struct nf_conntrack_expect *expect)
1262{ 885{
1263 struct nf_conntrack_expect *i;
1264 struct nf_conn *master = expect->master;
1265 struct nf_conn_help *master_help = nfct_help(master);
1266 int ret;
1267
1268 NF_CT_ASSERT(master_help);
1269
1270 DEBUGP("nf_conntrack_expect_related %p\n", related_to);
1271 DEBUGP("tuple: "); NF_CT_DUMP_TUPLE(&expect->tuple);
1272 DEBUGP("mask: "); NF_CT_DUMP_TUPLE(&expect->mask);
1273
1274 write_lock_bh(&nf_conntrack_lock);
1275 list_for_each_entry(i, &nf_conntrack_expect_list, list) {
1276 if (expect_matches(i, expect)) {
1277 /* Refresh timer: if it's dying, ignore.. */
1278 if (refresh_timer(i)) {
1279 ret = 0;
1280 goto out;
1281 }
1282 } else if (expect_clash(i, expect)) {
1283 ret = -EBUSY;
1284 goto out;
1285 }
1286 }
1287 /* Will be over limit? */
1288 if (master_help->helper->max_expected &&
1289 master_help->expecting >= master_help->helper->max_expected)
1290 evict_oldest_expect(master);
1291
1292 nf_conntrack_expect_insert(expect);
1293 nf_conntrack_expect_event(IPEXP_NEW, expect);
1294 ret = 0;
1295out:
1296 write_unlock_bh(&nf_conntrack_lock);
1297 return ret;
1298}
1299
1300int nf_conntrack_helper_register(struct nf_conntrack_helper *me)
1301{
1302 int ret;
1303 BUG_ON(me->timeout == 0);
1304
1305 ret = nf_conntrack_register_cache(NF_CT_F_HELP, "nf_conntrack:help",
1306 sizeof(struct nf_conn)
1307 + sizeof(struct nf_conn_help)
1308 + __alignof__(struct nf_conn_help));
1309 if (ret < 0) {
1310 printk(KERN_ERR "nf_conntrack_helper_reigster: Unable to create slab cache for conntracks\n");
1311 return ret;
1312 }
1313 write_lock_bh(&nf_conntrack_lock);
1314 list_add(&me->list, &helpers);
1315 write_unlock_bh(&nf_conntrack_lock);
1316
1317 return 0;
1318}
1319
1320struct nf_conntrack_helper *
1321__nf_conntrack_helper_find_byname(const char *name)
1322{
1323 struct nf_conntrack_helper *h;
1324
1325 list_for_each_entry(h, &helpers, list) {
1326 if (!strcmp(h->name, name))
1327 return h;
1328 }
1329
1330 return NULL;
1331}
1332
1333static inline void unhelp(struct nf_conntrack_tuple_hash *i,
1334 const struct nf_conntrack_helper *me)
1335{
1336 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(i);
1337 struct nf_conn_help *help = nfct_help(ct); 886 struct nf_conn_help *help = nfct_help(ct);
1338 887
1339 if (help && help->helper == me) {
1340 nf_conntrack_event(IPCT_HELPER, ct);
1341 help->helper = NULL;
1342 }
1343}
1344
1345void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)
1346{
1347 unsigned int i;
1348 struct nf_conntrack_tuple_hash *h;
1349 struct nf_conntrack_expect *exp, *tmp;
1350
1351 /* Need write lock here, to delete helper. */
1352 write_lock_bh(&nf_conntrack_lock); 888 write_lock_bh(&nf_conntrack_lock);
1353 list_del(&me->list); 889 /* Should be unconfirmed, so not in hash table yet */
1354 890 NF_CT_ASSERT(!nf_ct_is_confirmed(ct));
1355 /* Get rid of expectations */
1356 list_for_each_entry_safe(exp, tmp, &nf_conntrack_expect_list, list) {
1357 struct nf_conn_help *help = nfct_help(exp->master);
1358 if (help->helper == me && del_timer(&exp->timeout)) {
1359 nf_ct_unlink_expect(exp);
1360 nf_conntrack_expect_put(exp);
1361 }
1362 }
1363 891
1364 /* Get rid of expecteds, set helpers to NULL. */ 892 DEBUGP("Altering reply tuple of %p to ", ct);
1365 list_for_each_entry(h, &unconfirmed, list) 893 NF_CT_DUMP_TUPLE(newreply);
1366 unhelp(h, me);
1367 for (i = 0; i < nf_conntrack_htable_size; i++) {
1368 list_for_each_entry(h, &nf_conntrack_hash[i], list)
1369 unhelp(h, me);
1370 }
1371 write_unlock_bh(&nf_conntrack_lock);
1372 894
1373 /* Someone could be still looking at the helper in a bh. */ 895 ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
1374 synchronize_net(); 896 if (!ct->master && help && help->expecting == 0)
897 help->helper = __nf_ct_helper_find(newreply);
898 write_unlock_bh(&nf_conntrack_lock);
1375} 899}
900EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);
1376 901
1377/* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */ 902/* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */
1378void __nf_ct_refresh_acct(struct nf_conn *ct, 903void __nf_ct_refresh_acct(struct nf_conn *ct,
@@ -1399,9 +924,14 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
1399 ct->timeout.expires = extra_jiffies; 924 ct->timeout.expires = extra_jiffies;
1400 event = IPCT_REFRESH; 925 event = IPCT_REFRESH;
1401 } else { 926 } else {
1402 /* Need del_timer for race avoidance (may already be dying). */ 927 unsigned long newtime = jiffies + extra_jiffies;
1403 if (del_timer(&ct->timeout)) { 928
1404 ct->timeout.expires = jiffies + extra_jiffies; 929 /* Only update the timeout if the new timeout is at least
930 HZ jiffies from the old timeout. Need del_timer for race
931 avoidance (may already be dying). */
932 if (newtime - ct->timeout.expires >= HZ
933 && del_timer(&ct->timeout)) {
934 ct->timeout.expires = newtime;
1405 add_timer(&ct->timeout); 935 add_timer(&ct->timeout);
1406 event = IPCT_REFRESH; 936 event = IPCT_REFRESH;
1407 } 937 }
@@ -1412,9 +942,10 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
1412 ct->counters[CTINFO2DIR(ctinfo)].packets++; 942 ct->counters[CTINFO2DIR(ctinfo)].packets++;
1413 ct->counters[CTINFO2DIR(ctinfo)].bytes += 943 ct->counters[CTINFO2DIR(ctinfo)].bytes +=
1414 skb->len - (unsigned int)(skb->nh.raw - skb->data); 944 skb->len - (unsigned int)(skb->nh.raw - skb->data);
1415 if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000) 945
1416 || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000)) 946 if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000)
1417 event |= IPCT_COUNTER_FILLING; 947 || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000))
948 event |= IPCT_COUNTER_FILLING;
1418 } 949 }
1419#endif 950#endif
1420 951
@@ -1424,6 +955,7 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
1424 if (event) 955 if (event)
1425 nf_conntrack_event_cache(event, skb); 956 nf_conntrack_event_cache(event, skb);
1426} 957}
958EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct);
1427 959
1428#if defined(CONFIG_NF_CT_NETLINK) || \ 960#if defined(CONFIG_NF_CT_NETLINK) || \
1429 defined(CONFIG_NF_CT_NETLINK_MODULE) 961 defined(CONFIG_NF_CT_NETLINK_MODULE)
@@ -1448,6 +980,7 @@ int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb,
1448nfattr_failure: 980nfattr_failure:
1449 return -1; 981 return -1;
1450} 982}
983EXPORT_SYMBOL_GPL(nf_ct_port_tuple_to_nfattr);
1451 984
1452static const size_t cta_min_proto[CTA_PROTO_MAX] = { 985static const size_t cta_min_proto[CTA_PROTO_MAX] = {
1453 [CTA_PROTO_SRC_PORT-1] = sizeof(u_int16_t), 986 [CTA_PROTO_SRC_PORT-1] = sizeof(u_int16_t),
@@ -1463,13 +996,12 @@ int nf_ct_port_nfattr_to_tuple(struct nfattr *tb[],
1463 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) 996 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
1464 return -EINVAL; 997 return -EINVAL;
1465 998
1466 t->src.u.tcp.port = 999 t->src.u.tcp.port = *(__be16 *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]);
1467 *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]); 1000 t->dst.u.tcp.port = *(__be16 *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]);
1468 t->dst.u.tcp.port =
1469 *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]);
1470 1001
1471 return 0; 1002 return 0;
1472} 1003}
1004EXPORT_SYMBOL_GPL(nf_ct_port_nfattr_to_tuple);
1473#endif 1005#endif
1474 1006
1475/* Used by ipt_REJECT and ip6t_REJECT. */ 1007/* Used by ipt_REJECT and ip6t_REJECT. */
@@ -1490,6 +1022,7 @@ void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb)
1490 nskb->nfctinfo = ctinfo; 1022 nskb->nfctinfo = ctinfo;
1491 nf_conntrack_get(nskb->nfct); 1023 nf_conntrack_get(nskb->nfct);
1492} 1024}
1025EXPORT_SYMBOL_GPL(__nf_conntrack_attach);
1493 1026
1494static inline int 1027static inline int
1495do_iter(const struct nf_conntrack_tuple_hash *i, 1028do_iter(const struct nf_conntrack_tuple_hash *i,
@@ -1543,6 +1076,7 @@ nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data)
1543 nf_ct_put(ct); 1076 nf_ct_put(ct);
1544 } 1077 }
1545} 1078}
1079EXPORT_SYMBOL_GPL(nf_ct_iterate_cleanup);
1546 1080
1547static int kill_all(struct nf_conn *i, void *data) 1081static int kill_all(struct nf_conn *i, void *data)
1548{ 1082{
@@ -1562,6 +1096,7 @@ void nf_conntrack_flush()
1562{ 1096{
1563 nf_ct_iterate_cleanup(kill_all, NULL); 1097 nf_ct_iterate_cleanup(kill_all, NULL);
1564} 1098}
1099EXPORT_SYMBOL_GPL(nf_conntrack_flush);
1565 1100
1566/* Mishearing the voices in his head, our hero wonders how he's 1101/* Mishearing the voices in his head, our hero wonders how he's
1567 supposed to kill the mall. */ 1102 supposed to kill the mall. */
@@ -1599,6 +1134,8 @@ void nf_conntrack_cleanup(void)
1599 free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc, 1134 free_conntrack_hash(nf_conntrack_hash, nf_conntrack_vmalloc,
1600 nf_conntrack_htable_size); 1135 nf_conntrack_htable_size);
1601 1136
1137 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_generic);
1138
1602 /* free l3proto protocol tables */ 1139 /* free l3proto protocol tables */
1603 for (i = 0; i < PF_MAX; i++) 1140 for (i = 0; i < PF_MAX; i++)
1604 if (nf_ct_protos[i]) { 1141 if (nf_ct_protos[i]) {
@@ -1724,10 +1261,14 @@ int __init nf_conntrack_init(void)
1724 goto err_free_conntrack_slab; 1261 goto err_free_conntrack_slab;
1725 } 1262 }
1726 1263
1264 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_generic);
1265 if (ret < 0)
1266 goto out_free_expect_slab;
1267
1727 /* Don't NEED lock here, but good form anyway. */ 1268 /* Don't NEED lock here, but good form anyway. */
1728 write_lock_bh(&nf_conntrack_lock); 1269 write_lock_bh(&nf_conntrack_lock);
1729 for (i = 0; i < PF_MAX; i++) 1270 for (i = 0; i < AF_MAX; i++)
1730 nf_ct_l3protos[i] = &nf_conntrack_generic_l3proto; 1271 nf_ct_l3protos[i] = &nf_conntrack_l3proto_generic;
1731 write_unlock_bh(&nf_conntrack_lock); 1272 write_unlock_bh(&nf_conntrack_lock);
1732 1273
1733 /* For use by REJECT target */ 1274 /* For use by REJECT target */
@@ -1741,6 +1282,8 @@ int __init nf_conntrack_init(void)
1741 1282
1742 return ret; 1283 return ret;
1743 1284
1285out_free_expect_slab:
1286 kmem_cache_destroy(nf_conntrack_expect_cachep);
1744err_free_conntrack_slab: 1287err_free_conntrack_slab:
1745 nf_conntrack_unregister_cache(NF_CT_F_BASIC); 1288 nf_conntrack_unregister_cache(NF_CT_F_BASIC);
1746err_free_hash: 1289err_free_hash:
diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
new file mode 100644
index 000000000000..1a223e0c0856
--- /dev/null
+++ b/net/netfilter/nf_conntrack_ecache.c
@@ -0,0 +1,93 @@
1/* Event cache for netfilter. */
2
3/* (C) 1999-2001 Paul `Rusty' Russell
4 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
5 * (C) 2003,2004 USAGI/WIDE Project <http://www.linux-ipv6.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 version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/types.h>
13#include <linux/netfilter.h>
14#include <linux/skbuff.h>
15#include <linux/vmalloc.h>
16#include <linux/stddef.h>
17#include <linux/err.h>
18#include <linux/percpu.h>
19#include <linux/notifier.h>
20#include <linux/kernel.h>
21#include <linux/netdevice.h>
22
23#include <net/netfilter/nf_conntrack.h>
24#include <net/netfilter/nf_conntrack_core.h>
25
26ATOMIC_NOTIFIER_HEAD(nf_conntrack_chain);
27EXPORT_SYMBOL_GPL(nf_conntrack_chain);
28
29ATOMIC_NOTIFIER_HEAD(nf_conntrack_expect_chain);
30EXPORT_SYMBOL_GPL(nf_conntrack_expect_chain);
31
32DEFINE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache);
33EXPORT_PER_CPU_SYMBOL_GPL(nf_conntrack_ecache);
34
35/* deliver cached events and clear cache entry - must be called with locally
36 * disabled softirqs */
37static inline void
38__nf_ct_deliver_cached_events(struct nf_conntrack_ecache *ecache)
39{
40 if (nf_ct_is_confirmed(ecache->ct) && !nf_ct_is_dying(ecache->ct)
41 && ecache->events)
42 atomic_notifier_call_chain(&nf_conntrack_chain, ecache->events,
43 ecache->ct);
44
45 ecache->events = 0;
46 nf_ct_put(ecache->ct);
47 ecache->ct = NULL;
48}
49
50/* Deliver all cached events for a particular conntrack. This is called
51 * by code prior to async packet handling for freeing the skb */
52void nf_ct_deliver_cached_events(const struct nf_conn *ct)
53{
54 struct nf_conntrack_ecache *ecache;
55
56 local_bh_disable();
57 ecache = &__get_cpu_var(nf_conntrack_ecache);
58 if (ecache->ct == ct)
59 __nf_ct_deliver_cached_events(ecache);
60 local_bh_enable();
61}
62EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events);
63
64/* Deliver cached events for old pending events, if current conntrack != old */
65void __nf_ct_event_cache_init(struct nf_conn *ct)
66{
67 struct nf_conntrack_ecache *ecache;
68
69 /* take care of delivering potentially old events */
70 ecache = &__get_cpu_var(nf_conntrack_ecache);
71 BUG_ON(ecache->ct == ct);
72 if (ecache->ct)
73 __nf_ct_deliver_cached_events(ecache);
74 /* initialize for this conntrack/packet */
75 ecache->ct = ct;
76 nf_conntrack_get(&ct->ct_general);
77}
78EXPORT_SYMBOL_GPL(__nf_ct_event_cache_init);
79
80/* flush the event cache - touches other CPU's data and must not be called
81 * while packets are still passing through the code */
82void nf_ct_event_cache_flush(void)
83{
84 struct nf_conntrack_ecache *ecache;
85 int cpu;
86
87 for_each_possible_cpu(cpu) {
88 ecache = &per_cpu(nf_conntrack_ecache, cpu);
89 if (ecache->ct)
90 nf_ct_put(ecache->ct);
91 }
92}
93
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
new file mode 100644
index 000000000000..588d37937046
--- /dev/null
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -0,0 +1,442 @@
1/* Expectation handling for nf_conntrack. */
2
3/* (C) 1999-2001 Paul `Rusty' Russell
4 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
5 * (C) 2003,2004 USAGI/WIDE Project <http://www.linux-ipv6.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 version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/types.h>
13#include <linux/netfilter.h>
14#include <linux/skbuff.h>
15#include <linux/proc_fs.h>
16#include <linux/seq_file.h>
17#include <linux/stddef.h>
18#include <linux/slab.h>
19#include <linux/err.h>
20#include <linux/percpu.h>
21#include <linux/kernel.h>
22
23#include <net/netfilter/nf_conntrack.h>
24#include <net/netfilter/nf_conntrack_core.h>
25#include <net/netfilter/nf_conntrack_expect.h>
26#include <net/netfilter/nf_conntrack_helper.h>
27#include <net/netfilter/nf_conntrack_tuple.h>
28
29LIST_HEAD(nf_conntrack_expect_list);
30EXPORT_SYMBOL_GPL(nf_conntrack_expect_list);
31
32kmem_cache_t *nf_conntrack_expect_cachep __read_mostly;
33static unsigned int nf_conntrack_expect_next_id;
34
35/* nf_conntrack_expect helper functions */
36void nf_ct_unlink_expect(struct nf_conntrack_expect *exp)
37{
38 struct nf_conn_help *master_help = nfct_help(exp->master);
39
40 NF_CT_ASSERT(master_help);
41 NF_CT_ASSERT(!timer_pending(&exp->timeout));
42
43 list_del(&exp->list);
44 NF_CT_STAT_INC(expect_delete);
45 master_help->expecting--;
46 nf_conntrack_expect_put(exp);
47}
48EXPORT_SYMBOL_GPL(nf_ct_unlink_expect);
49
50static void expectation_timed_out(unsigned long ul_expect)
51{
52 struct nf_conntrack_expect *exp = (void *)ul_expect;
53
54 write_lock_bh(&nf_conntrack_lock);
55 nf_ct_unlink_expect(exp);
56 write_unlock_bh(&nf_conntrack_lock);
57 nf_conntrack_expect_put(exp);
58}
59
60struct nf_conntrack_expect *
61__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple)
62{
63 struct nf_conntrack_expect *i;
64
65 list_for_each_entry(i, &nf_conntrack_expect_list, list) {
66 if (nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask))
67 return i;
68 }
69 return NULL;
70}
71EXPORT_SYMBOL_GPL(__nf_conntrack_expect_find);
72
73/* Just find a expectation corresponding to a tuple. */
74struct nf_conntrack_expect *
75nf_conntrack_expect_find_get(const struct nf_conntrack_tuple *tuple)
76{
77 struct nf_conntrack_expect *i;
78
79 read_lock_bh(&nf_conntrack_lock);
80 i = __nf_conntrack_expect_find(tuple);
81 if (i)
82 atomic_inc(&i->use);
83 read_unlock_bh(&nf_conntrack_lock);
84
85 return i;
86}
87EXPORT_SYMBOL_GPL(nf_conntrack_expect_find_get);
88
89/* If an expectation for this connection is found, it gets delete from
90 * global list then returned. */
91struct nf_conntrack_expect *
92find_expectation(const struct nf_conntrack_tuple *tuple)
93{
94 struct nf_conntrack_expect *i;
95
96 list_for_each_entry(i, &nf_conntrack_expect_list, list) {
97 /* If master is not in hash table yet (ie. packet hasn't left
98 this machine yet), how can other end know about expected?
99 Hence these are not the droids you are looking for (if
100 master ct never got confirmed, we'd hold a reference to it
101 and weird things would happen to future packets). */
102 if (nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask)
103 && nf_ct_is_confirmed(i->master)) {
104 if (i->flags & NF_CT_EXPECT_PERMANENT) {
105 atomic_inc(&i->use);
106 return i;
107 } else if (del_timer(&i->timeout)) {
108 nf_ct_unlink_expect(i);
109 return i;
110 }
111 }
112 }
113 return NULL;
114}
115
116/* delete all expectations for this conntrack */
117void nf_ct_remove_expectations(struct nf_conn *ct)
118{
119 struct nf_conntrack_expect *i, *tmp;
120 struct nf_conn_help *help = nfct_help(ct);
121
122 /* Optimization: most connection never expect any others. */
123 if (!help || help->expecting == 0)
124 return;
125
126 list_for_each_entry_safe(i, tmp, &nf_conntrack_expect_list, list) {
127 if (i->master == ct && del_timer(&i->timeout)) {
128 nf_ct_unlink_expect(i);
129 nf_conntrack_expect_put(i);
130 }
131 }
132}
133EXPORT_SYMBOL_GPL(nf_ct_remove_expectations);
134
135/* Would two expected things clash? */
136static inline int expect_clash(const struct nf_conntrack_expect *a,
137 const struct nf_conntrack_expect *b)
138{
139 /* Part covered by intersection of masks must be unequal,
140 otherwise they clash */
141 struct nf_conntrack_tuple intersect_mask;
142 int count;
143
144 intersect_mask.src.l3num = a->mask.src.l3num & b->mask.src.l3num;
145 intersect_mask.src.u.all = a->mask.src.u.all & b->mask.src.u.all;
146 intersect_mask.dst.u.all = a->mask.dst.u.all & b->mask.dst.u.all;
147 intersect_mask.dst.protonum = a->mask.dst.protonum
148 & b->mask.dst.protonum;
149
150 for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++){
151 intersect_mask.src.u3.all[count] =
152 a->mask.src.u3.all[count] & b->mask.src.u3.all[count];
153 }
154
155 for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++){
156 intersect_mask.dst.u3.all[count] =
157 a->mask.dst.u3.all[count] & b->mask.dst.u3.all[count];
158 }
159
160 return nf_ct_tuple_mask_cmp(&a->tuple, &b->tuple, &intersect_mask);
161}
162
163static inline int expect_matches(const struct nf_conntrack_expect *a,
164 const struct nf_conntrack_expect *b)
165{
166 return a->master == b->master
167 && nf_ct_tuple_equal(&a->tuple, &b->tuple)
168 && nf_ct_tuple_equal(&a->mask, &b->mask);
169}
170
171/* Generally a bad idea to call this: could have matched already. */
172void nf_conntrack_unexpect_related(struct nf_conntrack_expect *exp)
173{
174 struct nf_conntrack_expect *i;
175
176 write_lock_bh(&nf_conntrack_lock);
177 /* choose the the oldest expectation to evict */
178 list_for_each_entry_reverse(i, &nf_conntrack_expect_list, list) {
179 if (expect_matches(i, exp) && del_timer(&i->timeout)) {
180 nf_ct_unlink_expect(i);
181 write_unlock_bh(&nf_conntrack_lock);
182 nf_conntrack_expect_put(i);
183 return;
184 }
185 }
186 write_unlock_bh(&nf_conntrack_lock);
187}
188EXPORT_SYMBOL_GPL(nf_conntrack_unexpect_related);
189
190/* We don't increase the master conntrack refcount for non-fulfilled
191 * conntracks. During the conntrack destruction, the expectations are
192 * always killed before the conntrack itself */
193struct nf_conntrack_expect *nf_conntrack_expect_alloc(struct nf_conn *me)
194{
195 struct nf_conntrack_expect *new;
196
197 new = kmem_cache_alloc(nf_conntrack_expect_cachep, GFP_ATOMIC);
198 if (!new)
199 return NULL;
200
201 new->master = me;
202 atomic_set(&new->use, 1);
203 return new;
204}
205EXPORT_SYMBOL_GPL(nf_conntrack_expect_alloc);
206
207void nf_conntrack_expect_init(struct nf_conntrack_expect *exp, int family,
208 union nf_conntrack_address *saddr,
209 union nf_conntrack_address *daddr,
210 u_int8_t proto, __be16 *src, __be16 *dst)
211{
212 int len;
213
214 if (family == AF_INET)
215 len = 4;
216 else
217 len = 16;
218
219 exp->flags = 0;
220 exp->expectfn = NULL;
221 exp->helper = NULL;
222 exp->tuple.src.l3num = family;
223 exp->tuple.dst.protonum = proto;
224 exp->mask.src.l3num = 0xFFFF;
225 exp->mask.dst.protonum = 0xFF;
226
227 if (saddr) {
228 memcpy(&exp->tuple.src.u3, saddr, len);
229 if (sizeof(exp->tuple.src.u3) > len)
230 /* address needs to be cleared for nf_ct_tuple_equal */
231 memset((void *)&exp->tuple.src.u3 + len, 0x00,
232 sizeof(exp->tuple.src.u3) - len);
233 memset(&exp->mask.src.u3, 0xFF, len);
234 if (sizeof(exp->mask.src.u3) > len)
235 memset((void *)&exp->mask.src.u3 + len, 0x00,
236 sizeof(exp->mask.src.u3) - len);
237 } else {
238 memset(&exp->tuple.src.u3, 0x00, sizeof(exp->tuple.src.u3));
239 memset(&exp->mask.src.u3, 0x00, sizeof(exp->mask.src.u3));
240 }
241
242 if (daddr) {
243 memcpy(&exp->tuple.dst.u3, daddr, len);
244 if (sizeof(exp->tuple.dst.u3) > len)
245 /* address needs to be cleared for nf_ct_tuple_equal */
246 memset((void *)&exp->tuple.dst.u3 + len, 0x00,
247 sizeof(exp->tuple.dst.u3) - len);
248 memset(&exp->mask.dst.u3, 0xFF, len);
249 if (sizeof(exp->mask.dst.u3) > len)
250 memset((void *)&exp->mask.dst.u3 + len, 0x00,
251 sizeof(exp->mask.dst.u3) - len);
252 } else {
253 memset(&exp->tuple.dst.u3, 0x00, sizeof(exp->tuple.dst.u3));
254 memset(&exp->mask.dst.u3, 0x00, sizeof(exp->mask.dst.u3));
255 }
256
257 if (src) {
258 exp->tuple.src.u.all = (__force u16)*src;
259 exp->mask.src.u.all = 0xFFFF;
260 } else {
261 exp->tuple.src.u.all = 0;
262 exp->mask.src.u.all = 0;
263 }
264
265 if (dst) {
266 exp->tuple.dst.u.all = (__force u16)*dst;
267 exp->mask.dst.u.all = 0xFFFF;
268 } else {
269 exp->tuple.dst.u.all = 0;
270 exp->mask.dst.u.all = 0;
271 }
272}
273EXPORT_SYMBOL_GPL(nf_conntrack_expect_init);
274
275void nf_conntrack_expect_put(struct nf_conntrack_expect *exp)
276{
277 if (atomic_dec_and_test(&exp->use))
278 kmem_cache_free(nf_conntrack_expect_cachep, exp);
279}
280EXPORT_SYMBOL_GPL(nf_conntrack_expect_put);
281
282static void nf_conntrack_expect_insert(struct nf_conntrack_expect *exp)
283{
284 struct nf_conn_help *master_help = nfct_help(exp->master);
285
286 atomic_inc(&exp->use);
287 master_help->expecting++;
288 list_add(&exp->list, &nf_conntrack_expect_list);
289
290 init_timer(&exp->timeout);
291 exp->timeout.data = (unsigned long)exp;
292 exp->timeout.function = expectation_timed_out;
293 exp->timeout.expires = jiffies + master_help->helper->timeout * HZ;
294 add_timer(&exp->timeout);
295
296 exp->id = ++nf_conntrack_expect_next_id;
297 atomic_inc(&exp->use);
298 NF_CT_STAT_INC(expect_create);
299}
300
301/* Race with expectations being used means we could have none to find; OK. */
302static void evict_oldest_expect(struct nf_conn *master)
303{
304 struct nf_conntrack_expect *i;
305
306 list_for_each_entry_reverse(i, &nf_conntrack_expect_list, list) {
307 if (i->master == master) {
308 if (del_timer(&i->timeout)) {
309 nf_ct_unlink_expect(i);
310 nf_conntrack_expect_put(i);
311 }
312 break;
313 }
314 }
315}
316
317static inline int refresh_timer(struct nf_conntrack_expect *i)
318{
319 struct nf_conn_help *master_help = nfct_help(i->master);
320
321 if (!del_timer(&i->timeout))
322 return 0;
323
324 i->timeout.expires = jiffies + master_help->helper->timeout*HZ;
325 add_timer(&i->timeout);
326 return 1;
327}
328
329int nf_conntrack_expect_related(struct nf_conntrack_expect *expect)
330{
331 struct nf_conntrack_expect *i;
332 struct nf_conn *master = expect->master;
333 struct nf_conn_help *master_help = nfct_help(master);
334 int ret;
335
336 NF_CT_ASSERT(master_help);
337
338 write_lock_bh(&nf_conntrack_lock);
339 list_for_each_entry(i, &nf_conntrack_expect_list, list) {
340 if (expect_matches(i, expect)) {
341 /* Refresh timer: if it's dying, ignore.. */
342 if (refresh_timer(i)) {
343 ret = 0;
344 goto out;
345 }
346 } else if (expect_clash(i, expect)) {
347 ret = -EBUSY;
348 goto out;
349 }
350 }
351 /* Will be over limit? */
352 if (master_help->helper->max_expected &&
353 master_help->expecting >= master_help->helper->max_expected)
354 evict_oldest_expect(master);
355
356 nf_conntrack_expect_insert(expect);
357 nf_conntrack_expect_event(IPEXP_NEW, expect);
358 ret = 0;
359out:
360 write_unlock_bh(&nf_conntrack_lock);
361 return ret;
362}
363EXPORT_SYMBOL_GPL(nf_conntrack_expect_related);
364
365#ifdef CONFIG_PROC_FS
366static void *exp_seq_start(struct seq_file *s, loff_t *pos)
367{
368 struct list_head *e = &nf_conntrack_expect_list;
369 loff_t i;
370
371 /* strange seq_file api calls stop even if we fail,
372 * thus we need to grab lock since stop unlocks */
373 read_lock_bh(&nf_conntrack_lock);
374
375 if (list_empty(e))
376 return NULL;
377
378 for (i = 0; i <= *pos; i++) {
379 e = e->next;
380 if (e == &nf_conntrack_expect_list)
381 return NULL;
382 }
383 return e;
384}
385
386static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
387{
388 struct list_head *e = v;
389
390 ++*pos;
391 e = e->next;
392
393 if (e == &nf_conntrack_expect_list)
394 return NULL;
395
396 return e;
397}
398
399static void exp_seq_stop(struct seq_file *s, void *v)
400{
401 read_unlock_bh(&nf_conntrack_lock);
402}
403
404static int exp_seq_show(struct seq_file *s, void *v)
405{
406 struct nf_conntrack_expect *expect = v;
407
408 if (expect->timeout.function)
409 seq_printf(s, "%ld ", timer_pending(&expect->timeout)
410 ? (long)(expect->timeout.expires - jiffies)/HZ : 0);
411 else
412 seq_printf(s, "- ");
413 seq_printf(s, "l3proto = %u proto=%u ",
414 expect->tuple.src.l3num,
415 expect->tuple.dst.protonum);
416 print_tuple(s, &expect->tuple,
417 __nf_ct_l3proto_find(expect->tuple.src.l3num),
418 __nf_ct_l4proto_find(expect->tuple.src.l3num,
419 expect->tuple.dst.protonum));
420 return seq_putc(s, '\n');
421}
422
423static struct seq_operations exp_seq_ops = {
424 .start = exp_seq_start,
425 .next = exp_seq_next,
426 .stop = exp_seq_stop,
427 .show = exp_seq_show
428};
429
430static int exp_open(struct inode *inode, struct file *file)
431{
432 return seq_open(file, &exp_seq_ops);
433}
434
435struct file_operations exp_file_ops = {
436 .owner = THIS_MODULE,
437 .open = exp_open,
438 .read = seq_read,
439 .llseek = seq_lseek,
440 .release = seq_release
441};
442#endif /* CONFIG_PROC_FS */
diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
index 0c17a5bd112b..92a947168761 100644
--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -26,12 +26,15 @@
26#include <net/tcp.h> 26#include <net/tcp.h>
27 27
28#include <net/netfilter/nf_conntrack.h> 28#include <net/netfilter/nf_conntrack.h>
29#include <net/netfilter/nf_conntrack_expect.h>
30#include <net/netfilter/nf_conntrack_ecache.h>
29#include <net/netfilter/nf_conntrack_helper.h> 31#include <net/netfilter/nf_conntrack_helper.h>
30#include <linux/netfilter/nf_conntrack_ftp.h> 32#include <linux/netfilter/nf_conntrack_ftp.h>
31 33
32MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
33MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>"); 35MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
34MODULE_DESCRIPTION("ftp connection tracking helper"); 36MODULE_DESCRIPTION("ftp connection tracking helper");
37MODULE_ALIAS("ip_conntrack_ftp");
35 38
36/* This is slow, but it's simple. --RR */ 39/* This is slow, but it's simple. --RR */
37static char *ftp_buffer; 40static char *ftp_buffer;
@@ -48,7 +51,7 @@ module_param(loose, bool, 0600);
48 51
49unsigned int (*nf_nat_ftp_hook)(struct sk_buff **pskb, 52unsigned int (*nf_nat_ftp_hook)(struct sk_buff **pskb,
50 enum ip_conntrack_info ctinfo, 53 enum ip_conntrack_info ctinfo,
51 enum ip_ct_ftp_type type, 54 enum nf_ct_ftp_type type,
52 unsigned int matchoff, 55 unsigned int matchoff,
53 unsigned int matchlen, 56 unsigned int matchlen,
54 struct nf_conntrack_expect *exp, 57 struct nf_conntrack_expect *exp,
@@ -71,7 +74,7 @@ static struct ftp_search {
71 size_t plen; 74 size_t plen;
72 char skip; 75 char skip;
73 char term; 76 char term;
74 enum ip_ct_ftp_type ftptype; 77 enum nf_ct_ftp_type ftptype;
75 int (*getnum)(const char *, size_t, struct nf_conntrack_man *, char); 78 int (*getnum)(const char *, size_t, struct nf_conntrack_man *, char);
76} search[IP_CT_DIR_MAX][2] = { 79} search[IP_CT_DIR_MAX][2] = {
77 [IP_CT_DIR_ORIGINAL] = { 80 [IP_CT_DIR_ORIGINAL] = {
@@ -80,7 +83,7 @@ static struct ftp_search {
80 .plen = sizeof("PORT") - 1, 83 .plen = sizeof("PORT") - 1,
81 .skip = ' ', 84 .skip = ' ',
82 .term = '\r', 85 .term = '\r',
83 .ftptype = IP_CT_FTP_PORT, 86 .ftptype = NF_CT_FTP_PORT,
84 .getnum = try_rfc959, 87 .getnum = try_rfc959,
85 }, 88 },
86 { 89 {
@@ -88,7 +91,7 @@ static struct ftp_search {
88 .plen = sizeof("EPRT") - 1, 91 .plen = sizeof("EPRT") - 1,
89 .skip = ' ', 92 .skip = ' ',
90 .term = '\r', 93 .term = '\r',
91 .ftptype = IP_CT_FTP_EPRT, 94 .ftptype = NF_CT_FTP_EPRT,
92 .getnum = try_eprt, 95 .getnum = try_eprt,
93 }, 96 },
94 }, 97 },
@@ -98,7 +101,7 @@ static struct ftp_search {
98 .plen = sizeof("227 ") - 1, 101 .plen = sizeof("227 ") - 1,
99 .skip = '(', 102 .skip = '(',
100 .term = ')', 103 .term = ')',
101 .ftptype = IP_CT_FTP_PASV, 104 .ftptype = NF_CT_FTP_PASV,
102 .getnum = try_rfc959, 105 .getnum = try_rfc959,
103 }, 106 },
104 { 107 {
@@ -106,7 +109,7 @@ static struct ftp_search {
106 .plen = sizeof("229 ") - 1, 109 .plen = sizeof("229 ") - 1,
107 .skip = '(', 110 .skip = '(',
108 .term = ')', 111 .term = ')',
109 .ftptype = IP_CT_FTP_EPSV, 112 .ftptype = NF_CT_FTP_EPSV,
110 .getnum = try_epsv_response, 113 .getnum = try_epsv_response,
111 }, 114 },
112 }, 115 },
@@ -171,7 +174,7 @@ static int try_rfc959(const char *data, size_t dlen,
171 174
172/* Grab port: number up to delimiter */ 175/* Grab port: number up to delimiter */
173static int get_port(const char *data, int start, size_t dlen, char delim, 176static int get_port(const char *data, int start, size_t dlen, char delim,
174 u_int16_t *port) 177 __be16 *port)
175{ 178{
176 u_int16_t tmp_port = 0; 179 u_int16_t tmp_port = 0;
177 int i; 180 int i;
@@ -317,7 +320,7 @@ static int find_pattern(const char *data, size_t dlen,
317} 320}
318 321
319/* Look up to see if we're just after a \n. */ 322/* Look up to see if we're just after a \n. */
320static int find_nl_seq(u32 seq, const struct ip_ct_ftp_master *info, int dir) 323static int find_nl_seq(u32 seq, const struct nf_ct_ftp_master *info, int dir)
321{ 324{
322 unsigned int i; 325 unsigned int i;
323 326
@@ -328,7 +331,7 @@ static int find_nl_seq(u32 seq, const struct ip_ct_ftp_master *info, int dir)
328} 331}
329 332
330/* We don't update if it's older than what we have. */ 333/* We don't update if it's older than what we have. */
331static void update_nl_seq(u32 nl_seq, struct ip_ct_ftp_master *info, int dir, 334static void update_nl_seq(u32 nl_seq, struct nf_ct_ftp_master *info, int dir,
332 struct sk_buff *skb) 335 struct sk_buff *skb)
333{ 336{
334 unsigned int i, oldest = NUM_SEQ_TO_REMEMBER; 337 unsigned int i, oldest = NUM_SEQ_TO_REMEMBER;
@@ -364,12 +367,12 @@ static int help(struct sk_buff **pskb,
364 u32 seq; 367 u32 seq;
365 int dir = CTINFO2DIR(ctinfo); 368 int dir = CTINFO2DIR(ctinfo);
366 unsigned int matchlen, matchoff; 369 unsigned int matchlen, matchoff;
367 struct ip_ct_ftp_master *ct_ftp_info = &nfct_help(ct)->help.ct_ftp_info; 370 struct nf_ct_ftp_master *ct_ftp_info = &nfct_help(ct)->help.ct_ftp_info;
368 struct nf_conntrack_expect *exp; 371 struct nf_conntrack_expect *exp;
369 struct nf_conntrack_man cmd = {}; 372 struct nf_conntrack_man cmd = {};
370
371 unsigned int i; 373 unsigned int i;
372 int found = 0, ends_in_nl; 374 int found = 0, ends_in_nl;
375 typeof(nf_nat_ftp_hook) nf_nat_ftp;
373 376
374 /* Until there's been traffic both ways, don't look in packets. */ 377 /* Until there's been traffic both ways, don't look in packets. */
375 if (ctinfo != IP_CT_ESTABLISHED 378 if (ctinfo != IP_CT_ESTABLISHED
@@ -500,12 +503,12 @@ static int help(struct sk_buff **pskb,
500 .u = { .tcp = { 0 }}, 503 .u = { .tcp = { 0 }},
501 }, 504 },
502 .dst = { .protonum = 0xFF, 505 .dst = { .protonum = 0xFF,
503 .u = { .tcp = { 0xFFFF }}, 506 .u = { .tcp = { __constant_htons(0xFFFF) }},
504 }, 507 },
505 }; 508 };
506 if (cmd.l3num == PF_INET) { 509 if (cmd.l3num == PF_INET) {
507 exp->mask.src.u3.ip = 0xFFFFFFFF; 510 exp->mask.src.u3.ip = htonl(0xFFFFFFFF);
508 exp->mask.dst.u3.ip = 0xFFFFFFFF; 511 exp->mask.dst.u3.ip = htonl(0xFFFFFFFF);
509 } else { 512 } else {
510 memset(exp->mask.src.u3.ip6, 0xFF, 513 memset(exp->mask.src.u3.ip6, 0xFF,
511 sizeof(exp->mask.src.u3.ip6)); 514 sizeof(exp->mask.src.u3.ip6));
@@ -514,13 +517,15 @@ static int help(struct sk_buff **pskb,
514 } 517 }
515 518
516 exp->expectfn = NULL; 519 exp->expectfn = NULL;
520 exp->helper = NULL;
517 exp->flags = 0; 521 exp->flags = 0;
518 522
519 /* Now, NAT might want to mangle the packet, and register the 523 /* Now, NAT might want to mangle the packet, and register the
520 * (possibly changed) expectation itself. */ 524 * (possibly changed) expectation itself. */
521 if (nf_nat_ftp_hook) 525 nf_nat_ftp = rcu_dereference(nf_nat_ftp_hook);
522 ret = nf_nat_ftp_hook(pskb, ctinfo, search[dir][i].ftptype, 526 if (nf_nat_ftp && ct->status & IPS_NAT_MASK)
523 matchoff, matchlen, exp, &seq); 527 ret = nf_nat_ftp(pskb, ctinfo, search[dir][i].ftptype,
528 matchoff, matchlen, exp, &seq);
524 else { 529 else {
525 /* Can't expect this? Best to drop packet now. */ 530 /* Can't expect this? Best to drop packet now. */
526 if (nf_conntrack_expect_related(exp) != 0) 531 if (nf_conntrack_expect_related(exp) != 0)
@@ -584,7 +589,8 @@ static int __init nf_conntrack_ftp_init(void)
584 for (j = 0; j < 2; j++) { 589 for (j = 0; j < 2; j++) {
585 ftp[i][j].tuple.src.u.tcp.port = htons(ports[i]); 590 ftp[i][j].tuple.src.u.tcp.port = htons(ports[i]);
586 ftp[i][j].tuple.dst.protonum = IPPROTO_TCP; 591 ftp[i][j].tuple.dst.protonum = IPPROTO_TCP;
587 ftp[i][j].mask.src.u.tcp.port = 0xFFFF; 592 ftp[i][j].mask.src.l3num = 0xFFFF;
593 ftp[i][j].mask.src.u.tcp.port = htons(0xFFFF);
588 ftp[i][j].mask.dst.protonum = 0xFF; 594 ftp[i][j].mask.dst.protonum = 0xFF;
589 ftp[i][j].max_expected = 1; 595 ftp[i][j].max_expected = 1;
590 ftp[i][j].timeout = 5 * 60; /* 5 Minutes */ 596 ftp[i][j].timeout = 5 * 60; /* 5 Minutes */
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c b/net/netfilter/nf_conntrack_h323_asn1.c
index 26dfecadb335..f6fad713d484 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323_asn1.c
+++ b/net/netfilter/nf_conntrack_h323_asn1.c
@@ -15,7 +15,7 @@
15#else 15#else
16#include <stdio.h> 16#include <stdio.h>
17#endif 17#endif
18#include <linux/netfilter_ipv4/ip_conntrack_helper_h323_asn1.h> 18#include <linux/netfilter/nf_conntrack_h323_asn1.h>
19 19
20/* Trace Flag */ 20/* Trace Flag */
21#ifndef H323_TRACE 21#ifndef H323_TRACE
@@ -144,7 +144,7 @@ static decoder_t Decoders[] = {
144/**************************************************************************** 144/****************************************************************************
145 * H.323 Types 145 * H.323 Types
146 ****************************************************************************/ 146 ****************************************************************************/
147#include "ip_conntrack_helper_h323_types.c" 147#include "nf_conntrack_h323_types.c"
148 148
149/**************************************************************************** 149/****************************************************************************
150 * Functions 150 * Functions
diff --git a/net/netfilter/nf_conntrack_h323_main.c b/net/netfilter/nf_conntrack_h323_main.c
new file mode 100644
index 000000000000..6d8568959f82
--- /dev/null
+++ b/net/netfilter/nf_conntrack_h323_main.c
@@ -0,0 +1,1856 @@
1/*
2 * H.323 connection tracking helper
3 *
4 * Copyright (c) 2006 Jing Min Zhao <zhaojingmin@users.sourceforge.net>
5 *
6 * This source code is licensed under General Public License version 2.
7 *
8 * Based on the 'brute force' H.323 connection tracking module by
9 * Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
10 *
11 * For more information, please see http://nath323.sourceforge.net/
12 */
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/ctype.h>
17#include <linux/inet.h>
18#include <linux/in.h>
19#include <linux/ip.h>
20#include <linux/udp.h>
21#include <linux/tcp.h>
22#include <linux/skbuff.h>
23#include <net/route.h>
24#include <net/ip6_route.h>
25
26#include <net/netfilter/nf_conntrack.h>
27#include <net/netfilter/nf_conntrack_core.h>
28#include <net/netfilter/nf_conntrack_tuple.h>
29#include <net/netfilter/nf_conntrack_expect.h>
30#include <net/netfilter/nf_conntrack_ecache.h>
31#include <net/netfilter/nf_conntrack_helper.h>
32#include <linux/netfilter/nf_conntrack_h323.h>
33
34#if 0
35#define DEBUGP printk
36#else
37#define DEBUGP(format, args...)
38#endif
39
40/* Parameters */
41static unsigned int default_rrq_ttl __read_mostly = 300;
42module_param(default_rrq_ttl, uint, 0600);
43MODULE_PARM_DESC(default_rrq_ttl, "use this TTL if it's missing in RRQ");
44
45static int gkrouted_only __read_mostly = 1;
46module_param(gkrouted_only, int, 0600);
47MODULE_PARM_DESC(gkrouted_only, "only accept calls from gatekeeper");
48
49static int callforward_filter __read_mostly = 1;
50module_param(callforward_filter, bool, 0600);
51MODULE_PARM_DESC(callforward_filter, "only create call forwarding expectations "
52 "if both endpoints are on different sides "
53 "(determined by routing information)");
54
55/* Hooks for NAT */
56int (*set_h245_addr_hook) (struct sk_buff **pskb,
57 unsigned char **data, int dataoff,
58 H245_TransportAddress *taddr,
59 union nf_conntrack_address *addr, __be16 port)
60 __read_mostly;
61int (*set_h225_addr_hook) (struct sk_buff **pskb,
62 unsigned char **data, int dataoff,
63 TransportAddress *taddr,
64 union nf_conntrack_address *addr, __be16 port)
65 __read_mostly;
66int (*set_sig_addr_hook) (struct sk_buff **pskb,
67 struct nf_conn *ct,
68 enum ip_conntrack_info ctinfo,
69 unsigned char **data,
70 TransportAddress *taddr, int count) __read_mostly;
71int (*set_ras_addr_hook) (struct sk_buff **pskb,
72 struct nf_conn *ct,
73 enum ip_conntrack_info ctinfo,
74 unsigned char **data,
75 TransportAddress *taddr, int count) __read_mostly;
76int (*nat_rtp_rtcp_hook) (struct sk_buff **pskb,
77 struct nf_conn *ct,
78 enum ip_conntrack_info ctinfo,
79 unsigned char **data, int dataoff,
80 H245_TransportAddress *taddr,
81 __be16 port, __be16 rtp_port,
82 struct nf_conntrack_expect *rtp_exp,
83 struct nf_conntrack_expect *rtcp_exp) __read_mostly;
84int (*nat_t120_hook) (struct sk_buff **pskb,
85 struct nf_conn *ct,
86 enum ip_conntrack_info ctinfo,
87 unsigned char **data, int dataoff,
88 H245_TransportAddress *taddr, __be16 port,
89 struct nf_conntrack_expect *exp) __read_mostly;
90int (*nat_h245_hook) (struct sk_buff **pskb,
91 struct nf_conn *ct,
92 enum ip_conntrack_info ctinfo,
93 unsigned char **data, int dataoff,
94 TransportAddress *taddr, __be16 port,
95 struct nf_conntrack_expect *exp) __read_mostly;
96int (*nat_callforwarding_hook) (struct sk_buff **pskb,
97 struct nf_conn *ct,
98 enum ip_conntrack_info ctinfo,
99 unsigned char **data, int dataoff,
100 TransportAddress *taddr, __be16 port,
101 struct nf_conntrack_expect *exp) __read_mostly;
102int (*nat_q931_hook) (struct sk_buff **pskb,
103 struct nf_conn *ct,
104 enum ip_conntrack_info ctinfo,
105 unsigned char **data, TransportAddress *taddr, int idx,
106 __be16 port, struct nf_conntrack_expect *exp)
107 __read_mostly;
108
109static DEFINE_SPINLOCK(nf_h323_lock);
110static char *h323_buffer;
111
112static struct nf_conntrack_helper nf_conntrack_helper_h245;
113static struct nf_conntrack_helper nf_conntrack_helper_q931[];
114static struct nf_conntrack_helper nf_conntrack_helper_ras[];
115
116/****************************************************************************/
117static int get_tpkt_data(struct sk_buff **pskb, unsigned int protoff,
118 struct nf_conn *ct, enum ip_conntrack_info ctinfo,
119 unsigned char **data, int *datalen, int *dataoff)
120{
121 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
122 int dir = CTINFO2DIR(ctinfo);
123 struct tcphdr _tcph, *th;
124 int tcpdatalen;
125 int tcpdataoff;
126 unsigned char *tpkt;
127 int tpktlen;
128 int tpktoff;
129
130 /* Get TCP header */
131 th = skb_header_pointer(*pskb, protoff, sizeof(_tcph), &_tcph);
132 if (th == NULL)
133 return 0;
134
135 /* Get TCP data offset */
136 tcpdataoff = protoff + th->doff * 4;
137
138 /* Get TCP data length */
139 tcpdatalen = (*pskb)->len - tcpdataoff;
140 if (tcpdatalen <= 0) /* No TCP data */
141 goto clear_out;
142
143 if (*data == NULL) { /* first TPKT */
144 /* Get first TPKT pointer */
145 tpkt = skb_header_pointer(*pskb, tcpdataoff, tcpdatalen,
146 h323_buffer);
147 BUG_ON(tpkt == NULL);
148
149 /* Validate TPKT identifier */
150 if (tcpdatalen < 4 || tpkt[0] != 0x03 || tpkt[1] != 0) {
151 /* Netmeeting sends TPKT header and data separately */
152 if (info->tpkt_len[dir] > 0) {
153 DEBUGP("nf_ct_h323: previous packet "
154 "indicated separate TPKT data of %hu "
155 "bytes\n", info->tpkt_len[dir]);
156 if (info->tpkt_len[dir] <= tcpdatalen) {
157 /* Yes, there was a TPKT header
158 * received */
159 *data = tpkt;
160 *datalen = info->tpkt_len[dir];
161 *dataoff = 0;
162 goto out;
163 }
164
165 /* Fragmented TPKT */
166 if (net_ratelimit())
167 printk("nf_ct_h323: "
168 "fragmented TPKT\n");
169 goto clear_out;
170 }
171
172 /* It is not even a TPKT */
173 return 0;
174 }
175 tpktoff = 0;
176 } else { /* Next TPKT */
177 tpktoff = *dataoff + *datalen;
178 tcpdatalen -= tpktoff;
179 if (tcpdatalen <= 4) /* No more TPKT */
180 goto clear_out;
181 tpkt = *data + *datalen;
182
183 /* Validate TPKT identifier */
184 if (tpkt[0] != 0x03 || tpkt[1] != 0)
185 goto clear_out;
186 }
187
188 /* Validate TPKT length */
189 tpktlen = tpkt[2] * 256 + tpkt[3];
190 if (tpktlen < 4)
191 goto clear_out;
192 if (tpktlen > tcpdatalen) {
193 if (tcpdatalen == 4) { /* Separate TPKT header */
194 /* Netmeeting sends TPKT header and data separately */
195 DEBUGP("nf_ct_h323: separate TPKT header indicates "
196 "there will be TPKT data of %hu bytes\n",
197 tpktlen - 4);
198 info->tpkt_len[dir] = tpktlen - 4;
199 return 0;
200 }
201
202 if (net_ratelimit())
203 printk("nf_ct_h323: incomplete TPKT (fragmented?)\n");
204 goto clear_out;
205 }
206
207 /* This is the encapsulated data */
208 *data = tpkt + 4;
209 *datalen = tpktlen - 4;
210 *dataoff = tpktoff + 4;
211
212 out:
213 /* Clear TPKT length */
214 info->tpkt_len[dir] = 0;
215 return 1;
216
217 clear_out:
218 info->tpkt_len[dir] = 0;
219 return 0;
220}
221
222/****************************************************************************/
223static int get_h245_addr(struct nf_conn *ct, unsigned char *data,
224 H245_TransportAddress *taddr,
225 union nf_conntrack_address *addr, __be16 *port)
226{
227 unsigned char *p;
228 int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
229 int len;
230
231 if (taddr->choice != eH245_TransportAddress_unicastAddress)
232 return 0;
233
234 switch (taddr->unicastAddress.choice) {
235 case eUnicastAddress_iPAddress:
236 if (family != AF_INET)
237 return 0;
238 p = data + taddr->unicastAddress.iPAddress.network;
239 len = 4;
240 break;
241 case eUnicastAddress_iP6Address:
242 if (family != AF_INET6)
243 return 0;
244 p = data + taddr->unicastAddress.iP6Address.network;
245 len = 16;
246 break;
247 default:
248 return 0;
249 }
250
251 memcpy(addr, p, len);
252 memset((void *)addr + len, 0, sizeof(*addr) - len);
253 memcpy(port, p + len, sizeof(__be16));
254
255 return 1;
256}
257
258/****************************************************************************/
259static int expect_rtp_rtcp(struct sk_buff **pskb, struct nf_conn *ct,
260 enum ip_conntrack_info ctinfo,
261 unsigned char **data, int dataoff,
262 H245_TransportAddress *taddr)
263{
264 int dir = CTINFO2DIR(ctinfo);
265 int ret = 0;
266 __be16 port;
267 __be16 rtp_port, rtcp_port;
268 union nf_conntrack_address addr;
269 struct nf_conntrack_expect *rtp_exp;
270 struct nf_conntrack_expect *rtcp_exp;
271 typeof(nat_rtp_rtcp_hook) nat_rtp_rtcp;
272
273 /* Read RTP or RTCP address */
274 if (!get_h245_addr(ct, *data, taddr, &addr, &port) ||
275 memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) ||
276 port == 0)
277 return 0;
278
279 /* RTP port is even */
280 port &= htons(~1);
281 rtp_port = port;
282 rtcp_port = htons(ntohs(port) + 1);
283
284 /* Create expect for RTP */
285 if ((rtp_exp = nf_conntrack_expect_alloc(ct)) == NULL)
286 return -1;
287 nf_conntrack_expect_init(rtp_exp, ct->tuplehash[!dir].tuple.src.l3num,
288 &ct->tuplehash[!dir].tuple.src.u3,
289 &ct->tuplehash[!dir].tuple.dst.u3,
290 IPPROTO_UDP, NULL, &rtp_port);
291
292 /* Create expect for RTCP */
293 if ((rtcp_exp = nf_conntrack_expect_alloc(ct)) == NULL) {
294 nf_conntrack_expect_put(rtp_exp);
295 return -1;
296 }
297 nf_conntrack_expect_init(rtcp_exp, ct->tuplehash[!dir].tuple.src.l3num,
298 &ct->tuplehash[!dir].tuple.src.u3,
299 &ct->tuplehash[!dir].tuple.dst.u3,
300 IPPROTO_UDP, NULL, &rtcp_port);
301
302 if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
303 &ct->tuplehash[!dir].tuple.dst.u3,
304 sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
305 (nat_rtp_rtcp = rcu_dereference(nat_rtp_rtcp_hook)) &&
306 ct->status & IPS_NAT_MASK) {
307 /* NAT needed */
308 ret = nat_rtp_rtcp(pskb, ct, ctinfo, data, dataoff,
309 taddr, port, rtp_port, rtp_exp, rtcp_exp);
310 } else { /* Conntrack only */
311 if (nf_conntrack_expect_related(rtp_exp) == 0) {
312 if (nf_conntrack_expect_related(rtcp_exp) == 0) {
313 DEBUGP("nf_ct_h323: expect RTP ");
314 NF_CT_DUMP_TUPLE(&rtp_exp->tuple);
315 DEBUGP("nf_ct_h323: expect RTCP ");
316 NF_CT_DUMP_TUPLE(&rtcp_exp->tuple);
317 } else {
318 nf_conntrack_unexpect_related(rtp_exp);
319 ret = -1;
320 }
321 } else
322 ret = -1;
323 }
324
325 nf_conntrack_expect_put(rtp_exp);
326 nf_conntrack_expect_put(rtcp_exp);
327
328 return ret;
329}
330
331/****************************************************************************/
332static int expect_t120(struct sk_buff **pskb,
333 struct nf_conn *ct,
334 enum ip_conntrack_info ctinfo,
335 unsigned char **data, int dataoff,
336 H245_TransportAddress *taddr)
337{
338 int dir = CTINFO2DIR(ctinfo);
339 int ret = 0;
340 __be16 port;
341 union nf_conntrack_address addr;
342 struct nf_conntrack_expect *exp;
343 typeof(nat_t120_hook) nat_t120;
344
345 /* Read T.120 address */
346 if (!get_h245_addr(ct, *data, taddr, &addr, &port) ||
347 memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) ||
348 port == 0)
349 return 0;
350
351 /* Create expect for T.120 connections */
352 if ((exp = nf_conntrack_expect_alloc(ct)) == NULL)
353 return -1;
354 nf_conntrack_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
355 &ct->tuplehash[!dir].tuple.src.u3,
356 &ct->tuplehash[!dir].tuple.dst.u3,
357 IPPROTO_TCP, NULL, &port);
358 exp->flags = NF_CT_EXPECT_PERMANENT; /* Accept multiple channels */
359
360 if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
361 &ct->tuplehash[!dir].tuple.dst.u3,
362 sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
363 (nat_t120 = rcu_dereference(nat_t120_hook)) &&
364 ct->status & IPS_NAT_MASK) {
365 /* NAT needed */
366 ret = nat_t120(pskb, ct, ctinfo, data, dataoff, taddr,
367 port, exp);
368 } else { /* Conntrack only */
369 if (nf_conntrack_expect_related(exp) == 0) {
370 DEBUGP("nf_ct_h323: expect T.120 ");
371 NF_CT_DUMP_TUPLE(&exp->tuple);
372 } else
373 ret = -1;
374 }
375
376 nf_conntrack_expect_put(exp);
377
378 return ret;
379}
380
381/****************************************************************************/
382static int process_h245_channel(struct sk_buff **pskb,
383 struct nf_conn *ct,
384 enum ip_conntrack_info ctinfo,
385 unsigned char **data, int dataoff,
386 H2250LogicalChannelParameters *channel)
387{
388 int ret;
389
390 if (channel->options & eH2250LogicalChannelParameters_mediaChannel) {
391 /* RTP */
392 ret = expect_rtp_rtcp(pskb, ct, ctinfo, data, dataoff,
393 &channel->mediaChannel);
394 if (ret < 0)
395 return -1;
396 }
397
398 if (channel->
399 options & eH2250LogicalChannelParameters_mediaControlChannel) {
400 /* RTCP */
401 ret = expect_rtp_rtcp(pskb, ct, ctinfo, data, dataoff,
402 &channel->mediaControlChannel);
403 if (ret < 0)
404 return -1;
405 }
406
407 return 0;
408}
409
410/****************************************************************************/
411static int process_olc(struct sk_buff **pskb, struct nf_conn *ct,
412 enum ip_conntrack_info ctinfo,
413 unsigned char **data, int dataoff,
414 OpenLogicalChannel *olc)
415{
416 int ret;
417
418 DEBUGP("nf_ct_h323: OpenLogicalChannel\n");
419
420 if (olc->forwardLogicalChannelParameters.multiplexParameters.choice ==
421 eOpenLogicalChannel_forwardLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters)
422 {
423 ret = process_h245_channel(pskb, ct, ctinfo, data, dataoff,
424 &olc->
425 forwardLogicalChannelParameters.
426 multiplexParameters.
427 h2250LogicalChannelParameters);
428 if (ret < 0)
429 return -1;
430 }
431
432 if ((olc->options &
433 eOpenLogicalChannel_reverseLogicalChannelParameters) &&
434 (olc->reverseLogicalChannelParameters.options &
435 eOpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters)
436 && (olc->reverseLogicalChannelParameters.multiplexParameters.
437 choice ==
438 eOpenLogicalChannel_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters))
439 {
440 ret =
441 process_h245_channel(pskb, ct, ctinfo, data, dataoff,
442 &olc->
443 reverseLogicalChannelParameters.
444 multiplexParameters.
445 h2250LogicalChannelParameters);
446 if (ret < 0)
447 return -1;
448 }
449
450 if ((olc->options & eOpenLogicalChannel_separateStack) &&
451 olc->forwardLogicalChannelParameters.dataType.choice ==
452 eDataType_data &&
453 olc->forwardLogicalChannelParameters.dataType.data.application.
454 choice == eDataApplicationCapability_application_t120 &&
455 olc->forwardLogicalChannelParameters.dataType.data.application.
456 t120.choice == eDataProtocolCapability_separateLANStack &&
457 olc->separateStack.networkAddress.choice ==
458 eNetworkAccessParameters_networkAddress_localAreaAddress) {
459 ret = expect_t120(pskb, ct, ctinfo, data, dataoff,
460 &olc->separateStack.networkAddress.
461 localAreaAddress);
462 if (ret < 0)
463 return -1;
464 }
465
466 return 0;
467}
468
469/****************************************************************************/
470static int process_olca(struct sk_buff **pskb, struct nf_conn *ct,
471 enum ip_conntrack_info ctinfo,
472 unsigned char **data, int dataoff,
473 OpenLogicalChannelAck *olca)
474{
475 H2250LogicalChannelAckParameters *ack;
476 int ret;
477
478 DEBUGP("nf_ct_h323: OpenLogicalChannelAck\n");
479
480 if ((olca->options &
481 eOpenLogicalChannelAck_reverseLogicalChannelParameters) &&
482 (olca->reverseLogicalChannelParameters.options &
483 eOpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters)
484 && (olca->reverseLogicalChannelParameters.multiplexParameters.
485 choice ==
486 eOpenLogicalChannelAck_reverseLogicalChannelParameters_multiplexParameters_h2250LogicalChannelParameters))
487 {
488 ret = process_h245_channel(pskb, ct, ctinfo, data, dataoff,
489 &olca->
490 reverseLogicalChannelParameters.
491 multiplexParameters.
492 h2250LogicalChannelParameters);
493 if (ret < 0)
494 return -1;
495 }
496
497 if ((olca->options &
498 eOpenLogicalChannelAck_forwardMultiplexAckParameters) &&
499 (olca->forwardMultiplexAckParameters.choice ==
500 eOpenLogicalChannelAck_forwardMultiplexAckParameters_h2250LogicalChannelAckParameters))
501 {
502 ack = &olca->forwardMultiplexAckParameters.
503 h2250LogicalChannelAckParameters;
504 if (ack->options &
505 eH2250LogicalChannelAckParameters_mediaChannel) {
506 /* RTP */
507 ret = expect_rtp_rtcp(pskb, ct, ctinfo, data, dataoff,
508 &ack->mediaChannel);
509 if (ret < 0)
510 return -1;
511 }
512
513 if (ack->options &
514 eH2250LogicalChannelAckParameters_mediaControlChannel) {
515 /* RTCP */
516 ret = expect_rtp_rtcp(pskb, ct, ctinfo, data, dataoff,
517 &ack->mediaControlChannel);
518 if (ret < 0)
519 return -1;
520 }
521 }
522
523 return 0;
524}
525
526/****************************************************************************/
527static int process_h245(struct sk_buff **pskb, struct nf_conn *ct,
528 enum ip_conntrack_info ctinfo,
529 unsigned char **data, int dataoff,
530 MultimediaSystemControlMessage *mscm)
531{
532 switch (mscm->choice) {
533 case eMultimediaSystemControlMessage_request:
534 if (mscm->request.choice ==
535 eRequestMessage_openLogicalChannel) {
536 return process_olc(pskb, ct, ctinfo, data, dataoff,
537 &mscm->request.openLogicalChannel);
538 }
539 DEBUGP("nf_ct_h323: H.245 Request %d\n",
540 mscm->request.choice);
541 break;
542 case eMultimediaSystemControlMessage_response:
543 if (mscm->response.choice ==
544 eResponseMessage_openLogicalChannelAck) {
545 return process_olca(pskb, ct, ctinfo, data, dataoff,
546 &mscm->response.
547 openLogicalChannelAck);
548 }
549 DEBUGP("nf_ct_h323: H.245 Response %d\n",
550 mscm->response.choice);
551 break;
552 default:
553 DEBUGP("nf_ct_h323: H.245 signal %d\n", mscm->choice);
554 break;
555 }
556
557 return 0;
558}
559
560/****************************************************************************/
561static int h245_help(struct sk_buff **pskb, unsigned int protoff,
562 struct nf_conn *ct, enum ip_conntrack_info ctinfo)
563{
564 static MultimediaSystemControlMessage mscm;
565 unsigned char *data = NULL;
566 int datalen;
567 int dataoff;
568 int ret;
569
570 /* Until there's been traffic both ways, don't look in packets. */
571 if (ctinfo != IP_CT_ESTABLISHED &&
572 ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
573 return NF_ACCEPT;
574 }
575 DEBUGP("nf_ct_h245: skblen = %u\n", (*pskb)->len);
576
577 spin_lock_bh(&nf_h323_lock);
578
579 /* Process each TPKT */
580 while (get_tpkt_data(pskb, protoff, ct, ctinfo,
581 &data, &datalen, &dataoff)) {
582 DEBUGP("nf_ct_h245: TPKT len=%d ", datalen);
583 NF_CT_DUMP_TUPLE(&ct->tuplehash[CTINFO2DIR(ctinfo)].tuple);
584
585 /* Decode H.245 signal */
586 ret = DecodeMultimediaSystemControlMessage(data, datalen,
587 &mscm);
588 if (ret < 0) {
589 if (net_ratelimit())
590 printk("nf_ct_h245: decoding error: %s\n",
591 ret == H323_ERROR_BOUND ?
592 "out of bound" : "out of range");
593 /* We don't drop when decoding error */
594 break;
595 }
596
597 /* Process H.245 signal */
598 if (process_h245(pskb, ct, ctinfo, &data, dataoff, &mscm) < 0)
599 goto drop;
600 }
601
602 spin_unlock_bh(&nf_h323_lock);
603 return NF_ACCEPT;
604
605 drop:
606 spin_unlock_bh(&nf_h323_lock);
607 if (net_ratelimit())
608 printk("nf_ct_h245: packet dropped\n");
609 return NF_DROP;
610}
611
612/****************************************************************************/
613static struct nf_conntrack_helper nf_conntrack_helper_h245 __read_mostly = {
614 .name = "H.245",
615 .me = THIS_MODULE,
616 .max_expected = H323_RTP_CHANNEL_MAX * 4 + 2 /* T.120 */,
617 .timeout = 240,
618 .tuple.dst.protonum = IPPROTO_UDP,
619 .mask.src.u.udp.port = __constant_htons(0xFFFF),
620 .mask.dst.protonum = 0xFF,
621 .help = h245_help
622};
623
624/****************************************************************************/
625int get_h225_addr(struct nf_conn *ct, unsigned char *data,
626 TransportAddress *taddr,
627 union nf_conntrack_address *addr, __be16 *port)
628{
629 unsigned char *p;
630 int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
631 int len;
632
633 switch (taddr->choice) {
634 case eTransportAddress_ipAddress:
635 if (family != AF_INET)
636 return 0;
637 p = data + taddr->ipAddress.ip;
638 len = 4;
639 break;
640 case eTransportAddress_ip6Address:
641 if (family != AF_INET6)
642 return 0;
643 p = data + taddr->ip6Address.ip6;
644 len = 16;
645 break;
646 default:
647 return 0;
648 }
649
650 memcpy(addr, p, len);
651 memset((void *)addr + len, 0, sizeof(*addr) - len);
652 memcpy(port, p + len, sizeof(__be16));
653
654 return 1;
655}
656
657/****************************************************************************/
658static int expect_h245(struct sk_buff **pskb, struct nf_conn *ct,
659 enum ip_conntrack_info ctinfo,
660 unsigned char **data, int dataoff,
661 TransportAddress *taddr)
662{
663 int dir = CTINFO2DIR(ctinfo);
664 int ret = 0;
665 __be16 port;
666 union nf_conntrack_address addr;
667 struct nf_conntrack_expect *exp;
668 typeof(nat_h245_hook) nat_h245;
669
670 /* Read h245Address */
671 if (!get_h225_addr(ct, *data, taddr, &addr, &port) ||
672 memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) ||
673 port == 0)
674 return 0;
675
676 /* Create expect for h245 connection */
677 if ((exp = nf_conntrack_expect_alloc(ct)) == NULL)
678 return -1;
679 nf_conntrack_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
680 &ct->tuplehash[!dir].tuple.src.u3,
681 &ct->tuplehash[!dir].tuple.dst.u3,
682 IPPROTO_TCP, NULL, &port);
683 exp->helper = &nf_conntrack_helper_h245;
684
685 if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
686 &ct->tuplehash[!dir].tuple.dst.u3,
687 sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
688 (nat_h245 = rcu_dereference(nat_h245_hook)) &&
689 ct->status & IPS_NAT_MASK) {
690 /* NAT needed */
691 ret = nat_h245(pskb, ct, ctinfo, data, dataoff, taddr,
692 port, exp);
693 } else { /* Conntrack only */
694 if (nf_conntrack_expect_related(exp) == 0) {
695 DEBUGP("nf_ct_q931: expect H.245 ");
696 NF_CT_DUMP_TUPLE(&exp->tuple);
697 } else
698 ret = -1;
699 }
700
701 nf_conntrack_expect_put(exp);
702
703 return ret;
704}
705
706/* If the calling party is on the same side of the forward-to party,
707 * we don't need to track the second call */
708static int callforward_do_filter(union nf_conntrack_address *src,
709 union nf_conntrack_address *dst,
710 int family)
711{
712 struct flowi fl1, fl2;
713 int ret = 0;
714
715 memset(&fl1, 0, sizeof(fl1));
716 memset(&fl2, 0, sizeof(fl2));
717
718 switch (family) {
719 case AF_INET: {
720 struct rtable *rt1, *rt2;
721
722 fl1.fl4_dst = src->ip;
723 fl2.fl4_dst = dst->ip;
724 if (ip_route_output_key(&rt1, &fl1) == 0) {
725 if (ip_route_output_key(&rt2, &fl2) == 0) {
726 if (rt1->rt_gateway == rt2->rt_gateway &&
727 rt1->u.dst.dev == rt2->u.dst.dev)
728 ret = 1;
729 dst_release(&rt2->u.dst);
730 }
731 dst_release(&rt1->u.dst);
732 }
733 break;
734 }
735#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
736 case AF_INET6: {
737 struct rt6_info *rt1, *rt2;
738
739 memcpy(&fl1.fl6_dst, src, sizeof(fl1.fl6_dst));
740 memcpy(&fl2.fl6_dst, dst, sizeof(fl2.fl6_dst));
741 rt1 = (struct rt6_info *)ip6_route_output(NULL, &fl1);
742 if (rt1) {
743 rt2 = (struct rt6_info *)ip6_route_output(NULL, &fl2);
744 if (rt2) {
745 if (!memcmp(&rt1->rt6i_gateway, &rt2->rt6i_gateway,
746 sizeof(rt1->rt6i_gateway)) &&
747 rt1->u.dst.dev == rt2->u.dst.dev)
748 ret = 1;
749 dst_release(&rt2->u.dst);
750 }
751 dst_release(&rt1->u.dst);
752 }
753 break;
754 }
755#endif
756 }
757 return ret;
758
759}
760
761/****************************************************************************/
762static int expect_callforwarding(struct sk_buff **pskb,
763 struct nf_conn *ct,
764 enum ip_conntrack_info ctinfo,
765 unsigned char **data, int dataoff,
766 TransportAddress *taddr)
767{
768 int dir = CTINFO2DIR(ctinfo);
769 int ret = 0;
770 __be16 port;
771 union nf_conntrack_address addr;
772 struct nf_conntrack_expect *exp;
773 typeof(nat_callforwarding_hook) nat_callforwarding;
774
775 /* Read alternativeAddress */
776 if (!get_h225_addr(ct, *data, taddr, &addr, &port) || port == 0)
777 return 0;
778
779 /* If the calling party is on the same side of the forward-to party,
780 * we don't need to track the second call */
781 if (callforward_filter &&
782 callforward_do_filter(&addr, &ct->tuplehash[!dir].tuple.src.u3,
783 ct->tuplehash[!dir].tuple.src.l3num)) {
784 DEBUGP("nf_ct_q931: Call Forwarding not tracked\n");
785 return 0;
786 }
787
788 /* Create expect for the second call leg */
789 if ((exp = nf_conntrack_expect_alloc(ct)) == NULL)
790 return -1;
791 nf_conntrack_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
792 &ct->tuplehash[!dir].tuple.src.u3, &addr,
793 IPPROTO_TCP, NULL, &port);
794 exp->helper = nf_conntrack_helper_q931;
795
796 if (memcmp(&ct->tuplehash[dir].tuple.src.u3,
797 &ct->tuplehash[!dir].tuple.dst.u3,
798 sizeof(ct->tuplehash[dir].tuple.src.u3)) &&
799 (nat_callforwarding = rcu_dereference(nat_callforwarding_hook)) &&
800 ct->status & IPS_NAT_MASK) {
801 /* Need NAT */
802 ret = nat_callforwarding(pskb, ct, ctinfo, data, dataoff,
803 taddr, port, exp);
804 } else { /* Conntrack only */
805 if (nf_conntrack_expect_related(exp) == 0) {
806 DEBUGP("nf_ct_q931: expect Call Forwarding ");
807 NF_CT_DUMP_TUPLE(&exp->tuple);
808 } else
809 ret = -1;
810 }
811
812 nf_conntrack_expect_put(exp);
813
814 return ret;
815}
816
817/****************************************************************************/
818static int process_setup(struct sk_buff **pskb, struct nf_conn *ct,
819 enum ip_conntrack_info ctinfo,
820 unsigned char **data, int dataoff,
821 Setup_UUIE *setup)
822{
823 int dir = CTINFO2DIR(ctinfo);
824 int ret;
825 int i;
826 __be16 port;
827 union nf_conntrack_address addr;
828 typeof(set_h225_addr_hook) set_h225_addr;
829
830 DEBUGP("nf_ct_q931: Setup\n");
831
832 if (setup->options & eSetup_UUIE_h245Address) {
833 ret = expect_h245(pskb, ct, ctinfo, data, dataoff,
834 &setup->h245Address);
835 if (ret < 0)
836 return -1;
837 }
838
839 set_h225_addr = rcu_dereference(set_h225_addr_hook);
840 if ((setup->options & eSetup_UUIE_destCallSignalAddress) &&
841 (set_h225_addr) && ct->status && IPS_NAT_MASK &&
842 get_h225_addr(ct, *data, &setup->destCallSignalAddress,
843 &addr, &port) &&
844 memcmp(&addr, &ct->tuplehash[!dir].tuple.src.u3, sizeof(addr))) {
845 DEBUGP("nf_ct_q931: set destCallSignalAddress "
846 NIP6_FMT ":%hu->" NIP6_FMT ":%hu\n",
847 NIP6(*(struct in6_addr *)&addr), ntohs(port),
848 NIP6(*(struct in6_addr *)&ct->tuplehash[!dir].tuple.src.u3),
849 ntohs(ct->tuplehash[!dir].tuple.src.u.tcp.port));
850 ret = set_h225_addr(pskb, data, dataoff,
851 &setup->destCallSignalAddress,
852 &ct->tuplehash[!dir].tuple.src.u3,
853 ct->tuplehash[!dir].tuple.src.u.tcp.port);
854 if (ret < 0)
855 return -1;
856 }
857
858 if ((setup->options & eSetup_UUIE_sourceCallSignalAddress) &&
859 (set_h225_addr) && ct->status & IPS_NAT_MASK &&
860 get_h225_addr(ct, *data, &setup->sourceCallSignalAddress,
861 &addr, &port) &&
862 memcmp(&addr, &ct->tuplehash[!dir].tuple.dst.u3, sizeof(addr))) {
863 DEBUGP("nf_ct_q931: set sourceCallSignalAddress "
864 NIP6_FMT ":%hu->" NIP6_FMT ":%hu\n",
865 NIP6(*(struct in6_addr *)&addr), ntohs(port),
866 NIP6(*(struct in6_addr *)&ct->tuplehash[!dir].tuple.dst.u3),
867 ntohs(ct->tuplehash[!dir].tuple.dst.u.tcp.port));
868 ret = set_h225_addr(pskb, data, dataoff,
869 &setup->sourceCallSignalAddress,
870 &ct->tuplehash[!dir].tuple.dst.u3,
871 ct->tuplehash[!dir].tuple.dst.u.tcp.port);
872 if (ret < 0)
873 return -1;
874 }
875
876 if (setup->options & eSetup_UUIE_fastStart) {
877 for (i = 0; i < setup->fastStart.count; i++) {
878 ret = process_olc(pskb, ct, ctinfo, data, dataoff,
879 &setup->fastStart.item[i]);
880 if (ret < 0)
881 return -1;
882 }
883 }
884
885 return 0;
886}
887
888/****************************************************************************/
889static int process_callproceeding(struct sk_buff **pskb,
890 struct nf_conn *ct,
891 enum ip_conntrack_info ctinfo,
892 unsigned char **data, int dataoff,
893 CallProceeding_UUIE *callproc)
894{
895 int ret;
896 int i;
897
898 DEBUGP("nf_ct_q931: CallProceeding\n");
899
900 if (callproc->options & eCallProceeding_UUIE_h245Address) {
901 ret = expect_h245(pskb, ct, ctinfo, data, dataoff,
902 &callproc->h245Address);
903 if (ret < 0)
904 return -1;
905 }
906
907 if (callproc->options & eCallProceeding_UUIE_fastStart) {
908 for (i = 0; i < callproc->fastStart.count; i++) {
909 ret = process_olc(pskb, ct, ctinfo, data, dataoff,
910 &callproc->fastStart.item[i]);
911 if (ret < 0)
912 return -1;
913 }
914 }
915
916 return 0;
917}
918
919/****************************************************************************/
920static int process_connect(struct sk_buff **pskb, struct nf_conn *ct,
921 enum ip_conntrack_info ctinfo,
922 unsigned char **data, int dataoff,
923 Connect_UUIE *connect)
924{
925 int ret;
926 int i;
927
928 DEBUGP("nf_ct_q931: Connect\n");
929
930 if (connect->options & eConnect_UUIE_h245Address) {
931 ret = expect_h245(pskb, ct, ctinfo, data, dataoff,
932 &connect->h245Address);
933 if (ret < 0)
934 return -1;
935 }
936
937 if (connect->options & eConnect_UUIE_fastStart) {
938 for (i = 0; i < connect->fastStart.count; i++) {
939 ret = process_olc(pskb, ct, ctinfo, data, dataoff,
940 &connect->fastStart.item[i]);
941 if (ret < 0)
942 return -1;
943 }
944 }
945
946 return 0;
947}
948
949/****************************************************************************/
950static int process_alerting(struct sk_buff **pskb, struct nf_conn *ct,
951 enum ip_conntrack_info ctinfo,
952 unsigned char **data, int dataoff,
953 Alerting_UUIE *alert)
954{
955 int ret;
956 int i;
957
958 DEBUGP("nf_ct_q931: Alerting\n");
959
960 if (alert->options & eAlerting_UUIE_h245Address) {
961 ret = expect_h245(pskb, ct, ctinfo, data, dataoff,
962 &alert->h245Address);
963 if (ret < 0)
964 return -1;
965 }
966
967 if (alert->options & eAlerting_UUIE_fastStart) {
968 for (i = 0; i < alert->fastStart.count; i++) {
969 ret = process_olc(pskb, ct, ctinfo, data, dataoff,
970 &alert->fastStart.item[i]);
971 if (ret < 0)
972 return -1;
973 }
974 }
975
976 return 0;
977}
978
979/****************************************************************************/
980static int process_information(struct sk_buff **pskb,
981 struct nf_conn *ct,
982 enum ip_conntrack_info ctinfo,
983 unsigned char **data, int dataoff,
984 Information_UUIE *info)
985{
986 int ret;
987 int i;
988
989 DEBUGP("nf_ct_q931: Information\n");
990
991 if (info->options & eInformation_UUIE_fastStart) {
992 for (i = 0; i < info->fastStart.count; i++) {
993 ret = process_olc(pskb, ct, ctinfo, data, dataoff,
994 &info->fastStart.item[i]);
995 if (ret < 0)
996 return -1;
997 }
998 }
999
1000 return 0;
1001}
1002
1003/****************************************************************************/
1004static int process_facility(struct sk_buff **pskb, struct nf_conn *ct,
1005 enum ip_conntrack_info ctinfo,
1006 unsigned char **data, int dataoff,
1007 Facility_UUIE *facility)
1008{
1009 int ret;
1010 int i;
1011
1012 DEBUGP("nf_ct_q931: Facility\n");
1013
1014 if (facility->reason.choice == eFacilityReason_callForwarded) {
1015 if (facility->options & eFacility_UUIE_alternativeAddress)
1016 return expect_callforwarding(pskb, ct, ctinfo, data,
1017 dataoff,
1018 &facility->
1019 alternativeAddress);
1020 return 0;
1021 }
1022
1023 if (facility->options & eFacility_UUIE_h245Address) {
1024 ret = expect_h245(pskb, ct, ctinfo, data, dataoff,
1025 &facility->h245Address);
1026 if (ret < 0)
1027 return -1;
1028 }
1029
1030 if (facility->options & eFacility_UUIE_fastStart) {
1031 for (i = 0; i < facility->fastStart.count; i++) {
1032 ret = process_olc(pskb, ct, ctinfo, data, dataoff,
1033 &facility->fastStart.item[i]);
1034 if (ret < 0)
1035 return -1;
1036 }
1037 }
1038
1039 return 0;
1040}
1041
1042/****************************************************************************/
1043static int process_progress(struct sk_buff **pskb, struct nf_conn *ct,
1044 enum ip_conntrack_info ctinfo,
1045 unsigned char **data, int dataoff,
1046 Progress_UUIE *progress)
1047{
1048 int ret;
1049 int i;
1050
1051 DEBUGP("nf_ct_q931: Progress\n");
1052
1053 if (progress->options & eProgress_UUIE_h245Address) {
1054 ret = expect_h245(pskb, ct, ctinfo, data, dataoff,
1055 &progress->h245Address);
1056 if (ret < 0)
1057 return -1;
1058 }
1059
1060 if (progress->options & eProgress_UUIE_fastStart) {
1061 for (i = 0; i < progress->fastStart.count; i++) {
1062 ret = process_olc(pskb, ct, ctinfo, data, dataoff,
1063 &progress->fastStart.item[i]);
1064 if (ret < 0)
1065 return -1;
1066 }
1067 }
1068
1069 return 0;
1070}
1071
1072/****************************************************************************/
1073static int process_q931(struct sk_buff **pskb, struct nf_conn *ct,
1074 enum ip_conntrack_info ctinfo,
1075 unsigned char **data, int dataoff, Q931 *q931)
1076{
1077 H323_UU_PDU *pdu = &q931->UUIE.h323_uu_pdu;
1078 int i;
1079 int ret = 0;
1080
1081 switch (pdu->h323_message_body.choice) {
1082 case eH323_UU_PDU_h323_message_body_setup:
1083 ret = process_setup(pskb, ct, ctinfo, data, dataoff,
1084 &pdu->h323_message_body.setup);
1085 break;
1086 case eH323_UU_PDU_h323_message_body_callProceeding:
1087 ret = process_callproceeding(pskb, ct, ctinfo, data, dataoff,
1088 &pdu->h323_message_body.
1089 callProceeding);
1090 break;
1091 case eH323_UU_PDU_h323_message_body_connect:
1092 ret = process_connect(pskb, ct, ctinfo, data, dataoff,
1093 &pdu->h323_message_body.connect);
1094 break;
1095 case eH323_UU_PDU_h323_message_body_alerting:
1096 ret = process_alerting(pskb, ct, ctinfo, data, dataoff,
1097 &pdu->h323_message_body.alerting);
1098 break;
1099 case eH323_UU_PDU_h323_message_body_information:
1100 ret = process_information(pskb, ct, ctinfo, data, dataoff,
1101 &pdu->h323_message_body.
1102 information);
1103 break;
1104 case eH323_UU_PDU_h323_message_body_facility:
1105 ret = process_facility(pskb, ct, ctinfo, data, dataoff,
1106 &pdu->h323_message_body.facility);
1107 break;
1108 case eH323_UU_PDU_h323_message_body_progress:
1109 ret = process_progress(pskb, ct, ctinfo, data, dataoff,
1110 &pdu->h323_message_body.progress);
1111 break;
1112 default:
1113 DEBUGP("nf_ct_q931: Q.931 signal %d\n",
1114 pdu->h323_message_body.choice);
1115 break;
1116 }
1117
1118 if (ret < 0)
1119 return -1;
1120
1121 if (pdu->options & eH323_UU_PDU_h245Control) {
1122 for (i = 0; i < pdu->h245Control.count; i++) {
1123 ret = process_h245(pskb, ct, ctinfo, data, dataoff,
1124 &pdu->h245Control.item[i]);
1125 if (ret < 0)
1126 return -1;
1127 }
1128 }
1129
1130 return 0;
1131}
1132
1133/****************************************************************************/
1134static int q931_help(struct sk_buff **pskb, unsigned int protoff,
1135 struct nf_conn *ct, enum ip_conntrack_info ctinfo)
1136{
1137 static Q931 q931;
1138 unsigned char *data = NULL;
1139 int datalen;
1140 int dataoff;
1141 int ret;
1142
1143 /* Until there's been traffic both ways, don't look in packets. */
1144 if (ctinfo != IP_CT_ESTABLISHED &&
1145 ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
1146 return NF_ACCEPT;
1147 }
1148 DEBUGP("nf_ct_q931: skblen = %u\n", (*pskb)->len);
1149
1150 spin_lock_bh(&nf_h323_lock);
1151
1152 /* Process each TPKT */
1153 while (get_tpkt_data(pskb, protoff, ct, ctinfo,
1154 &data, &datalen, &dataoff)) {
1155 DEBUGP("nf_ct_q931: TPKT len=%d ", datalen);
1156 NF_CT_DUMP_TUPLE(&ct->tuplehash[CTINFO2DIR(ctinfo)].tuple);
1157
1158 /* Decode Q.931 signal */
1159 ret = DecodeQ931(data, datalen, &q931);
1160 if (ret < 0) {
1161 if (net_ratelimit())
1162 printk("nf_ct_q931: decoding error: %s\n",
1163 ret == H323_ERROR_BOUND ?
1164 "out of bound" : "out of range");
1165 /* We don't drop when decoding error */
1166 break;
1167 }
1168
1169 /* Process Q.931 signal */
1170 if (process_q931(pskb, ct, ctinfo, &data, dataoff, &q931) < 0)
1171 goto drop;
1172 }
1173
1174 spin_unlock_bh(&nf_h323_lock);
1175 return NF_ACCEPT;
1176
1177 drop:
1178 spin_unlock_bh(&nf_h323_lock);
1179 if (net_ratelimit())
1180 printk("nf_ct_q931: packet dropped\n");
1181 return NF_DROP;
1182}
1183
1184/****************************************************************************/
1185static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = {
1186 {
1187 .name = "Q.931",
1188 .me = THIS_MODULE,
1189 /* T.120 and H.245 */
1190 .max_expected = H323_RTP_CHANNEL_MAX * 4 + 4,
1191 .timeout = 240,
1192 .tuple.src.l3num = AF_INET,
1193 .tuple.src.u.tcp.port = __constant_htons(Q931_PORT),
1194 .tuple.dst.protonum = IPPROTO_TCP,
1195 .mask.src.l3num = 0xFFFF,
1196 .mask.src.u.tcp.port = __constant_htons(0xFFFF),
1197 .mask.dst.protonum = 0xFF,
1198 .help = q931_help
1199 },
1200 {
1201 .name = "Q.931",
1202 .me = THIS_MODULE,
1203 /* T.120 and H.245 */
1204 .max_expected = H323_RTP_CHANNEL_MAX * 4 + 4,
1205 .timeout = 240,
1206 .tuple.src.l3num = AF_INET6,
1207 .tuple.src.u.tcp.port = __constant_htons(Q931_PORT),
1208 .tuple.dst.protonum = IPPROTO_TCP,
1209 .mask.src.l3num = 0xFFFF,
1210 .mask.src.u.tcp.port = __constant_htons(0xFFFF),
1211 .mask.dst.protonum = 0xFF,
1212 .help = q931_help
1213 },
1214};
1215
1216/****************************************************************************/
1217static unsigned char *get_udp_data(struct sk_buff **pskb, unsigned int protoff,
1218 int *datalen)
1219{
1220 struct udphdr _uh, *uh;
1221 int dataoff;
1222
1223 uh = skb_header_pointer(*pskb, protoff, sizeof(_uh), &_uh);
1224 if (uh == NULL)
1225 return NULL;
1226 dataoff = protoff + sizeof(_uh);
1227 if (dataoff >= (*pskb)->len)
1228 return NULL;
1229 *datalen = (*pskb)->len - dataoff;
1230 return skb_header_pointer(*pskb, dataoff, *datalen, h323_buffer);
1231}
1232
1233/****************************************************************************/
1234static struct nf_conntrack_expect *find_expect(struct nf_conn *ct,
1235 union nf_conntrack_address *addr,
1236 __be16 port)
1237{
1238 struct nf_conntrack_expect *exp;
1239 struct nf_conntrack_tuple tuple;
1240
1241 memset(&tuple.src.u3, 0, sizeof(tuple.src.u3));
1242 tuple.src.u.tcp.port = 0;
1243 memcpy(&tuple.dst.u3, addr, sizeof(tuple.dst.u3));
1244 tuple.dst.u.tcp.port = port;
1245 tuple.dst.protonum = IPPROTO_TCP;
1246
1247 exp = __nf_conntrack_expect_find(&tuple);
1248 if (exp && exp->master == ct)
1249 return exp;
1250 return NULL;
1251}
1252
1253/****************************************************************************/
1254static int set_expect_timeout(struct nf_conntrack_expect *exp,
1255 unsigned timeout)
1256{
1257 if (!exp || !del_timer(&exp->timeout))
1258 return 0;
1259
1260 exp->timeout.expires = jiffies + timeout * HZ;
1261 add_timer(&exp->timeout);
1262
1263 return 1;
1264}
1265
1266/****************************************************************************/
1267static int expect_q931(struct sk_buff **pskb, struct nf_conn *ct,
1268 enum ip_conntrack_info ctinfo,
1269 unsigned char **data,
1270 TransportAddress *taddr, int count)
1271{
1272 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1273 int dir = CTINFO2DIR(ctinfo);
1274 int ret = 0;
1275 int i;
1276 __be16 port;
1277 union nf_conntrack_address addr;
1278 struct nf_conntrack_expect *exp;
1279 typeof(nat_q931_hook) nat_q931;
1280
1281 /* Look for the first related address */
1282 for (i = 0; i < count; i++) {
1283 if (get_h225_addr(ct, *data, &taddr[i], &addr, &port) &&
1284 memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3,
1285 sizeof(addr)) == 0 && port != 0)
1286 break;
1287 }
1288
1289 if (i >= count) /* Not found */
1290 return 0;
1291
1292 /* Create expect for Q.931 */
1293 if ((exp = nf_conntrack_expect_alloc(ct)) == NULL)
1294 return -1;
1295 nf_conntrack_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
1296 gkrouted_only ? /* only accept calls from GK? */
1297 &ct->tuplehash[!dir].tuple.src.u3 :
1298 NULL,
1299 &ct->tuplehash[!dir].tuple.dst.u3,
1300 IPPROTO_TCP, NULL, &port);
1301 exp->helper = nf_conntrack_helper_q931;
1302 exp->flags = NF_CT_EXPECT_PERMANENT; /* Accept multiple calls */
1303
1304 nat_q931 = rcu_dereference(nat_q931_hook);
1305 if (nat_q931 && ct->status & IPS_NAT_MASK) { /* Need NAT */
1306 ret = nat_q931(pskb, ct, ctinfo, data, taddr, i, port, exp);
1307 } else { /* Conntrack only */
1308 if (nf_conntrack_expect_related(exp) == 0) {
1309 DEBUGP("nf_ct_ras: expect Q.931 ");
1310 NF_CT_DUMP_TUPLE(&exp->tuple);
1311
1312 /* Save port for looking up expect in processing RCF */
1313 info->sig_port[dir] = port;
1314 } else
1315 ret = -1;
1316 }
1317
1318 nf_conntrack_expect_put(exp);
1319
1320 return ret;
1321}
1322
1323/****************************************************************************/
1324static int process_grq(struct sk_buff **pskb, struct nf_conn *ct,
1325 enum ip_conntrack_info ctinfo,
1326 unsigned char **data, GatekeeperRequest *grq)
1327{
1328 typeof(set_ras_addr_hook) set_ras_addr;
1329
1330 DEBUGP("nf_ct_ras: GRQ\n");
1331
1332 set_ras_addr = rcu_dereference(set_ras_addr_hook);
1333 if (set_ras_addr && ct->status & IPS_NAT_MASK) /* NATed */
1334 return set_ras_addr(pskb, ct, ctinfo, data,
1335 &grq->rasAddress, 1);
1336 return 0;
1337}
1338
1339/****************************************************************************/
1340static int process_gcf(struct sk_buff **pskb, struct nf_conn *ct,
1341 enum ip_conntrack_info ctinfo,
1342 unsigned char **data, GatekeeperConfirm *gcf)
1343{
1344 int dir = CTINFO2DIR(ctinfo);
1345 int ret = 0;
1346 __be16 port;
1347 union nf_conntrack_address addr;
1348 struct nf_conntrack_expect *exp;
1349
1350 DEBUGP("nf_ct_ras: GCF\n");
1351
1352 if (!get_h225_addr(ct, *data, &gcf->rasAddress, &addr, &port))
1353 return 0;
1354
1355 /* Registration port is the same as discovery port */
1356 if (!memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1357 port == ct->tuplehash[dir].tuple.src.u.udp.port)
1358 return 0;
1359
1360 /* Avoid RAS expectation loops. A GCF is never expected. */
1361 if (test_bit(IPS_EXPECTED_BIT, &ct->status))
1362 return 0;
1363
1364 /* Need new expect */
1365 if ((exp = nf_conntrack_expect_alloc(ct)) == NULL)
1366 return -1;
1367 nf_conntrack_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
1368 &ct->tuplehash[!dir].tuple.src.u3, &addr,
1369 IPPROTO_UDP, NULL, &port);
1370 exp->helper = nf_conntrack_helper_ras;
1371
1372 if (nf_conntrack_expect_related(exp) == 0) {
1373 DEBUGP("nf_ct_ras: expect RAS ");
1374 NF_CT_DUMP_TUPLE(&exp->tuple);
1375 } else
1376 ret = -1;
1377
1378 nf_conntrack_expect_put(exp);
1379
1380 return ret;
1381}
1382
1383/****************************************************************************/
1384static int process_rrq(struct sk_buff **pskb, struct nf_conn *ct,
1385 enum ip_conntrack_info ctinfo,
1386 unsigned char **data, RegistrationRequest *rrq)
1387{
1388 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1389 int ret;
1390 typeof(set_ras_addr_hook) set_ras_addr;
1391
1392 DEBUGP("nf_ct_ras: RRQ\n");
1393
1394 ret = expect_q931(pskb, ct, ctinfo, data,
1395 rrq->callSignalAddress.item,
1396 rrq->callSignalAddress.count);
1397 if (ret < 0)
1398 return -1;
1399
1400 set_ras_addr = rcu_dereference(set_ras_addr_hook);
1401 if (set_ras_addr && ct->status & IPS_NAT_MASK) {
1402 ret = set_ras_addr(pskb, ct, ctinfo, data,
1403 rrq->rasAddress.item,
1404 rrq->rasAddress.count);
1405 if (ret < 0)
1406 return -1;
1407 }
1408
1409 if (rrq->options & eRegistrationRequest_timeToLive) {
1410 DEBUGP("nf_ct_ras: RRQ TTL = %u seconds\n", rrq->timeToLive);
1411 info->timeout = rrq->timeToLive;
1412 } else
1413 info->timeout = default_rrq_ttl;
1414
1415 return 0;
1416}
1417
1418/****************************************************************************/
1419static int process_rcf(struct sk_buff **pskb, struct nf_conn *ct,
1420 enum ip_conntrack_info ctinfo,
1421 unsigned char **data, RegistrationConfirm *rcf)
1422{
1423 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1424 int dir = CTINFO2DIR(ctinfo);
1425 int ret;
1426 struct nf_conntrack_expect *exp;
1427 typeof(set_sig_addr_hook) set_sig_addr;
1428
1429 DEBUGP("nf_ct_ras: RCF\n");
1430
1431 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1432 if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1433 ret = set_sig_addr(pskb, ct, ctinfo, data,
1434 rcf->callSignalAddress.item,
1435 rcf->callSignalAddress.count);
1436 if (ret < 0)
1437 return -1;
1438 }
1439
1440 if (rcf->options & eRegistrationConfirm_timeToLive) {
1441 DEBUGP("nf_ct_ras: RCF TTL = %u seconds\n", rcf->timeToLive);
1442 info->timeout = rcf->timeToLive;
1443 }
1444
1445 if (info->timeout > 0) {
1446 DEBUGP
1447 ("nf_ct_ras: set RAS connection timeout to %u seconds\n",
1448 info->timeout);
1449 nf_ct_refresh(ct, *pskb, info->timeout * HZ);
1450
1451 /* Set expect timeout */
1452 read_lock_bh(&nf_conntrack_lock);
1453 exp = find_expect(ct, &ct->tuplehash[dir].tuple.dst.u3,
1454 info->sig_port[!dir]);
1455 if (exp) {
1456 DEBUGP("nf_ct_ras: set Q.931 expect "
1457 "timeout to %u seconds for",
1458 info->timeout);
1459 NF_CT_DUMP_TUPLE(&exp->tuple);
1460 set_expect_timeout(exp, info->timeout);
1461 }
1462 read_unlock_bh(&nf_conntrack_lock);
1463 }
1464
1465 return 0;
1466}
1467
1468/****************************************************************************/
1469static int process_urq(struct sk_buff **pskb, struct nf_conn *ct,
1470 enum ip_conntrack_info ctinfo,
1471 unsigned char **data, UnregistrationRequest *urq)
1472{
1473 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1474 int dir = CTINFO2DIR(ctinfo);
1475 int ret;
1476 typeof(set_sig_addr_hook) set_sig_addr;
1477
1478 DEBUGP("nf_ct_ras: URQ\n");
1479
1480 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1481 if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1482 ret = set_sig_addr(pskb, ct, ctinfo, data,
1483 urq->callSignalAddress.item,
1484 urq->callSignalAddress.count);
1485 if (ret < 0)
1486 return -1;
1487 }
1488
1489 /* Clear old expect */
1490 nf_ct_remove_expectations(ct);
1491 info->sig_port[dir] = 0;
1492 info->sig_port[!dir] = 0;
1493
1494 /* Give it 30 seconds for UCF or URJ */
1495 nf_ct_refresh(ct, *pskb, 30 * HZ);
1496
1497 return 0;
1498}
1499
1500/****************************************************************************/
1501static int process_arq(struct sk_buff **pskb, struct nf_conn *ct,
1502 enum ip_conntrack_info ctinfo,
1503 unsigned char **data, AdmissionRequest *arq)
1504{
1505 struct nf_ct_h323_master *info = &nfct_help(ct)->help.ct_h323_info;
1506 int dir = CTINFO2DIR(ctinfo);
1507 __be16 port;
1508 union nf_conntrack_address addr;
1509 typeof(set_h225_addr_hook) set_h225_addr;
1510
1511 DEBUGP("nf_ct_ras: ARQ\n");
1512
1513 set_h225_addr = rcu_dereference(set_h225_addr_hook);
1514 if ((arq->options & eAdmissionRequest_destCallSignalAddress) &&
1515 get_h225_addr(ct, *data, &arq->destCallSignalAddress,
1516 &addr, &port) &&
1517 !memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1518 port == info->sig_port[dir] &&
1519 set_h225_addr && ct->status & IPS_NAT_MASK) {
1520 /* Answering ARQ */
1521 return set_h225_addr(pskb, data, 0,
1522 &arq->destCallSignalAddress,
1523 &ct->tuplehash[!dir].tuple.dst.u3,
1524 info->sig_port[!dir]);
1525 }
1526
1527 if ((arq->options & eAdmissionRequest_srcCallSignalAddress) &&
1528 get_h225_addr(ct, *data, &arq->srcCallSignalAddress,
1529 &addr, &port) &&
1530 !memcmp(&addr, &ct->tuplehash[dir].tuple.src.u3, sizeof(addr)) &&
1531 set_h225_addr && ct->status & IPS_NAT_MASK) {
1532 /* Calling ARQ */
1533 return set_h225_addr(pskb, data, 0,
1534 &arq->srcCallSignalAddress,
1535 &ct->tuplehash[!dir].tuple.dst.u3,
1536 port);
1537 }
1538
1539 return 0;
1540}
1541
1542/****************************************************************************/
1543static int process_acf(struct sk_buff **pskb, struct nf_conn *ct,
1544 enum ip_conntrack_info ctinfo,
1545 unsigned char **data, AdmissionConfirm *acf)
1546{
1547 int dir = CTINFO2DIR(ctinfo);
1548 int ret = 0;
1549 __be16 port;
1550 union nf_conntrack_address addr;
1551 struct nf_conntrack_expect *exp;
1552 typeof(set_sig_addr_hook) set_sig_addr;
1553
1554 DEBUGP("nf_ct_ras: ACF\n");
1555
1556 if (!get_h225_addr(ct, *data, &acf->destCallSignalAddress,
1557 &addr, &port))
1558 return 0;
1559
1560 if (!memcmp(&addr, &ct->tuplehash[dir].tuple.dst.u3, sizeof(addr))) {
1561 /* Answering ACF */
1562 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1563 if (set_sig_addr && ct->status & IPS_NAT_MASK)
1564 return set_sig_addr(pskb, ct, ctinfo, data,
1565 &acf->destCallSignalAddress, 1);
1566 return 0;
1567 }
1568
1569 /* Need new expect */
1570 if ((exp = nf_conntrack_expect_alloc(ct)) == NULL)
1571 return -1;
1572 nf_conntrack_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
1573 &ct->tuplehash[!dir].tuple.src.u3, &addr,
1574 IPPROTO_TCP, NULL, &port);
1575 exp->flags = NF_CT_EXPECT_PERMANENT;
1576 exp->helper = nf_conntrack_helper_q931;
1577
1578 if (nf_conntrack_expect_related(exp) == 0) {
1579 DEBUGP("nf_ct_ras: expect Q.931 ");
1580 NF_CT_DUMP_TUPLE(&exp->tuple);
1581 } else
1582 ret = -1;
1583
1584 nf_conntrack_expect_put(exp);
1585
1586 return ret;
1587}
1588
1589/****************************************************************************/
1590static int process_lrq(struct sk_buff **pskb, struct nf_conn *ct,
1591 enum ip_conntrack_info ctinfo,
1592 unsigned char **data, LocationRequest *lrq)
1593{
1594 typeof(set_ras_addr_hook) set_ras_addr;
1595
1596 DEBUGP("nf_ct_ras: LRQ\n");
1597
1598 set_ras_addr = rcu_dereference(set_ras_addr_hook);
1599 if (set_ras_addr && ct->status & IPS_NAT_MASK)
1600 return set_ras_addr(pskb, ct, ctinfo, data,
1601 &lrq->replyAddress, 1);
1602 return 0;
1603}
1604
1605/****************************************************************************/
1606static int process_lcf(struct sk_buff **pskb, struct nf_conn *ct,
1607 enum ip_conntrack_info ctinfo,
1608 unsigned char **data, LocationConfirm *lcf)
1609{
1610 int dir = CTINFO2DIR(ctinfo);
1611 int ret = 0;
1612 __be16 port;
1613 union nf_conntrack_address addr;
1614 struct nf_conntrack_expect *exp;
1615
1616 DEBUGP("nf_ct_ras: LCF\n");
1617
1618 if (!get_h225_addr(ct, *data, &lcf->callSignalAddress,
1619 &addr, &port))
1620 return 0;
1621
1622 /* Need new expect for call signal */
1623 if ((exp = nf_conntrack_expect_alloc(ct)) == NULL)
1624 return -1;
1625 nf_conntrack_expect_init(exp, ct->tuplehash[!dir].tuple.src.l3num,
1626 &ct->tuplehash[!dir].tuple.src.u3, &addr,
1627 IPPROTO_TCP, NULL, &port);
1628 exp->flags = NF_CT_EXPECT_PERMANENT;
1629 exp->helper = nf_conntrack_helper_q931;
1630
1631 if (nf_conntrack_expect_related(exp) == 0) {
1632 DEBUGP("nf_ct_ras: expect Q.931 ");
1633 NF_CT_DUMP_TUPLE(&exp->tuple);
1634 } else
1635 ret = -1;
1636
1637 nf_conntrack_expect_put(exp);
1638
1639 /* Ignore rasAddress */
1640
1641 return ret;
1642}
1643
1644/****************************************************************************/
1645static int process_irr(struct sk_buff **pskb, struct nf_conn *ct,
1646 enum ip_conntrack_info ctinfo,
1647 unsigned char **data, InfoRequestResponse *irr)
1648{
1649 int ret;
1650 typeof(set_ras_addr_hook) set_ras_addr;
1651 typeof(set_sig_addr_hook) set_sig_addr;
1652
1653 DEBUGP("nf_ct_ras: IRR\n");
1654
1655 set_ras_addr = rcu_dereference(set_ras_addr_hook);
1656 if (set_ras_addr && ct->status & IPS_NAT_MASK) {
1657 ret = set_ras_addr(pskb, ct, ctinfo, data,
1658 &irr->rasAddress, 1);
1659 if (ret < 0)
1660 return -1;
1661 }
1662
1663 set_sig_addr = rcu_dereference(set_sig_addr_hook);
1664 if (set_sig_addr && ct->status & IPS_NAT_MASK) {
1665 ret = set_sig_addr(pskb, ct, ctinfo, data,
1666 irr->callSignalAddress.item,
1667 irr->callSignalAddress.count);
1668 if (ret < 0)
1669 return -1;
1670 }
1671
1672 return 0;
1673}
1674
1675/****************************************************************************/
1676static int process_ras(struct sk_buff **pskb, struct nf_conn *ct,
1677 enum ip_conntrack_info ctinfo,
1678 unsigned char **data, RasMessage *ras)
1679{
1680 switch (ras->choice) {
1681 case eRasMessage_gatekeeperRequest:
1682 return process_grq(pskb, ct, ctinfo, data,
1683 &ras->gatekeeperRequest);
1684 case eRasMessage_gatekeeperConfirm:
1685 return process_gcf(pskb, ct, ctinfo, data,
1686 &ras->gatekeeperConfirm);
1687 case eRasMessage_registrationRequest:
1688 return process_rrq(pskb, ct, ctinfo, data,
1689 &ras->registrationRequest);
1690 case eRasMessage_registrationConfirm:
1691 return process_rcf(pskb, ct, ctinfo, data,
1692 &ras->registrationConfirm);
1693 case eRasMessage_unregistrationRequest:
1694 return process_urq(pskb, ct, ctinfo, data,
1695 &ras->unregistrationRequest);
1696 case eRasMessage_admissionRequest:
1697 return process_arq(pskb, ct, ctinfo, data,
1698 &ras->admissionRequest);
1699 case eRasMessage_admissionConfirm:
1700 return process_acf(pskb, ct, ctinfo, data,
1701 &ras->admissionConfirm);
1702 case eRasMessage_locationRequest:
1703 return process_lrq(pskb, ct, ctinfo, data,
1704 &ras->locationRequest);
1705 case eRasMessage_locationConfirm:
1706 return process_lcf(pskb, ct, ctinfo, data,
1707 &ras->locationConfirm);
1708 case eRasMessage_infoRequestResponse:
1709 return process_irr(pskb, ct, ctinfo, data,
1710 &ras->infoRequestResponse);
1711 default:
1712 DEBUGP("nf_ct_ras: RAS message %d\n", ras->choice);
1713 break;
1714 }
1715
1716 return 0;
1717}
1718
1719/****************************************************************************/
1720static int ras_help(struct sk_buff **pskb, unsigned int protoff,
1721 struct nf_conn *ct, enum ip_conntrack_info ctinfo)
1722{
1723 static RasMessage ras;
1724 unsigned char *data;
1725 int datalen = 0;
1726 int ret;
1727
1728 DEBUGP("nf_ct_ras: skblen = %u\n", (*pskb)->len);
1729
1730 spin_lock_bh(&nf_h323_lock);
1731
1732 /* Get UDP data */
1733 data = get_udp_data(pskb, protoff, &datalen);
1734 if (data == NULL)
1735 goto accept;
1736 DEBUGP("nf_ct_ras: RAS message len=%d ", datalen);
1737 NF_CT_DUMP_TUPLE(&ct->tuplehash[CTINFO2DIR(ctinfo)].tuple);
1738
1739 /* Decode RAS message */
1740 ret = DecodeRasMessage(data, datalen, &ras);
1741 if (ret < 0) {
1742 if (net_ratelimit())
1743 printk("nf_ct_ras: decoding error: %s\n",
1744 ret == H323_ERROR_BOUND ?
1745 "out of bound" : "out of range");
1746 goto accept;
1747 }
1748
1749 /* Process RAS message */
1750 if (process_ras(pskb, ct, ctinfo, &data, &ras) < 0)
1751 goto drop;
1752
1753 accept:
1754 spin_unlock_bh(&nf_h323_lock);
1755 return NF_ACCEPT;
1756
1757 drop:
1758 spin_unlock_bh(&nf_h323_lock);
1759 if (net_ratelimit())
1760 printk("nf_ct_ras: packet dropped\n");
1761 return NF_DROP;
1762}
1763
1764/****************************************************************************/
1765static struct nf_conntrack_helper nf_conntrack_helper_ras[] __read_mostly = {
1766 {
1767 .name = "RAS",
1768 .me = THIS_MODULE,
1769 .max_expected = 32,
1770 .timeout = 240,
1771 .tuple.src.l3num = AF_INET,
1772 .tuple.src.u.udp.port = __constant_htons(RAS_PORT),
1773 .tuple.dst.protonum = IPPROTO_UDP,
1774 .mask.src.l3num = 0xFFFF,
1775 .mask.src.u.udp.port = __constant_htons(0xFFFF),
1776 .mask.dst.protonum = 0xFF,
1777 .help = ras_help,
1778 },
1779 {
1780 .name = "RAS",
1781 .me = THIS_MODULE,
1782 .max_expected = 32,
1783 .timeout = 240,
1784 .tuple.src.l3num = AF_INET6,
1785 .tuple.src.u.udp.port = __constant_htons(RAS_PORT),
1786 .tuple.dst.protonum = IPPROTO_UDP,
1787 .mask.src.l3num = 0xFFFF,
1788 .mask.src.u.udp.port = __constant_htons(0xFFFF),
1789 .mask.dst.protonum = 0xFF,
1790 .help = ras_help,
1791 },
1792};
1793
1794/****************************************************************************/
1795static void __exit nf_conntrack_h323_fini(void)
1796{
1797 nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[1]);
1798 nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[0]);
1799 nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[1]);
1800 nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[0]);
1801 kfree(h323_buffer);
1802 DEBUGP("nf_ct_h323: fini\n");
1803}
1804
1805/****************************************************************************/
1806static int __init nf_conntrack_h323_init(void)
1807{
1808 int ret;
1809
1810 h323_buffer = kmalloc(65536, GFP_KERNEL);
1811 if (!h323_buffer)
1812 return -ENOMEM;
1813 ret = nf_conntrack_helper_register(&nf_conntrack_helper_q931[0]);
1814 if (ret < 0)
1815 goto err1;
1816 ret = nf_conntrack_helper_register(&nf_conntrack_helper_q931[1]);
1817 if (ret < 0)
1818 goto err2;
1819 ret = nf_conntrack_helper_register(&nf_conntrack_helper_ras[0]);
1820 if (ret < 0)
1821 goto err3;
1822 ret = nf_conntrack_helper_register(&nf_conntrack_helper_ras[1]);
1823 if (ret < 0)
1824 goto err4;
1825 DEBUGP("nf_ct_h323: init success\n");
1826 return 0;
1827
1828err4:
1829 nf_conntrack_helper_unregister(&nf_conntrack_helper_ras[0]);
1830err3:
1831 nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[1]);
1832err2:
1833 nf_conntrack_helper_unregister(&nf_conntrack_helper_q931[0]);
1834err1:
1835 return ret;
1836}
1837
1838/****************************************************************************/
1839module_init(nf_conntrack_h323_init);
1840module_exit(nf_conntrack_h323_fini);
1841
1842EXPORT_SYMBOL_GPL(get_h225_addr);
1843EXPORT_SYMBOL_GPL(set_h245_addr_hook);
1844EXPORT_SYMBOL_GPL(set_h225_addr_hook);
1845EXPORT_SYMBOL_GPL(set_sig_addr_hook);
1846EXPORT_SYMBOL_GPL(set_ras_addr_hook);
1847EXPORT_SYMBOL_GPL(nat_rtp_rtcp_hook);
1848EXPORT_SYMBOL_GPL(nat_t120_hook);
1849EXPORT_SYMBOL_GPL(nat_h245_hook);
1850EXPORT_SYMBOL_GPL(nat_callforwarding_hook);
1851EXPORT_SYMBOL_GPL(nat_q931_hook);
1852
1853MODULE_AUTHOR("Jing Min Zhao <zhaojingmin@users.sourceforge.net>");
1854MODULE_DESCRIPTION("H.323 connection tracking helper");
1855MODULE_LICENSE("GPL");
1856MODULE_ALIAS("ip_conntrack_h323");
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323_types.c b/net/netfilter/nf_conntrack_h323_types.c
index 4b359618bedd..4c6f8b3b1208 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323_types.c
+++ b/net/netfilter/nf_conntrack_h323_types.c
@@ -36,7 +36,8 @@ static field_t _TransportAddress_ipxAddress[] = { /* SEQUENCE */
36}; 36};
37 37
38static field_t _TransportAddress_ip6Address[] = { /* SEQUENCE */ 38static field_t _TransportAddress_ip6Address[] = { /* SEQUENCE */
39 {FNAME("ip") OCTSTR, FIXD, 16, 0, SKIP, 0, NULL}, 39 {FNAME("ip") OCTSTR, FIXD, 16, 0, DECODE,
40 offsetof(TransportAddress_ip6Address, ip6), NULL},
40 {FNAME("port") INT, WORD, 0, 0, SKIP, 0, NULL}, 41 {FNAME("port") INT, WORD, 0, 0, SKIP, 0, NULL},
41}; 42};
42 43
@@ -65,8 +66,8 @@ static field_t _TransportAddress[] = { /* CHOICE */
65 _TransportAddress_ipSourceRoute}, 66 _TransportAddress_ipSourceRoute},
66 {FNAME("ipxAddress") SEQ, 0, 3, 3, SKIP, 0, 67 {FNAME("ipxAddress") SEQ, 0, 3, 3, SKIP, 0,
67 _TransportAddress_ipxAddress}, 68 _TransportAddress_ipxAddress},
68 {FNAME("ip6Address") SEQ, 0, 2, 2, SKIP | EXT, 0, 69 {FNAME("ip6Address") SEQ, 0, 2, 2, DECODE | EXT,
69 _TransportAddress_ip6Address}, 70 offsetof(TransportAddress, ip6Address), _TransportAddress_ip6Address},
70 {FNAME("netBios") OCTSTR, FIXD, 16, 0, SKIP, 0, NULL}, 71 {FNAME("netBios") OCTSTR, FIXD, 16, 0, SKIP, 0, NULL},
71 {FNAME("nsap") OCTSTR, 5, 1, 0, SKIP, 0, NULL}, 72 {FNAME("nsap") OCTSTR, 5, 1, 0, SKIP, 0, NULL},
72 {FNAME("nonStandardAddress") SEQ, 0, 2, 2, SKIP, 0, 73 {FNAME("nonStandardAddress") SEQ, 0, 2, 2, SKIP, 0,
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
new file mode 100644
index 000000000000..0743be4434b0
--- /dev/null
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -0,0 +1,155 @@
1/* Helper handling for netfilter. */
2
3/* (C) 1999-2001 Paul `Rusty' Russell
4 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
5 * (C) 2003,2004 USAGI/WIDE Project <http://www.linux-ipv6.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 version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/types.h>
13#include <linux/netfilter.h>
14#include <linux/module.h>
15#include <linux/skbuff.h>
16#include <linux/vmalloc.h>
17#include <linux/stddef.h>
18#include <linux/slab.h>
19#include <linux/random.h>
20#include <linux/err.h>
21#include <linux/kernel.h>
22#include <linux/netdevice.h>
23
24#include <net/netfilter/nf_conntrack.h>
25#include <net/netfilter/nf_conntrack_l3proto.h>
26#include <net/netfilter/nf_conntrack_l4proto.h>
27#include <net/netfilter/nf_conntrack_helper.h>
28#include <net/netfilter/nf_conntrack_core.h>
29
30static __read_mostly LIST_HEAD(helpers);
31
32struct nf_conntrack_helper *
33__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple)
34{
35 struct nf_conntrack_helper *h;
36
37 list_for_each_entry(h, &helpers, list) {
38 if (nf_ct_tuple_mask_cmp(tuple, &h->tuple, &h->mask))
39 return h;
40 }
41 return NULL;
42}
43
44struct nf_conntrack_helper *
45nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple)
46{
47 struct nf_conntrack_helper *helper;
48
49 /* need nf_conntrack_lock to assure that helper exists until
50 * try_module_get() is called */
51 read_lock_bh(&nf_conntrack_lock);
52
53 helper = __nf_ct_helper_find(tuple);
54 if (helper) {
55 /* need to increase module usage count to assure helper will
56 * not go away while the caller is e.g. busy putting a
57 * conntrack in the hash that uses the helper */
58 if (!try_module_get(helper->me))
59 helper = NULL;
60 }
61
62 read_unlock_bh(&nf_conntrack_lock);
63
64 return helper;
65}
66EXPORT_SYMBOL_GPL(nf_ct_helper_find_get);
67
68void nf_ct_helper_put(struct nf_conntrack_helper *helper)
69{
70 module_put(helper->me);
71}
72EXPORT_SYMBOL_GPL(nf_ct_helper_put);
73
74struct nf_conntrack_helper *
75__nf_conntrack_helper_find_byname(const char *name)
76{
77 struct nf_conntrack_helper *h;
78
79 list_for_each_entry(h, &helpers, list) {
80 if (!strcmp(h->name, name))
81 return h;
82 }
83
84 return NULL;
85}
86EXPORT_SYMBOL_GPL(__nf_conntrack_helper_find_byname);
87
88static inline int unhelp(struct nf_conntrack_tuple_hash *i,
89 const struct nf_conntrack_helper *me)
90{
91 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(i);
92 struct nf_conn_help *help = nfct_help(ct);
93
94 if (help && help->helper == me) {
95 nf_conntrack_event(IPCT_HELPER, ct);
96 help->helper = NULL;
97 }
98 return 0;
99}
100
101int nf_conntrack_helper_register(struct nf_conntrack_helper *me)
102{
103 int size, ret;
104
105 BUG_ON(me->timeout == 0);
106
107 size = ALIGN(sizeof(struct nf_conn), __alignof__(struct nf_conn_help)) +
108 sizeof(struct nf_conn_help);
109 ret = nf_conntrack_register_cache(NF_CT_F_HELP, "nf_conntrack:help",
110 size);
111 if (ret < 0) {
112 printk(KERN_ERR "nf_conntrack_helper_register: Unable to create slab cache for conntracks\n");
113 return ret;
114 }
115 write_lock_bh(&nf_conntrack_lock);
116 list_add(&me->list, &helpers);
117 write_unlock_bh(&nf_conntrack_lock);
118
119 return 0;
120}
121EXPORT_SYMBOL_GPL(nf_conntrack_helper_register);
122
123void nf_conntrack_helper_unregister(struct nf_conntrack_helper *me)
124{
125 unsigned int i;
126 struct nf_conntrack_tuple_hash *h;
127 struct nf_conntrack_expect *exp, *tmp;
128
129 /* Need write lock here, to delete helper. */
130 write_lock_bh(&nf_conntrack_lock);
131 list_del(&me->list);
132
133 /* Get rid of expectations */
134 list_for_each_entry_safe(exp, tmp, &nf_conntrack_expect_list, list) {
135 struct nf_conn_help *help = nfct_help(exp->master);
136 if ((help->helper == me || exp->helper == me) &&
137 del_timer(&exp->timeout)) {
138 nf_ct_unlink_expect(exp);
139 nf_conntrack_expect_put(exp);
140 }
141 }
142
143 /* Get rid of expecteds, set helpers to NULL. */
144 list_for_each_entry(h, &unconfirmed, list)
145 unhelp(h, me);
146 for (i = 0; i < nf_conntrack_htable_size; i++) {
147 list_for_each_entry(h, &nf_conntrack_hash[i], list)
148 unhelp(h, me);
149 }
150 write_unlock_bh(&nf_conntrack_lock);
151
152 /* Someone could be still looking at the helper in a bh. */
153 synchronize_net();
154}
155EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);
diff --git a/net/netfilter/nf_conntrack_irc.c b/net/netfilter/nf_conntrack_irc.c
new file mode 100644
index 000000000000..ed01db634399
--- /dev/null
+++ b/net/netfilter/nf_conntrack_irc.c
@@ -0,0 +1,281 @@
1/* IRC extension for IP connection tracking, Version 1.21
2 * (C) 2000-2002 by Harald Welte <laforge@gnumonks.org>
3 * based on RR's ip_conntrack_ftp.c
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#include <linux/module.h>
12#include <linux/moduleparam.h>
13#include <linux/skbuff.h>
14#include <linux/in.h>
15#include <linux/tcp.h>
16#include <linux/netfilter.h>
17
18#include <net/netfilter/nf_conntrack.h>
19#include <net/netfilter/nf_conntrack_expect.h>
20#include <net/netfilter/nf_conntrack_helper.h>
21#include <linux/netfilter/nf_conntrack_irc.h>
22
23#define MAX_PORTS 8
24static unsigned short ports[MAX_PORTS];
25static int ports_c;
26static unsigned int max_dcc_channels = 8;
27static unsigned int dcc_timeout __read_mostly = 300;
28/* This is slow, but it's simple. --RR */
29static char *irc_buffer;
30static DEFINE_SPINLOCK(irc_buffer_lock);
31
32unsigned int (*nf_nat_irc_hook)(struct sk_buff **pskb,
33 enum ip_conntrack_info ctinfo,
34 unsigned int matchoff,
35 unsigned int matchlen,
36 struct nf_conntrack_expect *exp) __read_mostly;
37EXPORT_SYMBOL_GPL(nf_nat_irc_hook);
38
39MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
40MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
41MODULE_LICENSE("GPL");
42MODULE_ALIAS("ip_conntrack_irc");
43
44module_param_array(ports, ushort, &ports_c, 0400);
45MODULE_PARM_DESC(ports, "port numbers of IRC servers");
46module_param(max_dcc_channels, uint, 0400);
47MODULE_PARM_DESC(max_dcc_channels, "max number of expected DCC channels per "
48 "IRC session");
49module_param(dcc_timeout, uint, 0400);
50MODULE_PARM_DESC(dcc_timeout, "timeout on for unestablished DCC channels");
51
52static const char *dccprotos[] = {
53 "SEND ", "CHAT ", "MOVE ", "TSEND ", "SCHAT "
54};
55
56#define MINMATCHLEN 5
57
58#if 0
59#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s:" format, \
60 __FILE__, __FUNCTION__ , ## args)
61#else
62#define DEBUGP(format, args...)
63#endif
64
65/* tries to get the ip_addr and port out of a dcc command
66 * return value: -1 on failure, 0 on success
67 * data pointer to first byte of DCC command data
68 * data_end pointer to last byte of dcc command data
69 * ip returns parsed ip of dcc command
70 * port returns parsed port of dcc command
71 * ad_beg_p returns pointer to first byte of addr data
72 * ad_end_p returns pointer to last byte of addr data
73 */
74static int parse_dcc(char *data, char *data_end, u_int32_t *ip,
75 u_int16_t *port, char **ad_beg_p, char **ad_end_p)
76{
77 /* at least 12: "AAAAAAAA P\1\n" */
78 while (*data++ != ' ')
79 if (data > data_end - 12)
80 return -1;
81
82 *ad_beg_p = data;
83 *ip = simple_strtoul(data, &data, 10);
84
85 /* skip blanks between ip and port */
86 while (*data == ' ') {
87 if (data >= data_end)
88 return -1;
89 data++;
90 }
91
92 *port = simple_strtoul(data, &data, 10);
93 *ad_end_p = data;
94
95 return 0;
96}
97
98static int help(struct sk_buff **pskb, unsigned int protoff,
99 struct nf_conn *ct, enum ip_conntrack_info ctinfo)
100{
101 unsigned int dataoff;
102 struct tcphdr _tcph, *th;
103 char *data, *data_limit, *ib_ptr;
104 int dir = CTINFO2DIR(ctinfo);
105 struct nf_conntrack_expect *exp;
106 struct nf_conntrack_tuple *tuple;
107 u_int32_t dcc_ip;
108 u_int16_t dcc_port;
109 __be16 port;
110 int i, ret = NF_ACCEPT;
111 char *addr_beg_p, *addr_end_p;
112 typeof(nf_nat_irc_hook) nf_nat_irc;
113
114 /* If packet is coming from IRC server */
115 if (dir == IP_CT_DIR_REPLY)
116 return NF_ACCEPT;
117
118 /* Until there's been traffic both ways, don't look in packets. */
119 if (ctinfo != IP_CT_ESTABLISHED &&
120 ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY)
121 return NF_ACCEPT;
122
123 /* Not a full tcp header? */
124 th = skb_header_pointer(*pskb, protoff, sizeof(_tcph), &_tcph);
125 if (th == NULL)
126 return NF_ACCEPT;
127
128 /* No data? */
129 dataoff = protoff + th->doff*4;
130 if (dataoff >= (*pskb)->len)
131 return NF_ACCEPT;
132
133 spin_lock_bh(&irc_buffer_lock);
134 ib_ptr = skb_header_pointer(*pskb, dataoff, (*pskb)->len - dataoff,
135 irc_buffer);
136 BUG_ON(ib_ptr == NULL);
137
138 data = ib_ptr;
139 data_limit = ib_ptr + (*pskb)->len - dataoff;
140
141 /* strlen("\1DCC SENT t AAAAAAAA P\1\n")=24
142 * 5+MINMATCHLEN+strlen("t AAAAAAAA P\1\n")=14 */
143 while (data < data_limit - (19 + MINMATCHLEN)) {
144 if (memcmp(data, "\1DCC ", 5)) {
145 data++;
146 continue;
147 }
148 data += 5;
149 /* we have at least (19+MINMATCHLEN)-5 bytes valid data left */
150
151 DEBUGP("DCC found in master %u.%u.%u.%u:%u %u.%u.%u.%u:%u...\n",
152 NIPQUAD(iph->saddr), ntohs(th->source),
153 NIPQUAD(iph->daddr), ntohs(th->dest));
154
155 for (i = 0; i < ARRAY_SIZE(dccprotos); i++) {
156 if (memcmp(data, dccprotos[i], strlen(dccprotos[i]))) {
157 /* no match */
158 continue;
159 }
160 data += strlen(dccprotos[i]);
161 DEBUGP("DCC %s detected\n", dccprotos[i]);
162
163 /* we have at least
164 * (19+MINMATCHLEN)-5-dccprotos[i].matchlen bytes valid
165 * data left (== 14/13 bytes) */
166 if (parse_dcc((char *)data, data_limit, &dcc_ip,
167 &dcc_port, &addr_beg_p, &addr_end_p)) {
168 DEBUGP("unable to parse dcc command\n");
169 continue;
170 }
171 DEBUGP("DCC bound ip/port: %u.%u.%u.%u:%u\n",
172 HIPQUAD(dcc_ip), dcc_port);
173
174 /* dcc_ip can be the internal OR external (NAT'ed) IP */
175 tuple = &ct->tuplehash[dir].tuple;
176 if (tuple->src.u3.ip != htonl(dcc_ip) &&
177 tuple->dst.u3.ip != htonl(dcc_ip)) {
178 if (net_ratelimit())
179 printk(KERN_WARNING
180 "Forged DCC command from "
181 "%u.%u.%u.%u: %u.%u.%u.%u:%u\n",
182 NIPQUAD(tuple->src.u3.ip),
183 HIPQUAD(dcc_ip), dcc_port);
184 continue;
185 }
186
187 exp = nf_conntrack_expect_alloc(ct);
188 if (exp == NULL) {
189 ret = NF_DROP;
190 goto out;
191 }
192 tuple = &ct->tuplehash[!dir].tuple;
193 port = htons(dcc_port);
194 nf_conntrack_expect_init(exp, tuple->src.l3num,
195 NULL, &tuple->dst.u3,
196 IPPROTO_TCP, NULL, &port);
197
198 nf_nat_irc = rcu_dereference(nf_nat_irc_hook);
199 if (nf_nat_irc && ct->status & IPS_NAT_MASK)
200 ret = nf_nat_irc(pskb, ctinfo,
201 addr_beg_p - ib_ptr,
202 addr_end_p - addr_beg_p,
203 exp);
204 else if (nf_conntrack_expect_related(exp) != 0)
205 ret = NF_DROP;
206 nf_conntrack_expect_put(exp);
207 goto out;
208 }
209 }
210 out:
211 spin_unlock_bh(&irc_buffer_lock);
212 return ret;
213}
214
215static struct nf_conntrack_helper irc[MAX_PORTS] __read_mostly;
216static char irc_names[MAX_PORTS][sizeof("irc-65535")] __read_mostly;
217
218static void nf_conntrack_irc_fini(void);
219
220static int __init nf_conntrack_irc_init(void)
221{
222 int i, ret;
223 char *tmpname;
224
225 if (max_dcc_channels < 1) {
226 printk("nf_ct_irc: max_dcc_channels must not be zero\n");
227 return -EINVAL;
228 }
229
230 irc_buffer = kmalloc(65536, GFP_KERNEL);
231 if (!irc_buffer)
232 return -ENOMEM;
233
234 /* If no port given, default to standard irc port */
235 if (ports_c == 0)
236 ports[ports_c++] = IRC_PORT;
237
238 for (i = 0; i < ports_c; i++) {
239 irc[i].tuple.src.l3num = AF_INET;
240 irc[i].tuple.src.u.tcp.port = htons(ports[i]);
241 irc[i].tuple.dst.protonum = IPPROTO_TCP;
242 irc[i].mask.src.l3num = 0xFFFF;
243 irc[i].mask.src.u.tcp.port = htons(0xFFFF);
244 irc[i].mask.dst.protonum = 0xFF;
245 irc[i].max_expected = max_dcc_channels;
246 irc[i].timeout = dcc_timeout;
247 irc[i].me = THIS_MODULE;
248 irc[i].help = help;
249
250 tmpname = &irc_names[i][0];
251 if (ports[i] == IRC_PORT)
252 sprintf(tmpname, "irc");
253 else
254 sprintf(tmpname, "irc-%u", i);
255 irc[i].name = tmpname;
256
257 ret = nf_conntrack_helper_register(&irc[i]);
258 if (ret) {
259 printk("nf_ct_irc: failed to register helper "
260 "for pf: %u port: %u\n",
261 irc[i].tuple.src.l3num, ports[i]);
262 nf_conntrack_irc_fini();
263 return ret;
264 }
265 }
266 return 0;
267}
268
269/* This function is intentionally _NOT_ defined as __exit, because
270 * it is needed by the init function */
271static void nf_conntrack_irc_fini(void)
272{
273 int i;
274
275 for (i = 0; i < ports_c; i++)
276 nf_conntrack_helper_unregister(&irc[i]);
277 kfree(irc_buffer);
278}
279
280module_init(nf_conntrack_irc_init);
281module_exit(nf_conntrack_irc_fini);
diff --git a/net/netfilter/nf_conntrack_l3proto_generic.c b/net/netfilter/nf_conntrack_l3proto_generic.c
index 21e0bc91cf23..a3d31c3ac8e6 100644
--- a/net/netfilter/nf_conntrack_l3proto_generic.c
+++ b/net/netfilter/nf_conntrack_l3proto_generic.c
@@ -26,7 +26,7 @@
26 26
27#include <linux/netfilter_ipv4.h> 27#include <linux/netfilter_ipv4.h>
28#include <net/netfilter/nf_conntrack.h> 28#include <net/netfilter/nf_conntrack.h>
29#include <net/netfilter/nf_conntrack_protocol.h> 29#include <net/netfilter/nf_conntrack_l4proto.h>
30#include <net/netfilter/nf_conntrack_l3proto.h> 30#include <net/netfilter/nf_conntrack_l3proto.h>
31#include <net/netfilter/nf_conntrack_core.h> 31#include <net/netfilter/nf_conntrack_core.h>
32#include <net/netfilter/ipv4/nf_conntrack_ipv4.h> 32#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
@@ -37,8 +37,6 @@
37#define DEBUGP(format, args...) 37#define DEBUGP(format, args...)
38#endif 38#endif
39 39
40DECLARE_PER_CPU(struct nf_conntrack_stat, nf_conntrack_stat);
41
42static int generic_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff, 40static int generic_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff,
43 struct nf_conntrack_tuple *tuple) 41 struct nf_conntrack_tuple *tuple)
44{ 42{
@@ -84,7 +82,7 @@ static u_int32_t generic_get_features(const struct nf_conntrack_tuple *tuple)
84 return NF_CT_F_BASIC; 82 return NF_CT_F_BASIC;
85} 83}
86 84
87struct nf_conntrack_l3proto nf_conntrack_generic_l3proto = { 85struct nf_conntrack_l3proto nf_conntrack_l3proto_generic = {
88 .l3proto = PF_UNSPEC, 86 .l3proto = PF_UNSPEC,
89 .name = "unknown", 87 .name = "unknown",
90 .pkt_to_tuple = generic_pkt_to_tuple, 88 .pkt_to_tuple = generic_pkt_to_tuple,
@@ -94,3 +92,4 @@ struct nf_conntrack_l3proto nf_conntrack_generic_l3proto = {
94 .prepare = generic_prepare, 92 .prepare = generic_prepare,
95 .get_features = generic_get_features, 93 .get_features = generic_get_features,
96}; 94};
95EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_generic);
diff --git a/net/netfilter/nf_conntrack_netbios_ns.c b/net/netfilter/nf_conntrack_netbios_ns.c
new file mode 100644
index 000000000000..a5b234e444dc
--- /dev/null
+++ b/net/netfilter/nf_conntrack_netbios_ns.c
@@ -0,0 +1,126 @@
1/*
2 * NetBIOS name service broadcast connection tracking helper
3 *
4 * (c) 2005 Patrick McHardy <kaber@trash.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11/*
12 * This helper tracks locally originating NetBIOS name service
13 * requests by issuing permanent expectations (valid until
14 * timing out) matching all reply connections from the
15 * destination network. The only NetBIOS specific thing is
16 * actually the port number.
17 */
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <linux/init.h>
21#include <linux/skbuff.h>
22#include <linux/netdevice.h>
23#include <linux/inetdevice.h>
24#include <linux/if_addr.h>
25#include <linux/in.h>
26#include <linux/ip.h>
27#include <linux/netfilter.h>
28#include <net/route.h>
29
30#include <net/netfilter/nf_conntrack.h>
31#include <net/netfilter/nf_conntrack_helper.h>
32#include <net/netfilter/nf_conntrack_expect.h>
33
34#define NMBD_PORT 137
35
36MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
37MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper");
38MODULE_LICENSE("GPL");
39MODULE_ALIAS("ip_conntrack_netbios_ns");
40
41static unsigned int timeout __read_mostly = 3;
42module_param(timeout, uint, 0400);
43MODULE_PARM_DESC(timeout, "timeout for master connection/replies in seconds");
44
45static int help(struct sk_buff **pskb, unsigned int protoff,
46 struct nf_conn *ct, enum ip_conntrack_info ctinfo)
47{
48 struct nf_conntrack_expect *exp;
49 struct iphdr *iph = (*pskb)->nh.iph;
50 struct rtable *rt = (struct rtable *)(*pskb)->dst;
51 struct in_device *in_dev;
52 __be32 mask = 0;
53
54 /* we're only interested in locally generated packets */
55 if ((*pskb)->sk == NULL)
56 goto out;
57 if (rt == NULL || !(rt->rt_flags & RTCF_BROADCAST))
58 goto out;
59 if (CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL)
60 goto out;
61
62 rcu_read_lock();
63 in_dev = __in_dev_get_rcu(rt->u.dst.dev);
64 if (in_dev != NULL) {
65 for_primary_ifa(in_dev) {
66 if (ifa->ifa_broadcast == iph->daddr) {
67 mask = ifa->ifa_mask;
68 break;
69 }
70 } endfor_ifa(in_dev);
71 }
72 rcu_read_unlock();
73
74 if (mask == 0)
75 goto out;
76
77 exp = nf_conntrack_expect_alloc(ct);
78 if (exp == NULL)
79 goto out;
80
81 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
82 exp->tuple.src.u.udp.port = htons(NMBD_PORT);
83
84 exp->mask.src.u3.ip = mask;
85 exp->mask.src.u.udp.port = htons(0xFFFF);
86 exp->mask.dst.u3.ip = htonl(0xFFFFFFFF);
87 exp->mask.dst.u.udp.port = htons(0xFFFF);
88 exp->mask.dst.protonum = 0xFF;
89
90 exp->expectfn = NULL;
91 exp->flags = NF_CT_EXPECT_PERMANENT;
92
93 nf_conntrack_expect_related(exp);
94 nf_conntrack_expect_put(exp);
95
96 nf_ct_refresh(ct, *pskb, timeout * HZ);
97out:
98 return NF_ACCEPT;
99}
100
101static struct nf_conntrack_helper helper __read_mostly = {
102 .name = "netbios-ns",
103 .tuple.src.l3num = AF_INET,
104 .tuple.src.u.udp.port = __constant_htons(NMBD_PORT),
105 .tuple.dst.protonum = IPPROTO_UDP,
106 .mask.src.l3num = 0xFFFF,
107 .mask.src.u.udp.port = __constant_htons(0xFFFF),
108 .mask.dst.protonum = 0xFF,
109 .max_expected = 1,
110 .me = THIS_MODULE,
111 .help = help,
112};
113
114static int __init nf_conntrack_netbios_ns_init(void)
115{
116 helper.timeout = timeout;
117 return nf_conntrack_helper_register(&helper);
118}
119
120static void __exit nf_conntrack_netbios_ns_fini(void)
121{
122 nf_conntrack_helper_unregister(&helper);
123}
124
125module_init(nf_conntrack_netbios_ns_init);
126module_exit(nf_conntrack_netbios_ns_fini);
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index bd0156a28ecd..bd1d2de75e45 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -35,10 +35,15 @@
35#include <linux/netfilter.h> 35#include <linux/netfilter.h>
36#include <net/netfilter/nf_conntrack.h> 36#include <net/netfilter/nf_conntrack.h>
37#include <net/netfilter/nf_conntrack_core.h> 37#include <net/netfilter/nf_conntrack_core.h>
38#include <net/netfilter/nf_conntrack_expect.h>
38#include <net/netfilter/nf_conntrack_helper.h> 39#include <net/netfilter/nf_conntrack_helper.h>
39#include <net/netfilter/nf_conntrack_l3proto.h> 40#include <net/netfilter/nf_conntrack_l3proto.h>
40#include <net/netfilter/nf_conntrack_protocol.h> 41#include <net/netfilter/nf_conntrack_l4proto.h>
41#include <linux/netfilter_ipv4/ip_nat_protocol.h> 42#include <net/netfilter/nf_conntrack_tuple.h>
43#ifdef CONFIG_NF_NAT_NEEDED
44#include <net/netfilter/nf_nat_core.h>
45#include <net/netfilter/nf_nat_protocol.h>
46#endif
42 47
43#include <linux/netfilter/nfnetlink.h> 48#include <linux/netfilter/nfnetlink.h>
44#include <linux/netfilter/nfnetlink_conntrack.h> 49#include <linux/netfilter/nfnetlink_conntrack.h>
@@ -50,15 +55,15 @@ static char __initdata version[] = "0.93";
50static inline int 55static inline int
51ctnetlink_dump_tuples_proto(struct sk_buff *skb, 56ctnetlink_dump_tuples_proto(struct sk_buff *skb,
52 const struct nf_conntrack_tuple *tuple, 57 const struct nf_conntrack_tuple *tuple,
53 struct nf_conntrack_protocol *proto) 58 struct nf_conntrack_l4proto *l4proto)
54{ 59{
55 int ret = 0; 60 int ret = 0;
56 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO); 61 struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
57 62
58 NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum); 63 NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
59 64
60 if (likely(proto->tuple_to_nfattr)) 65 if (likely(l4proto->tuple_to_nfattr))
61 ret = proto->tuple_to_nfattr(skb, tuple); 66 ret = l4proto->tuple_to_nfattr(skb, tuple);
62 67
63 NFA_NEST_END(skb, nest_parms); 68 NFA_NEST_END(skb, nest_parms);
64 69
@@ -93,7 +98,7 @@ ctnetlink_dump_tuples(struct sk_buff *skb,
93{ 98{
94 int ret; 99 int ret;
95 struct nf_conntrack_l3proto *l3proto; 100 struct nf_conntrack_l3proto *l3proto;
96 struct nf_conntrack_protocol *proto; 101 struct nf_conntrack_l4proto *l4proto;
97 102
98 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num); 103 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
99 ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto); 104 ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto);
@@ -102,9 +107,9 @@ ctnetlink_dump_tuples(struct sk_buff *skb,
102 if (unlikely(ret < 0)) 107 if (unlikely(ret < 0))
103 return ret; 108 return ret;
104 109
105 proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum); 110 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
106 ret = ctnetlink_dump_tuples_proto(skb, tuple, proto); 111 ret = ctnetlink_dump_tuples_proto(skb, tuple, l4proto);
107 nf_ct_proto_put(proto); 112 nf_ct_l4proto_put(l4proto);
108 113
109 return ret; 114 return ret;
110} 115}
@@ -112,7 +117,7 @@ ctnetlink_dump_tuples(struct sk_buff *skb,
112static inline int 117static inline int
113ctnetlink_dump_status(struct sk_buff *skb, const struct nf_conn *ct) 118ctnetlink_dump_status(struct sk_buff *skb, const struct nf_conn *ct)
114{ 119{
115 u_int32_t status = htonl((u_int32_t) ct->status); 120 __be32 status = htonl((u_int32_t) ct->status);
116 NFA_PUT(skb, CTA_STATUS, sizeof(status), &status); 121 NFA_PUT(skb, CTA_STATUS, sizeof(status), &status);
117 return 0; 122 return 0;
118 123
@@ -124,7 +129,7 @@ static inline int
124ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct) 129ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct)
125{ 130{
126 long timeout_l = ct->timeout.expires - jiffies; 131 long timeout_l = ct->timeout.expires - jiffies;
127 u_int32_t timeout; 132 __be32 timeout;
128 133
129 if (timeout_l < 0) 134 if (timeout_l < 0)
130 timeout = 0; 135 timeout = 0;
@@ -141,26 +146,27 @@ nfattr_failure:
141static inline int 146static inline int
142ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct nf_conn *ct) 147ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct nf_conn *ct)
143{ 148{
144 struct nf_conntrack_protocol *proto = nf_ct_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num, ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum); 149 struct nf_conntrack_l4proto *l4proto = nf_ct_l4proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num, ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
145 struct nfattr *nest_proto; 150 struct nfattr *nest_proto;
146 int ret; 151 int ret;
147 152
148 if (!proto->to_nfattr) { 153 if (!l4proto->to_nfattr) {
149 nf_ct_proto_put(proto); 154 nf_ct_l4proto_put(l4proto);
150 return 0; 155 return 0;
151 } 156 }
152 157
153 nest_proto = NFA_NEST(skb, CTA_PROTOINFO); 158 nest_proto = NFA_NEST(skb, CTA_PROTOINFO);
154 159
155 ret = proto->to_nfattr(skb, nest_proto, ct); 160 ret = l4proto->to_nfattr(skb, nest_proto, ct);
156 161
157 nf_ct_proto_put(proto); 162 nf_ct_l4proto_put(l4proto);
158 163
159 NFA_NEST_END(skb, nest_proto); 164 NFA_NEST_END(skb, nest_proto);
160 165
161 return ret; 166 return ret;
162 167
163nfattr_failure: 168nfattr_failure:
169 nf_ct_l4proto_put(l4proto);
164 return -1; 170 return -1;
165} 171}
166 172
@@ -194,7 +200,7 @@ ctnetlink_dump_counters(struct sk_buff *skb, const struct nf_conn *ct,
194{ 200{
195 enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG; 201 enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG;
196 struct nfattr *nest_count = NFA_NEST(skb, type); 202 struct nfattr *nest_count = NFA_NEST(skb, type);
197 u_int32_t tmp; 203 __be32 tmp;
198 204
199 tmp = htonl(ct->counters[dir].packets); 205 tmp = htonl(ct->counters[dir].packets);
200 NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp); 206 NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp);
@@ -217,7 +223,7 @@ nfattr_failure:
217static inline int 223static inline int
218ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct) 224ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
219{ 225{
220 u_int32_t mark = htonl(ct->mark); 226 __be32 mark = htonl(ct->mark);
221 227
222 NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark); 228 NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark);
223 return 0; 229 return 0;
@@ -232,7 +238,7 @@ nfattr_failure:
232static inline int 238static inline int
233ctnetlink_dump_id(struct sk_buff *skb, const struct nf_conn *ct) 239ctnetlink_dump_id(struct sk_buff *skb, const struct nf_conn *ct)
234{ 240{
235 u_int32_t id = htonl(ct->id); 241 __be32 id = htonl(ct->id);
236 NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id); 242 NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id);
237 return 0; 243 return 0;
238 244
@@ -243,7 +249,7 @@ nfattr_failure:
243static inline int 249static inline int
244ctnetlink_dump_use(struct sk_buff *skb, const struct nf_conn *ct) 250ctnetlink_dump_use(struct sk_buff *skb, const struct nf_conn *ct)
245{ 251{
246 u_int32_t use = htonl(atomic_read(&ct->ct_general.use)); 252 __be32 use = htonl(atomic_read(&ct->ct_general.use));
247 253
248 NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use); 254 NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use);
249 return 0; 255 return 0;
@@ -329,8 +335,6 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
329 } else if (events & (IPCT_NEW | IPCT_RELATED)) { 335 } else if (events & (IPCT_NEW | IPCT_RELATED)) {
330 type = IPCTNL_MSG_CT_NEW; 336 type = IPCTNL_MSG_CT_NEW;
331 flags = NLM_F_CREATE|NLM_F_EXCL; 337 flags = NLM_F_CREATE|NLM_F_EXCL;
332 /* dump everything */
333 events = ~0UL;
334 group = NFNLGRP_CONNTRACK_NEW; 338 group = NFNLGRP_CONNTRACK_NEW;
335 } else if (events & (IPCT_STATUS | IPCT_PROTOINFO)) { 339 } else if (events & (IPCT_STATUS | IPCT_PROTOINFO)) {
336 type = IPCTNL_MSG_CT_NEW; 340 type = IPCTNL_MSG_CT_NEW;
@@ -365,28 +369,35 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
365 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0) 369 if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0)
366 goto nfattr_failure; 370 goto nfattr_failure;
367 NFA_NEST_END(skb, nest_parms); 371 NFA_NEST_END(skb, nest_parms);
368
369 /* NAT stuff is now a status flag */
370 if ((events & IPCT_STATUS || events & IPCT_NATINFO)
371 && ctnetlink_dump_status(skb, ct) < 0)
372 goto nfattr_failure;
373 if (events & IPCT_REFRESH
374 && ctnetlink_dump_timeout(skb, ct) < 0)
375 goto nfattr_failure;
376 if (events & IPCT_PROTOINFO
377 && ctnetlink_dump_protoinfo(skb, ct) < 0)
378 goto nfattr_failure;
379 if (events & IPCT_HELPINFO
380 && ctnetlink_dump_helpinfo(skb, ct) < 0)
381 goto nfattr_failure;
382 372
383 if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || 373 if (events & IPCT_DESTROY) {
384 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0) 374 if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
385 goto nfattr_failure; 375 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0)
376 goto nfattr_failure;
377 } else {
378 if (ctnetlink_dump_status(skb, ct) < 0)
379 goto nfattr_failure;
386 380
387 if (events & IPCT_MARK 381 if (ctnetlink_dump_timeout(skb, ct) < 0)
388 && ctnetlink_dump_mark(skb, ct) < 0) 382 goto nfattr_failure;
389 goto nfattr_failure; 383
384 if (events & IPCT_PROTOINFO
385 && ctnetlink_dump_protoinfo(skb, ct) < 0)
386 goto nfattr_failure;
387
388 if ((events & IPCT_HELPER || nfct_help(ct))
389 && ctnetlink_dump_helpinfo(skb, ct) < 0)
390 goto nfattr_failure;
391
392 if ((events & IPCT_MARK || ct->mark)
393 && ctnetlink_dump_mark(skb, ct) < 0)
394 goto nfattr_failure;
395
396 if (events & IPCT_COUNTER_FILLING &&
397 (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
398 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0))
399 goto nfattr_failure;
400 }
390 401
391 nlh->nlmsg_len = skb->tail - b; 402 nlh->nlmsg_len = skb->tail - b;
392 nfnetlink_send(skb, 0, group, 0); 403 nfnetlink_send(skb, 0, group, 0);
@@ -423,7 +434,7 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
423restart: 434restart:
424 list_for_each_prev(i, &nf_conntrack_hash[cb->args[0]]) { 435 list_for_each_prev(i, &nf_conntrack_hash[cb->args[0]]) {
425 h = (struct nf_conntrack_tuple_hash *) i; 436 h = (struct nf_conntrack_tuple_hash *) i;
426 if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) 437 if (NF_CT_DIRECTION(h) != IP_CT_DIR_ORIGINAL)
427 continue; 438 continue;
428 ct = nf_ct_tuplehash_to_ctrack(h); 439 ct = nf_ct_tuplehash_to_ctrack(h);
429 /* Dump entries of a given L3 protocol number. 440 /* Dump entries of a given L3 protocol number.
@@ -491,7 +502,7 @@ ctnetlink_parse_tuple_proto(struct nfattr *attr,
491 struct nf_conntrack_tuple *tuple) 502 struct nf_conntrack_tuple *tuple)
492{ 503{
493 struct nfattr *tb[CTA_PROTO_MAX]; 504 struct nfattr *tb[CTA_PROTO_MAX];
494 struct nf_conntrack_protocol *proto; 505 struct nf_conntrack_l4proto *l4proto;
495 int ret = 0; 506 int ret = 0;
496 507
497 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr); 508 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr);
@@ -503,12 +514,12 @@ ctnetlink_parse_tuple_proto(struct nfattr *attr,
503 return -EINVAL; 514 return -EINVAL;
504 tuple->dst.protonum = *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_NUM-1]); 515 tuple->dst.protonum = *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_NUM-1]);
505 516
506 proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum); 517 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
507 518
508 if (likely(proto->nfattr_to_tuple)) 519 if (likely(l4proto->nfattr_to_tuple))
509 ret = proto->nfattr_to_tuple(tb, tuple); 520 ret = l4proto->nfattr_to_tuple(tb, tuple);
510 521
511 nf_ct_proto_put(proto); 522 nf_ct_l4proto_put(l4proto);
512 523
513 return ret; 524 return ret;
514} 525}
@@ -549,28 +560,28 @@ ctnetlink_parse_tuple(struct nfattr *cda[], struct nf_conntrack_tuple *tuple,
549 return 0; 560 return 0;
550} 561}
551 562
552#ifdef CONFIG_IP_NF_NAT_NEEDED 563#ifdef CONFIG_NF_NAT_NEEDED
553static const size_t cta_min_protonat[CTA_PROTONAT_MAX] = { 564static const size_t cta_min_protonat[CTA_PROTONAT_MAX] = {
554 [CTA_PROTONAT_PORT_MIN-1] = sizeof(u_int16_t), 565 [CTA_PROTONAT_PORT_MIN-1] = sizeof(u_int16_t),
555 [CTA_PROTONAT_PORT_MAX-1] = sizeof(u_int16_t), 566 [CTA_PROTONAT_PORT_MAX-1] = sizeof(u_int16_t),
556}; 567};
557 568
558static int ctnetlink_parse_nat_proto(struct nfattr *attr, 569static int nfnetlink_parse_nat_proto(struct nfattr *attr,
559 const struct nf_conn *ct, 570 const struct nf_conn *ct,
560 struct ip_nat_range *range) 571 struct nf_nat_range *range)
561{ 572{
562 struct nfattr *tb[CTA_PROTONAT_MAX]; 573 struct nfattr *tb[CTA_PROTONAT_MAX];
563 struct ip_nat_protocol *npt; 574 struct nf_nat_protocol *npt;
564 575
565 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr); 576 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr);
566 577
567 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat)) 578 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat))
568 return -EINVAL; 579 return -EINVAL;
569 580
570 npt = ip_nat_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum); 581 npt = nf_nat_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
571 582
572 if (!npt->nfattr_to_range) { 583 if (!npt->nfattr_to_range) {
573 ip_nat_proto_put(npt); 584 nf_nat_proto_put(npt);
574 return 0; 585 return 0;
575 } 586 }
576 587
@@ -578,7 +589,7 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
578 if (npt->nfattr_to_range(tb, range) > 0) 589 if (npt->nfattr_to_range(tb, range) > 0)
579 range->flags |= IP_NAT_RANGE_PROTO_SPECIFIED; 590 range->flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
580 591
581 ip_nat_proto_put(npt); 592 nf_nat_proto_put(npt);
582 593
583 return 0; 594 return 0;
584} 595}
@@ -589,8 +600,8 @@ static const size_t cta_min_nat[CTA_NAT_MAX] = {
589}; 600};
590 601
591static inline int 602static inline int
592ctnetlink_parse_nat(struct nfattr *nat, 603nfnetlink_parse_nat(struct nfattr *nat,
593 const struct nf_conn *ct, struct ip_nat_range *range) 604 const struct nf_conn *ct, struct nf_nat_range *range)
594{ 605{
595 struct nfattr *tb[CTA_NAT_MAX]; 606 struct nfattr *tb[CTA_NAT_MAX];
596 int err; 607 int err;
@@ -603,12 +614,12 @@ ctnetlink_parse_nat(struct nfattr *nat,
603 return -EINVAL; 614 return -EINVAL;
604 615
605 if (tb[CTA_NAT_MINIP-1]) 616 if (tb[CTA_NAT_MINIP-1])
606 range->min_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MINIP-1]); 617 range->min_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MINIP-1]);
607 618
608 if (!tb[CTA_NAT_MAXIP-1]) 619 if (!tb[CTA_NAT_MAXIP-1])
609 range->max_ip = range->min_ip; 620 range->max_ip = range->min_ip;
610 else 621 else
611 range->max_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MAXIP-1]); 622 range->max_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MAXIP-1]);
612 623
613 if (range->min_ip) 624 if (range->min_ip)
614 range->flags |= IP_NAT_RANGE_MAP_IPS; 625 range->flags |= IP_NAT_RANGE_MAP_IPS;
@@ -616,7 +627,7 @@ ctnetlink_parse_nat(struct nfattr *nat,
616 if (!tb[CTA_NAT_PROTO-1]) 627 if (!tb[CTA_NAT_PROTO-1])
617 return 0; 628 return 0;
618 629
619 err = ctnetlink_parse_nat_proto(tb[CTA_NAT_PROTO-1], ct, range); 630 err = nfnetlink_parse_nat_proto(tb[CTA_NAT_PROTO-1], ct, range);
620 if (err < 0) 631 if (err < 0)
621 return err; 632 return err;
622 633
@@ -681,7 +692,7 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
681 ct = nf_ct_tuplehash_to_ctrack(h); 692 ct = nf_ct_tuplehash_to_ctrack(h);
682 693
683 if (cda[CTA_ID-1]) { 694 if (cda[CTA_ID-1]) {
684 u_int32_t id = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_ID-1])); 695 u_int32_t id = ntohl(*(__be32 *)NFA_DATA(cda[CTA_ID-1]));
685 if (ct->id != id) { 696 if (ct->id != id) {
686 nf_ct_put(ct); 697 nf_ct_put(ct);
687 return -ENOENT; 698 return -ENOENT;
@@ -751,7 +762,6 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
751 nf_ct_put(ct); 762 nf_ct_put(ct);
752 return -ENOMEM; 763 return -ENOMEM;
753 } 764 }
754 NETLINK_CB(skb2).dst_pid = NETLINK_CB(skb).pid;
755 765
756 err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, 766 err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq,
757 IPCTNL_MSG_CT_NEW, 1, ct); 767 IPCTNL_MSG_CT_NEW, 1, ct);
@@ -775,7 +785,7 @@ static inline int
775ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[]) 785ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[])
776{ 786{
777 unsigned long d; 787 unsigned long d;
778 unsigned status = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1])); 788 unsigned int status = ntohl(*(__be32 *)NFA_DATA(cda[CTA_STATUS-1]));
779 d = ct->status ^ status; 789 d = ct->status ^ status;
780 790
781 if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING)) 791 if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING))
@@ -792,35 +802,35 @@ ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[])
792 return -EINVAL; 802 return -EINVAL;
793 803
794 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) { 804 if (cda[CTA_NAT_SRC-1] || cda[CTA_NAT_DST-1]) {
795#ifndef CONFIG_IP_NF_NAT_NEEDED 805#ifndef CONFIG_NF_NAT_NEEDED
796 return -EINVAL; 806 return -EINVAL;
797#else 807#else
798 struct ip_nat_range range; 808 struct nf_nat_range range;
799 809
800 if (cda[CTA_NAT_DST-1]) { 810 if (cda[CTA_NAT_DST-1]) {
801 if (ctnetlink_parse_nat(cda[CTA_NAT_DST-1], ct, 811 if (nfnetlink_parse_nat(cda[CTA_NAT_DST-1], ct,
802 &range) < 0) 812 &range) < 0)
803 return -EINVAL; 813 return -EINVAL;
804 if (ip_nat_initialized(ct, 814 if (nf_nat_initialized(ct,
805 HOOK2MANIP(NF_IP_PRE_ROUTING))) 815 HOOK2MANIP(NF_IP_PRE_ROUTING)))
806 return -EEXIST; 816 return -EEXIST;
807 ip_nat_setup_info(ct, &range, hooknum); 817 nf_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING);
808 } 818 }
809 if (cda[CTA_NAT_SRC-1]) { 819 if (cda[CTA_NAT_SRC-1]) {
810 if (ctnetlink_parse_nat(cda[CTA_NAT_SRC-1], ct, 820 if (nfnetlink_parse_nat(cda[CTA_NAT_SRC-1], ct,
811 &range) < 0) 821 &range) < 0)
812 return -EINVAL; 822 return -EINVAL;
813 if (ip_nat_initialized(ct, 823 if (nf_nat_initialized(ct,
814 HOOK2MANIP(NF_IP_POST_ROUTING))) 824 HOOK2MANIP(NF_IP_POST_ROUTING)))
815 return -EEXIST; 825 return -EEXIST;
816 ip_nat_setup_info(ct, &range, hooknum); 826 nf_nat_setup_info(ct, &range, NF_IP_POST_ROUTING);
817 } 827 }
818#endif 828#endif
819 } 829 }
820 830
821 /* Be careful here, modifying NAT bits can screw up things, 831 /* Be careful here, modifying NAT bits can screw up things,
822 * so don't let users modify them directly if they don't pass 832 * so don't let users modify them directly if they don't pass
823 * ip_nat_range. */ 833 * nf_nat_range. */
824 ct->status |= status & ~(IPS_NAT_DONE_MASK | IPS_NAT_MASK); 834 ct->status |= status & ~(IPS_NAT_DONE_MASK | IPS_NAT_MASK);
825 return 0; 835 return 0;
826} 836}
@@ -874,7 +884,7 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
874static inline int 884static inline int
875ctnetlink_change_timeout(struct nf_conn *ct, struct nfattr *cda[]) 885ctnetlink_change_timeout(struct nf_conn *ct, struct nfattr *cda[])
876{ 886{
877 u_int32_t timeout = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); 887 u_int32_t timeout = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
878 888
879 if (!del_timer(&ct->timeout)) 889 if (!del_timer(&ct->timeout))
880 return -ETIME; 890 return -ETIME;
@@ -889,18 +899,18 @@ static inline int
889ctnetlink_change_protoinfo(struct nf_conn *ct, struct nfattr *cda[]) 899ctnetlink_change_protoinfo(struct nf_conn *ct, struct nfattr *cda[])
890{ 900{
891 struct nfattr *tb[CTA_PROTOINFO_MAX], *attr = cda[CTA_PROTOINFO-1]; 901 struct nfattr *tb[CTA_PROTOINFO_MAX], *attr = cda[CTA_PROTOINFO-1];
892 struct nf_conntrack_protocol *proto; 902 struct nf_conntrack_l4proto *l4proto;
893 u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum; 903 u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum;
894 u_int16_t l3num = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num; 904 u_int16_t l3num = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
895 int err = 0; 905 int err = 0;
896 906
897 nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr); 907 nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr);
898 908
899 proto = nf_ct_proto_find_get(l3num, npt); 909 l4proto = nf_ct_l4proto_find_get(l3num, npt);
900 910
901 if (proto->from_nfattr) 911 if (l4proto->from_nfattr)
902 err = proto->from_nfattr(tb, ct); 912 err = l4proto->from_nfattr(tb, ct);
903 nf_ct_proto_put(proto); 913 nf_ct_l4proto_put(l4proto);
904 914
905 return err; 915 return err;
906} 916}
@@ -936,7 +946,7 @@ ctnetlink_change_conntrack(struct nf_conn *ct, struct nfattr *cda[])
936 946
937#if defined(CONFIG_NF_CONNTRACK_MARK) 947#if defined(CONFIG_NF_CONNTRACK_MARK)
938 if (cda[CTA_MARK-1]) 948 if (cda[CTA_MARK-1])
939 ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); 949 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
940#endif 950#endif
941 951
942 return 0; 952 return 0;
@@ -949,6 +959,7 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
949{ 959{
950 struct nf_conn *ct; 960 struct nf_conn *ct;
951 int err = -EINVAL; 961 int err = -EINVAL;
962 struct nf_conn_help *help;
952 963
953 ct = nf_conntrack_alloc(otuple, rtuple); 964 ct = nf_conntrack_alloc(otuple, rtuple);
954 if (ct == NULL || IS_ERR(ct)) 965 if (ct == NULL || IS_ERR(ct))
@@ -956,14 +967,16 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
956 967
957 if (!cda[CTA_TIMEOUT-1]) 968 if (!cda[CTA_TIMEOUT-1])
958 goto err; 969 goto err;
959 ct->timeout.expires = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); 970 ct->timeout.expires = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
960 971
961 ct->timeout.expires = jiffies + ct->timeout.expires * HZ; 972 ct->timeout.expires = jiffies + ct->timeout.expires * HZ;
962 ct->status |= IPS_CONFIRMED; 973 ct->status |= IPS_CONFIRMED;
963 974
964 err = ctnetlink_change_status(ct, cda); 975 if (cda[CTA_STATUS-1]) {
965 if (err < 0) 976 err = ctnetlink_change_status(ct, cda);
966 goto err; 977 if (err < 0)
978 goto err;
979 }
967 980
968 if (cda[CTA_PROTOINFO-1]) { 981 if (cda[CTA_PROTOINFO-1]) {
969 err = ctnetlink_change_protoinfo(ct, cda); 982 err = ctnetlink_change_protoinfo(ct, cda);
@@ -973,12 +986,19 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
973 986
974#if defined(CONFIG_NF_CONNTRACK_MARK) 987#if defined(CONFIG_NF_CONNTRACK_MARK)
975 if (cda[CTA_MARK-1]) 988 if (cda[CTA_MARK-1])
976 ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); 989 ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
977#endif 990#endif
978 991
992 help = nfct_help(ct);
993 if (help)
994 help->helper = nf_ct_helper_find_get(rtuple);
995
979 add_timer(&ct->timeout); 996 add_timer(&ct->timeout);
980 nf_conntrack_hash_insert(ct); 997 nf_conntrack_hash_insert(ct);
981 998
999 if (help && help->helper)
1000 nf_ct_helper_put(help->helper);
1001
982 return 0; 1002 return 0;
983 1003
984err: 1004err:
@@ -1072,7 +1092,7 @@ ctnetlink_exp_dump_mask(struct sk_buff *skb,
1072{ 1092{
1073 int ret; 1093 int ret;
1074 struct nf_conntrack_l3proto *l3proto; 1094 struct nf_conntrack_l3proto *l3proto;
1075 struct nf_conntrack_protocol *proto; 1095 struct nf_conntrack_l4proto *l4proto;
1076 struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK); 1096 struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
1077 1097
1078 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num); 1098 l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
@@ -1082,9 +1102,9 @@ ctnetlink_exp_dump_mask(struct sk_buff *skb,
1082 if (unlikely(ret < 0)) 1102 if (unlikely(ret < 0))
1083 goto nfattr_failure; 1103 goto nfattr_failure;
1084 1104
1085 proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum); 1105 l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
1086 ret = ctnetlink_dump_tuples_proto(skb, mask, proto); 1106 ret = ctnetlink_dump_tuples_proto(skb, mask, l4proto);
1087 nf_ct_proto_put(proto); 1107 nf_ct_l4proto_put(l4proto);
1088 if (unlikely(ret < 0)) 1108 if (unlikely(ret < 0))
1089 goto nfattr_failure; 1109 goto nfattr_failure;
1090 1110
@@ -1101,8 +1121,8 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
1101 const struct nf_conntrack_expect *exp) 1121 const struct nf_conntrack_expect *exp)
1102{ 1122{
1103 struct nf_conn *master = exp->master; 1123 struct nf_conn *master = exp->master;
1104 u_int32_t timeout = htonl((exp->timeout.expires - jiffies) / HZ); 1124 __be32 timeout = htonl((exp->timeout.expires - jiffies) / HZ);
1105 u_int32_t id = htonl(exp->id); 1125 __be32 id = htonl(exp->id);
1106 1126
1107 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0) 1127 if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
1108 goto nfattr_failure; 1128 goto nfattr_failure;
@@ -1275,12 +1295,12 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1275 if (err < 0) 1295 if (err < 0)
1276 return err; 1296 return err;
1277 1297
1278 exp = nf_conntrack_expect_find(&tuple); 1298 exp = nf_conntrack_expect_find_get(&tuple);
1279 if (!exp) 1299 if (!exp)
1280 return -ENOENT; 1300 return -ENOENT;
1281 1301
1282 if (cda[CTA_EXPECT_ID-1]) { 1302 if (cda[CTA_EXPECT_ID-1]) {
1283 u_int32_t id = *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); 1303 __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1284 if (exp->id != ntohl(id)) { 1304 if (exp->id != ntohl(id)) {
1285 nf_conntrack_expect_put(exp); 1305 nf_conntrack_expect_put(exp);
1286 return -ENOENT; 1306 return -ENOENT;
@@ -1291,8 +1311,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
1291 skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); 1311 skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
1292 if (!skb2) 1312 if (!skb2)
1293 goto out; 1313 goto out;
1294 NETLINK_CB(skb2).dst_pid = NETLINK_CB(skb).pid; 1314
1295
1296 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, 1315 err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
1297 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, 1316 nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW,
1298 1, exp); 1317 1, exp);
@@ -1331,13 +1350,12 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
1331 return err; 1350 return err;
1332 1351
1333 /* bump usage count to 2 */ 1352 /* bump usage count to 2 */
1334 exp = nf_conntrack_expect_find(&tuple); 1353 exp = nf_conntrack_expect_find_get(&tuple);
1335 if (!exp) 1354 if (!exp)
1336 return -ENOENT; 1355 return -ENOENT;
1337 1356
1338 if (cda[CTA_EXPECT_ID-1]) { 1357 if (cda[CTA_EXPECT_ID-1]) {
1339 u_int32_t id = 1358 __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1340 *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
1341 if (exp->id != ntohl(id)) { 1359 if (exp->id != ntohl(id)) {
1342 nf_conntrack_expect_put(exp); 1360 nf_conntrack_expect_put(exp);
1343 return -ENOENT; 1361 return -ENOENT;
@@ -1433,6 +1451,7 @@ ctnetlink_create_expect(struct nfattr *cda[], u_int8_t u3)
1433 exp->expectfn = NULL; 1451 exp->expectfn = NULL;
1434 exp->flags = 0; 1452 exp->flags = 0;
1435 exp->master = ct; 1453 exp->master = ct;
1454 exp->helper = NULL;
1436 memcpy(&exp->tuple, &tuple, sizeof(struct nf_conntrack_tuple)); 1455 memcpy(&exp->tuple, &tuple, sizeof(struct nf_conntrack_tuple));
1437 memcpy(&exp->mask, &mask, sizeof(struct nf_conntrack_tuple)); 1456 memcpy(&exp->mask, &mask, sizeof(struct nf_conntrack_tuple));
1438 1457
@@ -1529,6 +1548,7 @@ static struct nfnetlink_subsystem ctnl_exp_subsys = {
1529 .cb = ctnl_exp_cb, 1548 .cb = ctnl_exp_cb,
1530}; 1549};
1531 1550
1551MODULE_ALIAS("ip_conntrack_netlink");
1532MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK); 1552MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK);
1533MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK_EXP); 1553MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK_EXP);
1534 1554
diff --git a/net/netfilter/nf_conntrack_pptp.c b/net/netfilter/nf_conntrack_pptp.c
new file mode 100644
index 000000000000..f0ff00e0d052
--- /dev/null
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -0,0 +1,607 @@
1/*
2 * Connection tracking support for PPTP (Point to Point Tunneling Protocol).
3 * PPTP is a a protocol for creating virtual private networks.
4 * It is a specification defined by Microsoft and some vendors
5 * working with Microsoft. PPTP is built on top of a modified
6 * version of the Internet Generic Routing Encapsulation Protocol.
7 * GRE is defined in RFC 1701 and RFC 1702. Documentation of
8 * PPTP can be found in RFC 2637
9 *
10 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
11 *
12 * Development of this code funded by Astaro AG (http://www.astaro.com/)
13 *
14 * Limitations:
15 * - We blindly assume that control connections are always
16 * established in PNS->PAC direction. This is a violation
17 * of RFFC2673
18 * - We can only support one single call within each session
19 * TODO:
20 * - testing of incoming PPTP calls
21 */
22
23#include <linux/module.h>
24#include <linux/skbuff.h>
25#include <linux/in.h>
26#include <linux/tcp.h>
27
28#include <net/netfilter/nf_conntrack.h>
29#include <net/netfilter/nf_conntrack_core.h>
30#include <net/netfilter/nf_conntrack_helper.h>
31#include <linux/netfilter/nf_conntrack_proto_gre.h>
32#include <linux/netfilter/nf_conntrack_pptp.h>
33
34#define NF_CT_PPTP_VERSION "3.1"
35
36MODULE_LICENSE("GPL");
37MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
38MODULE_DESCRIPTION("Netfilter connection tracking helper module for PPTP");
39MODULE_ALIAS("ip_conntrack_pptp");
40
41static DEFINE_SPINLOCK(nf_pptp_lock);
42
43int
44(*nf_nat_pptp_hook_outbound)(struct sk_buff **pskb,
45 struct nf_conn *ct, enum ip_conntrack_info ctinfo,
46 struct PptpControlHeader *ctlh,
47 union pptp_ctrl_union *pptpReq) __read_mostly;
48EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_outbound);
49
50int
51(*nf_nat_pptp_hook_inbound)(struct sk_buff **pskb,
52 struct nf_conn *ct, enum ip_conntrack_info ctinfo,
53 struct PptpControlHeader *ctlh,
54 union pptp_ctrl_union *pptpReq) __read_mostly;
55EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_inbound);
56
57void
58(*nf_nat_pptp_hook_exp_gre)(struct nf_conntrack_expect *expect_orig,
59 struct nf_conntrack_expect *expect_reply)
60 __read_mostly;
61EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_exp_gre);
62
63void
64(*nf_nat_pptp_hook_expectfn)(struct nf_conn *ct,
65 struct nf_conntrack_expect *exp) __read_mostly;
66EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
67
68#if 0
69/* PptpControlMessageType names */
70const char *pptp_msg_name[] = {
71 "UNKNOWN_MESSAGE",
72 "START_SESSION_REQUEST",
73 "START_SESSION_REPLY",
74 "STOP_SESSION_REQUEST",
75 "STOP_SESSION_REPLY",
76 "ECHO_REQUEST",
77 "ECHO_REPLY",
78 "OUT_CALL_REQUEST",
79 "OUT_CALL_REPLY",
80 "IN_CALL_REQUEST",
81 "IN_CALL_REPLY",
82 "IN_CALL_CONNECT",
83 "CALL_CLEAR_REQUEST",
84 "CALL_DISCONNECT_NOTIFY",
85 "WAN_ERROR_NOTIFY",
86 "SET_LINK_INFO"
87};
88EXPORT_SYMBOL(pptp_msg_name);
89#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, __FUNCTION__, ## args)
90#else
91#define DEBUGP(format, args...)
92#endif
93
94#define SECS *HZ
95#define MINS * 60 SECS
96#define HOURS * 60 MINS
97
98#define PPTP_GRE_TIMEOUT (10 MINS)
99#define PPTP_GRE_STREAM_TIMEOUT (5 HOURS)
100
101static void pptp_expectfn(struct nf_conn *ct,
102 struct nf_conntrack_expect *exp)
103{
104 typeof(nf_nat_pptp_hook_expectfn) nf_nat_pptp_expectfn;
105 DEBUGP("increasing timeouts\n");
106
107 /* increase timeout of GRE data channel conntrack entry */
108 ct->proto.gre.timeout = PPTP_GRE_TIMEOUT;
109 ct->proto.gre.stream_timeout = PPTP_GRE_STREAM_TIMEOUT;
110
111 /* Can you see how rusty this code is, compared with the pre-2.6.11
112 * one? That's what happened to my shiny newnat of 2002 ;( -HW */
113
114 rcu_read_lock();
115 nf_nat_pptp_expectfn = rcu_dereference(nf_nat_pptp_hook_expectfn);
116 if (nf_nat_pptp_expectfn && ct->status & IPS_NAT_MASK)
117 nf_nat_pptp_expectfn(ct, exp);
118 else {
119 struct nf_conntrack_tuple inv_t;
120 struct nf_conntrack_expect *exp_other;
121
122 /* obviously this tuple inversion only works until you do NAT */
123 nf_ct_invert_tuplepr(&inv_t, &exp->tuple);
124 DEBUGP("trying to unexpect other dir: ");
125 NF_CT_DUMP_TUPLE(&inv_t);
126
127 exp_other = nf_conntrack_expect_find_get(&inv_t);
128 if (exp_other) {
129 /* delete other expectation. */
130 DEBUGP("found\n");
131 nf_conntrack_unexpect_related(exp_other);
132 nf_conntrack_expect_put(exp_other);
133 } else {
134 DEBUGP("not found\n");
135 }
136 }
137 rcu_read_unlock();
138}
139
140static int destroy_sibling_or_exp(const struct nf_conntrack_tuple *t)
141{
142 struct nf_conntrack_tuple_hash *h;
143 struct nf_conntrack_expect *exp;
144 struct nf_conn *sibling;
145
146 DEBUGP("trying to timeout ct or exp for tuple ");
147 NF_CT_DUMP_TUPLE(t);
148
149 h = nf_conntrack_find_get(t, NULL);
150 if (h) {
151 sibling = nf_ct_tuplehash_to_ctrack(h);
152 DEBUGP("setting timeout of conntrack %p to 0\n", sibling);
153 sibling->proto.gre.timeout = 0;
154 sibling->proto.gre.stream_timeout = 0;
155 if (del_timer(&sibling->timeout))
156 sibling->timeout.function((unsigned long)sibling);
157 nf_ct_put(sibling);
158 return 1;
159 } else {
160 exp = nf_conntrack_expect_find_get(t);
161 if (exp) {
162 DEBUGP("unexpect_related of expect %p\n", exp);
163 nf_conntrack_unexpect_related(exp);
164 nf_conntrack_expect_put(exp);
165 return 1;
166 }
167 }
168 return 0;
169}
170
171/* timeout GRE data connections */
172static void pptp_destroy_siblings(struct nf_conn *ct)
173{
174 struct nf_conn_help *help = nfct_help(ct);
175 struct nf_conntrack_tuple t;
176
177 nf_ct_gre_keymap_destroy(ct);
178
179 /* try original (pns->pac) tuple */
180 memcpy(&t, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple, sizeof(t));
181 t.dst.protonum = IPPROTO_GRE;
182 t.src.u.gre.key = help->help.ct_pptp_info.pns_call_id;
183 t.dst.u.gre.key = help->help.ct_pptp_info.pac_call_id;
184 if (!destroy_sibling_or_exp(&t))
185 DEBUGP("failed to timeout original pns->pac ct/exp\n");
186
187 /* try reply (pac->pns) tuple */
188 memcpy(&t, &ct->tuplehash[IP_CT_DIR_REPLY].tuple, sizeof(t));
189 t.dst.protonum = IPPROTO_GRE;
190 t.src.u.gre.key = help->help.ct_pptp_info.pac_call_id;
191 t.dst.u.gre.key = help->help.ct_pptp_info.pns_call_id;
192 if (!destroy_sibling_or_exp(&t))
193 DEBUGP("failed to timeout reply pac->pns ct/exp\n");
194}
195
196/* expect GRE connections (PNS->PAC and PAC->PNS direction) */
197static int exp_gre(struct nf_conn *ct, __be16 callid, __be16 peer_callid)
198{
199 struct nf_conntrack_expect *exp_orig, *exp_reply;
200 enum ip_conntrack_dir dir;
201 int ret = 1;
202 typeof(nf_nat_pptp_hook_exp_gre) nf_nat_pptp_exp_gre;
203
204 exp_orig = nf_conntrack_expect_alloc(ct);
205 if (exp_orig == NULL)
206 goto out;
207
208 exp_reply = nf_conntrack_expect_alloc(ct);
209 if (exp_reply == NULL)
210 goto out_put_orig;
211
212 /* original direction, PNS->PAC */
213 dir = IP_CT_DIR_ORIGINAL;
214 nf_conntrack_expect_init(exp_orig, ct->tuplehash[dir].tuple.src.l3num,
215 &ct->tuplehash[dir].tuple.src.u3,
216 &ct->tuplehash[dir].tuple.dst.u3,
217 IPPROTO_GRE, &peer_callid, &callid);
218 exp_orig->expectfn = pptp_expectfn;
219
220 /* reply direction, PAC->PNS */
221 dir = IP_CT_DIR_REPLY;
222 nf_conntrack_expect_init(exp_reply, ct->tuplehash[dir].tuple.src.l3num,
223 &ct->tuplehash[dir].tuple.src.u3,
224 &ct->tuplehash[dir].tuple.dst.u3,
225 IPPROTO_GRE, &callid, &peer_callid);
226 exp_reply->expectfn = pptp_expectfn;
227
228 nf_nat_pptp_exp_gre = rcu_dereference(nf_nat_pptp_hook_exp_gre);
229 if (nf_nat_pptp_exp_gre && ct->status & IPS_NAT_MASK)
230 nf_nat_pptp_exp_gre(exp_orig, exp_reply);
231 if (nf_conntrack_expect_related(exp_orig) != 0)
232 goto out_put_both;
233 if (nf_conntrack_expect_related(exp_reply) != 0)
234 goto out_unexpect_orig;
235
236 /* Add GRE keymap entries */
237 if (nf_ct_gre_keymap_add(ct, IP_CT_DIR_ORIGINAL, &exp_orig->tuple) != 0)
238 goto out_unexpect_both;
239 if (nf_ct_gre_keymap_add(ct, IP_CT_DIR_REPLY, &exp_reply->tuple) != 0) {
240 nf_ct_gre_keymap_destroy(ct);
241 goto out_unexpect_both;
242 }
243 ret = 0;
244
245out_put_both:
246 nf_conntrack_expect_put(exp_reply);
247out_put_orig:
248 nf_conntrack_expect_put(exp_orig);
249out:
250 return ret;
251
252out_unexpect_both:
253 nf_conntrack_unexpect_related(exp_reply);
254out_unexpect_orig:
255 nf_conntrack_unexpect_related(exp_orig);
256 goto out_put_both;
257}
258
259static inline int
260pptp_inbound_pkt(struct sk_buff **pskb,
261 struct PptpControlHeader *ctlh,
262 union pptp_ctrl_union *pptpReq,
263 unsigned int reqlen,
264 struct nf_conn *ct,
265 enum ip_conntrack_info ctinfo)
266{
267 struct nf_ct_pptp_master *info = &nfct_help(ct)->help.ct_pptp_info;
268 u_int16_t msg;
269 __be16 cid = 0, pcid = 0;
270 typeof(nf_nat_pptp_hook_inbound) nf_nat_pptp_inbound;
271
272 msg = ntohs(ctlh->messageType);
273 DEBUGP("inbound control message %s\n", pptp_msg_name[msg]);
274
275 switch (msg) {
276 case PPTP_START_SESSION_REPLY:
277 /* server confirms new control session */
278 if (info->sstate < PPTP_SESSION_REQUESTED)
279 goto invalid;
280 if (pptpReq->srep.resultCode == PPTP_START_OK)
281 info->sstate = PPTP_SESSION_CONFIRMED;
282 else
283 info->sstate = PPTP_SESSION_ERROR;
284 break;
285
286 case PPTP_STOP_SESSION_REPLY:
287 /* server confirms end of control session */
288 if (info->sstate > PPTP_SESSION_STOPREQ)
289 goto invalid;
290 if (pptpReq->strep.resultCode == PPTP_STOP_OK)
291 info->sstate = PPTP_SESSION_NONE;
292 else
293 info->sstate = PPTP_SESSION_ERROR;
294 break;
295
296 case PPTP_OUT_CALL_REPLY:
297 /* server accepted call, we now expect GRE frames */
298 if (info->sstate != PPTP_SESSION_CONFIRMED)
299 goto invalid;
300 if (info->cstate != PPTP_CALL_OUT_REQ &&
301 info->cstate != PPTP_CALL_OUT_CONF)
302 goto invalid;
303
304 cid = pptpReq->ocack.callID;
305 pcid = pptpReq->ocack.peersCallID;
306 if (info->pns_call_id != pcid)
307 goto invalid;
308 DEBUGP("%s, CID=%X, PCID=%X\n", pptp_msg_name[msg],
309 ntohs(cid), ntohs(pcid));
310
311 if (pptpReq->ocack.resultCode == PPTP_OUTCALL_CONNECT) {
312 info->cstate = PPTP_CALL_OUT_CONF;
313 info->pac_call_id = cid;
314 exp_gre(ct, cid, pcid);
315 } else
316 info->cstate = PPTP_CALL_NONE;
317 break;
318
319 case PPTP_IN_CALL_REQUEST:
320 /* server tells us about incoming call request */
321 if (info->sstate != PPTP_SESSION_CONFIRMED)
322 goto invalid;
323
324 cid = pptpReq->icreq.callID;
325 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(cid));
326 info->cstate = PPTP_CALL_IN_REQ;
327 info->pac_call_id = cid;
328 break;
329
330 case PPTP_IN_CALL_CONNECT:
331 /* server tells us about incoming call established */
332 if (info->sstate != PPTP_SESSION_CONFIRMED)
333 goto invalid;
334 if (info->cstate != PPTP_CALL_IN_REP &&
335 info->cstate != PPTP_CALL_IN_CONF)
336 goto invalid;
337
338 pcid = pptpReq->iccon.peersCallID;
339 cid = info->pac_call_id;
340
341 if (info->pns_call_id != pcid)
342 goto invalid;
343
344 DEBUGP("%s, PCID=%X\n", pptp_msg_name[msg], ntohs(pcid));
345 info->cstate = PPTP_CALL_IN_CONF;
346
347 /* we expect a GRE connection from PAC to PNS */
348 exp_gre(ct, cid, pcid);
349 break;
350
351 case PPTP_CALL_DISCONNECT_NOTIFY:
352 /* server confirms disconnect */
353 cid = pptpReq->disc.callID;
354 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(cid));
355 info->cstate = PPTP_CALL_NONE;
356
357 /* untrack this call id, unexpect GRE packets */
358 pptp_destroy_siblings(ct);
359 break;
360
361 case PPTP_WAN_ERROR_NOTIFY:
362 case PPTP_ECHO_REQUEST:
363 case PPTP_ECHO_REPLY:
364 /* I don't have to explain these ;) */
365 break;
366
367 default:
368 goto invalid;
369 }
370
371 nf_nat_pptp_inbound = rcu_dereference(nf_nat_pptp_hook_inbound);
372 if (nf_nat_pptp_inbound && ct->status & IPS_NAT_MASK)
373 return nf_nat_pptp_inbound(pskb, ct, ctinfo, ctlh, pptpReq);
374 return NF_ACCEPT;
375
376invalid:
377 DEBUGP("invalid %s: type=%d cid=%u pcid=%u "
378 "cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n",
379 msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] : pptp_msg_name[0],
380 msg, ntohs(cid), ntohs(pcid), info->cstate, info->sstate,
381 ntohs(info->pns_call_id), ntohs(info->pac_call_id));
382 return NF_ACCEPT;
383}
384
385static inline int
386pptp_outbound_pkt(struct sk_buff **pskb,
387 struct PptpControlHeader *ctlh,
388 union pptp_ctrl_union *pptpReq,
389 unsigned int reqlen,
390 struct nf_conn *ct,
391 enum ip_conntrack_info ctinfo)
392{
393 struct nf_ct_pptp_master *info = &nfct_help(ct)->help.ct_pptp_info;
394 u_int16_t msg;
395 __be16 cid = 0, pcid = 0;
396 typeof(nf_nat_pptp_hook_outbound) nf_nat_pptp_outbound;
397
398 msg = ntohs(ctlh->messageType);
399 DEBUGP("outbound control message %s\n", pptp_msg_name[msg]);
400
401 switch (msg) {
402 case PPTP_START_SESSION_REQUEST:
403 /* client requests for new control session */
404 if (info->sstate != PPTP_SESSION_NONE)
405 goto invalid;
406 info->sstate = PPTP_SESSION_REQUESTED;
407 break;
408
409 case PPTP_STOP_SESSION_REQUEST:
410 /* client requests end of control session */
411 info->sstate = PPTP_SESSION_STOPREQ;
412 break;
413
414 case PPTP_OUT_CALL_REQUEST:
415 /* client initiating connection to server */
416 if (info->sstate != PPTP_SESSION_CONFIRMED)
417 goto invalid;
418 info->cstate = PPTP_CALL_OUT_REQ;
419 /* track PNS call id */
420 cid = pptpReq->ocreq.callID;
421 DEBUGP("%s, CID=%X\n", pptp_msg_name[msg], ntohs(cid));
422 info->pns_call_id = cid;
423 break;
424
425 case PPTP_IN_CALL_REPLY:
426 /* client answers incoming call */
427 if (info->cstate != PPTP_CALL_IN_REQ &&
428 info->cstate != PPTP_CALL_IN_REP)
429 goto invalid;
430
431 cid = pptpReq->icack.callID;
432 pcid = pptpReq->icack.peersCallID;
433 if (info->pac_call_id != pcid)
434 goto invalid;
435 DEBUGP("%s, CID=%X PCID=%X\n", pptp_msg_name[msg],
436 ntohs(cid), ntohs(pcid));
437
438 if (pptpReq->icack.resultCode == PPTP_INCALL_ACCEPT) {
439 /* part two of the three-way handshake */
440 info->cstate = PPTP_CALL_IN_REP;
441 info->pns_call_id = cid;
442 } else
443 info->cstate = PPTP_CALL_NONE;
444 break;
445
446 case PPTP_CALL_CLEAR_REQUEST:
447 /* client requests hangup of call */
448 if (info->sstate != PPTP_SESSION_CONFIRMED)
449 goto invalid;
450 /* FUTURE: iterate over all calls and check if
451 * call ID is valid. We don't do this without newnat,
452 * because we only know about last call */
453 info->cstate = PPTP_CALL_CLEAR_REQ;
454 break;
455
456 case PPTP_SET_LINK_INFO:
457 case PPTP_ECHO_REQUEST:
458 case PPTP_ECHO_REPLY:
459 /* I don't have to explain these ;) */
460 break;
461
462 default:
463 goto invalid;
464 }
465
466 nf_nat_pptp_outbound = rcu_dereference(nf_nat_pptp_hook_outbound);
467 if (nf_nat_pptp_outbound && ct->status & IPS_NAT_MASK)
468 return nf_nat_pptp_outbound(pskb, ct, ctinfo, ctlh, pptpReq);
469 return NF_ACCEPT;
470
471invalid:
472 DEBUGP("invalid %s: type=%d cid=%u pcid=%u "
473 "cstate=%d sstate=%d pns_cid=%u pac_cid=%u\n",
474 msg <= PPTP_MSG_MAX ? pptp_msg_name[msg] : pptp_msg_name[0],
475 msg, ntohs(cid), ntohs(pcid), info->cstate, info->sstate,
476 ntohs(info->pns_call_id), ntohs(info->pac_call_id));
477 return NF_ACCEPT;
478}
479
480static const unsigned int pptp_msg_size[] = {
481 [PPTP_START_SESSION_REQUEST] = sizeof(struct PptpStartSessionRequest),
482 [PPTP_START_SESSION_REPLY] = sizeof(struct PptpStartSessionReply),
483 [PPTP_STOP_SESSION_REQUEST] = sizeof(struct PptpStopSessionRequest),
484 [PPTP_STOP_SESSION_REPLY] = sizeof(struct PptpStopSessionReply),
485 [PPTP_OUT_CALL_REQUEST] = sizeof(struct PptpOutCallRequest),
486 [PPTP_OUT_CALL_REPLY] = sizeof(struct PptpOutCallReply),
487 [PPTP_IN_CALL_REQUEST] = sizeof(struct PptpInCallRequest),
488 [PPTP_IN_CALL_REPLY] = sizeof(struct PptpInCallReply),
489 [PPTP_IN_CALL_CONNECT] = sizeof(struct PptpInCallConnected),
490 [PPTP_CALL_CLEAR_REQUEST] = sizeof(struct PptpClearCallRequest),
491 [PPTP_CALL_DISCONNECT_NOTIFY] = sizeof(struct PptpCallDisconnectNotify),
492 [PPTP_WAN_ERROR_NOTIFY] = sizeof(struct PptpWanErrorNotify),
493 [PPTP_SET_LINK_INFO] = sizeof(struct PptpSetLinkInfo),
494};
495
496/* track caller id inside control connection, call expect_related */
497static int
498conntrack_pptp_help(struct sk_buff **pskb, unsigned int protoff,
499 struct nf_conn *ct, enum ip_conntrack_info ctinfo)
500
501{
502 int dir = CTINFO2DIR(ctinfo);
503 struct nf_ct_pptp_master *info = &nfct_help(ct)->help.ct_pptp_info;
504 struct tcphdr _tcph, *tcph;
505 struct pptp_pkt_hdr _pptph, *pptph;
506 struct PptpControlHeader _ctlh, *ctlh;
507 union pptp_ctrl_union _pptpReq, *pptpReq;
508 unsigned int tcplen = (*pskb)->len - protoff;
509 unsigned int datalen, reqlen, nexthdr_off;
510 int oldsstate, oldcstate;
511 int ret;
512 u_int16_t msg;
513
514 /* don't do any tracking before tcp handshake complete */
515 if (ctinfo != IP_CT_ESTABLISHED &&
516 ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY)
517 return NF_ACCEPT;
518
519 nexthdr_off = protoff;
520 tcph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_tcph), &_tcph);
521 BUG_ON(!tcph);
522 nexthdr_off += tcph->doff * 4;
523 datalen = tcplen - tcph->doff * 4;
524
525 pptph = skb_header_pointer(*pskb, nexthdr_off, sizeof(_pptph), &_pptph);
526 if (!pptph) {
527 DEBUGP("no full PPTP header, can't track\n");
528 return NF_ACCEPT;
529 }
530 nexthdr_off += sizeof(_pptph);
531 datalen -= sizeof(_pptph);
532
533 /* if it's not a control message we can't do anything with it */
534 if (ntohs(pptph->packetType) != PPTP_PACKET_CONTROL ||
535 ntohl(pptph->magicCookie) != PPTP_MAGIC_COOKIE) {
536 DEBUGP("not a control packet\n");
537 return NF_ACCEPT;
538 }
539
540 ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh);
541 if (!ctlh)
542 return NF_ACCEPT;
543 nexthdr_off += sizeof(_ctlh);
544 datalen -= sizeof(_ctlh);
545
546 reqlen = datalen;
547 msg = ntohs(ctlh->messageType);
548 if (msg > 0 && msg <= PPTP_MSG_MAX && reqlen < pptp_msg_size[msg])
549 return NF_ACCEPT;
550 if (reqlen > sizeof(*pptpReq))
551 reqlen = sizeof(*pptpReq);
552
553 pptpReq = skb_header_pointer(*pskb, nexthdr_off, reqlen, &_pptpReq);
554 if (!pptpReq)
555 return NF_ACCEPT;
556
557 oldsstate = info->sstate;
558 oldcstate = info->cstate;
559
560 spin_lock_bh(&nf_pptp_lock);
561
562 /* FIXME: We just blindly assume that the control connection is always
563 * established from PNS->PAC. However, RFC makes no guarantee */
564 if (dir == IP_CT_DIR_ORIGINAL)
565 /* client -> server (PNS -> PAC) */
566 ret = pptp_outbound_pkt(pskb, ctlh, pptpReq, reqlen, ct,
567 ctinfo);
568 else
569 /* server -> client (PAC -> PNS) */
570 ret = pptp_inbound_pkt(pskb, ctlh, pptpReq, reqlen, ct,
571 ctinfo);
572 DEBUGP("sstate: %d->%d, cstate: %d->%d\n",
573 oldsstate, info->sstate, oldcstate, info->cstate);
574 spin_unlock_bh(&nf_pptp_lock);
575
576 return ret;
577}
578
579/* control protocol helper */
580static struct nf_conntrack_helper pptp __read_mostly = {
581 .name = "pptp",
582 .me = THIS_MODULE,
583 .max_expected = 2,
584 .timeout = 5 * 60,
585 .tuple.src.l3num = AF_INET,
586 .tuple.src.u.tcp.port = __constant_htons(PPTP_CONTROL_PORT),
587 .tuple.dst.protonum = IPPROTO_TCP,
588 .mask.src.l3num = 0xffff,
589 .mask.src.u.tcp.port = __constant_htons(0xffff),
590 .mask.dst.protonum = 0xff,
591 .help = conntrack_pptp_help,
592 .destroy = pptp_destroy_siblings,
593};
594
595static int __init nf_conntrack_pptp_init(void)
596{
597 return nf_conntrack_helper_register(&pptp);
598}
599
600static void __exit nf_conntrack_pptp_fini(void)
601{
602 nf_conntrack_helper_unregister(&pptp);
603 nf_ct_gre_keymap_flush();
604}
605
606module_init(nf_conntrack_pptp_init);
607module_exit(nf_conntrack_pptp_fini);
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
new file mode 100644
index 000000000000..1a61b72712cd
--- /dev/null
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -0,0 +1,410 @@
1/* L3/L4 protocol support for nf_conntrack. */
2
3/* (C) 1999-2001 Paul `Rusty' Russell
4 * (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
5 * (C) 2003,2004 USAGI/WIDE Project <http://www.linux-ipv6.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 version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/types.h>
13#include <linux/netfilter.h>
14#include <linux/module.h>
15#include <linux/mutex.h>
16#include <linux/skbuff.h>
17#include <linux/vmalloc.h>
18#include <linux/stddef.h>
19#include <linux/err.h>
20#include <linux/percpu.h>
21#include <linux/moduleparam.h>
22#include <linux/notifier.h>
23#include <linux/kernel.h>
24#include <linux/netdevice.h>
25
26#include <net/netfilter/nf_conntrack.h>
27#include <net/netfilter/nf_conntrack_l3proto.h>
28#include <net/netfilter/nf_conntrack_l4proto.h>
29#include <net/netfilter/nf_conntrack_core.h>
30
31struct nf_conntrack_l4proto **nf_ct_protos[PF_MAX] __read_mostly;
32struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX] __read_mostly;
33EXPORT_SYMBOL_GPL(nf_ct_l3protos);
34
35#ifdef CONFIG_SYSCTL
36static DEFINE_MUTEX(nf_ct_proto_sysctl_mutex);
37
38static int
39nf_ct_register_sysctl(struct ctl_table_header **header, struct ctl_table *path,
40 struct ctl_table *table, unsigned int *users)
41{
42 if (*header == NULL) {
43 *header = nf_register_sysctl_table(path, table);
44 if (*header == NULL)
45 return -ENOMEM;
46 }
47 if (users != NULL)
48 (*users)++;
49 return 0;
50}
51
52static void
53nf_ct_unregister_sysctl(struct ctl_table_header **header,
54 struct ctl_table *table, unsigned int *users)
55{
56 if (users != NULL && --*users > 0)
57 return;
58 nf_unregister_sysctl_table(*header, table);
59 *header = NULL;
60}
61#endif
62
63struct nf_conntrack_l4proto *
64__nf_ct_l4proto_find(u_int16_t l3proto, u_int8_t l4proto)
65{
66 if (unlikely(l3proto >= AF_MAX || nf_ct_protos[l3proto] == NULL))
67 return &nf_conntrack_l4proto_generic;
68
69 return nf_ct_protos[l3proto][l4proto];
70}
71EXPORT_SYMBOL_GPL(__nf_ct_l4proto_find);
72
73/* this is guaranteed to always return a valid protocol helper, since
74 * it falls back to generic_protocol */
75struct nf_conntrack_l4proto *
76nf_ct_l4proto_find_get(u_int16_t l3proto, u_int8_t l4proto)
77{
78 struct nf_conntrack_l4proto *p;
79
80 preempt_disable();
81 p = __nf_ct_l4proto_find(l3proto, l4proto);
82 if (!try_module_get(p->me))
83 p = &nf_conntrack_l4proto_generic;
84 preempt_enable();
85
86 return p;
87}
88EXPORT_SYMBOL_GPL(nf_ct_l4proto_find_get);
89
90void nf_ct_l4proto_put(struct nf_conntrack_l4proto *p)
91{
92 module_put(p->me);
93}
94EXPORT_SYMBOL_GPL(nf_ct_l4proto_put);
95
96struct nf_conntrack_l3proto *
97nf_ct_l3proto_find_get(u_int16_t l3proto)
98{
99 struct nf_conntrack_l3proto *p;
100
101 preempt_disable();
102 p = __nf_ct_l3proto_find(l3proto);
103 if (!try_module_get(p->me))
104 p = &nf_conntrack_l3proto_generic;
105 preempt_enable();
106
107 return p;
108}
109EXPORT_SYMBOL_GPL(nf_ct_l3proto_find_get);
110
111void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p)
112{
113 module_put(p->me);
114}
115EXPORT_SYMBOL_GPL(nf_ct_l3proto_put);
116
117int
118nf_ct_l3proto_try_module_get(unsigned short l3proto)
119{
120 int ret;
121 struct nf_conntrack_l3proto *p;
122
123retry: p = nf_ct_l3proto_find_get(l3proto);
124 if (p == &nf_conntrack_l3proto_generic) {
125 ret = request_module("nf_conntrack-%d", l3proto);
126 if (!ret)
127 goto retry;
128
129 return -EPROTOTYPE;
130 }
131
132 return 0;
133}
134EXPORT_SYMBOL_GPL(nf_ct_l3proto_try_module_get);
135
136void nf_ct_l3proto_module_put(unsigned short l3proto)
137{
138 struct nf_conntrack_l3proto *p;
139
140 preempt_disable();
141 p = __nf_ct_l3proto_find(l3proto);
142 preempt_enable();
143
144 module_put(p->me);
145}
146EXPORT_SYMBOL_GPL(nf_ct_l3proto_module_put);
147
148static int kill_l3proto(struct nf_conn *i, void *data)
149{
150 return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num ==
151 ((struct nf_conntrack_l3proto *)data)->l3proto);
152}
153
154static int kill_l4proto(struct nf_conn *i, void *data)
155{
156 struct nf_conntrack_l4proto *l4proto;
157 l4proto = (struct nf_conntrack_l4proto *)data;
158 return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum ==
159 l4proto->l4proto) &&
160 (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num ==
161 l4proto->l3proto);
162}
163
164static int nf_ct_l3proto_register_sysctl(struct nf_conntrack_l3proto *l3proto)
165{
166 int err = 0;
167
168#ifdef CONFIG_SYSCTL
169 mutex_lock(&nf_ct_proto_sysctl_mutex);
170 if (l3proto->ctl_table != NULL) {
171 err = nf_ct_register_sysctl(&l3proto->ctl_table_header,
172 l3proto->ctl_table_path,
173 l3proto->ctl_table, NULL);
174 }
175 mutex_unlock(&nf_ct_proto_sysctl_mutex);
176#endif
177 return err;
178}
179
180static void nf_ct_l3proto_unregister_sysctl(struct nf_conntrack_l3proto *l3proto)
181{
182#ifdef CONFIG_SYSCTL
183 mutex_lock(&nf_ct_proto_sysctl_mutex);
184 if (l3proto->ctl_table_header != NULL)
185 nf_ct_unregister_sysctl(&l3proto->ctl_table_header,
186 l3proto->ctl_table, NULL);
187 mutex_unlock(&nf_ct_proto_sysctl_mutex);
188#endif
189}
190
191int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto)
192{
193 int ret = 0;
194
195 if (proto->l3proto >= AF_MAX) {
196 ret = -EBUSY;
197 goto out;
198 }
199
200 write_lock_bh(&nf_conntrack_lock);
201 if (nf_ct_l3protos[proto->l3proto] != &nf_conntrack_l3proto_generic) {
202 ret = -EBUSY;
203 goto out_unlock;
204 }
205 nf_ct_l3protos[proto->l3proto] = proto;
206 write_unlock_bh(&nf_conntrack_lock);
207
208 ret = nf_ct_l3proto_register_sysctl(proto);
209 if (ret < 0)
210 nf_conntrack_l3proto_unregister(proto);
211 return ret;
212
213out_unlock:
214 write_unlock_bh(&nf_conntrack_lock);
215out:
216 return ret;
217}
218EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_register);
219
220int nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto)
221{
222 int ret = 0;
223
224 if (proto->l3proto >= AF_MAX) {
225 ret = -EBUSY;
226 goto out;
227 }
228
229 write_lock_bh(&nf_conntrack_lock);
230 if (nf_ct_l3protos[proto->l3proto] != proto) {
231 write_unlock_bh(&nf_conntrack_lock);
232 ret = -EBUSY;
233 goto out;
234 }
235
236 nf_ct_l3protos[proto->l3proto] = &nf_conntrack_l3proto_generic;
237 write_unlock_bh(&nf_conntrack_lock);
238
239 nf_ct_l3proto_unregister_sysctl(proto);
240
241 /* Somebody could be still looking at the proto in bh. */
242 synchronize_net();
243
244 /* Remove all contrack entries for this protocol */
245 nf_ct_iterate_cleanup(kill_l3proto, proto);
246
247out:
248 return ret;
249}
250EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_unregister);
251
252static int nf_ct_l4proto_register_sysctl(struct nf_conntrack_l4proto *l4proto)
253{
254 int err = 0;
255
256#ifdef CONFIG_SYSCTL
257 mutex_lock(&nf_ct_proto_sysctl_mutex);
258 if (l4proto->ctl_table != NULL) {
259 err = nf_ct_register_sysctl(l4proto->ctl_table_header,
260 nf_net_netfilter_sysctl_path,
261 l4proto->ctl_table,
262 l4proto->ctl_table_users);
263 if (err < 0)
264 goto out;
265 }
266#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
267 if (l4proto->ctl_compat_table != NULL) {
268 err = nf_ct_register_sysctl(&l4proto->ctl_compat_table_header,
269 nf_net_ipv4_netfilter_sysctl_path,
270 l4proto->ctl_compat_table, NULL);
271 if (err == 0)
272 goto out;
273 nf_ct_unregister_sysctl(l4proto->ctl_table_header,
274 l4proto->ctl_table,
275 l4proto->ctl_table_users);
276 }
277#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
278out:
279 mutex_unlock(&nf_ct_proto_sysctl_mutex);
280#endif /* CONFIG_SYSCTL */
281 return err;
282}
283
284static void nf_ct_l4proto_unregister_sysctl(struct nf_conntrack_l4proto *l4proto)
285{
286#ifdef CONFIG_SYSCTL
287 mutex_lock(&nf_ct_proto_sysctl_mutex);
288 if (l4proto->ctl_table_header != NULL &&
289 *l4proto->ctl_table_header != NULL)
290 nf_ct_unregister_sysctl(l4proto->ctl_table_header,
291 l4proto->ctl_table,
292 l4proto->ctl_table_users);
293#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
294 if (l4proto->ctl_compat_table_header != NULL)
295 nf_ct_unregister_sysctl(&l4proto->ctl_compat_table_header,
296 l4proto->ctl_compat_table, NULL);
297#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
298 mutex_unlock(&nf_ct_proto_sysctl_mutex);
299#endif /* CONFIG_SYSCTL */
300}
301
302/* FIXME: Allow NULL functions and sub in pointers to generic for
303 them. --RR */
304int nf_conntrack_l4proto_register(struct nf_conntrack_l4proto *l4proto)
305{
306 int ret = 0;
307
308 if (l4proto->l3proto >= PF_MAX) {
309 ret = -EBUSY;
310 goto out;
311 }
312
313 if (l4proto == &nf_conntrack_l4proto_generic)
314 return nf_ct_l4proto_register_sysctl(l4proto);
315
316retry:
317 write_lock_bh(&nf_conntrack_lock);
318 if (nf_ct_protos[l4proto->l3proto]) {
319 if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto]
320 != &nf_conntrack_l4proto_generic) {
321 ret = -EBUSY;
322 goto out_unlock;
323 }
324 } else {
325 /* l3proto may be loaded latter. */
326 struct nf_conntrack_l4proto **proto_array;
327 int i;
328
329 write_unlock_bh(&nf_conntrack_lock);
330
331 proto_array = (struct nf_conntrack_l4proto **)
332 kmalloc(MAX_NF_CT_PROTO *
333 sizeof(struct nf_conntrack_l4proto *),
334 GFP_KERNEL);
335 if (proto_array == NULL) {
336 ret = -ENOMEM;
337 goto out;
338 }
339 for (i = 0; i < MAX_NF_CT_PROTO; i++)
340 proto_array[i] = &nf_conntrack_l4proto_generic;
341
342 write_lock_bh(&nf_conntrack_lock);
343 if (nf_ct_protos[l4proto->l3proto]) {
344 /* bad timing, but no problem */
345 write_unlock_bh(&nf_conntrack_lock);
346 kfree(proto_array);
347 } else {
348 nf_ct_protos[l4proto->l3proto] = proto_array;
349 write_unlock_bh(&nf_conntrack_lock);
350 }
351
352 /*
353 * Just once because array is never freed until unloading
354 * nf_conntrack.ko
355 */
356 goto retry;
357 }
358
359 nf_ct_protos[l4proto->l3proto][l4proto->l4proto] = l4proto;
360 write_unlock_bh(&nf_conntrack_lock);
361
362 ret = nf_ct_l4proto_register_sysctl(l4proto);
363 if (ret < 0)
364 nf_conntrack_l4proto_unregister(l4proto);
365 return ret;
366
367out_unlock:
368 write_unlock_bh(&nf_conntrack_lock);
369out:
370 return ret;
371}
372EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_register);
373
374int nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *l4proto)
375{
376 int ret = 0;
377
378 if (l4proto->l3proto >= PF_MAX) {
379 ret = -EBUSY;
380 goto out;
381 }
382
383 if (l4proto == &nf_conntrack_l4proto_generic) {
384 nf_ct_l4proto_unregister_sysctl(l4proto);
385 goto out;
386 }
387
388 write_lock_bh(&nf_conntrack_lock);
389 if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto]
390 != l4proto) {
391 write_unlock_bh(&nf_conntrack_lock);
392 ret = -EBUSY;
393 goto out;
394 }
395 nf_ct_protos[l4proto->l3proto][l4proto->l4proto]
396 = &nf_conntrack_l4proto_generic;
397 write_unlock_bh(&nf_conntrack_lock);
398
399 nf_ct_l4proto_unregister_sysctl(l4proto);
400
401 /* Somebody could be still looking at the proto in bh. */
402 synchronize_net();
403
404 /* Remove all contrack entries for this protocol */
405 nf_ct_iterate_cleanup(kill_l4proto, l4proto);
406
407out:
408 return ret;
409}
410EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister);
diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
index 26408bb0955b..69902531c236 100644
--- a/net/netfilter/nf_conntrack_proto_generic.c
+++ b/net/netfilter/nf_conntrack_proto_generic.c
@@ -15,9 +15,9 @@
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/timer.h> 16#include <linux/timer.h>
17#include <linux/netfilter.h> 17#include <linux/netfilter.h>
18#include <net/netfilter/nf_conntrack_protocol.h> 18#include <net/netfilter/nf_conntrack_l4proto.h>
19 19
20unsigned int nf_ct_generic_timeout __read_mostly = 600*HZ; 20static unsigned int nf_ct_generic_timeout __read_mostly = 600*HZ;
21 21
22static int generic_pkt_to_tuple(const struct sk_buff *skb, 22static int generic_pkt_to_tuple(const struct sk_buff *skb,
23 unsigned int dataoff, 23 unsigned int dataoff,
@@ -71,10 +71,42 @@ static int new(struct nf_conn *conntrack, const struct sk_buff *skb,
71 return 1; 71 return 1;
72} 72}
73 73
74struct nf_conntrack_protocol nf_conntrack_generic_protocol = 74#ifdef CONFIG_SYSCTL
75static struct ctl_table_header *generic_sysctl_header;
76static struct ctl_table generic_sysctl_table[] = {
77 {
78 .ctl_name = NET_NF_CONNTRACK_GENERIC_TIMEOUT,
79 .procname = "nf_conntrack_generic_timeout",
80 .data = &nf_ct_generic_timeout,
81 .maxlen = sizeof(unsigned int),
82 .mode = 0644,
83 .proc_handler = &proc_dointvec_jiffies,
84 },
85 {
86 .ctl_name = 0
87 }
88};
89#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
90static struct ctl_table generic_compat_sysctl_table[] = {
91 {
92 .ctl_name = NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT,
93 .procname = "ip_conntrack_generic_timeout",
94 .data = &nf_ct_generic_timeout,
95 .maxlen = sizeof(unsigned int),
96 .mode = 0644,
97 .proc_handler = &proc_dointvec_jiffies,
98 },
99 {
100 .ctl_name = 0
101 }
102};
103#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
104#endif /* CONFIG_SYSCTL */
105
106struct nf_conntrack_l4proto nf_conntrack_l4proto_generic =
75{ 107{
76 .l3proto = PF_UNSPEC, 108 .l3proto = PF_UNSPEC,
77 .proto = 0, 109 .l4proto = 0,
78 .name = "unknown", 110 .name = "unknown",
79 .pkt_to_tuple = generic_pkt_to_tuple, 111 .pkt_to_tuple = generic_pkt_to_tuple,
80 .invert_tuple = generic_invert_tuple, 112 .invert_tuple = generic_invert_tuple,
@@ -82,4 +114,11 @@ struct nf_conntrack_protocol nf_conntrack_generic_protocol =
82 .print_conntrack = generic_print_conntrack, 114 .print_conntrack = generic_print_conntrack,
83 .packet = packet, 115 .packet = packet,
84 .new = new, 116 .new = new,
117#ifdef CONFIG_SYSCTL
118 .ctl_table_header = &generic_sysctl_header,
119 .ctl_table = generic_sysctl_table,
120#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
121 .ctl_compat_table = generic_compat_sysctl_table,
122#endif
123#endif
85}; 124};
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
new file mode 100644
index 000000000000..ac193ce70249
--- /dev/null
+++ b/net/netfilter/nf_conntrack_proto_gre.c
@@ -0,0 +1,305 @@
1/*
2 * ip_conntrack_proto_gre.c - Version 3.0
3 *
4 * Connection tracking protocol helper module for GRE.
5 *
6 * GRE is a generic encapsulation protocol, which is generally not very
7 * suited for NAT, as it has no protocol-specific part as port numbers.
8 *
9 * It has an optional key field, which may help us distinguishing two
10 * connections between the same two hosts.
11 *
12 * GRE is defined in RFC 1701 and RFC 1702, as well as RFC 2784
13 *
14 * PPTP is built on top of a modified version of GRE, and has a mandatory
15 * field called "CallID", which serves us for the same purpose as the key
16 * field in plain GRE.
17 *
18 * Documentation about PPTP can be found in RFC 2637
19 *
20 * (C) 2000-2005 by Harald Welte <laforge@gnumonks.org>
21 *
22 * Development of this code funded by Astaro AG (http://www.astaro.com/)
23 *
24 */
25
26#include <linux/module.h>
27#include <linux/types.h>
28#include <linux/timer.h>
29#include <linux/list.h>
30#include <linux/seq_file.h>
31#include <linux/in.h>
32#include <linux/skbuff.h>
33
34#include <net/netfilter/nf_conntrack_l4proto.h>
35#include <net/netfilter/nf_conntrack_helper.h>
36#include <net/netfilter/nf_conntrack_core.h>
37#include <linux/netfilter/nf_conntrack_proto_gre.h>
38#include <linux/netfilter/nf_conntrack_pptp.h>
39
40#define GRE_TIMEOUT (30 * HZ)
41#define GRE_STREAM_TIMEOUT (180 * HZ)
42
43#if 0
44#define DEBUGP(format, args...) printk(KERN_DEBUG "%s:%s: " format, __FILE__, __FUNCTION__, ## args)
45#else
46#define DEBUGP(x, args...)
47#endif
48
49static DEFINE_RWLOCK(nf_ct_gre_lock);
50static LIST_HEAD(gre_keymap_list);
51
52void nf_ct_gre_keymap_flush(void)
53{
54 struct list_head *pos, *n;
55
56 write_lock_bh(&nf_ct_gre_lock);
57 list_for_each_safe(pos, n, &gre_keymap_list) {
58 list_del(pos);
59 kfree(pos);
60 }
61 write_unlock_bh(&nf_ct_gre_lock);
62}
63EXPORT_SYMBOL(nf_ct_gre_keymap_flush);
64
65static inline int gre_key_cmpfn(const struct nf_ct_gre_keymap *km,
66 const struct nf_conntrack_tuple *t)
67{
68 return km->tuple.src.l3num == t->src.l3num &&
69 !memcmp(&km->tuple.src.u3, &t->src.u3, sizeof(t->src.u3)) &&
70 !memcmp(&km->tuple.dst.u3, &t->dst.u3, sizeof(t->dst.u3)) &&
71 km->tuple.dst.protonum == t->dst.protonum &&
72 km->tuple.dst.u.all == t->dst.u.all;
73}
74
75/* look up the source key for a given tuple */
76static __be16 gre_keymap_lookup(struct nf_conntrack_tuple *t)
77{
78 struct nf_ct_gre_keymap *km;
79 __be16 key = 0;
80
81 read_lock_bh(&nf_ct_gre_lock);
82 list_for_each_entry(km, &gre_keymap_list, list) {
83 if (gre_key_cmpfn(km, t)) {
84 key = km->tuple.src.u.gre.key;
85 break;
86 }
87 }
88 read_unlock_bh(&nf_ct_gre_lock);
89
90 DEBUGP("lookup src key 0x%x for ", key);
91 NF_CT_DUMP_TUPLE(t);
92
93 return key;
94}
95
96/* add a single keymap entry, associate with specified master ct */
97int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,
98 struct nf_conntrack_tuple *t)
99{
100 struct nf_conn_help *help = nfct_help(ct);
101 struct nf_ct_gre_keymap **kmp, *km;
102
103 BUG_ON(strcmp(help->helper->name, "pptp"));
104 kmp = &help->help.ct_pptp_info.keymap[dir];
105 if (*kmp) {
106 /* check whether it's a retransmission */
107 list_for_each_entry(km, &gre_keymap_list, list) {
108 if (gre_key_cmpfn(km, t) && km == *kmp)
109 return 0;
110 }
111 DEBUGP("trying to override keymap_%s for ct %p\n",
112 dir == IP_CT_DIR_REPLY ? "reply" : "orig", ct);
113 return -EEXIST;
114 }
115
116 km = kmalloc(sizeof(*km), GFP_ATOMIC);
117 if (!km)
118 return -ENOMEM;
119 memcpy(&km->tuple, t, sizeof(*t));
120 *kmp = km;
121
122 DEBUGP("adding new entry %p: ", km);
123 NF_CT_DUMP_TUPLE(&km->tuple);
124
125 write_lock_bh(&nf_ct_gre_lock);
126 list_add_tail(&km->list, &gre_keymap_list);
127 write_unlock_bh(&nf_ct_gre_lock);
128
129 return 0;
130}
131EXPORT_SYMBOL_GPL(nf_ct_gre_keymap_add);
132
133/* destroy the keymap entries associated with specified master ct */
134void nf_ct_gre_keymap_destroy(struct nf_conn *ct)
135{
136 struct nf_conn_help *help = nfct_help(ct);
137 enum ip_conntrack_dir dir;
138
139 DEBUGP("entering for ct %p\n", ct);
140 BUG_ON(strcmp(help->helper->name, "pptp"));
141
142 write_lock_bh(&nf_ct_gre_lock);
143 for (dir = IP_CT_DIR_ORIGINAL; dir < IP_CT_DIR_MAX; dir++) {
144 if (help->help.ct_pptp_info.keymap[dir]) {
145 DEBUGP("removing %p from list\n",
146 help->help.ct_pptp_info.keymap[dir]);
147 list_del(&help->help.ct_pptp_info.keymap[dir]->list);
148 kfree(help->help.ct_pptp_info.keymap[dir]);
149 help->help.ct_pptp_info.keymap[dir] = NULL;
150 }
151 }
152 write_unlock_bh(&nf_ct_gre_lock);
153}
154EXPORT_SYMBOL_GPL(nf_ct_gre_keymap_destroy);
155
156/* PUBLIC CONNTRACK PROTO HELPER FUNCTIONS */
157
158/* invert gre part of tuple */
159static int gre_invert_tuple(struct nf_conntrack_tuple *tuple,
160 const struct nf_conntrack_tuple *orig)
161{
162 tuple->dst.u.gre.key = orig->src.u.gre.key;
163 tuple->src.u.gre.key = orig->dst.u.gre.key;
164 return 1;
165}
166
167/* gre hdr info to tuple */
168static int gre_pkt_to_tuple(const struct sk_buff *skb,
169 unsigned int dataoff,
170 struct nf_conntrack_tuple *tuple)
171{
172 struct gre_hdr_pptp _pgrehdr, *pgrehdr;
173 __be16 srckey;
174 struct gre_hdr _grehdr, *grehdr;
175
176 /* first only delinearize old RFC1701 GRE header */
177 grehdr = skb_header_pointer(skb, dataoff, sizeof(_grehdr), &_grehdr);
178 if (!grehdr || grehdr->version != GRE_VERSION_PPTP) {
179 /* try to behave like "nf_conntrack_proto_generic" */
180 tuple->src.u.all = 0;
181 tuple->dst.u.all = 0;
182 return 1;
183 }
184
185 /* PPTP header is variable length, only need up to the call_id field */
186 pgrehdr = skb_header_pointer(skb, dataoff, 8, &_pgrehdr);
187 if (!pgrehdr)
188 return 1;
189
190 if (ntohs(grehdr->protocol) != GRE_PROTOCOL_PPTP) {
191 DEBUGP("GRE_VERSION_PPTP but unknown proto\n");
192 return 0;
193 }
194
195 tuple->dst.u.gre.key = pgrehdr->call_id;
196 srckey = gre_keymap_lookup(tuple);
197 tuple->src.u.gre.key = srckey;
198
199 return 1;
200}
201
202/* print gre part of tuple */
203static int gre_print_tuple(struct seq_file *s,
204 const struct nf_conntrack_tuple *tuple)
205{
206 return seq_printf(s, "srckey=0x%x dstkey=0x%x ",
207 ntohs(tuple->src.u.gre.key),
208 ntohs(tuple->dst.u.gre.key));
209}
210
211/* print private data for conntrack */
212static int gre_print_conntrack(struct seq_file *s,
213 const struct nf_conn *ct)
214{
215 return seq_printf(s, "timeout=%u, stream_timeout=%u ",
216 (ct->proto.gre.timeout / HZ),
217 (ct->proto.gre.stream_timeout / HZ));
218}
219
220/* Returns verdict for packet, and may modify conntrack */
221static int gre_packet(struct nf_conn *ct,
222 const struct sk_buff *skb,
223 unsigned int dataoff,
224 enum ip_conntrack_info ctinfo,
225 int pf,
226 unsigned int hooknum)
227{
228 /* If we've seen traffic both ways, this is a GRE connection.
229 * Extend timeout. */
230 if (ct->status & IPS_SEEN_REPLY) {
231 nf_ct_refresh_acct(ct, ctinfo, skb,
232 ct->proto.gre.stream_timeout);
233 /* Also, more likely to be important, and not a probe. */
234 set_bit(IPS_ASSURED_BIT, &ct->status);
235 nf_conntrack_event_cache(IPCT_STATUS, skb);
236 } else
237 nf_ct_refresh_acct(ct, ctinfo, skb,
238 ct->proto.gre.timeout);
239
240 return NF_ACCEPT;
241}
242
243/* Called when a new connection for this protocol found. */
244static int gre_new(struct nf_conn *ct, const struct sk_buff *skb,
245 unsigned int dataoff)
246{
247 DEBUGP(": ");
248 NF_CT_DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
249
250 /* initialize to sane value. Ideally a conntrack helper
251 * (e.g. in case of pptp) is increasing them */
252 ct->proto.gre.stream_timeout = GRE_STREAM_TIMEOUT;
253 ct->proto.gre.timeout = GRE_TIMEOUT;
254
255 return 1;
256}
257
258/* Called when a conntrack entry has already been removed from the hashes
259 * and is about to be deleted from memory */
260static void gre_destroy(struct nf_conn *ct)
261{
262 struct nf_conn *master = ct->master;
263 DEBUGP(" entering\n");
264
265 if (!master)
266 DEBUGP("no master !?!\n");
267 else
268 nf_ct_gre_keymap_destroy(master);
269}
270
271/* protocol helper struct */
272static struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 = {
273 .l3proto = AF_INET,
274 .l4proto = IPPROTO_GRE,
275 .name = "gre",
276 .pkt_to_tuple = gre_pkt_to_tuple,
277 .invert_tuple = gre_invert_tuple,
278 .print_tuple = gre_print_tuple,
279 .print_conntrack = gre_print_conntrack,
280 .packet = gre_packet,
281 .new = gre_new,
282 .destroy = gre_destroy,
283 .me = THIS_MODULE,
284#if defined(CONFIG_NF_CONNTRACK_NETLINK) || \
285 defined(CONFIG_NF_CONNTRACK_NETLINK_MODULE)
286 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr,
287 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple,
288#endif
289};
290
291static int __init nf_ct_proto_gre_init(void)
292{
293 return nf_conntrack_l4proto_register(&nf_conntrack_l4proto_gre4);
294}
295
296static void nf_ct_proto_gre_fini(void)
297{
298 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_gre4);
299 nf_ct_gre_keymap_flush();
300}
301
302module_init(nf_ct_proto_gre_init);
303module_exit(nf_ct_proto_gre_fini);
304
305MODULE_LICENSE("GPL");
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index af568777372b..76e263668222 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -32,7 +32,8 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33 33
34#include <net/netfilter/nf_conntrack.h> 34#include <net/netfilter/nf_conntrack.h>
35#include <net/netfilter/nf_conntrack_protocol.h> 35#include <net/netfilter/nf_conntrack_l4proto.h>
36#include <net/netfilter/nf_conntrack_ecache.h>
36 37
37#if 0 38#if 0
38#define DEBUGP(format, ...) printk(format, ## __VA_ARGS__) 39#define DEBUGP(format, ...) printk(format, ## __VA_ARGS__)
@@ -216,7 +217,7 @@ static int sctp_print_conntrack(struct seq_file *s,
216for (offset = dataoff + sizeof(sctp_sctphdr_t), count = 0; \ 217for (offset = dataoff + sizeof(sctp_sctphdr_t), count = 0; \
217 offset < skb->len && \ 218 offset < skb->len && \
218 (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)); \ 219 (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)); \
219 offset += (htons(sch->length) + 3) & ~3, count++) 220 offset += (ntohs(sch->length) + 3) & ~3, count++)
220 221
221/* Some validity checks to make sure the chunks are fine */ 222/* Some validity checks to make sure the chunks are fine */
222static int do_basic_checks(struct nf_conn *conntrack, 223static int do_basic_checks(struct nf_conn *conntrack,
@@ -508,36 +509,10 @@ static int sctp_new(struct nf_conn *conntrack, const struct sk_buff *skb,
508 return 1; 509 return 1;
509} 510}
510 511
511struct nf_conntrack_protocol nf_conntrack_protocol_sctp4 = {
512 .l3proto = PF_INET,
513 .proto = IPPROTO_SCTP,
514 .name = "sctp",
515 .pkt_to_tuple = sctp_pkt_to_tuple,
516 .invert_tuple = sctp_invert_tuple,
517 .print_tuple = sctp_print_tuple,
518 .print_conntrack = sctp_print_conntrack,
519 .packet = sctp_packet,
520 .new = sctp_new,
521 .destroy = NULL,
522 .me = THIS_MODULE
523};
524
525struct nf_conntrack_protocol nf_conntrack_protocol_sctp6 = {
526 .l3proto = PF_INET6,
527 .proto = IPPROTO_SCTP,
528 .name = "sctp",
529 .pkt_to_tuple = sctp_pkt_to_tuple,
530 .invert_tuple = sctp_invert_tuple,
531 .print_tuple = sctp_print_tuple,
532 .print_conntrack = sctp_print_conntrack,
533 .packet = sctp_packet,
534 .new = sctp_new,
535 .destroy = NULL,
536 .me = THIS_MODULE
537};
538
539#ifdef CONFIG_SYSCTL 512#ifdef CONFIG_SYSCTL
540static ctl_table nf_ct_sysctl_table[] = { 513static unsigned int sctp_sysctl_table_users;
514static struct ctl_table_header *sctp_sysctl_header;
515static struct ctl_table sctp_sysctl_table[] = {
541 { 516 {
542 .ctl_name = NET_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED, 517 .ctl_name = NET_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED,
543 .procname = "nf_conntrack_sctp_timeout_closed", 518 .procname = "nf_conntrack_sctp_timeout_closed",
@@ -594,63 +569,134 @@ static ctl_table nf_ct_sysctl_table[] = {
594 .mode = 0644, 569 .mode = 0644,
595 .proc_handler = &proc_dointvec_jiffies, 570 .proc_handler = &proc_dointvec_jiffies,
596 }, 571 },
597 { .ctl_name = 0 } 572 {
573 .ctl_name = 0
574 }
598}; 575};
599 576
600static ctl_table nf_ct_netfilter_table[] = { 577#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
578static struct ctl_table sctp_compat_sysctl_table[] = {
601 { 579 {
602 .ctl_name = NET_NETFILTER, 580 .ctl_name = NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED,
603 .procname = "netfilter", 581 .procname = "ip_conntrack_sctp_timeout_closed",
604 .mode = 0555, 582 .data = &nf_ct_sctp_timeout_closed,
605 .child = nf_ct_sysctl_table, 583 .maxlen = sizeof(unsigned int),
584 .mode = 0644,
585 .proc_handler = &proc_dointvec_jiffies,
586 },
587 {
588 .ctl_name = NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT,
589 .procname = "ip_conntrack_sctp_timeout_cookie_wait",
590 .data = &nf_ct_sctp_timeout_cookie_wait,
591 .maxlen = sizeof(unsigned int),
592 .mode = 0644,
593 .proc_handler = &proc_dointvec_jiffies,
594 },
595 {
596 .ctl_name = NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED,
597 .procname = "ip_conntrack_sctp_timeout_cookie_echoed",
598 .data = &nf_ct_sctp_timeout_cookie_echoed,
599 .maxlen = sizeof(unsigned int),
600 .mode = 0644,
601 .proc_handler = &proc_dointvec_jiffies,
602 },
603 {
604 .ctl_name = NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED,
605 .procname = "ip_conntrack_sctp_timeout_established",
606 .data = &nf_ct_sctp_timeout_established,
607 .maxlen = sizeof(unsigned int),
608 .mode = 0644,
609 .proc_handler = &proc_dointvec_jiffies,
610 },
611 {
612 .ctl_name = NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT,
613 .procname = "ip_conntrack_sctp_timeout_shutdown_sent",
614 .data = &nf_ct_sctp_timeout_shutdown_sent,
615 .maxlen = sizeof(unsigned int),
616 .mode = 0644,
617 .proc_handler = &proc_dointvec_jiffies,
618 },
619 {
620 .ctl_name = NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD,
621 .procname = "ip_conntrack_sctp_timeout_shutdown_recd",
622 .data = &nf_ct_sctp_timeout_shutdown_recd,
623 .maxlen = sizeof(unsigned int),
624 .mode = 0644,
625 .proc_handler = &proc_dointvec_jiffies,
606 }, 626 },
607 { .ctl_name = 0 }
608};
609
610static ctl_table nf_ct_net_table[] = {
611 { 627 {
612 .ctl_name = CTL_NET, 628 .ctl_name = NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT,
613 .procname = "net", 629 .procname = "ip_conntrack_sctp_timeout_shutdown_ack_sent",
614 .mode = 0555, 630 .data = &nf_ct_sctp_timeout_shutdown_ack_sent,
615 .child = nf_ct_netfilter_table, 631 .maxlen = sizeof(unsigned int),
632 .mode = 0644,
633 .proc_handler = &proc_dointvec_jiffies,
616 }, 634 },
617 { .ctl_name = 0 } 635 {
636 .ctl_name = 0
637 }
638};
639#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
640#endif
641
642struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 = {
643 .l3proto = PF_INET,
644 .l4proto = IPPROTO_SCTP,
645 .name = "sctp",
646 .pkt_to_tuple = sctp_pkt_to_tuple,
647 .invert_tuple = sctp_invert_tuple,
648 .print_tuple = sctp_print_tuple,
649 .print_conntrack = sctp_print_conntrack,
650 .packet = sctp_packet,
651 .new = sctp_new,
652 .me = THIS_MODULE,
653#ifdef CONFIG_SYSCTL
654 .ctl_table_users = &sctp_sysctl_table_users,
655 .ctl_table_header = &sctp_sysctl_header,
656 .ctl_table = sctp_sysctl_table,
657#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
658 .ctl_compat_table = sctp_compat_sysctl_table,
659#endif
660#endif
618}; 661};
619 662
620static struct ctl_table_header *nf_ct_sysctl_header; 663struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 = {
664 .l3proto = PF_INET6,
665 .l4proto = IPPROTO_SCTP,
666 .name = "sctp",
667 .pkt_to_tuple = sctp_pkt_to_tuple,
668 .invert_tuple = sctp_invert_tuple,
669 .print_tuple = sctp_print_tuple,
670 .print_conntrack = sctp_print_conntrack,
671 .packet = sctp_packet,
672 .new = sctp_new,
673 .me = THIS_MODULE,
674#ifdef CONFIG_SYSCTL
675 .ctl_table_users = &sctp_sysctl_table_users,
676 .ctl_table_header = &sctp_sysctl_header,
677 .ctl_table = sctp_sysctl_table,
621#endif 678#endif
679};
622 680
623int __init nf_conntrack_proto_sctp_init(void) 681int __init nf_conntrack_proto_sctp_init(void)
624{ 682{
625 int ret; 683 int ret;
626 684
627 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_sctp4); 685 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_sctp4);
628 if (ret) { 686 if (ret) {
629 printk("nf_conntrack_proto_sctp4: protocol register failed\n"); 687 printk("nf_conntrack_l4proto_sctp4: protocol register failed\n");
630 goto out; 688 goto out;
631 } 689 }
632 ret = nf_conntrack_protocol_register(&nf_conntrack_protocol_sctp6); 690 ret = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_sctp6);
633 if (ret) { 691 if (ret) {
634 printk("nf_conntrack_proto_sctp6: protocol register failed\n"); 692 printk("nf_conntrack_l4proto_sctp6: protocol register failed\n");
635 goto cleanup_sctp4; 693 goto cleanup_sctp4;
636 } 694 }
637 695
638#ifdef CONFIG_SYSCTL
639 nf_ct_sysctl_header = register_sysctl_table(nf_ct_net_table, 0);
640 if (nf_ct_sysctl_header == NULL) {
641 printk("nf_conntrack_proto_sctp: can't register to sysctl.\n");
642 goto cleanup;
643 }
644#endif
645
646 return ret; 696 return ret;
647 697
648#ifdef CONFIG_SYSCTL
649 cleanup:
650 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_sctp6);
651#endif
652 cleanup_sctp4: 698 cleanup_sctp4:
653 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_sctp4); 699 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_sctp4);
654 out: 700 out:
655 DEBUGP("SCTP conntrack module loading %s\n", 701 DEBUGP("SCTP conntrack module loading %s\n",
656 ret ? "failed": "succeeded"); 702 ret ? "failed": "succeeded");
@@ -659,11 +705,8 @@ int __init nf_conntrack_proto_sctp_init(void)
659 705
660void __exit nf_conntrack_proto_sctp_fini(void) 706void __exit nf_conntrack_proto_sctp_fini(void)
661{ 707{
662 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_sctp6); 708 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_sctp6);
663 nf_conntrack_protocol_unregister(&nf_conntrack_protocol_sctp4); 709 nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_sctp4);
664#ifdef CONFIG_SYSCTL
665 unregister_sysctl_table(nf_ct_sysctl_header);
666#endif
667 DEBUGP("SCTP conntrack module unloaded\n"); 710 DEBUGP("SCTP conntrack module unloaded\n");
668} 711}
669 712
@@ -673,3 +716,4 @@ module_exit(nf_conntrack_proto_sctp_fini);
673MODULE_LICENSE("GPL"); 716MODULE_LICENSE("GPL");
674MODULE_AUTHOR("Kiran Kumar Immidi"); 717MODULE_AUTHOR("Kiran Kumar Immidi");
675MODULE_DESCRIPTION("Netfilter connection tracking protocol helper for SCTP"); 718MODULE_DESCRIPTION("Netfilter connection tracking protocol helper for SCTP");
719MODULE_ALIAS("ip_conntrack_proto_sctp");
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 238bbb5b72ef..626b0011dd89 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -42,7 +42,8 @@
42#include <linux/netfilter_ipv4.h> 42#include <linux/netfilter_ipv4.h>
43#include <linux/netfilter_ipv6.h> 43#include <linux/netfilter_ipv6.h>
44#include <net/netfilter/nf_conntrack.h> 44#include <net/netfilter/nf_conntrack.h>
45#include <net/netfilter/nf_conntrack_protocol.h> 45#include <net/netfilter/nf_conntrack_l4proto.h>
46#include <net/netfilter/nf_conntrack_ecache.h>
46 47
47#if 0 48#if 0
48#define DEBUGP printk 49#define DEBUGP printk
@@ -92,22 +93,22 @@ static const char *tcp_conntrack_names[] = {
92#define HOURS * 60 MINS 93#define HOURS * 60 MINS
93#define DAYS * 24 HOURS 94#define DAYS * 24 HOURS
94 95
95unsigned int nf_ct_tcp_timeout_syn_sent __read_mostly = 2 MINS; 96static unsigned int nf_ct_tcp_timeout_syn_sent __read_mostly = 2 MINS;
96unsigned int nf_ct_tcp_timeout_syn_recv __read_mostly = 60 SECS; 97static unsigned int nf_ct_tcp_timeout_syn_recv __read_mostly = 60 SECS;
97unsigned int nf_ct_tcp_timeout_established __read_mostly = 5 DAYS; 98static unsigned int nf_ct_tcp_timeout_established __read_mostly = 5 DAYS;
98unsigned int nf_ct_tcp_timeout_fin_wait __read_mostly = 2 MINS; 99static unsigned int nf_ct_tcp_timeout_fin_wait __read_mostly = 2 MINS;
99unsigned int nf_ct_tcp_timeout_close_wait __read_mostly = 60 SECS; 100static unsigned int nf_ct_tcp_timeout_close_wait __read_mostly = 60 SECS;
100unsigned int nf_ct_tcp_timeout_last_ack __read_mostly = 30 SECS; 101static unsigned int nf_ct_tcp_timeout_last_ack __read_mostly = 30 SECS;
101unsigned int nf_ct_tcp_timeout_time_wait __read_mostly = 2 MINS; 102static unsigned int nf_ct_tcp_timeout_time_wait __read_mostly = 2 MINS;
102unsigned int nf_ct_tcp_timeout_close __read_mostly = 10 SECS; 103static unsigned int nf_ct_tcp_timeout_close __read_mostly = 10 SECS;
103 104
104/* RFC1122 says the R2 limit should be at least 100 seconds. 105/* RFC1122 says the R2 limit should be at least 100 seconds.
105 Linux uses 15 packets as limit, which corresponds 106 Linux uses 15 packets as limit, which corresponds
106 to ~13-30min depending on RTO. */ 107 to ~13-30min depending on RTO. */
107unsigned int nf_ct_tcp_timeout_max_retrans __read_mostly = 5 MINS; 108static unsigned int nf_ct_tcp_timeout_max_retrans __read_mostly = 5 MINS;
108 109
109static unsigned int * tcp_timeouts[] 110static unsigned int * tcp_timeouts[] = {
110= { NULL, /* TCP_CONNTRACK_NONE */ 111 NULL, /* TCP_CONNTRACK_NONE */
111 &nf_ct_tcp_timeout_syn_sent, /* TCP_CONNTRACK_SYN_SENT, */ 112 &nf_ct_tcp_timeout_syn_sent, /* TCP_CONNTRACK_SYN_SENT, */
112 &nf_ct_tcp_timeout_syn_recv, /* TCP_CONNTRACK_SYN_RECV, */ 113 &nf_ct_tcp_timeout_syn_recv, /* TCP_CONNTRACK_SYN_RECV, */
113 &nf_ct_tcp_timeout_established, /* TCP_CONNTRACK_ESTABLISHED, */ 114 &nf_ct_tcp_timeout_established, /* TCP_CONNTRACK_ESTABLISHED, */
@@ -473,8 +474,8 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
473 474
474 /* Fast path for timestamp-only option */ 475 /* Fast path for timestamp-only option */
475 if (length == TCPOLEN_TSTAMP_ALIGNED*4 476 if (length == TCPOLEN_TSTAMP_ALIGNED*4
476 && *(__u32 *)ptr == 477 && *(__be32 *)ptr ==
477 __constant_ntohl((TCPOPT_NOP << 24) 478 __constant_htonl((TCPOPT_NOP << 24)
478 | (TCPOPT_NOP << 16) 479 | (TCPOPT_NOP << 16)
479 | (TCPOPT_TIMESTAMP << 8) 480 | (TCPOPT_TIMESTAMP << 8)
480 | TCPOLEN_TIMESTAMP)) 481 | TCPOLEN_TIMESTAMP))
@@ -505,9 +506,7 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
505 for (i = 0; 506 for (i = 0;
506 i < (opsize - TCPOLEN_SACK_BASE); 507 i < (opsize - TCPOLEN_SACK_BASE);
507 i += TCPOLEN_SACK_PERBLOCK) { 508 i += TCPOLEN_SACK_PERBLOCK) {
508 memcpy(&tmp, (__u32 *)(ptr + i) + 1, 509 tmp = ntohl(*((__be32 *)(ptr+i)+1));
509 sizeof(__u32));
510 tmp = ntohl(tmp);
511 510
512 if (after(tmp, *sack)) 511 if (after(tmp, *sack))
513 *sack = tmp; 512 *sack = tmp;
@@ -731,7 +730,7 @@ static int tcp_in_window(struct ip_ct_tcp *state,
731 return res; 730 return res;
732} 731}
733 732
734#ifdef CONFIG_IP_NF_NAT_NEEDED 733#ifdef CONFIG_NF_NAT_NEEDED
735/* Update sender->td_end after NAT successfully mangled the packet */ 734/* Update sender->td_end after NAT successfully mangled the packet */
736/* Caller must linearize skb at tcp header. */ 735/* Caller must linearize skb at tcp header. */
737void nf_conntrack_tcp_update(struct sk_buff *skb, 736void nf_conntrack_tcp_update(struct sk_buff *skb,
@@ -763,7 +762,7 @@ void nf_conntrack_tcp_update(struct sk_buff *skb,
763 receiver->td_end, receiver->td_maxend, receiver->td_maxwin, 762 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
764 receiver->td_scale); 763 receiver->td_scale);
765} 764}
766 765EXPORT_SYMBOL_GPL(nf_conntrack_tcp_update);
767#endif 766#endif
768 767
769#define TH_FIN 0x01 768#define TH_FIN 0x01
@@ -1167,11 +1166,221 @@ static int nfattr_to_tcp(struct nfattr *cda[], struct nf_conn *ct)
1167 return 0; 1166 return 0;
1168} 1167}
1169#endif 1168#endif
1170 1169
1171struct nf_conntrack_protocol nf_conntrack_protocol_tcp4 = 1170#ifdef CONFIG_SYSCTL
1171static unsigned int tcp_sysctl_table_users;
1172static struct ctl_table_header *tcp_sysctl_header;
1173static struct ctl_table tcp_sysctl_table[] = {
1174 {
1175 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
1176 .procname = "nf_conntrack_tcp_timeout_syn_sent",
1177 .data = &nf_ct_tcp_timeout_syn_sent,
1178 .maxlen = sizeof(unsigned int),
1179 .mode = 0644,
1180 .proc_handler = &proc_dointvec_jiffies,
1181 },
1182 {
1183 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV,
1184 .procname = "nf_conntrack_tcp_timeout_syn_recv",
1185 .data = &nf_ct_tcp_timeout_syn_recv,
1186 .maxlen = sizeof(unsigned int),
1187 .mode = 0644,
1188 .proc_handler = &proc_dointvec_jiffies,
1189 },
1190 {
1191 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED,
1192 .procname = "nf_conntrack_tcp_timeout_established",
1193 .data = &nf_ct_tcp_timeout_established,
1194 .maxlen = sizeof(unsigned int),
1195 .mode = 0644,
1196 .proc_handler = &proc_dointvec_jiffies,
1197 },
1198 {
1199 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT,
1200 .procname = "nf_conntrack_tcp_timeout_fin_wait",
1201 .data = &nf_ct_tcp_timeout_fin_wait,
1202 .maxlen = sizeof(unsigned int),
1203 .mode = 0644,
1204 .proc_handler = &proc_dointvec_jiffies,
1205 },
1206 {
1207 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT,
1208 .procname = "nf_conntrack_tcp_timeout_close_wait",
1209 .data = &nf_ct_tcp_timeout_close_wait,
1210 .maxlen = sizeof(unsigned int),
1211 .mode = 0644,
1212 .proc_handler = &proc_dointvec_jiffies,
1213 },
1214 {
1215 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK,
1216 .procname = "nf_conntrack_tcp_timeout_last_ack",
1217 .data = &nf_ct_tcp_timeout_last_ack,
1218 .maxlen = sizeof(unsigned int),
1219 .mode = 0644,
1220 .proc_handler = &proc_dointvec_jiffies,
1221 },
1222 {
1223 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT,
1224 .procname = "nf_conntrack_tcp_timeout_time_wait",
1225 .data = &nf_ct_tcp_timeout_time_wait,
1226 .maxlen = sizeof(unsigned int),
1227 .mode = 0644,
1228 .proc_handler = &proc_dointvec_jiffies,
1229 },
1230 {
1231 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE,
1232 .procname = "nf_conntrack_tcp_timeout_close",
1233 .data = &nf_ct_tcp_timeout_close,
1234 .maxlen = sizeof(unsigned int),
1235 .mode = 0644,
1236 .proc_handler = &proc_dointvec_jiffies,
1237 },
1238 {
1239 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS,
1240 .procname = "nf_conntrack_tcp_timeout_max_retrans",
1241 .data = &nf_ct_tcp_timeout_max_retrans,
1242 .maxlen = sizeof(unsigned int),
1243 .mode = 0644,
1244 .proc_handler = &proc_dointvec_jiffies,
1245 },
1246 {
1247 .ctl_name = NET_NF_CONNTRACK_TCP_LOOSE,
1248 .procname = "nf_conntrack_tcp_loose",
1249 .data = &nf_ct_tcp_loose,
1250 .maxlen = sizeof(unsigned int),
1251 .mode = 0644,
1252 .proc_handler = &proc_dointvec,
1253 },
1254 {
1255 .ctl_name = NET_NF_CONNTRACK_TCP_BE_LIBERAL,
1256 .procname = "nf_conntrack_tcp_be_liberal",
1257 .data = &nf_ct_tcp_be_liberal,
1258 .maxlen = sizeof(unsigned int),
1259 .mode = 0644,
1260 .proc_handler = &proc_dointvec,
1261 },
1262 {
1263 .ctl_name = NET_NF_CONNTRACK_TCP_MAX_RETRANS,
1264 .procname = "nf_conntrack_tcp_max_retrans",
1265 .data = &nf_ct_tcp_max_retrans,
1266 .maxlen = sizeof(unsigned int),
1267 .mode = 0644,
1268 .proc_handler = &proc_dointvec,
1269 },
1270 {
1271 .ctl_name = 0
1272 }
1273};
1274
1275#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
1276static struct ctl_table tcp_compat_sysctl_table[] = {
1277 {
1278 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
1279 .procname = "ip_conntrack_tcp_timeout_syn_sent",
1280 .data = &nf_ct_tcp_timeout_syn_sent,
1281 .maxlen = sizeof(unsigned int),
1282 .mode = 0644,
1283 .proc_handler = &proc_dointvec_jiffies,
1284 },
1285 {
1286 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV,
1287 .procname = "ip_conntrack_tcp_timeout_syn_recv",
1288 .data = &nf_ct_tcp_timeout_syn_recv,
1289 .maxlen = sizeof(unsigned int),
1290 .mode = 0644,
1291 .proc_handler = &proc_dointvec_jiffies,
1292 },
1293 {
1294 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED,
1295 .procname = "ip_conntrack_tcp_timeout_established",
1296 .data = &nf_ct_tcp_timeout_established,
1297 .maxlen = sizeof(unsigned int),
1298 .mode = 0644,
1299 .proc_handler = &proc_dointvec_jiffies,
1300 },
1301 {
1302 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT,
1303 .procname = "ip_conntrack_tcp_timeout_fin_wait",
1304 .data = &nf_ct_tcp_timeout_fin_wait,
1305 .maxlen = sizeof(unsigned int),
1306 .mode = 0644,
1307 .proc_handler = &proc_dointvec_jiffies,
1308 },
1309 {
1310 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT,
1311 .procname = "ip_conntrack_tcp_timeout_close_wait",
1312 .data = &nf_ct_tcp_timeout_close_wait,
1313 .maxlen = sizeof(unsigned int),
1314 .mode = 0644,
1315 .proc_handler = &proc_dointvec_jiffies,
1316 },
1317 {
1318 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK,
1319 .procname = "ip_conntrack_tcp_timeout_last_ack",
1320 .data = &nf_ct_tcp_timeout_last_ack,
1321 .maxlen = sizeof(unsigned int),
1322 .mode = 0644,
1323 .proc_handler = &proc_dointvec_jiffies,
1324 },
1325 {
1326 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT,
1327 .procname = "ip_conntrack_tcp_timeout_time_wait",
1328 .data = &nf_ct_tcp_timeout_time_wait,
1329 .maxlen = sizeof(unsigned int),
1330 .mode = 0644,
1331 .proc_handler = &proc_dointvec_jiffies,
1332 },
1333 {
1334 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE,
1335 .procname = "ip_conntrack_tcp_timeout_close",
1336 .data = &nf_ct_tcp_timeout_close,
1337 .maxlen = sizeof(unsigned int),
1338 .mode = 0644,
1339 .proc_handler = &proc_dointvec_jiffies,
1340 },
1341 {
1342 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS,
1343 .procname = "ip_conntrack_tcp_timeout_max_retrans",
1344 .data = &nf_ct_tcp_timeout_max_retrans,
1345 .maxlen = sizeof(unsigned int),
1346 .mode = 0644,
1347 .proc_handler = &proc_dointvec_jiffies,
1348 },
1349 {
1350 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_LOOSE,
1351 .procname = "ip_conntrack_tcp_loose",
1352 .data = &nf_ct_tcp_loose,
1353 .maxlen = sizeof(unsigned int),
1354 .mode = 0644,
1355 .proc_handler = &proc_dointvec,
1356 },
1357 {
1358 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL,
1359 .procname = "ip_conntrack_tcp_be_liberal",
1360 .data = &nf_ct_tcp_be_liberal,
1361 .maxlen = sizeof(unsigned int),
1362 .mode = 0644,
1363 .proc_handler = &proc_dointvec,
1364 },
1365 {
1366 .ctl_name = NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS,
1367 .procname = "ip_conntrack_tcp_max_retrans",
1368 .data = &nf_ct_tcp_max_retrans,
1369 .maxlen = sizeof(unsigned int),
1370 .mode = 0644,
1371 .proc_handler = &proc_dointvec,
1372 },
1373 {
1374 .ctl_name = 0
1375 }
1376};
1377#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
1378#endif /* CONFIG_SYSCTL */
1379
1380struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 =
1172{ 1381{
1173 .l3proto = PF_INET, 1382 .l3proto = PF_INET,
1174 .proto = IPPROTO_TCP, 1383 .l4proto = IPPROTO_TCP,
1175 .name = "tcp", 1384 .name = "tcp",
1176 .pkt_to_tuple = tcp_pkt_to_tuple, 1385 .pkt_to_tuple = tcp_pkt_to_tuple,
1177 .invert_tuple = tcp_invert_tuple, 1386 .invert_tuple = tcp_invert_tuple,
@@ -1187,12 +1396,21 @@ struct nf_conntrack_protocol nf_conntrack_protocol_tcp4 =
1187 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, 1396 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr,
1188 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, 1397 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple,
1189#endif 1398#endif
1399#ifdef CONFIG_SYSCTL
1400 .ctl_table_users = &tcp_sysctl_table_users,
1401 .ctl_table_header = &tcp_sysctl_header,
1402 .ctl_table = tcp_sysctl_table,
1403#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
1404 .ctl_compat_table = tcp_compat_sysctl_table,
1405#endif
1406#endif
1190}; 1407};
1408EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_tcp4);
1191 1409
1192struct nf_conntrack_protocol nf_conntrack_protocol_tcp6 = 1410struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 =
1193{ 1411{
1194 .l3proto = PF_INET6, 1412 .l3proto = PF_INET6,
1195 .proto = IPPROTO_TCP, 1413 .l4proto = IPPROTO_TCP,
1196 .name = "tcp", 1414 .name = "tcp",
1197 .pkt_to_tuple = tcp_pkt_to_tuple, 1415 .pkt_to_tuple = tcp_pkt_to_tuple,
1198 .invert_tuple = tcp_invert_tuple, 1416 .invert_tuple = tcp_invert_tuple,
@@ -1208,7 +1426,10 @@ struct nf_conntrack_protocol nf_conntrack_protocol_tcp6 =
1208 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, 1426 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr,
1209 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, 1427 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple,
1210#endif 1428#endif
1429#ifdef CONFIG_SYSCTL
1430 .ctl_table_users = &tcp_sysctl_table_users,
1431 .ctl_table_header = &tcp_sysctl_header,
1432 .ctl_table = tcp_sysctl_table,
1433#endif
1211}; 1434};
1212 1435EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_tcp6);
1213EXPORT_SYMBOL(nf_conntrack_protocol_tcp4);
1214EXPORT_SYMBOL(nf_conntrack_protocol_tcp6);
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index d28981cf9af5..e49cd25998c4 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -22,13 +22,15 @@
22#include <linux/ipv6.h> 22#include <linux/ipv6.h>
23#include <net/ip6_checksum.h> 23#include <net/ip6_checksum.h>
24#include <net/checksum.h> 24#include <net/checksum.h>
25
25#include <linux/netfilter.h> 26#include <linux/netfilter.h>
26#include <linux/netfilter_ipv4.h> 27#include <linux/netfilter_ipv4.h>
27#include <linux/netfilter_ipv6.h> 28#include <linux/netfilter_ipv6.h>
28#include <net/netfilter/nf_conntrack_protocol.h> 29#include <net/netfilter/nf_conntrack_l4proto.h>
30#include <net/netfilter/nf_conntrack_ecache.h>
29 31
30unsigned int nf_ct_udp_timeout __read_mostly = 30*HZ; 32static unsigned int nf_ct_udp_timeout __read_mostly = 30*HZ;
31unsigned int nf_ct_udp_timeout_stream __read_mostly = 180*HZ; 33static unsigned int nf_ct_udp_timeout_stream __read_mostly = 180*HZ;
32 34
33static int udp_pkt_to_tuple(const struct sk_buff *skb, 35static int udp_pkt_to_tuple(const struct sk_buff *skb,
34 unsigned int dataoff, 36 unsigned int dataoff,
@@ -146,10 +148,59 @@ static int udp_error(struct sk_buff *skb, unsigned int dataoff,
146 return NF_ACCEPT; 148 return NF_ACCEPT;
147} 149}
148 150
149struct nf_conntrack_protocol nf_conntrack_protocol_udp4 = 151#ifdef CONFIG_SYSCTL
152static unsigned int udp_sysctl_table_users;
153static struct ctl_table_header *udp_sysctl_header;
154static struct ctl_table udp_sysctl_table[] = {
155 {
156 .ctl_name = NET_NF_CONNTRACK_UDP_TIMEOUT,
157 .procname = "nf_conntrack_udp_timeout",
158 .data = &nf_ct_udp_timeout,
159 .maxlen = sizeof(unsigned int),
160 .mode = 0644,
161 .proc_handler = &proc_dointvec_jiffies,
162 },
163 {
164 .ctl_name = NET_NF_CONNTRACK_UDP_TIMEOUT_STREAM,
165 .procname = "nf_conntrack_udp_timeout_stream",
166 .data = &nf_ct_udp_timeout_stream,
167 .maxlen = sizeof(unsigned int),
168 .mode = 0644,
169 .proc_handler = &proc_dointvec_jiffies,
170 },
171 {
172 .ctl_name = 0
173 }
174};
175#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
176static struct ctl_table udp_compat_sysctl_table[] = {
177 {
178 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT,
179 .procname = "ip_conntrack_udp_timeout",
180 .data = &nf_ct_udp_timeout,
181 .maxlen = sizeof(unsigned int),
182 .mode = 0644,
183 .proc_handler = &proc_dointvec_jiffies,
184 },
185 {
186 .ctl_name = NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM,
187 .procname = "ip_conntrack_udp_timeout_stream",
188 .data = &nf_ct_udp_timeout_stream,
189 .maxlen = sizeof(unsigned int),
190 .mode = 0644,
191 .proc_handler = &proc_dointvec_jiffies,
192 },
193 {
194 .ctl_name = 0
195 }
196};
197#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
198#endif /* CONFIG_SYSCTL */
199
200struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 =
150{ 201{
151 .l3proto = PF_INET, 202 .l3proto = PF_INET,
152 .proto = IPPROTO_UDP, 203 .l4proto = IPPROTO_UDP,
153 .name = "udp", 204 .name = "udp",
154 .pkt_to_tuple = udp_pkt_to_tuple, 205 .pkt_to_tuple = udp_pkt_to_tuple,
155 .invert_tuple = udp_invert_tuple, 206 .invert_tuple = udp_invert_tuple,
@@ -163,12 +214,21 @@ struct nf_conntrack_protocol nf_conntrack_protocol_udp4 =
163 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, 214 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr,
164 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, 215 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple,
165#endif 216#endif
217#ifdef CONFIG_SYSCTL
218 .ctl_table_users = &udp_sysctl_table_users,
219 .ctl_table_header = &udp_sysctl_header,
220 .ctl_table = udp_sysctl_table,
221#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
222 .ctl_compat_table = udp_compat_sysctl_table,
223#endif
224#endif
166}; 225};
226EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udp4);
167 227
168struct nf_conntrack_protocol nf_conntrack_protocol_udp6 = 228struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 =
169{ 229{
170 .l3proto = PF_INET6, 230 .l3proto = PF_INET6,
171 .proto = IPPROTO_UDP, 231 .l4proto = IPPROTO_UDP,
172 .name = "udp", 232 .name = "udp",
173 .pkt_to_tuple = udp_pkt_to_tuple, 233 .pkt_to_tuple = udp_pkt_to_tuple,
174 .invert_tuple = udp_invert_tuple, 234 .invert_tuple = udp_invert_tuple,
@@ -182,7 +242,10 @@ struct nf_conntrack_protocol nf_conntrack_protocol_udp6 =
182 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, 242 .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr,
183 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, 243 .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple,
184#endif 244#endif
245#ifdef CONFIG_SYSCTL
246 .ctl_table_users = &udp_sysctl_table_users,
247 .ctl_table_header = &udp_sysctl_header,
248 .ctl_table = udp_sysctl_table,
249#endif
185}; 250};
186 251EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udp6);
187EXPORT_SYMBOL(nf_conntrack_protocol_udp4);
188EXPORT_SYMBOL(nf_conntrack_protocol_udp6);
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
new file mode 100644
index 000000000000..eb2a2411f97b
--- /dev/null
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -0,0 +1,531 @@
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/module.h>
12#include <linux/ctype.h>
13#include <linux/skbuff.h>
14#include <linux/inet.h>
15#include <linux/in.h>
16#include <linux/udp.h>
17#include <linux/netfilter.h>
18
19#include <net/netfilter/nf_conntrack.h>
20#include <net/netfilter/nf_conntrack_expect.h>
21#include <net/netfilter/nf_conntrack_helper.h>
22#include <linux/netfilter/nf_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");
33MODULE_ALIAS("ip_conntrack_sip");
34
35#define MAX_PORTS 8
36static unsigned short ports[MAX_PORTS];
37static int ports_c;
38module_param_array(ports, ushort, &ports_c, 0400);
39MODULE_PARM_DESC(ports, "port numbers of SIP servers");
40
41static unsigned int sip_timeout __read_mostly = SIP_TIMEOUT;
42module_param(sip_timeout, uint, 0600);
43MODULE_PARM_DESC(sip_timeout, "timeout for the master SIP session");
44
45unsigned int (*nf_nat_sip_hook)(struct sk_buff **pskb,
46 enum ip_conntrack_info ctinfo,
47 struct nf_conn *ct,
48 const char **dptr) __read_mostly;
49EXPORT_SYMBOL_GPL(nf_nat_sip_hook);
50
51unsigned int (*nf_nat_sdp_hook)(struct sk_buff **pskb,
52 enum ip_conntrack_info ctinfo,
53 struct nf_conntrack_expect *exp,
54 const char *dptr) __read_mostly;
55EXPORT_SYMBOL_GPL(nf_nat_sdp_hook);
56
57static int digits_len(struct nf_conn *, const char *, const char *, int *);
58static int epaddr_len(struct nf_conn *, const char *, const char *, int *);
59static int skp_digits_len(struct nf_conn *, const char *, const char *, int *);
60static int skp_epaddr_len(struct nf_conn *, const char *, const char *, int *);
61
62struct sip_header_nfo {
63 const char *lname;
64 const char *sname;
65 const char *ln_str;
66 size_t lnlen;
67 size_t snlen;
68 size_t ln_strlen;
69 int case_sensitive;
70 int (*match_len)(struct nf_conn *, const char *,
71 const char *, int *);
72};
73
74static const struct sip_header_nfo ct_sip_hdrs[] = {
75 [POS_REG_REQ_URI] = { /* SIP REGISTER request URI */
76 .lname = "sip:",
77 .lnlen = sizeof("sip:") - 1,
78 .ln_str = ":",
79 .ln_strlen = sizeof(":") - 1,
80 .match_len = epaddr_len,
81 },
82 [POS_REQ_URI] = { /* SIP request URI */
83 .lname = "sip:",
84 .lnlen = sizeof("sip:") - 1,
85 .ln_str = "@",
86 .ln_strlen = sizeof("@") - 1,
87 .match_len = epaddr_len,
88 },
89 [POS_FROM] = { /* SIP From header */
90 .lname = "From:",
91 .lnlen = sizeof("From:") - 1,
92 .sname = "\r\nf:",
93 .snlen = sizeof("\r\nf:") - 1,
94 .ln_str = "sip:",
95 .ln_strlen = sizeof("sip:") - 1,
96 .match_len = skp_epaddr_len,
97 },
98 [POS_TO] = { /* SIP To header */
99 .lname = "To:",
100 .lnlen = sizeof("To:") - 1,
101 .sname = "\r\nt:",
102 .snlen = sizeof("\r\nt:") - 1,
103 .ln_str = "sip:",
104 .ln_strlen = sizeof("sip:") - 1,
105 .match_len = skp_epaddr_len
106 },
107 [POS_VIA] = { /* SIP Via header */
108 .lname = "Via:",
109 .lnlen = sizeof("Via:") - 1,
110 .sname = "\r\nv:",
111 .snlen = sizeof("\r\nv:") - 1, /* rfc3261 "\r\n" */
112 .ln_str = "UDP ",
113 .ln_strlen = sizeof("UDP ") - 1,
114 .match_len = epaddr_len,
115 },
116 [POS_CONTACT] = { /* SIP Contact header */
117 .lname = "Contact:",
118 .lnlen = sizeof("Contact:") - 1,
119 .sname = "\r\nm:",
120 .snlen = sizeof("\r\nm:") - 1,
121 .ln_str = "sip:",
122 .ln_strlen = sizeof("sip:") - 1,
123 .match_len = skp_epaddr_len
124 },
125 [POS_CONTENT] = { /* SIP Content length header */
126 .lname = "Content-Length:",
127 .lnlen = sizeof("Content-Length:") - 1,
128 .sname = "\r\nl:",
129 .snlen = sizeof("\r\nl:") - 1,
130 .ln_str = ":",
131 .ln_strlen = sizeof(":") - 1,
132 .match_len = skp_digits_len
133 },
134 [POS_MEDIA] = { /* SDP media info */
135 .case_sensitive = 1,
136 .lname = "\nm=",
137 .lnlen = sizeof("\nm=") - 1,
138 .sname = "\rm=",
139 .snlen = sizeof("\rm=") - 1,
140 .ln_str = "audio ",
141 .ln_strlen = sizeof("audio ") - 1,
142 .match_len = digits_len
143 },
144 [POS_OWNER_IP4] = { /* SDP owner address*/
145 .case_sensitive = 1,
146 .lname = "\no=",
147 .lnlen = sizeof("\no=") - 1,
148 .sname = "\ro=",
149 .snlen = sizeof("\ro=") - 1,
150 .ln_str = "IN IP4 ",
151 .ln_strlen = sizeof("IN IP4 ") - 1,
152 .match_len = epaddr_len
153 },
154 [POS_CONNECTION_IP4] = {/* SDP connection info */
155 .case_sensitive = 1,
156 .lname = "\nc=",
157 .lnlen = sizeof("\nc=") - 1,
158 .sname = "\rc=",
159 .snlen = sizeof("\rc=") - 1,
160 .ln_str = "IN IP4 ",
161 .ln_strlen = sizeof("IN IP4 ") - 1,
162 .match_len = epaddr_len
163 },
164 [POS_OWNER_IP6] = { /* SDP owner address*/
165 .case_sensitive = 1,
166 .lname = "\no=",
167 .lnlen = sizeof("\no=") - 1,
168 .sname = "\ro=",
169 .snlen = sizeof("\ro=") - 1,
170 .ln_str = "IN IP6 ",
171 .ln_strlen = sizeof("IN IP6 ") - 1,
172 .match_len = epaddr_len
173 },
174 [POS_CONNECTION_IP6] = {/* SDP connection info */
175 .case_sensitive = 1,
176 .lname = "\nc=",
177 .lnlen = sizeof("\nc=") - 1,
178 .sname = "\rc=",
179 .snlen = sizeof("\rc=") - 1,
180 .ln_str = "IN IP6 ",
181 .ln_strlen = sizeof("IN IP6 ") - 1,
182 .match_len = epaddr_len
183 },
184 [POS_SDP_HEADER] = { /* SDP version header */
185 .case_sensitive = 1,
186 .lname = "\nv=",
187 .lnlen = sizeof("\nv=") - 1,
188 .sname = "\rv=",
189 .snlen = sizeof("\rv=") - 1,
190 .ln_str = "=",
191 .ln_strlen = sizeof("=") - 1,
192 .match_len = digits_len
193 }
194};
195
196/* get line lenght until first CR or LF seen. */
197int ct_sip_lnlen(const char *line, const char *limit)
198{
199 const char *k = line;
200
201 while ((line <= limit) && (*line == '\r' || *line == '\n'))
202 line++;
203
204 while (line <= limit) {
205 if (*line == '\r' || *line == '\n')
206 break;
207 line++;
208 }
209 return line - k;
210}
211EXPORT_SYMBOL_GPL(ct_sip_lnlen);
212
213/* Linear string search, case sensitive. */
214const char *ct_sip_search(const char *needle, const char *haystack,
215 size_t needle_len, size_t haystack_len,
216 int case_sensitive)
217{
218 const char *limit = haystack + (haystack_len - needle_len);
219
220 while (haystack <= limit) {
221 if (case_sensitive) {
222 if (strncmp(haystack, needle, needle_len) == 0)
223 return haystack;
224 } else {
225 if (strnicmp(haystack, needle, needle_len) == 0)
226 return haystack;
227 }
228 haystack++;
229 }
230 return NULL;
231}
232EXPORT_SYMBOL_GPL(ct_sip_search);
233
234static int digits_len(struct nf_conn *ct, const char *dptr,
235 const char *limit, int *shift)
236{
237 int len = 0;
238 while (dptr <= limit && isdigit(*dptr)) {
239 dptr++;
240 len++;
241 }
242 return len;
243}
244
245/* get digits lenght, skiping blank spaces. */
246static int skp_digits_len(struct nf_conn *ct, const char *dptr,
247 const char *limit, int *shift)
248{
249 for (; dptr <= limit && *dptr == ' '; dptr++)
250 (*shift)++;
251
252 return digits_len(ct, dptr, limit, shift);
253}
254
255static int parse_addr(struct nf_conn *ct, const char *cp, const char **endp,
256 union nf_conntrack_address *addr, const char *limit)
257{
258 const char *end;
259 int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
260 int ret = 0;
261
262 switch (family) {
263 case AF_INET:
264 ret = in4_pton(cp, limit - cp, (u8 *)&addr->ip, -1, &end);
265 break;
266 case AF_INET6:
267 ret = in6_pton(cp, limit - cp, (u8 *)&addr->ip6, -1, &end);
268 break;
269 default:
270 BUG();
271 }
272
273 if (ret == 0 || end == cp)
274 return 0;
275 if (endp)
276 *endp = end;
277 return 1;
278}
279
280/* skip ip address. returns its length. */
281static int epaddr_len(struct nf_conn *ct, const char *dptr,
282 const char *limit, int *shift)
283{
284 union nf_conntrack_address addr;
285 const char *aux = dptr;
286
287 if (!parse_addr(ct, dptr, &dptr, &addr, limit)) {
288 DEBUGP("ip: %s parse failed.!\n", dptr);
289 return 0;
290 }
291
292 /* Port number */
293 if (*dptr == ':') {
294 dptr++;
295 dptr += digits_len(ct, dptr, limit, shift);
296 }
297 return dptr - aux;
298}
299
300/* get address length, skiping user info. */
301static int skp_epaddr_len(struct nf_conn *ct, const char *dptr,
302 const char *limit, int *shift)
303{
304 int s = *shift;
305
306 for (; dptr <= limit && *dptr != '@'; dptr++)
307 (*shift)++;
308
309 if (*dptr == '@') {
310 dptr++;
311 (*shift)++;
312 } else
313 *shift = s;
314
315 return epaddr_len(ct, dptr, limit, shift);
316}
317
318/* Returns 0 if not found, -1 error parsing. */
319int ct_sip_get_info(struct nf_conn *ct,
320 const char *dptr, size_t dlen,
321 unsigned int *matchoff,
322 unsigned int *matchlen,
323 enum sip_header_pos pos)
324{
325 const struct sip_header_nfo *hnfo = &ct_sip_hdrs[pos];
326 const char *limit, *aux, *k = dptr;
327 int shift = 0;
328
329 limit = dptr + (dlen - hnfo->lnlen);
330
331 while (dptr <= limit) {
332 if ((strncmp(dptr, hnfo->lname, hnfo->lnlen) != 0) &&
333 (strncmp(dptr, hnfo->sname, hnfo->snlen) != 0)) {
334 dptr++;
335 continue;
336 }
337 aux = ct_sip_search(hnfo->ln_str, dptr, hnfo->ln_strlen,
338 ct_sip_lnlen(dptr, limit),
339 hnfo->case_sensitive);
340 if (!aux) {
341 DEBUGP("'%s' not found in '%s'.\n", hnfo->ln_str,
342 hnfo->lname);
343 return -1;
344 }
345 aux += hnfo->ln_strlen;
346
347 *matchlen = hnfo->match_len(ct, aux, limit, &shift);
348 if (!*matchlen)
349 return -1;
350
351 *matchoff = (aux - k) + shift;
352
353 DEBUGP("%s match succeeded! - len: %u\n", hnfo->lname,
354 *matchlen);
355 return 1;
356 }
357 DEBUGP("%s header not found.\n", hnfo->lname);
358 return 0;
359}
360EXPORT_SYMBOL_GPL(ct_sip_get_info);
361
362static int set_expected_rtp(struct sk_buff **pskb,
363 struct nf_conn *ct,
364 enum ip_conntrack_info ctinfo,
365 union nf_conntrack_address *addr,
366 __be16 port,
367 const char *dptr)
368{
369 struct nf_conntrack_expect *exp;
370 enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
371 int family = ct->tuplehash[!dir].tuple.src.l3num;
372 int ret;
373 typeof(nf_nat_sdp_hook) nf_nat_sdp;
374
375 exp = nf_conntrack_expect_alloc(ct);
376 if (exp == NULL)
377 return NF_DROP;
378 nf_conntrack_expect_init(exp, family,
379 &ct->tuplehash[!dir].tuple.src.u3, addr,
380 IPPROTO_UDP, NULL, &port);
381
382 nf_nat_sdp = rcu_dereference(nf_nat_sdp_hook);
383 if (nf_nat_sdp && ct->status & IPS_NAT_MASK)
384 ret = nf_nat_sdp(pskb, ctinfo, exp, dptr);
385 else {
386 if (nf_conntrack_expect_related(exp) != 0)
387 ret = NF_DROP;
388 else
389 ret = NF_ACCEPT;
390 }
391 nf_conntrack_expect_put(exp);
392
393 return ret;
394}
395
396static int sip_help(struct sk_buff **pskb,
397 unsigned int protoff,
398 struct nf_conn *ct,
399 enum ip_conntrack_info ctinfo)
400{
401 int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
402 union nf_conntrack_address addr;
403 unsigned int dataoff, datalen;
404 const char *dptr;
405 int ret = NF_ACCEPT;
406 int matchoff, matchlen;
407 u_int16_t port;
408 enum sip_header_pos pos;
409 typeof(nf_nat_sip_hook) nf_nat_sip;
410
411 /* No Data ? */
412 dataoff = protoff + sizeof(struct udphdr);
413 if (dataoff >= (*pskb)->len)
414 return NF_ACCEPT;
415
416 nf_ct_refresh(ct, *pskb, sip_timeout * HZ);
417
418 if (!skb_is_nonlinear(*pskb))
419 dptr = (*pskb)->data + dataoff;
420 else {
421 DEBUGP("Copy of skbuff not supported yet.\n");
422 goto out;
423 }
424
425 nf_nat_sip = rcu_dereference(nf_nat_sip_hook);
426 if (nf_nat_sip && ct->status & IPS_NAT_MASK) {
427 if (!nf_nat_sip(pskb, ctinfo, ct, &dptr)) {
428 ret = NF_DROP;
429 goto out;
430 }
431 }
432
433 datalen = (*pskb)->len - dataoff;
434 if (datalen < sizeof("SIP/2.0 200") - 1)
435 goto out;
436
437 /* RTP info only in some SDP pkts */
438 if (memcmp(dptr, "INVITE", sizeof("INVITE") - 1) != 0 &&
439 memcmp(dptr, "SIP/2.0 200", sizeof("SIP/2.0 200") - 1) != 0) {
440 goto out;
441 }
442 /* Get address and port from SDP packet. */
443 pos = family == AF_INET ? POS_CONNECTION_IP4 : POS_CONNECTION_IP6;
444 if (ct_sip_get_info(ct, dptr, datalen, &matchoff, &matchlen, pos) > 0) {
445
446 /* We'll drop only if there are parse problems. */
447 if (!parse_addr(ct, dptr + matchoff, NULL, &addr,
448 dptr + datalen)) {
449 ret = NF_DROP;
450 goto out;
451 }
452 if (ct_sip_get_info(ct, dptr, datalen, &matchoff, &matchlen,
453 POS_MEDIA) > 0) {
454
455 port = simple_strtoul(dptr + matchoff, NULL, 10);
456 if (port < 1024) {
457 ret = NF_DROP;
458 goto out;
459 }
460 ret = set_expected_rtp(pskb, ct, ctinfo, &addr,
461 htons(port), dptr);
462 }
463 }
464out:
465 return ret;
466}
467
468static struct nf_conntrack_helper sip[MAX_PORTS][2] __read_mostly;
469static char sip_names[MAX_PORTS][2][sizeof("sip-65535")] __read_mostly;
470
471static void nf_conntrack_sip_fini(void)
472{
473 int i, j;
474
475 for (i = 0; i < ports_c; i++) {
476 for (j = 0; j < 2; j++) {
477 if (sip[i][j].me == NULL)
478 continue;
479 nf_conntrack_helper_unregister(&sip[i][j]);
480 }
481 }
482}
483
484static int __init nf_conntrack_sip_init(void)
485{
486 int i, j, ret;
487 char *tmpname;
488
489 if (ports_c == 0)
490 ports[ports_c++] = SIP_PORT;
491
492 for (i = 0; i < ports_c; i++) {
493 memset(&sip[i], 0, sizeof(sip[i]));
494
495 sip[i][0].tuple.src.l3num = AF_INET;
496 sip[i][1].tuple.src.l3num = AF_INET6;
497 for (j = 0; j < 2; j++) {
498 sip[i][j].tuple.dst.protonum = IPPROTO_UDP;
499 sip[i][j].tuple.src.u.udp.port = htons(ports[i]);
500 sip[i][j].mask.src.l3num = 0xFFFF;
501 sip[i][j].mask.src.u.udp.port = htons(0xFFFF);
502 sip[i][j].mask.dst.protonum = 0xFF;
503 sip[i][j].max_expected = 2;
504 sip[i][j].timeout = 3 * 60; /* 3 minutes */
505 sip[i][j].me = THIS_MODULE;
506 sip[i][j].help = sip_help;
507
508 tmpname = &sip_names[i][j][0];
509 if (ports[i] == SIP_PORT)
510 sprintf(tmpname, "sip");
511 else
512 sprintf(tmpname, "sip-%u", i);
513 sip[i][j].name = tmpname;
514
515 DEBUGP("port #%u: %u\n", i, ports[i]);
516
517 ret = nf_conntrack_helper_register(&sip[i][j]);
518 if (ret) {
519 printk("nf_ct_sip: failed to register helper "
520 "for pf: %u port: %u\n",
521 sip[i][j].tuple.src.l3num, ports[i]);
522 nf_conntrack_sip_fini();
523 return ret;
524 }
525 }
526 }
527 return 0;
528}
529
530module_init(nf_conntrack_sip_init);
531module_exit(nf_conntrack_sip_fini);
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 5954f6773810..f1cb60ff9319 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -29,13 +29,11 @@
29#include <linux/sysctl.h> 29#include <linux/sysctl.h>
30#endif 30#endif
31 31
32#define ASSERT_READ_LOCK(x)
33#define ASSERT_WRITE_LOCK(x)
34
35#include <net/netfilter/nf_conntrack.h> 32#include <net/netfilter/nf_conntrack.h>
36#include <net/netfilter/nf_conntrack_l3proto.h>
37#include <net/netfilter/nf_conntrack_protocol.h>
38#include <net/netfilter/nf_conntrack_core.h> 33#include <net/netfilter/nf_conntrack_core.h>
34#include <net/netfilter/nf_conntrack_l3proto.h>
35#include <net/netfilter/nf_conntrack_l4proto.h>
36#include <net/netfilter/nf_conntrack_expect.h>
39#include <net/netfilter/nf_conntrack_helper.h> 37#include <net/netfilter/nf_conntrack_helper.h>
40 38
41#if 0 39#if 0
@@ -46,33 +44,15 @@
46 44
47MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
48 46
49extern atomic_t nf_conntrack_count;
50DECLARE_PER_CPU(struct ip_conntrack_stat, nf_conntrack_stat);
51
52static int kill_l3proto(struct nf_conn *i, void *data)
53{
54 return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num ==
55 ((struct nf_conntrack_l3proto *)data)->l3proto);
56}
57
58static int kill_proto(struct nf_conn *i, void *data)
59{
60 struct nf_conntrack_protocol *proto;
61 proto = (struct nf_conntrack_protocol *)data;
62 return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum ==
63 proto->proto) &&
64 (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num ==
65 proto->l3proto);
66}
67
68#ifdef CONFIG_PROC_FS 47#ifdef CONFIG_PROC_FS
69static int 48int
70print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, 49print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
71 struct nf_conntrack_l3proto *l3proto, 50 struct nf_conntrack_l3proto *l3proto,
72 struct nf_conntrack_protocol *proto) 51 struct nf_conntrack_l4proto *l4proto)
73{ 52{
74 return l3proto->print_tuple(s, tuple) || proto->print_tuple(s, tuple); 53 return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple);
75} 54}
55EXPORT_SYMBOL_GPL(print_tuple);
76 56
77#ifdef CONFIG_NF_CT_ACCT 57#ifdef CONFIG_NF_CT_ACCT
78static unsigned int 58static unsigned int
@@ -150,9 +130,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
150 const struct nf_conntrack_tuple_hash *hash = v; 130 const struct nf_conntrack_tuple_hash *hash = v;
151 const struct nf_conn *conntrack = nf_ct_tuplehash_to_ctrack(hash); 131 const struct nf_conn *conntrack = nf_ct_tuplehash_to_ctrack(hash);
152 struct nf_conntrack_l3proto *l3proto; 132 struct nf_conntrack_l3proto *l3proto;
153 struct nf_conntrack_protocol *proto; 133 struct nf_conntrack_l4proto *l4proto;
154 134
155 ASSERT_READ_LOCK(&nf_conntrack_lock);
156 NF_CT_ASSERT(conntrack); 135 NF_CT_ASSERT(conntrack);
157 136
158 /* we only want to print DIR_ORIGINAL */ 137 /* we only want to print DIR_ORIGINAL */
@@ -163,16 +142,16 @@ static int ct_seq_show(struct seq_file *s, void *v)
163 .tuple.src.l3num); 142 .tuple.src.l3num);
164 143
165 NF_CT_ASSERT(l3proto); 144 NF_CT_ASSERT(l3proto);
166 proto = __nf_ct_proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL] 145 l4proto = __nf_ct_l4proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL]
167 .tuple.src.l3num, 146 .tuple.src.l3num,
168 conntrack->tuplehash[IP_CT_DIR_ORIGINAL] 147 conntrack->tuplehash[IP_CT_DIR_ORIGINAL]
169 .tuple.dst.protonum); 148 .tuple.dst.protonum);
170 NF_CT_ASSERT(proto); 149 NF_CT_ASSERT(l4proto);
171 150
172 if (seq_printf(s, "%-8s %u %-8s %u %ld ", 151 if (seq_printf(s, "%-8s %u %-8s %u %ld ",
173 l3proto->name, 152 l3proto->name,
174 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num, 153 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num,
175 proto->name, 154 l4proto->name,
176 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum, 155 conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum,
177 timer_pending(&conntrack->timeout) 156 timer_pending(&conntrack->timeout)
178 ? (long)(conntrack->timeout.expires - jiffies)/HZ : 0) != 0) 157 ? (long)(conntrack->timeout.expires - jiffies)/HZ : 0) != 0)
@@ -181,11 +160,11 @@ static int ct_seq_show(struct seq_file *s, void *v)
181 if (l3proto->print_conntrack(s, conntrack)) 160 if (l3proto->print_conntrack(s, conntrack))
182 return -ENOSPC; 161 return -ENOSPC;
183 162
184 if (proto->print_conntrack(s, conntrack)) 163 if (l4proto->print_conntrack(s, conntrack))
185 return -ENOSPC; 164 return -ENOSPC;
186 165
187 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple, 166 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
188 l3proto, proto)) 167 l3proto, l4proto))
189 return -ENOSPC; 168 return -ENOSPC;
190 169
191 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL])) 170 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_ORIGINAL]))
@@ -196,7 +175,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
196 return -ENOSPC; 175 return -ENOSPC;
197 176
198 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple, 177 if (print_tuple(s, &conntrack->tuplehash[IP_CT_DIR_REPLY].tuple,
199 l3proto, proto)) 178 l3proto, l4proto))
200 return -ENOSPC; 179 return -ENOSPC;
201 180
202 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY])) 181 if (seq_print_counters(s, &conntrack->counters[IP_CT_DIR_REPLY]))
@@ -258,84 +237,6 @@ static struct file_operations ct_file_ops = {
258 .release = seq_release_private, 237 .release = seq_release_private,
259}; 238};
260 239
261/* expects */
262static void *exp_seq_start(struct seq_file *s, loff_t *pos)
263{
264 struct list_head *e = &nf_conntrack_expect_list;
265 loff_t i;
266
267 /* strange seq_file api calls stop even if we fail,
268 * thus we need to grab lock since stop unlocks */
269 read_lock_bh(&nf_conntrack_lock);
270
271 if (list_empty(e))
272 return NULL;
273
274 for (i = 0; i <= *pos; i++) {
275 e = e->next;
276 if (e == &nf_conntrack_expect_list)
277 return NULL;
278 }
279 return e;
280}
281
282static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
283{
284 struct list_head *e = v;
285
286 ++*pos;
287 e = e->next;
288
289 if (e == &nf_conntrack_expect_list)
290 return NULL;
291
292 return e;
293}
294
295static void exp_seq_stop(struct seq_file *s, void *v)
296{
297 read_unlock_bh(&nf_conntrack_lock);
298}
299
300static int exp_seq_show(struct seq_file *s, void *v)
301{
302 struct nf_conntrack_expect *expect = v;
303
304 if (expect->timeout.function)
305 seq_printf(s, "%ld ", timer_pending(&expect->timeout)
306 ? (long)(expect->timeout.expires - jiffies)/HZ : 0);
307 else
308 seq_printf(s, "- ");
309 seq_printf(s, "l3proto = %u proto=%u ",
310 expect->tuple.src.l3num,
311 expect->tuple.dst.protonum);
312 print_tuple(s, &expect->tuple,
313 __nf_ct_l3proto_find(expect->tuple.src.l3num),
314 __nf_ct_proto_find(expect->tuple.src.l3num,
315 expect->tuple.dst.protonum));
316 return seq_putc(s, '\n');
317}
318
319static struct seq_operations exp_seq_ops = {
320 .start = exp_seq_start,
321 .next = exp_seq_next,
322 .stop = exp_seq_stop,
323 .show = exp_seq_show
324};
325
326static int exp_open(struct inode *inode, struct file *file)
327{
328 return seq_open(file, &exp_seq_ops);
329}
330
331static struct file_operations exp_file_ops = {
332 .owner = THIS_MODULE,
333 .open = exp_open,
334 .read = seq_read,
335 .llseek = seq_lseek,
336 .release = seq_release
337};
338
339static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos) 240static void *ct_cpu_seq_start(struct seq_file *seq, loff_t *pos)
340{ 241{
341 int cpu; 242 int cpu;
@@ -428,34 +329,9 @@ static struct file_operations ct_cpu_seq_fops = {
428/* Sysctl support */ 329/* Sysctl support */
429 330
430int nf_conntrack_checksum __read_mostly = 1; 331int nf_conntrack_checksum __read_mostly = 1;
332EXPORT_SYMBOL_GPL(nf_conntrack_checksum);
431 333
432#ifdef CONFIG_SYSCTL 334#ifdef CONFIG_SYSCTL
433
434/* From nf_conntrack_core.c */
435extern int nf_conntrack_max;
436extern unsigned int nf_conntrack_htable_size;
437
438/* From nf_conntrack_proto_tcp.c */
439extern unsigned int nf_ct_tcp_timeout_syn_sent;
440extern unsigned int nf_ct_tcp_timeout_syn_recv;
441extern unsigned int nf_ct_tcp_timeout_established;
442extern unsigned int nf_ct_tcp_timeout_fin_wait;
443extern unsigned int nf_ct_tcp_timeout_close_wait;
444extern unsigned int nf_ct_tcp_timeout_last_ack;
445extern unsigned int nf_ct_tcp_timeout_time_wait;
446extern unsigned int nf_ct_tcp_timeout_close;
447extern unsigned int nf_ct_tcp_timeout_max_retrans;
448extern int nf_ct_tcp_loose;
449extern int nf_ct_tcp_be_liberal;
450extern int nf_ct_tcp_max_retrans;
451
452/* From nf_conntrack_proto_udp.c */
453extern unsigned int nf_ct_udp_timeout;
454extern unsigned int nf_ct_udp_timeout_stream;
455
456/* From nf_conntrack_proto_generic.c */
457extern unsigned int nf_ct_generic_timeout;
458
459/* Log invalid packets of a given protocol */ 335/* Log invalid packets of a given protocol */
460static int log_invalid_proto_min = 0; 336static int log_invalid_proto_min = 0;
461static int log_invalid_proto_max = 255; 337static int log_invalid_proto_max = 255;
@@ -496,94 +372,6 @@ static ctl_table nf_ct_sysctl_table[] = {
496 .proc_handler = &proc_dointvec, 372 .proc_handler = &proc_dointvec,
497 }, 373 },
498 { 374 {
499 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT,
500 .procname = "nf_conntrack_tcp_timeout_syn_sent",
501 .data = &nf_ct_tcp_timeout_syn_sent,
502 .maxlen = sizeof(unsigned int),
503 .mode = 0644,
504 .proc_handler = &proc_dointvec_jiffies,
505 },
506 {
507 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV,
508 .procname = "nf_conntrack_tcp_timeout_syn_recv",
509 .data = &nf_ct_tcp_timeout_syn_recv,
510 .maxlen = sizeof(unsigned int),
511 .mode = 0644,
512 .proc_handler = &proc_dointvec_jiffies,
513 },
514 {
515 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED,
516 .procname = "nf_conntrack_tcp_timeout_established",
517 .data = &nf_ct_tcp_timeout_established,
518 .maxlen = sizeof(unsigned int),
519 .mode = 0644,
520 .proc_handler = &proc_dointvec_jiffies,
521 },
522 {
523 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT,
524 .procname = "nf_conntrack_tcp_timeout_fin_wait",
525 .data = &nf_ct_tcp_timeout_fin_wait,
526 .maxlen = sizeof(unsigned int),
527 .mode = 0644,
528 .proc_handler = &proc_dointvec_jiffies,
529 },
530 {
531 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT,
532 .procname = "nf_conntrack_tcp_timeout_close_wait",
533 .data = &nf_ct_tcp_timeout_close_wait,
534 .maxlen = sizeof(unsigned int),
535 .mode = 0644,
536 .proc_handler = &proc_dointvec_jiffies,
537 },
538 {
539 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK,
540 .procname = "nf_conntrack_tcp_timeout_last_ack",
541 .data = &nf_ct_tcp_timeout_last_ack,
542 .maxlen = sizeof(unsigned int),
543 .mode = 0644,
544 .proc_handler = &proc_dointvec_jiffies,
545 },
546 {
547 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT,
548 .procname = "nf_conntrack_tcp_timeout_time_wait",
549 .data = &nf_ct_tcp_timeout_time_wait,
550 .maxlen = sizeof(unsigned int),
551 .mode = 0644,
552 .proc_handler = &proc_dointvec_jiffies,
553 },
554 {
555 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE,
556 .procname = "nf_conntrack_tcp_timeout_close",
557 .data = &nf_ct_tcp_timeout_close,
558 .maxlen = sizeof(unsigned int),
559 .mode = 0644,
560 .proc_handler = &proc_dointvec_jiffies,
561 },
562 {
563 .ctl_name = NET_NF_CONNTRACK_UDP_TIMEOUT,
564 .procname = "nf_conntrack_udp_timeout",
565 .data = &nf_ct_udp_timeout,
566 .maxlen = sizeof(unsigned int),
567 .mode = 0644,
568 .proc_handler = &proc_dointvec_jiffies,
569 },
570 {
571 .ctl_name = NET_NF_CONNTRACK_UDP_TIMEOUT_STREAM,
572 .procname = "nf_conntrack_udp_timeout_stream",
573 .data = &nf_ct_udp_timeout_stream,
574 .maxlen = sizeof(unsigned int),
575 .mode = 0644,
576 .proc_handler = &proc_dointvec_jiffies,
577 },
578 {
579 .ctl_name = NET_NF_CONNTRACK_GENERIC_TIMEOUT,
580 .procname = "nf_conntrack_generic_timeout",
581 .data = &nf_ct_generic_timeout,
582 .maxlen = sizeof(unsigned int),
583 .mode = 0644,
584 .proc_handler = &proc_dointvec_jiffies,
585 },
586 {
587 .ctl_name = NET_NF_CONNTRACK_LOG_INVALID, 375 .ctl_name = NET_NF_CONNTRACK_LOG_INVALID,
588 .procname = "nf_conntrack_log_invalid", 376 .procname = "nf_conntrack_log_invalid",
589 .data = &nf_ct_log_invalid, 377 .data = &nf_ct_log_invalid,
@@ -594,38 +382,6 @@ static ctl_table nf_ct_sysctl_table[] = {
594 .extra1 = &log_invalid_proto_min, 382 .extra1 = &log_invalid_proto_min,
595 .extra2 = &log_invalid_proto_max, 383 .extra2 = &log_invalid_proto_max,
596 }, 384 },
597 {
598 .ctl_name = NET_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS,
599 .procname = "nf_conntrack_tcp_timeout_max_retrans",
600 .data = &nf_ct_tcp_timeout_max_retrans,
601 .maxlen = sizeof(unsigned int),
602 .mode = 0644,
603 .proc_handler = &proc_dointvec_jiffies,
604 },
605 {
606 .ctl_name = NET_NF_CONNTRACK_TCP_LOOSE,
607 .procname = "nf_conntrack_tcp_loose",
608 .data = &nf_ct_tcp_loose,
609 .maxlen = sizeof(unsigned int),
610 .mode = 0644,
611 .proc_handler = &proc_dointvec,
612 },
613 {
614 .ctl_name = NET_NF_CONNTRACK_TCP_BE_LIBERAL,
615 .procname = "nf_conntrack_tcp_be_liberal",
616 .data = &nf_ct_tcp_be_liberal,
617 .maxlen = sizeof(unsigned int),
618 .mode = 0644,
619 .proc_handler = &proc_dointvec,
620 },
621 {
622 .ctl_name = NET_NF_CONNTRACK_TCP_MAX_RETRANS,
623 .procname = "nf_conntrack_tcp_max_retrans",
624 .data = &nf_ct_tcp_max_retrans,
625 .maxlen = sizeof(unsigned int),
626 .mode = 0644,
627 .proc_handler = &proc_dointvec,
628 },
629 385
630 { .ctl_name = 0 } 386 { .ctl_name = 0 }
631}; 387};
@@ -659,109 +415,9 @@ static ctl_table nf_ct_net_table[] = {
659 }, 415 },
660 { .ctl_name = 0 } 416 { .ctl_name = 0 }
661}; 417};
662EXPORT_SYMBOL(nf_ct_log_invalid); 418EXPORT_SYMBOL_GPL(nf_ct_log_invalid);
663#endif /* CONFIG_SYSCTL */ 419#endif /* CONFIG_SYSCTL */
664 420
665int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto)
666{
667 int ret = 0;
668
669 write_lock_bh(&nf_conntrack_lock);
670 if (nf_ct_l3protos[proto->l3proto] != &nf_conntrack_generic_l3proto) {
671 ret = -EBUSY;
672 goto out;
673 }
674 nf_ct_l3protos[proto->l3proto] = proto;
675out:
676 write_unlock_bh(&nf_conntrack_lock);
677
678 return ret;
679}
680
681void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto)
682{
683 write_lock_bh(&nf_conntrack_lock);
684 nf_ct_l3protos[proto->l3proto] = &nf_conntrack_generic_l3proto;
685 write_unlock_bh(&nf_conntrack_lock);
686
687 /* Somebody could be still looking at the proto in bh. */
688 synchronize_net();
689
690 /* Remove all contrack entries for this protocol */
691 nf_ct_iterate_cleanup(kill_l3proto, proto);
692}
693
694/* FIXME: Allow NULL functions and sub in pointers to generic for
695 them. --RR */
696int nf_conntrack_protocol_register(struct nf_conntrack_protocol *proto)
697{
698 int ret = 0;
699
700retry:
701 write_lock_bh(&nf_conntrack_lock);
702 if (nf_ct_protos[proto->l3proto]) {
703 if (nf_ct_protos[proto->l3proto][proto->proto]
704 != &nf_conntrack_generic_protocol) {
705 ret = -EBUSY;
706 goto out_unlock;
707 }
708 } else {
709 /* l3proto may be loaded latter. */
710 struct nf_conntrack_protocol **proto_array;
711 int i;
712
713 write_unlock_bh(&nf_conntrack_lock);
714
715 proto_array = (struct nf_conntrack_protocol **)
716 kmalloc(MAX_NF_CT_PROTO *
717 sizeof(struct nf_conntrack_protocol *),
718 GFP_KERNEL);
719 if (proto_array == NULL) {
720 ret = -ENOMEM;
721 goto out;
722 }
723 for (i = 0; i < MAX_NF_CT_PROTO; i++)
724 proto_array[i] = &nf_conntrack_generic_protocol;
725
726 write_lock_bh(&nf_conntrack_lock);
727 if (nf_ct_protos[proto->l3proto]) {
728 /* bad timing, but no problem */
729 write_unlock_bh(&nf_conntrack_lock);
730 kfree(proto_array);
731 } else {
732 nf_ct_protos[proto->l3proto] = proto_array;
733 write_unlock_bh(&nf_conntrack_lock);
734 }
735
736 /*
737 * Just once because array is never freed until unloading
738 * nf_conntrack.ko
739 */
740 goto retry;
741 }
742
743 nf_ct_protos[proto->l3proto][proto->proto] = proto;
744
745out_unlock:
746 write_unlock_bh(&nf_conntrack_lock);
747out:
748 return ret;
749}
750
751void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol *proto)
752{
753 write_lock_bh(&nf_conntrack_lock);
754 nf_ct_protos[proto->l3proto][proto->proto]
755 = &nf_conntrack_generic_protocol;
756 write_unlock_bh(&nf_conntrack_lock);
757
758 /* Somebody could be still looking at the proto in bh. */
759 synchronize_net();
760
761 /* Remove all contrack entries for this protocol */
762 nf_ct_iterate_cleanup(kill_proto, proto);
763}
764
765static int __init nf_conntrack_standalone_init(void) 421static int __init nf_conntrack_standalone_init(void)
766{ 422{
767#ifdef CONFIG_PROC_FS 423#ifdef CONFIG_PROC_FS
@@ -834,70 +490,4 @@ module_exit(nf_conntrack_standalone_fini);
834void need_conntrack(void) 490void need_conntrack(void)
835{ 491{
836} 492}
837 493EXPORT_SYMBOL_GPL(need_conntrack);
838#ifdef CONFIG_NF_CONNTRACK_EVENTS
839EXPORT_SYMBOL_GPL(nf_conntrack_chain);
840EXPORT_SYMBOL_GPL(nf_conntrack_expect_chain);
841EXPORT_SYMBOL_GPL(nf_conntrack_register_notifier);
842EXPORT_SYMBOL_GPL(nf_conntrack_unregister_notifier);
843EXPORT_SYMBOL_GPL(__nf_ct_event_cache_init);
844EXPORT_PER_CPU_SYMBOL_GPL(nf_conntrack_ecache);
845EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events);
846#endif
847EXPORT_SYMBOL(nf_ct_l3proto_try_module_get);
848EXPORT_SYMBOL(nf_ct_l3proto_module_put);
849EXPORT_SYMBOL(nf_conntrack_l3proto_register);
850EXPORT_SYMBOL(nf_conntrack_l3proto_unregister);
851EXPORT_SYMBOL(nf_conntrack_protocol_register);
852EXPORT_SYMBOL(nf_conntrack_protocol_unregister);
853EXPORT_SYMBOL(nf_ct_invert_tuplepr);
854EXPORT_SYMBOL(nf_conntrack_destroyed);
855EXPORT_SYMBOL(need_conntrack);
856EXPORT_SYMBOL(nf_conntrack_helper_register);
857EXPORT_SYMBOL(nf_conntrack_helper_unregister);
858EXPORT_SYMBOL(nf_ct_iterate_cleanup);
859EXPORT_SYMBOL(__nf_ct_refresh_acct);
860EXPORT_SYMBOL(nf_ct_protos);
861EXPORT_SYMBOL(__nf_ct_proto_find);
862EXPORT_SYMBOL(nf_ct_proto_find_get);
863EXPORT_SYMBOL(nf_ct_proto_put);
864EXPORT_SYMBOL(nf_ct_l3proto_find_get);
865EXPORT_SYMBOL(nf_ct_l3proto_put);
866EXPORT_SYMBOL(nf_ct_l3protos);
867EXPORT_SYMBOL_GPL(nf_conntrack_checksum);
868EXPORT_SYMBOL(nf_conntrack_expect_alloc);
869EXPORT_SYMBOL(nf_conntrack_expect_put);
870EXPORT_SYMBOL(nf_conntrack_expect_related);
871EXPORT_SYMBOL(nf_conntrack_unexpect_related);
872EXPORT_SYMBOL(nf_conntrack_tuple_taken);
873EXPORT_SYMBOL(nf_conntrack_htable_size);
874EXPORT_SYMBOL(nf_conntrack_lock);
875EXPORT_SYMBOL(nf_conntrack_hash);
876EXPORT_SYMBOL(nf_conntrack_untracked);
877EXPORT_SYMBOL_GPL(nf_conntrack_find_get);
878#ifdef CONFIG_IP_NF_NAT_NEEDED
879EXPORT_SYMBOL(nf_conntrack_tcp_update);
880#endif
881EXPORT_SYMBOL(__nf_conntrack_confirm);
882EXPORT_SYMBOL(nf_ct_get_tuple);
883EXPORT_SYMBOL(nf_ct_invert_tuple);
884EXPORT_SYMBOL(nf_conntrack_in);
885EXPORT_SYMBOL(__nf_conntrack_attach);
886EXPORT_SYMBOL(nf_conntrack_alloc);
887EXPORT_SYMBOL(nf_conntrack_free);
888EXPORT_SYMBOL(nf_conntrack_flush);
889EXPORT_SYMBOL(nf_ct_remove_expectations);
890EXPORT_SYMBOL(nf_ct_helper_find_get);
891EXPORT_SYMBOL(nf_ct_helper_put);
892EXPORT_SYMBOL(__nf_conntrack_helper_find_byname);
893EXPORT_SYMBOL(__nf_conntrack_find);
894EXPORT_SYMBOL(nf_ct_unlink_expect);
895EXPORT_SYMBOL(nf_conntrack_hash_insert);
896EXPORT_SYMBOL(__nf_conntrack_expect_find);
897EXPORT_SYMBOL(nf_conntrack_expect_find);
898EXPORT_SYMBOL(nf_conntrack_expect_list);
899#if defined(CONFIG_NF_CT_NETLINK) || \
900 defined(CONFIG_NF_CT_NETLINK_MODULE)
901EXPORT_SYMBOL(nf_ct_port_tuple_to_nfattr);
902EXPORT_SYMBOL(nf_ct_port_nfattr_to_tuple);
903#endif
diff --git a/net/netfilter/nf_conntrack_tftp.c b/net/netfilter/nf_conntrack_tftp.c
new file mode 100644
index 000000000000..f5bffe24b0a5
--- /dev/null
+++ b/net/netfilter/nf_conntrack_tftp.c
@@ -0,0 +1,160 @@
1/* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu>
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation.
6 */
7
8#include <linux/module.h>
9#include <linux/moduleparam.h>
10#include <linux/in.h>
11#include <linux/udp.h>
12#include <linux/netfilter.h>
13
14#include <net/netfilter/nf_conntrack.h>
15#include <net/netfilter/nf_conntrack_tuple.h>
16#include <net/netfilter/nf_conntrack_expect.h>
17#include <net/netfilter/nf_conntrack_ecache.h>
18#include <net/netfilter/nf_conntrack_helper.h>
19#include <linux/netfilter/nf_conntrack_tftp.h>
20
21MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
22MODULE_DESCRIPTION("TFTP connection tracking helper");
23MODULE_LICENSE("GPL");
24MODULE_ALIAS("ip_conntrack_tftp");
25
26#define MAX_PORTS 8
27static unsigned short ports[MAX_PORTS];
28static int ports_c;
29module_param_array(ports, ushort, &ports_c, 0400);
30MODULE_PARM_DESC(ports, "Port numbers of TFTP servers");
31
32#if 0
33#define DEBUGP(format, args...) printk("%s:%s:" format, \
34 __FILE__, __FUNCTION__ , ## args)
35#else
36#define DEBUGP(format, args...)
37#endif
38
39unsigned int (*nf_nat_tftp_hook)(struct sk_buff **pskb,
40 enum ip_conntrack_info ctinfo,
41 struct nf_conntrack_expect *exp) __read_mostly;
42EXPORT_SYMBOL_GPL(nf_nat_tftp_hook);
43
44static int tftp_help(struct sk_buff **pskb,
45 unsigned int protoff,
46 struct nf_conn *ct,
47 enum ip_conntrack_info ctinfo)
48{
49 struct tftphdr _tftph, *tfh;
50 struct nf_conntrack_expect *exp;
51 struct nf_conntrack_tuple *tuple;
52 unsigned int ret = NF_ACCEPT;
53 int family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num;
54 typeof(nf_nat_tftp_hook) nf_nat_tftp;
55
56 tfh = skb_header_pointer(*pskb, protoff + sizeof(struct udphdr),
57 sizeof(_tftph), &_tftph);
58 if (tfh == NULL)
59 return NF_ACCEPT;
60
61 switch (ntohs(tfh->opcode)) {
62 case TFTP_OPCODE_READ:
63 case TFTP_OPCODE_WRITE:
64 /* RRQ and WRQ works the same way */
65 DEBUGP("");
66 NF_CT_DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
67 NF_CT_DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
68
69 exp = nf_conntrack_expect_alloc(ct);
70 if (exp == NULL)
71 return NF_DROP;
72 tuple = &ct->tuplehash[IP_CT_DIR_REPLY].tuple;
73 nf_conntrack_expect_init(exp, family,
74 &tuple->src.u3, &tuple->dst.u3,
75 IPPROTO_UDP,
76 NULL, &tuple->dst.u.udp.port);
77
78 DEBUGP("expect: ");
79 NF_CT_DUMP_TUPLE(&exp->tuple);
80 NF_CT_DUMP_TUPLE(&exp->mask);
81
82 nf_nat_tftp = rcu_dereference(nf_nat_tftp_hook);
83 if (nf_nat_tftp && ct->status & IPS_NAT_MASK)
84 ret = nf_nat_tftp(pskb, ctinfo, exp);
85 else if (nf_conntrack_expect_related(exp) != 0)
86 ret = NF_DROP;
87 nf_conntrack_expect_put(exp);
88 break;
89 case TFTP_OPCODE_DATA:
90 case TFTP_OPCODE_ACK:
91 DEBUGP("Data/ACK opcode\n");
92 break;
93 case TFTP_OPCODE_ERROR:
94 DEBUGP("Error opcode\n");
95 break;
96 default:
97 DEBUGP("Unknown opcode\n");
98 }
99 return ret;
100}
101
102static struct nf_conntrack_helper tftp[MAX_PORTS][2] __read_mostly;
103static char tftp_names[MAX_PORTS][2][sizeof("tftp-65535")] __read_mostly;
104
105static void nf_conntrack_tftp_fini(void)
106{
107 int i, j;
108
109 for (i = 0; i < ports_c; i++) {
110 for (j = 0; j < 2; j++)
111 nf_conntrack_helper_unregister(&tftp[i][j]);
112 }
113}
114
115static int __init nf_conntrack_tftp_init(void)
116{
117 int i, j, ret;
118 char *tmpname;
119
120 if (ports_c == 0)
121 ports[ports_c++] = TFTP_PORT;
122
123 for (i = 0; i < ports_c; i++) {
124 memset(&tftp[i], 0, sizeof(tftp[i]));
125
126 tftp[i][0].tuple.src.l3num = AF_INET;
127 tftp[i][1].tuple.src.l3num = AF_INET6;
128 for (j = 0; j < 2; j++) {
129 tftp[i][j].tuple.dst.protonum = IPPROTO_UDP;
130 tftp[i][j].tuple.src.u.udp.port = htons(ports[i]);
131 tftp[i][j].mask.src.l3num = 0xFFFF;
132 tftp[i][j].mask.dst.protonum = 0xFF;
133 tftp[i][j].mask.src.u.udp.port = htons(0xFFFF);
134 tftp[i][j].max_expected = 1;
135 tftp[i][j].timeout = 5 * 60; /* 5 minutes */
136 tftp[i][j].me = THIS_MODULE;
137 tftp[i][j].help = tftp_help;
138
139 tmpname = &tftp_names[i][j][0];
140 if (ports[i] == TFTP_PORT)
141 sprintf(tmpname, "tftp");
142 else
143 sprintf(tmpname, "tftp-%u", i);
144 tftp[i][j].name = tmpname;
145
146 ret = nf_conntrack_helper_register(&tftp[i][j]);
147 if (ret) {
148 printk("nf_ct_tftp: failed to register helper "
149 "for pf: %u port: %u\n",
150 tftp[i][j].tuple.src.l3num, ports[i]);
151 nf_conntrack_tftp_fini();
152 return ret;
153 }
154 }
155 }
156 return 0;
157}
158
159module_init(nf_conntrack_tftp_init);
160module_exit(nf_conntrack_tftp_fini);
diff --git a/net/netfilter/nf_sysctl.c b/net/netfilter/nf_sysctl.c
new file mode 100644
index 000000000000..06ddddb2911f
--- /dev/null
+++ b/net/netfilter/nf_sysctl.c
@@ -0,0 +1,134 @@
1/* nf_sysctl.c netfilter sysctl registration/unregistation
2 *
3 * Copyright (c) 2006 Patrick McHardy <kaber@trash.net>
4 */
5#include <linux/module.h>
6#include <linux/sysctl.h>
7#include <linux/string.h>
8#include <linux/slab.h>
9
10static void
11path_free(struct ctl_table *path, struct ctl_table *table)
12{
13 struct ctl_table *t, *next;
14
15 for (t = path; t != NULL && t != table; t = next) {
16 next = t->child;
17 kfree(t);
18 }
19}
20
21static struct ctl_table *
22path_dup(struct ctl_table *path, struct ctl_table *table)
23{
24 struct ctl_table *t, *last = NULL, *tmp;
25
26 for (t = path; t != NULL; t = t->child) {
27 /* twice the size since path elements are terminated by an
28 * empty element */
29 tmp = kmemdup(t, 2 * sizeof(*t), GFP_KERNEL);
30 if (tmp == NULL) {
31 if (last != NULL)
32 path_free(path, table);
33 return NULL;
34 }
35
36 if (last != NULL)
37 last->child = tmp;
38 else
39 path = tmp;
40 last = tmp;
41 }
42
43 if (last != NULL)
44 last->child = table;
45 else
46 path = table;
47
48 return path;
49}
50
51struct ctl_table_header *
52nf_register_sysctl_table(struct ctl_table *path, struct ctl_table *table)
53{
54 struct ctl_table_header *header;
55
56 path = path_dup(path, table);
57 if (path == NULL)
58 return NULL;
59 header = register_sysctl_table(path, 0);
60 if (header == NULL)
61 path_free(path, table);
62 return header;
63}
64EXPORT_SYMBOL_GPL(nf_register_sysctl_table);
65
66void
67nf_unregister_sysctl_table(struct ctl_table_header *header,
68 struct ctl_table *table)
69{
70 struct ctl_table *path = header->ctl_table;
71
72 unregister_sysctl_table(header);
73 path_free(path, table);
74}
75EXPORT_SYMBOL_GPL(nf_unregister_sysctl_table);
76
77/* net/netfilter */
78static struct ctl_table nf_net_netfilter_table[] = {
79 {
80 .ctl_name = NET_NETFILTER,
81 .procname = "netfilter",
82 .mode = 0555,
83 },
84 {
85 .ctl_name = 0
86 }
87};
88struct ctl_table nf_net_netfilter_sysctl_path[] = {
89 {
90 .ctl_name = CTL_NET,
91 .procname = "net",
92 .mode = 0555,
93 .child = nf_net_netfilter_table,
94 },
95 {
96 .ctl_name = 0
97 }
98};
99EXPORT_SYMBOL_GPL(nf_net_netfilter_sysctl_path);
100
101/* net/ipv4/netfilter */
102static struct ctl_table nf_net_ipv4_netfilter_table[] = {
103 {
104 .ctl_name = NET_IPV4_NETFILTER,
105 .procname = "netfilter",
106 .mode = 0555,
107 },
108 {
109 .ctl_name = 0
110 }
111};
112static struct ctl_table nf_net_ipv4_table[] = {
113 {
114 .ctl_name = NET_IPV4,
115 .procname = "ipv4",
116 .mode = 0555,
117 .child = nf_net_ipv4_netfilter_table,
118 },
119 {
120 .ctl_name = 0
121 }
122};
123struct ctl_table nf_net_ipv4_netfilter_sysctl_path[] = {
124 {
125 .ctl_name = CTL_NET,
126 .procname = "net",
127 .mode = 0555,
128 .child = nf_net_ipv4_table,
129 },
130 {
131 .ctl_name = 0
132 }
133};
134EXPORT_SYMBOL_GPL(nf_net_ipv4_netfilter_sysctl_path);
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 1e5207b80fe5..d1505dd25c66 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -408,13 +408,13 @@ __build_packet_message(struct nfulnl_instance *inst,
408 const struct net_device *indev, 408 const struct net_device *indev,
409 const struct net_device *outdev, 409 const struct net_device *outdev,
410 const struct nf_loginfo *li, 410 const struct nf_loginfo *li,
411 const char *prefix) 411 const char *prefix, unsigned int plen)
412{ 412{
413 unsigned char *old_tail; 413 unsigned char *old_tail;
414 struct nfulnl_msg_packet_hdr pmsg; 414 struct nfulnl_msg_packet_hdr pmsg;
415 struct nlmsghdr *nlh; 415 struct nlmsghdr *nlh;
416 struct nfgenmsg *nfmsg; 416 struct nfgenmsg *nfmsg;
417 u_int32_t tmp_uint; 417 __be32 tmp_uint;
418 418
419 UDEBUG("entered\n"); 419 UDEBUG("entered\n");
420 420
@@ -432,12 +432,8 @@ __build_packet_message(struct nfulnl_instance *inst,
432 432
433 NFA_PUT(inst->skb, NFULA_PACKET_HDR, sizeof(pmsg), &pmsg); 433 NFA_PUT(inst->skb, NFULA_PACKET_HDR, sizeof(pmsg), &pmsg);
434 434
435 if (prefix) { 435 if (prefix)
436 int slen = strlen(prefix); 436 NFA_PUT(inst->skb, NFULA_PREFIX, plen, prefix);
437 if (slen > NFULNL_PREFIXLEN)
438 slen = NFULNL_PREFIXLEN;
439 NFA_PUT(inst->skb, NFULA_PREFIX, slen, prefix);
440 }
441 437
442 if (indev) { 438 if (indev) {
443 tmp_uint = htonl(indev->ifindex); 439 tmp_uint = htonl(indev->ifindex);
@@ -501,18 +497,16 @@ __build_packet_message(struct nfulnl_instance *inst,
501#endif 497#endif
502 } 498 }
503 499
504 if (skb->nfmark) { 500 if (skb->mark) {
505 tmp_uint = htonl(skb->nfmark); 501 tmp_uint = htonl(skb->mark);
506 NFA_PUT(inst->skb, NFULA_MARK, sizeof(tmp_uint), &tmp_uint); 502 NFA_PUT(inst->skb, NFULA_MARK, sizeof(tmp_uint), &tmp_uint);
507 } 503 }
508 504
509 if (indev && skb->dev && skb->dev->hard_header_parse) { 505 if (indev && skb->dev && skb->dev->hard_header_parse) {
510 struct nfulnl_msg_packet_hw phw; 506 struct nfulnl_msg_packet_hw phw;
511 507 int len = skb->dev->hard_header_parse((struct sk_buff *)skb,
512 phw.hw_addrlen =
513 skb->dev->hard_header_parse((struct sk_buff *)skb,
514 phw.hw_addr); 508 phw.hw_addr);
515 phw.hw_addrlen = htons(phw.hw_addrlen); 509 phw.hw_addrlen = htons(len);
516 NFA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw); 510 NFA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw);
517 } 511 }
518 512
@@ -529,7 +523,7 @@ __build_packet_message(struct nfulnl_instance *inst,
529 if (skb->sk) { 523 if (skb->sk) {
530 read_lock_bh(&skb->sk->sk_callback_lock); 524 read_lock_bh(&skb->sk->sk_callback_lock);
531 if (skb->sk->sk_socket && skb->sk->sk_socket->file) { 525 if (skb->sk->sk_socket && skb->sk->sk_socket->file) {
532 u_int32_t uid = htonl(skb->sk->sk_socket->file->f_uid); 526 __be32 uid = htonl(skb->sk->sk_socket->file->f_uid);
533 /* need to unlock here since NFA_PUT may goto */ 527 /* need to unlock here since NFA_PUT may goto */
534 read_unlock_bh(&skb->sk->sk_callback_lock); 528 read_unlock_bh(&skb->sk->sk_callback_lock);
535 NFA_PUT(inst->skb, NFULA_UID, sizeof(uid), &uid); 529 NFA_PUT(inst->skb, NFULA_UID, sizeof(uid), &uid);
@@ -603,6 +597,7 @@ nfulnl_log_packet(unsigned int pf,
603 const struct nf_loginfo *li; 597 const struct nf_loginfo *li;
604 unsigned int qthreshold; 598 unsigned int qthreshold;
605 unsigned int nlbufsiz; 599 unsigned int nlbufsiz;
600 unsigned int plen;
606 601
607 if (li_user && li_user->type == NF_LOG_TYPE_ULOG) 602 if (li_user && li_user->type == NF_LOG_TYPE_ULOG)
608 li = li_user; 603 li = li_user;
@@ -618,6 +613,10 @@ nfulnl_log_packet(unsigned int pf,
618 return; 613 return;
619 } 614 }
620 615
616 plen = 0;
617 if (prefix)
618 plen = strlen(prefix);
619
621 /* all macros expand to constant values at compile time */ 620 /* all macros expand to constant values at compile time */
622 /* FIXME: do we want to make the size calculation conditional based on 621 /* FIXME: do we want to make the size calculation conditional based on
623 * what is actually present? way more branches and checks, but more 622 * what is actually present? way more branches and checks, but more
@@ -632,7 +631,7 @@ nfulnl_log_packet(unsigned int pf,
632#endif 631#endif
633 + NFA_SPACE(sizeof(u_int32_t)) /* mark */ 632 + NFA_SPACE(sizeof(u_int32_t)) /* mark */
634 + NFA_SPACE(sizeof(u_int32_t)) /* uid */ 633 + NFA_SPACE(sizeof(u_int32_t)) /* uid */
635 + NFA_SPACE(NFULNL_PREFIXLEN) /* prefix */ 634 + NFA_SPACE(plen) /* prefix */
636 + NFA_SPACE(sizeof(struct nfulnl_msg_packet_hw)) 635 + NFA_SPACE(sizeof(struct nfulnl_msg_packet_hw))
637 + NFA_SPACE(sizeof(struct nfulnl_msg_packet_timestamp)); 636 + NFA_SPACE(sizeof(struct nfulnl_msg_packet_timestamp));
638 637
@@ -703,7 +702,7 @@ nfulnl_log_packet(unsigned int pf,
703 inst->qlen++; 702 inst->qlen++;
704 703
705 __build_packet_message(inst, skb, data_len, pf, 704 __build_packet_message(inst, skb, data_len, pf,
706 hooknum, in, out, li, prefix); 705 hooknum, in, out, li, prefix, plen);
707 706
708 /* timer_pending always called within inst->lock, so there 707 /* timer_pending always called within inst->lock, so there
709 * is no chance of a race here */ 708 * is no chance of a race here */
@@ -882,15 +881,15 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
882 } 881 }
883 882
884 if (nfula[NFULA_CFG_TIMEOUT-1]) { 883 if (nfula[NFULA_CFG_TIMEOUT-1]) {
885 u_int32_t timeout = 884 __be32 timeout =
886 *(u_int32_t *)NFA_DATA(nfula[NFULA_CFG_TIMEOUT-1]); 885 *(__be32 *)NFA_DATA(nfula[NFULA_CFG_TIMEOUT-1]);
887 886
888 nfulnl_set_timeout(inst, ntohl(timeout)); 887 nfulnl_set_timeout(inst, ntohl(timeout));
889 } 888 }
890 889
891 if (nfula[NFULA_CFG_NLBUFSIZ-1]) { 890 if (nfula[NFULA_CFG_NLBUFSIZ-1]) {
892 u_int32_t nlbufsiz = 891 __be32 nlbufsiz =
893 *(u_int32_t *)NFA_DATA(nfula[NFULA_CFG_NLBUFSIZ-1]); 892 *(__be32 *)NFA_DATA(nfula[NFULA_CFG_NLBUFSIZ-1]);
894 893
895 nfulnl_set_nlbufsiz(inst, ntohl(nlbufsiz)); 894 nfulnl_set_nlbufsiz(inst, ntohl(nlbufsiz));
896 } 895 }
@@ -903,8 +902,8 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
903 } 902 }
904 903
905 if (nfula[NFULA_CFG_FLAGS-1]) { 904 if (nfula[NFULA_CFG_FLAGS-1]) {
906 u_int16_t flags = 905 __be16 flags =
907 *(u_int16_t *)NFA_DATA(nfula[NFULA_CFG_FLAGS-1]); 906 *(__be16 *)NFA_DATA(nfula[NFULA_CFG_FLAGS-1]);
908 nfulnl_set_flags(inst, ntohs(flags)); 907 nfulnl_set_flags(inst, ntohs(flags));
909 } 908 }
910 909
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index e815a9aa6e95..a88a017da22c 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -349,7 +349,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
349 struct sk_buff *entskb = entry->skb; 349 struct sk_buff *entskb = entry->skb;
350 struct net_device *indev; 350 struct net_device *indev;
351 struct net_device *outdev; 351 struct net_device *outdev;
352 unsigned int tmp_uint; 352 __be32 tmp_uint;
353 353
354 QDEBUG("entered\n"); 354 QDEBUG("entered\n");
355 355
@@ -480,8 +480,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
480#endif 480#endif
481 } 481 }
482 482
483 if (entskb->nfmark) { 483 if (entskb->mark) {
484 tmp_uint = htonl(entskb->nfmark); 484 tmp_uint = htonl(entskb->mark);
485 NFA_PUT(skb, NFQA_MARK, sizeof(u_int32_t), &tmp_uint); 485 NFA_PUT(skb, NFQA_MARK, sizeof(u_int32_t), &tmp_uint);
486 } 486 }
487 487
@@ -489,10 +489,9 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
489 && entskb->dev->hard_header_parse) { 489 && entskb->dev->hard_header_parse) {
490 struct nfqnl_msg_packet_hw phw; 490 struct nfqnl_msg_packet_hw phw;
491 491
492 phw.hw_addrlen = 492 int len = entskb->dev->hard_header_parse(entskb,
493 entskb->dev->hard_header_parse(entskb,
494 phw.hw_addr); 493 phw.hw_addr);
495 phw.hw_addrlen = htons(phw.hw_addrlen); 494 phw.hw_addrlen = htons(len);
496 NFA_PUT(skb, NFQA_HWADDR, sizeof(phw), &phw); 495 NFA_PUT(skb, NFQA_HWADDR, sizeof(phw), &phw);
497 } 496 }
498 497
@@ -835,8 +834,8 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
835 } 834 }
836 835
837 if (nfqa[NFQA_MARK-1]) 836 if (nfqa[NFQA_MARK-1])
838 entry->skb->nfmark = ntohl(*(u_int32_t *) 837 entry->skb->mark = ntohl(*(__be32 *)
839 NFA_DATA(nfqa[NFQA_MARK-1])); 838 NFA_DATA(nfqa[NFQA_MARK-1]));
840 839
841 issue_verdict(entry, verdict); 840 issue_verdict(entry, verdict);
842 instance_put(queue); 841 instance_put(queue);
@@ -948,6 +947,14 @@ nfqnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
948 ntohl(params->copy_range)); 947 ntohl(params->copy_range));
949 } 948 }
950 949
950 if (nfqa[NFQA_CFG_QUEUE_MAXLEN-1]) {
951 __be32 *queue_maxlen;
952 queue_maxlen = NFA_DATA(nfqa[NFQA_CFG_QUEUE_MAXLEN-1]);
953 spin_lock_bh(&queue->lock);
954 queue->queue_maxlen = ntohl(*queue_maxlen);
955 spin_unlock_bh(&queue->lock);
956 }
957
951out_put: 958out_put:
952 instance_put(queue); 959 instance_put(queue);
953 return ret; 960 return ret;
diff --git a/net/netfilter/xt_CONNMARK.c b/net/netfilter/xt_CONNMARK.c
index c01524f817f0..b5548239d412 100644
--- a/net/netfilter/xt_CONNMARK.c
+++ b/net/netfilter/xt_CONNMARK.c
@@ -31,6 +31,9 @@ MODULE_ALIAS("ipt_CONNMARK");
31#include <linux/netfilter/x_tables.h> 31#include <linux/netfilter/x_tables.h>
32#include <linux/netfilter/xt_CONNMARK.h> 32#include <linux/netfilter/xt_CONNMARK.h>
33#include <net/netfilter/nf_conntrack_compat.h> 33#include <net/netfilter/nf_conntrack_compat.h>
34#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
35#include <net/netfilter/nf_conntrack_ecache.h>
36#endif
34 37
35static unsigned int 38static unsigned int
36target(struct sk_buff **pskb, 39target(struct sk_buff **pskb,
@@ -42,7 +45,7 @@ target(struct sk_buff **pskb,
42{ 45{
43 const struct xt_connmark_target_info *markinfo = targinfo; 46 const struct xt_connmark_target_info *markinfo = targinfo;
44 u_int32_t diff; 47 u_int32_t diff;
45 u_int32_t nfmark; 48 u_int32_t mark;
46 u_int32_t newmark; 49 u_int32_t newmark;
47 u_int32_t ctinfo; 50 u_int32_t ctinfo;
48 u_int32_t *ctmark = nf_ct_get_mark(*pskb, &ctinfo); 51 u_int32_t *ctmark = nf_ct_get_mark(*pskb, &ctinfo);
@@ -62,7 +65,7 @@ target(struct sk_buff **pskb,
62 break; 65 break;
63 case XT_CONNMARK_SAVE: 66 case XT_CONNMARK_SAVE:
64 newmark = (*ctmark & ~markinfo->mask) | 67 newmark = (*ctmark & ~markinfo->mask) |
65 ((*pskb)->nfmark & markinfo->mask); 68 ((*pskb)->mark & markinfo->mask);
66 if (*ctmark != newmark) { 69 if (*ctmark != newmark) {
67 *ctmark = newmark; 70 *ctmark = newmark;
68#if defined(CONFIG_IP_NF_CONNTRACK) || defined(CONFIG_IP_NF_CONNTRACK_MODULE) 71#if defined(CONFIG_IP_NF_CONNTRACK) || defined(CONFIG_IP_NF_CONNTRACK_MODULE)
@@ -73,10 +76,10 @@ target(struct sk_buff **pskb,
73 } 76 }
74 break; 77 break;
75 case XT_CONNMARK_RESTORE: 78 case XT_CONNMARK_RESTORE:
76 nfmark = (*pskb)->nfmark; 79 mark = (*pskb)->mark;
77 diff = (*ctmark ^ nfmark) & markinfo->mask; 80 diff = (*ctmark ^ mark) & markinfo->mask;
78 if (diff != 0) 81 if (diff != 0)
79 (*pskb)->nfmark = nfmark ^ diff; 82 (*pskb)->mark = mark ^ diff;
80 break; 83 break;
81 } 84 }
82 } 85 }
diff --git a/net/netfilter/xt_MARK.c b/net/netfilter/xt_MARK.c
index c6e860a7114f..0b48547e8d64 100644
--- a/net/netfilter/xt_MARK.c
+++ b/net/netfilter/xt_MARK.c
@@ -31,8 +31,8 @@ target_v0(struct sk_buff **pskb,
31{ 31{
32 const struct xt_mark_target_info *markinfo = targinfo; 32 const struct xt_mark_target_info *markinfo = targinfo;
33 33
34 if((*pskb)->nfmark != markinfo->mark) 34 if((*pskb)->mark != markinfo->mark)
35 (*pskb)->nfmark = markinfo->mark; 35 (*pskb)->mark = markinfo->mark;
36 36
37 return XT_CONTINUE; 37 return XT_CONTINUE;
38} 38}
@@ -54,16 +54,16 @@ target_v1(struct sk_buff **pskb,
54 break; 54 break;
55 55
56 case XT_MARK_AND: 56 case XT_MARK_AND:
57 mark = (*pskb)->nfmark & markinfo->mark; 57 mark = (*pskb)->mark & markinfo->mark;
58 break; 58 break;
59 59
60 case XT_MARK_OR: 60 case XT_MARK_OR:
61 mark = (*pskb)->nfmark | markinfo->mark; 61 mark = (*pskb)->mark | markinfo->mark;
62 break; 62 break;
63 } 63 }
64 64
65 if((*pskb)->nfmark != mark) 65 if((*pskb)->mark != mark)
66 (*pskb)->nfmark = mark; 66 (*pskb)->mark = mark;
67 67
68 return XT_CONTINUE; 68 return XT_CONTINUE;
69} 69}
diff --git a/net/netfilter/xt_NFLOG.c b/net/netfilter/xt_NFLOG.c
new file mode 100644
index 000000000000..901ed7abaa1b
--- /dev/null
+++ b/net/netfilter/xt_NFLOG.c
@@ -0,0 +1,86 @@
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
9#include <linux/module.h>
10#include <linux/init.h>
11#include <linux/skbuff.h>
12
13#include <linux/netfilter/x_tables.h>
14#include <linux/netfilter/xt_NFLOG.h>
15
16MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
17MODULE_DESCRIPTION("x_tables NFLOG target");
18MODULE_LICENSE("GPL");
19MODULE_ALIAS("ipt_NFLOG");
20MODULE_ALIAS("ip6t_NFLOG");
21
22static unsigned int
23nflog_target(struct sk_buff **pskb,
24 const struct net_device *in, const struct net_device *out,
25 unsigned int hooknum, const struct xt_target *target,
26 const void *targinfo)
27{
28 const struct xt_nflog_info *info = targinfo;
29 struct nf_loginfo li;
30
31 li.type = NF_LOG_TYPE_ULOG;
32 li.u.ulog.copy_len = info->len;
33 li.u.ulog.group = info->group;
34 li.u.ulog.qthreshold = info->threshold;
35
36 nf_log_packet(target->family, hooknum, *pskb, in, out, &li,
37 "%s", info->prefix);
38 return XT_CONTINUE;
39}
40
41static int
42nflog_checkentry(const char *tablename, const void *entry,
43 const struct xt_target *target, void *targetinfo,
44 unsigned int hookmask)
45{
46 struct xt_nflog_info *info = targetinfo;
47
48 if (info->flags & ~XT_NFLOG_MASK)
49 return 0;
50 if (info->prefix[sizeof(info->prefix) - 1] != '\0')
51 return 0;
52 return 1;
53}
54
55static struct xt_target xt_nflog_target[] = {
56 {
57 .name = "NFLOG",
58 .family = AF_INET,
59 .checkentry = nflog_checkentry,
60 .target = nflog_target,
61 .targetsize = sizeof(struct xt_nflog_info),
62 .me = THIS_MODULE,
63 },
64 {
65 .name = "NFLOG",
66 .family = AF_INET6,
67 .checkentry = nflog_checkentry,
68 .target = nflog_target,
69 .targetsize = sizeof(struct xt_nflog_info),
70 .me = THIS_MODULE,
71 },
72};
73
74static int __init xt_nflog_init(void)
75{
76 return xt_register_targets(xt_nflog_target,
77 ARRAY_SIZE(xt_nflog_target));
78}
79
80static void __exit xt_nflog_fini(void)
81{
82 xt_unregister_targets(xt_nflog_target, ARRAY_SIZE(xt_nflog_target));
83}
84
85module_init(xt_nflog_init);
86module_exit(xt_nflog_fini);
diff --git a/net/ipv4/netfilter/ipt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 33ccdbf8e794..501c564e247f 100644
--- a/net/ipv4/netfilter/ipt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -6,23 +6,8 @@
6 * $Id: ipt_hashlimit.c 3244 2004-10-20 16:24:29Z laforge@netfilter.org $ 6 * $Id: ipt_hashlimit.c 3244 2004-10-20 16:24:29Z laforge@netfilter.org $
7 * 7 *
8 * Development of this code was funded by Astaro AG, http://www.astaro.com/ 8 * Development of this code was funded by Astaro AG, http://www.astaro.com/
9 *
10 * based on ipt_limit.c by:
11 * Jérôme de Vivie <devivie@info.enserb.u-bordeaux.fr>
12 * Hervé Eychenne <eychenne@info.enserb.u-bordeaux.fr>
13 * Rusty Russell <rusty@rustcorp.com.au>
14 *
15 * The general idea is to create a hash table for every dstip and have a
16 * seperate limit counter per tuple. This way you can do something like 'limit
17 * the number of syn packets for each of my internal addresses.
18 *
19 * Ideally this would just be implemented as a general 'hash' match, which would
20 * allow us to attach any iptables target to it's hash buckets. But this is
21 * not possible in the current iptables architecture. As always, pkttables for
22 * 2.7.x will help ;)
23 */ 9 */
24#include <linux/module.h> 10#include <linux/module.h>
25#include <linux/skbuff.h>
26#include <linux/spinlock.h> 11#include <linux/spinlock.h>
27#include <linux/random.h> 12#include <linux/random.h>
28#include <linux/jhash.h> 13#include <linux/jhash.h>
@@ -31,28 +16,40 @@
31#include <linux/proc_fs.h> 16#include <linux/proc_fs.h>
32#include <linux/seq_file.h> 17#include <linux/seq_file.h>
33#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/skbuff.h>
20#include <linux/in.h>
21#include <linux/ip.h>
22#include <linux/ipv6.h>
34 23
24#include <linux/netfilter/x_tables.h>
35#include <linux/netfilter_ipv4/ip_tables.h> 25#include <linux/netfilter_ipv4/ip_tables.h>
36#include <linux/netfilter_ipv4/ipt_hashlimit.h> 26#include <linux/netfilter_ipv6/ip6_tables.h>
37 27#include <linux/netfilter/xt_hashlimit.h>
38/* FIXME: this is just for IP_NF_ASSERRT */
39#include <linux/netfilter_ipv4/ip_conntrack.h>
40#include <linux/mutex.h> 28#include <linux/mutex.h>
41 29
42MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
43MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); 31MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
44MODULE_DESCRIPTION("iptables match for limiting per hash-bucket"); 32MODULE_DESCRIPTION("iptables match for limiting per hash-bucket");
33MODULE_ALIAS("ipt_hashlimit");
34MODULE_ALIAS("ip6t_hashlimit");
45 35
46/* need to declare this at the top */ 36/* need to declare this at the top */
47static struct proc_dir_entry *hashlimit_procdir; 37static struct proc_dir_entry *hashlimit_procdir4;
38static struct proc_dir_entry *hashlimit_procdir6;
48static struct file_operations dl_file_ops; 39static struct file_operations dl_file_ops;
49 40
50/* hash table crap */ 41/* hash table crap */
51
52struct dsthash_dst { 42struct dsthash_dst {
53 __be32 src_ip; 43 union {
54 __be32 dst_ip; 44 struct {
55 /* ports have to be consecutive !!! */ 45 __be32 src;
46 __be32 dst;
47 } ip;
48 struct {
49 __be32 src[4];
50 __be32 dst[4];
51 } ip6;
52 } addr;
56 __be16 src_port; 53 __be16 src_port;
57 __be16 dst_port; 54 __be16 dst_port;
58}; 55};
@@ -71,9 +68,10 @@ struct dsthash_ent {
71 } rateinfo; 68 } rateinfo;
72}; 69};
73 70
74struct ipt_hashlimit_htable { 71struct xt_hashlimit_htable {
75 struct hlist_node node; /* global list of all htables */ 72 struct hlist_node node; /* global list of all htables */
76 atomic_t use; 73 atomic_t use;
74 int family;
77 75
78 struct hashlimit_cfg cfg; /* config */ 76 struct hashlimit_cfg cfg; /* config */
79 77
@@ -81,8 +79,8 @@ struct ipt_hashlimit_htable {
81 spinlock_t lock; /* lock for list_head */ 79 spinlock_t lock; /* lock for list_head */
82 u_int32_t rnd; /* random seed for hash */ 80 u_int32_t rnd; /* random seed for hash */
83 int rnd_initialized; 81 int rnd_initialized;
82 unsigned int count; /* number entries in table */
84 struct timer_list timer; /* timer for gc */ 83 struct timer_list timer; /* timer for gc */
85 atomic_t count; /* number entries in table */
86 84
87 /* seq_file stuff */ 85 /* seq_file stuff */
88 struct proc_dir_entry *pde; 86 struct proc_dir_entry *pde;
@@ -97,41 +95,33 @@ static kmem_cache_t *hashlimit_cachep __read_mostly;
97 95
98static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b) 96static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b)
99{ 97{
100 return (ent->dst.dst_ip == b->dst_ip 98 return !memcmp(&ent->dst, b, sizeof(ent->dst));
101 && ent->dst.dst_port == b->dst_port
102 && ent->dst.src_port == b->src_port
103 && ent->dst.src_ip == b->src_ip);
104} 99}
105 100
106static inline u_int32_t 101static u_int32_t
107hash_dst(const struct ipt_hashlimit_htable *ht, const struct dsthash_dst *dst) 102hash_dst(const struct xt_hashlimit_htable *ht, const struct dsthash_dst *dst)
108{ 103{
109 return (jhash_3words((__force u32)dst->dst_ip, 104 return jhash(dst, sizeof(*dst), ht->rnd) % ht->cfg.size;
110 ((__force u32)dst->dst_port<<16 |
111 (__force u32)dst->src_port),
112 (__force u32)dst->src_ip, ht->rnd) % ht->cfg.size);
113} 105}
114 106
115static inline struct dsthash_ent * 107static struct dsthash_ent *
116__dsthash_find(const struct ipt_hashlimit_htable *ht, struct dsthash_dst *dst) 108dsthash_find(const struct xt_hashlimit_htable *ht, struct dsthash_dst *dst)
117{ 109{
118 struct dsthash_ent *ent; 110 struct dsthash_ent *ent;
119 struct hlist_node *pos; 111 struct hlist_node *pos;
120 u_int32_t hash = hash_dst(ht, dst); 112 u_int32_t hash = hash_dst(ht, dst);
121 113
122 if (!hlist_empty(&ht->hash[hash])) 114 if (!hlist_empty(&ht->hash[hash])) {
123 hlist_for_each_entry(ent, pos, &ht->hash[hash], node) { 115 hlist_for_each_entry(ent, pos, &ht->hash[hash], node)
124 if (dst_cmp(ent, dst)) { 116 if (dst_cmp(ent, dst))
125 return ent; 117 return ent;
126 } 118 }
127 }
128
129 return NULL; 119 return NULL;
130} 120}
131 121
132/* allocate dsthash_ent, initialize dst, put in htable and lock it */ 122/* allocate dsthash_ent, initialize dst, put in htable and lock it */
133static struct dsthash_ent * 123static struct dsthash_ent *
134__dsthash_alloc_init(struct ipt_hashlimit_htable *ht, struct dsthash_dst *dst) 124dsthash_alloc_init(struct xt_hashlimit_htable *ht, struct dsthash_dst *dst)
135{ 125{
136 struct dsthash_ent *ent; 126 struct dsthash_ent *ent;
137 127
@@ -142,12 +132,11 @@ __dsthash_alloc_init(struct ipt_hashlimit_htable *ht, struct dsthash_dst *dst)
142 ht->rnd_initialized = 1; 132 ht->rnd_initialized = 1;
143 } 133 }
144 134
145 if (ht->cfg.max && 135 if (ht->cfg.max && ht->count >= ht->cfg.max) {
146 atomic_read(&ht->count) >= ht->cfg.max) {
147 /* FIXME: do something. question is what.. */ 136 /* FIXME: do something. question is what.. */
148 if (net_ratelimit()) 137 if (net_ratelimit())
149 printk(KERN_WARNING 138 printk(KERN_WARNING
150 "ipt_hashlimit: max count of %u reached\n", 139 "xt_hashlimit: max count of %u reached\n",
151 ht->cfg.max); 140 ht->cfg.max);
152 return NULL; 141 return NULL;
153 } 142 }
@@ -155,53 +144,47 @@ __dsthash_alloc_init(struct ipt_hashlimit_htable *ht, struct dsthash_dst *dst)
155 ent = kmem_cache_alloc(hashlimit_cachep, GFP_ATOMIC); 144 ent = kmem_cache_alloc(hashlimit_cachep, GFP_ATOMIC);
156 if (!ent) { 145 if (!ent) {
157 if (net_ratelimit()) 146 if (net_ratelimit())
158 printk(KERN_ERR 147 printk(KERN_ERR
159 "ipt_hashlimit: can't allocate dsthash_ent\n"); 148 "xt_hashlimit: can't allocate dsthash_ent\n");
160 return NULL; 149 return NULL;
161 } 150 }
162 151 memcpy(&ent->dst, dst, sizeof(ent->dst));
163 atomic_inc(&ht->count);
164
165 ent->dst.dst_ip = dst->dst_ip;
166 ent->dst.dst_port = dst->dst_port;
167 ent->dst.src_ip = dst->src_ip;
168 ent->dst.src_port = dst->src_port;
169 152
170 hlist_add_head(&ent->node, &ht->hash[hash_dst(ht, dst)]); 153 hlist_add_head(&ent->node, &ht->hash[hash_dst(ht, dst)]);
171 154 ht->count++;
172 return ent; 155 return ent;
173} 156}
174 157
175static inline void 158static inline void
176__dsthash_free(struct ipt_hashlimit_htable *ht, struct dsthash_ent *ent) 159dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent)
177{ 160{
178 hlist_del(&ent->node); 161 hlist_del(&ent->node);
179 kmem_cache_free(hashlimit_cachep, ent); 162 kmem_cache_free(hashlimit_cachep, ent);
180 atomic_dec(&ht->count); 163 ht->count--;
181} 164}
182static void htable_gc(unsigned long htlong); 165static void htable_gc(unsigned long htlong);
183 166
184static int htable_create(struct ipt_hashlimit_info *minfo) 167static int htable_create(struct xt_hashlimit_info *minfo, int family)
185{ 168{
186 int i; 169 struct xt_hashlimit_htable *hinfo;
187 unsigned int size; 170 unsigned int size;
188 struct ipt_hashlimit_htable *hinfo; 171 unsigned int i;
189 172
190 if (minfo->cfg.size) 173 if (minfo->cfg.size)
191 size = minfo->cfg.size; 174 size = minfo->cfg.size;
192 else { 175 else {
193 size = (((num_physpages << PAGE_SHIFT) / 16384) 176 size = ((num_physpages << PAGE_SHIFT) / 16384) /
194 / sizeof(struct list_head)); 177 sizeof(struct list_head);
195 if (num_physpages > (1024 * 1024 * 1024 / PAGE_SIZE)) 178 if (num_physpages > (1024 * 1024 * 1024 / PAGE_SIZE))
196 size = 8192; 179 size = 8192;
197 if (size < 16) 180 if (size < 16)
198 size = 16; 181 size = 16;
199 } 182 }
200 /* FIXME: don't use vmalloc() here or anywhere else -HW */ 183 /* FIXME: don't use vmalloc() here or anywhere else -HW */
201 hinfo = vmalloc(sizeof(struct ipt_hashlimit_htable) 184 hinfo = vmalloc(sizeof(struct xt_hashlimit_htable) +
202 + (sizeof(struct list_head) * size)); 185 sizeof(struct list_head) * size);
203 if (!hinfo) { 186 if (!hinfo) {
204 printk(KERN_ERR "ipt_hashlimit: Unable to create hashtable\n"); 187 printk(KERN_ERR "xt_hashlimit: unable to create hashtable\n");
205 return -1; 188 return -1;
206 } 189 }
207 minfo->hinfo = hinfo; 190 minfo->hinfo = hinfo;
@@ -217,11 +200,14 @@ static int htable_create(struct ipt_hashlimit_info *minfo)
217 for (i = 0; i < hinfo->cfg.size; i++) 200 for (i = 0; i < hinfo->cfg.size; i++)
218 INIT_HLIST_HEAD(&hinfo->hash[i]); 201 INIT_HLIST_HEAD(&hinfo->hash[i]);
219 202
220 atomic_set(&hinfo->count, 0);
221 atomic_set(&hinfo->use, 1); 203 atomic_set(&hinfo->use, 1);
204 hinfo->count = 0;
205 hinfo->family = family;
222 hinfo->rnd_initialized = 0; 206 hinfo->rnd_initialized = 0;
223 spin_lock_init(&hinfo->lock); 207 spin_lock_init(&hinfo->lock);
224 hinfo->pde = create_proc_entry(minfo->name, 0, hashlimit_procdir); 208 hinfo->pde = create_proc_entry(minfo->name, 0,
209 family == AF_INET ? hashlimit_procdir4 :
210 hashlimit_procdir6);
225 if (!hinfo->pde) { 211 if (!hinfo->pde) {
226 vfree(hinfo); 212 vfree(hinfo);
227 return -1; 213 return -1;
@@ -242,23 +228,21 @@ static int htable_create(struct ipt_hashlimit_info *minfo)
242 return 0; 228 return 0;
243} 229}
244 230
245static int select_all(struct ipt_hashlimit_htable *ht, struct dsthash_ent *he) 231static int select_all(struct xt_hashlimit_htable *ht, struct dsthash_ent *he)
246{ 232{
247 return 1; 233 return 1;
248} 234}
249 235
250static int select_gc(struct ipt_hashlimit_htable *ht, struct dsthash_ent *he) 236static int select_gc(struct xt_hashlimit_htable *ht, struct dsthash_ent *he)
251{ 237{
252 return (jiffies >= he->expires); 238 return (jiffies >= he->expires);
253} 239}
254 240
255static void htable_selective_cleanup(struct ipt_hashlimit_htable *ht, 241static void htable_selective_cleanup(struct xt_hashlimit_htable *ht,
256 int (*select)(struct ipt_hashlimit_htable *ht, 242 int (*select)(struct xt_hashlimit_htable *ht,
257 struct dsthash_ent *he)) 243 struct dsthash_ent *he))
258{ 244{
259 int i; 245 unsigned int i;
260
261 IP_NF_ASSERT(ht->cfg.size && ht->cfg.max);
262 246
263 /* lock hash table and iterate over it */ 247 /* lock hash table and iterate over it */
264 spin_lock_bh(&ht->lock); 248 spin_lock_bh(&ht->lock);
@@ -267,7 +251,7 @@ static void htable_selective_cleanup(struct ipt_hashlimit_htable *ht,
267 struct hlist_node *pos, *n; 251 struct hlist_node *pos, *n;
268 hlist_for_each_entry_safe(dh, pos, n, &ht->hash[i], node) { 252 hlist_for_each_entry_safe(dh, pos, n, &ht->hash[i], node) {
269 if ((*select)(ht, dh)) 253 if ((*select)(ht, dh))
270 __dsthash_free(ht, dh); 254 dsthash_free(ht, dh);
271 } 255 }
272 } 256 }
273 spin_unlock_bh(&ht->lock); 257 spin_unlock_bh(&ht->lock);
@@ -276,7 +260,7 @@ static void htable_selective_cleanup(struct ipt_hashlimit_htable *ht,
276/* hash table garbage collector, run by timer */ 260/* hash table garbage collector, run by timer */
277static void htable_gc(unsigned long htlong) 261static void htable_gc(unsigned long htlong)
278{ 262{
279 struct ipt_hashlimit_htable *ht = (struct ipt_hashlimit_htable *)htlong; 263 struct xt_hashlimit_htable *ht = (struct xt_hashlimit_htable *)htlong;
280 264
281 htable_selective_cleanup(ht, select_gc); 265 htable_selective_cleanup(ht, select_gc);
282 266
@@ -285,38 +269,39 @@ static void htable_gc(unsigned long htlong)
285 add_timer(&ht->timer); 269 add_timer(&ht->timer);
286} 270}
287 271
288static void htable_destroy(struct ipt_hashlimit_htable *hinfo) 272static void htable_destroy(struct xt_hashlimit_htable *hinfo)
289{ 273{
290 /* remove timer, if it is pending */ 274 /* remove timer, if it is pending */
291 if (timer_pending(&hinfo->timer)) 275 if (timer_pending(&hinfo->timer))
292 del_timer(&hinfo->timer); 276 del_timer(&hinfo->timer);
293 277
294 /* remove proc entry */ 278 /* remove proc entry */
295 remove_proc_entry(hinfo->pde->name, hashlimit_procdir); 279 remove_proc_entry(hinfo->pde->name,
296 280 hinfo->family == AF_INET ? hashlimit_procdir4 :
281 hashlimit_procdir6);
297 htable_selective_cleanup(hinfo, select_all); 282 htable_selective_cleanup(hinfo, select_all);
298 vfree(hinfo); 283 vfree(hinfo);
299} 284}
300 285
301static struct ipt_hashlimit_htable *htable_find_get(char *name) 286static struct xt_hashlimit_htable *htable_find_get(char *name, int family)
302{ 287{
303 struct ipt_hashlimit_htable *hinfo; 288 struct xt_hashlimit_htable *hinfo;
304 struct hlist_node *pos; 289 struct hlist_node *pos;
305 290
306 spin_lock_bh(&hashlimit_lock); 291 spin_lock_bh(&hashlimit_lock);
307 hlist_for_each_entry(hinfo, pos, &hashlimit_htables, node) { 292 hlist_for_each_entry(hinfo, pos, &hashlimit_htables, node) {
308 if (!strcmp(name, hinfo->pde->name)) { 293 if (!strcmp(name, hinfo->pde->name) &&
294 hinfo->family == family) {
309 atomic_inc(&hinfo->use); 295 atomic_inc(&hinfo->use);
310 spin_unlock_bh(&hashlimit_lock); 296 spin_unlock_bh(&hashlimit_lock);
311 return hinfo; 297 return hinfo;
312 } 298 }
313 } 299 }
314 spin_unlock_bh(&hashlimit_lock); 300 spin_unlock_bh(&hashlimit_lock);
315
316 return NULL; 301 return NULL;
317} 302}
318 303
319static void htable_put(struct ipt_hashlimit_htable *hinfo) 304static void htable_put(struct xt_hashlimit_htable *hinfo)
320{ 305{
321 if (atomic_dec_and_test(&hinfo->use)) { 306 if (atomic_dec_and_test(&hinfo->use)) {
322 spin_lock_bh(&hashlimit_lock); 307 spin_lock_bh(&hashlimit_lock);
@@ -326,7 +311,6 @@ static void htable_put(struct ipt_hashlimit_htable *hinfo)
326 } 311 }
327} 312}
328 313
329
330/* The algorithm used is the Simple Token Bucket Filter (TBF) 314/* The algorithm used is the Simple Token Bucket Filter (TBF)
331 * see net/sched/sch_tbf.c in the linux source tree 315 * see net/sched/sch_tbf.c in the linux source tree
332 */ 316 */
@@ -370,17 +354,82 @@ user2credits(u_int32_t user)
370 /* If multiplying would overflow... */ 354 /* If multiplying would overflow... */
371 if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY)) 355 if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY))
372 /* Divide first. */ 356 /* Divide first. */
373 return (user / IPT_HASHLIMIT_SCALE) * HZ * CREDITS_PER_JIFFY; 357 return (user / XT_HASHLIMIT_SCALE) * HZ * CREDITS_PER_JIFFY;
374 358
375 return (user * HZ * CREDITS_PER_JIFFY) / IPT_HASHLIMIT_SCALE; 359 return (user * HZ * CREDITS_PER_JIFFY) / XT_HASHLIMIT_SCALE;
376} 360}
377 361
378static inline void rateinfo_recalc(struct dsthash_ent *dh, unsigned long now) 362static inline void rateinfo_recalc(struct dsthash_ent *dh, unsigned long now)
379{ 363{
380 dh->rateinfo.credit += (now - xchg(&dh->rateinfo.prev, now)) 364 dh->rateinfo.credit += (now - dh->rateinfo.prev) * CREDITS_PER_JIFFY;
381 * CREDITS_PER_JIFFY;
382 if (dh->rateinfo.credit > dh->rateinfo.credit_cap) 365 if (dh->rateinfo.credit > dh->rateinfo.credit_cap)
383 dh->rateinfo.credit = dh->rateinfo.credit_cap; 366 dh->rateinfo.credit = dh->rateinfo.credit_cap;
367 dh->rateinfo.prev = now;
368}
369
370static int
371hashlimit_init_dst(struct xt_hashlimit_htable *hinfo, struct dsthash_dst *dst,
372 const struct sk_buff *skb, unsigned int protoff)
373{
374 __be16 _ports[2], *ports;
375 int nexthdr;
376
377 memset(dst, 0, sizeof(*dst));
378
379 switch (hinfo->family) {
380 case AF_INET:
381 if (hinfo->cfg.mode & XT_HASHLIMIT_HASH_DIP)
382 dst->addr.ip.dst = skb->nh.iph->daddr;
383 if (hinfo->cfg.mode & XT_HASHLIMIT_HASH_SIP)
384 dst->addr.ip.src = skb->nh.iph->saddr;
385
386 if (!(hinfo->cfg.mode &
387 (XT_HASHLIMIT_HASH_DPT | XT_HASHLIMIT_HASH_SPT)))
388 return 0;
389 nexthdr = skb->nh.iph->protocol;
390 break;
391#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
392 case AF_INET6:
393 if (hinfo->cfg.mode & XT_HASHLIMIT_HASH_DIP)
394 memcpy(&dst->addr.ip6.dst, &skb->nh.ipv6h->daddr,
395 sizeof(dst->addr.ip6.dst));
396 if (hinfo->cfg.mode & XT_HASHLIMIT_HASH_SIP)
397 memcpy(&dst->addr.ip6.src, &skb->nh.ipv6h->saddr,
398 sizeof(dst->addr.ip6.src));
399
400 if (!(hinfo->cfg.mode &
401 (XT_HASHLIMIT_HASH_DPT | XT_HASHLIMIT_HASH_SPT)))
402 return 0;
403 nexthdr = ipv6_find_hdr(skb, &protoff, -1, NULL);
404 if (nexthdr < 0)
405 return -1;
406 break;
407#endif
408 default:
409 BUG();
410 return 0;
411 }
412
413 switch (nexthdr) {
414 case IPPROTO_TCP:
415 case IPPROTO_UDP:
416 case IPPROTO_SCTP:
417 case IPPROTO_DCCP:
418 ports = skb_header_pointer(skb, protoff, sizeof(_ports),
419 &_ports);
420 break;
421 default:
422 _ports[0] = _ports[1] = 0;
423 ports = _ports;
424 break;
425 }
426 if (!ports)
427 return -1;
428 if (hinfo->cfg.mode & XT_HASHLIMIT_HASH_SPT)
429 dst->src_port = ports[0];
430 if (hinfo->cfg.mode & XT_HASHLIMIT_HASH_DPT)
431 dst->dst_port = ports[1];
432 return 0;
384} 433}
385 434
386static int 435static int
@@ -393,68 +442,31 @@ hashlimit_match(const struct sk_buff *skb,
393 unsigned int protoff, 442 unsigned int protoff,
394 int *hotdrop) 443 int *hotdrop)
395{ 444{
396 struct ipt_hashlimit_info *r = 445 struct xt_hashlimit_info *r =
397 ((struct ipt_hashlimit_info *)matchinfo)->u.master; 446 ((struct xt_hashlimit_info *)matchinfo)->u.master;
398 struct ipt_hashlimit_htable *hinfo = r->hinfo; 447 struct xt_hashlimit_htable *hinfo = r->hinfo;
399 unsigned long now = jiffies; 448 unsigned long now = jiffies;
400 struct dsthash_ent *dh; 449 struct dsthash_ent *dh;
401 struct dsthash_dst dst; 450 struct dsthash_dst dst;
402 451
403 /* build 'dst' according to hinfo->cfg and current packet */ 452 if (hashlimit_init_dst(hinfo, &dst, skb, protoff) < 0)
404 memset(&dst, 0, sizeof(dst)); 453 goto hotdrop;
405 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DIP)
406 dst.dst_ip = skb->nh.iph->daddr;
407 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SIP)
408 dst.src_ip = skb->nh.iph->saddr;
409 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT
410 ||hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT) {
411 __be16 _ports[2], *ports;
412
413 switch (skb->nh.iph->protocol) {
414 case IPPROTO_TCP:
415 case IPPROTO_UDP:
416 case IPPROTO_SCTP:
417 case IPPROTO_DCCP:
418 ports = skb_header_pointer(skb, skb->nh.iph->ihl*4,
419 sizeof(_ports), &_ports);
420 break;
421 default:
422 _ports[0] = _ports[1] = 0;
423 ports = _ports;
424 break;
425 }
426 if (!ports) {
427 /* We've been asked to examine this packet, and we
428 can't. Hence, no choice but to drop. */
429 *hotdrop = 1;
430 return 0;
431 }
432 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_SPT)
433 dst.src_port = ports[0];
434 if (hinfo->cfg.mode & IPT_HASHLIMIT_HASH_DPT)
435 dst.dst_port = ports[1];
436 }
437 454
438 spin_lock_bh(&hinfo->lock); 455 spin_lock_bh(&hinfo->lock);
439 dh = __dsthash_find(hinfo, &dst); 456 dh = dsthash_find(hinfo, &dst);
440 if (!dh) { 457 if (!dh) {
441 dh = __dsthash_alloc_init(hinfo, &dst); 458 dh = dsthash_alloc_init(hinfo, &dst);
442
443 if (!dh) { 459 if (!dh) {
444 /* enomem... don't match == DROP */
445 if (net_ratelimit())
446 printk(KERN_ERR "%s: ENOMEM\n", __FUNCTION__);
447 spin_unlock_bh(&hinfo->lock); 460 spin_unlock_bh(&hinfo->lock);
448 return 0; 461 goto hotdrop;
449 } 462 }
450 463
451 dh->expires = jiffies + msecs_to_jiffies(hinfo->cfg.expire); 464 dh->expires = jiffies + msecs_to_jiffies(hinfo->cfg.expire);
452
453 dh->rateinfo.prev = jiffies; 465 dh->rateinfo.prev = jiffies;
454 dh->rateinfo.credit = user2credits(hinfo->cfg.avg * 466 dh->rateinfo.credit = user2credits(hinfo->cfg.avg *
455 hinfo->cfg.burst); 467 hinfo->cfg.burst);
456 dh->rateinfo.credit_cap = user2credits(hinfo->cfg.avg * 468 dh->rateinfo.credit_cap = user2credits(hinfo->cfg.avg *
457 hinfo->cfg.burst); 469 hinfo->cfg.burst);
458 dh->rateinfo.cost = user2credits(hinfo->cfg.avg); 470 dh->rateinfo.cost = user2credits(hinfo->cfg.avg);
459 } else { 471 } else {
460 /* update expiration timeout */ 472 /* update expiration timeout */
@@ -473,6 +485,10 @@ hashlimit_match(const struct sk_buff *skb,
473 485
474 /* default case: we're overlimit, thus don't match */ 486 /* default case: we're overlimit, thus don't match */
475 return 0; 487 return 0;
488
489hotdrop:
490 *hotdrop = 1;
491 return 0;
476} 492}
477 493
478static int 494static int
@@ -482,42 +498,37 @@ hashlimit_checkentry(const char *tablename,
482 void *matchinfo, 498 void *matchinfo,
483 unsigned int hook_mask) 499 unsigned int hook_mask)
484{ 500{
485 struct ipt_hashlimit_info *r = matchinfo; 501 struct xt_hashlimit_info *r = matchinfo;
486 502
487 /* Check for overflow. */ 503 /* Check for overflow. */
488 if (r->cfg.burst == 0 504 if (r->cfg.burst == 0 ||
489 || user2credits(r->cfg.avg * r->cfg.burst) < 505 user2credits(r->cfg.avg * r->cfg.burst) < user2credits(r->cfg.avg)) {
490 user2credits(r->cfg.avg)) { 506 printk(KERN_ERR "xt_hashlimit: overflow, try lower: %u/%u\n",
491 printk(KERN_ERR "ipt_hashlimit: Overflow, try lower: %u/%u\n",
492 r->cfg.avg, r->cfg.burst); 507 r->cfg.avg, r->cfg.burst);
493 return 0; 508 return 0;
494 } 509 }
495 510 if (r->cfg.mode == 0 ||
496 if (r->cfg.mode == 0 511 r->cfg.mode > (XT_HASHLIMIT_HASH_DPT |
497 || r->cfg.mode > (IPT_HASHLIMIT_HASH_DPT 512 XT_HASHLIMIT_HASH_DIP |
498 |IPT_HASHLIMIT_HASH_DIP 513 XT_HASHLIMIT_HASH_SIP |
499 |IPT_HASHLIMIT_HASH_SIP 514 XT_HASHLIMIT_HASH_SPT))
500 |IPT_HASHLIMIT_HASH_SPT))
501 return 0; 515 return 0;
502
503 if (!r->cfg.gc_interval) 516 if (!r->cfg.gc_interval)
504 return 0; 517 return 0;
505
506 if (!r->cfg.expire) 518 if (!r->cfg.expire)
507 return 0; 519 return 0;
508
509 if (r->name[sizeof(r->name) - 1] != '\0') 520 if (r->name[sizeof(r->name) - 1] != '\0')
510 return 0; 521 return 0;
511 522
512 /* This is the best we've got: We cannot release and re-grab lock, 523 /* This is the best we've got: We cannot release and re-grab lock,
513 * since checkentry() is called before ip_tables.c grabs ipt_mutex. 524 * since checkentry() is called before x_tables.c grabs xt_mutex.
514 * We also cannot grab the hashtable spinlock, since htable_create will 525 * We also cannot grab the hashtable spinlock, since htable_create will
515 * call vmalloc, and that can sleep. And we cannot just re-search 526 * call vmalloc, and that can sleep. And we cannot just re-search
516 * the list of htable's in htable_create(), since then we would 527 * the list of htable's in htable_create(), since then we would
517 * create duplicate proc files. -HW */ 528 * create duplicate proc files. -HW */
518 mutex_lock(&hlimit_mutex); 529 mutex_lock(&hlimit_mutex);
519 r->hinfo = htable_find_get(r->name); 530 r->hinfo = htable_find_get(r->name, match->family);
520 if (!r->hinfo && (htable_create(r) != 0)) { 531 if (!r->hinfo && htable_create(r, match->family) != 0) {
521 mutex_unlock(&hlimit_mutex); 532 mutex_unlock(&hlimit_mutex);
522 return 0; 533 return 0;
523 } 534 }
@@ -525,20 +536,19 @@ hashlimit_checkentry(const char *tablename,
525 536
526 /* Ugly hack: For SMP, we only want to use one set */ 537 /* Ugly hack: For SMP, we only want to use one set */
527 r->u.master = r; 538 r->u.master = r;
528
529 return 1; 539 return 1;
530} 540}
531 541
532static void 542static void
533hashlimit_destroy(const struct xt_match *match, void *matchinfo) 543hashlimit_destroy(const struct xt_match *match, void *matchinfo)
534{ 544{
535 struct ipt_hashlimit_info *r = matchinfo; 545 struct xt_hashlimit_info *r = matchinfo;
536 546
537 htable_put(r->hinfo); 547 htable_put(r->hinfo);
538} 548}
539 549
540#ifdef CONFIG_COMPAT 550#ifdef CONFIG_COMPAT
541struct compat_ipt_hashlimit_info { 551struct compat_xt_hashlimit_info {
542 char name[IFNAMSIZ]; 552 char name[IFNAMSIZ];
543 struct hashlimit_cfg cfg; 553 struct hashlimit_cfg cfg;
544 compat_uptr_t hinfo; 554 compat_uptr_t hinfo;
@@ -547,40 +557,56 @@ struct compat_ipt_hashlimit_info {
547 557
548static void compat_from_user(void *dst, void *src) 558static void compat_from_user(void *dst, void *src)
549{ 559{
550 int off = offsetof(struct compat_ipt_hashlimit_info, hinfo); 560 int off = offsetof(struct compat_xt_hashlimit_info, hinfo);
551 561
552 memcpy(dst, src, off); 562 memcpy(dst, src, off);
553 memset(dst + off, 0, sizeof(struct compat_ipt_hashlimit_info) - off); 563 memset(dst + off, 0, sizeof(struct compat_xt_hashlimit_info) - off);
554} 564}
555 565
556static int compat_to_user(void __user *dst, void *src) 566static int compat_to_user(void __user *dst, void *src)
557{ 567{
558 int off = offsetof(struct compat_ipt_hashlimit_info, hinfo); 568 int off = offsetof(struct compat_xt_hashlimit_info, hinfo);
559 569
560 return copy_to_user(dst, src, off) ? -EFAULT : 0; 570 return copy_to_user(dst, src, off) ? -EFAULT : 0;
561} 571}
562#endif 572#endif
563 573
564static struct ipt_match ipt_hashlimit = { 574static struct xt_match xt_hashlimit[] = {
565 .name = "hashlimit", 575 {
566 .match = hashlimit_match, 576 .name = "hashlimit",
567 .matchsize = sizeof(struct ipt_hashlimit_info), 577 .family = AF_INET,
578 .match = hashlimit_match,
579 .matchsize = sizeof(struct xt_hashlimit_info),
580#ifdef CONFIG_COMPAT
581 .compatsize = sizeof(struct compat_xt_hashlimit_info),
582 .compat_from_user = compat_from_user,
583 .compat_to_user = compat_to_user,
584#endif
585 .checkentry = hashlimit_checkentry,
586 .destroy = hashlimit_destroy,
587 .me = THIS_MODULE
588 },
589 {
590 .name = "hashlimit",
591 .family = AF_INET6,
592 .match = hashlimit_match,
593 .matchsize = sizeof(struct xt_hashlimit_info),
568#ifdef CONFIG_COMPAT 594#ifdef CONFIG_COMPAT
569 .compatsize = sizeof(struct compat_ipt_hashlimit_info), 595 .compatsize = sizeof(struct compat_xt_hashlimit_info),
570 .compat_from_user = compat_from_user, 596 .compat_from_user = compat_from_user,
571 .compat_to_user = compat_to_user, 597 .compat_to_user = compat_to_user,
572#endif 598#endif
573 .checkentry = hashlimit_checkentry, 599 .checkentry = hashlimit_checkentry,
574 .destroy = hashlimit_destroy, 600 .destroy = hashlimit_destroy,
575 .me = THIS_MODULE 601 .me = THIS_MODULE
602 },
576}; 603};
577 604
578/* PROC stuff */ 605/* PROC stuff */
579
580static void *dl_seq_start(struct seq_file *s, loff_t *pos) 606static void *dl_seq_start(struct seq_file *s, loff_t *pos)
581{ 607{
582 struct proc_dir_entry *pde = s->private; 608 struct proc_dir_entry *pde = s->private;
583 struct ipt_hashlimit_htable *htable = pde->data; 609 struct xt_hashlimit_htable *htable = pde->data;
584 unsigned int *bucket; 610 unsigned int *bucket;
585 611
586 spin_lock_bh(&htable->lock); 612 spin_lock_bh(&htable->lock);
@@ -598,7 +624,7 @@ static void *dl_seq_start(struct seq_file *s, loff_t *pos)
598static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos) 624static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos)
599{ 625{
600 struct proc_dir_entry *pde = s->private; 626 struct proc_dir_entry *pde = s->private;
601 struct ipt_hashlimit_htable *htable = pde->data; 627 struct xt_hashlimit_htable *htable = pde->data;
602 unsigned int *bucket = (unsigned int *)v; 628 unsigned int *bucket = (unsigned int *)v;
603 629
604 *pos = ++(*bucket); 630 *pos = ++(*bucket);
@@ -612,43 +638,59 @@ static void *dl_seq_next(struct seq_file *s, void *v, loff_t *pos)
612static void dl_seq_stop(struct seq_file *s, void *v) 638static void dl_seq_stop(struct seq_file *s, void *v)
613{ 639{
614 struct proc_dir_entry *pde = s->private; 640 struct proc_dir_entry *pde = s->private;
615 struct ipt_hashlimit_htable *htable = pde->data; 641 struct xt_hashlimit_htable *htable = pde->data;
616 unsigned int *bucket = (unsigned int *)v; 642 unsigned int *bucket = (unsigned int *)v;
617 643
618 kfree(bucket); 644 kfree(bucket);
619
620 spin_unlock_bh(&htable->lock); 645 spin_unlock_bh(&htable->lock);
621} 646}
622 647
623static inline int dl_seq_real_show(struct dsthash_ent *ent, struct seq_file *s) 648static int dl_seq_real_show(struct dsthash_ent *ent, int family,
649 struct seq_file *s)
624{ 650{
625 /* recalculate to show accurate numbers */ 651 /* recalculate to show accurate numbers */
626 rateinfo_recalc(ent, jiffies); 652 rateinfo_recalc(ent, jiffies);
627 653
628 return seq_printf(s, "%ld %u.%u.%u.%u:%u->%u.%u.%u.%u:%u %u %u %u\n", 654 switch (family) {
629 (long)(ent->expires - jiffies)/HZ, 655 case AF_INET:
630 NIPQUAD(ent->dst.src_ip), ntohs(ent->dst.src_port), 656 return seq_printf(s, "%ld %u.%u.%u.%u:%u->"
631 NIPQUAD(ent->dst.dst_ip), ntohs(ent->dst.dst_port), 657 "%u.%u.%u.%u:%u %u %u %u\n",
632 ent->rateinfo.credit, ent->rateinfo.credit_cap, 658 (long)(ent->expires - jiffies)/HZ,
633 ent->rateinfo.cost); 659 NIPQUAD(ent->dst.addr.ip.src),
660 ntohs(ent->dst.src_port),
661 NIPQUAD(ent->dst.addr.ip.dst),
662 ntohs(ent->dst.dst_port),
663 ent->rateinfo.credit, ent->rateinfo.credit_cap,
664 ent->rateinfo.cost);
665 case AF_INET6:
666 return seq_printf(s, "%ld " NIP6_FMT ":%u->"
667 NIP6_FMT ":%u %u %u %u\n",
668 (long)(ent->expires - jiffies)/HZ,
669 NIP6(*(struct in6_addr *)&ent->dst.addr.ip6.src),
670 ntohs(ent->dst.src_port),
671 NIP6(*(struct in6_addr *)&ent->dst.addr.ip6.dst),
672 ntohs(ent->dst.dst_port),
673 ent->rateinfo.credit, ent->rateinfo.credit_cap,
674 ent->rateinfo.cost);
675 default:
676 BUG();
677 return 0;
678 }
634} 679}
635 680
636static int dl_seq_show(struct seq_file *s, void *v) 681static int dl_seq_show(struct seq_file *s, void *v)
637{ 682{
638 struct proc_dir_entry *pde = s->private; 683 struct proc_dir_entry *pde = s->private;
639 struct ipt_hashlimit_htable *htable = pde->data; 684 struct xt_hashlimit_htable *htable = pde->data;
640 unsigned int *bucket = (unsigned int *)v; 685 unsigned int *bucket = (unsigned int *)v;
641 struct dsthash_ent *ent; 686 struct dsthash_ent *ent;
642 struct hlist_node *pos; 687 struct hlist_node *pos;
643 688
644 if (!hlist_empty(&htable->hash[*bucket])) 689 if (!hlist_empty(&htable->hash[*bucket])) {
645 hlist_for_each_entry(ent, pos, &htable->hash[*bucket], node) { 690 hlist_for_each_entry(ent, pos, &htable->hash[*bucket], node)
646 if (dl_seq_real_show(ent, s)) { 691 if (dl_seq_real_show(ent, htable->family, s))
647 /* buffer was filled and unable to print that tuple */
648 return 1; 692 return 1;
649 } 693 }
650 }
651
652 return 0; 694 return 0;
653} 695}
654 696
@@ -678,56 +720,53 @@ static struct file_operations dl_file_ops = {
678 .release = seq_release 720 .release = seq_release
679}; 721};
680 722
681static int init_or_fini(int fini) 723static int __init xt_hashlimit_init(void)
682{ 724{
683 int ret = 0; 725 int err;
684
685 if (fini)
686 goto cleanup;
687 726
688 if (ipt_register_match(&ipt_hashlimit)) { 727 err = xt_register_matches(xt_hashlimit, ARRAY_SIZE(xt_hashlimit));
689 ret = -EINVAL; 728 if (err < 0)
690 goto cleanup_nothing; 729 goto err1;
691 }
692 730
693 hashlimit_cachep = kmem_cache_create("ipt_hashlimit", 731 err = -ENOMEM;
694 sizeof(struct dsthash_ent), 0, 732 hashlimit_cachep = kmem_cache_create("xt_hashlimit",
695 0, NULL, NULL); 733 sizeof(struct dsthash_ent), 0, 0,
734 NULL, NULL);
696 if (!hashlimit_cachep) { 735 if (!hashlimit_cachep) {
697 printk(KERN_ERR "Unable to create ipt_hashlimit slab cache\n"); 736 printk(KERN_ERR "xt_hashlimit: unable to create slab cache\n");
698 ret = -ENOMEM; 737 goto err2;
699 goto cleanup_unreg_match;
700 } 738 }
701 739 hashlimit_procdir4 = proc_mkdir("ipt_hashlimit", proc_net);
702 hashlimit_procdir = proc_mkdir("ipt_hashlimit", proc_net); 740 if (!hashlimit_procdir4) {
703 if (!hashlimit_procdir) { 741 printk(KERN_ERR "xt_hashlimit: unable to create proc dir "
704 printk(KERN_ERR "Unable to create proc dir entry\n"); 742 "entry\n");
705 ret = -ENOMEM; 743 goto err3;
706 goto cleanup_free_slab;
707 } 744 }
708 745 hashlimit_procdir6 = proc_mkdir("ip6t_hashlimit", proc_net);
709 return ret; 746 if (!hashlimit_procdir6) {
710 747 printk(KERN_ERR "xt_hashlimit: tnable to create proc dir "
711cleanup: 748 "entry\n");
749 goto err4;
750 }
751 return 0;
752err4:
712 remove_proc_entry("ipt_hashlimit", proc_net); 753 remove_proc_entry("ipt_hashlimit", proc_net);
713cleanup_free_slab: 754err3:
714 kmem_cache_destroy(hashlimit_cachep); 755 kmem_cache_destroy(hashlimit_cachep);
715cleanup_unreg_match: 756err2:
716 ipt_unregister_match(&ipt_hashlimit); 757 xt_unregister_matches(xt_hashlimit, ARRAY_SIZE(xt_hashlimit));
717cleanup_nothing: 758err1:
718 return ret; 759 return err;
719
720}
721 760
722static int __init ipt_hashlimit_init(void)
723{
724 return init_or_fini(0);
725} 761}
726 762
727static void __exit ipt_hashlimit_fini(void) 763static void __exit xt_hashlimit_fini(void)
728{ 764{
729 init_or_fini(1); 765 remove_proc_entry("ipt_hashlimit", proc_net);
766 remove_proc_entry("ip6t_hashlimit", proc_net);
767 kmem_cache_destroy(hashlimit_cachep);
768 xt_unregister_matches(xt_hashlimit, ARRAY_SIZE(xt_hashlimit));
730} 769}
731 770
732module_init(ipt_hashlimit_init); 771module_init(xt_hashlimit_init);
733module_exit(ipt_hashlimit_fini); 772module_exit(xt_hashlimit_fini);
diff --git a/net/netfilter/xt_mark.c b/net/netfilter/xt_mark.c
index 934dddfbcd23..dfa1ee6914c0 100644
--- a/net/netfilter/xt_mark.c
+++ b/net/netfilter/xt_mark.c
@@ -31,7 +31,7 @@ match(const struct sk_buff *skb,
31{ 31{
32 const struct xt_mark_info *info = matchinfo; 32 const struct xt_mark_info *info = matchinfo;
33 33
34 return ((skb->nfmark & info->mask) == info->mark) ^ info->invert; 34 return ((skb->mark & info->mask) == info->mark) ^ info->invert;
35} 35}
36 36
37static int 37static int
diff --git a/net/netfilter/xt_multiport.c b/net/netfilter/xt_multiport.c
index d3aefd380930..1602086c7fd6 100644
--- a/net/netfilter/xt_multiport.c
+++ b/net/netfilter/xt_multiport.c
@@ -1,5 +1,5 @@
1/* Kernel module to match one of a list of TCP/UDP/SCTP/DCCP ports: ports are in 1/* Kernel module to match one of a list of TCP/UDP(-Lite)/SCTP/DCCP ports:
2 the same place so we can treat them as equal. */ 2 ports are in 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
5 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> 5 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
@@ -104,7 +104,7 @@ match(const struct sk_buff *skb,
104 unsigned int protoff, 104 unsigned int protoff,
105 int *hotdrop) 105 int *hotdrop)
106{ 106{
107 u16 _ports[2], *pptr; 107 __be16 _ports[2], *pptr;
108 const struct xt_multiport *multiinfo = matchinfo; 108 const struct xt_multiport *multiinfo = matchinfo;
109 109
110 if (offset) 110 if (offset)
@@ -135,7 +135,7 @@ match_v1(const struct sk_buff *skb,
135 unsigned int protoff, 135 unsigned int protoff,
136 int *hotdrop) 136 int *hotdrop)
137{ 137{
138 u16 _ports[2], *pptr; 138 __be16 _ports[2], *pptr;
139 const struct xt_multiport_v1 *multiinfo = matchinfo; 139 const struct xt_multiport_v1 *multiinfo = matchinfo;
140 140
141 if (offset) 141 if (offset)
@@ -162,6 +162,7 @@ check(u_int16_t proto,
162{ 162{
163 /* Must specify supported protocol, 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_UDPLITE
165 || proto == IPPROTO_SCTP || proto == IPPROTO_DCCP) 166 || proto == IPPROTO_SCTP || proto == IPPROTO_DCCP)
166 && !(ip_invflags & XT_INV_PROTO) 167 && !(ip_invflags & XT_INV_PROTO)
167 && (match_flags == XT_MULTIPORT_SOURCE 168 && (match_flags == XT_MULTIPORT_SOURCE
diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index 7956acaaa24b..71bf036f833c 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -71,7 +71,7 @@ match_packet(const struct sk_buff *skb,
71 duprintf("Chunk num: %d\toffset: %d\ttype: %d\tlength: %d\tflags: %x\n", 71 duprintf("Chunk num: %d\toffset: %d\ttype: %d\tlength: %d\tflags: %x\n",
72 ++i, offset, sch->type, htons(sch->length), sch->flags); 72 ++i, offset, sch->type, htons(sch->length), sch->flags);
73 73
74 offset += (htons(sch->length) + 3) & ~3; 74 offset += (ntohs(sch->length) + 3) & ~3;
75 75
76 duprintf("skb->len: %d\toffset: %d\n", skb->len, offset); 76 duprintf("skb->len: %d\toffset: %d\n", skb->len, offset);
77 77
diff --git a/net/netfilter/xt_tcpudp.c b/net/netfilter/xt_tcpudp.c
index e76a68e0bc66..46414b562a19 100644
--- a/net/netfilter/xt_tcpudp.c
+++ b/net/netfilter/xt_tcpudp.c
@@ -10,7 +10,7 @@
10#include <linux/netfilter_ipv4/ip_tables.h> 10#include <linux/netfilter_ipv4/ip_tables.h>
11#include <linux/netfilter_ipv6/ip6_tables.h> 11#include <linux/netfilter_ipv6/ip6_tables.h>
12 12
13MODULE_DESCRIPTION("x_tables match for TCP and UDP, supports IPv4 and IPv6"); 13MODULE_DESCRIPTION("x_tables match for TCP and UDP(-Lite), supports IPv4 and IPv6");
14MODULE_LICENSE("GPL"); 14MODULE_LICENSE("GPL");
15MODULE_ALIAS("xt_tcp"); 15MODULE_ALIAS("xt_tcp");
16MODULE_ALIAS("xt_udp"); 16MODULE_ALIAS("xt_udp");
@@ -234,6 +234,24 @@ static struct xt_match xt_tcpudp_match[] = {
234 .proto = IPPROTO_UDP, 234 .proto = IPPROTO_UDP,
235 .me = THIS_MODULE, 235 .me = THIS_MODULE,
236 }, 236 },
237 {
238 .name = "udplite",
239 .family = AF_INET,
240 .checkentry = udp_checkentry,
241 .match = udp_match,
242 .matchsize = sizeof(struct xt_udp),
243 .proto = IPPROTO_UDPLITE,
244 .me = THIS_MODULE,
245 },
246 {
247 .name = "udplite",
248 .family = AF_INET6,
249 .checkentry = udp_checkentry,
250 .match = udp_match,
251 .matchsize = sizeof(struct xt_udp),
252 .proto = IPPROTO_UDPLITE,
253 .me = THIS_MODULE,
254 },
237}; 255};
238 256
239static int __init xt_tcpudp_init(void) 257static int __init xt_tcpudp_init(void)
diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index a6ce1d6d5c59..743b05734a49 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -407,12 +407,14 @@ static int netlbl_cipsov4_add(struct sk_buff *skb, struct genl_info *info)
407 407
408 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_ADD, 408 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_ADD,
409 &audit_info); 409 &audit_info);
410 audit_log_format(audit_buf, 410 if (audit_buf != NULL) {
411 " cipso_doi=%u cipso_type=%s res=%u", 411 audit_log_format(audit_buf,
412 doi, 412 " cipso_doi=%u cipso_type=%s res=%u",
413 type_str, 413 doi,
414 ret_val == 0 ? 1 : 0); 414 type_str,
415 audit_log_end(audit_buf); 415 ret_val == 0 ? 1 : 0);
416 audit_log_end(audit_buf);
417 }
416 418
417 return ret_val; 419 return ret_val;
418} 420}
@@ -452,17 +454,13 @@ static int netlbl_cipsov4_list(struct sk_buff *skb, struct genl_info *info)
452 } 454 }
453 455
454list_start: 456list_start:
455 ans_skb = nlmsg_new(NLMSG_GOODSIZE * nlsze_mult, GFP_KERNEL); 457 ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE * nlsze_mult, GFP_KERNEL);
456 if (ans_skb == NULL) { 458 if (ans_skb == NULL) {
457 ret_val = -ENOMEM; 459 ret_val = -ENOMEM;
458 goto list_failure; 460 goto list_failure;
459 } 461 }
460 data = netlbl_netlink_hdr_put(ans_skb, 462 data = genlmsg_put_reply(ans_skb, info, &netlbl_cipsov4_gnl_family,
461 info->snd_pid, 463 0, NLBL_CIPSOV4_C_LIST);
462 info->snd_seq,
463 netlbl_cipsov4_gnl_family.id,
464 0,
465 NLBL_CIPSOV4_C_LIST);
466 if (data == NULL) { 464 if (data == NULL) {
467 ret_val = -ENOMEM; 465 ret_val = -ENOMEM;
468 goto list_failure; 466 goto list_failure;
@@ -568,7 +566,7 @@ list_start:
568 566
569 genlmsg_end(ans_skb, data); 567 genlmsg_end(ans_skb, data);
570 568
571 ret_val = genlmsg_unicast(ans_skb, info->snd_pid); 569 ret_val = genlmsg_reply(ans_skb, info);
572 if (ret_val != 0) 570 if (ret_val != 0)
573 goto list_failure; 571 goto list_failure;
574 572
@@ -607,12 +605,9 @@ static int netlbl_cipsov4_listall_cb(struct cipso_v4_doi *doi_def, void *arg)
607 struct netlbl_cipsov4_doiwalk_arg *cb_arg = arg; 605 struct netlbl_cipsov4_doiwalk_arg *cb_arg = arg;
608 void *data; 606 void *data;
609 607
610 data = netlbl_netlink_hdr_put(cb_arg->skb, 608 data = genlmsg_put(cb_arg->skb, NETLINK_CB(cb_arg->nl_cb->skb).pid,
611 NETLINK_CB(cb_arg->nl_cb->skb).pid, 609 cb_arg->seq, &netlbl_cipsov4_gnl_family,
612 cb_arg->seq, 610 NLM_F_MULTI, NLBL_CIPSOV4_C_LISTALL);
613 netlbl_cipsov4_gnl_family.id,
614 NLM_F_MULTI,
615 NLBL_CIPSOV4_C_LISTALL);
616 if (data == NULL) 611 if (data == NULL)
617 goto listall_cb_failure; 612 goto listall_cb_failure;
618 613
@@ -687,11 +682,13 @@ static int netlbl_cipsov4_remove(struct sk_buff *skb, struct genl_info *info)
687 682
688 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_DEL, 683 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_DEL,
689 &audit_info); 684 &audit_info);
690 audit_log_format(audit_buf, 685 if (audit_buf != NULL) {
691 " cipso_doi=%u res=%u", 686 audit_log_format(audit_buf,
692 doi, 687 " cipso_doi=%u res=%u",
693 ret_val == 0 ? 1 : 0); 688 doi,
694 audit_log_end(audit_buf); 689 ret_val == 0 ? 1 : 0);
690 audit_log_end(audit_buf);
691 }
695 692
696 return ret_val; 693 return ret_val;
697} 694}
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index af4371d3b459..f46a0aeec44f 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -202,7 +202,6 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
202 int ret_val; 202 int ret_val;
203 u32 bkt; 203 u32 bkt;
204 struct audit_buffer *audit_buf; 204 struct audit_buffer *audit_buf;
205 char *audit_domain;
206 205
207 switch (entry->type) { 206 switch (entry->type) {
208 case NETLBL_NLTYPE_UNLABELED: 207 case NETLBL_NLTYPE_UNLABELED:
@@ -243,24 +242,24 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
243 } else 242 } else
244 ret_val = -EINVAL; 243 ret_val = -EINVAL;
245 244
246 if (entry->domain != NULL)
247 audit_domain = entry->domain;
248 else
249 audit_domain = "(default)";
250 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, audit_info); 245 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, audit_info);
251 audit_log_format(audit_buf, " nlbl_domain=%s", audit_domain); 246 if (audit_buf != NULL) {
252 switch (entry->type) {
253 case NETLBL_NLTYPE_UNLABELED:
254 audit_log_format(audit_buf, " nlbl_protocol=unlbl");
255 break;
256 case NETLBL_NLTYPE_CIPSOV4:
257 audit_log_format(audit_buf, 247 audit_log_format(audit_buf,
258 " nlbl_protocol=cipsov4 cipso_doi=%u", 248 " nlbl_domain=%s",
259 entry->type_def.cipsov4->doi); 249 entry->domain ? entry->domain : "(default)");
260 break; 250 switch (entry->type) {
251 case NETLBL_NLTYPE_UNLABELED:
252 audit_log_format(audit_buf, " nlbl_protocol=unlbl");
253 break;
254 case NETLBL_NLTYPE_CIPSOV4:
255 audit_log_format(audit_buf,
256 " nlbl_protocol=cipsov4 cipso_doi=%u",
257 entry->type_def.cipsov4->doi);
258 break;
259 }
260 audit_log_format(audit_buf, " res=%u", ret_val == 0 ? 1 : 0);
261 audit_log_end(audit_buf);
261 } 262 }
262 audit_log_format(audit_buf, " res=%u", ret_val == 0 ? 1 : 0);
263 audit_log_end(audit_buf);
264 263
265 rcu_read_unlock(); 264 rcu_read_unlock();
266 265
@@ -310,7 +309,6 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info)
310 int ret_val = -ENOENT; 309 int ret_val = -ENOENT;
311 struct netlbl_dom_map *entry; 310 struct netlbl_dom_map *entry;
312 struct audit_buffer *audit_buf; 311 struct audit_buffer *audit_buf;
313 char *audit_domain;
314 312
315 rcu_read_lock(); 313 rcu_read_lock();
316 if (domain != NULL) 314 if (domain != NULL)
@@ -348,16 +346,14 @@ int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info)
348 spin_unlock(&netlbl_domhsh_def_lock); 346 spin_unlock(&netlbl_domhsh_def_lock);
349 } 347 }
350 348
351 if (entry->domain != NULL)
352 audit_domain = entry->domain;
353 else
354 audit_domain = "(default)";
355 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, audit_info); 349 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, audit_info);
356 audit_log_format(audit_buf, 350 if (audit_buf != NULL) {
357 " nlbl_domain=%s res=%u", 351 audit_log_format(audit_buf,
358 audit_domain, 352 " nlbl_domain=%s res=%u",
359 ret_val == 0 ? 1 : 0); 353 entry->domain ? entry->domain : "(default)",
360 audit_log_end(audit_buf); 354 ret_val == 0 ? 1 : 0);
355 audit_log_end(audit_buf);
356 }
361 357
362 if (ret_val == 0) 358 if (ret_val == 0)
363 call_rcu(&entry->rcu, netlbl_domhsh_free_entry); 359 call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index ff971103fd0c..e03a3282c551 100644
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -40,6 +40,207 @@
40#include "netlabel_user.h" 40#include "netlabel_user.h"
41 41
42/* 42/*
43 * Security Attribute Functions
44 */
45
46/**
47 * netlbl_secattr_catmap_walk - Walk a LSM secattr catmap looking for a bit
48 * @catmap: the category bitmap
49 * @offset: the offset to start searching at, in bits
50 *
51 * Description:
52 * This function walks a LSM secattr category bitmap starting at @offset and
53 * returns the spot of the first set bit or -ENOENT if no bits are set.
54 *
55 */
56int netlbl_secattr_catmap_walk(struct netlbl_lsm_secattr_catmap *catmap,
57 u32 offset)
58{
59 struct netlbl_lsm_secattr_catmap *iter = catmap;
60 u32 node_idx;
61 u32 node_bit;
62 NETLBL_CATMAP_MAPTYPE bitmap;
63
64 if (offset > iter->startbit) {
65 while (offset >= (iter->startbit + NETLBL_CATMAP_SIZE)) {
66 iter = iter->next;
67 if (iter == NULL)
68 return -ENOENT;
69 }
70 node_idx = (offset - iter->startbit) / NETLBL_CATMAP_MAPSIZE;
71 node_bit = offset - iter->startbit -
72 (NETLBL_CATMAP_MAPSIZE * node_idx);
73 } else {
74 node_idx = 0;
75 node_bit = 0;
76 }
77 bitmap = iter->bitmap[node_idx] >> node_bit;
78
79 for (;;) {
80 if (bitmap != 0) {
81 while ((bitmap & NETLBL_CATMAP_BIT) == 0) {
82 bitmap >>= 1;
83 node_bit++;
84 }
85 return iter->startbit +
86 (NETLBL_CATMAP_MAPSIZE * node_idx) + node_bit;
87 }
88 if (++node_idx >= NETLBL_CATMAP_MAPCNT) {
89 if (iter->next != NULL) {
90 iter = iter->next;
91 node_idx = 0;
92 } else
93 return -ENOENT;
94 }
95 bitmap = iter->bitmap[node_idx];
96 node_bit = 0;
97 }
98
99 return -ENOENT;
100}
101
102/**
103 * netlbl_secattr_catmap_walk_rng - Find the end of a string of set bits
104 * @catmap: the category bitmap
105 * @offset: the offset to start searching at, in bits
106 *
107 * Description:
108 * This function walks a LSM secattr category bitmap starting at @offset and
109 * returns the spot of the first cleared bit or -ENOENT if the offset is past
110 * the end of the bitmap.
111 *
112 */
113int netlbl_secattr_catmap_walk_rng(struct netlbl_lsm_secattr_catmap *catmap,
114 u32 offset)
115{
116 struct netlbl_lsm_secattr_catmap *iter = catmap;
117 u32 node_idx;
118 u32 node_bit;
119 NETLBL_CATMAP_MAPTYPE bitmask;
120 NETLBL_CATMAP_MAPTYPE bitmap;
121
122 if (offset > iter->startbit) {
123 while (offset >= (iter->startbit + NETLBL_CATMAP_SIZE)) {
124 iter = iter->next;
125 if (iter == NULL)
126 return -ENOENT;
127 }
128 node_idx = (offset - iter->startbit) / NETLBL_CATMAP_MAPSIZE;
129 node_bit = offset - iter->startbit -
130 (NETLBL_CATMAP_MAPSIZE * node_idx);
131 } else {
132 node_idx = 0;
133 node_bit = 0;
134 }
135 bitmask = NETLBL_CATMAP_BIT << node_bit;
136
137 for (;;) {
138 bitmap = iter->bitmap[node_idx];
139 while (bitmask != 0 && (bitmap & bitmask) != 0) {
140 bitmask <<= 1;
141 node_bit++;
142 }
143
144 if (bitmask != 0)
145 return iter->startbit +
146 (NETLBL_CATMAP_MAPSIZE * node_idx) +
147 node_bit - 1;
148 else if (++node_idx >= NETLBL_CATMAP_MAPCNT) {
149 if (iter->next == NULL)
150 return iter->startbit + NETLBL_CATMAP_SIZE - 1;
151 iter = iter->next;
152 node_idx = 0;
153 }
154 bitmask = NETLBL_CATMAP_BIT;
155 node_bit = 0;
156 }
157
158 return -ENOENT;
159}
160
161/**
162 * netlbl_secattr_catmap_setbit - Set a bit in a LSM secattr catmap
163 * @catmap: the category bitmap
164 * @bit: the bit to set
165 * @flags: memory allocation flags
166 *
167 * Description:
168 * Set the bit specified by @bit in @catmap. Returns zero on success,
169 * negative values on failure.
170 *
171 */
172int netlbl_secattr_catmap_setbit(struct netlbl_lsm_secattr_catmap *catmap,
173 u32 bit,
174 gfp_t flags)
175{
176 struct netlbl_lsm_secattr_catmap *iter = catmap;
177 u32 node_bit;
178 u32 node_idx;
179
180 while (iter->next != NULL &&
181 bit >= (iter->startbit + NETLBL_CATMAP_SIZE))
182 iter = iter->next;
183 if (bit >= (iter->startbit + NETLBL_CATMAP_SIZE)) {
184 iter->next = netlbl_secattr_catmap_alloc(flags);
185 if (iter->next == NULL)
186 return -ENOMEM;
187 iter = iter->next;
188 iter->startbit = bit & ~(NETLBL_CATMAP_SIZE - 1);
189 }
190
191 /* gcc always rounds to zero when doing integer division */
192 node_idx = (bit - iter->startbit) / NETLBL_CATMAP_MAPSIZE;
193 node_bit = bit - iter->startbit - (NETLBL_CATMAP_MAPSIZE * node_idx);
194 iter->bitmap[node_idx] |= NETLBL_CATMAP_BIT << node_bit;
195
196 return 0;
197}
198
199/**
200 * netlbl_secattr_catmap_setrng - Set a range of bits in a LSM secattr catmap
201 * @catmap: the category bitmap
202 * @start: the starting bit
203 * @end: the last bit in the string
204 * @flags: memory allocation flags
205 *
206 * Description:
207 * Set a range of bits, starting at @start and ending with @end. Returns zero
208 * on success, negative values on failure.
209 *
210 */
211int netlbl_secattr_catmap_setrng(struct netlbl_lsm_secattr_catmap *catmap,
212 u32 start,
213 u32 end,
214 gfp_t flags)
215{
216 int ret_val = 0;
217 struct netlbl_lsm_secattr_catmap *iter = catmap;
218 u32 iter_max_spot;
219 u32 spot;
220
221 /* XXX - This could probably be made a bit faster by combining writes
222 * to the catmap instead of setting a single bit each time, but for
223 * right now skipping to the start of the range in the catmap should
224 * be a nice improvement over calling the individual setbit function
225 * repeatedly from a loop. */
226
227 while (iter->next != NULL &&
228 start >= (iter->startbit + NETLBL_CATMAP_SIZE))
229 iter = iter->next;
230 iter_max_spot = iter->startbit + NETLBL_CATMAP_SIZE;
231
232 for (spot = start; spot <= end && ret_val == 0; spot++) {
233 if (spot >= iter_max_spot && iter->next != NULL) {
234 iter = iter->next;
235 iter_max_spot = iter->startbit + NETLBL_CATMAP_SIZE;
236 }
237 ret_val = netlbl_secattr_catmap_setbit(iter, spot, GFP_ATOMIC);
238 }
239
240 return ret_val;
241}
242
243/*
43 * LSM Functions 244 * LSM Functions
44 */ 245 */
45 246
@@ -62,6 +263,9 @@ int netlbl_socket_setattr(const struct socket *sock,
62 int ret_val = -ENOENT; 263 int ret_val = -ENOENT;
63 struct netlbl_dom_map *dom_entry; 264 struct netlbl_dom_map *dom_entry;
64 265
266 if ((secattr->flags & NETLBL_SECATTR_DOMAIN) == 0)
267 return -ENOENT;
268
65 rcu_read_lock(); 269 rcu_read_lock();
66 dom_entry = netlbl_domhsh_getentry(secattr->domain); 270 dom_entry = netlbl_domhsh_getentry(secattr->domain);
67 if (dom_entry == NULL) 271 if (dom_entry == NULL)
@@ -146,10 +350,8 @@ int netlbl_socket_getattr(const struct socket *sock,
146int netlbl_skbuff_getattr(const struct sk_buff *skb, 350int netlbl_skbuff_getattr(const struct sk_buff *skb,
147 struct netlbl_lsm_secattr *secattr) 351 struct netlbl_lsm_secattr *secattr)
148{ 352{
149 int ret_val; 353 if (CIPSO_V4_OPTEXIST(skb) &&
150 354 cipso_v4_skbuff_getattr(skb, secattr) == 0)
151 ret_val = cipso_v4_skbuff_getattr(skb, secattr);
152 if (ret_val == 0)
153 return 0; 355 return 0;
154 356
155 return netlbl_unlabel_getattr(secattr); 357 return netlbl_unlabel_getattr(secattr);
@@ -200,7 +402,7 @@ void netlbl_cache_invalidate(void)
200int netlbl_cache_add(const struct sk_buff *skb, 402int netlbl_cache_add(const struct sk_buff *skb,
201 const struct netlbl_lsm_secattr *secattr) 403 const struct netlbl_lsm_secattr *secattr)
202{ 404{
203 if (secattr->cache == NULL) 405 if ((secattr->flags & NETLBL_SECATTR_CACHE) == 0)
204 return -ENOMSG; 406 return -ENOMSG;
205 407
206 if (CIPSO_V4_OPTEXIST(skb)) 408 if (CIPSO_V4_OPTEXIST(skb))
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 53c9079ad2c3..e8c80f33f3d7 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -188,12 +188,9 @@ static int netlbl_mgmt_listall_cb(struct netlbl_dom_map *entry, void *arg)
188 struct netlbl_domhsh_walk_arg *cb_arg = arg; 188 struct netlbl_domhsh_walk_arg *cb_arg = arg;
189 void *data; 189 void *data;
190 190
191 data = netlbl_netlink_hdr_put(cb_arg->skb, 191 data = genlmsg_put(cb_arg->skb, NETLINK_CB(cb_arg->nl_cb->skb).pid,
192 NETLINK_CB(cb_arg->nl_cb->skb).pid, 192 cb_arg->seq, &netlbl_mgmt_gnl_family,
193 cb_arg->seq, 193 NLM_F_MULTI, NLBL_MGMT_C_LISTALL);
194 netlbl_mgmt_gnl_family.id,
195 NLM_F_MULTI,
196 NLBL_MGMT_C_LISTALL);
197 if (data == NULL) 194 if (data == NULL)
198 goto listall_cb_failure; 195 goto listall_cb_failure;
199 196
@@ -356,15 +353,11 @@ static int netlbl_mgmt_listdef(struct sk_buff *skb, struct genl_info *info)
356 void *data; 353 void *data;
357 struct netlbl_dom_map *entry; 354 struct netlbl_dom_map *entry;
358 355
359 ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 356 ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
360 if (ans_skb == NULL) 357 if (ans_skb == NULL)
361 return -ENOMEM; 358 return -ENOMEM;
362 data = netlbl_netlink_hdr_put(ans_skb, 359 data = genlmsg_put_reply(ans_skb, info, &netlbl_mgmt_gnl_family,
363 info->snd_pid, 360 0, NLBL_MGMT_C_LISTDEF);
364 info->snd_seq,
365 netlbl_mgmt_gnl_family.id,
366 0,
367 NLBL_MGMT_C_LISTDEF);
368 if (data == NULL) 361 if (data == NULL)
369 goto listdef_failure; 362 goto listdef_failure;
370 363
@@ -390,7 +383,7 @@ static int netlbl_mgmt_listdef(struct sk_buff *skb, struct genl_info *info)
390 383
391 genlmsg_end(ans_skb, data); 384 genlmsg_end(ans_skb, data);
392 385
393 ret_val = genlmsg_unicast(ans_skb, info->snd_pid); 386 ret_val = genlmsg_reply(ans_skb, info);
394 if (ret_val != 0) 387 if (ret_val != 0)
395 goto listdef_failure; 388 goto listdef_failure;
396 return 0; 389 return 0;
@@ -422,12 +415,9 @@ static int netlbl_mgmt_protocols_cb(struct sk_buff *skb,
422 int ret_val = -ENOMEM; 415 int ret_val = -ENOMEM;
423 void *data; 416 void *data;
424 417
425 data = netlbl_netlink_hdr_put(skb, 418 data = genlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
426 NETLINK_CB(cb->skb).pid, 419 &netlbl_mgmt_gnl_family, NLM_F_MULTI,
427 cb->nlh->nlmsg_seq, 420 NLBL_MGMT_C_PROTOCOLS);
428 netlbl_mgmt_gnl_family.id,
429 NLM_F_MULTI,
430 NLBL_MGMT_C_PROTOCOLS);
431 if (data == NULL) 421 if (data == NULL)
432 goto protocols_cb_failure; 422 goto protocols_cb_failure;
433 423
@@ -492,15 +482,11 @@ static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info)
492 struct sk_buff *ans_skb = NULL; 482 struct sk_buff *ans_skb = NULL;
493 void *data; 483 void *data;
494 484
495 ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 485 ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
496 if (ans_skb == NULL) 486 if (ans_skb == NULL)
497 return -ENOMEM; 487 return -ENOMEM;
498 data = netlbl_netlink_hdr_put(ans_skb, 488 data = genlmsg_put_reply(ans_skb, info, &netlbl_mgmt_gnl_family,
499 info->snd_pid, 489 0, NLBL_MGMT_C_VERSION);
500 info->snd_seq,
501 netlbl_mgmt_gnl_family.id,
502 0,
503 NLBL_MGMT_C_VERSION);
504 if (data == NULL) 490 if (data == NULL)
505 goto version_failure; 491 goto version_failure;
506 492
@@ -512,7 +498,7 @@ static int netlbl_mgmt_version(struct sk_buff *skb, struct genl_info *info)
512 498
513 genlmsg_end(ans_skb, data); 499 genlmsg_end(ans_skb, data);
514 500
515 ret_val = genlmsg_unicast(ans_skb, info->snd_pid); 501 ret_val = genlmsg_reply(ans_skb, info);
516 if (ret_val != 0) 502 if (ret_val != 0)
517 goto version_failure; 503 goto version_failure;
518 return 0; 504 return 0;
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 1833ad233b39..5bc37181662e 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -35,6 +35,7 @@
35#include <linux/socket.h> 35#include <linux/socket.h>
36#include <linux/string.h> 36#include <linux/string.h>
37#include <linux/skbuff.h> 37#include <linux/skbuff.h>
38#include <linux/audit.h>
38#include <net/sock.h> 39#include <net/sock.h>
39#include <net/netlink.h> 40#include <net/netlink.h>
40#include <net/genetlink.h> 41#include <net/genetlink.h>
@@ -47,7 +48,8 @@
47#include "netlabel_unlabeled.h" 48#include "netlabel_unlabeled.h"
48 49
49/* Accept unlabeled packets flag */ 50/* Accept unlabeled packets flag */
50static atomic_t netlabel_unlabel_accept_flg = ATOMIC_INIT(0); 51static DEFINE_SPINLOCK(netlabel_unlabel_acceptflg_lock);
52static u8 netlabel_unlabel_acceptflg = 0;
51 53
52/* NetLabel Generic NETLINK CIPSOv4 family */ 54/* NetLabel Generic NETLINK CIPSOv4 family */
53static struct genl_family netlbl_unlabel_gnl_family = { 55static struct genl_family netlbl_unlabel_gnl_family = {
@@ -82,13 +84,20 @@ static void netlbl_unlabel_acceptflg_set(u8 value,
82 struct audit_buffer *audit_buf; 84 struct audit_buffer *audit_buf;
83 u8 old_val; 85 u8 old_val;
84 86
85 old_val = atomic_read(&netlabel_unlabel_accept_flg); 87 rcu_read_lock();
86 atomic_set(&netlabel_unlabel_accept_flg, value); 88 old_val = netlabel_unlabel_acceptflg;
89 spin_lock(&netlabel_unlabel_acceptflg_lock);
90 netlabel_unlabel_acceptflg = value;
91 spin_unlock(&netlabel_unlabel_acceptflg_lock);
92 rcu_read_unlock();
87 93
88 audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_ALLOW, 94 audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_ALLOW,
89 audit_info); 95 audit_info);
90 audit_log_format(audit_buf, " unlbl_accept=%u old=%u", value, old_val); 96 if (audit_buf != NULL) {
91 audit_log_end(audit_buf); 97 audit_log_format(audit_buf,
98 " unlbl_accept=%u old=%u", value, old_val);
99 audit_log_end(audit_buf);
100 }
92} 101}
93 102
94/* 103/*
@@ -138,29 +147,27 @@ static int netlbl_unlabel_list(struct sk_buff *skb, struct genl_info *info)
138 struct sk_buff *ans_skb; 147 struct sk_buff *ans_skb;
139 void *data; 148 void *data;
140 149
141 ans_skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 150 ans_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
142 if (ans_skb == NULL) 151 if (ans_skb == NULL)
143 goto list_failure; 152 goto list_failure;
144 data = netlbl_netlink_hdr_put(ans_skb, 153 data = genlmsg_put_reply(ans_skb, info, &netlbl_unlabel_gnl_family,
145 info->snd_pid, 154 0, NLBL_UNLABEL_C_LIST);
146 info->snd_seq,
147 netlbl_unlabel_gnl_family.id,
148 0,
149 NLBL_UNLABEL_C_LIST);
150 if (data == NULL) { 155 if (data == NULL) {
151 ret_val = -ENOMEM; 156 ret_val = -ENOMEM;
152 goto list_failure; 157 goto list_failure;
153 } 158 }
154 159
160 rcu_read_lock();
155 ret_val = nla_put_u8(ans_skb, 161 ret_val = nla_put_u8(ans_skb,
156 NLBL_UNLABEL_A_ACPTFLG, 162 NLBL_UNLABEL_A_ACPTFLG,
157 atomic_read(&netlabel_unlabel_accept_flg)); 163 netlabel_unlabel_acceptflg);
164 rcu_read_unlock();
158 if (ret_val != 0) 165 if (ret_val != 0)
159 goto list_failure; 166 goto list_failure;
160 167
161 genlmsg_end(ans_skb, data); 168 genlmsg_end(ans_skb, data);
162 169
163 ret_val = genlmsg_unicast(ans_skb, info->snd_pid); 170 ret_val = genlmsg_reply(ans_skb, info);
164 if (ret_val != 0) 171 if (ret_val != 0)
165 goto list_failure; 172 goto list_failure;
166 return 0; 173 return 0;
@@ -240,10 +247,17 @@ int netlbl_unlabel_genl_init(void)
240 */ 247 */
241int netlbl_unlabel_getattr(struct netlbl_lsm_secattr *secattr) 248int netlbl_unlabel_getattr(struct netlbl_lsm_secattr *secattr)
242{ 249{
243 if (atomic_read(&netlabel_unlabel_accept_flg) == 1) 250 int ret_val;
244 return netlbl_secattr_init(secattr);
245 251
246 return -ENOMSG; 252 rcu_read_lock();
253 if (netlabel_unlabel_acceptflg == 1) {
254 netlbl_secattr_init(secattr);
255 ret_val = 0;
256 } else
257 ret_val = -ENOMSG;
258 rcu_read_unlock();
259
260 return ret_val;
247} 261}
248 262
249/** 263/**
diff --git a/net/netlabel/netlabel_user.c b/net/netlabel/netlabel_user.c
index 98a416381e61..42f12bd65964 100644
--- a/net/netlabel/netlabel_user.c
+++ b/net/netlabel/netlabel_user.c
@@ -46,6 +46,10 @@
46#include "netlabel_cipso_v4.h" 46#include "netlabel_cipso_v4.h"
47#include "netlabel_user.h" 47#include "netlabel_user.h"
48 48
49/* do not do any auditing if audit_enabled == 0, see kernel/audit.c for
50 * details */
51extern int audit_enabled;
52
49/* 53/*
50 * NetLabel NETLINK Setup Functions 54 * NetLabel NETLINK Setup Functions
51 */ 55 */
@@ -101,6 +105,9 @@ struct audit_buffer *netlbl_audit_start_common(int type,
101 char *secctx; 105 char *secctx;
102 u32 secctx_len; 106 u32 secctx_len;
103 107
108 if (audit_enabled == 0)
109 return NULL;
110
104 audit_buf = audit_log_start(audit_ctx, GFP_ATOMIC, type); 111 audit_buf = audit_log_start(audit_ctx, GFP_ATOMIC, type);
105 if (audit_buf == NULL) 112 if (audit_buf == NULL)
106 return NULL; 113 return NULL;
diff --git a/net/netlabel/netlabel_user.h b/net/netlabel/netlabel_user.h
index 47967ef32964..6d7f4ab46c2b 100644
--- a/net/netlabel/netlabel_user.h
+++ b/net/netlabel/netlabel_user.h
@@ -42,37 +42,6 @@
42/* NetLabel NETLINK helper functions */ 42/* NetLabel NETLINK helper functions */
43 43
44/** 44/**
45 * netlbl_netlink_hdr_put - Write the NETLINK buffers into a sk_buff
46 * @skb: the packet
47 * @pid: the PID of the receipient
48 * @seq: the sequence number
49 * @type: the generic NETLINK message family type
50 * @cmd: command
51 *
52 * Description:
53 * Write both a NETLINK nlmsghdr structure and a Generic NETLINK genlmsghdr
54 * struct to the packet. Returns a pointer to the start of the payload buffer
55 * on success or NULL on failure.
56 *
57 */
58static inline void *netlbl_netlink_hdr_put(struct sk_buff *skb,
59 u32 pid,
60 u32 seq,
61 int type,
62 int flags,
63 u8 cmd)
64{
65 return genlmsg_put(skb,
66 pid,
67 seq,
68 type,
69 0,
70 flags,
71 cmd,
72 NETLBL_PROTO_VERSION);
73}
74
75/**
76 * netlbl_netlink_auditinfo - Fetch the audit information from a NETLINK msg 45 * netlbl_netlink_auditinfo - Fetch the audit information from a NETLINK msg
77 * @skb: the packet 46 * @skb: the packet
78 * @audit_info: NetLabel audit information 47 * @audit_info: NetLabel audit information
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index d527c8977b1f..3baafb10f8f3 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1148,12 +1148,11 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
1148 if (len > sk->sk_sndbuf - 32) 1148 if (len > sk->sk_sndbuf - 32)
1149 goto out; 1149 goto out;
1150 err = -ENOBUFS; 1150 err = -ENOBUFS;
1151 skb = nlmsg_new(len, GFP_KERNEL); 1151 skb = alloc_skb(len, GFP_KERNEL);
1152 if (skb==NULL) 1152 if (skb==NULL)
1153 goto out; 1153 goto out;
1154 1154
1155 NETLINK_CB(skb).pid = nlk->pid; 1155 NETLINK_CB(skb).pid = nlk->pid;
1156 NETLINK_CB(skb).dst_pid = dst_pid;
1157 NETLINK_CB(skb).dst_group = dst_group; 1156 NETLINK_CB(skb).dst_group = dst_group;
1158 NETLINK_CB(skb).loginuid = audit_get_loginuid(current->audit_context); 1157 NETLINK_CB(skb).loginuid = audit_get_loginuid(current->audit_context);
1159 selinux_get_task_sid(current, &(NETLINK_CB(skb).sid)); 1158 selinux_get_task_sid(current, &(NETLINK_CB(skb).sid));
@@ -1435,14 +1434,13 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
1435 struct sk_buff *skb; 1434 struct sk_buff *skb;
1436 struct nlmsghdr *rep; 1435 struct nlmsghdr *rep;
1437 struct nlmsgerr *errmsg; 1436 struct nlmsgerr *errmsg;
1438 int size; 1437 size_t payload = sizeof(*errmsg);
1439 1438
1440 if (err == 0) 1439 /* error messages get the original request appened */
1441 size = nlmsg_total_size(sizeof(*errmsg)); 1440 if (err)
1442 else 1441 payload += nlmsg_len(nlh);
1443 size = nlmsg_total_size(sizeof(*errmsg) + nlmsg_len(nlh));
1444 1442
1445 skb = nlmsg_new(size, GFP_KERNEL); 1443 skb = nlmsg_new(payload, GFP_KERNEL);
1446 if (!skb) { 1444 if (!skb) {
1447 struct sock *sk; 1445 struct sock *sk;
1448 1446
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 49bc2db7982b..b9b03747c1f3 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -331,7 +331,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
331 } 331 }
332 332
333 *errp = err = netlink_dump_start(genl_sock, skb, nlh, 333 *errp = err = netlink_dump_start(genl_sock, skb, nlh,
334 ops->dumpit, NULL); 334 ops->dumpit, ops->done);
335 if (err == 0) 335 if (err == 0)
336 skb_pull(skb, min(NLMSG_ALIGN(nlh->nlmsg_len), 336 skb_pull(skb, min(NLMSG_ALIGN(nlh->nlmsg_len),
337 skb->len)); 337 skb->len));
@@ -384,16 +384,19 @@ static void genl_rcv(struct sock *sk, int len)
384 * Controller 384 * Controller
385 **************************************************************************/ 385 **************************************************************************/
386 386
387static struct genl_family genl_ctrl = {
388 .id = GENL_ID_CTRL,
389 .name = "nlctrl",
390 .version = 0x1,
391 .maxattr = CTRL_ATTR_MAX,
392};
393
387static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq, 394static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
388 u32 flags, struct sk_buff *skb, u8 cmd) 395 u32 flags, struct sk_buff *skb, u8 cmd)
389{ 396{
390 struct nlattr *nla_ops;
391 struct genl_ops *ops;
392 void *hdr; 397 void *hdr;
393 int idx = 1;
394 398
395 hdr = genlmsg_put(skb, pid, seq, GENL_ID_CTRL, 0, flags, cmd, 399 hdr = genlmsg_put(skb, pid, seq, &genl_ctrl, flags, cmd);
396 family->version);
397 if (hdr == NULL) 400 if (hdr == NULL)
398 return -1; 401 return -1;
399 402
@@ -403,33 +406,39 @@ static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
403 NLA_PUT_U32(skb, CTRL_ATTR_HDRSIZE, family->hdrsize); 406 NLA_PUT_U32(skb, CTRL_ATTR_HDRSIZE, family->hdrsize);
404 NLA_PUT_U32(skb, CTRL_ATTR_MAXATTR, family->maxattr); 407 NLA_PUT_U32(skb, CTRL_ATTR_MAXATTR, family->maxattr);
405 408
406 nla_ops = nla_nest_start(skb, CTRL_ATTR_OPS); 409 if (!list_empty(&family->ops_list)) {
407 if (nla_ops == NULL) 410 struct nlattr *nla_ops;
408 goto nla_put_failure; 411 struct genl_ops *ops;
409 412 int idx = 1;
410 list_for_each_entry(ops, &family->ops_list, ops_list) {
411 struct nlattr *nest;
412 413
413 nest = nla_nest_start(skb, idx++); 414 nla_ops = nla_nest_start(skb, CTRL_ATTR_OPS);
414 if (nest == NULL) 415 if (nla_ops == NULL)
415 goto nla_put_failure; 416 goto nla_put_failure;
416 417
417 NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd); 418 list_for_each_entry(ops, &family->ops_list, ops_list) {
418 NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags); 419 struct nlattr *nest;
419 420
420 if (ops->policy) 421 nest = nla_nest_start(skb, idx++);
421 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_POLICY); 422 if (nest == NULL)
423 goto nla_put_failure;
422 424
423 if (ops->doit) 425 NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd);
424 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DOIT); 426 NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags);
425 427
426 if (ops->dumpit) 428 if (ops->policy)
427 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DUMPIT); 429 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_POLICY);
428 430
429 nla_nest_end(skb, nest); 431 if (ops->doit)
430 } 432 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DOIT);
431 433
432 nla_nest_end(skb, nla_ops); 434 if (ops->dumpit)
435 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DUMPIT);
436
437 nla_nest_end(skb, nest);
438 }
439
440 nla_nest_end(skb, nla_ops);
441 }
433 442
434 return genlmsg_end(skb, hdr); 443 return genlmsg_end(skb, hdr);
435 444
@@ -480,7 +489,7 @@ static struct sk_buff *ctrl_build_msg(struct genl_family *family, u32 pid,
480 struct sk_buff *skb; 489 struct sk_buff *skb;
481 int err; 490 int err;
482 491
483 skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); 492 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
484 if (skb == NULL) 493 if (skb == NULL)
485 return ERR_PTR(-ENOBUFS); 494 return ERR_PTR(-ENOBUFS);
486 495
@@ -529,7 +538,7 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info)
529 goto errout; 538 goto errout;
530 } 539 }
531 540
532 err = genlmsg_unicast(msg, info->snd_pid); 541 err = genlmsg_reply(msg, info);
533errout: 542errout:
534 return err; 543 return err;
535} 544}
@@ -562,13 +571,6 @@ static struct genl_ops genl_ctrl_ops = {
562 .policy = ctrl_policy, 571 .policy = ctrl_policy,
563}; 572};
564 573
565static struct genl_family genl_ctrl = {
566 .id = GENL_ID_CTRL,
567 .name = "nlctrl",
568 .version = 0x1,
569 .maxattr = CTRL_ATTR_MAX,
570};
571
572static int __init genl_init(void) 574static int __init genl_init(void)
573{ 575{
574 int i, err; 576 int i, err;
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
index c11737f472d6..0096105bcd47 100644
--- a/net/netrom/nr_route.c
+++ b/net/netrom/nr_route.c
@@ -155,14 +155,15 @@ static int nr_add_node(ax25_address *nr, const char *mnemonic, ax25_address *ax2
155 atomic_set(&nr_neigh->refcount, 1); 155 atomic_set(&nr_neigh->refcount, 1);
156 156
157 if (ax25_digi != NULL && ax25_digi->ndigi > 0) { 157 if (ax25_digi != NULL && ax25_digi->ndigi > 0) {
158 if ((nr_neigh->digipeat = kmalloc(sizeof(*ax25_digi), GFP_KERNEL)) == NULL) { 158 nr_neigh->digipeat = kmemdup(ax25_digi,
159 sizeof(*ax25_digi),
160 GFP_KERNEL);
161 if (nr_neigh->digipeat == NULL) {
159 kfree(nr_neigh); 162 kfree(nr_neigh);
160 if (nr_node) 163 if (nr_node)
161 nr_node_put(nr_node); 164 nr_node_put(nr_node);
162 return -ENOMEM; 165 return -ENOMEM;
163 } 166 }
164 memcpy(nr_neigh->digipeat, ax25_digi,
165 sizeof(*ax25_digi));
166 } 167 }
167 168
168 spin_lock_bh(&nr_neigh_list_lock); 169 spin_lock_bh(&nr_neigh_list_lock);
@@ -432,11 +433,12 @@ static int nr_add_neigh(ax25_address *callsign, ax25_digi *ax25_digi, struct net
432 atomic_set(&nr_neigh->refcount, 1); 433 atomic_set(&nr_neigh->refcount, 1);
433 434
434 if (ax25_digi != NULL && ax25_digi->ndigi > 0) { 435 if (ax25_digi != NULL && ax25_digi->ndigi > 0) {
435 if ((nr_neigh->digipeat = kmalloc(sizeof(*ax25_digi), GFP_KERNEL)) == NULL) { 436 nr_neigh->digipeat = kmemdup(ax25_digi, sizeof(*ax25_digi),
437 GFP_KERNEL);
438 if (nr_neigh->digipeat == NULL) {
436 kfree(nr_neigh); 439 kfree(nr_neigh);
437 return -ENOMEM; 440 return -ENOMEM;
438 } 441 }
439 memcpy(nr_neigh->digipeat, ax25_digi, sizeof(*ax25_digi));
440 } 442 }
441 443
442 spin_lock_bh(&nr_neigh_list_lock); 444 spin_lock_bh(&nr_neigh_list_lock);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index f4ccb90e6739..271d2eed0699 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -201,7 +201,7 @@ struct packet_sock {
201 spinlock_t bind_lock; 201 spinlock_t bind_lock;
202 char running; /* prot_hook is attached*/ 202 char running; /* prot_hook is attached*/
203 int ifindex; /* bound device */ 203 int ifindex; /* bound device */
204 unsigned short num; 204 __be16 num;
205#ifdef CONFIG_PACKET_MULTICAST 205#ifdef CONFIG_PACKET_MULTICAST
206 struct packet_mclist *mclist; 206 struct packet_mclist *mclist;
207#endif 207#endif
@@ -331,7 +331,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
331 struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name; 331 struct sockaddr_pkt *saddr=(struct sockaddr_pkt *)msg->msg_name;
332 struct sk_buff *skb; 332 struct sk_buff *skb;
333 struct net_device *dev; 333 struct net_device *dev;
334 unsigned short proto=0; 334 __be16 proto=0;
335 int err; 335 int err;
336 336
337 /* 337 /*
@@ -704,7 +704,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
704 struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name; 704 struct sockaddr_ll *saddr=(struct sockaddr_ll *)msg->msg_name;
705 struct sk_buff *skb; 705 struct sk_buff *skb;
706 struct net_device *dev; 706 struct net_device *dev;
707 unsigned short proto; 707 __be16 proto;
708 unsigned char *addr; 708 unsigned char *addr;
709 int ifindex, err, reserve = 0; 709 int ifindex, err, reserve = 0;
710 710
@@ -858,7 +858,7 @@ static int packet_release(struct socket *sock)
858 * Attach a packet hook. 858 * Attach a packet hook.
859 */ 859 */
860 860
861static int packet_do_bind(struct sock *sk, struct net_device *dev, int protocol) 861static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protocol)
862{ 862{
863 struct packet_sock *po = pkt_sk(sk); 863 struct packet_sock *po = pkt_sk(sk);
864 /* 864 /*
@@ -983,6 +983,7 @@ static int packet_create(struct socket *sock, int protocol)
983{ 983{
984 struct sock *sk; 984 struct sock *sk;
985 struct packet_sock *po; 985 struct packet_sock *po;
986 __be16 proto = (__force __be16)protocol; /* weird, but documented */
986 int err; 987 int err;
987 988
988 if (!capable(CAP_NET_RAW)) 989 if (!capable(CAP_NET_RAW))
@@ -1010,7 +1011,7 @@ static int packet_create(struct socket *sock, int protocol)
1010 1011
1011 po = pkt_sk(sk); 1012 po = pkt_sk(sk);
1012 sk->sk_family = PF_PACKET; 1013 sk->sk_family = PF_PACKET;
1013 po->num = protocol; 1014 po->num = proto;
1014 1015
1015 sk->sk_destruct = packet_sock_destruct; 1016 sk->sk_destruct = packet_sock_destruct;
1016 atomic_inc(&packet_socks_nr); 1017 atomic_inc(&packet_socks_nr);
@@ -1027,8 +1028,8 @@ static int packet_create(struct socket *sock, int protocol)
1027#endif 1028#endif
1028 po->prot_hook.af_packet_priv = sk; 1029 po->prot_hook.af_packet_priv = sk;
1029 1030
1030 if (protocol) { 1031 if (proto) {
1031 po->prot_hook.type = protocol; 1032 po->prot_hook.type = proto;
1032 dev_add_pack(&po->prot_hook); 1033 dev_add_pack(&po->prot_hook);
1033 sock_hold(sk); 1034 sock_hold(sk);
1034 po->running = 1; 1035 po->running = 1;
@@ -1624,7 +1625,8 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, int closing
1624{ 1625{
1625 char **pg_vec = NULL; 1626 char **pg_vec = NULL;
1626 struct packet_sock *po = pkt_sk(sk); 1627 struct packet_sock *po = pkt_sk(sk);
1627 int was_running, num, order = 0; 1628 int was_running, order = 0;
1629 __be16 num;
1628 int err = 0; 1630 int err = 0;
1629 1631
1630 if (req->tp_block_nr) { 1632 if (req->tp_block_nr) {
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index a22542fa1bc8..7252344779a0 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -396,7 +396,7 @@ int rose_add_loopback_neigh(void)
396int rose_add_loopback_node(rose_address *address) 396int rose_add_loopback_node(rose_address *address)
397{ 397{
398 struct rose_node *rose_node; 398 struct rose_node *rose_node;
399 unsigned int err = 0; 399 int err = 0;
400 400
401 spin_lock_bh(&rose_node_list_lock); 401 spin_lock_bh(&rose_node_list_lock);
402 402
@@ -432,7 +432,7 @@ int rose_add_loopback_node(rose_address *address)
432out: 432out:
433 spin_unlock_bh(&rose_node_list_lock); 433 spin_unlock_bh(&rose_node_list_lock);
434 434
435 return 0; 435 return err;
436} 436}
437 437
438/* 438/*
diff --git a/net/rxrpc/transport.c b/net/rxrpc/transport.c
index 94b2e2fe6fdb..4268b38d92d2 100644
--- a/net/rxrpc/transport.c
+++ b/net/rxrpc/transport.c
@@ -31,7 +31,6 @@
31#endif 31#endif
32#include <linux/errqueue.h> 32#include <linux/errqueue.h>
33#include <asm/uaccess.h> 33#include <asm/uaccess.h>
34#include <asm/checksum.h>
35#include "internal.h" 34#include "internal.h"
36 35
37struct errormsg { 36struct errormsg {
diff --git a/net/sched/Kconfig b/net/sched/Kconfig
index 8298ea9ffe19..f4544dd86476 100644
--- a/net/sched/Kconfig
+++ b/net/sched/Kconfig
@@ -6,6 +6,7 @@ menu "QoS and/or fair queueing"
6 6
7config NET_SCHED 7config NET_SCHED
8 bool "QoS and/or fair queueing" 8 bool "QoS and/or fair queueing"
9 select NET_SCH_FIFO
9 ---help--- 10 ---help---
10 When the kernel has several packets to send out over a network 11 When the kernel has several packets to send out over a network
11 device, it has to decide which ones to send first, which ones to 12 device, it has to decide which ones to send first, which ones to
@@ -40,6 +41,9 @@ config NET_SCHED
40 The available schedulers are listed in the following questions; you 41 The available schedulers are listed in the following questions; you
41 can say Y to as many as you like. If unsure, say N now. 42 can say Y to as many as you like. If unsure, say N now.
42 43
44config NET_SCH_FIFO
45 bool
46
43if NET_SCHED 47if NET_SCHED
44 48
45choice 49choice
@@ -320,7 +324,7 @@ config CLS_U32_PERF
320 324
321config CLS_U32_MARK 325config CLS_U32_MARK
322 bool "Netfilter marks support" 326 bool "Netfilter marks support"
323 depends on NET_CLS_U32 && NETFILTER 327 depends on NET_CLS_U32
324 ---help--- 328 ---help---
325 Say Y here to be able to use netfilter marks as u32 key. 329 Say Y here to be able to use netfilter marks as u32 key.
326 330
diff --git a/net/sched/Makefile b/net/sched/Makefile
index 0f06aec66094..ff2d6e5e282c 100644
--- a/net/sched/Makefile
+++ b/net/sched/Makefile
@@ -4,7 +4,7 @@
4 4
5obj-y := sch_generic.o 5obj-y := sch_generic.o
6 6
7obj-$(CONFIG_NET_SCHED) += sch_api.o sch_fifo.o sch_blackhole.o 7obj-$(CONFIG_NET_SCHED) += sch_api.o sch_blackhole.o
8obj-$(CONFIG_NET_CLS) += cls_api.o 8obj-$(CONFIG_NET_CLS) += cls_api.o
9obj-$(CONFIG_NET_CLS_ACT) += act_api.o 9obj-$(CONFIG_NET_CLS_ACT) += act_api.o
10obj-$(CONFIG_NET_ACT_POLICE) += act_police.o 10obj-$(CONFIG_NET_ACT_POLICE) += act_police.o
@@ -14,6 +14,7 @@ obj-$(CONFIG_NET_ACT_MIRRED) += act_mirred.o
14obj-$(CONFIG_NET_ACT_IPT) += act_ipt.o 14obj-$(CONFIG_NET_ACT_IPT) += act_ipt.o
15obj-$(CONFIG_NET_ACT_PEDIT) += act_pedit.o 15obj-$(CONFIG_NET_ACT_PEDIT) += act_pedit.o
16obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o 16obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o
17obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o
17obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o 18obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
18obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o 19obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
19obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o 20obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
index 6cff56696a81..85de7efd5fea 100644
--- a/net/sched/act_gact.c
+++ b/net/sched/act_gact.c
@@ -48,14 +48,14 @@ static struct tcf_hashinfo gact_hash_info = {
48#ifdef CONFIG_GACT_PROB 48#ifdef CONFIG_GACT_PROB
49static int gact_net_rand(struct tcf_gact *gact) 49static int gact_net_rand(struct tcf_gact *gact)
50{ 50{
51 if (net_random() % gact->tcfg_pval) 51 if (!gact->tcfg_pval || net_random() % gact->tcfg_pval)
52 return gact->tcf_action; 52 return gact->tcf_action;
53 return gact->tcfg_paction; 53 return gact->tcfg_paction;
54} 54}
55 55
56static int gact_determ(struct tcf_gact *gact) 56static int gact_determ(struct tcf_gact *gact)
57{ 57{
58 if (gact->tcf_bstats.packets % gact->tcfg_pval) 58 if (!gact->tcfg_pval || gact->tcf_bstats.packets % gact->tcfg_pval)
59 return gact->tcf_action; 59 return gact->tcf_action;
60 return gact->tcfg_paction; 60 return gact->tcfg_paction;
61} 61}
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index d8c9310da6e5..a9608064a4c3 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -156,10 +156,9 @@ static int tcf_ipt_init(struct rtattr *rta, struct rtattr *est,
156 rtattr_strlcpy(tname, tb[TCA_IPT_TABLE-1], IFNAMSIZ) >= IFNAMSIZ) 156 rtattr_strlcpy(tname, tb[TCA_IPT_TABLE-1], IFNAMSIZ) >= IFNAMSIZ)
157 strcpy(tname, "mangle"); 157 strcpy(tname, "mangle");
158 158
159 t = kmalloc(td->u.target_size, GFP_KERNEL); 159 t = kmemdup(td, td->u.target_size, GFP_KERNEL);
160 if (unlikely(!t)) 160 if (unlikely(!t))
161 goto err2; 161 goto err2;
162 memcpy(t, td, td->u.target_size);
163 162
164 if ((err = ipt_init_target(t, tname, hook)) < 0) 163 if ((err = ipt_init_target(t, tname, hook)) < 0)
165 goto err3; 164 goto err3;
@@ -256,13 +255,12 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
256 ** for foolproof you need to not assume this 255 ** for foolproof you need to not assume this
257 */ 256 */
258 257
259 t = kmalloc(ipt->tcfi_t->u.user.target_size, GFP_ATOMIC); 258 t = kmemdup(ipt->tcfi_t, ipt->tcfi_t->u.user.target_size, GFP_ATOMIC);
260 if (unlikely(!t)) 259 if (unlikely(!t))
261 goto rtattr_failure; 260 goto rtattr_failure;
262 261
263 c.bindcnt = ipt->tcf_bindcnt - bind; 262 c.bindcnt = ipt->tcf_bindcnt - bind;
264 c.refcnt = ipt->tcf_refcnt - ref; 263 c.refcnt = ipt->tcf_refcnt - ref;
265 memcpy(t, ipt->tcfi_t, ipt->tcfi_t->u.user.target_size);
266 strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name); 264 strcpy(t->u.user.name, ipt->tcfi_t->u.kernel.target->name);
267 265
268 RTA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t); 266 RTA_PUT(skb, TCA_IPT_TARG, ipt->tcfi_t->u.user.target_size, t);
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index fed47b658837..af68e1e83251 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -46,6 +46,18 @@ static struct tcf_hashinfo police_hash_info = {
46 .lock = &police_lock, 46 .lock = &police_lock,
47}; 47};
48 48
49/* old policer structure from before tc actions */
50struct tc_police_compat
51{
52 u32 index;
53 int action;
54 u32 limit;
55 u32 burst;
56 u32 mtu;
57 struct tc_ratespec rate;
58 struct tc_ratespec peakrate;
59};
60
49/* Each policer is serialized by its individual spinlock */ 61/* Each policer is serialized by its individual spinlock */
50 62
51#ifdef CONFIG_NET_CLS_ACT 63#ifdef CONFIG_NET_CLS_ACT
@@ -131,12 +143,15 @@ static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,
131 struct tc_police *parm; 143 struct tc_police *parm;
132 struct tcf_police *police; 144 struct tcf_police *police;
133 struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; 145 struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
146 int size;
134 147
135 if (rta == NULL || rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0) 148 if (rta == NULL || rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0)
136 return -EINVAL; 149 return -EINVAL;
137 150
138 if (tb[TCA_POLICE_TBF-1] == NULL || 151 if (tb[TCA_POLICE_TBF-1] == NULL)
139 RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]) != sizeof(*parm)) 152 return -EINVAL;
153 size = RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]);
154 if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
140 return -EINVAL; 155 return -EINVAL;
141 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]); 156 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]);
142 157
@@ -415,12 +430,15 @@ struct tcf_police *tcf_police_locate(struct rtattr *rta, struct rtattr *est)
415 struct tcf_police *police; 430 struct tcf_police *police;
416 struct rtattr *tb[TCA_POLICE_MAX]; 431 struct rtattr *tb[TCA_POLICE_MAX];
417 struct tc_police *parm; 432 struct tc_police *parm;
433 int size;
418 434
419 if (rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0) 435 if (rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0)
420 return NULL; 436 return NULL;
421 437
422 if (tb[TCA_POLICE_TBF-1] == NULL || 438 if (tb[TCA_POLICE_TBF-1] == NULL)
423 RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]) != sizeof(*parm)) 439 return NULL;
440 size = RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]);
441 if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
424 return NULL; 442 return NULL;
425 443
426 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]); 444 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]);
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index 901571a67707..5fe80854ca91 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -71,11 +71,10 @@ static int tcf_simp_release(struct tcf_defact *d, int bind)
71 71
72static int alloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata) 72static int alloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata)
73{ 73{
74 d->tcfd_defdata = kmalloc(datalen, GFP_KERNEL); 74 d->tcfd_defdata = kmemdup(defdata, datalen, GFP_KERNEL);
75 if (unlikely(!d->tcfd_defdata)) 75 if (unlikely(!d->tcfd_defdata))
76 return -ENOMEM; 76 return -ENOMEM;
77 d->tcfd_datalen = datalen; 77 d->tcfd_datalen = datalen;
78 memcpy(d->tcfd_defdata, defdata, datalen);
79 return 0; 78 return 0;
80} 79}
81 80
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 37a184021647..edb8fc97ae11 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -217,7 +217,7 @@ replay:
217 /* Create new proto tcf */ 217 /* Create new proto tcf */
218 218
219 err = -ENOBUFS; 219 err = -ENOBUFS;
220 if ((tp = kmalloc(sizeof(*tp), GFP_KERNEL)) == NULL) 220 if ((tp = kzalloc(sizeof(*tp), GFP_KERNEL)) == NULL)
221 goto errout; 221 goto errout;
222 err = -EINVAL; 222 err = -EINVAL;
223 tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND-1]); 223 tp_ops = tcf_proto_lookup_ops(tca[TCA_KIND-1]);
@@ -247,7 +247,6 @@ replay:
247 kfree(tp); 247 kfree(tp);
248 goto errout; 248 goto errout;
249 } 249 }
250 memset(tp, 0, sizeof(*tp));
251 tp->ops = tp_ops; 250 tp->ops = tp_ops;
252 tp->protocol = protocol; 251 tp->protocol = protocol;
253 tp->prio = nprio ? : tcf_auto_prio(*back); 252 tp->prio = nprio ? : tcf_auto_prio(*back);
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index e54acc6bcccd..f59a2c4aa039 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -101,11 +101,7 @@ static int fw_classify(struct sk_buff *skb, struct tcf_proto *tp,
101 struct fw_head *head = (struct fw_head*)tp->root; 101 struct fw_head *head = (struct fw_head*)tp->root;
102 struct fw_filter *f; 102 struct fw_filter *f;
103 int r; 103 int r;
104#ifdef CONFIG_NETFILTER 104 u32 id = skb->mark & head->mask;
105 u32 id = skb->nfmark & head->mask;
106#else
107 u32 id = 0;
108#endif
109 105
110 if (head != NULL) { 106 if (head != NULL) {
111 for (f=head->ht[fw_hash(id)]; f; f=f->next) { 107 for (f=head->ht[fw_hash(id)]; f; f=f->next) {
diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h
index 6e230ecfba05..587b9adab38c 100644
--- a/net/sched/cls_rsvp.h
+++ b/net/sched/cls_rsvp.h
@@ -77,7 +77,7 @@ struct rsvp_head
77struct rsvp_session 77struct rsvp_session
78{ 78{
79 struct rsvp_session *next; 79 struct rsvp_session *next;
80 u32 dst[RSVP_DST_LEN]; 80 __be32 dst[RSVP_DST_LEN];
81 struct tc_rsvp_gpi dpi; 81 struct tc_rsvp_gpi dpi;
82 u8 protocol; 82 u8 protocol;
83 u8 tunnelid; 83 u8 tunnelid;
@@ -89,7 +89,7 @@ struct rsvp_session
89struct rsvp_filter 89struct rsvp_filter
90{ 90{
91 struct rsvp_filter *next; 91 struct rsvp_filter *next;
92 u32 src[RSVP_DST_LEN]; 92 __be32 src[RSVP_DST_LEN];
93 struct tc_rsvp_gpi spi; 93 struct tc_rsvp_gpi spi;
94 u8 tunnelhdr; 94 u8 tunnelhdr;
95 95
@@ -100,17 +100,17 @@ struct rsvp_filter
100 struct rsvp_session *sess; 100 struct rsvp_session *sess;
101}; 101};
102 102
103static __inline__ unsigned hash_dst(u32 *dst, u8 protocol, u8 tunnelid) 103static __inline__ unsigned hash_dst(__be32 *dst, u8 protocol, u8 tunnelid)
104{ 104{
105 unsigned h = dst[RSVP_DST_LEN-1]; 105 unsigned h = (__force __u32)dst[RSVP_DST_LEN-1];
106 h ^= h>>16; 106 h ^= h>>16;
107 h ^= h>>8; 107 h ^= h>>8;
108 return (h ^ protocol ^ tunnelid) & 0xFF; 108 return (h ^ protocol ^ tunnelid) & 0xFF;
109} 109}
110 110
111static __inline__ unsigned hash_src(u32 *src) 111static __inline__ unsigned hash_src(__be32 *src)
112{ 112{
113 unsigned h = src[RSVP_DST_LEN-1]; 113 unsigned h = (__force __u32)src[RSVP_DST_LEN-1];
114 h ^= h>>16; 114 h ^= h>>16;
115 h ^= h>>8; 115 h ^= h>>8;
116 h ^= h>>4; 116 h ^= h>>4;
@@ -138,7 +138,7 @@ static int rsvp_classify(struct sk_buff *skb, struct tcf_proto *tp,
138 struct rsvp_session *s; 138 struct rsvp_session *s;
139 struct rsvp_filter *f; 139 struct rsvp_filter *f;
140 unsigned h1, h2; 140 unsigned h1, h2;
141 u32 *dst, *src; 141 __be32 *dst, *src;
142 u8 protocol; 142 u8 protocol;
143 u8 tunnelid = 0; 143 u8 tunnelid = 0;
144 u8 *xprt; 144 u8 *xprt;
@@ -410,7 +410,7 @@ static int rsvp_change(struct tcf_proto *tp, unsigned long base,
410 struct rtattr *tb[TCA_RSVP_MAX]; 410 struct rtattr *tb[TCA_RSVP_MAX];
411 struct tcf_exts e; 411 struct tcf_exts e;
412 unsigned h1, h2; 412 unsigned h1, h2;
413 u32 *dst; 413 __be32 *dst;
414 int err; 414 int err;
415 415
416 if (opt == NULL) 416 if (opt == NULL)
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 0a6cfa0005be..8b5194801995 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -143,7 +143,7 @@ next_knode:
143#endif 143#endif
144 144
145#ifdef CONFIG_CLS_U32_MARK 145#ifdef CONFIG_CLS_U32_MARK
146 if ((skb->nfmark & n->mark.mask) != n->mark.val) { 146 if ((skb->mark & n->mark.mask) != n->mark.val) {
147 n = n->next; 147 n = n->next;
148 goto next_knode; 148 goto next_knode;
149 } else { 149 } else {
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index 61e3b740ab1a..45d47d37155e 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -208,13 +208,9 @@ META_COLLECTOR(int_maclen)
208 * Netfilter 208 * Netfilter
209 **************************************************************************/ 209 **************************************************************************/
210 210
211META_COLLECTOR(int_nfmark) 211META_COLLECTOR(int_mark)
212{ 212{
213#ifdef CONFIG_NETFILTER 213 dst->value = skb->mark;
214 dst->value = skb->nfmark;
215#else
216 dst->value = 0;
217#endif
218} 214}
219 215
220/************************************************************************** 216/**************************************************************************
@@ -490,7 +486,7 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = {
490 [META_ID(PKTLEN)] = META_FUNC(int_pktlen), 486 [META_ID(PKTLEN)] = META_FUNC(int_pktlen),
491 [META_ID(DATALEN)] = META_FUNC(int_datalen), 487 [META_ID(DATALEN)] = META_FUNC(int_datalen),
492 [META_ID(MACLEN)] = META_FUNC(int_maclen), 488 [META_ID(MACLEN)] = META_FUNC(int_maclen),
493 [META_ID(NFMARK)] = META_FUNC(int_nfmark), 489 [META_ID(NFMARK)] = META_FUNC(int_mark),
494 [META_ID(TCINDEX)] = META_FUNC(int_tcindex), 490 [META_ID(TCINDEX)] = META_FUNC(int_tcindex),
495 [META_ID(RTCLASSID)] = META_FUNC(int_rtclassid), 491 [META_ID(RTCLASSID)] = META_FUNC(int_rtclassid),
496 [META_ID(RTIIF)] = META_FUNC(int_rtiif), 492 [META_ID(RTIIF)] = META_FUNC(int_rtiif),
@@ -550,10 +546,9 @@ static int meta_var_change(struct meta_value *dst, struct rtattr *rta)
550{ 546{
551 int len = RTA_PAYLOAD(rta); 547 int len = RTA_PAYLOAD(rta);
552 548
553 dst->val = (unsigned long) kmalloc(len, GFP_KERNEL); 549 dst->val = (unsigned long)kmemdup(RTA_DATA(rta), len, GFP_KERNEL);
554 if (dst->val == 0UL) 550 if (dst->val == 0UL)
555 return -ENOMEM; 551 return -ENOMEM;
556 memcpy((void *) dst->val, RTA_DATA(rta), len);
557 dst->len = len; 552 dst->len = len;
558 return 0; 553 return 0;
559} 554}
diff --git a/net/sched/em_nbyte.c b/net/sched/em_nbyte.c
index cc80babfd79f..005db409be64 100644
--- a/net/sched/em_nbyte.c
+++ b/net/sched/em_nbyte.c
@@ -34,12 +34,10 @@ static int em_nbyte_change(struct tcf_proto *tp, void *data, int data_len,
34 return -EINVAL; 34 return -EINVAL;
35 35
36 em->datalen = sizeof(*nbyte) + nbyte->len; 36 em->datalen = sizeof(*nbyte) + nbyte->len;
37 em->data = (unsigned long) kmalloc(em->datalen, GFP_KERNEL); 37 em->data = (unsigned long)kmemdup(data, em->datalen, GFP_KERNEL);
38 if (em->data == 0UL) 38 if (em->data == 0UL)
39 return -ENOBUFS; 39 return -ENOBUFS;
40 40
41 memcpy((void *) em->data, data, em->datalen);
42
43 return 0; 41 return 0;
44} 42}
45 43
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index 0fd0768a17c6..8f8a16da72a8 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -251,12 +251,11 @@ static int tcf_em_validate(struct tcf_proto *tp,
251 goto errout; 251 goto errout;
252 em->data = *(u32 *) data; 252 em->data = *(u32 *) data;
253 } else { 253 } else {
254 void *v = kmalloc(data_len, GFP_KERNEL); 254 void *v = kmemdup(data, data_len, GFP_KERNEL);
255 if (v == NULL) { 255 if (v == NULL) {
256 err = -ENOBUFS; 256 err = -ENOBUFS;
257 goto errout; 257 goto errout;
258 } 258 }
259 memcpy(v, data, data_len);
260 em->data = (unsigned long) v; 259 em->data = (unsigned long) v;
261 } 260 }
262 } 261 }
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 0b6489291140..65825f4409d9 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -191,21 +191,27 @@ int unregister_qdisc(struct Qdisc_ops *qops)
191 (root qdisc, all its children, children of children etc.) 191 (root qdisc, all its children, children of children etc.)
192 */ 192 */
193 193
194struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle) 194static struct Qdisc *__qdisc_lookup(struct net_device *dev, u32 handle)
195{ 195{
196 struct Qdisc *q; 196 struct Qdisc *q;
197 197
198 read_lock(&qdisc_tree_lock);
199 list_for_each_entry(q, &dev->qdisc_list, list) { 198 list_for_each_entry(q, &dev->qdisc_list, list) {
200 if (q->handle == handle) { 199 if (q->handle == handle)
201 read_unlock(&qdisc_tree_lock);
202 return q; 200 return q;
203 }
204 } 201 }
205 read_unlock(&qdisc_tree_lock);
206 return NULL; 202 return NULL;
207} 203}
208 204
205struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
206{
207 struct Qdisc *q;
208
209 read_lock(&qdisc_tree_lock);
210 q = __qdisc_lookup(dev, handle);
211 read_unlock(&qdisc_tree_lock);
212 return q;
213}
214
209static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid) 215static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid)
210{ 216{
211 unsigned long cl; 217 unsigned long cl;
@@ -348,6 +354,26 @@ dev_graft_qdisc(struct net_device *dev, struct Qdisc *qdisc)
348 return oqdisc; 354 return oqdisc;
349} 355}
350 356
357void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)
358{
359 struct Qdisc_class_ops *cops;
360 unsigned long cl;
361 u32 parentid;
362
363 if (n == 0)
364 return;
365 while ((parentid = sch->parent)) {
366 sch = __qdisc_lookup(sch->dev, TC_H_MAJ(parentid));
367 cops = sch->ops->cl_ops;
368 if (cops->qlen_notify) {
369 cl = cops->get(sch, parentid);
370 cops->qlen_notify(sch, cl);
371 cops->put(sch, cl);
372 }
373 sch->q.qlen -= n;
374 }
375}
376EXPORT_SYMBOL(qdisc_tree_decrease_qlen);
351 377
352/* Graft qdisc "new" to class "classid" of qdisc "parent" or 378/* Graft qdisc "new" to class "classid" of qdisc "parent" or
353 to device "dev". 379 to device "dev".
@@ -1112,7 +1138,7 @@ int tc_classify(struct sk_buff *skb, struct tcf_proto *tp,
1112 struct tcf_result *res) 1138 struct tcf_result *res)
1113{ 1139{
1114 int err = 0; 1140 int err = 0;
1115 u32 protocol = skb->protocol; 1141 __be16 protocol = skb->protocol;
1116#ifdef CONFIG_NET_CLS_ACT 1142#ifdef CONFIG_NET_CLS_ACT
1117 struct tcf_proto *otp = tp; 1143 struct tcf_proto *otp = tp;
1118reclassify: 1144reclassify:
@@ -1277,7 +1303,6 @@ static int __init pktsched_init(void)
1277 1303
1278subsys_initcall(pktsched_init); 1304subsys_initcall(pktsched_init);
1279 1305
1280EXPORT_SYMBOL(qdisc_lookup);
1281EXPORT_SYMBOL(qdisc_get_rtab); 1306EXPORT_SYMBOL(qdisc_get_rtab);
1282EXPORT_SYMBOL(qdisc_put_rtab); 1307EXPORT_SYMBOL(qdisc_put_rtab);
1283EXPORT_SYMBOL(register_qdisc); 1308EXPORT_SYMBOL(register_qdisc);
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index dbf44da0912f..edc7bb0b9c8b 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -316,7 +316,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
316 } 316 }
317 memset(flow,0,sizeof(*flow)); 317 memset(flow,0,sizeof(*flow));
318 flow->filter_list = NULL; 318 flow->filter_list = NULL;
319 if (!(flow->q = qdisc_create_dflt(sch->dev,&pfifo_qdisc_ops))) 319 if (!(flow->q = qdisc_create_dflt(sch->dev,&pfifo_qdisc_ops,classid)))
320 flow->q = &noop_qdisc; 320 flow->q = &noop_qdisc;
321 DPRINTK("atm_tc_change: qdisc %p\n",flow->q); 321 DPRINTK("atm_tc_change: qdisc %p\n",flow->q);
322 flow->sock = sock; 322 flow->sock = sock;
@@ -576,7 +576,8 @@ static int atm_tc_init(struct Qdisc *sch,struct rtattr *opt)
576 576
577 DPRINTK("atm_tc_init(sch %p,[qdisc %p],opt %p)\n",sch,p,opt); 577 DPRINTK("atm_tc_init(sch %p,[qdisc %p],opt %p)\n",sch,p,opt);
578 p->flows = &p->link; 578 p->flows = &p->link;
579 if(!(p->link.q = qdisc_create_dflt(sch->dev,&pfifo_qdisc_ops))) 579 if(!(p->link.q = qdisc_create_dflt(sch->dev,&pfifo_qdisc_ops,
580 sch->handle)))
580 p->link.q = &noop_qdisc; 581 p->link.q = &noop_qdisc;
581 DPRINTK("atm_tc_init: link (%p) qdisc %p\n",&p->link,p->link.q); 582 DPRINTK("atm_tc_init: link (%p) qdisc %p\n",&p->link,p->link.q);
582 p->link.filter_list = NULL; 583 p->link.filter_list = NULL;
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index bac881bfe362..ba82dfab6043 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -1429,7 +1429,8 @@ static int cbq_init(struct Qdisc *sch, struct rtattr *opt)
1429 q->link.sibling = &q->link; 1429 q->link.sibling = &q->link;
1430 q->link.classid = sch->handle; 1430 q->link.classid = sch->handle;
1431 q->link.qdisc = sch; 1431 q->link.qdisc = sch;
1432 if (!(q->link.q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops))) 1432 if (!(q->link.q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
1433 sch->handle)))
1433 q->link.q = &noop_qdisc; 1434 q->link.q = &noop_qdisc;
1434 1435
1435 q->link.priority = TC_CBQ_MAXPRIO-1; 1436 q->link.priority = TC_CBQ_MAXPRIO-1;
@@ -1674,7 +1675,8 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
1674 1675
1675 if (cl) { 1676 if (cl) {
1676 if (new == NULL) { 1677 if (new == NULL) {
1677 if ((new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops)) == NULL) 1678 if ((new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
1679 cl->classid)) == NULL)
1678 return -ENOBUFS; 1680 return -ENOBUFS;
1679 } else { 1681 } else {
1680#ifdef CONFIG_NET_CLS_POLICE 1682#ifdef CONFIG_NET_CLS_POLICE
@@ -1685,7 +1687,7 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
1685 sch_tree_lock(sch); 1687 sch_tree_lock(sch);
1686 *old = cl->q; 1688 *old = cl->q;
1687 cl->q = new; 1689 cl->q = new;
1688 sch->q.qlen -= (*old)->q.qlen; 1690 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
1689 qdisc_reset(*old); 1691 qdisc_reset(*old);
1690 sch_tree_unlock(sch); 1692 sch_tree_unlock(sch);
1691 1693
@@ -1932,7 +1934,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct rtattr **t
1932 cl->R_tab = rtab; 1934 cl->R_tab = rtab;
1933 rtab = NULL; 1935 rtab = NULL;
1934 cl->refcnt = 1; 1936 cl->refcnt = 1;
1935 if (!(cl->q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops))) 1937 if (!(cl->q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops, classid)))
1936 cl->q = &noop_qdisc; 1938 cl->q = &noop_qdisc;
1937 cl->classid = classid; 1939 cl->classid = classid;
1938 cl->tparent = parent; 1940 cl->tparent = parent;
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
index 11c8a2119b96..d5421816f007 100644
--- a/net/sched/sch_dsmark.c
+++ b/net/sched/sch_dsmark.c
@@ -88,15 +88,16 @@ static int dsmark_graft(struct Qdisc *sch, unsigned long arg,
88 sch, p, new, old); 88 sch, p, new, old);
89 89
90 if (new == NULL) { 90 if (new == NULL) {
91 new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); 91 new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
92 sch->handle);
92 if (new == NULL) 93 if (new == NULL)
93 new = &noop_qdisc; 94 new = &noop_qdisc;
94 } 95 }
95 96
96 sch_tree_lock(sch); 97 sch_tree_lock(sch);
97 *old = xchg(&p->q, new); 98 *old = xchg(&p->q, new);
99 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
98 qdisc_reset(*old); 100 qdisc_reset(*old);
99 sch->q.qlen = 0;
100 sch_tree_unlock(sch); 101 sch_tree_unlock(sch);
101 102
102 return 0; 103 return 0;
@@ -307,7 +308,7 @@ static struct sk_buff *dsmark_dequeue(struct Qdisc *sch)
307 if (p->mask[index] != 0xff || p->value[index]) 308 if (p->mask[index] != 0xff || p->value[index])
308 printk(KERN_WARNING "dsmark_dequeue: " 309 printk(KERN_WARNING "dsmark_dequeue: "
309 "unsupported protocol %d\n", 310 "unsupported protocol %d\n",
310 htons(skb->protocol)); 311 ntohs(skb->protocol));
311 break; 312 break;
312 }; 313 };
313 314
@@ -387,7 +388,7 @@ static int dsmark_init(struct Qdisc *sch, struct rtattr *opt)
387 p->default_index = default_index; 388 p->default_index = default_index;
388 p->set_tc_index = RTA_GET_FLAG(tb[TCA_DSMARK_SET_TC_INDEX-1]); 389 p->set_tc_index = RTA_GET_FLAG(tb[TCA_DSMARK_SET_TC_INDEX-1]);
389 390
390 p->q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); 391 p->q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops, sch->handle);
391 if (p->q == NULL) 392 if (p->q == NULL)
392 p->q = &noop_qdisc; 393 p->q = &noop_qdisc;
393 394
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 88c6a99ce53c..bc116bd6937c 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -450,13 +450,15 @@ errout:
450 return ERR_PTR(-err); 450 return ERR_PTR(-err);
451} 451}
452 452
453struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops) 453struct Qdisc * qdisc_create_dflt(struct net_device *dev, struct Qdisc_ops *ops,
454 unsigned int parentid)
454{ 455{
455 struct Qdisc *sch; 456 struct Qdisc *sch;
456 457
457 sch = qdisc_alloc(dev, ops); 458 sch = qdisc_alloc(dev, ops);
458 if (IS_ERR(sch)) 459 if (IS_ERR(sch))
459 goto errout; 460 goto errout;
461 sch->parent = parentid;
460 462
461 if (!ops->init || ops->init(sch, NULL) == 0) 463 if (!ops->init || ops->init(sch, NULL) == 0)
462 return sch; 464 return sch;
@@ -520,7 +522,8 @@ void dev_activate(struct net_device *dev)
520 if (dev->qdisc_sleeping == &noop_qdisc) { 522 if (dev->qdisc_sleeping == &noop_qdisc) {
521 struct Qdisc *qdisc; 523 struct Qdisc *qdisc;
522 if (dev->tx_queue_len) { 524 if (dev->tx_queue_len) {
523 qdisc = qdisc_create_dflt(dev, &pfifo_fast_ops); 525 qdisc = qdisc_create_dflt(dev, &pfifo_fast_ops,
526 TC_H_ROOT);
524 if (qdisc == NULL) { 527 if (qdisc == NULL) {
525 printk(KERN_INFO "%s: activation failed\n", dev->name); 528 printk(KERN_INFO "%s: activation failed\n", dev->name);
526 return; 529 return;
@@ -606,13 +609,10 @@ void dev_shutdown(struct net_device *dev)
606 qdisc_unlock_tree(dev); 609 qdisc_unlock_tree(dev);
607} 610}
608 611
609EXPORT_SYMBOL(__netdev_watchdog_up);
610EXPORT_SYMBOL(netif_carrier_on); 612EXPORT_SYMBOL(netif_carrier_on);
611EXPORT_SYMBOL(netif_carrier_off); 613EXPORT_SYMBOL(netif_carrier_off);
612EXPORT_SYMBOL(noop_qdisc); 614EXPORT_SYMBOL(noop_qdisc);
613EXPORT_SYMBOL(noop_qdisc_ops);
614EXPORT_SYMBOL(qdisc_create_dflt); 615EXPORT_SYMBOL(qdisc_create_dflt);
615EXPORT_SYMBOL(qdisc_alloc);
616EXPORT_SYMBOL(qdisc_destroy); 616EXPORT_SYMBOL(qdisc_destroy);
617EXPORT_SYMBOL(qdisc_reset); 617EXPORT_SYMBOL(qdisc_reset);
618EXPORT_SYMBOL(qdisc_lock_tree); 618EXPORT_SYMBOL(qdisc_lock_tree);
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 6a6735a2ed35..6eefa6995777 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -946,6 +946,7 @@ qdisc_peek_len(struct Qdisc *sch)
946 if (unlikely(sch->ops->requeue(skb, sch) != NET_XMIT_SUCCESS)) { 946 if (unlikely(sch->ops->requeue(skb, sch) != NET_XMIT_SUCCESS)) {
947 if (net_ratelimit()) 947 if (net_ratelimit())
948 printk("qdisc_peek_len: failed to requeue\n"); 948 printk("qdisc_peek_len: failed to requeue\n");
949 qdisc_tree_decrease_qlen(sch, 1);
949 return 0; 950 return 0;
950 } 951 }
951 return len; 952 return len;
@@ -957,11 +958,7 @@ hfsc_purge_queue(struct Qdisc *sch, struct hfsc_class *cl)
957 unsigned int len = cl->qdisc->q.qlen; 958 unsigned int len = cl->qdisc->q.qlen;
958 959
959 qdisc_reset(cl->qdisc); 960 qdisc_reset(cl->qdisc);
960 if (len > 0) { 961 qdisc_tree_decrease_qlen(cl->qdisc, len);
961 update_vf(cl, 0, 0);
962 set_passive(cl);
963 sch->q.qlen -= len;
964 }
965} 962}
966 963
967static void 964static void
@@ -1138,7 +1135,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
1138 cl->classid = classid; 1135 cl->classid = classid;
1139 cl->sched = q; 1136 cl->sched = q;
1140 cl->cl_parent = parent; 1137 cl->cl_parent = parent;
1141 cl->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); 1138 cl->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops, classid);
1142 if (cl->qdisc == NULL) 1139 if (cl->qdisc == NULL)
1143 cl->qdisc = &noop_qdisc; 1140 cl->qdisc = &noop_qdisc;
1144 cl->stats_lock = &sch->dev->queue_lock; 1141 cl->stats_lock = &sch->dev->queue_lock;
@@ -1271,7 +1268,8 @@ hfsc_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
1271 if (cl->level > 0) 1268 if (cl->level > 0)
1272 return -EINVAL; 1269 return -EINVAL;
1273 if (new == NULL) { 1270 if (new == NULL) {
1274 new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); 1271 new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
1272 cl->classid);
1275 if (new == NULL) 1273 if (new == NULL)
1276 new = &noop_qdisc; 1274 new = &noop_qdisc;
1277 } 1275 }
@@ -1294,6 +1292,17 @@ hfsc_class_leaf(struct Qdisc *sch, unsigned long arg)
1294 return NULL; 1292 return NULL;
1295} 1293}
1296 1294
1295static void
1296hfsc_qlen_notify(struct Qdisc *sch, unsigned long arg)
1297{
1298 struct hfsc_class *cl = (struct hfsc_class *)arg;
1299
1300 if (cl->qdisc->q.qlen == 0) {
1301 update_vf(cl, 0, 0);
1302 set_passive(cl);
1303 }
1304}
1305
1297static unsigned long 1306static unsigned long
1298hfsc_get_class(struct Qdisc *sch, u32 classid) 1307hfsc_get_class(struct Qdisc *sch, u32 classid)
1299{ 1308{
@@ -1514,7 +1523,8 @@ hfsc_init_qdisc(struct Qdisc *sch, struct rtattr *opt)
1514 q->root.refcnt = 1; 1523 q->root.refcnt = 1;
1515 q->root.classid = sch->handle; 1524 q->root.classid = sch->handle;
1516 q->root.sched = q; 1525 q->root.sched = q;
1517 q->root.qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); 1526 q->root.qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
1527 sch->handle);
1518 if (q->root.qdisc == NULL) 1528 if (q->root.qdisc == NULL)
1519 q->root.qdisc = &noop_qdisc; 1529 q->root.qdisc = &noop_qdisc;
1520 q->root.stats_lock = &sch->dev->queue_lock; 1530 q->root.stats_lock = &sch->dev->queue_lock;
@@ -1777,6 +1787,7 @@ static struct Qdisc_class_ops hfsc_class_ops = {
1777 .delete = hfsc_delete_class, 1787 .delete = hfsc_delete_class,
1778 .graft = hfsc_graft_class, 1788 .graft = hfsc_graft_class,
1779 .leaf = hfsc_class_leaf, 1789 .leaf = hfsc_class_leaf,
1790 .qlen_notify = hfsc_qlen_notify,
1780 .get = hfsc_get_class, 1791 .get = hfsc_get_class,
1781 .put = hfsc_put_class, 1792 .put = hfsc_put_class,
1782 .bind_tcf = hfsc_bind_tcf, 1793 .bind_tcf = hfsc_bind_tcf,
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 4b52fa78935a..215e68c2b615 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1223,17 +1223,14 @@ static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
1223 struct htb_class *cl = (struct htb_class *)arg; 1223 struct htb_class *cl = (struct htb_class *)arg;
1224 1224
1225 if (cl && !cl->level) { 1225 if (cl && !cl->level) {
1226 if (new == NULL && (new = qdisc_create_dflt(sch->dev, 1226 if (new == NULL &&
1227 &pfifo_qdisc_ops)) 1227 (new = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
1228 cl->classid))
1228 == NULL) 1229 == NULL)
1229 return -ENOBUFS; 1230 return -ENOBUFS;
1230 sch_tree_lock(sch); 1231 sch_tree_lock(sch);
1231 if ((*old = xchg(&cl->un.leaf.q, new)) != NULL) { 1232 if ((*old = xchg(&cl->un.leaf.q, new)) != NULL) {
1232 if (cl->prio_activity) 1233 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
1233 htb_deactivate(qdisc_priv(sch), cl);
1234
1235 /* TODO: is it correct ? Why CBQ doesn't do it ? */
1236 sch->q.qlen -= (*old)->q.qlen;
1237 qdisc_reset(*old); 1234 qdisc_reset(*old);
1238 } 1235 }
1239 sch_tree_unlock(sch); 1236 sch_tree_unlock(sch);
@@ -1248,6 +1245,14 @@ static struct Qdisc *htb_leaf(struct Qdisc *sch, unsigned long arg)
1248 return (cl && !cl->level) ? cl->un.leaf.q : NULL; 1245 return (cl && !cl->level) ? cl->un.leaf.q : NULL;
1249} 1246}
1250 1247
1248static void htb_qlen_notify(struct Qdisc *sch, unsigned long arg)
1249{
1250 struct htb_class *cl = (struct htb_class *)arg;
1251
1252 if (cl->un.leaf.q->q.qlen == 0)
1253 htb_deactivate(qdisc_priv(sch), cl);
1254}
1255
1251static unsigned long htb_get(struct Qdisc *sch, u32 classid) 1256static unsigned long htb_get(struct Qdisc *sch, u32 classid)
1252{ 1257{
1253 struct htb_class *cl = htb_find(classid, sch); 1258 struct htb_class *cl = htb_find(classid, sch);
@@ -1269,9 +1274,9 @@ static void htb_destroy_filters(struct tcf_proto **fl)
1269static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl) 1274static void htb_destroy_class(struct Qdisc *sch, struct htb_class *cl)
1270{ 1275{
1271 struct htb_sched *q = qdisc_priv(sch); 1276 struct htb_sched *q = qdisc_priv(sch);
1277
1272 if (!cl->level) { 1278 if (!cl->level) {
1273 BUG_TRAP(cl->un.leaf.q); 1279 BUG_TRAP(cl->un.leaf.q);
1274 sch->q.qlen -= cl->un.leaf.q->q.qlen;
1275 qdisc_destroy(cl->un.leaf.q); 1280 qdisc_destroy(cl->un.leaf.q);
1276 } 1281 }
1277 qdisc_put_rtab(cl->rate); 1282 qdisc_put_rtab(cl->rate);
@@ -1322,6 +1327,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
1322{ 1327{
1323 struct htb_sched *q = qdisc_priv(sch); 1328 struct htb_sched *q = qdisc_priv(sch);
1324 struct htb_class *cl = (struct htb_class *)arg; 1329 struct htb_class *cl = (struct htb_class *)arg;
1330 unsigned int qlen;
1325 1331
1326 // TODO: why don't allow to delete subtree ? references ? does 1332 // TODO: why don't allow to delete subtree ? references ? does
1327 // tc subsys quarantee us that in htb_destroy it holds no class 1333 // tc subsys quarantee us that in htb_destroy it holds no class
@@ -1334,6 +1340,12 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
1334 /* delete from hash and active; remainder in destroy_class */ 1340 /* delete from hash and active; remainder in destroy_class */
1335 hlist_del_init(&cl->hlist); 1341 hlist_del_init(&cl->hlist);
1336 1342
1343 if (!cl->level) {
1344 qlen = cl->un.leaf.q->q.qlen;
1345 qdisc_reset(cl->un.leaf.q);
1346 qdisc_tree_decrease_qlen(cl->un.leaf.q, qlen);
1347 }
1348
1337 if (cl->prio_activity) 1349 if (cl->prio_activity)
1338 htb_deactivate(q, cl); 1350 htb_deactivate(q, cl);
1339 1351
@@ -1410,11 +1422,14 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1410 /* create leaf qdisc early because it uses kmalloc(GFP_KERNEL) 1422 /* create leaf qdisc early because it uses kmalloc(GFP_KERNEL)
1411 so that can't be used inside of sch_tree_lock 1423 so that can't be used inside of sch_tree_lock
1412 -- thanks to Karlis Peisenieks */ 1424 -- thanks to Karlis Peisenieks */
1413 new_q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); 1425 new_q = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops, classid);
1414 sch_tree_lock(sch); 1426 sch_tree_lock(sch);
1415 if (parent && !parent->level) { 1427 if (parent && !parent->level) {
1428 unsigned int qlen = parent->un.leaf.q->q.qlen;
1429
1416 /* turn parent into inner node */ 1430 /* turn parent into inner node */
1417 sch->q.qlen -= parent->un.leaf.q->q.qlen; 1431 qdisc_reset(parent->un.leaf.q);
1432 qdisc_tree_decrease_qlen(parent->un.leaf.q, qlen);
1418 qdisc_destroy(parent->un.leaf.q); 1433 qdisc_destroy(parent->un.leaf.q);
1419 if (parent->prio_activity) 1434 if (parent->prio_activity)
1420 htb_deactivate(q, parent); 1435 htb_deactivate(q, parent);
@@ -1562,6 +1577,7 @@ static void htb_walk(struct Qdisc *sch, struct qdisc_walker *arg)
1562static struct Qdisc_class_ops htb_class_ops = { 1577static struct Qdisc_class_ops htb_class_ops = {
1563 .graft = htb_graft, 1578 .graft = htb_graft,
1564 .leaf = htb_leaf, 1579 .leaf = htb_leaf,
1580 .qlen_notify = htb_qlen_notify,
1565 .get = htb_get, 1581 .get = htb_get,
1566 .put = htb_put, 1582 .put = htb_put,
1567 .change = htb_change_class, 1583 .change = htb_change_class,
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 0441876aa1e7..79542af9dab1 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -287,13 +287,10 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)
287 psched_tdiff_t delay = PSCHED_TDIFF(cb->time_to_send, now); 287 psched_tdiff_t delay = PSCHED_TDIFF(cb->time_to_send, now);
288 288
289 if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) { 289 if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
290 qdisc_tree_decrease_qlen(q->qdisc, 1);
290 sch->qstats.drops++; 291 sch->qstats.drops++;
291
292 /* After this qlen is confused */
293 printk(KERN_ERR "netem: queue discpline %s could not requeue\n", 292 printk(KERN_ERR "netem: queue discpline %s could not requeue\n",
294 q->qdisc->ops->id); 293 q->qdisc->ops->id);
295
296 sch->q.qlen--;
297 } 294 }
298 295
299 mod_timer(&q->timer, jiffies + PSCHED_US2JIFFIE(delay)); 296 mod_timer(&q->timer, jiffies + PSCHED_US2JIFFIE(delay));
@@ -574,7 +571,8 @@ static int netem_init(struct Qdisc *sch, struct rtattr *opt)
574 q->timer.function = netem_watchdog; 571 q->timer.function = netem_watchdog;
575 q->timer.data = (unsigned long) sch; 572 q->timer.data = (unsigned long) sch;
576 573
577 q->qdisc = qdisc_create_dflt(sch->dev, &tfifo_qdisc_ops); 574 q->qdisc = qdisc_create_dflt(sch->dev, &tfifo_qdisc_ops,
575 TC_H_MAKE(sch->handle, 1));
578 if (!q->qdisc) { 576 if (!q->qdisc) {
579 pr_debug("netem: qdisc create failed\n"); 577 pr_debug("netem: qdisc create failed\n");
580 return -ENOMEM; 578 return -ENOMEM;
@@ -661,8 +659,8 @@ static int netem_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
661 659
662 sch_tree_lock(sch); 660 sch_tree_lock(sch);
663 *old = xchg(&q->qdisc, new); 661 *old = xchg(&q->qdisc, new);
662 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
664 qdisc_reset(*old); 663 qdisc_reset(*old);
665 sch->q.qlen = 0;
666 sch_tree_unlock(sch); 664 sch_tree_unlock(sch);
667 665
668 return 0; 666 return 0;
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index a5fa03c0c19b..2567b4c96c1e 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -222,21 +222,27 @@ static int prio_tune(struct Qdisc *sch, struct rtattr *opt)
222 222
223 for (i=q->bands; i<TCQ_PRIO_BANDS; i++) { 223 for (i=q->bands; i<TCQ_PRIO_BANDS; i++) {
224 struct Qdisc *child = xchg(&q->queues[i], &noop_qdisc); 224 struct Qdisc *child = xchg(&q->queues[i], &noop_qdisc);
225 if (child != &noop_qdisc) 225 if (child != &noop_qdisc) {
226 qdisc_tree_decrease_qlen(child, child->q.qlen);
226 qdisc_destroy(child); 227 qdisc_destroy(child);
228 }
227 } 229 }
228 sch_tree_unlock(sch); 230 sch_tree_unlock(sch);
229 231
230 for (i=0; i<q->bands; i++) { 232 for (i=0; i<q->bands; i++) {
231 if (q->queues[i] == &noop_qdisc) { 233 if (q->queues[i] == &noop_qdisc) {
232 struct Qdisc *child; 234 struct Qdisc *child;
233 child = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops); 235 child = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops,
236 TC_H_MAKE(sch->handle, i + 1));
234 if (child) { 237 if (child) {
235 sch_tree_lock(sch); 238 sch_tree_lock(sch);
236 child = xchg(&q->queues[i], child); 239 child = xchg(&q->queues[i], child);
237 240
238 if (child != &noop_qdisc) 241 if (child != &noop_qdisc) {
242 qdisc_tree_decrease_qlen(child,
243 child->q.qlen);
239 qdisc_destroy(child); 244 qdisc_destroy(child);
245 }
240 sch_tree_unlock(sch); 246 sch_tree_unlock(sch);
241 } 247 }
242 } 248 }
@@ -294,7 +300,7 @@ static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
294 sch_tree_lock(sch); 300 sch_tree_lock(sch);
295 *old = q->queues[band]; 301 *old = q->queues[band];
296 q->queues[band] = new; 302 q->queues[band] = new;
297 sch->q.qlen -= (*old)->q.qlen; 303 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
298 qdisc_reset(*old); 304 qdisc_reset(*old);
299 sch_tree_unlock(sch); 305 sch_tree_unlock(sch);
300 306
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index d65cadddea69..acddad08850f 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -175,12 +175,14 @@ static void red_destroy(struct Qdisc *sch)
175 qdisc_destroy(q->qdisc); 175 qdisc_destroy(q->qdisc);
176} 176}
177 177
178static struct Qdisc *red_create_dflt(struct net_device *dev, u32 limit) 178static struct Qdisc *red_create_dflt(struct Qdisc *sch, u32 limit)
179{ 179{
180 struct Qdisc *q = qdisc_create_dflt(dev, &bfifo_qdisc_ops); 180 struct Qdisc *q;
181 struct rtattr *rta; 181 struct rtattr *rta;
182 int ret; 182 int ret;
183 183
184 q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops,
185 TC_H_MAKE(sch->handle, 1));
184 if (q) { 186 if (q) {
185 rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), 187 rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)),
186 GFP_KERNEL); 188 GFP_KERNEL);
@@ -219,7 +221,7 @@ static int red_change(struct Qdisc *sch, struct rtattr *opt)
219 ctl = RTA_DATA(tb[TCA_RED_PARMS-1]); 221 ctl = RTA_DATA(tb[TCA_RED_PARMS-1]);
220 222
221 if (ctl->limit > 0) { 223 if (ctl->limit > 0) {
222 child = red_create_dflt(sch->dev, ctl->limit); 224 child = red_create_dflt(sch, ctl->limit);
223 if (child == NULL) 225 if (child == NULL)
224 return -ENOMEM; 226 return -ENOMEM;
225 } 227 }
@@ -227,8 +229,10 @@ static int red_change(struct Qdisc *sch, struct rtattr *opt)
227 sch_tree_lock(sch); 229 sch_tree_lock(sch);
228 q->flags = ctl->flags; 230 q->flags = ctl->flags;
229 q->limit = ctl->limit; 231 q->limit = ctl->limit;
230 if (child) 232 if (child) {
233 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
231 qdisc_destroy(xchg(&q->qdisc, child)); 234 qdisc_destroy(xchg(&q->qdisc, child));
235 }
232 236
233 red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog, 237 red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog,
234 ctl->Plog, ctl->Scell_log, 238 ctl->Plog, ctl->Scell_log,
@@ -306,8 +310,8 @@ static int red_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
306 310
307 sch_tree_lock(sch); 311 sch_tree_lock(sch);
308 *old = xchg(&q->qdisc, new); 312 *old = xchg(&q->qdisc, new);
313 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
309 qdisc_reset(*old); 314 qdisc_reset(*old);
310 sch->q.qlen = 0;
311 sch_tree_unlock(sch); 315 sch_tree_unlock(sch);
312 return 0; 316 return 0;
313} 317}
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index d0d6e595a78c..459cda258a5c 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -393,6 +393,7 @@ static int sfq_change(struct Qdisc *sch, struct rtattr *opt)
393{ 393{
394 struct sfq_sched_data *q = qdisc_priv(sch); 394 struct sfq_sched_data *q = qdisc_priv(sch);
395 struct tc_sfq_qopt *ctl = RTA_DATA(opt); 395 struct tc_sfq_qopt *ctl = RTA_DATA(opt);
396 unsigned int qlen;
396 397
397 if (opt->rta_len < RTA_LENGTH(sizeof(*ctl))) 398 if (opt->rta_len < RTA_LENGTH(sizeof(*ctl)))
398 return -EINVAL; 399 return -EINVAL;
@@ -403,8 +404,10 @@ static int sfq_change(struct Qdisc *sch, struct rtattr *opt)
403 if (ctl->limit) 404 if (ctl->limit)
404 q->limit = min_t(u32, ctl->limit, SFQ_DEPTH); 405 q->limit = min_t(u32, ctl->limit, SFQ_DEPTH);
405 406
407 qlen = sch->q.qlen;
406 while (sch->q.qlen >= q->limit-1) 408 while (sch->q.qlen >= q->limit-1)
407 sfq_drop(sch); 409 sfq_drop(sch);
410 qdisc_tree_decrease_qlen(sch, qlen - sch->q.qlen);
408 411
409 del_timer(&q->perturb_timer); 412 del_timer(&q->perturb_timer);
410 if (q->perturb_period) { 413 if (q->perturb_period) {
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index d9a5d298d755..ed9b6d938540 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -250,7 +250,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
250 250
251 if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) { 251 if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
252 /* When requeue fails skb is dropped */ 252 /* When requeue fails skb is dropped */
253 sch->q.qlen--; 253 qdisc_tree_decrease_qlen(q->qdisc, 1);
254 sch->qstats.drops++; 254 sch->qstats.drops++;
255 } 255 }
256 256
@@ -273,12 +273,14 @@ static void tbf_reset(struct Qdisc* sch)
273 del_timer(&q->wd_timer); 273 del_timer(&q->wd_timer);
274} 274}
275 275
276static struct Qdisc *tbf_create_dflt_qdisc(struct net_device *dev, u32 limit) 276static struct Qdisc *tbf_create_dflt_qdisc(struct Qdisc *sch, u32 limit)
277{ 277{
278 struct Qdisc *q = qdisc_create_dflt(dev, &bfifo_qdisc_ops); 278 struct Qdisc *q;
279 struct rtattr *rta; 279 struct rtattr *rta;
280 int ret; 280 int ret;
281 281
282 q = qdisc_create_dflt(sch->dev, &bfifo_qdisc_ops,
283 TC_H_MAKE(sch->handle, 1));
282 if (q) { 284 if (q) {
283 rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL); 285 rta = kmalloc(RTA_LENGTH(sizeof(struct tc_fifo_qopt)), GFP_KERNEL);
284 if (rta) { 286 if (rta) {
@@ -341,13 +343,15 @@ static int tbf_change(struct Qdisc* sch, struct rtattr *opt)
341 goto done; 343 goto done;
342 344
343 if (qopt->limit > 0) { 345 if (qopt->limit > 0) {
344 if ((child = tbf_create_dflt_qdisc(sch->dev, qopt->limit)) == NULL) 346 if ((child = tbf_create_dflt_qdisc(sch, qopt->limit)) == NULL)
345 goto done; 347 goto done;
346 } 348 }
347 349
348 sch_tree_lock(sch); 350 sch_tree_lock(sch);
349 if (child) 351 if (child) {
352 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
350 qdisc_destroy(xchg(&q->qdisc, child)); 353 qdisc_destroy(xchg(&q->qdisc, child));
354 }
351 q->limit = qopt->limit; 355 q->limit = qopt->limit;
352 q->mtu = qopt->mtu; 356 q->mtu = qopt->mtu;
353 q->max_size = max_size; 357 q->max_size = max_size;
@@ -449,8 +453,8 @@ static int tbf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
449 453
450 sch_tree_lock(sch); 454 sch_tree_lock(sch);
451 *old = xchg(&q->qdisc, new); 455 *old = xchg(&q->qdisc, new);
456 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
452 qdisc_reset(*old); 457 qdisc_reset(*old);
453 sch->q.qlen = 0;
454 sch_tree_unlock(sch); 458 sch_tree_unlock(sch);
455 459
456 return 0; 460 return 0;
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 88124696ba60..ad0057db0f91 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -486,7 +486,7 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc,
486 " port: %d\n", 486 " port: %d\n",
487 asoc, 487 asoc,
488 (&peer->ipaddr), 488 (&peer->ipaddr),
489 peer->ipaddr.v4.sin_port); 489 ntohs(peer->ipaddr.v4.sin_port));
490 490
491 /* If we are to remove the current retran_path, update it 491 /* If we are to remove the current retran_path, update it
492 * to the next peer before removing this peer from the list. 492 * to the next peer before removing this peer from the list.
@@ -535,13 +535,13 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
535 sp = sctp_sk(asoc->base.sk); 535 sp = sctp_sk(asoc->base.sk);
536 536
537 /* AF_INET and AF_INET6 share common port field. */ 537 /* AF_INET and AF_INET6 share common port field. */
538 port = addr->v4.sin_port; 538 port = ntohs(addr->v4.sin_port);
539 539
540 SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ", 540 SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ",
541 " port: %d state:%d\n", 541 " port: %d state:%d\n",
542 asoc, 542 asoc,
543 addr, 543 addr,
544 addr->v4.sin_port, 544 port,
545 peer_state); 545 peer_state);
546 546
547 /* Set the port if it has not been set yet. */ 547 /* Set the port if it has not been set yet. */
@@ -707,6 +707,7 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
707 struct sctp_transport *first; 707 struct sctp_transport *first;
708 struct sctp_transport *second; 708 struct sctp_transport *second;
709 struct sctp_ulpevent *event; 709 struct sctp_ulpevent *event;
710 struct sockaddr_storage addr;
710 struct list_head *pos; 711 struct list_head *pos;
711 int spc_state = 0; 712 int spc_state = 0;
712 713
@@ -729,8 +730,9 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
729 /* Generate and send a SCTP_PEER_ADDR_CHANGE notification to the 730 /* Generate and send a SCTP_PEER_ADDR_CHANGE notification to the
730 * user. 731 * user.
731 */ 732 */
732 event = sctp_ulpevent_make_peer_addr_change(asoc, 733 memset(&addr, 0, sizeof(struct sockaddr_storage));
733 (struct sockaddr_storage *) &transport->ipaddr, 734 memcpy(&addr, &transport->ipaddr, transport->af_specific->sockaddr_len);
735 event = sctp_ulpevent_make_peer_addr_change(asoc, &addr,
734 0, spc_state, error, GFP_ATOMIC); 736 0, spc_state, error, GFP_ATOMIC);
735 if (event) 737 if (event)
736 sctp_ulpq_tail_event(&asoc->ulpq, event); 738 sctp_ulpq_tail_event(&asoc->ulpq, event);
@@ -866,7 +868,7 @@ struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *asoc,
866 struct list_head *entry, *pos; 868 struct list_head *entry, *pos;
867 struct sctp_transport *transport; 869 struct sctp_transport *transport;
868 struct sctp_chunk *chunk; 870 struct sctp_chunk *chunk;
869 __u32 key = htonl(tsn); 871 __be32 key = htonl(tsn);
870 872
871 match = NULL; 873 match = NULL;
872 874
@@ -924,8 +926,8 @@ struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc,
924 926
925 sctp_read_lock(&asoc->base.addr_lock); 927 sctp_read_lock(&asoc->base.addr_lock);
926 928
927 if ((asoc->base.bind_addr.port == laddr->v4.sin_port) && 929 if ((htons(asoc->base.bind_addr.port) == laddr->v4.sin_port) &&
928 (asoc->peer.port == paddr->v4.sin_port)) { 930 (htons(asoc->peer.port) == paddr->v4.sin_port)) {
929 transport = sctp_assoc_lookup_paddr(asoc, paddr); 931 transport = sctp_assoc_lookup_paddr(asoc, paddr);
930 if (!transport) 932 if (!transport)
931 goto out; 933 goto out;
@@ -1136,7 +1138,7 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc)
1136 " port: %d\n", 1138 " port: %d\n",
1137 asoc, 1139 asoc,
1138 (&t->ipaddr), 1140 (&t->ipaddr),
1139 t->ipaddr.v4.sin_port); 1141 ntohs(t->ipaddr.v4.sin_port));
1140} 1142}
1141 1143
1142/* Choose the transport for sending a INIT packet. */ 1144/* Choose the transport for sending a INIT packet. */
@@ -1161,7 +1163,7 @@ struct sctp_transport *sctp_assoc_choose_init_transport(
1161 " port: %d\n", 1163 " port: %d\n",
1162 asoc, 1164 asoc,
1163 (&t->ipaddr), 1165 (&t->ipaddr),
1164 t->ipaddr.v4.sin_port); 1166 ntohs(t->ipaddr.v4.sin_port));
1165 1167
1166 return t; 1168 return t;
1167} 1169}
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index 2b9c12a170e5..00994158e496 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -161,7 +161,7 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
161 * Both v4 and v6 have the port at the same offset. 161 * Both v4 and v6 have the port at the same offset.
162 */ 162 */
163 if (!addr->a.v4.sin_port) 163 if (!addr->a.v4.sin_port)
164 addr->a.v4.sin_port = bp->port; 164 addr->a.v4.sin_port = htons(bp->port);
165 165
166 addr->use_as_src = use_as_src; 166 addr->use_as_src = use_as_src;
167 167
@@ -275,7 +275,7 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
275 break; 275 break;
276 } 276 }
277 277
278 af->from_addr_param(&addr, rawaddr, port, 0); 278 af->from_addr_param(&addr, rawaddr, htons(port), 0);
279 retval = sctp_add_bind_addr(bp, &addr, 1, gfp); 279 retval = sctp_add_bind_addr(bp, &addr, 1, gfp);
280 if (retval) { 280 if (retval) {
281 /* Can't finish building the list, clean up. */ 281 /* Can't finish building the list, clean up. */
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index a2b553721514..129756908da4 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -72,6 +72,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
72{ 72{
73 memset(ep, 0, sizeof(struct sctp_endpoint)); 73 memset(ep, 0, sizeof(struct sctp_endpoint));
74 74
75 ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp);
76 if (!ep->digest)
77 return NULL;
78
75 /* Initialize the base structure. */ 79 /* Initialize the base structure. */
76 /* What type of endpoint are we? */ 80 /* What type of endpoint are we? */
77 ep->base.type = SCTP_EP_TYPE_SOCKET; 81 ep->base.type = SCTP_EP_TYPE_SOCKET;
@@ -181,6 +185,9 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
181 /* Free up the HMAC transform. */ 185 /* Free up the HMAC transform. */
182 crypto_free_hash(sctp_sk(ep->base.sk)->hmac); 186 crypto_free_hash(sctp_sk(ep->base.sk)->hmac);
183 187
188 /* Free the digest buffer */
189 kfree(ep->digest);
190
184 /* Cleanup. */ 191 /* Cleanup. */
185 sctp_inq_free(&ep->base.inqueue); 192 sctp_inq_free(&ep->base.inqueue);
186 sctp_bind_addr_free(&ep->base.bind_addr); 193 sctp_bind_addr_free(&ep->base.bind_addr);
@@ -222,7 +229,7 @@ struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep,
222 struct sctp_endpoint *retval; 229 struct sctp_endpoint *retval;
223 230
224 sctp_read_lock(&ep->base.addr_lock); 231 sctp_read_lock(&ep->base.addr_lock);
225 if (ep->base.bind_addr.port == laddr->v4.sin_port) { 232 if (htons(ep->base.bind_addr.port) == laddr->v4.sin_port) {
226 if (sctp_bind_addr_match(&ep->base.bind_addr, laddr, 233 if (sctp_bind_addr_match(&ep->base.bind_addr, laddr,
227 sctp_sk(ep->base.sk))) { 234 sctp_sk(ep->base.sk))) {
228 retval = ep; 235 retval = ep;
@@ -250,7 +257,7 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc(
250 struct sctp_association *asoc; 257 struct sctp_association *asoc;
251 struct list_head *pos; 258 struct list_head *pos;
252 259
253 rport = paddr->v4.sin_port; 260 rport = ntohs(paddr->v4.sin_port);
254 261
255 list_for_each(pos, &ep->asocs) { 262 list_for_each(pos, &ep->asocs) {
256 asoc = list_entry(pos, struct sctp_association, asocs); 263 asoc = list_entry(pos, struct sctp_association, asocs);
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 6d82f400d13c..33111873a488 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -726,7 +726,7 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l
726 struct sctp_endpoint *ep; 726 struct sctp_endpoint *ep;
727 int hash; 727 int hash;
728 728
729 hash = sctp_ep_hashfn(laddr->v4.sin_port); 729 hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port));
730 head = &sctp_ep_hashtable[hash]; 730 head = &sctp_ep_hashtable[hash];
731 read_lock(&head->lock); 731 read_lock(&head->lock);
732 for (epb = head->chain; epb; epb = epb->next) { 732 for (epb = head->chain; epb; epb = epb->next) {
@@ -830,7 +830,7 @@ static struct sctp_association *__sctp_lookup_association(
830 /* Optimize here for direct hit, only listening connections can 830 /* Optimize here for direct hit, only listening connections can
831 * have wildcards anyways. 831 * have wildcards anyways.
832 */ 832 */
833 hash = sctp_assoc_hashfn(local->v4.sin_port, peer->v4.sin_port); 833 hash = sctp_assoc_hashfn(ntohs(local->v4.sin_port), ntohs(peer->v4.sin_port));
834 head = &sctp_assoc_hashtable[hash]; 834 head = &sctp_assoc_hashtable[hash];
835 read_lock(&head->lock); 835 read_lock(&head->lock);
836 for (epb = head->chain; epb; epb = epb->next) { 836 for (epb = head->chain; epb; epb = epb->next) {
@@ -957,7 +957,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb,
957 if (!af) 957 if (!af)
958 continue; 958 continue;
959 959
960 af->from_addr_param(paddr, params.addr, ntohs(sh->source), 0); 960 af->from_addr_param(paddr, params.addr, sh->source, 0);
961 961
962 asoc = __sctp_lookup_association(laddr, paddr, &transport); 962 asoc = __sctp_lookup_association(laddr, paddr, &transport);
963 if (asoc) 963 if (asoc)
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 78071c6e6cf1..3c3e560087ca 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -84,7 +84,7 @@ static struct notifier_block sctp_inet6addr_notifier = {
84 84
85/* ICMP error handler. */ 85/* ICMP error handler. */
86SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 86SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
87 int type, int code, int offset, __u32 info) 87 int type, int code, int offset, __be32 info)
88{ 88{
89 struct inet6_dev *idev; 89 struct inet6_dev *idev;
90 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data; 90 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
@@ -170,8 +170,6 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport,
170 fl.oif = transport->saddr.v6.sin6_scope_id; 170 fl.oif = transport->saddr.v6.sin6_scope_id;
171 else 171 else
172 fl.oif = sk->sk_bound_dev_if; 172 fl.oif = sk->sk_bound_dev_if;
173 fl.fl_ip_sport = inet_sk(sk)->sport;
174 fl.fl_ip_dport = transport->ipaddr.v6.sin6_port;
175 173
176 if (np->opt && np->opt->srcrt) { 174 if (np->opt && np->opt->srcrt) {
177 struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt; 175 struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
@@ -239,7 +237,7 @@ static inline int sctp_v6_addr_match_len(union sctp_addr *s1,
239 int i, j; 237 int i, j;
240 238
241 for (i = 0; i < 4 ; i++) { 239 for (i = 0; i < 4 ; i++) {
242 __u32 a1xora2; 240 __be32 a1xora2;
243 241
244 a1xora2 = a1->s6_addr32[i] ^ a2->s6_addr32[i]; 242 a1xora2 = a1->s6_addr32[i] ^ a2->s6_addr32[i];
245 243
@@ -350,7 +348,7 @@ static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb,
350 int is_saddr) 348 int is_saddr)
351{ 349{
352 void *from; 350 void *from;
353 __u16 *port; 351 __be16 *port;
354 struct sctphdr *sh; 352 struct sctphdr *sh;
355 353
356 port = &addr->v6.sin6_port; 354 port = &addr->v6.sin6_port;
@@ -360,10 +358,10 @@ static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb,
360 358
361 sh = (struct sctphdr *) skb->h.raw; 359 sh = (struct sctphdr *) skb->h.raw;
362 if (is_saddr) { 360 if (is_saddr) {
363 *port = ntohs(sh->source); 361 *port = sh->source;
364 from = &skb->nh.ipv6h->saddr; 362 from = &skb->nh.ipv6h->saddr;
365 } else { 363 } else {
366 *port = ntohs(sh->dest); 364 *port = sh->dest;
367 from = &skb->nh.ipv6h->daddr; 365 from = &skb->nh.ipv6h->daddr;
368 } 366 }
369 ipv6_addr_copy(&addr->v6.sin6_addr, from); 367 ipv6_addr_copy(&addr->v6.sin6_addr, from);
@@ -373,7 +371,7 @@ static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb,
373static void sctp_v6_from_sk(union sctp_addr *addr, struct sock *sk) 371static void sctp_v6_from_sk(union sctp_addr *addr, struct sock *sk)
374{ 372{
375 addr->v6.sin6_family = AF_INET6; 373 addr->v6.sin6_family = AF_INET6;
376 addr->v6.sin6_port = inet_sk(sk)->num; 374 addr->v6.sin6_port = 0;
377 addr->v6.sin6_addr = inet6_sk(sk)->rcv_saddr; 375 addr->v6.sin6_addr = inet6_sk(sk)->rcv_saddr;
378} 376}
379 377
@@ -407,7 +405,7 @@ static void sctp_v6_to_sk_daddr(union sctp_addr *addr, struct sock *sk)
407/* Initialize a sctp_addr from an address parameter. */ 405/* Initialize a sctp_addr from an address parameter. */
408static void sctp_v6_from_addr_param(union sctp_addr *addr, 406static void sctp_v6_from_addr_param(union sctp_addr *addr,
409 union sctp_addr_param *param, 407 union sctp_addr_param *param,
410 __u16 port, int iif) 408 __be16 port, int iif)
411{ 409{
412 addr->v6.sin6_family = AF_INET6; 410 addr->v6.sin6_family = AF_INET6;
413 addr->v6.sin6_port = port; 411 addr->v6.sin6_port = port;
@@ -425,7 +423,7 @@ static int sctp_v6_to_addr_param(const union sctp_addr *addr,
425 int length = sizeof(sctp_ipv6addr_param_t); 423 int length = sizeof(sctp_ipv6addr_param_t);
426 424
427 param->v6.param_hdr.type = SCTP_PARAM_IPV6_ADDRESS; 425 param->v6.param_hdr.type = SCTP_PARAM_IPV6_ADDRESS;
428 param->v6.param_hdr.length = ntohs(length); 426 param->v6.param_hdr.length = htons(length);
429 ipv6_addr_copy(&param->v6.addr, &addr->v6.sin6_addr); 427 ipv6_addr_copy(&param->v6.addr, &addr->v6.sin6_addr);
430 428
431 return length; 429 return length;
@@ -433,7 +431,7 @@ static int sctp_v6_to_addr_param(const union sctp_addr *addr,
433 431
434/* Initialize a sctp_addr from a dst_entry. */ 432/* Initialize a sctp_addr from a dst_entry. */
435static void sctp_v6_dst_saddr(union sctp_addr *addr, struct dst_entry *dst, 433static void sctp_v6_dst_saddr(union sctp_addr *addr, struct dst_entry *dst,
436 unsigned short port) 434 __be16 port)
437{ 435{
438 struct rt6_info *rt = (struct rt6_info *)dst; 436 struct rt6_info *rt = (struct rt6_info *)dst;
439 addr->sa.sa_family = AF_INET6; 437 addr->sa.sa_family = AF_INET6;
@@ -480,7 +478,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
480} 478}
481 479
482/* Initialize addr struct to INADDR_ANY. */ 480/* Initialize addr struct to INADDR_ANY. */
483static void sctp_v6_inaddr_any(union sctp_addr *addr, unsigned short port) 481static void sctp_v6_inaddr_any(union sctp_addr *addr, __be16 port)
484{ 482{
485 memset(addr, 0x00, sizeof(union sctp_addr)); 483 memset(addr, 0x00, sizeof(union sctp_addr));
486 addr->v6.sin6_family = AF_INET6; 484 addr->v6.sin6_family = AF_INET6;
@@ -855,7 +853,7 @@ static int sctp_inet6_send_verify(struct sctp_sock *opt, union sctp_addr *addr)
855 * Returns number of addresses supported. 853 * Returns number of addresses supported.
856 */ 854 */
857static int sctp_inet6_supported_addrs(const struct sctp_sock *opt, 855static int sctp_inet6_supported_addrs(const struct sctp_sock *opt,
858 __u16 *types) 856 __be16 *types)
859{ 857{
860 types[0] = SCTP_PARAM_IPV4_ADDRESS; 858 types[0] = SCTP_PARAM_IPV4_ADDRESS;
861 types[1] = SCTP_PARAM_IPV6_ADDRESS; 859 types[1] = SCTP_PARAM_IPV6_ADDRESS;
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 739582415bf6..fba567a7cb64 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -1065,7 +1065,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
1065 * A) Initialize the cacc_saw_newack to 0 for all destination 1065 * A) Initialize the cacc_saw_newack to 0 for all destination
1066 * addresses. 1066 * addresses.
1067 */ 1067 */
1068 if (sack->num_gap_ack_blocks > 0 && 1068 if (sack->num_gap_ack_blocks &&
1069 primary->cacc.changeover_active) { 1069 primary->cacc.changeover_active) {
1070 list_for_each(pos, transport_list) { 1070 list_for_each(pos, transport_list) {
1071 transport = list_entry(pos, struct sctp_transport, 1071 transport = list_entry(pos, struct sctp_transport,
@@ -1632,7 +1632,7 @@ pass:
1632} 1632}
1633 1633
1634static inline int sctp_get_skip_pos(struct sctp_fwdtsn_skip *skiplist, 1634static inline int sctp_get_skip_pos(struct sctp_fwdtsn_skip *skiplist,
1635 int nskips, __u16 stream) 1635 int nskips, __be16 stream)
1636{ 1636{
1637 int i; 1637 int i;
1638 1638
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 7f49e769080e..b3493bdbcacb 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -160,7 +160,7 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo
160 160
161 list_for_each(pos, &epb->bind_addr.address_list) { 161 list_for_each(pos, &epb->bind_addr.address_list) {
162 laddr = list_entry(pos, struct sctp_sockaddr_entry, list); 162 laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
163 addr = (union sctp_addr *)&laddr->a; 163 addr = &laddr->a;
164 af = sctp_get_af_specific(addr->sa.sa_family); 164 af = sctp_get_af_specific(addr->sa.sa_family);
165 if (primary && af->cmp_addr(addr, primary)) { 165 if (primary && af->cmp_addr(addr, primary)) {
166 seq_printf(seq, "*"); 166 seq_printf(seq, "*");
@@ -177,10 +177,10 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa
177 union sctp_addr *addr, *primary; 177 union sctp_addr *addr, *primary;
178 struct sctp_af *af; 178 struct sctp_af *af;
179 179
180 primary = &(assoc->peer.primary_addr); 180 primary = &assoc->peer.primary_addr;
181 list_for_each(pos, &assoc->peer.transport_addr_list) { 181 list_for_each(pos, &assoc->peer.transport_addr_list) {
182 transport = list_entry(pos, struct sctp_transport, transports); 182 transport = list_entry(pos, struct sctp_transport, transports);
183 addr = (union sctp_addr *)&transport->ipaddr; 183 addr = &transport->ipaddr;
184 af = sctp_get_af_specific(addr->sa.sa_family); 184 af = sctp_get_af_specific(addr->sa.sa_family);
185 if (af->cmp_addr(addr, primary)) { 185 if (af->cmp_addr(addr, primary)) {
186 seq_printf(seq, "*"); 186 seq_printf(seq, "*");
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 5b4f82fd98f8..11f3b549f4a4 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -251,7 +251,7 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
251 int is_saddr) 251 int is_saddr)
252{ 252{
253 void *from; 253 void *from;
254 __u16 *port; 254 __be16 *port;
255 struct sctphdr *sh; 255 struct sctphdr *sh;
256 256
257 port = &addr->v4.sin_port; 257 port = &addr->v4.sin_port;
@@ -259,10 +259,10 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
259 259
260 sh = (struct sctphdr *) skb->h.raw; 260 sh = (struct sctphdr *) skb->h.raw;
261 if (is_saddr) { 261 if (is_saddr) {
262 *port = ntohs(sh->source); 262 *port = sh->source;
263 from = &skb->nh.iph->saddr; 263 from = &skb->nh.iph->saddr;
264 } else { 264 } else {
265 *port = ntohs(sh->dest); 265 *port = sh->dest;
266 from = &skb->nh.iph->daddr; 266 from = &skb->nh.iph->daddr;
267 } 267 }
268 memcpy(&addr->v4.sin_addr.s_addr, from, sizeof(struct in_addr)); 268 memcpy(&addr->v4.sin_addr.s_addr, from, sizeof(struct in_addr));
@@ -272,7 +272,7 @@ static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
272static void sctp_v4_from_sk(union sctp_addr *addr, struct sock *sk) 272static void sctp_v4_from_sk(union sctp_addr *addr, struct sock *sk)
273{ 273{
274 addr->v4.sin_family = AF_INET; 274 addr->v4.sin_family = AF_INET;
275 addr->v4.sin_port = inet_sk(sk)->num; 275 addr->v4.sin_port = 0;
276 addr->v4.sin_addr.s_addr = inet_sk(sk)->rcv_saddr; 276 addr->v4.sin_addr.s_addr = inet_sk(sk)->rcv_saddr;
277} 277}
278 278
@@ -291,7 +291,7 @@ static void sctp_v4_to_sk_daddr(union sctp_addr *addr, struct sock *sk)
291/* Initialize a sctp_addr from an address parameter. */ 291/* Initialize a sctp_addr from an address parameter. */
292static void sctp_v4_from_addr_param(union sctp_addr *addr, 292static void sctp_v4_from_addr_param(union sctp_addr *addr,
293 union sctp_addr_param *param, 293 union sctp_addr_param *param,
294 __u16 port, int iif) 294 __be16 port, int iif)
295{ 295{
296 addr->v4.sin_family = AF_INET; 296 addr->v4.sin_family = AF_INET;
297 addr->v4.sin_port = port; 297 addr->v4.sin_port = port;
@@ -307,7 +307,7 @@ static int sctp_v4_to_addr_param(const union sctp_addr *addr,
307 int length = sizeof(sctp_ipv4addr_param_t); 307 int length = sizeof(sctp_ipv4addr_param_t);
308 308
309 param->v4.param_hdr.type = SCTP_PARAM_IPV4_ADDRESS; 309 param->v4.param_hdr.type = SCTP_PARAM_IPV4_ADDRESS;
310 param->v4.param_hdr.length = ntohs(length); 310 param->v4.param_hdr.length = htons(length);
311 param->v4.addr.s_addr = addr->v4.sin_addr.s_addr; 311 param->v4.addr.s_addr = addr->v4.sin_addr.s_addr;
312 312
313 return length; 313 return length;
@@ -315,7 +315,7 @@ static int sctp_v4_to_addr_param(const union sctp_addr *addr,
315 315
316/* Initialize a sctp_addr from a dst_entry. */ 316/* Initialize a sctp_addr from a dst_entry. */
317static void sctp_v4_dst_saddr(union sctp_addr *saddr, struct dst_entry *dst, 317static void sctp_v4_dst_saddr(union sctp_addr *saddr, struct dst_entry *dst,
318 unsigned short port) 318 __be16 port)
319{ 319{
320 struct rtable *rt = (struct rtable *)dst; 320 struct rtable *rt = (struct rtable *)dst;
321 saddr->v4.sin_family = AF_INET; 321 saddr->v4.sin_family = AF_INET;
@@ -338,7 +338,7 @@ static int sctp_v4_cmp_addr(const union sctp_addr *addr1,
338} 338}
339 339
340/* Initialize addr struct to INADDR_ANY. */ 340/* Initialize addr struct to INADDR_ANY. */
341static void sctp_v4_inaddr_any(union sctp_addr *addr, unsigned short port) 341static void sctp_v4_inaddr_any(union sctp_addr *addr, __be16 port)
342{ 342{
343 addr->v4.sin_family = AF_INET; 343 addr->v4.sin_family = AF_INET;
344 addr->v4.sin_addr.s_addr = INADDR_ANY; 344 addr->v4.sin_addr.s_addr = INADDR_ANY;
@@ -481,7 +481,7 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
481 list); 481 list);
482 if (!laddr->use_as_src) 482 if (!laddr->use_as_src)
483 continue; 483 continue;
484 sctp_v4_dst_saddr(&dst_saddr, dst, bp->port); 484 sctp_v4_dst_saddr(&dst_saddr, dst, htons(bp->port));
485 if (sctp_v4_cmp_addr(&dst_saddr, &laddr->a)) 485 if (sctp_v4_cmp_addr(&dst_saddr, &laddr->a))
486 goto out_unlock; 486 goto out_unlock;
487 } 487 }
@@ -538,7 +538,7 @@ static void sctp_v4_get_saddr(struct sctp_association *asoc,
538 538
539 if (rt) { 539 if (rt) {
540 saddr->v4.sin_family = AF_INET; 540 saddr->v4.sin_family = AF_INET;
541 saddr->v4.sin_port = asoc->base.bind_addr.port; 541 saddr->v4.sin_port = htons(asoc->base.bind_addr.port);
542 saddr->v4.sin_addr.s_addr = rt->rt_src; 542 saddr->v4.sin_addr.s_addr = rt->rt_src;
543 } 543 }
544} 544}
@@ -791,7 +791,7 @@ static int sctp_inet_send_verify(struct sctp_sock *opt, union sctp_addr *addr)
791 * chunks. Returns number of addresses supported. 791 * chunks. Returns number of addresses supported.
792 */ 792 */
793static int sctp_inet_supported_addrs(const struct sctp_sock *opt, 793static int sctp_inet_supported_addrs(const struct sctp_sock *opt,
794 __u16 *types) 794 __be16 *types)
795{ 795{
796 types[0] = SCTP_PARAM_IPV4_ADDRESS; 796 types[0] = SCTP_PARAM_IPV4_ADDRESS;
797 return 1; 797 return 1;
@@ -808,7 +808,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
808 NIPQUAD(((struct rtable *)skb->dst)->rt_dst)); 808 NIPQUAD(((struct rtable *)skb->dst)->rt_dst));
809 809
810 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); 810 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS);
811 return ip_queue_xmit(skb, ipfragok); 811 return ip_queue_xmit(skb, skb->sk, ipfragok);
812} 812}
813 813
814static struct sctp_af sctp_ipv4_specific; 814static struct sctp_af sctp_ipv4_specific;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 507dff72c585..04954e5f6846 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -111,7 +111,7 @@ static const struct sctp_paramhdr prsctp_param = {
111 * provided chunk, as most cause codes will be embedded inside an 111 * provided chunk, as most cause codes will be embedded inside an
112 * abort chunk. 112 * abort chunk.
113 */ 113 */
114void sctp_init_cause(struct sctp_chunk *chunk, __u16 cause_code, 114void sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code,
115 const void *payload, size_t paylen) 115 const void *payload, size_t paylen)
116{ 116{
117 sctp_errhdr_t err; 117 sctp_errhdr_t err;
@@ -183,7 +183,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
183 int num_types, addrs_len = 0; 183 int num_types, addrs_len = 0;
184 struct sctp_sock *sp; 184 struct sctp_sock *sp;
185 sctp_supported_addrs_param_t sat; 185 sctp_supported_addrs_param_t sat;
186 __u16 types[2]; 186 __be16 types[2];
187 sctp_adaption_ind_param_t aiparam; 187 sctp_adaption_ind_param_t aiparam;
188 188
189 /* RFC 2960 3.3.2 Initiation (INIT) (1) 189 /* RFC 2960 3.3.2 Initiation (INIT) (1)
@@ -775,7 +775,7 @@ struct sctp_chunk *sctp_make_abort_no_data(
775 const struct sctp_chunk *chunk, __u32 tsn) 775 const struct sctp_chunk *chunk, __u32 tsn)
776{ 776{
777 struct sctp_chunk *retval; 777 struct sctp_chunk *retval;
778 __u32 payload; 778 __be32 payload;
779 779
780 retval = sctp_make_abort(asoc, chunk, sizeof(sctp_errhdr_t) 780 retval = sctp_make_abort(asoc, chunk, sizeof(sctp_errhdr_t)
781 + sizeof(tsn)); 781 + sizeof(tsn));
@@ -951,7 +951,7 @@ nodata:
951/* Create an Operation Error chunk. */ 951/* Create an Operation Error chunk. */
952struct sctp_chunk *sctp_make_op_error(const struct sctp_association *asoc, 952struct sctp_chunk *sctp_make_op_error(const struct sctp_association *asoc,
953 const struct sctp_chunk *chunk, 953 const struct sctp_chunk *chunk,
954 __u16 cause_code, const void *payload, 954 __be16 cause_code, const void *payload,
955 size_t paylen) 955 size_t paylen)
956{ 956{
957 struct sctp_chunk *retval; 957 struct sctp_chunk *retval;
@@ -1190,15 +1190,14 @@ void sctp_chunk_assign_ssn(struct sctp_chunk *chunk)
1190 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) { 1190 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) {
1191 ssn = 0; 1191 ssn = 0;
1192 } else { 1192 } else {
1193 sid = htons(chunk->subh.data_hdr->stream); 1193 sid = ntohs(chunk->subh.data_hdr->stream);
1194 if (chunk->chunk_hdr->flags & SCTP_DATA_LAST_FRAG) 1194 if (chunk->chunk_hdr->flags & SCTP_DATA_LAST_FRAG)
1195 ssn = sctp_ssn_next(&chunk->asoc->ssnmap->out, sid); 1195 ssn = sctp_ssn_next(&chunk->asoc->ssnmap->out, sid);
1196 else 1196 else
1197 ssn = sctp_ssn_peek(&chunk->asoc->ssnmap->out, sid); 1197 ssn = sctp_ssn_peek(&chunk->asoc->ssnmap->out, sid);
1198 ssn = htons(ssn);
1199 } 1198 }
1200 1199
1201 chunk->subh.data_hdr->ssn = ssn; 1200 chunk->subh.data_hdr->ssn = htons(ssn);
1202 chunk->has_ssn = 1; 1201 chunk->has_ssn = 1;
1203} 1202}
1204 1203
@@ -1280,15 +1279,13 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
1280 - (bodysize % SCTP_COOKIE_MULTIPLE); 1279 - (bodysize % SCTP_COOKIE_MULTIPLE);
1281 *cookie_len = headersize + bodysize; 1280 *cookie_len = headersize + bodysize;
1282 1281
1283 retval = kmalloc(*cookie_len, GFP_ATOMIC);
1284
1285 if (!retval)
1286 goto nodata;
1287
1288 /* Clear this memory since we are sending this data structure 1282 /* Clear this memory since we are sending this data structure
1289 * out on the network. 1283 * out on the network.
1290 */ 1284 */
1291 memset(retval, 0x00, *cookie_len); 1285 retval = kzalloc(*cookie_len, GFP_ATOMIC);
1286 if (!retval)
1287 goto nodata;
1288
1292 cookie = (struct sctp_signed_cookie *) retval->body; 1289 cookie = (struct sctp_signed_cookie *) retval->body;
1293 1290
1294 /* Set up the parameter header. */ 1291 /* Set up the parameter header. */
@@ -1438,7 +1435,7 @@ no_hmac:
1438 goto fail; 1435 goto fail;
1439 } 1436 }
1440 1437
1441 if (ntohs(chunk->sctp_hdr->source) != bear_cookie->peer_addr.v4.sin_port || 1438 if (chunk->sctp_hdr->source != bear_cookie->peer_addr.v4.sin_port ||
1442 ntohs(chunk->sctp_hdr->dest) != bear_cookie->my_port) { 1439 ntohs(chunk->sctp_hdr->dest) != bear_cookie->my_port) {
1443 *error = -SCTP_IERROR_BAD_PORTS; 1440 *error = -SCTP_IERROR_BAD_PORTS;
1444 goto fail; 1441 goto fail;
@@ -1473,10 +1470,10 @@ no_hmac:
1473 suseconds_t usecs = (tv.tv_sec - 1470 suseconds_t usecs = (tv.tv_sec -
1474 bear_cookie->expiration.tv_sec) * 1000000L + 1471 bear_cookie->expiration.tv_sec) * 1000000L +
1475 tv.tv_usec - bear_cookie->expiration.tv_usec; 1472 tv.tv_usec - bear_cookie->expiration.tv_usec;
1473 __be32 n = htonl(usecs);
1476 1474
1477 usecs = htonl(usecs);
1478 sctp_init_cause(*errp, SCTP_ERROR_STALE_COOKIE, 1475 sctp_init_cause(*errp, SCTP_ERROR_STALE_COOKIE,
1479 &usecs, sizeof(usecs)); 1476 &n, sizeof(n));
1480 *error = -SCTP_IERROR_STALE_COOKIE; 1477 *error = -SCTP_IERROR_STALE_COOKIE;
1481 } else 1478 } else
1482 *error = -SCTP_IERROR_NOMEM; 1479 *error = -SCTP_IERROR_NOMEM;
@@ -1539,8 +1536,8 @@ malformed:
1539 ********************************************************************/ 1536 ********************************************************************/
1540 1537
1541struct __sctp_missing { 1538struct __sctp_missing {
1542 __u32 num_missing; 1539 __be32 num_missing;
1543 __u16 type; 1540 __be16 type;
1544} __attribute__((packed)); 1541} __attribute__((packed));
1545 1542
1546/* 1543/*
@@ -1852,9 +1849,10 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
1852 * added as the primary transport. The source address seems to 1849 * added as the primary transport. The source address seems to
1853 * be a a better choice than any of the embedded addresses. 1850 * be a a better choice than any of the embedded addresses.
1854 */ 1851 */
1855 if (peer_addr) 1852 if (peer_addr) {
1856 if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE)) 1853 if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
1857 goto nomem; 1854 goto nomem;
1855 }
1858 1856
1859 /* Process the initialization parameters. */ 1857 /* Process the initialization parameters. */
1860 1858
@@ -1910,10 +1908,9 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
1910 /* Copy cookie in case we need to resend COOKIE-ECHO. */ 1908 /* Copy cookie in case we need to resend COOKIE-ECHO. */
1911 cookie = asoc->peer.cookie; 1909 cookie = asoc->peer.cookie;
1912 if (cookie) { 1910 if (cookie) {
1913 asoc->peer.cookie = kmalloc(asoc->peer.cookie_len, gfp); 1911 asoc->peer.cookie = kmemdup(cookie, asoc->peer.cookie_len, gfp);
1914 if (!asoc->peer.cookie) 1912 if (!asoc->peer.cookie)
1915 goto clean_up; 1913 goto clean_up;
1916 memcpy(asoc->peer.cookie, cookie, asoc->peer.cookie_len);
1917 } 1914 }
1918 1915
1919 /* RFC 2960 7.2.1 The initial value of ssthresh MAY be arbitrarily 1916 /* RFC 2960 7.2.1 The initial value of ssthresh MAY be arbitrarily
@@ -2027,7 +2024,7 @@ static int sctp_process_param(struct sctp_association *asoc,
2027 /* Fall through. */ 2024 /* Fall through. */
2028 case SCTP_PARAM_IPV4_ADDRESS: 2025 case SCTP_PARAM_IPV4_ADDRESS:
2029 af = sctp_get_af_specific(param_type2af(param.p->type)); 2026 af = sctp_get_af_specific(param_type2af(param.p->type));
2030 af->from_addr_param(&addr, param.addr, asoc->peer.port, 0); 2027 af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0);
2031 scope = sctp_scope(peer_addr); 2028 scope = sctp_scope(peer_addr);
2032 if (sctp_in_scope(&addr, scope)) 2029 if (sctp_in_scope(&addr, scope))
2033 if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED)) 2030 if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))
@@ -2230,7 +2227,7 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
2230 union sctp_addr *laddr, 2227 union sctp_addr *laddr,
2231 struct sockaddr *addrs, 2228 struct sockaddr *addrs,
2232 int addrcnt, 2229 int addrcnt,
2233 __u16 flags) 2230 __be16 flags)
2234{ 2231{
2235 sctp_addip_param_t param; 2232 sctp_addip_param_t param;
2236 struct sctp_chunk *retval; 2233 struct sctp_chunk *retval;
@@ -2363,14 +2360,14 @@ static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *as
2363} 2360}
2364 2361
2365/* Add response parameters to an ASCONF_ACK chunk. */ 2362/* Add response parameters to an ASCONF_ACK chunk. */
2366static void sctp_add_asconf_response(struct sctp_chunk *chunk, __u32 crr_id, 2363static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id,
2367 __u16 err_code, sctp_addip_param_t *asconf_param) 2364 __be16 err_code, sctp_addip_param_t *asconf_param)
2368{ 2365{
2369 sctp_addip_param_t ack_param; 2366 sctp_addip_param_t ack_param;
2370 sctp_errhdr_t err_param; 2367 sctp_errhdr_t err_param;
2371 int asconf_param_len = 0; 2368 int asconf_param_len = 0;
2372 int err_param_len = 0; 2369 int err_param_len = 0;
2373 __u16 response_type; 2370 __be16 response_type;
2374 2371
2375 if (SCTP_ERROR_NO_ERROR == err_code) { 2372 if (SCTP_ERROR_NO_ERROR == err_code) {
2376 response_type = SCTP_PARAM_SUCCESS_REPORT; 2373 response_type = SCTP_PARAM_SUCCESS_REPORT;
@@ -2404,7 +2401,7 @@ static void sctp_add_asconf_response(struct sctp_chunk *chunk, __u32 crr_id,
2404} 2401}
2405 2402
2406/* Process a asconf parameter. */ 2403/* Process a asconf parameter. */
2407static __u16 sctp_process_asconf_param(struct sctp_association *asoc, 2404static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
2408 struct sctp_chunk *asconf, 2405 struct sctp_chunk *asconf,
2409 sctp_addip_param_t *asconf_param) 2406 sctp_addip_param_t *asconf_param)
2410{ 2407{
@@ -2413,7 +2410,7 @@ static __u16 sctp_process_asconf_param(struct sctp_association *asoc,
2413 union sctp_addr addr; 2410 union sctp_addr addr;
2414 struct list_head *pos; 2411 struct list_head *pos;
2415 union sctp_addr_param *addr_param; 2412 union sctp_addr_param *addr_param;
2416 2413
2417 addr_param = (union sctp_addr_param *) 2414 addr_param = (union sctp_addr_param *)
2418 ((void *)asconf_param + sizeof(sctp_addip_param_t)); 2415 ((void *)asconf_param + sizeof(sctp_addip_param_t));
2419 2416
@@ -2421,7 +2418,7 @@ static __u16 sctp_process_asconf_param(struct sctp_association *asoc,
2421 if (unlikely(!af)) 2418 if (unlikely(!af))
2422 return SCTP_ERROR_INV_PARAM; 2419 return SCTP_ERROR_INV_PARAM;
2423 2420
2424 af->from_addr_param(&addr, addr_param, asoc->peer.port, 0); 2421 af->from_addr_param(&addr, addr_param, htons(asoc->peer.port), 0);
2425 switch (asconf_param->param_hdr.type) { 2422 switch (asconf_param->param_hdr.type) {
2426 case SCTP_PARAM_ADD_IP: 2423 case SCTP_PARAM_ADD_IP:
2427 /* ADDIP 4.3 D9) If an endpoint receives an ADD IP address 2424 /* ADDIP 4.3 D9) If an endpoint receives an ADD IP address
@@ -2487,7 +2484,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
2487 sctp_addip_param_t *asconf_param; 2484 sctp_addip_param_t *asconf_param;
2488 struct sctp_chunk *asconf_ack; 2485 struct sctp_chunk *asconf_ack;
2489 2486
2490 __u16 err_code; 2487 __be16 err_code;
2491 int length = 0; 2488 int length = 0;
2492 int chunk_len = asconf->skb->len; 2489 int chunk_len = asconf->skb->len;
2493 __u32 serial; 2490 __u32 serial;
@@ -2586,7 +2583,7 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
2586 2583
2587 /* We have checked the packet before, so we do not check again. */ 2584 /* We have checked the packet before, so we do not check again. */
2588 af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type)); 2585 af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type));
2589 af->from_addr_param(&addr, addr_param, bp->port, 0); 2586 af->from_addr_param(&addr, addr_param, htons(bp->port), 0);
2590 2587
2591 switch (asconf_param->param_hdr.type) { 2588 switch (asconf_param->param_hdr.type) {
2592 case SCTP_PARAM_ADD_IP: 2589 case SCTP_PARAM_ADD_IP:
@@ -2630,7 +2627,7 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
2630 * All TLVs after the failed response are considered unsuccessful unless a 2627 * All TLVs after the failed response are considered unsuccessful unless a
2631 * specific success indication is present for the parameter. 2628 * specific success indication is present for the parameter.
2632 */ 2629 */
2633static __u16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack, 2630static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
2634 sctp_addip_param_t *asconf_param, 2631 sctp_addip_param_t *asconf_param,
2635 int no_err) 2632 int no_err)
2636{ 2633{
@@ -2638,7 +2635,7 @@ static __u16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
2638 sctp_errhdr_t *err_param; 2635 sctp_errhdr_t *err_param;
2639 int length; 2636 int length;
2640 int asconf_ack_len = asconf_ack->skb->len; 2637 int asconf_ack_len = asconf_ack->skb->len;
2641 __u16 err_code; 2638 __be16 err_code;
2642 2639
2643 if (no_err) 2640 if (no_err)
2644 err_code = SCTP_ERROR_NO_ERROR; 2641 err_code = SCTP_ERROR_NO_ERROR;
@@ -2694,7 +2691,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
2694 int all_param_pass = 0; 2691 int all_param_pass = 0;
2695 int no_err = 1; 2692 int no_err = 1;
2696 int retval = 0; 2693 int retval = 0;
2697 __u16 err_code = SCTP_ERROR_NO_ERROR; 2694 __be16 err_code = SCTP_ERROR_NO_ERROR;
2698 2695
2699 /* Skip the chunkhdr and addiphdr from the last asconf sent and store 2696 /* Skip the chunkhdr and addiphdr from the last asconf sent and store
2700 * a pointer to address parameter. 2697 * a pointer to address parameter.
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 9c10bdec1afe..7bbc6156e455 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -442,7 +442,7 @@ static void sctp_do_8_2_transport_strike(struct sctp_association *asoc,
442 " transport IP: port:%d failed.\n", 442 " transport IP: port:%d failed.\n",
443 asoc, 443 asoc,
444 (&transport->ipaddr), 444 (&transport->ipaddr),
445 transport->ipaddr.v4.sin_port); 445 ntohs(transport->ipaddr.v4.sin_port));
446 sctp_assoc_control_transport(asoc, transport, 446 sctp_assoc_control_transport(asoc, transport,
447 SCTP_TRANSPORT_DOWN, 447 SCTP_TRANSPORT_DOWN,
448 SCTP_FAILED_THRESHOLD); 448 SCTP_FAILED_THRESHOLD);
@@ -1360,12 +1360,12 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1360 break; 1360 break;
1361 1361
1362 case SCTP_CMD_INIT_FAILED: 1362 case SCTP_CMD_INIT_FAILED:
1363 sctp_cmd_init_failed(commands, asoc, cmd->obj.u32); 1363 sctp_cmd_init_failed(commands, asoc, cmd->obj.err);
1364 break; 1364 break;
1365 1365
1366 case SCTP_CMD_ASSOC_FAILED: 1366 case SCTP_CMD_ASSOC_FAILED:
1367 sctp_cmd_assoc_failed(commands, asoc, event_type, 1367 sctp_cmd_assoc_failed(commands, asoc, event_type,
1368 subtype, chunk, cmd->obj.u32); 1368 subtype, chunk, cmd->obj.err);
1369 break; 1369 break;
1370 1370
1371 case SCTP_CMD_INIT_COUNTER_INC: 1371 case SCTP_CMD_INIT_COUNTER_INC:
@@ -1420,7 +1420,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1420 1420
1421 case SCTP_CMD_PROCESS_CTSN: 1421 case SCTP_CMD_PROCESS_CTSN:
1422 /* Dummy up a SACK for processing. */ 1422 /* Dummy up a SACK for processing. */
1423 sackh.cum_tsn_ack = cmd->obj.u32; 1423 sackh.cum_tsn_ack = cmd->obj.be32;
1424 sackh.a_rwnd = 0; 1424 sackh.a_rwnd = 0;
1425 sackh.num_gap_ack_blocks = 0; 1425 sackh.num_gap_ack_blocks = 0;
1426 sackh.num_dup_tsns = 0; 1426 sackh.num_dup_tsns = 0;
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 1c42fe983a5b..27cc444aaf11 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -93,7 +93,7 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep,
93static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk); 93static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk);
94 94
95static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, 95static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
96 __u16 error, int sk_err, 96 __be16 error, int sk_err,
97 const struct sctp_association *asoc, 97 const struct sctp_association *asoc,
98 struct sctp_transport *transport); 98 struct sctp_transport *transport);
99 99
@@ -443,7 +443,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep,
443 __u32 init_tag; 443 __u32 init_tag;
444 struct sctp_chunk *err_chunk; 444 struct sctp_chunk *err_chunk;
445 struct sctp_packet *packet; 445 struct sctp_packet *packet;
446 __u16 error; 446 sctp_error_t error;
447 447
448 if (!sctp_vtag_verify(chunk, asoc)) 448 if (!sctp_vtag_verify(chunk, asoc))
449 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 449 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -886,7 +886,7 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep,
886 SCTP_ERROR(ETIMEDOUT)); 886 SCTP_ERROR(ETIMEDOUT));
887 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 887 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
888 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 888 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
889 SCTP_U32(SCTP_ERROR_NO_ERROR)); 889 SCTP_PERR(SCTP_ERROR_NO_ERROR));
890 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 890 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
891 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 891 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
892 return SCTP_DISPOSITION_DELETE_TCB; 892 return SCTP_DISPOSITION_DELETE_TCB;
@@ -2138,7 +2138,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep,
2138 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 2138 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
2139 SCTP_ERROR(ETIMEDOUT)); 2139 SCTP_ERROR(ETIMEDOUT));
2140 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 2140 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
2141 SCTP_U32(SCTP_ERROR_STALE_COOKIE)); 2141 SCTP_PERR(SCTP_ERROR_STALE_COOKIE));
2142 return SCTP_DISPOSITION_DELETE_TCB; 2142 return SCTP_DISPOSITION_DELETE_TCB;
2143 } 2143 }
2144 2144
@@ -2158,7 +2158,7 @@ static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep,
2158 * to give ample time to retransmit the new cookie and thus 2158 * to give ample time to retransmit the new cookie and thus
2159 * yield a higher probability of success on the reattempt. 2159 * yield a higher probability of success on the reattempt.
2160 */ 2160 */
2161 stale = ntohl(*(suseconds_t *)((u8 *)err + sizeof(sctp_errhdr_t))); 2161 stale = ntohl(*(__be32 *)((u8 *)err + sizeof(sctp_errhdr_t)));
2162 stale = (stale * 2) / 1000; 2162 stale = (stale * 2) / 1000;
2163 2163
2164 bht.param_hdr.type = SCTP_PARAM_COOKIE_PRESERVATIVE; 2164 bht.param_hdr.type = SCTP_PARAM_COOKIE_PRESERVATIVE;
@@ -2250,7 +2250,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,
2250{ 2250{
2251 struct sctp_chunk *chunk = arg; 2251 struct sctp_chunk *chunk = arg;
2252 unsigned len; 2252 unsigned len;
2253 __u16 error = SCTP_ERROR_NO_ERROR; 2253 __be16 error = SCTP_ERROR_NO_ERROR;
2254 2254
2255 if (!sctp_vtag_verify_either(chunk, asoc)) 2255 if (!sctp_vtag_verify_either(chunk, asoc))
2256 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 2256 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -2275,7 +2275,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,
2275 2275
2276 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET)); 2276 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET));
2277 /* ASSOC_FAILED will DELETE_TCB. */ 2277 /* ASSOC_FAILED will DELETE_TCB. */
2278 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_U32(error)); 2278 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error));
2279 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 2279 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
2280 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 2280 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
2281 2281
@@ -2295,7 +2295,7 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep,
2295{ 2295{
2296 struct sctp_chunk *chunk = arg; 2296 struct sctp_chunk *chunk = arg;
2297 unsigned len; 2297 unsigned len;
2298 __u16 error = SCTP_ERROR_NO_ERROR; 2298 __be16 error = SCTP_ERROR_NO_ERROR;
2299 2299
2300 if (!sctp_vtag_verify_either(chunk, asoc)) 2300 if (!sctp_vtag_verify_either(chunk, asoc))
2301 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 2301 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -2357,7 +2357,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep,
2357 * This is common code called by several sctp_sf_*_abort() functions above. 2357 * This is common code called by several sctp_sf_*_abort() functions above.
2358 */ 2358 */
2359static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, 2359static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
2360 __u16 error, int sk_err, 2360 __be16 error, int sk_err,
2361 const struct sctp_association *asoc, 2361 const struct sctp_association *asoc,
2362 struct sctp_transport *transport) 2362 struct sctp_transport *transport)
2363{ 2363{
@@ -2370,7 +2370,7 @@ static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
2370 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err)); 2370 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err));
2371 /* CMD_INIT_FAILED will DELETE_TCB. */ 2371 /* CMD_INIT_FAILED will DELETE_TCB. */
2372 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 2372 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
2373 SCTP_U32(error)); 2373 SCTP_PERR(error));
2374 return SCTP_DISPOSITION_ABORT; 2374 return SCTP_DISPOSITION_ABORT;
2375} 2375}
2376 2376
@@ -2466,7 +2466,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep,
2466 * received by the SHUTDOWN sender. 2466 * received by the SHUTDOWN sender.
2467 */ 2467 */
2468 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN, 2468 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN,
2469 SCTP_U32(chunk->subh.shutdown_hdr->cum_tsn_ack)); 2469 SCTP_BE32(chunk->subh.shutdown_hdr->cum_tsn_ack));
2470 2470
2471out: 2471out:
2472 return disposition; 2472 return disposition;
@@ -2545,6 +2545,7 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep,
2545{ 2545{
2546 sctp_cwrhdr_t *cwr; 2546 sctp_cwrhdr_t *cwr;
2547 struct sctp_chunk *chunk = arg; 2547 struct sctp_chunk *chunk = arg;
2548 u32 lowest_tsn;
2548 2549
2549 if (!sctp_vtag_verify(chunk, asoc)) 2550 if (!sctp_vtag_verify(chunk, asoc))
2550 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 2551 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -2556,14 +2557,14 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep,
2556 cwr = (sctp_cwrhdr_t *) chunk->skb->data; 2557 cwr = (sctp_cwrhdr_t *) chunk->skb->data;
2557 skb_pull(chunk->skb, sizeof(sctp_cwrhdr_t)); 2558 skb_pull(chunk->skb, sizeof(sctp_cwrhdr_t));
2558 2559
2559 cwr->lowest_tsn = ntohl(cwr->lowest_tsn); 2560 lowest_tsn = ntohl(cwr->lowest_tsn);
2560 2561
2561 /* Does this CWR ack the last sent congestion notification? */ 2562 /* Does this CWR ack the last sent congestion notification? */
2562 if (TSN_lte(asoc->last_ecne_tsn, cwr->lowest_tsn)) { 2563 if (TSN_lte(asoc->last_ecne_tsn, lowest_tsn)) {
2563 /* Stop sending ECNE. */ 2564 /* Stop sending ECNE. */
2564 sctp_add_cmd_sf(commands, 2565 sctp_add_cmd_sf(commands,
2565 SCTP_CMD_ECN_CWR, 2566 SCTP_CMD_ECN_CWR,
2566 SCTP_U32(cwr->lowest_tsn)); 2567 SCTP_U32(lowest_tsn));
2567 } 2568 }
2568 return SCTP_DISPOSITION_CONSUME; 2569 return SCTP_DISPOSITION_CONSUME;
2569} 2570}
@@ -3360,7 +3361,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
3360 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 3361 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
3361 SCTP_ERROR(ECONNABORTED)); 3362 SCTP_ERROR(ECONNABORTED));
3362 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 3363 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
3363 SCTP_U32(SCTP_ERROR_ASCONF_ACK)); 3364 SCTP_PERR(SCTP_ERROR_ASCONF_ACK));
3364 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 3365 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
3365 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 3366 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
3366 return SCTP_DISPOSITION_ABORT; 3367 return SCTP_DISPOSITION_ABORT;
@@ -3388,7 +3389,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
3388 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 3389 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
3389 SCTP_ERROR(ECONNABORTED)); 3390 SCTP_ERROR(ECONNABORTED));
3390 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 3391 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
3391 SCTP_U32(SCTP_ERROR_ASCONF_ACK)); 3392 SCTP_PERR(SCTP_ERROR_ASCONF_ACK));
3392 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 3393 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
3393 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 3394 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
3394 return SCTP_DISPOSITION_ABORT; 3395 return SCTP_DISPOSITION_ABORT;
@@ -3743,12 +3744,12 @@ static sctp_disposition_t sctp_sf_violation_chunklen(
3743 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 3744 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
3744 SCTP_ERROR(ECONNREFUSED)); 3745 SCTP_ERROR(ECONNREFUSED));
3745 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 3746 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
3746 SCTP_U32(SCTP_ERROR_PROTO_VIOLATION)); 3747 SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION));
3747 } else { 3748 } else {
3748 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 3749 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
3749 SCTP_ERROR(ECONNABORTED)); 3750 SCTP_ERROR(ECONNABORTED));
3750 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 3751 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
3751 SCTP_U32(SCTP_ERROR_PROTO_VIOLATION)); 3752 SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION));
3752 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 3753 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
3753 } 3754 }
3754 3755
@@ -4062,7 +4063,7 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort(
4062 SCTP_ERROR(ECONNABORTED)); 4063 SCTP_ERROR(ECONNABORTED));
4063 /* Delete the established association. */ 4064 /* Delete the established association. */
4064 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4065 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4065 SCTP_U32(SCTP_ERROR_USER_ABORT)); 4066 SCTP_PERR(SCTP_ERROR_USER_ABORT));
4066 4067
4067 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4068 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
4068 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 4069 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
@@ -4199,7 +4200,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort(
4199 SCTP_ERROR(ECONNREFUSED)); 4200 SCTP_ERROR(ECONNREFUSED));
4200 /* Delete the established association. */ 4201 /* Delete the established association. */
4201 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 4202 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
4202 SCTP_U32(SCTP_ERROR_USER_ABORT)); 4203 SCTP_PERR(SCTP_ERROR_USER_ABORT));
4203 4204
4204 return retval; 4205 return retval;
4205} 4206}
@@ -4571,7 +4572,7 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep,
4571 SCTP_ERROR(ETIMEDOUT)); 4572 SCTP_ERROR(ETIMEDOUT));
4572 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 4573 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
4573 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4574 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4574 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4575 SCTP_PERR(SCTP_ERROR_NO_ERROR));
4575 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4576 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
4576 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 4577 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
4577 return SCTP_DISPOSITION_DELETE_TCB; 4578 return SCTP_DISPOSITION_DELETE_TCB;
@@ -4693,7 +4694,7 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep,
4693 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 4694 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4694 SCTP_ERROR(ETIMEDOUT)); 4695 SCTP_ERROR(ETIMEDOUT));
4695 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 4696 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
4696 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4697 SCTP_PERR(SCTP_ERROR_NO_ERROR));
4697 return SCTP_DISPOSITION_DELETE_TCB; 4698 return SCTP_DISPOSITION_DELETE_TCB;
4698 } 4699 }
4699 4700
@@ -4745,7 +4746,7 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep
4745 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 4746 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4746 SCTP_ERROR(ETIMEDOUT)); 4747 SCTP_ERROR(ETIMEDOUT));
4747 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED, 4748 sctp_add_cmd_sf(commands, SCTP_CMD_INIT_FAILED,
4748 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4749 SCTP_PERR(SCTP_ERROR_NO_ERROR));
4749 return SCTP_DISPOSITION_DELETE_TCB; 4750 return SCTP_DISPOSITION_DELETE_TCB;
4750 } 4751 }
4751 4752
@@ -4781,7 +4782,7 @@ sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep,
4781 SCTP_ERROR(ETIMEDOUT)); 4782 SCTP_ERROR(ETIMEDOUT));
4782 /* Note: CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 4783 /* Note: CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
4783 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4784 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4784 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4785 SCTP_PERR(SCTP_ERROR_NO_ERROR));
4785 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4786 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
4786 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 4787 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
4787 return SCTP_DISPOSITION_DELETE_TCB; 4788 return SCTP_DISPOSITION_DELETE_TCB;
@@ -4859,7 +4860,7 @@ sctp_disposition_t sctp_sf_t4_timer_expire(
4859 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 4860 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4860 SCTP_ERROR(ETIMEDOUT)); 4861 SCTP_ERROR(ETIMEDOUT));
4861 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4862 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4862 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4863 SCTP_PERR(SCTP_ERROR_NO_ERROR));
4863 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4864 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
4864 SCTP_INC_STATS(SCTP_MIB_CURRESTAB); 4865 SCTP_INC_STATS(SCTP_MIB_CURRESTAB);
4865 return SCTP_DISPOSITION_ABORT; 4866 return SCTP_DISPOSITION_ABORT;
@@ -4915,7 +4916,7 @@ sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep,
4915 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 4916 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4916 SCTP_ERROR(ETIMEDOUT)); 4917 SCTP_ERROR(ETIMEDOUT));
4917 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4918 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4918 SCTP_U32(SCTP_ERROR_NO_ERROR)); 4919 SCTP_PERR(SCTP_ERROR_NO_ERROR));
4919 4920
4920 return SCTP_DISPOSITION_DELETE_TCB; 4921 return SCTP_DISPOSITION_DELETE_TCB;
4921nomem: 4922nomem:
@@ -5365,7 +5366,7 @@ static int sctp_eat_data(const struct sctp_association *asoc,
5365 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 5366 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
5366 SCTP_ERROR(ECONNABORTED)); 5367 SCTP_ERROR(ECONNABORTED));
5367 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 5368 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
5368 SCTP_U32(SCTP_ERROR_NO_DATA)); 5369 SCTP_PERR(SCTP_ERROR_NO_DATA));
5369 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 5370 SCTP_INC_STATS(SCTP_MIB_ABORTEDS);
5370 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 5371 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB);
5371 return SCTP_IERROR_NO_DATA; 5372 return SCTP_IERROR_NO_DATA;
diff --git a/net/sctp/sm_statetable.c b/net/sctp/sm_statetable.c
index 8bcca5676151..733dd87b3a7d 100644
--- a/net/sctp/sm_statetable.c
+++ b/net/sctp/sm_statetable.c
@@ -104,325 +104,322 @@ const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type,
104 }; 104 };
105} 105}
106 106
107#define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}
108
107#define TYPE_SCTP_DATA { \ 109#define TYPE_SCTP_DATA { \
108 /* SCTP_STATE_EMPTY */ \ 110 /* SCTP_STATE_EMPTY */ \
109 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 111 TYPE_SCTP_FUNC(sctp_sf_ootb), \
110 /* SCTP_STATE_CLOSED */ \ 112 /* SCTP_STATE_CLOSED */ \
111 {.fn = sctp_sf_tabort_8_4_8, .name = "sctp_sf_tabort_8_4_8"}, \ 113 TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
112 /* SCTP_STATE_COOKIE_WAIT */ \ 114 /* SCTP_STATE_COOKIE_WAIT */ \
113 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 115 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
114 /* SCTP_STATE_COOKIE_ECHOED */ \ 116 /* SCTP_STATE_COOKIE_ECHOED */ \
115 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 117 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
116 /* SCTP_STATE_ESTABLISHED */ \ 118 /* SCTP_STATE_ESTABLISHED */ \
117 {.fn = sctp_sf_eat_data_6_2, .name = "sctp_sf_eat_data_6_2"}, \ 119 TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
118 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 120 /* SCTP_STATE_SHUTDOWN_PENDING */ \
119 {.fn = sctp_sf_eat_data_6_2, .name = "sctp_sf_eat_data_6_2"}, \ 121 TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
120 /* SCTP_STATE_SHUTDOWN_SENT */ \ 122 /* SCTP_STATE_SHUTDOWN_SENT */ \
121 {.fn = sctp_sf_eat_data_fast_4_4, .name = "sctp_sf_eat_data_fast_4_4"}, \ 123 TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
122 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 124 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
123 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 125 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
124 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 126 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
125 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 127 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
126} /* TYPE_SCTP_DATA */ 128} /* TYPE_SCTP_DATA */
127 129
128#define TYPE_SCTP_INIT { \ 130#define TYPE_SCTP_INIT { \
129 /* SCTP_STATE_EMPTY */ \ 131 /* SCTP_STATE_EMPTY */ \
130 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 132 TYPE_SCTP_FUNC(sctp_sf_bug), \
131 /* SCTP_STATE_CLOSED */ \ 133 /* SCTP_STATE_CLOSED */ \
132 {.fn = sctp_sf_do_5_1B_init, .name = "sctp_sf_do_5_1B_init"}, \ 134 TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
133 /* SCTP_STATE_COOKIE_WAIT */ \ 135 /* SCTP_STATE_COOKIE_WAIT */ \
134 {.fn = sctp_sf_do_5_2_1_siminit, .name = "sctp_sf_do_5_2_1_siminit"}, \ 136 TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
135 /* SCTP_STATE_COOKIE_ECHOED */ \ 137 /* SCTP_STATE_COOKIE_ECHOED */ \
136 {.fn = sctp_sf_do_5_2_1_siminit, .name = "sctp_sf_do_5_2_1_siminit"}, \ 138 TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
137 /* SCTP_STATE_ESTABLISHED */ \ 139 /* SCTP_STATE_ESTABLISHED */ \
138 {.fn = sctp_sf_do_5_2_2_dupinit, .name = "sctp_sf_do_5_2_2_dupinit"}, \ 140 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
139 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 141 /* SCTP_STATE_SHUTDOWN_PENDING */ \
140 {.fn = sctp_sf_do_5_2_2_dupinit, .name = "sctp_sf_do_5_2_2_dupinit"}, \ 142 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
141 /* SCTP_STATE_SHUTDOWN_SENT */ \ 143 /* SCTP_STATE_SHUTDOWN_SENT */ \
142 {.fn = sctp_sf_do_5_2_2_dupinit, .name = "sctp_sf_do_5_2_2_dupinit"}, \ 144 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
143 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 145 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
144 {.fn = sctp_sf_do_5_2_2_dupinit, .name = "sctp_sf_do_5_2_2_dupinit"}, \ 146 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
145 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 147 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
146 {.fn = sctp_sf_do_9_2_reshutack, .name = "sctp_sf_do_9_2_reshutack"}, \ 148 TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
147} /* TYPE_SCTP_INIT */ 149} /* TYPE_SCTP_INIT */
148 150
149#define TYPE_SCTP_INIT_ACK { \ 151#define TYPE_SCTP_INIT_ACK { \
150 /* SCTP_STATE_EMPTY */ \ 152 /* SCTP_STATE_EMPTY */ \
151 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 153 TYPE_SCTP_FUNC(sctp_sf_ootb), \
152 /* SCTP_STATE_CLOSED */ \ 154 /* SCTP_STATE_CLOSED */ \
153 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 155 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
154 /* SCTP_STATE_COOKIE_WAIT */ \ 156 /* SCTP_STATE_COOKIE_WAIT */ \
155 {.fn = sctp_sf_do_5_1C_ack, .name = "sctp_sf_do_5_1C_ack"}, \ 157 TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
156 /* SCTP_STATE_COOKIE_ECHOED */ \ 158 /* SCTP_STATE_COOKIE_ECHOED */ \
157 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 159 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
158 /* SCTP_STATE_ESTABLISHED */ \ 160 /* SCTP_STATE_ESTABLISHED */ \
159 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 161 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
160 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 162 /* SCTP_STATE_SHUTDOWN_PENDING */ \
161 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 163 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
162 /* SCTP_STATE_SHUTDOWN_SENT */ \ 164 /* SCTP_STATE_SHUTDOWN_SENT */ \
163 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 165 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
164 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 166 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
165 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 167 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
166 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 168 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
167 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 169 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
168} /* TYPE_SCTP_INIT_ACK */ 170} /* TYPE_SCTP_INIT_ACK */
169 171
170#define TYPE_SCTP_SACK { \ 172#define TYPE_SCTP_SACK { \
171 /* SCTP_STATE_EMPTY */ \ 173 /* SCTP_STATE_EMPTY */ \
172 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 174 TYPE_SCTP_FUNC(sctp_sf_ootb), \
173 /* SCTP_STATE_CLOSED */ \ 175 /* SCTP_STATE_CLOSED */ \
174 {.fn = sctp_sf_tabort_8_4_8, .name = "sctp_sf_tabort_8_4_8"}, \ 176 TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
175 /* SCTP_STATE_COOKIE_WAIT */ \ 177 /* SCTP_STATE_COOKIE_WAIT */ \
176 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 178 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
177 /* SCTP_STATE_COOKIE_ECHOED */ \ 179 /* SCTP_STATE_COOKIE_ECHOED */ \
178 {.fn = sctp_sf_eat_sack_6_2, .name = "sctp_sf_eat_sack_6_2"}, \ 180 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
179 /* SCTP_STATE_ESTABLISHED */ \ 181 /* SCTP_STATE_ESTABLISHED */ \
180 {.fn = sctp_sf_eat_sack_6_2, .name = "sctp_sf_eat_sack_6_2"}, \ 182 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
181 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 183 /* SCTP_STATE_SHUTDOWN_PENDING */ \
182 {.fn = sctp_sf_eat_sack_6_2, .name = "sctp_sf_eat_sack_6_2"}, \ 184 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
183 /* SCTP_STATE_SHUTDOWN_SENT */ \ 185 /* SCTP_STATE_SHUTDOWN_SENT */ \
184 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 186 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
185 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 187 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
186 {.fn = sctp_sf_eat_sack_6_2, .name = "sctp_sf_eat_sack_6_2"}, \ 188 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
187 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 189 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
188 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 190 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
189} /* TYPE_SCTP_SACK */ 191} /* TYPE_SCTP_SACK */
190 192
191#define TYPE_SCTP_HEARTBEAT { \ 193#define TYPE_SCTP_HEARTBEAT { \
192 /* SCTP_STATE_EMPTY */ \ 194 /* SCTP_STATE_EMPTY */ \
193 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 195 TYPE_SCTP_FUNC(sctp_sf_ootb), \
194 /* SCTP_STATE_CLOSED */ \ 196 /* SCTP_STATE_CLOSED */ \
195 {.fn = sctp_sf_tabort_8_4_8, .name = "sctp_sf_tabort_8_4_8"}, \ 197 TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
196 /* SCTP_STATE_COOKIE_WAIT */ \ 198 /* SCTP_STATE_COOKIE_WAIT */ \
197 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 199 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
198 /* SCTP_STATE_COOKIE_ECHOED */ \ 200 /* SCTP_STATE_COOKIE_ECHOED */ \
199 {.fn = sctp_sf_beat_8_3, .name = "sctp_sf_beat_8_3"}, \ 201 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
200 /* SCTP_STATE_ESTABLISHED */ \ 202 /* SCTP_STATE_ESTABLISHED */ \
201 {.fn = sctp_sf_beat_8_3, .name = "sctp_sf_beat_8_3"}, \ 203 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
202 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 204 /* SCTP_STATE_SHUTDOWN_PENDING */ \
203 {.fn = sctp_sf_beat_8_3, .name = "sctp_sf_beat_8_3"}, \ 205 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
204 /* SCTP_STATE_SHUTDOWN_SENT */ \ 206 /* SCTP_STATE_SHUTDOWN_SENT */ \
205 {.fn = sctp_sf_beat_8_3, .name = "sctp_sf_beat_8_3"}, \ 207 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
206 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 208 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
207 {.fn = sctp_sf_beat_8_3, .name = "sctp_sf_beat_8_3"}, \ 209 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
208 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 210 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
209 /* This should not happen, but we are nice. */ \ 211 /* This should not happen, but we are nice. */ \
210 {.fn = sctp_sf_beat_8_3, .name = "sctp_sf_beat_8_3"}, \ 212 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
211} /* TYPE_SCTP_HEARTBEAT */ 213} /* TYPE_SCTP_HEARTBEAT */
212 214
213#define TYPE_SCTP_HEARTBEAT_ACK { \ 215#define TYPE_SCTP_HEARTBEAT_ACK { \
214 /* SCTP_STATE_EMPTY */ \ 216 /* SCTP_STATE_EMPTY */ \
215 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 217 TYPE_SCTP_FUNC(sctp_sf_ootb), \
216 /* SCTP_STATE_CLOSED */ \ 218 /* SCTP_STATE_CLOSED */ \
217 {.fn = sctp_sf_tabort_8_4_8, .name = "sctp_sf_tabort_8_4_8"}, \ 219 TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
218 /* SCTP_STATE_COOKIE_WAIT */ \ 220 /* SCTP_STATE_COOKIE_WAIT */ \
219 {.fn = sctp_sf_violation, .name = "sctp_sf_violation"}, \ 221 TYPE_SCTP_FUNC(sctp_sf_violation), \
220 /* SCTP_STATE_COOKIE_ECHOED */ \ 222 /* SCTP_STATE_COOKIE_ECHOED */ \
221 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 223 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
222 /* SCTP_STATE_ESTABLISHED */ \ 224 /* SCTP_STATE_ESTABLISHED */ \
223 {.fn = sctp_sf_backbeat_8_3, .name = "sctp_sf_backbeat_8_3"}, \ 225 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
224 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 226 /* SCTP_STATE_SHUTDOWN_PENDING */ \
225 {.fn = sctp_sf_backbeat_8_3, .name = "sctp_sf_backbeat_8_3"}, \ 227 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
226 /* SCTP_STATE_SHUTDOWN_SENT */ \ 228 /* SCTP_STATE_SHUTDOWN_SENT */ \
227 {.fn = sctp_sf_backbeat_8_3, .name = "sctp_sf_backbeat_8_3"}, \ 229 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
228 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 230 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
229 {.fn = sctp_sf_backbeat_8_3, .name = "sctp_sf_backbeat_8_3"}, \ 231 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
230 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 232 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
231 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 233 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
232} /* TYPE_SCTP_HEARTBEAT_ACK */ 234} /* TYPE_SCTP_HEARTBEAT_ACK */
233 235
234#define TYPE_SCTP_ABORT { \ 236#define TYPE_SCTP_ABORT { \
235 /* SCTP_STATE_EMPTY */ \ 237 /* SCTP_STATE_EMPTY */ \
236 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 238 TYPE_SCTP_FUNC(sctp_sf_ootb), \
237 /* SCTP_STATE_CLOSED */ \ 239 /* SCTP_STATE_CLOSED */ \
238 {.fn = sctp_sf_pdiscard, .name = "sctp_sf_pdiscard"}, \ 240 TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
239 /* SCTP_STATE_COOKIE_WAIT */ \ 241 /* SCTP_STATE_COOKIE_WAIT */ \
240 {.fn = sctp_sf_cookie_wait_abort, .name = "sctp_sf_cookie_wait_abort"}, \ 242 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
241 /* SCTP_STATE_COOKIE_ECHOED */ \ 243 /* SCTP_STATE_COOKIE_ECHOED */ \
242 {.fn = sctp_sf_cookie_echoed_abort, \ 244 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
243 .name = "sctp_sf_cookie_echoed_abort"}, \
244 /* SCTP_STATE_ESTABLISHED */ \ 245 /* SCTP_STATE_ESTABLISHED */ \
245 {.fn = sctp_sf_do_9_1_abort, .name = "sctp_sf_do_9_1_abort"}, \ 246 TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
246 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 247 /* SCTP_STATE_SHUTDOWN_PENDING */ \
247 {.fn = sctp_sf_shutdown_pending_abort, \ 248 TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
248 .name = "sctp_sf_shutdown_pending_abort"}, \
249 /* SCTP_STATE_SHUTDOWN_SENT */ \ 249 /* SCTP_STATE_SHUTDOWN_SENT */ \
250 {.fn = sctp_sf_shutdown_sent_abort, \ 250 TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
251 .name = "sctp_sf_shutdown_sent_abort"}, \
252 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 251 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
253 {.fn = sctp_sf_do_9_1_abort, .name = "sctp_sf_do_9_1_abort"}, \ 252 TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
254 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 253 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
255 {.fn = sctp_sf_shutdown_ack_sent_abort, \ 254 TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
256 .name = "sctp_sf_shutdown_ack_sent_abort"}, \
257} /* TYPE_SCTP_ABORT */ 255} /* TYPE_SCTP_ABORT */
258 256
259#define TYPE_SCTP_SHUTDOWN { \ 257#define TYPE_SCTP_SHUTDOWN { \
260 /* SCTP_STATE_EMPTY */ \ 258 /* SCTP_STATE_EMPTY */ \
261 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 259 TYPE_SCTP_FUNC(sctp_sf_ootb), \
262 /* SCTP_STATE_CLOSED */ \ 260 /* SCTP_STATE_CLOSED */ \
263 {.fn = sctp_sf_tabort_8_4_8, .name = "sctp_sf_tabort_8_4_8"}, \ 261 TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
264 /* SCTP_STATE_COOKIE_WAIT */ \ 262 /* SCTP_STATE_COOKIE_WAIT */ \
265 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 263 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
266 /* SCTP_STATE_COOKIE_ECHOED */ \ 264 /* SCTP_STATE_COOKIE_ECHOED */ \
267 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 265 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
268 /* SCTP_STATE_ESTABLISHED */ \ 266 /* SCTP_STATE_ESTABLISHED */ \
269 {.fn = sctp_sf_do_9_2_shutdown, .name = "sctp_sf_do_9_2_shutdown"}, \ 267 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
270 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 268 /* SCTP_STATE_SHUTDOWN_PENDING */ \
271 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 269 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
272 /* SCTP_STATE_SHUTDOWN_SENT */ \ 270 /* SCTP_STATE_SHUTDOWN_SENT */ \
273 {.fn = sctp_sf_do_9_2_shutdown_ack, \ 271 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
274 .name = "sctp_sf_do_9_2_shutdown_ack"}, \
275 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 272 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
276 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 273 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
277 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 274 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
278 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 275 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
279} /* TYPE_SCTP_SHUTDOWN */ 276} /* TYPE_SCTP_SHUTDOWN */
280 277
281#define TYPE_SCTP_SHUTDOWN_ACK { \ 278#define TYPE_SCTP_SHUTDOWN_ACK { \
282 /* SCTP_STATE_EMPTY */ \ 279 /* SCTP_STATE_EMPTY */ \
283 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 280 TYPE_SCTP_FUNC(sctp_sf_ootb), \
284 /* SCTP_STATE_CLOSED */ \ 281 /* SCTP_STATE_CLOSED */ \
285 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 282 TYPE_SCTP_FUNC(sctp_sf_ootb), \
286 /* SCTP_STATE_COOKIE_WAIT */ \ 283 /* SCTP_STATE_COOKIE_WAIT */ \
287 {.fn = sctp_sf_do_8_5_1_E_sa, .name = "sctp_sf_do_8_5_1_E_sa"}, \ 284 TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
288 /* SCTP_STATE_COOKIE_ECHOED */ \ 285 /* SCTP_STATE_COOKIE_ECHOED */ \
289 {.fn = sctp_sf_do_8_5_1_E_sa, .name = "sctp_sf_do_8_5_1_E_sa"}, \ 286 TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
290 /* SCTP_STATE_ESTABLISHED */ \ 287 /* SCTP_STATE_ESTABLISHED */ \
291 {.fn = sctp_sf_violation, .name = "sctp_sf_violation"}, \ 288 TYPE_SCTP_FUNC(sctp_sf_violation), \
292 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 289 /* SCTP_STATE_SHUTDOWN_PENDING */ \
293 {.fn = sctp_sf_violation, .name = "sctp_sf_violation"}, \ 290 TYPE_SCTP_FUNC(sctp_sf_violation), \
294 /* SCTP_STATE_SHUTDOWN_SENT */ \ 291 /* SCTP_STATE_SHUTDOWN_SENT */ \
295 {.fn = sctp_sf_do_9_2_final, .name = "sctp_sf_do_9_2_final"}, \ 292 TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
296 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 293 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
297 {.fn = sctp_sf_violation, .name = "sctp_sf_violation"}, \ 294 TYPE_SCTP_FUNC(sctp_sf_violation), \
298 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 295 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
299 {.fn = sctp_sf_do_9_2_final, .name = "sctp_sf_do_9_2_final"}, \ 296 TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
300} /* TYPE_SCTP_SHUTDOWN_ACK */ 297} /* TYPE_SCTP_SHUTDOWN_ACK */
301 298
302#define TYPE_SCTP_ERROR { \ 299#define TYPE_SCTP_ERROR { \
303 /* SCTP_STATE_EMPTY */ \ 300 /* SCTP_STATE_EMPTY */ \
304 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 301 TYPE_SCTP_FUNC(sctp_sf_ootb), \
305 /* SCTP_STATE_CLOSED */ \ 302 /* SCTP_STATE_CLOSED */ \
306 {.fn = sctp_sf_tabort_8_4_8, .name = "sctp_sf_tabort_8_4_8"}, \ 303 TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
307 /* SCTP_STATE_COOKIE_WAIT */ \ 304 /* SCTP_STATE_COOKIE_WAIT */ \
308 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 305 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
309 /* SCTP_STATE_COOKIE_ECHOED */ \ 306 /* SCTP_STATE_COOKIE_ECHOED */ \
310 {.fn = sctp_sf_cookie_echoed_err, .name = "sctp_sf_cookie_echoed_err"}, \ 307 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
311 /* SCTP_STATE_ESTABLISHED */ \ 308 /* SCTP_STATE_ESTABLISHED */ \
312 {.fn = sctp_sf_operr_notify, .name = "sctp_sf_operr_notify"}, \ 309 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
313 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 310 /* SCTP_STATE_SHUTDOWN_PENDING */ \
314 {.fn = sctp_sf_operr_notify, .name = "sctp_sf_operr_notify"}, \ 311 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
315 /* SCTP_STATE_SHUTDOWN_SENT */ \ 312 /* SCTP_STATE_SHUTDOWN_SENT */ \
316 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 313 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
317 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 314 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
318 {.fn = sctp_sf_operr_notify, .name = "sctp_sf_operr_notify"}, \ 315 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
319 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 316 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
320 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 317 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
321} /* TYPE_SCTP_ERROR */ 318} /* TYPE_SCTP_ERROR */
322 319
323#define TYPE_SCTP_COOKIE_ECHO { \ 320#define TYPE_SCTP_COOKIE_ECHO { \
324 /* SCTP_STATE_EMPTY */ \ 321 /* SCTP_STATE_EMPTY */ \
325 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 322 TYPE_SCTP_FUNC(sctp_sf_bug), \
326 /* SCTP_STATE_CLOSED */ \ 323 /* SCTP_STATE_CLOSED */ \
327 {.fn = sctp_sf_do_5_1D_ce, .name = "sctp_sf_do_5_1D_ce"}, \ 324 TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
328 /* SCTP_STATE_COOKIE_WAIT */ \ 325 /* SCTP_STATE_COOKIE_WAIT */ \
329 {.fn = sctp_sf_do_5_2_4_dupcook, .name = "sctp_sf_do_5_2_4_dupcook"}, \ 326 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
330 /* SCTP_STATE_COOKIE_ECHOED */ \ 327 /* SCTP_STATE_COOKIE_ECHOED */ \
331 {.fn = sctp_sf_do_5_2_4_dupcook, .name = "sctp_sf_do_5_2_4_dupcook"}, \ 328 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
332 /* SCTP_STATE_ESTABLISHED */ \ 329 /* SCTP_STATE_ESTABLISHED */ \
333 {.fn = sctp_sf_do_5_2_4_dupcook, .name = "sctp_sf_do_5_2_4_dupcook"}, \ 330 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
334 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 331 /* SCTP_STATE_SHUTDOWN_PENDING */ \
335 {.fn = sctp_sf_do_5_2_4_dupcook, .name = "sctp_sf_do_5_2_4_dupcook"}, \ 332 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
336 /* SCTP_STATE_SHUTDOWN_SENT */ \ 333 /* SCTP_STATE_SHUTDOWN_SENT */ \
337 {.fn = sctp_sf_do_5_2_4_dupcook, .name = "sctp_sf_do_5_2_4_dupcook"}, \ 334 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
338 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 335 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
339 {.fn = sctp_sf_do_5_2_4_dupcook, .name = "sctp_sf_do_5_2_4_dupcook"}, \ 336 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
340 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 337 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
341 {.fn = sctp_sf_do_5_2_4_dupcook, .name = "sctp_sf_do_5_2_4_dupcook"}, \ 338 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
342} /* TYPE_SCTP_COOKIE_ECHO */ 339} /* TYPE_SCTP_COOKIE_ECHO */
343 340
344#define TYPE_SCTP_COOKIE_ACK { \ 341#define TYPE_SCTP_COOKIE_ACK { \
345 /* SCTP_STATE_EMPTY */ \ 342 /* SCTP_STATE_EMPTY */ \
346 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 343 TYPE_SCTP_FUNC(sctp_sf_ootb), \
347 /* SCTP_STATE_CLOSED */ \ 344 /* SCTP_STATE_CLOSED */ \
348 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 345 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
349 /* SCTP_STATE_COOKIE_WAIT */ \ 346 /* SCTP_STATE_COOKIE_WAIT */ \
350 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 347 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
351 /* SCTP_STATE_COOKIE_ECHOED */ \ 348 /* SCTP_STATE_COOKIE_ECHOED */ \
352 {.fn = sctp_sf_do_5_1E_ca, .name = "sctp_sf_do_5_1E_ca"}, \ 349 TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
353 /* SCTP_STATE_ESTABLISHED */ \ 350 /* SCTP_STATE_ESTABLISHED */ \
354 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 351 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
355 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 352 /* SCTP_STATE_SHUTDOWN_PENDING */ \
356 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 353 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
357 /* SCTP_STATE_SHUTDOWN_SENT */ \ 354 /* SCTP_STATE_SHUTDOWN_SENT */ \
358 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 355 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
359 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 356 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
360 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 357 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
361 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 358 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
362 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 359 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
363} /* TYPE_SCTP_COOKIE_ACK */ 360} /* TYPE_SCTP_COOKIE_ACK */
364 361
365#define TYPE_SCTP_ECN_ECNE { \ 362#define TYPE_SCTP_ECN_ECNE { \
366 /* SCTP_STATE_EMPTY */ \ 363 /* SCTP_STATE_EMPTY */ \
367 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 364 TYPE_SCTP_FUNC(sctp_sf_ootb), \
368 /* SCTP_STATE_CLOSED */ \ 365 /* SCTP_STATE_CLOSED */ \
369 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 366 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
370 /* SCTP_STATE_COOKIE_WAIT */ \ 367 /* SCTP_STATE_COOKIE_WAIT */ \
371 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 368 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
372 /* SCTP_STATE_COOKIE_ECHOED */ \ 369 /* SCTP_STATE_COOKIE_ECHOED */ \
373 {.fn = sctp_sf_do_ecne, .name = "sctp_sf_do_ecne"}, \ 370 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
374 /* SCTP_STATE_ESTABLISHED */ \ 371 /* SCTP_STATE_ESTABLISHED */ \
375 {.fn = sctp_sf_do_ecne, .name = "sctp_sf_do_ecne"}, \ 372 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
376 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 373 /* SCTP_STATE_SHUTDOWN_PENDING */ \
377 {.fn = sctp_sf_do_ecne, .name = "sctp_sf_do_ecne"}, \ 374 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
378 /* SCTP_STATE_SHUTDOWN_SENT */ \ 375 /* SCTP_STATE_SHUTDOWN_SENT */ \
379 {.fn = sctp_sf_do_ecne, .name = "sctp_sf_do_ecne"}, \ 376 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
380 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 377 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
381 {.fn = sctp_sf_do_ecne, .name = "sctp_sf_do_ecne"}, \ 378 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
382 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 379 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
383 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 380 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
384} /* TYPE_SCTP_ECN_ECNE */ 381} /* TYPE_SCTP_ECN_ECNE */
385 382
386#define TYPE_SCTP_ECN_CWR { \ 383#define TYPE_SCTP_ECN_CWR { \
387 /* SCTP_STATE_EMPTY */ \ 384 /* SCTP_STATE_EMPTY */ \
388 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 385 TYPE_SCTP_FUNC(sctp_sf_ootb), \
389 /* SCTP_STATE_CLOSED */ \ 386 /* SCTP_STATE_CLOSED */ \
390 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 387 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
391 /* SCTP_STATE_COOKIE_WAIT */ \ 388 /* SCTP_STATE_COOKIE_WAIT */ \
392 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 389 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
393 /* SCTP_STATE_COOKIE_ECHOED */ \ 390 /* SCTP_STATE_COOKIE_ECHOED */ \
394 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 391 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
395 /* SCTP_STATE_ESTABLISHED */ \ 392 /* SCTP_STATE_ESTABLISHED */ \
396 {.fn = sctp_sf_do_ecn_cwr, .name = "sctp_sf_do_ecn_cwr"}, \ 393 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
397 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 394 /* SCTP_STATE_SHUTDOWN_PENDING */ \
398 {.fn = sctp_sf_do_ecn_cwr, .name = "sctp_sf_do_ecn_cwr"}, \ 395 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
399 /* SCTP_STATE_SHUTDOWN_SENT */ \ 396 /* SCTP_STATE_SHUTDOWN_SENT */ \
400 {.fn = sctp_sf_do_ecn_cwr, .name = "sctp_sf_do_ecn_cwr"}, \ 397 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
401 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 398 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
402 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 399 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
403 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 400 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
404 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 401 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
405} /* TYPE_SCTP_ECN_CWR */ 402} /* TYPE_SCTP_ECN_CWR */
406 403
407#define TYPE_SCTP_SHUTDOWN_COMPLETE { \ 404#define TYPE_SCTP_SHUTDOWN_COMPLETE { \
408 /* SCTP_STATE_EMPTY */ \ 405 /* SCTP_STATE_EMPTY */ \
409 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 406 TYPE_SCTP_FUNC(sctp_sf_ootb), \
410 /* SCTP_STATE_CLOSED */ \ 407 /* SCTP_STATE_CLOSED */ \
411 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 408 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
412 /* SCTP_STATE_COOKIE_WAIT */ \ 409 /* SCTP_STATE_COOKIE_WAIT */ \
413 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 410 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
414 /* SCTP_STATE_COOKIE_ECHOED */ \ 411 /* SCTP_STATE_COOKIE_ECHOED */ \
415 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 412 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
416 /* SCTP_STATE_ESTABLISHED */ \ 413 /* SCTP_STATE_ESTABLISHED */ \
417 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 414 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
418 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 415 /* SCTP_STATE_SHUTDOWN_PENDING */ \
419 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 416 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
420 /* SCTP_STATE_SHUTDOWN_SENT */ \ 417 /* SCTP_STATE_SHUTDOWN_SENT */ \
421 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 418 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
422 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 419 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
423 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 420 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
424 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 421 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
425 {.fn = sctp_sf_do_4_C, .name = "sctp_sf_do_4_C"}, \ 422 TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
426} /* TYPE_SCTP_SHUTDOWN_COMPLETE */ 423} /* TYPE_SCTP_SHUTDOWN_COMPLETE */
427 424
428/* The primary index for this table is the chunk type. 425/* The primary index for this table is the chunk type.
@@ -450,44 +447,44 @@ static const sctp_sm_table_entry_t chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][
450 447
451#define TYPE_SCTP_ASCONF { \ 448#define TYPE_SCTP_ASCONF { \
452 /* SCTP_STATE_EMPTY */ \ 449 /* SCTP_STATE_EMPTY */ \
453 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 450 TYPE_SCTP_FUNC(sctp_sf_ootb), \
454 /* SCTP_STATE_CLOSED */ \ 451 /* SCTP_STATE_CLOSED */ \
455 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 452 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
456 /* SCTP_STATE_COOKIE_WAIT */ \ 453 /* SCTP_STATE_COOKIE_WAIT */ \
457 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 454 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
458 /* SCTP_STATE_COOKIE_ECHOED */ \ 455 /* SCTP_STATE_COOKIE_ECHOED */ \
459 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 456 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
460 /* SCTP_STATE_ESTABLISHED */ \ 457 /* SCTP_STATE_ESTABLISHED */ \
461 {.fn = sctp_sf_do_asconf, .name = "sctp_sf_do_asconf"}, \ 458 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
462 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 459 /* SCTP_STATE_SHUTDOWN_PENDING */ \
463 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 460 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
464 /* SCTP_STATE_SHUTDOWN_SENT */ \ 461 /* SCTP_STATE_SHUTDOWN_SENT */ \
465 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 462 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
466 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 463 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
467 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 464 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
468 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 465 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
469 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 466 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
470} /* TYPE_SCTP_ASCONF */ 467} /* TYPE_SCTP_ASCONF */
471 468
472#define TYPE_SCTP_ASCONF_ACK { \ 469#define TYPE_SCTP_ASCONF_ACK { \
473 /* SCTP_STATE_EMPTY */ \ 470 /* SCTP_STATE_EMPTY */ \
474 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 471 TYPE_SCTP_FUNC(sctp_sf_ootb), \
475 /* SCTP_STATE_CLOSED */ \ 472 /* SCTP_STATE_CLOSED */ \
476 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 473 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
477 /* SCTP_STATE_COOKIE_WAIT */ \ 474 /* SCTP_STATE_COOKIE_WAIT */ \
478 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 475 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
479 /* SCTP_STATE_COOKIE_ECHOED */ \ 476 /* SCTP_STATE_COOKIE_ECHOED */ \
480 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 477 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
481 /* SCTP_STATE_ESTABLISHED */ \ 478 /* SCTP_STATE_ESTABLISHED */ \
482 {.fn = sctp_sf_do_asconf_ack, .name = "sctp_sf_do_asconf_ack"}, \ 479 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
483 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 480 /* SCTP_STATE_SHUTDOWN_PENDING */ \
484 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 481 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
485 /* SCTP_STATE_SHUTDOWN_SENT */ \ 482 /* SCTP_STATE_SHUTDOWN_SENT */ \
486 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 483 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
487 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 484 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
488 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 485 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
489 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 486 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
490 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 487 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
491} /* TYPE_SCTP_ASCONF_ACK */ 488} /* TYPE_SCTP_ASCONF_ACK */
492 489
493/* The primary index for this table is the chunk type. 490/* The primary index for this table is the chunk type.
@@ -500,23 +497,23 @@ static const sctp_sm_table_entry_t addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_
500 497
501#define TYPE_SCTP_FWD_TSN { \ 498#define TYPE_SCTP_FWD_TSN { \
502 /* SCTP_STATE_EMPTY */ \ 499 /* SCTP_STATE_EMPTY */ \
503 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, \ 500 TYPE_SCTP_FUNC(sctp_sf_ootb), \
504 /* SCTP_STATE_CLOSED */ \ 501 /* SCTP_STATE_CLOSED */ \
505 {.fn = sctp_sf_tabort_8_4_8, .name = "sctp_sf_tabort_8_4_8"}, \ 502 TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8), \
506 /* SCTP_STATE_COOKIE_WAIT */ \ 503 /* SCTP_STATE_COOKIE_WAIT */ \
507 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 504 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
508 /* SCTP_STATE_COOKIE_ECHOED */ \ 505 /* SCTP_STATE_COOKIE_ECHOED */ \
509 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 506 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
510 /* SCTP_STATE_ESTABLISHED */ \ 507 /* SCTP_STATE_ESTABLISHED */ \
511 {.fn = sctp_sf_eat_fwd_tsn, .name = "sctp_sf_eat_fwd_tsn"}, \ 508 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
512 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 509 /* SCTP_STATE_SHUTDOWN_PENDING */ \
513 {.fn = sctp_sf_eat_fwd_tsn, .name = "sctp_sf_eat_fwd_tsn"}, \ 510 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
514 /* SCTP_STATE_SHUTDOWN_SENT */ \ 511 /* SCTP_STATE_SHUTDOWN_SENT */ \
515 {.fn = sctp_sf_eat_fwd_tsn_fast, .name = "sctp_sf_eat_fwd_tsn_fast"}, \ 512 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
516 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 513 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
517 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 514 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
518 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 515 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
519 {.fn = sctp_sf_discard_chunk, .name = "sctp_sf_discard_chunk"}, \ 516 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
520} /* TYPE_SCTP_FWD_TSN */ 517} /* TYPE_SCTP_FWD_TSN */
521 518
522/* The primary index for this table is the chunk type. 519/* The primary index for this table is the chunk type.
@@ -529,167 +526,150 @@ static const sctp_sm_table_entry_t prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUN
529static const sctp_sm_table_entry_t 526static const sctp_sm_table_entry_t
530chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = { 527chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
531 /* SCTP_STATE_EMPTY */ 528 /* SCTP_STATE_EMPTY */
532 {.fn = sctp_sf_ootb, .name = "sctp_sf_ootb"}, 529 TYPE_SCTP_FUNC(sctp_sf_ootb),
533 /* SCTP_STATE_CLOSED */ 530 /* SCTP_STATE_CLOSED */
534 {.fn = sctp_sf_tabort_8_4_8, .name = "sctp_sf_tabort_8_4_8"}, 531 TYPE_SCTP_FUNC(sctp_sf_tabort_8_4_8),
535 /* SCTP_STATE_COOKIE_WAIT */ 532 /* SCTP_STATE_COOKIE_WAIT */
536 {.fn = sctp_sf_unk_chunk, .name = "sctp_sf_unk_chunk"}, 533 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
537 /* SCTP_STATE_COOKIE_ECHOED */ 534 /* SCTP_STATE_COOKIE_ECHOED */
538 {.fn = sctp_sf_unk_chunk, .name = "sctp_sf_unk_chunk"}, 535 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
539 /* SCTP_STATE_ESTABLISHED */ 536 /* SCTP_STATE_ESTABLISHED */
540 {.fn = sctp_sf_unk_chunk, .name = "sctp_sf_unk_chunk"}, 537 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
541 /* SCTP_STATE_SHUTDOWN_PENDING */ 538 /* SCTP_STATE_SHUTDOWN_PENDING */
542 {.fn = sctp_sf_unk_chunk, .name = "sctp_sf_unk_chunk"}, 539 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
543 /* SCTP_STATE_SHUTDOWN_SENT */ 540 /* SCTP_STATE_SHUTDOWN_SENT */
544 {.fn = sctp_sf_unk_chunk, .name = "sctp_sf_unk_chunk"}, 541 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
545 /* SCTP_STATE_SHUTDOWN_RECEIVED */ 542 /* SCTP_STATE_SHUTDOWN_RECEIVED */
546 {.fn = sctp_sf_unk_chunk, .name = "sctp_sf_unk_chunk"}, 543 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
547 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ 544 /* SCTP_STATE_SHUTDOWN_ACK_SENT */
548 {.fn = sctp_sf_unk_chunk, .name = "sctp_sf_unk_chunk"}, 545 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
549}; /* chunk unknown */ 546}; /* chunk unknown */
550 547
551 548
552#define TYPE_SCTP_PRIMITIVE_ASSOCIATE { \ 549#define TYPE_SCTP_PRIMITIVE_ASSOCIATE { \
553 /* SCTP_STATE_EMPTY */ \ 550 /* SCTP_STATE_EMPTY */ \
554 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 551 TYPE_SCTP_FUNC(sctp_sf_bug), \
555 /* SCTP_STATE_CLOSED */ \ 552 /* SCTP_STATE_CLOSED */ \
556 {.fn = sctp_sf_do_prm_asoc, .name = "sctp_sf_do_prm_asoc"}, \ 553 TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
557 /* SCTP_STATE_COOKIE_WAIT */ \ 554 /* SCTP_STATE_COOKIE_WAIT */ \
558 {.fn = sctp_sf_not_impl, .name = "sctp_sf_not_impl"}, \ 555 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
559 /* SCTP_STATE_COOKIE_ECHOED */ \ 556 /* SCTP_STATE_COOKIE_ECHOED */ \
560 {.fn = sctp_sf_not_impl, .name = "sctp_sf_not_impl"}, \ 557 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
561 /* SCTP_STATE_ESTABLISHED */ \ 558 /* SCTP_STATE_ESTABLISHED */ \
562 {.fn = sctp_sf_not_impl, .name = "sctp_sf_not_impl"}, \ 559 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
563 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 560 /* SCTP_STATE_SHUTDOWN_PENDING */ \
564 {.fn = sctp_sf_not_impl, .name = "sctp_sf_not_impl"}, \ 561 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
565 /* SCTP_STATE_SHUTDOWN_SENT */ \ 562 /* SCTP_STATE_SHUTDOWN_SENT */ \
566 {.fn = sctp_sf_not_impl, .name = "sctp_sf_not_impl"}, \ 563 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
567 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 564 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
568 {.fn = sctp_sf_not_impl, .name = "sctp_sf_not_impl"}, \ 565 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
569 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 566 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
570 {.fn = sctp_sf_not_impl, .name = "sctp_sf_not_impl"}, \ 567 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
571} /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */ 568} /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */
572 569
573#define TYPE_SCTP_PRIMITIVE_SHUTDOWN { \ 570#define TYPE_SCTP_PRIMITIVE_SHUTDOWN { \
574 /* SCTP_STATE_EMPTY */ \ 571 /* SCTP_STATE_EMPTY */ \
575 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 572 TYPE_SCTP_FUNC(sctp_sf_bug), \
576 /* SCTP_STATE_CLOSED */ \ 573 /* SCTP_STATE_CLOSED */ \
577 {.fn = sctp_sf_error_closed, .name = "sctp_sf_error_closed"}, \ 574 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
578 /* SCTP_STATE_COOKIE_WAIT */ \ 575 /* SCTP_STATE_COOKIE_WAIT */ \
579 {.fn = sctp_sf_cookie_wait_prm_shutdown, \ 576 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
580 .name = "sctp_sf_cookie_wait_prm_shutdown"}, \
581 /* SCTP_STATE_COOKIE_ECHOED */ \ 577 /* SCTP_STATE_COOKIE_ECHOED */ \
582 {.fn = sctp_sf_cookie_echoed_prm_shutdown, \ 578 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
583 .name = "sctp_sf_cookie_echoed_prm_shutdown"},\
584 /* SCTP_STATE_ESTABLISHED */ \ 579 /* SCTP_STATE_ESTABLISHED */ \
585 {.fn = sctp_sf_do_9_2_prm_shutdown, \ 580 TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
586 .name = "sctp_sf_do_9_2_prm_shutdown"}, \
587 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 581 /* SCTP_STATE_SHUTDOWN_PENDING */ \
588 {.fn = sctp_sf_ignore_primitive, .name = "sctp_sf_ignore_primitive"}, \ 582 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
589 /* SCTP_STATE_SHUTDOWN_SENT */ \ 583 /* SCTP_STATE_SHUTDOWN_SENT */ \
590 {.fn = sctp_sf_ignore_primitive, .name = "sctp_sf_ignore_primitive"}, \ 584 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
591 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 585 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
592 {.fn = sctp_sf_ignore_primitive, .name = "sctp_sf_ignore_primitive"}, \ 586 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
593 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 587 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
594 {.fn = sctp_sf_ignore_primitive, .name = "sctp_sf_ignore_primitive"}, \ 588 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
595} /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */ 589} /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */
596 590
597#define TYPE_SCTP_PRIMITIVE_ABORT { \ 591#define TYPE_SCTP_PRIMITIVE_ABORT { \
598 /* SCTP_STATE_EMPTY */ \ 592 /* SCTP_STATE_EMPTY */ \
599 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 593 TYPE_SCTP_FUNC(sctp_sf_bug), \
600 /* SCTP_STATE_CLOSED */ \ 594 /* SCTP_STATE_CLOSED */ \
601 {.fn = sctp_sf_error_closed, .name = "sctp_sf_error_closed"}, \ 595 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
602 /* SCTP_STATE_COOKIE_WAIT */ \ 596 /* SCTP_STATE_COOKIE_WAIT */ \
603 {.fn = sctp_sf_cookie_wait_prm_abort, \ 597 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
604 .name = "sctp_sf_cookie_wait_prm_abort"}, \
605 /* SCTP_STATE_COOKIE_ECHOED */ \ 598 /* SCTP_STATE_COOKIE_ECHOED */ \
606 {.fn = sctp_sf_cookie_echoed_prm_abort, \ 599 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
607 .name = "sctp_sf_cookie_echoed_prm_abort"}, \
608 /* SCTP_STATE_ESTABLISHED */ \ 600 /* SCTP_STATE_ESTABLISHED */ \
609 {.fn = sctp_sf_do_9_1_prm_abort, \ 601 TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
610 .name = "sctp_sf_do_9_1_prm_abort"}, \
611 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 602 /* SCTP_STATE_SHUTDOWN_PENDING */ \
612 {.fn = sctp_sf_shutdown_pending_prm_abort, \ 603 TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
613 .name = "sctp_sf_shutdown_pending_prm_abort"}, \
614 /* SCTP_STATE_SHUTDOWN_SENT */ \ 604 /* SCTP_STATE_SHUTDOWN_SENT */ \
615 {.fn = sctp_sf_shutdown_sent_prm_abort, \ 605 TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
616 .name = "sctp_sf_shutdown_sent_prm_abort"}, \
617 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 606 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
618 {.fn = sctp_sf_do_9_1_prm_abort, \ 607 TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
619 .name = "sctp_sf_do_9_1_prm_abort"}, \
620 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 608 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
621 {.fn = sctp_sf_shutdown_ack_sent_prm_abort, \ 609 TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
622 .name = "sctp_sf_shutdown_ack_sent_prm_abort"}, \
623} /* TYPE_SCTP_PRIMITIVE_ABORT */ 610} /* TYPE_SCTP_PRIMITIVE_ABORT */
624 611
625#define TYPE_SCTP_PRIMITIVE_SEND { \ 612#define TYPE_SCTP_PRIMITIVE_SEND { \
626 /* SCTP_STATE_EMPTY */ \ 613 /* SCTP_STATE_EMPTY */ \
627 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 614 TYPE_SCTP_FUNC(sctp_sf_bug), \
628 /* SCTP_STATE_CLOSED */ \ 615 /* SCTP_STATE_CLOSED */ \
629 {.fn = sctp_sf_error_closed, .name = "sctp_sf_error_closed"}, \ 616 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
630 /* SCTP_STATE_COOKIE_WAIT */ \ 617 /* SCTP_STATE_COOKIE_WAIT */ \
631 {.fn = sctp_sf_do_prm_send, .name = "sctp_sf_do_prm_send"}, \ 618 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
632 /* SCTP_STATE_COOKIE_ECHOED */ \ 619 /* SCTP_STATE_COOKIE_ECHOED */ \
633 {.fn = sctp_sf_do_prm_send, .name = "sctp_sf_do_prm_send"}, \ 620 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
634 /* SCTP_STATE_ESTABLISHED */ \ 621 /* SCTP_STATE_ESTABLISHED */ \
635 {.fn = sctp_sf_do_prm_send, .name = "sctp_sf_do_prm_send"}, \ 622 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
636 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 623 /* SCTP_STATE_SHUTDOWN_PENDING */ \
637 {.fn = sctp_sf_error_shutdown, .name = "sctp_sf_error_shutdown"}, \ 624 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
638 /* SCTP_STATE_SHUTDOWN_SENT */ \ 625 /* SCTP_STATE_SHUTDOWN_SENT */ \
639 {.fn = sctp_sf_error_shutdown, .name = "sctp_sf_error_shutdown"}, \ 626 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
640 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 627 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
641 {.fn = sctp_sf_error_shutdown, .name = "sctp_sf_error_shutdown"}, \ 628 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
642 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 629 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
643 {.fn = sctp_sf_error_shutdown, .name = "sctp_sf_error_shutdown"}, \ 630 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
644} /* TYPE_SCTP_PRIMITIVE_SEND */ 631} /* TYPE_SCTP_PRIMITIVE_SEND */
645 632
646#define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT { \ 633#define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT { \
647 /* SCTP_STATE_EMPTY */ \ 634 /* SCTP_STATE_EMPTY */ \
648 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 635 TYPE_SCTP_FUNC(sctp_sf_bug), \
649 /* SCTP_STATE_CLOSED */ \ 636 /* SCTP_STATE_CLOSED */ \
650 {.fn = sctp_sf_error_closed, .name = "sctp_sf_error_closed"}, \ 637 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
651 /* SCTP_STATE_COOKIE_WAIT */ \ 638 /* SCTP_STATE_COOKIE_WAIT */ \
652 {.fn = sctp_sf_do_prm_requestheartbeat, \ 639 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
653 .name = "sctp_sf_do_prm_requestheartbeat"}, \
654 /* SCTP_STATE_COOKIE_ECHOED */ \ 640 /* SCTP_STATE_COOKIE_ECHOED */ \
655 {.fn = sctp_sf_do_prm_requestheartbeat, \ 641 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
656 .name = "sctp_sf_do_prm_requestheartbeat"}, \
657 /* SCTP_STATE_ESTABLISHED */ \ 642 /* SCTP_STATE_ESTABLISHED */ \
658 {.fn = sctp_sf_do_prm_requestheartbeat, \ 643 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
659 .name = "sctp_sf_do_prm_requestheartbeat"}, \
660 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 644 /* SCTP_STATE_SHUTDOWN_PENDING */ \
661 {.fn = sctp_sf_do_prm_requestheartbeat, \ 645 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
662 .name = "sctp_sf_do_prm_requestheartbeat"}, \
663 /* SCTP_STATE_SHUTDOWN_SENT */ \ 646 /* SCTP_STATE_SHUTDOWN_SENT */ \
664 {.fn = sctp_sf_do_prm_requestheartbeat, \ 647 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
665 .name = "sctp_sf_do_prm_requestheartbeat"}, \
666 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 648 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
667 {.fn = sctp_sf_do_prm_requestheartbeat, \ 649 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
668 .name = "sctp_sf_do_prm_requestheartbeat"}, \
669 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 650 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
670 {.fn = sctp_sf_do_prm_requestheartbeat, \ 651 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
671 .name = "sctp_sf_do_prm_requestheartbeat"}, \
672} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */ 652} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
673 653
674#define TYPE_SCTP_PRIMITIVE_ASCONF { \ 654#define TYPE_SCTP_PRIMITIVE_ASCONF { \
675 /* SCTP_STATE_EMPTY */ \ 655 /* SCTP_STATE_EMPTY */ \
676 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 656 TYPE_SCTP_FUNC(sctp_sf_bug), \
677 /* SCTP_STATE_CLOSED */ \ 657 /* SCTP_STATE_CLOSED */ \
678 {.fn = sctp_sf_error_closed, .name = "sctp_sf_error_closed"}, \ 658 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
679 /* SCTP_STATE_COOKIE_WAIT */ \ 659 /* SCTP_STATE_COOKIE_WAIT */ \
680 {.fn = sctp_sf_error_closed, .name = "sctp_sf_error_closed"}, \ 660 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
681 /* SCTP_STATE_COOKIE_ECHOED */ \ 661 /* SCTP_STATE_COOKIE_ECHOED */ \
682 {.fn = sctp_sf_error_closed, .name = "sctp_sf_error_closed"}, \ 662 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
683 /* SCTP_STATE_ESTABLISHED */ \ 663 /* SCTP_STATE_ESTABLISHED */ \
684 {.fn = sctp_sf_do_prm_asconf, .name = "sctp_sf_do_prm_asconf"}, \ 664 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
685 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 665 /* SCTP_STATE_SHUTDOWN_PENDING */ \
686 {.fn = sctp_sf_error_shutdown, .name = "sctp_sf_error_shutdown"}, \ 666 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
687 /* SCTP_STATE_SHUTDOWN_SENT */ \ 667 /* SCTP_STATE_SHUTDOWN_SENT */ \
688 {.fn = sctp_sf_error_shutdown, .name = "sctp_sf_error_shutdown"}, \ 668 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
689 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 669 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
690 {.fn = sctp_sf_error_shutdown, .name = "sctp_sf_error_shutdown"}, \ 670 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
691 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 671 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
692 {.fn = sctp_sf_error_shutdown, .name = "sctp_sf_error_shutdown"}, \ 672 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
693} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */ 673} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
694 674
695/* The primary index for this table is the primitive type. 675/* The primary index for this table is the primitive type.
@@ -706,47 +686,44 @@ static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPE
706 686
707#define TYPE_SCTP_OTHER_NO_PENDING_TSN { \ 687#define TYPE_SCTP_OTHER_NO_PENDING_TSN { \
708 /* SCTP_STATE_EMPTY */ \ 688 /* SCTP_STATE_EMPTY */ \
709 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 689 TYPE_SCTP_FUNC(sctp_sf_bug), \
710 /* SCTP_STATE_CLOSED */ \ 690 /* SCTP_STATE_CLOSED */ \
711 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 691 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
712 /* SCTP_STATE_COOKIE_WAIT */ \ 692 /* SCTP_STATE_COOKIE_WAIT */ \
713 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 693 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
714 /* SCTP_STATE_COOKIE_ECHOED */ \ 694 /* SCTP_STATE_COOKIE_ECHOED */ \
715 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 695 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
716 /* SCTP_STATE_ESTABLISHED */ \ 696 /* SCTP_STATE_ESTABLISHED */ \
717 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 697 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
718 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 698 /* SCTP_STATE_SHUTDOWN_PENDING */ \
719 {.fn = sctp_sf_do_9_2_start_shutdown, \ 699 TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
720 .name = "sctp_do_9_2_start_shutdown"}, \
721 /* SCTP_STATE_SHUTDOWN_SENT */ \ 700 /* SCTP_STATE_SHUTDOWN_SENT */ \
722 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 701 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
723 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 702 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
724 {.fn = sctp_sf_do_9_2_shutdown_ack, \ 703 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
725 .name = "sctp_sf_do_9_2_shutdown_ack"}, \
726 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 704 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
727 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 705 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
728} 706}
729 707
730#define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH { \ 708#define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH { \
731 /* SCTP_STATE_EMPTY */ \ 709 /* SCTP_STATE_EMPTY */ \
732 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 710 TYPE_SCTP_FUNC(sctp_sf_bug), \
733 /* SCTP_STATE_CLOSED */ \ 711 /* SCTP_STATE_CLOSED */ \
734 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 712 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
735 /* SCTP_STATE_COOKIE_WAIT */ \ 713 /* SCTP_STATE_COOKIE_WAIT */ \
736 {.fn = sctp_sf_cookie_wait_icmp_abort, \ 714 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
737 .name = "sctp_sf_cookie_wait_icmp_abort"}, \
738 /* SCTP_STATE_COOKIE_ECHOED */ \ 715 /* SCTP_STATE_COOKIE_ECHOED */ \
739 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 716 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
740 /* SCTP_STATE_ESTABLISHED */ \ 717 /* SCTP_STATE_ESTABLISHED */ \
741 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 718 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
742 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 719 /* SCTP_STATE_SHUTDOWN_PENDING */ \
743 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 720 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
744 /* SCTP_STATE_SHUTDOWN_SENT */ \ 721 /* SCTP_STATE_SHUTDOWN_SENT */ \
745 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 722 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
746 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 723 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
747 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 724 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
748 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 725 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
749 {.fn = sctp_sf_ignore_other, .name = "sctp_sf_ignore_other"}, \ 726 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
750} 727}
751 728
752static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = { 729static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
@@ -756,215 +733,212 @@ static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_
756 733
757#define TYPE_SCTP_EVENT_TIMEOUT_NONE { \ 734#define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
758 /* SCTP_STATE_EMPTY */ \ 735 /* SCTP_STATE_EMPTY */ \
759 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 736 TYPE_SCTP_FUNC(sctp_sf_bug), \
760 /* SCTP_STATE_CLOSED */ \ 737 /* SCTP_STATE_CLOSED */ \
761 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 738 TYPE_SCTP_FUNC(sctp_sf_bug), \
762 /* SCTP_STATE_COOKIE_WAIT */ \ 739 /* SCTP_STATE_COOKIE_WAIT */ \
763 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 740 TYPE_SCTP_FUNC(sctp_sf_bug), \
764 /* SCTP_STATE_COOKIE_ECHOED */ \ 741 /* SCTP_STATE_COOKIE_ECHOED */ \
765 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 742 TYPE_SCTP_FUNC(sctp_sf_bug), \
766 /* SCTP_STATE_ESTABLISHED */ \ 743 /* SCTP_STATE_ESTABLISHED */ \
767 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 744 TYPE_SCTP_FUNC(sctp_sf_bug), \
768 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 745 /* SCTP_STATE_SHUTDOWN_PENDING */ \
769 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 746 TYPE_SCTP_FUNC(sctp_sf_bug), \
770 /* SCTP_STATE_SHUTDOWN_SENT */ \ 747 /* SCTP_STATE_SHUTDOWN_SENT */ \
771 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 748 TYPE_SCTP_FUNC(sctp_sf_bug), \
772 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 749 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
773 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 750 TYPE_SCTP_FUNC(sctp_sf_bug), \
774 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 751 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
775 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 752 TYPE_SCTP_FUNC(sctp_sf_bug), \
776} 753}
777 754
778#define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \ 755#define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
779 /* SCTP_STATE_EMPTY */ \ 756 /* SCTP_STATE_EMPTY */ \
780 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 757 TYPE_SCTP_FUNC(sctp_sf_bug), \
781 /* SCTP_STATE_CLOSED */ \ 758 /* SCTP_STATE_CLOSED */ \
782 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 759 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
783 /* SCTP_STATE_COOKIE_WAIT */ \ 760 /* SCTP_STATE_COOKIE_WAIT */ \
784 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 761 TYPE_SCTP_FUNC(sctp_sf_bug), \
785 /* SCTP_STATE_COOKIE_ECHOED */ \ 762 /* SCTP_STATE_COOKIE_ECHOED */ \
786 {.fn = sctp_sf_t1_cookie_timer_expire, \ 763 TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
787 .name = "sctp_sf_t1_cookie_timer_expire"}, \
788 /* SCTP_STATE_ESTABLISHED */ \ 764 /* SCTP_STATE_ESTABLISHED */ \
789 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 765 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
790 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 766 /* SCTP_STATE_SHUTDOWN_PENDING */ \
791 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 767 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
792 /* SCTP_STATE_SHUTDOWN_SENT */ \ 768 /* SCTP_STATE_SHUTDOWN_SENT */ \
793 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 769 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
794 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 770 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
795 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 771 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
796 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 772 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
797 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 773 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
798} 774}
799 775
800#define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \ 776#define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
801 /* SCTP_STATE_EMPTY */ \ 777 /* SCTP_STATE_EMPTY */ \
802 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 778 TYPE_SCTP_FUNC(sctp_sf_bug), \
803 /* SCTP_STATE_CLOSED */ \ 779 /* SCTP_STATE_CLOSED */ \
804 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 780 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
805 /* SCTP_STATE_COOKIE_WAIT */ \ 781 /* SCTP_STATE_COOKIE_WAIT */ \
806 {.fn = sctp_sf_t1_init_timer_expire, \ 782 TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
807 .name = "sctp_sf_t1_init_timer_expire"}, \
808 /* SCTP_STATE_COOKIE_ECHOED */ \ 783 /* SCTP_STATE_COOKIE_ECHOED */ \
809 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 784 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
810 /* SCTP_STATE_ESTABLISHED */ \ 785 /* SCTP_STATE_ESTABLISHED */ \
811 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 786 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
812 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 787 /* SCTP_STATE_SHUTDOWN_PENDING */ \
813 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 788 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
814 /* SCTP_STATE_SHUTDOWN_SENT */ \ 789 /* SCTP_STATE_SHUTDOWN_SENT */ \
815 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 790 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
816 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 791 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
817 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 792 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
818 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 793 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
819 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 794 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
820} 795}
821 796
822#define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \ 797#define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
823 /* SCTP_STATE_EMPTY */ \ 798 /* SCTP_STATE_EMPTY */ \
824 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 799 TYPE_SCTP_FUNC(sctp_sf_bug), \
825 /* SCTP_STATE_CLOSED */ \ 800 /* SCTP_STATE_CLOSED */ \
826 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 801 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
827 /* SCTP_STATE_COOKIE_WAIT */ \ 802 /* SCTP_STATE_COOKIE_WAIT */ \
828 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 803 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
829 /* SCTP_STATE_COOKIE_ECHOED */ \ 804 /* SCTP_STATE_COOKIE_ECHOED */ \
830 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 805 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
831 /* SCTP_STATE_ESTABLISHED */ \ 806 /* SCTP_STATE_ESTABLISHED */ \
832 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 807 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
833 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 808 /* SCTP_STATE_SHUTDOWN_PENDING */ \
834 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 809 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
835 /* SCTP_STATE_SHUTDOWN_SENT */ \ 810 /* SCTP_STATE_SHUTDOWN_SENT */ \
836 {.fn = sctp_sf_t2_timer_expire, .name = "sctp_sf_t2_timer_expire"}, \ 811 TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
837 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 812 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
838 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 813 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
839 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 814 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
840 {.fn = sctp_sf_t2_timer_expire, .name = "sctp_sf_t2_timer_expire"}, \ 815 TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
841} 816}
842 817
843#define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \ 818#define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
844 /* SCTP_STATE_EMPTY */ \ 819 /* SCTP_STATE_EMPTY */ \
845 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 820 TYPE_SCTP_FUNC(sctp_sf_bug), \
846 /* SCTP_STATE_CLOSED */ \ 821 /* SCTP_STATE_CLOSED */ \
847 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 822 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
848 /* SCTP_STATE_COOKIE_WAIT */ \ 823 /* SCTP_STATE_COOKIE_WAIT */ \
849 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 824 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
850 /* SCTP_STATE_COOKIE_ECHOED */ \ 825 /* SCTP_STATE_COOKIE_ECHOED */ \
851 {.fn = sctp_sf_do_6_3_3_rtx, .name = "sctp_sf_do_6_3_3_rtx"}, \ 826 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
852 /* SCTP_STATE_ESTABLISHED */ \ 827 /* SCTP_STATE_ESTABLISHED */ \
853 {.fn = sctp_sf_do_6_3_3_rtx, .name = "sctp_sf_do_6_3_3_rtx"}, \ 828 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
854 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 829 /* SCTP_STATE_SHUTDOWN_PENDING */ \
855 {.fn = sctp_sf_do_6_3_3_rtx, .name = "sctp_sf_do_6_3_3_rtx"}, \ 830 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
856 /* SCTP_STATE_SHUTDOWN_SENT */ \ 831 /* SCTP_STATE_SHUTDOWN_SENT */ \
857 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 832 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
858 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 833 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
859 {.fn = sctp_sf_do_6_3_3_rtx, .name = "sctp_sf_do_6_3_3_rtx"}, \ 834 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
860 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 835 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
861 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 836 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
862} 837}
863 838
864#define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \ 839#define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
865 /* SCTP_STATE_EMPTY */ \ 840 /* SCTP_STATE_EMPTY */ \
866 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 841 TYPE_SCTP_FUNC(sctp_sf_bug), \
867 /* SCTP_STATE_CLOSED */ \ 842 /* SCTP_STATE_CLOSED */ \
868 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 843 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
869 /* SCTP_STATE_COOKIE_WAIT */ \ 844 /* SCTP_STATE_COOKIE_WAIT */ \
870 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 845 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
871 /* SCTP_STATE_COOKIE_ECHOED */ \ 846 /* SCTP_STATE_COOKIE_ECHOED */ \
872 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 847 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
873 /* SCTP_STATE_ESTABLISHED */ \ 848 /* SCTP_STATE_ESTABLISHED */ \
874 {.fn = sctp_sf_t4_timer_expire, .name = "sctp_sf_t4_timer_expire"}, \ 849 TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
875 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 850 /* SCTP_STATE_SHUTDOWN_PENDING */ \
876 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 851 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
877 /* SCTP_STATE_SHUTDOWN_SENT */ \ 852 /* SCTP_STATE_SHUTDOWN_SENT */ \
878 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 853 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
879 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 854 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
880 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 855 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
881 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 856 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
882 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 857 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
883} 858}
884 859
885#define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \ 860#define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
886 /* SCTP_STATE_EMPTY */ \ 861 /* SCTP_STATE_EMPTY */ \
887 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 862 TYPE_SCTP_FUNC(sctp_sf_bug), \
888 /* SCTP_STATE_CLOSED */ \ 863 /* SCTP_STATE_CLOSED */ \
889 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 864 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
890 /* SCTP_STATE_COOKIE_WAIT */ \ 865 /* SCTP_STATE_COOKIE_WAIT */ \
891 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 866 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
892 /* SCTP_STATE_COOKIE_ECHOED */ \ 867 /* SCTP_STATE_COOKIE_ECHOED */ \
893 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 868 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
894 /* SCTP_STATE_ESTABLISHED */ \ 869 /* SCTP_STATE_ESTABLISHED */ \
895 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 870 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
896 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 871 /* SCTP_STATE_SHUTDOWN_PENDING */ \
897 {.fn = sctp_sf_t5_timer_expire, .name = "sctp_sf_t5_timer_expire"}, \ 872 TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
898 /* SCTP_STATE_SHUTDOWN_SENT */ \ 873 /* SCTP_STATE_SHUTDOWN_SENT */ \
899 {.fn = sctp_sf_t5_timer_expire, .name = "sctp_sf_t5_timer_expire"}, \ 874 TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
900 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 875 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
901 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 876 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
902 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 877 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
903 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 878 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
904} 879}
905 880
906#define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \ 881#define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
907 /* SCTP_STATE_EMPTY */ \ 882 /* SCTP_STATE_EMPTY */ \
908 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 883 TYPE_SCTP_FUNC(sctp_sf_bug), \
909 /* SCTP_STATE_CLOSED */ \ 884 /* SCTP_STATE_CLOSED */ \
910 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 885 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
911 /* SCTP_STATE_COOKIE_WAIT */ \ 886 /* SCTP_STATE_COOKIE_WAIT */ \
912 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 887 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
913 /* SCTP_STATE_COOKIE_ECHOED */ \ 888 /* SCTP_STATE_COOKIE_ECHOED */ \
914 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 889 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
915 /* SCTP_STATE_ESTABLISHED */ \ 890 /* SCTP_STATE_ESTABLISHED */ \
916 {.fn = sctp_sf_sendbeat_8_3, .name = "sctp_sf_sendbeat_8_3"}, \ 891 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
917 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 892 /* SCTP_STATE_SHUTDOWN_PENDING */ \
918 {.fn = sctp_sf_sendbeat_8_3, .name = "sctp_sf_sendbeat_8_3"}, \ 893 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
919 /* SCTP_STATE_SHUTDOWN_SENT */ \ 894 /* SCTP_STATE_SHUTDOWN_SENT */ \
920 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 895 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
921 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 896 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
922 {.fn = sctp_sf_sendbeat_8_3, .name = "sctp_sf_sendbeat_8_3"}, \ 897 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
923 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 898 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
924 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 899 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
925} 900}
926 901
927#define TYPE_SCTP_EVENT_TIMEOUT_SACK { \ 902#define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
928 /* SCTP_STATE_EMPTY */ \ 903 /* SCTP_STATE_EMPTY */ \
929 {.fn = sctp_sf_bug, .name = "sctp_sf_bug"}, \ 904 TYPE_SCTP_FUNC(sctp_sf_bug), \
930 /* SCTP_STATE_CLOSED */ \ 905 /* SCTP_STATE_CLOSED */ \
931 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 906 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
932 /* SCTP_STATE_COOKIE_WAIT */ \ 907 /* SCTP_STATE_COOKIE_WAIT */ \
933 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 908 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
934 /* SCTP_STATE_COOKIE_ECHOED */ \ 909 /* SCTP_STATE_COOKIE_ECHOED */ \
935 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 910 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
936 /* SCTP_STATE_ESTABLISHED */ \ 911 /* SCTP_STATE_ESTABLISHED */ \
937 {.fn = sctp_sf_do_6_2_sack, .name = "sctp_sf_do_6_2_sack"}, \ 912 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
938 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 913 /* SCTP_STATE_SHUTDOWN_PENDING */ \
939 {.fn = sctp_sf_do_6_2_sack, .name = "sctp_sf_do_6_2_sack"}, \ 914 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
940 /* SCTP_STATE_SHUTDOWN_SENT */ \ 915 /* SCTP_STATE_SHUTDOWN_SENT */ \
941 {.fn = sctp_sf_do_6_2_sack, .name = "sctp_sf_do_6_2_sack"}, \ 916 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
942 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 917 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
943 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 918 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
944 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 919 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
945 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 920 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
946} 921}
947 922
948#define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \ 923#define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
949 /* SCTP_STATE_EMPTY */ \ 924 /* SCTP_STATE_EMPTY */ \
950 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 925 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
951 /* SCTP_STATE_CLOSED */ \ 926 /* SCTP_STATE_CLOSED */ \
952 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 927 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
953 /* SCTP_STATE_COOKIE_WAIT */ \ 928 /* SCTP_STATE_COOKIE_WAIT */ \
954 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 929 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
955 /* SCTP_STATE_COOKIE_ECHOED */ \ 930 /* SCTP_STATE_COOKIE_ECHOED */ \
956 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 931 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
957 /* SCTP_STATE_ESTABLISHED */ \ 932 /* SCTP_STATE_ESTABLISHED */ \
958 {.fn = sctp_sf_autoclose_timer_expire, \ 933 TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
959 .name = "sctp_sf_autoclose_timer_expire"}, \
960 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 934 /* SCTP_STATE_SHUTDOWN_PENDING */ \
961 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 935 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
962 /* SCTP_STATE_SHUTDOWN_SENT */ \ 936 /* SCTP_STATE_SHUTDOWN_SENT */ \
963 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 937 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
964 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \ 938 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
965 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 939 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
966 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \ 940 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
967 {.fn = sctp_sf_timer_ignore, .name = "sctp_sf_timer_ignore"}, \ 941 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
968} 942}
969 943
970static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = { 944static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 935bc9187fd8..02b27145b279 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -229,11 +229,9 @@ static struct sctp_transport *sctp_addr_id2transport(struct sock *sk,
229 struct sctp_transport *transport; 229 struct sctp_transport *transport;
230 union sctp_addr *laddr = (union sctp_addr *)addr; 230 union sctp_addr *laddr = (union sctp_addr *)addr;
231 231
232 laddr->v4.sin_port = ntohs(laddr->v4.sin_port);
233 addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep, 232 addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep,
234 (union sctp_addr *)addr, 233 laddr,
235 &transport); 234 &transport);
236 laddr->v4.sin_port = htons(laddr->v4.sin_port);
237 235
238 if (!addr_asoc) 236 if (!addr_asoc)
239 return NULL; 237 return NULL;
@@ -368,9 +366,7 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
368 sctp_write_lock(&ep->base.addr_lock); 366 sctp_write_lock(&ep->base.addr_lock);
369 367
370 /* Use GFP_ATOMIC since BHs are disabled. */ 368 /* Use GFP_ATOMIC since BHs are disabled. */
371 addr->v4.sin_port = ntohs(addr->v4.sin_port);
372 ret = sctp_add_bind_addr(bp, addr, 1, GFP_ATOMIC); 369 ret = sctp_add_bind_addr(bp, addr, 1, GFP_ATOMIC);
373 addr->v4.sin_port = htons(addr->v4.sin_port);
374 sctp_write_unlock(&ep->base.addr_lock); 370 sctp_write_unlock(&ep->base.addr_lock);
375 sctp_local_bh_enable(); 371 sctp_local_bh_enable();
376 372
@@ -572,7 +568,6 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
572 addr = (union sctp_addr *)addr_buf; 568 addr = (union sctp_addr *)addr_buf;
573 af = sctp_get_af_specific(addr->v4.sin_family); 569 af = sctp_get_af_specific(addr->v4.sin_family);
574 memcpy(&saveaddr, addr, af->sockaddr_len); 570 memcpy(&saveaddr, addr, af->sockaddr_len);
575 saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port);
576 retval = sctp_add_bind_addr(bp, &saveaddr, 0, 571 retval = sctp_add_bind_addr(bp, &saveaddr, 0,
577 GFP_ATOMIC); 572 GFP_ATOMIC);
578 addr_buf += af->sockaddr_len; 573 addr_buf += af->sockaddr_len;
@@ -607,9 +602,8 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr *addrs, int addrcnt)
607 int cnt; 602 int cnt;
608 struct sctp_bind_addr *bp = &ep->base.bind_addr; 603 struct sctp_bind_addr *bp = &ep->base.bind_addr;
609 int retval = 0; 604 int retval = 0;
610 union sctp_addr saveaddr;
611 void *addr_buf; 605 void *addr_buf;
612 struct sockaddr *sa_addr; 606 union sctp_addr *sa_addr;
613 struct sctp_af *af; 607 struct sctp_af *af;
614 608
615 SCTP_DEBUG_PRINTK("sctp_bindx_rem (sk: %p, addrs: %p, addrcnt: %d)\n", 609 SCTP_DEBUG_PRINTK("sctp_bindx_rem (sk: %p, addrs: %p, addrcnt: %d)\n",
@@ -627,19 +621,13 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr *addrs, int addrcnt)
627 goto err_bindx_rem; 621 goto err_bindx_rem;
628 } 622 }
629 623
630 /* The list may contain either IPv4 or IPv6 address; 624 sa_addr = (union sctp_addr *)addr_buf;
631 * determine the address length to copy the address to 625 af = sctp_get_af_specific(sa_addr->sa.sa_family);
632 * saveaddr.
633 */
634 sa_addr = (struct sockaddr *)addr_buf;
635 af = sctp_get_af_specific(sa_addr->sa_family);
636 if (!af) { 626 if (!af) {
637 retval = -EINVAL; 627 retval = -EINVAL;
638 goto err_bindx_rem; 628 goto err_bindx_rem;
639 } 629 }
640 memcpy(&saveaddr, sa_addr, af->sockaddr_len); 630 if (sa_addr->v4.sin_port != htons(bp->port)) {
641 saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port);
642 if (saveaddr.v4.sin_port != bp->port) {
643 retval = -EINVAL; 631 retval = -EINVAL;
644 goto err_bindx_rem; 632 goto err_bindx_rem;
645 } 633 }
@@ -654,7 +642,7 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr *addrs, int addrcnt)
654 sctp_local_bh_disable(); 642 sctp_local_bh_disable();
655 sctp_write_lock(&ep->base.addr_lock); 643 sctp_write_lock(&ep->base.addr_lock);
656 644
657 retval = sctp_del_bind_addr(bp, &saveaddr); 645 retval = sctp_del_bind_addr(bp, sa_addr);
658 646
659 sctp_write_unlock(&ep->base.addr_lock); 647 sctp_write_unlock(&ep->base.addr_lock);
660 sctp_local_bh_enable(); 648 sctp_local_bh_enable();
@@ -693,7 +681,6 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
693 struct sctp_bind_addr *bp; 681 struct sctp_bind_addr *bp;
694 struct sctp_chunk *chunk; 682 struct sctp_chunk *chunk;
695 union sctp_addr *laddr; 683 union sctp_addr *laddr;
696 union sctp_addr saveaddr;
697 void *addr_buf; 684 void *addr_buf;
698 struct sctp_af *af; 685 struct sctp_af *af;
699 struct list_head *pos, *pos1; 686 struct list_head *pos, *pos1;
@@ -773,13 +760,11 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
773 for (i = 0; i < addrcnt; i++) { 760 for (i = 0; i < addrcnt; i++) {
774 laddr = (union sctp_addr *)addr_buf; 761 laddr = (union sctp_addr *)addr_buf;
775 af = sctp_get_af_specific(laddr->v4.sin_family); 762 af = sctp_get_af_specific(laddr->v4.sin_family);
776 memcpy(&saveaddr, laddr, af->sockaddr_len);
777 saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port);
778 list_for_each(pos1, &bp->address_list) { 763 list_for_each(pos1, &bp->address_list) {
779 saddr = list_entry(pos1, 764 saddr = list_entry(pos1,
780 struct sctp_sockaddr_entry, 765 struct sctp_sockaddr_entry,
781 list); 766 list);
782 if (sctp_cmp_addr_exact(&saddr->a, &saveaddr)) 767 if (sctp_cmp_addr_exact(&saddr->a, laddr))
783 saddr->use_as_src = 0; 768 saddr->use_as_src = 0;
784 } 769 }
785 addr_buf += af->sockaddr_len; 770 addr_buf += af->sockaddr_len;
@@ -979,7 +964,7 @@ static int __sctp_connect(struct sock* sk,
979 int err = 0; 964 int err = 0;
980 int addrcnt = 0; 965 int addrcnt = 0;
981 int walk_size = 0; 966 int walk_size = 0;
982 struct sockaddr *sa_addr; 967 union sctp_addr *sa_addr;
983 void *addr_buf; 968 void *addr_buf;
984 969
985 sp = sctp_sk(sk); 970 sp = sctp_sk(sk);
@@ -999,8 +984,8 @@ static int __sctp_connect(struct sock* sk,
999 /* Walk through the addrs buffer and count the number of addresses. */ 984 /* Walk through the addrs buffer and count the number of addresses. */
1000 addr_buf = kaddrs; 985 addr_buf = kaddrs;
1001 while (walk_size < addrs_size) { 986 while (walk_size < addrs_size) {
1002 sa_addr = (struct sockaddr *)addr_buf; 987 sa_addr = (union sctp_addr *)addr_buf;
1003 af = sctp_get_af_specific(sa_addr->sa_family); 988 af = sctp_get_af_specific(sa_addr->sa.sa_family);
1004 989
1005 /* If the address family is not supported or if this address 990 /* If the address family is not supported or if this address
1006 * causes the address buffer to overflow return EINVAL. 991 * causes the address buffer to overflow return EINVAL.
@@ -1010,18 +995,16 @@ static int __sctp_connect(struct sock* sk,
1010 goto out_free; 995 goto out_free;
1011 } 996 }
1012 997
1013 err = sctp_verify_addr(sk, (union sctp_addr *)sa_addr, 998 err = sctp_verify_addr(sk, sa_addr, af->sockaddr_len);
1014 af->sockaddr_len);
1015 if (err) 999 if (err)
1016 goto out_free; 1000 goto out_free;
1017 1001
1018 memcpy(&to, sa_addr, af->sockaddr_len); 1002 memcpy(&to, sa_addr, af->sockaddr_len);
1019 to.v4.sin_port = ntohs(to.v4.sin_port);
1020 1003
1021 /* Check if there already is a matching association on the 1004 /* Check if there already is a matching association on the
1022 * endpoint (other than the one created here). 1005 * endpoint (other than the one created here).
1023 */ 1006 */
1024 asoc2 = sctp_endpoint_lookup_assoc(ep, &to, &transport); 1007 asoc2 = sctp_endpoint_lookup_assoc(ep, sa_addr, &transport);
1025 if (asoc2 && asoc2 != asoc) { 1008 if (asoc2 && asoc2 != asoc) {
1026 if (asoc2->state >= SCTP_STATE_ESTABLISHED) 1009 if (asoc2->state >= SCTP_STATE_ESTABLISHED)
1027 err = -EISCONN; 1010 err = -EISCONN;
@@ -1034,7 +1017,7 @@ static int __sctp_connect(struct sock* sk,
1034 * make sure that there is no peeled-off association matching 1017 * make sure that there is no peeled-off association matching
1035 * the peer address even on another socket. 1018 * the peer address even on another socket.
1036 */ 1019 */
1037 if (sctp_endpoint_is_peeled_off(ep, &to)) { 1020 if (sctp_endpoint_is_peeled_off(ep, sa_addr)) {
1038 err = -EADDRNOTAVAIL; 1021 err = -EADDRNOTAVAIL;
1039 goto out_free; 1022 goto out_free;
1040 } 1023 }
@@ -1065,7 +1048,7 @@ static int __sctp_connect(struct sock* sk,
1065 } 1048 }
1066 } 1049 }
1067 1050
1068 scope = sctp_scope(&to); 1051 scope = sctp_scope(sa_addr);
1069 asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL); 1052 asoc = sctp_association_new(ep, sk, scope, GFP_KERNEL);
1070 if (!asoc) { 1053 if (!asoc) {
1071 err = -ENOMEM; 1054 err = -ENOMEM;
@@ -1074,7 +1057,7 @@ static int __sctp_connect(struct sock* sk,
1074 } 1057 }
1075 1058
1076 /* Prime the peer's transport structures. */ 1059 /* Prime the peer's transport structures. */
1077 transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, 1060 transport = sctp_assoc_add_peer(asoc, sa_addr, GFP_KERNEL,
1078 SCTP_UNKNOWN); 1061 SCTP_UNKNOWN);
1079 if (!transport) { 1062 if (!transport) {
1080 err = -ENOMEM; 1063 err = -ENOMEM;
@@ -1427,11 +1410,6 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1427 if (msg_namelen > sizeof(to)) 1410 if (msg_namelen > sizeof(to))
1428 msg_namelen = sizeof(to); 1411 msg_namelen = sizeof(to);
1429 memcpy(&to, msg->msg_name, msg_namelen); 1412 memcpy(&to, msg->msg_name, msg_namelen);
1430 SCTP_DEBUG_PRINTK("Just memcpy'd. msg_name is "
1431 "0x%x:%u.\n",
1432 to.v4.sin_addr.s_addr, to.v4.sin_port);
1433
1434 to.v4.sin_port = ntohs(to.v4.sin_port);
1435 msg_name = msg->msg_name; 1413 msg_name = msg->msg_name;
1436 } 1414 }
1437 1415
@@ -3217,8 +3195,8 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len,
3217 status.sstat_outstrms = asoc->c.sinit_num_ostreams; 3195 status.sstat_outstrms = asoc->c.sinit_num_ostreams;
3218 status.sstat_fragmentation_point = asoc->frag_point; 3196 status.sstat_fragmentation_point = asoc->frag_point;
3219 status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc); 3197 status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
3220 memcpy(&status.sstat_primary.spinfo_address, 3198 memcpy(&status.sstat_primary.spinfo_address, &transport->ipaddr,
3221 &(transport->ipaddr), sizeof(union sctp_addr)); 3199 transport->af_specific->sockaddr_len);
3222 /* Map ipv4 address into v4-mapped-on-v6 address. */ 3200 /* Map ipv4 address into v4-mapped-on-v6 address. */
3223 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), 3201 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
3224 (union sctp_addr *)&status.sstat_primary.spinfo_address); 3202 (union sctp_addr *)&status.sstat_primary.spinfo_address);
@@ -3770,7 +3748,6 @@ static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
3770 memcpy(&temp, &from->ipaddr, sizeof(temp)); 3748 memcpy(&temp, &from->ipaddr, sizeof(temp));
3771 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 3749 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
3772 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; 3750 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
3773 temp.v4.sin_port = htons(temp.v4.sin_port);
3774 if (copy_to_user(to, &temp, addrlen)) 3751 if (copy_to_user(to, &temp, addrlen))
3775 return -EFAULT; 3752 return -EFAULT;
3776 to += addrlen ; 3753 to += addrlen ;
@@ -3821,7 +3798,6 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
3821 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; 3798 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
3822 if(space_left < addrlen) 3799 if(space_left < addrlen)
3823 return -ENOMEM; 3800 return -ENOMEM;
3824 temp.v4.sin_port = htons(temp.v4.sin_port);
3825 if (copy_to_user(to, &temp, addrlen)) 3801 if (copy_to_user(to, &temp, addrlen))
3826 return -EFAULT; 3802 return -EFAULT;
3827 to += addrlen; 3803 to += addrlen;
@@ -3889,7 +3865,7 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
3889 struct sctp_sockaddr_entry, 3865 struct sctp_sockaddr_entry,
3890 list); 3866 list);
3891 if ((PF_INET == sk->sk_family) && 3867 if ((PF_INET == sk->sk_family) &&
3892 (AF_INET6 == addr->a.sa.sa_family)) 3868 (AF_INET6 == addr->a.sa.sa_family))
3893 continue; 3869 continue;
3894 cnt++; 3870 cnt++;
3895 } 3871 }
@@ -3933,7 +3909,6 @@ static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_add
3933 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), 3909 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
3934 &temp); 3910 &temp);
3935 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 3911 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
3936 temp.v4.sin_port = htons(port);
3937 if (copy_to_user(to, &temp, addrlen)) { 3912 if (copy_to_user(to, &temp, addrlen)) {
3938 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, 3913 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock,
3939 flags); 3914 flags);
@@ -3970,7 +3945,6 @@ static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port,
3970 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 3945 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
3971 if(space_left<addrlen) 3946 if(space_left<addrlen)
3972 return -ENOMEM; 3947 return -ENOMEM;
3973 temp.v4.sin_port = htons(port);
3974 if (copy_to_user(*to, &temp, addrlen)) { 3948 if (copy_to_user(*to, &temp, addrlen)) {
3975 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, 3949 sctp_spin_unlock_irqrestore(&sctp_local_addr_lock,
3976 flags); 3950 flags);
@@ -4055,7 +4029,6 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4055 memcpy(&temp, &addr->a, sizeof(temp)); 4029 memcpy(&temp, &addr->a, sizeof(temp));
4056 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4030 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4057 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 4031 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
4058 temp.v4.sin_port = htons(temp.v4.sin_port);
4059 if (copy_to_user(to, &temp, addrlen)) { 4032 if (copy_to_user(to, &temp, addrlen)) {
4060 err = -EFAULT; 4033 err = -EFAULT;
4061 goto unlock; 4034 goto unlock;
@@ -4146,7 +4119,6 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4146 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; 4119 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
4147 if(space_left < addrlen) 4120 if(space_left < addrlen)
4148 return -ENOMEM; /*fixme: right error?*/ 4121 return -ENOMEM; /*fixme: right error?*/
4149 temp.v4.sin_port = htons(temp.v4.sin_port);
4150 if (copy_to_user(to, &temp, addrlen)) { 4122 if (copy_to_user(to, &temp, addrlen)) {
4151 err = -EFAULT; 4123 err = -EFAULT;
4152 goto unlock; 4124 goto unlock;
@@ -4194,12 +4166,8 @@ static int sctp_getsockopt_primary_addr(struct sock *sk, int len,
4194 if (!asoc->peer.primary_path) 4166 if (!asoc->peer.primary_path)
4195 return -ENOTCONN; 4167 return -ENOTCONN;
4196 4168
4197 asoc->peer.primary_path->ipaddr.v4.sin_port =
4198 htons(asoc->peer.primary_path->ipaddr.v4.sin_port);
4199 memcpy(&prim.ssp_addr, &asoc->peer.primary_path->ipaddr, 4169 memcpy(&prim.ssp_addr, &asoc->peer.primary_path->ipaddr,
4200 sizeof(union sctp_addr)); 4170 asoc->peer.primary_path->af_specific->sockaddr_len);
4201 asoc->peer.primary_path->ipaddr.v4.sin_port =
4202 ntohs(asoc->peer.primary_path->ipaddr.v4.sin_port);
4203 4171
4204 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, 4172 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp,
4205 (union sctp_addr *)&prim.ssp_addr); 4173 (union sctp_addr *)&prim.ssp_addr);
@@ -4645,9 +4613,7 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
4645 unsigned short snum; 4613 unsigned short snum;
4646 int ret; 4614 int ret;
4647 4615
4648 /* NOTE: Remember to put this back to net order. */ 4616 snum = ntohs(addr->v4.sin_port);
4649 addr->v4.sin_port = ntohs(addr->v4.sin_port);
4650 snum = addr->v4.sin_port;
4651 4617
4652 SCTP_DEBUG_PRINTK("sctp_get_port() begins, snum=%d\n", snum); 4618 SCTP_DEBUG_PRINTK("sctp_get_port() begins, snum=%d\n", snum);
4653 sctp_local_bh_disable(); 4619 sctp_local_bh_disable();
@@ -4784,7 +4750,6 @@ fail_unlock:
4784 4750
4785fail: 4751fail:
4786 sctp_local_bh_enable(); 4752 sctp_local_bh_enable();
4787 addr->v4.sin_port = htons(addr->v4.sin_port);
4788 return ret; 4753 return ret;
4789} 4754}
4790 4755
@@ -5083,7 +5048,7 @@ static int sctp_autobind(struct sock *sk)
5083{ 5048{
5084 union sctp_addr autoaddr; 5049 union sctp_addr autoaddr;
5085 struct sctp_af *af; 5050 struct sctp_af *af;
5086 unsigned short port; 5051 __be16 port;
5087 5052
5088 /* Initialize a local sockaddr structure to INADDR_ANY. */ 5053 /* Initialize a local sockaddr structure to INADDR_ANY. */
5089 af = sctp_sk(sk)->pf->af; 5054 af = sctp_sk(sk)->pf->af;
diff --git a/net/sctp/tsnmap.c b/net/sctp/tsnmap.c
index ac4fae161bc7..42d9498c64fa 100644
--- a/net/sctp/tsnmap.c
+++ b/net/sctp/tsnmap.c
@@ -401,13 +401,14 @@ __u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map)
401 401
402 /* Refresh the gap ack information. */ 402 /* Refresh the gap ack information. */
403 if (sctp_tsnmap_has_gap(map)) { 403 if (sctp_tsnmap_has_gap(map)) {
404 __u16 start, end;
404 sctp_tsnmap_iter_init(map, &iter); 405 sctp_tsnmap_iter_init(map, &iter);
405 while (sctp_tsnmap_next_gap_ack(map, &iter, 406 while (sctp_tsnmap_next_gap_ack(map, &iter,
406 &map->gabs[gabs].start, 407 &start,
407 &map->gabs[gabs].end)) { 408 &end)) {
408 409
409 map->gabs[gabs].start = htons(map->gabs[gabs].start); 410 map->gabs[gabs].start = htons(start);
410 map->gabs[gabs].end = htons(map->gabs[gabs].end); 411 map->gabs[gabs].end = htons(end);
411 gabs++; 412 gabs++;
412 if (gabs >= SCTP_MAX_GABS) 413 if (gabs >= SCTP_MAX_GABS)
413 break; 414 break;
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index a015283a9087..e255a709f1b7 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -351,7 +351,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
351 struct sctp_remote_error *sre; 351 struct sctp_remote_error *sre;
352 struct sk_buff *skb; 352 struct sk_buff *skb;
353 sctp_errhdr_t *ch; 353 sctp_errhdr_t *ch;
354 __u16 cause; 354 __be16 cause;
355 int elen; 355 int elen;
356 356
357 ch = (sctp_errhdr_t *)(chunk->skb->data); 357 ch = (sctp_errhdr_t *)(chunk->skb->data);
diff --git a/net/socket.c b/net/socket.c
index 6c9b9b326d76..e8db54702a69 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -77,7 +77,6 @@
77#include <linux/cache.h> 77#include <linux/cache.h>
78#include <linux/module.h> 78#include <linux/module.h>
79#include <linux/highmem.h> 79#include <linux/highmem.h>
80#include <linux/divert.h>
81#include <linux/mount.h> 80#include <linux/mount.h>
82#include <linux/security.h> 81#include <linux/security.h>
83#include <linux/syscalls.h> 82#include <linux/syscalls.h>
@@ -852,11 +851,6 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
852 err = vlan_ioctl_hook(argp); 851 err = vlan_ioctl_hook(argp);
853 mutex_unlock(&vlan_ioctl_mutex); 852 mutex_unlock(&vlan_ioctl_mutex);
854 break; 853 break;
855 case SIOCGIFDIVERT:
856 case SIOCSIFDIVERT:
857 /* Convert this to call through a hook */
858 err = divert_ioctl(cmd, argp);
859 break;
860 case SIOCADDDLCI: 854 case SIOCADDDLCI:
861 case SIOCDELDLCI: 855 case SIOCDELDLCI:
862 err = -ENOPKG; 856 err = -ENOPKG;
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index b36b9463f5a4..e5a84a482e57 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -198,11 +198,10 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest)
198 q = (const void *)((const char *)p + len); 198 q = (const void *)((const char *)p + len);
199 if (unlikely(q > end || q < p)) 199 if (unlikely(q > end || q < p))
200 return ERR_PTR(-EFAULT); 200 return ERR_PTR(-EFAULT);
201 dest->data = kmalloc(len, GFP_KERNEL); 201 dest->data = kmemdup(p, len, GFP_KERNEL);
202 if (unlikely(dest->data == NULL)) 202 if (unlikely(dest->data == NULL))
203 return ERR_PTR(-ENOMEM); 203 return ERR_PTR(-ENOMEM);
204 dest->len = len; 204 dest->len = len;
205 memcpy(dest->data, p, len);
206 return q; 205 return q;
207} 206}
208 207
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c
index 325e72e4fd31..754b8cd6439f 100644
--- a/net/sunrpc/auth_gss/gss_krb5_mech.c
+++ b/net/sunrpc/auth_gss/gss_krb5_mech.c
@@ -70,10 +70,9 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res)
70 q = (const void *)((const char *)p + len); 70 q = (const void *)((const char *)p + len);
71 if (unlikely(q > end || q < p)) 71 if (unlikely(q > end || q < p))
72 return ERR_PTR(-EFAULT); 72 return ERR_PTR(-EFAULT);
73 res->data = kmalloc(len, GFP_KERNEL); 73 res->data = kmemdup(p, len, GFP_KERNEL);
74 if (unlikely(res->data == NULL)) 74 if (unlikely(res->data == NULL))
75 return ERR_PTR(-ENOMEM); 75 return ERR_PTR(-ENOMEM);
76 memcpy(res->data, p, len);
77 res->len = len; 76 res->len = len;
78 return q; 77 return q;
79} 78}
diff --git a/net/sunrpc/auth_gss/gss_spkm3_mech.c b/net/sunrpc/auth_gss/gss_spkm3_mech.c
index bdedf456bc17..d57f60838895 100644
--- a/net/sunrpc/auth_gss/gss_spkm3_mech.c
+++ b/net/sunrpc/auth_gss/gss_spkm3_mech.c
@@ -76,10 +76,9 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res)
76 q = (const void *)((const char *)p + len); 76 q = (const void *)((const char *)p + len);
77 if (unlikely(q > end || q < p)) 77 if (unlikely(q > end || q < p))
78 return ERR_PTR(-EFAULT); 78 return ERR_PTR(-EFAULT);
79 res->data = kmalloc(len, GFP_KERNEL); 79 res->data = kmemdup(p, len, GFP_KERNEL);
80 if (unlikely(res->data == NULL)) 80 if (unlikely(res->data == NULL))
81 return ERR_PTR(-ENOMEM); 81 return ERR_PTR(-ENOMEM);
82 memcpy(res->data, p, len);
83 return q; 82 return q;
84} 83}
85 84
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 1f0f079ffa65..700353b330fd 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -113,9 +113,7 @@ static int rsi_match(struct cache_head *a, struct cache_head *b)
113static int dup_to_netobj(struct xdr_netobj *dst, char *src, int len) 113static int dup_to_netobj(struct xdr_netobj *dst, char *src, int len)
114{ 114{
115 dst->len = len; 115 dst->len = len;
116 dst->data = (len ? kmalloc(len, GFP_KERNEL) : NULL); 116 dst->data = (len ? kmemdup(src, len, GFP_KERNEL) : NULL);
117 if (dst->data)
118 memcpy(dst->data, src, len);
119 if (len && !dst->data) 117 if (len && !dst->data)
120 return -ENOMEM; 118 return -ENOMEM;
121 return 0; 119 return 0;
@@ -756,10 +754,9 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
756 if (!new) 754 if (!new)
757 goto out; 755 goto out;
758 kref_init(&new->h.ref); 756 kref_init(&new->h.ref);
759 new->h.name = kmalloc(strlen(name) + 1, GFP_KERNEL); 757 new->h.name = kstrdup(name, GFP_KERNEL);
760 if (!new->h.name) 758 if (!new->h.name)
761 goto out_free_dom; 759 goto out_free_dom;
762 strcpy(new->h.name, name);
763 new->h.flavour = &svcauthops_gss; 760 new->h.flavour = &svcauthops_gss;
764 new->pseudoflavor = pseudoflavor; 761 new->pseudoflavor = pseudoflavor;
765 762
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 78696f2dc7d6..dfeea4fea95a 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -253,10 +253,9 @@ rpc_clone_client(struct rpc_clnt *clnt)
253{ 253{
254 struct rpc_clnt *new; 254 struct rpc_clnt *new;
255 255
256 new = kmalloc(sizeof(*new), GFP_KERNEL); 256 new = kmemdup(clnt, sizeof(*new), GFP_KERNEL);
257 if (!new) 257 if (!new)
258 goto out_no_clnt; 258 goto out_no_clnt;
259 memcpy(new, clnt, sizeof(*new));
260 atomic_set(&new->cl_count, 1); 259 atomic_set(&new->cl_count, 1);
261 atomic_set(&new->cl_users, 0); 260 atomic_set(&new->cl_users, 0);
262 new->cl_parent = clnt; 261 new->cl_parent = clnt;
diff --git a/net/sunrpc/socklib.c b/net/sunrpc/socklib.c
index 6f17527b9e69..2635c543ba06 100644
--- a/net/sunrpc/socklib.c
+++ b/net/sunrpc/socklib.c
@@ -45,7 +45,8 @@ static size_t skb_read_bits(skb_reader_t *desc, void *to, size_t len)
45 */ 45 */
46static size_t skb_read_and_csum_bits(skb_reader_t *desc, void *to, size_t len) 46static size_t skb_read_and_csum_bits(skb_reader_t *desc, void *to, size_t len)
47{ 47{
48 unsigned int csum2, pos; 48 unsigned int pos;
49 __wsum csum2;
49 50
50 if (len > desc->count) 51 if (len > desc->count)
51 len = desc->count; 52 len = desc->count;
@@ -160,13 +161,13 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
160 if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_and_csum_bits) < 0) 161 if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_and_csum_bits) < 0)
161 return -1; 162 return -1;
162 if (desc.offset != skb->len) { 163 if (desc.offset != skb->len) {
163 unsigned int csum2; 164 __wsum csum2;
164 csum2 = skb_checksum(skb, desc.offset, skb->len - desc.offset, 0); 165 csum2 = skb_checksum(skb, desc.offset, skb->len - desc.offset, 0);
165 desc.csum = csum_block_add(desc.csum, csum2, desc.offset); 166 desc.csum = csum_block_add(desc.csum, csum2, desc.offset);
166 } 167 }
167 if (desc.count) 168 if (desc.count)
168 return -1; 169 return -1;
169 if ((unsigned short)csum_fold(desc.csum)) 170 if (csum_fold(desc.csum))
170 return -1; 171 return -1;
171 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) 172 if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
172 netdev_rx_csum_fault(skb->dev); 173 netdev_rx_csum_fault(skb->dev);
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index e1bd933629fe..a0a953a430c2 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -101,9 +101,9 @@ static void ip_map_put(struct kref *kref)
101 * IP addresses in reverse-endian (i.e. on a little-endian machine). 101 * IP addresses in reverse-endian (i.e. on a little-endian machine).
102 * So use a trivial but reliable hash instead 102 * So use a trivial but reliable hash instead
103 */ 103 */
104static inline int hash_ip(unsigned long ip) 104static inline int hash_ip(__be32 ip)
105{ 105{
106 int hash = ip ^ (ip>>16); 106 int hash = (__force u32)ip ^ ((__force u32)ip>>16);
107 return (hash ^ (hash>>8)) & 0xff; 107 return (hash ^ (hash>>8)) & 0xff;
108} 108}
109#endif 109#endif
@@ -284,7 +284,7 @@ static struct ip_map *ip_map_lookup(char *class, struct in_addr addr)
284 ip.m_addr = addr; 284 ip.m_addr = addr;
285 ch = sunrpc_cache_lookup(&ip_map_cache, &ip.h, 285 ch = sunrpc_cache_lookup(&ip_map_cache, &ip.h,
286 hash_str(class, IP_HASHBITS) ^ 286 hash_str(class, IP_HASHBITS) ^
287 hash_ip((unsigned long)addr.s_addr)); 287 hash_ip(addr.s_addr));
288 288
289 if (ch) 289 if (ch)
290 return container_of(ch, struct ip_map, h); 290 return container_of(ch, struct ip_map, h);
@@ -313,7 +313,7 @@ static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t ex
313 ch = sunrpc_cache_update(&ip_map_cache, 313 ch = sunrpc_cache_update(&ip_map_cache,
314 &ip.h, &ipm->h, 314 &ip.h, &ipm->h,
315 hash_str(ipm->m_class, IP_HASHBITS) ^ 315 hash_str(ipm->m_class, IP_HASHBITS) ^
316 hash_ip((unsigned long)ipm->m_addr.s_addr)); 316 hash_ip(ipm->m_addr.s_addr));
317 if (!ch) 317 if (!ch)
318 return -ENOMEM; 318 return -ENOMEM;
319 cache_put(ch, &ip_map_cache); 319 cache_put(ch, &ip_map_cache);
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 1bb75703f384..730c5c47ed8d 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -774,8 +774,8 @@ int tipc_bclink_set_queue_limits(u32 limit)
774 774
775int tipc_bclink_init(void) 775int tipc_bclink_init(void)
776{ 776{
777 bcbearer = kmalloc(sizeof(*bcbearer), GFP_ATOMIC); 777 bcbearer = kzalloc(sizeof(*bcbearer), GFP_ATOMIC);
778 bclink = kmalloc(sizeof(*bclink), GFP_ATOMIC); 778 bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC);
779 if (!bcbearer || !bclink) { 779 if (!bcbearer || !bclink) {
780 nomem: 780 nomem:
781 warn("Multicast link creation failed, no memory\n"); 781 warn("Multicast link creation failed, no memory\n");
@@ -786,14 +786,12 @@ int tipc_bclink_init(void)
786 return -ENOMEM; 786 return -ENOMEM;
787 } 787 }
788 788
789 memset(bcbearer, 0, sizeof(struct bcbearer));
790 INIT_LIST_HEAD(&bcbearer->bearer.cong_links); 789 INIT_LIST_HEAD(&bcbearer->bearer.cong_links);
791 bcbearer->bearer.media = &bcbearer->media; 790 bcbearer->bearer.media = &bcbearer->media;
792 bcbearer->media.send_msg = tipc_bcbearer_send; 791 bcbearer->media.send_msg = tipc_bcbearer_send;
793 sprintf(bcbearer->media.name, "tipc-multicast"); 792 sprintf(bcbearer->media.name, "tipc-multicast");
794 793
795 bcl = &bclink->link; 794 bcl = &bclink->link;
796 memset(bclink, 0, sizeof(struct bclink));
797 INIT_LIST_HEAD(&bcl->waiting_ports); 795 INIT_LIST_HEAD(&bcl->waiting_ports);
798 bcl->next_out_no = 1; 796 bcl->next_out_no = 1;
799 spin_lock_init(&bclink->node.lock); 797 spin_lock_init(&bclink->node.lock);
diff --git a/net/tipc/config.c b/net/tipc/config.c
index ed1351ed05e1..458a2c46cef3 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -107,7 +107,7 @@ int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
107struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value) 107struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value)
108{ 108{
109 struct sk_buff *buf; 109 struct sk_buff *buf;
110 u32 value_net; 110 __be32 value_net;
111 111
112 buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(value))); 112 buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(value)));
113 if (buf) { 113 if (buf) {
@@ -284,8 +284,7 @@ static struct sk_buff *cfg_set_own_addr(void)
284 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 284 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
285 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 285 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
286 286
287 addr = *(u32 *)TLV_DATA(req_tlv_area); 287 addr = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
288 addr = ntohl(addr);
289 if (addr == tipc_own_addr) 288 if (addr == tipc_own_addr)
290 return tipc_cfg_reply_none(); 289 return tipc_cfg_reply_none();
291 if (!tipc_addr_node_valid(addr)) 290 if (!tipc_addr_node_valid(addr))
@@ -319,8 +318,7 @@ static struct sk_buff *cfg_set_remote_mng(void)
319 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 318 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
320 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 319 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
321 320
322 value = *(u32 *)TLV_DATA(req_tlv_area); 321 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
323 value = ntohl(value);
324 tipc_remote_management = (value != 0); 322 tipc_remote_management = (value != 0);
325 return tipc_cfg_reply_none(); 323 return tipc_cfg_reply_none();
326} 324}
@@ -332,8 +330,7 @@ static struct sk_buff *cfg_set_max_publications(void)
332 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 330 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
333 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 331 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
334 332
335 value = *(u32 *)TLV_DATA(req_tlv_area); 333 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
336 value = ntohl(value);
337 if (value != delimit(value, 1, 65535)) 334 if (value != delimit(value, 1, 65535))
338 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE 335 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
339 " (max publications must be 1-65535)"); 336 " (max publications must be 1-65535)");
@@ -348,8 +345,7 @@ static struct sk_buff *cfg_set_max_subscriptions(void)
348 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 345 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
349 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 346 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
350 347
351 value = *(u32 *)TLV_DATA(req_tlv_area); 348 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
352 value = ntohl(value);
353 if (value != delimit(value, 1, 65535)) 349 if (value != delimit(value, 1, 65535))
354 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE 350 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
355 " (max subscriptions must be 1-65535"); 351 " (max subscriptions must be 1-65535");
@@ -363,8 +359,7 @@ static struct sk_buff *cfg_set_max_ports(void)
363 359
364 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 360 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
365 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 361 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
366 value = *(u32 *)TLV_DATA(req_tlv_area); 362 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
367 value = ntohl(value);
368 if (value == tipc_max_ports) 363 if (value == tipc_max_ports)
369 return tipc_cfg_reply_none(); 364 return tipc_cfg_reply_none();
370 if (value != delimit(value, 127, 65535)) 365 if (value != delimit(value, 127, 65535))
@@ -383,8 +378,7 @@ static struct sk_buff *cfg_set_max_zones(void)
383 378
384 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 379 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
385 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 380 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
386 value = *(u32 *)TLV_DATA(req_tlv_area); 381 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
387 value = ntohl(value);
388 if (value == tipc_max_zones) 382 if (value == tipc_max_zones)
389 return tipc_cfg_reply_none(); 383 return tipc_cfg_reply_none();
390 if (value != delimit(value, 1, 255)) 384 if (value != delimit(value, 1, 255))
@@ -403,8 +397,7 @@ static struct sk_buff *cfg_set_max_clusters(void)
403 397
404 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 398 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
405 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 399 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
406 value = *(u32 *)TLV_DATA(req_tlv_area); 400 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
407 value = ntohl(value);
408 if (value != delimit(value, 1, 1)) 401 if (value != delimit(value, 1, 1))
409 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE 402 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
410 " (max clusters fixed at 1)"); 403 " (max clusters fixed at 1)");
@@ -417,8 +410,7 @@ static struct sk_buff *cfg_set_max_nodes(void)
417 410
418 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 411 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
419 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 412 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
420 value = *(u32 *)TLV_DATA(req_tlv_area); 413 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
421 value = ntohl(value);
422 if (value == tipc_max_nodes) 414 if (value == tipc_max_nodes)
423 return tipc_cfg_reply_none(); 415 return tipc_cfg_reply_none();
424 if (value != delimit(value, 8, 2047)) 416 if (value != delimit(value, 8, 2047))
@@ -437,8 +429,7 @@ static struct sk_buff *cfg_set_max_slaves(void)
437 429
438 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 430 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
439 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 431 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
440 value = *(u32 *)TLV_DATA(req_tlv_area); 432 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
441 value = ntohl(value);
442 if (value != 0) 433 if (value != 0)
443 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED 434 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
444 " (max secondary nodes fixed at 0)"); 435 " (max secondary nodes fixed at 0)");
@@ -451,8 +442,7 @@ static struct sk_buff *cfg_set_netid(void)
451 442
452 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 443 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
453 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 444 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
454 value = *(u32 *)TLV_DATA(req_tlv_area); 445 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
455 value = ntohl(value);
456 if (value == tipc_net_id) 446 if (value == tipc_net_id)
457 return tipc_cfg_reply_none(); 447 return tipc_cfg_reply_none();
458 if (value != delimit(value, 1, 9999)) 448 if (value != delimit(value, 1, 9999))
diff --git a/net/tipc/dbg.c b/net/tipc/dbg.c
index d8af4c28695d..627f99b7afdf 100644
--- a/net/tipc/dbg.c
+++ b/net/tipc/dbg.c
@@ -393,8 +393,7 @@ struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
393 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) 393 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
394 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 394 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
395 395
396 value = *(u32 *)TLV_DATA(req_tlv_area); 396 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
397 value = ntohl(value);
398 if (value != delimit(value, 0, 32768)) 397 if (value != delimit(value, 0, 32768))
399 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE 398 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
400 " (log size must be 0-32768)"); 399 " (log size must be 0-32768)");
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 03bd659c43ca..7bf87cb26ef3 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -66,11 +66,11 @@
66 */ 66 */
67 67
68struct distr_item { 68struct distr_item {
69 u32 type; 69 __be32 type;
70 u32 lower; 70 __be32 lower;
71 u32 upper; 71 __be32 upper;
72 u32 ref; 72 __be32 ref;
73 u32 key; 73 __be32 key;
74}; 74};
75 75
76/** 76/**
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 886bda5e88db..4111a31def79 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -60,7 +60,7 @@ struct node *tipc_node_create(u32 addr)
60 struct node *n_ptr; 60 struct node *n_ptr;
61 struct node **curr_node; 61 struct node **curr_node;
62 62
63 n_ptr = kmalloc(sizeof(*n_ptr),GFP_ATOMIC); 63 n_ptr = kzalloc(sizeof(*n_ptr),GFP_ATOMIC);
64 if (!n_ptr) { 64 if (!n_ptr) {
65 warn("Node creation failed, no memory\n"); 65 warn("Node creation failed, no memory\n");
66 return NULL; 66 return NULL;
@@ -75,7 +75,6 @@ struct node *tipc_node_create(u32 addr)
75 return NULL; 75 return NULL;
76 } 76 }
77 77
78 memset(n_ptr, 0, sizeof(*n_ptr));
79 n_ptr->addr = addr; 78 n_ptr->addr = addr;
80 spin_lock_init(&n_ptr->lock); 79 spin_lock_init(&n_ptr->lock);
81 INIT_LIST_HEAD(&n_ptr->nsub); 80 INIT_LIST_HEAD(&n_ptr->nsub);
@@ -597,8 +596,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
597 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 596 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
598 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 597 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
599 598
600 domain = *(u32 *)TLV_DATA(req_tlv_area); 599 domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
601 domain = ntohl(domain);
602 if (!tipc_addr_domain_valid(domain)) 600 if (!tipc_addr_domain_valid(domain))
603 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE 601 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
604 " (network address)"); 602 " (network address)");
@@ -642,8 +640,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
642 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) 640 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
643 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); 641 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
644 642
645 domain = *(u32 *)TLV_DATA(req_tlv_area); 643 domain = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
646 domain = ntohl(domain);
647 if (!tipc_addr_domain_valid(domain)) 644 if (!tipc_addr_domain_valid(domain))
648 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE 645 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
649 " (network address)"); 646 " (network address)");
@@ -664,8 +661,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
664 661
665 /* Add TLV for broadcast link */ 662 /* Add TLV for broadcast link */
666 663
667 link_info.dest = tipc_own_addr & 0xfffff00; 664 link_info.dest = htonl(tipc_own_addr & 0xfffff00);
668 link_info.dest = htonl(link_info.dest);
669 link_info.up = htonl(1); 665 link_info.up = htonl(1);
670 sprintf(link_info.str, tipc_bclink_name); 666 sprintf(link_info.str, tipc_bclink_name);
671 tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); 667 tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index 7a918f12a5df..ddade7388aa0 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -350,7 +350,7 @@ static void subscr_subscribe(struct tipc_subscr *s,
350 350
351 /* Allocate subscription object */ 351 /* Allocate subscription object */
352 352
353 sub = kmalloc(sizeof(*sub), GFP_ATOMIC); 353 sub = kzalloc(sizeof(*sub), GFP_ATOMIC);
354 if (!sub) { 354 if (!sub) {
355 warn("Subscription rejected, no memory\n"); 355 warn("Subscription rejected, no memory\n");
356 subscr_terminate(subscriber); 356 subscr_terminate(subscriber);
@@ -359,7 +359,6 @@ static void subscr_subscribe(struct tipc_subscr *s,
359 359
360 /* Initialize subscription object */ 360 /* Initialize subscription object */
361 361
362 memset(sub, 0, sizeof(*sub));
363 sub->seq.type = htohl(s->seq.type, subscriber->swap); 362 sub->seq.type = htohl(s->seq.type, subscriber->swap);
364 sub->seq.lower = htohl(s->seq.lower, subscriber->swap); 363 sub->seq.lower = htohl(s->seq.lower, subscriber->swap);
365 sub->seq.upper = htohl(s->seq.upper, subscriber->swap); 364 sub->seq.upper = htohl(s->seq.upper, subscriber->swap);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index b43a27828df5..2f208c7f4d43 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -151,8 +151,9 @@ static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb)
151 * each socket state is protected by separate rwlock. 151 * each socket state is protected by separate rwlock.
152 */ 152 */
153 153
154static inline unsigned unix_hash_fold(unsigned hash) 154static inline unsigned unix_hash_fold(__wsum n)
155{ 155{
156 unsigned hash = (__force unsigned)n;
156 hash ^= hash>>16; 157 hash ^= hash>>16;
157 hash ^= hash>>8; 158 hash ^= hash>>8;
158 return hash&(UNIX_HASH_SIZE-1); 159 return hash&(UNIX_HASH_SIZE-1);
diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c
index 6f39faa15832..c2059733e15a 100644
--- a/net/wanrouter/af_wanpipe.c
+++ b/net/wanrouter/af_wanpipe.c
@@ -13,7 +13,7 @@
13* Due Credit: 13* Due Credit:
14* Wanpipe socket layer is based on Packet and 14* Wanpipe socket layer is based on Packet and
15* the X25 socket layers. The above sockets were 15* the X25 socket layers. The above sockets were
16* used for the specific use of Sangoma Technoloiges 16* used for the specific use of Sangoma Technologies
17* API programs. 17* API programs.
18* Packet socket Authors: Ross Biro, Fred N. van Kempen and 18* Packet socket Authors: Ross Biro, Fred N. van Kempen and
19* Alan Cox. 19* Alan Cox.
@@ -23,7 +23,7 @@
23* Apr 25, 2000 Nenad Corbic o Added the ability to send zero length packets. 23* Apr 25, 2000 Nenad Corbic o Added the ability to send zero length packets.
24* Mar 13, 2000 Nenad Corbic o Added a tx buffer check via ioctl call. 24* Mar 13, 2000 Nenad Corbic o Added a tx buffer check via ioctl call.
25* Mar 06, 2000 Nenad Corbic o Fixed the corrupt sock lcn problem. 25* Mar 06, 2000 Nenad Corbic o Fixed the corrupt sock lcn problem.
26* Server and client applicaton can run 26* Server and client application can run
27* simultaneously without conflicts. 27* simultaneously without conflicts.
28* Feb 29, 2000 Nenad Corbic o Added support for PVC protocols, such as 28* Feb 29, 2000 Nenad Corbic o Added support for PVC protocols, such as
29* CHDLC, Frame Relay and HDLC API. 29* CHDLC, Frame Relay and HDLC API.
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index 9479659277ae..316211d9f17d 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -3,7 +3,7 @@
3* 3*
4* This module is completely hardware-independent and provides 4* This module is completely hardware-independent and provides
5* the following common services for the WAN Link Drivers: 5* the following common services for the WAN Link Drivers:
6* o WAN device managenment (registering, unregistering) 6* o WAN device management (registering, unregistering)
7* o Network interface management 7* o Network interface management
8* o Physical connection management (dial-up, incoming calls) 8* o Physical connection management (dial-up, incoming calls)
9* o Logical connection management (switched virtual circuits) 9* o Logical connection management (switched virtual circuits)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index ba924d40df7d..f6c77bd36fdd 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -50,6 +50,40 @@ static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo);
50static struct xfrm_policy_afinfo *xfrm_policy_lock_afinfo(unsigned int family); 50static struct xfrm_policy_afinfo *xfrm_policy_lock_afinfo(unsigned int family);
51static void xfrm_policy_unlock_afinfo(struct xfrm_policy_afinfo *afinfo); 51static void xfrm_policy_unlock_afinfo(struct xfrm_policy_afinfo *afinfo);
52 52
53static inline int
54__xfrm4_selector_match(struct xfrm_selector *sel, struct flowi *fl)
55{
56 return addr_match(&fl->fl4_dst, &sel->daddr, sel->prefixlen_d) &&
57 addr_match(&fl->fl4_src, &sel->saddr, sel->prefixlen_s) &&
58 !((xfrm_flowi_dport(fl) ^ sel->dport) & sel->dport_mask) &&
59 !((xfrm_flowi_sport(fl) ^ sel->sport) & sel->sport_mask) &&
60 (fl->proto == sel->proto || !sel->proto) &&
61 (fl->oif == sel->ifindex || !sel->ifindex);
62}
63
64static inline int
65__xfrm6_selector_match(struct xfrm_selector *sel, struct flowi *fl)
66{
67 return addr_match(&fl->fl6_dst, &sel->daddr, sel->prefixlen_d) &&
68 addr_match(&fl->fl6_src, &sel->saddr, sel->prefixlen_s) &&
69 !((xfrm_flowi_dport(fl) ^ sel->dport) & sel->dport_mask) &&
70 !((xfrm_flowi_sport(fl) ^ sel->sport) & sel->sport_mask) &&
71 (fl->proto == sel->proto || !sel->proto) &&
72 (fl->oif == sel->ifindex || !sel->ifindex);
73}
74
75int xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl,
76 unsigned short family)
77{
78 switch (family) {
79 case AF_INET:
80 return __xfrm4_selector_match(sel, fl);
81 case AF_INET6:
82 return __xfrm6_selector_match(sel, fl);
83 }
84 return 0;
85}
86
53int xfrm_register_type(struct xfrm_type *type, unsigned short family) 87int xfrm_register_type(struct xfrm_type *type, unsigned short family)
54{ 88{
55 struct xfrm_policy_afinfo *afinfo = xfrm_policy_lock_afinfo(family); 89 struct xfrm_policy_afinfo *afinfo = xfrm_policy_lock_afinfo(family);
@@ -1177,6 +1211,7 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, struct flowi *fl,
1177 if (tmpl->mode == XFRM_MODE_TUNNEL) { 1211 if (tmpl->mode == XFRM_MODE_TUNNEL) {
1178 remote = &tmpl->id.daddr; 1212 remote = &tmpl->id.daddr;
1179 local = &tmpl->saddr; 1213 local = &tmpl->saddr;
1214 family = tmpl->encap_family;
1180 if (xfrm_addr_any(local, family)) { 1215 if (xfrm_addr_any(local, family)) {
1181 error = xfrm_get_saddr(&tmp, remote, family); 1216 error = xfrm_get_saddr(&tmp, remote, family);
1182 if (error) 1217 if (error)
@@ -1894,7 +1929,8 @@ int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *first,
1894 1929
1895 if (fl && !xfrm_selector_match(&dst->xfrm->sel, fl, family)) 1930 if (fl && !xfrm_selector_match(&dst->xfrm->sel, fl, family))
1896 return 0; 1931 return 0;
1897 if (fl && !security_xfrm_flow_state_match(fl, dst->xfrm, pol)) 1932 if (fl && pol &&
1933 !security_xfrm_state_pol_flow_match(dst->xfrm, pol, fl))
1898 return 0; 1934 return 0;
1899 if (dst->xfrm->km.state != XFRM_STATE_VALID) 1935 if (dst->xfrm->km.state != XFRM_STATE_VALID)
1900 return 0; 1936 return 0;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 40c527179843..da54a64ccfa3 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1304,7 +1304,7 @@ int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol)
1304} 1304}
1305EXPORT_SYMBOL(km_query); 1305EXPORT_SYMBOL(km_query);
1306 1306
1307int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, u16 sport) 1307int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport)
1308{ 1308{
1309 int err = -EINVAL; 1309 int err = -EINVAL;
1310 struct xfrm_mgr *km; 1310 struct xfrm_mgr *km;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index c4cde57d9216..6f97665983d2 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -244,11 +244,10 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 *props,
244 *props = algo->desc.sadb_alg_id; 244 *props = algo->desc.sadb_alg_id;
245 245
246 len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8; 246 len = sizeof(*ualg) + (ualg->alg_key_len + 7U) / 8;
247 p = kmalloc(len, GFP_KERNEL); 247 p = kmemdup(ualg, len, GFP_KERNEL);
248 if (!p) 248 if (!p)
249 return -ENOMEM; 249 return -ENOMEM;
250 250
251 memcpy(p, ualg, len);
252 strcpy(p->alg_name, algo->name); 251 strcpy(p->alg_name, algo->name);
253 *algpp = p; 252 *algpp = p;
254 return 0; 253 return 0;
@@ -263,11 +262,10 @@ static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct rtattr *u_a
263 return 0; 262 return 0;
264 263
265 uencap = RTA_DATA(rta); 264 uencap = RTA_DATA(rta);
266 p = kmalloc(sizeof(*p), GFP_KERNEL); 265 p = kmemdup(uencap, sizeof(*p), GFP_KERNEL);
267 if (!p) 266 if (!p)
268 return -ENOMEM; 267 return -ENOMEM;
269 268
270 memcpy(p, uencap, sizeof(*p));
271 *encapp = p; 269 *encapp = p;
272 return 0; 270 return 0;
273} 271}
@@ -305,11 +303,10 @@ static int attach_one_addr(xfrm_address_t **addrpp, struct rtattr *u_arg)
305 return 0; 303 return 0;
306 304
307 uaddrp = RTA_DATA(rta); 305 uaddrp = RTA_DATA(rta);
308 p = kmalloc(sizeof(*p), GFP_KERNEL); 306 p = kmemdup(uaddrp, sizeof(*p), GFP_KERNEL);
309 if (!p) 307 if (!p)
310 return -ENOMEM; 308 return -ENOMEM;
311 309
312 memcpy(p, uaddrp, sizeof(*p));
313 *addrpp = p; 310 *addrpp = p;
314 return 0; 311 return 0;
315} 312}
@@ -495,6 +492,7 @@ static struct xfrm_state *xfrm_user_state_lookup(struct xfrm_usersa_id *p,
495 goto out; 492 goto out;
496 } 493 }
497 494
495 err = -ESRCH;
498 x = xfrm_state_lookup_byaddr(&p->daddr, saddr, p->proto, 496 x = xfrm_state_lookup_byaddr(&p->daddr, saddr, p->proto,
499 p->family); 497 p->family);
500 } 498 }
@@ -652,7 +650,6 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,
652 if (!skb) 650 if (!skb)
653 return ERR_PTR(-ENOMEM); 651 return ERR_PTR(-ENOMEM);
654 652
655 NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid;
656 info.in_skb = in_skb; 653 info.in_skb = in_skb;
657 info.out_skb = skb; 654 info.out_skb = skb;
658 info.nlmsg_seq = seq; 655 info.nlmsg_seq = seq;
@@ -772,7 +769,7 @@ out_noput:
772 return err; 769 return err;
773} 770}
774 771
775static int verify_policy_dir(__u8 dir) 772static int verify_policy_dir(u8 dir)
776{ 773{
777 switch (dir) { 774 switch (dir) {
778 case XFRM_POLICY_IN: 775 case XFRM_POLICY_IN:
@@ -787,7 +784,7 @@ static int verify_policy_dir(__u8 dir)
787 return 0; 784 return 0;
788} 785}
789 786
790static int verify_policy_type(__u8 type) 787static int verify_policy_type(u8 type)
791{ 788{
792 switch (type) { 789 switch (type) {
793 case XFRM_POLICY_TYPE_MAIN: 790 case XFRM_POLICY_TYPE_MAIN:
@@ -861,6 +858,7 @@ static void copy_templates(struct xfrm_policy *xp, struct xfrm_user_tmpl *ut,
861 int i; 858 int i;
862 859
863 xp->xfrm_nr = nr; 860 xp->xfrm_nr = nr;
861 xp->family = ut->family;
864 for (i = 0; i < nr; i++, ut++) { 862 for (i = 0; i < nr; i++, ut++) {
865 struct xfrm_tmpl *t = &xp->xfrm_vec[i]; 863 struct xfrm_tmpl *t = &xp->xfrm_vec[i];
866 864
@@ -874,6 +872,7 @@ static void copy_templates(struct xfrm_policy *xp, struct xfrm_user_tmpl *ut,
874 t->aalgos = ut->aalgos; 872 t->aalgos = ut->aalgos;
875 t->ealgos = ut->ealgos; 873 t->ealgos = ut->ealgos;
876 t->calgos = ut->calgos; 874 t->calgos = ut->calgos;
875 t->encap_family = ut->family;
877 } 876 }
878} 877}
879 878
@@ -900,7 +899,7 @@ static int copy_from_user_policy_type(u8 *tp, struct rtattr **xfrma)
900{ 899{
901 struct rtattr *rt = xfrma[XFRMA_POLICY_TYPE-1]; 900 struct rtattr *rt = xfrma[XFRMA_POLICY_TYPE-1];
902 struct xfrm_userpolicy_type *upt; 901 struct xfrm_userpolicy_type *upt;
903 __u8 type = XFRM_POLICY_TYPE_MAIN; 902 u8 type = XFRM_POLICY_TYPE_MAIN;
904 int err; 903 int err;
905 904
906 if (rt) { 905 if (rt) {
@@ -1027,7 +1026,7 @@ static int copy_to_user_tmpl(struct xfrm_policy *xp, struct sk_buff *skb)
1027 struct xfrm_tmpl *kp = &xp->xfrm_vec[i]; 1026 struct xfrm_tmpl *kp = &xp->xfrm_vec[i];
1028 1027
1029 memcpy(&up->id, &kp->id, sizeof(up->id)); 1028 memcpy(&up->id, &kp->id, sizeof(up->id));
1030 up->family = xp->family; 1029 up->family = kp->encap_family;
1031 memcpy(&up->saddr, &kp->saddr, sizeof(up->saddr)); 1030 memcpy(&up->saddr, &kp->saddr, sizeof(up->saddr));
1032 up->reqid = kp->reqid; 1031 up->reqid = kp->reqid;
1033 up->mode = kp->mode; 1032 up->mode = kp->mode;
@@ -1082,12 +1081,12 @@ static inline int copy_to_user_sec_ctx(struct xfrm_policy *xp, struct sk_buff *s
1082} 1081}
1083 1082
1084#ifdef CONFIG_XFRM_SUB_POLICY 1083#ifdef CONFIG_XFRM_SUB_POLICY
1085static int copy_to_user_policy_type(struct xfrm_policy *xp, struct sk_buff *skb) 1084static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
1086{ 1085{
1087 struct xfrm_userpolicy_type upt; 1086 struct xfrm_userpolicy_type upt;
1088 1087
1089 memset(&upt, 0, sizeof(upt)); 1088 memset(&upt, 0, sizeof(upt));
1090 upt.type = xp->type; 1089 upt.type = type;
1091 1090
1092 RTA_PUT(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt); 1091 RTA_PUT(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
1093 1092
@@ -1098,7 +1097,7 @@ rtattr_failure:
1098} 1097}
1099 1098
1100#else 1099#else
1101static inline int copy_to_user_policy_type(struct xfrm_policy *xp, struct sk_buff *skb) 1100static inline int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
1102{ 1101{
1103 return 0; 1102 return 0;
1104} 1103}
@@ -1127,7 +1126,7 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr
1127 goto nlmsg_failure; 1126 goto nlmsg_failure;
1128 if (copy_to_user_sec_ctx(xp, skb)) 1127 if (copy_to_user_sec_ctx(xp, skb))
1129 goto nlmsg_failure; 1128 goto nlmsg_failure;
1130 if (copy_to_user_policy_type(xp, skb) < 0) 1129 if (copy_to_user_policy_type(xp->type, skb) < 0)
1131 goto nlmsg_failure; 1130 goto nlmsg_failure;
1132 1131
1133 nlh->nlmsg_len = skb->tail - b; 1132 nlh->nlmsg_len = skb->tail - b;
@@ -1170,7 +1169,6 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
1170 if (!skb) 1169 if (!skb)
1171 return ERR_PTR(-ENOMEM); 1170 return ERR_PTR(-ENOMEM);
1172 1171
1173 NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid;
1174 info.in_skb = in_skb; 1172 info.in_skb = in_skb;
1175 info.out_skb = skb; 1173 info.out_skb = skb;
1176 info.nlmsg_seq = seq; 1174 info.nlmsg_seq = seq;
@@ -1189,7 +1187,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
1189{ 1187{
1190 struct xfrm_policy *xp; 1188 struct xfrm_policy *xp;
1191 struct xfrm_userpolicy_id *p; 1189 struct xfrm_userpolicy_id *p;
1192 __u8 type = XFRM_POLICY_TYPE_MAIN; 1190 u8 type = XFRM_POLICY_TYPE_MAIN;
1193 int err; 1191 int err;
1194 struct km_event c; 1192 struct km_event c;
1195 int delete; 1193 int delete;
@@ -1283,10 +1281,12 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, struct km_eve
1283 id = NLMSG_DATA(nlh); 1281 id = NLMSG_DATA(nlh);
1284 nlh->nlmsg_flags = 0; 1282 nlh->nlmsg_flags = 0;
1285 1283
1286 id->sa_id.daddr = x->id.daddr; 1284 memcpy(&id->sa_id.daddr, &x->id.daddr,sizeof(x->id.daddr));
1287 id->sa_id.spi = x->id.spi; 1285 id->sa_id.spi = x->id.spi;
1288 id->sa_id.family = x->props.family; 1286 id->sa_id.family = x->props.family;
1289 id->sa_id.proto = x->id.proto; 1287 id->sa_id.proto = x->id.proto;
1288 memcpy(&id->saddr, &x->props.saddr,sizeof(x->props.saddr));
1289 id->reqid = x->props.reqid;
1290 id->flags = c->data.aevent; 1290 id->flags = c->data.aevent;
1291 1291
1292 RTA_PUT(skb, XFRMA_REPLAY_VAL, sizeof(x->replay), &x->replay); 1292 RTA_PUT(skb, XFRMA_REPLAY_VAL, sizeof(x->replay), &x->replay);
@@ -1407,7 +1407,7 @@ out:
1407static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma) 1407static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
1408{ 1408{
1409 struct km_event c; 1409 struct km_event c;
1410 __u8 type = XFRM_POLICY_TYPE_MAIN; 1410 u8 type = XFRM_POLICY_TYPE_MAIN;
1411 int err; 1411 int err;
1412 1412
1413 err = copy_from_user_policy_type(&type, (struct rtattr **)xfrma); 1413 err = copy_from_user_policy_type(&type, (struct rtattr **)xfrma);
@@ -1428,7 +1428,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh, void *
1428 struct xfrm_policy *xp; 1428 struct xfrm_policy *xp;
1429 struct xfrm_user_polexpire *up = NLMSG_DATA(nlh); 1429 struct xfrm_user_polexpire *up = NLMSG_DATA(nlh);
1430 struct xfrm_userpolicy_info *p = &up->pol; 1430 struct xfrm_userpolicy_info *p = &up->pol;
1431 __u8 type = XFRM_POLICY_TYPE_MAIN; 1431 u8 type = XFRM_POLICY_TYPE_MAIN;
1432 int err = -ENOENT; 1432 int err = -ENOENT;
1433 1433
1434 err = copy_from_user_policy_type(&type, (struct rtattr **)xfrma); 1434 err = copy_from_user_policy_type(&type, (struct rtattr **)xfrma);
@@ -1907,7 +1907,7 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x,
1907 goto nlmsg_failure; 1907 goto nlmsg_failure;
1908 if (copy_to_user_state_sec_ctx(x, skb)) 1908 if (copy_to_user_state_sec_ctx(x, skb))
1909 goto nlmsg_failure; 1909 goto nlmsg_failure;
1910 if (copy_to_user_policy_type(xp, skb) < 0) 1910 if (copy_to_user_policy_type(xp->type, skb) < 0)
1911 goto nlmsg_failure; 1911 goto nlmsg_failure;
1912 1912
1913 nlh->nlmsg_len = skb->tail - b; 1913 nlh->nlmsg_len = skb->tail - b;
@@ -2017,7 +2017,7 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp,
2017 goto nlmsg_failure; 2017 goto nlmsg_failure;
2018 if (copy_to_user_sec_ctx(xp, skb)) 2018 if (copy_to_user_sec_ctx(xp, skb))
2019 goto nlmsg_failure; 2019 goto nlmsg_failure;
2020 if (copy_to_user_policy_type(xp, skb) < 0) 2020 if (copy_to_user_policy_type(xp->type, skb) < 0)
2021 goto nlmsg_failure; 2021 goto nlmsg_failure;
2022 upe->hard = !!hard; 2022 upe->hard = !!hard;
2023 2023
@@ -2096,7 +2096,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *
2096 copy_to_user_policy(xp, p, dir); 2096 copy_to_user_policy(xp, p, dir);
2097 if (copy_to_user_tmpl(xp, skb) < 0) 2097 if (copy_to_user_tmpl(xp, skb) < 0)
2098 goto nlmsg_failure; 2098 goto nlmsg_failure;
2099 if (copy_to_user_policy_type(xp, skb) < 0) 2099 if (copy_to_user_policy_type(xp->type, skb) < 0)
2100 goto nlmsg_failure; 2100 goto nlmsg_failure;
2101 2101
2102 nlh->nlmsg_len = skb->tail - b; 2102 nlh->nlmsg_len = skb->tail - b;
@@ -2117,7 +2117,6 @@ static int xfrm_notify_policy_flush(struct km_event *c)
2117 unsigned char *b; 2117 unsigned char *b;
2118 int len = 0; 2118 int len = 0;
2119#ifdef CONFIG_XFRM_SUB_POLICY 2119#ifdef CONFIG_XFRM_SUB_POLICY
2120 struct xfrm_userpolicy_type upt;
2121 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); 2120 len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
2122#endif 2121#endif
2123 len += NLMSG_LENGTH(0); 2122 len += NLMSG_LENGTH(0);
@@ -2130,12 +2129,8 @@ static int xfrm_notify_policy_flush(struct km_event *c)
2130 2129
2131 nlh = NLMSG_PUT(skb, c->pid, c->seq, XFRM_MSG_FLUSHPOLICY, 0); 2130 nlh = NLMSG_PUT(skb, c->pid, c->seq, XFRM_MSG_FLUSHPOLICY, 0);
2132 nlh->nlmsg_flags = 0; 2131 nlh->nlmsg_flags = 0;
2133 2132 if (copy_to_user_policy_type(c->data.type, skb) < 0)
2134#ifdef CONFIG_XFRM_SUB_POLICY 2133 goto nlmsg_failure;
2135 memset(&upt, 0, sizeof(upt));
2136 upt.type = c->data.type;
2137 RTA_PUT(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
2138#endif
2139 2134
2140 nlh->nlmsg_len = skb->tail - b; 2135 nlh->nlmsg_len = skb->tail - b;
2141 2136
@@ -2143,9 +2138,6 @@ static int xfrm_notify_policy_flush(struct km_event *c)
2143 return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_POLICY, GFP_ATOMIC); 2138 return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_POLICY, GFP_ATOMIC);
2144 2139
2145nlmsg_failure: 2140nlmsg_failure:
2146#ifdef CONFIG_XFRM_SUB_POLICY
2147rtattr_failure:
2148#endif
2149 kfree_skb(skb); 2141 kfree_skb(skb);
2150 return -1; 2142 return -1;
2151} 2143}
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 331c079f029b..4c723fd18648 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -158,7 +158,7 @@ unknown_option() {
158} 158}
159 159
160list_header() { 160list_header() {
161 echo "deps_initramfs := \\" 161 :
162} 162}
163 163
164header() { 164header() {
@@ -227,6 +227,7 @@ arg="$1"
227case "$arg" in 227case "$arg" in
228 "-l") # files included in initramfs - used by kbuild 228 "-l") # files included in initramfs - used by kbuild
229 dep_list="list_" 229 dep_list="list_"
230 echo "deps_initramfs := \\"
230 shift 231 shift
231 ;; 232 ;;
232 "-o") # generate gzipped cpio image named $1 233 "-o") # generate gzipped cpio image named $1
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index ebc781b493d7..d54440fc166c 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -221,16 +221,14 @@ static void init_dialog_colors(void)
221 */ 221 */
222static void color_setup(const char *theme) 222static void color_setup(const char *theme)
223{ 223{
224 if (set_theme(theme)) { 224 int use_color;
225 if (has_colors()) { /* Terminal supports color? */ 225
226 start_color(); 226 use_color = set_theme(theme);
227 init_dialog_colors(); 227 if (use_color && has_colors()) {
228 } 228 start_color();
229 } 229 init_dialog_colors();
230 else 230 } else
231 {
232 set_mono_theme(); 231 set_mono_theme();
233 }
234} 232}
235 233
236/* 234/*
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 393f3749f330..338bdea96541 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1259,6 +1259,7 @@ void ConfigSearchWindow::search(void)
1259 * Construct the complete config widget 1259 * Construct the complete config widget
1260 */ 1260 */
1261ConfigMainWindow::ConfigMainWindow(void) 1261ConfigMainWindow::ConfigMainWindow(void)
1262 : searchWindow(0)
1262{ 1263{
1263 QMenuBar* menu; 1264 QMenuBar* menu;
1264 bool ok; 1265 bool ok;
diff --git a/security/dummy.c b/security/dummy.c
index 43874c1e6e23..558795b237d6 100644
--- a/security/dummy.c
+++ b/security/dummy.c
@@ -828,6 +828,11 @@ static inline void dummy_inet_csk_clone(struct sock *newsk,
828{ 828{
829} 829}
830 830
831static inline void dummy_inet_conn_established(struct sock *sk,
832 struct sk_buff *skb)
833{
834}
835
831static inline void dummy_req_classify_flow(const struct request_sock *req, 836static inline void dummy_req_classify_flow(const struct request_sock *req,
832 struct flowi *fl) 837 struct flowi *fl)
833{ 838{
@@ -836,7 +841,7 @@ static inline void dummy_req_classify_flow(const struct request_sock *req,
836 841
837#ifdef CONFIG_SECURITY_NETWORK_XFRM 842#ifdef CONFIG_SECURITY_NETWORK_XFRM
838static int dummy_xfrm_policy_alloc_security(struct xfrm_policy *xp, 843static int dummy_xfrm_policy_alloc_security(struct xfrm_policy *xp,
839 struct xfrm_user_sec_ctx *sec_ctx, struct sock *sk) 844 struct xfrm_user_sec_ctx *sec_ctx)
840{ 845{
841 return 0; 846 return 0;
842} 847}
@@ -856,7 +861,7 @@ static int dummy_xfrm_policy_delete_security(struct xfrm_policy *xp)
856} 861}
857 862
858static int dummy_xfrm_state_alloc_security(struct xfrm_state *x, 863static int dummy_xfrm_state_alloc_security(struct xfrm_state *x,
859 struct xfrm_user_sec_ctx *sec_ctx, struct xfrm_sec_ctx *pol, u32 secid) 864 struct xfrm_user_sec_ctx *sec_ctx, u32 secid)
860{ 865{
861 return 0; 866 return 0;
862} 867}
@@ -881,12 +886,6 @@ static int dummy_xfrm_state_pol_flow_match(struct xfrm_state *x,
881 return 1; 886 return 1;
882} 887}
883 888
884static int dummy_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm,
885 struct xfrm_policy *xp)
886{
887 return 1;
888}
889
890static int dummy_xfrm_decode_session(struct sk_buff *skb, u32 *fl, int ckall) 889static int dummy_xfrm_decode_session(struct sk_buff *skb, u32 *fl, int ckall)
891{ 890{
892 return 0; 891 return 0;
@@ -1108,6 +1107,7 @@ void security_fixup_ops (struct security_operations *ops)
1108 set_to_dummy_if_null(ops, sock_graft); 1107 set_to_dummy_if_null(ops, sock_graft);
1109 set_to_dummy_if_null(ops, inet_conn_request); 1108 set_to_dummy_if_null(ops, inet_conn_request);
1110 set_to_dummy_if_null(ops, inet_csk_clone); 1109 set_to_dummy_if_null(ops, inet_csk_clone);
1110 set_to_dummy_if_null(ops, inet_conn_established);
1111 set_to_dummy_if_null(ops, req_classify_flow); 1111 set_to_dummy_if_null(ops, req_classify_flow);
1112 #endif /* CONFIG_SECURITY_NETWORK */ 1112 #endif /* CONFIG_SECURITY_NETWORK */
1113#ifdef CONFIG_SECURITY_NETWORK_XFRM 1113#ifdef CONFIG_SECURITY_NETWORK_XFRM
@@ -1120,7 +1120,6 @@ void security_fixup_ops (struct security_operations *ops)
1120 set_to_dummy_if_null(ops, xfrm_state_delete_security); 1120 set_to_dummy_if_null(ops, xfrm_state_delete_security);
1121 set_to_dummy_if_null(ops, xfrm_policy_lookup); 1121 set_to_dummy_if_null(ops, xfrm_policy_lookup);
1122 set_to_dummy_if_null(ops, xfrm_state_pol_flow_match); 1122 set_to_dummy_if_null(ops, xfrm_state_pol_flow_match);
1123 set_to_dummy_if_null(ops, xfrm_flow_state_match);
1124 set_to_dummy_if_null(ops, xfrm_decode_session); 1123 set_to_dummy_if_null(ops, xfrm_decode_session);
1125#endif /* CONFIG_SECURITY_NETWORK_XFRM */ 1124#endif /* CONFIG_SECURITY_NETWORK_XFRM */
1126#ifdef CONFIG_KEYS 1125#ifdef CONFIG_KEYS
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index a300702da527..74c0319c417e 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -32,12 +32,7 @@
32#include "avc.h" 32#include "avc.h"
33#include "avc_ss.h" 33#include "avc_ss.h"
34 34
35static const struct av_perm_to_string 35static const struct av_perm_to_string av_perm_to_string[] = {
36{
37 u16 tclass;
38 u32 value;
39 const char *name;
40} av_perm_to_string[] = {
41#define S_(c, v, s) { c, v, s }, 36#define S_(c, v, s) { c, v, s },
42#include "av_perm_to_string.h" 37#include "av_perm_to_string.h"
43#undef S_ 38#undef S_
@@ -57,17 +52,21 @@ static const char *class_to_string[] = {
57#undef TE_ 52#undef TE_
58#undef S_ 53#undef S_
59 54
60static const struct av_inherit 55static const struct av_inherit av_inherit[] = {
61{
62 u16 tclass;
63 const char **common_pts;
64 u32 common_base;
65} av_inherit[] = {
66#define S_(c, i, b) { c, common_##i##_perm_to_string, b }, 56#define S_(c, i, b) { c, common_##i##_perm_to_string, b },
67#include "av_inherit.h" 57#include "av_inherit.h"
68#undef S_ 58#undef S_
69}; 59};
70 60
61const struct selinux_class_perm selinux_class_perm = {
62 av_perm_to_string,
63 ARRAY_SIZE(av_perm_to_string),
64 class_to_string,
65 ARRAY_SIZE(class_to_string),
66 av_inherit,
67 ARRAY_SIZE(av_inherit)
68};
69
71#define AVC_CACHE_SLOTS 512 70#define AVC_CACHE_SLOTS 512
72#define AVC_DEF_CACHE_THRESHOLD 512 71#define AVC_DEF_CACHE_THRESHOLD 512
73#define AVC_CACHE_RECLAIM 16 72#define AVC_CACHE_RECLAIM 16
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 8ab5679a37a3..a29d78d3f44c 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -58,6 +58,7 @@
58#include <linux/netlink.h> 58#include <linux/netlink.h>
59#include <linux/tcp.h> 59#include <linux/tcp.h>
60#include <linux/udp.h> 60#include <linux/udp.h>
61#include <linux/dccp.h>
61#include <linux/quota.h> 62#include <linux/quota.h>
62#include <linux/un.h> /* for Unix socket types */ 63#include <linux/un.h> /* for Unix socket types */
63#include <net/af_unix.h> /* for Unix socket types */ 64#include <net/af_unix.h> /* for Unix socket types */
@@ -751,6 +752,8 @@ static inline u16 socket_type_to_security_class(int family, int type, int protoc
751 return SECCLASS_UDP_SOCKET; 752 return SECCLASS_UDP_SOCKET;
752 else 753 else
753 return SECCLASS_RAWIP_SOCKET; 754 return SECCLASS_RAWIP_SOCKET;
755 case SOCK_DCCP:
756 return SECCLASS_DCCP_SOCKET;
754 default: 757 default:
755 return SECCLASS_RAWIP_SOCKET; 758 return SECCLASS_RAWIP_SOCKET;
756 } 759 }
@@ -1754,7 +1757,8 @@ static inline void flush_unauthorized_files(struct files_struct * files)
1754 get_file(devnull); 1757 get_file(devnull);
1755 } else { 1758 } else {
1756 devnull = dentry_open(dget(selinux_null), mntget(selinuxfs_mount), O_RDWR); 1759 devnull = dentry_open(dget(selinux_null), mntget(selinuxfs_mount), O_RDWR);
1757 if (!devnull) { 1760 if (IS_ERR(devnull)) {
1761 devnull = NULL;
1758 put_unused_fd(fd); 1762 put_unused_fd(fd);
1759 fput(file); 1763 fput(file);
1760 continue; 1764 continue;
@@ -2888,7 +2892,8 @@ static void selinux_task_to_inode(struct task_struct *p,
2888} 2892}
2889 2893
2890/* Returns error only if unable to parse addresses */ 2894/* Returns error only if unable to parse addresses */
2891static int selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad) 2895static int selinux_parse_skb_ipv4(struct sk_buff *skb,
2896 struct avc_audit_data *ad, u8 *proto)
2892{ 2897{
2893 int offset, ihlen, ret = -EINVAL; 2898 int offset, ihlen, ret = -EINVAL;
2894 struct iphdr _iph, *ih; 2899 struct iphdr _iph, *ih;
@@ -2906,6 +2911,9 @@ static int selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad
2906 ad->u.net.v4info.daddr = ih->daddr; 2911 ad->u.net.v4info.daddr = ih->daddr;
2907 ret = 0; 2912 ret = 0;
2908 2913
2914 if (proto)
2915 *proto = ih->protocol;
2916
2909 switch (ih->protocol) { 2917 switch (ih->protocol) {
2910 case IPPROTO_TCP: { 2918 case IPPROTO_TCP: {
2911 struct tcphdr _tcph, *th; 2919 struct tcphdr _tcph, *th;
@@ -2939,6 +2947,22 @@ static int selinux_parse_skb_ipv4(struct sk_buff *skb, struct avc_audit_data *ad
2939 break; 2947 break;
2940 } 2948 }
2941 2949
2950 case IPPROTO_DCCP: {
2951 struct dccp_hdr _dccph, *dh;
2952
2953 if (ntohs(ih->frag_off) & IP_OFFSET)
2954 break;
2955
2956 offset += ihlen;
2957 dh = skb_header_pointer(skb, offset, sizeof(_dccph), &_dccph);
2958 if (dh == NULL)
2959 break;
2960
2961 ad->u.net.sport = dh->dccph_sport;
2962 ad->u.net.dport = dh->dccph_dport;
2963 break;
2964 }
2965
2942 default: 2966 default:
2943 break; 2967 break;
2944 } 2968 }
@@ -2949,7 +2973,8 @@ out:
2949#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 2973#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
2950 2974
2951/* Returns error only if unable to parse addresses */ 2975/* Returns error only if unable to parse addresses */
2952static int selinux_parse_skb_ipv6(struct sk_buff *skb, struct avc_audit_data *ad) 2976static int selinux_parse_skb_ipv6(struct sk_buff *skb,
2977 struct avc_audit_data *ad, u8 *proto)
2953{ 2978{
2954 u8 nexthdr; 2979 u8 nexthdr;
2955 int ret = -EINVAL, offset; 2980 int ret = -EINVAL, offset;
@@ -2970,6 +2995,9 @@ static int selinux_parse_skb_ipv6(struct sk_buff *skb, struct avc_audit_data *ad
2970 if (offset < 0) 2995 if (offset < 0)
2971 goto out; 2996 goto out;
2972 2997
2998 if (proto)
2999 *proto = nexthdr;
3000
2973 switch (nexthdr) { 3001 switch (nexthdr) {
2974 case IPPROTO_TCP: { 3002 case IPPROTO_TCP: {
2975 struct tcphdr _tcph, *th; 3003 struct tcphdr _tcph, *th;
@@ -2995,6 +3023,18 @@ static int selinux_parse_skb_ipv6(struct sk_buff *skb, struct avc_audit_data *ad
2995 break; 3023 break;
2996 } 3024 }
2997 3025
3026 case IPPROTO_DCCP: {
3027 struct dccp_hdr _dccph, *dh;
3028
3029 dh = skb_header_pointer(skb, offset, sizeof(_dccph), &_dccph);
3030 if (dh == NULL)
3031 break;
3032
3033 ad->u.net.sport = dh->dccph_sport;
3034 ad->u.net.dport = dh->dccph_dport;
3035 break;
3036 }
3037
2998 /* includes fragments */ 3038 /* includes fragments */
2999 default: 3039 default:
3000 break; 3040 break;
@@ -3006,13 +3046,13 @@ out:
3006#endif /* IPV6 */ 3046#endif /* IPV6 */
3007 3047
3008static int selinux_parse_skb(struct sk_buff *skb, struct avc_audit_data *ad, 3048static int selinux_parse_skb(struct sk_buff *skb, struct avc_audit_data *ad,
3009 char **addrp, int *len, int src) 3049 char **addrp, int *len, int src, u8 *proto)
3010{ 3050{
3011 int ret = 0; 3051 int ret = 0;
3012 3052
3013 switch (ad->u.net.family) { 3053 switch (ad->u.net.family) {
3014 case PF_INET: 3054 case PF_INET:
3015 ret = selinux_parse_skb_ipv4(skb, ad); 3055 ret = selinux_parse_skb_ipv4(skb, ad, proto);
3016 if (ret || !addrp) 3056 if (ret || !addrp)
3017 break; 3057 break;
3018 *len = 4; 3058 *len = 4;
@@ -3022,7 +3062,7 @@ static int selinux_parse_skb(struct sk_buff *skb, struct avc_audit_data *ad,
3022 3062
3023#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 3063#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
3024 case PF_INET6: 3064 case PF_INET6:
3025 ret = selinux_parse_skb_ipv6(skb, ad); 3065 ret = selinux_parse_skb_ipv6(skb, ad, proto);
3026 if (ret || !addrp) 3066 if (ret || !addrp)
3027 break; 3067 break;
3028 *len = 16; 3068 *len = 16;
@@ -3100,9 +3140,7 @@ static int selinux_socket_post_create(struct socket *sock, int family,
3100 if (sock->sk) { 3140 if (sock->sk) {
3101 sksec = sock->sk->sk_security; 3141 sksec = sock->sk->sk_security;
3102 sksec->sid = isec->sid; 3142 sksec->sid = isec->sid;
3103 err = selinux_netlbl_socket_post_create(sock, 3143 err = selinux_netlbl_socket_post_create(sock);
3104 family,
3105 isec->sid);
3106 } 3144 }
3107 3145
3108 return err; 3146 return err;
@@ -3179,7 +3217,11 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
3179 case SECCLASS_UDP_SOCKET: 3217 case SECCLASS_UDP_SOCKET:
3180 node_perm = UDP_SOCKET__NODE_BIND; 3218 node_perm = UDP_SOCKET__NODE_BIND;
3181 break; 3219 break;
3182 3220
3221 case SECCLASS_DCCP_SOCKET:
3222 node_perm = DCCP_SOCKET__NODE_BIND;
3223 break;
3224
3183 default: 3225 default:
3184 node_perm = RAWIP_SOCKET__NODE_BIND; 3226 node_perm = RAWIP_SOCKET__NODE_BIND;
3185 break; 3227 break;
@@ -3217,16 +3259,17 @@ static int selinux_socket_connect(struct socket *sock, struct sockaddr *address,
3217 return err; 3259 return err;
3218 3260
3219 /* 3261 /*
3220 * If a TCP socket, check name_connect permission for the port. 3262 * If a TCP or DCCP socket, check name_connect permission for the port.
3221 */ 3263 */
3222 isec = SOCK_INODE(sock)->i_security; 3264 isec = SOCK_INODE(sock)->i_security;
3223 if (isec->sclass == SECCLASS_TCP_SOCKET) { 3265 if (isec->sclass == SECCLASS_TCP_SOCKET ||
3266 isec->sclass == SECCLASS_DCCP_SOCKET) {
3224 struct sock *sk = sock->sk; 3267 struct sock *sk = sock->sk;
3225 struct avc_audit_data ad; 3268 struct avc_audit_data ad;
3226 struct sockaddr_in *addr4 = NULL; 3269 struct sockaddr_in *addr4 = NULL;
3227 struct sockaddr_in6 *addr6 = NULL; 3270 struct sockaddr_in6 *addr6 = NULL;
3228 unsigned short snum; 3271 unsigned short snum;
3229 u32 sid; 3272 u32 sid, perm;
3230 3273
3231 if (sk->sk_family == PF_INET) { 3274 if (sk->sk_family == PF_INET) {
3232 addr4 = (struct sockaddr_in *)address; 3275 addr4 = (struct sockaddr_in *)address;
@@ -3245,11 +3288,13 @@ static int selinux_socket_connect(struct socket *sock, struct sockaddr *address,
3245 if (err) 3288 if (err)
3246 goto out; 3289 goto out;
3247 3290
3291 perm = (isec->sclass == SECCLASS_TCP_SOCKET) ?
3292 TCP_SOCKET__NAME_CONNECT : DCCP_SOCKET__NAME_CONNECT;
3293
3248 AVC_AUDIT_DATA_INIT(&ad,NET); 3294 AVC_AUDIT_DATA_INIT(&ad,NET);
3249 ad.u.net.dport = htons(snum); 3295 ad.u.net.dport = htons(snum);
3250 ad.u.net.family = sk->sk_family; 3296 ad.u.net.family = sk->sk_family;
3251 err = avc_has_perm(isec->sid, sid, isec->sclass, 3297 err = avc_has_perm(isec->sid, sid, isec->sclass, perm, &ad);
3252 TCP_SOCKET__NAME_CONNECT, &ad);
3253 if (err) 3298 if (err)
3254 goto out; 3299 goto out;
3255 } 3300 }
@@ -3437,7 +3482,13 @@ static int selinux_sock_rcv_skb_compat(struct sock *sk, struct sk_buff *skb,
3437 node_perm = NODE__TCP_RECV; 3482 node_perm = NODE__TCP_RECV;
3438 recv_perm = TCP_SOCKET__RECV_MSG; 3483 recv_perm = TCP_SOCKET__RECV_MSG;
3439 break; 3484 break;
3440 3485
3486 case SECCLASS_DCCP_SOCKET:
3487 netif_perm = NETIF__DCCP_RECV;
3488 node_perm = NODE__DCCP_RECV;
3489 recv_perm = DCCP_SOCKET__RECV_MSG;
3490 break;
3491
3441 default: 3492 default:
3442 netif_perm = NETIF__RAWIP_RECV; 3493 netif_perm = NETIF__RAWIP_RECV;
3443 node_perm = NODE__RAWIP_RECV; 3494 node_perm = NODE__RAWIP_RECV;
@@ -3493,7 +3544,7 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
3493 ad.u.net.netif = skb->dev ? skb->dev->name : "[unknown]"; 3544 ad.u.net.netif = skb->dev ? skb->dev->name : "[unknown]";
3494 ad.u.net.family = family; 3545 ad.u.net.family = family;
3495 3546
3496 err = selinux_parse_skb(skb, &ad, &addrp, &len, 1); 3547 err = selinux_parse_skb(skb, &ad, &addrp, &len, 1, NULL);
3497 if (err) 3548 if (err)
3498 goto out; 3549 goto out;
3499 3550
@@ -3523,25 +3574,16 @@ static int selinux_socket_getpeersec_stream(struct socket *sock, char __user *op
3523 u32 scontext_len; 3574 u32 scontext_len;
3524 struct sk_security_struct *ssec; 3575 struct sk_security_struct *ssec;
3525 struct inode_security_struct *isec; 3576 struct inode_security_struct *isec;
3526 u32 peer_sid = 0; 3577 u32 peer_sid = SECSID_NULL;
3527 3578
3528 isec = SOCK_INODE(sock)->i_security; 3579 isec = SOCK_INODE(sock)->i_security;
3529 3580
3530 /* if UNIX_STREAM check peer_sid, if TCP check dst for labelled sa */ 3581 if (isec->sclass == SECCLASS_UNIX_STREAM_SOCKET ||
3531 if (isec->sclass == SECCLASS_UNIX_STREAM_SOCKET) { 3582 isec->sclass == SECCLASS_TCP_SOCKET) {
3532 ssec = sock->sk->sk_security; 3583 ssec = sock->sk->sk_security;
3533 peer_sid = ssec->peer_sid; 3584 peer_sid = ssec->peer_sid;
3534 } 3585 }
3535 else if (isec->sclass == SECCLASS_TCP_SOCKET) { 3586 if (peer_sid == SECSID_NULL) {
3536 peer_sid = selinux_netlbl_socket_getpeersec_stream(sock);
3537 if (peer_sid == SECSID_NULL)
3538 peer_sid = selinux_socket_getpeer_stream(sock->sk);
3539 if (peer_sid == SECSID_NULL) {
3540 err = -ENOPROTOOPT;
3541 goto out;
3542 }
3543 }
3544 else {
3545 err = -ENOPROTOOPT; 3587 err = -ENOPROTOOPT;
3546 goto out; 3588 goto out;
3547 } 3589 }
@@ -3573,13 +3615,12 @@ static int selinux_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *
3573 u32 peer_secid = SECSID_NULL; 3615 u32 peer_secid = SECSID_NULL;
3574 int err = 0; 3616 int err = 0;
3575 3617
3576 if (sock && (sock->sk->sk_family == PF_UNIX)) 3618 if (sock && sock->sk->sk_family == PF_UNIX)
3577 selinux_get_inode_sid(SOCK_INODE(sock), &peer_secid); 3619 selinux_get_inode_sid(SOCK_INODE(sock), &peer_secid);
3578 else if (skb) { 3620 else if (skb)
3579 peer_secid = selinux_netlbl_socket_getpeersec_dgram(skb); 3621 security_skb_extlbl_sid(skb,
3580 if (peer_secid == SECSID_NULL) 3622 SECINITSID_UNLABELED,
3581 peer_secid = selinux_socket_getpeer_dgram(skb); 3623 &peer_secid);
3582 }
3583 3624
3584 if (peer_secid == SECSID_NULL) 3625 if (peer_secid == SECSID_NULL)
3585 err = -EINVAL; 3626 err = -EINVAL;
@@ -3606,7 +3647,7 @@ static void selinux_sk_clone_security(const struct sock *sk, struct sock *newsk)
3606 newssec->sid = ssec->sid; 3647 newssec->sid = ssec->sid;
3607 newssec->peer_sid = ssec->peer_sid; 3648 newssec->peer_sid = ssec->peer_sid;
3608 3649
3609 selinux_netlbl_sk_clone_security(ssec, newssec); 3650 selinux_netlbl_sk_security_clone(ssec, newssec);
3610} 3651}
3611 3652
3612static void selinux_sk_getsecid(struct sock *sk, u32 *secid) 3653static void selinux_sk_getsecid(struct sock *sk, u32 *secid)
@@ -3640,17 +3681,10 @@ static int selinux_inet_conn_request(struct sock *sk, struct sk_buff *skb,
3640 u32 newsid; 3681 u32 newsid;
3641 u32 peersid; 3682 u32 peersid;
3642 3683
3643 newsid = selinux_netlbl_inet_conn_request(skb, sksec->sid); 3684 security_skb_extlbl_sid(skb, SECINITSID_UNLABELED, &peersid);
3644 if (newsid != SECSID_NULL) {
3645 req->secid = newsid;
3646 return 0;
3647 }
3648
3649 err = selinux_xfrm_decode_session(skb, &peersid, 0);
3650 BUG_ON(err);
3651
3652 if (peersid == SECSID_NULL) { 3685 if (peersid == SECSID_NULL) {
3653 req->secid = sksec->sid; 3686 req->secid = sksec->sid;
3687 req->peer_secid = SECSID_NULL;
3654 return 0; 3688 return 0;
3655 } 3689 }
3656 3690
@@ -3659,6 +3693,7 @@ static int selinux_inet_conn_request(struct sock *sk, struct sk_buff *skb,
3659 return err; 3693 return err;
3660 3694
3661 req->secid = newsid; 3695 req->secid = newsid;
3696 req->peer_secid = peersid;
3662 return 0; 3697 return 0;
3663} 3698}
3664 3699
@@ -3668,12 +3703,23 @@ static void selinux_inet_csk_clone(struct sock *newsk,
3668 struct sk_security_struct *newsksec = newsk->sk_security; 3703 struct sk_security_struct *newsksec = newsk->sk_security;
3669 3704
3670 newsksec->sid = req->secid; 3705 newsksec->sid = req->secid;
3706 newsksec->peer_sid = req->peer_secid;
3671 /* NOTE: Ideally, we should also get the isec->sid for the 3707 /* NOTE: Ideally, we should also get the isec->sid for the
3672 new socket in sync, but we don't have the isec available yet. 3708 new socket in sync, but we don't have the isec available yet.
3673 So we will wait until sock_graft to do it, by which 3709 So we will wait until sock_graft to do it, by which
3674 time it will have been created and available. */ 3710 time it will have been created and available. */
3675 3711
3676 selinux_netlbl_sk_security_init(newsksec, req->rsk_ops->family); 3712 /* We don't need to take any sort of lock here as we are the only
3713 * thread with access to newsksec */
3714 selinux_netlbl_sk_security_reset(newsksec, req->rsk_ops->family);
3715}
3716
3717static void selinux_inet_conn_established(struct sock *sk,
3718 struct sk_buff *skb)
3719{
3720 struct sk_security_struct *sksec = sk->sk_security;
3721
3722 security_skb_extlbl_sid(skb, SECINITSID_UNLABELED, &sksec->peer_sid);
3677} 3723}
3678 3724
3679static void selinux_req_classify_flow(const struct request_sock *req, 3725static void selinux_req_classify_flow(const struct request_sock *req,
@@ -3756,7 +3802,13 @@ static int selinux_ip_postroute_last_compat(struct sock *sk, struct net_device *
3756 node_perm = NODE__TCP_SEND; 3802 node_perm = NODE__TCP_SEND;
3757 send_perm = TCP_SOCKET__SEND_MSG; 3803 send_perm = TCP_SOCKET__SEND_MSG;
3758 break; 3804 break;
3759 3805
3806 case SECCLASS_DCCP_SOCKET:
3807 netif_perm = NETIF__DCCP_SEND;
3808 node_perm = NODE__DCCP_SEND;
3809 send_perm = DCCP_SOCKET__SEND_MSG;
3810 break;
3811
3760 default: 3812 default:
3761 netif_perm = NETIF__RAWIP_SEND; 3813 netif_perm = NETIF__RAWIP_SEND;
3762 node_perm = NODE__RAWIP_SEND; 3814 node_perm = NODE__RAWIP_SEND;
@@ -3807,6 +3859,7 @@ static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
3807 struct avc_audit_data ad; 3859 struct avc_audit_data ad;
3808 struct net_device *dev = (struct net_device *)out; 3860 struct net_device *dev = (struct net_device *)out;
3809 struct sk_security_struct *sksec; 3861 struct sk_security_struct *sksec;
3862 u8 proto;
3810 3863
3811 sk = skb->sk; 3864 sk = skb->sk;
3812 if (!sk) 3865 if (!sk)
@@ -3818,7 +3871,7 @@ static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
3818 ad.u.net.netif = dev->name; 3871 ad.u.net.netif = dev->name;
3819 ad.u.net.family = family; 3872 ad.u.net.family = family;
3820 3873
3821 err = selinux_parse_skb(skb, &ad, &addrp, &len, 0); 3874 err = selinux_parse_skb(skb, &ad, &addrp, &len, 0, &proto);
3822 if (err) 3875 if (err)
3823 goto out; 3876 goto out;
3824 3877
@@ -3832,7 +3885,7 @@ static unsigned int selinux_ip_postroute_last(unsigned int hooknum,
3832 if (err) 3885 if (err)
3833 goto out; 3886 goto out;
3834 3887
3835 err = selinux_xfrm_postroute_last(sksec->sid, skb, &ad); 3888 err = selinux_xfrm_postroute_last(sksec->sid, skb, &ad, proto);
3836out: 3889out:
3837 return err ? NF_DROP : NF_ACCEPT; 3890 return err ? NF_DROP : NF_ACCEPT;
3838} 3891}
@@ -4738,6 +4791,7 @@ static struct security_operations selinux_ops = {
4738 .sock_graft = selinux_sock_graft, 4791 .sock_graft = selinux_sock_graft,
4739 .inet_conn_request = selinux_inet_conn_request, 4792 .inet_conn_request = selinux_inet_conn_request,
4740 .inet_csk_clone = selinux_inet_csk_clone, 4793 .inet_csk_clone = selinux_inet_csk_clone,
4794 .inet_conn_established = selinux_inet_conn_established,
4741 .req_classify_flow = selinux_req_classify_flow, 4795 .req_classify_flow = selinux_req_classify_flow,
4742 4796
4743#ifdef CONFIG_SECURITY_NETWORK_XFRM 4797#ifdef CONFIG_SECURITY_NETWORK_XFRM
@@ -4750,7 +4804,6 @@ static struct security_operations selinux_ops = {
4750 .xfrm_state_delete_security = selinux_xfrm_state_delete, 4804 .xfrm_state_delete_security = selinux_xfrm_state_delete,
4751 .xfrm_policy_lookup = selinux_xfrm_policy_lookup, 4805 .xfrm_policy_lookup = selinux_xfrm_policy_lookup,
4752 .xfrm_state_pol_flow_match = selinux_xfrm_state_pol_flow_match, 4806 .xfrm_state_pol_flow_match = selinux_xfrm_state_pol_flow_match,
4753 .xfrm_flow_state_match = selinux_xfrm_flow_state_match,
4754 .xfrm_decode_session = selinux_xfrm_decode_session, 4807 .xfrm_decode_session = selinux_xfrm_decode_session,
4755#endif 4808#endif
4756 4809
diff --git a/security/selinux/include/av_inherit.h b/security/selinux/include/av_inherit.h
index a68fdd55597f..8377a4ba3b95 100644
--- a/security/selinux/include/av_inherit.h
+++ b/security/selinux/include/av_inherit.h
@@ -30,3 +30,4 @@
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) 32 S_(SECCLASS_APPLETALK_SOCKET, socket, 0x00400000UL)
33 S_(SECCLASS_DCCP_SOCKET, socket, 0x00400000UL)
diff --git a/security/selinux/include/av_perm_to_string.h b/security/selinux/include/av_perm_to_string.h
index 09fc8a2345eb..ad9fb2d69b50 100644
--- a/security/selinux/include/av_perm_to_string.h
+++ b/security/selinux/include/av_perm_to_string.h
@@ -35,12 +35,16 @@
35 S_(SECCLASS_NODE, NODE__RAWIP_RECV, "rawip_recv") 35 S_(SECCLASS_NODE, NODE__RAWIP_RECV, "rawip_recv")
36 S_(SECCLASS_NODE, NODE__RAWIP_SEND, "rawip_send") 36 S_(SECCLASS_NODE, NODE__RAWIP_SEND, "rawip_send")
37 S_(SECCLASS_NODE, NODE__ENFORCE_DEST, "enforce_dest") 37 S_(SECCLASS_NODE, NODE__ENFORCE_DEST, "enforce_dest")
38 S_(SECCLASS_NODE, NODE__DCCP_RECV, "dccp_recv")
39 S_(SECCLASS_NODE, NODE__DCCP_SEND, "dccp_send")
38 S_(SECCLASS_NETIF, NETIF__TCP_RECV, "tcp_recv") 40 S_(SECCLASS_NETIF, NETIF__TCP_RECV, "tcp_recv")
39 S_(SECCLASS_NETIF, NETIF__TCP_SEND, "tcp_send") 41 S_(SECCLASS_NETIF, NETIF__TCP_SEND, "tcp_send")
40 S_(SECCLASS_NETIF, NETIF__UDP_RECV, "udp_recv") 42 S_(SECCLASS_NETIF, NETIF__UDP_RECV, "udp_recv")
41 S_(SECCLASS_NETIF, NETIF__UDP_SEND, "udp_send") 43 S_(SECCLASS_NETIF, NETIF__UDP_SEND, "udp_send")
42 S_(SECCLASS_NETIF, NETIF__RAWIP_RECV, "rawip_recv") 44 S_(SECCLASS_NETIF, NETIF__RAWIP_RECV, "rawip_recv")
43 S_(SECCLASS_NETIF, NETIF__RAWIP_SEND, "rawip_send") 45 S_(SECCLASS_NETIF, NETIF__RAWIP_SEND, "rawip_send")
46 S_(SECCLASS_NETIF, NETIF__DCCP_RECV, "dccp_recv")
47 S_(SECCLASS_NETIF, NETIF__DCCP_SEND, "dccp_send")
44 S_(SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__CONNECTTO, "connectto") 48 S_(SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__CONNECTTO, "connectto")
45 S_(SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__NEWCONN, "newconn") 49 S_(SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__NEWCONN, "newconn")
46 S_(SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__ACCEPTFROM, "acceptfrom") 50 S_(SECCLASS_UNIX_STREAM_SOCKET, UNIX_STREAM_SOCKET__ACCEPTFROM, "acceptfrom")
@@ -252,3 +256,7 @@
252 S_(SECCLASS_KEY, KEY__LINK, "link") 256 S_(SECCLASS_KEY, KEY__LINK, "link")
253 S_(SECCLASS_KEY, KEY__SETATTR, "setattr") 257 S_(SECCLASS_KEY, KEY__SETATTR, "setattr")
254 S_(SECCLASS_KEY, KEY__CREATE, "create") 258 S_(SECCLASS_KEY, KEY__CREATE, "create")
259 S_(SECCLASS_CONTEXT, CONTEXT__TRANSLATE, "translate")
260 S_(SECCLASS_CONTEXT, CONTEXT__CONTAINS, "contains")
261 S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NODE_BIND, "node_bind")
262 S_(SECCLASS_DCCP_SOCKET, DCCP_SOCKET__NAME_CONNECT, "name_connect")
diff --git a/security/selinux/include/av_permissions.h b/security/selinux/include/av_permissions.h
index 81f4f526c8b1..2de4b5fe3aa1 100644
--- a/security/selinux/include/av_permissions.h
+++ b/security/selinux/include/av_permissions.h
@@ -312,6 +312,8 @@
312#define NODE__RAWIP_RECV 0x00000010UL 312#define NODE__RAWIP_RECV 0x00000010UL
313#define NODE__RAWIP_SEND 0x00000020UL 313#define NODE__RAWIP_SEND 0x00000020UL
314#define NODE__ENFORCE_DEST 0x00000040UL 314#define NODE__ENFORCE_DEST 0x00000040UL
315#define NODE__DCCP_RECV 0x00000080UL
316#define NODE__DCCP_SEND 0x00000100UL
315 317
316#define NETIF__TCP_RECV 0x00000001UL 318#define NETIF__TCP_RECV 0x00000001UL
317#define NETIF__TCP_SEND 0x00000002UL 319#define NETIF__TCP_SEND 0x00000002UL
@@ -319,6 +321,8 @@
319#define NETIF__UDP_SEND 0x00000008UL 321#define NETIF__UDP_SEND 0x00000008UL
320#define NETIF__RAWIP_RECV 0x00000010UL 322#define NETIF__RAWIP_RECV 0x00000010UL
321#define NETIF__RAWIP_SEND 0x00000020UL 323#define NETIF__RAWIP_SEND 0x00000020UL
324#define NETIF__DCCP_RECV 0x00000040UL
325#define NETIF__DCCP_SEND 0x00000080UL
322 326
323#define NETLINK_SOCKET__IOCTL 0x00000001UL 327#define NETLINK_SOCKET__IOCTL 0x00000001UL
324#define NETLINK_SOCKET__READ 0x00000002UL 328#define NETLINK_SOCKET__READ 0x00000002UL
@@ -970,3 +974,31 @@
970#define KEY__LINK 0x00000010UL 974#define KEY__LINK 0x00000010UL
971#define KEY__SETATTR 0x00000020UL 975#define KEY__SETATTR 0x00000020UL
972#define KEY__CREATE 0x00000040UL 976#define KEY__CREATE 0x00000040UL
977
978#define CONTEXT__TRANSLATE 0x00000001UL
979#define CONTEXT__CONTAINS 0x00000002UL
980
981#define DCCP_SOCKET__IOCTL 0x00000001UL
982#define DCCP_SOCKET__READ 0x00000002UL
983#define DCCP_SOCKET__WRITE 0x00000004UL
984#define DCCP_SOCKET__CREATE 0x00000008UL
985#define DCCP_SOCKET__GETATTR 0x00000010UL
986#define DCCP_SOCKET__SETATTR 0x00000020UL
987#define DCCP_SOCKET__LOCK 0x00000040UL
988#define DCCP_SOCKET__RELABELFROM 0x00000080UL
989#define DCCP_SOCKET__RELABELTO 0x00000100UL
990#define DCCP_SOCKET__APPEND 0x00000200UL
991#define DCCP_SOCKET__BIND 0x00000400UL
992#define DCCP_SOCKET__CONNECT 0x00000800UL
993#define DCCP_SOCKET__LISTEN 0x00001000UL
994#define DCCP_SOCKET__ACCEPT 0x00002000UL
995#define DCCP_SOCKET__GETOPT 0x00004000UL
996#define DCCP_SOCKET__SETOPT 0x00008000UL
997#define DCCP_SOCKET__SHUTDOWN 0x00010000UL
998#define DCCP_SOCKET__RECVFROM 0x00020000UL
999#define DCCP_SOCKET__SENDTO 0x00040000UL
1000#define DCCP_SOCKET__RECV_MSG 0x00080000UL
1001#define DCCP_SOCKET__SEND_MSG 0x00100000UL
1002#define DCCP_SOCKET__NAME_BIND 0x00200000UL
1003#define DCCP_SOCKET__NODE_BIND 0x00400000UL
1004#define DCCP_SOCKET__NAME_CONNECT 0x00800000UL
diff --git a/security/selinux/include/avc_ss.h b/security/selinux/include/avc_ss.h
index 450a2831e2e3..ff869e8b6f4a 100644
--- a/security/selinux/include/avc_ss.h
+++ b/security/selinux/include/avc_ss.h
@@ -10,5 +10,29 @@
10 10
11int avc_ss_reset(u32 seqno); 11int avc_ss_reset(u32 seqno);
12 12
13struct av_perm_to_string
14{
15 u16 tclass;
16 u32 value;
17 const char *name;
18};
19
20struct av_inherit
21{
22 u16 tclass;
23 const char **common_pts;
24 u32 common_base;
25};
26
27struct selinux_class_perm
28{
29 const struct av_perm_to_string *av_perm_to_string;
30 u32 av_pts_len;
31 const char **class_to_string;
32 u32 cts_len;
33 const struct av_inherit *av_inherit;
34 u32 av_inherit_len;
35};
36
13#endif /* _SELINUX_AVC_SS_H_ */ 37#endif /* _SELINUX_AVC_SS_H_ */
14 38
diff --git a/security/selinux/include/class_to_string.h b/security/selinux/include/class_to_string.h
index 24303b61309f..9f3ebb1bfae6 100644
--- a/security/selinux/include/class_to_string.h
+++ b/security/selinux/include/class_to_string.h
@@ -61,3 +61,5 @@
61 S_("appletalk_socket") 61 S_("appletalk_socket")
62 S_("packet") 62 S_("packet")
63 S_("key") 63 S_("key")
64 S_("context")
65 S_("dccp_socket")
diff --git a/security/selinux/include/flask.h b/security/selinux/include/flask.h
index 95887aed2a68..67cef371ee00 100644
--- a/security/selinux/include/flask.h
+++ b/security/selinux/include/flask.h
@@ -63,6 +63,8 @@
63#define SECCLASS_APPLETALK_SOCKET 56 63#define SECCLASS_APPLETALK_SOCKET 56
64#define SECCLASS_PACKET 57 64#define SECCLASS_PACKET 57
65#define SECCLASS_KEY 58 65#define SECCLASS_KEY 58
66#define SECCLASS_CONTEXT 59
67#define SECCLASS_DCCP_SOCKET 60
66 68
67/* 69/*
68 * Security identifier indices for initial entities 70 * Security identifier indices for initial entities
diff --git a/security/selinux/include/objsec.h b/security/selinux/include/objsec.h
index ef2267fea8bd..91b88f0ba20c 100644
--- a/security/selinux/include/objsec.h
+++ b/security/selinux/include/objsec.h
@@ -23,6 +23,7 @@
23#include <linux/fs.h> 23#include <linux/fs.h>
24#include <linux/binfmts.h> 24#include <linux/binfmts.h>
25#include <linux/in.h> 25#include <linux/in.h>
26#include <linux/spinlock.h>
26#include "flask.h" 27#include "flask.h"
27#include "avc.h" 28#include "avc.h"
28 29
@@ -108,6 +109,7 @@ struct sk_security_struct {
108 NLBL_REQUIRE, 109 NLBL_REQUIRE,
109 NLBL_LABELED, 110 NLBL_LABELED,
110 } nlbl_state; 111 } nlbl_state;
112 spinlock_t nlbl_lock; /* protects nlbl_state */
111#endif 113#endif
112}; 114};
113 115
diff --git a/security/selinux/include/security.h b/security/selinux/include/security.h
index 1ef79172cc8c..210eec77e7ff 100644
--- a/security/selinux/include/security.h
+++ b/security/selinux/include/security.h
@@ -34,6 +34,8 @@
34#define POLICYDB_VERSION_MAX POLICYDB_VERSION_RANGETRANS 34#define POLICYDB_VERSION_MAX POLICYDB_VERSION_RANGETRANS
35#endif 35#endif
36 36
37struct sk_buff;
38
37extern int selinux_enabled; 39extern int selinux_enabled;
38extern int selinux_mls_enabled; 40extern int selinux_mls_enabled;
39 41
@@ -80,6 +82,8 @@ int security_netif_sid(char *name, u32 *if_sid,
80int security_node_sid(u16 domain, void *addr, u32 addrlen, 82int security_node_sid(u16 domain, void *addr, u32 addrlen,
81 u32 *out_sid); 83 u32 *out_sid);
82 84
85void security_skb_extlbl_sid(struct sk_buff *skb, u32 base_sid, u32 *sid);
86
83int security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid, 87int security_validate_transition(u32 oldsid, u32 newsid, u32 tasksid,
84 u16 tclass); 88 u16 tclass);
85 89
diff --git a/security/selinux/include/selinux_netlabel.h b/security/selinux/include/selinux_netlabel.h
index 9de10cc2cef2..2a732c9033e3 100644
--- a/security/selinux/include/selinux_netlabel.h
+++ b/security/selinux/include/selinux_netlabel.h
@@ -38,19 +38,17 @@
38 38
39#ifdef CONFIG_NETLABEL 39#ifdef CONFIG_NETLABEL
40void selinux_netlbl_cache_invalidate(void); 40void selinux_netlbl_cache_invalidate(void);
41int selinux_netlbl_socket_post_create(struct socket *sock, 41int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u32 base_sid, u32 *sid);
42 int sock_family, 42int selinux_netlbl_socket_post_create(struct socket *sock);
43 u32 sid);
44void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock); 43void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock);
45u32 selinux_netlbl_inet_conn_request(struct sk_buff *skb, u32 sock_sid);
46int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec, 44int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
47 struct sk_buff *skb, 45 struct sk_buff *skb,
48 struct avc_audit_data *ad); 46 struct avc_audit_data *ad);
49u32 selinux_netlbl_socket_getpeersec_stream(struct socket *sock); 47void selinux_netlbl_sk_security_reset(struct sk_security_struct *ssec,
50u32 selinux_netlbl_socket_getpeersec_dgram(struct sk_buff *skb); 48 int family);
51void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec, 49void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec,
52 int family); 50 int family);
53void selinux_netlbl_sk_clone_security(struct sk_security_struct *ssec, 51void selinux_netlbl_sk_security_clone(struct sk_security_struct *ssec,
54 struct sk_security_struct *newssec); 52 struct sk_security_struct *newssec);
55int selinux_netlbl_inode_permission(struct inode *inode, int mask); 53int selinux_netlbl_inode_permission(struct inode *inode, int mask);
56int selinux_netlbl_socket_setsockopt(struct socket *sock, 54int selinux_netlbl_socket_setsockopt(struct socket *sock,
@@ -62,23 +60,23 @@ static inline void selinux_netlbl_cache_invalidate(void)
62 return; 60 return;
63} 61}
64 62
65static inline int selinux_netlbl_socket_post_create(struct socket *sock, 63static inline int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
66 int sock_family, 64 u32 base_sid,
67 u32 sid) 65 u32 *sid)
68{ 66{
67 *sid = SECSID_NULL;
69 return 0; 68 return 0;
70} 69}
71 70
72static inline void selinux_netlbl_sock_graft(struct sock *sk, 71static inline int selinux_netlbl_socket_post_create(struct socket *sock)
73 struct socket *sock)
74{ 72{
75 return; 73 return 0;
76} 74}
77 75
78static inline u32 selinux_netlbl_inet_conn_request(struct sk_buff *skb, 76static inline void selinux_netlbl_sock_graft(struct sock *sk,
79 u32 sock_sid) 77 struct socket *sock)
80{ 78{
81 return SECSID_NULL; 79 return;
82} 80}
83 81
84static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec, 82static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
@@ -88,14 +86,11 @@ static inline int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
88 return 0; 86 return 0;
89} 87}
90 88
91static inline u32 selinux_netlbl_socket_getpeersec_stream(struct socket *sock) 89static inline void selinux_netlbl_sk_security_reset(
92{ 90 struct sk_security_struct *ssec,
93 return SECSID_NULL; 91 int family)
94}
95
96static inline u32 selinux_netlbl_socket_getpeersec_dgram(struct sk_buff *skb)
97{ 92{
98 return SECSID_NULL; 93 return;
99} 94}
100 95
101static inline void selinux_netlbl_sk_security_init( 96static inline void selinux_netlbl_sk_security_init(
@@ -105,7 +100,7 @@ static inline void selinux_netlbl_sk_security_init(
105 return; 100 return;
106} 101}
107 102
108static inline void selinux_netlbl_sk_clone_security( 103static inline void selinux_netlbl_sk_security_clone(
109 struct sk_security_struct *ssec, 104 struct sk_security_struct *ssec,
110 struct sk_security_struct *newssec) 105 struct sk_security_struct *newssec)
111{ 106{
diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
index 526b28019aca..161eb571c82d 100644
--- a/security/selinux/include/xfrm.h
+++ b/security/selinux/include/xfrm.h
@@ -8,20 +8,17 @@
8#define _SELINUX_XFRM_H_ 8#define _SELINUX_XFRM_H_
9 9
10int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, 10int selinux_xfrm_policy_alloc(struct xfrm_policy *xp,
11 struct xfrm_user_sec_ctx *sec_ctx, struct sock *sk); 11 struct xfrm_user_sec_ctx *sec_ctx);
12int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new); 12int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new);
13void selinux_xfrm_policy_free(struct xfrm_policy *xp); 13void selinux_xfrm_policy_free(struct xfrm_policy *xp);
14int selinux_xfrm_policy_delete(struct xfrm_policy *xp); 14int selinux_xfrm_policy_delete(struct xfrm_policy *xp);
15int selinux_xfrm_state_alloc(struct xfrm_state *x, 15int selinux_xfrm_state_alloc(struct xfrm_state *x,
16 struct xfrm_user_sec_ctx *sec_ctx, struct xfrm_sec_ctx *pol, u32 secid); 16 struct xfrm_user_sec_ctx *sec_ctx, u32 secid);
17void selinux_xfrm_state_free(struct xfrm_state *x); 17void selinux_xfrm_state_free(struct xfrm_state *x);
18int selinux_xfrm_state_delete(struct xfrm_state *x); 18int selinux_xfrm_state_delete(struct xfrm_state *x);
19int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir); 19int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 fl_secid, u8 dir);
20int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, 20int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x,
21 struct xfrm_policy *xp, struct flowi *fl); 21 struct xfrm_policy *xp, struct flowi *fl);
22int selinux_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm,
23 struct xfrm_policy *xp);
24
25 22
26/* 23/*
27 * Extract the security blob from the sock (it's actually on the socket) 24 * Extract the security blob from the sock (it's actually on the socket)
@@ -38,9 +35,7 @@ static inline struct inode_security_struct *get_sock_isec(struct sock *sk)
38int selinux_xfrm_sock_rcv_skb(u32 sid, struct sk_buff *skb, 35int selinux_xfrm_sock_rcv_skb(u32 sid, struct sk_buff *skb,
39 struct avc_audit_data *ad); 36 struct avc_audit_data *ad);
40int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb, 37int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb,
41 struct avc_audit_data *ad); 38 struct avc_audit_data *ad, u8 proto);
42u32 selinux_socket_getpeer_stream(struct sock *sk);
43u32 selinux_socket_getpeer_dgram(struct sk_buff *skb);
44int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall); 39int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
45#else 40#else
46static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb, 41static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb,
@@ -50,20 +45,11 @@ static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb,
50} 45}
51 46
52static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb, 47static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb,
53 struct avc_audit_data *ad) 48 struct avc_audit_data *ad, u8 proto)
54{ 49{
55 return 0; 50 return 0;
56} 51}
57 52
58static inline int selinux_socket_getpeer_stream(struct sock *sk)
59{
60 return SECSID_NULL;
61}
62
63static inline int selinux_socket_getpeer_dgram(struct sk_buff *skb)
64{
65 return SECSID_NULL;
66}
67static inline int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall) 53static inline int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall)
68{ 54{
69 *sid = SECSID_NULL; 55 *sid = SECSID_NULL;
@@ -71,4 +57,10 @@ static inline int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int
71} 57}
72#endif 58#endif
73 59
60static inline void selinux_skb_xfrm_sid(struct sk_buff *skb, u32 *sid)
61{
62 int err = selinux_xfrm_decode_session(skb, sid, 0);
63 BUG_ON(err);
64}
65
74#endif /* _SELINUX_XFRM_H_ */ 66#endif /* _SELINUX_XFRM_H_ */
diff --git a/security/selinux/nlmsgtab.c b/security/selinux/nlmsgtab.c
index b8f4d25cf335..ccfe8755735e 100644
--- a/security/selinux/nlmsgtab.c
+++ b/security/selinux/nlmsgtab.c
@@ -60,7 +60,6 @@ static struct nlmsg_perm nlmsg_route_perms[] =
60 { RTM_DELACTION, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, 60 { RTM_DELACTION, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
61 { RTM_GETACTION, NETLINK_ROUTE_SOCKET__NLMSG_READ }, 61 { RTM_GETACTION, NETLINK_ROUTE_SOCKET__NLMSG_READ },
62 { RTM_NEWPREFIX, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, 62 { RTM_NEWPREFIX, NETLINK_ROUTE_SOCKET__NLMSG_WRITE },
63 { RTM_GETPREFIX, NETLINK_ROUTE_SOCKET__NLMSG_READ },
64 { RTM_GETMULTICAST, NETLINK_ROUTE_SOCKET__NLMSG_READ }, 63 { RTM_GETMULTICAST, NETLINK_ROUTE_SOCKET__NLMSG_READ },
65 { RTM_GETANYCAST, NETLINK_ROUTE_SOCKET__NLMSG_READ }, 64 { RTM_GETANYCAST, NETLINK_ROUTE_SOCKET__NLMSG_READ },
66 { RTM_GETNEIGHTBL, NETLINK_ROUTE_SOCKET__NLMSG_READ }, 65 { RTM_GETNEIGHTBL, NETLINK_ROUTE_SOCKET__NLMSG_READ },
diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
index d539346ab3a2..ce492a6b38ed 100644
--- a/security/selinux/ss/ebitmap.c
+++ b/security/selinux/ss/ebitmap.c
@@ -6,7 +6,7 @@
6/* 6/*
7 * Updated: Hewlett-Packard <paul.moore@hp.com> 7 * Updated: Hewlett-Packard <paul.moore@hp.com>
8 * 8 *
9 * Added ebitmap_export() and ebitmap_import() 9 * Added support to import/export the NetLabel category bitmap
10 * 10 *
11 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 11 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
12 */ 12 */
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <net/netlabel.h>
17#include "ebitmap.h" 18#include "ebitmap.h"
18#include "policydb.h" 19#include "policydb.h"
19 20
@@ -67,141 +68,120 @@ int ebitmap_cpy(struct ebitmap *dst, struct ebitmap *src)
67 return 0; 68 return 0;
68} 69}
69 70
71#ifdef CONFIG_NETLABEL
70/** 72/**
71 * ebitmap_export - Export an ebitmap to a unsigned char bitmap string 73 * ebitmap_netlbl_export - Export an ebitmap into a NetLabel category bitmap
72 * @src: the ebitmap to export 74 * @ebmap: the ebitmap to export
73 * @dst: the resulting bitmap string 75 * @catmap: the NetLabel category bitmap
74 * @dst_len: length of dst in bytes
75 * 76 *
76 * Description: 77 * Description:
77 * Allocate a buffer at least src->highbit bits long and export the extensible 78 * Export a SELinux extensibile bitmap into a NetLabel category bitmap.
78 * bitmap into the buffer. The bitmap string will be in little endian format, 79 * Returns zero on success, negative values on error.
79 * i.e. LSB first. The value returned in dst_len may not the true size of the
80 * buffer as the length of the buffer is rounded up to a multiple of MAPTYPE.
81 * The caller must free the buffer when finished. Returns zero on success,
82 * negative values on failure.
83 * 80 *
84 */ 81 */
85int ebitmap_export(const struct ebitmap *src, 82int ebitmap_netlbl_export(struct ebitmap *ebmap,
86 unsigned char **dst, 83 struct netlbl_lsm_secattr_catmap **catmap)
87 size_t *dst_len)
88{ 84{
89 size_t bitmap_len; 85 struct ebitmap_node *e_iter = ebmap->node;
90 unsigned char *bitmap; 86 struct netlbl_lsm_secattr_catmap *c_iter;
91 struct ebitmap_node *iter_node; 87 u32 cmap_idx;
92 MAPTYPE node_val; 88
93 size_t bitmap_byte; 89 /* This function is a much simpler because SELinux's MAPTYPE happens
94 unsigned char bitmask; 90 * to be the same as NetLabel's NETLBL_CATMAP_MAPTYPE, if MAPTYPE is
95 91 * changed from a u64 this function will most likely need to be changed
96 if (src->highbit == 0) { 92 * as well. It's not ideal but I think the tradeoff in terms of
97 *dst = NULL; 93 * neatness and speed is worth it. */
98 *dst_len = 0; 94
95 if (e_iter == NULL) {
96 *catmap = NULL;
99 return 0; 97 return 0;
100 } 98 }
101 99
102 bitmap_len = src->highbit / 8; 100 c_iter = netlbl_secattr_catmap_alloc(GFP_ATOMIC);
103 if (src->highbit % 7) 101 if (c_iter == NULL)
104 bitmap_len += 1;
105
106 bitmap = kzalloc((bitmap_len & ~(sizeof(MAPTYPE) - 1)) +
107 sizeof(MAPTYPE),
108 GFP_ATOMIC);
109 if (bitmap == NULL)
110 return -ENOMEM; 102 return -ENOMEM;
103 *catmap = c_iter;
104 c_iter->startbit = e_iter->startbit & ~(NETLBL_CATMAP_SIZE - 1);
105
106 while (e_iter != NULL) {
107 if (e_iter->startbit >=
108 (c_iter->startbit + NETLBL_CATMAP_SIZE)) {
109 c_iter->next = netlbl_secattr_catmap_alloc(GFP_ATOMIC);
110 if (c_iter->next == NULL)
111 goto netlbl_export_failure;
112 c_iter = c_iter->next;
113 c_iter->startbit = e_iter->startbit &
114 ~(NETLBL_CATMAP_SIZE - 1);
115 }
116 cmap_idx = (e_iter->startbit - c_iter->startbit) /
117 NETLBL_CATMAP_MAPSIZE;
118 c_iter->bitmap[cmap_idx] = e_iter->map;
119 e_iter = e_iter->next;
120 }
111 121
112 iter_node = src->node;
113 do {
114 bitmap_byte = iter_node->startbit / 8;
115 bitmask = 0x80;
116 node_val = iter_node->map;
117 do {
118 if (bitmask == 0) {
119 bitmap_byte++;
120 bitmask = 0x80;
121 }
122 if (node_val & (MAPTYPE)0x01)
123 bitmap[bitmap_byte] |= bitmask;
124 node_val >>= 1;
125 bitmask >>= 1;
126 } while (node_val > 0);
127 iter_node = iter_node->next;
128 } while (iter_node);
129
130 *dst = bitmap;
131 *dst_len = bitmap_len;
132 return 0; 122 return 0;
123
124netlbl_export_failure:
125 netlbl_secattr_catmap_free(*catmap);
126 return -ENOMEM;
133} 127}
134 128
135/** 129/**
136 * ebitmap_import - Import an unsigned char bitmap string into an ebitmap 130 * ebitmap_netlbl_import - Import a NetLabel category bitmap into an ebitmap
137 * @src: the bitmap string 131 * @ebmap: the ebitmap to export
138 * @src_len: the bitmap length in bytes 132 * @catmap: the NetLabel category bitmap
139 * @dst: the empty ebitmap
140 * 133 *
141 * Description: 134 * Description:
142 * This function takes a little endian bitmap string in src and imports it into 135 * Import a NetLabel category bitmap into a SELinux extensibile bitmap.
143 * the ebitmap pointed to by dst. Returns zero on success, negative values on 136 * Returns zero on success, negative values on error.
144 * failure.
145 * 137 *
146 */ 138 */
147int ebitmap_import(const unsigned char *src, 139int ebitmap_netlbl_import(struct ebitmap *ebmap,
148 size_t src_len, 140 struct netlbl_lsm_secattr_catmap *catmap)
149 struct ebitmap *dst)
150{ 141{
151 size_t src_off = 0; 142 struct ebitmap_node *e_iter = NULL;
152 size_t node_limit; 143 struct ebitmap_node *emap_prev = NULL;
153 struct ebitmap_node *node_new; 144 struct netlbl_lsm_secattr_catmap *c_iter = catmap;
154 struct ebitmap_node *node_last = NULL; 145 u32 c_idx;
155 u32 i_byte;
156 u32 i_bit;
157 unsigned char src_byte;
158
159 while (src_off < src_len) {
160 if (src_len - src_off >= sizeof(MAPTYPE)) {
161 if (*(MAPTYPE *)&src[src_off] == 0) {
162 src_off += sizeof(MAPTYPE);
163 continue;
164 }
165 node_limit = sizeof(MAPTYPE);
166 } else {
167 for (src_byte = 0, i_byte = src_off;
168 i_byte < src_len && src_byte == 0;
169 i_byte++)
170 src_byte |= src[i_byte];
171 if (src_byte == 0)
172 break;
173 node_limit = src_len - src_off;
174 }
175 146
176 node_new = kzalloc(sizeof(*node_new), GFP_ATOMIC); 147 /* This function is a much simpler because SELinux's MAPTYPE happens
177 if (unlikely(node_new == NULL)) { 148 * to be the same as NetLabel's NETLBL_CATMAP_MAPTYPE, if MAPTYPE is
178 ebitmap_destroy(dst); 149 * changed from a u64 this function will most likely need to be changed
179 return -ENOMEM; 150 * as well. It's not ideal but I think the tradeoff in terms of
180 } 151 * neatness and speed is worth it. */
181 node_new->startbit = src_off * 8;
182 for (i_byte = 0; i_byte < node_limit; i_byte++) {
183 src_byte = src[src_off++];
184 for (i_bit = i_byte * 8; src_byte != 0; i_bit++) {
185 if (src_byte & 0x80)
186 node_new->map |= MAPBIT << i_bit;
187 src_byte <<= 1;
188 }
189 }
190 152
191 if (node_last != NULL) 153 do {
192 node_last->next = node_new; 154 for (c_idx = 0; c_idx < NETLBL_CATMAP_MAPCNT; c_idx++) {
193 else 155 if (c_iter->bitmap[c_idx] == 0)
194 dst->node = node_new; 156 continue;
195 node_last = node_new; 157
196 } 158 e_iter = kzalloc(sizeof(*e_iter), GFP_ATOMIC);
159 if (e_iter == NULL)
160 goto netlbl_import_failure;
161 if (emap_prev == NULL)
162 ebmap->node = e_iter;
163 else
164 emap_prev->next = e_iter;
165 emap_prev = e_iter;
197 166
198 if (likely(node_last != NULL)) 167 e_iter->startbit = c_iter->startbit +
199 dst->highbit = node_last->startbit + MAPSIZE; 168 NETLBL_CATMAP_MAPSIZE * c_idx;
169 e_iter->map = c_iter->bitmap[c_idx];
170 }
171 c_iter = c_iter->next;
172 } while (c_iter != NULL);
173 if (e_iter != NULL)
174 ebmap->highbit = e_iter->startbit + MAPSIZE;
200 else 175 else
201 ebitmap_init(dst); 176 ebitmap_destroy(ebmap);
202 177
203 return 0; 178 return 0;
179
180netlbl_import_failure:
181 ebitmap_destroy(ebmap);
182 return -ENOMEM;
204} 183}
184#endif /* CONFIG_NETLABEL */
205 185
206int ebitmap_contains(struct ebitmap *e1, struct ebitmap *e2) 186int ebitmap_contains(struct ebitmap *e1, struct ebitmap *e2)
207{ 187{
diff --git a/security/selinux/ss/ebitmap.h b/security/selinux/ss/ebitmap.h
index da2d4651b10d..1270e34b61c1 100644
--- a/security/selinux/ss/ebitmap.h
+++ b/security/selinux/ss/ebitmap.h
@@ -14,6 +14,8 @@
14#ifndef _SS_EBITMAP_H_ 14#ifndef _SS_EBITMAP_H_
15#define _SS_EBITMAP_H_ 15#define _SS_EBITMAP_H_
16 16
17#include <net/netlabel.h>
18
17#define MAPTYPE u64 /* portion of bitmap in each node */ 19#define MAPTYPE u64 /* portion of bitmap in each node */
18#define MAPSIZE (sizeof(MAPTYPE) * 8) /* number of bits in node bitmap */ 20#define MAPSIZE (sizeof(MAPTYPE) * 8) /* number of bits in node bitmap */
19#define MAPBIT 1ULL /* a bit in the node bitmap */ 21#define MAPBIT 1ULL /* a bit in the node bitmap */
@@ -69,16 +71,28 @@ static inline int ebitmap_node_get_bit(struct ebitmap_node * n,
69 71
70int ebitmap_cmp(struct ebitmap *e1, struct ebitmap *e2); 72int ebitmap_cmp(struct ebitmap *e1, struct ebitmap *e2);
71int ebitmap_cpy(struct ebitmap *dst, struct ebitmap *src); 73int ebitmap_cpy(struct ebitmap *dst, struct ebitmap *src);
72int ebitmap_export(const struct ebitmap *src,
73 unsigned char **dst,
74 size_t *dst_len);
75int ebitmap_import(const unsigned char *src,
76 size_t src_len,
77 struct ebitmap *dst);
78int ebitmap_contains(struct ebitmap *e1, struct ebitmap *e2); 74int ebitmap_contains(struct ebitmap *e1, struct ebitmap *e2);
79int ebitmap_get_bit(struct ebitmap *e, unsigned long bit); 75int ebitmap_get_bit(struct ebitmap *e, unsigned long bit);
80int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value); 76int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value);
81void ebitmap_destroy(struct ebitmap *e); 77void ebitmap_destroy(struct ebitmap *e);
82int ebitmap_read(struct ebitmap *e, void *fp); 78int ebitmap_read(struct ebitmap *e, void *fp);
83 79
80#ifdef CONFIG_NETLABEL
81int ebitmap_netlbl_export(struct ebitmap *ebmap,
82 struct netlbl_lsm_secattr_catmap **catmap);
83int ebitmap_netlbl_import(struct ebitmap *ebmap,
84 struct netlbl_lsm_secattr_catmap *catmap);
85#else
86static inline int ebitmap_netlbl_export(struct ebitmap *ebmap,
87 struct netlbl_lsm_secattr_catmap **catmap)
88{
89 return -ENOMEM;
90}
91static inline int ebitmap_netlbl_import(struct ebitmap *ebmap,
92 struct netlbl_lsm_secattr_catmap *catmap)
93{
94 return -ENOMEM;
95}
96#endif
97
84#endif /* _SS_EBITMAP_H_ */ 98#endif /* _SS_EBITMAP_H_ */
diff --git a/security/selinux/ss/hashtab.c b/security/selinux/ss/hashtab.c
index 24e5ec957630..77b530c3bbce 100644
--- a/security/selinux/ss/hashtab.c
+++ b/security/selinux/ss/hashtab.c
@@ -8,8 +8,8 @@
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include "hashtab.h" 9#include "hashtab.h"
10 10
11struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, void *key), 11struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, const void *key),
12 int (*keycmp)(struct hashtab *h, void *key1, void *key2), 12 int (*keycmp)(struct hashtab *h, const void *key1, const void *key2),
13 u32 size) 13 u32 size)
14{ 14{
15 struct hashtab *p; 15 struct hashtab *p;
@@ -71,7 +71,7 @@ int hashtab_insert(struct hashtab *h, void *key, void *datum)
71 return 0; 71 return 0;
72} 72}
73 73
74void *hashtab_search(struct hashtab *h, void *key) 74void *hashtab_search(struct hashtab *h, const void *key)
75{ 75{
76 u32 hvalue; 76 u32 hvalue;
77 struct hashtab_node *cur; 77 struct hashtab_node *cur;
diff --git a/security/selinux/ss/hashtab.h b/security/selinux/ss/hashtab.h
index 4cc85816a718..7e2ff3e3c6d2 100644
--- a/security/selinux/ss/hashtab.h
+++ b/security/selinux/ss/hashtab.h
@@ -22,9 +22,9 @@ struct hashtab {
22 struct hashtab_node **htable; /* hash table */ 22 struct hashtab_node **htable; /* hash table */
23 u32 size; /* number of slots in hash table */ 23 u32 size; /* number of slots in hash table */
24 u32 nel; /* number of elements in hash table */ 24 u32 nel; /* number of elements in hash table */
25 u32 (*hash_value)(struct hashtab *h, void *key); 25 u32 (*hash_value)(struct hashtab *h, const void *key);
26 /* hash function */ 26 /* hash function */
27 int (*keycmp)(struct hashtab *h, void *key1, void *key2); 27 int (*keycmp)(struct hashtab *h, const void *key1, const void *key2);
28 /* key comparison function */ 28 /* key comparison function */
29}; 29};
30 30
@@ -39,8 +39,8 @@ struct hashtab_info {
39 * Returns NULL if insufficent space is available or 39 * Returns NULL if insufficent space is available or
40 * the new hash table otherwise. 40 * the new hash table otherwise.
41 */ 41 */
42struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, void *key), 42struct hashtab *hashtab_create(u32 (*hash_value)(struct hashtab *h, const void *key),
43 int (*keycmp)(struct hashtab *h, void *key1, void *key2), 43 int (*keycmp)(struct hashtab *h, const void *key1, const void *key2),
44 u32 size); 44 u32 size);
45 45
46/* 46/*
@@ -59,7 +59,7 @@ int hashtab_insert(struct hashtab *h, void *k, void *d);
59 * Returns NULL if no entry has the specified key or 59 * Returns NULL if no entry has the specified key or
60 * the datum of the entry otherwise. 60 * the datum of the entry otherwise.
61 */ 61 */
62void *hashtab_search(struct hashtab *h, void *k); 62void *hashtab_search(struct hashtab *h, const void *k);
63 63
64/* 64/*
65 * Destroys the specified hash table. 65 * Destroys the specified hash table.
diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c
index 2cca8e251624..b4f682dc13ff 100644
--- a/security/selinux/ss/mls.c
+++ b/security/selinux/ss/mls.c
@@ -13,7 +13,7 @@
13/* 13/*
14 * Updated: Hewlett-Packard <paul.moore@hp.com> 14 * Updated: Hewlett-Packard <paul.moore@hp.com>
15 * 15 *
16 * Added support to import/export the MLS label 16 * Added support to import/export the MLS label from NetLabel
17 * 17 *
18 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 18 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
19 */ 19 */
@@ -22,6 +22,7 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <net/netlabel.h>
25#include "sidtab.h" 26#include "sidtab.h"
26#include "mls.h" 27#include "mls.h"
27#include "policydb.h" 28#include "policydb.h"
@@ -571,163 +572,108 @@ int mls_compute_sid(struct context *scontext,
571 return -EINVAL; 572 return -EINVAL;
572} 573}
573 574
575#ifdef CONFIG_NETLABEL
574/** 576/**
575 * mls_export_lvl - Export the MLS sensitivity levels 577 * mls_export_netlbl_lvl - Export the MLS sensitivity levels to NetLabel
576 * @context: the security context 578 * @context: the security context
577 * @low: the low sensitivity level 579 * @secattr: the NetLabel security attributes
578 * @high: the high sensitivity level
579 * 580 *
580 * Description: 581 * Description:
581 * Given the security context copy the low MLS sensitivity level into lvl_low 582 * Given the security context copy the low MLS sensitivity level into the
582 * and the high sensitivity level in lvl_high. The MLS levels are only 583 * NetLabel MLS sensitivity level field.
583 * exported if the pointers are not NULL, if they are NULL then that level is
584 * not exported.
585 * 584 *
586 */ 585 */
587void mls_export_lvl(const struct context *context, u32 *low, u32 *high) 586void mls_export_netlbl_lvl(struct context *context,
587 struct netlbl_lsm_secattr *secattr)
588{ 588{
589 if (!selinux_mls_enabled) 589 if (!selinux_mls_enabled)
590 return; 590 return;
591 591
592 if (low != NULL) 592 secattr->mls_lvl = context->range.level[0].sens - 1;
593 *low = context->range.level[0].sens - 1; 593 secattr->flags |= NETLBL_SECATTR_MLS_LVL;
594 if (high != NULL)
595 *high = context->range.level[1].sens - 1;
596} 594}
597 595
598/** 596/**
599 * mls_import_lvl - Import the MLS sensitivity levels 597 * mls_import_netlbl_lvl - Import the NetLabel MLS sensitivity levels
600 * @context: the security context 598 * @context: the security context
601 * @low: the low sensitivity level 599 * @secattr: the NetLabel security attributes
602 * @high: the high sensitivity level
603 * 600 *
604 * Description: 601 * Description:
605 * Given the security context and the two sensitivty levels, set the MLS levels 602 * Given the security context and the NetLabel security attributes, copy the
606 * in the context according the two given as parameters. Returns zero on 603 * NetLabel MLS sensitivity level into the context.
607 * success, negative values on failure.
608 * 604 *
609 */ 605 */
610void mls_import_lvl(struct context *context, u32 low, u32 high) 606void mls_import_netlbl_lvl(struct context *context,
607 struct netlbl_lsm_secattr *secattr)
611{ 608{
612 if (!selinux_mls_enabled) 609 if (!selinux_mls_enabled)
613 return; 610 return;
614 611
615 context->range.level[0].sens = low + 1; 612 context->range.level[0].sens = secattr->mls_lvl + 1;
616 context->range.level[1].sens = high + 1; 613 context->range.level[1].sens = context->range.level[0].sens;
617} 614}
618 615
619/** 616/**
620 * mls_export_cat - Export the MLS categories 617 * mls_export_netlbl_cat - Export the MLS categories to NetLabel
621 * @context: the security context 618 * @context: the security context
622 * @low: the low category 619 * @secattr: the NetLabel security attributes
623 * @low_len: length of the cat_low bitmap in bytes
624 * @high: the high category
625 * @high_len: length of the cat_high bitmap in bytes
626 * 620 *
627 * Description: 621 * Description:
628 * Given the security context export the low MLS category bitmap into cat_low 622 * Given the security context copy the low MLS categories into the NetLabel
629 * and the high category bitmap into cat_high. The MLS categories are only 623 * MLS category field. Returns zero on success, negative values on failure.
630 * exported if the pointers are not NULL, if they are NULL then that level is
631 * not exported. The caller is responsibile for freeing the memory when
632 * finished. Returns zero on success, negative values on failure.
633 * 624 *
634 */ 625 */
635int mls_export_cat(const struct context *context, 626int mls_export_netlbl_cat(struct context *context,
636 unsigned char **low, 627 struct netlbl_lsm_secattr *secattr)
637 size_t *low_len,
638 unsigned char **high,
639 size_t *high_len)
640{ 628{
641 int rc = -EPERM; 629 int rc;
642 630
643 if (!selinux_mls_enabled) { 631 if (!selinux_mls_enabled)
644 *low = NULL;
645 *low_len = 0;
646 *high = NULL;
647 *high_len = 0;
648 return 0; 632 return 0;
649 }
650 633
651 if (low != NULL) { 634 rc = ebitmap_netlbl_export(&context->range.level[0].cat,
652 rc = ebitmap_export(&context->range.level[0].cat, 635 &secattr->mls_cat);
653 low, 636 if (rc == 0 && secattr->mls_cat != NULL)
654 low_len); 637 secattr->flags |= NETLBL_SECATTR_MLS_CAT;
655 if (rc != 0)
656 goto export_cat_failure;
657 }
658 if (high != NULL) {
659 rc = ebitmap_export(&context->range.level[1].cat,
660 high,
661 high_len);
662 if (rc != 0)
663 goto export_cat_failure;
664 }
665
666 return 0;
667 638
668export_cat_failure:
669 if (low != NULL) {
670 kfree(*low);
671 *low = NULL;
672 *low_len = 0;
673 }
674 if (high != NULL) {
675 kfree(*high);
676 *high = NULL;
677 *high_len = 0;
678 }
679 return rc; 639 return rc;
680} 640}
681 641
682/** 642/**
683 * mls_import_cat - Import the MLS categories 643 * mls_import_netlbl_cat - Import the MLS categories from NetLabel
684 * @context: the security context 644 * @context: the security context
685 * @low: the low category 645 * @secattr: the NetLabel security attributes
686 * @low_len: length of the cat_low bitmap in bytes
687 * @high: the high category
688 * @high_len: length of the cat_high bitmap in bytes
689 * 646 *
690 * Description: 647 * Description:
691 * Given the security context and the two category bitmap strings import the 648 * Copy the NetLabel security attributes into the SELinux context; since the
692 * categories into the security context. The MLS categories are only imported 649 * NetLabel security attribute only contains a single MLS category use it for
693 * if the pointers are not NULL, if they are NULL they are skipped. Returns 650 * both the low and high categories of the context. Returns zero on success,
694 * zero on success, negative values on failure. 651 * negative values on failure.
695 * 652 *
696 */ 653 */
697int mls_import_cat(struct context *context, 654int mls_import_netlbl_cat(struct context *context,
698 const unsigned char *low, 655 struct netlbl_lsm_secattr *secattr)
699 size_t low_len,
700 const unsigned char *high,
701 size_t high_len)
702{ 656{
703 int rc = -EPERM; 657 int rc;
704 658
705 if (!selinux_mls_enabled) 659 if (!selinux_mls_enabled)
706 return 0; 660 return 0;
707 661
708 if (low != NULL) { 662 rc = ebitmap_netlbl_import(&context->range.level[0].cat,
709 rc = ebitmap_import(low, 663 secattr->mls_cat);
710 low_len, 664 if (rc != 0)
711 &context->range.level[0].cat); 665 goto import_netlbl_cat_failure;
712 if (rc != 0) 666
713 goto import_cat_failure; 667 rc = ebitmap_cpy(&context->range.level[1].cat,
714 } 668 &context->range.level[0].cat);
715 if (high != NULL) { 669 if (rc != 0)
716 if (high == low) 670 goto import_netlbl_cat_failure;
717 rc = ebitmap_cpy(&context->range.level[1].cat,
718 &context->range.level[0].cat);
719 else
720 rc = ebitmap_import(high,
721 high_len,
722 &context->range.level[1].cat);
723 if (rc != 0)
724 goto import_cat_failure;
725 }
726 671
727 return 0; 672 return 0;
728 673
729import_cat_failure: 674import_netlbl_cat_failure:
730 ebitmap_destroy(&context->range.level[0].cat); 675 ebitmap_destroy(&context->range.level[0].cat);
731 ebitmap_destroy(&context->range.level[1].cat); 676 ebitmap_destroy(&context->range.level[1].cat);
732 return rc; 677 return rc;
733} 678}
679#endif /* CONFIG_NETLABEL */
diff --git a/security/selinux/ss/mls.h b/security/selinux/ss/mls.h
index df6032c6d492..661d6fc76966 100644
--- a/security/selinux/ss/mls.h
+++ b/security/selinux/ss/mls.h
@@ -13,7 +13,7 @@
13/* 13/*
14 * Updated: Hewlett-Packard <paul.moore@hp.com> 14 * Updated: Hewlett-Packard <paul.moore@hp.com>
15 * 15 *
16 * Added support to import/export the MLS label 16 * Added support to import/export the MLS label from NetLabel
17 * 17 *
18 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006 18 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
19 */ 19 */
@@ -69,19 +69,37 @@ int mls_compute_sid(struct context *scontext,
69int mls_setup_user_range(struct context *fromcon, struct user_datum *user, 69int mls_setup_user_range(struct context *fromcon, struct user_datum *user,
70 struct context *usercon); 70 struct context *usercon);
71 71
72void mls_export_lvl(const struct context *context, u32 *low, u32 *high); 72#ifdef CONFIG_NETLABEL
73void mls_import_lvl(struct context *context, u32 low, u32 high); 73void mls_export_netlbl_lvl(struct context *context,
74 74 struct netlbl_lsm_secattr *secattr);
75int mls_export_cat(const struct context *context, 75void mls_import_netlbl_lvl(struct context *context,
76 unsigned char **low, 76 struct netlbl_lsm_secattr *secattr);
77 size_t *low_len, 77int mls_export_netlbl_cat(struct context *context,
78 unsigned char **high, 78 struct netlbl_lsm_secattr *secattr);
79 size_t *high_len); 79int mls_import_netlbl_cat(struct context *context,
80int mls_import_cat(struct context *context, 80 struct netlbl_lsm_secattr *secattr);
81 const unsigned char *low, 81#else
82 size_t low_len, 82static inline void mls_export_netlbl_lvl(struct context *context,
83 const unsigned char *high, 83 struct netlbl_lsm_secattr *secattr)
84 size_t high_len); 84{
85 return;
86}
87static inline void mls_import_netlbl_lvl(struct context *context,
88 struct netlbl_lsm_secattr *secattr)
89{
90 return;
91}
92static inline int mls_export_netlbl_cat(struct context *context,
93 struct netlbl_lsm_secattr *secattr)
94{
95 return -ENOMEM;
96}
97static inline int mls_import_netlbl_cat(struct context *context,
98 struct netlbl_lsm_secattr *secattr)
99{
100 return -ENOMEM;
101}
102#endif
85 103
86#endif /* _SS_MLS_H */ 104#endif /* _SS_MLS_H */
87 105
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index ba48961f9d05..cd79c6338aa0 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -468,7 +468,7 @@ static int common_destroy(void *key, void *datum, void *p)
468 return 0; 468 return 0;
469} 469}
470 470
471static int class_destroy(void *key, void *datum, void *p) 471static int cls_destroy(void *key, void *datum, void *p)
472{ 472{
473 struct class_datum *cladatum; 473 struct class_datum *cladatum;
474 struct constraint_node *constraint, *ctemp; 474 struct constraint_node *constraint, *ctemp;
@@ -566,7 +566,7 @@ static int cat_destroy(void *key, void *datum, void *p)
566static int (*destroy_f[SYM_NUM]) (void *key, void *datum, void *datap) = 566static int (*destroy_f[SYM_NUM]) (void *key, void *datum, void *datap) =
567{ 567{
568 common_destroy, 568 common_destroy,
569 class_destroy, 569 cls_destroy,
570 role_destroy, 570 role_destroy,
571 type_destroy, 571 type_destroy,
572 user_destroy, 572 user_destroy,
@@ -1124,7 +1124,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp)
1124out: 1124out:
1125 return rc; 1125 return rc;
1126bad: 1126bad:
1127 class_destroy(key, cladatum, NULL); 1127 cls_destroy(key, cladatum, NULL);
1128 goto out; 1128 goto out;
1129} 1129}
1130 1130
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index bfe122764c98..bdb7070dd3dc 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -17,9 +17,13 @@
17 * 17 *
18 * Added support for NetLabel 18 * Added support for NetLabel
19 * 19 *
20 * Updated: Chad Sellers <csellers@tresys.com>
21 *
22 * Added validation of kernel classes and permissions
23 *
20 * Copyright (C) 2006 Hewlett-Packard Development Company, L.P. 24 * Copyright (C) 2006 Hewlett-Packard Development Company, L.P.
21 * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc. 25 * Copyright (C) 2004-2006 Trusted Computer Solutions, Inc.
22 * Copyright (C) 2003 - 2004 Tresys Technology, LLC 26 * Copyright (C) 2003 - 2004, 2006 Tresys Technology, LLC
23 * Copyright (C) 2003 Red Hat, Inc., James Morris <jmorris@redhat.com> 27 * Copyright (C) 2003 Red Hat, Inc., James Morris <jmorris@redhat.com>
24 * This program is free software; you can redistribute it and/or modify 28 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License as published by 29 * it under the terms of the GNU General Public License as published by
@@ -29,6 +33,7 @@
29#include <linux/slab.h> 33#include <linux/slab.h>
30#include <linux/string.h> 34#include <linux/string.h>
31#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/rcupdate.h>
32#include <linux/errno.h> 37#include <linux/errno.h>
33#include <linux/in.h> 38#include <linux/in.h>
34#include <linux/sched.h> 39#include <linux/sched.h>
@@ -49,10 +54,17 @@
49#include "mls.h" 54#include "mls.h"
50#include "objsec.h" 55#include "objsec.h"
51#include "selinux_netlabel.h" 56#include "selinux_netlabel.h"
57#include "xfrm.h"
58#include "ebitmap.h"
52 59
53extern void selnl_notify_policyload(u32 seqno); 60extern void selnl_notify_policyload(u32 seqno);
54unsigned int policydb_loaded_version; 61unsigned int policydb_loaded_version;
55 62
63/*
64 * This is declared in avc.c
65 */
66extern const struct selinux_class_perm selinux_class_perm;
67
56static DEFINE_RWLOCK(policy_rwlock); 68static DEFINE_RWLOCK(policy_rwlock);
57#define POLICY_RDLOCK read_lock(&policy_rwlock) 69#define POLICY_RDLOCK read_lock(&policy_rwlock)
58#define POLICY_WRLOCK write_lock_irq(&policy_rwlock) 70#define POLICY_WRLOCK write_lock_irq(&policy_rwlock)
@@ -1019,86 +1031,112 @@ int security_change_sid(u32 ssid,
1019} 1031}
1020 1032
1021/* 1033/*
1022 * Verify that each permission that is defined under the 1034 * Verify that each kernel class that is defined in the
1023 * existing policy is still defined with the same value 1035 * policy is correct
1024 * in the new policy.
1025 */
1026static int validate_perm(void *key, void *datum, void *p)
1027{
1028 struct hashtab *h;
1029 struct perm_datum *perdatum, *perdatum2;
1030 int rc = 0;
1031
1032
1033 h = p;
1034 perdatum = datum;
1035
1036 perdatum2 = hashtab_search(h, key);
1037 if (!perdatum2) {
1038 printk(KERN_ERR "security: permission %s disappeared",
1039 (char *)key);
1040 rc = -ENOENT;
1041 goto out;
1042 }
1043 if (perdatum->value != perdatum2->value) {
1044 printk(KERN_ERR "security: the value of permission %s changed",
1045 (char *)key);
1046 rc = -EINVAL;
1047 }
1048out:
1049 return rc;
1050}
1051
1052/*
1053 * Verify that each class that is defined under the
1054 * existing policy is still defined with the same
1055 * attributes in the new policy.
1056 */ 1036 */
1057static int validate_class(void *key, void *datum, void *p) 1037static int validate_classes(struct policydb *p)
1058{ 1038{
1059 struct policydb *newp; 1039 int i, j;
1060 struct class_datum *cladatum, *cladatum2; 1040 struct class_datum *cladatum;
1061 int rc; 1041 struct perm_datum *perdatum;
1062 1042 u32 nprim, tmp, common_pts_len, perm_val, pol_val;
1063 newp = p; 1043 u16 class_val;
1064 cladatum = datum; 1044 const struct selinux_class_perm *kdefs = &selinux_class_perm;
1065 1045 const char *def_class, *def_perm, *pol_class;
1066 cladatum2 = hashtab_search(newp->p_classes.table, key); 1046 struct symtab *perms;
1067 if (!cladatum2) { 1047
1068 printk(KERN_ERR "security: class %s disappeared\n", 1048 for (i = 1; i < kdefs->cts_len; i++) {
1069 (char *)key); 1049 def_class = kdefs->class_to_string[i];
1070 rc = -ENOENT; 1050 if (i > p->p_classes.nprim) {
1071 goto out; 1051 printk(KERN_INFO
1072 } 1052 "security: class %s not defined in policy\n",
1073 if (cladatum->value != cladatum2->value) { 1053 def_class);
1074 printk(KERN_ERR "security: the value of class %s changed\n", 1054 continue;
1075 (char *)key); 1055 }
1076 rc = -EINVAL; 1056 pol_class = p->p_class_val_to_name[i-1];
1077 goto out; 1057 if (strcmp(pol_class, def_class)) {
1058 printk(KERN_ERR
1059 "security: class %d is incorrect, found %s but should be %s\n",
1060 i, pol_class, def_class);
1061 return -EINVAL;
1062 }
1078 } 1063 }
1079 if ((cladatum->comdatum && !cladatum2->comdatum) || 1064 for (i = 0; i < kdefs->av_pts_len; i++) {
1080 (!cladatum->comdatum && cladatum2->comdatum)) { 1065 class_val = kdefs->av_perm_to_string[i].tclass;
1081 printk(KERN_ERR "security: the inherits clause for the access " 1066 perm_val = kdefs->av_perm_to_string[i].value;
1082 "vector definition for class %s changed\n", (char *)key); 1067 def_perm = kdefs->av_perm_to_string[i].name;
1083 rc = -EINVAL; 1068 if (class_val > p->p_classes.nprim)
1084 goto out; 1069 continue;
1070 pol_class = p->p_class_val_to_name[class_val-1];
1071 cladatum = hashtab_search(p->p_classes.table, pol_class);
1072 BUG_ON(!cladatum);
1073 perms = &cladatum->permissions;
1074 nprim = 1 << (perms->nprim - 1);
1075 if (perm_val > nprim) {
1076 printk(KERN_INFO
1077 "security: permission %s in class %s not defined in policy\n",
1078 def_perm, pol_class);
1079 continue;
1080 }
1081 perdatum = hashtab_search(perms->table, def_perm);
1082 if (perdatum == NULL) {
1083 printk(KERN_ERR
1084 "security: permission %s in class %s not found in policy\n",
1085 def_perm, pol_class);
1086 return -EINVAL;
1087 }
1088 pol_val = 1 << (perdatum->value - 1);
1089 if (pol_val != perm_val) {
1090 printk(KERN_ERR
1091 "security: permission %s in class %s has incorrect value\n",
1092 def_perm, pol_class);
1093 return -EINVAL;
1094 }
1085 } 1095 }
1086 if (cladatum->comdatum) { 1096 for (i = 0; i < kdefs->av_inherit_len; i++) {
1087 rc = hashtab_map(cladatum->comdatum->permissions.table, validate_perm, 1097 class_val = kdefs->av_inherit[i].tclass;
1088 cladatum2->comdatum->permissions.table); 1098 if (class_val > p->p_classes.nprim)
1089 if (rc) { 1099 continue;
1090 printk(" in the access vector definition for class " 1100 pol_class = p->p_class_val_to_name[class_val-1];
1091 "%s\n", (char *)key); 1101 cladatum = hashtab_search(p->p_classes.table, pol_class);
1092 goto out; 1102 BUG_ON(!cladatum);
1103 if (!cladatum->comdatum) {
1104 printk(KERN_ERR
1105 "security: class %s should have an inherits clause but does not\n",
1106 pol_class);
1107 return -EINVAL;
1108 }
1109 tmp = kdefs->av_inherit[i].common_base;
1110 common_pts_len = 0;
1111 while (!(tmp & 0x01)) {
1112 common_pts_len++;
1113 tmp >>= 1;
1114 }
1115 perms = &cladatum->comdatum->permissions;
1116 for (j = 0; j < common_pts_len; j++) {
1117 def_perm = kdefs->av_inherit[i].common_pts[j];
1118 if (j >= perms->nprim) {
1119 printk(KERN_INFO
1120 "security: permission %s in class %s not defined in policy\n",
1121 def_perm, pol_class);
1122 continue;
1123 }
1124 perdatum = hashtab_search(perms->table, def_perm);
1125 if (perdatum == NULL) {
1126 printk(KERN_ERR
1127 "security: permission %s in class %s not found in policy\n",
1128 def_perm, pol_class);
1129 return -EINVAL;
1130 }
1131 if (perdatum->value != j + 1) {
1132 printk(KERN_ERR
1133 "security: permission %s in class %s has incorrect value\n",
1134 def_perm, pol_class);
1135 return -EINVAL;
1136 }
1093 } 1137 }
1094 } 1138 }
1095 rc = hashtab_map(cladatum->permissions.table, validate_perm, 1139 return 0;
1096 cladatum2->permissions.table);
1097 if (rc)
1098 printk(" in access vector definition for class %s\n",
1099 (char *)key);
1100out:
1101 return rc;
1102} 1140}
1103 1141
1104/* Clone the SID into the new SID table. */ 1142/* Clone the SID into the new SID table. */
@@ -1243,6 +1281,16 @@ int security_load_policy(void *data, size_t len)
1243 avtab_cache_destroy(); 1281 avtab_cache_destroy();
1244 return -EINVAL; 1282 return -EINVAL;
1245 } 1283 }
1284 /* Verify that the kernel defined classes are correct. */
1285 if (validate_classes(&policydb)) {
1286 printk(KERN_ERR
1287 "security: the definition of a class is incorrect\n");
1288 LOAD_UNLOCK;
1289 sidtab_destroy(&sidtab);
1290 policydb_destroy(&policydb);
1291 avtab_cache_destroy();
1292 return -EINVAL;
1293 }
1246 policydb_loaded_version = policydb.policyvers; 1294 policydb_loaded_version = policydb.policyvers;
1247 ss_initialized = 1; 1295 ss_initialized = 1;
1248 seqno = ++latest_granting; 1296 seqno = ++latest_granting;
@@ -1265,10 +1313,10 @@ int security_load_policy(void *data, size_t len)
1265 1313
1266 sidtab_init(&newsidtab); 1314 sidtab_init(&newsidtab);
1267 1315
1268 /* Verify that the existing classes did not change. */ 1316 /* Verify that the kernel defined classes are correct. */
1269 if (hashtab_map(policydb.p_classes.table, validate_class, &newpolicydb)) { 1317 if (validate_classes(&newpolicydb)) {
1270 printk(KERN_ERR "security: the definition of an existing " 1318 printk(KERN_ERR
1271 "class changed\n"); 1319 "security: the definition of a class is incorrect\n");
1272 rc = -EINVAL; 1320 rc = -EINVAL;
1273 goto err; 1321 goto err;
1274 } 1322 }
@@ -2145,6 +2193,32 @@ void selinux_audit_set_callback(int (*callback)(void))
2145 aurule_callback = callback; 2193 aurule_callback = callback;
2146} 2194}
2147 2195
2196/**
2197 * security_skb_extlbl_sid - Determine the external label of a packet
2198 * @skb: the packet
2199 * @base_sid: the SELinux SID to use as a context for MLS only external labels
2200 * @sid: the packet's SID
2201 *
2202 * Description:
2203 * Check the various different forms of external packet labeling and determine
2204 * the external SID for the packet.
2205 *
2206 */
2207void security_skb_extlbl_sid(struct sk_buff *skb, u32 base_sid, u32 *sid)
2208{
2209 u32 xfrm_sid;
2210 u32 nlbl_sid;
2211
2212 selinux_skb_xfrm_sid(skb, &xfrm_sid);
2213 if (selinux_netlbl_skbuff_getsid(skb,
2214 (xfrm_sid == SECSID_NULL ?
2215 base_sid : xfrm_sid),
2216 &nlbl_sid) != 0)
2217 nlbl_sid = SECSID_NULL;
2218
2219 *sid = (nlbl_sid == SECSID_NULL ? xfrm_sid : nlbl_sid);
2220}
2221
2148#ifdef CONFIG_NETLABEL 2222#ifdef CONFIG_NETLABEL
2149/* 2223/*
2150 * This is the structure we store inside the NetLabel cache block. 2224 * This is the structure we store inside the NetLabel cache block.
@@ -2209,8 +2283,6 @@ static void selinux_netlbl_cache_add(struct sk_buff *skb, struct context *ctx)
2209 cache = kzalloc(sizeof(*cache), GFP_ATOMIC); 2283 cache = kzalloc(sizeof(*cache), GFP_ATOMIC);
2210 if (cache == NULL) 2284 if (cache == NULL)
2211 goto netlbl_cache_add_return; 2285 goto netlbl_cache_add_return;
2212 secattr.cache->free = selinux_netlbl_cache_free;
2213 secattr.cache->data = (void *)cache;
2214 2286
2215 cache->type = NETLBL_CACHE_T_MLS; 2287 cache->type = NETLBL_CACHE_T_MLS;
2216 if (ebitmap_cpy(&cache->data.mls_label.level[0].cat, 2288 if (ebitmap_cpy(&cache->data.mls_label.level[0].cat,
@@ -2223,6 +2295,10 @@ static void selinux_netlbl_cache_add(struct sk_buff *skb, struct context *ctx)
2223 cache->data.mls_label.level[0].sens = ctx->range.level[0].sens; 2295 cache->data.mls_label.level[0].sens = ctx->range.level[0].sens;
2224 cache->data.mls_label.level[1].sens = ctx->range.level[0].sens; 2296 cache->data.mls_label.level[1].sens = ctx->range.level[0].sens;
2225 2297
2298 secattr.cache->free = selinux_netlbl_cache_free;
2299 secattr.cache->data = (void *)cache;
2300 secattr.flags = NETLBL_SECATTR_CACHE;
2301
2226 netlbl_cache_add(skb, &secattr); 2302 netlbl_cache_add(skb, &secattr);
2227 2303
2228netlbl_cache_add_return: 2304netlbl_cache_add_return:
@@ -2268,7 +2344,7 @@ static int selinux_netlbl_secattr_to_sid(struct sk_buff *skb,
2268 2344
2269 POLICY_RDLOCK; 2345 POLICY_RDLOCK;
2270 2346
2271 if (secattr->cache) { 2347 if (secattr->flags & NETLBL_SECATTR_CACHE) {
2272 cache = NETLBL_CACHE(secattr->cache->data); 2348 cache = NETLBL_CACHE(secattr->cache->data);
2273 switch (cache->type) { 2349 switch (cache->type) {
2274 case NETLBL_CACHE_T_SID: 2350 case NETLBL_CACHE_T_SID:
@@ -2301,7 +2377,7 @@ static int selinux_netlbl_secattr_to_sid(struct sk_buff *skb,
2301 default: 2377 default:
2302 goto netlbl_secattr_to_sid_return; 2378 goto netlbl_secattr_to_sid_return;
2303 } 2379 }
2304 } else if (secattr->mls_lvl_vld) { 2380 } else if (secattr->flags & NETLBL_SECATTR_MLS_LVL) {
2305 ctx = sidtab_search(&sidtab, base_sid); 2381 ctx = sidtab_search(&sidtab, base_sid);
2306 if (ctx == NULL) 2382 if (ctx == NULL)
2307 goto netlbl_secattr_to_sid_return; 2383 goto netlbl_secattr_to_sid_return;
@@ -2309,13 +2385,10 @@ static int selinux_netlbl_secattr_to_sid(struct sk_buff *skb,
2309 ctx_new.user = ctx->user; 2385 ctx_new.user = ctx->user;
2310 ctx_new.role = ctx->role; 2386 ctx_new.role = ctx->role;
2311 ctx_new.type = ctx->type; 2387 ctx_new.type = ctx->type;
2312 mls_import_lvl(&ctx_new, secattr->mls_lvl, secattr->mls_lvl); 2388 mls_import_netlbl_lvl(&ctx_new, secattr);
2313 if (secattr->mls_cat) { 2389 if (secattr->flags & NETLBL_SECATTR_MLS_CAT) {
2314 if (mls_import_cat(&ctx_new, 2390 if (ebitmap_netlbl_import(&ctx_new.range.level[0].cat,
2315 secattr->mls_cat, 2391 secattr->mls_cat) != 0)
2316 secattr->mls_cat_len,
2317 NULL,
2318 0) != 0)
2319 goto netlbl_secattr_to_sid_return; 2392 goto netlbl_secattr_to_sid_return;
2320 ctx_new.range.level[1].cat.highbit = 2393 ctx_new.range.level[1].cat.highbit =
2321 ctx_new.range.level[0].cat.highbit; 2394 ctx_new.range.level[0].cat.highbit;
@@ -2360,20 +2433,20 @@ netlbl_secattr_to_sid_return_cleanup:
2360 * assign to the packet. Returns zero on success, negative values on failure. 2433 * assign to the packet. Returns zero on success, negative values on failure.
2361 * 2434 *
2362 */ 2435 */
2363static int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, 2436int selinux_netlbl_skbuff_getsid(struct sk_buff *skb, u32 base_sid, u32 *sid)
2364 u32 base_sid,
2365 u32 *sid)
2366{ 2437{
2367 int rc; 2438 int rc;
2368 struct netlbl_lsm_secattr secattr; 2439 struct netlbl_lsm_secattr secattr;
2369 2440
2370 netlbl_secattr_init(&secattr); 2441 netlbl_secattr_init(&secattr);
2371 rc = netlbl_skbuff_getattr(skb, &secattr); 2442 rc = netlbl_skbuff_getattr(skb, &secattr);
2372 if (rc == 0) 2443 if (rc == 0 && secattr.flags != NETLBL_SECATTR_NONE)
2373 rc = selinux_netlbl_secattr_to_sid(skb, 2444 rc = selinux_netlbl_secattr_to_sid(skb,
2374 &secattr, 2445 &secattr,
2375 base_sid, 2446 base_sid,
2376 sid); 2447 sid);
2448 else
2449 *sid = SECSID_NULL;
2377 netlbl_secattr_destroy(&secattr); 2450 netlbl_secattr_destroy(&secattr);
2378 2451
2379 return rc; 2452 return rc;
@@ -2386,7 +2459,9 @@ static int selinux_netlbl_skbuff_getsid(struct sk_buff *skb,
2386 * 2459 *
2387 * Description: 2460 * Description:
2388 * Attempt to label a socket using the NetLabel mechanism using the given 2461 * Attempt to label a socket using the NetLabel mechanism using the given
2389 * SID. Returns zero values on success, negative values on failure. 2462 * SID. Returns zero values on success, negative values on failure. The
2463 * caller is responsibile for calling rcu_read_lock() before calling this
2464 * this function and rcu_read_unlock() after this function returns.
2390 * 2465 *
2391 */ 2466 */
2392static int selinux_netlbl_socket_setsid(struct socket *sock, u32 sid) 2467static int selinux_netlbl_socket_setsid(struct socket *sock, u32 sid)
@@ -2409,19 +2484,18 @@ static int selinux_netlbl_socket_setsid(struct socket *sock, u32 sid)
2409 2484
2410 secattr.domain = kstrdup(policydb.p_type_val_to_name[ctx->type - 1], 2485 secattr.domain = kstrdup(policydb.p_type_val_to_name[ctx->type - 1],
2411 GFP_ATOMIC); 2486 GFP_ATOMIC);
2412 mls_export_lvl(ctx, &secattr.mls_lvl, NULL); 2487 secattr.flags |= NETLBL_SECATTR_DOMAIN;
2413 secattr.mls_lvl_vld = 1; 2488 mls_export_netlbl_lvl(ctx, &secattr);
2414 rc = mls_export_cat(ctx, 2489 rc = mls_export_netlbl_cat(ctx, &secattr);
2415 &secattr.mls_cat,
2416 &secattr.mls_cat_len,
2417 NULL,
2418 NULL);
2419 if (rc != 0) 2490 if (rc != 0)
2420 goto netlbl_socket_setsid_return; 2491 goto netlbl_socket_setsid_return;
2421 2492
2422 rc = netlbl_socket_setattr(sock, &secattr); 2493 rc = netlbl_socket_setattr(sock, &secattr);
2423 if (rc == 0) 2494 if (rc == 0) {
2495 spin_lock(&sksec->nlbl_lock);
2424 sksec->nlbl_state = NLBL_LABELED; 2496 sksec->nlbl_state = NLBL_LABELED;
2497 spin_unlock(&sksec->nlbl_lock);
2498 }
2425 2499
2426netlbl_socket_setsid_return: 2500netlbl_socket_setsid_return:
2427 POLICY_RDUNLOCK; 2501 POLICY_RDUNLOCK;
@@ -2430,6 +2504,25 @@ netlbl_socket_setsid_return:
2430} 2504}
2431 2505
2432/** 2506/**
2507 * selinux_netlbl_sk_security_reset - Reset the NetLabel fields
2508 * @ssec: the sk_security_struct
2509 * @family: the socket family
2510 *
2511 * Description:
2512 * Called when the NetLabel state of a sk_security_struct needs to be reset.
2513 * The caller is responsibile for all the NetLabel sk_security_struct locking.
2514 *
2515 */
2516void selinux_netlbl_sk_security_reset(struct sk_security_struct *ssec,
2517 int family)
2518{
2519 if (family == PF_INET)
2520 ssec->nlbl_state = NLBL_REQUIRE;
2521 else
2522 ssec->nlbl_state = NLBL_UNSET;
2523}
2524
2525/**
2433 * selinux_netlbl_sk_security_init - Setup the NetLabel fields 2526 * selinux_netlbl_sk_security_init - Setup the NetLabel fields
2434 * @ssec: the sk_security_struct 2527 * @ssec: the sk_security_struct
2435 * @family: the socket family 2528 * @family: the socket family
@@ -2442,14 +2535,13 @@ netlbl_socket_setsid_return:
2442void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec, 2535void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec,
2443 int family) 2536 int family)
2444{ 2537{
2445 if (family == PF_INET) 2538 /* No locking needed, we are the only one who has access to ssec */
2446 ssec->nlbl_state = NLBL_REQUIRE; 2539 selinux_netlbl_sk_security_reset(ssec, family);
2447 else 2540 spin_lock_init(&ssec->nlbl_lock);
2448 ssec->nlbl_state = NLBL_UNSET;
2449} 2541}
2450 2542
2451/** 2543/**
2452 * selinux_netlbl_sk_clone_security - Copy the NetLabel fields 2544 * selinux_netlbl_sk_security_clone - Copy the NetLabel fields
2453 * @ssec: the original sk_security_struct 2545 * @ssec: the original sk_security_struct
2454 * @newssec: the cloned sk_security_struct 2546 * @newssec: the cloned sk_security_struct
2455 * 2547 *
@@ -2458,41 +2550,41 @@ void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec,
2458 * @newssec. 2550 * @newssec.
2459 * 2551 *
2460 */ 2552 */
2461void selinux_netlbl_sk_clone_security(struct sk_security_struct *ssec, 2553void selinux_netlbl_sk_security_clone(struct sk_security_struct *ssec,
2462 struct sk_security_struct *newssec) 2554 struct sk_security_struct *newssec)
2463{ 2555{
2556 /* We don't need to take newssec->nlbl_lock because we are the only
2557 * thread with access to newssec, but we do need to take the RCU read
2558 * lock as other threads could have access to ssec */
2559 rcu_read_lock();
2560 selinux_netlbl_sk_security_reset(newssec, ssec->sk->sk_family);
2464 newssec->sclass = ssec->sclass; 2561 newssec->sclass = ssec->sclass;
2465 if (ssec->nlbl_state != NLBL_UNSET) 2562 rcu_read_unlock();
2466 newssec->nlbl_state = NLBL_REQUIRE;
2467 else
2468 newssec->nlbl_state = NLBL_UNSET;
2469} 2563}
2470 2564
2471/** 2565/**
2472 * selinux_netlbl_socket_post_create - Label a socket using NetLabel 2566 * selinux_netlbl_socket_post_create - Label a socket using NetLabel
2473 * @sock: the socket to label 2567 * @sock: the socket to label
2474 * @sock_family: the socket family
2475 * @sid: the SID to use
2476 * 2568 *
2477 * Description: 2569 * Description:
2478 * Attempt to label a socket using the NetLabel mechanism using the given 2570 * Attempt to label a socket using the NetLabel mechanism using the given
2479 * SID. Returns zero values on success, negative values on failure. 2571 * SID. Returns zero values on success, negative values on failure.
2480 * 2572 *
2481 */ 2573 */
2482int selinux_netlbl_socket_post_create(struct socket *sock, 2574int selinux_netlbl_socket_post_create(struct socket *sock)
2483 int sock_family,
2484 u32 sid)
2485{ 2575{
2576 int rc = 0;
2486 struct inode_security_struct *isec = SOCK_INODE(sock)->i_security; 2577 struct inode_security_struct *isec = SOCK_INODE(sock)->i_security;
2487 struct sk_security_struct *sksec = sock->sk->sk_security; 2578 struct sk_security_struct *sksec = sock->sk->sk_security;
2488 2579
2489 sksec->sclass = isec->sclass; 2580 sksec->sclass = isec->sclass;
2490 2581
2491 if (sock_family != PF_INET) 2582 rcu_read_lock();
2492 return 0; 2583 if (sksec->nlbl_state == NLBL_REQUIRE)
2584 rc = selinux_netlbl_socket_setsid(sock, sksec->sid);
2585 rcu_read_unlock();
2493 2586
2494 sksec->nlbl_state = NLBL_REQUIRE; 2587 return rc;
2495 return selinux_netlbl_socket_setsid(sock, sid);
2496} 2588}
2497 2589
2498/** 2590/**
@@ -2514,11 +2606,16 @@ void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock)
2514 2606
2515 sksec->sclass = isec->sclass; 2607 sksec->sclass = isec->sclass;
2516 2608
2517 if (sk->sk_family != PF_INET) 2609 rcu_read_lock();
2610
2611 if (sksec->nlbl_state != NLBL_REQUIRE) {
2612 rcu_read_unlock();
2518 return; 2613 return;
2614 }
2519 2615
2520 netlbl_secattr_init(&secattr); 2616 netlbl_secattr_init(&secattr);
2521 if (netlbl_sock_getattr(sk, &secattr) == 0 && 2617 if (netlbl_sock_getattr(sk, &secattr) == 0 &&
2618 secattr.flags != NETLBL_SECATTR_NONE &&
2522 selinux_netlbl_secattr_to_sid(NULL, 2619 selinux_netlbl_secattr_to_sid(NULL,
2523 &secattr, 2620 &secattr,
2524 SECINITSID_UNLABELED, 2621 SECINITSID_UNLABELED,
@@ -2526,35 +2623,12 @@ void selinux_netlbl_sock_graft(struct sock *sk, struct socket *sock)
2526 sksec->peer_sid = nlbl_peer_sid; 2623 sksec->peer_sid = nlbl_peer_sid;
2527 netlbl_secattr_destroy(&secattr); 2624 netlbl_secattr_destroy(&secattr);
2528 2625
2529 sksec->nlbl_state = NLBL_REQUIRE;
2530
2531 /* Try to set the NetLabel on the socket to save time later, if we fail 2626 /* Try to set the NetLabel on the socket to save time later, if we fail
2532 * here we will pick up the pieces in later calls to 2627 * here we will pick up the pieces in later calls to
2533 * selinux_netlbl_inode_permission(). */ 2628 * selinux_netlbl_inode_permission(). */
2534 selinux_netlbl_socket_setsid(sock, sksec->sid); 2629 selinux_netlbl_socket_setsid(sock, sksec->sid);
2535}
2536
2537/**
2538 * selinux_netlbl_inet_conn_request - Handle a new connection request
2539 * @skb: the packet
2540 * @sock_sid: the SID of the parent socket
2541 *
2542 * Description:
2543 * If present, use the security attributes of the packet in @skb and the
2544 * parent sock's SID to arrive at a SID for the new child sock. Returns the
2545 * SID of the connection or SECSID_NULL on failure.
2546 *
2547 */
2548u32 selinux_netlbl_inet_conn_request(struct sk_buff *skb, u32 sock_sid)
2549{
2550 int rc;
2551 u32 peer_sid;
2552
2553 rc = selinux_netlbl_skbuff_getsid(skb, sock_sid, &peer_sid);
2554 if (rc != 0)
2555 return SECSID_NULL;
2556 2630
2557 return peer_sid; 2631 rcu_read_unlock();
2558} 2632}
2559 2633
2560/** 2634/**
@@ -2572,25 +2646,24 @@ u32 selinux_netlbl_inet_conn_request(struct sk_buff *skb, u32 sock_sid)
2572int selinux_netlbl_inode_permission(struct inode *inode, int mask) 2646int selinux_netlbl_inode_permission(struct inode *inode, int mask)
2573{ 2647{
2574 int rc; 2648 int rc;
2575 struct inode_security_struct *isec;
2576 struct sk_security_struct *sksec; 2649 struct sk_security_struct *sksec;
2577 struct socket *sock; 2650 struct socket *sock;
2578 2651
2579 if (!S_ISSOCK(inode->i_mode)) 2652 if (!S_ISSOCK(inode->i_mode) ||
2653 ((mask & (MAY_WRITE | MAY_APPEND)) == 0))
2580 return 0; 2654 return 0;
2581
2582 sock = SOCKET_I(inode); 2655 sock = SOCKET_I(inode);
2583 isec = inode->i_security;
2584 sksec = sock->sk->sk_security; 2656 sksec = sock->sk->sk_security;
2585 mutex_lock(&isec->lock); 2657
2586 if (unlikely(sksec->nlbl_state == NLBL_REQUIRE && 2658 rcu_read_lock();
2587 (mask & (MAY_WRITE | MAY_APPEND)))) { 2659 if (sksec->nlbl_state != NLBL_REQUIRE) {
2588 lock_sock(sock->sk); 2660 rcu_read_unlock();
2589 rc = selinux_netlbl_socket_setsid(sock, sksec->sid); 2661 return 0;
2590 release_sock(sock->sk); 2662 }
2591 } else 2663 lock_sock(sock->sk);
2592 rc = 0; 2664 rc = selinux_netlbl_socket_setsid(sock, sksec->sid);
2593 mutex_unlock(&isec->lock); 2665 release_sock(sock->sk);
2666 rcu_read_unlock();
2594 2667
2595 return rc; 2668 return rc;
2596} 2669}
@@ -2648,42 +2721,6 @@ int selinux_netlbl_sock_rcv_skb(struct sk_security_struct *sksec,
2648} 2721}
2649 2722
2650/** 2723/**
2651 * selinux_netlbl_socket_getpeersec_stream - Return the connected peer's SID
2652 * @sock: the socket
2653 *
2654 * Description:
2655 * Examine @sock to find the connected peer's SID. Returns the SID on success
2656 * or SECSID_NULL on error.
2657 *
2658 */
2659u32 selinux_netlbl_socket_getpeersec_stream(struct socket *sock)
2660{
2661 struct sk_security_struct *sksec = sock->sk->sk_security;
2662 return sksec->peer_sid;
2663}
2664
2665/**
2666 * selinux_netlbl_socket_getpeersec_dgram - Return the SID of a NetLabel packet
2667 * @skb: the packet
2668 *
2669 * Description:
2670 * Examine @skb to find the SID assigned to it by NetLabel. Returns the SID on
2671 * success, SECSID_NULL on error.
2672 *
2673 */
2674u32 selinux_netlbl_socket_getpeersec_dgram(struct sk_buff *skb)
2675{
2676 int peer_sid;
2677
2678 if (selinux_netlbl_skbuff_getsid(skb,
2679 SECINITSID_UNLABELED,
2680 &peer_sid) != 0)
2681 return SECSID_NULL;
2682
2683 return peer_sid;
2684}
2685
2686/**
2687 * selinux_netlbl_socket_setsockopt - Do not allow users to remove a NetLabel 2724 * selinux_netlbl_socket_setsockopt - Do not allow users to remove a NetLabel
2688 * @sock: the socket 2725 * @sock: the socket
2689 * @level: the socket level or protocol 2726 * @level: the socket level or protocol
@@ -2701,21 +2738,19 @@ int selinux_netlbl_socket_setsockopt(struct socket *sock,
2701 int optname) 2738 int optname)
2702{ 2739{
2703 int rc = 0; 2740 int rc = 0;
2704 struct inode *inode = SOCK_INODE(sock);
2705 struct sk_security_struct *sksec = sock->sk->sk_security; 2741 struct sk_security_struct *sksec = sock->sk->sk_security;
2706 struct inode_security_struct *isec = inode->i_security;
2707 struct netlbl_lsm_secattr secattr; 2742 struct netlbl_lsm_secattr secattr;
2708 2743
2709 mutex_lock(&isec->lock); 2744 rcu_read_lock();
2710 if (level == IPPROTO_IP && optname == IP_OPTIONS && 2745 if (level == IPPROTO_IP && optname == IP_OPTIONS &&
2711 sksec->nlbl_state == NLBL_LABELED) { 2746 sksec->nlbl_state == NLBL_LABELED) {
2712 netlbl_secattr_init(&secattr); 2747 netlbl_secattr_init(&secattr);
2713 rc = netlbl_socket_getattr(sock, &secattr); 2748 rc = netlbl_socket_getattr(sock, &secattr);
2714 if (rc == 0 && (secattr.cache || secattr.mls_lvl_vld)) 2749 if (rc == 0 && secattr.flags != NETLBL_SECATTR_NONE)
2715 rc = -EACCES; 2750 rc = -EACCES;
2716 netlbl_secattr_destroy(&secattr); 2751 netlbl_secattr_destroy(&secattr);
2717 } 2752 }
2718 mutex_unlock(&isec->lock); 2753 rcu_read_unlock();
2719 2754
2720 return rc; 2755 return rc;
2721} 2756}
diff --git a/security/selinux/ss/symtab.c b/security/selinux/ss/symtab.c
index 24a10d36d3b6..837658a98a54 100644
--- a/security/selinux/ss/symtab.c
+++ b/security/selinux/ss/symtab.c
@@ -9,9 +9,9 @@
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include "symtab.h" 10#include "symtab.h"
11 11
12static unsigned int symhash(struct hashtab *h, void *key) 12static unsigned int symhash(struct hashtab *h, const void *key)
13{ 13{
14 char *p, *keyp; 14 const char *p, *keyp;
15 unsigned int size; 15 unsigned int size;
16 unsigned int val; 16 unsigned int val;
17 17
@@ -23,9 +23,9 @@ static unsigned int symhash(struct hashtab *h, void *key)
23 return val & (h->size - 1); 23 return val & (h->size - 1);
24} 24}
25 25
26static int symcmp(struct hashtab *h, void *key1, void *key2) 26static int symcmp(struct hashtab *h, const void *key1, const void *key2)
27{ 27{
28 char *keyp1, *keyp2; 28 const char *keyp1, *keyp2;
29 29
30 keyp1 = key1; 30 keyp1 = key1;
31 keyp2 = key2; 31 keyp2 = key2;
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index 675b995a67c3..bd8d1ef40a90 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -115,76 +115,46 @@ int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x, struct xfrm_policy *
115 struct flowi *fl) 115 struct flowi *fl)
116{ 116{
117 u32 state_sid; 117 u32 state_sid;
118 u32 pol_sid; 118 int rc;
119 int err;
120 119
121 if (xp->security) { 120 if (!xp->security)
122 if (!x->security)
123 /* unlabeled SA and labeled policy can't match */
124 return 0;
125 else
126 state_sid = x->security->ctx_sid;
127 pol_sid = xp->security->ctx_sid;
128 } else
129 if (x->security) 121 if (x->security)
130 /* unlabeled policy and labeled SA can't match */ 122 /* unlabeled policy and labeled SA can't match */
131 return 0; 123 return 0;
132 else 124 else
133 /* unlabeled policy and unlabeled SA match all flows */ 125 /* unlabeled policy and unlabeled SA match all flows */
134 return 1; 126 return 1;
135
136 err = avc_has_perm(state_sid, pol_sid, SECCLASS_ASSOCIATION,
137 ASSOCIATION__POLMATCH,
138 NULL);
139
140 if (err)
141 return 0;
142
143 err = avc_has_perm(fl->secid, state_sid, SECCLASS_ASSOCIATION,
144 ASSOCIATION__SENDTO,
145 NULL)? 0:1;
146
147 return err;
148}
149
150/*
151 * LSM hook implementation that authorizes that a particular outgoing flow
152 * can use a given security association.
153 */
154
155int selinux_xfrm_flow_state_match(struct flowi *fl, struct xfrm_state *xfrm,
156 struct xfrm_policy *xp)
157{
158 int rc = 0;
159 u32 sel_sid = SECINITSID_UNLABELED;
160 struct xfrm_sec_ctx *ctx;
161
162 if (!xp->security)
163 if (!xfrm->security)
164 return 1;
165 else
166 return 0;
167 else 127 else
168 if (!xfrm->security) 128 if (!x->security)
129 /* unlabeled SA and labeled policy can't match */
169 return 0; 130 return 0;
131 else
132 if (!selinux_authorizable_xfrm(x))
133 /* Not a SELinux-labeled SA */
134 return 0;
170 135
171 /* Context sid is either set to label or ANY_ASSOC */ 136 state_sid = x->security->ctx_sid;
172 if ((ctx = xfrm->security)) {
173 if (!selinux_authorizable_ctx(ctx))
174 return 0;
175 137
176 sel_sid = ctx->ctx_sid; 138 if (fl->secid != state_sid)
177 } 139 return 0;
178 140
179 rc = avc_has_perm(fl->secid, sel_sid, SECCLASS_ASSOCIATION, 141 rc = avc_has_perm(fl->secid, state_sid, SECCLASS_ASSOCIATION,
180 ASSOCIATION__SENDTO, 142 ASSOCIATION__SENDTO,
181 NULL)? 0:1; 143 NULL)? 0:1;
182 144
145 /*
146 * We don't need a separate SA Vs. policy polmatch check
147 * since the SA is now of the same label as the flow and
148 * a flow Vs. policy polmatch check had already happened
149 * in selinux_xfrm_policy_lookup() above.
150 */
151
183 return rc; 152 return rc;
184} 153}
185 154
186/* 155/*
187 * LSM hook implementation that determines the sid for the session. 156 * LSM hook implementation that checks and/or returns the xfrm sid for the
157 * incoming packet.
188 */ 158 */
189 159
190int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall) 160int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall)
@@ -226,16 +196,15 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall)
226 * CTX does not have a meaningful value on input 196 * CTX does not have a meaningful value on input
227 */ 197 */
228static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp, 198static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp,
229 struct xfrm_user_sec_ctx *uctx, struct xfrm_sec_ctx *pol, u32 sid) 199 struct xfrm_user_sec_ctx *uctx, u32 sid)
230{ 200{
231 int rc = 0; 201 int rc = 0;
232 struct task_security_struct *tsec = current->security; 202 struct task_security_struct *tsec = current->security;
233 struct xfrm_sec_ctx *ctx = NULL; 203 struct xfrm_sec_ctx *ctx = NULL;
234 char *ctx_str = NULL; 204 char *ctx_str = NULL;
235 u32 str_len; 205 u32 str_len;
236 u32 ctx_sid;
237 206
238 BUG_ON(uctx && pol); 207 BUG_ON(uctx && sid);
239 208
240 if (!uctx) 209 if (!uctx)
241 goto not_from_user; 210 goto not_from_user;
@@ -279,15 +248,7 @@ static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp,
279 return rc; 248 return rc;
280 249
281not_from_user: 250not_from_user:
282 if (pol) { 251 rc = security_sid_to_context(sid, &ctx_str, &str_len);
283 rc = security_sid_mls_copy(pol->ctx_sid, sid, &ctx_sid);
284 if (rc)
285 goto out;
286 }
287 else
288 ctx_sid = sid;
289
290 rc = security_sid_to_context(ctx_sid, &ctx_str, &str_len);
291 if (rc) 252 if (rc)
292 goto out; 253 goto out;
293 254
@@ -302,7 +263,7 @@ not_from_user:
302 263
303 ctx->ctx_doi = XFRM_SC_DOI_LSM; 264 ctx->ctx_doi = XFRM_SC_DOI_LSM;
304 ctx->ctx_alg = XFRM_SC_ALG_SELINUX; 265 ctx->ctx_alg = XFRM_SC_ALG_SELINUX;
305 ctx->ctx_sid = ctx_sid; 266 ctx->ctx_sid = sid;
306 ctx->ctx_len = str_len; 267 ctx->ctx_len = str_len;
307 memcpy(ctx->ctx_str, 268 memcpy(ctx->ctx_str,
308 ctx_str, 269 ctx_str,
@@ -323,22 +284,14 @@ out2:
323 * xfrm_policy. 284 * xfrm_policy.
324 */ 285 */
325int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, 286int selinux_xfrm_policy_alloc(struct xfrm_policy *xp,
326 struct xfrm_user_sec_ctx *uctx, struct sock *sk) 287 struct xfrm_user_sec_ctx *uctx)
327{ 288{
328 int err; 289 int err;
329 u32 sid;
330 290
331 BUG_ON(!xp); 291 BUG_ON(!xp);
332 BUG_ON(uctx && sk); 292 BUG_ON(!uctx);
333
334 if (sk) {
335 struct sk_security_struct *ssec = sk->sk_security;
336 sid = ssec->sid;
337 }
338 else
339 sid = SECSID_NULL;
340 293
341 err = selinux_xfrm_sec_ctx_alloc(&xp->security, uctx, NULL, sid); 294 err = selinux_xfrm_sec_ctx_alloc(&xp->security, uctx, 0);
342 return err; 295 return err;
343} 296}
344 297
@@ -399,13 +352,13 @@ int selinux_xfrm_policy_delete(struct xfrm_policy *xp)
399 * xfrm_state. 352 * xfrm_state.
400 */ 353 */
401int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *uctx, 354int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *uctx,
402 struct xfrm_sec_ctx *pol, u32 secid) 355 u32 secid)
403{ 356{
404 int err; 357 int err;
405 358
406 BUG_ON(!x); 359 BUG_ON(!x);
407 360
408 err = selinux_xfrm_sec_ctx_alloc(&x->security, uctx, pol, secid); 361 err = selinux_xfrm_sec_ctx_alloc(&x->security, uctx, secid);
409 return err; 362 return err;
410} 363}
411 364
@@ -419,74 +372,6 @@ void selinux_xfrm_state_free(struct xfrm_state *x)
419 kfree(ctx); 372 kfree(ctx);
420} 373}
421 374
422/*
423 * SELinux internal function to retrieve the context of a connected
424 * (sk->sk_state == TCP_ESTABLISHED) TCP socket based on its security
425 * association used to connect to the remote socket.
426 *
427 * Retrieve via getsockopt SO_PEERSEC.
428 */
429u32 selinux_socket_getpeer_stream(struct sock *sk)
430{
431 struct dst_entry *dst, *dst_test;
432 u32 peer_sid = SECSID_NULL;
433
434 if (sk->sk_state != TCP_ESTABLISHED)
435 goto out;
436
437 dst = sk_dst_get(sk);
438 if (!dst)
439 goto out;
440
441 for (dst_test = dst; dst_test != 0;
442 dst_test = dst_test->child) {
443 struct xfrm_state *x = dst_test->xfrm;
444
445 if (x && selinux_authorizable_xfrm(x)) {
446 struct xfrm_sec_ctx *ctx = x->security;
447 peer_sid = ctx->ctx_sid;
448 break;
449 }
450 }
451 dst_release(dst);
452
453out:
454 return peer_sid;
455}
456
457/*
458 * SELinux internal function to retrieve the context of a UDP packet
459 * based on its security association used to connect to the remote socket.
460 *
461 * Retrieve via setsockopt IP_PASSSEC and recvmsg with control message
462 * type SCM_SECURITY.
463 */
464u32 selinux_socket_getpeer_dgram(struct sk_buff *skb)
465{
466 struct sec_path *sp;
467
468 if (skb == NULL)
469 return SECSID_NULL;
470
471 if (skb->sk->sk_protocol != IPPROTO_UDP)
472 return SECSID_NULL;
473
474 sp = skb->sp;
475 if (sp) {
476 int i;
477
478 for (i = sp->len-1; i >= 0; i--) {
479 struct xfrm_state *x = sp->xvec[i];
480 if (selinux_authorizable_xfrm(x)) {
481 struct xfrm_sec_ctx *ctx = x->security;
482 return ctx->ctx_sid;
483 }
484 }
485 }
486
487 return SECSID_NULL;
488}
489
490 /* 375 /*
491 * LSM hook implementation that authorizes deletion of labeled SAs. 376 * LSM hook implementation that authorizes deletion of labeled SAs.
492 */ 377 */
@@ -532,6 +417,13 @@ int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb,
532 } 417 }
533 } 418 }
534 419
420 /*
421 * This check even when there's no association involved is
422 * intended, according to Trent Jaeger, to make sure a
423 * process can't engage in non-ipsec communication unless
424 * explicitly allowed by policy.
425 */
426
535 rc = avc_has_perm(isec_sid, sel_sid, SECCLASS_ASSOCIATION, 427 rc = avc_has_perm(isec_sid, sel_sid, SECCLASS_ASSOCIATION,
536 ASSOCIATION__RECVFROM, ad); 428 ASSOCIATION__RECVFROM, ad);
537 429
@@ -543,10 +435,10 @@ int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb,
543 * If we have no security association, then we need to determine 435 * If we have no security association, then we need to determine
544 * whether the socket is allowed to send to an unlabelled destination. 436 * whether the socket is allowed to send to an unlabelled destination.
545 * If we do have a authorizable security association, then it has already been 437 * If we do have a authorizable security association, then it has already been
546 * checked in xfrm_policy_lookup hook. 438 * checked in the selinux_xfrm_state_pol_flow_match hook above.
547 */ 439 */
548int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb, 440int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb,
549 struct avc_audit_data *ad) 441 struct avc_audit_data *ad, u8 proto)
550{ 442{
551 struct dst_entry *dst; 443 struct dst_entry *dst;
552 int rc = 0; 444 int rc = 0;
@@ -565,6 +457,27 @@ int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb,
565 } 457 }
566 } 458 }
567 459
460 switch (proto) {
461 case IPPROTO_AH:
462 case IPPROTO_ESP:
463 case IPPROTO_COMP:
464 /*
465 * We should have already seen this packet once before
466 * it underwent xfrm(s). No need to subject it to the
467 * unlabeled check.
468 */
469 goto out;
470 default:
471 break;
472 }
473
474 /*
475 * This check even when there's no association involved is
476 * intended, according to Trent Jaeger, to make sure a
477 * process can't engage in non-ipsec communication unless
478 * explicitly allowed by policy.
479 */
480
568 rc = avc_has_perm(isec_sid, SECINITSID_UNLABELED, SECCLASS_ASSOCIATION, 481 rc = avc_has_perm(isec_sid, SECINITSID_UNLABELED, SECCLASS_ASSOCIATION,
569 ASSOCIATION__SENDTO, ad); 482 ASSOCIATION__SENDTO, ad);
570out: 483out:
diff --git a/sound/Kconfig b/sound/Kconfig
index e0d791a98452..95949b6806ac 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -64,11 +64,11 @@ source "sound/arm/Kconfig"
64 64
65source "sound/mips/Kconfig" 65source "sound/mips/Kconfig"
66 66
67# the following will depenend on the order of config. 67# the following will depend on the order of config.
68# here assuming USB is defined before ALSA 68# here assuming USB is defined before ALSA
69source "sound/usb/Kconfig" 69source "sound/usb/Kconfig"
70 70
71# the following will depenend on the order of config. 71# the following will depend on the order of config.
72# here assuming PCMCIA is defined before ALSA 72# here assuming PCMCIA is defined before ALSA
73source "sound/pcmcia/Kconfig" 73source "sound/pcmcia/Kconfig"
74 74
diff --git a/sound/aoa/codecs/snd-aoa-codec-tas.c b/sound/aoa/codecs/snd-aoa-codec-tas.c
index 2ef55a17917c..9de8485ba3f5 100644
--- a/sound/aoa/codecs/snd-aoa-codec-tas.c
+++ b/sound/aoa/codecs/snd-aoa-codec-tas.c
@@ -514,9 +514,15 @@ static int tas_snd_capture_source_put(struct snd_kcontrol *kcontrol,
514 mutex_lock(&tas->mtx); 514 mutex_lock(&tas->mtx);
515 oldacr = tas->acr; 515 oldacr = tas->acr;
516 516
517 tas->acr &= ~TAS_ACR_INPUT_B; 517 /*
518 * Despite what the data sheet says in one place, the
519 * TAS_ACR_B_MONAUREAL bit forces mono output even when
520 * input A (line in) is selected.
521 */
522 tas->acr &= ~(TAS_ACR_INPUT_B | TAS_ACR_B_MONAUREAL);
518 if (ucontrol->value.enumerated.item[0]) 523 if (ucontrol->value.enumerated.item[0])
519 tas->acr |= TAS_ACR_INPUT_B; 524 tas->acr |= TAS_ACR_INPUT_B | TAS_ACR_B_MONAUREAL |
525 TAS_ACR_B_MON_SEL_RIGHT;
520 if (oldacr == tas->acr) { 526 if (oldacr == tas->acr) {
521 mutex_unlock(&tas->mtx); 527 mutex_unlock(&tas->mtx);
522 return 0; 528 return 0;
@@ -686,8 +692,7 @@ static int tas_reset_init(struct tas *tas)
686 if (tas_write_reg(tas, TAS_REG_MCS, 1, &tmp)) 692 if (tas_write_reg(tas, TAS_REG_MCS, 1, &tmp))
687 goto outerr; 693 goto outerr;
688 694
689 tas->acr |= TAS_ACR_ANALOG_PDOWN | TAS_ACR_B_MONAUREAL | 695 tas->acr |= TAS_ACR_ANALOG_PDOWN;
690 TAS_ACR_B_MON_SEL_RIGHT;
691 if (tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr)) 696 if (tas_write_reg(tas, TAS_REG_ACR, 1, &tas->acr))
692 goto outerr; 697 goto outerr;
693 698
diff --git a/sound/core/init.c b/sound/core/init.c
index 3058d626a90a..6152a7554dfd 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -361,6 +361,8 @@ static int snd_card_do_free(struct snd_card *card)
361 snd_printk(KERN_WARNING "unable to free card info\n"); 361 snd_printk(KERN_WARNING "unable to free card info\n");
362 /* Not fatal error */ 362 /* Not fatal error */
363 } 363 }
364 if (card->dev)
365 device_unregister(card->dev);
364 kfree(card); 366 kfree(card);
365 return 0; 367 return 0;
366} 368}
@@ -495,6 +497,12 @@ int snd_card_register(struct snd_card *card)
495 int err; 497 int err;
496 498
497 snd_assert(card != NULL, return -EINVAL); 499 snd_assert(card != NULL, return -EINVAL);
500 if (!card->dev) {
501 card->dev = device_create(sound_class, card->parent, 0,
502 "card%i", card->number);
503 if (IS_ERR(card->dev))
504 card->dev = NULL;
505 }
498 if ((err = snd_device_register_all(card)) < 0) 506 if ((err = snd_device_register_all(card)) < 0)
499 return err; 507 return err;
500 mutex_lock(&snd_card_mutex); 508 mutex_lock(&snd_card_mutex);
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 505b23ec4058..e0821eb3d851 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2359,7 +2359,8 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file)
2359 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; 2359 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
2360 snd_assert(substream != NULL, return -ENXIO); 2360 snd_assert(substream != NULL, return -ENXIO);
2361 pcm = substream->pcm; 2361 pcm = substream->pcm;
2362 snd_pcm_oss_sync(pcm_oss_file); 2362 if (!pcm->card->shutdown)
2363 snd_pcm_oss_sync(pcm_oss_file);
2363 mutex_lock(&pcm->open_mutex); 2364 mutex_lock(&pcm->open_mutex);
2364 snd_pcm_oss_release_file(pcm_oss_file); 2365 snd_pcm_oss_release_file(pcm_oss_file);
2365 mutex_unlock(&pcm->open_mutex); 2366 mutex_unlock(&pcm->open_mutex);
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index fbbbcd20c4cc..5ac6e19ccb41 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -910,7 +910,8 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream)
910 substream->pstr->substream_opened--; 910 substream->pstr->substream_opened--;
911} 911}
912 912
913static ssize_t show_pcm_class(struct class_device *class_device, char *buf) 913static ssize_t show_pcm_class(struct device *dev,
914 struct device_attribute *attr, char *buf)
914{ 915{
915 struct snd_pcm *pcm; 916 struct snd_pcm *pcm;
916 const char *str; 917 const char *str;
@@ -921,7 +922,7 @@ static ssize_t show_pcm_class(struct class_device *class_device, char *buf)
921 [SNDRV_PCM_CLASS_DIGITIZER] = "digitizer", 922 [SNDRV_PCM_CLASS_DIGITIZER] = "digitizer",
922 }; 923 };
923 924
924 if (! (pcm = class_get_devdata(class_device)) || 925 if (! (pcm = dev_get_drvdata(dev)) ||
925 pcm->dev_class > SNDRV_PCM_CLASS_LAST) 926 pcm->dev_class > SNDRV_PCM_CLASS_LAST)
926 str = "none"; 927 str = "none";
927 else 928 else
@@ -929,7 +930,7 @@ static ssize_t show_pcm_class(struct class_device *class_device, char *buf)
929 return snprintf(buf, PAGE_SIZE, "%s\n", str); 930 return snprintf(buf, PAGE_SIZE, "%s\n", str);
930} 931}
931 932
932static struct class_device_attribute pcm_attrs = 933static struct device_attribute pcm_attrs =
933 __ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL); 934 __ATTR(pcm_class, S_IRUGO, show_pcm_class, NULL);
934 935
935static int snd_pcm_dev_register(struct snd_device *device) 936static int snd_pcm_dev_register(struct snd_device *device)
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 37b4b10850ae..66e24b5da469 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1310,7 +1310,8 @@ static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream,
1310 int f_flags) 1310 int f_flags)
1311{ 1311{
1312 struct snd_pcm_runtime *runtime = substream->runtime; 1312 struct snd_pcm_runtime *runtime = substream->runtime;
1313 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 1313 if (runtime->status->state == SNDRV_PCM_STATE_OPEN ||
1314 runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED)
1314 return -EBADFD; 1315 return -EBADFD;
1315 if (snd_pcm_running(substream)) 1316 if (snd_pcm_running(substream))
1316 return -EBUSY; 1317 return -EBUSY;
@@ -1568,7 +1569,8 @@ static int snd_pcm_drop(struct snd_pcm_substream *substream)
1568 runtime = substream->runtime; 1569 runtime = substream->runtime;
1569 card = substream->pcm->card; 1570 card = substream->pcm->card;
1570 1571
1571 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 1572 if (runtime->status->state == SNDRV_PCM_STATE_OPEN ||
1573 runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED)
1572 return -EBADFD; 1574 return -EBADFD;
1573 1575
1574 snd_power_lock(card); 1576 snd_power_lock(card);
diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c
index 412dd62b654e..9f7b32e1ccde 100644
--- a/sound/core/rtctimer.c
+++ b/sound/core/rtctimer.c
@@ -22,13 +22,10 @@
22 22
23#include <sound/driver.h> 23#include <sound/driver.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/time.h>
26#include <linux/threads.h>
27#include <linux/interrupt.h> 25#include <linux/interrupt.h>
28#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
29#include <sound/core.h> 27#include <sound/core.h>
30#include <sound/timer.h> 28#include <sound/timer.h>
31#include <sound/info.h>
32 29
33#if defined(CONFIG_RTC) || defined(CONFIG_RTC_MODULE) 30#if defined(CONFIG_RTC) || defined(CONFIG_RTC_MODULE)
34 31
@@ -50,7 +47,9 @@ static int rtctimer_stop(struct snd_timer *t);
50 * The hardware dependent description for this timer. 47 * The hardware dependent description for this timer.
51 */ 48 */
52static struct snd_timer_hardware rtc_hw = { 49static struct snd_timer_hardware rtc_hw = {
53 .flags = SNDRV_TIMER_HW_FIRST|SNDRV_TIMER_HW_AUTO, 50 .flags = SNDRV_TIMER_HW_AUTO |
51 SNDRV_TIMER_HW_FIRST |
52 SNDRV_TIMER_HW_TASKLET,
54 .ticks = 100000000L, /* FIXME: XXX */ 53 .ticks = 100000000L, /* FIXME: XXX */
55 .open = rtctimer_open, 54 .open = rtctimer_open,
56 .close = rtctimer_close, 55 .close = rtctimer_close,
@@ -60,6 +59,7 @@ static struct snd_timer_hardware rtc_hw = {
60 59
61static int rtctimer_freq = RTC_FREQ; /* frequency */ 60static int rtctimer_freq = RTC_FREQ; /* frequency */
62static struct snd_timer *rtctimer; 61static struct snd_timer *rtctimer;
62static struct tasklet_struct rtc_tasklet;
63static rtc_task_t rtc_task; 63static rtc_task_t rtc_task;
64 64
65 65
@@ -81,6 +81,7 @@ rtctimer_close(struct snd_timer *t)
81 rtc_task_t *rtc = t->private_data; 81 rtc_task_t *rtc = t->private_data;
82 if (rtc) { 82 if (rtc) {
83 rtc_unregister(rtc); 83 rtc_unregister(rtc);
84 tasklet_kill(&rtc_tasklet);
84 t->private_data = NULL; 85 t->private_data = NULL;
85 } 86 }
86 return 0; 87 return 0;
@@ -105,12 +106,17 @@ rtctimer_stop(struct snd_timer *timer)
105 return 0; 106 return 0;
106} 107}
107 108
109static void rtctimer_tasklet(unsigned long data)
110{
111 snd_timer_interrupt((struct snd_timer *)data, 1);
112}
113
108/* 114/*
109 * interrupt 115 * interrupt
110 */ 116 */
111static void rtctimer_interrupt(void *private_data) 117static void rtctimer_interrupt(void *private_data)
112{ 118{
113 snd_timer_interrupt(private_data, 1); 119 tasklet_hi_schedule(private_data);
114} 120}
115 121
116 122
@@ -139,9 +145,11 @@ static int __init rtctimer_init(void)
139 timer->hw = rtc_hw; 145 timer->hw = rtc_hw;
140 timer->hw.resolution = NANO_SEC / rtctimer_freq; 146 timer->hw.resolution = NANO_SEC / rtctimer_freq;
141 147
148 tasklet_init(&rtc_tasklet, rtctimer_tasklet, (unsigned long)timer);
149
142 /* set up RTC callback */ 150 /* set up RTC callback */
143 rtc_task.func = rtctimer_interrupt; 151 rtc_task.func = rtctimer_interrupt;
144 rtc_task.private_data = timer; 152 rtc_task.private_data = &rtc_tasklet;
145 153
146 err = snd_timer_global_register(timer); 154 err = snd_timer_global_register(timer);
147 if (err < 0) { 155 if (err < 0) {
diff --git a/sound/core/sound.c b/sound/core/sound.c
index efa476c5210a..282742022de6 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -61,9 +61,6 @@ EXPORT_SYMBOL(snd_ecards_limit);
61static struct snd_minor *snd_minors[SNDRV_OS_MINORS]; 61static struct snd_minor *snd_minors[SNDRV_OS_MINORS];
62static DEFINE_MUTEX(sound_mutex); 62static DEFINE_MUTEX(sound_mutex);
63 63
64extern struct class *sound_class;
65
66
67#ifdef CONFIG_KMOD 64#ifdef CONFIG_KMOD
68 65
69/** 66/**
@@ -268,11 +265,10 @@ int snd_register_device(int type, struct snd_card *card, int dev,
268 snd_minors[minor] = preg; 265 snd_minors[minor] = preg;
269 if (card) 266 if (card)
270 device = card->dev; 267 device = card->dev;
271 preg->class_dev = class_device_create(sound_class, NULL, 268 preg->dev = device_create(sound_class, device, MKDEV(major, minor),
272 MKDEV(major, minor), 269 "%s", name);
273 device, "%s", name); 270 if (preg->dev)
274 if (preg->class_dev) 271 dev_set_drvdata(preg->dev, private_data);
275 class_set_devdata(preg->class_dev, private_data);
276 272
277 mutex_unlock(&sound_mutex); 273 mutex_unlock(&sound_mutex);
278 return 0; 274 return 0;
@@ -320,7 +316,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
320 return -EINVAL; 316 return -EINVAL;
321 } 317 }
322 318
323 class_device_destroy(sound_class, MKDEV(major, minor)); 319 device_destroy(sound_class, MKDEV(major, minor));
324 320
325 kfree(snd_minors[minor]); 321 kfree(snd_minors[minor]);
326 snd_minors[minor] = NULL; 322 snd_minors[minor] = NULL;
@@ -331,15 +327,15 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
331EXPORT_SYMBOL(snd_unregister_device); 327EXPORT_SYMBOL(snd_unregister_device);
332 328
333int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev, 329int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
334 const struct class_device_attribute *attr) 330 struct device_attribute *attr)
335{ 331{
336 int minor, ret = -EINVAL; 332 int minor, ret = -EINVAL;
337 struct class_device *cdev; 333 struct device *d;
338 334
339 mutex_lock(&sound_mutex); 335 mutex_lock(&sound_mutex);
340 minor = find_snd_minor(type, card, dev); 336 minor = find_snd_minor(type, card, dev);
341 if (minor >= 0 && (cdev = snd_minors[minor]->class_dev) != NULL) 337 if (minor >= 0 && (d = snd_minors[minor]->dev) != NULL)
342 ret = class_device_create_file(cdev, attr); 338 ret = device_create_file(d, attr);
343 mutex_unlock(&sound_mutex); 339 mutex_unlock(&sound_mutex);
344 return ret; 340 return ret;
345 341
diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
index 6e3c41f530e6..b1c5d8286e40 100644
--- a/sound/oss/cs46xx.c
+++ b/sound/oss/cs46xx.c
@@ -779,7 +779,7 @@ static unsigned int cs_set_adc_rate(struct cs_state *state, unsigned int rate)
779 rate = 48000 / 9; 779 rate = 48000 / 9;
780 780
781 /* 781 /*
782 * We can not capture at at rate greater than the Input Rate (48000). 782 * We cannot capture at at rate greater than the Input Rate (48000).
783 * Return an error if an attempt is made to stray outside that limit. 783 * Return an error if an attempt is made to stray outside that limit.
784 */ 784 */
785 if (rate > 48000) 785 if (rate > 48000)
@@ -4754,8 +4754,8 @@ static int cs_hardware_init(struct cs_card *card)
4754 mdelay(5 * cs_laptop_wait); /* Shouldnt be needed ?? */ 4754 mdelay(5 * cs_laptop_wait); /* Shouldnt be needed ?? */
4755 4755
4756/* 4756/*
4757* If we are resuming under 2.2.x then we can not schedule a timeout. 4757* If we are resuming under 2.2.x then we cannot schedule a timeout,
4758* so, just spin the CPU. 4758* so just spin the CPU.
4759*/ 4759*/
4760 if (card->pm.flags & CS46XX_PM_IDLE) { 4760 if (card->pm.flags & CS46XX_PM_IDLE) {
4761 /* 4761 /*
diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
index 2344d09c7114..75c5e745705f 100644
--- a/sound/oss/soundcard.c
+++ b/sound/oss/soundcard.c
@@ -557,17 +557,17 @@ static int __init oss_init(void)
557 sound_dmap_flag = (dmabuf > 0 ? 1 : 0); 557 sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
558 558
559 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) { 559 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
560 class_device_create(sound_class, NULL, 560 device_create(sound_class, NULL,
561 MKDEV(SOUND_MAJOR, dev_list[i].minor), 561 MKDEV(SOUND_MAJOR, dev_list[i].minor),
562 NULL, "%s", dev_list[i].name); 562 "%s", dev_list[i].name);
563 563
564 if (!dev_list[i].num) 564 if (!dev_list[i].num)
565 continue; 565 continue;
566 566
567 for (j = 1; j < *dev_list[i].num; j++) 567 for (j = 1; j < *dev_list[i].num; j++)
568 class_device_create(sound_class, NULL, 568 device_create(sound_class, NULL,
569 MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)), 569 MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
570 NULL, "%s%d", dev_list[i].name, j); 570 "%s%d", dev_list[i].name, j);
571 } 571 }
572 572
573 if (sound_nblocks >= 1024) 573 if (sound_nblocks >= 1024)
@@ -581,11 +581,11 @@ static void __exit oss_cleanup(void)
581 int i, j; 581 int i, j;
582 582
583 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) { 583 for (i = 0; i < sizeof (dev_list) / sizeof *dev_list; i++) {
584 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor)); 584 device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor));
585 if (!dev_list[i].num) 585 if (!dev_list[i].num)
586 continue; 586 continue;
587 for (j = 1; j < *dev_list[i].num; j++) 587 for (j = 1; j < *dev_list[i].num; j++)
588 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10))); 588 device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
589 } 589 }
590 590
591 unregister_sound_special(1); 591 unregister_sound_special(1);
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 8058059c56e9..8bc4ffa6220d 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -956,6 +956,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
956 .ca0151_chip = 1, 956 .ca0151_chip = 1,
957 .spk71 = 1, 957 .spk71 = 1,
958 .spdif_bug = 1, 958 .spdif_bug = 1,
959 .adc_1361t = 1, /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */
959 .ac97_chip = 1} , 960 .ac97_chip = 1} ,
960 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, 961 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04,
961 .driver = "Audigy2", .name = "Audigy 2 [Unknown]", 962 .driver = "Audigy2", .name = "Audigy 2 [Unknown]",
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 0d728c6f697c..fb961448db19 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5870,7 +5870,7 @@ static struct hda_board_config alc262_cfg_tbl[] = {
5870 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, 5870 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
5871 .config = ALC262_FUJITSU }, 5871 .config = ALC262_FUJITSU },
5872 { .modelname = "hp-bpc", .config = ALC262_HP_BPC }, 5872 { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
5873 { .pci_subvendor = 0x103c, .pci_subdevice = 0x208c, 5873 { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
5874 .config = ALC262_HP_BPC }, /* xw4400 */ 5874 .config = ALC262_HP_BPC }, /* xw4400 */
5875 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, 5875 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
5876 .config = ALC262_HP_BPC }, /* xw6400 */ 5876 .config = ALC262_HP_BPC }, /* xw6400 */
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 731b7b97ee71..fe51ef3e49d2 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -336,6 +336,13 @@ static struct hda_board_config stac9200_cfg_tbl[] = {
336 .pci_subvendor = PCI_VENDOR_ID_INTEL, 336 .pci_subvendor = PCI_VENDOR_ID_INTEL,
337 .pci_subdevice = 0x2668, /* DFI LanParty */ 337 .pci_subdevice = 0x2668, /* DFI LanParty */
338 .config = STAC_REF }, 338 .config = STAC_REF },
339 /* Dell laptops have BIOS problem */
340 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01b5,
341 .config = STAC_REF }, /* Dell Inspiron 630m */
342 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01c2,
343 .config = STAC_REF }, /* Dell Latitude D620 */
344 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01cb,
345 .config = STAC_REF }, /* Dell Latitude 120L */
339 {} /* terminator */ 346 {} /* terminator */
340}; 347};
341 348
@@ -591,13 +598,6 @@ static struct hda_board_config stac9205_cfg_tbl[] = {
591 .pci_subvendor = PCI_VENDOR_ID_INTEL, 598 .pci_subvendor = PCI_VENDOR_ID_INTEL,
592 .pci_subdevice = 0x2668, /* DFI LanParty */ 599 .pci_subdevice = 0x2668, /* DFI LanParty */
593 .config = STAC_REF }, /* SigmaTel reference board */ 600 .config = STAC_REF }, /* SigmaTel reference board */
594 /* Dell laptops have BIOS problem */
595 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01b5,
596 .config = STAC_REF }, /* Dell Inspiron 630m */
597 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01c2,
598 .config = STAC_REF }, /* Dell Latitude D620 */
599 { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01cb,
600 .config = STAC_REF }, /* Dell Latitude 120L */
601 {} /* terminator */ 601 {} /* terminator */
602}; 602};
603 603
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 5322c50c9617..8f1ced4ab34c 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -170,8 +170,8 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati
170 else 170 else
171 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); 171 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
172 172
173 class_device_create(sound_class, NULL, MKDEV(SOUND_MAJOR, s->unit_minor), 173 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
174 dev, s->name+6); 174 s->name+6);
175 return r; 175 return r;
176 176
177 fail: 177 fail:
@@ -193,7 +193,7 @@ static void sound_remove_unit(struct sound_unit **list, int unit)
193 p = __sound_remove_unit(list, unit); 193 p = __sound_remove_unit(list, unit);
194 spin_unlock(&sound_loader_lock); 194 spin_unlock(&sound_loader_lock);
195 if (p) { 195 if (p) {
196 class_device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor)); 196 device_destroy(sound_class, MKDEV(SOUND_MAJOR, p->unit_minor));
197 kfree(p); 197 kfree(p);
198 } 198 }
199} 199}
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index c82b01c7ad3a..67202b9eeb77 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -1469,7 +1469,8 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
1469 subs->cur_audiofmt = NULL; 1469 subs->cur_audiofmt = NULL;
1470 subs->cur_rate = 0; 1470 subs->cur_rate = 0;
1471 subs->period_bytes = 0; 1471 subs->period_bytes = 0;
1472 release_substream_urbs(subs, 0); 1472 if (!subs->stream->chip->shutdown)
1473 release_substream_urbs(subs, 0);
1473 return snd_pcm_free_vmalloc_buffer(substream); 1474 return snd_pcm_free_vmalloc_buffer(substream);
1474} 1475}
1475 1476
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index b7c5e59b2299..24f5a26c5f0c 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -981,7 +981,7 @@ void snd_usbmidi_disconnect(struct list_head* p)
981 if (umidi->usb_protocol_ops->finish_out_endpoint) 981 if (umidi->usb_protocol_ops->finish_out_endpoint)
982 umidi->usb_protocol_ops->finish_out_endpoint(ep->out); 982 umidi->usb_protocol_ops->finish_out_endpoint(ep->out);
983 } 983 }
984 if (ep->in && ep->in->urb) 984 if (ep->in)
985 usb_kill_urb(ep->in->urb); 985 usb_kill_urb(ep->in->urb);
986 } 986 }
987} 987}
diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c
index 1024c178f5c0..e74eb1bc8d87 100644
--- a/sound/usb/usbmixer.c
+++ b/sound/usb/usbmixer.c
@@ -1620,8 +1620,7 @@ static void snd_usb_mixer_free(struct usb_mixer_interface *mixer)
1620 kfree(mixer->urb->transfer_buffer); 1620 kfree(mixer->urb->transfer_buffer);
1621 usb_free_urb(mixer->urb); 1621 usb_free_urb(mixer->urb);
1622 } 1622 }
1623 if (mixer->rc_urb) 1623 usb_free_urb(mixer->rc_urb);
1624 usb_free_urb(mixer->rc_urb);
1625 kfree(mixer->rc_setup_packet); 1624 kfree(mixer->rc_setup_packet);
1626 kfree(mixer); 1625 kfree(mixer);
1627} 1626}
@@ -2056,8 +2055,6 @@ void snd_usb_mixer_disconnect(struct list_head *p)
2056 struct usb_mixer_interface *mixer; 2055 struct usb_mixer_interface *mixer;
2057 2056
2058 mixer = list_entry(p, struct usb_mixer_interface, list); 2057 mixer = list_entry(p, struct usb_mixer_interface, list);
2059 if (mixer->urb) 2058 usb_kill_urb(mixer->urb);
2060 usb_kill_urb(mixer->urb); 2059 usb_kill_urb(mixer->rc_urb);
2061 if (mixer->rc_urb)
2062 usb_kill_urb(mixer->rc_urb);
2063} 2060}
diff --git a/usr/Makefile b/usr/Makefile
index e338e7bedb29..382702ad663b 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -20,7 +20,7 @@ $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE
20hostprogs-y := gen_init_cpio 20hostprogs-y := gen_init_cpio
21initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh 21initramfs := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
22ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ 22ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
23 $(CONFIG_INITRAMFS_SOURCE),-d) 23 $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
24ramfs-args := \ 24ramfs-args := \
25 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ 25 $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
26 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) 26 $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))